# Raycast weird intersection

**URL:** <https://discourse.threejs.org/t/raycast-weird-intersection/25486>\
**Category:** Questions\
**Tags:** raycasting\
**Created:** [April 19, 2021, 1:17pm UTC](https://discourse.threejs.org/t/raycast-weird-intersection/25486 "2021-04-19T13:17:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tfacchini](https://avatars.discourse-cdn.com/v4/letter/t/8edcca/32.png) [@tfacchini](https://discourse.threejs.org/u/tfacchini)\
**Post date:** [April 19, 2021, 1:17pm UTC](https://discourse.threejs.org/t/raycast-weird-intersection/25486/1 "2021-04-19T13:17:50Z")

</div>

Hello everyone,

I’m currently facing this weird behaviour when casting a ray.

As you can see on the image I’m clicking reasonably far from the planeGeometry / Line, but the result of the raycast says I’m clicking on the geometry.

 ![raycast](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/0/c/0c2f2b606f851e0e87f460345d38c6e5e58eff77.png)

Just so you guys know, I’m using React Three Fiber hook which gives me back some ‘entities’ necessary for the rayCast, below you can see the code:

```
const RayCaster = (): null => {
    const { raycaster, camera, mouse, scene } = useThree()

    if (pointerState === 1) {
        raycaster.setFromCamera( mouse, camera )
        const intersects = raycaster.intersectObjects (scene.children, true)
        const intersectable = getIntersectable(intersects)

        if (intersectable !== undefined) {
            console.log(intersectable)
            const posX = Math.floor(intersects[0].point.x)
            const posY = Math.floor(intersects[0].point.y)
            const posZ = Math.floor(intersects[0].point.z)

            console.log(`x: ${posX}, y: ${posY}, z: ${posZ}`)
        } else {
            console.log('no intersects')
        }

    }
    return null
}

```

and this is the function I’m using to check for specific intersected geometries:

```
function getIntersectable (entities: Object): ?Object {
    console.log(entities)
    for (let i = 0; i < entities.length; i++) {
        if (entities[i].object.parent && entities[i].object.parent.userData.intersectable == true) {
            return entities[i]
        }
    }
}

```

Any idea on what may be causing this weird offset?

Thanks
