draw = regl({
frag: `
precision mediump float;
varying vec3 vColor;
void main() {
gl_FragColor = vec4(vColor, 1.0);
}`,
vert: `
precision mediump float;
attribute vec2 position;
// instanced attributes
attribute vec3 color;
attribute vec2 offset;
attribute float angle;
varying vec3 vColor;
void main() {
gl_Position = vec4(cos(angle) * position.x + sin(angle) * position.y + offset.x,
-sin(angle) * position.x + cos(angle) * position.y + offset.y, 0, 1);
vColor = color;
}`,
attributes: {
position: [
[0.0, -0.05],
[-0.05, 0.0],
[0.05, 0.05]
],
offset: {
buffer: regl.buffer(offsetArray),
divisor: 1
},
color: {
buffer: regl.buffer(colorArray),
divisor: 1
},
angle: {
buffer: angleBuffer,
divisor: 1
}
},
depth: {
enable: false
},
count: 3,
instances: N * N
})