animate position
This commit is contained in:
parent
e749bfee47
commit
4ad7e2e3d0
|
@ -160,6 +160,9 @@ async function draw() {
|
|||
let colorLocation = gl.getUniformLocation(program, "color");
|
||||
gl.uniform3f(colorLocation, ...hslToRgb(hue, 1, 0.5));
|
||||
|
||||
let positionLocation = gl.getUniformLocation(program, "position");
|
||||
gl.uniform2f(positionLocation, Math.cos(hue * 2 * Math.PI) * 0.2, Math.sin(hue * 2 * Math.PI) * 0.2);
|
||||
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer);
|
||||
|
||||
gl.drawArrays(gl.TRIANGLES, 0, vertices.length / 2);
|
||||
|
|
|
@ -2,9 +2,10 @@ precision mediump float;
|
|||
|
||||
attribute vec2 vertPosition;
|
||||
uniform vec3 color;
|
||||
uniform vec2 position;
|
||||
varying vec3 fragColor;
|
||||
|
||||
void main() {
|
||||
fragColor = color;
|
||||
gl_Position = vec4(vertPosition, 0.0, 1.0);
|
||||
gl_Position = vec4(position + vertPosition, 0.0, 1.0);
|
||||
}
|
Loading…
Reference in New Issue