@vizij/render 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 +147 -0
- package/dist/index.d.mts +456 -0
- package/dist/index.d.ts +456 -0
- package/dist/index.js +2723 -0
- package/dist/index.mjs +2727 -0
- package/package.json +88 -0
package/README.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# @vizij/render
|
|
2
|
+
|
|
3
|
+
> Three.js + React renderer, scene store, and helper controllers for Vizij faces.
|
|
4
|
+
|
|
5
|
+
This package exposes the `Vizij` canvas component along with hooks, stores, and GLTF helpers that power Vizij’s real-time character visualisation. It is the foundation that other packages (`@vizij/rig`, `@vizij/orchestrator-react`, etc.) build upon.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Table of Contents
|
|
10
|
+
|
|
11
|
+
1. [Overview](#overview)
|
|
12
|
+
2. [Installation](#installation)
|
|
13
|
+
3. [Usage](#usage)
|
|
14
|
+
4. [Store & Hooks](#store--hooks)
|
|
15
|
+
5. [Controllers & Helpers](#controllers--helpers)
|
|
16
|
+
6. [Development & Testing](#development--testing)
|
|
17
|
+
7. [Publishing](#publishing)
|
|
18
|
+
8. [Related Packages](#related-packages)
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Overview
|
|
23
|
+
|
|
24
|
+
- `Vizij` renders a fully managed `@react-three/fiber` canvas with sensible defaults for orthographic cameras and safe-area overlays.
|
|
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.
|
|
27
|
+
- Controllers wrap common behaviours (e.g., pointer interaction, safe-area visualisation) so you can compose features quickly.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# pnpm
|
|
35
|
+
pnpm add @vizij/render three @react-three/fiber @react-three/drei zustand @vizij/utils
|
|
36
|
+
|
|
37
|
+
# npm
|
|
38
|
+
npm install @vizij/render three @react-three/fiber @react-three/drei zustand @vizij/utils
|
|
39
|
+
|
|
40
|
+
# yarn
|
|
41
|
+
yarn add @vizij/render three @react-three/fiber @react-three/drei zustand @vizij/utils
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Peer requirements:
|
|
45
|
+
|
|
46
|
+
- `react >= 18`
|
|
47
|
+
- `three >= 0.170`
|
|
48
|
+
- `@react-three/fiber >= 8`
|
|
49
|
+
- `@react-three/drei >= 9`
|
|
50
|
+
- `zustand >= 5`
|
|
51
|
+
- Optional UI integrations: `tailwindcss >= 4.1` (declared as a peer for theme utilities)
|
|
52
|
+
|
|
53
|
+
Ensure these versions align with the rest of your app to avoid duplicate React or Three.js instances.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Usage
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import { Vizij, useVizijStore } from "@vizij/render";
|
|
61
|
+
import { useEffect } from "react";
|
|
62
|
+
|
|
63
|
+
export function VizijCanvas() {
|
|
64
|
+
const setDebug = useVizijStore((state) => state.setDebugState);
|
|
65
|
+
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
setDebug((debug) => ({ ...debug, showGrid: true }));
|
|
68
|
+
}, [setDebug]);
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<Vizij
|
|
72
|
+
rootId="default/root"
|
|
73
|
+
namespace="default"
|
|
74
|
+
showSafeArea
|
|
75
|
+
style={{ width: "100%", height: 480 }}
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Wrap the component tree with `VizijContext.Provider` if you want to supply a custom store; otherwise the `Vizij` component creates one internally.
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Store & Hooks
|
|
86
|
+
|
|
87
|
+
- `useVizijStore(selector?)` – Access or mutate the renderer store with automatic subscription management.
|
|
88
|
+
- `useVizijStoreGetter`, `useVizijStoreSetter`, `useVizijStoreSubscription` – Fine-grained accessors when you need optimised reads/writes.
|
|
89
|
+
- `useFeatures()` – Inspect feature flags registered in the store.
|
|
90
|
+
- Store types (`VizijData`, `VizijActions`) are exported from `store-types` for strongly typed selectors.
|
|
91
|
+
|
|
92
|
+
The store tracks world graph entries, controllers, debug overlays, and renderable metadata. See `src/store.ts` for the full surface.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Controllers & Helpers
|
|
97
|
+
|
|
98
|
+
- Controllers under `src/controllers` encapsulate input handling, camera logic, and other behaviours. Compose them with your own React components.
|
|
99
|
+
- `loadGLTF` / `loadGLTFBlob` simplify loading rig assets and extract animatable metadata used by `@vizij/rig`.
|
|
100
|
+
- `export` helpers produce snapshots of the current scene (useful for tooling or exporting frames).
|
|
101
|
+
|
|
102
|
+
All exports are re-exported through `src/index.tsx`, so a simple `import { loadGLTF } from "@vizij/render"` works.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Development & Testing
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
pnpm --filter "@vizij/render" build
|
|
110
|
+
pnpm --filter "@vizij/render" test
|
|
111
|
+
pnpm --filter "@vizij/render" typecheck
|
|
112
|
+
pnpm --filter "@vizij/render" lint
|
|
113
|
+
pnpm --filter "@vizij/render" size
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
`tsup` produces both ESM and CJS bundles with type declarations. Tests run via Vitest (currently smoke-level), and `size-limit` guards against unexpected bundle growth.
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Publishing
|
|
121
|
+
|
|
122
|
+
Use the shared workflow at [`.github/workflows/publish-npm.yml`](../../.github/workflows/publish-npm.yml).
|
|
123
|
+
|
|
124
|
+
1. Align dependency versions (`three`, `@react-three/*`, `zustand`, Vizij packages) and generate a changeset:
|
|
125
|
+
```bash
|
|
126
|
+
pnpm changeset
|
|
127
|
+
pnpm version:packages
|
|
128
|
+
```
|
|
129
|
+
2. Validate locally:
|
|
130
|
+
```bash
|
|
131
|
+
pnpm install
|
|
132
|
+
pnpm --filter "@vizij/render" build
|
|
133
|
+
pnpm --filter "@vizij/render" test
|
|
134
|
+
pnpm --filter "@vizij/render" typecheck
|
|
135
|
+
pnpm --filter "@vizij/render" lint
|
|
136
|
+
pnpm --filter "@vizij/render" exec npm pack --dry-run
|
|
137
|
+
```
|
|
138
|
+
3. Tag the release as `npm-render-vX.Y.Z` and push the tag. The workflow will publish with provenance metadata.
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## Related Packages
|
|
143
|
+
|
|
144
|
+
- [`@vizij/rig`](../@vizij/rig/README.md) – Hooks that consume the renderer to load rigged models.
|
|
145
|
+
- [`@vizij/animation-react`](../@vizij/animation-react/README.md) – React bindings that feed animation values back into the renderer.
|
|
146
|
+
|
|
147
|
+
Questions or contributions? Open an issue so we can keep the renderer API and docs sharp for the whole Vizij ecosystem. 🎨
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ComponentProps, ReactNode, RefObject } from 'react';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
import { Canvas, ThreeEvent } from '@react-three/fiber';
|
|
5
|
+
import * as zustand from 'zustand';
|
|
6
|
+
import * as THREE from 'three';
|
|
7
|
+
import { Mesh, Group as Group$1, BufferGeometry, ShapeGeometry } from 'three';
|
|
8
|
+
import { RawValue, AnimatableValue, RawVector2 } from '@vizij/utils';
|
|
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
|
+
interface VizijProps {
|
|
19
|
+
style?: React.CSSProperties;
|
|
20
|
+
className?: string;
|
|
21
|
+
rootId: string;
|
|
22
|
+
namespace?: string;
|
|
23
|
+
showSafeArea?: boolean;
|
|
24
|
+
onPointerMissed?: ComponentProps<typeof Canvas>["onPointerMissed"];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Renders the Vizij component.
|
|
28
|
+
*
|
|
29
|
+
* @param style - The style object for the Vizij component.
|
|
30
|
+
*
|
|
31
|
+
* @param className - The CSS class name for the Vizij component
|
|
32
|
+
*
|
|
33
|
+
* @param rootId - The root identifier for the Vizij component.
|
|
34
|
+
*
|
|
35
|
+
* @param namespace - The namespace for the Vizij component
|
|
36
|
+
*
|
|
37
|
+
* @param showSafeArea - Whether to show the safe area.
|
|
38
|
+
*
|
|
39
|
+
* @returns The rendered ReactNode.
|
|
40
|
+
*/
|
|
41
|
+
declare function Vizij({ style, className, rootId, namespace, showSafeArea, onPointerMissed, }: VizijProps): ReactNode;
|
|
42
|
+
interface InnerVizijProps {
|
|
43
|
+
rootId: string;
|
|
44
|
+
namespace: string;
|
|
45
|
+
container?: {
|
|
46
|
+
width: number;
|
|
47
|
+
height: number;
|
|
48
|
+
resolution: number;
|
|
49
|
+
};
|
|
50
|
+
showSafeArea?: boolean;
|
|
51
|
+
}
|
|
52
|
+
declare function InnerVizij({ rootId, namespace, container, showSafeArea, }: InnerVizijProps): react_jsx_runtime.JSX.Element;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* A wrapping type to reference an attribute that is animatable.
|
|
56
|
+
*
|
|
57
|
+
* @param amimated - A boolean indicating whether the feature is animated. Always true for an AnimatedFeature.
|
|
58
|
+
* @param value - The id of the {@link AnimatableValue} used to populate this value.
|
|
59
|
+
*/
|
|
60
|
+
interface AnimatedFeature {
|
|
61
|
+
animated: true;
|
|
62
|
+
value: string;
|
|
63
|
+
label?: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* A wrapping type to specify an attribute that is not animatable (i.e. static) directly.
|
|
67
|
+
*
|
|
68
|
+
* @param amimated - A boolean indicating whether the feature is animated. Always false for a StaticFeature.
|
|
69
|
+
* @param value - The value {@link RawValue} of the feature.
|
|
70
|
+
*/
|
|
71
|
+
interface StaticFeature {
|
|
72
|
+
animated: false;
|
|
73
|
+
value: RawValue;
|
|
74
|
+
label?: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A wrapping type to specify an attribute that is animatable, modified to directly
|
|
78
|
+
* include the {@link AnimatableValue} for storage.
|
|
79
|
+
*
|
|
80
|
+
* @param amimated - A boolean indicating whether the feature is animated. Always true for an AnimatedFeature.
|
|
81
|
+
* @param value - The {@link AnimatableValue} used to populate this value.
|
|
82
|
+
*/
|
|
83
|
+
interface StoredAnimatedFeature {
|
|
84
|
+
animated: true;
|
|
85
|
+
value: AnimatableValue;
|
|
86
|
+
label?: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* A wrapping type to reference an attribute that is either animatable or static.
|
|
90
|
+
*
|
|
91
|
+
* @param amimated - A boolean indicating whether the feature is animated.
|
|
92
|
+
* @param value - The id of the {@link AnimatableValue} used to populate this value if animated, or the value {@link RawValue} if static.
|
|
93
|
+
*/
|
|
94
|
+
type Feature = AnimatedFeature | StaticFeature;
|
|
95
|
+
|
|
96
|
+
interface RenderableBase {
|
|
97
|
+
id: string;
|
|
98
|
+
name: string;
|
|
99
|
+
tags: string[];
|
|
100
|
+
type: string;
|
|
101
|
+
refs: Record<string, RefObject<any>>;
|
|
102
|
+
features: Record<string, Feature>;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
type StoredFeatures<T extends RenderableBase["features"]> = {
|
|
106
|
+
[key in keyof T]: StaticFeature | StoredAnimatedFeature;
|
|
107
|
+
};
|
|
108
|
+
interface Stored<T extends Omit<RenderableBase, "refs">> {
|
|
109
|
+
id: T["id"];
|
|
110
|
+
name: T["name"];
|
|
111
|
+
tags: T["tags"];
|
|
112
|
+
type: T["type"];
|
|
113
|
+
features: StoredFeatures<T["features"]>;
|
|
114
|
+
}
|
|
115
|
+
type StoredRenderable = Stored<RenderableBase>;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* An object for creating hierarchies/bodies
|
|
119
|
+
*
|
|
120
|
+
* @param id - The id of the ellipse
|
|
121
|
+
* @param name - The name of the ellipse
|
|
122
|
+
* @param tags - The tags of the ellipse
|
|
123
|
+
* @param type - Type flag
|
|
124
|
+
* @param refs - The reference to the group[s] in the scene, for each namespace
|
|
125
|
+
* @param features - The features of the ellipse (translation, rotation, and scale)
|
|
126
|
+
* @param children - The children of the ellipse (list of ids for other bodies or shapes)
|
|
127
|
+
*/
|
|
128
|
+
interface Ellipse extends RenderableBase {
|
|
129
|
+
type: "ellipse";
|
|
130
|
+
refs: Record<string, RefObject<Mesh>>;
|
|
131
|
+
features: {
|
|
132
|
+
height: Feature;
|
|
133
|
+
width: Feature;
|
|
134
|
+
fillOpacity?: Feature;
|
|
135
|
+
strokeOpacity?: Feature;
|
|
136
|
+
fillColor?: Feature;
|
|
137
|
+
strokeColor?: Feature;
|
|
138
|
+
strokeWidth?: Feature;
|
|
139
|
+
strokeOffset?: Feature;
|
|
140
|
+
translation: Feature;
|
|
141
|
+
rotation: Feature;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
type EllipseFeature = keyof Ellipse["features"];
|
|
145
|
+
type StoredEllipse = Stored<Ellipse>;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* An object for creating rectangles
|
|
149
|
+
*
|
|
150
|
+
* @param id - The id of the rectangle
|
|
151
|
+
* @param name - The name of the rectangle
|
|
152
|
+
* @param tags - The tags of the rectangle
|
|
153
|
+
* @param type - Type flag
|
|
154
|
+
* @param refs - The reference to the group[s] in the scene, for each namespace
|
|
155
|
+
* @param features - The features of the rectangle (translation, rotation, and scale)
|
|
156
|
+
* @param children - The children of the rectangle (list of ids for other bodies or shapes)
|
|
157
|
+
*/
|
|
158
|
+
interface Rectangle extends RenderableBase {
|
|
159
|
+
type: "rectangle";
|
|
160
|
+
refs: Record<string, RefObject<Mesh>>;
|
|
161
|
+
features: {
|
|
162
|
+
height: Feature;
|
|
163
|
+
width: Feature;
|
|
164
|
+
fillOpacity?: Feature;
|
|
165
|
+
strokeOpacity?: Feature;
|
|
166
|
+
fillColor?: Feature;
|
|
167
|
+
strokeColor?: Feature;
|
|
168
|
+
strokeWidth?: Feature;
|
|
169
|
+
strokeRadius?: Feature;
|
|
170
|
+
strokeOffset?: Feature;
|
|
171
|
+
translation: Feature;
|
|
172
|
+
rotation: Feature;
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
type RectangleFeature = keyof Rectangle["features"];
|
|
176
|
+
type StoredRectangle = Stored<Rectangle>;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* An object for creating hierarchies/groups
|
|
180
|
+
*
|
|
181
|
+
* @param id - The id of the group
|
|
182
|
+
* @param name - The name of the group
|
|
183
|
+
* @param tags - The tags of the group
|
|
184
|
+
* @param type - Type flag
|
|
185
|
+
* @param refs - The reference to the group[s] in the vizij, for each namespace
|
|
186
|
+
* @param features - The features of the group (translation, rotation, and scale)
|
|
187
|
+
* @param root - Whether the group is a root node
|
|
188
|
+
* @param children - The children of the group (list of ids for other groups or shapes)
|
|
189
|
+
*/
|
|
190
|
+
interface Group extends RenderableBase {
|
|
191
|
+
type: "group";
|
|
192
|
+
refs: Record<string, RefObject<Group$1>>;
|
|
193
|
+
root: boolean;
|
|
194
|
+
features: {
|
|
195
|
+
translation: Feature;
|
|
196
|
+
rotation: Feature;
|
|
197
|
+
scale?: Feature;
|
|
198
|
+
};
|
|
199
|
+
rootBounds?: {
|
|
200
|
+
center: RawVector2;
|
|
201
|
+
size: RawVector2;
|
|
202
|
+
};
|
|
203
|
+
children: string[];
|
|
204
|
+
}
|
|
205
|
+
type GroupFeature = keyof Group["features"];
|
|
206
|
+
type StoredGroup = Stored<Group>;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Represents a 3D mesh object in the scene that can be rendered.
|
|
210
|
+
*
|
|
211
|
+
* Shapes are the visual building blocks of the scene, containing geometry and material
|
|
212
|
+
* properties that define their appearance.
|
|
213
|
+
*
|
|
214
|
+
* @property id - Unique identifier for the shape
|
|
215
|
+
* @property name - Human-readable name for the shape
|
|
216
|
+
* @property tags - List of tags for categorizing and filtering
|
|
217
|
+
* @property type - Always "shape"
|
|
218
|
+
* @property refs - Map of React refs to Three.js Mesh objects
|
|
219
|
+
* @property features - Visual and transformation properties that can be animated
|
|
220
|
+
* @property material - The type of Three.js material to use for rendering
|
|
221
|
+
* @property geometry - The Three.js geometry defining the shape's structure
|
|
222
|
+
*
|
|
223
|
+
* @remarks
|
|
224
|
+
* Features include material properties (shininess, opacity, etc.) and transformations
|
|
225
|
+
* (translation, rotation, scale).
|
|
226
|
+
*/
|
|
227
|
+
interface Shape extends RenderableBase {
|
|
228
|
+
type: "shape";
|
|
229
|
+
refs: Record<string, RefObject<Mesh>>;
|
|
230
|
+
features: {
|
|
231
|
+
shininess?: Feature;
|
|
232
|
+
opacity?: Feature;
|
|
233
|
+
roughness?: Feature;
|
|
234
|
+
metalness?: Feature;
|
|
235
|
+
color?: Feature;
|
|
236
|
+
translation: Feature;
|
|
237
|
+
rotation: Feature;
|
|
238
|
+
scale?: Feature;
|
|
239
|
+
};
|
|
240
|
+
material: ShapeMaterial;
|
|
241
|
+
geometry: BufferGeometry | ShapeGeometry;
|
|
242
|
+
morphTargets?: string[];
|
|
243
|
+
children?: string[];
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Supported material types for shapes.
|
|
247
|
+
*
|
|
248
|
+
* @remarks
|
|
249
|
+
* Maps to Three.js material types.
|
|
250
|
+
*/
|
|
251
|
+
declare enum ShapeMaterial {
|
|
252
|
+
Standard = "standard",
|
|
253
|
+
Phong = "phong",
|
|
254
|
+
Basic = "basic",
|
|
255
|
+
Lambert = "lambert",
|
|
256
|
+
Normal = "normal"
|
|
257
|
+
}
|
|
258
|
+
type ShapeFeature = keyof Shape["features"];
|
|
259
|
+
type StoredShape = Stored<Omit<Shape, "geometry">>;
|
|
260
|
+
|
|
261
|
+
type World = Record<string, Group | Ellipse | Rectangle | Shape>;
|
|
262
|
+
|
|
263
|
+
type RenderableFeature = GroupFeature | EllipseFeature;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* A type representing the selection of an element.
|
|
267
|
+
* @param {string} id - The unique identifier of the id being selected.
|
|
268
|
+
* @param {string} namespace - The namespace of the selection.
|
|
269
|
+
* @param {string} type - The type of the selection.
|
|
270
|
+
* @param {string} [color] - The color of the selection.
|
|
271
|
+
* @param {object} [tooltip] - The tooltip information for the selection.
|
|
272
|
+
*/
|
|
273
|
+
interface Selection {
|
|
274
|
+
id: string;
|
|
275
|
+
namespace: string;
|
|
276
|
+
type: "body" | "joint" | "screen" | "shape" | "slot" | "group" | "ellipse" | "rectangle" | "animatable" | "parent";
|
|
277
|
+
color?: string;
|
|
278
|
+
tooltip?: {
|
|
279
|
+
type: "animatable" | "text";
|
|
280
|
+
title: string;
|
|
281
|
+
description?: string;
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
interface VizijData {
|
|
286
|
+
world: World;
|
|
287
|
+
animatables: Record<string, AnimatableValue>;
|
|
288
|
+
values: Map<string, RawValue | undefined>;
|
|
289
|
+
renderHit: boolean;
|
|
290
|
+
preferences: {
|
|
291
|
+
damping: boolean;
|
|
292
|
+
};
|
|
293
|
+
elementSelection: Selection[];
|
|
294
|
+
hoveredElement: Selection | null;
|
|
295
|
+
slotConfig: Record<string, string>;
|
|
296
|
+
}
|
|
297
|
+
interface VizijActions {
|
|
298
|
+
setValue: (id: string, namespace: string, value: RawValue | ((current: RawValue | undefined) => RawValue | undefined)) => void;
|
|
299
|
+
setWorldElementName: (id: string, value: string) => void;
|
|
300
|
+
setVizij: (scene: World, animatables: Record<string, AnimatableValue>) => void;
|
|
301
|
+
setSlot: (parentId: string, parentNamespace: string, childId: string, childNamespace: string) => void;
|
|
302
|
+
setSlots: (slots: Record<string, string>, replace?: boolean) => void;
|
|
303
|
+
clearSlot: (parentId: string, parentNamespace: string) => void;
|
|
304
|
+
addWorldElements: (world: World, animatables: Record<string, AnimatableValue>, replace?: boolean) => void;
|
|
305
|
+
setPreferences: (preferences: Partial<VizijData["preferences"]>) => void;
|
|
306
|
+
getExportableBodies: (filterIds?: string[]) => Group$1[];
|
|
307
|
+
updateElementSelection: (selection: Selection, chain: string[]) => void;
|
|
308
|
+
setHoveredElement: (selection: Selection | null) => void;
|
|
309
|
+
onElementClick: (selection: Selection, chain: string[], event: ThreeEvent<MouseEvent>) => void;
|
|
310
|
+
clearSelection: () => void;
|
|
311
|
+
setOrigin: (id: string, origin: {
|
|
312
|
+
translation?: THREE.Vector3;
|
|
313
|
+
rotation?: THREE.Vector3;
|
|
314
|
+
}) => void;
|
|
315
|
+
setAxis: (id: string, axis: THREE.Vector3) => void;
|
|
316
|
+
setTags: (id: string, tags: string[]) => void;
|
|
317
|
+
setStaticFeature: (id: string, feature: RenderableFeature, value: RawValue) => void;
|
|
318
|
+
setAnimatableValue: (id: string, value: AnimatableValue) => void;
|
|
319
|
+
setParent: (id: string, parent: string) => void;
|
|
320
|
+
setChild: (id: string, child: string) => void;
|
|
321
|
+
setChildren: (id: string, children: string[]) => void;
|
|
322
|
+
setGeometry: (id: string, geometry: THREE.BufferGeometry) => void;
|
|
323
|
+
setMaterial: (id: string, material: string) => void;
|
|
324
|
+
setReference: (id: string, namespace: string, object: RefObject<Group$1 | Mesh>) => void;
|
|
325
|
+
createGroup: (root: boolean) => void;
|
|
326
|
+
createAnimatable: (elementId: string, featureName: string, value: Partial<AnimatableValue>) => void;
|
|
327
|
+
createStatic: (elementId: string, featureName: string, value: RawValue) => void;
|
|
328
|
+
}
|
|
329
|
+
type VizijStoreSetter = (partial: (VizijData & VizijActions) | Partial<VizijData & VizijActions> | ((state: VizijData & VizijActions) => (VizijData & VizijActions) | Partial<VizijData & VizijActions>), replace?: false | undefined) => void;
|
|
330
|
+
type VizijStoreGetter = () => VizijData & VizijActions;
|
|
331
|
+
|
|
332
|
+
declare const VizijSlice: (set: VizijStoreSetter, get: VizijStoreGetter) => {
|
|
333
|
+
world: {};
|
|
334
|
+
animatables: {};
|
|
335
|
+
values: Map<any, any>;
|
|
336
|
+
renderHit: boolean;
|
|
337
|
+
preferences: {
|
|
338
|
+
damping: boolean;
|
|
339
|
+
};
|
|
340
|
+
elementSelection: never[];
|
|
341
|
+
hoveredElement: null;
|
|
342
|
+
slotConfig: {};
|
|
343
|
+
clearSelection: () => void;
|
|
344
|
+
updateElementSelection: (selection: Selection, _chain: string[]) => void;
|
|
345
|
+
setHoveredElement: (selection: Selection | null) => void;
|
|
346
|
+
onElementClick: (selection: Selection, _chain: string[], event: ThreeEvent<MouseEvent>) => void;
|
|
347
|
+
getExportableBodies: (filterIds?: string[]) => THREE.Group<THREE.Object3DEventMap>[];
|
|
348
|
+
setGeometry: (id: string, geometry: THREE.BufferGeometry) => void;
|
|
349
|
+
setValue: (id: string, namespace: string, value: RawValue | ((current: RawValue | undefined) => RawValue | undefined)) => void;
|
|
350
|
+
setWorldElementName: (id: string, value: string) => void;
|
|
351
|
+
setParent: (id: string, parent: string) => void;
|
|
352
|
+
setChild: (id: string, child: string) => void;
|
|
353
|
+
setChildren: (id: string, children: string[]) => void;
|
|
354
|
+
createGroup: (root: boolean) => void;
|
|
355
|
+
setOrigin: (id: string, origin: {
|
|
356
|
+
translation?: THREE.Vector3;
|
|
357
|
+
rotation?: THREE.Vector3;
|
|
358
|
+
}) => void;
|
|
359
|
+
setAxis: (id: string, axis: THREE.Vector3) => void;
|
|
360
|
+
setTags: (id: string, tags: string[]) => void;
|
|
361
|
+
setMaterial: (id: string, material: string) => void;
|
|
362
|
+
setStaticFeature: (id: string, feature: RenderableFeature, value: RawValue) => void;
|
|
363
|
+
createAnimatable: (elementId: string, featureName: string, value: Partial<AnimatableValue>) => void;
|
|
364
|
+
createStatic: (elementId: string, featureName: string, value: RawValue) => void;
|
|
365
|
+
setAnimatableValue: (id: string, value: AnimatableValue) => void;
|
|
366
|
+
setSlot: (parentId: string, parentNamespace: string, childId: string, childNamespace: string) => void;
|
|
367
|
+
setSlots: (slots: Record<string, string>, replace?: boolean) => void;
|
|
368
|
+
clearSlot: (parentId: string, parentNamespace: string) => void;
|
|
369
|
+
setVizij: (scene: World, animatables: Record<string, AnimatableValue>) => void;
|
|
370
|
+
addWorldElements(world: World, animatables: Record<string, AnimatableValue>, replace?: boolean): void;
|
|
371
|
+
setPreferences: (preferences: Partial<VizijData["preferences"]>) => void;
|
|
372
|
+
setReference: (id: string, namespace: string, ref: RefObject<Group$1 | Mesh>) => void;
|
|
373
|
+
};
|
|
374
|
+
declare const useDefaultVizijStore: zustand.UseBoundStore<Omit<zustand.StoreApi<VizijData & VizijActions>, "subscribe"> & {
|
|
375
|
+
subscribe: {
|
|
376
|
+
(listener: (selectedState: VizijData & VizijActions, previousSelectedState: VizijData & VizijActions) => void): () => void;
|
|
377
|
+
<U>(selector: (state: VizijData & VizijActions) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
378
|
+
equalityFn?: ((a: U, b: U) => boolean) | undefined;
|
|
379
|
+
fireImmediately?: boolean;
|
|
380
|
+
} | undefined): () => void;
|
|
381
|
+
};
|
|
382
|
+
}>;
|
|
383
|
+
declare const createVizijStore: (initial?: Partial<VizijData & VizijActions>) => zustand.UseBoundStore<Omit<zustand.StoreApi<VizijData & VizijActions>, "subscribe"> & {
|
|
384
|
+
subscribe: {
|
|
385
|
+
(listener: (selectedState: VizijData & VizijActions, previousSelectedState: VizijData & VizijActions) => void): () => void;
|
|
386
|
+
<U>(selector: (state: VizijData & VizijActions) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
387
|
+
equalityFn?: ((a: U, b: U) => boolean) | undefined;
|
|
388
|
+
fireImmediately?: boolean;
|
|
389
|
+
} | undefined): () => void;
|
|
390
|
+
};
|
|
391
|
+
}>;
|
|
392
|
+
type VizijStore = typeof useDefaultVizijStore;
|
|
393
|
+
|
|
394
|
+
declare const VizijContext: react.Context<zustand.UseBoundStore<Omit<zustand.StoreApi<VizijData & VizijActions>, "subscribe"> & {
|
|
395
|
+
subscribe: {
|
|
396
|
+
(listener: (selectedState: VizijData & VizijActions, previousSelectedState: VizijData & VizijActions) => void): () => void;
|
|
397
|
+
<U>(selector: (state: VizijData & VizijActions) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
398
|
+
equalityFn?: ((a: U, b: U) => boolean) | undefined;
|
|
399
|
+
fireImmediately?: boolean;
|
|
400
|
+
} | undefined): () => void;
|
|
401
|
+
};
|
|
402
|
+
}> | null>;
|
|
403
|
+
|
|
404
|
+
declare function useVizijStore<T>(selector: (state: VizijData & VizijActions) => T): T;
|
|
405
|
+
|
|
406
|
+
declare function useVizijStoreSubscription<T>(selector: (state: VizijData & VizijActions) => T, listener: (state: T) => void): void;
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Custom React hook to manage and subscribe to feature values.
|
|
410
|
+
*
|
|
411
|
+
* @param namespace - The namespace for the features.
|
|
412
|
+
* @param features - A record of feature objects keyed by their IDs.
|
|
413
|
+
* @param callbacks - A record of callback functions keyed by feature IDs.
|
|
414
|
+
* @param debugInfo - Optional debug information to log in case of errors.
|
|
415
|
+
*
|
|
416
|
+
* @throws [Error] If the SceneContext store is not found.
|
|
417
|
+
*
|
|
418
|
+
* @returns [void]
|
|
419
|
+
*
|
|
420
|
+
* This hook sets up subscriptions to feature values and invokes the provided callbacks when the values change.
|
|
421
|
+
* It handles both animated and non-animated features. For animated features, it subscribes to the animatable value
|
|
422
|
+
* in the store and invokes the callback whenever the value changes. For non-animated features, it immediately
|
|
423
|
+
* invokes the callback with the feature's value.
|
|
424
|
+
*/
|
|
425
|
+
declare function useFeatures(namespace: string, features: Record<string, Feature>, callbacks: Record<string, (current: RawValue) => void>, debugInfo?: any): void;
|
|
426
|
+
|
|
427
|
+
declare function useVizijStoreSetter(): {
|
|
428
|
+
(partial: (VizijData & VizijActions) | Partial<VizijData & VizijActions> | ((state: VizijData & VizijActions) => (VizijData & VizijActions) | Partial<VizijData & VizijActions>), replace?: false): void;
|
|
429
|
+
(state: (VizijData & VizijActions) | ((state: VizijData & VizijActions) => VizijData & VizijActions), replace: true): void;
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
declare function useVizijStoreGetter(): () => VizijData & VizijActions;
|
|
433
|
+
|
|
434
|
+
declare class EmptyModelError extends Error {
|
|
435
|
+
constructor(message: string);
|
|
436
|
+
}
|
|
437
|
+
declare function loadGLTF(url: string, namespaces: string[], aggressiveImport?: boolean, rootBounds?: {
|
|
438
|
+
center: RawVector2;
|
|
439
|
+
size: RawVector2;
|
|
440
|
+
}): Promise<[World, Record<string, AnimatableValue>]>;
|
|
441
|
+
declare function loadGLTFFromBlob(blob: Blob, namespaces: string[], aggressiveImport?: boolean, rootBounds?: {
|
|
442
|
+
center: RawVector2;
|
|
443
|
+
size: RawVector2;
|
|
444
|
+
}): Promise<[World, Record<string, AnimatableValue>]>;
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Loads a GLTF model from a Blob and returns the Three.js scene containing the model.
|
|
448
|
+
*
|
|
449
|
+
* @param blob - The Blob containing the GLTF data.
|
|
450
|
+
* @returns A Promise that resolves with the THREE.Scene containing the loaded model.
|
|
451
|
+
*/
|
|
452
|
+
declare const loadGltfFromBlob: (blob: Blob, namespaces: string[]) => Promise<[World, Record<string, AnimatableValue>]>;
|
|
453
|
+
|
|
454
|
+
declare function exportScene(data: Group$1, fileName?: string): void;
|
|
455
|
+
|
|
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 };
|