@xviewer.js/core 1.0.0-alpha.32 → 1.0.0-alpha.33

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/dist/main.js CHANGED
@@ -1469,7 +1469,7 @@ class VirtualCamera extends Component {
1469
1469
  this.correctPosition = new three.Vector3();
1470
1470
  this.correctRotation = new three.Quaternion();
1471
1471
  this.lookaheadPosition = new three.Vector3();
1472
- this.trackedObjectOffset = new three.Vector3();
1472
+ this.lookAtOffset = new three.Vector3();
1473
1473
  }
1474
1474
  }
1475
1475
  __decorate([
@@ -2639,7 +2639,7 @@ class FreelookVirtualCamera extends VirtualCamera {
2639
2639
  _onMouseWheel(e) {
2640
2640
  const { __worldPos } = FreelookVirtualCamera;
2641
2641
  if (this.lookAt) {
2642
- let dist = __worldPos.copy(this.lookAt.position).add(this.trackedObjectOffset).distanceTo(this.node.position);
2642
+ let dist = __worldPos.copy(this.lookAt.position).add(this.lookAtOffset).distanceTo(this.node.position);
2643
2643
  let distNew = dist + this._distanceDelta;
2644
2644
  if (e.deltaY > 0) {
2645
2645
  distNew *= this._calculateDistanceScale(1 / 0.85);
@@ -2670,7 +2670,7 @@ class FreelookVirtualCamera extends VirtualCamera {
2670
2670
  __loc0.set(touches[rotateTouchID].pageX, touches[rotateTouchID].pageY);
2671
2671
  __loc1.set(touches[rotateTouchID + 1].pageX, touches[rotateTouchID + 1].pageY);
2672
2672
  if (this.lookAt) {
2673
- let dist = __worldPos.copy(this.lookAt.position).add(this.trackedObjectOffset).distanceTo(this.node.position);
2673
+ let dist = __worldPos.copy(this.lookAt.position).add(this.lookAtOffset).distanceTo(this.node.position);
2674
2674
  let distNew = (dist + this._distanceDelta) * this._calculateDistanceScale(this._preLoc0.distanceTo(this._preLoc1) / __loc0.distanceTo(__loc1));
2675
2675
  this._distanceDelta = distNew - dist;
2676
2676
  }
@@ -2725,7 +2725,7 @@ class FreelookVirtualCamera extends VirtualCamera {
2725
2725
  __posDelta.applyQuaternion(__quat);
2726
2726
  __spherical.setFromVector3(__posDelta);
2727
2727
  const { theta, phi, radius } = __spherical;
2728
- __worldPos.copy(this.lookAt.position).add(this.trackedObjectOffset);
2728
+ __worldPos.copy(this.lookAt.position).add(this.lookAtOffset);
2729
2729
  __posDelta.copy(this.node.position).sub(__worldPos);
2730
2730
  __posDelta.applyQuaternion(__quat);
2731
2731
  __spherical.setFromVector3(__posDelta);
@@ -2736,12 +2736,13 @@ class FreelookVirtualCamera extends VirtualCamera {
2736
2736
  this._rotateDelta.y = dy;
2737
2737
  this._distanceDelta = dz;
2738
2738
  this._tempSmoothing = smoothing;
2739
+ this._lookAtOffsetDelta.copy(lookAt).sub(this.lookAt.position).sub(this.lookAtOffset);
2739
2740
  }
2740
2741
  update(dt) {
2741
2742
  if (!this.lookAt) return;
2742
2743
  const dampFactor = exponentialDamp(1, 0, this._tempSmoothing, dt);
2743
- const { __posDelta, __worldPos, __quat, __spherical, __xAxis, __yAxis } = FreelookVirtualCamera;
2744
- __worldPos.copy(this.lookAt.position).add(this.trackedObjectOffset);
2744
+ const { __posDelta, __offsetDelta, __worldPos, __quat, __spherical, __xAxis, __yAxis } = FreelookVirtualCamera;
2745
+ __worldPos.copy(this.lookAt.position).add(this.lookAtOffset);
2745
2746
  if (this._rotateDelta.manhattanLength() + abs(this._distanceDelta) > 0.001) {
2746
2747
  __quat.setFromUnitVectors(this.node.up, three.Object3D.DEFAULT_UP);
2747
2748
  __posDelta.copy(this.node.position).sub(__worldPos);
@@ -2768,13 +2769,17 @@ class FreelookVirtualCamera extends VirtualCamera {
2768
2769
  __yAxis.normalize();
2769
2770
  }
2770
2771
  let length = __posDelta.length() * 2 * tan(degToRad(this.fov * 0.5));
2771
- let trackedObjectOffset = this.trackedObjectOffset;
2772
- trackedObjectOffset.sub(__xAxis.multiplyScalar(this._panDelta.x * length * (1 - dampFactor)));
2773
- trackedObjectOffset.add(__yAxis.multiplyScalar(this._panDelta.y * length * (1 - dampFactor)));
2772
+ let lookAtOffset = this.lookAtOffset;
2773
+ lookAtOffset.sub(__xAxis.multiplyScalar(this._panDelta.x * length * (1 - dampFactor)));
2774
+ lookAtOffset.add(__yAxis.multiplyScalar(this._panDelta.y * length * (1 - dampFactor)));
2774
2775
  this._panDelta.multiplyScalar(dampFactor);
2775
- __worldPos.copy(this.lookAt.position).add(trackedObjectOffset);
2776
+ __worldPos.copy(this.lookAt.position).add(lookAtOffset);
2776
2777
  this.node.position.copy(__posDelta.add(__worldPos));
2777
2778
  }
2779
+ if (this._lookAtOffsetDelta.manhattanLength() > 0.001) {
2780
+ this.lookAtOffset.add(__offsetDelta.copy(this._lookAtOffsetDelta).multiplyScalar(1 - dampFactor));
2781
+ this._lookAtOffsetDelta.multiplyScalar(dampFactor);
2782
+ }
2778
2783
  this.node.lookAt(__worldPos);
2779
2784
  }
2780
2785
  constructor(...args){
@@ -2787,6 +2792,7 @@ class FreelookVirtualCamera extends VirtualCamera {
2787
2792
  this._rotateDelta = new three.Vector2();
2788
2793
  this._panDelta = new three.Vector2();
2789
2794
  this._tempSmoothing = 0;
2795
+ this._lookAtOffsetDelta = new three.Vector3();
2790
2796
  this.forbidX = false;
2791
2797
  this.forbidY = false;
2792
2798
  this.forbidZ = false;
@@ -2818,6 +2824,7 @@ FreelookVirtualCamera.__xAxis = new three.Vector3();
2818
2824
  FreelookVirtualCamera.__yAxis = new three.Vector3();
2819
2825
  FreelookVirtualCamera.__quat = new three.Quaternion();
2820
2826
  FreelookVirtualCamera.__spherical = new three.Spherical();
2827
+ FreelookVirtualCamera.__offsetDelta = new three.Vector3();
2821
2828
  __decorate([
2822
2829
  property({
2823
2830
  dir: "set"