2017-03-05 97 views

回答

1

將紋理應用到.FBX模型的主要問題是.FBX作爲一組子模型加載,每個子模型都有自己的材質。更換這些紋理的方法是遍歷模型的結構:

// FBX loader returns a group containing a multiple sub-objects. Traverse and apply texture to all. 
group.traverse(function (child) { 
    if (child instanceof THREE.Mesh) { 

     // apply texture 
     child.material.map = texture 
     child.material.needsUpdate = true; 
    } 
}); 

對於工作示例,我已經修改了默認three.js所FBX例子來證明這一點:

http://www.eponalabs.com/experiments/FBXReplaceTexture/fbx_replace_texture.html

當您按下按鈕時,上面的代碼片段將用來代替Unsplash.it中佔位符圖像的紋理。

Running man with texture replaced

+1

'mesh'是一組?也許你應該把它稱爲「組」來避免混淆。 – WestLangley

相關問題