@shopware-ag/dive 1.17.1 → 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.
- package/README.md +56 -22
- package/build/dive.cjs +56 -45
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.cts +41 -6
- package/build/dive.d.ts +41 -6
- package/build/dive.js +54 -43
- package/build/dive.js.map +1 -1
- package/package.json +2 -1
- package/src/__test__/DIVE.test.ts +0 -40
- package/src/animation/__test__/AnimationSystem.test.ts +0 -7
- package/src/ar/arquicklook/__test__/ARQuickLook.test.ts +0 -140
- package/src/ar/sceneviewer/__test__/SceneViewer.test.ts +0 -140
- package/src/axiscamera/__test__/AxisCamera.test.ts +0 -76
- package/src/com/__test__/Communication.test.ts +0 -6
- package/src/controls/__test__/OrbitControls.test.ts +0 -87
- package/src/dive.ts +3 -3
- package/src/exporters/usdz/__test__/USDZExporter.test.ts +57 -0
- package/src/gizmo/Gizmo.ts +6 -0
- package/src/gizmo/handles/AxisHandle.ts +14 -8
- package/src/gizmo/handles/RadialHandle.ts +12 -6
- package/src/gizmo/handles/ScaleHandle.ts +14 -8
- package/src/gizmo/rotate/RotateGizmo.ts +6 -0
- package/src/gizmo/scale/ScaleGizmo.ts +6 -0
- package/src/gizmo/translate/TranslateGizmo.ts +6 -0
- package/src/group/Group.ts +6 -1
- package/src/group/__test__/Group.test.ts +6 -3
- package/src/io/gltf/__test__/GLTFIO.test.ts +0 -77
- package/src/light/PointLight.ts +1 -1
- package/src/light/__test__/AmbientLight.test.ts +0 -24
- package/src/light/__test__/PointLight.test.ts +0 -61
- package/src/light/__test__/SceneLight.test.ts +0 -89
- package/src/loadingmanager/LoadingManager.ts +2 -1
- package/src/loadingmanager/__test__/LoadingManager.test.ts +0 -30
- package/src/math/degToRad/__test__/degToRad.test.ts +0 -7
- package/src/math/radToDeg/__test__/radToDeg.test.ts +0 -7
- package/src/model/Model.ts +1 -1
- package/src/model/__test__/Model.test.ts +5 -155
- package/src/node/__test__/Node.test.ts +0 -149
- package/src/primitive/__test__/Primitive.test.ts +6 -199
- package/src/primitive/floor/__test__/Floor.test.ts +0 -3
- package/src/renderer/__test__/Renderer.test.ts +16 -46
- package/src/scene/__test__/Scene.test.ts +6 -16
- package/src/scene/root/Root.ts +4 -4
- package/src/scene/root/__test__/Root.test.ts +6 -188
- package/src/toolbox/__test__/BaseTool.test.ts +34 -38
- package/src/toolbox/select/__test__/SelectTool.test.ts +21 -89
- package/src/toolbox/transform/TransformTool.ts +61 -53
- package/src/toolbox/transform/__test__/TransformTool.test.ts +14 -80
package/build/dive.d.cts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
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';
|
|
5
|
-
import {
|
|
6
|
-
import { GLTF as GLTF$1 } from 'three/examples/jsm/loaders/GLTFLoader';
|
|
5
|
+
import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader';
|
|
7
6
|
|
|
8
7
|
type DIVERendererSettings = {
|
|
9
8
|
antialias: boolean;
|
|
@@ -451,7 +450,7 @@ declare class DIVEPointLight extends Object3D implements DIVESelectable, DIVEMov
|
|
|
451
450
|
readonly isDIVEPointLight: true;
|
|
452
451
|
readonly isMovable: true;
|
|
453
452
|
readonly isSelectable: true;
|
|
454
|
-
gizmo: TransformControls
|
|
453
|
+
gizmo: TransformControls | null;
|
|
455
454
|
private light;
|
|
456
455
|
private mesh;
|
|
457
456
|
constructor();
|
|
@@ -530,7 +529,7 @@ declare class DIVEPrimitive extends DIVENode {
|
|
|
530
529
|
type DIVESceneObject = DIVEModel | DIVEGroup | DIVEPrimitive | DIVEAmbientLight | DIVEPointLight | DIVESceneLight;
|
|
531
530
|
|
|
532
531
|
type DIVESceneFileType = {
|
|
533
|
-
glb: GLTF
|
|
532
|
+
glb: GLTF;
|
|
534
533
|
};
|
|
535
534
|
|
|
536
535
|
type DIVESceneData = {
|
|
@@ -802,6 +801,41 @@ declare abstract class DIVEBaseTool {
|
|
|
802
801
|
private pointerWasDragged;
|
|
803
802
|
}
|
|
804
803
|
|
|
804
|
+
declare class DIVEGizmoPlane extends Object3D {
|
|
805
|
+
private _meshX;
|
|
806
|
+
get XPlane(): Mesh;
|
|
807
|
+
private _meshY;
|
|
808
|
+
get YPlane(): Mesh;
|
|
809
|
+
private _meshZ;
|
|
810
|
+
get ZPlane(): Mesh;
|
|
811
|
+
constructor();
|
|
812
|
+
assemble(mode: DIVEGizmoMode, axis: DIVEGizmoAxis): void;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
type DIVEGizmoMode = 'translate' | 'rotate' | 'scale';
|
|
816
|
+
type DIVEGizmoAxis = 'x' | 'y' | 'z';
|
|
817
|
+
declare class DIVEGizmo extends Object3D {
|
|
818
|
+
private _mode;
|
|
819
|
+
get mode(): DIVEGizmoMode;
|
|
820
|
+
set mode(value: DIVEGizmoMode);
|
|
821
|
+
set debug(value: boolean);
|
|
822
|
+
private _gizmoNode;
|
|
823
|
+
get gizmoNode(): Object3D;
|
|
824
|
+
private _translateGizmo;
|
|
825
|
+
private _rotateGizmo;
|
|
826
|
+
private _scaleGizmo;
|
|
827
|
+
private _gizmoPlane;
|
|
828
|
+
get gizmoPlane(): DIVEGizmoPlane;
|
|
829
|
+
private _object;
|
|
830
|
+
get object(): (Object3D & DIVESelectable) | null;
|
|
831
|
+
constructor(controller: DIVEOrbitControls);
|
|
832
|
+
attach(object: Object3D & DIVESelectable): this;
|
|
833
|
+
detach(): this;
|
|
834
|
+
onHover(mode: DIVEGizmoMode, axis: DIVEGizmoAxis, value: boolean): void;
|
|
835
|
+
onChange(position?: Vector3, rotation?: Euler, scale?: Vector3): void;
|
|
836
|
+
private assemble;
|
|
837
|
+
}
|
|
838
|
+
|
|
805
839
|
/**
|
|
806
840
|
* A Tool to select and move objects in the scene.
|
|
807
841
|
*
|
|
@@ -811,11 +845,12 @@ declare abstract class DIVEBaseTool {
|
|
|
811
845
|
*/
|
|
812
846
|
declare class DIVETransformTool extends DIVEBaseTool {
|
|
813
847
|
readonly isTransformTool: boolean;
|
|
814
|
-
protected _gizmo: TransformControls;
|
|
848
|
+
protected _gizmo: TransformControls | DIVEGizmo;
|
|
815
849
|
constructor(scene: DIVEScene, controller: DIVEOrbitControls);
|
|
816
850
|
Activate(): void;
|
|
817
851
|
SetGizmoMode(mode: 'translate' | 'rotate' | 'scale'): void;
|
|
818
852
|
SetGizmoVisibility(active: boolean): void;
|
|
853
|
+
private initGizmo;
|
|
819
854
|
}
|
|
820
855
|
|
|
821
856
|
/**
|
package/build/dive.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
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';
|
|
5
|
-
import {
|
|
6
|
-
import { GLTF as GLTF$1 } from 'three/examples/jsm/loaders/GLTFLoader';
|
|
5
|
+
import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader';
|
|
7
6
|
|
|
8
7
|
type DIVERendererSettings = {
|
|
9
8
|
antialias: boolean;
|
|
@@ -451,7 +450,7 @@ declare class DIVEPointLight extends Object3D implements DIVESelectable, DIVEMov
|
|
|
451
450
|
readonly isDIVEPointLight: true;
|
|
452
451
|
readonly isMovable: true;
|
|
453
452
|
readonly isSelectable: true;
|
|
454
|
-
gizmo: TransformControls
|
|
453
|
+
gizmo: TransformControls | null;
|
|
455
454
|
private light;
|
|
456
455
|
private mesh;
|
|
457
456
|
constructor();
|
|
@@ -530,7 +529,7 @@ declare class DIVEPrimitive extends DIVENode {
|
|
|
530
529
|
type DIVESceneObject = DIVEModel | DIVEGroup | DIVEPrimitive | DIVEAmbientLight | DIVEPointLight | DIVESceneLight;
|
|
531
530
|
|
|
532
531
|
type DIVESceneFileType = {
|
|
533
|
-
glb: GLTF
|
|
532
|
+
glb: GLTF;
|
|
534
533
|
};
|
|
535
534
|
|
|
536
535
|
type DIVESceneData = {
|
|
@@ -802,6 +801,41 @@ declare abstract class DIVEBaseTool {
|
|
|
802
801
|
private pointerWasDragged;
|
|
803
802
|
}
|
|
804
803
|
|
|
804
|
+
declare class DIVEGizmoPlane extends Object3D {
|
|
805
|
+
private _meshX;
|
|
806
|
+
get XPlane(): Mesh;
|
|
807
|
+
private _meshY;
|
|
808
|
+
get YPlane(): Mesh;
|
|
809
|
+
private _meshZ;
|
|
810
|
+
get ZPlane(): Mesh;
|
|
811
|
+
constructor();
|
|
812
|
+
assemble(mode: DIVEGizmoMode, axis: DIVEGizmoAxis): void;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
type DIVEGizmoMode = 'translate' | 'rotate' | 'scale';
|
|
816
|
+
type DIVEGizmoAxis = 'x' | 'y' | 'z';
|
|
817
|
+
declare class DIVEGizmo extends Object3D {
|
|
818
|
+
private _mode;
|
|
819
|
+
get mode(): DIVEGizmoMode;
|
|
820
|
+
set mode(value: DIVEGizmoMode);
|
|
821
|
+
set debug(value: boolean);
|
|
822
|
+
private _gizmoNode;
|
|
823
|
+
get gizmoNode(): Object3D;
|
|
824
|
+
private _translateGizmo;
|
|
825
|
+
private _rotateGizmo;
|
|
826
|
+
private _scaleGizmo;
|
|
827
|
+
private _gizmoPlane;
|
|
828
|
+
get gizmoPlane(): DIVEGizmoPlane;
|
|
829
|
+
private _object;
|
|
830
|
+
get object(): (Object3D & DIVESelectable) | null;
|
|
831
|
+
constructor(controller: DIVEOrbitControls);
|
|
832
|
+
attach(object: Object3D & DIVESelectable): this;
|
|
833
|
+
detach(): this;
|
|
834
|
+
onHover(mode: DIVEGizmoMode, axis: DIVEGizmoAxis, value: boolean): void;
|
|
835
|
+
onChange(position?: Vector3, rotation?: Euler, scale?: Vector3): void;
|
|
836
|
+
private assemble;
|
|
837
|
+
}
|
|
838
|
+
|
|
805
839
|
/**
|
|
806
840
|
* A Tool to select and move objects in the scene.
|
|
807
841
|
*
|
|
@@ -811,11 +845,12 @@ declare abstract class DIVEBaseTool {
|
|
|
811
845
|
*/
|
|
812
846
|
declare class DIVETransformTool extends DIVEBaseTool {
|
|
813
847
|
readonly isTransformTool: boolean;
|
|
814
|
-
protected _gizmo: TransformControls;
|
|
848
|
+
protected _gizmo: TransformControls | DIVEGizmo;
|
|
815
849
|
constructor(scene: DIVEScene, controller: DIVEOrbitControls);
|
|
816
850
|
Activate(): void;
|
|
817
851
|
SetGizmoMode(mode: 'translate' | 'rotate' | 'scale'): void;
|
|
818
852
|
SetGizmoVisibility(active: boolean): void;
|
|
853
|
+
private initGizmo;
|
|
819
854
|
}
|
|
820
855
|
|
|
821
856
|
/**
|
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 =
|
|
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
|
-
//
|
|
385
|
-
//
|
|
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
|
});
|
|
@@ -3089,7 +3095,8 @@ var DIVEModel = class extends DIVENode {
|
|
|
3089
3095
|
};
|
|
3090
3096
|
|
|
3091
3097
|
// src/loadingmanager/LoadingManager.ts
|
|
3092
|
-
import { DRACOLoader
|
|
3098
|
+
import { DRACOLoader } from "three/examples/jsm/loaders/DRACOLoader";
|
|
3099
|
+
import { GLTFLoader as GLTFLoader2 } from "three/examples/jsm/loaders/GLTFLoader";
|
|
3093
3100
|
var DIVELoadingManager = class {
|
|
3094
3101
|
// ... maybe extend with other loaders later
|
|
3095
3102
|
constructor() {
|
|
@@ -3408,6 +3415,9 @@ var DIVEGroup = class extends DIVENode {
|
|
|
3408
3415
|
this._lines[index].visible = visible;
|
|
3409
3416
|
}
|
|
3410
3417
|
attach(object) {
|
|
3418
|
+
if (this._members.includes(object)) {
|
|
3419
|
+
return this;
|
|
3420
|
+
}
|
|
3411
3421
|
const line = this.createLine();
|
|
3412
3422
|
this.add(line);
|
|
3413
3423
|
this._lines.push(line);
|
|
@@ -4454,12 +4464,12 @@ var getObjectDelta = (a, b) => {
|
|
|
4454
4464
|
|
|
4455
4465
|
// src/dive.ts
|
|
4456
4466
|
init_Info();
|
|
4457
|
-
import {
|
|
4467
|
+
import { MathUtils as MathUtils5 } from "three";
|
|
4458
4468
|
|
|
4459
4469
|
// package.json
|
|
4460
4470
|
var package_default = {
|
|
4461
4471
|
name: "@shopware-ag/dive",
|
|
4462
|
-
version: "1.
|
|
4472
|
+
version: "1.18.0",
|
|
4463
4473
|
description: "Shopware Spatial Framework",
|
|
4464
4474
|
type: "module",
|
|
4465
4475
|
main: "./build/dive.cjs",
|
|
@@ -4503,6 +4513,7 @@ var package_default = {
|
|
|
4503
4513
|
globals: "^15.0.0",
|
|
4504
4514
|
jest: "^29.7.0",
|
|
4505
4515
|
"jest-environment-jsdom": "^29.7.0",
|
|
4516
|
+
"jest-junit": "^16.0.0",
|
|
4506
4517
|
jsdom: "^24.0.0",
|
|
4507
4518
|
prettier: "^3.3.3",
|
|
4508
4519
|
"prettier-plugin-multiline-arrays": "^3.0.6",
|
|
@@ -4618,7 +4629,7 @@ var DIVE = class _DIVE {
|
|
|
4618
4629
|
position: { x: 0, y: 2, z: 2 },
|
|
4619
4630
|
target: { x: 0, y: 0.5, z: 0 }
|
|
4620
4631
|
});
|
|
4621
|
-
const lightid =
|
|
4632
|
+
const lightid = MathUtils5.generateUUID();
|
|
4622
4633
|
dive.Communication.PerformAction("ADD_OBJECT", {
|
|
4623
4634
|
entityType: "light",
|
|
4624
4635
|
type: "scene",
|
|
@@ -4629,7 +4640,7 @@ var DIVE = class _DIVE {
|
|
|
4629
4640
|
intensity: 1,
|
|
4630
4641
|
color: 16777215
|
|
4631
4642
|
});
|
|
4632
|
-
const modelid =
|
|
4643
|
+
const modelid = MathUtils5.generateUUID();
|
|
4633
4644
|
dive.Communication.Subscribe("MODEL_LOADED", (data) => {
|
|
4634
4645
|
if (data.id !== modelid) return;
|
|
4635
4646
|
const transform = dive.Communication.PerformAction(
|