| 1 | import test from "node:test"; |
| 2 | import assert from "node:assert/strict"; |
| 3 | import { natureNoise01, perlin2, NATURE_TINT, NATURE_NOISE_SIZE } from "../../shared/render/natureNoise.js"; |
| 4 | import { CHUNK_SIZE } from "../../shared/protocol/constants.js"; |
| 5 | |
| 6 | test("nature noise is continuous across chunk borders", () => |
| 7 | { |
| 8 | const scale = NATURE_TINT.scale; |
| 9 | const a = natureNoise01(CHUNK_SIZE - 1, 5, scale); |
| 10 | const b = natureNoise01(CHUNK_SIZE, 5, scale); |
| 11 | assert.ok(Math.abs(a - b) < 0.25, `border jump too large: ${a} vs ${b}`); |
| 12 | }); |
| 13 | |
| 14 | test("perlin is deterministic and bounded", () => |
| 15 | { |
| 16 | assert.equal(perlin2(1.5, 2.5), perlin2(1.5, 2.5)); |
| 17 | const n = natureNoise01(12, 34, NATURE_TINT.scale); |
| 18 | assert.ok(n >= 0 && n <= 1); |
| 19 | }); |
| 20 | |
| 21 | test("nature noise texture includes a one-tile halo", () => |
| 22 | { |
| 23 | assert.equal(NATURE_NOISE_SIZE, CHUNK_SIZE + 2); |
| 24 | }); |