Enhance junction shape serialization and migration tests
This commit is contained in:
@@ -1094,7 +1094,48 @@ describe("scene document JSON", () => {
|
|||||||
height: 0.12,
|
height: 0.12,
|
||||||
materialId: null
|
materialId: null
|
||||||
});
|
});
|
||||||
expect(SPLINE_CORRIDOR_JUNCTION_EDGE_SCENE_DOCUMENT_VERSION).toBe(
|
expect(SPLINE_CORRIDOR_JUNCTION_EDGE_SCENE_DOCUMENT_VERSION).toBe(108);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("migrates junctions without authored shape settings to straight junctions", () => {
|
||||||
|
const pathA = createScenePath({ id: "path-junction-shape-json-a" });
|
||||||
|
const pathB = createScenePath({ id: "path-junction-shape-json-b" });
|
||||||
|
const junction = createSplineCorridorJunction({
|
||||||
|
id: "junction-shape-json",
|
||||||
|
center: { x: 1, y: 0, z: 2 },
|
||||||
|
connections: [
|
||||||
|
{ pathId: pathA.id, progress: 0.25, clipDistance: 2.5 },
|
||||||
|
{ pathId: pathB.id, progress: 0.75, clipDistance: 2.5 }
|
||||||
|
]
|
||||||
|
});
|
||||||
|
const legacyDocument = JSON.parse(
|
||||||
|
serializeSceneDocument({
|
||||||
|
...createEmptySceneDocument({
|
||||||
|
name: "Legacy Junction Shape Scene"
|
||||||
|
}),
|
||||||
|
paths: {
|
||||||
|
[pathA.id]: pathA,
|
||||||
|
[pathB.id]: pathB
|
||||||
|
},
|
||||||
|
splineCorridorJunctions: {
|
||||||
|
[junction.id]: junction
|
||||||
|
}
|
||||||
|
})
|
||||||
|
) as {
|
||||||
|
version: number;
|
||||||
|
splineCorridorJunctions: Record<string, { shapeMode?: unknown }>;
|
||||||
|
};
|
||||||
|
|
||||||
|
legacyDocument.version = SPLINE_CORRIDOR_JUNCTION_EDGE_SCENE_DOCUMENT_VERSION;
|
||||||
|
delete legacyDocument.splineCorridorJunctions[junction.id]?.shapeMode;
|
||||||
|
|
||||||
|
const migratedDocument = migrateSceneDocument(legacyDocument);
|
||||||
|
|
||||||
|
expect(migratedDocument.version).toBe(SCENE_DOCUMENT_VERSION);
|
||||||
|
expect(
|
||||||
|
migratedDocument.splineCorridorJunctions[junction.id]?.shapeMode
|
||||||
|
).toBe("straight");
|
||||||
|
expect(SPLINE_CORRIDOR_JUNCTION_SHAPE_SCENE_DOCUMENT_VERSION).toBe(
|
||||||
SCENE_DOCUMENT_VERSION
|
SCENE_DOCUMENT_VERSION
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -1108,6 +1149,7 @@ describe("scene document JSON", () => {
|
|||||||
radius: 2.5,
|
radius: 2.5,
|
||||||
materialId: "starter-concrete-checker",
|
materialId: "starter-concrete-checker",
|
||||||
terrainMode: "paintOnly",
|
terrainMode: "paintOnly",
|
||||||
|
shapeMode: "curve",
|
||||||
edge: {
|
edge: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
collisionEnabled: true,
|
collisionEnabled: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user