@3dsource/metabox-front-api 1.2.1-dev.4 → 1.2.2-dev.0

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
@@ -1,31 +1,33 @@
1
- # MetaBox Basic Configurators API
1
+ # Metabox Basic Configurators API
2
2
 
3
- This package provides an API for interacting with the MetaBox Basic Configurator using plain JavaScript.
3
+ This package provides an API for interacting with the Metabox Basic Configurator using plain JavaScript.
4
4
 
5
5
  ### Installation (for using with frameworks like Angular, React, etc.) This is the recommended method
6
6
 
7
7
  ```sh
8
- npm install @3dsource/metabox-front-api@^1.0.0 --save
8
+ npm install @3dsource/metabox-front-api@^1.2.1-dev.5 --save
9
9
  ```
10
10
 
11
11
  then
12
12
 
13
13
  ```typescript
14
- import { FromMetaBoxApiAction, GetFastRender, GetPdf, integrateMetaBox, saveImage, SetEnvironment, SetMaterial, SetProduct, ShowEmbeddedMenu, ShowOverlayInterface, SetEnvironmentMaterial, Communicator, ConfiguratorEnvelope } from '@3dsource/metabox-front-api';
14
+ import { FromMetaboxApiAction, GetScreenshot, GetPdf, integrateMetaBox, saveImage, SetEnvironment, SetMaterial, SetProduct, ShowEmbeddedMenu, ShowOverlayInterface, SetEnvironmentMaterial, Communicator, ConfiguratorEnvelope } from '@3dsource/metabox-front-api';
15
15
  ```
16
16
 
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):
17
+ **OR** work with direct import from `NPM` using `CDN` network `unpkg.com` or `jsdelivr.net` (you can also download
18
+ package and use it locally):
18
19
 
19
20
  ```javascript
20
- import { FromMetaBoxApiAction, GetFastRender, GetPdf, integrateMetaBox, saveImage, SetEnvironment, SetMaterial, SetProduct, ShowEmbeddedMenu, ShowOverlayInterface, SetEnvironmentMaterial, Communicator, ConfiguratorEnvelope } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@1.2.0';
21
+ import { FromMetaboxApiAction, GetScreenshot, GetPdf, integrateMetaBox, saveImage, SetEnvironment, SetMaterial, SetProduct, ShowEmbeddedMenu, ShowOverlayInterface, SetEnvironmentMaterial, Communicator, ConfiguratorEnvelope } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@1.2.1-dev.5';
21
22
  ```
22
23
 
23
24
  ## Usage
24
25
 
25
26
  ### 1. Create HTML Structure
26
27
 
27
- Ensure your HTML page has the following structure, where the MetaBox Configurator will be integrated.
28
- You **MUST** control CSS style of `embed3DSource` element to make the configurator responsive and fit your needs on your own.
28
+ Ensure your HTML page has the following structure, where the Metabox Configurator will be integrated.
29
+ You **MUST** control CSS style of `embed3DSource` element to make the configurator responsive and fit your needs on your
30
+ own.
29
31
 
30
32
  ```html
31
33
  <div id="embed3DSource">
@@ -35,7 +37,7 @@ You **MUST** control CSS style of `embed3DSource` element to make the configurat
35
37
 
36
38
  ### 2. Include Required Scripts
37
39
 
38
- Below is an example demonstrating how to use the MetaBox API functions:
40
+ Below is an example demonstrating how to use the Metabox API functions:
39
41
 
40
42
  Insert this code into your HTML file just before the closing `</body>` tag:
41
43
 
@@ -45,7 +47,7 @@ HTML:
45
47
 
46
48
  ```html
47
49
  <script type="module">
48
- import { integrateMetaBox, SetEnvironment, ShowOverlayInterface, SetEnvironmentMaterial, SetMaterial, SetProduct, ShowEmbeddedMenu, GetFastRender, GetPdf, saveImage, Communicator, FromMetaboxApiAction } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@1.2.0';
50
+ import { integrateMetaBox, SetEnvironment, ShowOverlayInterface, SetEnvironmentMaterial, SetMaterial, SetProduct, ShowEmbeddedMenu, GetScreenshot, GetPdf, saveImage, Communicator, FromMetaboxApiAction } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@1.2.1-dev.5';
49
51
 
