小编Rom*_*man的帖子

THREEjs,更新对象的矩阵不会改变它的位置和旋转参数

我想在创建对象时为对象设置一个变换矩阵,然后通过位置、旋转和缩放来控制它,但是虽然更改矩阵确实改变了世界空间中的对象,但它的位置参数仍然保持为 0, 0, 0。

let mesh =  new THREE.Mesh(
    new THREE.BoxGeometry(),
    new THREE.MeshPhongMaterial({color:0xf15728})
)
this.scene.add(mesh)

let pos = new THREE.Vector3().setFromMatrixPosition(m)

mesh.matrixAutoUpdate = false
mesh.matrix.copy(m)

// ***************//
mesh.updateMatrix()
// ***************//

console.log("mesh.position", mesh.position)
console.log("pos", pos)
Run Code Online (Sandbox Code Playgroud)

pos这是和的值的输出mesh.position

在此输入图像描述

transformation matrix three.js

3
推荐指数
1
解决办法
2080
查看次数

标签 统计

matrix ×1

three.js ×1

transformation ×1