@shopware-ag/dive 1.17.1 → 1.17.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/build/dive.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { ShadowMapType, ToneMapping, WebGLRenderer, Scene, Camera, PerspectiveCamera, Box3, Vector3Like, Texture, Object3D, Vector3, Color, Mesh, ColorRepresentation, Intersection, Vector2, Raycaster } from 'three';
1
+ import { ShadowMapType, ToneMapping, WebGLRenderer, Scene, Camera, PerspectiveCamera, Box3, Vector3Like, Texture, Object3D, Vector3, Color, Mesh, ColorRepresentation, Intersection, Vector2, Raycaster, Euler } from 'three';
2
2
  import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
3
3
  import { Tween } from '@tweenjs/tween.js';
4
4
  import { TransformControls } from 'three/examples/jsm/controls/TransformControls';
@@ -802,6 +802,41 @@ declare abstract class DIVEBaseTool {
802
802
  private pointerWasDragged;
803
803
  }
804
804
 
805
+ declare class DIVEGizmoPlane extends Object3D {
806
+ private _meshX;
807
+ get XPlane(): Mesh;
808
+ private _meshY;
809
+ get YPlane(): Mesh;
810
+ private _meshZ;
811
+ get ZPlane(): Mesh;
812
+ constructor();
813
+ assemble(mode: DIVEGizmoMode, axis: DIVEGizmoAxis): void;
814
+ }
815
+
816
+ type DIVEGizmoMode = 'translate' | 'rotate' | 'scale';
817
+ type DIVEGizmoAxis = 'x' | 'y' | 'z';
818
+ declare class DIVEGizmo extends Object3D {
819
+ private _mode;
820
+ get mode(): DIVEGizmoMode;
821
+ set mode(value: DIVEGizmoMode);
822
+ set debug(value: boolean);
823
+ private _gizmoNode;
824
+ get gizmoNode(): Object3D;
825
+ private _translateGizmo;
826
+ private _rotateGizmo;
827
+ private _scaleGizmo;
828
+ private _gizmoPlane;
829
+ get gizmoPlane(): DIVEGizmoPlane;
830
+ private _object;
831
+ get object(): (Object3D & DIVESelectable) | null;
832
+ constructor(controller: DIVEOrbitControls);
833
+ attach(object: Object3D & DIVESelectable): this;
834
+ detach(): this;
835
+ onHover(mode: DIVEGizmoMode, axis: DIVEGizmoAxis, value: boolean): void;
836
+ onChange(position?: Vector3, rotation?: Euler, scale?: Vector3): void;
837
+ private assemble;
838
+ }
839
+
805
840
  /**
806
841
  * A Tool to select and move objects in the scene.
807
842
  *
@@ -811,11 +846,12 @@ declare abstract class DIVEBaseTool {
811
846
  */
812
847
  declare class DIVETransformTool extends DIVEBaseTool {
813
848
  readonly isTransformTool: boolean;
814
- protected _gizmo: TransformControls;
849
+ protected _gizmo: TransformControls | DIVEGizmo;
815
850
  constructor(scene: DIVEScene, controller: DIVEOrbitControls);
816
851
  Activate(): void;
817
852
  SetGizmoMode(mode: 'translate' | 'rotate' | 'scale'): void;
818
853
  SetGizmoVisibility(active: boolean): void;
854
+ private initGizmo;
819
855
  }
820
856
 
