@shopware-ag/dive 1.6.3 → 1.6.5

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 CHANGED
@@ -705,7 +705,7 @@ var _DIVECommunication = class _DIVECommunication {
705
705
  this.registered = /* @__PURE__ */ new Map();
706
706
  // private listeners: { [key: string]: EventListener[] } = {};
707
707
  this.listeners = /* @__PURE__ */ new Map();
708
- this.id = (0, import_MathUtils.generateUUID)();
708
+ this._id = (0, import_MathUtils.generateUUID)();
709
709
  this.renderer = renderer;
710
710
  this.scene = scene;
711
711
  this.controller = controls;
@@ -714,8 +714,13 @@ var _DIVECommunication = class _DIVECommunication {
714
714
  _DIVECommunication.__instances.push(this);
715
715
  }
716
716
  static get(id) {
717
+ const fromComID = this.__instances.find((instance) => instance.id === id);
718
+ if (fromComID) return fromComID;
717
719
  return this.__instances.find((instance) => Array.from(instance.registered.values()).find((object) => object.id === id));
718
720
  }
721
+ get id() {
722
+ return this._id;
723
+ }
719
724
  get mediaGenerator() {
720
725
  if (!this._mediaGenerator) {
721
726
  const DIVEMediaCreator2 = (init_MediaCreator(), __toCommonJS(MediaCreator_exports)).DIVEMediaCreator;
@@ -1577,7 +1582,7 @@ var DIVEOrbitControlsDefaultSettings = {
1577
1582
  dampingFactor: 0.04
1578
1583
  };
1579
1584
  var _DIVEOrbitControls = class _DIVEOrbitControls extends import_Addons3.OrbitControls {
1580
- constructor(camera, renderer, settings = DIVEOrbitControlsDefaultSettings) {
1585
+ constructor(camera, renderer, animationSystem, settings = DIVEOrbitControlsDefaultSettings) {
1581
1586
  super(camera, renderer.domElement);
1582
1587
  this.last = null;
1583
1588
  this.animating = false;
@@ -1586,18 +1591,28 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_Addons3.OrbitCo
1586
1591
  };
1587
1592
  this.stopRevertLast = () => {
1588
1593
  };
1594
+ this._removePreRenderCallback = () => {
1595
+ };
1589
1596
  this.preRenderCallback = () => {
1590
1597
  if (this.locked) return;
1591
1598
  this.update();
1592
1599
  };
1600
+ this._animationSystem = animationSystem;
1593
1601
  this.domElement = renderer.domElement;
1594
1602
  this.object = camera;
1595
- renderer.AddPreRenderCallback(() => {
1603
+ const id = renderer.AddPreRenderCallback(() => {
1596
1604
  this.preRenderCallback();
1597
1605
  });
1606
+ this._removePreRenderCallback = () => {
1607
+ renderer.RemovePreRenderCallback(id);
1608
+ };
1598
1609
  this.enableDamping = settings.enableDamping;
1599
1610
  this.dampingFactor = settings.dampingFactor;
1600
1611
  }
1612
+ Dispose() {
1613
+ this._removePreRenderCallback();
1614
+ this.dispose();
1615
+ }
1601
1616
  ComputeEncompassingView(bb) {
1602
1617
  const center = bb.getCenter(new import_three14.Vector3());
1603
1618
  const size = bb.getSize(new import_three14.Vector3());
@@ -1633,8 +1648,8 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_Addons3.OrbitCo
1633
1648
  this.animating = duration > 0;
1634
1649
  this.locked = lock;
1635
1650
  this.enabled = false;
1636
- const tweenPos = new import_tween.Tween(this.object.position).to(toPosition, duration).easing(import_tween.Easing.Quadratic.Out).start();
1637
- const tweenQuat = new import_tween.Tween(this.target).to(toTarget, duration).easing(import_tween.Easing.Quadratic.Out).onUpdate(() => {
1651
+ const tweenPos = this._animationSystem.Animate(this.object.position).to(toPosition, duration).easing(import_tween.Easing.Quadratic.Out).start();
1652
+ const tweenQuat = this._animationSystem.Animate(this.target).to(toTarget, duration).easing(import_tween.Easing.Quadratic.Out).onUpdate(() => {
1638
1653
  this.object.lookAt(this.target);
1639
1654
  }).onComplete(() => {
1640
1655
  this.animating = false;
@@ -1651,8 +1666,8 @@ var _DIVEOrbitControls = class _DIVEOrbitControls extends import_Addons3.OrbitCo
1651
1666
  this.animating = duration > 0;
1652
1667
  this.enabled = false;
1653
1668
  const { pos, target } = this.last;
1654
- const tweenPos = new import_tween.Tween(this.object.position).to(pos, duration).easing(import_tween.Easing.Quadratic.Out).start();
1655
- const tweenQuat = new import_tween.Tween(this.target).to(target, duration).easing(import_tween.Easing.Quadratic.Out).onUpdate(() => {
1669
+ const tweenPos = this._animationSystem.Animate(this.object.position).to(pos, duration).easing(import_tween.Easing.Quadratic.Out).start();
1670
+ const tweenQuat = this._animationSystem.Animate(this.target).to(target, duration).easing(import_tween.Easing.Quadratic.Out).onUpdate(() => {
1656
1671
  this.object.lookAt(this.target);
1657
1672
  }).onComplete(() => {
1658
1673
  this.animating = false;
@@ -1746,6 +1761,26 @@ var DIVEToolbox = class {
1746
1761
  };
1747
1762
  DIVEToolbox.DefaultTool = "select";
1748
1763
 
1764
+ // src/animation/AnimationSystem.ts
1765
+ var import_tween2 = require("@tweenjs/tween.js");
1766
+ var DIVEAnimationSystem = class {
1767
+ constructor(renderer) {
1768
+ this._renderer = renderer;
1769
+ this._rendererCallbackId = this._renderer.AddPreRenderCallback(() => {
1770
+ this.Update();
1771
+ });
1772
+ }
1773
+ Dispose() {
1774
+ this._renderer.RemovePreRenderCallback(this._rendererCallbackId);
1775
+ }
1776
+ Update() {
1777
+ (0, import_tween2.update)();
1778
+ }
1779
+ Animate(object) {
1780
+ return new import_tween2.Tween(object);
1781
+ }
1782
+ };
1783
+
1749
1784
  // src/axiscamera/AxisCamera.ts
1750
1785
  var import_three15 = require("three");
1751
1786
  var import_three_spritetext = __toESM(require("three-spritetext"), 1);
@@ -2027,10 +2062,10 @@ var DIVE = class _DIVE {
2027
2062
  this.renderer = new DIVERenderer(this._settings.renderer);
2028
2063
  this.scene = new DIVEScene();
2029
2064
  this.perspectiveCamera = new DIVEPerspectiveCamera(this._settings.perspectiveCamera);
2030
- this.orbitControls = new DIVEOrbitControls(this.perspectiveCamera, this.renderer, this._settings.orbitControls);
2065
+ this.animationSystem = new DIVEAnimationSystem(this.renderer);
2066
+ this.orbitControls = new DIVEOrbitControls(this.perspectiveCamera, this.renderer, this.animationSystem, this._settings.orbitControls);
2031
2067
  this.toolbox = new DIVEToolbox(this.scene, this.orbitControls);
2032
2068
  this.communication = new DIVECommunication(this.renderer, this.scene, this.orbitControls, this.toolbox);
2033
- this.animationSystem = null;
2034
2069
  if (this._settings.displayAxes) {
2035
2070
  this.axisCamera = new DIVEAxisCamera(this.renderer, this.scene, this.orbitControls);
2036
2071
  } else {
@@ -2050,7 +2085,9 @@ var DIVE = class _DIVE {
2050
2085
  var _a;
2051
2086
  this.removeResizeObserver();
2052
2087
  this.renderer.Dispose();
2088
+ this.orbitControls.Dispose();
2053
2089
  (_a = this.axisCamera) == null ? void 0 : _a.Dispose();
2090
+ this.animationSystem.Dispose();
2054
2091
  this.toolbox.Dispose();
2055
2092
  this.communication.DestroyInstance();
2056
2093
  }