We are currently encountering an issue with ThreeJS. Our goal is to integrate HTML elements into ThreeJS and use raycasting to determine whether we are pointing to any HTML element. However, when we intersect with it, it returns an empty array. An example of this scenario can be found in the following CodePen:
https://codepen.io/wazosa/pen/OJrqRRy?editors=1111
mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
raycaster.setFromCamera(mouse, camera);
var intersects = raycaster.intersectObject(scene, true);
console.log(intersects)
if (intersects.length > 0) {
var object = intersects[0].object;
}
In this example, there is a div and a cube. Clicking on the cube will display it in the console, but clicking on the div element results in an empty array. Any suggestions on how to resolve this issue would be greatly appreciated.
Thank you in advance