Interface: SceneInstance
Loaded scene instance.
The root Container belongs to the app. Add it to the stage, then query nodes and drive the runtime. getAll() includes expanded Prefab children.
Properties
| Property | Modifier | Type | Description |
|---|---|---|---|
root | public | Container | Scene root Container (label is suity-scene/suity-prefab). |
document | public | SuitySceneDocument | Original scene document (runtime instances are not written into it). |
issues | readonly | readonly SceneIssue[] | Validation/asset issues accumulated during load and runtime. |
input | readonly | InputState | Scene input state: action definitions/bindings plus the frame snapshot. |
mainCamera | readonly | SceneNodeHandle | null | Runtime main camera (in-memory only; null when unset). |
Methods
setMainCamera()
setMainCamera(ref): SceneNodeHandle | null;Sets the main camera by ref or uid; null clears it.
Parameters
| Parameter | Type |
|---|---|
ref | string | null |
Returns
SceneNodeHandle | null
getMainCameraView()
getMainCameraView(viewportWidth, viewportHeight): CameraView | null;Resolved main camera view for a viewport, or null when unavailable.
Parameters
| Parameter | Type |
|---|---|
viewportWidth | number |
viewportHeight | number |
Returns
CameraView | null
get()
get(ref): SceneNodeHandle | null;Looks up a node by: exact ref -> uid -> exact name -> case-insensitive name -> name path (Root/Child). Prefab direct children use instance/child; the legacy source-root path is not resolved.
Parameters
| Parameter | Type |
|---|---|
ref | string |
Returns
SceneNodeHandle | null
getByUid()
getByUid(uid): SceneNodeHandle | null;Looks up a node by uid; prefers top-level nodes when uids collide.
Parameters
| Parameter | Type |
|---|---|
uid | string |
Returns
SceneNodeHandle | null
getAllByUid()
getAllByUid(uid): SceneNodeHandle[];All nodes with a uid (Prefab children can share document-scoped uids).
Parameters
| Parameter | Type |
|---|---|
uid | string |
Returns
getAll()
getAll(): SceneNodeHandle[];All runtime nodes, including expanded Prefab child nodes.
Returns
getAllByName()
getAllByName(name): SceneNodeHandle[];Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
getChildByName()
getChildByName(parentRef, name): SceneNodeHandle | null;Finds a direct child of parentRef by name. parentRef: null targets the scene root. Exact names win over case-insensitive matches.
Parameters
| Parameter | Type |
|---|---|
parentRef | string | null |
name | string |
Returns
SceneNodeHandle | null
resolve()
resolve(path): SceneNodeHandle | null;Resolves a name path from the scene root, e.g. "Enemies/Boss/Weapon". Each segment matches name exactly; duplicate names use the first child. Empty paths and missing segments return null. Prefab paths start at the merged instance root; there is no source-root segment.
Parameters
| Parameter | Type |
|---|---|
path | string |
Returns
SceneNodeHandle | null
findByComponent()
findByComponent(type): SceneNodeHandle[];Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
findByLayer()
findByLayer(layer): SceneNodeHandle[];Finds nodes whose normalized layer equals layer (empty = default).
Parameters
| Parameter | Type |
|---|---|
layer | string |
Returns
findByTag()
findByTag(tag): SceneNodeHandle[];Finds nodes containing the tag (case-insensitive).
Parameters
| Parameter | Type |
|---|---|
tag | string |
Returns
findByTags()
findByTags(query): SceneNodeHandle[];Finds nodes matching all/any/none tag criteria.
Parameters
| Parameter | Type |
|---|---|
query | TagsQuery |
Returns
findNodes()
findNodes(query): SceneNodeHandle[];Combined layer/tags/component/name/nodeKind query.
Parameters
| Parameter | Type |
|---|---|
query | NodeQuery |
Returns
resolveAsset()
resolveAsset(ref): Promise<ResolvedAsset | null>;Resolves a document alias, Addressable Key or uid to a URL.
Parameters
| Parameter | Type |
|---|---|
ref | string |
Returns
Promise<ResolvedAsset | null>
loadTexture()
loadTexture(ref): Promise<Texture<TextureSource<any>>>;Loads a texture for a document alias / Addressable Key / uid.
Parameters
| Parameter | Type |
|---|---|
ref | string |
Returns
Promise<Texture<TextureSource<any>>>
on()
on(event, handler): () => void;Subscribes to a runtime event. Returns an unsubscribe function.
Parameters
| Parameter | Type |
|---|---|
event | SceneEvent |
handler | (payload) => void |
Returns
() => void
instantiatePrefab()
instantiatePrefab(options): Promise<SceneNodeHandle>;Instantiates a Prefab into this scene.
Errors (all RuntimeSceneError with a code):
READ_ONLY: scene not loaded with{ mutable: true }ENGINE_NOT_AVAILABLE: no active engine catalogPREFAB_NOT_FOUND,PREFAB_INVALID,PARENT_NOT_FOUND,ABORTED,UID_CONFLICT
Child asset failures emit assetMissing and do not abort instantiation.
Parameters
| Parameter | Type |
|---|---|
options | InstantiatePrefabOptions & { cullArea?: NodeCullArea | null; } |
Returns
Promise<SceneNodeHandle>
addNode()
addNode(options): Promise<SceneNodeHandle>;Adds a normal runtime node (requires mutable: true + engine catalog).
Parameters
| Parameter | Type |
|---|---|
options | AddNodeOptions & { cullArea?: NodeCullArea | null; } |
Returns
Promise<SceneNodeHandle>
reparentNode()
reparentNode(
ref,
parentRef,
options?
): SceneNodeHandle;Moves a runtime node under another parent (or the scene root).
Parameters
| Parameter | Type |
|---|---|
ref | string |
parentRef | string | null |
options? | MoveNodeOptions |
Returns
reorderNode()
reorderNode(
ref,
index,
options?
): SceneNodeHandle;Reorders a runtime node among its current siblings.
Parameters
| Parameter | Type |
|---|---|
ref | string |
index | number |
options? | MoveNodeOptions |
Returns
setComponent()
setComponent(
ref,
component,
componentRef?
): SceneNodeHandle;Adds or replaces a component and runs the handler lifecycle.
Parameters
| Parameter | Type |
|---|---|
ref | string |
component | SuitySceneComponent |
componentRef? | string |
Returns
removeNode()
removeNode(ref, options?): boolean;Removes a runtime node and its subtree (requires mutable: true).
Parameters
| Parameter | Type |
|---|---|
ref | string |
options? | { allowStatic?: boolean; } |
options.allowStatic? | boolean |
Returns
boolean
removePrefabInstance()
removePrefabInstance(ref): boolean;Removes a runtime-instantiated Prefab and its expanded children. Returns false when the ref does not exist. Throws PREFAB_INVALID when the target is not a Prefab instance and READ_ONLY for read-only scenes.
Parameters
| Parameter | Type |
|---|---|
ref | string |
Returns
boolean
snapshot()
snapshot(): RuntimeSceneSnapshot;Read-only runtime-tree snapshot; never writes back to the scene document.
Returns
snapshotNode()
snapshotNode(ref): RuntimeNodeSnapshot | null;Parameters
| Parameter | Type |
|---|---|
ref | string |
Returns
RuntimeNodeSnapshot | null
flush()
flush(): Promise<void>;Waits for queued component writes and view refreshes.
Returns
Promise<void>
reloadPrefabInstance()
reloadPrefabInstance(ref, options?): Promise<SceneNodeHandle>;Reloads a Prefab instance from its source document, reapplies authored overrides, and discards runtime property changes.
Defaults preserve the instance transform and scene-owned children.
Parameters
| Parameter | Type |
|---|---|
ref | string |
options? | { preserveTransform?: boolean; preserveSceneChildren?: boolean; } |
options.preserveTransform? | boolean |
options.preserveSceneChildren? | boolean |
Returns
Promise<SceneNodeHandle>
update()
update(dt): void;Advances component handlers and adapter node views. dt is in seconds.
Parameters
| Parameter | Type |
|---|---|
dt | number |
Returns
void
destroy()
destroy(): void;Destroys all runtime nodes, component handlers and engine views.
Returns
void
