three.js - three js apply texture -


i'm unable apply image texture object exported 3d studio max. can see in image, texture loaded applied once in center of face.

enter image description here

i've tried repeat texture with

texture.wraps = texture.wrapt =  three.repeatwrapping; texture.repeat.x = 2; texture.repeat.y = 2; 

but it's worst.

see code below

<html> <head>     <meta charset="utf8">     <title>demo customizer</title>     <script src="lib/three.min.js"></script>     <script src="lib/controls/trackballcontrols.js"></script>     <script src="lib/controls/orbitcontrols.js"></script>     <script src="lib/loaders/mtlloader.js"></script>     <script src="lib/loaders/objmtlloader.js"></script>     <script src="lib/loaders/objloader.js"></script>     <script src="lib/detector.js"></script>     <script src="lib/libs/stats.min.js"></script>  </head> <body>     <script>     var renderer, scene, camera, mesh, controls, material;      document.addeventlistener("domcontentloaded", function() {          var manager = new three.loadingmanager();         manager.onprogress = function ( item, loaded, total ) {              console.log( item, loaded, total );          };          var texture = new three.texture();          var loader = new three.imageloader( manager );         loader.load( 'material/textures/granit1.jpg', function ( image ) {              texture.image = image;             texture.needsupdate = true;              //texture.wraps = texture.wrapt =  three.repeatwrapping;             //texture.repeat.x = 2;             //texture.repeat.y = 2;         } );          var loader = new three.objloader( manager );            loader.load( '3ds/test3.obj', function ( object ) {               object.position.x = 220;             object.position.y = -8;              object.traverse( function ( child ) {                  if ( child instanceof three.mesh ) {                     console.log(child);                     child.material.map = texture;                  }              } );               // on initialise le moteur de rendu             renderer = new three.webglrenderer();              renderer.setsize( window.innerwidth, window.innerheight );             document.body.appendchild( renderer.domelement );              // on initialise la scène             scene = new three.scene();              // on initialise la camera que l’on place ensuite sur la scène             camera = new three.perspectivecamera( 45, window.innerwidth / window.innerheight, 1, 2000 );             //camera.position.z = 350;              scene.add(camera);             //camera.position.set(0,0,350);             camera.position.set(0,150,400);             camera.lookat(scene.position);              controls = new three.orbitcontrols( camera );             controls.addeventlistener( 'change', render );              // on ajoute une lumière blanche             var lumiere = new three.directionallight( 0xffffff, 1.0 );             lumiere.position.set( 0, 0, 400 );             scene.add( lumiere );             var light = new three.ambientlight( 0x404040 ); // soft white light             scene.add( light );             //scene.add( mesh );             scene.add( object );              // floor             var floortexture = new three.imageutils.loadtexture( 'material/textures/metal/metal001.jpg' );             floortexture.wraps = floortexture.wrapt = three.repeatwrapping;              floortexture.repeat.set( 10, 10 );             var floormaterial = new three.meshbasicmaterial( { map: floortexture, side: three.doubleside } );             var floorgeometry = new three.planegeometry(1000, 1000, 10, 10);             var floor = new three.mesh(floorgeometry, floormaterial);             floor.position.y =0.1;             floor.rotation.x = math.pi / 2;             scene.add(floor);              animate();          });          function animate() {              requestanimationframe( animate );             controls.update();          }          function render() {              renderer.render( scene, camera );          }     });      </script> </body> </html> 

you need apply uvw coordinates model. determines how texture wrap onto model.

in 3ds max, apply uvw modifier model. have few choose from. if model simple may able use simple 1 "uvw map", otherwise, if model complex need use "unwrap uvw" modifier , tweek quite bit. there many tutorials on net doing this.

once done add texture diffuse slot on material in material editor in 3ds max , apply material model. test texture , uvw set right.

then once model , texture looking in max, ready export max , load threejs


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -