@d5techs/3dgs-lib 1.4.26 → 1.4.28
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 +30 -66
- package/dist/3dgs-lib.cjs.map +1 -1
- package/dist/3dgs-lib.js +30 -66
- package/dist/3dgs-lib.js.map +1 -1
- package/dist/core/OrbitControls.d.ts +0 -3
- package/package.json +1 -1
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", 8e-4);
|
|
627
627
|
__publicField(this, "panSpeed", 5e-3);
|
|
628
628
|
// 移动端触摸灵敏度
|
|
629
629
|
__publicField(this, "touchZoomSpeed", 0.01);
|
|
@@ -635,10 +635,7 @@ const _OrbitControls = class _OrbitControls {
|
|
|
635
635
|
__publicField(this, "isDragging", false);
|
|
636
636
|
__publicField(this, "lastX", 0);
|
|
637
637
|
__publicField(this, "lastY", 0);
|
|
638
|
-
//
|
|
639
|
-
__publicField(this, "velocityTheta", 0);
|
|
640
|
-
__publicField(this, "velocityPhi", 0);
|
|
641
|
-
__publicField(this, "velocityDistance", 0);
|
|
638
|
+
// 阻尼速度(仅平移使用)
|
|
642
639
|
__publicField(this, "velocityPanX", 0);
|
|
643
640
|
__publicField(this, "velocityPanY", 0);
|
|
644
641
|
__publicField(this, "velocityPanZ", 0);
|
|
@@ -759,19 +756,15 @@ const _OrbitControls = class _OrbitControls {
|
|
|
759
756
|
this.lastX = e.clientX;
|
|
760
757
|
this.lastY = e.clientY;
|
|
761
758
|
if (e.buttons === 1) {
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
this.theta -= deltaX * this.rotateSpeed;
|
|
767
|
-
this.phi -= deltaY * this.rotateSpeed;
|
|
768
|
-
this.phi = Math.max(this.minPhi, Math.min(this.maxPhi, this.phi));
|
|
769
|
-
}
|
|
759
|
+
this.theta -= deltaX * this.rotateSpeed;
|
|
760
|
+
this.phi -= deltaY * this.rotateSpeed;
|
|
761
|
+
this.phi = Math.max(this.minPhi, Math.min(this.maxPhi, this.phi));
|
|
762
|
+
this.applySpherical();
|
|
770
763
|
} else if (e.buttons === 2 || e.buttons === 4) {
|
|
771
764
|
this.panByScreenDelta(deltaX, deltaY);
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
765
|
+
if (!this.enableDamping) {
|
|
766
|
+
this.applySpherical();
|
|
767
|
+
}
|
|
775
768
|
}
|
|
776
769
|
}
|
|
777
770
|
onMouseUp() {
|
|
@@ -780,17 +773,17 @@ const _OrbitControls = class _OrbitControls {
|
|
|
780
773
|
onWheel(e) {
|
|
781
774
|
e.preventDefault();
|
|
782
775
|
if (!this.enabled) return;
|
|
783
|
-
|
|
784
|
-
if (
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
)
|
|
792
|
-
|
|
793
|
-
|
|
776
|
+
let delta = e.deltaY;
|
|
777
|
+
if (e.deltaMode === 1) delta *= 40;
|
|
778
|
+
else if (e.deltaMode === 2) delta *= 800;
|
|
779
|
+
const normalizedDelta = Math.sign(delta) * Math.min(Math.abs(delta), 120);
|
|
780
|
+
const factor = 1 + normalizedDelta * this.zoomSpeed;
|
|
781
|
+
this.distance *= factor;
|
|
782
|
+
this.distance = Math.max(
|
|
783
|
+
this.minDistance,
|
|
784
|
+
Math.min(this.maxDistance, this.distance)
|
|
785
|
+
);
|
|
786
|
+
this.applySpherical();
|
|
794
787
|
}
|
|
795
788
|
onKeyDown(e) {
|
|
796
789
|
var _a2;
|
|
@@ -916,30 +909,20 @@ const _OrbitControls = class _OrbitControls {
|
|
|
916
909
|
const deltaY = e.touches[0].clientY - this.lastY;
|
|
917
910
|
this.lastX = e.touches[0].clientX;
|
|
918
911
|
this.lastY = e.touches[0].clientY;
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
this.theta -= deltaX * this.rotateSpeed;
|
|
924
|
-
this.phi -= deltaY * this.rotateSpeed;
|
|
925
|
-
this.phi = Math.max(this.minPhi, Math.min(this.maxPhi, this.phi));
|
|
926
|
-
this.applySpherical();
|
|
927
|
-
}
|
|
912
|
+
this.theta -= deltaX * this.rotateSpeed;
|
|
913
|
+
this.phi -= deltaY * this.rotateSpeed;
|
|
914
|
+
this.phi = Math.max(this.minPhi, Math.min(this.maxPhi, this.phi));
|
|
915
|
+
this.applySpherical();
|
|
928
916
|
} else if (e.touches.length === 2) {
|
|
929
917
|
const currentDistance = this.getTouchDistance(e.touches);
|
|
930
918
|
const currentCenter = this.getTouchCenter(e.touches);
|
|
931
919
|
if (this.lastTouchDistance > 0) {
|
|
932
920
|
const ratio = currentDistance / this.lastTouchDistance;
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
this.
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
this.distance = Math.max(
|
|
939
|
-
this.minDistance,
|
|
940
|
-
Math.min(this.maxDistance, this.distance)
|
|
941
|
-
);
|
|
942
|
-
}
|
|
921
|
+
this.distance /= ratio;
|
|
922
|
+
this.distance = Math.max(
|
|
923
|
+
this.minDistance,
|
|
924
|
+
Math.min(this.maxDistance, this.distance)
|
|
925
|
+
);
|
|
943
926
|
}
|
|
944
927
|
const deltaX = currentCenter.x - this.lastTouchCenter.x;
|
|
945
928
|
const deltaY = currentCenter.y - this.lastTouchCenter.y;
|
|
@@ -958,9 +941,7 @@ const _OrbitControls = class _OrbitControls {
|
|
|
958
941
|
}
|
|
959
942
|
this.lastTouchDistance = currentDistance;
|
|
960
943
|
this.lastTouchCenter = currentCenter;
|
|
961
|
-
|
|
962
|
-
this.applySpherical();
|
|
963
|
-
}
|
|
944
|
+
this.applySpherical();
|
|
964
945
|
}
|
|
965
946
|
}
|
|
966
947
|
onTouchEnd(e) {
|
|
@@ -1007,27 +988,13 @@ const _OrbitControls = class _OrbitControls {
|
|
|
1007
988
|
if (this.enableDamping) {
|
|
1008
989
|
const EPS = 1e-6;
|
|
1009
990
|
const f = this.dampingFactor;
|
|
1010
|
-
this.theta += this.velocityTheta * f;
|
|
1011
|
-
this.phi += this.velocityPhi * f;
|
|
1012
|
-
this.phi = Math.max(this.minPhi, Math.min(this.maxPhi, this.phi));
|
|
1013
|
-
this.distance *= Math.exp(this.velocityDistance * f);
|
|
1014
|
-
this.distance = Math.max(
|
|
1015
|
-
this.minDistance,
|
|
1016
|
-
Math.min(this.maxDistance, this.distance)
|
|
1017
|
-
);
|
|
1018
991
|
this.camera.target[0] += this.velocityPanX * f;
|
|
1019
992
|
this.camera.target[1] += this.velocityPanY * f;
|
|
1020
993
|
this.camera.target[2] += this.velocityPanZ * f;
|
|
1021
994
|
const decay = 1 - f;
|
|
1022
|
-
this.velocityTheta *= decay;
|
|
1023
|
-
this.velocityPhi *= decay;
|
|
1024
|
-
this.velocityDistance *= decay;
|
|
1025
995
|
this.velocityPanX *= decay;
|
|
1026
996
|
this.velocityPanY *= decay;
|
|
1027
997
|
this.velocityPanZ *= decay;
|
|
1028
|
-
if (Math.abs(this.velocityTheta) < EPS) this.velocityTheta = 0;
|
|
1029
|
-
if (Math.abs(this.velocityPhi) < EPS) this.velocityPhi = 0;
|
|
1030
|
-
if (Math.abs(this.velocityDistance) < EPS) this.velocityDistance = 0;
|
|
1031
998
|
if (Math.abs(this.velocityPanX) < EPS) this.velocityPanX = 0;
|
|
1032
999
|
if (Math.abs(this.velocityPanY) < EPS) this.velocityPanY = 0;
|
|
1033
1000
|
if (Math.abs(this.velocityPanZ) < EPS) this.velocityPanZ = 0;
|
|
@@ -1136,9 +1103,6 @@ const _OrbitControls = class _OrbitControls {
|
|
|
1136
1103
|
requestAnimationFrame(animate);
|
|
1137
1104
|
}
|
|
1138
1105
|
clearVelocity() {
|
|
1139
|
-
this.velocityTheta = 0;
|
|
1140
|
-
this.velocityPhi = 0;
|
|
1141
|
-
this.velocityDistance = 0;
|
|
1142
1106
|
this.velocityPanX = 0;
|
|
1143
1107
|
this.velocityPanY = 0;
|
|
1144
1108
|
this.velocityPanZ = 0;
|