天天看点

three.js绕边缘旋转

dummy = new THREE.Object3D();

       plane = new THREE.Mesh(new THREE.PlaneGeometry(,),new THREE.MeshBasicMaterial({color:}));

          plane.position.set(,,);

         dummy.add(plane);

         dummy.position.set(,,);

         scene.add(dummy);
           
由于three.js 模型默认旋转是以坐标轴 x, y z来旋转的,所以我们通过plane.rotation.x/y/z的方法只能绕其mesh的中心轴旋转,而无法绕边缘。 在这里plane为dummy的一个child,我们在旋转dummy的时候,plane也可以旋转。dummy也是绕中心旋转,我们只要设定好plane的坐标就好了。

     在这个例子中,将Plane的左边缘的x的坐标设置为dummy的x的坐标的中心。谨记:plane坐标是相对于其parent坐标来设的,当设plane坐标时,将dummy的中心坐标看成是0,0,0而不是dummy在世界坐标系中的坐标。
           

继续阅读