@xviewer.js/core 1.0.0-alpha.31 → 1.0.0-alpha.32
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 +58 -87
- package/dist/main.js.map +1 -1
- package/dist/module.js +58 -87
- package/dist/module.js.map +1 -1
- package/package.json +1 -1
- package/types/cinestation/FreelookVirtualCamera.d.ts +4 -11
package/dist/main.js
CHANGED
|
@@ -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.trackedObjectOffset).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);
|
|
@@ -2681,7 +2674,9 @@ class FreelookVirtualCamera extends VirtualCamera {
|
|
|
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,51 @@ 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.trackedObjectOffset);
|
|
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
|
+
}
|
|
2724
2740
|
update(dt) {
|
|
2725
2741
|
if (!this.lookAt) return;
|
|
2726
|
-
const
|
|
2742
|
+
const dampFactor = exponentialDamp(1, 0, this._tempSmoothing, dt);
|
|
2743
|
+
const { __posDelta, __worldPos, __quat, __spherical, __xAxis, __yAxis } = FreelookVirtualCamera;
|
|
2727
2744
|
__worldPos.copy(this.lookAt.position).add(this.trackedObjectOffset);
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
this._distanceDelta *= dampFactor;
|
|
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;
|
|
2745
|
+
if (this._rotateDelta.manhattanLength() + abs(this._distanceDelta) > 0.001) {
|
|
2746
|
+
__quat.setFromUnitVectors(this.node.up, three.Object3D.DEFAULT_UP);
|
|
2747
|
+
__posDelta.copy(this.node.position).sub(__worldPos);
|
|
2748
|
+
__posDelta.applyQuaternion(__quat);
|
|
2749
|
+
__spherical.setFromVector3(__posDelta);
|
|
2750
|
+
this._rotateDelta.x = __spherical.theta - clamp(__spherical.theta - this._rotateDelta.x, this.thetaMin, this.thetaMax);
|
|
2751
|
+
__spherical.theta = __spherical.theta - this._rotateDelta.x * (1 - dampFactor);
|
|
2752
|
+
this._rotateDelta.y = clamp(__spherical.phi + this._rotateDelta.y, this.phiMin, this.phiMax) - __spherical.phi;
|
|
2753
|
+
__spherical.phi = clamp(__spherical.phi + this._rotateDelta.y * (1 - dampFactor), 0.001, Math.PI - 0.001);
|
|
2754
|
+
this._distanceDelta = clamp(__spherical.radius + this._distanceDelta, this.distanceMin, this.distanceMax) - __spherical.radius;
|
|
2755
|
+
__spherical.radius = __spherical.radius + this._distanceDelta * (1 - dampFactor);
|
|
2756
|
+
this._rotateDelta.multiplyScalar(dampFactor);
|
|
2757
|
+
this._distanceDelta *= dampFactor;
|
|
2758
|
+
__posDelta.setFromSpherical(__spherical);
|
|
2759
|
+
__posDelta.applyQuaternion(__quat.invert());
|
|
2760
|
+
this.node.position.copy(__posDelta.add(__worldPos));
|
|
2765
2761
|
}
|
|
2766
|
-
if (
|
|
2762
|
+
if (this._panDelta.manhattanLength() > 0.001) {
|
|
2767
2763
|
__posDelta.copy(this.node.position).sub(__worldPos);
|
|
2768
2764
|
__xAxis.setFromMatrixColumn(this.node.matrix, 0);
|
|
2769
2765
|
__yAxis.setFromMatrixColumn(this.node.matrix, 1);
|
|
@@ -2772,7 +2768,6 @@ class FreelookVirtualCamera extends VirtualCamera {
|
|
|
2772
2768
|
__yAxis.normalize();
|
|
2773
2769
|
}
|
|
2774
2770
|
let length = __posDelta.length() * 2 * tan(degToRad(this.fov * 0.5));
|
|
2775
|
-
let dampFactor = quarticDamp(1, 0, this.panSmoothing, dt);
|
|
2776
2771
|
let trackedObjectOffset = this.trackedObjectOffset;
|
|
2777
2772
|
trackedObjectOffset.sub(__xAxis.multiplyScalar(this._panDelta.x * length * (1 - dampFactor)));
|
|
2778
2773
|
trackedObjectOffset.add(__yAxis.multiplyScalar(this._panDelta.y * length * (1 - dampFactor)));
|
|
@@ -2791,17 +2786,16 @@ class FreelookVirtualCamera extends VirtualCamera {
|
|
|
2791
2786
|
this._preLoc1 = new three.Vector2();
|
|
2792
2787
|
this._rotateDelta = new three.Vector2();
|
|
2793
2788
|
this._panDelta = new three.Vector2();
|
|
2794
|
-
this.
|
|
2789
|
+
this._tempSmoothing = 0;
|
|
2795
2790
|
this.forbidX = false;
|
|
2796
2791
|
this.forbidY = false;
|
|
2797
2792
|
this.forbidZ = false;
|
|
2798
2793
|
this.forbidPanX = false;
|
|
2799
2794
|
this.forbidPanY = false;
|
|
2800
2795
|
this.forbitPanOffsetY = false;
|
|
2796
|
+
this.smoothing = 0.5;
|
|
2801
2797
|
this.rotateSpeed = 2;
|
|
2802
|
-
this.rotateSmoothing = 0.5;
|
|
2803
2798
|
this.panSpeed = 2;
|
|
2804
|
-
this.panSmoothing = 0.5;
|
|
2805
2799
|
this.panScale = new three.Vector3(1, 1, 1);
|
|
2806
2800
|
this.phiMin = 0.001;
|
|
2807
2801
|
this.phiMax = Math.PI - 0.001;
|
|
@@ -2811,26 +2805,6 @@ class FreelookVirtualCamera extends VirtualCamera {
|
|
|
2811
2805
|
this.distanceMax = Infinity;
|
|
2812
2806
|
this.rotateTouchID = 0;
|
|
2813
2807
|
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
2808
|
}
|
|
2835
2809
|
}
|
|
2836
2810
|
FreelookVirtualCamera.__loc0 = new three.Vector2();
|
|
@@ -2840,16 +2814,10 @@ FreelookVirtualCamera.__preCenter = new three.Vector2();
|
|
|
2840
2814
|
FreelookVirtualCamera.__moveDelta = new three.Vector2();
|
|
2841
2815
|
FreelookVirtualCamera.__worldPos = new three.Vector3();
|
|
2842
2816
|
FreelookVirtualCamera.__posDelta = new three.Vector3();
|
|
2843
|
-
FreelookVirtualCamera.__posOffset = new three.Vector3();
|
|
2844
2817
|
FreelookVirtualCamera.__xAxis = new three.Vector3();
|
|
2845
2818
|
FreelookVirtualCamera.__yAxis = new three.Vector3();
|
|
2846
2819
|
FreelookVirtualCamera.__quat = new three.Quaternion();
|
|
2847
2820
|
FreelookVirtualCamera.__spherical = new three.Spherical();
|
|
2848
|
-
__decorate([
|
|
2849
|
-
property({
|
|
2850
|
-
value: VCamFreeLookMode
|
|
2851
|
-
})
|
|
2852
|
-
], FreelookVirtualCamera.prototype, "mode", void 0);
|
|
2853
2821
|
__decorate([
|
|
2854
2822
|
property({
|
|
2855
2823
|
dir: "set"
|
|
@@ -2880,6 +2848,9 @@ __decorate([
|
|
|
2880
2848
|
dir: "set"
|
|
2881
2849
|
})
|
|
2882
2850
|
], FreelookVirtualCamera.prototype, "forbitPanOffsetY", void 0);
|
|
2851
|
+
__decorate([
|
|
2852
|
+
property
|
|
2853
|
+
], FreelookVirtualCamera.prototype, "printInfo", null);
|
|
2883
2854
|
|
|
2884
2855
|
class Box extends three.Mesh {
|
|
2885
2856
|
constructor(...args){
|