@xviewer.js/core 1.0.0-alpha.31 → 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 +72 -94
- package/dist/main.js.map +1 -1
- package/dist/module.js +72 -94
- package/dist/module.js.map +1 -1
- package/package.json +1 -1
- package/types/cinestation/FreelookVirtualCamera.d.ts +6 -11
- package/types/cinestation/VirtualCamera.d.ts +1 -1
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.
|
|
1472
|
+
this.lookAtOffset = new three.Vector3();
|
|
1473
1473
|
}
|
|
1474
1474
|
}
|
|
1475
1475
|
__decorate([
|
|
@@ -2584,11 +2584,10 @@ Perlin._Permutation = [
|
|
|
2584
2584
|
|
|
2585
2585
|
const { clamp, degToRad } = three.MathUtils;
|
|
2586
2586
|
const { abs, tan } = Math;
|
|
2587
|
-
const VCamFreeLookMode = {
|
|
2588
|
-
FREE: 0,
|
|
2589
|
-
TRANSLATE: 1
|
|
2590
|
-
};
|
|
2591
2587
|
class FreelookVirtualCamera extends VirtualCamera {
|
|
2588
|
+
printInfo() {
|
|
2589
|
+
console.log(this.node.position, this.lookAt.position);
|
|
2590
|
+
}
|
|
2592
2591
|
onEnable() {
|
|
2593
2592
|
this.viewer.on(DeviceInput.POINTER_DOWN, this._onPointerDown, this);
|
|
2594
2593
|
this.viewer.on(DeviceInput.POINTER_UP, this._onPointerUp, this);
|
|
@@ -2613,14 +2612,6 @@ class FreelookVirtualCamera extends VirtualCamera {
|
|
|
2613
2612
|
this._panDelta.set(0, 0);
|
|
2614
2613
|
this._distanceDelta = 0;
|
|
2615
2614
|
}
|
|
2616
|
-
gotoPOI(position, lookAt, duration = 1, easing = Easing.Quadratic.InOut) {
|
|
2617
|
-
this.viewer.killTweensOf(this._tweenPOI);
|
|
2618
|
-
this.viewer.tween(this._tweenPOI).to({
|
|
2619
|
-
position,
|
|
2620
|
-
lookAt,
|
|
2621
|
-
trackedObjectOffset: Vector3_ZERO
|
|
2622
|
-
}, duration).easing(easing).start();
|
|
2623
|
-
}
|
|
2624
2615
|
_onPointerDown(e) {
|
|
2625
2616
|
if (SystemInfo.isMobile) return;
|
|
2626
2617
|
this._button = e.button;
|
|
@@ -2632,21 +2623,23 @@ class FreelookVirtualCamera extends VirtualCamera {
|
|
|
2632
2623
|
}
|
|
2633
2624
|
_onPointerMove(e) {
|
|
2634
2625
|
if (SystemInfo.isMobile) return;
|
|
2635
|
-
|
|
2626
|
+
const { __loc0, __moveDelta } = FreelookVirtualCamera;
|
|
2627
|
+
__loc0.set(e.pageX, e.pageY);
|
|
2636
2628
|
switch(this._button){
|
|
2637
2629
|
case 0:
|
|
2638
|
-
this._rotateDelta.add(this._calculateRotateDelta(
|
|
2630
|
+
this._rotateDelta.add(this._calculateRotateDelta(__moveDelta, this._preLoc0, __loc0));
|
|
2639
2631
|
break;
|
|
2640
2632
|
case 1:
|
|
2641
2633
|
case 2:
|
|
2642
|
-
this._panDelta.add(this._calculatePanDelta(
|
|
2634
|
+
this._panDelta.add(this._calculatePanDelta(__moveDelta, this._preLoc0, __loc0));
|
|
2643
2635
|
break;
|
|
2644
2636
|
}
|
|
2645
|
-
this._preLoc0.copy(
|
|
2637
|
+
this._preLoc0.copy(__loc0);
|
|
2646
2638
|
}
|
|
2647
2639
|
_onMouseWheel(e) {
|
|
2640
|
+
const { __worldPos } = FreelookVirtualCamera;
|
|
2648
2641
|
if (this.lookAt) {
|
|
2649
|
-
let dist =
|
|
2642
|
+
let dist = __worldPos.copy(this.lookAt.position).add(this.lookAtOffset).distanceTo(this.node.position);
|
|
2650
2643
|
let distNew = dist + this._distanceDelta;
|
|
2651
2644
|
if (e.deltaY > 0) {
|
|
2652
2645
|
distNew *= this._calculateDistanceScale(1 / 0.85);
|
|
@@ -2677,11 +2670,13 @@ class FreelookVirtualCamera extends VirtualCamera {
|
|
|
2677
2670
|
__loc0.set(touches[rotateTouchID].pageX, touches[rotateTouchID].pageY);
|
|
2678
2671
|
__loc1.set(touches[rotateTouchID + 1].pageX, touches[rotateTouchID + 1].pageY);
|
|
2679
2672
|
if (this.lookAt) {
|
|
2680
|
-
let dist = __worldPos.copy(this.lookAt.position).add(this.
|
|
2673
|
+
let dist = __worldPos.copy(this.lookAt.position).add(this.lookAtOffset).distanceTo(this.node.position);
|
|
2681
2674
|
let distNew = (dist + this._distanceDelta) * this._calculateDistanceScale(this._preLoc0.distanceTo(this._preLoc1) / __loc0.distanceTo(__loc1));
|
|
2682
2675
|
this._distanceDelta = distNew - dist;
|
|
2683
2676
|
}
|
|
2684
|
-
|
|
2677
|
+
__preCenter.copy(this._preLoc0).add(this._preLoc1).multiplyScalar(0.5);
|
|
2678
|
+
__center.copy(__loc0).add(__loc1).multiplyScalar(0.5);
|
|
2679
|
+
this._panDelta.add(this._calculatePanDelta(__moveDelta, __preCenter, __center));
|
|
2685
2680
|
this._preLoc0.copy(__loc0);
|
|
2686
2681
|
this._preLoc1.copy(__loc1);
|
|
2687
2682
|
} else if (touches.length > rotateTouchID) {
|
|
@@ -2708,6 +2703,7 @@ class FreelookVirtualCamera extends VirtualCamera {
|
|
|
2708
2703
|
if (this.forbidY) {
|
|
2709
2704
|
out.y = 0;
|
|
2710
2705
|
}
|
|
2706
|
+
this._tempSmoothing = this.smoothing;
|
|
2711
2707
|
return out;
|
|
2712
2708
|
}
|
|
2713
2709
|
_calculatePanDelta(out, loc0, loc1) {
|
|
@@ -2719,51 +2715,52 @@ class FreelookVirtualCamera extends VirtualCamera {
|
|
|
2719
2715
|
if (this.forbidPanY) {
|
|
2720
2716
|
out.y = 0;
|
|
2721
2717
|
}
|
|
2718
|
+
this._tempSmoothing = this.smoothing;
|
|
2722
2719
|
return out;
|
|
2723
2720
|
}
|
|
2721
|
+
gotoPOI(position, lookAt, smoothing = 1) {
|
|
2722
|
+
const { __posDelta, __worldPos, __quat, __spherical } = FreelookVirtualCamera;
|
|
2723
|
+
__quat.setFromUnitVectors(this.node.up, three.Object3D.DEFAULT_UP);
|
|
2724
|
+
__posDelta.copy(position).sub(lookAt);
|
|
2725
|
+
__posDelta.applyQuaternion(__quat);
|
|
2726
|
+
__spherical.setFromVector3(__posDelta);
|
|
2727
|
+
const { theta, phi, radius } = __spherical;
|
|
2728
|
+
__worldPos.copy(this.lookAt.position).add(this.lookAtOffset);
|
|
2729
|
+
__posDelta.copy(this.node.position).sub(__worldPos);
|
|
2730
|
+
__posDelta.applyQuaternion(__quat);
|
|
2731
|
+
__spherical.setFromVector3(__posDelta);
|
|
2732
|
+
const dx = theta - __spherical.theta;
|
|
2733
|
+
const dy = phi - __spherical.phi;
|
|
2734
|
+
const dz = radius - __spherical.radius;
|
|
2735
|
+
this._rotateDelta.x = -dx;
|
|
2736
|
+
this._rotateDelta.y = dy;
|
|
2737
|
+
this._distanceDelta = dz;
|
|
2738
|
+
this._tempSmoothing = smoothing;
|
|
2739
|
+
this._lookAtOffsetDelta.copy(lookAt).sub(this.lookAt.position).sub(this.lookAtOffset);
|
|
2740
|
+
}
|
|
2724
2741
|
update(dt) {
|
|
2725
2742
|
if (!this.lookAt) return;
|
|
2726
|
-
const
|
|
2727
|
-
__worldPos
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
__posDelta.setFromSpherical(__spherical);
|
|
2746
|
-
__posDelta.applyQuaternion(__quat.invert());
|
|
2747
|
-
this.node.position.copy(__posDelta.add(__worldPos));
|
|
2748
|
-
}
|
|
2749
|
-
break;
|
|
2750
|
-
case VCamFreeLookMode.TRANSLATE:
|
|
2751
|
-
if (abs(this._distanceDelta) > 0.001) {
|
|
2752
|
-
__posDelta.copy(this.node.position).sub(this.lookAt.position);
|
|
2753
|
-
let dampFactor = quarticDamp(1, 0, this.rotateSmoothing, dt);
|
|
2754
|
-
let dist0 = __posDelta.length();
|
|
2755
|
-
this._distanceDelta = clamp(dist0 + this._distanceDelta, this.distanceMin, this.distanceMax) - dist0;
|
|
2756
|
-
let dist = dist0 + this._distanceDelta * (1 - dampFactor);
|
|
2757
|
-
this._distanceDelta *= dampFactor;
|
|
2758
|
-
let pos = __posDelta.normalize().multiplyScalar(dist).add(this.lookAt.position);
|
|
2759
|
-
__posOffset.copy(pos).sub(this.node.position);
|
|
2760
|
-
this.trackedObjectOffset.add(__posOffset);
|
|
2761
|
-
this.node.position.copy(pos);
|
|
2762
|
-
__worldPos.copy(this.lookAt.position).add(this.trackedObjectOffset);
|
|
2763
|
-
}
|
|
2764
|
-
break;
|
|
2743
|
+
const dampFactor = exponentialDamp(1, 0, this._tempSmoothing, dt);
|
|
2744
|
+
const { __posDelta, __offsetDelta, __worldPos, __quat, __spherical, __xAxis, __yAxis } = FreelookVirtualCamera;
|
|
2745
|
+
__worldPos.copy(this.lookAt.position).add(this.lookAtOffset);
|
|
2746
|
+
if (this._rotateDelta.manhattanLength() + abs(this._distanceDelta) > 0.001) {
|
|
2747
|
+
__quat.setFromUnitVectors(this.node.up, three.Object3D.DEFAULT_UP);
|
|
2748
|
+
__posDelta.copy(this.node.position).sub(__worldPos);
|
|
2749
|
+
__posDelta.applyQuaternion(__quat);
|
|
2750
|
+
__spherical.setFromVector3(__posDelta);
|
|
2751
|
+
this._rotateDelta.x = __spherical.theta - clamp(__spherical.theta - this._rotateDelta.x, this.thetaMin, this.thetaMax);
|
|
2752
|
+
__spherical.theta = __spherical.theta - this._rotateDelta.x * (1 - dampFactor);
|
|
2753
|
+
this._rotateDelta.y = clamp(__spherical.phi + this._rotateDelta.y, this.phiMin, this.phiMax) - __spherical.phi;
|
|
2754
|
+
__spherical.phi = clamp(__spherical.phi + this._rotateDelta.y * (1 - dampFactor), 0.001, Math.PI - 0.001);
|
|
2755
|
+
this._distanceDelta = clamp(__spherical.radius + this._distanceDelta, this.distanceMin, this.distanceMax) - __spherical.radius;
|
|
2756
|
+
__spherical.radius = __spherical.radius + this._distanceDelta * (1 - dampFactor);
|
|
2757
|
+
this._rotateDelta.multiplyScalar(dampFactor);
|
|
2758
|
+
this._distanceDelta *= dampFactor;
|
|
2759
|
+
__posDelta.setFromSpherical(__spherical);
|
|
2760
|
+
__posDelta.applyQuaternion(__quat.invert());
|
|
2761
|
+
this.node.position.copy(__posDelta.add(__worldPos));
|
|
2765
2762
|
}
|
|
2766
|
-
if (
|
|
2763
|
+
if (this._panDelta.manhattanLength() > 0.001) {
|
|
2767
2764
|
__posDelta.copy(this.node.position).sub(__worldPos);
|
|
2768
2765
|
__xAxis.setFromMatrixColumn(this.node.matrix, 0);
|
|
2769
2766
|
__yAxis.setFromMatrixColumn(this.node.matrix, 1);
|
|
@@ -2772,14 +2769,17 @@ class FreelookVirtualCamera extends VirtualCamera {
|
|
|
2772
2769
|
__yAxis.normalize();
|
|
2773
2770
|
}
|
|
2774
2771
|
let length = __posDelta.length() * 2 * tan(degToRad(this.fov * 0.5));
|
|
2775
|
-
let
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
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)));
|
|
2779
2775
|
this._panDelta.multiplyScalar(dampFactor);
|
|
2780
|
-
__worldPos.copy(this.lookAt.position).add(
|
|
2776
|
+
__worldPos.copy(this.lookAt.position).add(lookAtOffset);
|
|
2781
2777
|
this.node.position.copy(__posDelta.add(__worldPos));
|
|
2782
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
|
+
}
|
|
2783
2783
|
this.node.lookAt(__worldPos);
|
|
2784
2784
|
}
|
|
2785
2785
|
constructor(...args){
|
|
@@ -2791,17 +2791,17 @@ class FreelookVirtualCamera extends VirtualCamera {
|
|
|
2791
2791
|
this._preLoc1 = new three.Vector2();
|
|
2792
2792
|
this._rotateDelta = new three.Vector2();
|
|
2793
2793
|
this._panDelta = new three.Vector2();
|
|
2794
|
-
this.
|
|
2794
|
+
this._tempSmoothing = 0;
|
|
2795
|
+
this._lookAtOffsetDelta = new three.Vector3();
|
|
2795
2796
|
this.forbidX = false;
|
|
2796
2797
|
this.forbidY = false;
|
|
2797
2798
|
this.forbidZ = false;
|
|
2798
2799
|
this.forbidPanX = false;
|
|
2799
2800
|
this.forbidPanY = false;
|
|
2800
2801
|
this.forbitPanOffsetY = false;
|
|
2802
|
+
this.smoothing = 0.5;
|
|
2801
2803
|
this.rotateSpeed = 2;
|
|
2802
|
-
this.rotateSmoothing = 0.5;
|
|
2803
2804
|
this.panSpeed = 2;
|
|
2804
|
-
this.panSmoothing = 0.5;
|
|
2805
2805
|
this.panScale = new three.Vector3(1, 1, 1);
|
|
2806
2806
|
this.phiMin = 0.001;
|
|
2807
2807
|
this.phiMax = Math.PI - 0.001;
|
|
@@ -2811,26 +2811,6 @@ class FreelookVirtualCamera extends VirtualCamera {
|
|
|
2811
2811
|
this.distanceMax = Infinity;
|
|
2812
2812
|
this.rotateTouchID = 0;
|
|
2813
2813
|
this.lookAt = new three.Object3D();
|
|
2814
|
-
this._tweenPOI = {
|
|
2815
|
-
get position () {
|
|
2816
|
-
return this.node.position;
|
|
2817
|
-
},
|
|
2818
|
-
set position (v){
|
|
2819
|
-
this.node.position.copy(v);
|
|
2820
|
-
},
|
|
2821
|
-
get lookAt () {
|
|
2822
|
-
return this.lookAt.position;
|
|
2823
|
-
},
|
|
2824
|
-
set lookAt (v){
|
|
2825
|
-
this.lookAt.position.copy(v);
|
|
2826
|
-
},
|
|
2827
|
-
get trackedObjectOffset () {
|
|
2828
|
-
return this.trackedObjectOffset;
|
|
2829
|
-
},
|
|
2830
|
-
set trackedObjectOffset (v){
|
|
2831
|
-
this.trackedObjectOffset.copy(v);
|
|
2832
|
-
}
|
|
2833
|
-
};
|
|
2834
2814
|
}
|
|
2835
2815
|
}
|
|
2836
2816
|
FreelookVirtualCamera.__loc0 = new three.Vector2();
|
|
@@ -2840,16 +2820,11 @@ FreelookVirtualCamera.__preCenter = new three.Vector2();
|
|
|
2840
2820
|
FreelookVirtualCamera.__moveDelta = new three.Vector2();
|
|
2841
2821
|
FreelookVirtualCamera.__worldPos = new three.Vector3();
|
|
2842
2822
|
FreelookVirtualCamera.__posDelta = new three.Vector3();
|
|
2843
|
-
FreelookVirtualCamera.__posOffset = new three.Vector3();
|
|
2844
2823
|
FreelookVirtualCamera.__xAxis = new three.Vector3();
|
|
2845
2824
|
FreelookVirtualCamera.__yAxis = new three.Vector3();
|
|
2846
2825
|
FreelookVirtualCamera.__quat = new three.Quaternion();
|
|
2847
2826
|
FreelookVirtualCamera.__spherical = new three.Spherical();
|
|
2848
|
-
|
|
2849
|
-
property({
|
|
2850
|
-
value: VCamFreeLookMode
|
|
2851
|
-
})
|
|
2852
|
-
], FreelookVirtualCamera.prototype, "mode", void 0);
|
|
2827
|
+
FreelookVirtualCamera.__offsetDelta = new three.Vector3();
|
|
2853
2828
|
__decorate([
|
|
2854
2829
|
property({
|
|
2855
2830
|
dir: "set"
|
|
@@ -2880,6 +2855,9 @@ __decorate([
|
|
|
2880
2855
|
dir: "set"
|
|
2881
2856
|
})
|
|
2882
2857
|
], FreelookVirtualCamera.prototype, "forbitPanOffsetY", void 0);
|
|
2858
|
+
__decorate([
|
|
2859
|
+
property
|
|
2860
|
+
], FreelookVirtualCamera.prototype, "printInfo", null);
|
|
2883
2861
|
|
|
2884
2862
|
class Box extends three.Mesh {
|
|
2885
2863
|
constructor(...args){
|