Skip to content

Dynamic Scene Builder

Extracts scene data from a live world with optional component and entity filtering.

import { DynamicSceneBuilder } from '@shell/serialization';
// Full world snapshot
const scene = new DynamicSceneBuilder(world).build();
// Only specific components (allowlist)
const scene = new DynamicSceneBuilder(world).denyAll().allowComponent(Transform, Velocity).build();
// Exclude specific components (denylist)
const scene = new DynamicSceneBuilder(world).denyComponent(InternalState).build();
// Only specific entities
const scene = new DynamicSceneBuilder(world).extractEntities([e1, e2]).build();
// Combined
const scene = new DynamicSceneBuilder(world)
.extractEntities([e1])
.denyAll()
.allowComponent(Transform)
.build();
MethodDescription
.allowAll()Reset filter (default — include all)
.denyAll()Start allowlist mode
.allowComponent(...comps)Add to allowlist
.denyComponent(...comps)Add to denylist
.extractEntities(iterable)Only extract these entities
.extractEntities(null)Reset to all entities
.build()Returns SceneData