@shopware-ag/dive 1.17.0 → 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.cjs +90 -45
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.cts +38 -2
- package/build/dive.d.ts +38 -2
- package/build/dive.js +90 -45
- package/build/dive.js.map +1 -1
- package/package.json +2 -1
- package/src/com/Communication.ts +41 -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/model/Model.ts +7 -2
- package/src/model/__test__/Model.test.ts +48 -73
- package/src/primitive/Primitive.ts +7 -2
- package/src/primitive/__test__/Primitive.test.ts +25 -18
- package/src/toolbox/select/__test__/SelectTool.test.ts +32 -27
- package/src/toolbox/transform/TransformTool.ts +61 -53
- package/src/toolbox/transform/__test__/TransformTool.test.ts +27 -25
package/build/dive.cjs
CHANGED
|
@@ -337,40 +337,7 @@ var init_TransformTool = __esm({
|
|
|
337
337
|
super(scene, controller);
|
|
338
338
|
this.isTransformTool = true;
|
|
339
339
|
this.name = "DIVETransformTool";
|
|
340
|
-
this._gizmo =
|
|
341
|
-
this._controller.object,
|
|
342
|
-
this._controller.domElement
|
|
343
|
-
);
|
|
344
|
-
this._gizmo.mode = "translate";
|
|
345
|
-
this._gizmo.addEventListener("mouseDown", () => {
|
|
346
|
-
controller.enabled = false;
|
|
347
|
-
if (!implementsInterface(
|
|
348
|
-
this._gizmo.object,
|
|
349
|
-
"isMovable"
|
|
350
|
-
))
|
|
351
|
-
return;
|
|
352
|
-
if (!this._gizmo.object.onMoveStart) return;
|
|
353
|
-
this._gizmo.object.onMoveStart();
|
|
354
|
-
});
|
|
355
|
-
this._gizmo.addEventListener("objectChange", () => {
|
|
356
|
-
if (!implementsInterface(
|
|
357
|
-
this._gizmo.object,
|
|
358
|
-
"isMovable"
|
|
359
|
-
))
|
|
360
|
-
return;
|
|
361
|
-
if (!this._gizmo.object.onMove) return;
|
|
362
|
-
this._gizmo.object.onMove();
|
|
363
|
-
});
|
|
364
|
-
this._gizmo.addEventListener("mouseUp", () => {
|
|
365
|
-
controller.enabled = true;
|
|
366
|
-
if (!implementsInterface(
|
|
367
|
-
this._gizmo.object,
|
|
368
|
-
"isMovable"
|
|
369
|
-
))
|
|
370
|
-
return;
|
|
371
|
-
if (!this._gizmo.object.onMoveEnd) return;
|
|
372
|
-
this._gizmo.object.onMoveEnd();
|
|
373
|
-
});
|
|
340
|
+
this._gizmo = this.initGizmo();
|
|
374
341
|
this._scene.add(this._gizmo);
|
|
375
342
|
}
|
|
376
343
|
Activate() {
|
|
@@ -382,19 +349,58 @@ var init_TransformTool = __esm({
|
|
|
382
349
|
const contains = this._scene.children.includes(this._gizmo);
|
|
383
350
|
if (active && !contains) {
|
|
384
351
|
this._scene.add(this._gizmo);
|
|
352
|
+
if ("isTransformControls" in this._gizmo) {
|
|
353
|
+
this._gizmo.getRaycaster().layers.enableAll();
|
|
354
|
+
}
|
|
385
355
|
} else if (!active && contains) {
|
|
386
356
|
this._scene.remove(this._gizmo);
|
|
357
|
+
if ("isTransformControls" in this._gizmo) {
|
|
358
|
+
this._gizmo.getRaycaster().layers.disableAll();
|
|
359
|
+
}
|
|
387
360
|
}
|
|
388
361
|
}
|
|
362
|
+
// only used for optimizing pointer events with DIVEGizmo
|
|
389
363
|
// public onPointerDown(e: PointerEvent): void {
|
|
390
364
|
// super.onPointerDown(e);
|
|
391
|
-
//
|
|
392
|
-
//
|
|
393
|
-
//
|
|
365
|
+
// if (this._hovered) {
|
|
366
|
+
// this._dragRaycastOnObjects = (
|
|
367
|
+
// this._gizmo as DIVEGizmo
|
|
368
|
+
// ).gizmoPlane?.children;
|
|
369
|
+
// }
|
|
394
370
|
// }
|
|
371
|
+
// only used for optimizing pointer events with DIVEGizmo
|
|
395
372
|
// protected raycast(): Intersection[] {
|
|
396
|
-
// return super.raycast(this._gizmo.gizmoNode.children);
|
|
373
|
+
// return super.raycast((this._gizmo as DIVEGizmo).gizmoNode.children);
|
|
397
374
|
// }
|
|
375
|
+
initGizmo() {
|
|
376
|
+
const g = new import_TransformControls.TransformControls(
|
|
377
|
+
// this._controller,
|
|
378
|
+
this._controller.object,
|
|
379
|
+
this._controller.domElement
|
|
380
|
+
);
|
|
381
|
+
g.mode = "translate";
|
|
382
|
+
g.addEventListener("mouseDown", () => {
|
|
383
|
+
this._controller.enabled = false;
|
|
384
|
+
if (!implementsInterface(g.object, "isMovable"))
|
|
385
|
+
return;
|
|
386
|
+
if (!g.object.onMoveStart) return;
|
|
387
|
+
g.object.onMoveStart();
|
|
388
|
+
});
|
|
389
|
+
g.addEventListener("objectChange", () => {
|
|
390
|
+
if (!implementsInterface(g.object, "isMovable"))
|
|
391
|
+
return;
|
|
392
|
+
if (!g.object.onMove) return;
|
|
393
|
+
g.object.onMove();
|
|
394
|
+
});
|
|
395
|
+
g.addEventListener("mouseUp", () => {
|
|
396
|
+
this._controller.enabled = true;
|
|
397
|
+
if (!implementsInterface(g.object, "isMovable"))
|
|
398
|
+
return;
|
|
399
|
+
if (!g.object.onMoveEnd) return;
|
|
400
|
+
g.object.onMoveEnd();
|
|
401
|
+
});
|
|
402
|
+
return g;
|
|
403
|
+
}
|
|
398
404
|
};
|
|
399
405
|
}
|
|
400
406
|
});
|
|
@@ -2550,6 +2556,22 @@ var _DIVECommunication = class _DIVECommunication {
|
|
|
2550
2556
|
deleteObject(payload) {
|
|
2551
2557
|
const deletedObject = this.registered.get(payload.id);
|
|
2552
2558
|
if (!deletedObject) return false;
|
|
2559
|
+
if (deletedObject.parentId) {
|
|
2560
|
+
this.setParent({
|
|
2561
|
+
object: { id: deletedObject.id },
|
|
2562
|
+
parent: null
|
|
2563
|
+
});
|
|
2564
|
+
}
|
|
2565
|
+
if (deletedObject.entityType === "group") {
|
|
2566
|
+
this.registered.forEach((object) => {
|
|
2567
|
+
if (object.parentId === deletedObject.id) {
|
|
2568
|
+
this.updateObject({
|
|
2569
|
+
id: object.id,
|
|
2570
|
+
parentId: null
|
|
2571
|
+
});
|
|
2572
|
+
}
|
|
2573
|
+
});
|
|
2574
|
+
}
|
|
2553
2575
|
Object.assign(payload, deletedObject);
|
|
2554
2576
|
this.registered.delete(payload.id);
|
|
2555
2577
|
Array.from(this.registered.values()).forEach((object) => {
|
|
@@ -2712,6 +2734,10 @@ var _DIVECommunication = class _DIVECommunication {
|
|
|
2712
2734
|
if (!sceneObject) return false;
|
|
2713
2735
|
if (payload.parent === null) {
|
|
2714
2736
|
this.scene.Root.attach(sceneObject);
|
|
2737
|
+
this.updateObject({
|
|
2738
|
+
id: object.id,
|
|
2739
|
+
parentId: null
|
|
2740
|
+
});
|
|
2715
2741
|
return true;
|
|
2716
2742
|
}
|
|
2717
2743
|
if (payload.object.id === payload.parent.id) {
|
|
@@ -2720,14 +2746,26 @@ var _DIVECommunication = class _DIVECommunication {
|
|
|
2720
2746
|
const parent = this.registered.get(payload.parent.id);
|
|
2721
2747
|
if (!parent) {
|
|
2722
2748
|
this.scene.Root.attach(sceneObject);
|
|
2749
|
+
this.updateObject({
|
|
2750
|
+
id: object.id,
|
|
2751
|
+
parentId: null
|
|
2752
|
+
});
|
|
2723
2753
|
return true;
|
|
2724
2754
|
}
|
|
2725
2755
|
const parentObject = this.scene.GetSceneObject(parent);
|
|
2726
2756
|
if (!parentObject) {
|
|
2727
2757
|
this.scene.Root.attach(sceneObject);
|
|
2758
|
+
this.updateObject({
|
|
2759
|
+
id: object.id,
|
|
2760
|
+
parentId: null
|
|
2761
|
+
});
|
|
2728
2762
|
return true;
|
|
2729
2763
|
}
|
|
2730
2764
|
parentObject.attach(sceneObject);
|
|
2765
|
+
this.updateObject({
|
|
2766
|
+
id: object.id,
|
|
2767
|
+
parentId: parent.id
|
|
2768
|
+
});
|
|
2731
2769
|
return true;
|
|
2732
2770
|
}
|
|
2733
2771
|
exportScene(payload) {
|
|
@@ -3002,12 +3040,15 @@ var DIVEModel = class extends DIVENode {
|
|
|
3002
3040
|
}
|
|
3003
3041
|
}
|
|
3004
3042
|
PlaceOnFloor() {
|
|
3005
|
-
var _a;
|
|
3043
|
+
var _a, _b, _c, _d, _e;
|
|
3006
3044
|
const worldPos = this.getWorldPosition(this._positionWorldBuffer);
|
|
3007
3045
|
const oldWorldPos = worldPos.clone();
|
|
3008
|
-
|
|
3046
|
+
(_b = (_a = this._mesh) == null ? void 0 : _a.geometry) == null ? void 0 : _b.computeBoundingBox();
|
|
3047
|
+
const meshBB = (_d = (_c = this._mesh) == null ? void 0 : _c.geometry) == null ? void 0 : _d.boundingBox;
|
|
3048
|
+
if (!meshBB || !this._mesh) return;
|
|
3049
|
+
worldPos.y = worldPos.y - this._mesh.localToWorld(meshBB.min.clone()).y;
|
|
3009
3050
|
if (worldPos.y === oldWorldPos.y) return;
|
|
3010
|
-
(
|
|
3051
|
+
(_e = DIVECommunication.get(this.userData.id)) == null ? void 0 : _e.PerformAction(
|
|
3011
3052
|
"UPDATE_OBJECT",
|
|
3012
3053
|
{
|
|
3013
3054
|
id: this.userData.id,
|
|
@@ -3139,12 +3180,15 @@ var DIVEPrimitive = class extends DIVENode {
|
|
|
3139
3180
|
if (this._mesh) this._mesh.material = primitiveMaterial;
|
|
3140
3181
|
}
|
|
3141
3182
|
PlaceOnFloor() {
|
|
3142
|
-
var _a;
|
|
3183
|
+
var _a, _b, _c, _d, _e;
|
|
3143
3184
|
const worldPos = this.getWorldPosition(this._positionWorldBuffer);
|
|
3144
3185
|
const oldWorldPos = worldPos.clone();
|
|
3145
|
-
|
|
3186
|
+
(_b = (_a = this._mesh) == null ? void 0 : _a.geometry) == null ? void 0 : _b.computeBoundingBox();
|
|
3187
|
+
const meshBB = (_d = (_c = this._mesh) == null ? void 0 : _c.geometry) == null ? void 0 : _d.boundingBox;
|
|
3188
|
+
if (!meshBB || !this._mesh) return;
|
|
3189
|
+
worldPos.y = worldPos.y - this._mesh.localToWorld(meshBB.min.clone()).y;
|
|
3146
3190
|
if (worldPos.y === oldWorldPos.y) return;
|
|
3147
|
-
(
|
|
3191
|
+
(_e = DIVECommunication.get(this.userData.id)) == null ? void 0 : _e.PerformAction(
|
|
3148
3192
|
"UPDATE_OBJECT",
|
|
3149
3193
|
{
|
|
3150
3194
|
id: this.userData.id,
|
|
@@ -4390,7 +4434,7 @@ init_Info();
|
|
|
4390
4434
|
// package.json
|
|
4391
4435
|
var package_default = {
|
|
4392
4436
|
name: "@shopware-ag/dive",
|
|
4393
|
-
version: "1.17.
|
|
4437
|
+
version: "1.17.2",
|
|
4394
4438
|
description: "Shopware Spatial Framework",
|
|
4395
4439
|
type: "module",
|
|
4396
4440
|
main: "./build/dive.cjs",
|
|
@@ -4434,6 +4478,7 @@ var package_default = {
|
|
|
4434
4478
|
globals: "^15.0.0",
|
|
4435
4479
|
jest: "^29.7.0",
|
|
4436
4480
|
"jest-environment-jsdom": "^29.7.0",
|
|
4481
|
+
"jest-junit": "^16.0.0",
|
|
4437
4482
|
jsdom: "^24.0.0",
|
|
4438
4483
|
prettier: "^3.3.3",
|
|
4439
4484
|
"prettier-plugin-multiline-arrays": "^3.0.6",
|