[SOLVED] How to set world matrices manually



Suppose I am building a tool on top of Three.js, and I calculate world matrices of my objects somewhere else outside of Three, and I want to apply the world matrices to the Object3Ds. How can we do this?

I tried

// init
const object = new Object3D
object.matrixAutoUpdate = false

// render loop
render() {
  object.matrixWorld.set( ... )
  renderer.render(scene, camera)

but this doesn’t work because the world matrices are overriden on each tick: when the renderer calls scene.updateMatrixWorld() it goes and updates all the world matrices based on local matrices, which overrides my custom values.

What would be the best way to set world matrices manually? Maybe I should set scene.autoUpdate to false, then that way scene.updateMatrixWorld doesn’t get called, and it renders my values. Giving it a shot…


Yep, that worked: set scene.autoUpdate = false, then just provide world matrices yourself. This causes the renderer to completely skip updating world matrices of the scene (and also skips updating local matrices of all objects).