@shapeshift-labs/frontier-scene
v0.1.0
Published
Patch-native 2D/3D scene graph and transform propagation primitives for Frontier hosts.
Maintainers
Readme
@shapeshift-labs/frontier-scene
Patch-native scene graph primitives for Frontier hosts. The package stores scene state as JSON, accepts Frontier patch tuples for mutation, and keeps hot transform/bounds state in typed-array caches.
API Shape
import { createSceneGraph, sceneNode2d, sceneNode3d } from '@shapeshift-labs/frontier-scene';
const scene = createSceneGraph({
nodes: [
sceneNode2d('root', { local: { x: 10, y: 20 } }),
sceneNode2d('sprite', {
parent: 'root',
local: { x: 4, y: 8, rotation: 0.2 },
bounds: { minX: 0, minY: 0, maxX: 32, maxY: 32 }
}),
sceneNode3d('camera', {
local: { x: 0, y: 2, z: 8 },
bounds: { minX: -1, minY: -1, minZ: -1, maxX: 1, maxY: 1, maxZ: 1 }
})
]
});
scene.commit([[0, ['nodes', 'sprite', 'local', 'x'], 12]], {
origin: { actionId: 'sprite.move', causeId: 'pointer-drag' }
});
scene.updateWorld();
scene.readWorld2d('sprite');
scene.queryAabb2d({ minX: 0, minY: 0, maxX: 128, maxY: 128 });
scene.toVirtualSpatialItems();Design Notes
frontier-scene deliberately does not own a renderer. DOM, Canvas, WebGL, WebGPU, and game engines can all consume the same serialized graph, world matrices, bounds queries, and virtual-item adapters.
The internal model follows the same direction as the rest of Frontier:
- JSON snapshot is the durable state.
- Frontier patch tuples are the mutation format.
- Dirty nodes are inferred from patch paths.
- 2D and 3D local transforms are recomputed only for locally dirty nodes.
- World matrix propagation is subtree-dirty, while world bounds are materialized lazily on bounds reads and culling queries.
- Scheduler integration is structural, so
frontier-schedulercan queue scene updates without becoming a dependency. toVirtualSpatialItems()andtoVirtualAabb3Items()return shapes that can feedfrontier-virtualspatial and frustum culling.
Related Packages
The published Frontier package family is generated from one shared package catalog so READMEs stay in sync across packages:
@shapeshift-labs/frontier: Core JSON diff/apply, compact patch tuples, JSON Pointer, equality, clone, validation, Unicode helpers.@shapeshift-labs/frontier-query: Shared query-key, selector path, condition, entity identity, and table-shape primitives.@shapeshift-labs/frontier-codec: Patch serialization, binary frames, canonical JSON, and patch-history codecs.@shapeshift-labs/frontier-engine: Stateful planned diff engine, adaptive profiles, schema plans, and engine-level history helpers.@shapeshift-labs/frontier-state: Patch-routed app-state subscriptions, owned commits, maintained views, and path mapping.@shapeshift-labs/frontier-state-cache: Normalized query-result cache with entity/query watchers, persistence, change logs, optimistic layers, and mutation bridge.@shapeshift-labs/frontier-state-cache-idb: IndexedDB persistence adapter for Frontier state-cache snapshots.@shapeshift-labs/frontier-state-cache-file: Structured file persistence adapter for Frontier state-cache snapshots and change logs.@shapeshift-labs/frontier-state-cache-sql: SQL persistence adapter for Frontier state-cache snapshots and change logs.@shapeshift-labs/frontier-schema: JSON Schema validation, Frontier profile generation, CloudEvent envelopes, and query/table schema helpers.@shapeshift-labs/frontier-event-log: Bounded event logs, replay cursors, consumer acknowledgements, keyed compaction, checkpoints, and Frontier patch event records.@shapeshift-labs/frontier-scheduler: Deterministic work scheduling, lanes, cancellation, backpressure, frame policies, replay snapshots, and work graphs.@shapeshift-labs/frontier-logging: Opt-in structured logging, browser telemetry, file sinks, exporters, benchmark traces, and Frontier patch/update summaries.@shapeshift-labs/frontier-mutation: Explicit mutation and selector plans compiled to Frontier patches or CRDT operations.@shapeshift-labs/frontier-virtual: DOM-neutral virtualization, layout providers, range materialization, grids, spatial culling, frustum culling, and serializable layout state.@shapeshift-labs/frontier-dom: Patch-native DOM and host renderer bindings, manifest hydration, JSX runtime/compiler helpers, SSR, devtools, and logging bridges.@shapeshift-labs/frontier-crdt: Native CRDT documents, update tooling, awareness, branches, conflict introspection, version frames, and undo.@shapeshift-labs/frontier-crdt-sync: CRDT sync endpoints, repo/storage/provider contracts, document URLs, local networks, model checking, forensics, and text binding contracts.@shapeshift-labs/frontier-crdt-websocket: WebSocket client/server transports for Frontier CRDT sync providers.@shapeshift-labs/frontier-react: React external-store hooks and adapters for Frontier state, cache, and CRDT surfaces.@shapeshift-labs/frontier-richtext: Rich text Delta normalization/application, marks, embeds, ranges, and cursor/selection transforms for local editor integrations.@shapeshift-labs/frontier-realtime: Shared realtime command, tick, snapshot, prediction, reconciliation, interpolation, rollback, message, and delta primitives.@shapeshift-labs/frontier-realtime-server: Authoritative realtime room, tick, command validation, rate-limit, session, and snapshot-history runtime.@shapeshift-labs/frontier-realtime-websocket: WebSocket client, wire, and Node room-server transport for Frontier realtime.@shapeshift-labs/frontier-game: Game-facing entity, component, player, room, ownership, spatial interest, rollback, physics, and replication helpers above realtime.
Package source repositories:
siliconjungle/-shapeshift-labs-frontiersiliconjungle/-shapeshift-labs-frontier-querysiliconjungle/-shapeshift-labs-frontier-codecsiliconjungle/-shapeshift-labs-frontier-enginesiliconjungle/-shapeshift-labs-frontier-statesiliconjungle/-shapeshift-labs-frontier-state-cachesiliconjungle/-shapeshift-labs-frontier-state-cache-idbsiliconjungle/-shapeshift-labs-frontier-state-cache-filesiliconjungle/-shapeshift-labs-frontier-state-cache-sqlsiliconjungle/-shapeshift-labs-frontier-schemasiliconjungle/-shapeshift-labs-frontier-event-logsiliconjungle/-shapeshift-labs-frontier-schedulersiliconjungle/-shapeshift-labs-frontier-loggingsiliconjungle/-shapeshift-labs-frontier-mutationsiliconjungle/-shapeshift-labs-frontier-virtualsiliconjungle/-shapeshift-labs-frontier-scenesiliconjungle/-shapeshift-labs-frontier-domsiliconjungle/-shapeshift-labs-frontier-crdtsiliconjungle/-shapeshift-labs-frontier-crdt-syncsiliconjungle/-shapeshift-labs-frontier-crdt-websocketsiliconjungle/-shapeshift-labs-frontier-reactsiliconjungle/-shapeshift-labs-frontier-richtextsiliconjungle/-shapeshift-labs-frontier-realtimesiliconjungle/-shapeshift-labs-frontier-realtime-serversiliconjungle/-shapeshift-labs-frontier-realtime-websocketsiliconjungle/-shapeshift-labs-frontier-game
Install
npm install @shapeshift-labs/frontier-sceneBenchmarks
Run the package-local benchmark:
npm run benchCurrent benchmark coverage is Frontier-only and focuses on package-local behavior. These are Frontier-only package measurements, not competitor comparisons:
- scene creation for mixed 2D/3D graphs
- single-node patch plus dirty transform propagation
- batch patch application plus world update
- 2D AABB culling
- 3D frustum culling
- JSON snapshot serialize/rehydrate
Latest local run on Node v26.1.0, darwin arm64, 10000 mixed nodes:
scene:create-10k-mixed: 58 ops/sec (17.2112 ms/op, p95 25.3264 ms)
scene:patch-update-2d-leaf: 22514 ops/sec (0.0444 ms/op, p95 0.0756 ms)
scene:patch-update-3d-leaf: 29511 ops/sec (0.0339 ms/op, p95 0.0532 ms)
scene:batch-128-patches-update: 8636 ops/sec (0.1158 ms/op, p95 0.2654 ms)
scene:cull-2d-aabb: 15440 ops/sec (0.0648 ms/op, p95 0.0836 ms)
scene:cull-3d-frustum: 16448 ops/sec (0.0608 ms/op, p95 0.0746 ms)
scene:serialize-rehydrate: 58 ops/sec (17.3770 ms/op, p95 26.8814 ms)