Why Three.Raycaster works only in one object?Detecting an undefined object propertyHow do JavaScript closures work?What is the most efficient way to deep clone an object in JavaScript?How do I remove a property from a JavaScript object?How do I check if an array includes an object in JavaScript?How do I correctly clone a JavaScript object?Checking if a key exists in a JavaScript object?Storing Objects in HTML5 localStorageWhy does Google prepend while(1); to their JSON responses?How to check if an object is an array?
Reaction of borax with NaOH
Exclude loop* snap devices from lsblk output?
Why does my circuit work on a breadboard, but not on a perfboard? I am new to soldering
Was there ever any real use for a 6800-based Apple I?
How does Howard Stark know this?
Exception propagation: When should I catch exceptions?
Proof that the inverse image of a single element is a discrete space
Size of a folder with du
Repair a file using Audacity?
Why was Thor doubtful about his worthiness to Mjolnir?
use the oversamplling followed by '' decimation method ''to increasee the ADC resolution and not normal averaging
Why in a Ethernet LAN, a packet sniffer can obtain all packets sent over the LAN?
Two researchers want to work on the same extension to my paper. Who to help?
How are one-time password generators like Google Authenticator different from having two passwords?
Does kinetic energy warp spacetime?
How can a Lich look like a human without magic?
What is Plautus’s pun about frustum and frustrum?
Find the cipher used
What does 松の木に吊るされた mean in this sentence?
iMac 27" 2017 memory upgrade question
Is a vector space automatically spacelike if it has a basis of spacelike vectors?
Why do Thanos's punches not kill Captain America or at least cause some mortal injuries?
How do I compare the result of "1d20+x, with advantage" to "1d20+y, without advantage", assuming x < y?
Why does getw return -1 when trying to read a character?
Why Three.Raycaster works only in one object?
Detecting an undefined object propertyHow do JavaScript closures work?What is the most efficient way to deep clone an object in JavaScript?How do I remove a property from a JavaScript object?How do I check if an array includes an object in JavaScript?How do I correctly clone a JavaScript object?Checking if a key exists in a JavaScript object?Storing Objects in HTML5 localStorageWhy does Google prepend while(1); to their JSON responses?How to check if an object is an array?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
Hi all I have about 300 Three.Line objects, a Three.GridHelper, and other objects (spheres, cubes, pyramids, camera, light) in my scene. What I'm trying to do, is to reference each line with a THREE.RayCaster, so that I can detect whether that Line is colliding with another object in the current scene.
This is the function I use for the moment, however the for loop only goes into 2 iterations only, which means that the other objects are not referenced with a raycaster (or at least there is no further intersection).
intersect: function()
//var thisNormal;
var raycaster = new THREE.Raycaster();
var intersects = raycaster.intersectObjects(scene_Main.children);
for(var i=0; i<intersects.length; i++)
console.log("intersects loop = " + i);
if(intersects.length > 0)
console.log("not empty");
intersects[i].object.material = ray_material_yellow;

As you can see from the figure above, the only object that change the material to YELLOW, is the GridHelper. Please if you are familiar with this let me know what is going on. Why this only get the GridHelper object and not any other objects?
I think the way that I create the objects could be the problem. Here is a figure of code just to mention this as well.

