@d5techs/3dgs-lib 1.4.33 → 1.4.35

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 CHANGED
@@ -625,7 +625,7 @@ const _OrbitControls = class _OrbitControls {
625
625
  __publicField(this, "maxPhi", Math.PI - 0.01);
626
626
  // 灵敏度
627
627
  __publicField(this, "rotateSpeed", 5e-3);
628
- __publicField(this, "zoomSpeed", 5e-4);
628
+ __publicField(this, "zoomSpeed", 1e-3);
629
629
  __publicField(this, "panSpeed", 5e-3);
630
630
  // 移动端触摸灵敏度
631
631
  __publicField(this, "touchZoomSpeed", 0.01);
@@ -1095,6 +1095,24 @@ const _OrbitControls = class _OrbitControls {
1095
1095
  this.camera.target[2] = z;
1096
1096
  this.applySpherical();
1097
1097
  }
1098
+ /**
1099
+ * 将 target 移到新位置,但保持相机世界坐标不变(重算 distance/theta/phi)
1100
+ */
1101
+ setTargetKeepPosition(x, y, z) {
1102
+ this.clearVelocity();
1103
+ const dx = this.camera.position[0] - x;
1104
+ const dy = this.camera.position[1] - y;
1105
+ const dz = this.camera.position[2] - z;
1106
+ const newDist = Math.sqrt(dx * dx + dy * dy + dz * dz);
1107
+ if (newDist < this.minDistance) return;
1108
+ this.camera.target[0] = x;
1109
+ this.camera.target[1] = y;
1110
+ this.camera.target[2] = z;
1111
+ this.distance = newDist;
1112
+ this.theta = Math.atan2(dx, dz);
1113
+ this.phi = Math.acos(Math.min(1, Math.max(-1, dy / newDist)));
1114
+ this.applySpherical();
1115
+ }
1098
1116
  getTarget() {
1099
1117
  return [
1100
1118
  this.camera.target[0],
@@ -18789,6 +18807,22 @@ class App {
18789
18807
  this.controls.frameModel(bbox.center, bbox.radius, animate);
18790
18808
  return true;
18791
18809
  }
18810
+ /**
18811
+ * 将 orbit target 吸附到视口中心的模型表面点,保持相机位置不变。
18812
+ * 用于相机初始化完成后改善缩放手感(target 在表面而非包围盒中心)。
18813
+ */
18814
+ snapTargetToSurface() {
18815
+ const rect = this.canvas.getBoundingClientRect();
18816
+ const hit = this.pickSplatPosition(
18817
+ rect.left + rect.width / 2,
18818
+ rect.top + rect.height / 2
18819
+ );
18820
+ if (hit) {
18821
+ this.controls.setTargetKeepPosition(hit[0], hit[1], hit[2]);
18822
+ return true;
18823
+ }
18824
+ return false;
18825
+ }
18792
18826
  // ============================================
18793
18827
  // Gizmo(委托给 GizmoManager)
18794
18828
  // ============================================