Implement utilities for cloning and reattaching spline corridor junctions to paths

This commit is contained in:
2026-05-13 20:01:02 +02:00
parent 88c1060019
commit fa95a05d0f

View File

@@ -0,0 +1,40 @@
import { cloneScenePath, type ScenePath } from "../document/paths";
import type { SceneDocument } from "../document/scene-document";
import {
cloneSplineCorridorJunction,
type SplineCorridorJunctionRegistry
} from "../document/spline-corridor-junctions";
import { reattachSplineCorridorJunctionsToPaths } from "../spline-corridor/spline-corridor-junctions";
export function cloneSplineCorridorJunctionRegistry(
junctions: SplineCorridorJunctionRegistry
): SplineCorridorJunctionRegistry {
return Object.fromEntries(
Object.entries(junctions).map(([junctionId, junction]) => [
junctionId,
cloneSplineCorridorJunction(junction)
])
);
}
export function setScenePathAndReattachJunctions(
document: SceneDocument,
path: ScenePath
): SceneDocument {
const nextPath = cloneScenePath(path);
const nextPaths = {
...document.paths,
[nextPath.id]: nextPath
};
return {
...document,
paths: nextPaths,
splineCorridorJunctions: reattachSplineCorridorJunctionsToPaths({
paths: Object.values(nextPaths),
junctions: document.splineCorridorJunctions,
changedPathIds: [nextPath.id],
terrains: Object.values(document.terrains)
})
};
}