refactor: streamline right-click selection handling and event listener management in SelectionControls
This commit is contained in:
parent
81664ba765
commit
fdc8255c19
|
@ -84,7 +84,6 @@ const SelectionControls: React.FC = () => {
|
|||
const onPointerUp = (event: PointerEvent) => {
|
||||
if (event.button === 2 && !event.ctrlKey && !event.shiftKey) {
|
||||
isRightClick.current = false;
|
||||
rightClickMoved.current = false;
|
||||
if (!rightClickMoved.current) {
|
||||
clearSelection();
|
||||
}
|
||||
|
@ -171,18 +170,14 @@ const SelectionControls: React.FC = () => {
|
|||
if (!rightClickMoved.current) {
|
||||
clearSelection();
|
||||
}
|
||||
rightClickMoved.current = false;
|
||||
};
|
||||
|
||||
if (!toggleView && activeModule === "builder") {
|
||||
helper.enabled = true;
|
||||
if (duplicatedObjects.length === 0 && pastedObjects.length === 0) {
|
||||
canvasElement.addEventListener("pointerdown", onPointerDown);
|
||||
canvasElement.addEventListener("pointermove", onPointerMove);
|
||||
canvasElement.addEventListener("pointerup", onPointerUp);
|
||||
} else {
|
||||
helper.enabled = false;
|
||||
helper.dispose();
|
||||
}
|
||||
canvasElement.addEventListener("pointermove", onPointerMove);
|
||||
canvasElement.addEventListener("pointerup", onPointerUp);
|
||||
canvasElement.addEventListener("pointerdown", onPointerDown);
|
||||
canvasElement.addEventListener("contextmenu", onContextMenu);
|
||||
canvasElement.addEventListener("keydown", onKeyDown);
|
||||
} else {
|
||||
|
@ -208,7 +203,6 @@ const SelectionControls: React.FC = () => {
|
|||
}, [activeModule]);
|
||||
|
||||
useFrame(() => {
|
||||
console.log(rightClickMoved.current);
|
||||
if (pastedObjects.length === 0 && duplicatedObjects.length === 0 && movedObjects.length === 0 && rotatedObjects.length === 0) {
|
||||
selectionGroup.current.position.set(0, 0, 0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue