@shopware-ag/dive 1.6.0 → 1.6.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopware-ag/dive",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "description": "Shopware Spatial Framework",
5
5
  "type": "module",
6
6
  "main": "./build/dive.cjs",
@@ -166,6 +166,10 @@ export default class DIVECommunication {
166
166
  returnValue = this.setGizmoVisibility(payload as Actions['SET_GIZMO_VISIBILITY']['PAYLOAD']);
167
167
  break;
168
168
  }
169
+ case 'USE_TOOL': {
170
+ returnValue = this.useTool(payload as Actions['USE_TOOL']['PAYLOAD']);
171
+ break;
172
+ }
169
173
  case 'MODEL_LOADED': {
170
174
  returnValue = this.modelLoaded(payload as Actions['MODEL_LOADED']['PAYLOAD']);
171
175
  break;
@@ -420,6 +424,11 @@ export default class DIVECommunication {
420
424
  return payload;
421
425
  }
422
426
 
427
+ private useTool(payload: Actions['USE_TOOL']['PAYLOAD']): Actions['USE_TOOL']['RETURN'] {
428
+ this.toolbox.UseTool(payload.tool);
429
+ return true;
430
+ }
431
+
423
432
  private modelLoaded(payload: Actions['MODEL_LOADED']['PAYLOAD']): Actions['MODEL_LOADED']['RETURN'] {
424
433
  (this.registered.get(payload.id) as COMModel).loaded = true;
425
434
  return true;
@@ -21,6 +21,7 @@ import GET_CAMERA_TRANSFORM from "./camera/getcameratransform.ts";
21
21
  import DROP_IT from "./object/model/dropit.ts";
22
22
  import SET_GIZMO_VISIBILITY from "./toolbox/transform/setgizmovisible.js";
23
23
  import COMPUTE_ENCOMPASSING_VIEW from "./camera/computeencompassingview.ts";
24
+ import USE_TOOL from "./toolbox/usetool.ts";
24
25
 
25
26
  export type Actions = {
26
27
  GET_ALL_SCENE_DATA: GET_ALL_SCENE_DATA,
@@ -43,6 +44,7 @@ export type Actions = {
43
44
  ZOOM_CAMERA: ZOOM_CAMERA,
44
45
  SET_GIZMO_MODE: SET_GIZMO_MODE,
45
46
  SET_GIZMO_VISIBILITY: SET_GIZMO_VISIBILITY,
47
+ USE_TOOL: USE_TOOL,
46
48
  MODEL_LOADED: MODEL_LOADED,
47
49
  UPDATE_SCENE: UPDATE_SCENE,
48
50
  GENERATE_MEDIA: GENERATE_MEDIA,
@@ -0,0 +1,6 @@
1
+ import { type ToolType } from "../../../toolbox/Toolbox";
2
+
3
+ export default interface USE_TOOL {
4
+ 'PAYLOAD': { tool: ToolType },
5
+ 'RETURN': boolean,
6
+ }
@@ -97,7 +97,7 @@ export default class DIVEModel extends Object3D implements DIVESelectable, DIVEM
97
97
  const worldPos = mesh.localToWorld(meshBB.max.clone());
98
98
 
99
99
  const oldPos = this.position.clone();
100
- const newPos = this.position.clone().setY(worldPos.y).add(new Vector3(0, bottomY, 0));
100
+ const newPos = this.position.clone().setY(worldPos.y).sub(new Vector3(0, bottomY, 0));
101
101
  this.position.copy(newPos);
102
102
 
103
103
  // if the position changed, update the object in communication
@@ -43,6 +43,12 @@ jest.mock('three', () => {
43
43
  this.z += vec3.z;
44
44
  return this;
45
45
  };
46
+ this.sub = (vec3: Vector3) => {
47
+ this.x -= vec3.x;
48
+ this.y -= vec3.y;
49
+ this.z -= vec3.z;
50
+ return this;
51
+ };
46
52
  return this;
47
53
  }),
48
54
  Object3D: jest.fn(function () {
@@ -63,6 +69,7 @@ jest.mock('three', () => {
63
69
  },
64
70
  }
65
71
  this.add = jest.fn();
72
+ this.sub = jest.fn();
66
73
  this.children = [{
67
74
  visible: true,
68
75
  material: {
@@ -278,7 +285,7 @@ describe('dive/model/DIVEModel', () => {
278
285
  model.parent = scene.Root;
279
286
 
280
287
  expect(() => model.DropIt()).not.toThrow();
281
- expect(model.position.y).toBe(1.5);
288
+ expect(model.position.y).toBe(2.5);
282
289
  expect(comMock.PerformAction).toHaveBeenCalledTimes(1);
283
290
 
284
291
  expect(() => model.DropIt()).not.toThrow();