Three.js raycaster.intersectObjects( scene.children, true ) does not detect skinnedMesh when BufferGeometry is in back

I build a scene and added multiple gltf models. Three.js detects a SkinnedMesh only rarely when it is in front of a BufferGeometry, even though it always detects the SkinnedMesh when the BufferGeometry is not added to the scene. In front of a PlaneGeometry the SkinnedMesh becomes detected. When BufferGeometry and SkinnedMesh are added to the scene, they are both contained in scene.children and become returned with intersects[ 0 ].object.name. Most times when intersecting the SkinnedMesh, the BufferGeometry in behind becomes returned. This also accounts for raycaster.intersectObjects( scene.children ). This are my relevant lines of code:

raycaster.setFromCamera( mouse, camera );
const intersects = raycaster.intersectObjects( scene.children, true ); 

for ( let i = 0; i < intersects.length; i ++ )
{
    if(intersects[ 0 ].object.name === "Corgi")
    {
          console.log('corgi');
    }

}

What do I need to do to detect the SkinnedMesh? I tried with three.js version r126 and r134.
I appreciate help A LOT! THANKS!

i think i faced an issue where , if the rig/bones/skeleton has translated , rotated or scaled the skinned mesh , the ray cast does not work or its off

1 Like

Thanks! Thats likely part of the solution, because the skinnedMesh is translating all the time. Nevertheless it relates to the object in behind the skinnedMesh too, because when only a PlaneGeometry is in behind it is working perfectly. Any ideas how to solve this issue?