Thursday, 15 January 2015

three.js - threejs wireframe not working with OBJMTLLoader -



three.js - threejs wireframe not working with OBJMTLLoader -

am loading object in threejs using objmtlloader, wireframe command working lone objloader, objmtlloader doesn't working

var loader = new three.objmtlloader(); loader.load( 'obj/male02/male02.obj', 'obj/male02/male02_dds.mtl', function ( object ) { object.children[0].geometry.computefacenormals(); var geometry = object.children[0].geometry; console.log(geometry); three.geometryutils.center(geometry); geometry.dynamic = true; var material = new three.meshlambertmaterial({color: 0xffffff, shading: three.flatshading, vertexcolors: three.vertexcolors }); mesh = new three.mesh(geometry, material); scene.add( mesh ); } ); function wireframe(){ //alert('hhhhhh'); mesh.material.wireframe = true; mesh.material.color = new three.color( 0x6893de ); }

but causing next error, model not showing on viewer, here want know can create wireframe on kind of 3d models??

object.children[0].geometry undefined

even though objmtlloader returns three.object3d object have .children, should not assume .children of type three.mesh. should traverse() three.object3d in order find three.mesh.

object.traverse( function ( kid ) { if ( kid instanceof three.mesh ) // geometry } );

three.js

No comments:

Post a Comment