My situation is sort of like this:
// Setup:
var spotPivot = new BABYLON.TransformNode();
var spot = new BABYLON.MeshBuilder.CreateRibbon(...);
spot.parent = spotPivot;
// Now what I am doing prior to rendering is:
var onRender = (function()
{
var a = 0;
return function()
{
spot.setParent(spotPivot);
updateMesh(spot, a);
spot.setParent(null);
a = a < 100 ? ++a : 0;
};
})();
Note that spotPivot
is located at an extremely far distance from the camera, however, the spot
transformation takes this back to very close to the camera. I am using setParent(null)
to trigger a computation that calculates the real position of spot
on the CPU before it’s sent to the GPU. This avoids needing a very high precision, which is not available on the GPU.
To make clear what happens: spotPivot.position.z
is perhaps 10000000000, but the spot.position.z
is actually -1000000000. The camera is located at (0,0,0). So therefore, after the parent is removed, the spot is actually located on like spot.position.z = 10
. This avoids needing high precision on GPU, and still allows me to use extreme distances in the model keeping high precision on small scale.
However, BabylonJS does not accurately compute this new position. When I animate another axis using a
in the code, then the animation is rounded off, resulting in a non-smooth animation. I believe this is due to a built-in inaccuracy in BabylonJS, and I suspect it may have something to do with the BABYLON.Epsilon
value.
I’ve tried temporarily changing this value before setting parent, and resetting to original value after setParent(null)
, so I could have higher accuracy. However, this does not work, the epsilon value actually does not change. Also, I’ve seen other epsilon values hard-coded scattered in the source code.
I would like to know if the epsilon is responsible for these inaccurate transformations, and if so, how I can change it in the context of the code I’ve supplied.
Thank you in advance for any input!