Hi there,
This thread is a part of the same project as the previous question I’ve asked here : [SOLVED] Beginner - PerspectiveCamera
Note that you don’t need to read the old post to understand that one.
So I am currently creating boxes at some locations. Thoses boxes can be clicked out using Raycaster. It pop out a window (a div, DOM) that take all the screen. But, if I click on the div, it also include the Raycaster values, causing more boxes to be clicked through the div.
To get ride of this, I’ve included the div (Yes, I actually do) in the clickable objects. As a result, when I click wherever on the div, boxes aren’t clicked, as long as the div is now included in intersects and as long as I am only acting on the first item clicked. I actually made what I want and it works, but I get a JavaScript error, so I think this isn’t the way I should do this.
Error :
Uncaught TypeError: a.raycast is not a function (three.min.js:295)
at xe (three.min.js:295)
at uf.intersectObjects (three.min.js:863)
at HTMLDocument.onDocumentMouseDown (scene.js:334)
Line 334 :
var intersects = raycaster.intersectObjects(objects);
if(intersects.length > 0) {
if(intersects[0].c_type == "div") {
[...]
Any idea how I could get ride off that error ?
EDIT : As you should have understand, I define any clickable element by a custom attribute named c_type. It means that clicking on a c_type = “box” will not make the same action as a c_type = “div”. Example :
$('div#boxDetail').c_type = "div";
EDIT 2 : Forget what I’ve said. Raycaster doesn’t work anymore when the div is added to objects. But I have an inda, I will try, and tell you the result.
EDIT 3 : My idea doesn’t work. It was to make an object containing the div. Why not, after all ?