From 0f0bfc853d34e132a55b1e9005ddd06142470af3 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Sat, 11 Apr 2026 12:34:03 +0200 Subject: [PATCH] Update scene document JSON tests for input bindings and migration --- .../serialization/scene-document-json.test.ts | 67 +++++++++++++++++-- 1 file changed, 62 insertions(+), 5 deletions(-) diff --git a/tests/serialization/scene-document-json.test.ts b/tests/serialization/scene-document-json.test.ts index e03bcccc..5b655262 100644 --- a/tests/serialization/scene-document-json.test.ts +++ b/tests/serialization/scene-document-json.test.ts @@ -10,6 +10,7 @@ import { LOCAL_LIGHTS_AND_SKYBOX_SCENE_DOCUMENT_VERSION, MODEL_ASSET_PIPELINE_SCENE_DOCUMENT_VERSION, PLAYER_START_COLLIDER_SETTINGS_SCENE_DOCUMENT_VERSION, + PLAYER_START_INPUT_BINDINGS_SCENE_DOCUMENT_VERSION, PLAYER_START_NAVIGATION_MODE_SCENE_DOCUMENT_VERSION, SCENE_TRANSITION_ENTITIES_SCENE_DOCUMENT_VERSION, SCENE_DOCUMENT_VERSION, @@ -424,16 +425,17 @@ describe("scene document JSON", () => { }, inputBindings: { keyboard: { - moveForward: "ArrowUp", - moveBackward: "ArrowDown", - moveLeft: "ArrowLeft", - moveRight: "ArrowRight" + moveForward: "KeyQ", + moveBackward: "BracketLeft", + moveLeft: "Comma", + moveRight: "Period" }, gamepad: { moveForward: "dpadUp", moveBackward: "dpadDown", moveLeft: "dpadLeft", - moveRight: "dpadRight" + moveRight: "dpadRight", + cameraLook: "rightStick" } } }); @@ -708,6 +710,61 @@ describe("scene document JSON", () => { ); }); + it("migrates version 26 Player Start input bindings to include default gamepad camera look", () => { + const playerStart = { + id: "entity-player-start-legacy-camera-look", + kind: "playerStart" as const, + position: { + x: 2, + y: 0, + z: 0 + }, + yawDegrees: 0, + navigationMode: "firstPerson" as const, + inputBindings: { + keyboard: { + moveForward: "KeyW", + moveBackward: "KeyS", + moveLeft: "KeyA", + moveRight: "KeyD" + }, + gamepad: { + moveForward: "leftStickUp", + moveBackward: "leftStickDown", + moveLeft: "leftStickLeft", + moveRight: "leftStickRight" + } + }, + collider: { + mode: "capsule" as const, + eyeHeight: 1.6, + capsuleRadius: 0.3, + capsuleHeight: 1.8, + boxSize: { + x: 0.6, + y: 1.8, + z: 0.6 + } + } + }; + const legacyDocument = { + ...createEmptySceneDocument({ name: "Legacy Player Camera Look Scene" }), + version: PLAYER_START_INPUT_BINDINGS_SCENE_DOCUMENT_VERSION, + entities: { + [playerStart.id]: playerStart + } + }; + + const migratedDocument = migrateSceneDocument(legacyDocument); + + expect(migratedDocument.version).toBe(SCENE_DOCUMENT_VERSION); + expect(migratedDocument.entities[playerStart.id]).toEqual( + createPlayerStartEntity({ + ...playerStart + }) + ); + }); + it("round-trips authored third-person Player Start navigation", () => { const playerStart = createPlayerStartEntity({ id: "entity-player-start-third-person",