Skip to main content

Class: RenderableManager

Creates and updates renderable components.

Because runtime calls are performed asynchronously over IPC, procedurally building a renderable through a sequence of API calls can span multiple frames. To avoid exposing partially initialized content, such as placeholder shaders or incomplete meshes, keep the component disabled until setup is complete, then enable it once the renderable is ready.

Constructors

Constructor

new RenderableManager(): RenderableManager;

Returns

RenderableManager

Methods

Create()

static Create(entity, isSkinnedMesh?): Promise<boolean>;

Creates a renderable component on an entity.

Parameters

ParameterTypeDescription
entitynumberThe Entity to update.
isSkinnedMesh?booleanWhether the renderable should be created as a skinned mesh. Defaults to false. Blend shapes only work when this is true.

Returns

Promise<boolean>

A promise that resolves to true if the renderable component was created, or false otherwise.


Destroy()

static Destroy(entity): Promise<boolean>;

Removes a renderable component from an entity.

Parameters

ParameterTypeDescription
entitynumberThe Entity to update.

Returns

Promise<boolean>

A promise that resolves to true if the renderable component was removed, or false otherwise.


HasComponent()

static HasComponent(entity): Promise<boolean>;

Checks whether an entity has a renderable component.

Parameters

ParameterTypeDescription
entitynumberThe Entity to inspect.

Returns

Promise<boolean>

A promise that resolves to true if the entity has a renderable component, or false otherwise.


SetEnabled()

static SetEnabled(entity, enabled): Promise<void>;

Sets whether a renderable component is enabled.

Parameters

ParameterTypeDescription
entitynumberThe Entity to update.
enabledbooleanWhether the renderable component is enabled.

Returns

Promise<void>

A promise that resolves when the enabled state has been changed.


GetEnabled()

static GetEnabled(entity): Promise<boolean>;

Gets whether a renderable component is enabled.

Parameters

ParameterTypeDescription
entitynumberThe Entity to inspect.

Returns

Promise<boolean>

A promise that resolves to true if the renderable component is enabled, or false otherwise.


SetMesh()

static SetMesh(entity, mesh): Promise<void>;

Sets the mesh of a renderable component.

Parameters

ParameterTypeDescription
entitynumberThe Entity to update.
meshnumberThe Mesh to assign.

Returns

Promise<void>

A promise that resolves when the mesh has been changed.


GetMesh()

static GetMesh(entity): Promise<number>;

Gets the mesh of a renderable component.

Parameters

ParameterTypeDescription
entitynumberThe Entity to inspect.

Returns

Promise<number>

A promise that resolves to the assigned Mesh.

Throws

An error if no mesh is assigned to the renderable component.


SetBlendShapeWeight()

static SetBlendShapeWeight(
entity,
index,
weight): Promise<void>;

Sets the weight of a blend shape.

Parameters

ParameterTypeDescription
entitynumberThe Entity to update.
indexnumberThe blend shape index.
weightnumberThe blend shape weight in the range [0.0, 1.0].

Returns

Promise<void>

A promise that resolves when the blend shape weight has been changed.


GetBlendShapeWeight()

static GetBlendShapeWeight(entity, index): Promise<number>;

Gets the weight of a blend shape.

Parameters

ParameterTypeDescription
entitynumberThe Entity to inspect.
indexnumberThe blend shape index.

Returns

Promise<number>

A promise that resolves to the blend shape weight.


SetMaterial()

static SetMaterial(
entity,
material,
index?): Promise<void>;

Sets the material of a renderable component.

Parameters

ParameterTypeDescription
entitynumberThe Entity to update.
materialnumberThe Material to assign.
index?numberThe material index. Defaults to 0.

Returns

Promise<void>

A promise that resolves when the material has been changed.


GetMaterial()

static GetMaterial(entity, index?): Promise<number>;

Gets the material of a renderable component.

Parameters

ParameterTypeDescription
entitynumberThe Entity to inspect.
index?numberThe material index. Defaults to 0.

Returns

Promise<number>

A promise that resolves to the assigned Material.

Throws

An error if no material is assigned to the renderable component at the given index.


SetReceiveShadows()

static SetReceiveShadows(entity, receive): Promise<void>;

Sets whether a renderable component receives shadows.

Parameters

ParameterTypeDescription
entitynumberThe Entity to update.
receivebooleanWhether the renderable component receives shadows.

Returns

Promise<void>

A promise that resolves when the receive-shadows setting has been changed.


GetReceiveShadows()

static GetReceiveShadows(entity): Promise<boolean>;

Gets whether a renderable component receives shadows.

Parameters

ParameterTypeDescription
entitynumberThe Entity to inspect.

Returns

Promise<boolean>

A promise that resolves to true if the renderable component receives shadows, or false otherwise.


SetShadowMode()

static SetShadowMode(entity, shadowMode): Promise<void>;

Sets the shadow casting mode of a renderable component.

Parameters

ParameterTypeDescription
entitynumberThe Entity to update.
shadowModeShadowCastingModeThe shadow casting mode to assign.

Returns

Promise<void>

A promise that resolves when the shadow casting mode has been changed.


GetShadowMode()

static GetShadowMode(entity): Promise<ShadowCastingMode>;

Gets the shadow casting mode of a renderable component.

Parameters

ParameterTypeDescription
entitynumberThe Entity to inspect.

Returns

Promise<ShadowCastingMode>

A promise that resolves to the shadow casting mode.