# HG changeset patch # User Eugen Sawin # Date 1303133447 -7200 # Node ID 92eb274bc56489a240b92c66ed24a22f24d1e689 # Parent 8b187fa957adc5394edf4374b07e2655e4e3b8ff Still bugged camera. diff -r 8b187fa957ad -r 92eb274bc564 scripts/machine.js --- a/scripts/machine.js Sun Apr 17 14:44:11 2011 +0200 +++ b/scripts/machine.js Mon Apr 18 15:30:47 2011 +0200 @@ -72,11 +72,15 @@ } Camera.prototype.moveLeft = function() { - this.x -= this.speed.x; + var d = 1 - Math.sin(this.yaw); + this.x -= d * this.speed.x; + this.z += (1 - d) * this.speed.z; } Camera.prototype.moveRight = function() { - this.x += this.speed.x; + var d = 1 - Math.sin(this.yaw); + this.x += d * this.speed.x; + this.z -= (1 - d) * this.speed.z; } Camera.prototype.moveUp = function() { @@ -88,8 +92,9 @@ } Camera.prototype.zoom = function(delta) { - this.x += this.speed.x * delta * Math.sin(this.yaw); - this.z += this.speed.z * delta * Math.cos(this.yaw); + this.x -= Math.sin(this.yaw) * this.speed.x * delta; + this.y -= Math.sin(this.pitch) * this.speed.y * delta; + this.z -= Math.cos(this.yaw) * Math.cos(this.pitch) * this.speed.z * delta; } Camera.prototype.changePitch = function(delta) { @@ -249,7 +254,7 @@ gl.viewport(0, 0, viewport.width, viewport.height); gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); - mat4.perspective(55, viewport.width / viewport.height, 0.1, 100.0, pMatrix); + mat4.perspective(45, viewport.width / viewport.height, 0.1, 100.0, pMatrix); mat4.identity(mvMatrix); //mat4.multiply(mvMatrix, camera.rotMatrix);