三个.js中的makeBasis和extractBasis之间的区别

时间:2015-11-18 12:04:32

标签: three.js

来自three.js doc:

.makeBasis ( xAxis, zAxis, zAxis ) this

Creates the basis matrix consisting of the three provided axis vectors. Returns the current matrix.
# .extractBasis ( xAxis, zAxis, zAxis ) this

Extracts basis of into the three axis vectors provided. Returns the current matrix.

这两种方法有什么区别?

makeBasis看起来有点奇怪。创建基础矩阵,然后返回当前矩阵?没有任何意义。

1 个答案:

答案 0 :(得分:2)

通过查看Matrix4.js的源代码,可以清楚地回答您的问题。

extractBasis: function ( xAxis, yAxis, zAxis ) {

    var te = this.elements;

    xAxis.set( te[ 0 ], te[ 1 ], te[ 2 ] );
    yAxis.set( te[ 4 ], te[ 5 ], te[ 6 ] );
    zAxis.set( te[ 8 ], te[ 9 ], te[ 10 ] );

    return this;

},

makeBasis: function ( xAxis, yAxis, zAxis ) {

    this.set(
        xAxis.x, yAxis.x, zAxis.x, 0,
        xAxis.y, yAxis.y, zAxis.y, 0,
        xAxis.z, yAxis.z, zAxis.z, 0,
        0,       0,       0,       1
    );

    return this;

},

three.js r.73