@d5techs/3dgs-lib 1.4.29 → 1.4.31

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", 1e-3);
628
+ __publicField(this, "zoomSpeed", 15e-4);
629
629
  __publicField(this, "panSpeed", 5e-3);
630
630
  // 移动端触摸灵敏度
631
631
  __publicField(this, "touchZoomSpeed", 0.01);
@@ -637,10 +637,9 @@ 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);
644
643
  __publicField(this, "deltaPanX", 0);
645
644
  __publicField(this, "deltaPanY", 0);
646
645
  __publicField(this, "deltaPanZ", 0);
@@ -739,9 +738,10 @@ const _OrbitControls = class _OrbitControls {
739
738
  const dx = -deltaX * scale;
740
739
  const dy = deltaY * scale;
741
740
  if (this.enableDamping) {
742
- this.deltaPanX += dx * right[0] + dy * up[0];
743
- this.deltaPanY += dx * right[1] + dy * up[1];
744
- this.deltaPanZ += dx * right[2] + dy * up[2];
741
+ const d = this.dampingFactor;
742
+ this.deltaPanX += (dx * right[0] + dy * up[0]) * d;
743
+ this.deltaPanY += (dx * right[1] + dy * up[1]) * d;
744
+ this.deltaPanZ += (dx * right[2] + dy * up[2]) * d;
745
745
  } else {
746
746
  this.camera.target[0] += dx * right[0] + dy * up[0];
747
747
  this.camera.target[1] += dx * right[1] + dy * up[1];
@@ -762,8 +762,8 @@ const _OrbitControls = class _OrbitControls {
762
762
  this.lastY = e.clientY;
763
763
  if (e.buttons === 1) {
764
764
  if (this.enableDamping) {
765
- this.deltaTheta += -deltaX * this.rotateSpeed;
766
- this.deltaPhi += -deltaY * this.rotateSpeed;
765
+ this.deltaTheta += -deltaX * this.rotateSpeed * this.dampingFactor;
766
+ this.deltaPhi += -deltaY * this.rotateSpeed * this.dampingFactor;
767
767
  } else {
768
768
  this.theta -= deltaX * this.rotateSpeed;
769
769
  this.phi -= deltaY * this.rotateSpeed;
@@ -787,16 +787,11 @@ const _OrbitControls = class _OrbitControls {
787
787
  else if (e.deltaMode === 2) delta *= 800;
788
788
  const normalizedDelta = Math.sign(delta) * Math.min(Math.abs(delta), 120);
789
789
  const zoomDelta = normalizedDelta * this.zoomSpeed;
790
- if (this.enableDamping) {
791
- this.deltaDistance += zoomDelta;
792
- } else {
793
- this.distance *= Math.exp(zoomDelta);
794
- this.distance = Math.max(
795
- this.minDistance,
796
- Math.min(this.maxDistance, this.distance)
797
- );
798
- this.applySpherical();
799
- }
790
+ this.distance *= Math.exp(zoomDelta);
791
+ this.distance = Math.max(
792
+ this.minDistance,
793
+ Math.min(this.maxDistance, this.distance)
794
+ );
800
795
  }
801
796
  onKeyDown(e) {
802
797
  var _a2;
@@ -923,8 +918,8 @@ const _OrbitControls = class _OrbitControls {
923
918
  this.lastX = e.touches[0].clientX;
924
919
  this.lastY = e.touches[0].clientY;
925
920
  if (this.enableDamping) {
926
- this.deltaTheta += -deltaX * this.rotateSpeed;
927
- this.deltaPhi += -deltaY * this.rotateSpeed;
921
+ this.deltaTheta += -deltaX * this.rotateSpeed * this.dampingFactor;
922
+ this.deltaPhi += -deltaY * this.rotateSpeed * this.dampingFactor;
928
923
  } else {
929
924
  this.theta -= deltaX * this.rotateSpeed;
930
925
  this.phi -= deltaY * this.rotateSpeed;
@@ -936,15 +931,11 @@ const _OrbitControls = class _OrbitControls {
936
931
  const currentCenter = this.getTouchCenter(e.touches);
937
932
  if (this.lastTouchDistance > 0) {
938
933
  const ratio = currentDistance / this.lastTouchDistance;
939
- if (this.enableDamping) {
940
- this.deltaDistance += -Math.log(ratio);
941
- } else {
942
- this.distance /= ratio;
943
- this.distance = Math.max(
944
- this.minDistance,
945
- Math.min(this.maxDistance, this.distance)
946
- );
947
- }
934
+ this.distance /= ratio;
935
+ this.distance = Math.max(
936
+ this.minDistance,
937
+ Math.min(this.maxDistance, this.distance)
938
+ );
948
939
  }
949
940
  const deltaX = currentCenter.x - this.lastTouchCenter.x;
950
941
  const deltaY = currentCenter.y - this.lastTouchCenter.y;
@@ -953,9 +944,10 @@ const _OrbitControls = class _OrbitControls {
953
944
  const dx = -deltaX * scale;
954
945
  const dy = deltaY * scale;
955
946
  if (this.enableDamping) {
956
- this.deltaPanX += dx * right[0] + dy * up[0];
957
- this.deltaPanY += dx * right[1] + dy * up[1];
958
- this.deltaPanZ += dx * right[2] + dy * up[2];
947
+ const d = this.dampingFactor;
948
+ this.deltaPanX += (dx * right[0] + dy * up[0]) * d;
949
+ this.deltaPanY += (dx * right[1] + dy * up[1]) * d;
950
+ this.deltaPanZ += (dx * right[2] + dy * up[2]) * d;
959
951
  } else {
960
952
  this.camera.target[0] += dx * right[0] + dy * up[0];
961
953
  this.camera.target[1] += dx * right[1] + dy * up[1];
@@ -1017,15 +1009,6 @@ const _OrbitControls = class _OrbitControls {
1017
1009
  this.deltaPhi *= decay;
1018
1010
  if (Math.abs(this.deltaTheta) < EPS) this.deltaTheta = 0;
1019
1011
  if (Math.abs(this.deltaPhi) < EPS) this.deltaPhi = 0;
1020
- if (Math.abs(this.deltaDistance) > EPS) {
1021
- this.distance *= Math.exp(this.deltaDistance);
1022
- this.distance = Math.max(
1023
- this.minDistance,
1024
- Math.min(this.maxDistance, this.distance)
1025
- );
1026
- this.deltaDistance *= decay;
1027
- if (Math.abs(this.deltaDistance) < EPS) this.deltaDistance = 0;
1028
- }
1029
1012
  this.camera.target[0] += this.deltaPanX;
1030
1013
  this.camera.target[1] += this.deltaPanY;
1031
1014
  this.camera.target[2] += this.deltaPanZ;
@@ -1142,7 +1125,6 @@ const _OrbitControls = class _OrbitControls {
1142
1125
  clearVelocity() {
1143
1126
  this.deltaTheta = 0;
1144
1127
  this.deltaPhi = 0;
1145
- this.deltaDistance = 0;
1146
1128
  this.deltaPanX = 0;
1147
1129
  this.deltaPanY = 0;
1148
1130
  this.deltaPanZ = 0;