@3dsource/metabox-front-api 3.0.16-dev.3 → 3.0.16-dev.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -50
- package/fesm2022/3dsource-metabox-front-api.mjs +618 -363
- package/fesm2022/3dsource-metabox-front-api.mjs.map +1 -1
- package/package.json +1 -1
- package/types/3dsource-metabox-front-api.d.ts +1068 -379
package/README.md
CHANGED
|
@@ -24,6 +24,7 @@ TypeScript/JavaScript API for integrating Metabox Basic Configurator into web ap
|
|
|
24
24
|
- [Camera Control](#camera-control)
|
|
25
25
|
- [Showcase/Animation Control](#showcaseanimation-control)
|
|
26
26
|
- [Measurement Tools](#measurement-tools)
|
|
27
|
+
- [Stream Control](#stream-control)
|
|
27
28
|
- [Export & Media](#export--media)
|
|
28
29
|
- [Advanced Commands (Use with Caution)](#advanced-commands-use-with-caution)
|
|
29
30
|
- [Event Handling](#event-handling)
|
|
@@ -352,17 +353,17 @@ Embeds the Metabox configurator iframe and establishes communication channel.
|
|
|
352
353
|
**Signature:**
|
|
353
354
|
|
|
354
355
|
```typescript
|
|
355
|
-
function integrateMetabox(configuratorId: string, containerId
|
|
356
|
+
function integrateMetabox(configuratorId: string, containerId: string, apiReadyCallback: (api: Communicator) => void, config?: IntegrateMetaboxConfig): void;
|
|
356
357
|
```
|
|
357
358
|
|
|
358
359
|
**Parameters:**
|
|
359
360
|
|
|
360
|
-
| Parameter | Type | Required | Default
|
|
361
|
-
| ------------------ | ------------------------ | -------- |
|
|
362
|
-
| `configuratorId` | `string` | ✅ | -
|
|
363
|
-
| `containerId` | `string` |
|
|
364
|
-
| `apiReadyCallback` | `function` | ✅ | -
|
|
365
|
-
| `config` | `IntegrateMetaboxConfig` | ❌ | `{}`
|
|
361
|
+
| Parameter | Type | Required | Default | Description |
|
|
362
|
+
| ------------------ | ------------------------ | -------- | ------- | ---------------------------------- |
|
|
363
|
+
| `configuratorId` | `string` | ✅ | - | Configurator UUID (not full URL) |
|
|
364
|
+
| `containerId` | `string` | ✅ | - | DOM container element ID |
|
|
365
|
+
| `apiReadyCallback` | `function` | ✅ | - | Callback invoked when API is ready |
|
|
366
|
+
| `config` | `IntegrateMetaboxConfig` | ❌ | `{}` | Additional configuration options |
|
|
366
367
|
|
|
367
368
|
**Config Options (`IntegrateMetaboxConfig`):**
|
|
368
369
|
|
|
@@ -372,7 +373,7 @@ interface IntegrateMetaboxConfig {
|
|
|
372
373
|
introImage?: string; // URL for intro image
|
|
373
374
|
introVideo?: string; // URL for intro video
|
|
374
375
|
loadingImage?: string; // URL for loading spinner
|
|
375
|
-
state?:
|
|
376
|
+
state?: string; // Predefined state for initial loading in rison format (see https://github.com/Nanonid/rison)
|
|
376
377
|
domain?: string; // Override domain (HTTPS only)
|
|
377
378
|
}
|
|
378
379
|
```
|
|
@@ -446,8 +447,8 @@ api.sendCommandToMetabox(new ShowEmbeddedMenu(false)); // Hide for custom UI
|
|
|
446
447
|
**Example:**
|
|
447
448
|
|
|
448
449
|
```typescript
|
|
449
|
-
api.sendCommandToMetabox(new ApplyZoom(
|
|
450
|
-
api.sendCommandToMetabox(new ApplyZoom(-
|
|
450
|
+
api.sendCommandToMetabox(new ApplyZoom(50)); // Zoom in
|
|
451
|
+
api.sendCommandToMetabox(new ApplyZoom(-25)); // Zoom out
|
|
451
452
|
api.sendCommandToMetabox(new ResetCamera()); // Reset view
|
|
452
453
|
api.sendCommandToMetabox(
|
|
453
454
|
new SetCamera({
|
|
@@ -540,13 +541,26 @@ Notes:
|
|
|
540
541
|
| `ShowMeasurement` | None | Display product dimensions |
|
|
541
542
|
| `HideMeasurement` | None | Hide dimension overlay |
|
|
542
543
|
|
|
544
|
+
#### Stream Control
|
|
545
|
+
|
|
546
|
+
| Command | Parameters | Description |
|
|
547
|
+
| -------------- | ---------- | ----------------------------------------------------------- |
|
|
548
|
+
| `ResumeStream` | None | Resume pixel streaming session after pause or disconnection |
|
|
549
|
+
|
|
550
|
+
**Example:**
|
|
551
|
+
|
|
552
|
+
```typescript
|
|
553
|
+
// Resume the stream after an idle timeout or network interruption
|
|
554
|
+
api.sendCommandToMetabox(new ResumeStream());
|
|
555
|
+
```
|
|
556
|
+
|
|
543
557
|
#### Export & Media
|
|
544
558
|
|
|
545
|
-
| Command | Parameters
|
|
546
|
-
| ---------------------------- |
|
|
547
|
-
| `GetScreenshot` | `
|
|
548
|
-
| `GetPdf` | None
|
|
549
|
-
| `GetCallToActionInformation` | None
|
|
559
|
+
| Command | Parameters | Description | Event Triggered |
|
|
560
|
+
| ---------------------------- | --------------------------------------------------- | -------------------- | ---------------------- |
|
|
561
|
+
| `GetScreenshot` | `mimeType: MimeType, size?: {x: number, y: number}` | Render screenshot | `screenshotReady` |
|
|
562
|
+
| `GetPdf` | None | Generate PDF export | Server-side (no event) |
|
|
563
|
+
| `GetCallToActionInformation` | None | Trigger CTA workflow | Backend redirect |
|
|
550
564
|
|
|
551
565
|
**Screenshot Example:**
|
|
552
566
|
|
|
@@ -562,7 +576,7 @@ api.addEventListener('screenshotReady', (imageData) => {
|
|
|
562
576
|
|
|
563
577
|
| Command | Parameters | Description |
|
|
564
578
|
| --------------- | ------------------------------- | ----------------------------------- |
|
|
565
|
-
| `UnrealCommand` | `
|
|
579
|
+
| `UnrealCommand` | `payload: object` | Send raw command to Unreal Engine |
|
|
566
580
|
| `MetaboxConfig` | `appId: string, config: object` | Internal initialization (auto-sent) |
|
|
567
581
|
|
|
568
582
|
**Warning:** `UnrealCommand` bypasses API validation. Use only for custom Unreal-specific features.
|
|
@@ -583,17 +597,16 @@ Event-driven architecture for reactive state management. Register listeners via
|
|
|
583
597
|
|
|
584
598
|
#### Available Events
|
|
585
599
|
|
|
586
|
-
| Event | Payload Type
|
|
587
|
-
| ----------------------------- |
|
|
588
|
-
| `configuratorDataUpdated` | `ConfiguratorEnvelope`
|
|
589
|
-
| `ecomConfiguratorDataUpdated` | `EcomConfigurator`
|
|
590
|
-
| `viewportReady` | `boolean`
|
|
591
|
-
| `showcaseStatusChanged` | `ShowCaseStatus`
|
|
592
|
-
| `statusMessageChanged` | `string \| null`
|
|
593
|
-
| `screenshotReady` | `string \| null`
|
|
594
|
-
| `getCameraResult` | `CameraCommandPayload`
|
|
595
|
-
| `
|
|
596
|
-
| `videoResolutionChanged` | `{width: number\|null, height: number\|null}` | Stream resolution changed | Adjust viewport layout |
|
|
600
|
+
| Event | Payload Type | Description | Use Case |
|
|
601
|
+
| ----------------------------- | ---------------------- | ---------------------------- | ----------------------------------------- |
|
|
602
|
+
| `configuratorDataUpdated` | `ConfiguratorEnvelope` | Configuration state changed | Sync UI with product/material/environment |
|
|
603
|
+
| `ecomConfiguratorDataUpdated` | `EcomConfigurator` | CTA configuration loaded | Display CTA button with label |
|
|
604
|
+
| `viewportReady` | `boolean` | 3D viewport ready state | Hide loading, enable interactions |
|
|
605
|
+
| `showcaseStatusChanged` | `ShowCaseStatus` | Animation playback status | Update play/pause button state |
|
|
606
|
+
| `statusMessageChanged` | `string \| null` | Loading/progress message | Display user feedback |
|
|
607
|
+
| `screenshotReady` | `string \| null` | Base64 screenshot data | Download or display image |
|
|
608
|
+
| `getCameraResult` | `CameraCommandPayload` | Current camera data returned | Capture/store current camera |
|
|
609
|
+
| `videoResolutionChanged` | `VideoResolution` | Stream resolution changed | Adjust viewport layout |
|
|
597
610
|
|
|
598
611
|
#### Event Examples
|
|
599
612
|
|
|
@@ -647,11 +660,11 @@ api.addEventListener('showcaseStatusChanged', (status: ShowCaseStatus) => {
|
|
|
647
660
|
const playButton = document.getElementById('play-btn');
|
|
648
661
|
|
|
649
662
|
switch (status) {
|
|
650
|
-
case '
|
|
663
|
+
case 'play':
|
|
651
664
|
playButton.textContent = 'Pause';
|
|
652
665
|
break;
|
|
653
|
-
case '
|
|
654
|
-
case '
|
|
666
|
+
case 'pause':
|
|
667
|
+
case 'stop':
|
|
655
668
|
playButton.textContent = 'Play';
|
|
656
669
|
break;
|
|
657
670
|
}
|
|
@@ -665,10 +678,11 @@ api.addEventListener('showcaseStatusChanged', (status: ShowCaseStatus) => {
|
|
|
665
678
|
Downloads base64-encoded image to user's device.
|
|
666
679
|
|
|
667
680
|
**Parameters:**
|
|
668
|
-
|
|
669
|
-
|
|
681
|
+
|
|
682
|
+
| Parameter | Type | Description |
|
|
683
|
+
| ---------- | -------- | --------------------------------------------------- |
|
|
670
684
|
| `imageUrl` | `string` | Base64 data URL (e.g., `data:image/png;base64,...`) |
|
|
671
|
-
| `filename` | `string` | Desired filename with extension
|
|
685
|
+
| `filename` | `string` | Desired filename with extension |
|
|
672
686
|
|
|
673
687
|
**Example:**
|
|
674
688
|
|
|
@@ -827,12 +841,6 @@ A complete HTML example showing how to integrate the Metabox configurator with v
|
|
|
827
841
|
// Save the image with a timestamp
|
|
828
842
|
saveImage(imageData, `configurator-screenshot-${Date.now()}.png`);
|
|
829
843
|
});
|
|
830
|
-
|
|
831
|
-
// Listen for errors
|
|
832
|
-
api.addEventListener('error', (error) => {
|
|
833
|
-
console.error('Configurator error:', error);
|
|
834
|
-
showError('An error occurred in the configurator: ' + error.message);
|
|
835
|
-
});
|
|
836
844
|
} catch (error) {
|
|
837
845
|
console.error('Error setting up API:', error);
|
|
838
846
|
showError('Failed to initialize configurator API: ' + error.message);
|
|
@@ -969,13 +977,6 @@ const MetaboxConfigurator: React.FC<MetaboxConfiguratorProps> = ({ configuratorI
|
|
|
969
977
|
}
|
|
970
978
|
});
|
|
971
979
|
|
|
972
|
-
// Listen for errors from the configurator
|
|
973
|
-
apiInstance.addEventListener('error', (error: any) => {
|
|
974
|
-
if (mounted) {
|
|
975
|
-
handleError(`Configurator error: ${error.message || error}`);
|
|
976
|
-
}
|
|
977
|
-
});
|
|
978
|
-
|
|
979
980
|
console.log('React Metabox Configurator initialized successfully');
|
|
980
981
|
} catch (error) {
|
|
981
982
|
if (mounted) {
|
|
@@ -1209,7 +1210,7 @@ export default MetaboxConfigurator;
|
|
|
1209
1210
|
```typescript
|
|
1210
1211
|
// metabox-configurator.component.ts
|
|
1211
1212
|
import { Component, input, OnInit, output, signal } from '@angular/core';
|
|
1212
|
-
import { Communicator, ConfiguratorEnvelope, GetPdf, GetScreenshot, InitShowcase, integrateMetabox, PauseShowcase, PlayShowcase, saveImage, SetProductMaterial, SetProduct, ShowEmbeddedMenu, ShowOverlayInterface, StopShowcase } from '@3dsource/metabox-front-api';
|
|
1213
|
+
import { Communicator, ConfiguratorEnvelope, GetCallToActionInformation, GetPdf, GetScreenshot, InitShowcase, integrateMetabox, PauseShowcase, PlayShowcase, saveImage, SetProductMaterial, SetProduct, ShowEmbeddedMenu, ShowOverlayInterface, StopShowcase } from '@3dsource/metabox-front-api';
|
|
1213
1214
|
|
|
1214
1215
|
interface ConfiguratorState {
|
|
1215
1216
|
isLoading: boolean;
|
|
@@ -1620,13 +1621,11 @@ export class MetaboxConfiguratorComponent implements OnInit {
|
|
|
1620
1621
|
**Key Features of this Angular Example:**
|
|
1621
1622
|
|
|
1622
1623
|
- **Comprehensive Error Handling**: Try-catch blocks and user-friendly error states
|
|
1623
|
-
- **Proper Lifecycle Management**: OnDestroy implementation with cleanup
|
|
1624
1624
|
- **Loading States**: Visual feedback with spinner during initialization
|
|
1625
1625
|
- **TypeScript Integration**: Full type safety with proper interfaces
|
|
1626
1626
|
- **Unique Container IDs**: Automatic ID generation to avoid conflicts
|
|
1627
1627
|
- **Event Outputs**: Emits state changes and errors to parent components
|
|
1628
1628
|
- **Responsive Design**: Clean, accessible button layout with proper styling
|
|
1629
|
-
- **Component Cleanup**: Prevents memory leaks and handles component destruction
|
|
1630
1629
|
|
|
1631
1630
|
**Usage Example:**
|
|
1632
1631
|
|
|
@@ -1900,7 +1899,7 @@ If you're still experiencing issues:
|
|
|
1900
1899
|
|
|
1901
1900
|
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.
|
|
1902
1901
|
|
|
1903
|
-
When standalone is enabled, the embedded page does not render Metabox’s internal menus, overlays, or template logic. You are responsible for sending commands (e.g.,
|
|
1902
|
+
When standalone is enabled, the embedded page does not render Metabox’s internal menus, overlays, or template logic. You are responsible for sending commands (e.g., `SetProduct`, `SetProductMaterial`, `SetEnvironment`) and listening to events to keep your UI in sync.
|
|
1904
1903
|
|
|
1905
1904
|
Key points:
|
|
1906
1905
|
|