@3dsource/metabox-front-api 0.0.13 → 0.0.14

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
@@ -14,13 +14,13 @@ then
14
14
  import { FromMetaBoxApiAction, GetFastRender, GetPdf, integrateMetaBox, saveImage, SetEnvironment, SetMaterial, SetProduct, ShowEmbeddedMenu,... } from '@3dsource/metabox-front-api';
15
15
  ```
16
16
 
17
- **OR** work with direct import from `NPM` using `CDN` network unpkg.com (you can also download package and use it locally):
17
+ **OR** work with direct import from `NPM` using `CDN` network `unpkg.com` or `jsdelivr.net` (you can also download package and use it locally):
18
18
 
19
19
  ```javascript
20
- import { FromMetaBoxApiAction, GetFastRender, GetPdf, integrateMetaBox, saveImage, SetEnvironment, SetMaterial, SetProduct, ShowEmbeddedMenu,... } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
20
+ import { FromMetaBoxApiAction, GetFastRender, GetPdf, integrateMetaBox, saveImage, SetEnvironment, SetMaterial, SetProduct, ShowEmbeddedMenu,... } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@latest/dist/index.js';
21
21
  ```
22
22
 
23
- **WE ARE HIGHLY RECOMMENDING TO USE THE FIRST OPTION WITH NPM, AS THE SECOND ONE CAN RAPIDLY CHANGE AND MAY CAUSE UNEXPECTED BEHAVIOR WITH CODE YOU ARE ALREADY USING.**
23
+ **We strongly recommend using the first option with npm and locking it to the latest version at the time of integration, as the second option can change rapidly and may cause unexpected behavior in your existing code.**
24
24
 
25
25
  ## Usage
26
26
 
@@ -45,8 +45,7 @@ Insert this code into your HTML file just before the closing `</body>` tag:
45
45
 
46
46
  ```html
47
47
  <script type="module">
48
- import { integrateMetaBox, SetEnvironment, SetMaterial, SetProduct, ShowEmbeddedMenu, GetFastRender, GetPdf, saveImage, FromMetaboxApiAction } from '@3dsource/metabox-front-api';
49
- let initilaized = false;
48
+ import { integrateMetaBox, SetEnvironment, SetEnvironmentMaterial, SetMaterial, SetProduct, ShowEmbeddedMenu, GetFastRender, GetPdf, saveImage, FromMetaboxApiAction } from '@3dsource/metabox-front-api';
50
49
  // Expose API
51
50
  window.env3DSource.apiReady = (api) => {
52
51
  api.addEventListener('metaboxData', (data) => {
@@ -55,20 +54,8 @@ Insert this code into your HTML file just before the closing `</body>` tag:
55
54
  return;
56
55
  }
57
56
 
58
- if (eventType === 'viewportReady' && payload === true) {
59
- //You can use this event to trigger any action that can work only when the viewport is ready,
60
- //i.e. GetPdf or GetFastRender
61
-
62
- // Get a fast render (optionally specify size)
63
- new GetFastRender('image/png', { x: 1024, y: 1024 });
64
-
65
- // Generate a PDF of the current view
66
- new GetPdf();
67
- }
68
-
69
57
  if (eventType === 'basicConfiguratorDataWithState') {
70
58
  updateConfiguratorData(data);
71
- setupInitialState();
72
59
  }
73
60
 
74
61
  if (eventType === 'fastRender') {
@@ -76,6 +63,7 @@ Insert this code into your HTML file just before the closing `</body>` tag:
76
63
  saveImage(payload, 'Render.png');
77
64
  }
78
65
  });
66
+ setupInitialState();
79
67
  };
80
68
 
81
69
  /**
@@ -87,27 +75,36 @@ Insert this code into your HTML file just before the closing `</body>` tag:
87
75
  }
88
76
 
89
77
  /**
90
- * Setup initial state
78
+ * Setup initial state,
79
+ * Executes additional commands as example
91
80
  */
92
81
  function setupInitialState() {
93
- if (initilaized) {
94
- return;
95
- }
82
+ // All commands can be used at any time from the moment api is ready and will be buffered automatically
83
+ // i.e. GetFastRender and GetPdf will be executed when the viewport is ready
84
+
96
85
  // Set product
97
- new SetProduct('product-id');
86
+ new SetProduct('productId');
98
87
 
99
88
  // Set environment
100
- new SetEnvironment('env-id');
89
+ new SetEnvironment('environmentId');
101
90
 
102
91
  // Set material
103
- new SetMaterial('product-id', 'slot-id', 'material-id');
92
+ new SetMaterial('productId', 'slotId', 'materialId');
93
+
94
+ // Set environment material
95
+ new SetEnvironmentMaterial('productId', 'slotId', 'materialId');
104
96
 
105
97
  // Toggle embedded menu
106
98
  new ShowEmbeddedMenu(false);
99
+
100
+ //Request Pdf, Will execute as stream is ready, will be auto-downloaded
101
+ new GetPdf();
102
+
103
+ //Request Fast Render, Will execute as stream is ready, will be sent back as a callback
104
+ new GetFastRender('image/png', { x: 1024, y: 1024 });
107
105
  }
108
106
 
109
107
  // Integrate the 3D configurator into your page
