0

So, I've been having problems with xtk's

var rotate = m.rotate($ANGLE, $IAXIS);

function for quite some time now. Basically, what I would like to do is rotate a single object in space around a certain axis without moving other objects or the camera. My idea is to do that by applying the rotate function on X.matrix which would contain object's transform.matrix.

The problem is, I can't get the X.matrix.rotate to work AT ALL. Can anyone maybe give me at least some example how the function call should look like, and how to define $IAXIS because I suspect that might be the problem.

Many thanks!

Marija
  • 11

2 Answers2

0

Ah, the axis currently should be a goog.math.Vec3 like here in camera3d.js

  var yAxisVector = new goog.math.Vec3(parseFloat(this._view.getValueAt(1, 0)),
      parseFloat(this._view.getValueAt(1, 1)), parseFloat(this._view
          .getValueAt(1, 2)));

  // we rotate around the Y Axis when the mouse moves along the screen in X
  // direction
  var rotateX = identity.rotate(angleX, yAxisVector);

Since goog.math.Vec3 is minimized during compilation, we now also enable passing the axis as an array [x,y,z].

But to transform an object, it is easier to use

var o = new X.object();
o.transform.rotateX(10);
o.transform.rotateY(10);
o.transform.rotateZ(10);
haehn
  • 967
  • 1
  • 6
  • 19
0

Just an update on this one: Since Google kindly introduced some major changes to their closure library I have found the quaternion notation most suitable for solving this problem. Thanks to everyone for their comments!

Marija
  • 11