Trying to get some solar system action going (not really, but similar mechanics) with three.js. I have code that kinda works but seems far from elegant. Also, the whole adding and subtracting the position business is off.
What would be the proper way to do this? I don’t think I can use a dummy object (see #1593) in this program because the center point may change during runtime.
The crucial pieces are:
mat1 = new THREE.Matrix4(); axis = new THREE.Vector3(); axis.sub(two.position, one.position); axis.crossSelf(new THREE.Vector3(1,0,0)); axis.normalize(); mat1.makeRotationAxis(axis, 0.005);
and in animate():
two.applyMatrix(mat1); two.position.addSelf(one.position); two.updateMatrix(); renderer.render( scene, camera ); two.position.subSelf(one.position); two.updateMatrix();
Pardon my ignorance, I’m new to 3d.