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