50
52
  class JsIntegrator {
51
53
  constructor() {
@@ -70,12 +72,12 @@ HTML:
70
72
  setupInitialState(api) {
71
73
  api.sendCommandToMetaBox(new SetProduct('productId'));
72
74
  api.sendCommandToMetaBox(new SetEnvironment('environmentId'));
73
- api.sendCommandToMetaBox(new SetMaterial('productId', 'slotId', 'materialId'));
74
- api.sendCommandToMetaBox(new SetEnvironmentMaterial('productId', 'slotId', 'materialId'));
75
+ api.sendCommandToMetaBox(new SetMaterial('slotId', 'materialId'));
76
+ api.sendCommandToMetaBox(new SetEnvironmentMaterial('slotId', 'materialId'));
75
77
  api.sendCommandToMetaBox(new ShowEmbeddedMenu(false));
76
78
  api.sendCommandToMetaBox(new ShowOverlayInterface(false));
77
79
  api.sendCommandToMetaBox(new GetPdf());
78
- api.sendCommandToMetaBox(new GetFastRender('image/png', { x: 1024, y: 1024 }));
80
+ api.sendCommandToMetaBox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));
79
81
  }
80
82
  }
81
83
 
@@ -86,7 +88,7 @@ HTML:
86
88
  TypeScript:
87
89
 
88
90
  ```typescript
89
- import { ConfiguratorEnvelope, UniversalConfigurator, integrateMetaBox, SetEnvironment, ShowOverlayInterface, SetEnvironmentMaterial, SetMaterial, SetProduct, ShowEmbeddedMenu, GetFastRender, GetPdf, saveImage, Communicator, FromMetaboxApiAction } from '@3dsource/metabox-front-api';
91
+ import { ConfiguratorEnvelope, UniversalConfigurator, integrateMetaBox, SetEnvironment, ShowOverlayInterface, SetEnvironmentMaterial, SetMaterial, SetProduct, ShowEmbeddedMenu, GetScreenshot, GetPdf, saveImage, Communicator, FromMetaboxApiAction } from '@3dsource/metabox-front-api';
90
92
 
91
93
  class TsIntegrator {
92
94
  constructor() {
@@ -111,12 +113,12 @@ class TsIntegrator {
111
113
  setupInitialState(api: Communicator) {
112
114
  api.sendCommandToMetaBox(new SetProduct('productId'));
113
115
  api.sendCommandToMetaBox(new SetEnvironment('environmentId'));
114
- api.sendCommandToMetaBox(new SetMaterial('productId', 'slotId', 'materialId'));
115
- api.sendCommandToMetaBox(new SetEnvironmentMaterial('productId', 'slotId', 'materialId'));
116
+ api.sendCommandToMetaBox(new SetMaterial('slotId', 'materialId'));
117
+ api.sendCommandToMetaBox(new SetEnvironmentMaterial('slotId', 'materialId'));
116
118
  api.sendCommandToMetaBox(new ShowEmbeddedMenu(false));
117
119
  api.sendCommandToMetaBox(new ShowOverlayInterface(false));
118
120
  api.sendCommandToMetaBox(new GetPdf());
119
- api.sendCommandToMetaBox(new GetFastRender('image/png', { x: 1024, y: 1024 }));
121
+ api.sendCommandToMetaBox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));
120
122
  }
121
123
  }
122
124
 
@@ -127,7 +129,7 @@ new TsIntegrator();
127
129
 
128
130
  #### `integrateMetaBox`
129
131
 
130
- - **Description**: Integrates the MetaBox configurator into the specified container.
132
+ - **Description**: Integrates the Metabox configurator into the specified container.
131
133
  - **Usage**:
132
134
 
133
135
  ```typescript
