@3dsource/metabox-modular-configurator-api 0.0.4-dev.0 → 0.0.5
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 +62 -6
- package/index.d.ts +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,6 +12,7 @@ components, component types, materials, and capture screenshots or PDFs.
|
|
|
12
12
|
- [Quick Start](#quick-start)
|
|
13
13
|
- [API Reference](#api-reference)
|
|
14
14
|
- [System Terminology](#system-terminology)
|
|
15
|
+
- [Steps to build custom menu](#steps-to-build-custom-menu)
|
|
15
16
|
- [Core Integration](#core-integration)
|
|
16
17
|
- [Type Definitions](#type-definitions)
|
|
17
18
|
- [Command Classes](#command-classes)
|
|
@@ -26,6 +27,7 @@ components, component types, materials, and capture screenshots or PDFs.
|
|
|
26
27
|
- 📱 Responsive design support
|
|
27
28
|
- 🎨 Full control over materials, environments, and components
|
|
28
29
|
- 📸 Screenshot and PDF generation
|
|
30
|
+
- 🛒 Call-to-Action (CTA) data generation
|
|
29
31
|
- 🎬 Showcase management
|
|
30
32
|
- 📦 TypeScript support with full type definitions
|
|
31
33
|
- 🌐 CDN support for quick prototyping
|
|
@@ -33,7 +35,7 @@ components, component types, materials, and capture screenshots or PDFs.
|
|
|
33
35
|
## Prerequisites
|
|
34
36
|
|
|
35
37
|
- Modern web browser with ES6 module support
|
|
36
|
-
- HTTPS connection (required for
|
|
38
|
+
- HTTPS connection (required for Unreal Engine)
|
|
37
39
|
- Valid Metabox modular configurator URL
|
|
38
40
|
|
|
39
41
|
## Installation
|
|
@@ -56,15 +58,14 @@ import { integrateMetabox, Communicator, SetEnvironment, SetComponent } from 'ht
|
|
|
56
58
|
|
|
57
59
|
Alternative CDN options:
|
|
58
60
|
|
|
59
|
-
- **jsDelivr**: `https://cdn.jsdelivr.net/npm/@3dsource/metabox-modular-configurator-api@0.0.
|
|
61
|
+
- **jsDelivr**: `https://cdn.jsdelivr.net/npm/@3dsource/metabox-modular-configurator-api@0.0.5/+esm`
|
|
60
62
|
|
|
61
63
|
## Quick Start
|
|
62
64
|
|
|
63
65
|
### 1. HTML Setup
|
|
64
66
|
|
|
65
67
|
Ensure your HTML page has the following structure, where the Metabox Configurator will be integrated.
|
|
66
|
-
You
|
|
67
|
-
own.
|
|
68
|
+
You must provide CSS for the `#embed3DSource` element to make the configurator responsive and fit your layout needs.
|
|
68
69
|
Create a container element where the configurator will be embedded:
|
|
69
70
|
|
|
70
71
|
```html
|
|
@@ -97,7 +98,7 @@ Create a container element where the configurator will be embedded:
|
|
|
97
98
|
|
|
98
99
|
```html
|
|
99
100
|
<script type="module">
|
|
100
|
-
import { GetPdf, GetScreenshot, integrateMetabox, saveImage, SetComponent, SetComponentMaterial, SetEnvironment, SetEnvironmentMaterial, ShowEmbeddedMenu, ShowOverlayInterface } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-modular-configurator-api';
|
|
101
|
+
import { GetPdf, GetScreenshot, GetCallToActionInformation, integrateMetabox, saveImage, SetComponent, SetComponentMaterial, SetEnvironment, SetEnvironmentMaterial, ShowEmbeddedMenu, ShowOverlayInterface, ResetCamera, ApplyZoom } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-modular-configurator-api';
|
|
101
102
|
|
|
102
103
|
// Replace it with your actual configurator URL
|
|
103
104
|
const configuratorUrl = 'https://metabox.3dsource.com/metabox-configurator/modular/your-configurator-id';
|
|
@@ -124,6 +125,7 @@ Create a container element where the configurator will be embedded:
|
|
|
124
125
|
api.sendCommandToMetaBox(new ShowOverlayInterface(false));
|
|
125
126
|
api.sendCommandToMetaBox(new GetPdf());
|
|
126
127
|
api.sendCommandToMetaBox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));
|
|
128
|
+
api.sendCommandToMetaBox(new GetCallToActionInformation());
|
|
127
129
|
});
|
|
128
130
|
</script>
|
|
129
131
|
```
|
|
@@ -251,6 +253,33 @@ configurator.changeMaterial('seat-fabric', 'leather-brown');
|
|
|
251
253
|
- **component** - Product in the Modular configurator context.
|
|
252
254
|
- **componentId** - Unique Component ID within the Metabox system; mandatory. Assigned by the Metabox system automatically after the Modular configurator is created in Metabox.
|
|
253
255
|
- **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.
|
|
256
|
+
- **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).
|
|
257
|
+
To enable the CTA button, add two mandatory parameters in the Configurator Manager:
|
|
258
|
+
- Text label for the CTA button (examples: "Get Quote", "Contact Dealer").
|
|
259
|
+
- Callback URL for an HTTP POST request. Response requirements:
|
|
260
|
+
```json
|
|
261
|
+
{
|
|
262
|
+
"redirectUrl": "https://your.site/thank-you-or-checkout"
|
|
263
|
+
}
|
|
264
|
+
```
|
|
265
|
+
When the user clicks the CTA button in the configurator:
|
|
266
|
+
- Metabox generates a JSON payload with the current configuration and sends it to the specified Callback URL.
|
|
267
|
+
- Your backend decides how to use the configuration JSON (e.g., generate a PDF or build a product list).
|
|
268
|
+
- 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.).
|
|
269
|
+
|
|
270
|
+
### Steps to build custom menu
|
|
271
|
+
|
|
272
|
+
- **configuratorDataUpdated** - add event listener to receive get configurator data and then updates
|
|
273
|
+
- **showEmbeddedMenu** - hide embedded metabox right sidebar, but if you want to show it again, you can use this method
|
|
274
|
+
- **showOverlayInterface** - hide viewport metabox actions if you want to add yours
|
|
275
|
+
- **setEnvironment** - set active environment when you want to change environment
|
|
276
|
+
- **setEnvironmentMaterialById** - set environment material by slot ID
|
|
277
|
+
- **setComponentType** - set component type when you want to change component type !!!IMPORTANT!!!
|
|
278
|
+
- **setComponent** - set active component
|
|
279
|
+
- **setComponentMaterialById** - set component material by slot ID
|
|
280
|
+
- **getScreenshot** - get screenshot
|
|
281
|
+
- **getCallToActionInformation** - send call to action information to api endpoint provided in CTA configuration
|
|
282
|
+
- **getPdf** - get PDF.
|
|
254
283
|
|
|
255
284
|
### Core Integration
|
|
256
285
|
|
|
@@ -398,6 +427,7 @@ interface ToMetaboxMessagePayloads {
|
|
|
398
427
|
setComponentType: { typeId: string };
|
|
399
428
|
setComponentMaterialById: { slotId: string; materialId: string };
|
|
400
429
|
getScreenshot: { format: MimeType; size?: { x: number; y: number } };
|
|
430
|
+
getCallToActionInformation: void;
|
|
401
431
|
getPdf: void;
|
|
402
432
|
showEmbeddedMenu: { visible: boolean };
|
|
403
433
|
showOverlayInterface: { visible: boolean };
|
|
@@ -593,7 +623,7 @@ Captures a screenshot of the current configurator view.
|
|
|
593
623
|
|
|
594
624
|
**Parameters:**
|
|
595
625
|
|
|
596
|
-
- `mimeType` (`string`): Image format ('image/png', 'image/jpeg')
|
|
626
|
+
- `mimeType` (`string`): Image format ('image/png', 'image/jpeg', 'image/webp')
|
|
597
627
|
- `size` (`{ x: number; y: number }`, optional): Screenshot dimensions in pixels
|
|
598
628
|
|
|
599
629
|
**TypeScript Interface:**
|
|
@@ -621,6 +651,21 @@ Generates a PDF document of the current configuration.
|
|
|
621
651
|
api.sendCommandToMetaBox(new GetPdf());
|
|
622
652
|
```
|
|
623
653
|
|
|
654
|
+
### Commerce & CTA
|
|
655
|
+
|
|
656
|
+
#### `GetCallToActionInformation()`
|
|
657
|
+
|
|
658
|
+
Requests Call-To-Action information based on the current configuration. The configurator will compile CTA data and post it to the endpoint specified in the CTA configuration.
|
|
659
|
+
|
|
660
|
+
- No parameters.
|
|
661
|
+
- The response is delivered to the configured endpoint URL; listen to your backend or proxy endpoint to handle it.
|
|
662
|
+
|
|
663
|
+
**Example:**
|
|
664
|
+
|
|
665
|
+
```typescript
|
|
666
|
+
api.sendCommandToMetaBox(new GetCallToActionInformation());
|
|
667
|
+
```
|
|
668
|
+
|
|
624
669
|
#### `saveImage(renderData, fileName)`
|
|
625
670
|
|
|
626
671
|
Utility function to save image data to a file.
|
|
@@ -682,6 +727,17 @@ api.sendCommandToMetaBox(new UnrealCommand('SetLightIntensity 2.5'));
|
|
|
682
727
|
|
|
683
728
|
## Examples
|
|
684
729
|
|
|
730
|
+
### CTA Request Example
|
|
731
|
+
|
|
732
|
+
```typescript
|
|
733
|
+
import { integrateMetabox, Communicator, GetCallToActionInformation } from '@3dsource/metabox-modular-configurator-api';
|
|
734
|
+
|
|
735
|
+
integrateMetabox('https://metabox.3dsource.com/metabox-configurator/modular/your-configurator-id', 'embed3DSource', (api: Communicator) => {
|
|
736
|
+
// Request CTA data for the current configuration
|
|
737
|
+
api.sendCommandToMetaBox(new GetCallToActionInformation());
|
|
738
|
+
});
|
|
739
|
+
```
|
|
740
|
+
|
|
685
741
|
### Complete Product Configurator
|
|
686
742
|
|
|
687
743
|
```typescript
|
package/index.d.ts
CHANGED
|
@@ -128,6 +128,9 @@ interface InitialModularConfigurator {
|
|
|
128
128
|
/** The camera settings used in the configurator. */
|
|
129
129
|
/** Indicates if the configurator is active. */
|
|
130
130
|
isActive: boolean;
|
|
131
|
+
/** Indicates if the cta in ecom configurator is enabled or not. */
|
|
132
|
+
ctaEnabled: boolean;
|
|
133
|
+
/** A list of available connectors shows connections between all component types . */
|
|
131
134
|
connectors: ModularConfiguratorConnector[];
|
|
132
135
|
/** GraphQL typename for the Modular Configurator. */
|
|
133
136
|
__typename: 'ModularConfigurator';
|