Skip to main content

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​
ParameterTypeDescription
entitynumberThe Entity to assign the material to.
submeshIndex?numberThe 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​

ParameterTypeDescription
handlenumberThe 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​

ParameterTypeDescription
handlenumberThe Material to update.
propertyMaterialPropertyThe property to change.
valuenumberThe 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​

ParameterTypeDescription
handlenumberThe Material to inspect.
propertyMaterialPropertyThe 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​

ParameterTypeDescription
handlenumberThe Material to update.
propertyMaterialPropertyThe property to change.
valuevec4The 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​

ParameterTypeDescription
handlenumberThe Material to inspect.
propertyMaterialPropertyThe 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​

ParameterTypeDescription
handlenumberThe Material to update.
propertyMaterialPropertyThe property to change.
rgbavec4The 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​

ParameterTypeDescription
handlenumberThe Material to inspect.
propertyMaterialPropertyThe 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​

ParameterTypeDescription
handlenumberThe Material to update.
propertyMaterialPropertyThe property to change.
texturenumberThe 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​

ParameterTypeDescription
handlenumberThe Material to inspect.
propertyMaterialPropertyThe 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​

ParameterTypeDescription
handlenumberThe Material to update.
alphaMode?AlphaModeThe 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​

ParameterTypeDescription
handlenumberThe Material to inspect.

Returns​

Promise<AlphaMode>

A promise that resolves to the alpha mode.