I'm trying to get a 'chase' camera working on an object.
I've found an example that doe exactly what I want, however it is aimed at r49:
http://stemkoski.github.com/Three.js/Chase-Camera.html
I've attempted to update it to the new rotation methods as follows:
var rotation_matrix = new THREE.Matrix4().makeRotationZ(rotateAngle);
cube.matrix.multiplySelf(rotation_matrix);
cube.rotation.setEulerFromRotationMatrix(cube.matrix);
This seems to work fine for the object, however the camera doesn't follow in the same way. I've put up a demo here:
http://jsfiddle.net/SSEDs/
(Press A and D to rotate)
What am I doing wrong?
You need to add the camera as a child of the cube. Not only does it work, but the math is a lot simpler.
cube.add( camera );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With