
Show HN: Basic voxel engine in WebGL/JavaScript with full source - nergal
https://github.com/Lallassu/vox2
======
z3t4
This is built using Three.js ... I've seen tons of cool Three.js demons, even
tried doing some stuff myself, but not that many actual games. It seems webGL
is too bleeding edge. Maybe when the WebGL spec. is final and implemented in
the major browsers I'll give it a try. But for now I use Canvas for the
graphics. Canvas is much higher level and hardware accelerated, plus easier to
use then WebGL. Low level graphics and JS don't fit well together.

I'll love to see a good voxel engine in JS! I think you will be too limited by
Three.JS though.

~~~
arcatek
I made a voxel engine without using Three.js a few years ago[1] (well, the
engine is rendering-agnostic, so I actually used Three.js, but only the really
basic primitives, such as BufferGeometry).

The issue wasn't so much WebGL performances (especially since WebGL is
actually hardware accelerated), but rather the CPU cost required to rasterize
a real-time voxel world into a polygonal geometry. I wasn't able to generate
geometry chunks fast enough to match the player speed (so the player was
always able to catch up with the rendering). Even using workers wasn't
improving the perfs so much (but I think could have improved that by changing
the update heuristic a bit).

But it was pretty fun nevertheless! I'm proud to be one of the few JS voxel
engine using marching cubes, which look much better than usual cubes :)

[1] [http://arcanis.github.io/voxplode/](http://arcanis.github.io/voxplode/)
(may take a while to load, may be a bit buggy, especially if you move before
the chunk underneath has been loaded)

------
AustinG08
Thanks for sharing. Stuff like this instantly rekindles my desire to create
games. It's like being a kid again, the tiny visible portion sparks my
imagination as to what could lay beyond...

~~~
greggman
If you haven't seen Voxatron you might like it. It's a virtual fantasy voxel
console you can make "cartridges" for. Here's some of the user made carts

[http://www.lexaloffle.com/bbs/?cat=6&mode=cposts&orderby=ts&...](http://www.lexaloffle.com/bbs/?cat=6&mode=cposts&orderby=ts&orderby=rating)

~~~
AustinG08
and there goes my weekend, this is so freaking sweet

~~~
nergal
I made a little voxel game earlier. Faar from as good as voxatron but it was
just a learning game. Http://voxlords.webgl.nu

~~~
AustinG08
Dang dude this is super impressive. How did you get started learning how to
create games like this?

~~~
nergal
Working as a programmer but like game programming on my spare time. But I'm
still a novice game developer. But it's fun :)

------
trumpete
I am getting periodic drops in FPS, is it rebuilding chunks or what?

~~~
adrusi
Sounds like GC pauses. Next to unavoidable in javascript unfortunately.

~~~
agentultra
Might also be scheduler delays in the browser[0]. I've seen more hardcore
demos than this run pause-less.

[0][https://developer.mozilla.org/en-
US/docs/Web/API/window/requ...](https://developer.mozilla.org/en-
US/docs/Web/API/window/requestAnimationFrame?redirectlocale=en-
US&redirectslug=DOM%2Fwindow.requestAnimationFrame)

