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.

有帮助吗?

解决方案

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

object.traverse( function ( child ) {

    if ( child.geometry !== undefined ) {

        console.log( child.geometry.vertices );

    }

} );

其他提示

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
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top