@shopware-ag/dive 1.15.5 → 1.16.1
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 +77 -40
- package/build/dive.cjs +665 -153
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.cts +68 -52
- package/build/dive.d.ts +68 -52
- package/build/dive.js +706 -160
- package/build/dive.js.map +1 -1
- package/package.json +64 -60
- package/src/__test__/DIVE.test.ts +35 -31
- package/src/animation/AnimationSystem.ts +4 -4
- package/src/animation/__test__/AnimationSystem.test.ts +3 -3
- package/src/axiscamera/AxisCamera.ts +31 -11
- package/src/axiscamera/__test__/AxisCamera.test.ts +18 -10
- package/src/camera/PerspectiveCamera.ts +28 -13
- package/src/camera/__test__/PerspectiveCamera.test.ts +2 -2
- package/src/com/Communication.ts +297 -95
- package/src/com/__test__/Communication.test.ts +227 -140
- package/src/com/actions/camera/computeencompassingview.ts +7 -7
- package/src/com/actions/camera/getcameratransform.ts +7 -7
- package/src/com/actions/camera/movecamera.ts +15 -13
- package/src/com/actions/camera/resetcamera.ts +3 -3
- package/src/com/actions/camera/setcameralayer.ts +3 -3
- package/src/com/actions/camera/setcameratransform.ts +7 -7
- package/src/com/actions/camera/zoomcamera.ts +3 -3
- package/src/com/actions/index.ts +52 -50
- package/src/com/actions/media/generatemedia.ts +16 -13
- package/src/com/actions/object/addobject.ts +4 -4
- package/src/com/actions/object/deleteobject.ts +4 -4
- package/src/com/actions/object/deselectobject.ts +4 -4
- package/src/com/actions/object/getallobjects.ts +4 -4
- package/src/com/actions/object/getobjects.ts +4 -4
- package/src/com/actions/object/model/dropit.ts +3 -3
- package/src/com/actions/object/model/modelloaded.ts +3 -3
- package/src/com/actions/object/model/placeonfloor.ts +3 -3
- package/src/com/actions/object/selectobject.ts +4 -4
- package/src/com/actions/object/setparent.ts +7 -7
- package/src/com/actions/object/updateobject.ts +4 -4
- package/src/com/actions/scene/exportscene.ts +6 -0
- package/src/com/actions/scene/getallscenedata.ts +23 -18
- package/src/com/actions/scene/setbackground.ts +3 -3
- package/src/com/actions/scene/updatescene.ts +9 -9
- package/src/com/actions/toolbox/select/setgizmomode.ts +3 -3
- package/src/com/actions/toolbox/transform/setgizmovisible.ts +3 -3
- package/src/com/actions/toolbox/usetool.ts +4 -4
- package/src/com/types/COMBaseEntity.ts +2 -2
- package/src/com/types/COMEntity.ts +6 -6
- package/src/com/types/COMEntityType.ts +1 -1
- package/src/com/types/COMGeometry.ts +2 -2
- package/src/com/types/COMGroup.ts +3 -3
- package/src/com/types/COMLight.ts +3 -3
- package/src/com/types/COMMaterial.ts +2 -2
- package/src/com/types/COMModel.ts +4 -4
- package/src/com/types/COMPov.ts +3 -3
- package/src/com/types/COMPrimitive.ts +5 -5
- package/src/com/types/index.ts +10 -10
- package/src/constant/AxisHelperColors.ts +1 -1
- package/src/constant/GridColors.ts +1 -1
- package/src/controls/OrbitControls.ts +62 -29
- package/src/controls/__test__/OrbitControls.test.ts +133 -39
- package/src/dive.ts +82 -36
- package/src/gizmo/Gizmo.ts +21 -13
- package/src/gizmo/handles/AxisHandle.ts +40 -17
- package/src/gizmo/handles/RadialHandle.ts +39 -15
- package/src/gizmo/handles/ScaleHandle.ts +62 -25
- package/src/gizmo/plane/GizmoPlane.ts +5 -6
- package/src/gizmo/rotate/RotateGizmo.ts +58 -16
- package/src/gizmo/scale/ScaleGizmo.ts +37 -15
- package/src/gizmo/translate/TranslateGizmo.ts +34 -14
- package/src/grid/Grid.ts +13 -5
- package/src/grid/__test__/Grid.test.ts +5 -3
- package/src/group/Group.ts +9 -7
- package/src/group/__test__/Group.test.ts +8 -6
- package/src/helper/applyMixins/__test__/applyMixins.test.ts +9 -6
- package/src/helper/applyMixins/applyMixins.ts +6 -3
- package/src/helper/findInterface/__test__/findInterface.test.ts +28 -18
- package/src/helper/findInterface/findInterface.ts +7 -4
- package/src/helper/findSceneRecursive/__test__/findSceneRecursive.test.ts +1 -1
- package/src/helper/findSceneRecursive/findSceneRecursive.ts +1 -1
- package/src/helper/getObjectDelta/__test__/getObjectDelta.test.ts +43 -7
- package/src/helper/getObjectDelta/getObjectDelta.ts +13 -9
- package/src/helper/isInterface/__test__/implementsInterface.test.ts +1 -1
- package/src/helper/isInterface/implementsInterface.ts +6 -3
- package/src/info/Info.ts +20 -16
- package/src/info/__test__/Info.test.ts +67 -36
- package/src/interface/Draggable.ts +2 -2
- package/src/interface/Hoverable.ts +2 -2
- package/src/interface/Movable.ts +1 -1
- package/src/interface/Rotatable.ts +1 -1
- package/src/interface/Scalable.ts +1 -1
- package/src/io/IO.ts +85 -0
- package/src/io/__test__/IO.test.ts +99 -0
- package/src/io/gltf/GLTFIO.ts +56 -0
- package/src/io/gltf/__test__/GLTFIO.test.ts +185 -0
- package/src/light/PointLight.ts +42 -9
- package/src/light/SceneLight.ts +5 -5
- package/src/light/__test__/AmbientLight.test.ts +5 -4
- package/src/light/__test__/PointLight.test.ts +14 -10
- package/src/light/__test__/SceneLight.test.ts +19 -13
- package/src/loadingmanager/LoadingManager.ts +11 -6
- package/src/loadingmanager/__test__/LoadingManager.test.ts +14 -9
- package/src/math/__test__/DIVEMath.test.ts +1 -1
- package/src/math/ceil/__test__/ceilExp.test.ts +1 -1
- package/src/math/ceil/ceilExp.ts +2 -2
- package/src/math/floor/__test__/floorExp.test.ts +1 -1
- package/src/math/floor/floorExp.ts +2 -2
- package/src/math/helper/__test__/shift.test.ts +1 -1
- package/src/math/helper/shift.ts +1 -1
- package/src/math/index.ts +7 -7
- package/src/math/round/__test__/roundExp.test.ts +1 -1
- package/src/math/round/roundExp.ts +6 -3
- package/src/math/signedAngleTo/__test__/signedAngleTo.test.ts +10 -4
- package/src/math/signedAngleTo/signedAngleTo.ts +11 -4
- package/src/math/toFixed/__test__/toFixedExp.test.ts +9 -9
- package/src/math/toFixed/toFixedExp.ts +6 -3
- package/src/math/truncate/__test__/truncateExp.test.ts +1 -1
- package/src/math/truncate/truncateExp.ts +6 -3
- package/src/mediacreator/MediaCreator.ts +20 -10
- package/src/mediacreator/__test__/MediaCreator.test.ts +27 -12
- package/src/model/Model.ts +35 -7
- package/src/model/__test__/Model.test.ts +71 -44
- package/src/node/Node.ts +34 -12
- package/src/node/__test__/Node.test.ts +17 -13
- package/src/primitive/Primitive.ts +78 -13
- package/src/primitive/__test__/Primitive.test.ts +49 -38
- package/src/primitive/floor/Floor.ts +14 -3
- package/src/primitive/floor/__test__/Floor.test.ts +10 -4
- package/src/renderer/Renderer.ts +46 -15
- package/src/renderer/__test__/Renderer.test.ts +74 -24
- package/src/scene/Scene.ts +9 -3
- package/src/scene/__test__/Scene.test.ts +2 -2
- package/src/scene/root/Root.ts +142 -75
- package/src/scene/root/__test__/Root.test.ts +439 -111
- package/src/toolbox/BaseTool.ts +69 -33
- package/src/toolbox/Toolbox.ts +37 -17
- package/src/toolbox/__test__/BaseTool.test.ts +324 -160
- package/src/toolbox/__test__/Toolbox.test.ts +31 -14
- package/src/toolbox/select/SelectTool.ts +24 -19
- package/src/toolbox/select/__test__/SelectTool.test.ts +95 -59
- package/src/toolbox/transform/TransformTool.ts +40 -17
- package/src/toolbox/transform/__test__/TransformTool.test.ts +22 -15
- package/src/types/SceneObjects.ts +8 -8
- package/src/types/SceneType.ts +14 -0
- package/src/types/index.ts +3 -4
package/README.md
CHANGED
|
@@ -16,24 +16,33 @@
|
|
|
16
16
|
</p>
|
|
17
17
|
|
|
18
18
|
# About
|
|
19
|
-
DIVE is a spatial framework made by and optimized for Shopware. It can be used directly integrated in a Shopware frontend such as Storefront or in any other frontend you want to use it in, it is not tied to Shopware.
|
|
20
19
|
|
|
21
|
-
DIVE
|
|
20
|
+
DIVE is a spatial framework made by and optimized for Shopware. It can be used
|
|
21
|
+
directly integrated in a Shopware frontend such as Storefront or in any other
|
|
22
|
+
frontend you want to use it in, it is not tied to Shopware.
|
|
23
|
+
|
|
24
|
+
DIVE supplies your frontend application with all needed tooling to set up a
|
|
25
|
+
basic 3D application with event-based controls called "Actions". For further
|
|
26
|
+
information, see [Getting started](#getting-started).
|
|
22
27
|
|
|
23
28
|
# Installation
|
|
24
29
|
|
|
25
30
|
#### npm:
|
|
31
|
+
|
|
26
32
|
```
|
|
27
33
|
npm install @shopware-ag/dive
|
|
28
34
|
```
|
|
29
35
|
|
|
30
36
|
#### yarn:
|
|
37
|
+
|
|
31
38
|
```
|
|
32
39
|
yarn add @shopware-ag/dive
|
|
33
40
|
```
|
|
34
41
|
|
|
35
42
|
#### Setup in Shopware
|
|
43
|
+
|
|
36
44
|
Don't forget to include DIVE in your webpack.config.js:
|
|
45
|
+
|
|
37
46
|
```js
|
|
38
47
|
const path = require('path');
|
|
39
48
|
|
|
@@ -75,7 +84,11 @@ module.exports = () => {
|
|
|
75
84
|
```
|
|
76
85
|
|
|
77
86
|
# Quick View
|
|
78
|
-
|
|
87
|
+
|
|
88
|
+
QuickView is used to quickly display your assets with as few lines of code as
|
|
89
|
+
possible. Simply call the static `QuickView()` method (with your data-uri as a
|
|
90
|
+
parameter) to create an instance of DIVE with your asset to use in further code.
|
|
91
|
+
|
|
79
92
|
```ts
|
|
80
93
|
import { DIVE } from '@shopware-ag/dive';
|
|
81
94
|
|
|
@@ -83,23 +96,27 @@ const dive = DIVE.QuickView('your/asset/uri.glb'); // <-- call QuickView()
|
|
|
83
96
|
|
|
84
97
|
const myCanvasWrapper = document.createElement('div');
|
|
85
98
|
myCanvasWrapper.appendChild(dive.Canvas);
|
|
86
|
-
|
|
87
99
|
```
|
|
88
100
|
|
|
89
101
|
# Getting started
|
|
102
|
+
|
|
90
103
|
Import:
|
|
104
|
+
|
|
91
105
|
```ts
|
|
92
106
|
import { DIVE } from '@shopware-ag/dive'; // <-- import DIVE
|
|
93
107
|
```
|
|
94
108
|
|
|
95
109
|
Instantiate:
|
|
110
|
+
|
|
96
111
|
```ts
|
|
97
112
|
import { DIVE } from '@shopware-ag/dive';
|
|
98
113
|
|
|
99
114
|
const dive = new DIVE(); // <-- instantiate DIVE
|
|
100
115
|
```
|
|
101
116
|
|
|
102
|
-
DIVE supplies your application with a HTMLCanvasElement that it uses as a render
|
|
117
|
+
DIVE supplies your application with a HTMLCanvasElement that it uses as a render
|
|
118
|
+
target. After instantiating, you can use the supplied canvas within you frontend
|
|
119
|
+
code to attach it to your DOM.
|
|
103
120
|
|
|
104
121
|
```ts
|
|
105
122
|
const dive = new DIVE();
|
|
@@ -108,7 +125,9 @@ const myCanvasWrapper = document.createElement('div'); // <-- create wrapper ele
|
|
|
108
125
|
myCanvasWrapper.appendChild(dive.Canvas); // <-- reference DIVE canvas
|
|
109
126
|
```
|
|
110
127
|
|
|
111
|
-
To interact with your newly created DIVE instance you have to perform actions
|
|
128
|
+
To interact with your newly created DIVE instance you have to perform actions
|
|
129
|
+
via DIVECommunication. For further information, see [Actions](#actions).
|
|
130
|
+
|
|
112
131
|
```ts
|
|
113
132
|
const dive = new DIVE();
|
|
114
133
|
|
|
@@ -117,16 +136,21 @@ myCanvasWrapper.appendChild(dive.Canvas);
|
|
|
117
136
|
|
|
118
137
|
const com = dive.Communication; // <-- reference DIVECommunication
|
|
119
138
|
|
|
120
|
-
com.PerformAction('SET_CAMERA_TRANSFORM', {
|
|
139
|
+
com.PerformAction('SET_CAMERA_TRANSFORM', {
|
|
140
|
+
// <-- perform action on DIVECommunication
|
|
121
141
|
position: { x: 0, y: 2, z: 2 },
|
|
122
142
|
target: { x: 0, y: 0.5, z: 0 },
|
|
123
143
|
});
|
|
124
144
|
```
|
|
125
145
|
|
|
126
146
|
# Actions
|
|
127
|
-
Actions symbolize the communication between frontend and 3D space. All actions can be performed anywhere, no matter if you are in frontend or 3D.
|
|
128
147
|
|
|
129
|
-
|
|
148
|
+
Actions symbolize the communication between frontend and 3D space. All actions
|
|
149
|
+
can be performed anywhere, no matter if you are in frontend or 3D.
|
|
150
|
+
|
|
151
|
+
In addition to the impact that specific actions have, every action can be
|
|
152
|
+
subscribed to.
|
|
153
|
+
|
|
130
154
|
```ts
|
|
131
155
|
const myCanvasWrapper = document.createElement('div');
|
|
132
156
|
const dive = new DIVE();
|
|
@@ -135,7 +159,8 @@ myCanvasWrapper.appendChild(dive.Canvas);
|
|
|
135
159
|
|
|
136
160
|
const com = dive.Communication;
|
|
137
161
|
|
|
138
|
-
com.Subscribe('SET_CAMERA_TRANSFORM', () => {
|
|
162
|
+
com.Subscribe('SET_CAMERA_TRANSFORM', () => {
|
|
163
|
+
// <-- add subscription
|
|
139
164
|
// do something
|
|
140
165
|
});
|
|
141
166
|
|
|
@@ -145,7 +170,9 @@ com.PerformAction('SET_CAMERA_TRANSFORM', {
|
|
|
145
170
|
});
|
|
146
171
|
```
|
|
147
172
|
|
|
148
|
-
Subscribing to an action returns a `unsubscribe()`-callback that should be
|
|
173
|
+
Subscribing to an action returns a `unsubscribe()`-callback that should be
|
|
174
|
+
executed when not needed anymore.
|
|
175
|
+
|
|
149
176
|
```ts
|
|
150
177
|
const myCanvasWrapper = document.createElement('div');
|
|
151
178
|
const dive = new DIVE();
|
|
@@ -154,7 +181,8 @@ myCanvasWrapper.appendChild(dive.Canvas);
|
|
|
154
181
|
|
|
155
182
|
const com = dive.Communication;
|
|
156
183
|
|
|
157
|
-
const unsubscribe = com.Subscribe('SET_CAMERA_TRANSFORM', () => {
|
|
184
|
+
const unsubscribe = com.Subscribe('SET_CAMERA_TRANSFORM', () => {
|
|
185
|
+
// <-- save unsubscribe callback
|
|
158
186
|
// do something
|
|
159
187
|
});
|
|
160
188
|
|
|
@@ -167,31 +195,40 @@ unsubscribe(); // <-- execute unsubscribe callback when done
|
|
|
167
195
|
```
|
|
168
196
|
|
|
169
197
|
# Actions (List)
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
|
176
|
-
|
|
|
177
|
-
| [
|
|
178
|
-
| [
|
|
179
|
-
| [
|
|
180
|
-
| [
|
|
181
|
-
| [
|
|
182
|
-
| [
|
|
183
|
-
| [
|
|
184
|
-
| [
|
|
185
|
-
| [
|
|
186
|
-
| [
|
|
187
|
-
| [
|
|
188
|
-
| [
|
|
189
|
-
| [
|
|
190
|
-
| [
|
|
191
|
-
| [
|
|
192
|
-
| [
|
|
193
|
-
| [
|
|
194
|
-
| [
|
|
195
|
-
| [
|
|
196
|
-
| [
|
|
197
|
-
| [
|
|
198
|
+
|
|
199
|
+
In the following you find a list of all available actions to perform on
|
|
200
|
+
DIVECommunication class via
|
|
201
|
+
[`com.PerformAction()`](https://github.com/shopware/dive/blob/2e193c58843939ce07a1d35bfbd5b3c9d26eeeca/src/com/Communication.ts#L85).
|
|
202
|
+
|
|
203
|
+
| Action | Description |
|
|
204
|
+
| :------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------- |
|
|
205
|
+
| [GET_ALL_SCENE_DATA](./src/com/actions/scene/getallscenedata.ts) | Return all scene data that is currently set |
|
|
206
|
+
| [GET_ALL_OBJECTS](./src/com/actions/object/getallobjects.ts) | Return a map of all objects |
|
|
207
|
+
| [GET_OBJECTS](./src/com/actions/object/getobjects.ts) | Return an array of all objects with given ids |
|
|
208
|
+
| [ADD_OBJECT](./src/com/actions/object/addobject.ts) | Add an object to the scene |
|
|
209
|
+
| [UPDATE_OBJECT](./src/com/actions/object/updateobject.ts) | Update an existing object |
|
|
210
|
+
| [DELETE_OBJECT](./src/com/actions/object/deleteobject.ts) | Delete an existing object |
|
|
211
|
+
| [SELECT_OBJECT](./src/com/actions/object/selectobject.ts) | Select an existing object in the scene |
|
|
212
|
+
| [DESELECT_OBJECT](./src/com/actions/object/deselectobject.ts) | Deselect an existing object in the scene |
|
|
213
|
+
| [SET_BACKGROUND](./src/com/actions/scene/setbackground.ts) | Set a background color |
|
|
214
|
+
| [DROP_IT](./src/com/actions/object/model/dropit.ts) | Places the model onto the next underlying object's bounding box |
|
|
215
|
+
| [PLACE_ON_FLOOR](./src/com/actions/object/model/placeonfloor.ts) | Places the model onto the floor (zero plane) |
|
|
216
|
+
| [SET_CAMERA_TRANSFORM](./src/com/actions/camera/setcameratransform.ts) | Set camera transformation (w/o animation, used to initially set up camera) |
|
|
217
|
+
| [GET_CAMERA_TRANSFORM](./src/com/actions/camera/getcameratransform.ts) | Return currenty camera transformation |
|
|
218
|
+
| [MOVE_CAMERA](./src/com/actions/camera/movecamera.ts) | Move camera to a specific position or the position of a previously defined POV (with an animation) |
|
|
219
|
+
| [RESET_CAMERA](./src/com/actions/camera/resetcamera.ts) | Reset camera to original position after MOVE_CAMERA was performed |
|
|
220
|
+
| [COMPUTE_ENCOMPASSING_VIEW](./src/com/actions/camera/computeencompassingview.ts) | Calculates the camera position and target to view the whole scene |
|
|
221
|
+
| [SET_CAMERA_LAYER](./src/com/actions/camera/setcameralayer.ts) | Set camera layer to switch between live view and editor view |
|
|
222
|
+
| [ZOOM_CAMERA](./src/com/actions/camera/zoomcamera.ts) | Zoom in or out |
|
|
223
|
+
| [SET_GIZMO_MODE](./src/com/actions/toolbox/select/setgizmomode.ts) | Set gizmo mode |
|
|
224
|
+
| [SET_GIZMO_VISIBILITY](./src/com/actions/toolbox/select/setgizmovisibility.ts) | Set gizmo visibility |
|
|
225
|
+
| [USE_TOOL](./src/com/actions/toolbox/usetool.ts) | Use a specific tool |
|
|
226
|
+
| [MODEL_LOADED](./src/com/actions/object/model/modelloaded.ts) | Is performed when a model file is completely loaded |
|
|
227
|
+
| [UPDATE_SCENE](./src/com/actions/scene/updatescene.ts) | Update scene data |
|
|
228
|
+
| [GENERATE_MEDIA](./src/com/actions/media/generatemedia.ts) | Generate a screenshot with the specified parameters |
|
|
229
|
+
| [SET_PARENT](./src/com/actions/object/setparent.ts) | Sets an objects parent |
|
|
230
|
+
| [EXPORT_SCENE](./src/com/actions/scene/exportscene.ts) | Exports a scene to a glb, saves it to a blob and returns the associated uri |
|
|
231
|
+
|
|
232
|
+
# Formatter
|
|
233
|
+
|
|
234
|
+
DIVE uses Prettier as a preconfigured formatter.
|