TextureSampler

A TextureSampler is an loose coupling association of a Texture and sampling properties, such as filtering and wrap properties. A TextureSampler can be used in places where a Texture is used, so that the Texture will use these sampling properties when used by the shader, allowing the same Texture to be used multiple times within the same shader with different sampling properties. This is necessary for some situations, such as an environment lighting texture, which requires a mipmap, to also be used as a sky sphere background texture, which should not use mipmap filtering.

A TextureSampler will create a GLSampler as its RenderAsset.

Constructor

new L3D.TextureSampler(texture, options)

Parameters
texture Texture | GLTexture

The texture to associate with this sampler.

options Object

Optional configuration for the sampler.

Properties
minFilter number GL.LINEAR
magFilter number GL.LINEAR
filter number

Sets both minFilter and magFilter to the same value.

wrapS number GL.CLAMP_TO_EDGE
wrapT number GL.CLAMP_TO_EDGE
wrapR number GL.CLAMP_TO_EDGE
wrap number

Sets both wrapS and wrapT to the same value.

Extends

Properties

Overrides:
filename String

Get the filename of the asset.

Overrides:
id String

The unique identifier of the object. Changing a node's ID can have unintended consequences.

Overrides:
isLoaded bool

Is the texture loaded and ready to use?

Overrides:
isLoading bool

True if the asset is in the process of loading.

Overrides:
isValid bool

True if the asset does not have an error.

magFilter number = GL.LINEAR

The WebGL magFilter type. Can be: GL.NEAREST, or GL.LINEAR.

minFilter number = GL.LINEAR

The WebGL minFilter type. Can be: GL.NEAREST, GL.LINEAR, GL.LINEAR_MIPMAP_LINEAR, GL.LINEAR_MIPMAP_NEAREST, GL.NEAREST_MIPMAP_LINEAR, or GL.NEAREST_MIPMAP_NEAREST.

mipmap bool = false

True if the filtering requires the texture to have a mipmap. Setting this property will change the minFilter.

Overrides:
name String

The name of the object.

Overrides:
onError Signal

Emitted when there was an error loaading the asset.

Overrides:
onLoad Signal

Emitted when the asset has finished loading.

Overrides:
onLoading Signal

Emitted when the asset has started loading.

Overrides:
onModified Signal

Fired when the object has been modified.

Overrides:
onNameChanged Signal

Fired when the object's name changes.

Overrides:
onStateChange Signal

Emitted when the state of the asset has changed.

Overrides:
onUpdate Signal

Emitted when the assets data has been updated.

Overrides:
path String

The URL of the asset.

Overrides:
state number

Inidicates whether the asset is Unloaded, Loading, Loaded, or Error. The onStateChange signal will be emitted when the state's value changes.

texture Texture

The texture associated with this sampler.

wrapR number = GL.CLAMP_TO_EDGE

The WebGL wrapR type. Can be: GL.REPEAT, GL.CLAMP_TO_EDGE, or GL.MIRRORED_REPEAT

wrapS number = GL.CLAMP_TO_EDGE

The WebGL wrapS type. Can be: GL.REPEAT, GL.CLAMP_TO_EDGE, or GL.MIRRORED_REPEAT

wrapT number = GL.CLAMP_TO_EDGE

The WebGL wrapT type. Can be: GL.REPEAT, GL.CLAMP_TO_EDGE, or GL.MIRRORED_REPEAT

Methods

clone(options) → Object

Overrides:

Creates a clone of this object.

Parameters
options Object

Options for the clone method.

Returns
Object

configure(options)

Overrides:

Set the properties of the sampler object.

Parameters
options Object
Properties
minFilter number GL.LINEAR
magFilter number GL.LINEAR
filter number

Sets both minFilter and magFilter to the same value.

wrapS number GL.CLAMP_TO_EDGE
wrapT number GL.CLAMP_TO_EDGE
wrapR number GL.CLAMP_TO_EDGE
wrap number

Sets both wrapS and wrapT to the same value.

destroy()

Overrides:

Destroy any render assets created by the asset.

getPropertyInfo(path) → Object

Overrides:

Get information about a particular property of this object.

Parameters
path String
Returns
Object

getRenderAsset(gl)RenderAsset

Overrides:

Get a RenderAsset for this asset. If a RenderAsset hadn't been requested for the given GLContext yet, a new one will be created. Otherwise the previous one will be updated and returned.

A RenderAsset is the WebGL version of the asset, such as the GLTexture for an Texture asset. Because the editor has multiple GLContexts, RenderAssets are generated for each GLContext that requires it.

Parameters
gl GLContext
Returns
RenderAsset

serialize() → Object

Overrides:

Serialize the object to a JSON structure.

Returns
Object

The serialized version of the object.

setModified()

Overrides:

Fires the objects onModified signal.

toJSON() → Object

Overrides:

Serialize the object to a JSON structure

Returns
Object

The serialized version of the object.

updateRenderAsset(renderAsset)

Overrides:

Called to create the WebGL and/or pdate the object for this asset, in this case a WebGLSampler.

Parameters
renderAsset RenderAsset

The RenderAsset object to udpate for this asset.