three.js: from plane-orthogonal vector to plane rotation matrix

后端 未结 2 942
终归单人心
终归单人心 2021-01-06 03:37

I want to set the rotation of a plane. This requires three numbers denoting the rotation in radians in the x, y and z axes.

I don\'t have these numbers, but, I have

2条回答
  •  無奈伤痛
    2021-01-06 04:05

    In three.js r50, the default plane is located at the origin and it's normal points in the positive-z direction. So it is the vector ( 0, 0, 1 ) that you want to transform to myVec. But you don't have to do that directly.

    The easiest way to do what you want in three.js is like so.

    var v = myPlane.position.clone();
    v.add( myVec );
    myPlane.lookAt( v );
    

    Let three.js do the math for you. :-)

    EDIT: Updated to three.js r.66

提交回复
热议问题