@vizij/render 0.0.1 → 0.0.3

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 CHANGED
@@ -101,6 +101,18 @@ The store tracks world graph entries, controllers, debug overlays, and renderabl
101
101
 
102
102
  All exports are re-exported through `src/index.tsx`, so a simple `import { loadGLTF } from "@vizij/render"` works.
103
103
 
104
+ ### Dual-format Vizij bundles
105
+
106
+ Vizij scenes persist authoring metadata inside GLBs so third-party tools see baked animation, while Vizij runtimes retain orchestrator graphs and clips.
107
+
108
+ - Every renderable still carries a `RobotData` extension in `userData` describing features and animatable bindings.
109
+ - The exporter now writes a root-level `extensions.VIZIJ_bundle` block following the schema in [`src/types/vizij-bundle.ts`](./src/types/vizij-bundle.ts). It contains rig graphs, pose configs, stored Vizij clips, and provenance hashes.
110
+ - Use `exportScene(group, { bundle, animations })` to embed both the Vizij bundle and optional baked `THREE.AnimationClip` instances. The helper attaches the bundle only for the export call and restores the original object.
111
+ - When loading assets, prefer `loadGLTFWithBundle` / `loadGLTFFromBlobWithBundle` to retrieve `{ world, animatables, bundle }`. The legacy tuple helpers remain available if you do not need bundle metadata.
112
+ - `extractVizijBundle(scene)` and `applyVizijBundle(scene, bundle)` (under `src/functions/vizij-bundle.ts`) let advanced tooling inspect or mutate bundles without triggering a fresh export.
113
+
114
+ With this structure, authoring tools can round-trip orchestrator assets while shipping native glTF animations for viewers that do not understand Vizij.
115
+
104
116
  ---
105
117
 
106
118
  ## Development & Testing
package/dist/index.d.mts CHANGED
@@ -4,7 +4,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import { Canvas, ThreeEvent } from '@react-three/fiber';
5
5
  import * as zustand from 'zustand';
6
6
  import * as THREE from 'three';
7
- import { Mesh, Group as Group$1, BufferGeometry, ShapeGeometry } from 'three';
7
+ import { Mesh, Group as Group$1, BufferGeometry, ShapeGeometry, AnimationClip, Object3D } from 'three';
8
8
  import { RawValue, AnimatableValue, RawVector2 } from '@vizij/utils';
9
9
 
