@shopware-ag/dive 1.3.2 → 1.4.1
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 +15 -12
- package/build/dive.cjs +67 -14
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.cts +9 -0
- package/build/dive.d.ts +9 -0
- package/build/dive.js +67 -14
- package/build/dive.js.map +1 -1
- package/package.json +1 -1
- package/src/__test__/DIVE.test.ts +1 -0
- package/src/com/Communication.ts +23 -1
- package/src/com/__test__/Communication.test.ts +31 -3
- package/src/com/actions/index.ts +2 -0
- package/src/com/actions/object/deselectobject.ts +6 -0
- package/src/light/PointLight.ts +10 -2
- package/src/light/__test__/PointLight.test.ts +18 -0
- package/src/model/Model.ts +8 -0
- package/src/model/__test__/Model.test.ts +20 -0
- package/src/toolbox/Toolbox.ts +13 -8
- package/src/toolbox/select/SelectTool.ts +13 -4
- package/src/toolbox/transform/TransformTool.ts +16 -0
- package/src/toolbox/transform/__test__/TransformTool.test.ts +132 -0
package/build/dive.d.cts
CHANGED
|
@@ -354,6 +354,13 @@ interface SELECT_OBJECT {
|
|
|
354
354
|
'RETURN': boolean;
|
|
355
355
|
}
|
|
356
356
|
|
|
357
|
+
interface DESELECT_OBJECT {
|
|
358
|
+
'PAYLOAD': Partial<COMEntity> & {
|
|
359
|
+
id: string;
|
|
360
|
+
};
|
|
361
|
+
'RETURN': boolean;
|
|
362
|
+
}
|
|
363
|
+
|
|
357
364
|
interface GET_CAMERA_TRANSFORM {
|
|
358
365
|
'PAYLOAD': object;
|
|
359
366
|
'RETURN': {
|
|
@@ -377,6 +384,7 @@ type Actions = {
|
|
|
377
384
|
UPDATE_OBJECT: UPDATE_OBJECT;
|
|
378
385
|
DELETE_OBJECT: DELETE_OBJECT;
|
|
379
386
|
SELECT_OBJECT: SELECT_OBJECT;
|
|
387
|
+
DESELECT_OBJECT: DESELECT_OBJECT;
|
|
380
388
|
SET_BACKGROUND: SET_BACKGROUND;
|
|
381
389
|
DROP_IT: DROP_IT;
|
|
382
390
|
PLACE_ON_FLOOR: PLACE_ON_FLOOR;
|
|
@@ -528,6 +536,7 @@ declare class DIVECommunication {
|
|
|
528
536
|
private updateObject;
|
|
529
537
|
private deleteObject;
|
|
530
538
|
private selectObject;
|
|
539
|
+
private deselectObject;
|
|
531
540
|
private setBackground;
|
|
532
541
|
private dropIt;
|
|
533
542
|
private placeOnFloor;
|
package/build/dive.d.ts
CHANGED
|
@@ -354,6 +354,13 @@ interface SELECT_OBJECT {
|
|
|
354
354
|
'RETURN': boolean;
|
|
355
355
|
}
|
|
356
356
|
|
|
357
|
+
interface DESELECT_OBJECT {
|
|
358
|
+
'PAYLOAD': Partial<COMEntity> & {
|
|
359
|
+
id: string;
|
|
360
|
+
};
|
|
361
|
+
'RETURN': boolean;
|
|
362
|
+
}
|
|
363
|
+
|
|
357
364
|
interface GET_CAMERA_TRANSFORM {
|
|
358
365
|
'PAYLOAD': object;
|
|
359
366
|
'RETURN': {
|
|
@@ -377,6 +384,7 @@ type Actions = {
|
|
|
377
384
|
UPDATE_OBJECT: UPDATE_OBJECT;
|
|
378
385
|
DELETE_OBJECT: DELETE_OBJECT;
|
|
379
386
|
SELECT_OBJECT: SELECT_OBJECT;
|
|
387
|
+
DESELECT_OBJECT: DESELECT_OBJECT;
|
|
380
388
|
SET_BACKGROUND: SET_BACKGROUND;
|
|
381
389
|
DROP_IT: DROP_IT;
|
|
382
390
|
PLACE_ON_FLOOR: PLACE_ON_FLOOR;
|
|
@@ -528,6 +536,7 @@ declare class DIVECommunication {
|
|
|
528
536
|
private updateObject;
|
|
529
537
|
private deleteObject;
|
|
530
538
|
private selectObject;
|
|
539
|
+
private deselectObject;
|
|
531
540
|
private setBackground;
|
|
532
541
|
private dropIt;
|
|
533
542
|
private placeOnFloor;
|
package/build/dive.js
CHANGED
|
@@ -257,6 +257,10 @@ var _DIVECommunication = class _DIVECommunication {
|
|
|
257
257
|
returnValue = this.selectObject(payload);
|
|
258
258
|
break;
|
|
259
259
|
}
|
|
260
|
+
case "DESELECT_OBJECT": {
|
|
261
|
+
returnValue = this.deselectObject(payload);
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
260
264
|
case "SET_BACKGROUND": {
|
|
261
265
|
returnValue = this.setBackground(payload);
|
|
262
266
|
break;
|
|
@@ -392,7 +396,18 @@ var _DIVECommunication = class _DIVECommunication {
|
|
|
392
396
|
if (!sceneObject) return false;
|
|
393
397
|
if (!("isSelectable" in sceneObject)) return false;
|
|
394
398
|
this.toolbox.UseTool("select");
|
|
395
|
-
this.toolbox.GetActiveTool().
|
|
399
|
+
this.toolbox.GetActiveTool().AttachGizmo(sceneObject);
|
|
400
|
+
Object.assign(payload, object);
|
|
401
|
+
return true;
|
|
402
|
+
}
|
|
403
|
+
deselectObject(payload) {
|
|
404
|
+
const object = this.registered.get(payload.id);
|
|
405
|
+
if (!object) return false;
|
|
406
|
+
const sceneObject = this.scene.GetSceneObject(object);
|
|
407
|
+
if (!sceneObject) return false;
|
|
408
|
+
if (!("isSelectable" in sceneObject)) return false;
|
|
409
|
+
this.toolbox.UseTool("select");
|
|
410
|
+
this.toolbox.GetActiveTool().DetachGizmo();
|
|
396
411
|
Object.assign(payload, object);
|
|
397
412
|
return true;
|
|
398
413
|
}
|
|
@@ -506,7 +521,7 @@ var DIVEPointLight = class extends Object3D2 {
|
|
|
506
521
|
const geometry = new SphereGeometry(geoSize, geoSize * 320, geoSize * 320);
|
|
507
522
|
const material = new MeshBasicMaterial({ color: this.light.color, transparent: true, opacity: 0.8, side: FrontSide });
|
|
508
523
|
this.mesh = new Mesh(geometry, material);
|
|
509
|
-
this.mesh.layers.mask =
|
|
524
|
+
this.mesh.layers.mask = UI_LAYER_MASK;
|
|
510
525
|
this.add(this.mesh);
|
|
511
526
|
}
|
|
512
527
|
SetColor(color) {
|
|
@@ -524,6 +539,14 @@ var DIVEPointLight = class extends Object3D2 {
|
|
|
524
539
|
var _a;
|
|
525
540
|
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("UPDATE_OBJECT", { id: this.userData.id, position: this.position });
|
|
526
541
|
}
|
|
542
|
+
onSelect() {
|
|
543
|
+
var _a;
|
|
544
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("SELECT_OBJECT", { id: this.userData.id });
|
|
545
|
+
}
|
|
546
|
+
onDeselect() {
|
|
547
|
+
var _a;
|
|
548
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("DESELECT_OBJECT", { id: this.userData.id });
|
|
549
|
+
}
|
|
527
550
|
};
|
|
528
551
|
|
|
529
552
|
// src/light/SceneLight.ts
|
|
@@ -721,6 +744,14 @@ var DIVEModel = class extends Object3D5 {
|
|
|
721
744
|
var _a;
|
|
722
745
|
(_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 });
|
|
723
746
|
}
|
|
747
|
+
onSelect() {
|
|
748
|
+
var _a;
|
|
749
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("SELECT_OBJECT", { id: this.userData.id });
|
|
750
|
+
}
|
|
751
|
+
onDeselect() {
|
|
752
|
+
var _a;
|
|
753
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("DESELECT_OBJECT", { id: this.userData.id });
|
|
754
|
+
}
|
|
724
755
|
};
|
|
725
756
|
|
|
726
757
|
// src/loadingmanager/LoadingManager.ts
|
|
@@ -1351,6 +1382,18 @@ var DIVETransformTool = class extends DIVEBaseTool {
|
|
|
1351
1382
|
this.name = "DIVETransformTool";
|
|
1352
1383
|
this._gizmo = new TransformControls(this._controller.object, this._controller.domElement);
|
|
1353
1384
|
this._gizmo.mode = "translate";
|
|
1385
|
+
this._gizmo.addEventListener("mouseDown", () => {
|
|
1386
|
+
controller.enabled = false;
|
|
1387
|
+
});
|
|
1388
|
+
this._gizmo.addEventListener("mouseUp", () => {
|
|
1389
|
+
controller.enabled = true;
|
|
1390
|
+
});
|
|
1391
|
+
this._gizmo.addEventListener("objectChange", () => {
|
|
1392
|
+
if (!this._gizmo.object) return;
|
|
1393
|
+
if (!("isMoveable" in this._gizmo.object)) return;
|
|
1394
|
+
if (!("onMove" in this._gizmo.object)) return;
|
|
1395
|
+
this._gizmo.object.onMove();
|
|
1396
|
+
});
|
|
1354
1397
|
scene.add(this._gizmo);
|
|
1355
1398
|
}
|
|
1356
1399
|
Activate() {
|
|
@@ -1379,15 +1422,21 @@ var DIVESelectTool = class extends DIVETransformTool {
|
|
|
1379
1422
|
}
|
|
1380
1423
|
Select(selectable) {
|
|
1381
1424
|
if (selectable.onSelect) selectable.onSelect();
|
|
1382
|
-
|
|
1383
|
-
const movable = selectable;
|
|
1384
|
-
this._gizmo.attach(movable);
|
|
1385
|
-
}
|
|
1425
|
+
this.AttachGizmo(selectable);
|
|
1386
1426
|
}
|
|
1387
1427
|
Deselect(selectable) {
|
|
1388
1428
|
if (selectable.onDeselect) selectable.onDeselect();
|
|
1429
|
+
this.DetachGizmo();
|
|
1430
|
+
}
|
|
1431
|
+
DetachGizmo() {
|
|
1389
1432
|
this._gizmo.detach();
|
|
1390
1433
|
}
|
|
1434
|
+
AttachGizmo(selectable) {
|
|
1435
|
+
if ("isMoveable" in selectable) {
|
|
1436
|
+
const movable = selectable;
|
|
1437
|
+
this._gizmo.attach(movable);
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1391
1440
|
onClick(e) {
|
|
1392
1441
|
super.onClick(e);
|
|
1393
1442
|
const first = this._raycaster.intersectObjects(this._scene.Root.children, true)[0];
|
|
@@ -1422,15 +1471,19 @@ var DIVEToolbox = class {
|
|
|
1422
1471
|
this.removeListenersCallback = () => {
|
|
1423
1472
|
};
|
|
1424
1473
|
this.selectTool = new DIVESelectTool(scene, controller);
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1474
|
+
const pointerMove = this.onPointerMove.bind(this);
|
|
1475
|
+
const pointerDown = this.onPointerDown.bind(this);
|
|
1476
|
+
const pointerUp = this.onPointerUp.bind(this);
|
|
1477
|
+
const wheel = this.onWheel.bind(this);
|
|
1478
|
+
controller.domElement.addEventListener("pointermove", pointerMove);
|
|
1479
|
+
controller.domElement.addEventListener("pointerdown", pointerDown);
|
|
1480
|
+
controller.domElement.addEventListener("pointerup", pointerUp);
|
|
1481
|
+
controller.domElement.addEventListener("wheel", wheel);
|
|
1429
1482
|
this.removeListenersCallback = () => {
|
|
1430
|
-
controller.domElement.removeEventListener("pointermove",
|
|
1431
|
-
controller.domElement.removeEventListener("pointerdown",
|
|
1432
|
-
controller.domElement.removeEventListener("pointerup",
|
|
1433
|
-
controller.domElement.removeEventListener("wheel",
|
|
1483
|
+
controller.domElement.removeEventListener("pointermove", pointerMove);
|
|
1484
|
+
controller.domElement.removeEventListener("pointerdown", pointerDown);
|
|
1485
|
+
controller.domElement.removeEventListener("pointerup", pointerUp);
|
|
1486
|
+
controller.domElement.removeEventListener("wheel", wheel);
|
|
1434
1487
|
};
|
|
1435
1488
|
this.activeTool = this.selectTool;
|
|
1436
1489
|
this.activeTool.Activate();
|