Material
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:
Getters for non-scalar types have an optional argument to skip an array allocation:
Note: Materials are per-engine, they can thus be shared by multiple scenes.
TypeScript
The Wonderland Editor can automatically generate material definitions (.d.ts) from the project pipelines.
To enable the generation, go to the Project Settings > JavaScript
panel and
set materialDefinitions
to a path, e.g., materials.d.ts
.
It’s then possible to cast the material type using:
- Material
.constructor(engine, params) ⇒ Material- .pipeline
.shader- .clone() ⇒ null | Material
- .hasParameter(name) ⇒ boolean
- .toString() ⇒ string
Material.wrap(engine, index) ⇒ null | Material
.constructor(engine: WonderlandEngine, params: number | MaterialParameters) ⇒ Material
Deprecated: Use getTemplate via materials to create a new material with a given pipeline:
Param | Type | Description |
---|---|---|
engine | WonderlandEngine | |
params | number | MaterialParameters |
.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.
Param | Type | Description |
---|---|---|
name | string | The 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.
Param | Type | Description |
---|---|---|
engine | WonderlandEngine | Engine instance. |
index | number | The index. |