ThreeJS - 通过 applyMatrix4 变换不保留特征向量的方向

ThreeJS - Transform by applyMatrix4 doesn't preserve eigen vector's direction

我使用 Object3D.applyMatrix4 变换了一个位于变换矩阵特征值 space 上的向量。本以为它不会移动,因为特征值为1,或者至少保持在特征跨度上,但它移动到一个意想不到的地方。

我做了一个示例项目:stackblitz

但下面可能是您需要检查的所有代码

let pointGeo = new THREE.Geometry()
pointGeo.vertices = [new THREE.Vector3(1,-1,1)]
let pmat = new THREE.PointsMaterial({color: 0x00f0f0, size: 0.3})
let pointObj = new THREE.Points(pointGeo, pmat)
let matrix = new THREE.Matrix4()
matrix.set( 1,  3,  3, 0,
           -3, -5, -3, 0,
            3,  3,  1, 0,
            0,  0,  0, 1)
pointObj.applyMatrix4(matrix)

具体来说,我正在用矩阵变换点 (1, -1, 1)(紫色方块所在的位置)。乘以矩阵不应改变值。 (通过手工计算仔细检查)但它移动到蓝色方块所在的位置。

是否有应用其他转换的其他阶段?我在这里错过了什么?

这里是 applyMatrix4 的源代码...您是否完全像这样手动应用您的矩阵:


        applyMatrix4 ( m ) {

            var x = this.x, y = this.y, z = this.z;
            var e = m.elements;

            var w = 1 / ( e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] );

            this.x = ( e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] ) * w;
            this.y = ( e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] ) * w;
            this.z = ( e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] ) * w;

            return this;

        },
    ```

我发现 Object3D.applyMatrix4 不是显式定义局部矩阵的正确函数。我尝试直接设置 Object3D.matrix 属性 并且有效。我这样更改了代码:

o.matrix = mat
o.matrixAutoUpdate = false
o.updateMatrixWorld(true)