Material

A Material are used to render geometry. They associate uniform values and RenderState with a Shader. Multiple Materials can reference the same Shader.

Constructor

new L3D.Material()

Extends

Properties

castShadows bool

If true, the object with this material will be included in shadow rendering.

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.

ignoreFrustum bool

If true, objects with this material will not be skipped if they are not visible by the camera.

ignoreLights bool

If true, the material will not calculate any lighting.

Overrides:
isLoaded bool

Is the asset loaded?

Overrides:
isLoading bool

Is the asset loading?

Overrides:
isValid bool

True if the asset does not have an error.

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.

properties Object

The public properties of the shader.

queue RenderQueue

The RenderQueue to use.

receiveShadows bool

If true, the material will evaluate shadow maps from lights.

renderState RenderState

The RenderState to apply when rendering this material.

shader String

The name of the shader used by this material.

shaderAsset Shader

The shader used by this material.

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.

twoSided bool

If true, the material will not do any backface culling.

uniforms Object

The shader uniforms set by this material.

useSceneAmbient bool

If true, the material will recieve ambient light.

Methods

clone(options) → Object

Overrides:

Creates a clone of this object.

Parameters
options Object

Options for the clone method.

Returns
Object

configure(o)

Overrides:

Load the material from a JSON object.

Parameters
o Object

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 this material to a JSON object

Returns
Object

setModified()

Overrides:

Fires the objects onModified signal.

setProperty(name, value, add)

Set a property value for the material. This will result in setting a uniform value on the associated shader.

Parameters
name String

The name of the property.

value *

The value to set the property to.

add bool

Add the property if the property hasn't been found on the material, perhaps because the material is still loading.

toJSON() → Object

Overrides:

Serialize the object to a JSON structure

Returns
Object

The serialized version of the object.

updateRenderAsset(renderAsset)

Overrides:

Update the given RenderAsset.

Parameters
renderAsset RenderAsset

The RenderAsset to update.