Add mipmapping where possible and possibly fix grass side overlay for resourcepacks

This commit is contained in:
Blue (Lukas Rieger) 2020-01-22 20:39:38 +01:00
parent 8cf7bb3dc4
commit 316f2d3293

View File

@ -37,6 +37,7 @@ import {
MeshLambertMaterial, MeshLambertMaterial,
NormalBlending, NormalBlending,
NearestFilter, NearestFilter,
NearestMipmapLinearFilter,
PerspectiveCamera, PerspectiveCamera,
Scene, Scene,
Texture, Texture,
@ -89,7 +90,7 @@ export default class BlueMap {
this.initModules(); this.initModules();
this.start(); this.start();
}).catch(error => { }).catch(error => {
this.onLoadError(error.toString()) this.onLoadError(error.toString());
console.error(error); console.error(error);
}); });
} }
@ -364,9 +365,11 @@ export default class BlueMap {
for (let i = 0; i < textures['textures'].length; i++) { for (let i = 0; i < textures['textures'].length; i++) {
let t = textures['textures'][i]; let t = textures['textures'][i];
let opaque = t['color'][3] === 1;
let transparent = t['transparent'];
let material = new MeshLambertMaterial({ let material = new MeshLambertMaterial({
transparent: t['transparent'], transparent: transparent,
alphaTest: 0.01, alphaTest: transparent ? 0 : (opaque ? 1 : 0.01),
depthWrite: true, depthWrite: true,
depthTest: true, depthTest: true,
blending: NormalBlending, blending: NormalBlending,
@ -378,15 +381,15 @@ export default class BlueMap {
let texture = new Texture(); let texture = new Texture();
texture.image = stringToImage(t['texture']); texture.image = stringToImage(t['texture']);
texture.premultiplyAlpha = false; texture.anisotropy = 1;
texture.generateMipmaps = false; texture.generateMipmaps = opaque || transparent;
texture.magFilter = NearestFilter; texture.magFilter = NearestFilter;
texture.minFilter = NearestFilter; texture.minFilter = texture.generateMipmaps ? NearestMipmapLinearFilter : NearestFilter;
texture.wrapS = ClampToEdgeWrapping; texture.wrapS = ClampToEdgeWrapping;
texture.wrapT = ClampToEdgeWrapping; texture.wrapT = ClampToEdgeWrapping;
texture.flipY = false; texture.flipY = false;
texture.needsUpdate = true;
texture.flatShading = true; texture.flatShading = true;
texture.needsUpdate = true;
material.map = texture; material.map = texture;
material.needsUpdate = true; material.needsUpdate = true;