Update FirstPersonNavigationController context and resolveFirstPersonMotion type

This commit is contained in:
2026-04-11 12:19:46 +02:00
parent 5e1b865f56
commit 26e86baf98

View File

@@ -4,6 +4,10 @@ import { afterEach, describe, expect, it, vi } from "vitest";
import type { Vec3 } from "../../src/core/vector"; import type { Vec3 } from "../../src/core/vector";
import { createEmptySceneDocument } from "../../src/document/scene-document"; import { createEmptySceneDocument } from "../../src/document/scene-document";
import { createPlayerStartEntity } from "../../src/entities/entity-instances"; import { createPlayerStartEntity } from "../../src/entities/entity-instances";
import type {
FirstPersonPlayerShape,
ResolvedPlayerMotion
} from "../../src/runtime-three/player-collision";
import { buildRuntimeSceneFromDocument } from "../../src/runtime-three/runtime-scene-build"; import { buildRuntimeSceneFromDocument } from "../../src/runtime-three/runtime-scene-build";
import { FirstPersonNavigationController } from "../../src/runtime-three/first-person-navigation-controller"; import { FirstPersonNavigationController } from "../../src/runtime-three/first-person-navigation-controller";
@@ -35,7 +39,7 @@ function createRuntimeControllerContext(
resolveFirstPersonMotion: ( resolveFirstPersonMotion: (
feetPosition: Vec3, feetPosition: Vec3,
motion: Vec3 motion: Vec3
) => { feetPosition: Vec3; grounded: boolean } | null = () => null ) => ResolvedPlayerMotion | null = () => null
) { ) {
const runtimeScene = buildRuntimeSceneFromDocument( const runtimeScene = buildRuntimeSceneFromDocument(
{ {
@@ -59,7 +63,7 @@ function createRuntimeControllerContext(
resolveFirstPersonMotion: ( resolveFirstPersonMotion: (
feetPosition: Vec3, feetPosition: Vec3,
motion: Vec3, motion: Vec3,
_shape _shape: FirstPersonPlayerShape
) => resolveFirstPersonMotion(feetPosition, motion), ) => resolveFirstPersonMotion(feetPosition, motion),
resolvePlayerVolumeState: () => ({ resolvePlayerVolumeState: () => ({
inWater: false, inWater: false,
@@ -146,7 +150,12 @@ describe("FirstPersonNavigationController", () => {
y: feetPosition.y + motion.y, y: feetPosition.y + motion.y,
z: feetPosition.z + motion.z z: feetPosition.z + motion.z
}, },
grounded: false grounded: false,
collidedAxes: {
x: false,
y: false,
z: false
}
}) })
); );
const controller = new FirstPersonNavigationController(); const controller = new FirstPersonNavigationController();