From eb3d08140f0935b1b20af55e48f12c9314420cbc Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Fri, 3 Apr 2026 00:32:05 +0200 Subject: [PATCH] Modify creationCommitHandler to handle boolean return and update logic in viewport-host.ts --- src/viewport-three/viewport-host.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/viewport-three/viewport-host.ts b/src/viewport-three/viewport-host.ts index 42ea5d15..1487a32e 100644 --- a/src/viewport-three/viewport-host.ts +++ b/src/viewport-three/viewport-host.ts @@ -209,7 +209,7 @@ export class ViewportHost { private container: HTMLElement | null = null; private brushSelectionChangeHandler: ((selection: EditorSelection) => void) | null = null; private creationPreviewChangeHandler: ((toolPreview: ViewportToolPreview) => void) | null = null; - private creationCommitHandler: ((toolPreview: CreationViewportToolPreview) => void) | null = null; + private creationCommitHandler: ((toolPreview: CreationViewportToolPreview) => boolean) | null = null; private toolMode: ToolMode = "select"; private viewMode: ViewportViewMode = "perspective"; private displayMode: ViewportDisplayMode = "normal"; @@ -317,7 +317,7 @@ export class ViewportHost { this.creationPreviewChangeHandler = handler; } - setCreationCommitHandler(handler: ((toolPreview: CreationViewportToolPreview) => void) | null) { + setCreationCommitHandler(handler: ((toolPreview: CreationViewportToolPreview) => boolean) | null) { this.creationCommitHandler = handler; } @@ -1314,7 +1314,12 @@ export class ViewportHost { this.creationPreviewChangeHandler?.(nextCreationPreview); if (previewCenter !== null) { - this.creationCommitHandler?.(nextCreationPreview); + const committed = this.creationCommitHandler?.(nextCreationPreview) === true; + + if (committed) { + this.syncCreationPreview(null); + this.creationPreviewChangeHandler?.({ kind: "none" }); + } } return;