Skip to content

Commit

Permalink
test: better scene
Browse files Browse the repository at this point in the history
  • Loading branch information
piellardj authored and Sceat committed Jul 2, 2024
1 parent 8b1f39c commit 536f44c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/test/voxel-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,17 @@ type StoredVoxel = {
};

class VoxelMap implements IVoxelMap, IHeightmap {
public readonly scaleXZ: number;
public readonly size: THREE.Vector3;
public readonly voxelMaterialsList = Object.values(voxelMaterials);

private readonly noise2D: NoiseFunction2D;
private readonly voxels: ReadonlyArray<StoredVoxel>;
private readonly coordsShift: THREE.Vector3 = new THREE.Vector3(0, 0, 0);

public constructor(width: number, height: number, altitude: number, seed: string) {
public constructor(width: number, height: number, scaleXZ: number, altitude: number, seed: string) {
this.size = new THREE.Vector3(width, altitude, height);
this.scaleXZ = scaleXZ;

const prng = alea(seed);
this.noise2D = createNoise2D(prng);
Expand Down Expand Up @@ -128,7 +130,7 @@ class VoxelMap implements IVoxelMap, IHeightmap {
x -= this.coordsShift.x;
z -= this.coordsShift.z;

const noise = this.noise2D(x / 50, z / 50);
const noise = this.noise2D(x / this.scaleXZ, z / this.scaleXZ);
const altitude = (0.5 + 0.5 * noise) * this.size.y;

const voxelType = this.altitudeToVoxelType(altitude);
Expand Down

0 comments on commit 536f44c

Please sign in to comment.