3
我用这对我的相机相机旋转鼠标停留在原点
library.Camera = function Camera(PosX, PosY, PosZ, Pitch, Yaw){
this.x = PosX;
this.y = PosY;
this.z = PosZ;
this.pitch = Pitch;
this.yaw = Yaw;
this.getCameraMatrix = function(ModelMatrix){
var TMatrix = ModelMatrix;
mat4.translate(TMatrix, TMatrix, [this.x, this.y, this.z]);
mat4.rotateX(TMatrix, TMatrix, degToRad(this.pitch));
mat4.rotateY(TMatrix, TMatrix, degToRad(this.yaw));
return TMatrix;
};
};
搬家正常工作,甚至旋转的作品一点。问题在于,鼠标的旋转始终围绕原点旋转。所以如果我向左移动(-x)并开始旋转,相机仍围绕原点旋转,而不是围绕当前点。
http://glmatrix.net/docs/2.2.0/symbols/mat4.html
[在固定点OpenGL上旋转]的可能重复(http://stackoverflow.com/questions/8360107/rotating-on-a-fixed-point-opengl) –