0

三.js r62

我有一个来自 .obj 文件的场景,其中包含一些网格。 https://dl.dropboxusercontent.com/u/8913924/terrain/index.html

我尝试将纹理应用于“地形”对象。结果是一个不可见/透明的纹理。

(如果纹理应用于场景中的任何其他对象 - 一切似乎都很好)

检查上面的演示

注意:.mtl 文件为空;

上传纹理并将其应用于场景的所有对象:

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

将此纹理应用于地形和所有其他对象:

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;                    
}
4

0 回答 0