三个js,块纹理是模糊的

时间:2015-06-13 18:51:31

标签: javascript web three.js

我正在尝试使用three.js库制作3D块 我做到了现在我不想在上面加上纹理。我做到了,它正在发挥作用:

var textureHerbe = [
     new THREE.MeshBasicMaterial({map:THREE.ImageUtils.loadTexture('img/texture/herbe/border.gif')}),
     new THREE.MeshBasicMaterial({map:THREE.ImageUtils.loadTexture('img/texture/herbe/border.gif')}),
     new THREE.MeshBasicMaterial({map:THREE.ImageUtils.loadTexture('img/texture/herbe/top.gif')}),
     new THREE.MeshBasicMaterial({map:THREE.ImageUtils.loadTexture('img/texture/herbe/bottom.gif')}),
     new THREE.MeshBasicMaterial({map:THREE.ImageUtils.loadTexture('img/texture/herbe/border.gif')}),
     new THREE.MeshBasicMaterial({map:THREE.ImageUtils.loadTexture('img/texture/herbe/border.gif')})
];

结果如下:
enter image description here
但看看这个,它是模糊的!
所以我看了这个this link。我不知道如何将我的代码与他的解决方案的代码混合:/
你知道我怎么做吗?谢谢你,祝你有个美好的一天。

1 个答案:

答案 0 :(得分:1)

首先,您要多次加载相同的纹理。因此,将其分配给变量,然后使纹理与分辨率无关,并且渲染时不会模糊。

var border_tex = new THREE.ImageUtils.loadTexture('img/texture/herbe/border.gif');
border_tex.magFilter = THREE.NearestFilter;
border_tex.minFilter = THREE.LinearMipMapLinearFilter;

var top_tex = new THREE.ImageUtils.loadTexture('img/texture/herbe/top.gif');
top_tex.magFilter = THREE.NearestFilter;
top_tex.minFilter = THREE.LinearMipMapLinearFilter;

var bottom_tex = new THREE.ImageUtils.loadTexture('img/texture/herbe/bottom.gif');
bottom_tex.magFilter = THREE.NearestFilter;
bottom_tex.minFilter = THREE.LinearMipMapLinearFilter;

var textureHerbe = [
    new THREE.MeshBasicMaterial( { map: border_tex } ),
    new THREE.MeshBasicMaterial( { map: border_tex } ),
    new THREE.MeshBasicMaterial( { map: top_tex } ),
    new THREE.MeshBasicMaterial( { map: bottom_tex } ),
    new THREE.MeshBasicMaterial( { map: border_tex } ),
    new THREE.MeshBasicMaterial( { map: border_tex } ),
];