jibo-anim-db
Advanced tools
Comparing version 3.0.0 to 3.1.2
@@ -45,2 +45,12 @@ import { AnimVBase, KeyFrame, KeyFrameType, Point, Tween, Color, AudioEvent, Event } from '../DataFormats'; | ||
} | ||
/** | ||
* @typedef jibo.animdb#Anim | ||
* @description Interface for animation formats | ||
* @property version {string} | ||
* @property framerate {number} | ||
* @property duration {number} | ||
* @property scale {number} | ||
* @property layers {jibo.animdb.LayerName[]} | ||
* @property [animdb] {number} | ||
*/ | ||
export interface Anim extends AnimVBase { | ||
@@ -47,0 +57,0 @@ version: string; |
import { Range } from './Range'; | ||
import { LayerPresence } from './AnimUtils'; | ||
import { Anim } from './animation_formats/0_6_X/AnimV0_6_X'; | ||
import { Playback } from './Playback'; | ||
import { AnimConfig } from './Classes'; | ||
import { AnimConfig, LayerPresence } from './Classes'; | ||
import { AnimCollection } from "./AnimCollection"; | ||
@@ -14,2 +13,20 @@ export declare class Transform { | ||
} | ||
/** | ||
* @typedef jibo.animdb#AnimMetadata | ||
* @description Interface for the animation metadata. | ||
* @property name {string} Name of the animation. | ||
* @property path {string} Path to the animation. | ||
* @property scale {number[]} Description needed. | ||
* @property speed {number[]} Description needed. | ||
* @property durationRange {number[]} Description needed. | ||
* @property duration {number} Duration of the animation in milliseconds. | ||
* @property startsNeutral {boolean} `true` if the animation starts in a neutral pose. | ||
* @property endsNeutral {boolean} `true` if the animation ends in a neutral pose. | ||
* @property hasAudio {boolean} `true` if animation includes audio | ||
* @property holdSafeKF {number} Description needed. | ||
* @property orientation {string} Orientation of the animation. | ||
* @proprety categories {string[]} Description needed. | ||
* @property layers {jibo.animdb#LayerPresence} Layers included in the animation. | ||
* @property metaTerms {string[]} Array of meta terms for the animation. | ||
*/ | ||
export interface AnimMetadata { | ||
@@ -31,2 +48,14 @@ name: string; | ||
} | ||
/** | ||
* @class Animation | ||
* @memberof jibo.animdb | ||
* @description Instantiates Animation object. | ||
* | ||
* Important: Optional `animCache` object will persist and mutate. | ||
* | ||
* @param {jibo.animdb.AnimCollection} parent - The animation collection this animation belongs to. | ||
* @param {jibo.animdb#AnimMetadata} meta Animation meta data | ||
* @param {string} resourceRoot Root directory for finding resources | ||
* @param {jibo.animdb#Anim} [animCache] Optinal animation data | ||
*/ | ||
export declare class Animation { | ||
@@ -40,7 +69,42 @@ parent: AnimCollection; | ||
constructor(parent: AnimCollection, meta: AnimMetadata, resourceRoot: string, animCache?: Anim); | ||
/** | ||
* Loads the animation data from disk | ||
* @method jibo.animdb.Animation#loadAnimationObject | ||
* @returns {Promise<jibo.animdb#Anim>} | ||
*/ | ||
loadAnimationObject(): Promise<Anim>; | ||
/** | ||
* Create animation object from query parameters | ||
* @param {jibo.animdb#AnimConfig} options - Animation config options | ||
* @method jibo.animdb.Animation#createFromConfig | ||
* @returns {Promise<jibo.animdb.Playback>} | ||
*/ | ||
createFromConfig(options?: AnimConfig): Promise<Playback>; | ||
/** | ||
* Retrieves animation (from file or cache), applies transformation and returns a playback object | ||
* @param {jibo.animdb.Transform} trans Desired transformation | ||
* @returns {Promise<jibo.animdb.Playback>} | ||
* @method jibo.animdb.Animation#_applyTransformation | ||
* @private | ||
*/ | ||
private _applyTransformation(trans); | ||
/** | ||
* Applies transformation to animation and returns a playback object | ||
* | ||
* @param {jibo.animdb#Anim} animData Animation data | ||
* @param {jibo.animdb.Transform} trans Desired transformation | ||
* @returns {jibo.animdb.Playback} | ||
* @method jibo.animdb.Animation#_applyTransformationToAnim | ||
* @private | ||
*/ | ||
private _applyTransformationToAnim(animData, trans); | ||
/** | ||
* Creates a transformation spec from a requirements object based on desired | ||
* speeds and duration, scale etc. | ||
* @param {jibo.animdb#AnimConfig} options | ||
* @returns {jibo.animdb.Transform} | ||
* @method jibo.animdb.Animation#_getTransformation | ||
* @private | ||
*/ | ||
private _getTransformation(options?); | ||
} |
@@ -5,2 +5,6 @@ import { Animation } from './Animation'; | ||
import { AnimDB } from "./AnimDB"; | ||
/** | ||
* @class AnimCollection | ||
* @memberof jibo.animdb | ||
*/ | ||
export declare class AnimCollection { | ||
@@ -13,8 +17,54 @@ parent: AnimDB; | ||
constructor(parent: AnimDB); | ||
/** | ||
* Adds animation to collection | ||
* @method jibo.animdb.AnimCollection#addAnimation | ||
* @param {jibo.animdb.Animation} animation Animation to add | ||
*/ | ||
addAnimation(animation: Animation): void; | ||
/** | ||
* Adds animation category to collection | ||
* @method jibo.animdb.AnimCollection#addCategory | ||
* @param {jibo.animdb.Category} category Category to add | ||
*/ | ||
addCategory(category: Category): void; | ||
/** | ||
* Returns category by name | ||
* @method jibo.animdb.AnimCollection#getCategoryByName | ||
* @param {string} name Name of category | ||
* @returns {jibo.animdb.Category|undefined} | ||
*/ | ||
getCategoryByName(name: string): Category; | ||
/** | ||
* Returns animation by name | ||
* @method jibo.animdb.AnimCollection#getAnimByName | ||
* @param {string} name Name of animation | ||
* @returns {jibo.animdb.Animation|undefined} | ||
*/ | ||
getAnimByName(name: string): Animation; | ||
/** | ||
* Returns the animation names in this collection. | ||
* @method jibo.animdb.AnimCollection#getAnimationNames | ||
* @returns {string[]} List of animation names. | ||
*/ | ||
getAnimationNames(): string[]; | ||
/** | ||
* Returns the animation categories in this collection. | ||
* @method jibo.animdb.AnimCollection#getAnimationCategories | ||
* @returns {string[]} List of animation categories. | ||
*/ | ||
getAnimationCategories(): string[]; | ||
/** | ||
* Search animations for meta tags | ||
* @method jibo.animdb.AnimCollection#search | ||
* @param {string} searchTerm Search term could be meta tag, name, or category | ||
* @returns {jibo.animdb.SearchResults} | ||
*/ | ||
search(searchTerm: string): SearchResults; | ||
/** | ||
* Queries for animations that fit the criteria | ||
* @method jibo.animdb.AnimCollection#query | ||
* @param {jibo.animdb#AnimQuery} query | ||
* @return {jibo.animdb.AnimResults} | ||
*/ | ||
query(query: AnimQuery): AnimResults; | ||
} |
import { AnimCollection } from './AnimCollection'; | ||
import { Animation } from './Animation'; | ||
import { AnimResults, AnimQuery, SearchResults } from './Classes'; | ||
/** | ||
* @class AnimDB | ||
* @memberof jibo.animdb | ||
*/ | ||
export declare class AnimDB { | ||
private collections; | ||
constructor(jibo: any); | ||
/** | ||
* Adds animation database instance | ||
* @method jibo.animdb.AnimDB#push | ||
* @param {jibo.animdb.AnimCollection} animCollection Animation collection to add | ||
*/ | ||
push(animCollection: AnimCollection): void; | ||
/** | ||
* Pops the last anim database instance off the stack | ||
* @method jibo.animdb.AnimDB#pop | ||
* @return {jibo.animdb.AnimCollection} | ||
*/ | ||
pop(): AnimCollection; | ||
/** | ||
* Get animation by name. Returns first animation by that iname in the case of multiple collections | ||
* @method jibo.animdb.AnimDB#getAnimByName | ||
* @param {string} animName Name of animation to retrieve | ||
* @returns {jibo.animdb.Animation} | ||
*/ | ||
getAnimByName(animName: string): Animation; | ||
/** | ||
* Get animation names. Returns a list of all the animation names in the animDB. | ||
* @method jibo.animdb.AnimDB#getAnimationNames | ||
* @returns {string[]} List of animation names | ||
*/ | ||
getAnimationNames(): string[]; | ||
/** | ||
* Get animation categories. Returns a list of all the animation categories in the animDB. | ||
* @method jibo.animdb.AnimDB#getAnimationCategories | ||
* @returns {string[]} List of animation categories | ||
*/ | ||
getAnimationCategories(): string[]; | ||
/** | ||
* Search animations for meta tags | ||
* @method jibo.animdb.AnimDB#search | ||
* @param {string} searchTerm Search term could be meta tag, name, or category | ||
* @returns {jibo.animdb.SearchResults} | ||
*/ | ||
search(searchTerm: string): SearchResults; | ||
/** | ||
* Queries for animations that fit the criteria | ||
* @method jibo.animdb.AnimDB#query | ||
* @param {jibo.animdb#AnimQuery} query The query parameters | ||
* @return {jibo.animdb.AnimResults} | ||
*/ | ||
query(query: AnimQuery): AnimResults; | ||
} |
import { Anim } from './animation_formats/0_6_X/AnimV0_6_X'; | ||
import { AnimDB } from './AnimDB'; | ||
import { AnimMetadata } from './Animation'; | ||
/** | ||
* @class AnimDBParser | ||
* @memberof jibo.animdb | ||
*/ | ||
export declare class AnimDBParser { | ||
/** | ||
* Creates an animDB from a list of root directories | ||
* @method jibo.animdb.AnimDBParser#readAnimDB | ||
* @param {object} jibo - The jibo runtime | ||
* @param {string} animDBPath Path to an animDB json | ||
* @param {string[]} [moreAnimDBPaths] Paths to more animDB json | ||
* @returns {Promise<jibo.animdb.AnimDB>} | ||
*/ | ||
static readAnimDB(jibo: any, animDBPath: string, ...moreAnimDBPaths: string[]): Promise<AnimDB>; | ||
/** | ||
* Creates an animDB instance from a particular root animation directory | ||
* @method jibo.animdb.AnimDBParser#readAndAddAnimCollection | ||
* @param {jibo.animdb.AnimDB} animDB - The animDB to add collection to | ||
* @param {string} animDBPath | ||
* @returns {Promise<jibo.animdb.AnimCollection>} | ||
*/ | ||
static readAndAddAnimCollection(animDB: AnimDB, animDBPath: string): Promise<void>; | ||
/** | ||
* Finds all key files under a certain root dir (recursively), reads them and | ||
* extracts meta data from them. | ||
* Writes resulting metadata collection to a json object on disk | ||
* @method jibo.animdb.AnimDBParser#createAndWriteAnimMetaData | ||
* @param {Object} jibo - The jibo runtime | ||
* @param {string} rootDir Animations will be searched in rootDir/animations | ||
* @param {string} outName Name of output file (no extension) | ||
* @returns {Promise<any>} | ||
*/ | ||
static createAndWriteAnimMetaData(jibo: any, rootDir: string, outName: string): Promise<any>; | ||
/** | ||
* Finds all key files under a certain root dir (recursively), reads them and | ||
* extracts meta data from them | ||
* @method jibo.animdb.AnimDBParser#createAnimMetaData | ||
* @param {Object} jibo - The jibo runtime | ||
* @param {string} rootDir Animations will be searched in rootDir/animations | ||
* @returns {Promise<object>} an object comprised of {@link jibo.animdb#AnimMetadata}. | ||
*/ | ||
static createAnimMetaData(jibo: any, rootDir: string): Promise<{ | ||
[x: string]: AnimMetadata; | ||
}>; | ||
/** | ||
* Loads animation data from disk and calculates derived properties | ||
* @method jibo.animdb.AnimDBParser#parseAnimation | ||
* @param {Object} jibo - The jibo runtime | ||
* @param {string} filePath to animation | ||
* @returns {Promise<jibo.animdb#AnimMetadata>} | ||
*/ | ||
static parseAnimation(jibo: any, filePath: string): Promise<AnimMetadata>; | ||
/** | ||
* Loads animation data from disk and expanding resolving/"macro-expanding" any Reference layers | ||
* @method jibo.animdb.AnimDBParser#loadKeys | ||
* @param {Object} jibo - The jibo runtime | ||
* @param {string} keysPath to animation | ||
* @returns {Promise<jibo.animdb#Anim>} | ||
*/ | ||
static loadKeys(jibo: any, keysPath: string): Promise<Anim>; | ||
/** | ||
* Calculates derived properties from Anim object | ||
* @method jibo.animdb.AnimDBParser#parseAnimationFromAnim | ||
* @param {jibo.animdb#Anim} animData object Animation object | ||
* @param {string} filePath keys file JSON | ||
* @returns {jibo.animdb#AnimMetadata} | ||
*/ | ||
static parseAnimationFromAnim(animData: Anim, filePath: string): AnimMetadata; | ||
} |
@@ -1,63 +0,1 @@ | ||
import { Orientation, AnimQuery } from './Classes'; | ||
import { Anim } from './animation_formats/0_6_X/AnimV0_6_X'; | ||
import { Layer } from './animation_formats/0_6_X/AnimV0_6_X'; | ||
export interface LayerHandler<T> { | ||
(l: Layer<T>): void; | ||
} | ||
export declare class LayerName { | ||
short: string; | ||
long: string; | ||
static Body: LayerName; | ||
static Eye: LayerName; | ||
static EyeTexture: LayerName; | ||
static Overlay: LayerName; | ||
static OverlayTexture: LayerName; | ||
static AudioEvent: LayerName; | ||
static Event: LayerName; | ||
static Pixi: LayerName; | ||
static BackgroundTexture: LayerName; | ||
static LED: LayerName; | ||
static Glow: LayerName; | ||
static Lighting: LayerName; | ||
static Layers: LayerName[]; | ||
constructor(short: string, long?: string); | ||
} | ||
export interface LayerPresence { | ||
Body?: boolean; | ||
Eye?: boolean; | ||
EyeTexture?: boolean; | ||
Overlay?: boolean; | ||
OverlayTexture?: boolean; | ||
AudioEvent?: boolean; | ||
Event?: boolean; | ||
Pixi?: boolean; | ||
BackgroundTexture?: boolean; | ||
LED?: boolean; | ||
Glow?: boolean; | ||
Lighting?: boolean; | ||
} | ||
export declare enum BuilderLayer { | ||
beat, | ||
default, | ||
posture, | ||
} | ||
export interface PlayOptions { | ||
layer?: BuilderLayer; | ||
root?: string; | ||
} | ||
export declare class AnimUtils { | ||
static syncAnimLayers(animData: Anim, layers: LayerPresence): void; | ||
static _addMockLayer(animData: Anim, type: string): void; | ||
static scaleTimeInPlace(animData: Anim, scale: number): void; | ||
static scaleBodyInPlace(animData: Anim, scale: number): void; | ||
static flipScreenLeftRight(animData: Anim): void; | ||
static startsNeutral(animData: Anim): boolean; | ||
static endsNeutral(animData: Anim): boolean; | ||
static checkLayers(animData: Anim, strict?: boolean): LayerPresence; | ||
static hasAudio(animData: Anim): boolean; | ||
static hasLayer(animData: Anim, layerName: LayerName, strict?: boolean): boolean; | ||
static hasHoldSafe(animData: Anim, name: string): number; | ||
static calculateOrientation(animData: Anim): Orientation; | ||
static forEachLayerType(animData: Anim, layerName: LayerName, handler: LayerHandler<any>): void; | ||
static insertDefaultAnimQueryParams(query: AnimQuery): void; | ||
} | ||
export { }; |
import { Animation } from './Animation'; | ||
import { AnimQuery, AnimResults } from './Classes'; | ||
/** | ||
* @class Category | ||
* @memberof jibo.animdb | ||
*/ | ||
export declare class Category { | ||
@@ -8,4 +12,15 @@ name: string; | ||
constructor(name: string); | ||
/** | ||
* Adds animation to category | ||
* @method jibo.animdb.Category#addAnimation | ||
* @param {jibo.animdb.Animation} anim Animation to add | ||
*/ | ||
addAnimation(anim: Animation): void; | ||
/** | ||
* Queries for animations that fit the criteria | ||
* @method jibo.animdb.Category#query | ||
* @param {jibo.animdb#AnimQuery} query Animation query parameters | ||
* @return {jibo.animdb.AnimResults} | ||
*/ | ||
query(query: AnimQuery): AnimResults; | ||
} |
import { Animation } from './Animation'; | ||
import { Category } from './Category'; | ||
import { LayerPresence } from './AnimUtils'; | ||
/** | ||
* @typedef jibo.animdb#Orientation | ||
* @description Enum of orientation options. | ||
* @property LEFT {any} 'LEFT' | ||
* @property RIGHT {any} 'RIGHT' | ||
*/ | ||
export declare enum Orientation { | ||
/** | ||
* Animation Left oriented | ||
* @type {string} | ||
*/ | ||
LEFT, | ||
/** | ||
* Animation Right oriented | ||
* @type {string} | ||
*/ | ||
RIGHT, | ||
} | ||
/** | ||
* @typedef jibo.animdb#AnimConfig | ||
* @description Interface of configurations. | ||
* @property [duration] {number} Desired duration of animation in frames | ||
* @property [speed] {number} Desired speed of animation (relative to 1 as normal) | ||
* @property [scale] {number} Desired scale multiplier for body DoFs | ||
* @property [orientation] {jibo.animdb#Orientation} Desired orientation of the animation (left or right sided) | ||
* @property [layers] {jibo.animdb#LayerPresence} Desired layers to be present in animation | ||
*/ | ||
export interface AnimConfig { | ||
@@ -15,2 +37,10 @@ duration?: number; | ||
} | ||
/** | ||
* @typedef jibo.animdb#PlaybackOptions | ||
* @description Interface of playback options. | ||
* @property [forceReturnToIdle] {boolean} | ||
* @property [screenCenterOverride] {boolean} | ||
* @property [handleBuilder] {function} | ||
* @property [handleAnimation] {function} | ||
*/ | ||
export interface PlaybackOptions { | ||
@@ -22,2 +52,9 @@ forceReturnToIdle?: boolean; | ||
} | ||
/** | ||
* @typedef jibo.animdb#HasAudio | ||
* @description Enum of audio options | ||
* @property YES {any} 'YES' | ||
* @property NO {any} 'NO' | ||
* @property DONT_CARE {any} 'DONT_CARE' | ||
*/ | ||
export declare enum HasAudio { | ||
@@ -28,2 +65,13 @@ YES, | ||
} | ||
/** | ||
* @typedef jibo.animdb#AnimQuery | ||
* @description Interface of query informaton. | ||
* @property [category] {string} Desired category name | ||
* @property [categories] {string[]} Multiple category names to pick from | ||
* @property [duration] {number} Desired animation duration in frames | ||
* @property [durationError] {number} Allowed duration error in frames | ||
* @property [hasAudio] {jibo.animdb#HasAudio} Whether animation can contain audio | ||
* @property [includeMeta] {string[]} List of meta tags that the animation must contain | ||
* @property [excludeMeta] {string[]} List of meta tags that the animation must not contain | ||
*/ | ||
export interface AnimQuery { | ||
@@ -38,10 +86,143 @@ category?: string; | ||
} | ||
/** | ||
* @class AnimResults | ||
* @memberof jibo.animdb | ||
*/ | ||
export declare class AnimResults { | ||
/** | ||
* Animations that match the query | ||
* @name jibo.animdb.AnimResults#matching | ||
* @type {jibo.animdb.Animation[]} | ||
*/ | ||
matching: Animation[]; | ||
/** | ||
* Animations that match the query but not the duration boundaries | ||
* @name jibo.animdb.AnimResults#nonMatching | ||
* @type {jibo.animdb.Animation[]} | ||
*/ | ||
nonMatching: Animation[]; | ||
} | ||
/** | ||
* @class SearchResults | ||
* @memberof jibo.animdb | ||
*/ | ||
export declare class SearchResults { | ||
/** | ||
* Category that matches search string | ||
* @name jibo.animdb.SearchResults#category | ||
* @type {jibo.animdb.Category} | ||
*/ | ||
category: Category; | ||
/** | ||
* Animation whose name matches search string | ||
* @name jibo.animdb.SearchResults#name | ||
* @type {jibo.animdb.Category} | ||
*/ | ||
name: Animation; | ||
/** | ||
* Animations that match search string on meta tags | ||
* @name jibo.animdb.SearchResults#meta | ||
* @type {jibo.animdb.Category} | ||
*/ | ||
meta: Animation[]; | ||
} | ||
/** | ||
* @typedef jibo.animdb#LayerPresence | ||
* @description Interface for layers present in the animation. | ||
* @property [Body] {boolean} | ||
* @property [Eye] {boolean} | ||
* @property [EyeTexture] {boolean} | ||
* @property [Overlay] {boolean} | ||
* @property [OverlayTexture] {boolean} | ||
* @property [AudioEvent] {boolean} | ||
* @property [Event] {boolean} | ||
* @property [Pixi] {boolean} | ||
* @property [BackgroundTexture] {boolean} | ||
* @property [LED] {boolean} | ||
* @property [Glow] {boolean} | ||
* @property [Lighting] {boolean} | ||
*/ | ||
export interface LayerPresence { | ||
/** | ||
* @name jibo.animdb.LayerPresence#Body | ||
* @type {boolean} | ||
*/ | ||
Body?: boolean; | ||
/** | ||
* @name jibo.animdb.LayerPresence#Eye | ||
* @type {boolean} | ||
*/ | ||
Eye?: boolean; | ||
/** | ||
* @name jibo.animdb.LayerPresence#EyeTexture | ||
* @type {boolean} | ||
*/ | ||
EyeTexture?: boolean; | ||
/** | ||
* @name jibo.animdb.LayerPresence#Overlay | ||
* @type {boolean} | ||
*/ | ||
Overlay?: boolean; | ||
/** | ||
* @name jibo.animdb.LayerPresence#OverlayTexture | ||
* @type {boolean} | ||
*/ | ||
OverlayTexture?: boolean; | ||
/** | ||
* @name jibo.animdb.LayerPresence#AudioEvent | ||
* @type {boolean} | ||
*/ | ||
AudioEvent?: boolean; | ||
/** | ||
* @name jibo.animdb.LayerPresence#Event | ||
* @type {boolean} | ||
*/ | ||
Event?: boolean; | ||
/** | ||
* @name jibo.animdb.LayerPresence#Pixi | ||
* @type {boolean} | ||
*/ | ||
Pixi?: boolean; | ||
/** | ||
* @name jibo.animdb.LayerPresence#BackgroundTexture | ||
* @type {boolean} | ||
*/ | ||
BackgroundTexture?: boolean; | ||
/** | ||
* @name jibo.animdb.LayerPresence#LED | ||
* @type {boolean} | ||
*/ | ||
LED?: boolean; | ||
/** | ||
* @name jibo.animdb.LayerPresence#Glow | ||
* @type {boolean} | ||
*/ | ||
Glow?: boolean; | ||
/** | ||
* @name jibo.animdb.LayerPresence#Lighting | ||
* @type {boolean} | ||
*/ | ||
Lighting?: boolean; | ||
} | ||
/** | ||
* @typedef jibo.animdb#BuilderLayer | ||
* @description Enum of BuilderLayer options: | ||
* @property beat {string} 'beat' | ||
* @property default {string} 'default' | ||
* @property posture {string} 'posture' | ||
*/ | ||
export declare enum BuilderLayer { | ||
beat, | ||
default, | ||
posture, | ||
} | ||
/** | ||
* @typedef jibo.animdb#PlayOptions | ||
* @description Options for playing the animation. | ||
* @property [layer] {jibo.animdb#BuilderLayer} | ||
* @property [root] {string} | ||
*/ | ||
export interface PlayOptions { | ||
layer?: BuilderLayer; | ||
root?: string; | ||
} |
@@ -0,1 +1,13 @@ | ||
/** | ||
* @description The AnimDB library provides access to a centralized | ||
* repository of animations which can be queried for animations by | ||
* name or by a set of search criteria including duration, meta tags, | ||
* category, etc. | ||
* | ||
* The library also provides an ability to modify animations like | ||
* extend their duration with a HOLD_SAFE keyframe, scale their body | ||
* DoFs (exaggerate or mute the movement), change orientation, etc. | ||
* | ||
* @namespace jibo.animdb | ||
*/ | ||
export * from './AnimDB'; | ||
@@ -11,3 +23,4 @@ export * from './Range'; | ||
export * from './Utils'; | ||
import * as api from './api'; | ||
import * as animation_formats from './animation_formats'; | ||
export { animation_formats }; | ||
export { animation_formats, api }; |
@@ -5,2 +5,8 @@ import { KeysPlayback } from 'jibo-cai-utils'; | ||
import { Animation } from './Animation'; | ||
/** | ||
* @class Playback | ||
* @memberof jibo.animdb | ||
* @param {number} duration - Desired duration | ||
* @param {number} speed - Desired speed | ||
*/ | ||
export declare class Playback { | ||
@@ -16,4 +22,14 @@ duration: number; | ||
constructor(duration: number, speed: number, _framesToHold: number, _resourceRoot: string, _animData: Anim, _animation: Animation); | ||
init(options: PlaybackOptions): Promise<KeysPlayback>; | ||
/** | ||
* Initializes the KeysPlayback object for the animation | ||
* @returns {Promise<KeysPlayback>} | ||
*/ | ||
init(): Promise<KeysPlayback>; | ||
/** | ||
* Plays the animation | ||
* @method jibo.animdb.Playback#play | ||
* @param {jibo.animdb#PlaybackOptions} [options] - Options that allow configuring playback of animation | ||
* @returns {Promise<void>} | ||
*/ | ||
play(options?: PlaybackOptions): Promise<void>; | ||
} |
@@ -0,10 +1,50 @@ | ||
/** | ||
* A number to represent infinite duration | ||
* @const INFINITE_DURATION | ||
* @memberof jibo.animdb | ||
* @private | ||
*/ | ||
export declare const INFINITE_DURATION = 1000000; | ||
/** | ||
* Represents a time boundary with an max and min limit. | ||
* @class Range | ||
* @memberof jibo.animdb | ||
* @private | ||
*/ | ||
export declare class Range { | ||
min: number; | ||
max: number; | ||
/** | ||
* Constructs a Range object | ||
* @param {number} min - Minimum value of range | ||
* @param {number} max - Maximum value of range | ||
*/ | ||
constructor(min: number, max: number); | ||
/** | ||
* @method jibo.animdb.Range#toString | ||
* @returns {string} | ||
*/ | ||
toString(): string; | ||
/** | ||
* Takes a number and limits it by this range. | ||
* If `min` then return min bound, if higher then return max bound | ||
* @method jibo.animdb.Range#limit | ||
* @param {number} num - Number to limit to range | ||
* @returns {number} | ||
*/ | ||
limit(num: number): number; | ||
/** | ||
* Does the upper bound of this range represent infinity | ||
* @method jibo.animdb.Range#isUpperInfinite | ||
* @returns {boolean} | ||
*/ | ||
isUpperInfinite(): boolean; | ||
/** | ||
* Reports how far a number is from being within this range. | ||
* Returns 0 if it is contained in range. | ||
* @method jibo.animdb.Range#distanceFrom | ||
* @param {number} num - Number to calculate distance from | ||
* @returns {number} | ||
*/ | ||
distanceFrom(num: number): number; | ||
} |
@@ -0,1 +1,14 @@ | ||
import { Animation } from './Animation'; | ||
import { AnimResults, HasAudio, AnimQuery } from './Classes'; | ||
/** | ||
* @typedef jibo.animdb#SemVer | ||
* @description interface | ||
* @property semver {string} Example '1.0.4-alpha.1' | ||
* @property version {string} Example '1.0.4' | ||
* @property major {number} Example '1' | ||
* @property minor {number} Example '0' | ||
* @property patch {number} Example '4' | ||
* @property [release] {string} Example 'alpha.1' | ||
* @private | ||
*/ | ||
export interface SemVer { | ||
@@ -9,1 +22,93 @@ semver: string; | ||
} | ||
/** | ||
* @class Utils | ||
* @memberof jibo.animdb | ||
* @private | ||
*/ | ||
export declare class Utils { | ||
/** | ||
* Returns input or default value if input is falsey or empty | ||
* @method jibo.animdb.Utils#parseString | ||
* @static | ||
* @param {string} input | ||
* @param {string} defaultVal | ||
* @returns {string} | ||
*/ | ||
static parseString(input: any, defaultVal: string): any; | ||
/** | ||
* Returns input or default value if input is falsey or empty | ||
* @method jibo.animdb.Utils#parseNumber | ||
* @static | ||
* @param {string} input | ||
* @param {number} defaultVal | ||
* @returns {string} | ||
*/ | ||
static parseNumber(input: any, defaultVal: number): number; | ||
/** | ||
* Parses input string to SemVer object | ||
* @method jibo.animdb.Utils#parseSemVer | ||
* @static | ||
* @param {string} input | ||
* @returns {jibo.animdb#SemVer} | ||
*/ | ||
static parseSemVer(input: string): SemVer; | ||
/** | ||
* Retrieves all animations from a list that match a certain | ||
* duration criteria | ||
* @method jibo.animdb.Utils#getAnimationsByQuery | ||
* @static | ||
* @param {jibo.animdb.Animation[]} animations Input animation collection | ||
* @param {jibo.animdb.AnimResults} interimResults | ||
* @param {jibo.animdb#AnimQuery} [query] Selection criteria | ||
*/ | ||
static getAnimationsByQuery(animations: Animation[], interimResults: AnimResults, query: AnimQuery): void; | ||
/** | ||
* Checks if animation matches audio requirement | ||
* @method jibo.animdb.Utils#audioMatch | ||
* @static | ||
* @param {jibo.animdb.Animation} animation | ||
* @param {jibo.animdb#HasAudio} shouldHaveAudio | ||
* @returns {boolean} | ||
*/ | ||
static audioMatch(animation: Animation, shouldHaveAudio: HasAudio): boolean; | ||
/** | ||
* Checks if animation matches meta tag criteria | ||
* @method jibo.animdb.Utils#metaMatch | ||
* @static | ||
* @param {jibo.animdb.Animation} animation | ||
* @param {string[]} shouldIncludeMeta | ||
* @param {string[]} shouldExcludeMeta | ||
* @returns {boolean} | ||
*/ | ||
static metaMatch(animation: Animation, shouldIncludeMeta: string[], shouldExcludeMeta: string[]): boolean; | ||
/** | ||
* Adds animation to result if duration matches bounds | ||
* @method jibo.animdb.Utils#addIfDurationMatch | ||
* @static | ||
* @param {jibo.animdb.Animation} animation | ||
* @param {number} duration | ||
* @param {number} durationError | ||
* @param {jibo.animdb.AnimResults} res | ||
*/ | ||
static addIfDurationMatch(animation: Animation, duration: number, durationError: number, res: AnimResults): void; | ||
/** | ||
* Takes a number and limits it by this range. | ||
* If min then return min bound, if higher then return max bound | ||
* @method jibo.animdb.Utils#limitToRange | ||
* @static | ||
* @param {number} num | ||
* @param {number[]} range [min, max] | ||
* @returns {number} | ||
*/ | ||
static limitToRange(num: number, range: number[]): number; | ||
/** | ||
* Reports how far a number is from being within this range | ||
* Returns 0 if it is contained in range | ||
* @method jibo.animdb.Utils#distanceFromRange | ||
* @static | ||
* @param {number} num | ||
* @param {number[]} range [min, max] | ||
* @returns {number} | ||
*/ | ||
static distanceFromRange(num: number, range: number[]): number; | ||
} |
/** | ||
* jibo-anim-db - Provides query abstraction over a library of animations | ||
* @version v3.0.0 | ||
* @version v3.1.2 | ||
* @license Copyright (c) 2017, Jibo, Inc. All rights reserved. | ||
@@ -9,2 +9,2 @@ * All use of the Jibo SDK is subject to the Jibo SDK End User License Agreement (EULA) | ||
*/ | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.jiboAnimDb=t()}}(function(){return function t(e,n,i){function a(o,s){if(!n[o]){if(!e[o]){var u="function"==typeof require&&require;if(!s&&u)return u(o,!0);if(r)return r(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[o]={exports:{}};e[o][0].call(l.exports,function(t){var n=e[o][1][t];return a(n?n:t)},l,l.exports,t,e,n,i)}return n[o].exports}for(var r="function"==typeof require&&require,o=0;o<i.length;o++)a(i[o]);return a}({1:[function(t,e,n){"use strict";var i=t("./Utils"),a=t("./Classes"),r=t("./AnimUtils"),o=function(){function t(t){this.parent=t,this.animations=[],this.categories=[],this._animationsByName=new Map,this._categoriesByName=new Map}return t.prototype.addAnimation=function(t){var e=t.name.toLowerCase();this._animationsByName.has(e)||(this._animationsByName.set(e,t),this.animations.push(t))},t.prototype.addCategory=function(t){var e=t.name.toLowerCase();this._categoriesByName.has(e)||(this._categoriesByName.set(e,t),this.categories.push(t))},t.prototype.getCategoryByName=function(t){return this._categoriesByName.get(t.toLowerCase())},t.prototype.getAnimByName=function(t){return this._animationsByName.get(t.toLowerCase())},t.prototype.search=function(t){var e=t.toLowerCase(),n=new a.SearchResults;return this._search(e,n),n},t.prototype.query=function(t){r.AnimUtils.insertDefaultAnimQueryParams(t);var e=new a.AnimResults;this._query(t,e);var n=[];new Set(e.matching).forEach(function(t){return n.push(t)}),e.matching=n;var i=[];return new Set(e.nonMatching).forEach(function(t){return i.push(t)}),e.nonMatching=i,e},t.prototype._search=function(t,e){var n=this._categoriesByName.get(t);n&&(e.category=n);var i=this._animationsByName.get(t);i&&(e.name=i),this.animations.forEach(function(n){n.meta.metaTerms.forEach(function(i){i===t&&e.meta.push(n)})})},t.prototype._query=function(t,e){var n=this;t.categories.length?t.categories.forEach(function(i){var a=n._categoriesByName.get(i);a&&a._query(t,e)}):i.Utils.getAnimationsByQuery(this.animations,e,t)},t}();n.AnimCollection=o},{"./AnimUtils":4,"./Classes":7,"./Utils":10}],2:[function(t,e,n){"use strict";var i=t("./Classes"),a=t("./AnimUtils"),r=function(){function t(t){this.collections=[],this.jibo=t}return t.prototype.push=function(t){this.collections.push(t)},t.prototype.pop=function(){return this.collections.pop()},t.prototype.getAnimByName=function(t){for(var e,n=0;n<this.collections.length;n++){var i=this.collections[n],a=i.getAnimByName(t);if(a){e=a;break}}return e},t.prototype.search=function(t){var e=t.toLowerCase(),n=new i.SearchResults;return this.collections.forEach(function(t){t._search(e,n)}),n},t.prototype.query=function(t){a.AnimUtils.insertDefaultAnimQueryParams(t);var e=new i.AnimResults;this.collections.forEach(function(n){n._query(t,e)});var n=[];new Set(e.matching).forEach(function(t){return n.push(t)}),e.matching=n;var r=[];return new Set(e.nonMatching).forEach(function(t){return r.push(t)}),e.nonMatching=r,e},t}();n.AnimDB=r},{"./AnimUtils":4,"./Classes":7}],3:[function(t,e,n){"use strict";var i=t("path"),a=t("fs"),r=t("jibo-cai-utils"),o=t("./AnimDB"),s=t("./AnimCollection"),u=t("./Animation"),c=t("./Category"),l=t("./AnimUtils"),f=t("./Utils"),m=t("./Range"),h=t("json-stable-stringify"),d=function(){function t(){}return t.readAnimDB=function(e,n){for(var i=[],a=2;a<arguments.length;a++)i[a-2]=arguments[a];i.unshift(n);var r=new o.AnimDB(e),s=i.map(function(e){return t.readAndAddAnimCollection(r,e)});return Promise.all(s).then(function(){return r})},t.readAndAddAnimCollection=function(t,e){var n=i.dirname(e);return r.FileUtils.readFile(e).then(function(e){for(var i=JSON.parse(e),a=new s.AnimCollection(t),r=function(t){var e=i[t];t=e.name.toLowerCase();var r=new u.Animation(a,e,n),o=a.getAnimByName(r.name);if(o){var s=[o.meta.path,e.path];throw new Error("Duplicate animation name: '"+t+"' at paths: "+s)}a.addAnimation(r),r.meta.categories.forEach(function(t){var e=a.getCategoryByName(t);e||(e=new c.Category(t),a.addCategory(e)),e.addAnimation(r)})},o=0,l=Object.keys(i);o<l.length;o++){var f=l[o];r(f)}t.push(a)})},t.createAndWriteAnimMetaData=function(e,n,o){return t.createAnimMetaData(e,n).then(function(t){var e=i.join(n,o+".json"),s=h(t,{space:" "});return r.PromiseUtils.promisify(function(t){return a.writeFile(e,s,"utf8",t)})})},t.createAnimMetaData=function(e,n){var a=i.join(n,"animations");return r.FileUtils.findAllFilesWithExt(a,"keys").then(function(n){var a=n.filter(function(t){return!i.basename(t).startsWith("_")}),r=a.map(function(n){return t.parseAnimation(e,n)});return Promise.all(r)}).then(function(t){var e=t,a=i.resolve(n),r={};return e.forEach(function(t){var e=t.path.substring(0,a.length);if(e!==a)throw new Error("Animation doesn't have the expected root path: "+[t.path,a]);if(t.path=t.path.substring(a.length+i.sep.length),r[t.name]){var n=[r[t.name].path,t.path];throw new Error("Duplicate animation name: '"+t.name+"' at paths: "+n)}r[t.name]=t}),r})},t.parseAnimation=function(e,n){return t.loadKeys(e,n).then(function(e){return t.parseAnimationFromAnim(e,n)})},t.loadKeys=function(t,e){return new t.rendering.animation.KeysLoader(e).load()},t.parseAnimationFromAnim=function(t,e){var n,a,r,o;try{var s=i.basename(e,i.extname(e));n=t.animdb||{},o=f.Utils.parseString(n.name,s),a=[f.Utils.parseNumber(n.scaleMin,1),f.Utils.parseNumber(n.scaleMax,1)],r=[f.Utils.parseNumber(n.speedMin,1),f.Utils.parseNumber(n.speedMax,1)]}catch(t){throw new Error("Error parsing animation at path '"+e+"': '"+t+"'")}if(r[0]<=0||r[0]>r[1])throw new Error("Invalid speed bounds '"+JSON.stringify(r)+"' for animation '"+e+"'");if(a[0]>a[1])throw new Error("Invalid scale bounds '"+JSON.stringify(a)+"' for animation '"+e+"'");var u=n.categories||"",c=[];u.split(",").forEach(function(t){var e=t.trim().toLowerCase();e.length&&c.push(e)});var h=n.meta||"",d=[];h.split(",").forEach(function(t){var e=t.trim().toLowerCase();e.length&&d.push(e)});var y=l.AnimUtils.hasHoldSafe(t,o),p=[r[0]*t.duration,r[1]*t.duration];y!==-1&&(p[1]=m.INFINITE_DURATION);var v={name:o,scale:a,speed:r,durationRange:p,categories:c,metaTerms:d,holdSafeKF:y,path:e,duration:t.duration,startsNeutral:l.AnimUtils.startsNeutral(t),endsNeutral:l.AnimUtils.endsNeutral(t),hasAudio:l.AnimUtils.hasAudio(t),orientation:l.AnimUtils.calculateOrientation(t),layers:l.AnimUtils.checkLayers(t)};return v},t}();n.AnimDBParser=d},{"./AnimCollection":1,"./AnimDB":2,"./AnimUtils":4,"./Animation":5,"./Category":6,"./Range":9,"./Utils":10,fs:void 0,"jibo-cai-utils":void 0,"json-stable-stringify":void 0,path:void 0}],4:[function(t,e,n){"use strict";var i=t("./Classes"),a=t("./animation_formats/LayerMocks"),r=3,o="HOLD_SAFE",s=function(){function t(t,e){this.short=t,this.long=e}return t}();s.Body=new s("Body"),s.Eye=new s("Eye"),s.EyeTexture=new s("EyeTexture","Eye Texture"),s.Overlay=new s("Overlay"),s.OverlayTexture=new s("OverlayTexture","Overlay Texture"),s.AudioEvent=new s("AudioEvent","Audio Event"),s.Event=new s("Event"),s.Pixi=new s("Pixi"),s.BackgroundTexture=new s("BackgroundTexture","Background Texture"),s.LED=new s("LED"),s.Glow=new s("Glow"),s.Lighting=new s("Lighting"),s.Layers=[s.Body,s.Eye,s.EyeTexture,s.Overlay,s.OverlayTexture,s.AudioEvent,s.Event,s.Pixi,s.BackgroundTexture,s.LED,s.Glow,s.Lighting],n.LayerName=s;var u;!function(t){t[t.beat="beat"]="beat",t[t.default="default"]="default",t[t.posture="posture"]="posture"}(u=n.BuilderLayer||(n.BuilderLayer={}));var c=function(){function t(){}return t.syncAnimLayers=function(e,n){for(var i=e.layers.length-1;i>=0;i--){var a=e.layers[i].type;s[a]||(a=a.replace(/\s/g,"")),void 0===n[a]||n[a]||e.layers.splice(i,1)}Object.keys(n).forEach(function(t){n[t]||delete n[t]});var r=Object.keys(n).filter(function(n){return!t.hasLayer(e,s[n],!1)});r.forEach(function(n){return t._addMockLayer(e,s[n].long||s[n].short)})},t._addMockLayer=function(t,e){t.layers.push(a.LayerTemplate.generateLayer(e,e))},t.scaleTimeInPlace=function(t,e){t.layers.forEach(function(t){t.keyframes.forEach(function(t){t.time=Math.round(t.time*e)})}),t.duration=Math.round(t.duration*e)},t.scaleBodyInPlace=function(e,n){t.forEachLayerType(e,s.Body,function(t){t.keyframes.forEach(function(t){t.value.Head*=n,t.value.Pelvis*=n,t.value.Torso*=n})})},t.flipScreenLeftRight=function(e){var n=function(t){t.keyframes.forEach(function(t){t.value.Translate.x*=-1})};t.forEachLayerType(e,s.Eye,n),t.forEachLayerType(e,s.Overlay,n)},t.startsNeutral=function(e){var n=!0,i=e.duration;return t.forEachLayerType(e,s.Body,function(t){if(t.keyframes.length){var e=t.keyframes[0];e.time<i&&(i=e.time,(Math.abs(e.value.Pelvis)>r||Math.abs(e.value.Head)>r||Math.abs(e.value.Torso)>r)&&(n=!1))}}),n},t.endsNeutral=function(e){var n=!0,i=-1;return t.forEachLayerType(e,s.Body,function(t){if(t.keyframes.length){var e=t.keyframes[t.keyframes.length-1];e.time>i&&(i=e.time,(Math.abs(e.value.Pelvis)>r||Math.abs(e.value.Head)>r||Math.abs(e.value.Torso)>r)&&(n=!1))}}),n},t.checkLayers=function(e,n){void 0===n&&(n=!0);var i={};return s.Layers.forEach(function(a){t.hasLayer(e,a,n)&&(i[a.short]=!0)}),i},t.hasAudio=function(e){return t.hasLayer(e,s.AudioEvent)},t.hasLayer=function(e,n,i){void 0===i&&(i=!0);var a=[];return t.forEachLayerType(e,n,function(t){i?a.push(0!==t.keyframes.length):a.push(!0)}),a.some(function(t){return t})},t.hasHoldSafe=function(e,n){var i=-1;return t.forEachLayerType(e,s.Event,function(t){t.keyframes.forEach(function(t){if(t.value.Event.name===o){if(i!==-1)throw new Error("Two HOLD_SAFE keyframes defined in animation"+(" '"+n+"' at frames "+i+" and "+t.time));i=t.time}})}),i},t.calculateOrientation=function(e){var n=0,a=0,r=0,o=0;t.forEachLayerType(e,s.Body,function(t){t.keyframes.forEach(function(t){o++,n+=t.value.Head,a+=t.value.Pelvis,r+=t.value.Torso})}),n/=o,a/=o,r/=o;var u=(r+a)/2;return Math.abs(u)>10?u>0?i.Orientation.LEFT:i.Orientation.RIGHT:n>0?i.Orientation.LEFT:i.Orientation.RIGHT},t.forEachLayerType=function(t,e,n){var i=e.long||e.short,a=i+" #";t.layers.forEach(function(t){(t.name===i||t.name.startsWith(a))&&n(t)})},t.insertDefaultAnimQueryParams=function(t){t.categories||(t.categories=[]),t.category&&t.categories.push(t.category);for(var e=0;e<t.categories.length;e++)t.categories[e]=t.categories[e].toLowerCase();if(t.includeMeta)for(var e=0;e<t.includeMeta.length;e++)t.includeMeta[e]=t.includeMeta[e].toLowerCase();else t.includeMeta=[];if(t.excludeMeta)for(var e=0;e<t.excludeMeta.length;e++)t.excludeMeta[e]=t.excludeMeta[e].toLowerCase();else t.excludeMeta=[];t.durationError||(t.durationError=0),t.duration||(t.duration=-1),"undefined"==typeof t.hasAudio&&(t.hasAudio=i.HasAudio.DONT_CARE)},t}();n.AnimUtils=c},{"./Classes":7,"./animation_formats/LayerMocks":12}],5:[function(t,e,n){"use strict";var i=t("path"),a=t("jibo-cai-utils"),r=t("./Range"),o=t("./AnimUtils"),s=t("./Utils"),u=t("./Playback"),c=function(){function t(){this.framesToHold=-1,this.speed=1,this.scale=1,this.shouldFlipLeftRight=!1}return t}();n.Transform=c;var l=function(){function t(t,e,n,i){this.parent=t,this.meta=e,this.resourceRoot=n,this.animCache=i,this.name=e.name,this.durationRange=new r.Range(e.durationRange[0],e.durationRange[1])}return t.prototype.loadAnimationObject=function(){var t=this;return a.FileUtils.readFile(i.join(this.resourceRoot,this.meta.path)).then(function(e){var n;try{n=JSON.parse(e)}catch(e){throw"Parsing error: '"+e+"' in animation at path: '"+t.meta.path+"'"}return n})},t.prototype.createFromConfig=function(t){var e=this._getTransformation(t);return this._applyTransformation(e)},t.prototype._applyTransformation=function(t){var e=this,n=this.animCache?Promise.resolve(this.animCache):this.loadAnimationObject();return n.then(function(n){return e._applyTransformationToAnim(n,t)})},t.prototype._applyTransformationToAnim=function(t,e){var n=!1;if(e.layers&&o.AnimUtils.syncAnimLayers(t,e.layers),1!==e.scale){var i=e.scale;e.shouldFlipLeftRight&&(i*=-1,n=!0),o.AnimUtils.scaleBodyInPlace(t,i)}e.shouldFlipLeftRight&&(o.AnimUtils.flipScreenLeftRight(t),n||o.AnimUtils.scaleBodyInPlace(t,-1));var a=this.meta.duration;return e.speed!==-1&&(a*=e.speed),e.framesToHold!==-1&&(a+=e.framesToHold),new u.Playback(a,e.speed,e.framesToHold,this.resourceRoot,t,this)},t.prototype._getTransformation=function(t){var e=new c;if(t){if(t.orientation){var n=t.orientation;n!==this.meta.orientation&&(e.shouldFlipLeftRight=!0)}t.speed&&(e.speed=s.Utils.limitToRange(t.speed,this.meta.speed)),t.scale&&(e.scale=s.Utils.limitToRange(t.scale,this.meta.scale)),t.layers&&(e.layers=t.layers),t.duration&&(t.duration<this.meta.durationRange[0]?e.speed=this.meta.speed[0]:t.duration<e.speed*this.meta.duration?(e.speed=t.duration/this.meta.duration,e.speed=s.Utils.limitToRange(e.speed,this.meta.speed)):this.meta.holdSafeKF!==-1?e.framesToHold=t.duration-e.speed*this.meta.duration:t.duration>e.speed*this.meta.duration&&"number"!=typeof t.speed&&(e.speed=t.duration/this.meta.duration,e.speed=s.Utils.limitToRange(e.speed,this.meta.speed)))}return e},t}();n.Animation=l},{"./AnimUtils":4,"./Playback":8,"./Range":9,"./Utils":10,"jibo-cai-utils":void 0,path:void 0}],6:[function(t,e,n){"use strict";var i=t("./Utils"),a=t("./AnimUtils"),r=t("./Classes"),o=function(){function t(t){this.name=t,this.animations=[],this.animationsByName=new Map}return t.prototype.addAnimation=function(t){this.animations.push(t),this.animationsByName.set(t.name,t)},t.prototype.query=function(t){a.AnimUtils.insertDefaultAnimQueryParams(t);var e=new r.AnimResults;return this._query(t,e),e},t.prototype._query=function(t,e){i.Utils.getAnimationsByQuery(this.animations,e,t)},t}();n.Category=o},{"./AnimUtils":4,"./Classes":7,"./Utils":10}],7:[function(t,e,n){"use strict";var i;!function(t){t[t.LEFT="LEFT"]="LEFT",t[t.RIGHT="RIGHT"]="RIGHT"}(i=n.Orientation||(n.Orientation={}));var a;!function(t){t[t.YES="YES"]="YES",t[t.NO="NO"]="NO",t[t.DONT_CARE="DONT_CARE"]="DONT_CARE"}(a=n.HasAudio||(n.HasAudio={}));var r=function(){function t(){this.matching=[],this.nonMatching=[]}return t}();n.AnimResults=r;var o=function(){function t(){this.meta=[]}return t}();n.SearchResults=o},{}],8:[function(t,e,n){"use strict";var i=t("jibo-cai-utils"),a=t("./AnimUtils"),r=30,o=function(){function t(t,e,n,i,a,r){this.duration=t,this.speed=e,this._framesToHold=n,this._resourceRoot=i,this._animData=a,this._animation=r,this._audioOnly=!1}return t.prototype.init=function(t){var e=this._animation.parent.parent.jibo;return 1===this._animData.layers.length&&this._animData.layers[0].type===a.LayerName.AudioEvent.long&&(a.AnimUtils._addMockLayer(this._animData,a.LayerName.Body.short),this._audioOnly=!0),this.keysPlaybackPr=i.PlaybackUtils.createKeysPlayback({jibo:e,animData:this._animData,rootPath:this._resourceRoot}),this.keysPlaybackPr},t.prototype.play=function(t){var e=this;void 0===t&&(t={});var n=this._animation.parent.parent.jibo,o=function(t,n){n.setPaused&&(n.setPaused(!0),i.TimeUtils.wait(e._framesToHold/r*1e3).then(function(){return n.setPaused(!1)}))},s=this.keysPlaybackPr||this.init(t),u=function(n){n.setSpeed(e.speed),n.on("HOLD_SAFE",o),e._audioOnly&&n.setLayer(a.BuilderLayer.beat),t.handleBuilder&&t.handleBuilder(n)};return s.then(function(e){return e.play(u,t.handleAnimation,t.screenCenterOverride)}).then(function(){if(t.forceReturnToIdle)return i.PromiseUtils.promisify(function(t){return n.animate.centerRobot(n.animate.dofs.BODY,null,t)})}).then(function(){return null})},t}();n.Playback=o},{"./AnimUtils":4,"jibo-cai-utils":void 0}],9:[function(t,e,n){"use strict";n.INFINITE_DURATION=1e6;var i=function(){function t(t,e){if(this.min=t,this.max=e,t>e)throw new Error("Invalid bounds "+this.toString())}return t.prototype.toString=function(){return"["+this.min+", "+this.max+"]"},t.prototype.limit=function(t){return t<this.min?this.min:t>this.max?this.max:t},t.prototype.isUpperInfinite=function(){return this.max===n.INFINITE_DURATION},t.prototype.distanceFrom=function(t){return t<this.min?this.min-t:t>this.max?t-this.max:0},t}();n.Range=i},{}],10:[function(t,e,n){"use strict";var i=t("./Classes"),a=t("semver-utils"),r=function(){function t(){}return t.parseString=function(t,e){return t&&t.length?t:e},t.parseNumber=function(t,e){if("number"==typeof t)return t;if(!t||!t.length)return e;try{var n=parseFloat(t);return n}catch(t){return e}},t.parseSemVer=function(t){var e=a.parse(t);return{semver:e.semver,version:e.version,major:parseInt(e.major),minor:parseInt(e.minor),patch:parseInt(e.patch),release:e.release}},t.getAnimationsByQuery=function(e,n,i){e.forEach(function(e){t.audioMatch(e,i.hasAudio)&&t.metaMatch(e,i.includeMeta,i.excludeMeta)&&t.addIfDurationMatch(e,i.duration,i.durationError,n)})},t.audioMatch=function(t,e){return e===i.HasAudio.DONT_CARE||e===i.HasAudio.YES&&t.meta.hasAudio||e===i.HasAudio.NO&&!t.meta.hasAudio},t.metaMatch=function(t,e,n){return!(e.length>0||n.length>0)||(e.length>0&&n.length>0?t.meta.metaTerms.some(function(t){return e.indexOf(t)!==-1})&&t.meta.metaTerms.every(function(t){return n.indexOf(t)===-1}):e.length>0?t.meta.metaTerms.some(function(t){return e.indexOf(t)!==-1}):n.length>0?t.meta.metaTerms.every(function(t){return n.indexOf(t)===-1}):void 0)},t.addIfDurationMatch=function(e,n,i,a){if(n===-1)a.matching.push(e);else{var r=t.distanceFromRange(n,e.meta.durationRange);0===r?a.matching.push(e):r<=i&&a.nonMatching.push(e)}},t.limitToRange=function(t,e){return t<e[0]?e[0]:t>e[1]?e[1]:t},t.distanceFromRange=function(t,e){return t<e[0]?e[0]-t:t>e[1]?t-e[1]:0},t}();n.Utils=r},{"./Classes":7,"semver-utils":void 0}],11:[function(t,e,n){"use strict"},{}],12:[function(t,e,n){"use strict";var i=t("jibo-keyframes").generateId,a=function(){function t(){}return t.generateLayer=function(t,e){var n={};return n.id=i(),n.name=t,n.type=e,n.visible=!0,n.locked=!1,n.keyframes=[],n},t}();n.LayerTemplate=a},{"jibo-keyframes":void 0}],13:[function(t,e,n){"use strict";function i(t){for(var e in t)n.hasOwnProperty(e)||(n[e]=t[e])}i(t("./LayerMocks"));var a=t("./0_6_X");n.format_0_6_x=a},{"./0_6_X":11,"./LayerMocks":12}],14:[function(t,e,n){"use strict";function i(t){for(var e in t)n.hasOwnProperty(e)||(n[e]=t[e])}i(t("./AnimDB")),i(t("./Range")),i(t("./AnimDBParser")),i(t("./AnimUtils")),i(t("./AnimCollection")),i(t("./Playback")),i(t("./Animation")),i(t("./Classes")),i(t("./AnimUtils")),i(t("./Utils"));var a=t("./animation_formats");n.animation_formats=a},{"./AnimCollection":1,"./AnimDB":2,"./AnimDBParser":3,"./AnimUtils":4,"./Animation":5,"./Classes":7,"./Playback":8,"./Range":9,"./Utils":10,"./animation_formats":13}],15:[function(t,e,n){"use strict";function i(t){for(var e in t)n.hasOwnProperty(e)||(n[e]=t[e])}i(t("./main"))},{"./main":14}]},{},[15])(15)}); | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.jiboAnimDb=e()}}(function(){return function e(t,n,i){function a(o,s){if(!n[o]){if(!t[o]){var u="function"==typeof require&&require;if(!s&&u)return u(o,!0);if(r)return r(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return a(n?n:e)},l,l.exports,e,t,n,i)}return n[o].exports}for(var r="function"==typeof require&&require,o=0;o<i.length;o++)a(i[o]);return a}({1:[function(e,t,n){"use strict";var i=e("./Utils"),a=e("./Classes"),r=e("./AnimUtils"),o=function(){function e(e){this.parent=e,this.animations=[],this.categories=[],this._animationsByName=new Map,this._categoriesByName=new Map}return e.prototype.addAnimation=function(e){var t=e.name.toLowerCase();this._animationsByName.has(t)||(this._animationsByName.set(t,e),this.animations.push(e))},e.prototype.addCategory=function(e){var t=e.name.toLowerCase();this._categoriesByName.has(t)||(this._categoriesByName.set(t,e),this.categories.push(e))},e.prototype.getCategoryByName=function(e){return this._categoriesByName.get(e.toLowerCase())},e.prototype.getAnimByName=function(e){return this._animationsByName.get(e.toLowerCase())},e.prototype.getAnimationNames=function(){return Array.from(this._animationsByName.keys())},e.prototype.getAnimationCategories=function(){return Array.from(this._categoriesByName.keys())},e.prototype.search=function(e){var t=e.toLowerCase(),n=new a.SearchResults;return this._search(t,n),n},e.prototype.query=function(e){r.AnimUtils.insertDefaultAnimQueryParams(e);var t=new a.AnimResults;this._query(e,t);var n=[];new Set(t.matching).forEach(function(e){return n.push(e)}),t.matching=n;var i=[];return new Set(t.nonMatching).forEach(function(e){return i.push(e)}),t.nonMatching=i,t},e.prototype._search=function(e,t){var n=this._categoriesByName.get(e);n&&(t.category=n);var i=this._animationsByName.get(e);i&&(t.name=i),this.animations.forEach(function(n){n.meta.metaTerms.forEach(function(i){i===e&&t.meta.push(n)})})},e.prototype._query=function(e,t){var n=this;e.categories.length?e.categories.forEach(function(i){var a=n._categoriesByName.get(i);a&&a._query(e,t)}):i.Utils.getAnimationsByQuery(this.animations,t,e)},e}();n.AnimCollection=o},{"./AnimUtils":4,"./Classes":7,"./Utils":10}],2:[function(e,t,n){"use strict";var i=e("./Classes"),a=e("./AnimUtils"),r=function(){function e(e){this.collections=[],this.jibo=e}return e.prototype.push=function(e){this.collections.push(e)},e.prototype.pop=function(){return this.collections.pop()},e.prototype.getAnimByName=function(e){for(var t,n=0;n<this.collections.length;n++){var i=this.collections[n],a=i.getAnimByName(e);if(a){t=a;break}}return t},e.prototype.getAnimationNames=function(){for(var e=[],t=0;t<this.collections.length;t++)e=e.concat(this.collections[t].getAnimationNames());return e},e.prototype.getAnimationCategories=function(){for(var e=[],t=0;t<this.collections.length;t++)e=e.concat(this.collections[t].getAnimationCategories());return e},e.prototype.search=function(e){var t=e.toLowerCase(),n=new i.SearchResults;return this.collections.forEach(function(e){e._search(t,n)}),n},e.prototype.query=function(e){a.AnimUtils.insertDefaultAnimQueryParams(e);var t=new i.AnimResults;this.collections.forEach(function(n){n._query(e,t)});var n=[];new Set(t.matching).forEach(function(e){return n.push(e)}),t.matching=n;var r=[];return new Set(t.nonMatching).forEach(function(e){return r.push(e)}),t.nonMatching=r,t},e}();n.AnimDB=r},{"./AnimUtils":4,"./Classes":7}],3:[function(e,t,n){"use strict";var i=e("path"),a=e("fs"),r=e("jibo-cai-utils"),o=e("./AnimDB"),s=e("./AnimCollection"),u=e("./Animation"),c=e("./Category"),l=e("./AnimUtils"),m=e("./Utils"),f=e("./Range"),h=e("json-stable-stringify"),y=function(){function e(){}return e.readAnimDB=function(t,n){for(var i=[],a=2;a<arguments.length;a++)i[a-2]=arguments[a];i.unshift(n);var r=new o.AnimDB(t),s=i.map(function(t){return e.readAndAddAnimCollection(r,t)});return Promise.all(s).then(function(){return r})},e.readAndAddAnimCollection=function(e,t){var n=i.dirname(t);return r.FileUtils.readFile(t).then(function(t){for(var i=JSON.parse(t),a=new s.AnimCollection(e),r=function(e){var t=i[e];e=t.name.toLowerCase();var r=new u.Animation(a,t,n),o=a.getAnimByName(r.name);if(o){var s=[o.meta.path,t.path];throw new Error("Duplicate animation name: '"+e+"' at paths: "+s)}a.addAnimation(r),r.meta.categories.forEach(function(e){var t=a.getCategoryByName(e);t||(t=new c.Category(e),a.addCategory(t)),t.addAnimation(r)})},o=0,l=Object.keys(i);o<l.length;o++){var m=l[o];r(m)}e.push(a)})},e.createAndWriteAnimMetaData=function(t,n,o){return e.createAnimMetaData(t,n).then(function(e){var t=i.join(n,o+".json"),s=h(e,{space:" "});return r.PromiseUtils.promisify(function(e){return a.writeFile(t,s,"utf8",e)})})},e.createAnimMetaData=function(t,n){var a=i.join(n,"animations");return r.FileUtils.findAllFilesWithExt(a,"keys").then(function(n){var a=n.filter(function(e){return!i.basename(e).startsWith("_")}),r=a.map(function(n){return e.parseAnimation(t,n)});return Promise.all(r)}).then(function(e){var t=e,a=i.resolve(n),r={};return t.forEach(function(e){var t=e.path.substring(0,a.length);if(t!==a)throw new Error("Animation doesn't have the expected root path: "+[e.path,a]);if(e.path=e.path.substring(a.length+i.sep.length),r[e.name]){var n=[r[e.name].path,e.path];throw new Error("Duplicate animation name: '"+e.name+"' at paths: "+n)}r[e.name]=e}),r})},e.parseAnimation=function(t,n){return e.loadKeys(t,n).then(function(t){return e.parseAnimationFromAnim(t,n)})},e.loadKeys=function(e,t){return new e.rendering.animation.KeysLoader(t).load()},e.parseAnimationFromAnim=function(e,t){var n,a,r,o;try{var s=i.basename(t,i.extname(t));n=e.animdb||{},o=m.Utils.parseString(n.name,s),a=[m.Utils.parseNumber(n.scaleMin,1),m.Utils.parseNumber(n.scaleMax,1)],r=[m.Utils.parseNumber(n.speedMin,1),m.Utils.parseNumber(n.speedMax,1)]}catch(e){throw new Error("Error parsing animation at path '"+t+"': '"+e+"'")}if(r[0]<=0||r[0]>r[1])throw new Error("Invalid speed bounds '"+JSON.stringify(r)+"' for animation '"+t+"'");if(a[0]>a[1])throw new Error("Invalid scale bounds '"+JSON.stringify(a)+"' for animation '"+t+"'");var u=n.categories||"",c=[];u.split(",").forEach(function(e){var t=e.trim().toLowerCase();t.length&&c.push(t)});var h=n.meta||"",y=[];h.split(",").forEach(function(e){var t=e.trim().toLowerCase();t.length&&y.push(t)});var d=l.AnimUtils.hasHoldSafe(e,o),p=[r[0]*e.duration,r[1]*e.duration];d!==-1&&(p[1]=f.INFINITE_DURATION);var v={name:o,scale:a,speed:r,durationRange:p,categories:c,metaTerms:y,holdSafeKF:d,path:t,duration:e.duration,startsNeutral:l.AnimUtils.startsNeutral(e),endsNeutral:l.AnimUtils.endsNeutral(e),hasAudio:l.AnimUtils.hasAudio(e),orientation:l.AnimUtils.calculateOrientation(e),layers:l.AnimUtils.checkLayers(e)};return v},e}();n.AnimDBParser=y},{"./AnimCollection":1,"./AnimDB":2,"./AnimUtils":4,"./Animation":5,"./Category":6,"./Range":9,"./Utils":10,fs:void 0,"jibo-cai-utils":void 0,"json-stable-stringify":void 0,path:void 0}],4:[function(e,t,n){"use strict";var i=e("./Classes"),a=e("./animation_formats/LayerMocks"),r=3,o="HOLD_SAFE",s=function(){function e(){}return e.syncAnimLayers=function(t,n){for(var a=t.layers.length-1;a>=0;a--){var r=t.layers[a].type;i.LayerName[r]||(r=r.replace(/\s/g,"")),void 0===n[r]||n[r]||t.layers.splice(a,1)}Object.keys(n).forEach(function(e){n[e]||delete n[e]});var o=Object.keys(n).filter(function(n){return!e.hasLayer(t,i.LayerName[n],!1)});o.forEach(function(n){return e._addMockLayer(t,i.LayerName[n].long||i.LayerName[n].short)})},e._addMockLayer=function(e,t){e.layers.push(a.LayerTemplate.generateLayer(t,t))},e.scaleTimeInPlace=function(e,t){e.layers.forEach(function(e){e.keyframes.forEach(function(e){e.time=Math.round(e.time*t)})}),e.duration=Math.round(e.duration*t)},e.scaleBodyInPlace=function(t,n){e.forEachLayerType(t,i.LayerName.Body,function(e){e.keyframes.forEach(function(e){e.value.Head*=n,e.value.Pelvis*=n,e.value.Torso*=n})})},e.flipScreenLeftRight=function(t){var n=function(e){e.keyframes.forEach(function(e){e.value.Translate.x*=-1})};e.forEachLayerType(t,i.LayerName.Eye,n),e.forEachLayerType(t,i.LayerName.Overlay,n)},e.startsNeutral=function(t){var n=!0,a=t.duration;return e.forEachLayerType(t,i.LayerName.Body,function(e){if(e.keyframes.length){var t=e.keyframes[0];t.time<a&&(a=t.time,(Math.abs(t.value.Pelvis)>r||Math.abs(t.value.Head)>r||Math.abs(t.value.Torso)>r)&&(n=!1))}}),n},e.endsNeutral=function(t){var n=!0,a=-1;return e.forEachLayerType(t,i.LayerName.Body,function(e){if(e.keyframes.length){var t=e.keyframes[e.keyframes.length-1];t.time>a&&(a=t.time,(Math.abs(t.value.Pelvis)>r||Math.abs(t.value.Head)>r||Math.abs(t.value.Torso)>r)&&(n=!1))}}),n},e.checkLayers=function(t,n){void 0===n&&(n=!0);var a={};return i.LayerName.Layers.forEach(function(i){e.hasLayer(t,i,n)&&(a[i.short]=!0)}),a},e.hasAudio=function(t){return e.hasLayer(t,i.LayerName.AudioEvent)},e.hasLayer=function(t,n,i){void 0===i&&(i=!0);var a=[];return e.forEachLayerType(t,n,function(e){i?a.push(0!==e.keyframes.length):a.push(!0)}),a.some(function(e){return e})},e.hasHoldSafe=function(t,n){var a=-1;return e.forEachLayerType(t,i.LayerName.Event,function(e){e.keyframes.forEach(function(e){if(e.value.Event.name===o){if(a!==-1)throw new Error("Two HOLD_SAFE keyframes defined in animation"+(" '"+n+"' at frames "+a+" and "+e.time));a=e.time}})}),a},e.calculateOrientation=function(t){var n=0,a=0,r=0,o=0;e.forEachLayerType(t,i.LayerName.Body,function(e){e.keyframes.forEach(function(e){o++,n+=e.value.Head,a+=e.value.Pelvis,r+=e.value.Torso})}),n/=o,a/=o,r/=o;var s=(r+a)/2;return Math.abs(s)>10?s>0?i.Orientation.LEFT:i.Orientation.RIGHT:n>0?i.Orientation.LEFT:i.Orientation.RIGHT},e.forEachLayerType=function(e,t,n){var i=t.long||t.short,a=i+" #";e.layers.forEach(function(e){(e.name===i||e.name.startsWith(a))&&n(e)})},e.insertDefaultAnimQueryParams=function(e){e.categories||(e.categories=[]),e.category&&e.categories.push(e.category);for(var t=0;t<e.categories.length;t++)e.categories[t]=e.categories[t].toLowerCase();if(e.includeMeta)for(var t=0;t<e.includeMeta.length;t++)e.includeMeta[t]=e.includeMeta[t].toLowerCase();else e.includeMeta=[];if(e.excludeMeta)for(var t=0;t<e.excludeMeta.length;t++)e.excludeMeta[t]=e.excludeMeta[t].toLowerCase();else e.excludeMeta=[];e.durationError||(e.durationError=0),e.duration||(e.duration=-1),"undefined"==typeof e.hasAudio&&(e.hasAudio=i.HasAudio.DONT_CARE)},e}();n.AnimUtils=s},{"./Classes":7,"./animation_formats/LayerMocks":12}],5:[function(e,t,n){"use strict";var i=e("path"),a=e("jibo-cai-utils"),r=e("./Range"),o=e("./AnimUtils"),s=e("./Utils"),u=e("./Playback"),c=function(){function e(){this.framesToHold=-1,this.speed=1,this.scale=1,this.shouldFlipLeftRight=!1}return e}();n.Transform=c;var l=function(){function e(e,t,n,i){this.parent=e,this.meta=t,this.resourceRoot=n,this.animCache=i,this.name=t.name,this.durationRange=new r.Range(t.durationRange[0],t.durationRange[1])}return e.prototype.loadAnimationObject=function(){var e=this;return a.FileUtils.readFile(i.join(this.resourceRoot,this.meta.path)).then(function(t){var n;try{n=JSON.parse(t)}catch(t){throw"Parsing error: '"+t+"' in animation at path: '"+e.meta.path+"'"}return n})},e.prototype.createFromConfig=function(e){var t=this._getTransformation(e);return this._applyTransformation(t)},e.prototype._applyTransformation=function(e){var t=this,n=this.animCache?Promise.resolve(this.animCache):this.loadAnimationObject();return n.then(function(n){return t._applyTransformationToAnim(n,e)})},e.prototype._applyTransformationToAnim=function(e,t){var n=!1;if(t.layers&&o.AnimUtils.syncAnimLayers(e,t.layers),1!==t.scale){var i=t.scale;t.shouldFlipLeftRight&&(i*=-1,n=!0),o.AnimUtils.scaleBodyInPlace(e,i)}t.shouldFlipLeftRight&&(o.AnimUtils.flipScreenLeftRight(e),n||o.AnimUtils.scaleBodyInPlace(e,-1));var a=this.meta.duration;return t.speed!==-1&&(a*=t.speed),t.framesToHold!==-1&&(a+=t.framesToHold),new u.Playback(a,t.speed,t.framesToHold,this.resourceRoot,e,this)},e.prototype._getTransformation=function(e){var t=new c;if(e){if(e.orientation){var n=e.orientation;n!==this.meta.orientation&&(t.shouldFlipLeftRight=!0)}e.speed&&(t.speed=s.Utils.limitToRange(e.speed,this.meta.speed)),e.scale&&(t.scale=s.Utils.limitToRange(e.scale,this.meta.scale)),e.layers&&(t.layers=e.layers),e.duration&&(e.duration<this.meta.durationRange[0]?t.speed=this.meta.speed[0]:e.duration<t.speed*this.meta.duration?(t.speed=e.duration/this.meta.duration,t.speed=s.Utils.limitToRange(t.speed,this.meta.speed)):this.meta.holdSafeKF!==-1?t.framesToHold=e.duration-t.speed*this.meta.duration:e.duration>t.speed*this.meta.duration&&"number"!=typeof e.speed&&(t.speed=e.duration/this.meta.duration,t.speed=s.Utils.limitToRange(t.speed,this.meta.speed)))}return t},e}();n.Animation=l},{"./AnimUtils":4,"./Playback":8,"./Range":9,"./Utils":10,"jibo-cai-utils":void 0,path:void 0}],6:[function(e,t,n){"use strict";var i=e("./Utils"),a=e("./AnimUtils"),r=e("./Classes"),o=function(){function e(e){this.name=e,this.animations=[],this.animationsByName=new Map}return e.prototype.addAnimation=function(e){this.animations.push(e),this.animationsByName.set(e.name,e)},e.prototype.query=function(e){a.AnimUtils.insertDefaultAnimQueryParams(e);var t=new r.AnimResults;return this._query(e,t),t},e.prototype._query=function(e,t){i.Utils.getAnimationsByQuery(this.animations,t,e)},e}();n.Category=o},{"./AnimUtils":4,"./Classes":7,"./Utils":10}],7:[function(e,t,n){"use strict";var i;!function(e){e[e.LEFT="LEFT"]="LEFT",e[e.RIGHT="RIGHT"]="RIGHT"}(i=n.Orientation||(n.Orientation={}));var a;!function(e){e[e.YES="YES"]="YES",e[e.NO="NO"]="NO",e[e.DONT_CARE="DONT_CARE"]="DONT_CARE"}(a=n.HasAudio||(n.HasAudio={}));var r=function(){function e(){this.matching=[],this.nonMatching=[]}return e}();n.AnimResults=r;var o=function(){function e(){this.meta=[]}return e}();n.SearchResults=o;var s=function(){function e(e,t){this.short=e,this.long=t}return e}();s.Body=new s("Body"),s.Eye=new s("Eye"),s.EyeTexture=new s("EyeTexture","Eye Texture"),s.Overlay=new s("Overlay"),s.OverlayTexture=new s("OverlayTexture","Overlay Texture"),s.AudioEvent=new s("AudioEvent","Audio Event"),s.Event=new s("Event"),s.Pixi=new s("Pixi"),s.BackgroundTexture=new s("BackgroundTexture","Background Texture"),s.LED=new s("LED"),s.Glow=new s("Glow"),s.Lighting=new s("Lighting"),s.Layers=[s.Body,s.Eye,s.EyeTexture,s.Overlay,s.OverlayTexture,s.AudioEvent,s.Event,s.Pixi,s.BackgroundTexture,s.LED,s.Glow,s.Lighting],n.LayerName=s;var u;!function(e){e[e.beat="beat"]="beat",e[e.default="default"]="default",e[e.posture="posture"]="posture"}(u=n.BuilderLayer||(n.BuilderLayer={}))},{}],8:[function(e,t,n){"use strict";var i=e("jibo-cai-utils"),a=e("./Classes"),r=e("./AnimUtils"),o=30,s=function(){function e(e,t,n,i,a,r){this.duration=e,this.speed=t,this._framesToHold=n,this._resourceRoot=i,this._animData=a,this._animation=r,this._audioOnly=!1}return e.prototype.init=function(){var e=this._animation.parent.parent.jibo;return 1===this._animData.layers.length&&this._animData.layers[0].type===a.LayerName.AudioEvent.long&&(r.AnimUtils._addMockLayer(this._animData,a.LayerName.Body.short),this._audioOnly=!0),this.keysPlaybackPr=i.PlaybackUtils.createKeysPlayback({jibo:e,animData:this._animData,rootPath:this._resourceRoot}),this.keysPlaybackPr},e.prototype.play=function(e){var t=this;void 0===e&&(e={});var n=this._animation.parent.parent.jibo,r=function(e,n){n.setPaused&&(n.setPaused(!0),i.TimeUtils.wait(t._framesToHold/o*1e3).then(function(){return n.setPaused(!1)}))},s=this.keysPlaybackPr||this.init(),u=function(n){n.setSpeed(t.speed),n.on("HOLD_SAFE",r),t._audioOnly&&n.setLayer(a.BuilderLayer.beat),e.handleBuilder&&e.handleBuilder(n)};return s.then(function(t){return t.play(u,e.handleAnimation,e.screenCenterOverride)}).then(function(){if(e.forceReturnToIdle)return i.PromiseUtils.promisify(function(e){return n.animate.centerRobot(n.animate.dofs.BODY,null,e)})}).then(function(){return null})},e}();n.Playback=s},{"./AnimUtils":4,"./Classes":7,"jibo-cai-utils":void 0}],9:[function(e,t,n){"use strict";n.INFINITE_DURATION=1e6;var i=function(){function e(e,t){if(this.min=e,this.max=t,e>t)throw new Error("Invalid bounds "+this.toString())}return e.prototype.toString=function(){return"["+this.min+", "+this.max+"]"},e.prototype.limit=function(e){return e<this.min?this.min:e>this.max?this.max:e},e.prototype.isUpperInfinite=function(){return this.max===n.INFINITE_DURATION},e.prototype.distanceFrom=function(e){return e<this.min?this.min-e:e>this.max?e-this.max:0},e}();n.Range=i},{}],10:[function(e,t,n){"use strict";var i=e("./Classes"),a=e("semver-utils"),r=function(){function e(){}return e.parseString=function(e,t){return e&&e.length?e:t},e.parseNumber=function(e,t){if("number"==typeof e)return e;if(!e||!e.length)return t;try{var n=parseFloat(e);return n}catch(e){return t}},e.parseSemVer=function(e){var t=a.parse(e);return{semver:t.semver,version:t.version,major:parseInt(t.major),minor:parseInt(t.minor),patch:parseInt(t.patch),release:t.release}},e.getAnimationsByQuery=function(t,n,i){t.forEach(function(t){e.audioMatch(t,i.hasAudio)&&e.metaMatch(t,i.includeMeta,i.excludeMeta)&&e.addIfDurationMatch(t,i.duration,i.durationError,n)})},e.audioMatch=function(e,t){return t===i.HasAudio.DONT_CARE||t===i.HasAudio.YES&&e.meta.hasAudio||t===i.HasAudio.NO&&!e.meta.hasAudio},e.metaMatch=function(e,t,n){return!(t.length>0||n.length>0)||(t.length>0&&n.length>0?e.meta.metaTerms.some(function(e){return t.indexOf(e)!==-1})&&e.meta.metaTerms.every(function(e){return n.indexOf(e)===-1}):t.length>0?e.meta.metaTerms.some(function(e){return t.indexOf(e)!==-1}):n.length>0?e.meta.metaTerms.every(function(e){return n.indexOf(e)===-1}):void 0)},e.addIfDurationMatch=function(t,n,i,a){if(n===-1)a.matching.push(t);else{var r=e.distanceFromRange(n,t.meta.durationRange);0===r?a.matching.push(t):r<=i&&a.nonMatching.push(t)}},e.limitToRange=function(e,t){return e<t[0]?t[0]:e>t[1]?t[1]:e},e.distanceFromRange=function(e,t){return e<t[0]?t[0]-e:e>t[1]?e-t[1]:0},e}();n.Utils=r},{"./Classes":7,"semver-utils":void 0}],11:[function(e,t,n){"use strict"},{}],12:[function(e,t,n){"use strict";var i=e("jibo-keyframes").generateId,a=function(){function e(){}return e.generateLayer=function(e,t){var n={};return n.id=i(),n.name=e,n.type=t,n.visible=!0,n.locked=!1,n.keyframes=[],n},e}();n.LayerTemplate=a},{"jibo-keyframes":void 0}],13:[function(e,t,n){"use strict";function i(e){for(var t in e)n.hasOwnProperty(t)||(n[t]=e[t])}i(e("./LayerMocks"));var a=e("./0_6_X");n.format_0_6_x=a},{"./0_6_X":11,"./LayerMocks":12}],14:[function(e,t,n){"use strict";function i(e){for(var t in e)n.hasOwnProperty(t)||(n[t]=e[t])}function a(e,t){for(var i=[],a=2;a<arguments.length;a++)i[a-2]=arguments[a];return f(this,void 0,void 0,function(){return h(this,function(a){switch(a.label){case 0:return t?[3,1]:(n._animDB=new v.AnimDB(e),[3,3]);case 1:return[4,y.AnimDBParser.readAnimDB.apply(y.AnimDBParser,[e,t].concat(i))];case 2:n._animDB=a.sent(),a.label=3;case 3:return[2]}})})}function r(e){return n._animDB.getAnimByName(e)}function o(){return n._animDB.getAnimationNames()}function s(){return n._animDB.getAnimationCategories()}function u(e){return n._animDB.search(e)}function c(e){return n._animDB.query(e)}function l(e){n._animDB.push(e)}function m(){return n._animDB.pop()}var f=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))(function(a,r){function o(e){try{u(i.next(e))}catch(e){r(e)}}function s(e){try{u(i.throw(e))}catch(e){r(e)}}function u(e){e.done?a(e.value):new n(function(t){t(e.value)}).then(o,s)}u((i=i.apply(e,t||[])).next())})},h=this&&this.__generator||function(e,t){function n(e){return function(t){return i([e,t])}}function i(n){if(a)throw new TypeError("Generator is already executing.");for(;s;)try{if(a=1,r&&(o=r[2&n[0]?"return":n[0]?"throw":"next"])&&!(o=o.call(r,n[1])).done)return o;switch(r=0,o&&(n=[0,o.value]),n[0]){case 0:case 1:o=n;break;case 4:return s.label++,{value:n[1],done:!1};case 5:s.label++,r=n[1],n=[0];continue;case 7:n=s.ops.pop(),s.trys.pop();continue;default:if(o=s.trys,!(o=o.length>0&&o[o.length-1])&&(6===n[0]||2===n[0])){s=0;continue}if(3===n[0]&&(!o||n[1]>o[0]&&n[1]<o[3])){s.label=n[1];break}if(6===n[0]&&s.label<o[1]){s.label=o[1],o=n;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(n);break}o[2]&&s.ops.pop(),s.trys.pop();continue}n=t.call(e,s)}catch(e){n=[6,e],r=0}finally{a=o=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}var a,r,o,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return{next:n(0),throw:n(1),return:n(2)}},y=e("./AnimDBParser");n.AnimDBParser=y.AnimDBParser;var d=e("./AnimCollection");n.AnimCollection=d.AnimCollection;var p=e("./Animation");n.Animation=p.Animation;var v=e("./AnimDB");n.AnimDB=v.AnimDB;var g=e("./Playback");n.Playback=g.Playback,i(e("./animation_formats")),i(e("./Classes")),n.init=a,n.getAnimByName=r,n.getAnimationNames=o,n.getAnimationCategories=s,n.search=u,n.query=c,n.push=l,n.pop=m},{"./AnimCollection":1,"./AnimDB":2,"./AnimDBParser":3,"./Animation":5,"./Classes":7,"./Playback":8,"./animation_formats":13}],15:[function(e,t,n){"use strict";function i(e){for(var t in e)n.hasOwnProperty(t)||(n[t]=e[t])}i(e("./AnimDB")),i(e("./Range")),i(e("./AnimDBParser")),i(e("./AnimUtils")),i(e("./AnimCollection")),i(e("./Playback")),i(e("./Animation")),i(e("./Classes")),i(e("./AnimUtils")),i(e("./Utils"));var a=e("./api");n.api=a;var r=e("./animation_formats");n.animation_formats=r},{"./AnimCollection":1,"./AnimDB":2,"./AnimDBParser":3,"./AnimUtils":4,"./Animation":5,"./Classes":7,"./Playback":8,"./Range":9,"./Utils":10,"./animation_formats":13,"./api":14}],16:[function(e,t,n){"use strict";function i(e){for(var t in e)n.hasOwnProperty(t)||(n[t]=e[t])}i(e("./main"))},{"./main":15}]},{},[16])(16)}); |
jibo-anim-db - Provides query abstraction over a library of animations | ||
@version v3.0.0 | ||
@version v3.1.2 | ||
Copyright (c) 2017, Jibo, Inc. All rights reserved. | ||
@@ -4,0 +4,0 @@ All use of the Jibo SDK is subject to the Jibo SDK End User License Agreement (EULA) |
{ | ||
"name": "jibo-anim-db", | ||
"version": "3.0.0", | ||
"version": "3.1.2", | ||
"description": "Provides query abstraction over a library of animations", | ||
@@ -5,0 +5,0 @@ "main": "lib/jibo-anim-db.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
54749
22
957
2