aframevr / aframe-inspector

:mag: Visual inspector tool for A-Frame. Hit *<ctrl> + <alt> + i* on any A-Frame scene.
https://aframe.io/aframe-inspector/examples/
MIT License
655 stars 203 forks source link

Selection should select the object closest to the camera. #470

Closed andyli closed 7 years ago

andyli commented 7 years ago

raycaster.intersectObjects(objects) returns intersections sorted by distance, closest first, according to the doc at https://threejs.org/docs/?q=Raycaster#Reference/Core/Raycaster

So, once we find a valid selection target, we should break the loop, because the later ones will be further away from the camera.

andyli commented 7 years ago

A demo of the bug and fix:

The original A-Frame hello world: https://aframe.io/examples/showcase/helloworld/ Put up the inspector, try click on the cylinder and the floor behind it will be selected.

The same demo with the fixed inspector: https://aframe-inspector-selection-fix.glitch.me Put up the inspector. The cylinder can be selected by clicking on it.

fernandojsg commented 7 years ago

@andyli sorry for the late merge. Good catch! thanks