Just starting out as a new programmer in the world of Javascript and three.js, I encountered an error where getObjectById is not working properly. The specific TypeError message reads: "scene.getObjectById is not a function."
My goal was to access an object within the three.js scene using its id, which I had saved in an array at location tre[m][1].
The issue seems to occur not only with calling by id but also by name.
function crvtre(){
// alert("I enter crvtre"); for(var m=0; m<max; m++){ for(var n=m+1; n<max; n++){ // we should add in (tre[m][0] != tre[n][0]) to draw between trees only and inside one tree if(tre[m][5]==0 && tre[n][5]==0 && (tre[m][0] != tre[n][0])){ var object = scene.getObjectById(tre[m][1],true); console.log(object.userData[1]) } } } //animate(); }
Although this may seem like a trivial issue, I have been struggling to pinpoint the exact reason behind it. Any ideas or suggestions would be greatly appreciated!