0

Three.js r62

I have a scene from .obj file with a few meshes. https://dl.dropboxusercontent.com/u/8913924/terrain/index.html

I try to apply a texture to the "terrain" object. Result is an invisible/transparent texture.

(if a texture applied to any other objects in the scene - everything seems ok)

check the demo above.

Notes: .mtl file is empty;

Upload a texture and apply the one to all the objects of the scene:

/* prepare the texture */
var texture = THREE.ImageUtils.loadTexture( 'crate.gif' );
texture.needsUpdate = true;

Apply this texture to terrain and all other objects:

if ( ('string' == typeof o.type) && ( 'terrain' == o.type)){
 /*work with terrain*/          
 //object.children[i].material = object.children[i].material.clone();
 object.children[i] = new THREE.Mesh (object.children[i].geometry.clone(), object.children[i].material.clone());
 object.children[i].material.color.setHex(0xffffff);
 object.children[i].material.map = texture;
 object.children[i].material.ownMaterial = true;
 //console.log('terrain colored');
} else  {
      /*work with all other objects*/
  object.children[i].material = object.children[i].material.clone();
  object.children[i].material.ownMaterial = true;
  object.children[i].material.map = texture;                    
}

0 Answers0