@d5techs/3dgs-lib 1.4.31 → 1.4.33

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", 15e-4);
628
+ __publicField(this, "zoomSpeed", 5e-4);
629
629
  __publicField(this, "panSpeed", 5e-3);
630
630
  // 移动端触摸灵敏度
631
631
  __publicField(this, "touchZoomSpeed", 0.01);
@@ -637,9 +637,10 @@ const _OrbitControls = class _OrbitControls {
637
637
  __publicField(this, "isDragging", false);
638
638
  __publicField(this, "lastX", 0);
639
639
  __publicField(this, "lastY", 0);
640
- // 待应用的增量(每帧全量应用后衰减,实现旋转/平移惯性)
640
+ // 待应用的增量(每帧全量应用后衰减,实现惯性)
641
641
  __publicField(this, "deltaTheta", 0);
642
642
  __publicField(this, "deltaPhi", 0);
643
+ __publicField(this, "deltaDistance", 0);
643
644
  __publicField(this, "deltaPanX", 0);
644
645
  __publicField(this, "deltaPanY", 0);
645
646
  __publicField(this, "deltaPanZ", 0);
@@ -787,11 +788,18 @@ const _OrbitControls = class _OrbitControls {
787
788
  else if (e.deltaMode === 2) delta *= 800;
788
789
  const normalizedDelta = Math.sign(delta) * Math.min(Math.abs(delta), 120);
789
790
  const zoomDelta = normalizedDelta * this.zoomSpeed;
790
- this.distance *= Math.exp(zoomDelta);
791
- this.distance = Math.max(
792
- this.minDistance,
793
- Math.min(this.maxDistance, this.distance)
794
- );
791
+ if (this.enableDamping) {
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);
795
+ } else {
796
+ this.distance *= Math.exp(zoomDelta);
797
+ this.distance = Math.max(
798
+ this.minDistance,
799
+ Math.min(this.maxDistance, this.distance)
800
+ );
801
+ this.applySpherical();
802
+ }
795
803
  }
796
804
  onKeyDown(e) {
797
805
  var _a2;
@@ -931,11 +939,15 @@ const _OrbitControls = class _OrbitControls {
931
939
  const currentCenter = this.getTouchCenter(e.touches);
932
940
  if (this.lastTouchDistance > 0) {
933
941
  const ratio = currentDistance / this.lastTouchDistance;
934
- this.distance /= ratio;
935
- this.distance = Math.max(
936
- this.minDistance,
937
- Math.min(this.maxDistance, this.distance)
938
- );
942
+ if (this.enableDamping) {
943
+ this.deltaDistance += -Math.log(ratio) * this.dampingFactor;
944
+ } else {
945
+ this.distance /= ratio;
946
+ this.distance = Math.max(
947
+ this.minDistance,
948
+ Math.min(this.maxDistance, this.distance)
949
+ );
950
+ }
939
951
  }
940
952
  const deltaX = currentCenter.x - this.lastTouchCenter.x;
941
953
  const deltaY = currentCenter.y - this.lastTouchCenter.y;
@@ -1009,6 +1021,15 @@ const _OrbitControls = class _OrbitControls {
1009
1021
  this.deltaPhi *= decay;
1010
1022
  if (Math.abs(this.deltaTheta) < EPS) this.deltaTheta = 0;
1011
1023
  if (Math.abs(this.deltaPhi) < EPS) this.deltaPhi = 0;
1024
+ if (Math.abs(this.deltaDistance) > EPS) {
1025
+ this.distance *= Math.exp(this.deltaDistance);
1026
+ this.distance = Math.max(
1027
+ this.minDistance,
1028
+ Math.min(this.maxDistance, this.distance)
1029
+ );
1030
+ this.deltaDistance *= decay;
1031
+ if (Math.abs(this.deltaDistance) < EPS) this.deltaDistance = 0;
1032
+ }
1012
1033
  this.camera.target[0] += this.deltaPanX;
1013
1034
  this.camera.target[1] += this.deltaPanY;
1014
1035
  this.camera.target[2] += this.deltaPanZ;
@@ -1125,6 +1146,7 @@ const _OrbitControls = class _OrbitControls {
1125
1146
  clearVelocity() {
1126
1147
  this.deltaTheta = 0;
1127
1148
  this.deltaPhi = 0;
1149
+ this.deltaDistance = 0;
1128
1150
  this.deltaPanX = 0;
1129
1151
  this.deltaPanY = 0;
1130
1152
  this.deltaPanZ = 0;