From df19192118083967b065c789c7b0a1395b4b9725 Mon Sep 17 00:00:00 2001 From: Richard Zink Date: Tue, 6 Oct 2026 15:43:22 +0200 Subject: [PATCH] Fix: simplified landscape generation --- assets/index.html | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/assets/index.html b/assets/index.html index b36aa02..40bb252 100644 --- a/assets/index.html +++ b/assets/index.html @@ -64,12 +64,12 @@ class Landscape { constructor() { - this.gridSize = 60; - this.gridRange = 40; - this.offsetX = -this.gridRange * this.gridSize; - this.offsetZ = -this.gridRange * this.gridSize; + this.gridSize = 80; + this.gridRange = 50; + this.offsetX = 0; + this.offsetZ = 0; this.points = new Map(); - this.waterLevel = -15; + this.waterLevel = -10; this.updateOffset(); } @@ -78,14 +78,13 @@ } generateHeight(x, z) { - const nx = x / 80; - const nz = z / 80; + const nx = x / 100; + const nz = z / 100; let y = 0; - y += Math.sin(nx) * 25; - y += Math.cos(nz) * 25; + y += Math.sin(nx) * 30; + y += Math.cos(nz) * 30; y += Math.sin(nx * 2 + nz * 0.5) * 15; y += Math.cos(nz * 2 - nx) * 15; - y += Math.sin(nx * 3 - nz * 2) * 8; return y; } @@ -95,35 +94,20 @@ updateOffset() { this.offsetX -= 1; - this.offsetZ -= 0.5; - if (this.offsetX < -this.gridSize) { - this.offsetX = 0; - } + this.offsetZ -= 1; } getPoint(x, z) { - const key = this.getKey(x + this.offsetX, z + this.offsetZ); - if (this.points.has(key)) { - return this.points.get(key); - } - const worldX = x * this.gridSize + this.offsetX; const worldZ = z * this.gridSize + this.offsetZ; const y = this.generateHeight(worldX, worldZ); const point = new Point3D(worldX, y, worldZ); point.isWater = this.isWater(worldX, worldZ, y); - this.points.set(key, point); return point; } update() { this.updateOffset(); - this.points.forEach((val, key) => { - const [gx, gz] = key.split(',').map(Number); - if (gx > this.gridRange || gz > this.gridRange) { - this.points.delete(key); - } - }); } draw() {