@d5techs/3dgs-lib 1.4.33 → 1.4.34

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],
@@ -18787,6 +18805,16 @@ class App {
18787
18805
  return false;
18788
18806
  }
18789
18807
  this.controls.frameModel(bbox.center, bbox.radius, animate);
18808
+ if (!animate) {
18809
+ const rect = this.canvas.getBoundingClientRect();
18810
+ const hit = this.pickSplatPosition(
18811
+ rect.left + rect.width / 2,
18812
+ rect.top + rect.height / 2
18813
+ );
18814
+ if (hit) {
18815
+ this.controls.setTargetKeepPosition(hit[0], hit[1], hit[2]);
18816
+ }
18817
+ }
18790
18818
  return true;
18791
18819
  }
18792
18820
  // ============================================