I’ve been experimenting with Google Maps’ WebGLOverlayView and managed to get babylon.js rendering directly inside the map’s WebGL context. The babylon.js scene stays perfectly synchronized with the map’s tilt, zoom, and heading, so you can render 3D content that feels truly “anchored” to the real world.
EDIT: Now support Mapbox as well!
It’s not just a simple overlay! Your babylon.js scene is rendered directly into the GL context of the map. As you can see our cube is part of the google maps 3d layer
This is an early version, but it already does what I need for my project. If there’s interest from others, I’d be happy to polish it further, improve the API, add docs and maybe even turn it into a reusable npm package (maybe an addon? @Deltakosh)
Help from the community would be very appreciated as well!
I’d love to hear your thoughts, ideas, or use cases for this kind of integration!
Thanks goes to @Evgeni_Popov for helping me to solve the rendering issues and to @tibotiber for the idea/sample project to implement the Mapbox custom layer.
Google Maps only. Potentially could be used after some tweaks if the map exposes it’s gl context and some parameters required to build the camera’s projection matrix.
This is absolutely amazing. Very good work as always @roland!
For @kzhsw’s question, I know mapbox exposes the gl context as well, so likely a good candidate, and they’re pushing their 3D base maps so it would be an interesting fit. I don’t have time to lead something like this but feel free to ping me if anyone starts something on the mapbox side
If you could set up a small private Mapbox starter repo for me on GitHub (so I don’t have to dig through the docs), I’d be happy to give it a spin and try to add support for Mapbox with the overlay too.
So, so, so many integrations for this it’s hard to even start. Seriously.
There’s a massive potential there:
user customization of the map to find the intended place they’re going.
Customization of business address and advertisement on the map itself from the businesses standpoint.. it could be built as a map service to add reviews, etc, or interact with the business via the customization in certain ways.
So many more too that’s just a start. I’m probably not being clear enough here so I’ll msg when my mind is a little clearer.
@roland the starter repo is up! I’ve added you as collaborator.
I went with vanilla TS to avoid any framework related issues and make it easy for anyone to pick it up. I don’t think we’ll have a lot of UI (if any) anyway.
I’ve written a super quick README to make things easy to start. I’ll DM you my Mapbox token, so you don’t need to create an account if you want. Then just pop it into the .env.
MapBox overlay added It’s a draft version (some stuff like handling context lost is missing, etc.) but you can already try it out. I kept the options for both gmaps and mapbox the same so:
For example, if I need to render a model using babylonjs at a certain latitude and longitude, how can I find the corresponding position in babylonjs based on latitude and longitude
You can use this function. It is located under google-maps/utils but will be moved to common/utils becuase it can be used with any map which uses spherical mercator projection.