Question

I just load an MTLOBJ and everything is fine but when I want to get the Geometry attribute of the object to get the vertices, there is no way because apparently, it loads a Object3D which should have a Mesh. But I hardly try to find a way to solve this problem.

It seems that Mrdoob proposes to get the parses data but every parameters used in the parse function are set private ..

I try to get the vertices parameters from the geometry parameter which should be in a mesh but no way, even looking through the doc.

Was it helpful?

Solution

You can find the geometry in the hierarchy by doing this:

object.traverse( function ( child ) {

    if ( child.geometry !== undefined ) {

        console.log( child.geometry.vertices );

    }

} );

OTHER TIPS

After some researchs, it appeared that the Object3D is composed with Meshs.

And in the case of loading an OBJMTL (.obj and .mtl), the Object3D named modele had the Mesh accessible by doing modele.children[O] and the array vertices of geometry by doing modele.children[0].geometry.vertices .

I was looking for a way to be sure the object I attribute to my modele was the Mesh with his geometry parameter, thank you Mr Doob for that.

function loadModel(obj, mtl) {
    loader.load(obj, mtl, function ( object ) {
        modele = object;
        //loadingDone = true;
        analyseModel();
        //putModel();
    });
}

function analyseModel() {
    analyser = new AnalyseObj(modele.children[0]); //I give the Mesh of my model
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top