javascript - How to set a texture on a Object3D child Mesh -
i imported object3d this:
var globalobject; // global object var loader = new three.objectloader(); loader.load('path/to/object3d.json', function(object) { globalobject = object; scene.add(globalobject); }); what want achieve when user clicks on button, mesh elements of whole object texture. this:
// on button click { for(var in globalobject.children) { // apply mesh of interest { var texture = three.imageutils.loadtexture('path/to/image.jpg'); globalobject.children[i].material = new three.meshlambertmaterial({map: texture, needsupdate: true}); } // end apply mesh of interest } } // end on button click the above code seems work far setting texture. problem here texture looks kind of distorted. looks http://db.tt/s5vesbyd
how correct this, full texture gets applied both surfaces?
this should trick:
// on button click { for(var in globalobject.children) { // apply mesh of interest { var texture = three.imageutils.loadtexture('path/to/image.jpg'); texture.wraps = three.repeatwrapping; texture.wrapt = three.repeatwrapping; globalobject.children[i].material = new three.meshlambertmaterial({map: texture, needsupdate: true}); } // end apply mesh of interest } } // end on button click
Comments
Post a Comment