821
857
  /**
package/build/dive.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ShadowMapType, ToneMapping, WebGLRenderer, Scene, Camera, PerspectiveCamera, Box3, Vector3Like, Texture, Object3D, Vector3, Color, Mesh, ColorRepresentation, Intersection, Vector2, Raycaster } from 'three';
1
+ import { ShadowMapType, ToneMapping, WebGLRenderer, Scene, Camera, PerspectiveCamera, Box3, Vector3Like, Texture, Object3D, Vector3, Color, Mesh, ColorRepresentation, Intersection, Vector2, Raycaster, Euler } from 'three';
2
2
  import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
3
3
  import { Tween } from '@tweenjs/tween.js';
4
4
  import { TransformControls } from 'three/examples/jsm/controls/TransformControls';
@@ -802,6 +802,41 @@ declare abstract class DIVEBaseTool {
802
802
  private pointerWasDragged;
803
803
  }
804
804
 
805
+ declare class DIVEGizmoPlane extends Object3D {
806
+ private _meshX;
807
+ get XPlane(): Mesh;
808
+ private _meshY;
809
+ get YPlane(): Mesh;
810
+ private _meshZ;
811
+ get ZPlane(): Mesh;
812
+ constructor();
813
+ assemble(mode: DIVEGizmoMode, axis: DIVEGizmoAxis): void;
814
+ }
815
+
816
+ type DIVEGizmoMode = 'translate' | 'rotate' | 'scale';
817
+ type DIVEGizmoAxis = 'x' | 'y' | 'z';
818
+ declare class DIVEGizmo extends Object3D {
819
+ private _mode;
820
+ get mode(): DIVEGizmoMode;
821
+ set mode(value: DIVEGizmoMode);
822
+ set debug(value: boolean);
823
+ private _gizmoNode;
824
+ get gizmoNode(): Object3D;
825
+ private _translateGizmo;
826
+ private _rotateGizmo;
827
+ private _scaleGizmo;
828
+ private _gizmoPlane;
829
+ get gizmoPlane(): DIVEGizmoPlane;
830
+ private _object;
831
+ get object(): (Object3D & DIVESelectable) | null;
832
+ constructor(controller: DIVEOrbitControls);
833
+ attach(object: Object3D & DIVESelectable): this;
834
+ detach(): this;
835
+ onHover(mode: DIVEGizmoMode, axis: DIVEGizmoAxis, value: boolean): void;
836
+ onChange(position?: Vector3, rotation?: Euler, scale?: Vector3): void;
837
+ private assemble;
838
+ }
839
+
805
840
  /**
806
841
  * A Tool to select and move objects in the scene.
807
842
  *
@@ -811,11 +846,12 @@ declare abstract class DIVEBaseTool {
811
846
  */
812
847
  declare class DIVETransformTool extends DIVEBaseTool {
813
848
  readonly isTransformTool: boolean;
814
- protected _gizmo: TransformControls;
849
+ protected _gizmo: TransformControls | DIVEGizmo;
815
850
  constructor(scene: DIVEScene, controller: DIVEOrbitControls);
816
851
  Activate(): void;
817
852
  SetGizmoMode(mode: 'translate' | 'rotate' | 'scale'): void;
818
853
  SetGizmoVisibility(active: boolean): void;
854
+ private initGizmo;
819
855
  }
820
856
 
