.babylon files support for babylon-viewer

Do you mean the scene represented with .babylon constructs is embedded in the glb? I don’t think I’m quite following why this might be preferable to just loading .babylon files, but maybe I’m just missing something.

Today with the Babylon Viewer, if you are consuming the npm package and building your own bundle, you can in fact make it work with .babylon files quite easily. Specifically, you just need to import the Babylon loader, e.g. import "@babylonjs/core/Loading/Plugins/babylonFileLoader". Just be aware if you do this, it will statically include the Babylon file loader (and everything it depends on) in your bundle.

We have other work planned to allow the Babylon file loader to be dynamically imported (like other loaders from @babylonjs/loaders). Once that is done, bundler code splitting will separate it out and allow it to be downloaded only when needed.

This dynamic import support is what we need to enable this in the pre-bundled Babylon Viewer that can be loaded directly into a webpage from CDN.

So in summary: If you are building your own bundle, it’s already possible to load .babylon files (with additional imports). If you are using the pre-bundled Babylon Viewer via CDN, then we have plans that will enable loading .babylon files.

2 Likes