@shopware-ag/dive 1.4.1 → 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 +25 -25
- package/build/dive.cjs +29 -4
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.cts +8 -0
- package/build/dive.d.ts +8 -0
- package/build/dive.js +29 -4
- package/build/dive.js.map +1 -1
- package/package.json +1 -1
- package/src/com/Communication.ts +9 -0
- package/src/com/__test__/Communication.test.ts +10 -0
- package/src/com/actions/index.ts +2 -0
- package/src/com/actions/toolbox/transform/setgizmovisible.ts +4 -0
- package/src/model/Model.ts +6 -0
- package/src/model/__test__/Model.test.ts +9 -0
- package/src/scene/root/modelroot/ModelRoot.ts +1 -1
- package/src/scene/root/modelroot/__test__/ModelRoot.test.ts +1 -0
- package/src/toolbox/BaseTool.ts +2 -2
- package/src/toolbox/Toolbox.ts +4 -0
- package/src/toolbox/__test__/BaseTool.test.ts +6 -0
- package/src/toolbox/__test__/Toolbox.test.ts +8 -0
- package/src/toolbox/select/SelectTool.ts +2 -1
- package/src/toolbox/select/__test__/SelectTool.test.ts +13 -3
- package/src/toolbox/transform/TransformTool.ts +9 -0
- package/src/toolbox/transform/__test__/TransformTool.test.ts +12 -0
package/build/dive.d.cts
CHANGED
|
@@ -376,6 +376,11 @@ interface DROP_IT {
|
|
|
376
376
|
'RETURN': boolean;
|
|
377
377
|
}
|
|
378
378
|
|
|
379
|
+
interface SET_GIZMO_VISIBILITY {
|
|
380
|
+
'PAYLOAD': boolean;
|
|
381
|
+
'RETURN': boolean;
|
|
382
|
+
}
|
|
383
|
+
|
|
379
384
|
type Actions = {
|
|
380
385
|
GET_ALL_SCENE_DATA: GET_ALL_SCENE_DATA;
|
|
381
386
|
GET_ALL_OBJECTS: GET_ALL_OBJECTS;
|
|
@@ -395,6 +400,7 @@ type Actions = {
|
|
|
395
400
|
SET_CAMERA_LAYER: SET_CAMERA_LAYER;
|
|
396
401
|
ZOOM_CAMERA: ZOOM_CAMERA;
|
|
397
402
|
SET_GIZMO_MODE: SET_GIZMO_MODE;
|
|
403
|
+
SET_GIZMO_VISIBILITY: SET_GIZMO_VISIBILITY;
|
|
398
404
|
MODEL_LOADED: MODEL_LOADED;
|
|
399
405
|
UPDATE_SCENE: UPDATE_SCENE;
|
|
400
406
|
GENERATE_MEDIA: GENERATE_MEDIA;
|
|
@@ -473,6 +479,7 @@ declare class DIVEToolbox {
|
|
|
473
479
|
GetActiveTool(): DIVEBaseTool;
|
|
474
480
|
UseTool(tool: string): void;
|
|
475
481
|
SetGizmoMode(mode: 'translate' | 'rotate' | 'scale'): void;
|
|
482
|
+
SetGizmoVisibility(active: boolean): void;
|
|
476
483
|
onPointerMove(e: PointerEvent): void;
|
|
477
484
|
onPointerDown(e: PointerEvent): void;
|
|
478
485
|
onPointerUp(e: PointerEvent): void;
|
|
@@ -547,6 +554,7 @@ declare class DIVECommunication {
|
|
|
547
554
|
private resetCamera;
|
|
548
555
|
private zoomCamera;
|
|
549
556
|
private setGizmoMode;
|
|
557
|
+
private setGizmoVisibility;
|
|
550
558
|
private modelLoaded;
|
|
551
559
|
private updateScene;
|
|
552
560
|
private generateMedia;
|
package/build/dive.d.ts
CHANGED
|
@@ -376,6 +376,11 @@ interface DROP_IT {
|
|
|
376
376
|
'RETURN': boolean;
|
|
377
377
|
}
|
|
378
378
|
|
|
379
|
+
interface SET_GIZMO_VISIBILITY {
|
|
380
|
+
'PAYLOAD': boolean;
|
|
381
|
+
'RETURN': boolean;
|
|
382
|
+
}
|
|
383
|
+
|
|
379
384
|
type Actions = {
|
|
380
385
|
GET_ALL_SCENE_DATA: GET_ALL_SCENE_DATA;
|
|
381
386
|
GET_ALL_OBJECTS: GET_ALL_OBJECTS;
|
|
@@ -395,6 +400,7 @@ type Actions = {
|
|
|
395
400
|
SET_CAMERA_LAYER: SET_CAMERA_LAYER;
|
|
396
401
|
ZOOM_CAMERA: ZOOM_CAMERA;
|
|
397
402
|
SET_GIZMO_MODE: SET_GIZMO_MODE;
|
|
403
|
+
SET_GIZMO_VISIBILITY: SET_GIZMO_VISIBILITY;
|
|
398
404
|
MODEL_LOADED: MODEL_LOADED;
|
|
399
405
|
UPDATE_SCENE: UPDATE_SCENE;
|
|
400
406
|
GENERATE_MEDIA: GENERATE_MEDIA;
|
|
@@ -473,6 +479,7 @@ declare class DIVEToolbox {
|
|
|
473
479
|
GetActiveTool(): DIVEBaseTool;
|
|
474
480
|
UseTool(tool: string): void;
|
|
475
481
|
SetGizmoMode(mode: 'translate' | 'rotate' | 'scale'): void;
|
|
482
|
+
SetGizmoVisibility(active: boolean): void;
|
|
476
483
|
onPointerMove(e: PointerEvent): void;
|
|
477
484
|
onPointerDown(e: PointerEvent): void;
|
|
478
485
|
onPointerUp(e: PointerEvent): void;
|
|
@@ -547,6 +554,7 @@ declare class DIVECommunication {
|
|
|
547
554
|
private resetCamera;
|
|
548
555
|
private zoomCamera;
|
|
549
556
|
private setGizmoMode;
|
|
557
|
+
private setGizmoVisibility;
|
|
550
558
|
private modelLoaded;
|
|
551
559
|
private updateScene;
|
|
552
560
|
private generateMedia;
|
package/build/dive.js
CHANGED
|
@@ -301,6 +301,10 @@ var _DIVECommunication = class _DIVECommunication {
|
|
|
301
301
|
returnValue = this.setGizmoMode(payload);
|
|
302
302
|
break;
|
|
303
303
|
}
|
|
304
|
+
case "SET_GIZMO_VISIBILITY": {
|
|
305
|
+
returnValue = this.setGizmoVisibility(payload);
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
304
308
|
case "MODEL_LOADED": {
|
|
305
309
|
returnValue = this.modelLoaded(payload);
|
|
306
310
|
break;
|
|
@@ -471,6 +475,10 @@ var _DIVECommunication = class _DIVECommunication {
|
|
|
471
475
|
this.toolbox.SetGizmoMode(payload.mode);
|
|
472
476
|
return true;
|
|
473
477
|
}
|
|
478
|
+
setGizmoVisibility(payload) {
|
|
479
|
+
this.toolbox.SetGizmoVisibility(payload);
|
|
480
|
+
return payload;
|
|
481
|
+
}
|
|
474
482
|
modelLoaded(payload) {
|
|
475
483
|
this.registered.get(payload.id).loaded = true;
|
|
476
484
|
return true;
|
|
@@ -706,6 +714,11 @@ var DIVEModel = class extends Object3D5 {
|
|
|
706
714
|
SetScale(scale) {
|
|
707
715
|
this.scale.set(scale.x, scale.y, scale.z);
|
|
708
716
|
}
|
|
717
|
+
SetVisibility(visible) {
|
|
718
|
+
this.traverse((child) => {
|
|
719
|
+
child.visible = visible;
|
|
720
|
+
});
|
|
721
|
+
}
|
|
709
722
|
SetToWorldOrigin() {
|
|
710
723
|
var _a;
|
|
711
724
|
this.position.set(0, 0, 0);
|
|
@@ -820,7 +833,7 @@ var DIVEModelRoot = class extends Object3D6 {
|
|
|
820
833
|
if (object.position !== void 0) sceneObject.SetPosition(object.position);
|
|
821
834
|
if (object.rotation !== void 0) sceneObject.SetRotation(object.rotation);
|
|
822
835
|
if (object.scale !== void 0) sceneObject.SetScale(object.scale);
|
|
823
|
-
if (object.visible !== void 0) sceneObject.
|
|
836
|
+
if (object.visible !== void 0) sceneObject.SetVisibility(object.visible);
|
|
824
837
|
}
|
|
825
838
|
DeleteModel(object) {
|
|
826
839
|
if (object.id === void 0) {
|
|
@@ -1366,8 +1379,8 @@ var DIVEBaseTool = class {
|
|
|
1366
1379
|
onWheel(e) {
|
|
1367
1380
|
}
|
|
1368
1381
|
raycast(objects) {
|
|
1369
|
-
if (objects !== void 0) return this._raycaster.intersectObjects(objects, true);
|
|
1370
|
-
return this._raycaster.intersectObjects(this._scene.children, true);
|
|
1382
|
+
if (objects !== void 0) return this._raycaster.intersectObjects(objects, true).filter((i) => i.object.visible);
|
|
1383
|
+
return this._raycaster.intersectObjects(this._scene.children, true).filter((i) => i.object.visible);
|
|
1371
1384
|
}
|
|
1372
1385
|
pointerWasDragged() {
|
|
1373
1386
|
return this._lastPointerDown.distanceTo(this._pointer) > this.POINTER_DRAG_THRESHOLD;
|
|
@@ -1401,6 +1414,14 @@ var DIVETransformTool = class extends DIVEBaseTool {
|
|
|
1401
1414
|
SetGizmoMode(mode) {
|
|
1402
1415
|
this._gizmo.mode = mode;
|
|
1403
1416
|
}
|
|
1417
|
+
SetGizmoVisibility(active) {
|
|
1418
|
+
const contains = this._scene.children.includes(this._gizmo);
|
|
1419
|
+
if (active && !contains) {
|
|
1420
|
+
this._scene.add(this._gizmo);
|
|
1421
|
+
} else if (!active && contains) {
|
|
1422
|
+
this._scene.remove(this._gizmo);
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1404
1425
|
// public onPointerDown(e: PointerEvent): void {
|
|
1405
1426
|
// super.onPointerDown(e);
|
|
1406
1427
|
// // if (this._hovered) {
|
|
@@ -1435,11 +1456,12 @@ var DIVESelectTool = class extends DIVETransformTool {
|
|
|
1435
1456
|
if ("isMoveable" in selectable) {
|
|
1436
1457
|
const movable = selectable;
|
|
1437
1458
|
this._gizmo.attach(movable);
|
|
1459
|
+
this.SetGizmoVisibility(movable.visible);
|
|
1438
1460
|
}
|
|
1439
1461
|
}
|
|
1440
1462
|
onClick(e) {
|
|
1441
1463
|
super.onClick(e);
|
|
1442
|
-
const first = this._raycaster.intersectObjects(this._scene.Root.children, true)[0];
|
|
1464
|
+
const first = this._raycaster.intersectObjects(this._scene.Root.children, true).filter((intersect) => intersect.object.visible)[0];
|
|
1443
1465
|
const selectable = this.findSelectableInterface(first == null ? void 0 : first.object);
|
|
1444
1466
|
if (!first || !selectable) {
|
|
1445
1467
|
if (this._gizmo.object) {
|
|
@@ -1510,6 +1532,9 @@ var DIVEToolbox = class {
|
|
|
1510
1532
|
SetGizmoMode(mode) {
|
|
1511
1533
|
this.selectTool.SetGizmoMode(mode);
|
|
1512
1534
|
}
|
|
1535
|
+
SetGizmoVisibility(active) {
|
|
1536
|
+
this.selectTool.SetGizmoVisibility(active);
|
|
1537
|
+
}
|
|
1513
1538
|
onPointerMove(e) {
|
|
1514
1539
|
this.activeTool.onPointerMove(e);
|
|
1515
1540
|
}
|