@virtualdisplay.io/client 3.7.0 → 4.0.0-alpha.10

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 (79) hide show
  1. package/CHANGELOG.md +106 -76
  2. package/LICENSE +1 -1
  3. package/README.md +322 -31
  4. package/dist/browser-CDLfpTNV.cjs +8 -0
  5. package/dist/browser-DxtIwHNu.js +1227 -0
  6. package/dist/chunk-BcutgqC9.cjs +1 -0
  7. package/dist/chunk-C_CI6nMA.js +13 -0
  8. package/dist/src/annotations/annotations.d.ts +20 -0
  9. package/dist/src/annotations/annotations.d.ts.map +1 -0
  10. package/dist/src/annotations/index.d.ts +2 -0
  11. package/dist/src/annotations/index.d.ts.map +1 -0
  12. package/dist/src/attributes/attribute.d.ts +38 -0
  13. package/dist/src/attributes/attribute.d.ts.map +1 -0
  14. package/dist/src/attributes/attributes.d.ts +43 -0
  15. package/dist/src/attributes/attributes.d.ts.map +1 -0
  16. package/dist/src/attributes/selections.d.ts +16 -0
  17. package/dist/src/attributes/selections.d.ts.map +1 -0
  18. package/dist/src/attributes/value.d.ts +13 -0
  19. package/dist/src/attributes/value.d.ts.map +1 -0
  20. package/dist/src/camera/camera.d.ts +40 -0
  21. package/dist/src/camera/camera.d.ts.map +1 -0
  22. package/dist/src/camera/index.d.ts +4 -0
  23. package/dist/src/camera/index.d.ts.map +1 -0
  24. package/dist/src/camera/position.d.ts +56 -0
  25. package/dist/src/camera/position.d.ts.map +1 -0
  26. package/dist/src/client/client.d.ts +51 -0
  27. package/dist/src/client/client.d.ts.map +1 -0
  28. package/dist/src/client/error.d.ts +26 -0
  29. package/dist/src/client/error.d.ts.map +1 -0
  30. package/dist/src/client/iframe-builder.d.ts +27 -0
  31. package/dist/src/client/iframe-builder.d.ts.map +1 -0
  32. package/dist/src/client/options.d.ts +19 -0
  33. package/dist/src/client/options.d.ts.map +1 -0
  34. package/dist/src/client/ready-state-tracker.d.ts +13 -0
  35. package/dist/src/client/ready-state-tracker.d.ts.map +1 -0
  36. package/dist/src/client/types.d.ts +19 -0
  37. package/dist/src/client/types.d.ts.map +1 -0
  38. package/dist/src/index.d.ts +12 -0
  39. package/dist/src/index.d.ts.map +1 -0
  40. package/dist/src/snapshot/index.d.ts +3 -0
  41. package/dist/src/snapshot/index.d.ts.map +1 -0
  42. package/dist/src/snapshot/photo.d.ts +47 -0
  43. package/dist/src/snapshot/photo.d.ts.map +1 -0
  44. package/dist/src/snapshot/snapshot.d.ts +30 -0
  45. package/dist/src/snapshot/snapshot.d.ts.map +1 -0
  46. package/dist/src/ui/action-bar.d.ts +18 -0
  47. package/dist/src/ui/action-bar.d.ts.map +1 -0
  48. package/dist/src/ui/camera-controls.d.ts +8 -0
  49. package/dist/src/ui/camera-controls.d.ts.map +1 -0
  50. package/dist/src/ui/controls/attribute-group.d.ts +6 -0
  51. package/dist/src/ui/controls/attribute-group.d.ts.map +1 -0
  52. package/dist/src/ui/event-bus.d.ts +12 -0
  53. package/dist/src/ui/event-bus.d.ts.map +1 -0
  54. package/dist/src/ui/loading.d.ts +43 -0
  55. package/dist/src/ui/loading.d.ts.map +1 -0
  56. package/dist/src/ui/standard-interface.d.ts +42 -0
  57. package/dist/src/ui/standard-interface.d.ts.map +1 -0
  58. package/dist/src/ui/styles.d.ts +3 -0
  59. package/dist/src/ui/styles.d.ts.map +1 -0
  60. package/dist/src/utils/logger.d.ts +11 -0
  61. package/dist/src/utils/logger.d.ts.map +1 -0
  62. package/dist/virtualdisplay.client.cjs.js +311 -8
  63. package/dist/virtualdisplay.client.es.js +2218 -8018
  64. package/dist/virtualdisplay.client.umd.js +318 -8
  65. package/package.json +15 -99
  66. package/README.npm.md +0 -78
  67. package/dist/index.d.ts +0 -821
  68. package/dist/virtualdisplay.client.cjs.js.map +0 -1
  69. package/dist/virtualdisplay.client.es.js.map +0 -1
  70. package/dist/virtualdisplay.client.umd.js.map +0 -1
  71. package/node_modules/@virtualdisplay-io/logger/CHANGELOG.md +0 -82
  72. package/node_modules/@virtualdisplay-io/logger/LICENSE +0 -21
  73. package/node_modules/@virtualdisplay-io/logger/README.md +0 -314
  74. package/node_modules/@virtualdisplay-io/logger/dist/index.d.ts +0 -167
  75. package/node_modules/@virtualdisplay-io/logger/dist/virtualdisplay.logger.cjs.js +0 -4
  76. package/node_modules/@virtualdisplay-io/logger/dist/virtualdisplay.logger.cjs.js.map +0 -1
  77. package/node_modules/@virtualdisplay-io/logger/dist/virtualdisplay.logger.es.js +0 -377
  78. package/node_modules/@virtualdisplay-io/logger/dist/virtualdisplay.logger.es.js.map +0 -1
  79. package/node_modules/@virtualdisplay-io/logger/package.json +0 -79
