Skip to content

@relu-interactives/spatial-ecs


@relu-interactives/spatial-ecs / index / spawnPrefab

Function: spawnPrefab() ​

ts
function spawnPrefab(
   world, 
   source, 
options?): Promise<number>;

Defined in: prefab/spawnPrefab.ts:144

Instantiate a prefab into a live world at runtime.

source may be a URL string, a script AssetInput ({ path, type }), or an already-loaded PrefabAsset. Resolves with the root entity id once all entities/components exist — heavyweight assets inside (models, textures, audio) continue loading reactively through their systems, using the shared model cache for repeat spawns.

Parameters ​

ParameterType
worldWorld
sourceSpawnPrefabSource
options?SpawnPrefabOptions

Returns ​

Promise<number>