@d5techs/3dgs-lib 1.4.30 → 1.4.32

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
@@ -1103,15 +1103,28 @@ const _OrbitControls = class _OrbitControls {
1103
1103
  const fovRad = this.camera.fov;
1104
1104
  const halfFov = fovRad / 2;
1105
1105
  const marginFactor = 1.5;
1106
- const targetDistance = radius / Math.tan(halfFov) * marginFactor;
1107
- const clampedDistance = Math.max(this.minDistance, targetDistance);
1106
+ const totalDistance = radius / Math.tan(halfFov) * marginFactor;
1107
+ const surfaceOffset = radius * 0.85;
1108
+ const sinPhi = Math.sin(this.phi);
1109
+ const cosPhi = Math.cos(this.phi);
1110
+ const sinTheta = Math.sin(this.theta);
1111
+ const cosTheta = Math.cos(this.theta);
1112
+ const offsetTarget = [
1113
+ center[0] + sinPhi * sinTheta * surfaceOffset,
1114
+ center[1] + cosPhi * surfaceOffset,
1115
+ center[2] + sinPhi * cosTheta * surfaceOffset
1116
+ ];
1117
+ const adjustedDistance = Math.max(
1118
+ this.minDistance,
1119
+ totalDistance - surfaceOffset
1120
+ );
1108
1121
  if (animate) {
1109
- this.animateToFrame(center, clampedDistance);
1122
+ this.animateToFrame(offsetTarget, adjustedDistance);
1110
1123
  } else {
1111
- this.camera.target[0] = center[0];
1112
- this.camera.target[1] = center[1];
1113
- this.camera.target[2] = center[2];
1114
- this.distance = clampedDistance;
1124
+ this.camera.target[0] = offsetTarget[0];
1125
+ this.camera.target[1] = offsetTarget[1];
1126
+ this.camera.target[2] = offsetTarget[2];
1127
+ this.distance = adjustedDistance;
1115
1128
  this.applySpherical();
1116
1129
  }
1117
1130
  }