@shopware-ag/dive 1.6.3 → 1.6.4
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.cjs +29 -7
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.cts +18 -1
- package/build/dive.d.ts +18 -1
- package/build/dive.js +30 -8
- package/build/dive.js.map +1 -1
- package/package.json +1 -1
- package/src/animation/AnimationSystem.ts +8 -4
- package/src/animation/__test__/AnimationSystem.test.ts +9 -2
- package/src/controls/OrbitControls.ts +11 -6
- package/src/controls/__test__/OrbitControls.test.ts +40 -14
- package/src/dive.ts +8 -5
- package/src/mediacreator/__test__/MediaCreator.test.ts +19 -1
- package/src/toolbox/select/__test__/SelectTool.test.ts +27 -1
- package/src/toolbox/transform/__test__/TransformTool.test.ts +26 -1
package/build/dive.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ShadowMapType, ToneMapping, WebGLRenderer, Scene, Camera, PerspectiveCamera, Box3, Vector3Like, Mesh, ColorRepresentation, Object3D, Intersection, Vector2, Raycaster, Vector3 } from 'three';
|
|
2
2
|
import { OrbitControls } from 'three/examples/jsm/Addons.js';
|
|
3
|
+
import { Tween } from '@tweenjs/tween.js';
|
|
3
4
|
import { TransformControls } from 'three/examples/jsm/Addons';
|
|
4
5
|
|
|
5
6
|
type DIVERendererSettings = {
|
|
@@ -87,6 +88,21 @@ declare class DIVEPerspectiveCamera extends PerspectiveCamera {
|
|
|
87
88
|
SetCameraLayer(layer: 'LIVE' | 'EDITOR'): void;
|
|
88
89
|
}
|
|
89
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Updates all animations.
|
|
93
|
+
* DIVE uses Tween.js to handle animations.
|
|
94
|
+
*
|
|
95
|
+
* @module
|
|
96
|
+
*/
|
|
97
|
+
declare class DIVEAnimationSystem {
|
|
98
|
+
private _renderer;
|
|
99
|
+
private _rendererCallbackId;
|
|
100
|
+
constructor(renderer: DIVERenderer);
|
|
101
|
+
Dispose(): void;
|
|
102
|
+
Update(): void;
|
|
103
|
+
Animate<T extends object>(object: T): Tween<T>;
|
|
104
|
+
}
|
|
105
|
+
|
|
90
106
|
type DIVEOrbitControlsSettings = {
|
|
91
107
|
enableDamping: boolean;
|
|
92
108
|
dampingFactor: number;
|
|
@@ -98,6 +114,7 @@ type DIVEOrbitControlsSettings = {
|
|
|
98
114
|
*/
|
|
99
115
|
declare class DIVEOrbitControls extends OrbitControls {
|
|
100
116
|
static readonly DEFAULT_ZOOM_FACTOR = 1;
|
|
117
|
+
private _animationSystem;
|
|
101
118
|
private last;
|
|
102
119
|
private animating;
|
|
103
120
|
private locked;
|
|
@@ -105,7 +122,7 @@ declare class DIVEOrbitControls extends OrbitControls {
|
|
|
105
122
|
private stopRevertLast;
|
|
106
123
|
object: DIVEPerspectiveCamera;
|
|
107
124
|
domElement: HTMLCanvasElement;
|
|
108
|
-
constructor(camera: DIVEPerspectiveCamera, renderer: DIVERenderer, settings?: DIVEOrbitControlsSettings);
|
|
125
|
+
constructor(camera: DIVEPerspectiveCamera, renderer: DIVERenderer, animationSystem: DIVEAnimationSystem, settings?: DIVEOrbitControlsSettings);
|
|
109
126
|
ComputeEncompassingView(bb: Box3): {
|
|
110
127
|
position: Vector3Like;
|
|
111
128
|
target: Vector3Like;
|
package/build/dive.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ShadowMapType, ToneMapping, WebGLRenderer, Scene, Camera, PerspectiveCamera, Box3, Vector3Like, Mesh, ColorRepresentation, Object3D, Intersection, Vector2, Raycaster, Vector3 } from 'three';
|
|
2
2
|
import { OrbitControls } from 'three/examples/jsm/Addons.js';
|
|
3
|
+
import { Tween } from '@tweenjs/tween.js';
|
|
3
4
|
import { TransformControls } from 'three/examples/jsm/Addons';
|
|
4
5
|
|
|
5
6
|
type DIVERendererSettings = {
|
|
@@ -87,6 +88,21 @@ declare class DIVEPerspectiveCamera extends PerspectiveCamera {
|
|
|
87
88
|
SetCameraLayer(layer: 'LIVE' | 'EDITOR'): void;
|
|
88
89
|
}
|
|
89
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Updates all animations.
|
|
93
|
+
* DIVE uses Tween.js to handle animations.
|
|
94
|
+
*
|
|
95
|
+
* @module
|
|
96
|
+
*/
|
|
97
|
+
declare class DIVEAnimationSystem {
|
|
98
|
+
private _renderer;
|
|
99
|
+
private _rendererCallbackId;
|
|
100
|
+
constructor(renderer: DIVERenderer);
|
|
101
|
+
Dispose(): void;
|
|
102
|
+
Update(): void;
|
|
103
|
+
Animate<T extends object>(object: T): Tween<T>;
|
|
104
|
+
}
|
|
105
|
+
|
|
90
106
|
type DIVEOrbitControlsSettings = {
|
|
91
107
|
enableDamping: boolean;
|
|
92
108
|
dampingFactor: number;
|
|
@@ -98,6 +114,7 @@ type DIVEOrbitControlsSettings = {
|
|
|
98
114
|
*/
|
|
99
115
|
declare class DIVEOrbitControls extends OrbitControls {
|
|
100
116
|
static readonly DEFAULT_ZOOM_FACTOR = 1;
|
|
117
|
+
private _animationSystem;
|
|
101
118
|
private last;
|
|
102
119
|
private animating;
|
|
103
120
|
private locked;
|
|
@@ -105,7 +122,7 @@ declare class DIVEOrbitControls extends OrbitControls {
|
|
|
105
122
|
private stopRevertLast;
|
|
106
123
|
object: DIVEPerspectiveCamera;
|
|
107
124
|
domElement: HTMLCanvasElement;
|
|
108
|
-
constructor(camera: DIVEPerspectiveCamera, renderer: DIVERenderer, settings?: DIVEOrbitControlsSettings);
|
|
125
|
+
constructor(camera: DIVEPerspectiveCamera, renderer: DIVERenderer, animationSystem: DIVEAnimationSystem, settings?: DIVEOrbitControlsSettings);
|
|
109
126
|
ComputeEncompassingView(bb: Box3): {
|
|
110
127
|
position: Vector3Like;
|
|
111
128
|
target: Vector3Like;
|
package/build/dive.js
CHANGED
|
@@ -1549,13 +1549,13 @@ init_PerspectiveCamera();
|
|
|
1549
1549
|
// src/controls/OrbitControls.ts
|
|
1550
1550
|
import { OrbitControls } from "three/examples/jsm/Addons.js";
|
|
1551
1551
|
import { MathUtils as MathUtils2, Vector3 as Vector33 } from "three";
|
|
1552
|
-
import { Easing
|
|
1552
|
+
import { Easing } from "@tweenjs/tween.js";
|
|
1553
1553
|
var DIVEOrbitControlsDefaultSettings = {
|
|
1554
1554
|
enableDamping: true,
|
|
1555
1555
|
dampingFactor: 0.04
|
|
1556
1556
|
};
|
|
1557
1557
|
var _DIVEOrbitControls = class _DIVEOrbitControls extends OrbitControls {
|
|
1558
|
-
constructor(camera, renderer, settings = DIVEOrbitControlsDefaultSettings) {
|
|
1558
|
+
constructor(camera, renderer, animationSystem, settings = DIVEOrbitControlsDefaultSettings) {
|
|
1559
1559
|
super(camera, renderer.domElement);
|
|
1560
1560
|
this.last = null;
|
|
1561
1561
|
this.animating = false;
|
|
@@ -1568,6 +1568,7 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends OrbitControls {
|
|
|
1568
1568
|
if (this.locked) return;
|
|
1569
1569
|
this.update();
|
|
1570
1570
|
};
|
|
1571
|
+
this._animationSystem = animationSystem;
|
|
1571
1572
|
this.domElement = renderer.domElement;
|
|
1572
1573
|
this.object = camera;
|
|
1573
1574
|
renderer.AddPreRenderCallback(() => {
|
|
@@ -1611,8 +1612,8 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends OrbitControls {
|
|
|
1611
1612
|
this.animating = duration > 0;
|
|
1612
1613
|
this.locked = lock;
|
|
1613
1614
|
this.enabled = false;
|
|
1614
|
-
const tweenPos =
|
|
1615
|
-
const tweenQuat =
|
|
1615
|
+
const tweenPos = this._animationSystem.Animate(this.object.position).to(toPosition, duration).easing(Easing.Quadratic.Out).start();
|
|
1616
|
+
const tweenQuat = this._animationSystem.Animate(this.target).to(toTarget, duration).easing(Easing.Quadratic.Out).onUpdate(() => {
|
|
1616
1617
|
this.object.lookAt(this.target);
|
|
1617
1618
|
}).onComplete(() => {
|
|
1618
1619
|
this.animating = false;
|
|
@@ -1629,8 +1630,8 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends OrbitControls {
|
|
|
1629
1630
|
this.animating = duration > 0;
|
|
1630
1631
|
this.enabled = false;
|
|
1631
1632
|
const { pos, target } = this.last;
|
|
1632
|
-
const tweenPos =
|
|
1633
|
-
const tweenQuat =
|
|
1633
|
+
const tweenPos = this._animationSystem.Animate(this.object.position).to(pos, duration).easing(Easing.Quadratic.Out).start();
|
|
1634
|
+
const tweenQuat = this._animationSystem.Animate(this.target).to(target, duration).easing(Easing.Quadratic.Out).onUpdate(() => {
|
|
1634
1635
|
this.object.lookAt(this.target);
|
|
1635
1636
|
}).onComplete(() => {
|
|
1636
1637
|
this.animating = false;
|
|
@@ -1724,6 +1725,26 @@ var DIVEToolbox = class {
|
|
|
1724
1725
|
};
|
|
1725
1726
|
DIVEToolbox.DefaultTool = "select";
|
|
1726
1727
|
|
|
1728
|
+
// src/animation/AnimationSystem.ts
|
|
1729
|
+
import { Tween, update as updateTween } from "@tweenjs/tween.js";
|
|
1730
|
+
var DIVEAnimationSystem = class {
|
|
1731
|
+
constructor(renderer) {
|
|
1732
|
+
this._renderer = renderer;
|
|
1733
|
+
this._rendererCallbackId = this._renderer.AddPreRenderCallback(() => {
|
|
1734
|
+
this.Update();
|
|
1735
|
+
});
|
|
1736
|
+
}
|
|
1737
|
+
Dispose() {
|
|
1738
|
+
this._renderer.RemovePreRenderCallback(this._rendererCallbackId);
|
|
1739
|
+
}
|
|
1740
|
+
Update() {
|
|
1741
|
+
updateTween();
|
|
1742
|
+
}
|
|
1743
|
+
Animate(object) {
|
|
1744
|
+
return new Tween(object);
|
|
1745
|
+
}
|
|
1746
|
+
};
|
|
1747
|
+
|
|
1727
1748
|
// src/axiscamera/AxisCamera.ts
|
|
1728
1749
|
init_VisibilityLayerMask();
|
|
1729
1750
|
import { AxesHelper, Color as Color7, Matrix4, OrthographicCamera, Vector4 } from "three";
|
|
@@ -2005,10 +2026,10 @@ var DIVE = class _DIVE {
|
|
|
2005
2026
|
this.renderer = new DIVERenderer(this._settings.renderer);
|
|
2006
2027
|
this.scene = new DIVEScene();
|
|
2007
2028
|
this.perspectiveCamera = new DIVEPerspectiveCamera(this._settings.perspectiveCamera);
|
|
2008
|
-
this.
|
|
2029
|
+
this.animationSystem = new DIVEAnimationSystem(this.renderer);
|
|
2030
|
+
this.orbitControls = new DIVEOrbitControls(this.perspectiveCamera, this.renderer, this.animationSystem, this._settings.orbitControls);
|
|
2009
2031
|
this.toolbox = new DIVEToolbox(this.scene, this.orbitControls);
|
|
2010
2032
|
this.communication = new DIVECommunication(this.renderer, this.scene, this.orbitControls, this.toolbox);
|
|
2011
|
-
this.animationSystem = null;
|
|
2012
2033
|
if (this._settings.displayAxes) {
|
|
2013
2034
|
this.axisCamera = new DIVEAxisCamera(this.renderer, this.scene, this.orbitControls);
|
|
2014
2035
|
} else {
|
|
@@ -2029,6 +2050,7 @@ var DIVE = class _DIVE {
|
|
|
2029
2050
|
this.removeResizeObserver();
|
|
2030
2051
|
this.renderer.Dispose();
|
|
2031
2052
|
(_a = this.axisCamera) == null ? void 0 : _a.Dispose();
|
|
2053
|
+
this.animationSystem.Dispose();
|
|
2032
2054
|
this.toolbox.Dispose();
|
|
2033
2055
|
this.communication.DestroyInstance();
|
|
2034
2056
|
}
|