// From kennebec at http://stackoverflow.com/a/3955096/142317 // Add a remove value function to the Array class. Array.prototype.remove = function() { var what, a = arguments, L = a.length, ax; while (L && this.length) { what = a[--L]; while ((ax = this.indexOf(what)) !== -1) { this.splice(ax, 1); } } return this; }; // Sort blocks in the order that they should be drawn for the given camera. IsoBlock.sortBlocks = function(blocks, camera) { var i, j, numBlocks=blocks.length; // Initialize the list of blocks that each block is behind. for (i=0; i 0) { // Draw block by removing one from "to draw" and adding // it to the end of our "drawn" list. var block = blocksToDraw.pop(); blocksDrawn.push(block); // Tell blocks in front of the one we just drew // that they can stop waiting on it. for (j=0; j