Local cursor position in sprite

sprites

#1

Hi,

I have 10 sprites moving around in 3D space. Now I “click” one using the THREE.Raycaster and intersectObjects method to detect if the mouse whilst clicking “hitted/was on” a Sprite. Works great.

My question now is, can I somehow detect where in the sprite (sprite´s local coordinates) I hitted/clicked the Sprite? Like, where in the Sprite the mouse was “on xy-position”?

Thanks for your feedback
bI


#2

The intersection point is in world space. Have you tried to transform this point into the local space of the sprite? You can do that by multiplying the intersection point by the inverse world matrix of the sprite.


#3

Just or curiousity, why do you want to know coordinates of clicking on a sprite? To know UV coordinates?


#4

Yep @prisoner849


#5

Take a look at this post:

There’s already uv data in the object of intersection.

if (intersects.length > 0){
    let obj = intersects[0];
    let uv = obj.uv;
    if (Math.min(uv.x, uv.y) > 0.75) { 
      obj.object.visible = false; // you have to do the stuff for real clearance
    }
  }