@3dsource/metabox-front-api 1.2.3-dev.0 → 1.2.4
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 +139 -3
- package/index.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,6 +11,7 @@ their material slots, and materials, environments.
|
|
|
11
11
|
- [Installation](#installation)
|
|
12
12
|
- [Quick Start](#quick-start)
|
|
13
13
|
- [API Reference](#api-reference)
|
|
14
|
+
- [Steps to build custom menu](#steps-to-build-custom-menu)
|
|
14
15
|
- [System Terminology](#system-terminology)
|
|
15
16
|
- [Core Functions](#core-functions)
|
|
16
17
|
- [Command Classes](#command-classes)
|
|
@@ -45,7 +46,7 @@ their material slots, and materials, environments.
|
|
|
45
46
|
For use with frameworks like Angular, React, Vue, etc.:
|
|
46
47
|
|
|
47
48
|
```bash
|
|
48
|
-
npm install @3dsource/metabox-front-api@^1.2.
|
|
49
|
+
npm install @3dsource/metabox-front-api@^1.2.4 --save
|
|
49
50
|
```
|
|
50
51
|
|
|
51
52
|
Then import the required components:
|
|
@@ -58,7 +59,7 @@ import { integrateMetaBox, Communicator, ConfiguratorEnvelope, SetProduct, SetMa
|
|
|
58
59
|
|
|
59
60
|
Alternative CDN options:
|
|
60
61
|
|
|
61
|
-
- **jsDelivr**: `https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@^1.2.
|
|
62
|
+
- **jsDelivr**: `https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@^1.2.4/+esm`
|
|
62
63
|
|
|
63
64
|
For quick prototyping or vanilla JavaScript projects:
|
|
64
65
|
|
|
@@ -102,7 +103,7 @@ Create a container element where the Metabox Configurator will be embedded:
|
|
|
102
103
|
|
|
103
104
|
```html
|
|
104
105
|
<script type="module">
|
|
105
|
-
import { integrateMetaBox, SetProduct, SetMaterial, SetEnvironment, GetScreenshot, saveImage } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@1.2.
|
|
106
|
+
import { integrateMetaBox, SetProduct, SetMaterial, SetEnvironment, GetScreenshot, saveImage } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@1.2.4';
|
|
106
107
|
|
|
107
108
|
class MetaboxIntegrator {
|
|
108
109
|
constructor() {
|
|
@@ -286,6 +287,32 @@ const metaboxIntegrator = new MetaboxIntegrator();
|
|
|
286
287
|
- **component** - Product in the Modular configurator context.
|
|
287
288
|
- **componentId** - Unique Component ID within the Metabox system; mandatory. Assigned by the Metabox system automatically after the Modular configurator is created in Metabox.
|
|
288
289
|
- **componentType** - Exists in Modular Configurator only; the name of the type of the product component, which can include one or several separate products of the same category (examples of product component types: truck wheel, truck bumper). It is set by an unreal artist while creating the digital twin model and is automatically added to the Metabox system after this twin is uploaded to Metabox.
|
|
290
|
+
- **E‑Com Configurator** — can be created from any Basic or Modular Configurator by adding a CTA (call‑to‑action) button to the standard configurator right‑nav menu in the Metabox Configurator Manager (where users create and edit configurators).
|
|
291
|
+
To enable the CTA button, add two mandatory parameters in the Configurator Manager:
|
|
292
|
+
- Text label for the CTA button (examples: "Get Quote", "Contact Dealer").
|
|
293
|
+
- Callback URL for an HTTP POST request. Response requirements:
|
|
294
|
+
```json
|
|
295
|
+
{
|
|
296
|
+
"redirectUrl": "https://your.site/thank-you-or-checkout"
|
|
297
|
+
}
|
|
298
|
+
```
|
|
299
|
+
When the user clicks the CTA button in the configurator:
|
|
300
|
+
- Metabox generates a JSON payload with the current configuration and sends it to the specified Callback URL.
|
|
301
|
+
- Your backend decides how to use the configuration JSON (e.g., generate a PDF or build a product list).
|
|
302
|
+
- 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.).
|
|
303
|
+
|
|
304
|
+
### Steps to build custom menu
|
|
305
|
+
|
|
306
|
+
- **configuratorDataUpdated** - add event listener to receive get configurator data and then updates
|
|
307
|
+
- **showEmbeddedMenu** - hide embedded metabox right sidebar, but if you want to show it again, you can use this method
|
|
308
|
+
- **showOverlayInterface** - hide viewport metabox actions if you want to add yours
|
|
309
|
+
- **setEnvironment** - set active environment when you want to change environment
|
|
310
|
+
- **setEnvironmentMaterialById** - set environment material by slot ID
|
|
311
|
+
- **setProduct** - set active product when you want to change product
|
|
312
|
+
- **setProductMaterialById** - set product material by slot ID
|
|
313
|
+
- **getScreenshot** - get screenshot
|
|
314
|
+
- **getCallToActionInformation** - send call to action information to api endpoint provided in CTA configuration
|
|
315
|
+
- **getPdf** - get PDF.
|
|
289
316
|
|
|
290
317
|
### Core Functions
|
|
291
318
|
|
|
@@ -317,6 +344,54 @@ integrateMetaBox('https://metabox.3dsource.com/metabox-configurator/basic/your-i
|
|
|
317
344
|
|
|
318
345
|
All commands are sent to the configurator using the `api.sendCommandToMetaBox()` method.
|
|
319
346
|
|
|
347
|
+
#### Command Payload Types
|
|
348
|
+
|
|
349
|
+
All commands use strongly typed payloads defined in `ToMetaboxMessagePayloads`:
|
|
350
|
+
|
|
351
|
+
```typescript
|
|
352
|
+
interface ToMetaboxMessagePayloads {
|
|
353
|
+
[MetaboxBasicConfiguratorActions.getPdf]: void;
|
|
354
|
+
[MetaboxBasicConfiguratorActions.getCallToActionInformation]: void;
|
|
355
|
+
[MetaboxBasicConfiguratorActions.loadLevel]: { id: string };
|
|
356
|
+
[MetaboxBasicConfiguratorActions.setProduct]: { productId: string };
|
|
357
|
+
/**
|
|
358
|
+
* @deprecated
|
|
359
|
+
* @hidden use
|
|
360
|
+
* {@link MetaboxBasicConfiguratorActions.watchCallbacks}
|
|
361
|
+
*/
|
|
362
|
+
[MetaboxBasicConfiguratorActions.addResponse]: void;
|
|
363
|
+
[MetaboxBasicConfiguratorActions.watchCallbacks]: void;
|
|
364
|
+
[MetaboxBasicConfiguratorActions.getFastRender]: {
|
|
365
|
+
format: MimeType;
|
|
366
|
+
size?: { x: number; y: number };
|
|
367
|
+
};
|
|
368
|
+
[MetaboxBasicConfiguratorActions.getScreenshot]: {
|
|
369
|
+
format: MimeType;
|
|
370
|
+
size?: { x: number; y: number };
|
|
371
|
+
};
|
|
372
|
+
[MetaboxBasicConfiguratorActions.setMaterialById]: {
|
|
373
|
+
slotId: string;
|
|
374
|
+
materialId: string;
|
|
375
|
+
};
|
|
376
|
+
[MetaboxBasicConfiguratorActions.setEnvironmentMaterialById]: {
|
|
377
|
+
slotId: string;
|
|
378
|
+
materialId: string;
|
|
379
|
+
};
|
|
380
|
+
[MetaboxBasicConfiguratorActions.showEmbeddedMenu]: { visible: boolean };
|
|
381
|
+
[MetaboxBasicConfiguratorActions.showOverlayInterface]: { visible: boolean };
|
|
382
|
+
[MetaboxBasicConfiguratorActions.forceSetDeviceType]: {
|
|
383
|
+
deviceType: ApplicationDeviceTypes;
|
|
384
|
+
};
|
|
385
|
+
[MetaboxBasicConfiguratorActions.resetCamera]: void;
|
|
386
|
+
[MetaboxBasicConfiguratorActions.applyZoom]: { zoom: number };
|
|
387
|
+
[MetaboxBasicConfiguratorActions.initShowcase]: { productId: string };
|
|
388
|
+
[MetaboxBasicConfiguratorActions.playShowcase]: void;
|
|
389
|
+
[MetaboxBasicConfiguratorActions.pauseShowcase]: void;
|
|
390
|
+
[MetaboxBasicConfiguratorActions.stopShowcase]: void;
|
|
391
|
+
[MetaboxBasicConfiguratorActions.sendCommandToUnreal]: object;
|
|
392
|
+
}
|
|
393
|
+
```
|
|
394
|
+
|
|
320
395
|
#### Product Configuration
|
|
321
396
|
|
|
322
397
|
##### `SetProduct`
|
|
@@ -412,6 +487,28 @@ Generates a PDF of the current view.
|
|
|
412
487
|
api.sendCommandToMetaBox(new GetPdf());
|
|
413
488
|
```
|
|
414
489
|
|
|
490
|
+
##### `GetCallToActionInformation`
|
|
491
|
+
|
|
492
|
+
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.
|
|
493
|
+
|
|
494
|
+
Notes:
|
|
495
|
+
|
|
496
|
+
- Requires CTA to be configured in the Metabox Configurator Manager (label and callback URL).
|
|
497
|
+
- No parameters are required.
|
|
498
|
+
- Your backend must respond with a JSON object containing a redirectUrl field.
|
|
499
|
+
|
|
500
|
+
```typescript
|
|
501
|
+
api.sendCommandToMetaBox(new GetCallToActionInformation());
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
Example backend response expected by Metabox:
|
|
505
|
+
|
|
506
|
+
```json
|
|
507
|
+
{
|
|
508
|
+
"redirectUrl": "https://your.site/thank-you-or-checkout"
|
|
509
|
+
}
|
|
510
|
+
```
|
|
511
|
+
|
|
415
512
|
#### Showcase Management
|
|
416
513
|
|
|
417
514
|
##### `InitShowcase`
|
|
@@ -511,6 +608,31 @@ api.addEventListener('screenshotReady', (imageData: string | null) => {
|
|
|
511
608
|
|
|
512
609
|
## Examples
|
|
513
610
|
|
|
611
|
+
### E‑Com CTA example
|
|
612
|
+
|
|
613
|
+
Minimal example of triggering the Call‑To‑Action flow from your page once the API is ready.
|
|
614
|
+
|
|
615
|
+
```html
|
|
616
|
+
<div id="metabox-container"></div>
|
|
617
|
+
<button id="cta-btn" disabled>Send configuration (CTA)</button>
|
|
618
|
+
|
|
619
|
+
<script type="module">
|
|
620
|
+
import { integrateMetaBox, GetCallToActionInformation } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@latest';
|
|
621
|
+
|
|
622
|
+
let api = null;
|
|
623
|
+
|
|
624
|
+
integrateMetaBox('https://metabox.3dsource.com/metabox-configurator/basic/your-configurator-id', 'metabox-container', (apiInstance) => {
|
|
625
|
+
api = apiInstance;
|
|
626
|
+
document.getElementById('cta-btn').disabled = false;
|
|
627
|
+
});
|
|
628
|
+
|
|
629
|
+
document.getElementById('cta-btn').addEventListener('click', () => {
|
|
630
|
+
// Triggers sending the current configuration to your CTA Callback URL
|
|
631
|
+
api.sendCommandToMetaBox(new GetCallToActionInformation());
|
|
632
|
+
});
|
|
633
|
+
</script>
|
|
634
|
+
```
|
|
635
|
+
|
|
514
636
|
### Basic Product Configurator
|
|
515
637
|
|
|
516
638
|
A complete HTML example showing how to integrate the Metabox configurator with vanilla JavaScript.
|
|
@@ -1127,6 +1249,7 @@ interface ConfiguratorState {
|
|
|
1127
1249
|
<button (click)="applyMaterial('slot-1', 'material-blue')" [disabled]="!_state.isApiReady" class="control-button">Blue Material</button>
|
|
1128
1250
|
<button (click)="getPdf()" [disabled]="!_state.isApiReady" class="control-button">Get PDF</button>
|
|
1129
1251
|
<button (click)="takeScreenshot()" [disabled]="!_state.isApiReady" class="control-button screenshot-button">📸 Take Screenshot</button>
|
|
1252
|
+
<button (click)="sendCallToActionInformation()" [disabled]="!_state.isApiReady" class="control-button">Send Call To Action Information</button>
|
|
1130
1253
|
</div>
|
|
1131
1254
|
</div>
|
|
1132
1255
|
}
|
|
@@ -1387,6 +1510,19 @@ export class MetaboxConfiguratorComponent implements OnInit {
|
|
|
1387
1510
|
}
|
|
1388
1511
|
}
|
|
1389
1512
|
|
|
1513
|
+
sendCallToActionInformation(): void {
|
|
1514
|
+
if (!this.state().isApiReady || !this.api) {
|
|
1515
|
+
console.warn('API not ready yet');
|
|
1516
|
+
return;
|
|
1517
|
+
}
|
|
1518
|
+
try {
|
|
1519
|
+
console.log('Generating cta information...');
|
|
1520
|
+
this.api.sendCommandToMetaBox(new GetCallToActionInformation());
|
|
1521
|
+
} catch (error) {
|
|
1522
|
+
this.handleError(`Failed to generating cta information: ${this.getErrorMessage(error)}`);
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1390
1526
|
getPdf(): void {
|
|
1391
1527
|
if (!this.state().isApiReady || !this.api) {
|
|
1392
1528
|
console.warn('API not ready yet');
|
package/index.d.ts
CHANGED
|
@@ -196,6 +196,8 @@ interface UniversalConfigurator {
|
|
|
196
196
|
/** The camera settings used in the configurator. */
|
|
197
197
|
/** Indicates if the configurator is active. */
|
|
198
198
|
isActive: boolean;
|
|
199
|
+
/** Indicates if the cta in ecom configurator is enabled or not. */
|
|
200
|
+
ctaEnabled: boolean;
|
|
199
201
|
/** GraphQL typename for the configurator. */
|
|
200
202
|
__typename: 'UniversalConfigurator';
|
|
201
203
|
}
|