Update player start serialization tests to include interaction angle/sector logic
This commit is contained in:
@@ -3,9 +3,10 @@ import { describe, expect, it } from "vitest";
|
|||||||
import { migrateSceneDocument } from "../../src/document/migrate-scene-document";
|
import { migrateSceneDocument } from "../../src/document/migrate-scene-document";
|
||||||
import {
|
import {
|
||||||
createEmptySceneDocument,
|
createEmptySceneDocument,
|
||||||
SHADER_SKY_AURORA_SCENE_DOCUMENT_VERSION
|
PLAYER_START_INTERACTION_REACH_SCENE_DOCUMENT_VERSION
|
||||||
} from "../../src/document/scene-document";
|
} from "../../src/document/scene-document";
|
||||||
import {
|
import {
|
||||||
|
DEFAULT_PLAYER_START_INTERACTION_ANGLE_DEGREES,
|
||||||
DEFAULT_PLAYER_START_INTERACTION_REACH_METERS,
|
DEFAULT_PLAYER_START_INTERACTION_REACH_METERS,
|
||||||
createPlayerStartEntity
|
createPlayerStartEntity
|
||||||
} from "../../src/entities/entity-instances";
|
} from "../../src/entities/entity-instances";
|
||||||
@@ -14,8 +15,8 @@ import {
|
|||||||
serializeSceneDocument
|
serializeSceneDocument
|
||||||
} from "../../src/serialization/scene-document-json";
|
} from "../../src/serialization/scene-document-json";
|
||||||
|
|
||||||
describe("Player Start interaction reach persistence", () => {
|
describe("Player Start interaction sector persistence", () => {
|
||||||
it("migrates legacy player starts without an authored interaction reach", () => {
|
it("migrates legacy player starts without an authored interaction sector", () => {
|
||||||
const playerStart = createPlayerStartEntity({
|
const playerStart = createPlayerStartEntity({
|
||||||
id: "entity-player-start-legacy"
|
id: "entity-player-start-legacy"
|
||||||
});
|
});
|
||||||
@@ -24,10 +25,11 @@ describe("Player Start interaction reach persistence", () => {
|
|||||||
} as Record<string, unknown>;
|
} as Record<string, unknown>;
|
||||||
|
|
||||||
delete legacyPlayerStart.interactionReachMeters;
|
delete legacyPlayerStart.interactionReachMeters;
|
||||||
|
delete legacyPlayerStart.interactionAngleDegrees;
|
||||||
|
|
||||||
const migrated = migrateSceneDocument({
|
const migrated = migrateSceneDocument({
|
||||||
...createEmptySceneDocument({ name: "Legacy Reach Scene" }),
|
...createEmptySceneDocument({ name: "Legacy Reach Scene" }),
|
||||||
version: SHADER_SKY_AURORA_SCENE_DOCUMENT_VERSION,
|
version: PLAYER_START_INTERACTION_REACH_SCENE_DOCUMENT_VERSION,
|
||||||
entities: {
|
entities: {
|
||||||
[playerStart.id]: legacyPlayerStart
|
[playerStart.id]: legacyPlayerStart
|
||||||
}
|
}
|
||||||
@@ -35,14 +37,16 @@ describe("Player Start interaction reach persistence", () => {
|
|||||||
|
|
||||||
expect(migrated.entities[playerStart.id]).toMatchObject({
|
expect(migrated.entities[playerStart.id]).toMatchObject({
|
||||||
kind: "playerStart",
|
kind: "playerStart",
|
||||||
interactionReachMeters: DEFAULT_PLAYER_START_INTERACTION_REACH_METERS
|
interactionReachMeters: DEFAULT_PLAYER_START_INTERACTION_REACH_METERS,
|
||||||
|
interactionAngleDegrees: DEFAULT_PLAYER_START_INTERACTION_ANGLE_DEGREES
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("round-trips an authored interaction reach through scene JSON", () => {
|
it("round-trips authored interaction sector settings through scene JSON", () => {
|
||||||
const playerStart = createPlayerStartEntity({
|
const playerStart = createPlayerStartEntity({
|
||||||
id: "entity-player-start-round-trip",
|
id: "entity-player-start-round-trip",
|
||||||
interactionReachMeters: 3.4
|
interactionReachMeters: 3.4,
|
||||||
|
interactionAngleDegrees: 42
|
||||||
});
|
});
|
||||||
const document = {
|
const document = {
|
||||||
...createEmptySceneDocument({ name: "Round Trip Reach Scene" }),
|
...createEmptySceneDocument({ name: "Round Trip Reach Scene" }),
|
||||||
@@ -55,7 +59,8 @@ describe("Player Start interaction reach persistence", () => {
|
|||||||
|
|
||||||
expect(parsed.entities[playerStart.id]).toMatchObject({
|
expect(parsed.entities[playerStart.id]).toMatchObject({
|
||||||
kind: "playerStart",
|
kind: "playerStart",
|
||||||
interactionReachMeters: 3.4
|
interactionReachMeters: 3.4,
|
||||||
|
interactionAngleDegrees: 42
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user