@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/README.md +15 -12
- package/build/dive.cjs +55 -6
- 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 +55 -6
- 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/select/SelectTool.ts +13 -4
- package/src/toolbox/transform/TransformTool.ts +16 -0
- package/src/toolbox/transform/__test__/TransformTool.test.ts +132 -0
package/README.md
CHANGED
|
@@ -162,22 +162,25 @@ In the following you find a list of all available actions to perform on DIVEComm
|
|
|
162
162
|
| Action | Description
|
|
163
163
|
| :--- | :---
|
|
164
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
|
|
165
173
|
| [SET_BACKGROUND](./src/com/actions/scene/setbackground.ts) | Set a background color
|
|
166
|
-
| [
|
|
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)
|
|
167
177
|
| [GET_CAMERA_TRANSFORM](./src/com/actions/camera/getcameratransform.ts) | Return currenty camera transformation
|
|
168
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)
|
|
169
179
|
| [RESET_CAMERA](./src/com/actions/camera/resetcamera.ts) | Reset camera to original position after MOVE_CAMERA was performed
|
|
170
180
|
| [SET_CAMERA_LAYER](./src/com/actions/camera/setcameralayer.ts) | Set camera layer to switch between live view and editor view
|
|
171
|
-
| [SET_CAMERA_TRANSFORM](./src/com/actions/camera/setcameratransform.ts) | Set camera transformation (w/o animation, used to initially set up camera)
|
|
172
181
|
| [ZOOM_CAMERA](./src/com/actions/camera/zoomcamera.ts) | Zoom in or out
|
|
173
|
-
| [GENERATE_MEDIA](./src/com/actions/media/generatemedia.ts) | Generate a screenshot with the specified parameters
|
|
174
|
-
| [MODEL_LOADED](./src/com/actions/object/model/modelloaded.ts) | Is performed when a model file is completely loaded
|
|
175
|
-
| [DROP_IT](./src/com/actions/object/model/dropit.ts) | Places the model onto the nextg underlying object's bounding box
|
|
176
|
-
| [PLACE_ON_FLOOR](./src/com/actions/object/model/placeonfloor.ts) | Set a model onto to the floor
|
|
177
|
-
| [ADD_OBJECT](./src/com/actions/object/addobject.ts) | Add an object to the scene
|
|
178
|
-
| [UPDATE_OBJECT](./src/com/actions/object/updateobject.ts) | Update an existing object
|
|
179
|
-
| [DELETE_OBJECT](./src/com/actions/object/deleteobject.ts) | Delete an existing object
|
|
180
|
-
| [GET_ALL_OBJECTS](./src/com/actions/object/getallobjects.ts) | Return a map of all objects
|
|
181
|
-
| [GET_OBJECTS](./src/com/actions/object/getobjects.ts) | Return a map of all objects (with the opportunity to filter for ids)
|
|
182
|
-
| [SELECT_OBJECT](./src/com/actions/object/selectobject.ts) | Select an existing object in the scene
|
|
183
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
|
+
|
|
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
|
@@ -292,6 +292,10 @@ var _DIVECommunication = class _DIVECommunication {
|
|
|
292
292
|
returnValue = this.selectObject(payload);
|
|
293
293
|
break;
|
|
294
294
|
}
|
|
295
|
+
case "DESELECT_OBJECT": {
|
|
296
|
+
returnValue = this.deselectObject(payload);
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
295
299
|
case "SET_BACKGROUND": {
|
|
296
300
|
returnValue = this.setBackground(payload);
|
|
297
301
|
break;
|
|
@@ -427,7 +431,18 @@ var _DIVECommunication = class _DIVECommunication {
|
|
|
427
431
|
if (!sceneObject) return false;
|
|
428
432
|
if (!("isSelectable" in sceneObject)) return false;
|
|
429
433
|
this.toolbox.UseTool("select");
|
|
430
|
-
this.toolbox.GetActiveTool().
|
|
434
|
+
this.toolbox.GetActiveTool().AttachGizmo(sceneObject);
|
|
435
|
+
Object.assign(payload, object);
|
|
436
|
+
return true;
|
|
437
|
+
}
|
|
438
|
+
deselectObject(payload) {
|
|
439
|
+
const object = this.registered.get(payload.id);
|
|
440
|
+
if (!object) return false;
|
|
441
|
+
const sceneObject = this.scene.GetSceneObject(object);
|
|
442
|
+
if (!sceneObject) return false;
|
|
443
|
+
if (!("isSelectable" in sceneObject)) return false;
|
|
444
|
+
this.toolbox.UseTool("select");
|
|
445
|
+
this.toolbox.GetActiveTool().DetachGizmo();
|
|
431
446
|
Object.assign(payload, object);
|
|
432
447
|
return true;
|
|
433
448
|
}
|
|
@@ -541,7 +556,7 @@ var DIVEPointLight = class extends import_three4.Object3D {
|
|
|
541
556
|
const geometry = new import_three4.SphereGeometry(geoSize, geoSize * 320, geoSize * 320);
|
|
542
557
|
const material = new import_three4.MeshBasicMaterial({ color: this.light.color, transparent: true, opacity: 0.8, side: import_three4.FrontSide });
|
|
543
558
|
this.mesh = new import_three4.Mesh(geometry, material);
|
|
544
|
-
this.mesh.layers.mask =
|
|
559
|
+
this.mesh.layers.mask = UI_LAYER_MASK;
|
|
545
560
|
this.add(this.mesh);
|
|
546
561
|
}
|
|
547
562
|
SetColor(color) {
|
|
@@ -559,6 +574,14 @@ var DIVEPointLight = class extends import_three4.Object3D {
|
|
|
559
574
|
var _a;
|
|
560
575
|
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("UPDATE_OBJECT", { id: this.userData.id, position: this.position });
|
|
561
576
|
}
|
|
577
|
+
onSelect() {
|
|
578
|
+
var _a;
|
|
579
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("SELECT_OBJECT", { id: this.userData.id });
|
|
580
|
+
}
|
|
581
|
+
onDeselect() {
|
|
582
|
+
var _a;
|
|
583
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("DESELECT_OBJECT", { id: this.userData.id });
|
|
584
|
+
}
|
|
562
585
|
};
|
|
563
586
|
|
|
564
587
|
// src/light/SceneLight.ts
|
|
@@ -756,6 +779,14 @@ var DIVEModel = class extends import_three7.Object3D {
|
|
|
756
779
|
var _a;
|
|
757
780
|
(_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 });
|
|
758
781
|
}
|
|
782
|
+
onSelect() {
|
|
783
|
+
var _a;
|
|
784
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("SELECT_OBJECT", { id: this.userData.id });
|
|
785
|
+
}
|
|
786
|
+
onDeselect() {
|
|
787
|
+
var _a;
|
|
788
|
+
(_a = DIVECommunication.get(this.userData.id)) == null ? void 0 : _a.PerformAction("DESELECT_OBJECT", { id: this.userData.id });
|
|
789
|
+
}
|
|
759
790
|
};
|
|
760
791
|
|
|
761
792
|
// src/loadingmanager/LoadingManager.ts
|
|
@@ -1386,6 +1417,18 @@ var DIVETransformTool = class extends DIVEBaseTool {
|
|
|
1386
1417
|
this.name = "DIVETransformTool";
|
|
1387
1418
|
this._gizmo = new import_Addons3.TransformControls(this._controller.object, this._controller.domElement);
|
|
1388
1419
|
this._gizmo.mode = "translate";
|
|
1420
|
+
this._gizmo.addEventListener("mouseDown", () => {
|
|
1421
|
+
controller.enabled = false;
|
|
1422
|
+
});
|
|
1423
|
+
this._gizmo.addEventListener("mouseUp", () => {
|
|
1424
|
+
controller.enabled = true;
|
|
1425
|
+
});
|
|
1426
|
+
this._gizmo.addEventListener("objectChange", () => {
|
|
1427
|
+
if (!this._gizmo.object) return;
|
|
1428
|
+
if (!("isMoveable" in this._gizmo.object)) return;
|
|
1429
|
+
if (!("onMove" in this._gizmo.object)) return;
|
|
1430
|
+
this._gizmo.object.onMove();
|
|
1431
|
+
});
|
|
1389
1432
|
scene.add(this._gizmo);
|
|
1390
1433
|
}
|
|
1391
1434
|
Activate() {
|
|
@@ -1414,15 +1457,21 @@ var DIVESelectTool = class extends DIVETransformTool {
|
|
|
1414
1457
|
}
|
|
1415
1458
|
Select(selectable) {
|
|
1416
1459
|
if (selectable.onSelect) selectable.onSelect();
|
|
1417
|
-
|
|
1418
|
-
const movable = selectable;
|
|
1419
|
-
this._gizmo.attach(movable);
|
|
1420
|
-
}
|
|
1460
|
+
this.AttachGizmo(selectable);
|
|
1421
1461
|
}
|
|
1422
1462
|
Deselect(selectable) {
|
|
1423
1463
|
if (selectable.onDeselect) selectable.onDeselect();
|
|
1464
|
+
this.DetachGizmo();
|
|
1465
|
+
}
|
|
1466
|
+
DetachGizmo() {
|
|
1424
1467
|
this._gizmo.detach();
|
|
1425
1468
|
}
|
|
1469
|
+
AttachGizmo(selectable) {
|
|
1470
|
+
if ("isMoveable" in selectable) {
|
|
1471
|
+
const movable = selectable;
|
|
1472
|
+
this._gizmo.attach(movable);
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1426
1475
|
onClick(e) {
|
|
1427
1476
|
super.onClick(e);
|
|
1428
1477
|
const first = this._raycaster.intersectObjects(this._scene.Root.children, true)[0];
|