Add water surface height to volume state and update camera submerged logic
This commit is contained in:
@@ -328,7 +328,8 @@ export class FirstPersonNavigationController implements NavigationController {
|
|||||||
resolveVolumeState: (feetPosition) =>
|
resolveVolumeState: (feetPosition) =>
|
||||||
this.context?.resolvePlayerVolumeState(feetPosition) ?? {
|
this.context?.resolvePlayerVolumeState(feetPosition) ?? {
|
||||||
inWater: false,
|
inWater: false,
|
||||||
inFog: false
|
inFog: false,
|
||||||
|
waterSurfaceHeight: null
|
||||||
},
|
},
|
||||||
probeGround: (feetPosition, shape, maxDistance) =>
|
probeGround: (feetPosition, shape, maxDistance) =>
|
||||||
this.context?.probePlayerGround?.(feetPosition, shape, maxDistance) ?? {
|
this.context?.probePlayerGround?.(feetPosition, shape, maxDistance) ?? {
|
||||||
@@ -437,6 +438,10 @@ export class FirstPersonNavigationController implements NavigationController {
|
|||||||
);
|
);
|
||||||
const cameraVolumeState =
|
const cameraVolumeState =
|
||||||
this.context.resolvePlayerVolumeState(eyePosition);
|
this.context.resolvePlayerVolumeState(eyePosition);
|
||||||
|
const cameraSubmerged =
|
||||||
|
cameraVolumeState.inWater &&
|
||||||
|
cameraVolumeState.waterSurfaceHeight !== null &&
|
||||||
|
eyePosition.y < cameraVolumeState.waterSurfaceHeight;
|
||||||
|
|
||||||
const telemetry = createPlayerControllerTelemetry({
|
const telemetry = createPlayerControllerTelemetry({
|
||||||
feetPosition: {
|
feetPosition: {
|
||||||
@@ -449,7 +454,7 @@ export class FirstPersonNavigationController implements NavigationController {
|
|||||||
this.context.getRuntimeScene().playerMovement
|
this.context.getRuntimeScene().playerMovement
|
||||||
),
|
),
|
||||||
inWaterVolume: this.inWaterVolume,
|
inWaterVolume: this.inWaterVolume,
|
||||||
cameraSubmerged: cameraVolumeState.inWater,
|
cameraSubmerged,
|
||||||
inFogVolume: this.inFogVolume,
|
inFogVolume: this.inFogVolume,
|
||||||
pointerLocked: this.pointerLocked,
|
pointerLocked: this.pointerLocked,
|
||||||
spawn: this.context.getRuntimeScene().spawn,
|
spawn: this.context.getRuntimeScene().spawn,
|
||||||
|
|||||||
Reference in New Issue
Block a user