UPDATE:
intersect: function()
if(!f_Ray_intersected_check)
//var thisNormal;
var counter = 0;
var intersects = [];
for(var i=0; i<f_Ray_List[0].length; i++)
console.log(f_Ray_List[i]);
for(var j=0; j<f_Ray_List[0].length; j++)
var raycaster = new THREE.Raycaster();
intersects[i] = raycaster.intersectObjects(f_Ray_List[i], true);
for(var i=0; i<intersects.length; i++)
if(intersects[i].length > 0)
counter++;
intersects.object.material = ray_material_yellow;
alert(counter);
f_Ray_intersected_check = true; //Exit entry of this function - do not enter again
,
javascript three.js
|
show 1 more comment
Hi all I have about 300 Three.Line objects, a Three.GridHelper, and other objects (spheres, cubes, pyramids, camera, light) in my scene. What I'm trying to do, is to reference each line with a THREE.RayCaster, so that I can detect whether that Line is colliding with another object in the current scene.
This is the function I use for the moment, however the for loop only goes into 2 iterations only, which means that the other objects are not referenced with a raycaster (or at least there is no further intersection).
intersect: function()
//var thisNormal;
var raycaster = new THREE.Raycaster();
var intersects = raycaster.intersectObjects(scene_Main.children);
for(var i=0; i<intersects.length; i++)
console.log("intersects loop = " + i);
if(intersects.length > 0)
console.log("not empty");
intersects[i].object.material = ray_material_yellow;

As you can see from the figure above, the only object that change the material to YELLOW, is the GridHelper. Please if you are familiar with this let me know what is going on. Why this only get the GridHelper object and not any other objects?
I think the way that I create the objects could be the problem. Here is a figure of code just to mention this as well.

UPDATE:
intersect: function()
if(!f_Ray_intersected_check)
//var thisNormal;
var counter = 0;
var intersects = [];
for(var i=0; i<f_Ray_List[0].length; i++)
console.log(f_Ray_List[i]);
for(var j=0; j<f_Ray_List[0].length; j++)
var raycaster = new THREE.Raycaster();
intersects[i] = raycaster.intersectObjects(f_Ray_List[i], true);
for(var i=0; i<intersects.length; i++)
if(intersects[i].length > 0)
counter++;
intersects.object.material = ray_material_yellow;
alert(counter);
f_Ray_intersected_check = true; //Exit entry of this function - do not enter again
,
javascript three.js
1
Does it work if you call the method like so:raycaster.intersectObjects(scene_Main.children, true);? Notice the second parameterrecursivethat is now set totrue. It means the raycaster also checks the entire hierarchy of objects (children) and not only the objects in the given array.
– Mugen87
Mar 23 at 12:23
Nope, still the same. And when I try to pass the list of raysraycaster.intersectObjects( f_Ray_List, true );it gives me the following error
– Loizos Vasileiou
Mar 23 at 12:43
There is something wrong with your ray list. It seems to be an array with arrays which is no valid data structure forRaycaster.intersectObjects(). It's only allowed to pass an array ofObject3Ds. Children of an object muss be present in theObject3D.childrenarray.
– Mugen87
Mar 23 at 12:47
I updated my function, it doesn't give any error. However theif(intersects[i].length > 0)...statement is never executed.
– Loizos Vasileiou
Mar 23 at 13:58
I could not figure out how and whereRaycaster.rayis set.
– Alex Khoroshylov
Mar 23 at 14:50
|
show 1 more comment
Hi all I have about 300 Three.Line objects, a Three.GridHelper, and other objects (spheres, cubes, pyramids, camera, light) in my scene. What I'm trying to do, is to reference each line with a THREE.RayCaster, so that I can detect whether that Line is colliding with another object in the current scene.
This is the function I use for the moment, however the for loop only goes into 2 iterations only, which means that the other objects are not referenced with a raycaster (or at least there is no further intersection).
intersect: function()
//var thisNormal;
var raycaster = new THREE.Raycaster();
var intersects = raycaster.intersectObjects(scene_Main.children);
for(var i=0; i<intersects.length; i++)
console.log("intersects loop = " + i);
if(intersects.length > 0)
console.log("not empty");
intersects[i].object.material = ray_material_yellow;

As you can see from the figure above, the only object that change the material to YELLOW, is the GridHelper. Please if you are familiar with this let me know what is going on. Why this only get the GridHelper object and not any other objects?
I think the way that I create the objects could be the problem. Here is a figure of code just to mention this as well.

