three.js icon indicating copy to clipboard operation
three.js copied to clipboard

Raycaster not working on webGL objects loaded using OBJMTLLoader

Open abincg opened this issue 13 years ago • 2 comments

Hi... I was working on a webGL project in which I dynamically loads some objects to the scene using the OBJMTLLoader. But I can't locate the objects using Raycaster to find the intersecting points. In the same project, when I added geometric objects statically and dynamically, it was working fine. What may be the problem for the issue..? The below code is used to load the object.

    this.loadNewObject=function(url)
        {               
            var path1="./models/"+url+".obj";
            var path2="./models/"+url+".mtl";
            var scene1=dview.scene;
            var loader = new THREE.OBJMTLLoader();
            loader.addEventListener( 'load', function ( event ) {

                var dae1 = event.content;


            dae1.scale.x = dae1.scale.y = dae1.scale.z = 0.225;
            dae1.position.x=0;
            dae1.position.y=0;
            dae1.position.z=100;


            scene.add(dae1);
            objects.push(dae1);

            });
            loader.load(path1, path2 );
        }

abincg avatar Jul 04 '13 09:07 abincg

abincg, i am also loading OBJ with and without material and it works fine with both r58 and dev59 so there is some issue on your side, i think. Although i can't see what should be wrong with your code. But it sure gets loaded and displays correctly? Maybe you are doing something wrong with the raycaster ? btw. your scene varialbe is called "scene1" in this code snipped but you are adding "dae" to "scene". is that correct? btw why is your variable named dae because obj and dae are two different file formats, ( i know, it is just a variable name, just as a side note)

GuyGood avatar Jul 05 '13 07:07 GuyGood

Hi GuyGood...

I solved the above issue. As you mentioned the error was with the raycaster... I made a small mistake on it's coding. And about the other things you mentioned, I didn't find any issues related to that. By the way thanks for your concern.

abincg avatar Jul 05 '13 07:07 abincg