Enhance unit tests for player climbing logic, including movement detection and planar input resolution
This commit is contained in:
@@ -5,7 +5,9 @@ import { createEmptySceneDocument } from "../../src/document/scene-document";
|
|||||||
import { FIRST_PERSON_PLAYER_SHAPE } from "../../src/runtime-three/player-collision";
|
import { FIRST_PERSON_PLAYER_SHAPE } from "../../src/runtime-three/player-collision";
|
||||||
import {
|
import {
|
||||||
computeClimbPlaneMovement,
|
computeClimbPlaneMovement,
|
||||||
|
isClimbMovementIntoSurface,
|
||||||
isClimbableWallNormal,
|
isClimbableWallNormal,
|
||||||
|
resolveClimbPlanarInputDirection,
|
||||||
resolvePlayerClimbSurface,
|
resolvePlayerClimbSurface,
|
||||||
shouldEnterClimbing,
|
shouldEnterClimbing,
|
||||||
shouldExitClimbing
|
shouldExitClimbing
|
||||||
@@ -79,6 +81,7 @@ describe("player climbing helpers", () => {
|
|||||||
expect(
|
expect(
|
||||||
shouldEnterClimbing({
|
shouldEnterClimbing({
|
||||||
climbInput: 1,
|
climbInput: 1,
|
||||||
|
movementIntoSurface: false,
|
||||||
surface,
|
surface,
|
||||||
jumpPressed: false
|
jumpPressed: false
|
||||||
})
|
})
|
||||||
@@ -86,26 +89,72 @@ describe("player climbing helpers", () => {
|
|||||||
expect(
|
expect(
|
||||||
shouldEnterClimbing({
|
shouldEnterClimbing({
|
||||||
climbInput: 0,
|
climbInput: 0,
|
||||||
|
movementIntoSurface: true,
|
||||||
|
surface,
|
||||||
|
jumpPressed: false
|
||||||
|
})
|
||||||
|
).toBe(true);
|
||||||
|
expect(
|
||||||
|
shouldEnterClimbing({
|
||||||
|
climbInput: 0,
|
||||||
|
movementIntoSurface: false,
|
||||||
surface,
|
surface,
|
||||||
jumpPressed: false
|
jumpPressed: false
|
||||||
})
|
})
|
||||||
).toBe(false);
|
).toBe(false);
|
||||||
expect(
|
expect(
|
||||||
shouldExitClimbing({
|
shouldExitClimbing({
|
||||||
climbInput: 1,
|
|
||||||
surface,
|
surface,
|
||||||
jumpPressed: true
|
jumpPressed: true
|
||||||
})
|
})
|
||||||
).toBe(true);
|
).toBe(true);
|
||||||
expect(
|
expect(
|
||||||
shouldExitClimbing({
|
shouldExitClimbing({
|
||||||
climbInput: 0,
|
|
||||||
surface,
|
surface,
|
||||||
jumpPressed: false
|
jumpPressed: false
|
||||||
})
|
})
|
||||||
|
).toBe(false);
|
||||||
|
expect(
|
||||||
|
shouldExitClimbing({
|
||||||
|
surface: null,
|
||||||
|
jumpPressed: false
|
||||||
|
})
|
||||||
).toBe(true);
|
).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("treats movement into a climbable face as climb intent", () => {
|
||||||
|
const surface = {
|
||||||
|
brushId: "brush-wall",
|
||||||
|
faceId: "negZ",
|
||||||
|
point: { x: 0, y: 1, z: 0.75 },
|
||||||
|
normal: { x: 0, y: 0, z: -1 },
|
||||||
|
distance: 0.75
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(
|
||||||
|
resolveClimbPlanarInputDirection(createInputState({ moveForward: 1 }), 0)
|
||||||
|
.direction
|
||||||
|
).toMatchObject({
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
z: 1
|
||||||
|
});
|
||||||
|
expect(
|
||||||
|
isClimbMovementIntoSurface({
|
||||||
|
input: createInputState({ moveForward: 1 }),
|
||||||
|
movementYawRadians: 0,
|
||||||
|
surface,
|
||||||
|
})
|
||||||
|
).toBe(true);
|
||||||
|
expect(
|
||||||
|
isClimbMovementIntoSurface({
|
||||||
|
input: createInputState({ moveBackward: 1 }),
|
||||||
|
movementYawRadians: 0,
|
||||||
|
surface
|
||||||
|
})
|
||||||
|
).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
it("resolves only authored climbable whitebox faces in front of the player", () => {
|
it("resolves only authored climbable whitebox faces in front of the player", () => {
|
||||||
const brush = createBoxBrush({
|
const brush = createBoxBrush({
|
||||||
id: "brush-climbable-wall",
|
id: "brush-climbable-wall",
|
||||||
|
|||||||
Reference in New Issue
Block a user