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