@shopware-ag/dive 1.17.2 → 1.18.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.
Files changed (40) hide show
  1. package/README.md +56 -22
  2. package/build/dive.cjs +11 -7
  3. package/build/dive.cjs.map +1 -1
  4. package/build/dive.d.cts +3 -4
  5. package/build/dive.d.ts +3 -4
  6. package/build/dive.js +9 -5
  7. package/build/dive.js.map +1 -1
  8. package/package.json +1 -1
  9. package/src/__test__/DIVE.test.ts +0 -40
  10. package/src/animation/__test__/AnimationSystem.test.ts +0 -7
  11. package/src/ar/arquicklook/__test__/ARQuickLook.test.ts +0 -140
  12. package/src/ar/sceneviewer/__test__/SceneViewer.test.ts +0 -140
  13. package/src/axiscamera/__test__/AxisCamera.test.ts +0 -76
  14. package/src/com/__test__/Communication.test.ts +0 -6
  15. package/src/controls/__test__/OrbitControls.test.ts +0 -87
  16. package/src/dive.ts +3 -3
  17. package/src/exporters/usdz/__test__/USDZExporter.test.ts +57 -0
  18. package/src/group/Group.ts +6 -1
  19. package/src/group/__test__/Group.test.ts +6 -3
  20. package/src/io/gltf/__test__/GLTFIO.test.ts +0 -77
  21. package/src/light/PointLight.ts +1 -1
  22. package/src/light/__test__/AmbientLight.test.ts +0 -24
  23. package/src/light/__test__/PointLight.test.ts +0 -61
  24. package/src/light/__test__/SceneLight.test.ts +0 -89
  25. package/src/loadingmanager/LoadingManager.ts +2 -1
  26. package/src/loadingmanager/__test__/LoadingManager.test.ts +0 -30
  27. package/src/math/degToRad/__test__/degToRad.test.ts +0 -7
  28. package/src/math/radToDeg/__test__/radToDeg.test.ts +0 -7
  29. package/src/model/Model.ts +1 -1
  30. package/src/model/__test__/Model.test.ts +5 -155
  31. package/src/node/__test__/Node.test.ts +0 -149
  32. package/src/primitive/__test__/Primitive.test.ts +6 -199
  33. package/src/primitive/floor/__test__/Floor.test.ts +0 -3
  34. package/src/renderer/__test__/Renderer.test.ts +16 -46
  35. package/src/scene/__test__/Scene.test.ts +6 -16
  36. package/src/scene/root/Root.ts +4 -4
  37. package/src/scene/root/__test__/Root.test.ts +6 -188
  38. package/src/toolbox/__test__/BaseTool.test.ts +34 -38
  39. package/src/toolbox/select/__test__/SelectTool.test.ts +16 -89
  40. package/src/toolbox/transform/__test__/TransformTool.test.ts +14 -82
package/README.md CHANGED
@@ -47,10 +47,6 @@ npm install @shopware-ag/dive
47
47
  yarn add @shopware-ag/dive