UPDATE:
intersect: function()
if(!f_Ray_intersected_check)
//var thisNormal;
var counter = 0;
var intersects = [];
for(var i=0; i<f_Ray_List[0].length; i++)
console.log(f_Ray_List[i]);
for(var j=0; j<f_Ray_List[0].length; j++)
var raycaster = new THREE.Raycaster();
intersects[i] = raycaster.intersectObjects(f_Ray_List[i], true);
for(var i=0; i<intersects.length; i++)
if(intersects[i].length > 0)
counter++;
intersects.object.material = ray_material_yellow;
alert(counter);
f_Ray_intersected_check = true; //Exit entry of this function - do not enter again
,
javascript three.js
Hi all I have about 300 Three.Line objects, a Three.GridHelper, and other objects (spheres, cubes, pyramids, camera, light) in my scene. What I'm trying to do, is to reference each line with a THREE.RayCaster, so that I can detect whether that Line is colliding with another object in the current scene.
This is the function I use for the moment, however the for loop only goes into 2 iterations only, which means that the other objects are not referenced with a raycaster (or at least there is no further intersection).
intersect: function()
//var thisNormal;
var raycaster = new THREE.Raycaster();
var intersects = raycaster.intersectObjects(scene_Main.children);
for(var i=0; i<intersects.length; i++)
console.log("intersects loop = " + i);
if(intersects.length > 0)
console.log("not empty");
intersects[i].object.material = ray_material_yellow;

As you can see from the figure above, the only object that change the material to YELLOW, is the GridHelper. Please if you are familiar with this let me know what is going on. Why this only get the GridHelper object and not any other objects?
I think the way that I create the objects could be the problem. Here is a figure of code just to mention this as well.

