# AnimDB ## Description This project provides an interface to an animation database with methods to query animations from that database as well as manipulate them. ## How to build / run - To initially setup: `yarn install` - To build: `gulp debug` - To test: `gulp test` ## Example usage ### Reading and using an AnimDB ```js import { AnimDB, AnimDBParser, Orientation, AnimConfig, AnimQuery, HasAudio } from 'jibo-anim-db'; // We read an animation database AnimDBParser.readAnimDB('/some/path/animdb.json') .then( animDB => { // Now we can for example retrieve animation objects by name let anim1 = animDB.getAnimByName('SomeAnimName'); // And we can then createFromConfig playback objects from those animations // which comply with optional requirements let playbackPromise = anim1.createFromConfig({ duration: 10, speed: 0.8, scale: 1.2, orientation: Orientation.LEFT }); // A playback object can then be played which will play either // one or two animations on a time line fitting those requirements playbackPromise .then( playback => playback.play({ jibo }) ) .catch(console.error.bind(console)); // We can also query for a set of animations that belong to a // certain category and optionally that can be made to have a // certain duration let res = animDB.query({ category: 'SomeCatName', duration: 35, durationError: 10, hasAudio: HasAudio.YES }); // All matching animations will be provided in 'matching' array: res.matching[0].createFromConfig({ duration: 35 }) .then( playback => playback.play({ jibo }) ) .catch(console.error.bind(console)); // And animations whose durations don't match exactly but are within // the error bounds are returned in `nonMatching` res.nonMatching[0].createFromConfig({ duration: 35 }) .then( playback => playback.play({ jibo }) ) .catch(console.error.bind(console)); }).catch(console.error); ``` ### Creating an AnimDB ```js // We build and write an animation database // This path has to point to a directory which contains an 'animations' directory AnimDBParser.createAndWriteAnimMetaData('/some/path/', 'animdb') .then( () => console.log('Done') ) .catch(console.error.bind(console)); ```