3 ms·
I'm not a fan of using libraries for simple examples either, but WebGL just requires tons of boilerplate even for the simplest stuff. If you just want to show
by phoboslab 11y ago
I'm not a fan of using libraries for simple examples either, but WebGL just requires tons of boilerplate even for the simplest stuff.
If you just want to show a pixel shader, you probably don't need any library. Still, creating textures, setting up the buffer for your single quad, compiling pixel and vertex shaders and the shaders themselves will easily pile up to a good 100 lines of code.
Now, if you want to do anything with real 3d objects, such as in this example, you need code to:
- generate or load the models
- set up your camera
- trace clicks on the canvas to the objects (not a simple feat in 3d space)
- implement this mover widget/drag+drop of objects
- implement some sort of lighting
- implement some sort of shadow rendering, so it's easier to estimate
the position of the objects
- (for all of the above) implement a library for
vector and matrix math
You'll easily end up with a thousand lines of code there, and you haven't done anything yet to solve the actual problem this article discusses.