110
-
111
108
  /**
112
109
  * Additional url parameters:
113
110
  * @see integrateMetaBox
@@ -144,6 +141,14 @@ Insert this code into your HTML file just before the closing `</body>` tag:
144
141
  new SetMaterial(productId: string, slotId: string, materialId: string);
145
142
  ```
146
143
 
144
+ ### `SetEnvironmentMaterial`
145
+
146
+ - **Description**: Sets the material for a given environment slot.
147
+ - **Constructor**:
148
+ ```typescript
149
+ new SetEnvironmentMaterial(productId: string, slotId: string, materialId: string);
150
+ ```
151
+
147
152
  ### `SetProduct`
148
153
 
149
154
  - **Description**: Sets the product by ID.
@@ -162,12 +167,6 @@ Insert this code into your HTML file just before the closing `</body>` tag:
162
167
 
163
168
  ### `GetFastRender`
164
169
 
165
- **Important:** Before invoking this action, ensure that the MetaBox viewport is fully loaded. This is indicated by the event:
166
-
167
- ```javascript
168
- data.eventType === 'viewportReady' && data.payload === true.
169
- ```
170
-
171
170
  - **Description**: Retrieves a fast render of the current view.
172
171
  - **Usage**:
173
172
  ```typescript
@@ -176,12 +175,6 @@ data.eventType === 'viewportReady' && data.payload === true.
176
175
 
177
176
  ### `GetPdf`
178
177
 
179
- **Important:** Before invoking this action, ensure that the MetaBox viewport is fully loaded. This is indicated by the event:
180
-
181
- ```javascript
182
- data.eventType === 'viewportReady' && data.payload === true.
183
- ```
184
-
185
178
  - **Description**: Generates a PDF of the current view.
186
179
  - **Usage**:
187
180
  ```typescript
@@ -1,7 +1,25 @@
1
1
  import type { Communicator } from '../lib/initializeCommunicator';
2
2
  /**
3
- * Base class for all API actions.
4
- * @hidden
3
+ * To integrate the MetaBox configurator into an HTML element, use the following example:
4
+ *
5
+ * **We strongly recommend using the option with npm and locking it to the latest version at the time of integration, as the option with cdn can change rapidly and may cause unexpected behavior in your existing code. See root documentation.**
6
+ *
7
+ * ```typescript
8
+ * import { integrateMetaBox } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@latest/dist/index.js';
9
+ *
10
+ * integrateMetaBox(
11
+ * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
12
+ * 'embed3DSource'
13
+ * );
14
+ *
15
+ * // Set up the global API environment
16
+ * window.env3DSource = window.env3DSource || {};
17
+ *
18
+ * //Listen for the API ready event
19
+ * window.env3DSource.apiReady = (api) => {
20
+ * // Use the API actions here
21
+ * };
22
+ * ```
5
23
  */
