0

Help bro. I use three.js raycaster() function to intersect a Object3D in the Group, but it return nothing....and the raycaster() can intersect with the THREE.mesh if I put a mesh into the scene, SO Does it means that the raycaster() function can't support the import Object?

code to intersect on the click event

        function onMouseClick(event) {
            mouse.x = ((event.clientX - canvas.getBoundingClientRect().left) / canvas.offsetWidth) * 2 - 1;
            mouse.y = - ((event.clientY - canvas.getBoundingClientRect().top) / canvas.offsetHeight) * 2 + 1;

            raycaster.setFromCamera(mouse, camera);

            var clickobjstore = raycaster.intersectObjects(huojia.children[0], true);

            console.log(clickobjstore);

            for (var i = 0; i < clickobjstore.length; i++) {
                console.log(clickobjstore);
                clickobjstore[i].object.material.color.set(0xff0000);

            }
            renderer.render(scene, camera);
        }

img of the group object on console

the group object on the memory

amjackfan
  • 1
  • 2
  • its solved and so on – amjackfan May 28 '20 at 07:14
  • Recursive raycasting will work on the nested objects yes. If you've solved this then feel free to post an answer to your question so others can use it. :) – Don McCurdy May 29 '20 at 01:35
  • Does this answer your question? [Raycasting against 'subscenes' in three.js](https://stackoverflow.com/questions/17607435/raycasting-against-subscenes-in-three-js) – Don McCurdy May 29 '20 at 01:36

0 Answers0