@vizij/runtime-react 0.0.14 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -4
- package/dist/index.cjs +4077 -0
- package/dist/index.d.cts +342 -0
- package/dist/index.d.ts +173 -9
- package/dist/index.js +3035 -346
- package/package.json +15 -11
- package/dist/index.d.mts +0 -178
- package/dist/index.mjs +0 -1363
package/README.md
CHANGED
|
@@ -73,6 +73,10 @@ function RuntimeHud() {
|
|
|
73
73
|
|
|
74
74
|
The provider creates a renderer store, boots the orchestrator, registers the supplied bundle, then renders the face once bounds are available.
|
|
75
75
|
|
|
76
|
+
### Sharing one orchestrator across multiple faces
|
|
77
|
+
|
|
78
|
+
Wrap your app in a single `<OrchestratorProvider>` and give each `VizijRuntimeProvider` a unique `namespace`. The runtime will automatically reuse a parent orchestrator provider (instead of spinning up one per face), prefix graph inputs/outputs with that namespace inside the wasm blackboard, and strip the prefix again before values reach the renderer store. Set `orchestratorScope="shared"` when you want to enforce reuse; leave it at the default `"auto"` to reuse when available and fall back to an isolated provider otherwise.
|
|
79
|
+
|
|
76
80
|
## Asset Bundle Anatomy
|
|
77
81
|
|
|
78
82
|
`VizijRuntimeProvider` expects a `VizijAssetBundle`:
|
|
@@ -81,6 +85,7 @@ The provider creates a renderer store, boots the orchestrator, registers the sup
|
|
|
81
85
|
- `rig`: optional. When omitted, the runtime looks for a `VIZIJ_bundle` extension inside the GLB and registers the first rig graph it finds.
|
|
82
86
|
- `pose`: optional. Provide your own pose graph/config or just a `stageNeutralFilter`; bundled pose data is pulled from the GLB when present.
|
|
83
87
|
- `animations`: optional array. Explicit entries merge with animations discovered in the GLB bundle (deduped by id). Use `playAnimation` to trigger them.
|
|
88
|
+
- `programs`: optional array. Explicit entries merge with bundled `motiongraph` programs (deduped by id). Use `playProgram` / `pauseProgram` / `stopProgram` to control them.
|
|
84
89
|
- `initialInputs`: optional map of ValueJSON that seeds inputs before autostart.
|
|
85
90
|
- `metadata`: free-form dictionary you can read back through `useVizijRuntime().assetBundle.metadata`.
|
|
86
91
|
- `bundle`: optional. Supply pre-parsed bundle metadata when you manage world loading yourself. When loading from GLB/Blob the runtime fills this with the extracted `VizijBundleExtension`.
|
|
@@ -93,10 +98,14 @@ Namespace defaults to `assetBundle.namespace ?? "default"`. Face id falls back t
|
|
|
93
98
|
- `namespace` / `faceId`: override bundle values to reuse the same assets under multiple namespaces or faces.
|
|
94
99
|
- `autoCreate` + `createOptions`: forwarded to `OrchestratorProvider`. Leave `autoCreate` enabled unless you need manual control over WASM creation.
|
|
95
100
|
- `autostart`: when true, the orchestrator starts ticking as soon as assets register.
|
|
101
|
+
- `driveOrchestrator`: defaults to `true`. In shared orchestrator setups, set this to `false` on non-driver runtimes so only one loop calls `stepRuntime` while others continue to stage inputs/animations.
|
|
96
102
|
- `mergeStrategy`: orchestrator merge strategy, defaults to additive for outputs/intermediate values.
|
|
103
|
+
- `orchestratorScope`: control orchestrator reuse. `"auto"` (default) reuses a parent `OrchestratorProvider` when present, `"shared"` requires one, and `"isolated"` always spins up a dedicated instance.
|
|
97
104
|
- `onRegisterControllers(ids)`: observe graph and animation controller ids that were registered.
|
|
98
105
|
- `onStatusChange(status)`: gets every status update (loading events, errors, controller updates).
|
|
99
106
|
|
|
107
|
+
Inputs are staged in a per-frame buffer and flushed together before each `step()`, minimizing wasm boundary crossings even when multiple drivers write in the same tick.
|
|
108
|
+
|
|
100
109
|
The provider exposes context via `useVizijRuntime()` once `loading` flips to `false`.
|
|
101
110
|
|
|
102
111
|
## Hooks and Helpers
|
|
@@ -104,12 +113,13 @@ The provider exposes context via `useVizijRuntime()` once `loading` flips to `fa
|
|
|
104
113
|
- `useVizijRuntime()`: returns the full runtime context (status, setters, animation helpers, and the original asset bundle). Common properties:
|
|
105
114
|
- `loading`, `ready`, `error`, `errors`: lifecycle state.
|
|
106
115
|
- `namespace`, `faceId`, `rootId`: resolved IDs the renderer/orchestrator share.
|
|
107
|
-
- `outputPaths`:
|
|
116
|
+
- `outputPaths`: namespaced output signal paths detected in the registered graphs (matches orchestrator write keys).
|
|
108
117
|
- `controllers`: `{ graphs, anims }` that were installed.
|
|
109
118
|
- `setInput(path, value)`, `setValue(id, namespace, value)`: talk directly to the orchestrator or renderer store.
|
|
110
119
|
- `stagePoseNeutral(force)`: restore the neutral pose captured at export.
|
|
111
120
|
- `animateValue(path, target, options)`, `cancelAnimation(path)`: tween rig values with built-in easing.
|
|
112
121
|
- `playAnimation(id, options)`, `stopAnimation(id)`: drive bundle animations that were provided in `animations`.
|
|
122
|
+
- `playProgram(id)`, `pauseProgram(id)`, `stopProgram(id)`: drive bundled procedural programs discovered from `motiongraph` bundle entries or supplied via `programs`.
|
|
113
123
|
- `step(dt)` / `advanceAnimations(dt)`: manually tick the orchestrator if you run outside `autostart`.
|
|
114
124
|
- `useRigInput(path)`: returns `[value, setter]` for a single rig input. The setter writes through the orchestrator while the value mirrors the renderer store.
|
|
115
125
|
- `useVizijOutputs(paths)`: subscribes to renderer output paths (`RawValue` map) for UI or logging.
|
|
@@ -135,13 +145,17 @@ Watch `onStatusChange` for realtime updates and implement retries or fallbacks i
|
|
|
135
145
|
|
|
136
146
|
Animations are defined alongside rig inputs. Each track maps to an input path (`animation/<id>/<channel>`). When `playAnimation` runs, the runtime schedules frames and writes values back through the orchestrator merge strategy. Use `options.reset` to restart clips, `options.weight` to blend multiple clips, and `stopAnimation` to cut a clip immediately.
|
|
137
147
|
|
|
148
|
+
## Working With Procedural Programs
|
|
149
|
+
|
|
150
|
+
Bundled procedural programs are discovered from `motiongraph` graph entries in the embedded `VIZIJ_bundle`. `playProgram(id)` registers the graph and lets it own any output paths it writes. `pauseProgram(id)` unregisters it without resetting its last written values. `stopProgram(id)` unregisters it and restores owned inputs to their default values when available.
|
|
151
|
+
|
|
138
152
|
For ad-hoc gestures, use `animateValue` with duration/easing. If you need custom easing, pass a function `(t) => number`.
|
|
139
153
|
|
|
140
154
|
## Asset Bundling Workflow
|
|
141
155
|
|
|
142
|
-
1. Export an authoring scene to GLB with Vizij metadata intact (bounds, animatable ids). Enable “Embed Vizij bundle” in vizij-authoring to persist rig graphs, pose rig data, and
|
|
143
|
-
2. Drop the GLB into a `VizijAssetBundle` and let the runtime extract rig/pose/animation data automatically.
|
|
144
|
-
3. Optionally override or extend bundle contents by setting `rig`, `pose`, or `
|
|
156
|
+
1. Export an authoring scene to GLB with Vizij metadata intact (bounds, animatable ids). Enable “Embed Vizij bundle” in vizij-authoring to persist rig graphs, pose rig data, animations, and procedural programs inside the GLB.
|
|
157
|
+
2. Drop the GLB into a `VizijAssetBundle` and let the runtime extract rig/pose/animation/program data automatically.
|
|
158
|
+
3. Optionally override or extend bundle contents by setting `rig`, `pose`, `animations`, or `programs` manually (useful for tooling builds or custom staging).
|
|
145
159
|
4. Host GLB URLs or include them via bundler asset imports (`new URL("./face.glb", import.meta.url).href`).
|
|
146
160
|
|
|
147
161
|
The runtime tolerates incremental bundles; swap `assetBundle` props to hot-reload assets in dev builds.
|