Add water surface height to volume state and update camera submerged logic

This commit is contained in:
2026-04-11 22:13:10 +02:00
parent 5c7e606aa6
commit 5e7c04bfd3

View File

@@ -300,7 +300,8 @@ export class ThirdPersonNavigationController implements NavigationController {
resolveVolumeState: (feetPosition) =>
this.context?.resolvePlayerVolumeState(feetPosition) ?? {
inWater: false,
inFog: false
inFog: false,
waterSurfaceHeight: null
},
probeGround: (feetPosition, shape, maxDistance) =>
this.context?.probePlayerGround?.(feetPosition, shape, maxDistance) ?? {
@@ -435,6 +436,10 @@ export class ThirdPersonNavigationController implements NavigationController {
y: this.context.camera.position.y,
z: this.context.camera.position.z
});
const cameraSubmerged =
cameraVolumeState.inWater &&
cameraVolumeState.waterSurfaceHeight !== null &&
this.context.camera.position.y < cameraVolumeState.waterSurfaceHeight;
const telemetry = createPlayerControllerTelemetry({
feetPosition: {
@@ -447,7 +452,7 @@ export class ThirdPersonNavigationController implements NavigationController {
this.context.getRuntimeScene().playerMovement
),
inWaterVolume: this.inWaterVolume,
cameraSubmerged: cameraVolumeState.inWater,
cameraSubmerged,
inFogVolume: this.inFogVolume,
pointerLocked: false,
spawn: this.context.getRuntimeScene().spawn,