@@ -149,7 +151,7 @@ new TsIntegrator();
149
151
  - **Usage**:
150
152
 
151
153
  ```typescript
152
- api.sendCommandToMetaBox(new SetMaterial(productId: string, slotId: string, materialId: string));
154
+ api.sendCommandToMetaBox(new SetMaterial(slotId: string, materialId: string));
153
155
  ```
154
156
 
155
157
  #### `SetEnvironmentMaterial`
@@ -158,7 +160,7 @@ new TsIntegrator();
158
160
  - **Usage**:
159
161
 
160
162
  ```typescript
161
- api.sendCommandToMetaBox(new SetEnvironmentMaterial(productId: string, slotId: string, materialId: string));
163
+ api.sendCommandToMetaBox(new SetEnvironmentMaterial(slotId: string, materialId: string));
162
164
  ```
163
165
 
164
166
  #### `SetProduct`
@@ -172,7 +174,7 @@ new TsIntegrator();
172
174
 
173
175
  #### `ShowEmbeddedMenu`
174
176
 
175
- - **Description**: Toggles the embedded menu in the MetaBox configurator.
177
+ - **Description**: Toggles the embedded menu in the Metabox configurator.
176
178
  - **Usage**:
177
179
 
178
180
  ```typescript
@@ -188,13 +190,13 @@ new TsIntegrator();
188
190
  api.sendCommandToMetaBox(new ShowOverlayInterface(visible: boolean));
189
191
  ```
190
192
 
191
- #### `GetFastRender`
193
+ #### `GetScreenshot`
192
194
 
193
- - **Description**: Retrieves a fast render of the current view.
195
+ - **Description**: Retrieves a screenshot/render of the current view.
194
196
  - **Usage**:
195
197
 
196
198
  ```typescript
197
- api.sendCommandToMetaBox(new GetFastRender(mimeType: string, size?: { x: number, y: number }));
199
+ api.sendCommandToMetaBox(new GetScreenshot(mimeType: string, size?: { x: number, y: number }));
198
200
  ```
199
201
 
200
202
  #### `GetPdf`
@@ -214,3 +216,57 @@ new TsIntegrator();
214
216
  ```typescript
215
217
  saveImage(renderData: string, fileName: string): void;
216
218
  ```
219
+
220
+ #### `ResetCamera`
221
+
222
+ - **Description**: Resets the camera to its default position and rotation.
223
+ - **Usage**:
224
+
225
+ ```typescript
226
+ api.sendCommandToMetaBox(new ResetCamera());
227
+ ```
228
+
229
+ #### `ApplyZoom`
230
+
231
+ - **Description**: Applies zoom to the camera view.
232
+ - **Usage**:
233
+
234
+ ```typescript
235
+ api.sendCommandToMetaBox(new ApplyZoom(zoom: number));
236
+ ```
237
+
238
+ #### `InitShowcase`
239
+
240
+ - **Description**: Initializes a showcase with the given showcase ID.
241
+ - **Usage**:
242
+
243
+ ```typescript
244
+ api.sendCommandToMetaBox(new InitShowcase(showcaseId: string));
245
+ ```
246
+
247
+ #### `PlayShowcase`
248
+
249
+ - **Description**: Plays the currently loaded showcase.
250
+ - **Usage**:
251
+
252
+ ```typescript
253
+ api.sendCommandToMetaBox(new PlayShowcase());
254
+ ```
255
+
256
+ #### `PauseShowcase`
257
+
258
+ - **Description**: Pauses the currently playing showcase.
259
+ - **Usage**:
260
+
261
+ ```typescript
262
+ api.sendCommandToMetaBox(new PauseShowcase());
263
+ ```
264
+
265
+ #### `StopShowcase`
266
+
267
+ - **Description**: Stops the currently playing showcase.
268
+ - **Usage**:
269
+
270
+ ```typescript
271
+ api.sendCommandToMetaBox(new StopShowcase());
272
+ ```