How can I rotate a mesh by 90 degrees in ThreeJS?
The threejs rotation uses Radians (as you might know)
you can use this
mesh.rotation.x = Math.PI / 2;
or
mesh.rotation.set(new THREE.Vector3( 0, 0, Math.PI / 2));
You can rotate an object by using this function:
function rotateObject(object, degreeX=0, degreeY=0, degreeZ=0) { object.rotateX(THREE.Math.degToRad(degreeX)); object.rotateY(THREE.Math.degToRad(degreeY)); object.rotateZ(THREE.Math.degToRad(degreeZ));}// usage:rotateObject(myPlane, 40, 30, 20);
Let's say meshToRotate
needs to be rotated by 90 degrees in X axis. Then do the following.
var meshToRotate = new THREE.Mesh( geometry, material );//Rotating mesh by 90 degree in X axis. meshToRotate.rotateX( Math.PI / 2 );