@d5techs/3dgs-lib 1.4.43 → 1.4.45
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 +26 -12
- package/dist/3dgs-lib.cjs.map +1 -1
- package/dist/3dgs-lib.js +26 -12
- package/dist/3dgs-lib.js.map +1 -1
- package/dist/core/OrbitControls.d.ts +5 -0
- package/package.json +1 -1
package/dist/3dgs-lib.js
CHANGED
|
@@ -622,7 +622,7 @@ const _OrbitControls = class _OrbitControls {
|
|
|
622
622
|
__publicField(this, "minPhi", 0.01);
|
|
623
623
|
__publicField(this, "maxPhi", Math.PI - 0.01);
|
|
624
624
|
// 灵敏度
|
|
625
|
-
__publicField(this, "rotateSpeed",
|
|
625
|
+
__publicField(this, "rotateSpeed", 5e-3);
|
|
626
626
|
__publicField(this, "zoomSpeed", 1e-3);
|
|
627
627
|
__publicField(this, "panSpeed", 5e-3);
|
|
628
628
|
// 移动端触摸灵敏度
|
|
@@ -737,7 +737,7 @@ const _OrbitControls = class _OrbitControls {
|
|
|
737
737
|
*/
|
|
738
738
|
panByScreenDelta(deltaX, deltaY) {
|
|
739
739
|
const { right, up } = this.getCameraAxes();
|
|
740
|
-
const scale = this.panSpeed * this.
|
|
740
|
+
const scale = this.panSpeed * this.getEffectiveZoomDist();
|
|
741
741
|
const dx = -deltaX * scale;
|
|
742
742
|
const dy = deltaY * scale;
|
|
743
743
|
if (this.enableDamping) {
|
|
@@ -764,12 +764,13 @@ const _OrbitControls = class _OrbitControls {
|
|
|
764
764
|
this.lastX = e.clientX;
|
|
765
765
|
this.lastY = e.clientY;
|
|
766
766
|
if (e.buttons === 1) {
|
|
767
|
+
const rs = this.rotateSpeed * this.getRotateScale();
|
|
767
768
|
if (this.enableDamping) {
|
|
768
|
-
this.deltaTheta += -deltaX *
|
|
769
|
-
this.deltaPhi += -deltaY *
|
|
769
|
+
this.deltaTheta += -deltaX * rs * this.dampingFactor;
|
|
770
|
+
this.deltaPhi += -deltaY * rs * this.dampingFactor;
|
|
770
771
|
} else {
|
|
771
|
-
this.theta -= deltaX *
|
|
772
|
-
this.phi -= deltaY *
|
|
772
|
+
this.theta -= deltaX * rs;
|
|
773
|
+
this.phi -= deltaY * rs;
|
|
773
774
|
this.phi = Math.max(this.minPhi, Math.min(this.maxPhi, this.phi));
|
|
774
775
|
}
|
|
775
776
|
} else if (e.buttons === 2 || e.buttons === 4) {
|
|
@@ -824,7 +825,7 @@ const _OrbitControls = class _OrbitControls {
|
|
|
824
825
|
const m = this.camera.viewMatrix;
|
|
825
826
|
const right = [m[0], m[4], m[8]];
|
|
826
827
|
const forward = [-m[2], -m[6], -m[10]];
|
|
827
|
-
const speed = this.moveSpeed * this.
|
|
828
|
+
const speed = this.moveSpeed * this.getEffectiveZoomDist();
|
|
828
829
|
let dx = 0, dy = 0, dz = 0;
|
|
829
830
|
if (this.pressedKeys.has("w") || this.pressedKeys.has("arrowup")) {
|
|
830
831
|
dx += forward[0] * speed;
|
|
@@ -929,12 +930,13 @@ const _OrbitControls = class _OrbitControls {
|
|
|
929
930
|
const deltaY = e.touches[0].clientY - this.lastY;
|
|
930
931
|
this.lastX = e.touches[0].clientX;
|
|
931
932
|
this.lastY = e.touches[0].clientY;
|
|
933
|
+
const rs = this.rotateSpeed * this.getRotateScale();
|
|
932
934
|
if (this.enableDamping) {
|
|
933
|
-
this.deltaTheta += -deltaX *
|
|
934
|
-
this.deltaPhi += -deltaY *
|
|
935
|
+
this.deltaTheta += -deltaX * rs * this.dampingFactor;
|
|
936
|
+
this.deltaPhi += -deltaY * rs * this.dampingFactor;
|
|
935
937
|
} else {
|
|
936
|
-
this.theta -= deltaX *
|
|
937
|
-
this.phi -= deltaY *
|
|
938
|
+
this.theta -= deltaX * rs;
|
|
939
|
+
this.phi -= deltaY * rs;
|
|
938
940
|
this.phi = Math.max(this.minPhi, Math.min(this.maxPhi, this.phi));
|
|
939
941
|
this.applySpherical();
|
|
940
942
|
}
|
|
@@ -958,7 +960,7 @@ const _OrbitControls = class _OrbitControls {
|
|
|
958
960
|
const deltaX = currentCenter.x - this.lastTouchCenter.x;
|
|
959
961
|
const deltaY = currentCenter.y - this.lastTouchCenter.y;
|
|
960
962
|
const { right, up } = this.getCameraAxes();
|
|
961
|
-
const scale = this.touchPanSpeed * this.
|
|
963
|
+
const scale = this.touchPanSpeed * this.getEffectiveZoomDist();
|
|
962
964
|
const dx = -deltaX * scale;
|
|
963
965
|
const dy = deltaY * scale;
|
|
964
966
|
if (this.enableDamping) {
|
|
@@ -1011,6 +1013,18 @@ const _OrbitControls = class _OrbitControls {
|
|
|
1011
1013
|
this.camera.position[2] = this.camera.target[2] + this.distance * sinPhi * cosTheta;
|
|
1012
1014
|
this.camera.updateMatrix();
|
|
1013
1015
|
}
|
|
1016
|
+
/**
|
|
1017
|
+
* 旋转速度缩放:当 target 远离模型时降低旋转灵敏度,
|
|
1018
|
+
* 使模型在屏幕上的视觉运动速度保持一致。
|
|
1019
|
+
*/
|
|
1020
|
+
getRotateScale() {
|
|
1021
|
+
if (this.zoomDistanceCap === Infinity || this.distance < 1e-6) return 1;
|
|
1022
|
+
const cp = this.camera.position;
|
|
1023
|
+
const mc = this._modelCenter;
|
|
1024
|
+
const dx = cp[0] - mc[0], dy = cp[1] - mc[1], dz = cp[2] - mc[2];
|
|
1025
|
+
const camToCenter = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
1026
|
+
return Math.min(1, camToCenter / this.distance);
|
|
1027
|
+
}
|
|
1014
1028
|
/**
|
|
1015
1029
|
* 缩放有效距离:取 distance、相机到模型中心距离、zoomDistanceCap 三者最小值。
|
|
1016
1030
|
* 保证缩放步长始终与相机到模型的真实接近程度匹配。
|