Skip to content

Commit

Permalink
Added demo
Browse files Browse the repository at this point in the history
  • Loading branch information
NoMoreDeps committed Feb 10, 2021
1 parent dd843f7 commit 53d44ca
Show file tree
Hide file tree
Showing 6 changed files with 766 additions and 22 deletions.
738 changes: 738 additions & 0 deletions docs/js/_game.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/js/game.js

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions src/Geometry/Terrain/Block/Types/Block.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
export type Block = {
name : string;
guid : string;
uid : number;
name : string; // Block name
guid : string; // Unique global Id
uid : number; // Unique local id
sidesTex : [
string,// BACK
string,// FRONT
string,// RIGHT
string,// LEFT
string,// TOP
string // BOTTOM
string, // BACK
string, // FRONT
string, // RIGHT
string, // LEFT
string, // TOP
string // BOTTOM
];
size: [
number, // WIDTH
Expand Down
8 changes: 4 additions & 4 deletions src/Geometry/Terrain/Chunk/ChunkBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ export class ChunkBuilder {

static create(size: number = 32) : Chunk {
const chunk = {
data : [] ,
data: [],
dataSize: 0,
rcData : [] ,
rcData: [],
rcDataSize: 0,
size : size
} as Chunk;
size: size
} as unknown as Chunk;

return chunk;
}
Expand Down
14 changes: 7 additions & 7 deletions src/Geometry/Terrain/Chunk/Types/Chunk.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Vector3 } from "../../../../Core/Types/Geometry/Vector3";

export type Chunk = {
position : Vector3 ;
size : number ;
data : Array<number> ;
dataSize : number ;
rcData : Array<number> ;
rcDataSize : number ;
hasRc : boolean ;
position : Vector3 ; // 3D position in the world
size : number ; // Size of the chunk, default will be 32
data : Array<number> ; // The original data
dataSize : number ; // The number of non empty blocks
rcData : Array<number> ; // An optimized version of visible only visible data
rcDataSize : number ; // The number of visible blocks
hasRc : boolean ; // Define if a chunk has been optimized or not
};
8 changes: 7 additions & 1 deletion src/Plugin/Geometry/Simplex/Chunk/ChunkBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class ChunkBuilder {
inflateSimplexNoiseMapToChunk(position: Vector3) {
const size = this._chunkSize;
const chunk = ChunkBuilder.create(size);
const {x, y, z} = {...position};
/*const {x, y, z} = {...position};
forX(x * size, x * size + size, (_x) => {
forX(z * size, z * size + size, (_z) => {
Expand All @@ -90,6 +90,12 @@ export class ChunkBuilder {
chunk.dataSize ++;
})
});
});*/
forX(0, 32, x => {
forX(0, 32, z => {
chunk.data[vector3ToArrayIndex(x , 1, z, size)] = 1;
chunk.dataSize ++;
});
});

return chunk;
Expand Down

0 comments on commit 53d44ca

Please sign in to comment.