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