Material

1.2.0+

Wrapper around a native material.

For more information about how to create materials, have a look at the MaterialManager class.

Properties 

The material properties are automatically converted into getters/setters:

1const material = new PhongMaterial();
2
3// Set the `diffuseColor` property
4material.setDiffuseColor([1.0, 0.0, 0.0, 1.0]);
5console.log(material.getDiffuseColor());

Getters for non-scalar types have an optional argument to skip an array allocation:

1const material = new PhongMaterial();
2const diffuse = [0, 0, 0, 0];
3material.getDiffuseColor(diffuse);
4console.log(diffuse) // Prints '[1.0, 1.0, 1.0, 1.0]'

Note: Materials are per-engine, they can thus be shared by multiple scenes.

.constructor(engine: WonderlandEngine, params: number | MaterialParameters) ⇒ Material 

Deprecated: Use getTemplate via materials to create a new material with a given pipeline:

1const PhongMaterial = engine.materials.getTemplate('Phong Opaque');
2const material = new PhongMaterial();
3material.setDiffuseColor([1, 0, 0]);
ParamTypeDescription
engineWonderlandEngine
paramsnumber | MaterialParameters

._destroyedPrototype: { _ } 

Proxy used to override prototypes of destroyed materials.

.pipeline: string 

Name of the pipeline used by this material.

.shader: string 

Deprecated: Use pipeline instead.

.clone() ⇒ null | Material 

Create a copy of the underlying native material.

Returns: Material clone.

.hasParameter(name: string) ⇒ boolean 

Check whether a parameter exists on this material.

Returns: true if the parameter with name name exists on this material, false otherwise.

ParamTypeDescription
namestringThe name to check.

.toString() ⇒ string 

Material.wrap(engine: WonderlandEngine, index: number) ⇒ null | Material 

Wrap a native material index.

Returns: Material instance or null if index <= 0.

Deprecated: Use the materials instead.

ParamTypeDescription
engineWonderlandEngineEngine instance.
indexnumberThe index.