Skip to main content

Interface: Scene

A Scene is a flat container of RenderableManager and LightManager components.

A Scene doesn't provide a hierarchy of objects, i.e.: it's not a scene-graph. However, it manages the list of objects to render and the list of lights. These can be added or removed from a Scene at any time. Moreover clients can use TransformManager to create a graph of transforms.

A RenderableManager component must be added to a Scene in order to be rendered, and the Scene must be provided to a View.

Creation and Destruction

A Scene is created using Engine#createScene and destroyed using Engine#destroyScene(Scene).

See

  • View
  • LightManager
  • RenderableManager
  • TransformManager

Extends

  • PointerHolder

Properties

entityCount

readonly entityCount: number

Returns the number of entities in the scene.

Defined in

src/types/Scene.ts:63


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

addAssetEntities()

addAssetEntities(asset): void

Adds all entities associated with the given asset to the scene.

Parameters

asset: FilamentAsset

Returns

void

Defined in

src/types/Scene.ts:54


addEntities()

addEntities(entities): void

Adds multiple entities to the scene.

Parameters

entities: Entity[]

Returns

void

Defined in

src/types/Scene.ts:39


addEntity()

addEntity(entity): void

Adds a single entity to the scene. If you want to add your asset to the scene, which likely contains multiple entities, use addAssetEntities instead.

Parameters

entity: Entity

Returns

void

Defined in

src/types/Scene.ts:34


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


removeAssetEntities()

removeAssetEntities(asset): void

Removes all entities associated with the given asset from the scene.

Parameters

asset: FilamentAsset

Returns

void

Defined in

src/types/Scene.ts:58


removeEntities()

removeEntities(entities): void

Removes multiple entities from the scene.

Parameters

entities: Entity[]

Returns

void

Defined in

src/types/Scene.ts:49


removeEntity()

removeEntity(entity): void

Removes the Renderable from the Scene.

Parameters

entity: Entity

Returns

void

Defined in

src/types/Scene.ts:44