10
10
  declare function InnerController({ animatableId, namespace, subfield, className, }: {
@@ -282,6 +282,94 @@ interface Selection {
282
282
  };
283
283
  }
284
284
 
285
+ type VizijBundleVersion = 1;
286
+ type VizijBundleGraphKind = "rig" | "pose" | "pose-driver" | "animation-bridge" | "low-level" | string;
287
+ type VizijPoseId = string;
288
+ type VizijAnimationId = string;
289
+ type VizijGraphId = string;
290
+ interface VizijBundleGraphMetadata {
291
+ hash?: string;
292
+ source?: string;
293
+ kind?: VizijBundleGraphKind;
294
+ exportedAt?: string;
295
+ [key: string]: unknown;
296
+ }
297
+ interface VizijBundleGraphEntry {
298
+ id: VizijGraphId;
299
+ kind: VizijBundleGraphKind;
300
+ spec: Record<string, unknown>;
301
+ label?: string;
302
+ metadata?: VizijBundleGraphMetadata;
303
+ }
304
+ interface VizijPoseDefinition {
305
+ id: VizijPoseId;
306
+ name?: string;
307
+ description?: string;
308
+ values: Record<string, number | undefined>;
309
+ }
310
+ interface VizijPoseRigConfig {
311
+ version: number;
312
+ faceId?: string | null;
313
+ title?: string;
314
+ description?: string;
315
+ neutralInputs: Record<string, number>;
316
+ poses: VizijPoseDefinition[];
317
+ metadata?: Record<string, unknown>;
318
+ [key: string]: unknown;
319
+ }
320
+ interface VizijBundlePoseSection {
321
+ config: VizijPoseRigConfig;
322
+ metadata?: {
323
+ hash?: string;
324
+ exportedAt?: string;
325
+ [key: string]: unknown;
326
+ };
327
+ }
328
+ interface VizijBundleAnimationKeyframe {
329
+ time: number;
330
+ value: number;
331
+ easing?: "linear" | "easeIn" | "easeOut" | "easeInOut" | string;
332
+ inTangent?: number | null;
333
+ outTangent?: number | null;
334
+ [key: string]: unknown;
335
+ }
336
+ interface VizijBundleAnimationTrack {
337
+ channel: string;
338
+ keyframes: VizijBundleAnimationKeyframe[];
339
+ interpolation?: "step" | "linear" | "cubic" | string;
340
+ [key: string]: unknown;
341
+ }
342
+ interface VizijBundleAnimationClip {
343
+ id: VizijAnimationId;
344
+ name?: string;
345
+ duration?: number;
346
+ tracks: VizijBundleAnimationTrack[];
347
+ metadata?: Record<string, unknown>;
348
+ [key: string]: unknown;
349
+ }
350
+ interface VizijBundleAnimationEntry {
351
+ id: VizijAnimationId;
352
+ clip: VizijBundleAnimationClip;
353
+ metadata?: {
354
+ hash?: string;
355
+ sampleRateHz?: number;
356
+ rigGraphHash?: string;
357
+ poseGraphHash?: string | null;
358
+ bakedClipIndex?: number | null;
359
+ tolerance?: number;
360
+ exportedAt?: string;
361
+ [key: string]: unknown;
362
+ };
363
+ }
364
+ interface VizijBundleExtension {
365
+ version: VizijBundleVersion;
366
+ exportedAt?: string;
367
+ graphs?: VizijBundleGraphEntry[];
368
+ poses?: VizijBundlePoseSection | null;
369
+ animations?: VizijBundleAnimationEntry[];
370
+ metadata?: Record<string, unknown>;
371
+ }
372
+
285
373
  interface VizijData {
286
374
  world: World;
287
375
  animatables: Record<string, AnimatableValue>;
@@ -442,6 +530,19 @@ declare function loadGLTFFromBlob(blob: Blob, namespaces: string[], aggressiveIm
442
530
  center: RawVector2;
443
531
  size: RawVector2;
444
532
  }): Promise<[World, Record<string, AnimatableValue>]>;
533
+ type LoadedVizijAsset = {
534
+ world: World;
535
+ animatables: Record<string, AnimatableValue>;
536
+ bundle: VizijBundleExtension | null;
537
+ };
538
+ declare function loadGLTFWithBundle(url: string, namespaces: string[], aggressiveImport?: boolean, rootBounds?: {
539
+ center: RawVector2;
540
+ size: RawVector2;
541
+ }): Promise<LoadedVizijAsset>;
542
+ declare function loadGLTFFromBlobWithBundle(blob: Blob, namespaces: string[], aggressiveImport?: boolean, rootBounds?: {
543
+ center: RawVector2;
544
+ size: RawVector2;
545
+ }): Promise<LoadedVizijAsset>;
445
546
 
446
547
  /**
447
548
  * Loads a GLTF model from a Blob and returns the Three.js scene containing the model.
@@ -451,6 +552,15 @@ declare function loadGLTFFromBlob(blob: Blob, namespaces: string[], aggressiveIm
451
552
  */
452
553
  declare const loadGltfFromBlob: (blob: Blob, namespaces: string[]) => Promise<[World, Record<string, AnimatableValue>]>;
453
554
 
454
- declare function exportScene(data: Group$1, fileName?: string): void;
555
+ type ExportSceneOptions = {
556
+ fileName?: string;
557
+ bundle?: VizijBundleExtension | null;
558
+ animations?: AnimationClip[];
559
+ binary?: boolean;
560
+ };
561
+ declare function exportScene(data: Group$1, fileNameOrOptions?: string | ExportSceneOptions): void;
562
+
563
+ declare function extractVizijBundle(object: Object3D, parserJson?: unknown): VizijBundleExtension | null;
564
+ declare function applyVizijBundle(object: Object3D, bundle: VizijBundleExtension | null): () => void;
455
565
 
456
- export { type AnimatedFeature, Controller, type Ellipse, type EllipseFeature, EmptyModelError, type Feature, type Group, type GroupFeature, InnerVizij, type InnerVizijProps, type Rectangle, type RectangleFeature, type RenderableBase, type RenderableFeature, type Selection, type Shape, type ShapeFeature, ShapeMaterial, type StaticFeature, type Stored, type StoredAnimatedFeature, type StoredEllipse, type StoredFeatures, type StoredGroup, type StoredRectangle, type StoredRenderable, type StoredShape, Vizij, type VizijActions, VizijContext, type VizijData, type VizijProps, VizijSlice, type VizijStore, type VizijStoreGetter, type VizijStoreSetter, type World, createVizijStore, exportScene, loadGLTF, loadGLTFFromBlob, loadGltfFromBlob, useDefaultVizijStore, useFeatures, useVizijStore, useVizijStoreGetter, useVizijStoreSetter, useVizijStoreSubscription };
566
+ export { type AnimatedFeature, Controller, type Ellipse, type EllipseFeature, EmptyModelError, type ExportSceneOptions, type Feature, type Group, type GroupFeature, InnerVizij, type InnerVizijProps, type LoadedVizijAsset, type Rectangle, type RectangleFeature, type RenderableBase, type RenderableFeature, type Selection, type Shape, type ShapeFeature, ShapeMaterial, type StaticFeature, type Stored, type StoredAnimatedFeature, type StoredEllipse, type StoredFeatures, type StoredGroup, type StoredRectangle, type StoredRenderable, type StoredShape, Vizij, type VizijActions, type VizijAnimationId, type VizijBundleAnimationClip, type VizijBundleAnimationEntry, type VizijBundleAnimationKeyframe, type VizijBundleAnimationTrack, type VizijBundleExtension, type VizijBundleGraphEntry, type VizijBundleGraphKind, type VizijBundleGraphMetadata, type VizijBundlePoseSection, type VizijBundleVersion, VizijContext, type VizijData, type VizijGraphId, type VizijPoseDefinition, type VizijPoseId, type VizijPoseRigConfig, type VizijProps, VizijSlice, type VizijStore, type VizijStoreGetter, type VizijStoreSetter, type World, applyVizijBundle, createVizijStore, exportScene, extractVizijBundle, loadGLTF, loadGLTFFromBlob, loadGLTFFromBlobWithBundle, loadGLTFWithBundle, loadGltfFromBlob, useDefaultVizijStore, useFeatures, useVizijStore, useVizijStoreGetter, useVizijStoreSetter, useVizijStoreSubscription };
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import { Canvas, ThreeEvent } from '@react-three/fiber';
5
5
  import * as zustand from 'zustand';
6
6
  import * as THREE from 'three';
7
- import { Mesh, Group as Group$1, BufferGeometry, ShapeGeometry } from 'three';
7
+ import { Mesh, Group as Group$1, BufferGeometry, ShapeGeometry, AnimationClip, Object3D } from 'three';
8
8
  import { RawValue, AnimatableValue, RawVector2 } from '@vizij/utils';
9
9
 
10
10
  declare function InnerController({ animatableId, namespace, subfield, className, }: {
@@ -282,6 +282,94 @@ interface Selection {
282
282
  };
283
283
  }
284
284
 
285
+ type VizijBundleVersion = 1;
286
+ type VizijBundleGraphKind = "rig" | "pose" | "pose-driver" | "animation-bridge" | "low-level" | string;
287
+ type VizijPoseId = string;
288
+ type VizijAnimationId = string;
289
+ type VizijGraphId = string;
290
+ interface VizijBundleGraphMetadata {
291
+ hash?: string;
292
+ source?: string;
293
+ kind?: VizijBundleGraphKind;
294
+ exportedAt?: string;
295
+ [key: string]: unknown;
296
+ }
297
+ interface VizijBundleGraphEntry {
298
+ id: VizijGraphId;
299
+ kind: VizijBundleGraphKind;
300
+ spec: Record<string, unknown>;
301
+ label?: string;
302
+ metadata?: VizijBundleGraphMetadata;
303
+ }
304
+ interface VizijPoseDefinition {
305
+ id: VizijPoseId;
306
+ name?: string;
307
+ description?: string;
308
+ values: Record<string, number | undefined>;
309
+ }
310
+ interface VizijPoseRigConfig {
311
+ version: number;
312
+ faceId?: string | null;
313
+ title?: string;
314
+ description?: string;
315
+ neutralInputs: Record<string, number>;
316
+ poses: VizijPoseDefinition[];
317
+ metadata?: Record<string, unknown>;
318
+ [key: string]: unknown;
319
+ }
320
+ interface VizijBundlePoseSection {
321
+ config: VizijPoseRigConfig;
322
+ metadata?: {
323
+ hash?: string;
324
+ exportedAt?: string;
325
+ [key: string]: unknown;
326
+ };
327
+ }
328
+ interface VizijBundleAnimationKeyframe {
329
+ time: number;
330
+ value: number;
331
+ easing?: "linear" | "easeIn" | "easeOut" | "easeInOut" | string;
332
+ inTangent?: number | null;
333
+ outTangent?: number | null;
334
+ [key: string]: unknown;
335
+ }
336
+ interface VizijBundleAnimationTrack {
337
+ channel: string;
338
+ keyframes: VizijBundleAnimationKeyframe[];
339
+ interpolation?: "step" | "linear" | "cubic" | string;
340
+ [key: string]: unknown;
341
+ }
342
+ interface VizijBundleAnimationClip {
343
+ id: VizijAnimationId;
344
+ name?: string;
345
+ duration?: number;
346
+ tracks: VizijBundleAnimationTrack[];
347
+ metadata?: Record<string, unknown>;
348
+ [key: string]: unknown;
349
+ }
350
+ interface VizijBundleAnimationEntry {
351
+ id: VizijAnimationId;
352
+ clip: VizijBundleAnimationClip;
353
+ metadata?: {
354
+ hash?: string;
355
+ sampleRateHz?: number;
356
+ rigGraphHash?: string;
357
+ poseGraphHash?: string | null;
358
+ bakedClipIndex?: number | null;
359
+ tolerance?: number;
360
+ exportedAt?: string;
361
+ [key: string]: unknown;
362
+ };
363
+ }
364
+ interface VizijBundleExtension {
365
+ version: VizijBundleVersion;
366
+ exportedAt?: string;
367
+ graphs?: VizijBundleGraphEntry[];
368
+ poses?: VizijBundlePoseSection | null;
369
+ animations?: VizijBundleAnimationEntry[];
370
+ metadata?: Record<string, unknown>;
371
+ }
372
+
285
373
  interface VizijData {
286
374
  world: World;
287
375
  animatables: Record<string, AnimatableValue>;
@@ -442,6 +530,19 @@ declare function loadGLTFFromBlob(blob: Blob, namespaces: string[], aggressiveIm
442
530
  center: RawVector2;
443
531
  size: RawVector2;
444
532
  }): Promise<[World, Record<string, AnimatableValue>]>;
533
+ type LoadedVizijAsset = {
534
+ world: World;
535
+ animatables: Record<string, AnimatableValue>;
536
+ bundle: VizijBundleExtension | null;
537
+ };
538
+ declare function loadGLTFWithBundle(url: string, namespaces: string[], aggressiveImport?: boolean, rootBounds?: {
539
+ center: RawVector2;
540
+ size: RawVector2;
541
+ }): Promise<LoadedVizijAsset>;
542
+ declare function loadGLTFFromBlobWithBundle(blob: Blob, namespaces: string[], aggressiveImport?: boolean, rootBounds?: {
543
+ center: RawVector2;
544
+ size: RawVector2;
545
+ }): Promise<LoadedVizijAsset>;
445
546
 
446
547
  /**
447
548
  * Loads a GLTF model from a Blob and returns the Three.js scene containing the model.
@@ -451,6 +552,15 @@ declare function loadGLTFFromBlob(blob: Blob, namespaces: string[], aggressiveIm
451
552
  */
452
553
  declare const loadGltfFromBlob: (blob: Blob, namespaces: string[]) => Promise<[World, Record<string, AnimatableValue>]>;
453
554
 
454
- declare function exportScene(data: Group$1, fileName?: string): void;
555
+ type ExportSceneOptions = {
556
+ fileName?: string;
557
+ bundle?: VizijBundleExtension | null;
558
+ animations?: AnimationClip[];
559
+ binary?: boolean;
560
+ };
561
+ declare function exportScene(data: Group$1, fileNameOrOptions?: string | ExportSceneOptions): void;
562
+
563
+ declare function extractVizijBundle(object: Object3D, parserJson?: unknown): VizijBundleExtension | null;
564
+ declare function applyVizijBundle(object: Object3D, bundle: VizijBundleExtension | null): () => void;
455
565
 
456
- export { type AnimatedFeature, Controller, type Ellipse, type EllipseFeature, EmptyModelError, type Feature, type Group, type GroupFeature, InnerVizij, type InnerVizijProps, type Rectangle, type RectangleFeature, type RenderableBase, type RenderableFeature, type Selection, type Shape, type ShapeFeature, ShapeMaterial, type StaticFeature, type Stored, type StoredAnimatedFeature, type StoredEllipse, type StoredFeatures, type StoredGroup, type StoredRectangle, type StoredRenderable, type StoredShape, Vizij, type VizijActions, VizijContext, type VizijData, type VizijProps, VizijSlice, type VizijStore, type VizijStoreGetter, type VizijStoreSetter, type World, createVizijStore, exportScene, loadGLTF, loadGLTFFromBlob, loadGltfFromBlob, useDefaultVizijStore, useFeatures, useVizijStore, useVizijStoreGetter, useVizijStoreSetter, useVizijStoreSubscription };
566
+ export { type AnimatedFeature, Controller, type Ellipse, type EllipseFeature, EmptyModelError, type ExportSceneOptions, type Feature, type Group, type GroupFeature, InnerVizij, type InnerVizijProps, type LoadedVizijAsset, type Rectangle, type RectangleFeature, type RenderableBase, type RenderableFeature, type Selection, type Shape, type ShapeFeature, ShapeMaterial, type StaticFeature, type Stored, type StoredAnimatedFeature, type StoredEllipse, type StoredFeatures, type StoredGroup, type StoredRectangle, type StoredRenderable, type StoredShape, Vizij, type VizijActions, type VizijAnimationId, type VizijBundleAnimationClip, type VizijBundleAnimationEntry, type VizijBundleAnimationKeyframe, type VizijBundleAnimationTrack, type VizijBundleExtension, type VizijBundleGraphEntry, type VizijBundleGraphKind, type VizijBundleGraphMetadata, type VizijBundlePoseSection, type VizijBundleVersion, VizijContext, type VizijData, type VizijGraphId, type VizijPoseDefinition, type VizijPoseId, type VizijPoseRigConfig, type VizijProps, VizijSlice, type VizijStore, type VizijStoreGetter, type VizijStoreSetter, type World, applyVizijBundle, createVizijStore, exportScene, extractVizijBundle, loadGLTF, loadGLTFFromBlob, loadGLTFFromBlobWithBundle, loadGLTFWithBundle, loadGltfFromBlob, useDefaultVizijStore, useFeatures, useVizijStore, useVizijStoreGetter, useVizijStoreSetter, useVizijStoreSubscription };