Refactor terrain data handling and add comprehensive unit tests for brush, mesh, and serialization.
This commit is contained in:
@@ -3,6 +3,7 @@ import { describe, expect, it } from "vitest";
|
||||
import { createTerrain } from "../../src/document/terrains";
|
||||
import {
|
||||
buildTerrainDerivedMeshData,
|
||||
buildTerrainLodChunkMeshData,
|
||||
buildTerrainLodMeshData,
|
||||
resolveTerrainLodLevelIndex,
|
||||
resolveTerrainLodLevelIndexWithHysteresis
|
||||
@@ -131,6 +132,25 @@ describe("terrain mesh generation", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("can rebuild one terrain LoD chunk from its starting sample", () => {
|
||||
const terrain = createTerrain({
|
||||
sampleCountX: 130,
|
||||
sampleCountZ: 70
|
||||
});
|
||||
|
||||
const chunk = buildTerrainLodChunkMeshData(terrain, 64, 0);
|
||||
|
||||
expect(chunk).toMatchObject({
|
||||
chunkX: 1,
|
||||
chunkZ: 0,
|
||||
startSampleX: 64,
|
||||
startSampleZ: 0,
|
||||
endSampleX: 128,
|
||||
endSampleZ: 64
|
||||
});
|
||||
expect(chunk?.levels.length).toBeGreaterThan(1);
|
||||
});
|
||||
|
||||
it("generates smaller terrain LoD levels as stride increases", () => {
|
||||
const terrain = createTerrain({
|
||||
sampleCountX: 65,
|
||||
|
||||
Reference in New Issue
Block a user