@liveroom-tech/react-immersive 5.1.0 → 5.3.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.
Files changed (48) hide show
  1. package/LICENSE +10 -6
  2. package/README.md +106 -3427
  3. package/dist/binding-builder.css +1 -1
  4. package/dist/binding-builder.js +64 -13
  5. package/dist/binding-builder.mjs +1 -1
  6. package/dist/chunk-4FDMYUGT.mjs +3 -0
  7. package/dist/chunk-CV4E7DOO.mjs +79 -0
  8. package/dist/chunk-F4WT3HEK.mjs +1 -0
  9. package/dist/chunk-FPJZDEON.mjs +1 -0
  10. package/dist/chunk-JHKMRMJH.mjs +1 -0
  11. package/dist/chunk-TW2M4UXT.mjs +1 -0
  12. package/dist/chunk-W24UP6NM.mjs +1 -0
  13. package/dist/hosted.css +1 -1
  14. package/dist/hosted.d.mts +8 -5
  15. package/dist/hosted.d.ts +8 -5
  16. package/dist/hosted.js +63 -12
  17. package/dist/hosted.mjs +1 -1
  18. package/dist/index.css +1 -1
  19. package/dist/index.d.mts +48 -9
  20. package/dist/index.d.ts +48 -9
  21. package/dist/index.js +62 -11
  22. package/dist/index.mjs +1 -1
  23. package/dist/materialVariants-DjTuiWmN.d.mts +314 -0
  24. package/dist/materialVariants-DjTuiWmN.d.ts +314 -0
  25. package/dist/modelInfo-BQ5UZu95.d.ts +43 -0
  26. package/dist/modelInfo-CcYpydB7.d.mts +43 -0
  27. package/dist/{ModelViewer-Bj-KjiDL.d.mts → modelViewerProps-BalkRDni.d.ts} +133 -12
  28. package/dist/{ModelViewer-BkQ73y6N.d.ts → modelViewerProps-DdsJDRB7.d.mts} +133 -12
  29. package/dist/{objectCatalog-BIeXURoq.d.ts → rendererBackend-C_Jb4_Jy.d.mts} +47 -5
  30. package/dist/{objectCatalog-BIeXURoq.d.mts → rendererBackend-C_Jb4_Jy.d.ts} +47 -5
  31. package/dist/simple-model-viewer.css +1 -1
  32. package/dist/simple-model-viewer.d.mts +32 -4
  33. package/dist/simple-model-viewer.d.ts +32 -4
  34. package/dist/simple-model-viewer.js +3 -3
  35. package/dist/simple-model-viewer.mjs +1 -1
  36. package/dist/utils.d.mts +5 -4
  37. package/dist/utils.d.ts +5 -4
  38. package/dist/utils.js +1 -1
  39. package/dist/utils.mjs +1 -1
  40. package/package.json +3 -1
  41. package/dist/chunk-32WCLPTZ.mjs +0 -1
  42. package/dist/chunk-CSGNL4XU.mjs +0 -3
  43. package/dist/chunk-F2ILTIPG.mjs +0 -28
  44. package/dist/chunk-SEESCGUS.mjs +0 -1
  45. package/dist/chunk-V6GALFL5.mjs +0 -1
  46. package/dist/chunk-WN6GMMHF.mjs +0 -1
  47. package/dist/modelInfo-DnkmTGMd.d.mts +0 -23
  48. package/dist/modelInfo-DnkmTGMd.d.ts +0 -23
package/README.md CHANGED
@@ -1,3467 +1,146 @@
1
- # React Immersive — 3D model viewer for React
1
+ # React Immersive — 3D model viewers for React
2
2
 
3
- `@liveroom-tech/react-immersive` is a React-based 3D model viewer for interactive GLB, GLTF, OBJ, FBX, and USDZ assets. It renders a model with React Three Fiber, lets users click named meshes, shows a built-in side panel for the selected object, and supports per-object actions such as color changes, texture uploads, and visibility toggles.
3
+ `@liveroom-tech/react-immersive` renders GLB/GLTF, OBJ, FBX, USDZ, STL, and PLY
4
+ assets in React. Use its components and hooks for mesh selection, materials,
5
+ visibility, camera control, animations, annotations, and scene authoring.
4
6
 
