fix: aim world splat camera at ground plane
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled

This commit is contained in:
Your Name 2026-05-25 21:32:27 +08:00
parent 161126bd4c
commit b40fe24b4a

View File

@ -487,11 +487,21 @@ function positionCameraInsideWorld({
const nearTargetPosition = cameraPosition
.clone()
.addScaledVector(lookDirection, THREE.MathUtils.clamp(majorSpan * 0.24, 0.75, 2.4));
nearTargetPosition.y = THREE.MathUtils.clamp(
eyeY - THREE.MathUtils.clamp(size.y * 0.025, 0.04, 0.18),
minEyeY <= maxEyeY ? minEyeY : worldBounds.min.y,
minEyeY <= maxEyeY ? maxEyeY : worldBounds.max.y
const targetDrop = firstPerson
? THREE.MathUtils.clamp(humanEyeOffset * 0.46 + size.y * 0.035, 0.38, 0.95)
: THREE.MathUtils.clamp(size.y * 0.025, 0.04, 0.18);
const minLookTargetY = Math.max(
worldBounds.min.y + Math.max(size.y * 0.04, 0.08),
estimatedFloorY + 0.05
);
const maxLookTargetY =
minEyeY <= maxEyeY
? maxEyeY
: worldBounds.max.y - Math.max(size.y * 0.08, 0.16);
nearTargetPosition.y =
minLookTargetY <= maxLookTargetY
? THREE.MathUtils.clamp(eyeY - targetDrop, minLookTargetY, maxLookTargetY)
: eyeY - targetDrop;
nearTargetPosition.x = clampInsideAxis(
nearTargetPosition.x,
worldBounds.min.x,