/** Mapbox give the context(*gl*) and the perspective matrix(*matrix*).**/
render: function(gl, matrix) {
if(this.scene) {
let projection = BABYLON.Matrix.FromArray(matrix);
this.scene.activeCamera.freezeProjectionMatrix(world.multiply(projection));
this.scene.render(false);
this.engine.wipeCaches(true);
}
this.map.triggerRepaint();
}
Is BABYLON approximates perspective values somewhere?
…I said that because I notice this small kind of delay :
https://jsfiddle.net/y09ucome/ (You’ll need to put the mapbox access token back in there, as I removed it in case you don’t want it there forever)
Yeah it is a precision issue caused by the matrix class using Float32Arrays. Doing the maths as just a standard array fixes the issue entirely.
Integration with mapbox might actually be very useful, so thanks for posting this here
Edit:
It’s just the conversion of the matrix provided by mapbox to a float32array (with Matrix.FromArray) that causes precision loss, so just setting the internal array to that matrix directly (and ignoring that you’re setting it to the wrong type) also solves the issue. https://jsfiddle.net/dt6ovyxL/
Ideally babylonjs would have matrix methods that allow multiplication of a matrix by an array (for both pre and post multiplication) to help with this use case. I could do a pr to add these if that sounds like a good idea @Deltakosh, though I’m weary that math.vector.ts is growing quite large.