5
- [Website](https://react-immersive.liveroom.dev) · [Documentation](https://react-immersive.liveroom.dev/docs) · [Live editor](https://react-immersive.liveroom.dev/editor) · [npm](https://www.npmjs.com/package/@liveroom-tech/react-immersive) · [GitHub](https://github.com/Liveroom-Technologies/react-immersive-docs)
7
+ **Documentation baseline: 5.2.0 · React 19.**
6
8
 
7
- ## What It Does
9
+ [Documentation](https://react-immersive.liveroom.dev/docs) ·
10
+ [AI Agent Guide](https://react-immersive.liveroom.dev/docs/agent-guide.md) ·
11
+ [Markdown index](https://react-immersive.liveroom.dev/llms.txt) ·
12
+ [Examples](https://react-immersive.liveroom.dev/docs/examples) ·
13
+ [Public GitHub](https://github.com/Liveroom-Technologies/react-immersive-docs)
8
14
 
9
- The library currently exports:
15
+ ## Choose a component
10
16
 
11
- ```ts
12
- import {
13
- material,
14
- ModelViewer,
15
- patchBindings,
16
- patchSceneConfig,
17
- useObjectBinding,
18
- useObjectBindingIds,
19
- useObjectBindings,
20
- useSceneConfig,
21
- useViewer,
22
- useViewerActions,
23
- useViewerAnimations,
24
- useViewerCamera,
25
- useViewerConnection,
26
- useViewerEffects,
27
- useViewerHover,
28
- useViewerModel,
29
- useViewerSelection,
30
- MATERIAL_BLENDING_MODES,
31
- MATERIAL_SIDES,
32
- } from "@liveroom-tech/react-immersive";
33
- import { SimpleModelViewer } from "@liveroom-tech/react-immersive/simple-model-viewer";
34
- import { BindingBuilder } from "@liveroom-tech/react-immersive/binding-builder";
35
- ```
36
-
37
- Each component has its own entry point, so an app downloads only the ones it
38
- imports.
39
-
40
- It also exports types for `ObjectBinding`, `ObjectBindingMaterial`, `ObjectBindingsController`, `ObjectActionEvent`, `ObjectTransformSpace`, `SceneConfig`, `SceneConfigPatch`, `SceneConfigController`, `AnimationControls`, `CinematicConfig` / `CinematicWaypoint`, and related shapes used throughout this document.
41
-
42
- `ModelViewer` provides:
43
-
44
- - GLB/GLTF, OBJ/MTL, FBX, and USDZ model rendering through `@react-three/fiber`
45
- - camera-driven 3D Tiles streaming through `tilesetUrl`, with configurable screen-space error and bounded tile cache
46
- - orbit/pan/zoom camera controls via `CameraControls`
47
- - auto-fits the model on load, and re-fits when the canvas is resized (window resize, device rotation, or a panel opening/closing), toggleable through `refitOnResize` to instead preserve the user's orbit/zoom
48
- - scene lighting through `sceneConfig.lighting`, with the `sceneLight` helper and a runtime lights controller
49
- - optional custom camera configuration through a `camera` prop
50
- - optional custom background color through a `backgroundColor` prop
51
- - optional shadow rendering toggle through a `shadows` prop (on by default)
52
- - optional on-screen movement controller through `showMouseController` and its tuning props
53
- - optional canvas-focused keyboard camera navigation through `enableKeyboardNavigation`
54
- - optional top-right camera orientation control through `showViewGizmo`
55
- - optional per-object move and rotate gizmo through `moveModeEnabled`, with World/Local axis alignment through `objectTransformSpace`
56
- - optional custom left object data panel through `customObjectBindingDataPanel`
57
- - optional custom right scene objects panel through `customSceneObjectsPanel`
58
- - your own UI over the 3D view through `overlay`, and react-three-fiber content inside the scene through `unsafe_sceneChildren`
59
- - optional hiding of either built-in panel through `showObjectBindingDataPanel` and `showSceneObjectsPanel`
60
- - optional model export button through `showDownloadButton` and `downloadFilename`, opt-in PNG capture through `preserveDrawingBuffer`, plus an independent `showResetButton` toggle for the rest of that action bar
61
- - an optional UV Checker toolbar button through `showUvCheckerButton`, for inspecting UV scale, stretching, seams, orientation, and missing UV0 coordinates directly in `ModelViewer`
62
- - glTF material variants (`KHR_materials_variants`) with a built-in picker through `showMaterialVariants`, selected by `sceneConfig.model.materialVariant`
63
- - distance, angle, polygon area, and point-to-plane measurements with vertex/edge snapping and bounding dimensions through `showMeasureTools` and `measurementUnit`
64
- - an exploded-view slider that slides each bound part outward from the model center to reveal interior/assembly structure through `showExplodeControls`
65
- - isolation that ghosts or hides everything but the objects you focus on, through `isolation` / `onIsolationChange` and `showIsolateControls`
66
- - a section cut that opens the model along an axis, with a draggable plane, through `showSectionTools` and `sceneConfig.section`
67
- - a cinematic auto-camera that glides the camera along authored waypoints (or a zero-config showcase orbit), like a film, through `cinematic`, with a play/pause control that yields the moment you touch the camera
68
- - video export of a cinematic pass or turntable revolution, through the download menu or `captureVideo`, using browser-supported WebM/MP4 encoding
69
- - a guided-tour control cluster (Previous/Stop/Next) for stepping through annotations, toggleable via `showAnnotationNavigation`
70
- - optional annotation detail popups on marker hover via `showAnnotationOnHover`
71
- - PBR, Matcap, and UV Checker renderer modes, with the checker exposing UV stretching, seams, rotation, and missing UV0 data directly on the model
72
- - a `sceneConfig` prop accepting the same scene-wide config (lighting, environment, background, post-processing, animations, annotations) authored by `BindingBuilder`'s Scene tab
73
- - WebGL context-loss recovery with a reload button and automatic rebuild when the context returns
74
- - render-loop and perf tuning through `renderMode`, `maxDpr`, `performanceProfile`, and compressed-asset decoder options (`dracoDecoderPath`, `ktx2TranscoderPath`, `meshopt`)
75
- - WebXR "View in your space" (AR) and "Enter VR" through `enableXR`, with tap-to-place, pinch-to-resize, and twist-to-rotate AR placement gestures
76
- - mesh selection by object name
77
- - a built-in left side panel for the selected object
78
- - object-specific action buttons driven by `objectBindings`
79
- - built-in color picking that commits the chosen hex into `objectBindings.style.material.baseColor`
80
- - built-in texture upload that commits a URL into `objectBindings.style.material.texture.path` (blob URL by default, or a durable URL when `onTextureUpload` is provided)
81
- - per-object `MeshPhysicalMaterial` overrides for metalness, roughness, emissive, normal/bump, AO, displacement, clearcoat, sheen, anisotropy, specular, transmission, thickness, reflectivity, sidedness, and limited blending modes
82
- - per-object visibility toggling through `objectBindings.visible`
83
- - decals: images and text printed on an object's surface through `objectBindings.decals`, placed from the surface point pointer events report
84
- - data-driven looks through `sceneConfig.styleRules`: colour scales from metrics, material overrides by status or metadata, and pulsing alarms
85
- - hover and selected-state highlighting
86
- - external selection state control through `selectedObject` and `onObjectSelect`
87
- - hover callbacks through `onObjectHover`
88
- - double-click, right-click, and touch long-press callbacks through `onObjectDoubleClick` and `onObjectContextMenu`
89
- - model-ready callbacks through `onModelLoaded`
90
- - model-load error callbacks through `onLoadError`
91
- - camera change callbacks through `onCameraChange`
92
- - viewer-ready callbacks through `onViewerReady`
93
- - action event callbacks through `onAction`
94
- - opt-in engagement analytics through `onEngagement`, with `debugEngagement` console logging
95
- - animation playback for GLB/GLTF, FBX, and USDZ models with supported embedded animations through `onAnimationsReady`
96
- - annotation marker callbacks through `onAnnotationsChange` and controlled/uncontrolled `activeAnnotation` / `onActiveAnnotationChange`
97
-
98
- `BindingBuilder` provides:
99
-
100
- - a design-time UI for generating starter bindings from GLB, GLTF, OBJ, FBX, and USDZ assets, gated by `licenseKey` (see "`BindingBuilder` licensing & plan tiers" below)
101
- - demo model loading or custom `.glb`, `.gltf`, `.obj`, `.fbx`, `.usdz`, or model ZIP bundle upload
102
- - editable binding fields for identity, basics, style, actions, metrics, metadata, and saved camera state
103
- - per-object move and rotate authoring with a geometry-centered pivot, World/Local axes, numeric fields, and restore-to-authored-transform support
104
- - a one-click material preset gallery (wood, metal, chrome, glass, plastic, fabric, ceramic, concrete, etc.)
105
- - undo/redo for both the Object tab's bindings and the Scene tab's config, independently, with `Cmd/Ctrl+Z` / `Cmd/Ctrl+Shift+Z` shortcuts
106
- - a Scene tab for the same `sceneConfig` shape `ModelViewer` accepts (lighting, environment, background, post-processing, animations, annotations, and cinematic camera paths)
107
- - a Cinematic sub-tab for authoring a camera path visually, frame the model, capture the current view as a waypoint, reorder/preview/delete waypoints, and toggle loop/auto-play; stored on `sceneConfig.cinematic` and replayed by `ModelViewer`'s `cinematic` prop
108
- - import a previously exported `objectBindings.json` or `sceneConfig.json` and merge it back onto the current model/config
109
- - live preview using `ModelViewer`
110
- - export as JSON or TypeScript, bundled into a `.zip` with a `materials/` folder automatically when any texture field was filled by file upload, otherwise a plain file
111
- - license-tier gating for some editor features (texture maps, environment lighting/backgrounds, wireframe preview, animation configuration, annotations, style rules, post-processing)
112
-
113
- `SimpleModelViewer` provides:
114
-
115
- - a lightweight GLB/GLTF/OBJ/FBX/USDZ viewer with no bindings or actions that does not require a `licenseKey`
116
- - optional local `.glb`, standalone/data-URI `.gltf`, `.obj`, `.fbx`, `.usdz`, or model ZIP bundle upload mode for ad-hoc inspection without relying on the `modelUrl` asset
117
- - built-in scene objects panel with search and visibility toggles
118
- - a built-in environment/scene settings panel (background color, environment preset, auto-rotate, exposure, ambient + directional light) toggleable via `showSceneSettingsPanel`, with each control's initial value seedable via props
119
- - click-to-select and fit-to-object focus behavior
120
- - optional background color and model lifecycle callbacks
121
- - a smaller API surface for simple inspection use cases
122
-
123
- ## Why `objectBindings` Exists
124
-
125
- `objectBindings` solves the gap between a raw GLB/GLTF file and an interactive
126
- product experience. A model file gives you geometry, materials, and mesh node
127
- names. It does not know that `"CarBody"` is configurable, that `"FrontDoor"`
128
- should open a panel, or that `"Wall_A"` should expose metadata and a saved
129
- camera view.
130
-
131
- `objectBindings` is the bridge between those raw mesh names and your app's
132
- domain model. It is a serializable record, keyed by mesh node name, that lets
133
- you:
134
-
135
- - declare which meshes are interactive
136
- - carry live render state such as visibility, local transforms, and per-object material overrides
137
- - attach actions like `change-color`, `change-material`, and `toggle-visibility`
138
- - store metadata and metrics alongside the 3D scene
139
- - save camera framing so object focus can use curated views
140
-
141
- Because it is plain data, bindings can be authored by hand, generated through
142
- `BindingBuilder`, stored in a database, versioned as JSON, and round-tripped
143
- through `onObjectBindingsChange` so your app state and the 3D scene stay in
144
- sync.
145
-
146
- ## Why It Is Worth The Setup
17
+ | Need | Component and import | CSS import | Runtime key prop |
18
+ | --- | --- | --- | --- |
19
+ | Display/inspect a model and toggle mesh visibility | `SimpleModelViewer` from `@liveroom-tech/react-immersive/simple-model-viewer` | `@liveroom-tech/react-immersive/simple-model-viewer.css` | None |
20
+ | Interactive object bindings, materials, actions, tours, camera and app state | `ModelViewer` from `@liveroom-tech/react-immersive` | `@liveroom-tech/react-immersive/styles.css` | Required |
21
+ | Author and export bindings/scene configuration | `BindingBuilder` from `@liveroom-tech/react-immersive/binding-builder` | `@liveroom-tech/react-immersive/binding-builder.css` | Required |
147
22
 
148
- At first glance, `objectBindings` can look like extra setup. That is true only
149
- if your goal is to render a model and do nothing else with it.
23
+ Import each component's stylesheet once. Give the viewer's container an explicit
24
+ height. The package does not require Tailwind in the consuming application.
150
25
 
151
- If the model needs to behave like part of your application, bindings stop being
152
- overhead and start being the abstraction that keeps the project maintainable.
153
- They give you a single source of truth instead of scattering logic across mesh
154
- refs, material mutations, raycasting handlers, and custom UI glue.
26
+ ## Install
155
27
 
156
- The short version:
157
-
158
- - without bindings, the model is a visual asset
159
- - with bindings, the model becomes application state
160
-
161
- If you only need a viewer, use `SimpleModelViewer`. If you need selection,
162
- customization, persistence, metadata, object-level actions, or app-driven
163
- behavior, bindings are usually the right tradeoff.
164
-
165
- ## Example Applications Where Bindings Shine
166
-
167
- - product configurators for cars, furniture, apparel, appliances, or custom goods
168
- - e-commerce customization flows where meshes map to real purchasable options
169
- - CPQ and sales tools where 3D parts correspond to business rules and pricing
170
- - real estate and interior design tools with clickable rooms, walls, fixtures, and finishes
171
- - industrial and engineering viewers for assemblies, equipment, and maintenance workflows
172
- - training and guided walkthroughs with annotations, steps, and saved object viewpoints
173
- - digital twins and operational dashboards where scene parts map to live assets, metrics, and alerts
174
- - smart building controls where lights, switches, sensors, HVAC units, and doors map to real-time app behavior
175
-
176
- The pattern is consistent: if users need to say "this exact part of the model
177
- has its own meaning, state, or behavior," object bindings are a strong fit.
178
-
179
- ## Installation
28
+ In a React 19 application:
180
29
 
181
30
  ```bash
182
- npm install @liveroom-tech/react-immersive three @react-three/fiber
183
- ```
184
-
185
- Import the stylesheet for each component you use, once, from your
186
- application root (for example, Next.js `app/layout.tsx`):
187
-
188
- ```tsx
189
- import "@liveroom-tech/react-immersive/styles.css"; // ModelViewer
190
- import "@liveroom-tech/react-immersive/simple-model-viewer.css"; // SimpleModelViewer
191
- import "@liveroom-tech/react-immersive/binding-builder.css"; // BindingBuilder
192
- ```
193
-
194
- The styles ship as a static CSS file rather than a runtime-injected `<style>`
195
- tag, so a strict CSP does not need `style-src 'unsafe-inline'`. Tailwind is not
196
- required in the consuming app.
197
-
198
- If a component's stylesheet is missing, it renders unstyled, and in
199
- development it logs a console warning naming the import to add.
200
-
201
- Peer dependencies, which your app provides so there's exactly one copy of each:
202
-
203
- - `react` and `react-dom` 19
204
- - `three` 0.184
205
- - `@react-three/fiber` 9
206
-
207
- Everything else, including drei, post-processing, and WebXR support, installs
208
- with the package.
209
-
210
- `ModelViewer` and `BindingBuilder` require a `licenseKey` at runtime (see [`licenseKey`](#licensekey)). Get one from the Developer Portal, see [Resources](#resources) below.
211
-
212
- ## Resources
213
-
214
- - [Developer Portal](https://react-immersive.liveroom.dev), sign in, pick a plan, and generate a `licenseKey`
215
- - [Docs](https://react-immersive.liveroom.dev/docs), full reference for every component, hook, and prop
216
- - [Examples & community repo](https://github.com/liveroom-technologies/react-immersive-docs/examples), public docs source, starter examples, and community resources
217
- - [Report a bug / request a feature](https://github.com/liveroom-technologies/react-immersive-docs/issues), for public bug reports, docs issues, and feature requests
218
- - [Discussions & Q&A](https://github.com/liveroom-technologies/react-immersive-docs/discussions), ask questions, share ideas, and compare approaches
219
- - [Private support / security](mailto:developers@liveroom.xyz?subject=React%20Immersive%20Support), for license, account, confidential customer, or security-sensitive issues
220
- - [Live editor](https://react-immersive.liveroom.dev/editor), try `BindingBuilder` in the browser without installing anything
221
- - [npm package](https://www.npmjs.com/package/@liveroom-tech/react-immersive)
222
-
223
- ## Quick Start
224
-
225
- The shortest working viewer lets `ModelViewer` generate the bindings itself:
226
-
227
- ```tsx
228
- import { ModelViewer } from "@liveroom-tech/react-immersive";
229
-
230
- export default function Example() {
231
- return (
232
- <div style={{ height: "100vh", overflow: "hidden" }}>
233
- <ModelViewer
234
- modelUrl="/model.glb"
235
- licenseKey="your-license-key"
236
- />
237
- </div>
238
- );
239
- }
31
+ npm install @liveroom-tech/react-immersive@5.2.0 three@^0.184.0 @react-three/fiber@^9.6.1
240
32
  ```
241
33
 
242
- Every mesh in the model can then be hovered and selected, and opens the side
243
- panel with Change Color, Change Material, and Toggle Visibility (or, for meshes
244
- whose names contain "light", Toggle Light, Change Light Color, and Set
245
- Brightness). See
246
- [Generating bindings automatically](#generating-bindings-automatically) for how
247
- to keep and refine the generated bindings.
248
-
249
- To control the viewer from your own UI, use `useViewer`. It connects every
250
- viewer hook to `ModelViewer` at once:
251
-
252
- ```tsx
253
- import { ModelViewer, useViewer } from "@liveroom-tech/react-immersive";
254
-
255
- export default function Configurator() {
256
- const viewer = useViewer();
34
+ | Peer | Supported range |
35
+ | --- | --- |
36
+ | `react` | `^19.0.0` |
37
+ | `react-dom` | `^19.0.0` |
38
+ | `three` | `^0.184.0` |
39
+ | `@react-three/fiber` | `^9.6.1` |
257
40
 
258
- return (
259
- <div style={{ height: "100vh", overflow: "hidden" }}>
260
- <ModelViewer
261
- modelUrl="/model.glb"
262
- licenseKey="your-license-key"
263
- {...viewer.props}
264
- />
265
- <button
266
- onClick={() => viewer.bindings.setBaseColor({ group: "paint" }, "#b91c1c")}
267
- >
268
- Paint it red
269
- </button>
270
- <button onClick={() => viewer.camera.resetView()}>Reset view</button>
271
- </div>
272
- );
273
- }
274
- ```
41
+ The complete [Vite](https://react-immersive.liveroom.dev/docs/frameworks/vite)
42
+ and [Next.js App Router](https://react-immersive.liveroom.dev/docs/frameworks/nextjs)
43
+ guides include file locations, client boundaries, sample assets, TypeScript
44
+ configuration and run/build instructions. Standalone starters live in the
45
+ [public examples repository](https://github.com/Liveroom-Technologies/react-immersive-docs/tree/main/examples).
275
46
 
276
- `viewer.bindings`, `viewer.selection`, `viewer.hover`, `viewer.camera`,
277
- `viewer.model`, `viewer.animations`, `viewer.actions`, `viewer.scene`,
278
- `viewer.isolation`, `viewer.effects`, and `viewer.connection` are the results of the hooks they're
279
- named after (`useObjectBindings`, `useViewerSelection`, and so on), so
280
- everything below applies to them. Without a `bindings` option, `useViewer`
281
- generates bindings from the model like `objectBindings="auto"`; pass
282
- `useViewer({ bindings })` to start from your own. It also accepts
283
- `sceneConfig`, `camera` (the `useViewerCamera` options), and `onAction`,
284
- `onObjectSelect`, `onObjectHover`, and `onLoadError` callbacks. `sceneConfig`
285
- is passed to `ModelViewer` only once you've supplied one or changed the scene
286
- through `viewer.scene`, so the default scene behaves as if none were passed.
287
- Props set on `ModelViewer` after the spread take precedence.
47
+ ## First render
288
48
 
289
- The full example below authors bindings by hand and wires up every hook
290
- individually, which is what `useViewer` does for you. Wire them yourself when
291
- state lives elsewhere, such as bindings owned by a store:
49
+ Place your asset at `public/model.glb`. In a Vite React application:
292
50
 
293
51
  ```tsx
294
- import {
295
- ModelViewer,
296
- useObjectBinding,
297
- useObjectBindings,
298
- useViewerActions,
299
- useViewerAnimations,
300
- useViewerCamera,
301
- useViewerHover,
302
- useViewerModel,
303
- useViewerSelection,
304
- } from "@liveroom-tech/react-immersive";
305
- import { defineObjectBindings } from "@liveroom-tech/react-immersive/utils";
306
-
307
- const initialBindings = defineObjectBindings({
308
- CarBody: {
309
- id: "car-body",
310
- modelObjectId: "CarBody",
311
- type: "body",
312
- label: "Car Body",
313
- selectable: true,
314
- hoverable: true,
315
- visible: true,
316
- style: {
317
- material: {
318
- texture: {
319
- path: "/materials/oak-wood.jpg",
320
- },
321
- },
322
- },
323
- metrics: {},
324
- metadata: {
325
- category: "exterior",
326
- },
327
- actions: [
328
- { id: "change-color", label: "Change Color", type: "command" },
329
- { id: "change-material", label: "Change Material", type: "command" },
330
- { id: "toggle-visibility", label: "Toggle Visibility", type: "command" },
331
- {
332
- id: "toggle-body",
333
- label: "Toggle Body",
334
- type: "command",
335
- effects: [{ target: "CarBody", visibility: "toggle" }],
336
- },
337
- ],
338
- },
339
- });
340
-
341
- export default function Example() {
342
- const bindings = useObjectBindings(initialBindings);
343
- const {
344
- objectBindings,
345
- setObjectBindings,
346
- hiddenObjects,
347
- toggleObjectVisibility,
348
- } = bindings;
349
- const { selectedObjectBinding, handleObjectSelect } = useViewerSelection();
350
- const { hoveredObjectBinding, handleHoveredObject } = useViewerHover();
351
- const camera = useViewerCamera();
352
- const {
353
- cameraState,
354
- resetView,
355
- focusObject,
356
- fitScene,
357
- setCameraTarget,
358
- handleCameraChange,
359
- handleViewerReady,
360
- } = camera;
361
- const {
362
- isLoading,
363
- isReady,
364
- error,
365
- bounds,
366
- objectCount,
367
- handleModelLoaded,
368
- handleLoadError,
369
- } = useViewerModel();
370
- const animations = useViewerAnimations();
371
- const { getActionsForObject, handleAction, runAction } = useViewerActions({
372
- bindings,
373
- camera,
374
- animations,
375
- onAction: (event) => {},
376
- });
377
- const focusedBinding = useObjectBinding(objectBindings, "car-body");
52
+ import "@liveroom-tech/react-immersive/simple-model-viewer.css";
53
+ import { SimpleModelViewer } from "@liveroom-tech/react-immersive/simple-model-viewer";
378
54
 
55
+ export default function App() {
379
56
  return (
380
- <div style={{ height: "100vh", overflow: "hidden" }}>
381
- <ModelViewer
57
+ <div style={{ height: "100vh" }}>
58
+ <SimpleModelViewer
382
59
  modelUrl="/model.glb"
383
- licenseKey="your-license-key"
384
- objectBindings={objectBindings}
385
- selectedObject={selectedObjectBinding}
386
- onObjectSelect={handleObjectSelect}
387
- onObjectHover={handleHoveredObject}
388
- onCameraChange={handleCameraChange}
389
- onModelLoaded={handleModelLoaded}
390
- onLoadError={handleLoadError}
391
- onObjectBindingsChange={setObjectBindings}
392
- onViewerReady={handleViewerReady}
393
- onAnimationsReady={animations.handleAnimationsReady}
394
- onAction={handleAction}
60
+ onModelLoaded={(model) => console.log("Loaded", model.objectCount, "objects")}
61
+ onLoadError={(error) => console.error("Model failed to load", error)}
395
62
  />
396
-
397
- <button onClick={() => toggleObjectVisibility("car-body")}>
398
- Toggle Visibility
399
- </button>
400
- <button onClick={() => runAction("car-body", "toggle-body")}>
401
- Run declarative action
402
- </button>
403
- <button onClick={() => resetView()}>Reset view</button>
404
- <button onClick={() => focusObject("car-body")}>Focus Object</button>
405
- <button onClick={() => fitScene()}>Fit scene</button>
406
- <button onClick={() => setCameraTarget([0, 0, 0])}>Target origin</button>
407
- <pre>{JSON.stringify(getActionsForObject("car-body"), null, 2)}</pre>
408
- <pre>{JSON.stringify(cameraState, null, 2)}</pre>
409
- <pre>
410
- {JSON.stringify(
411
- { isLoading, isReady, error, bounds, objectCount },
412
- null,
413
- 2,
414
- )}
415
- </pre>
416
- <pre>{JSON.stringify(hiddenObjects, null, 2)}</pre>
417
- <pre>{JSON.stringify(hoveredObjectBinding, null, 2)}</pre>
418
- <pre>{JSON.stringify(focusedBinding, null, 2)}</pre>
419
63
  </div>
420
64
  );
421
65
  }
422
66
  ```
423
67
 
424
- If you want a simple helper for selection state, the library also exports:
425
-
426
- ```tsx
427
- const {
428
- selectedObjectBinding,
429
- setSelectedObjectBinding,
430
- handleObjectSelect,
431
- clearSelection,
432
- } = useViewerSelection();
433
- ```
434
-
435
- If you want to resolve a binding from an object identifier, the library also exports:
436
-
437
- ```tsx
438
- const binding = useObjectBinding(objectBindings, "car-body");
439
- ```
440
-
441
- `useObjectBinding` checks, in order:
442
-
443
- - the object binding map key
444
- - `binding.id`
445
- - `binding.modelObjectId`
446
-
447
- If you want a flat list of every `modelObjectId` across your bindings, the library also exports:
448
-
449
- ```tsx
450
- const ids = useObjectBindingIds(objectBindings);
451
- // → ["CarBody", "WheelFL", "WheelFR", ...]
452
- ```
453
-
454
- If you want one state owner for binding patches, materials, and visibility, use `useObjectBindings`:
455
-
456
- ```tsx
457
- const {
458
- objectBindings,
459
- setObjectBindings,
460
- updateObjectBindings,
461
- selectObjectBindings,
462
- selectObjectBindingIds,
463
- setMaterial,
464
- setBaseColor,
465
- setTexture,
466
- clearTexture,
467
- copyMaterial,
468
- resetMaterial,
469
- getMaterial,
470
- setTransform,
471
- resetTransform,
472
- updateMetadata,
473
- addDecal,
474
- updateDecal,
475
- removeDecal,
476
- hiddenObjects,
477
- hiddenObjectIds,
478
- hideObject,
479
- showObject,
480
- toggleObjectVisibility,
481
- isObjectHidden,
482
- clearHiddenObjects,
483
- } = useObjectBindings(initialBindings);
484
-
485
- <ModelViewer
486
- modelUrl="/model.glb"
487
- licenseKey="your-license-key"
488
- objectBindings={objectBindings}
489
- onObjectBindingsChange={setObjectBindings}
490
- />;
491
- ```
492
-
493
- `useObjectBindings` owns the state used by the viewer. Every setter uses a functional update, so consecutive material, visibility, and general binding updates in the same tick compose instead of overwriting each other.
494
-
495
- Object identifiers accepted by its methods can be:
496
-
497
- - the object binding map key
498
- - `binding.id`
499
- - `binding.modelObjectId`
500
-
501
- You can also target bindings by a shared `group`, `tag`, or object `type`. Groups
502
- represent one named set, while tags let a binding participate in several sets:
503
-
504
- ```tsx
505
- updateObjectBindings({ group: "paint" }, { selectable: false });
506
- setBaseColor({ tag: "exterior" }, "#2563eb");
507
- hideObject({ type: "wheel" });
508
-
509
- const exteriorBindings = selectObjectBindings({ tag: "exterior" });
510
- const paintIds = selectObjectBindingIds({ group: "paint" });
511
-
512
- setTexture({ group: "screens" }, "/images/dashboard.png");
513
- clearTexture({ tag: "printable" }, "baseColor");
514
- copyMaterial("wheel-front", { group: "wheels" });
515
-
516
- setTransform("door-left", {
517
- rotation: [0, Math.PI / 2, 0],
518
- });
519
- resetTransform("door-left");
520
- updateMetadata({ group: "lights" }, { state: "on" });
521
- ```
522
-
523
- When a parent or store owns the state, use the pure `selectBindings` and
524
- `selectBindingKeys` helpers for the same queries, and `patchBindings` to update
525
- all matches. Import these helpers from
526
- `@liveroom-tech/react-immersive/utils` when the module must remain usable from a
527
- React Server Component; the main entry continues to re-export them for
528
- backwards compatibility.
529
-
530
- The hook returns:
531
-
532
- - `objectBindings` and `setObjectBindings`
533
- - `updateObjectBindings` for any binding field or atomic edit batch
534
- - `selectObjectBindings` and `selectObjectBindingIds` for group, tag, or type queries
535
- - `setMaterial`, `setBaseColor`, `setTexture`, `clearTexture`, `copyMaterial`, `resetMaterial`, and `getMaterial`
536
- - `setTransform` and `resetTransform` for persistent local-space model transforms
537
- - `updateMetadata` for recursively merged application data
538
- - `addDecal`, `updateDecal`, and `removeDecal` for images and text printed on objects (see [Decals](#decals))
539
- - `hiddenObjects`: a derived map of hidden binding keys
540
- - `hiddenObjectIds`: the currently hidden binding IDs
541
- - `hideObject`, `showObject`, `toggleObjectVisibility`
542
- - `isObjectHidden`
543
- - `clearHiddenObjects`
544
-
545
- For scene-wide state, use `useSceneConfig`:
546
-
547
- ```tsx
548
- const {
549
- sceneConfig,
550
- setSceneConfig,
551
- updateSceneConfig,
552
- resetSceneConfig,
553
- lights,
554
- } = useSceneConfig(initialSceneConfig);
555
-
556
- const enableUvChecker = () =>
557
- updateSceneConfig({
558
- model: { renderer: "uv-checker" },
559
- lighting: { ambient: { intensity: 0.5 } },
560
- });
561
-
562
- lights.setIntensity("bulb-light", 4);
563
- lights.setColor("bulb-light", "#ffd27d");
564
- lights.toggle("bulb-light");
565
- lights.attach("bulb-light", {
566
- objectId: "bulb-filament",
567
- offset: [0, -0.2, 0],
568
- });
569
-
570
- <ModelViewer
571
- modelUrl="/model.glb"
572
- licenseKey="your-license-key"
573
- objectBindings={objectBindings}
574
- sceneConfig={sceneConfig}
575
- />;
576
-
577
- <button onClick={enableUvChecker}>Show UV checker</button>;
578
- ```
579
-
580
- Nested objects merge recursively, while arrays and tuples are replaced. Every
581
- update uses a functional state updater, so consecutive calls compose. Use the
582
- pure `patchSceneConfig(sceneConfig, patch)` utility when a store or parent owns
583
- the scene state. The namespaced `lights` controller also provides `add`,
584
- `update`, `remove`, `show`, `hide`, `toggle`, `setIntensity`, `setColor`,
585
- `attach`, and `detach`. Attached lights follow a bound model object without an
586
- R3F light component.
587
-
588
- For high-frequency visual effects, use `useViewerEffects`. It mutates the live
589
- viewer efficiently, requests demand-rendered frames automatically, and restores
590
- its runtime changes on cleanup. Application code does not need Three.js node or
591
- material access:
592
-
593
- ```tsx
594
- const {
595
- addPointLight,
596
- flicker,
597
- handleViewerReady,
598
- overrideEffect,
599
- stopEffect,
600
- } = useViewerEffects();
601
-
602
- useEffect(() => {
603
- flicker(
604
- {
605
- materials: [
606
- {
607
- targets: { group: "filaments" },
608
- values: { emissiveIntensity: [0.02, 8] },
609
- },
610
- ],
611
- lights: [
612
- {
613
- lights: ["light-left", "light-right"],
614
- intensity: [0, 180],
615
- },
616
- ],
617
- },
618
- { id: "bulbs", synchronized: true, blackoutChance: 0.1 },
619
- );
620
-
621
- return () => stopEffect("bulbs");
622
- }, [flicker, stopEffect]);
623
-
624
- <ModelViewer
625
- modelUrl="/bulbs.glb"
626
- licenseKey="your-license-key"
627
- objectBindings={objectBindings}
628
- onViewerReady={(viewer) => {
629
- handleViewerReady(viewer);
630
- addPointLight({
631
- id: "light-left",
632
- target: "filament-left",
633
- color: "#ff9a3c",
634
- intensity: 0,
635
- distance: 30,
636
- });
637
- }}
638
- />;
639
-
640
- <button onClick={() => overrideEffect("bulbs", 0, 800)}>Blackout</button>;
641
- ```
642
-
643
- `transition`, `timeline`, `pulse`, and `flicker` share material, transform, and
644
- light channels. `setMaterial`, `setTransform`, and `getWorldPosition` cover
645
- immediate runtime work. `addPointLight`, `updatePointLight`, and
646
- `removePointLight` manage lights attached to model objects. `resetRuntime` stops
647
- active effects, restores snapshotted values, and disposes runtime lights.
648
-
649
- If you want to keep hover state in sync with the viewer, the library also exports:
650
-
651
- ```tsx
652
- const { hoveredObjectBinding, handleHoveredObject } = useViewerHover();
653
-
654
- <ModelViewer
655
- modelUrl="/model.glb"
656
- licenseKey="your-license-key"
657
- objectBindings={objectBindings}
658
- onObjectHover={handleHoveredObject}
659
- />;
660
- ```
661
-
662
- `useViewerHover` returns:
663
-
664
- - `hoveredObjectBinding`: the currently hovered binding or `null`
665
- - `handleHoveredObject`: a callback you can pass directly to `onObjectHover`
666
-
667
- If you want model lifecycle and scene metadata, the library also exports:
668
-
669
- ```tsx
670
- const {
671
- isLoading,
672
- isReady,
673
- error,
674
- bounds,
675
- objectCount,
676
- materialVariants,
677
- objects,
678
- handleModelLoaded,
679
- handleObjectCatalog,
680
- handleLoadError,
681
- } = useViewerModel();
682
-
683
- <ModelViewer
684
- modelUrl="/model.glb"
685
- licenseKey="your-license-key"
686
- objectBindings={objectBindings}
687
- onModelLoaded={handleModelLoaded}
688
- onObjectCatalog={handleObjectCatalog}
689
- onLoadError={handleLoadError}
690
- />;
691
- ```
692
-
693
- `useViewerModel` returns:
694
-
695
- - `isLoading`: `true` until the model has loaded or failed
696
- - `isReady`: `true` after a successful model load
697
- - `error`: the most recent load/render error, or `null`
698
- - `bounds`: the loaded scene bounds as `min`, `max`, `center`, and `size`
699
- - `objectCount`: the number of mesh objects in the loaded scene
700
- - `materialVariants`: the names of the model's glTF material variants, or an
701
- empty array (see [`showMaterialVariants`](#showmaterialvariants))
702
- - `objects`: every bindable object in the model as a `ViewerObjectInfo`, once
703
- `handleObjectCatalog` is passed to `onObjectCatalog`
704
- - `handleModelLoaded`: a callback you can pass directly to `onModelLoaded`
705
- - `handleObjectCatalog`: a callback you can pass directly to `onObjectCatalog`
706
- - `handleLoadError`: a callback you can pass directly to `onLoadError`
707
-
708
- If you want to inspect or trigger binding actions programmatically, the library also exports:
709
-
710
- ```tsx
711
- const { getActionsForObject, handleAction, runAction } = useViewerActions({
712
- bindings,
713
- scene,
714
- camera,
715
- animations,
716
- onAction: (event) => {},
717
- });
718
-
719
- const actions = getActionsForObject("car-body");
720
- await runAction("car-body", "power-on");
721
-
722
- <ModelViewer onAction={handleAction} />;
723
- ```
724
-
725
- `useViewerActions` returns:
726
-
727
- - `getActionsForObject`: resolves the actions configured for a binding by key, `binding.id`, or `binding.modelObjectId`
728
- - `handleAction`: executes an action event and can be passed directly to `ModelViewer.onAction`
729
- - `runAction`: finds and executes an action, then resolves to its event, or `null` if the binding or action cannot be found
730
-
731
- Actions can declare ordered `effects` for object-binding patches, scene patches, visibility, camera controls, and animation controls. Pass the corresponding hook controllers into `useViewerActions`; omitted optional controllers cause only their effect category to be skipped.
68
+ For Next.js, import CSS in `app/layout.tsx` and use the complete client component
69
+ from the [Next.js guide](https://react-immersive.liveroom.dev/docs/frameworks/nextjs).
70
+ The public [Red Room sample](https://react-immersive.liveroom.dev/red_room.glb)
71
+ is by [LaisLH](https://skfb.ly/6VBJR), licensed under
72
+ [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/); retain attribution.
732
73
 
733
- `runAction` executes declarative effects only. It does not invoke viewer-owned behavior such as opening a picker or running the built-in visibility toggle. For programmatic visibility, call the bindings controller directly or declare a custom action with a visibility effect.
74
+ ## Add interaction
734
75
 
735
- ## `BindingBuilder`
736
-
737
- `BindingBuilder` is an exported design-time helper component for authoring `objectBindings` in the browser.
738
-
739
- Basic usage:
76
+ `ModelViewer` generates bindings automatically when `objectBindings` is omitted.
77
+ Use `useViewer` to connect bindings, selection, camera, animations and other
78
+ controllers to one viewer:
740
79
 
741
80
  ```tsx
742
- import "@liveroom-tech/react-immersive/binding-builder.css";
743
- import { BindingBuilder } from "@liveroom-tech/react-immersive/binding-builder";
744
-
745
- export default function App() {
746
- return <BindingBuilder licenseKey="your-license-key" />;
747
- }
748
- ```
749
-
750
- `BindingBuilder` accepts one required prop and the same optional decoder
751
- configuration as the viewers:
752
-
753
- ```ts
754
- type BindingBuilderProps = {
755
- licenseKey: string;
756
- dracoDecoderPath?: string | false;
757
- ktx2TranscoderPath?: string | false;
758
- meshopt?: boolean;
759
- };
760
- ```
761
-
762
- `licenseKey` is validated the same way as `ModelViewer`'s (see [`licenseKey`](#licensekey) below). While the key is being checked, `BindingBuilder` renders a "Verifying license…" placeholder; if it's invalid, it renders an error message instead of the editor.
763
-
764
- Current behavior, Object tab:
765
-
766
- - upload a `.glb`, standalone/data-URI `.gltf`, `.obj`, `.fbx`, or `.usdz` file, or a `.zip` bundle (a `.gltf` with its `.bin` and textures, an `.obj` with its MTL and textures, or an `.fbx` with external textures)
767
- - traverse renderable mesh nodes and generate starter bindings automatically
768
- - edit binding identity, label, type, status, booleans, style, actions, metrics, metadata, and saved camera state
769
- - add decals to the selected object from the **Decals** panel: upload an image or add text to place it automatically at the centre of the camera-facing surface, then set its size, rotation, and opacity; **Move** lets you drag the decal across the object's surface. Release to save, or press Escape to cancel. Uploaded images are exported under `materials/` with the bindings
770
- - move and rotate the selected object from the **Move & Rotate** panel using a geometry-centered pivot, World/Local axis alignment, or numeric position and degree fields; restore its authored transform with one click
771
- - apply a one-click material preset (wood, metal, chrome, glass, plastic, fabric, ceramic, concrete, etc.) onto the selected object's material
772
- - undo/redo the current bindings (toolbar buttons or `Cmd/Ctrl+Z` / `Cmd/Ctrl+Shift+Z`); rapid edits coalesce into a single undo step
773
- - import a previously exported `objectBindings.json`, merged onto the current model by `modelObjectId`
774
- - export the current bindings as JSON or TypeScript, with TypeScript exports wrapped in `defineObjectBindings` to preserve literal IDs, bundled into a `.zip` (with a `materials/` folder) when any texture field was filled by uploading a file, otherwise a plain file
775
-
776
- Current behavior, Scene tab:
777
-
778
- - configure the same `SceneConfig` shape `ModelViewer`'s `sceneConfig` prop accepts (lighting, environment, background, ground shadows, wireframe, post-processing, animations, annotations)
779
- - configure auto-rotation and its speed, exported as `sceneConfig.model.autoRotate` and `sceneConfig.model.autoRotateSpeed`
780
- - preview animation clips, several at once and forwards or backwards, and set each clip's loop mode (loop, play once, or ping-pong), speed, and display name
781
- - pick which of the model's glTF material variants the scene starts with, exported as `sceneConfig.model.materialVariant`
782
- - isolate a node from the Scene Nodes list to see it on its own in the preview while you edit it (not exported)
783
- - set up a section cut (**General → Section Cut**: axis, position, and side to keep), exported as `sceneConfig.section`; the preview has the section toolbar and draggable plane too
784
- - build style rules (**Rules** sub-tab) that restyle objects from their metrics, status, and metadata, with suggestions from the model's bindings, a live match count, and a live preview; exported as `sceneConfig.styleRules`
785
- - position and rotate directional, point, and spot lights with transform gizmos; spot lights also expose angle and penumbra controls
786
- - undo/redo the scene config independently of the Object tab's bindings history
787
- - import a previously exported `sceneConfig.json`, merged by top-level section
788
- - export the current scene config as JSON or TypeScript
789
-
790
- Preview:
791
-
792
- - the selected node previews live in an embedded `ModelViewer`
793
-
794
- Autosave:
795
-
796
- - the session (the model, its object bindings, and the scene settings, with an uploaded model file included) is saved to this browser's IndexedDB, in a database named `react-immersive:binding-builder`, shortly after each edit and when the tab is hidden or closed
797
- - **Restore last session** in the preview toolbar reopens it; one session is kept per browser
798
- - while there are edits on screen, leaving or reloading the page asks for confirmation
799
- - if the browser refuses to store a session, usually for lack of space, the editor says so; export your work to keep it
800
- - enable **Transform gizmo**, select a mesh, then use the arrows and plane handles to move it or the rings to rotate it; all changes are saved to `binding.transform`
801
-
802
- ### `BindingBuilder` licensing & plan tiers
803
-
804
- Some editor features are gated by the license's plan tier (the server-returned `tier`, normalized to `"free" | "starter" | "growth"`):
81
+ "use client";
805
82
 
806
- | Tier | Unlocks |
807
- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
808
- | `free` | All 3 components are available. `SimpleModelViewer` is fully available, while `ModelViewer` and `BindingBuilder` are limited to local development with base color, metalness/roughness sliders, and basic scene settings only |
809
- | `starter` | + Texture maps, the specular workflow, reflectivity, environment lighting, environment backgrounds, wireframe preview, animation configuration, annotations, style rules, decals |
810
- | `growth` | + Post-processing effects |
811
-
812
- A locked feature renders in place (not hidden) with a message naming the required plan, so it stays discoverable while editing.
813
-
814
- ## `SimpleModelViewer`
815
-
816
- `SimpleModelViewer` is an exported lightweight viewer for cases where you want to load a GLB, GLTF, OBJ, FBX, or USDZ asset, inspect meshes, and toggle visibility without building `objectBindings`. It can either load a fixed `modelUrl` or, when `enableModelUpload` is turned on, let the user drag-and-drop or choose a local model at runtime.
817
-
818
- Basic usage:
83
+ import { ModelViewer, useViewer } from "@liveroom-tech/react-immersive";
84
+ import "@liveroom-tech/react-immersive/styles.css";
819
85
 
820
- ```tsx
821
- import "@liveroom-tech/react-immersive/simple-model-viewer.css";
822
- import { SimpleModelViewer } from "@liveroom-tech/react-immersive/simple-model-viewer";
86
+ export function InteractiveViewer({ licenseKey }: { licenseKey: string }) {
87
+ const viewer = useViewer();
823
88
 
824
- export default function App() {
825
89
  return (
826
90
  <div style={{ height: "100vh" }}>
827
- <SimpleModelViewer modelUrl="/model.glb" />
91
+ <ModelViewer modelUrl="/model.glb" licenseKey={licenseKey} {...viewer.props} />
828
92
  </div>
829
93
  );
830
94
  }
831
95
  ```
832
96
 
833
- `SimpleModelViewer` does not take a `licenseKey`, licensing is enforced by `ModelViewer` and `BindingBuilder` only.
834
-
835
- Sizing note:
836
-
837
- - `SimpleModelViewer` fills the width and height of its parent container
838
- - give the parent an explicit height (for example `100vh`, `480px`, or a Tailwind class like `h-[100px]`) when you want a fixed viewer height
839
-
840
- Current behavior:
841
-
842
- - discovers renderable meshes directly from the loaded model scene
843
- - renders a right-side scene objects panel with search and visibility toggles
844
- - renders a left-side environment/scene settings panel (background color, environment preset, auto-rotate, exposure, ambient + directional light) toggleable via `showSceneSettingsPanel`, with every control seedable via props
845
- - optionally replaces `modelUrl` with a drag-and-drop / file-picker flow when `enableModelUpload` is enabled
846
- - lets users click a mesh or panel row to select and focus it
847
- - fits the full scene on initial load
848
- - uses built-in ambient, directional, and environment lighting
849
-
850
- Use `SimpleModelViewer` when you want a quick inspection viewer.
851
- Use `ModelViewer` when you need binding-driven styling, actions, metadata, custom panels, exports, or animation integrations.
852
-
853
- If you want camera state and imperative camera helpers, the library also exports:
854
-
855
- ```tsx
856
- const camera = useViewerCamera({
857
- initialPosition: [0, 2, 8],
858
- initialTarget: [0, 1.2, 0],
859
- });
860
-
861
- const {
862
- cameraState,
863
- resetView,
864
- focusObject,
865
- fitScene,
866
- setCameraTarget,
867
- lookAt,
868
- orbitTo,
869
- dollyTo,
870
- savePreset,
871
- goToPreset,
872
- handleCameraChange,
873
- handleViewerReady,
874
- } = camera;
875
-
876
- <ModelViewer
877
- modelUrl="/model.glb"
878
- licenseKey="your-license-key"
879
- objectBindings={objectBindings}
880
- onCameraChange={handleCameraChange}
881
- onViewerReady={handleViewerReady}
882
- />;
883
- ```
884
-
885
- `useViewerCamera` returns:
886
-
887
- - `cameraState`: the latest camera `position`, `target`, `fov`, and `zoom`
888
- - `resetView`: resets the controls to their initial saved state
889
- - `focusObject`: fits the camera to a binding by key, `binding.id`, or `binding.modelObjectId`
890
- - `fitScene`: fits the camera to the whole loaded scene
891
- - `setCameraTarget`: sets the camera target to a given `[x, y, z]`
892
- - `setCameraState`: restores a full camera state (`position`/`target`/`fov`/`zoom`) previously read from `cameraState`
893
- - `lookAt`: moves the position and target together
894
- - `orbitTo`: orbits to azimuth and polar angles in degrees (azimuth 0 is the front, 90 the right; polar 0 is straight down, 90 level)
895
- - `dollyTo`: moves to a distance from the current target
896
- - `savePreset`: captures the current camera under a name
897
- - `goToPreset`: moves to a named camera preset
898
- - `handleCameraChange`: a callback you can pass directly to `onCameraChange`
899
- - `handleViewerReady`: a callback you can pass directly to `onViewerReady`
900
-
901
- Pass `initialPosition`, `initialTarget`, and optional named `presets` to `useViewerCamera` to configure the first view without writing an `onViewerReady` wrapper.
902
-
903
- If your GLB/GLTF model contains animations, the library also exports:
904
-
905
- ```tsx
906
- const {
907
- clips,
908
- currentClip,
909
- isPlaying,
910
- speed,
911
- play,
912
- pause,
913
- stop,
914
- setSpeed,
915
- handleAnimationsReady,
916
- } = useViewerAnimations();
917
-
918
- <ModelViewer
919
- modelUrl="/character.glb"
920
- licenseKey="your-license-key"
921
- objectBindings={objectBindings}
922
- onAnimationsReady={handleAnimationsReady}
923
- />;
924
- ```
925
-
926
- `useViewerAnimations` returns:
927
-
928
- - `clips`: an array of animation clip names found in the GLB/GLTF file
929
- - `clipDetails`: clip metadata including `sourceName` and `duration` in seconds
930
- - `currentClip`: the clip played most recently, while it's active, or `null`
931
- - `isPlaying`: `true` while any clip is playing (not paused, finished, or stopped)
932
- - `speed`: the playback speed of `currentClip` (default `1`)
933
- - `time`: the live playback position of `currentClip`, in seconds (updates while playing)
934
- - `duration`: the length of `currentClip`, in seconds
935
- - `active`: every active clip (playing, paused, or finished) with its `status`, `time`, `duration`, `speed`, and `reverse`, most recently played last
936
- - `play(clip, options?)`: starts a clip by name, replacing the clips already playing unless `options.alongside` is set; `options.fade` blends over that many seconds, and `options.reverse` plays it backwards. A paused clip resumes instead of restarting
937
- - `pause(clip?)`: pauses one clip, or every active clip, at its current time
938
- - `stop(clip?)`: stops one clip, or every active clip, and resets the pose
939
- - `setSpeed(speed, clip?)`: changes the playback speed (e.g. `0.5` for half speed, `2` for double) of one clip, or of every active clip and those played later without their own speed
940
- - `seek(time, clip?)`: scrubs one clip, or every active clip, to an absolute time in seconds (works while playing or paused), clamped to the clip length
941
- - `handleAnimationsReady`: a callback you can pass directly to `onAnimationsReady`
942
-
943
- Example with playback controls:
944
-
945
- ```tsx
946
- const { clips, currentClip, isPlaying, play, pause, stop, setSpeed } =
947
- useViewerAnimations();
948
-
949
- // Play/pause toggle
950
- <button onClick={() => (isPlaying ? pause() : play(currentClip ?? clips[0]))}>
951
- {isPlaying ? "Pause" : "Play"}
952
- </button>
953
-
954
- // Stop
955
- <button onClick={() => stop()}>Stop</button>
956
-
957
- // Speed slider
958
- <input
959
- type="range"
960
- min="0.1"
961
- max="3"
962
- step="0.1"
963
- defaultValue="1"
964
- onChange={(e) => setSpeed(Number(e.target.value))}
965
- />
966
-
967
- // Clip selector
968
- {clips.map((name) => (
969
- <button key={name} onClick={() => play(name)}>
970
- {name} {currentClip === name && isPlaying ? "▶" : ""}
971
- </button>
972
- ))}
973
- ```
974
-
975
- Several clips can play at once. `play` replaces the clips already playing
976
- unless you pass `alongside: true`, and the other controls act on one clip when
977
- you name it, or on every active clip when you don't:
978
-
979
- ```tsx
980
- const animations = useViewerAnimations();
981
-
982
- // Open both doors together, then close the left one.
983
- animations.play("DoorLeftOpen", { alongside: true });
984
- animations.play("DoorRightOpen", { alongside: true });
985
- animations.play("DoorLeftOpen", { alongside: true, reverse: true });
986
-
987
- // Blend from walking to running over half a second.
988
- animations.play("Run", { fade: 0.5 });
989
-
990
- animations.pause("Wheels"); // one clip
991
- animations.stop(); // every clip
992
-
993
- // What's active, and how far along each clip is
994
- animations.active.map(({ clip, status, time }) => `${clip}: ${status} at ${time}s`);
995
- ```
996
-
997
- A clip whose `loopMode` is `"once"` holds its last pose when it finishes
998
- (`status: "finished"`) until it's stopped or played again, so an opened door
999
- stays open. `"ping-pong"` plays forwards then backwards, repeatedly. Playing a
1000
- clip that's already playing in the same direction leaves it running; playing
1001
- it the other way turns it around where it is.
1002
-
1003
- ## Presets and grouped props
1004
-
1005
- `preset` sets `ModelViewer` up for a common kind of page:
1006
-
1007
- | Preset | For | What it sets |
1008
- | --- | --- | --- |
1009
- | `minimal` | Just the model | Hides both panels, the download and reset buttons, tour controls, and the material variant buttons |
1010
- | `showcase` | A product on display | Everything `minimal` does, plus auto-rotation |
1011
- | `configurator` | Customers changing parts | Shows the selected object's panel, the reset button, and the material variant buttons; hides the scene objects panel and download |
1012
- | `inspector` | Checking a model | Every panel, the view gizmo, the measure, UV checker, exploded-view, section-cut, and isolate tools, and keyboard navigation |
1013
-
1014
- `MODEL_VIEWER_PRESETS` lists exactly which props each preset sets.
1015
-
1016
- Related props are also available as groups, which keeps a configured viewer
1017
- readable:
1018
-
1019
- ```tsx
1020
- <ModelViewer
1021
- modelUrl="/car.glb"
1022
- licenseKey="your-license-key"
1023
- preset="configurator"
1024
- ui={{ download: "car.glb" }}
1025
- tools={{ measure: { unit: "cm" } }}
1026
- controls={{ autoRotate: 0.5, zoom: false, limits: { maxDistance: 20 } }}
1027
- perf={{ profile: "low" }}
1028
- xr={{ enabled: true, usdzUrl: "/car.usdz" }}
1029
- />
1030
- ```
1031
-
1032
- | Group | Fields, and the flat prop each one sets |
1033
- | --- | --- |
1034
- | `ui` | `objectPanel` (`showObjectBindingDataPanel`), `sceneObjects` (`showSceneObjectsPanel`), `download` (`showDownloadButton`; a string also sets `downloadFilename`), `reset` (`showResetButton`), `fullscreen` (`showFullscreenButton`), `loadingOverlay` (`showLoadingOverlay`), `viewGizmo` (`showViewGizmo`), `mouseController` (`showMouseController`; `{ position, opacity }` also sets `mouseControllerPosition` and `mouseControllerOpacity`), `annotationNavigation` (`showAnnotationNavigation`), `annotationOnHover` (`showAnnotationOnHover`), `highlightOnHover`, `materialVariants` (`showMaterialVariants`) |
1035
- | `tools` | `measure` (`showMeasureTools`; `{ unit }` also sets `measurementUnit`), `uvChecker` (`showUvCheckerButton`), `explode` (`showExplodeControls`), `section` (`showSectionTools`), `isolate` (`showIsolateControls`), `texturePositioning` (`texturePositioning`) |
1036
- | `controls` | `enabled` (`enableCameraControls`), `keyboard` (`enableKeyboardNavigation`), `zoom` (the opposite of `disableZoom`), `zoomOnSelect` (`zoomOnSelected`), `autoRotate` (a number also sets `autoRotateSpeed`), `refitOnResize`, `limits` (`cameraLimits`), `moveSensitivity`, `zoomSensitivity` |
1037
- | `perf` | `renderMode`, `maxDpr`, `profile` (`performanceProfile`), `preserveDrawingBuffer` |
1038
- | `tiles` | `url` (`tilesetUrl`), `errorTarget` (`tilesErrorTarget`), `cacheSize` (`tilesCacheSize`) |
1039
- | `xr` | `enabled` (`enableXR`), `usdzUrl`, `scaleMode` (`arScaleMode`), `mobileHandoffUrl` |
1040
- | `decoders` | `draco` (`dracoDecoderPath`), `ktx2` (`ktx2TranscoderPath`), `meshopt` |
1041
-
1042
- A preset only fills in defaults: a flat prop overrides it, and a grouped prop
1043
- overrides both. The flat props keep working exactly as before.
1044
-
1045
- ## Public API
1046
-
1047
- The source code currently defines `ModelViewer` with these props:
1048
-
1049
- ```ts
1050
- type Props = {
1051
- preset?: "minimal" | "showcase" | "configurator" | "inspector";
1052
- ui?: ModelViewerUiOptions;
1053
- tools?: ModelViewerToolsOptions;
1054
- controls?: ModelViewerControlsOptions;
1055
- perf?: ModelViewerPerfOptions;
1056
- tiles?: ModelViewerTilesOptions;
1057
- xr?: ModelViewerXrOptions;
1058
- decoders?: ModelViewerDecoderOptions;
1059
- modelUrl: string;
1060
- tilesetUrl?: string | null;
1061
- tilesErrorTarget?: number;
1062
- tilesCacheSize?: number;
1063
- onObjectCatalog?: (objects: ViewerObjectInfo[]) => void;
1064
- modelFormat?: "glb" | "gltf" | "obj" | "fbx" | "usdz";
1065
- licenseKey: string;
1066
- objectBindings?: Record<string, ObjectBinding> | "auto"; // default "auto"
1067
- selectedObject?: ObjectBinding | null;
1068
- panelHoveredObject?: ObjectBinding | null;
1069
- onObjectBindingsChange?: (next: Record<string, ObjectBinding>) => void;
1070
- onObjectSelect?: (binding: ObjectBinding | null) => void;
1071
- onObjectHover?: (binding: ObjectBinding | null) => void;
1072
- onObjectDoubleClick?: (event: ObjectPointerEvent) => boolean | void;
1073
- onObjectContextMenu?: (event: ObjectPointerEvent) => void;
1074
- onModelLoaded?: (model: ViewerModelInfo) => void;
1075
- onLoadError?: (error: unknown) => void;
1076
- onProgress?: (event: ProgressEvent) => void;
1077
- cameraControllerType?: "orbit" | "pointerLock";
1078
- onCameraControllerChange?: (
1079
- controller: "orbit" | "pointerLock",
1080
- ) => void;
1081
- onAction?: (event: ObjectActionEvent) => void;
1082
- onEngagement?: (event: ViewerEngagementEvent) => void | Promise<void>;
1083
- debugEngagement?: boolean;
1084
- onHiddenObjectsChange?: (next: Record<string, boolean>) => void;
1085
- onCameraChange?: (state: ViewerCameraState) => void;
1086
- onViewerReady?: (viewer: ViewerReadyState) => void;
1087
- onTextureUpload?: (file: File, objectId: string) => Promise<string>;
1088
- texturePositioning?: boolean | TexturePositioningControls;
1089
- onAnimationsReady?: (controls: AnimationControls) => void;
1090
- onAnnotationsChange?: (annotations: AnnotationMarker[]) => void;
1091
- activeAnnotation?: AnnotationMarker | null;
1092
- onActiveAnnotationChange?: (annotation: AnnotationMarker | null) => void;
1093
- camera?: ViewerCameraConfig;
1094
- cameraLimits?: CameraLimits;
1095
- backgroundColor?: string;
1096
- shadows?: boolean;
1097
- showObjectBindingDataPanel?: boolean;
1098
- customObjectBindingDataPanel?: (
1099
- props: CustomObjectBindingDataPanelProps,
1100
- ) => React.ReactNode;
1101
- customSceneObjectsPanel?: (
1102
- props: CustomSceneObjectsPanelProps,
1103
- ) => React.ReactNode;
1104
- showSceneObjectsPanel?: boolean;
1105
- showDownloadButton?: boolean;
1106
- downloadFilename?: string;
1107
- showResetButton?: boolean;
1108
- showFullscreenButton?: boolean;
1109
- showLoadingOverlay?: boolean;
1110
- showMouseController?: boolean;
1111
- mouseControllerPosition?:
1112
- | "bottom-left"
1113
- | "bottom-right"
1114
- | "top-left"
1115
- | "top-right"
1116
- | "center"
1117
- | "center-bottom"
1118
- | "center-top";
1119
- mouseControllerOpacity?: number;
1120
- moveSensitivity?: number;
1121
- zoomSensitivity?: number;
1122
- sceneConfig?: SceneConfig;
1123
- disableZoom?: boolean;
1124
- zoomOnSelected?: boolean;
1125
- highlightOnHover?: boolean;
1126
- enableCameraControls?: boolean;
1127
- moveModeEnabled?: boolean;
1128
- objectTransformSpace?: "local" | "world";
1129
- enableKeyboardNavigation?: boolean;
1130
- onAutoFit?: () => Promise<boolean>;
1131
- refitOnResize?: boolean;
1132
- renderMode?: "always" | "demand";
1133
- maxDpr?: number;
1134
- preserveDrawingBuffer?: boolean;
1135
- performanceProfile?: "auto" | "high" | "low";
1136
- dracoDecoderPath?: string | false;
1137
- ktx2TranscoderPath?: string | false;
1138
- meshopt?: boolean;
1139
- showMeasureTools?: boolean;
1140
- showUvCheckerButton?: boolean;
1141
- showExplodeControls?: boolean;
1142
- showSectionTools?: boolean;
1143
- isolation?: ViewerIsolation | null;
1144
- onIsolationChange?: (isolation: ViewerIsolation | null) => void;
1145
- showIsolateControls?: boolean;
1146
- showMaterialVariants?: boolean;
1147
- cinematic?: boolean | CinematicConfig;
1148
- measurementUnit?: string;
1149
- enableXR?: boolean;
1150
- usdzUrl?: string;
1151
- arScaleMode?: "normalized" | "real-world";
1152
- mobileHandoffUrl?: string;
1153
- showAnnotationNavigation?: boolean;
1154
- showAnnotationOnHover?: boolean;
1155
- onSceneConfigChange?: (config: SceneConfig) => void;
1156
- showViewGizmo?: boolean;
1157
- overlay?: React.ReactNode;
1158
- unsafe_sceneChildren?: React.ReactNode;
1159
- autoRotate?: boolean;
1160
- autoRotateSpeed?: number;
1161
- };
1162
- ```
1163
-
1164
- ### `modelUrl`
1165
-
1166
- URL or public path to a `.glb`, `.gltf`, `.obj`, `.fbx`, or `.usdz` model. Hosted GLTF, OBJ, and FBX assets must serve external buffers, MTL files, and textures at their declared relative paths. USDZ dependencies are contained in the USDZ package. Use `modelFormat` when a signed or extensionless URL cannot be auto-detected.
1167
-
1168
- Example:
1169
-
1170
- ```tsx
1171
- modelUrl = "/model.glb";
1172
- ```
1173
-
1174
- ### `modelFormat`
1175
-
1176
- Optional explicit format for signed or extensionless model URLs. Normal URLs
1177
- ending in `.glb`, `.gltf`, `.obj`, `.fbx`, or `.usdz` are detected automatically.
1178
-
1179
- ### 3D Tiles streaming
1180
-
1181
- Use `tilesetUrl` to stream a processed 3D Tiles model instead of downloading
1182
- `modelUrl` as one monolithic asset. `modelUrl` remains required by the component
1183
- API, but `tilesetUrl` is the render source while streaming is enabled.
1184
-
1185
- ```tsx
1186
- <ModelViewer
1187
- modelUrl="/models/campus.glb"
1188
- tilesetUrl="/models/campus/tileset.json"
1189
- tilesErrorTarget={8}
1190
- tilesCacheSize={800}
1191
- onObjectCatalog={(objects) => console.log(objects)}
1192
- {...props}
1193
- />
1194
- ```
1195
-
1196
- - `tilesErrorTarget` controls the screen-space error target. Lower values load
1197
- sharper tiles and use more bandwidth/GPU memory. Default: `8`.
1198
- - `tilesCacheSize` is the maximum number of parsed tiles kept in the client
1199
- cache. Default: `800`.
1200
- - `onObjectCatalog` receives the bindable-object catalog from `objects.json`
1201
- before all referenced tiles have loaded. See [`onObjectCatalog`](#onobjectcatalog).
1202
-
1203
- Bindings, selection, hover, material overrides, transforms, exploded view, and
1204
- scene renderer modes use the same public API in streamed and monolithic modes.
1205
- The tileset and its tile payloads must be browser-accessible, and the optional
1206
- object catalog must sit beside `tileset.json` as `objects.json`.
1207
-
1208
- ### `licenseKey`
1209
-
1210
- License key for the library. Required.
1211
-
1212
- ### `objectBindings`
1213
-
1214
- A map keyed by the model node name, or `"auto"`, the default (see
1215
- [Generating bindings automatically](#generating-bindings-automatically)). Each
1216
- key should match a mesh name from the GLB/GLTF file.
1217
-
1218
- `objectBindings` is the single source of truth for all visual state. Changes to the binding record drive rendering:
1219
-
1220
- - `visible` controls mesh visibility
1221
- - `style.material.baseColor` sets the mesh color (committed by the built-in color picker on close)
1222
- - `style.material.texture.path` sets the mesh texture (committed by the built-in texture upload; uses `onTextureUpload` for a durable URL when provided, otherwise a session-scoped blob URL)
1223
- - `style.material.*` applies per-object `MeshPhysicalMaterial` overrides such as emissive, metalness, roughness, opacity, clearcoat, sheen, anisotropy, specular, transmission, thickness, reflectivity, and sidedness
1224
- - `cameraState.position` and `cameraState.target` define the camera view to use when that object is focused or selected from the viewer UI
1225
-
1226
- Example:
1227
-
1228
- ```ts
1229
- import { defineObjectBindings } from "@liveroom-tech/react-immersive/utils";
1230
-
1231
- const objectBindings = defineObjectBindings({
1232
- Object_2: {
1233
- id: "obj-2",
1234
- modelObjectId: "Object_2",
1235
- type: "body",
1236
- visible: true,
1237
- cameraState: {
1238
- position: [2.8, 1.6, 4.2],
1239
- target: [0, 0.8, 0],
1240
- },
1241
- style: {
1242
- material: {
1243
- baseColor: "#ff0000",
1244
- texture: {
1245
- path: "/materials/body-finish.jpg",
1246
- },
1247
- },
1248
- },
1249
- actions: [
1250
- { id: "change-color", label: "Change Color", type: "command" },
1251
- { id: "change-material", label: "Change Material", type: "command" },
1252
- { id: "toggle-visibility", label: "Toggle Visibility", type: "command" },
1253
- ],
1254
- metrics: {},
1255
- metadata: {},
1256
- },
1257
- });
1258
- ```
1259
-
1260
- `defineObjectBindings` validates the complete record while preserving its exact keys and literal values. Use `ObjectBindingKey<typeof objectBindings>` for the binding-key union and `ObjectBindingActionId<typeof objectBindings, "Object_2">` for that binding's action-id union. It returns the input unchanged at runtime.
1261
-
1262
- If a binding's `modelObjectId` (or its key) doesn't match any node in the
1263
- loaded model, that binding can never be selected. `ModelViewer` then shows a
1264
- dismissible banner with the number of mismatched bindings, and logs a console
1265
- warning naming them. Log [`onObjectCatalog`](#onobjectcatalog) to see the
1266
- model's node names.
1267
-
1268
- #### Generating bindings automatically
1269
-
1270
- `objectBindings` defaults to `"auto"`: leave it out and `ModelViewer` generates
1271
- a binding for every mesh when the model loads, so you don't need to know the
1272
- node names up front:
1273
-
1274
- ```tsx
1275
- <ModelViewer modelUrl="/model.glb" licenseKey="your-license-key" />
1276
- ```
1277
-
1278
- Each generated binding is keyed by the node name, with a readable `label`
1279
- (`"Wheel_FL"` becomes `"Wheel FL"`), an inferred `type`, a unique `id`, and
1280
- built-in actions: `change-color`, `change-material`, and `toggle-visibility`,
1281
- or `toggle-light`, `change-light-color`, and `set-brightness` for meshes whose
1282
- names contain "light". For a streamed model (`tilesetUrl`), the bindings come
1283
- from the object catalog, so objects are bindable before their tiles load.
1284
-
1285
- The generated bindings are passed to `onObjectBindingsChange` once they exist,
1286
- and again after every edit. To keep them, and to refine them later, store them
1287
- and pass them back:
1288
-
1289
- ```tsx
1290
- const [objectBindings, setObjectBindings] = useState<
1291
- Record<string, ObjectBinding> | "auto"
1292
- >("auto");
1293
-
1294
- <ModelViewer
1295
- modelUrl={modelUrl}
1296
- licenseKey="your-license-key"
1297
- objectBindings={objectBindings}
1298
- onObjectBindingsChange={setObjectBindings}
1299
- />;
1300
- ```
1301
-
1302
- After the first change the viewer is controlled by your state as usual. Set the
1303
- state back to `"auto"` when you switch to a different model. While the prop is
1304
- `"auto"`, bindings the same model already had are kept when it reloads, so
1305
- runtime edits survive; a different `modelUrl` starts from fresh bindings.
1306
-
1307
- The same defaults are available as functions from both entry points (they are
1308
- also what `BindingBuilder` generates):
1309
-
1310
- ```ts
1311
- import {
1312
- buildBindingsFromNodes,
1313
- createDefaultBinding,
1314
- inferType,
1315
- } from "@liveroom-tech/react-immersive/utils";
1316
-
1317
- const bindings = buildBindingsFromNodes(["CarBody", "Wheel_FL"]);
1318
- const door = { ...createDefaultBinding("FrontDoor"), label: "Front door" };
1319
- inferType("Wheel_FL"); // "wheel"
1320
- ```
1321
-
1322
- Every generated action is one `ModelViewer` performs itself, so every
1323
- generated button works without extra setup.
1324
-
1325
- ### `selectedObject`
1326
-
1327
- Optional currently selected object binding, or `null` when nothing is selected.
1328
-
1329
- If provided, `ModelViewer` behaves as a controlled component.
1330
- If omitted, `ModelViewer` manages its own selection state internally.
1331
-
1332
- When the selected object has a `cameraState` with both `position` and `target`, the viewer uses that saved camera view for focus/select behavior instead of falling back to `fitToBox`.
1333
-
1334
- ### `panelHoveredObject`
1335
-
1336
- Optional externally controlled binding to highlight as hovered by a custom
1337
- scene-objects panel. It takes precedence over the built-in panel and canvas
1338
- hover while `highlightOnHover` is enabled. Pass `null` when no panel row is
1339
- hovered.
1340
-
1341
- ### `onObjectSelect`
1342
-
1343
- Optional callback called when the user clicks a mesh or closes the side panel.
1344
-
1345
- Behavior:
1346
-
1347
- - clicking a mesh calls `onObjectSelect(binding)`
1348
- - closing the panel calls `onObjectSelect(null)`
1349
- - clicking the same mesh again still selects it; selection is not toggled off automatically
1350
- - if the binding includes `cameraState.position` and `cameraState.target`, the viewer moves the camera to that saved view when focusing that object
1351
-
1352
- ### `onObjectHover`
1353
-
1354
- Optional callback called when the user hovers a mesh in the model.
1355
-
1356
- Behavior:
1357
-
1358
- - pointer over a mesh calls `onObjectHover(binding)`
1359
- - pointer out calls `onObjectHover(null)`
1360
-
1361
- ### `onObjectDoubleClick`
1362
-
1363
- Optional callback called when the user double-clicks an object.
1364
-
1365
- ```ts
1366
- onObjectDoubleClick?: (event: ObjectPointerEvent) => boolean | void
1367
-
1368
- type ObjectPointerEvent = {
1369
- binding: ObjectBinding;
1370
- clientX: number; // viewport coordinates
1371
- clientY: number;
1372
- pointerType: string; // "mouse" | "pen" | "touch"
1373
- surface?: { position: Vec3; normal: Vec3 }; // where on the object, in its own space
1374
- };
1375
- ```
1376
-
1377
- Return `true` to say you handled it: the viewer then skips its own double-click
1378
- behavior, which moves the camera's orbit point to that spot (or starts texture
1379
- positioning, when `texturePositioning` is on). Return nothing to keep it.
1380
-
1381
- ### `onObjectContextMenu`
1382
-
1383
- Optional callback called when the user right-clicks an object, or long-presses
1384
- it on a touch screen. Use it to open your own menu:
1385
-
1386
- ```tsx
1387
- <ModelViewer
1388
- {...props}
1389
- onObjectContextMenu={({ binding, clientX, clientY }) =>
1390
- openMenu({ for: binding.id, x: clientX, y: clientY })
1391
- }
1392
- />
1393
- ```
1394
-
1395
- It receives the same `ObjectPointerEvent` as `onObjectDoubleClick`, with the
1396
- position where the gesture started, ready for a `position: fixed` menu. A
1397
- right-click fires when the button is released without the pointer moving, so a
1398
- right-drag still pans the camera. A long-press fires after half a second, and
1399
- not if the finger moves or a second finger touches down (a pinch); lifting the
1400
- finger afterwards doesn't select the object. Objects with `selectable: false`
1401
- don't fire it.
1402
-
1403
- ### `onHiddenObjectsChange`
1404
-
1405
- Optional callback fired with the derived hidden-object map whenever the current binding data changes hidden visibility state.
1406
-
1407
- ### `onObjectBindingsChange`
1408
-
1409
- Optional callback fired when the viewer's built-in UI updates binding data.
1410
-
1411
- This fires for:
1412
-
1413
- - visibility toggles (`binding.visible`)
1414
- - color picks (`binding.style.material.baseColor`), committed when the color picker closes
1415
- - texture uploads (`binding.style.material.texture.path`), committed immediately (via `onTextureUpload` when provided, otherwise as a blob URL)
1416
- - texture removal (`binding.style.material.texture` cleared)
1417
- - object movement and rotation (`binding.transform.position` and `binding.transform.rotation`)
1418
-
1419
- If you want the viewer and your app state to stay in sync, pass `objectBindings` from state and wire this callback back into that state setter.
1420
-
1421
- ### `onObjectCatalog`
1422
-
1423
- Optional callback listing every bindable object in the model: each named mesh,
1424
- under the identifier `objectBindings` is keyed by. It's the quickest way to find
1425
- out what your meshes are called:
1426
-
1427
- ```tsx
1428
- <ModelViewer
1429
- modelUrl="/model.glb"
1430
- licenseKey="your-license-key"
1431
- onObjectCatalog={(objects) => console.table(objects)}
1432
- />
1433
- ```
1434
-
1435
- It fires each time a model loads. For a streamed model (`tilesetUrl`) the list
1436
- comes from `objects.json` beside `tileset.json`, before the tiles containing
1437
- those objects have necessarily loaded. Each entry is a `ViewerObjectInfo`:
1438
-
1439
- ```ts
1440
- type ViewerObjectInfo = {
1441
- name: string; // the key to use in objectBindings
1442
- triangles: number;
1443
- minimum: [number, number, number];
1444
- maximum: [number, number, number];
1445
- };
1446
- ```
1447
-
1448
- `minimum` and `maximum` are the object's bounds in the model's own units, in
1449
- Z-up coordinates as in 3D Tiles: a point at glTF `(x, y, z)` is `(x, -z, y)`
1450
- here. They're the same for loaded and streamed models, and don't change when the
1451
- viewer moves or scales the model. To keep the list in state, use
1452
- `useViewerModel` and pass its `handleObjectCatalog`.
1453
-
1454
- ### `onModelLoaded`
1455
-
1456
- Optional callback fired after the model has loaded, with its bounds and mesh
1457
- count:
1458
-
1459
- ```ts
1460
- (model: ViewerModelInfo) => void
1461
-
1462
- type ViewerModelInfo = {
1463
- bounds: { min: Vec3; max: Vec3; center: Vec3; size: Vec3 }; // world space
1464
- objectCount: number; // meshes in the loaded scene
1465
- materialVariants: string[]; // glTF material variant names, if any
1466
- };
1467
- ```
1468
-
1469
- For the model's object names, use [`onObjectCatalog`](#onobjectcatalog).
1470
-
1471
- ### `onLoadError`
1472
-
1473
- Optional callback fired if the model fails to load or render.
1474
-
1475
- Current callback shape:
1476
-
1477
- ```ts
1478
- (error: unknown) => void
1479
- ```
1480
-
1481
- Whether or not you pass it, `ModelViewer` shows a message in place of the
1482
- model that explains the likely cause: a missing file (404), refused access
1483
- (401/403), a blocked cross-origin request (CORS), a web page served instead of
1484
- a model, or a file that isn't the expected format. It includes the URL and the
1485
- underlying error. Set `showLoadingOverlay={false}` to show your own instead.
1486
-
1487
- ### `onProgress`
1488
-
1489
- Called with the loader's `ProgressEvent` while a monolithic model is being
1490
- downloaded. When `event.lengthComputable` is true, progress is
1491
- `event.loaded / event.total`; the built-in loading overlay uses the same value.
1492
-
1493
- ```ts
1494
- onProgress?: (event: ProgressEvent) => void
1495
- ```
1496
-
1497
- ### `onAction`
1498
-
1499
- Optional callback fired when a built-in action button is clicked from the side panel.
1500
-
1501
- Current event shape:
1502
-
1503
- ```ts
1504
- type ObjectActionEvent = {
1505
- objectId: string;
1506
- action: ObjectBindingAction;
1507
- binding?: ObjectBinding;
1508
- screenX?: number;
1509
- screenY?: number;
1510
- };
1511
- ```
1512
-
1513
- ### `onEngagement` / `debugEngagement`
1514
-
1515
- Optional interaction analytics. Set `onEngagement` to receive typed
1516
- `ViewerEngagementEvent` objects, or set `debugEngagement` to log them in the
1517
- browser's developer console with the `[react-immersive engagement]` prefix.
1518
- Both are disabled by default. The viewer does not send telemetry or persist
1519
- analytics identifiers; your callback decides where events go.
1520
-
1521
- ```tsx
1522
- import { ModelViewer, type ViewerEngagementEvent } from "@liveroom-tech/react-immersive";
1523
-
1524
- function handleEngagement(event: ViewerEngagementEvent) {
1525
- if (event.type === "part-viewed") {
1526
- console.info("Part viewed:", event.objectKey, event.source);
1527
- }
1528
- if (event.type === "ar-ended") {
1529
- console.info("Time in AR:", event.durationMs);
1530
- }
1531
- // Connect this callback to your application's analytics integration.
1532
- }
1533
-
1534
- <ModelViewer
1535
- modelUrl="/car.glb"
1536
- licenseKey={licenseKey}
1537
- onEngagement={handleEngagement}
1538
- debugEngagement
1539
- />
1540
- ```
1541
-
1542
- Every event includes `sessionId` (an ephemeral ID for this viewer/model),
1543
- `timestamp` (ISO format), `elapsedMs`, `modelUrl`, and `tilesetUrl` (or `null`).
1544
- Durations use a monotonic clock and are expressed in milliseconds. Session
1545
- elapsed time includes loading and background time; it is not an attention metric.
1546
-
1547
- | Event `type` | Details and trigger |
1548
- | --- | --- |
1549
- | `part-viewed` | `objectId`, `objectKey`, optional `label`, and `source` (`"canvas"` or `"panel"`). Selecting/focusing a different part; reselecting the current part is ignored. |
1550
- | `variant-chosen` | `variant` and `previousVariant` (names or `null` for the default). Choosing a different built-in material variant. |
1551
- | `ar-started` | A confirmed immersive WebXR AR session begins. |
1552
- | `ar-ended` | `durationMs` and `reason` (`"session-ended"` or `"interrupted"`). A confirmed AR session ends, or tracking stops on model change, unmount, or context loss. |
1553
- | `ar-launch-requested` | `channel` (`"quick-look"` or `"mobile-handoff"`). Opening external AR or its QR handoff; this does not claim an AR session started. |
1554
- | `tour-started` | `annotationCount`. Starting the guided tour. |
1555
- | `tour-completed` | `annotationCount` and `durationMs`. Advancing past its final annotation; emitted once per completed tour. |
1556
- | `tour-stopped` | `annotationCount`, `durationMs`, and `reason` (`"stopped"`, `"restarted"`, `"annotations-changed"`, or `"interrupted"`). Leaving a tour before completion. |
1557
-
1558
- Hover, camera motion, renders, and externally supplied selection/variant updates
1559
- do not create engagement events. WebXR duration measures the session interval;
1560
- Quick Look runs outside the page and has no reliable duration callback. Turning
1561
- tracking on during an existing AR session measures from attachment. Callback
1562
- changes do not restart timing, and synchronous or asynchronous callback failures are logged without
1563
- interrupting the viewer. A new model or re-enabling tracking creates a new
1564
- analytics session; WebGL recovery keeps the session ID; context loss ends active intervals
1565
- as interrupted.
1566
-
1567
- ### `onViewerReady`
1568
-
1569
- Optional callback fired once camera controls are available and again when the
1570
- viewer publishes updated ready-state data (for example after model load,
1571
- camera changes, or binding changes).
1572
-
1573
- Current callback shape:
1574
-
1575
- ```ts
1576
- (viewer: ViewerReadyState) => void
1577
- ```
1578
-
1579
- `ViewerReadyState` includes `captureImage`, an imperative method for grabbing a PNG snapshot of the canvas:
1580
-
1581
- ```ts
1582
- type ViewerReadyState = {
1583
- objectBindings: Record<string, ObjectBinding>;
1584
- homeCameraState: { position: Vec3; target: Vec3 } | null;
1585
- captureImage: (options?: CaptureImageOptions) => Promise<string>;
1586
- captureVideo: (options?: CaptureVideoOptions) => Promise<Blob>;
1587
- invalidate: () => void;
1588
- raw: {
1589
- controls: CameraControls; // camera-controls
1590
- scene: Object3D | null; // three.js
1591
- nodes: Record<string, Object3D>; // model nodes by binding key and name
1592
- };
1593
- };
1594
-
1595
- type CaptureImageOptions = {
1596
- width?: number;
1597
- height?: number;
1598
- transparent?: boolean;
1599
- };
1600
- ```
1601
-
1602
- `raw` holds the live three.js scene, the camera-controls instance, and the
1603
- model's nodes, for integrations the rest of the API doesn't cover. You don't
1604
- need it for anything the hooks and props already do, and its shapes are those
1605
- libraries' own, so they can change when those libraries do.
1606
-
1607
- `captureImage` requires the opt-in `preserveDrawingBuffer` prop, forces a render, and resolves with a `data:image/png` URL. Pass `width`/`height` to render at a resolution other than the canvas's current size, and `transparent` to hide the configured background so the PNG carries an alpha channel instead. It rejects if called before the viewer is ready or when framebuffer preservation is disabled. The Download PNG menu item is also shown only when this prop is enabled.
1608
-
1609
- ```tsx
1610
- <ModelViewer
1611
- preserveDrawingBuffer
1612
- onViewerReady={(viewer) => {
1613
- viewer
1614
- .captureImage({ width: 1920, height: 1080, transparent: true })
1615
- .then((dataUrl) => {
1616
- // upload, preview, etc.
1617
- });
1618
- }}
1619
- />;
1620
- ```
1621
-
1622
- Note: requesting a custom `width`/`height` briefly resizes the live canvas to render at that resolution before restoring it, which can cause a momentary flicker on screen, fine for an occasional snapshot, not for rapid/looped calls.
1623
-
1624
- If camera, effects, screenshots, or custom setup all need the ready viewer, combine them with `useViewerConnection`:
1625
-
1626
- ```tsx
1627
- const camera = useViewerCamera();
1628
- const effects = useViewerEffects();
1629
- const connection = useViewerConnection(camera, effects);
1630
-
1631
- <ModelViewer
1632
- preserveDrawingBuffer
1633
- onViewerReady={connection.handleViewerReady}
1634
- />;
1635
-
1636
- const dataUrl = await connection.captureImage({ width: 1920, height: 1080 });
1637
- ```
1638
-
1639
- `captureVideo` records one complete cinematic pass or turntable revolution and
1640
- resolves with a video `Blob`. It is also available on `useViewerConnection` and
1641
- `useViewer().connection`. Call it from a button handler after the model has
1642
- finished loading and framing; ready-state callbacks run repeatedly as the camera
1643
- moves and should not start recordings automatically.
1644
-
1645
- ```tsx
1646
- const viewer = useViewer();
1647
- const abort = new AbortController();
1648
-
1649
- <ModelViewer {...viewer.props} cinematic showDownloadButton />;
1650
-
1651
- // Run in an event handler. Upload the Blob or preview it with an object URL.
1652
- const clip = await viewer.connection.captureVideo({
1653
- mode: "turntable", // or "cinematic" to use the enabled camera path
1654
- format: "auto", // prefers WebM; falls back to MP4
1655
- duration: 12, // seconds; defaults to path timing or a 24-second orbit
1656
- fps: 30, // 1–60; actual throughput depends on rendering/encoding
1657
- videoBitsPerSecond: 8_000_000,
1658
- signal: abort.signal,
1659
- });
1660
- // abort.abort() cancels an in-progress export and discards its data.
1661
- ```
1662
-
1663
- The download menu offers **Record turntable video** and, when cinematic is
1664
- enabled, **Record cinematic video**, plus Auto/WebM/MP4 format selection. A
1665
- recording shows progress and a Cancel control. The filename and Blob MIME type
1666
- match the encoded format; an explicitly requested unsupported format rejects
1667
- instead of silently changing formats. With `loop: true`, a cinematic export
1668
- includes the return segment and stops after one cycle.
1669
-
1670
- Recording runs in real time at the canvas's current pixel resolution, includes
1671
- post-processing, and hides editor gizmos. It pauses cinematic playback, blocks
1672
- viewer gestures, then restores the previous camera pose and controls on success,
1673
- cancellation, or failure. Keep the tab visible until recording completes.
1674
- `preserveDrawingBuffer` is unnecessary for video. No audio, HTML overlays,
1675
- GIF encoding, or format transcoding is included. The browser must support
1676
- `canvas.captureStream` and `MediaRecorder`; exports reject before framing,
1677
- during XR, during another recording, or for durations outside (0, 300] seconds.
1678
-
1679
- ### `onTextureUpload`
1680
-
1681
- Optional async callback for handling texture file uploads. When provided, the viewer calls it instead of creating a blob URL, letting consumers upload to their own storage (S3, Cloudinary, a CDN, etc.) and return a durable URL that survives page reloads.
1682
-
1683
- Current callback shape:
1684
-
1685
- ```ts
1686
- (file: File, objectId: string) => Promise<string>;
1687
- ```
1688
-
1689
- The returned string is stored in `binding.style.material.texture.path` via `onObjectBindingsChange`.
1690
-
1691
- If omitted, the viewer falls back to `URL.createObjectURL(file)` which produces a short blob URL that works for the current session but is lost on reload.
1692
-
1693
- Example:
1694
-
1695
- ```tsx
1696
- <ModelViewer
1697
- modelUrl="/model.glb"
1698
- licenseKey="your-license-key"
1699
- objectBindings={objectBindings}
1700
- onObjectBindingsChange={setObjectBindings}
1701
- onTextureUpload={async (file, objectId) => {
1702
- const formData = new FormData();
1703
- formData.append("file", file);
1704
- formData.append("objectId", objectId);
1705
- const res = await fetch("/api/upload-texture", {
1706
- method: "POST",
1707
- body: formData,
1708
- });
1709
- const { url } = await res.json();
1710
- return url; // e.g. "https://cdn.example.com/textures/abc123.png"
1711
- }}
1712
- />
1713
- ```
1714
-
1715
- ### `texturePositioning`
1716
-
1717
- Turns on texture positioning for objects with an uploaded texture. Off by
1718
- default. When on, the **Change Material** panel gains Offset X/Y and Rotation
1719
- controls, and double-clicking the object puts the viewer in Move/Zoom mode:
1720
- drag to move the texture, scroll to scale it, and click the canvas or
1721
- **Done positioning** to finish.
1722
-
1723
- ```tsx
1724
- <ModelViewer modelUrl="/sofa.glb" licenseKey="your-license-key" texturePositioning />
1725
- ```
1726
-
1727
- Changes are written to the binding's `style.material.texture` (`offset`,
1728
- `rotation` in radians, and `scale`), so they reach `onObjectBindingsChange`
1729
- and your saved bindings like any other edit.
1730
-
1731
- To handle some of it yourself, pass an object instead of `true`. Any field you
1732
- leave out keeps the viewer's own behavior:
1733
-
1734
- ```ts
1735
- type TexturePositioningControls = {
1736
- offset?: [number, number]; // shown in the Offset fields instead of the binding's
1737
- rotationDegrees?: number; // shown in the Rotation field, 0–360
1738
- onOffsetChange?: (objectId: string, axisIndex: 0 | 1, value: number) => void;
1739
- onRotationChange?: (objectId: string, degrees: number) => void;
1740
- isPositioning?: boolean; // shows "Done positioning" instead of the hint
1741
- onEndPositioning?: () => void; // after Done positioning ends the mode
1742
- };
1743
- ```
1744
-
1745
- `onOffsetChange` and `onRotationChange` replace the viewer's writes from the
1746
- panel fields; dragging and scrolling on the canvas still write to the binding.
1747
-
1748
- ---
1749
-
1750
- ### `onAnimationsReady`
1751
-
1752
- Optional callback fired after the GLB/GLTF model is loaded, providing animation controls. If the model contains no animations, it is still called with an empty `clips` array and no-op control functions.
1753
-
1754
- Current callback shape:
1755
-
1756
- ```ts
1757
- (controls: AnimationControls) => void
1758
- ```
1759
-
1760
- Where `AnimationControls` is:
1761
-
1762
- ```ts
1763
- type AnimationPlayOptions = {
1764
- alongside?: boolean; // keep the clips already playing (default false: replace them)
1765
- fade?: number; // seconds to fade in, and to fade out the clips it replaces
1766
- reverse?: boolean; // play backwards, from where the clip is or from its end
1767
- };
1768
-
1769
- type AnimationClipState = {
1770
- clip: string;
1771
- status: "playing" | "paused" | "finished"; // finished: a play-once clip holding its last pose
1772
- time: number; // seconds
1773
- duration: number; // seconds
1774
- speed: number;
1775
- reverse: boolean;
1776
- };
1777
-
1778
- type AnimationPlaybackState = {
1779
- currentClip: string | null; // the clip played most recently, while it's active
1780
- isPlaying: boolean; // whether any clip is playing
1781
- speed: number; // speed, position and length of currentClip
1782
- time: number;
1783
- duration: number;
1784
- active: AnimationClipState[]; // every active clip, most recently played last
1785
- };
1786
-
1787
- // Leave out clipName to act on every active clip.
1788
- type AnimationControls = {
1789
- clips: string[];
1790
- clipDetails?: { sourceName: string; duration: number }[];
1791
- play: (clipName: string, options?: AnimationPlayOptions) => void;
1792
- pause: (clipName?: string) => void;
1793
- stop: (clipName?: string) => void; // stops and resets the pose
1794
- setSpeed: (speed: number, clipName?: string) => void;
1795
- seek?: (time: number, clipName?: string) => void; // absolute time, in seconds
1796
- getState?: () => AnimationPlaybackState;
1797
- subscribe?: (listener: (state: AnimationPlaybackState) => void) => () => void;
1798
- };
1799
- ```
1800
-
1801
- Wire this to `useViewerAnimations().handleAnimationsReady` for the simplest integration.
1802
- When `sceneConfig.animations.autoplayClip` is set, `ModelViewer` will auto-play
1803
- that clip on load and respect per-clip `loopMode` (`"repeat"`, `"once"`, or
1804
- `"ping-pong"`), `speed`, `displayName`, and soft-delete (`hidden`) settings.
1805
-
1806
- ### Lighting
1807
-
1808
- Lighting lives in `sceneConfig.lighting`: an ambient light plus a list of
1809
- directional, point, spot, and hemisphere lights. Without a `sceneConfig`,
1810
- `ModelViewer` uses its default rig (ambient, a hemisphere fill, and a
1811
- shadow-casting key light). To use your own lights, patch the default scene
1812
- config. `sceneLight` fills in every setting you leave out:
1813
-
1814
- ```tsx
1815
- import {
1816
- DEFAULT_SCENE_CONFIG,
1817
- patchSceneConfig,
1818
- sceneLight,
1819
- } from "@liveroom-tech/react-immersive/utils";
1820
-
1821
- const sceneConfig = patchSceneConfig(DEFAULT_SCENE_CONFIG, {
1822
- lighting: {
1823
- ambient: { intensity: 0.5 },
1824
- lights: [
1825
- sceneLight({ id: "key", type: "directional", position: [4, 8, 4], intensity: 1.6, castShadow: true }),
1826
- sceneLight({ id: "fill", type: "point", position: [-3, 3, 2], intensity: 0.8 }),
1827
- ],
1828
- },
1829
- });
1830
-
1831
- <ModelViewer
1832
- modelUrl="/model.glb"
1833
- licenseKey="your-license-key"
1834
- sceneConfig={sceneConfig}
1835
- />;
1836
- ```
1837
-
1838
- To change lights while the app runs, use the lights controller from
1839
- `useViewer` (or `useSceneConfig`):
1840
-
1841
- ```tsx
1842
- const viewer = useViewer({ sceneConfig });
1843
-
1844
- viewer.scene.lights.setIntensity("key", 2.2);
1845
- viewer.scene.lights.toggle("fill");
1846
- viewer.scene.lights.add({ id: "bulb", type: "point", color: "#ffd27d", intensity: 4 });
1847
- viewer.scene.lights.attach("bulb", { objectId: "Lamp", offset: [0, 1.4, 0] });
1848
- ```
1849
-
1850
- An attached light follows the object, offset from the object's origin in its
1851
- local space (the origin is often at its base, not its center). Lighting set up
1852
- in `BindingBuilder`'s Scene tab exports as the same `sceneConfig`.
1853
-
1854
- ### Style rules
1855
-
1856
- `sceneConfig.styleRules` restyles objects from their own data while the app
1857
- runs: a colour for a temperature, grey for a disabled part, a pulsing glow for
1858
- an alarm. Each rule picks objects (`target`), checks their data (`when`), and
1859
- sets a look (`material`, `colorScale`, `pulse`):
1860
-
1861
- ```tsx
1862
- const viewer = useViewer({
1863
- bindings,
1864
- sceneConfig: {
1865
- ...DEFAULT_SCENE_CONFIG,
1866
- styleRules: [
1867
- {
1868
- id: "temperature",
1869
- target: { group: "pumps" },
1870
- colorScale: {
1871
- metric: "temperature",
1872
- stops: [[18, "#3b82f6"], [24, "#22c55e"], [32, "#ef4444"]],
1873
- },
1874
- },
1875
- {
1876
- id: "offline",
1877
- when: { status: "disabled" },
1878
- material: { baseColor: "#9ca3af", opacity: 0.4 },
1879
- },
1880
- {
1881
- id: "alarm",
1882
- when: [{ metric: "temperature", above: 32 }, { metadata: "alarm.acknowledged", equals: false }],
1883
- pulse: { color: "#ff3b30", speed: 1.5 },
1884
- },
1885
- ],
1886
- },
1887
- });
1888
-
1889
- <ModelViewer modelUrl="/plant.glb" licenseKey="your-license-key" {...viewer.props} />;
1890
-
1891
- // Live data: update the bindings and the looks follow.
1892
- viewer.bindings.updateObjectBindings("pump-3", { metrics: { temperature: 34 } });
1893
- viewer.bindings.updateObjectBindings("valve-1", { status: "disabled" });
1894
- ```
1895
-
1896
- - `target` takes the same targets as the binding helpers: an id, a list of
1897
- ids, `{ group }`, `{ tag }`, or `{ type }`. Left out, the rule considers every
1898
- bound object.
1899
- - `when` is a condition, or a list that must all match; left out, the rule
1900
- always applies. Conditions: `{ metric, above?, below? }` (the value must be
1901
- greater than `above` and less than `below`; an object without the metric
1902
- doesn't match), `{ status }` with one status or a list (a binding without
1903
- one counts as `"normal"`), and `{ metadata, equals }`, where dots in the key
1904
- reach into nested metadata.
1905
- - `material` accepts any `style.material` field. `colorScale` sets
1906
- `baseColor` (or `emissive`, with `channel: "emissive"`) from a metric,
1907
- blending between hex colour stops and taking the nearest stop outside them.
1908
- `pulse` makes the glow fade in and out (`true`, or `{ color, speed }` in
1909
- pulses per second).
1910
- - Rules apply in order over each object's own `style.material`, so a later
1911
- rule wins where two set the same field. Hover and selection highlighting
1912
- still show on top.
1913
- - Rules only change how objects look. `objectBindings`, `onObjectBindingsChange`,
1914
- and every callback keep the object's own values, so nothing a rule sets is
1915
- saved with the bindings.
1916
- - The pulse isn't drawn on streamed 3D Tiles models (`tilesetUrl`); the other
1917
- looks are.
1918
-
1919
- BindingBuilder's Scene tab has a **Rules** sub-tab for building these rules
1920
- visually. It suggests your groups, tags, types, metric names, and metadata
1921
- keys, shows how many objects each rule matches right now, and previews the
1922
- result live. Rules export and import with the rest of `sceneConfig`.
1923
-
1924
- `applyStyleRules(bindings, rules)` (from the main entry or `/utils`) returns
1925
- the styled bindings, for example to colour your own list the way the viewer
1926
- does, and `colorScaleValue(stops, value)` the colour a scale gives a value, for
1927
- a legend.
1928
-
1929
- ### `camera`
1930
-
1931
- Optional starting camera: where it is and its lens.
1932
-
1933
- ```ts
1934
- type ViewerCameraConfig = {
1935
- position?: [number, number, number];
1936
- fov?: number; // vertical field of view in degrees; default 50
1937
- near?: number;
1938
- far?: number;
1939
- zoom?: number;
1940
- };
1941
- ```
1942
-
1943
- Without a `position`, the camera starts at `[0, 0, 5]`. Pass one for predictable framing.
1944
-
1945
- Example:
1946
-
1947
- ```tsx
1948
- <ModelViewer
1949
- modelUrl="/model.glb"
1950
- licenseKey="your-license-key"
1951
- objectBindings={objectBindings}
1952
- camera={{
1953
- position: [0, 2.2, 7],
1954
- fov: 40,
1955
- near: 0.1,
1956
- far: 1000,
1957
- }}
1958
- />
1959
- ```
1960
-
1961
- Passing an explicit `camera` counts as choosing the initial view yourself, so the mount-time auto-fit (see [`onAutoFit`](#onautofit)) is skipped automatically and your `position`/`fov` stick. Provide `onAutoFit` as well only if you want to run your _own_ fit-to-scene logic instead.
1962
-
1963
- ### `cameraLimits`
1964
-
1965
- Constrains how far the orbit camera can zoom, tilt, turn, and pan. Angles are
1966
- in degrees.
1967
-
1968
- ```tsx
1969
- <ModelViewer
1970
- modelUrl="/car.glb"
1971
- licenseKey="your-license-key"
1972
- cameraLimits={{
1973
- minDistance: 2,
1974
- maxDistance: 12,
1975
- maxPolarAngle: 85, // stay above the floor
1976
- minAzimuthAngle: -60, // turn at most 60° either side of the front
1977
- maxAzimuthAngle: 60,
1978
- }}
1979
- />
1980
- ```
1981
-
1982
- ```ts
1983
- type CameraLimits = {
1984
- minDistance?: number; // default 0
1985
- maxDistance?: number; // default Infinity
1986
- minPolarAngle?: number; // degrees, default 0
1987
- maxPolarAngle?: number; // degrees, default 180
1988
- minAzimuthAngle?: number; // degrees, default -Infinity
1989
- maxAzimuthAngle?: number; // degrees, default Infinity
1990
- panBoundary?: [
1991
- min: [number, number, number],
1992
- max: [number, number, number],
1993
- ];
1994
- boundaryEnclosesCamera?: boolean; // default false
1995
- boundaryFriction?: number; // default 0
1996
- };
1997
- ```
1998
-
1999
- - **Polar** is the vertical angle: `0` looks straight down from above, `90` is
2000
- level with the target, and `180` looks straight up from below.
2001
- - **Azimuth** is the horizontal angle around the vertical axis: `0` views the
2002
- target from the front (+Z), `90` from its right (+X), and `-90` from its left.
2003
-
2004
- `panBoundary` is an axis-aligned world-space box. These limits apply to the
2005
- orbit controller; pointer-lock mode is not orbiting around the same target.
2006
-
2007
- ### `backgroundColor`
2008
-
2009
- Optional background color for the viewer canvas.
2010
-
2011
- Example:
2012
-
2013
- ```tsx
2014
- <ModelViewer
2015
- modelUrl="/model.glb"
2016
- licenseKey="your-license-key"
2017
- objectBindings={objectBindings}
2018
- backgroundColor="#0f172a"
2019
- />
2020
- ```
2021
-
2022
- ### `shadows`
2023
-
2024
- Optional boolean that controls whether the viewer renders shadows.
2025
-
2026
- Default:
2027
-
2028
- ```ts
2029
- true;
2030
- ```
2031
-
2032
- When `true`, the canvas renders soft shadows: the default light rig casts a shadow from a directional key light, furniture and decor meshes cast and receive shadows, and ambient occlusion is applied through post-processing. When `false`, shadow map rendering is disabled entirely on the canvas, so there is no shadow-pass cost (the per-mesh and light `castShadow`/`receiveShadow` flags are simply ignored).
2033
-
2034
- Example:
2035
-
2036
- ```tsx
2037
- <ModelViewer
2038
- modelUrl="/model.glb"
2039
- licenseKey="your-license-key"
2040
- objectBindings={objectBindings}
2041
- shadows={false}
2042
- />
2043
- ```
2044
-
2045
- > **Interior models (rooms, dollhouses):** a single large mesh usually forms the walls/ceiling enclosure. If that shell cast shadows it would seal the whole interior in darkness when lit from outside, so the viewer automatically detects the enclosure (a mesh spanning most of the scene footprint in both horizontal axes) and excludes it from casting while still letting it **receive** shadows. Furniture and decor then cast realistic contact shadows onto the floor. See [How Rendering Works](#how-rendering-works).
2046
-
2047
- ### `onCameraChange`
2048
-
2049
- Optional callback fired whenever the camera moves, with its plain state. It
2050
- fires often while the user orbits, pans, or zooms.
2051
-
2052
- ```ts
2053
- (state: ViewerCameraState) => void
2054
-
2055
- type ViewerCameraState = {
2056
- position: [number, number, number];
2057
- target: [number, number, number];
2058
- fov: number | null;
2059
- zoom: number;
2060
- azimuthAngle?: number; // radians, for setCameraState to restore
2061
- polarAngle?: number; // radians
2062
- };
2063
- ```
2064
-
2065
- It's the same state `useViewerCamera` exposes as `cameraState`, and
2066
- `setCameraState` restores it.
2067
-
2068
- ### `showObjectBindingDataPanel`
2069
-
2070
- Optional boolean that controls whether the built-in left object details panel is rendered.
2071
-
2072
- Default:
2073
-
2074
- ```ts
2075
- true;
2076
- ```
2077
-
2078
- ### `customObjectBindingDataPanel`
2079
-
2080
- Optional render prop for replacing the built-in left object details panel.
2081
-
2082
- Current prop shape:
2083
-
2084
- ```ts
2085
- type CustomObjectBindingDataPanelProps = {
2086
- isOpen: boolean;
2087
- selectedObject: ObjectBinding | null;
2088
- currentAction: ObjectActionEvent | null;
2089
- onClose: () => void;
2090
- onAction: (event: ObjectActionEvent) => void;
2091
- };
2092
- ```
2093
-
2094
- When provided, `ModelViewer` passes its existing internal handlers into your custom panel. Your panel can call them, wrap them, or ignore them.
2095
-
2096
- ### `overlay`
2097
-
2098
- Your own UI over the 3D view: badges, HUDs, buttons, custom panels. It sits
2099
- above the model and below the viewer's toolbars and banners.
2100
-
2101
- ```tsx
2102
- <ModelViewer
2103
- modelUrl="/sofa.glb"
2104
- licenseKey="your-license-key"
2105
- overlay={
2106
- <div style={{ position: "absolute", top: 16, left: 16 }}>
2107
- In stock <button onClick={addToCart}>Add to cart</button>
2108
- </div>
2109
- }
2110
- />
2111
- ```
2112
-
2113
- The layer covers the view but lets pointer events through, so the model stays
2114
- draggable around your elements. Its direct children receive pointer events, so
2115
- position them yourself (for example with `position: "absolute"`) rather than
2116
- wrapping everything in one full-size container.
2117
-
2118
- ### `unsafe_sceneChildren`
2119
-
2120
- react-three-fiber elements rendered inside the scene, for anything the viewer
2121
- can't do itself, such as custom geometry, a helper, or an effect driven by
2122
- `useFrame`:
2123
-
2124
- ```tsx
2125
- import { useFrame } from "@react-three/fiber";
2126
-
2127
- function Marker() {
2128
- const ref = useRef<Mesh>(null);
2129
- useFrame((_, delta) => (ref.current!.rotation.y += delta));
2130
- return (
2131
- <mesh ref={ref} position={[0, 1.5, 0]}>
2132
- <boxGeometry args={[0.3, 0.3, 0.3]} />
2133
- <meshStandardMaterial color="hotpink" />
2134
- </mesh>
2135
- );
2136
- }
2137
-
2138
- <ModelViewer {...props} unsafe_sceneChildren={<Marker />} />;
2139
- ```
2140
-
2141
- They're rendered inside their own `Suspense` boundary, so a child that loads
2142
- assets doesn't hold up the model. Because they work with three.js directly,
2143
- they're outside the viewer's own API: the name says so, and they can break when
2144
- three.js or react-three-fiber change. Prefer the props and hooks for anything
2145
- they cover.
2146
-
2147
- ### `customSceneObjectsPanel`
2148
-
2149
- Optional render prop for replacing the built-in right scene objects panel.
2150
-
2151
- Current prop shape:
2152
-
2153
- ```ts
2154
- type CustomSceneObjectsPanelProps = {
2155
- objectBindings: Record<string, ObjectBinding>;
2156
- onAction?: (event: ObjectActionEvent) => void;
2157
- onFocus?: (binding: ObjectBinding) => void;
2158
- onHover?: (binding: ObjectBinding | null) => void;
2159
- };
2160
- ```
2161
-
2162
- When provided, `ModelViewer` passes the current bindings plus its built-in action, focus, and hover handlers into your custom panel.
2163
-
2164
- ### `showSceneObjectsPanel`
2165
-
2166
- Optional boolean that controls whether the built-in right scene objects panel is rendered.
2167
-
2168
- Default:
2169
-
2170
- ```ts
2171
- true;
2172
- ```
2173
-
2174
- ### `showDownloadButton`
2175
-
2176
- Optional boolean that enables the download split-button (export GLB, export the
2177
- model's UV layout, and—when `preserveDrawingBuffer` is enabled—export a PNG
2178
- screenshot).
2179
-
2180
- Default:
2181
-
2182
- ```ts
2183
- true;
2184
- ```
2185
-
2186
- UV export downloads an editable 2048×2048 SVG UV-island outline when the model
2187
- uses one material. For multi-material models it downloads a ZIP containing one
2188
- SVG texture template per material. Meshes without a `uv` attribute are omitted;
2189
- when the model has no UV coordinates, the viewer reports that no layout is
2190
- available.
2191
-
2192
- The bottom-right action bar renders when at least one of `showResetButton`, `showDownloadButton`, `showFullscreenButton` (when supported), or (`showAnnotationNavigation` with annotations present) is `true`.
2193
-
2194
- ### `downloadFilename`
2195
-
2196
- Optional filename stem for the built-in model export button.
2197
-
2198
- Default:
2199
-
2200
- ```ts
2201
- "model";
2202
- ```
2203
-
2204
- ### `showResetButton`
2205
-
2206
- Optional boolean that shows the "reset camera view" button in the bottom-right action bar.
2207
-
2208
- Default:
2209
-
2210
- ```ts
2211
- true;
2212
- ```
2213
-
2214
- ### `showFullscreenButton`
2215
-
2216
- Optional boolean that adds an enter/exit fullscreen toggle to the bottom-right
2217
- action bar. Its grouped form is `ui.fullscreen`. Default: `false`.
2218
-
2219
- ```tsx
2220
- <ModelViewer
2221
- modelUrl="/model.glb"
2222
- licenseKey={licenseKey}
2223
- ui={{ fullscreen: true }}
2224
- />
2225
- ```
2226
-
2227
- Fullscreen expands the whole viewer, including its panels and overlays. The
2228
- button reflects browser exits such as Escape, and is hidden when fullscreen is
2229
- unavailable. It is temporarily disabled during video recording. Embedded viewers
2230
- need an iframe with `allow="fullscreen"` (or `allowFullScreen` in React). A rejected
2231
- request displays an error beside the button; see the
2232
- [Fullscreen API permissions](https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullscreen#security).
2233
-
2234
- ### `showLoadingOverlay`
2235
-
2236
- Optional boolean controlling whether the built-in loading overlay is shown while the model is loading and the initial camera fit is settling, and the load-error message if the model fails to load (see [`onLoadError`](#onloaderror)).
2237
-
2238
- Default:
2239
-
2240
- ```ts
2241
- true;
2242
- ```
2243
-
2244
- ### `showMouseController`
2245
-
2246
- Optional boolean that renders an on-screen joystick controller for moving the camera with a mouse or touch, useful on touch devices or kiosk layouts where drag-to-orbit is awkward.
2247
-
2248
- Default:
2249
-
2250
- ```ts
2251
- false;
2252
- ```
2253
-
2254
- ### `mouseControllerPosition`
2255
-
2256
- Optional placement for the on-screen controller.
2257
-
2258
- ```ts
2259
- type MouseControllerPosition =
2260
- | "bottom-left"
2261
- | "bottom-right"
2262
- | "top-left"
2263
- | "top-right"
2264
- | "center"
2265
- | "center-bottom"
2266
- | "center-top";
2267
- ```
2268
-
2269
- ### `mouseControllerOpacity`
2270
-
2271
- Optional opacity for the on-screen controller.
2272
-
2273
- Default:
2274
-
2275
- ```ts
2276
- 1;
2277
- ```
2278
-
2279
- ### `moveSensitivity`
2280
-
2281
- Optional movement sensitivity for the on-screen controller.
2282
-
2283
- Default:
2284
-
2285
- ```ts
2286
- 0.08;
2287
- ```
2288
-
2289
- ### `zoomSensitivity`
2290
-
2291
- Optional zoom sensitivity for the underlying `CameraControls` zoom interaction (mouse wheel / trackpad / pinch).
2292
-
2293
- Default:
2294
-
2295
- ```ts
2296
- 1.0;
2297
- ```
2298
-
2299
- Example:
2300
-
2301
- ```tsx
2302
- <ModelViewer
2303
- modelUrl="/model.glb"
2304
- licenseKey="your-license-key"
2305
- objectBindings={objectBindings}
2306
- showMouseController
2307
- mouseControllerPosition="bottom-right"
2308
- mouseControllerOpacity={0.8}
2309
- moveSensitivity={0.1}
2310
- zoomSensitivity={1.2}
2311
- />
2312
- ```
2313
-
2314
- ### `sceneConfig`
2315
-
2316
- Optional scene-wide configuration object (`SceneConfig`) covering model, camera, lighting, wireframe, shadows, environment, background, ground shadows, post-processing, animations, and annotations. It is the same shape authored by `BindingBuilder`'s Scene tab. If omitted, the viewer uses its built-in default scene config.
2317
-
2318
- `sceneConfig.animations` drives autoplay and per-clip playback settings, and `sceneConfig.annotations` seeds the annotation markers rendered on the model.
2319
-
2320
- `sceneConfig.model.renderer` accepts `"pbr"`, `"matcap"`, or `"uv-checker"`.
2321
- UV Checker temporarily replaces every mesh material with an unlit numbered test
2322
- chart without changing `objectBindings` or uploaded textures. Switching back
2323
- restores the original material references. Meshes without UV0 coordinates appear
2324
- magenta and trigger an explanatory notice.
2325
-
2326
- ```tsx
2327
- <ModelViewer
2328
- {...props}
2329
- sceneConfig={{
2330
- ...sceneConfig,
2331
- model: { ...sceneConfig.model, renderer: "uv-checker" },
2332
- }}
2333
- />
2334
- ```
2335
-
2336
- ### `onSceneConfigChange`
2337
-
2338
- Called with an updated `SceneConfig` when viewer-owned scene editing changes
2339
- the configuration. Currently this is used when a light-position or rotation
2340
- gizmo moves a scene-config light. Update controlled `sceneConfig` state with
2341
- the value returned by this callback.
2342
-
2343
- ```ts
2344
- onSceneConfigChange?: (config: SceneConfig) => void
2345
- ```
2346
-
2347
- ### `disableZoom`
2348
-
2349
- Optional boolean. When `true`, the viewer never zooms the camera to an object on selection (selection still highlights and fires callbacks).
2350
-
2351
- Default:
2352
-
2353
- ```ts
2354
- false;
2355
- ```
2356
-
2357
- ### `zoomOnSelected`
2358
-
2359
- Optional boolean controlling whether selecting an object zooms/fits the camera to it. Set to `false` to keep the current camera framing on selection. Zooming is also skipped when `disableZoom` is `true`.
2360
-
2361
- Default:
2362
-
2363
- ```ts
2364
- true;
2365
- ```
2366
-
2367
- ### `highlightOnHover`
2368
-
2369
- Controls hover highlighting for the canvas, built-in object list, and
2370
- `panelHoveredObject`. Default: `true`. On very large models, viewport hover is
2371
- disabled for performance, while panel-row highlighting remains available.
2372
-
2373
- ### Moving and rotating objects
2374
-
2375
- Set `moveModeEnabled` to show a centered Drei `PivotControls` gizmo for the
2376
- selected bound object. Translation arrows, plane handles, and rotation rings
2377
- are available together; scaling is not enabled. While object editing is on,
2378
- the camera controls are paused so pointer drags manipulate the object instead
2379
- of the camera.
2380
-
2381
- ```tsx
2382
- import { useState } from "react";
2383
- import {
2384
- ModelViewer,
2385
- type ObjectBinding,
2386
- } from "@liveroom-tech/react-immersive";
2387
-
2388
- export function EditableViewer({
2389
- initialBindings,
2390
- }: {
2391
- initialBindings: Record<string, ObjectBinding>;
2392
- }) {
2393
- const [objectBindings, setObjectBindings] = useState(initialBindings);
2394
-
2395
- return (
2396
- <ModelViewer
2397
- modelUrl="/model.glb"
2398
- licenseKey="your-license-key"
2399
- objectBindings={objectBindings}
2400
- onObjectBindingsChange={setObjectBindings}
2401
- moveModeEnabled
2402
- objectTransformSpace="world"
2403
- />
2404
- );
2405
- }
2406
- ```
2407
-
2408
- Click a bound mesh to select it, then drag an arrow to move on one axis, a
2409
- plane handle to move on two axes, or a ring to rotate. The pivot is placed at
2410
- the center of the selected object's renderable geometry, so rotation happens
2411
- around the object itself even when the source model's node origin is elsewhere.
2412
-
2413
- `objectTransformSpace` accepts:
2414
-
2415
- - `"world"` (default): the gizmo remains aligned with the scene axes
2416
- - `"local"`: the gizmo follows the selected object's current orientation
2417
-
2418
- Axis space changes the direction of the handles; it does not change the
2419
- object's position when toggled. The resulting `transform.position` and
2420
- `transform.rotation` values are always persisted in the object's local space,
2421
- with rotation stored in radians.
2422
-
2423
- Passing `onObjectBindingsChange` makes binding edits controlled, so the parent
2424
- must store the returned record as shown above. Without that callback,
2425
- `ModelViewer` keeps edits internally for the mounted viewer. Similarly, when
2426
- you pass `selectedObject`, update it from `onObjectSelect`; otherwise selection
2427
- is managed internally.
2428
-
2429
- ### `enableCameraControls`
2430
-
2431
- Optional boolean controlling orbit, pan, and zoom input. Default: `true`.
2432
- Camera controls are temporarily disabled whenever `moveModeEnabled` is on.
2433
-
2434
- ### `cameraControllerType` / `onCameraControllerChange`
2435
-
2436
- Selects the active camera interaction mode:
2437
-
2438
- - `"orbit"` (default) uses orbit, pan, and zoom controls.
2439
- - `"pointerLock"` captures the pointer for first-person look-around. Leaving
2440
- pointer lock returns the viewer to orbit mode.
2441
-
2442
- The viewer's camera-controller menu can manage this internally. Pass
2443
- `cameraControllerType` to control it from application state and update that
2444
- state from `onCameraControllerChange`.
2445
-
2446
- ```tsx
2447
- const [controller, setController] = useState<"orbit" | "pointerLock">("orbit");
2448
-
2449
- <ModelViewer
2450
- {...props}
2451
- cameraControllerType={controller}
2452
- onCameraControllerChange={setController}
2453
- />
2454
- ```
2455
-
2456
- Auto-rotation pauses while pointer-lock mode is active.
2457
-
2458
- ### `autoRotate` / `autoRotateSpeed`
2459
-
2460
- Enables automatic orbiting and controls its speed. Defaults are `false` and
2461
- `1`. When these props aren't passed, `sceneConfig.model.autoRotate` and
2462
- `sceneConfig.model.autoRotateSpeed` apply, so a scene exported from
2463
- `BindingBuilder` can carry the same behavior. When they are passed, they win.
2464
-
2465
- ```tsx
2466
- <ModelViewer {...props} autoRotate autoRotateSpeed={0.75} />
2467
- ```
2468
-
2469
- ### `enableKeyboardNavigation`
2470
-
2471
- Optional boolean enabling camera shortcuts after the viewer canvas is clicked
2472
- or focused. Default: `false`. Use `W`/`S` to move forward/back, `A`/`D` to
2473
- truck left/right, Space/`C` to move up/down, and the arrow keys to orbit.
2474
- `Shift` + Up/Down moves forward/back. Keyboard navigation is inactive while
2475
- object editing or camera controls are disabled.
2476
-
2477
- ### `showViewGizmo`
2478
-
2479
- Optional boolean showing a clickable orientation gizmo in the top-right of the
2480
- viewer. Default: `false`. It indicates the camera's view of the scene axes and
2481
- can snap the camera to an axis; it is separate from the selected object's
2482
- transform gizmo and is hidden while `moveModeEnabled` is on.
2483
-
2484
- ### `onAutoFit`
2485
-
2486
- Optional async callback fired once the model has loaded and the scene is ready. When provided, the viewer calls it so consumers can run their own fit-to-scene behavior (e.g. an animated fit); if omitted, the viewer falls back to its internal `fitScene`, unless an explicit [`camera`](#camera) prop was given, in which case that position is treated as the chosen initial view and `fitScene` is skipped.
2487
-
2488
- Current callback shape:
2489
-
2490
- ```ts
2491
- () => Promise<boolean>;
2492
- ```
2493
-
2494
- ### `refitOnResize`
2495
-
2496
- Optional boolean controlling whether the camera re-frames the model to fit whenever the canvas is resized, a browser window resize, a device rotation, or a side panel opening/closing (which changes how much width the canvas has). Set to `false` to preserve the user's current orbit/zoom across resizes; the camera aspect stays correct either way, so the model never distorts, it just isn't re-centered. This only affects re-fits _after_ the initial mount-time auto-fit.
2497
-
2498
- Default:
2499
-
2500
- ```ts
2501
- true;
2502
- ```
2503
-
2504
- ### `onAnnotationsChange`
2505
-
2506
- Optional callback fired when the annotation markers on the model change (added, edited, or removed through the viewer UI).
2507
-
2508
- Current callback shape:
2509
-
2510
- ```ts
2511
- (annotations: AnnotationMarker[]) => void
2512
- ```
2513
-
2514
- Where `AnnotationMarker` is the `SceneAnnotationMarker` shape:
2515
-
2516
- ```ts
2517
- type AnnotationMarker = {
2518
- id: number;
2519
- worldPosition: [number, number, number];
2520
- localPosition: [number, number, number];
2521
- title: string;
2522
- description: string;
2523
- };
2524
- ```
2525
-
2526
- ### `activeAnnotation` / `onActiveAnnotationChange`
2527
-
2528
- Optional controlled state for which annotation is currently open. Pass `activeAnnotation` to control it from your app, and `onActiveAnnotationChange` to be notified when the viewer wants to open (`AnnotationMarker`) or close (`null`) one. If `activeAnnotation` is left `undefined`, the viewer manages this state internally (uncontrolled).
2529
-
2530
- Current shapes:
2531
-
2532
- ```ts
2533
- activeAnnotation?: AnnotationMarker | null;
2534
- onActiveAnnotationChange?: (annotation: AnnotationMarker | null) => void;
2535
- ```
2536
-
2537
- ### `renderMode`
2538
-
2539
- Optional render loop mode. `"demand"` (default) only re-renders the canvas when something changes (camera move, state update, animation frame); `"always"` runs a continuous render loop.
2540
-
2541
- ### `maxDpr`
2542
-
2543
- Optional upper bound for the device pixel ratio used when rendering, so retina/4K displays don't render at full 2–3x cost.
2544
-
2545
- Default:
2546
-
2547
- ```ts
2548
- 2;
2549
- ```
2550
-
2551
- ### `preserveDrawingBuffer`
2552
-
2553
- Optional boolean that retains the WebGL framebuffer for PNG screenshots. It is
2554
- `false` by default to avoid imposing framebuffer-retention cost on every frame.
2555
- Enable it when using `captureImage` or the built-in Download PNG action.
2556
-
2557
- Default:
2558
-
2559
- ```ts
2560
- false;
2561
- ```
2562
-
2563
- ### `performanceProfile`
2564
-
2565
- Optional control over how aggressively the viewer trades visual fidelity for a stable WebGL context on constrained GPUs.
2566
-
2567
- ```ts
2568
- performanceProfile?: "auto" | "high" | "low";
2569
- ```
2570
-
2571
- - `"auto"` (default), applies a reduced profile on handheld/mobile browsers and other low-power touch devices: the postprocessing pipeline is skipped, soft shadows are disabled, and the device pixel ratio is capped. Desktop-class touch devices may still keep the higher-quality path when they advertise plenty of memory. This keeps mobile GPUs within their memory budget so the context isn't lost, which also keeps WebXR (`enableXR`) usable, since a lost context can't start a session.
2572
- - `"high"`, always render at full quality (postprocessing, soft shadows, full `maxDpr`), even on mobile. Use when you know the target devices can handle it.
2573
- - `"low"`, always apply the reduced profile, on any device.
2574
-
2575
- Default:
2576
-
2577
- ```ts
2578
- "auto";
2579
- ```
2580
-
2581
- If the WebGL context is lost, rendering pauses and the viewer displays a
2582
- **Reload viewer** button. This message appears even with
2583
- `ui={{ loadingOverlay: false }}`. When the browser fires `webglcontextrestored`,
2584
- the viewer automatically rebuilds its canvas and scene; the reload button starts
2585
- the same rebuild without waiting for browser restoration.
2586
-
2587
- Recovery uses the current props and cached model assets, cancels video recording,
2588
- and resets transient viewer state (camera, selection, measurements, and playback).
2589
- Keep configuration edits in controlled props to retain them across a rebuild.
2590
- `onSceneLoaded`, `onModelLoaded`, `onAnimationsReady`, and `onViewerReady` run again
2591
- for the rebuilt scene, so integrations receive fresh controls and object refs.
2592
-
2593
- ### `dracoDecoderPath` / `ktx2TranscoderPath` / `meshopt`
2594
-
2595
- Optional controls for the compressed-asset decoders used when loading the GLB/GLTF asset.
2596
-
2597
- ```ts
2598
- dracoDecoderPath?: string | false;
2599
- ktx2TranscoderPath?: string | false;
2600
- meshopt?: boolean;
2601
- ```
2602
-
2603
- Meshopt is bundled and enabled by default. DRACO and KTX2 are also enabled by
2604
- default through immutable, versioned decoder builds hosted on the first-party
2605
- `assets.react-immersive.liveroom.dev` domain. They are fetched lazily only when a model
2606
- uses the corresponding compression format.
2607
-
2608
- ```ts
2609
- dracoDecoderPath =
2610
- "https://assets.react-immersive.liveroom.dev/three-r184/draco/";
2611
- ktx2TranscoderPath =
2612
- "https://assets.react-immersive.liveroom.dev/three-r184/basis/";
2613
- ```
2614
-
2615
- Pass `false` to disable either decoder. For a fully self-hosted or offline
2616
- deployment, version-matched files are included under `dist/decoders`.
2617
-
2618
- Copy those files into your app's public/static directory during deployment:
2619
-
2620
- ```sh
2621
- cp -R node_modules/@liveroom-tech/react-immersive/dist/decoders public/react-immersive-decoders
2622
- ```
2623
-
2624
- Then pass the public URL directories (including the trailing slash):
2625
-
2626
- ```tsx
2627
- <ModelViewer
2628
- dracoDecoderPath="/react-immersive-decoders/draco/"
2629
- ktx2TranscoderPath="/react-immersive-decoders/basis/"
2630
- {...props}
2631
- />
2632
- ```
2633
-
2634
- The same props are available on `SimpleModelViewer` and `BindingBuilder`. When
2635
- using the built-in defaults with a strict CSP, allow the first-party asset
2636
- origin and decoder workers; a typical baseline is
2637
- `connect-src 'self' https://assets.react-immersive.liveroom.dev; worker-src 'self' blob:; script-src 'self' 'wasm-unsafe-eval'`.
2638
- Self-hosted paths only require `'self'`. Older browsers may require their
2639
- WebAssembly fallback policy as well.
2640
-
2641
- ### `showUvCheckerButton`
2642
-
2643
- Optional boolean that shows a UV Checker toggle button over the canvas. Turning it on temporarily replaces the model's materials with the numbered diagnostic texture; turning it off restores the renderer configured by `sceneConfig`. Missing UV0 coordinates are shown in magenta.
2644
-
2645
- ```tsx
2646
- <ModelViewer showUvCheckerButton {...props} />
2647
- ```
2648
-
2649
- Default:
2650
-
2651
- ```ts
2652
- false;
2653
- ```
2654
-
2655
- ### `showMeasureTools`
2656
-
2657
- Optional boolean that shows measurement tools and a toggleable bounding-box
2658
- dimensions overlay. Start measuring, then choose a tool:
2659
-
2660
- - **Distance:** pick points for distances between consecutive picks.
2661
- - **Angle:** pick an arm, the angle's vertex, and the other arm. The readout is
2662
- in degrees, with an arc around the middle pick.
2663
- - **Area:** pick polygon corners in boundary order, then **Finish area**. The
2664
- closed polygon is shaded and labeled in square units. Concave polygons are
2665
- supported; nonplanar, crossing, touching, duplicate, or collinear boundaries
2666
- show an error. Use Undo to correct a pick.
2667
- - **Point to plane:** pick a reference face, then a point. The tool highlights
2668
- the picked triangle and shows the shortest distance to its infinite plane,
2669
- with a perpendicular segment to the projected point.
2670
-
2671
- **No snapping** keeps picks on the surface. **Snap: vertex**, **Snap: edge**,
2672
- and **Snap: auto** snap within 12 CSS pixels to vertices or triangle edges on
2673
- the picked face. Auto prioritizes nearby vertices. Hover markers identify the
2674
- snap target; snapped picks are yellow. Snapping respects world transforms,
2675
- instances, and the current pose of skinned/morph geometry. Mesh triangulation
2676
- edges can also be snap targets.
2677
-
2678
- Undo removes the last pick; Clear removes the current measurement. Switching
2679
- tools clears picks. A new pick after a completed angle, area, or point-to-plane
2680
- measurement starts another measurement. Picks are snapshots in world space;
2681
- model changes, display rotation, and binding transforms clear them. Pause
2682
- animated models before measuring a pose. Hidden objects, decals, and editor
2683
- helpers are excluded from picking.
2684
-
2685
- Default:
2686
-
2687
- ```ts
2688
- false;
2689
- ```
2690
-
2691
- ### `measurementUnit`
2692
-
2693
- Optional unit suffix appended to distance and dimension readouts; area uses its
2694
- squared form (for example `m²`). Angles always use degrees. glTF models are
2695
- authored in meters by spec, so values are not converted; this only changes the
2696
- displayed label.
2697
-
2698
- Default:
2699
-
2700
- ```ts
2701
- "m";
2702
- ```
2703
-
2704
- ### `showExplodeControls`
2705
-
2706
- Optional boolean that shows an exploded-view slider over the canvas. It slides each bound part outward from the model center to reveal interior/assembly structure, then back to reassemble. Best suited to static product/CAD models, the offset writes node positions each frame, so it conflicts with a playing skeletal animation.
2707
-
2708
- Default:
2709
-
2710
- ```ts
2711
- false;
2712
- ```
2713
-
2714
- ### `showMaterialVariants`
2715
-
2716
- Shows a row of buttons, centered at the bottom of the viewer, for switching
2717
- between the model's glTF material variants (the `KHR_materials_variants`
2718
- extension): the colorways, finishes, or trims a product file ships with. It
2719
- appears only for a glTF/GLB with more than one variant. Default `true`.
2720
-
2721
- Picking a variant sets `sceneConfig.model.materialVariant`, which is also how
2722
- you choose one yourself:
2723
-
2724
- ```tsx
2725
- const viewer = useViewer();
2726
-
2727
- <ModelViewer modelUrl="/shoe.glb" licenseKey="your-license-key" {...viewer.props} />;
2728
-
2729
- // The model's variant names, once it has loaded
2730
- viewer.model.materialVariants; // ["midnight", "beach", "street"]
2731
-
2732
- viewer.scene.updateSceneConfig({ model: { materialVariant: "beach" } });
2733
- viewer.scene.updateSceneConfig({ model: { materialVariant: null } }); // the defaults
2734
- ```
2735
-
2736
- - A variant sets each object's starting material. `objectBindings` material
2737
- overrides (`style.material`) still apply on top of it, and clearing an
2738
- override returns to the variant's material rather than the file's default.
2739
- - Objects the variant doesn't map keep their default material, bound or not.
2740
- - A variant's materials and textures load the first time it's chosen; the
2741
- current look stays until they're ready.
2742
- - With `onSceneConfigChange`, a pick goes to your scene config (`useViewer`
2743
- wires this up). Without it, `ModelViewer` keeps the pick itself until
2744
- `sceneConfig.model.materialVariant` or `modelUrl` changes.
2745
- - A name the model doesn't have shows the defaults and logs a console warning
2746
- listing the model's variants.
2747
- - An action can switch variants with a scene-config effect:
2748
- `{ sceneConfig: { model: { materialVariant: "beach" } } }`.
2749
- - `onModelLoaded` reports the names as `materialVariants`, and BindingBuilder's
2750
- Scene tab (**General → Material variant**) picks the one the exported scene
2751
- config starts with. OBJ, FBX, USDZ, and streamed 3D Tiles models have no
2752
- variants.
2753
-
2754
- ### Decals
2755
-
2756
- `binding.decals` prints images and text onto an object's surface: a logo on a
2757
- shirt, a name on a mug, a label on a machine. Each decal is projected onto the
2758
- object and follows it as it moves, and it's saved with the binding like any
2759
- other edit.
2760
-
2761
- ```tsx
2762
- const viewer = useViewer();
2763
-
2764
- <ModelViewer
2765
- modelUrl="/mug.glb"
2766
- licenseKey="your-license-key"
2767
- {...viewer.props}
2768
- // Put the customer's text where they double-click.
2769
- onObjectDoubleClick={({ binding, surface }) => {
2770
- if (!surface) return;
2771
- viewer.bindings.addDecal(binding.id, {
2772
- text: customerName,
2773
- color: "#1e293b",
2774
- ...surface, // position and normal, in the object's own space
2775
- size: 0.06, // width in model units
2776
- });
2777
- return true; // skip the viewer's own double-click behavior
2778
- }}
2779
- />;
2780
-
2781
- const id = viewer.bindings.addDecal("mug", { image: "/logos/acme.png", position, normal, size: 0.05 });
2782
- viewer.bindings.updateDecal("mug", id, { size: 0.08, rotation: Math.PI / 12 });
2783
- viewer.bindings.removeDecal("mug", id);
2784
- ```
2785
-
2786
- ```ts
2787
- type ObjectBindingDecal = {
2788
- id: string;
2789
- image?: string; // a URL or public path
2790
- text?: string; // shown when there's no image
2791
- color?: string; // text colour, default "#ffffff"
2792
- fontFamily?: string; // CSS font family, default "sans-serif"
2793
- fontWeight?: "normal" | "bold"; // default "bold"
2794
- position: [number, number, number]; // on the object, in its own space
2795
- normal: [number, number, number]; // the way the surface faces there
2796
- size: number; // width in model units; the height follows the image or text
2797
- rotation?: number; // radians around the normal, default 0
2798
- opacity?: number; // 0–1, default 1
2799
- };
2800
- ```
2801
-
2802
- - `onObjectDoubleClick` and `onObjectContextMenu` report `surface`: the point
2803
- under the pointer and the way the surface faces, in the object's own space,
2804
- which is exactly what a decal's `position` and `normal` take.
2805
- - `addDecal` returns the decal's id (pass your own `id` to choose it), and
2806
- takes the same targets as the other binding helpers, so
2807
- `addDecal({ group: "panels" }, …)` prints on each. Decals are plain binding
2808
- data: you can also set `decals` directly.
2809
- - A decal wraps onto the surface around its position, reaching about half
2810
- its size in depth, so it follows gentle curves without printing on the far
2811
- side of a thin part.
2812
- - A decal fades with its object when that object is ghosted by isolation or
2813
- made see-through by a style rule, and is cut by a section cut.
2814
- - To let the people using your viewer add their own, give a binding the
2815
- built-in `add-text` and `add-image` actions:
2816
-
2817
- ```ts
2818
- actions: [
2819
- { id: "add-text", label: "Add Text", type: "command" },
2820
- { id: "add-image", label: "Add Image", type: "command" },
2821
- ]
2822
- ```
2823
-
2824
- Each opens a control under its button in the object panel. **Add Text**
2825
- takes the text and a colour; **Add Image** takes an image file (sent through
2826
- `onTextureUpload` when you pass it, so the saved URL lasts; otherwise a
2827
- blob URL for this session). The decal appears automatically at the centre
2828
- of the camera-facing surface, ready to drag, resize, turn, or remove. **Move** enables dragging across
2829
- the object's surface; release to save, or press Escape to cancel. The
2830
- **Position** arrows move a decal in small steps relative to the current
2831
- view, without needing to grab it. Click for a fine adjustment or hold an
2832
- arrow for continuous movement. Each step stays on the nearby visible surface.
2833
- Every change is saved to the
2834
- binding's `decals` and reported through `onObjectBindingsChange`. While a
2835
- decal is in Move mode, a hint shows over the viewer and Escape cancels
2836
- the current drag without removing the centred decal.
2837
- - On a rigged (skinned) mesh a decal bends with the animation: it takes on
2838
- the bone weights of the surface under it and is driven by the same skeleton.
2839
- A click on a posed mesh is stored at the matching point of its rest shape, so
2840
- a decal lands where you clicked whatever pose the model is in. Over a joint
2841
- that bends sharply across few polygons, the decal's outer edge can sit a
2842
- hair off the surface. Decals don't follow morph targets (blend shapes).
2843
- - Decals need the binding's object to be a mesh, and aren't drawn on streamed
2844
- 3D Tiles models.
2845
-
2846
- ### Isolating objects
2847
-
2848
- `isolation` focuses the view on some objects: everything else is ghosted
2849
- (drawn faintly) or hidden, and clicks and hovers pass through to what's
2850
- isolated. Nothing about the bindings changes, and clearing the isolation puts
2851
- everything back. It's view state, like the selection, so it isn't part of
2852
- `sceneConfig`.
2853
-
2854
- ```tsx
2855
- const viewer = useViewer();
2856
-
2857
- <ModelViewer
2858
- modelUrl="/engine.glb"
2859
- licenseKey="your-license-key"
2860
- {...viewer.props}
2861
- tools={{ isolate: true }}
2862
- />;
2863
-
2864
- viewer.isolation.isolate({ group: "gearbox" }); // ghost everything else
2865
- viewer.isolation.isolate(["piston-1", "piston-2"], { mode: "hide" });
2866
- viewer.isolation.clearIsolation();
2867
- ```
2868
-
2869
- ```ts
2870
- type ViewerIsolation = {
2871
- target: ObjectBindingTarget; // an id, a list of ids, { group }, { tag }, or { type }
2872
- mode?: "ghost" | "hide"; // default "ghost"
2873
- ghostOpacity?: number; // 0–1, default 0.12
2874
- };
2875
-
2876
- isolation?: ViewerIsolation | null;
2877
- onIsolationChange?: (isolation: ViewerIsolation | null) => void;
2878
- showIsolateControls?: boolean; // tools.isolate
2879
- ```
2880
-
2881
- - Pass `isolation` (including `null`) to control it, and update it from
2882
- `onIsolationChange`; `useViewer` wires both, as `viewer.isolation`. Leave
2883
- `isolation` out and `ModelViewer` keeps it itself, clearing it when
2884
- `modelUrl` changes. `useViewerIsolation` is the same state on its own.
2885
- - `showIsolateControls` (`tools.isolate`, default `false`) adds an isolate
2886
- button to each row of the scene objects panel (click again to show all) and
2887
- a "Show all" pill at the bottom of the viewer while anything is isolated.
2888
- - An action can isolate with an `isolation` effect:
2889
- `{ isolation: { target: { group: "engine" } } }`, or `{ isolation: null }`
2890
- to show everything again. Pass `isolation` to `useViewerActions` for it
2891
- (`useViewer` does).
2892
- - A target that matches no object isolates nothing, rather than fading out
2893
- the whole model. Ghosting never raises an object's own lower opacity, and
2894
- style rules still apply underneath.
2895
- - `applyIsolation` (main entry and `/utils`) applies an isolation to bindings
2896
- the same way, for rendering your own lists.
2897
-
2898
- ### `showSectionTools`
2899
-
2900
- Shows a section-cut button over the canvas (`tools.section`). It cuts the model
2901
- open along an axis, hiding everything on one side of a plane, to look inside
2902
- assemblies, equipment, and buildings. Default `false`.
2903
-
2904
- With the cut on, the toolbar picks the axis (X, Y, or Z), the position along
2905
- it, and which side stays, and a plane appears across the model that you can
2906
- drag. The cut is stored in `sceneConfig.section`, so you can also set it
2907
- yourself, author it in BindingBuilder, or switch it from an action:
2908
-
2909
- ```tsx
2910
- viewer.scene.updateSceneConfig({
2911
- section: { enabled: true, axis: "y", position: 0.4, flip: false }, // a floor-plan cut
2912
- });
2913
- ```
2914
-
2915
- ```ts
2916
- type SceneSectionConfig = {
2917
- enabled: boolean;
2918
- axis: "x" | "y" | "z"; // world axis the cut runs across
2919
- position: number; // 0 at the model's minimum along the axis, 1 at its maximum
2920
- flip: boolean; // keep the higher side instead of the lower one
2921
- };
2922
- ```
2923
-
2924
- - The cut applies to the model only; lights, helpers, and gizmos stay whole.
2925
- It also shows without the toolbar whenever `sceneConfig.section.enabled` is
2926
- set; the draggable plane appears only with `showSectionTools`.
2927
- - While the cut is on, the model's materials render both sides of each
2928
- surface, so a cut part shows its inside surfaces instead of disappearing.
2929
- There are no solid caps over the cut.
2930
- - Clicking and hovering ignore whatever is cut away, so the parts you can see
2931
- behind the cut are the ones you select.
2932
- - Toolbar changes go to `onSceneConfigChange` when you pass it (`useViewer`
2933
- does); otherwise `ModelViewer` keeps them until `sceneConfig.section` or
2934
- `modelUrl` changes.
2935
- - The measuring tool can still pick points on the hidden side of a cut.
2936
-
2937
- Default:
2938
-
2939
- ```ts
2940
- false;
2941
- ```
2942
-
2943
- ### `cinematic`
2944
-
2945
- Optional cinematic auto-camera. The camera glides along a path on its own, like a film, ideal for showing off a gallery, apartment, or product with no user interaction. Renders a play/pause button over the canvas; grabbing the camera (or selecting a part) pauses it.
2946
-
2947
- ```ts
2948
- cinematic?: boolean | CinematicConfig;
2949
-
2950
- type CinematicConfig = {
2951
- waypoints?: CinematicWaypoint[]; // camera keyframes to glide through
2952
- duration?: number; // seconds for one full pass (auto-scales when omitted)
2953
- loop?: boolean; // default true
2954
- autoPlay?: boolean; // start once the model has loaded and framed (default false)
2955
- };
2956
-
2957
- type CinematicWaypoint = {
2958
- position: [number, number, number];
2959
- target: [number, number, number]; // world-space look-at point
2960
- };
2961
- ```
2962
-
2963
- - Boolean `true` (or an object with fewer than two waypoints) gives a zero-config **showcase orbit** around the model's bounding sphere.
2964
- - Two or more `waypoints` author a **walkthrough**: the camera follows a smooth Catmull-Rom spline through them at a constant on-screen speed, looping seamlessly.
2965
- - Waypoints are easiest to capture visually in `BindingBuilder`'s **Cinematic** tab, which stores them on `sceneConfig.cinematic`.
2966
-
2967
- A path can also come from `sceneConfig.cinematic`. The `cinematic` prop overrides it: a boolean toggles the feature (`true` keeps any authored waypoints, `false` forces it off), and an object overrides field-by-field, so you can keep the authored waypoints while overriding, say, `autoPlay` or `loop`.
2968
-
2969
- ```tsx
2970
- // Zero-config showcase orbit
2971
- <ModelViewer cinematic ... />
2972
-
2973
- // Authored walkthrough
2974
- <ModelViewer
2975
- cinematic={{
2976
- waypoints: [
2977
- { position: [4, 2, 6], target: [0, 1, 0] },
2978
- { position: [-3, 2, 4], target: [0, 1, 0] },
2979
- { position: [-5, 2, -2], target: [0, 1, 0] },
2980
- ],
2981
- loop: true,
2982
- autoPlay: true,
2983
- }}
2984
- ...
2985
- />
2986
-
2987
- // Keep the BindingBuilder-authored path, just autoplay it
2988
- <ModelViewer sceneConfig={sceneConfig} cinematic={{ autoPlay: true }} ... />
2989
- ```
2990
-
2991
- Default: disabled.
2992
-
2993
- ### `enableXR`
2994
-
2995
- Optional boolean that enables XR entry points. On WebXR-capable browsers, the viewer shows a **"View in your space"** (AR) and/or **"Enter VR"** button once `navigator.xr.isSessionSupported(...)` resolves `true` for that mode. On iPhone/iPad, WebXR AR is not available, but if you also pass [`usdzUrl`](#usdzUrl), the viewer shows a **"View in AR"** button that launches Apple Quick Look instead.
2996
-
2997
- On entering a session the model is rested on the floor a short distance in front
2998
- of the viewer. By default it is normalized to ~1 m on its longest axis so
2999
- arbitrary uploads and room scenes are framed safely. Set
3000
- [`arScaleMode`](#arscalemode) to `"real-world"` for product AR, which preserves
3001
- the GLB's authored metre scale.
3002
-
3003
- **AR placement gestures**, inside an AR session the viewer now uses an explicit placement flow:
3004
-
3005
- - before placement, a bottom label says **"Move your device over a flat surface"** until a hit-testable surface is found
3006
- - once a surface is found, a reticle appears on it and the label changes to **"Tap to place"**
3007
- - tapping the screen or the label places the model at the reticle
3008
- - after placement, **pinch** (two fingers) resizes the model and **twist** rotates it around its vertical axis without changing its position
3009
- - a bottom **"Relocate"** button lets the user press-and-hold to bring the reticle back; releasing the button places the model at the current reticle position
3010
-
3011
- VR sessions keep the initial framed placement (there are no real surfaces to hit-test against).
3012
-
3013
- > Postprocessing is automatically disabled during an XR session (the effect composer isn't WebXR-aware). Note also that on low-power devices the default [`performanceProfile`](#performanceprofile) of `"auto"` already disables postprocessing and soft shadows, important for keeping the WebGL context alive so AR can start at all.
3014
-
3015
- Default:
3016
-
3017
- ```ts
3018
- false;
3019
- ```
3020
-
3021
- ### `usdzUrl`
3022
-
3023
- Optional `USDZ` URL used as an Apple-device fallback when `enableXR` is `true`.
3024
- On iPhone/iPad, if WebXR AR is unavailable and this prop is provided, the viewer
3025
- shows a **"View in AR"** button that launches Apple Quick Look for the given
3026
- asset.
3027
-
3028
- ```ts
3029
- usdzUrl?: string;
3030
- ```
3031
-
3032
- Notes:
3033
-
3034
- - this should point to a `.usdz` file that Safari can fetch directly
3035
- - Android / WebXR-capable devices ignore this and continue using the normal WebXR AR flow
3036
- - if `usdzUrl` is omitted, Apple handheld devices simply won't get an AR button
3037
-
3038
- ### `arScaleMode`
3039
-
3040
- Controls the initial model size inside WebXR AR and VR sessions.
3041
-
3042
- ```ts
3043
- arScaleMode?: "normalized" | "real-world";
3044
- ```
3045
-
3046
- - `"normalized"` (default) fits the longest model dimension to approximately
3047
- 1 metre. Use this for arbitrary uploads and room-scale scenes.
3048
- - `"real-world"` preserves the GLB's authored scale. glTF units are metres, so
3049
- use this for product models exported at their real dimensions.
3050
-
3051
- Users can still pinch to resize after placement in either mode.
3052
-
3053
- ### `showAnnotationNavigation`
3054
-
3055
- Optional boolean that shows the "Guided Tour" control cluster when the model has at least one annotation: a single "Guided Tour" button that, once started, becomes Previous/Stop/Next controls for stepping through annotations in order.
3056
-
3057
- Default:
3058
-
3059
- ```ts
3060
- true;
3061
- ```
3062
-
3063
- ### `showAnnotationOnHover`
3064
-
3065
- Optional boolean that temporarily opens an annotation's detail popup when the
3066
- pointer hovers over its marker. Moving the pointer away closes the hover popup
3067
- after a short grace period. Clicking a marker still locks its popup open until
3068
- it is closed.
3069
-
3070
- Default:
3071
-
3072
- ```ts
3073
- false;
3074
- ```
3075
-
3076
- ```tsx
3077
- <ModelViewer {...props} showAnnotationOnHover />
3078
- ```
3079
-
3080
- ### Theming the scene objects / object binding panels
3081
-
3082
- The scene objects panel and object binding data panel read their colors,
3083
- borders, shadows, and fonts from CSS custom properties (`--ri-sidepanel-*`
3084
- and `--ri-databinding-*`) instead of hardcoded values, each with the current
3085
- look baked in as a fallback. Override them on a `.ri-viewer` ancestor to
3086
- re-skin those panels:
3087
-
3088
- ```css
3089
- .my-app .ri-viewer {
3090
- --ri-sidepanel-bg: #1a0033;
3091
- --ri-sidepanel-accent: #ff2d75;
3092
- }
3093
- ```
3094
-
3095
- See the full variable list in the [`ModelViewer` docs](https://react-immersive.liveroom.dev/docs/reference/model-viewer#theming).
3096
-
3097
- ## `SimpleModelViewer` Public API
3098
-
3099
- ```ts
3100
- type SimpleModelViewerProps = {
3101
- modelUrl: string;
3102
- modelFormat?: "glb" | "gltf" | "obj" | "fbx" | "usdz";
3103
- dracoDecoderPath?: string | false;
3104
- ktx2TranscoderPath?: string | false;
3105
- meshopt?: boolean;
3106
- backgroundColor?: string;
3107
- showSceneObjectsPanel?: boolean;
3108
- showSceneSettingsPanel?: boolean;
3109
- enableModelUpload?: boolean;
3110
- zoomOnSelected?: boolean;
3111
- highlightOnHover?: boolean;
3112
- showLoadingOverlay?: boolean;
3113
- refitOnResize?: boolean;
3114
- // Initial values for the scene settings (environment) panel
3115
- backgroundEnabled?: boolean;
3116
- autoRotate?: boolean;
3117
- envPreset?: PresetsType; // @react-three/drei environment preset
3118
- exposure?: number;
3119
- ambientIntensity?: number;
3120
- ambientColor?: string;
3121
- directionalIntensity?: number;
3122
- directionalColor?: string;
3123
- onModelLoaded?: (model: ViewerModelInfo) => void;
3124
- onLoadError?: (error: unknown) => void;
3125
- };
3126
- ```
3127
-
3128
- `SimpleModelViewer` does not take a `licenseKey`, licensing is enforced by `ModelViewer` and `BindingBuilder` only.
3129
-
3130
- ### `modelUrl`
3131
-
3132
- URL or public path to the `.glb`, `.gltf`, `.obj`, `.fbx`, or `.usdz` model to inspect. Hosted assets must serve external dependencies at their declared relative paths; USDZ dependencies are packaged internally. Use `modelFormat` when a signed or extensionless URL cannot be auto-detected.
3133
-
3134
- ### `modelFormat`
3135
-
3136
- Optional explicit format for signed or extensionless model URLs. Normal URLs
3137
- ending in a supported extension are detected automatically.
3138
-
3139
- ### `backgroundColor`
3140
-
3141
- Optional canvas background color.
3142
-
3143
- Default:
3144
-
3145
- ```ts
3146
- "#1a1a1a";
3147
- ```
3148
-
3149
- ### `showSceneObjectsPanel`
3150
-
3151
- Optional boolean that controls whether the right-side scene objects panel is rendered.
3152
-
3153
- Default:
3154
-
3155
- ```ts
3156
- true;
3157
- ```
3158
-
3159
- ### `showSceneSettingsPanel`
3160
-
3161
- Optional boolean that controls whether the left-side environment/scene settings panel is rendered. It exposes background color/visibility, the `@react-three/drei` environment preset, auto-rotate, exposure, and ambient/directional light color and intensity.
3162
-
3163
- Default:
3164
-
3165
- ```ts
3166
- true;
3167
- ```
3168
-
3169
- ### Scene settings defaults
3170
-
3171
- The following optional props seed the initial values of the scene settings (environment) panel. Each maps to one control, and the panel stays interactive so the user can still adjust them at runtime. They are initial values (not controlled props): changing one after mount does not override a value the user has since changed in the panel, the exception is `backgroundColor`, which stays in sync live.
3172
-
3173
- | Prop | Type | Panel control | Default |
3174
- | ---------------------- | ------------- | ----------------------- | ----------- |
3175
- | `backgroundEnabled` | `boolean` | Background on/off | `false` |
3176
- | `autoRotate` | `boolean` | Auto Rotate | `false` |
3177
- | `envPreset` | `PresetsType` | Environment preset | `"city"` |
3178
- | `exposure` | `number` | Exposure | `1` |
3179
- | `ambientIntensity` | `number` | Ambient Light Intensity | `0.6` |
3180
- | `ambientColor` | `string` | Ambient Light Color | `"#ffffff"` |
3181
- | `directionalIntensity` | `number` | Direct Light Intensity | `1.2` |
3182
- | `directionalColor` | `string` | Direct Light Color | `"#ffffff"` |
3183
-
3184
- `envPreset` accepts any `@react-three/drei` `PresetsType` (for example `"city"`, `"sunset"`, `"dawn"`, `"night"`, `"warehouse"`, `"forest"`, `"apartment"`, `"studio"`, `"park"`, `"lobby"`).
3185
-
3186
- ```tsx
3187
- <SimpleModelViewer
3188
- modelUrl="/model.glb"
3189
- backgroundEnabled
3190
- envPreset="sunset"
3191
- exposure={1.2}
3192
- ambientIntensity={0.4}
3193
- directionalColor="#fff4e0"
3194
- autoRotate
3195
- />
3196
- ```
3197
-
3198
- ### `zoomOnSelected`
3199
-
3200
- Optional boolean. When `true`, selecting a mesh (via click or the objects panel) zooms/frames the camera on it.
3201
-
3202
- Default:
3203
-
3204
- ```ts
3205
- false;
3206
- ```
3207
-
3208
- ### `highlightOnHover`
3209
-
3210
- Optional boolean. When `true`, hovering a mesh (in the viewport or the objects panel) highlights it.
3211
-
3212
- Default:
3213
-
3214
- ```ts
3215
- false;
3216
- ```
3217
-
3218
- ### `showLoadingOverlay`
3219
-
3220
- Optional boolean controlling whether the built-in loading overlay is shown while the model is loading, uploaded files are being prepared, and the initial camera fit is settling.
3221
-
3222
- Default:
3223
-
3224
- ```ts
3225
- true;
3226
- ```
3227
-
3228
- ### `refitOnResize`
3229
-
3230
- Optional boolean controlling whether the camera re-frames the model to fit whenever the canvas is resized, a browser window resize, a device rotation, or a side panel (scene settings / scene objects) opening or closing. Set to `false` to preserve the user's current orbit/zoom across resizes; the camera aspect stays correct either way, so the model never distorts, it just isn't re-centered.
3231
-
3232
- Default:
3233
-
3234
- ```ts
3235
- true;
3236
- ```
3237
-
3238
- ### `enableModelUpload`
3239
-
3240
- Optional boolean that swaps the fixed `modelUrl` workflow for a built-in upload UI. It accepts `.glb`, standalone/data-URI `.gltf`, `.obj`, `.fbx`, `.usdz`, or a `.zip` bundle. ZIP bundles may contain a GLTF with its buffers/textures, an OBJ with its optional MTL/textures, or an FBX with external textures. A USDZ file is already a self-contained package and is uploaded directly.
3241
-
3242
- Default:
3243
-
3244
- ```ts
3245
- false;
3246
- ```
3247
-
3248
- ### `onModelLoaded`
3249
-
3250
- Optional callback fired after the model has loaded, with its bounds and mesh
3251
- count (`(model: ViewerModelInfo) => void`, the same payload as `ModelViewer`'s).
3252
-
3253
- ### `onLoadError`
3254
-
3255
- Optional callback fired if the model fails to load or render.
3256
-
3257
- ## Object Binding Shape
3258
-
3259
- The current source defines these binding types internally:
3260
-
3261
- ```ts
3262
- type ObjectBindingAction = {
3263
- id: string;
3264
- label: string;
3265
- type: "command";
3266
- };
3267
-
3268
- type ObjectBindingCameraState = {
3269
- position?: [number, number, number];
3270
- target?: [number, number, number];
3271
- fov?: number;
3272
- zoom?: number;
3273
- };
3274
-
3275
- type ObjectBindingMaterial = {
3276
- // exported by the package; includes texture/baseColor plus the supported
3277
- // MeshPhysicalMaterial overrides used by the viewer and BindingBuilder
3278
- };
3279
-
3280
- type ObjectBindingStyle = {
3281
- material?: ObjectBindingMaterial;
3282
- };
3283
-
3284
- type ObjectBindingTransform = {
3285
- position?: [number, number, number];
3286
- rotation?: [number, number, number]; // radians
3287
- scale?: [number, number, number];
3288
- };
3289
-
3290
- type ObjectBinding = {
3291
- id: string;
3292
- type?: ObjectBindingType; // any string; suggestions: "body" | "light" | "wheel" | "wall" | "door" | "furniture" | ...; default "other"
3293
- modelObjectId: string;
3294
- label?: string;
3295
- group?: string;
3296
- tags?: string[];
3297
- visible?: boolean;
3298
- selectable?: boolean;
3299
- hoverable?: boolean;
3300
- transform?: ObjectBindingTransform;
3301
- style?: ObjectBindingStyle;
3302
- decals?: ObjectBindingDecal[];
3303
- actions?: ObjectBindingAction[];
3304
- metrics?: Record<string, number>;
3305
- metadata?: Record<string, unknown>;
3306
- cameraState?: ObjectBindingCameraState;
3307
- };
3308
- ```
3309
-
3310
- Notes:
3311
-
3312
- - the `objectBindings` record is keyed by node name, not by `id`
3313
- - `group` and `tags` can be assigned in `BindingBuilder` and used as targets by binding helpers and runtime material or transform effects
3314
- - `visible` is live render state, not just an initial default
3315
- - `transform` is persistent local-space render state; position values use model units and rotation values use radians
3316
- - the transform gizmo is displayed at the center of the object's renderable geometry for intuitive rotation, even if the authored node origin is elsewhere; this does not rewrite the GLB/GLTF origin
3317
- - missing transform fields retain their model-authored values, and removing `transform` restores the authored transform
3318
- - `style.material.baseColor` is read by the renderer and is the committed source of truth for color picks
3319
- - `style.material.texture.path` is read by the renderer and is the committed source of truth for texture uploads (stored as durable URLs via `onTextureUpload` when provided, or session-scoped blob URLs otherwise)
3320
- - if no `texture.path` is provided and no `style.material.baseColor` is set, the viewer falls back to the node's original GLB/GLTF material
3321
- - supported `style.material` fields are applied as per-object `MeshPhysicalMaterial` overrides, including metalness, roughness, emissive, opacity, alpha masking, normal/bump, AO, displacement, clearcoat, sheen, anisotropy, specular, transmission, thickness, attenuation tint/distance, reflectivity, and side selection
3322
- - each `style.material` group also accepts a texture-map slot (`metalnessMap`, `roughnessMap`, `normalMap`, `aoMap`, `clearcoatMap`, etc.); color maps are decoded as sRGB and data maps as linear automatically
3323
- - `BindingBuilder` intentionally omits exact Sketchfab glossiness, cavity, and subsurface-scattering workflows; those require preprocessing or a different material pipeline
3324
- - `cameraState` stores a saved camera view for the object; when both `position` and `target` are set, the viewer uses that view when the object is focused or selected instead of falling back to `fitToBox`
3325
- - `metrics` and `metadata` are displayed in the side panel as nested key/value fields (objects expand into indented child labels)
3326
- - `type` groups and filters bindings (for example `hideObject({ type: "wheel" })`). Any string works: `ObjectBindingType` suggests values for vehicles, rooms, furniture, characters, weapons, environment, and more, but a domain it doesn't cover can use its own (`"bone"`, `"turbine-blade"`). Left out, it counts as `"other"`
3327
-
3328
- ## Supported Built-In Actions
3329
-
3330
- `ModelViewer` handles eight action ids itself: `change-color`,
3331
- `change-material`, `add-text`, `add-image`, `toggle-visibility`,
3332
- `toggle-light`, `change-light-color`, and `set-brightness`. Any other id does something only when you handle it in
3333
- `onAction` (pass `useViewerActions().handleAction` there to run an action's
3334
- declared `effects`). If a binding has such an action and `ModelViewer` has no
3335
- `onAction`, its button does nothing, and the viewer logs a console warning
3336
- naming each one. Every action also reaches `onAction`, after the viewer's own
3337
- handling.
3338
-
3339
- `ACTION_CATALOG` lists the ids `BindingBuilder` offers, and whether the viewer
3340
- or your app handles each one (`handling: "viewer" | "host"`):
3341
-
3342
- ```ts
3343
- import { ACTION_CATALOG, findCatalogAction } from "@liveroom-tech/react-immersive/utils";
3344
-
3345
- findCatalogAction("toggle-light")?.handling; // "viewer"
3346
- ```
3347
-
3348
- ### Implemented behaviors
3349
-
3350
- - `add-text`
3351
- Opens a text box and colour inline beneath the action; the text appears at the centre of the camera-facing surface, ready to drag, resize, turn, or remove. Saved to `binding.decals` (see [Decals](#decals))
3352
- - `add-image`
3353
- Opens an image chooser inline beneath the action; the image is placed and edited the same way. Uses `onTextureUpload` for a durable URL when provided, otherwise a session-scoped blob URL
3354
- - `toggle-visibility`
3355
- Hides or shows the selected mesh by setting `binding.visible` and calling `onObjectBindingsChange`
3356
- - `change-color`
3357
- Opens the color picker inline beneath the action; the chosen hex is applied as a live preview while dragging and committed into `binding.style.material.baseColor` via `onObjectBindingsChange` when the picker closes
3358
- - `change-material`
3359
- Opens the texture upload panel inline beneath the action for JPG, PNG, and WebP files; if `onTextureUpload` is provided, the file is passed to it and the returned URL is stored in `binding.style.material.texture.path`; otherwise a session-scoped blob URL is used as the fallback
3360
- - `toggle-light`
3361
- Turns the object's light off, or back on
3362
- - `change-light-color`
3363
- Opens a color picker inline beneath the action that sets the light's color
3364
- - `set-brightness`
3365
- Opens a slider inline beneath the action that sets the light's brightness, from 0 to 200% of what it was when it opened
3366
-
3367
- What "the object's light" is depends on the scene:
3368
-
3369
- - If scene lights are attached to the object (in `BindingBuilder`'s Lighting
3370
- tab, or with `useSceneConfig().lights.attach`), the actions control those
3371
- lights, which light up the room around it. The changes go to
3372
- `sceneConfig.lighting`: to `onSceneConfigChange` if you pass it (`useViewer`
3373
- does, so `viewer.scene` stays current), otherwise `ModelViewer` keeps them
3374
- itself, over whatever `sceneConfig` it's given.
3375
- - Otherwise they control the object's own glow: its emissive color and strength,
3376
- saved on the binding as `style.material.emissive` and
3377
- `style.material.emissiveIntensity`, like any other edit. This works on any
3378
- light fixture with no setup, but a glow doesn't light up the objects around
3379
- it. Toggling off and back on restores the previous strength.
3380
-
3381
- ## How Rendering Works
3382
-
3383
- At a high level, the current viewer does the following:
3384
-
3385
- 1. creates a Three.js canvas; only `fov: 50` is defaulted, so camera position falls back to React Three Fiber's `Canvas` default (`[0, 0, 5]`) unless `camera.position` is passed
3386
- 2. loads the GLB/GLTF asset with `useGLTF`
3387
- 3. looks up meshes by the keys in `objectBindings` (resolving `modelObjectId` to find the actual model node)
3388
- 4. clones each referenced material so edits stay isolated per object (keyed on a structural signature of the binding-to-mesh mapping, not the `objectBindings` reference, so materials are not recreated on every binding update)
3389
- 5. applies runtime color, texture, and style overrides from `objectBindings` in a `useEffect` (not during render)
3390
- 6. manages a reference-counted texture cache so the same texture URL is decoded once and disposed when no longer referenced; each texture is decoded in the correct color space, color maps (base color/albedo, emissive, sheen color, specular color) as sRGB and data maps (normal, roughness, metalness, AO, displacement, etc.) as linear, and the cache is keyed by URL **and** color space, so the same image can be reused safely as both a color and a data map
3391
- 7. adds hover, selected, and panel-hover emissive highlighting
3392
- 8. creates an `AnimationMixer` for the loaded scene, ticked every frame via `useFrame`, and exposes playback controls through `onAnimationsReady`
3393
- 9. renders a side panel for the selected object and its configured actions
3394
-
3395
- Only objects listed in `objectBindings` are rendered interactively by the current `Model` component.
3396
-
3397
- ### Lighting, shadows, and post-processing
3398
-
3399
- When `shadows` is enabled (the default), the canvas renders soft shadow maps and the viewer applies:
3400
-
3401
- - a default light rig (`Lights`) with ambient + hemisphere fill and a directional key light that casts shadows, sized to the model
3402
- - per-mesh `castShadow`/`receiveShadow`, with one exception: the large enclosing "shell" mesh (walls/ceiling of an interior model) is detected by its bounding-box size and excluded from **casting** so a top-down light still reaches the interior, it continues to **receive** shadows, so furniture casts visible contact shadows onto the floor and walls
3403
- - a post-processing stack (`EffectComposer`) with SSAO ambient occlusion (normal pass enabled), bloom, vignette, and ACES filmic tone mapping
3404
-
3405
- Pass `shadows={false}` to disable shadow rendering entirely, or set your own lights in `sceneConfig.lighting` (see [Lighting](#lighting)) to replace the default rig.
3406
-
3407
- ## UI Behavior
3408
-
3409
- The current component includes its own UI shell:
3410
-
3411
- - a viewer layout that fills its parent container
3412
- - a sliding left side panel about `280px` wide (collapses to half-width on narrow screens so the canvas keeps its other half)
3413
- - a canvas area that fills the remaining width
3414
- - a color picker that expands inline beneath the **Change Color** action
3415
- - a texture upload panel that expands inline beneath the **Change Material** action
3416
- - a right scene objects panel with search and per-object visibility toggles
3417
-
3418
- Because of that, it works best when mounted in a container with an explicit height.
3419
-
3420
- ## Usage Expectations For Models
3421
-
3422
- To use this library successfully, your model asset should follow these expectations:
3423
-
3424
- - the mesh node names must match the keys in `objectBindings` (or be referenced via `modelObjectId`)
3425
- - target nodes should have geometry and a supported Three.js mesh material; imported materials are normalized into the editable PBR pipeline
3426
- - the file should be accessible from the browser at `modelUrl`; hosted GLTF, OBJ, and FBX assets must also serve external dependencies at their declared relative paths
3427
- - OBJ does not contain animations; supported FBX and USDZ animation clips are exposed through the same animation controls as glTF
3428
- - OBJ has no standard unit metadata, so set an appropriate measurement label/scene scale when real-world dimensions matter
3429
-
3430
- If a node name or material name does not match, that object will not render through the interactive binding flow.
3431
-
3432
- ### Large models
3433
-
3434
- Viewport picking (click/hover) is accelerated by a BVH index built in a
3435
- background worker, so even multi-million-triangle models stay responsive to
3436
- the pointer. Models above roughly **12 million triangles** are too large to
3437
- index without a significant memory cost, and the viewer degrades gracefully
3438
- instead of freezing:
3439
-
3440
- - viewport click/hover picking is disabled (`onObjectSelect` / `onObjectHover`
3441
- do not fire from the canvas); selection through the scene objects panel
3442
- still works
3443
- - a dismissible banner tells the user the model is very large, may render
3444
- slowly on their device, and that selection is available through the panel
3445
- - the loading overlay calls out the extra work, uploading that much geometry
3446
- to the GPU is a single synchronous operation that can block the page for
3447
- tens of seconds in any WebGL viewer
3448
-
3449
- Orbit, zoom, animations, annotations, and the panels keep working. There is no
3450
- viewer-side way to make models of this size feel fast, the per-frame cost is
3451
- inherent, and on mobile devices the decoded geometry alone can exceed the
3452
- tab's memory budget. Decimate such assets at ingestion (to roughly 2–3M
3453
- triangles) instead of shipping the raw export; note that very large
3454
- Draco-compressed files need Blender or native tooling to decimate, the WASM
3455
- builds of `gltf-transform` and `gltfpack` cannot decode them within their 4GB
3456
- address space.
3457
-
3458
- Two related picking notes that apply to models of every size:
3459
-
3460
- - clicks resolve the front-most surface under the pointer; a mesh with
3461
- `selectable: false` does not pass the click through to meshes behind it
3462
- - `SimpleModelViewer` renders on demand, an idle viewer draws no frames, so
3463
- it costs no GPU time or battery until something changes
3464
-
3465
- ## License
3466
-
3467
- Proprietary, see [LICENSE](./LICENSE). Installing the package does not itself grant a right to use it in production; a valid `licenseKey` from the [Developer Portal](https://react-immersive.liveroom.dev) is required, and usage is bound to the terms of your license tier.
97
+ See [Getting Started](https://react-immersive.liveroom.dev/docs/getting-started)
98
+ for a complete bindings example. Use `onObjectCatalog` or BindingBuilder to
99
+ obtain actual model-node identifiers. `defineObjectBindings` preserves literal
100
+ IDs; widen mutable React state to `Record<string, ObjectBinding>` when passing a
101
+ state setter to `onObjectBindingsChange`.
102
+
103
+ Pure data helpers, including `defineObjectBindings`, `patchBindings`,
104
+ `patchSceneConfig`, and `selectBindings`, are available from the server-safe
105
+ `@liveroom-tech/react-immersive/utils` entry.
106
+
107
+ ## Find the API for your task
108
+
109
+ - [ModelViewer](https://react-immersive.liveroom.dev/docs/reference/model-viewer.md): props, bindings, materials, annotations, exports, XR, performance.
110
+ - [SimpleModelViewer](https://react-immersive.liveroom.dev/docs/reference/simple-model-viewer.md): inspection, uploads, lighting and callbacks.
111
+ - [BindingBuilder](https://react-immersive.liveroom.dev/docs/reference/binding-builder.md): authoring, exports and import workflows.
112
+ - [useViewer](https://react-immersive.liveroom.dev/docs/hooks/use-viewer.md): connect controllers to the viewer.
113
+ - [useObjectBindings](https://react-immersive.liveroom.dev/docs/hooks/use-object-bindings.md): editable state, selectors, materials and visibility.
114
+ - [useViewerCamera](https://react-immersive.liveroom.dev/docs/hooks/use-viewer-camera.md): camera focus, reset and saved views.
115
+ - [useSceneConfig](https://react-immersive.liveroom.dev/docs/hooks/use-scene-config.md): lighting, environment and scene settings.
116
+ - [Types](https://react-immersive.liveroom.dev/docs/reference/types.md) and [labels](https://react-immersive.liveroom.dev/docs/reference/labels.md).
117
+ - [Manifest](https://react-immersive.liveroom.dev/docs/manifest.json): supported version/peers, all page URLs and small API section exports.
118
+ - [Extended package reference](https://react-immersive.liveroom.dev/docs/package-reference.md): detailed examples retained from the former long README.
119
+ - [Troubleshooting](https://react-immersive.liveroom.dev/docs/troubleshooting.md) and [migration notes](https://react-immersive.liveroom.dev/docs/releases.md).
120
+
121
+ ## License and keys
122
+
123
+ This is proprietary software, commercially maintained by Liveroom. The core
124
+ source is private; documentation, starters, issues and discussions are public.
125
+ See the [package license](https://react-immersive.liveroom.dev/LICENSE.txt),
126
+ also included as `LICENSE` in the npm package, and the
127
+ [licensing guide](https://react-immersive.liveroom.dev/docs/licensing).
128
+
129
+ ModelViewer and BindingBuilder require a runtime `licenseKey`. Create one in the
130
+ [console](https://react-immersive.liveroom.dev/console). Local development and
131
+ production domains are governed by the selected plan. SimpleModelViewer has no
132
+ runtime key prop and needs no key or paid plan, including in production.
133
+ The remaining proprietary package terms still apply.
134
+
135
+ `VITE_LICENSE_KEY` and `NEXT_PUBLIC_LICENSE_KEY` are browser-visible values.
136
+ Use a key for the intended registered domain and keep keys out of public
137
+ repositories. Never put account credentials, payment tokens, or server API
138
+ secrets in client-exposed environment variables.
139
+
140
+ ## Support
141
+
142
+ Report reproducible issues with the package version, framework, browser and
143
+ sanitized error text in the
144
+ [public issue tracker](https://github.com/Liveroom-Technologies/react-immersive-docs/issues).
145
+ Send private models, license/account requests and security reports to
146
+ [developers@liveroom.xyz](mailto:developers@liveroom.xyz).