I’m trying to get the intersection point of a mesh loaded through the FBXLoader on a mouseDown event, which works for the most part. But for some reason the rayCaster.intersectObjects seems to always be lagging behind a single mouseclick.
My problem can be viewed in this fiddle. As you can see in the console it’ll always log the data from the previous click, instead of the current.
I’m fairly sure the problem is somewhere on my end, so any help would be greatly appreciated!
It’s also important that raycaster.setFromCamera( mouse, camera ); is executed with the latest event data. So place it always right before raycaster.intersectObjects(). Since raycaster.setFromCamera() was placed in your render loop, you have seen the previous click in the console.
Also note that clientX/clientY can give you incorrect positions.
It’s also heavily dependent to which object you’re attaching your click event handlers. Unless you’re guaranteed to be running in a full window, attach your mousedown/mouseup events directly to the canvas, not window.