@vizij/render 0.0.3 → 0.0.5

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
@@ -23,7 +23,7 @@ This package exposes the `Vizij` canvas component along with hooks, stores, and
23
23
 
24
24
  - `Vizij` renders a fully managed `@react-three/fiber` canvas with sensible defaults for orthographic cameras and safe-area overlays.
25
25
  - A Zustand-powered store (`useVizijStore`) tracks renderables, controllers, and transient state. Hooks let you read or mutate slices without re-rendering entire scenes.
26
- - Utilities (`loadGLTF`, `loadGLTFBlob`, export helpers) streamline loading rigged GLTF assets and exporting scene snapshots.
26
+ - Utilities (`loadGLTF`, `loadGLTFBlob`, export helpers) streamline loading rigged GLTF assets and exporting scene snapshots. The tuple helpers now return `[world, animatables, animations]`, where `animations` contains parsed clip metadata for any channels embedded in the GLB.
27
27
  - Controllers wrap common behaviours (e.g., pointer interaction, safe-area visualisation) so you can compose features quickly.
28
28
 
29
29
  ---
@@ -108,7 +108,8 @@ Vizij scenes persist authoring metadata inside GLBs so third-party tools see bak
108
108
  - Every renderable still carries a `RobotData` extension in `userData` describing features and animatable bindings.
