@d5techs/3dgs-lib 1.4.35 → 1.4.37

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
@@ -628,6 +628,9 @@ const _OrbitControls = class _OrbitControls {
628
628
  // 移动端触摸灵敏度
629
629
  __publicField(this, "touchZoomSpeed", 0.01);
630
630
  __publicField(this, "touchPanSpeed", 3e-3);
631
+ // 缩放步长上限:用 min(distance, zoomDistanceCap) 计算每步的绝对位移,
632
+ // 使远距离时缩放速度由模型尺寸而非 target 位置决定。frameModel 会自动设置为 radius。
633
+ __publicField(this, "zoomDistanceCap", Infinity);
631
634
  // 阻尼:每帧应用全量 delta,然后 delta *= (1 - dampingFactor) 实现惯性
632
635
  __publicField(this, "enableDamping", true);
633
636
  __publicField(this, "dampingFactor", 0.1);
@@ -791,7 +794,9 @@ const _OrbitControls = class _OrbitControls {
791
794
  const maxAccum = 120 * this.zoomSpeed * this.dampingFactor * 3;
792
795
  this.deltaDistance = Math.sign(this.deltaDistance) * Math.min(Math.abs(this.deltaDistance), maxAccum);
793
796
  } else {
794
- this.distance *= Math.exp(zoomDelta);
797
+ const factor = Math.exp(zoomDelta);
798
+ const effectiveDist = Math.min(this.distance, this.zoomDistanceCap);
799
+ this.distance -= effectiveDist * (1 - factor);
795
800
  this.distance = Math.max(
796
801
  this.minDistance,
797
802
  Math.min(this.maxDistance, this.distance)
@@ -940,7 +945,9 @@ const _OrbitControls = class _OrbitControls {
940
945
  if (this.enableDamping) {
941
946
  this.deltaDistance += -Math.log(ratio) * this.dampingFactor;
942
947
  } else {
943
- this.distance /= ratio;
948
+ const factor = 1 / ratio;
949
+ const effectiveDist = Math.min(this.distance, this.zoomDistanceCap);
950
+ this.distance -= effectiveDist * (1 - factor);
944
951
  this.distance = Math.max(
945
952
  this.minDistance,
946
953
  Math.min(this.maxDistance, this.distance)
@@ -1020,7 +1027,9 @@ const _OrbitControls = class _OrbitControls {
1020
1027
  if (Math.abs(this.deltaTheta) < EPS) this.deltaTheta = 0;
1021
1028
  if (Math.abs(this.deltaPhi) < EPS) this.deltaPhi = 0;
1022
1029
  if (Math.abs(this.deltaDistance) > EPS) {
1023
- this.distance *= Math.exp(this.deltaDistance);
1030
+ const factor = Math.exp(this.deltaDistance);
1031
+ const effectiveDist = Math.min(this.distance, this.zoomDistanceCap);
1032
+ this.distance -= effectiveDist * (1 - factor);
1024
1033
  this.distance = Math.max(
1025
1034
  this.minDistance,
1026
1035
  Math.min(this.maxDistance, this.distance)
@@ -1120,6 +1129,7 @@ const _OrbitControls = class _OrbitControls {
1120
1129
  }
1121
1130
  frameModel(center, radius, animate = true) {
1122
1131
  this.clearVelocity();
1132
+ this.zoomDistanceCap = radius;
1123
1133
  const fovRad = this.camera.fov;
1124
1134
  const halfFov = fovRad / 2;
1125
1135
  const marginFactor = 1.5;
@@ -18807,7 +18817,7 @@ class App {
18807
18817
  }
18808
18818
  /**
18809
18819
  * 将 orbit target 吸附到视口中心的模型表面点,保持相机位置不变。
18810
- * 用于相机初始化完成后改善缩放手感(target 在表面而非包围盒中心)。
18820
+ * 调用方可在相机初始化完毕后主动调用以改善缩放手感。
18811
18821
  */
18812
18822
  snapTargetToSurface() {
18813
18823
  const rect = this.canvas.getBoundingClientRect();