48
48
  ```
49
49
 
50
- # Formatter
51
-
52
- DIVE uses Prettier as a preconfigured formatter.
53
-
54
50
  #### Setup in Shopware
55
51
 
56
52
  Don't forget to include DIVE in your webpack.config.js:
@@ -60,24 +56,33 @@ const path = require('path');
60
56
 
61
57
  module.exports = () => {
62
58
  return {
63
- ...
59
+ // Other configurations...
64
60
  resolve: {
65
- extensions: ['.ts', '.cjs', '.js'],
61
+ extensions: [
62
+ '.ts',
63
+ '.cjs',
64
+ '.js',
65
+ ],
66
66
  alias: {
67
67
  three: path.resolve(__dirname, 'path/to/node_modules/three'),
68
- "@shopware-ag/dive": path.resolve(__dirname, 'path/to/node_modules/@shopware-ag/dive'),
69
- }
68
+ '@shopware-ag/dive': path.resolve(
69
+ __dirname,
70
+ 'path/to/node_modules/@shopware-ag/dive',
71
+ ),
72
+ },
70
73
  },
71
- ...
72
74
  module: {
73
75
  rules: [
74
- ...
76
+ // Other rules...
75
77
  {
76
78
  test: /\.(js|ts)$/,
77
79
  loader: 'swc-loader',
78
80
  include: [
79
81
  path.resolve(__dirname, 'path/to/node_modules/three'),
80
- path.resolve(__dirname, 'path/to/node_modules/@shopware-ag/dive')
82
+ path.resolve(
83
+ __dirname,
84
+ 'path/to/node_modules/@shopware-ag/dive',
85
+ ),
81
86
  ],
82
87
  options: {
83
88
  jsc: {
@@ -88,18 +93,20 @@ module.exports = () => {
88
93
  },
89
94
  },
90
95
  },
91
- ...
96
+ // Other rules...
92
97
  ],
93
- }
98
+ },
94
99
  };
95
100
  };
96
101
  ```
97
102
 
98
- # Quick View
103
+ # Usage
104
+
105
+ ## Quick View
99
106
 
100
107
  QuickView is used to quickly display your assets with as few lines of code as
101
- possible. Simply call the static `QuickView()` method (with your data-uri as a
102
- parameter) to create an instance of DIVE with your asset to use in further code.
108
+ possible. Simply call the static `QuickView()` method, with your data URI as a
109
+ parameter, to create an instance of DIVE with your asset to use in further code.
103
110
 
104
111
  ```ts
105
112
  import { DIVE } from '@shopware-ag/dive';
@@ -110,15 +117,30 @@ const myCanvasWrapper = document.createElement('div');
110
117
  myCanvasWrapper.appendChild(dive.Canvas);
111
118
  ```
112
119
 
113
- # Getting started
120
+ ### Example with Error Handling:
121
+
122
+ ```ts
123
+ import { DIVE } from '@shopware-ag/dive';
124
+
125
+ try {
126
+ const dive = DIVE.QuickView('your/asset/uri.glb'); // <-- call QuickView()
127
+
128
+ const myCanvasWrapper = document.createElement('div');
129
+ myCanvasWrapper.appendChild(dive.Canvas);
130
+ } catch (error) {
131
+ console.error('Failed to load asset:', error);
132
+ }
133
+ ```
134
+
135
+ ## Getting started
114
136
 
115
- Import:
137
+ ### Import:
116
138
 
117
139
  ```ts
118
140
  import { DIVE } from '@shopware-ag/dive'; // <-- import DIVE
119
141
  ```
120
142
 
121
- Instantiate:
143
+ ### Instantiate:
122
144
 
123
145
  ```ts
124
146
  import { DIVE } from '@shopware-ag/dive';
@@ -127,7 +149,7 @@ const dive = new DIVE(); // <-- instantiate DIVE
127
149
  ```
128
150
 
129
151
  DIVE supplies your application with a HTMLCanvasElement that it uses as a render
130
- target. After instantiating, you can use the supplied canvas within you frontend
152
+ target. After instantiating, you can use the supplied canvas within your frontend
131
153
  code to attach it to your DOM.
132
154
 
133
155
  ```ts
@@ -155,7 +177,7 @@ com.PerformAction('SET_CAMERA_TRANSFORM', {
155
177
  });
156
178
  ```
157
179
 
158
- # Actions
180
+ ## Actions
159
181
 
160
182
  Actions symbolize the communication between frontend and 3D space. All actions
161
183
  can be performed anywhere, no matter if you are in frontend or 3D.
