SceneAssets

View source

ExtendsAssets

Typed resource alias for the shared Assets pool of Scene assets. It inherits Assets behavior for adding scenes with Assets#add and resolving handles with Assets#get or Assets#getByAssetId.

Retrieve the shared pool with world.getResource and SceneAssets. A SceneInstance can store a handle from this pool for scene restoration.

Examples

import { Scene, SceneAssets, SceneInstance } from '@wimaengine/scene'

// `world` provides the shared SceneAssets pool.
const scenes = world.getResource(SceneAssets)
const sceneHandle = scenes.add(new Scene())
const instanceEntity = world.spawn([
  new SceneInstance(sceneHandle)
])

// The handle identifies the scene in this shared pool.
console.log(scenes.get(sceneHandle) !== undefined, instanceEntity.id())

Constructor


constructor(type: object)

View source

Creates a typed asset pool for values identified by type.

The supplied constructor is retained as the asset family’s type identity for handles and resource access.

Parameters

NameDescriptionDefault
type

Constructor for the asset values in this container.

—