Hi,
Yeah... I need to add some simple scene graph capability to the framework. I've been working on many things in the framework, (but not sharing anything yet), probably will work on this in the next few weeks.
I'm not sure on what axis you're trying to rotate the objects, but lets say you have an object 'obj', on (1, 0, 1) and your center of rotation 'c' is (0.5, 0.5, 0.5), and you would like to make a rotation around the Y axis of angle 'alpha', then the rotation could be calculated by:
//take the distance of the object to the center of rotation and its current angle
var pos = obj.position,
dist = Math.sqrt((pos.x - c.x) * (pos.x - c.x) + (pos.y - c.y) * (pos.y - c.y) + (pos.z - c.z) * (pos.z - c.z)),
currentAlpha = Math.atan2(pos.z, pos.x),
//get the final angle the object should be at by adding its current angle and the displacement
endAlpha = alpha + currentAlpha;
//update the object position with this new angle:
pos.x = Math.cos(endAlpha) * dist;
pos.z = Math.cos(endAlpha) * dist;
//update the rotation of the object
obj.rotate.set(0, alpha, 0);
//update coordinates and matrix
obj.update();
I'm not sure the math is fine, but I guess this should be a good start. I'm thinking about adding a Node class and have a tree structure in which multiple objects can be manipulated at the same time, this is something I'll definitely work on.
Let me know if you have any further questions.
--
Nicolas Garcia Belmonte -
http://philogb.github.com/