@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.js CHANGED
@@ -623,7 +623,7 @@ const _OrbitControls = class _OrbitControls {
623
623
  __publicField(this, "maxPhi", Math.PI - 0.01);
624
624
  // 灵敏度
625
625
  __publicField(this, "rotateSpeed", 5e-3);
626
- __publicField(this, "zoomSpeed", 1e-3);
626
+ __publicField(this, "zoomSpeed", 15e-4);
627
627
  __publicField(this, "panSpeed", 5e-3);
628
628
  // 移动端触摸灵敏度
629
629
  __publicField(this, "touchZoomSpeed", 0.01);
@@ -635,10 +635,9 @@ const _OrbitControls = class _OrbitControls {
635
635
  __publicField(this, "isDragging", false);
636
636
  __publicField(this, "lastX", 0);
637
637
  __publicField(this, "lastY", 0);
638
- // 待应用的增量(每帧全量应用后衰减,实现惯性)
638
+ // 待应用的增量(每帧全量应用后衰减,实现旋转/平移惯性)
639
639
  __publicField(this, "deltaTheta", 0);
640
640
  __publicField(this, "deltaPhi", 0);
641
- __publicField(this, "deltaDistance", 0);
642
641
  __publicField(this, "deltaPanX", 0);
643
642
  __publicField(this, "deltaPanY", 0);
644
643
  __publicField(this, "deltaPanZ", 0);
@@ -737,9 +736,10 @@ const _OrbitControls = class _OrbitControls {
737
736
  const dx = -deltaX * scale;
738
737
  const dy = deltaY * scale;
739
738
  if (this.enableDamping) {
740
- this.deltaPanX += dx * right[0] + dy * up[0];
741
- this.deltaPanY += dx * right[1] + dy * up[1];
742
- this.deltaPanZ += dx * right[2] + dy * up[2];
739
+ const d = this.dampingFactor;
740
+ this.deltaPanX += (dx * right[0] + dy * up[0]) * d;
741
+ this.deltaPanY += (dx * right[1] + dy * up[1]) * d;
742
+ this.deltaPanZ += (dx * right[2] + dy * up[2]) * d;
743
743
  } else {
744
744
  this.camera.target[0] += dx * right[0] + dy * up[0];
745
745
  this.camera.target[1] += dx * right[1] + dy * up[1];
@@ -760,8 +760,8 @@ const _OrbitControls = class _OrbitControls {
760
760
  this.lastY = e.clientY;
761
761
  if (e.buttons === 1) {
762
762
  if (this.enableDamping) {
763
- this.deltaTheta += -deltaX * this.rotateSpeed;
764
- this.deltaPhi += -deltaY * this.rotateSpeed;
763
+ this.deltaTheta += -deltaX * this.rotateSpeed * this.dampingFactor;
764
+ this.deltaPhi += -deltaY * this.rotateSpeed * this.dampingFactor;
765
765
  } else {
766
766
  this.theta -= deltaX * this.rotateSpeed;
767
767
  this.phi -= deltaY * this.rotateSpeed;
@@ -785,16 +785,11 @@ const _OrbitControls = class _OrbitControls {
785
785
  else if (e.deltaMode === 2) delta *= 800;
786
786
  const normalizedDelta = Math.sign(delta) * Math.min(Math.abs(delta), 120);
787
787
  const zoomDelta = normalizedDelta * this.zoomSpeed;
788
- if (this.enableDamping) {
789
- this.deltaDistance += zoomDelta;
790
- } else {
791
- this.distance *= Math.exp(zoomDelta);
792
- this.distance = Math.max(
793
- this.minDistance,
794
- Math.min(this.maxDistance, this.distance)
795
- );
796
- this.applySpherical();
797
- }
788
+ this.distance *= Math.exp(zoomDelta);
789
+ this.distance = Math.max(
790
+ this.minDistance,
791
+ Math.min(this.maxDistance, this.distance)
792
+ );
798
793
  }
799
794
  onKeyDown(e) {
800
795
  var _a2;
@@ -921,8 +916,8 @@ const _OrbitControls = class _OrbitControls {
921
916
  this.lastX = e.touches[0].clientX;
922
917
  this.lastY = e.touches[0].clientY;
923
918
  if (this.enableDamping) {
924
- this.deltaTheta += -deltaX * this.rotateSpeed;
925
- this.deltaPhi += -deltaY * this.rotateSpeed;
919
+ this.deltaTheta += -deltaX * this.rotateSpeed * this.dampingFactor;
920
+ this.deltaPhi += -deltaY * this.rotateSpeed * this.dampingFactor;
926
921
  } else {
927
922
  this.theta -= deltaX * this.rotateSpeed;
928
923
  this.phi -= deltaY * this.rotateSpeed;
@@ -934,15 +929,11 @@ const _OrbitControls = class _OrbitControls {
934
929
  const currentCenter = this.getTouchCenter(e.touches);
935
930
  if (this.lastTouchDistance > 0) {
936
931
  const ratio = currentDistance / this.lastTouchDistance;
937
- if (this.enableDamping) {
938
- this.deltaDistance += -Math.log(ratio);
939
- } else {
940
- this.distance /= ratio;
941
- this.distance = Math.max(
942
- this.minDistance,
943
- Math.min(this.maxDistance, this.distance)
944
- );
945
- }
932
+ this.distance /= ratio;
933
+ this.distance = Math.max(
934
+ this.minDistance,
935
+ Math.min(this.maxDistance, this.distance)
936
+ );
946
937
  }
947
938
  const deltaX = currentCenter.x - this.lastTouchCenter.x;
948
939
  const deltaY = currentCenter.y - this.lastTouchCenter.y;
@@ -951,9 +942,10 @@ const _OrbitControls = class _OrbitControls {
951
942
  const dx = -deltaX * scale;
952
943
  const dy = deltaY * scale;
953
944
  if (this.enableDamping) {
954
- this.deltaPanX += dx * right[0] + dy * up[0];
955
- this.deltaPanY += dx * right[1] + dy * up[1];
956
- this.deltaPanZ += dx * right[2] + dy * up[2];
945
+ const d = this.dampingFactor;
946
+ this.deltaPanX += (dx * right[0] + dy * up[0]) * d;
947
+ this.deltaPanY += (dx * right[1] + dy * up[1]) * d;
948
+ this.deltaPanZ += (dx * right[2] + dy * up[2]) * d;
957
949
  } else {
958
950
  this.camera.target[0] += dx * right[0] + dy * up[0];
959
951
  this.camera.target[1] += dx * right[1] + dy * up[1];
@@ -1015,15 +1007,6 @@ const _OrbitControls = class _OrbitControls {
1015
1007
  this.deltaPhi *= decay;
1016
1008
  if (Math.abs(this.deltaTheta) < EPS) this.deltaTheta = 0;
1017
1009
  if (Math.abs(this.deltaPhi) < EPS) this.deltaPhi = 0;
1018
- if (Math.abs(this.deltaDistance) > EPS) {
1019
- this.distance *= Math.exp(this.deltaDistance);
1020
- this.distance = Math.max(
1021
- this.minDistance,
1022
- Math.min(this.maxDistance, this.distance)
1023
- );
1024
- this.deltaDistance *= decay;
1025
- if (Math.abs(this.deltaDistance) < EPS) this.deltaDistance = 0;
1026
- }
1027
1010
  this.camera.target[0] += this.deltaPanX;
1028
1011
  this.camera.target[1] += this.deltaPanY;
1029
1012
  this.camera.target[2] += this.deltaPanZ;
@@ -1140,7 +1123,6 @@ const _OrbitControls = class _OrbitControls {
1140
1123
  clearVelocity() {
1141
1124
  this.deltaTheta = 0;
1142
1125
  this.deltaPhi = 0;
1143
- this.deltaDistance = 0;
1144
1126
  this.deltaPanX = 0;
1145
1127
  this.deltaPanY = 0;
1146
1128
  this.deltaPanZ = 0;