Offset between mouseposition and raycast intersection

hi
this is to fix mouse coord when the renderer (and its canvas) has a lower size then fullwidth

var rect = renderer.domElement.getBoundingClientRect();
mouse.x = ( ( event.clientX - rect.left ) / ( rect.right - rect.left ) ) * 2 - 1;
mouse.y = - ( ( event.clientY - rect.top ) / ( rect.bottom - rect.top) ) * 2 + 1;

I think could solve

2 Likes