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

This commit is contained in:
2026-04-11 22:12:59 +02:00
parent e9ce5083ba
commit 5c7e606aa6

View File

@@ -328,7 +328,8 @@ export class FirstPersonNavigationController 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) ?? {
@@ -437,6 +438,10 @@ export class FirstPersonNavigationController implements NavigationController {
);
const cameraVolumeState =
this.context.resolvePlayerVolumeState(eyePosition);
const cameraSubmerged =
cameraVolumeState.inWater &&
cameraVolumeState.waterSurfaceHeight !== null &&
eyePosition.y < cameraVolumeState.waterSurfaceHeight;
const telemetry = createPlayerControllerTelemetry({
feetPosition: {
@@ -449,7 +454,7 @@ export class FirstPersonNavigationController implements NavigationController {
this.context.getRuntimeScene().playerMovement
),
inWaterVolume: this.inWaterVolume,
cameraSubmerged: cameraVolumeState.inWater,
cameraSubmerged,
inFogVolume: this.inFogVolume,
pointerLocked: this.pointerLocked,
spawn: this.context.getRuntimeScene().spawn,