auto-git:

[change] src/runtime-three/third-person-navigation-controller.ts
This commit is contained in:
2026-05-01 16:26:04 +02:00
parent 8e59ccac1c
commit 6eeb8de7cb

View File

@@ -924,26 +924,56 @@ export class ThirdPersonNavigationController implements NavigationController {
return false; return false;
} }
this.climbSurface = activeSurface;
const climbMovement = computeClimbPlaneMovement({ const climbMovement = computeClimbPlaneMovement({
normal: activeSurface.normal, normal: activeSurface.normal,
input: inputState, input: inputState,
speedMetersPerSecond: CLIMB_SPEED_METERS_PER_SECOND, speedMetersPerSecond: CLIMB_SPEED_METERS_PER_SECOND,
dt dt
}); });
const climbTopOutAssist =
playerMovement.edgeAssist.enabled && climbMovement.motion.y > 0
? resolvePlayerEdgeAssistTopOut({
feetPosition: this.feetPosition,
shape: this.standingPlayerShape,
direction: {
x: -activeSurface.normal.x,
y: 0,
z: -activeSurface.normal.z
},
pushToTopHeight: playerMovement.edgeAssist.pushToTopHeight,
canOccupyShape: (feetPosition, shape) =>
this.context?.canOccupyPlayerShape?.(feetPosition, shape) ??
true,
probeGround: (feetPosition, shape, maxDistance) =>
this.context?.probePlayerGround?.(
feetPosition,
shape,
maxDistance
) ?? {
grounded: false,
distance: null,
normal: null,
slopeDegrees: null
}
})
: null;
this.climbSurface = climbTopOutAssist === null ? activeSurface : null;
const resolvedMotion = const resolvedMotion =
this.context.resolveFirstPersonMotion( climbTopOutAssist === null
this.feetPosition, ? (this.context.resolveFirstPersonMotion(
climbMovement.motion, this.feetPosition,
this.standingPlayerShape climbMovement.motion,
) ?? null; this.standingPlayerShape
) ?? null)
: null;
const nextFeetPosition = const nextFeetPosition =
climbTopOutAssist?.feetPosition ??
resolvedMotion?.feetPosition ?? { resolvedMotion?.feetPosition ?? {
x: this.feetPosition.x + climbMovement.motion.x, x: this.feetPosition.x + climbMovement.motion.x,
y: this.feetPosition.y + climbMovement.motion.y, y: this.feetPosition.y + climbMovement.motion.y,
z: this.feetPosition.z + climbMovement.motion.z z: this.feetPosition.z + climbMovement.motion.z
}; };
const displacement = { const displacement = {
x: nextFeetPosition.x - this.feetPosition.x, x: nextFeetPosition.x - this.feetPosition.x,
y: nextFeetPosition.y - this.feetPosition.y, y: nextFeetPosition.y - this.feetPosition.y,
@@ -963,21 +993,33 @@ export class ThirdPersonNavigationController implements NavigationController {
this.latestJumpStarted = false; this.latestJumpStarted = false;
this.latestHeadBump = false; this.latestHeadBump = false;
this.previousPlanarDisplacement = displacement; this.previousPlanarDisplacement = displacement;
this.grounded = false; this.grounded = climbTopOutAssist !== null;
this.inWaterVolume = volumeState.inWater; this.inWaterVolume = volumeState.inWater;
this.inFogVolume = volumeState.inFog; this.inFogVolume = volumeState.inFog;
this.smoothedFeetY = this.feetPosition.y; this.smoothedFeetY = this.feetPosition.y;
this.locomotionState = this.createClimbingLocomotionState({ this.locomotionState =
inputMagnitude: climbMovement.inputMagnitude, climbTopOutAssist === null
displacement, ? this.createClimbingLocomotionState({
dt, inputMagnitude: climbMovement.inputMagnitude,
collisionCount: resolvedMotion?.collisionCount ?? 0, displacement,
collidedAxes: resolvedMotion?.collidedAxes ?? { dt,
x: false, collisionCount: resolvedMotion?.collisionCount ?? 0,
y: false, collidedAxes: resolvedMotion?.collidedAxes ?? {
z: false x: false,
} y: false,
}); z: false
}
})
: {
...createIdleRuntimeLocomotionState("grounded"),
gait: "walk",
inputMagnitude: climbMovement.inputMagnitude,
requestedPlanarSpeed: CLIMB_SPEED_METERS_PER_SECOND,
planarSpeed:
dt > 0
? Math.hypot(displacement.x, displacement.z) / dt
: 0
};
this.updateCameraTransform(dt); this.updateCameraTransform(dt);
this.publishTelemetry(); this.publishTelemetry();