@shopware-ag/dive 1.4.2 → 1.5.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 CHANGED
@@ -159,27 +159,28 @@ unsubscribe(); // <-- execute unsubscribe callback when done
159
159
 
160
160
  In the following you find a list of all available actions to perform on DIVECommunication class via `com.PerformAction()`.
161
161
 
162
- | Action | Description
163
- | :--- | :---
164
- | [GET_ALL_SCENE_DATA](./src/com/actions/scene/getallscenedata.ts) | Return all scene data that is currently set
165
- | [GET_ALL_OBJECTS](./src/com/actions/object/getallobjects.ts) | Return a map of all objects
166
- | [GET_OBJECTS](./src/com/actions/object/getobjects.ts) | Return an array of all objects with given ids
167
- | [PLACE_ON_FLOOR](./src/com/actions/object/model/placeonfloor.ts) | Set a model onto to the floor
168
- | [ADD_OBJECT](./src/com/actions/object/addobject.ts) | Add an object to the scene
169
- | [UPDATE_OBJECT](./src/com/actions/object/updateobject.ts) | Update an existing object
170
- | [DELETE_OBJECT](./src/com/actions/object/deleteobject.ts) | Delete an existing object
171
- | [SELECT_OBJECT](./src/com/actions/object/selectobject.ts) | Select an existing object in the scene
172
- | [DESELECT_OBJECT](./src/com/actions/object/deselectobject.ts) | Deselect an existing object in the scene
173
- | [SET_BACKGROUND](./src/com/actions/scene/setbackground.ts) | Set a background color
174
- | [DROP_IT](./src/com/actions/object/model/dropit.ts) | Places the model onto the next underlying object's bounding box
175
- | [PLACE_ON_FLOOR](./src/com/actions/object/model/placeonfloor.ts) | Places the model onto the floor (zero plane)
176
- | [SET_CAMERA_TRANSFORM](./src/com/actions/camera/setcameratransform.ts) | Set camera transformation (w/o animation, used to initially set up camera)
177
- | [GET_CAMERA_TRANSFORM](./src/com/actions/camera/getcameratransform.ts) | Return currenty camera transformation
178
- | [MOVE_CAMERA](./src/com/actions/camera/movecamera.ts) | Move camera to a specific position or the position of a previously defined POV (with an animation)
179
- | [RESET_CAMERA](./src/com/actions/camera/resetcamera.ts) | Reset camera to original position after MOVE_CAMERA was performed
180
- | [SET_CAMERA_LAYER](./src/com/actions/camera/setcameralayer.ts) | Set camera layer to switch between live view and editor view
181
- | [ZOOM_CAMERA](./src/com/actions/camera/zoomcamera.ts) | Zoom in or out
182
- | [SET_GIZMO_MODE](./src/com/actions/toolbox/select/setgizmomode.ts) | Set gizmo mode
183
- | [MODEL_LOADED](./src/com/actions/object/model/modelloaded.ts) | Is performed when a model file is completely loaded
184
- | [UPDATE_SCENE](./src/com/actions/scene/updatescene.ts) | Update scene data
185
- | [GENERATE_MEDIA](./src/com/actions/media/generatemedia.ts) | Generate a screenshot with the specified parameters
162
+ | Action | Description
163
+ |:-------------------------------------------------------------------------------| :---
164
+ | [GET_ALL_SCENE_DATA](./src/com/actions/scene/getallscenedata.ts) | Return all scene data that is currently set
165
+ | [GET_ALL_OBJECTS](./src/com/actions/object/getallobjects.ts) | Return a map of all objects
166
+ | [GET_OBJECTS](./src/com/actions/object/getobjects.ts) | Return an array of all objects with given ids
167
+ | [PLACE_ON_FLOOR](./src/com/actions/object/model/placeonfloor.ts) | Set a model onto to the floor
168
+ | [ADD_OBJECT](./src/com/actions/object/addobject.ts) | Add an object to the scene
169
+ | [UPDATE_OBJECT](./src/com/actions/object/updateobject.ts) | Update an existing object
170
+ | [DELETE_OBJECT](./src/com/actions/object/deleteobject.ts) | Delete an existing object
171
+ | [SELECT_OBJECT](./src/com/actions/object/selectobject.ts) | Select an existing object in the scene
172
+ | [DESELECT_OBJECT](./src/com/actions/object/deselectobject.ts) | Deselect an existing object in the scene
173
+ | [SET_BACKGROUND](./src/com/actions/scene/setbackground.ts) | Set a background color
174
+ | [DROP_IT](./src/com/actions/object/model/dropit.ts) | Places the model onto the next underlying object's bounding box
175
+ | [PLACE_ON_FLOOR](./src/com/actions/object/model/placeonfloor.ts) | Places the model onto the floor (zero plane)
176
+ | [SET_CAMERA_TRANSFORM](./src/com/actions/camera/setcameratransform.ts) | Set camera transformation (w/o animation, used to initially set up camera)
177
+ | [GET_CAMERA_TRANSFORM](./src/com/actions/camera/getcameratransform.ts) | Return currenty camera transformation
178
+ | [MOVE_CAMERA](./src/com/actions/camera/movecamera.ts) | Move camera to a specific position or the position of a previously defined POV (with an animation)
179
+ | [RESET_CAMERA](./src/com/actions/camera/resetcamera.ts) | Reset camera to original position after MOVE_CAMERA was performed
180
+ | [SET_CAMERA_LAYER](./src/com/actions/camera/setcameralayer.ts) | Set camera layer to switch between live view and editor view
181
+ | [ZOOM_CAMERA](./src/com/actions/camera/zoomcamera.ts) | Zoom in or out
182
+ | [SET_GIZMO_MODE](./src/com/actions/toolbox/select/setgizmomode.ts) | Set gizmo mode
183
+ | [SET_GIZMO_VISIBILITY](./src/com/actions/toolbox/select/setgizmovisibility.ts) | Set gizmo visibility
184
+ | [MODEL_LOADED](./src/com/actions/object/model/modelloaded.ts) | Is performed when a model file is completely loaded
185
+ | [UPDATE_SCENE](./src/com/actions/scene/updatescene.ts) | Update scene data
186
+ | [GENERATE_MEDIA](./src/com/actions/media/generatemedia.ts) | Generate a screenshot with the specified parameters
package/build/dive.cjs CHANGED
@@ -336,6 +336,10 @@ var _DIVECommunication = class _DIVECommunication {
336
336
  returnValue = this.setGizmoMode(payload);
337
337
  break;
338
338
  }
