@3dsource/metabox-front-api 3.0.16-dev.5 → 3.0.16-dev.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -43
- package/fesm2022/3dsource-metabox-front-api.mjs +616 -361
- package/fesm2022/3dsource-metabox-front-api.mjs.map +1 -1
- package/package.json +1 -1
- package/types/3dsource-metabox-front-api.d.ts +1066 -377
|
@@ -2,6 +2,19 @@ import { fromEvent } from 'rxjs';
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Base class for commands sent to the Metabox API.
|
|
5
|
+
*
|
|
6
|
+
* ### What does it unlock?
|
|
7
|
+
* Base class that all other commands inherit from in a class hierarchy. Provides common properties
|
|
8
|
+
* and methods that are automatically available to all command subclasses.
|
|
9
|
+
*
|
|
10
|
+
* ### Practical Application
|
|
11
|
+
* Base class all commands inherit from. Never instantiate directly — use specific subclasses like
|
|
12
|
+
* SetProduct, SetCamera, etc. All commands are sent via `api.sendCommandToMetabox(new CommandName(...))`.
|
|
13
|
+
*
|
|
14
|
+
* ### AI Coding Best Practices
|
|
15
|
+
* Never construct a generic CommandBase. Always use the specific typed command class. When generating
|
|
16
|
+
* dynamic command dispatch, use a switch/map pattern matching command names to their constructors.
|
|
17
|
+
*
|
|
5
18
|
* @internal
|
|
6
19
|
* @hidden
|
|
7
20
|
*/
|
|
@@ -9,18 +22,48 @@ class CommandBase {
|
|
|
9
22
|
}
|
|
10
23
|
|
|
11
24
|
/**
|
|
12
|
-
* Wrapper helper function to use
|
|
25
|
+
* Wrapper helper function to use with RxJS the same way as `fromEvent`, to listen to events from the Communicator.
|
|
26
|
+
*
|
|
27
|
+
* ### What does it unlock?
|
|
28
|
+
* Function that creates an event listener subscription. Allows developers to subscribe to specific events from the Communicator.
|
|
29
|
+
*
|
|
30
|
+
* ### Practical Application
|
|
31
|
+
* Function that creates event listener subscriptions. Alternative to api.addEventListener() — both subscribe
|
|
32
|
+
* to configurator events. Use to react to state changes, screenshot readiness, viewport loading, showcase status, etc.
|
|
13
33
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
34
|
+
* ### AI Coding Best Practices
|
|
35
|
+
* Prefer api.addEventListener() directly from the Communicator object. If using fromCommunicatorEvent, pass the
|
|
36
|
+
* event name and handler. Key events: configuratorDataUpdated, viewportReady, screenshotReady, showcaseStatusChanged,
|
|
37
|
+
* getCameraResult. Always subscribe BEFORE sending commands that trigger responses.
|
|
38
|
+
*
|
|
39
|
+
* @param {Communicator} target - The Communicator instance to listen on.
|
|
40
|
+
* @param {T} eventName - The event name from {@link FromMetaBoxApiEvents} to subscribe to.
|
|
41
|
+
* @returns An Observable that emits the typed payload each time the event fires.
|
|
16
42
|
* @internal
|
|
17
43
|
*/
|
|
18
44
|
function fromCommunicatorEvent(target, eventName) {
|
|
19
45
|
return fromEvent(target, eventName);
|
|
20
46
|
}
|
|
21
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Registry of all action identifiers that can be sent from the host application to the Metabox Basic Configurator.
|
|
50
|
+
* Each key maps to a string used as the `action` field in the postMessage envelope.
|
|
51
|
+
*
|
|
52
|
+
* ### What does it unlock?
|
|
53
|
+
* Variable containing all available action names. Interface listing all actions that the configurator supports.
|
|
54
|
+
*
|
|
55
|
+
* ### Practical Application
|
|
56
|
+
* Master action registry object — all supported configurator action names. Invaluable reference for building
|
|
57
|
+
* admin dashboards, permission systems, or feature-availability displays.
|
|
58
|
+
*
|
|
59
|
+
* ### AI Coding Best Practices
|
|
60
|
+
* Iterate this object to dynamically build action dropdowns, command palettes, or feature checklists in admin tools.
|
|
61
|
+
* Each key is an action name, value is its description. Excellent reference for AI coding agents to understand
|
|
62
|
+
* the full command vocabulary available.
|
|
63
|
+
*/
|
|
22
64
|
const MetaboxBasicConfiguratorActions = {
|
|
23
65
|
metaboxConfig: 'metaboxConfig',
|
|
66
|
+
resumeStream: 'resumeStream',
|
|
24
67
|
setEnvironment: 'setEnvironment',
|
|
25
68
|
setEnvironmentMaterialById: 'setEnvironmentMaterialById',
|
|
26
69
|
setProduct: 'setProduct',
|
|
@@ -46,18 +89,27 @@ const MetaboxBasicConfiguratorActions = {
|
|
|
46
89
|
|
|
47
90
|
/**
|
|
48
91
|
* Represents a command to send Metabox Config to Metabox Basic Configurator.
|
|
49
|
-
*
|
|
50
|
-
*
|
|
92
|
+
*
|
|
93
|
+
* ### What does it unlock?
|
|
94
|
+
* Configuration object passed to MetaBox during initialization. Specifies domain, host, standalone mode,
|
|
95
|
+
* and other parameters that control how the configurator behaves.
|
|
96
|
+
*
|
|
97
|
+
* ### Practical Application
|
|
98
|
+
* Internal configuration object auto-sent during initialization. Contains appId and config.
|
|
99
|
+
* DO NOT call directly — integrateMetabox() handles this automatically as part of its setup sequence.
|
|
100
|
+
*
|
|
101
|
+
* ### AI Coding Best Practices
|
|
102
|
+
* NEVER instantiate or send MetaboxConfig manually. It is auto-sent by integrateMetabox().
|
|
103
|
+
* Use the IntegrateMetaboxConfig parameter of integrateMetabox() instead for setting domain, standalone,
|
|
104
|
+
* loadingImage, introImage, state, etc.
|
|
51
105
|
*
|
|
52
106
|
* @internal
|
|
53
107
|
* Automatically sent when the Communicator instance is ready.
|
|
108
|
+
*
|
|
109
|
+
* @param {string} appId - The unique identifier for the Communicator Instance
|
|
110
|
+
* @param {MetaboxCommandConfig} config - optional initial config: standalone - if true - disable metabox custom template and all logic
|
|
54
111
|
*/
|
|
55
112
|
class MetaboxConfig extends CommandBase {
|
|
56
|
-
/**
|
|
57
|
-
* Creates an instance of MetaboxConfig.
|
|
58
|
-
* @param {string} appId - The unique identifier for the Communicator Instance
|
|
59
|
-
* @param {MetaboxCommandConfig} config - optional initial config: standalone - if true - disable metabox custom template and all logic
|
|
60
|
-
*/
|
|
61
113
|
constructor(appId, config) {
|
|
62
114
|
super();
|
|
63
115
|
this.data = {
|
|
@@ -69,26 +121,28 @@ class MetaboxConfig extends CommandBase {
|
|
|
69
121
|
|
|
70
122
|
/**
|
|
71
123
|
* Represents a command to get a PDF from Metabox Basic Configurator.
|
|
72
|
-
* @remarks
|
|
73
124
|
* This class sends a message to the Metabox API to generate a PDF based on the current configuration.
|
|
74
|
-
* **Important**: No need to listen to any events to see changes.
|
|
75
|
-
*
|
|
125
|
+
* **Important**: No need to listen to any events to see changes. Pdf will be downloaded automatically once it's ready.
|
|
126
|
+
*
|
|
127
|
+
* ### What does it unlock?
|
|
128
|
+
* Generates a native MetaBox PDF document. No subscription required — it executes independently.
|
|
129
|
+
*
|
|
130
|
+
* ### Practical Application
|
|
131
|
+
* Generates a branded PDF from the current configurator state server-side. No event subscription needed.
|
|
132
|
+
* Use for B2B quote workflows, downloadable spec sheets, or emailing configured product summaries to prospects.
|
|
133
|
+
*
|
|
134
|
+
* ### AI Coding Best Practices
|
|
135
|
+
* Simply call `api.sendCommandToMetabox(new GetPdf())`. No parameters or event subscription required.
|
|
136
|
+
* The PDF generates inside MetaBox application.
|
|
76
137
|
*
|
|
77
138
|
* @example
|
|
78
139
|
* import { GetPdf, Communicator } from '@3dsource/metabox-front-api';
|
|
79
|
-
*
|
|
80
|
-
* @param {Communicator} api - communicator instance api
|
|
81
140
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
141
|
+
*
|
|
82
142
|
* api.sendCommandToMetabox(new GetPdf());
|
|
83
143
|
* };
|
|
84
144
|
*/
|
|
85
145
|
class GetPdf extends CommandBase {
|
|
86
|
-
/**
|
|
87
|
-
* Creates an instance of GetPdf.
|
|
88
|
-
*
|
|
89
|
-
* @remarks
|
|
90
|
-
* This constructor does not require any parameters.
|
|
91
|
-
*/
|
|
92
146
|
constructor() {
|
|
93
147
|
super();
|
|
94
148
|
this.data = { action: MetaboxBasicConfiguratorActions.getPdf };
|
|
@@ -97,39 +151,37 @@ class GetPdf extends CommandBase {
|
|
|
97
151
|
|
|
98
152
|
/**
|
|
99
153
|
* Represents a command to get a Call To Action Information from Metabox Basic Configurator.
|
|
100
|
-
*
|
|
101
|
-
*
|
|
154
|
+
* This class sends a message to the Metabox API to generate Call To Action information based on the current
|
|
155
|
+
* configuration and sends it to the endpoint URL from the CTA information.
|
|
102
156
|
*
|
|
103
157
|
* To listen for changes after sending this command, listen to the 'ecomConfiguratorDataUpdated' event.
|
|
104
|
-
* //...Assume that the integration is already implemented (only once)
|
|
105
|
-
* @example
|
|
106
|
-
* import { Communicator } from '@3dsource/metabox-front-api';
|
|
107
158
|
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
* @param {EcomConfigurator} data - description for all ecom configurator params
|
|
111
|
-
* api.addEventListener('ecomConfiguratorDataUpdated', (data) => {
|
|
112
|
-
* console.log('Ecom configurator params:', data);
|
|
113
|
-
* });
|
|
114
|
-
* };
|
|
159
|
+
* ### What does it unlock?
|
|
160
|
+
* Retrieves information about call-to-action that were added to the configurator. Requires subscription to receive data.
|
|
115
161
|
*
|
|
116
|
-
*
|
|
162
|
+
* ### Practical Application
|
|
163
|
+
* Triggers the CTA (Call-to-Action) workflow configured in MetaBox admin. The CTA label and callback URL are set in admin.
|
|
164
|
+
* When invoked, MetaBox POSTs the full configuration JSON (including BOM) to your callback URL endpoint, which returns a { redirectUrl }.
|
|
117
165
|
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
166
|
+
* ### AI Coding Best Practices
|
|
167
|
+
* Call only after user completes configuration. Subscribe to ecomConfiguratorDataUpdated to get CTA label/URL for building
|
|
168
|
+
* custom CTA buttons in your UI. The POST payload includes the full bill of materials — your backend endpoint processes it
|
|
169
|
+
* and returns a redirect URL.
|
|
120
170
|
*
|
|
121
|
-
* @
|
|
171
|
+
* @example
|
|
172
|
+
* import { Communicator, EcomConfigurator,GetCallToActionInformation } from '@3dsource/metabox-front-api';
|
|
122
173
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
174
|
+
*
|
|
175
|
+
* //Subscribe to the event before sending the command to ensure you capture the response
|
|
176
|
+
* api.addEventListener('ecomConfiguratorDataUpdated', (data:EcomConfigurator) => {
|
|
177
|
+
* console.log('Ecom configurator params:', data);
|
|
178
|
+
* });
|
|
179
|
+
*
|
|
180
|
+
* Send the command to get Call To Action information from Metabox Basic Configurator
|
|
123
181
|
* api.sendCommandToMetabox(new GetCallToActionInformation());
|
|
124
182
|
* };
|
|
125
183
|
*/
|
|
126
184
|
class GetCallToActionInformation extends CommandBase {
|
|
127
|
-
/**
|
|
128
|
-
* Creates an instance of GetCallToActionInformation.
|
|
129
|
-
*
|
|
130
|
-
* @remarks
|
|
131
|
-
* This constructor does not require any parameters.
|
|
132
|
-
*/
|
|
133
185
|
constructor() {
|
|
134
186
|
super();
|
|
135
187
|
this.data = {
|
|
@@ -140,38 +192,35 @@ class GetCallToActionInformation extends CommandBase {
|
|
|
140
192
|
|
|
141
193
|
/**
|
|
142
194
|
* Represents a command to get the camera configuration from Unreal.
|
|
143
|
-
* @remarks
|
|
144
195
|
* This class sends a message to the Metabox API to get the camera from a scene.
|
|
145
|
-
*
|
|
146
196
|
* To listen for changes after sending this command, listen to the 'getCameraResult' event.
|
|
147
|
-
* //...Assume that the integration is already implemented (only once)
|
|
148
|
-
* @example
|
|
149
|
-
* import { Communicator } from '@3dsource/metabox-front-api';
|
|
150
197
|
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
198
|
+
* ### What does it unlock?
|
|
199
|
+
* Retrieves camera presets for the configurator; allowing extraction and application of saved camera positions.
|
|
200
|
+
*
|
|
201
|
+
* ### Practical Application
|
|
202
|
+
* Requests current camera state — returns asynchronously via the getCameraResult event. Returns a CameraCommandPayload
|
|
203
|
+
* with fov, mode, position, rotation, and restrictions. Use to save camera positions, create shareable view links,
|
|
204
|
+
* or build 'save this angle' features.
|
|
158
205
|
*
|
|
159
|
-
*
|
|
206
|
+
* ### AI Coding Best Practices
|
|
207
|
+
* ALWAYS subscribe to getCameraResult BEFORE calling GetCamera(). Pattern: `api.addEventListener('getCameraResult', handler);`
|
|
208
|
+
* then `api.sendCommandToMetabox(new GetCamera())`. The returned CameraCommandPayload can be fed directly back into
|
|
209
|
+
* SetCamera to restore the view.
|
|
160
210
|
*
|
|
161
211
|
* @example
|
|
162
|
-
* import {
|
|
163
|
-
* @param {Communicator} api - communicator instance api
|
|
212
|
+
* import { Communicator, CameraCommandPayload,GetCamera } from '@3dsource/metabox-front-api';
|
|
164
213
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
214
|
+
*
|
|
215
|
+
* //Subscribe to the event before sending the command to ensure you capture the response
|
|
216
|
+
* api.addEventListener('getCameraResult', (data:CameraCommandPayload) => {
|
|
217
|
+
* console.log('Camera params after get camera command:', data);
|
|
218
|
+
* });
|
|
219
|
+
*
|
|
165
220
|
* api.sendCommandToMetabox(new GetCamera());
|
|
166
221
|
* };
|
|
167
222
|
*/
|
|
168
223
|
class GetCamera extends CommandBase {
|
|
169
|
-
/**
|
|
170
|
-
* Creates an instance of GetCamera.
|
|
171
|
-
*
|
|
172
|
-
* @remarks
|
|
173
|
-
* This constructor does not require any parameters.
|
|
174
|
-
*/
|
|
175
224
|
constructor() {
|
|
176
225
|
super();
|
|
177
226
|
this.data = { action: MetaboxBasicConfiguratorActions.getCamera };
|
|
@@ -180,14 +229,24 @@ class GetCamera extends CommandBase {
|
|
|
180
229
|
|
|
181
230
|
/**
|
|
182
231
|
* Represents a command to set the camera configuration.
|
|
183
|
-
* @remarks
|
|
184
232
|
* This class sends a message to the Metabox API to set the camera on a scene.
|
|
185
233
|
* **Important**: No need to listen to any events to see changes.
|
|
186
|
-
*
|
|
234
|
+
*
|
|
235
|
+
* ### What does it unlock?
|
|
236
|
+
* Sets camera presets with restriction parameters (FOV, rotation, position).
|
|
237
|
+
*
|
|
238
|
+
* ### Practical Application
|
|
239
|
+
* Sets camera with precise control: fov (degrees), mode ('orbit'|'fps'), position ({x,y,z}),
|
|
240
|
+
* rotation ({horizontal,vertical}), and restrictions (min/max distance, FOV, rotation bounds).
|
|
241
|
+
* Use for guided tours, preset view buttons, or restricting camera to prevent users seeing behind the product.
|
|
242
|
+
*
|
|
243
|
+
* ### AI Coding Best Practices
|
|
244
|
+
* Only include fields you want to change — omitted values keep current settings. Use orbit mode for typical product viewing,
|
|
245
|
+
* fps for walkthrough/room scenes. Apply restrictions to prevent bad angles. Full interface:
|
|
246
|
+
* `{fov?, mode?, position?, rotation?, restrictions?}`.
|
|
187
247
|
*
|
|
188
248
|
* @example
|
|
189
249
|
* import { SetCamera, Communicator } from '@3dsource/metabox-front-api';
|
|
190
|
-
* @param {Communicator} api - communicator instance api
|
|
191
250
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
192
251
|
* api.sendCommandToMetabox(new SetCamera({
|
|
193
252
|
* fov: 45,
|
|
@@ -203,16 +262,13 @@ class GetCamera extends CommandBase {
|
|
|
203
262
|
* minFov: 0,
|
|
204
263
|
* minHorizontalRotation: 0,
|
|
205
264
|
* minVerticalRotation: 0,
|
|
206
|
-
*
|
|
265
|
+
* },
|
|
207
266
|
* }));
|
|
208
267
|
* };
|
|
268
|
+
*
|
|
269
|
+
* @param {CameraCommandPayload} camera - The camera configuration.
|
|
209
270
|
*/
|
|
210
271
|
class SetCamera extends CommandBase {
|
|
211
|
-
/**
|
|
212
|
-
* Creates an instance of SetCamera.
|
|
213
|
-
*
|
|
214
|
-
* @param {CameraCommandPayload} camera - The camera configuration.
|
|
215
|
-
*/
|
|
216
272
|
constructor(camera) {
|
|
217
273
|
super();
|
|
218
274
|
this.data = {
|
|
@@ -224,25 +280,26 @@ class SetCamera extends CommandBase {
|
|
|
224
280
|
|
|
225
281
|
/**
|
|
226
282
|
* Represents a command to reset the camera to its initial position.
|
|
227
|
-
* @remarks
|
|
228
283
|
* This class sends a message to the Metabox API to reset the camera on a scene.
|
|
229
|
-
*
|
|
230
|
-
*
|
|
284
|
+
*
|
|
285
|
+
* ### What does it unlock?
|
|
286
|
+
* Resets the camera to its default state and position. Used to return camera to initial configuration after user manipulation.
|
|
287
|
+
*
|
|
288
|
+
* ### Practical Application
|
|
289
|
+
* Resets camera to the default position defined in the product/environment template. Essential for 'Reset View' buttons.
|
|
290
|
+
* Also, useful after programmatic camera moves to return to a known starting state.
|
|
291
|
+
*
|
|
292
|
+
* ### AI Coding Best Practices
|
|
293
|
+
* Call `api.sendCommandToMetabox(new ResetCamera())`. No parameters. Restores template defaults — not the last user position.
|
|
294
|
+
* Good practice to call after SetProduct changes that may shift the focal point.
|
|
231
295
|
*
|
|
232
296
|
* @example
|
|
233
297
|
* import { ResetCamera, Communicator } from '@3dsource/metabox-front-api';
|
|
234
|
-
* @param {Communicator} api - communicator instance api
|
|
235
298
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
236
299
|
* api.sendCommandToMetabox(new ResetCamera());
|
|
237
300
|
* };
|
|
238
301
|
*/
|
|
239
302
|
class ResetCamera extends CommandBase {
|
|
240
|
-
/**
|
|
241
|
-
* Creates an instance of ResetCamera.
|
|
242
|
-
*
|
|
243
|
-
* @remarks
|
|
244
|
-
* This constructor does not require any parameters.
|
|
245
|
-
*/
|
|
246
303
|
constructor() {
|
|
247
304
|
super();
|
|
248
305
|
this.data = { action: MetaboxBasicConfiguratorActions.resetCamera };
|
|
@@ -251,26 +308,30 @@ class ResetCamera extends CommandBase {
|
|
|
251
308
|
|
|
252
309
|
/**
|
|
253
310
|
* Represents a command to apply zoom and change the camera zoom on a scene.
|
|
254
|
-
* @remarks
|
|
255
311
|
* This class sends a command to the Metabox API to change zoom on a scene.
|
|
256
|
-
*
|
|
257
|
-
*
|
|
312
|
+
*
|
|
313
|
+
* ### What does it unlock?
|
|
314
|
+
* Controls zoom functionality for the configurator; allowing users to adjust the zoom level of 3D objects and camera presets.
|
|
315
|
+
*
|
|
316
|
+
* ### Practical Application
|
|
317
|
+
* Implements programmatic zoom on the pixel-streamed viewport. Use to build zoom slider controls, pinch-to-zoom on mobile,
|
|
318
|
+
* or 'zoom to detail' buttons. Takes a numeric delta: positive zooms in, negative zooms out
|
|
319
|
+
* (e.g., ApplyZoom(50) zooms in, ApplyZoom(-50) zooms out).
|
|
320
|
+
*
|
|
321
|
+
* ### AI Coding Best Practices
|
|
322
|
+
* Always use numeric delta values, not absolute zoom levels. Pair with a UI slider that sends incremental values.
|
|
323
|
+
* Debounce zoom input to ~100ms intervals to prevent overwhelming the Unreal stream.
|
|
324
|
+
* Pattern: `api.sendCommandToMetabox(new ApplyZoom(50))`.
|
|
258
325
|
*
|
|
259
326
|
* @example
|
|
260
327
|
* import { ApplyZoom, Communicator } from '@3dsource/metabox-front-api';
|
|
261
|
-
*
|
|
262
|
-
* @param {Communicator} api - communicator instance api
|
|
263
328
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
264
|
-
* api.sendCommandToMetabox(new ApplyZoom(
|
|
265
|
-
* api.sendCommandToMetabox(new ApplyZoom(-10));
|
|
329
|
+
* api.sendCommandToMetabox(new ApplyZoom(50));
|
|
266
330
|
* };
|
|
331
|
+
*
|
|
332
|
+
* @param {number} zoom - The zoom value to apply.
|
|
267
333
|
*/
|
|
268
334
|
class ApplyZoom extends CommandBase {
|
|
269
|
-
/**
|
|
270
|
-
* Creates an instance of ApplyZoom.
|
|
271
|
-
*
|
|
272
|
-
* @param {number} zoom - The zoom value to apply.
|
|
273
|
-
*/
|
|
274
335
|
constructor(zoom) {
|
|
275
336
|
super();
|
|
276
337
|
this.data = {
|
|
@@ -281,54 +342,37 @@ class ApplyZoom extends CommandBase {
|
|
|
281
342
|
}
|
|
282
343
|
|
|
283
344
|
/**
|
|
284
|
-
* Represents a command to initialize Showcase for a product scene and start a sequence for the product.
|
|
285
345
|
* @remarks
|
|
346
|
+
* Represents a command to initialize Showcase for a product scene and start a sequence for the product.
|
|
286
347
|
* This class sends a command to the Metabox API to initialize showcase if the product has a sequence.
|
|
287
348
|
* To check this, find the showcase property in the current product and listen to the 'configuratorDataUpdated' event.
|
|
288
|
-
* //...Assume that the integration is already implemented (only once)
|
|
289
|
-
* @example
|
|
290
|
-
* import { Communicator } from '@3dsource/metabox-front-api';
|
|
291
|
-
*
|
|
292
|
-
* @param {Communicator} api - communicator instance api
|
|
293
|
-
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
294
|
-
* @param {ConfiguratorEnvelope} data - configurator state after updated
|
|
295
|
-
* api.addEventListener('configuratorDataUpdated', (data) => {
|
|
296
|
-
* console.log('State updated after applied new environment:', data);
|
|
297
|
-
* });
|
|
298
|
-
* };
|
|
299
|
-
*
|
|
300
349
|
* If this property exists, you can send the init showcase command.
|
|
301
350
|
*
|
|
302
351
|
* To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event.
|
|
303
|
-
* //...Assume that the integration is already implemented (only once)
|
|
304
|
-
* @example
|
|
305
|
-
* import { Communicator } from '@3dsource/metabox-front-api';
|
|
306
352
|
*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
* @param {ShowCaseStatus} data - showcase status value
|
|
310
|
-
* api.addEventListener('showcaseStatusChanged', (data) => {
|
|
311
|
-
* console.log('Showcase status value after changed:', data);
|
|
312
|
-
* });
|
|
313
|
-
* };
|
|
353
|
+
* ### What does it unlock?
|
|
354
|
+
* Initializes and displays the showcase/demo view for the configurator. Used when transitioning into presentation or demo mode.
|
|
314
355
|
*
|
|
315
|
-
*
|
|
356
|
+
* ### Practical Application
|
|
357
|
+
* Loads the showcase/animation sequence attached to the current product. Must be called BEFORE PlayShowcase.
|
|
358
|
+
* Use to initialize auto-playing product demos, trade show presentations, or hero section animations on landing pages.
|
|
316
359
|
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
360
|
+
* ### AI Coding Best Practices
|
|
361
|
+
* ALWAYS call InitShowcase() before PlayShowcase(). Required sequence: InitShowcase → PlayShowcase → PauseShowcase/StopShowcase.
|
|
362
|
+
* Subscribe to showcaseStatusChanged to track playback state ('playing'/'paused'/'stopped').
|
|
319
363
|
*
|
|
320
|
-
* @
|
|
364
|
+
* @example
|
|
365
|
+
* import { Communicator,ShowCaseStatus,InitShowcase } from '@3dsource/metabox-front-api';
|
|
321
366
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
367
|
+
* //Subscribe to the event before sending the command to ensure you capture the response
|
|
368
|
+
* api.addEventListener('showcaseStatusChanged', (data:ShowCaseStatus) => {
|
|
369
|
+
* console.log('Showcase status value after changed:', data);
|
|
370
|
+
* });
|
|
371
|
+
*
|
|
322
372
|
* api.sendCommandToMetabox(new InitShowcase());
|
|
323
373
|
* };
|
|
324
374
|
*/
|
|
325
375
|
class InitShowcase extends CommandBase {
|
|
326
|
-
/**
|
|
327
|
-
* Creates an instance of InitShowcase.
|
|
328
|
-
*
|
|
329
|
-
* @remarks
|
|
330
|
-
* This constructor does not require any parameters.
|
|
331
|
-
*/
|
|
332
376
|
constructor() {
|
|
333
377
|
super();
|
|
334
378
|
this.data = {
|
|
@@ -339,39 +383,34 @@ class InitShowcase extends CommandBase {
|
|
|
339
383
|
|
|
340
384
|
/**
|
|
341
385
|
* Represents a command to play Showcase for a product when it is already initialized and paused.
|
|
342
|
-
* @remarks
|
|
343
386
|
* This class sends a command to the Metabox API to play showcase for a product if it is already initialized and paused.
|
|
344
387
|
*
|
|
345
388
|
* To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event.
|
|
346
|
-
* //...Assume that the integration is already implemented (only once)
|
|
347
|
-
* @example
|
|
348
|
-
* import { Communicator } from '@3dsource/metabox-front-api';
|
|
349
389
|
*
|
|
350
|
-
*
|
|
390
|
+
* ### What does it unlock?
|
|
391
|
+
* Starts or resumes the showcase/timeline playback. Executes the internal MetaBox play command internally.
|
|
392
|
+
*
|
|
393
|
+
* ### Practical Application
|
|
394
|
+
* Starts or resumes showcase playback. Use for 'Play Demo' buttons on landing pages, auto-play on page load,
|
|
395
|
+
* or resuming demos after inactivity timeout on kiosk displays.
|
|
396
|
+
*
|
|
397
|
+
* ### AI Coding Best Practices
|
|
398
|
+
* Call `api.sendCommandToMetabox(new PlayShowcase())`. Must call InitShowcase() first or it won't play.
|
|
399
|
+
* Subscribe to showcaseStatusChanged to track state. Auto-play pattern: wait for viewportReady → InitShowcase →
|
|
400
|
+
* PlayShowcase.
|
|
401
|
+
*
|
|
402
|
+
* @example
|
|
403
|
+
* import { Communicator,PlayShowcase } from '@3dsource/metabox-front-api';
|
|
351
404
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
352
|
-
*
|
|
405
|
+
* //Subscribe to the event before sending the command to ensure you capture the response
|
|
353
406
|
* api.addEventListener('showcaseStatusChanged', (data) => {
|
|
354
407
|
* console.log('Showcase status value after changed:', data);
|
|
355
408
|
* });
|
|
356
|
-
* };
|
|
357
|
-
*
|
|
358
|
-
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
|
|
359
|
-
*
|
|
360
|
-
* @example
|
|
361
|
-
* import { PlayShowcase, Communicator } from '@3dsource/metabox-front-api';
|
|
362
409
|
*
|
|
363
|
-
* @param {Communicator} api - communicator instance api
|
|
364
|
-
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
365
410
|
* api.sendCommandToMetabox(new PlayShowcase());
|
|
366
411
|
* };
|
|
367
412
|
*/
|
|
368
413
|
class PlayShowcase extends CommandBase {
|
|
369
|
-
/**
|
|
370
|
-
* Creates an instance of PlayShowcase.
|
|
371
|
-
*
|
|
372
|
-
* @remarks
|
|
373
|
-
* This constructor does not require any parameters.
|
|
374
|
-
*/
|
|
375
414
|
constructor() {
|
|
376
415
|
super();
|
|
377
416
|
this.data = { action: MetaboxBasicConfiguratorActions.playShowcase };
|
|
@@ -382,6 +421,8 @@ class PlayShowcase extends CommandBase {
|
|
|
382
421
|
* @internal
|
|
383
422
|
* @hidden
|
|
384
423
|
* Represents a command to send Unreal command.
|
|
424
|
+
*
|
|
425
|
+
* @param {Object} payload - An raw command that will be sent into MetaBox Unreal Application.
|
|
385
426
|
*/
|
|
386
427
|
class UnrealCommand extends CommandBase {
|
|
387
428
|
constructor(payload) {
|
|
@@ -395,39 +436,34 @@ class UnrealCommand extends CommandBase {
|
|
|
395
436
|
|
|
396
437
|
/**
|
|
397
438
|
* Represents a command to pause Showcase for a product when it is already initialized and playing.
|
|
398
|
-
* @remarks
|
|
399
439
|
* This class sends a command to the Metabox API to pause showcase for a product if it is already initialized and playing.
|
|
400
440
|
*
|
|
401
441
|
* To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event.
|
|
402
|
-
* //...Assume that the integration is already implemented (only once)
|
|
403
|
-
* @example
|
|
404
|
-
* import { Communicator } from '@3dsource/metabox-front-api';
|
|
405
442
|
*
|
|
406
|
-
*
|
|
407
|
-
*
|
|
408
|
-
* @param {ShowCaseStatus} data - showcase status value
|
|
409
|
-
* api.addEventListener('showcaseStatusChanged', (data) => {
|
|
410
|
-
* console.log('Showcase status value after changed:', data);
|
|
411
|
-
* });
|
|
412
|
-
* };
|
|
443
|
+
* ### What does it unlock?
|
|
444
|
+
* Pauses the showcase/timeline playback. Can be called independently without requiring any flag parameters.
|
|
413
445
|
*
|
|
414
|
-
*
|
|
446
|
+
* ### Practical Application
|
|
447
|
+
* Pauses showcase animation playback. The showcase remains initialized and can be resumed with
|
|
448
|
+
* PlayShowcase. Use when you need to temporarily freeze the animation (e.g., on a "Pause" button click).
|
|
415
449
|
*
|
|
416
|
-
*
|
|
417
|
-
*
|
|
450
|
+
* ### AI Coding Best Practices
|
|
451
|
+
* Call `api.sendCommandToMetabox(new PauseShowcase())`. No parameters. Subscribe to showcaseStatusChanged
|
|
452
|
+
* to confirm 'pause' state. Use PlayShowcase to resume or StopShowcase to reset.
|
|
418
453
|
*
|
|
419
|
-
* @
|
|
454
|
+
* @example
|
|
455
|
+
* import { Communicator,ShowCaseStatus,PauseShowcase } from '@3dsource/metabox-front-api';
|
|
420
456
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
421
|
-
*
|
|
457
|
+
*
|
|
458
|
+
* //Subscribe to the event before sending the command to ensure you capture the response
|
|
459
|
+
* api.addEventListener('showcaseStatusChanged', (data:ShowCaseStatus) => {
|
|
460
|
+
* console.log('Showcase status value after changed:', data);
|
|
461
|
+
* });
|
|
462
|
+
*
|
|
463
|
+
* api.sendCommandToMetabox(new PauseShowcase());
|
|
422
464
|
* };
|
|
423
465
|
*/
|
|
424
466
|
class PauseShowcase extends CommandBase {
|
|
425
|
-
/**
|
|
426
|
-
* Creates an instance of PauseShowcase.
|
|
427
|
-
*
|
|
428
|
-
* @remarks
|
|
429
|
-
* This constructor does not require any parameters.
|
|
430
|
-
*/
|
|
431
467
|
constructor() {
|
|
432
468
|
super();
|
|
433
469
|
this.data = { action: MetaboxBasicConfiguratorActions.pauseShowcase };
|
|
@@ -436,39 +472,35 @@ class PauseShowcase extends CommandBase {
|
|
|
436
472
|
|
|
437
473
|
/**
|
|
438
474
|
* Represents a command to stop Showcase for a product when it is already initialized, and you want to destroy it.
|
|
439
|
-
* @remarks
|
|
440
475
|
* This class sends a command to the Metabox API to stop showcase for a product if it is already initialized.
|
|
441
476
|
*
|
|
442
477
|
* To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event.
|
|
443
|
-
* //...Assume that the integration is already implemented (only once)
|
|
444
|
-
* @example
|
|
445
|
-
* import { Communicator } from '@3dsource/metabox-front-api';
|
|
446
478
|
*
|
|
447
|
-
*
|
|
448
|
-
*
|
|
449
|
-
* @param {ShowCaseStatus} data - showcase status value
|
|
450
|
-
* api.addEventListener('showcaseStatusChanged', (data) => {
|
|
451
|
-
* console.log('Showcase status value after changed:', data);
|
|
452
|
-
* });
|
|
453
|
-
* };
|
|
479
|
+
* ### What does it unlock?
|
|
480
|
+
* Stops the showcase/timeline playback and closes the showcase mode. Returns to normal configurator view.
|
|
454
481
|
*
|
|
455
|
-
*
|
|
482
|
+
* ### Practical Application
|
|
483
|
+
* Stops showcase playback and exits showcase mode entirely. Returns to normal interactive configurator view.
|
|
484
|
+
* Use for 'Exit Demo' buttons or auto-trigger when the user starts actively configuring the product.
|
|
456
485
|
*
|
|
457
|
-
*
|
|
458
|
-
*
|
|
486
|
+
* ### AI Coding Best Practices
|
|
487
|
+
* Call `api.sendCommandToMetabox(new StopShowcase())`. Fully resets the showcase state. Subscribe to
|
|
488
|
+
* showcaseStatusChanged to confirm 'stopped' status. After stopping, the configurator returns to full
|
|
489
|
+
* interactive mode — re-enable configuration controls.
|
|
459
490
|
*
|
|
460
|
-
* @
|
|
491
|
+
* @example
|
|
492
|
+
* import { Communicator,ShowCaseStatus } from '@3dsource/metabox-front-api';
|
|
461
493
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
462
|
-
*
|
|
494
|
+
*
|
|
495
|
+
* //Subscribe to the event before sending the command to ensure you capture the response
|
|
496
|
+
* api.addEventListener('showcaseStatusChanged', (data:ShowCaseStatus) => {
|
|
497
|
+
* console.log('Showcase status value after changed:', data);
|
|
498
|
+
* });
|
|
499
|
+
*
|
|
500
|
+
* api.sendCommandToMetabox(new StopShowcase());
|
|
463
501
|
* };
|
|
464
502
|
*/
|
|
465
503
|
class StopShowcase extends CommandBase {
|
|
466
|
-
/**
|
|
467
|
-
* Creates an instance of StopShowcase.
|
|
468
|
-
*
|
|
469
|
-
* @remarks
|
|
470
|
-
* This constructor does not require any parameters.
|
|
471
|
-
*/
|
|
472
504
|
constructor() {
|
|
473
505
|
super();
|
|
474
506
|
this.data = { action: MetaboxBasicConfiguratorActions.stopShowcase };
|
|
@@ -477,37 +509,42 @@ class StopShowcase extends CommandBase {
|
|
|
477
509
|
|
|
478
510
|
/**
|
|
479
511
|
* Represents a command to get a screenshot.
|
|
480
|
-
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
|
|
481
512
|
*
|
|
482
|
-
*
|
|
483
|
-
* To listen for changes after sending this command, listen to the 'screenshot' event.
|
|
484
|
-
* //...Assume that the integration is already implemented (only once)
|
|
485
|
-
* @example
|
|
486
|
-
* import { Communicator } from '@3dsource/metabox-front-api';
|
|
513
|
+
* To listen for changes after sending this command, listen to the 'screenshot' event before command is sent.
|
|
487
514
|
*
|
|
488
|
-
*
|
|
515
|
+
* ### What does it unlock?
|
|
516
|
+
* Takes a screenshot on the server side (Unreal Engine) of the 3D scene. Returns high-quality image.
|
|
517
|
+
* Requires subscription to the screenshotReady event to receive the rendered image.
|
|
518
|
+
*
|
|
519
|
+
* ### Practical Application
|
|
520
|
+
* Renders a high-res screenshot on the Unreal Engine server. Takes format ('image/png'|'image/jpeg'|'image/webp')
|
|
521
|
+
* and optional size ({x, y}). Returns base64 data via screenshotReady event. Use for thumbnails, social sharing,
|
|
522
|
+
* saving config snapshots, or attaching images to quotes.
|
|
523
|
+
*
|
|
524
|
+
* ### AI Coding Best Practices
|
|
525
|
+
* Subscribe to screenshotReady BEFORE sending GetScreenshot. Pattern:
|
|
526
|
+
* `api.addEventListener('screenshotReady', (data) => { if(data) saveImage(data, 'name.png'); })`.
|
|
527
|
+
* Specify size for consistent outputs: `new GetScreenshot('image/png', {x:2048, y:2048})`.
|
|
528
|
+
* Use saveImage() helper to convert base64 to downloadable file.
|
|
529
|
+
*
|
|
530
|
+
* @example
|
|
531
|
+
* import { Communicator,saveImage,GetScreenshot } from '@3dsource/metabox-front-api';
|
|
489
532
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
490
|
-
*
|
|
491
|
-
*
|
|
533
|
+
*
|
|
534
|
+
* //Subscribe to the event before sending the command to ensure you capture the response
|
|
535
|
+
* api.addEventListener('screenshot', (data:string) => {
|
|
536
|
+
* // The data is a base64 string of the image. You can use it to display the image or save it as a file.
|
|
492
537
|
* console.log('Get screenshot here:', data);
|
|
493
538
|
* saveImage(data, 'Render.png');
|
|
494
539
|
* });
|
|
495
|
-
* };
|
|
496
540
|
*
|
|
497
|
-
*
|
|
498
|
-
* import { GetScreenshot, Communicator, saveImage } from '@3dsource/metabox-front-api';
|
|
499
|
-
*
|
|
500
|
-
* @param {Communicator} api - communicator instance api
|
|
501
|
-
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
502
|
-
* api.sendCommandToMetabox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));
|
|
541
|
+
* api.sendCommandToMetabox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));
|
|
503
542
|
* };
|
|
543
|
+
*
|
|
544
|
+
* @param {MimeType} mimeType - The output format.
|
|
545
|
+
* @param {{ x: number; y: number }} [size] - Optional size in pixels.
|
|
504
546
|
*/
|
|
505
547
|
class GetScreenshot extends CommandBase {
|
|
506
|
-
/**
|
|
507
|
-
* Constructs an instance of GetScreenshot.
|
|
508
|
-
* @param {MimeType} mimeType - The output format.
|
|
509
|
-
* @param {{ x: number; y: number }} [size] - Optional size in pixels.
|
|
510
|
-
*/
|
|
511
548
|
constructor(mimeType, size) {
|
|
512
549
|
super();
|
|
513
550
|
this.data = {
|
|
@@ -519,39 +556,41 @@ class GetScreenshot extends CommandBase {
|
|
|
519
556
|
|
|
520
557
|
/**
|
|
521
558
|
* Represents a command to set a product by its ID.
|
|
522
|
-
*
|
|
523
|
-
* @remarks
|
|
524
559
|
* This action sends a message to the Metabox API to set a product using the provided product ID.
|
|
525
|
-
*
|
|
526
560
|
* To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.
|
|
527
|
-
* //...Assume that the integration is already implemented (only once)
|
|
528
|
-
* @example
|
|
529
|
-
* import { Communicator } from '@3dsource/metabox-front-api';
|
|
530
561
|
*
|
|
531
|
-
*
|
|
562
|
+
* ### What does it unlock?
|
|
563
|
+
* Sets the active product in the Basic Configurator by its UUID. Triggers a full state update including
|
|
564
|
+
* available materials, slots, showcase data, and environment compatibility.
|
|
565
|
+
*
|
|
566
|
+
* ### Practical Application
|
|
567
|
+
* Selects which product to display in the 3D viewport. Takes a productId (UUID). Use to build product picker UIs,
|
|
568
|
+
* deep-link to specific products, or switch products programmatically based on external catalog selections.
|
|
569
|
+
* The configurator responds with a full ConfiguratorEnvelope via configuratorDataUpdated.
|
|
570
|
+
*
|
|
571
|
+
* ### AI Coding Best Practices
|
|
572
|
+
* Call `api.sendCommandToMetabox(new SetProduct('product-uuid'))`. Get valid product IDs from
|
|
573
|
+
* `configurator.products` in the configuratorDataUpdated envelope. Subscribe to configuratorDataUpdated
|
|
574
|
+
* BEFORE sending the command. After switching products, material and environment selections may reset —
|
|
575
|
+
* re-apply them if needed.
|
|
576
|
+
*
|
|
577
|
+
* @example
|
|
578
|
+
* import { Communicator,ConfiguratorEnvelope } from '@3dsource/metabox-front-api';
|
|
532
579
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
533
|
-
*
|
|
534
|
-
*
|
|
580
|
+
*
|
|
581
|
+
* //Subscribe to the event before sending the command to ensure you capture the response
|
|
582
|
+
* api.addEventListener('configuratorDataUpdated', (data:ConfiguratorEnvelope) => {
|
|
535
583
|
* console.log('State updated after applied new product:', data);
|
|
536
584
|
* });
|
|
537
|
-
* };
|
|
538
585
|
*
|
|
539
|
-
*
|
|
540
|
-
* import { SetProduct, Communicator } from '@3dsource/metabox-front-api';
|
|
541
|
-
*
|
|
542
|
-
* @param {Communicator} api - communicator instance api
|
|
543
|
-
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
544
|
-
* api.setCommandToMetaBox(new SetProduct(
|
|
586
|
+
* api.sendCommandToMetabox(new SetProduct(
|
|
545
587
|
* 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3'
|
|
546
588
|
* ));
|
|
547
589
|
* };
|
|
590
|
+
*
|
|
591
|
+
* @param {string} productId - The product ID.
|
|
548
592
|
*/
|
|
549
593
|
class SetProduct extends CommandBase {
|
|
550
|
-
/**
|
|
551
|
-
* Creates an instance of SetProduct.
|
|
552
|
-
*
|
|
553
|
-
* @param {string} productId - The product ID.
|
|
554
|
-
*/
|
|
555
594
|
constructor(productId) {
|
|
556
595
|
super();
|
|
557
596
|
this.data = {
|
|
@@ -563,40 +602,41 @@ class SetProduct extends CommandBase {
|
|
|
563
602
|
|
|
564
603
|
/**
|
|
565
604
|
* Represents a command to set a material by its slot ID and Material ID.
|
|
566
|
-
*
|
|
567
|
-
* @remarks
|
|
568
605
|
* To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.
|
|
569
|
-
* //...Assume that the integration is already implemented (only once)
|
|
570
606
|
*
|
|
571
|
-
*
|
|
572
|
-
*
|
|
607
|
+
* ### What does it unlock?
|
|
608
|
+
* Sets a material variant for a product slot. Simulates selecting a different material/finish from the menu
|
|
609
|
+
* for a specific customizable surface on the product.
|
|
610
|
+
*
|
|
611
|
+
* ### Practical Application
|
|
612
|
+
* Applies a material to a specific slot on the active product. Takes slotId (string) and materialId (UUID).
|
|
613
|
+
* Use to build swatch pickers, apply preset themes/bundles, or sync material selections from an external
|
|
614
|
+
* PIM/ERP system via externalId mapping.
|
|
615
|
+
*
|
|
616
|
+
* ### AI Coding Best Practices
|
|
617
|
+
* Get valid slotId and materialId values from the product's slot definitions in the configuratorDataUpdated envelope —
|
|
618
|
+
* check `product.slots` and each slot's `enabledMaterials` list. Pattern:
|
|
619
|
+
* `new SetProductMaterial('slot-name', 'material-uuid')`. The referenced product must already be set.
|
|
573
620
|
*
|
|
574
|
-
* @
|
|
621
|
+
* @example
|
|
622
|
+
* import { Communicator,ConfiguratorEnvelope,SetProductMaterial } from '@3dsource/metabox-front-api';
|
|
575
623
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
576
|
-
*
|
|
577
|
-
*
|
|
624
|
+
*
|
|
625
|
+
* //Subscribe to the event before sending the command to ensure you capture the response
|
|
626
|
+
* api.addEventListener('configuratorDataUpdated', (data:ConfiguratorEnvelope) => {
|
|
578
627
|
* console.log('State updated after applied new material:', data);
|
|
579
628
|
* });
|
|
580
|
-
* };
|
|
581
629
|
*
|
|
582
|
-
*
|
|
583
|
-
* import { SetProductMaterial, Communicator } from '@3dsource/metabox-front-api';
|
|
584
|
-
*
|
|
585
|
-
* @param {Communicator} api - communicator instance api
|
|
586
|
-
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
587
|
-
* api.sendCommandToMetabox(new SetProductMaterial(
|
|
630
|
+
* api.sendCommandToMetabox(new SetProductMaterial(
|
|
588
631
|
* 'carpaint',
|
|
589
632
|
* 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
|
|
590
633
|
* ));
|
|
591
634
|
* };
|
|
635
|
+
*
|
|
636
|
+
* @param {string} slotId - The slot ID.
|
|
637
|
+
* @param {string} materialId - The material ID.
|
|
592
638
|
*/
|
|
593
639
|
class SetProductMaterial extends CommandBase {
|
|
594
|
-
/**
|
|
595
|
-
* Creates an instance of SetProductMaterial.
|
|
596
|
-
*
|
|
597
|
-
* @param {string} slotId - The slot ID.
|
|
598
|
-
* @param {string} materialId - The material ID.
|
|
599
|
-
*/
|
|
600
640
|
constructor(slotId, materialId) {
|
|
601
641
|
super();
|
|
602
642
|
this.data = {
|
|
@@ -608,35 +648,35 @@ class SetProductMaterial extends CommandBase {
|
|
|
608
648
|
|
|
609
649
|
/**
|
|
610
650
|
* Represents a command to set the environment by its ID.
|
|
611
|
-
*
|
|
612
|
-
* @remarks
|
|
613
651
|
* To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.
|
|
614
|
-
* //...Assume that the integration is already implemented (only once)
|
|
615
|
-
* @example
|
|
616
|
-
* import { Communicator } from '@3dsource/metabox-front-api';
|
|
617
652
|
*
|
|
618
|
-
*
|
|
653
|
+
* ### What does it unlock?
|
|
654
|
+
* Sets environmental/lighting settings for the scene. Controls factors like lighting conditions and environmental appearance.
|
|
655
|
+
*
|
|
656
|
+
* ### Practical Application
|
|
657
|
+
* Changes the 3D scene/environment (studio, showroom, outdoor, etc.). Takes an environmentId UUID.
|
|
658
|
+
* Environments include lighting, backdrop, and optionally dynamic sky (udsEnabled) with time-of-day (udsHour) control.
|
|
659
|
+
*
|
|
660
|
+
* ### AI Coding Best Practices
|
|
661
|
+
* Call `api.sendCommandToMetabox(new SetEnvironment('env-uuid'))`. Get valid environment IDs from the configurator
|
|
662
|
+
* definition in configuratorDataUpdated. Set environment after product during initialization. Each environment has
|
|
663
|
+
* its own material slots, thumbnails, and lighting properties.
|
|
664
|
+
*
|
|
665
|
+
* @example
|
|
666
|
+
* import { Communicator,ConfiguratorEnvelope } from '@3dsource/metabox-front-api';
|
|
619
667
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
620
|
-
*
|
|
621
|
-
*
|
|
668
|
+
*
|
|
669
|
+
* //Subscribe to the event before sending the command to ensure you capture the response
|
|
670
|
+
* api.addEventListener('configuratorDataUpdated', (data:ConfiguratorEnvelope) => {
|
|
622
671
|
* console.log('State updated after applied new environment:', data);
|
|
623
672
|
* });
|
|
624
|
-
* };
|
|
625
673
|
*
|
|
626
|
-
*
|
|
627
|
-
* import { SetEnvironment, Communicator } from '@3dsource/metabox-front-api';
|
|
628
|
-
*
|
|
629
|
-
* @param {Communicator} api - communicator instance api
|
|
630
|
-
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
631
|
-
* api.sendCommandToMetabox(new SetEnvironment('55555555-1234-1234-1234-01234567890'));
|
|
674
|
+
* api.sendCommandToMetabox(new SetEnvironment('55555555-1234-1234-1234-01234567890'))
|
|
632
675
|
* };
|
|
676
|
+
*
|
|
677
|
+
* @param {string} environmentId - The environment ID.
|
|
633
678
|
*/
|
|
634
679
|
class SetEnvironment extends CommandBase {
|
|
635
|
-
/**
|
|
636
|
-
* Creates an instance of SetEnvironment.
|
|
637
|
-
*
|
|
638
|
-
* @param {string} environmentId - The environment ID.
|
|
639
|
-
*/
|
|
640
680
|
constructor(environmentId) {
|
|
641
681
|
super();
|
|
642
682
|
this.data = {
|
|
@@ -648,39 +688,40 @@ class SetEnvironment extends CommandBase {
|
|
|
648
688
|
|
|
649
689
|
/**
|
|
650
690
|
* Represents a command to set an environment material by its slot ID and Material ID.
|
|
651
|
-
*
|
|
652
|
-
* @remarks
|
|
653
691
|
* To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.
|
|
654
|
-
* //...Assume that the integration is already implemented (only once)
|
|
655
|
-
* @example
|
|
656
|
-
* import { Communicator } from '@3dsource/metabox-front-api';
|
|
657
692
|
*
|
|
658
|
-
*
|
|
693
|
+
* ### What does it unlock?
|
|
694
|
+
* Sets environmental material properties such as textures and appearance attributes for the scene environment.
|
|
695
|
+
*
|
|
696
|
+
* ### Practical Application
|
|
697
|
+
* Applies materials to environment slots (floor, walls, backdrop textures). Takes slotId and materialId.
|
|
698
|
+
* Use for scene-based configurators where the environment is also customizable — kitchen visualizers,
|
|
699
|
+
* room planners, trade show booth designers.
|
|
700
|
+
*
|
|
701
|
+
* ### AI Coding Best Practices
|
|
702
|
+
* Pattern: `new SetEnvironmentMaterial('floor-slot-id', 'material-uuid')`. Get valid slot and material IDs from
|
|
703
|
+
* the environment definition's slots array in configuratorDataUpdated. Only useful when the active environment
|
|
704
|
+
* has configurable material slots.
|
|
705
|
+
*
|
|
706
|
+
* @example
|
|
707
|
+
* import { Communicator,ConfiguratorEnvelope } from '@3dsource/metabox-front-api';
|
|
659
708
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
660
|
-
*
|
|
661
|
-
*
|
|
709
|
+
*
|
|
710
|
+
* //Subscribe to the event before sending the command to ensure you capture the response
|
|
711
|
+
* api.addEventListener('configuratorDataUpdated', (data:ConfiguratorEnvelope) => {
|
|
662
712
|
* console.log('State updated after applied new environment material:', data);
|
|
663
713
|
* });
|
|
664
|
-
* };
|
|
665
|
-
*
|
|
666
|
-
* @example
|
|
667
|
-
* import { SetEnvironmentMaterial, Communicator } from '@3dsource/metabox-front-api';
|
|
668
714
|
*
|
|
669
|
-
*
|
|
670
|
-
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
671
|
-
* api.sendCommandToMetabox(new SetEnvironmentMaterial(
|
|
715
|
+
* api.sendCommandToMetabox(new SetEnvironmentMaterial(
|
|
672
716
|
* 'carpaint',
|
|
673
717
|
* 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
|
|
674
718
|
* ));
|
|
675
719
|
* };
|
|
720
|
+
*
|
|
721
|
+
* @param {string} slotId - The slot ID.
|
|
722
|
+
* @param {string} materialId - The material ID.
|
|
676
723
|
*/
|
|
677
724
|
class SetEnvironmentMaterial extends CommandBase {
|
|
678
|
-
/**
|
|
679
|
-
* Creates an instance of SetEnvironmentMaterial.
|
|
680
|
-
*
|
|
681
|
-
* @param {string} slotId - The slot ID.
|
|
682
|
-
* @param {string} materialId - The material ID.
|
|
683
|
-
*/
|
|
684
725
|
constructor(slotId, materialId) {
|
|
685
726
|
super();
|
|
686
727
|
this.data = {
|
|
@@ -692,24 +733,30 @@ class SetEnvironmentMaterial extends CommandBase {
|
|
|
692
733
|
|
|
693
734
|
/**
|
|
694
735
|
* Represents a command to toggle the embedded Metabox menu.
|
|
695
|
-
* @remarks
|
|
696
736
|
* This command can only be used when using the metabox menu.
|
|
697
|
-
*
|
|
737
|
+
*
|
|
738
|
+
* ### What does it unlock?
|
|
739
|
+
* Shows the embedded menu interface. Only works when using the MetaBox native menu (not in standalone/custom menu
|
|
740
|
+
* mode).
|
|
741
|
+
*
|
|
742
|
+
* ### Practical Application
|
|
743
|
+
* Toggles the native MetaBox right sidebar menu. Takes a boolean parameter. Pass false to hide when building custom UI.
|
|
744
|
+
* In standalone mode, the menu is already hidden — this is only relevant in default (non-standalone) mode.
|
|
745
|
+
*
|
|
746
|
+
* ### AI Coding Best Practices
|
|
747
|
+
* In standalone mode (`{standalone:true}`), this is unnecessary (menu already hidden). In default mode,
|
|
748
|
+
* call `new ShowEmbeddedMenu(false)` early in initialization to hide built-in UI before rendering custom controls.
|
|
749
|
+
* Pattern for custom UI: `ShowEmbeddedMenu(false)` + `ShowOverlayInterface(false)`.
|
|
698
750
|
*
|
|
699
751
|
* @example
|
|
700
752
|
* import { ShowEmbeddedMenu, Communicator } from '@3dsource/metabox-front-api';
|
|
701
|
-
*
|
|
702
|
-
* @param {Communicator} api - communicator instance api
|
|
703
753
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
704
754
|
* api.sendCommandToMetabox(new ShowEmbeddedMenu(true));
|
|
705
755
|
* };
|
|
756
|
+
*
|
|
757
|
+
* @param {boolean} visible - A flag indicating whether the embedded menu should be visible.
|
|
706
758
|
*/
|
|
707
759
|
class ShowEmbeddedMenu extends CommandBase {
|
|
708
|
-
/**
|
|
709
|
-
* Creates an instance of ShowEmbeddedMenu.
|
|
710
|
-
*
|
|
711
|
-
* @param {boolean} visible - A flag indicating whether the embedded menu should be visible.
|
|
712
|
-
*/
|
|
713
760
|
constructor(visible) {
|
|
714
761
|
super();
|
|
715
762
|
this.data = {
|
|
@@ -721,25 +768,30 @@ class ShowEmbeddedMenu extends CommandBase {
|
|
|
721
768
|
|
|
722
769
|
/**
|
|
723
770
|
* Represents a command to toggle the Unreal Overlay Interface Menu.
|
|
724
|
-
*
|
|
725
|
-
* @remarks
|
|
726
771
|
* This action sends a message to the Metabox API to toggle the visibility of the Unreal overlay UI.
|
|
727
|
-
*
|
|
772
|
+
*
|
|
773
|
+
* ### What does it unlock?
|
|
774
|
+
* Shows the overlay interface elements. Displays UI controls and buttons overlaid on the 3D scene.
|
|
775
|
+
*
|
|
776
|
+
* ### Practical Application
|
|
777
|
+
* Toggles viewport overlay controls (buttons overlaid on the 3D scene). Takes a boolean.
|
|
778
|
+
* Use `ShowOverlayInterface(false)` alongside `ShowEmbeddedMenu(false)` when building fully custom UI
|
|
779
|
+
* that replaces all native MetaBox controls.
|
|
780
|
+
*
|
|
781
|
+
* ### AI Coding Best Practices
|
|
782
|
+
* In standalone mode, overlays are already hidden. In default mode, call `new ShowOverlayInterface(false)`
|
|
783
|
+
* early in initialization to prevent flash of native UI. Always pair with `ShowEmbeddedMenu(false)` for clean custom UI.
|
|
784
|
+
* Pass true to restore if entering a mode that uses native controls.
|
|
728
785
|
*
|
|
729
786
|
* @example
|
|
730
787
|
* import { ShowOverlayInterface, Communicator } from '@3dsource/metabox-front-api';
|
|
731
|
-
*
|
|
732
|
-
* @param {Communicator} api - communicator instance api
|
|
733
788
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
734
|
-
* api.
|
|
789
|
+
* api.sendCommandToMetabox(new ShowOverlayInterface(true));
|
|
735
790
|
* };
|
|
791
|
+
*
|
|
792
|
+
* @param {boolean} visible - A flag indicating whether the Unreal overlay UI should be visible.
|
|
736
793
|
*/
|
|
737
794
|
class ShowOverlayInterface extends CommandBase {
|
|
738
|
-
/**
|
|
739
|
-
* Creates an instance of ShowOverlayInterface.
|
|
740
|
-
*
|
|
741
|
-
* @param {boolean} visible - A flag indicating whether the Unreal overlay UI should be visible.
|
|
742
|
-
*/
|
|
743
795
|
constructor(visible) {
|
|
744
796
|
super();
|
|
745
797
|
this.data = {
|
|
@@ -751,26 +803,26 @@ class ShowOverlayInterface extends CommandBase {
|
|
|
751
803
|
|
|
752
804
|
/**
|
|
753
805
|
* Represents a command to show measurement for a product when it is already loaded.
|
|
754
|
-
* @remarks
|
|
755
806
|
* This class sends a command to the Metabox API to show measurement for a product if it is already initialized.
|
|
756
|
-
*
|
|
757
|
-
*
|
|
807
|
+
*
|
|
808
|
+
* ### What does it unlock?
|
|
809
|
+
* Shows the measurement overlay. Works as a toggle with HideMeasurement to control visibility.
|
|
810
|
+
*
|
|
811
|
+
* ### Practical Application
|
|
812
|
+
* Shows the measurement/dimension overlay tools on the 3D viewport. Use for B2B or technical applications
|
|
813
|
+
* where buyers need to verify product dimensions, check fit specifications, or confirm measurements during procurement.
|
|
814
|
+
*
|
|
815
|
+
* ### AI Coding Best Practices
|
|
816
|
+
* Call `api.sendCommandToMetabox(new ShowMeasurement())`. No parameters. Pair with HideMeasurement for toggle behavior.
|
|
817
|
+
* Track visibility state in your app to keep toggle buttons in sync.
|
|
758
818
|
*
|
|
759
819
|
* @example
|
|
760
820
|
* import { ShowMeasurement, Communicator } from '@3dsource/metabox-front-api';
|
|
761
|
-
*
|
|
762
|
-
* @param {Communicator} api - communicator instance api
|
|
763
821
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
764
822
|
* api.sendCommandToMetabox(new ShowMeasurement());
|
|
765
823
|
* };
|
|
766
824
|
*/
|
|
767
825
|
class ShowMeasurement extends CommandBase {
|
|
768
|
-
/**
|
|
769
|
-
* Creates an instance of ShowMeasurement.
|
|
770
|
-
*
|
|
771
|
-
* @remarks
|
|
772
|
-
* This constructor does not require any parameters.
|
|
773
|
-
*/
|
|
774
826
|
constructor() {
|
|
775
827
|
super();
|
|
776
828
|
this.data = { action: MetaboxBasicConfiguratorActions.showMeasurement };
|
|
@@ -779,26 +831,26 @@ class ShowMeasurement extends CommandBase {
|
|
|
779
831
|
|
|
780
832
|
/**
|
|
781
833
|
* Represents a command to hide measurement for a product when it is already loaded.
|
|
782
|
-
* @remarks
|
|
783
834
|
* This class sends a command to the Metabox API to hide measurement for a product if it is already initialized.
|
|
784
|
-
*
|
|
785
|
-
*
|
|
835
|
+
*
|
|
836
|
+
* ### What does it unlock?
|
|
837
|
+
* Hides the measurement overlay. Executes unconditionally to hide the UI controls.
|
|
838
|
+
*
|
|
839
|
+
* ### Practical Application
|
|
840
|
+
* Hides the measurement/dimension overlay. Use when transitioning from a technical spec view back to a clean
|
|
841
|
+
* product presentation, or to keep consumer-facing configurators visually clean.
|
|
842
|
+
*
|
|
843
|
+
* ### AI Coding Best Practices
|
|
844
|
+
* Call `api.sendCommandToMetabox(new HideMeasurement())`. No parameters. Pair with ShowMeasurement as a toggle.
|
|
845
|
+
* Track visibility state in your app state to keep toggle buttons in sync.
|
|
786
846
|
*
|
|
787
847
|
* @example
|
|
788
848
|
* import { HideMeasurement, Communicator } from '@3dsource/metabox-front-api';
|
|
789
|
-
*
|
|
790
|
-
* @param {Communicator} api - communicator instance api
|
|
791
849
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
792
850
|
* api.sendCommandToMetabox(new HideMeasurement());
|
|
793
851
|
* };
|
|
794
852
|
*/
|
|
795
853
|
class HideMeasurement extends CommandBase {
|
|
796
|
-
/**
|
|
797
|
-
* Creates an instance of HideMeasurement.
|
|
798
|
-
*
|
|
799
|
-
* @remarks
|
|
800
|
-
* This constructor does not require any parameters.
|
|
801
|
-
*/
|
|
802
854
|
constructor() {
|
|
803
855
|
super();
|
|
804
856
|
this.data = { action: MetaboxBasicConfiguratorActions.hideMeasurement };
|
|
@@ -807,26 +859,29 @@ class HideMeasurement extends CommandBase {
|
|
|
807
859
|
|
|
808
860
|
/**
|
|
809
861
|
* Represents a command to force set the device type.
|
|
810
|
-
*
|
|
811
|
-
* @remarks
|
|
812
862
|
* This class sends a message to the Metabox API to force set the device type.
|
|
813
|
-
*
|
|
814
|
-
*
|
|
863
|
+
*
|
|
864
|
+
* ### What does it unlock?
|
|
865
|
+
* Forces the specification of device type (desktop or mobile) for the MetaBox configurator. Possibly deprecated.
|
|
866
|
+
*
|
|
867
|
+
* ### Practical Application
|
|
868
|
+
* Forces device type override (desktop/tablet/mobile). Likely deprecated — MetaBox auto-detects via ApplicationDeviceTypes.
|
|
869
|
+
* Only relevant for kiosk or showroom setups where you need to force a specific rendering mode.
|
|
870
|
+
*
|
|
871
|
+
* ### AI Coding Best Practices
|
|
872
|
+
* Avoid unless you have a confirmed kiosk/showroom use case. If needed, set it once during initialization only.
|
|
873
|
+
* Prefer letting MetaBox handle device detection automatically.
|
|
815
874
|
*
|
|
816
875
|
* @example
|
|
817
876
|
* import { ForceSetDeviceType, Communicator } from '@3dsource/metabox-front-api';
|
|
818
877
|
*
|
|
819
|
-
* @param {Communicator} api - communicator instance api
|
|
820
878
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
821
879
|
* api.sendCommandToMetabox(new ForceSetDeviceType('desktop'));
|
|
822
880
|
* };
|
|
881
|
+
*
|
|
882
|
+
* @param {ApplicationDeviceTypes} deviceType - The device type to force set.
|
|
823
883
|
*/
|
|
824
884
|
class ForceSetDeviceType extends CommandBase {
|
|
825
|
-
/**
|
|
826
|
-
* Creates an instance of ForceSetDeviceType.
|
|
827
|
-
*
|
|
828
|
-
* @param {ApplicationDeviceTypes} deviceType - The device type to force set.
|
|
829
|
-
*/
|
|
830
885
|
constructor(deviceType) {
|
|
831
886
|
super();
|
|
832
887
|
this.data = {
|
|
@@ -836,8 +891,47 @@ class ForceSetDeviceType extends CommandBase {
|
|
|
836
891
|
}
|
|
837
892
|
}
|
|
838
893
|
|
|
894
|
+
/**
|
|
895
|
+
* Represents a command to resume the pixel streaming session.
|
|
896
|
+
* This class sends a message to the Metabox API to resume a paused or disconnected stream.
|
|
897
|
+
*
|
|
898
|
+
* ### What does it unlock?
|
|
899
|
+
* Resumes the Unreal Engine pixel streaming connection after it has been paused, disconnected, or stopped due to inactivity (AFK timeout).
|
|
900
|
+
*
|
|
901
|
+
* ### Practical Application
|
|
902
|
+
* Used to reconnect the 3D streaming session without a full page reload. Essential for 'Reconnect' or 'Resume' buttons
|
|
903
|
+
* shown when the stream is interrupted, e.g., after an idle timeout or network disruption.
|
|
904
|
+
*
|
|
905
|
+
* ### AI Coding Best Practices
|
|
906
|
+
* Call `api.sendCommandToMetabox(new ResumeStream())`. No parameters. Resumes the existing streaming session —
|
|
907
|
+
* does not reinitialize the configurator or reset product/environment state.
|
|
908
|
+
*
|
|
909
|
+
* @example
|
|
910
|
+
* import { ResumeStream, Communicator } from '@3dsource/metabox-front-api';
|
|
911
|
+
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
912
|
+
* api.sendCommandToMetabox(new ResumeStream());
|
|
913
|
+
* };
|
|
914
|
+
*/
|
|
915
|
+
class ResumeStream extends CommandBase {
|
|
916
|
+
constructor() {
|
|
917
|
+
super();
|
|
918
|
+
this.data = { action: MetaboxBasicConfiguratorActions.resumeStream };
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
|
|
839
922
|
/**
|
|
840
923
|
* EventDispatcher is a class that manages event listeners and dispatches events to them.
|
|
924
|
+
*
|
|
925
|
+
* ### What does it unlock?
|
|
926
|
+
* Parent class of Communicator that dispatches commands. Acts as an event dispatcher that routes command messages internally.
|
|
927
|
+
*
|
|
928
|
+
* ### Practical Application
|
|
929
|
+
* Internal event routing layer — parent class of Communicator. Routes postMessage commands between your app
|
|
930
|
+
* and the Unreal Engine pixel stream. Not used directly but understanding it helps debug message delivery issues.
|
|
931
|
+
*
|
|
932
|
+
* ### AI Coding Best Practices
|
|
933
|
+
* Do not reference or extend EventDispatcher in application code. Use only the Communicator interface methods.
|
|
934
|
+
* If debugging communication failures, check browser console for postMessage errors related to this layer.
|
|
841
935
|
*/
|
|
842
936
|
class EventDispatcher {
|
|
843
937
|
constructor() {
|
|
@@ -846,6 +940,10 @@ class EventDispatcher {
|
|
|
846
940
|
*/
|
|
847
941
|
this.listeners = [];
|
|
848
942
|
}
|
|
943
|
+
/**
|
|
944
|
+
* Removes all registered listeners. Subclasses override this to perform additional cleanup.
|
|
945
|
+
* @param key - Instance key (used by subclass overrides for registry cleanup).
|
|
946
|
+
*/
|
|
849
947
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
850
948
|
destroy(key) {
|
|
851
949
|
this.listeners = [];
|
|
@@ -853,7 +951,7 @@ class EventDispatcher {
|
|
|
853
951
|
/**
|
|
854
952
|
* Adds an event listener for receiving specific types of messages.
|
|
855
953
|
*
|
|
856
|
-
* @param messageType - The message type to listen for.
|
|
954
|
+
* @param {string} messageType - The message type to listen for.
|
|
857
955
|
* @param callback - The callback function to execute when a message is received.
|
|
858
956
|
*/
|
|
859
957
|
addEventListener(messageType, callback) {
|
|
@@ -863,7 +961,7 @@ class EventDispatcher {
|
|
|
863
961
|
/**
|
|
864
962
|
* Dispatches an event to all listeners of a specific message type.
|
|
865
963
|
*
|
|
866
|
-
* @param messageType - The message type.
|
|
964
|
+
* @param {string} messageType - The message type.
|
|
867
965
|
* @param data - The data associated with the event.
|
|
868
966
|
*/
|
|
869
967
|
dispatchEvent(messageType, data) {
|
|
@@ -875,7 +973,7 @@ class EventDispatcher {
|
|
|
875
973
|
/**
|
|
876
974
|
* Removes an event listener for a specific type of message.
|
|
877
975
|
*
|
|
878
|
-
* @param messageType - The message type.
|
|
976
|
+
* @param {string} messageType - The message type.
|
|
879
977
|
* @param callback - The callback function to remove.
|
|
880
978
|
*/
|
|
881
979
|
removeEventListener(messageType, callback) {
|
|
@@ -887,11 +985,89 @@ class EventDispatcher {
|
|
|
887
985
|
/**
|
|
888
986
|
* @internal
|
|
889
987
|
* @hidden
|
|
890
|
-
*
|
|
988
|
+
* Core constants used for host-to-iframe communication and URL construction.
|
|
989
|
+
*/
|
|
990
|
+
/**
|
|
991
|
+
* Storage key for the Metabox Communicator instance registry.
|
|
992
|
+
*
|
|
993
|
+
* ### What does it unlock?
|
|
994
|
+
* Constant string identifier for MetaBox version. Used internally to reference the MetaBox system and versioning.
|
|
995
|
+
*
|
|
996
|
+
* ### Practical Application
|
|
997
|
+
* Internal system reference for versioning.
|
|
998
|
+
* Not needed in front-end application code.
|
|
999
|
+
*
|
|
1000
|
+
* ### AI Coding Best Practices
|
|
1001
|
+
* Skip in application code. This constant is for internal MetaBox system identification only.
|
|
1002
|
+
*
|
|
1003
|
+
* @internal
|
|
1004
|
+
*/
|
|
1005
|
+
const Metabox = 'metabox_v3';
|
|
1006
|
+
/**
|
|
1007
|
+
* Identifier used as the `host` field in postMessage envelopes sent to the iframe.
|
|
1008
|
+
*
|
|
1009
|
+
* ### What does it unlock?
|
|
1010
|
+
* Constant for the MetaBox host connection point. Specifies endpoint for MetaBox connections.
|
|
1011
|
+
*
|
|
1012
|
+
* ### Practical Application
|
|
1013
|
+
* MetaBox endpoint constant. The host the configurator iframe connects to for Unreal Engine pixel streaming.
|
|
1014
|
+
* Not needed in front-end application code.
|
|
1015
|
+
*
|
|
1016
|
+
* ### AI Coding Best Practices
|
|
1017
|
+
* Skip in application code. This constant is for internal MetaBox system identification only.
|
|
1018
|
+
*
|
|
1019
|
+
* @internal
|
|
891
1020
|
*/
|
|
892
|
-
const Metabox = 'metabox';
|
|
893
1021
|
const MetaboxHost = 'metaboxHost';
|
|
1022
|
+
/**
|
|
1023
|
+
* Identifier used as the `host` field in postMessage envelopes received from the iframe.
|
|
1024
|
+
*
|
|
1025
|
+
* ### What does it unlock?
|
|
1026
|
+
* Constant identifier used internally to reference and compare MetaBox data. Used for data validation and internal routing.
|
|
1027
|
+
*
|
|
1028
|
+
* ### Practical Application
|
|
1029
|
+
* Internal data reference constant used for validation and message routing within the communication layer.
|
|
1030
|
+
* Not needed in front-end application code.
|
|
1031
|
+
*
|
|
1032
|
+
* ### AI Coding Best Practices
|
|
1033
|
+
* Skip in application code. Only relevant if debugging very low-level message traffic between your app and the MetaBox iframe.
|
|
1034
|
+
*
|
|
1035
|
+
* @internal
|
|
1036
|
+
*/
|
|
1037
|
+
const MetaboxData = 'metaboxData';
|
|
1038
|
+
/**
|
|
1039
|
+
* Action string dispatched by the iframe when the configurator app has loaded.
|
|
1040
|
+
*
|
|
1041
|
+
* ### What does it unlock?
|
|
1042
|
+
* Indicates when the application has completed initialization.
|
|
1043
|
+
*
|
|
1044
|
+
* ### Practical Application
|
|
1045
|
+
* App initialization flag variable. Signals when MetaBox has completed loading. Use the viewportReady event
|
|
1046
|
+
* (more reliable) to gate your UI rendering — don't show controls until MetaBox confirms it's ready.
|
|
1047
|
+
*
|
|
1048
|
+
* ### AI Coding Best Practices
|
|
1049
|
+
* Prefer the viewportReady event over this variable:
|
|
1050
|
+
* `api.addEventListener('viewportReady', (ready) => { if(ready) enableUI(); })`.
|
|
1051
|
+
* viewportReady with true value is the reliable signal that MetaBox PixelStreaming is become visible.
|
|
1052
|
+
*
|
|
1053
|
+
* @internal
|
|
1054
|
+
*/
|
|
894
1055
|
const AppLoaded = 'appLoaded';
|
|
1056
|
+
/**
|
|
1057
|
+
* Default production domain for the Metabox Basic Configurator.
|
|
1058
|
+
*
|
|
1059
|
+
* ### What does it unlock?
|
|
1060
|
+
* Constant for the standard default MetaBox domain. Used as the primary domain for connecting to MetaBox server.
|
|
1061
|
+
*
|
|
1062
|
+
* ### Practical Application
|
|
1063
|
+
* The base domain used when no override is specified. Override only via IntegrateMetaboxConfig.domain
|
|
1064
|
+
* if connecting to a custom or self-hosted MetaBox instance.
|
|
1065
|
+
*
|
|
1066
|
+
* ### AI Coding Best Practices
|
|
1067
|
+
* Let integrateMetabox() use the default. Override only if needed:
|
|
1068
|
+
* `integrateMetabox(id, container, callback, { domain: 'https://custom.domain.com' })`.
|
|
1069
|
+
* HTTPS is mandatory — HTTP will be rejected.
|
|
1070
|
+
*/
|
|
895
1071
|
/**
|
|
896
1072
|
* @deprecated
|
|
897
1073
|
*/
|
|
@@ -905,13 +1081,42 @@ const MetaboxHost_V3 = 'metaboxHost_v3';
|
|
|
905
1081
|
*/
|
|
906
1082
|
const AppLoaded_V3 = 'appLoaded_v3';
|
|
907
1083
|
const MetaboxDomain = 'metabox.3dsource.com';
|
|
1084
|
+
/**
|
|
1085
|
+
* Base route path appended to the domain when building the configurator iframe URL.
|
|
1086
|
+
*
|
|
1087
|
+
* ### What does it unlock?
|
|
1088
|
+
* Base route URL constant used for loading the configurator. Standard path endpoint for accessing the configurator.
|
|
1089
|
+
*
|
|
1090
|
+
* ### Practical Application
|
|
1091
|
+
* The configurator URL format is: `https://{domain}/metabox-configurator/basic/{configuratorId}`.
|
|
1092
|
+
* Automatically constructed by integrateMetabox().
|
|
1093
|
+
*
|
|
1094
|
+
* ### AI Coding Best Practices
|
|
1095
|
+
* Let integrateMetabox() handle URL construction. Only reference if building URLs manually
|
|
1096
|
+
* (e.g., QR codes, email links, server-side rendering).
|
|
1097
|
+
*/
|
|
908
1098
|
const BasicRouteUrl = 'metabox-configurator/basic';
|
|
909
1099
|
|
|
910
|
-
const VERSION = '3.0.16-dev.
|
|
1100
|
+
const VERSION = '3.0.16-dev.6';
|
|
911
1101
|
|
|
912
1102
|
const communicatorMap = new Map();
|
|
913
1103
|
/**
|
|
914
|
-
* Handles messaging between the host page and embedded
|
|
1104
|
+
* Handles messaging between the host page and embedded Metabox content.
|
|
1105
|
+
*
|
|
1106
|
+
* ### What does it unlock?
|
|
1107
|
+
* Internal class that creates a proxy/communication layer between the API and MetaBox.
|
|
1108
|
+
* Handles reading and sending commands through the established connection.
|
|
1109
|
+
*
|
|
1110
|
+
* ### Practical Application
|
|
1111
|
+
* The API handle returned in the integrateMetabox callback. Provides sendCommandToMetabox() to send commands,
|
|
1112
|
+
* and addEventListener()/removeEventListener() for event subscriptions. This is your entire interface to
|
|
1113
|
+
* the MetaBox Unreal Engine stream.
|
|
1114
|
+
*
|
|
1115
|
+
* ### AI Coding Best Practices
|
|
1116
|
+
* Store the Communicator reference from the apiReadyCallback in a module-scoped variable or state store.
|
|
1117
|
+
* NEVER send commands before this callback fires. All commands and event listeners go through this single
|
|
1118
|
+
* api object. Clean up listeners with removeEventListener on component unmount.
|
|
1119
|
+
*
|
|
915
1120
|
* @internal Use {@link Communicator.createInstance} or the {@link integrateMetabox} helper to instantiate.
|
|
916
1121
|
*/
|
|
917
1122
|
class Communicator extends EventDispatcher {
|
|
@@ -944,7 +1149,7 @@ class Communicator extends EventDispatcher {
|
|
|
944
1149
|
* Listens for Metabox to signal readiness, then initializes communicator.
|
|
945
1150
|
* @param apiReadyCallback - Called with the new Communicator once the Metabox is loaded.
|
|
946
1151
|
* @param {MetaboxEnvironment} environment - The environment in which the Communicator is running.
|
|
947
|
-
* @param {MetaboxCommandConfig} config -
|
|
1152
|
+
* @param {MetaboxCommandConfig} config - optional initial config: standalone - if true - disable metabox custom template and all logic
|
|
948
1153
|
*/
|
|
949
1154
|
static createInstance(apiReadyCallback, environment, config) {
|
|
950
1155
|
const startHandler = (event) => {
|
|
@@ -963,6 +1168,7 @@ class Communicator extends EventDispatcher {
|
|
|
963
1168
|
super.destroy(key);
|
|
964
1169
|
window.removeEventListener('message', this.binder);
|
|
965
1170
|
}
|
|
1171
|
+
/** Destroys all active Communicator instances and clears the internal registry. */
|
|
966
1172
|
static clearAll() {
|
|
967
1173
|
if (communicatorMap.size === 0) {
|
|
968
1174
|
return;
|
|
@@ -970,6 +1176,10 @@ class Communicator extends EventDispatcher {
|
|
|
970
1176
|
communicatorMap.forEach((value, key) => value.instance.destroy(key));
|
|
971
1177
|
communicatorMap.clear();
|
|
972
1178
|
}
|
|
1179
|
+
/**
|
|
1180
|
+
* Retrieves a registered Communicator instance by its key.
|
|
1181
|
+
* @param key - The composite key (`version_environment_appId`) identifying the instance.
|
|
1182
|
+
*/
|
|
973
1183
|
static getCommunicator(key) {
|
|
974
1184
|
return communicatorMap.get(key);
|
|
975
1185
|
}
|
|
@@ -996,6 +1206,8 @@ class Communicator extends EventDispatcher {
|
|
|
996
1206
|
}
|
|
997
1207
|
/**
|
|
998
1208
|
* Registers an event listener for messages dispatched by the Metabox.
|
|
1209
|
+
* @param messageType - The event name to listen for (e.g. `'configuratorDataUpdated'`).
|
|
1210
|
+
* @param callback - Handler invoked with the typed payload when the event fires.
|
|
999
1211
|
* @override
|
|
1000
1212
|
*/
|
|
1001
1213
|
addEventListener(messageType, callback) {
|
|
@@ -1003,6 +1215,8 @@ class Communicator extends EventDispatcher {
|
|
|
1003
1215
|
}
|
|
1004
1216
|
/**
|
|
1005
1217
|
* Dispatches a typed event to all registered listeners.
|
|
1218
|
+
* @param messageType - The event name to dispatch.
|
|
1219
|
+
* @param data - The payload to pass to each listener.
|
|
1006
1220
|
* @override
|
|
1007
1221
|
*/
|
|
1008
1222
|
dispatchEvent(messageType, data) {
|
|
@@ -1010,6 +1224,8 @@ class Communicator extends EventDispatcher {
|
|
|
1010
1224
|
}
|
|
1011
1225
|
/**
|
|
1012
1226
|
* Removes a previously registered event listener.
|
|
1227
|
+
* @param messageType - The event name the listener was registered for.
|
|
1228
|
+
* @param callback - The same function reference that was passed to {@link addEventListener}.
|
|
1013
1229
|
* @override
|
|
1014
1230
|
*/
|
|
1015
1231
|
removeEventListener(messageType, callback) {
|
|
@@ -1029,8 +1245,21 @@ class Communicator extends EventDispatcher {
|
|
|
1029
1245
|
}
|
|
1030
1246
|
|
|
1031
1247
|
/**
|
|
1248
|
+
* Constructs the iframe source URL for the Metabox Basic Configurator.
|
|
1249
|
+
*
|
|
1250
|
+
* ### What does it unlock?
|
|
1251
|
+
* Utility function that prepares the iframe source URL. Constructs the proper URL with parameters
|
|
1252
|
+
* for loading the MetaBox configurator.
|
|
1253
|
+
*
|
|
1254
|
+
* ### Practical Application
|
|
1255
|
+
* Utility function that constructs the iframe source URL with proper parameters.
|
|
1256
|
+
* URL format: `https://{domain}/metabox-configurator/basic/{configuratorId}`.
|
|
1257
|
+
* Called internally by integrateMetabox() — use directly only for manual URL construction.
|
|
1258
|
+
*
|
|
1259
|
+
* ### AI Coding Best Practices
|
|
1260
|
+
* Usually called internally. Use directly only for pre-constructing embed URLs (QR codes, email links,
|
|
1261
|
+
* preview URLs). Verify output is HTTPS. Remember basic configurators use `/basic/` path.
|
|
1032
1262
|
*
|
|
1033
|
-
* @remarks
|
|
1034
1263
|
* @internal
|
|
1035
1264
|
* @hidden
|
|
1036
1265
|
*
|
|
@@ -1060,11 +1289,26 @@ const prepareIframeSrc = (configuratorId, config) => {
|
|
|
1060
1289
|
* Integrates the Metabox Basic Configurator into the page by injecting an iframe and
|
|
1061
1290
|
* initializing a Communicator instance for host-to-iframe messaging.
|
|
1062
1291
|
*
|
|
1063
|
-
* @remarks
|
|
1064
1292
|
* - Builds a secure iframe URL using the provided configuratorId and config options.
|
|
1065
1293
|
* - Ensures the resulting URL uses HTTPS and that the target container exists.
|
|
1066
1294
|
* - Removes any previously embedded iframe with id "embeddedContent" before inserting a new one.
|
|
1067
1295
|
*
|
|
1296
|
+
* ### What does it unlock?
|
|
1297
|
+
* Main initialization function for MetaBox integration. Initializes the configurator, receives an API handle,
|
|
1298
|
+
* and sets up all configurations.
|
|
1299
|
+
*
|
|
1300
|
+
* ### Practical Application
|
|
1301
|
+
* THE entry point function. Creates the configurator iframe, establishes postMessage communication, and returns
|
|
1302
|
+
* the Communicator api handle via callback. Call ONCE per configurator. Params: configuratorId (UUID),
|
|
1303
|
+
* containerId (DOM element ID, default 'embed3DSource'), apiReadyCallback, config (IntegrateMetaboxConfig).
|
|
1304
|
+
*
|
|
1305
|
+
* ### AI Coding Best Practices
|
|
1306
|
+
* Pattern: `integrateMetabox('uuid', 'div-id', (api) => {
|
|
1307
|
+
* setup listeners, then set product, then environment
|
|
1308
|
+
* }, { standalone: true })`.
|
|
1309
|
+
* Ensure container div exists in DOM with non-zero dimensions. HTTPS required.
|
|
1310
|
+
* Inside callback: 1) addEventListener for configuratorDataUpdated, 2) SetProduct, 3) SetEnvironment.
|
|
1311
|
+
*
|
|
1068
1312
|
* @param {string} configuratorId - The Basic Configurator ID (not a full URL). It is appended to
|
|
1069
1313
|
* `https://{domain}/metabox-configurator/basic/{configuratorId}` to form the iframe src.
|
|
1070
1314
|
*
|
|
@@ -1153,10 +1397,22 @@ function integrateMetabox(configuratorId, containerId, apiReadyCallback, config)
|
|
|
1153
1397
|
/**
|
|
1154
1398
|
* Saves an image by triggering a download.
|
|
1155
1399
|
*
|
|
1156
|
-
* @remarks
|
|
1157
1400
|
* This function creates an anchor element, sets its `href` attribute to the provided image URL,
|
|
1158
1401
|
* and triggers a click event to initiate a download with the specified filename.
|
|
1159
1402
|
*
|
|
1403
|
+
* ### What does it unlock?
|
|
1404
|
+
* Main exported function to save images from the configurator. Converts base64 image data to actual image
|
|
1405
|
+
* files and saves them to the local filesystem.
|
|
1406
|
+
*
|
|
1407
|
+
* ### Practical Application
|
|
1408
|
+
* Exported utility function that converts base64 screenshot data (from screenshotReady event) to a downloadable
|
|
1409
|
+
* image file. Handles the base64 → blob → browser download flow. Import directly from the API package.
|
|
1410
|
+
*
|
|
1411
|
+
* ### AI Coding Best Practices
|
|
1412
|
+
* Pattern: `api.addEventListener('screenshotReady', (data) => { if(data) saveImage(data, 'config-screenshot.png'); })`.
|
|
1413
|
+
* Filename extension should match the MimeType passed to GetScreenshot.
|
|
1414
|
+
* Import: `import { saveImage } from '@3dsource/metabox-front-api'`.
|
|
1415
|
+
*
|
|
1160
1416
|
* @param {string} imageUrl - The URL of the image to save.
|
|
1161
1417
|
* @param {string} filename - The name of the file to save.
|
|
1162
1418
|
*/
|
|
@@ -1172,7 +1428,6 @@ function saveImage(imageUrl, filename) {
|
|
|
1172
1428
|
/**
|
|
1173
1429
|
* Sets the URL parameters based on the provided state.
|
|
1174
1430
|
*
|
|
1175
|
-
* @remarks
|
|
1176
1431
|
* @internal
|
|
1177
1432
|
* @hidden
|
|
1178
1433
|
* This function updates the current URL by replacing its search parameters with the key-value pairs from the provided state object.
|
|
@@ -1210,5 +1465,5 @@ function getUrlParams() {
|
|
|
1210
1465
|
* Generated bundle index. Do not edit.
|
|
1211
1466
|
*/
|
|
1212
1467
|
|
|
1213
|
-
export { AppLoaded, AppLoaded_V3, ApplyZoom, BasicRouteUrl, CommandBase, Communicator, EventDispatcher, ForceSetDeviceType, GetCallToActionInformation, GetCamera, GetPdf, GetScreenshot, HideMeasurement, InitShowcase, Metabox, MetaboxBasicConfiguratorActions, MetaboxConfig, MetaboxDomain, MetaboxHost, MetaboxHost_V3, Metabox_V3, PauseShowcase, PlayShowcase, ResetCamera, SetCamera, SetEnvironment, SetEnvironmentMaterial, SetProduct, SetProductMaterial, ShowEmbeddedMenu, ShowMeasurement, ShowOverlayInterface, StopShowcase, UnrealCommand, VERSION, fromCommunicatorEvent, getUrlParams, integrateMetabox, prepareIframeSrc, saveImage, setUrlParams };
|
|
1468
|
+
export { AppLoaded, AppLoaded_V3, ApplyZoom, BasicRouteUrl, CommandBase, Communicator, EventDispatcher, ForceSetDeviceType, GetCallToActionInformation, GetCamera, GetPdf, GetScreenshot, HideMeasurement, InitShowcase, Metabox, MetaboxBasicConfiguratorActions, MetaboxConfig, MetaboxData, MetaboxDomain, MetaboxHost, MetaboxHost_V3, Metabox_V3, PauseShowcase, PlayShowcase, ResetCamera, ResumeStream, SetCamera, SetEnvironment, SetEnvironmentMaterial, SetProduct, SetProductMaterial, ShowEmbeddedMenu, ShowMeasurement, ShowOverlayInterface, StopShowcase, UnrealCommand, VERSION, fromCommunicatorEvent, getUrlParams, integrateMetabox, prepareIframeSrc, saveImage, setUrlParams };
|
|
1214
1469
|
//# sourceMappingURL=3dsource-metabox-front-api.mjs.map
|