Demos / WebGL 3D

A cube, spun by your finger.

A vanilla WebGL scene — one vertex shader, one fragment shader, a rotating cube with per-vertex color, drag-to-orbit.

WebGL OK Drag inside the canvas to spin · two-finger drag works too.

What's going on

The cube is 36 vertices (12 triangles, 6 faces × 2 tris). Per-vertex colors are interpolated by the rasterizer. Pointer drags accumulate into Euler angles on the model matrix; the camera stays put.

Safari supports WebGL2 on iPad, but we ask for WebGL1 as a fallback and the shaders are written in GLSL ES 1.00 so they work in both.