Raycast return incorrect point values

Hi everyone!

I’m working on something like pool game.
Now, when I set raycast from camera to plane on y=0 from point A to B, I’ve created tinny cubes coping both vectors from intersects[0].point. They are on Y=0

But when I log those same vectors I get with y > 0

This is my function

function floorRay(e, source) {
e.preventDefault()

    if(source) {
        raycast.setFromCamera(pointerState.position, camera)
    } else {
        raycast.setFromCamera(pointerState.clickPos, camera)
    }

    raycastData.intersects = raycast.intersectObject(floorMesh, false)
}

Why this is happening? :upside_down_face:

1 Like

pointerState.position, please use a correct object V2 for first argument.

Or use set( V3, V3).

pointerState.position is a V2 with mouse coordinates.

pointerState.clickPos.x = ( ( e.clientX - rect.left ) / rect.width ) * 2 - 1
pointerState.clickPos.y = - ( ( e.clientY - rect.top ) / rect.height ) * 2 + 1

Them a JSFiddle with minimum coding is needed to prevent doing YoYo.

by 10^-15 :smiling_face_with_tear:

also they are < 0 :smiling_face_with_tear: