Issues with combined yaw and pitch.
1.1 --- a/scripts/machine.js Thu Apr 21 13:12:49 2011 +0200
1.2 +++ b/scripts/machine.js Thu Apr 21 13:59:39 2011 +0200
1.3 @@ -96,21 +96,24 @@
1.4 }
1.5 Camera.prototype.pitch = function(delta)
1.6 {
1.7 -
1.8 + delta *= -this.speed.pitch;
1.9 + vec3.scale(this.target, Math.cos(delta));
1.10 + vec3.scale(this.up, Math.sin(delta));
1.11 + vec3.add(this.target, this.up);
1.12 + vec3.normalize(this.target);
1.13 + vec3.cross(this.target, this.right, this.up);
1.14 + vec3.scale(this.up, -1);
1.15 + vec3.normalize(this.up);
1.16 }
1.17 Camera.prototype.yaw = function(delta)
1.18 {
1.19 - delta *= this.speed.yaw;
1.20 - var right = vec3.create(this.right);
1.21 - vec3.scale(right, Math.cos(delta));
1.22 - var target = vec3.create(this.target);
1.23 - vec3.scale(target, Math.sin(delta));
1.24 - vec3.add(right, target);
1.25 - vec3.normalize(right);
1.26 - this.right = right;
1.27 - vec3.cross(this.right, this.up, target);
1.28 - vec3.scale(target, -1);
1.29 - this.target = target;
1.30 + delta *= -this.speed.yaw;
1.31 + vec3.scale(this.right, Math.cos(delta));
1.32 + vec3.scale(this.target, Math.sin(delta));
1.33 + vec3.add(this.right, this.target);
1.34 + vec3.normalize(this.right);
1.35 + vec3.cross(this.right, this.up, this.target);
1.36 + vec3.scale(this.target, -1);
1.37 vec3.normalize(this.target);
1.38 }
1.39 Camera.prototype.roll = function(delta)
1.40 @@ -200,8 +203,7 @@
1.41 {
1.42 var delta = normaliseWheelDelta(this.wheelDelta);
1.43 var action = this.actionMap["wheel"];
1.44 - if (delta > 0 && action) action(delta);
1.45 - else if (delta < 0 && action) action(delta);
1.46 + if (delta != 0 && action) action(delta);
1.47 this.wheelDelta = 0;
1.48 }
1.49
1.50 @@ -266,25 +268,10 @@
1.51 mat4.perspective(45, viewport.width / viewport.height, 0.1, 100.0, pMatrix);
1.52
1.53 mat4.identity(mvMatrix);
1.54 - mat4.multiply(mvMatrix, camera.matrix);
1.55 - //mat4.multiply(mvMatrix, camera.rotMatrix);
1.56 - //mat4.multiply(mvMatrix, camera.transMatrix);
1.57 - //mat4.rotate(mvMatrix, -camera.pitch, [1, 0, 0]);
1.58 - //mat4.rotate(mvMatrix, -camera.yaw, [0, 1, 0]);
1.59 -
1.60 - //mat4.translate(mvMatrix, [-camera.pos[0], -camera.pos[1], -camera.pos[2]]);
1.61 - //mat4.multiply(mvMatrix, camera.matrix);
1.62 - //mat4.rotate(camera.matrix, -camera.pitch, [1, 0, 0]);
1.63 - //mat4.rotate(camera.matrix, -camera.yaw, [0, 1, 0]);
1.64 - //camera.yaw = camera.pitch = 0;
1.65 -
1.66 + mat4.multiply(mvMatrix, camera.matrix);
1.67
1.68 //this.pushMatrix(mvMatrix);
1.69
1.70 - //mat4.rotate(mvMatrix, scene.rotation.x, [1, 0, 0]);
1.71 - //mat4.rotate(mvMatrix, scene.rotation.y, [0, 1, 0]);
1.72 - //mat4.rotate(mvMatrix, scene.rotation.z, [0, 0, 1]);
1.73 -
1.74 gl.bindBuffer(gl.ARRAY_BUFFER, scene.positionBuffer);
1.75 gl.vertexAttribPointer(shader.vertexPosition, scene.positionBuffer.itemSize, gl.FLOAT, false, 0, 0);
1.76