@d5techs/3dgs-lib 1.4.27 → 1.4.28

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", 8e-4);
627
627
  __publicField(this, "panSpeed", 5e-3);
628
628
  // 移动端触摸灵敏度
629
629
  __publicField(this, "touchZoomSpeed", 0.01);
@@ -635,10 +635,7 @@ const _OrbitControls = class _OrbitControls {
635
635
  __publicField(this, "isDragging", false);
636
636
  __publicField(this, "lastX", 0);
637
637
  __publicField(this, "lastY", 0);
638
- // 阻尼速度
639
- __publicField(this, "velocityTheta", 0);
640
- __publicField(this, "velocityPhi", 0);
641
- __publicField(this, "velocityDistance", 0);
638
+ // 阻尼速度(仅平移使用)
642
639
  __publicField(this, "velocityPanX", 0);
643
640
  __publicField(this, "velocityPanY", 0);
644
641
  __publicField(this, "velocityPanZ", 0);
@@ -759,22 +756,15 @@ const _OrbitControls = class _OrbitControls {
759
756
  this.lastX = e.clientX;
760
757
  this.lastY = e.clientY;
761
758
  if (e.buttons === 1) {
762
- if (this.enableDamping) {
763
- this.velocityTheta += -deltaX * this.rotateSpeed;
764
- this.velocityPhi += -deltaY * this.rotateSpeed;
765
- const maxRotVel = 0.5;
766
- this.velocityTheta = Math.max(-maxRotVel, Math.min(maxRotVel, this.velocityTheta));
767
- this.velocityPhi = Math.max(-maxRotVel, Math.min(maxRotVel, this.velocityPhi));
768
- } else {
769
- this.theta -= deltaX * this.rotateSpeed;
770
- this.phi -= deltaY * this.rotateSpeed;
771
- this.phi = Math.max(this.minPhi, Math.min(this.maxPhi, this.phi));
772
- }
759
+ this.theta -= deltaX * this.rotateSpeed;
760
+ this.phi -= deltaY * this.rotateSpeed;
761
+ this.phi = Math.max(this.minPhi, Math.min(this.maxPhi, this.phi));
762
+ this.applySpherical();
773
763
  } else if (e.buttons === 2 || e.buttons === 4) {
774
764
  this.panByScreenDelta(deltaX, deltaY);
775
- }
776
- if (!this.enableDamping) {
777
- this.applySpherical();
765
+ if (!this.enableDamping) {
766
+ this.applySpherical();
767
+ }
778
768
  }
779
769
  }
780
770
  onMouseUp() {
@@ -786,20 +776,14 @@ const _OrbitControls = class _OrbitControls {
786
776
  let delta = e.deltaY;
787
777
  if (e.deltaMode === 1) delta *= 40;
788
778
  else if (e.deltaMode === 2) delta *= 800;
789
- const normalizedDelta = Math.sign(delta) * Math.min(Math.abs(delta), 150);
790
- const zoomDelta = normalizedDelta * this.zoomSpeed;
791
- if (this.enableDamping) {
792
- this.velocityDistance += zoomDelta;
793
- const maxVelocity = 2;
794
- this.velocityDistance = Math.max(-maxVelocity, Math.min(maxVelocity, this.velocityDistance));
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
- }
779
+ const normalizedDelta = Math.sign(delta) * Math.min(Math.abs(delta), 120);
780
+ const factor = 1 + normalizedDelta * this.zoomSpeed;
781
+ this.distance *= factor;
782
+ this.distance = Math.max(
783
+ this.minDistance,
784
+ Math.min(this.maxDistance, this.distance)
785
+ );
786
+ this.applySpherical();
803
787
  }
804
788
  onKeyDown(e) {
805
789
  var _a2;
@@ -925,30 +909,20 @@ const _OrbitControls = class _OrbitControls {
925
909
  const deltaY = e.touches[0].clientY - this.lastY;
926
910
  this.lastX = e.touches[0].clientX;
927
911
  this.lastY = e.touches[0].clientY;
928
- if (this.enableDamping) {
929
- this.velocityTheta += -deltaX * this.rotateSpeed;
930
- this.velocityPhi += -deltaY * this.rotateSpeed;
931
- } else {
932
- this.theta -= deltaX * this.rotateSpeed;
933
- this.phi -= deltaY * this.rotateSpeed;
934
- this.phi = Math.max(this.minPhi, Math.min(this.maxPhi, this.phi));
935
- this.applySpherical();
936
- }
912
+ this.theta -= deltaX * this.rotateSpeed;
913
+ this.phi -= deltaY * this.rotateSpeed;
914
+ this.phi = Math.max(this.minPhi, Math.min(this.maxPhi, this.phi));
915
+ this.applySpherical();
937
916
  } else if (e.touches.length === 2) {
938
917
  const currentDistance = this.getTouchDistance(e.touches);
939
918
  const currentCenter = this.getTouchCenter(e.touches);
940
919
  if (this.lastTouchDistance > 0) {
941
920
  const ratio = currentDistance / this.lastTouchDistance;
942
- const zoomDelta = -Math.log(ratio) / (this.touchZoomSpeed * 100);
943
- if (this.enableDamping) {
944
- this.velocityDistance += zoomDelta;
945
- } else {
946
- this.distance *= Math.exp(zoomDelta);
947
- this.distance = Math.max(
948
- this.minDistance,
949
- Math.min(this.maxDistance, this.distance)
950
- );
951
- }
921
+ this.distance /= ratio;
922
+ this.distance = Math.max(
923
+ this.minDistance,
924
+ Math.min(this.maxDistance, this.distance)
925
+ );
952
926
  }
953
927
  const deltaX = currentCenter.x - this.lastTouchCenter.x;
954
928
  const deltaY = currentCenter.y - this.lastTouchCenter.y;
@@ -967,9 +941,7 @@ const _OrbitControls = class _OrbitControls {
967
941
  }
968
942
  this.lastTouchDistance = currentDistance;
969
943
  this.lastTouchCenter = currentCenter;
970
- if (!this.enableDamping) {
971
- this.applySpherical();
972
- }
944
+ this.applySpherical();
973
945
  }
974
946
  }
975
947
  onTouchEnd(e) {
@@ -1016,27 +988,13 @@ const _OrbitControls = class _OrbitControls {
1016
988
  if (this.enableDamping) {
1017
989
  const EPS = 1e-6;
1018
990
  const f = this.dampingFactor;
1019
- this.theta += this.velocityTheta * f;
1020
- this.phi += this.velocityPhi * f;
1021
- this.phi = Math.max(this.minPhi, Math.min(this.maxPhi, this.phi));
1022
- this.distance *= Math.exp(this.velocityDistance * f);
1023
- this.distance = Math.max(
1024
- this.minDistance,
1025
- Math.min(this.maxDistance, this.distance)
1026
- );
1027
991
  this.camera.target[0] += this.velocityPanX * f;
1028
992
  this.camera.target[1] += this.velocityPanY * f;
1029
993
  this.camera.target[2] += this.velocityPanZ * f;
1030
994
  const decay = 1 - f;
1031
- this.velocityTheta *= decay;
1032
- this.velocityPhi *= decay;
1033
- this.velocityDistance *= decay;
1034
995
  this.velocityPanX *= decay;
1035
996
  this.velocityPanY *= decay;
1036
997
  this.velocityPanZ *= decay;
1037
- if (Math.abs(this.velocityTheta) < EPS) this.velocityTheta = 0;
1038
- if (Math.abs(this.velocityPhi) < EPS) this.velocityPhi = 0;
1039
- if (Math.abs(this.velocityDistance) < EPS) this.velocityDistance = 0;
1040
998
  if (Math.abs(this.velocityPanX) < EPS) this.velocityPanX = 0;
1041
999
  if (Math.abs(this.velocityPanY) < EPS) this.velocityPanY = 0;
1042
1000
  if (Math.abs(this.velocityPanZ) < EPS) this.velocityPanZ = 0;
@@ -1145,9 +1103,6 @@ const _OrbitControls = class _OrbitControls {
1145
1103
  requestAnimationFrame(animate);
1146
1104
  }
1147
1105
  clearVelocity() {
1148
- this.velocityTheta = 0;
1149
- this.velocityPhi = 0;
1150
- this.velocityDistance = 0;
1151
1106
  this.velocityPanX = 0;
1152
1107
  this.velocityPanY = 0;
1153
1108
  this.velocityPanZ = 0;