Show HN: Basic voxel engine in WebGL/JavaScript with full source
github.com
github.com
I'll love to see a good voxel engine in JS! I think you will be too limited by Three.JS though.
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/ (may take a while to load, may be a bit buggy, especially if you move before the chunk underneath has been loaded)
On that note, the beginnings of OpenGL ES 3.0 based WebGL 2 landed in Firefox recently¹ and can be tested by flipping a pref in about:config². You can verify if it works by visiting WebGL Report³.
1: https://blog.mozilla.org/futurereleases/2015/03/03/an-early-...
Three.js is a JS library, one of its render targets is WebGL. Three.js is more a scene graph layer and graphics/game engine.
Where as WebGL is bare metal. And I wish more people would consider using WebGL directly for their demos, tutorials and products.
It's like every top answer on a JavaScript questions on Stackoverflow was answered with a JQuery code snip back in 2013. Fast forward to 2015, the landscape changed completely and the SO community upvoted vanilla JS answers.
Some may remember the Voxel.js project that had gained traction fast. The main developer wrote a long blog post about the development: https://medium.com/@deathcap1/six-months-of-voxel-js-494be64... .
Quotes from that article: Unfortunately the greedy meshing + texture atlases demonstration was not compatible with the three.js library used by voxel-engine, so I forked it. [...] I updated to three.js version r66, from the previous r58 series. Slightly non-trivial since there were a few major changes, though they provide a migration guide to help updating. The most noticeable was the removal of Face4 (quads, removed in r60), so you need to use two Face3 (triangles) in its place. [...] That and realizing having three.js part of voxel-engine is the reason most voxel plugins have a horrible peer dependency to the game instance.
http://www.lexaloffle.com/bbs/?cat=6&mode=cposts&orderby=ts&...
[0]https://developer.mozilla.org/en-US/docs/Web/API/window/requ...