@@ -206,7 +228,7 @@ com.PerformAction('SET_CAMERA_TRANSFORM', {
206
228
  unsubscribe(); // <-- execute unsubscribe callback when done
207
229
  ```
208
230
 
209
- # Actions (List)
231
+ ### Actions List
210
232
 
211
233
  In the following you find a list of all available actions to perform on
212
234
  DIVECommunication class via
@@ -434,3 +456,15 @@ DIVECommunication class via
434
456
  </td>
435
457
  </tr>
436
458
  </table>
459
+
460
+ # Unit Tests
461
+
462
+ 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.
463
+
464
+ 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.
465
+
466
+ 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.
467
+
468
+ # Formatting
469
+
470
+ DIVE uses Prettier as a preconfigured formatter.
package/build/dive.cjs CHANGED
@@ -3092,13 +3092,14 @@ var DIVEModel = class extends DIVENode {
3092
3092
  };
3093
3093
 
3094
3094
  // src/loadingmanager/LoadingManager.ts
3095
- var import_Addons = require("three/examples/jsm/Addons.js");
3095
+ var import_DRACOLoader = require("three/examples/jsm/loaders/DRACOLoader");
3096
+ var import_GLTFLoader2 = require("three/examples/jsm/loaders/GLTFLoader");
3096
3097
  var DIVELoadingManager = class {
3097
3098
  // ... maybe extend with other loaders later
3098
3099
  constructor() {
3099
3100
  this.progress = /* @__PURE__ */ new Map();
3100
- this.gltfloader = new import_Addons.GLTFLoader();
3101
- this.dracoloader = new import_Addons.DRACOLoader();
3101
+ this.gltfloader = new import_GLTFLoader2.GLTFLoader();
3102
+ this.dracoloader = new import_DRACOLoader.DRACOLoader();
3102
3103
  this.dracoloader.setDecoderPath(
3103
3104
  "https://www.gstatic.com/draco/v1/decoders/"
3104
3105
  );
@@ -3394,6 +3395,9 @@ var DIVEGroup = class extends DIVENode {
3394
3395
  this._lines[index].visible = visible;
3395
3396
  }
3396
3397
  attach(object) {
3398
+ if (this._members.includes(object)) {
3399
+ return this;
3400
+ }
3397
3401
  const line = this.createLine();
3398
3402
  this.add(line);
3399
3403
  this._lines.push(line);
@@ -4428,13 +4432,13 @@ var getObjectDelta = (a, b) => {
4428
4432
  };
4429
4433
 
4430
4434
  // src/dive.ts
4431
- var import_MathUtils2 = require("three/src/math/MathUtils");
4435
+ var import_three28 = require("three");
4432
4436
  init_Info();
4433
4437
 
4434
4438
  // package.json
4435
4439
  var package_default = {
4436
4440
  name: "@shopware-ag/dive",
4437
- version: "1.17.2",
4441
+ version: "1.18.0",
4438
4442
  description: "Shopware Spatial Framework",
4439
4443
  type: "module",
4440
4444
  main: "./build/dive.cjs",
@@ -4594,7 +4598,7 @@ var DIVE = class _DIVE {
4594
4598
  position: { x: 0, y: 2, z: 2 },
4595
4599
  target: { x: 0, y: 0.5, z: 0 }
4596
4600
  });
4597
- const lightid = (0, import_MathUtils2.generateUUID)();
4601
+ const lightid = import_three28.MathUtils.generateUUID();
4598
4602
  dive.Communication.PerformAction("ADD_OBJECT", {
4599
4603
  entityType: "light",
4600
4604
  type: "scene",
@@ -4605,7 +4609,7 @@ var DIVE = class _DIVE {
4605
4609
  intensity: 1,
4606
4610
  color: 16777215
4607
4611
  });
4608
- const modelid = (0, import_MathUtils2.generateUUID)();
4612
+ const modelid = import_three28.MathUtils.generateUUID();
4609
4613
  dive.Communication.Subscribe("MODEL_LOADED", (data) => {
4610
4614
  if (data.id !== modelid) return;
4611
4615
  const transform = dive.Communication.PerformAction(