109
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
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.
111
+ - When loading assets, prefer `loadGLTFWithBundle` / `loadGLTFFromBlobWithBundle` to retrieve `{ world, animatables, bundle, animations }`. The legacy tuple helpers return `[world, animatables, animations]` if you only need the renderer state.
112
+ - The new `animations` field exposes `VizijAnimationClipData[]`, which maps each glTF animation channel back to Vizij animatable ids (`RobotData.features.*.value.id`). Each track provides component-aware `times`/`values` arrays so runtimes can register clips without re-parsing the GLB.
112
113
  - `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
 
114
115
  With this structure, authoring tools can round-trip orchestrator assets while shipping native glTF animations for viewers that do not understand Vizij.
package/dist/index.d.mts CHANGED
@@ -1,20 +1,12 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
1
2
  import * as react from 'react';
2
3
  import { ComponentProps, ReactNode, RefObject } from 'react';
3
- 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
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
- declare function InnerController({ animatableId, namespace, subfield, className, }: {
11
- animatableId: string;
12
- namespace?: string;
13
- subfield?: string;
14
- className?: string;
15
- }): react_jsx_runtime.JSX.Element | undefined;
16
- declare const Controller: react.MemoExoticComponent<typeof InnerController>;
17
-
18
10
  interface VizijProps {
19
11
  style?: React.CSSProperties;
20
12
  className?: string;
@@ -370,6 +362,49 @@ interface VizijBundleExtension {
370
362
  metadata?: Record<string, unknown>;
371
363
  }
372
364
 
365
+ interface VizijAnimationTrackData {
366
+ /** Vizij animatable id extracted from RobotData.features.*.value.id */
367
+ componentId: string;
368
+ /** Feature key (e.g. translation, chin, etc.) */
369
+ feature: string;
370
+ /** Vizij renderable id that owns the feature. */
371
+ renderableId: string;
372
+ /** glTF node index referenced by the channel. */
373
+ nodeIndex: number;
374
+ /** Optional glTF node name for debugging. */
375
+ nodeName?: string;
376
+ /** Original glTF channel path (translation, rotation, etc.). */
377
+ path?: string;
378
+ /** Optional feature component label (e.g. x, y, z) if provided by the glTF channel. */
379
+ component?: string;
380
+ /** Index within the output accessor for multi-component values. */
381
+ componentIndex?: number;
382
+ /** Numeric type reported by the Vizij animatable (number, vector3, etc.). */
383
+ valueType?: string;
384
+ /** Number of numeric entries per keyframe within `values`. */
385
+ valueSize: number;
386
+ /** Interpolation declared on the glTF sampler. */
387
+ interpolation?: string;
388
+ /** Keyframe times extracted from the GLTF animation sampler. */
389
+ times: number[];
390
+ /** Keyframe values (flattened, length === times.length * valueSize). */
391
+ values: number[];
392
+ }
393
+ interface VizijAnimationClipData {
394
+ /** Stable identifier derived from glTF animation name or index. */
395
+ id: string;
396
+ /** Human readable name (mirrors glTF animation name when available). */
397
+ name?: string;
398
+ /** Duration in seconds resolved from the THREE.AnimationClip. */
399
+ duration: number;
400
+ /** Raw glTF animation index in the asset. */
401
+ index: number;
402
+ /** Optional metadata copied from glTF animation extras. */
403
+ metadata?: Record<string, unknown>;
404
+ /** Extracted per-channel track data for Vizij animatables. */
405
+ tracks: VizijAnimationTrackData[];
406
+ }
407
+
373
408
  interface VizijData {
374
409
  world: World;
375
410
  animatables: Record<string, AnimatableValue>;
@@ -525,15 +560,16 @@ declare class EmptyModelError extends Error {
525
560
  declare function loadGLTF(url: string, namespaces: string[], aggressiveImport?: boolean, rootBounds?: {
526
561
  center: RawVector2;
527
562
  size: RawVector2;
528
- }): Promise<[World, Record<string, AnimatableValue>]>;
563
+ }): Promise<[World, Record<string, AnimatableValue>, VizijAnimationClipData[]]>;
529
564
  declare function loadGLTFFromBlob(blob: Blob, namespaces: string[], aggressiveImport?: boolean, rootBounds?: {
530
565
  center: RawVector2;
531
566
  size: RawVector2;
532
- }): Promise<[World, Record<string, AnimatableValue>]>;
567
+ }): Promise<[World, Record<string, AnimatableValue>, VizijAnimationClipData[]]>;
533
568
  type LoadedVizijAsset = {
534
569
  world: World;
535
570
  animatables: Record<string, AnimatableValue>;
536
571
  bundle: VizijBundleExtension | null;
572
+ animations: VizijAnimationClipData[];
537
573
  };
538
574
  declare function loadGLTFWithBundle(url: string, namespaces: string[], aggressiveImport?: boolean, rootBounds?: {
539
575
  center: RawVector2;
@@ -563,4 +599,4 @@ declare function exportScene(data: Group$1, fileNameOrOptions?: string | ExportS
563
599
  declare function extractVizijBundle(object: Object3D, parserJson?: unknown): VizijBundleExtension | null;
564
600
  declare function applyVizijBundle(object: Object3D, bundle: VizijBundleExtension | null): () => void;
565
601
 
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 };
602
+ export { type AnimatedFeature, 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 VizijAnimationClipData, type VizijAnimationId, type VizijAnimationTrackData, 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
@@ -1,20 +1,12 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
1
2
  import * as react from 'react';
2
3
  import { ComponentProps, ReactNode, RefObject } from 'react';
3
- 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
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
- declare function InnerController({ animatableId, namespace, subfield, className, }: {
11
- animatableId: string;
12
- namespace?: string;
13
- subfield?: string;
14
- className?: string;
15
- }): react_jsx_runtime.JSX.Element | undefined;
16
- declare const Controller: react.MemoExoticComponent<typeof InnerController>;
17
-
18
10
  interface VizijProps {
19
11
  style?: React.CSSProperties;
20
12
  className?: string;
@@ -370,6 +362,49 @@ interface VizijBundleExtension {
370
362
  metadata?: Record<string, unknown>;
371
363
  }
372
364
 
365
+ interface VizijAnimationTrackData {
366
+ /** Vizij animatable id extracted from RobotData.features.*.value.id */
367
+ componentId: string;
368
+ /** Feature key (e.g. translation, chin, etc.) */
369
+ feature: string;
370
+ /** Vizij renderable id that owns the feature. */
371
+ renderableId: string;
372
+ /** glTF node index referenced by the channel. */
373
+ nodeIndex: number;
374
+ /** Optional glTF node name for debugging. */
375
+ nodeName?: string;
376
+ /** Original glTF channel path (translation, rotation, etc.). */
377
+ path?: string;
378
+ /** Optional feature component label (e.g. x, y, z) if provided by the glTF channel. */
379
+ component?: string;
380
+ /** Index within the output accessor for multi-component values. */
381
+ componentIndex?: number;
382
+ /** Numeric type reported by the Vizij animatable (number, vector3, etc.). */
383
+ valueType?: string;
384
+ /** Number of numeric entries per keyframe within `values`. */
385
+ valueSize: number;
386
+ /** Interpolation declared on the glTF sampler. */
387
+ interpolation?: string;
388
+ /** Keyframe times extracted from the GLTF animation sampler. */
389
+ times: number[];
390
+ /** Keyframe values (flattened, length === times.length * valueSize). */
391
+ values: number[];
392
+ }
393
+ interface VizijAnimationClipData {
394
+ /** Stable identifier derived from glTF animation name or index. */
395
+ id: string;
396
+ /** Human readable name (mirrors glTF animation name when available). */
397
+ name?: string;
398
+ /** Duration in seconds resolved from the THREE.AnimationClip. */
399
+ duration: number;
400
+ /** Raw glTF animation index in the asset. */
401
+ index: number;
402
+ /** Optional metadata copied from glTF animation extras. */
403
+ metadata?: Record<string, unknown>;
404
+ /** Extracted per-channel track data for Vizij animatables. */
405
+ tracks: VizijAnimationTrackData[];
406
+ }
407
+
373
408
  interface VizijData {
374
409
  world: World;
375
410
  animatables: Record<string, AnimatableValue>;
@@ -525,15 +560,16 @@ declare class EmptyModelError extends Error {
525
560
  declare function loadGLTF(url: string, namespaces: string[], aggressiveImport?: boolean, rootBounds?: {
526
561
  center: RawVector2;
527
562
  size: RawVector2;
528
- }): Promise<[World, Record<string, AnimatableValue>]>;
563
+ }): Promise<[World, Record<string, AnimatableValue>, VizijAnimationClipData[]]>;
529
564
  declare function loadGLTFFromBlob(blob: Blob, namespaces: string[], aggressiveImport?: boolean, rootBounds?: {
530
565
  center: RawVector2;
531
566
  size: RawVector2;
532
- }): Promise<[World, Record<string, AnimatableValue>]>;
567
+ }): Promise<[World, Record<string, AnimatableValue>, VizijAnimationClipData[]]>;
533
568
  type LoadedVizijAsset = {
534
569
  world: World;
535
570
  animatables: Record<string, AnimatableValue>;
536
571
  bundle: VizijBundleExtension | null;
572
+ animations: VizijAnimationClipData[];
537
573
  };
538
574
  declare function loadGLTFWithBundle(url: string, namespaces: string[], aggressiveImport?: boolean, rootBounds?: {
539
575
  center: RawVector2;
@@ -563,4 +599,4 @@ declare function exportScene(data: Group$1, fileNameOrOptions?: string | ExportS
563
599
  declare function extractVizijBundle(object: Object3D, parserJson?: unknown): VizijBundleExtension | null;
564
600
  declare function applyVizijBundle(object: Object3D, bundle: VizijBundleExtension | null): () => void;
565
601
 
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 };
602
+ export { type AnimatedFeature, 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 VizijAnimationClipData, type VizijAnimationId, type VizijAnimationTrackData, 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 };