If you haven’t already played around with the in-browser voxel game demos on voxeljs.com, check them out. I stumbled across them in April and was blown away. Who knew 3D environments could run so well in the browser? Apparently lots of people did, more than two years ago. Oh well, I’m late to the party again. Regardless, working with those tools looked like great fun, so I forked some repos and began building. My end goal is a multiplayer voxel game that I can host on my linode server. My current iteration works pretty well on a local network, but strange things happen when I try to compile and host on my linode server. I’m betting it’s due to module incompatibilities with newer versions of node.js. So I press on.

Let’s see if I can remember and recap what I’ve done:

  • Pulled the voxel-engine dependency out of voxel-server. In my mind, it should be in charge of generating+sending world chunks, relaying block changes, and relaying player positions. That’s about it.
  • Created voxel-generator to unify the interface used to generate chunks. On the client-side, this middle man is in charge of proxying the “I need X chunk” to the server, which then generates (or reads the chunk from disk) and sends it back. This means I no longer use the voxel module for chunk generation. The separation of concerns makes things cleaner.
  • Also relating to the voxel-generator module, I removed the chunk padding logic that’s still present in the voxel module. The comment makes me think it’s unnecessary, and since there’s no indication of whether it necessary for the meshing algorithms, I’ve removed it. This saves 6 additional loop iterations and removes 34^3 - 32^2 = 6536 bytes from the output array. Since V8 garbage collection pauses are already quite disruptive, I figured allocating less memory is a good thing.
  • Created a voxel-coordinates module to handle coordinate calculations. The voxel module was previously handling this, and I wanted to start using chunk lower bound as the chunk ID, so I figured a new module made sense.
  • Save chunk changes to disk, so your world is preserved between voxel-server restarts.
  • Incorporate voxel-select for bulk creation/destruction.
  • Chunks can be requested and received in bulk from the server
  • Since many chunks can arrive at once, the engine now queues “chunksToDraw” and spreads out the draws over time. Didn’t want the game to pause while far-off pieces of the world were being drawn.
  • Added similar queueing for the removal of far off chunks.

In the meantime, here’s a screenshot:

Underground

That’s it for now. Take care, and thanks for reading.