@3dsource/metabox-front-api 1.2.1-dev.3 → 1.2.1-dev.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 +16 -18
- package/fesm2022/3dsource-metabox-front-api.mjs +301 -138
- package/fesm2022/3dsource-metabox-front-api.mjs.map +1 -1
- package/index.d.ts +576 -404
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,34 +1,33 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Metabox Basic Configurators API
|
|
2
2
|
|
|
3
|
-
This package provides an API for interacting with the
|
|
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.
|
|
8
|
+
npm install @3dsource/metabox-front-api@^1.2.1 --save
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
then
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import {
|
|
14
|
+
import { FromMetaboxApiAction, GetFastRender, GetPdf, integrateMetaBox, saveImage, SetEnvironment, SetMaterial, SetProduct, ShowEmbeddedMenu, ShowOverlayInterface, SetEnvironmentMaterial, Communicator, ConfiguratorEnvelope } from '@3dsource/metabox-front-api';
|
|
15
15
|
```
|
|
16
16
|
|
|
17
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 {
|
|
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.1';
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## Usage
|
|
24
24
|
|
|
25
25
|
### 1. Create HTML Structure
|
|
26
26
|
|
|
27
|
-
Ensure your HTML page has the following structure, where the
|
|
27
|
+
Ensure your HTML page has the following structure, where the Metabox Configurator will be integrated.
|
|
28
28
|
You **MUST** control CSS style of `embed3DSource` element to make the configurator responsive and fit your needs on your own.
|
|
29
29
|
|
|
30
30
|
```html
|
|
31
|
-
|
|
32
31
|
<div id="embed3DSource">
|
|
33
32
|
<!-- Your Configurator iframe will be embedded here -->
|
|
34
33
|
</div>
|
|
@@ -36,7 +35,7 @@ You **MUST** control CSS style of `embed3DSource` element to make the configurat
|
|
|
36
35
|
|
|
37
36
|
### 2. Include Required Scripts
|
|
38
37
|
|
|
39
|
-
Below is an example demonstrating how to use the
|
|
38
|
+
Below is an example demonstrating how to use the Metabox API functions:
|
|
40
39
|
|
|
41
40
|
Insert this code into your HTML file just before the closing `</body>` tag:
|
|
42
41
|
|
|
@@ -45,9 +44,8 @@ Insert this code into your HTML file just before the closing `</body>` tag:
|
|
|
45
44
|
HTML:
|
|
46
45
|
|
|
47
46
|
```html
|
|
48
|
-
|
|
49
47
|
<script type="module">
|
|
50
|
-
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.
|
|
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.1';
|
|
51
49
|
|
|
52
50
|
class JsIntegrator {
|
|
53
51
|
constructor() {
|
|
@@ -72,8 +70,8 @@ HTML:
|
|
|
72
70
|
setupInitialState(api) {
|
|
73
71
|
api.sendCommandToMetaBox(new SetProduct('productId'));
|
|
74
72
|
api.sendCommandToMetaBox(new SetEnvironment('environmentId'));
|
|
75
|
-
api.sendCommandToMetaBox(new SetMaterial('
|
|
76
|
-
api.sendCommandToMetaBox(new SetEnvironmentMaterial('
|
|
73
|
+
api.sendCommandToMetaBox(new SetMaterial('slotId', 'materialId'));
|
|
74
|
+
api.sendCommandToMetaBox(new SetEnvironmentMaterial('slotId', 'materialId'));
|
|
77
75
|
api.sendCommandToMetaBox(new ShowEmbeddedMenu(false));
|
|
78
76
|
api.sendCommandToMetaBox(new ShowOverlayInterface(false));
|
|
79
77
|
api.sendCommandToMetaBox(new GetPdf());
|
|
@@ -113,8 +111,8 @@ class TsIntegrator {
|
|
|
113
111
|
setupInitialState(api: Communicator) {
|
|
114
112
|
api.sendCommandToMetaBox(new SetProduct('productId'));
|
|
115
113
|
api.sendCommandToMetaBox(new SetEnvironment('environmentId'));
|
|
116
|
-
api.sendCommandToMetaBox(new SetMaterial('
|
|
117
|
-
api.sendCommandToMetaBox(new SetEnvironmentMaterial('
|
|
114
|
+
api.sendCommandToMetaBox(new SetMaterial('slotId', 'materialId'));
|
|
115
|
+
api.sendCommandToMetaBox(new SetEnvironmentMaterial('slotId', 'materialId'));
|
|
118
116
|
api.sendCommandToMetaBox(new ShowEmbeddedMenu(false));
|
|
119
117
|
api.sendCommandToMetaBox(new ShowOverlayInterface(false));
|
|
120
118
|
api.sendCommandToMetaBox(new GetPdf());
|
|
@@ -129,7 +127,7 @@ new TsIntegrator();
|
|
|
129
127
|
|
|
130
128
|
#### `integrateMetaBox`
|
|
131
129
|
|
|
132
|
-
- **Description**: Integrates the
|
|
130
|
+
- **Description**: Integrates the Metabox configurator into the specified container.
|
|
133
131
|
- **Usage**:
|
|
134
132
|
|
|
135
133
|
```typescript
|
|
@@ -151,7 +149,7 @@ new TsIntegrator();
|
|
|
151
149
|
- **Usage**:
|
|
152
150
|
|
|
153
151
|
```typescript
|
|
154
|
-
api.sendCommandToMetaBox(new SetMaterial(
|
|
152
|
+
api.sendCommandToMetaBox(new SetMaterial(slotId: string, materialId: string));
|
|
155
153
|
```
|
|
156
154
|
|
|
157
155
|
#### `SetEnvironmentMaterial`
|
|
@@ -160,7 +158,7 @@ new TsIntegrator();
|
|
|
160
158
|
- **Usage**:
|
|
161
159
|
|
|
162
160
|
```typescript
|
|
163
|
-
api.sendCommandToMetaBox(new SetEnvironmentMaterial(
|
|
161
|
+
api.sendCommandToMetaBox(new SetEnvironmentMaterial(slotId: string, materialId: string));
|
|
164
162
|
```
|
|
165
163
|
|
|
166
164
|
#### `SetProduct`
|
|
@@ -174,7 +172,7 @@ new TsIntegrator();
|
|
|
174
172
|
|
|
175
173
|
#### `ShowEmbeddedMenu`
|
|
176
174
|
|
|
177
|
-
- **Description**: Toggles the embedded menu in the
|
|
175
|
+
- **Description**: Toggles the embedded menu in the Metabox configurator.
|
|
178
176
|
- **Usage**:
|
|
179
177
|
|
|
180
178
|
```typescript
|