From 4e50e3c5dea4ecab4c21ed68a1ff60c438a7ccde Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Wed, 13 May 2026 20:03:11 +0200 Subject: [PATCH] Improve path point position command to handle spline corridor junction state --- .../set-path-point-positions-command.ts | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/commands/set-path-point-positions-command.ts b/src/commands/set-path-point-positions-command.ts index 66e454b9..fd0a3d4b 100644 --- a/src/commands/set-path-point-positions-command.ts +++ b/src/commands/set-path-point-positions-command.ts @@ -7,8 +7,13 @@ import { getScenePathPointIndex, type ScenePath } from "../document/paths"; +import type { SplineCorridorJunctionRegistry } from "../document/spline-corridor-junctions"; import type { EditorCommand } from "./command"; +import { + cloneSplineCorridorJunctionRegistry, + setScenePathAndReattachJunctions +} from "./path-junction-maintenance"; export interface PathPointPositionUpdate { pointId: string; @@ -85,6 +90,7 @@ export function createSetPathPointPositionsCommand( position: cloneVec3(update.position) })); let previousPath: ScenePath | null = null; + let previousJunctions: SplineCorridorJunctionRegistry | null = null; let previousSelection: EditorSelection | null = null; let previousToolMode: ToolMode | null = null; @@ -115,13 +121,18 @@ export function createSetPathPointPositionsCommand( previousToolMode = context.getToolMode(); } - context.setDocument({ - ...currentDocument, - paths: { - ...currentDocument.paths, - [path.id]: applyPathPointUpdates(path, updates) - } - }); + if (previousJunctions === null) { + previousJunctions = cloneSplineCorridorJunctionRegistry( + currentDocument.splineCorridorJunctions + ); + } + + context.setDocument( + setScenePathAndReattachJunctions( + currentDocument, + applyPathPointUpdates(path, updates) + ) + ); context.setSelection( createPathPointSelection( options.pathId, @@ -142,7 +153,11 @@ export function createSetPathPointPositionsCommand( paths: { ...currentDocument.paths, [previousPath.id]: cloneScenePath(previousPath) - } + }, + splineCorridorJunctions: + previousJunctions === null + ? currentDocument.splineCorridorJunctions + : cloneSplineCorridorJunctionRegistry(previousJunctions) }); if (previousSelection !== null) {