@shopware-ag/dive 1.1.2 → 1.3.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 +1 -0
- package/build/dive.cjs +333 -60
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.cts +73 -6
- package/build/dive.d.ts +73 -6
- package/build/dive.js +335 -62
- package/build/dive.js.map +1 -1
- package/package.json +1 -1
- package/src/__test__/DIVE.test.ts +2 -0
- package/src/com/Communication.ts +21 -3
- package/src/com/__test__/Communication.test.ts +44 -6
- package/src/com/actions/index.ts +2 -0
- package/src/com/actions/object/getobjects.ts +2 -2
- package/src/com/actions/object/model/dropit.ts +4 -0
- package/src/dive.ts +7 -0
- package/src/gizmo/Gizmo.ts +130 -0
- package/src/gizmo/handles/AxisHandle.ts +124 -0
- package/src/gizmo/handles/RadialHandle.ts +119 -0
- package/src/gizmo/handles/ScaleHandle.ts +152 -0
- package/src/gizmo/plane/GizmoPlane.ts +85 -0
- package/src/gizmo/rotate/RotateGizmo.ts +95 -0
- package/src/gizmo/scale/ScaleGizmo.ts +97 -0
- package/src/gizmo/translate/TranslateGizmo.ts +88 -0
- package/src/helper/findSceneRecursive/__test__/findSceneRecursive.test.ts +40 -0
- package/src/helper/findSceneRecursive/findSceneRecursive.ts +16 -0
- package/src/interface/Draggable.ts +34 -0
- package/src/interface/Hoverable.ts +33 -0
- package/src/interface/Moveable.ts +0 -2
- package/src/interface/Selectable.ts +6 -0
- package/src/interface/__test__/Interfaces.test.ts +56 -0
- package/src/math/index.ts +3 -0
- package/src/math/signedAngleTo/__test__/signedAngleTo.test.ts +14 -0
- package/src/math/signedAngleTo/signedAngleTo.ts +13 -0
- package/src/model/Model.ts +35 -1
- package/src/model/__test__/Model.test.ts +141 -8
- package/src/scene/root/lightroot/LightRoot.ts +17 -3
- package/src/scene/root/lightroot/__test__/LightRoot.test.ts +12 -3
- package/src/scene/root/modelroot/ModelRoot.ts +17 -3
- package/src/scene/root/modelroot/__test__/ModelRoot.test.ts +13 -14
- package/src/toolbox/BaseTool.ts +254 -4
- package/src/toolbox/Toolbox.ts +6 -0
- package/src/toolbox/__test__/BaseTool.test.ts +389 -0
- package/src/toolbox/__test__/Toolbox.test.ts +8 -0
- package/src/toolbox/select/SelectTool.ts +29 -65
- package/src/toolbox/select/__test__/SelectTool.test.ts +57 -25
- package/src/toolbox/transform/TransformTool.ts +48 -0
- /package/src/helper/getObjectDelta/__test__/{getObjectDelta.spec.ts → getObjectDelta.test.ts} +0 -0
package/build/dive.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ShadowMapType, ToneMapping, WebGLRenderer, Scene, Camera, PerspectiveCamera, Vector3Like, Mesh, ColorRepresentation, Object3D } from 'three';
|
|
1
|
+
import { ShadowMapType, ToneMapping, WebGLRenderer, Scene, Camera, PerspectiveCamera, Vector3Like, Mesh, ColorRepresentation, Object3D, Intersection, Vector2, Raycaster, Vector3 } from 'three';
|
|
2
2
|
import { OrbitControls } from 'three/examples/jsm/Addons.js';
|
|
3
3
|
|
|
4
4
|
type DIVERendererSettings = {
|
|
@@ -272,10 +272,9 @@ interface GET_ALL_OBJECTS {
|
|
|
272
272
|
|
|
273
273
|
interface GET_OBJECTS {
|
|
274
274
|
'PAYLOAD': {
|
|
275
|
-
|
|
276
|
-
ids?: string[];
|
|
275
|
+
ids: string[];
|
|
277
276
|
};
|
|
278
|
-
'RETURN':
|
|
277
|
+
'RETURN': COMEntity[];
|
|
279
278
|
}
|
|
280
279
|
|
|
281
280
|
interface ADD_OBJECT {
|
|
@@ -363,6 +362,13 @@ interface GET_CAMERA_TRANSFORM {
|
|
|
363
362
|
};
|
|
364
363
|
}
|
|
365
364
|
|
|
365
|
+
interface DROP_IT {
|
|
366
|
+
'PAYLOAD': {
|
|
367
|
+
id: string;
|
|
368
|
+
};
|
|
369
|
+
'RETURN': boolean;
|
|
370
|
+
}
|
|
371
|
+
|
|
366
372
|
type Actions = {
|
|
367
373
|
GET_ALL_SCENE_DATA: GET_ALL_SCENE_DATA;
|
|
368
374
|
GET_ALL_OBJECTS: GET_ALL_OBJECTS;
|
|
@@ -372,6 +378,7 @@ type Actions = {
|
|
|
372
378
|
DELETE_OBJECT: DELETE_OBJECT;
|
|
373
379
|
SELECT_OBJECT: SELECT_OBJECT;
|
|
374
380
|
SET_BACKGROUND: SET_BACKGROUND;
|
|
381
|
+
DROP_IT: DROP_IT;
|
|
375
382
|
PLACE_ON_FLOOR: PLACE_ON_FLOOR;
|
|
376
383
|
SET_CAMERA_TRANSFORM: SET_CAMERA_TRANSFORM;
|
|
377
384
|
GET_CAMERA_TRANSFORM: GET_CAMERA_TRANSFORM;
|
|
@@ -385,14 +392,62 @@ type Actions = {
|
|
|
385
392
|
GENERATE_MEDIA: GENERATE_MEDIA;
|
|
386
393
|
};
|
|
387
394
|
|
|
395
|
+
interface DIVEDraggable {
|
|
396
|
+
isDraggable: true;
|
|
397
|
+
onDragStart?: (e: DraggableEvent) => void;
|
|
398
|
+
onDrag?: (e: DraggableEvent) => void;
|
|
399
|
+
onDragEnd?: (e: DraggableEvent) => void;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
interface DIVEHoverable {
|
|
403
|
+
isHoverable: true;
|
|
404
|
+
onPointerEnter?: (i: Intersection) => void;
|
|
405
|
+
onPointerOver?: (i: Intersection) => void;
|
|
406
|
+
onPointerLeave?: () => void;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
type DraggableEvent = {
|
|
410
|
+
dragStart: Vector3;
|
|
411
|
+
dragCurrent: Vector3;
|
|
412
|
+
dragEnd: Vector3;
|
|
413
|
+
dragDelta: Vector3;
|
|
414
|
+
};
|
|
388
415
|
declare abstract class DIVEBaseTool {
|
|
389
|
-
|
|
390
|
-
|
|
416
|
+
readonly POINTER_DRAG_THRESHOLD: number;
|
|
417
|
+
name: string;
|
|
418
|
+
protected _canvas: HTMLElement;
|
|
419
|
+
protected _scene: DIVEScene;
|
|
420
|
+
protected _controller: DIVEOrbitControls;
|
|
421
|
+
protected _pointer: Vector2;
|
|
422
|
+
protected get _pointerAnyDown(): boolean;
|
|
423
|
+
protected _pointerPrimaryDown: boolean;
|
|
424
|
+
protected _pointerMiddleDown: boolean;
|
|
425
|
+
protected _pointerSecondaryDown: boolean;
|
|
426
|
+
protected _lastPointerDown: Vector2;
|
|
427
|
+
protected _lastPointerUp: Vector2;
|
|
428
|
+
protected _raycaster: Raycaster;
|
|
429
|
+
protected _intersects: Intersection[];
|
|
430
|
+
protected _hovered: (Object3D & DIVEHoverable) | null;
|
|
431
|
+
protected _dragging: boolean;
|
|
432
|
+
protected _dragStart: Vector3;
|
|
433
|
+
protected _dragCurrent: Vector3;
|
|
434
|
+
protected _dragEnd: Vector3;
|
|
435
|
+
protected _dragDelta: Vector3;
|
|
436
|
+
protected _draggable: DIVEDraggable | null;
|
|
437
|
+
protected _dragRaycastOnObjects: Object3D[] | null;
|
|
438
|
+
protected constructor(scene: DIVEScene, controller: DIVEOrbitControls);
|
|
391
439
|
Activate(): void;
|
|
392
440
|
Deactivate(): void;
|
|
393
441
|
onPointerDown(e: PointerEvent): void;
|
|
442
|
+
onDragStart(e: PointerEvent): void;
|
|
443
|
+
onPointerMove(e: PointerEvent): void;
|
|
444
|
+
onDrag(e: PointerEvent): void;
|
|
394
445
|
onPointerUp(e: PointerEvent): void;
|
|
446
|
+
onClick(e: PointerEvent): void;
|
|
447
|
+
onDragEnd(e: PointerEvent): void;
|
|
395
448
|
onWheel(e: WheelEvent): void;
|
|
449
|
+
protected raycast(objects?: Object3D[]): Intersection[];
|
|
450
|
+
private pointerWasDragged;
|
|
396
451
|
}
|
|
397
452
|
|
|
398
453
|
/**
|
|
@@ -410,6 +465,7 @@ declare class DIVEToolbox {
|
|
|
410
465
|
GetActiveTool(): DIVEBaseTool;
|
|
411
466
|
UseTool(tool: string): void;
|
|
412
467
|
SetGizmoMode(mode: 'translate' | 'rotate' | 'scale'): void;
|
|
468
|
+
onPointerMove(e: PointerEvent): void;
|
|
413
469
|
onPointerDown(e: PointerEvent): void;
|
|
414
470
|
onPointerUp(e: PointerEvent): void;
|
|
415
471
|
onWheel(e: WheelEvent): void;
|
|
@@ -473,6 +529,7 @@ declare class DIVECommunication {
|
|
|
473
529
|
private deleteObject;
|
|
474
530
|
private selectObject;
|
|
475
531
|
private setBackground;
|
|
532
|
+
private dropIt;
|
|
476
533
|
private placeOnFloor;
|
|
477
534
|
private setCameraTransform;
|
|
478
535
|
private getCameraTransform;
|
|
@@ -492,6 +549,15 @@ declare function floorExp(number: number, decimals?: number): number;
|
|
|
492
549
|
|
|
493
550
|
declare function roundExponential(number: number, decimals?: number): number;
|
|
494
551
|
|
|
552
|
+
/**
|
|
553
|
+
* Calculate the signed angle between two vectors. Only works when the vectors are on the same plane.
|
|
554
|
+
* @param vecB Start Vector
|
|
555
|
+
* @param vecA Target Vector
|
|
556
|
+
* @param planeNormal The vector's plane normal
|
|
557
|
+
* @returns Signed angle in radians
|
|
558
|
+
*/
|
|
559
|
+
declare function signedAngleTo(vecA: Vector3, vecB: Vector3, planeNormal: Vector3): number;
|
|
560
|
+
|
|
495
561
|
declare function toFixedExp(number: number, decimals?: number): string;
|
|
496
562
|
|
|
497
563
|
declare function truncateExp(number: number, decimals?: number): number;
|
|
@@ -502,6 +568,7 @@ declare const DIVEMath: {
|
|
|
502
568
|
roundExp: typeof roundExponential;
|
|
503
569
|
toFixedExp: typeof toFixedExp;
|
|
504
570
|
truncateExp: typeof truncateExp;
|
|
571
|
+
signedAngleTo: typeof signedAngleTo;
|
|
505
572
|
};
|
|
506
573
|
|
|
507
574
|
type DIVESettings = {
|
package/build/dive.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ShadowMapType, ToneMapping, WebGLRenderer, Scene, Camera, PerspectiveCamera, Vector3Like, Mesh, ColorRepresentation, Object3D } from 'three';
|
|
1
|
+
import { ShadowMapType, ToneMapping, WebGLRenderer, Scene, Camera, PerspectiveCamera, Vector3Like, Mesh, ColorRepresentation, Object3D, Intersection, Vector2, Raycaster, Vector3 } from 'three';
|
|
2
2
|
import { OrbitControls } from 'three/examples/jsm/Addons.js';
|
|
3
3
|
|
|
4
4
|
type DIVERendererSettings = {
|
|
@@ -272,10 +272,9 @@ interface GET_ALL_OBJECTS {
|
|
|
272
272
|
|
|
273
273
|
interface GET_OBJECTS {
|
|
274
274
|
'PAYLOAD': {
|
|
275
|
-
|
|
276
|
-
ids?: string[];
|
|
275
|
+
ids: string[];
|
|
277
276
|
};
|
|
278
|
-
'RETURN':
|
|
277
|
+
'RETURN': COMEntity[];
|
|
279
278
|
}
|
|
280
279
|
|
|
281
280
|
interface ADD_OBJECT {
|
|
@@ -363,6 +362,13 @@ interface GET_CAMERA_TRANSFORM {
|
|
|
363
362
|
};
|
|
364
363
|
}
|
|
365
364
|
|
|
365
|
+
interface DROP_IT {
|
|
366
|
+
'PAYLOAD': {
|
|
367
|
+
id: string;
|
|
368
|
+
};
|
|
369
|
+
'RETURN': boolean;
|
|
370
|
+
}
|
|
371
|
+
|
|
366
372
|
type Actions = {
|
|
367
373
|
GET_ALL_SCENE_DATA: GET_ALL_SCENE_DATA;
|
|
368
374
|
GET_ALL_OBJECTS: GET_ALL_OBJECTS;
|
|
@@ -372,6 +378,7 @@ type Actions = {
|
|
|
372
378
|
DELETE_OBJECT: DELETE_OBJECT;
|
|
373
379
|
SELECT_OBJECT: SELECT_OBJECT;
|
|
374
380
|
SET_BACKGROUND: SET_BACKGROUND;
|
|
381
|
+
DROP_IT: DROP_IT;
|
|
375
382
|
PLACE_ON_FLOOR: PLACE_ON_FLOOR;
|
|
376
383
|
SET_CAMERA_TRANSFORM: SET_CAMERA_TRANSFORM;
|
|
377
384
|
GET_CAMERA_TRANSFORM: GET_CAMERA_TRANSFORM;
|
|
@@ -385,14 +392,62 @@ type Actions = {
|
|
|
385
392
|
GENERATE_MEDIA: GENERATE_MEDIA;
|
|
386
393
|
};
|
|
387
394
|
|
|
395
|
+
interface DIVEDraggable {
|
|
396
|
+
isDraggable: true;
|
|
397
|
+
onDragStart?: (e: DraggableEvent) => void;
|
|
398
|
+
onDrag?: (e: DraggableEvent) => void;
|
|
399
|
+
onDragEnd?: (e: DraggableEvent) => void;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
interface DIVEHoverable {
|
|
403
|
+
isHoverable: true;
|
|
404
|
+
onPointerEnter?: (i: Intersection) => void;
|
|
405
|
+
onPointerOver?: (i: Intersection) => void;
|
|
406
|
+
onPointerLeave?: () => void;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
type DraggableEvent = {
|
|
410
|
+
dragStart: Vector3;
|
|
411
|
+
dragCurrent: Vector3;
|
|
412
|
+
dragEnd: Vector3;
|
|
413
|
+
dragDelta: Vector3;
|
|
414
|
+
};
|
|
388
415
|
declare abstract class DIVEBaseTool {
|
|
389
|
-
|
|
390
|
-
|
|
416
|
+
readonly POINTER_DRAG_THRESHOLD: number;
|
|
417
|
+
name: string;
|
|
418
|
+
protected _canvas: HTMLElement;
|
|
419
|
+
protected _scene: DIVEScene;
|
|
420
|
+
protected _controller: DIVEOrbitControls;
|
|
421
|
+
protected _pointer: Vector2;
|
|
422
|
+
protected get _pointerAnyDown(): boolean;
|
|
423
|
+
protected _pointerPrimaryDown: boolean;
|
|
424
|
+
protected _pointerMiddleDown: boolean;
|
|
425
|
+
protected _pointerSecondaryDown: boolean;
|
|
426
|
+
protected _lastPointerDown: Vector2;
|
|
427
|
+
protected _lastPointerUp: Vector2;
|
|
428
|
+
protected _raycaster: Raycaster;
|
|
429
|
+
protected _intersects: Intersection[];
|
|
430
|
+
protected _hovered: (Object3D & DIVEHoverable) | null;
|
|
431
|
+
protected _dragging: boolean;
|
|
432
|
+
protected _dragStart: Vector3;
|
|
433
|
+
protected _dragCurrent: Vector3;
|
|
434
|
+
protected _dragEnd: Vector3;
|
|
435
|
+
protected _dragDelta: Vector3;
|
|
436
|
+
protected _draggable: DIVEDraggable | null;
|
|
437
|
+
protected _dragRaycastOnObjects: Object3D[] | null;
|
|
438
|
+
protected constructor(scene: DIVEScene, controller: DIVEOrbitControls);
|
|
391
439
|
Activate(): void;
|
|
392
440
|
Deactivate(): void;
|
|
393
441
|
onPointerDown(e: PointerEvent): void;
|
|
442
|
+
onDragStart(e: PointerEvent): void;
|
|
443
|
+
onPointerMove(e: PointerEvent): void;
|
|
444
|
+
onDrag(e: PointerEvent): void;
|
|
394
445
|
onPointerUp(e: PointerEvent): void;
|
|
446
|
+
onClick(e: PointerEvent): void;
|
|
447
|
+
onDragEnd(e: PointerEvent): void;
|
|
395
448
|
onWheel(e: WheelEvent): void;
|
|
449
|
+
protected raycast(objects?: Object3D[]): Intersection[];
|
|
450
|
+
private pointerWasDragged;
|
|
396
451
|
}
|
|
397
452
|
|
|
398
453
|
/**
|
|
@@ -410,6 +465,7 @@ declare class DIVEToolbox {
|
|
|
410
465
|
GetActiveTool(): DIVEBaseTool;
|
|
411
466
|
UseTool(tool: string): void;
|
|
412
467
|
SetGizmoMode(mode: 'translate' | 'rotate' | 'scale'): void;
|
|
468
|
+
onPointerMove(e: PointerEvent): void;
|
|
413
469
|
onPointerDown(e: PointerEvent): void;
|
|
414
470
|
onPointerUp(e: PointerEvent): void;
|
|
415
471
|
onWheel(e: WheelEvent): void;
|
|
@@ -473,6 +529,7 @@ declare class DIVECommunication {
|
|
|
473
529
|
private deleteObject;
|
|
474
530
|
private selectObject;
|
|
475
531
|
private setBackground;
|
|
532
|
+
private dropIt;
|
|
476
533
|
private placeOnFloor;
|
|
477
534
|
private setCameraTransform;
|
|
478
535
|
private getCameraTransform;
|
|
@@ -492,6 +549,15 @@ declare function floorExp(number: number, decimals?: number): number;
|
|
|
492
549
|
|
|
493
550
|
declare function roundExponential(number: number, decimals?: number): number;
|
|
494
551
|
|
|
552
|
+
/**
|
|
553
|
+
* Calculate the signed angle between two vectors. Only works when the vectors are on the same plane.
|
|
554
|
+
* @param vecB Start Vector
|
|
555
|
+
* @param vecA Target Vector
|
|
556
|
+
* @param planeNormal The vector's plane normal
|
|
557
|
+
* @returns Signed angle in radians
|
|
558
|
+
*/
|
|
559
|
+
declare function signedAngleTo(vecA: Vector3, vecB: Vector3, planeNormal: Vector3): number;
|
|
560
|
+
|
|
495
561
|
declare function toFixedExp(number: number, decimals?: number): string;
|
|
496
562
|
|
|
497
563
|
declare function truncateExp(number: number, decimals?: number): number;
|
|
@@ -502,6 +568,7 @@ declare const DIVEMath: {
|
|
|
502
568
|
roundExp: typeof roundExponential;
|
|
503
569
|
toFixedExp: typeof toFixedExp;
|
|
504
570
|
truncateExp: typeof truncateExp;
|
|
571
|
+
signedAngleTo: typeof signedAngleTo;
|
|
505
572
|
};
|
|
506
573
|
|
|
507
574
|
type DIVESettings = {
|