localToWorld uses matrix from the previous frame
See original GitHub issueDescription of the problem
It seems that Object3D.prototype.localToWorld
(and all other matrix-related stuff) works with the matrix that is not up to dated.
This can be easily checked by the following code:
const object = new three.Mesh(
new three.BoxGeometry(1, 1, 1),
new three.MeshBasicMaterial,
);
// expected : 0, 0, 0
// actual : 0, 0, 0
console.log(object.localToWorld(new three.Vector3(0 ,0, 0)));
object.position.set(1, 2, 3);
// expected : 1, 2, 3
// actual : 0, 0, 0
console.log(object.localToWorld(new three.Vector3(0 ,0, 0)));
object.updateWorldMatrix(true, false);
// expected : 1, 2, 3
// actual : 1, 2, 3
console.log(object.localToWorld(new three.Vector3(0 ,0, 0)));
The only way to fix this is to use updateWorldMatrix
(or render the scene) to force matrix update.
In my case this causes a camera to lag behind the object which it is tracking. That was definitely not what I was expect to see, so I think this should be fixed.
Issue Analytics
- State:
- Created 3 years ago
- Comments:22
Top Results From Across the Web
How to manually calculate localToWorldMatrix ...
So I figured out I need multiplication of each parent 's transformation matrix. Since Unity uses column major matrices, a world vertex position ......
Read more >Add PreviousLocalToWorld to material editor.
Lack of previous frame local to world matrix in material editor causes a ton of inconvenience, when working with world position offset.
Read more >Struct LocalToWorld | Entities | 1.0.0-exp.12 - Unity - Manual
This matrix is primarily intended for consumption by the rendering systems. The matrix value is generally updated automatically by TransformToMatrixSystem based ...
Read more >Get Prim Local to World Transform
Given a path to a prim on the current USD stage, return the the transformation matrix. that transforms a vector from the local...
Read more >LocalTransformation< StoredMatrix > Class Template Reference
Inheritance diagram for geo::LocalTransformation< StoredMatrix >: ... Constructor: uses the specified local-to-world transformation. More.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You should not do the mistake to underestimate the current performance limitations of the engine’s world matrix computations. Other engines like BabylonJS handle this topic way better. Even if there are no new complains, the way
three.js
updates its world matrices needs to be revisited.Yes, that sounds good. We need a test case for validation anyway!