package/CHANGELOG.md CHANGED
@@ -1,142 +1,172 @@
1
1
  # Changelog
2
2
 
3
- All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
3
+ ## 4.0.0-alpha.10
4
+
5
+ ### Patch Changes
6
+
7
+ Fix AR button on mobile to launch native AR (Quick Look on iOS, Scene Viewer on Android) instead of the QR modal. Fix fullscreen button on iPhone Safari.
8
+
9
+ ## 4.0.0-alpha.9
10
+
11
+ ### Patch Changes
12
+
13
+ Fix state mix-up when multiple `VirtualdisplayClient` instances are mounted on the same page. Each client now correctly receives only its own server replies, so loading state, mapping, and mutation results no longer cross between viewers.
14
+
15
+ ## 4.0.0-alpha.8
16
+
17
+ ### Minor Changes
18
+
19
+ Add `viewerSettings` option to `ClientOptions`. Pass a partial `ViewerSettings` to override fields like `ar`, `fullscreen`, `cameraControls`, `attributeControls`, or `annotations` without changing the model's metadata.
20
+
21
+ Add annotations API: `client.annotations.setEnabled(enabled)` toggles annotation markers, and `startPlacing()` / `stopPlacing()` / `onPlaced(callback)` enable click-to-place flows for custom annotation editors. New `AnnotationPosition` type is exported.
22
+
23
+ Add `attributeControls` field to `ViewerSettings`. Set to `false` to hide the built-in attribute selector while keeping `client.select()` and `client.onChange()` available.
24
+
25
+ Fix toolbar buttons appearing briefly before the loading indicator clears.
26
+
27
+ Fix annotation markers ignoring `annotations: false` when set via the `viewerSettings` override.
28
+
29
+ Fix loading indicator hanging when model metadata is unavailable.
30
+
31
+ Internal code quality improvements.
32
+
33
+ ## 4.0.0-alpha.7
34
+
35
+ ### Patch Changes
36
+
37
+ Restructure standard interface layout to use corner slots. Camera controls and screenshot button now share a single card when both are enabled.
38
+
39
+ ## 4.0.0-alpha.6
40
+
41
+ ### Patch Changes
42
+
43
+ Fix camera control buttons accumulating clicks correctly.
44
+
45
+ ## 4.0.0-alpha.5
46
+
47
+ ### Patch Changes
48
+
49
+ Internal code quality improvements.
50
+
51
+ Ship complete TypeScript type definitions for all exports.
52
+
53
+ ## 4.0.0-alpha.4
54
+
55
+ ### Minor Changes
56
+
57
+ Add `language` option to `ClientOptions`. Pass a BCP 47 language tag (e.g. `"nl"`, `"de"`) to override the viewer language at initialisation time. Useful when embedding the same model on multiple pages with different languages.
58
+
59
+ Add built-in standard interface: loading indicator, toolbar (screenshot, AR, fullscreen), camera controls, and attribute controls are now rendered automatically inside the viewer container. UI is driven by `viewerSettings` received from the server and requires no manual setup.
60
+
61
+ ### Patch Changes
62
+
63
+ Fix build target: use ESNext in tsconfig to resolve rolldown bundling issues with ES2022 class fields.
64
+
65
+ ## 4.0.0-alpha.2
66
+
67
+ ### Patch Changes
68
+
69
+ Build optimisations.
70
+
71
+ ## 4.0.0-alpha.1
72
+
73
+ ### Major Changes
74
+
75
+ Metadata-driven configuration replaces direct scene node manipulation. The client now receives available attributes and values from the server via a mapping message, instead of managing 3D nodes directly.
76
+
77
+ ### Breaking changes
78
+
79
+ - **Attribute-only API**: replaces the previous node-based approach with `select()`, `onChange()`, `getValues()`
80
+ - **Removed `isReady` getter** — use `onReady(callback)` instead
81
+ - **Removed `getQueueStatus`** — no longer part of the public API
82
+ - **Package scope changed** from `@virtualdisplay-io/client` to `@virtualdisplay.io/client`
83
+
84
+ ### New features
85
+
86
+ - Metadata-driven mapping: server sends available attributes and values automatically
87
+ - Camera control API: `camera.rotate()`, `camera.tilt()`, `camera.zoom()`
88
+ - Snapshot API: `snapshot.take()` with `photo.onDeveloped()` callback
89
+ - Viewer configuration: AR, fullscreen, loading indicator controls
90
+ - `onMutationFailed` callback for error handling
91
+
92
+ All notable changes to this project will be documented in this file.
4
93
 
