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