@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.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", 3e-3);
625
+ __publicField(this, "rotateSpeed", 5e-3);
626
626
  __publicField(this, "zoomSpeed", 1e-3);
627
627
  __publicField(this, "panSpeed", 5e-3);
628
628
  // 移动端触摸灵敏度
@@ -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 * this.rotateSpeed * this.dampingFactor;
769
- this.deltaPhi += -deltaY * this.rotateSpeed * this.dampingFactor;
769
+ this.deltaTheta += -deltaX * rs * this.dampingFactor;
770
+ this.deltaPhi += -deltaY * rs * this.dampingFactor;
770
771
  } else {
771
- this.theta -= deltaX * this.rotateSpeed;
772
- this.phi -= deltaY * this.rotateSpeed;
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) {
@@ -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 * this.rotateSpeed * this.dampingFactor;
934
- this.deltaPhi += -deltaY * this.rotateSpeed * this.dampingFactor;
935
+ this.deltaTheta += -deltaX * rs * this.dampingFactor;
936
+ this.deltaPhi += -deltaY * rs * this.dampingFactor;
935
937
  } else {
936
- this.theta -= deltaX * this.rotateSpeed;
937
- this.phi -= deltaY * this.rotateSpeed;
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
  }
@@ -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
  * 保证缩放步长始终与相机到模型的真实接近程度匹配。