当我在JavaScript中使用自定义uv加载模型时,我加载模型时工作正常:
var loader=new THREE.JSONLoader();
loader.load(
name .js',
function ( geometry, materials ) {
var material = new THREE.MeshFaceMaterial( materials );
var object = new THREE.Mesh( geometry, material );
object.position.y = -10;
object.name = name;
view3D.scene.add( object );
}, onProgress, onError)
我用:
创建一个新纹理function CreateTextureMaterial(ImageName){
var Texture = new THREE.ImageUtils.loadTexture('texture/'+ImageName);
var Material = new THREE.MeshBasicMaterial({
map:Texture});
return Material;
}
我将它加载到模型上:
function ChangeTexture(ObjectName, TextureMaterial){
obj = scene.getObjectByName(ObjectName);
obj.material = TextureMaterial;
}
它没有像我预期的那样工作 - 它加载默认的uvs设置但不加载文件的一个。我试着用:
var obj = scene.getObjectByName(ObjectName);
var Texture = new THREE.ImageUtils.loadTexture('texture/'+ImageName);
var Material = new THREE.MeshBasicMaterial({
map:obj.geomerty.faceVertexUvs});
obj.material=Material;
在我看不到任何东西之后。我需要做什么?
答案 0 :(得分:0)
因为MeshFaceMaterial
是一种材料集合,而不仅仅是一种材料,例如MeshBasicMaterial的实例。
此外,您必须为map
应用图像纹理。
你可以这样做。
var texture = new THREE.ImageUtils.loadTexture('texture/'+ImageName);
var myBasicMaterial = new THREE.MeshBasicMaterial({
map: texture
});
obj.material.materials[ 0 ] = myBasicMaterial;