Search code examples
javascriptthree.jsgeometrymeshvertices

Loading an OBJMTL Object with three.js and get geometry parameter of the Mesh


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.


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 );
    
        }
    
    } );