@d5techs/3dgs-lib 1.4.36 → 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.cjs +13 -3
- package/dist/3dgs-lib.cjs.map +1 -1
- package/dist/3dgs-lib.js +13 -3
- package/dist/3dgs-lib.js.map +1 -1
- package/dist/core/OrbitControls.d.ts +1 -0
- package/package.json +1 -1
package/dist/3dgs-lib.cjs
CHANGED
|
@@ -630,6 +630,9 @@ const _OrbitControls = class _OrbitControls {
|
|
|
630
630
|
// 移动端触摸灵敏度
|
|
631
631
|
__publicField(this, "touchZoomSpeed", 0.01);
|
|
632
632
|
__publicField(this, "touchPanSpeed", 3e-3);
|
|
633
|
+
// 缩放步长上限:用 min(distance, zoomDistanceCap) 计算每步的绝对位移,
|
|
634
|
+
// 使远距离时缩放速度由模型尺寸而非 target 位置决定。frameModel 会自动设置为 radius。
|
|
635
|
+
__publicField(this, "zoomDistanceCap", Infinity);
|
|
633
636
|
// 阻尼:每帧应用全量 delta,然后 delta *= (1 - dampingFactor) 实现惯性
|
|
634
637
|
__publicField(this, "enableDamping", true);
|
|
635
638
|
__publicField(this, "dampingFactor", 0.1);
|
|
@@ -793,7 +796,9 @@ const _OrbitControls = class _OrbitControls {
|
|
|
793
796
|
const maxAccum = 120 * this.zoomSpeed * this.dampingFactor * 3;
|
|
794
797
|
this.deltaDistance = Math.sign(this.deltaDistance) * Math.min(Math.abs(this.deltaDistance), maxAccum);
|
|
795
798
|
} else {
|
|
796
|
-
|
|
799
|
+
const factor = Math.exp(zoomDelta);
|
|
800
|
+
const effectiveDist = Math.min(this.distance, this.zoomDistanceCap);
|
|
801
|
+
this.distance -= effectiveDist * (1 - factor);
|
|
797
802
|
this.distance = Math.max(
|
|
798
803
|
this.minDistance,
|
|
799
804
|
Math.min(this.maxDistance, this.distance)
|
|
@@ -942,7 +947,9 @@ const _OrbitControls = class _OrbitControls {
|
|
|
942
947
|
if (this.enableDamping) {
|
|
943
948
|
this.deltaDistance += -Math.log(ratio) * this.dampingFactor;
|
|
944
949
|
} else {
|
|
945
|
-
|
|
950
|
+
const factor = 1 / ratio;
|
|
951
|
+
const effectiveDist = Math.min(this.distance, this.zoomDistanceCap);
|
|
952
|
+
this.distance -= effectiveDist * (1 - factor);
|
|
946
953
|
this.distance = Math.max(
|
|
947
954
|
this.minDistance,
|
|
948
955
|
Math.min(this.maxDistance, this.distance)
|
|
@@ -1022,7 +1029,9 @@ const _OrbitControls = class _OrbitControls {
|
|
|
1022
1029
|
if (Math.abs(this.deltaTheta) < EPS) this.deltaTheta = 0;
|
|
1023
1030
|
if (Math.abs(this.deltaPhi) < EPS) this.deltaPhi = 0;
|
|
1024
1031
|
if (Math.abs(this.deltaDistance) > EPS) {
|
|
1025
|
-
|
|
1032
|
+
const factor = Math.exp(this.deltaDistance);
|
|
1033
|
+
const effectiveDist = Math.min(this.distance, this.zoomDistanceCap);
|
|
1034
|
+
this.distance -= effectiveDist * (1 - factor);
|
|
1026
1035
|
this.distance = Math.max(
|
|
1027
1036
|
this.minDistance,
|
|
1028
1037
|
Math.min(this.maxDistance, this.distance)
|
|
@@ -1122,6 +1131,7 @@ const _OrbitControls = class _OrbitControls {
|
|
|
1122
1131
|
}
|
|
1123
1132
|
frameModel(center, radius, animate = true) {
|
|
1124
1133
|
this.clearVelocity();
|
|
1134
|
+
this.zoomDistanceCap = radius;
|
|
1125
1135
|
const fovRad = this.camera.fov;
|
|
1126
1136
|
const halfFov = fovRad / 2;
|
|
1127
1137
|
const marginFactor = 1.5;
|