821
857
  /**
package/build/dive.js CHANGED
@@ -330,40 +330,7 @@ var init_TransformTool = __esm({
330
330
  super(scene, controller);
331
331
  this.isTransformTool = true;
332
332
  this.name = "DIVETransformTool";
333
- this._gizmo = new TransformControls(
334
- this._controller.object,
335
- this._controller.domElement
336
- );
337
- this._gizmo.mode = "translate";
338
- this._gizmo.addEventListener("mouseDown", () => {
339
- controller.enabled = false;
340
- if (!implementsInterface(
341
- this._gizmo.object,
342
- "isMovable"
343
- ))
344
- return;
345
- if (!this._gizmo.object.onMoveStart) return;
346
- this._gizmo.object.onMoveStart();
347
- });
348
- this._gizmo.addEventListener("objectChange", () => {
349
- if (!implementsInterface(
350
- this._gizmo.object,
351
- "isMovable"
352
- ))
353
- return;
354
- if (!this._gizmo.object.onMove) return;
355
- this._gizmo.object.onMove();
356
- });
357
- this._gizmo.addEventListener("mouseUp", () => {
358
- controller.enabled = true;
359
- if (!implementsInterface(
360
- this._gizmo.object,
361
- "isMovable"
362
- ))
363
- return;
364
- if (!this._gizmo.object.onMoveEnd) return;
365
- this._gizmo.object.onMoveEnd();
366
- });
333
+ this._gizmo = this.initGizmo();
367
334
  this._scene.add(this._gizmo);
368
335
  }
369
336
  Activate() {
@@ -375,19 +342,58 @@ var init_TransformTool = __esm({
375
342
  const contains = this._scene.children.includes(this._gizmo);
376
343
  if (active && !contains) {
377
344
  this._scene.add(this._gizmo);
345
+ if ("isTransformControls" in this._gizmo) {
346
+ this._gizmo.getRaycaster().layers.enableAll();
347
+ }
378
348
  } else if (!active && contains) {
379
349
  this._scene.remove(this._gizmo);
350
+ if ("isTransformControls" in this._gizmo) {
351
+ this._gizmo.getRaycaster().layers.disableAll();
352
+ }
380
353
  }
381
354
  }
355
+ // only used for optimizing pointer events with DIVEGizmo
382
356
  // public onPointerDown(e: PointerEvent): void {
383
357
  // super.onPointerDown(e);
384
- // // if (this._hovered) {
385
- // // this._dragRaycastOnObjects = this._gizmo.gizmoPlane.children;
386
- // // }
358
+ // if (this._hovered) {
359
+ // this._dragRaycastOnObjects = (
360
+ // this._gizmo as DIVEGizmo
361
+ // ).gizmoPlane?.children;
362
+ // }
387
363
  // }
364
+ // only used for optimizing pointer events with DIVEGizmo
388
365
  // protected raycast(): Intersection[] {
389
- // return super.raycast(this._gizmo.gizmoNode.children);
366
+ // return super.raycast((this._gizmo as DIVEGizmo).gizmoNode.children);
390
367
  // }
368
+ initGizmo() {
369
+ const g = new TransformControls(
370
+ // this._controller,
371
+ this._controller.object,
372
+ this._controller.domElement
373
+ );
374
+ g.mode = "translate";
375
+ g.addEventListener("mouseDown", () => {
376
+ this._controller.enabled = false;
377
+ if (!implementsInterface(g.object, "isMovable"))
378
+ return;
379
+ if (!g.object.onMoveStart) return;
380
+ g.object.onMoveStart();
381
+ });
382
+ g.addEventListener("objectChange", () => {
383
+ if (!implementsInterface(g.object, "isMovable"))
384
+ return;
385
+ if (!g.object.onMove) return;
386
+ g.object.onMove();
387
+ });
388
+ g.addEventListener("mouseUp", () => {
389
+ this._controller.enabled = true;
390
+ if (!implementsInterface(g.object, "isMovable"))
391
+ return;
392
+ if (!g.object.onMoveEnd) return;
393
+ g.object.onMoveEnd();
394
+ });
395
+ return g;
396
+ }
391
397
  };
392
398
  }
393
399
  });
@@ -4459,7 +4465,7 @@ import { generateUUID as generateUUID2 } from "three/src/math/MathUtils";
4459
4465
  // package.json
4460
4466
  var package_default = {
4461
4467
  name: "@shopware-ag/dive",
4462
- version: "1.17.1",
4468
+ version: "1.17.2",
4463
4469
  description: "Shopware Spatial Framework",
4464
4470
  type: "module",
4465
4471
  main: "./build/dive.cjs",
@@ -4503,6 +4509,7 @@ var package_default = {
4503
4509
  globals: "^15.0.0",
4504
4510
  jest: "^29.7.0",
4505
4511
  "jest-environment-jsdom": "^29.7.0",
4512
+ "jest-junit": "^16.0.0",
4506
4513
  jsdom: "^24.0.0",
4507
4514
  prettier: "^3.3.3",
4508
4515
  "prettier-plugin-multiline-arrays": "^3.0.6",