I found the reference code from github and other questions about object rotation on stackoverflow.
var vector = new THREE.Vector3( 1, 0, 0 );
var axis = new THREE.Vector3( 1, 0, 0 ).normalize();
var angle = Math.PI / 2;
function rotateAroundWorldAxis(object, axis, angle) {
var matrix = new THREE.Matrix4().makeRotationAxis( axis, angle );
matrix.multiplyVector3( vector );
object.matrix = matrix;
object.rotation.setEulerFromRotationMatrix(object.matrix);
}
function render() {
rotateAroundWorldAxis(tubeMesh, axis, angle);
renderer.render( scene, camera );
}
I can't figure out what could be the reason of the error "Uncaught TypeError: Cannot read property 'x' of undefined." In google chrome it shows as
- Uncaught TypeError: Cannot read property 'x' of undefined at three.min.js:56
- THREE.Matrix4.makeRotationAxis at three.min.js:56
- rotateAroundWorldAxis at my_model.htm:290
- render at my_model.htm:297
- animate
The error is in three.min.js at line no. 56.
I am using r51 of three.js library.