339
+ case "SET_GIZMO_VISIBILITY": {
340
+ returnValue = this.setGizmoVisibility(payload);
341
+ break;
342
+ }
339
343
  case "MODEL_LOADED": {
340
344
  returnValue = this.modelLoaded(payload);
341
345
  break;
@@ -506,6 +510,10 @@ var _DIVECommunication = class _DIVECommunication {
506
510
  this.toolbox.SetGizmoMode(payload.mode);
507
511
  return true;
508
512
  }
513
+ setGizmoVisibility(payload) {
514
+ this.toolbox.SetGizmoVisibility(payload);
515
+ return payload;
516
+ }
509
517
  modelLoaded(payload) {
510
518
  this.registered.get(payload.id).loaded = true;
511
519
  return true;
@@ -741,6 +749,11 @@ var DIVEModel = class extends import_three7.Object3D {
741
749
  SetScale(scale) {
742
750
  this.scale.set(scale.x, scale.y, scale.z);
743
751
  }
752
+ SetVisibility(visible) {
753
+ this.traverse((child) => {
754
+ child.visible = visible;
755
+ });
756
+ }
744
757
  SetToWorldOrigin() {
745
758
  var _a;
746
759
  this.position.set(0, 0, 0);
@@ -855,7 +868,7 @@ var DIVEModelRoot = class extends import_three8.Object3D {
855
868
  if (object.position !== void 0) sceneObject.SetPosition(object.position);
856
869
  if (object.rotation !== void 0) sceneObject.SetRotation(object.rotation);
857
870
  if (object.scale !== void 0) sceneObject.SetScale(object.scale);
858
- if (object.visible !== void 0) sceneObject.visible = object.visible;
871
+ if (object.visible !== void 0) sceneObject.SetVisibility(object.visible);
859
872
  }
860
873
  DeleteModel(object) {
861
874
  if (object.id === void 0) {
@@ -1401,8 +1414,8 @@ var DIVEBaseTool = class {
1401
1414
  onWheel(e) {
1402
1415
  }
1403
1416
  raycast(objects) {
1404
- if (objects !== void 0) return this._raycaster.intersectObjects(objects, true);
1405
- return this._raycaster.intersectObjects(this._scene.children, true);
1417
+ if (objects !== void 0) return this._raycaster.intersectObjects(objects, true).filter((i) => i.object.visible);
1418
+ return this._raycaster.intersectObjects(this._scene.children, true).filter((i) => i.object.visible);
1406
1419
  }
1407
1420
  pointerWasDragged() {
1408
1421
  return this._lastPointerDown.distanceTo(this._pointer) > this.POINTER_DRAG_THRESHOLD;
@@ -1436,6 +1449,14 @@ var DIVETransformTool = class extends DIVEBaseTool {
1436
1449
  SetGizmoMode(mode) {
1437
1450
  this._gizmo.mode = mode;
1438
1451
  }
1452
+ SetGizmoVisibility(active) {
1453
+ const contains = this._scene.children.includes(this._gizmo);
1454
+ if (active && !contains) {
1455
+ this._scene.add(this._gizmo);
1456
+ } else if (!active && contains) {
1457
+ this._scene.remove(this._gizmo);
1458
+ }
1459
+ }
1439
1460
  // public onPointerDown(e: PointerEvent): void {
1440
1461
  // super.onPointerDown(e);
1441
1462
  // // if (this._hovered) {
@@ -1470,11 +1491,12 @@ var DIVESelectTool = class extends DIVETransformTool {
1470
1491
  if ("isMoveable" in selectable) {
1471
1492
  const movable = selectable;
1472
1493
  this._gizmo.attach(movable);
1494
+ this.SetGizmoVisibility(movable.visible);
1473
1495
  }
1474
1496
  }
1475
1497
  onClick(e) {
1476
1498
  super.onClick(e);
1477
- const first = this._raycaster.intersectObjects(this._scene.Root.children, true)[0];
1499
+ const first = this._raycaster.intersectObjects(this._scene.Root.children, true).filter((intersect) => intersect.object.visible)[0];
1478
1500
  const selectable = this.findSelectableInterface(first == null ? void 0 : first.object);
1479
1501
  if (!first || !selectable) {
1480
1502
  if (this._gizmo.object) {
@@ -1545,6 +1567,9 @@ var DIVEToolbox = class {
1545
1567
  SetGizmoMode(mode) {
1546
1568
  this.selectTool.SetGizmoMode(mode);
1547
1569
  }
1570
+ SetGizmoVisibility(active) {
1571
+ this.selectTool.SetGizmoVisibility(active);
1572
+ }
1548
1573
  onPointerMove(e) {
1549
1574
  this.activeTool.onPointerMove(e);
1550
1575
  }