Skip to content

Commit 856a0fc

Browse files
committed
make face vertex pushing it's own method
1 parent b8ebd19 commit 856a0fc

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

src/client/scripts/World/ChunkMesher.js

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -403,33 +403,37 @@ class ChunkMesher {
403403
col4[0] /= ile;
404404
col4[2] /= ile;
405405
}
406-
if (this.chunkTerrain.getBlock(...pos).transparent) {
406+
407+
faceVertex.color = [
408+
...col1,
409+
...col3,
410+
...col2,
411+
...col2,
412+
...col3,
413+
...col4];
414+
415+
this.push(t_positions, t_normals, t_uvs, t_colors,
416+
positions, normals, uvs, colors,
417+
faceVertex, this.chunkTerrain.getBlock(...pos).transparent);
418+
419+
420+
};
421+
422+
push(t_positions, t_normals, t_uvs, t_colors,
423+
positions, normals, uvs, colors,
424+
faceVertex, transparent) {
425+
if (transparent) {
407426
t_positions.push(...faceVertex.pos);
408427
t_normals.push(...faceVertex.norm);
409428
t_uvs.push(...faceVertex.uv);
410-
t_colors.push(
411-
...col1,
412-
...col3,
413-
...col2,
414-
...col2,
415-
...col3,
416-
...col4
417-
);
429+
t_colors.push(...faceVertex.color);
418430
} else {
419431
positions.push(...faceVertex.pos);
420432
normals.push(...faceVertex.norm);
421433
uvs.push(...faceVertex.uv);
422-
colors.push(
423-
...col1,
424-
...col3,
425-
...col2,
426-
...col2,
427-
...col3,
428-
...col4
429-
);
434+
colors.push(...faceVertex.color);
430435
}
431-
};
432-
436+
}
433437
aoColor(type) {
434438
if (type === 0) {
435439
return [0.9, 0.9, 0.9];
@@ -494,7 +498,7 @@ class ChunkMesher {
494498
}
495499
}
496500
} else if (
497-
this.chunkTerrain.getBlock(...pos).name === "lava"
501+
this.chunkTerrain.getBlock(...pos).name === "lava"
498502
) {
499503
for (var l in this.neighbours) {
500504
const offset = this.neighbours[l];
@@ -508,7 +512,7 @@ class ChunkMesher {
508512
this.addFace(t_positions, t_normals, t_uvs, t_colors, positions, normals, uvs, colors, l, pos);
509513
}
510514
}
511-
} else if(this.customRender[this.chunkTerrain.getBlock(...pos).name]){
515+
} else if (this.customRender[this.chunkTerrain.getBlock(...pos).name]) {
512516
this.customRender[this.chunkTerrain.getBlock(...pos).name](t_positions, t_normals, t_uvs, t_colors, positions, normals, uvs, colors, pos);
513517
}
514518
}

0 commit comments

Comments
 (0)