@d5techs/3dgs-lib 1.4.31 → 1.4.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/3dgs-lib.cjs +34 -12
- package/dist/3dgs-lib.cjs.map +1 -1
- package/dist/3dgs-lib.js +34 -12
- package/dist/3dgs-lib.js.map +1 -1
- package/dist/core/OrbitControls.d.ts +1 -0
- package/package.json +65 -65
package/dist/3dgs-lib.js
CHANGED
|
@@ -623,7 +623,7 @@ const _OrbitControls = class _OrbitControls {
|
|
|
623
623
|
__publicField(this, "maxPhi", Math.PI - 0.01);
|
|
624
624
|
// 灵敏度
|
|
625
625
|
__publicField(this, "rotateSpeed", 5e-3);
|
|
626
|
-
__publicField(this, "zoomSpeed",
|
|
626
|
+
__publicField(this, "zoomSpeed", 5e-4);
|
|
627
627
|
__publicField(this, "panSpeed", 5e-3);
|
|
628
628
|
// 移动端触摸灵敏度
|
|
629
629
|
__publicField(this, "touchZoomSpeed", 0.01);
|
|
@@ -635,9 +635,10 @@ const _OrbitControls = class _OrbitControls {
|
|
|
635
635
|
__publicField(this, "isDragging", false);
|
|
636
636
|
__publicField(this, "lastX", 0);
|
|
637
637
|
__publicField(this, "lastY", 0);
|
|
638
|
-
//
|
|
638
|
+
// 待应用的增量(每帧全量应用后衰减,实现惯性)
|
|
639
639
|
__publicField(this, "deltaTheta", 0);
|
|
640
640
|
__publicField(this, "deltaPhi", 0);
|
|
641
|
+
__publicField(this, "deltaDistance", 0);
|
|
641
642
|
__publicField(this, "deltaPanX", 0);
|
|
642
643
|
__publicField(this, "deltaPanY", 0);
|
|
643
644
|
__publicField(this, "deltaPanZ", 0);
|
|
@@ -785,11 +786,18 @@ const _OrbitControls = class _OrbitControls {
|
|
|
785
786
|
else if (e.deltaMode === 2) delta *= 800;
|
|
786
787
|
const normalizedDelta = Math.sign(delta) * Math.min(Math.abs(delta), 120);
|
|
787
788
|
const zoomDelta = normalizedDelta * this.zoomSpeed;
|
|
788
|
-
this.
|
|
789
|
-
|
|
790
|
-
this.
|
|
791
|
-
Math.
|
|
792
|
-
|
|
789
|
+
if (this.enableDamping) {
|
|
790
|
+
this.deltaDistance += zoomDelta * this.dampingFactor;
|
|
791
|
+
const maxAccum = 120 * this.zoomSpeed * this.dampingFactor * 3;
|
|
792
|
+
this.deltaDistance = Math.sign(this.deltaDistance) * Math.min(Math.abs(this.deltaDistance), maxAccum);
|
|
793
|
+
} else {
|
|
794
|
+
this.distance *= Math.exp(zoomDelta);
|
|
795
|
+
this.distance = Math.max(
|
|
796
|
+
this.minDistance,
|
|
797
|
+
Math.min(this.maxDistance, this.distance)
|
|
798
|
+
);
|
|
799
|
+
this.applySpherical();
|
|
800
|
+
}
|
|
793
801
|
}
|
|
794
802
|
onKeyDown(e) {
|
|
795
803
|
var _a2;
|
|
@@ -929,11 +937,15 @@ const _OrbitControls = class _OrbitControls {
|
|
|
929
937
|
const currentCenter = this.getTouchCenter(e.touches);
|
|
930
938
|
if (this.lastTouchDistance > 0) {
|
|
931
939
|
const ratio = currentDistance / this.lastTouchDistance;
|
|
932
|
-
this.
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
940
|
+
if (this.enableDamping) {
|
|
941
|
+
this.deltaDistance += -Math.log(ratio) * this.dampingFactor;
|
|
942
|
+
} else {
|
|
943
|
+
this.distance /= ratio;
|
|
944
|
+
this.distance = Math.max(
|
|
945
|
+
this.minDistance,
|
|
946
|
+
Math.min(this.maxDistance, this.distance)
|
|
947
|
+
);
|
|
948
|
+
}
|
|
937
949
|
}
|
|
938
950
|
const deltaX = currentCenter.x - this.lastTouchCenter.x;
|
|
939
951
|
const deltaY = currentCenter.y - this.lastTouchCenter.y;
|
|
@@ -1007,6 +1019,15 @@ const _OrbitControls = class _OrbitControls {
|
|
|
1007
1019
|
this.deltaPhi *= decay;
|
|
1008
1020
|
if (Math.abs(this.deltaTheta) < EPS) this.deltaTheta = 0;
|
|
1009
1021
|
if (Math.abs(this.deltaPhi) < EPS) this.deltaPhi = 0;
|
|
1022
|
+
if (Math.abs(this.deltaDistance) > EPS) {
|
|
1023
|
+
this.distance *= Math.exp(this.deltaDistance);
|
|
1024
|
+
this.distance = Math.max(
|
|
1025
|
+
this.minDistance,
|
|
1026
|
+
Math.min(this.maxDistance, this.distance)
|
|
1027
|
+
);
|
|
1028
|
+
this.deltaDistance *= decay;
|
|
1029
|
+
if (Math.abs(this.deltaDistance) < EPS) this.deltaDistance = 0;
|
|
1030
|
+
}
|
|
1010
1031
|
this.camera.target[0] += this.deltaPanX;
|
|
1011
1032
|
this.camera.target[1] += this.deltaPanY;
|
|
1012
1033
|
this.camera.target[2] += this.deltaPanZ;
|
|
@@ -1123,6 +1144,7 @@ const _OrbitControls = class _OrbitControls {
|
|
|
1123
1144
|
clearVelocity() {
|
|
1124
1145
|
this.deltaTheta = 0;
|
|
1125
1146
|
this.deltaPhi = 0;
|
|
1147
|
+
this.deltaDistance = 0;
|
|
1126
1148
|
this.deltaPanX = 0;
|
|
1127
1149
|
this.deltaPanY = 0;
|
|
1128
1150
|
this.deltaPanZ = 0;
|