Class: MaterialManager
Creates and updates materials.
Constructors
Constructor
new MaterialManager(): MaterialManager;
Returns
MaterialManager
Methods
Create()
Call Signature
static Create(): Promise<number>;
Creates a material.
Returns
Promise<number>
A promise that resolves to the created Material.
Call Signature
static Create(entity, submeshIndex?): Promise<number>;
Creates a material and assigns it to an entity.
Parameters
| Parameter | Type | Description |
|---|---|---|
entity | number | The Entity to assign the material to. |
submeshIndex? | number | The submesh index to assign the material to. Defaults to 0. |
Returns
Promise<number>
A promise that resolves to the created Material.
Destroy()
static Destroy(handle): Promise<boolean>;
Destroys a material.
Parameters
| Parameter | Type | Description |
|---|---|---|
handle | number | The Material to destroy. |
Returns
Promise<boolean>
A promise that resolves to true if the material was destroyed, or
false otherwise.
SetFloat()
static SetFloat(
handle,
property,
value): Promise<void>;
Sets a numeric property on a material.
Parameters
| Parameter | Type | Description |
|---|---|---|
handle | number | The Material to update. |
property | MaterialProperty | The property to change. |
value | number | The numeric value to assign. |
Returns
Promise<void>
A promise that resolves when the property has been changed.
GetFloat()
static GetFloat(handle, property): Promise<number>;
Gets a numeric property from a material.
Parameters
| Parameter | Type | Description |
|---|---|---|
handle | number | The Material to inspect. |
property | MaterialProperty | The property to read. |
Returns
Promise<number>
A promise that resolves to the numeric property value.
SetVector()
static SetVector(
handle,
property,
value): Promise<void>;
Sets a vector property on a material.
Parameters
| Parameter | Type | Description |
|---|---|---|
handle | number | The Material to update. |
property | MaterialProperty | The property to change. |
value | vec4 | The vector value to assign. |
Returns
Promise<void>
A promise that resolves when the property has been changed.
GetVector()
static GetVector(handle, property): Promise<vec4>;
Gets a vector property from a material.
Parameters
| Parameter | Type | Description |
|---|---|---|
handle | number | The Material to inspect. |
property | MaterialProperty | The property to read. |
Returns
Promise<vec4>
A promise that resolves to the vector property value.
SetColor()
static SetColor(
handle,
property,
rgba): Promise<void>;
Sets a color property on a material.
Parameters
| Parameter | Type | Description |
|---|---|---|
handle | number | The Material to update. |
property | MaterialProperty | The property to change. |
rgba | vec4 | The color value to assign as an RGBA vec4, with each channel in the range [0.0, 1.0]. For HDR emission, values greater than 1.0 are supported. |
Returns
Promise<void>
A promise that resolves when the property has been changed.
GetColor()
static GetColor(handle, property): Promise<vec4>;
Gets a color property from a material.
Parameters
| Parameter | Type | Description |
|---|---|---|
handle | number | The Material to inspect. |
property | MaterialProperty | The property to read. |
Returns
Promise<vec4>
A promise that resolves to the color value as an RGBA vec4, with
each channel in the range [0.0, 1.0].
SetTexture()
static SetTexture(
handle,
property,
texture): Promise<void>;
Sets a texture property on a material.
Parameters
| Parameter | Type | Description |
|---|---|---|
handle | number | The Material to update. |
property | MaterialProperty | The property to change. |
texture | number | The Texture to assign. |
Returns
Promise<void>
A promise that resolves when the property has been changed.
GetTexture()
static GetTexture(handle, property): Promise<number>;
Gets a texture property from a material.
Parameters
| Parameter | Type | Description |
|---|---|---|
handle | number | The Material to inspect. |
property | MaterialProperty | The property to read. |
Returns
Promise<number>
A promise that resolves to the assigned Texture.
SetAlphaMode()
static SetAlphaMode(handle, alphaMode?): Promise<void>;
Sets the alpha mode of a material.
Parameters
| Parameter | Type | Description |
|---|---|---|
handle | number | The Material to update. |
alphaMode? | AlphaMode | The alpha mode to assign. Defaults to AlphaMode.Opaque. |
Returns
Promise<void>
A promise that resolves when the alpha mode has been changed.
GetAlphaMode()
static GetAlphaMode(handle): Promise<AlphaMode>;
Gets the alpha mode of a material.
Parameters
| Parameter | Type | Description |
|---|---|---|
handle | number | The Material to inspect. |
Returns
Promise<AlphaMode>
A promise that resolves to the alpha mode.