javascript - How to add a MTL texture to an OBJ in three.js -


hello trying figure out how add mtl file obj in three.js. had obj loaded , coming fix issue. when added code mtl file loaded using mtlloader not getting passed mtlloader.load(url, ....) (as in after adding bit of code scene being rendered nothing inside of it). using alerts track progress of code , getting alerts before statement not after. of solutions have found include using objmtlloader no longer part of current version of three.js (r74).

this code taken official example of loading obj + mtl:

var mtlloader = new three.mtlloader(); mtlloader.setbaseurl( 'obj/male02/' ); mtlloader.setpath( 'obj/male02/' ); var url = "male02_dds.mtl"; mtlloader.load( url, function( materials ) {      materials.preload();      var objloader = new three.objloader();     objloader.setmaterials( materials );     objloader.setpath( 'obj/male02/' );     objloader.load( 'male02.obj', function ( object ) {          object.position.y = - 95;         scene.add( object );      }, onprogress, onerror );  }); 

http://threejs.org/examples/#webgl_loader_obj_mtl

you assign materials obj via:

objloader.setmaterials( materials );

if want manipulate materials, mtlloader giving in callback instance of three.mtlloader.materialcreator. can materials materials.getasarray() example. see source possible functions: https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/mtlloader.js#l138-l417


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -