This works, and is only a proof of concept, but it works!
Cesium is never passed a webgl context and never makes a viewer object. It does not do the multiple-canvas method, or other work arounds like that.
Babylon is in charge of the render loop, and timing of cesium processing loop. Tile/Map glb are loaded into babylon context, and fully interactable in babylon.
Main code creates a framestate and cesiumcamera based on babyloncamera values, so cesium has all the data it needs to process and manage the state of tiles.
Try it yourself! I’ve got the demo published to my list of demos. Demo here: Cesium with Babylon.js
Keys:
F - Show frustum
B - Show tile bounding sphere volumes
Space - Pause cesium updates, to examine the scene “third person view”
GitHub - techtruth/cesium_in_babylon at mars – Here is the source. Its on the mars branch, not the main branch.
I’ve seen this asked around the forums for years, and I think this is a promising start. Code posted below.
The real obstacle here was the DynamicEnvironmentMapManager - Cesium Documentation – it requires a webgl context to initialize, and is in the constructor of the native 3dtileset class. I’ll work up a PR to cesium so that can be made optionally.
The camera rotation in this is not very pretty, so I have disabled mouse-based movement. Apparently babylon’s universalcamera’s mouse controls have their own idea of “up” that is different than the camera’s up. But that just makes it ugly, not bad ![]()
Happy to answer questions or collaborate on this.
PS - Please don’t kill my quota by visiting the demo site too much… I already killed my quota last month and would like to keep developing this month!
