fix camera bug, no more camera bugs
This commit is contained in:
parent
49c8eaa468
commit
cd5559fd41
|
@ -6,12 +6,22 @@ import mat4 from 'gl-mat4';
|
|||
* @param {any} context the program context
|
||||
*/
|
||||
export function updateCamera(context: any) {
|
||||
const xAxis = mat4.create();
|
||||
mat4.rotateY(xAxis, xAxis, context.params.camRot.y);
|
||||
const xMat = mat4.create();
|
||||
mat4.rotateY(xMat, xMat, context.params.camRot.y);
|
||||
mat4.rotateX(xMat, xMat, context.params.camRot.x);
|
||||
mat4.rotate(xMat, xMat, context.params.camRot.x, [
|
||||
xAxis[0],
|
||||
xAxis[4],
|
||||
xAxis[8],
|
||||
]);
|
||||
const zMat = mat4.create();
|
||||
mat4.rotateY(zMat, zMat, context.params.camRot.y);
|
||||
mat4.rotateX(zMat, zMat, context.params.camRot.x);
|
||||
mat4.rotate(zMat, zMat, context.params.camRot.x, [
|
||||
xAxis[0],
|
||||
xAxis[4],
|
||||
xAxis[8],
|
||||
]);
|
||||
if (context.params.keyboard.a) {
|
||||
context.params.camPos.x += xMat[0];
|
||||
context.params.camPos.y += xMat[4];
|
||||
|
|
Loading…
Reference in New Issue