-
-
Save z3t0/21f224b05922e6bbc348d3a215dc5bc1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var ndarray = require('ndarray') | |
| var block = require('./block.js') | |
| module.exports = function() { | |
| return new Chunk() | |
| } | |
| function Chunk() { | |
| this.size = 16 | |
| this.dims = [this.size, this.size, this.size] | |
| this.data = ndarray(new Array(this.dims[0] * this.dims[1] * this.dims[2]), this.dims) | |
| this.mesh = null | |
| // TODO: Add position | |
| // Set all blocks | |
| for (x = 0; x < this.size; x++) { | |
| for (y = 0; y < this.size; y++){ | |
| for (z = 0; z < this.size; z++){ | |
| this.data.set(x,y,z, new block(x, y, z, 1)) | |
| } | |
| } | |
| } | |
| } | |
| Chunk.prototype.CreateMesh = function(chunk) { | |
| var mesh = [] | |
| for (x = 0; x < this.size; x++) { | |
| for (y = 0; y < this.size; y++){ | |
| for (z = 0; z < this.size; z++){ | |
| var mesh = mesh.concat(this.data.get(x, y, z).CreateMesh()) | |
| } | |
| } | |
| } | |
| this.mesh = mesh | |
| debugger; | |
| } | |
| Chunk.prototype.GetBlock = function(x, y, z) { | |
| return this.data.get(x,y,z) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment