Skip to main content

Interface: RenderableManager

Factory and manager for \em renderables, which are entities that can be drawn.

Renderables are bundles of \em primitives, each of which has its own geometry and material. All primitives in a particular renderable share a set of rendering attributes, such as whether they cast shadows or use vertex skinning.

Usage example:

auto renderable = utils::EntityManager::get().create();

RenderableManager::Builder(1)
.boundingBox({{ -1, -1, -1 }, { 1, 1, 1 }})
.material(0, matInstance)
.geometry(0, RenderableManager::PrimitiveType::TRIANGLES, vertBuffer, indBuffer, 0, 3)
.receiveShadows(false)
.build(engine, renderable);

scene->addEntity(renderable);

To modify the state of an existing renderable, clients should first use RenderableManager to get a temporary handle called an \em instance. The instance can then be used to get or set the renderable's state. Please note that instances are ephemeral; clients should store entities, not instances.

  • For details about constructing renderables, see RenderableManager::Builder.
  • To associate a 4x4 transform with an entity, see TransformManager.
  • To associate a human-readable label with an entity, see utils::NameComponentManager.

Extends

  • PointerHolder

Properties

isValid

readonly isValid: boolean

Get if the refernce to the native pointer is still valid and strong.

If this is false, this object has been manually released with release() and all other methods on this object will throw an Error.

Inherited from

PointerHolder.isValid

Defined in

src/types/PointerHolder.ts:37

Methods

changeMaterialTextureMap()

changeMaterialTextureMap(renderable, materialName, textureBuffer, textureFlags): void

Sets the baseColorMap parameter to the given textureBuffer.

Parameters

renderable: Entity

materialName: string

textureBuffer: FilamentBuffer

textureFlags: TextureFlags

Returns

void

Worklet

Defined in

src/types/RenderableManager.ts:66


createDebugCubeWireframe()

createDebugCubeWireframe(halfExtent, material, color): Entity

Creates the wireframe of a cube with the given half extent for debugging purposes. Note: you don't have to supply a material. In that case the color will always be white. You can't provide a different color than white if you don't provide a material.

Parameters

halfExtent: Float3

material: undefined | Material

color: undefined | number

Provide a color in the format 0xRRGGBBAA

Returns

Entity

Defined in

src/types/RenderableManager.ts:104


createImageBackgroundShape()

createImageBackgroundShape(material): Entity

Parameters

material: Material

Returns

Entity

Defined in

src/types/RenderableManager.ts:88


createPlane()

createPlane(shadowMaterial, halfExtendX, halfExtendY, halfExtendZ): Entity

Creates a plane with the material provided. Creates it at the 0,0,0 origin.

Parameters

shadowMaterial: Material

See Engine.createMaterial

halfExtendX: number

halfExtendY: number

halfExtendZ: number

Returns

Entity

Worklet

Defined in

src/types/RenderableManager.ts:85


getAxisAlignedBoundingBox()

getAxisAlignedBoundingBox(entity): Box

Parameters

entity: Entity

Returns

Box

Defined in

src/types/RenderableManager.ts:106


getMaterialInstanceAt()

getMaterialInstanceAt(renderable, index): MaterialInstance

Parameters

renderable: Entity

index: number

Returns

MaterialInstance

Defined in

src/types/RenderableManager.ts:45


getPrimitiveCount()

getPrimitiveCount(renderable): number

Parameters

renderable: Entity

Returns

number

Defined in

src/types/RenderableManager.ts:44


release()

release(): void

Manually release this reference to the native pointer. This will ensure that JS will no longer hold a strong reference, and memory can be safely cleaned up.

If the native pointer is still referenced elsewhere in native code, the underlying memory will not be deleted unless the other references are also released.

If this is not called, the memory will only be cleaned once the JS gabage collector decides to delete this object, which might be at any point in the future.

Calling release() is not required as the GC will destroy this object eventually anyways, but it is recommended to optimize memory usage.

After manually releasing a pointer, all future methods on this object will throw an Error.

Returns

void

Inherited from

PointerHolder.release

Defined in

src/types/PointerHolder.ts:30


scaleBoundingBox()

scaleBoundingBox(asset, scale): void

Takes an asset, gets the bounding box of all renderable entities and updates the bounding box to be multiplied by the given scale factor. Note: This was added as a workaround as there seems to be a bug in filament. When using an animator the asset for some reason is slightly transformed. The bounding box doesn't seem to be updated to reflect this transformation. And the shadow is calculated the bounding box, which causes the shadow to appear clipped.

Parameters

asset: FilamentAsset

scale: number

Returns

void

Defined in

src/types/RenderableManager.ts:96


setAssetEntitiesOpacity()

setAssetEntitiesOpacity(asset, opacity): void

Convenience method to apply the given opacity to every material of all the asset's entities. Prefer to use this method over getMaterialInstanceAt and setOpacity for performance reasons. Note: This will be applied to all instances of the asset in case its an instanced asset. If you need to control the opacity of each instance separately, see setInstanceEntitiesOpacity

Parameters

asset: FilamentAsset

opacity: number

Returns

void

Defined in

src/types/RenderableManager.ts:54


setCastShadow()

setCastShadow(renderable, castShadow): void

Changes whether or not the renderable casts shadows.

Parameters

renderable: Entity

castShadow: boolean

Returns

void

Default

false

Defined in

src/types/RenderableManager.ts:72


setInstanceEntitiesOpacity()

setInstanceEntitiesOpacity(instance, opacity): void

Convenience method to apply the given opacity to every material of all the instances's entities. Prefer to use this method over getMaterialInstanceAt and setOpacity for performance reasons.

Parameters

instance: FilamentInstance

opacity: number

Returns

void

Defined in

src/types/RenderableManager.ts:60


setMaterialInstanceAt()

setMaterialInstanceAt(renderable, index, material): void

Parameters

renderable: Entity

index: number

material: MaterialInstance

Returns

void

Defined in

src/types/RenderableManager.ts:46


setReceiveShadow()

setReceiveShadow(renderable, receiveShadow): void

Changes whether or not the renderable can receive shadows.

Parameters

renderable: Entity

receiveShadow: boolean

Returns

void

Default

false

Defined in

src/types/RenderableManager.ts:78