@d5techs/3dgs-lib 1.4.43 → 1.4.44
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 +23 -9
- package/dist/3dgs-lib.cjs.map +1 -1
- package/dist/3dgs-lib.js +23 -9
- 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.cjs
CHANGED
|
@@ -624,7 +624,7 @@ const _OrbitControls = class _OrbitControls {
|
|
|
624
624
|
__publicField(this, "minPhi", 0.01);
|
|
625
625
|
__publicField(this, "maxPhi", Math.PI - 0.01);
|
|
626
626
|
// 灵敏度
|
|
627
|
-
__publicField(this, "rotateSpeed",
|
|
627
|
+
__publicField(this, "rotateSpeed", 5e-3);
|
|
628
628
|
__publicField(this, "zoomSpeed", 1e-3);
|
|
629
629
|
__publicField(this, "panSpeed", 5e-3);
|
|
630
630
|
// 移动端触摸灵敏度
|
|
@@ -766,12 +766,13 @@ const _OrbitControls = class _OrbitControls {
|
|
|
766
766
|
this.lastX = e.clientX;
|
|
767
767
|
this.lastY = e.clientY;
|
|
768
768
|
if (e.buttons === 1) {
|
|
769
|
+
const rs = this.rotateSpeed * this.getRotateScale();
|
|
769
770
|
if (this.enableDamping) {
|
|
770
|
-
this.deltaTheta += -deltaX *
|
|
771
|
-
this.deltaPhi += -deltaY *
|
|
771
|
+
this.deltaTheta += -deltaX * rs * this.dampingFactor;
|
|
772
|
+
this.deltaPhi += -deltaY * rs * this.dampingFactor;
|
|
772
773
|
} else {
|
|
773
|
-
this.theta -= deltaX *
|
|
774
|
-
this.phi -= deltaY *
|
|
774
|
+
this.theta -= deltaX * rs;
|
|
775
|
+
this.phi -= deltaY * rs;
|
|
775
776
|
this.phi = Math.max(this.minPhi, Math.min(this.maxPhi, this.phi));
|
|
776
777
|
}
|
|
777
778
|
} else if (e.buttons === 2 || e.buttons === 4) {
|
|
@@ -931,12 +932,13 @@ const _OrbitControls = class _OrbitControls {
|
|
|
931
932
|
const deltaY = e.touches[0].clientY - this.lastY;
|
|
932
933
|
this.lastX = e.touches[0].clientX;
|
|
933
934
|
this.lastY = e.touches[0].clientY;
|
|
935
|
+
const rs = this.rotateSpeed * this.getRotateScale();
|
|
934
936
|
if (this.enableDamping) {
|
|
935
|
-
this.deltaTheta += -deltaX *
|
|
936
|
-
this.deltaPhi += -deltaY *
|
|
937
|
+
this.deltaTheta += -deltaX * rs * this.dampingFactor;
|
|
938
|
+
this.deltaPhi += -deltaY * rs * this.dampingFactor;
|
|
937
939
|
} else {
|
|
938
|
-
this.theta -= deltaX *
|
|
939
|
-
this.phi -= deltaY *
|
|
940
|
+
this.theta -= deltaX * rs;
|
|
941
|
+
this.phi -= deltaY * rs;
|
|
940
942
|
this.phi = Math.max(this.minPhi, Math.min(this.maxPhi, this.phi));
|
|
941
943
|
this.applySpherical();
|
|
942
944
|
}
|
|
@@ -1013,6 +1015,18 @@ const _OrbitControls = class _OrbitControls {
|
|
|
1013
1015
|
this.camera.position[2] = this.camera.target[2] + this.distance * sinPhi * cosTheta;
|
|
1014
1016
|
this.camera.updateMatrix();
|
|
1015
1017
|
}
|
|
1018
|
+
/**
|
|
1019
|
+
* 旋转速度缩放:当 target 远离模型时降低旋转灵敏度,
|
|
1020
|
+
* 使模型在屏幕上的视觉运动速度保持一致。
|
|
1021
|
+
*/
|
|
1022
|
+
getRotateScale() {
|
|
1023
|
+
if (this.zoomDistanceCap === Infinity || this.distance < 1e-6) return 1;
|
|
1024
|
+
const cp = this.camera.position;
|
|
1025
|
+
const mc = this._modelCenter;
|
|
1026
|
+
const dx = cp[0] - mc[0], dy = cp[1] - mc[1], dz = cp[2] - mc[2];
|
|
1027
|
+
const camToCenter = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
1028
|
+
return Math.min(1, camToCenter / this.distance);
|
|
1029
|
+
}
|
|
1016
1030
|
/**
|
|
1017
1031
|
* 缩放有效距离:取 distance、相机到模型中心距离、zoomDistanceCap 三者最小值。
|
|
1018
1032
|
* 保证缩放步长始终与相机到模型的真实接近程度匹配。
|