Import GIFExporter with webpack

Hi, I’d love to be able to save one of my babylonjs scenes to an animated gif.

I would like to …
import GIFExporter from 'babylonjs-gifexporter'
However, I get an error from my webpack build about ‘gif.creator.service.js’ cannot be loaded because it uses new Worker() to require the file.

Anyone have a similar issue or know a workaround? I found a webpack package called ‘worker-plugin’ that seems like it should help but it doesn’t.
–Andy

Hello, could you create the issue in Github in the extensions repo and ping the dev from it : antpowell ???

The project is managed by him.

Ahh, thanks, I did so here

Do not hesitate to ping us back here next week if you have no answer, it has been a while I did not here from him.

Hi, I wasn’t able to get this working as is so I ended up going with another solution. Here’s the approach I took to export GIF’s …

  • I used a library called CCapture.js
  • In my runRenderLoop(), I call scene.render() and then capturer.capture(canvas) and it seems to work pretty well that way
  • This library had the same problem as babylonjs-gifexporter in that it can’t locate the gif worker service files if you import using webpack. To work around it, I pulled in the library as a script tag instead.

Hope this helps somebody.
–Andy

Could you kindly share your solution?
I definitely need HD video tool for Babylon rendering (and more particles as well).

For HD video, look at the CCapture ffmpeg option, it seems like that would work for you.
(I’ll see if I can create a playground when I get some time)

1 Like