Paint polygons with colored verticies to a canvas. DrawScene is under 200 lines and is written for clarity and hackability. It works well as a library, but it is also a solid foundation for building on. It is based on Learning WebGL lessons, particularly Lesson 2.
Requires gl-matrix.
var shapes = name: "triangle" position: -15 00 -70 verticies: 00 10 00 -10 -10 00 10 -10 00 pointCount: 3 colors: 10 04 06 10 09 04 07 10 08 04 09 10 name: "square" position: 15 00 -70 verticies: 10 10 00 -10 10 00 10 -10 00 -10 -10 00 pointCount: 4 colors: 10 08 02 10 09 07 04 10 08 07 06 10 07 06 08 10
If you want to redraw from a different angle without rebuffering:
var camera = fovy: 45 near: 01 far: 1000 pitch: 00 yaw: 00 xPos: 00 yPos: 04 zPos: 00 drawScene
When you want to buffer new data, just call drawScene again. You can provide a camera then too:
shapes.forEach(...) drawScene(shapes, camera)
Requires you have a single canvas in your document:
Check out demo.html.