From 9f502a6aa22f4b7dd6aeb690edf74ca61cbdbfb3 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Wed, 15 Apr 2026 15:07:17 +0200 Subject: [PATCH] Add new function for editor selection click handling and update viewport logic --- src/core/selection.ts | 20 ++++++++++++++++++++ src/viewport-three/viewport-host.ts | 12 +++++------- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/core/selection.ts b/src/core/selection.ts index d1e94f68..cc2b4441 100644 --- a/src/core/selection.ts +++ b/src/core/selection.ts @@ -207,6 +207,26 @@ export function applySameKindSelectionClick( }; } +export function applyEditorSelectionClick( + currentSelection: EditorSelection, + clickedSelection: EditorSelection | null, + shiftKey: boolean +): EditorSelection { + if (clickedSelection === null) { + return shiftKey + ? cloneEditorSelection(currentSelection) + : { + kind: "none" + }; + } + + return applySameKindSelectionClick( + currentSelection, + clickedSelection, + shiftKey + ); +} + export function getSingleSelectedBrushId(selection: EditorSelection): string | null { if (selection.kind === "brushFace" || selection.kind === "brushEdge" || selection.kind === "brushVertex") { return selection.brushId; diff --git a/src/viewport-three/viewport-host.ts b/src/viewport-three/viewport-host.ts index 7c1832ba..4d10889c 100644 --- a/src/viewport-three/viewport-host.ts +++ b/src/viewport-three/viewport-host.ts @@ -43,6 +43,7 @@ import { import { EffectComposer } from "postprocessing"; import { + applyEditorSelectionClick, applySameKindSelectionClick, areEditorSelectionsEqual, isBrushEdgeSelected, @@ -6838,12 +6839,9 @@ export class ViewportHost { if (candidates.length === 0) { this.lastClickPointer = null; this.lastClickSelectionKey = null; - - if (!event.shiftKey) { - this.brushSelectionChangeHandler?.({ - kind: "none" - }); - } + this.brushSelectionChangeHandler?.( + applyEditorSelectionClick(this.currentSelection, null, event.shiftKey) + ); return; } @@ -6872,7 +6870,7 @@ export class ViewportHost { const chosen = candidates[candidateIndex]; this.lastClickSelectionKey = chosen.key; this.brushSelectionChangeHandler?.( - applySameKindSelectionClick( + applyEditorSelectionClick( this.currentSelection, chosen.selection, event.shiftKey