@d5techs/3dgs-lib 1.4.27 → 1.4.29
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 +55 -62
- package/dist/3dgs-lib.cjs.map +1 -1
- package/dist/3dgs-lib.js +55 -62
- package/dist/3dgs-lib.js.map +1 -1
- package/dist/core/OrbitControls.d.ts +6 -6
- package/package.json +1 -1
package/dist/3dgs-lib.js
CHANGED
|
@@ -628,20 +628,20 @@ const _OrbitControls = class _OrbitControls {
|
|
|
628
628
|
// 移动端触摸灵敏度
|
|
629
629
|
__publicField(this, "touchZoomSpeed", 0.01);
|
|
630
630
|
__publicField(this, "touchPanSpeed", 3e-3);
|
|
631
|
-
//
|
|
631
|
+
// 阻尼:每帧应用全量 delta,然后 delta *= (1 - dampingFactor) 实现惯性
|
|
632
632
|
__publicField(this, "enableDamping", true);
|
|
633
|
-
__publicField(this, "dampingFactor", 0.
|
|
633
|
+
__publicField(this, "dampingFactor", 0.1);
|
|
634
634
|
// 状态
|
|
635
635
|
__publicField(this, "isDragging", false);
|
|
636
636
|
__publicField(this, "lastX", 0);
|
|
637
637
|
__publicField(this, "lastY", 0);
|
|
638
|
-
//
|
|
639
|
-
__publicField(this, "
|
|
640
|
-
__publicField(this, "
|
|
641
|
-
__publicField(this, "
|
|
642
|
-
__publicField(this, "
|
|
643
|
-
__publicField(this, "
|
|
644
|
-
__publicField(this, "
|
|
638
|
+
// 待应用的增量(每帧全量应用后衰减,实现惯性)
|
|
639
|
+
__publicField(this, "deltaTheta", 0);
|
|
640
|
+
__publicField(this, "deltaPhi", 0);
|
|
641
|
+
__publicField(this, "deltaDistance", 0);
|
|
642
|
+
__publicField(this, "deltaPanX", 0);
|
|
643
|
+
__publicField(this, "deltaPanY", 0);
|
|
644
|
+
__publicField(this, "deltaPanZ", 0);
|
|
645
645
|
// 键盘移动
|
|
646
646
|
__publicField(this, "moveSpeed", 0.015);
|
|
647
647
|
__publicField(this, "pressedKeys", /* @__PURE__ */ new Set());
|
|
@@ -737,9 +737,9 @@ const _OrbitControls = class _OrbitControls {
|
|
|
737
737
|
const dx = -deltaX * scale;
|
|
738
738
|
const dy = deltaY * scale;
|
|
739
739
|
if (this.enableDamping) {
|
|
740
|
-
this.
|
|
741
|
-
this.
|
|
742
|
-
this.
|
|
740
|
+
this.deltaPanX += dx * right[0] + dy * up[0];
|
|
741
|
+
this.deltaPanY += dx * right[1] + dy * up[1];
|
|
742
|
+
this.deltaPanZ += dx * right[2] + dy * up[2];
|
|
743
743
|
} else {
|
|
744
744
|
this.camera.target[0] += dx * right[0] + dy * up[0];
|
|
745
745
|
this.camera.target[1] += dx * right[1] + dy * up[1];
|
|
@@ -760,11 +760,8 @@ const _OrbitControls = class _OrbitControls {
|
|
|
760
760
|
this.lastY = e.clientY;
|
|
761
761
|
if (e.buttons === 1) {
|
|
762
762
|
if (this.enableDamping) {
|
|
763
|
-
this.
|
|
764
|
-
this.
|
|
765
|
-
const maxRotVel = 0.5;
|
|
766
|
-
this.velocityTheta = Math.max(-maxRotVel, Math.min(maxRotVel, this.velocityTheta));
|
|
767
|
-
this.velocityPhi = Math.max(-maxRotVel, Math.min(maxRotVel, this.velocityPhi));
|
|
763
|
+
this.deltaTheta += -deltaX * this.rotateSpeed;
|
|
764
|
+
this.deltaPhi += -deltaY * this.rotateSpeed;
|
|
768
765
|
} else {
|
|
769
766
|
this.theta -= deltaX * this.rotateSpeed;
|
|
770
767
|
this.phi -= deltaY * this.rotateSpeed;
|
|
@@ -786,12 +783,10 @@ const _OrbitControls = class _OrbitControls {
|
|
|
786
783
|
let delta = e.deltaY;
|
|
787
784
|
if (e.deltaMode === 1) delta *= 40;
|
|
788
785
|
else if (e.deltaMode === 2) delta *= 800;
|
|
789
|
-
const normalizedDelta = Math.sign(delta) * Math.min(Math.abs(delta),
|
|
786
|
+
const normalizedDelta = Math.sign(delta) * Math.min(Math.abs(delta), 120);
|
|
790
787
|
const zoomDelta = normalizedDelta * this.zoomSpeed;
|
|
791
788
|
if (this.enableDamping) {
|
|
792
|
-
this.
|
|
793
|
-
const maxVelocity = 2;
|
|
794
|
-
this.velocityDistance = Math.max(-maxVelocity, Math.min(maxVelocity, this.velocityDistance));
|
|
789
|
+
this.deltaDistance += zoomDelta;
|
|
795
790
|
} else {
|
|
796
791
|
this.distance *= Math.exp(zoomDelta);
|
|
797
792
|
this.distance = Math.max(
|
|
@@ -926,8 +921,8 @@ const _OrbitControls = class _OrbitControls {
|
|
|
926
921
|
this.lastX = e.touches[0].clientX;
|
|
927
922
|
this.lastY = e.touches[0].clientY;
|
|
928
923
|
if (this.enableDamping) {
|
|
929
|
-
this.
|
|
930
|
-
this.
|
|
924
|
+
this.deltaTheta += -deltaX * this.rotateSpeed;
|
|
925
|
+
this.deltaPhi += -deltaY * this.rotateSpeed;
|
|
931
926
|
} else {
|
|
932
927
|
this.theta -= deltaX * this.rotateSpeed;
|
|
933
928
|
this.phi -= deltaY * this.rotateSpeed;
|
|
@@ -939,11 +934,10 @@ const _OrbitControls = class _OrbitControls {
|
|
|
939
934
|
const currentCenter = this.getTouchCenter(e.touches);
|
|
940
935
|
if (this.lastTouchDistance > 0) {
|
|
941
936
|
const ratio = currentDistance / this.lastTouchDistance;
|
|
942
|
-
const zoomDelta = -Math.log(ratio) / (this.touchZoomSpeed * 100);
|
|
943
937
|
if (this.enableDamping) {
|
|
944
|
-
this.
|
|
938
|
+
this.deltaDistance += -Math.log(ratio);
|
|
945
939
|
} else {
|
|
946
|
-
this.distance
|
|
940
|
+
this.distance /= ratio;
|
|
947
941
|
this.distance = Math.max(
|
|
948
942
|
this.minDistance,
|
|
949
943
|
Math.min(this.maxDistance, this.distance)
|
|
@@ -957,9 +951,9 @@ const _OrbitControls = class _OrbitControls {
|
|
|
957
951
|
const dx = -deltaX * scale;
|
|
958
952
|
const dy = deltaY * scale;
|
|
959
953
|
if (this.enableDamping) {
|
|
960
|
-
this.
|
|
961
|
-
this.
|
|
962
|
-
this.
|
|
954
|
+
this.deltaPanX += dx * right[0] + dy * up[0];
|
|
955
|
+
this.deltaPanY += dx * right[1] + dy * up[1];
|
|
956
|
+
this.deltaPanZ += dx * right[2] + dy * up[2];
|
|
963
957
|
} else {
|
|
964
958
|
this.camera.target[0] += dx * right[0] + dy * up[0];
|
|
965
959
|
this.camera.target[1] += dx * right[1] + dy * up[1];
|
|
@@ -967,9 +961,7 @@ const _OrbitControls = class _OrbitControls {
|
|
|
967
961
|
}
|
|
968
962
|
this.lastTouchDistance = currentDistance;
|
|
969
963
|
this.lastTouchCenter = currentCenter;
|
|
970
|
-
if (!this.enableDamping)
|
|
971
|
-
this.applySpherical();
|
|
972
|
-
}
|
|
964
|
+
if (!this.enableDamping) this.applySpherical();
|
|
973
965
|
}
|
|
974
966
|
}
|
|
975
967
|
onTouchEnd(e) {
|
|
@@ -1015,31 +1007,32 @@ const _OrbitControls = class _OrbitControls {
|
|
|
1015
1007
|
this.applyKeyboardMovement();
|
|
1016
1008
|
if (this.enableDamping) {
|
|
1017
1009
|
const EPS = 1e-6;
|
|
1018
|
-
const
|
|
1019
|
-
this.theta += this.
|
|
1020
|
-
this.phi += this.
|
|
1010
|
+
const decay = 1 - this.dampingFactor;
|
|
1011
|
+
this.theta += this.deltaTheta;
|
|
1012
|
+
this.phi += this.deltaPhi;
|
|
1021
1013
|
this.phi = Math.max(this.minPhi, Math.min(this.maxPhi, this.phi));
|
|
1022
|
-
this.
|
|
1023
|
-
this.
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
)
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
this.
|
|
1036
|
-
this.
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
if (Math.abs(this.
|
|
1042
|
-
if (Math.abs(this.
|
|
1014
|
+
this.deltaTheta *= decay;
|
|
1015
|
+
this.deltaPhi *= decay;
|
|
1016
|
+
if (Math.abs(this.deltaTheta) < EPS) this.deltaTheta = 0;
|
|
1017
|
+
if (Math.abs(this.deltaPhi) < EPS) this.deltaPhi = 0;
|
|
1018
|
+
if (Math.abs(this.deltaDistance) > EPS) {
|
|
1019
|
+
this.distance *= Math.exp(this.deltaDistance);
|
|
1020
|
+
this.distance = Math.max(
|
|
1021
|
+
this.minDistance,
|
|
1022
|
+
Math.min(this.maxDistance, this.distance)
|
|
1023
|
+
);
|
|
1024
|
+
this.deltaDistance *= decay;
|
|
1025
|
+
if (Math.abs(this.deltaDistance) < EPS) this.deltaDistance = 0;
|
|
1026
|
+
}
|
|
1027
|
+
this.camera.target[0] += this.deltaPanX;
|
|
1028
|
+
this.camera.target[1] += this.deltaPanY;
|
|
1029
|
+
this.camera.target[2] += this.deltaPanZ;
|
|
1030
|
+
this.deltaPanX *= decay;
|
|
1031
|
+
this.deltaPanY *= decay;
|
|
1032
|
+
this.deltaPanZ *= decay;
|
|
1033
|
+
if (Math.abs(this.deltaPanX) < EPS) this.deltaPanX = 0;
|
|
1034
|
+
if (Math.abs(this.deltaPanY) < EPS) this.deltaPanY = 0;
|
|
1035
|
+
if (Math.abs(this.deltaPanZ) < EPS) this.deltaPanZ = 0;
|
|
1043
1036
|
}
|
|
1044
1037
|
this.applySpherical();
|
|
1045
1038
|
}
|
|
@@ -1145,12 +1138,12 @@ const _OrbitControls = class _OrbitControls {
|
|
|
1145
1138
|
requestAnimationFrame(animate);
|
|
1146
1139
|
}
|
|
1147
1140
|
clearVelocity() {
|
|
1148
|
-
this.
|
|
1149
|
-
this.
|
|
1150
|
-
this.
|
|
1151
|
-
this.
|
|
1152
|
-
this.
|
|
1153
|
-
this.
|
|
1141
|
+
this.deltaTheta = 0;
|
|
1142
|
+
this.deltaPhi = 0;
|
|
1143
|
+
this.deltaDistance = 0;
|
|
1144
|
+
this.deltaPanX = 0;
|
|
1145
|
+
this.deltaPanY = 0;
|
|
1146
|
+
this.deltaPanZ = 0;
|
|
1154
1147
|
}
|
|
1155
1148
|
};
|
|
1156
1149
|
/** 移动键 */
|