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