heightmap select - style fixes

This commit is contained in:
Azgaar 2022-05-27 02:22:25 +03:00
parent 6766de46ef
commit f56bd0f586
7 changed files with 123 additions and 91 deletions

View file

@ -1369,10 +1369,12 @@ function editHeightmap() {
grid.cells.h.forEach((height, i) => {
const h = height < 20 ? Math.max(height / 1.5, 0) : height;
const v = (h / 100) * 255;
imageData.data[i * 4] = v;
imageData.data[i * 4 + 1] = v;
imageData.data[i * 4 + 2] = v;
imageData.data[i * 4 + 3] = 255;
const n = i * 4;
imageData.data[n] = v;
imageData.data[n + 1] = v;
imageData.data[n + 2] = v;
imageData.data[n + 3] = 255;
});
ctx.putImageData(imageData, 0, 0);

View file

@ -151,9 +151,9 @@ function toggleHeight(event) {
function drawHeightmap() {
TIME && console.time("drawHeightmap");
terrs.selectAll("*").remove();
const cells = pack.cells,
vertices = pack.vertices,
n = cells.i.length;
const {cells, vertices} = pack;
const n = cells.i.length;
const used = new Uint8Array(cells.i.length);
const paths = new Array(101).fill("");
@ -161,6 +161,7 @@ function drawHeightmap() {
const terracing = terrs.attr("terracing") / 10; // add additional shifted darker layer for pseudo-3d effect
const skip = +terrs.attr("skip") + 1;
const simplification = +terrs.attr("relax");
switch (+terrs.attr("curve")) {
case 0:
lineGen.curve(d3.curveBasisClosed);