1

I need to transform my objects from normal coordinates to relative coordinate on a globe. I have computed a very nice transformation matrix and set it to the object like below. Object.matrixAutoUpdate = false; Object.matrix= my matrix; It works fine. But later when I need to perform a scale on z. Nothing happened, I guess it's because I turn off auto update. So I called updateMatrix() after changing the scale. The scale did change, but the transformation matrix changed backed to the default one.

Did I do anything wrong?

By the way, if I don't use matrix, and change the up vector of the object. The value never changes. It's always 0,1,0.

2 Answers 2

1

You need to set object.matrixWorldNeedsUpdate to true when modifying object.matrix.

Sign up to request clarification or add additional context in comments.

1 Comment

Is this still the case? I see in WebGLRenderer that it calls scene.updateMatrixWorld() which calls updateMatrixWorld( true ) on all of it's children, which seems to force update all child world matrices, therefore if we are calling renderer.render() every tick, we do not need to set object.matrixWorldNeedsUpdate to true every time we modify object.matrix.
1

if you want to use object matrix, you set the matrixAutoUpdate to false, here is the code for transform, rotation in x,y,z sequence, then do scale, last transform.

rM = new THREE.Matrix4().multiplyMatrices(new THREE.Matrix4().makeRotationY(rV.y), new THREE.Matrix4().makeRotationX(rV.x));
rM.premultiply(new THREE.Matrix4().makeRotationZ(rV.z));
object.matrix.copy(rM).scale(sV).setPosition(tV);

here you cannot use the updateMatrix for it will update matrix according the object posiiton, scale, rotation info which were not changed when your set the matrix.

4 Comments

Do not set matrixAutoUpdate = false unless you are familiar with the inner-workings of the library and understand the consequences of doing so.
@WestLangley What are the consequences? I am building a lib on top of Three, where I'm calculating matrices outside of Three, and I want to apply them to all the objects. Is there a bad consequence?
@trusktr Only set matrixAutoUpdate = false if the object is known to be static. More info here.
I also set scene.autoUpdate to false. All objects have custom matrixWorlds. Are there any consequences of that?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.