///////////////////////////////////////////////////////////////////////// // cylinder ///////////////////////////////////////////////////////////////////////// cylinderGeometry = new THREE.CylinderGeometry( 0.30, 0.30, 0.80, 20, 4 ); cylinder = new THREE.Mesh( cylinderGeometry, diffuseMaterial); scene.add( cylinder ); // cylinder.matrix transforms the cylinder relative to its parent // By default, the parent is the world coordinate system ///////// Below are 3 different ways to position the cylinder wrt its parent ///////// Of course, you should only want to use one of these, i.e., comment out the other two. //////// (1) directly setting M_model cylinder.matrixAutoUpdate = false; cylinder.matrix.set( 0.7,-0.7,0,2, 0.7,0.7,0,0, 0,0,1,0, 0,0,0,1); //////// (2) using a typical graphics API setup, i.e., right multiplying, therefore local coordinates cylinder.matrixAutoUpdate = false; cylinder.matrix.identity(); var tempMatrix = new THREE.Matrix4; tempMatrix.makeTranslation(3,1,0); // build translation matrix cylinder.matrix.multiply(tempMatrix); // right multiply tempMatrix.makeRotationZ(Math.PI/4); // build rotation matrix cylinder.matrix.multiply(tempMatrix); // right multiply //////// (3) default threejs setup // upon rendering, the transformation is defined by the following sequence (right multiplied, i.e., local coords) // Translate( cylinder.position ); // RotateX ( cylinder.rotate.x ); // RotateY ( cylinder.rotate.y ); // RotateZ ( cylinder.rotate.z ); cylinder.matrixAutoUpdate = true; cylinder.position.set(2, 0, 0); cylinder.rotation.set(0,0,Math.PI/4); // Euler angle sequence of rotations: X,Y,Z