Skip to content

Instantly share code, notes, and snippets.

@rezoner
Created March 13, 2019 09:54
Show Gist options
  • Save rezoner/16cb65965c3f17fcb1e9d233e3a18164 to your computer and use it in GitHub Desktop.
Save rezoner/16cb65965c3f17fcb1e9d233e3a18164 to your computer and use it in GitHub Desktop.
PIXEL3D work in progress example
/* Code to draw a cube */
function render() {
this.camera.rotation.z += this.elapsed;
for (var x = 0; x < 64; x++) {
for (var y = 0; y < 64; y++) {
for (var z = 0; z < 64; z++) {
this.color = 0xff0000 * x / 128;
this.drawPixel(x, y, z);
}
}
}
}
/* Code to draw thousands of cubes */
function create() {
this.beginModel();
for (var x = 0; x < 64; x++) {
for (var y = 0; y < 64; y++) {
for (var z = 0; z < 64; z++) {
this.color = 0xff0000 * x / 128;
this.drawPixel(x, y, z);
}
}
}
this.model = this.endModel();
}
function render() {
this.camera.rotation.z += this.elapsed;
for(let i =0; i < 1000; i++) {
this.renderModel(this.model, x, y, z);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment