Three.js line vector to cylinder?

后端 未结 9 1833
粉色の甜心
粉色の甜心 2020-12-14 23:53

I have this to create a line between 2 points:

var geometry = new THREE.Geometry();
geometry.vertices.push(new THREE.Vector3(0, 0, 0));
geometry.vertices.pus         


        
9条回答
  •  抹茶落季
    2020-12-15 00:15

    For rotating the orientation, you can use

    edge.rotateX(Math.PI / 2);
    

    Or

    edge.rotateY(Math.PI / 2);
    

    Or

    edge.rotateZ(Math.PI / 2);
    

    As per the coordinates you wish to rotate. Hence, the code posted above with:

    var orientation = new THREE.Matrix4();
    /* THREE.Object3D().up (=Y) default orientation for all objects */
    orientation.lookAt(pointX, pointY, new THREE.Object3D().up);
    /* rotation around axis X by -90 degrees 
     * matches the default orientation Y 
     * with the orientation of looking Z */
    orientation.multiply(new THREE.Matrix4(1,0,0,0,
                                           0,0,1,0, 
                                           0,-1,0,0,
                                           0,0,0,1));
    

    Will not be required.

提交回复
热议问题