implement stats.min.js, improve fps

This commit is contained in:
LabyStudio
2022-02-01 08:30:51 +01:00
parent ac850a5101
commit ed49c9f776
7 changed files with 56 additions and 25 deletions
@@ -16,14 +16,9 @@ window.BlockRenderer = class {
// Check if face is hidden by other block
if (block.shouldRenderFace(world, x, y, z, face)) {
// Start drawing
this.tessellator.startDrawing();
// Render face
this.renderFace(world, block, boundingBox, face, x, y, z);
// Draw
this.tessellator.draw(group);
}
}
}
@@ -6,8 +6,6 @@ window.Tessellator = class {
side: THREE.BackSide,
transparent: true
});
this.index = new THREE.BufferAttribute(new Uint32Array([0, 2, 1, 0, 3, 2]), 1);
}
bindTexture(texture) {
@@ -50,7 +48,19 @@ window.Tessellator = class {
geometry.setAttribute('position', new THREE.BufferAttribute(new Float32Array(this.vertices), 3));
geometry.setAttribute('color', new THREE.BufferAttribute(new Float32Array(this.colors), 3));
geometry.setAttribute('uv', new THREE.BufferAttribute(new Float32Array(this.uv), 2));
geometry.setIndex(this.index);
// Create index array
let index = [];
let verticesPerFace = 4;
for (let i = 0; i < this.addedVertices / verticesPerFace; i++) {
index.push(i * verticesPerFace + 0);
index.push(i * verticesPerFace + 2);
index.push(i * verticesPerFace + 1);
index.push(i * verticesPerFace + 0);
index.push(i * verticesPerFace + 3);
index.push(i * verticesPerFace + 2);
}
geometry.setIndex(new THREE.BufferAttribute(new Uint32Array(index), 1));
let mesh = new THREE.Mesh(geometry, this.material);
group.matrixAutoUpdate = false;