@d5techs/3dgs-lib 1.4.32 → 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 +38 -21
- package/dist/3dgs-lib.cjs.map +1 -1
- package/dist/3dgs-lib.js +38 -21
- package/dist/3dgs-lib.js.map +1 -1
- package/dist/core/OrbitControls.d.ts +4 -0
- package/package.json +1 -1
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",
|
|
628
|
+
__publicField(this, "zoomSpeed", 1e-3);
|
|
629
629
|
__publicField(this, "panSpeed", 5e-3);
|
|
630
630
|
// 移动端触摸灵敏度
|
|
631
631
|
__publicField(this, "touchZoomSpeed", 0.01);
|
|
@@ -790,6 +790,8 @@ const _OrbitControls = class _OrbitControls {
|
|
|
790
790
|
const zoomDelta = normalizedDelta * this.zoomSpeed;
|
|
791
791
|
if (this.enableDamping) {
|
|
792
792
|
this.deltaDistance += zoomDelta * this.dampingFactor;
|
|
793
|
+
const maxAccum = 120 * this.zoomSpeed * this.dampingFactor * 3;
|
|
794
|
+
this.deltaDistance = Math.sign(this.deltaDistance) * Math.min(Math.abs(this.deltaDistance), maxAccum);
|
|
793
795
|
} else {
|
|
794
796
|
this.distance *= Math.exp(zoomDelta);
|
|
795
797
|
this.distance = Math.max(
|
|
@@ -1093,6 +1095,24 @@ const _OrbitControls = class _OrbitControls {
|
|
|
1093
1095
|
this.camera.target[2] = z;
|
|
1094
1096
|
this.applySpherical();
|
|
1095
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
|
+
}
|
|
1096
1116
|
getTarget() {
|
|
1097
1117
|
return [
|
|
1098
1118
|
this.camera.target[0],
|
|
@@ -1105,28 +1125,15 @@ const _OrbitControls = class _OrbitControls {
|
|
|
1105
1125
|
const fovRad = this.camera.fov;
|
|
1106
1126
|
const halfFov = fovRad / 2;
|
|
1107
1127
|
const marginFactor = 1.5;
|
|
1108
|
-
const
|
|
1109
|
-
const
|
|
1110
|
-
const sinPhi = Math.sin(this.phi);
|
|
1111
|
-
const cosPhi = Math.cos(this.phi);
|
|
1112
|
-
const sinTheta = Math.sin(this.theta);
|
|
1113
|
-
const cosTheta = Math.cos(this.theta);
|
|
1114
|
-
const offsetTarget = [
|
|
1115
|
-
center[0] + sinPhi * sinTheta * surfaceOffset,
|
|
1116
|
-
center[1] + cosPhi * surfaceOffset,
|
|
1117
|
-
center[2] + sinPhi * cosTheta * surfaceOffset
|
|
1118
|
-
];
|
|
1119
|
-
const adjustedDistance = Math.max(
|
|
1120
|
-
this.minDistance,
|
|
1121
|
-
totalDistance - surfaceOffset
|
|
1122
|
-
);
|
|
1128
|
+
const targetDistance = radius / Math.tan(halfFov) * marginFactor;
|
|
1129
|
+
const clampedDistance = Math.max(this.minDistance, targetDistance);
|
|
1123
1130
|
if (animate) {
|
|
1124
|
-
this.animateToFrame(
|
|
1131
|
+
this.animateToFrame(center, clampedDistance);
|
|
1125
1132
|
} else {
|
|
1126
|
-
this.camera.target[0] =
|
|
1127
|
-
this.camera.target[1] =
|
|
1128
|
-
this.camera.target[2] =
|
|
1129
|
-
this.distance =
|
|
1133
|
+
this.camera.target[0] = center[0];
|
|
1134
|
+
this.camera.target[1] = center[1];
|
|
1135
|
+
this.camera.target[2] = center[2];
|
|
1136
|
+
this.distance = clampedDistance;
|
|
1130
1137
|
this.applySpherical();
|
|
1131
1138
|
}
|
|
1132
1139
|
}
|
|
@@ -18798,6 +18805,16 @@ class App {
|
|
|
18798
18805
|
return false;
|
|
18799
18806
|
}
|
|
18800
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
|
+
}
|
|
18801
18818
|
return true;
|
|
18802
18819
|
}
|
|
18803
18820
|
// ============================================
|