question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

localToWorld uses matrix from the previous frame

See original GitHub issue
Description 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:open
  • Created 3 years ago
  • Comments:22

github_iconTop GitHub Comments

3reactions
Mugen87commented, Sep 2, 2020

Three complaints out of how many millions of users?

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.

1reaction
Mugen87commented, Sep 2, 2020

Yes, that sounds good. We need a test case for validation anyway!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found