@shopware-ag/dive 1.19.1-beta.2 → 1.19.1-beta.4
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 +295 -362
- package/build/chunks/PerspectiveCamera-ACx6umAu.mjs +38 -0
- package/build/chunks/PerspectiveCamera-ACx6umAu.mjs.map +1 -0
- package/build/chunks/PerspectiveCamera-BXPNOM71.cjs +2 -0
- package/build/chunks/PerspectiveCamera-BXPNOM71.cjs.map +1 -0
- package/build/chunks/fflate.module-DHdJvhNh.cjs +7 -0
- package/build/chunks/fflate.module-DHdJvhNh.cjs.map +1 -0
- package/build/chunks/fflate.module-DkZg07PZ.mjs +603 -0
- package/build/chunks/fflate.module-DkZg07PZ.mjs.map +1 -0
- package/build/chunks/file-type-error-D6aWGgyc.mjs +15 -0
- package/build/chunks/file-type-error-D6aWGgyc.mjs.map +1 -0
- package/build/chunks/file-type-error-DtvBgs64.cjs +2 -0
- package/build/chunks/file-type-error-DtvBgs64.cjs.map +1 -0
- package/build/chunks/index-C7Wx_9uY.mjs +34 -0
- package/build/chunks/index-C7Wx_9uY.mjs.map +1 -0
- package/build/chunks/index-MNP0K5dt.cjs +2 -0
- package/build/chunks/index-MNP0K5dt.cjs.map +1 -0
- package/build/chunks/network-error-C2ZDC8qS.cjs +2 -0
- package/build/chunks/network-error-C2ZDC8qS.cjs.map +1 -0
- package/build/chunks/network-error-DgecatEk.mjs +27 -0
- package/build/chunks/network-error-DgecatEk.mjs.map +1 -0
- package/build/index.cjs +57 -0
- package/build/index.cjs.map +1 -0
- package/build/index.d.ts +6 -0
- package/build/index.mjs +6884 -0
- package/build/index.mjs.map +1 -0
- package/build/src/animation/AnimationSystem.d.ts +1 -1
- package/build/src/axiscamera/AxisCamera.d.ts +2 -2
- package/build/src/com/Communication.d.ts +5 -8
- package/build/src/com/actions/scene/exportscene.d.ts +1 -1
- package/build/src/com/actions/scene/launchar.d.ts +1 -1
- package/build/src/controls/OrbitControls.d.ts +2 -2
- package/build/src/dive.d.ts +12 -29
- package/build/src/engine/Engine.d.ts +32 -0
- package/build/src/{camera → engine/camera}/PerspectiveCamera.d.ts +1 -1
- package/build/src/{scene → engine/scene}/Scene.d.ts +4 -4
- package/build/src/{scene → engine/scene}/root/Root.d.ts +2 -3
- package/build/src/error/ar-compatibility/ar-compatibility-error.d.ts +12 -0
- package/build/src/error/file-type/file-type-error.d.ts +4 -0
- package/build/src/error/index.d.ts +4 -0
- package/build/src/error/network/network-error.d.ts +5 -0
- package/build/src/error/parse/parse-error.d.ts +4 -0
- package/build/src/helper/findSceneRecursive/findSceneRecursive.d.ts +1 -1
- package/build/src/helper/getFileTypeFromUri/getFileTypeFromUri.d.ts +6 -0
- package/build/src/helper/index.d.ts +7 -0
- package/build/src/helper/isFileTypeSupported/isFileTypeSupported.d.ts +7 -0
- package/build/src/index.d.ts +2 -0
- package/build/src/math/index.d.ts +1 -1
- package/build/src/modules/_system/Module.d.ts +13 -0
- package/build/src/modules/_system/ModuleRegistry.d.ts +29 -0
- package/build/src/modules/ar/ARSystem.cjs +2 -0
- package/build/src/modules/ar/ARSystem.cjs.map +1 -0
- package/build/src/{ar/AR.d.ts → modules/ar/ARSystem.d.ts} +26 -0
- package/build/src/modules/ar/ARSystem.mjs +164 -0
- package/build/src/modules/ar/ARSystem.mjs.map +1 -0
- package/build/src/{ar → modules/ar}/arquicklook/ARQuickLook.d.ts +2 -1
- package/build/src/{ar → modules/ar}/sceneviewer/SceneViewer.d.ts +1 -1
- package/build/src/{ar → modules/ar}/webxr/WebXR.d.ts +3 -3
- package/build/src/{ar → modules/ar}/webxr/controller/WebXRController.d.ts +2 -2
- package/build/src/{ar → modules/ar}/webxr/origin/WebXROrigin.d.ts +1 -1
- package/build/src/{ar → modules/ar}/webxr/raycaster/WebXRRaycaster.d.ts +3 -3
- package/build/src/{ar → modules/ar}/webxr/raycaster/ar/WebXRRaycasterAR.d.ts +1 -1
- package/build/src/{ar → modules/ar}/webxr/raycaster/three/WebXRRaycasterTHREE.d.ts +2 -2
- package/build/src/{ar → modules/ar}/webxr/touchscreencontrols/WebXRTouchscreenControls.d.ts +1 -1
- package/build/src/modules/asset/converter/AssetConverter.cjs +2 -0
- package/build/src/modules/asset/converter/AssetConverter.cjs.map +1 -0
- package/build/src/modules/asset/converter/AssetConverter.d.ts +29 -0
- package/build/src/modules/asset/converter/AssetConverter.mjs +22 -0
- package/build/src/modules/asset/converter/AssetConverter.mjs.map +1 -0
- package/build/src/modules/asset/exporter/AssetExporter.cjs +165 -0
- package/build/src/modules/asset/exporter/AssetExporter.cjs.map +1 -0
- package/build/src/{exporter/Exporter.d.ts → modules/asset/exporter/AssetExporter.d.ts} +7 -2
- package/build/src/modules/asset/exporter/AssetExporter.mjs +1622 -0
- package/build/src/modules/asset/exporter/AssetExporter.mjs.map +1 -0
- package/build/src/modules/asset/loader/AssetLoader.cjs +3 -0
- package/build/src/modules/asset/loader/AssetLoader.cjs.map +1 -0
- package/build/src/modules/asset/loader/AssetLoader.d.ts +33 -0
- package/build/src/modules/asset/loader/AssetLoader.mjs +1924 -0
- package/build/src/modules/asset/loader/AssetLoader.mjs.map +1 -0
- package/build/src/modules/index.d.ts +10 -0
- package/build/src/modules/mediacreator/MediaCreator.cjs +2 -0
- package/build/src/modules/mediacreator/MediaCreator.cjs.map +1 -0
- package/build/src/modules/mediacreator/MediaCreator.d.ts +40 -0
- package/build/src/modules/mediacreator/MediaCreator.mjs +28 -0
- package/build/src/modules/mediacreator/MediaCreator.mjs.map +1 -0
- package/build/src/modules/systeminfo/SystemInfo.cjs +2 -0
- package/build/src/modules/systeminfo/SystemInfo.cjs.map +1 -0
- package/build/src/{info/Info.d.ts → modules/systeminfo/SystemInfo.d.ts} +40 -7
- package/build/src/modules/systeminfo/SystemInfo.mjs +115 -0
- package/build/src/modules/systeminfo/SystemInfo.mjs.map +1 -0
- package/build/src/toolbox/BaseTool.d.ts +1 -1
- package/build/src/toolbox/Toolbox.d.ts +1 -1
- package/build/src/toolbox/select/SelectTool.d.ts +1 -1
- package/build/src/toolbox/transform/TransformTool.d.ts +1 -1
- package/build/src/types/file/FileTypes.d.ts +1 -2
- package/build/src/types/index.d.ts +1 -0
- package/package.json +17 -21
- package/build/dive.cjs +0 -4025
- package/build/dive.cjs.map +0 -1
- package/build/dive.d.ts +0 -6
- package/build/dive.js +0 -4025
- package/build/dive.js.map +0 -1
- package/build/dive.mjs +0 -28200
- package/build/dive.mjs.map +0 -1
- package/build/src/converter/Converter.d.ts +0 -12
- package/build/src/io/IO.d.ts +0 -10
- package/build/src/io/gltf/GLTFIO.d.ts +0 -12
- package/build/src/loader/Loader.d.ts +0 -7
- package/build/src/mediacreator/MediaCreator.d.ts +0 -17
- package/build/src/module/Module.d.ts +0 -8
- package/build/src/types/error/index.d.ts +0 -12
- /package/build/src/{renderer → engine/renderer}/Renderer.d.ts +0 -0
- /package/build/src/{scene → engine/scene}/xrroot/XRRoot.d.ts +0 -0
- /package/build/src/{scene → engine/scene}/xrroot/xrlightroot/XRLightRoot.d.ts +0 -0
- /package/build/src/{ar → modules/ar}/webxr/crosshair/WebXRCrosshair.d.ts +0 -0
- /package/build/src/{ar → modules/ar}/webxr/overlay/Overlay.d.ts +0 -0
package/README.md
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
This file is automatically generated
|
|
5
|
-
You can find the template in ci/readme/template/TEMPLATE_README.md
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
-->
|
|
9
|
-
|
|
10
1
|
<p align="center">
|
|
11
2
|
<img alt="DIVE logo" src="./assets/svg/dive.svg" style="width: 100%; height: auto; max-height: 500px;">
|
|
12
3
|
</p>
|
|
@@ -28,25 +19,45 @@ You can find the template in ci/readme/template/TEMPLATE_README.md
|
|
|
28
19
|
|
|
29
20
|
## Table of Contents
|
|
30
21
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
22
|
+
- [Table of Contents](#table-of-contents)
|
|
23
|
+
- [About](#about)
|
|
24
|
+
- [Setup and Maintenance](#setup-and-maintenance)
|
|
25
|
+
- [Installation](#installation)
|
|
26
|
+
- [Module System](#module-system)
|
|
27
|
+
- [Module Exports](#module-exports)
|
|
28
|
+
- [Build Process](#build-process)
|
|
29
|
+
- [Development Workflow](#development-workflow)
|
|
30
|
+
- [Local Development with Yalc](#local-development-with-yalc)
|
|
31
|
+
- [Shopware Integration](#shopware-integration)
|
|
32
|
+
- [Testing and Quality Assurance](#testing-and-quality-assurance)
|
|
33
|
+
- [Unit Tests](#unit-tests)
|
|
34
|
+
- [Code Formatting](#code-formatting)
|
|
35
|
+
- [Usage Guide](#usage-guide)
|
|
36
|
+
- [Core Concepts](#core-concepts)
|
|
37
|
+
- [Quick View](#quick-view)
|
|
38
|
+
- [Getting Started](#getting-started)
|
|
39
|
+
- [Import](#import)
|
|
40
|
+
- [Instantiate](#instantiate)
|
|
41
|
+
- [Modules](#modules)
|
|
42
|
+
- [Modules (List)](#modules-list)
|
|
43
|
+
- [Actions](#actions)
|
|
44
|
+
- [Basic Usage](#basic-usage)
|
|
45
|
+
- [Subscribing to Actions](#subscribing-to-actions)
|
|
46
|
+
- [Actions List](#actions-list)
|
|
38
47
|
|
|
39
48
|
## About
|
|
40
49
|
|
|
41
|
-
DIVE is a spatial framework made by and optimized for Shopware. It can be used
|
|
42
|
-
|
|
43
|
-
|
|
50
|
+
DIVE is a spatial framework made by and optimized for Shopware. It can be used directly integrated
|
|
51
|
+
in a Shopware frontend such as Storefront or in any other frontend you want to use it in, it is not
|
|
52
|
+
tied to Shopware.
|
|
53
|
+
|
|
54
|
+
DIVE supplies your frontend application with all needed tooling to set up a basic 3D application
|
|
55
|
+
with event-based controls called "Actions". For further information, see
|
|
56
|
+
[Getting started](#getting-started).
|
|
44
57
|
|
|
45
|
-
|
|
46
|
-
basic 3D application with event-based controls called "Actions". For further
|
|
47
|
-
information, see [Getting started](#getting-started).
|
|
58
|
+
## Setup and Maintenance
|
|
48
59
|
|
|
49
|
-
|
|
60
|
+
### Installation
|
|
50
61
|
|
|
51
62
|
The `@shopware-ag/dive` package can be installed via
|
|
52
63
|
|
|
@@ -58,59 +69,110 @@ or
|
|
|
58
69
|
yarn add @shopware-ag/dive
|
|
59
70
|
```
|
|
60
71
|
|
|
61
|
-
|
|
72
|
+
### Module System
|
|
73
|
+
|
|
74
|
+
DIVE uses a modern module system with support for both ESM and CommonJS formats. The package is
|
|
75
|
+
built using Vite and supports the following module formats:
|
|
76
|
+
|
|
77
|
+
- ESM (`.mjs` files)
|
|
78
|
+
- CommonJS (`.cjs` files)
|
|
79
|
+
- TypeScript type definitions (`.d.ts` files)
|
|
80
|
+
|
|
81
|
+
#### Module Exports
|
|
82
|
+
|
|
83
|
+
The package exports are configured in `package.json` to support both direct imports and
|
|
84
|
+
module-specific imports:
|
|
85
|
+
|
|
86
|
+
```json
|
|
87
|
+
{
|
|
88
|
+
"exports": {
|
|
89
|
+
".": {
|
|
90
|
+
"types": "./build/index.d.ts",
|
|
91
|
+
"import": "./build/index.mjs",
|
|
92
|
+
"require": "./build/index.cjs"
|
|
93
|
+
},
|
|
94
|
+
"./modules/*": {
|
|
95
|
+
"types": "./build/src/modules/*.d.ts",
|
|
96
|
+
"import": "./build/src/modules/*.mjs",
|
|
97
|
+
"require": "./build/src/modules/*.cjs"
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
```
|
|
62
102
|
|
|
63
|
-
|
|
103
|
+
#### Build Process
|
|
64
104
|
|
|
65
|
-
|
|
66
|
-
based on) uses it's own instances of `npm` so we need to make sure that the `npm link` get's executed within the correct `devenv` environment a.k.a `nix/store`.
|
|
67
|
-
To make sure you are using the correct instance of `npm` you have to browse to your `devenv` project:
|
|
105
|
+
The build process is handled by Vite and can be triggered using:
|
|
68
106
|
|
|
69
107
|
```bash
|
|
70
|
-
|
|
108
|
+
yarn build # One-time build
|
|
109
|
+
yarn dev # Watch mode for development
|
|
71
110
|
```
|
|
72
111
|
|
|
73
|
-
|
|
112
|
+
The build process:
|
|
74
113
|
|
|
75
|
-
|
|
114
|
+
1. Compiles TypeScript code
|
|
115
|
+
2. Generates type definitions
|
|
116
|
+
3. Creates both ESM and CommonJS versions of the code
|
|
117
|
+
4. Places all output in the `build/` directory
|
|
76
118
|
|
|
77
|
-
####
|
|
119
|
+
#### Development Workflow
|
|
78
120
|
|
|
79
|
-
|
|
121
|
+
For local development, you can use the watch mode to automatically rebuild when files change:
|
|
80
122
|
|
|
81
123
|
```bash
|
|
82
|
-
|
|
124
|
+
yarn dev
|
|
83
125
|
```
|
|
84
126
|
|
|
85
|
-
|
|
127
|
+
This is particularly useful when working with the module system as it ensures your changes are
|
|
128
|
+
immediately reflected in the build output.
|
|
129
|
+
|
|
130
|
+
### Local Development with Yalc
|
|
131
|
+
|
|
132
|
+
[Yalc](https://github.com/wclr/yalc) is the recommended way to test local changes in your project.
|
|
133
|
+
It provides better dependency management and more reliable linking than npm link.
|
|
134
|
+
|
|
135
|
+
First, install yalc globally if you haven't already:
|
|
86
136
|
|
|
87
137
|
```bash
|
|
88
|
-
|
|
138
|
+
npm install -g yalc
|
|
89
139
|
```
|
|
90
140
|
|
|
91
|
-
|
|
141
|
+
Then, in your DIVE project directory:
|
|
92
142
|
|
|
93
|
-
|
|
143
|
+
```bash
|
|
144
|
+
# Publish the package to yalc's local store
|
|
145
|
+
yalc publish
|
|
94
146
|
|
|
95
|
-
|
|
147
|
+
# In your project that uses DIVE:
|
|
148
|
+
yalc add @shopware-ag/dive
|
|
149
|
+
```
|
|
96
150
|
|
|
97
|
-
|
|
151
|
+
When you make changes to DIVE, you'll need to:
|
|
98
152
|
|
|
99
153
|
```bash
|
|
100
|
-
|
|
101
|
-
|
|
154
|
+
# In DIVE directory:
|
|
155
|
+
yalc push
|
|
156
|
+
|
|
157
|
+
# Or if you want to republish:
|
|
158
|
+
yalc publish --force
|
|
102
159
|
```
|
|
103
160
|
|
|
104
|
-
|
|
161
|
+
To remove the local package from your project:
|
|
105
162
|
|
|
106
163
|
```bash
|
|
107
|
-
|
|
108
|
-
npm link @shopware-ag/dive
|
|
164
|
+
yalc remove @shopware-ag/dive
|
|
109
165
|
```
|
|
110
166
|
|
|
111
|
-
|
|
167
|
+
Benefits of using yalc:
|
|
168
|
+
|
|
169
|
+
- Better dependency management
|
|
170
|
+
- More reliable than npm link
|
|
171
|
+
- Works well with package managers (npm, yarn, pnpm)
|
|
172
|
+
- Maintains proper package.json dependencies
|
|
173
|
+
- Supports multiple projects using the same local package
|
|
112
174
|
|
|
113
|
-
|
|
175
|
+
### Shopware Integration
|
|
114
176
|
|
|
115
177
|
Don't forget to include DIVE in your `webpack.config.js`:
|
|
116
178
|
|
|
@@ -163,47 +225,54 @@ module.exports = () => {
|
|
|
163
225
|
};
|
|
164
226
|
```
|
|
165
227
|
|
|
166
|
-
|
|
228
|
+
### Testing and Quality Assurance
|
|
167
229
|
|
|
168
|
-
|
|
230
|
+
#### Unit Tests
|
|
169
231
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
parameter, to create an instance of DIVE with your asset to use in further code.
|
|
232
|
+
All relevant files are covered by Jest tests. If you find any file that has not been covered yet,
|
|
233
|
+
feel free to add unit tests accordingly.
|
|
173
234
|
|
|
174
|
-
|
|
175
|
-
|
|
235
|
+
If there are any modules that have to be mocked (like `three`) you can create a given file in the
|
|
236
|
+
`__mocks__` folder in project root. Jest manages to mock modules with a given file with the modules
|
|
237
|
+
name as a file name (for example `three.ts`). Every export will be part of the modules mock. You
|
|
238
|
+
don't need to mock the module in your test anymore, you only extend the module mock.
|
|
176
239
|
|
|
177
|
-
|
|
240
|
+
If you have any other things from a module to import, you can simply create a folder structure and
|
|
241
|
+
place the mock file at the end of your structure. To understand better please take a look at the
|
|
242
|
+
`__mocks__` folder for yourself.
|
|
178
243
|
|
|
179
|
-
|
|
180
|
-
myCanvasWrapper.appendChild(dive.Canvas);
|
|
181
|
-
```
|
|
244
|
+
#### Code Formatting
|
|
182
245
|
|
|
183
|
-
|
|
246
|
+
DIVE uses Prettier as a preconfigured formatter.
|
|
247
|
+
|
|
248
|
+
## Usage Guide
|
|
249
|
+
|
|
250
|
+
### Core Concepts
|
|
251
|
+
|
|
252
|
+
#### Quick View
|
|
253
|
+
|
|
254
|
+
QuickView is used to quickly display your assets with as few lines of code as possible. Simply call
|
|
255
|
+
the static `QuickView()` method, with your data URI as a parameter, to create an instance of DIVE
|
|
256
|
+
with your asset to use in further code.
|
|
184
257
|
|
|
185
258
|
```ts
|
|
186
259
|
import { DIVE } from '@shopware-ag/dive';
|
|
187
260
|
|
|
188
|
-
|
|
189
|
-
const dive = DIVE.QuickView('your/asset/uri.glb'); // <-- call QuickView()
|
|
261
|
+
const dive = await DIVE.QuickView('your/asset/uri.glb'); // <-- call QuickView()
|
|
190
262
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
} catch (error) {
|
|
194
|
-
console.error('Failed to load asset:', error);
|
|
195
|
-
}
|
|
263
|
+
const myCanvasWrapper = document.createElement('div');
|
|
264
|
+
myCanvasWrapper.appendChild(dive.Canvas);
|
|
196
265
|
```
|
|
197
266
|
|
|
198
|
-
|
|
267
|
+
#### Getting Started
|
|
199
268
|
|
|
200
|
-
|
|
269
|
+
##### Import
|
|
201
270
|
|
|
202
271
|
```ts
|
|
203
272
|
import { DIVE } from '@shopware-ag/dive'; // <-- import DIVE
|
|
204
273
|
```
|
|
205
274
|
|
|
206
|
-
|
|
275
|
+
##### Instantiate
|
|
207
276
|
|
|
208
277
|
```ts
|
|
209
278
|
import { DIVE } from '@shopware-ag/dive';
|
|
@@ -211,9 +280,8 @@ import { DIVE } from '@shopware-ag/dive';
|
|
|
211
280
|
const dive = new DIVE(); // <-- instantiate DIVE
|
|
212
281
|
```
|
|
213
282
|
|
|
214
|
-
DIVE supplies your application with a HTMLCanvasElement that it uses as a render
|
|
215
|
-
|
|
216
|
-
code to attach it to your DOM.
|
|
283
|
+
DIVE supplies your application with a HTMLCanvasElement that it uses as a render target. After
|
|
284
|
+
instantiating, you can use the supplied canvas within your frontend code to attach it to your DOM.
|
|
217
285
|
|
|
218
286
|
```ts
|
|
219
287
|
const dive = new DIVE();
|
|
@@ -222,328 +290,193 @@ const myCanvasWrapper = document.createElement('div'); // <-- create wrapper ele
|
|
|
222
290
|
myCanvasWrapper.appendChild(dive.Canvas); // <-- reference DIVE canvas
|
|
223
291
|
```
|
|
224
292
|
|
|
225
|
-
|
|
226
|
-
|
|
293
|
+
### Modules
|
|
294
|
+
|
|
295
|
+
DIVE comes with several built-in modules that provide specific functionality. You can access modules
|
|
296
|
+
in two ways:
|
|
297
|
+
|
|
298
|
+
1. Direct import from the modules directory (recommended for most use cases):
|
|
299
|
+
|
|
300
|
+
```ts
|
|
301
|
+
import { ARSystem } from '@shopware-ag/dive/modules/ar';
|
|
302
|
+
|
|
303
|
+
// Initialize AR with options
|
|
304
|
+
const arSystem = new ARSystem();
|
|
305
|
+
await arSystem.launch('path/to/model.glb', {
|
|
306
|
+
arPlacement: 'horizontal', // or 'vertical'
|
|
307
|
+
arScale: 'auto' // or 'fixed'
|
|
308
|
+
});
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
2. Through the DIVE instance (when you need to work with a specific DIVE instance):
|
|
227
312
|
|
|
228
313
|
```ts
|
|
314
|
+
import { DIVE } from '@shopware-ag/dive';
|
|
315
|
+
|
|
316
|
+
// Create a DIVE instance
|
|
229
317
|
const dive = new DIVE();
|
|
230
318
|
|
|
231
|
-
|
|
232
|
-
|
|
319
|
+
// Get a module instance from the DIVE instance
|
|
320
|
+
const assetLoader = await dive.modules.get('AssetLoader');
|
|
321
|
+
const model = await assetLoader.load('path/to/model.glb');
|
|
322
|
+
```
|
|
233
323
|
|
|
234
|
-
|
|
324
|
+
### Modules (List)
|
|
235
325
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
326
|
+
DIVE provides several specialized modules for different aspects of 3D content handling:
|
|
327
|
+
|
|
328
|
+
#### ARSystem
|
|
329
|
+
|
|
330
|
+
The AR module enables Augmented Reality features across different platforms:
|
|
331
|
+
|
|
332
|
+
```ts
|
|
333
|
+
import { ARSystem } from '@shopware-ag/dive/modules/ar';
|
|
334
|
+
const arSystem = new ARSystem();
|
|
335
|
+
|
|
336
|
+
// Launch AR with options
|
|
337
|
+
await arSystem.launch('path/to/model.glb', {
|
|
338
|
+
arPlacement: 'horizontal', // or 'vertical'
|
|
339
|
+
arScale: 'auto' // or 'fixed'
|
|
240
340
|
});
|
|
241
341
|
```
|
|
242
342
|
|
|
243
|
-
|
|
343
|
+
Features:
|
|
344
|
+
- Platform-specific AR implementations (ARQuickLook for iOS, SceneViewer for Android)
|
|
345
|
+
- Automatic format conversion for AR compatibility
|
|
346
|
+
- Configurable placement and scaling options
|
|
244
347
|
|
|
245
|
-
|
|
246
|
-
can be performed anywhere, no matter if you are in frontend or 3D.
|
|
348
|
+
#### AssetConverter
|
|
247
349
|
|
|
248
|
-
|
|
249
|
-
subscribed to.
|
|
350
|
+
Converts between different 3D file formats:
|
|
250
351
|
|
|
251
352
|
```ts
|
|
252
|
-
|
|
253
|
-
const
|
|
353
|
+
import { AssetConverter } from '@shopware-ag/dive/modules/asset/converter';
|
|
354
|
+
const assetConverter = new AssetConverter();
|
|
355
|
+
const usdzBuffer = await assetConverter.convert('input.glb').to('usdz');
|
|
356
|
+
```
|
|
254
357
|
|
|
255
|
-
|
|
358
|
+
#### AssetExporter
|
|
256
359
|
|
|
257
|
-
|
|
360
|
+
Exports 3D assets to various formats:
|
|
258
361
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
362
|
+
```ts
|
|
363
|
+
import { AssetExporter } from '@shopware-ag/dive/modules/asset/exporter';
|
|
364
|
+
const assetExporter = new AssetExporter();
|
|
365
|
+
const buffer = await assetExporter.export(model, 'glb');
|
|
366
|
+
```
|
|
263
367
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
368
|
+
#### AssetLoader
|
|
369
|
+
|
|
370
|
+
Handles loading of 3D assets in various formats:
|
|
371
|
+
|
|
372
|
+
```ts
|
|
373
|
+
// Direct import
|
|
374
|
+
import { AssetLoader } from '@shopware-ag/dive/modules/asset/loader';
|
|
375
|
+
const assetLoader = new AssetLoader();
|
|
376
|
+
const model = await assetLoader.load('path/to/model.glb');
|
|
377
|
+
|
|
378
|
+
// Or through DIVE instance
|
|
379
|
+
const assetLoader = await dive.modules.get('AssetLoader');
|
|
380
|
+
const model = await assetLoader.load('path/to/model.glb');
|
|
268
381
|
```
|
|
269
382
|
|
|
270
|
-
|
|
271
|
-
|
|
383
|
+
Supported formats:
|
|
384
|
+
- GLB/GLTF
|
|
385
|
+
- USDZ
|
|
386
|
+
|
|
387
|
+
#### MediaCreator
|
|
388
|
+
|
|
389
|
+
Provides tools for creating media content from the 3D scene:
|
|
272
390
|
|
|
273
391
|
```ts
|
|
274
|
-
|
|
275
|
-
const
|
|
392
|
+
import { MediaCreator } from '@shopware-ag/dive/modules/mediacreator';
|
|
393
|
+
const mediaCreator = new MediaCreator();
|
|
394
|
+
|
|
395
|
+
// Generate a screenshot
|
|
396
|
+
const screenshot = await mediaCreator.GenerateMedia(
|
|
397
|
+
{ x: 0, y: 0, z: 0 }, // camera position
|
|
398
|
+
{ x: 0, y: 0, z: 0 }, // camera target
|
|
399
|
+
1920, // width
|
|
400
|
+
1080 // height
|
|
401
|
+
);
|
|
402
|
+
```
|
|
276
403
|
|
|
277
|
-
|
|
404
|
+
Features:
|
|
405
|
+
- High-quality screenshot generation
|
|
406
|
+
- Customizable camera position and target
|
|
407
|
+
- Configurable output resolution
|
|
278
408
|
|
|
279
|
-
|
|
409
|
+
#### SystemInfo
|
|
280
410
|
|
|
281
|
-
|
|
282
|
-
// <-- save unsubscribe callback
|
|
283
|
-
// do something
|
|
284
|
-
});
|
|
411
|
+
Provides information about the system's capabilities and performance:
|
|
285
412
|
|
|
413
|
+
```ts
|
|
414
|
+
import { SystemInfo } from '@shopware-ag/dive/modules/systeminfo';
|
|
415
|
+
const systemInfo = new SystemInfo();
|
|
416
|
+
|
|
417
|
+
// Get system information
|
|
418
|
+
const system = systemInfo.getSystem(); // Returns ESystem enum (IOS, ANDROID, etc.)
|
|
419
|
+
|
|
420
|
+
// Check AR capabilities
|
|
421
|
+
const supportsAR = systemInfo.getSupportsAR();
|
|
422
|
+
|
|
423
|
+
// Check device type
|
|
424
|
+
const isMobile = systemInfo.isMobile;
|
|
425
|
+
const isDesktop = systemInfo.isDesktop;
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
Features:
|
|
429
|
+
- System detection (iOS, Android, Windows, etc.)
|
|
430
|
+
- WebXR support detection
|
|
431
|
+
- AR capability checking
|
|
432
|
+
- Device type detection
|
|
433
|
+
- SceneViewer support detection
|
|
434
|
+
|
|
435
|
+
Each module is designed to be used independently, allowing you to use only the functionality you
|
|
436
|
+
need. This helps keep your bundle size small and your application focused.
|
|
437
|
+
|
|
438
|
+
### Actions
|
|
439
|
+
|
|
440
|
+
Actions are the primary way to communicate between your frontend application and the 3D space in
|
|
441
|
+
DIVE. They can be used to control various aspects of the 3D scene, such as camera movement, object
|
|
442
|
+
manipulation, and scene state management.
|
|
443
|
+
|
|
444
|
+
#### Basic Usage
|
|
445
|
+
|
|
446
|
+
To perform an action, use the `DIVECommunication` instance:
|
|
447
|
+
|
|
448
|
+
```ts
|
|
449
|
+
const dive = new DIVE();
|
|
450
|
+
const com = dive.Communication;
|
|
451
|
+
|
|
452
|
+
// Perform an action
|
|
286
453
|
com.PerformAction('SET_CAMERA_TRANSFORM', {
|
|
287
454
|
position: { x: 0, y: 2, z: 2 },
|
|
288
455
|
target: { x: 0, y: 0.5, z: 0 },
|
|
289
456
|
});
|
|
457
|
+
```
|
|
290
458
|
|
|
291
|
-
|
|
459
|
+
#### Subscribing to Actions
|
|
460
|
+
|
|
461
|
+
You can subscribe to actions to react to changes in the 3D space:
|
|
462
|
+
|
|
463
|
+
```ts
|
|
464
|
+
const unsubscribe = com.Subscribe('SET_CAMERA_TRANSFORM', (data) => {
|
|
465
|
+
console.log('Camera position changed:', data);
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
// Don't forget to unsubscribe when done
|
|
469
|
+
unsubscribe();
|
|
292
470
|
```
|
|
293
471
|
|
|
294
472
|
#### Actions List
|
|
295
473
|
|
|
296
|
-
|
|
297
|
-
DIVECommunication class via
|
|
298
|
-
[`com.PerformAction()`](https://github.com/shopware/dive/blob/2e193c58843939ce07a1d35bfbd5b3c9d26eeeca/src/com/Communication.ts#L85).
|
|
299
|
-
|
|
300
|
-
<table>
|
|
301
|
-
<tr>
|
|
302
|
-
<th>Actions</th>
|
|
303
|
-
<th>Description</th>
|
|
304
|
-
</tr>
|
|
305
|
-
<tr>
|
|
306
|
-
<td>
|
|
307
|
-
<a href="src/com/actions/object/addobject.ts"> ADD_OBJECT </a>
|
|
308
|
-
</td>
|
|
309
|
-
<td>
|
|
310
|
-
Adds an object to the scene.
|
|
311
|
-
</td>
|
|
312
|
-
</tr>
|
|
313
|
-
<tr>
|
|
314
|
-
<td>
|
|
315
|
-
<a href="src/com/actions/camera/computeencompassingview.ts"> COMPUTE_ENCOMPASSING_VIEW </a>
|
|
316
|
-
</td>
|
|
317
|
-
<td>
|
|
318
|
-
Calculates the camera position and target to view the whole scene. (experimental)
|
|
319
|
-
</td>
|
|
320
|
-
</tr>
|
|
321
|
-
<tr>
|
|
322
|
-
<td>
|
|
323
|
-
<a href="src/com/actions/object/deleteobject.ts"> DELETE_OBJECT </a>
|
|
324
|
-
</td>
|
|
325
|
-
<td>
|
|
326
|
-
Deletes an object from the scene.
|
|
327
|
-
</td>
|
|
328
|
-
</tr>
|
|
329
|
-
<tr>
|
|
330
|
-
<td>
|
|
331
|
-
<a href="src/com/actions/object/deselectobject.ts"> DESELECT_OBJECT </a>
|
|
332
|
-
</td>
|
|
333
|
-
<td>
|
|
334
|
-
Deselects an existing object.
|
|
335
|
-
</td>
|
|
336
|
-
</tr>
|
|
337
|
-
<tr>
|
|
338
|
-
<td>
|
|
339
|
-
<a href="src/com/actions/object/model/dropit.ts"> DROP_IT </a>
|
|
340
|
-
</td>
|
|
341
|
-
<td>
|
|
342
|
-
Places an object on top of an underlying object or the floor.
|
|
343
|
-
</td>
|
|
344
|
-
</tr>
|
|
345
|
-
<tr>
|
|
346
|
-
<td>
|
|
347
|
-
<a href="src/com/actions/scene/exportscene.ts"> EXPORT_SCENE </a>
|
|
348
|
-
</td>
|
|
349
|
-
<td>
|
|
350
|
-
Exports the current scene to a blob and returns the URL.
|
|
351
|
-
</td>
|
|
352
|
-
</tr>
|
|
353
|
-
<tr>
|
|
354
|
-
<td>
|
|
355
|
-
<a href="src/com/actions/media/generatemedia.ts"> GENERATE_MEDIA </a>
|
|
356
|
-
</td>
|
|
357
|
-
<td>
|
|
358
|
-
Generates a screenshot, stores it in a Blob and returns a Promise of a valid URI.
|
|
359
|
-
</td>
|
|
360
|
-
</tr>
|
|
361
|
-
<tr>
|
|
362
|
-
<td>
|
|
363
|
-
<a href="src/com/actions/object/getallobjects.ts"> GET_ALL_OBJECTS </a>
|
|
364
|
-
</td>
|
|
365
|
-
<td>
|
|
366
|
-
Retrieves all objects in the scene.
|
|
367
|
-
</td>
|
|
368
|
-
</tr>
|
|
369
|
-
<tr>
|
|
370
|
-
<td>
|
|
371
|
-
<a href="src/com/actions/scene/getallscenedata.ts"> GET_ALL_SCENE_DATA </a>
|
|
372
|
-
</td>
|
|
373
|
-
<td>
|
|
374
|
-
Retrieves all current scene data.
|
|
375
|
-
</td>
|
|
376
|
-
</tr>
|
|
377
|
-
<tr>
|
|
378
|
-
<td>
|
|
379
|
-
<a href="src/com/actions/camera/getcameratransform.ts"> GET_CAMERA_TRANSFORM </a>
|
|
380
|
-
</td>
|
|
381
|
-
<td>
|
|
382
|
-
Returns the current camera position and target.
|
|
383
|
-
</td>
|
|
384
|
-
</tr>
|
|
385
|
-
<tr>
|
|
386
|
-
<td>
|
|
387
|
-
<a href="src/com/actions/object/getobjects.ts"> GET_OBJECTS </a>
|
|
388
|
-
</td>
|
|
389
|
-
<td>
|
|
390
|
-
Returns a list of objects of given IDs.
|
|
391
|
-
</td>
|
|
392
|
-
</tr>
|
|
393
|
-
<tr>
|
|
394
|
-
<td>
|
|
395
|
-
<a href="src/com/actions/scene/launchar.ts"> LAUNCH_AR </a>
|
|
396
|
-
</td>
|
|
397
|
-
<td>
|
|
398
|
-
Launches AR mode in native capabilities. (iOS: AR Quick Look, Android: Google Scene Viewer)
|
|
399
|
-
</td>
|
|
400
|
-
</tr>
|
|
401
|
-
<tr>
|
|
402
|
-
<td>
|
|
403
|
-
<a href="src/com/actions/object/model/modelloaded.ts"> MODEL_LOADED </a>
|
|
404
|
-
</td>
|
|
405
|
-
<td>
|
|
406
|
-
Is triggered when a model is loaded.
|
|
407
|
-
</td>
|
|
408
|
-
</tr>
|
|
409
|
-
<tr>
|
|
410
|
-
<td>
|
|
411
|
-
<a href="src/com/actions/camera/movecamera.ts"> MOVE_CAMERA </a>
|
|
412
|
-
</td>
|
|
413
|
-
<td>
|
|
414
|
-
Moves the camera to a new position and target.
|
|
415
|
-
</td>
|
|
416
|
-
</tr>
|
|
417
|
-
<tr>
|
|
418
|
-
<td>
|
|
419
|
-
<a href="src/com/actions/object/model/placeonfloor.ts"> PLACE_ON_FLOOR </a>
|
|
420
|
-
</td>
|
|
421
|
-
<td>
|
|
422
|
-
Places an object on the floor.
|
|
423
|
-
</td>
|
|
424
|
-
</tr>
|
|
425
|
-
<tr>
|
|
426
|
-
<td>
|
|
427
|
-
<a href="src/com/actions/camera/resetcamera.ts"> RESET_CAMERA </a>
|
|
428
|
-
</td>
|
|
429
|
-
<td>
|
|
430
|
-
Reset the camera to its initial position and rotation.
|
|
431
|
-
</td>
|
|
432
|
-
</tr>
|
|
433
|
-
<tr>
|
|
434
|
-
<td>
|
|
435
|
-
<a href="src/com/actions/object/selectobject.ts"> SELECT_OBJECT </a>
|
|
436
|
-
</td>
|
|
437
|
-
<td>
|
|
438
|
-
Selects an existing object.
|
|
439
|
-
</td>
|
|
440
|
-
</tr>
|
|
441
|
-
<tr>
|
|
442
|
-
<td>
|
|
443
|
-
<a href="src/com/actions/scene/setbackground.ts"> SET_BACKGROUND </a>
|
|
444
|
-
</td>
|
|
445
|
-
<td>
|
|
446
|
-
Set the background color of the scene.
|
|
447
|
-
</td>
|
|
448
|
-
</tr>
|
|
449
|
-
<tr>
|
|
450
|
-
<td>
|
|
451
|
-
<a href="src/com/actions/camera/setcameralayer.ts"> SET_CAMERA_LAYER </a>
|
|
452
|
-
</td>
|
|
453
|
-
<td>
|
|
454
|
-
Sets the camera layer to a certain layer.
|
|
455
|
-
</td>
|
|
456
|
-
</tr>
|
|
457
|
-
<tr>
|
|
458
|
-
<td>
|
|
459
|
-
<a href="src/com/actions/camera/setcameratransform.ts"> SET_CAMERA_TRANSFORM </a>
|
|
460
|
-
</td>
|
|
461
|
-
<td>
|
|
462
|
-
Sets the camera position and target.
|
|
463
|
-
</td>
|
|
464
|
-
</tr>
|
|
465
|
-
<tr>
|
|
466
|
-
<td>
|
|
467
|
-
<a href="src/com/actions/toolbox/select/setgizmomode.ts"> SET_GIZMO_MODE </a>
|
|
468
|
-
</td>
|
|
469
|
-
<td>
|
|
470
|
-
Sets the gizmo's mode.
|
|
471
|
-
</td>
|
|
472
|
-
</tr>
|
|
473
|
-
<tr>
|
|
474
|
-
<td>
|
|
475
|
-
<a href="src/com/actions/toolbox/transform/setgizmoscalelinked.ts"> SET_GIZMO_SCALE_LINKED </a>
|
|
476
|
-
</td>
|
|
477
|
-
<td>
|
|
478
|
-
Sets the gizmo's unified scale mode.
|
|
479
|
-
</td>
|
|
480
|
-
</tr>
|
|
481
|
-
<tr>
|
|
482
|
-
<td>
|
|
483
|
-
<a href="src/com/actions/toolbox/transform/setgizmovisible.ts"> SET_GIZMO_VISIBILITY </a>
|
|
484
|
-
</td>
|
|
485
|
-
<td>
|
|
486
|
-
Sets the gizmo's visibility.
|
|
487
|
-
</td>
|
|
488
|
-
</tr>
|
|
489
|
-
<tr>
|
|
490
|
-
<td>
|
|
491
|
-
<a href="src/com/actions/object/setparent.ts"> SET_PARENT </a>
|
|
492
|
-
</td>
|
|
493
|
-
<td>
|
|
494
|
-
Attach an object to another object.
|
|
495
|
-
</td>
|
|
496
|
-
</tr>
|
|
497
|
-
<tr>
|
|
498
|
-
<td>
|
|
499
|
-
<a href="src/com/actions/renderer/startrender.ts"> START_RENDER </a>
|
|
500
|
-
</td>
|
|
501
|
-
<td>
|
|
502
|
-
Starts the render process.
|
|
503
|
-
</td>
|
|
504
|
-
</tr>
|
|
505
|
-
<tr>
|
|
506
|
-
<td>
|
|
507
|
-
<a href="src/com/actions/object/updateobject.ts"> UPDATE_OBJECT </a>
|
|
508
|
-
</td>
|
|
509
|
-
<td>
|
|
510
|
-
Updates an existing object.
|
|
511
|
-
</td>
|
|
512
|
-
</tr>
|
|
513
|
-
<tr>
|
|
514
|
-
<td>
|
|
515
|
-
<a href="src/com/actions/scene/updatescene.ts"> UPDATE_SCENE </a>
|
|
516
|
-
</td>
|
|
517
|
-
<td>
|
|
518
|
-
Updates global scene data.
|
|
519
|
-
</td>
|
|
520
|
-
</tr>
|
|
521
|
-
<tr>
|
|
522
|
-
<td>
|
|
523
|
-
<a href="src/com/actions/toolbox/usetool.ts"> USE_TOOL </a>
|
|
524
|
-
</td>
|
|
525
|
-
<td>
|
|
526
|
-
Activates a specific tool from the toolbox.
|
|
527
|
-
</td>
|
|
528
|
-
</tr>
|
|
529
|
-
<tr>
|
|
530
|
-
<td>
|
|
531
|
-
<a href="src/com/actions/camera/zoomcamera.ts"> ZOOM_CAMERA </a>
|
|
532
|
-
</td>
|
|
533
|
-
<td>
|
|
534
|
-
Zooms the camera in or out by a certain amount.
|
|
535
|
-
</td>
|
|
536
|
-
</tr>
|
|
537
|
-
</table>
|
|
538
|
-
|
|
539
|
-
## Unit Tests
|
|
540
|
-
|
|
541
|
-
All relevant files are covered by Jest tests. If you find any file that has not been covered yet, feel free to add unit tests accordingly.
|
|
542
|
-
|
|
543
|
-
If there are any modules that have to be mocked (like `three`) you can create a given file in the `__mocks__` folder in project root. Jest manages to mock modules with a given file with the modules name as a file name (for example `three.ts`). Every export will be part of the modules mock. You don't need to mock the module in your test anymore, you only extend the module mock.
|
|
544
|
-
|
|
545
|
-
If you have any other things from a module to import, you can simply create a folder structure and place the mock file at the end of your structure. To understand better please take a look at the `__mocks__` folder for yourself.
|
|
546
|
-
|
|
547
|
-
## Formatting
|
|
474
|
+
The following table lists all available actions in DIVE:
|
|
548
475
|
|
|
549
|
-
|
|
476
|
+
| Action | Description | Input | Return |
|
|
477
|
+
|--------|-------------|-------|--------|
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
Each action has specific parameters and return values. For detailed information about each action,
|
|
482
|
+
refer to the TypeScript type definitions in the source code.
|