WebGl 二维平移

本文基于上一篇- 《WebGl 旋转及缩放》 的示例代码修改

添加变量,做简单的相加即可实现平移

index.vs

1
2
3
4
5
6
uniform vec2 u_translation;

main () {
// ...
scaledPosition = scaledPosition + u_translation;
}

index.jw

1
2
3
4
5
const scaledPosition = scaledPosition + u_translation;

// ...

gl.uniform2fv(u_translation, translation);
#

Comments

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×