我是否必须为每个纹理设置各向异性纹理过滤?
如果您可以为 Material 甚至全局场景设置各向异性级别,我认为会很酷。有任何想法吗?

maxA = renderer.getMaxAnisotropy();

var texture1 = THREE.ImageUtils.loadTexture('models/folder/m67/o1.jpg');
texture1.anisotropy = maxA;

var texture2 = THREE.ImageUtils.loadTexture('models/folder/m67/o2.jpg');
texture2.anisotropy = maxA;

var texture3 = THREE.ImageUtils.loadTexture('models/folder/m67/c1.jpg');
texture3.anisotropy = maxA;

var texture4 = THREE.ImageUtils.loadTexture('models/folder/m67/c2.jpg');
texture4.anisotropy = maxA;

var material = {
  "logoprint": new THREE.MeshPhongMaterial({
    map: texture1
  }),
}

最佳答案

您可以将负载包装到一个函数中,imageutils 只是为您提供了另一个实用程序函数

function loadTexture( url ){
    var tex = THREE.ImageUtils.loadTexture(url);
    tex.anisotropy = MAXANISO;
    return tex;
}

澄清这里发生的事情,以及如何处理 ImageUtils 折旧警告:
var tl = new THREE.TextureLoader();

//calling load on it immediately returns a THREE.Texture object
var myTexture = tl.load( 'name.jpg' );

//you can also pass a callback
function onTextureLoaded( tex ){

    //tex.image contains data, because textureLoader updated it, before passing it to the callback
    handleTexture( tex )...
}
var myTexture = tl.load( 'name.jpg' , onTextureLoaded );

// myTexture is now an instance of THREE.Texture
// myTexture.image contains no data

myTexture.aniso = ...; //texture is configured , but probably waiting for data

纹理对象本身包含所有这些 3d 属性,例如环绕、映射类型和过滤。图像数据本身与此无关,无论您如何使用它,它都保持不变。
当您在纹理加载器上调用 load 时,它会返回一个代理 - 一个对象的引用,该对象可以被配置、操作并传递给其他对象(如 Material )以供使用。
Material 可以渲染空纹理。加载图像数据时,纹理会更新,下一帧将反射(reflect)这一点。
 var tl = new THREE.TextureLoader()

 function myCustomLoad( url ){
     var newTex = tl.load(url); //make the proxy
     newTex.prop = ... ;//config
     return newTex; //return configured texture, it will update itself
}

关于Three.js:我必须为每个纹理设置各向异性纹理过滤吗?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35012926/

10-15 14:02