@3dsource/metabox-front-api 2.0.3 → 2.0.4-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,20 +9,37 @@ their material slots, and materials, environments.
9
9
  - [Features](#features)
10
10
  - [Prerequisites](#prerequisites)
11
11
  - [Installation](#installation)
12
+ - [Method 1: NPM Package (Recommended)](#method-1-npm-package-recommended)
13
+ - [Method 2: CDN Import](#method-2-cdn-import)
12
14
  - [Quick Start](#quick-start)
15
+ - [1. HTML Setup](#1-html-setup)
16
+ - [2. Basic Integration](#2-basic-integration)
17
+ - [JavaScript Example](#javascript-example)
18
+ - [TypeScript Example](#typescript-example)
13
19
  - [API Reference](#api-reference)
14
- - [Steps to build custom menu](#steps-to-build-custom-menu)
15
20
  - [System Terminology](#system-terminology)
21
+ - [Steps to build a custom menu](#steps-to-build-a-custom-menu)
16
22
  - [Core Functions](#core-functions)
23
+ - [`integrateMetabox`](#integratemetabox)
17
24
  - [Command Classes](#command-classes)
25
+ - [Command Payload Types (Internal)](#command-payload-types-internal)
26
+ - [Product & Environment](#product--environment)
27
+ - [UI & Overlay](#ui--overlay)
28
+ - [Camera & View](#camera--view)
29
+ - [Showcase Control](#showcase-control)
30
+ - [Media & Export](#media--export)
31
+ - [Advanced / Experimental](#advanced--experimental)
18
32
  - [Event Handling](#event-handling)
33
+ - [Available Events](#available-events)
34
+ - [Example: Basic State Listener](#example-basic-state-listener)
19
35
  - [Utility Functions](#utility-functions)
20
36
  - [Standalone Mode](#standalone-mode)
21
37
  - [Examples](#examples)
22
38
  - [Best Practices](#best-practices)
23
39
  - [Troubleshooting](#troubleshooting)
40
+ - [Common Issues](#common-issues)
24
41
  - [Browser Compatibility](#browser-compatibility)
25
- - [Contributing](#contributing)
42
+ - [Requirements](#requirements)
26
43
 
27
44
  ## Features
28
45
 
@@ -40,7 +57,7 @@ their material slots, and materials, environments.
40
57
  - HTTPS connection (required for unreal engine)
41
58
  - Valid Metabox basic configurator URL
42
59
 
43
- Important: integrateMetaBox validates inputs at runtime. It requires a non-empty HTTPS URL for iframeSrc and a non-empty containerId. An error will be thrown if these are invalid.
60
+ Important: integrateMetabox validates inputs at runtime. It requires a non-empty configuratorId and a non-empty containerId. The iframe URL is constructed internally as `https://{domain}/metabox-configurator/basic/{configuratorId}` with optional query parameters (introImage, introVideo, loadingImage). HTTPS is enforced and non-HTTPS URLs are rejected.
44
61
 
45
62
  ## Installation
46
63
 
@@ -49,25 +66,27 @@ Important: integrateMetaBox validates inputs at runtime. It requires a non-empty
49
66
  For use with frameworks like Angular, React, Vue, etc.:
50
67
 
51
68
  ```bash
52
- npm install @3dsource/metabox-front-api@^2.0.1 --save
69
+ npm install @3dsource/metabox-front-api@latest --save
70
+ # or pin a specific version
71
+ # npm install @3dsource/metabox-front-api@latest --save
53
72
  ```
54
73
 
55
74
  Then import the required components:
56
75
 
57
76
  ```typescript
58
- import { integrateMetaBox, Communicator, ConfiguratorEnvelope, SetProduct, SetMaterial, SetEnvironment, GetScreenshot, GetPdf, saveImage } from '@3dsource/metabox-front-api';
77
+ import { integrateMetabox, Communicator, ConfiguratorEnvelope, SetProduct, SetProductMaterial, SetEnvironment, GetScreenshot, GetPdf, saveImage } from '@3dsource/metabox-front-api';
59
78
  ```
60
79
 
61
80
  ### Method 2: CDN Import
62
81
 
63
82
  Alternative CDN options:
64
83
 
65
- - **jsDelivr**: `https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@^2.0.1/+esm`
84
+ - **jsDelivr**: `https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@latest/+esm`
66
85
 
67
86
  For quick prototyping or vanilla JavaScript projects:
68
87
 
69
88
  ```javascript
70
- import { integrateMetaBox, Communicator, ConfiguratorEnvelope, SetProduct, SetMaterial, SetEnvironment, GetScreenshot, GetPdf, saveImage } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api';
89
+ import { integrateMetabox, Communicator, ConfiguratorEnvelope, SetProduct, SetProductMaterial, SetEnvironment, GetScreenshot, GetPdf, saveImage } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api';
71
90
  ```
72
91
 
73
92
  ## Quick Start
@@ -106,67 +125,28 @@ Create a container element where the Metabox Configurator will be embedded:
106
125
 
107
126
  ```html
108
127
  <script type="module">
109
- import { integrateMetaBox, SetProduct, SetMaterial, SetEnvironment, GetScreenshot, saveImage } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@2.0.1/+esm';
128
+ import { integrateMetabox, SetProduct, SetProductMaterial, SetEnvironment, GetScreenshot, saveImage } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@latest/+esm';
110
129
 
111
- class MetaboxIntegrator {
112
- constructor() {
113
- // Replace 'your-configurator-id' with your actual basic configurator ID
114
- const configuratorUrl = 'https://metabox.3dsource.com/metabox-configurator/basic/your-configurator-id';
115
-
116
- // Initialize the configurator
117
- integrateMetaBox(configuratorUrl, 'embed3DSource', (api) => {
118
- this.onApiReady(api);
119
- });
120
- }
121
-
122
- onApiReady(api) {
123
- console.log('Metabox API is ready!');
124
-
125
- // Listen for configurator data updates
126
- api.addEventListener('configuratorDataUpdated', (data) => {
127
- console.log('Configurator data updated:', data);
128
- this.handleConfiguratorUpdate(data);
129
- });
130
-
131
- // Listen for screenshot/render completion
132
- api.addEventListener('screenshotReady', (imageData) => {
133
- console.log('Screenshot ready');
134
- saveImage(imageData, 'configurator-screenshot.png');
135
- });
136
-
137
- // Set up the initial configuration
138
- this.configureInitialState(api);
139
- }
140
-
141
- handleConfiguratorUpdate(data) {
142
- // Handle configurator state changes
143
- // You can update your UI, save state, etc.
144
- }
145
-
146
- configureInitialState(api) {
147
- // Set the initial product
148
- api.sendCommandToMetaBox(new SetProduct('your-product-id'));
149
-
150
- // Set initial environment
151
- api.sendCommandToMetaBox(new SetEnvironment('your-environment-id'));
152
-
153
- // Apply material to a specific slot
154
- api.sendCommandToMetaBox(new SetMaterial('slot-id', 'material-id'));
155
-
156
- // Take a screenshot
157
- api.sendCommandToMetaBox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));
158
- }
159
- }
160
-
161
- // Initialize the integrator
162
- new MetaboxIntegrator();
130
+ const configuratorId = 'configurator-id'; // your actual configurator id
131
+ // Ensure a container with id embed3DSource exists (see HTML Setup)
132
+ integrateMetabox(configuratorId, 'embed3DSource', (api) => {
133
+ api.addEventListener('configuratorDataUpdated', (env) => {
134
+ console.log('State updated:', env.productId, env.environmentId);
135
+ });
136
+ api.addEventListener('screenshotReady', (image) => {
137
+ if (image) saveImage(image, `configurator-${Date.now()}.png`);
138
+ });
139
+ // Initial commands
140
+ api.sendCommandToMetabox(new SetProduct('product-1'));
141
+ api.sendCommandToMetabox(new GetScreenshot('image/png', { x: 1280, y: 720 }));
142
+ });
163
143
  </script>
164
144
  ```
165
145
 
166
146
  #### TypeScript Example
167
147
 
168
148
  ```typescript
169
- import { integrateMetaBox, Communicator, ConfiguratorEnvelope, SetProduct, SetMaterial, SetEnvironment, GetScreenshot, GetPdf, ShowEmbeddedMenu, ShowOverlayInterface, saveImage } from '@3dsource/metabox-front-api';
149
+ import { integrateMetabox, Communicator, ConfiguratorEnvelope, SetProduct, SetProductMaterial, SetEnvironment, GetScreenshot, GetPdf, ShowEmbeddedMenu, ShowOverlayInterface, saveImage } from '@3dsource/metabox-front-api';
170
150
 
171
151
  class MetaboxIntegrator {
172
152
  private api: Communicator | null = null;
@@ -177,11 +157,11 @@ class MetaboxIntegrator {
177
157
 
178
158
  private async initialize(): Promise<void> {
179
159
  try {
180
- // Replace 'your-configurator-id' with your actual configurator ID
181
- const configuratorUrl = 'https://metabox.3dsource.com/metabox-configurator/basic/your-configurator-id';
160
+ // Replace 'configurator-id' with your actual configurator ID
161
+ const configuratorId = 'configurator-id';
182
162
 
183
163
  // Initialize the configurator with type safety
184
- integrateMetaBox(configuratorUrl, 'embed3DSource', (api: Communicator) => {
164
+ integrateMetabox(configuratorId, 'embed3DSource', (api: Communicator) => {
185
165
  this.onApiReady(api);
186
166
  });
187
167
  } catch (error) {
@@ -230,40 +210,40 @@ class MetaboxIntegrator {
230
210
  if (!this.api) return;
231
211
 
232
212
  // Set initial product
233
- this.api.sendCommandToMetaBox(new SetProduct('your-product-id'));
213
+ this.api.sendCommandToMetabox(new SetProduct('your-product-id'));
234
214
 
235
215
  // Set initial environment
236
- this.api.sendCommandToMetaBox(new SetEnvironment('your-environment-id'));
216
+ this.api.sendCommandToMetabox(new SetEnvironment('your-environment-id'));
237
217
 
238
218
  // Apply material to a specific slot
239
- this.api.sendCommandToMetaBox(new SetMaterial('slot-id', 'material-id'));
219
+ this.api.sendCommandToMetabox(new SetProductMaterial('slot-id', 'material-id'));
240
220
 
241
221
  // Configure UI visibility
242
- this.api.sendCommandToMetaBox(new ShowEmbeddedMenu(false));
243
- this.api.sendCommandToMetaBox(new ShowOverlayInterface(false));
222
+ this.api.sendCommandToMetabox(new ShowEmbeddedMenu(false));
223
+ this.api.sendCommandToMetabox(new ShowOverlayInterface(false));
244
224
 
245
225
  // Generate initial screenshot
246
- this.api.sendCommandToMetaBox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));
226
+ this.api.sendCommandToMetabox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));
247
227
  }
248
228
 
249
229
  // Public method to change product
250
230
  public changeProduct(productId: string): void {
251
231
  if (this.api) {
252
- this.api.sendCommandToMetaBox(new SetProduct(productId));
232
+ this.api.sendCommandToMetabox(new SetProduct(productId));
253
233
  }
254
234
  }
255
235
 
256
236
  // Public method to apply material
257
237
  public applyMaterial(slotId: string, materialId: string): void {
258
238
  if (this.api) {
259
- this.api.sendCommandToMetaBox(new SetMaterial(slotId, materialId));
239
+ this.api.sendCommandToMetabox(new SetProductMaterial(slotId, materialId));
260
240
  }
261
241
  }
262
242
 
263
243
  // Public method to take screenshot
264
244
  public takeScreenshot(width: number = 1024, height: number = 1024): void {
265
245
  if (this.api) {
266
- this.api.sendCommandToMetaBox(new GetScreenshot('image/png', { x: width, y: height }));
246
+ this.api.sendCommandToMetabox(new GetScreenshot('image/png', { x: width, y: height }));
267
247
  }
268
248
  }
269
249
  }
@@ -304,14 +284,14 @@ const metaboxIntegrator = new MetaboxIntegrator();
304
284
  - Your backend decides how to use the configuration JSON (e.g., generate a PDF or build a product list).
305
285
  - After your endpoint responds with a JSON containing "redirectUrl", the user is redirected in a new browser tab to that URL (a non‑Metabox page on your side) to complete the flow (e.g., leave contact information, proceed to checkout, etc.).
306
286
 
307
- ### Steps to build custom menu
287
+ ### Steps to build a custom menu
308
288
 
309
- - **configuratorDataUpdated** - add event listener to receive get configurator data and then updates
310
- - **showEmbeddedMenu** - hide embedded metabox right sidebar, but if you want to show it again, you can use this method
289
+ - **configuratorDataUpdated** - add event listener to receive configurator data and updates
290
+ - **showEmbeddedMenu** - hide embedded metabox right sidebar; show again with the command
311
291
  - **showOverlayInterface** - hide viewport metabox actions if you want to add yours
312
292
  - **setEnvironment** - set active environment when you want to change environment
313
293
  - **setEnvironmentMaterialById** - set environment material by slot ID
314
- - **setProduct** - set active product when you want to change product
294
+ - **setProduct** - set active product when you want to change the product
315
295
  - **setProductMaterialById** - set product material by slot ID
316
296
  - **getScreenshot** - get screenshot
317
297
  - **getCallToActionInformation** - send call to action information to api endpoint provided in CTA configuration
@@ -319,271 +299,164 @@ const metaboxIntegrator = new MetaboxIntegrator();
319
299
 
320
300
  ### Core Functions
321
301
 
322
- #### `integrateMetaBox`
302
+ #### `integrateMetabox`
323
303
 
324
304
  Integrates the Metabox configurator into the specified container element.
325
305
 
326
306
  **TypeScript Signature:**
327
307
 
328
308
  ```typescript
329
- function integrateMetaBox(configuratorUrl: string, containerId: string, apiReadyCallback: (api: Communicator) => void, config?: Partial<MetaboxCommandConfig>): void;
309
+ function integrateMetabox(
310
+ configuratorId: string,
311
+ containerId?: string, // defaults to 'embed3DSource'
312
+ apiReadyCallback: (api: Communicator) => void, // required
313
+ config?: IntegrateMetaboxConfig,
314
+ ): void;
330
315
  ```
331
316
 
332
317
  **Parameters:**
333
318
 
334
- - `configuratorUrl` (string): The URL of your Metabox basic configurator
335
- - `containerId` (string): The ID of the HTML element where the configurator will be embedded
336
- - `apiReadyCallback` (function): Callback function that receives the Communicator API instance
337
- - `config` (Partial<MetaboxCommandConfig>, optional): Initial configuration for the integration. Set `standalone: true` to disable Metabox’s built-in UI/template logic and control everything from the host app. Other fields like `hostUrl` and `apiVersion` are populated automatically.
338
-
339
- **Example:**
340
-
341
- ```typescript
342
- integrateMetaBox('https://metabox.3dsource.com/metabox-configurator/basic/your-id', 'embed3DSource', (api) => {
343
- console.log('API ready!', api);
344
- });
345
- ```
346
-
347
- ### Command Classes
348
-
349
- All commands are sent to the configurator using the `api.sendCommandToMetaBox()` method.
350
-
351
- #### Command Payload Types
352
-
353
- All commands use strongly typed payloads defined in `ToMetaboxMessagePayloads`:
354
-
355
- ```typescript
356
- interface ToMetaboxMessagePayloads {
357
- [MetaboxBasicConfiguratorActions.getPdf]: void;
358
- [MetaboxBasicConfiguratorActions.getCallToActionInformation]: void;
359
- [MetaboxBasicConfiguratorActions.loadLevel]: { id: string };
360
- [MetaboxBasicConfiguratorActions.setProduct]: { productId: string };
361
- [MetaboxBasicConfiguratorActions.getScreenshot]: {
362
- format: MimeType;
363
- size?: { x: number; y: number };
364
- };
365
- [MetaboxBasicConfiguratorActions.setMaterialById]: {
366
- slotId: string;
367
- materialId: string;
368
- };
369
- [MetaboxBasicConfiguratorActions.setEnvironmentMaterialById]: {
370
- slotId: string;
371
- materialId: string;
372
- };
373
- [MetaboxBasicConfiguratorActions.showEmbeddedMenu]: { visible: boolean };
374
- [MetaboxBasicConfiguratorActions.showOverlayInterface]: { visible: boolean };
375
- [MetaboxBasicConfiguratorActions.forceSetDeviceType]: {
376
- deviceType: ApplicationDeviceTypes;
377
- };
378
- [MetaboxBasicConfiguratorActions.resetCamera]: void;
379
- [MetaboxBasicConfiguratorActions.applyZoom]: { zoom: number };
380
- [MetaboxBasicConfiguratorActions.initShowcase]: void;
381
- [MetaboxBasicConfiguratorActions.playShowcase]: void;
382
- [MetaboxBasicConfiguratorActions.pauseShowcase]: void;
383
- [MetaboxBasicConfiguratorActions.stopShowcase]: void;
384
- [MetaboxBasicConfiguratorActions.sendCommandToUnreal]: object;
385
- }
386
- ```
387
-
388
- #### Product Configuration
389
-
390
- ##### `SetProduct`
391
-
392
- Sets the active product by ID.
393
-
394
- ```typescript
395
- api.sendCommandToMetaBox(new SetProduct(productId));
396
- ```
319
+ - `configuratorId` (string, required): Basic Configurator ID (not a full URL). Internal iframe src: `https://{domain}/metabox-configurator/basic/{configuratorId}`.
320
+ - `containerId` (string, optional): Host element id. Defaults to `embed3DSource`.
321
+ - `apiReadyCallback` (required): Invoked once Metabox signals readiness.
322
+ - `config` (optional):
323
+ - `standalone?`: Disable built‑in UI/template logic inside iframe.
324
+ - `introImage?`, `introVideo?`, `loadingImage?`: Optional URLs appended as query params.
325
+ - `domain?`: Override domain (HTTPS enforced).
397
326
 
398
- ##### `SetMaterial`
327
+ **Throws:** Error if `configuratorId` or `containerId` empty, container element missing, or generated URL not HTTPS.
399
328
 
400
- Applies a material to a specific product slot.
401
-
402
- ```typescript
403
- api.sendCommandToMetaBox(new SetMaterial(slotId, materialId));
404
- ```
405
-
406
- #### Environment Configuration
407
-
408
- ##### `SetEnvironment`
409
-
410
- Changes the environment/background by ID.
411
-
412
- ```typescript
413
- api.sendCommandToMetaBox(new SetEnvironment(environmentId));
414
- ```
415
-
416
- ##### `SetEnvironmentMaterial`
417
-
418
- Applies a material to a specific environment slot.
419
-
420
- ```typescript
421
- api.sendCommandToMetaBox(new SetEnvironmentMaterial(slotId, materialId));
422
- ```
423
-
424
- #### Camera Controls
425
-
426
- ##### `ResetCamera`
427
-
428
- Resets the camera to its default position and rotation.
429
-
430
- ```typescript
431
- api.sendCommandToMetaBox(new ResetCamera());
432
- ```
433
-
434
- ##### `ApplyZoom`
435
-
436
- Applies zoom to the camera view.
437
-
438
- ```typescript
439
- api.sendCommandToMetaBox(new ApplyZoom(zoom));
440
- ```
441
-
442
- #### Interface Controls
443
-
444
- ##### `ShowEmbeddedMenu(visible)`
445
-
446
- Controls the visibility of the embedded configurator menu (right sidebar).
447
-
448
- Parameters:
449
-
450
- - `visible` (boolean): `true` to show the built-in menu; `false` to hide it.
451
-
452
- Examples:
453
-
454
- ```typescript
455
- api.sendCommandToMetaBox(new ShowEmbeddedMenu(true)); // Show menu
456
- api.sendCommandToMetaBox(new ShowEmbeddedMenu(false)); // Hide menu
457
- ```
458
-
459
- ##### `ShowOverlayInterface(visible)`
460
-
461
- Controls the visibility of the overlay interface over the Unreal viewport (e.g., on‑viewport buttons, tooltips, hotspots).
462
-
463
- Parameters:
464
-
465
- - `visible` (boolean): `true` to show the overlay; `false` to hide it.
466
-
467
- Examples:
468
-
469
- ```typescript
470
- api.sendCommandToMetaBox(new ShowOverlayInterface(true)); // Show overlay
471
- api.sendCommandToMetaBox(new ShowOverlayInterface(false)); // Hide overlay
472
- ```
473
-
474
- #### Media Generation
329
+ Notes:
475
330
 
476
- ##### `GetScreenshot`
331
+ - HTTPS is enforced: attempts to use non-HTTPS iframe URLs are rejected.
332
+ - If a previous iframe with id `embeddedContent` exists, it will be removed before inserting a new one.
477
333
 
478
- Captures a screenshot/render of the current view.
334
+ **Example:**
479
335
 
480
336
  ```typescript
481
- api.sendCommandToMetaBox(new GetScreenshot(mimeType, { x: 1920, y: 1080 }));
482
- ```
483
-
484
- **Parameters:**
337
+ import { IntegrateMetaboxConfig } from '@3dsource/metabox-front-api';
485
338
 
486
- - `mimeType`: Image format ('image/png', 'image/jpeg', etc.)
487
- - `size`: Optional dimensions object with x and y properties
488
-
489
- ##### `GetPdf`
490
-
491
- Generates a PDF of the current view.
339
+ const config: IntegrateMetaboxConfig = {
340
+ introImage: 'https://example.com/intro.png',
341
+ loadingImage: 'https://example.com/loading.png',
342
+ standalone: false,
343
+ };
492
344
 
493
- ```typescript
494
- api.sendCommandToMetaBox(new GetPdf());
345
+ integrateMetabox(
346
+ 'configurator-id',
347
+ 'embed3DSource',
348
+ (api) => {
349
+ console.log('API ready!', api);
350
+ },
351
+ config,
352
+ );
495
353
  ```
496
354
 
497
- ##### `GetCallToActionInformation`
498
-
499
- Triggers the CTA flow for E‑Com Configurators. This command sends the current configuration to the CTA callback URL configured in Metabox and, upon a successful response from your backend, opens the returned redirectUrl in a new browser tab.
355
+ ### Command Classes
500
356
 
501
- Notes:
357
+ All commands are sent using `api.sendCommandToMetabox(new SomeCommand(...))`.
502
358
 
503
- - Requires CTA to be configured in the Metabox Configurator Manager (label and callback URL).
504
- - No parameters are required.
505
- - Your backend must respond with a JSON object containing a redirectUrl field.
359
+ #### Command Payload Types (Internal)
506
360
 
507
361
  ```typescript
508
- api.sendCommandToMetaBox(new GetCallToActionInformation());
509
- ```
510
-
511
- Example backend response expected by Metabox:
512
-
513
- ```json
514
- {
515
- "redirectUrl": "https://your.site/thank-you-or-checkout"
362
+ interface ToMetaboxMessagePayloads {
363
+ metaboxConfig: { appId: string; config: MetaboxCommandConfig };
364
+ setProduct: { productId: string };
365
+ setEnvironment: { id: string };
366
+ getPdf: void;
367
+ getCallToActionInformation: void;
368
+ watchCallbacks: void; // enables experimental unrealCallback events
369
+ getScreenshot: { format: MimeType; size?: { x: number; y: number } };
370
+ setProductMaterialById: { slotId: string; materialId: string };
371
+ setEnvironmentMaterialById: { slotId: string; materialId: string };
372
+ showEmbeddedMenu: { visible: boolean };
373
+ showOverlayInterface: { visible: boolean };
374
+ forceSetDeviceType: { deviceType: ApplicationDeviceTypes };
375
+ resetCamera: void;
376
+ applyZoom: { zoom: number };
377
+ initShowcase: void;
378
+ playShowcase: void;
379
+ pauseShowcase: void;
380
+ stopShowcase: void;
381
+ sendCommandToUnreal: object; // arbitrary Unreal command payload
516
382
  }
517
383
  ```
518
384
 
519
- #### Showcase Management
385
+ #### Product & Environment
520
386
 
521
- ##### `InitShowcase`
387
+ - `SetProduct(productId: string)` – Select active product.
388
+ - `SetProductMaterial(slotId: string, materialId: string)` – Apply material to product slot.
389
+ - `SetEnvironment(id: string)` – Activate environment.
390
+ - `SetEnvironmentMaterial(slotId: string, materialId: string)` – Apply material to environment slot.
522
391
 
523
- Initializes a showcase with current product on scene.
392
+ #### UI & Overlay
524
393
 
525
- ```typescript
526
- api.sendCommandToMetaBox(new InitShowcase());
527
- ```
394
+ - `ShowEmbeddedMenu(visible: boolean)` – Toggle right sidebar menu.
395
+ - `ShowOverlayInterface(visible: boolean)` – Toggle viewport overlay UI.
528
396
 
529
- ##### `PlayShowcase`
397
+ #### Camera & View
530
398
 
531
- Plays the currently loaded showcase.
399
+ - `ResetCamera()` – Reset camera to initial state.
400
+ - `ApplyZoom(zoom: number)` – Apply a zoom factor within allowed range.
532
401
 
533
- ```typescript
534
- api.sendCommandToMetaBox(new PlayShowcase());
535
- ```
402
+ #### Showcase Control
536
403
 
537
- ##### `PauseShowcase`
404
+ - `InitShowcase()` – Initialize a product showcase sequence.
405
+ - `PlayShowcase()` / `PauseShowcase()` / `StopShowcase()` – Control showcase playback.
538
406
 
539
- Pauses the currently playing showcase.
407
+ #### Media & Export
540
408
 
541
- ```typescript
542
- api.sendCommandToMetaBox(new PauseShowcase());
543
- ```
409
+ - `GetScreenshot(format: MimeType, size?)` – Request a screenshot (listen to `screenshotReady`).
410
+ - `GetPdf()` – Request PDF generation (no dedicated event, handled internally server‑side; poll status messages if needed).
411
+ - `GetCallToActionInformation()` – Trigger CTA flow (backend must return `{ redirectUrl }`).
412
+
413
+ #### Advanced / Experimental
544
414
 
545
- ##### `StopShowcase`
415
+ - `UnrealCommand(command: object)` – Send low‑level command to Unreal. Use cautiously.
416
+ - `WatchCallbacks()` – Enable reception of `unrealCallback` events. Experimental / not guaranteed.
417
+ - `MetaboxConfig(appId: string, partialConfig)` – Internal initialization command (auto‑sent on communicator creation).
546
418
 
547
- Stops the currently playing showcase and returns to the initial state.
419
+ Example:
548
420
 
549
421
  ```typescript
550
- api.sendCommandToMetaBox(new StopShowcase());
422
+ import { UnrealCommand } from '@3dsource/metabox-front-api';
423
+ api.sendCommandToMetabox(new UnrealCommand({ type: 'SetLightIntensity', value: 2.5 }));
551
424
  ```
552
425
 
553
426
  ### Event Handling
554
427
 
555
- The API uses an event-driven architecture. Listen for events using the `addEventListener` method:
428
+ The API uses an event-driven architecture. Register listeners via `api.addEventListener(eventName, handler)`.
556
429
 
557
430
  #### Available Events
558
431
 
559
- | Event Name | Description | Data Type |
560
- | ------------------------- | ------------------------------------- | ----------------------------- |
561
- | `configuratorDataUpdated` | Fired when configuration data changes | `ModularConfiguratorEnvelope` |
562
- | `screenshotReady` | Fired when a screenshot is ready | `string` (base64 image data) |
563
- | `showcaseStatusChanged` | Fired when showcase status changes | `ShowCaseStatus` |
564
- | `viewportReady` | Fired when viewport is ready | `boolean` |
565
- | `statusMessageChanged` | Fired when status message changes | `string \| null` |
432
+ | Event | Payload Type | Description |
433
+ | ----------------------------- | -------------------- | ---------------------------------------------------------- | ------ | -------------------------- |
434
+ | `configuratorDataUpdated` | ConfiguratorEnvelope | Product/environment/material selections changed. |
435
+ | `ecomConfiguratorDataUpdated` | EcomConfigurator | CTA config (label, callbackUrl) updated. |
436
+ | `dataChannelConnected` | boolean | Unreal data channel connectivity state. |
437
+ | `viewportReady` | boolean | Unreal viewport visibility and readiness. |
438
+ | `showcaseStatusChanged` | ShowCaseStatus | Showcase playback status: init/play/pause/stop. |
439
+ | `statusMessageChanged` | string \| null | Human‑readable loading/progress message. |
440
+ | `screenshotReady` | string \| null | Base64 image data from latest screenshot (null if failed). |
441
+ | `videoResolutionChanged` | { width: number | null; height: number | null } | Video stream size changes. |
442
+ | `unrealCallback` | { json: object } | Unreal callback (requires WatchCallbacks; experimental). |
566
443
 
567
- ##### `configuratorDataUpdated`
568
-
569
- Fired when the configurator state changes (product, materials, environment, etc.).
444
+ #### Example: Basic State Listener
570
445
 
571
446
  ```typescript
572
- api.addEventListener('configuratorDataUpdated', (data: ConfiguratorEnvelope) => {
573
- console.log('Configurator state updated:', data);
574
- // Access data.product, data.materials, data.environment, etc.
447
+ api.addEventListener('configuratorDataUpdated', (data) => {
448
+ console.log('Product:', data.productId);
449
+ console.log('Product materials:', data.productMaterialsIds);
450
+ console.log('Environment:', data.environmentId);
451
+ console.log('Environment materials:', data.environmentMaterialsIds);
575
452
  });
576
453
  ```
577
454
 
578
- ##### `screenshotReady`
579
-
580
- Fired when a screenshot or fast render is completed.
455
+ #### Screenshot
581
456
 
582
457
  ```typescript
583
- api.addEventListener('screenshotReady', (imageData: string) => {
584
- console.log('Render completed');
585
- // imageData contains the base64 encoded image
586
- saveImage(imageData, 'screenshot.png');
458
+ api.addEventListener('screenshotReady', (image) => {
459
+ if (!image) return;
587
460
  });
588
461
  ```
589
462
 
@@ -632,18 +505,18 @@ Minimal example of triggering the Call‑To‑Action flow from your page once th
632
505
  <button id="cta-btn" disabled>Send configuration (CTA)</button>
633
506
 
634
507
  <script type="module">
635
- import { integrateMetaBox, GetCallToActionInformation } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@latest';
508
+ import { integrateMetabox, GetCallToActionInformation } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@latest/+esm';
636
509
 
637
510
  let api = null;
638
511
 
639
- integrateMetaBox('https://metabox.3dsource.com/metabox-configurator/basic/your-configurator-id', 'metabox-container', (apiInstance) => {
512
+ integrateMetabox('configurator-id', 'metabox-container', (apiInstance) => {
640
513
  api = apiInstance;
641
514
  document.getElementById('cta-btn').disabled = false;
642
515
  });
643
516
 
644
517
  document.getElementById('cta-btn').addEventListener('click', () => {
645
518
  // Triggers sending the current configuration to your CTA Callback URL
646
- api.sendCommandToMetaBox(new GetCallToActionInformation());
519
+ api.sendCommandToMetabox(new GetCallToActionInformation());
647
520
  });
648
521
  </script>
649
522
  ```
@@ -718,7 +591,7 @@ A complete HTML example showing how to integrate the Metabox configurator with v
718
591
  </div>
719
592
 
720
593
  <script type="module">
721
- import { integrateMetaBox, SetProduct, SetMaterial, GetScreenshot, saveImage } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@latest';
594
+ import { integrateMetabox, SetProduct, SetProductMaterial, GetScreenshot, saveImage } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@latest/+esm';
722
595
 
723
596
  let api = null;
724
597
  let isApiReady = false;
@@ -742,40 +615,41 @@ A complete HTML example showing how to integrate the Metabox configurator with v
742
615
 
743
616
  // Initialize configurator with error handling
744
617
  try {
745
- // Replace 'your-configurator-id' with your actual configurator ID from 3DSource
746
- const configuratorUrl = 'https://metabox.3dsource.com/metabox-configurator/basic/your-configurator-id';
747
-
748
- integrateMetaBox(configuratorUrl, 'metabox-container', (apiInstance) => {
749
- try {
750
- api = apiInstance;
751
- isApiReady = true;
752
- setLoadingState(false);
753
- console.log('Configurator ready!');
754
-
755
- // Listen for configurator state changes
756
- api.addEventListener('configuratorDataUpdated', (data) => {
757
- console.log('Configurator state updated:', data);
758
- // You can update your UI based on the current state
759
- // For example, update available materials, products, etc.
760
- });
761
-
762
- // Listen for screenshot completion
763
- api.addEventListener('screenshotReady', (imageData) => {
764
- console.log('Screenshot captured successfully');
765
- // Save the image with a timestamp
766
- saveImage(imageData, `configurator-screenshot-${Date.now()}.png`);
767
- });
768
-
769
- // Listen for errors
770
- api.addEventListener('error', (error) => {
771
- console.error('Configurator error:', error);
772
- showError('An error occurred in the configurator: ' + error.message);
773
- });
774
- } catch (error) {
775
- console.error('Error setting up API:', error);
776
- showError('Failed to initialize configurator API: ' + error.message);
777
- }
778
- });
618
+ // Replace 'configurator-id' with your actual configurator ID from 3DSource
619
+ const configuratorId = 'configurator-id';
620
+
621
+ integrate -
622
+ metabox.ts(configuratorId, 'metabox-container', (apiInstance) => {
623
+ try {
624
+ api = apiInstance;
625
+ isApiReady = true;
626
+ setLoadingState(false);
627
+ console.log('Configurator ready!');
628
+
629
+ // Listen for configurator state changes
630
+ api.addEventListener('configuratorDataUpdated', (data) => {
631
+ console.log('Configurator state updated:', data);
632
+ // You can update your UI based on the current state
633
+ // For example, update available materials, products, etc.
634
+ });
635
+
636
+ // Listen for screenshot completion
637
+ api.addEventListener('screenshotReady', (imageData) => {
638
+ console.log('Screenshot captured successfully');
639
+ // Save the image with a timestamp
640
+ saveImage(imageData, `configurator-screenshot-${Date.now()}.png`);
641
+ });
642
+
643
+ // Listen for errors
644
+ api.addEventListener('error', (error) => {
645
+ console.error('Configurator error:', error);
646
+ showError('An error occurred in the configurator: ' + error.message);
647
+ });
648
+ } catch (error) {
649
+ console.error('Error setting up API:', error);
650
+ showError('Failed to initialize configurator API: ' + error.message);
651
+ }
652
+ });
779
653
  } catch (error) {
780
654
  console.error('Error initializing configurator:', error);
781
655
  showError('Failed to load configurator: ' + error.message);
@@ -790,7 +664,7 @@ A complete HTML example showing how to integrate the Metabox configurator with v
790
664
 
791
665
  try {
792
666
  console.log(`Changing to product: ${productId}`);
793
- api.sendCommandToMetaBox(new SetProduct(productId));
667
+ api.sendCommandToMetabox(new SetProduct(productId));
794
668
  } catch (error) {
795
669
  console.error('Error changing product:', error);
796
670
  showError('Failed to change product: ' + error.message);
@@ -805,7 +679,7 @@ A complete HTML example showing how to integrate the Metabox configurator with v
805
679
 
806
680
  try {
807
681
  console.log(`Applying material ${materialId} to slot ${slotId}`);
808
- api.sendCommandToMetaBox(new SetMaterial(slotId, materialId));
682
+ api.sendCommandToMetabox(new SetProductMaterial(slotId, materialId));
809
683
  } catch (error) {
810
684
  console.error('Error applying material:', error);
811
685
  showError('Failed to apply material: ' + error.message);
@@ -821,7 +695,7 @@ A complete HTML example showing how to integrate the Metabox configurator with v
821
695
  try {
822
696
  console.log('Taking screenshot...');
823
697
  // Request high-quality screenshot in PNG format
824
- api.sendCommandToMetaBox(new GetScreenshot('image/png', { x: 1920, y: 1080 }));
698
+ api.sendCommandToMetabox(new GetScreenshot('image/png', { x: 1920, y: 1080 }));
825
699
  } catch (error) {
826
700
  console.error('Error taking screenshot:', error);
827
701
  showError('Failed to take screenshot: ' + error.message);
@@ -832,32 +706,14 @@ A complete HTML example showing how to integrate the Metabox configurator with v
832
706
  </html>
833
707
  ```
834
708
 
835
- **Key Features of this Example:**
836
-
837
- - **Error Handling**: Comprehensive error handling for all API operations
838
- - **Loading States**: Visual feedback while the configurator loads
839
- - **Button States**: Buttons are disabled until the API is ready
840
- - **Console Logging**: Detailed logging for debugging
841
- - **Responsive Design**: Clean, responsive button layout
842
- - **Latest CDN**: Uses `@latest` for the most recent version
843
-
844
- **To Use This Example:**
845
-
846
- 1. Replace `'your-configurator-id'` with your actual configurator ID
847
- 2. Replace placeholder product IDs (`'product-1'`, `'product-2'`) with real product IDs
848
- 3. Replace placeholder material IDs (`'material-red'`, `'material-blue'`) with real material IDs
849
- 4. Replace placeholder slot ID (`'slot-1'`) with the actual slot ID from your configurator
850
-
851
709
  ### React Integration Example
852
710
 
853
- A complete React component with TypeScript showing proper integration, error handling, and cleanup.
854
-
855
711
  ```tsx
856
712
  import React, { useEffect, useRef, useState, useCallback } from 'react';
857
- import { integrateMetaBox, Communicator, SetProduct, SetMaterial, GetScreenshot, saveImage, ConfiguratorEnvelope } from '@3dsource/metabox-front-api';
713
+ import { integrateMetabox, Communicator, ConfiguratorEnvelope, SetProduct, SetProductMaterial, GetScreenshot, saveImage } from '@3dsource/metabox-front-api';
858
714
 
859
715
  interface MetaboxConfiguratorProps {
860
- configuratorUrl: string;
716
+ configuratorId: string;
861
717
  onStateChange?: (data: ConfiguratorEnvelope) => void;
862
718
  onError?: (error: string) => void;
863
719
  className?: string;
@@ -869,7 +725,7 @@ interface ConfiguratorState {
869
725
  isApiReady: boolean;
870
726
  }
871
727
 
872
- const MetaboxConfigurator: React.FC<MetaboxConfiguratorProps> = ({ configuratorUrl, onStateChange, onError, className }) => {
728
+ const MetaboxConfigurator: React.FC<MetaboxConfiguratorProps> = ({ configuratorId, onStateChange, onError, className }) => {
873
729
  const containerRef = useRef<HTMLDivElement>(null);
874
730
  const [api, setApi] = useState<Communicator | null>(null);
875
731
  const [state, setState] = useState<ConfiguratorState>({
@@ -904,7 +760,7 @@ const MetaboxConfigurator: React.FC<MetaboxConfiguratorProps> = ({ configuratorU
904
760
  // Set the container ID
905
761
  containerRef.current!.id = containerId.current;
906
762
 
907
- integrateMetaBox(configuratorUrl, containerId.current, (apiInstance) => {
763
+ integrateMetabox(configuratorId, containerId.current, (apiInstance) => {
908
764
  if (!mounted) return; // Component was unmounted
909
765
 
910
766
  try {
@@ -956,7 +812,7 @@ const MetaboxConfigurator: React.FC<MetaboxConfiguratorProps> = ({ configuratorU
956
812
  console.log('Cleaning up Metabox Configurator');
957
813
  }
958
814
  };
959
- }, [configuratorUrl, onStateChange, handleError, api]);
815
+ }, [configuratorId, onStateChange, handleError, api]);
960
816
 
961
817
  // Command methods with error handling
962
818
  const changeProduct = useCallback(
@@ -968,7 +824,7 @@ const MetaboxConfigurator: React.FC<MetaboxConfiguratorProps> = ({ configuratorU
968
824
 
969
825
  try {
970
826
  console.log(`Changing to product: ${productId}`);
971
- api.sendCommandToMetaBox(new SetProduct(productId));
827
+ api.sendCommandToMetabox(new SetProduct(productId));
972
828
  } catch (error) {
973
829
  handleError(`Failed to change product: ${error instanceof Error ? error.message : String(error)}`);
974
830
  }
@@ -985,7 +841,7 @@ const MetaboxConfigurator: React.FC<MetaboxConfiguratorProps> = ({ configuratorU
985
841
 
986
842
  try {
987
843
  console.log(`Applying material ${materialId} to slot ${slotId}`);
988
- api.sendCommandToMetaBox(new SetMaterial(slotId, materialId));
844
+ api.sendCommandToMetabox(new SetProductMaterial(slotId, materialId));
989
845
  } catch (error) {
990
846
  handleError(`Failed to apply material: ${error instanceof Error ? error.message : String(error)}`);
991
847
  }
@@ -1001,7 +857,7 @@ const MetaboxConfigurator: React.FC<MetaboxConfiguratorProps> = ({ configuratorU
1001
857
 
1002
858
  try {
1003
859
  console.log('Taking screenshot...');
1004
- api.sendCommandToMetaBox(new GetScreenshot('image/png', { x: 1920, y: 1080 }));
860
+ api.sendCommandToMetabox(new GetScreenshot('image/png', { x: 1920, y: 1080 }));
1005
861
  } catch (error) {
1006
862
  handleError(`Failed to take screenshot: ${error instanceof Error ? error.message : String(error)}`);
1007
863
  }
@@ -1160,61 +1016,12 @@ const MetaboxConfigurator: React.FC<MetaboxConfiguratorProps> = ({ configuratorU
1160
1016
  export default MetaboxConfigurator;
1161
1017
  ```
1162
1018
 
1163
- **Key Features of this React Example:**
1164
-
1165
- - **Proper TypeScript Integration**: Full type safety with proper interfaces
1166
- - **Error Handling**: Comprehensive error states and user feedback
1167
- - **Component Cleanup**: Proper unmounting and memory leak prevention
1168
- - **Unique Container IDs**: Automatic ID generation to avoid conflicts
1169
- - **Loading States**: Visual feedback during initialization
1170
- - **Optimized Re-renders**: Uses useCallback to prevent unnecessary re-renders
1171
- - **Responsive Design**: Flexible button layout with proper styling
1172
-
1173
- **Usage Example:**
1174
-
1175
- ```tsx
1176
- // App.tsx
1177
- import React from 'react';
1178
- import MetaboxConfigurator from './components/MetaboxConfigurator';
1179
- import { ConfiguratorEnvelope } from '@3dsource/metabox-front-api';
1180
-
1181
- function App() {
1182
- const handleStateChange = (data: ConfiguratorEnvelope) => {
1183
- console.log('Configurator state changed:', data);
1184
- // Update your application state based on configurator changes
1185
- };
1186
-
1187
- const handleError = (error: string) => {
1188
- console.error('Configurator error:', error);
1189
- // Handle errors (show notifications, log to analytics, etc.)
1190
- };
1191
-
1192
- return (
1193
- <div className="App">
1194
- <h1>My Product Configurator</h1>
1195
- <MetaboxConfigurator configuratorUrl="https://metabox.3dsource.com/metabox-configurator/basic/your-configurator-id" onStateChange={handleStateChange} onError={handleError} className="my-configurator" />
1196
- </div>
1197
- );
1198
- }
1199
-
1200
- export default App;
1201
- ```
1202
-
1203
- **To Use This Component:**
1204
-
1205
- 1. Install the package: `npm install @3dsource/metabox-front-api`
1206
- 2. Replace `'your-configurator-id'` with your actual configurator ID
1207
- 3. Replace placeholder IDs in the component with your real product, material, and slot IDs
1208
- 4. Customize the styling by passing a `className` prop or modifying the inline styles
1209
-
1210
1019
  ### Angular Integration Example
1211
1020
 
1212
- A complete Angular component with TypeScript showing proper integration, error handling, and lifecycle management.
1213
-
1214
1021
  ```typescript
1215
1022
  // metabox-configurator.component.ts
1216
1023
  import { Component, input, OnInit, output, signal } from '@angular/core';
1217
- import { Communicator, ConfiguratorEnvelope, GetPdf, GetScreenshot, InitShowcase, integrateMetaBox, PauseShowcase, PlayShowcase, saveImage, SetMaterial, SetProduct, ShowEmbeddedMenu, ShowOverlayInterface, StopShowcase } from '@3dsource/metabox-front-api';
1024
+ import { Communicator, ConfiguratorEnvelope, GetPdf, GetScreenshot, InitShowcase, integrateMetabox, PauseShowcase, PlayShowcase, saveImage, SetProductMaterial, SetProduct, ShowEmbeddedMenu, ShowOverlayInterface, StopShowcase } from '@3dsource/metabox-front-api';
1218
1025
 
1219
1026
  interface ConfiguratorState {
1220
1027
  isLoading: boolean;
@@ -1411,7 +1218,7 @@ interface ConfiguratorState {
1411
1218
  ],
1412
1219
  })
1413
1220
  export class MetaboxConfiguratorComponent implements OnInit {
1414
- configuratorUrl = input.required<string>();
1221
+ configuratorId = input.required<string>();
1415
1222
  stateChange = output<ConfiguratorEnvelope>();
1416
1223
  errorFired = output<string>();
1417
1224
  state = signal<ConfiguratorState>({
@@ -1435,7 +1242,7 @@ export class MetaboxConfiguratorComponent implements OnInit {
1435
1242
 
1436
1243
  try {
1437
1244
  console.log(`Changing to product: ${productId}`);
1438
- this.api.sendCommandToMetaBox(new SetProduct(productId));
1245
+ this.api.sendCommandToMetabox(new SetProduct(productId));
1439
1246
  } catch (error) {
1440
1247
  this.handleError(`Failed to change product: ${this.getErrorMessage(error)}`);
1441
1248
  }
@@ -1448,7 +1255,7 @@ export class MetaboxConfiguratorComponent implements OnInit {
1448
1255
  }
1449
1256
 
1450
1257
  try {
1451
- this.api.sendCommandToMetaBox(new InitShowcase());
1258
+ this.api.sendCommandToMetabox(new InitShowcase());
1452
1259
  } catch (error) {
1453
1260
  this.handleError(`Failed to init showcase for product: ${this.getErrorMessage(error)}`);
1454
1261
  }
@@ -1462,7 +1269,7 @@ export class MetaboxConfiguratorComponent implements OnInit {
1462
1269
 
1463
1270
  try {
1464
1271
  console.log(`Stop showcase`);
1465
- this.api.sendCommandToMetaBox(new StopShowcase());
1272
+ this.api.sendCommandToMetabox(new StopShowcase());
1466
1273
  } catch (error) {
1467
1274
  this.handleError(`Failed to init showcase for product: ${this.getErrorMessage(error)}`);
1468
1275
  }
@@ -1476,7 +1283,7 @@ export class MetaboxConfiguratorComponent implements OnInit {
1476
1283
 
1477
1284
  try {
1478
1285
  console.log(`Play showcase`);
1479
- this.api.sendCommandToMetaBox(new PlayShowcase());
1286
+ this.api.sendCommandToMetabox(new PlayShowcase());
1480
1287
  } catch {
1481
1288
  this.handleError(`Failed to play showcase`);
1482
1289
  }
@@ -1490,7 +1297,7 @@ export class MetaboxConfiguratorComponent implements OnInit {
1490
1297
 
1491
1298
  try {
1492
1299
  console.log(`Pause showcase`);
1493
- this.api.sendCommandToMetaBox(new PauseShowcase());
1300
+ this.api.sendCommandToMetabox(new PauseShowcase());
1494
1301
  } catch {
1495
1302
  this.handleError(`Failed to pause showcase`);
1496
1303
  }
@@ -1504,7 +1311,7 @@ export class MetaboxConfiguratorComponent implements OnInit {
1504
1311
 
1505
1312
  try {
1506
1313
  console.log(`Applying material ${materialId} to slot ${slotId}`);
1507
- this.api.sendCommandToMetaBox(new SetMaterial(slotId, materialId));
1314
+ this.api.sendCommandToMetabox(new SetProductMaterial(slotId, materialId));
1508
1315
  } catch (error) {
1509
1316
  this.handleError(`Failed to apply material: ${this.getErrorMessage(error)}`);
1510
1317
  }
@@ -1518,7 +1325,7 @@ export class MetaboxConfiguratorComponent implements OnInit {
1518
1325
 
1519
1326
  try {
1520
1327
  console.log('Taking screenshot...');
1521
- this.api.sendCommandToMetaBox(new GetScreenshot('image/png', { x: 1920, y: 1080 }));
1328
+ this.api.sendCommandToMetabox(new GetScreenshot('image/png', { x: 1920, y: 1080 }));
1522
1329
  } catch (error) {
1523
1330
  this.handleError(`Failed to take screenshot: ${this.getErrorMessage(error)}`);
1524
1331
  }
@@ -1531,7 +1338,7 @@ export class MetaboxConfiguratorComponent implements OnInit {
1531
1338
  }
1532
1339
  try {
1533
1340
  console.log('Generating cta information...');
1534
- this.api.sendCommandToMetaBox(new GetCallToActionInformation());
1341
+ this.api.sendCommandToMetabox(new GetCallToActionInformation());
1535
1342
  } catch (error) {
1536
1343
  this.handleError(`Failed to generating cta information: ${this.getErrorMessage(error)}`);
1537
1344
  }
@@ -1545,7 +1352,7 @@ export class MetaboxConfiguratorComponent implements OnInit {
1545
1352
 
1546
1353
  try {
1547
1354
  console.log('Generating PDF...');
1548
- this.api.sendCommandToMetaBox(new GetPdf());
1355
+ this.api.sendCommandToMetabox(new GetPdf());
1549
1356
  } catch (error) {
1550
1357
  this.handleError(`Failed to generating pdf: ${this.getErrorMessage(error)}`);
1551
1358
  }
@@ -1561,15 +1368,15 @@ export class MetaboxConfiguratorComponent implements OnInit {
1561
1368
  return;
1562
1369
  }
1563
1370
 
1564
- this.api.sendCommandToMetaBox(new ShowEmbeddedMenu(true));
1565
- this.api.sendCommandToMetaBox(new ShowOverlayInterface(true));
1371
+ this.api.sendCommandToMetabox(new ShowEmbeddedMenu(true));
1372
+ this.api.sendCommandToMetabox(new ShowOverlayInterface(true));
1566
1373
  }
1567
1374
 
1568
1375
  private initializeConfigurator() {
1569
1376
  try {
1570
1377
  this.updateState({ isLoading: true, error: null });
1571
1378
 
1572
- integrateMetaBox(this.configuratorUrl(), this.containerId(), (apiInstance) => {
1379
+ integrateMetabox(this.configuratorId(), this.containerId(), (apiInstance) => {
1573
1380
  try {
1574
1381
  this.api = apiInstance;
1575
1382
  this.updateState({ isLoading: false, isApiReady: true });
@@ -1597,7 +1404,7 @@ export class MetaboxConfiguratorComponent implements OnInit {
1597
1404
  });
1598
1405
 
1599
1406
  // Listen for screenshot completion
1600
- this.api.addEventListener('screenshot', (imageData: string | null) => {
1407
+ this.api.addEventListener('screenshotReady', (imageData: string | null) => {
1601
1408
  console.log(`Screenshot captured successfully ${imageData ?? ''}`);
1602
1409
  saveImage(imageData ?? '', `configurator-screenshot-${Date.now()}.png`);
1603
1410
  });
@@ -1645,7 +1452,7 @@ import { ConfiguratorEnvelope } from '@3dsource/metabox-front-api';
1645
1452
  template: `
1646
1453
  <div class="app-container">
1647
1454
  <h1>My Product Configurator</h1>
1648
- <app-metabox-configurator [configuratorUrl]="configuratorUrl" (stateChange)="onConfiguratorStateChange($event)" (errorFired)="onConfiguratorError($event)"></app-metabox-configurator>
1455
+ <app-metabox-configurator [configuratorId]="configuratorId" (stateChange)="onConfiguratorStateChange($event)" (errorFired)="onConfiguratorError($event)"></app-metabox-configurator>
1649
1456
  </div>
1650
1457
  `,
1651
1458
  styles: [
@@ -1659,7 +1466,7 @@ import { ConfiguratorEnvelope } from '@3dsource/metabox-front-api';
1659
1466
  ],
1660
1467
  })
1661
1468
  export class AppComponent {
1662
- configuratorUrl = 'https://metabox.3dsource.com/metabox-configurator/basic/your-configurator-id';
1469
+ configuratorId = 'configurator-id';
1663
1470
 
1664
1471
  onConfiguratorStateChange(data: ConfiguratorEnvelope): void {
1665
1472
  console.log('Configurator state changed:', data);
@@ -1677,7 +1484,7 @@ export class AppComponent {
1677
1484
 
1678
1485
  1. Install the package: `npm install @3dsource/metabox-front-api`
1679
1486
  2. Import the component in your Angular module
1680
- 3. Replace `'your-configurator-id'` with your actual configurator ID
1487
+ 3. Replace `'configurator-id'` with your actual configurator ID
1681
1488
  4. Replace placeholder IDs with your real product, material, and slot IDs
1682
1489
  5. Customize the styling by modifying the component styles
1683
1490
 
@@ -1688,7 +1495,7 @@ export class AppComponent {
1688
1495
  Always implement proper error handling when working with the API:
1689
1496
 
1690
1497
  ```typescript
1691
- integrateMetaBox(configuratorUrl, containerId, (api) => {
1498
+ integrateMetabox(configuratorId, containerId, (api) => {
1692
1499
  try {
1693
1500
  // Set up event listeners with error handling
1694
1501
  api.addEventListener('configuratorDataUpdated', (data) => {
@@ -1700,7 +1507,7 @@ integrateMetaBox(configuratorUrl, containerId, (api) => {
1700
1507
  });
1701
1508
 
1702
1509
  // Send commands with error handling
1703
- api.sendCommandToMetaBox(new SetProduct(productId));
1510
+ api.sendCommandToMetabox(new SetProduct(productId));
1704
1511
  } catch (error) {
1705
1512
  console.error('Error initializing configurator:', error);
1706
1513
  }
@@ -1742,7 +1549,7 @@ class ConfiguratorStateManager {
1742
1549
  ```typescript
1743
1550
  // Debounce example
1744
1551
  const debouncedMaterialChange = debounce((slotId, materialId) => {
1745
- api.sendCommandToMetaBox(new SetMaterial(slotId, materialId));
1552
+ api.sendCommandToMetabox(new SetProductMaterial(slotId, materialId));
1746
1553
  }, 300);
1747
1554
  ```
1748
1555
 
@@ -1779,7 +1586,7 @@ const hideLoadingState = () => {
1779
1586
  document.getElementById('loading').style.display = 'none';
1780
1587
  };
1781
1588
 
1782
- integrateMetaBox(configuratorUrl, containerId, (api) => {
1589
+ integrateMetabox(configuratorId, containerId, (api) => {
1783
1590
  hideLoadingState();
1784
1591
  // Continue with initialization
1785
1592
  });
@@ -1795,8 +1602,8 @@ integrateMetaBox(configuratorUrl, containerId, (api) => {
1795
1602
 
1796
1603
  **Solutions**:
1797
1604
 
1798
- - Verify the configurator URL is correct and accessible
1799
- - Ensure the container element exists in the DOM before calling `integrateMetaBox`
1605
+ - Verify the configurator ID is correct and accessible
1606
+ - Ensure the container element exists in the DOM before calling `integrateMetabox`
1800
1607
  - Check that you're using HTTPS (required for Unreal Engine)
1801
1608
  - Verify your configurator ID is valid
1802
1609
 
@@ -1827,7 +1634,7 @@ if (location.protocol !== 'https:' && location.hostname !== 'localhost') {
1827
1634
  ```typescript
1828
1635
  let apiReady = false;
1829
1636
 
1830
- integrateMetaBox(configuratorUrl, containerId, (api) => {
1637
+ integrateMetabox(configuratorId, containerId, (api) => {
1831
1638
  apiReady = true;
1832
1639
  // Now it's safe to send commands
1833
1640
  });
@@ -1835,7 +1642,7 @@ integrateMetaBox(configuratorUrl, containerId, (api) => {
1835
1642
  // Wait for API to be ready
1836
1643
  const sendCommand = (command) => {
1837
1644
  if (apiReady && api) {
1838
- api.sendCommandToMetaBox(command);
1645
+ api.sendCommandToMetabox(command);
1839
1646
  } else {
1840
1647
  console.warn('API not ready yet');
1841
1648
  }
@@ -1853,7 +1660,7 @@ const sendCommand = (command) => {
1853
1660
  - Ensure the configurator is configured to send the expected events
1854
1661
 
1855
1662
  ```typescript
1856
- integrateMetaBox(configuratorUrl, containerId, (api) => {
1663
+ integrateMetabox(configuratorId, containerId, (api) => {
1857
1664
  // Set up listeners immediately
1858
1665
  api.addEventListener('configuratorDataUpdated', (data) => {
1859
1666
  console.log('Event received:', data);
@@ -1862,7 +1669,7 @@ integrateMetaBox(configuratorUrl, containerId, (api) => {
1862
1669
  // Test if events are working
1863
1670
  setTimeout(() => {
1864
1671
  console.log('Testing event system...');
1865
- api.sendCommandToMetaBox(new SetProduct('test-product'));
1672
+ api.sendCommandToMetabox(new SetProduct('test-product'));
1866
1673
  }, 1000);
1867
1674
  });
1868
1675
  ```
@@ -1882,39 +1689,17 @@ integrateMetaBox(configuratorUrl, containerId, (api) => {
1882
1689
  api.addEventListener('configuratorDataUpdated', (data) => {
1883
1690
  // Scene is loaded, safe to take screenshot
1884
1691
  setTimeout(() => {
1885
- api.sendCommandToMetaBox(new GetScreenshot('image/png', { x: 1920, y: 1080 }));
1692
+ api.sendCommandToMetabox(new GetScreenshot('image/png', { x: 1920, y: 1080 }));
1886
1693
  }, 500);
1887
1694
  });
1888
1695
  ```
1889
1696
 
1890
- ### Debug Mode
1891
-
1892
- Enable debug logging to troubleshoot issues:
1893
-
1894
- ```typescript
1895
- // Enable debug mode (if available)
1896
- window.METABOX_DEBUG = true;
1897
-
1898
- integrateMetaBox(configuratorUrl, containerId, (api) => {
1899
- console.log('API initialized:', api);
1900
-
1901
- // Log all events
1902
- api.addEventListener('configuratorDataUpdated', (data) => {
1903
- console.log('State update:', data);
1904
- });
1905
-
1906
- api.addEventListener('screenshotReady', (imageData) => {
1907
- console.log('Render completed, data length:', imageData.length);
1908
- });
1909
- });
1910
- ```
1911
-
1912
1697
  ### Getting Help
1913
1698
 
1914
1699
  If you're still experiencing issues:
1915
1700
 
1916
1701
  1. Check the browser console for error messages
1917
- 2. Verify your configurator URL in a separate browser tab
1702
+ 2. Verify your configurator ID in a separate browser tab
1918
1703
  3. Test with a minimal example to isolate the issue
1919
1704
  4. Contact support with:
1920
1705
 
@@ -1942,41 +1727,6 @@ The Metabox Front API supports modern browsers with ES6 module support:
1942
1727
  - **HTTPS**: Required for Unreal Engine integration
1943
1728
  - **Modern JavaScript**: ES2017+ features are used
1944
1729
 
1945
- ## Contributing
1946
-
1947
- We welcome contributions to improve the Metabox Front API! Here's how you can help:
1948
-
1949
- ### Development Setup
1950
-
1951
- 1. Clone the repository
1952
- 2. Install dependencies: `npm install`
1953
- 3. Build the project: `npm run build`
1954
- 4. Run tests: `npm test`
1955
-
1956
- ### Guidelines
1957
-
1958
- - Follow TypeScript best practices
1959
- - Add tests for new features
1960
- - Update documentation for API changes
1961
- - Use semantic commit messages
1962
-
1963
- ### Reporting Issues
1964
-
1965
- When reporting issues, please include:
1966
-
1967
- - Browser version and operating system
1968
- - Minimal code example reproducing the issue
1969
- - Expected vs actual behavior
1970
- - Console error messages (if any)
1971
-
1972
- ### Feature Requests
1973
-
1974
- We're always looking to improve the API. Feel free to suggest new features or enhancements through our issue tracker.
1975
-
1976
- ---
1977
-
1978
- **Need help?** Contact our support team or check our documentation for more detailed guides and tutorials.
1979
-
1980
1730
  ## Standalone Mode
1981
1731
 
1982
1732
  Standalone mode lets you embed the Metabox renderer without the built‑in Metabox UI and template logic. This is ideal when you want to build a fully custom UI (menus, buttons, flows) and drive the configurator entirely through this API.
@@ -1986,26 +1736,26 @@ When standalone is enabled, the embedded page does not render Metabox’s intern
1986
1736
  Key points:
1987
1737
 
1988
1738
  - Purpose: use when you need a 100% custom interface and logic on the host page.
1989
- - Behavior: Metabox default UI, embedded menu and template logic are disabled on the iframe side.
1739
+ - Behavior: Metabox default UI, embedded menu, and template logic are disabled on the iframe side.
1990
1740
  - Control: you drive everything with API commands and events.
1991
- - Availability: supported since v2 of the API (example versions ≥ 2.0.1).
1741
+ - Availability: supported since v2 of the API.
1992
1742
 
1993
1743
  How to enable
1994
1744
 
1995
- Pass the 4th argument config with standalone set to true when calling integrateMetaBox.
1745
+ Pass as param to config with a standalone set to true when calling integrateMetabox.
1996
1746
 
1997
1747
  TypeScript example:
1998
1748
 
1999
1749
  ```typescript
2000
- import { integrateMetaBox, Communicator, SetProduct, SetEnvironment } from '@3dsource/metabox-front-api';
1750
+ import { integrateMetabox, Communicator, SetProduct, SetEnvironment } from '@3dsource/metabox-front-api';
2001
1751
 
2002
- integrateMetaBox(
2003
- 'https://metabox.3dsource.com/metabox-configurator/basic/your-configurator-id',
1752
+ integrateMetabox(
1753
+ 'configurator-id',
2004
1754
  'embed3DSource',
2005
1755
  (api: Communicator) => {
2006
1756
  // Send your initial commands to establish state
2007
- api.sendCommandToMetaBox(new SetProduct('your-product-id'));
2008
- api.sendCommandToMetaBox(new SetEnvironment('your-environment-id'));
1757
+ api.sendCommandToMetabox(new SetProduct('your-product-id'));
1758
+ api.sendCommandToMetabox(new SetEnvironment('your-environment-id'));
2009
1759
  },
2010
1760
  { standalone: true },
2011
1761
  );
@@ -2015,22 +1765,22 @@ JavaScript (CDN) example:
2015
1765
 
2016
1766
  ```html
2017
1767
  <script type="module">
2018
- import { integrateMetaBox, SetProduct, SetEnvironment } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@2.0.1/+esm';
1768
+ import { integrateMetabox, SetProduct, SetEnvironment } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@latest/+esm';
2019
1769
 
2020
- integrateMetaBox(
2021
- 'https://metabox.3dsource.com/metabox-configurator/basic/your-configurator-id',
1770
+ integrateMetabox(
1771
+ 'configurator-id',
2022
1772
  'embed3DSource',
2023
1773
  (api) => {
2024
- api.sendCommandToMetaBox(new SetProduct('your-product-id'));
2025
- api.sendCommandToMetaBox(new SetEnvironment('your-environment-id'));
1774
+ api.sendCommandToMetabox(new SetProduct('your-product-id'));
1775
+ api.sendCommandToMetabox(new SetEnvironment('your-environment-id'));
2026
1776
  },
2027
1777
  { standalone: true },
2028
1778
  );
2029
1779
  </script>
2030
1780
  ```
2031
1781
 
2032
- Notes and tips
1782
+ Notes and tips:
2033
1783
 
2034
1784
  - In standalone mode, nothing will change until you send initial commands (e.g., set product/environment). If you see a blank/default view, ensure you dispatch the necessary SetProduct/SetEnvironment commands once api is ready.
2035
1785
  - All events (like configuratorDataUpdated, screenshotReady) still work; use them to keep your UI synchronized.
2036
- - Runtime validation still applies: use an HTTPS URL and a valid containerId. The config.hostUrl and config.apiVersion are set automatically by the library; you typically don’t need to pass them.
1786
+ - Runtime validation still applies: configuratorId and containerId must be non-empty. HTTPS is enforced for the internally constructed iframe URL. The hostUrl and apiVersion values are handled internally; you do not need to pass them.