I'm using Three.JS to render some objects. I'm struggling with some very simple object rendering and translation.
The scenario is that I spawn an object at 0,0,0 in world space with 0,0,0 rotation.
var scene, camera, cube;
...
function change() {
var degrees = 90
var zTranslation = 5;
cube.rotation.y = degrees * Math.PI / 180;
cube.rotation.z = zTranslation;
var newCubeMatrix = cube.matrix;
newCubeMatrix.identity();
newCubeMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(cube.rotation.y));
newCubeMatrix.multiplySelf(THREE.Matrix4.translationMatrix(cube.position.x, cube.position.y, cube.position.z));
cube.updateMatrix();
}
function loop() {
renderer.render( scene, camera );
}
...
What now happens is that the cube is rotation 90 degrees and translated 5 points on the Z axis in world space, not 5 points on the Z axis in the cube's local space.
How do I make the cube translate 5 points in it's local space?
