WebGL-沿对象行进的方向旋转对象 [英] WebGL - Rotating object in the direction it is travelling
本文介绍了WebGL-沿对象行进的方向旋转对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在此示例中: http://deeplogic.info/project/webGL/
如何沿对象行进的方向旋转对象?
How can I rotate the object in the direction in which it is travelling?
推荐答案
To get rotation around z for an object moving in the direction (x, y) you can use the Math.atan2(y,x)
method. It'll return an angle in radians. The OpenGL convention prior to ES 2 was to work in degrees, but nowadays it's up to whatever code you have to push transformations to the vertex shader. You'll probably want to convert though, in which case just multiply the result by 180 (half a circle in degrees) and divide by pi (half a circle in radians).
这篇关于WebGL-沿对象行进的方向旋转对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文