First, the video: https://fastupload.io/wcUdJUE71ox9wA4/file
(taken thanks to the BJS inspector).
The video shows a mesh starting to wobble as the camera gets closer to it.
. makes use of BJS’s floating camera example.
. has huge dimensions (1e11 and the like for faraway objects)
. has one tiny quirk: when getting close to an object, it reduces its scaling from its “strategic value” (a star, however big, would not be visible given the dimensions involved in the scene) to smaller values, down to the scaling that corresponds to the actual “real” size. (the recalculation is plugged in scene.onBeforeActiveMeshesEvaluationObservable).
. has its engine initialised with useHighPrecisionMatrix and useHighPrecisionFloats set to true.
Now everything works very nicely. But I am obviously doing something wrong and getting closer to a star makes dance the lambada (or whatever other jerking you can think of )
It will not be easy to do a PG for this, but am trying to poll for ideas/opinions before I start doing it. Maybe one guru had this problem before and can explain what the (practical) problem is (that would be great), or… the deeper flaw in trying to build such a scene.
Can you talk more about this scaling change? I’ll also cc @Evgeni_Popov who is the best with maths and could maybe already see something worth noting here
It definitely looks like a problem of precision because of big coordinates, but using floating origin should fix it (I think you are using Floating Origin (Huge Scenes Support) | Babylon.js Documentation ?).
Maybe someone already experienced this problem and will be able to help, else I think we will need a PG to help more.
Yes I am indeed using something extremely inspired from that link.
I think I have found one issue (maybe not the issue):
. before, all stars were made children of virtual cubes, themselves
OriginEntity. Systems, with their children stars, were then placed relative to those cubes.
. now, the cubes no longer
OriginEntity. Rather, this inheritance is now at system level. Hopefully this manages to keep the precision at individual entities (which were previously very far away from each other, within their parent cubes).
Need to work on this locally!
Yes that was it indeed.
The distances between meshes “intra origin entity” were too vast. Hence the imprecision.
Moving the origin entity inheritance to “closer” objects (or even individual objects) fixes it.