我修改了一个 minecraft-ish 演示,这样你就可以四处跳跃并放置方块。但是由于某种原因,我构建的块的纹理是平滑的而不是像素化的。

我认为相关的来源:

var textureDirt = THREE.ImageUtils.loadTexture( 'img/dirt.png' );
textureGrass.magFilter = THREE.NearestFilter;
textureGrass.minFilter = THREE.LinearMipMapLinearFilter;
var material = new THREE.MeshLambertMaterial( { map: textureDirt, ambient: 0xbbbbbb, vertexColors: THREE.VertexColors } );

var geometry = new THREE.CubeGeometry(1,1,1);
var mesh = new THREE.Mesh(geometry, material);
mesh.position.x = point[0];
mesh.position.y = point[1];
mesh.position.z = point[2];

// for physics
mesh.blockType = type;
world[point] = mesh;

scene.add(mesh);

现场演示:
http://ubershmekel.github.com/mine3js/

其余的来源:
https://github.com/ubershmekel/mine3js/blob/master/js/main.js

最佳答案

查看问题后,我发现了错误。我没有将过滤器应用于污垢 Material

textureGrass.magFilter = THREE.NearestFilter;
textureGrass.minFilter = THREE.LinearMipMapLinearFilter;

本来应该
textureDirt.magFilter = THREE.NearestFilter;
textureDirt.minFilter = THREE.LinearMipMapLinearFilter;

关于javascript - 如何用三个js渲染像素化纹理?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15780592/

10-09 18:44