From 975e0661b337ee2e4ee709a2ccafa597ff0e5e45 Mon Sep 17 00:00:00 2001 From: Sander Moolin Date: Tue, 23 Mar 2021 09:41:32 -0400 Subject: [PATCH] update event order --- src/core/Raycaster.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/core/Raycaster.js b/src/core/Raycaster.js index a4c06d1..ea1ba59 100644 --- a/src/core/Raycaster.js +++ b/src/core/Raycaster.js @@ -96,6 +96,21 @@ export default { this.intersects || scene.children ); + // capture expired intersects + if (this.onPointerLeave) { + const newObjects = intersects.map(intersect => { + return { + object: intersect.object, + instanceId: intersect.instanceId + } + }); + // TODO: optimize + const expiredIntersects = this._intersects.filter(intersect => !newObjects.find(val => val.object === intersect.object && val.instanceId === intersect.instanceId)); + if (expiredIntersects.length) { + this.onPointerLeave(expiredIntersects) + } + } + // capture new intersects if (this.onPointerEnter) { const old = this._intersects.map(intersect => { @@ -116,21 +131,6 @@ export default { this.onPointerOver(intersects) } - // capture expired intersects - if (this.onPointerLeave) { - const newObjects = intersects.map(intersect => { - return { - object: intersect.object, - instanceId: intersect.instanceId - } - }); - // TODO: optimize - const expiredIntersects = this._intersects.filter(intersect => !newObjects.find(val => val.object === intersect.object && val.instanceId === intersect.instanceId)); - if (expiredIntersects.length) { - this.onPointerLeave(expiredIntersects) - } - } - // save internal intersect list this._intersects = intersects; },