Update test for ThirdPersonNavigationController with movement template speed check
This commit is contained in:
@@ -31,22 +31,24 @@ function createMockGamepad(options: {
|
|||||||
} as unknown as Gamepad;
|
} as unknown as Gamepad;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createRuntimeControllerContext() {
|
function createRuntimeControllerContext(
|
||||||
|
playerStart = createPlayerStartEntity({
|
||||||
|
id: "entity-player-start-main",
|
||||||
|
inputBindings: {
|
||||||
|
keyboard: {
|
||||||
|
moveForward: "ArrowUp",
|
||||||
|
moveBackward: "ArrowDown",
|
||||||
|
moveLeft: "ArrowLeft",
|
||||||
|
moveRight: "ArrowRight"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
) {
|
||||||
const runtimeScene = buildRuntimeSceneFromDocument(
|
const runtimeScene = buildRuntimeSceneFromDocument(
|
||||||
{
|
{
|
||||||
...createEmptySceneDocument({ name: "Third Person Binding Scene" }),
|
...createEmptySceneDocument({ name: "Third Person Binding Scene" }),
|
||||||
entities: {
|
entities: {
|
||||||
"entity-player-start-main": createPlayerStartEntity({
|
[playerStart.id]: playerStart
|
||||||
id: "entity-player-start-main",
|
|
||||||
inputBindings: {
|
|
||||||
keyboard: {
|
|
||||||
moveForward: "ArrowUp",
|
|
||||||
moveBackward: "ArrowDown",
|
|
||||||
moveLeft: "ArrowLeft",
|
|
||||||
moveRight: "ArrowRight"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -149,4 +151,43 @@ describe("ThirdPersonNavigationController", () => {
|
|||||||
|
|
||||||
controller.deactivate(context);
|
controller.deactivate(context);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
it("uses the authored movement template speed for third-person motion telemetry", () => {
|
||||||
|
const playerStart = createPlayerStartEntity({
|
||||||
|
id: "entity-player-start-custom-third-person-movement",
|
||||||
|
inputBindings: {
|
||||||
|
keyboard: {
|
||||||
|
moveForward: "ArrowUp",
|
||||||
|
moveBackward: "ArrowDown",
|
||||||
|
moveLeft: "ArrowLeft",
|
||||||
|
moveRight: "ArrowRight"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
movementTemplate: {
|
||||||
|
moveSpeed: 2.25
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const { context } = createRuntimeControllerContext(playerStart);
|
||||||
|
const controller = new ThirdPersonNavigationController();
|
||||||
|
|
||||||
|
controller.activate(context);
|
||||||
|
window.dispatchEvent(new KeyboardEvent("keydown", { code: "ArrowUp" }));
|
||||||
|
controller.update(1);
|
||||||
|
|
||||||
|
const telemetry = context.setFirstPersonTelemetry.mock.calls.at(-1)?.[0];
|
||||||
|
|
||||||
|
expect(telemetry?.feetPosition.z).toBeCloseTo(2.25);
|
||||||
|
expect(telemetry?.movement).toMatchObject({
|
||||||
|
templateKind: "default",
|
||||||
|
moveSpeed: 2.25,
|
||||||
|
capabilities: {
|
||||||
|
jump: true,
|
||||||
|
sprint: true,
|
||||||
|
crouch: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
window.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowUp" }));
|
||||||
|
controller.deactivate(context);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user