Skip to content

Commit

Permalink
Remove child-attached listener that updates raycaster and define rayc…
Browse files Browse the repository at this point in the history
…aster component before cursor (aframevr#721)
  • Loading branch information
vincentfretin authored Jul 22, 2024
1 parent ec526a2 commit 3a28e20
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/lib/raycaster.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import Events from './Events';
import debounce from 'lodash.debounce';

export function initRaycaster(inspector) {
// Use cursor="rayOrigin: mouse".
const mouseCursor = document.createElement('a-entity');
mouseCursor.setAttribute('id', 'aframeInspectorMouseCursor');
mouseCursor.setAttribute('cursor', 'rayOrigin', 'mouse');
mouseCursor.setAttribute('data-aframe-inspector', 'true');
mouseCursor.setAttribute('raycaster', {
interval: 100,
objects: 'a-scene :not([data-aframe-inspector])'
});
mouseCursor.setAttribute('cursor', 'rayOrigin', 'mouse');
mouseCursor.setAttribute('data-aframe-inspector', 'true');

// Only visible objects.
const raycaster = mouseCursor.components.raycaster;
Expand All @@ -33,13 +32,6 @@ export function initRaycaster(inspector) {
inspector.sceneEl.appendChild(mouseCursor);
inspector.cursor = mouseCursor;

inspector.sceneEl.addEventListener(
'child-attached',
debounce(function () {
mouseCursor.components.raycaster.refreshObjects();
}, 250)
);

mouseCursor.addEventListener('click', handleClick);
mouseCursor.addEventListener('mouseenter', onMouseEnter);
mouseCursor.addEventListener('mouseleave', onMouseLeave);
Expand Down

0 comments on commit 3a28e20

Please sign in to comment.