From 112df7dae23e9162e3fa843148c166162c2a879e Mon Sep 17 00:00:00 2001 From: Vincent Fretin Date: Fri, 10 Jan 2025 17:40:04 +0100 Subject: [PATCH] Remove raycaster-closest-entity-changed listener when removing cursor component, this fixes getIntersection on undefined error when we remove cursor and raycaster components on the scene and there is a hand raycaster emitting this event (#5625) --- src/components/cursor.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/cursor.js b/src/components/cursor.js index 6518034bdb..11863d385d 100644 --- a/src/components/cursor.js +++ b/src/components/cursor.js @@ -196,6 +196,7 @@ module.exports.Component = registerComponent('cursor', { el.removeEventListener(upEvent, self.onCursorUp); }); el.removeEventListener('raycaster-intersection', this.onIntersection); + el.removeEventListener('raycaster-closest-entity-changed', this.onIntersection); el.removeEventListener('raycaster-intersection-cleared', this.onIntersectionCleared); canvas.removeEventListener('mousemove', this.onMouseMove); canvas.removeEventListener('touchstart', this.onMouseMove);