Update RunnerCanvas to use cameraSubmerged for underwater overlay and add tests

This commit is contained in:
2026-04-07 05:29:41 +02:00
parent b062b2beea
commit 0826cc78bb
6 changed files with 130 additions and 5 deletions

View File

@@ -176,14 +176,17 @@ export class FirstPersonNavigationController {
if (this.context === null) {
return;
}
const eyePosition = toEyePosition(this.feetPosition, getFirstPersonPlayerEyeHeight(this.context.getRuntimeScene().playerCollider));
const cameraVolumeState = this.context.resolvePlayerVolumeState(eyePosition);
this.context.setFirstPersonTelemetry({
feetPosition: {
...this.feetPosition
},
eyePosition: toEyePosition(this.feetPosition, getFirstPersonPlayerEyeHeight(this.context.getRuntimeScene().playerCollider)),
eyePosition,
grounded: this.grounded,
locomotionState: this.locomotionState,
inWaterVolume: this.inWaterVolume,
cameraSubmerged: cameraVolumeState.inWater,
inFogVolume: this.inFogVolume,
pointerLocked: this.pointerLocked,
spawn: this.context.getRuntimeScene().spawn

View File

@@ -209,14 +209,18 @@ export class FirstPersonNavigationController implements NavigationController {
return;
}
const eyePosition = toEyePosition(this.feetPosition, getFirstPersonPlayerEyeHeight(this.context.getRuntimeScene().playerCollider));
const cameraVolumeState = this.context.resolvePlayerVolumeState(eyePosition);
this.context.setFirstPersonTelemetry({
feetPosition: {
...this.feetPosition
},
eyePosition: toEyePosition(this.feetPosition, getFirstPersonPlayerEyeHeight(this.context.getRuntimeScene().playerCollider)),
eyePosition,
grounded: this.grounded,
locomotionState: this.locomotionState,
inWaterVolume: this.inWaterVolume,
cameraSubmerged: cameraVolumeState.inWater,
inFogVolume: this.inFogVolume,
pointerLocked: this.pointerLocked,
spawn: this.context.getRuntimeScene().spawn

View File

@@ -11,6 +11,7 @@ export interface FirstPersonTelemetry {
grounded: boolean;
locomotionState: RuntimeLocomotionState;
inWaterVolume: boolean;
cameraSubmerged: boolean;
inFogVolume: boolean;
pointerLocked: boolean;
spawn: RuntimeSpawnPoint;