First, awesome job on this library, very easy to use.
And second, a question/feature request: I have been playing around with applying an impulse on an object with applyCentralImpulse(). I am applying a positive impulse on the Y axis like rocket.applyCentralImpulse(new THREE.Vector3(0, 1e3, 0)). This is the rocket taking off. But then I rotate my rocket on the Z axis, and I want to apply the same impulse, but now propel my rocket in the direction it is facing (instead of just up on the Y world axis). In other words, I want to propel my rocket on it's own Y axis.
rocket.applyCentralImpulse(new THREE.Vector3(0, 1e3, 0))
I'm new to matrices and physics in general, but I have some idea that I need to take my force vector and somehow convert that into my objects direction vector (maybe the cross product of my direction and force vectors?). It doesn't appear there is a ready-made function to apply an impulse to an object relative to it's own XYZ, but maybe you could point me in the right direction as to how one would accomplish this?
After a lot of messing around and some help from someone who actually knows physics, I found out how to do this--it's pretty simple, actually.
If you have a force, like Vector3(0, 100, 0), you can apply that to an object relative to itself by multiplying it by the object's matrix.
So, if you have a box mesh, box, and your force, var force = THREE.Vector3(0, 100, 0), you do something like this to get the actual force you are going to apply to the box:
var force = THREE.Vector3(0, 100, 0)
var newForce = box.matrix.multiplyVector3(force);
This will apply the force in the Y direction of the object instead of the Y direction of the scene.
You beat me by an hour :) I'm glad the solution I was thinking of is what worked for you, haha.
Enjoy the library!
Actually, the way I did this turned out to cause me a lot of head-scratching issues (like velocities getting out of control). For an explanation of how I got this working, see this comment on a related issue.
In short, you have to extract the rotation matrix of the object and multiply the force vector by that, then apply the resulting vector back to your object.