UPDATE:
intersect: function()
if(!f_Ray_intersected_check)
//var thisNormal;
var counter = 0;
var intersects = [];
for(var i=0; i<f_Ray_List[0].length; i++)
console.log(f_Ray_List[i]);
for(var j=0; j<f_Ray_List[0].length; j++)
var raycaster = new THREE.Raycaster();
intersects[i] = raycaster.intersectObjects(f_Ray_List[i], true);
for(var i=0; i<intersects.length; i++)
if(intersects[i].length > 0)
counter++;
intersects.object.material = ray_material_yellow;
alert(counter);
f_Ray_intersected_check = true; //Exit entry of this function - do not enter again
,
javascript three.js
javascript three.js
edited Mar 23 at 13:56
Loizos Vasileiou
asked Mar 23 at 11:27
Loizos VasileiouLoizos Vasileiou
14211
14211
1
Does it work if you call the method like so:raycaster.intersectObjects(scene_Main.children, true);? Notice the second parameterrecursivethat is now set totrue. It means the raycaster also checks the entire hierarchy of objects (children) and not only the objects in the given array.
– Mugen87
Mar 23 at 12:23
Nope, still the same. And when I try to pass the list of raysraycaster.intersectObjects( f_Ray_List, true );it gives me the following error
– Loizos Vasileiou
Mar 23 at 12:43
There is something wrong with your ray list. It seems to be an array with arrays which is no valid data structure forRaycaster.intersectObjects(). It's only allowed to pass an array ofObject3Ds. Children of an object muss be present in theObject3D.childrenarray.
– Mugen87
Mar 23 at 12:47
I updated my function, it doesn't give any error. However theif(intersects[i].length > 0)...statement is never executed.
– Loizos Vasileiou
Mar 23 at 13:58
I could not figure out how and whereRaycaster.rayis set.
– Alex Khoroshylov
Mar 23 at 14:50
|
show 1 more comment
1
Does it work if you call the method like so:raycaster.intersectObjects(scene_Main.children, true);? Notice the second parameterrecursivethat is now set totrue. It means the raycaster also checks the entire hierarchy of objects (children) and not only the objects in the given array.
– Mugen87
Mar 23 at 12:23
Nope, still the same. And when I try to pass the list of raysraycaster.intersectObjects( f_Ray_List, true );it gives me the following error
– Loizos Vasileiou
Mar 23 at 12:43
There is something wrong with your ray list. It seems to be an array with arrays which is no valid data structure forRaycaster.intersectObjects(). It's only allowed to pass an array ofObject3Ds. Children of an object muss be present in theObject3D.childrenarray.
– Mugen87
Mar 23 at 12:47
I updated my function, it doesn't give any error. However theif(intersects[i].length > 0)...statement is never executed.
– Loizos Vasileiou
Mar 23 at 13:58
I could not figure out how and whereRaycaster.rayis set.
– Alex Khoroshylov
Mar 23 at 14:50
1
1
Does it work if you call the method like so:
raycaster.intersectObjects(scene_Main.children, true);? Notice the second parameter recursive that is now set to true. It means the raycaster also checks the entire hierarchy of objects (children) and not only the objects in the given array.– Mugen87
Mar 23 at 12:23
Does it work if you call the method like so:
raycaster.intersectObjects(scene_Main.children, true);? Notice the second parameter recursive that is now set to true. It means the raycaster also checks the entire hierarchy of objects (children) and not only the objects in the given array.– Mugen87
Mar 23 at 12:23
Nope, still the same. And when I try to pass the list of rays
raycaster.intersectObjects( f_Ray_List, true ); it gives me the following error– Loizos Vasileiou
Mar 23 at 12:43
Nope, still the same. And when I try to pass the list of rays
raycaster.intersectObjects( f_Ray_List, true ); it gives me the following error– Loizos Vasileiou
Mar 23 at 12:43
There is something wrong with your ray list. It seems to be an array with arrays which is no valid data structure for
Raycaster.intersectObjects(). It's only allowed to pass an array of Object3Ds. Children of an object muss be present in the Object3D.children array.– Mugen87
Mar 23 at 12:47
There is something wrong with your ray list. It seems to be an array with arrays which is no valid data structure for
Raycaster.intersectObjects(). It's only allowed to pass an array of Object3Ds. Children of an object muss be present in the Object3D.children array.– Mugen87
Mar 23 at 12:47
I updated my function, it doesn't give any error. However the
if(intersects[i].length > 0)... statement is never executed.– Loizos Vasileiou
Mar 23 at 13:58
I updated my function, it doesn't give any error. However the
if(intersects[i].length > 0)... statement is never executed.– Loizos Vasileiou
Mar 23 at 13:58
I could not figure out how and where
Raycaster.ray is set.– Alex Khoroshylov
Mar 23 at 14:50
I could not figure out how and where
Raycaster.ray is set.– Alex Khoroshylov
Mar 23 at 14:50
|
show 1 more comment
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55313241%2fwhy-three-raycaster-works-only-in-one-object%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55313241%2fwhy-three-raycaster-works-only-in-one-object%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Does it work if you call the method like so:
raycaster.intersectObjects(scene_Main.children, true);? Notice the second parameterrecursivethat is now set totrue. It means the raycaster also checks the entire hierarchy of objects (children) and not only the objects in the given array.– Mugen87
Mar 23 at 12:23
Nope, still the same. And when I try to pass the list of rays
raycaster.intersectObjects( f_Ray_List, true );it gives me the following error– Loizos Vasileiou
Mar 23 at 12:43
There is something wrong with your ray list. It seems to be an array with arrays which is no valid data structure for
Raycaster.intersectObjects(). It's only allowed to pass an array ofObject3Ds. Children of an object muss be present in theObject3D.childrenarray.– Mugen87
Mar 23 at 12:47
I updated my function, it doesn't give any error. However the
if(intersects[i].length > 0)...statement is never executed.– Loizos Vasileiou
Mar 23 at 13:58
I could not figure out how and where
Raycaster.rayis set.– Alex Khoroshylov
Mar 23 at 14:50