0

If I use raycaster in this way to detect the intersection of the mouse with a cube it works just fine !

  raycaster.setFromCamera(mouse, camera)
  const intersects = raycaster.intersectObject(cubeMesh)
  if(intersects.length > 0)
  console.log('intersecting')

and after this I have a .gltf object which is positioned exactly as the cubeMesh and I do check if it is loaded first and all this is taking place in an "update" function (every frame) but the interseciton with the .gltf is not detected:

const Update = () => {

  renderer.render(scene, camera)

  raycaster.setFromCamera(mouse, camera)
  
  if(gltfObj){
    const intersects = raycaster.intersectObject(gltfObj)
    if(intersects.length > 0)
    console.log('intersecting')
  }

  requestAnimationFrame(Update);
};
David Maze
  • 130,717
  • 29
  • 175
  • 215
NoobCatX
  • 1
  • 1

1 Answers1

0

Soled: I changed this line and it worked:

const intersects = raycaster.intersectObject(gltfObject, true)
NoobCatX
  • 1
  • 1