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