Babylon Lite Compat

Hey everyone - we are now publishing a @babylonjs/lite-compat experimental/preview package. What this package aims to do is implement a subset of the Babylon.js API that can be implemented on top of Babylon Lite. This let’s you run existing code written against the Babylon.js API while actually using Babylon Lite under the hood, as long as it only uses the subset of Babylon.js that can be backed by Babylon Lite. It’s experimental because it is not clear yet whether this type of compat layer will be able to cover 80% of the real world Babylon.js use cases (very useful), or only 5% (less useful).

To use it with your existing Babylon.js-based code, replace @babylonjs/core and @babylonjs/loaders with @babylonjs/lite-compat. Then, you can either change all your imports to point at @babylonjs/lite-compat, or you can use one of the bundler plugins included in the @babylonjs/lite-compat package to have your bundler automatically rewrite those Babylon.js imports to Babylon Lite Compat imports (examples in the package readme.md).

If you try out the compat layer and find something that you need is missing, feel free to reply to this thread, but please also open a GitHub issue using the compat issue template.

13 Likes

Could it be a solution to use lite-compat to make the old code to work, but using the babylonLite librairies to write the new code in the same project ?

Yes that should be possible. The compat package has a peerDependency on lite, so they sit side by side. The only thing that might be needed, depending on your scenario, is for the compat layer to publicly expose lite objects it wraps. I would say give it a try and let us know what works and what doesn’t for you. Happy to continue to improve it to make it more useful!

I added to my template lite-compat example -

The simple scene worked well. For Gizmo and Havok there was the need to implement workarounds, otherwise the scene would differ from the original Babylon.js scene. I created issues:

3 Likes