@3dsource/metabox-front-api 3.0.13 → 3.0.15
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.
|
@@ -2,14 +2,18 @@ import { fromEvent } from 'rxjs';
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Base class for commands sent to the Metabox API.
|
|
5
|
+
* @internal
|
|
6
|
+
* @hidden
|
|
5
7
|
*/
|
|
6
8
|
class CommandBase {
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* Wrapper helper function to use it with rxJs the same as `fromEvent` to listen to events from the Communicator.
|
|
13
|
+
*
|
|
11
14
|
* @param {Communicator} target
|
|
12
15
|
* @param eventName
|
|
16
|
+
* @internal
|
|
13
17
|
*/
|
|
14
18
|
function fromCommunicatorEvent(target, eventName) {
|
|
15
19
|
return fromEvent(target, eventName);
|
|
@@ -44,6 +48,9 @@ const MetaboxBasicConfiguratorActions = {
|
|
|
44
48
|
/**
|
|
45
49
|
* Represents a command to send Metabox Config to Metabox Basic Configurator.
|
|
46
50
|
* @remarks
|
|
51
|
+
* **Important**: No need to listen to any events to see changes.
|
|
52
|
+
*
|
|
53
|
+
* @internal
|
|
47
54
|
* Automatically sent when the Communicator instance is ready.
|
|
48
55
|
*/
|
|
49
56
|
class MetaboxConfig extends CommandBase {
|
|
@@ -65,12 +72,13 @@ class MetaboxConfig extends CommandBase {
|
|
|
65
72
|
* Represents a command to get a PDF from Metabox Basic Configurator.
|
|
66
73
|
* @remarks
|
|
67
74
|
* This class sends a message to the Metabox API to generate a PDF based on the current configuration.
|
|
68
|
-
*
|
|
69
|
-
*
|
|
75
|
+
* **Important**: No need to listen to any events to see changes.
|
|
70
76
|
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
|
|
71
77
|
*
|
|
72
78
|
* @example
|
|
73
79
|
* import { GetPdf, Communicator } from '@3dsource/metabox-front-api';
|
|
80
|
+
*
|
|
81
|
+
* @param {Communicator} api - communicator instance api
|
|
74
82
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
75
83
|
* api.sendCommandToMetabox(new GetPdf());
|
|
76
84
|
* };
|
|
@@ -91,13 +99,27 @@ class GetPdf extends CommandBase {
|
|
|
91
99
|
/**
|
|
92
100
|
* Represents a command to get a Call To Action Information from Metabox Basic Configurator.
|
|
93
101
|
* @remarks
|
|
94
|
-
* This class sends a message to the Metabox API to generate Call To Action information based on the current configuration and sends it to the endpoint
|
|
95
|
-
*
|
|
102
|
+
* This class sends a message to the Metabox API to generate Call To Action information based on the current configuration and sends it to the endpoint URL from the CTA information.
|
|
103
|
+
*
|
|
104
|
+
* To listen for changes after sending this command, listen to the 'ecomConfiguratorDataUpdated' event.
|
|
105
|
+
* //...Assume that the integration is already implemented (only once)
|
|
106
|
+
* @example
|
|
107
|
+
* import { Communicator } from '@3dsource/metabox-front-api';
|
|
108
|
+
*
|
|
109
|
+
* @param {Communicator} api - communicator instance api
|
|
110
|
+
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
111
|
+
* @param {EcomConfigurator} data - description for all ecom configurator params
|
|
112
|
+
* api.addEventListener('ecomConfiguratorDataUpdated', (data) => {
|
|
113
|
+
* console.log('Ecom configurator params:', data);
|
|
114
|
+
* });
|
|
115
|
+
* };
|
|
96
116
|
*
|
|
97
117
|
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
|
|
98
118
|
*
|
|
99
119
|
* @example
|
|
100
120
|
* import { GetCallToActionInformation, Communicator } from '@3dsource/metabox-front-api';
|
|
121
|
+
*
|
|
122
|
+
* @param {Communicator} api - communicator instance api
|
|
101
123
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
102
124
|
* api.sendCommandToMetabox(new GetCallToActionInformation());
|
|
103
125
|
* };
|
|
@@ -118,15 +140,28 @@ class GetCallToActionInformation extends CommandBase {
|
|
|
118
140
|
}
|
|
119
141
|
|
|
120
142
|
/**
|
|
121
|
-
* Represents a command to
|
|
143
|
+
* Represents a command to get the camera configuration from Unreal.
|
|
122
144
|
* @remarks
|
|
123
145
|
* This class sends a message to the Metabox API to get the camera from a scene.
|
|
124
|
-
*
|
|
146
|
+
*
|
|
147
|
+
* To listen for changes after sending this command, listen to the 'getCameraResult' event.
|
|
148
|
+
* //...Assume that the integration is already implemented (only once)
|
|
149
|
+
* @example
|
|
150
|
+
* import { Communicator } from '@3dsource/metabox-front-api';
|
|
151
|
+
*
|
|
152
|
+
* @param {Communicator} api - communicator instance api
|
|
153
|
+
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
154
|
+
* @param {CameraCommandPayload} data - camera params
|
|
155
|
+
* api.addEventListener('getCameraResult', (data) => {
|
|
156
|
+
* console.log('Camera params after get camera command:', data);
|
|
157
|
+
* });
|
|
158
|
+
* };
|
|
125
159
|
*
|
|
126
160
|
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
|
|
127
161
|
*
|
|
128
162
|
* @example
|
|
129
163
|
* import { GetCamera, Communicator } from '@3dsource/metabox-front-api';
|
|
164
|
+
* @param {Communicator} api - communicator instance api
|
|
130
165
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
131
166
|
* api.sendCommandToMetabox(new GetCamera());
|
|
132
167
|
* };
|
|
@@ -145,14 +180,15 @@ class GetCamera extends CommandBase {
|
|
|
145
180
|
}
|
|
146
181
|
|
|
147
182
|
/**
|
|
148
|
-
* Represents a command to
|
|
183
|
+
* Represents a command to set the camera configuration.
|
|
149
184
|
* @remarks
|
|
150
185
|
* This class sends a message to the Metabox API to set the camera on a scene.
|
|
151
|
-
*
|
|
186
|
+
* **Important**: No need to listen to any events to see changes.
|
|
152
187
|
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
|
|
153
188
|
*
|
|
154
189
|
* @example
|
|
155
|
-
* import {
|
|
190
|
+
* import { SetCamera, Communicator } from '@3dsource/metabox-front-api';
|
|
191
|
+
* @param {Communicator} api - communicator instance api
|
|
156
192
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
157
193
|
* api.sendCommandToMetabox(new SetCamera({
|
|
158
194
|
* fov: 45,
|
|
@@ -176,8 +212,7 @@ class SetCamera extends CommandBase {
|
|
|
176
212
|
/**
|
|
177
213
|
* Creates an instance of SetCamera.
|
|
178
214
|
*
|
|
179
|
-
* @
|
|
180
|
-
* @param {CameraCommandPayload} camera - camera config
|
|
215
|
+
* @param {CameraCommandPayload} camera - The camera configuration.
|
|
181
216
|
*/
|
|
182
217
|
constructor(camera) {
|
|
183
218
|
super();
|
|
@@ -189,15 +224,15 @@ class SetCamera extends CommandBase {
|
|
|
189
224
|
}
|
|
190
225
|
|
|
191
226
|
/**
|
|
192
|
-
* Represents a command to
|
|
227
|
+
* Represents a command to reset the camera to its initial position.
|
|
193
228
|
* @remarks
|
|
194
229
|
* This class sends a message to the Metabox API to reset the camera on a scene.
|
|
195
|
-
*
|
|
196
|
-
*
|
|
230
|
+
* **Important**: No need to listen to any events to see changes.
|
|
197
231
|
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
|
|
198
232
|
*
|
|
199
233
|
* @example
|
|
200
234
|
* import { ResetCamera, Communicator } from '@3dsource/metabox-front-api';
|
|
235
|
+
* @param {Communicator} api - communicator instance api
|
|
201
236
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
202
237
|
* api.sendCommandToMetabox(new ResetCamera());
|
|
203
238
|
* };
|
|
@@ -216,14 +251,16 @@ class ResetCamera extends CommandBase {
|
|
|
216
251
|
}
|
|
217
252
|
|
|
218
253
|
/**
|
|
219
|
-
* Represents a command to
|
|
254
|
+
* Represents a command to apply zoom and change the camera zoom on a scene.
|
|
220
255
|
* @remarks
|
|
221
256
|
* This class sends a command to the Metabox API to change zoom on a scene.
|
|
222
|
-
*
|
|
257
|
+
* **Important**: No need to listen to any events to see changes.
|
|
223
258
|
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
|
|
224
259
|
*
|
|
225
260
|
* @example
|
|
226
261
|
* import { ApplyZoom, Communicator } from '@3dsource/metabox-front-api';
|
|
262
|
+
*
|
|
263
|
+
* @param {Communicator} api - communicator instance api
|
|
227
264
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
228
265
|
* api.sendCommandToMetabox(new ApplyZoom(10));
|
|
229
266
|
* api.sendCommandToMetabox(new ApplyZoom(-10));
|
|
@@ -233,7 +270,7 @@ class ApplyZoom extends CommandBase {
|
|
|
233
270
|
/**
|
|
234
271
|
* Creates an instance of ApplyZoom.
|
|
235
272
|
*
|
|
236
|
-
* @param {
|
|
273
|
+
* @param {number} zoom - The zoom value to apply.
|
|
237
274
|
*/
|
|
238
275
|
constructor(zoom) {
|
|
239
276
|
super();
|
|
@@ -245,17 +282,43 @@ class ApplyZoom extends CommandBase {
|
|
|
245
282
|
}
|
|
246
283
|
|
|
247
284
|
/**
|
|
248
|
-
* Represents a command to
|
|
285
|
+
* Represents a command to initialize Showcase for a product scene and start a sequence for the product.
|
|
249
286
|
* @remarks
|
|
250
|
-
* This class sends a command to the Metabox API to
|
|
251
|
-
*
|
|
252
|
-
*
|
|
287
|
+
* This class sends a command to the Metabox API to initialize showcase if the product has a sequence.
|
|
288
|
+
* To check this, find the showcase property in the current product and listen to the 'configuratorDataUpdated' event.
|
|
289
|
+
* //...Assume that the integration is already implemented (only once)
|
|
290
|
+
* @example
|
|
291
|
+
* import { Communicator } from '@3dsource/metabox-front-api';
|
|
292
|
+
*
|
|
293
|
+
* @param {Communicator} api - communicator instance api
|
|
294
|
+
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
295
|
+
* @param {ConfiguratorEnvelope} data - configurator state after updated
|
|
296
|
+
* api.addEventListener('configuratorDataUpdated', (data) => {
|
|
297
|
+
* console.log('State updated after applied new environment:', data);
|
|
298
|
+
* });
|
|
299
|
+
* };
|
|
300
|
+
*
|
|
301
|
+
* If this property exists, you can send the init showcase command.
|
|
302
|
+
*
|
|
303
|
+
* To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event.
|
|
304
|
+
* //...Assume that the integration is already implemented (only once)
|
|
305
|
+
* @example
|
|
306
|
+
* import { Communicator } from '@3dsource/metabox-front-api';
|
|
307
|
+
*
|
|
308
|
+
* @param {Communicator} api - communicator instance api
|
|
309
|
+
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
310
|
+
* @param {ShowCaseStatus} data - showcase status value
|
|
311
|
+
* api.addEventListener('showcaseStatusChanged', (data) => {
|
|
312
|
+
* console.log('Showcase status value after changed:', data);
|
|
313
|
+
* });
|
|
314
|
+
* };
|
|
253
315
|
*
|
|
254
316
|
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
|
|
255
317
|
*
|
|
256
318
|
* @example
|
|
257
|
-
* ```typescript
|
|
258
319
|
* import { InitShowcase, Communicator } from '@3dsource/metabox-front-api';
|
|
320
|
+
*
|
|
321
|
+
* @param {Communicator} api - communicator instance api
|
|
259
322
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
260
323
|
* api.sendCommandToMetabox(new InitShowcase());
|
|
261
324
|
* };
|
|
@@ -276,14 +339,29 @@ class InitShowcase extends CommandBase {
|
|
|
276
339
|
}
|
|
277
340
|
|
|
278
341
|
/**
|
|
279
|
-
* Represents a command to
|
|
342
|
+
* Represents a command to play Showcase for a product when it is already initialized and paused.
|
|
280
343
|
* @remarks
|
|
281
|
-
* This class sends a command to the Metabox API to play showcase for a product if it is already initialized and
|
|
344
|
+
* This class sends a command to the Metabox API to play showcase for a product if it is already initialized and paused.
|
|
345
|
+
*
|
|
346
|
+
* To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event.
|
|
347
|
+
* //...Assume that the integration is already implemented (only once)
|
|
348
|
+
* @example
|
|
349
|
+
* import { Communicator } from '@3dsource/metabox-front-api';
|
|
350
|
+
*
|
|
351
|
+
* @param {Communicator} api - communicator instance api
|
|
352
|
+
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
353
|
+
* @param {ShowCaseStatus} data - showcase status value
|
|
354
|
+
* api.addEventListener('showcaseStatusChanged', (data) => {
|
|
355
|
+
* console.log('Showcase status value after changed:', data);
|
|
356
|
+
* });
|
|
357
|
+
* };
|
|
282
358
|
*
|
|
283
359
|
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
|
|
284
360
|
*
|
|
285
361
|
* @example
|
|
286
362
|
* import { PlayShowcase, Communicator } from '@3dsource/metabox-front-api';
|
|
363
|
+
*
|
|
364
|
+
* @param {Communicator} api - communicator instance api
|
|
287
365
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
288
366
|
* api.sendCommandToMetabox(new PlayShowcase());
|
|
289
367
|
* };
|
|
@@ -317,14 +395,29 @@ class UnrealCommand extends CommandBase {
|
|
|
317
395
|
}
|
|
318
396
|
|
|
319
397
|
/**
|
|
320
|
-
* Represents a command to
|
|
398
|
+
* Represents a command to pause Showcase for a product when it is already initialized and playing.
|
|
321
399
|
* @remarks
|
|
322
|
-
* This class sends a command to the Metabox API to pause showcase for a product if it is already initialized and
|
|
400
|
+
* This class sends a command to the Metabox API to pause showcase for a product if it is already initialized and playing.
|
|
401
|
+
*
|
|
402
|
+
* To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event.
|
|
403
|
+
* //...Assume that the integration is already implemented (only once)
|
|
404
|
+
* @example
|
|
405
|
+
* import { Communicator } from '@3dsource/metabox-front-api';
|
|
406
|
+
*
|
|
407
|
+
* @param {Communicator} api - communicator instance api
|
|
408
|
+
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
409
|
+
* @param {ShowCaseStatus} data - showcase status value
|
|
410
|
+
* api.addEventListener('showcaseStatusChanged', (data) => {
|
|
411
|
+
* console.log('Showcase status value after changed:', data);
|
|
412
|
+
* });
|
|
413
|
+
* };
|
|
323
414
|
*
|
|
324
415
|
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
|
|
325
416
|
*
|
|
326
417
|
* @example
|
|
327
418
|
* import { PauseShowcase, Communicator } from '@3dsource/metabox-front-api';
|
|
419
|
+
*
|
|
420
|
+
* @param {Communicator} api - communicator instance api
|
|
328
421
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
329
422
|
* api.sendCommandToMetabox(new PauseShowcase());
|
|
330
423
|
* };
|
|
@@ -343,14 +436,29 @@ class PauseShowcase extends CommandBase {
|
|
|
343
436
|
}
|
|
344
437
|
|
|
345
438
|
/**
|
|
346
|
-
* Represents a command to
|
|
439
|
+
* Represents a command to stop Showcase for a product when it is already initialized, and you want to destroy it.
|
|
347
440
|
* @remarks
|
|
348
|
-
* This class sends a command to the Metabox API to
|
|
441
|
+
* This class sends a command to the Metabox API to stop showcase for a product if it is already initialized.
|
|
442
|
+
*
|
|
443
|
+
* To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event.
|
|
444
|
+
* //...Assume that the integration is already implemented (only once)
|
|
445
|
+
* @example
|
|
446
|
+
* import { Communicator } from '@3dsource/metabox-front-api';
|
|
447
|
+
*
|
|
448
|
+
* @param {Communicator} api - communicator instance api
|
|
449
|
+
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
450
|
+
* @param {ShowCaseStatus} data - showcase status value
|
|
451
|
+
* api.addEventListener('showcaseStatusChanged', (data) => {
|
|
452
|
+
* console.log('Showcase status value after changed:', data);
|
|
453
|
+
* });
|
|
454
|
+
* };
|
|
349
455
|
*
|
|
350
456
|
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
|
|
351
457
|
*
|
|
352
458
|
* @example
|
|
353
459
|
* import { StopShowcase, Communicator } from '@3dsource/metabox-front-api';
|
|
460
|
+
*
|
|
461
|
+
* @param {Communicator} api - communicator instance api
|
|
354
462
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
355
463
|
* api.sendCommandToMetabox(new StopShowcase());
|
|
356
464
|
* };
|
|
@@ -370,17 +478,28 @@ class StopShowcase extends CommandBase {
|
|
|
370
478
|
|
|
371
479
|
/**
|
|
372
480
|
* Represents a command to get a screenshot.
|
|
373
|
-
*
|
|
374
481
|
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
|
|
375
482
|
*
|
|
483
|
+
* @remarks
|
|
484
|
+
* To listen for changes after sending this command, listen to the 'screenshot' event.
|
|
485
|
+
* //...Assume that the integration is already implemented (only once)
|
|
486
|
+
* @example
|
|
487
|
+
* import { Communicator } from '@3dsource/metabox-front-api';
|
|
488
|
+
*
|
|
489
|
+
* @param {Communicator} api - communicator instance api
|
|
490
|
+
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
491
|
+
* @param {string} data - base64 string image
|
|
492
|
+
* api.addEventListener('screenshot', (data) => {
|
|
493
|
+
* console.log('Get screenshot here:', data);
|
|
494
|
+
* saveImage(data, 'Render.png');
|
|
495
|
+
* });
|
|
496
|
+
* };
|
|
497
|
+
*
|
|
376
498
|
* @example
|
|
377
499
|
* import { GetScreenshot, Communicator, saveImage } from '@3dsource/metabox-front-api';
|
|
500
|
+
*
|
|
501
|
+
* @param {Communicator} api - communicator instance api
|
|
378
502
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
379
|
-
* // Listen for events from to the Metabox API
|
|
380
|
-
* api.addEventListener('screenshot', (data) => {
|
|
381
|
-
* // Process the get screenshot response
|
|
382
|
-
* saveImage(data, 'Render.png');
|
|
383
|
-
* });
|
|
384
503
|
* api.sendCommandToMetabox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));
|
|
385
504
|
* };
|
|
386
505
|
*/
|
|
@@ -405,10 +524,23 @@ class GetScreenshot extends CommandBase {
|
|
|
405
524
|
* @remarks
|
|
406
525
|
* This action sends a message to the Metabox API to set a product using the provided product ID.
|
|
407
526
|
*
|
|
527
|
+
* To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.
|
|
528
|
+
* //...Assume that the integration is already implemented (only once)
|
|
529
|
+
* @example
|
|
530
|
+
* import { Communicator } from '@3dsource/metabox-front-api';
|
|
531
|
+
*
|
|
532
|
+
* @param {Communicator} api - communicator instance api
|
|
533
|
+
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
534
|
+
* @param {ConfiguratorEnvelope} data - configurator state after updated
|
|
535
|
+
* api.addEventListener('configuratorDataUpdated', (data) => {
|
|
536
|
+
* console.log('State updated after applied new product:', data);
|
|
537
|
+
* });
|
|
538
|
+
* };
|
|
539
|
+
*
|
|
408
540
|
* @example
|
|
409
541
|
* import { SetProduct, Communicator } from '@3dsource/metabox-front-api';
|
|
410
542
|
*
|
|
411
|
-
*
|
|
543
|
+
* @param {Communicator} api - communicator instance api
|
|
412
544
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
413
545
|
* api.setCommandToMetaBox(new SetProduct(
|
|
414
546
|
* 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3'
|
|
@@ -433,10 +565,25 @@ class SetProduct extends CommandBase {
|
|
|
433
565
|
/**
|
|
434
566
|
* Represents a command to set a material by its slot ID and Material ID.
|
|
435
567
|
*
|
|
568
|
+
* @remarks
|
|
569
|
+
* To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.
|
|
570
|
+
* //...Assume that the integration is already implemented (only once)
|
|
571
|
+
*
|
|
572
|
+
* @example
|
|
573
|
+
* import { Communicator } from '@3dsource/metabox-front-api';
|
|
574
|
+
*
|
|
575
|
+
* @param {Communicator} api - communicator instance api
|
|
576
|
+
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
577
|
+
* @param {ConfiguratorEnvelope} data - configurator state after updated
|
|
578
|
+
* api.addEventListener('configuratorDataUpdated', (data) => {
|
|
579
|
+
* console.log('State updated after applied new material:', data);
|
|
580
|
+
* });
|
|
581
|
+
* };
|
|
582
|
+
*
|
|
436
583
|
* @example
|
|
437
584
|
* import { SetProductMaterial, Communicator } from '@3dsource/metabox-front-api';
|
|
438
585
|
*
|
|
439
|
-
*
|
|
586
|
+
* @param {Communicator} api - communicator instance api
|
|
440
587
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
441
588
|
* api.sendCommandToMetabox(new SetProductMaterial(
|
|
442
589
|
* 'carpaint',
|
|
@@ -463,12 +610,25 @@ class SetProductMaterial extends CommandBase {
|
|
|
463
610
|
/**
|
|
464
611
|
* Represents a command to set the environment by its ID.
|
|
465
612
|
*
|
|
613
|
+
* @remarks
|
|
614
|
+
* To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.
|
|
615
|
+
* //...Assume that the integration is already implemented (only once)
|
|
616
|
+
* @example
|
|
617
|
+
* import { Communicator } from '@3dsource/metabox-front-api';
|
|
618
|
+
*
|
|
619
|
+
* @param {Communicator} api - communicator instance api
|
|
620
|
+
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
621
|
+
* @param {ConfiguratorEnvelope} data - configurator state after updated
|
|
622
|
+
* api.addEventListener('configuratorDataUpdated', (data) => {
|
|
623
|
+
* console.log('State updated after applied new environment:', data);
|
|
624
|
+
* });
|
|
625
|
+
* };
|
|
626
|
+
*
|
|
466
627
|
* @example
|
|
467
628
|
* import { SetEnvironment, Communicator } from '@3dsource/metabox-front-api';
|
|
468
629
|
*
|
|
469
|
-
*
|
|
630
|
+
* @param {Communicator} api - communicator instance api
|
|
470
631
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
471
|
-
* // Change the environment to '55555555-1234-1234-1234-01234567890'
|
|
472
632
|
* api.sendCommandToMetabox(new SetEnvironment('55555555-1234-1234-1234-01234567890'));
|
|
473
633
|
* };
|
|
474
634
|
*/
|
|
@@ -490,10 +650,24 @@ class SetEnvironment extends CommandBase {
|
|
|
490
650
|
/**
|
|
491
651
|
* Represents a command to set an environment material by its slot ID and Material ID.
|
|
492
652
|
*
|
|
653
|
+
* @remarks
|
|
654
|
+
* To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.
|
|
655
|
+
* //...Assume that the integration is already implemented (only once)
|
|
656
|
+
* @example
|
|
657
|
+
* import { Communicator } from '@3dsource/metabox-front-api';
|
|
658
|
+
*
|
|
659
|
+
* @param {Communicator} api - communicator instance api
|
|
660
|
+
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
661
|
+
* @param {ConfiguratorEnvelope} data - configurator state after updated
|
|
662
|
+
* api.addEventListener('configuratorDataUpdated', (data) => {
|
|
663
|
+
* console.log('State updated after applied new environment material:', data);
|
|
664
|
+
* });
|
|
665
|
+
* };
|
|
666
|
+
*
|
|
493
667
|
* @example
|
|
494
668
|
* import { SetEnvironmentMaterial, Communicator } from '@3dsource/metabox-front-api';
|
|
495
669
|
*
|
|
496
|
-
*
|
|
670
|
+
* @param {Communicator} api - communicator instance api
|
|
497
671
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
498
672
|
* api.sendCommandToMetabox(new SetEnvironmentMaterial(
|
|
499
673
|
* 'carpaint',
|
|
@@ -518,14 +692,17 @@ class SetEnvironmentMaterial extends CommandBase {
|
|
|
518
692
|
}
|
|
519
693
|
|
|
520
694
|
/**
|
|
521
|
-
* Represents a command to toggle the
|
|
695
|
+
* Represents a command to toggle the embedded Metabox menu.
|
|
696
|
+
* @remarks
|
|
697
|
+
* This command can only be used when using the metabox menu.
|
|
698
|
+
* **Important**: No need to listen to any events to see changes.
|
|
522
699
|
*
|
|
523
700
|
* @example
|
|
524
701
|
* import { ShowEmbeddedMenu, Communicator } from '@3dsource/metabox-front-api';
|
|
525
702
|
*
|
|
526
|
-
*
|
|
703
|
+
* @param {Communicator} api - communicator instance api
|
|
527
704
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
528
|
-
* api.
|
|
705
|
+
* api.sendCommandToMetabox(new ShowEmbeddedMenu(true));
|
|
529
706
|
* };
|
|
530
707
|
*/
|
|
531
708
|
class ShowEmbeddedMenu extends CommandBase {
|
|
@@ -548,11 +725,12 @@ class ShowEmbeddedMenu extends CommandBase {
|
|
|
548
725
|
*
|
|
549
726
|
* @remarks
|
|
550
727
|
* This action sends a message to the Metabox API to toggle the visibility of the Unreal overlay UI.
|
|
728
|
+
* **Important**: No need to listen to any events to see changes.
|
|
551
729
|
*
|
|
552
730
|
* @example
|
|
553
731
|
* import { ShowOverlayInterface, Communicator } from '@3dsource/metabox-front-api';
|
|
554
732
|
*
|
|
555
|
-
*
|
|
733
|
+
* @param {Communicator} api - communicator instance api
|
|
556
734
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
557
735
|
* api.setCommandToMetaBox(new ShowOverlayInterface(true));
|
|
558
736
|
* };
|
|
@@ -594,21 +772,23 @@ class WatchCallbacks extends CommandBase {
|
|
|
594
772
|
}
|
|
595
773
|
|
|
596
774
|
/**
|
|
597
|
-
* Represents a command to
|
|
775
|
+
* Represents a command to show measurement for a product when it is already loaded.
|
|
598
776
|
* @remarks
|
|
599
|
-
* This class sends a command to the Metabox API to
|
|
600
|
-
*
|
|
777
|
+
* This class sends a command to the Metabox API to show measurement for a product if it is already initialized.
|
|
778
|
+
* **Important**: No need to listen to any events to see changes.
|
|
601
779
|
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
|
|
602
780
|
*
|
|
603
781
|
* @example
|
|
604
782
|
* import { ShowMeasurement, Communicator } from '@3dsource/metabox-front-api';
|
|
783
|
+
*
|
|
784
|
+
* @param {Communicator} api - communicator instance api
|
|
605
785
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
606
786
|
* api.sendCommandToMetabox(new ShowMeasurement());
|
|
607
787
|
* };
|
|
608
788
|
*/
|
|
609
789
|
class ShowMeasurement extends CommandBase {
|
|
610
790
|
/**
|
|
611
|
-
* Creates an instance of
|
|
791
|
+
* Creates an instance of ShowMeasurement.
|
|
612
792
|
*
|
|
613
793
|
* @remarks
|
|
614
794
|
* This constructor does not require any parameters.
|
|
@@ -620,14 +800,16 @@ class ShowMeasurement extends CommandBase {
|
|
|
620
800
|
}
|
|
621
801
|
|
|
622
802
|
/**
|
|
623
|
-
* Represents a command to
|
|
803
|
+
* Represents a command to hide measurement for a product when it is already loaded.
|
|
624
804
|
* @remarks
|
|
625
|
-
* This class sends a command to the Metabox API to
|
|
626
|
-
*
|
|
805
|
+
* This class sends a command to the Metabox API to hide measurement for a product if it is already initialized.
|
|
806
|
+
* **Important**: No need to listen to any events to see changes.
|
|
627
807
|
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
|
|
628
808
|
*
|
|
629
809
|
* @example
|
|
630
810
|
* import { HideMeasurement, Communicator } from '@3dsource/metabox-front-api';
|
|
811
|
+
*
|
|
812
|
+
* @param {Communicator} api - communicator instance api
|
|
631
813
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
632
814
|
* api.sendCommandToMetabox(new HideMeasurement());
|
|
633
815
|
* };
|
|
@@ -649,12 +831,14 @@ class HideMeasurement extends CommandBase {
|
|
|
649
831
|
* Represents a command to force set the device type.
|
|
650
832
|
*
|
|
651
833
|
* @remarks
|
|
652
|
-
* This class sends a message to the Metabox API to force
|
|
834
|
+
* This class sends a message to the Metabox API to force set the device type.
|
|
835
|
+
* **Important**: No need to listen to any events to see changes.
|
|
836
|
+
* //...Assume that the integration is already implemented (only once)
|
|
653
837
|
*
|
|
654
838
|
* @example
|
|
655
839
|
* import { ForceSetDeviceType, Communicator } from '@3dsource/metabox-front-api';
|
|
656
840
|
*
|
|
657
|
-
*
|
|
841
|
+
* @param {Communicator} api - communicator instance api
|
|
658
842
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
659
843
|
* api.sendCommandToMetabox(new ForceSetDeviceType('desktop'));
|
|
660
844
|
* };
|
|
@@ -722,6 +906,11 @@ class EventDispatcher {
|
|
|
722
906
|
}
|
|
723
907
|
}
|
|
724
908
|
|
|
909
|
+
/**
|
|
910
|
+
* @internal
|
|
911
|
+
* @hidden
|
|
912
|
+
* Represents main constants.
|
|
913
|
+
*/
|
|
725
914
|
const Metabox = 'metabox_v3';
|
|
726
915
|
const MetaboxHost = 'metaboxHost_v3';
|
|
727
916
|
const MetaboxData = 'metaboxData_v3';
|
|
@@ -729,7 +918,7 @@ const AppLoaded = 'appLoaded_v3';
|
|
|
729
918
|
const MetaboxDomain = 'metabox.3dsource.com';
|
|
730
919
|
const BasicRouteUrl = 'metabox-configurator/basic';
|
|
731
920
|
|
|
732
|
-
const VERSION = '3.0.
|
|
921
|
+
const VERSION = '3.0.15';
|
|
733
922
|
|
|
734
923
|
const communicatorMap = new Map();
|
|
735
924
|
/**
|
|
@@ -760,9 +949,9 @@ class Communicator extends EventDispatcher {
|
|
|
760
949
|
}
|
|
761
950
|
/**
|
|
762
951
|
* Listens for Metabox to signal readiness, then initializes communicator.
|
|
763
|
-
* @param apiReadyCallback - Called with the new Communicator once
|
|
952
|
+
* @param apiReadyCallback - Called with the new Communicator once the Metabox is loaded.
|
|
764
953
|
* @param {MetaboxEnvironment} environment - The environment in which the Communicator is running.
|
|
765
|
-
* @param {MetaboxCommandConfig} config -
|
|
954
|
+
* @param {MetaboxCommandConfig} config - Optional initial config: standalone - if true, disable metabox custom template and all logic.
|
|
766
955
|
*/
|
|
767
956
|
static createInstance(apiReadyCallback, environment, config) {
|
|
768
957
|
const startHandler = (event) => {
|
|
@@ -800,10 +989,11 @@ class Communicator extends EventDispatcher {
|
|
|
800
989
|
const iframe = document.getElementById('embeddedContent');
|
|
801
990
|
const message = {
|
|
802
991
|
host: MetaboxHost,
|
|
992
|
+
envelope: { ...data },
|
|
803
993
|
payload: { ...data },
|
|
804
994
|
};
|
|
805
995
|
if (!iframe?.contentWindow) {
|
|
806
|
-
console.warn('
|
|
996
|
+
console.warn('Metabox IFrame not found or not ready. Message sends to the same window');
|
|
807
997
|
window.postMessage({ ...message, target: 'metabox' }, '*');
|
|
808
998
|
return;
|
|
809
999
|
}
|
|
@@ -811,7 +1001,7 @@ class Communicator extends EventDispatcher {
|
|
|
811
1001
|
iframe.contentWindow.postMessage({ ...message, target: 'child' }, '*');
|
|
812
1002
|
}
|
|
813
1003
|
/**
|
|
814
|
-
* Registers an event listener for messages dispatched by
|
|
1004
|
+
* Registers an event listener for messages dispatched by the Metabox.
|
|
815
1005
|
* @override
|
|
816
1006
|
*/
|
|
817
1007
|
addEventListener(messageType, callback) {
|
|
@@ -832,7 +1022,7 @@ class Communicator extends EventDispatcher {
|
|
|
832
1022
|
return super.removeEventListener(messageType, callback);
|
|
833
1023
|
}
|
|
834
1024
|
/**
|
|
835
|
-
* Filters and dispatches incoming messages from
|
|
1025
|
+
* Filters and dispatches incoming messages from the Metabox.
|
|
836
1026
|
* @param {FromMetaBoxApiEvents | 'metaboxData' } messageType - Expected message type for filtering ('metaboxData').
|
|
837
1027
|
* @param {MessageEvent} event - The postMessage event received on a window.
|
|
838
1028
|
*/
|
|
@@ -846,6 +1036,15 @@ class Communicator extends EventDispatcher {
|
|
|
846
1036
|
}
|
|
847
1037
|
}
|
|
848
1038
|
|
|
1039
|
+
/**
|
|
1040
|
+
*
|
|
1041
|
+
* @remarks
|
|
1042
|
+
* @internal
|
|
1043
|
+
* @hidden
|
|
1044
|
+
*
|
|
1045
|
+
* @param {string} configuratorId - An string identifier for the configurator.
|
|
1046
|
+
* @param {IntegrateMetaboxConfig} config - An object containing the configuration options.
|
|
1047
|
+
*/
|
|
849
1048
|
const prepareIframeSrc = (configuratorId, config) => {
|
|
850
1049
|
const base = `https://${config?.domain || MetaboxDomain}/${BasicRouteUrl}/${configuratorId}`;
|
|
851
1050
|
const params = new URLSearchParams();
|
|
@@ -982,6 +1181,8 @@ function saveImage(imageUrl, filename) {
|
|
|
982
1181
|
* Sets the URL parameters based on the provided state.
|
|
983
1182
|
*
|
|
984
1183
|
* @remarks
|
|
1184
|
+
* @internal
|
|
1185
|
+
* @hidden
|
|
985
1186
|
* This function updates the current URL by replacing its search parameters with the key-value pairs from the provided state object.
|
|
986
1187
|
*
|
|
987
1188
|
* @param {Record<string, string>} state - An object containing key-value pairs to set as URL parameters.
|
|
@@ -998,6 +1199,8 @@ function setUrlParams(state) {
|
|
|
998
1199
|
* Retrieves the URL parameters as an object.
|
|
999
1200
|
*
|
|
1000
1201
|
* @remarks
|
|
1202
|
+
* @internal
|
|
1203
|
+
* @hidden
|
|
1001
1204
|
* This function parses the current URL's search parameters and returns them as a key-value object.
|
|
1002
1205
|
*
|
|
1003
1206
|
* @returns An object containing the URL parameters.
|