drawBunny = regl({
vert: `
precision mediump float;
attribute vec3 position;
uniform mat4 model, view, projection;
void main() {
gl_Position = projection * view * model * vec4(position, 1);
}`,
frag: `
precision mediump float;
void main() {
gl_FragColor = vec4(1, 1, 1, 1);
}`,
attributes: {
position: bunny.positions
},
elements: bunny.cells,
uniforms: {
model: mat4.identity([]),
view: ({ tick }) => {
const t = 0.01 * tick;
return mat4.lookAt(
[],
[30 * Math.cos(t), 2.5, 30 * Math.sin(t)],
[0, 2.5, 0],
[0, 1, 0]
);
},
projection: ({ viewportWidth, viewportHeight }) =>
mat4.perspective(
[],
Math.PI / 4,
viewportWidth / viewportHeight,
0.01,
1000
)
}
})