<p>I think you need to call <code>setFromMatrixPosition(m)</code> again after updating the matrix. After all, you need to update both the position and matrix, not just the matrix.</p>
<p><code>mesh.position.setFromMatrixPosition(mesh.matrix)</code> or <code>mesh.position = new THREE.Vector3().setFromMatrixPosition(mesh.matrix)</code> right after <code>mesh.updateMatrix()</code></p>

CC BY-SA 4.0
2020-11-16T10:43:08.873Z
2020-11-16T10:43:08.873Z
AnnoyinC
<p>I want to set a transformation matrix to an object upon creation and then control it by position, rotation and scale, but while changing the matrix does change the object in world space, it's position parameter still remains 0, 0, 0.</p>
<pre><code>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(&quot;mesh.position&quot;, mesh.position)
console.log(&quot;pos&quot;, pos)
</code></pre>
<p>Here's the output for the values of both <code>pos</code> and <code>mesh.position</code></p>
<p><a href="https://i.sstatic.net/rpyoR.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/rpyoR.png" alt="enter image description here" /></a></p>

<transformations><matrix><three.js>
THREEjs: updating an object's matrix doesnt change it's position and rotation params
Roman
# THREEjs: updating an object's matrix doesnt change it's position and rotation params

(Asked by: username_0 on 2020-11-02)

I want to set a transformation matrix to an object upon creation and then control it by position, rotation and scale, but while changing the matrix does change the object in world space, it's position parameter still remains 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)

```

Here's the output for the values of both `pos` and `mesh.position`

[![enter image description here](https://i.sstatic.net/rpyoR.png)](https://i.sstatic.net/rpyoR.png)

**Tags:** transformations, matrix, three.js


---

## 1 answers

### Answer by username_1 on 2020-11-16. Score: 0 | Accepted answer

I think you need to call `setFromMatrixPosition(m)` again after updating the matrix. After all, you need to update both the position and matrix, not just the matrix.

`mesh.position.setFromMatrixPosition(mesh.matrix)` or `mesh.position = new THREE.Vector3().setFromMatrixPosition(mesh.matrix)` right after `mesh.updateMatrix()`


---