5
94
  ## [3.7.0](https://github.com/virtualdisplay-io/client/compare/v3.6.0...v3.7.0) (2025-08-05)
6
95
 
7
96
  ### ✨ Features
8
97
 
9
- * dynamic mapping - proxy release ([#9](https://github.com/virtualdisplay-io/client/issues/9)) ([a95f0e7](https://github.com/virtualdisplay-io/client/commit/a95f0e7a7672b844571b11307637083c6b487f3f)), closes [#8](https://github.com/virtualdisplay-io/client/issues/8)
98
+ - dynamic mapping - proxy release ([#9](https://github.com/virtualdisplay-io/client/issues/9)) ([a95f0e7](https://github.com/virtualdisplay-io/client/commit/a95f0e7a7672b844571b11307637083c6b487f3f)), closes [#8](https://github.com/virtualdisplay-io/client/issues/8)
10
99
 
11
100
  ### 🔧 Maintenance
12
101
 
13
- * various fixes and documentation updates ([#7](https://github.com/virtualdisplay-io/client/issues/7)) ([325150b](https://github.com/virtualdisplay-io/client/commit/325150b41bd557e7426e6dae6780cd4fd7660deb))
102
+ - various fixes and documentation updates ([#7](https://github.com/virtualdisplay-io/client/issues/7)) ([325150b](https://github.com/virtualdisplay-io/client/commit/325150b41bd557e7426e6dae6780cd4fd7660deb))
14
103
 
15
104
  ## [3.6.0](https://github.com/virtualdisplay-io/client/compare/v3.5.1...v3.6.0) (2025-07-23)
16
105
 
17
106
  ### ✨ Features
18
107
 
19
- * add camera configuration support ([#6](https://github.com/virtualdisplay-io/client/issues/6)) ([a6bce4b](https://github.com/virtualdisplay-io/client/commit/a6bce4bfd0d55362e76c893ddf5ed28409dc8bec))
108
+ - add camera configuration support ([#6](https://github.com/virtualdisplay-io/client/issues/6)) ([a6bce4b](https://github.com/virtualdisplay-io/client/commit/a6bce4bfd0d55362e76c893ddf5ed28409dc8bec))
20
109
 
21
110
  ## [3.5.1](https://github.com/virtualdisplay-io/client/compare/v3.5.0...v3.5.1) (2025-07-18)
22
111
 
23
112
  ### ♻️ Code Refactoring
24
113
 
25
- * remove validation of outgoing message types ([#5](https://github.com/virtualdisplay-io/client/issues/5)) ([5f4f985](https://github.com/virtualdisplay-io/client/commit/5f4f9853d65af676aec3a865864f43461fdb6ca5))
114
+ - remove validation of outgoing message types ([#5](https://github.com/virtualdisplay-io/client/issues/5)) ([5f4f985](https://github.com/virtualdisplay-io/client/commit/5f4f9853d65af676aec3a865864f43461fdb6ca5))
26
115
 
27
116
  ## [3.5.0](https://github.com/virtualdisplay-io/client/compare/v3.4.1...v3.5.0) (2025-07-16)
28
117
 
29
118
  ### ✨ Features
30
119
 
31
- * camera control API ([#4](https://github.com/virtualdisplay-io/client/issues/4)) ([1e4c147](https://github.com/virtualdisplay-io/client/commit/1e4c14747cad2a4617c4cc763522b50941adaa7f))
120
+ - camera control API ([#4](https://github.com/virtualdisplay-io/client/issues/4)) ([1e4c147](https://github.com/virtualdisplay-io/client/commit/1e4c14747cad2a4617c4cc763522b50941adaa7f))
32
121
 
33
122
  ## [3.4.1](https://github.com/virtualdisplay-io/client/compare/v3.4.0...v3.4.1) (2025-07-10)
34
123
 
35
124
  ### 🐛 Bug Fixes
36
125
 
37
- * EventBus once handlers and logging improvements ([#3](https://github.com/virtualdisplay-io/client/issues/3)) ([5a99d8d](https://github.com/virtualdisplay-io/client/commit/5a99d8d6ef82d058799734b54c98ca171d17dd36))
126
+ - EventBus once handlers and logging improvements ([#3](https://github.com/virtualdisplay-io/client/issues/3)) ([5a99d8d](https://github.com/virtualdisplay-io/client/commit/5a99d8d6ef82d058799734b54c98ca171d17dd36))
38
127
 
39
128
  ## [3.4.0](https://github.com/virtualdisplay-io/client/compare/v3.3.0...v3.4.0) (2025-07-09)
40
129
 
41
130
  ### ✨ Features
42
131
 
43
- * implement UI configuration via PostMessage CONFIG messages ([#2](https://github.com/virtualdisplay-io/client/issues/2)) ([abc2294](https://github.com/virtualdisplay-io/client/commit/abc229414f9f70c54f37db903c46c0612c5eb6cf))
132
+ - implement UI configuration via PostMessage CONFIG messages ([#2](https://github.com/virtualdisplay-io/client/issues/2)) ([abc2294](https://github.com/virtualdisplay-io/client/commit/abc229414f9f70c54f37db903c46c0612c5eb6cf))
44
133
 
45
134
  ## [3.3.0](https://github.com/virtualdisplay-io/client/compare/v3.2.2...v3.3.0) (2025-07-07)
46
135
 
47
136
  ### ✨ Features
48
137
 
49
- * add isInitial flag to StateMessage ([#50](https://github.com/virtualdisplay-io/client/issues/50)) ([8590354](https://github.com/virtualdisplay-io/client/commit/859035423e161f43791433baac203b2adb95c9fd))
138
+ - add isInitial flag to StateMessage ([#50](https://github.com/virtualdisplay-io/client/issues/50)) ([8590354](https://github.com/virtualdisplay-io/client/commit/859035423e161f43791433baac203b2adb95c9fd))
50
139
 
51
140
  ## [3.2.2](https://github.com/virtualdisplay-io/client/compare/v3.2.1...v3.2.2) (2025-07-01)
52
141
 
53
142
  ### 🐛 Bug Fixes
54
143
 
55
- * change default logger level to warn ([#49](https://github.com/virtualdisplay-io/client/issues/49)) ([a567db2](https://github.com/virtualdisplay-io/client/commit/a567db23a50173e3b167238af2197e545bda6320))
144
+ - change default logger level to warn ([#49](https://github.com/virtualdisplay-io/client/issues/49)) ([a567db2](https://github.com/virtualdisplay-io/client/commit/a567db23a50173e3b167238af2197e545bda6320))
56
145
 
57
146
  ## [3.2.1](https://github.com/virtualdisplay-io/client/compare/v3.2.0...v3.2.1) (2025-06-30)
58
147
 
59
148
  ### 🐛 Bug Fixes
60
149
 
61
- * prevent .env from being used in production builds ([#48](https://github.com/virtualdisplay-io/client/issues/48)) ([7ab54d0](https://github.com/virtualdisplay-io/client/commit/7ab54d02a9aad94daf5a53899fefa9299f9bf73f))
150
+ - prevent .env from being used in production builds ([#48](https://github.com/virtualdisplay-io/client/issues/48)) ([7ab54d0](https://github.com/virtualdisplay-io/client/commit/7ab54d02a9aad94daf5a53899fefa9299f9bf73f))
62
151
 
63
152
  ## [3.2.0](https://github.com/virtualdisplay-io/client/compare/v3.1.0...v3.2.0) (2025-06-27)
64
153
 
65
154
  ### ✨ Features
66
155
 
67
- * publish client package to npm registry ([#45](https://github.com/virtualdisplay-io/client/issues/45)) ([825810b](https://github.com/virtualdisplay-io/client/commit/825810b0ca56da8e50f34f2afac9f75a87acbc40))
156
+ - publish client package to npm registry ([#45](https://github.com/virtualdisplay-io/client/issues/45)) ([825810b](https://github.com/virtualdisplay-io/client/commit/825810b0ca56da8e50f34f2afac9f75a87acbc40))
68
157
 
69
158
  ### 🐛 Bug Fixes
70
159
 
71
- * improve GitHub Actions authentication and remove .env.act ([#47](https://github.com/virtualdisplay-io/client/issues/47)) ([3acc86e](https://github.com/virtualdisplay-io/client/commit/3acc86e5c27a26af0b77cc23ddff397eee141de5))
72
- * use GITHUB_TOKEN for checkout action ([#46](https://github.com/virtualdisplay-io/client/issues/46)) ([f8d60fb](https://github.com/virtualdisplay-io/client/commit/f8d60fba2547950137de10838bcfc874e78d9f33))
160
+ - improve GitHub Actions authentication and remove .env.act ([#47](https://github.com/virtualdisplay-io/client/issues/47)) ([3acc86e](https://github.com/virtualdisplay-io/client/commit/3acc86e5c27a26af0b77cc23ddff397eee141de5))
161
+ - use GITHUB_TOKEN for checkout action ([#46](https://github.com/virtualdisplay-io/client/issues/46)) ([f8d60fb](https://github.com/virtualdisplay-io/client/commit/f8d60fba2547950137de10838bcfc874e78d9f33))
73
162
 
74
163
  ### 📝 Documentation
75
164
 
76
- * update README version reference to v3.1 ([#44](https://github.com/virtualdisplay-io/client/issues/44)) ([1652c15](https://github.com/virtualdisplay-io/client/commit/1652c157890ca43d1e366b302a37f02465d6450b))
165
+ - update README version reference to v3.1 ([#44](https://github.com/virtualdisplay-io/client/issues/44)) ([1652c15](https://github.com/virtualdisplay-io/client/commit/1652c157890ca43d1e366b302a37f02465d6450b))
77
166
 
78
167
  ## [3.1.0](https://github.com/virtualdisplay-io/client/compare/v3.0.0...v3.1.0) (2025-06-25)
79
168
 
80
- ### ⚠ BREAKING CHANGES
81
-
82
- * Complete API redesign with the following changes:
83
- - Removed isReady getter - use onReady callback instead
84
- - Removed getQueueStatus method - internal implementation detail
85
- - Removed toJSON from ModelNode - not needed for public API
86
- - Complete restructure from core/ to src/ with domain-driven design
87
- - New attribute-based API is now the only way to interact with 3D models
88
- - Fire-and-forget messaging pattern for all operations
89
- - JSON Schema validation for mapping configuration
90
-
91
- Features:
92
- - Simplified color configurator demo (300 lines → 160 lines)
93
- - Bundled @virtualdisplay-io/logger package
94
- - Domain-driven directory structure
95
- - Proper error handling with error codes
96
- - Event-driven architecture with EventBus
97
- - onChange callbacks for real-time UI synchronization
98
- - Comprehensive test coverage
99
-
100
- Documentation:
101
- - Complete README rewrite focusing on actual functionality
102
- - Added terminology standards for consistent communication
103
- - Removed unimplemented accessibility claims
104
- - Clear separation between simple and configurable products
105
-
106
- * fix: update lockfile after removing translator dependency
107
-
108
- * docs: update README for v4.0 release
109
-
110
- * fix: add GitHub registry configuration for @virtualdisplay-io scope
111
-
112
- * fix: add npm authentication to bundle-size workflow and package permissions
113
-
114
- * fix: use GITHUB_TOKEN for npm auth and add trailing slash to registry URL
115
-
116
- * chore: update lockfile with fresh install
117
-
118
- * fix: use GH_PAT instead of GITHUB_TOKEN for package authentication
119
-
120
- - Replace GITHUB_TOKEN with GH_PAT in all workflows to avoid conflicts with GitHub's reserved token
121
- - Update CI, release, and bundle-size workflows to use new token variable
122
- - Add .env.act for local testing with act
123
- - Required because GitHub's automatic GITHUB_TOKEN cannot access private organization packages
124
-
125
- * fix: remove push trigger from bundle-size workflow
126
-
127
- - Bundle size analysis should only run on pull requests
128
- - Prevents duplicate runs and confusion about which branch is being tested
129
- - Aligns with CI/CD best practices for PR-based workflows
130
-
131
- ### ✨ Features
132
-
133
- * v4.0.0 - simplified architecture and attribute-only API ([#41](https://github.com/virtualdisplay-io/client/issues/41)) ([dc649c1](https://github.com/virtualdisplay-io/client/commit/dc649c1b863b2427bf6e0350960c4d2e2a2dacb8))
134
-
135
169
  ### 🐛 Bug Fixes
136
170
 
137
- * add missing conventional-changelog-conventionalcommits dependency ([8a15743](https://github.com/virtualdisplay-io/client/commit/8a15743de3984c742ccb5de0537333f321108cd4))
138
- * use NODE_AUTH_TOKEN for npm authentication ([#43](https://github.com/virtualdisplay-io/client/issues/43)) ([c148c6c](https://github.com/virtualdisplay-io/client/commit/c148c6cba6b6b4d1fc431ca5618ad2c3c26638c2))
139
-
140
- ### 🔧 Maintenance
141
-
142
- * trigger release workflow to test GH_PAT secret ([9b07140](https://github.com/virtualdisplay-io/client/commit/9b07140e01d72ccc3774f20733afd197f52c4cde))
171
+ - add missing conventional-changelog-conventionalcommits dependency ([8a15743](https://github.com/virtualdisplay-io/client/commit/8a15743de3984c742ccb5de0537333f321108cd4))
172
+ - use NODE_AUTH_TOKEN for npm authentication ([#43](https://github.com/virtualdisplay-io/client/issues/43)) ([c148c6c](https://github.com/virtualdisplay-io/client/commit/c148c6cba6b6b4d1fc431ca5618ad2c3c26638c2))
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Virtualdisplay
3
+ Copyright (c) 2025-2026 Virtualdisplay
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # Virtualdisplay client
2
2
 
3
- TypeScript library for embedding interactive 3D product models in web applications.
3
+ TypeScript library for embedding interactive 3D product models in web
4
+ applications.
5
+
6
+ - Built-in viewer UI with loading indicator, product controls, and action bar
7
+ - Simple attribute-based API for product configurators
8
+ - Server-driven configuration, no client-side mapping needed
9
+ - Fire-and-forget messaging with automatic state synchronisation
10
+ - Zero external dependencies (all bundled)
11
+ - Works with any frontend framework or vanilla JavaScript
4
12
 
5
13
  ## Installation
6
14
 
@@ -19,7 +27,7 @@ yarn add @virtualdisplay.io/client
19
27
  ```typescript
20
28
  import { VirtualdisplayClient } from '@virtualdisplay.io/client';
21
29
 
22
- // That's it! Your 3D model is now displayed
30
+ // Your 3D model is now displayed
23
31
  const client = new VirtualdisplayClient({
24
32
  parent: '#product-container',
25
33
  license: 'your-license-key',
@@ -32,47 +40,330 @@ const client = new VirtualdisplayClient({
32
40
  ```typescript
33
41
  import { VirtualdisplayClient } from '@virtualdisplay.io/client';
34
42
 
35
- // Create client instance
36
43
  const client = new VirtualdisplayClient({
37
44
  parent: '#product-container',
38
45
  license: 'your-license-key',
39
46
  model: 'sneaker',
40
47
  });
41
48
 
42
- // Map product options to 3D parts
43
- client.setMapping({
44
- attributes: [
45
- {
46
- name: 'Color',
47
- values: [
48
- { value: 'Red', nodeIds: ['laces_red', 'sole_red'], isSelected: true },
49
- { value: 'Blue', nodeIds: ['laces_blue', 'sole_blue'] },
50
- ],
51
- },
52
- ],
49
+ // Select a product option. The 3D model updates automatically.
50
+ // Calls are buffered until the server provides the attribute mapping
51
+ client.select('Color', 'red');
52
+ ```
53
+
54
+ The server defines which attributes and values are available for each model.
55
+ The client receives this configuration automatically via postMessage. No
56
+ manual mapping required.
57
+
58
+ ## How it works
59
+
60
+ The 3D server hosts the viewer in an iframe, keeping WebGL complexity isolated
61
+ from your application. The client library handles all communication via
62
+ postMessage.
63
+
64
+ ![Architecture overview](docs/arch.png)
65
+
66
+ On startup, the server sends the client its configuration (viewer settings,
67
+ camera limits) and available product attributes. The loading indicator shows
68
+ progress while the model downloads.
69
+
70
+ ![Startup sequence](docs/startup-sequence.png)
71
+
72
+ 1. Client creates iframe; outgoing messages are queued until the server is ready.
73
+ 2. Server sends `HANDSHAKE` when its message listener is active; client flushes queue.
74
+ 3. Server sends progress updates while the model downloads. The client displays these in the loading indicator.
75
+ 4. Server sends `CONFIG` with viewer settings and camera limits from model metadata.
76
+ 5. Server sends `MAPPING` with attribute definitions, values, and defaults. `onReady` fires.
77
+
78
+ ## Product configuration
79
+
80
+ Configure product options by selecting attribute values. The server defines
81
+ which attributes exist (e.g. "Color", "Size") and which values each has
82
+ (e.g. "red", "blue"). You select values; the 3D model updates automatically.
83
+
84
+ ![Product configuration sequence](docs/mutation.png)
85
+
86
+ - `select()` returns immediately; the result arrives asynchronously.
87
+ - Each attribute in the result has its own `success` flag and optional `error`.
88
+ - Attributes within the same component fail as a group.
89
+
90
+ ### Selecting values
91
+
92
+ ```typescript
93
+ // Select a product option. The 3D model updates automatically.
94
+ client.select('Color', 'blue');
95
+ client.select('Size', 'large');
96
+ ```
97
+
98
+ Can be called immediately after construction. Selections are buffered until the
99
+ server handshake completes.
100
+
101
+ ### Tracking changes
102
+
103
+ Keep your UI in sync with the 3D server state:
104
+
105
+ ```typescript
106
+ client.onChange('Color', (selectedValue) => {
107
+ // selectedValue.value is the selected value (e.g. 'blue')
108
+ // selectedValue.isSelected is true
109
+ updateColorButton(selectedValue.value);
110
+ });
111
+ ```
112
+
113
+ ### Querying available values
114
+
115
+ ```typescript
116
+ // All values for an attribute
117
+ const colors = client.getValues('Color');
118
+ colors.forEach((av) => {
119
+ console.log(av.value, av.isSelected);
120
+ });
121
+
122
+ // A specific value
123
+ const blue = client.getValue('Color', 'blue');
124
+ if (blue?.isSelected) {
125
+ highlightButton('blue');
126
+ }
127
+ ```
128
+
129
+ ### Direct attribute access
130
+
131
+ For advanced use cases, get the `Attribute` instance directly:
132
+
133
+ ```typescript
134
+ const colorAttr = client.getAttribute('Color');
135
+ if (colorAttr) {
136
+ colorAttr.select('blue');
137
+ colorAttr.getValues(); // AttributeValue[]
138
+ colorAttr.getValue('blue'); // AttributeValue | undefined
139
+ colorAttr.onChange((value) => { ... });
140
+ }
141
+ ```
142
+
143
+ ### Handling failed mutations
144
+
145
+ ```typescript
146
+ client.onMutationFailed(({ attribute, value }) => {
147
+ console.error(`Mutation failed: ${attribute} = ${value}`);
148
+ });
149
+ ```
150
+
151
+ ## Snapshots
152
+
153
+ Capture the current 3D view as an image. Useful for product shots, social
154
+ sharing, or saving configurations.
155
+
156
+ ![Snapshot sequence](docs/snapshot.png)
157
+
158
+ - Filename is validated client-side (extension, no path traversal).
159
+ - Server always responds, either with image data or an error reason.
160
+
161
+ ### Taking a snapshot
162
+
163
+ ```typescript
164
+ const photo = client.snapshot.take('product-hero-shot.png');
165
+
166
+ // Register callback for when image is ready
167
+ photo.onDeveloped((photoData) => {
168
+ // photoData.filename - The filename you provided
169
+ // photoData.data - Base64 encoded image data
170
+ const img = document.createElement('img');
171
+ img.src = photoData.data;
172
+ document.body.appendChild(img);
173
+ });
174
+
175
+ // Handle errors (e.g., canvas not available)
176
+ photo.onError((error) => {
177
+ console.error('Snapshot failed:', error.message);
178
+ });
179
+ ```
180
+
181
+ Filename must end with `.png`. The server always returns PNG data.
182
+
183
+ ## Camera
184
+
185
+ The standard interface includes built-in camera controls when they are
186
+ enabled in the Virtualdisplay portal. The camera can also be controlled
187
+ programmatically.
188
+
189
+ ![Camera sequence](docs/camera.png)
190
+
191
+ - Commands accumulate via chaining; `.set()` sends them all at once.
192
+ - `.reset()` sends immediately without chaining.
193
+ - Position updates are continuous. They fire on both programmatic and user-driven camera movement.
194
+
195
+ ### Controlling the camera
196
+
197
+ ```typescript
198
+ // Chain commands, then send with .set()
199
+ client.camera.rotate(45).set();
200
+ client.camera.rotate(90).tilt(45).zoom(150).set();
201
+
202
+ // Reset to the default position configured in the portal (sends immediately)
203
+ client.camera.reset();
204
+ ```
205
+
206
+ ### Tracking camera position
207
+
208
+ The current camera position is updated in real-time as the user orbits, zooms,
209
+ or tilts the model.
210
+
211
+ ```typescript
212
+ client.cameraPosition.onChange((position) => {
213
+ console.log(position.rotation, position.tilt, position.zoom);
214
+ });
215
+
216
+ // Read current values directly
217
+ console.log(client.cameraPosition.rotation);
218
+ console.log(client.cameraPosition.tilt);
219
+ console.log(client.cameraPosition.zoom);
220
+ ```
221
+
222
+ ## Annotations
223
+
224
+ Annotations are interactive markers placed on the 3D model. They are
225
+ configured and saved in the Virtualdisplay portal. The client library
226
+ exposes APIs to toggle their visibility and to build custom annotation
227
+ editors.
228
+
229
+ ### Toggling annotations
230
+
231
+ ```typescript
232
+ client.annotations.setEnabled(false); // Hide all markers
233
+ client.annotations.setEnabled(true); // Show them again
234
+ ```
235
+
236
+ Visibility can also be controlled via `viewerSettings.annotations` (see below).
237
+
238
+ ### Placing annotations
239
+
240
+ For building a custom annotation editor, the client supports click-to-place
241
+ mode. Enter the mode, listen for the placed position, then exit.
242
+
243
+ ```typescript
244
+ client.annotations.onPlaced((position) => {
245
+ // position has x, y, z coordinates on the model surface
246
+ console.log(position);
247
+ });
248
+
249
+ // Enter placement mode. The next click on the model fires onPlaced.
250
+ client.annotations.startPlacing();
251
+
252
+ // Cancel placement mode without recording a click.
253
+ client.annotations.stopPlacing();
254
+ ```
255
+
256
+ The position type is `AnnotationPosition`, exported from the package.
257
+
258
+ ## Standard interface
259
+
260
+ The client renders a complete viewer UI automatically: loading indicator,
261
+ attribute controls, camera controls, and an action bar with AR, fullscreen,
262
+ and screenshot buttons. Each element is shown or hidden based on viewer
263
+ settings configured in the Virtualdisplay portal.
264
+
265
+ ### Available settings
266
+
267
+ | Field | Type | Effect when `false` |
268
+ | ------------------- | --------- | ---------------------------------------------------------------------------------------------- |
269
+ | `ar` | `boolean` | Hides the AR button |
270
+ | `fullscreen` | `boolean` | Hides the fullscreen button |
271
+ | `screenshot` | `boolean` | Hides the screenshot button |
272
+ | `cameraControls` | `boolean` | Hides the camera control buttons |
273
+ | `attributeControls` | `boolean` | Hides the built-in attribute selector. `client.select()` and `client.onChange()` keep working. |
274
+ | `annotations` | `boolean` | Hides all annotation markers |
275
+ | `language` | `string` | Sets the viewer UI language (BCP 47, e.g. `'nl'`, `'en'`, `'de'`) |
276
+
277
+ ### Overriding settings
278
+
279
+ The portal is the recommended place to change these settings: one source of
280
+ truth, and the viewer behaves the same wherever it is embedded.
281
+
282
+ We know there are situations where the portal alone cannot cover the case at
283
+ hand. For those, `ClientOptions.viewerSettings` accepts a partial override of
284
+ the same fields. Use it sparingly: every override is one more place where
285
+ the embedded viewer disagrees with the portal. Omitted fields fall back to
286
+ the metadata value.
287
+
288
+ Any override that differs from the metadata is logged with `console.warn`.
289
+ The warning is always emitted, so the deviation stays traceable when
290
+ something needs explaining.
291
+
292
+ ```typescript
293
+ const client = new VirtualdisplayClient({
294
+ parent: '#product-container',
295
+ license: 'your-license-key',
296
+ model: 'sneaker',
297
+ viewerSettings: {
298
+ cameraControls: false,
299
+ },
300
+ });
301
+ ```
302
+
303
+ ## Lifecycle
304
+
305
+ ### Ready state
306
+
307
+ Use `onReady` to know when the model and attribute definitions are available.
308
+ Not required before calling `select()` or `onChange()`, those are buffered
309
+ automatically.
310
+
311
+ ```typescript
312
+ client.onReady(() => {
313
+ const values = client.getValues('Color');
314
+ console.log('Available colours:', values.map(v => v.value));
53
315
  });
316
+ ```
317
+
318
+ ### Cleanup
319
+
320
+ ```typescript
321
+ client.destroy();
322
+ ```
54
323
 
55
- // Control via product options
56
- client.getAttribute('Color')?.select('Red');
324
+ ## Constructor options
325
+
326
+ ```typescript
327
+ import type { ViewerSettings } from '@virtualdisplay.io/client';
328
+
329
+ interface ClientOptions {
330
+ parent: string | HTMLElement; // Where to embed the 3D viewer
331
+ license: string; // License key from your Virtualdisplay account
332
+ model: string; // Which 3D model to load
333
+ debug?: boolean; // Shows console logs for troubleshooting
334
+ language?: string; // Viewer language: 'nl', 'en', or 'de'
335
+ viewerSettings?: Partial<ViewerSettings>; // Override fields from model metadata (see Standard interface)
336
+ }
57
337
  ```
58
338
 
59
- ## Key features
339
+ ## Error codes
340
+
341
+ The client throws `VirtualdisplayError` for known error conditions:
342
+
343
+ | Code | Meaning |
344
+ | --------------------- | ------------------------------------------------ |
345
+ | `NO_MAPPING` | Attribute data not yet available from the server |
346
+ | `ATTRIBUTE_NOT_FOUND` | Requested attribute doesn't exist in the mapping |
347
+ | `VALUE_NOT_FOUND` | Requested value doesn't exist for attribute |
348
+ | `PARENT_NOT_FOUND` | Parent element for iframe not found |
349
+ | `INVALID_PARAMETER` | Invalid parameter (e.g. snapshot filename) |
350
+ | `SNAPSHOT_FAILED` | Server could not capture the snapshot |
351
+
352
+ ## Troubleshooting
353
+
354
+ **Iframe not loading:**
60
355
 
61
- - **Simple API**: Attribute-based product configuration
62
- - **Fire-and-forget**: Send commands without waiting for responses
63
- - **State sync**: Automatic synchronization between client and 3D viewer
64
- - **Framework-agnostic**: Works with React, Vue, Angular, or vanilla JS
65
- - **TypeScript first**: Full type safety and IntelliSense support
66
- - **Minimal dependencies**: Only essential validation and logging included
356
+ - Check that the parent element exists in the DOM
357
+ - Verify your license key is valid
358
+ - Ensure the model ID matches your licence
67
359
 
68
- ## Documentation
360
+ **Attributes not working:**
69
361
 
70
- For complete documentation including:
362
+ - Verify attribute names match exactly (case-sensitive)
363
+ - Check that the value exists for the attribute
364
+ - Use `onMutationFailed` to catch server-side errors
71
365
 
72
- - API reference
73
- - Advanced examples
74
- - Integration guides
75
- - Architecture diagrams
76
- - Troubleshooting
366
+ ## Changelog
77
367
 
78
- Visit our [GitHub repository](https://github.com/virtualdisplay-io/client)
368
+ See the [npm version history](https://www.npmjs.com/package/@virtualdisplay.io/client?activeTab=versions)
369
+ for release notes.