@vizij/runtime-react 0.0.1
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 +146 -0
- package/dist/index.d.mts +176 -0
- package/dist/index.d.ts +176 -0
- package/dist/index.js +1065 -0
- package/dist/index.mjs +1054 -0
- package/package.json +61 -0
package/README.md
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# @vizij/runtime-react
|
|
2
|
+
|
|
3
|
+
High-level runtime harness that combines the Vizij renderer with orchestrator controllers for React apps. Drop in an asset bundle and the provider wires loading, orchestration, and rendering for you.
|
|
4
|
+
|
|
5
|
+
> **Status:** experimental. Surface area may change ahead of the first stable release.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @vizij/runtime-react @vizij/render @vizij/orchestrator-react react react-dom
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Those three Vizij packages must stay in lock-step; always upgrade them together.
|
|
14
|
+
|
|
15
|
+
## Getting Started
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import {
|
|
19
|
+
VizijRuntimeFace,
|
|
20
|
+
VizijRuntimeProvider,
|
|
21
|
+
useVizijRuntime,
|
|
22
|
+
} from "@vizij/runtime-react";
|
|
23
|
+
|
|
24
|
+
import rigGraph from "./rig.graph.json";
|
|
25
|
+
|
|
26
|
+
const assetBundle = {
|
|
27
|
+
namespace: "demo",
|
|
28
|
+
glb: { kind: "url", src: new URL("./face.glb", import.meta.url).href },
|
|
29
|
+
rig: { id: "rig:demo", spec: rigGraph },
|
|
30
|
+
initialInputs: {
|
|
31
|
+
"pose/blinkLeft": { float: 0.2 },
|
|
32
|
+
"pose/blinkRight": { float: 0.2 },
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export function App() {
|
|
37
|
+
return (
|
|
38
|
+
<VizijRuntimeProvider assetBundle={assetBundle} autostart>
|
|
39
|
+
<RuntimeHud />
|
|
40
|
+
<VizijRuntimeFace />
|
|
41
|
+
</VizijRuntimeProvider>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function RuntimeHud() {
|
|
46
|
+
const { loading, error, namespace } = useVizijRuntime();
|
|
47
|
+
if (loading) return <p>Loading bundle...</p>;
|
|
48
|
+
if (error) return <p>Failed to load runtime: {error.message}</p>;
|
|
49
|
+
return <p>Runtime online for namespace {namespace}</p>;
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The provider creates a renderer store, boots the orchestrator, registers the supplied bundle, then renders the face once bounds are available.
|
|
54
|
+
|
|
55
|
+
## Asset Bundle Anatomy
|
|
56
|
+
|
|
57
|
+
`VizijRuntimeProvider` expects a `VizijAssetBundle`:
|
|
58
|
+
|
|
59
|
+
- `glb`: required. Either `{ kind: "url", src }`, `{ kind: "blob", blob }`, or `{ kind: "world", world, animatables }`. URL/blob variants can opt into `aggressiveImport` for tooling builds and provide `rootBounds` overrides when the GLB lacks metadata.
|
|
60
|
+
- `rig`: required. Graph specification describing inputs/outputs for the orchestrator (`id` must be unique within the namespace).
|
|
61
|
+
- `pose`: optional. Supply authoring pose graph/config so the runtime can neutralise the rig before you drive it.
|
|
62
|
+
- `animations`: optional array. Each item defines channels that map to runtime input paths. Use `playAnimation` to trigger them.
|
|
63
|
+
- `initialInputs`: optional map of ValueJSON that seeds inputs before autostart.
|
|
64
|
+
- `metadata`: free-form dictionary you can read back through `useVizijRuntime().assetBundle.metadata`.
|
|
65
|
+
|
|
66
|
+
Namespace defaults to `assetBundle.namespace ?? "default"`. Face id falls back to the bundle pose config when omitted.
|
|
67
|
+
|
|
68
|
+
## Provider Props
|
|
69
|
+
|
|
70
|
+
- `assetBundle`: bundle described above.
|
|
71
|
+
- `namespace` / `faceId`: override bundle values to reuse the same assets under multiple namespaces or faces.
|
|
72
|
+
- `autoCreate` + `createOptions`: forwarded to `OrchestratorProvider`. Leave `autoCreate` enabled unless you need manual control over WASM creation.
|
|
73
|
+
- `autostart`: when true, the orchestrator starts ticking as soon as assets register.
|
|
74
|
+
- `mergeStrategy`: orchestrator merge strategy, defaults to additive for outputs/intermediate values.
|
|
75
|
+
- `onRegisterControllers(ids)`: observe graph and animation controller ids that were registered.
|
|
76
|
+
- `onStatusChange(status)`: gets every status update (loading events, errors, controller updates).
|
|
77
|
+
|
|
78
|
+
The provider exposes context via `useVizijRuntime()` once `loading` flips to `false`.
|
|
79
|
+
|
|
80
|
+
## Hooks and Helpers
|
|
81
|
+
|
|
82
|
+
- `useVizijRuntime()`: returns the full runtime context (status, setters, animation helpers, and the original asset bundle). Common properties:
|
|
83
|
+
- `loading`, `ready`, `error`, `errors`: lifecycle state.
|
|
84
|
+
- `namespace`, `faceId`, `rootId`: resolved IDs the renderer/orchestrator share.
|
|
85
|
+
- `outputPaths`: list of output signal paths detected in the registered graphs.
|
|
86
|
+
- `controllers`: `{ graphs, anims }` that were installed.
|
|
87
|
+
- `setInput(path, value)`, `setValue(id, namespace, value)`: talk directly to the orchestrator or renderer store.
|
|
88
|
+
- `stagePoseNeutral(force)`: restore the neutral pose captured at export.
|
|
89
|
+
- `animateValue(path, target, options)`, `cancelAnimation(path)`: tween rig values with built-in easing.
|
|
90
|
+
- `playAnimation(id, options)`, `stopAnimation(id)`: drive bundle animations that were provided in `animations`.
|
|
91
|
+
- `step(dt)` / `advanceAnimations(dt)`: manually tick the orchestrator if you run outside `autostart`.
|
|
92
|
+
- `useRigInput(path)`: returns `[value, setter]` for a single rig input. The setter writes through the orchestrator while the value mirrors the renderer store.
|
|
93
|
+
- `useVizijOutputs(paths)`: subscribes to renderer output paths (`RawValue` map) for UI or logging.
|
|
94
|
+
- `registerInputDriver(id, factory)`: attach custom drivers (speech-to-anim, sensors). The factory receives `setInput` and `setRendererValue` helpers and must return `{ start, stop, dispose }`.
|
|
95
|
+
|
|
96
|
+
## Components
|
|
97
|
+
|
|
98
|
+
- `<VizijRuntimeFace />`: renders a `<Vizij>` once `rootId` is known. Pass any renderer props (camera controls, overlays, etc.). Use `namespaceOverride` to inspect another namespace while keeping the runtime context intact.
|
|
99
|
+
- Compose your own UI with the renderer primitives exported from `@vizij/render`. The runtime only handles wiring and state.
|
|
100
|
+
|
|
101
|
+
## Error Handling
|
|
102
|
+
|
|
103
|
+
Errors are captured with phase metadata. `status.error` is the most recent failure; `status.errors` keeps history for observability panels. Typical phases:
|
|
104
|
+
|
|
105
|
+
- `assets`: bundle loading issues (bad GLB URL, malformed rig spec).
|
|
106
|
+
- `registration`: orchestrator graph registration problems.
|
|
107
|
+
- `driver`: input driver lifecycle exceptions.
|
|
108
|
+
- `animation`: failures while sampling clip tracks.
|
|
109
|
+
|
|
110
|
+
Watch `onStatusChange` for realtime updates and implement retries or fallbacks in your UI.
|
|
111
|
+
|
|
112
|
+
## Working With Animations
|
|
113
|
+
|
|
114
|
+
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.
|
|
115
|
+
|
|
116
|
+
For ad-hoc gestures, use `animateValue` with duration/easing. If you need custom easing, pass a function `(t) => number`.
|
|
117
|
+
|
|
118
|
+
## Asset Bundling Workflow
|
|
119
|
+
|
|
120
|
+
1. Export an authoring scene to GLB with Vizij metadata intact (bounds, animatable ids).
|
|
121
|
+
2. Export orchestrator graphs (rig, pose, optional animation graphs) to JSON.
|
|
122
|
+
3. Package everything under a namespace in a `VizijAssetBundle`.
|
|
123
|
+
4. Host GLB URLs or include them via bundler asset imports (`new URL("./face.glb", import.meta.url).href`).
|
|
124
|
+
|
|
125
|
+
The runtime tolerates incremental bundles; swap `assetBundle` props to hot-reload assets in dev builds.
|
|
126
|
+
|
|
127
|
+
## Development Scripts
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
pnpm --filter "@vizij/runtime-react" build # tsup compile to dist/
|
|
131
|
+
pnpm --filter "@vizij/runtime-react" test # vitest
|
|
132
|
+
pnpm --filter "@vizij/runtime-react" typecheck # tsc --noEmit
|
|
133
|
+
pnpm --filter "@vizij/runtime-react" lint # eslint
|
|
134
|
+
pnpm --filter "@vizij/runtime-react" dev # tsup watch build
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Changes to orchestrator or renderer packages often require coordinated updates here; run the fullscreen tutorial app (`apps/tutorial-fullscreen-face`) to validate.
|
|
138
|
+
|
|
139
|
+
## Publishing
|
|
140
|
+
|
|
141
|
+
When ready to publish:
|
|
142
|
+
|
|
143
|
+
1. `pnpm changeset` and follow the prompts.
|
|
144
|
+
2. `pnpm version:packages` and `pnpm install` to sync lockfiles.
|
|
145
|
+
3. Build, test, and pack the runtime filter (`pnpm --filter "@vizij/runtime-react" build`, `pnpm --filter "@vizij/runtime-react" test`, `pnpm --filter "@vizij/runtime-react" exec npm pack --dry-run`).
|
|
146
|
+
4. Push a tag named `npm-runtime-react-vX.Y.Z`. The shared GitHub Action handles `npm publish`.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import { ReactNode, PropsWithChildren } from 'react';
|
|
4
|
+
import { GraphRegistrationConfig, GraphSubscriptions, AnimationSetup, ValueJSON, CreateOrchOptions, MergeStrategyOptions, ShapeJSON } from '@vizij/orchestrator-react';
|
|
5
|
+
import { AnimatableValue, RawValue } from '@vizij/utils';
|
|
6
|
+
import { World, VizijProps } from '@vizij/render';
|
|
7
|
+
|
|
8
|
+
type PoseDefinition = {
|
|
9
|
+
id: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
values: Record<string, number | undefined>;
|
|
13
|
+
};
|
|
14
|
+
type PoseRigConfig = {
|
|
15
|
+
version: number;
|
|
16
|
+
faceId?: string | null;
|
|
17
|
+
title?: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
neutralInputs: Record<string, number>;
|
|
20
|
+
poses: PoseDefinition[];
|
|
21
|
+
metadata?: Record<string, unknown>;
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
};
|
|
24
|
+
type RootBounds = {
|
|
25
|
+
center: {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
};
|
|
29
|
+
size: {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
type VizijGlbAsset = {
|
|
35
|
+
kind: "url";
|
|
36
|
+
src: string;
|
|
37
|
+
aggressiveImport?: boolean;
|
|
38
|
+
rootBounds?: RootBounds;
|
|
39
|
+
} | {
|
|
40
|
+
kind: "blob";
|
|
41
|
+
blob: Blob;
|
|
42
|
+
aggressiveImport?: boolean;
|
|
43
|
+
rootBounds?: RootBounds;
|
|
44
|
+
} | {
|
|
45
|
+
kind: "world";
|
|
46
|
+
world: World;
|
|
47
|
+
animatables: Record<string, AnimatableValue>;
|
|
48
|
+
};
|
|
49
|
+
type VizijGraphAsset = {
|
|
50
|
+
id: string;
|
|
51
|
+
spec: GraphRegistrationConfig["spec"];
|
|
52
|
+
subscriptions?: Partial<GraphSubscriptions>;
|
|
53
|
+
};
|
|
54
|
+
type AnimationKeyframeLike = {
|
|
55
|
+
time?: number;
|
|
56
|
+
value?: number;
|
|
57
|
+
};
|
|
58
|
+
type AnimationTrackLike = {
|
|
59
|
+
channel: string;
|
|
60
|
+
keyframes?: AnimationKeyframeLike[];
|
|
61
|
+
};
|
|
62
|
+
type AnimationClipLike = {
|
|
63
|
+
id?: string;
|
|
64
|
+
name?: string;
|
|
65
|
+
duration?: number;
|
|
66
|
+
tracks?: AnimationTrackLike[];
|
|
67
|
+
[key: string]: unknown;
|
|
68
|
+
};
|
|
69
|
+
type VizijAnimationAsset = {
|
|
70
|
+
id: string;
|
|
71
|
+
clip: AnimationClipLike;
|
|
72
|
+
setup?: Partial<AnimationSetup>;
|
|
73
|
+
weight?: number;
|
|
74
|
+
};
|
|
75
|
+
type VizijAssetBundle = {
|
|
76
|
+
namespace?: string;
|
|
77
|
+
faceId?: string;
|
|
78
|
+
glb: VizijGlbAsset;
|
|
79
|
+
rig: VizijGraphAsset;
|
|
80
|
+
pose?: {
|
|
81
|
+
graph?: VizijGraphAsset;
|
|
82
|
+
config?: PoseRigConfig;
|
|
83
|
+
stageNeutralFilter?: (id: string, path: string) => boolean;
|
|
84
|
+
};
|
|
85
|
+
animations?: VizijAnimationAsset[];
|
|
86
|
+
initialInputs?: Record<string, ValueJSON>;
|
|
87
|
+
metadata?: Record<string, unknown>;
|
|
88
|
+
};
|
|
89
|
+
type RuntimeError = {
|
|
90
|
+
message: string;
|
|
91
|
+
cause?: unknown;
|
|
92
|
+
phase?: "assets" | "orchestrator" | "registration" | "animation" | "bridge" | "driver" | "unknown";
|
|
93
|
+
timestamp: number;
|
|
94
|
+
};
|
|
95
|
+
type VizijRuntimeStatus = {
|
|
96
|
+
loading: boolean;
|
|
97
|
+
ready: boolean;
|
|
98
|
+
error: RuntimeError | null;
|
|
99
|
+
errors: RuntimeError[];
|
|
100
|
+
namespace: string;
|
|
101
|
+
faceId?: string;
|
|
102
|
+
rootId?: string | null;
|
|
103
|
+
outputPaths: string[];
|
|
104
|
+
controllers: {
|
|
105
|
+
graphs: string[];
|
|
106
|
+
anims: string[];
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
type AnimateValueOptions = {
|
|
110
|
+
duration?: number;
|
|
111
|
+
easing?: ((t: number) => number) | "linear" | "easeInOut" | "easeOut" | "easeIn";
|
|
112
|
+
namespace?: string;
|
|
113
|
+
coordinate?: "input" | "renderer";
|
|
114
|
+
};
|
|
115
|
+
type PlayAnimationOptions = {
|
|
116
|
+
weight?: number;
|
|
117
|
+
speed?: number;
|
|
118
|
+
reset?: boolean;
|
|
119
|
+
};
|
|
120
|
+
type InputDriverLifecycle = {
|
|
121
|
+
start: () => void;
|
|
122
|
+
stop: () => void;
|
|
123
|
+
dispose: () => void;
|
|
124
|
+
};
|
|
125
|
+
type InputDriverContext = {
|
|
126
|
+
setInput: (path: string, value: ValueJSON, shape?: ShapeJSON) => void;
|
|
127
|
+
setRendererValue: (id: string, namespace: string, value: RawValue | ((prev: RawValue | undefined) => RawValue | undefined)) => void;
|
|
128
|
+
namespace: string;
|
|
129
|
+
faceId?: string;
|
|
130
|
+
};
|
|
131
|
+
type InputDriverFactory = (ctx: InputDriverContext) => InputDriverLifecycle;
|
|
132
|
+
type VizijRuntimeFaceProps = Omit<VizijProps, "rootId" | "namespace"> & {
|
|
133
|
+
namespaceOverride?: string;
|
|
134
|
+
};
|
|
135
|
+
type VizijRuntimeContextValue = VizijRuntimeStatus & {
|
|
136
|
+
assetBundle: VizijAssetBundle;
|
|
137
|
+
setInput: (path: string, value: ValueJSON, shape?: ShapeJSON) => void;
|
|
138
|
+
setValue: (id: string, namespace: string, value: RawValue | ((prev: RawValue | undefined) => RawValue | undefined)) => void;
|
|
139
|
+
stagePoseNeutral: (force?: boolean) => void;
|
|
140
|
+
animateValue: (path: string, target: ValueJSON, options?: AnimateValueOptions) => Promise<void>;
|
|
141
|
+
cancelAnimation: (path: string) => void;
|
|
142
|
+
registerInputDriver: (id: string, factory: InputDriverFactory) => InputDriverLifecycle;
|
|
143
|
+
playAnimation: (id: string, options?: PlayAnimationOptions) => Promise<void>;
|
|
144
|
+
stopAnimation: (id: string) => void;
|
|
145
|
+
step: (dt: number) => void;
|
|
146
|
+
advanceAnimations: (dt: number) => void;
|
|
147
|
+
};
|
|
148
|
+
type VizijRuntimeProviderProps = {
|
|
149
|
+
assetBundle: VizijAssetBundle;
|
|
150
|
+
children: ReactNode;
|
|
151
|
+
namespace?: string;
|
|
152
|
+
faceId?: string;
|
|
153
|
+
autoCreate?: boolean;
|
|
154
|
+
createOptions?: CreateOrchOptions;
|
|
155
|
+
autostart?: boolean;
|
|
156
|
+
mergeStrategy?: MergeStrategyOptions;
|
|
157
|
+
onRegisterControllers?: (ids: {
|
|
158
|
+
graphs: string[];
|
|
159
|
+
anims: string[];
|
|
160
|
+
}) => void;
|
|
161
|
+
onStatusChange?: (status: VizijRuntimeStatus) => void;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
type ProviderProps = PropsWithChildren<VizijRuntimeProviderProps>;
|
|
165
|
+
declare function VizijRuntimeProvider({ assetBundle, children, namespace: namespaceProp, faceId: faceIdProp, autoCreate, createOptions, autostart, mergeStrategy, onRegisterControllers, onStatusChange, }: ProviderProps): react_jsx_runtime.JSX.Element;
|
|
166
|
+
|
|
167
|
+
declare function VizijRuntimeFaceInner({ namespaceOverride, ...props }: VizijRuntimeFaceProps): react_jsx_runtime.JSX.Element | null;
|
|
168
|
+
declare const VizijRuntimeFace: react.MemoExoticComponent<typeof VizijRuntimeFaceInner>;
|
|
169
|
+
|
|
170
|
+
declare function useVizijRuntime(): VizijRuntimeContextValue;
|
|
171
|
+
|
|
172
|
+
declare function useVizijOutputs(paths: string[]): Record<string, RawValue | undefined>;
|
|
173
|
+
|
|
174
|
+
declare function useRigInput(path: string): [RawValue | undefined, (value: ValueJSON, shape?: ShapeJSON) => void];
|
|
175
|
+
|
|
176
|
+
export { type AnimateValueOptions, type AnimationClipLike, type AnimationKeyframeLike, type AnimationTrackLike, type InputDriverContext, type InputDriverFactory, type InputDriverLifecycle, type PlayAnimationOptions, type PoseDefinition, type PoseRigConfig, type RootBounds, type VizijAnimationAsset, type VizijAssetBundle, type VizijGlbAsset, type VizijGraphAsset, VizijRuntimeFace, type VizijRuntimeFaceProps, VizijRuntimeProvider, type VizijRuntimeProviderProps, type VizijRuntimeStatus, useRigInput, useVizijOutputs, useVizijRuntime };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import { ReactNode, PropsWithChildren } from 'react';
|
|
4
|
+
import { GraphRegistrationConfig, GraphSubscriptions, AnimationSetup, ValueJSON, CreateOrchOptions, MergeStrategyOptions, ShapeJSON } from '@vizij/orchestrator-react';
|
|
5
|
+
import { AnimatableValue, RawValue } from '@vizij/utils';
|
|
6
|
+
import { World, VizijProps } from '@vizij/render';
|
|
7
|
+
|
|
8
|
+
type PoseDefinition = {
|
|
9
|
+
id: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
values: Record<string, number | undefined>;
|
|
13
|
+
};
|
|
14
|
+
type PoseRigConfig = {
|
|
15
|
+
version: number;
|
|
16
|
+
faceId?: string | null;
|
|
17
|
+
title?: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
neutralInputs: Record<string, number>;
|
|
20
|
+
poses: PoseDefinition[];
|
|
21
|
+
metadata?: Record<string, unknown>;
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
};
|
|
24
|
+
type RootBounds = {
|
|
25
|
+
center: {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
};
|
|
29
|
+
size: {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
type VizijGlbAsset = {
|
|
35
|
+
kind: "url";
|
|
36
|
+
src: string;
|
|
37
|
+
aggressiveImport?: boolean;
|
|
38
|
+
rootBounds?: RootBounds;
|
|
39
|
+
} | {
|
|
40
|
+
kind: "blob";
|
|
41
|
+
blob: Blob;
|
|
42
|
+
aggressiveImport?: boolean;
|
|
43
|
+
rootBounds?: RootBounds;
|
|
44
|
+
} | {
|
|
45
|
+
kind: "world";
|
|
46
|
+
world: World;
|
|
47
|
+
animatables: Record<string, AnimatableValue>;
|
|
48
|
+
};
|
|
49
|
+
type VizijGraphAsset = {
|
|
50
|
+
id: string;
|
|
51
|
+
spec: GraphRegistrationConfig["spec"];
|
|
52
|
+
subscriptions?: Partial<GraphSubscriptions>;
|
|
53
|
+
};
|
|
54
|
+
type AnimationKeyframeLike = {
|
|
55
|
+
time?: number;
|
|
56
|
+
value?: number;
|
|
57
|
+
};
|
|
58
|
+
type AnimationTrackLike = {
|
|
59
|
+
channel: string;
|
|
60
|
+
keyframes?: AnimationKeyframeLike[];
|
|
61
|
+
};
|
|
62
|
+
type AnimationClipLike = {
|
|
63
|
+
id?: string;
|
|
64
|
+
name?: string;
|
|
65
|
+
duration?: number;
|
|
66
|
+
tracks?: AnimationTrackLike[];
|
|
67
|
+
[key: string]: unknown;
|
|
68
|
+
};
|
|
69
|
+
type VizijAnimationAsset = {
|
|
70
|
+
id: string;
|
|
71
|
+
clip: AnimationClipLike;
|
|
72
|
+
setup?: Partial<AnimationSetup>;
|
|
73
|
+
weight?: number;
|
|
74
|
+
};
|
|
75
|
+
type VizijAssetBundle = {
|
|
76
|
+
namespace?: string;
|
|
77
|
+
faceId?: string;
|
|
78
|
+
glb: VizijGlbAsset;
|
|
79
|
+
rig: VizijGraphAsset;
|
|
80
|
+
pose?: {
|
|
81
|
+
graph?: VizijGraphAsset;
|
|
82
|
+
config?: PoseRigConfig;
|
|
83
|
+
stageNeutralFilter?: (id: string, path: string) => boolean;
|
|
84
|
+
};
|
|
85
|
+
animations?: VizijAnimationAsset[];
|
|
86
|
+
initialInputs?: Record<string, ValueJSON>;
|
|
87
|
+
metadata?: Record<string, unknown>;
|
|
88
|
+
};
|
|
89
|
+
type RuntimeError = {
|
|
90
|
+
message: string;
|
|
91
|
+
cause?: unknown;
|
|
92
|
+
phase?: "assets" | "orchestrator" | "registration" | "animation" | "bridge" | "driver" | "unknown";
|
|
93
|
+
timestamp: number;
|
|
94
|
+
};
|
|
95
|
+
type VizijRuntimeStatus = {
|
|
96
|
+
loading: boolean;
|
|
97
|
+
ready: boolean;
|
|
98
|
+
error: RuntimeError | null;
|
|
99
|
+
errors: RuntimeError[];
|
|
100
|
+
namespace: string;
|
|
101
|
+
faceId?: string;
|
|
102
|
+
rootId?: string | null;
|
|
103
|
+
outputPaths: string[];
|
|
104
|
+
controllers: {
|
|
105
|
+
graphs: string[];
|
|
106
|
+
anims: string[];
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
type AnimateValueOptions = {
|
|
110
|
+
duration?: number;
|
|
111
|
+
easing?: ((t: number) => number) | "linear" | "easeInOut" | "easeOut" | "easeIn";
|
|
112
|
+
namespace?: string;
|
|
113
|
+
coordinate?: "input" | "renderer";
|
|
114
|
+
};
|
|
115
|
+
type PlayAnimationOptions = {
|
|
116
|
+
weight?: number;
|
|
117
|
+
speed?: number;
|
|
118
|
+
reset?: boolean;
|
|
119
|
+
};
|
|
120
|
+
type InputDriverLifecycle = {
|
|
121
|
+
start: () => void;
|
|
122
|
+
stop: () => void;
|
|
123
|
+
dispose: () => void;
|
|
124
|
+
};
|
|
125
|
+
type InputDriverContext = {
|
|
126
|
+
setInput: (path: string, value: ValueJSON, shape?: ShapeJSON) => void;
|
|
127
|
+
setRendererValue: (id: string, namespace: string, value: RawValue | ((prev: RawValue | undefined) => RawValue | undefined)) => void;
|
|
128
|
+
namespace: string;
|
|
129
|
+
faceId?: string;
|
|
130
|
+
};
|
|
131
|
+
type InputDriverFactory = (ctx: InputDriverContext) => InputDriverLifecycle;
|
|
132
|
+
type VizijRuntimeFaceProps = Omit<VizijProps, "rootId" | "namespace"> & {
|
|
133
|
+
namespaceOverride?: string;
|
|
134
|
+
};
|
|
135
|
+
type VizijRuntimeContextValue = VizijRuntimeStatus & {
|
|
136
|
+
assetBundle: VizijAssetBundle;
|
|
137
|
+
setInput: (path: string, value: ValueJSON, shape?: ShapeJSON) => void;
|
|
138
|
+
setValue: (id: string, namespace: string, value: RawValue | ((prev: RawValue | undefined) => RawValue | undefined)) => void;
|
|
139
|
+
stagePoseNeutral: (force?: boolean) => void;
|
|
140
|
+
animateValue: (path: string, target: ValueJSON, options?: AnimateValueOptions) => Promise<void>;
|
|
141
|
+
cancelAnimation: (path: string) => void;
|
|
142
|
+
registerInputDriver: (id: string, factory: InputDriverFactory) => InputDriverLifecycle;
|
|
143
|
+
playAnimation: (id: string, options?: PlayAnimationOptions) => Promise<void>;
|
|
144
|
+
stopAnimation: (id: string) => void;
|
|
145
|
+
step: (dt: number) => void;
|
|
146
|
+
advanceAnimations: (dt: number) => void;
|
|
147
|
+
};
|
|
148
|
+
type VizijRuntimeProviderProps = {
|
|
149
|
+
assetBundle: VizijAssetBundle;
|
|
150
|
+
children: ReactNode;
|
|
151
|
+
namespace?: string;
|
|
152
|
+
faceId?: string;
|
|
153
|
+
autoCreate?: boolean;
|
|
154
|
+
createOptions?: CreateOrchOptions;
|
|
155
|
+
autostart?: boolean;
|
|
156
|
+
mergeStrategy?: MergeStrategyOptions;
|
|
157
|
+
onRegisterControllers?: (ids: {
|
|
158
|
+
graphs: string[];
|
|
159
|
+
anims: string[];
|
|
160
|
+
}) => void;
|
|
161
|
+
onStatusChange?: (status: VizijRuntimeStatus) => void;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
type ProviderProps = PropsWithChildren<VizijRuntimeProviderProps>;
|
|
165
|
+
declare function VizijRuntimeProvider({ assetBundle, children, namespace: namespaceProp, faceId: faceIdProp, autoCreate, createOptions, autostart, mergeStrategy, onRegisterControllers, onStatusChange, }: ProviderProps): react_jsx_runtime.JSX.Element;
|
|
166
|
+
|
|
167
|
+
declare function VizijRuntimeFaceInner({ namespaceOverride, ...props }: VizijRuntimeFaceProps): react_jsx_runtime.JSX.Element | null;
|
|
168
|
+
declare const VizijRuntimeFace: react.MemoExoticComponent<typeof VizijRuntimeFaceInner>;
|
|
169
|
+
|
|
170
|
+
declare function useVizijRuntime(): VizijRuntimeContextValue;
|
|
171
|
+
|
|
172
|
+
declare function useVizijOutputs(paths: string[]): Record<string, RawValue | undefined>;
|
|
173
|
+
|
|
174
|
+
declare function useRigInput(path: string): [RawValue | undefined, (value: ValueJSON, shape?: ShapeJSON) => void];
|
|
175
|
+
|
|
176
|
+
export { type AnimateValueOptions, type AnimationClipLike, type AnimationKeyframeLike, type AnimationTrackLike, type InputDriverContext, type InputDriverFactory, type InputDriverLifecycle, type PlayAnimationOptions, type PoseDefinition, type PoseRigConfig, type RootBounds, type VizijAnimationAsset, type VizijAssetBundle, type VizijGlbAsset, type VizijGraphAsset, VizijRuntimeFace, type VizijRuntimeFaceProps, VizijRuntimeProvider, type VizijRuntimeProviderProps, type VizijRuntimeStatus, useRigInput, useVizijOutputs, useVizijRuntime };
|