How do I include "babylon-lottie"

Anxious to see my Lottie assets working. The documentation had:

    import { LottieTexture } from "babylon-lottie"

And some what new to JavaScript. I added to index.html:

<script>
    import { LottieTexture } from "babylon-lottie"
</script>

But that is not finding the JavaScript source. And getting an error:

Uncaught SyntaxError: Cannot use import statement outside a module (at index.html:28:9)

Thank you in advance for the help.

Please just note that lottie is not an official babylon addon. It is maintained by a community member: @qq2315137135

I did find the demo that works from the Extensions. :slight_smile: Another one in a discussion thread was broken.

Anyway I can clone the demo: https://babylonjs-lottie-demo.netlify.app/

Where are the Community Contributions kept?

I believe I found it: GitHub - 2315137135/babylonjs-lottie-project

This should fix your issue:

<script type="module">
    import { LottieTexture } from "babylon-lottie"
</script>

Thank you. I will give that a try. I ended up recreating the demo project in Vue, copied asset files, typescript files, vue files to the newly generated project. Then installed packages npm install until it worked. Four installs total. Only three were needed.

If you want to use it in non-module JS, you can use the UMD version from CDN. Here’s an example:

In the example:

LoadScriptAsync("https://www.unpkg.com/babylonjs-lottie@1.2.6/dist/index.umd.js")

is equivalent to:

<script type="text/javascript" src="https://www.unpkg.com/babylonjs-lottie@1.2.6/dist/index.umd.js"></script>

Then you can use:

let lottieTexture = LOTTIE.LottieTexture.ParseFromObject("", lottieJsonObject, scene)

Thank you for working on this. The Lottie animations work on Windows and Android. I am using .NET MAUI with WebViewer, XAML. It aint the most efficient use of resources but I got the animations working on a box. Some Lottie animations do not render properly using .NET MAUI. The animation library throws in hiccups that should not be there. I do have quite a few that I need to test. My focus is C#, XAML, with Babylon.