Worked on vertical Camera movement
This commit is contained in:
parent
2b735340ca
commit
2200b54b21
@ -130,22 +130,28 @@ function mouseMoveEvent(e) {
|
||||
//changeVertical = 0.01;
|
||||
|
||||
horizontalVal = (horizontalVal + changeHorizontal) % 360;
|
||||
verticalVal = (verticalVal + changeHorizontal) % 360;
|
||||
|
||||
verticalVal = verticalVal + changeVertical;
|
||||
if (verticalVal > 1) {
|
||||
verticalVal = 1;
|
||||
} else if (verticalVal < -1) {
|
||||
verticalVal = -1;
|
||||
}
|
||||
|
||||
|
||||
let sinX = (Math.round(((Math.sin(horizontalVal))*100)))/100;
|
||||
let cosY = (Math.round(((Math.cos(verticalVal))*100)))/100;
|
||||
let negCosZ = -(Math.round(((Math.cos(horizontalVal))*100)))/100;
|
||||
|
||||
target[0] = sinX*distanceEyeTarget;
|
||||
target[1] = target[1] + changeVertical*distanceEyeTarget;
|
||||
target[2] = negCosZ*distanceEyeTarget;
|
||||
target[0] = sinX * cosY * 10;
|
||||
target[1] = verticalVal * 10;
|
||||
target[2] = negCosZ * cosY * 10;
|
||||
|
||||
//set the viewMatrix
|
||||
const viewLoc = gl.getUniformLocation(program, "viewMatrix");
|
||||
mat4.lookAt(viewMatrix, eye, target, up);
|
||||
gl.uniformMatrix4fv(viewLoc, false, viewMatrix);
|
||||
}
|
||||
|
||||
//console.log(changeX);
|
||||
}
|
||||
|
||||
function changeView(e)
|
||||
|
Loading…
Reference in New Issue
Block a user