babylonjs-gifexporter
v1.0.2
Published
Create animated GIF from BabylonJS Engine.
Downloads
7
Maintainers
Readme
Babylon.js Animated GIF Exporter
Babylon.js Animated GIF Exporter is a simple library that enables exporting of animated GIFs from any BabylonJS Engine.
To capture and create an animated GIF from your Babylon Engine:
Download package
npm i babylonjs-gifexporter
Import GIFExporter into your project
import GIFExporter from 'babylonjs-gifexporter';
Ensure the engine is created with
preserveDrawingBuffer
set totrue
. There are multiple ways of setting this flag, I will show a simple example here.const engine = new BABYLON.Engine(canvas, true, { preserveDrawingBuffer: true });
Creat an instance of the GIF Exporter using the
engine
and anoptions
object:options
is an object that consist ofdelay: number
andduration: number
options:{delay: number, duration: number}
Basic creation:
const gifExporter = new GIFExporter(engine, { delay: 20, duration: 1000 });
The above 🔼🔼example🔼🔼 will capture a frame every 20 miliseconds to create a 1 second long animated GIF.
Call
download('nameOf.gif')
method with the name you want of your GIF file +.gif
gifExporter.download(myAnimation.gif);