MaterialManager

Manage materials.

Creation 

To create a material, first retrieve the class associated to the pipeline using getTemplate:

1const PhongMaterial = engine.materials.getTemplate('Phong Opaque');

Creating a material is then done using the constructor:

1const material = new PhongMaterial();
2material.setDiffuseColor([1.0, 0.0, 0.0, 1.0]);

._wrapInstance(instance: Material) ⇒ Material 

Wrap a material instance.

@todo: Remove at 2.0.0.

Note: Wrapping should only be called once per instance.

Returns: The new material, wrapped in a proxy.

ParamTypeDescription
instanceMaterialThe material instance.

.getTemplate<T>(pipeline: string) ⇒ MaterialConstructor 

Get the material class with the given pipeline name.

Usage 

1const PhongMaterial = engine.materials.getTemplate('Phong Opaque');
2const material = new PhongMaterial();
3material.setDiffuseColor([1.0, 0.0, 0.0, 1.0]);

Returns: The material class.

Throws: Error if the material class doesn’t exist.

ParamTypeDescription
pipelinestringThe pipeline name to search for.
Template ParamType Definition
Textends Material

.wrap(index: number) ⇒ null | Material 

ParamTypeDescription
indexnumber