Vector3 of ray intersect with model

I want to get x,y,z position where ray intersect with model?

You need to do something like that.
Then you can do something like this

var intersects = raycaster.intersectObjects( scene.children );
if(intersects.length > 0) {

   hitPosition.copy(intersects[0].point)
}

intersectObject(s) returns an object

Checks all intersection between the ray and the object with or without the descendants. Intersections are returned sorted by distance, closest first. An array of intersections is returned…

[ { distance, point, face, faceIndex, object }, ... ]

distance – distance between the origin of the ray and the intersection
point – point of intersection, in world coordinates
face – intersected face
faceIndex – index of the intersected face
object – the intersected object
uv - U,V coordinates at point of intersection
uv2 - Second set of U,V coordinates at point of intersection
instanceId – The index number of the instance where the ray intersects the InstancedMesh

The first element inside the returned intersects array will be the nearest and first object hit.

1 Like