From 574ec3efbb680a4a5f302030d68c2f542abe0876 Mon Sep 17 00:00:00 2001 From: Flafy Date: Sun, 6 Oct 2024 12:32:45 +0300 Subject: [PATCH] fix: pointer move attempts to intersect geometries causing intense lag After adding a OrbitControls to the canvas and loading a relatively big STL file (50mb). Performance is really bad when the pointer is moving over the geometry. Using Chrome's performance diagnostics tool, I found out that happens because this library attempts to intersect the geometry the pointer is on every pointer move event. Not sure if this is the correct solution, but it cancels the intersection calculations on pointer move. --- packages/fiber/src/core/events.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/fiber/src/core/events.ts b/packages/fiber/src/core/events.ts index 68a8511dbd..0dc398cef5 100644 --- a/packages/fiber/src/core/events.ts +++ b/packages/fiber/src/core/events.ts @@ -437,7 +437,7 @@ export function createEvents(store: UseBoundStore) { const isClickEvent = name === 'onClick' || name === 'onContextMenu' || name === 'onDoubleClick' const filter = isPointerMove ? filterPointerEvents : undefined - const hits = intersect(event, filter) + const hits = isPointerMove ? [] : intersect(event, filter) const delta = isClickEvent ? calculateDistance(event) : 0 // Save initial coordinates on pointer-down