6
24
  export declare class ApiAction {
7
25
  protected api: Communicator;
@@ -6,40 +6,25 @@ import { ApiAction } from './ApiAction';
6
6
  */
7
7
  export type MimeType = 'image/png' | 'image/jpeg' | 'image/webp';
8
8
  /**
9
+ * {@inheritDoc ApiAction}
10
+ *
9
11
  * Represents a fast render action.
10
12
  * @remarks
11
13
  * This class sends a message to the MetaBox API to obtain a fast render based on the provided format and optional size.
12
14
  *
13
- * **Important:** Before invoking this action, ensure that the MetaBox viewport is fully loaded. This is indicated by the event:
14
- * ```javascript
15
- * data.eventType === 'viewportReady' && data.payload === true.
16
- * ```
17
- * Only then request be processed.
15
+ * **Important**: Invoking this action will buffer it until the viewport is ready. Only then will the request be processed.
18
16
  *
19
17
  * @example
20
- * import { integrateMetaBox, GetFastRender, saveImage } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
21
- *
22
- * // Integrate the MetaBox configurator into an HTML element with the ID 'embed3DSource'
23
- * integrateMetaBox(
24
- * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
25
- * 'embed3DSource'
26
- * );
27
- *
28
- * // Set up the global API environment
29
- * window.env3DSource = window.env3DSource || {};
18
+ * import { GetFastRender,saveImage } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
30
19
  * window.env3DSource.apiReady = (api) => {
31
20
  * // Listen for events from the MetaBox API
32
21
  * api.addEventListener('metaboxData', (data) => {
33
- * // Ensure the viewport is ready before sending render requests
34
- * if (data.eventType === 'viewportReady' && data.payload === true) {
35
- * // Request a fast render (PNG image with 1024x1024 dimensions)
36
- * new GetFastRender('image/png', { x: 1024, y: 1024 });
37
- * }
38
22
  * // Process the fast render response
39
23
  * if (data.eventType === 'fastRender') {
40
24
  * saveImage(data.payload, 'Render.png');
41
25
  * }
42
26
  * });
27
+ * new GetFastRender('image/png', { x: 1024, y: 1024 });
43
28
  * };
44
29
  */
45
30
  export declare class GetFastRender extends ApiAction {
@@ -1,32 +1,18 @@
1
1
  import { ApiAction } from './ApiAction';
2
2
  /**
3
+ * {@inheritDoc ApiAction}
4
+ *
3
5
  * Represents an action to get a PDF from Metabox.
4
6
  * @remarks
5
7
  * This class sends a message to the MetaBox API to generate a PDF based on the current configuration.
6
8
  * This action does not require any parameters.
7
9
  *
8
- * **Important:** Before invoking this action, ensure that the MetaBox viewport is fully loaded. This is indicated by the event:
9
- *```javascript
10
- * data.eventType === 'viewportReady' && data.payload === true.
11
- * ```
12
- * Only then request be processed.
10
+ * **Important**: Invoking this action will buffer it until the viewport is ready. Only then will the request be processed.
13
11
  *
14
12
  * @example
15
- * import { integrateMetaBox, GetPdf } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
16
- *
17
- * integrateMetaBox(
18
- * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
19
- * 'embed3DSource'
20
- * );
21
- *
22
- * window.env3DSource = window.env3DSource || {};
13
+ * import { GetPdf } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
23
14
  * window.env3DSource.apiReady = (api) => {
24
- * api.addEventListener('metaboxData', (data) => {
25
- * if (data.eventType === 'viewportReady' && data.payload === true) {
26
- * // Request a PDF of the current configuration
27
- * new GetPdf();
28
- * }
29
- * });
15
+ * new GetPdf();
30
16
  * };
31
17
  */
32
18
  export declare class GetPdf extends ApiAction {
@@ -1,5 +1,6 @@
1
1
  import { ApiAction } from './ApiAction';
2
2
  /**
3
+ * {@inheritDoc ApiAction}
3
4
  * @internal
4
5
  * @hidden
5
6
  * Represents an action to send Unreal command.
@@ -1,21 +1,13 @@
1
1
  import { ApiAction } from './ApiAction';
2
2
  /**
3
+ * {@inheritDoc ApiAction}
4
+ *
3
5
  * Represents an action to set the environment by its ID.
4
6
  * @remarks
5
7
  * This action sends a message to the MetaBox API to load the environment level using the specified environment ID.
6
- * It requires the MetaBox API to be properly initialized and an event listener to be registered.
7
8
  *
8
9
  * @example
9
- * import { integrateMetaBox, SetEnvironment } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
10
- *
11
- * // Integrate the MetaBox configurator into an HTML element with the ID 'embed3DSource'
12
- * integrateMetaBox(
13
- * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
14
- * 'embed3DSource'
15
- * );
16
- *
17
- * // Setup API ready callback
18
- * window.env3DSource = window.env3DSource || {};
10
+ * import { SetEnvironment } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
19
11
  * window.env3DSource.apiReady = (api) => {
20
12
  * // Change the environment to '55555555-1234-1234-1234-01234567890'
21
13
  * new SetEnvironment('55555555-1234-1234-1234-01234567890');
@@ -1,45 +1,25 @@
1
1
  import { ApiAction } from './ApiAction';
2
2
  /**
3
- * Represents an action to set a material by its ID.
3
+ * {@inheritDoc ApiAction}
4
+ *
5
+ * Represents an action to set a environment material by its ID.
4
6
  *
5
7
  * @remarks
6
- * This action sends a message to the MetaBox API to update the material on a specific product slot using the provided identifiers.
7
-
8
- * **Important:** Before invoking this action, ensure that the MetaBox already dispatched
9
- * as minimum one eventType:"basicConfiguratorDataWithState":
10
- * ```javascript
11
- * data.eventType === 'basicConfiguratorDataWithState'.
12
- * ```
13
- * Only then request be processed.
8
+ * This action sends a message to the MetaBox API to update the material on a specific environment slot using the provided identifiers.
14
9
  *
15
10
  * @example
16
- * import { SetMaterial } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
17
- *
18
- * // Integrate the MetaBox configurator into an HTML element with the ID 'embed3DSource'
19
- * integrateMetaBox(
20
- * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
21
- * 'embed3DSource'
22
- * );
23
- *
24
- * // Set up the global API environment
25
- * window.env3DSource = window.env3DSource || {};
11
+ * import { SetEnvironmentMaterial } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
26
12
  * window.env3DSource.apiReady = (api) => {
27
- * // Listen for events from the MetaBox API
28
- * api.addEventListener('metaboxData', (data) => {
29
- * // Process SetMaterial
30
- * if (data.eventType === 'basicConfiguratorDataWithState') {
31
- * new SetEnvironmentMaterial(
32
- * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3',
33
- * 'carpaint',
34
- * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
35
- * );
36
- * }
37
- * });
13
+ * new SetEnvironmentMaterial(
14
+ * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3',
15
+ * 'carpaint',
16
+ * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
17
+ * );
38
18
  * };
39
19
  */
40
20
  export declare class SetEnvironmentMaterial extends ApiAction {
41
21
  /**
42
- * Creates an instance of SetMaterial.
22
+ * Creates an instance of SetEnvironmentMaterial.
43
23
  *
44
24
  * @param productId - The product ID.
45
25
  * @param slotId - The slot ID.
@@ -1,40 +1,20 @@
1
1
  import { ApiAction } from './ApiAction';
2
2
  /**
3
+ * {@inheritDoc ApiAction}
4
+ *
3
5
  * Represents an action to set a material by its ID.
4
6
  *
5
7
  * @remarks
6
8
  * This action sends a message to the MetaBox API to update the material on a specific product slot using the provided identifiers.
7
-
8
- * **Important:** Before invoking this action, ensure that the MetaBox already dispatched
9
- * as minimum one eventType:"basicConfiguratorDataWithState":
10
- * ```javascript
11
- * data.eventType === 'basicConfiguratorDataWithState'.
12
- * ```
13
- * Only then request be processed.
14
9
  *
15
10
  * @example
16
11
  * import { SetMaterial } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
17
- *
18
- * // Integrate the MetaBox configurator into an HTML element with the ID 'embed3DSource'
19
- * integrateMetaBox(
20
- * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
21
- * 'embed3DSource'
22
- * );
23
- *
24
- * // Set up the global API environment
25
- * window.env3DSource = window.env3DSource || {};
26
12
  * window.env3DSource.apiReady = (api) => {
27
- * // Listen for events from the MetaBox API
28
- * api.addEventListener('metaboxData', (data) => {
29
- * // Process SetMaterial
30
- * if (data.eventType === 'basicConfiguratorDataWithState') {
31
- * new SetMaterial(
32
- * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3',
33
- * 'carpaint',
34
- * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
35
- * );
36
- * }
37
- * });
13
+ * new SetMaterial(
14
+ * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3',
15
+ * 'carpaint',
16
+ * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
17
+ * );
38
18
  * };
39
19
  */
40
20
  export declare class SetMaterial extends ApiAction {
@@ -1,9 +1,19 @@
1
1
  import { ApiAction } from './ApiAction';
2
2
  /**
3
+ * {@inheritDoc ApiAction}
4
+ *
3
5
  * Represents an action to set a product by its ID.
4
6
  *
5
7
  * @remarks
6
8
  * This action sends a message to the MetaBox API to set a product using the provided product ID.
9
+ *
10
+ * @example
11
+ * import { SetProduct } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
12
+ * window.env3DSource.apiReady = (api) => {
13
+ * new SetProduct(
14
+ * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3'
15
+ * );
16
+ * };
7
17
  */
8
18
  export declare class SetProduct extends ApiAction {
9
19
  /**
@@ -1,9 +1,17 @@
1
1
  import { ApiAction } from './ApiAction';
2
2
  /**
3
- * Represents an action to toggle the Embedded Menu in MetaBox.
3
+ * {@inheritDoc ApiAction}
4
+ *
5
+ * Represents an action to toggle the Embedded MetaBox Menu.
4
6
  *
5
7
  * @remarks
6
8
  * This action sends a message to the MetaBox API to toggle the visibility of the embedded menu.
9
+ *
10
+ * @example
11
+ * import { ShowEmbeddedMenu } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
12
+ * window.env3DSource.apiReady = (api) => {
13
+ * new ShowEmbeddedMenu(true);
14
+ * };
7
15
  */
8
16
  export declare class ShowEmbeddedMenu extends ApiAction {
9
17
  /**
@@ -1,6 +1,8 @@
1
1
  import { ApiAction } from './ApiAction';
2
2
  /**
3
3
  * @experimental
4
+ * @internal
5
+ * @hidden
4
6
  * @remarks
5
7
  * Represents an action to watch Unreal callbacks from Unreal engine.
6
8
  * Can be useful for custom solutions.
package/dist/index.d.ts CHANGED
@@ -7,14 +7,14 @@ export { SetEnvironmentMaterial } from './actions/SetEnvironmentMaterial';
7
7
  export { GetFastRender } from './actions/GetFastRender';
8
8
  export { SendCommandToUnreal } from './actions/SendCommandToUnreal';
9
9
  export { WatchCallbacks } from './actions/WatchCallbacks';
10
- export { MimeType } from './actions/GetFastRender';
10
+ export type { MimeType } from './actions/GetFastRender';
11
11
  export { ApiAction } from './actions/ApiAction';
12
12
  export * from './lib/integrateMetaBox';
13
13
  export * from './lib/initializeCommunicator';
14
14
  export * from './lib/saveImage';
15
15
  export * from './lib/sleep';
16
16
  export * from './lib/UrlUtils';
17
- export * from './interfaces/UniversalConfigurator';
17
+ export type * from './interfaces/UniversalConfigurator';
18
18
  export * from './interfaces/ToMetaboxMessagePayloads';
19
19
  export * from './interfaces/FromMetaboxMessagePayloads';
20
20
  export * from './interfaces/application-device-types';
package/dist/index.esm.js CHANGED
@@ -4,8 +4,26 @@
4
4
  * All Rights Reserved
5
5
  */
6
6
  /**
7
- * Base class for all API actions.
8
- * @hidden
7
+ * To integrate the MetaBox configurator into an HTML element, use the following example:
8
+ *
9
+ * **We strongly recommend using the option with npm and locking it to the latest version at the time of integration, as the option with cdn can change rapidly and may cause unexpected behavior in your existing code. See root documentation.**
10
+ *
11
+ * ```typescript
12
+ * import { integrateMetaBox } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@latest/dist/index.js';
13
+ *
14
+ * integrateMetaBox(
15
+ * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
16
+ * 'embed3DSource'
17
+ * );
18
+ *
19
+ * // Set up the global API environment
20
+ * window.env3DSource = window.env3DSource || {};
21
+ *
22
+ * //Listen for the API ready event
23
+ * window.env3DSource.apiReady = (api) => {
24
+ * // Use the API actions here
25
+ * };
26
+ * ```
9
27
  */
10
28
  class ApiAction {
11
29
  constructor() {
@@ -43,10 +61,18 @@ const ToMetaBoxApiAction = {
43
61
  * All Rights Reserved
44
62
  */
45
63
  /**
46
- * Represents an action to toggle the Embedded Menu in MetaBox.
64
+ * {@inheritDoc ApiAction}
65
+ *
66
+ * Represents an action to toggle the Embedded MetaBox Menu.
47
67
  *
48
68
  * @remarks
49
69
  * This action sends a message to the MetaBox API to toggle the visibility of the embedded menu.
70
+ *
71
+ * @example
72
+ * import { ShowEmbeddedMenu } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
73
+ * window.env3DSource.apiReady = (api) => {
74
+ * new ShowEmbeddedMenu(true);
75
+ * };
50
76
  */
51
77
  class ShowEmbeddedMenu extends ApiAction {
52
78
  /**
@@ -71,22 +97,14 @@ class ShowEmbeddedMenu extends ApiAction {
71
97
  * All Rights Reserved
72
98
  */
73
99
  /**
100
+ * {@inheritDoc ApiAction}
101
+ *
74
102
  * Represents an action to set the environment by its ID.
75
103
  * @remarks
76
104
  * This action sends a message to the MetaBox API to load the environment level using the specified environment ID.
77
- * It requires the MetaBox API to be properly initialized and an event listener to be registered.
78
105
  *
79
106
  * @example
80
- * import { integrateMetaBox, SetEnvironment } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
81
- *
82
- * // Integrate the MetaBox configurator into an HTML element with the ID 'embed3DSource'
83
- * integrateMetaBox(
84
- * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
85
- * 'embed3DSource'
86
- * );
87
- *
88
- * // Setup API ready callback
89
- * window.env3DSource = window.env3DSource || {};
107
+ * import { SetEnvironment } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
90
108
  * window.env3DSource.apiReady = (api) => {
91
109
  * // Change the environment to '55555555-1234-1234-1234-01234567890'
92
110
  * new SetEnvironment('55555555-1234-1234-1234-01234567890');
@@ -115,10 +133,20 @@ class SetEnvironment extends ApiAction {
115
133
  * All Rights Reserved
116
134
  */
117
135
  /**
136
+ * {@inheritDoc ApiAction}
137
+ *
118
138
  * Represents an action to set a product by its ID.
119
139
  *
120
140
  * @remarks
121
141
  * This action sends a message to the MetaBox API to set a product using the provided product ID.
142
+ *
143
+ * @example
144
+ * import { SetProduct } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
145
+ * window.env3DSource.apiReady = (api) => {
146
+ * new SetProduct(
147
+ * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3'
148
+ * );
149
+ * };
122
150
  */
123
151
  class SetProduct extends ApiAction {
124
152
  /**
@@ -143,33 +171,19 @@ class SetProduct extends ApiAction {
143
171
  * All Rights Reserved
144
172
  */
145
173
  /**
174
+ * {@inheritDoc ApiAction}
175
+ *
146
176
  * Represents an action to get a PDF from Metabox.
147
177
  * @remarks
148
178
  * This class sends a message to the MetaBox API to generate a PDF based on the current configuration.
149
179
  * This action does not require any parameters.
150
180
  *
151
- * **Important:** Before invoking this action, ensure that the MetaBox viewport is fully loaded. This is indicated by the event:
152
- *```javascript
153
- * data.eventType === 'viewportReady' && data.payload === true.
154
- * ```
155
- * Only then request be processed.
181
+ * **Important**: Invoking this action will buffer it until the viewport is ready. Only then will the request be processed.
156
182
  *
157
183
  * @example
158
- * import { integrateMetaBox, GetPdf } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
159
- *
160
- * integrateMetaBox(
161
- * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
162
- * 'embed3DSource'
163
- * );
164
- *
165
- * window.env3DSource = window.env3DSource || {};
184
+ * import { GetPdf } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
166
185
  * window.env3DSource.apiReady = (api) => {
167
- * api.addEventListener('metaboxData', (data) => {
168
- * if (data.eventType === 'viewportReady' && data.payload === true) {
169
- * // Request a PDF of the current configuration
170
- * new GetPdf();
171
- * }
172
- * });
186
+ * new GetPdf();
173
187
  * };
174
188
  */
175
189
  class GetPdf extends ApiAction {
@@ -193,41 +207,21 @@ class GetPdf extends ApiAction {
193
207
  * All Rights Reserved
194
208
  */
195
209
  /**
210
+ * {@inheritDoc ApiAction}
211
+ *
196
212
  * Represents an action to set a material by its ID.
197
213
  *
198
214
  * @remarks
199
215
  * This action sends a message to the MetaBox API to update the material on a specific product slot using the provided identifiers.
200
-
201
- * **Important:** Before invoking this action, ensure that the MetaBox already dispatched
202
- * as minimum one eventType:"basicConfiguratorDataWithState":
203
- * ```javascript
204
- * data.eventType === 'basicConfiguratorDataWithState'.
205
- * ```
206
- * Only then request be processed.
207
216
  *
208
217
  * @example
209
218
  * import { SetMaterial } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
210
- *
211
- * // Integrate the MetaBox configurator into an HTML element with the ID 'embed3DSource'
212
- * integrateMetaBox(
213
- * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
214
- * 'embed3DSource'
215
- * );
216
- *
217
- * // Set up the global API environment
218
- * window.env3DSource = window.env3DSource || {};
219
219
  * window.env3DSource.apiReady = (api) => {
220
- * // Listen for events from the MetaBox API
221
- * api.addEventListener('metaboxData', (data) => {
222
- * // Process SetMaterial
223
- * if (data.eventType === 'basicConfiguratorDataWithState') {
224
- * new SetMaterial(
225
- * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3',
226
- * 'carpaint',
227
- * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
228
- * );
229
- * }
230
- * });
220
+ * new SetMaterial(
221
+ * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3',
222
+ * 'carpaint',
223
+ * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
224
+ * );
231
225
  * };
232
226
  */
233
227
  class SetMaterial extends ApiAction {
@@ -257,46 +251,26 @@ class SetMaterial extends ApiAction {
257
251
  * All Rights Reserved
258
252
  */
259
253
  /**
260
- * Represents an action to set a material by its ID.
254
+ * {@inheritDoc ApiAction}
255
+ *
256
+ * Represents an action to set a environment material by its ID.
261
257
  *
262
258
  * @remarks
263
- * This action sends a message to the MetaBox API to update the material on a specific product slot using the provided identifiers.
264
-
265
- * **Important:** Before invoking this action, ensure that the MetaBox already dispatched
266
- * as minimum one eventType:"basicConfiguratorDataWithState":
267
- * ```javascript
268
- * data.eventType === 'basicConfiguratorDataWithState'.
269
- * ```
270
- * Only then request be processed.
259
+ * This action sends a message to the MetaBox API to update the material on a specific environment slot using the provided identifiers.
271
260
  *
272
261
  * @example
273
- * import { SetMaterial } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
274
- *
275
- * // Integrate the MetaBox configurator into an HTML element with the ID 'embed3DSource'
276
- * integrateMetaBox(
277
- * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
278
- * 'embed3DSource'
279
- * );
280
- *
281
- * // Set up the global API environment
282
- * window.env3DSource = window.env3DSource || {};
262
+ * import { SetEnvironmentMaterial } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
283
263
  * window.env3DSource.apiReady = (api) => {
284
- * // Listen for events from the MetaBox API
285
- * api.addEventListener('metaboxData', (data) => {
286
- * // Process SetMaterial
287
- * if (data.eventType === 'basicConfiguratorDataWithState') {
288
- * new SetEnvironmentMaterial(
289
- * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3',
290
- * 'carpaint',
291
- * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
292
- * );
293
- * }
294
- * });
264
+ * new SetEnvironmentMaterial(
265
+ * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3',
266
+ * 'carpaint',
267
+ * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
268
+ * );
295
269
  * };
296
270
  */
297
271
  class SetEnvironmentMaterial extends ApiAction {
298
272
  /**
299
- * Creates an instance of SetMaterial.
273
+ * Creates an instance of SetEnvironmentMaterial.
300
274
  *
301
275
  * @param productId - The product ID.
302
276
  * @param slotId - The slot ID.
@@ -321,40 +295,25 @@ class SetEnvironmentMaterial extends ApiAction {
321
295
  * All Rights Reserved
322
296
  */
323
297
  /**
298
+ * {@inheritDoc ApiAction}
299
+ *
324
300
  * Represents a fast render action.
325
301
  * @remarks
326
302
  * This class sends a message to the MetaBox API to obtain a fast render based on the provided format and optional size.
327
303
  *
328
- * **Important:** Before invoking this action, ensure that the MetaBox viewport is fully loaded. This is indicated by the event:
329
- * ```javascript
330
- * data.eventType === 'viewportReady' && data.payload === true.
331
- * ```
332
- * Only then request be processed.
304
+ * **Important**: Invoking this action will buffer it until the viewport is ready. Only then will the request be processed.
333
305
  *
334
306
  * @example
335
- * import { integrateMetaBox, GetFastRender, saveImage } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
336
- *
337
- * // Integrate the MetaBox configurator into an HTML element with the ID 'embed3DSource'
338
- * integrateMetaBox(
339
- * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
340
- * 'embed3DSource'
341
- * );
342
- *
343
- * // Set up the global API environment
344
- * window.env3DSource = window.env3DSource || {};
307
+ * import { GetFastRender,saveImage } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
345
308
  * window.env3DSource.apiReady = (api) => {
346
309
  * // Listen for events from the MetaBox API
347
310
  * api.addEventListener('metaboxData', (data) => {
348
- * // Ensure the viewport is ready before sending render requests
349
- * if (data.eventType === 'viewportReady' && data.payload === true) {
350
- * // Request a fast render (PNG image with 1024x1024 dimensions)
351
- * new GetFastRender('image/png', { x: 1024, y: 1024 });
352
- * }
353
311
  * // Process the fast render response
354
312
  * if (data.eventType === 'fastRender') {
355
313
  * saveImage(data.payload, 'Render.png');
356
314
  * }
357
315
  * });
316
+ * new GetFastRender('image/png', { x: 1024, y: 1024 });
358
317
  * };
359
318
  */
360
319
  class GetFastRender extends ApiAction {
@@ -381,6 +340,7 @@ class GetFastRender extends ApiAction {
381
340
  * All Rights Reserved
382
341
  */
383
342
  /**
343
+ * {@inheritDoc ApiAction}
384
344
  * @internal
385
345
  * @hidden
386
346
  * Represents an action to send Unreal command.
@@ -402,6 +362,8 @@ class SendCommandToUnreal extends ApiAction {
402
362
  */
403
363
  /**
404
364
  * @experimental
365
+ * @internal
366
+ * @hidden
405
367
  * @remarks
406
368
  * Represents an action to watch Unreal callbacks from Unreal engine.
407
369
  * Can be useful for custom solutions.
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.umd.js CHANGED
@@ -10,8 +10,26 @@
10
10
  * All Rights Reserved
11
11
  */
12
12
  /**
13
- * Base class for all API actions.
14
- * @hidden
13
+ * To integrate the MetaBox configurator into an HTML element, use the following example:
14
+ *
15
+ * **We strongly recommend using the option with npm and locking it to the latest version at the time of integration, as the option with cdn can change rapidly and may cause unexpected behavior in your existing code. See root documentation.**
16
+ *
17
+ * ```typescript
18
+ * import { integrateMetaBox } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@latest/dist/index.js';
19
+ *
20
+ * integrateMetaBox(
21
+ * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
22
+ * 'embed3DSource'
23
+ * );
24
+ *
25
+ * // Set up the global API environment
26
+ * window.env3DSource = window.env3DSource || {};
27
+ *
28
+ * //Listen for the API ready event
29
+ * window.env3DSource.apiReady = (api) => {
30
+ * // Use the API actions here
31
+ * };
32
+ * ```
15
33
  */
16
34
  class ApiAction {
17
35
  constructor() {
@@ -49,10 +67,18 @@
49
67
  * All Rights Reserved
50
68
  */
51
69
  /**
52
- * Represents an action to toggle the Embedded Menu in MetaBox.
70
+ * {@inheritDoc ApiAction}
71
+ *
72
+ * Represents an action to toggle the Embedded MetaBox Menu.
53
73
  *
54
74
  * @remarks
55
75
  * This action sends a message to the MetaBox API to toggle the visibility of the embedded menu.
76
+ *
77
+ * @example
78
+ * import { ShowEmbeddedMenu } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
79
+ * window.env3DSource.apiReady = (api) => {
80
+ * new ShowEmbeddedMenu(true);
81
+ * };
56
82
  */
57
83
  class ShowEmbeddedMenu extends ApiAction {
58
84
  /**
@@ -77,22 +103,14 @@
77
103
  * All Rights Reserved
78
104
  */
79
105
  /**
106
+ * {@inheritDoc ApiAction}
107
+ *
80
108
  * Represents an action to set the environment by its ID.
81
109
  * @remarks
82
110
  * This action sends a message to the MetaBox API to load the environment level using the specified environment ID.
83
- * It requires the MetaBox API to be properly initialized and an event listener to be registered.
84
111
  *
85
112
  * @example
86
- * import { integrateMetaBox, SetEnvironment } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
87
- *
88
- * // Integrate the MetaBox configurator into an HTML element with the ID 'embed3DSource'
89
- * integrateMetaBox(
90
- * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
91
- * 'embed3DSource'
92
- * );
93
- *
94
- * // Setup API ready callback
95
- * window.env3DSource = window.env3DSource || {};
113
+ * import { SetEnvironment } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
96
114
  * window.env3DSource.apiReady = (api) => {
97
115
  * // Change the environment to '55555555-1234-1234-1234-01234567890'
98
116
  * new SetEnvironment('55555555-1234-1234-1234-01234567890');
@@ -121,10 +139,20 @@
121
139
  * All Rights Reserved
122
140
  */
123
141
  /**
142
+ * {@inheritDoc ApiAction}
143
+ *
124
144
  * Represents an action to set a product by its ID.
125
145
  *
126
146
  * @remarks
127
147
  * This action sends a message to the MetaBox API to set a product using the provided product ID.
148
+ *
149
+ * @example
150
+ * import { SetProduct } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
151
+ * window.env3DSource.apiReady = (api) => {
152
+ * new SetProduct(
153
+ * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3'
154
+ * );
155
+ * };
128
156
  */
129
157
  class SetProduct extends ApiAction {
130
158
  /**
@@ -149,33 +177,19 @@
149
177
  * All Rights Reserved
150
178
  */
151
179
  /**
180
+ * {@inheritDoc ApiAction}
181
+ *
152
182
  * Represents an action to get a PDF from Metabox.
153
183
  * @remarks
154
184
  * This class sends a message to the MetaBox API to generate a PDF based on the current configuration.
155
185
  * This action does not require any parameters.
156
186
  *
157
- * **Important:** Before invoking this action, ensure that the MetaBox viewport is fully loaded. This is indicated by the event:
158
- *```javascript
159
- * data.eventType === 'viewportReady' && data.payload === true.
160
- * ```
161
- * Only then request be processed.
187
+ * **Important**: Invoking this action will buffer it until the viewport is ready. Only then will the request be processed.
162
188
  *
163
189
  * @example
164
- * import { integrateMetaBox, GetPdf } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
165
- *
166
- * integrateMetaBox(
167
- * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
168
- * 'embed3DSource'
169
- * );
170
- *
171
- * window.env3DSource = window.env3DSource || {};
190
+ * import { GetPdf } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
172
191
  * window.env3DSource.apiReady = (api) => {
173
- * api.addEventListener('metaboxData', (data) => {
174
- * if (data.eventType === 'viewportReady' && data.payload === true) {
175
- * // Request a PDF of the current configuration
176
- * new GetPdf();
177
- * }
178
- * });
192
+ * new GetPdf();
179
193
  * };
180
194
  */
181
195
  class GetPdf extends ApiAction {
@@ -199,41 +213,21 @@
199
213
  * All Rights Reserved
200
214
  */
201
215
  /**
216
+ * {@inheritDoc ApiAction}
217
+ *
202
218
  * Represents an action to set a material by its ID.
203
219
  *
204
220
  * @remarks
205
221
  * This action sends a message to the MetaBox API to update the material on a specific product slot using the provided identifiers.
206
-
207
- * **Important:** Before invoking this action, ensure that the MetaBox already dispatched
208
- * as minimum one eventType:"basicConfiguratorDataWithState":
209
- * ```javascript
210
- * data.eventType === 'basicConfiguratorDataWithState'.
211
- * ```
212
- * Only then request be processed.
213
222
  *
214
223
  * @example
215
224
  * import { SetMaterial } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
216
- *
217
- * // Integrate the MetaBox configurator into an HTML element with the ID 'embed3DSource'
218
- * integrateMetaBox(
219
- * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
220
- * 'embed3DSource'
221
- * );
222
- *
223
- * // Set up the global API environment
224
- * window.env3DSource = window.env3DSource || {};
225
225
  * window.env3DSource.apiReady = (api) => {
226
- * // Listen for events from the MetaBox API
227
- * api.addEventListener('metaboxData', (data) => {
228
- * // Process SetMaterial
229
- * if (data.eventType === 'basicConfiguratorDataWithState') {
230
- * new SetMaterial(
231
- * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3',
232
- * 'carpaint',
233
- * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
234
- * );
235
- * }
236
- * });
226
+ * new SetMaterial(
227
+ * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3',
228
+ * 'carpaint',
229
+ * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
230
+ * );
237
231
  * };
238
232
  */
239
233
  class SetMaterial extends ApiAction {
@@ -263,46 +257,26 @@
263
257
  * All Rights Reserved
264
258
  */
265
259
  /**
266
- * Represents an action to set a material by its ID.
260
+ * {@inheritDoc ApiAction}
261
+ *
262
+ * Represents an action to set a environment material by its ID.
267
263
  *
268
264
  * @remarks
269
- * This action sends a message to the MetaBox API to update the material on a specific product slot using the provided identifiers.
270
-
271
- * **Important:** Before invoking this action, ensure that the MetaBox already dispatched
272
- * as minimum one eventType:"basicConfiguratorDataWithState":
273
- * ```javascript
274
- * data.eventType === 'basicConfiguratorDataWithState'.
275
- * ```
276
- * Only then request be processed.
265
+ * This action sends a message to the MetaBox API to update the material on a specific environment slot using the provided identifiers.
277
266
  *
278
267
  * @example
279
- * import { SetMaterial } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
280
- *
281
- * // Integrate the MetaBox configurator into an HTML element with the ID 'embed3DSource'
282
- * integrateMetaBox(
283
- * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
284
- * 'embed3DSource'
285
- * );
286
- *
287
- * // Set up the global API environment
288
- * window.env3DSource = window.env3DSource || {};
268
+ * import { SetEnvironmentMaterial } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
289
269
  * window.env3DSource.apiReady = (api) => {
290
- * // Listen for events from the MetaBox API
291
- * api.addEventListener('metaboxData', (data) => {
292
- * // Process SetMaterial
293
- * if (data.eventType === 'basicConfiguratorDataWithState') {
294
- * new SetEnvironmentMaterial(
295
- * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3',
296
- * 'carpaint',
297
- * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
298
- * );
299
- * }
300
- * });
270
+ * new SetEnvironmentMaterial(
271
+ * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3',
272
+ * 'carpaint',
273
+ * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
274
+ * );
301
275
  * };
302
276
  */
303
277
  class SetEnvironmentMaterial extends ApiAction {
304
278
  /**
305
- * Creates an instance of SetMaterial.
279
+ * Creates an instance of SetEnvironmentMaterial.
306
280
  *
307
281
  * @param productId - The product ID.
308
282
  * @param slotId - The slot ID.
@@ -327,40 +301,25 @@
327
301
  * All Rights Reserved
328
302
  */
329
303
  /**
304
+ * {@inheritDoc ApiAction}
305
+ *
330
306
  * Represents a fast render action.
331
307
  * @remarks
332
308
  * This class sends a message to the MetaBox API to obtain a fast render based on the provided format and optional size.
333
309
  *
334
- * **Important:** Before invoking this action, ensure that the MetaBox viewport is fully loaded. This is indicated by the event:
335
- * ```javascript
336
- * data.eventType === 'viewportReady' && data.payload === true.
337
- * ```
338
- * Only then request be processed.
310
+ * **Important**: Invoking this action will buffer it until the viewport is ready. Only then will the request be processed.
339
311
  *
340
312
  * @example
341
- * import { integrateMetaBox, GetFastRender, saveImage } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
342
- *
343
- * // Integrate the MetaBox configurator into an HTML element with the ID 'embed3DSource'
344
- * integrateMetaBox(
345
- * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
346
- * 'embed3DSource'
347
- * );
348
- *
349
- * // Set up the global API environment
350
- * window.env3DSource = window.env3DSource || {};
313
+ * import { GetFastRender,saveImage } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
351
314
  * window.env3DSource.apiReady = (api) => {
352
315
  * // Listen for events from the MetaBox API
353
316
  * api.addEventListener('metaboxData', (data) => {
354
- * // Ensure the viewport is ready before sending render requests
355
- * if (data.eventType === 'viewportReady' && data.payload === true) {
356
- * // Request a fast render (PNG image with 1024x1024 dimensions)
357
- * new GetFastRender('image/png', { x: 1024, y: 1024 });
358
- * }
359
317
  * // Process the fast render response
360
318
  * if (data.eventType === 'fastRender') {
361
319
  * saveImage(data.payload, 'Render.png');
362
320
  * }
363
321
  * });
322
+ * new GetFastRender('image/png', { x: 1024, y: 1024 });
364
323
  * };
365
324
  */
366
325
  class GetFastRender extends ApiAction {
@@ -387,6 +346,7 @@
387
346
  * All Rights Reserved
388
347
  */
389
348
  /**
349
+ * {@inheritDoc ApiAction}
390
350
  * @internal
391
351
  * @hidden
392
352
  * Represents an action to send Unreal command.
@@ -408,6 +368,8 @@
408
368
  */
409
369
  /**
410
370
  * @experimental
371
+ * @internal
372
+ * @hidden
411
373
  * @remarks
412
374
  * Represents an action to watch Unreal callbacks from Unreal engine.
413
375
  * Can be useful for custom solutions.
@@ -1 +1 @@
1
- {"version":3,"file":"index.umd.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.umd.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -82,7 +82,7 @@ export interface FromMetaboxMessagePayloads {
82
82
  /**
83
83
  * Dispatches Every when user toggle fullscreen button in internal menu.
84
84
  */
85
- isFullscreen: boolean;
85
+ isFullScreen: boolean;
86
86
  /**
87
87
  * Dispatches at the moment while configurator loads. Shows status information.
88
88
  */
@@ -6,7 +6,7 @@ export interface ConfiguratorEnvelope {
6
6
  /**
7
7
  * A reference to the universal configurator.
8
8
  */
9
- configurator: UniversalConfigurator | null;
9
+ configurator: UniversalConfigurator;
10
10
  /**
11
11
  * The unique product identifier.
12
12
  */
@@ -16,7 +16,9 @@ export interface ConfiguratorEnvelope {
16
16
  */
17
17
  productMaterialsIds: SelectedIds;
18
18
  /**
19
- * @deprecated, use `productMaterialsIds` instead.
19
+ * @deprecated,
20
+ * use `productMaterialsIds` instead.
21
+ * @hidden
20
22
  */
21
23
  selectedMaterials: SelectedIds;
22
24
  /**
@@ -74,6 +76,8 @@ export interface Product {
74
76
  thumbnailList: Thumbnail[];
75
77
  /** Available slots for the product. */
76
78
  slots: Slot[];
79
+ /** List of metaProperties for the product (optional). */
80
+ metaProperties: MetaProperty[];
77
81
  /** The model information associated with the product. */
78
82
  /** Unique identifier for the product. */
79
83
  id: string;
@@ -107,6 +111,21 @@ export interface Slot {
107
111
  /** GraphQL typename for the slot. */
108
112
  __typename: 'Slot';
109
113
  }
114
+ /**
115
+ * Represents a metaProperty within a product that may allow business logic customization.
116
+ */
117
+ export interface MetaProperty {
118
+ /** Unique identifier for the metaProperty. */
119
+ id: string;
120
+ /** Display name for the metaProperty. */
121
+ name: string;
122
+ /** Value for the metaProperty. */
123
+ value: string;
124
+ /** Type for the metaProperty. */
125
+ type: string;
126
+ /** GraphQL typename for the metaProperty. */
127
+ __typename: 'MetaProperty';
128
+ }
110
129
  /**
111
130
  * Represents a material that can be applied to a product slot.
112
131
  */
package/package.json CHANGED
@@ -1,37 +1,41 @@
1
1
  {
2
2
  "name": "@3dsource/metabox-front-api",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "API for MetaBox BASIC configurator",
5
- "main": "dist/index.umd.js",
6
- "module": "dist/index.esm.js",
7
- "unpkg": "dist/index.esm.js",
8
- "jsdelivr": "dist/index.esm.js",
9
- "type": "module",
10
- "scripts": {
11
- "build": "rollup -c",
12
- "clean": "rimraf dist",
13
- "packAll": "npm run clean && npm run build && npm pack",
14
- "publishApi": "npm run packAll && npm publish --access public",
15
- "apiDoc": "typedoc --entryPointStrategy Expand src/index.ts --tsconfig ./../../../tsconfig.typedoc.json --out ./../../../dist/browser/apiDocBasic"
16
- },
17
- "files": [
18
- "dist/**/*"
5
+ "keywords": [
6
+ "metabox",
7
+ "api",
8
+ "configurator"
19
9
  ],
20
10
  "repository": {
21
11
  "type": "git",
22
12
  "url": "git@bitbucket.org:dreamsoft/ams_vps-frontend.git"
23
13
  },
14
+ "license": "MIT",
15
+ "author": "3dsource.com",
16
+ "type": "module",
24
17
  "exports": {
25
- ".": "./dist/index.esm.js"
18
+ ".": {
19
+ "import": "./dist/index.esm.js",
20
+ "require": "./dist/index.umd.js",
21
+ "types": "./dist/index.d.ts"
22
+ }
26
23
  },
24
+ "main": "dist/index.umd.js",
25
+ "jsdelivr": "dist/index.esm.js",
26
+ "unpkg": "dist/index.esm.js",
27
+ "module": "dist/index.esm.js",
27
28
  "types": "dist/index.d.ts",
28
- "keywords": [
29
- "metabox",
30
- "api",
31
- "configurator"
29
+ "files": [
30
+ "dist/**/*"
32
31
  ],
33
- "author": "3dsource.com",
34
- "license": "MIT",
32
+ "scripts": {
33
+ "apiDoc": "typedoc --entryPointStrategy Expand src/index.ts --tsconfig ./../../../tsconfig.typedoc.json --out ./../../../dist/browser/apiDocBasic",
34
+ "build": "rollup -c",
35
+ "clean": "rimraf dist",
36
+ "packAll": "npm run clean && npm run build && npm pack",
37
+ "publishApi": "npm run packAll && npm publish --access public"
38
+ },
35
39
  "devDependencies": {
36
40
  "rimraf": "^3.0.2",
37
41
  "rollup": "^4.39.0",