@shopware-ag/dive 1.15.3 → 1.15.5
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 +216 -138
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.cts +31 -22
- package/build/dive.d.ts +31 -22
- package/build/dive.js +219 -141
- package/build/dive.js.map +1 -1
- package/package.json +3 -1
- package/src/com/Communication.ts +3 -2
- package/src/com/__test__/Communication.test.ts +6 -6
- package/src/com/types/COMBaseEntity.ts +1 -1
- package/src/dive.ts +2 -1
- package/src/group/Group.ts +116 -68
- package/src/group/__test__/Group.test.ts +20 -4
- package/src/helper/applyMixins/__test__/applyMixins.test.ts +3 -3
- package/src/helper/findInterface/__test__/findInterface.test.ts +53 -0
- package/src/helper/findInterface/findInterface.ts +10 -0
- package/src/helper/getObjectDelta/__test__/getObjectDelta.test.ts +0 -2
- package/src/helper/isInterface/__test__/implementsInterface.test.ts +19 -0
- package/src/helper/isInterface/implementsInterface.ts +6 -0
- package/src/interface/Draggable.ts +0 -20
- package/src/interface/Hoverable.ts +1 -20
- package/src/interface/Movable.ts +12 -0
- package/src/interface/Selectable.ts +0 -23
- package/src/light/PointLight.ts +3 -3
- package/src/node/Node.ts +8 -3
- package/src/node/__test__/Node.test.ts +4 -0
- package/src/primitive/Primitive.ts +5 -3
- package/src/primitive/__test__/Primitive.test.ts +4 -2
- package/src/scene/root/Root.ts +13 -17
- package/src/scene/root/__test__/Root.test.ts +13 -11
- package/src/toolbox/BaseTool.ts +5 -4
- package/src/toolbox/select/SelectTool.ts +7 -6
- package/src/toolbox/select/__test__/SelectTool.test.ts +3 -3
- package/src/toolbox/transform/TransformTool.ts +19 -8
- package/src/toolbox/transform/__test__/TransformTool.test.ts +4 -2
- package/src/interface/Moveable.ts +0 -11
- package/src/interface/__test__/Interfaces.test.ts +0 -87
package/build/dive.cjs
CHANGED
|
@@ -80,45 +80,27 @@ var init_VisibilityLayerMask = __esm({
|
|
|
80
80
|
}
|
|
81
81
|
});
|
|
82
82
|
|
|
83
|
-
// src/
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
// src/helper/isInterface/implementsInterface.ts
|
|
84
|
+
function implementsInterface(object, discriminator) {
|
|
85
|
+
if (!object) return false;
|
|
86
|
+
return discriminator in object;
|
|
87
|
+
}
|
|
88
|
+
var init_implementsInterface = __esm({
|
|
89
|
+
"src/helper/isInterface/implementsInterface.ts"() {
|
|
87
90
|
"use strict";
|
|
88
|
-
isDraggable = (object) => {
|
|
89
|
-
return "isDraggable" in object;
|
|
90
|
-
};
|
|
91
|
-
findDraggableInterface = (child) => {
|
|
92
|
-
if (child === void 0) return void 0;
|
|
93
|
-
if (child.parent === null) {
|
|
94
|
-
return void 0;
|
|
95
|
-
}
|
|
96
|
-
if (isDraggable(child)) {
|
|
97
|
-
return child;
|
|
98
|
-
}
|
|
99
|
-
return findDraggableInterface(child.parent);
|
|
100
|
-
};
|
|
101
91
|
}
|
|
102
92
|
});
|
|
103
93
|
|
|
104
|
-
// src/
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
94
|
+
// src/helper/findInterface/findInterface.ts
|
|
95
|
+
function findInterface(object, discriminator) {
|
|
96
|
+
if (!object) return void 0;
|
|
97
|
+
if (implementsInterface(object, discriminator)) return object;
|
|
98
|
+
return findInterface(object.parent, discriminator);
|
|
99
|
+
}
|
|
100
|
+
var init_findInterface = __esm({
|
|
101
|
+
"src/helper/findInterface/findInterface.ts"() {
|
|
108
102
|
"use strict";
|
|
109
|
-
|
|
110
|
-
return "isHoverable" in object;
|
|
111
|
-
};
|
|
112
|
-
findHoverableInterface = (child) => {
|
|
113
|
-
if (child === void 0) return void 0;
|
|
114
|
-
if (child.parent === null) {
|
|
115
|
-
return void 0;
|
|
116
|
-
}
|
|
117
|
-
if (isHoverable(child)) {
|
|
118
|
-
return child;
|
|
119
|
-
}
|
|
120
|
-
return findHoverableInterface(child.parent);
|
|
121
|
-
};
|
|
103
|
+
init_implementsInterface();
|
|
122
104
|
}
|
|
123
105
|
});
|
|
124
106
|
|
|
@@ -129,8 +111,7 @@ var init_BaseTool = __esm({
|
|
|
129
111
|
"use strict";
|
|
130
112
|
import_three3 = require("three");
|
|
131
113
|
init_VisibilityLayerMask();
|
|
132
|
-
|
|
133
|
-
init_Hoverable();
|
|
114
|
+
init_findInterface();
|
|
134
115
|
DIVEBaseTool = class {
|
|
135
116
|
constructor(scene, controller) {
|
|
136
117
|
this.POINTER_DRAG_THRESHOLD = 1e-3;
|
|
@@ -177,7 +158,7 @@ var init_BaseTool = __esm({
|
|
|
177
158
|
break;
|
|
178
159
|
}
|
|
179
160
|
this._lastPointerDown.copy(this._pointer);
|
|
180
|
-
this._draggable =
|
|
161
|
+
this._draggable = findInterface((_a = this._intersects[0]) == null ? void 0 : _a.object, "isDraggable") || null;
|
|
181
162
|
}
|
|
182
163
|
onDragStart(e) {
|
|
183
164
|
if (!this._draggable) return;
|
|
@@ -206,7 +187,7 @@ var init_BaseTool = __esm({
|
|
|
206
187
|
this._pointer.y = -(e.offsetY / this._canvas.clientHeight) * 2 + 1;
|
|
207
188
|
this._raycaster.setFromCamera(this._pointer, this._controller.object);
|
|
208
189
|
this._intersects = this.raycast(this._scene.children);
|
|
209
|
-
const hoverable =
|
|
190
|
+
const hoverable = findInterface((_a = this._intersects[0]) == null ? void 0 : _a.object, "isHoverable");
|
|
210
191
|
if (this._intersects[0] && hoverable) {
|
|
211
192
|
if (!this._hovered) {
|
|
212
193
|
if (hoverable.onPointerEnter) hoverable.onPointerEnter(this._intersects[0]);
|
|
@@ -318,6 +299,7 @@ var init_TransformTool = __esm({
|
|
|
318
299
|
"use strict";
|
|
319
300
|
init_BaseTool();
|
|
320
301
|
import_Addons = require("three/examples/jsm/Addons");
|
|
302
|
+
init_implementsInterface();
|
|
321
303
|
DIVETransformTool = class extends DIVEBaseTool {
|
|
322
304
|
constructor(scene, controller) {
|
|
323
305
|
super(scene, controller);
|
|
@@ -327,16 +309,21 @@ var init_TransformTool = __esm({
|
|
|
327
309
|
this._gizmo.mode = "translate";
|
|
328
310
|
this._gizmo.addEventListener("mouseDown", () => {
|
|
329
311
|
controller.enabled = false;
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
312
|
+
if (!implementsInterface(this._gizmo.object, "isMovable")) return;
|
|
313
|
+
if (!this._gizmo.object.onMoveStart) return;
|
|
314
|
+
this._gizmo.object.onMoveStart();
|
|
333
315
|
});
|
|
334
316
|
this._gizmo.addEventListener("objectChange", () => {
|
|
335
|
-
if (!this._gizmo.object) return;
|
|
336
|
-
if (!
|
|
337
|
-
if (!("onMove" in this._gizmo.object)) return;
|
|
317
|
+
if (!implementsInterface(this._gizmo.object, "isMovable")) return;
|
|
318
|
+
if (!this._gizmo.object.onMove) return;
|
|
338
319
|
this._gizmo.object.onMove();
|
|
339
320
|
});
|
|
321
|
+
this._gizmo.addEventListener("mouseUp", () => {
|
|
322
|
+
controller.enabled = true;
|
|
323
|
+
if (!implementsInterface(this._gizmo.object, "isMovable")) return;
|
|
324
|
+
if (!this._gizmo.object.onMoveEnd) return;
|
|
325
|
+
this._gizmo.object.onMoveEnd();
|
|
326
|
+
});
|
|
340
327
|
scene.add(this._gizmo);
|
|
341
328
|
}
|
|
342
329
|
Activate() {
|
|
@@ -365,26 +352,6 @@ var init_TransformTool = __esm({
|
|
|
365
352
|
}
|
|
366
353
|
});
|
|
367
354
|
|
|
368
|
-
// src/interface/Selectable.ts
|
|
369
|
-
function isSelectable(object) {
|
|
370
|
-
return "isSelectable" in object;
|
|
371
|
-
}
|
|
372
|
-
function findSelectableInterface(child) {
|
|
373
|
-
if (child === void 0) return void 0;
|
|
374
|
-
if (child.parent === null) {
|
|
375
|
-
return void 0;
|
|
376
|
-
}
|
|
377
|
-
if (isSelectable(child)) {
|
|
378
|
-
return child;
|
|
379
|
-
}
|
|
380
|
-
return findSelectableInterface(child.parent);
|
|
381
|
-
}
|
|
382
|
-
var init_Selectable = __esm({
|
|
383
|
-
"src/interface/Selectable.ts"() {
|
|
384
|
-
"use strict";
|
|
385
|
-
}
|
|
386
|
-
});
|
|
387
|
-
|
|
388
355
|
// src/toolbox/select/SelectTool.ts
|
|
389
356
|
var SelectTool_exports = {};
|
|
390
357
|
__export(SelectTool_exports, {
|
|
@@ -396,7 +363,7 @@ var init_SelectTool = __esm({
|
|
|
396
363
|
"src/toolbox/select/SelectTool.ts"() {
|
|
397
364
|
"use strict";
|
|
398
365
|
init_TransformTool();
|
|
399
|
-
|
|
366
|
+
init_findInterface();
|
|
400
367
|
isSelectTool = (tool) => {
|
|
401
368
|
return tool.isSelectTool !== void 0;
|
|
402
369
|
};
|
|
@@ -417,7 +384,7 @@ var init_SelectTool = __esm({
|
|
|
417
384
|
this.DetachGizmo();
|
|
418
385
|
}
|
|
419
386
|
AttachGizmo(selectable) {
|
|
420
|
-
if ("
|
|
387
|
+
if ("isMovable" in selectable) {
|
|
421
388
|
const movable = selectable;
|
|
422
389
|
this._gizmo.attach(movable);
|
|
423
390
|
this.SetGizmoVisibility(movable.visible);
|
|
@@ -429,7 +396,7 @@ var init_SelectTool = __esm({
|
|
|
429
396
|
onClick(e) {
|
|
430
397
|
super.onClick(e);
|
|
431
398
|
const first = this._raycaster.intersectObjects(this._scene.Root.children, true).filter((intersect) => intersect.object.visible)[0];
|
|
432
|
-
const selectable =
|
|
399
|
+
const selectable = findInterface(first == null ? void 0 : first.object, "isSelectable");
|
|
433
400
|
if (!first || !selectable) {
|
|
434
401
|
if (this._gizmo.object) {
|
|
435
402
|
this.Deselect(this._gizmo.object);
|
|
@@ -706,6 +673,7 @@ var import_three5 = require("three");
|
|
|
706
673
|
// src/com/Communication.ts
|
|
707
674
|
var import_MathUtils = require("three/src/math/MathUtils");
|
|
708
675
|
init_SelectTool();
|
|
676
|
+
var import_lodash = require("lodash");
|
|
709
677
|
var _DIVECommunication = class _DIVECommunication {
|
|
710
678
|
constructor(renderer, scene, controls, toolbox) {
|
|
711
679
|
this.registered = /* @__PURE__ */ new Map();
|
|
@@ -900,7 +868,7 @@ var _DIVECommunication = class _DIVECommunication {
|
|
|
900
868
|
}
|
|
901
869
|
addObject(payload) {
|
|
902
870
|
if (this.registered.get(payload.id)) return false;
|
|
903
|
-
if (payload.
|
|
871
|
+
if (payload.parentId === void 0) payload.parentId = null;
|
|
904
872
|
this.registered.set(payload.id, payload);
|
|
905
873
|
this.scene.AddSceneObject(payload);
|
|
906
874
|
return true;
|
|
@@ -908,7 +876,7 @@ var _DIVECommunication = class _DIVECommunication {
|
|
|
908
876
|
updateObject(payload) {
|
|
909
877
|
const objectToUpdate = this.registered.get(payload.id);
|
|
910
878
|
if (!objectToUpdate) return false;
|
|
911
|
-
this.registered.set(payload.id,
|
|
879
|
+
this.registered.set(payload.id, (0, import_lodash.merge)(objectToUpdate, payload));
|
|
912
880
|
const updatedObject = this.registered.get(payload.id);
|
|
913
881
|
this.scene.UpdateSceneObject(__spreadProps(__spreadValues({}, payload), { id: updatedObject.id, entityType: updatedObject.entityType }));
|
|
914
882
|
Object.assign(payload, updatedObject);
|
|
@@ -1088,7 +1056,7 @@ var DIVEPointLight = class extends import_three5.Object3D {
|
|
|
1088
1056
|
super();
|
|
1089
1057
|
this.isDIVELight = true;
|
|
1090
1058
|
this.isDIVEPointLight = true;
|
|
1091
|
-
this.
|
|
1059
|
+
this.isMovable = true;
|
|
1092
1060
|
this.isSelectable = true;
|
|
1093
1061
|
this.gizmo = null;
|
|
1094
1062
|
this.name = "DIVEPointLight";
|
|
@@ -1192,7 +1160,7 @@ var DIVENode = class extends import_three7.Object3D {
|
|
|
1192
1160
|
super();
|
|
1193
1161
|
this.isDIVENode = true;
|
|
1194
1162
|
this.isSelectable = true;
|
|
1195
|
-
this.
|
|
1163
|
+
this.isMovable = true;
|
|
1196
1164
|
this.gizmo = null;
|
|
1197
1165
|
this.layers.mask = PRODUCT_LAYER_MASK;
|
|
1198
1166
|
this._boundingBox = new import_three7.Box3();
|
|
@@ -1217,6 +1185,9 @@ var DIVENode = class extends import_three7.Object3D {
|
|
|
1217
1185
|
onMove() {
|
|
1218
1186
|
var _a;
|
|
1219
1187
|
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("UPDATE_OBJECT", { id: this.userData.id, position: this.position, rotation: this.rotation, scale: this.scale });
|
|
1188
|
+
if (this.parent && "isDIVEGroup" in this.parent) {
|
|
1189
|
+
this.parent.UpdateLineTo(this);
|
|
1190
|
+
}
|
|
1220
1191
|
}
|
|
1221
1192
|
onSelect() {
|
|
1222
1193
|
var _a;
|
|
@@ -1415,7 +1386,7 @@ var DIVEPrimitive = class extends DIVENode {
|
|
|
1415
1386
|
DropIt() {
|
|
1416
1387
|
var _a;
|
|
1417
1388
|
if (!this.parent) {
|
|
1418
|
-
console.warn("
|
|
1389
|
+
console.warn("DIVEPrimitive: DropIt() called on a model that is not in the scene.", this);
|
|
1419
1390
|
return;
|
|
1420
1391
|
}
|
|
1421
1392
|
const bottomY = this._boundingBox.min.y * this.scale.y;
|
|
@@ -1437,7 +1408,7 @@ var DIVEPrimitive = class extends DIVENode {
|
|
|
1437
1408
|
}
|
|
1438
1409
|
}
|
|
1439
1410
|
assembleGeometry(geometry) {
|
|
1440
|
-
switch (geometry.name) {
|
|
1411
|
+
switch (geometry.name.toLowerCase()) {
|
|
1441
1412
|
case "cylinder":
|
|
1442
1413
|
return this.createCylinderGeometry(geometry);
|
|
1443
1414
|
case "sphere":
|
|
@@ -1452,8 +1423,10 @@ var DIVEPrimitive = class extends DIVENode {
|
|
|
1452
1423
|
return this.createWallGeometry(geometry);
|
|
1453
1424
|
case "plane":
|
|
1454
1425
|
return this.createPlaneGeometry(geometry);
|
|
1455
|
-
default:
|
|
1426
|
+
default: {
|
|
1427
|
+
console.warn("DIVEPrimitive: Invalid geometry type:", geometry.name.toLowerCase());
|
|
1456
1428
|
return new import_three9.BufferGeometry();
|
|
1429
|
+
}
|
|
1457
1430
|
}
|
|
1458
1431
|
}
|
|
1459
1432
|
createCylinderGeometry(geometry) {
|
|
@@ -1496,74 +1469,118 @@ var DIVEPrimitive = class extends DIVENode {
|
|
|
1496
1469
|
// src/group/Group.ts
|
|
1497
1470
|
var import_three10 = require("three");
|
|
1498
1471
|
var DIVEGroup = class extends DIVENode {
|
|
1472
|
+
// lines to children
|
|
1499
1473
|
constructor() {
|
|
1500
1474
|
super();
|
|
1501
1475
|
this.isDIVEGroup = true;
|
|
1502
1476
|
this.name = "DIVEGroup";
|
|
1503
|
-
this.
|
|
1504
|
-
this.
|
|
1505
|
-
this.add(this._boxMesh);
|
|
1477
|
+
this._members = [];
|
|
1478
|
+
this._lines = [];
|
|
1506
1479
|
}
|
|
1507
|
-
|
|
1508
|
-
|
|
1480
|
+
SetLinesVisibility(visible, object) {
|
|
1481
|
+
if (!object) {
|
|
1482
|
+
this._lines.forEach((line) => {
|
|
1483
|
+
line.visible = visible;
|
|
1484
|
+
});
|
|
1485
|
+
return;
|
|
1486
|
+
}
|
|
1487
|
+
const index = this._members.indexOf(object);
|
|
1488
|
+
if (index === -1) return;
|
|
1489
|
+
this._lines[index].visible = visible;
|
|
1509
1490
|
}
|
|
1510
1491
|
attach(object) {
|
|
1492
|
+
const line = this.createLine();
|
|
1493
|
+
this.add(line);
|
|
1494
|
+
this._lines.push(line);
|
|
1511
1495
|
super.attach(object);
|
|
1512
|
-
this.
|
|
1513
|
-
this.
|
|
1496
|
+
this._members.push(object);
|
|
1497
|
+
this.updateLineTo(line, object);
|
|
1498
|
+
this.SetLinesVisibility(true, object);
|
|
1514
1499
|
return this;
|
|
1515
1500
|
}
|
|
1516
1501
|
remove(object) {
|
|
1502
|
+
const index = this._members.indexOf(object);
|
|
1503
|
+
if (index === -1) return this;
|
|
1504
|
+
const line = this._lines[index];
|
|
1505
|
+
super.remove(line);
|
|
1506
|
+
this._lines.splice(index, 1);
|
|
1517
1507
|
super.remove(object);
|
|
1518
|
-
this.
|
|
1519
|
-
this.updateBoxMesh();
|
|
1508
|
+
this._members.splice(index, 1);
|
|
1520
1509
|
return this;
|
|
1521
1510
|
}
|
|
1511
|
+
UpdateLineTo(object) {
|
|
1512
|
+
const index = this._members.indexOf(object);
|
|
1513
|
+
if (index === -1) return;
|
|
1514
|
+
this.updateLineTo(this._lines[index], object);
|
|
1515
|
+
}
|
|
1522
1516
|
/**
|
|
1523
|
-
*
|
|
1524
|
-
* Children's world positions are kept.
|
|
1517
|
+
* Adds a line to this grouo as last child.
|
|
1525
1518
|
*/
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
const
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
if (child.uuid === this._boxMesh.uuid) return;
|
|
1533
|
-
child.position.copy(this.worldToLocal(childrensWorldPositions[i]));
|
|
1519
|
+
createLine() {
|
|
1520
|
+
const geo = new import_three10.BufferGeometry();
|
|
1521
|
+
const mat = new import_three10.LineDashedMaterial({
|
|
1522
|
+
color: 6710886,
|
|
1523
|
+
dashSize: 0.05,
|
|
1524
|
+
gapSize: 0.025
|
|
1534
1525
|
});
|
|
1535
|
-
|
|
1526
|
+
const line = new import_three10.Line(geo, mat);
|
|
1527
|
+
line.visible = false;
|
|
1528
|
+
return line;
|
|
1536
1529
|
}
|
|
1537
1530
|
/**
|
|
1538
|
-
* Updates
|
|
1539
|
-
* @returns {Vector3} The new center of the bounding box.
|
|
1531
|
+
* Updates a line to the object.
|
|
1540
1532
|
*/
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1533
|
+
updateLineTo(line, object) {
|
|
1534
|
+
line.geometry.setFromPoints([new import_three10.Vector3(0, 0, 0), object.position.clone()]);
|
|
1535
|
+
line.computeLineDistances();
|
|
1536
|
+
}
|
|
1537
|
+
// public SetBoundingBoxVisibility(visible: boolean): void {
|
|
1538
|
+
// this._boxMesh.visible = visible;
|
|
1539
|
+
// }
|
|
1540
|
+
// /**
|
|
1541
|
+
// * Recalculates the position of the group based on it's bounding box.
|
|
1542
|
+
// * Children's world positions are kept.
|
|
1543
|
+
// */
|
|
1544
|
+
// private recalculatePosition(): void {
|
|
1545
|
+
// // store all children's world positions
|
|
1546
|
+
// const childrensWorldPositions: Vector3[] = this.children.map((child) => child.getWorldPosition(new Vector3()));
|
|
1547
|
+
// // calculate new center and set it as the group's position
|
|
1548
|
+
// const bbcenter = this.updateBB();
|
|
1549
|
+
// this.position.copy(bbcenter);
|
|
1550
|
+
// // set childrens's positions so their world positions are kept
|
|
1551
|
+
// this.children.forEach((child, i) => {
|
|
1552
|
+
// if (child.uuid === this._boxMesh.uuid) return;
|
|
1553
|
+
// child.position.copy(this.worldToLocal(childrensWorldPositions[i]));
|
|
1554
|
+
// });
|
|
1555
|
+
// DIVECommunication.get(this.userData.id)?.PerformAction('UPDATE_OBJECT', { id: this.userData.id, position: this.position });
|
|
1556
|
+
// }
|
|
1557
|
+
// /**
|
|
1558
|
+
// * Updates the bounding box of the group.
|
|
1559
|
+
// * @returns {Vector3} The new center of the bounding box.
|
|
1560
|
+
// */
|
|
1561
|
+
// private updateBB(): Vector3 {
|
|
1562
|
+
// this._boundingBox.makeEmpty();
|
|
1563
|
+
// if (this.children.length === 1) {
|
|
1564
|
+
// // because we always have the box mesh as 1 child
|
|
1565
|
+
// return this.position.clone();
|
|
1566
|
+
// }
|
|
1567
|
+
// this.children.forEach((child) => {
|
|
1568
|
+
// if (child.uuid === this._boxMesh.uuid) return;
|
|
1569
|
+
// this._boundingBox.expandByObject(child);
|
|
1570
|
+
// });
|
|
1571
|
+
// return this._boundingBox.getCenter(new Vector3());
|
|
1572
|
+
// }
|
|
1573
|
+
// private updateBoxMesh(): void {
|
|
1574
|
+
// if (this.children.length === 1) {
|
|
1575
|
+
// // because we always have the box mesh as 1 child
|
|
1576
|
+
// this._boxMesh.visible = false;
|
|
1577
|
+
// return;
|
|
1578
|
+
// }
|
|
1579
|
+
// this._boxMesh.quaternion.copy(this.quaternion.clone().invert());
|
|
1580
|
+
// this._boxMesh.scale.set(1 / this.scale.x, 1 / this.scale.y, 1 / this.scale.z);
|
|
1581
|
+
// this._boxMesh.geometry = new BoxGeometry(this._boundingBox.max.x - this._boundingBox.min.x, this._boundingBox.max.y - this._boundingBox.min.y, this._boundingBox.max.z - this._boundingBox.min.z);
|
|
1582
|
+
// this._boxMesh.visible = true;
|
|
1583
|
+
// }
|
|
1567
1584
|
};
|
|
1568
1585
|
|
|
1569
1586
|
// src/scene/root/Root.ts
|
|
@@ -1692,7 +1709,7 @@ var DIVERoot = class extends import_three11.Object3D {
|
|
|
1692
1709
|
break;
|
|
1693
1710
|
}
|
|
1694
1711
|
default: {
|
|
1695
|
-
console.warn(`
|
|
1712
|
+
console.warn(`DIVERoot.updateLight: Unknown light type: ${light.type}`);
|
|
1696
1713
|
return;
|
|
1697
1714
|
}
|
|
1698
1715
|
}
|
|
@@ -1705,7 +1722,7 @@ var DIVERoot = class extends import_three11.Object3D {
|
|
|
1705
1722
|
if (light.enabled !== void 0 && light.enabled !== null) sceneObject.SetEnabled(light.enabled);
|
|
1706
1723
|
if (light.color !== void 0 && light.color !== null) sceneObject.SetColor(new import_three11.Color(light.color));
|
|
1707
1724
|
if (light.visible !== void 0 && light.visible !== null) sceneObject.visible = light.visible;
|
|
1708
|
-
if (light.
|
|
1725
|
+
if (light.parentId !== void 0) this.setParent(__spreadProps(__spreadValues({}, light), { parentId: light.parentId }));
|
|
1709
1726
|
}
|
|
1710
1727
|
updateModel(model) {
|
|
1711
1728
|
let sceneObject = this.GetSceneObject(model);
|
|
@@ -1728,7 +1745,7 @@ var DIVERoot = class extends import_three11.Object3D {
|
|
|
1728
1745
|
if (model.scale !== void 0) sceneObject.SetScale(model.scale);
|
|
1729
1746
|
if (model.visible !== void 0) sceneObject.SetVisibility(model.visible);
|
|
1730
1747
|
if (model.material !== void 0) sceneObject.SetMaterial(model.material);
|
|
1731
|
-
if (model.
|
|
1748
|
+
if (model.parentId !== void 0) this.setParent(__spreadProps(__spreadValues({}, model), { parentId: model.parentId }));
|
|
1732
1749
|
}
|
|
1733
1750
|
updatePrimitive(primitive) {
|
|
1734
1751
|
let sceneObject = this.GetSceneObject(primitive);
|
|
@@ -1745,7 +1762,7 @@ var DIVERoot = class extends import_three11.Object3D {
|
|
|
1745
1762
|
if (primitive.scale !== void 0) sceneObject.SetScale(primitive.scale);
|
|
1746
1763
|
if (primitive.visible !== void 0) sceneObject.SetVisibility(primitive.visible);
|
|
1747
1764
|
if (primitive.material !== void 0) sceneObject.SetMaterial(primitive.material);
|
|
1748
|
-
if (primitive.
|
|
1765
|
+
if (primitive.parentId !== void 0) this.setParent(__spreadProps(__spreadValues({}, primitive), { parentId: primitive.parentId }));
|
|
1749
1766
|
}
|
|
1750
1767
|
updateGroup(group) {
|
|
1751
1768
|
let sceneObject = this.GetSceneObject(group);
|
|
@@ -1760,13 +1777,13 @@ var DIVERoot = class extends import_three11.Object3D {
|
|
|
1760
1777
|
if (group.rotation !== void 0) sceneObject.SetRotation(group.rotation);
|
|
1761
1778
|
if (group.scale !== void 0) sceneObject.SetScale(group.scale);
|
|
1762
1779
|
if (group.visible !== void 0) sceneObject.SetVisibility(group.visible);
|
|
1763
|
-
if (group.bbVisible !== void 0) sceneObject.
|
|
1764
|
-
if (group.
|
|
1780
|
+
if (group.bbVisible !== void 0) sceneObject.SetLinesVisibility(group.bbVisible);
|
|
1781
|
+
if (group.parentId !== void 0) this.setParent(__spreadProps(__spreadValues({}, group), { parentId: group.parentId }));
|
|
1765
1782
|
}
|
|
1766
1783
|
deleteLight(light) {
|
|
1767
1784
|
const sceneObject = this.GetSceneObject(light);
|
|
1768
1785
|
if (!sceneObject) {
|
|
1769
|
-
console.warn(`
|
|
1786
|
+
console.warn(`DIVERoot.deleteLight: Light with id ${light.id} not found`);
|
|
1770
1787
|
return;
|
|
1771
1788
|
}
|
|
1772
1789
|
this.detachTransformControls(sceneObject);
|
|
@@ -1775,7 +1792,7 @@ var DIVERoot = class extends import_three11.Object3D {
|
|
|
1775
1792
|
deleteModel(model) {
|
|
1776
1793
|
const sceneObject = this.GetSceneObject(model);
|
|
1777
1794
|
if (!sceneObject) {
|
|
1778
|
-
console.warn(`
|
|
1795
|
+
console.warn(`DIVERoot.deleteModel: Model with id ${model.id} not found`);
|
|
1779
1796
|
return;
|
|
1780
1797
|
}
|
|
1781
1798
|
this.detachTransformControls(sceneObject);
|
|
@@ -1784,7 +1801,7 @@ var DIVERoot = class extends import_three11.Object3D {
|
|
|
1784
1801
|
deletePrimitive(primitive) {
|
|
1785
1802
|
const sceneObject = this.GetSceneObject(primitive);
|
|
1786
1803
|
if (!sceneObject) {
|
|
1787
|
-
console.warn(`
|
|
1804
|
+
console.warn(`DIVERoot.deletePrimitive: Primitive with id ${primitive.id} not found`);
|
|
1788
1805
|
return;
|
|
1789
1806
|
}
|
|
1790
1807
|
this.detachTransformControls(sceneObject);
|
|
@@ -1793,7 +1810,7 @@ var DIVERoot = class extends import_three11.Object3D {
|
|
|
1793
1810
|
deleteGroup(group) {
|
|
1794
1811
|
const sceneObject = this.GetSceneObject(group);
|
|
1795
1812
|
if (!sceneObject) {
|
|
1796
|
-
console.warn(`
|
|
1813
|
+
console.warn(`DIVERoot.deleteGroup: Group with id ${group.id} not found`);
|
|
1797
1814
|
return;
|
|
1798
1815
|
}
|
|
1799
1816
|
this.detachTransformControls(sceneObject);
|
|
@@ -1810,11 +1827,8 @@ var DIVERoot = class extends import_three11.Object3D {
|
|
|
1810
1827
|
setParent(object) {
|
|
1811
1828
|
const sceneObject = this.GetSceneObject(object);
|
|
1812
1829
|
if (!sceneObject) return;
|
|
1813
|
-
if (
|
|
1814
|
-
|
|
1815
|
-
}
|
|
1816
|
-
if (object.parent !== null) {
|
|
1817
|
-
const parent = this.GetSceneObject(object.parent);
|
|
1830
|
+
if (object.parentId !== null) {
|
|
1831
|
+
const parent = this.GetSceneObject({ id: object.parentId });
|
|
1818
1832
|
if (!parent) return;
|
|
1819
1833
|
parent.attach(sceneObject);
|
|
1820
1834
|
} else {
|
|
@@ -2362,6 +2376,70 @@ var DIVEInfo = class {
|
|
|
2362
2376
|
};
|
|
2363
2377
|
DIVEInfo._supportsWebXR = null;
|
|
2364
2378
|
|
|
2379
|
+
// package.json
|
|
2380
|
+
var package_default = {
|
|
2381
|
+
name: "@shopware-ag/dive",
|
|
2382
|
+
version: "1.15.5",
|
|
2383
|
+
description: "Shopware Spatial Framework",
|
|
2384
|
+
type: "module",
|
|
2385
|
+
main: "./build/dive.cjs",
|
|
2386
|
+
module: "./build/dive.js",
|
|
2387
|
+
types: "./build/dive.d.ts",
|
|
2388
|
+
files: [
|
|
2389
|
+
"build",
|
|
2390
|
+
"LICENSE",
|
|
2391
|
+
"package.json",
|
|
2392
|
+
"README.md",
|
|
2393
|
+
"src"
|
|
2394
|
+
],
|
|
2395
|
+
keywords: [
|
|
2396
|
+
"dive",
|
|
2397
|
+
"shopware",
|
|
2398
|
+
"sw6",
|
|
2399
|
+
"three",
|
|
2400
|
+
"three.js",
|
|
2401
|
+
"3d",
|
|
2402
|
+
"typescript"
|
|
2403
|
+
],
|
|
2404
|
+
repository: "git@github.com:shopware/dive.git",
|
|
2405
|
+
author: "ffrank <f.frank@shopware.com>",
|
|
2406
|
+
license: "MIT",
|
|
2407
|
+
browserslist: [
|
|
2408
|
+
"> 1%, not dead, not ie 11, not op_mini all"
|
|
2409
|
+
],
|
|
2410
|
+
dependencies: {
|
|
2411
|
+
"@tweenjs/tween.js": "^23.1.1",
|
|
2412
|
+
lodash: "^4.17.21",
|
|
2413
|
+
three: "^0.163.0",
|
|
2414
|
+
"three-spritetext": "^1.8.2"
|
|
2415
|
+
},
|
|
2416
|
+
devDependencies: {
|
|
2417
|
+
"@eslint/js": "^9.1.1",
|
|
2418
|
+
"@types/jest": "^29.5.12",
|
|
2419
|
+
"@types/lodash": "^4.17.12",
|
|
2420
|
+
"@types/node": "^20.12.7",
|
|
2421
|
+
"@types/three": "^0.163.0",
|
|
2422
|
+
eslint: "^9.1.1",
|
|
2423
|
+
globals: "^15.0.0",
|
|
2424
|
+
jest: "^29.7.0",
|
|
2425
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
2426
|
+
jsdom: "^24.0.0",
|
|
2427
|
+
"ts-jest": "^29.1.2",
|
|
2428
|
+
"ts-node": "^10.9.2",
|
|
2429
|
+
tsup: "^8.0.2",
|
|
2430
|
+
typescript: "^5.4.5",
|
|
2431
|
+
"typescript-eslint": "^7.7.1"
|
|
2432
|
+
},
|
|
2433
|
+
scripts: {
|
|
2434
|
+
build: "tsup && yarn genmd",
|
|
2435
|
+
watch: "tsup --watch",
|
|
2436
|
+
lint: "eslint",
|
|
2437
|
+
unit: "jest",
|
|
2438
|
+
coverage: "jest --coverage",
|
|
2439
|
+
genmd: "node ./scripts/genmd.js"
|
|
2440
|
+
}
|
|
2441
|
+
};
|
|
2442
|
+
|
|
2365
2443
|
// src/math/helper/shift.ts
|
|
2366
2444
|
function shift(value, exponent) {
|
|
2367
2445
|
const subvalues = (value + "e").split("e");
|
|
@@ -2537,7 +2615,7 @@ var DIVE = class _DIVE {
|
|
|
2537
2615
|
console.log(this.scene);
|
|
2538
2616
|
}
|
|
2539
2617
|
};
|
|
2540
|
-
console.log(
|
|
2618
|
+
console.log(`DIVE ${package_default.version} initialized`);
|
|
2541
2619
|
}
|
|
2542
2620
|
Dispose() {
|
|
2543
2621
|
var _a;
|