Library for loading and displaying Flare animations.
npm install @2dimensions/flare-js```
npm install
npm start -- --watch
There are a few steps to start rendering a Flare file:
1. Create a canvas element in HTMLGraphics
2. Instantiate and initialize the object with the canvas referencewindow.requestAnimationFrame()
3. Start the render loop with Flare.ActorLoader.load(fileLocation, callback)
4. Load the an Actor from file with Actor
5. Initialize and instantiate the - that will initialize the ActorArtboards for the loaded Flare file: Actor.initialize()
- First actor.makeInstance()
- then AnimationInstance(actor, animation)
6. Create a new AnimationInstance
7. Advance the within the window.requestAnimationFrame callback: animationInstance.time
- increase its time value with the provided setter animationInstance.apply()
- then apply it with actor.advance(elapsed)
8. Advance the actor:
The example folder contains two files, example.html and example.js, with an example implementation on how to use this runtime.
Use NPM to get the gl-matrix dependency:``
npm install gl-matrix
After the installation completes, copy gl-matrix.js from node_modules/gl-matrix-dist into the repo's /build folder. (N.B. canvaskit is downloaded with this repo, and already present in the /build folder.)
At this point run a webpack build:
``
npm run dev
Use a local web server such as NGINX or MAMP to expose the resources.
This file contains the canvas element that we need to render the Flare file. It'll also load the necessary dependencies (i.e. Flare-JS, gl-matrix, canvaskit) and the example running script example.js.
The