0
votes

Thanks for the helps in advance.

Three.js Raycaster class allows sending rays from camera to the object. I want to achieve a reverse operation. Imagine that we have a plane in the scene which represents our screen for projection. We also have an object (mesh) to be projected. I'm trying to find where would a vertex be projected on the screen.

Practically, for a vertex, if we project a ray from vertex to camera, we need to find its intersection with the screen plane. Note that everything is in 3D here. So my screen(camera) plane is in 3D coordinates too.

Any advise to solve this problem?

1

1 Answers

0
votes

I think what you are looking for is projection of an object3d to screen position. It was answered here:

answer

then you will have vector2d with x,y screen coordinates.

if you want the point on an actual 3d plane, you can then make a ray from the camera to that position on the screen, add to the ray intersection only that plane you locate infront of the camera, and then get the intersection point:

    rayCaster.setFromCamera(vector2d,  camera);
    var aIntersects = rayCaster.intersectObject(planeInFrontOfCamera);
    if (aIntersects.length > 0) {
       var positionOnPlane = aIntersects[0].point.
    }