@shopware-ag/dive 1.3.2 → 1.4.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/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().Select(sceneObject);
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 = HELPER_LAYER_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
- if ("isMoveable" in selectable) {
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];