MapBox GL to BABYLON Camera Projection

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 :slight_smile:

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.

3 Likes