title: How can I rotate around a scene in webgl on mousedrag (emulating a camera moving around a position)
body: <p>Okay,
  So I have been reading for the past few hours and I have managed to get the mouse drag to work on the x axis using the following matrix computation, but no luck with the y axis:
  where 
  newX = new mouse X coord
  previousX = mouse X coord at last update
  position = camera position
  mvMatrix = model view matrix or 'world matrix'</p>
  
  <pre><code>angle = 0.01*(newX-previousX);
  rM = mat4.create();
  mat4.identity(rM);
  
  rM[0] = Math.cos(angle);
  rM[2] = Math.sin(angle);
  rM[8] = -Math.sin(angle);
  rM[10] = Math.cos(angle);
  
  mat4.multiplyVec3(
      rM,
      position,
      position
  )
  </code></pre>
  
  <p>*Note this uses the glMatrix Library (http://code.google.com/p/glmatrix/)</p>
  
  <p>And also in order to always face the position 0,0,0</p>
  
  <pre><code>mat4.lookAt(
      position,
      vec3.create([0, 0, 0]),
      vec3.create([position[0], position[1]+1, position[2]]),
      mvMatrix
  );
  </code></pre>
  
  <p>I got the matrix from <a href="http://en.wikipedia.org/wiki/Rotation_matrix" rel="nofollow">http://en.wikipedia.org/wiki/Rotation_matrix</a>
  I have used the matrix under 'basic rotations' and Ry</p>
  
  <p>I am sure this has been done before, any help would be apreciated.</p>
  
  <p>Cheers, Josh</p>