diff --git a/packages/eva.js/README.md b/packages/eva.js/README.md index b212fe2c..ddea313d 100644 --- a/packages/eva.js/README.md +++ b/packages/eva.js/README.md @@ -1,7 +1,6 @@ - # @eva/eva.js More Introduction + - [EN](https://eva.js.org) - [中文](https://eva-engine.gitee.io) - \ No newline at end of file diff --git a/packages/eva.js/__tests__/__mocks__/requestAnimationFrame.ts b/packages/eva.js/__tests__/__mocks__/requestAnimationFrame.ts index 8f73396e..70e311c2 100644 --- a/packages/eva.js/__tests__/__mocks__/requestAnimationFrame.ts +++ b/packages/eva.js/__tests__/__mocks__/requestAnimationFrame.ts @@ -29,9 +29,5 @@ class RequestAnimationFrameMockSession { export const requestAnimationFrameMock = new RequestAnimationFrameMockSession(); -window.requestAnimationFrame = requestAnimationFrameMock.requestAnimationFrame.bind( - requestAnimationFrameMock, -); -window.cancelAnimationFrame = requestAnimationFrameMock.cancelAnimationFrame.bind( - requestAnimationFrameMock, -); +window.requestAnimationFrame = requestAnimationFrameMock.requestAnimationFrame.bind(requestAnimationFrameMock); +window.cancelAnimationFrame = requestAnimationFrameMock.cancelAnimationFrame.bind(requestAnimationFrameMock); diff --git a/packages/eva.js/__tests__/__mocks__/resource-loader.ts b/packages/eva.js/__tests__/__mocks__/resource-loader.ts index b29e9669..8659f15a 100644 --- a/packages/eva.js/__tests__/__mocks__/resource-loader.ts +++ b/packages/eva.js/__tests__/__mocks__/resource-loader.ts @@ -117,4 +117,4 @@ export class XhrLoadStrategy { } } -export class VideoLoadStrategy {} \ No newline at end of file +export class VideoLoadStrategy {} diff --git a/packages/eva.js/__tests__/decorators.spec.ts b/packages/eva.js/__tests__/decorators.spec.ts index 64906c91..90d727df 100644 --- a/packages/eva.js/__tests__/decorators.spec.ts +++ b/packages/eva.js/__tests__/decorators.spec.ts @@ -1,6 +1,6 @@ -import {decorators, System} from '../lib'; +import { decorators, System } from '../lib'; -const {IDEProp, componentObserver} = decorators; +const { IDEProp, componentObserver } = decorators; describe('decorators', () => { it('ide decorator should collect props', () => { @@ -19,8 +19,8 @@ describe('decorators', () => { Transform: [ 'size', ['style', 'color'], - {prop: 'position', deep: false}, - {prop: ['transform', 'translate'], deep: true}, + { prop: 'position', deep: false }, + { prop: ['transform', 'translate'], deep: true }, ], }) class Test extends System {} diff --git a/packages/eva.js/__tests__/game.spec.ts b/packages/eva.js/__tests__/game.spec.ts index 124e0697..bc1f2472 100644 --- a/packages/eva.js/__tests__/game.spec.ts +++ b/packages/eva.js/__tests__/game.spec.ts @@ -1,7 +1,7 @@ -import {mocked} from 'ts-jest/utils'; -import {Game, Scene, GameObject, System} from '../lib'; +import { mocked } from 'ts-jest/utils'; +import { Game, Scene, GameObject, System } from '../lib'; import Ticker from '../lib/game/Ticker'; -import {TestSystem, Test2System, TestComponent} from '@eva/plugin-renderer-test'; +import { TestSystem, Test2System, TestComponent } from '@eva/plugin-renderer-test'; const MockTicker = mocked(Ticker, true); const mockTickerAdd = jest.fn(); @@ -75,7 +75,6 @@ describe('Game', () => { expect(game.systems.length).toBe(2); expect(game.systems[0]).toBeInstanceOf(TestSystem); expect(game.systems[1]).toBeInstanceOf(Test2System); - }); it('add system twice', () => { @@ -126,7 +125,7 @@ describe('Game', () => { game.addSystem(testSys); expect(game.systems.length).toBe(1); game.removeSystem(testSys); - expect(game.systems.length).toBe(0); + expect(game.systems.length).toBe(0); }); it('when throug in anything else', () => { @@ -162,14 +161,14 @@ describe('Game', () => { }); it('pause when pausing', () => { - const game = new Game({autoStart: false}); + const game = new Game({ autoStart: false }); game.pause(); expect(mockTickerPause).not.toBeCalled(); expect(game.playing).toBeFalsy(); }); it('start', () => { - const game = new Game({autoStart: false}); + const game = new Game({ autoStart: false }); game.addSystem(TestSystem); game.addSystem(Test2System); game.start(); @@ -185,7 +184,7 @@ describe('Game', () => { }); it('resume', () => { - const game = new Game({autoStart: false}); + const game = new Game({ autoStart: false }); game.addSystem(TestSystem); game.addSystem(Test2System); game.resume(); @@ -232,7 +231,7 @@ describe('Game', () => { }); it('trigger pause without scene', () => { - const game = new Game({needScene: false, systems: [new TestSystem(), new Test2System()]}); + const game = new Game({ needScene: false, systems: [new TestSystem(), new Test2System()] }); game.triggerPause(); }); @@ -255,7 +254,7 @@ describe('Game', () => { }); it('init ticker without scene', () => { - new Game({needScene: false}); + new Game({ needScene: false }); const fn = mockTickerAdd.mock.calls[0][0]; fn(); expect(mockTickerAdd).toBeCalled(); diff --git a/packages/eva.js/__tests__/gameObject.spec.ts b/packages/eva.js/__tests__/gameObject.spec.ts index 7196be5e..badda518 100644 --- a/packages/eva.js/__tests__/gameObject.spec.ts +++ b/packages/eva.js/__tests__/gameObject.spec.ts @@ -113,7 +113,7 @@ describe('GameObject', () => { expect(child.scene).toBeUndefined(); }); - it('do nothing if child\'s parent not this', () => { + it("do nothing if child's parent not this", () => { const parent = new GameObject('parent'); const parent2 = new GameObject('parent2'); const child = new GameObject('child'); @@ -203,9 +203,7 @@ describe('GameObject', () => { it('do nothing when Component.componentName not on gameObject', () => { const gameObj = new GameObject('gameObj'); - expect( - gameObj.removeComponent(TestComponent.componentName), - ).toBeUndefined(); + expect(gameObj.removeComponent(TestComponent.componentName)).toBeUndefined(); expect(gameObj.components.length).toBe(1); }); @@ -226,15 +224,15 @@ describe('GameObject', () => { const gameObj = new GameObject('gameObj'); expect(() => { gameObj.removeComponent('Transform'); - }).toThrow('Transform can\'t be removed'); + }).toThrow("Transform can't be removed"); expect(() => { gameObj.removeComponent(Transform.componentName); - }).toThrow('Transform can\'t be removed'); + }).toThrow("Transform can't be removed"); expect(() => { gameObj.removeComponent(gameObj.transform.name); - }).toThrow('Transform can\'t be removed'); + }).toThrow("Transform can't be removed"); }); it('getComponent by componentName', () => { diff --git a/packages/eva.js/__tests__/observer.spec.ts b/packages/eva.js/__tests__/observer.spec.ts index 9ab290ad..29ee919e 100644 --- a/packages/eva.js/__tests__/observer.spec.ts +++ b/packages/eva.js/__tests__/observer.spec.ts @@ -1,5 +1,5 @@ -import {TestSystem, TestComponent} from '@eva/plugin-renderer-test'; -import {GameObject, Transform} from '../lib'; +import { TestSystem, TestComponent } from '@eva/plugin-renderer-test'; +import { GameObject, Transform } from '../lib'; import { initObserver, setSystemObserver, @@ -30,14 +30,9 @@ describe('observer', () => { it('initObserver successfully', () => { initObserver([TestSystem]); - const { - componentProps, - systemInstance, - observerInfos, - } = testUtils.getLocal(); + const { componentProps, systemInstance, observerInfos } = testUtils.getLocal(); - const observerKeyCount = Object.keys(TestSystem.observerInfo['Test']) - .length; + const observerKeyCount = Object.keys(TestSystem.observerInfo['Test']).length; expect(componentProps['Test'].length).toBe(observerKeyCount); expect(systemInstance['Test']).toStrictEqual(system); expect(observerInfos['Test']).toStrictEqual(TestSystem.observerInfo); @@ -52,7 +47,7 @@ describe('observer', () => { observer(testComp, testComp.name); expect(testComp['_size']).toEqual([10, 10]); - expect(testComp['_style']).toMatchObject({color: 'rgba(255, 255, 255)'}); + expect(testComp['_style']).toMatchObject({ color: 'rgba(255, 255, 255)' }); expect(system.componentObserver.add).toHaveBeenCalledTimes(1); const size = [20, 20]; @@ -77,11 +72,11 @@ describe('observer', () => { const gameObj = new GameObject('gameObj'); gameObj.addComponent(testComp); - TestSystem.observerInfo['Test'].push({prop: ['transform'], deep: false}); + TestSystem.observerInfo['Test'].push({ prop: ['transform'], deep: false }); initObserver(TestSystem); observer(testComp, testComp.name); - const {componentProps} = testUtils.getLocal(); + const { componentProps } = testUtils.getLocal(); expect(componentProps['Test']).toContainEqual({ prop: ['transform'], deep: false, @@ -103,7 +98,7 @@ describe('observer', () => { }); it('should throw error when component not instanceof Component', () => { - const comp: any = {name: 'Test', size: [15, 15]}; + const comp: any = { name: 'Test', size: [15, 15] }; expect(() => { observer(comp); }).toThrow('component param must be an instance of Component'); @@ -174,12 +169,10 @@ describe('observer', () => { const testComp = new TestComponent(); gameObj.addComponent(testComp); - const {objectCache} = testUtils.getLocal(); + const { objectCache } = testUtils.getLocal(); expect(objectCache[gameObj.id]).toHaveProperty('Test_size'); expect(objectCache[gameObj.id]).toHaveProperty('Test_style'); - expect(objectCache[gameObj.id]).toHaveProperty( - 'Test_geomerty,data,vertex', - ); + expect(objectCache[gameObj.id]).toHaveProperty('Test_geomerty,data,vertex'); observerRemoved(testComp); expect(objectCache[gameObj.id]).toBeUndefined(); @@ -194,13 +187,13 @@ describe('observer', () => { it('observer add component is null', () => { expect(() => { observerRemoved(null, TestComponent.componentName); - }).toThrow('Cannot read property \'gameObject\' of null'); + }).toThrow("Cannot read property 'gameObject' of null"); }); it('component is undefined', () => { expect(() => { observerRemoved(undefined, TestComponent.componentName); - }).toThrow('Cannot read property \'gameObject\' of undefined'); + }).toThrow("Cannot read property 'gameObject' of undefined"); }); it('componentName is empty', () => { diff --git a/packages/eva.js/__tests__/resource.spec.ts b/packages/eva.js/__tests__/resource.spec.ts index 5d9b4ac3..214f2b07 100644 --- a/packages/eva.js/__tests__/resource.spec.ts +++ b/packages/eva.js/__tests__/resource.spec.ts @@ -69,7 +69,7 @@ describe('resource management', () => { res.on(LOAD_EVENT.COMPLETE, () => { expect(checkResourceSpy).toHaveBeenCalledTimes(1); done(); - }) + }); res.loadConfig([imageRes]); }); @@ -79,24 +79,24 @@ describe('resource management', () => { }); it('preload without resource', done => { - res.on(LOAD_EVENT.COMPLETE, (loader) => { + res.on(LOAD_EVENT.COMPLETE, loader => { expect(loader.resourceTotal).toBe(0); - done() - }) + done(); + }); res.preload(); }); it('preload with resources', done => { const progressSpy = jest.fn(); res.on(LOAD_EVENT.PROGRESS, progressSpy); - res.on(LOAD_EVENT.COMPLETE, (loader) => { + res.on(LOAD_EVENT.COMPLETE, loader => { expect(progressSpy).toBeCalledTimes(2); expect(loader.resourceTotal).toBe(2); done(); - }) + }); res.addResource([imageRes, imageRes2]); res.preload(); - }) + }); /** * 连续触发两次 preload,会导致 resourceManager 的 progress 属性被覆盖 @@ -105,10 +105,7 @@ describe('resource management', () => { res.loadConfig([imageRes]); res.loadConfig([imageRes2]); - const [image, dragonBone] = await Promise.all([ - res.getResource(imageRes.name), - res.getResource(imageRes2.name), - ]); + const [image, dragonBone] = await Promise.all([res.getResource(imageRes.name), res.getResource(imageRes2.name)]); expect(image).toMatchObject({}); expect(dragonBone).toMatchObject({}); @@ -171,7 +168,7 @@ describe('resource management', () => { res.on(LOAD_EVENT.COMPLETE, () => { expect(imageInstanceCallback).toHaveBeenCalled(); done(); - }) + }); res.loadConfig([imageRes]); }); diff --git a/packages/eva.js/__tests__/scene.spec.ts b/packages/eva.js/__tests__/scene.spec.ts index e5c4f192..ce13d871 100644 --- a/packages/eva.js/__tests__/scene.spec.ts +++ b/packages/eva.js/__tests__/scene.spec.ts @@ -1,4 +1,4 @@ -import {Scene, Transform, GameObject} from '../lib'; +import { Scene, Transform, GameObject } from '../lib'; describe('Scene', () => { it('create scene', () => { diff --git a/packages/eva.js/__tests__/utils/resources.ts b/packages/eva.js/__tests__/utils/resources.ts index fdb6eb7b..b87011eb 100644 --- a/packages/eva.js/__tests__/utils/resources.ts +++ b/packages/eva.js/__tests__/utils/resources.ts @@ -1,4 +1,4 @@ -import {RESOURCE_TYPE} from '../../lib'; +import { RESOURCE_TYPE } from '../../lib'; export interface EVAResourceParams { name: string; @@ -16,7 +16,7 @@ type EVAResourceObject = Record; export class EVADataRes { static from(options: Partial): EVAResourceObject { - const {name, data} = options; + const { name, data } = options; return { name, type: 'data', @@ -32,7 +32,7 @@ export class EVADataRes { export class EVADragonBone { static from(options: Partial): EVAResourceObject { - const {name, preload, image, imageType = 'png', ske, tex} = options; + const { name, preload, image, imageType = 'png', ske, tex } = options; return { name, type: RESOURCE_TYPE.DRAGONBONE, @@ -57,7 +57,7 @@ export class EVADragonBone { export class EVAImage { static from(options: Partial): EVAResourceObject { - const {name, image, preload, imageType = 'png'} = options; + const { name, image, preload, imageType = 'png' } = options; return { name, preload, @@ -74,7 +74,7 @@ export class EVAImage { export class EVASprite { static from(options: Partial): EVAResourceObject { - const {name, image, json, preload, imageType = 'png'} = options; + const { name, image, json, preload, imageType = 'png' } = options; return { name, preload, @@ -95,7 +95,7 @@ export class EVASprite { export class EVASpriteAnimation { static from(options: Partial): EVAResourceObject { - const {name, image, json, preload, imageType = 'png'} = options; + const { name, image, json, preload, imageType = 'png' } = options; return { name, preload, diff --git a/packages/eva.js/api-extractor.json b/packages/eva.js/api-extractor.json index b1dedbf0..7219dc5d 100644 --- a/packages/eva.js/api-extractor.json +++ b/packages/eva.js/api-extractor.json @@ -4,4 +4,4 @@ "dtsRollup": { "publicTrimmedFilePath": "./dist/eva.js.d.ts" } -} \ No newline at end of file +} diff --git a/packages/eva.js/index.js b/packages/eva.js/index.js index 781332b1..a199a46a 100644 --- a/packages/eva.js/index.js +++ b/packages/eva.js/index.js @@ -1,7 +1,7 @@ -'use strict' +'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/eva.js.cjs.prod.js') + module.exports = require('./dist/eva.js.cjs.prod.js'); } else { - module.exports = require('./dist/eva.js.cjs.js') + module.exports = require('./dist/eva.js.cjs.js'); } diff --git a/packages/eva.js/lib/core/Component.ts b/packages/eva.js/lib/core/Component.ts index 7a3084e3..d8ee793e 100644 --- a/packages/eva.js/lib/core/Component.ts +++ b/packages/eva.js/lib/core/Component.ts @@ -34,9 +34,7 @@ export type ComponentType = typeof Component; * assert(getComponentName(new Transform()) === 'Transform') * ``` */ -export function getComponentName>( - component: T | ComponentConstructor, -): string { +export function getComponentName>(component: T | ComponentConstructor): string { if (component instanceof Component) { return component.name; } else if (component instanceof Function) { @@ -45,11 +43,11 @@ export function getComponentName>( } // eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface ComponentParams { } +export interface ComponentParams {} export interface ComponentConstructor> { componentName: string; - new(params?: ComponentParams): T; + new (params?: ComponentParams): T; } /** diff --git a/packages/eva.js/lib/core/ComponentObserver.ts b/packages/eva.js/lib/core/ComponentObserver.ts index c34c1b85..f993f366 100644 --- a/packages/eva.js/lib/core/ComponentObserver.ts +++ b/packages/eva.js/lib/core/ComponentObserver.ts @@ -39,16 +39,11 @@ class ComponentObserver { */ add({ component, prop, type, componentName }: ObserverEventParams) { if (type === ObserverType.REMOVE) { - this.events = this.events.filter( - changed => changed.component !== component, - ); + this.events = this.events.filter(changed => changed.component !== component); } const index = this.events.findIndex( - changed => - changed.component === component && - isEqual(changed.prop, prop) && - changed.type === type, + changed => changed.component === component && isEqual(changed.prop, prop) && changed.type === type, ); if (index > -1) { this.events.splice(index, 1); diff --git a/packages/eva.js/lib/core/GameObject.ts b/packages/eva.js/lib/core/GameObject.ts index 713f1fc0..89b02c0a 100644 --- a/packages/eva.js/lib/core/GameObject.ts +++ b/packages/eva.js/lib/core/GameObject.ts @@ -55,11 +55,7 @@ class GameObject { * @readonly */ get parent(): GameObject { - return ( - this.transform && - this.transform.parent && - this.transform.parent.gameObject - ); + return this.transform && this.transform.parent && this.transform.parent.gameObject; } /** @@ -118,11 +114,7 @@ class GameObject { * @param gameObject - child gameobject */ removeChild(gameObject: GameObject): GameObject { - if ( - !(gameObject instanceof GameObject) || - !gameObject.parent || - gameObject.parent !== this - ) { + if (!(gameObject instanceof GameObject) || !gameObject.parent || gameObject.parent !== this) { return gameObject; } @@ -139,10 +131,7 @@ class GameObject { */ addComponent>(C: T): T; addComponent>(C: ComponentConstructor, obj?: ComponentParams): T; - addComponent>( - C: T | ComponentConstructor, - obj?: ComponentParams, - ): T { + addComponent>(C: T | ComponentConstructor, obj?: ComponentParams): T { const componentName = getComponentName(C); if (this._componentCache[componentName]) return; @@ -152,14 +141,10 @@ class GameObject { } else if (C instanceof Component) { component = C; } else { - throw new Error( - 'addComponent recieve Component and Component Constructor', - ); + throw new Error('addComponent recieve Component and Component Constructor'); } if (component.gameObject) { - throw new Error( - `component has been added on gameObject ${component.gameObject.name}`, - ); + throw new Error(`component has been added on gameObject ${component.gameObject.name}`); } component.gameObject = this; @@ -185,9 +170,7 @@ class GameObject { removeComponent>(c: string): T; removeComponent>(c: T): T; removeComponent>(c: ComponentConstructor): T; - removeComponent>( - c: string | T | ComponentConstructor, - ): T { + removeComponent>(c: string | T | ComponentConstructor): T { let componentName: string; if (typeof c === 'string') { componentName = c; @@ -198,7 +181,7 @@ class GameObject { } if (componentName === 'Transform') { - throw new Error('Transform can\'t be removed'); + throw new Error("Transform can't be removed"); } return this._removeComponent(componentName); @@ -224,9 +207,7 @@ class GameObject { */ getComponent>(c: ComponentConstructor): T; getComponent(c: string): T; - getComponent( - c: string | ComponentConstructor, - ): T { + getComponent(c: string | ComponentConstructor): T { let componentName: string; if (typeof c === 'string') { componentName = c; diff --git a/packages/eva.js/lib/core/Transform.ts b/packages/eva.js/lib/core/Transform.ts index 2f955c2a..c0a54f6e 100644 --- a/packages/eva.js/lib/core/Transform.ts +++ b/packages/eva.js/lib/core/Transform.ts @@ -1,6 +1,6 @@ import { IDEProp } from '../decorators/ide'; import Component from './Component'; -import type { ComponentParams } from './Component' +import type { ComponentParams } from './Component'; /** * Two dimensional vector diff --git a/packages/eva.js/lib/core/observer.ts b/packages/eva.js/lib/core/observer.ts index 57f3c48c..a6cc45e2 100644 --- a/packages/eva.js/lib/core/observer.ts +++ b/packages/eva.js/lib/core/observer.ts @@ -128,13 +128,7 @@ function removeObjectCache(component: Component) { * @param {pureObserverProp} param0.prop - pure observer prop * @param {ObserverType} param0.type - observer type */ -function addObserver({ - systemName, - componentName, - component, - prop, - type, -}: ObserverEvent) { +function addObserver({ systemName, componentName, component, prop, type }: ObserverEvent) { systemInstance[systemName].componentObserver.add({ component, prop, @@ -197,9 +191,7 @@ function defineProperty({ return; } if (!(key in obj)) { - console.error( - `prop ${key} not in component: ${componentName}, Can not observer`, - ); + console.error(`prop ${key} not in component: ${componentName}, Can not observer`); return; } @@ -276,10 +268,7 @@ export function initObserver(Systems: typeof System[] | typeof System) { * @param {Component} component * @param {string} componentName - default value is `component.name`, it will be deprecated */ -export function observer( - component: Component, - componentName: string = component.name, -) { +export function observer(component: Component, componentName: string = component.name) { if (!componentName || !componentProps[componentName]) { return; } @@ -309,10 +298,7 @@ export function observer( * @param component * @param componentName - default value is `component.name`, it will be deprecated */ -export function observerAdded( - component: Component, - componentName: string = component.name, -) { +export function observerAdded(component: Component, componentName: string = component.name) { for (const systemName in observerInfos) { const observerInfo = observerInfos[systemName] || {}; const info = observerInfo[componentName]; @@ -331,10 +317,7 @@ export function observerAdded( * @param component * @param componentName - default value is `component.name`, it will be deprecated */ -export function observerRemoved( - component: Component, - componentName: string = component.name, -) { +export function observerRemoved(component: Component, componentName: string = component.name) { for (const systemName in observerInfos) { const observerInfo = observerInfos[systemName] || {}; const info = observerInfo[componentName]; diff --git a/packages/eva.js/lib/game/Game.ts b/packages/eva.js/lib/game/Game.ts index b3ee18fb..5cb5eaab 100644 --- a/packages/eva.js/lib/game/Game.ts +++ b/packages/eva.js/lib/game/Game.ts @@ -57,9 +57,7 @@ const triggerStart = (obj: System | Component) => { const getAllGameObjects = game => { const mainSceneGameObjects = game?.scene?.gameObjects || []; - const gameObjectsArray = game?.multiScenes.map( - ({ gameObjects }) => gameObjects, - ); + const gameObjectsArray = game?.multiScenes.map(({ gameObjects }) => gameObjects); let otherSceneGameObjects = []; for (const gameObjects of gameObjectsArray) { otherSceneGameObjects = [...otherSceneGameObjects, ...gameObjects]; @@ -74,10 +72,7 @@ const gameObjectLoop = (e, gameObjects = []) => { triggerStart(component); component.update && component.update(e); } catch (e) { - console.error( - `gameObject: ${gameObject.name} ${component.name} update error`, - e, - ); + console.error(`gameObject: ${gameObject.name} ${component.name} update error`, e); } } } @@ -86,10 +81,7 @@ const gameObjectLoop = (e, gameObjects = []) => { try { component.lateUpdate && component.lateUpdate(e); } catch (e) { - console.error( - `gameObject: ${gameObject.name} ${component.name} lateUpdate error`, - e, - ); + console.error(`gameObject: ${gameObject.name} ${component.name} lateUpdate error`, e); } } } @@ -101,10 +93,7 @@ const gameObjectResume = gameObjects => { try { component.onResume && component.onResume(); } catch (e) { - console.error( - `gameObject: ${gameObject.name}, ${component.name}, onResume error`, - e, - ); + console.error(`gameObject: ${gameObject.name}, ${component.name}, onResume error`, e); } } } @@ -116,10 +105,7 @@ const gameObjectPause = gameObjects => { try { component.onPause && component.onPause(); } catch (e) { - console.error( - `gameObject: ${gameObject.name}, ${component.name}, onResume error`, - e, - ); + console.error(`gameObject: ${gameObject.name}, ${component.name}, onResume error`, e); } } } @@ -145,12 +131,7 @@ class Game extends EventEmitter { /** Systems alled to this game */ systems: System[] = []; - constructor({ - systems, - frameRate = 60, - autoStart = true, - needScene = true, - }: GameParams = {}) { + constructor({ systems, frameRate = 60, autoStart = true, needScene = true }: GameParams = {}) { super(); this.ticker = new Ticker({ autoStart: false, frameRate }); @@ -172,8 +153,8 @@ class Game extends EventEmitter { } /** - * Get scene on this game - */ + * Get scene on this game + */ get scene() { return this._scene; } @@ -195,10 +176,7 @@ class Game extends EventEmitter { * @typeParam T - system which extends base `System` class * @typeparam U - type of system class */ - addSystem( - S: T | U, - obj?: any, - ): T | InstanceType { + addSystem(S: T | U, obj?: any): T | InstanceType { let system; if (S instanceof Function) { system = new S(obj); @@ -375,11 +353,7 @@ class Game extends EventEmitter { this.multiScenes = null; } - loadScene({ - scene, - mode = LOAD_SCENE_MODE.SINGLE, - params = {}, - }: LoadSceneParams) { + loadScene({ scene, mode = LOAD_SCENE_MODE.SINGLE, params = {} }: LoadSceneParams) { if (!scene) { return; } diff --git a/packages/eva.js/lib/game/Ticker.ts b/packages/eva.js/lib/game/Ticker.ts index 7c844285..a51be419 100644 --- a/packages/eva.js/lib/game/Ticker.ts +++ b/packages/eva.js/lib/game/Ticker.ts @@ -9,7 +9,7 @@ interface TickerOptions { /** Default Ticker Options */ const defaultOptions: Partial = { autoStart: true, - frameRate: 60 + frameRate: 60, }; /** @@ -93,7 +93,7 @@ class Ticker { time: currentTime, currentTime: currentTime, frameCount: ++this._frameCount, - fps: Math.round(1000 / deltaTime) + fps: Math.round(1000 / deltaTime), }; for (const func of this._tickers) { diff --git a/packages/eva.js/lib/index.ts b/packages/eva.js/lib/index.ts index dfe9c2be..7181f220 100644 --- a/packages/eva.js/lib/index.ts +++ b/packages/eva.js/lib/index.ts @@ -1,8 +1,5 @@ import Component, { UpdateParams as _UpdateParams } from './core/Component'; -import { - ObserverType, - PureObserverInfo as _PureObserverInfo, -} from './core/observer'; +import { ObserverType, PureObserverInfo as _PureObserverInfo } from './core/observer'; import GameObject from './core/GameObject'; import System from './core/System'; import Transform, { TransformParams as _TransformParams } from './core/Transform'; diff --git a/packages/eva.js/lib/loader/Progress.ts b/packages/eva.js/lib/loader/Progress.ts index 2d22b70b..cde85f1a 100644 --- a/packages/eva.js/lib/loader/Progress.ts +++ b/packages/eva.js/lib/loader/Progress.ts @@ -29,8 +29,7 @@ export default class Progress extends EE { onProgress(param: EventParam) { this.resourceLoadedCount++; - this.progress = - Math.floor((this.resourceLoadedCount / this.resourceTotal) * 100) / 100; + this.progress = Math.floor((this.resourceLoadedCount / this.resourceTotal) * 100) / 100; if (param.success) { this.resource.emit(LOAD_EVENT.LOADED, this, param); } else { diff --git a/packages/eva.js/lib/loader/Resource.ts b/packages/eva.js/lib/loader/Resource.ts index b99bce05..c1a25432 100644 --- a/packages/eva.js/lib/loader/Resource.ts +++ b/packages/eva.js/lib/loader/Resource.ts @@ -64,10 +64,10 @@ XhrLoadStrategy.setExtensionXhrType('json', XhrResponseType.Json); XhrLoadStrategy.setExtensionXhrType('tex', XhrResponseType.Json); XhrLoadStrategy.setExtensionXhrType('ske', XhrResponseType.Json); -XhrLoadStrategy.setExtensionXhrType('mp3', XhrResponseType.Buffer) -XhrLoadStrategy.setExtensionXhrType('wav', XhrResponseType.Buffer) -XhrLoadStrategy.setExtensionXhrType('aac', XhrResponseType.Buffer) -XhrLoadStrategy.setExtensionXhrType('ogg', XhrResponseType.Buffer) +XhrLoadStrategy.setExtensionXhrType('mp3', XhrResponseType.Buffer); +XhrLoadStrategy.setExtensionXhrType('wav', XhrResponseType.Buffer); +XhrLoadStrategy.setExtensionXhrType('aac', XhrResponseType.Buffer); +XhrLoadStrategy.setExtensionXhrType('ogg', XhrResponseType.Buffer); const STRATEGY = { png: ImageLoadStrategy, @@ -78,7 +78,7 @@ const STRATEGY = { tex: XhrLoadStrategy, ske: XhrLoadStrategy, audio: XhrLoadStrategy, - video: VideoLoadStrategy + video: VideoLoadStrategy, }; type ResourceName = string; @@ -185,7 +185,7 @@ class Resource extends EE { } } delete this.promiseMap[name]; - resource.data = {} + resource.data = {}; resource.complete = false; resource.instance = undefined; } diff --git a/packages/eva.js/lib/sprite-timeline/index.js b/packages/eva.js/lib/sprite-timeline/index.js index d38ccf33..5997134a 100644 --- a/packages/eva.js/lib/sprite-timeline/index.js +++ b/packages/eva.js/lib/sprite-timeline/index.js @@ -1,4 +1,4 @@ -import {createNowTime, formatDelay} from './utils'; +import { createNowTime, formatDelay } from './utils'; const _nowtime = createNowTime(); @@ -76,7 +76,7 @@ class Timeline { return this[_timeMark][this[_timeMark].length - 1]; } - markTime({time = this.currentTime, entropy = this.entropy, playbackRate = this.playbackRate} = {}) { + markTime({ time = this.currentTime, entropy = this.entropy, playbackRate = this.playbackRate } = {}) { const timeMark = { globalTime: this.globalTime, localTime: time, @@ -88,7 +88,7 @@ class Timeline { } get currentTime() { - const {localTime, globalTime} = this.lastTimeMark; + const { localTime, globalTime } = this.lastTimeMark; return localTime + (this.globalTime - globalTime) * this.playbackRate; } @@ -97,11 +97,11 @@ class Timeline { to = time, timers = this[_timers]; - this.markTime({time}); + this.markTime({ time }); Array.from(Object.entries(timers)).forEach(([id, timer]) => { if (!timers.has(id)) return; // Need check because it maybe clearTimeout by former handler(). - const {isEntropy, delay, heading} = timer.time, - {handler, startTime} = timer; + const { isEntropy, delay, heading } = timer.time, + { handler, startTime } = timer; if (!isEntropy) { const endTime = startTime + delay; @@ -127,7 +127,7 @@ class Timeline { // while the entropy remain to go forwards. // Both of the initial values is set to -originTime get entropy() { - const {entropy, globalEntropy} = this.lastTimeMark; + const { entropy, globalEntropy } = this.lastTimeMark; return entropy + Math.abs((this.globalEntropy - globalEntropy) * this.playbackRate); } @@ -152,7 +152,7 @@ class Timeline { const idx = this.seekTimeMark(entropy); this[_timeMark].length = idx + 1; } - this.markTime({entropy}); + this.markTime({ entropy }); this.updateTimers(); } @@ -164,7 +164,7 @@ class Timeline { const idx = this.seekTimeMark(seekEntropy), timeMark = this[_timeMark][idx]; - const {entropy, playbackRate, globalTime} = timeMark; + const { entropy, playbackRate, globalTime } = timeMark; return globalTime + (seekEntropy - entropy) / Math.abs(playbackRate); } @@ -173,7 +173,7 @@ class Timeline { const idx = this.seekTimeMark(seekEntropy), timeMark = this[_timeMark][idx]; - const {localTime, entropy, playbackRate} = timeMark; + const { localTime, entropy, playbackRate } = timeMark; if (playbackRate > 0) { return localTime + (seekEntropy - entropy); @@ -217,7 +217,7 @@ class Timeline { set playbackRate(rate) { if (rate !== this.playbackRate) { - this.markTime({playbackRate: rate}); + this.markTime({ playbackRate: rate }); this[_playbackRate] = rate; this.updateTimers(); } @@ -270,11 +270,11 @@ class Timeline { setTimeout(func, {entropy: 100}) setTimeout(func, 100}) */ - setTimeout(handler, time = {delay: 0}) { + setTimeout(handler, time = { delay: 0 }) { return this[_setTimer](handler, time); } - setInterval(handler, time = {delay: 0}) { + setInterval(handler, time = { delay: 0 }) { const that = this; const id = this[_setTimer](function step() { // reset timer before handler cause we may clearTimeout in handler() @@ -324,7 +324,7 @@ class Timeline { // eslint-disable-line no-restricted-globals delay = Math.ceil(delay); if (globalTimeout !== setTimeout) { - delay = {delay, heading}; + delay = { delay, heading }; } timerID = globalTimeout(() => { this[_timers].delete(id); diff --git a/packages/eva.js/lib/sprite-timeline/utils.js b/packages/eva.js/lib/sprite-timeline/utils.js index fe8a30a9..ab84114d 100644 --- a/packages/eva.js/lib/sprite-timeline/utils.js +++ b/packages/eva.js/lib/sprite-timeline/utils.js @@ -15,9 +15,9 @@ export function createNowTime(syncLocker = true) { */ export function formatDelay(delay) { if (typeof delay === 'number') { - delay = {delay}; + delay = { delay }; } else if ('entropy' in delay) { - delay = {delay: delay.entropy, isEntropy: true}; + delay = { delay: delay.entropy, isEntropy: true }; } return delay; } diff --git a/packages/global.d.ts b/packages/global.d.ts index 3caf829d..820972f0 100644 --- a/packages/global.d.ts +++ b/packages/global.d.ts @@ -13,4 +13,4 @@ declare namespace jest { declare namespace PIXI.miniprogram { export const type = 'taobao miniprogram'; -} \ No newline at end of file +} diff --git a/packages/miniprogram-adapter/README.md b/packages/miniprogram-adapter/README.md index a6b3b341..b1e102bf 100644 --- a/packages/miniprogram-adapter/README.md +++ b/packages/miniprogram-adapter/README.md @@ -1,7 +1,6 @@ - # @eva/miniprogram-adapter More Introduction + - [EN](https://eva.js.org) - [中文](https://eva-engine.gitee.io) - \ No newline at end of file diff --git a/packages/miniprogram-adapter/api-extractor.json b/packages/miniprogram-adapter/api-extractor.json index 99401063..75c34710 100644 --- a/packages/miniprogram-adapter/api-extractor.json +++ b/packages/miniprogram-adapter/api-extractor.json @@ -4,4 +4,4 @@ "dtsRollup": { "publicTrimmedFilePath": "./dist/miniprogram-adapter.d.ts" } -} \ No newline at end of file +} diff --git a/packages/miniprogram-adapter/index.js b/packages/miniprogram-adapter/index.js index dcfa89c7..3288ef7b 100644 --- a/packages/miniprogram-adapter/index.js +++ b/packages/miniprogram-adapter/index.js @@ -1,7 +1,7 @@ -'use strict' +'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/miniprogram-adapter.cjs.prod.js') + module.exports = require('./dist/miniprogram-adapter.cjs.prod.js'); } else { - module.exports = require('./dist/miniprogram-adapter.cjs.js') + module.exports = require('./dist/miniprogram-adapter.cjs.js'); } diff --git a/packages/miniprogram-pixi/README.md b/packages/miniprogram-pixi/README.md index ff6e6bf4..012147d3 100644 --- a/packages/miniprogram-pixi/README.md +++ b/packages/miniprogram-pixi/README.md @@ -1,7 +1,6 @@ - # @eva/miniprogram-pixi More Introduction + - [EN](https://eva.js.org) - [中文](https://eva-engine.gitee.io) - \ No newline at end of file diff --git a/packages/miniprogram-pixi/api-extractor.json b/packages/miniprogram-pixi/api-extractor.json index 85ad2e87..01401d4b 100644 --- a/packages/miniprogram-pixi/api-extractor.json +++ b/packages/miniprogram-pixi/api-extractor.json @@ -4,4 +4,4 @@ "dtsRollup": { "publicTrimmedFilePath": "./dist/miniprogram-pixi.d.ts" } -} \ No newline at end of file +} diff --git a/packages/miniprogram-pixi/index.js b/packages/miniprogram-pixi/index.js index 1015e27a..089b9e09 100644 --- a/packages/miniprogram-pixi/index.js +++ b/packages/miniprogram-pixi/index.js @@ -1,7 +1,7 @@ -'use strict' +'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/miniprogram-pixi.cjs.prod.js') + module.exports = require('./dist/miniprogram-pixi.cjs.prod.js'); } else { - module.exports = require('./dist/miniprogram-pixi.cjs.js') + module.exports = require('./dist/miniprogram-pixi.cjs.js'); } diff --git a/packages/plugin-a11y/README.md b/packages/plugin-a11y/README.md index 51069942..9260a87d 100644 --- a/packages/plugin-a11y/README.md +++ b/packages/plugin-a11y/README.md @@ -1,7 +1,6 @@ - # @eva/plugin-a11y More Introduction + - [EN](https://eva.js.org) - [中文](https://eva-engine.gitee.io) - \ No newline at end of file diff --git a/packages/plugin-a11y/__tests__/plugin-a11y.test.js b/packages/plugin-a11y/__tests__/plugin-a11y.test.js index 1dc23efb..0e024c44 100644 --- a/packages/plugin-a11y/__tests__/plugin-a11y.test.js +++ b/packages/plugin-a11y/__tests__/plugin-a11y.test.js @@ -3,5 +3,5 @@ const pluginA11Y = require('..'); describe('plugin-a11y', () => { - it('needs tests'); + it('needs tests'); }); diff --git a/packages/plugin-a11y/api-extractor.json b/packages/plugin-a11y/api-extractor.json index 900e5c76..12885d7a 100644 --- a/packages/plugin-a11y/api-extractor.json +++ b/packages/plugin-a11y/api-extractor.json @@ -4,4 +4,4 @@ "dtsRollup": { "publicTrimmedFilePath": "./dist/plugin-a11y.d.ts" } -} \ No newline at end of file +} diff --git a/packages/plugin-a11y/index.js b/packages/plugin-a11y/index.js index 2bdf2163..b6599d35 100644 --- a/packages/plugin-a11y/index.js +++ b/packages/plugin-a11y/index.js @@ -1,7 +1,7 @@ -'use strict' +'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/plugin-a11y.cjs.prod.js') + module.exports = require('./dist/plugin-a11y.cjs.prod.js'); } else { - module.exports = require('./dist/plugin-a11y.cjs.js') + module.exports = require('./dist/plugin-a11y.cjs.js'); } diff --git a/packages/plugin-a11y/lib/A11y.ts b/packages/plugin-a11y/lib/A11y.ts index ea09c299..4681b5d4 100644 --- a/packages/plugin-a11y/lib/A11y.ts +++ b/packages/plugin-a11y/lib/A11y.ts @@ -1,5 +1,5 @@ -import {Component, decorators} from '@eva/eva.js'; -import {uuid} from './utils'; +import { Component, decorators } from '@eva/eva.js'; +import { uuid } from './utils'; export interface A11yParams { hint: string; @@ -82,15 +82,7 @@ export default class A11y extends Component { constructor(param: A11yParams) { super(); Object.assign(this, param); - const { - hint = '', - event, - delay = 0, - attr = {}, - role = '', - props = {}, - state = {}, - } = param; + const { hint = '', event, delay = 0, attr = {}, role = '', props = {}, state = {} } = param; this.hint = hint; this.event = event; this.delay = delay; diff --git a/packages/plugin-a11y/lib/A11ySystem.ts b/packages/plugin-a11y/lib/A11ySystem.ts index a1700acd..1ff9ff29 100644 --- a/packages/plugin-a11y/lib/A11ySystem.ts +++ b/packages/plugin-a11y/lib/A11ySystem.ts @@ -4,7 +4,15 @@ import EE from 'eventemitter3'; import A11y from './A11y'; import { setStyle, setTransform } from './utils'; -import { POSITION, ZINDEX, PointerEvents, MaskBackground, EventPosition, A11yMaskStyle, A11yActivate } from './constant'; +import { + POSITION, + ZINDEX, + PointerEvents, + MaskBackground, + EventPosition, + A11yMaskStyle, + A11yActivate, +} from './constant'; interface SystemParam { debug?: boolean; diff --git a/packages/plugin-a11y/lib/constant.ts b/packages/plugin-a11y/lib/constant.ts index 3fd7c863..70f586fc 100644 --- a/packages/plugin-a11y/lib/constant.ts +++ b/packages/plugin-a11y/lib/constant.ts @@ -51,4 +51,4 @@ export interface A11yMaskStyle { export interface EventPosition { x: number; y: number; -} \ No newline at end of file +} diff --git a/packages/plugin-a11y/lib/index.ts b/packages/plugin-a11y/lib/index.ts index 62fcbd12..a8edbdf0 100644 --- a/packages/plugin-a11y/lib/index.ts +++ b/packages/plugin-a11y/lib/index.ts @@ -1,3 +1,3 @@ -export { default as A11ySystem } from './A11ySystem' -export { default as A11y } from './A11y' -export { A11yActivate } from './constant' \ No newline at end of file +export { default as A11ySystem } from './A11ySystem'; +export { default as A11y } from './A11y'; +export { A11yActivate } from './constant'; diff --git a/packages/plugin-a11y/lib/utils.ts b/packages/plugin-a11y/lib/utils.ts index 7073aae4..a1e9e258 100644 --- a/packages/plugin-a11y/lib/utils.ts +++ b/packages/plugin-a11y/lib/utils.ts @@ -1,4 +1,4 @@ -import {A11yMaskStyle} from './constant'; +import { A11yMaskStyle } from './constant'; /** * 生成唯一的标识符 @@ -6,9 +6,7 @@ import {A11yMaskStyle} from './constant'; * @param radix 基 */ function uuid(len: number) { - let chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split( - '', - ); + let chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''); let uuid = []; let radix = chars.length; for (let i = 0; i < len; i++) uuid[i] = chars[0 | (Math.random() * radix)]; @@ -21,16 +19,7 @@ function uuid(len: number) { * @param style 样式属性 */ const setStyle = (element: HTMLElement, style: A11yMaskStyle) => { - const { - width, - height, - position, - left = 0, - top = 0, - zIndex, - pointerEvents, - background, - } = style; + const { width, height, position, left = 0, top = 0, zIndex, pointerEvents, background } = style; element.style.width = `${width}px`; element.style.height = `${height}px`; element.style.position = position; @@ -44,15 +33,13 @@ const setStyle = (element: HTMLElement, style: A11yMaskStyle) => { }; const setTransform = (element: HTMLElement, transform, ratioX, ratioY) => { - const {worldTransform} = transform; - const {a, b, c, d, tx, ty} = worldTransform; - const matrix = `matrix(${a}, ${b}, ${c}, ${d}, ${tx * ratioX}, ${ - ty * ratioY - })`; + const { worldTransform } = transform; + const { a, b, c, d, tx, ty } = worldTransform; + const matrix = `matrix(${a}, ${b}, ${c}, ${d}, ${tx * ratioX}, ${ty * ratioY})`; element.style.transform = `${matrix}`; element.style.webkitTransform = `${matrix}`; element.style.transformOrigin = 'left top'; element.style.webkitTransformOrigin = 'left top'; }; -export {setStyle, setTransform, uuid}; +export { setStyle, setTransform, uuid }; diff --git a/packages/plugin-evax/README.md b/packages/plugin-evax/README.md index 5ea76d75..a262d6f6 100644 --- a/packages/plugin-evax/README.md +++ b/packages/plugin-evax/README.md @@ -1,7 +1,6 @@ - # @eva/plugin-evax More Introduction + - [EN](https://eva.js.org) - [中文](https://eva-engine.gitee.io) - \ No newline at end of file diff --git a/packages/plugin-evax/api-extractor.json b/packages/plugin-evax/api-extractor.json index 53fe2a6e..b3053af5 100644 --- a/packages/plugin-evax/api-extractor.json +++ b/packages/plugin-evax/api-extractor.json @@ -4,4 +4,4 @@ "dtsRollup": { "publicTrimmedFilePath": "./dist/plugin-evax.d.ts" } -} \ No newline at end of file +} diff --git a/packages/plugin-evax/index.js b/packages/plugin-evax/index.js index 69841fd9..c01940c7 100644 --- a/packages/plugin-evax/index.js +++ b/packages/plugin-evax/index.js @@ -1,7 +1,7 @@ -'use strict' +'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/plugin-evax.cjs.prod.js') + module.exports = require('./dist/plugin-evax.cjs.prod.js'); } else { - module.exports = require('./dist/plugin-evax.cjs.js') + module.exports = require('./dist/plugin-evax.cjs.js'); } diff --git a/packages/plugin-evax/lib/EvaXComponent.ts b/packages/plugin-evax/lib/EvaXComponent.ts index 20fcd737..7a342c04 100644 --- a/packages/plugin-evax/lib/EvaXComponent.ts +++ b/packages/plugin-evax/lib/EvaXComponent.ts @@ -1,4 +1,4 @@ -import {Component, decorators} from '@eva/eva.js'; +import { Component, decorators } from '@eva/eva.js'; import EvaXSystem from './EvaXSystem'; interface Events { @@ -19,8 +19,8 @@ export default class EvaXComponent extends Component { } evax: EvaXSystem; @decorators.IDEProp events: Events = {}; - init(option: EvaXParams = {events: {}}) { - const {events} = option; + init(option: EvaXParams = { events: {} }) { + const { events } = option; this.events = events || {}; } } diff --git a/packages/plugin-evax/lib/EvaXSystem.ts b/packages/plugin-evax/lib/EvaXSystem.ts index adf2d225..fe06b0ae 100644 --- a/packages/plugin-evax/lib/EvaXSystem.ts +++ b/packages/plugin-evax/lib/EvaXSystem.ts @@ -1,5 +1,5 @@ import { System, decorators, ComponentChanged, OBSERVER_TYPE } from '@eva/eva.js'; -import EventEmitter from 'eventemitter3' +import EventEmitter from 'eventemitter3'; import EvaXComponent from './EvaXComponent'; import { defineProperty, updateStore } from './utils'; @@ -42,14 +42,7 @@ export default class EvaXSystem extends System { return; } const realKey = key.split('.').slice(1).join('.'); - defineProperty( - realKey, - deep, - this.store, - key, - this.store, - (key, oldStore) => this.changeCallback(key, oldStore), - ); + defineProperty(realKey, deep, this.store, key, this.store, (key, oldStore) => this.changeCallback(key, oldStore)); } update() { const changes = this.componentObserver.clear(); @@ -106,5 +99,5 @@ export default class EvaXSystem extends System { emit(eventName, ...args) { return this.ee.emit(eventName, ...args); } - onDestroy() { } + onDestroy() {} } diff --git a/packages/plugin-evax/lib/index.ts b/packages/plugin-evax/lib/index.ts index 69807eb2..0bfccc37 100644 --- a/packages/plugin-evax/lib/index.ts +++ b/packages/plugin-evax/lib/index.ts @@ -5,4 +5,4 @@ export default { Systems: [EvaXSystem], }; -export {EvaXComponent as EvaX, EvaXSystem}; +export { EvaXComponent as EvaX, EvaXSystem }; diff --git a/packages/plugin-evax/lib/utils.ts b/packages/plugin-evax/lib/utils.ts index 9969575c..86acced8 100644 --- a/packages/plugin-evax/lib/utils.ts +++ b/packages/plugin-evax/lib/utils.ts @@ -3,14 +3,7 @@ import isObject from 'lodash-es/isObject'; const _defineCache = new Map(); -export function defineProperty( - key, - deep, - store, - originKey, - originStore, - callback, -) { +export function defineProperty(key, deep, store, originKey, originStore, callback) { if (!_defineCache.has(store)) { _defineCache.set(store, []); } diff --git a/packages/plugin-matterjs/README.md b/packages/plugin-matterjs/README.md index d25d590f..c4bbd26d 100644 --- a/packages/plugin-matterjs/README.md +++ b/packages/plugin-matterjs/README.md @@ -1,7 +1,6 @@ - # @eva/plugin-matterjs More Introduction + - [EN](https://eva.js.org) - [中文](https://eva-engine.gitee.io) - \ No newline at end of file diff --git a/packages/plugin-matterjs/__tests__/plugin-matterjs.test.js b/packages/plugin-matterjs/__tests__/plugin-matterjs.test.js index ae9fb179..5b6b017d 100644 --- a/packages/plugin-matterjs/__tests__/plugin-matterjs.test.js +++ b/packages/plugin-matterjs/__tests__/plugin-matterjs.test.js @@ -3,5 +3,5 @@ const pluginMatterjs = require('..'); describe('plugin-matterjs', () => { - it('needs tests'); + it('needs tests'); }); diff --git a/packages/plugin-matterjs/api-extractor.json b/packages/plugin-matterjs/api-extractor.json index 0dead264..67506a30 100644 --- a/packages/plugin-matterjs/api-extractor.json +++ b/packages/plugin-matterjs/api-extractor.json @@ -4,4 +4,4 @@ "dtsRollup": { "publicTrimmedFilePath": "./dist/plugin-matterjs.d.ts" } -} \ No newline at end of file +} diff --git a/packages/plugin-matterjs/index.js b/packages/plugin-matterjs/index.js index c0fca113..5e4909ff 100644 --- a/packages/plugin-matterjs/index.js +++ b/packages/plugin-matterjs/index.js @@ -1,7 +1,7 @@ -'use strict' +'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/plugin-matterjs.cjs.prod.js') + module.exports = require('./dist/plugin-matterjs.cjs.prod.js'); } else { - module.exports = require('./dist/plugin-matterjs.cjs.js') + module.exports = require('./dist/plugin-matterjs.cjs.js'); } diff --git a/packages/plugin-matterjs/lib/Physics.ts b/packages/plugin-matterjs/lib/Physics.ts index 80c00949..c6bd4983 100644 --- a/packages/plugin-matterjs/lib/Physics.ts +++ b/packages/plugin-matterjs/lib/Physics.ts @@ -3,10 +3,9 @@ import Matter from './matter'; export enum PhysicsType { RECTANGLE = 'rectangle', CIRCLE = 'circle', - POLYGON = 'polygon' + POLYGON = 'polygon', } - export class Physics extends Component { static componentName: string = 'Physics'; private bodyParams: any; diff --git a/packages/plugin-matterjs/lib/PhysicsEngine.ts b/packages/plugin-matterjs/lib/PhysicsEngine.ts index cbc9b27b..55eefc7a 100644 --- a/packages/plugin-matterjs/lib/PhysicsEngine.ts +++ b/packages/plugin-matterjs/lib/PhysicsEngine.ts @@ -1,6 +1,6 @@ import Matter from './matter'; import BodiesFactory from './BodiesFactory'; -import {Component, Game} from '@eva/eva.js'; +import { Component, Game } from '@eva/eva.js'; export default class PhysicsEngine { private Engine: any; private World: any; @@ -94,7 +94,7 @@ export default class PhysicsEngine { const pairs: any[] = event.pairs || []; for (let i = 0; i < pairs.length; i++) { const pair = pairs[i]; - const {bodyA, bodyB} = pair; + const { bodyA, bodyB } = pair; const componentA: Component = bodyA.component; const componentB: Component = bodyB.component; componentA.emit(eventName, componentB.gameObject, componentA.gameObject); diff --git a/packages/plugin-matterjs/lib/PhysicsSystem.ts b/packages/plugin-matterjs/lib/PhysicsSystem.ts index 659a4146..483fc7cb 100644 --- a/packages/plugin-matterjs/lib/PhysicsSystem.ts +++ b/packages/plugin-matterjs/lib/PhysicsSystem.ts @@ -23,7 +23,7 @@ export default class PhysicsSystem extends System { * * Called while the System installed, if game is not begain, it will be called while begain. use to pre operation, init data. */ - awake() { } + awake() {} /** * System 被安装后,所有的 awake 执行完后 @@ -67,7 +67,7 @@ export default class PhysicsSystem extends System { * * Like update, called all of gameobject update. */ - lateUpdate() { } + lateUpdate() {} /** * 游戏开始和游戏暂停后开始播放的时候调用。 * @@ -90,5 +90,5 @@ export default class PhysicsSystem extends System { * System 被销毁的时候调用。 * Called while the system be destroyed. */ - onDestroy() { } + onDestroy() {} } diff --git a/packages/plugin-matterjs/lib/index.ts b/packages/plugin-matterjs/lib/index.ts index bc2ab250..661ba970 100644 --- a/packages/plugin-matterjs/lib/index.ts +++ b/packages/plugin-matterjs/lib/index.ts @@ -1,4 +1,4 @@ import PhysicsSystem from './PhysicsSystem'; -import {Physics, PhysicsType} from './Physics'; +import { Physics, PhysicsType } from './Physics'; -export {Physics, PhysicsSystem, PhysicsType}; +export { Physics, PhysicsSystem, PhysicsType }; diff --git a/packages/plugin-matterjs/lib/matter.js b/packages/plugin-matterjs/lib/matter.js index a0423882..b27fa681 100644 --- a/packages/plugin-matterjs/lib/matter.js +++ b/packages/plugin-matterjs/lib/matter.js @@ -42,7 +42,7 @@ const main = function () { /******/ /******/ /******/ __webpack_require__.d = function (exports, name, getter) { /******/ if (!__webpack_require__.o(exports, name)) { - /******/ Object.defineProperty(exports, name, {enumerable: true, get: getter}); + /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ @@ -50,10 +50,10 @@ const main = function () { /******/ /******/ /******/ __webpack_require__.r = function (exports) { /******/ if (typeof Symbol !== 'undefined' && Symbol.toStringTag) { - /******/ Object.defineProperty(exports, Symbol.toStringTag, {value: 'Module'}); + /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } - /******/ Object.defineProperty(exports, '__esModule', {value: true}); + /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; // create a fake namespace object // mode & 1: value is a module id, require it // mode & 2: merge all properties of value into the ns // mode & 4: return value when already ns object // mode & 8|1: behave like require /******/ @@ -63,7 +63,7 @@ const main = function () { /******/ if (mode & 4 && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); - /******/ Object.defineProperty(ns, 'default', {enumerable: true, value: value}); + /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if (mode & 2 && typeof value != 'string') for (var key in value) __webpack_require__.d( @@ -655,8 +655,8 @@ const main = function () { */ Bounds.create = function (vertices) { var bounds = { - min: {x: 0, y: 0}, - max: {x: 0, y: 0}, + min: { x: 0, y: 0 }, + max: { x: 0, y: 0 }, }; if (vertices) Bounds.update(bounds, vertices); @@ -788,7 +788,7 @@ const main = function () { * @return {vector} A new vector */ Vector.create = function (x, y) { - return {x: x || 0, y: y || 0}; + return { x: x || 0, y: y || 0 }; }; /** @@ -798,7 +798,7 @@ const main = function () { * @return {vector} A new cloned vector */ Vector.clone = function (vector) { - return {x: vector.x, y: vector.y}; + return { x: vector.x, y: vector.y }; }; /** @@ -866,8 +866,8 @@ const main = function () { */ Vector.normalise = function (vector) { var magnitude = Vector.magnitude(vector); - if (magnitude === 0) return {x: 0, y: 0}; - return {x: vector.x / magnitude, y: vector.y / magnitude}; + if (magnitude === 0) return { x: 0, y: 0 }; + return { x: vector.x / magnitude, y: vector.y / magnitude }; }; /** @@ -944,7 +944,7 @@ const main = function () { * @return {vector} A new vector multiplied by scalar */ Vector.mult = function (vector, scalar) { - return {x: vector.x * scalar, y: vector.y * scalar}; + return { x: vector.x * scalar, y: vector.y * scalar }; }; /** @@ -955,7 +955,7 @@ const main = function () { * @return {vector} A new vector divided by scalar */ Vector.div = function (vector, scalar) { - return {x: vector.x / scalar, y: vector.y / scalar}; + return { x: vector.x / scalar, y: vector.y / scalar }; }; /** @@ -967,7 +967,7 @@ const main = function () { */ Vector.perp = function (vector, negate) { negate = negate === true ? -1 : 1; - return {x: negate * -vector.y, y: negate * vector.x}; + return { x: negate * -vector.y, y: negate * vector.x }; }; /** @@ -977,7 +977,7 @@ const main = function () { * @return {vector} The negated vector */ Vector.neg = function (vector) { - return {x: -vector.x, y: -vector.y}; + return { x: -vector.x, y: -vector.y }; }; /** @@ -1079,7 +1079,7 @@ const main = function () { points = []; path.replace(pathPattern, function (match, x, y) { - points.push({x: parseFloat(x), y: parseFloat(y)}); + points.push({ x: parseFloat(x), y: parseFloat(y) }); }); return Vertices.create(points, body); @@ -1093,7 +1093,7 @@ const main = function () { */ Vertices.centre = function (vertices) { var area = Vertices.area(vertices, true), - centre = {x: 0, y: 0}, + centre = { x: 0, y: 0 }, cross, temp, j; @@ -1115,7 +1115,7 @@ const main = function () { * @return {vector} The average point */ Vertices.mean = function (vertices) { - var average = {x: 0, y: 0}; + var average = { x: 0, y: 0 }; for (var i = 0; i < vertices.length; i++) { average.x += vertices[i].x; @@ -1654,7 +1654,7 @@ const main = function () { Composite.add = function (composite, object) { var objects = [].concat(object); - Events.trigger(composite, 'beforeAdd', {object: object}); + Events.trigger(composite, 'beforeAdd', { object: object }); for (var i = 0; i < objects.length; i++) { var obj = objects[i]; @@ -1681,7 +1681,7 @@ const main = function () { } } - Events.trigger(composite, 'afterAdd', {object: object}); + Events.trigger(composite, 'afterAdd', { object: object }); return composite; }; @@ -1699,7 +1699,7 @@ const main = function () { Composite.remove = function (composite, object, deep) { var objects = [].concat(object); - Events.trigger(composite, 'beforeRemove', {object: object}); + Events.trigger(composite, 'beforeRemove', { object: object }); for (var i = 0; i < objects.length; i++) { var obj = objects[i]; @@ -1720,7 +1720,7 @@ const main = function () { } } - Events.trigger(composite, 'afterRemove', {object: object}); + Events.trigger(composite, 'afterRemove', { object: object }); return composite; }; @@ -2306,15 +2306,15 @@ const main = function () { plugin: {}, angle: 0, vertices: Vertices.fromPath('L 0 0 L 40 0 L 40 40 L 0 40'), - position: {x: 0, y: 0}, - force: {x: 0, y: 0}, + position: { x: 0, y: 0 }, + force: { x: 0, y: 0 }, torque: 0, - positionImpulse: {x: 0, y: 0}, - constraintImpulse: {x: 0, y: 0, angle: 0}, + positionImpulse: { x: 0, y: 0 }, + constraintImpulse: { x: 0, y: 0, angle: 0 }, totalContacts: 0, speed: 0, angularSpeed: 0, - velocity: {x: 0, y: 0}, + velocity: { x: 0, y: 0 }, angularVelocity: 0, isSensor: false, isStatic: false, @@ -2841,9 +2841,9 @@ const main = function () { Body.setMass(part, body.density * part.area); // update inertia (requires vertices to be at origin) - Vertices.translate(part.vertices, {x: -part.position.x, y: -part.position.y}); + Vertices.translate(part.vertices, { x: -part.position.x, y: -part.position.y }); Body.setInertia(part, Body._inertiaScale * Vertices.inertia(part.vertices, part.mass)); - Vertices.translate(part.vertices, {x: part.position.x, y: part.position.y}); + Vertices.translate(part.vertices, { x: part.position.x, y: part.position.y }); if (i > 0) { totalArea += part.area; @@ -2948,7 +2948,7 @@ const main = function () { Body.applyForce = function (body, position, force) { body.force.x += force.x; body.force.y += force.y; - var offset = {x: position.x - body.position.x, y: position.y - body.position.y}; + var offset = { x: position.x - body.position.x, y: position.y - body.position.y }; body.torque += offset.x * force.y - offset.y * force.x; }; @@ -2968,7 +2968,7 @@ const main = function () { mass: 0, area: 0, inertia: 0, - centre: {x: 0, y: 0}, + centre: { x: 0, y: 0 }, }; // sum the properties of all compound parts of the parent body @@ -3665,8 +3665,8 @@ const main = function () { var constraint = options; // if bodies defined but no points, use body centre - if (constraint.bodyA && !constraint.pointA) constraint.pointA = {x: 0, y: 0}; - if (constraint.bodyB && !constraint.pointB) constraint.pointB = {x: 0, y: 0}; + if (constraint.bodyA && !constraint.pointA) constraint.pointA = { x: 0, y: 0 }; + if (constraint.bodyB && !constraint.pointB) constraint.pointB = { x: 0, y: 0 }; // calculate static length using initial world space points var initialPointA = constraint.bodyA @@ -4435,8 +4435,8 @@ const main = function () { // find bounds of all objects var bounds = { - min: {x: Infinity, y: Infinity}, - max: {x: -Infinity, y: -Infinity}, + min: { x: Infinity, y: Infinity }, + max: { x: -Infinity, y: -Infinity }, }; for (var i = 0; i < objects.length; i += 1) { @@ -6253,7 +6253,7 @@ const main = function () { // reuse collision object collision = previousCollision; } else { - collision = {collided: false, bodyA: bodyA, bodyB: bodyB}; + collision = { collided: false, bodyA: bodyA, bodyB: bodyB }; } if (previousCollision && canReusePrevCol) { @@ -6366,7 +6366,7 @@ const main = function () { SAT._overlapAxes = function (verticesA, verticesB, axes) { var projectionA = Vector._temp[0], projectionB = Vector._temp[1], - result = {overlap: Number.MAX_VALUE}, + result = { overlap: Number.MAX_VALUE }, overlap, axis; @@ -6503,12 +6503,12 @@ const main = function () { } mouse.element = element || document.body; - mouse.absolute = {x: 0, y: 0}; - mouse.position = {x: 0, y: 0}; - mouse.mousedownPosition = {x: 0, y: 0}; - mouse.mouseupPosition = {x: 0, y: 0}; - mouse.offset = {x: 0, y: 0}; - mouse.scale = {x: 1, y: 1}; + mouse.absolute = { x: 0, y: 0 }; + mouse.position = { x: 0, y: 0 }; + mouse.mousedownPosition = { x: 0, y: 0 }; + mouse.mouseupPosition = { x: 0, y: 0 }; + mouse.offset = { x: 0, y: 0 }; + mouse.scale = { x: 1, y: 1 }; mouse.wheelDelta = 0; mouse.button = -1; mouse.pixelRatio = parseInt(mouse.element.getAttribute('data-pixel-ratio'), 10) || 1; @@ -6786,7 +6786,7 @@ const main = function () { var rectangle = { label: 'Rectangle Body', - position: {x: x, y: y}, + position: { x: x, y: y }, vertices: Vertices.fromPath('L 0 0 L ' + width + ' 0 L ' + width + ' ' + height + ' L 0 ' + height), }; @@ -6837,7 +6837,7 @@ const main = function () { var trapezoid = { label: 'Trapezoid Body', - position: {x: x, y: y}, + position: { x: x, y: y }, vertices: Vertices.fromPath(verticesPath), }; @@ -6917,7 +6917,7 @@ const main = function () { var polygon = { label: 'Polygon Body', - position: {x: x, y: y}, + position: { x: x, y: y }, vertices: Vertices.fromPath(path), }; @@ -7006,7 +7006,7 @@ const main = function () { } parts.push({ - position: {x: x, y: y}, + position: { x: x, y: y }, vertices: vertices, }); } else { @@ -7086,8 +7086,8 @@ const main = function () { if (parts.length > 1) { // create the parent body to be returned, that contains generated compound parts - body = Body.create(Common.extend({parts: parts.slice(0)}, options)); - Body.setPosition(body, {x: x, y: y}); + body = Body.create(Common.extend({ parts: parts.slice(0) }, options)); + Body.setPosition(body, { x: x, y: y }); return body; } else { @@ -7565,8 +7565,8 @@ const main = function () { scale: 0.001, }, bounds: { - min: {x: -Infinity, y: -Infinity}, - max: {x: Infinity, y: Infinity}, + min: { x: -Infinity, y: -Infinity }, + max: { x: Infinity, y: Infinity }, }, }; @@ -8289,7 +8289,7 @@ const main = function () { engine.world = options.world || World.create(engine.world); engine.pairs = Pairs.create(); engine.broadphase = engine.broadphase.controller.create(engine.broadphase); - engine.metrics = engine.metrics || {extended: false}; + engine.metrics = engine.metrics || { extended: false }; // @if DEBUG engine.metrics = Metrics.create(engine.metrics); @@ -8390,7 +8390,7 @@ const main = function () { // trigger collision events if (pairs.collisionStart.length > 0) - Events.trigger(engine, 'collisionStart', {pairs: pairs.collisionStart}); + Events.trigger(engine, 'collisionStart', { pairs: pairs.collisionStart }); // iteratively resolve position between collisions Resolver.preSolvePosition(pairs.list); @@ -8414,9 +8414,9 @@ const main = function () { // trigger collision events if (pairs.collisionActive.length > 0) - Events.trigger(engine, 'collisionActive', {pairs: pairs.collisionActive}); + Events.trigger(engine, 'collisionActive', { pairs: pairs.collisionActive }); - if (pairs.collisionEnd.length > 0) Events.trigger(engine, 'collisionEnd', {pairs: pairs.collisionEnd}); + if (pairs.collisionEnd.length > 0) Events.trigger(engine, 'collisionEnd', { pairs: pairs.collisionEnd }); // @if DEBUG // update metrics log @@ -9015,7 +9015,7 @@ const main = function () { rayLength = Vector.magnitude(Vector.sub(startPoint, endPoint)), rayX = (endPoint.x + startPoint.x) * 0.5, rayY = (endPoint.y + startPoint.y) * 0.5, - ray = Bodies.rectangle(rayX, rayY, rayLength, rayWidth, {angle: rayAngle}), + ray = Bodies.rectangle(rayX, rayY, rayLength, rayWidth, { angle: rayAngle }), collisions = Query.collides(ray, bodies); for (var i = 0; i < collisions.length; i += 1) { @@ -9142,7 +9142,7 @@ const main = function () { var constraint = Constraint.create({ label: 'Mouse Constraint', pointA: mouse.position, - pointB: {x: 0, y: 0}, + pointB: { x: 0, y: 0 }, length: 0.01, stiffness: 0.1, angularStiffness: 1, @@ -9208,7 +9208,7 @@ const main = function () { constraint.angleB = body.angle; Sleeping.set(body, false); - Events.trigger(mouseConstraint, 'startdrag', {mouse: mouse, body: body}); + Events.trigger(mouseConstraint, 'startdrag', { mouse: mouse, body: body }); break; } @@ -9223,7 +9223,7 @@ const main = function () { constraint.bodyB = mouseConstraint.body = null; constraint.pointB = null; - if (body) Events.trigger(mouseConstraint, 'enddrag', {mouse: mouse, body: body}); + if (body) Events.trigger(mouseConstraint, 'enddrag', { mouse: mouse, body: body }); } }; @@ -9237,11 +9237,11 @@ const main = function () { var mouse = mouseConstraint.mouse, mouseEvents = mouse.sourceEvents; - if (mouseEvents.mousemove) Events.trigger(mouseConstraint, 'mousemove', {mouse: mouse}); + if (mouseEvents.mousemove) Events.trigger(mouseConstraint, 'mousemove', { mouse: mouse }); - if (mouseEvents.mousedown) Events.trigger(mouseConstraint, 'mousedown', {mouse: mouse}); + if (mouseEvents.mousedown) Events.trigger(mouseConstraint, 'mousedown', { mouse: mouse }); - if (mouseEvents.mouseup) Events.trigger(mouseConstraint, 'mouseup', {mouse: mouse}); + if (mouseEvents.mouseup) Events.trigger(mouseConstraint, 'mouseup', { mouse: mouse }); // reset the mouse state ready for the next step Mouse.clearSourceEvents(mouse); @@ -9729,7 +9729,7 @@ const main = function () { * @return {composite} A new composite containing objects created in the callback */ Composites.stack = function (xx, yy, columns, rows, columnGap, rowGap, callback) { - var stack = Composite.create({label: 'Stack'}), + var stack = Composite.create({ label: 'Stack' }), x = xx, y = yy, lastBody, @@ -9747,7 +9747,7 @@ const main = function () { if (bodyHeight > maxHeight) maxHeight = bodyHeight; - Body.translate(body, {x: bodyWidth * 0.5, y: bodyHeight * 0.5}); + Body.translate(body, { x: bodyWidth * 0.5, y: bodyHeight * 0.5 }); x = body.bounds.max.x + columnGap; @@ -9791,9 +9791,9 @@ const main = function () { var defaults = { bodyA: bodyA, - pointA: {x: bodyAWidth * xOffsetA, y: bodyAHeight * yOffsetA}, + pointA: { x: bodyAWidth * xOffsetA, y: bodyAHeight * yOffsetA }, bodyB: bodyB, - pointB: {x: bodyBWidth * xOffsetB, y: bodyBHeight * yOffsetB}, + pointB: { x: bodyBWidth * xOffsetB, y: bodyBHeight * yOffsetB }, }; var constraint = Common.extend(defaults, options); @@ -9830,7 +9830,7 @@ const main = function () { bodyB = bodies[col + row * columns]; Composite.addConstraint( composite, - Constraint.create(Common.extend({bodyA: bodyA, bodyB: bodyB}, options)), + Constraint.create(Common.extend({ bodyA: bodyA, bodyB: bodyB }, options)), ); } @@ -9840,14 +9840,14 @@ const main = function () { bodyB = bodies[col + row * columns]; Composite.addConstraint( composite, - Constraint.create(Common.extend({bodyA: bodyA, bodyB: bodyB}, options)), + Constraint.create(Common.extend({ bodyA: bodyA, bodyB: bodyB }, options)), ); if (crossBrace && col > 0) { bodyC = bodies[col - 1 + (row - 1) * columns]; Composite.addConstraint( composite, - Constraint.create(Common.extend({bodyA: bodyC, bodyB: bodyB}, options)), + Constraint.create(Common.extend({ bodyA: bodyC, bodyB: bodyB }, options)), ); } @@ -9855,7 +9855,7 @@ const main = function () { bodyC = bodies[col + 1 + (row - 1) * columns]; Composite.addConstraint( composite, - Constraint.create(Common.extend({bodyA: bodyC, bodyB: bodyB}, options)), + Constraint.create(Common.extend({ bodyA: bodyC, bodyB: bodyB }, options)), ); } } @@ -9904,7 +9904,7 @@ const main = function () { // retroactively fix the first body's position, since width was unknown if (i === 1) { - Body.translate(lastBody, {x: (column + (columns % 2 === 1 ? 1 : -1)) * lastBodyWidth, y: 0}); + Body.translate(lastBody, { x: (column + (columns % 2 === 1 ? 1 : -1)) * lastBodyWidth, y: 0 }); } var xOffset = lastBody ? column * lastBodyWidth : 0; @@ -9925,7 +9925,7 @@ const main = function () { * @return {composite} A new composite newtonsCradle body */ Composites.newtonsCradle = function (xx, yy, number, size, length) { - var newtonsCradle = Composite.create({label: 'Newtons Cradle'}); + var newtonsCradle = Composite.create({ label: 'Newtons Cradle' }); for (var i = 0; i < number; i++) { var separation = 1.9, @@ -9936,7 +9936,7 @@ const main = function () { frictionAir: 0.0001, slop: 1, }), - constraint = Constraint.create({pointA: {x: xx + i * (size * separation), y: yy}, bodyB: circle}); + constraint = Constraint.create({ pointA: { x: xx + i * (size * separation), y: yy }, bodyB: circle }); Composite.addBody(newtonsCradle, circle); Composite.addConstraint(newtonsCradle, constraint); @@ -9962,7 +9962,7 @@ const main = function () { wheelBOffset = width * 0.5 - wheelBase, wheelYOffset = 0; - var car = Composite.create({label: 'Car'}), + var car = Composite.create({ label: 'Car' }), body = Bodies.rectangle(xx, yy, width, height, { collisionFilter: { group: group, @@ -9989,7 +9989,7 @@ const main = function () { var axelA = Constraint.create({ bodyB: body, - pointB: {x: wheelAOffset, y: wheelYOffset}, + pointB: { x: wheelAOffset, y: wheelYOffset }, bodyA: wheelA, stiffness: 1, length: 0, @@ -9997,7 +9997,7 @@ const main = function () { var axelB = Constraint.create({ bodyB: body, - pointB: {x: wheelBOffset, y: wheelYOffset}, + pointB: { x: wheelBOffset, y: wheelYOffset }, bodyA: wheelB, stiffness: 1, length: 0, @@ -10039,9 +10039,9 @@ const main = function () { particleOptions, constraintOptions, ) { - particleOptions = Common.extend({inertia: Infinity}, particleOptions); + particleOptions = Common.extend({ inertia: Infinity }, particleOptions); constraintOptions = Common.extend( - {stiffness: 0.2, render: {type: 'line', anchors: false}}, + { stiffness: 0.2, render: { type: 'line', anchors: false } }, constraintOptions, ); diff --git a/packages/plugin-renderer-dragonbone/README.md b/packages/plugin-renderer-dragonbone/README.md index 1dc5f304..c7e16a03 100644 --- a/packages/plugin-renderer-dragonbone/README.md +++ b/packages/plugin-renderer-dragonbone/README.md @@ -1,7 +1,6 @@ - # @eva/plugin-renderer-dragonbone More Introduction + - [EN](https://eva.js.org) - [中文](https://eva-engine.gitee.io) - \ No newline at end of file diff --git a/packages/plugin-renderer-dragonbone/api-extractor.json b/packages/plugin-renderer-dragonbone/api-extractor.json index 811b506e..249324f6 100644 --- a/packages/plugin-renderer-dragonbone/api-extractor.json +++ b/packages/plugin-renderer-dragonbone/api-extractor.json @@ -4,4 +4,4 @@ "dtsRollup": { "publicTrimmedFilePath": "./dist/plugin-renderer-dragonbone.d.ts" } -} \ No newline at end of file +} diff --git a/packages/plugin-renderer-dragonbone/index.js b/packages/plugin-renderer-dragonbone/index.js index afa052b7..90171813 100644 --- a/packages/plugin-renderer-dragonbone/index.js +++ b/packages/plugin-renderer-dragonbone/index.js @@ -1,7 +1,7 @@ -'use strict' +'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/plugin-renderer-dragonbone.cjs.prod.js') + module.exports = require('./dist/plugin-renderer-dragonbone.cjs.prod.js'); } else { - module.exports = require('./dist/plugin-renderer-dragonbone.cjs.js') + module.exports = require('./dist/plugin-renderer-dragonbone.cjs.js'); } diff --git a/packages/plugin-renderer-dragonbone/lib/component.ts b/packages/plugin-renderer-dragonbone/lib/component.ts index b900050d..e9c0a9e5 100644 --- a/packages/plugin-renderer-dragonbone/lib/component.ts +++ b/packages/plugin-renderer-dragonbone/lib/component.ts @@ -24,9 +24,7 @@ export default class DragonBone extends Component { init(obj?: DragonBoneParams) { if (!obj) return; if (!obj.armatureName) { - throw new Error( - `The dragonBone component on ${this.gameObject.name}, armatureName is required!`, - ); + throw new Error(`The dragonBone component on ${this.gameObject.name}, armatureName is required!`); } Object.assign(this, obj); if (this.autoPlay) { diff --git a/packages/plugin-renderer-dragonbone/lib/db.js b/packages/plugin-renderer-dragonbone/lib/db.js index bc9c10a4..05139716 100644 --- a/packages/plugin-renderer-dragonbone/lib/db.js +++ b/packages/plugin-renderer-dragonbone/lib/db.js @@ -1,12 +1,4 @@ -import { - Texture, - Sprite, - Graphics, - mesh, - ticker, - BLEND_MODES, - Rectangle, -} from 'pixi.js'; +import { Texture, Sprite, Graphics, mesh, ticker, BLEND_MODES, Rectangle } from 'pixi.js'; const PIXI = { Texture, @@ -22,25 +14,22 @@ var dragonBones; ('use strict'); var __extends = (this && this.__extends) || - (function() { + (function () { var extendStatics = Object.setPrototypeOf || - ({__proto__: []} instanceof Array && - function(d, b) { + ({ __proto__: [] } instanceof Array && + function (d, b) { d.__proto__ = b; }) || - function(d, b) { + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return function(d, b) { + return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } - d.prototype = - b === null - ? Object.create(b) - : ((__.prototype = b.prototype), new __()); + d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __()); }; })(); /** @@ -66,11 +55,11 @@ var __extends = * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * @private */ - var DragonBones = /** @class */ (function() { + var DragonBones = /** @class */ (function () { function DragonBones(eventManager) { this._clock = new dragonBones.WorldClock(); this._events = []; @@ -83,7 +72,7 @@ var __extends = '\nWebsite: http://dragonbones.com/\nSource and Demo: https://github.com/DragonBones/', ); } - DragonBones.prototype.advanceTime = function(passedTime) { + DragonBones.prototype.advanceTime = function (passedTime) { if (this._objects.length > 0) { for (var _i = 0, _a = this._objects; _i < _a.length; _i++) { var object = _a[_i]; @@ -97,10 +86,7 @@ var __extends = var eventObject = this._events[i]; var armature = eventObject.armature; if (armature._armatureData !== null) { - armature.eventDispatcher.dispatchDBEvent( - eventObject.type, - eventObject, - ); + armature.eventDispatcher.dispatchDBEvent(eventObject.type, eventObject); if (eventObject.type === dragonBones.EventObject.SOUND_EVENT) { this._eventManager.dispatchDBEvent(eventObject.type, eventObject); } @@ -110,25 +96,25 @@ var __extends = this._events.length = 0; } }; - DragonBones.prototype.bufferEvent = function(value) { + DragonBones.prototype.bufferEvent = function (value) { if (this._events.indexOf(value) < 0) { this._events.push(value); } }; - DragonBones.prototype.bufferObject = function(object) { + DragonBones.prototype.bufferObject = function (object) { if (this._objects.indexOf(object) < 0) { this._objects.push(object); } }; Object.defineProperty(DragonBones.prototype, 'clock', { - get: function() { + get: function () { return this._clock; }, enumerable: true, configurable: true, }); Object.defineProperty(DragonBones.prototype, 'eventManager', { - get: function() { + get: function () { return this._eventManager; }, enumerable: true, @@ -144,10 +130,10 @@ var __extends = })(dragonBones || (dragonBones = {})); // if (!console.warn) { - console.warn = function() {}; + console.warn = function () {}; } if (!console.assert) { - console.assert = function() {}; + console.assert = function () {}; } // if (!Date.now) { @@ -179,7 +165,7 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * - The BaseObject is the base class for all objects in the DragonBones framework. * All BaseObject instances are cached to the object pool to reduce the performance consumption of frequent requests for memory or memory recovery. @@ -192,7 +178,7 @@ if (!Date.now) { * @version DragonBones 4.5 * @language zh_CN */ - var BaseObject = /** @class */ (function() { + var BaseObject = /** @class */ (function () { function BaseObject() { /** * - A unique identification number assigned to the object. @@ -207,14 +193,11 @@ if (!Date.now) { this.hashCode = BaseObject._hashCode++; this._isInPool = false; } - BaseObject._returnObject = function(object) { + BaseObject._returnObject = function (object) { var classType = String(object.constructor); var maxCount = - classType in BaseObject._maxCountMap - ? BaseObject._maxCountMap[classType] - : BaseObject._defaultMaxCount; - var pool = (BaseObject._poolsMap[classType] = - BaseObject._poolsMap[classType] || []); + classType in BaseObject._maxCountMap ? BaseObject._maxCountMap[classType] : BaseObject._defaultMaxCount; + var pool = (BaseObject._poolsMap[classType] = BaseObject._poolsMap[classType] || []); if (pool.length < maxCount) { if (!object._isInPool) { object._isInPool = true; @@ -225,7 +208,7 @@ if (!Date.now) { } else { } }; - BaseObject.toString = function() { + BaseObject.toString = function () { throw new Error(); }; /** @@ -242,16 +225,13 @@ if (!Date.now) { * @version DragonBones 4.5 * @language zh_CN */ - BaseObject.setMaxCount = function(objectConstructor, maxCount) { + BaseObject.setMaxCount = function (objectConstructor, maxCount) { if (maxCount < 0 || maxCount !== maxCount) { maxCount = 0; } if (objectConstructor !== null) { var classType = String(objectConstructor); - var pool = - classType in BaseObject._poolsMap - ? BaseObject._poolsMap[classType] - : null; + var pool = classType in BaseObject._poolsMap ? BaseObject._poolsMap[classType] : null; if (pool !== null && pool.length > maxCount) { pool.length = maxCount; } @@ -281,16 +261,13 @@ if (!Date.now) { * @version DragonBones 4.5 * @language zh_CN */ - BaseObject.clearPool = function(objectConstructor) { + BaseObject.clearPool = function (objectConstructor) { if (objectConstructor === void 0) { objectConstructor = null; } if (objectConstructor !== null) { var classType = String(objectConstructor); - var pool = - classType in BaseObject._poolsMap - ? BaseObject._poolsMap[classType] - : null; + var pool = classType in BaseObject._poolsMap ? BaseObject._poolsMap[classType] : null; if (pool !== null && pool.length > 0) { pool.length = 0; } @@ -313,12 +290,9 @@ if (!Date.now) { * @version DragonBones 4.5 * @language zh_CN */ - BaseObject.borrowObject = function(objectConstructor) { + BaseObject.borrowObject = function (objectConstructor) { var classType = String(objectConstructor); - var pool = - classType in BaseObject._poolsMap - ? BaseObject._poolsMap[classType] - : null; + var pool = classType in BaseObject._poolsMap ? BaseObject._poolsMap[classType] : null; if (pool !== null && pool.length > 0) { var object_1 = pool.pop(); object_1._isInPool = false; @@ -338,7 +312,7 @@ if (!Date.now) { * @version DragonBones 4.5 * @language zh_CN */ - BaseObject.prototype.returnToPool = function() { + BaseObject.prototype.returnToPool = function () { this._onClear(); BaseObject._returnObject(this); }; @@ -373,7 +347,7 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * - 2D Transform matrix. * @version DragonBones 3.0 @@ -384,7 +358,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - var Matrix = /** @class */ (function() { + var Matrix = /** @class */ (function () { /** * @private */ @@ -414,7 +388,7 @@ if (!Date.now) { this.tx = tx; this.ty = ty; } - Matrix.prototype.toString = function() { + Matrix.prototype.toString = function () { return ( '[object dragonBones.Matrix] a:' + this.a + @@ -433,7 +407,7 @@ if (!Date.now) { /** * @private */ - Matrix.prototype.copyFrom = function(value) { + Matrix.prototype.copyFrom = function (value) { this.a = value.a; this.b = value.b; this.c = value.c; @@ -445,7 +419,7 @@ if (!Date.now) { /** * @private */ - Matrix.prototype.copyFromArray = function(value, offset) { + Matrix.prototype.copyFromArray = function (value, offset) { if (offset === void 0) { offset = 0; } @@ -469,7 +443,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - Matrix.prototype.identity = function() { + Matrix.prototype.identity = function () { this.a = this.d = 1.0; this.b = this.c = 0.0; this.tx = this.ty = 0.0; @@ -487,7 +461,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - Matrix.prototype.concat = function(value) { + Matrix.prototype.concat = function (value) { var aA = this.a * value.a; var bA = 0.0; var cA = 0.0; @@ -524,7 +498,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - Matrix.prototype.invert = function() { + Matrix.prototype.invert = function () { var aA = this.a; var bA = this.b; var cA = this.c; @@ -577,7 +551,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - Matrix.prototype.transformPoint = function(x, y, result, delta) { + Matrix.prototype.transformPoint = function (x, y, result, delta) { if (delta === void 0) { delta = false; } @@ -591,7 +565,7 @@ if (!Date.now) { /** * @private */ - Matrix.prototype.transformRectangle = function(rectangle, delta) { + Matrix.prototype.transformRectangle = function (rectangle, delta) { if (delta === void 0) { delta = false; } @@ -666,7 +640,7 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * - 2D Transform. * @version DragonBones 3.0 @@ -677,7 +651,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - var Transform = /** @class */ (function() { + var Transform = /** @class */ (function () { /** * @private */ @@ -710,12 +684,12 @@ if (!Date.now) { /** * @private */ - Transform.normalizeRadian = function(value) { + Transform.normalizeRadian = function (value) { value = (value + Math.PI) % (Math.PI * 2.0); value += value > 0.0 ? -Math.PI : Math.PI; return value; }; - Transform.prototype.toString = function() { + Transform.prototype.toString = function () { return ( '[object dragonBones.Transform] x:' + this.x + @@ -734,7 +708,7 @@ if (!Date.now) { /** * @private */ - Transform.prototype.copyFrom = function(value) { + Transform.prototype.copyFrom = function (value) { this.x = value.x; this.y = value.y; this.skew = value.skew; @@ -746,7 +720,7 @@ if (!Date.now) { /** * @private */ - Transform.prototype.identity = function() { + Transform.prototype.identity = function () { this.x = this.y = 0.0; this.skew = this.rotation = 0.0; this.scaleX = this.scaleY = 1.0; @@ -755,7 +729,7 @@ if (!Date.now) { /** * @private */ - Transform.prototype.add = function(value) { + Transform.prototype.add = function (value) { this.x += value.x; this.y += value.y; this.skew += value.skew; @@ -767,7 +741,7 @@ if (!Date.now) { /** * @private */ - Transform.prototype.minus = function(value) { + Transform.prototype.minus = function (value) { this.x -= value.x; this.y -= value.y; this.skew -= value.skew; @@ -779,7 +753,7 @@ if (!Date.now) { /** * @private */ - Transform.prototype.fromMatrix = function(matrix) { + Transform.prototype.fromMatrix = function (matrix) { var backupScaleX = this.scaleX, backupScaleY = this.scaleY; var PI_Q = Transform.PI_Q; @@ -791,10 +765,7 @@ if (!Date.now) { this.rotation > -PI_Q && this.rotation < PI_Q ? matrix.a / Math.cos(this.rotation) : matrix.b / Math.sin(this.rotation); - this.scaleY = - skewX > -PI_Q && skewX < PI_Q - ? matrix.d / Math.cos(skewX) - : -matrix.c / Math.sin(skewX); + this.scaleY = skewX > -PI_Q && skewX < PI_Q ? matrix.d / Math.cos(skewX) : -matrix.c / Math.sin(skewX); if (backupScaleX >= 0.0 && this.scaleX < 0.0) { this.scaleX = -this.scaleX; this.rotation = this.rotation - Math.PI; @@ -809,7 +780,7 @@ if (!Date.now) { /** * @private */ - Transform.prototype.toMatrix = function(matrix) { + Transform.prototype.toMatrix = function (matrix) { if (this.rotation === 0.0) { matrix.a = 1.0; matrix.b = 0.0; @@ -887,11 +858,11 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * @private */ - var ColorTransform = /** @class */ (function() { + var ColorTransform = /** @class */ (function () { function ColorTransform( alphaMultiplier, redMultiplier, @@ -935,7 +906,7 @@ if (!Date.now) { this.greenOffset = greenOffset; this.blueOffset = blueOffset; } - ColorTransform.prototype.copyFrom = function(value) { + ColorTransform.prototype.copyFrom = function (value) { this.alphaMultiplier = value.alphaMultiplier; this.redMultiplier = value.redMultiplier; this.greenMultiplier = value.greenMultiplier; @@ -945,7 +916,7 @@ if (!Date.now) { this.greenOffset = value.greenOffset; this.blueOffset = value.blueOffset; }; - ColorTransform.prototype.identity = function() { + ColorTransform.prototype.identity = function () { this.alphaMultiplier = this.redMultiplier = this.greenMultiplier = this.blueMultiplier = 1.0; this.alphaOffset = this.redOffset = this.greenOffset = this.blueOffset = 0; }; @@ -976,7 +947,7 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * - The Point object represents a location in a two-dimensional coordinate system. * @version DragonBones 3.0 @@ -987,7 +958,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - var Point = /** @class */ (function() { + var Point = /** @class */ (function () { /** * - Creates a new point. If you pass no parameters to this method, a point is created at (0,0). * @param x - The horizontal coordinate. @@ -1015,14 +986,14 @@ if (!Date.now) { /** * @private */ - Point.prototype.copyFrom = function(value) { + Point.prototype.copyFrom = function (value) { this.x = value.x; this.y = value.y; }; /** * @private */ - Point.prototype.clear = function() { + Point.prototype.clear = function () { this.x = this.y = 0.0; }; return Point; @@ -1052,7 +1023,7 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * - A Rectangle object is an area defined by its position, as indicated by its top-left corner point (x, y) and by its * width and its height.
@@ -1071,7 +1042,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - var Rectangle = /** @class */ (function() { + var Rectangle = /** @class */ (function () { /** * @private */ @@ -1096,7 +1067,7 @@ if (!Date.now) { /** * @private */ - Rectangle.prototype.copyFrom = function(value) { + Rectangle.prototype.copyFrom = function (value) { this.x = value.x; this.y = value.y; this.width = value.width; @@ -1105,7 +1076,7 @@ if (!Date.now) { /** * @private */ - Rectangle.prototype.clear = function() { + Rectangle.prototype.clear = function () { this.x = this.y = 0.0; this.width = this.height = 0.0; }; @@ -1136,7 +1107,7 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * - The user custom data. * @version DragonBones 5.0 @@ -1147,7 +1118,7 @@ if (!Date.now) { * @version DragonBones 5.0 * @language zh_CN */ - var UserData = /** @class */ (function(_super) { + var UserData = /** @class */ (function (_super) { __extends(UserData, _super); function UserData() { var _this = (_super !== null && _super.apply(this, arguments)) || this; @@ -1186,10 +1157,10 @@ if (!Date.now) { _this.strings = []; return _this; } - UserData.toString = function() { + UserData.toString = function () { return '[class dragonBones.UserData]'; }; - UserData.prototype._onClear = function() { + UserData.prototype._onClear = function () { this.ints.length = 0; this.floats.length = 0; this.strings.length = 0; @@ -1197,19 +1168,19 @@ if (!Date.now) { /** * @internal */ - UserData.prototype.addInt = function(value) { + UserData.prototype.addInt = function (value) { this.ints.push(value); }; /** * @internal */ - UserData.prototype.addFloat = function(value) { + UserData.prototype.addFloat = function (value) { this.floats.push(value); }; /** * @internal */ - UserData.prototype.addString = function(value) { + UserData.prototype.addString = function (value) { this.strings.push(value); }; /** @@ -1222,7 +1193,7 @@ if (!Date.now) { * @version DragonBones 5.0 * @language zh_CN */ - UserData.prototype.getInt = function(index) { + UserData.prototype.getInt = function (index) { if (index === void 0) { index = 0; } @@ -1238,13 +1209,11 @@ if (!Date.now) { * @version DragonBones 5.0 * @language zh_CN */ - UserData.prototype.getFloat = function(index) { + UserData.prototype.getFloat = function (index) { if (index === void 0) { index = 0; } - return index >= 0 && index < this.floats.length - ? this.floats[index] - : 0.0; + return index >= 0 && index < this.floats.length ? this.floats[index] : 0.0; }; /** * - Get the custom string. @@ -1256,13 +1225,11 @@ if (!Date.now) { * @version DragonBones 5.0 * @language zh_CN */ - UserData.prototype.getString = function(index) { + UserData.prototype.getString = function (index) { if (index === void 0) { index = 0; } - return index >= 0 && index < this.strings.length - ? this.strings[index] - : ''; + return index >= 0 && index < this.strings.length ? this.strings[index] : ''; }; return UserData; })(dragonBones.BaseObject); @@ -1270,17 +1237,17 @@ if (!Date.now) { /** * @private */ - var ActionData = /** @class */ (function(_super) { + var ActionData = /** @class */ (function (_super) { __extends(ActionData, _super); function ActionData() { var _this = (_super !== null && _super.apply(this, arguments)) || this; _this.data = null; // return _this; } - ActionData.toString = function() { + ActionData.toString = function () { return '[class dragonBones.ActionData]'; }; - ActionData.prototype._onClear = function() { + ActionData.prototype._onClear = function () { if (this.data !== null) { this.data.returnToPool(); } @@ -1317,7 +1284,7 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * - The DragonBones data. * A DragonBones data contains multiple armature data. @@ -1332,7 +1299,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - var DragonBonesData = /** @class */ (function(_super) { + var DragonBonesData = /** @class */ (function (_super) { __extends(DragonBonesData, _super); function DragonBonesData() { var _this = (_super !== null && _super.apply(this, arguments)) || this; @@ -1365,10 +1332,10 @@ if (!Date.now) { _this.userData = null; // Initial value. return _this; } - DragonBonesData.toString = function() { + DragonBonesData.toString = function () { return '[class dragonBones.DragonBonesData]'; }; - DragonBonesData.prototype._onClear = function() { + DragonBonesData.prototype._onClear = function () { for (var k in this.armatures) { this.armatures[k].returnToPool(); delete this.armatures[k]; @@ -1398,7 +1365,7 @@ if (!Date.now) { /** * @internal */ - DragonBonesData.prototype.addArmature = function(value) { + DragonBonesData.prototype.addArmature = function (value) { if (value.name in this.armatures) { console.warn('Same armature: ' + value.name); return; @@ -1419,10 +1386,8 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - DragonBonesData.prototype.getArmature = function(armatureName) { - return armatureName in this.armatures - ? this.armatures[armatureName] - : null; + DragonBonesData.prototype.getArmature = function (armatureName) { + return armatureName in this.armatures ? this.armatures[armatureName] : null; }; return DragonBonesData; })(dragonBones.BaseObject); @@ -1451,7 +1416,7 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * - The armature data. * @version DragonBones 3.0 @@ -1462,7 +1427,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - var ArmatureData = /** @class */ (function(_super) { + var ArmatureData = /** @class */ (function (_super) { __extends(ArmatureData, _super); function ArmatureData() { var _this = (_super !== null && _super.apply(this, arguments)) || this; @@ -1527,10 +1492,10 @@ if (!Date.now) { _this.userData = null; // Initial value. return _this; } - ArmatureData.toString = function() { + ArmatureData.toString = function () { return '[class dragonBones.ArmatureData]'; }; - ArmatureData.prototype._onClear = function() { + ArmatureData.prototype._onClear = function () { for (var _i = 0, _a = this.defaultActions; _i < _a.length; _i++) { var action = _a[_i]; action.returnToPool(); @@ -1590,7 +1555,7 @@ if (!Date.now) { /** * @internal */ - ArmatureData.prototype.sortBones = function() { + ArmatureData.prototype.sortBones = function () { var total = this.sortedBones.length; if (total <= 0) { return; @@ -1610,10 +1575,7 @@ if (!Date.now) { var flag = false; for (var k in this.constraints) { var constraint = this.constraints[k]; - if ( - constraint.root === bone && - this.sortedBones.indexOf(constraint.target) < 0 - ) { + if (constraint.root === bone && this.sortedBones.indexOf(constraint.target) < 0) { flag = true; break; } @@ -1631,7 +1593,7 @@ if (!Date.now) { /** * @internal */ - ArmatureData.prototype.cacheFrames = function(frameRate) { + ArmatureData.prototype.cacheFrames = function (frameRate) { if (this.cacheFrameRate > 0) { return; } @@ -1643,10 +1605,7 @@ if (!Date.now) { /** * @internal */ - ArmatureData.prototype.setCacheFrame = function( - globalTransformMatrix, - transform, - ) { + ArmatureData.prototype.setCacheFrame = function (globalTransformMatrix, transform) { var dataArray = this.parent.cachedFrames; var arrayOffset = dataArray.length; dataArray.length += 10; @@ -1665,11 +1624,7 @@ if (!Date.now) { /** * @internal */ - ArmatureData.prototype.getCacheFrame = function( - globalTransformMatrix, - transform, - arrayOffset, - ) { + ArmatureData.prototype.getCacheFrame = function (globalTransformMatrix, transform, arrayOffset) { var dataArray = this.parent.cachedFrames; globalTransformMatrix.a = dataArray[arrayOffset]; globalTransformMatrix.b = dataArray[arrayOffset + 1]; @@ -1687,7 +1642,7 @@ if (!Date.now) { /** * @internal */ - ArmatureData.prototype.addBone = function(value) { + ArmatureData.prototype.addBone = function (value) { if (value.name in this.bones) { console.warn('Same bone: ' + value.name); return; @@ -1698,7 +1653,7 @@ if (!Date.now) { /** * @internal */ - ArmatureData.prototype.addSlot = function(value) { + ArmatureData.prototype.addSlot = function (value) { if (value.name in this.slots) { console.warn('Same slot: ' + value.name); return; @@ -1709,7 +1664,7 @@ if (!Date.now) { /** * @internal */ - ArmatureData.prototype.addConstraint = function(value) { + ArmatureData.prototype.addConstraint = function (value) { if (value.name in this.constraints) { console.warn('Same constraint: ' + value.name); return; @@ -1719,7 +1674,7 @@ if (!Date.now) { /** * @internal */ - ArmatureData.prototype.addSkin = function(value) { + ArmatureData.prototype.addSkin = function (value) { if (value.name in this.skins) { console.warn('Same skin: ' + value.name); return; @@ -1736,7 +1691,7 @@ if (!Date.now) { /** * @internal */ - ArmatureData.prototype.addAnimation = function(value) { + ArmatureData.prototype.addAnimation = function (value) { if (value.name in this.animations) { console.warn('Same animation: ' + value.name); return; @@ -1751,7 +1706,7 @@ if (!Date.now) { /** * @internal */ - ArmatureData.prototype.addAction = function(value, isDefault) { + ArmatureData.prototype.addAction = function (value, isDefault) { if (isDefault) { this.defaultActions.push(value); } else { @@ -1770,7 +1725,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - ArmatureData.prototype.getBone = function(boneName) { + ArmatureData.prototype.getBone = function (boneName) { return boneName in this.bones ? this.bones[boneName] : null; }; /** @@ -1785,16 +1740,14 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - ArmatureData.prototype.getSlot = function(slotName) { + ArmatureData.prototype.getSlot = function (slotName) { return slotName in this.slots ? this.slots[slotName] : null; }; /** * @private */ - ArmatureData.prototype.getConstraint = function(constraintName) { - return constraintName in this.constraints - ? this.constraints[constraintName] - : null; + ArmatureData.prototype.getConstraint = function (constraintName) { + return constraintName in this.constraints ? this.constraints[constraintName] : null; }; /** * - Get a specific skin data. @@ -1808,13 +1761,13 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - ArmatureData.prototype.getSkin = function(skinName) { + ArmatureData.prototype.getSkin = function (skinName) { return skinName in this.skins ? this.skins[skinName] : null; }; /** * @private */ - ArmatureData.prototype.getMesh = function(skinName, slotName, meshName) { + ArmatureData.prototype.getMesh = function (skinName, slotName, meshName) { var skin = this.getSkin(skinName); if (skin === null) { return null; @@ -1833,10 +1786,8 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - ArmatureData.prototype.getAnimation = function(animationName) { - return animationName in this.animations - ? this.animations[animationName] - : null; + ArmatureData.prototype.getAnimation = function (animationName) { + return animationName in this.animations ? this.animations[animationName] : null; }; return ArmatureData; })(dragonBones.BaseObject); @@ -1851,7 +1802,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - var BoneData = /** @class */ (function(_super) { + var BoneData = /** @class */ (function (_super) { __extends(BoneData, _super); function BoneData() { var _this = (_super !== null && _super.apply(this, arguments)) || this; @@ -1865,10 +1816,10 @@ if (!Date.now) { _this.userData = null; // Initial value. return _this; } - BoneData.toString = function() { + BoneData.toString = function () { return '[class dragonBones.BoneData]'; }; - BoneData.prototype._onClear = function() { + BoneData.prototype._onClear = function () { if (this.userData !== null) { this.userData.returnToPool(); } @@ -1890,17 +1841,17 @@ if (!Date.now) { /** * @internal */ - var SurfaceData = /** @class */ (function(_super) { + var SurfaceData = /** @class */ (function (_super) { __extends(SurfaceData, _super); function SurfaceData() { var _this = (_super !== null && _super.apply(this, arguments)) || this; _this.geometry = new dragonBones.GeometryData(); return _this; } - SurfaceData.toString = function() { + SurfaceData.toString = function () { return '[class dragonBones.SurfaceData]'; }; - SurfaceData.prototype._onClear = function() { + SurfaceData.prototype._onClear = function () { _super.prototype._onClear.call(this); this.type = 1 /* Surface */; this.segmentX = 0; @@ -1920,7 +1871,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - var SlotData = /** @class */ (function(_super) { + var SlotData = /** @class */ (function (_super) { __extends(SlotData, _super); function SlotData() { var _this = (_super !== null && _super.apply(this, arguments)) || this; @@ -1937,13 +1888,13 @@ if (!Date.now) { /** * @internal */ - SlotData.createColor = function() { + SlotData.createColor = function () { return new dragonBones.ColorTransform(); }; - SlotData.toString = function() { + SlotData.toString = function () { return '[class dragonBones.SlotData]'; }; - SlotData.prototype._onClear = function() { + SlotData.prototype._onClear = function () { if (this.userData !== null) { this.userData.returnToPool(); } @@ -1988,16 +1939,16 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * @private */ - var ConstraintData = /** @class */ (function(_super) { + var ConstraintData = /** @class */ (function (_super) { __extends(ConstraintData, _super); function ConstraintData() { return (_super !== null && _super.apply(this, arguments)) || this; } - ConstraintData.prototype._onClear = function() { + ConstraintData.prototype._onClear = function () { this.order = 0; this.name = ''; this.type = 0 /* IK */; @@ -2011,15 +1962,15 @@ if (!Date.now) { /** * @internal */ - var IKConstraintData = /** @class */ (function(_super) { + var IKConstraintData = /** @class */ (function (_super) { __extends(IKConstraintData, _super); function IKConstraintData() { return (_super !== null && _super.apply(this, arguments)) || this; } - IKConstraintData.toString = function() { + IKConstraintData.toString = function () { return '[class dragonBones.IKConstraintData]'; }; - IKConstraintData.prototype._onClear = function() { + IKConstraintData.prototype._onClear = function () { _super.prototype._onClear.call(this); this.scaleEnabled = false; this.bendPositive = false; @@ -2031,17 +1982,17 @@ if (!Date.now) { /** * @internal */ - var PathConstraintData = /** @class */ (function(_super) { + var PathConstraintData = /** @class */ (function (_super) { __extends(PathConstraintData, _super); function PathConstraintData() { var _this = (_super !== null && _super.apply(this, arguments)) || this; _this.bones = []; return _this; } - PathConstraintData.toString = function() { + PathConstraintData.toString = function () { return '[class dragonBones.PathConstraintData]'; }; - PathConstraintData.prototype._onClear = function() { + PathConstraintData.prototype._onClear = function () { _super.prototype._onClear.call(this); this.pathSlot = null; this.pathDisplayData = null; @@ -2055,7 +2006,7 @@ if (!Date.now) { this.rotateMix = 0.0; this.translateMix = 0.0; }; - PathConstraintData.prototype.AddBone = function(value) { + PathConstraintData.prototype.AddBone = function (value) { this.bones.push(value); }; return PathConstraintData; @@ -2085,19 +2036,19 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * @private */ - var CanvasData = /** @class */ (function(_super) { + var CanvasData = /** @class */ (function (_super) { __extends(CanvasData, _super); function CanvasData() { return (_super !== null && _super.apply(this, arguments)) || this; } - CanvasData.toString = function() { + CanvasData.toString = function () { return '[class dragonBones.CanvasData]'; }; - CanvasData.prototype._onClear = function() { + CanvasData.prototype._onClear = function () { this.hasBackground = false; this.color = 0x000000; this.x = 0; @@ -2132,7 +2083,7 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * - The skin data, typically a armature data instance contains at least one skinData. * @version DragonBones 3.0 @@ -2143,7 +2094,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - var SkinData = /** @class */ (function(_super) { + var SkinData = /** @class */ (function (_super) { __extends(SkinData, _super); function SkinData() { var _this = (_super !== null && _super.apply(this, arguments)) || this; @@ -2153,17 +2104,13 @@ if (!Date.now) { _this.displays = {}; return _this; } - SkinData.toString = function() { + SkinData.toString = function () { return '[class dragonBones.SkinData]'; }; - SkinData.prototype._onClear = function() { + SkinData.prototype._onClear = function () { for (var k in this.displays) { var slotDisplays = this.displays[k]; - for ( - var _i = 0, slotDisplays_1 = slotDisplays; - _i < slotDisplays_1.length; - _i++ - ) { + for (var _i = 0, slotDisplays_1 = slotDisplays; _i < slotDisplays_1.length; _i++) { var display = slotDisplays_1[_i]; if (display !== null) { display.returnToPool(); @@ -2178,7 +2125,7 @@ if (!Date.now) { /** * @internal */ - SkinData.prototype.addDisplay = function(slotName, value) { + SkinData.prototype.addDisplay = function (slotName, value) { if (!(slotName in this.displays)) { this.displays[slotName] = []; } @@ -2191,14 +2138,10 @@ if (!Date.now) { /** * @private */ - SkinData.prototype.getDisplay = function(slotName, displayName) { + SkinData.prototype.getDisplay = function (slotName, displayName) { var slotDisplays = this.getDisplays(slotName); if (slotDisplays !== null) { - for ( - var _i = 0, slotDisplays_2 = slotDisplays; - _i < slotDisplays_2.length; - _i++ - ) { + for (var _i = 0, slotDisplays_2 = slotDisplays; _i < slotDisplays_2.length; _i++) { var display = slotDisplays_2[_i]; if (display !== null && display.name === displayName) { return display; @@ -2210,7 +2153,7 @@ if (!Date.now) { /** * @private */ - SkinData.prototype.getDisplays = function(slotName) { + SkinData.prototype.getDisplays = function (slotName) { if (!(slotName in this.displays)) { return null; } @@ -2243,15 +2186,15 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * @private */ - var GeometryData = /** @class */ (function() { + var GeometryData = /** @class */ (function () { function GeometryData() { this.weight = null; // Initial value. } - GeometryData.prototype.clear = function() { + GeometryData.prototype.clear = function () { if (!this.isShared && this.weight !== null) { this.weight.returnToPool(); } @@ -2261,13 +2204,13 @@ if (!Date.now) { this.data = null; this.weight = null; }; - GeometryData.prototype.shareFrom = function(value) { + GeometryData.prototype.shareFrom = function (value) { this.isShared = true; this.offset = value.offset; this.weight = value.weight; }; Object.defineProperty(GeometryData.prototype, 'vertexCount', { - get: function() { + get: function () { var intArray = this.data.intArray; return intArray[this.offset + 0 /* GeometryVertexCount */]; }, @@ -2275,7 +2218,7 @@ if (!Date.now) { configurable: true, }); Object.defineProperty(GeometryData.prototype, 'triangleCount', { - get: function() { + get: function () { var intArray = this.data.intArray; return intArray[this.offset + 1 /* GeometryTriangleCount */]; }, @@ -2288,14 +2231,14 @@ if (!Date.now) { /** * @private */ - var DisplayData = /** @class */ (function(_super) { + var DisplayData = /** @class */ (function (_super) { __extends(DisplayData, _super); function DisplayData() { var _this = (_super !== null && _super.apply(this, arguments)) || this; _this.transform = new dragonBones.Transform(); return _this; } - DisplayData.prototype._onClear = function() { + DisplayData.prototype._onClear = function () { this.name = ''; this.path = ''; this.transform.identity(); @@ -2307,17 +2250,17 @@ if (!Date.now) { /** * @private */ - var ImageDisplayData = /** @class */ (function(_super) { + var ImageDisplayData = /** @class */ (function (_super) { __extends(ImageDisplayData, _super); function ImageDisplayData() { var _this = (_super !== null && _super.apply(this, arguments)) || this; _this.pivot = new dragonBones.Point(); return _this; } - ImageDisplayData.toString = function() { + ImageDisplayData.toString = function () { return '[class dragonBones.ImageDisplayData]'; }; - ImageDisplayData.prototype._onClear = function() { + ImageDisplayData.prototype._onClear = function () { _super.prototype._onClear.call(this); this.type = 0 /* Image */; this.pivot.clear(); @@ -2329,17 +2272,17 @@ if (!Date.now) { /** * @private */ - var ArmatureDisplayData = /** @class */ (function(_super) { + var ArmatureDisplayData = /** @class */ (function (_super) { __extends(ArmatureDisplayData, _super); function ArmatureDisplayData() { var _this = (_super !== null && _super.apply(this, arguments)) || this; _this.actions = []; return _this; } - ArmatureDisplayData.toString = function() { + ArmatureDisplayData.toString = function () { return '[class dragonBones.ArmatureDisplayData]'; }; - ArmatureDisplayData.prototype._onClear = function() { + ArmatureDisplayData.prototype._onClear = function () { _super.prototype._onClear.call(this); for (var _i = 0, _a = this.actions; _i < _a.length; _i++) { var action = _a[_i]; @@ -2353,7 +2296,7 @@ if (!Date.now) { /** * @private */ - ArmatureDisplayData.prototype.addAction = function(value) { + ArmatureDisplayData.prototype.addAction = function (value) { this.actions.push(value); }; return ArmatureDisplayData; @@ -2362,17 +2305,17 @@ if (!Date.now) { /** * @private */ - var MeshDisplayData = /** @class */ (function(_super) { + var MeshDisplayData = /** @class */ (function (_super) { __extends(MeshDisplayData, _super); function MeshDisplayData() { var _this = (_super !== null && _super.apply(this, arguments)) || this; _this.geometry = new GeometryData(); return _this; } - MeshDisplayData.toString = function() { + MeshDisplayData.toString = function () { return '[class dragonBones.MeshDisplayData]'; }; - MeshDisplayData.prototype._onClear = function() { + MeshDisplayData.prototype._onClear = function () { _super.prototype._onClear.call(this); this.type = 2 /* Mesh */; this.geometry.clear(); @@ -2384,17 +2327,17 @@ if (!Date.now) { /** * @private */ - var BoundingBoxDisplayData = /** @class */ (function(_super) { + var BoundingBoxDisplayData = /** @class */ (function (_super) { __extends(BoundingBoxDisplayData, _super); function BoundingBoxDisplayData() { var _this = (_super !== null && _super.apply(this, arguments)) || this; _this.boundingBox = null; // Initial value. return _this; } - BoundingBoxDisplayData.toString = function() { + BoundingBoxDisplayData.toString = function () { return '[class dragonBones.BoundingBoxDisplayData]'; }; - BoundingBoxDisplayData.prototype._onClear = function() { + BoundingBoxDisplayData.prototype._onClear = function () { _super.prototype._onClear.call(this); if (this.boundingBox !== null) { this.boundingBox.returnToPool(); @@ -2408,7 +2351,7 @@ if (!Date.now) { /** * @private */ - var PathDisplayData = /** @class */ (function(_super) { + var PathDisplayData = /** @class */ (function (_super) { __extends(PathDisplayData, _super); function PathDisplayData() { var _this = (_super !== null && _super.apply(this, arguments)) || this; @@ -2416,10 +2359,10 @@ if (!Date.now) { _this.curveLengths = []; return _this; } - PathDisplayData.toString = function() { + PathDisplayData.toString = function () { return '[class dragonBones.PathDisplayData]'; }; - PathDisplayData.prototype._onClear = function() { + PathDisplayData.prototype._onClear = function () { _super.prototype._onClear.call(this); this.type = 4 /* Path */; this.closed = false; @@ -2433,22 +2376,22 @@ if (!Date.now) { /** * @private */ - var WeightData = /** @class */ (function(_super) { + var WeightData = /** @class */ (function (_super) { __extends(WeightData, _super); function WeightData() { var _this = (_super !== null && _super.apply(this, arguments)) || this; _this.bones = []; return _this; } - WeightData.toString = function() { + WeightData.toString = function () { return '[class dragonBones.WeightData]'; }; - WeightData.prototype._onClear = function() { + WeightData.prototype._onClear = function () { this.count = 0; this.offset = 0; this.bones.length = 0; }; - WeightData.prototype.addBone = function(value) { + WeightData.prototype.addBone = function (value) { this.bones.push(value); }; return WeightData; @@ -2478,7 +2421,7 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * - The base class of bounding box data. * @see dragonBones.RectangleData @@ -2495,12 +2438,12 @@ if (!Date.now) { * @version DragonBones 5.0 * @language zh_CN */ - var BoundingBoxData = /** @class */ (function(_super) { + var BoundingBoxData = /** @class */ (function (_super) { __extends(BoundingBoxData, _super); function BoundingBoxData() { return (_super !== null && _super.apply(this, arguments)) || this; } - BoundingBoxData.prototype._onClear = function() { + BoundingBoxData.prototype._onClear = function () { this.color = 0x000000; this.width = 0.0; this.height = 0.0; @@ -2518,25 +2461,18 @@ if (!Date.now) { * @version DragonBones 5.1 * @language zh_CN */ - var RectangleBoundingBoxData = /** @class */ (function(_super) { + var RectangleBoundingBoxData = /** @class */ (function (_super) { __extends(RectangleBoundingBoxData, _super); function RectangleBoundingBoxData() { return (_super !== null && _super.apply(this, arguments)) || this; } - RectangleBoundingBoxData.toString = function() { + RectangleBoundingBoxData.toString = function () { return '[class dragonBones.RectangleBoundingBoxData]'; }; /** * - Compute the bit code for a point (x, y) using the clip rectangle */ - RectangleBoundingBoxData._computeOutCode = function( - x, - y, - xMin, - yMin, - xMax, - yMax, - ) { + RectangleBoundingBoxData._computeOutCode = function (x, y, xMin, yMin, xMax, yMax) { var code = 0; /* InSide */ // initialised as being inside of [[clip window]] if (x < xMin) { code |= 1 /* Left */; @@ -2553,7 +2489,7 @@ if (!Date.now) { /** * @private */ - RectangleBoundingBoxData.rectangleIntersectsSegment = function( + RectangleBoundingBoxData.rectangleIntersectsSegment = function ( xA, yA, xB, @@ -2581,22 +2517,8 @@ if (!Date.now) { return -1; } var intersectionCount = 0; - var outcode0 = RectangleBoundingBoxData._computeOutCode( - xA, - yA, - xMin, - yMin, - xMax, - yMax, - ); - var outcode1 = RectangleBoundingBoxData._computeOutCode( - xB, - yB, - xMin, - yMin, - xMax, - yMax, - ); + var outcode0 = RectangleBoundingBoxData._computeOutCode(xA, yA, xMin, yMin, xMax, yMax); + var outcode1 = RectangleBoundingBoxData._computeOutCode(xB, yB, xMin, yMin, xMax, yMax); while (true) { if ((outcode0 | outcode1) === 0) { intersectionCount = 2; @@ -2642,28 +2564,14 @@ if (!Date.now) { if (outcodeOut === outcode0) { xA = x; yA = y; - outcode0 = RectangleBoundingBoxData._computeOutCode( - xA, - yA, - xMin, - yMin, - xMax, - yMax, - ); + outcode0 = RectangleBoundingBoxData._computeOutCode(xA, yA, xMin, yMin, xMax, yMax); if (normalRadians !== null) { normalRadians.x = normalRadian; } } else { xB = x; yB = y; - outcode1 = RectangleBoundingBoxData._computeOutCode( - xB, - yB, - xMin, - yMin, - xMax, - yMax, - ); + outcode1 = RectangleBoundingBoxData._computeOutCode(xB, yB, xMin, yMin, xMax, yMax); if (normalRadians !== null) { normalRadians.y = normalRadian; } @@ -2710,14 +2618,14 @@ if (!Date.now) { } return intersectionCount; }; - RectangleBoundingBoxData.prototype._onClear = function() { + RectangleBoundingBoxData.prototype._onClear = function () { _super.prototype._onClear.call(this); this.type = 0 /* Rectangle */; }; /** * @inheritDoc */ - RectangleBoundingBoxData.prototype.containsPoint = function(pX, pY) { + RectangleBoundingBoxData.prototype.containsPoint = function (pX, pY) { var widthH = this.width * 0.5; if (pX >= -widthH && pX <= widthH) { var heightH = this.height * 0.5; @@ -2730,7 +2638,7 @@ if (!Date.now) { /** * @inheritDoc */ - RectangleBoundingBoxData.prototype.intersectsSegment = function( + RectangleBoundingBoxData.prototype.intersectsSegment = function ( xA, yA, xB, @@ -2778,18 +2686,18 @@ if (!Date.now) { * @version DragonBones 5.1 * @language zh_CN */ - var EllipseBoundingBoxData = /** @class */ (function(_super) { + var EllipseBoundingBoxData = /** @class */ (function (_super) { __extends(EllipseBoundingBoxData, _super); function EllipseBoundingBoxData() { return (_super !== null && _super.apply(this, arguments)) || this; } - EllipseBoundingBoxData.toString = function() { + EllipseBoundingBoxData.toString = function () { return '[class dragonBones.EllipseData]'; }; /** * @private */ - EllipseBoundingBoxData.ellipseIntersectsSegment = function( + EllipseBoundingBoxData.ellipseIntersectsSegment = function ( xA, yA, xB, @@ -2874,20 +2782,14 @@ if (!Date.now) { intersectionPointA.x = xA + sA * xD; intersectionPointA.y = (yA + sA * yD) / d; if (normalRadians !== null) { - normalRadians.x = Math.atan2( - (intersectionPointA.y / rr) * dd, - intersectionPointA.x / rr, - ); + normalRadians.x = Math.atan2((intersectionPointA.y / rr) * dd, intersectionPointA.x / rr); } } if (intersectionPointB !== null) { intersectionPointB.x = xA + sB * xD; intersectionPointB.y = (yA + sB * yD) / d; if (normalRadians !== null) { - normalRadians.y = Math.atan2( - (intersectionPointB.y / rr) * dd, - intersectionPointB.x / rr, - ); + normalRadians.y = Math.atan2((intersectionPointB.y / rr) * dd, intersectionPointB.x / rr); } } } @@ -2895,14 +2797,14 @@ if (!Date.now) { } return intersectionCount; }; - EllipseBoundingBoxData.prototype._onClear = function() { + EllipseBoundingBoxData.prototype._onClear = function () { _super.prototype._onClear.call(this); this.type = 1 /* Ellipse */; }; /** * @inheritDoc */ - EllipseBoundingBoxData.prototype.containsPoint = function(pX, pY) { + EllipseBoundingBoxData.prototype.containsPoint = function (pX, pY) { var widthH = this.width * 0.5; if (pX >= -widthH && pX <= widthH) { var heightH = this.height * 0.5; @@ -2916,7 +2818,7 @@ if (!Date.now) { /** * @inheritDoc */ - EllipseBoundingBoxData.prototype.intersectsSegment = function( + EllipseBoundingBoxData.prototype.intersectsSegment = function ( xA, yA, xB, @@ -2962,7 +2864,7 @@ if (!Date.now) { * @version DragonBones 5.1 * @language zh_CN */ - var PolygonBoundingBoxData = /** @class */ (function(_super) { + var PolygonBoundingBoxData = /** @class */ (function (_super) { __extends(PolygonBoundingBoxData, _super); function PolygonBoundingBoxData() { var _this = (_super !== null && _super.apply(this, arguments)) || this; @@ -2979,13 +2881,13 @@ if (!Date.now) { _this.vertices = []; return _this; } - PolygonBoundingBoxData.toString = function() { + PolygonBoundingBoxData.toString = function () { return '[class dragonBones.PolygonBoundingBoxData]'; }; /** * @private */ - PolygonBoundingBoxData.polygonIntersectsSegment = function( + PolygonBoundingBoxData.polygonIntersectsSegment = function ( xA, yA, xB, @@ -3059,8 +2961,7 @@ if (!Date.now) { xMax = x; yMax = y; if (normalRadians !== null) { - normalRadians.x = - Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; + normalRadians.x = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; normalRadians.y = normalRadians.x; } } else { @@ -3069,8 +2970,7 @@ if (!Date.now) { xMin = x; yMin = y; if (normalRadians !== null) { - normalRadians.x = - Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; + normalRadians.x = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; } } if (d > dMax) { @@ -3078,8 +2978,7 @@ if (!Date.now) { xMax = x; yMax = y; if (normalRadians !== null) { - normalRadians.y = - Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; + normalRadians.y = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; } } } @@ -3126,7 +3025,7 @@ if (!Date.now) { } return intersectionCount; }; - PolygonBoundingBoxData.prototype._onClear = function() { + PolygonBoundingBoxData.prototype._onClear = function () { _super.prototype._onClear.call(this); this.type = 2 /* Polygon */; this.x = 0.0; @@ -3136,14 +3035,9 @@ if (!Date.now) { /** * @inheritDoc */ - PolygonBoundingBoxData.prototype.containsPoint = function(pX, pY) { + PolygonBoundingBoxData.prototype.containsPoint = function (pX, pY) { var isInSide = false; - if ( - pX >= this.x && - pX <= this.width && - pY >= this.y && - pY <= this.height - ) { + if (pX >= this.x && pX <= this.width && pY >= this.y && pY <= this.height) { for (var i = 0, l = this.vertices.length, iP = l - 2; i < l; i += 2) { var yA = this.vertices[iP + 1]; var yB = this.vertices[i + 1]; @@ -3162,7 +3056,7 @@ if (!Date.now) { /** * @inheritDoc */ - PolygonBoundingBoxData.prototype.intersectsSegment = function( + PolygonBoundingBoxData.prototype.intersectsSegment = function ( xA, yA, xB, @@ -3236,7 +3130,7 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * - The animation data. * @version DragonBones 3.0 @@ -3247,7 +3141,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - var AnimationData = /** @class */ (function(_super) { + var AnimationData = /** @class */ (function (_super) { __extends(AnimationData, _super); function AnimationData() { var _this = (_super !== null && _super.apply(this, arguments)) || this; @@ -3289,10 +3183,10 @@ if (!Date.now) { _this.zOrderTimeline = null; // Initial value. return _this; } - AnimationData.toString = function() { + AnimationData.toString = function () { return '[class dragonBones.AnimationData]'; }; - AnimationData.prototype._onClear = function() { + AnimationData.prototype._onClear = function () { for (var k in this.boneTimelines) { for (var _i = 0, _a = this.boneTimelines[k]; _i < _a.length; _i++) { var timeline = _a[_i]; @@ -3308,22 +3202,14 @@ if (!Date.now) { delete this.slotTimelines[k]; } for (var k in this.constraintTimelines) { - for ( - var _d = 0, _e = this.constraintTimelines[k]; - _d < _e.length; - _d++ - ) { + for (var _d = 0, _e = this.constraintTimelines[k]; _d < _e.length; _d++) { var timeline = _e[_d]; timeline.returnToPool(); } delete this.constraintTimelines[k]; } for (var k in this.animationTimelines) { - for ( - var _f = 0, _g = this.animationTimelines[k]; - _f < _g.length; - _f++ - ) { + for (var _f = 0, _g = this.animationTimelines[k]; _f < _g.length; _f++) { var timeline = _g[_f]; timeline.returnToPool(); } @@ -3366,7 +3252,7 @@ if (!Date.now) { /** * @internal */ - AnimationData.prototype.cacheFrames = function(frameRate) { + AnimationData.prototype.cacheFrames = function (frameRate) { if (this.cacheFrameRate > 0.0) { return; } @@ -3399,11 +3285,9 @@ if (!Date.now) { /** * @private */ - AnimationData.prototype.addBoneTimeline = function(timelineName, timeline) { + AnimationData.prototype.addBoneTimeline = function (timelineName, timeline) { var timelines = - timelineName in this.boneTimelines - ? this.boneTimelines[timelineName] - : (this.boneTimelines[timelineName] = []); + timelineName in this.boneTimelines ? this.boneTimelines[timelineName] : (this.boneTimelines[timelineName] = []); if (timelines.indexOf(timeline) < 0) { timelines.push(timeline); } @@ -3411,11 +3295,9 @@ if (!Date.now) { /** * @private */ - AnimationData.prototype.addSlotTimeline = function(timelineName, timeline) { + AnimationData.prototype.addSlotTimeline = function (timelineName, timeline) { var timelines = - timelineName in this.slotTimelines - ? this.slotTimelines[timelineName] - : (this.slotTimelines[timelineName] = []); + timelineName in this.slotTimelines ? this.slotTimelines[timelineName] : (this.slotTimelines[timelineName] = []); if (timelines.indexOf(timeline) < 0) { timelines.push(timeline); } @@ -3423,10 +3305,7 @@ if (!Date.now) { /** * @private */ - AnimationData.prototype.addConstraintTimeline = function( - timelineName, - timeline, - ) { + AnimationData.prototype.addConstraintTimeline = function (timelineName, timeline) { var timelines = timelineName in this.constraintTimelines ? this.constraintTimelines[timelineName] @@ -3438,10 +3317,7 @@ if (!Date.now) { /** * @private */ - AnimationData.prototype.addAnimationTimeline = function( - timelineName, - timeline, - ) { + AnimationData.prototype.addAnimationTimeline = function (timelineName, timeline) { var timelines = timelineName in this.animationTimelines ? this.animationTimelines[timelineName] @@ -3453,50 +3329,38 @@ if (!Date.now) { /** * @private */ - AnimationData.prototype.getBoneTimelines = function(timelineName) { - return timelineName in this.boneTimelines - ? this.boneTimelines[timelineName] - : null; + AnimationData.prototype.getBoneTimelines = function (timelineName) { + return timelineName in this.boneTimelines ? this.boneTimelines[timelineName] : null; }; /** * @private */ - AnimationData.prototype.getSlotTimelines = function(timelineName) { - return timelineName in this.slotTimelines - ? this.slotTimelines[timelineName] - : null; + AnimationData.prototype.getSlotTimelines = function (timelineName) { + return timelineName in this.slotTimelines ? this.slotTimelines[timelineName] : null; }; /** * @private */ - AnimationData.prototype.getConstraintTimelines = function(timelineName) { - return timelineName in this.constraintTimelines - ? this.constraintTimelines[timelineName] - : null; + AnimationData.prototype.getConstraintTimelines = function (timelineName) { + return timelineName in this.constraintTimelines ? this.constraintTimelines[timelineName] : null; }; /** * @private */ - AnimationData.prototype.getAnimationTimelines = function(timelineName) { - return timelineName in this.animationTimelines - ? this.animationTimelines[timelineName] - : null; + AnimationData.prototype.getAnimationTimelines = function (timelineName) { + return timelineName in this.animationTimelines ? this.animationTimelines[timelineName] : null; }; /** * @private */ - AnimationData.prototype.getBoneCachedFrameIndices = function(boneName) { - return boneName in this.boneCachedFrameIndices - ? this.boneCachedFrameIndices[boneName] - : null; + AnimationData.prototype.getBoneCachedFrameIndices = function (boneName) { + return boneName in this.boneCachedFrameIndices ? this.boneCachedFrameIndices[boneName] : null; }; /** * @private */ - AnimationData.prototype.getSlotCachedFrameIndices = function(slotName) { - return slotName in this.slotCachedFrameIndices - ? this.slotCachedFrameIndices[slotName] - : null; + AnimationData.prototype.getSlotCachedFrameIndices = function (slotName) { + return slotName in this.slotCachedFrameIndices ? this.slotCachedFrameIndices[slotName] : null; }; return AnimationData; })(dragonBones.BaseObject); @@ -3504,15 +3368,15 @@ if (!Date.now) { /** * @private */ - var TimelineData = /** @class */ (function(_super) { + var TimelineData = /** @class */ (function (_super) { __extends(TimelineData, _super); function TimelineData() { return (_super !== null && _super.apply(this, arguments)) || this; } - TimelineData.toString = function() { + TimelineData.toString = function () { return '[class dragonBones.TimelineData]'; }; - TimelineData.prototype._onClear = function() { + TimelineData.prototype._onClear = function () { this.type = 10 /* BoneAll */; this.offset = 0; this.frameIndicesOffset = -1; @@ -3523,15 +3387,15 @@ if (!Date.now) { /** * @internal */ - var AnimationTimelineData = /** @class */ (function(_super) { + var AnimationTimelineData = /** @class */ (function (_super) { __extends(AnimationTimelineData, _super); function AnimationTimelineData() { return (_super !== null && _super.apply(this, arguments)) || this; } - AnimationTimelineData.toString = function() { + AnimationTimelineData.toString = function () { return '[class dragonBones.AnimationTimelineData]'; }; - AnimationTimelineData.prototype._onClear = function() { + AnimationTimelineData.prototype._onClear = function () { _super.prototype._onClear.call(this); this.x = 0.0; this.y = 0.0; @@ -3563,7 +3427,7 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * - The animation config is used to describe all the information needed to play an animation state. * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. @@ -3580,7 +3444,7 @@ if (!Date.now) { * @version DragonBones 5.0 * @language zh_CN */ - var AnimationConfig = /** @class */ (function(_super) { + var AnimationConfig = /** @class */ (function (_super) { __extends(AnimationConfig, _super); function AnimationConfig() { var _this = (_super !== null && _super.apply(this, arguments)) || this; @@ -3590,10 +3454,10 @@ if (!Date.now) { _this.boneMask = []; return _this; } - AnimationConfig.toString = function() { + AnimationConfig.toString = function () { return '[class dragonBones.AnimationConfig]'; }; - AnimationConfig.prototype._onClear = function() { + AnimationConfig.prototype._onClear = function () { this.pauseFadeOut = true; this.fadeOutMode = 4 /* All */; this.fadeOutTweenType = 1 /* Line */; @@ -3620,13 +3484,13 @@ if (!Date.now) { /** * @private */ - AnimationConfig.prototype.clear = function() { + AnimationConfig.prototype.clear = function () { this._onClear(); }; /** * @private */ - AnimationConfig.prototype.copyFrom = function(value) { + AnimationConfig.prototype.copyFrom = function (value) { this.pauseFadeOut = value.pauseFadeOut; this.fadeOutMode = value.fadeOutMode; this.autoFadeOutTime = value.autoFadeOutTime; @@ -3680,7 +3544,7 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * - The texture atlas data. * @version DragonBones 3.0 @@ -3691,7 +3555,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - var TextureAtlasData = /** @class */ (function(_super) { + var TextureAtlasData = /** @class */ (function (_super) { __extends(TextureAtlasData, _super); function TextureAtlasData() { var _this = (_super !== null && _super.apply(this, arguments)) || this; @@ -3701,7 +3565,7 @@ if (!Date.now) { _this.textures = {}; return _this; } - TextureAtlasData.prototype._onClear = function() { + TextureAtlasData.prototype._onClear = function () { for (var k in this.textures) { this.textures[k].returnToPool(); delete this.textures[k]; @@ -3717,7 +3581,7 @@ if (!Date.now) { /** * @private */ - TextureAtlasData.prototype.copyFrom = function(value) { + TextureAtlasData.prototype.copyFrom = function (value) { this.autoSearch = value.autoSearch; this.scale = value.scale; this.width = value.width; @@ -3738,7 +3602,7 @@ if (!Date.now) { /** * @internal */ - TextureAtlasData.prototype.addTexture = function(value) { + TextureAtlasData.prototype.addTexture = function (value) { if (value.name in this.textures) { console.warn('Same texture: ' + value.name); return; @@ -3749,7 +3613,7 @@ if (!Date.now) { /** * @private */ - TextureAtlasData.prototype.getTexture = function(textureName) { + TextureAtlasData.prototype.getTexture = function (textureName) { return textureName in this.textures ? this.textures[textureName] : null; }; return TextureAtlasData; @@ -3758,7 +3622,7 @@ if (!Date.now) { /** * @private */ - var TextureData = /** @class */ (function(_super) { + var TextureData = /** @class */ (function (_super) { __extends(TextureData, _super); function TextureData() { var _this = (_super !== null && _super.apply(this, arguments)) || this; @@ -3766,17 +3630,17 @@ if (!Date.now) { _this.frame = null; // Initial value. return _this; } - TextureData.createRectangle = function() { + TextureData.createRectangle = function () { return new dragonBones.Rectangle(); }; - TextureData.prototype._onClear = function() { + TextureData.prototype._onClear = function () { this.rotated = false; this.name = ''; this.region.clear(); this.parent = null; // this.frame = null; }; - TextureData.prototype.copyFrom = function(value) { + TextureData.prototype.copyFrom = function (value) { this.rotated = value.rotated; this.name = value.name; this.region.copyFrom(value.region); @@ -3817,7 +3681,7 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones_1) { +(function (dragonBones_1) { /** * - Armature is the core of the skeleton animation system. * @see dragonBones.ArmatureData @@ -3836,7 +3700,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - var Armature = /** @class */ (function(_super) { + var Armature = /** @class */ (function (_super) { __extends(Armature, _super); function Armature() { var _this = (_super !== null && _super.apply(this, arguments)) || this; @@ -3856,15 +3720,13 @@ if (!Date.now) { _this._clock = null; // Initial value. return _this; } - Armature.toString = function() { + Armature.toString = function () { return '[class dragonBones.Armature]'; }; - Armature._onSortSlots = function(a, b) { - return a._zIndex * 1000 + a._zOrder > b._zIndex * 1000 + b._zOrder - ? 1 - : -1; + Armature._onSortSlots = function (a, b) { + return a._zIndex * 1000 + a._zOrder > b._zIndex * 1000 + b._zOrder ? 1 : -1; }; - Armature.prototype._onClear = function() { + Armature.prototype._onClear = function () { if (this._clock !== null) { this._clock.remove(this); } @@ -3922,7 +3784,7 @@ if (!Date.now) { /** * @internal */ - Armature.prototype._sortZOrder = function(slotIndices, offset) { + Armature.prototype._sortZOrder = function (slotIndices, offset) { var slotDatas = this._armatureData.sortedSlots; var isOriginal = slotIndices === null; if (this._zOrderDirty || !isOriginal) { @@ -3944,7 +3806,7 @@ if (!Date.now) { /** * @internal */ - Armature.prototype._addBone = function(value) { + Armature.prototype._addBone = function (value) { if (this._bones.indexOf(value) < 0) { this._bones.push(value); } @@ -3952,7 +3814,7 @@ if (!Date.now) { /** * @internal */ - Armature.prototype._addSlot = function(value) { + Armature.prototype._addSlot = function (value) { if (this._slots.indexOf(value) < 0) { this._slots.push(value); } @@ -3960,7 +3822,7 @@ if (!Date.now) { /** * @internal */ - Armature.prototype._addConstraint = function(value) { + Armature.prototype._addConstraint = function (value) { if (this._constraints.indexOf(value) < 0) { this._constraints.push(value); } @@ -3968,7 +3830,7 @@ if (!Date.now) { /** * @internal */ - Armature.prototype._bufferAction = function(action, append) { + Armature.prototype._bufferAction = function (action, append) { if (this._actions.indexOf(action) < 0) { if (append) { this._actions.push(action); @@ -3997,7 +3859,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - Armature.prototype.dispose = function() { + Armature.prototype.dispose = function () { if (this._armatureData !== null) { this._lockUpdate = true; this._dragonBones.bufferObject(this); @@ -4006,19 +3868,12 @@ if (!Date.now) { /** * @internal */ - Armature.prototype.init = function( - armatureData, - proxy, - display, - dragonBones, - ) { + Armature.prototype.init = function (armatureData, proxy, display, dragonBones) { if (this._armatureData !== null) { return; } this._armatureData = armatureData; - this._animation = dragonBones_1.BaseObject.borrowObject( - dragonBones_1.Animation, - ); + this._animation = dragonBones_1.BaseObject.borrowObject(dragonBones_1.Animation); this._proxy = proxy; this._display = display; this._dragonBones = dragonBones; @@ -4029,7 +3884,7 @@ if (!Date.now) { /** * @inheritDoc */ - Armature.prototype.advanceTime = function(passedTime) { + Armature.prototype.advanceTime = function (passedTime) { if (this._lockUpdate) { return; } @@ -4060,9 +3915,7 @@ if (!Date.now) { // Update alpha. if (this._alphaDirty) { this._alphaDirty = false; - this._globalAlpha = - this._alpha * - (this._parent !== null ? this._parent._globalAlpha : 1.0); + this._globalAlpha = this._alpha * (this._parent !== null ? this._parent._globalAlpha : 1.0); for (var _i = 0, _a = this._bones; _i < _a.length; _i++) { var bone = _a[_i]; bone._updateAlpha(); @@ -4073,10 +3926,7 @@ if (!Date.now) { } } // Update bones and slots. - if ( - this._cacheFrameIndex < 0 || - this._cacheFrameIndex !== prevCacheFrameIndex - ) { + if (this._cacheFrameIndex < 0 || this._cacheFrameIndex !== prevCacheFrameIndex) { var i = 0, l = 0; for (i = 0, l = this._bones.length; i < l; ++i) { @@ -4138,7 +3988,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - Armature.prototype.invalidUpdate = function(boneName, updateSlot) { + Armature.prototype.invalidUpdate = function (boneName, updateSlot) { if (boneName === void 0) { boneName = null; } @@ -4189,7 +4039,7 @@ if (!Date.now) { * @version DragonBones 5.0 * @language zh_CN */ - Armature.prototype.containsPoint = function(x, y) { + Armature.prototype.containsPoint = function (x, y) { for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { var slot = _a[_i]; if (slot.containsPoint(x, y)) { @@ -4228,7 +4078,7 @@ if (!Date.now) { * @version DragonBones 5.0 * @language zh_CN */ - Armature.prototype.intersectsSegment = function( + Armature.prototype.intersectsSegment = function ( xA, yA, xB, @@ -4271,9 +4121,7 @@ if (!Date.now) { if (intersectionCount > 0) { if (intersectionPointA !== null || intersectionPointB !== null) { if (intersectionPointA !== null) { - var d = isV - ? intersectionPointA.y - yA - : intersectionPointA.x - xA; + var d = isV ? intersectionPointA.y - yA : intersectionPointA.x - xA; if (d < 0.0) { d = -d; } @@ -4338,7 +4186,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - Armature.prototype.getBone = function(name) { + Armature.prototype.getBone = function (name) { for (var _i = 0, _a = this._bones; _i < _a.length; _i++) { var bone = _a[_i]; if (bone.name === name) { @@ -4361,7 +4209,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - Armature.prototype.getBoneByDisplay = function(display) { + Armature.prototype.getBoneByDisplay = function (display) { var slot = this.getSlotByDisplay(display); return slot !== null ? slot.parent : null; }; @@ -4379,7 +4227,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - Armature.prototype.getSlot = function(name) { + Armature.prototype.getSlot = function (name) { for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { var slot = _a[_i]; if (slot.name === name) { @@ -4402,7 +4250,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - Armature.prototype.getSlotByDisplay = function(display) { + Armature.prototype.getSlotByDisplay = function (display) { if (display !== null) { for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { var slot = _a[_i]; @@ -4425,7 +4273,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - Armature.prototype.getBones = function() { + Armature.prototype.getBones = function () { return this._bones; }; /** @@ -4440,7 +4288,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - Armature.prototype.getSlots = function() { + Armature.prototype.getSlots = function () { return this._slots; }; Object.defineProperty(Armature.prototype, 'flipX', { @@ -4454,10 +4302,10 @@ if (!Date.now) { * @version DragonBones 5.5 * @language zh_CN */ - get: function() { + get: function () { return this._flipX; }, - set: function(value) { + set: function (value) { if (this._flipX === value) { return; } @@ -4478,10 +4326,10 @@ if (!Date.now) { * @version DragonBones 5.5 * @language zh_CN */ - get: function() { + get: function () { return this._flipY; }, - set: function(value) { + set: function (value) { if (this._flipY === value) { return; } @@ -4520,10 +4368,10 @@ if (!Date.now) { * @version DragonBones 4.5 * @language zh_CN */ - get: function() { + get: function () { return this._armatureData.cacheFrameRate; }, - set: function(value) { + set: function (value) { if (this._armatureData.cacheFrameRate !== value) { this._armatureData.cacheFrames(value); // Set child armature frameRate. @@ -4550,7 +4398,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - get: function() { + get: function () { return this._armatureData.name; }, enumerable: true, @@ -4569,7 +4417,7 @@ if (!Date.now) { * @version DragonBones 4.5 * @language zh_CN */ - get: function() { + get: function () { return this._armatureData; }, enumerable: true, @@ -4588,7 +4436,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - get: function() { + get: function () { return this._animation; }, enumerable: true, @@ -4598,7 +4446,7 @@ if (!Date.now) { /** * @pivate */ - get: function() { + get: function () { return this._proxy; }, enumerable: true, @@ -4615,7 +4463,7 @@ if (!Date.now) { * @version DragonBones 4.5 * @language zh_CN */ - get: function() { + get: function () { return this._proxy; }, enumerable: true, @@ -4636,7 +4484,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - get: function() { + get: function () { return this._display; }, enumerable: true, @@ -4646,10 +4494,10 @@ if (!Date.now) { /** * @private */ - get: function() { + get: function () { return this._replacedTexture; }, - set: function(value) { + set: function (value) { if (this._replacedTexture === value) { return; } @@ -4671,10 +4519,10 @@ if (!Date.now) { /** * @inheritDoc */ - get: function() { + get: function () { return this._clock; }, - set: function(value) { + set: function (value) { if (this._clock === value) { return; } @@ -4710,7 +4558,7 @@ if (!Date.now) { * @version DragonBones 4.5 * @language zh_CN */ - get: function() { + get: function () { return this._parent; }, enumerable: true, @@ -4726,7 +4574,7 @@ if (!Date.now) { * @deprecated * @language zh_CN */ - Armature.prototype.getDisplay = function() { + Armature.prototype.getDisplay = function () { return this._display; }; return Armature; @@ -4756,7 +4604,7 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * - The base class of the transform object. * @see dragonBones.Transform @@ -4769,7 +4617,7 @@ if (!Date.now) { * @version DragonBones 4.5 * @language zh_CN */ - var TransformObject = /** @class */ (function(_super) { + var TransformObject = /** @class */ (function (_super) { __extends(TransformObject, _super); function TransformObject() { var _this = (_super !== null && _super.apply(this, arguments)) || this; @@ -4814,7 +4662,7 @@ if (!Date.now) { } /** */ - TransformObject.prototype._onClear = function() { + TransformObject.prototype._onClear = function () { this.globalTransformMatrix.identity(); this.global.identity(); this.offset.identity(); @@ -4848,7 +4696,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - TransformObject.prototype.updateGlobalTransform = function() { + TransformObject.prototype.updateGlobalTransform = function () { if (this._globalDirty) { this._globalDirty = false; this.global.fromMatrix(this.globalTransformMatrix); @@ -4865,7 +4713,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - get: function() { + get: function () { return this._armature; }, enumerable: true, @@ -4901,7 +4749,7 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * - Bone is one of the most important logical units in the armature animation system, * and is responsible for the realization of translate, rotation, scaling in the animations. @@ -4921,7 +4769,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - var Bone = /** @class */ (function(_super) { + var Bone = /** @class */ (function (_super) { __extends(Bone, _super); function Bone() { var _this = (_super !== null && _super.apply(this, arguments)) || this; @@ -4931,10 +4779,10 @@ if (!Date.now) { _this.animationPose = new dragonBones.Transform(); return _this; } - Bone.toString = function() { + Bone.toString = function () { return '[class dragonBones.Bone]'; }; - Bone.prototype._onClear = function() { + Bone.prototype._onClear = function () { _super.prototype._onClear.call(this); this.offsetMode = 1 /* Additive */; this.animationPose.identity(); @@ -4948,7 +4796,7 @@ if (!Date.now) { this._parent = null; // this._cachedFrameIndices = null; }; - Bone.prototype._updateGlobalTransformMatrix = function(isCache) { + Bone.prototype._updateGlobalTransformMatrix = function (isCache) { // For typescript. var boneData = this._boneData; var global = this.global; @@ -4967,8 +4815,7 @@ if (!Date.now) { global.x = origin.x + offset.x + animationPose.x; global.y = origin.y + offset.y + animationPose.y; global.skew = origin.skew + offset.skew + animationPose.skew; - global.rotation = - origin.rotation + offset.rotation + animationPose.rotation; + global.rotation = origin.rotation + offset.rotation + animationPose.rotation; global.scaleX = origin.scaleX * offset.scaleX * animationPose.scaleX; global.scaleY = origin.scaleY * offset.scaleY * animationPose.scaleY; } else { @@ -5040,10 +4887,8 @@ if (!Date.now) { if (boneData.inheritTranslation) { var x = global.x; var y = global.y; - global.x = - parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; - global.y = - parentMatrix.b * x + parentMatrix.d * y + parentMatrix.ty; + global.x = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; + global.y = parentMatrix.b * x + parentMatrix.d * y + parentMatrix.ty; } else { if (flipX) { global.x = -global.x; @@ -5059,11 +4904,7 @@ if (!Date.now) { } else { rotation = global.rotation + parent.global.rotation; } - if ( - parentMatrix.a * parentMatrix.d - - parentMatrix.b * parentMatrix.c < - 0.0 - ) { + if (parentMatrix.a * parentMatrix.d - parentMatrix.b * parentMatrix.c < 0.0) { rotation -= global.rotation * 2.0; if (flipX !== flipY || boneData.inheritReflection) { global.skew += Math.PI; @@ -5111,7 +4952,7 @@ if (!Date.now) { /** * @internal */ - Bone.prototype._updateAlpha = function() { + Bone.prototype._updateAlpha = function () { if (this._parent !== null) { this._globalAlpha = this._alpha * this._parent._globalAlpha; } else { @@ -5121,7 +4962,7 @@ if (!Date.now) { /** * @internal */ - Bone.prototype.init = function(boneData, armatureValue) { + Bone.prototype.init = function (boneData, armatureValue) { if (this._boneData !== null) { return; } @@ -5138,34 +4979,24 @@ if (!Date.now) { /** * @internal */ - Bone.prototype.update = function(cacheFrameIndex) { + Bone.prototype.update = function (cacheFrameIndex) { if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; - if ( - cachedFrameIndex >= 0 && - this._cachedFrameIndex === cachedFrameIndex - ) { + if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { this._transformDirty = false; } else if (cachedFrameIndex >= 0) { this._transformDirty = true; this._cachedFrameIndex = cachedFrameIndex; } else { if (this._hasConstraint) { - for ( - var _i = 0, _a = this._armature._constraints; - _i < _a.length; - _i++ - ) { + for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { var constraint = _a[_i]; if (constraint._root === this) { constraint.update(); } } } - if ( - this._transformDirty || - (this._parent !== null && this._parent._childrenTransformDirty) - ) { + if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { this._transformDirty = true; this._cachedFrameIndex = -1; } else if (this._cachedFrameIndex >= 0) { @@ -5178,21 +5009,14 @@ if (!Date.now) { } } else { if (this._hasConstraint) { - for ( - var _b = 0, _c = this._armature._constraints; - _b < _c.length; - _b++ - ) { + for (var _b = 0, _c = this._armature._constraints; _b < _c.length; _b++) { var constraint = _c[_b]; if (constraint._root === this) { constraint.update(); } } } - if ( - this._transformDirty || - (this._parent !== null && this._parent._childrenTransformDirty) - ) { + if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { cacheFrameIndex = -1; this._transformDirty = true; this._cachedFrameIndex = -1; @@ -5208,19 +5032,11 @@ if (!Date.now) { this._updateGlobalTransformMatrix(isCache); } if (isCache && this._cachedFrameIndices !== null) { - this._cachedFrameIndex = this._cachedFrameIndices[ - cacheFrameIndex - ] = this._armature._armatureData.setCacheFrame( - this.globalTransformMatrix, - this.global, - ); + this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = + this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global); } } else { - this._armature._armatureData.getCacheFrame( - this.globalTransformMatrix, - this.global, - this._cachedFrameIndex, - ); + this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); } // } else if (this._childrenTransformDirty) { @@ -5231,13 +5047,10 @@ if (!Date.now) { /** * @internal */ - Bone.prototype.updateByConstraint = function() { + Bone.prototype.updateByConstraint = function () { if (this._localDirty) { this._localDirty = false; - if ( - this._transformDirty || - (this._parent !== null && this._parent._childrenTransformDirty) - ) { + if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { this._updateGlobalTransformMatrix(true); } this._transformDirty = true; @@ -5268,7 +5081,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - Bone.prototype.invalidUpdate = function() { + Bone.prototype.invalidUpdate = function () { this._transformDirty = true; }; /** @@ -5283,7 +5096,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - Bone.prototype.contains = function(value) { + Bone.prototype.contains = function (value) { if (value === this) { return false; } @@ -5304,7 +5117,7 @@ if (!Date.now) { * @version DragonBones 4.5 * @language zh_CN */ - get: function() { + get: function () { return this._boneData; }, enumerable: true, @@ -5325,10 +5138,10 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - get: function() { + get: function () { return this._visible; }, - set: function(value) { + set: function (value) { if (this._visible === value) { return; } @@ -5354,7 +5167,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - get: function() { + get: function () { return this._boneData.name; }, enumerable: true, @@ -5371,7 +5184,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - get: function() { + get: function () { return this._parent; }, enumerable: true, @@ -5404,11 +5217,11 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * @internal */ - var Surface = /** @class */ (function(_super) { + var Surface = /** @class */ (function (_super) { __extends(Surface, _super); function Surface() { var _this = (_super !== null && _super.apply(this, arguments)) || this; @@ -5424,10 +5237,10 @@ if (!Date.now) { _this._matrixCahce = []; return _this; } - Surface.toString = function() { + Surface.toString = function () { return '[class dragonBones.Surface]'; }; - Surface.prototype._onClear = function() { + Surface.prototype._onClear = function () { _super.prototype._onClear.call(this); this._dX = 0.0; this._dY = 0.0; @@ -5440,28 +5253,13 @@ if (!Date.now) { this._hullCache.length = 0; this._bone = null; }; - Surface.prototype._getAffineTransform = function( - x, - y, - lX, - lY, - aX, - aY, - bX, - bY, - cX, - cY, - transform, - matrix, - isDown, - ) { + Surface.prototype._getAffineTransform = function (x, y, lX, lY, aX, aY, bX, bY, cX, cY, transform, matrix, isDown) { var dabX = bX - aX; var dabY = bY - aY; var dacX = cX - aX; var dacY = cY - aY; transform.rotation = Math.atan2(dabY, dabX); - transform.skew = - Math.atan2(dacY, dacX) - Math.PI * 0.5 - transform.rotation; + transform.skew = Math.atan2(dacY, dacX) - Math.PI * 0.5 - transform.rotation; if (isDown) { transform.rotation += Math.PI; } @@ -5471,14 +5269,13 @@ if (!Date.now) { transform.x = matrix.tx = aX - (matrix.a * x + matrix.c * y); transform.y = matrix.ty = aY - (matrix.b * x + matrix.d * y); }; - Surface.prototype._updateVertices = function() { + Surface.prototype._updateVertices = function () { var data = this._armature.armatureData.parent; var geometry = this._boneData.geometry; var intArray = data.intArray; var floatArray = data.floatArray; var vertexCount = intArray[geometry.offset + 0 /* GeometryVertexCount */]; - var verticesOffset = - intArray[geometry.offset + 2 /* GeometryFloatOffset */]; + var verticesOffset = intArray[geometry.offset + 2 /* GeometryFloatOffset */]; var vertices = this._vertices; var animationVertices = this._deformVertices; if (this._parent !== null) { @@ -5486,8 +5283,7 @@ if (!Date.now) { for (var i = 0, l = vertexCount; i < l; ++i) { var iD = i * 2; var x = floatArray[verticesOffset + iD] + animationVertices[iD]; - var y = - floatArray[verticesOffset + iD + 1] + animationVertices[iD + 1]; + var y = floatArray[verticesOffset + iD + 1] + animationVertices[iD + 1]; var matrix = this._parent._getGlobalTransformMatrix(x, y); // vertices[iD] = matrix.a * x + matrix.c * y + matrix.tx; @@ -5498,26 +5294,21 @@ if (!Date.now) { for (var i = 0, l = vertexCount; i < l; ++i) { var iD = i * 2; var x = floatArray[verticesOffset + iD] + animationVertices[iD]; - var y = - floatArray[verticesOffset + iD + 1] + animationVertices[iD + 1]; + var y = floatArray[verticesOffset + iD + 1] + animationVertices[iD + 1]; // - vertices[iD] = - parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; - vertices[iD + 1] = - parentMatrix.b * x + parentMatrix.d * y + parentMatrix.ty; + vertices[iD] = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; + vertices[iD + 1] = parentMatrix.b * x + parentMatrix.d * y + parentMatrix.ty; } } } else { for (var i = 0, l = vertexCount; i < l; ++i) { var iD = i * 2; - vertices[iD] = - floatArray[verticesOffset + iD] + animationVertices[iD]; - vertices[iD + 1] = - floatArray[verticesOffset + iD + 1] + animationVertices[iD + 1]; + vertices[iD] = floatArray[verticesOffset + iD] + animationVertices[iD]; + vertices[iD + 1] = floatArray[verticesOffset + iD + 1] + animationVertices[iD + 1]; } } }; - Surface.prototype._updateGlobalTransformMatrix = function(isCache) { + Surface.prototype._updateGlobalTransformMatrix = function (isCache) { // tslint:disable-next-line:no-unused-expression isCache; var segmentXD = this._boneData.segmentX * 2; @@ -5561,7 +5352,7 @@ if (!Date.now) { ); this._globalDirty = false; }; - Surface.prototype._getGlobalTransformMatrix = function(x, y) { + Surface.prototype._getGlobalTransformMatrix = function (x, y) { var lA = 200.0; var lB = 1000.0; if (x < -lB || lB < x || y < -lB || lB < y) { @@ -5588,10 +5379,7 @@ if (!Date.now) { } // Left. isDown = y > this._kX * (x + lA) + pY; - matrixIndex = - ((segmentX * segmentY + segmentX + segmentY + segmentY + indexY) * 2 + - (isDown ? 1 : 0)) * - 7; + matrixIndex = ((segmentX * segmentY + segmentX + segmentY + segmentY + indexY) * 2 + (isDown ? 1 : 0)) * 7; if (matrices[matrixIndex] > 0.0) { helpMatrix.copyFromArray(matrices, matrixIndex + 1); } else { @@ -5648,9 +5436,7 @@ if (!Date.now) { } // Right. isDown = y > this._kX * (x - lB) + pY; - matrixIndex = - ((segmentX * segmentY + segmentX + indexY) * 2 + (isDown ? 1 : 0)) * - 7; + matrixIndex = ((segmentX * segmentY + segmentX + indexY) * 2 + (isDown ? 1 : 0)) * 7; if (matrices[matrixIndex] > 0.0) { helpMatrix.copyFromArray(matrices, matrixIndex + 1); } else { @@ -5707,8 +5493,7 @@ if (!Date.now) { } // Up. isDown = y > this._kY * (x - pX - dX) - lB; - matrixIndex = - ((segmentX * segmentY + indexX) * 2 + (isDown ? 1 : 0)) * 7; + matrixIndex = ((segmentX * segmentY + indexX) * 2 + (isDown ? 1 : 0)) * 7; if (matrices[matrixIndex] > 0.0) { helpMatrix.copyFromArray(matrices, matrixIndex + 1); } else { @@ -5765,10 +5550,7 @@ if (!Date.now) { } // Down isDown = y > this._kY * (x - pX - dX) + lA; - matrixIndex = - ((segmentX * segmentY + segmentX + segmentY + indexX) * 2 + - (isDown ? 1 : 0)) * - 7; + matrixIndex = ((segmentX * segmentY + segmentX + segmentY + indexX) * 2 + (isDown ? 1 : 0)) * 7; if (matrices[matrixIndex] > 0.0) { helpMatrix.copyFromArray(matrices, matrixIndex + 1); } else { @@ -5875,16 +5657,15 @@ if (!Date.now) { * @internal * @private */ - Surface.prototype.init = function(surfaceData, armatureValue) { + Surface.prototype.init = function (surfaceData, armatureValue) { if (this._boneData !== null) { return; } _super.prototype.init.call(this, surfaceData, armatureValue); var segmentX = surfaceData.segmentX; var segmentY = surfaceData.segmentY; - var vertexCount = this._armature.armatureData.parent.intArray[ - surfaceData.geometry.offset + 0 /* GeometryVertexCount */ - ]; + var vertexCount = + this._armature.armatureData.parent.intArray[surfaceData.geometry.offset + 0 /* GeometryVertexCount */]; var lB = 1000.0; var lA = 200.0; // @@ -5895,8 +5676,7 @@ if (!Date.now) { this._kY = -(lB - lA) / this._dX; this._vertices.length = vertexCount * 2; this._deformVertices.length = vertexCount * 2; - this._matrixCahce.length = - (segmentX * segmentY + segmentX * 2 + segmentY * 2) * 2 * 7; + this._matrixCahce.length = (segmentX * segmentY + segmentX * 2 + segmentY * 2) * 2 * 7; this._hullCache.length = 10; for (var i = 0; i < vertexCount * 2; ++i) { this._deformVertices[i] = 0.0; @@ -5912,34 +5692,24 @@ if (!Date.now) { /** * @internal */ - Surface.prototype.update = function(cacheFrameIndex) { + Surface.prototype.update = function (cacheFrameIndex) { if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; - if ( - cachedFrameIndex >= 0 && - this._cachedFrameIndex === cachedFrameIndex - ) { + if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { this._transformDirty = false; } else if (cachedFrameIndex >= 0) { this._transformDirty = true; this._cachedFrameIndex = cachedFrameIndex; } else { if (this._hasConstraint) { - for ( - var _i = 0, _a = this._armature._constraints; - _i < _a.length; - _i++ - ) { + for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { var constraint = _a[_i]; if (constraint._root === this) { constraint.update(); } } } - if ( - this._transformDirty || - (this._parent !== null && this._parent._childrenTransformDirty) - ) { + if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { this._transformDirty = true; this._cachedFrameIndex = -1; } else if (this._cachedFrameIndex >= 0) { @@ -5952,21 +5722,14 @@ if (!Date.now) { } } else { if (this._hasConstraint) { - for ( - var _b = 0, _c = this._armature._constraints; - _b < _c.length; - _b++ - ) { + for (var _b = 0, _c = this._armature._constraints; _b < _c.length; _b++) { var constraint = _c[_b]; if (constraint._root === this) { constraint.update(); } } } - if ( - this._transformDirty || - (this._parent !== null && this._parent._childrenTransformDirty) - ) { + if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { cacheFrameIndex = -1; this._transformDirty = true; this._cachedFrameIndex = -1; @@ -5988,19 +5751,11 @@ if (!Date.now) { this._updateGlobalTransformMatrix(isCache); } if (isCache && this._cachedFrameIndices !== null) { - this._cachedFrameIndex = this._cachedFrameIndices[ - cacheFrameIndex - ] = this._armature._armatureData.setCacheFrame( - this.globalTransformMatrix, - this.global, - ); + this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = + this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global); } } else { - this._armature._armatureData.getCacheFrame( - this.globalTransformMatrix, - this.global, - this._cachedFrameIndex, - ); + this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); } // Update hull vertices. var lB = 1000.0; @@ -6014,12 +5769,7 @@ if (!Date.now) { this._hullCache[1] = helpPoint.y; this._hullCache[2] = ddX - helpPoint.x; this._hullCache[3] = ddY - helpPoint.y; - this.globalTransformMatrix.transformPoint( - 0.0, - this._dY, - helpPoint, - true, - ); + this.globalTransformMatrix.transformPoint(0.0, this._dY, helpPoint, true); this._hullCache[4] = helpPoint.x; this._hullCache[5] = helpPoint.y; // @@ -6028,12 +5778,7 @@ if (!Date.now) { this._hullCache[7] = helpPoint.y; this._hullCache[8] = ddX - helpPoint.x; this._hullCache[9] = ddY - helpPoint.y; - this.globalTransformMatrix.transformPoint( - this._dX, - 0.0, - helpPoint, - true, - ); + this.globalTransformMatrix.transformPoint(this._dX, 0.0, helpPoint, true); this._hullCache[10] = helpPoint.x; this._hullCache[11] = helpPoint.y; } else if (this._childrenTransformDirty) { @@ -6068,28 +5813,28 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * @private */ - var DisplayFrame = /** @class */ (function(_super) { + var DisplayFrame = /** @class */ (function (_super) { __extends(DisplayFrame, _super); function DisplayFrame() { var _this = (_super !== null && _super.apply(this, arguments)) || this; _this.deformVertices = []; return _this; } - DisplayFrame.toString = function() { + DisplayFrame.toString = function () { return '[class dragonBones.DisplayFrame]'; }; - DisplayFrame.prototype._onClear = function() { + DisplayFrame.prototype._onClear = function () { this.rawDisplayData = null; this.displayData = null; this.textureData = null; this.display = null; this.deformVertices.length = 0; }; - DisplayFrame.prototype.updateDeformVertices = function() { + DisplayFrame.prototype.updateDeformVertices = function () { if (this.rawDisplayData === null || this.deformVertices.length !== 0) { return; } @@ -6105,17 +5850,14 @@ if (!Date.now) { if (rawGeometryData.weight !== null) { vertexCount = rawGeometryData.weight.count * 2; } else { - vertexCount = - rawGeometryData.data.intArray[ - rawGeometryData.offset + 0 /* GeometryVertexCount */ - ] * 2; + vertexCount = rawGeometryData.data.intArray[rawGeometryData.offset + 0 /* GeometryVertexCount */] * 2; } this.deformVertices.length = vertexCount; for (var i = 0, l = this.deformVertices.length; i < l; ++i) { this.deformVertices[i] = 0.0; } }; - DisplayFrame.prototype.getGeometryData = function() { + DisplayFrame.prototype.getGeometryData = function () { if (this.displayData !== null) { if (this.displayData.type === 2 /* Mesh */) { return this.displayData.geometry; @@ -6134,22 +5876,16 @@ if (!Date.now) { } return null; }; - DisplayFrame.prototype.getBoundingBox = function() { - if ( - this.displayData !== null && - this.displayData.type === 3 /* BoundingBox */ - ) { + DisplayFrame.prototype.getBoundingBox = function () { + if (this.displayData !== null && this.displayData.type === 3 /* BoundingBox */) { return this.displayData.boundingBox; } - if ( - this.rawDisplayData !== null && - this.rawDisplayData.type === 3 /* BoundingBox */ - ) { + if (this.rawDisplayData !== null && this.rawDisplayData.type === 3 /* BoundingBox */) { return this.rawDisplayData.boundingBox; } return null; }; - DisplayFrame.prototype.getTextureData = function() { + DisplayFrame.prototype.getTextureData = function () { if (this.displayData !== null) { if (this.displayData.type === 0 /* Image */) { return this.displayData.texture; @@ -6198,7 +5934,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - var Slot = /** @class */ (function(_super) { + var Slot = /** @class */ (function (_super) { __extends(Slot, _super); function Slot() { var _this = (_super !== null && _super.apply(this, arguments)) || this; @@ -6220,26 +5956,18 @@ if (!Date.now) { _this._display = null; return _this; } - Slot.prototype._onClear = function() { + Slot.prototype._onClear = function () { _super.prototype._onClear.call(this); var disposeDisplayList = []; for (var _i = 0, _a = this._displayFrames; _i < _a.length; _i++) { var dispayFrame = _a[_i]; var display = dispayFrame.display; - if ( - display !== this._rawDisplay && - display !== this._meshDisplay && - disposeDisplayList.indexOf(display) < 0 - ) { + if (display !== this._rawDisplay && display !== this._meshDisplay && disposeDisplayList.indexOf(display) < 0) { disposeDisplayList.push(display); } dispayFrame.returnToPool(); } - for ( - var _b = 0, disposeDisplayList_1 = disposeDisplayList; - _b < disposeDisplayList_1.length; - _b++ - ) { + for (var _b = 0, disposeDisplayList_1 = disposeDisplayList; _b < disposeDisplayList_1.length; _b++) { var eachDisplay = disposeDisplayList_1[_b]; if (eachDisplay instanceof dragonBones.Armature) { eachDisplay.dispose(); @@ -6247,10 +5975,7 @@ if (!Date.now) { this._disposeDisplay(eachDisplay, true); } } - if ( - this._meshDisplay !== null && - this._meshDisplay !== this._rawDisplay - ) { + if (this._meshDisplay !== null && this._meshDisplay !== this._rawDisplay) { this._disposeDisplay(this._meshDisplay, false); } if (this._rawDisplay !== null) { @@ -6292,7 +6017,7 @@ if (!Date.now) { this._parent = null; // this._cachedFrameIndices = null; }; - Slot.prototype._hasDisplay = function(display) { + Slot.prototype._hasDisplay = function (display) { for (var _i = 0, _a = this._displayFrames; _i < _a.length; _i++) { var displayFrame = _a[_i]; if (displayFrame.display === display) { @@ -6304,7 +6029,7 @@ if (!Date.now) { /** * @internal */ - Slot.prototype._isBonesUpdate = function() { + Slot.prototype._isBonesUpdate = function () { for (var _i = 0, _a = this._geometryBones; _i < _a.length; _i++) { var bone = _a[_i]; if (bone !== null && bone._childrenTransformDirty) { @@ -6316,14 +6041,14 @@ if (!Date.now) { /** * @internal */ - Slot.prototype._updateAlpha = function() { + Slot.prototype._updateAlpha = function () { var globalAlpha = this._alpha * this._parent._globalAlpha; if (this._globalAlpha !== globalAlpha) { this._globalAlpha = globalAlpha; this._colorDirty = true; } }; - Slot.prototype._updateDisplayData = function() { + Slot.prototype._updateDisplayData = function () { var prevDisplayFrame = this._displayFrame; var prevGeometryData = this._geometryData; var prevTextureData = this._textureData; @@ -6333,10 +6058,7 @@ if (!Date.now) { this._geometryData = null; this._boundingBoxData = null; this._textureData = null; - if ( - this._displayIndex >= 0 && - this._displayIndex < this._displayFrames.length - ) { + if (this._displayIndex >= 0 && this._displayIndex < this._displayFrames.length) { this._displayFrame = this._displayFrames[this._displayIndex]; rawDisplayData = this._displayFrame.rawDisplayData; displayData = this._displayFrame.displayData; @@ -6352,11 +6074,8 @@ if (!Date.now) { // Update pivot offset. if (this._geometryData === null && this._textureData !== null) { var imageDisplayData = - displayData !== null && displayData.type === 0 /* Image */ - ? displayData - : rawDisplayData; // - var scale = - this._textureData.parent.scale * this._armature._armatureData.scale; + displayData !== null && displayData.type === 0 /* Image */ ? displayData : rawDisplayData; // + var scale = this._textureData.parent.scale * this._armature._armatureData.scale; var frame = this._textureData.frame; this._pivotX = imageDisplayData.pivot.x; this._pivotY = imageDisplayData.pivot.y; @@ -6388,10 +6107,7 @@ if (!Date.now) { } if (!dragonBones.DragonBones.yDown) { this._pivotY = - (this._textureData.rotated - ? this._textureData.region.width - : this._textureData.region.height) * - scale - + (this._textureData.rotated ? this._textureData.region.width : this._textureData.region.height) * scale - this._pivotY; } } else { @@ -6408,10 +6124,7 @@ if (!Date.now) { } // TODO remove slot offset. if (this.origin !== null) { - this.global - .copyFrom(this.origin) - .add(this.offset) - .toMatrix(this._localMatrix); + this.global.copyFrom(this.origin).add(this.offset).toMatrix(this._localMatrix); } else { this.global.copyFrom(this.offset).toMatrix(this._localMatrix); } @@ -6422,14 +6135,8 @@ if (!Date.now) { if (this._geometryData !== null) { this._geometryBones.length = 0; if (this._geometryData.weight !== null) { - for ( - var i = 0, l = this._geometryData.weight.bones.length; - i < l; - ++i - ) { - var bone = this._armature.getBone( - this._geometryData.weight.bones[i].name, - ); + for (var i = 0, l = this._geometryData.weight.bones.length; i < l; ++i) { + var bone = this._armature.getBone(this._geometryData.weight.bones[i].name); this._geometryBones.push(bone); } } @@ -6442,17 +6149,13 @@ if (!Date.now) { this._transformDirty = true; } }; - Slot.prototype._updateDisplay = function() { - var prevDisplay = - this._display !== null ? this._display : this._rawDisplay; + Slot.prototype._updateDisplay = function () { + var prevDisplay = this._display !== null ? this._display : this._rawDisplay; var prevChildArmature = this._childArmature; // Update display and child armature. if (this._displayFrame !== null) { this._display = this._displayFrame.display; - if ( - this._display !== null && - this._display instanceof dragonBones.Armature - ) { + if (this._display !== null && this._display instanceof dragonBones.Armature) { this._childArmature = this._display; this._display = this._childArmature.display; } else { @@ -6463,8 +6166,7 @@ if (!Date.now) { this._childArmature = null; } // Update display. - var currentDisplay = - this._display !== null ? this._display : this._rawDisplay; + var currentDisplay = this._display !== null ? this._display : this._rawDisplay; if (currentDisplay !== prevDisplay) { this._textureDirty = true; this._visibleDirty = true; @@ -6501,27 +6203,14 @@ if (!Date.now) { this._displayFrame.displayData !== null ? this._displayFrame.displayData : this._displayFrame.rawDisplayData; - if ( - displayData !== null && - displayData.type === 1 /* Armature */ - ) { + if (displayData !== null && displayData.type === 1 /* Armature */) { actions = displayData.actions; } if (actions !== null && actions.length > 0) { - for ( - var _i = 0, actions_1 = actions; - _i < actions_1.length; - _i++ - ) { + for (var _i = 0, actions_1 = actions; _i < actions_1.length; _i++) { var action = actions_1[_i]; - var eventObject = dragonBones.BaseObject.borrowObject( - dragonBones.EventObject, - ); - dragonBones.EventObject.actionDataToInstance( - action, - eventObject, - this._armature, - ); + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + dragonBones.EventObject.actionDataToInstance(action, eventObject, this._armature); eventObject.slot = this; this._armature._bufferAction(eventObject, false); } @@ -6533,14 +6222,11 @@ if (!Date.now) { } } }; - Slot.prototype._updateGlobalTransformMatrix = function(isCache) { + Slot.prototype._updateGlobalTransformMatrix = function (isCache) { var parentMatrix = this._parent._boneData.type === 0 /* Bone */ ? this._parent.globalTransformMatrix - : this._parent._getGlobalTransformMatrix( - this.global.x, - this.global.y, - ); + : this._parent._getGlobalTransformMatrix(this.global.x, this.global.y); this.globalTransformMatrix.copyFrom(this._localMatrix); this.globalTransformMatrix.concat(parentMatrix); if (isCache) { @@ -6552,7 +6238,7 @@ if (!Date.now) { /** * @internal */ - Slot.prototype._setDisplayIndex = function(value, isAnimation) { + Slot.prototype._setDisplayIndex = function (value, isAnimation) { if (isAnimation === void 0) { isAnimation = false; } @@ -6565,19 +6251,14 @@ if (!Date.now) { if (this._displayIndex === value) { return; } - this._displayIndex = - value < this._displayFrames.length - ? value - : this._displayFrames.length - 1; + this._displayIndex = value < this._displayFrames.length ? value : this._displayFrames.length - 1; this._displayDataDirty = true; - this._displayDirty = - this._displayIndex < 0 || - this._display !== this._displayFrames[this._displayIndex].display; + this._displayDirty = this._displayIndex < 0 || this._display !== this._displayFrames[this._displayIndex].display; }; /** * @internal */ - Slot.prototype._setZOrder = function(value) { + Slot.prototype._setZOrder = function (value) { if (this._zOrder === value) { // return false; } @@ -6588,19 +6269,14 @@ if (!Date.now) { /** * @internal */ - Slot.prototype._setColor = function(value) { + Slot.prototype._setColor = function (value) { this._colorTransform.copyFrom(value); return (this._colorDirty = true); }; /** * @internal */ - Slot.prototype.init = function( - slotData, - armatureValue, - rawDisplay, - meshDisplay, - ) { + Slot.prototype.init = function (slotData, armatureValue, rawDisplay, meshDisplay) { if (this._slotData !== null) { return; } @@ -6634,7 +6310,7 @@ if (!Date.now) { /** * @internal */ - Slot.prototype.update = function(cacheFrameIndex) { + Slot.prototype.update = function (cacheFrameIndex) { if (this._displayDataDirty) { this._updateDisplayData(); this._displayDataDirty = false; @@ -6644,11 +6320,7 @@ if (!Date.now) { this._displayDirty = false; } if (this._geometryDirty || this._textureDirty) { - if ( - this._display === null || - this._display === this._rawDisplay || - this._display === this._meshDisplay - ) { + if (this._display === null || this._display === this._rawDisplay || this._display === this._meshDisplay) { this._updateFrame(); } this._geometryDirty = false; @@ -6690,18 +6362,12 @@ if (!Date.now) { } if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; - if ( - cachedFrameIndex >= 0 && - this._cachedFrameIndex === cachedFrameIndex - ) { + if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { this._transformDirty = false; } else if (cachedFrameIndex >= 0) { this._transformDirty = true; this._cachedFrameIndex = cachedFrameIndex; - } else if ( - this._transformDirty || - this._parent._childrenTransformDirty - ) { + } else if (this._transformDirty || this._parent._childrenTransformDirty) { this._transformDirty = true; this._cachedFrameIndex = -1; } else if (this._cachedFrameIndex >= 0) { @@ -6721,19 +6387,11 @@ if (!Date.now) { var isCache = cacheFrameIndex >= 0; this._updateGlobalTransformMatrix(isCache); if (isCache && this._cachedFrameIndices !== null) { - this._cachedFrameIndex = this._cachedFrameIndices[ - cacheFrameIndex - ] = this._armature._armatureData.setCacheFrame( - this.globalTransformMatrix, - this.global, - ); + this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = + this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global); } } else { - this._armature._armatureData.getCacheFrame( - this.globalTransformMatrix, - this.global, - this._cachedFrameIndex, - ); + this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); } this._updateTransform(); this._transformDirty = false; @@ -6749,7 +6407,7 @@ if (!Date.now) { * @version DragonBones 4.5 * @language zh_CN */ - Slot.prototype.invalidUpdate = function() { + Slot.prototype.invalidUpdate = function () { this._displayDataDirty = true; this._displayDirty = true; // @@ -6758,7 +6416,7 @@ if (!Date.now) { /** * @private */ - Slot.prototype.updateTransformAndMatrix = function() { + Slot.prototype.updateTransformAndMatrix = function () { if (this._transformDirty) { this._updateGlobalTransformMatrix(false); this._transformDirty = false; @@ -6767,7 +6425,7 @@ if (!Date.now) { /** * @private */ - Slot.prototype.replaceRawDisplayData = function(displayData, index) { + Slot.prototype.replaceRawDisplayData = function (displayData, index) { if (index === void 0) { index = -1; } @@ -6783,13 +6441,8 @@ if (!Date.now) { if (displayFrame.rawDisplayData === null) { var defaultSkin = this._armature._armatureData.defaultSkin; if (defaultSkin !== null) { - var defaultRawDisplayDatas = defaultSkin.getDisplays( - this._slotData.name, - ); - if ( - defaultRawDisplayDatas !== null && - index < defaultRawDisplayDatas.length - ) { + var defaultRawDisplayDatas = defaultSkin.getDisplays(this._slotData.name); + if (defaultRawDisplayDatas !== null && index < defaultRawDisplayDatas.length) { displayFrame.rawDisplayData = defaultRawDisplayDatas[index]; } } @@ -6802,7 +6455,7 @@ if (!Date.now) { /** * @private */ - Slot.prototype.replaceDisplayData = function(displayData, index) { + Slot.prototype.replaceDisplayData = function (displayData, index) { if (index === void 0) { index = -1; } @@ -6812,10 +6465,7 @@ if (!Date.now) { return; } var displayFrame = this._displayFrames[index]; - if ( - displayFrame.displayData !== displayData && - displayFrame.rawDisplayData !== displayData - ) { + if (displayFrame.displayData !== displayData && displayFrame.rawDisplayData !== displayData) { displayFrame.displayData = displayData; if (index === this._displayIndex) { this._displayDataDirty = true; @@ -6825,7 +6475,7 @@ if (!Date.now) { /** * @private */ - Slot.prototype.replaceTextureData = function(textureData, index) { + Slot.prototype.replaceTextureData = function (textureData, index) { if (index === void 0) { index = -1; } @@ -6845,7 +6495,7 @@ if (!Date.now) { /** * @private */ - Slot.prototype.replaceDisplay = function(value, index) { + Slot.prototype.replaceDisplay = function (value, index) { if (index === void 0) { index = -1; } @@ -6902,7 +6552,7 @@ if (!Date.now) { * @version DragonBones 5.0 * @language zh_CN */ - Slot.prototype.containsPoint = function(x, y) { + Slot.prototype.containsPoint = function (x, y) { if (this._boundingBoxData === null) { return false; } @@ -6910,10 +6560,7 @@ if (!Date.now) { Slot._helpMatrix.copyFrom(this.globalTransformMatrix); Slot._helpMatrix.invert(); Slot._helpMatrix.transformPoint(x, y, Slot._helpPoint); - return this._boundingBoxData.containsPoint( - Slot._helpPoint.x, - Slot._helpPoint.y, - ); + return this._boundingBoxData.containsPoint(Slot._helpPoint.x, Slot._helpPoint.y); }; /** * - Check whether a specific segment intersects a custom bounding box for the slot. @@ -6945,7 +6592,7 @@ if (!Date.now) { * @version DragonBones 5.0 * @language zh_CN */ - Slot.prototype.intersectsSegment = function( + Slot.prototype.intersectsSegment = function ( xA, yA, xB, @@ -6987,36 +6634,20 @@ if (!Date.now) { if (intersectionCount > 0) { if (intersectionCount === 1 || intersectionCount === 2) { if (intersectionPointA !== null) { - this.globalTransformMatrix.transformPoint( - intersectionPointA.x, - intersectionPointA.y, - intersectionPointA, - ); + this.globalTransformMatrix.transformPoint(intersectionPointA.x, intersectionPointA.y, intersectionPointA); if (intersectionPointB !== null) { intersectionPointB.x = intersectionPointA.x; intersectionPointB.y = intersectionPointA.y; } } else if (intersectionPointB !== null) { - this.globalTransformMatrix.transformPoint( - intersectionPointB.x, - intersectionPointB.y, - intersectionPointB, - ); + this.globalTransformMatrix.transformPoint(intersectionPointB.x, intersectionPointB.y, intersectionPointB); } } else { if (intersectionPointA !== null) { - this.globalTransformMatrix.transformPoint( - intersectionPointA.x, - intersectionPointA.y, - intersectionPointA, - ); + this.globalTransformMatrix.transformPoint(intersectionPointA.x, intersectionPointA.y, intersectionPointA); } if (intersectionPointB !== null) { - this.globalTransformMatrix.transformPoint( - intersectionPointB.x, - intersectionPointB.y, - intersectionPointB, - ); + this.globalTransformMatrix.transformPoint(intersectionPointB.x, intersectionPointB.y, intersectionPointB); } } if (normalRadians !== null) { @@ -7041,7 +6672,7 @@ if (!Date.now) { /** * @private */ - Slot.prototype.getDisplayFrameAt = function(index) { + Slot.prototype.getDisplayFrameAt = function (index) { return this._displayFrames[index]; }; Object.defineProperty(Slot.prototype, 'visible', { @@ -7057,10 +6688,10 @@ if (!Date.now) { * @version DragonBones 5.6 * @language zh_CN */ - get: function() { + get: function () { return this._visible; }, - set: function(value) { + set: function (value) { if (this._visible === value) { return; } @@ -7074,17 +6705,15 @@ if (!Date.now) { /** * @private */ - get: function() { + get: function () { return this._displayFrames.length; }, - set: function(value) { + set: function (value) { var prevCount = this._displayFrames.length; if (prevCount < value) { this._displayFrames.length = value; for (var i = prevCount; i < value; ++i) { - this._displayFrames[i] = dragonBones.BaseObject.borrowObject( - DisplayFrame, - ); + this._displayFrames[i] = dragonBones.BaseObject.borrowObject(DisplayFrame); } } else if (prevCount > value) { for (var i = prevCount - 1; i < value; --i) { @@ -7120,10 +6749,10 @@ if (!Date.now) { * @version DragonBones 4.5 * @language zh_CN */ - get: function() { + get: function () { return this._displayIndex; }, - set: function(value) { + set: function (value) { this._setDisplayIndex(value); this.update(-1); }, @@ -7143,7 +6772,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - get: function() { + get: function () { return this._slotData.name; }, enumerable: true, @@ -7160,7 +6789,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - get: function() { + get: function () { var displays = new Array(); for (var _i = 0, _a = this._displayFrames; _i < _a.length; _i++) { var displayFrame = _a[_i]; @@ -7168,7 +6797,7 @@ if (!Date.now) { } return displays; }, - set: function(value) { + set: function (value) { this.displayFrameCount = value.length; var index = 0; for (var _i = 0, value_1 = value; _i < value_1.length; _i++) { @@ -7192,7 +6821,7 @@ if (!Date.now) { * @version DragonBones 4.5 * @language zh_CN */ - get: function() { + get: function () { return this._slotData; }, enumerable: true, @@ -7209,7 +6838,7 @@ if (!Date.now) { * @version DragonBones 5.0 * @language zh_CN */ - get: function() { + get: function () { return this._boundingBoxData; }, enumerable: true, @@ -7219,7 +6848,7 @@ if (!Date.now) { /** * @private */ - get: function() { + get: function () { return this._rawDisplay; }, enumerable: true, @@ -7229,7 +6858,7 @@ if (!Date.now) { /** * @private */ - get: function() { + get: function () { return this._meshDisplay; }, enumerable: true, @@ -7256,10 +6885,10 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - get: function() { + get: function () { return this._display; }, - set: function(value) { + set: function (value) { if (this._display === value) { return; } @@ -7302,10 +6931,10 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - get: function() { + get: function () { return this._childArmature; }, - set: function(value) { + set: function (value) { if (this._childArmature === value) { return; } @@ -7325,7 +6954,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - get: function() { + get: function () { return this._parent; }, enumerable: true, @@ -7341,7 +6970,7 @@ if (!Date.now) { * @deprecated * @language zh_CN */ - Slot.prototype.getDisplay = function() { + Slot.prototype.getDisplay = function () { return this._display; }; /** @@ -7354,7 +6983,7 @@ if (!Date.now) { * @deprecated * @language zh_CN */ - Slot.prototype.setDisplay = function(value) { + Slot.prototype.setDisplay = function (value) { this.display = value; }; return Slot; @@ -7384,23 +7013,23 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * @internal */ - var Constraint = /** @class */ (function(_super) { + var Constraint = /** @class */ (function (_super) { __extends(Constraint, _super); function Constraint() { return (_super !== null && _super.apply(this, arguments)) || this; } - Constraint.prototype._onClear = function() { + Constraint.prototype._onClear = function () { this._armature = null; // this._target = null; // this._root = null; // this._bone = null; }; Object.defineProperty(Constraint.prototype, 'name', { - get: function() { + get: function () { return this._constraintData.name; }, enumerable: true, @@ -7415,22 +7044,22 @@ if (!Date.now) { /** * @internal */ - var IKConstraint = /** @class */ (function(_super) { + var IKConstraint = /** @class */ (function (_super) { __extends(IKConstraint, _super); function IKConstraint() { return (_super !== null && _super.apply(this, arguments)) || this; } - IKConstraint.toString = function() { + IKConstraint.toString = function () { return '[class dragonBones.IKConstraint]'; }; - IKConstraint.prototype._onClear = function() { + IKConstraint.prototype._onClear = function () { _super.prototype._onClear.call(this); this._scaleEnabled = false; this._bendPositive = false; this._weight = 1.0; this._constraintData = null; }; - IKConstraint.prototype._computeA = function() { + IKConstraint.prototype._computeA = function () { var ikGlobal = this._target.global; var global = this._root.global; var globalTransformMatrix = this._root.globalTransformMatrix; @@ -7438,12 +7067,10 @@ if (!Date.now) { if (global.scaleX < 0.0) { radian += Math.PI; } - global.rotation += - dragonBones.Transform.normalizeRadian(radian - global.rotation) * - this._weight; + global.rotation += dragonBones.Transform.normalizeRadian(radian - global.rotation) * this._weight; global.toMatrix(globalTransformMatrix); }; - IKConstraint.prototype._computeB = function() { + IKConstraint.prototype._computeB = function () { var boneLength = this._bone._boneData.length; var parent = this._root; var ikGlobal = this._target.global; @@ -7467,10 +7094,7 @@ if (!Date.now) { var lT = Math.sqrt(lTT); var radianA = 0.0; if (lL + lP <= lT || lT + lL <= lP || lT + lP <= lL) { - radianA = Math.atan2( - ikGlobal.y - parentGlobal.y, - ikGlobal.x - parentGlobal.x, - ); + radianA = Math.atan2(ikGlobal.y - parentGlobal.y, ikGlobal.x - parentGlobal.x); if (lL + lP <= lT) { } else if (lP < lL) { radianA += Math.PI; @@ -7486,10 +7110,7 @@ if (!Date.now) { var parentParent = parent.parent; if (parentParent !== null) { var parentParentMatrix = parentParent.globalTransformMatrix; - isPPR = - parentParentMatrix.a * parentParentMatrix.d - - parentParentMatrix.b * parentParentMatrix.c < - 0.0; + isPPR = parentParentMatrix.a * parentParentMatrix.d - parentParentMatrix.b * parentParentMatrix.c < 0.0; } if (isPPR !== this._bendPositive) { global.x = hX - rX; @@ -7498,10 +7119,7 @@ if (!Date.now) { global.x = hX + rX; global.y = hY + rY; } - radianA = Math.atan2( - global.y - parentGlobal.y, - global.x - parentGlobal.x, - ); + radianA = Math.atan2(global.y - parentGlobal.y, global.x - parentGlobal.x); } var dR = dragonBones.Transform.normalizeRadian(radianA - rawRadianA); parentGlobal.rotation = rawParentRadian + dR * this._weight; @@ -7519,11 +7137,10 @@ if (!Date.now) { parentGlobal.rotation + rawRadian - rawParentRadian + - dragonBones.Transform.normalizeRadian(radianB - dR - rawRadian) * - this._weight; + dragonBones.Transform.normalizeRadian(radianB - dR - rawRadian) * this._weight; global.toMatrix(globalTransformMatrix); }; - IKConstraint.prototype.init = function(constraintData, armature) { + IKConstraint.prototype.init = function (constraintData, armature) { if (this._constraintData !== null) { return; } @@ -7531,10 +7148,7 @@ if (!Date.now) { this._armature = armature; this._target = this._armature.getBone(this._constraintData.target.name); this._root = this._armature.getBone(this._constraintData.root.name); - this._bone = - this._constraintData.bone !== null - ? this._armature.getBone(this._constraintData.bone.name) - : null; + this._bone = this._constraintData.bone !== null ? this._armature.getBone(this._constraintData.bone.name) : null; { var ikConstraintData = this._constraintData; this._scaleEnabled = ikConstraintData.scaleEnabled; @@ -7543,7 +7157,7 @@ if (!Date.now) { } this._root._hasConstraint = true; }; - IKConstraint.prototype.update = function() { + IKConstraint.prototype.update = function () { this._root.updateByConstraint(); if (this._bone !== null) { this._bone.updateByConstraint(); @@ -7552,7 +7166,7 @@ if (!Date.now) { this._computeA(); } }; - IKConstraint.prototype.invalidUpdate = function() { + IKConstraint.prototype.invalidUpdate = function () { this._root.invalidUpdate(); if (this._bone !== null) { this._bone.invalidUpdate(); @@ -7564,7 +7178,7 @@ if (!Date.now) { /** * @internal */ - var PathConstraint = /** @class */ (function(_super) { + var PathConstraint = /** @class */ (function (_super) { __extends(PathConstraint, _super); function PathConstraint() { var _this = (_super !== null && _super.apply(this, arguments)) || this; @@ -7577,10 +7191,10 @@ if (!Date.now) { _this._segments = [10]; return _this; } - PathConstraint.toString = function() { + PathConstraint.toString = function () { return '[class dragonBones.PathConstraint]'; }; - PathConstraint.prototype._onClear = function() { + PathConstraint.prototype._onClear = function () { _super.prototype._onClear.call(this); this.dirty = false; this.pathOffset = 0; @@ -7597,7 +7211,7 @@ if (!Date.now) { this._boneLengths.length = 0; this._pathGlobalVertices.length = 0; }; - PathConstraint.prototype._updatePathVertices = function(verticesData) { + PathConstraint.prototype._updatePathVertices = function (verticesData) { //计算曲线的节点数据 var armature = this._armature; var dragonBonesData = armature.armatureData.parent; @@ -7654,19 +7268,14 @@ if (!Date.now) { this._pathGlobalVertices[iW++] = yG; } }; - PathConstraint.prototype._computeVertices = function( - start, - count, - offset, - out, - ) { + PathConstraint.prototype._computeVertices = function (start, count, offset, out) { //TODO优化 for (var i = offset, iW = start; i < count; i += 2) { out[i] = this._pathGlobalVertices[iW++]; out[i + 1] = this._pathGlobalVertices[iW++]; } }; - PathConstraint.prototype._computeBezierCurve = function( + PathConstraint.prototype._computeBezierCurve = function ( pathDisplayDta, spaceCount, tangents, @@ -7676,8 +7285,7 @@ if (!Date.now) { //计算当前的骨骼在曲线上的位置 var armature = this._armature; var intArray = armature.armatureData.parent.intArray; - var vertexCount = - intArray[pathDisplayDta.geometry.offset + 0 /* GeometryVertexCount */]; + var vertexCount = intArray[pathDisplayDta.geometry.offset + 0 /* GeometryVertexCount */]; var positions = this._positions; var spaces = this._spaces; var isClosed = pathDisplayDta.closed; @@ -7827,11 +7435,7 @@ if (!Date.now) { } var segments = this._segments; var curveLength = 0; - for ( - var i = 0, o = 0, curve = 0, segment = 0; - i < spaceCount; - i++, o += 3 - ) { + for (var i = 0, o = 0, curve = 0, segment = 0; i < spaceCount; i++, o += 3) { var space = spaces[i]; position += space; var p = position; @@ -7906,24 +7510,11 @@ if (!Date.now) { } break; } - this.addCurvePosition( - p * 0.1, - x1, - y1, - cx1, - cy1, - cx2, - cy2, - x2, - y2, - positions, - o, - tangents, - ); + this.addCurvePosition(p * 0.1, x1, y1, cx1, cy1, cx2, cy2, x2, y2, positions, o, tangents); } }; //Calculates a point on the curve, for a given t value between 0 and 1. - PathConstraint.prototype.addCurvePosition = function( + PathConstraint.prototype.addCurvePosition = function ( t, x1, y1, @@ -7962,15 +7553,12 @@ if (!Date.now) { out[offset + 1] = y; if (tangents) { //Calculates the curve tangent at the specified t value - out[offset + 2] = Math.atan2( - y - (a * y1 + b * cy1 + c * cy2), - x - (a * x1 + b * cx1 + c * cx2), - ); + out[offset + 2] = Math.atan2(y - (a * y1 + b * cy1 + c * cy2), x - (a * x1 + b * cx1 + c * cx2)); } else { out[offset + 2] = 0; } }; - PathConstraint.prototype.init = function(constraintData, armature) { + PathConstraint.prototype.init = function (constraintData, armature) { this._constraintData = constraintData; this._armature = armature; var data = constraintData; @@ -7996,12 +7584,9 @@ if (!Date.now) { } this._root._hasConstraint = true; }; - PathConstraint.prototype.update = function() { + PathConstraint.prototype.update = function () { var pathSlot = this._pathSlot; - if ( - pathSlot._geometryData === null || - pathSlot._geometryData.offset !== this.pathOffset - ) { + if (pathSlot._geometryData === null || pathSlot._geometryData.offset !== this.pathOffset) { return; } var constraintData = this._constraintData; @@ -8142,7 +7727,7 @@ if (!Date.now) { } this.dirty = false; }; - PathConstraint.prototype.invalidUpdate = function() {}; + PathConstraint.prototype.invalidUpdate = function () {}; return PathConstraint; })(Constraint); dragonBones.PathConstraint = PathConstraint; @@ -8170,7 +7755,7 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * - Worldclock provides clock support for animations, advance time for each IAnimatable object added to the instance. * @see dragonBones.IAnimateble @@ -8185,7 +7770,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - var WorldClock = /** @class */ (function() { + var WorldClock = /** @class */ (function () { /** * - Creating a Worldclock instance. Typically, you do not need to create Worldclock instance. * When multiple Worldclock instances are running at different speeds, can achieving some specific animation effects, such as bullet time. @@ -8246,7 +7831,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - WorldClock.prototype.advanceTime = function(passedTime) { + WorldClock.prototype.advanceTime = function (passedTime) { if (passedTime !== passedTime) { passedTime = 0.0; } @@ -8306,7 +7891,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - WorldClock.prototype.contains = function(value) { + WorldClock.prototype.contains = function (value) { if (value === this) { return false; } @@ -8328,7 +7913,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - WorldClock.prototype.add = function(value) { + WorldClock.prototype.add = function (value) { if (this._animatebles.indexOf(value) < 0) { this._animatebles.push(value); value.clock = this; @@ -8346,7 +7931,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - WorldClock.prototype.remove = function(value) { + WorldClock.prototype.remove = function (value) { var index = this._animatebles.indexOf(value); if (index >= 0) { this._animatebles[index] = null; @@ -8363,7 +7948,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - WorldClock.prototype.clear = function() { + WorldClock.prototype.clear = function () { for (var _i = 0, _a = this._animatebles; _i < _a.length; _i++) { var animatable = _a[_i]; if (animatable !== null) { @@ -8375,10 +7960,10 @@ if (!Date.now) { /** * @inheritDoc */ - get: function() { + get: function () { return this._clock; }, - set: function(value) { + set: function (value) { if (this._clock === value) { return; } @@ -8420,7 +8005,7 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * - The animation player is used to play the animation data and manage the animation states. * @see dragonBones.AnimationData @@ -8435,7 +8020,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - var Animation = /** @class */ (function(_super) { + var Animation = /** @class */ (function (_super) { __extends(Animation, _super); function Animation() { var _this = (_super !== null && _super.apply(this, arguments)) || this; @@ -8446,10 +8031,10 @@ if (!Date.now) { _this._animationConfig = null; // Initial value. return _this; } - Animation.toString = function() { + Animation.toString = function () { return '[class dragonBones.Animation]'; }; - Animation.prototype._onClear = function() { + Animation.prototype._onClear = function () { for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { var animationState = _a[_i]; animationState.returnToPool(); @@ -8477,7 +8062,7 @@ if (!Date.now) { this._animationConfig = null; // this._lastAnimationState = null; }; - Animation.prototype._fadeOut = function(animationConfig) { + Animation.prototype._fadeOut = function (animationConfig) { switch (animationConfig.fadeOutMode) { case 1 /* SameLayer */: for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { @@ -8486,10 +8071,7 @@ if (!Date.now) { continue; } if (animationState.layer === animationConfig.layer) { - animationState.fadeOut( - animationConfig.fadeOutTime, - animationConfig.pauseFadeOut, - ); + animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); } } break; @@ -8500,10 +8082,7 @@ if (!Date.now) { continue; } if (animationState.group === animationConfig.group) { - animationState.fadeOut( - animationConfig.fadeOutTime, - animationConfig.pauseFadeOut, - ); + animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); } } break; @@ -8513,14 +8092,8 @@ if (!Date.now) { if (animationState._parent !== null) { continue; } - if ( - animationState.layer === animationConfig.layer && - animationState.group === animationConfig.group - ) { - animationState.fadeOut( - animationConfig.fadeOutTime, - animationConfig.pauseFadeOut, - ); + if (animationState.layer === animationConfig.layer && animationState.group === animationConfig.group) { + animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); } } break; @@ -8530,10 +8103,7 @@ if (!Date.now) { if (animationState._parent !== null) { continue; } - animationState.fadeOut( - animationConfig.fadeOutTime, - animationConfig.pauseFadeOut, - ); + animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); } break; case 5 /* Single */: // TODO @@ -8544,26 +8114,22 @@ if (!Date.now) { /** * @internal */ - Animation.prototype.init = function(armature) { + Animation.prototype.init = function (armature) { if (this._armature !== null) { return; } this._armature = armature; - this._animationConfig = dragonBones.BaseObject.borrowObject( - dragonBones.AnimationConfig, - ); + this._animationConfig = dragonBones.BaseObject.borrowObject(dragonBones.AnimationConfig); }; /** * @internal */ - Animation.prototype.advanceTime = function(passedTime) { + Animation.prototype.advanceTime = function (passedTime) { if (passedTime < 0.0) { passedTime = -passedTime; } if (this._armature.inheritAnimation && this._armature._parent !== null) { - this._inheritTimeScale = - this._armature._parent._armature.animation._inheritTimeScale * - this.timeScale; + this._inheritTimeScale = this._armature._parent._armature.animation._inheritTimeScale * this.timeScale; } else { this._inheritTimeScale = this.timeScale; } @@ -8588,32 +8154,16 @@ if (!Date.now) { var cacheFrameRate = animationData.cacheFrameRate; if (this._animationDirty && cacheFrameRate > 0.0) { this._animationDirty = false; - for ( - var _i = 0, _a = this._armature.getBones(); - _i < _a.length; - _i++ - ) { + for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { var bone = _a[_i]; - bone._cachedFrameIndices = animationData.getBoneCachedFrameIndices( - bone.name, - ); + bone._cachedFrameIndices = animationData.getBoneCachedFrameIndices(bone.name); } - for ( - var _b = 0, _c = this._armature.getSlots(); - _b < _c.length; - _b++ - ) { + for (var _b = 0, _c = this._armature.getSlots(); _b < _c.length; _b++) { var slot = _c[_b]; if (slot.displayFrameCount > 0) { var rawDisplayData = slot.getDisplayFrameAt(0).rawDisplayData; - if ( - rawDisplayData !== null && - rawDisplayData.parent === - this._armature.armatureData.defaultSkin - ) { - slot._cachedFrameIndices = animationData.getSlotCachedFrameIndices( - slot.name, - ); + if (rawDisplayData !== null && rawDisplayData.parent === this._armature.armatureData.defaultSkin) { + slot._cachedFrameIndices = animationData.getSlotCachedFrameIndices(slot.name); continue; } } @@ -8625,10 +8175,7 @@ if (!Date.now) { } else if (animationStateCount > 1) { for (var i = 0, r = 0; i < animationStateCount; ++i) { var animationState = this._animationStates[i]; - if ( - animationState._fadeState > 0 && - animationState._subFadeState > 0 - ) { + if (animationState._fadeState > 0 && animationState._subFadeState > 0) { r++; this._armature._dragonBones.bufferObject(animationState); this._animationDirty = true; @@ -8643,13 +8190,8 @@ if (!Date.now) { } if (i === animationStateCount - 1 && r > 0) { this._animationStates.length -= r; - if ( - this._lastAnimationState === null && - this._animationStates.length > 0 - ) { - this._lastAnimationState = this._animationStates[ - this._animationStates.length - 1 - ]; + if (this._lastAnimationState === null && this._animationStates.length > 0) { + this._lastAnimationState = this._animationStates[this._animationStates.length - 1]; } } } @@ -8670,7 +8212,7 @@ if (!Date.now) { * @version DragonBones 4.5 * @language zh_CN */ - Animation.prototype.reset = function() { + Animation.prototype.reset = function () { for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { var animationState = _a[_i]; animationState.returnToPool(); @@ -8694,7 +8236,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - Animation.prototype.stop = function(animationName) { + Animation.prototype.stop = function (animationName) { if (animationName === void 0) { animationName = null; } @@ -8730,7 +8272,7 @@ if (!Date.now) { * @version DragonBones 5.0 * @language zh_CN */ - Animation.prototype.playConfig = function(animationConfig) { + Animation.prototype.playConfig = function (animationConfig) { var animationName = animationConfig.animation; if (!(animationName in this._animations)) { console.warn( @@ -8768,8 +8310,7 @@ if (!Date.now) { if (animationData.frameCount > 0) { if (animationConfig.position < 0.0) { animationConfig.position %= animationData.duration; - animationConfig.position = - animationData.duration - animationConfig.position; + animationConfig.position = animationData.duration - animationConfig.position; } else if (animationConfig.position === animationData.duration) { animationConfig.position -= 0.000001; // Play a little time before end. } else if (animationConfig.position > animationData.duration) { @@ -8777,11 +8318,9 @@ if (!Date.now) { } if ( animationConfig.duration > 0.0 && - animationConfig.position + animationConfig.duration > - animationData.duration + animationConfig.position + animationConfig.duration > animationData.duration ) { - animationConfig.duration = - animationData.duration - animationConfig.position; + animationConfig.duration = animationData.duration - animationConfig.position; } if (animationConfig.playTimes < 0) { animationConfig.playTimes = animationData.playTimes; @@ -8798,9 +8337,7 @@ if (!Date.now) { } this._fadeOut(animationConfig); // - var animationState = dragonBones.BaseObject.borrowObject( - dragonBones.AnimationState, - ); + var animationState = dragonBones.BaseObject.borrowObject(dragonBones.AnimationState); animationState.init(this._armature, animationData, animationConfig); this._animationDirty = true; this._armature._cacheFrameIndex = -1; @@ -8811,10 +8348,7 @@ if (!Date.now) { added = true; this._animationStates.splice(i, 0, animationState); break; - } else if ( - i !== l - 1 && - animationState.layer > this._animationStates[i + 1].layer - ) { + } else if (i !== l - 1 && animationState.layer > this._animationStates[i + 1].layer) { added = true; this._animationStates.splice(i + 1, 0, animationState); break; @@ -8839,14 +8373,7 @@ if (!Date.now) { } } for (var k in animationData.animationTimelines) { - var childAnimationState = this.fadeIn( - k, - 0.0, - 1, - animationState.layer, - '', - 5 /* Single */, - ); + var childAnimationState = this.fadeIn(k, 0.0, 1, animationState.layer, '', 5 /* Single */); if (childAnimationState === null) { continue; } @@ -8893,7 +8420,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - Animation.prototype.play = function(animationName, playTimes) { + Animation.prototype.play = function (animationName, playTimes) { if (animationName === void 0) { animationName = null; } @@ -8904,8 +8431,7 @@ if (!Date.now) { this._animationConfig.resetToPose = true; this._animationConfig.playTimes = playTimes; this._animationConfig.fadeInTime = 0.0; - this._animationConfig.animation = - animationName !== null ? animationName : ''; + this._animationConfig.animation = animationName !== null ? animationName : ''; if (animationName !== null && animationName.length > 0) { this.playConfig(this._animationConfig); } else if (this._lastAnimationState === null) { @@ -8914,10 +8440,7 @@ if (!Date.now) { this._animationConfig.animation = defaultAnimation.name; this.playConfig(this._animationConfig); } - } else if ( - !this._lastAnimationState.isPlaying && - !this._lastAnimationState.isCompleted - ) { + } else if (!this._lastAnimationState.isPlaying && !this._lastAnimationState.isCompleted) { this._lastAnimationState.play(); } else { this._animationConfig.animation = this._lastAnimationState.name; @@ -8959,14 +8482,7 @@ if (!Date.now) { * @version DragonBones 4.5 * @language zh_CN */ - Animation.prototype.fadeIn = function( - animationName, - fadeInTime, - playTimes, - layer, - group, - fadeOutMode, - ) { + Animation.prototype.fadeIn = function (animationName, fadeInTime, playTimes, layer, group, fadeOutMode) { if (fadeInTime === void 0) { fadeInTime = -1.0; } @@ -9009,11 +8525,7 @@ if (!Date.now) { * @version DragonBones 4.5 * @language zh_CN */ - Animation.prototype.gotoAndPlayByTime = function( - animationName, - time, - playTimes, - ) { + Animation.prototype.gotoAndPlayByTime = function (animationName, time, playTimes) { if (time === void 0) { time = 0.0; } @@ -9046,11 +8558,7 @@ if (!Date.now) { * @version DragonBones 4.5 * @language zh_CN */ - Animation.prototype.gotoAndPlayByFrame = function( - animationName, - frame, - playTimes, - ) { + Animation.prototype.gotoAndPlayByFrame = function (animationName, frame, playTimes) { if (frame === void 0) { frame = 0; } @@ -9062,15 +8570,10 @@ if (!Date.now) { this._animationConfig.playTimes = playTimes; this._animationConfig.fadeInTime = 0.0; this._animationConfig.animation = animationName; - var animationData = - animationName in this._animations - ? this._animations[animationName] - : null; + var animationData = animationName in this._animations ? this._animations[animationName] : null; if (animationData !== null) { this._animationConfig.position = - animationData.frameCount > 0 - ? (animationData.duration * frame) / animationData.frameCount - : 0.0; + animationData.frameCount > 0 ? (animationData.duration * frame) / animationData.frameCount : 0.0; } return this.playConfig(this._animationConfig); }; @@ -9092,11 +8595,7 @@ if (!Date.now) { * @version DragonBones 4.5 * @language zh_CN */ - Animation.prototype.gotoAndPlayByProgress = function( - animationName, - progress, - playTimes, - ) { + Animation.prototype.gotoAndPlayByProgress = function (animationName, progress, playTimes) { if (progress === void 0) { progress = 0.0; } @@ -9108,13 +8607,9 @@ if (!Date.now) { this._animationConfig.playTimes = playTimes; this._animationConfig.fadeInTime = 0.0; this._animationConfig.animation = animationName; - var animationData = - animationName in this._animations - ? this._animations[animationName] - : null; + var animationData = animationName in this._animations ? this._animations[animationName] : null; if (animationData !== null) { - this._animationConfig.position = - animationData.duration * (progress > 0.0 ? progress : 0.0); + this._animationConfig.position = animationData.duration * (progress > 0.0 ? progress : 0.0); } return this.playConfig(this._animationConfig); }; @@ -9134,7 +8629,7 @@ if (!Date.now) { * @version DragonBones 4.5 * @language zh_CN */ - Animation.prototype.gotoAndStopByTime = function(animationName, time) { + Animation.prototype.gotoAndStopByTime = function (animationName, time) { if (time === void 0) { time = 0.0; } @@ -9160,7 +8655,7 @@ if (!Date.now) { * @version DragonBones 4.5 * @language zh_CN */ - Animation.prototype.gotoAndStopByFrame = function(animationName, frame) { + Animation.prototype.gotoAndStopByFrame = function (animationName, frame) { if (frame === void 0) { frame = 0; } @@ -9186,18 +8681,11 @@ if (!Date.now) { * @version DragonBones 4.5 * @language zh_CN */ - Animation.prototype.gotoAndStopByProgress = function( - animationName, - progress, - ) { + Animation.prototype.gotoAndStopByProgress = function (animationName, progress) { if (progress === void 0) { progress = 0.0; } - var animationState = this.gotoAndPlayByProgress( - animationName, - progress, - 1, - ); + var animationState = this.gotoAndPlayByProgress(animationName, progress, 1); if (animationState !== null) { animationState.stop(); } @@ -9206,15 +8694,13 @@ if (!Date.now) { /** * @internal */ - Animation.prototype.getBlendState = function(type, name, target) { + Animation.prototype.getBlendState = function (type, name, target) { if (!(type in this._blendStates)) { this._blendStates[type] = {}; } var blendStates = this._blendStates[type]; if (!(name in blendStates)) { - var blendState = (blendStates[ - name - ] = dragonBones.BaseObject.borrowObject(dragonBones.BlendState)); + var blendState = (blendStates[name] = dragonBones.BaseObject.borrowObject(dragonBones.BlendState)); blendState.target = target; } return blendStates[name]; @@ -9245,17 +8731,14 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - Animation.prototype.getState = function(animationName, layer) { + Animation.prototype.getState = function (animationName, layer) { if (layer === void 0) { layer = -1; } var i = this._animationStates.length; while (i--) { var animationState = this._animationStates[i]; - if ( - animationState.name === animationName && - (layer < 0 || animationState.layer === layer) - ) { + if (animationState.name === animationName && (layer < 0 || animationState.layer === layer)) { return animationState; } } @@ -9275,7 +8758,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - Animation.prototype.hasAnimation = function(animationName) { + Animation.prototype.hasAnimation = function (animationName) { return animationName in this._animations; }; /** @@ -9288,7 +8771,7 @@ if (!Date.now) { * @version DragonBones 5.1 * @language zh_CN */ - Animation.prototype.getStates = function() { + Animation.prototype.getStates = function () { return this._animationStates; }; Object.defineProperty(Animation.prototype, 'isPlaying', { @@ -9304,7 +8787,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - get: function() { + get: function () { for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { var animationState = _a[_i]; if (animationState.isPlaying) { @@ -9329,7 +8812,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - get: function() { + get: function () { for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { var animationState = _a[_i]; if (!animationState.isCompleted) { @@ -9354,10 +8837,8 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - get: function() { - return this._lastAnimationState !== null - ? this._lastAnimationState.name - : ''; + get: function () { + return this._lastAnimationState !== null ? this._lastAnimationState.name : ''; }, enumerable: true, configurable: true, @@ -9373,7 +8854,7 @@ if (!Date.now) { * @version DragonBones 4.5 * @language zh_CN */ - get: function() { + get: function () { return this._animationNames; }, enumerable: true, @@ -9390,10 +8871,10 @@ if (!Date.now) { * @version DragonBones 4.5 * @language zh_CN */ - get: function() { + get: function () { return this._animations; }, - set: function(value) { + set: function (value) { if (this._animations === value) { return; } @@ -9422,7 +8903,7 @@ if (!Date.now) { * @version DragonBones 5.0 * @language zh_CN */ - get: function() { + get: function () { this._animationConfig.clear(); return this._animationConfig; }, @@ -9442,7 +8923,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - get: function() { + get: function () { return this._lastAnimationState; }, enumerable: true, @@ -9475,7 +8956,7 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * - The animation state is generated when the animation data is played. * @see dragonBones.Animation @@ -9490,7 +8971,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - var AnimationState = /** @class */ (function(_super) { + var AnimationState = /** @class */ (function (_super) { __extends(AnimationState, _super); function AnimationState() { var _this = (_super !== null && _super.apply(this, arguments)) || this; @@ -9509,10 +8990,10 @@ if (!Date.now) { _this._zOrderTimeline = null; // Initial value. return _this; } - AnimationState.toString = function() { + AnimationState.toString = function () { return '[class dragonBones.AnimationState]'; }; - AnimationState.prototype._onClear = function() { + AnimationState.prototype._onClear = function () { for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { var timeline = _a[_i]; timeline.returnToPool(); @@ -9593,29 +9074,17 @@ if (!Date.now) { this._activeChildB = null; this._parent = null; }; - AnimationState.prototype._updateTimelines = function() { + AnimationState.prototype._updateTimelines = function () { { - for ( - var _i = 0, _a = this._armature._constraints; - _i < _a.length; - _i++ - ) { + for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { var constraint = _a[_i]; - var timelineDatas = this._animationData.getConstraintTimelines( - constraint.name, - ); + var timelineDatas = this._animationData.getConstraintTimelines(constraint.name); if (timelineDatas !== null) { - for ( - var _b = 0, timelineDatas_1 = timelineDatas; - _b < timelineDatas_1.length; - _b++ - ) { + for (var _b = 0, timelineDatas_1 = timelineDatas; _b < timelineDatas_1.length; _b++) { var timelineData = timelineDatas_1[_b]; switch (timelineData.type) { case 30 /* IKConstraint */: { - var timeline = dragonBones.BaseObject.borrowObject( - dragonBones.IKConstraintTimelineState, - ); + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintTimelineState); timeline.target = constraint; timeline.init(this._armature, this, timelineData); this._constraintTimelines.push(timeline); @@ -9626,9 +9095,7 @@ if (!Date.now) { } } } else if (this.resetToPose) { - var timeline = dragonBones.BaseObject.borrowObject( - dragonBones.IKConstraintTimelineState, - ); + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintTimelineState); timeline.target = constraint; timeline.init(this._armature, this, null); this._constraintTimelines.push(timeline); @@ -9637,7 +9104,7 @@ if (!Date.now) { } } }; - AnimationState.prototype._updateBoneAndSlotTimelines = function() { + AnimationState.prototype._updateBoneAndSlotTimelines = function () { { var boneTimelines = {}; // Create bone timelines map. @@ -9667,80 +9134,50 @@ if (!Date.now) { if (timelineName in boneTimelines) { delete boneTimelines[timelineName]; } else { - var timelineDatas = this._animationData.getBoneTimelines( - timelineName, - ); - var blendState = this._armature.animation.getBlendState( - BlendState.BONE_TRANSFORM, - bone.name, - bone, - ); + var timelineDatas = this._animationData.getBoneTimelines(timelineName); + var blendState = this._armature.animation.getBlendState(BlendState.BONE_TRANSFORM, bone.name, bone); if (timelineDatas !== null) { - for ( - var _f = 0, timelineDatas_2 = timelineDatas; - _f < timelineDatas_2.length; - _f++ - ) { + for (var _f = 0, timelineDatas_2 = timelineDatas; _f < timelineDatas_2.length; _f++) { var timelineData = timelineDatas_2[_f]; switch (timelineData.type) { case 10 /* BoneAll */: { - var timeline = dragonBones.BaseObject.borrowObject( - dragonBones.BoneAllTimelineState, - ); + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); timeline.target = blendState; timeline.init(this._armature, this, timelineData); this._boneTimelines.push(timeline); break; } case 11 /* BoneTranslate */: { - var timeline = dragonBones.BaseObject.borrowObject( - dragonBones.BoneTranslateTimelineState, - ); + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneTranslateTimelineState); timeline.target = blendState; timeline.init(this._armature, this, timelineData); this._boneTimelines.push(timeline); break; } case 12 /* BoneRotate */: { - var timeline = dragonBones.BaseObject.borrowObject( - dragonBones.BoneRotateTimelineState, - ); + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneRotateTimelineState); timeline.target = blendState; timeline.init(this._armature, this, timelineData); this._boneTimelines.push(timeline); break; } case 13 /* BoneScale */: { - var timeline = dragonBones.BaseObject.borrowObject( - dragonBones.BoneScaleTimelineState, - ); + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneScaleTimelineState); timeline.target = blendState; timeline.init(this._armature, this, timelineData); this._boneTimelines.push(timeline); break; } case 60 /* BoneAlpha */: { - var timeline = dragonBones.BaseObject.borrowObject( - dragonBones.AlphaTimelineState, - ); - timeline.target = this._armature.animation.getBlendState( - BlendState.BONE_ALPHA, - bone.name, - bone, - ); + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AlphaTimelineState); + timeline.target = this._armature.animation.getBlendState(BlendState.BONE_ALPHA, bone.name, bone); timeline.init(this._armature, this, timelineData); this._boneBlendTimelines.push(timeline); break; } case 50 /* Surface */: { - var timeline = dragonBones.BaseObject.borrowObject( - dragonBones.SurfaceTimelineState, - ); - timeline.target = this._armature.animation.getBlendState( - BlendState.SURFACE, - bone.name, - bone, - ); + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SurfaceTimelineState); + timeline.target = this._armature.animation.getBlendState(BlendState.SURFACE, bone.name, bone); timeline.init(this._armature, this, timelineData); this._boneBlendTimelines.push(timeline); break; @@ -9751,22 +9188,14 @@ if (!Date.now) { } } else if (this.resetToPose) { if (bone._boneData.type === 0 /* Bone */) { - var timeline = dragonBones.BaseObject.borrowObject( - dragonBones.BoneAllTimelineState, - ); + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); timeline.target = blendState; timeline.init(this._armature, this, null); this._boneTimelines.push(timeline); this._poseTimelines.push(timeline); } else { - var timeline = dragonBones.BaseObject.borrowObject( - dragonBones.SurfaceTimelineState, - ); - timeline.target = this._armature.animation.getBlendState( - BlendState.SURFACE, - bone.name, - bone, - ); + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SurfaceTimelineState); + timeline.target = this._armature.animation.getBlendState(BlendState.SURFACE, bone.name, bone); timeline.init(this._armature, this, null); this._boneBlendTimelines.push(timeline); this._poseTimelines.push(timeline); @@ -9824,21 +9253,13 @@ if (!Date.now) { var displayIndexFlag = false; var colorFlag = false; ffdFlags.length = 0; - var timelineDatas = this._animationData.getSlotTimelines( - timelineName, - ); + var timelineDatas = this._animationData.getSlotTimelines(timelineName); if (timelineDatas !== null) { - for ( - var _q = 0, timelineDatas_3 = timelineDatas; - _q < timelineDatas_3.length; - _q++ - ) { + for (var _q = 0, timelineDatas_3 = timelineDatas; _q < timelineDatas_3.length; _q++) { var timelineData = timelineDatas_3[_q]; switch (timelineData.type) { case 20 /* SlotDisplay */: { - var timeline = dragonBones.BaseObject.borrowObject( - dragonBones.SlotDislayTimelineState, - ); + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDislayTimelineState); timeline.target = slot; timeline.init(this._armature, this, timelineData); this._slotTimelines.push(timeline); @@ -9846,22 +9267,14 @@ if (!Date.now) { break; } case 23 /* SlotZIndex */: { - var timeline = dragonBones.BaseObject.borrowObject( - dragonBones.SlotZIndexTimelineState, - ); - timeline.target = this._armature.animation.getBlendState( - BlendState.SLOT_Z_INDEX, - slot.name, - slot, - ); + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotZIndexTimelineState); + timeline.target = this._armature.animation.getBlendState(BlendState.SLOT_Z_INDEX, slot.name, slot); timeline.init(this._armature, this, timelineData); this._slotBlendTimelines.push(timeline); break; } case 21 /* SlotColor */: { - var timeline = dragonBones.BaseObject.borrowObject( - dragonBones.SlotColorTimelineState, - ); + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotColorTimelineState); timeline.target = slot; timeline.init(this._armature, this, timelineData); this._slotTimelines.push(timeline); @@ -9869,14 +9282,8 @@ if (!Date.now) { break; } case 22 /* SlotDeform */: { - var timeline = dragonBones.BaseObject.borrowObject( - dragonBones.DeformTimelineState, - ); - timeline.target = this._armature.animation.getBlendState( - BlendState.SLOT_DEFORM, - slot.name, - slot, - ); + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.DeformTimelineState); + timeline.target = this._armature.animation.getBlendState(BlendState.SLOT_DEFORM, slot.name, slot); timeline.init(this._armature, this, timelineData); if (timeline.target !== null) { this._slotBlendTimelines.push(timeline); @@ -9887,14 +9294,8 @@ if (!Date.now) { break; } case 24 /* SlotAlpha */: { - var timeline = dragonBones.BaseObject.borrowObject( - dragonBones.AlphaTimelineState, - ); - timeline.target = this._armature.animation.getBlendState( - BlendState.SLOT_ALPHA, - slot.name, - slot, - ); + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AlphaTimelineState); + timeline.target = this._armature.animation.getBlendState(BlendState.SLOT_ALPHA, slot.name, slot); timeline.init(this._armature, this, timelineData); this._slotBlendTimelines.push(timeline); break; @@ -9906,18 +9307,14 @@ if (!Date.now) { } if (this.resetToPose) { if (!displayIndexFlag) { - var timeline = dragonBones.BaseObject.borrowObject( - dragonBones.SlotDislayTimelineState, - ); + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDislayTimelineState); timeline.target = slot; timeline.init(this._armature, this, null); this._slotTimelines.push(timeline); this._poseTimelines.push(timeline); } if (!colorFlag) { - var timeline = dragonBones.BaseObject.borrowObject( - dragonBones.SlotColorTimelineState, - ); + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotColorTimelineState); timeline.target = slot; timeline.init(this._armature, this, null); this._slotTimelines.push(timeline); @@ -9929,20 +9326,11 @@ if (!Date.now) { continue; } var geometryData = displayFrame.getGeometryData(); - if ( - geometryData !== null && - ffdFlags.indexOf(geometryData.offset) < 0 - ) { - var timeline = dragonBones.BaseObject.borrowObject( - dragonBones.DeformTimelineState, - ); + if (geometryData !== null && ffdFlags.indexOf(geometryData.offset) < 0) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.DeformTimelineState); timeline.geometryOffset = geometryData.offset; // timeline.displayFrame = displayFrame; // - timeline.target = this._armature.animation.getBlendState( - BlendState.SLOT_DEFORM, - slot.name, - slot, - ); + timeline.target = this._armature.animation.getBlendState(BlendState.SLOT_DEFORM, slot.name, slot); timeline.init(this._armature, this, null); this._slotBlendTimelines.push(timeline); this._poseTimelines.push(timeline); @@ -9968,19 +9356,15 @@ if (!Date.now) { } } }; - AnimationState.prototype._advanceFadeTime = function(passedTime) { + AnimationState.prototype._advanceFadeTime = function (passedTime) { var isFadeOut = this._fadeState > 0; if (this._subFadeState < 0) { this._subFadeState = 0; var eventActive = this._parent === null && this.actionEnabled; if (eventActive) { - var eventType = isFadeOut - ? dragonBones.EventObject.FADE_OUT - : dragonBones.EventObject.FADE_IN; + var eventType = isFadeOut ? dragonBones.EventObject.FADE_OUT : dragonBones.EventObject.FADE_IN; if (this._armature.eventDispatcher.hasDBEventListener(eventType)) { - var eventObject = dragonBones.BaseObject.borrowObject( - dragonBones.EventObject, - ); + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); eventObject.type = eventType; eventObject.armature = this._armature; eventObject.animationState = this; @@ -10013,9 +9397,7 @@ if (!Date.now) { ? dragonBones.EventObject.FADE_OUT_COMPLETE : dragonBones.EventObject.FADE_IN_COMPLETE; if (this._armature.eventDispatcher.hasDBEventListener(eventType)) { - var eventObject = dragonBones.BaseObject.borrowObject( - dragonBones.EventObject, - ); + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); eventObject.type = eventType; eventObject.armature = this._armature; eventObject.animationState = this; @@ -10027,11 +9409,7 @@ if (!Date.now) { /** * @internal */ - AnimationState.prototype.init = function( - armature, - animationData, - animationConfig, - ) { + AnimationState.prototype.init = function (armature, animationData, animationConfig) { if (this._armature !== null) { return; } @@ -10048,10 +9426,7 @@ if (!Date.now) { this.timeScale = animationConfig.timeScale; this.fadeTotalTime = animationConfig.fadeInTime; this.autoFadeOutTime = animationConfig.autoFadeOutTime; - this.name = - animationConfig.name.length > 0 - ? animationConfig.name - : animationConfig.animation; + this.name = animationConfig.name.length > 0 ? animationConfig.name : animationConfig.animation; this.group = animationConfig.group; // this._weight = animationConfig.weight; @@ -10089,37 +9464,21 @@ if (!Date.now) { this._boneMask[i] = animationConfig.boneMask[i]; } } - this._actionTimeline = dragonBones.BaseObject.borrowObject( - dragonBones.ActionTimelineState, - ); - this._actionTimeline.init( - this._armature, - this, - this._animationData.actionTimeline, - ); + this._actionTimeline = dragonBones.BaseObject.borrowObject(dragonBones.ActionTimelineState); + this._actionTimeline.init(this._armature, this, this._animationData.actionTimeline); this._actionTimeline.currentTime = this._time; if (this._actionTimeline.currentTime < 0.0) { - this._actionTimeline.currentTime = - this._duration - this._actionTimeline.currentTime; + this._actionTimeline.currentTime = this._duration - this._actionTimeline.currentTime; } if (this._animationData.zOrderTimeline !== null) { - this._zOrderTimeline = dragonBones.BaseObject.borrowObject( - dragonBones.ZOrderTimelineState, - ); - this._zOrderTimeline.init( - this._armature, - this, - this._animationData.zOrderTimeline, - ); + this._zOrderTimeline = dragonBones.BaseObject.borrowObject(dragonBones.ZOrderTimelineState); + this._zOrderTimeline.init(this._armature, this, this._animationData.zOrderTimeline); } }; /** * @internal */ - AnimationState.prototype.advanceTime = function( - passedTime, - cacheFrameRate, - ) { + AnimationState.prototype.advanceTime = function (passedTime, cacheFrameRate) { // Update fade time. if (this._fadeState !== 0 || this._subFadeState !== 0) { this._advanceFadeTime(passedTime); @@ -10156,19 +9515,13 @@ if (!Date.now) { } if (isCacheEnabled) { var internval = cacheFrameRate * 2.0; - this._actionTimeline.currentTime = - Math.floor(this._actionTimeline.currentTime * internval) / internval; + this._actionTimeline.currentTime = Math.floor(this._actionTimeline.currentTime * internval) / internval; } - if ( - this._zOrderTimeline !== null && - this._zOrderTimeline.playState <= 0 - ) { + if (this._zOrderTimeline !== null && this._zOrderTimeline.playState <= 0) { this._zOrderTimeline.update(time); } if (isCacheEnabled) { - var cacheFrameIndex = Math.floor( - this._actionTimeline.currentTime * cacheFrameRate, - ); // uint + var cacheFrameIndex = Math.floor(this._actionTimeline.currentTime * cacheFrameRate); // uint if (this._armature._cacheFrameIndex === cacheFrameIndex) { isUpdateTimeline = false; isUpdateBoneTimeline = false; @@ -10224,11 +9577,7 @@ if (!Date.now) { if (timeline.playState <= 0) { var slot = timeline.target; var displayController = slot.displayController; - if ( - displayController === null || - displayController === this.name || - displayController === this.group - ) { + if (displayController === null || displayController === this.name || displayController === this.group) { timeline.update(time); } } @@ -10354,7 +9703,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - AnimationState.prototype.play = function() { + AnimationState.prototype.play = function () { this._playheadState = 3; // 11 }; /** @@ -10367,7 +9716,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - AnimationState.prototype.stop = function() { + AnimationState.prototype.stop = function () { this._playheadState &= 1; // 0x }; /** @@ -10384,7 +9733,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - AnimationState.prototype.fadeOut = function(fadeOutTime, pausePlayhead) { + AnimationState.prototype.fadeOut = function (fadeOutTime, pausePlayhead) { if (pausePlayhead === void 0) { pausePlayhead = true; } @@ -10433,8 +9782,7 @@ if (!Date.now) { } } this.displayControl = false; // - this.fadeTotalTime = - this._fadeProgress > 0.000001 ? fadeOutTime / this._fadeProgress : 0.0; + this.fadeTotalTime = this._fadeProgress > 0.000001 ? fadeOutTime / this._fadeProgress : 0.0; this._fadeTime = this.fadeTotalTime * (1.0 - this._fadeProgress); }; /** @@ -10449,10 +9797,8 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - AnimationState.prototype.containsBoneMask = function(boneName) { - return ( - this._boneMask.length === 0 || this._boneMask.indexOf(boneName) >= 0 - ); + AnimationState.prototype.containsBoneMask = function (boneName) { + return this._boneMask.length === 0 || this._boneMask.indexOf(boneName) >= 0; }; /** * - Add a specific bone mask. @@ -10468,7 +9814,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - AnimationState.prototype.addBoneMask = function(boneName, recursive) { + AnimationState.prototype.addBoneMask = function (boneName, recursive) { if (recursive === void 0) { recursive = true; } @@ -10482,10 +9828,7 @@ if (!Date.now) { if (recursive) { for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { var bone = _a[_i]; - if ( - this._boneMask.indexOf(bone.name) < 0 && - currentBone.contains(bone) - ) { + if (this._boneMask.indexOf(bone.name) < 0 && currentBone.contains(bone)) { this._boneMask.push(bone.name); } } @@ -10506,7 +9849,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - AnimationState.prototype.removeBoneMask = function(boneName, recursive) { + AnimationState.prototype.removeBoneMask = function (boneName, recursive) { if (recursive === void 0) { recursive = true; } @@ -10551,32 +9894,23 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - AnimationState.prototype.removeAllBoneMask = function() { + AnimationState.prototype.removeAllBoneMask = function () { this._boneMask.length = 0; this._timelineDirty = 1; }; /** * @private */ - AnimationState.prototype.addState = function( - animationState, - timelineDatas, - ) { + AnimationState.prototype.addState = function (animationState, timelineDatas) { if (timelineDatas === void 0) { timelineDatas = null; } if (timelineDatas !== null) { - for ( - var _i = 0, timelineDatas_4 = timelineDatas; - _i < timelineDatas_4.length; - _i++ - ) { + for (var _i = 0, timelineDatas_4 = timelineDatas; _i < timelineDatas_4.length; _i++) { var timelineData = timelineDatas_4[_i]; switch (timelineData.type) { case 40 /* AnimationProgress */: { - var timeline = dragonBones.BaseObject.borrowObject( - dragonBones.AnimationProgressTimelineState, - ); + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationProgressTimelineState); timeline.target = animationState; timeline.init(this._armature, this, timelineData); this._animationTimelines.push(timeline); @@ -10591,18 +9925,14 @@ if (!Date.now) { break; } case 41 /* AnimationWeight */: { - var timeline = dragonBones.BaseObject.borrowObject( - dragonBones.AnimationWeightTimelineState, - ); + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationWeightTimelineState); timeline.target = animationState; timeline.init(this._armature, this, timelineData); this._animationTimelines.push(timeline); break; } case 42 /* AnimationParameter */: { - var timeline = dragonBones.BaseObject.borrowObject( - dragonBones.AnimationParametersTimelineState, - ); + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationParametersTimelineState); timeline.target = animationState; timeline.init(this._armature, this, timelineData); this._animationTimelines.push(timeline); @@ -10620,7 +9950,7 @@ if (!Date.now) { /** * @internal */ - AnimationState.prototype.activeTimeline = function() { + AnimationState.prototype.activeTimeline = function () { for (var _i = 0, _a = this._slotTimelines; _i < _a.length; _i++) { var timeline = _a[_i]; timeline.dirty = true; @@ -10638,7 +9968,7 @@ if (!Date.now) { * @version DragonBones 5.1 * @language zh_CN */ - get: function() { + get: function () { return this._fadeState < 0; }, enumerable: true, @@ -10655,7 +9985,7 @@ if (!Date.now) { * @version DragonBones 5.1 * @language zh_CN */ - get: function() { + get: function () { return this._fadeState > 0; }, enumerable: true, @@ -10672,7 +10002,7 @@ if (!Date.now) { * @version DragonBones 5.1 * @language zh_CN */ - get: function() { + get: function () { return this._fadeState === 0; }, enumerable: true, @@ -10689,10 +10019,8 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - get: function() { - return ( - (this._playheadState & 2) !== 0 && this._actionTimeline.playState <= 0 - ); + get: function () { + return (this._playheadState & 2) !== 0 && this._actionTimeline.playState <= 0; }, enumerable: true, configurable: true, @@ -10708,7 +10036,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - get: function() { + get: function () { return this._actionTimeline.playState > 0; }, enumerable: true, @@ -10725,7 +10053,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - get: function() { + get: function () { return this._actionTimeline.currentPlayTimes; }, enumerable: true, @@ -10742,7 +10070,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - get: function() { + get: function () { return this._duration; }, enumerable: true, @@ -10759,13 +10087,11 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - get: function() { + get: function () { return this._actionTimeline.currentTime; }, - set: function(value) { - var currentPlayTimes = - this._actionTimeline.currentPlayTimes - - (this._actionTimeline.playState > 0 ? 1 : 0); + set: function (value) { + var currentPlayTimes = this._actionTimeline.currentPlayTimes - (this._actionTimeline.playState > 0 ? 1 : 0); if (value < 0 || this._duration < value) { value = (value % this._duration) + currentPlayTimes * this._duration; if (value < 0) { @@ -10819,10 +10145,10 @@ if (!Date.now) { * @version DragonBones 3.0 * @language en_US */ - get: function() { + get: function () { return this._weight; }, - set: function(value) { + set: function (value) { if (this._weight === value) { return; } @@ -10850,7 +10176,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - get: function() { + get: function () { return this._animationData; }, enumerable: true, @@ -10862,19 +10188,19 @@ if (!Date.now) { /** * @internal */ - var BlendState = /** @class */ (function(_super) { + var BlendState = /** @class */ (function (_super) { __extends(BlendState, _super); function BlendState() { return (_super !== null && _super.apply(this, arguments)) || this; } - BlendState.toString = function() { + BlendState.toString = function () { return '[class dragonBones.BlendState]'; }; - BlendState.prototype._onClear = function() { + BlendState.prototype._onClear = function () { this.reset(); this.target = null; }; - BlendState.prototype.update = function(animationState) { + BlendState.prototype.update = function (animationState) { var animationLayer = animationState.layer; var animationWeight = animationState._weightResult; if (this.dirty > 0) { @@ -10906,7 +10232,7 @@ if (!Date.now) { this.layerWeight = animationWeight; return true; }; - BlendState.prototype.reset = function() { + BlendState.prototype.reset = function () { this.dirty = 0; this.layer = 0; this.leftWeight = 0.0; @@ -10946,16 +10272,16 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * @internal */ - var TimelineState = /** @class */ (function(_super) { + var TimelineState = /** @class */ (function (_super) { __extends(TimelineState, _super); function TimelineState() { return (_super !== null && _super.apply(this, arguments)) || this; } - TimelineState.prototype._onClear = function() { + TimelineState.prototype._onClear = function () { this.dirty = false; this.playState = -1; this.currentPlayTimes = -1; @@ -10983,7 +10309,7 @@ if (!Date.now) { this._timelineArray = null; // this._frameIndices = null; // }; - TimelineState.prototype._setCurrentTime = function(passedTime) { + TimelineState.prototype._setCurrentTime = function (passedTime) { var prevState = this.playState; var prevPlayTimes = this.currentPlayTimes; var prevTime = this.currentTime; @@ -10991,25 +10317,15 @@ if (!Date.now) { this.playState = this._actionTimeline.playState >= 0 ? 1 : -1; this.currentPlayTimes = 1; this.currentTime = this._actionTimeline.currentTime; - } else if ( - this._actionTimeline === null || - this._timeScale !== 1.0 || - this._timeOffset !== 0.0 - ) { + } else if (this._actionTimeline === null || this._timeScale !== 1.0 || this._timeOffset !== 0.0) { var playTimes = this._animationState.playTimes; var totalTime = playTimes * this._duration; passedTime *= this._timeScale; if (this._timeOffset !== 0.0) { passedTime += this._timeOffset * this._animationData.duration; } - if ( - playTimes > 0 && - (passedTime >= totalTime || passedTime <= -totalTime) - ) { - if ( - this.playState <= 0 && - this._animationState._playheadState === 3 - ) { + if (playTimes > 0 && (passedTime >= totalTime || passedTime <= -totalTime)) { + if (this.playState <= 0 && this._animationState._playheadState === 3) { this.playState = 1; } this.currentPlayTimes = playTimes; @@ -11019,10 +10335,7 @@ if (!Date.now) { this.currentTime = this._duration + 0.000001; // Precision problem } } else { - if ( - this.playState !== 0 && - this._animationState._playheadState === 3 - ) { + if (this.playState !== 0 && this._animationState._playheadState === 3) { this.playState = 0; } if (passedTime < 0.0) { @@ -11040,10 +10353,7 @@ if (!Date.now) { this.currentPlayTimes = this._actionTimeline.currentPlayTimes; this.currentTime = this._actionTimeline.currentTime; } - if ( - this.currentPlayTimes === prevPlayTimes && - this.currentTime === prevTime - ) { + if (this.currentPlayTimes === prevPlayTimes && this.currentTime === prevTime) { return false; } // Clear frame flag when timeline start or loopComplete. @@ -11055,11 +10365,7 @@ if (!Date.now) { } return true; }; - TimelineState.prototype.init = function( - armature, - animationState, - timelineData, - ) { + TimelineState.prototype.init = function (armature, animationState, timelineData) { this._armature = armature; this._animationState = animationState; this._timelineData = timelineData; @@ -11079,44 +10385,25 @@ if (!Date.now) { this._timelineArray = dragonBonesData.timelineArray; this._frameIndices = dragonBonesData.frameIndices; // - this._frameCount = this._timelineArray[ - this._timelineData.offset + 2 /* TimelineKeyFrameCount */ - ]; - this._frameValueOffset = this._timelineArray[ - this._timelineData.offset + 4 /* TimelineFrameValueOffset */ - ]; - this._timeScale = - 100.0 / - this._timelineArray[ - this._timelineData.offset + 0 /* TimelineScale */ - ]; - this._timeOffset = - this._timelineArray[ - this._timelineData.offset + 1 /* TimelineOffset */ - ] * 0.01; - } - }; - TimelineState.prototype.fadeOut = function() { + this._frameCount = this._timelineArray[this._timelineData.offset + 2 /* TimelineKeyFrameCount */]; + this._frameValueOffset = this._timelineArray[this._timelineData.offset + 4 /* TimelineFrameValueOffset */]; + this._timeScale = 100.0 / this._timelineArray[this._timelineData.offset + 0 /* TimelineScale */]; + this._timeOffset = this._timelineArray[this._timelineData.offset + 1 /* TimelineOffset */] * 0.01; + } + }; + TimelineState.prototype.fadeOut = function () { this.dirty = false; }; - TimelineState.prototype.update = function(passedTime) { + TimelineState.prototype.update = function (passedTime) { if (this._setCurrentTime(passedTime)) { if (this._frameCount > 1) { - var timelineFrameIndex = Math.floor( - this.currentTime * this._frameRate, - ); // uint - var frameIndex = this._frameIndices[ - this._timelineData.frameIndicesOffset + timelineFrameIndex - ]; + var timelineFrameIndex = Math.floor(this.currentTime * this._frameRate); // uint + var frameIndex = this._frameIndices[this._timelineData.frameIndicesOffset + timelineFrameIndex]; if (this._frameIndex !== frameIndex) { this._frameIndex = frameIndex; this._frameOffset = this._animationData.frameOffset + - this._timelineArray[ - this._timelineData.offset + - 5 /* TimelineFrameOffset */ + - this._frameIndex - ]; + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */ + this._frameIndex]; this._onArriveAtFrame(); } } else if (this._frameIndex < 0) { @@ -11124,9 +10411,7 @@ if (!Date.now) { if (this._timelineData !== null) { this._frameOffset = this._animationData.frameOffset + - this._timelineArray[ - this._timelineData.offset + 5 /* TimelineFrameOffset */ - ]; + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */]; } this._onArriveAtFrame(); } @@ -11135,19 +10420,19 @@ if (!Date.now) { } } }; - TimelineState.prototype.blend = function(_isDirty) {}; + TimelineState.prototype.blend = function (_isDirty) {}; return TimelineState; })(dragonBones.BaseObject); dragonBones.TimelineState = TimelineState; /** * @internal */ - var TweenTimelineState = /** @class */ (function(_super) { + var TweenTimelineState = /** @class */ (function (_super) { __extends(TweenTimelineState, _super); function TweenTimelineState() { return (_super !== null && _super.apply(this, arguments)) || this; } - TweenTimelineState._getEasingValue = function(tweenType, progress, easing) { + TweenTimelineState._getEasingValue = function (tweenType, progress, easing) { var value = progress; switch (tweenType) { case 3 /* QuadIn */: @@ -11162,12 +10447,7 @@ if (!Date.now) { } return (value - progress) * easing + progress; }; - TweenTimelineState._getEasingCurveValue = function( - progress, - samples, - count, - offset, - ) { + TweenTimelineState._getEasingCurveValue = function (progress, samples, count, offset) { if (progress <= 0.0) { return 0.0; } else if (progress >= 1.0) { @@ -11180,21 +10460,14 @@ if (!Date.now) { var toValue = 0.0; if (isOmited) { fromValue = valueIndex === 0 ? 0.0 : samples[offset + valueIndex - 1]; - toValue = - valueIndex === segmentCount - 1 - ? 10000.0 - : samples[offset + valueIndex]; + toValue = valueIndex === segmentCount - 1 ? 10000.0 : samples[offset + valueIndex]; } else { fromValue = samples[offset + valueIndex - 1]; toValue = samples[offset + valueIndex]; } - return ( - (fromValue + - (toValue - fromValue) * (progress * segmentCount - valueIndex)) * - 0.0001 - ); + return (fromValue + (toValue - fromValue) * (progress * segmentCount - valueIndex)) * 0.0001; }; - TweenTimelineState.prototype._onClear = function() { + TweenTimelineState.prototype._onClear = function () { _super.prototype._onClear.call(this); this._tweenType = 0 /* None */; this._curveCount = 0; @@ -11204,52 +10477,32 @@ if (!Date.now) { this._tweenProgress = 0.0; this._valueScale = 1.0; }; - TweenTimelineState.prototype._onArriveAtFrame = function() { + TweenTimelineState.prototype._onArriveAtFrame = function () { if ( this._frameCount > 1 && (this._frameIndex !== this._frameCount - 1 || this._animationState.playTimes === 0 || - this._animationState.currentPlayTimes < - this._animationState.playTimes - 1) + this._animationState.currentPlayTimes < this._animationState.playTimes - 1) ) { - this._tweenType = this._frameArray[ - this._frameOffset + 1 /* FrameTweenType */ - ]; + this._tweenType = this._frameArray[this._frameOffset + 1 /* FrameTweenType */]; this._isTween = this._tweenType !== 0 /* None */; if (this._isTween) { if (this._tweenType === 2 /* Curve */) { - this._curveCount = this._frameArray[ - this._frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */ - ]; - } else if ( - this._tweenType !== 0 /* None */ && - this._tweenType !== 1 /* Line */ - ) { - this._tweenEasing = - this._frameArray[ - this._frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */ - ] * 0.01; + this._curveCount = this._frameArray[this._frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */]; + } else if (this._tweenType !== 0 /* None */ && this._tweenType !== 1 /* Line */) { + this._tweenEasing = this._frameArray[this._frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] * 0.01; } } else { this.dirty = true; } - this._framePosition = - this._frameArray[this._frameOffset] * this._frameRateR; + this._framePosition = this._frameArray[this._frameOffset] * this._frameRateR; if (this._frameIndex === this._frameCount - 1) { - this._frameDurationR = - 1.0 / (this._animationData.duration - this._framePosition); + this._frameDurationR = 1.0 / (this._animationData.duration - this._framePosition); } else { var nextFrameOffset = this._animationData.frameOffset + - this._timelineArray[ - this._timelineData.offset + - 5 /* TimelineFrameOffset */ + - this._frameIndex + - 1 - ]; - var frameDuration = - this._frameArray[nextFrameOffset] * this._frameRateR - - this._framePosition; + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */ + this._frameIndex + 1]; + var frameDuration = this._frameArray[nextFrameOffset] * this._frameRateR - this._framePosition; if (frameDuration > 0) { this._frameDurationR = 1.0 / frameDuration; } else { @@ -11261,11 +10514,10 @@ if (!Date.now) { this._isTween = false; } }; - TweenTimelineState.prototype._onUpdateFrame = function() { + TweenTimelineState.prototype._onUpdateFrame = function () { if (this._isTween) { this.dirty = true; - this._tweenProgress = - (this.currentTime - this._framePosition) * this._frameDurationR; + this._tweenProgress = (this.currentTime - this._framePosition) * this._frameDurationR; if (this._tweenType === 2 /* Curve */) { this._tweenProgress = TweenTimelineState._getEasingCurveValue( this._tweenProgress, @@ -11288,37 +10540,33 @@ if (!Date.now) { /** * @internal */ - var SingleValueTimelineState = /** @class */ (function(_super) { + var SingleValueTimelineState = /** @class */ (function (_super) { __extends(SingleValueTimelineState, _super); function SingleValueTimelineState() { return (_super !== null && _super.apply(this, arguments)) || this; } - SingleValueTimelineState.prototype._onClear = function() { + SingleValueTimelineState.prototype._onClear = function () { _super.prototype._onClear.call(this); this._current = 0.0; this._difference = 0.0; this._result = 0.0; }; - SingleValueTimelineState.prototype._onArriveAtFrame = function() { + SingleValueTimelineState.prototype._onArriveAtFrame = function () { _super.prototype._onArriveAtFrame.call(this); if (this._timelineData !== null) { var valueScale = this._valueScale; var valueArray = this._valueArray; // - var valueOffset = - this._valueOffset + this._frameValueOffset + this._frameIndex; + var valueOffset = this._valueOffset + this._frameValueOffset + this._frameIndex; if (this._isTween) { var nextValueOffset = - this._frameIndex === this._frameCount - 1 - ? this._valueOffset + this._frameValueOffset - : valueOffset + 1; + this._frameIndex === this._frameCount - 1 ? this._valueOffset + this._frameValueOffset : valueOffset + 1; if (valueScale === 1.0) { this._current = valueArray[valueOffset]; this._difference = valueArray[nextValueOffset] - this._current; } else { this._current = valueArray[valueOffset] * valueScale; - this._difference = - valueArray[nextValueOffset] * valueScale - this._current; + this._difference = valueArray[nextValueOffset] * valueScale - this._current; } } else { this._result = valueArray[valueOffset] * valueScale; @@ -11327,7 +10575,7 @@ if (!Date.now) { this._result = 0.0; } }; - SingleValueTimelineState.prototype._onUpdateFrame = function() { + SingleValueTimelineState.prototype._onUpdateFrame = function () { _super.prototype._onUpdateFrame.call(this); if (this._isTween) { this._result = this._current + this._difference * this._tweenProgress; @@ -11339,12 +10587,12 @@ if (!Date.now) { /** * @internal */ - var DoubleValueTimelineState = /** @class */ (function(_super) { + var DoubleValueTimelineState = /** @class */ (function (_super) { __extends(DoubleValueTimelineState, _super); function DoubleValueTimelineState() { return (_super !== null && _super.apply(this, arguments)) || this; } - DoubleValueTimelineState.prototype._onClear = function() { + DoubleValueTimelineState.prototype._onClear = function () { _super.prototype._onClear.call(this); this._currentA = 0.0; this._currentB = 0.0; @@ -11353,32 +10601,26 @@ if (!Date.now) { this._resultA = 0.0; this._resultB = 0.0; }; - DoubleValueTimelineState.prototype._onArriveAtFrame = function() { + DoubleValueTimelineState.prototype._onArriveAtFrame = function () { _super.prototype._onArriveAtFrame.call(this); if (this._timelineData !== null) { var valueScale = this._valueScale; var valueArray = this._valueArray; // - var valueOffset = - this._valueOffset + this._frameValueOffset + this._frameIndex * 2; + var valueOffset = this._valueOffset + this._frameValueOffset + this._frameIndex * 2; if (this._isTween) { var nextValueOffset = - this._frameIndex === this._frameCount - 1 - ? this._valueOffset + this._frameValueOffset - : valueOffset + 2; + this._frameIndex === this._frameCount - 1 ? this._valueOffset + this._frameValueOffset : valueOffset + 2; if (valueScale === 1.0) { this._currentA = valueArray[valueOffset]; this._currentB = valueArray[valueOffset + 1]; this._differenceA = valueArray[nextValueOffset] - this._currentA; - this._differenceB = - valueArray[nextValueOffset + 1] - this._currentB; + this._differenceB = valueArray[nextValueOffset + 1] - this._currentB; } else { this._currentA = valueArray[valueOffset] * valueScale; this._currentB = valueArray[valueOffset + 1] * valueScale; - this._differenceA = - valueArray[nextValueOffset] * valueScale - this._currentA; - this._differenceB = - valueArray[nextValueOffset + 1] * valueScale - this._currentB; + this._differenceA = valueArray[nextValueOffset] * valueScale - this._currentA; + this._differenceB = valueArray[nextValueOffset + 1] * valueScale - this._currentB; } } else { this._resultA = valueArray[valueOffset] * valueScale; @@ -11389,13 +10631,11 @@ if (!Date.now) { this._resultB = 0.0; } }; - DoubleValueTimelineState.prototype._onUpdateFrame = function() { + DoubleValueTimelineState.prototype._onUpdateFrame = function () { _super.prototype._onUpdateFrame.call(this); if (this._isTween) { - this._resultA = - this._currentA + this._differenceA * this._tweenProgress; - this._resultB = - this._currentB + this._differenceB * this._tweenProgress; + this._resultA = this._currentA + this._differenceA * this._tweenProgress; + this._resultB = this._currentB + this._differenceB * this._tweenProgress; } }; return DoubleValueTimelineState; @@ -11404,19 +10644,19 @@ if (!Date.now) { /** * @internal */ - var MutilpleValueTimelineState = /** @class */ (function(_super) { + var MutilpleValueTimelineState = /** @class */ (function (_super) { __extends(MutilpleValueTimelineState, _super); function MutilpleValueTimelineState() { var _this = (_super !== null && _super.apply(this, arguments)) || this; _this._rd = []; return _this; } - MutilpleValueTimelineState.prototype._onClear = function() { + MutilpleValueTimelineState.prototype._onClear = function () { _super.prototype._onClear.call(this); this._valueCount = 0; this._rd.length = 0; }; - MutilpleValueTimelineState.prototype._onArriveAtFrame = function() { + MutilpleValueTimelineState.prototype._onArriveAtFrame = function () { _super.prototype._onArriveAtFrame.call(this); var valueCount = this._valueCount; var rd = this._rd; @@ -11424,10 +10664,7 @@ if (!Date.now) { var valueScale = this._valueScale; var valueArray = this._valueArray; // - var valueOffset = - this._valueOffset + - this._frameValueOffset + - this._frameIndex * valueCount; + var valueOffset = this._valueOffset + this._frameValueOffset + this._frameIndex * valueCount; if (this._isTween) { var nextValueOffset = this._frameIndex === this._frameCount - 1 @@ -11435,15 +10672,11 @@ if (!Date.now) { : valueOffset + valueCount; if (valueScale === 1.0) { for (var i = 0; i < valueCount; ++i) { - rd[valueCount + i] = - valueArray[nextValueOffset + i] - valueArray[valueOffset + i]; + rd[valueCount + i] = valueArray[nextValueOffset + i] - valueArray[valueOffset + i]; } } else { for (var i = 0; i < valueCount; ++i) { - rd[valueCount + i] = - (valueArray[nextValueOffset + i] - - valueArray[valueOffset + i]) * - valueScale; + rd[valueCount + i] = (valueArray[nextValueOffset + i] - valueArray[valueOffset + i]) * valueScale; } } } else if (valueScale === 1.0) { @@ -11461,7 +10694,7 @@ if (!Date.now) { } } }; - MutilpleValueTimelineState.prototype._onUpdateFrame = function() { + MutilpleValueTimelineState.prototype._onUpdateFrame = function () { _super.prototype._onUpdateFrame.call(this); if (this._isTween) { var valueCount = this._valueCount; @@ -11470,20 +10703,14 @@ if (!Date.now) { var valueArray = this._valueArray; var rd = this._rd; // - var valueOffset = - this._valueOffset + - this._frameValueOffset + - this._frameIndex * valueCount; + var valueOffset = this._valueOffset + this._frameValueOffset + this._frameIndex * valueCount; if (valueScale === 1.0) { for (var i = 0; i < valueCount; ++i) { - rd[i] = - valueArray[valueOffset + i] + rd[valueCount + i] * tweenProgress; + rd[i] = valueArray[valueOffset + i] + rd[valueCount + i] * tweenProgress; } } else { for (var i = 0; i < valueCount; ++i) { - rd[i] = - valueArray[valueOffset + i] * valueScale + - rd[valueCount + i] * tweenProgress; + rd[i] = valueArray[valueOffset + i] * valueScale + rd[valueCount + i] * tweenProgress; } } } @@ -11515,98 +10742,70 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * @internal */ - var ActionTimelineState = /** @class */ (function(_super) { + var ActionTimelineState = /** @class */ (function (_super) { __extends(ActionTimelineState, _super); function ActionTimelineState() { return (_super !== null && _super.apply(this, arguments)) || this; } - ActionTimelineState.toString = function() { + ActionTimelineState.toString = function () { return '[class dragonBones.ActionTimelineState]'; }; - ActionTimelineState.prototype._onCrossFrame = function(frameIndex) { + ActionTimelineState.prototype._onCrossFrame = function (frameIndex) { var eventDispatcher = this._armature.eventDispatcher; if (this._animationState.actionEnabled) { var frameOffset = this._animationData.frameOffset + - this._timelineArray[ - this._timelineData.offset + 5 /* TimelineFrameOffset */ + frameIndex - ]; + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */ + frameIndex]; var actionCount = this._frameArray[frameOffset + 1]; var actions = this._animationData.parent.actions; // May be the animaton data not belong to this armature data. for (var i = 0; i < actionCount; ++i) { var actionIndex = this._frameArray[frameOffset + 2 + i]; var action = actions[actionIndex]; if (action.type === 0 /* Play */) { - var eventObject = dragonBones.BaseObject.borrowObject( - dragonBones.EventObject, - ); + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); // eventObject.time = this._frameArray[frameOffset] * this._frameRateR; // Precision problem eventObject.time = this._frameArray[frameOffset] / this._frameRate; eventObject.animationState = this._animationState; - dragonBones.EventObject.actionDataToInstance( - action, - eventObject, - this._armature, - ); + dragonBones.EventObject.actionDataToInstance(action, eventObject, this._armature); this._armature._bufferAction(eventObject, true); } else { var eventType = action.type === 10 /* Frame */ ? dragonBones.EventObject.FRAME_EVENT : dragonBones.EventObject.SOUND_EVENT; - if ( - action.type === 11 /* Sound */ || - eventDispatcher.hasDBEventListener(eventType) - ) { - var eventObject = dragonBones.BaseObject.borrowObject( - dragonBones.EventObject, - ); + if (action.type === 11 /* Sound */ || eventDispatcher.hasDBEventListener(eventType)) { + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); // eventObject.time = this._frameArray[frameOffset] * this._frameRateR; // Precision problem - eventObject.time = - this._frameArray[frameOffset] / this._frameRate; + eventObject.time = this._frameArray[frameOffset] / this._frameRate; eventObject.animationState = this._animationState; - dragonBones.EventObject.actionDataToInstance( - action, - eventObject, - this._armature, - ); + dragonBones.EventObject.actionDataToInstance(action, eventObject, this._armature); this._armature._dragonBones.bufferEvent(eventObject); } } } } }; - ActionTimelineState.prototype._onArriveAtFrame = function() {}; - ActionTimelineState.prototype._onUpdateFrame = function() {}; - ActionTimelineState.prototype.update = function(passedTime) { + ActionTimelineState.prototype._onArriveAtFrame = function () {}; + ActionTimelineState.prototype._onUpdateFrame = function () {}; + ActionTimelineState.prototype.update = function (passedTime) { var prevState = this.playState; var prevPlayTimes = this.currentPlayTimes; var prevTime = this.currentTime; if (this._setCurrentTime(passedTime)) { - var eventActive = - this._animationState._parent === null && - this._animationState.actionEnabled; + var eventActive = this._animationState._parent === null && this._animationState.actionEnabled; var eventDispatcher = this._armature.eventDispatcher; if (prevState < 0) { if (this.playState !== prevState) { - if ( - this._animationState.displayControl && - this._animationState.resetToPose - ) { + if (this._animationState.displayControl && this._animationState.resetToPose) { this._armature._sortZOrder(null, 0); } prevPlayTimes = this.currentPlayTimes; - if ( - eventActive && - eventDispatcher.hasDBEventListener(dragonBones.EventObject.START) - ) { - var eventObject = dragonBones.BaseObject.borrowObject( - dragonBones.EventObject, - ); + if (eventActive && eventDispatcher.hasDBEventListener(dragonBones.EventObject.START)) { + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); eventObject.type = dragonBones.EventObject.START; eventObject.armature = this._armature; eventObject.animationState = this._animationState; @@ -11620,27 +10819,15 @@ if (!Date.now) { var loopCompleteEvent = null; var completeEvent = null; if (eventActive && this.currentPlayTimes !== prevPlayTimes) { - if ( - eventDispatcher.hasDBEventListener( - dragonBones.EventObject.LOOP_COMPLETE, - ) - ) { - loopCompleteEvent = dragonBones.BaseObject.borrowObject( - dragonBones.EventObject, - ); + if (eventDispatcher.hasDBEventListener(dragonBones.EventObject.LOOP_COMPLETE)) { + loopCompleteEvent = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); loopCompleteEvent.type = dragonBones.EventObject.LOOP_COMPLETE; loopCompleteEvent.armature = this._armature; loopCompleteEvent.animationState = this._animationState; } if (this.playState > 0) { - if ( - eventDispatcher.hasDBEventListener( - dragonBones.EventObject.COMPLETE, - ) - ) { - completeEvent = dragonBones.BaseObject.borrowObject( - dragonBones.EventObject, - ); + if (eventDispatcher.hasDBEventListener(dragonBones.EventObject.COMPLETE)) { + completeEvent = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); completeEvent.type = dragonBones.EventObject.COMPLETE; completeEvent.armature = this._armature; completeEvent.animationState = this._animationState; @@ -11649,29 +10836,19 @@ if (!Date.now) { } if (this._frameCount > 1) { var timelineData = this._timelineData; - var timelineFrameIndex = Math.floor( - this.currentTime * this._frameRate, - ); // uint - var frameIndex = this._frameIndices[ - timelineData.frameIndicesOffset + timelineFrameIndex - ]; + var timelineFrameIndex = Math.floor(this.currentTime * this._frameRate); // uint + var frameIndex = this._frameIndices[timelineData.frameIndicesOffset + timelineFrameIndex]; if (this._frameIndex !== frameIndex) { var crossedFrameIndex = this._frameIndex; this._frameIndex = frameIndex; if (this._timelineArray !== null) { this._frameOffset = this._animationData.frameOffset + - this._timelineArray[ - timelineData.offset + - 5 /* TimelineFrameOffset */ + - this._frameIndex - ]; + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + this._frameIndex]; if (isReverse) { if (crossedFrameIndex < 0) { var prevFrameIndex = Math.floor(prevTime * this._frameRate); - crossedFrameIndex = this._frameIndices[ - timelineData.frameIndicesOffset + prevFrameIndex - ]; + crossedFrameIndex = this._frameIndices[timelineData.frameIndicesOffset + prevFrameIndex]; if (this.currentPlayTimes === prevPlayTimes) { if (crossedFrameIndex === frameIndex) { crossedFrameIndex = -1; @@ -11681,18 +10858,10 @@ if (!Date.now) { while (crossedFrameIndex >= 0) { var frameOffset = this._animationData.frameOffset + - this._timelineArray[ - timelineData.offset + - 5 /* TimelineFrameOffset */ + - crossedFrameIndex - ]; + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + crossedFrameIndex]; // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem - var framePosition = - this._frameArray[frameOffset] / this._frameRate; - if ( - this._position <= framePosition && - framePosition <= this._position + this._duration - ) { + var framePosition = this._frameArray[frameOffset] / this._frameRate; + if (this._position <= framePosition && framePosition <= this._position + this._duration) { this._onCrossFrame(crossedFrameIndex); } if (loopCompleteEvent !== null && crossedFrameIndex === 0) { @@ -11711,19 +10880,12 @@ if (!Date.now) { } else { if (crossedFrameIndex < 0) { var prevFrameIndex = Math.floor(prevTime * this._frameRate); - crossedFrameIndex = this._frameIndices[ - timelineData.frameIndicesOffset + prevFrameIndex - ]; + crossedFrameIndex = this._frameIndices[timelineData.frameIndicesOffset + prevFrameIndex]; var frameOffset = this._animationData.frameOffset + - this._timelineArray[ - timelineData.offset + - 5 /* TimelineFrameOffset */ + - crossedFrameIndex - ]; + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + crossedFrameIndex]; // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem - var framePosition = - this._frameArray[frameOffset] / this._frameRate; + var framePosition = this._frameArray[frameOffset] / this._frameRate; if (this.currentPlayTimes === prevPlayTimes) { if (prevTime <= framePosition) { if (crossedFrameIndex > 0) { @@ -11744,14 +10906,9 @@ if (!Date.now) { } var frameOffset = this._animationData.frameOffset + - this._timelineArray[ - timelineData.offset + - 5 /* TimelineFrameOffset */ + - crossedFrameIndex - ]; + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + crossedFrameIndex]; // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem - var framePosition = - this._frameArray[frameOffset] / this._frameRate; + var framePosition = this._frameArray[frameOffset] / this._frameRate; if ( this._position <= framePosition && framePosition <= this._position + this._duration // @@ -11774,12 +10931,9 @@ if (!Date.now) { if (this._timelineData !== null) { this._frameOffset = this._animationData.frameOffset + - this._timelineArray[ - this._timelineData.offset + 5 /* TimelineFrameOffset */ - ]; + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */]; // Arrive at frame. - var framePosition = - this._frameArray[this._frameOffset] / this._frameRate; + var framePosition = this._frameArray[this._frameOffset] / this._frameRate; if (this.currentPlayTimes === prevPlayTimes) { if (prevTime <= framePosition) { this._onCrossFrame(this._frameIndex); @@ -11801,7 +10955,7 @@ if (!Date.now) { } } }; - ActionTimelineState.prototype.setCurrentTime = function(value) { + ActionTimelineState.prototype.setCurrentTime = function (value) { this._setCurrentTime(value); this._frameIndex = -1; }; @@ -11811,15 +10965,15 @@ if (!Date.now) { /** * @internal */ - var ZOrderTimelineState = /** @class */ (function(_super) { + var ZOrderTimelineState = /** @class */ (function (_super) { __extends(ZOrderTimelineState, _super); function ZOrderTimelineState() { return (_super !== null && _super.apply(this, arguments)) || this; } - ZOrderTimelineState.toString = function() { + ZOrderTimelineState.toString = function () { return '[class dragonBones.ZOrderTimelineState]'; }; - ZOrderTimelineState.prototype._onArriveAtFrame = function() { + ZOrderTimelineState.prototype._onArriveAtFrame = function () { if (this.playState >= 0) { var count = this._frameArray[this._frameOffset + 1]; if (count > 0) { @@ -11829,22 +10983,22 @@ if (!Date.now) { } } }; - ZOrderTimelineState.prototype._onUpdateFrame = function() {}; + ZOrderTimelineState.prototype._onUpdateFrame = function () {}; return ZOrderTimelineState; })(dragonBones.TimelineState); dragonBones.ZOrderTimelineState = ZOrderTimelineState; /** * @internal */ - var BoneAllTimelineState = /** @class */ (function(_super) { + var BoneAllTimelineState = /** @class */ (function (_super) { __extends(BoneAllTimelineState, _super); function BoneAllTimelineState() { return (_super !== null && _super.apply(this, arguments)) || this; } - BoneAllTimelineState.toString = function() { + BoneAllTimelineState.toString = function () { return '[class dragonBones.BoneAllTimelineState]'; }; - BoneAllTimelineState.prototype._onArriveAtFrame = function() { + BoneAllTimelineState.prototype._onArriveAtFrame = function () { _super.prototype._onArriveAtFrame.call(this); if (this._isTween && this._frameIndex === this._frameCount - 1) { this._rd[2] = dragonBones.Transform.normalizeRadian(this._rd[2]); @@ -11855,22 +11009,18 @@ if (!Date.now) { this._rd[5] = 1.0; } }; - BoneAllTimelineState.prototype.init = function( - armature, - animationState, - timelineData, - ) { + BoneAllTimelineState.prototype.init = function (armature, animationState, timelineData) { _super.prototype.init.call(this, armature, animationState, timelineData); this._valueOffset = this._animationData.frameFloatOffset; this._valueCount = 6; this._valueArray = this._animationData.parent.parent.frameFloatArray; }; - BoneAllTimelineState.prototype.fadeOut = function() { + BoneAllTimelineState.prototype.fadeOut = function () { this.dirty = false; this._rd[2] = dragonBones.Transform.normalizeRadian(this._rd[2]); this._rd[3] = dragonBones.Transform.normalizeRadian(this._rd[3]); }; - BoneAllTimelineState.prototype.blend = function(isDirty) { + BoneAllTimelineState.prototype.blend = function (isDirty) { var valueScale = this._armature.armatureData.scale; var rd = this._rd; // @@ -11904,25 +11054,21 @@ if (!Date.now) { /** * @internal */ - var BoneTranslateTimelineState = /** @class */ (function(_super) { + var BoneTranslateTimelineState = /** @class */ (function (_super) { __extends(BoneTranslateTimelineState, _super); function BoneTranslateTimelineState() { return (_super !== null && _super.apply(this, arguments)) || this; } - BoneTranslateTimelineState.toString = function() { + BoneTranslateTimelineState.toString = function () { return '[class dragonBones.BoneTranslateTimelineState]'; }; - BoneTranslateTimelineState.prototype.init = function( - armature, - animationState, - timelineData, - ) { + BoneTranslateTimelineState.prototype.init = function (armature, animationState, timelineData) { _super.prototype.init.call(this, armature, animationState, timelineData); this._valueOffset = this._animationData.frameFloatOffset; this._valueScale = this._armature.armatureData.scale; this._valueArray = this._animationData.parent.parent.frameFloatArray; }; - BoneTranslateTimelineState.prototype.blend = function(isDirty) { + BoneTranslateTimelineState.prototype.blend = function (isDirty) { var blendState = this.target; var bone = blendState.target; var blendWeight = blendState.blendWeight; @@ -11948,40 +11094,32 @@ if (!Date.now) { /** * @internal */ - var BoneRotateTimelineState = /** @class */ (function(_super) { + var BoneRotateTimelineState = /** @class */ (function (_super) { __extends(BoneRotateTimelineState, _super); function BoneRotateTimelineState() { return (_super !== null && _super.apply(this, arguments)) || this; } - BoneRotateTimelineState.toString = function() { + BoneRotateTimelineState.toString = function () { return '[class dragonBones.BoneRotateTimelineState]'; }; - BoneRotateTimelineState.prototype._onArriveAtFrame = function() { + BoneRotateTimelineState.prototype._onArriveAtFrame = function () { _super.prototype._onArriveAtFrame.call(this); if (this._isTween && this._frameIndex === this._frameCount - 1) { - this._differenceA = dragonBones.Transform.normalizeRadian( - this._differenceA, - ); - this._differenceB = dragonBones.Transform.normalizeRadian( - this._differenceB, - ); + this._differenceA = dragonBones.Transform.normalizeRadian(this._differenceA); + this._differenceB = dragonBones.Transform.normalizeRadian(this._differenceB); } }; - BoneRotateTimelineState.prototype.init = function( - armature, - animationState, - timelineData, - ) { + BoneRotateTimelineState.prototype.init = function (armature, animationState, timelineData) { _super.prototype.init.call(this, armature, animationState, timelineData); this._valueOffset = this._animationData.frameFloatOffset; this._valueArray = this._animationData.parent.parent.frameFloatArray; }; - BoneRotateTimelineState.prototype.fadeOut = function() { + BoneRotateTimelineState.prototype.fadeOut = function () { this.dirty = false; this._resultA = dragonBones.Transform.normalizeRadian(this._resultA); this._resultB = dragonBones.Transform.normalizeRadian(this._resultB); }; - BoneRotateTimelineState.prototype.blend = function(isDirty) { + BoneRotateTimelineState.prototype.blend = function (isDirty) { var blendState = this.target; var bone = blendState.target; var blendWeight = blendState.blendWeight; @@ -12007,31 +11145,27 @@ if (!Date.now) { /** * @internal */ - var BoneScaleTimelineState = /** @class */ (function(_super) { + var BoneScaleTimelineState = /** @class */ (function (_super) { __extends(BoneScaleTimelineState, _super); function BoneScaleTimelineState() { return (_super !== null && _super.apply(this, arguments)) || this; } - BoneScaleTimelineState.toString = function() { + BoneScaleTimelineState.toString = function () { return '[class dragonBones.BoneScaleTimelineState]'; }; - BoneScaleTimelineState.prototype._onArriveAtFrame = function() { + BoneScaleTimelineState.prototype._onArriveAtFrame = function () { _super.prototype._onArriveAtFrame.call(this); if (this._timelineData === null) { this._resultA = 1.0; this._resultB = 1.0; } }; - BoneScaleTimelineState.prototype.init = function( - armature, - animationState, - timelineData, - ) { + BoneScaleTimelineState.prototype.init = function (armature, animationState, timelineData) { _super.prototype.init.call(this, armature, animationState, timelineData); this._valueOffset = this._animationData.frameFloatOffset; this._valueArray = this._animationData.parent.parent.frameFloatArray; }; - BoneScaleTimelineState.prototype.blend = function(isDirty) { + BoneScaleTimelineState.prototype.blend = function (isDirty) { var blendState = this.target; var bone = blendState.target; var blendWeight = blendState.blendWeight; @@ -12057,43 +11191,34 @@ if (!Date.now) { /** * @internal */ - var SurfaceTimelineState = /** @class */ (function(_super) { + var SurfaceTimelineState = /** @class */ (function (_super) { __extends(SurfaceTimelineState, _super); function SurfaceTimelineState() { return (_super !== null && _super.apply(this, arguments)) || this; } - SurfaceTimelineState.toString = function() { + SurfaceTimelineState.toString = function () { return '[class dragonBones.SurfaceTimelineState]'; }; - SurfaceTimelineState.prototype._onClear = function() { + SurfaceTimelineState.prototype._onClear = function () { _super.prototype._onClear.call(this); this._deformCount = 0; this._deformOffset = 0; this._sameValueOffset = 0; }; - SurfaceTimelineState.prototype.init = function( - armature, - animationState, - timelineData, - ) { + SurfaceTimelineState.prototype.init = function (armature, animationState, timelineData) { _super.prototype.init.call(this, armature, animationState, timelineData); if (this._timelineData !== null) { var dragonBonesData = this._animationData.parent.parent; var frameIntArray = dragonBonesData.frameIntArray; var frameIntOffset = this._animationData.frameIntOffset + - this._timelineArray[ - this._timelineData.offset + 3 /* TimelineFrameValueCount */ - ]; + this._timelineArray[this._timelineData.offset + 3 /* TimelineFrameValueCount */]; this._valueOffset = this._animationData.frameFloatOffset; - this._valueCount = - frameIntArray[frameIntOffset + 2 /* DeformValueCount */]; + this._valueCount = frameIntArray[frameIntOffset + 2 /* DeformValueCount */]; this._deformCount = frameIntArray[frameIntOffset + 1 /* DeformCount */]; - this._deformOffset = - frameIntArray[frameIntOffset + 3 /* DeformValueOffset */]; + this._deformOffset = frameIntArray[frameIntOffset + 3 /* DeformValueOffset */]; this._sameValueOffset = - frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] + - this._animationData.frameFloatOffset; + frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] + this._animationData.frameFloatOffset; this._valueScale = this._armature.armatureData.scale; this._valueArray = dragonBonesData.frameFloatArray; this._rd.length = this._valueCount * 2; @@ -12101,7 +11226,7 @@ if (!Date.now) { this._deformCount = this.target.target._deformVertices.length; } }; - SurfaceTimelineState.prototype.blend = function(isDirty) { + SurfaceTimelineState.prototype.blend = function (isDirty) { var blendState = this.target; var surface = blendState.target; var blendWeight = blendState.blendWeight; @@ -12143,31 +11268,27 @@ if (!Date.now) { /** * @internal */ - var AlphaTimelineState = /** @class */ (function(_super) { + var AlphaTimelineState = /** @class */ (function (_super) { __extends(AlphaTimelineState, _super); function AlphaTimelineState() { return (_super !== null && _super.apply(this, arguments)) || this; } - AlphaTimelineState.toString = function() { + AlphaTimelineState.toString = function () { return '[class dragonBones.AlphaTimelineState]'; }; - AlphaTimelineState.prototype._onArriveAtFrame = function() { + AlphaTimelineState.prototype._onArriveAtFrame = function () { _super.prototype._onArriveAtFrame.call(this); if (this._timelineData === null) { this._result = 1.0; } }; - AlphaTimelineState.prototype.init = function( - armature, - animationState, - timelineData, - ) { + AlphaTimelineState.prototype.init = function (armature, animationState, timelineData) { _super.prototype.init.call(this, armature, animationState, timelineData); this._valueOffset = this._animationData.frameIntOffset; this._valueScale = 0.01; this._valueArray = this._animationData.parent.parent.frameIntArray; }; - AlphaTimelineState.prototype.blend = function(isDirty) { + AlphaTimelineState.prototype.blend = function (isDirty) { var blendState = this.target; var alphaTarget = blendState.target; var blendWeight = blendState.blendWeight; @@ -12190,34 +11311,32 @@ if (!Date.now) { /** * @internal */ - var SlotDislayTimelineState = /** @class */ (function(_super) { + var SlotDislayTimelineState = /** @class */ (function (_super) { __extends(SlotDislayTimelineState, _super); function SlotDislayTimelineState() { return (_super !== null && _super.apply(this, arguments)) || this; } - SlotDislayTimelineState.toString = function() { + SlotDislayTimelineState.toString = function () { return '[class dragonBones.SlotDislayTimelineState]'; }; - SlotDislayTimelineState.prototype._onArriveAtFrame = function() { + SlotDislayTimelineState.prototype._onArriveAtFrame = function () { if (this.playState >= 0) { var slot = this.target; var displayIndex = - this._timelineData !== null - ? this._frameArray[this._frameOffset + 1] - : slot._slotData.displayIndex; + this._timelineData !== null ? this._frameArray[this._frameOffset + 1] : slot._slotData.displayIndex; if (slot.displayIndex !== displayIndex) { slot._setDisplayIndex(displayIndex, true); } } }; - SlotDislayTimelineState.prototype._onUpdateFrame = function() {}; + SlotDislayTimelineState.prototype._onUpdateFrame = function () {}; return SlotDislayTimelineState; })(dragonBones.TimelineState); dragonBones.SlotDislayTimelineState = SlotDislayTimelineState; /** * @internal */ - var SlotColorTimelineState = /** @class */ (function(_super) { + var SlotColorTimelineState = /** @class */ (function (_super) { __extends(SlotColorTimelineState, _super); function SlotColorTimelineState() { var _this = (_super !== null && _super.apply(this, arguments)) || this; @@ -12226,19 +11345,16 @@ if (!Date.now) { _this._result = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]; return _this; } - SlotColorTimelineState.toString = function() { + SlotColorTimelineState.toString = function () { return '[class dragonBones.SlotColorTimelineState]'; }; - SlotColorTimelineState.prototype._onArriveAtFrame = function() { + SlotColorTimelineState.prototype._onArriveAtFrame = function () { _super.prototype._onArriveAtFrame.call(this); if (this._timelineData !== null) { var dragonBonesData = this._animationData.parent.parent; var colorArray = dragonBonesData.colorArray; var frameIntArray = dragonBonesData.frameIntArray; - var valueOffset = - this._animationData.frameIntOffset + - this._frameValueOffset + - this._frameIndex; + var valueOffset = this._animationData.frameIntOffset + this._frameValueOffset + this._frameIndex; var colorOffset = frameIntArray[valueOffset]; if (colorOffset < 0) { colorOffset += 65536; // Fixed out of bounds bug. @@ -12253,10 +11369,7 @@ if (!Date.now) { this._current[6] = colorArray[colorOffset++]; this._current[7] = colorArray[colorOffset++]; if (this._frameIndex === this._frameCount - 1) { - colorOffset = - frameIntArray[ - this._animationData.frameIntOffset + this._frameValueOffset - ]; + colorOffset = frameIntArray[this._animationData.frameIntOffset + this._frameValueOffset]; } else { colorOffset = frameIntArray[valueOffset + 1]; } @@ -12294,40 +11407,29 @@ if (!Date.now) { this._result[7] = color.blueOffset; } }; - SlotColorTimelineState.prototype._onUpdateFrame = function() { + SlotColorTimelineState.prototype._onUpdateFrame = function () { _super.prototype._onUpdateFrame.call(this); if (this._isTween) { - this._result[0] = - (this._current[0] + this._difference[0] * this._tweenProgress) * 0.01; - this._result[1] = - (this._current[1] + this._difference[1] * this._tweenProgress) * 0.01; - this._result[2] = - (this._current[2] + this._difference[2] * this._tweenProgress) * 0.01; - this._result[3] = - (this._current[3] + this._difference[3] * this._tweenProgress) * 0.01; - this._result[4] = - this._current[4] + this._difference[4] * this._tweenProgress; - this._result[5] = - this._current[5] + this._difference[5] * this._tweenProgress; - this._result[6] = - this._current[6] + this._difference[6] * this._tweenProgress; - this._result[7] = - this._current[7] + this._difference[7] * this._tweenProgress; - } - }; - SlotColorTimelineState.prototype.fadeOut = function() { + this._result[0] = (this._current[0] + this._difference[0] * this._tweenProgress) * 0.01; + this._result[1] = (this._current[1] + this._difference[1] * this._tweenProgress) * 0.01; + this._result[2] = (this._current[2] + this._difference[2] * this._tweenProgress) * 0.01; + this._result[3] = (this._current[3] + this._difference[3] * this._tweenProgress) * 0.01; + this._result[4] = this._current[4] + this._difference[4] * this._tweenProgress; + this._result[5] = this._current[5] + this._difference[5] * this._tweenProgress; + this._result[6] = this._current[6] + this._difference[6] * this._tweenProgress; + this._result[7] = this._current[7] + this._difference[7] * this._tweenProgress; + } + }; + SlotColorTimelineState.prototype.fadeOut = function () { this._isTween = false; }; - SlotColorTimelineState.prototype.update = function(passedTime) { + SlotColorTimelineState.prototype.update = function (passedTime) { _super.prototype.update.call(this, passedTime); // Fade animation. if (this._isTween || this.dirty) { var slot = this.target; var result = slot._colorTransform; - if ( - this._animationState._fadeState !== 0 || - this._animationState._subFadeState !== 0 - ) { + if (this._animationState._fadeState !== 0 || this._animationState._subFadeState !== 0) { if ( result.alphaMultiplier !== this._result[0] || result.redMultiplier !== this._result[1] || @@ -12339,22 +11441,14 @@ if (!Date.now) { result.blueOffset !== this._result[7] ) { var fadeProgress = Math.pow(this._animationState._fadeProgress, 4); - result.alphaMultiplier += - (this._result[0] - result.alphaMultiplier) * fadeProgress; - result.redMultiplier += - (this._result[1] - result.redMultiplier) * fadeProgress; - result.greenMultiplier += - (this._result[2] - result.greenMultiplier) * fadeProgress; - result.blueMultiplier += - (this._result[3] - result.blueMultiplier) * fadeProgress; - result.alphaOffset += - (this._result[4] - result.alphaOffset) * fadeProgress; - result.redOffset += - (this._result[5] - result.redOffset) * fadeProgress; - result.greenOffset += - (this._result[6] - result.greenOffset) * fadeProgress; - result.blueOffset += - (this._result[7] - result.blueOffset) * fadeProgress; + result.alphaMultiplier += (this._result[0] - result.alphaMultiplier) * fadeProgress; + result.redMultiplier += (this._result[1] - result.redMultiplier) * fadeProgress; + result.greenMultiplier += (this._result[2] - result.greenMultiplier) * fadeProgress; + result.blueMultiplier += (this._result[3] - result.blueMultiplier) * fadeProgress; + result.alphaOffset += (this._result[4] - result.alphaOffset) * fadeProgress; + result.redOffset += (this._result[5] - result.redOffset) * fadeProgress; + result.greenOffset += (this._result[6] - result.greenOffset) * fadeProgress; + result.blueOffset += (this._result[7] - result.blueOffset) * fadeProgress; slot._colorDirty = true; } } else if (this.dirty) { @@ -12388,15 +11482,15 @@ if (!Date.now) { /** * @internal */ - var SlotZIndexTimelineState = /** @class */ (function(_super) { + var SlotZIndexTimelineState = /** @class */ (function (_super) { __extends(SlotZIndexTimelineState, _super); function SlotZIndexTimelineState() { return (_super !== null && _super.apply(this, arguments)) || this; } - SlotZIndexTimelineState.toString = function() { + SlotZIndexTimelineState.toString = function () { return '[class dragonBones.SlotZIndexTimelineState]'; }; - SlotZIndexTimelineState.prototype._onArriveAtFrame = function() { + SlotZIndexTimelineState.prototype._onArriveAtFrame = function () { _super.prototype._onArriveAtFrame.call(this); if (this._timelineData === null) { var blendState = this.target; @@ -12404,16 +11498,12 @@ if (!Date.now) { this._result = slot.slotData.zIndex; } }; - SlotZIndexTimelineState.prototype.init = function( - armature, - animationState, - timelineData, - ) { + SlotZIndexTimelineState.prototype.init = function (armature, animationState, timelineData) { _super.prototype.init.call(this, armature, animationState, timelineData); this._valueOffset = this._animationData.frameIntOffset; this._valueArray = this._animationData.parent.parent.frameIntArray; }; - SlotZIndexTimelineState.prototype.blend = function(isDirty) { + SlotZIndexTimelineState.prototype.blend = function (isDirty) { var blendState = this.target; var slot = blendState.target; var blendWeight = blendState.blendWeight; @@ -12433,15 +11523,15 @@ if (!Date.now) { /** * @internal */ - var DeformTimelineState = /** @class */ (function(_super) { + var DeformTimelineState = /** @class */ (function (_super) { __extends(DeformTimelineState, _super); function DeformTimelineState() { return (_super !== null && _super.apply(this, arguments)) || this; } - DeformTimelineState.toString = function() { + DeformTimelineState.toString = function () { return '[class dragonBones.DeformTimelineState]'; }; - DeformTimelineState.prototype._onClear = function() { + DeformTimelineState.prototype._onClear = function () { _super.prototype._onClear.call(this); this.geometryOffset = 0; this.displayFrame = null; @@ -12449,23 +11539,16 @@ if (!Date.now) { this._deformOffset = 0; this._sameValueOffset = 0; }; - DeformTimelineState.prototype.init = function( - armature, - animationState, - timelineData, - ) { + DeformTimelineState.prototype.init = function (armature, animationState, timelineData) { _super.prototype.init.call(this, armature, animationState, timelineData); if (this._timelineData !== null) { var frameIntOffset = this._animationData.frameIntOffset + - this._timelineArray[ - this._timelineData.offset + 3 /* TimelineFrameValueCount */ - ]; + this._timelineArray[this._timelineData.offset + 3 /* TimelineFrameValueCount */]; var dragonBonesData = this._animationData.parent.parent; var frameIntArray = dragonBonesData.frameIntArray; var slot = this.target.target; - this.geometryOffset = - frameIntArray[frameIntOffset + 0 /* DeformVertexOffset */]; + this.geometryOffset = frameIntArray[frameIntOffset + 0 /* DeformVertexOffset */]; if (this.geometryOffset < 0) { this.geometryOffset += 65536; // Fixed out of bounds bug. } @@ -12486,14 +11569,11 @@ if (!Date.now) { return; } this._valueOffset = this._animationData.frameFloatOffset; - this._valueCount = - frameIntArray[frameIntOffset + 2 /* DeformValueCount */]; + this._valueCount = frameIntArray[frameIntOffset + 2 /* DeformValueCount */]; this._deformCount = frameIntArray[frameIntOffset + 1 /* DeformCount */]; - this._deformOffset = - frameIntArray[frameIntOffset + 3 /* DeformValueOffset */]; + this._deformOffset = frameIntArray[frameIntOffset + 3 /* DeformValueOffset */]; this._sameValueOffset = - frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] + - this._animationData.frameFloatOffset; + frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] + this._animationData.frameFloatOffset; this._valueScale = this._armature.armatureData.scale; this._valueArray = dragonBonesData.frameFloatArray; this._rd.length = this._valueCount * 2; @@ -12501,7 +11581,7 @@ if (!Date.now) { this._deformCount = this.displayFrame.deformVertices.length; } }; - DeformTimelineState.prototype.blend = function(isDirty) { + DeformTimelineState.prototype.blend = function (isDirty) { var blendState = this.target; var slot = blendState.target; var blendWeight = blendState.blendWeight; @@ -12545,15 +11625,15 @@ if (!Date.now) { /** * @internal */ - var IKConstraintTimelineState = /** @class */ (function(_super) { + var IKConstraintTimelineState = /** @class */ (function (_super) { __extends(IKConstraintTimelineState, _super); function IKConstraintTimelineState() { return (_super !== null && _super.apply(this, arguments)) || this; } - IKConstraintTimelineState.toString = function() { + IKConstraintTimelineState.toString = function () { return '[class dragonBones.IKConstraintTimelineState]'; }; - IKConstraintTimelineState.prototype._onUpdateFrame = function() { + IKConstraintTimelineState.prototype._onUpdateFrame = function () { _super.prototype._onUpdateFrame.call(this); var ikConstraint = this.target; if (this._timelineData !== null) { @@ -12567,11 +11647,7 @@ if (!Date.now) { ikConstraint.invalidUpdate(); this.dirty = false; }; - IKConstraintTimelineState.prototype.init = function( - armature, - animationState, - timelineData, - ) { + IKConstraintTimelineState.prototype.init = function (armature, animationState, timelineData) { _super.prototype.init.call(this, armature, animationState, timelineData); this._valueOffset = this._animationData.frameIntOffset; this._valueScale = 0.01; @@ -12583,15 +11659,15 @@ if (!Date.now) { /** * @internal */ - var AnimationProgressTimelineState = /** @class */ (function(_super) { + var AnimationProgressTimelineState = /** @class */ (function (_super) { __extends(AnimationProgressTimelineState, _super); function AnimationProgressTimelineState() { return (_super !== null && _super.apply(this, arguments)) || this; } - AnimationProgressTimelineState.toString = function() { + AnimationProgressTimelineState.toString = function () { return '[class dragonBones.AnimationProgressTimelineState]'; }; - AnimationProgressTimelineState.prototype._onUpdateFrame = function() { + AnimationProgressTimelineState.prototype._onUpdateFrame = function () { _super.prototype._onUpdateFrame.call(this); var animationState = this.target; if (animationState._parent !== null) { @@ -12599,11 +11675,7 @@ if (!Date.now) { } this.dirty = false; }; - AnimationProgressTimelineState.prototype.init = function( - armature, - animationState, - timelineData, - ) { + AnimationProgressTimelineState.prototype.init = function (armature, animationState, timelineData) { _super.prototype.init.call(this, armature, animationState, timelineData); this._valueOffset = this._animationData.frameIntOffset; this._valueScale = 0.0001; @@ -12615,15 +11687,15 @@ if (!Date.now) { /** * @internal */ - var AnimationWeightTimelineState = /** @class */ (function(_super) { + var AnimationWeightTimelineState = /** @class */ (function (_super) { __extends(AnimationWeightTimelineState, _super); function AnimationWeightTimelineState() { return (_super !== null && _super.apply(this, arguments)) || this; } - AnimationWeightTimelineState.toString = function() { + AnimationWeightTimelineState.toString = function () { return '[class dragonBones.AnimationWeightTimelineState]'; }; - AnimationWeightTimelineState.prototype._onUpdateFrame = function() { + AnimationWeightTimelineState.prototype._onUpdateFrame = function () { _super.prototype._onUpdateFrame.call(this); var animationState = this.target; if (animationState._parent !== null) { @@ -12631,11 +11703,7 @@ if (!Date.now) { } this.dirty = false; }; - AnimationWeightTimelineState.prototype.init = function( - armature, - animationState, - timelineData, - ) { + AnimationWeightTimelineState.prototype.init = function (armature, animationState, timelineData) { _super.prototype.init.call(this, armature, animationState, timelineData); this._valueOffset = this._animationData.frameIntOffset; this._valueScale = 0.0001; @@ -12647,15 +11715,15 @@ if (!Date.now) { /** * @internal */ - var AnimationParametersTimelineState = /** @class */ (function(_super) { + var AnimationParametersTimelineState = /** @class */ (function (_super) { __extends(AnimationParametersTimelineState, _super); function AnimationParametersTimelineState() { return (_super !== null && _super.apply(this, arguments)) || this; } - AnimationParametersTimelineState.toString = function() { + AnimationParametersTimelineState.toString = function () { return '[class dragonBones.AnimationParametersTimelineState]'; }; - AnimationParametersTimelineState.prototype._onUpdateFrame = function() { + AnimationParametersTimelineState.prototype._onUpdateFrame = function () { _super.prototype._onUpdateFrame.call(this); var animationState = this.target; if (animationState._parent !== null) { @@ -12664,11 +11732,7 @@ if (!Date.now) { } this.dirty = false; }; - AnimationParametersTimelineState.prototype.init = function( - armature, - animationState, - timelineData, - ) { + AnimationParametersTimelineState.prototype.init = function (armature, animationState, timelineData) { _super.prototype.init.call(this, armature, animationState, timelineData); this._valueOffset = this._animationData.frameIntOffset; this._valueScale = 0.0001; @@ -12701,7 +11765,7 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * - The properties of the object carry basic information about an event, * which are passed as parameter or parameter's parameter to event listeners when an event occurs. @@ -12713,7 +11777,7 @@ if (!Date.now) { * @version DragonBones 4.5 * @language zh_CN */ - var EventObject = /** @class */ (function(_super) { + var EventObject = /** @class */ (function (_super) { __extends(EventObject, _super); function EventObject() { return (_super !== null && _super.apply(this, arguments)) || this; @@ -12722,14 +11786,11 @@ if (!Date.now) { * @internal * @private */ - EventObject.actionDataToInstance = function(data, instance, armature) { + EventObject.actionDataToInstance = function (data, instance, armature) { if (data.type === 0 /* Play */) { instance.type = EventObject.FRAME_EVENT; } else { - instance.type = - data.type === 10 /* Frame */ - ? EventObject.FRAME_EVENT - : EventObject.SOUND_EVENT; + instance.type = data.type === 10 /* Frame */ ? EventObject.FRAME_EVENT : EventObject.SOUND_EVENT; } instance.name = data.name; instance.armature = armature; @@ -12742,10 +11803,10 @@ if (!Date.now) { instance.slot = armature.getSlot(data.slot.name); } }; - EventObject.toString = function() { + EventObject.toString = function () { return '[class dragonBones.EventObject]'; }; - EventObject.prototype._onClear = function() { + EventObject.prototype._onClear = function () { this.time = 0.0; this.type = ''; this.name = ''; @@ -12882,13 +11943,13 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * @private */ - var DataParser = /** @class */ (function() { + var DataParser = /** @class */ (function () { function DataParser() {} - DataParser._getArmatureType = function(value) { + DataParser._getArmatureType = function (value) { switch (value.toLowerCase()) { case 'stage': return 2 /* Stage */; @@ -12900,7 +11961,7 @@ if (!Date.now) { return 0 /* Armature */; } }; - DataParser._getBoneType = function(value) { + DataParser._getBoneType = function (value) { switch (value.toLowerCase()) { case 'bone': return 0 /* Bone */; @@ -12910,7 +11971,7 @@ if (!Date.now) { return 0 /* Bone */; } }; - DataParser._getPositionMode = function(value) { + DataParser._getPositionMode = function (value) { switch (value.toLocaleLowerCase()) { case 'percent': return 1 /* Percent */; @@ -12920,7 +11981,7 @@ if (!Date.now) { return 1 /* Percent */; } }; - DataParser._getSpacingMode = function(value) { + DataParser._getSpacingMode = function (value) { switch (value.toLocaleLowerCase()) { case 'length': return 0 /* Length */; @@ -12932,7 +11993,7 @@ if (!Date.now) { return 0 /* Length */; } }; - DataParser._getRotateMode = function(value) { + DataParser._getRotateMode = function (value) { switch (value.toLocaleLowerCase()) { case 'tangent': return 0 /* Tangent */; @@ -12944,7 +12005,7 @@ if (!Date.now) { return 0 /* Tangent */; } }; - DataParser._getDisplayType = function(value) { + DataParser._getDisplayType = function (value) { switch (value.toLowerCase()) { case 'image': return 0 /* Image */; @@ -12960,7 +12021,7 @@ if (!Date.now) { return 0 /* Image */; } }; - DataParser._getBoundingBoxType = function(value) { + DataParser._getBoundingBoxType = function (value) { switch (value.toLowerCase()) { case 'rectangle': return 0 /* Rectangle */; @@ -12972,7 +12033,7 @@ if (!Date.now) { return 0 /* Rectangle */; } }; - DataParser._getBlendMode = function(value) { + DataParser._getBlendMode = function (value) { switch (value.toLowerCase()) { case 'normal': return 0 /* Normal */; @@ -13006,7 +12067,7 @@ if (!Date.now) { return 0 /* Normal */; } }; - DataParser._getAnimationBlendType = function(value) { + DataParser._getAnimationBlendType = function (value) { switch (value.toLowerCase()) { case 'none': return 0 /* None */; @@ -13016,7 +12077,7 @@ if (!Date.now) { return 0 /* None */; } }; - DataParser._getActionType = function(value) { + DataParser._getActionType = function (value) { switch (value.toLowerCase()) { case 'play': return 0 /* Play */; @@ -13193,11 +12254,11 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * @private */ - var ObjectDataParser = /** @class */ (function(_super) { + var ObjectDataParser = /** @class */ (function (_super) { __extends(ObjectDataParser, _super); function ObjectDataParser() { var _this = (_super !== null && _super.apply(this, arguments)) || this; @@ -13241,7 +12302,7 @@ if (!Date.now) { _this._slotChildActions = {}; return _this; } - ObjectDataParser._getBoolean = function(rawData, key, defaultValue) { + ObjectDataParser._getBoolean = function (rawData, key, defaultValue) { if (key in rawData) { var value = rawData[key]; var type = typeof value; @@ -13265,7 +12326,7 @@ if (!Date.now) { } return defaultValue; }; - ObjectDataParser._getNumber = function(rawData, key, defaultValue) { + ObjectDataParser._getNumber = function (rawData, key, defaultValue) { if (key in rawData) { var value = rawData[key]; if (value === null || value === 'NaN') { @@ -13275,7 +12336,7 @@ if (!Date.now) { } return defaultValue; }; - ObjectDataParser._getString = function(rawData, key, defaultValue) { + ObjectDataParser._getString = function (rawData, key, defaultValue) { if (key in rawData) { var value = rawData[key]; var type = typeof value; @@ -13286,18 +12347,7 @@ if (!Date.now) { } return defaultValue; }; - ObjectDataParser.prototype._getCurvePoint = function( - x1, - y1, - x2, - y2, - x3, - y3, - x4, - y4, - t, - result, - ) { + ObjectDataParser.prototype._getCurvePoint = function (x1, y1, x2, y2, x3, y3, x4, y4, t, result) { var l_t = 1.0 - t; var powA = l_t * l_t; var powB = t * t; @@ -13308,7 +12358,7 @@ if (!Date.now) { result.x = kA * x1 + kB * x2 + kC * x3 + kD * x4; result.y = kA * y1 + kB * y2 + kC * y3 + kD * y4; }; - ObjectDataParser.prototype._samplingEasingCurve = function(curve, samples) { + ObjectDataParser.prototype._samplingEasingCurve = function (curve, samples) { var curveCount = curve.length; if (curveCount % 3 === 1) { var stepIndex = -2; @@ -13330,18 +12380,7 @@ if (!Date.now) { var higher = 1.0; while (higher - lower > 0.0001) { var percentage = (higher + lower) * 0.5; - this._getCurvePoint( - x1, - y1, - x2, - y2, - x3, - y3, - x4, - y4, - percentage, - this._helpPoint, - ); + this._getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, percentage, this._helpPoint); if (t - this._helpPoint.x > 0.0) { lower = percentage; } else { @@ -13370,18 +12409,7 @@ if (!Date.now) { var higher = 1.0; while (higher - lower > 0.0001) { var percentage = (higher + lower) * 0.5; - this._getCurvePoint( - x1, - y1, - x2, - y2, - x3, - y3, - x4, - y4, - percentage, - this._helpPoint, - ); + this._getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, percentage, this._helpPoint); if (t - this._helpPoint.x > 0.0) { lower = percentage; } else { @@ -13393,65 +12421,24 @@ if (!Date.now) { return false; } }; - ObjectDataParser.prototype._parseActionDataInFrame = function( - rawData, - frameStart, - bone, - slot, - ) { + ObjectDataParser.prototype._parseActionDataInFrame = function (rawData, frameStart, bone, slot) { if (dragonBones.DataParser.EVENT in rawData) { - this._mergeActionFrame( - rawData[dragonBones.DataParser.EVENT], - frameStart, - 10 /* Frame */, - bone, - slot, - ); + this._mergeActionFrame(rawData[dragonBones.DataParser.EVENT], frameStart, 10 /* Frame */, bone, slot); } if (dragonBones.DataParser.SOUND in rawData) { - this._mergeActionFrame( - rawData[dragonBones.DataParser.SOUND], - frameStart, - 11 /* Sound */, - bone, - slot, - ); + this._mergeActionFrame(rawData[dragonBones.DataParser.SOUND], frameStart, 11 /* Sound */, bone, slot); } if (dragonBones.DataParser.ACTION in rawData) { - this._mergeActionFrame( - rawData[dragonBones.DataParser.ACTION], - frameStart, - 0 /* Play */, - bone, - slot, - ); + this._mergeActionFrame(rawData[dragonBones.DataParser.ACTION], frameStart, 0 /* Play */, bone, slot); } if (dragonBones.DataParser.EVENTS in rawData) { - this._mergeActionFrame( - rawData[dragonBones.DataParser.EVENTS], - frameStart, - 10 /* Frame */, - bone, - slot, - ); + this._mergeActionFrame(rawData[dragonBones.DataParser.EVENTS], frameStart, 10 /* Frame */, bone, slot); } if (dragonBones.DataParser.ACTIONS in rawData) { - this._mergeActionFrame( - rawData[dragonBones.DataParser.ACTIONS], - frameStart, - 0 /* Play */, - bone, - slot, - ); + this._mergeActionFrame(rawData[dragonBones.DataParser.ACTIONS], frameStart, 0 /* Play */, bone, slot); } }; - ObjectDataParser.prototype._mergeActionFrame = function( - rawData, - frameStart, - type, - bone, - slot, - ) { + ObjectDataParser.prototype._mergeActionFrame = function (rawData, frameStart, type, bone, slot) { var actionOffset = this._armature.actions.length; var actions = this._parseActionData(rawData, type, bone, slot); var frameIndex = 0; @@ -13485,34 +12472,19 @@ if (!Date.now) { frame.actions.push(actionOffset + i); } }; - ObjectDataParser.prototype._parseArmature = function(rawData, scale) { - var armature = dragonBones.BaseObject.borrowObject( - dragonBones.ArmatureData, - ); - armature.name = ObjectDataParser._getString( - rawData, - dragonBones.DataParser.NAME, - '', - ); + ObjectDataParser.prototype._parseArmature = function (rawData, scale) { + var armature = dragonBones.BaseObject.borrowObject(dragonBones.ArmatureData); + armature.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ''); armature.frameRate = ObjectDataParser._getNumber( rawData, dragonBones.DataParser.FRAME_RATE, this._data.frameRate, ); armature.scale = scale; - if ( - dragonBones.DataParser.TYPE in rawData && - typeof rawData[dragonBones.DataParser.TYPE] === 'string' - ) { - armature.type = dragonBones.DataParser._getArmatureType( - rawData[dragonBones.DataParser.TYPE], - ); + if (dragonBones.DataParser.TYPE in rawData && typeof rawData[dragonBones.DataParser.TYPE] === 'string') { + armature.type = dragonBones.DataParser._getArmatureType(rawData[dragonBones.DataParser.TYPE]); } else { - armature.type = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.TYPE, - 0 /* Armature */, - ); + armature.type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, 0 /* Armature */); } if (armature.frameRate === 0) { armature.frameRate = 24; @@ -13520,69 +12492,32 @@ if (!Date.now) { this._armature = armature; if (dragonBones.DataParser.CANVAS in rawData) { var rawCanvas = rawData[dragonBones.DataParser.CANVAS]; - var canvas = dragonBones.BaseObject.borrowObject( - dragonBones.CanvasData, - ); + var canvas = dragonBones.BaseObject.borrowObject(dragonBones.CanvasData); if (dragonBones.DataParser.COLOR in rawCanvas) { canvas.hasBackground = true; } else { canvas.hasBackground = false; } - canvas.color = ObjectDataParser._getNumber( - rawCanvas, - dragonBones.DataParser.COLOR, - 0, - ); - canvas.x = - ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.X, 0) * - armature.scale; - canvas.y = - ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.Y, 0) * - armature.scale; - canvas.width = - ObjectDataParser._getNumber( - rawCanvas, - dragonBones.DataParser.WIDTH, - 0, - ) * armature.scale; - canvas.height = - ObjectDataParser._getNumber( - rawCanvas, - dragonBones.DataParser.HEIGHT, - 0, - ) * armature.scale; + canvas.color = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.COLOR, 0); + canvas.x = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.X, 0) * armature.scale; + canvas.y = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.Y, 0) * armature.scale; + canvas.width = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.WIDTH, 0) * armature.scale; + canvas.height = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.HEIGHT, 0) * armature.scale; armature.canvas = canvas; } if (dragonBones.DataParser.AABB in rawData) { var rawAABB = rawData[dragonBones.DataParser.AABB]; - armature.aabb.x = - ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.X, 0.0) * - armature.scale; - armature.aabb.y = - ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.Y, 0.0) * - armature.scale; - armature.aabb.width = - ObjectDataParser._getNumber( - rawAABB, - dragonBones.DataParser.WIDTH, - 0.0, - ) * armature.scale; + armature.aabb.x = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.X, 0.0) * armature.scale; + armature.aabb.y = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.Y, 0.0) * armature.scale; + armature.aabb.width = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.WIDTH, 0.0) * armature.scale; armature.aabb.height = - ObjectDataParser._getNumber( - rawAABB, - dragonBones.DataParser.HEIGHT, - 0.0, - ) * armature.scale; + ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.HEIGHT, 0.0) * armature.scale; } if (dragonBones.DataParser.BONE in rawData) { var rawBones = rawData[dragonBones.DataParser.BONE]; for (var _i = 0, rawBones_1 = rawBones; _i < rawBones_1.length; _i++) { var rawBone = rawBones_1[_i]; - var parentName = ObjectDataParser._getString( - rawBone, - dragonBones.DataParser.PARENT, - '', - ); + var parentName = ObjectDataParser._getString(rawBone, dragonBones.DataParser.PARENT, ''); var bone = this._parseBone(rawBone); if (parentName.length > 0) { var parent_1 = armature.getBone(parentName); @@ -13596,11 +12531,7 @@ if (!Date.now) { } } if (bone.name in this._cacheBones) { - for ( - var _a = 0, _b = this._cacheBones[bone.name]; - _a < _b.length; - _a++ - ) { + for (var _a = 0, _b = this._cacheBones[bone.name]; _a < _b.length; _a++) { var child = _b[_a]; child.parent = bone; } @@ -13648,11 +12579,7 @@ if (!Date.now) { } for (var i = 0, l = this._cacheRawMeshes.length; i < l; ++i) { var rawData_1 = this._cacheRawMeshes[i]; - var shareName = ObjectDataParser._getString( - rawData_1, - dragonBones.DataParser.SHARE, - '', - ); + var shareName = ObjectDataParser._getString(rawData_1, dragonBones.DataParser.SHARE, ''); if (shareName.length === 0) { continue; } @@ -13673,23 +12600,14 @@ if (!Date.now) { } if (dragonBones.DataParser.ANIMATION in rawData) { var rawAnimations = rawData[dragonBones.DataParser.ANIMATION]; - for ( - var _g = 0, rawAnimations_1 = rawAnimations; - _g < rawAnimations_1.length; - _g++ - ) { + for (var _g = 0, rawAnimations_1 = rawAnimations; _g < rawAnimations_1.length; _g++) { var rawAnimation = rawAnimations_1[_g]; var animation = this._parseAnimation(rawAnimation); armature.addAnimation(animation); } } if (dragonBones.DataParser.DEFAULT_ACTIONS in rawData) { - var actions = this._parseActionData( - rawData[dragonBones.DataParser.DEFAULT_ACTIONS], - 0 /* Play */, - null, - null, - ); + var actions = this._parseActionData(rawData[dragonBones.DataParser.DEFAULT_ACTIONS], 0 /* Play */, null, null); for (var _h = 0, actions_3 = actions; _h < actions_3.length; _h++) { var action = actions_3[_h]; armature.addAction(action, true); @@ -13702,12 +12620,7 @@ if (!Date.now) { } } if (dragonBones.DataParser.ACTIONS in rawData) { - var actions = this._parseActionData( - rawData[dragonBones.DataParser.ACTIONS], - 0 /* Play */, - null, - null, - ); + var actions = this._parseActionData(rawData[dragonBones.DataParser.ACTIONS], 0 /* Play */, null, null); for (var _j = 0, actions_4 = actions; _j < actions_4.length; _j++) { var action = actions_4[_j]; armature.addAction(action, false); @@ -13732,21 +12645,12 @@ if (!Date.now) { } return armature; }; - ObjectDataParser.prototype._parseBone = function(rawData) { + ObjectDataParser.prototype._parseBone = function (rawData) { var type = 0; /* Bone */ - if ( - dragonBones.DataParser.TYPE in rawData && - typeof rawData[dragonBones.DataParser.TYPE] === 'string' - ) { - type = dragonBones.DataParser._getBoneType( - rawData[dragonBones.DataParser.TYPE], - ); + if (dragonBones.DataParser.TYPE in rawData && typeof rawData[dragonBones.DataParser.TYPE] === 'string') { + type = dragonBones.DataParser._getBoneType(rawData[dragonBones.DataParser.TYPE]); } else { - type = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.TYPE, - 0 /* Bone */, - ); + type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, 0 /* Bone */); } if (type === 0 /* Bone */) { var scale = this._armature.scale; @@ -13756,113 +12660,40 @@ if (!Date.now) { dragonBones.DataParser.INHERIT_TRANSLATION, true, ); - bone.inheritRotation = ObjectDataParser._getBoolean( - rawData, - dragonBones.DataParser.INHERIT_ROTATION, - true, - ); - bone.inheritScale = ObjectDataParser._getBoolean( - rawData, - dragonBones.DataParser.INHERIT_SCALE, - true, - ); - bone.inheritReflection = ObjectDataParser._getBoolean( - rawData, - dragonBones.DataParser.INHERIT_REFLECTION, - true, - ); - bone.length = - ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.LENGTH, - 0, - ) * scale; - bone.alpha = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.ALPHA, - 1.0, - ); - bone.name = ObjectDataParser._getString( - rawData, - dragonBones.DataParser.NAME, - '', - ); + bone.inheritRotation = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_ROTATION, true); + bone.inheritScale = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_SCALE, true); + bone.inheritReflection = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_REFLECTION, true); + bone.length = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.LENGTH, 0) * scale; + bone.alpha = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA, 1.0); + bone.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ''); if (dragonBones.DataParser.TRANSFORM in rawData) { - this._parseTransform( - rawData[dragonBones.DataParser.TRANSFORM], - bone.transform, - scale, - ); + this._parseTransform(rawData[dragonBones.DataParser.TRANSFORM], bone.transform, scale); } return bone; } - var surface = dragonBones.BaseObject.borrowObject( - dragonBones.SurfaceData, - ); - surface.alpha = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.ALPHA, - 1.0, - ); - surface.name = ObjectDataParser._getString( - rawData, - dragonBones.DataParser.NAME, - '', - ); - surface.segmentX = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.SEGMENT_X, - 0, - ); - surface.segmentY = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.SEGMENT_Y, - 0, - ); + var surface = dragonBones.BaseObject.borrowObject(dragonBones.SurfaceData); + surface.alpha = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA, 1.0); + surface.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ''); + surface.segmentX = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SEGMENT_X, 0); + surface.segmentY = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SEGMENT_Y, 0); this._parseGeometry(rawData, surface.geometry); return surface; }; - ObjectDataParser.prototype._parseIKConstraint = function(rawData) { - var bone = this._armature.getBone( - ObjectDataParser._getString(rawData, dragonBones.DataParser.BONE, ''), - ); + ObjectDataParser.prototype._parseIKConstraint = function (rawData) { + var bone = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.BONE, '')); if (bone === null) { return null; } - var target = this._armature.getBone( - ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET, ''), - ); + var target = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET, '')); if (target === null) { return null; } - var chain = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.CHAIN, - 0, - ); - var constraint = dragonBones.BaseObject.borrowObject( - dragonBones.IKConstraintData, - ); - constraint.scaleEnabled = ObjectDataParser._getBoolean( - rawData, - dragonBones.DataParser.SCALE, - false, - ); - constraint.bendPositive = ObjectDataParser._getBoolean( - rawData, - dragonBones.DataParser.BEND_POSITIVE, - true, - ); - constraint.weight = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.WEIGHT, - 1.0, - ); - constraint.name = ObjectDataParser._getString( - rawData, - dragonBones.DataParser.NAME, - '', - ); + var chain = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.CHAIN, 0); + var constraint = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintData); + constraint.scaleEnabled = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.SCALE, false); + constraint.bendPositive = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.BEND_POSITIVE, true); + constraint.weight = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WEIGHT, 1.0); + constraint.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ''); constraint.type = 0 /* IK */; constraint.target = target; if (chain > 0 && bone.parent !== null) { @@ -13874,10 +12705,8 @@ if (!Date.now) { } return constraint; }; - ObjectDataParser.prototype._parsePathConstraint = function(rawData) { - var target = this._armature.getSlot( - ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET, ''), - ); + ObjectDataParser.prototype._parsePathConstraint = function (rawData) { + var target = this._armature.getSlot(ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET, '')); if (target === null) { return null; } @@ -13888,80 +12717,35 @@ if (!Date.now) { //TODO var targetDisplay = defaultSkin.getDisplay( target.name, - ObjectDataParser._getString( - rawData, - dragonBones.DataParser.TARGET_DISPLAY, - target.name, - ), + ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET_DISPLAY, target.name), ); - if ( - targetDisplay === null || - !(targetDisplay instanceof dragonBones.PathDisplayData) - ) { + if (targetDisplay === null || !(targetDisplay instanceof dragonBones.PathDisplayData)) { return null; } var bones = rawData[dragonBones.DataParser.BONES]; if (bones === null || bones.length === 0) { return null; } - var constraint = dragonBones.BaseObject.borrowObject( - dragonBones.PathConstraintData, - ); - constraint.name = ObjectDataParser._getString( - rawData, - dragonBones.DataParser.NAME, - '', - ); + var constraint = dragonBones.BaseObject.borrowObject(dragonBones.PathConstraintData); + constraint.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ''); constraint.type = 1 /* Path */; constraint.pathSlot = target; constraint.pathDisplayData = targetDisplay; constraint.target = target.parent; constraint.positionMode = dragonBones.DataParser._getPositionMode( - ObjectDataParser._getString( - rawData, - dragonBones.DataParser.POSITION_MODE, - '', - ), + ObjectDataParser._getString(rawData, dragonBones.DataParser.POSITION_MODE, ''), ); constraint.spacingMode = dragonBones.DataParser._getSpacingMode( - ObjectDataParser._getString( - rawData, - dragonBones.DataParser.SPACING_MODE, - '', - ), + ObjectDataParser._getString(rawData, dragonBones.DataParser.SPACING_MODE, ''), ); constraint.rotateMode = dragonBones.DataParser._getRotateMode( - ObjectDataParser._getString( - rawData, - dragonBones.DataParser.ROTATE_MODE, - '', - ), - ); - constraint.position = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.POSITION, - 0, - ); - constraint.spacing = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.SPACING, - 0, - ); - constraint.rotateOffset = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.ROTATE_OFFSET, - 0, - ); - constraint.rotateMix = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.ROTATE_MIX, - 1, - ); - constraint.translateMix = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.TRANSLATE_MIX, - 1, + ObjectDataParser._getString(rawData, dragonBones.DataParser.ROTATE_MODE, ''), ); + constraint.position = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.POSITION, 0); + constraint.spacing = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SPACING, 0); + constraint.rotateOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE_OFFSET, 0); + constraint.rotateMix = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE_MIX, 1); + constraint.translateMix = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TRANSLATE_MIX, 1); // for (var _i = 0, bones_3 = bones; _i < bones_3.length; _i++) { var boneName = bones_3[_i]; @@ -13975,52 +12759,25 @@ if (!Date.now) { } return constraint; }; - ObjectDataParser.prototype._parseSlot = function(rawData, zOrder) { + ObjectDataParser.prototype._parseSlot = function (rawData, zOrder) { var slot = dragonBones.BaseObject.borrowObject(dragonBones.SlotData); - slot.displayIndex = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.DISPLAY_INDEX, - 0, - ); + slot.displayIndex = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DISPLAY_INDEX, 0); slot.zOrder = zOrder; - slot.zIndex = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.Z_INDEX, - 0, - ); - slot.alpha = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.ALPHA, - 1.0, - ); - slot.name = ObjectDataParser._getString( - rawData, - dragonBones.DataParser.NAME, - '', - ); - slot.parent = this._armature.getBone( - ObjectDataParser._getString(rawData, dragonBones.DataParser.PARENT, ''), - ); // + slot.zIndex = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Z_INDEX, 0); + slot.alpha = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA, 1.0); + slot.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ''); + slot.parent = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.PARENT, '')); // if ( dragonBones.DataParser.BLEND_MODE in rawData && typeof rawData[dragonBones.DataParser.BLEND_MODE] === 'string' ) { - slot.blendMode = dragonBones.DataParser._getBlendMode( - rawData[dragonBones.DataParser.BLEND_MODE], - ); + slot.blendMode = dragonBones.DataParser._getBlendMode(rawData[dragonBones.DataParser.BLEND_MODE]); } else { - slot.blendMode = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.BLEND_MODE, - 0 /* Normal */, - ); + slot.blendMode = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.BLEND_MODE, 0 /* Normal */); } if (dragonBones.DataParser.COLOR in rawData) { slot.color = dragonBones.SlotData.createColor(); - this._parseColorTransform( - rawData[dragonBones.DataParser.COLOR], - slot.color, - ); + this._parseColorTransform(rawData[dragonBones.DataParser.COLOR], slot.color); } else { slot.color = dragonBones.SlotData.DEFAULT_COLOR; } @@ -14034,7 +12791,7 @@ if (!Date.now) { } return slot; }; - ObjectDataParser.prototype._parseSkin = function(rawData) { + ObjectDataParser.prototype._parseSkin = function (rawData) { var skin = dragonBones.BaseObject.borrowObject(dragonBones.SkinData); skin.name = ObjectDataParser._getString( rawData, @@ -14049,21 +12806,13 @@ if (!Date.now) { this._skin = skin; for (var _i = 0, rawSlots_2 = rawSlots; _i < rawSlots_2.length; _i++) { var rawSlot = rawSlots_2[_i]; - var slotName = ObjectDataParser._getString( - rawSlot, - dragonBones.DataParser.NAME, - '', - ); + var slotName = ObjectDataParser._getString(rawSlot, dragonBones.DataParser.NAME, ''); var slot = this._armature.getSlot(slotName); if (slot !== null) { this._slot = slot; if (dragonBones.DataParser.DISPLAY in rawSlot) { var rawDisplays = rawSlot[dragonBones.DataParser.DISPLAY]; - for ( - var _a = 0, rawDisplays_1 = rawDisplays; - _a < rawDisplays_1.length; - _a++ - ) { + for (var _a = 0, rawDisplays_1 = rawDisplays; _a < rawDisplays_1.length; _a++) { var rawDisplay = rawDisplays_1[_a]; if (rawDisplay) { skin.addDisplay(slotName, this._parseDisplay(rawDisplay)); @@ -14079,73 +12828,39 @@ if (!Date.now) { } return skin; }; - ObjectDataParser.prototype._parseDisplay = function(rawData) { - var name = ObjectDataParser._getString( - rawData, - dragonBones.DataParser.NAME, - '', - ); - var path = ObjectDataParser._getString( - rawData, - dragonBones.DataParser.PATH, - '', - ); + ObjectDataParser.prototype._parseDisplay = function (rawData) { + var name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ''); + var path = ObjectDataParser._getString(rawData, dragonBones.DataParser.PATH, ''); var type = 0; /* Image */ var display = null; - if ( - dragonBones.DataParser.TYPE in rawData && - typeof rawData[dragonBones.DataParser.TYPE] === 'string' - ) { - type = dragonBones.DataParser._getDisplayType( - rawData[dragonBones.DataParser.TYPE], - ); + if (dragonBones.DataParser.TYPE in rawData && typeof rawData[dragonBones.DataParser.TYPE] === 'string') { + type = dragonBones.DataParser._getDisplayType(rawData[dragonBones.DataParser.TYPE]); } else { - type = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.TYPE, - type, - ); + type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, type); } switch (type) { case 0 /* Image */: { - var imageDisplay = (display = dragonBones.BaseObject.borrowObject( - dragonBones.ImageDisplayData, - )); + var imageDisplay = (display = dragonBones.BaseObject.borrowObject(dragonBones.ImageDisplayData)); imageDisplay.name = name; imageDisplay.path = path.length > 0 ? path : name; this._parsePivot(rawData, imageDisplay); break; } case 1 /* Armature */: { - var armatureDisplay = (display = dragonBones.BaseObject.borrowObject( - dragonBones.ArmatureDisplayData, - )); + var armatureDisplay = (display = dragonBones.BaseObject.borrowObject(dragonBones.ArmatureDisplayData)); armatureDisplay.name = name; armatureDisplay.path = path.length > 0 ? path : name; armatureDisplay.inheritAnimation = true; if (dragonBones.DataParser.ACTIONS in rawData) { - var actions = this._parseActionData( - rawData[dragonBones.DataParser.ACTIONS], - 0 /* Play */, - null, - null, - ); + var actions = this._parseActionData(rawData[dragonBones.DataParser.ACTIONS], 0 /* Play */, null, null); for (var _i = 0, actions_5 = actions; _i < actions_5.length; _i++) { var action = actions_5[_i]; armatureDisplay.addAction(action); } } else if (this._slot.name in this._slotChildActions) { var displays = this._skin.getDisplays(this._slot.name); - if ( - displays === null - ? this._slot.displayIndex === 0 - : this._slot.displayIndex === displays.length - ) { - for ( - var _a = 0, _b = this._slotChildActions[this._slot.name]; - _a < _b.length; - _a++ - ) { + if (displays === null ? this._slot.displayIndex === 0 : this._slot.displayIndex === displays.length) { + for (var _a = 0, _b = this._slotChildActions[this._slot.name]; _a < _b.length; _a++) { var action = _b[_a]; armatureDisplay.addAction(action); } @@ -14155,9 +12870,7 @@ if (!Date.now) { break; } case 2 /* Mesh */: { - var meshDisplay = (display = dragonBones.BaseObject.borrowObject( - dragonBones.MeshDisplayData, - )); + var meshDisplay = (display = dragonBones.BaseObject.borrowObject(dragonBones.MeshDisplayData)); meshDisplay.geometry.inheritDeform = ObjectDataParser._getBoolean( rawData, dragonBones.DataParser.INHERIT_DEFORM, @@ -14188,14 +12901,8 @@ if (!Date.now) { } case 4 /* Path */: { var rawCurveLengths = rawData[dragonBones.DataParser.LENGTHS]; - var pathDisplay = (display = dragonBones.BaseObject.borrowObject( - dragonBones.PathDisplayData, - )); - pathDisplay.closed = ObjectDataParser._getBoolean( - rawData, - dragonBones.DataParser.CLOSED, - false, - ); + var pathDisplay = (display = dragonBones.BaseObject.borrowObject(dragonBones.PathDisplayData)); + pathDisplay.closed = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.CLOSED, false); pathDisplay.constantSpeed = ObjectDataParser._getBoolean( rawData, dragonBones.DataParser.CONSTANT_SPEED, @@ -14212,106 +12919,63 @@ if (!Date.now) { } } if (display !== null && dragonBones.DataParser.TRANSFORM in rawData) { - this._parseTransform( - rawData[dragonBones.DataParser.TRANSFORM], - display.transform, - this._armature.scale, - ); + this._parseTransform(rawData[dragonBones.DataParser.TRANSFORM], display.transform, this._armature.scale); } return display; }; - ObjectDataParser.prototype._parsePath = function(rawData, display) { + ObjectDataParser.prototype._parsePath = function (rawData, display) { this._parseGeometry(rawData, display.geometry); }; - ObjectDataParser.prototype._parsePivot = function(rawData, display) { + ObjectDataParser.prototype._parsePivot = function (rawData, display) { if (dragonBones.DataParser.PIVOT in rawData) { var rawPivot = rawData[dragonBones.DataParser.PIVOT]; - display.pivot.x = ObjectDataParser._getNumber( - rawPivot, - dragonBones.DataParser.X, - 0.0, - ); - display.pivot.y = ObjectDataParser._getNumber( - rawPivot, - dragonBones.DataParser.Y, - 0.0, - ); + display.pivot.x = ObjectDataParser._getNumber(rawPivot, dragonBones.DataParser.X, 0.0); + display.pivot.y = ObjectDataParser._getNumber(rawPivot, dragonBones.DataParser.Y, 0.0); } else { display.pivot.x = 0.5; display.pivot.y = 0.5; } }; - ObjectDataParser.prototype._parseMesh = function(rawData, mesh) { + ObjectDataParser.prototype._parseMesh = function (rawData, mesh) { this._parseGeometry(rawData, mesh.geometry); if (dragonBones.DataParser.WEIGHTS in rawData) { var rawSlotPose = rawData[dragonBones.DataParser.SLOT_POSE]; var rawBonePoses = rawData[dragonBones.DataParser.BONE_POSE]; - var meshName = - this._skin.name + '_' + this._slot.name + '_' + mesh.name; + var meshName = this._skin.name + '_' + this._slot.name + '_' + mesh.name; this._weightSlotPose[meshName] = rawSlotPose; this._weightBonePoses[meshName] = rawBonePoses; } }; - ObjectDataParser.prototype._parseBoundingBox = function(rawData) { + ObjectDataParser.prototype._parseBoundingBox = function (rawData) { var boundingBox = null; var type = 0; /* Rectangle */ - if ( - dragonBones.DataParser.SUB_TYPE in rawData && - typeof rawData[dragonBones.DataParser.SUB_TYPE] === 'string' - ) { - type = dragonBones.DataParser._getBoundingBoxType( - rawData[dragonBones.DataParser.SUB_TYPE], - ); + if (dragonBones.DataParser.SUB_TYPE in rawData && typeof rawData[dragonBones.DataParser.SUB_TYPE] === 'string') { + type = dragonBones.DataParser._getBoundingBoxType(rawData[dragonBones.DataParser.SUB_TYPE]); } else { - type = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.SUB_TYPE, - type, - ); + type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SUB_TYPE, type); } switch (type) { case 0 /* Rectangle */: - boundingBox = dragonBones.BaseObject.borrowObject( - dragonBones.RectangleBoundingBoxData, - ); + boundingBox = dragonBones.BaseObject.borrowObject(dragonBones.RectangleBoundingBoxData); break; case 1 /* Ellipse */: - boundingBox = dragonBones.BaseObject.borrowObject( - dragonBones.EllipseBoundingBoxData, - ); + boundingBox = dragonBones.BaseObject.borrowObject(dragonBones.EllipseBoundingBoxData); break; case 2 /* Polygon */: boundingBox = this._parsePolygonBoundingBox(rawData); break; } if (boundingBox !== null) { - boundingBox.color = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.COLOR, - 0x000000, - ); - if ( - boundingBox.type === 0 /* Rectangle */ || - boundingBox.type === 1 /* Ellipse */ - ) { - boundingBox.width = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.WIDTH, - 0.0, - ); - boundingBox.height = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.HEIGHT, - 0.0, - ); + boundingBox.color = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.COLOR, 0x000000); + if (boundingBox.type === 0 /* Rectangle */ || boundingBox.type === 1 /* Ellipse */) { + boundingBox.width = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WIDTH, 0.0); + boundingBox.height = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.HEIGHT, 0.0); } } return boundingBox; }; - ObjectDataParser.prototype._parsePolygonBoundingBox = function(rawData) { - var polygonBoundingBox = dragonBones.BaseObject.borrowObject( - dragonBones.PolygonBoundingBoxData, - ); + ObjectDataParser.prototype._parsePolygonBoundingBox = function (rawData) { + var polygonBoundingBox = dragonBones.BaseObject.borrowObject(dragonBones.PolygonBoundingBoxData); if (dragonBones.DataParser.VERTICES in rawData) { var scale = this._armature.scale; var rawVertices = rawData[dragonBones.DataParser.VERTICES]; @@ -14344,44 +13008,20 @@ if (!Date.now) { polygonBoundingBox.width -= polygonBoundingBox.x; polygonBoundingBox.height -= polygonBoundingBox.y; } else { - console.warn( - 'Data error.\n Please reexport DragonBones Data to fixed the bug.', - ); + console.warn('Data error.\n Please reexport DragonBones Data to fixed the bug.'); } return polygonBoundingBox; }; - ObjectDataParser.prototype._parseAnimation = function(rawData) { - var animation = dragonBones.BaseObject.borrowObject( - dragonBones.AnimationData, - ); + ObjectDataParser.prototype._parseAnimation = function (rawData) { + var animation = dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); animation.blendType = dragonBones.DataParser._getAnimationBlendType( - ObjectDataParser._getString( - rawData, - dragonBones.DataParser.BLEND_TYPE, - '', - ), - ); - animation.frameCount = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.DURATION, - 0, - ); - animation.playTimes = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.PLAY_TIMES, - 1, + ObjectDataParser._getString(rawData, dragonBones.DataParser.BLEND_TYPE, ''), ); + animation.frameCount = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DURATION, 0); + animation.playTimes = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.PLAY_TIMES, 1); animation.duration = animation.frameCount / this._armature.frameRate; // float - animation.fadeInTime = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.FADE_IN_TIME, - 0.0, - ); - animation.scale = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.SCALE, - 1.0, - ); + animation.fadeInTime = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FADE_IN_TIME, 0.0); + animation.scale = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0); animation.name = ObjectDataParser._getString( rawData, dragonBones.DataParser.NAME, @@ -14401,11 +13041,7 @@ if (!Date.now) { for (var i = 0, frameStart = 0; i < keyFrameCount; ++i) { var rawFrame = rawFrames[i]; this._parseActionDataInFrame(rawFrame, frameStart, null, null); - frameStart += ObjectDataParser._getNumber( - rawFrame, - dragonBones.DataParser.DURATION, - 1, - ); + frameStart += ObjectDataParser._getNumber(rawFrame, dragonBones.DataParser.DURATION, 1); } } } @@ -14422,49 +13058,29 @@ if (!Date.now) { } if (dragonBones.DataParser.BONE in rawData) { var rawTimelines = rawData[dragonBones.DataParser.BONE]; - for ( - var _i = 0, rawTimelines_1 = rawTimelines; - _i < rawTimelines_1.length; - _i++ - ) { + for (var _i = 0, rawTimelines_1 = rawTimelines; _i < rawTimelines_1.length; _i++) { var rawTimeline = rawTimelines_1[_i]; this._parseBoneTimeline(rawTimeline); } } if (dragonBones.DataParser.SLOT in rawData) { var rawTimelines = rawData[dragonBones.DataParser.SLOT]; - for ( - var _a = 0, rawTimelines_2 = rawTimelines; - _a < rawTimelines_2.length; - _a++ - ) { + for (var _a = 0, rawTimelines_2 = rawTimelines; _a < rawTimelines_2.length; _a++) { var rawTimeline = rawTimelines_2[_a]; this._parseSlotTimeline(rawTimeline); } } if (dragonBones.DataParser.FFD in rawData) { var rawTimelines = rawData[dragonBones.DataParser.FFD]; - for ( - var _b = 0, rawTimelines_3 = rawTimelines; - _b < rawTimelines_3.length; - _b++ - ) { + for (var _b = 0, rawTimelines_3 = rawTimelines; _b < rawTimelines_3.length; _b++) { var rawTimeline = rawTimelines_3[_b]; var skinName = ObjectDataParser._getString( rawTimeline, dragonBones.DataParser.SKIN, dragonBones.DataParser.DEFAULT_NAME, ); - var slotName = ObjectDataParser._getString( - rawTimeline, - dragonBones.DataParser.SLOT, - '', - ); - var displayName = ObjectDataParser._getString( - rawTimeline, - dragonBones.DataParser.NAME, - '', - ); + var slotName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.SLOT, ''); + var displayName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ''); if (skinName.length === 0) { skinName = dragonBones.DataParser.DEFAULT_NAME; } @@ -14491,17 +13107,9 @@ if (!Date.now) { } if (dragonBones.DataParser.IK in rawData) { var rawTimelines = rawData[dragonBones.DataParser.IK]; - for ( - var _c = 0, rawTimelines_4 = rawTimelines; - _c < rawTimelines_4.length; - _c++ - ) { + for (var _c = 0, rawTimelines_4 = rawTimelines; _c < rawTimelines_4.length; _c++) { var rawTimeline = rawTimelines_4[_c]; - var constraintName = ObjectDataParser._getString( - rawTimeline, - dragonBones.DataParser.NAME, - '', - ); + var constraintName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ''); var constraint = this._armature.getConstraint(constraintName); if (constraint === null) { continue; @@ -14534,22 +13142,10 @@ if (!Date.now) { } if (dragonBones.DataParser.TIMELINE in rawData) { var rawTimelines = rawData[dragonBones.DataParser.TIMELINE]; - for ( - var _d = 0, rawTimelines_5 = rawTimelines; - _d < rawTimelines_5.length; - _d++ - ) { + for (var _d = 0, rawTimelines_5 = rawTimelines; _d < rawTimelines_5.length; _d++) { var rawTimeline = rawTimelines_5[_d]; - var timelineType = ObjectDataParser._getNumber( - rawTimeline, - dragonBones.DataParser.TYPE, - 0 /* Action */, - ); - var timelineName = ObjectDataParser._getString( - rawTimeline, - dragonBones.DataParser.NAME, - '', - ); + var timelineType = ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.TYPE, 0 /* Action */); + var timelineName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ''); var timeline = null; switch (timelineType) { case 0 /* Action */: @@ -14568,10 +13164,7 @@ if (!Date.now) { this._frameValueType = 1 /* Int */; if (timelineType === 23 /* SlotZIndex */) { this._frameValueScale = 1.0; - } else if ( - timelineType === 40 /* AnimationProgress */ || - timelineType === 41 /* AnimationWeight */ - ) { + } else if (timelineType === 40 /* AnimationProgress */ || timelineType === 41 /* AnimationWeight */) { this._frameValueScale = 10000.0; } else { this._frameValueScale = 100.0; @@ -14586,24 +13179,11 @@ if (!Date.now) { } else { this._frameDefaultValue = 0.0; } - if ( - timelineType === 40 /* AnimationProgress */ && - animation.blendType !== 0 /* None */ - ) { - timeline = dragonBones.BaseObject.borrowObject( - dragonBones.AnimationTimelineData, - ); + if (timelineType === 40 /* AnimationProgress */ && animation.blendType !== 0 /* None */) { + timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationTimelineData); var animaitonTimeline = timeline; - animaitonTimeline.x = ObjectDataParser._getNumber( - rawTimeline, - dragonBones.DataParser.X, - 0.0, - ); - animaitonTimeline.y = ObjectDataParser._getNumber( - rawTimeline, - dragonBones.DataParser.Y, - 0.0, - ); + animaitonTimeline.x = ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.X, 0.0); + animaitonTimeline.y = ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.Y, 0.0); } timeline = this._parseTimeline( rawTimeline, @@ -14621,10 +13201,7 @@ if (!Date.now) { case 13 /* BoneScale */: case 30 /* IKConstraint */: case 42 /* AnimationParameter */: - if ( - timelineType === 30 /* IKConstraint */ || - timelineType === 42 /* AnimationParameter */ - ) { + if (timelineType === 30 /* IKConstraint */ || timelineType === 42 /* AnimationParameter */) { this._frameValueType = 1 /* Int */; if (timelineType === 42 /* AnimationParameter */) { this._frameValueScale = 10000.0; @@ -14639,10 +13216,7 @@ if (!Date.now) { } this._frameValueType = 2 /* Float */; } - if ( - timelineType === 13 /* BoneScale */ || - timelineType === 30 /* IKConstraint */ - ) { + if (timelineType === 13 /* BoneScale */ || timelineType === 30 /* IKConstraint */) { this._frameDefaultValue = 1.0; } else { this._frameDefaultValue = 0.0; @@ -14684,11 +13258,7 @@ if (!Date.now) { var skin = this._armature.skins[skinName]; for (var slontName in skin.displays) { var displays = skin.displays[slontName]; - for ( - var _e = 0, displays_1 = displays; - _e < displays_1.length; - _e++ - ) { + for (var _e = 0, displays_1 = displays; _e < displays_1.length; _e++) { var display = displays_1[_e]; if (display !== null && display.name === timelineName) { this._geometry = display.geometry; @@ -14761,7 +13331,7 @@ if (!Date.now) { this._animation = null; // return animation; }; - ObjectDataParser.prototype._parseTimeline = function( + ObjectDataParser.prototype._parseTimeline = function ( rawData, rawFrames, framesKey, @@ -14788,9 +13358,7 @@ if (!Date.now) { var frameFloatArrayLength = this._frameFloatArray.length; var timelineOffset = this._timelineArray.length; if (timeline === null) { - timeline = dragonBones.BaseObject.borrowObject( - dragonBones.TimelineData, - ); + timeline = dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); } timeline.type = timelineType; timeline.offset = timelineOffset; @@ -14798,67 +13366,42 @@ if (!Date.now) { this._timeline = timeline; this._timelineArray.length += 1 + 1 + 1 + 1 + 1 + keyFrameCount; if (rawData !== null) { - this._timelineArray[ - timelineOffset + 0 /* TimelineScale */ - ] = Math.round( - ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.SCALE, - 1.0, - ) * 100, + this._timelineArray[timelineOffset + 0 /* TimelineScale */] = Math.round( + ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0) * 100, ); - this._timelineArray[ - timelineOffset + 1 /* TimelineOffset */ - ] = Math.round( - ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.OFFSET, - 0.0, - ) * 100, + this._timelineArray[timelineOffset + 1 /* TimelineOffset */] = Math.round( + ObjectDataParser._getNumber(rawData, dragonBones.DataParser.OFFSET, 0.0) * 100, ); } else { this._timelineArray[timelineOffset + 0 /* TimelineScale */] = 100; this._timelineArray[timelineOffset + 1 /* TimelineOffset */] = 0; } - this._timelineArray[ - timelineOffset + 2 /* TimelineKeyFrameCount */ - ] = keyFrameCount; - this._timelineArray[ - timelineOffset + 3 /* TimelineFrameValueCount */ - ] = frameValueCount; + this._timelineArray[timelineOffset + 2 /* TimelineKeyFrameCount */] = keyFrameCount; + this._timelineArray[timelineOffset + 3 /* TimelineFrameValueCount */] = frameValueCount; switch (this._frameValueType) { case 0 /* Step */: - this._timelineArray[ - timelineOffset + 4 /* TimelineFrameValueOffset */ - ] = 0; + this._timelineArray[timelineOffset + 4 /* TimelineFrameValueOffset */] = 0; break; case 1 /* Int */: - this._timelineArray[ - timelineOffset + 4 /* TimelineFrameValueOffset */ - ] = frameIntArrayLength - this._animation.frameIntOffset; + this._timelineArray[timelineOffset + 4 /* TimelineFrameValueOffset */] = + frameIntArrayLength - this._animation.frameIntOffset; break; case 2 /* Float */: - this._timelineArray[ - timelineOffset + 4 /* TimelineFrameValueOffset */ - ] = frameFloatArrayLength - this._animation.frameFloatOffset; + this._timelineArray[timelineOffset + 4 /* TimelineFrameValueOffset */] = + frameFloatArrayLength - this._animation.frameFloatOffset; break; } if (keyFrameCount === 1) { timeline.frameIndicesOffset = -1; this._timelineArray[timelineOffset + 5 /* TimelineFrameOffset */ + 0] = - frameParser.call(this, rawFrames[0], 0, 0) - - this._animation.frameOffset; + frameParser.call(this, rawFrames[0], 0, 0) - this._animation.frameOffset; } else { var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. var frameIndices = this._data.frameIndices; var frameIndicesOffset = frameIndices.length; frameIndices.length += totalFrameCount; timeline.frameIndicesOffset = frameIndicesOffset; - for ( - var i = 0, iK = 0, frameStart = 0, frameCount = 0; - i < totalFrameCount; - ++i - ) { + for (var i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { if (frameStart + frameCount <= i && iK < keyFrameCount) { var rawFrame = rawFrames[iK]; frameStart = i; // frame.frameStart; @@ -14868,18 +13411,11 @@ if (!Date.now) { if (rawFrame instanceof ActionFrame) { frameCount = this._actionFrames[iK + 1].frameStart - frameStart; } else { - frameCount = ObjectDataParser._getNumber( - rawFrame, - dragonBones.DataParser.DURATION, - 1, - ); + frameCount = ObjectDataParser._getNumber(rawFrame, dragonBones.DataParser.DURATION, 1); } } - this._timelineArray[ - timelineOffset + 5 /* TimelineFrameOffset */ + iK - ] = - frameParser.call(this, rawFrame, frameStart, frameCount) - - this._animation.frameOffset; + this._timelineArray[timelineOffset + 5 /* TimelineFrameOffset */ + iK] = + frameParser.call(this, rawFrame, frameStart, frameCount) - this._animation.frameOffset; iK++; } frameIndices[frameIndicesOffset + i] = iK - 1; @@ -14888,10 +13424,8 @@ if (!Date.now) { this._timeline = null; // return timeline; }; - ObjectDataParser.prototype._parseBoneTimeline = function(rawData) { - var bone = this._armature.getBone( - ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ''), - ); + ObjectDataParser.prototype._parseBoneTimeline = function (rawData) { + var bone = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, '')); if (bone === null) { return; } @@ -14962,10 +13496,8 @@ if (!Date.now) { this._bone = null; // this._slot = null; // }; - ObjectDataParser.prototype._parseSlotTimeline = function(rawData) { - var slot = this._armature.getSlot( - ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ''), - ); + ObjectDataParser.prototype._parseSlotTimeline = function (rawData) { + var slot = this._armature.getSlot(ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, '')); if (slot === null) { return; } @@ -15022,11 +13554,7 @@ if (!Date.now) { } this._slot = null; // }; - ObjectDataParser.prototype._parseFrame = function( - rawData, - frameStart, - frameCount, - ) { + ObjectDataParser.prototype._parseFrame = function (rawData, frameStart, frameCount) { // tslint:disable-next-line:no-unused-expression rawData; // tslint:disable-next-line:no-unused-expression @@ -15036,76 +13564,51 @@ if (!Date.now) { this._frameArray[frameOffset + 0 /* FramePosition */] = frameStart; return frameOffset; }; - ObjectDataParser.prototype._parseTweenFrame = function( - rawData, - frameStart, - frameCount, - ) { + ObjectDataParser.prototype._parseTweenFrame = function (rawData, frameStart, frameCount) { var frameOffset = this._parseFrame(rawData, frameStart, frameCount); if (frameCount > 0) { if (dragonBones.DataParser.CURVE in rawData) { var sampleCount = frameCount + 1; this._helpArray.length = sampleCount; - var isOmited = this._samplingEasingCurve( - rawData[dragonBones.DataParser.CURVE], - this._helpArray, - ); + var isOmited = this._samplingEasingCurve(rawData[dragonBones.DataParser.CURVE], this._helpArray); this._frameArray.length += 1 + 1 + this._helpArray.length; - this._frameArray[ - frameOffset + 1 /* FrameTweenType */ - ] = 2 /* Curve */; - this._frameArray[ - frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */ - ] = isOmited ? sampleCount : -sampleCount; + this._frameArray[frameOffset + 1 /* FrameTweenType */] = 2 /* Curve */; + this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = isOmited + ? sampleCount + : -sampleCount; for (var i = 0; i < sampleCount; ++i) { - this._frameArray[ - frameOffset + 3 /* FrameCurveSamples */ + i - ] = Math.round(this._helpArray[i] * 10000.0); + this._frameArray[frameOffset + 3 /* FrameCurveSamples */ + i] = Math.round(this._helpArray[i] * 10000.0); } } else { var noTween = -2.0; var tweenEasing = noTween; if (dragonBones.DataParser.TWEEN_EASING in rawData) { - tweenEasing = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.TWEEN_EASING, - noTween, - ); + tweenEasing = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TWEEN_EASING, noTween); } if (tweenEasing === noTween) { this._frameArray.length += 1; - this._frameArray[ - frameOffset + 1 /* FrameTweenType */ - ] = 0 /* None */; + this._frameArray[frameOffset + 1 /* FrameTweenType */] = 0 /* None */; } else if (tweenEasing === 0.0) { this._frameArray.length += 1; - this._frameArray[ - frameOffset + 1 /* FrameTweenType */ - ] = 1 /* Line */; + this._frameArray[frameOffset + 1 /* FrameTweenType */] = 1 /* Line */; } else if (tweenEasing < 0.0) { this._frameArray.length += 1 + 1; - this._frameArray[ - frameOffset + 1 /* FrameTweenType */ - ] = 3 /* QuadIn */; - this._frameArray[ - frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */ - ] = Math.round(-tweenEasing * 100.0); + this._frameArray[frameOffset + 1 /* FrameTweenType */] = 3 /* QuadIn */; + this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round( + -tweenEasing * 100.0, + ); } else if (tweenEasing <= 1.0) { this._frameArray.length += 1 + 1; - this._frameArray[ - frameOffset + 1 /* FrameTweenType */ - ] = 4 /* QuadOut */; - this._frameArray[ - frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */ - ] = Math.round(tweenEasing * 100.0); + this._frameArray[frameOffset + 1 /* FrameTweenType */] = 4 /* QuadOut */; + this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round( + tweenEasing * 100.0, + ); } else { this._frameArray.length += 1 + 1; - this._frameArray[ - frameOffset + 1 /* FrameTweenType */ - ] = 5 /* QuadInOut */; - this._frameArray[ - frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */ - ] = Math.round(tweenEasing * 100.0 - 100.0); + this._frameArray[frameOffset + 1 /* FrameTweenType */] = 5 /* QuadInOut */; + this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round( + tweenEasing * 100.0 - 100.0, + ); } } } else { @@ -15114,11 +13617,7 @@ if (!Date.now) { } return frameOffset; }; - ObjectDataParser.prototype._parseSingleValueFrame = function( - rawData, - frameStart, - frameCount, - ) { + ObjectDataParser.prototype._parseSingleValueFrame = function (rawData, frameStart, frameCount) { var frameOffset = 0; switch (this._frameValueType) { case 0: { @@ -15136,11 +13635,8 @@ if (!Date.now) { var frameValueOffset = this._frameIntArray.length; this._frameIntArray.length += 1; this._frameIntArray[frameValueOffset] = Math.round( - ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.VALUE, - this._frameDefaultValue, - ) * this._frameValueScale, + ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, this._frameDefaultValue) * + this._frameValueScale, ); break; } @@ -15149,21 +13645,14 @@ if (!Date.now) { var frameValueOffset = this._frameFloatArray.length; this._frameFloatArray.length += 1; this._frameFloatArray[frameValueOffset] = - ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.VALUE, - this._frameDefaultValue, - ) * this._frameValueScale; + ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, this._frameDefaultValue) * + this._frameValueScale; break; } } return frameOffset; }; - ObjectDataParser.prototype._parseDoubleValueFrame = function( - rawData, - frameStart, - frameCount, - ) { + ObjectDataParser.prototype._parseDoubleValueFrame = function (rawData, frameStart, frameCount) { var frameOffset = 0; switch (this._frameValueType) { case 0: { @@ -15186,18 +13675,12 @@ if (!Date.now) { var frameValueOffset = this._frameIntArray.length; this._frameIntArray.length += 2; this._frameIntArray[frameValueOffset] = Math.round( - ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.X, - this._frameDefaultValue, - ) * this._frameValueScale, + ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, this._frameDefaultValue) * + this._frameValueScale, ); this._frameIntArray[frameValueOffset + 1] = Math.round( - ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.Y, - this._frameDefaultValue, - ) * this._frameValueScale, + ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, this._frameDefaultValue) * + this._frameValueScale, ); break; } @@ -15206,27 +13689,17 @@ if (!Date.now) { var frameValueOffset = this._frameFloatArray.length; this._frameFloatArray.length += 2; this._frameFloatArray[frameValueOffset] = - ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.X, - this._frameDefaultValue, - ) * this._frameValueScale; + ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, this._frameDefaultValue) * + this._frameValueScale; this._frameFloatArray[frameValueOffset + 1] = - ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.Y, - this._frameDefaultValue, - ) * this._frameValueScale; + ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, this._frameDefaultValue) * + this._frameValueScale; break; } } return frameOffset; }; - ObjectDataParser.prototype._parseActionFrame = function( - frame, - frameStart, - frameCount, - ) { + ObjectDataParser.prototype._parseActionFrame = function (frame, frameStart, frameCount) { // tslint:disable-next-line:no-unused-expression frameCount; var frameOffset = this._frameArray.length; @@ -15235,16 +13708,11 @@ if (!Date.now) { this._frameArray[frameOffset + 0 /* FramePosition */] = frameStart; this._frameArray[frameOffset + 0 /* FramePosition */ + 1] = actionCount; // Action count. for (var i = 0; i < actionCount; ++i) { - this._frameArray[frameOffset + 0 /* FramePosition */ + 2 + i] = - frame.actions[i]; + this._frameArray[frameOffset + 0 /* FramePosition */ + 2 + i] = frame.actions[i]; } return frameOffset; }; - ObjectDataParser.prototype._parseZOrderFrame = function( - rawData, - frameStart, - frameCount, - ) { + ObjectDataParser.prototype._parseZOrderFrame = function (rawData, frameStart, frameCount) { var frameOffset = this._parseFrame(rawData, frameStart, frameCount); if (dragonBones.DataParser.Z_ORDER in rawData) { var rawZOrder = rawData[dragonBones.DataParser.Z_ORDER]; @@ -15277,8 +13745,7 @@ if (!Date.now) { var i = slotCount; while (i--) { if (zOrders[i] === -1) { - this._frameArray[frameOffset + 2 + i] = - unchanged[--unchangedIndex] || 0; + this._frameArray[frameOffset + 2 + i] = unchanged[--unchangedIndex] || 0; } else { this._frameArray[frameOffset + 2 + i] = zOrders[i] || 0; } @@ -15290,51 +13757,25 @@ if (!Date.now) { this._frameArray[frameOffset + 1] = 0; return frameOffset; }; - ObjectDataParser.prototype._parseBoneAllFrame = function( - rawData, - frameStart, - frameCount, - ) { + ObjectDataParser.prototype._parseBoneAllFrame = function (rawData, frameStart, frameCount) { this._helpTransform.identity(); if (dragonBones.DataParser.TRANSFORM in rawData) { - this._parseTransform( - rawData[dragonBones.DataParser.TRANSFORM], - this._helpTransform, - 1.0, - ); + this._parseTransform(rawData[dragonBones.DataParser.TRANSFORM], this._helpTransform, 1.0); } // Modify rotation. var rotation = this._helpTransform.rotation; if (frameStart !== 0) { if (this._prevClockwise === 0) { - rotation = - this._prevRotation + - dragonBones.Transform.normalizeRadian( - rotation - this._prevRotation, - ); + rotation = this._prevRotation + dragonBones.Transform.normalizeRadian(rotation - this._prevRotation); } else { - if ( - this._prevClockwise > 0 - ? rotation >= this._prevRotation - : rotation <= this._prevRotation - ) { - this._prevClockwise = - this._prevClockwise > 0 - ? this._prevClockwise - 1 - : this._prevClockwise + 1; + if (this._prevClockwise > 0 ? rotation >= this._prevRotation : rotation <= this._prevRotation) { + this._prevClockwise = this._prevClockwise > 0 ? this._prevClockwise - 1 : this._prevClockwise + 1; } rotation = - this._prevRotation + - rotation - - this._prevRotation + - dragonBones.Transform.PI_D * this._prevClockwise; + this._prevRotation + rotation - this._prevRotation + dragonBones.Transform.PI_D * this._prevClockwise; } } - this._prevClockwise = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.TWEEN_ROTATE, - 0.0, - ); + this._prevClockwise = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TWEEN_ROTATE, 0.0); this._prevRotation = rotation; // var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); @@ -15349,68 +13790,30 @@ if (!Date.now) { this._parseActionDataInFrame(rawData, frameStart, this._bone, this._slot); return frameOffset; }; - ObjectDataParser.prototype._parseBoneTranslateFrame = function( - rawData, - frameStart, - frameCount, - ) { + ObjectDataParser.prototype._parseBoneTranslateFrame = function (rawData, frameStart, frameCount) { var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); var frameFloatOffset = this._frameFloatArray.length; this._frameFloatArray.length += 2; - this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.X, - 0.0, - ); - this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.Y, - 0.0, - ); + this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 0.0); + this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 0.0); return frameOffset; }; - ObjectDataParser.prototype._parseBoneRotateFrame = function( - rawData, - frameStart, - frameCount, - ) { + ObjectDataParser.prototype._parseBoneRotateFrame = function (rawData, frameStart, frameCount) { // Modify rotation. var rotation = - ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.ROTATE, - 0.0, - ) * dragonBones.Transform.DEG_RAD; + ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE, 0.0) * dragonBones.Transform.DEG_RAD; if (frameStart !== 0) { if (this._prevClockwise === 0) { - rotation = - this._prevRotation + - dragonBones.Transform.normalizeRadian( - rotation - this._prevRotation, - ); + rotation = this._prevRotation + dragonBones.Transform.normalizeRadian(rotation - this._prevRotation); } else { - if ( - this._prevClockwise > 0 - ? rotation >= this._prevRotation - : rotation <= this._prevRotation - ) { - this._prevClockwise = - this._prevClockwise > 0 - ? this._prevClockwise - 1 - : this._prevClockwise + 1; + if (this._prevClockwise > 0 ? rotation >= this._prevRotation : rotation <= this._prevRotation) { + this._prevClockwise = this._prevClockwise > 0 ? this._prevClockwise - 1 : this._prevClockwise + 1; } rotation = - this._prevRotation + - rotation - - this._prevRotation + - dragonBones.Transform.PI_D * this._prevClockwise; + this._prevRotation + rotation - this._prevRotation + dragonBones.Transform.PI_D * this._prevClockwise; } } - this._prevClockwise = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.CLOCK_WISE, - 0, - ); + this._prevClockwise = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.CLOCK_WISE, 0); this._prevRotation = rotation; // var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); @@ -15418,43 +13821,22 @@ if (!Date.now) { this._frameFloatArray.length += 2; this._frameFloatArray[frameFloatOffset++] = rotation; this._frameFloatArray[frameFloatOffset++] = - ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW, 0.0) * - dragonBones.Transform.DEG_RAD; + ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW, 0.0) * dragonBones.Transform.DEG_RAD; return frameOffset; }; - ObjectDataParser.prototype._parseBoneScaleFrame = function( - rawData, - frameStart, - frameCount, - ) { + ObjectDataParser.prototype._parseBoneScaleFrame = function (rawData, frameStart, frameCount) { var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); var frameFloatOffset = this._frameFloatArray.length; this._frameFloatArray.length += 2; - this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.X, - 1.0, - ); - this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.Y, - 1.0, - ); + this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 1.0); + this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 1.0); return frameOffset; }; - ObjectDataParser.prototype._parseSlotDisplayFrame = function( - rawData, - frameStart, - frameCount, - ) { + ObjectDataParser.prototype._parseSlotDisplayFrame = function (rawData, frameStart, frameCount) { var frameOffset = this._parseFrame(rawData, frameStart, frameCount); this._frameArray.length += 1; if (dragonBones.DataParser.VALUE in rawData) { - this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.VALUE, - 0, - ); + this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, 0); } else { this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber( rawData, @@ -15462,25 +13844,13 @@ if (!Date.now) { 0, ); } - this._parseActionDataInFrame( - rawData, - frameStart, - this._slot.parent, - this._slot, - ); + this._parseActionDataInFrame(rawData, frameStart, this._slot.parent, this._slot); return frameOffset; }; - ObjectDataParser.prototype._parseSlotColorFrame = function( - rawData, - frameStart, - frameCount, - ) { + ObjectDataParser.prototype._parseSlotColorFrame = function (rawData, frameStart, frameCount) { var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); var colorOffset = -1; - if ( - dragonBones.DataParser.VALUE in rawData || - dragonBones.DataParser.COLOR in rawData - ) { + if (dragonBones.DataParser.VALUE in rawData || dragonBones.DataParser.COLOR in rawData) { var rawColor = dragonBones.DataParser.VALUE in rawData ? rawData[dragonBones.DataParser.VALUE] @@ -15491,30 +13861,14 @@ if (!Date.now) { this._parseColorTransform(rawColor, this._helpColorTransform); colorOffset = this._colorArray.length; this._colorArray.length += 8; - this._colorArray[colorOffset++] = Math.round( - this._helpColorTransform.alphaMultiplier * 100, - ); - this._colorArray[colorOffset++] = Math.round( - this._helpColorTransform.redMultiplier * 100, - ); - this._colorArray[colorOffset++] = Math.round( - this._helpColorTransform.greenMultiplier * 100, - ); - this._colorArray[colorOffset++] = Math.round( - this._helpColorTransform.blueMultiplier * 100, - ); - this._colorArray[colorOffset++] = Math.round( - this._helpColorTransform.alphaOffset, - ); - this._colorArray[colorOffset++] = Math.round( - this._helpColorTransform.redOffset, - ); - this._colorArray[colorOffset++] = Math.round( - this._helpColorTransform.greenOffset, - ); - this._colorArray[colorOffset++] = Math.round( - this._helpColorTransform.blueOffset, - ); + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.alphaMultiplier * 100); + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.redMultiplier * 100); + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.greenMultiplier * 100); + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.blueMultiplier * 100); + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.alphaOffset); + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.redOffset); + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.greenOffset); + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.blueOffset); colorOffset -= 8; break; } @@ -15539,27 +13893,13 @@ if (!Date.now) { this._frameIntArray[frameIntOffset] = colorOffset; return frameOffset; }; - ObjectDataParser.prototype._parseSlotDeformFrame = function( - rawData, - frameStart, - frameCount, - ) { + ObjectDataParser.prototype._parseSlotDeformFrame = function (rawData, frameStart, frameCount) { var frameFloatOffset = this._frameFloatArray.length; var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var rawVertices = - dragonBones.DataParser.VERTICES in rawData - ? rawData[dragonBones.DataParser.VERTICES] - : null; - var offset = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.OFFSET, - 0, - ); // uint - var vertexCount = this._intArray[ - this._mesh.geometry.offset + 0 /* GeometryVertexCount */ - ]; - var meshName = - this._mesh.parent.name + '_' + this._slot.name + '_' + this._mesh.name; + var rawVertices = dragonBones.DataParser.VERTICES in rawData ? rawData[dragonBones.DataParser.VERTICES] : null; + var offset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.OFFSET, 0); // uint + var vertexCount = this._intArray[this._mesh.geometry.offset + 0 /* GeometryVertexCount */]; + var meshName = this._mesh.parent.name + '_' + this._slot.name + '_' + this._mesh.name; var weight = this._mesh.geometry.weight; var x = 0.0; var y = 0.0; @@ -15611,27 +13951,19 @@ if (!Date.now) { if (frameStart === 0) { var frameIntOffset = this._frameIntArray.length; this._frameIntArray.length += 1 + 1 + 1 + 1 + 1; - this._frameIntArray[ - frameIntOffset + 0 /* DeformVertexOffset */ - ] = this._mesh.geometry.offset; - this._frameIntArray[frameIntOffset + 1 /* DeformCount */] = - this._frameFloatArray.length - frameFloatOffset; + this._frameIntArray[frameIntOffset + 0 /* DeformVertexOffset */] = this._mesh.geometry.offset; + this._frameIntArray[frameIntOffset + 1 /* DeformCount */] = this._frameFloatArray.length - frameFloatOffset; this._frameIntArray[frameIntOffset + 2 /* DeformValueCount */] = this._frameFloatArray.length - frameFloatOffset; this._frameIntArray[frameIntOffset + 3 /* DeformValueOffset */] = 0; this._frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] = frameFloatOffset - this._animation.frameFloatOffset; - this._timelineArray[ - this._timeline.offset + 3 /* TimelineFrameValueCount */ - ] = frameIntOffset - this._animation.frameIntOffset; + this._timelineArray[this._timeline.offset + 3 /* TimelineFrameValueCount */] = + frameIntOffset - this._animation.frameIntOffset; } return frameOffset; }; - ObjectDataParser.prototype._parseIKConstraintFrame = function( - rawData, - frameStart, - frameCount, - ) { + ObjectDataParser.prototype._parseIKConstraintFrame = function (rawData, frameStart, frameCount) { var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); var frameIntOffset = this._frameIntArray.length; this._frameIntArray.length += 2; @@ -15643,25 +13975,14 @@ if (!Date.now) { ? 1 : 0; this._frameIntArray[frameIntOffset++] = Math.round( - ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.WEIGHT, - 1.0, - ) * 100.0, + ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WEIGHT, 1.0) * 100.0, ); - return frameOffset; - }; - ObjectDataParser.prototype._parseActionData = function( - rawData, - type, - bone, - slot, - ) { + return frameOffset; + }; + ObjectDataParser.prototype._parseActionData = function (rawData, type, bone, slot) { var actions = new Array(); if (typeof rawData === 'string') { - var action = dragonBones.BaseObject.borrowObject( - dragonBones.ActionData, - ); + var action = dragonBones.BaseObject.borrowObject(dragonBones.ActionData); action.type = type; action.name = rawData; action.bone = bone; @@ -15670,53 +13991,29 @@ if (!Date.now) { } else if (rawData instanceof Array) { for (var _i = 0, rawData_2 = rawData; _i < rawData_2.length; _i++) { var rawAction = rawData_2[_i]; - var action = dragonBones.BaseObject.borrowObject( - dragonBones.ActionData, - ); + var action = dragonBones.BaseObject.borrowObject(dragonBones.ActionData); if (dragonBones.DataParser.GOTO_AND_PLAY in rawAction) { action.type = 0 /* Play */; - action.name = ObjectDataParser._getString( - rawAction, - dragonBones.DataParser.GOTO_AND_PLAY, - '', - ); + action.name = ObjectDataParser._getString(rawAction, dragonBones.DataParser.GOTO_AND_PLAY, ''); } else { if ( dragonBones.DataParser.TYPE in rawAction && typeof rawAction[dragonBones.DataParser.TYPE] === 'string' ) { - action.type = dragonBones.DataParser._getActionType( - rawAction[dragonBones.DataParser.TYPE], - ); + action.type = dragonBones.DataParser._getActionType(rawAction[dragonBones.DataParser.TYPE]); } else { - action.type = ObjectDataParser._getNumber( - rawAction, - dragonBones.DataParser.TYPE, - type, - ); + action.type = ObjectDataParser._getNumber(rawAction, dragonBones.DataParser.TYPE, type); } - action.name = ObjectDataParser._getString( - rawAction, - dragonBones.DataParser.NAME, - '', - ); + action.name = ObjectDataParser._getString(rawAction, dragonBones.DataParser.NAME, ''); } if (dragonBones.DataParser.BONE in rawAction) { - var boneName = ObjectDataParser._getString( - rawAction, - dragonBones.DataParser.BONE, - '', - ); + var boneName = ObjectDataParser._getString(rawAction, dragonBones.DataParser.BONE, ''); action.bone = this._armature.getBone(boneName); } else { action.bone = bone; } if (dragonBones.DataParser.SLOT in rawAction) { - var slotName = ObjectDataParser._getString( - rawAction, - dragonBones.DataParser.SLOT, - '', - ); + var slotName = ObjectDataParser._getString(rawAction, dragonBones.DataParser.SLOT, ''); action.slot = this._armature.getSlot(slotName); } else { action.slot = slot; @@ -15724,9 +14021,7 @@ if (!Date.now) { var userData = null; if (dragonBones.DataParser.INTS in rawAction) { if (userData === null) { - userData = dragonBones.BaseObject.borrowObject( - dragonBones.UserData, - ); + userData = dragonBones.BaseObject.borrowObject(dragonBones.UserData); } var rawInts = rawAction[dragonBones.DataParser.INTS]; for (var _a = 0, rawInts_1 = rawInts; _a < rawInts_1.length; _a++) { @@ -15736,32 +14031,20 @@ if (!Date.now) { } if (dragonBones.DataParser.FLOATS in rawAction) { if (userData === null) { - userData = dragonBones.BaseObject.borrowObject( - dragonBones.UserData, - ); + userData = dragonBones.BaseObject.borrowObject(dragonBones.UserData); } var rawFloats = rawAction[dragonBones.DataParser.FLOATS]; - for ( - var _b = 0, rawFloats_1 = rawFloats; - _b < rawFloats_1.length; - _b++ - ) { + for (var _b = 0, rawFloats_1 = rawFloats; _b < rawFloats_1.length; _b++) { var rawValue = rawFloats_1[_b]; userData.addFloat(rawValue); } } if (dragonBones.DataParser.STRINGS in rawAction) { if (userData === null) { - userData = dragonBones.BaseObject.borrowObject( - dragonBones.UserData, - ); + userData = dragonBones.BaseObject.borrowObject(dragonBones.UserData); } var rawStrings = rawAction[dragonBones.DataParser.STRINGS]; - for ( - var _c = 0, rawStrings_1 = rawStrings; - _c < rawStrings_1.length; - _c++ - ) { + for (var _c = 0, rawStrings_1 = rawStrings; _c < rawStrings_1.length; _c++) { var rawValue = rawStrings_1[_c]; userData.addString(rawValue); } @@ -15772,11 +14055,7 @@ if (!Date.now) { } return actions; }; - ObjectDataParser.prototype._parseDeformFrame = function( - rawData, - frameStart, - frameCount, - ) { + ObjectDataParser.prototype._parseDeformFrame = function (rawData, frameStart, frameCount) { var frameFloatOffset = this._frameFloatArray.length; var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); var rawVertices = @@ -15785,14 +14064,8 @@ if (!Date.now) { : dragonBones.DataParser.VALUE in rawData ? rawData[dragonBones.DataParser.VALUE] : null; - var offset = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.OFFSET, - 0, - ); // uint - var vertexCount = this._intArray[ - this._geometry.offset + 0 /* GeometryVertexCount */ - ]; + var offset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.OFFSET, 0); // uint + var vertexCount = this._intArray[this._geometry.offset + 0 /* GeometryVertexCount */]; var weight = this._geometry.weight; var x = 0.0; var y = 0.0; @@ -15823,129 +14096,51 @@ if (!Date.now) { if (frameStart === 0) { var frameIntOffset = this._frameIntArray.length; this._frameIntArray.length += 1 + 1 + 1 + 1 + 1; - this._frameIntArray[ - frameIntOffset + 0 /* DeformVertexOffset */ - ] = this._geometry.offset; - this._frameIntArray[frameIntOffset + 1 /* DeformCount */] = - this._frameFloatArray.length - frameFloatOffset; + this._frameIntArray[frameIntOffset + 0 /* DeformVertexOffset */] = this._geometry.offset; + this._frameIntArray[frameIntOffset + 1 /* DeformCount */] = this._frameFloatArray.length - frameFloatOffset; this._frameIntArray[frameIntOffset + 2 /* DeformValueCount */] = this._frameFloatArray.length - frameFloatOffset; this._frameIntArray[frameIntOffset + 3 /* DeformValueOffset */] = 0; this._frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] = frameFloatOffset - this._animation.frameFloatOffset; - this._timelineArray[ - this._timeline.offset + 3 /* TimelineFrameValueCount */ - ] = frameIntOffset - this._animation.frameIntOffset; + this._timelineArray[this._timeline.offset + 3 /* TimelineFrameValueCount */] = + frameIntOffset - this._animation.frameIntOffset; } return frameOffset; }; - ObjectDataParser.prototype._parseTransform = function( - rawData, - transform, - scale, - ) { - transform.x = - ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 0.0) * - scale; - transform.y = - ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 0.0) * - scale; - if ( - dragonBones.DataParser.ROTATE in rawData || - dragonBones.DataParser.SKEW in rawData - ) { + ObjectDataParser.prototype._parseTransform = function (rawData, transform, scale) { + transform.x = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 0.0) * scale; + transform.y = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 0.0) * scale; + if (dragonBones.DataParser.ROTATE in rawData || dragonBones.DataParser.SKEW in rawData) { transform.rotation = dragonBones.Transform.normalizeRadian( - ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.ROTATE, - 0.0, - ) * dragonBones.Transform.DEG_RAD, + ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE, 0.0) * dragonBones.Transform.DEG_RAD, ); transform.skew = dragonBones.Transform.normalizeRadian( - ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.SKEW, - 0.0, - ) * dragonBones.Transform.DEG_RAD, + ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW, 0.0) * dragonBones.Transform.DEG_RAD, ); - } else if ( - dragonBones.DataParser.SKEW_X in rawData || - dragonBones.DataParser.SKEW_Y in rawData - ) { + } else if (dragonBones.DataParser.SKEW_X in rawData || dragonBones.DataParser.SKEW_Y in rawData) { transform.rotation = dragonBones.Transform.normalizeRadian( - ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.SKEW_Y, - 0.0, - ) * dragonBones.Transform.DEG_RAD, + ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW_Y, 0.0) * dragonBones.Transform.DEG_RAD, ); transform.skew = dragonBones.Transform.normalizeRadian( - ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.SKEW_X, - 0.0, - ) * dragonBones.Transform.DEG_RAD, + ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW_X, 0.0) * dragonBones.Transform.DEG_RAD, ) - transform.rotation; } - transform.scaleX = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.SCALE_X, - 1.0, - ); - transform.scaleY = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.SCALE_Y, - 1.0, - ); + transform.scaleX = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE_X, 1.0); + transform.scaleY = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE_Y, 1.0); }; - ObjectDataParser.prototype._parseColorTransform = function(rawData, color) { - color.alphaMultiplier = - ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.ALPHA_MULTIPLIER, - 100, - ) * 0.01; - color.redMultiplier = - ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.RED_MULTIPLIER, - 100, - ) * 0.01; - color.greenMultiplier = - ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.GREEN_MULTIPLIER, - 100, - ) * 0.01; - color.blueMultiplier = - ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.BLUE_MULTIPLIER, - 100, - ) * 0.01; - color.alphaOffset = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.ALPHA_OFFSET, - 0, - ); - color.redOffset = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.RED_OFFSET, - 0, - ); - color.greenOffset = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.GREEN_OFFSET, - 0, - ); - color.blueOffset = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.BLUE_OFFSET, - 0, - ); + ObjectDataParser.prototype._parseColorTransform = function (rawData, color) { + color.alphaMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA_MULTIPLIER, 100) * 0.01; + color.redMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.RED_MULTIPLIER, 100) * 0.01; + color.greenMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.GREEN_MULTIPLIER, 100) * 0.01; + color.blueMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.BLUE_MULTIPLIER, 100) * 0.01; + color.alphaOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA_OFFSET, 0); + color.redOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.RED_OFFSET, 0); + color.greenOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.GREEN_OFFSET, 0); + color.blueOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.BLUE_OFFSET, 0); }; - ObjectDataParser.prototype._parseGeometry = function(rawData, geometry) { + ObjectDataParser.prototype._parseGeometry = function (rawData, geometry) { var rawVertices = rawData[dragonBones.DataParser.VERTICES]; var vertexCount = Math.floor(rawVertices.length / 2); // uint var triangleCount = 0; @@ -15956,12 +14151,8 @@ if (!Date.now) { geometry.data = this._data; // this._intArray.length += 1 + 1 + 1 + 1; - this._intArray[ - geometryOffset + 0 /* GeometryVertexCount */ - ] = vertexCount; - this._intArray[ - geometryOffset + 2 /* GeometryFloatOffset */ - ] = verticesOffset; + this._intArray[geometryOffset + 0 /* GeometryVertexCount */] = vertexCount; + this._intArray[geometryOffset + 2 /* GeometryFloatOffset */] = verticesOffset; this._intArray[geometryOffset + 3 /* GeometryWeightOffset */] = -1; // // this._floatArray.length += vertexCount * 2; @@ -15974,14 +14165,11 @@ if (!Date.now) { // this._intArray.length += triangleCount * 3; for (var i = 0, l = triangleCount * 3; i < l; ++i) { - this._intArray[geometryOffset + 4 /* GeometryVertexIndices */ + i] = - rawTriangles[i]; + this._intArray[geometryOffset + 4 /* GeometryVertexIndices */ + i] = rawTriangles[i]; } } // Fill triangle count. - this._intArray[ - geometryOffset + 1 /* GeometryTriangleCount */ - ] = triangleCount; + this._intArray[geometryOffset + 1 /* GeometryTriangleCount */] = triangleCount; if (dragonBones.DataParser.UVS in rawData) { var rawUVs = rawData[dragonBones.DataParser.UVS]; var uvOffset = verticesOffset + vertexCount * 2; @@ -15997,13 +14185,10 @@ if (!Date.now) { var floatOffset = this._floatArray.length; var weightBoneCount = 0; var sortedBones = this._armature.sortedBones; - var weight = dragonBones.BaseObject.borrowObject( - dragonBones.WeightData, - ); + var weight = dragonBones.BaseObject.borrowObject(dragonBones.WeightData); weight.count = weightCount; weight.offset = weightOffset; - this._intArray.length += - 1 + 1 + weightBoneCount + vertexCount + weightCount; + this._intArray.length += 1 + 1 + weightBoneCount + vertexCount + weightCount; this._intArray[weightOffset + 1 /* WeigthFloatOffset */] = floatOffset; if (dragonBones.DataParser.BONE_POSE in rawData) { var rawSlotPose = rawData[dragonBones.DataParser.SLOT_POSE]; @@ -16016,17 +14201,12 @@ if (!Date.now) { var bone = this._rawBones[rawBoneIndex]; weight.addBone(bone); weightBoneIndices[i] = rawBoneIndex; - this._intArray[ - weightOffset + 2 /* WeigthBoneIndices */ + i - ] = sortedBones.indexOf(bone); + this._intArray[weightOffset + 2 /* WeigthBoneIndices */ + i] = sortedBones.indexOf(bone); } this._floatArray.length += weightCount * 3; this._helpMatrixA.copyFromArray(rawSlotPose, 0); for ( - var i = 0, - iW = 0, - iB = weightOffset + 2 /* WeigthBoneIndices */ + weightBoneCount, - iV = floatOffset; + var i = 0, iW = 0, iB = weightOffset + 2 /* WeigthBoneIndices */ + weightBoneCount, iV = floatOffset; i < vertexCount; ++i ) { @@ -16056,9 +14236,7 @@ if (!Date.now) { var rawBoneIndex = rawBones[i]; var bone = this._rawBones[rawBoneIndex]; weight.addBone(bone); - this._intArray[ - weightOffset + 2 /* WeigthBoneIndices */ + i - ] = sortedBones.indexOf(bone); + this._intArray[weightOffset + 2 /* WeigthBoneIndices */ + i] = sortedBones.indexOf(bone); } this._floatArray.length += weightCount * 3; for ( @@ -16087,7 +14265,7 @@ if (!Date.now) { geometry.weight = weight; } }; - ObjectDataParser.prototype._parseArray = function(rawData) { + ObjectDataParser.prototype._parseArray = function (rawData) { // tslint:disable-next-line:no-unused-expression rawData; this._intArray.length = 0; @@ -16098,7 +14276,7 @@ if (!Date.now) { this._timelineArray.length = 0; this._colorArray.length = 0; }; - ObjectDataParser.prototype._modifyArray = function() { + ObjectDataParser.prototype._modifyArray = function () { // Align. if (this._intArray.length % Int16Array.BYTES_PER_ELEMENT !== 0) { this._intArray.push(0); @@ -16127,31 +14305,11 @@ if (!Date.now) { var binary = new ArrayBuffer(lTotal); var intArray = new Int16Array(binary, 0, this._intArray.length); var floatArray = new Float32Array(binary, l1, this._floatArray.length); - var frameIntArray = new Int16Array( - binary, - l1 + l2, - this._frameIntArray.length, - ); - var frameFloatArray = new Float32Array( - binary, - l1 + l2 + l3, - this._frameFloatArray.length, - ); - var frameArray = new Int16Array( - binary, - l1 + l2 + l3 + l4, - this._frameArray.length, - ); - var timelineArray = new Uint16Array( - binary, - l1 + l2 + l3 + l4 + l5, - this._timelineArray.length, - ); - var colorArray = new Int16Array( - binary, - l1 + l2 + l3 + l4 + l5 + l6, - this._colorArray.length, - ); + var frameIntArray = new Int16Array(binary, l1 + l2, this._frameIntArray.length); + var frameFloatArray = new Float32Array(binary, l1 + l2 + l3, this._frameFloatArray.length); + var frameArray = new Int16Array(binary, l1 + l2 + l3 + l4, this._frameArray.length); + var timelineArray = new Uint16Array(binary, l1 + l2 + l3 + l4 + l5, this._timelineArray.length); + var colorArray = new Int16Array(binary, l1 + l2 + l3 + l4 + l5 + l6, this._colorArray.length); for (var i = 0, l = this._intArray.length; i < l; ++i) { intArray[i] = this._intArray[i]; } @@ -16183,39 +14341,21 @@ if (!Date.now) { this._data.colorArray = colorArray; this._defaultColorOffset = -1; }; - ObjectDataParser.prototype.parseDragonBonesData = function(rawData, scale) { + ObjectDataParser.prototype.parseDragonBonesData = function (rawData, scale) { if (scale === void 0) { scale = 1; } console.assert(rawData !== null && rawData !== undefined, 'Data error.'); - var version = ObjectDataParser._getString( - rawData, - dragonBones.DataParser.VERSION, - '', - ); - var compatibleVersion = ObjectDataParser._getString( - rawData, - dragonBones.DataParser.COMPATIBLE_VERSION, - '', - ); + var version = ObjectDataParser._getString(rawData, dragonBones.DataParser.VERSION, ''); + var compatibleVersion = ObjectDataParser._getString(rawData, dragonBones.DataParser.COMPATIBLE_VERSION, ''); if ( dragonBones.DataParser.DATA_VERSIONS.indexOf(version) >= 0 || dragonBones.DataParser.DATA_VERSIONS.indexOf(compatibleVersion) >= 0 ) { - var data = dragonBones.BaseObject.borrowObject( - dragonBones.DragonBonesData, - ); + var data = dragonBones.BaseObject.borrowObject(dragonBones.DragonBonesData); data.version = version; - data.name = ObjectDataParser._getString( - rawData, - dragonBones.DataParser.NAME, - '', - ); - data.frameRate = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.FRAME_RATE, - 24, - ); + data.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ''); + data.frameRate = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FRAME_RATE, 24); if (data.frameRate === 0) { data.frameRate = 24; } @@ -16223,11 +14363,7 @@ if (!Date.now) { this._data = data; this._parseArray(rawData); var rawArmatures = rawData[dragonBones.DataParser.ARMATURE]; - for ( - var _i = 0, rawArmatures_1 = rawArmatures; - _i < rawArmatures_1.length; - _i++ - ) { + for (var _i = 0, rawArmatures_1 = rawArmatures; _i < rawArmatures_1.length; _i++) { var rawArmature = rawArmatures_1[_i]; data.addArmature(this._parseArmature(rawArmature, scale)); } @@ -16235,21 +14371,14 @@ if (!Date.now) { this._modifyArray(); } if (dragonBones.DataParser.STAGE in rawData) { - data.stage = data.getArmature( - ObjectDataParser._getString( - rawData, - dragonBones.DataParser.STAGE, - '', - ), - ); + data.stage = data.getArmature(ObjectDataParser._getString(rawData, dragonBones.DataParser.STAGE, '')); } else if (data.armatureNames.length > 0) { data.stage = data.getArmature(data.armatureNames[0]); } this._data = null; } if (dragonBones.DataParser.TEXTURE_ATLAS in rawData) { - this._rawTextureAtlases = - rawData[dragonBones.DataParser.TEXTURE_ATLAS]; + this._rawTextureAtlases = rawData[dragonBones.DataParser.TEXTURE_ATLAS]; } return data; } else { @@ -16264,25 +14393,16 @@ if (!Date.now) { } return null; }; - ObjectDataParser.prototype.parseTextureAtlasData = function( - rawData, - textureAtlasData, - scale, - ) { + ObjectDataParser.prototype.parseTextureAtlasData = function (rawData, textureAtlasData, scale) { if (scale === void 0) { scale = 1.0; } console.assert(rawData !== undefined); if (rawData === null) { - if ( - this._rawTextureAtlases === null || - this._rawTextureAtlases.length === 0 - ) { + if (this._rawTextureAtlases === null || this._rawTextureAtlases.length === 0) { return false; } - var rawTextureAtlas = this._rawTextureAtlases[ - this._rawTextureAtlasIndex++ - ]; + var rawTextureAtlas = this._rawTextureAtlases[this._rawTextureAtlasIndex++]; this.parseTextureAtlasData(rawTextureAtlas, textureAtlasData, scale); if (this._rawTextureAtlasIndex >= this._rawTextureAtlases.length) { this._rawTextureAtlasIndex = 0; @@ -16291,92 +14411,29 @@ if (!Date.now) { return true; } // Texture format. - textureAtlasData.width = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.WIDTH, - 0, - ); - textureAtlasData.height = ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.HEIGHT, - 0, - ); + textureAtlasData.width = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WIDTH, 0); + textureAtlasData.height = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.HEIGHT, 0); textureAtlasData.scale = - scale === 1.0 - ? 1.0 / - ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.SCALE, - 1.0, - ) - : scale; - textureAtlasData.name = ObjectDataParser._getString( - rawData, - dragonBones.DataParser.NAME, - '', - ); - textureAtlasData.imagePath = ObjectDataParser._getString( - rawData, - dragonBones.DataParser.IMAGE_PATH, - '', - ); + scale === 1.0 ? 1.0 / ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0) : scale; + textureAtlasData.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ''); + textureAtlasData.imagePath = ObjectDataParser._getString(rawData, dragonBones.DataParser.IMAGE_PATH, ''); if (dragonBones.DataParser.SUB_TEXTURE in rawData) { var rawTextures = rawData[dragonBones.DataParser.SUB_TEXTURE]; for (var i = 0, l = rawTextures.length; i < l; ++i) { var rawTexture = rawTextures[i]; - var frameWidth = ObjectDataParser._getNumber( - rawTexture, - dragonBones.DataParser.FRAME_WIDTH, - -1.0, - ); - var frameHeight = ObjectDataParser._getNumber( - rawTexture, - dragonBones.DataParser.FRAME_HEIGHT, - -1.0, - ); + var frameWidth = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_WIDTH, -1.0); + var frameHeight = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_HEIGHT, -1.0); var textureData = textureAtlasData.createTexture(); - textureData.rotated = ObjectDataParser._getBoolean( - rawTexture, - dragonBones.DataParser.ROTATED, - false, - ); - textureData.name = ObjectDataParser._getString( - rawTexture, - dragonBones.DataParser.NAME, - '', - ); - textureData.region.x = ObjectDataParser._getNumber( - rawTexture, - dragonBones.DataParser.X, - 0.0, - ); - textureData.region.y = ObjectDataParser._getNumber( - rawTexture, - dragonBones.DataParser.Y, - 0.0, - ); - textureData.region.width = ObjectDataParser._getNumber( - rawTexture, - dragonBones.DataParser.WIDTH, - 0.0, - ); - textureData.region.height = ObjectDataParser._getNumber( - rawTexture, - dragonBones.DataParser.HEIGHT, - 0.0, - ); + textureData.rotated = ObjectDataParser._getBoolean(rawTexture, dragonBones.DataParser.ROTATED, false); + textureData.name = ObjectDataParser._getString(rawTexture, dragonBones.DataParser.NAME, ''); + textureData.region.x = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.X, 0.0); + textureData.region.y = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.Y, 0.0); + textureData.region.width = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.WIDTH, 0.0); + textureData.region.height = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.HEIGHT, 0.0); if (frameWidth > 0.0 && frameHeight > 0.0) { textureData.frame = dragonBones.TextureData.createRectangle(); - textureData.frame.x = ObjectDataParser._getNumber( - rawTexture, - dragonBones.DataParser.FRAME_X, - 0.0, - ); - textureData.frame.y = ObjectDataParser._getNumber( - rawTexture, - dragonBones.DataParser.FRAME_Y, - 0.0, - ); + textureData.frame.x = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_X, 0.0); + textureData.frame.y = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_Y, 0.0); textureData.frame.width = frameWidth; textureData.frame.height = frameHeight; } @@ -16395,7 +14452,7 @@ if (!Date.now) { * @deprecated * @language zh_CN */ - ObjectDataParser.getInstance = function() { + ObjectDataParser.getInstance = function () { if (ObjectDataParser._objectDataParserInstance === null) { ObjectDataParser._objectDataParserInstance = new ObjectDataParser(); } @@ -16408,7 +14465,7 @@ if (!Date.now) { /** * @private */ - var ActionFrame = /** @class */ (function() { + var ActionFrame = /** @class */ (function () { function ActionFrame() { this.frameStart = 0; this.actions = []; @@ -16440,19 +14497,19 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * @private */ - var BinaryDataParser = /** @class */ (function(_super) { + var BinaryDataParser = /** @class */ (function (_super) { __extends(BinaryDataParser, _super); function BinaryDataParser() { return (_super !== null && _super.apply(this, arguments)) || this; } - BinaryDataParser.prototype._inRange = function(a, min, max) { + BinaryDataParser.prototype._inRange = function (a, min, max) { return min <= a && a <= max; }; - BinaryDataParser.prototype._decodeUTF8 = function(data) { + BinaryDataParser.prototype._decodeUTF8 = function (data) { var EOF_byte = -1; var EOF_code_point = -1; var FATAL_POINT = 0xfffd; @@ -16490,8 +14547,7 @@ if (!Date.now) { utf8_code_point = _byte - 0xf0; } else { } - utf8_code_point = - utf8_code_point * Math.pow(64, utf8_bytes_needed); + utf8_code_point = utf8_code_point * Math.pow(64, utf8_bytes_needed); code_point = null; } } else if (!this._inRange(_byte, 0x80, 0xbf)) { @@ -16503,10 +14559,7 @@ if (!Date.now) { code_point = _byte; } else { utf8_bytes_seen += 1; - utf8_code_point = - utf8_code_point + - (_byte - 0x80) * - Math.pow(64, utf8_bytes_needed - utf8_bytes_seen); + utf8_code_point = utf8_code_point + (_byte - 0x80) * Math.pow(64, utf8_bytes_needed - utf8_bytes_seen); if (utf8_bytes_seen !== utf8_bytes_needed) { code_point = null; } else { @@ -16516,10 +14569,7 @@ if (!Date.now) { utf8_bytes_needed = 0; utf8_bytes_seen = 0; utf8_lower_boundary = 0; - if ( - this._inRange(cp, lower_boundary, 0x10ffff) && - !this._inRange(cp, 0xd800, 0xdfff) - ) { + if (this._inRange(cp, lower_boundary, 0x10ffff) && !this._inRange(cp, 0xd800, 0xdfff)) { code_point = cp; } else { code_point = _byte; @@ -16533,33 +14583,23 @@ if (!Date.now) { if (code_point > 0) result += String.fromCharCode(code_point); } else { code_point -= 0x10000; - result += String.fromCharCode( - 0xd800 + ((code_point >> 10) & 0x3ff), - ); + result += String.fromCharCode(0xd800 + ((code_point >> 10) & 0x3ff)); result += String.fromCharCode(0xdc00 + (code_point & 0x3ff)); } } } return result; }; - BinaryDataParser.prototype._parseBinaryTimeline = function( - type, - offset, - timelineData, - ) { + BinaryDataParser.prototype._parseBinaryTimeline = function (type, offset, timelineData) { if (timelineData === void 0) { timelineData = null; } var timeline = - timelineData !== null - ? timelineData - : dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); + timelineData !== null ? timelineData : dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); timeline.type = type; timeline.offset = offset; this._timeline = timeline; - var keyFrameCount = this._timelineArrayBuffer[ - timeline.offset + 2 /* TimelineKeyFrameCount */ - ]; + var keyFrameCount = this._timelineArrayBuffer[timeline.offset + 2 /* TimelineKeyFrameCount */]; if (keyFrameCount === 1) { timeline.frameIndicesOffset = -1; } else { @@ -16569,27 +14609,20 @@ if (!Date.now) { frameIndicesOffset = frameIndices.length; frameIndices.length += totalFrameCount; timeline.frameIndicesOffset = frameIndicesOffset; - for ( - var i = 0, iK = 0, frameStart = 0, frameCount = 0; - i < totalFrameCount; - ++i - ) { + for (var i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { if (frameStart + frameCount <= i && iK < keyFrameCount) { - frameStart = this._frameArrayBuffer[ - this._animation.frameOffset + - this._timelineArrayBuffer[ - timeline.offset + 5 /* TimelineFrameOffset */ + iK - ] - ]; + frameStart = + this._frameArrayBuffer[ + this._animation.frameOffset + + this._timelineArrayBuffer[timeline.offset + 5 /* TimelineFrameOffset */ + iK] + ]; if (iK === keyFrameCount - 1) { frameCount = this._animation.frameCount - frameStart; } else { frameCount = this._frameArrayBuffer[ this._animation.frameOffset + - this._timelineArrayBuffer[ - timeline.offset + 5 /* TimelineFrameOffset */ + iK + 1 - ] + this._timelineArrayBuffer[timeline.offset + 5 /* TimelineFrameOffset */ + iK + 1] ] - frameStart; } iK++; @@ -16600,38 +14633,16 @@ if (!Date.now) { this._timeline = null; // return timeline; }; - BinaryDataParser.prototype._parseAnimation = function(rawData) { - var animation = dragonBones.BaseObject.borrowObject( - dragonBones.AnimationData, - ); + BinaryDataParser.prototype._parseAnimation = function (rawData) { + var animation = dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); animation.blendType = dragonBones.DataParser._getAnimationBlendType( - dragonBones.ObjectDataParser._getString( - rawData, - dragonBones.DataParser.BLEND_TYPE, - '', - ), - ); - animation.frameCount = dragonBones.ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.DURATION, - 0, - ); - animation.playTimes = dragonBones.ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.PLAY_TIMES, - 1, + dragonBones.ObjectDataParser._getString(rawData, dragonBones.DataParser.BLEND_TYPE, ''), ); + animation.frameCount = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DURATION, 0); + animation.playTimes = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.PLAY_TIMES, 1); animation.duration = animation.frameCount / this._armature.frameRate; // float - animation.fadeInTime = dragonBones.ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.FADE_IN_TIME, - 0.0, - ); - animation.scale = dragonBones.ObjectDataParser._getNumber( - rawData, - dragonBones.DataParser.SCALE, - 1.0, - ); + animation.fadeInTime = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FADE_IN_TIME, 0.0); + animation.scale = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0); animation.name = dragonBones.ObjectDataParser._getString( rawData, dragonBones.DataParser.NAME, @@ -16647,16 +14658,10 @@ if (!Date.now) { animation.frameOffset = offsets[2]; this._animation = animation; if (dragonBones.DataParser.ACTION in rawData) { - animation.actionTimeline = this._parseBinaryTimeline( - 0 /* Action */, - rawData[dragonBones.DataParser.ACTION], - ); + animation.actionTimeline = this._parseBinaryTimeline(0 /* Action */, rawData[dragonBones.DataParser.ACTION]); } if (dragonBones.DataParser.Z_ORDER in rawData) { - animation.zOrderTimeline = this._parseBinaryTimeline( - 1 /* ZOrder */, - rawData[dragonBones.DataParser.Z_ORDER], - ); + animation.zOrderTimeline = this._parseBinaryTimeline(1 /* ZOrder */, rawData[dragonBones.DataParser.Z_ORDER]); } if (dragonBones.DataParser.BONE in rawData) { var rawTimeliness = rawData[dragonBones.DataParser.BONE]; @@ -16669,10 +14674,7 @@ if (!Date.now) { for (var i = 0, l = rawTimelines.length; i < l; i += 2) { var timelineType = rawTimelines[i]; var timelineOffset = rawTimelines[i + 1]; - var timeline = this._parseBinaryTimeline( - timelineType, - timelineOffset, - ); + var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); this._animation.addBoneTimeline(bone.name, timeline); } } @@ -16688,10 +14690,7 @@ if (!Date.now) { for (var i = 0, l = rawTimelines.length; i < l; i += 2) { var timelineType = rawTimelines[i]; var timelineOffset = rawTimelines[i + 1]; - var timeline = this._parseBinaryTimeline( - timelineType, - timelineOffset, - ); + var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); this._animation.addSlotTimeline(slot.name, timeline); } } @@ -16707,63 +14706,31 @@ if (!Date.now) { for (var i = 0, l = rawTimelines.length; i < l; i += 2) { var timelineType = rawTimelines[i]; var timelineOffset = rawTimelines[i + 1]; - var timeline = this._parseBinaryTimeline( - timelineType, - timelineOffset, - ); + var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); this._animation.addConstraintTimeline(constraint.name, timeline); } } } if (dragonBones.DataParser.TIMELINE in rawData) { var rawTimelines = rawData[dragonBones.DataParser.TIMELINE]; - for ( - var _i = 0, rawTimelines_6 = rawTimelines; - _i < rawTimelines_6.length; - _i++ - ) { + for (var _i = 0, rawTimelines_6 = rawTimelines; _i < rawTimelines_6.length; _i++) { var rawTimeline = rawTimelines_6[_i]; - var timelineOffset = dragonBones.ObjectDataParser._getNumber( - rawTimeline, - dragonBones.DataParser.OFFSET, - 0, - ); + var timelineOffset = dragonBones.ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.OFFSET, 0); if (timelineOffset >= 0) { var timelineType = dragonBones.ObjectDataParser._getNumber( rawTimeline, dragonBones.DataParser.TYPE, 0 /* Action */, ); - var timelineName = dragonBones.ObjectDataParser._getString( - rawTimeline, - dragonBones.DataParser.NAME, - '', - ); + var timelineName = dragonBones.ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ''); var timeline = null; - if ( - timelineType === 40 /* AnimationProgress */ && - animation.blendType !== 0 /* None */ - ) { - timeline = dragonBones.BaseObject.borrowObject( - dragonBones.AnimationTimelineData, - ); + if (timelineType === 40 /* AnimationProgress */ && animation.blendType !== 0 /* None */) { + timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationTimelineData); var animaitonTimeline = timeline; - animaitonTimeline.x = dragonBones.ObjectDataParser._getNumber( - rawTimeline, - dragonBones.DataParser.X, - 0.0, - ); - animaitonTimeline.y = dragonBones.ObjectDataParser._getNumber( - rawTimeline, - dragonBones.DataParser.Y, - 0.0, - ); + animaitonTimeline.x = dragonBones.ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.X, 0.0); + animaitonTimeline.y = dragonBones.ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.Y, 0.0); } - timeline = this._parseBinaryTimeline( - timelineType, - timelineOffset, - timeline, - ); + timeline = this._parseBinaryTimeline(timelineType, timelineOffset, timeline); switch (timelineType) { case 0 /* Action */: // TODO @@ -16800,31 +14767,20 @@ if (!Date.now) { this._animation = null; return animation; }; - BinaryDataParser.prototype._parseGeometry = function(rawData, geometry) { + BinaryDataParser.prototype._parseGeometry = function (rawData, geometry) { geometry.offset = rawData[dragonBones.DataParser.OFFSET]; geometry.data = this._data; - var weightOffset = this._intArrayBuffer[ - geometry.offset + 3 /* GeometryWeightOffset */ - ]; + var weightOffset = this._intArrayBuffer[geometry.offset + 3 /* GeometryWeightOffset */]; if (weightOffset >= 0) { - var weight = dragonBones.BaseObject.borrowObject( - dragonBones.WeightData, - ); - var vertexCount = this._intArrayBuffer[ - geometry.offset + 0 /* GeometryVertexCount */ - ]; - var boneCount = this._intArrayBuffer[ - weightOffset + 0 /* WeigthBoneCount */ - ]; + var weight = dragonBones.BaseObject.borrowObject(dragonBones.WeightData); + var vertexCount = this._intArrayBuffer[geometry.offset + 0 /* GeometryVertexCount */]; + var boneCount = this._intArrayBuffer[weightOffset + 0 /* WeigthBoneCount */]; weight.offset = weightOffset; for (var i = 0; i < boneCount; ++i) { - var boneIndex = this._intArrayBuffer[ - weightOffset + 2 /* WeigthBoneIndices */ + i - ]; + var boneIndex = this._intArrayBuffer[weightOffset + 2 /* WeigthBoneIndices */ + i]; weight.addBone(this._rawBones[boneIndex]); } - var boneIndicesOffset = - weightOffset + 2 /* WeigthBoneIndices */ + boneCount; + var boneIndicesOffset = weightOffset + 2 /* WeigthBoneIndices */ + boneCount; var weightCount = 0; for (var i = 0, l = vertexCount; i < l; ++i) { var vertexBoneCount = this._intArrayBuffer[boneIndicesOffset++]; @@ -16835,7 +14791,7 @@ if (!Date.now) { geometry.weight = weight; } }; - BinaryDataParser.prototype._parseArray = function(rawData) { + BinaryDataParser.prototype._parseArray = function (rawData) { var offsets = rawData[dragonBones.DataParser.OFFSET]; var l1 = offsets[1]; var l2 = offsets[3]; @@ -16844,11 +14800,7 @@ if (!Date.now) { var l5 = offsets[9]; var l6 = offsets[11]; var l7 = offsets.length > 12 ? offsets[13] : 0; // Color. - var intArray = new Int16Array( - this._binary, - this._binaryOffset + offsets[0], - l1 / Int16Array.BYTES_PER_ELEMENT, - ); + var intArray = new Int16Array(this._binary, this._binaryOffset + offsets[0], l1 / Int16Array.BYTES_PER_ELEMENT); var floatArray = new Float32Array( this._binary, this._binaryOffset + offsets[2], @@ -16864,11 +14816,7 @@ if (!Date.now) { this._binaryOffset + offsets[6], l4 / Float32Array.BYTES_PER_ELEMENT, ); - var frameArray = new Int16Array( - this._binary, - this._binaryOffset + offsets[8], - l5 / Int16Array.BYTES_PER_ELEMENT, - ); + var frameArray = new Int16Array(this._binary, this._binaryOffset + offsets[8], l5 / Int16Array.BYTES_PER_ELEMENT); var timelineArray = new Uint16Array( this._binary, this._binaryOffset + offsets[10], @@ -16876,11 +14824,7 @@ if (!Date.now) { ); var colorArray = l7 > 0 - ? new Int16Array( - this._binary, - this._binaryOffset + offsets[12], - l7 / Int16Array.BYTES_PER_ELEMENT, - ) + ? new Int16Array(this._binary, this._binaryOffset + offsets[12], l7 / Int16Array.BYTES_PER_ELEMENT) : intArray; // Color. this._data.binary = this._binary; this._data.intArray = this._intArrayBuffer = intArray; @@ -16891,16 +14835,11 @@ if (!Date.now) { this._data.timelineArray = this._timelineArrayBuffer = timelineArray; this._data.colorArray = colorArray; }; - BinaryDataParser.prototype.parseDragonBonesData = function(rawData, scale) { + BinaryDataParser.prototype.parseDragonBonesData = function (rawData, scale) { if (scale === void 0) { scale = 1; } - console.assert( - rawData !== null && - rawData !== undefined && - rawData instanceof ArrayBuffer, - 'Data error.', - ); + console.assert(rawData !== null && rawData !== undefined && rawData instanceof ArrayBuffer, 'Data error.'); var tag = new Uint8Array(rawData, 0, 8); if ( tag[0] !== 'D'.charCodeAt(0) || @@ -16930,7 +14869,7 @@ if (!Date.now) { * @deprecated * @language zh_CN */ - BinaryDataParser.getInstance = function() { + BinaryDataParser.getInstance = function () { if (BinaryDataParser._binaryDataParserInstance === null) { BinaryDataParser._binaryDataParserInstance = new BinaryDataParser(); } @@ -16964,7 +14903,7 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * - Base class for the factory that create the armatures. (Typically only one global factory instance is required) * The factory instance create armatures by parsed and added DragonBonesData instances and TextureAtlasData instances. @@ -16987,7 +14926,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - var BaseFactory = /** @class */ (function() { + var BaseFactory = /** @class */ (function () { /** * - Create a factory instance. (typically only one global factory instance is required) * @version DragonBones 3.0 @@ -17016,22 +14955,14 @@ if (!Date.now) { if (BaseFactory._binaryParser === null) { BaseFactory._binaryParser = new dragonBones.BinaryDataParser(); } - this._dataParser = - dataParser !== null ? dataParser : BaseFactory._objectParser; + this._dataParser = dataParser !== null ? dataParser : BaseFactory._objectParser; } - BaseFactory.prototype._isSupportMesh = function() { + BaseFactory.prototype._isSupportMesh = function () { return true; }; - BaseFactory.prototype._getTextureData = function( - textureAtlasName, - textureName, - ) { + BaseFactory.prototype._getTextureData = function (textureAtlasName, textureName) { if (textureAtlasName in this._textureAtlasDataMap) { - for ( - var _i = 0, _a = this._textureAtlasDataMap[textureAtlasName]; - _i < _a.length; - _i++ - ) { + for (var _i = 0, _a = this._textureAtlasDataMap[textureAtlasName]; _i < _a.length; _i++) { var textureAtlasData = _a[_i]; var textureData = textureAtlasData.getTexture(textureName); if (textureData !== null) { @@ -17041,11 +14972,7 @@ if (!Date.now) { } if (this.autoSearch) { for (var k in this._textureAtlasDataMap) { - for ( - var _b = 0, _c = this._textureAtlasDataMap[k]; - _b < _c.length; - _b++ - ) { + for (var _b = 0, _c = this._textureAtlasDataMap[k]; _b < _c.length; _b++) { var textureAtlasData = _c[_b]; if (textureAtlasData.autoSearch) { var textureData = textureAtlasData.getTexture(textureName); @@ -17058,7 +14985,7 @@ if (!Date.now) { } return null; }; - BaseFactory.prototype._fillBuildArmaturePackage = function( + BaseFactory.prototype._fillBuildArmaturePackage = function ( dataPackage, dragonBonesName, armatureName, @@ -17073,10 +15000,7 @@ if (!Date.now) { armatureData = dragonBonesData.getArmature(armatureName); } } - if ( - armatureData === null && - (dragonBonesName.length === 0 || this.autoSearch) - ) { + if (armatureData === null && (dragonBonesName.length === 0 || this.autoSearch)) { for (var k in this._dragonBonesDataMap) { dragonBonesData = this._dragonBonesDataMap[k]; if (dragonBonesName.length === 0 || dragonBonesData.autoSearch) { @@ -17114,17 +15038,11 @@ if (!Date.now) { } return false; }; - BaseFactory.prototype._buildBones = function(dataPackage, armature) { - for ( - var _i = 0, _a = dataPackage.armature.sortedBones; - _i < _a.length; - _i++ - ) { + BaseFactory.prototype._buildBones = function (dataPackage, armature) { + for (var _i = 0, _a = dataPackage.armature.sortedBones; _i < _a.length; _i++) { var boneData = _a[_i]; var bone = dragonBones.BaseObject.borrowObject( - boneData.type === 0 /* Bone */ - ? dragonBones.Bone - : dragonBones.Surface, + boneData.type === 0 /* Bone */ ? dragonBones.Bone : dragonBones.Surface, ); bone.init(boneData, armature); } @@ -17132,7 +15050,7 @@ if (!Date.now) { /** * @private */ - BaseFactory.prototype._buildSlots = function(dataPackage, armature) { + BaseFactory.prototype._buildSlots = function (dataPackage, armature) { var currentSkin = dataPackage.skin; var defaultSkin = dataPackage.armature.defaultSkin; if (currentSkin === null || defaultSkin === null) { @@ -17149,14 +15067,9 @@ if (!Date.now) { skinSlots[k] = displays; } } - for ( - var _i = 0, _a = dataPackage.armature.sortedSlots; - _i < _a.length; - _i++ - ) { + for (var _i = 0, _a = dataPackage.armature.sortedSlots; _i < _a.length; _i++) { var slotData = _a[_i]; - var displayDatas = - slotData.name in skinSlots ? skinSlots[slotData.name] : null; + var displayDatas = slotData.name in skinSlots ? skinSlots[slotData.name] : null; var slot = this._buildSlot(dataPackage, slotData, armature); if (displayDatas !== null) { slot.displayFrameCount = displayDatas.length; @@ -17165,17 +15078,10 @@ if (!Date.now) { slot.replaceRawDisplayData(displayData, i); if (displayData !== null) { if (dataPackage.textureAtlasName.length > 0) { - var textureData = this._getTextureData( - dataPackage.textureAtlasName, - displayData.path, - ); + var textureData = this._getTextureData(dataPackage.textureAtlasName, displayData.path); slot.replaceTextureData(textureData, i); } - var display = this._getSlotDisplay( - dataPackage, - displayData, - slot, - ); + var display = this._getSlotDisplay(dataPackage, displayData, slot); slot.replaceDisplay(display, i); } else { slot.replaceDisplay(null); @@ -17185,41 +15091,31 @@ if (!Date.now) { slot._setDisplayIndex(slotData.displayIndex, true); } }; - BaseFactory.prototype._buildConstraints = function(dataPackage, armature) { + BaseFactory.prototype._buildConstraints = function (dataPackage, armature) { var constraints = dataPackage.armature.constraints; for (var k in constraints) { var constraintData = constraints[k]; // TODO more constraint type. switch (constraintData.type) { case 0 /* IK */: - var ikConstraint = dragonBones.BaseObject.borrowObject( - dragonBones.IKConstraint, - ); + var ikConstraint = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraint); ikConstraint.init(constraintData, armature); armature._addConstraint(ikConstraint); break; case 1 /* Path */: - var pathConstraint = dragonBones.BaseObject.borrowObject( - dragonBones.PathConstraint, - ); + var pathConstraint = dragonBones.BaseObject.borrowObject(dragonBones.PathConstraint); pathConstraint.init(constraintData, armature); armature._addConstraint(pathConstraint); break; default: - var constraint = dragonBones.BaseObject.borrowObject( - dragonBones.IKConstraint, - ); + var constraint = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraint); constraint.init(constraintData, armature); armature._addConstraint(constraint); break; } } }; - BaseFactory.prototype._buildChildArmature = function( - dataPackage, - _slot, - displayData, - ) { + BaseFactory.prototype._buildChildArmature = function (dataPackage, _slot, displayData) { return this.buildArmature( displayData.path, dataPackage !== null ? dataPackage.dataName : '', @@ -17227,24 +15123,14 @@ if (!Date.now) { dataPackage !== null ? dataPackage.textureAtlasName : '', ); }; - BaseFactory.prototype._getSlotDisplay = function( - dataPackage, - displayData, - slot, - ) { - var dataName = - dataPackage !== null - ? dataPackage.dataName - : displayData.parent.parent.parent.name; + BaseFactory.prototype._getSlotDisplay = function (dataPackage, displayData, slot) { + var dataName = dataPackage !== null ? dataPackage.dataName : displayData.parent.parent.parent.name; var display = null; switch (displayData.type) { case 0 /* Image */: { var imageDisplayData = displayData; if (imageDisplayData.texture === null) { - imageDisplayData.texture = this._getTextureData( - dataName, - displayData.path, - ); + imageDisplayData.texture = this._getTextureData(dataName, displayData.path); } display = slot.rawDisplay; break; @@ -17252,10 +15138,7 @@ if (!Date.now) { case 2 /* Mesh */: { var meshDisplayData = displayData; if (meshDisplayData.texture === null) { - meshDisplayData.texture = this._getTextureData( - dataName, - meshDisplayData.path, - ); + meshDisplayData.texture = this._getTextureData(dataName, meshDisplayData.path); } if (this._isSupportMesh()) { display = slot.meshDisplay; @@ -17266,34 +15149,19 @@ if (!Date.now) { } case 1 /* Armature */: { var armatureDisplayData = displayData; - var childArmature = this._buildChildArmature( - dataPackage, - slot, - armatureDisplayData, - ); + var childArmature = this._buildChildArmature(dataPackage, slot, armatureDisplayData); if (childArmature !== null) { - childArmature.inheritAnimation = - armatureDisplayData.inheritAnimation; + childArmature.inheritAnimation = armatureDisplayData.inheritAnimation; if (!childArmature.inheritAnimation) { var actions = armatureDisplayData.actions.length > 0 ? armatureDisplayData.actions : childArmature.armatureData.defaultActions; if (actions.length > 0) { - for ( - var _i = 0, actions_6 = actions; - _i < actions_6.length; - _i++ - ) { + for (var _i = 0, actions_6 = actions; _i < actions_6.length; _i++) { var action = actions_6[_i]; - var eventObject = dragonBones.BaseObject.borrowObject( - dragonBones.EventObject, - ); - dragonBones.EventObject.actionDataToInstance( - action, - eventObject, - slot.armature, - ); + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + dragonBones.EventObject.actionDataToInstance(action, eventObject, slot.armature); eventObject.slot = slot; slot.armature._bufferAction(eventObject, false); } @@ -17339,21 +15207,14 @@ if (!Date.now) { * @version DragonBones 4.5 * @language zh_CN */ - BaseFactory.prototype.parseDragonBonesData = function( - rawData, - name, - scale, - ) { + BaseFactory.prototype.parseDragonBonesData = function (rawData, name, scale) { if (name === void 0) { name = null; } if (scale === void 0) { scale = 1.0; } - var dataParser = - rawData instanceof ArrayBuffer - ? BaseFactory._binaryParser - : this._dataParser; + var dataParser = rawData instanceof ArrayBuffer ? BaseFactory._binaryParser : this._dataParser; var dragonBonesData = dataParser.parseDragonBonesData(rawData, scale); while (true) { var textureAtlasData = this._buildTextureAtlasData(null, null); @@ -17397,12 +15258,7 @@ if (!Date.now) { * @version DragonBones 4.5 * @language zh_CN */ - BaseFactory.prototype.parseTextureAtlasData = function( - rawData, - textureAtlas, - name, - scale, - ) { + BaseFactory.prototype.parseTextureAtlasData = function (rawData, textureAtlas, name, scale) { if (name === void 0) { name = null; } @@ -17429,18 +15285,12 @@ if (!Date.now) { * @version DragonBones 5.7 * @language zh_CN */ - BaseFactory.prototype.updateTextureAtlases = function( - textureAtlases, - name, - ) { + BaseFactory.prototype.updateTextureAtlases = function (textureAtlases, name) { var textureAtlasDatas = this.getTextureAtlasData(name); if (textureAtlasDatas !== null) { for (var i = 0, l = textureAtlasDatas.length; i < l; ++i) { if (i < textureAtlases.length) { - this._buildTextureAtlasData( - textureAtlasDatas[i], - textureAtlases[i], - ); + this._buildTextureAtlasData(textureAtlasDatas[i], textureAtlases[i]); } } } @@ -17467,10 +15317,8 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - BaseFactory.prototype.getDragonBonesData = function(name) { - return name in this._dragonBonesDataMap - ? this._dragonBonesDataMap[name] - : null; + BaseFactory.prototype.getDragonBonesData = function (name) { + return name in this._dragonBonesDataMap ? this._dragonBonesDataMap[name] : null; }; /** * - Cache a DragonBonesData instance to the factory. @@ -17494,7 +15342,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - BaseFactory.prototype.addDragonBonesData = function(data, name) { + BaseFactory.prototype.addDragonBonesData = function (data, name) { if (name === void 0) { name = null; } @@ -17530,7 +15378,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - BaseFactory.prototype.removeDragonBonesData = function(name, disposeData) { + BaseFactory.prototype.removeDragonBonesData = function (name, disposeData) { if (disposeData === void 0) { disposeData = true; } @@ -17561,10 +15409,8 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - BaseFactory.prototype.getTextureAtlasData = function(name) { - return name in this._textureAtlasDataMap - ? this._textureAtlasDataMap[name] - : null; + BaseFactory.prototype.getTextureAtlasData = function (name) { + return name in this._textureAtlasDataMap ? this._textureAtlasDataMap[name] : null; }; /** * - Cache a TextureAtlasData instance to the factory. @@ -17588,15 +15434,13 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - BaseFactory.prototype.addTextureAtlasData = function(data, name) { + BaseFactory.prototype.addTextureAtlasData = function (data, name) { if (name === void 0) { name = null; } name = name !== null ? name : data.name; var textureAtlasList = - name in this._textureAtlasDataMap - ? this._textureAtlasDataMap[name] - : (this._textureAtlasDataMap[name] = []); + name in this._textureAtlasDataMap ? this._textureAtlasDataMap[name] : (this._textureAtlasDataMap[name] = []); if (textureAtlasList.indexOf(data) < 0) { textureAtlasList.push(data); } @@ -17623,18 +15467,14 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - BaseFactory.prototype.removeTextureAtlasData = function(name, disposeData) { + BaseFactory.prototype.removeTextureAtlasData = function (name, disposeData) { if (disposeData === void 0) { disposeData = true; } if (name in this._textureAtlasDataMap) { var textureAtlasDataList = this._textureAtlasDataMap[name]; if (disposeData) { - for ( - var _i = 0, textureAtlasDataList_1 = textureAtlasDataList; - _i < textureAtlasDataList_1.length; - _i++ - ) { + for (var _i = 0, textureAtlasDataList_1 = textureAtlasDataList; _i < textureAtlasDataList_1.length; _i++) { var textureAtlasData = textureAtlasDataList_1[_i]; this._dragonBones.bufferObject(textureAtlasData); } @@ -17658,20 +15498,12 @@ if (!Date.now) { * @version DragonBones 5.1 * @language zh_CN */ - BaseFactory.prototype.getArmatureData = function(name, dragonBonesName) { + BaseFactory.prototype.getArmatureData = function (name, dragonBonesName) { if (dragonBonesName === void 0) { dragonBonesName = ''; } var dataPackage = new BuildArmaturePackage(); - if ( - !this._fillBuildArmaturePackage( - dataPackage, - dragonBonesName, - name, - '', - '', - ) - ) { + if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName, name, '', '')) { return null; } return dataPackage.armature; @@ -17688,7 +15520,7 @@ if (!Date.now) { * @version DragonBones 4.5 * @language zh_CN */ - BaseFactory.prototype.clear = function(disposeData) { + BaseFactory.prototype.clear = function (disposeData) { if (disposeData === void 0) { disposeData = true; } @@ -17701,11 +15533,7 @@ if (!Date.now) { for (var k in this._textureAtlasDataMap) { if (disposeData) { var textureAtlasDataList = this._textureAtlasDataMap[k]; - for ( - var _i = 0, textureAtlasDataList_2 = textureAtlasDataList; - _i < textureAtlasDataList_2.length; - _i++ - ) { + for (var _i = 0, textureAtlasDataList_2 = textureAtlasDataList; _i < textureAtlasDataList_2.length; _i++) { var textureAtlasData = textureAtlasDataList_2[_i]; this._dragonBones.bufferObject(textureAtlasData); } @@ -17747,12 +15575,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - BaseFactory.prototype.buildArmature = function( - armatureName, - dragonBonesName, - skinName, - textureAtlasName, - ) { + BaseFactory.prototype.buildArmature = function (armatureName, dragonBonesName, skinName, textureAtlasName) { if (dragonBonesName === void 0) { dragonBonesName = ''; } @@ -17772,12 +15595,7 @@ if (!Date.now) { textureAtlasName || '', ) ) { - console.warn( - 'No armature data: ' + - armatureName + - ', ' + - (dragonBonesName !== null ? dragonBonesName : ''), - ); + console.warn('No armature data: ' + armatureName + ', ' + (dragonBonesName !== null ? dragonBonesName : '')); return null; } var armature = this._buildArmature(dataPackage); @@ -17791,11 +15609,7 @@ if (!Date.now) { /** * @private */ - BaseFactory.prototype.replaceDisplay = function( - slot, - displayData, - displayIndex, - ) { + BaseFactory.prototype.replaceDisplay = function (slot, displayData, displayIndex) { if (displayIndex === void 0) { displayIndex = -1; } @@ -17809,8 +15623,7 @@ if (!Date.now) { if (displayData !== null) { var display = this._getSlotDisplay(null, displayData, slot); if (displayData.type === 0 /* Image */) { - var rawDisplayData = slot.getDisplayFrameAt(displayIndex) - .rawDisplayData; + var rawDisplayData = slot.getDisplayFrameAt(displayIndex).rawDisplayData; if (rawDisplayData !== null && rawDisplayData.type === 2 /* Mesh */) { display = slot.meshDisplay; } @@ -17854,7 +15667,7 @@ if (!Date.now) { * @version DragonBones 4.5 * @language zh_CN */ - BaseFactory.prototype.replaceSlotDisplay = function( + BaseFactory.prototype.replaceSlotDisplay = function ( dragonBonesName, armatureName, slotName, @@ -17865,33 +15678,19 @@ if (!Date.now) { if (displayIndex === void 0) { displayIndex = -1; } - var armatureData = this.getArmatureData( - armatureName, - dragonBonesName || '', - ); + var armatureData = this.getArmatureData(armatureName, dragonBonesName || ''); if (armatureData === null || armatureData.defaultSkin === null) { return false; } - var displayData = armatureData.defaultSkin.getDisplay( - slotName, - displayName, - ); + var displayData = armatureData.defaultSkin.getDisplay(slotName, displayName); this.replaceDisplay(slot, displayData, displayIndex); return true; }; /** * @private */ - BaseFactory.prototype.replaceSlotDisplayList = function( - dragonBonesName, - armatureName, - slotName, - slot, - ) { - var armatureData = this.getArmatureData( - armatureName, - dragonBonesName || '', - ); + BaseFactory.prototype.replaceSlotDisplayList = function (dragonBonesName, armatureName, slotName, slot) { + var armatureData = this.getArmatureData(armatureName, dragonBonesName || ''); if (!armatureData || !armatureData.defaultSkin) { return false; } @@ -17944,12 +15743,7 @@ if (!Date.now) { * @version DragonBones 5.6 * @language zh_CN */ - BaseFactory.prototype.replaceSkin = function( - armature, - skin, - isOverride, - exclude, - ) { + BaseFactory.prototype.replaceSkin = function (armature, skin, isOverride, exclude) { if (isOverride === void 0) { isOverride = false; } @@ -17980,10 +15774,7 @@ if (!Date.now) { var displayData = displayDatas[i]; slot.replaceRawDisplayData(displayData, i); if (displayData !== null) { - slot.replaceDisplay( - this._getSlotDisplay(null, displayData, slot), - i, - ); + slot.replaceDisplay(this._getSlotDisplay(null, displayData, slot), i); } else { slot.replaceDisplay(null, i); } @@ -18030,11 +15821,7 @@ if (!Date.now) { * @version DragonBones 5.6 * @language zh_CN */ - BaseFactory.prototype.replaceAnimation = function( - armature, - armatureData, - isOverride, - ) { + BaseFactory.prototype.replaceAnimation = function (armature, armatureData, isOverride) { if (isOverride === void 0) { isOverride = true; } @@ -18064,14 +15851,8 @@ if (!Date.now) { var displayDatas = skinData.getDisplays(slot.name); if (displayDatas !== null && index < displayDatas.length) { var displayData = displayDatas[index]; - if ( - displayData !== null && - displayData.type === 1 /* Armature */ - ) { - var childArmatureData = this.getArmatureData( - displayData.path, - displayData.parent.parent.parent.name, - ); + if (displayData !== null && displayData.type === 1 /* Armature */) { + var childArmatureData = this.getArmatureData(displayData.path, displayData.parent.parent.parent.name); if (childArmatureData) { this.replaceAnimation(display, childArmatureData, isOverride); } @@ -18086,13 +15867,13 @@ if (!Date.now) { /** * @private */ - BaseFactory.prototype.getAllDragonBonesData = function() { + BaseFactory.prototype.getAllDragonBonesData = function () { return this._dragonBonesDataMap; }; /** * @private */ - BaseFactory.prototype.getAllTextureAtlasData = function() { + BaseFactory.prototype.getAllTextureAtlasData = function () { return this._textureAtlasDataMap; }; Object.defineProperty(BaseFactory.prototype, 'clock', { @@ -18106,7 +15887,7 @@ if (!Date.now) { * @version DragonBones 5.7 * @language zh_CN */ - get: function() { + get: function () { return this._dragonBones.clock; }, enumerable: true, @@ -18116,7 +15897,7 @@ if (!Date.now) { /** * @private */ - get: function() { + get: function () { return this._dragonBones; }, enumerable: true, @@ -18130,7 +15911,7 @@ if (!Date.now) { /** * @private */ - var BuildArmaturePackage = /** @class */ (function() { + var BuildArmaturePackage = /** @class */ (function () { function BuildArmaturePackage() { this.dataName = ''; this.textureAtlasName = ''; @@ -18163,7 +15944,7 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * - The PixiJS texture atlas data. * @version DragonBones 3.0 @@ -18174,17 +15955,17 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - var PixiTextureAtlasData = /** @class */ (function(_super) { + var PixiTextureAtlasData = /** @class */ (function (_super) { __extends(PixiTextureAtlasData, _super); function PixiTextureAtlasData() { var _this = (_super !== null && _super.apply(this, arguments)) || this; _this._renderTexture = null; // Initial value. return _this; } - PixiTextureAtlasData.toString = function() { + PixiTextureAtlasData.toString = function () { return '[class dragonBones.PixiTextureAtlasData]'; }; - PixiTextureAtlasData.prototype._onClear = function() { + PixiTextureAtlasData.prototype._onClear = function () { _super.prototype._onClear.call(this); if (this._renderTexture !== null) { // this._renderTexture.dispose(); @@ -18194,7 +15975,7 @@ if (!Date.now) { /** * @inheritDoc */ - PixiTextureAtlasData.prototype.createTexture = function() { + PixiTextureAtlasData.prototype.createTexture = function () { return dragonBones.BaseObject.borrowObject(PixiTextureData); }; Object.defineProperty(PixiTextureAtlasData.prototype, 'renderTexture', { @@ -18208,10 +15989,10 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - get: function() { + get: function () { return this._renderTexture; }, - set: function(value) { + set: function (value) { if (this._renderTexture === value) { return; } @@ -18233,12 +16014,7 @@ if (!Date.now) { textureData.region.width, textureData.region.height, ), - new PIXI.Rectangle( - 0, - 0, - textureData.region.width, - textureData.region.height, - ), + new PIXI.Rectangle(0, 0, textureData.region.width, textureData.region.height), textureData.rotated, // .d.ts bug ); } @@ -18258,17 +16034,17 @@ if (!Date.now) { /** * @internal */ - var PixiTextureData = /** @class */ (function(_super) { + var PixiTextureData = /** @class */ (function (_super) { __extends(PixiTextureData, _super); function PixiTextureData() { var _this = (_super !== null && _super.apply(this, arguments)) || this; _this.renderTexture = null; // Initial value. return _this; } - PixiTextureData.toString = function() { + PixiTextureData.toString = function () { return '[class dragonBones.PixiTextureData]'; }; - PixiTextureData.prototype._onClear = function() { + PixiTextureData.prototype._onClear = function () { _super.prototype._onClear.call(this); if (this.renderTexture !== null) { this.renderTexture.destroy(false); @@ -18302,11 +16078,11 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * @inheritDoc */ - var PixiArmatureDisplay = /** @class */ (function(_super) { + var PixiArmatureDisplay = /** @class */ (function (_super) { __extends(PixiArmatureDisplay, _super); function PixiArmatureDisplay() { var _this = (_super !== null && _super.apply(this, arguments)) || this; @@ -18323,13 +16099,13 @@ if (!Date.now) { /** * @inheritDoc */ - PixiArmatureDisplay.prototype.dbInit = function(armature) { + PixiArmatureDisplay.prototype.dbInit = function (armature) { this._armature = armature; }; /** * @inheritDoc */ - PixiArmatureDisplay.prototype.dbClear = function() { + PixiArmatureDisplay.prototype.dbClear = function () { if (this._debugDrawer !== null) { this._debugDrawer.destroy(true); } @@ -18340,7 +16116,7 @@ if (!Date.now) { /** * @inheritDoc */ - PixiArmatureDisplay.prototype.dbUpdate = function() { + PixiArmatureDisplay.prototype.dbUpdate = function () { var drawed = dragonBones.DragonBones.debugDraw || this.debugDraw; if (drawed || this._debugDraw) { this._debugDraw = drawed; @@ -18401,11 +16177,7 @@ if (!Date.now) { break; case 2 /* Polygon */: var vertices = boundingBoxData.vertices; - for ( - var i_4 = 0, l_1 = vertices.length; - i_4 < l_1; - i_4 += 2 - ) { + for (var i_4 = 0, l_1 = vertices.length; i_4 < l_1; i_4 += 2) { var x = vertices[i_4]; var y = vertices[i_4 + 1]; if (i_4 === 0) { @@ -18441,10 +16213,7 @@ if (!Date.now) { } } } - } else if ( - this._debugDrawer !== null && - this._debugDrawer.parent === this - ) { + } else if (this._debugDrawer !== null && this._debugDrawer.parent === this) { this.removeChild(this._debugDrawer); } } @@ -18452,7 +16221,7 @@ if (!Date.now) { /** * @inheritDoc */ - PixiArmatureDisplay.prototype.dispose = function(disposeProxy) { + PixiArmatureDisplay.prototype.dispose = function (disposeProxy) { if (disposeProxy === void 0) { disposeProxy = true; } @@ -18466,49 +16235,38 @@ if (!Date.now) { /** * @inheritDoc */ - PixiArmatureDisplay.prototype.destroy = function() { + PixiArmatureDisplay.prototype.destroy = function () { this.dispose(); }; /** * @private */ - PixiArmatureDisplay.prototype.dispatchDBEvent = function( - type, - eventObject, - ) { + PixiArmatureDisplay.prototype.dispatchDBEvent = function (type, eventObject) { this.emit(type, eventObject); }; /** * @inheritDoc */ - PixiArmatureDisplay.prototype.hasDBEventListener = function(type) { + PixiArmatureDisplay.prototype.hasDBEventListener = function (type) { return this.listeners(type, true); // .d.ts bug }; /** * @inheritDoc */ - PixiArmatureDisplay.prototype.addDBEventListener = function( - type, - listener, - target, - ) { + PixiArmatureDisplay.prototype.addDBEventListener = function (type, listener, target) { this.addListener(type, listener, target); }; /** * @inheritDoc */ - PixiArmatureDisplay.prototype.removeDBEventListener = function( - type, - listener, - target, - ) { + PixiArmatureDisplay.prototype.removeDBEventListener = function (type, listener, target) { this.removeListener(type, listener, target); }; Object.defineProperty(PixiArmatureDisplay.prototype, 'armature', { /** * @inheritDoc */ - get: function() { + get: function () { return this._armature; }, enumerable: true, @@ -18518,7 +16276,7 @@ if (!Date.now) { /** * @inheritDoc */ - get: function() { + get: function () { return this._armature.animation; }, enumerable: true, @@ -18551,7 +16309,7 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * - The PixiJS slot. * @version DragonBones 3.0 @@ -18562,41 +16320,41 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - var PixiSlot = /** @class */ (function(_super) { + var PixiSlot = /** @class */ (function (_super) { __extends(PixiSlot, _super); function PixiSlot() { return (_super !== null && _super.apply(this, arguments)) || this; } - PixiSlot.toString = function() { + PixiSlot.toString = function () { return '[class dragonBones.PixiSlot]'; }; - PixiSlot.prototype._onClear = function() { + PixiSlot.prototype._onClear = function () { _super.prototype._onClear.call(this); this._textureScale = 1.0; this._renderDisplay = null; this._updateTransform = this._updateTransformV4; }; - PixiSlot.prototype._initDisplay = function(value, isRetain) { + PixiSlot.prototype._initDisplay = function (value, isRetain) { // tslint:disable-next-line:no-unused-expression value; // tslint:disable-next-line:no-unused-expression isRetain; }; - PixiSlot.prototype._disposeDisplay = function(value, isRelease) { + PixiSlot.prototype._disposeDisplay = function (value, isRelease) { // tslint:disable-next-line:no-unused-expression value; if (!isRelease) { value.destroy(); } }; - PixiSlot.prototype._onUpdateDisplay = function() { + PixiSlot.prototype._onUpdateDisplay = function () { this._renderDisplay = this._display ? this._display : this._rawDisplay; }; - PixiSlot.prototype._addDisplay = function() { + PixiSlot.prototype._addDisplay = function () { var container = this._armature.display; container.addChild(this._renderDisplay); }; - PixiSlot.prototype._replaceDisplay = function(value) { + PixiSlot.prototype._replaceDisplay = function (value) { var container = this._armature.display; var prevDisplay = value; container.addChild(this._renderDisplay); @@ -18604,10 +16362,10 @@ if (!Date.now) { container.removeChild(prevDisplay); this._textureScale = 1.0; }; - PixiSlot.prototype._removeDisplay = function() { + PixiSlot.prototype._removeDisplay = function () { this._renderDisplay.parent.removeChild(this._renderDisplay); }; - PixiSlot.prototype._updateZOrder = function() { + PixiSlot.prototype._updateZOrder = function () { var container = this._armature.display; var index = container.getChildIndex(this._renderDisplay); if (index === this._zOrder) { @@ -18618,10 +16376,10 @@ if (!Date.now) { /** * @internal */ - PixiSlot.prototype._updateVisible = function() { + PixiSlot.prototype._updateVisible = function () { this._renderDisplay.visible = this._parent.visible && this._visible; }; - PixiSlot.prototype._updateBlendMode = function() { + PixiSlot.prototype._updateBlendMode = function () { if (this._renderDisplay instanceof PIXI.Sprite) { switch (this._blendMode) { case 0 /* Normal */: @@ -18657,13 +16415,10 @@ if (!Date.now) { } // TODO child armature. }; - PixiSlot.prototype._updateColor = function() { + PixiSlot.prototype._updateColor = function () { var alpha = this._colorTransform.alphaMultiplier * this._globalAlpha; this._renderDisplay.alpha = alpha; - if ( - this._renderDisplay instanceof PIXI.Sprite || - this._renderDisplay instanceof PIXI.mesh.Mesh - ) { + if (this._renderDisplay instanceof PIXI.Sprite || this._renderDisplay instanceof PIXI.mesh.Mesh) { var color = (Math.round(this._colorTransform.redMultiplier * 0xff) << 16) + (Math.round(this._colorTransform.greenMultiplier * 0xff) << 8) + @@ -18672,28 +16427,20 @@ if (!Date.now) { } // TODO child armature. }; - PixiSlot.prototype._updateFrame = function() { + PixiSlot.prototype._updateFrame = function () { var currentTextureData = this._textureData; - if ( - this._displayIndex >= 0 && - this._display !== null && - currentTextureData !== null - ) { + if (this._displayIndex >= 0 && this._display !== null && currentTextureData !== null) { var currentTextureAtlasData = currentTextureData.parent; if (this._armature.replacedTexture !== null) { if (this._armature._replaceTextureAtlasData === null) { - currentTextureAtlasData = dragonBones.BaseObject.borrowObject( - dragonBones.PixiTextureAtlasData, - ); + currentTextureAtlasData = dragonBones.BaseObject.borrowObject(dragonBones.PixiTextureAtlasData); currentTextureAtlasData.copyFrom(currentTextureData.parent); currentTextureAtlasData.renderTexture = this._armature.replacedTexture; this._armature._replaceTextureAtlasData = currentTextureAtlasData; } else { currentTextureAtlasData = this._armature._replaceTextureAtlasData; } - currentTextureData = currentTextureAtlasData.getTexture( - currentTextureData.name, - ); + currentTextureData = currentTextureAtlasData.getTexture(currentTextureData.name); } var renderTexture = currentTextureData.renderTexture; if (renderTexture !== null) { @@ -18701,14 +16448,9 @@ if (!Date.now) { var data = this._geometryData.data; var intArray = data.intArray; var floatArray = data.floatArray; - var vertexCount = - intArray[this._geometryData.offset + 0 /* GeometryVertexCount */]; - var triangleCount = - intArray[ - this._geometryData.offset + 1 /* GeometryTriangleCount */ - ]; - var vertexOffset = - intArray[this._geometryData.offset + 2 /* GeometryFloatOffset */]; + var vertexCount = intArray[this._geometryData.offset + 0 /* GeometryVertexCount */]; + var triangleCount = intArray[this._geometryData.offset + 1 /* GeometryTriangleCount */]; + var vertexOffset = intArray[this._geometryData.offset + 2 /* GeometryFloatOffset */]; if (vertexOffset < 0) { vertexOffset += 65536; // Fixed out of bouds bug. } @@ -18716,13 +16458,9 @@ if (!Date.now) { var scale = this._armature._armatureData.scale; var meshDisplay = this._renderDisplay; var textureAtlasWidth = - currentTextureAtlasData.width > 0.0 - ? currentTextureAtlasData.width - : renderTexture.baseTexture.width; + currentTextureAtlasData.width > 0.0 ? currentTextureAtlasData.width : renderTexture.baseTexture.width; var textureAtlasHeight = - currentTextureAtlasData.height > 0.0 - ? currentTextureAtlasData.height - : renderTexture.baseTexture.height; + currentTextureAtlasData.height > 0.0 ? currentTextureAtlasData.height : renderTexture.baseTexture.height; var region = currentTextureData.region; meshDisplay.vertices = new Float32Array(vertexCount * 2); meshDisplay.uvs = new Float32Array(vertexCount * 2); @@ -18731,24 +16469,17 @@ if (!Date.now) { meshDisplay.vertices[i] = floatArray[vertexOffset + i] * scale; } for (var i = 0; i < triangleCount * 3; ++i) { - meshDisplay.indices[i] = - intArray[ - this._geometryData.offset + 4 /* GeometryVertexIndices */ + i - ]; + meshDisplay.indices[i] = intArray[this._geometryData.offset + 4 /* GeometryVertexIndices */ + i]; } for (var i = 0, l = vertexCount * 2; i < l; i += 2) { var u = floatArray[uvOffset + i]; var v = floatArray[uvOffset + i + 1]; if (currentTextureData.rotated) { - meshDisplay.uvs[i] = - (region.x + (1.0 - v) * region.width) / textureAtlasWidth; - meshDisplay.uvs[i + 1] = - (region.y + u * region.height) / textureAtlasHeight; + meshDisplay.uvs[i] = (region.x + (1.0 - v) * region.width) / textureAtlasWidth; + meshDisplay.uvs[i + 1] = (region.y + u * region.height) / textureAtlasHeight; } else { - meshDisplay.uvs[i] = - (region.x + u * region.width) / textureAtlasWidth; - meshDisplay.uvs[i + 1] = - (region.y + v * region.height) / textureAtlasHeight; + meshDisplay.uvs[i] = (region.x + u * region.width) / textureAtlasWidth; + meshDisplay.uvs[i + 1] = (region.y + v * region.height) / textureAtlasHeight; } } this._textureScale = 1.0; @@ -18761,9 +16492,7 @@ if (!Date.now) { this._identityTransform(); } } else { - this._textureScale = - currentTextureData.parent.scale * - this._armature._armatureData.scale; + this._textureScale = currentTextureData.parent.scale * this._armature._armatureData.scale; var normalDisplay = this._renderDisplay; normalDisplay.texture = renderTexture; } @@ -18785,7 +16514,7 @@ if (!Date.now) { normalDisplay.visible = false; } }; - PixiSlot.prototype._updateMesh = function() { + PixiSlot.prototype._updateMesh = function () { var scale = this._armature._armatureData.scale; var deformVertices = this._displayFrame.deformVertices; var bones = this._geometryBones; @@ -18797,10 +16526,8 @@ if (!Date.now) { var data = geometryData.data; var intArray = data.intArray; var floatArray = data.floatArray; - var vertexCount = - intArray[geometryData.offset + 0 /* GeometryVertexCount */]; - var weightFloatOffset = - intArray[weightData.offset + 1 /* WeigthFloatOffset */]; + var vertexCount = intArray[geometryData.offset + 0 /* GeometryVertexCount */]; + var weightFloatOffset = intArray[weightData.offset + 1 /* WeigthFloatOffset */]; if (weightFloatOffset < 0) { weightFloatOffset += 65536; // Fixed out of bouds bug. } @@ -18840,10 +16567,8 @@ if (!Date.now) { var data = geometryData.data; var intArray = data.intArray; var floatArray = data.floatArray; - var vertexCount = - intArray[geometryData.offset + 0 /* GeometryVertexCount */]; - var vertexOffset = - intArray[geometryData.offset + 2 /* GeometryFloatOffset */]; + var vertexCount = intArray[geometryData.offset + 0 /* GeometryVertexCount */]; + var vertexOffset = intArray[geometryData.offset + 2 /* GeometryFloatOffset */]; if (vertexOffset < 0) { vertexOffset += 65536; // Fixed out of bouds bug. } @@ -18857,8 +16582,7 @@ if (!Date.now) { if (isSurface) { var matrix = this._parent._getGlobalTransformMatrix(x, y); meshDisplay.vertices[i] = matrix.a * x + matrix.c * y + matrix.tx; - meshDisplay.vertices[i + 1] = - matrix.b * x + matrix.d * y + matrix.ty; + meshDisplay.vertices[i + 1] = matrix.b * x + matrix.d * y + matrix.ty; } else { meshDisplay.vertices[i] = x; meshDisplay.vertices[i + 1] = y; @@ -18866,24 +16590,17 @@ if (!Date.now) { } } }; - PixiSlot.prototype._updateTransform = function() { + PixiSlot.prototype._updateTransform = function () { throw new Error(); }; - PixiSlot.prototype._updateTransformV3 = function() { + PixiSlot.prototype._updateTransformV3 = function () { this.updateGlobalTransform(); // Update transform. var transform = this.global; - if ( - this._renderDisplay === this._rawDisplay || - this._renderDisplay === this._meshDisplay - ) { + if (this._renderDisplay === this._rawDisplay || this._renderDisplay === this._meshDisplay) { var x = - transform.x - - (this.globalTransformMatrix.a * this._pivotX + - this.globalTransformMatrix.c * this._pivotY); + transform.x - (this.globalTransformMatrix.a * this._pivotX + this.globalTransformMatrix.c * this._pivotY); var y = - transform.y - - (this.globalTransformMatrix.b * this._pivotX + - this.globalTransformMatrix.d * this._pivotY); + transform.y - (this.globalTransformMatrix.b * this._pivotX + this.globalTransformMatrix.d * this._pivotY); this._renderDisplay.setTransform( x, y, @@ -18900,21 +16617,14 @@ if (!Date.now) { this._renderDisplay.scale.set(transform.scaleX, transform.scaleY); } }; - PixiSlot.prototype._updateTransformV4 = function() { + PixiSlot.prototype._updateTransformV4 = function () { this.updateGlobalTransform(); // Update transform. var transform = this.global; - if ( - this._renderDisplay === this._rawDisplay || - this._renderDisplay === this._meshDisplay - ) { + if (this._renderDisplay === this._rawDisplay || this._renderDisplay === this._meshDisplay) { var x = - transform.x - - (this.globalTransformMatrix.a * this._pivotX + - this.globalTransformMatrix.c * this._pivotY); + transform.x - (this.globalTransformMatrix.a * this._pivotX + this.globalTransformMatrix.c * this._pivotY); var y = - transform.y - - (this.globalTransformMatrix.b * this._pivotX + - this.globalTransformMatrix.d * this._pivotY); + transform.y - (this.globalTransformMatrix.b * this._pivotX + this.globalTransformMatrix.d * this._pivotY); this._renderDisplay.setTransform( x, y, @@ -18931,7 +16641,7 @@ if (!Date.now) { this._renderDisplay.scale.set(transform.scaleX, transform.scaleY); } }; - PixiSlot.prototype._identityTransform = function() { + PixiSlot.prototype._identityTransform = function () { this._renderDisplay.setTransform(0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0); }; return PixiSlot; @@ -18961,7 +16671,7 @@ if (!Date.now) { * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -(function(dragonBones) { +(function (dragonBones) { /** * - The PixiJS factory. * @version DragonBones 3.0 @@ -18972,7 +16682,7 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - var PixiFactory = /** @class */ (function(_super) { + var PixiFactory = /** @class */ (function (_super) { __extends(PixiFactory, _super); /** * @inheritDoc @@ -18984,18 +16694,14 @@ if (!Date.now) { var _this = _super.call(this, dataParser) || this; if (PixiFactory._dragonBonesInstance === null) { var eventManager = new dragonBones.PixiArmatureDisplay(); - PixiFactory._dragonBonesInstance = new dragonBones.DragonBones( - eventManager, - ); + PixiFactory._dragonBonesInstance = new dragonBones.DragonBones(eventManager); // PIXI.ticker.shared.add(PixiFactory._clockHandler, PixiFactory); } _this._dragonBones = PixiFactory._dragonBonesInstance; return _this; } - PixiFactory._clockHandler = function(passedTime) { - this._dragonBonesInstance.advanceTime( - PIXI.ticker.shared.elapsedMS * passedTime * 0.001, - ); + PixiFactory._clockHandler = function (passedTime) { + this._dragonBonesInstance.advanceTime(PIXI.ticker.shared.elapsedMS * passedTime * 0.001); }; Object.defineProperty(PixiFactory, 'factory', { /** @@ -19008,7 +16714,7 @@ if (!Date.now) { * @version DragonBones 4.7 * @language zh_CN */ - get: function() { + get: function () { if (PixiFactory._factory === null) { PixiFactory._factory = new PixiFactory(); } @@ -19017,47 +16723,27 @@ if (!Date.now) { enumerable: true, configurable: true, }); - PixiFactory.prototype._buildTextureAtlasData = function( - textureAtlasData, - textureAtlas, - ) { + PixiFactory.prototype._buildTextureAtlasData = function (textureAtlasData, textureAtlas) { if (textureAtlasData) { textureAtlasData.renderTexture = textureAtlas; } else { - textureAtlasData = dragonBones.BaseObject.borrowObject( - dragonBones.PixiTextureAtlasData, - ); + textureAtlasData = dragonBones.BaseObject.borrowObject(dragonBones.PixiTextureAtlasData); } return textureAtlasData; }; - PixiFactory.prototype._buildArmature = function(dataPackage) { + PixiFactory.prototype._buildArmature = function (dataPackage) { var armature = dragonBones.BaseObject.borrowObject(dragonBones.Armature); var armatureDisplay = new dragonBones.PixiArmatureDisplay(); - armature.init( - dataPackage.armature, - armatureDisplay, - armatureDisplay, - this._dragonBones, - ); + armature.init(dataPackage.armature, armatureDisplay, armatureDisplay, this._dragonBones); return armature; }; - PixiFactory.prototype._buildSlot = function( - _dataPackage, - slotData, - armature, - ) { + PixiFactory.prototype._buildSlot = function (_dataPackage, slotData, armature) { var slot = dragonBones.BaseObject.borrowObject(dragonBones.PixiSlot); slot.init( slotData, armature, new PIXI.Sprite(), - new PIXI.mesh.Mesh( - null, - null, - null, - null, - PIXI.mesh.Mesh.DRAW_MODES.TRIANGLES, - ), + new PIXI.mesh.Mesh(null, null, null, null, PIXI.mesh.Mesh.DRAW_MODES.TRIANGLES), ); return slot; }; @@ -19093,12 +16779,7 @@ if (!Date.now) { * * @language zh_CN */ - PixiFactory.prototype.buildArmatureDisplay = function( - armatureName, - dragonBonesName, - skinName, - textureAtlasName, - ) { + PixiFactory.prototype.buildArmatureDisplay = function (armatureName, dragonBonesName, skinName, textureAtlasName) { if (dragonBonesName === void 0) { dragonBonesName = ''; } @@ -19108,12 +16789,7 @@ if (!Date.now) { if (textureAtlasName === void 0) { textureAtlasName = ''; } - var armature = this.buildArmature( - armatureName, - dragonBonesName || '', - skinName || '', - textureAtlasName || '', - ); + var armature = this.buildArmature(armatureName, dragonBonesName || '', skinName || '', textureAtlasName || ''); if (armature !== null) { this._dragonBones.clock.add(armature); return armature.display; @@ -19134,17 +16810,11 @@ if (!Date.now) { * @version DragonBones 3.0 * @language zh_CN */ - PixiFactory.prototype.getTextureDisplay = function( - textureName, - textureAtlasName, - ) { + PixiFactory.prototype.getTextureDisplay = function (textureName, textureAtlasName) { if (textureAtlasName === void 0) { textureAtlasName = null; } - var textureData = this._getTextureData( - textureAtlasName !== null ? textureAtlasName : '', - textureName, - ); + var textureData = this._getTextureData(textureAtlasName !== null ? textureAtlasName : '', textureName); if (textureData !== null && textureData.renderTexture !== null) { return new PIXI.Sprite(textureData.renderTexture); } @@ -19163,7 +16833,7 @@ if (!Date.now) { * @version DragonBones 4.5 * @language zh_CN */ - get: function() { + get: function () { return this._dragonBones.eventManager; }, enumerable: true, diff --git a/packages/plugin-renderer-dragonbone/lib/engine.ts b/packages/plugin-renderer-dragonbone/lib/engine.ts index 69abb813..b5fa9ab4 100644 --- a/packages/plugin-renderer-dragonbone/lib/engine.ts +++ b/packages/plugin-renderer-dragonbone/lib/engine.ts @@ -3,7 +3,7 @@ import dragonBones from './db'; export default class DragonBone { armature; factory = dragonBones.PixiFactory.factory; - constructor({armatureName}) { + constructor({ armatureName }) { this.armature = this.factory.buildArmatureDisplay(armatureName); } play(name, time) { diff --git a/packages/plugin-renderer-dragonbone/lib/system.ts b/packages/plugin-renderer-dragonbone/lib/system.ts index 1bd08c4d..e7c0c558 100644 --- a/packages/plugin-renderer-dragonbone/lib/system.ts +++ b/packages/plugin-renderer-dragonbone/lib/system.ts @@ -1,18 +1,6 @@ import { Texture, ticker } from 'pixi.js'; -import { - decorators, - resource, - ComponentChanged, - RESOURCE_TYPE, - OBSERVER_TYPE, - Component -} from '@eva/eva.js'; -import { - Renderer, - RendererSystem, - RendererManager, - ContainerManager, -} from '@eva/plugin-renderer'; +import { decorators, resource, ComponentChanged, RESOURCE_TYPE, OBSERVER_TYPE, Component } from '@eva/eva.js'; +import { Renderer, RendererSystem, RendererManager, ContainerManager } from '@eva/plugin-renderer'; import DragonBoneEngine from './engine'; import DragonBoneComponent from './component'; import dragonBones from './db'; @@ -38,7 +26,7 @@ resource.registerInstance(RESOURCE_TYPE.DRAGONBONE, ({ data, name }) => { resource.registerDestroy(RESOURCE_TYPE.DRAGONBONE, ({ name }) => { factory.removeDragonBonesData(name); factory.removeTextureAtlasData(name); -}) +}); @decorators.componentObserver({ DragonBone: ['armatureName'], @@ -55,15 +43,10 @@ export default class DragonBone extends Renderer { init() { this.renderSystem = this.game.getSystem(RendererSystem) as RendererSystem; this.renderSystem.rendererManager.register(this); - ticker.shared.add( - dragonBones.PixiFactory._clockHandler, - dragonBones.PixiFactory, - ); + ticker.shared.add(dragonBones.PixiFactory._clockHandler, dragonBones.PixiFactory); } async componentChanged(changed: ComponentChanged) { - this.autoPlay[ - changed.gameObject.id - ] = (changed.component as DragonBoneComponent).autoPlay; + this.autoPlay[changed.gameObject.id] = (changed.component as DragonBoneComponent).autoPlay; if (changed.componentName === 'DragonBone') { if (changed.type === OBSERVER_TYPE.ADD) { this.add(changed); @@ -84,15 +67,13 @@ export default class DragonBone extends Renderer { await resource.getResource(component.resource); if (this.isRemovedMap.get(component)) { this.isRemovedMap.delete(component); - return + return; } const armature = new DragonBoneEngine({ armatureName: component.armatureName, }); this.armatures[changed.gameObject.id] = armature; - this.renderSystem.containerManager - .getContainer(changed.gameObject.id) - .addChildAt(armature.armature, 0); + this.renderSystem.containerManager.getContainer(changed.gameObject.id).addChildAt(armature.armature, 0); component.armature = armature; for (const key in events) { armature.armature.on(events[key], e => { @@ -114,11 +95,8 @@ export default class DragonBone extends Renderer { this.isRemovedMap.set(changed.component, true); return; } - this.autoPlay[changed.gameObject.id] = - armature.armature.animation.isPlaying; - this.renderSystem.containerManager - .getContainer(changed.gameObject.id) - .removeChild(armature.armature); + this.autoPlay[changed.gameObject.id] = armature.armature.animation.isPlaying; + this.renderSystem.containerManager.getContainer(changed.gameObject.id).removeChild(armature.armature); armature.armature.removeAllListeners(); armature.armature.destroy({ children: true }); const component = changed.component as DragonBoneComponent; diff --git a/packages/plugin-renderer-event/README.md b/packages/plugin-renderer-event/README.md index 6fdd8265..8f26e742 100644 --- a/packages/plugin-renderer-event/README.md +++ b/packages/plugin-renderer-event/README.md @@ -1,7 +1,6 @@ - # @eva/plugin-renderer-event More Introduction + - [EN](https://eva.js.org) - [中文](https://eva-engine.gitee.io) - \ No newline at end of file diff --git a/packages/plugin-renderer-event/api-extractor.json b/packages/plugin-renderer-event/api-extractor.json index 33bdc19e..45d6d97f 100644 --- a/packages/plugin-renderer-event/api-extractor.json +++ b/packages/plugin-renderer-event/api-extractor.json @@ -4,4 +4,4 @@ "dtsRollup": { "publicTrimmedFilePath": "./dist/plugin-renderer-event.d.ts" } -} \ No newline at end of file +} diff --git a/packages/plugin-renderer-event/index.js b/packages/plugin-renderer-event/index.js index c0c6db11..8c2e9a7d 100644 --- a/packages/plugin-renderer-event/index.js +++ b/packages/plugin-renderer-event/index.js @@ -1,7 +1,7 @@ -'use strict' +'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/plugin-renderer-event.cjs.prod.js') + module.exports = require('./dist/plugin-renderer-event.cjs.prod.js'); } else { - module.exports = require('./dist/plugin-renderer-event.cjs.js') + module.exports = require('./dist/plugin-renderer-event.cjs.js'); } diff --git a/packages/plugin-renderer-event/lib/system.ts b/packages/plugin-renderer-event/lib/system.ts index 0ac46a8d..66fdc44e 100644 --- a/packages/plugin-renderer-event/lib/system.ts +++ b/packages/plugin-renderer-event/lib/system.ts @@ -1,6 +1,6 @@ -import {Renderer, RendererSystem, RendererManager, ContainerManager} from '@eva/plugin-renderer'; -import {decorators, ComponentChanged, OBSERVER_TYPE} from '@eva/eva.js'; -import {Circle, Ellipse, Polygon, RoundedRectangle, Rectangle} from 'pixi.js'; +import { Renderer, RendererSystem, RendererManager, ContainerManager } from '@eva/plugin-renderer'; +import { decorators, ComponentChanged, OBSERVER_TYPE } from '@eva/eva.js'; +import { Circle, Ellipse, Polygon, RoundedRectangle, Rectangle } from 'pixi.js'; import EventComponent from './component'; const hitAreaFunc = { @@ -20,7 +20,7 @@ const propertyForHitArea = { }; @decorators.componentObserver({ - Event: [{prop: ['hitArea'], deep: true}], + Event: [{ prop: ['hitArea'], deep: true }], }) export default class Event extends Renderer { static systemName = 'Event'; @@ -28,7 +28,7 @@ export default class Event extends Renderer { renderSystem: RendererSystem; rendererManager: RendererManager; containerManager: ContainerManager; - init({moveWhenInside = false} = {}) { + init({ moveWhenInside = false } = {}) { this.renderSystem = this.game.getSystem(RendererSystem) as RendererSystem; this.renderSystem.rendererManager.register(this); try { @@ -168,7 +168,7 @@ export default class Event extends Renderer { } } addHitArea(changed: ComponentChanged, container, hitArea) { - const {type, style} = hitArea; + const { type, style } = hitArea; if (!hitAreaFunc[type]) { console.error(`${changed.gameObject.name}'s hitArea type is not defined`); return; diff --git a/packages/plugin-renderer-graphics/README.md b/packages/plugin-renderer-graphics/README.md index 887d56fd..3bcbe86e 100644 --- a/packages/plugin-renderer-graphics/README.md +++ b/packages/plugin-renderer-graphics/README.md @@ -1,7 +1,6 @@ - # @eva/plugin-renderer-graphics More Introduction + - [EN](https://eva.js.org) - [中文](https://eva-engine.gitee.io) - \ No newline at end of file diff --git a/packages/plugin-renderer-graphics/api-extractor.json b/packages/plugin-renderer-graphics/api-extractor.json index 29d82ecb..c105e97c 100644 --- a/packages/plugin-renderer-graphics/api-extractor.json +++ b/packages/plugin-renderer-graphics/api-extractor.json @@ -4,4 +4,4 @@ "dtsRollup": { "publicTrimmedFilePath": "./dist/plugin-renderer-graphics.d.ts" } -} \ No newline at end of file +} diff --git a/packages/plugin-renderer-graphics/index.js b/packages/plugin-renderer-graphics/index.js index 2aa1704a..1131af9a 100644 --- a/packages/plugin-renderer-graphics/index.js +++ b/packages/plugin-renderer-graphics/index.js @@ -1,7 +1,7 @@ -'use strict' +'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/plugin-renderer-graphics.cjs.prod.js') + module.exports = require('./dist/plugin-renderer-graphics.cjs.prod.js'); } else { - module.exports = require('./dist/plugin-renderer-graphics.cjs.js') + module.exports = require('./dist/plugin-renderer-graphics.cjs.js'); } diff --git a/packages/plugin-renderer-graphics/lib/component.ts b/packages/plugin-renderer-graphics/lib/component.ts index 6414ee76..3a668282 100644 --- a/packages/plugin-renderer-graphics/lib/component.ts +++ b/packages/plugin-renderer-graphics/lib/component.ts @@ -1,5 +1,5 @@ -import {Component} from '@eva/eva.js'; -import {Graphics as GraphicsEngine} from '@eva/renderer-adapter'; +import { Component } from '@eva/eva.js'; +import { Graphics as GraphicsEngine } from '@eva/renderer-adapter'; export default class Graphics extends Component { static componentName: string = 'Graphics'; diff --git a/packages/plugin-renderer-graphics/lib/index.ts b/packages/plugin-renderer-graphics/lib/index.ts index 96653d0b..a6f9f0a4 100644 --- a/packages/plugin-renderer-graphics/lib/index.ts +++ b/packages/plugin-renderer-graphics/lib/index.ts @@ -1,3 +1,3 @@ import Graphics from './component'; import GraphicsSystem from './system'; -export {Graphics, GraphicsSystem}; +export { Graphics, GraphicsSystem }; diff --git a/packages/plugin-renderer-graphics/lib/system.ts b/packages/plugin-renderer-graphics/lib/system.ts index 6128e8b3..9ed6b10a 100644 --- a/packages/plugin-renderer-graphics/lib/system.ts +++ b/packages/plugin-renderer-graphics/lib/system.ts @@ -1,9 +1,4 @@ -import { - Renderer, - RendererSystem, - RendererManager, - ContainerManager, -} from '@eva/plugin-renderer'; +import { Renderer, RendererSystem, RendererManager, ContainerManager } from '@eva/plugin-renderer'; import { decorators, ComponentChanged, OBSERVER_TYPE } from '@eva/eva.js'; import GraphicsComponent from './component'; @@ -32,7 +27,7 @@ export default class Graphics extends Renderer { this.containerManager .getContainer(changed.gameObject.id) .removeChild((changed.component as GraphicsComponent).graphics); - (changed.component as GraphicsComponent).graphics.destroy({ children: true }) + (changed.component as GraphicsComponent).graphics.destroy({ children: true }); } } } diff --git a/packages/plugin-renderer-img/README.md b/packages/plugin-renderer-img/README.md index 630d9390..0f2d4241 100644 --- a/packages/plugin-renderer-img/README.md +++ b/packages/plugin-renderer-img/README.md @@ -1,7 +1,6 @@ - # @eva/plugin-renderer-img More Introduction + - [EN](https://eva.js.org) - [中文](https://eva-engine.gitee.io) - \ No newline at end of file diff --git a/packages/plugin-renderer-img/api-extractor.json b/packages/plugin-renderer-img/api-extractor.json index ea503425..36f345aa 100644 --- a/packages/plugin-renderer-img/api-extractor.json +++ b/packages/plugin-renderer-img/api-extractor.json @@ -4,4 +4,4 @@ "dtsRollup": { "publicTrimmedFilePath": "./dist/plugin-renderer-img.d.ts" } -} \ No newline at end of file +} diff --git a/packages/plugin-renderer-img/index.js b/packages/plugin-renderer-img/index.js index f89fae8c..44ea3a26 100644 --- a/packages/plugin-renderer-img/index.js +++ b/packages/plugin-renderer-img/index.js @@ -1,7 +1,7 @@ -'use strict' +'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/plugin-renderer-img.cjs.prod.js') + module.exports = require('./dist/plugin-renderer-img.cjs.prod.js'); } else { - module.exports = require('./dist/plugin-renderer-img.cjs.js') + module.exports = require('./dist/plugin-renderer-img.cjs.js'); } diff --git a/packages/plugin-renderer-img/lib/system.ts b/packages/plugin-renderer-img/lib/system.ts index 5352b7cf..c1abc551 100644 --- a/packages/plugin-renderer-img/lib/system.ts +++ b/packages/plugin-renderer-img/lib/system.ts @@ -1,17 +1,5 @@ -import { - GameObject, - decorators, - resource, - ComponentChanged, - RESOURCE_TYPE, - OBSERVER_TYPE, -} from '@eva/eva.js'; -import { - RendererManager, - ContainerManager, - RendererSystem, - Renderer, -} from '@eva/plugin-renderer'; +import { GameObject, decorators, resource, ComponentChanged, RESOURCE_TYPE, OBSERVER_TYPE } from '@eva/eva.js'; +import { RendererManager, ContainerManager, RendererSystem, Renderer } from '@eva/plugin-renderer'; import { Sprite } from '@eva/renderer-adapter'; import { Texture } from 'pixi.js'; import ImgComponent from './component'; @@ -58,30 +46,22 @@ export default class Img extends Renderer { const sprite = new Sprite(null); resource.getResource(component.resource).then(({ instance }) => { if (!instance) { - console.error( - `GameObject:${changed.gameObject.name}'s Img resource load error`, - ); + console.error(`GameObject:${changed.gameObject.name}'s Img resource load error`); } sprite.image = instance; }); this.imgs[changed.gameObject.id] = sprite; - this.containerManager - .getContainer(changed.gameObject.id) - .addChildAt(sprite.sprite, 0); + this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite.sprite, 0); } else if (changed.type === OBSERVER_TYPE.CHANGE) { const { instance } = await resource.getResource(component.resource); if (!instance) { - console.error( - `GameObject:${changed.gameObject.name}'s Img resource load error`, - ); + console.error(`GameObject:${changed.gameObject.name}'s Img resource load error`); } this.imgs[changed.gameObject.id].image = instance; } else if (changed.type === OBSERVER_TYPE.REMOVE) { const sprite = this.imgs[changed.gameObject.id]; - this.containerManager - .getContainer(changed.gameObject.id) - .removeChild(sprite.sprite); - sprite.sprite.destroy({ children: true }) + this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite.sprite); + sprite.sprite.destroy({ children: true }); delete this.imgs[changed.gameObject.id]; } } diff --git a/packages/plugin-renderer-lottie/README.md b/packages/plugin-renderer-lottie/README.md index 446716cd..64dfb7f5 100644 --- a/packages/plugin-renderer-lottie/README.md +++ b/packages/plugin-renderer-lottie/README.md @@ -1,7 +1,6 @@ - # @eva/plugin-renderer-lottie More Introduction + - [EN](https://eva.js.org) - [中文](https://eva-engine.gitee.io) - \ No newline at end of file diff --git a/packages/plugin-renderer-lottie/api-extractor.json b/packages/plugin-renderer-lottie/api-extractor.json index 39061ad4..d635d1fc 100644 --- a/packages/plugin-renderer-lottie/api-extractor.json +++ b/packages/plugin-renderer-lottie/api-extractor.json @@ -4,4 +4,4 @@ "dtsRollup": { "publicTrimmedFilePath": "./dist/plugin-renderer-lottie.d.ts" } -} \ No newline at end of file +} diff --git a/packages/plugin-renderer-lottie/index.js b/packages/plugin-renderer-lottie/index.js index 5388edfa..9f836139 100644 --- a/packages/plugin-renderer-lottie/index.js +++ b/packages/plugin-renderer-lottie/index.js @@ -1,7 +1,7 @@ -'use strict' +'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/plugin-renderer-lottie.cjs.prod.js') + module.exports = require('./dist/plugin-renderer-lottie.cjs.prod.js'); } else { - module.exports = require('./dist/plugin-renderer-lottie.cjs.js') + module.exports = require('./dist/plugin-renderer-lottie.cjs.js'); } diff --git a/packages/plugin-renderer-lottie/lib/Lottie.ts b/packages/plugin-renderer-lottie/lib/Lottie.ts index 0d41de82..38018372 100644 --- a/packages/plugin-renderer-lottie/lib/Lottie.ts +++ b/packages/plugin-renderer-lottie/lib/Lottie.ts @@ -1,17 +1,6 @@ -import { - Component, - decorators -} from '@eva/eva.js'; -import { - IExpandOpts, - IOptions -} from './types'; -import { - Sprite, - Text, - TextStyle, - Graphics -} from 'pixi.js'; +import { Component, decorators } from '@eva/eva.js'; +import { IExpandOpts, IOptions } from './types'; +import { Sprite, Text, TextStyle, Graphics } from 'pixi.js'; interface ExtendOptions extends IOptions { autoStart: boolean; @@ -19,12 +8,12 @@ interface ExtendOptions extends IOptions { export default class Lottie extends Component { @decorators.IDEProp - slot: { [key: string]: string } + slot: { [key: string]: string }; static componentName: string = 'Lottie'; public static application: any; public anim: any; - public options: ExtendOptions + public options: ExtendOptions; public loadStatus: boolean = false; public firstPlay: () => void | null = null; public slotCache: { [key: string]: any }; @@ -32,50 +21,38 @@ export default class Lottie extends Component { public currentSlot: { [name: string]: any } = {}; constructor(options: IOptions) { - super() + super(); this.options = { autoStart: false, - ...options - } + ...options, + }; this.on('success', () => { this.loadStatus = true; const { ip, op } = this.anim.keyframes; for (let i = ip; i <= op; i++) { const event = `@${i}`; - this.anim.on(event, e => this.emit(event, e)) + this.anim.on(event, e => this.emit(event, e)); } this.firstPlay && this.firstPlay(); - }) + }); } play( params: number[] = [], expandOpts: IExpandOpts = { - repeats: 0 - } + repeats: 0, + }, ) { if (!this.loadStatus) { this.firstPlay = () => { this.play(params, expandOpts); - } + }; return; } const { slot = [] } = expandOpts; - slot.forEach(({ - name, - type, - value, - style = {} - }) => { - const { - x, - y, - anchor = { x: 0, y: 0 }, - pivot = { x: 0, y: 0 }, - width, - height - } = style; + slot.forEach(({ name, type, value, style = {} }) => { + const { x, y, anchor = { x: 0, y: 0 }, pivot = { x: 0, y: 0 }, width, height } = style; if (type === 'IMAGE') { this.currentSlot[name] = Sprite.from(value); } else if (type === 'TEXT') { @@ -88,24 +65,21 @@ export default class Lottie extends Component { this.currentSlot[name].anchor.set(anchor.x || 0, anchor.y || 0); this.currentSlot[name].pivot.set( this.currentSlot[name].width * (pivot.x || 0), - this.currentSlot[name].height * (pivot.y || 0) + this.currentSlot[name].height * (pivot.y || 0), ); if (this.prevSlot[name]) this.anim.unbindSlot(name, this.prevSlot[name]); this.anim.bindSlot(name, this.currentSlot[name]); this.prevSlot[name] = this.currentSlot[name]; - }) + }); - this.anim.playSegment( - this.playParamsHandle(params), - expandOpts - ) + this.anim.playSegment(this.playParamsHandle(params), expandOpts); } playParamsHandle(params) { let p = [].concat(params); const { keyframes } = this.anim; if (!p.length || p.length > 2) { - p = [keyframes.ip, keyframes.op] + p = [keyframes.ip, keyframes.op]; } else if (p.length === 1) { p = [p[0] % keyframes.op, keyframes.op]; } @@ -117,7 +91,7 @@ export default class Lottie extends Component { this.on('success', () => { const ele = this.anim.querySelector(name); const display = ele.display; - g.beginFill(0xFFFFFF); + g.beginFill(0xffffff); g.drawRect(0, 0, 100, 100); g.endFill(); g.alpha = 0; @@ -125,7 +99,7 @@ export default class Lottie extends Component { ele.display.interactive = true; ele.display.on('pointertap', () => { callback(); - }) - }) + }); + }); } -} \ No newline at end of file +} diff --git a/packages/plugin-renderer-lottie/lib/LottieSystem.ts b/packages/plugin-renderer-lottie/lib/LottieSystem.ts index 64b65113..9d87c6f2 100644 --- a/packages/plugin-renderer-lottie/lib/LottieSystem.ts +++ b/packages/plugin-renderer-lottie/lib/LottieSystem.ts @@ -1,14 +1,5 @@ -import { - OBSERVER_TYPE, - decorators, - ComponentChanged, - resource -} from '@eva/eva.js'; -import { - Renderer, - RendererManager, - ContainerManager, -} from '@eva/plugin-renderer'; +import { OBSERVER_TYPE, decorators, ComponentChanged, resource } from '@eva/eva.js'; +import { Renderer, RendererManager, ContainerManager } from '@eva/plugin-renderer'; import { AnimationManager, DisplayRegister, @@ -19,11 +10,10 @@ import { SpriteElement, Container, LoadTexture, - LoadJson + LoadJson, } from './lottie-pixi'; import { imageHandle } from './utils'; -import Lottie from './Lottie' - +import Lottie from './Lottie'; function loadTexture(assets, options) { return new LoadTexture(assets, options); @@ -44,10 +34,10 @@ DisplayRegister.registerDisplayByType(DisplayRegister.Type.Component, CompElemen DisplayRegister.registerDisplayByType(DisplayRegister.Type.Container, Container); @decorators.componentObserver({ - Lottie: [] + Lottie: [], }) export default class LottieSystem extends Renderer { - static systemName = 'LottieSystem' + static systemName = 'LottieSystem'; public manager: any; public app: any; public renderSystem; @@ -61,8 +51,8 @@ export default class LottieSystem extends Renderer { 'complete', 'loopComplete', 'enterFrame', - 'update' - ] + 'update', + ]; /** * System 初始化用,可以配置参数,游戏未开始 @@ -71,7 +61,7 @@ export default class LottieSystem extends Renderer { * @param param init params */ init() { - this.renderSystem = this.game.systems.find((s: any) => (s.application)) + this.renderSystem = this.game.systems.find((s: any) => s.application); this.app = this.renderSystem.application; } @@ -88,11 +78,9 @@ export default class LottieSystem extends Renderer { async add(changed: ComponentChanged) { this.manager = new AnimationManager(this.app); const component = changed.component as Lottie; - const container = this.renderSystem.containerManager.getContainer( - changed.gameObject.id, - ); + const container = this.renderSystem.containerManager.getContainer(changed.gameObject.id); if (!container) return; - const { resource: rn, ...otherOpts } = component.options + const { resource: rn, ...otherOpts } = component.options; const { data } = await resource.getResource(rn); const json = { ...(data.json || {}) }; const assets = json.assets || []; @@ -101,25 +89,23 @@ export default class LottieSystem extends Renderer { }); const anim = this.manager.parseAnimation({ keyframes: json, - ...otherOpts - }) + ...otherOpts, + }); component.anim = anim; - container.addChildAt(anim.group, 0) + container.addChildAt(anim.group, 0); this.managerLife.forEach(eventName => { - anim.on(eventName, e => component.emit(eventName, e)) - }) + anim.on(eventName, e => component.emit(eventName, e)); + }); if (anim.isImagesLoaded) component.emit('success', {}); } remove(changed: ComponentChanged) { const component = changed.component as Lottie; - const container = this.renderSystem.containerManager.getContainer( - changed.gameObject.id, - ); + const container = this.renderSystem.containerManager.getContainer(changed.gameObject.id); if (container) { container.removeChild(component.anim.group); - component.anim.group.destory(true) + component.anim.group.destory(true); } component.anim = null; } -} \ No newline at end of file +} diff --git a/packages/plugin-renderer-lottie/lib/lottie-core.js b/packages/plugin-renderer-lottie/lib/lottie-core.js index b31e9dbf..c3e9eafb 100644 --- a/packages/plugin-renderer-lottie/lib/lottie-core.js +++ b/packages/plugin-renderer-lottie/lib/lottie-core.js @@ -1,4 +1,1506 @@ -function t(t){return Object.prototype.toString.call(t)}const s={copyJSON:function(t){return JSON.parse(JSON.stringify(t))},isArray:function(){let s=t([]);return function(e){return t(e)===s}}(),isString:function(){let s=t("s");return function(e){return t(e)===s}}(),isNumber:function(){let s=t(1);return function(e){return t(e)===s}}(),isFunction:function(){let s=t((function(){}));return function(e){return t(e)===s}}(),isUndefined:function(t){return void 0===t},isBoolean:function(){let s=t(!0);return function(e){return t(e)===s}}(),isObject:function(){let s=t({});return function(e){return t(e)===s}}(),random:function(t,s){return this.isArray(t)?t[~~(Math.random()*t.length)]:(this.isNumber(s)||(s=t||1,t=0),t+Math.random()*(s-t))},euclideanModulo:function(t,s){return(t%s+s)%s},codomainBounce:function(t,s,e){return te?2*e-t:t},clamp:function(t,s,e){return te?e:t},inRange:(t,s,e)=>t>=s&&t<=e,getAssets(t,s){for(let e=0;e(t[0]<<16)+(t[1]<<8)+(0|t[2])};class e{constructor(){this.listeners={},this.addEventListener=this.on,this.removeEventListener=this.off}on(t,e){return s.isFunction(e)?(s.isUndefined(this.listeners[t])&&(this.listeners[t]=[]),this.listeners[t].push(e),this):this}off(t,e){if(s.isUndefined(this.listeners[t]))return this;const i=this.listeners[t];let h=i.length;if(h>0)if(e)for(;h--;)i[h]===e&&i.splice(h,1);else i.length=0;return this}once(t,e){if(!s.isFunction(e))return this;const i=s=>{e(s),this.off(t,i)};return this.on(t,i),this}emit(t,...e){if(s.isUndefined(this.listeners[t]))return this;const i=(this.listeners[t]||[]).slice(0);for(let t=0;t=0;s-=1)if("sh"==t[s].ty)if(t[s].ks.k.i)l(t[s].ks.k);else for(i=t[s].ks.k.length,e=0;ee[0]||!(e[0]>t[0])&&(t[1]>e[1]||!(e[1]>t[1])&&(t[2]>e[2]||!(e[2]>t[2])&&void 0))}let c=function(){let t=[4,4,14];function s(t){let s=t.t.d;t.t.d={k:[{s:s,t:0}]}}function e(t){let e,i=t.length;for(e=0;e=0;e-=1)if("sh"==t[e].ty)if(t[e].ks.k.i)t[e].ks.k.c=t[e].closed;else for(h=t[e].ks.k.length,i=0;i=.001?function(t,s,e,i){for(let h=0;h<4;++h){let h=x(s,e,i);if(0===h)return s;s-=(S(s,e,i)-t)/h}return s}(t,i,this.mX1,this.mX2):0===h?i:function(t,s,e,i,h){let r,a,n=0;do{a=s+(e-s)/2,r=S(a,i,h)-t,r>0?e=a:s=a}while(Math.abs(r)>1e-7&&++n<10);return a}(t,s,s+.1,this.mX1,this.mX2)},M.prototype.get=function(t){return this.mX1===this.mY1&&this.mX2===this.mY2?t:0===t?0:1===t?1:S(this._getTForX(t),this.mY1,this.mY2)};const P={};var T={getBezierEasing:function(t,s,e,i,h){const r=h||("bez_"+t+"_"+s+"_"+e+"_"+i).replace(/\./g,"p");if(P[r])return P[r];const a=new M(t,s,e,i);return P[r]=a,a}};let w;function D(t){return new Array(t)}w="function"==typeof Uint8ClampedArray&&"function"==typeof Float32Array?function(t,s){return"float32"===t?new Float32Array(s):"int16"===t?new Int16Array(s):"uint8c"===t?new Uint8ClampedArray(s):void 0}:function(t,s){let e=0;const i=[];let h;switch(t){case"int16":case"uint8c":h=1;break;default:h=1.1}for(e=0;e=this._maxLength&&this.doubleArrayLength(),e){case"v":r=this.v;break;case"i":r=this.i;break;case"o":r=this.o}(!r[i]||r[i]&&!h)&&(r[i]=A.newElement()),r[i][0]=t,r[i][1]=s}setTripleAt(t,s,e,i,h,r,a,n){this.setXYAt(t,s,"v",a,n),this.setXYAt(e,i,"o",a,n),this.setXYAt(h,r,"i",a,n)}reverse(){const t=new C;t.setPathData(this.c,this._length);const s=this.v,e=this.o,i=this.i;let h=0;this.c&&(t.setTripleAt(s[0][0],s[0][1],i[0][0],i[0][1],e[0][0],e[0][1],0,!1),h=1);let r=this._length-1;const a=this._length;for(let n=h;n-.001&&a<.001}function z(t,s,e,i){let h,r=0;const a=[],n=[],o=X.newElement(),l=e.length;for(let p=0;p<200;p+=1){const c=p/199;h=0;for(let r=0;ra?-1:1;let s=!0;for(;s;)if(i[r]<=a&&i[r+1]>a?(n=(a-i[r])/(i[r+1]-i[r]),s=!1):r+=t,r<0||r>=h-1){if(r===h-1)return e[r];s=!1}return e[r]+(e[r+1]-e[r])*n}}const J=w("float32",8);var H={getSegmentsLength:function(t){const s=Y.newElement(),e=t.c,i=t.v,h=t.o,r=t.i,a=t._length,n=s.lengths;let o=0,l=0;for(;l1?1:h,a),o=G(r=r>1?1:r,a),l=t.length,p=1-n,c=1-o,d=p*p*p,u=n*p*p*3,f=n*n*p*3,m=n*n*n,g=p*p*c,y=n*p*c+p*n*c+p*p*o,v=n*n*c+p*n*o+n*p*o,_=n*n*o,k=p*c*c,S=n*c*c+p*o*c+p*c*o,x=n*o*c+p*o*o+n*c*o,M=n*o*o,P=c*c*c,T=o*c*c+c*o*c+c*c*o,w=o*o*c+c*o*o+o*c*o,D=o*o*o;for(let h=0;hp?l>c?l-p-c:c-p-l:c>p?c-p-l:p-l-c,d>-1e-4&&d<1e-4}};const U=Math.PI/180,Z=[0,0],Q=/(loopIn|loopOut)\(([^)]+)/,W=/["']\w+["']/;class ${constructor(t,s,e){this.begin=s,this.end=e,this.total=this.end-this.begin,this.type=t}update(t){return"in"===this.type?t>=this.begin?t:this.end-s.euclideanModulo(this.begin-t,this.total):"out"===this.type?t<=this.end?t:this.begin+s.euclideanModulo(t-this.end,this.total):void 0}}class tt{constructor(t,s,e){this.begin=s,this.end=e,this.total=this.end-this.begin,this.type=t}update(t){if("in"===this.type&&tthis.end){const s=t-this.end;return this.pingpong(s)}return t}pingpong(t){return Math.floor(t/this.total)%2?this.begin+s.euclideanModulo(t,this.total):this.end-s.euclideanModulo(t,this.total)}}const st={loopIn(t,s,e){const i=t[0].t,h=t.length-1,r=t[Math.min(h,e)].t;switch(s){case"cycle":return new $("in",i,r);case"pingpong":return new tt("in",i,r)}return null},loopOut(t,s,e){const i=t.length-1,h=t[Math.max(0,i-e)].t,r=t[i].t;switch(s){case"cycle":return new $("out",h,r);case"pingpong":return new tt("out",h,r)}return null}};function et(t){const s=t.match(Q),e=s[2].split(/\s*,\s*/).map(t=>W.test(t)?t.replace(/"|'/g,""):parseInt(t));return{name:s[1],mode:e[0],offset:e[1]}}var it={hasSupportExpression:function(t){return t.x&&Q.test(t.x)},getExpression:function(t){const{name:s,mode:e,offset:i=0}=et(t.x),h=0===i?t.k.length-1:i;return st[s]&&st[s](t.k,e,h)}};function ht(t){const s=t[0]*U,e=t[1]*U,i=t[2]*U,h=Math.cos(s/2),r=Math.cos(e/2),a=Math.cos(i/2),n=Math.sin(s/2),o=Math.sin(e/2),l=Math.sin(i/2);return[n*o*a+h*r*l,n*r*a+h*o*l,h*o*a-n*r*l,h*r*a-n*o*l]}class rt{interpolateValue(t,s){let e;"multidimensional"===this.propType&&(e=w("float32",this.pv.length));let i,h,r,a,n,o,l,p,c=s.lastIndex,d=c,u=this.keyframes.length-1,f=!0;for(;f;){if(i=this.keyframes[d],h=this.keyframes[d+1],d===u-1&&t>=h.t){i.h&&(i=h),c=0;break}if(h.t>t){c=d;break}d=g||t=g?c.points.length-1:0;for(a=c.points[s].point.length,r=0;r=m&&u=g)e[0]=m[0],e[1]=m[1],e[2]=m[2];else if(t<=y)e[0]=i.s[0],e[1]=i.s[1],e[2]=i.s[2];else{!function(t,s){const e=s[0],i=s[1],h=s[2],r=s[3],a=Math.atan2(2*i*r-2*e*h,1-2*i*i-2*h*h),n=Math.asin(2*e*i+2*h*r),o=Math.atan2(2*e*r-2*i*h,1-2*e*e-2*h*h);t[0]=a/U,t[1]=n/U,t[2]=o/U}(e,function(t,s,e){const i=[],h=t[0],r=t[1],a=t[2],n=t[3];let o,l,p,c,d,u=s[0],f=s[1],m=s[2],g=s[3];return l=h*u+r*f+a*m+n*g,l<0&&(l=-l,u=-u,f=-f,m=-m,g=-g),1-l>1e-6?(o=Math.acos(l),p=Math.sin(o),c=Math.sin((1-e)*o)/p,d=Math.sin(e*o)/p):(c=1-e,d=e),i[0]=c*h+d*u,i[1]=c*r+d*f,i[2]=c*a+d*m,i[3]=c*n+d*g,i}(ht(i.s),ht(m),(t-y)/(g-y)))}else for(d=0;d=g?n=1:t=e&&t>=e||this._caching.lastFrame=t&&(this._caching._lastKeyframeIndex=-1,this._caching.lastIndex=0);let s=this.interpolateValue(t,this._caching);this.pv=s}return this._caching.lastFrame=t,this.pv}setVValue(t){let s;if("unidimensional"===this.propType)s=t*this.mult,Math.abs(this.v-s)>1e-5&&(this.v=s,this._mdf=!0);else{let e=0;const i=this.v.length;for(;e1e-5&&(this.v[e]=s,this._mdf=!0),e+=1}}processEffectsSequence(t){if(this.expression&&(t=this.expression.update(t)),t===this.frameId||!this.effectsSequence.length)return;if(this.lock)return void this.setVValue(this.pv);let s;this.lock=!0,this._mdf=this._isFirstFrame;let e=this.effectsSequence.length,i=this.kf?this.pv:this.data.k;for(s=0;s=u[u.length-1].t)i=u[u.length-1].s?u[u.length-1].s[0]:u[u.length-2].e[0],r=!0;else{let s,e,a=d,n=u.length-1,o=!0;for(;o&&(s=u[a],e=u[a+1],!(e.t>t));)a=e.t)p=1;else if(te&&t>e)||(this._caching.lastIndex=i e ? 2 * e - t : t; + }, + clamp: function (t, s, e) { + return t < s ? s : t > e ? e : t; + }, + inRange: (t, s, e) => t >= s && t <= e, + getAssets(t, s) { + for (let e = 0; e < s.length; e++) if (t === s[e].id) return s[e]; + return console.error('have not assets name as', t), {}; + }, + rgb2hex: t => (t[0] << 16) + (t[1] << 8) + (0 | t[2]), +}; +class e { + constructor() { + (this.listeners = {}), (this.addEventListener = this.on), (this.removeEventListener = this.off); + } + on(t, e) { + return s.isFunction(e) + ? (s.isUndefined(this.listeners[t]) && (this.listeners[t] = []), this.listeners[t].push(e), this) + : this; + } + off(t, e) { + if (s.isUndefined(this.listeners[t])) return this; + const i = this.listeners[t]; + let h = i.length; + if (h > 0) + if (e) for (; h--; ) i[h] === e && i.splice(h, 1); + else i.length = 0; + return this; + } + once(t, e) { + if (!s.isFunction(e)) return this; + const i = s => { + e(s), this.off(t, i); + }; + return this.on(t, i), this; + } + emit(t, ...e) { + if (s.isUndefined(this.listeners[t])) return this; + const i = (this.listeners[t] || []).slice(0); + for (let t = 0; t < i.length; t++) i[t].apply(this, e); + return this; + } +} +const i = {}, + h = { Ajax: 'Ajax', Texture: 'Texture' }; +var r = { + Type: h, + registerLoaderByType: function (t, s) { + i[t] = s; + }, +}; +function a(t, s, e) { + let i, + h, + r, + p, + c, + d, + u = t.length; + for (h = 0; h < u; h += 1) + if (((i = t[h]), 'ks' in i && !i.completed)) { + if (((i.completed = !0), i.tt && (t[h - 1].td = i.tt), i.hasMask)) { + let t = i.masksProperties; + for (p = t.length, r = 0; r < p; r += 1) + if (t[r].pt.k.i) l(t[r].pt.k); + else + for (d = t[r].pt.k.length, c = 0; c < d; c += 1) + t[r].pt.k[c].s && l(t[r].pt.k[c].s[0]), t[r].pt.k[c].e && l(t[r].pt.k[c].e[0]); + } + 0 === i.ty ? ((i.layers = n(i.refId, s)), a(i.layers, s)) : 4 === i.ty ? o(i.shapes) : 5 == i.ty && m(i); + } +} +function n(t, s) { + let e = 0, + i = s.length; + for (; e < i; ) { + if (s[e].id === t) + return s[e].layers.__used ? JSON.parse(JSON.stringify(s[e].layers)) : ((s[e].layers.__used = !0), s[e].layers); + e += 1; + } +} +function o(t) { + let s, e, i; + for (s = t.length - 1; s >= 0; s -= 1) + if ('sh' == t[s].ty) + if (t[s].ks.k.i) l(t[s].ks.k); + else + for (i = t[s].ks.k.length, e = 0; e < i; e += 1) + t[s].ks.k[e].s && l(t[s].ks.k[e].s[0]), t[s].ks.k[e].e && l(t[s].ks.k[e].e[0]); + else 'gr' == t[s].ty && o(t[s].it); +} +function l(t) { + let s, + e = t.i.length; + for (s = 0; s < e; s += 1) + (t.i[s][0] += t.v[s][0]), (t.i[s][1] += t.v[s][1]), (t.o[s][0] += t.v[s][0]), (t.o[s][1] += t.v[s][1]); +} +function p(t, s) { + let e = s ? s.split('.') : [100, 100, 100]; + return ( + t[0] > e[0] || (!(e[0] > t[0]) && (t[1] > e[1] || (!(e[1] > t[1]) && (t[2] > e[2] || (!(e[2] > t[2]) && void 0))))) + ); +} +let c = (function () { + let t = [4, 4, 14]; + function s(t) { + let s = t.t.d; + t.t.d = { k: [{ s: s, t: 0 }] }; + } + function e(t) { + let e, + i = t.length; + for (e = 0; e < i; e += 1) 5 === t[e].ty && s(t[e]); + } + return function (s) { + if (p(t, s.v) && (e(s.layers), s.assets)) { + let t, + i = s.assets.length; + for (t = 0; t < i; t += 1) s.assets[t].layers && e(s.assets[t].layers); + } + }; + })(), + d = (function () { + let t = [4, 7, 99]; + return function (s) { + if (s.chars && !p(t, s.v)) { + let t, + e, + i, + h, + r, + a = s.chars.length; + for (t = 0; t < a; t += 1) + if (s.chars[t].data && s.chars[t].data.shapes) + for (r = s.chars[t].data.shapes[0].it, i = r.length, e = 0; e < i; e += 1) + (h = r[e].ks.k), h.__converted || (l(r[e].ks.k), (h.__converted = !0)); + } + }; + })(), + u = (function () { + let t = [4, 1, 9]; + function s(t) { + let e, + i, + h, + r = t.length; + for (e = 0; e < r; e += 1) + if ('gr' === t[e].ty) s(t[e].it); + else if ('fl' === t[e].ty || 'st' === t[e].ty) + if (t[e].c.k && t[e].c.k[0].i) + for (h = t[e].c.k.length, i = 0; i < h; i += 1) + t[e].c.k[i].s && + ((t[e].c.k[i].s[0] /= 255), + (t[e].c.k[i].s[1] /= 255), + (t[e].c.k[i].s[2] /= 255), + (t[e].c.k[i].s[3] /= 255)), + t[e].c.k[i].e && + ((t[e].c.k[i].e[0] /= 255), + (t[e].c.k[i].e[1] /= 255), + (t[e].c.k[i].e[2] /= 255), + (t[e].c.k[i].e[3] /= 255)); + else (t[e].c.k[0] /= 255), (t[e].c.k[1] /= 255), (t[e].c.k[2] /= 255), (t[e].c.k[3] /= 255); + } + function e(t) { + let e, + i = t.length; + for (e = 0; e < i; e += 1) 4 === t[e].ty && s(t[e].shapes); + } + return function (s) { + if (p(t, s.v) && (e(s.layers), s.assets)) { + let t, + i = s.assets.length; + for (t = 0; t < i; t += 1) s.assets[t].layers && e(s.assets[t].layers); + } + }; + })(), + f = (function () { + let t = [4, 4, 18]; + function s(t) { + let e, i, h; + for (e = t.length - 1; e >= 0; e -= 1) + if ('sh' == t[e].ty) + if (t[e].ks.k.i) t[e].ks.k.c = t[e].closed; + else + for (h = t[e].ks.k.length, i = 0; i < h; i += 1) + t[e].ks.k[i].s && (t[e].ks.k[i].s[0].c = t[e].closed), + t[e].ks.k[i].e && (t[e].ks.k[i].e[0].c = t[e].closed); + else 'gr' == t[e].ty && s(t[e].it); + } + function e(t) { + let e, + i, + h, + r, + a, + n, + o = t.length; + for (i = 0; i < o; i += 1) { + if (((e = t[i]), e.hasMask)) { + let t = e.masksProperties; + for (r = t.length, h = 0; h < r; h += 1) + if (t[h].pt.k.i) t[h].pt.k.c = t[h].cl; + else + for (n = t[h].pt.k.length, a = 0; a < n; a += 1) + t[h].pt.k[a].s && (t[h].pt.k[a].s[0].c = t[h].cl), t[h].pt.k[a].e && (t[h].pt.k[a].e[0].c = t[h].cl); + } + 4 === e.ty && s(e.shapes); + } + } + return function (s) { + if (p(t, s.v) && (e(s.layers), s.assets)) { + let t, + i = s.assets.length; + for (t = 0; t < i; t += 1) s.assets[t].layers && e(s.assets[t].layers); + } + }; + })(); +function m(t, s) { + 0 !== t.t.a.length || 'm' in t.t.p || (t.singleShape = !0); +} +var g = { + completeData: function (t, s) { + t.__complete || (u(t), c(t), d(t), f(t), a(t.layers, t.assets), (t.__complete = !0)); + }, + checkColors: u, + checkChars: d, + checkShapes: f, + completeLayers: a, +}; +let y = 'function' == typeof Float32Array; +function v(t, s) { + return 1 - 3 * s + 3 * t; +} +function _(t, s) { + return 3 * s - 6 * t; +} +function k(t) { + return 3 * t; +} +function S(t, s, e) { + return ((v(s, e) * t + _(s, e)) * t + k(s)) * t; +} +function x(t, s, e) { + return 3 * v(s, e) * t * t + 2 * _(s, e) * t + k(s); +} +function M(t, s, e, i) { + if (!(0 <= t && t <= 1 && 0 <= e && e <= 1)) throw new Error('bezier x values must be in [0, 1] range'); + (this.mX1 = t), + (this.mY1 = s), + (this.mX2 = e), + (this.mY2 = i), + (this.sampleValues = y ? new Float32Array(11) : new Array(11)), + this._preCompute(), + (this.get = this.get.bind(this)); +} +(M.prototype._preCompute = function () { + if (this.mX1 !== this.mY1 || this.mX2 !== this.mY2) + for (let t = 0; t < 11; ++t) this.sampleValues[t] = S(0.1 * t, this.mX1, this.mX2); +}), + (M.prototype._getTForX = function (t) { + let s = 0, + e = 1; + for (; 10 !== e && this.sampleValues[e] <= t; ++e) s += 0.1; + --e; + let i = s + ((t - this.sampleValues[e]) / (this.sampleValues[e + 1] - this.sampleValues[e])) * 0.1, + h = x(i, this.mX1, this.mX2); + return h >= 0.001 + ? (function (t, s, e, i) { + for (let h = 0; h < 4; ++h) { + let h = x(s, e, i); + if (0 === h) return s; + s -= (S(s, e, i) - t) / h; + } + return s; + })(t, i, this.mX1, this.mX2) + : 0 === h + ? i + : (function (t, s, e, i, h) { + let r, + a, + n = 0; + do { + (a = s + (e - s) / 2), (r = S(a, i, h) - t), r > 0 ? (e = a) : (s = a); + } while (Math.abs(r) > 1e-7 && ++n < 10); + return a; + })(t, s, s + 0.1, this.mX1, this.mX2); + }), + (M.prototype.get = function (t) { + return this.mX1 === this.mY1 && this.mX2 === this.mY2 + ? t + : 0 === t + ? 0 + : 1 === t + ? 1 + : S(this._getTForX(t), this.mY1, this.mY2); + }); +const P = {}; +var T = { + getBezierEasing: function (t, s, e, i, h) { + const r = h || ('bez_' + t + '_' + s + '_' + e + '_' + i).replace(/\./g, 'p'); + if (P[r]) return P[r]; + const a = new M(t, s, e, i); + return (P[r] = a), a; + }, +}; +let w; +function D(t) { + return new Array(t); +} +w = + 'function' == typeof Uint8ClampedArray && 'function' == typeof Float32Array + ? function (t, s) { + return 'float32' === t + ? new Float32Array(s) + : 'int16' === t + ? new Int16Array(s) + : 'uint8c' === t + ? new Uint8ClampedArray(s) + : void 0; + } + : function (t, s) { + let e = 0; + const i = []; + let h; + switch (t) { + case 'int16': + case 'uint8c': + h = 1; + break; + default: + h = 1.1; + } + for (e = 0; e < s; e += 1) i.push(h); + return i; + }; +var L = { + double: function (t) { + return t.concat(D(t.length)); + }, +}; +const F = function (t, s, e) { + let i = 0, + h = t, + r = D(h); + return { + newElement: function () { + let t; + return i ? ((i -= 1), (t = r[i])) : (t = s()), t; + }, + release: function (t) { + i === h && ((r = L.double(r)), (h *= 2)), e && e(t), (r[i] = t), (i += 1); + }, + }; +}; +const A = F(8, function () { + return w('float32', 2); +}); +class C { + constructor() { + (this.c = !1), + (this._length = 0), + (this._maxLength = 8), + (this.v = D(this._maxLength)), + (this.o = D(this._maxLength)), + (this.i = D(this._maxLength)); + } + setPathData(t, s) { + (this.c = t), this.setLength(s); + let e = 0; + for (; e < s; ) (this.v[e] = A.newElement()), (this.o[e] = A.newElement()), (this.i[e] = A.newElement()), (e += 1); + } + setLength(t) { + for (; this._maxLength < t; ) this.doubleArrayLength(); + this._length = t; + } + doubleArrayLength() { + (this.v = this.v.concat(D(this._maxLength))), + (this.i = this.i.concat(D(this._maxLength))), + (this.o = this.o.concat(D(this._maxLength))), + (this._maxLength *= 2); + } + setXYAt(t, s, e, i, h) { + let r; + switch ( + ((this._length = Math.max(this._length, i + 1)), this._length >= this._maxLength && this.doubleArrayLength(), e) + ) { + case 'v': + r = this.v; + break; + case 'i': + r = this.i; + break; + case 'o': + r = this.o; + } + (!r[i] || (r[i] && !h)) && (r[i] = A.newElement()), (r[i][0] = t), (r[i][1] = s); + } + setTripleAt(t, s, e, i, h, r, a, n) { + this.setXYAt(t, s, 'v', a, n), this.setXYAt(e, i, 'o', a, n), this.setXYAt(h, r, 'i', a, n); + } + reverse() { + const t = new C(); + t.setPathData(this.c, this._length); + const s = this.v, + e = this.o, + i = this.i; + let h = 0; + this.c && (t.setTripleAt(s[0][0], s[0][1], i[0][0], i[0][1], e[0][0], e[0][1], 0, !1), (h = 1)); + let r = this._length - 1; + const a = this._length; + for (let n = h; n < a; n += 1) t.setTripleAt(s[r][0], s[r][1], i[r][0], i[r][1], e[r][0], e[r][1], n, !1), (r -= 1); + return t; + } +} +const b = F( + 4, + function () { + return new C(); + }, + function (t) { + const s = t._length; + for (let e = 0; e < s; e += 1) + A.release(t.v[e]), A.release(t.i[e]), A.release(t.o[e]), (t.v[e] = null), (t.i[e] = null), (t.o[e] = null); + (t._length = 0), (t.c = !1); + }, +); +b.clone = function (t) { + const s = b.newElement(), + e = void 0 === t._length ? t.v.length : t._length; + s.setLength(e), (s.c = t.c); + for (let i = 0; i < e; i += 1) s.setTripleAt(t.v[i][0], t.v[i][1], t.o[i][0], t.o[i][1], t.i[i][0], t.i[i][1], i); + return s; +}; +class I { + constructor() { + (this._length = 0), (this._maxLength = 4), (this.shapes = D(this._maxLength)); + } + addShape(t) { + this._length === this._maxLength && + ((this.shapes = this.shapes.concat(D(this._maxLength))), (this._maxLength *= 2)), + (this.shapes[this._length] = t), + (this._length += 1); + } + releaseShapes() { + for (let t = 0; t < this._length; t += 1) b.release(this.shapes[t]); + this._length = 0; + } +} +let E = 0, + V = 4, + N = D(V); +var q = { + newShapeCollection: function () { + let t; + return E ? ((E -= 1), (t = N[E])) : (t = new I()), t; + }, + release: function (t) { + const s = t._length; + for (let e = 0; e < s; e += 1) b.release(t.shapes[e]); + (t._length = 0), E === V && ((N = L.double(N)), (V *= 2)), (N[E] = t), (E += 1); + }, +}; +class O { + outTypeExpressionMode() { + (this._hasOutTypeExpression = !0), this.container && this.container.outTypeExpressionMode(); + } + addDynamicProperty(t) { + -1 === this.dynamicProperties.indexOf(t) && + (this.dynamicProperties.push(t), + this.container.addDynamicProperty(this), + (this._isAnimated = !0), + t._hasOutTypeExpression && this.outTypeExpressionMode()); + } + iterateDynamicProperties(t) { + this._mdf = !1; + const s = this.dynamicProperties.length; + for (let e = 0; e < s; e += 1) + this.dynamicProperties[e].getValue(t), this.dynamicProperties[e]._mdf && (this._mdf = !0); + } + initDynamicPropertyContainer(t) { + (this.container = t), + (this.dynamicProperties = []), + (this._mdf = !1), + (this._isAnimated = !1), + (this._hasOutTypeExpression = !1); + } +} +const X = F(8, function () { + return { addedLength: 0, percents: w('float32', 200), lengths: w('float32', 200) }; +}); +const Y = F( + 8, + function () { + return { lengths: [], totalLength: 0 }; + }, + function (t) { + const s = t.lengths.length; + for (let e = 0; e < s; e += 1) X.release(t.lengths[e]); + t.lengths.length = 0; + }, +); +function j(t, s, e, i, h, r) { + const a = t * i + s * h + e * r - h * i - r * t - e * s; + return a > -0.001 && a < 0.001; +} +function z(t, s, e, i) { + let h, + r = 0; + const a = [], + n = [], + o = X.newElement(), + l = e.length; + for (let p = 0; p < 200; p += 1) { + const c = p / 199; + h = 0; + for (let r = 0; r < l; r += 1) { + const o = + Math.pow(1 - c, 3) * t[r] + + 3 * Math.pow(1 - c, 2) * c * e[r] + + 3 * (1 - c) * Math.pow(c, 2) * i[r] + + Math.pow(c, 3) * s[r]; + (a[r] = o), null !== n[r] && (h += Math.pow(a[r] - n[r], 2)), (n[r] = a[r]); + } + h && ((h = Math.sqrt(h)), (r += h)), (o.percents[p] = c), (o.lengths[p] = r); + } + return (o.addedLength = r), o; +} +function B(t) { + (this.segmentLength = 0), (this.points = new Array(t)); +} +function R(t, s) { + (this.partialLength = t), (this.point = s); +} +const K = {}; +function G(t, s) { + const e = s.percents, + i = s.lengths, + h = e.length; + let r = Math.floor((h - 1) * t); + const a = t * s.addedLength; + let n = 0; + if (r === h - 1 || 0 === r || a === i[r]) return e[r]; + { + const t = i[r] > a ? -1 : 1; + let s = !0; + for (; s; ) + if ( + (i[r] <= a && i[r + 1] > a ? ((n = (a - i[r]) / (i[r + 1] - i[r])), (s = !1)) : (r += t), r < 0 || r >= h - 1) + ) { + if (r === h - 1) return e[r]; + s = !1; + } + return e[r] + (e[r + 1] - e[r]) * n; + } +} +const J = w('float32', 8); +var H = { + getSegmentsLength: function (t) { + const s = Y.newElement(), + e = t.c, + i = t.v, + h = t.o, + r = t.i, + a = t._length, + n = s.lengths; + let o = 0, + l = 0; + for (; l < a - 1; l += 1) (n[l] = z(i[l], i[l + 1], h[l], r[l + 1])), (o += n[l].addedLength); + return e && a && ((n[l] = z(i[l], i[0], h[l], r[0])), (o += n[l].addedLength)), (s.totalLength = o), s; + }, + getNewSegment: function (t, s, e, i, h, r, a) { + const n = G((h = h < 0 ? 0 : h > 1 ? 1 : h), a), + o = G((r = r > 1 ? 1 : r), a), + l = t.length, + p = 1 - n, + c = 1 - o, + d = p * p * p, + u = n * p * p * 3, + f = n * n * p * 3, + m = n * n * n, + g = p * p * c, + y = n * p * c + p * n * c + p * p * o, + v = n * n * c + p * n * o + n * p * o, + _ = n * n * o, + k = p * c * c, + S = n * c * c + p * o * c + p * c * o, + x = n * o * c + p * o * o + n * c * o, + M = n * o * o, + P = c * c * c, + T = o * c * c + c * o * c + c * c * o, + w = o * o * c + c * o * o + o * c * o, + D = o * o * o; + for (let h = 0; h < l; h += 1) + (J[4 * h] = Math.round(1e3 * (d * t[h] + u * e[h] + f * i[h] + m * s[h])) / 1e3), + (J[4 * h + 1] = Math.round(1e3 * (g * t[h] + y * e[h] + v * i[h] + _ * s[h])) / 1e3), + (J[4 * h + 2] = Math.round(1e3 * (k * t[h] + S * e[h] + x * i[h] + M * s[h])) / 1e3), + (J[4 * h + 3] = Math.round(1e3 * (P * t[h] + T * e[h] + w * i[h] + D * s[h])) / 1e3); + return J; + }, + getPointInSegment: function (t, s, e, i, h, r) { + const a = G(h, r), + n = 1 - a; + return [ + Math.round( + 1e3 * + (n * n * n * t[0] + + (a * n * n + n * a * n + n * n * a) * e[0] + + (a * a * n + n * a * a + a * n * a) * i[0] + + a * a * a * s[0]), + ) / 1e3, + Math.round( + 1e3 * + (n * n * n * t[1] + + (a * n * n + n * a * n + n * n * a) * e[1] + + (a * a * n + n * a * a + a * n * a) * i[1] + + a * a * a * s[1]), + ) / 1e3, + ]; + }, + buildBezierData: function (t, s, e, i) { + const h = (t[0] + '_' + t[1] + '_' + s[0] + '_' + s[1] + '_' + e[0] + '_' + e[1] + '_' + i[0] + '_' + i[1]).replace( + /\./g, + 'p', + ); + if (!K[h]) { + let r, + a, + n = 200, + o = 0, + l = null; + 2 === t.length && + (t[0] != s[0] || t[1] != s[1]) && + j(t[0], t[1], s[0], s[1], t[0] + e[0], t[1] + e[1]) && + j(t[0], t[1], s[0], s[1], s[0] + i[0], s[1] + i[1]) && + (n = 2); + const p = new B(n), + c = e.length; + for (let h = 0; h < n; h += 1) { + a = D(c); + const d = h / (n - 1); + r = 0; + for (let h = 0; h < c; h += 1) { + const n = + Math.pow(1 - d, 3) * t[h] + + 3 * Math.pow(1 - d, 2) * d * (t[h] + e[h]) + + 3 * (1 - d) * Math.pow(d, 2) * (s[h] + i[h]) + + Math.pow(d, 3) * s[h]; + (a[h] = n), null !== l && (r += Math.pow(a[h] - l[h], 2)); + } + (r = Math.sqrt(r)), (o += r), (p.points[h] = new R(r, a)), (l = a); + } + (p.segmentLength = o), (K[h] = p); + } + return K[h]; + }, + pointOnLine2D: j, + pointOnLine3D: function (t, s, e, i, h, r, a, n, o) { + if (0 === e && 0 === r && 0 === o) return j(t, s, i, h, a, n); + const l = Math.sqrt(Math.pow(i - t, 2) + Math.pow(h - s, 2) + Math.pow(r - e, 2)), + p = Math.sqrt(Math.pow(a - t, 2) + Math.pow(n - s, 2) + Math.pow(o - e, 2)), + c = Math.sqrt(Math.pow(a - i, 2) + Math.pow(n - h, 2) + Math.pow(o - r, 2)); + let d; + return (d = l > p ? (l > c ? l - p - c : c - p - l) : c > p ? c - p - l : p - l - c), d > -1e-4 && d < 1e-4; + }, +}; +const U = Math.PI / 180, + Z = [0, 0], + Q = /(loopIn|loopOut)\(([^)]+)/, + W = /["']\w+["']/; +class $ { + constructor(t, s, e) { + (this.begin = s), (this.end = e), (this.total = this.end - this.begin), (this.type = t); + } + update(t) { + return 'in' === this.type + ? t >= this.begin + ? t + : this.end - s.euclideanModulo(this.begin - t, this.total) + : 'out' === this.type + ? t <= this.end + ? t + : this.begin + s.euclideanModulo(t - this.end, this.total) + : void 0; + } +} +class tt { + constructor(t, s, e) { + (this.begin = s), (this.end = e), (this.total = this.end - this.begin), (this.type = t); + } + update(t) { + if (('in' === this.type && t < this.begin) || ('out' === this.type && t > this.end)) { + const s = t - this.end; + return this.pingpong(s); + } + return t; + } + pingpong(t) { + return Math.floor(t / this.total) % 2 + ? this.begin + s.euclideanModulo(t, this.total) + : this.end - s.euclideanModulo(t, this.total); + } +} +const st = { + loopIn(t, s, e) { + const i = t[0].t, + h = t.length - 1, + r = t[Math.min(h, e)].t; + switch (s) { + case 'cycle': + return new $('in', i, r); + case 'pingpong': + return new tt('in', i, r); + } + return null; + }, + loopOut(t, s, e) { + const i = t.length - 1, + h = t[Math.max(0, i - e)].t, + r = t[i].t; + switch (s) { + case 'cycle': + return new $('out', h, r); + case 'pingpong': + return new tt('out', h, r); + } + return null; + }, +}; +function et(t) { + const s = t.match(Q), + e = s[2].split(/\s*,\s*/).map(t => (W.test(t) ? t.replace(/"|'/g, '') : parseInt(t))); + return { name: s[1], mode: e[0], offset: e[1] }; +} +var it = { + hasSupportExpression: function (t) { + return t.x && Q.test(t.x); + }, + getExpression: function (t) { + const { name: s, mode: e, offset: i = 0 } = et(t.x), + h = 0 === i ? t.k.length - 1 : i; + return st[s] && st[s](t.k, e, h); + }, +}; +function ht(t) { + const s = t[0] * U, + e = t[1] * U, + i = t[2] * U, + h = Math.cos(s / 2), + r = Math.cos(e / 2), + a = Math.cos(i / 2), + n = Math.sin(s / 2), + o = Math.sin(e / 2), + l = Math.sin(i / 2); + return [n * o * a + h * r * l, n * r * a + h * o * l, h * o * a - n * r * l, h * r * a - n * o * l]; +} +class rt { + interpolateValue(t, s) { + let e; + 'multidimensional' === this.propType && (e = w('float32', this.pv.length)); + let i, + h, + r, + a, + n, + o, + l, + p, + c = s.lastIndex, + d = c, + u = this.keyframes.length - 1, + f = !0; + for (; f; ) { + if (((i = this.keyframes[d]), (h = this.keyframes[d + 1]), d === u - 1 && t >= h.t)) { + i.h && (i = h), (c = 0); + break; + } + if (h.t > t) { + c = d; + break; + } + d < u - 1 ? (d += 1) : ((c = 0), (f = !1)); + } + let m, + g = h.t, + y = i.t; + if (i.to) { + i.bezierData || (i.bezierData = H.buildBezierData(i.s, h.s || i.e, i.to, i.ti)); + let c = i.bezierData; + if (t >= g || t < y) { + let s = t >= g ? c.points.length - 1 : 0; + for (a = c.points[s].point.length, r = 0; r < a; r += 1) e[r] = c.points[s].point[r]; + } else { + i.__fnct ? (p = i.__fnct) : ((p = T.getBezierEasing(i.o.x, i.o.y, i.i.x, i.i.y, i.n).get), (i.__fnct = p)), + (n = p((t - y) / (g - y))); + let h, + u = c.segmentLength * n, + m = s.lastFrame < t && s._lastKeyframeIndex === d ? s._lastAddedLength : 0; + for (l = s.lastFrame < t && s._lastKeyframeIndex === d ? s._lastPoint : 0, f = !0, o = c.points.length; f; ) { + if (((m += c.points[l].partialLength), 0 === u || 0 === n || l === c.points.length - 1)) { + for (a = c.points[l].point.length, r = 0; r < a; r += 1) e[r] = c.points[l].point[r]; + break; + } + if (u >= m && u < m + c.points[l + 1].partialLength) { + for (h = (u - m) / c.points[l + 1].partialLength, a = c.points[l].point.length, r = 0; r < a; r += 1) + e[r] = c.points[l].point[r] + (c.points[l + 1].point[r] - c.points[l].point[r]) * h; + break; + } + l < o - 1 ? (l += 1) : (f = !1); + } + (s._lastPoint = l), (s._lastAddedLength = m - c.points[l].partialLength), (s._lastKeyframeIndex = d); + } + } else { + let s, r, a, o, l; + if (((u = i.s.length), (m = h.s || i.e), this.sh && 1 !== i.h)) + if (t >= g) (e[0] = m[0]), (e[1] = m[1]), (e[2] = m[2]); + else if (t <= y) (e[0] = i.s[0]), (e[1] = i.s[1]), (e[2] = i.s[2]); + else { + !(function (t, s) { + const e = s[0], + i = s[1], + h = s[2], + r = s[3], + a = Math.atan2(2 * i * r - 2 * e * h, 1 - 2 * i * i - 2 * h * h), + n = Math.asin(2 * e * i + 2 * h * r), + o = Math.atan2(2 * e * r - 2 * i * h, 1 - 2 * e * e - 2 * h * h); + (t[0] = a / U), (t[1] = n / U), (t[2] = o / U); + })( + e, + (function (t, s, e) { + const i = [], + h = t[0], + r = t[1], + a = t[2], + n = t[3]; + let o, + l, + p, + c, + d, + u = s[0], + f = s[1], + m = s[2], + g = s[3]; + return ( + (l = h * u + r * f + a * m + n * g), + l < 0 && ((l = -l), (u = -u), (f = -f), (m = -m), (g = -g)), + 1 - l > 1e-6 + ? ((o = Math.acos(l)), (p = Math.sin(o)), (c = Math.sin((1 - e) * o) / p), (d = Math.sin(e * o) / p)) + : ((c = 1 - e), (d = e)), + (i[0] = c * h + d * u), + (i[1] = c * r + d * f), + (i[2] = c * a + d * m), + (i[3] = c * n + d * g), + i + ); + })(ht(i.s), ht(m), (t - y) / (g - y)), + ); + } + else + for (d = 0; d < u; d += 1) + 1 !== i.h && + (t >= g + ? (n = 1) + : t < y + ? (n = 0) + : (i.o.x.constructor === Array + ? (i.__fnct || (i.__fnct = []), + i.__fnct[d] + ? (p = i.__fnct[d]) + : ((s = void 0 === i.o.x[d] ? i.o.x[0] : i.o.x[d]), + (r = void 0 === i.o.y[d] ? i.o.y[0] : i.o.y[d]), + (a = void 0 === i.i.x[d] ? i.i.x[0] : i.i.x[d]), + (o = void 0 === i.i.y[d] ? i.i.y[0] : i.i.y[d]), + (p = T.getBezierEasing(s, r, a, o).get), + (i.__fnct[d] = p))) + : i.__fnct + ? (p = i.__fnct) + : ((s = i.o.x), + (r = i.o.y), + (a = i.i.x), + (o = i.i.y), + (p = T.getBezierEasing(s, r, a, o).get), + (i.__fnct = p)), + (n = p((t - y) / (g - y))))), + (m = h.s || i.e), + (l = 1 === i.h ? i.s[d] : i.s[d] + (m[d] - i.s[d]) * n), + 'multidimensional' === this.propType ? (e[d] = l) : (e = l); + } + return (s.lastIndex = c), e; + } + getValueAtCurrentTime(t) { + let s = this.keyframes[0].t, + e = this.keyframes[this.keyframes.length - 1].t; + if ( + !( + t === this._caching.lastFrame || + (-999999 !== this._caching.lastFrame && + ((this._caching.lastFrame >= e && t >= e) || (this._caching.lastFrame < s && t < s))) + ) + ) { + this._caching.lastFrame >= t && ((this._caching._lastKeyframeIndex = -1), (this._caching.lastIndex = 0)); + let s = this.interpolateValue(t, this._caching); + this.pv = s; + } + return (this._caching.lastFrame = t), this.pv; + } + setVValue(t) { + let s; + if ('unidimensional' === this.propType) + (s = t * this.mult), Math.abs(this.v - s) > 1e-5 && ((this.v = s), (this._mdf = !0)); + else { + let e = 0; + const i = this.v.length; + for (; e < i; ) + (s = t[e] * this.mult), Math.abs(this.v[e] - s) > 1e-5 && ((this.v[e] = s), (this._mdf = !0)), (e += 1); + } + } + processEffectsSequence(t) { + if ((this.expression && (t = this.expression.update(t)), t === this.frameId || !this.effectsSequence.length)) + return; + if (this.lock) return void this.setVValue(this.pv); + let s; + (this.lock = !0), (this._mdf = this._isFirstFrame); + let e = this.effectsSequence.length, + i = this.kf ? this.pv : this.data.k; + for (s = 0; s < e; s += 1) i = this.effectsSequence[s](t); + this.setVValue(i), (this._isFirstFrame = !1), (this.lock = !1), (this.frameId = t); + } + addEffect(t) { + this.effectsSequence.push(t), this.container.addDynamicProperty(this); + } +} +class at extends rt { + constructor(t, s, e, i) { + super(), + (this.propType = 'unidimensional'), + (this.mult = e || 1), + (this.data = s), + (this.v = e ? s.k * e : s.k), + (this.pv = s.k), + (this._mdf = !1), + (this.elem = t), + (this.container = i), + (this.k = !1), + (this.kf = !1), + (this.vel = 0), + (this.effectsSequence = []), + (this._isFirstFrame = !0), + (this.getValue = this.processEffectsSequence); + } +} +class nt extends rt { + constructor(t, s, e, i) { + super(), + (this.propType = 'multidimensional'), + (this.mult = e || 1), + (this.data = s), + (this._mdf = !1), + (this.elem = t), + (this.container = i), + (this.comp = t.comp), + (this.k = !1), + (this.kf = !1), + (this.frameId = -1); + const h = s.k.length; + (this.v = w('float32', h)), (this.pv = w('float32', h)), (this.vel = w('float32', h)); + for (let t = 0; t < h; t += 1) (this.v[t] = s.k[t] * this.mult), (this.pv[t] = s.k[t]); + (this._isFirstFrame = !0), (this.effectsSequence = []), (this.getValue = this.processEffectsSequence); + } +} +class ot extends rt { + constructor(t, s, e, i) { + super(), + (this.propType = 'unidimensional'), + (this.keyframes = s.k), + (this.frameId = -1), + (this._caching = { lastFrame: -999999, lastIndex: 0, value: 0, _lastKeyframeIndex: -1 }), + (this.k = !0), + (this.kf = !0), + (this.data = s), + (this.mult = e || 1), + (this.elem = t), + (this.container = i), + (this.comp = t.comp), + (this.v = -999999), + (this.pv = -999999), + (this._isFirstFrame = !0), + (this.getValue = this.processEffectsSequence), + (this.effectsSequence = [this.getValueAtCurrentTime.bind(this)]), + (this._hasOutTypeExpression = !1), + it.hasSupportExpression(s) && + ((this.expression = it.getExpression(s)), (this._hasOutTypeExpression = 'out' === this.expression.type)); + } +} +class lt extends rt { + constructor(t, s, e, i) { + let h; + super(), (this.propType = 'multidimensional'); + let r, + a, + n, + o, + l = s.k.length; + for (h = 0; h < l - 1; h += 1) + s.k[h].to && + s.k[h].s && + s.k[h + 1] && + s.k[h + 1].s && + ((r = s.k[h].s), + (a = s.k[h + 1].s), + (n = s.k[h].to), + (o = s.k[h].ti), + ((2 === r.length && + (r[0] !== a[0] || r[1] !== a[1]) && + H.pointOnLine2D(r[0], r[1], a[0], a[1], r[0] + n[0], r[1] + n[1]) && + H.pointOnLine2D(r[0], r[1], a[0], a[1], a[0] + o[0], a[1] + o[1])) || + (3 === r.length && + (r[0] !== a[0] || r[1] !== a[1] || r[2] !== a[2]) && + H.pointOnLine3D(r[0], r[1], r[2], a[0], a[1], a[2], r[0] + n[0], r[1] + n[1], r[2] + n[2]) && + H.pointOnLine3D(r[0], r[1], r[2], a[0], a[1], a[2], a[0] + o[0], a[1] + o[1], a[2] + o[2]))) && + ((s.k[h].to = null), (s.k[h].ti = null)), + r[0] === a[0] && + r[1] === a[1] && + 0 === n[0] && + 0 === n[1] && + 0 === o[0] && + 0 === o[1] && + (2 === r.length || (r[2] === a[2] && 0 === n[2] && 0 === o[2])) && + ((s.k[h].to = null), (s.k[h].ti = null))); + (this.effectsSequence = [this.getValueAtCurrentTime.bind(this)]), + (this.keyframes = s.k), + (this.k = !0), + (this.kf = !0), + (this._isFirstFrame = !0), + (this.mult = e || 1), + (this.elem = t), + (this.container = i), + (this.comp = t.comp), + (this.getValue = this.processEffectsSequence), + (this.frameId = -1); + let p = s.k[0].s.length; + for (this.v = w('float32', p), this.pv = w('float32', p), h = 0; h < p; h += 1) + (this.v[h] = -999999), (this.pv[h] = -999999); + (this._caching = { lastFrame: -999999, lastIndex: 0, value: w('float32', p) }), + (this._hasOutTypeExpression = !1), + it.hasSupportExpression(s) && + ((this.expression = it.getExpression(s)), (this._hasOutTypeExpression = 'out' === this.expression.type)); + } +} +var pt = { + getProp: function (t, s, e, i, h) { + let r; + if (s.k.length) + if ('number' == typeof s.k[0]) r = new nt(t, s, i, h); + else + switch (e) { + case 0: + r = new ot(t, s, i, h); + break; + case 1: + r = new lt(t, s, i, h); + } + else r = new at(t, s, i, h); + return r.effectsSequence.length && h.addDynamicProperty(r), r; + }, +}; +class ct { + interpolateShape(t, s, e) { + let i, + h, + r, + a, + n, + o, + l, + p, + c, + d = e.lastIndex, + u = this.keyframes; + if (t < u[0].t) (i = u[0].s[0]), (r = !0), (d = 0); + else if (t >= u[u.length - 1].t) (i = u[u.length - 1].s ? u[u.length - 1].s[0] : u[u.length - 2].e[0]), (r = !0); + else { + let s, + e, + a = d, + n = u.length - 1, + o = !0; + for (; o && ((s = u[a]), (e = u[a + 1]), !(e.t > t)); ) a < n - 1 ? (a += 1) : (o = !1); + if (((r = 1 === s.h), (d = a), !r)) { + if (t >= e.t) p = 1; + else if (t < s.t) p = 0; + else { + let i; + s.__fnct ? (i = s.__fnct) : ((i = T.getBezierEasing(s.o.x, s.o.y, s.i.x, s.i.y).get), (s.__fnct = i)), + (p = i((t - s.t) / (e.t - s.t))); + } + h = e.s ? e.s[0] : s.e[0]; + } + i = s.s[0]; + } + for (o = s._length, l = i.i[0].length, e.lastIndex = d, a = 0; a < o; a += 1) + for (n = 0; n < l; n += 1) + (c = r ? i.i[a][n] : i.i[a][n] + (h.i[a][n] - i.i[a][n]) * p), + (s.i[a][n] = c), + (c = r ? i.o[a][n] : i.o[a][n] + (h.o[a][n] - i.o[a][n]) * p), + (s.o[a][n] = c), + (c = r ? i.v[a][n] : i.v[a][n] + (h.v[a][n] - i.v[a][n]) * p), + (s.v[a][n] = c); + } + interpolateShapeCurrentTime(t) { + let s = this.keyframes[0].t, + e = this.keyframes[this.keyframes.length - 1].t, + i = this._caching.lastFrame; + return ( + (-999999 !== i && ((i < s && t < s) || (i > e && t > e))) || + ((this._caching.lastIndex = i < t ? this._caching.lastIndex : 0), + this.interpolateShape(t, this.pv, this._caching)), + (this._caching.lastFrame = t), + this.pv + ); + } + resetShape() { + this.paths = this.localShapeCollection; + } + shapesEqual(t, s) { + if (t._length !== s._length || t.c !== s.c) return !1; + let e, + i = t._length; + for (e = 0; e < i; e += 1) + if ( + t.v[e][0] !== s.v[e][0] || + t.v[e][1] !== s.v[e][1] || + t.o[e][0] !== s.o[e][0] || + t.o[e][1] !== s.o[e][1] || + t.i[e][0] !== s.i[e][0] || + t.i[e][1] !== s.i[e][1] + ) + return !1; + return !0; + } + setVValue(t) { + this.shapesEqual(this.v, t) || + ((this.v = b.clone(t)), + this.localShapeCollection.releaseShapes(), + this.localShapeCollection.addShape(this.v), + (this._mdf = !0), + (this.paths = this.localShapeCollection)); + } + processEffectsSequence(t) { + if (t === this.frameId) return; + if (!this.effectsSequence.length) return void (this._mdf = !1); + if (this.lock) return void this.setVValue(this.pv); + (this.lock = !0), (this._mdf = !1); + let s, + e = this.kf ? this.pv : this.data.ks ? this.data.ks.k : this.data.pt.k, + i = this.effectsSequence.length; + for (s = 0; s < i; s += 1) e = this.effectsSequence[s](t); + this.setVValue(e), (this.lock = !1), (this.frameId = t); + } + addEffect(t) { + this.effectsSequence.push(t), this.container.addDynamicProperty(this); + } +} +class dt extends ct { + constructor(t, s, e) { + super(), + (this.propType = 'shape'), + (this.comp = t.comp), + (this.container = t), + (this.elem = t), + (this.data = s), + (this.k = !1), + (this.kf = !1), + (this._mdf = !1); + let i = 3 === e ? s.pt.k : s.ks.k; + (this.v = b.clone(i)), + (this.pv = b.clone(this.v)), + (this.localShapeCollection = q.newShapeCollection()), + (this.paths = this.localShapeCollection), + this.paths.addShape(this.v), + (this.reset = this.resetShape), + (this.effectsSequence = []), + (this.getValue = this.processEffectsSequence); + } +} +class ut extends ct { + constructor(t, s, e) { + super(), + (this.propType = 'shape'), + (this.comp = t.comp), + (this.elem = t), + (this.container = t), + (this.keyframes = 3 === e ? s.pt.k : s.ks.k), + (this.k = !0), + (this.kf = !0); + let i = this.keyframes[0].s[0].i.length; + (this.v = b.newElement()), + this.v.setPathData(this.keyframes[0].s[0].c, i), + (this.pv = b.clone(this.v)), + (this.localShapeCollection = q.newShapeCollection()), + (this.paths = this.localShapeCollection), + this.paths.addShape(this.v), + (this.lastFrame = -999999), + (this.reset = this.resetShape), + (this._caching = { lastFrame: -999999, lastIndex: 0 }), + (this.effectsSequence = [this.interpolateShapeCurrentTime.bind(this)]), + (this.getValue = this.processEffectsSequence), + (this._hasOutTypeExpression = !1), + it.hasSupportExpression(s) && + ((this.expression = it.getExpression(s)), (this._hasOutTypeExpression = 'out' === this.expression.type)); + } +} +class ft extends O { + constructor(t, s) { + super(), + (this.v = b.newElement()), + this.v.setPathData(!0, 4), + (this.localShapeCollection = q.newShapeCollection()), + (this.paths = this.localShapeCollection), + this.localShapeCollection.addShape(this.v), + (this.d = s.d), + (this.elem = t), + (this.comp = t.comp), + (this.frameId = -1), + this.initDynamicPropertyContainer(t), + (this.p = pt.getProp(t, s.p, 1, 0, this)), + (this.s = pt.getProp(t, s.s, 1, 0, this)), + this.dynamicProperties.length ? (this.k = !0) : ((this.k = !1), this.convertEllToPath()); + } + reset() { + this.paths = this.localShapeCollection; + } + getValue(t) { + t !== this.frameId && (this.iterateDynamicProperties(t), (this.frameId = t), this._mdf && this.convertEllToPath()); + } + convertEllToPath() { + const t = this.p.v[0], + s = this.p.v[1], + e = this.s.v[0] / 2, + i = this.s.v[1] / 2, + h = 3 !== this.d, + r = this.v; + (r.v[0][0] = t), + (r.v[0][1] = s - i), + (r.v[1][0] = h ? t + e : t - e), + (r.v[1][1] = s), + (r.v[2][0] = t), + (r.v[2][1] = s + i), + (r.v[3][0] = h ? t - e : t + e), + (r.v[3][1] = s), + (r.i[0][0] = h ? t - e * gt : t + e * gt), + (r.i[0][1] = s - i), + (r.i[1][0] = h ? t + e : t - e), + (r.i[1][1] = s - i * gt), + (r.i[2][0] = h ? t + e * gt : t - e * gt), + (r.i[2][1] = s + i), + (r.i[3][0] = h ? t - e : t + e), + (r.i[3][1] = s + i * gt), + (r.o[0][0] = h ? t + e * gt : t - e * gt), + (r.o[0][1] = s - i), + (r.o[1][0] = h ? t + e : t - e), + (r.o[1][1] = s + i * gt), + (r.o[2][0] = h ? t - e * gt : t + e * gt), + (r.o[2][1] = s + i), + (r.o[3][0] = h ? t - e : t + e), + (r.o[3][1] = s - i * gt); + } +} +class mt extends O { + constructor(t, s) { + super(), + (this.v = b.newElement()), + this.v.setPathData(!0, 0), + (this.elem = t), + (this.comp = t.comp), + (this.data = s), + (this.frameId = -1), + (this.d = s.d), + this.initDynamicPropertyContainer(t), + 1 === s.sy + ? ((this.ir = pt.getProp(t, s.ir, 0, 0, this)), + (this.is = pt.getProp(t, s.is, 0, 0.01, this)), + (this.convertToPath = this.convertStarToPath)) + : (this.convertToPath = this.convertPolygonToPath), + (this.pt = pt.getProp(t, s.pt, 0, 0, this)), + (this.p = pt.getProp(t, s.p, 1, 0, this)), + (this.r = pt.getProp(t, s.r, 0, U, this)), + (this.or = pt.getProp(t, s.or, 0, 0, this)), + (this.os = pt.getProp(t, s.os, 0, 0.01, this)), + (this.localShapeCollection = q.newShapeCollection()), + this.localShapeCollection.addShape(this.v), + (this.paths = this.localShapeCollection), + this.dynamicProperties.length ? (this.k = !0) : ((this.k = !1), this.convertToPath()); + } + reset() { + this.paths = this.localShapeCollection; + } + getValue(t) { + t !== this.frameId && ((this.frameId = t), this.iterateDynamicProperties(t), this._mdf && this.convertToPath()); + } + convertStarToPath() { + let t, + s, + e, + i, + h = 2 * Math.floor(this.pt.v), + r = (2 * Math.PI) / h, + a = !0, + n = this.or.v, + o = this.ir.v, + l = this.os.v, + p = this.is.v, + c = (2 * Math.PI * n) / (2 * h), + d = (2 * Math.PI * o) / (2 * h), + u = -Math.PI / 2; + u += this.r.v; + let f = 3 === this.data.d ? -1 : 1; + for (this.v._length = 0, t = 0; t < h; t += 1) { + (s = a ? n : o), (e = a ? l : p), (i = a ? c : d); + let h = s * Math.cos(u), + m = s * Math.sin(u), + g = 0 === h && 0 === m ? 0 : m / Math.sqrt(h * h + m * m), + y = 0 === h && 0 === m ? 0 : -h / Math.sqrt(h * h + m * m); + (h += +this.p.v[0]), + (m += +this.p.v[1]), + this.v.setTripleAt(h, m, h - g * i * e * f, m - y * i * e * f, h + g * i * e * f, m + y * i * e * f, t, !0), + (a = !a), + (u += r * f); + } + } + convertPolygonToPath() { + let t, + s = Math.floor(this.pt.v), + e = (2 * Math.PI) / s, + i = this.or.v, + h = this.os.v, + r = (2 * Math.PI * i) / (4 * s), + a = -Math.PI / 2, + n = 3 === this.data.d ? -1 : 1; + for (a += this.r.v, this.v._length = 0, t = 0; t < s; t += 1) { + let s = i * Math.cos(a), + o = i * Math.sin(a), + l = 0 === s && 0 === o ? 0 : o / Math.sqrt(s * s + o * o), + p = 0 === s && 0 === o ? 0 : -s / Math.sqrt(s * s + o * o); + (s += +this.p.v[0]), + (o += +this.p.v[1]), + this.v.setTripleAt(s, o, s - l * r * h * n, o - p * r * h * n, s + l * r * h * n, o + p * r * h * n, t, !0), + (a += e * n); + } + (this.paths.length = 0), (this.paths[0] = this.v); + } +} +const gt = 0.5519; +class yt extends O { + constructor(t, s) { + super(), + (this.v = b.newElement()), + (this.v.c = !0), + (this.localShapeCollection = q.newShapeCollection()), + this.localShapeCollection.addShape(this.v), + (this.paths = this.localShapeCollection), + (this.elem = t), + (this.comp = t.comp), + (this.frameId = -1), + (this.d = s.d), + this.initDynamicPropertyContainer(t), + (this.p = pt.getProp(t, s.p, 1, 0, this)), + (this.s = pt.getProp(t, s.s, 1, 0, this)), + (this.r = pt.getProp(t, s.r, 0, 0, this)), + this.dynamicProperties.length ? (this.k = !0) : ((this.k = !1), this.convertRectToPath()); + } + reset() { + this.paths = this.localShapeCollection; + } + getValue(t) { + t !== this.frameId && ((this.frameId = t), this.iterateDynamicProperties(t), this._mdf && this.convertRectToPath()); + } + convertRectToPath() { + let t = this.p.v[0], + s = this.p.v[1], + e = this.s.v[0] / 2, + i = this.s.v[1] / 2, + h = Math.min(e, i, this.r.v), + r = h * (1 - 0.5519); + (this.v._length = 0), + 2 === this.d || 1 === this.d + ? (this.v.setTripleAt(t + e, s - i + h, t + e, s - i + h, t + e, s - i + r, 0, !0), + this.v.setTripleAt(t + e, s + i - h, t + e, s + i - r, t + e, s + i - h, 1, !0), + 0 !== h + ? (this.v.setTripleAt(t + e - h, s + i, t + e - h, s + i, t + e - r, s + i, 2, !0), + this.v.setTripleAt(t - e + h, s + i, t - e + r, s + i, t - e + h, s + i, 3, !0), + this.v.setTripleAt(t - e, s + i - h, t - e, s + i - h, t - e, s + i - r, 4, !0), + this.v.setTripleAt(t - e, s - i + h, t - e, s - i + r, t - e, s - i + h, 5, !0), + this.v.setTripleAt(t - e + h, s - i, t - e + h, s - i, t - e + r, s - i, 6, !0), + this.v.setTripleAt(t + e - h, s - i, t + e - r, s - i, t + e - h, s - i, 7, !0)) + : (this.v.setTripleAt(t - e, s + i, t - e + r, s + i, t - e, s + i, 2), + this.v.setTripleAt(t - e, s - i, t - e, s - i + r, t - e, s - i, 3))) + : (this.v.setTripleAt(t + e, s - i + h, t + e, s - i + r, t + e, s - i + h, 0, !0), + 0 !== h + ? (this.v.setTripleAt(t + e - h, s - i, t + e - h, s - i, t + e - r, s - i, 1, !0), + this.v.setTripleAt(t - e + h, s - i, t - e + r, s - i, t - e + h, s - i, 2, !0), + this.v.setTripleAt(t - e, s - i + h, t - e, s - i + h, t - e, s - i + r, 3, !0), + this.v.setTripleAt(t - e, s + i - h, t - e, s + i - r, t - e, s + i - h, 4, !0), + this.v.setTripleAt(t - e + h, s + i, t - e + h, s + i, t - e + r, s + i, 5, !0), + this.v.setTripleAt(t + e - h, s + i, t + e - r, s + i, t + e - h, s + i, 6, !0), + this.v.setTripleAt(t + e, s + i - h, t + e, s + i - h, t + e, s + i - r, 7, !0)) + : (this.v.setTripleAt(t - e, s - i, t - e + r, s - i, t - e, s - i, 1, !0), + this.v.setTripleAt(t - e, s + i, t - e, s + i - r, t - e, s + i, 2, !0), + this.v.setTripleAt(t + e, s + i, t + e - r, s + i, t + e, s + i, 3, !0))); + } +} +var vt = { + getShapeProp: function (t, s, e) { + let i; + if (3 === e || 4 === e) { + i = (3 === e ? s.pt : s.ks).k.length ? new ut(t, s, e) : new dt(t, s, e); + } else 5 === e ? (i = new yt(t, s)) : 6 === e ? (i = new ft(t, s)) : 7 === e && (i = new mt(t, s)); + return i.k && t.addDynamicProperty(i), i; + }, + getConstructorFunction: function () { + return dt; + }, + getKeyframedConstructorFunction: function () { + return ut; + }, +}; +class _t extends O { + constructor(t, s, e) { + super(), + (this.frameId = -1), + (this.elem = t), + (this.session = e), + (this.masksProperties = s || []), + this.initDynamicPropertyContainer(t), + (this.viewData = D(this.masksProperties.length)); + const i = this.masksProperties.length; + let h = !1; + for (let t = 0; t < i; t++) + 'n' !== this.masksProperties[t].mode && (h = !0), + (this.viewData[t] = vt.getShapeProp(this, this.masksProperties[t], 3)), + (this.viewData[t].inv = this.masksProperties[t].inv); + this.hasMasks = h; + } + getValue(t) { + t !== this.frameId && (this.iterateDynamicProperties(t), (this.frameId = t)); + } +} /*! Transformation Matrix v2.0 (c) Epistemex 2014-2015 @@ -6,4 +1508,2167 @@ function t(t){return Object.prototype.toString.call(t)}const s={copyJSON:functio By Ken Fyrstenberg Contributions by leeoniya. License: MIT, header required. - */var kt=function(){var t=Math.cos,s=Math.sin,e=Math.tan,i=Math.round;function h(){return this.props[0]=1,this.props[1]=0,this.props[2]=0,this.props[3]=0,this.props[4]=0,this.props[5]=1,this.props[6]=0,this.props[7]=0,this.props[8]=0,this.props[9]=0,this.props[10]=1,this.props[11]=0,this.props[12]=0,this.props[13]=0,this.props[14]=0,this.props[15]=1,this}function r(e){if(0===e)return this;var i=t(e),h=s(e);return this._t(i,-h,0,0,h,i,0,0,0,0,1,0,0,0,0,1)}function a(e){if(0===e)return this;var i=t(e),h=s(e);return this._t(1,0,0,0,0,i,-h,0,0,h,i,0,0,0,0,1)}function n(e){if(0===e)return this;var i=t(e),h=s(e);return this._t(i,0,h,0,0,1,0,0,-h,0,i,0,0,0,0,1)}function o(e){if(0===e)return this;var i=t(e),h=s(e);return this._t(i,-h,0,0,h,i,0,0,0,0,1,0,0,0,0,1)}function l(t,s){return this._t(1,s,t,1,0,0)}function p(t,s){return this.shear(e(t),e(s))}function c(i,h){var r=t(h),a=s(h);return this._t(r,a,0,0,-a,r,0,0,0,0,1,0,0,0,0,1)._t(1,0,0,0,e(i),1,0,0,0,0,1,0,0,0,0,1)._t(r,-a,0,0,a,r,0,0,0,0,1,0,0,0,0,1)}function d(t,s,e){return e||0===e||(e=1),1===t&&1===s&&1===e?this:this._t(t,0,0,0,0,s,0,0,0,0,e,0,0,0,0,1)}function u(t,s,e,i,h,r,a,n,o,l,p,c,d,u,f,m){return this.props[0]=t,this.props[1]=s,this.props[2]=e,this.props[3]=i,this.props[4]=h,this.props[5]=r,this.props[6]=a,this.props[7]=n,this.props[8]=o,this.props[9]=l,this.props[10]=p,this.props[11]=c,this.props[12]=d,this.props[13]=u,this.props[14]=f,this.props[15]=m,this}function f(t,s,e){return e=e||0,0!==t||0!==s||0!==e?this._t(1,0,0,0,0,1,0,0,0,0,1,0,t,s,e,1):this}function m(t,s,e,i,h,r,a,n,o,l,p,c,d,u,f,m){var g=this.props;if(1===t&&0===s&&0===e&&0===i&&0===h&&1===r&&0===a&&0===n&&0===o&&0===l&&1===p&&0===c)return g[12]=g[12]*t+g[15]*d,g[13]=g[13]*r+g[15]*u,g[14]=g[14]*p+g[15]*f,g[15]=g[15]*m,this._identityCalculated=!1,this;var y=g[0],v=g[1],_=g[2],k=g[3],S=g[4],x=g[5],M=g[6],P=g[7],T=g[8],w=g[9],D=g[10],L=g[11],F=g[12],A=g[13],C=g[14],b=g[15];return g[0]=y*t+v*h+_*o+k*d,g[1]=y*s+v*r+_*l+k*u,g[2]=y*e+v*a+_*p+k*f,g[3]=y*i+v*n+_*c+k*m,g[4]=S*t+x*h+M*o+P*d,g[5]=S*s+x*r+M*l+P*u,g[6]=S*e+x*a+M*p+P*f,g[7]=S*i+x*n+M*c+P*m,g[8]=T*t+w*h+D*o+L*d,g[9]=T*s+w*r+D*l+L*u,g[10]=T*e+w*a+D*p+L*f,g[11]=T*i+w*n+D*c+L*m,g[12]=F*t+A*h+C*o+b*d,g[13]=F*s+A*r+C*l+b*u,g[14]=F*e+A*a+C*p+b*f,g[15]=F*i+A*n+C*c+b*m,this._identityCalculated=!1,this}function g(){return this._identityCalculated||(this._identity=!(1!==this.props[0]||0!==this.props[1]||0!==this.props[2]||0!==this.props[3]||0!==this.props[4]||1!==this.props[5]||0!==this.props[6]||0!==this.props[7]||0!==this.props[8]||0!==this.props[9]||1!==this.props[10]||0!==this.props[11]||0!==this.props[12]||0!==this.props[13]||0!==this.props[14]||1!==this.props[15]),this._identityCalculated=!0),this._identity}function y(t){for(var s=0;s<16;){if(t.props[s]!==this.props[s])return!1;s+=1}return!0}function v(t){var s;for(s=0;s<16;s+=1)t.props[s]=this.props[s]}function _(t){var s;for(s=0;s<16;s+=1)this.props[s]=t[s]}function k(t,s,e){return{x:t*this.props[0]+s*this.props[4]+e*this.props[8]+this.props[12],y:t*this.props[1]+s*this.props[5]+e*this.props[9]+this.props[13],z:t*this.props[2]+s*this.props[6]+e*this.props[10]+this.props[14]}}function S(t,s,e){return t*this.props[0]+s*this.props[4]+e*this.props[8]+this.props[12]}function x(t,s,e){return t*this.props[1]+s*this.props[5]+e*this.props[9]+this.props[13]}function M(t,s,e){return t*this.props[2]+s*this.props[6]+e*this.props[10]+this.props[14]}function P(t){var s=this.props[0]*this.props[5]-this.props[1]*this.props[4],e=this.props[5]/s,i=-this.props[1]/s,h=-this.props[4]/s,r=this.props[0]/s,a=(this.props[4]*this.props[13]-this.props[5]*this.props[12])/s,n=-(this.props[0]*this.props[13]-this.props[1]*this.props[12])/s;return[t[0]*e+t[1]*h+a,t[0]*i+t[1]*r+n,0]}function T(t){var s,e=t.length,i=[];for(s=0;s0||t>-1e-6&&t<0?i(1e4*t)/1e4:t}function b(){var t=this.props;return"matrix("+C(t[0])+","+C(t[1])+","+C(t[4])+","+C(t[5])+","+C(t[12])+","+C(t[13])+")"}return function(){this.reset=h,this.rotate=r,this.rotateX=a,this.rotateY=n,this.rotateZ=o,this.skew=p,this.skewFromAxis=c,this.shear=l,this.scale=d,this.setTransform=u,this.translate=f,this.transform=m,this.applyToPoint=k,this.applyToX=S,this.applyToY=x,this.applyToZ=M,this.applyToPointArray=L,this.applyToTriplePoints=D,this.applyToPointStringified=F,this.toCSS=A,this.to2dCSS=b,this.clone=v,this.cloneFromProps=_,this.equals=y,this.inversePoints=T,this.inversePoint=P,this._t=this.transform,this.isIdentity=g,this._identity=!0,this._identityCalculated=!1,this.props=w("float32",16),this.reset()}}();class St{constructor(){this.sequences={},this.sequenceList=[],this.transform_key_count=0}addTransformSequence(t){const s=t.length;let e="_";for(let i=0;i=0;e-=1)s=t.transforms[e].transform.mProps.v.props,t.finalTransform.transform(s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8],s[9],s[10],s[11],s[12],s[13],s[14],s[15])}t._mdf=i}processSequences(t){const s=this.sequenceList.length;for(let e=0;e=this.p.keyframes[this.p.keyframes.length-1].t?(t=this.p.getValueAtTime(this.p.keyframes[this.p.keyframes.length-1].t/e,0),s=this.p.getValueAtTime((this.p.keyframes[this.p.keyframes.length-1].t-.05)/e,0)):(t=this.p.pv,s=this.p.getValueAtTime((this.p._caching.lastFrame+this.p.offsetTime-.01)/e,this.p.offsetTime));else if(this.px&&this.px.keyframes&&this.py.keyframes&&this.px.getValueAtTime&&this.py.getValueAtTime){t=[],s=[];let i=this.px,h=this.py;i._caching.lastFrame+i.offsetTime<=i.keyframes[0].t?(t[0]=i.getValueAtTime((i.keyframes[0].t+.01)/e,0),t[1]=h.getValueAtTime((h.keyframes[0].t+.01)/e,0),s[0]=i.getValueAtTime(i.keyframes[0].t/e,0),s[1]=h.getValueAtTime(h.keyframes[0].t/e,0)):i._caching.lastFrame+i.offsetTime>=i.keyframes[i.keyframes.length-1].t?(t[0]=i.getValueAtTime(i.keyframes[i.keyframes.length-1].t/e,0),t[1]=h.getValueAtTime(h.keyframes[h.keyframes.length-1].t/e,0),s[0]=i.getValueAtTime((i.keyframes[i.keyframes.length-1].t-.01)/e,0),s[1]=h.getValueAtTime((h.keyframes[h.keyframes.length-1].t-.01)/e,0)):(t=[i.pv,h.pv],s[0]=i.getValueAtTime((i._caching.lastFrame+i.offsetTime-.01)/e,i.offsetTime),s[1]=h.getValueAtTime((h._caching.lastFrame+h.offsetTime-.01)/e,h.offsetTime))}else t=s=Z;this.v.rotate(-Math.atan2(t[1]-s[1],t[0]-s[0]))}this.data.p&&this.data.p.s?this.data.p.z?this.v.translate(this.px.v,this.py.v,-this.pz.v):this.v.translate(this.px.v,this.py.v,0):this.v.translate(this.p.v[0],this.p.v[1],-this.p.v[2])}this.frameId=t}}precalculateMatrix(){if(!this.a.k&&(this.pre.translate(-this.a.v[0],-this.a.v[1],this.a.v[2]),this.appliedTransformations=1,!this.s.effectsSequence.length)){if(this.pre.scale(this.s.v[0],this.s.v[1],this.s.v[2]),this.appliedTransformations=2,this.sk){if(this.sk.effectsSequence.length||this.sa.effectsSequence.length)return;this.pre.skewFromAxis(-this.sk.v,this.sa.v),this.appliedTransformations=3}if(this.r){if(this.r.effectsSequence.length)return;this.pre.rotate(-this.r.v),this.appliedTransformations=4}else this.rz.effectsSequence.length||this.ry.effectsSequence.length||this.rx.effectsSequence.length||this.or.effectsSequence.length||(this.pre.rotateZ(-this.rz.v).rotateY(this.ry.v).rotateX(this.rx.v).rotateZ(-this.or.v[2]).rotateY(this.or.v[1]).rotateX(this.or.v[0]),this.appliedTransformations=4)}}applyToMatrix(t){let s=this._mdf;this.iterateDynamicProperties(),this._mdf=this._mdf||s,this.a&&t.translate(-this.a.v[0],-this.a.v[1],this.a.v[2]),this.s&&t.scale(this.s.v[0],this.s.v[1],this.s.v[2]),this.sk&&t.skewFromAxis(-this.sk.v,this.sa.v),this.r?t.rotate(-this.r.v):t.rotateZ(-this.rz.v).rotateY(this.ry.v).rotateX(this.rx.v).rotateZ(-this.or.v[2]).rotateY(this.or.v[1]).rotateX(this.or.v[0]),this.data.p.s?this.data.p.z?t.translate(this.px.v,this.py.v,-this.pz.v):t.translate(this.px.v,this.py.v,0):t.translate(this.p.v[0],this.p.v[1],-this.p.v[2])}}function Ft(t,s,e){return new Lt(t,s,e)}class At extends O{initModifierProperties(){}addShapeToModifier(){}addShape(t){if(!this.closed){t.sh.container.addDynamicProperty(t.sh);const s={shape:t.sh,data:t,localShapeCollection:q.newShapeCollection()};this.shapes.push(s),this.addShapeToModifier(s),this._isAnimated&&t.setAsAnimated()}}init(t,s){this.shapes=[],this.elem=t,this.initDynamicPropertyContainer(t),this.initModifierProperties(t,s),this.frameId=-999999,this.closed=!1,this.k=!1,this.dynamicProperties.length?this.k=!0:this.getValue(!0)}processKeys(t){t!==this.frameId&&(this.frameId=t,this.iterateDynamicProperties(t))}}const Ct={};function bt(t,s){Ct[t]||(Ct[t]=s)}bt("tm",class extends At{initModifierProperties(t,s){this.s=pt.getProp(t,s.s,0,.01,this),this.e=pt.getProp(t,s.e,0,.01,this),this.o=pt.getProp(t,s.o,0,0,this),this.sValue=0,this.eValue=0,this.getValue=this.processKeys,this.m=s.m,this._isAnimated=!!this.s.effectsSequence.length||!!this.e.effectsSequence.length||!!this.o.effectsSequence.length}addShapeToModifier(t){t.pathsData=[]}calculateShapeEdges(t,s,e,i,h){let r=[];s<=1?r.push({s:t,e:s}):t>=1?r.push({s:t-1,e:s-1}):(r.push({s:t,e:1}),r.push({s:0,e:s-1}));let a,n,o=[],l=r.length;for(a=0;ai+e);else{let t,s;t=n.s*h<=i?0:(n.s*h-i)/e,s=n.e*h>=i+e?1:(n.e*h-i)/e,o.push([t,s])}return o.length||o.push([0,0]),o}releasePathsData(t){const s=t.length;for(let e=0;e1?1:this.s.v<0?0:this.s.v)+t,e=(this.e.v>1?1:this.e.v<0?0:this.e.v)+t,s>e){let t=s;s=e,e=t}s=1e-4*Math.round(1e4*s),e=1e-4*Math.round(1e4*e),this.sValue=s,this.eValue=e}else s=this.sValue,e=this.eValue;let r,a,n,o,l,p=this.shapes.length,c=0;if(e===s)for(h=0;h=0;h-=1)if(d=this.shapes[h],d.shape._mdf){for(u=d.localShapeCollection,u.releaseShapes(),2===this.m&&p>1?(m=this.calculateShapeEdges(s,e,d.totalShapeLength,v,c),v+=d.totalShapeLength):m=[[g,y]],a=m.length,r=0;r=1?f.push({s:d.totalShapeLength*(g-1),e:d.totalShapeLength*(y-1)}):(f.push({s:d.totalShapeLength*g,e:d.totalShapeLength}),f.push({s:0,e:d.totalShapeLength*(y-1)}));let t=this.addShapes(d,f[0]);if(f[0].s!==f[0].e){if(f.length>1){if(d.shape.paths.shapes[d.shape.paths._length-1].c){let s=t.pop();this.addPaths(t,u),t=this.addShapes(d,f[1],s)}else this.addPaths(t,u),t=this.addShapes(d,f[1])}this.addPaths(t,u)}}d.shape.paths=u}}}addPaths(t,s){const e=t.length;for(let i=0;is.e){e.c=!1;break}s.s<=f&&s.e>=f+a.addedLength?(this.addSegment(d[i].v[h-1],d[i].o[h-1],d[i].i[h],d[i].v[h],e,n,g),g=!1):(l=H.getNewSegment(d[i].v[h-1],d[i].v[h],d[i].o[h-1],d[i].i[h],(s.s-f)/a.addedLength,(s.e-f)/a.addedLength,o[h-1]),this.addSegmentFromArray(l,e,n,g),g=!1,e.c=!1),f+=a.addedLength,n+=1}if(d[i].c&&o.length){if(a=o[h-1],f<=s.e){let t=o[h-1].addedLength;s.s<=f&&s.e>=f+t?(this.addSegment(d[i].v[h-1],d[i].o[h-1],d[i].i[0],d[i].v[0],e,n,g),g=!1):(l=H.getNewSegment(d[i].v[h-1],d[i].v[0],d[i].o[h-1],d[i].i[0],(s.s-f)/t,(s.e-f)/t,o[h-1]),this.addSegmentFromArray(l,e,n,g),g=!1,e.c=!1)}else e.c=!1;f+=a.addedLength,n+=1}if(e._length&&(e.setXYAt(e.v[p][0],e.v[p][1],"i",p),e.setXYAt(e.v[e._length-1][0],e.v[e._length-1][1],"o",e._length-1)),f>s.e)break;i0;)e-=1,this._elements.unshift(s[e]);this.dynamicProperties.length?this.k=!0:this.getValue(!0)}resetElements(t){const s=t.length;for(let e=0;e0?Math.floor(h):Math.ceil(h),n=this.pMatrix.props,o=this.rMatrix.props,l=this.sMatrix.props;this.pMatrix.reset(),this.rMatrix.reset(),this.sMatrix.reset(),this.tMatrix.reset(),this.matrix.reset();let p=0;if(h>0){for(;pa;)this.applyTransforms(this.pMatrix,this.rMatrix,this.sMatrix,this.tr,1,!0),p-=1;r&&(this.applyTransforms(this.pMatrix,this.rMatrix,this.sMatrix,this.tr,-r,!0),p-=r)}s=1===this.data.m?0:this._currentCopies-1;const c=1===this.data.m?1:-1;for(i=this._currentCopies;i;){const t=this.elemsData[s].it,e=t[t.length-1].transform.mProps.v.props,h=e.length;if(t[t.length-1].transform.mProps._mdf=!0,t[t.length-1].transform.op._mdf=!0,t[t.length-1].transform.op.v=this.so.v+(this.eo.v-this.so.v)*(s/(this._currentCopies-1)),0!==p){(0!==s&&1===c||s!==this._currentCopies-1&&-1===c)&&this.applyTransforms(this.pMatrix,this.rMatrix,this.sMatrix,this.tr,1,!1),this.matrix.transform(o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],o[8],o[9],o[10],o[11],o[12],o[13],o[14],o[15]),this.matrix.transform(l[0],l[1],l[2],l[3],l[4],l[5],l[6],l[7],l[8],l[9],l[10],l[11],l[12],l[13],l[14],l[15]),this.matrix.transform(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9],n[10],n[11],n[12],n[13],n[14],n[15]);for(let t=0;t.01)return!1;i+=1}return!0}checkCollapsable(){if(this.o.length/2!=this.c.length/4)return!1;if(this.data.k.k[0].s){let t=0,s=this.data.k.k.length;for(;t=0;s-=1)this.shapeModifiers[s].processShapes(t,this._isFirstFrame)}searchProcessedElement(t){let s=this.processedElements,e=0,i=s.length;for(;e=0;r-=1){if(o=this.searchProcessedElement(t[r]),o?s[r]=e[o-1]:t[r]._shouldRender=i,"fl"==t[r].ty||"st"==t[r].ty||"gf"==t[r].ty||"gs"==t[r].ty)o?s[r].style.closed=!1:s[r]=this.createStyleElement(t[r],f),d.push(s[r].style);else if("gr"==t[r].ty){if(o)for(n=s[r].it.length,a=0;a=0;h-=1)"tr"==s[h].ty?(i=e[h].transform,this.updateShapeTransform(t,i)):"sh"==s[h].ty||"el"==s[h].ty||"rc"==s[h].ty||"sr"==s[h].ty?this.updatePath(s[h],e[h]):"fl"==s[h].ty?this.updateFill(s[h],e[h],i):"st"==s[h].ty?this.updateStroke(s[h],e[h],i):"gf"==s[h].ty||"gs"==s[h].ty?this.updateGradientFill(s[h],e[h],i):"gr"==s[h].ty&&this.updateShape(i,s[h].it,e[h].it)}updateGrahpics(){const t=this.stylesList.length;for(let s=0;s=e.op-e.st,this.isOverlapMode=i.overlapMode,this.parseLayer(t,s)}outTypeExpressionMode(){this._hasOutTypeExpression=!0,this.isOverlapLayer&&(this.needUpdateOverlap=!0)}prepareProperties(t,s){let e,i=this.dynamicProperties.length;for(e=0;e=this.layer.ip:this.visible=e,this.prepareProperties(t,e)}updateDisplay(){const t=this.elem.display;this.elem._isRoot||(this.visible?t.show():t.hide(),(this._mdf||this.transform._mdf||this._isFirstFrame)&&t.updateLottieTransform(this.transform),this.masks&&(this.masks._mdf||this._isFirstFrame)&&t.updateLottieMasks(this.masks)),this._isFirstFrame=!1}}class Xt{constructor(t){this.data=t,void 0===this.data.sr&&(this.data.sr=1),this.offsetTime=t.st||0,this.fullname=t.nm||"",this.idname=t.ln||"",this.classnames=t.cl?t.cl.split(" "):[],this.bodymovin=new Ot(this),this.displayType="",this.display=null,this.hierarchy=null,this.lottieTreeParent=null}initBodymovin(t,s){this.bodymovin.initFrame(t,s),this.display&&this.display.onSetupLottie&&this.display.onSetupLottie()}hasValidMasks(){return!(!this.bodymovin.masks||!this.bodymovin.masks.hasMasks)}setHierarchy(t){this.hierarchy=t,this.display.setHierarchy(t.display)}initDisplayInstance(t,s){return new(Tt(t))(this,s)}updateFrame(t){this.bodymovin.updateFrame(t),this.bodymovin.updateDisplay()}}class Yt extends Xt{constructor(t,s){super(t);const{global:e}=s;this.session=s;const i={layer:t,session:s};if(e.maskComp){i.maskComp=e.maskComp;const{w:s,h:h}=t;i.viewport={w:s,h:h}}this.config=i,this.childNodes=[],this.displayType=wt.Type.Component,this.innerDisplay=null,this.display=this.initDisplayInstance(this.displayType,i),this.initBodymovin(t,s)}updateFrame(t){if(this.bodymovin.updateFrame(t),this.bodymovin.updateDisplay(),t-=this.offsetTime,this.bodymovin.tm){let s=this.bodymovin.tm.v;s===this.data.op&&(s=this.data.op-1),t=s}else t/=this.data.sr;for(let s=0;s{this._setupDate(t)}),this.jsonLoader.once("error",t=>{this.emit("error",t)})}}_setupDate(t){this._sourceData=t,this._copyJSON&&(t=s.copyJSON(t)),g.completeData(t),this.keyframes=t;const{w:e,h:r,st:a=0,fr:n,ip:o,op:l,assets:p}=t;this.frameRate=n,this.frameMult=n/1e3,this._defaultSegment=[o,l];const c=this._segmentName&&this.segments[this._segmentName]||this._defaultSegment;this.beginFrame=c[0],this.endFrame=c[1],this._timePerFrame=1e3/n,this.duration=Math.floor(this.endFrame-this.beginFrame);let d=null;const u=p.filter(t=>t.u||t.p);u.length>0?(this.textureLoader=d=function(t,s){const e=i[h.Texture];return e||console.warn("must register an image loader, before you parse an animation some has image assets"),e(t,s)}(u,{prefix:this._prefix,autoLoad:this._autoLoad}),d.loaded?(this.isImagesLoaded=!0,this.isPaused=!this._autoStart,this.emit("ImageReady")):(d.once("complete",()=>{this.isImagesLoaded=!0,this.emit("ImageReady")}),null!==this._pausedNeedSet&&(this._pausedNeedSet=!0,d.once("complete",()=>{this._pausedNeedSet&&(this._pausedNeedSet=!1,this.isPaused=!this._autoStart)})))):(this.isImagesLoaded=!0,this.isPaused=!this._autoStart);const f={global:{assets:p,textureLoader:d,frameRate:n,maskComp:this._maskComp,overlapMode:this.overlapMode},local:{w:e,h:r,ip:o,op:l,st:a}};this._buildElements(f),null!==this.textureLoader&&this._justDisplayOnImagesLoaded&&!this.textureLoader.loaded&&null!==this._justDisplayNeedSet&&(this.group.visible=!1,this._justDisplayNeedSet=!0,this.textureLoader.once("complete",()=>{this._justDisplayNeedSet&&(this._justDisplayNeedSet=!1,this.group.visible=!0)})),this.isDisplayLoaded=!0,this.update(0,!0)}_buildElements(t){this.root=this._extraCompositions(this.keyframes,t,!0),this.display=this.root.display,this.group.addChild(this.display),this.emit("DOMLoaded").emit("DisplayReady"),null===this.textureLoader?this.emit("success"):this.textureLoader.loaded?this.emit("success"):this.textureLoader.once("complete",()=>this.emit("success"))}_extraCompositions(t,{global:e,local:i},h=!1){const{w:r,h:a,ip:n,op:o,st:l=0}=t,p=new Yt(t,{global:e,local:i});p._isRoot=h;const c=t.layers||s.getAssets(t.refId,e.assets).layers,d={global:e,local:{w:r,h:a,ip:n,op:o,st:l}},u=this._createElements(c,d);for(let t=c.length-1;t>=0;t--){const e=c[t],i=u[e.ind];if(i){if(!s.isUndefined(e.parent)){const t=u[e.parent];t._isParent=!0,i.setHierarchy(t)}p.addChild(i)}}return p}_createElements(t,s){const e={};for(let i=t.length-1;i>=0;i--){const h=t[i];let r=null;if(void 0===h.td){switch(h.ty){case 0:r=this._extraCompositions(h,s);break;case 1:r=new jt(h,s);break;case 2:r=new zt(h,s);break;case 3:r=new Rt(h,s);break;case 4:r=new Bt(h,s);break;default:continue}r&&(void 0===h.ind&&(h.ind=i),e[h.ind]=r,r.name=h.nm||null)}}return e}getDisplayByQuerySelector(t){const s=this.querySelector(t);return s&&s.display?s.display:(console.warn("can not find display which query with ",t),null)}_queryMatch(t,s,e){const i=t.substr(0,1),h=t.substr(1,t.length);let r=!1;return r="#"===i?s.idname===h:"."===i?-1!==s.classnames.indexOf(h):s.fullname===t,r&&e.push(s),r}_searchNodes(t,s,e,i=!1){if(s.childNodes&&s.childNodes.length>0){const h=[];for(let r=0;r0&&h.push(a)}for(let s=0;s>0;this._lastFrame!==h&&(this._emitFrame(this.direction>0?h:this._lastFrame),this._lastFrame=h),!1===e?(this.emit("enterFrame",i),this.emit("update",this.frameNum/this.duration)):this.hadEnded!==e&&!0===e&&this.emit("complete"),this.hadEnded=e}_updateTime(t){const e=this.direction*this.timeScale*t;if(this._waitCut>0)return this._waitCut-=Math.abs(e),null;if(this.isPaused||this._delayCut>0)return this._delayCut>0&&(this._delayCut-=Math.abs(e)),null;this.frameNum+=e/this._timePerFrame;let i=!1;return this._spill()&&(this._repeatsCut>0||this.infinite?(this._repeatsCut>0&&--this._repeatsCut,this._delayCut=this.delay,this.alternate?(this.direction*=-1,this.frameNum=s.codomainBounce(this.frameNum,0,this.duration)):(this.direction=1,this.frameNum=s.euclideanModulo(this.frameNum,this.duration)),this.emit("loopComplete")):(this.overlapMode||(this.frameNum=s.clamp(this.frameNum,0,this.duration),this.living=!1),i=!0)),i}_spill(){const t=this.frameNum<=0&&-1===this.direction,s=this.frameNum>=this.duration&&1===this.direction;return t||s}frameToTime(t){return t*this._timePerFrame}setSpeed(t){this.timeScale=t}playSegment(t,e={}){if(!t)return;let i=null;s.isArray(t)?i=t:s.isString(t)&&(i=this.segments[t],s.isArray(i)&&(this._segmentName=t)),s.isArray(i)&&(this.beginFrame=s.isNumber(i[0])?i[0]:this._defaultSegment[0],this.endFrame=s.isNumber(i[1])?i[1]:this._defaultSegment[1],s.isNumber(e.repeats)&&(this.repeats=e.repeats),s.isBoolean(e.infinite)&&(this.infinite=e.infinite),s.isBoolean(e.alternate)&&(this.alternate=e.alternate),s.isNumber(e.wait)&&(this.wait=e.wait),s.isNumber(e.delay)&&(this.delay=e.delay),this.replay())}goToAndStop(t,s=!1){this.frameNum=s?t:t*this.frameMult,this.update(0,!0),this.pause()}goToAndPlay(t,s=!1){this.frameNum=s?t:t*this.frameMult,this.update(0,!0),this.resume()}getDuration(t){const s=this.endFrame-this.beginFrame;return t?s:s/this.frameRate}setDirection(t){return this.direction=t<0?-1:1,this}pause(){return this._pausedNeedSet?this._pausedNeedSet=!1:this._pausedNeedSet=null,this.isPaused=!0,this}resume(){return this._pausedNeedSet?this._pausedNeedSet=!1:this._pausedNeedSet=null,this.isPaused=!1,this}play(){return this.resume()}replay(){return this._pausedNeedSet?this._pausedNeedSet=!1:this._pausedNeedSet=null,this.isPaused=!1,this._repeatsCut=this.repeats,this._delayCut=this.delay,this.living=!0,this.frameNum=0,this.duration=Math.floor(this.endFrame-this.beginFrame),this.direction=1,this}show(){this._justDisplayNeedSet?this._justDisplayNeedSet=!1:this._justDisplayNeedSet=null,this.group.visible=!0}hide(){this._justDisplayNeedSet?this._justDisplayNeedSet=!1:this._justDisplayNeedSet=null,this.group.visible=!1}destroy(){this.parent&&this.parent.remove(this),this.group.parent&&this.group.parent.removeChild(this.group),this.pause(),this.root=null,this.group=null,this.display=null,this.textureLoader&&(this.textureLoader.off("complete"),this.textureLoader=null),this.jsonLoader&&(this.jsonLoader.off("success"),this.jsonLoader=null),this.keyframes=null,this.living=!1}}class Gt extends e{constructor(t){super(),this._lastTime=0,this._snippet=0,this.timeScale=1,this.isPaused=!1,this.ticker=t.ticker?t.ticker:t,this.groups=[],this.update=this.update.bind(this),this.ticker&&this.start()}add(t){const s=arguments.length;if(s>1)for(let t=0;t1)for(let t=0;t200)&&(this._lastTime=Date.now(),t=Date.now()-this._lastTime),this._lastTime+=t,this._snippet=t}destroy(){for(let t=this.groups.length-1;t>=0;t--)this.groups[t].destroy()}}export{Kt as AnimationGroup,Gt as AnimationManager,M as BezierEasing,wt as DisplayRegister,e as Eventer,r as LoaderRegister,pt as PropertyFactory,s as Tools,qt as TransformFrames,Lt as TransformProperty}; \ No newline at end of file + */ var kt = (function () { + var t = Math.cos, + s = Math.sin, + e = Math.tan, + i = Math.round; + function h() { + return ( + (this.props[0] = 1), + (this.props[1] = 0), + (this.props[2] = 0), + (this.props[3] = 0), + (this.props[4] = 0), + (this.props[5] = 1), + (this.props[6] = 0), + (this.props[7] = 0), + (this.props[8] = 0), + (this.props[9] = 0), + (this.props[10] = 1), + (this.props[11] = 0), + (this.props[12] = 0), + (this.props[13] = 0), + (this.props[14] = 0), + (this.props[15] = 1), + this + ); + } + function r(e) { + if (0 === e) return this; + var i = t(e), + h = s(e); + return this._t(i, -h, 0, 0, h, i, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); + } + function a(e) { + if (0 === e) return this; + var i = t(e), + h = s(e); + return this._t(1, 0, 0, 0, 0, i, -h, 0, 0, h, i, 0, 0, 0, 0, 1); + } + function n(e) { + if (0 === e) return this; + var i = t(e), + h = s(e); + return this._t(i, 0, h, 0, 0, 1, 0, 0, -h, 0, i, 0, 0, 0, 0, 1); + } + function o(e) { + if (0 === e) return this; + var i = t(e), + h = s(e); + return this._t(i, -h, 0, 0, h, i, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); + } + function l(t, s) { + return this._t(1, s, t, 1, 0, 0); + } + function p(t, s) { + return this.shear(e(t), e(s)); + } + function c(i, h) { + var r = t(h), + a = s(h); + return this._t(r, a, 0, 0, -a, r, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1) + ._t(1, 0, 0, 0, e(i), 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1) + ._t(r, -a, 0, 0, a, r, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); + } + function d(t, s, e) { + return ( + e || 0 === e || (e = 1), + 1 === t && 1 === s && 1 === e ? this : this._t(t, 0, 0, 0, 0, s, 0, 0, 0, 0, e, 0, 0, 0, 0, 1) + ); + } + function u(t, s, e, i, h, r, a, n, o, l, p, c, d, u, f, m) { + return ( + (this.props[0] = t), + (this.props[1] = s), + (this.props[2] = e), + (this.props[3] = i), + (this.props[4] = h), + (this.props[5] = r), + (this.props[6] = a), + (this.props[7] = n), + (this.props[8] = o), + (this.props[9] = l), + (this.props[10] = p), + (this.props[11] = c), + (this.props[12] = d), + (this.props[13] = u), + (this.props[14] = f), + (this.props[15] = m), + this + ); + } + function f(t, s, e) { + return (e = e || 0), 0 !== t || 0 !== s || 0 !== e ? this._t(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, t, s, e, 1) : this; + } + function m(t, s, e, i, h, r, a, n, o, l, p, c, d, u, f, m) { + var g = this.props; + if ( + 1 === t && + 0 === s && + 0 === e && + 0 === i && + 0 === h && + 1 === r && + 0 === a && + 0 === n && + 0 === o && + 0 === l && + 1 === p && + 0 === c + ) + return ( + (g[12] = g[12] * t + g[15] * d), + (g[13] = g[13] * r + g[15] * u), + (g[14] = g[14] * p + g[15] * f), + (g[15] = g[15] * m), + (this._identityCalculated = !1), + this + ); + var y = g[0], + v = g[1], + _ = g[2], + k = g[3], + S = g[4], + x = g[5], + M = g[6], + P = g[7], + T = g[8], + w = g[9], + D = g[10], + L = g[11], + F = g[12], + A = g[13], + C = g[14], + b = g[15]; + return ( + (g[0] = y * t + v * h + _ * o + k * d), + (g[1] = y * s + v * r + _ * l + k * u), + (g[2] = y * e + v * a + _ * p + k * f), + (g[3] = y * i + v * n + _ * c + k * m), + (g[4] = S * t + x * h + M * o + P * d), + (g[5] = S * s + x * r + M * l + P * u), + (g[6] = S * e + x * a + M * p + P * f), + (g[7] = S * i + x * n + M * c + P * m), + (g[8] = T * t + w * h + D * o + L * d), + (g[9] = T * s + w * r + D * l + L * u), + (g[10] = T * e + w * a + D * p + L * f), + (g[11] = T * i + w * n + D * c + L * m), + (g[12] = F * t + A * h + C * o + b * d), + (g[13] = F * s + A * r + C * l + b * u), + (g[14] = F * e + A * a + C * p + b * f), + (g[15] = F * i + A * n + C * c + b * m), + (this._identityCalculated = !1), + this + ); + } + function g() { + return ( + this._identityCalculated || + ((this._identity = !( + 1 !== this.props[0] || + 0 !== this.props[1] || + 0 !== this.props[2] || + 0 !== this.props[3] || + 0 !== this.props[4] || + 1 !== this.props[5] || + 0 !== this.props[6] || + 0 !== this.props[7] || + 0 !== this.props[8] || + 0 !== this.props[9] || + 1 !== this.props[10] || + 0 !== this.props[11] || + 0 !== this.props[12] || + 0 !== this.props[13] || + 0 !== this.props[14] || + 1 !== this.props[15] + )), + (this._identityCalculated = !0)), + this._identity + ); + } + function y(t) { + for (var s = 0; s < 16; ) { + if (t.props[s] !== this.props[s]) return !1; + s += 1; + } + return !0; + } + function v(t) { + var s; + for (s = 0; s < 16; s += 1) t.props[s] = this.props[s]; + } + function _(t) { + var s; + for (s = 0; s < 16; s += 1) this.props[s] = t[s]; + } + function k(t, s, e) { + return { + x: t * this.props[0] + s * this.props[4] + e * this.props[8] + this.props[12], + y: t * this.props[1] + s * this.props[5] + e * this.props[9] + this.props[13], + z: t * this.props[2] + s * this.props[6] + e * this.props[10] + this.props[14], + }; + } + function S(t, s, e) { + return t * this.props[0] + s * this.props[4] + e * this.props[8] + this.props[12]; + } + function x(t, s, e) { + return t * this.props[1] + s * this.props[5] + e * this.props[9] + this.props[13]; + } + function M(t, s, e) { + return t * this.props[2] + s * this.props[6] + e * this.props[10] + this.props[14]; + } + function P(t) { + var s = this.props[0] * this.props[5] - this.props[1] * this.props[4], + e = this.props[5] / s, + i = -this.props[1] / s, + h = -this.props[4] / s, + r = this.props[0] / s, + a = (this.props[4] * this.props[13] - this.props[5] * this.props[12]) / s, + n = -(this.props[0] * this.props[13] - this.props[1] * this.props[12]) / s; + return [t[0] * e + t[1] * h + a, t[0] * i + t[1] * r + n, 0]; + } + function T(t) { + var s, + e = t.length, + i = []; + for (s = 0; s < e; s += 1) i[s] = P(t[s]); + return i; + } + function D(t, s, e) { + var i = w('float32', 6); + if (this.isIdentity()) (i[0] = t[0]), (i[1] = t[1]), (i[2] = s[0]), (i[3] = s[1]), (i[4] = e[0]), (i[5] = e[1]); + else { + var h = this.props[0], + r = this.props[1], + a = this.props[4], + n = this.props[5], + o = this.props[12], + l = this.props[13]; + (i[0] = t[0] * h + t[1] * a + o), + (i[1] = t[0] * r + t[1] * n + l), + (i[2] = s[0] * h + s[1] * a + o), + (i[3] = s[0] * r + s[1] * n + l), + (i[4] = e[0] * h + e[1] * a + o), + (i[5] = e[0] * r + e[1] * n + l); + } + return i; + } + function L(t, s, e) { + return this.isIdentity() + ? [t, s, e] + : [ + t * this.props[0] + s * this.props[4] + e * this.props[8] + this.props[12], + t * this.props[1] + s * this.props[5] + e * this.props[9] + this.props[13], + t * this.props[2] + s * this.props[6] + e * this.props[10] + this.props[14], + ]; + } + function F(t, s) { + if (this.isIdentity()) return t + ',' + s; + var e = this.props; + return ( + Math.round(100 * (t * e[0] + s * e[4] + e[12])) / 100 + + ',' + + Math.round(100 * (t * e[1] + s * e[5] + e[13])) / 100 + ); + } + function A() { + for (var t = 0, s = this.props, e = 'matrix3d('; t < 16; ) + (e += i(1e4 * s[t]) / 1e4), (e += 15 === t ? ')' : ','), (t += 1); + return e; + } + function C(t) { + return (t < 1e-6 && t > 0) || (t > -1e-6 && t < 0) ? i(1e4 * t) / 1e4 : t; + } + function b() { + var t = this.props; + return 'matrix(' + C(t[0]) + ',' + C(t[1]) + ',' + C(t[4]) + ',' + C(t[5]) + ',' + C(t[12]) + ',' + C(t[13]) + ')'; + } + return function () { + (this.reset = h), + (this.rotate = r), + (this.rotateX = a), + (this.rotateY = n), + (this.rotateZ = o), + (this.skew = p), + (this.skewFromAxis = c), + (this.shear = l), + (this.scale = d), + (this.setTransform = u), + (this.translate = f), + (this.transform = m), + (this.applyToPoint = k), + (this.applyToX = S), + (this.applyToY = x), + (this.applyToZ = M), + (this.applyToPointArray = L), + (this.applyToTriplePoints = D), + (this.applyToPointStringified = F), + (this.toCSS = A), + (this.to2dCSS = b), + (this.clone = v), + (this.cloneFromProps = _), + (this.equals = y), + (this.inversePoints = T), + (this.inversePoint = P), + (this._t = this.transform), + (this.isIdentity = g), + (this._identity = !0), + (this._identityCalculated = !1), + (this.props = w('float32', 16)), + this.reset(); + }; +})(); +class St { + constructor() { + (this.sequences = {}), (this.sequenceList = []), (this.transform_key_count = 0); + } + addTransformSequence(t) { + const s = t.length; + let e = '_'; + for (let i = 0; i < s; i += 1) e += t[i].transform.key + '_'; + let i = this.sequences[e]; + return ( + i || + ((i = { transforms: [].concat(t), finalTransform: new kt(), _mdf: !1 }), + (this.sequences[e] = i), + this.sequenceList.push(i)), + i + ); + } + processSequence(t, s) { + let e = 0, + i = s; + const h = t.transforms.length; + for (; e < h && !s; ) { + if (t.transforms[e].transform.mProps._mdf) { + i = !0; + break; + } + e += 1; + } + if (i) { + let s; + for (t.finalTransform.reset(), e = h - 1; e >= 0; e -= 1) + (s = t.transforms[e].transform.mProps.v.props), + t.finalTransform.transform( + s[0], + s[1], + s[2], + s[3], + s[4], + s[5], + s[6], + s[7], + s[8], + s[9], + s[10], + s[11], + s[12], + s[13], + s[14], + s[15], + ); + } + t._mdf = i; + } + processSequences(t) { + const s = this.sequenceList.length; + for (let e = 0; e < s; e += 1) this.processSequence(this.sequenceList[e], t); + } + getNewKey() { + return '_' + this.transform_key_count++; + } +} +class xt { + constructor(t, s) { + (this.elem = t), (this.pos = s); + } +} +class Mt { + constructor(t, s, e, i) { + (this.styledShapes = []), (this.tr = [0, 0, 0, 0, 0, 0]); + let h = 4; + 'rc' == s.ty ? (h = 5) : 'el' == s.ty ? (h = 6) : 'sr' == s.ty && (h = 7), (this.sh = vt.getShapeProp(t, s, h)); + const r = e.length; + for (let t = 0; t < r; t += 1) + if (!e[t].closed) { + const s = { transforms: i.addTransformSequence(e[t].transforms), trNodes: [] }; + this.styledShapes.push(s), e[t].elements.push(s); + } + } + setAsAnimated() { + this._isAnimated = !0; + } +} +const Pt = {}; +function Tt(t) { + return Pt[t]; +} +var wt = { + Type: { + Null: 'Null', + Path: 'Path', + Shape: 'Shape', + Solid: 'Solid', + Sprite: 'Sprite', + Component: 'Component', + Container: 'Container', + }, + registerDisplayByType: function (t, s) { + Pt[t] = s; + }, +}; +class Dt { + constructor(t, s, e) { + (this.elem = t), + (this.data = s), + (this.type = s.ty), + (this.preTransforms = e), + (this.transforms = []), + (this.elements = []), + (this.closed = !0 === s.hd), + (this.displayType = wt.Type.Path); + const i = Tt(this.displayType); + (this.display = new i(this, s)), + this.elem.innerDisplay ? this.elem.innerDisplay.addChild(this.display) : this.elem.display.addChild(this.display); + } + updateGrahpics() { + this.display.updateLottieGrahpics(this); + } +} +class Lt extends O { + constructor(t, s, e) { + if ( + (super(), + (this.elem = t), + (this.frameId = -1), + (this.propType = 'transform'), + (this.data = s), + (this.v = new kt()), + (this.pre = new kt()), + (this.appliedTransformations = 0), + this.initDynamicPropertyContainer(e || t), + s.p && s.p.s + ? ((this.px = pt.getProp(t, s.p.x, 0, 0, this)), + (this.py = pt.getProp(t, s.p.y, 0, 0, this)), + s.p.z && (this.pz = pt.getProp(t, s.p.z, 0, 0, this))) + : (this.p = pt.getProp(t, s.p || { k: [0, 0, 0] }, 1, 0, this)), + s.rx) + ) { + if ( + ((this.rx = pt.getProp(t, s.rx, 0, U, this)), + (this.ry = pt.getProp(t, s.ry, 0, U, this)), + (this.rz = pt.getProp(t, s.rz, 0, U, this)), + s.or.k[0].ti) + ) { + let t, + e = s.or.k.length; + for (t = 0; t < e; t += 1) s.or.k[t].to = s.or.k[t].ti = null; + } + (this.or = pt.getProp(t, s.or, 1, U, this)), (this.or.sh = !0); + } else this.r = pt.getProp(t, s.r || { k: 0 }, 0, U, this); + s.sk && ((this.sk = pt.getProp(t, s.sk, 0, U, this)), (this.sa = pt.getProp(t, s.sa, 0, U, this))), + (this.a = pt.getProp(t, s.a || { k: [0, 0, 0] }, 1, 0, this)), + (this.s = pt.getProp(t, s.s || { k: [100, 100, 100] }, 1, 0.01, this)), + s.o ? (this.o = pt.getProp(t, s.o, 0, 0.01, t)) : (this.o = { _mdf: !1, v: 1 }), + (this._isDirty = !0), + this.dynamicProperties.length || this.getValue(-999999, !0); + } + getValue(t, s) { + if (t !== this.frameId) { + if ( + (this._isDirty && (this.precalculateMatrix(), (this._isDirty = !1)), + this.iterateDynamicProperties(), + this._mdf || s) + ) { + if ( + (this.v.cloneFromProps(this.pre.props), + this.appliedTransformations < 1 && this.v.translate(-this.a.v[0], -this.a.v[1], this.a.v[2]), + this.appliedTransformations < 2 && this.v.scale(this.s.v[0], this.s.v[1], this.s.v[2]), + this.sk && this.appliedTransformations < 3 && this.v.skewFromAxis(-this.sk.v, this.sa.v), + this.r && this.appliedTransformations < 4 + ? this.v.rotate(-this.r.v) + : !this.r && + this.appliedTransformations < 4 && + this.v + .rotateZ(-this.rz.v) + .rotateY(this.ry.v) + .rotateX(this.rx.v) + .rotateZ(-this.or.v[2]) + .rotateY(this.or.v[1]) + .rotateX(this.or.v[0]), + this.autoOriented) + ) { + let t, s; + const e = this.elem.globalData.frameRate; + if (this.p && this.p.keyframes && this.p.getValueAtTime) + this.p._caching.lastFrame + this.p.offsetTime <= this.p.keyframes[0].t + ? ((t = this.p.getValueAtTime((this.p.keyframes[0].t + 0.01) / e, 0)), + (s = this.p.getValueAtTime(this.p.keyframes[0].t / e, 0))) + : this.p._caching.lastFrame + this.p.offsetTime >= this.p.keyframes[this.p.keyframes.length - 1].t + ? ((t = this.p.getValueAtTime(this.p.keyframes[this.p.keyframes.length - 1].t / e, 0)), + (s = this.p.getValueAtTime((this.p.keyframes[this.p.keyframes.length - 1].t - 0.05) / e, 0))) + : ((t = this.p.pv), + (s = this.p.getValueAtTime( + (this.p._caching.lastFrame + this.p.offsetTime - 0.01) / e, + this.p.offsetTime, + ))); + else if ( + this.px && + this.px.keyframes && + this.py.keyframes && + this.px.getValueAtTime && + this.py.getValueAtTime + ) { + (t = []), (s = []); + let i = this.px, + h = this.py; + i._caching.lastFrame + i.offsetTime <= i.keyframes[0].t + ? ((t[0] = i.getValueAtTime((i.keyframes[0].t + 0.01) / e, 0)), + (t[1] = h.getValueAtTime((h.keyframes[0].t + 0.01) / e, 0)), + (s[0] = i.getValueAtTime(i.keyframes[0].t / e, 0)), + (s[1] = h.getValueAtTime(h.keyframes[0].t / e, 0))) + : i._caching.lastFrame + i.offsetTime >= i.keyframes[i.keyframes.length - 1].t + ? ((t[0] = i.getValueAtTime(i.keyframes[i.keyframes.length - 1].t / e, 0)), + (t[1] = h.getValueAtTime(h.keyframes[h.keyframes.length - 1].t / e, 0)), + (s[0] = i.getValueAtTime((i.keyframes[i.keyframes.length - 1].t - 0.01) / e, 0)), + (s[1] = h.getValueAtTime((h.keyframes[h.keyframes.length - 1].t - 0.01) / e, 0))) + : ((t = [i.pv, h.pv]), + (s[0] = i.getValueAtTime((i._caching.lastFrame + i.offsetTime - 0.01) / e, i.offsetTime)), + (s[1] = h.getValueAtTime((h._caching.lastFrame + h.offsetTime - 0.01) / e, h.offsetTime))); + } else t = s = Z; + this.v.rotate(-Math.atan2(t[1] - s[1], t[0] - s[0])); + } + this.data.p && this.data.p.s + ? this.data.p.z + ? this.v.translate(this.px.v, this.py.v, -this.pz.v) + : this.v.translate(this.px.v, this.py.v, 0) + : this.v.translate(this.p.v[0], this.p.v[1], -this.p.v[2]); + } + this.frameId = t; + } + } + precalculateMatrix() { + if ( + !this.a.k && + (this.pre.translate(-this.a.v[0], -this.a.v[1], this.a.v[2]), + (this.appliedTransformations = 1), + !this.s.effectsSequence.length) + ) { + if ((this.pre.scale(this.s.v[0], this.s.v[1], this.s.v[2]), (this.appliedTransformations = 2), this.sk)) { + if (this.sk.effectsSequence.length || this.sa.effectsSequence.length) return; + this.pre.skewFromAxis(-this.sk.v, this.sa.v), (this.appliedTransformations = 3); + } + if (this.r) { + if (this.r.effectsSequence.length) return; + this.pre.rotate(-this.r.v), (this.appliedTransformations = 4); + } else + this.rz.effectsSequence.length || + this.ry.effectsSequence.length || + this.rx.effectsSequence.length || + this.or.effectsSequence.length || + (this.pre + .rotateZ(-this.rz.v) + .rotateY(this.ry.v) + .rotateX(this.rx.v) + .rotateZ(-this.or.v[2]) + .rotateY(this.or.v[1]) + .rotateX(this.or.v[0]), + (this.appliedTransformations = 4)); + } + } + applyToMatrix(t) { + let s = this._mdf; + this.iterateDynamicProperties(), + (this._mdf = this._mdf || s), + this.a && t.translate(-this.a.v[0], -this.a.v[1], this.a.v[2]), + this.s && t.scale(this.s.v[0], this.s.v[1], this.s.v[2]), + this.sk && t.skewFromAxis(-this.sk.v, this.sa.v), + this.r + ? t.rotate(-this.r.v) + : t + .rotateZ(-this.rz.v) + .rotateY(this.ry.v) + .rotateX(this.rx.v) + .rotateZ(-this.or.v[2]) + .rotateY(this.or.v[1]) + .rotateX(this.or.v[0]), + this.data.p.s + ? this.data.p.z + ? t.translate(this.px.v, this.py.v, -this.pz.v) + : t.translate(this.px.v, this.py.v, 0) + : t.translate(this.p.v[0], this.p.v[1], -this.p.v[2]); + } +} +function Ft(t, s, e) { + return new Lt(t, s, e); +} +class At extends O { + initModifierProperties() {} + addShapeToModifier() {} + addShape(t) { + if (!this.closed) { + t.sh.container.addDynamicProperty(t.sh); + const s = { shape: t.sh, data: t, localShapeCollection: q.newShapeCollection() }; + this.shapes.push(s), this.addShapeToModifier(s), this._isAnimated && t.setAsAnimated(); + } + } + init(t, s) { + (this.shapes = []), + (this.elem = t), + this.initDynamicPropertyContainer(t), + this.initModifierProperties(t, s), + (this.frameId = -999999), + (this.closed = !1), + (this.k = !1), + this.dynamicProperties.length ? (this.k = !0) : this.getValue(!0); + } + processKeys(t) { + t !== this.frameId && ((this.frameId = t), this.iterateDynamicProperties(t)); + } +} +const Ct = {}; +function bt(t, s) { + Ct[t] || (Ct[t] = s); +} +bt( + 'tm', + class extends At { + initModifierProperties(t, s) { + (this.s = pt.getProp(t, s.s, 0, 0.01, this)), + (this.e = pt.getProp(t, s.e, 0, 0.01, this)), + (this.o = pt.getProp(t, s.o, 0, 0, this)), + (this.sValue = 0), + (this.eValue = 0), + (this.getValue = this.processKeys), + (this.m = s.m), + (this._isAnimated = + !!this.s.effectsSequence.length || !!this.e.effectsSequence.length || !!this.o.effectsSequence.length); + } + addShapeToModifier(t) { + t.pathsData = []; + } + calculateShapeEdges(t, s, e, i, h) { + let r = []; + s <= 1 + ? r.push({ s: t, e: s }) + : t >= 1 + ? r.push({ s: t - 1, e: s - 1 }) + : (r.push({ s: t, e: 1 }), r.push({ s: 0, e: s - 1 })); + let a, + n, + o = [], + l = r.length; + for (a = 0; a < l; a += 1) + if (((n = r[a]), n.e * h < i || n.s * h > i + e)); + else { + let t, s; + (t = n.s * h <= i ? 0 : (n.s * h - i) / e), (s = n.e * h >= i + e ? 1 : (n.e * h - i) / e), o.push([t, s]); + } + return o.length || o.push([0, 0]), o; + } + releasePathsData(t) { + const s = t.length; + for (let e = 0; e < s; e += 1) Y.release(t[e]); + return (t.length = 0), t; + } + processShapes(t) { + let s, e, i, h; + if (this._mdf || t) { + let t = (this.o.v % 360) / 360; + if ( + (t < 0 && (t += 1), + (s = (this.s.v > 1 ? 1 : this.s.v < 0 ? 0 : this.s.v) + t), + (e = (this.e.v > 1 ? 1 : this.e.v < 0 ? 0 : this.e.v) + t), + s > e) + ) { + let t = s; + (s = e), (e = t); + } + (s = 1e-4 * Math.round(1e4 * s)), (e = 1e-4 * Math.round(1e4 * e)), (this.sValue = s), (this.eValue = e); + } else (s = this.sValue), (e = this.eValue); + let r, + a, + n, + o, + l, + p = this.shapes.length, + c = 0; + if (e === s) + for (h = 0; h < p; h += 1) + this.shapes[h].localShapeCollection.releaseShapes(), + (this.shapes[h].shape._mdf = !0), + (this.shapes[h].shape.paths = this.shapes[h].localShapeCollection), + this._mdf && (this.shapes[h].pathsData.length = 0); + else if ((1 === e && 0 === s) || (0 === e && 1 === s)) { + if (this._mdf) + for (h = 0; h < p; h += 1) (this.shapes[h].pathsData.length = 0), (this.shapes[h].shape._mdf = !0); + } else { + let d, + u, + f = []; + for (h = 0; h < p; h += 1) + if (((d = this.shapes[h]), d.shape._mdf || this._mdf || t || 2 === this.m)) { + if (((i = d.shape.paths), (a = i._length), (l = 0), !d.shape._mdf && d.pathsData.length)) + l = d.totalShapeLength; + else { + for (n = this.releasePathsData(d.pathsData), r = 0; r < a; r += 1) + (o = H.getSegmentsLength(i.shapes[r])), n.push(o), (l += o.totalLength); + (d.totalShapeLength = l), (d.pathsData = n); + } + (c += l), (d.shape._mdf = !0); + } else d.shape.paths = d.localShapeCollection; + let m, + g = s, + y = e, + v = 0; + for (h = p - 1; h >= 0; h -= 1) + if (((d = this.shapes[h]), d.shape._mdf)) { + for ( + u = d.localShapeCollection, + u.releaseShapes(), + 2 === this.m && p > 1 + ? ((m = this.calculateShapeEdges(s, e, d.totalShapeLength, v, c)), (v += d.totalShapeLength)) + : (m = [[g, y]]), + a = m.length, + r = 0; + r < a; + r += 1 + ) { + (g = m[r][0]), + (y = m[r][1]), + (f.length = 0), + y <= 1 + ? f.push({ s: d.totalShapeLength * g, e: d.totalShapeLength * y }) + : g >= 1 + ? f.push({ s: d.totalShapeLength * (g - 1), e: d.totalShapeLength * (y - 1) }) + : (f.push({ s: d.totalShapeLength * g, e: d.totalShapeLength }), + f.push({ s: 0, e: d.totalShapeLength * (y - 1) })); + let t = this.addShapes(d, f[0]); + if (f[0].s !== f[0].e) { + if (f.length > 1) { + if (d.shape.paths.shapes[d.shape.paths._length - 1].c) { + let s = t.pop(); + this.addPaths(t, u), (t = this.addShapes(d, f[1], s)); + } else this.addPaths(t, u), (t = this.addShapes(d, f[1])); + } + this.addPaths(t, u); + } + } + d.shape.paths = u; + } + } + } + addPaths(t, s) { + const e = t.length; + for (let i = 0; i < e; i += 1) s.addShape(t[i]); + } + addSegment(t, s, e, i, h, r, a) { + h.setXYAt(s[0], s[1], 'o', r), + h.setXYAt(e[0], e[1], 'i', r + 1), + a && h.setXYAt(t[0], t[1], 'v', r), + h.setXYAt(i[0], i[1], 'v', r + 1); + } + addSegmentFromArray(t, s, e, i) { + s.setXYAt(t[1], t[5], 'o', e), + s.setXYAt(t[2], t[6], 'i', e + 1), + i && s.setXYAt(t[0], t[4], 'v', e), + s.setXYAt(t[3], t[7], 'v', e + 1); + } + addShapes(t, s, e) { + let i, + h, + r, + a, + n, + o, + l, + p, + c = t.pathsData, + d = t.shape.paths.shapes, + u = t.shape.paths._length, + f = 0, + m = [], + g = !0; + for ( + e ? ((n = e._length), (p = e._length)) : ((e = b.newElement()), (n = 0), (p = 0)), m.push(e), i = 0; + i < u; + i += 1 + ) { + for (o = c[i].lengths, e.c = d[i].c, r = d[i].c ? o.length : o.length + 1, h = 1; h < r; h += 1) + if (((a = o[h - 1]), f + a.addedLength < s.s)) (f += a.addedLength), (e.c = !1); + else { + if (f > s.e) { + e.c = !1; + break; + } + s.s <= f && s.e >= f + a.addedLength + ? (this.addSegment(d[i].v[h - 1], d[i].o[h - 1], d[i].i[h], d[i].v[h], e, n, g), (g = !1)) + : ((l = H.getNewSegment( + d[i].v[h - 1], + d[i].v[h], + d[i].o[h - 1], + d[i].i[h], + (s.s - f) / a.addedLength, + (s.e - f) / a.addedLength, + o[h - 1], + )), + this.addSegmentFromArray(l, e, n, g), + (g = !1), + (e.c = !1)), + (f += a.addedLength), + (n += 1); + } + if (d[i].c && o.length) { + if (((a = o[h - 1]), f <= s.e)) { + let t = o[h - 1].addedLength; + s.s <= f && s.e >= f + t + ? (this.addSegment(d[i].v[h - 1], d[i].o[h - 1], d[i].i[0], d[i].v[0], e, n, g), (g = !1)) + : ((l = H.getNewSegment( + d[i].v[h - 1], + d[i].v[0], + d[i].o[h - 1], + d[i].i[0], + (s.s - f) / t, + (s.e - f) / t, + o[h - 1], + )), + this.addSegmentFromArray(l, e, n, g), + (g = !1), + (e.c = !1)); + } else e.c = !1; + (f += a.addedLength), (n += 1); + } + if ( + (e._length && + (e.setXYAt(e.v[p][0], e.v[p][1], 'i', p), + e.setXYAt(e.v[e._length - 1][0], e.v[e._length - 1][1], 'o', e._length - 1)), + f > s.e) + ) + break; + i < u - 1 && ((e = b.newElement()), (g = !0), m.push(e), (n = 0)); + } + return m; + } + }, +), + bt( + 'rd', + class extends At { + initModifierProperties(t, s) { + (this.getValue = this.processKeys), + (this.rd = pt.getProp(t, s.r, 0, null, this)), + (this._isAnimated = !!this.rd.effectsSequence.length); + } + processPath(t, s) { + const e = b.newElement(); + let i; + e.c = t.c; + let h, + r, + a, + n, + o, + l, + p, + c, + d, + u, + f, + m, + g = t._length, + y = 0; + for (i = 0; i < g; i += 1) + (h = t.v[i]), + (a = t.o[i]), + (r = t.i[i]), + h[0] === a[0] && h[1] === a[1] && h[0] === r[0] && h[1] === r[1] + ? (0 !== i && i !== g - 1) || t.c + ? ((n = 0 === i ? t.v[g - 1] : t.v[i - 1]), + (o = Math.sqrt(Math.pow(h[0] - n[0], 2) + Math.pow(h[1] - n[1], 2))), + (l = o ? Math.min(o / 2, s) / o : 0), + (p = f = h[0] + (n[0] - h[0]) * l), + (c = m = h[1] - (h[1] - n[1]) * l), + (d = p - 0.5519 * (p - h[0])), + (u = c - 0.5519 * (c - h[1])), + e.setTripleAt(p, c, d, u, f, m, y), + (y += 1), + (n = i === g - 1 ? t.v[0] : t.v[i + 1]), + (o = Math.sqrt(Math.pow(h[0] - n[0], 2) + Math.pow(h[1] - n[1], 2))), + (l = o ? Math.min(o / 2, s) / o : 0), + (p = d = h[0] + (n[0] - h[0]) * l), + (c = u = h[1] + (n[1] - h[1]) * l), + (f = p - 0.5519 * (p - h[0])), + (m = c - 0.5519 * (c - h[1])), + e.setTripleAt(p, c, d, u, f, m, y), + (y += 1)) + : (e.setTripleAt(h[0], h[1], a[0], a[1], r[0], r[1], y), (y += 1)) + : (e.setTripleAt(t.v[i][0], t.v[i][1], t.o[i][0], t.o[i][1], t.i[i][0], t.i[i][1], y), (y += 1)); + return e; + } + processShapes(t) { + let s, + e, + i, + h, + r = this.shapes.length, + a = this.rd.v; + if (0 !== a) { + let n, o; + for (e = 0; e < r; e += 1) { + if (((n = this.shapes[e]), (o = n.localShapeCollection), n.shape._mdf || this._mdf || t)) + for ( + o.releaseShapes(), n.shape._mdf = !0, s = n.shape.paths.shapes, h = n.shape.paths._length, i = 0; + i < h; + i += 1 + ) + o.addShape(this.processPath(s[i], a)); + n.shape.paths = n.localShapeCollection; + } + } + this.dynamicProperties.length || (this._mdf = !1); + } + }, + ), + bt( + 'rp', + class extends At { + initModifierProperties(t, s) { + (this.getValue = this.processKeys), + (this.c = pt.getProp(t, s.c, 0, null, this)), + (this.o = pt.getProp(t, s.o, 0, null, this)), + (this.tr = Ft(t, s.tr, this)), + (this.so = pt.getProp(t, s.tr.so, 0, 0.01, this)), + (this.eo = pt.getProp(t, s.tr.eo, 0, 0.01, this)), + (this.data = s), + this.dynamicProperties.length || this.getValue(!0), + (this._isAnimated = !!this.dynamicProperties.length), + (this.pMatrix = new kt()), + (this.rMatrix = new kt()), + (this.sMatrix = new kt()), + (this.tMatrix = new kt()), + (this.matrix = new kt()); + } + applyTransforms(t, s, e, i, h, r) { + let a = r ? -1 : 1, + n = i.s.v[0] + (1 - i.s.v[0]) * (1 - h), + o = i.s.v[1] + (1 - i.s.v[1]) * (1 - h); + t.translate(i.p.v[0] * a * h, i.p.v[1] * a * h, i.p.v[2]), + s.translate(-i.a.v[0], -i.a.v[1], i.a.v[2]), + s.rotate(-i.r.v * a * h), + s.translate(i.a.v[0], i.a.v[1], i.a.v[2]), + e.translate(-i.a.v[0], -i.a.v[1], i.a.v[2]), + e.scale(r ? 1 / n : n, r ? 1 / o : o), + e.translate(i.a.v[0], i.a.v[1], i.a.v[2]); + } + init(t, s, e, i) { + for ( + this.elem = t, + this.arr = s, + this.pos = e, + this.elemsData = i, + this._currentCopies = 0, + this._elements = [], + this._groups = [], + this.frameId = -1, + this.initDynamicPropertyContainer(t), + this.initModifierProperties(t, s[e]); + e > 0; + + ) + (e -= 1), this._elements.unshift(s[e]); + this.dynamicProperties.length ? (this.k = !0) : this.getValue(!0); + } + resetElements(t) { + const s = t.length; + for (let e = 0; e < s; e += 1) (t[e]._processed = !1), 'gr' === t[e].ty && this.resetElements(t[e].it); + } + cloneElements(t) { + let s = JSON.parse(JSON.stringify(t)); + return this.resetElements(s), s; + } + changeGroupRender(t, s) { + const e = t.length; + for (let i = 0; i < e; i += 1) (t[i]._render = s), 'gr' === t[i].ty && this.changeGroupRender(t[i].it, s); + } + processShapes(t) { + if (this._mdf || t) { + let t = Math.ceil(this.c.v); + if (this._groups.length < t) { + for (; this._groups.length < t; ) { + let t = { it: this.cloneElements(this._elements), ty: 'gr' }; + t.it.push({ + a: { a: 0, ix: 1, k: [0, 0] }, + nm: 'Transform', + o: { a: 0, ix: 7, k: 100 }, + p: { a: 0, ix: 2, k: [0, 0] }, + r: { + a: 1, + ix: 6, + k: [ + { s: 0, e: 0, t: 0 }, + { s: 0, e: 0, t: 1 }, + ], + }, + s: { a: 0, ix: 3, k: [100, 100] }, + sa: { a: 0, ix: 5, k: 0 }, + sk: { a: 0, ix: 4, k: 0 }, + ty: 'tr', + }), + this.arr.splice(0, 0, t), + this._groups.splice(0, 0, t), + (this._currentCopies += 1); + } + this.elem.reloadShapes(); + } + let s, + e, + i = 0; + for (s = 0; s <= this._groups.length - 1; s += 1) + (e = i < t), (this._groups[s]._render = e), this.changeGroupRender(this._groups[s].it, e), (i += 1); + this._currentCopies = t; + let h = this.o.v, + r = h % 1, + a = h > 0 ? Math.floor(h) : Math.ceil(h), + n = this.pMatrix.props, + o = this.rMatrix.props, + l = this.sMatrix.props; + this.pMatrix.reset(), this.rMatrix.reset(), this.sMatrix.reset(), this.tMatrix.reset(), this.matrix.reset(); + let p = 0; + if (h > 0) { + for (; p < a; ) this.applyTransforms(this.pMatrix, this.rMatrix, this.sMatrix, this.tr, 1, !1), (p += 1); + r && (this.applyTransforms(this.pMatrix, this.rMatrix, this.sMatrix, this.tr, r, !1), (p += r)); + } else if (h < 0) { + for (; p > a; ) this.applyTransforms(this.pMatrix, this.rMatrix, this.sMatrix, this.tr, 1, !0), (p -= 1); + r && (this.applyTransforms(this.pMatrix, this.rMatrix, this.sMatrix, this.tr, -r, !0), (p -= r)); + } + s = 1 === this.data.m ? 0 : this._currentCopies - 1; + const c = 1 === this.data.m ? 1 : -1; + for (i = this._currentCopies; i; ) { + const t = this.elemsData[s].it, + e = t[t.length - 1].transform.mProps.v.props, + h = e.length; + if ( + ((t[t.length - 1].transform.mProps._mdf = !0), + (t[t.length - 1].transform.op._mdf = !0), + (t[t.length - 1].transform.op.v = this.so.v + (this.eo.v - this.so.v) * (s / (this._currentCopies - 1))), + 0 !== p) + ) { + ((0 !== s && 1 === c) || (s !== this._currentCopies - 1 && -1 === c)) && + this.applyTransforms(this.pMatrix, this.rMatrix, this.sMatrix, this.tr, 1, !1), + this.matrix.transform( + o[0], + o[1], + o[2], + o[3], + o[4], + o[5], + o[6], + o[7], + o[8], + o[9], + o[10], + o[11], + o[12], + o[13], + o[14], + o[15], + ), + this.matrix.transform( + l[0], + l[1], + l[2], + l[3], + l[4], + l[5], + l[6], + l[7], + l[8], + l[9], + l[10], + l[11], + l[12], + l[13], + l[14], + l[15], + ), + this.matrix.transform( + n[0], + n[1], + n[2], + n[3], + n[4], + n[5], + n[6], + n[7], + n[8], + n[9], + n[10], + n[11], + n[12], + n[13], + n[14], + n[15], + ); + for (let t = 0; t < h; t += 1) e[t] = this.matrix.props[t]; + this.matrix.reset(); + } else { + this.matrix.reset(); + for (let t = 0; t < h; t += 1) e[t] = this.matrix.props[t]; + } + (p += 1), (i -= 1), (s += c); + } + } else { + let t = this._currentCopies, + s = 0; + const e = 1; + for (; t; ) { + const i = this.elemsData[s].it; + (i[i.length - 1].transform.mProps._mdf = !1), (i[i.length - 1].transform.op._mdf = !1), (t -= 1), (s += e); + } + } + } + addShape() {} + }, + ), + bt( + 'ms', + class extends At { + initModifierProperties(t, s) { + (this.getValue = this.processKeys), (this.data = s), (this.positions = []); + } + processKeys(t, s) { + (t !== this.frameId || s) && (this._mdf = !0); + } + addShapeToModifier() { + this.positions.push([]); + } + processPath(t, s, e) { + let i, + h, + r, + a, + n = t.v.length, + o = [], + l = [], + p = []; + for (i = 0; i < n; i += 1) { + e.v[i] || + ((e.v[i] = [t.v[i][0], t.v[i][1]]), + (e.o[i] = [t.o[i][0], t.o[i][1]]), + (e.i[i] = [t.i[i][0], t.i[i][1]]), + (e.distV[i] = 0), + (e.distO[i] = 0), + (e.distI[i] = 0)), + (h = Math.atan2(t.v[i][1] - s[1], t.v[i][0] - s[0])), + (r = s[0] - e.v[i][0]), + (a = s[1] - e.v[i][1]); + let n = Math.sqrt(r * r + a * a); + (e.distV[i] += (n - e.distV[i]) * this.data.dc), + (e.v[i][0] = (Math.cos(h) * Math.max(0, this.data.maxDist - e.distV[i])) / 2 + t.v[i][0]), + (e.v[i][1] = (Math.sin(h) * Math.max(0, this.data.maxDist - e.distV[i])) / 2 + t.v[i][1]), + (h = Math.atan2(t.o[i][1] - s[1], t.o[i][0] - s[0])), + (r = s[0] - e.o[i][0]), + (a = s[1] - e.o[i][1]), + (n = Math.sqrt(r * r + a * a)), + (e.distO[i] += (n - e.distO[i]) * this.data.dc), + (e.o[i][0] = (Math.cos(h) * Math.max(0, this.data.maxDist - e.distO[i])) / 2 + t.o[i][0]), + (e.o[i][1] = (Math.sin(h) * Math.max(0, this.data.maxDist - e.distO[i])) / 2 + t.o[i][1]), + (h = Math.atan2(t.i[i][1] - s[1], t.i[i][0] - s[0])), + (r = s[0] - e.i[i][0]), + (a = s[1] - e.i[i][1]), + (n = Math.sqrt(r * r + a * a)), + (e.distI[i] += (n - e.distI[i]) * this.data.dc), + (e.i[i][0] = (Math.cos(h) * Math.max(0, this.data.maxDist - e.distI[i])) / 2 + t.i[i][0]), + (e.i[i][1] = (Math.sin(h) * Math.max(0, this.data.maxDist - e.distI[i])) / 2 + t.i[i][1]), + o.push(e.v[i]), + l.push(e.o[i]), + p.push(e.i[i]); + } + return { v: o, o: l, i: p, c: t.c }; + } + processShapes() { + let t, + s, + e, + i, + h = this.elem.globalData.mouseX, + r = this.elem.globalData.mouseY, + a = this.shapes.length; + if (h) { + let n, + o = this.elem.globalToLocal([h, r, 0]), + l = []; + for (s = 0; s < a; s += 1) + if (((n = this.shapes[s]), n.shape._mdf || this._mdf)) { + for (n.shape._mdf = !0, t = n.shape.paths, i = t.length, e = 0; e < i; e += 1) + this.positions[s][e] || + (this.positions[s][e] = { v: [], o: [], i: [], distV: [], distO: [], distI: [] }), + l.push(this.processPath(t[e], o, this.positions[s][e])); + (n.shape.paths = l), (n.last = l); + } else n.shape.paths = n.last; + } + } + }, + ); +var It = { + getModifier: function (t, s, e) { + return new Ct[t](s, e); + }, +}; +class Et extends O { + constructor(t, s, e) { + let i; + super(), + (this.elem = t), + (this.frameId = -1), + (this.dataProps = D(s.length)), + (this.k = !1), + (this.dashArray = w('float32', s.length ? s.length - 1 : 0)), + (this.dashoffset = w('float32', 1)), + this.initDynamicPropertyContainer(e); + let h, + r = s.length || 0; + for (i = 0; i < r; i += 1) + (h = pt.getProp(t, s[i].v, 0, 0, this)), (this.k = h.k || this.k), (this.dataProps[i] = { n: s[i].n, p: h }); + this.k || this.getValue(!0), (this._isAnimated = this.k); + } + getValue(t, s) { + if ( + (t !== this.frameId || s) && + ((this.frameId = t), this.iterateDynamicProperties(), (this._mdf = this._mdf || s), this._mdf) + ) { + let t = 0, + s = this.dataProps.length; + for (t = 0; t < s; t += 1) + 'o' != this.dataProps[t].n + ? (this.dashArray[t] = this.dataProps[t].p.v) + : (this.dashoffset[0] = this.dataProps[t].p.v); + } + } +} +class Vt extends O { + constructor(t, s, e) { + super(), (this.data = s), (this.c = w('uint8c', 4 * s.p)); + let i = s.k.k[0].s ? s.k.k[0].s.length - 4 * s.p : s.k.k.length - 4 * s.p; + (this.o = w('float32', i)), + (this._cmdf = !1), + (this._omdf = !1), + (this._collapsable = this.checkCollapsable()), + (this._hasOpacity = i), + this.initDynamicPropertyContainer(e), + (this.prop = pt.getProp(t, s.k, 1, null, this)), + (this.k = this.prop.k), + this.getValue(!0); + } + comparePoints(t, s) { + let e, + i = 0, + h = this.o.length / 2; + for (; i < h; ) { + if (((e = Math.abs(t[4 * i] - t[4 * s + 2 * i])), e > 0.01)) return !1; + i += 1; + } + return !0; + } + checkCollapsable() { + if (this.o.length / 2 != this.c.length / 4) return !1; + if (this.data.k.k[0].s) { + let t = 0, + s = this.data.k.k.length; + for (; t < s; ) { + if (!this.comparePoints(this.data.k.k[t].s, this.data.p)) return !1; + t += 1; + } + } else if (!this.comparePoints(this.data.k.k, this.data.p)) return !1; + return !0; + } + getValue(t) { + if ((this.prop.getValue(), (this._mdf = !1), (this._cmdf = !1), (this._omdf = !1), this.prop._mdf || t)) { + let s, + e, + i, + h = 4 * this.data.p; + for (s = 0; s < h; s += 1) + (e = s % 4 == 0 ? 100 : 255), + (i = Math.round(this.prop.v[s] * e)), + this.c[s] !== i && ((this.c[s] = i), (this._cmdf = !t)); + if (this.o.length) + for (h = this.prop.v.length, s = 4 * this.data.p; s < h; s += 1) + (e = s % 2 == 0 ? 100 : 1), + (i = s % 2 == 0 ? Math.round(100 * this.prop.v[s]) : this.prop.v[s]), + this.o[s - 4 * this.data.p] !== i && ((this.o[s - 4 * this.data.p] = i), (this._omdf = !t)); + this._mdf = !t; + } + } +} +class Nt extends O { + constructor(t, s, e) { + super(), + (this.frameId = -1), + (this.keyframesManager = t), + (this.elem = t.elem), + (this.session = e), + (this.shapes = []), + (this.shapesData = s), + (this.stylesList = []), + (this.itemsData = []), + (this.prevViewData = []), + (this.shapeModifiers = []), + (this.processedElements = []), + (this.transformsManager = new St()), + this.initDynamicPropertyContainer(t), + (this.lcEnum = { 1: 'butt', 2: 'round', 3: 'square' }), + (this.ljEnum = { 1: 'miter', 2: 'round', 3: 'bevel' }), + (this._isFirstFrame = !0), + (this.transformHelper = { opacity: 1, _opMdf: !1 }), + this.searchShapes(this.shapesData, this.itemsData, this.prevViewData, !0, []), + this._isAnimated || + ((this.transformHelper.opacity = 1), + (this.transformHelper._opMdf = !1), + this.updateModifiers(this.frameId), + this.transformsManager.processSequences(this._isFirstFrame), + this.updateShape(this.transformHelper, this.shapesData, this.itemsData), + this.updateGrahpics()); + } + createStyleElement(t, s) { + const e = new Dt(this.elem, t, this.transformsManager.addTransformSequence(s)), + i = {}; + if ( + ('fl' == t.ty || 'st' == t.ty + ? ((i.c = pt.getProp(this, t.c, 1, 255, this)), i.c.k || (e.co = i.c.v)) + : ('gf' !== t.ty && 'gs' !== t.ty) || + ((i.s = pt.getProp(this, t.s, 1, null, this)), + (i.e = pt.getProp(this, t.e, 1, null, this)), + (i.h = pt.getProp(this, t.h || { k: 0 }, 0, 0.01, this)), + (i.a = pt.getProp(this, t.a || { k: 0 }, 0, U, this)), + (i.g = new Vt(this, t.g, this))), + (i.o = pt.getProp(this, t.o, 0, 0.01, this)), + 'st' == t.ty || 'gs' == t.ty) + ) { + if ( + ((e.lc = this.lcEnum[t.lc] || 'round'), + (e.lj = this.ljEnum[t.lj] || 'round'), + 1 == t.lj && (e.ml = t.ml), + (i.w = pt.getProp(this, t.w, 0, null, this)), + i.w.k || (e.wi = i.w.v), + t.d) + ) { + let s = new Et(this, t.d, 'canvas', this); + (i.d = s), i.d.k || ((e.da = i.d.dashArray), (e.do = i.d.dashoffset[0])); + } + } else e.r = 2 === t.r ? 'evenodd' : 'nonzero'; + return this.stylesList.push(e), (i.style = e), i; + } + addShapeToModifiers(t) { + let s, + e = this.shapeModifiers.length; + for (s = 0; s < e; s += 1) this.shapeModifiers[s].addShape(t); + } + isShapeInAnimatedModifiers(t) { + let s = this.shapeModifiers.length; + for (; 0 < s; ) if (this.shapeModifiers[0].isAnimatedWithShape(t)) return !0; + return !1; + } + updateModifiers(t) { + if (!this.shapeModifiers.length) return; + let s, + e = this.shapes.length; + for (s = 0; s < e; s += 1) this.shapes[s].sh.reset(); + for (e = this.shapeModifiers.length, s = e - 1; s >= 0; s -= 1) + this.shapeModifiers[s].processShapes(t, this._isFirstFrame); + } + searchProcessedElement(t) { + let s = this.processedElements, + e = 0, + i = s.length; + for (; e < i; ) { + if (s[e].elem === t) return s[e].pos; + e += 1; + } + return 0; + } + addProcessedElement(t, s) { + let e = this.processedElements, + i = e.length; + for (; i; ) if (((i -= 1), e[i].elem === t)) return void (e[i].pos = s); + e.push(new xt(t, s)); + } + createGroupElement() { + return { it: [], prevViewData: [] }; + } + createTransformElement(t) { + return { + transform: { + opacity: 1, + _opMdf: !1, + key: this.transformsManager.getNewKey(), + op: pt.getProp(this, t.o, 0, 0.01, this), + mProps: Ft(this, t, this), + }, + }; + } + createShapeElement(t) { + const s = new Mt(this, t, this.stylesList, this.transformsManager); + return this.shapes.push(s), this.addShapeToModifiers(s), s; + } + reloadShapes() { + let t; + this._isFirstFrame = !0; + let s = this.itemsData.length; + for (t = 0; t < s; t += 1) this.prevViewData[t] = this.itemsData[t]; + for ( + this.searchShapes(this.shapesData, this.itemsData, this.prevViewData, !0, []), + s = this.dynamicProperties.length, + t = 0; + t < s; + t += 1 + ) + this.dynamicProperties[t].getValue(); + this.updateModifiers(), this.transformsManager.processSequences(this._isFirstFrame); + } + addTransformToStyleList(t) { + const s = this.stylesList.length; + for (let e = 0; e < s; e += 1) this.stylesList[e].closed || this.stylesList[e].transforms.push(t); + } + removeTransformFromStyleList() { + const t = this.stylesList.length; + for (let s = 0; s < t; s += 1) this.stylesList[s].closed || this.stylesList[s].transforms.pop(); + } + closeStyles(t) { + const s = t.length; + for (let e = 0; e < s; e += 1) t[e].closed = !0; + } + searchShapes(t, s, e, i, h) { + let r, + a, + n, + o, + l, + p, + c = t.length - 1, + d = [], + u = [], + f = [].concat(h); + for (r = c; r >= 0; r -= 1) { + if ( + ((o = this.searchProcessedElement(t[r])), + o ? (s[r] = e[o - 1]) : (t[r]._shouldRender = i), + 'fl' == t[r].ty || 'st' == t[r].ty || 'gf' == t[r].ty || 'gs' == t[r].ty) + ) + o ? (s[r].style.closed = !1) : (s[r] = this.createStyleElement(t[r], f)), d.push(s[r].style); + else if ('gr' == t[r].ty) { + if (o) for (n = s[r].it.length, a = 0; a < n; a += 1) s[r].prevViewData[a] = s[r].it[a]; + else s[r] = this.createGroupElement(t[r]); + this.searchShapes(t[r].it, s[r].it, s[r].prevViewData, i, f); + } else + 'tr' == t[r].ty + ? (o || ((p = this.createTransformElement(t[r])), (s[r] = p)), + f.push(s[r]), + this.addTransformToStyleList(s[r])) + : 'sh' == t[r].ty || 'rc' == t[r].ty || 'el' == t[r].ty || 'sr' == t[r].ty + ? o || (s[r] = this.createShapeElement(t[r])) + : 'tm' == t[r].ty || 'rd' == t[r].ty + ? (o + ? ((l = s[r]), (l.closed = !1)) + : ((l = It.getModifier(t[r].ty)), l.init(this, t[r]), (s[r] = l), this.shapeModifiers.push(l)), + u.push(l)) + : 'rp' == t[r].ty && + (o + ? ((l = s[r]), (l.closed = !0)) + : ((l = It.getModifier(t[r].ty)), + (s[r] = l), + l.init(this, t, r, s), + this.shapeModifiers.push(l), + (i = !1)), + u.push(l)); + this.addProcessedElement(t[r], r + 1); + } + for (this.removeTransformFromStyleList(), this.closeStyles(d), c = u.length, r = 0; r < c; r += 1) u[r].closed = !0; + } + updateShapeTransform(t, s) { + (t._opMdf || s.op._mdf || this._isFirstFrame) && ((s.opacity = t.opacity), (s.opacity *= s.op.v), (s._opMdf = !0)); + } + updateStyledShape(t, s) { + if (this._isFirstFrame || s._mdf || t.transforms._mdf) { + let e, + i, + h, + r = t.trNodes, + a = s.paths, + n = a._length; + r.length = 0; + let o = t.transforms.finalTransform; + for (h = 0; h < n; h += 1) { + let t = a.shapes[h]; + if (t && t.v) { + for (i = t._length, e = 1; e < i; e += 1) + 1 === e && r.push({ t: 'm', p: o.applyToPointArray(t.v[0][0], t.v[0][1], 0) }), + r.push({ t: 'c', pts: o.applyToTriplePoints(t.o[e - 1], t.i[e], t.v[e]) }); + 1 === i && r.push({ t: 'm', p: o.applyToPointArray(t.v[0][0], t.v[0][1], 0) }), + t.c && + i && + (r.push({ t: 'c', pts: o.applyToTriplePoints(t.o[e - 1], t.i[0], t.v[0]) }), r.push({ t: 'z' })); + } + } + t.trNodes = r; + } + } + updatePath(t, s) { + if (!0 !== t.hd && t._shouldRender) { + let t, + e = s.styledShapes.length; + for (t = 0; t < e; t += 1) this.updateStyledShape(s.styledShapes[t], s.sh); + } + } + updateFill(t, s, e) { + const i = s.style; + (s.c._mdf || this._isFirstFrame) && (i.co = s.c.v), + (s.o._mdf || e._opMdf || this._isFirstFrame) && (i.coOp = s.o.v * e.opacity); + } + updateStroke(t, s, e) { + let i = s.style, + h = s.d; + h && (h._mdf || this._isFirstFrame) && ((i.da = h.dashArray), (i.do = h.dashoffset[0])), + (s.c._mdf || this._isFirstFrame) && (i.co = s.c.v), + (s.o._mdf || e._opMdf || this._isFirstFrame) && (i.coOp = s.o.v * e.opacity), + (s.w._mdf || this._isFirstFrame) && (i.wi = s.w.v); + } + updateGradientFill(t, s, e) { + let i = s.style; + (i.grd = s.g.c), (i.coOp = s.o.v * e.opacity); + } + updateShape(t, s, e) { + let i = t; + for (let h = s.length - 1; h >= 0; h -= 1) + 'tr' == s[h].ty + ? ((i = e[h].transform), this.updateShapeTransform(t, i)) + : 'sh' == s[h].ty || 'el' == s[h].ty || 'rc' == s[h].ty || 'sr' == s[h].ty + ? this.updatePath(s[h], e[h]) + : 'fl' == s[h].ty + ? this.updateFill(s[h], e[h], i) + : 'st' == s[h].ty + ? this.updateStroke(s[h], e[h], i) + : 'gf' == s[h].ty || 'gs' == s[h].ty + ? this.updateGradientFill(s[h], e[h], i) + : 'gr' == s[h].ty && this.updateShape(i, s[h].it, e[h].it); + } + updateGrahpics() { + const t = this.stylesList.length; + for (let s = 0; s < t; s += 1) { + this.stylesList[s].updateGrahpics(); + } + } + getValue(t) { + t !== this.frameId && + (this.iterateDynamicProperties(t), + (this.transformHelper.opacity = 1), + (this.transformHelper._opMdf = !1), + this.updateModifiers(t), + this.transformsManager.processSequences(this._isFirstFrame), + this.updateShape(this.transformHelper, this.shapesData, this.itemsData), + this.updateGrahpics(), + (this.frameId = t)); + } +} +class qt extends Lt { + constructor(t, s, e) { + super(t, s), (this.frameId = -1), (this.hs = s), (this.session = e); + } + getValue(t) { + t !== this.frameId && (this.iterateDynamicProperties(t), (this.frameId = t)); + } + get x() { + return this.p ? this.p.v[0] : this.px.v; + } + get y() { + return this.p ? this.p.v[1] : this.py.v; + } + get anchorX() { + return this.a.v[0]; + } + get anchorY() { + return this.a.v[1]; + } + get scaleX() { + return this.s.v[0]; + } + get scaleY() { + return this.s.v[1]; + } + get rotation() { + return (this.r && this.r.v) || 0; + } + get alpha() { + return this.o.v; + } +} +class Ot { + constructor(t) { + (this.elem = t), + (this._isFirstFrame = !1), + (this.dynamicProperties = []), + (this._mdf = !1), + (this.transform = null), + (this.masks = null), + (this.shapes = null), + (this._hasOutTypeExpression = !1), + (this.needUpdateOverlap = !1), + (this.isOverlapMode = !1), + (this.visible = !0), + (this._isFirstFrame = !0); + } + initFrame(t, s) { + this.layer = t; + const { local: e, global: i } = s; + (this.session = s), + (this.isOverlapLayer = this.layer.op >= e.op - e.st), + (this.isOverlapMode = i.overlapMode), + this.parseLayer(t, s); + } + outTypeExpressionMode() { + (this._hasOutTypeExpression = !0), this.isOverlapLayer && (this.needUpdateOverlap = !0); + } + prepareProperties(t, s) { + let e, + i = this.dynamicProperties.length; + for (e = 0; e < i; e += 1) + (s || this.needUpdateOverlap || (this.elem._isParent && 'transform' === this.dynamicProperties[e].propType)) && + (this.dynamicProperties[e].getValue(t), this.dynamicProperties[e]._mdf && (this._mdf = !0)); + } + addDynamicProperty(t) { + -1 === this.dynamicProperties.indexOf(t) && this.dynamicProperties.push(t); + } + parseLayer({ ks: t, hasMask: s, masksProperties: e, shapes: i, tm: h }, r) { + if ( + (t && (this.transform = new qt(this, t, r)), + s && (this.masks = new _t(this, e, r)), + i && (this.shapes = new Nt(this, i, r)), + h) + ) { + const { frameRate: t } = r.global; + this.tm = pt.getProp(this, h, 0, t, this); + } + } + updateFrame(t) { + this._mdf = !1; + const e = s.inRange(t, this.layer.ip, this.layer.op); + this.isOverlapMode && this.isOverlapLayer ? (this.visible = t >= this.layer.ip) : (this.visible = e), + this.prepareProperties(t, e); + } + updateDisplay() { + const t = this.elem.display; + this.elem._isRoot || + (this.visible ? t.show() : t.hide(), + (this._mdf || this.transform._mdf || this._isFirstFrame) && t.updateLottieTransform(this.transform), + this.masks && (this.masks._mdf || this._isFirstFrame) && t.updateLottieMasks(this.masks)), + (this._isFirstFrame = !1); + } +} +class Xt { + constructor(t) { + (this.data = t), + void 0 === this.data.sr && (this.data.sr = 1), + (this.offsetTime = t.st || 0), + (this.fullname = t.nm || ''), + (this.idname = t.ln || ''), + (this.classnames = t.cl ? t.cl.split(' ') : []), + (this.bodymovin = new Ot(this)), + (this.displayType = ''), + (this.display = null), + (this.hierarchy = null), + (this.lottieTreeParent = null); + } + initBodymovin(t, s) { + this.bodymovin.initFrame(t, s), this.display && this.display.onSetupLottie && this.display.onSetupLottie(); + } + hasValidMasks() { + return !(!this.bodymovin.masks || !this.bodymovin.masks.hasMasks); + } + setHierarchy(t) { + (this.hierarchy = t), this.display.setHierarchy(t.display); + } + initDisplayInstance(t, s) { + return new (Tt(t))(this, s); + } + updateFrame(t) { + this.bodymovin.updateFrame(t), this.bodymovin.updateDisplay(); + } +} +class Yt extends Xt { + constructor(t, s) { + super(t); + const { global: e } = s; + this.session = s; + const i = { layer: t, session: s }; + if (e.maskComp) { + i.maskComp = e.maskComp; + const { w: s, h: h } = t; + i.viewport = { w: s, h: h }; + } + (this.config = i), + (this.childNodes = []), + (this.displayType = wt.Type.Component), + (this.innerDisplay = null), + (this.display = this.initDisplayInstance(this.displayType, i)), + this.initBodymovin(t, s); + } + updateFrame(t) { + if ((this.bodymovin.updateFrame(t), this.bodymovin.updateDisplay(), (t -= this.offsetTime), this.bodymovin.tm)) { + let s = this.bodymovin.tm.v; + s === this.data.op && (s = this.data.op - 1), (t = s); + } else t /= this.data.sr; + for (let s = 0; s < this.childNodes.length; s++) this.childNodes[s].updateFrame(t); + } + addChild(t) { + (t.lottieTreeParent = this), + this.childNodes.push(t), + this.innerDisplay ? this.innerDisplay.addChild(t.display) : this.display.addChild(t.display); + } +} +class jt extends Xt { + constructor(t, s) { + super(t); + const e = { layer: t, session: s, rect: { x: 0, y: 0, width: t.sw, height: t.sh }, color: t.sc }; + (this.config = e), + (this.session = s), + (this.displayType = wt.Type.Solid), + (this.display = this.initDisplayInstance(this.displayType, e)), + this.initBodymovin(t, s); + } +} +class zt extends Xt { + constructor(t, e) { + super(t); + const { + global: { textureLoader: i, assets: h }, + } = e, + r = s.getAssets(t.refId, h), + a = { layer: t, session: e, texture: i.getTextureById(r.id), asset: r }; + (this.config = a), + (this.session = e), + (this.displayType = wt.Type.Sprite), + (this.display = this.initDisplayInstance(this.displayType, a)), + this.initBodymovin(t, e); + } +} +class Bt extends Xt { + constructor(t, s) { + super(t); + const e = { layer: t, session: s }; + (this.config = e), + (this.session = s), + (this.displayType = wt.Type.Shape), + (this.display = this.initDisplayInstance(this.displayType, e)), + this.initBodymovin(t, s); + } +} +class Rt extends Xt { + constructor(t, s) { + super(t); + const e = { layer: t, session: s }; + (this.config = e), + (this.session = s), + (this.displayType = wt.Type.Null), + (this.display = this.initDisplayInstance(this.displayType, e)), + this.initBodymovin(t, s); + } +} +class Kt extends e { + constructor(t) { + super(), + (this.living = !0), + (this.infinite = t.infinite || !1), + (this.repeats = t.repeats || 0), + (this.alternate = t.alternate || !1), + (this.wait = t.wait || 0), + (this.delay = t.delay || 0), + (this.overlapMode = t.overlapMode || !1), + (this.timeScale = s.isNumber(t.timeScale) ? t.timeScale : 1), + (this.frameNum = 0), + (this.isPaused = !0), + (this.direction = 1), + (this._lastFrame = -1 / 0), + (this._repeatsCut = this.repeats), + (this._delayCut = this.delay), + (this._waitCut = this.wait), + (this.segments = t.segments || {}), + (this._segmentName = t.initSegment || ''), + (this._prefix = t.prefix || ''), + (this._autoLoad = !s.isBoolean(t.autoLoad) || t.autoLoad), + (this._autoStart = !s.isBoolean(t.autoStart) || t.autoStart), + (this._justDisplayOnImagesLoaded = !s.isBoolean(t.justDisplayOnImagesLoaded) || t.justDisplayOnImagesLoaded), + (this._maskComp = t.maskComp || !1), + (this.textureLoader = null), + (this.jsonLoader = null), + (this.root = null), + (this.parent = null); + const e = Tt(wt.Type.Container); + if ( + ((this.group = new e()), + (this.display = null), + (this.isDisplayLoaded = !1), + (this.isImagesLoaded = !1), + (this._copyJSON = t.copyJSON || !1), + t.keyframes) + ) + !this._prefix && t.keyframes.prefix && (this._prefix = t.keyframes.prefix), this._setupDate(t.keyframes); + else if (t.path) { + let s = ''; + (s = + -1 !== t.path.lastIndexOf('\\') + ? t.path.substr(0, t.path.lastIndexOf('\\') + 1) + : t.path.substr(0, t.path.lastIndexOf('/') + 1)), + !this._prefix && s && (this._prefix = s), + (this.jsonLoader = (function (t) { + const s = i[h.Ajax]; + return s || console.warn('must register an ajax loader, before you parse an animation from path'), s(t); + })(t.path)), + this.jsonLoader.once('success', t => { + this._setupDate(t); + }), + this.jsonLoader.once('error', t => { + this.emit('error', t); + }); + } + } + _setupDate(t) { + (this._sourceData = t), this._copyJSON && (t = s.copyJSON(t)), g.completeData(t), (this.keyframes = t); + const { w: e, h: r, st: a = 0, fr: n, ip: o, op: l, assets: p } = t; + (this.frameRate = n), (this.frameMult = n / 1e3), (this._defaultSegment = [o, l]); + const c = (this._segmentName && this.segments[this._segmentName]) || this._defaultSegment; + (this.beginFrame = c[0]), + (this.endFrame = c[1]), + (this._timePerFrame = 1e3 / n), + (this.duration = Math.floor(this.endFrame - this.beginFrame)); + let d = null; + const u = p.filter(t => t.u || t.p); + u.length > 0 + ? ((this.textureLoader = d = + (function (t, s) { + const e = i[h.Texture]; + return ( + e || console.warn('must register an image loader, before you parse an animation some has image assets'), + e(t, s) + ); + })(u, { prefix: this._prefix, autoLoad: this._autoLoad })), + d.loaded + ? ((this.isImagesLoaded = !0), (this.isPaused = !this._autoStart), this.emit('ImageReady')) + : (d.once('complete', () => { + (this.isImagesLoaded = !0), this.emit('ImageReady'); + }), + null !== this._pausedNeedSet && + ((this._pausedNeedSet = !0), + d.once('complete', () => { + this._pausedNeedSet && ((this._pausedNeedSet = !1), (this.isPaused = !this._autoStart)); + })))) + : ((this.isImagesLoaded = !0), (this.isPaused = !this._autoStart)); + const f = { + global: { assets: p, textureLoader: d, frameRate: n, maskComp: this._maskComp, overlapMode: this.overlapMode }, + local: { w: e, h: r, ip: o, op: l, st: a }, + }; + this._buildElements(f), + null !== this.textureLoader && + this._justDisplayOnImagesLoaded && + !this.textureLoader.loaded && + null !== this._justDisplayNeedSet && + ((this.group.visible = !1), + (this._justDisplayNeedSet = !0), + this.textureLoader.once('complete', () => { + this._justDisplayNeedSet && ((this._justDisplayNeedSet = !1), (this.group.visible = !0)); + })), + (this.isDisplayLoaded = !0), + this.update(0, !0); + } + _buildElements(t) { + (this.root = this._extraCompositions(this.keyframes, t, !0)), + (this.display = this.root.display), + this.group.addChild(this.display), + this.emit('DOMLoaded').emit('DisplayReady'), + null === this.textureLoader + ? this.emit('success') + : this.textureLoader.loaded + ? this.emit('success') + : this.textureLoader.once('complete', () => this.emit('success')); + } + _extraCompositions(t, { global: e, local: i }, h = !1) { + const { w: r, h: a, ip: n, op: o, st: l = 0 } = t, + p = new Yt(t, { global: e, local: i }); + p._isRoot = h; + const c = t.layers || s.getAssets(t.refId, e.assets).layers, + d = { global: e, local: { w: r, h: a, ip: n, op: o, st: l } }, + u = this._createElements(c, d); + for (let t = c.length - 1; t >= 0; t--) { + const e = c[t], + i = u[e.ind]; + if (i) { + if (!s.isUndefined(e.parent)) { + const t = u[e.parent]; + (t._isParent = !0), i.setHierarchy(t); + } + p.addChild(i); + } + } + return p; + } + _createElements(t, s) { + const e = {}; + for (let i = t.length - 1; i >= 0; i--) { + const h = t[i]; + let r = null; + if (void 0 === h.td) { + switch (h.ty) { + case 0: + r = this._extraCompositions(h, s); + break; + case 1: + r = new jt(h, s); + break; + case 2: + r = new zt(h, s); + break; + case 3: + r = new Rt(h, s); + break; + case 4: + r = new Bt(h, s); + break; + default: + continue; + } + r && (void 0 === h.ind && (h.ind = i), (e[h.ind] = r), (r.name = h.nm || null)); + } + } + return e; + } + getDisplayByQuerySelector(t) { + const s = this.querySelector(t); + return s && s.display ? s.display : (console.warn('can not find display which query with ', t), null); + } + _queryMatch(t, s, e) { + const i = t.substr(0, 1), + h = t.substr(1, t.length); + let r = !1; + return ( + (r = '#' === i ? s.idname === h : '.' === i ? -1 !== s.classnames.indexOf(h) : s.fullname === t), + r && e.push(s), + r + ); + } + _searchNodes(t, s, e, i = !1) { + if (s.childNodes && s.childNodes.length > 0) { + const h = []; + for (let r = 0; r < s.childNodes.length; r++) { + const a = s.childNodes[r]; + if (this._queryMatch(t, a, e) && i) return !0; + a.childNodes && a.childNodes.length > 0 && h.push(a); + } + for (let s = 0; s < h.length; s++) if (this._searchNodes(t, h[s], e, i)) return !0; + } + return !1; + } + querySelector(t) { + const s = []; + return this._queryMatch(t, this.root, s) ? s[0] : (this._searchNodes(t, this.root, s, !0), s[0] || null); + } + querySelectorAll(t) { + const s = [], + e = '#' === t.substr(0, 1); + return this._queryMatch(t, this.root, s) && e ? s : (this._searchNodes(t, this.root, s, e), s); + } + bindSlot(t, s) { + return this.getDisplayByQuerySelector(t).addChild(s), this; + } + unbindSlot(t, s) { + return this.getDisplayByQuerySelector(t).removeChild(s), this; + } + _emitFrame(t) { + this.emit(`@${t}`); + } + update(t, s = !1) { + if (!this.living || !this.isDisplayLoaded || (this.isPaused && !s)) return; + const e = this._updateTime(t), + i = this.beginFrame + this.frameNum; + this.root.updateFrame(i); + const h = i >> 0; + this._lastFrame !== h && (this._emitFrame(this.direction > 0 ? h : this._lastFrame), (this._lastFrame = h)), + !1 === e + ? (this.emit('enterFrame', i), this.emit('update', this.frameNum / this.duration)) + : this.hadEnded !== e && !0 === e && this.emit('complete'), + (this.hadEnded = e); + } + _updateTime(t) { + const e = this.direction * this.timeScale * t; + if (this._waitCut > 0) return (this._waitCut -= Math.abs(e)), null; + if (this.isPaused || this._delayCut > 0) return this._delayCut > 0 && (this._delayCut -= Math.abs(e)), null; + this.frameNum += e / this._timePerFrame; + let i = !1; + return ( + this._spill() && + (this._repeatsCut > 0 || this.infinite + ? (this._repeatsCut > 0 && --this._repeatsCut, + (this._delayCut = this.delay), + this.alternate + ? ((this.direction *= -1), (this.frameNum = s.codomainBounce(this.frameNum, 0, this.duration))) + : ((this.direction = 1), (this.frameNum = s.euclideanModulo(this.frameNum, this.duration))), + this.emit('loopComplete')) + : (this.overlapMode || ((this.frameNum = s.clamp(this.frameNum, 0, this.duration)), (this.living = !1)), + (i = !0))), + i + ); + } + _spill() { + const t = this.frameNum <= 0 && -1 === this.direction, + s = this.frameNum >= this.duration && 1 === this.direction; + return t || s; + } + frameToTime(t) { + return t * this._timePerFrame; + } + setSpeed(t) { + this.timeScale = t; + } + playSegment(t, e = {}) { + if (!t) return; + let i = null; + s.isArray(t) ? (i = t) : s.isString(t) && ((i = this.segments[t]), s.isArray(i) && (this._segmentName = t)), + s.isArray(i) && + ((this.beginFrame = s.isNumber(i[0]) ? i[0] : this._defaultSegment[0]), + (this.endFrame = s.isNumber(i[1]) ? i[1] : this._defaultSegment[1]), + s.isNumber(e.repeats) && (this.repeats = e.repeats), + s.isBoolean(e.infinite) && (this.infinite = e.infinite), + s.isBoolean(e.alternate) && (this.alternate = e.alternate), + s.isNumber(e.wait) && (this.wait = e.wait), + s.isNumber(e.delay) && (this.delay = e.delay), + this.replay()); + } + goToAndStop(t, s = !1) { + (this.frameNum = s ? t : t * this.frameMult), this.update(0, !0), this.pause(); + } + goToAndPlay(t, s = !1) { + (this.frameNum = s ? t : t * this.frameMult), this.update(0, !0), this.resume(); + } + getDuration(t) { + const s = this.endFrame - this.beginFrame; + return t ? s : s / this.frameRate; + } + setDirection(t) { + return (this.direction = t < 0 ? -1 : 1), this; + } + pause() { + return this._pausedNeedSet ? (this._pausedNeedSet = !1) : (this._pausedNeedSet = null), (this.isPaused = !0), this; + } + resume() { + return this._pausedNeedSet ? (this._pausedNeedSet = !1) : (this._pausedNeedSet = null), (this.isPaused = !1), this; + } + play() { + return this.resume(); + } + replay() { + return ( + this._pausedNeedSet ? (this._pausedNeedSet = !1) : (this._pausedNeedSet = null), + (this.isPaused = !1), + (this._repeatsCut = this.repeats), + (this._delayCut = this.delay), + (this.living = !0), + (this.frameNum = 0), + (this.duration = Math.floor(this.endFrame - this.beginFrame)), + (this.direction = 1), + this + ); + } + show() { + this._justDisplayNeedSet ? (this._justDisplayNeedSet = !1) : (this._justDisplayNeedSet = null), + (this.group.visible = !0); + } + hide() { + this._justDisplayNeedSet ? (this._justDisplayNeedSet = !1) : (this._justDisplayNeedSet = null), + (this.group.visible = !1); + } + destroy() { + this.parent && this.parent.remove(this), + this.group.parent && this.group.parent.removeChild(this.group), + this.pause(), + (this.root = null), + (this.group = null), + (this.display = null), + this.textureLoader && (this.textureLoader.off('complete'), (this.textureLoader = null)), + this.jsonLoader && (this.jsonLoader.off('success'), (this.jsonLoader = null)), + (this.keyframes = null), + (this.living = !1); + } +} +class Gt extends e { + constructor(t) { + super(), + (this._lastTime = 0), + (this._snippet = 0), + (this.timeScale = 1), + (this.isPaused = !1), + (this.ticker = t.ticker ? t.ticker : t), + (this.groups = []), + (this.update = this.update.bind(this)), + this.ticker && this.start(); + } + add(t) { + const s = arguments.length; + if (s > 1) for (let t = 0; t < s; t++) this.add(arguments[t]); + else null !== t.parent && t.parent.remove(t), (t.parent = this), this.groups.push(t); + return t; + } + remove(t) { + if (arguments.length > 1) for (let t = 0; t < arguments.length; t++) this.remove(arguments[t]); + const s = this.groups.indexOf(t); + -1 !== s && ((t.parent = null), this.groups.splice(s, 1)); + } + parseAnimation(t) { + const s = new Kt(t); + return this.add(s); + } + setSpeed(t) { + this.timeScale = t; + } + start() { + return (this._lastTime = Date.now()), this.ticker.add(this.update), this; + } + stop() { + return this.ticker.remove(this.update), this; + } + pause() { + return (this.isPaused = !0), this; + } + resume() { + return (this.isPaused = !1), this; + } + update() { + if ((this.timeline(), this.isPaused)) return; + const t = this.timeScale * this._snippet, + s = this.groups.length; + for (let e = 0; e < s; e++) { + this.groups[e].update(t); + } + this.emit('update', this._snippet); + } + timeline() { + let t = Date.now() - this._lastTime; + (!this._lastTime || t > 200) && ((this._lastTime = Date.now()), (t = Date.now() - this._lastTime)), + (this._lastTime += t), + (this._snippet = t); + } + destroy() { + for (let t = this.groups.length - 1; t >= 0; t--) this.groups[t].destroy(); + } +} +export { + Kt as AnimationGroup, + Gt as AnimationManager, + M as BezierEasing, + wt as DisplayRegister, + e as Eventer, + r as LoaderRegister, + pt as PropertyFactory, + s as Tools, + qt as TransformFrames, + Lt as TransformProperty, +}; diff --git a/packages/plugin-renderer-lottie/lib/lottie-pixi.js b/packages/plugin-renderer-lottie/lib/lottie-pixi.js index 608f32db..f964168e 100644 --- a/packages/plugin-renderer-lottie/lib/lottie-pixi.js +++ b/packages/plugin-renderer-lottie/lib/lottie-pixi.js @@ -1 +1,1365 @@ -import{Tools as t,Eventer as e,BezierEasing as s,TransformFrames as i,AnimationManager as n}from"./lottie-core";import{Graphics as r,Container as h,Shader as o,glCore as a,WebGLRenderer as l,ObjectRenderer as p,utils as c,CanvasRenderer as u,BLEND_MODES as d,Matrix as f,Sprite as m,Rectangle as g,Texture as y,settings as w,UPDATE_PRIORITY as v,ticker as x,DisplayObject as b,Application as P}from"pixi.js";class T extends r{constructor(t){super(),this.parentCompBox=t,this.lineStyle(0)}updateLayerMask(t){for(let e=0;ethis.buffer.length){const e=new this.buffer.constructor(Math.max(this.length+t.length,Math.round(2*this.buffer.length)));e.set(this.buffer,0),this.buffer=e}for(let e=0;e=r&&(r+=2*Math.PI);let o=r-n,a=1;h&&(a=-1,o=2*Math.PI-o,0==o&&(o=2*Math.PI));const l=o*i;let p=Math.sqrt(l/1)>>0;p=p%2==0?p+1:p;const c=o/p;let u=n;for(let n=0;n=2,h=e.lineWidth/2;let o,a=[i[0],i[1]];for(let t=2;ts[r];)n-=s[r],r++,h=h?0:1,r==s.length&&(r=0);let o=[t[0],t[1]],a=[h];for(let e=2;e=s[r];)p+=s[r]-n,n=0,h=h?0:1,r++,r==s.length&&(r=0),a.push(h),o.push(t[e-2]+p*i[0],t[e-1]+p*i[1]);l-p!=0&&(o.push(t[e],t[e+1]),a.push(h)),n+=l-p}return e&&(t.pop(),t.pop(),o.pop(),o.pop(),a.pop()),{newPoints:o,toDrawOrNotToDraw:a}}(a,n,e.lineDash,e.lineDashOffset);o=t.toDrawOrNotToDraw,a=t.newPoints}const l=s.length;let p=s.length;const c=[];if(n)a.push(a[2],a[3]);else{const t=[a[2]-a[0],a[3]-a[1]],i=O(t[0],t[1]);t[0]/=i,t[1]/=i;const n=[-t[1],t[0]],l=[a[0]+h*n[0],a[1]+h*n[1]],u=[a[0]-h*n[0],a[1]-h*n[1]];if("butt"==e.lineCap)s.push(l[0],l[1],u[0],u[1]);else if("square"==e.lineCap)s.push(l[0]-h*t[0],l[1]-h*t[1],u[0]-h*t[0],u[1]-h*t[1]);else{s.push(a[0],a[1],l[0],l[1]);const t=Math.atan2(l[1]-a[1],l[0]-a[0]),e=Math.atan2(u[1]-a[1],u[0]-a[0]);E(s,a[0],a[1],h,t,e),s.push(a[0],a[1],u[0],u[1]),s.push(l[0],l[1],u[0],u[1])}if(r){const t=o[0];for(let e=p;e0?(f[0]/=l,f[1]/=l,g=[-f[1],f[0]],m=g[0]*n[0]+g[1]*n[1],y=h/m):(y=0,g=[-f[1],f[0]]);const w=[a[t]+y*g[0],a[t+1]+y*g[1]],v=[a[t]-y*g[0],a[t+1]-y*g[1]];if("miter"==e.lineJoin&&1/m<=e.miterLimit)s.push(w[0],w[1],v[0],v[1]);else{const i=d[1]*u[0]-d[0]*u[1];if("round"==e.lineJoin)if(i<0){const e=[a[t]+d[1]*h,a[t+1]-d[0]*h],i=[a[t]+u[1]*h,a[t+1]-u[0]*h];s.push(w[0],w[1],e[0],e[1]);const n=Math.atan2(e[1]-a[t+1],e[0]-a[t]),r=Math.atan2(i[1]-a[t+1],i[0]-a[t]);E(s,a[t],a[t+1],h,n,r),s.push(w[0],w[1],i[0],i[1])}else{const e=[a[t]-d[1]*h,a[t+1]+d[0]*h],i=[a[t]-u[1]*h,a[t+1]+u[0]*h];s.push(e[0],e[1],v[0],v[1]);const n=Math.atan2(i[1]-a[t+1],i[0]-a[t]),r=Math.atan2(e[1]-a[t+1],e[0]-a[t]);E(s,a[t],a[t+1],h,n,r),s.push(i[0],i[1],v[0],v[1])}else if(i<0){const e=[a[t]+d[1]*h,a[t+1]-d[0]*h],i=[a[t]+u[1]*h,a[t+1]-u[0]*h];s.push(w[0],w[1],e[0],e[1],w[0],w[1],i[0],i[1])}else{const e=[a[t]-d[1]*h,a[t+1]+d[0]*h],i=[a[t]-u[1]*h,a[t+1]+u[0]*h];s.push(e[0],e[1],v[0],v[1],i[0],i[1],v[0],v[1])}}if(r){const e=o[t/2];for(let t=p;t=6){for(let t=0;t=2;for(let t=0;t1){const t=this.paths.length,e=function(t){const e=t.length;let s=0;for(let i=e-1,n=0;n0;if(this.currentPath.isClockWise=e,0===t&&(this.firstIsClockWise=e),t>0&&this.preClockWiseStatus===this.firstIsClockWise&&this.preClockWiseStatus!==e){(t>0?this.paths[t-1]:null).holes.push(this.currentPath)}else this.paths.push(this.currentPath),this.preClockWiseStatus=e;this.currentPath=null,this.isDirty=!0}this._samplerPoints.length=0}closePath(){this.currentPath.closePath()}stroke(){this.endPath(),this.drawType="stroke"}fill(){null!==this.currentPath&&(this.closePath(),this.endPath(),this.drawType="fill")}_renderWebGL(t){t.setObjectRenderer(t.plugins.lottiegraphics),t.plugins.lottiegraphics.render(this)}_renderCanvas(t){t.plugins.lottiegraphics.render(this)}}class z extends X{constructor(t,e){super(),this.lottieElement=t,this.config=e,this.passMatrix=new f}setShapeTransform(){const t=this.lottieElement.preTransforms.finalTransform.props;this.passMatrix.set(t[0],t[1],t[4],t[5],t[12],t[13]),this.transform.setFromMatrix(this.passMatrix)}updateTransform(){this.setShapeTransform(),this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha,this._bounds.updateID++}updateLottieGrahpics(e){const s=e.type;if(this.clear(),("st"===s||"gs"===s)&&0===e.wi||!e.data._shouldRender||0===e.coOp)return;const i=e.elements,n=i.length;for(let t=0;t{s.orig=new g(0,0,i.w,i.h),s._updateUvs()}),this.lottieElement=t,this.config=e}onSetupLottie(){if(this.lottieElement.hasValidMasks()){const t=this.config.session.local;this.graphicsMasks=new T(t),this.mask=this.graphicsMasks,this.addChild(this.mask)}}setHierarchy(t){this.hierarchy=t}show(){this.visible=!0}hide(){this.visible=!1}updateLottieTransform(t){this.x=t.x,this.y=t.y,this.pivot.x=t.anchorX,this.pivot.y=t.anchorY,this.scale.x=t.scaleX,this.scale.y=t.scaleY,this.rotation=t.rotation,this.alpha=t.alpha}updateLottieMasks(t){this.graphicsMasks&&this.graphicsMasks.updateMasks(t)}}const U=/^(https?:)?\/\//;class N extends e{constructor(t,{prefix:e,autoLoad:s=!0}){super(),this.assets=t,this.prefix=e||"",this.textures={},this._total=0,this._failed=0,this._received=0,this.loaded=!1,s&&this.load()}load(){this.assets.forEach(t=>{const e=t.id,s=function(t,e){if(1===t.e)return t.p;e&&(e=e.replace(/\/?$/,"/"));const s=t.u+t.p;let i="";return i=t.up?t.up:U.test(s)?s:e+s,i}(t,this.prefix),i=y.fromImage(s,"*");this.textures[e]=i,this._total++,i.baseTexture.hasLoaded?(this._received++,this.emit("update"),this._received+this._failed>=this._total&&this._onComplete()):(i.baseTexture.once("loaded",()=>{this._received++,this.emit("update"),this._received+this._failed>=this._total&&this._onComplete()}),i.baseTexture.once("error",()=>{this._failed++,this.emit("update"),this._received+this._failed>=this._total&&this._onComplete()}))})}_onComplete(){this.loaded=!0,this.emit("complete"),this._failed>0&&(this._failed>=this._total?this.emit("fail"):this.emit("partlyfail",this._failed))}getTextureById(t){return this.textures[t]}}function j(t){return t.response&&"object"==typeof t.response?t.response:t.response&&"string"==typeof t.response?JSON.parse(t.response):t.responseText?JSON.parse(t.responseText):void 0}class q extends e{constructor(t){super(),this.path=t,this.onSuccess=this.onSuccess.bind(this),this.onFail=this.onFail.bind(this),function(t,e,s){let i,n=new XMLHttpRequest;n.open("GET",t,!0);try{n.responseType="json"}catch(t){console.error("lottie-pixi loadAjax:",t)}n.send(),n.onreadystatechange=function(){if(4==n.readyState)if(200==n.status)i=j(n),e(i);else try{i=j(n),e(i)}catch(t){s&&s(t)}}}(t,this.onSuccess,this.onFail)}onSuccess(t){this.emit("success",t),this.emit("complete",t)}onFail(t){this.emit("fail",t),this.emit("error",t)}}const Y={Linear:{None:t=>t},Ease:{In:function(){const t=new s(.42,0,1,1);return function(e){return t.get(e)}}(),Out:function(){const t=new s(0,0,.58,1);return function(e){return t.get(e)}}(),InOut:function(){const t=new s(.42,0,.58,1);return function(e){return t.get(e)}}(),Bezier(t,e,i,n){const r=new s(t,e,i,n);return function(t){return r.get(t)}}},Elastic:{In:t=>0===t?0:1===t?1:-Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI),Out:t=>0===t?0:1===t?1:Math.pow(2,-10*t)*Math.sin(5*(t-.1)*Math.PI)+1,InOut:t=>0===t?0:1===t?1:(t*=2)<1?-.5*Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI):.5*Math.pow(2,-10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)+1},Back:{In(t){const e=1.70158;return t*t*((e+1)*t-e)},Out(t){const e=1.70158;return--t*t*((e+1)*t+e)+1},InOut(t){const e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)}},Bounce:{In:t=>1-Y.Bounce.Out(1-t),Out:t=>t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375,InOut:t=>t<.5?.5*Y.Bounce.In(2*t):.5*Y.Bounce.Out(2*t-1)+.5}};function J(s){e.call(this),this.element=s.element||{},this.duration=s.duration||300,this.living=!0,this.resident=s.resident||!1,this.infinite=s.infinite||!1,this.alternate=s.alternate||!1,this.repeats=s.repeats||0,this.delay=s.delay||0,this.wait=s.wait||0,this.timeScale=t.isNumber(s.timeScale)?s.timeScale:1,s.onComplete&&this.on("complete",s.onComplete.bind(this)),s.onUpdate&&this.on("update",s.onUpdate.bind(this)),this.init(),this.paused=!1}function V(e){J.call(this,e),e.from=e.from||{};for(const s in e.to)t.isUndefined(e.from[s])&&(e.from[s]=this.element[s]);this.ease=e.ease||Y.Ease.InOut,this.from=e.from,this.to=e.to}function H(e){J.call(this,e),this.dynamicProperties=[],this._mdf=!1,this.keyframes=t.copyJSON(e.keyframes),this.frameRate=e.frameRate||30,this.tpf=1e3/this.frameRate,this.ip=t.isUndefined(e.ip)?this.keyframes.ip:e.ip,this.op=t.isUndefined(e.ip)?this.keyframes.op:e.op,this.tfs=this.op-this.ip,this.duration=this.tfs*this.tpf,this.ignoreProps=t.isArray(e.ignoreProps)?e.ignoreProps:[],this.transform=new i(this,this.keyframes.ks)}function $(t,e){J.call(this,e),this.runners=[],this.queues=[],this.cursor=0,this.total=0,this.alternate=!1,t&&this.then(t)}J.prototype=Object.create(e.prototype),J.prototype.update=function(e){const s=this.direction*this.timeScale*e;if(this.waitCut>0)return void(this.waitCut-=Math.abs(s));if(this.paused||!this.living||this.delayCut>0)return void(this.delayCut>0&&(this.delayCut-=Math.abs(s)));this.progress+=s;let i=!1;const n=this.progress;let r;return this.spill()&&(this.repeatsCut>0||this.infinite?(this.repeatsCut>0&&--this.repeatsCut,this.delayCut=this.delay,this.alternate?(this.direction*=-1,this.progress=t.codomainBounce(this.progress,0,this.duration)):(this.direction=1,this.progress=t.euclideanModulo(this.progress,this.duration))):i=!0),i?(this.resident||(this.living=!1),this.progress=t.clamp(n,0,this.duration),r=this.nextPose(),this.emit("complete",r,n-this.progress)):(r=this.nextPose(),this.emit("update",r,this.progress/this.duration)),r},J.prototype.spill=function(){const t=this.progress<=0&&-1===this.direction,e=this.progress>=this.duration&&1===this.direction;return t||e},J.prototype.init=function(){this.direction=1,this.progress=0,this.repeatsCut=this.repeats,this.delayCut=this.delay,this.waitCut=this.wait},J.prototype.nextPose=function(){console.warn("should be overwrite")},J.prototype.linear=function(t,e,s){return(e-t)*s+t},J.prototype.setSpeed=function(t){return this.timeScale=t,this},J.prototype.pause=function(){return this.paused=!0,this},J.prototype.resume=function(){return this.paused=!1,this},J.prototype.restart=J.prototype.resume,J.prototype.stop=function(){return this.repeats=0,this.infinite=!1,this.progress=this.duration,this},J.prototype.cancel=function(){return this.living=!1,this},V.prototype=Object.create(J.prototype),V.prototype.nextPose=function(){const t={},e=this.ease(this.progress/this.duration);for(const s in this.to)void 0!==this.element[s]&&(this.element[s]=t[s]=this.linear(this.from[s],this.to[s],e));return t},H.prototype=Object.create(J.prototype),H.prototype.prepareProperties=function(t){const e=this.dynamicProperties.length;let s;for(s=0;s0&&(t+=this._residueTime,this._residueTime=0),this.runners[this.cursor].update(t)},$.prototype.update=function(t){if(this.wait>0)return void(this.wait-=Math.abs(t));if(this.paused||!this.living||this.delayCut>0)return void(this.delayCut>0&&(this.delayCut-=Math.abs(t)));const e=this.cursor,s=this.nextPose(this.timeScale*t);return this.emit("update",{index:e,pose:s},this.progress/this.duration),this.spill()&&(this.repeats>0||this.infinite?(this.repeats>0&&--this.repeats,this.delayCut=this.delay,this.cursor=0):(this.resident||(this.living=!1),this.emit("complete",s))),s},$.prototype.spill=function(){return this.cursor>=this.total};const K={settings:w,UPDATE_PRIORITY:v,animationTicker:x.shared};function Q(t){K.animationTicker=t}function Z(t){this.element=t,this.animates=[],this.timeScale=1,this.paused=!1,this.updateDeltaTime=this.updateDeltaTime.bind(this),K.animationTicker.add(this.updateDeltaTime,K.UPDATE_PRIORITY.HIGH)}Z.prototype.clearAnimators=function(t){if(this.paused)return;const e=this.animates;for(let s=0;s0&&this.clearAnimators(e)},Z.prototype.animate=function(t,e){return t.element=this.element,this._addMove(new V(t),e)},Z.prototype.queues=function(t,e,s){return e.element=this.element,this._addMove(new $(t,e),s)},Z.prototype.bodymovin=function(t,e){return t.element=this.element,this._addMove(new H(t),e)},Z.prototype._addMove=function(t,e){return e&&this.clearAll(),this.animates.push(t),t},Z.prototype.pause=function(){this.paused=!0},Z.prototype.resume=function(){this.paused=!1},Z.prototype.restart=Z.prototype.resume,Z.prototype.setSpeed=function(t){this.timeScale=t},Z.prototype.clearAll=function(){this.animates.length=0},b.prototype.setupAnimations=function(){this.animations||(this.animations=new Z(this))},b.prototype.animate=function(t,e){return this.animations||this.setupAnimations(),this.animations.animate(t,e)},b.prototype.queues=function(t,e={},s){return this.animations||this.setupAnimations(),this.animations.queues(t,e,s)},b.prototype.bodymovin=function(t,e){return this.animations||this.setupAnimations(),this.animations.bodymovin(t,e)},Object.defineProperties(b.prototype,{scaleXY:{get(){return this.scale.x},set(t){this.scale.set(t)}},scaleX:{get(){return this.scale.x},set(t){this.scale.x=t}},scaleY:{get(){return this.scale.y},set(t){this.scale.y=t}},pivotX:{get(){return this.pivot.x},set(t){this.pivot.x=t}},pivotY:{get(){return this.pivot.y},set(t){this.pivot.y=t}}}),h.prototype.updateTransform=function(){this.emit("pretransform"),this._boundsID++,this.hierarchy&&this.hierarchy.transform?(this.hierarchy.updateTransform(),this.transform.updateTransform(this.hierarchy.transform)):this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha;for(let t=0,e=this.children.length;t{t.useAESize&&this.resizeWithAESize(),this.app.stage.addChild(this.animate.group),this.emit("DisplayReady",this)}),this.animate.isImagesLoaded?this.loaded=!0:(this.animate.once("success",()=>{this.loaded=!0,this.emit("success",this)}),this.animate.once("error",t=>{this.emit("error",t)}))}}function et(e){return e.container&&!e.view&&(e.view=e.container),e.animationData&&!e.keyframes&&(e.keyframes=e.animationData),e.assetsPath&&!e.prefix&&(e.prefix=e.assetsPath.replace(/images\/?$/,"")),e.initialSegment&&!e.initSegment&&(e.initSegment=e.initialSegment),t.isBoolean(e.autoplay)&&!t.isBoolean(e.autoStart)&&(e.autoStart=e.autoplay),t.isBoolean(e.loop)&&!t.isBoolean(e.infinite)&&(e.infinite=e.loop),e.view=t.isString(e.view)?document.querySelector(e.view):e.view,e.useAESize=!t.isBoolean(e.useAESize)||e.useAESize,new tt(e)}export{Y as Tween,et as loadAnimation,Q as useTicker,k as CompElement,z as PathLottie,G as SolidElement,R as SpriteElement,h as Container,q as LoadJson,N as LoadTexture};export{AnimationGroup,AnimationManager,BezierEasing,DisplayRegister,Eventer,LoaderRegister,PropertyFactory,Tools,TransformFrames,TransformProperty}from"./lottie-core"; \ No newline at end of file +import { + Tools as t, + Eventer as e, + BezierEasing as s, + TransformFrames as i, + AnimationManager as n, +} from './lottie-core'; +import { + Graphics as r, + Container as h, + Shader as o, + glCore as a, + WebGLRenderer as l, + ObjectRenderer as p, + utils as c, + CanvasRenderer as u, + BLEND_MODES as d, + Matrix as f, + Sprite as m, + Rectangle as g, + Texture as y, + settings as w, + UPDATE_PRIORITY as v, + ticker as x, + DisplayObject as b, + Application as P, +} from 'pixi.js'; +class T extends r { + constructor(t) { + super(), (this.parentCompBox = t), this.lineStyle(0); + } + updateLayerMask(t) { + for (let e = 0; e < t.viewData.length; e++) { + if (t.viewData[e].inv) { + const t = this.parentCompBox; + this.moveTo(0, 0), this.lineTo(t.w, 0), this.lineTo(t.w, t.h), this.lineTo(0, t.h), this.lineTo(0, 0); + } + const s = t.viewData[e].v, + i = s.v[0]; + this.moveTo(i[0], i[1]); + const n = s._length; + let r = 1; + for (; r < n; r++) { + const t = s.o[r - 1], + e = s.i[r], + i = s.v[r]; + this.bezierCurveTo(t[0], t[1], e[0], e[1], i[0], i[1]); + } + const h = s.o[r - 1], + o = s.i[0], + a = s.v[0]; + this.bezierCurveTo(h[0], h[1], o[0], o[1], a[0], a[1]), t.viewData[e].inv && this.addHole(); + } + } + updateMasks(t) { + this.clear(), this.beginFill(0), this.updateLayerMask(t), this.endFill(); + } +} +class M extends r { + constructor(t) { + super(), (this.viewport = t), this.lineStyle(0), this.initCompMask(); + } + initCompMask() { + this.clear(), this.beginFill(0); + const t = this.viewport; + this.moveTo(0, 0), + this.lineTo(t.w, 0), + this.lineTo(t.w, t.h), + this.lineTo(0, t.h), + this.lineTo(0, 0), + this.endFill(); + } +} +class k extends h { + constructor(t, e) { + super(), (this.lottieElement = t), (this.config = e); + } + onSetupLottie() { + if (this.config.maskComp) { + const t = this.config.viewport; + (this.preCompMask = new M(t)), (this.mask = this.preCompMask), this.addChild(this.mask); + } + if (this.lottieElement.hasValidMasks()) { + const t = this.config.session.local; + if (((this.graphicsMasks = new T(t)), this.mask)) { + const t = new h(); + (t.mask = this.graphicsMasks), t.addChild(this.mask), (this.lottieElement.innerDisplay = t), this.addChild(t); + } else (this.mask = this.graphicsMasks), this.addChild(this.mask); + } + } + setHierarchy(t) { + this.hierarchy = t; + } + show() { + this.visible = !0; + } + hide() { + this.visible = !1; + } + updateLottieTransform(t) { + (this.x = t.x), + (this.y = t.y), + (this.pivot.x = t.anchorX), + (this.pivot.y = t.anchorY), + (this.scale.x = t.scaleX), + (this.scale.y = t.scaleY), + (this.rotation = t.rotation), + (this.alpha = t.alpha); + } + updateLottieMasks(t) { + this.graphicsMasks && this.graphicsMasks.updateMasks(t); + } +} +class C extends o { + constructor(t) { + super( + t, + [ + 'attribute vec2 aVertexPosition;', + 'uniform mat3 translationMatrix;', + 'uniform mat3 projectionMatrix;', + 'void main(void){', + ' gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);', + '}', + ].join('\n'), + [ + 'uniform float alpha;', + 'uniform vec3 color;', + 'void main(void){', + ' gl_FragColor = vec4(color * alpha, alpha);', + '}', + ].join('\n'), + ); + } +} +function S(t, e) { + (this.buffer = new t(10)), (this.length = 0); +} +S.prototype = { + reset() { + this.length = 0; + }, + destroy() { + (this.buffer = null), (this.length = 0); + }, + push(...t) { + if (this.length + t.length > this.buffer.length) { + const e = new this.buffer.constructor(Math.max(this.length + t.length, Math.round(2 * this.buffer.length))); + e.set(this.buffer, 0), (this.buffer = e); + } + for (let e = 0; e < t.length; e++) this.buffer[this.length++] = t[e]; + return this.length; + }, + setBuffer(t) { + (this.buffer = t), (this.length = this.buffer.length); + }, +}; +class D { + constructor(t, e, s) { + (this.gl = t), + (this.vertices = new S(Float32Array)), + (this.indices = new S(Uint16Array)), + (this.buffer = a.GLBuffer.createVertexBuffer(t)), + (this.indexBuffer = a.GLBuffer.createIndexBuffer(t)), + (this.dirty = !0), + (this.shader = e), + (this.vao = new a.VertexArrayObject(t, s) + .addIndex(this.indexBuffer) + .addAttribute(this.buffer, e.attributes.aVertexPosition, t.FLOAT, !1, 8, 0)); + } + reset() { + this.vertices.reset(), this.indices.reset(); + } + upload() { + this.buffer.upload(this.vertices.buffer), this.indexBuffer.upload(this.indices.buffer), (this.dirty = !1); + } + destroy() { + this.vertices.destroy(), + this.indices.destroy(), + this.vao.destroy(), + this.buffer.destroy(), + this.indexBuffer.destroy(), + (this.gl = null), + (this.buffer = null), + (this.indexBuffer = null); + } +} +function _(t, e, s) { + return t.push(e, s), t; +} +function O(t, e) { + return Math.sqrt(t * t + e * e); +} +function L(t, e, s, i, n) { + return ( + (function (t, e) { + const s = 1 - t; + return s * s * s * e; + })(t, e) + + (function (t, e) { + const s = 1 - t; + return 3 * s * s * t * e; + })(t, s) + + (function (t, e) { + return 3 * (1 - t) * t * t * e; + })(t, i) + + (function (t, e) { + return t * t * t * e; + })(t, n) + ); +} +function A(t, e, s, i, n, r, h) { + if (!(isFinite(e) && isFinite(s) && isFinite(i) && isFinite(n) && isFinite(r) && isFinite(h))) return t; + const o = t[t.length - 2], + a = t[t.length - 1], + l = (function (t, e, s, i, n, r, h, o) { + const a = n - s, + l = r - i, + p = s - t, + c = i - e; + return O(h - n, o - r) + O(a, l) + O(p, c); + })(o, a, e, s, i, n, r, h), + p = Math.min(10 / l, 0.5); + for (let l = p; l < 1; l += p) { + const p = L(l, o, e, i, r), + c = L(l, a, s, n, h); + t.push(p, c); + } + return t.push(r, h), t; +} +function I(t, e) { + for (let s = 0; s < t.length; s++) { + const { cmd: i, args: n } = t[s]; + switch (i) { + case 'M': + case 'L': + _(e, n[0], n[1]); + break; + case 'C': + A(e, n[0], n[1], n[2], n[3], n[4], n[5]); + } + } + return e; +} +function E(t, e, s, i, n, r, h) { + (n %= 2 * Math.PI), + (r %= 2 * Math.PI), + n < 0 && (n += 2 * Math.PI), + r < 0 && (r += 2 * Math.PI), + n >= r && (r += 2 * Math.PI); + let o = r - n, + a = 1; + h && ((a = -1), (o = 2 * Math.PI - o), 0 == o && (o = 2 * Math.PI)); + const l = o * i; + let p = Math.sqrt(l / 1) >> 0; + p = p % 2 == 0 ? p + 1 : p; + const c = o / p; + let u = n; + for (let n = 0; n < p + 1; n++) t.push(e, s, e + i * Math.cos(u), s + i * Math.sin(u)), (u += a * c); +} +function B(t, e, s) { + const i = I(t.cmds, []), + n = t.isClosed, + r = e.lineDash.length >= 2, + h = e.lineWidth / 2; + let o, + a = [i[0], i[1]]; + for (let t = 2; t < i.length; t += 2) + (i[t] == a[a.length - 2] && i[t + 1] == a[a.length - 1]) || a.push(i[t], i[t + 1]); + if ((!n || (a[a.length - 2] == a[0] && a[a.length - 1] == a[1]) || a.push(a[0], a[1]), r)) { + const t = (function (t, e, s, i) { + e && t.push(t[0], t[1]); + let n = i, + r = 0, + h = 1; + for (; n > s[r]; ) (n -= s[r]), r++, (h = h ? 0 : 1), r == s.length && (r = 0); + let o = [t[0], t[1]], + a = [h]; + for (let e = 2; e < t.length; e += 2) { + let i = [t[e] - t[e - 2], t[e + 1] - t[e - 1]], + l = O(i[0], i[1]); + (i[0] /= l), (i[1] /= l); + let p = 0; + for (; l - p + n >= s[r]; ) + (p += s[r] - n), + (n = 0), + (h = h ? 0 : 1), + r++, + r == s.length && (r = 0), + a.push(h), + o.push(t[e - 2] + p * i[0], t[e - 1] + p * i[1]); + l - p != 0 && (o.push(t[e], t[e + 1]), a.push(h)), (n += l - p); + } + return e && (t.pop(), t.pop(), o.pop(), o.pop(), a.pop()), { newPoints: o, toDrawOrNotToDraw: a }; + })(a, n, e.lineDash, e.lineDashOffset); + (o = t.toDrawOrNotToDraw), (a = t.newPoints); + } + const l = s.length; + let p = s.length; + const c = []; + if (n) a.push(a[2], a[3]); + else { + const t = [a[2] - a[0], a[3] - a[1]], + i = O(t[0], t[1]); + (t[0] /= i), (t[1] /= i); + const n = [-t[1], t[0]], + l = [a[0] + h * n[0], a[1] + h * n[1]], + u = [a[0] - h * n[0], a[1] - h * n[1]]; + if ('butt' == e.lineCap) s.push(l[0], l[1], u[0], u[1]); + else if ('square' == e.lineCap) s.push(l[0] - h * t[0], l[1] - h * t[1], u[0] - h * t[0], u[1] - h * t[1]); + else { + s.push(a[0], a[1], l[0], l[1]); + const t = Math.atan2(l[1] - a[1], l[0] - a[0]), + e = Math.atan2(u[1] - a[1], u[0] - a[0]); + E(s, a[0], a[1], h, t, e), s.push(a[0], a[1], u[0], u[1]), s.push(l[0], l[1], u[0], u[1]); + } + if (r) { + const t = o[0]; + for (let e = p; e < s.length; e += 2) c.push(t); + p = s.length; + } + } + for (let t = 2; t < a.length - 2; t += 2) { + const i = [a[t] - a[t - 2], a[t + 1] - a[t - 1]], + n = [-i[1], i[0]]; + let l = O(n[0], n[1]); + (n[0] /= l), (n[1] /= l); + let u = [a[t + 2] - a[t], a[t + 3] - a[t + 1]]; + (l = O(u[0], u[1])), (u[0] /= l), (u[1] /= l); + let d = [a[t] - a[t - 2], a[t + 1] - a[t - 1]]; + (l = O(d[0], d[1])), (d[0] /= l), (d[1] /= l); + let f = [d[0] + u[0], d[1] + u[1]]; + l = O(f[0], f[1]); + let m, + g, + y = 0; + l > 0 + ? ((f[0] /= l), (f[1] /= l), (g = [-f[1], f[0]]), (m = g[0] * n[0] + g[1] * n[1]), (y = h / m)) + : ((y = 0), (g = [-f[1], f[0]])); + const w = [a[t] + y * g[0], a[t + 1] + y * g[1]], + v = [a[t] - y * g[0], a[t + 1] - y * g[1]]; + if ('miter' == e.lineJoin && 1 / m <= e.miterLimit) s.push(w[0], w[1], v[0], v[1]); + else { + const i = d[1] * u[0] - d[0] * u[1]; + if ('round' == e.lineJoin) + if (i < 0) { + const e = [a[t] + d[1] * h, a[t + 1] - d[0] * h], + i = [a[t] + u[1] * h, a[t + 1] - u[0] * h]; + s.push(w[0], w[1], e[0], e[1]); + const n = Math.atan2(e[1] - a[t + 1], e[0] - a[t]), + r = Math.atan2(i[1] - a[t + 1], i[0] - a[t]); + E(s, a[t], a[t + 1], h, n, r), s.push(w[0], w[1], i[0], i[1]); + } else { + const e = [a[t] - d[1] * h, a[t + 1] + d[0] * h], + i = [a[t] - u[1] * h, a[t + 1] + u[0] * h]; + s.push(e[0], e[1], v[0], v[1]); + const n = Math.atan2(i[1] - a[t + 1], i[0] - a[t]), + r = Math.atan2(e[1] - a[t + 1], e[0] - a[t]); + E(s, a[t], a[t + 1], h, n, r), s.push(i[0], i[1], v[0], v[1]); + } + else if (i < 0) { + const e = [a[t] + d[1] * h, a[t + 1] - d[0] * h], + i = [a[t] + u[1] * h, a[t + 1] - u[0] * h]; + s.push(w[0], w[1], e[0], e[1], w[0], w[1], i[0], i[1]); + } else { + const e = [a[t] - d[1] * h, a[t + 1] + d[0] * h], + i = [a[t] - u[1] * h, a[t + 1] + u[0] * h]; + s.push(e[0], e[1], v[0], v[1], i[0], i[1], v[0], v[1]); + } + } + if (r) { + const e = o[t / 2]; + for (let t = p; t < s.length; t += 2) c.push(e); + p = s.length; + } + } + if (n) s.push(s.buffer[l], s.buffer[l + 1], s.buffer[l + 2], s.buffer[l + 3]); + else { + const t = [a[a.length - 2] - a[a.length - 4], a[a.length - 1] - a[a.length - 3]], + i = Math.sqrt(Math.pow(t[0], 2) + Math.pow(t[1], 2)); + (t[0] /= i), (t[1] /= i); + const n = [-t[1], t[0]], + r = [a[a.length - 2] + h * n[0], a[a.length - 1] + h * n[1]], + o = [a[a.length - 2] - h * n[0], a[a.length - 1] - h * n[1]]; + if ('butt' == e.lineCap) s.push(r[0], r[1], o[0], o[1]); + else if ('square' == e.lineCap) s.push(r[0] + h * t[0], r[1] + h * t[1], o[0] + h * t[0], o[1] + h * t[1]); + else { + s.push(r[0], r[1], o[0], o[1]), s.push(a[a.length - 2], a[a.length - 1], o[0], o[1]); + const t = Math.atan2(o[1] - a[a.length - 1], o[0] - a[a.length - 2]), + e = Math.atan2(r[1] - a[a.length - 1], r[0] - a[a.length - 2]); + E(s, a[a.length - 2], a[a.length - 1], h, t, e), s.push(a[a.length - 2], a[a.length - 1], r[0], r[1]); + } + } + if (r) { + const t = o[o.length - 1]; + for (let e = p; e < s.length; e += 2) c.push(t); + p = s.length; + } + return c; +} +function F(t, e) { + const s = t.isClosed; + let i = !0; + const n = I(t.cmds, []); + let r = [n[0], n[1]]; + for (let t = 2; t < n.length; t += 2) + (n[t] == r[r.length - 2] && n[t + 1] == r[r.length - 1]) || r.push(n[t], n[t + 1]); + if ((!s || (r[r.length - 2] == r[0] && r[r.length - 1] == r[1]) || r.push(r[0], r[1]), r.length >= 6)) { + for (let t = 0; t < r.length; t++) e.push(r[t]); + i = !1; + } + return i; +} +l.registerPlugin( + 'lottiegraphics', + class extends p { + constructor(t) { + super(t), + (this.graphicsDataPool = []), + (this.primitiveShader = null), + (this.webGLData = null), + (this.gl = t.gl), + (this.CONTEXT_UID = 0); + } + onContextChange() { + (this.gl = this.renderer.gl), + (this.CONTEXT_UID = this.renderer.CONTEXT_UID), + (this.primitiveShader = new C(this.gl)); + } + destroy() { + p.prototype.destroy.call(this); + for (let t = 0; t < this.graphicsDataPool.length; ++t) this.graphicsDataPool[t].destroy(); + this.graphicsDataPool = null; + } + render(t) { + const e = this.renderer, + s = e.gl, + i = this.getWebGLData(t); + if ((t.isDirty && this.updateGraphics(t, i), 0 === i.indices.length)) return; + const n = this.primitiveShader; + e.bindShader(n), + e.state.setBlendMode(t.blendMode), + (n.uniforms.translationMatrix = t.transform.worldTransform.toArray(!0)), + (n.uniforms.color = c.hex2rgb(t.color)), + (n.uniforms.alpha = t.worldAlpha), + e.bindVao(i.vao), + i.vao.draw(s.TRIANGLES, i.indices.length); + } + updateGraphics(t, e) { + e.reset(), 'stroke' === t.drawType ? this.buildStroke(t, e) : this.buildFill(t, e), (t.isDirty = !1); + } + buildStroke(t, e) { + const { vertices: s, indices: i } = e, + { paths: n, lineStyle: r } = t, + h = r.lineDash.length >= 2; + for (let t = 0; t < n.length; t++) { + const e = n[t], + o = s.length / 2, + a = B(e, r, s); + if (h) for (let t = o + 2; t < s.length / 2; t += 2) a[t - o - 1] && i.push(t - 2, t, t - 1, t, t + 1, t - 1); + else for (let t = o + 2; t < s.length / 2; t += 2) i.push(t - 2, t, t - 1, t, t + 1, t - 1); + } + e.upload(); + } + buildFill(t, e) { + const { vertices: s, indices: i } = e, + { paths: n } = t; + let r = []; + const h = []; + for (let t = 0; t < n.length; t++) { + const e = n[t], + s = []; + if (F(e, s)) break; + const i = e.holes, + o = []; + for (let t = 0; t < i.length; t++) { + const e = i[t], + n = s.length; + if (F(e, s)) break; + o.push(n / 2); + } + const a = c.earcut(s, o, 2), + l = r.length / 2; + for (let t = 0; t < s.length; t += 2) r.push(s[t], s[t + 1]); + for (let t = 0; t < a.length; t += 3) h.push(l + a[t], l + a[t + 1], l + a[t + 2]); + } + r.length < 6 || h < 3 || (s.setBuffer(new Float32Array(r)), i.setBuffer(new Uint16Array(h)), e.upload()); + } + getWebGLData(t) { + return ( + (t.webGLData && this.CONTEXT_UID === t.webGLData.CONTEXT_UID) || + ((t.webGLData = new D(this.renderer.gl, this.primitiveShader, this.renderer.state.attribState)), + (t.webGLData.CONTEXT_UID = this.CONTEXT_UID)), + t.webGLData + ); + } + }, +); +u.registerPlugin( + 'lottiegraphics', + class { + constructor(t) { + this.renderer = t; + } + destroy() { + this.renderer = null; + } + render(t) { + const e = this.renderer, + s = e.context, + i = t.lineStyle, + n = t.worldAlpha, + r = t.transform.worldTransform, + h = e.resolution; + s.setTransform(r.a * h, r.b * h, r.c * h, r.d * h, r.tx * h, r.ty * h), + e.setBlendMode(t.blendMode), + (s.globalAlpha = n), + 'stroke' === t.drawType + ? ((s.lineWidth = i.lineWidth), + (s.lineJoin = i.lineJoin), + (s.miterLimit = i.miterLimit), + (s.lineCap = i.lineCap), + (s.lineDashOffset = i.lineDashOffset), + s.setLineDash(i.lineDash || []), + this.buildStroke(t)) + : this.buildFill(t); + } + buildStroke(t) { + const e = this.renderer.context, + s = `#${`00000${(0 | t.color).toString(16)}`.substr(-6)}`, + { paths: i, lineStyle: n } = t; + (e.lineWidth = n.lineWidth), + (e.lineJoin = n.lineJoin), + (e.miterLimit = n.miterLimit), + (e.lineCap = n.lineCap), + (e.lineDashOffset = n.lineDashOffset), + e.setLineDash(n.lineDash || []), + e.beginPath(); + for (let t = 0; t < i.length; t++) this.drawPath(e, i[t]); + (e.strokeStyle = s), e.stroke(); + } + buildFill(t) { + const e = this.renderer.context, + s = `#${`00000${(0 | t.color).toString(16)}`.substr(-6)}`, + { paths: i } = t; + e.beginPath(); + for (let t = 0; t < i.length; t++) { + const s = i[t]; + this.drawPath(e, s); + for (let t = 0; t < s.holes.length; t++) this.drawPath(e, s.holes[t]); + } + (e.fillStyle = s), e.fill(); + } + drawPath(t, e) { + for (let s = 0; s < e.cmds.length; s++) { + const { cmd: i, args: n } = e.cmds[s]; + switch (i) { + case 'M': + t.moveTo(n[0], n[1]); + break; + case 'L': + t.lineTo(n[0], n[1]); + break; + case 'C': + t.bezierCurveTo(n[0], n[1], n[2], n[3], n[4], n[5]); + } + } + } + }, +); +class W { + constructor() { + (this.cmds = []), (this.holes = []), (this.isClosed = !1), (this.isClockWise = !1); + } + getLength() { + return this.cmds.length; + } + add(t, e) { + this.cmds.push({ cmd: t, args: e }); + } + moveTo(t = 0, e = 0) { + this.add('M', [t, e]); + } + lineTo(t, e) { + this.add('L', [t, e]); + } + bezierCurveTo(t, e, s, i, n, r) { + this.add('C', [t, e, s, i, n, r]); + } + closePath() { + this.isClosed = !0; + } +} +class X extends h { + constructor() { + super(), + (this.paths = []), + (this._samplerPoints = []), + (this.currentPath = null), + (this.color = 0), + (this.lineStyle = { + lineWidth: 1, + lineJoin: 'miter', + miterLimit: 10, + lineCap: 'butt', + lineDash: [], + lineDashOffset: 0, + }), + (this.isDirty = !0), + (this.drawType = ''), + (this.blendMode = d.NORMAL), + (this.webGLData = null), + (this.firstIsClockWise = !0), + (this.preClockWiseStatus = null); + } + clear() { + (this.paths.length = 0), + (this.currentPath = null), + (this.firstIsClockWise = !0), + (this.preClockWiseStatus = null), + (this.isDirty = !0); + } + moveTo(t = 0, e = 0) { + this.endPath(), (this.currentPath = new W()), this.currentPath.moveTo(t, e), this._samplerPoints.push([t, e]); + } + lineTo(t, e) { + this.currentPath.lineTo(t, e), this._samplerPoints.push([t, e]); + } + bezierCurveTo(t, e, s, i, n, r) { + this.currentPath.bezierCurveTo(t, e, s, i, n, r), this._samplerPoints.push([n, r]); + } + endPath() { + if (this.currentPath && this.currentPath.getLength() > 1) { + const t = this.paths.length, + e = + (function (t) { + const e = t.length; + let s = 0; + for (let i = e - 1, n = 0; n < e; i = n++) s += t[i][0] * t[n][1] - t[n][0] * t[i][1]; + return 0.5 * s; + })(this._samplerPoints) > 0; + if ( + ((this.currentPath.isClockWise = e), + 0 === t && (this.firstIsClockWise = e), + t > 0 && this.preClockWiseStatus === this.firstIsClockWise && this.preClockWiseStatus !== e) + ) { + (t > 0 ? this.paths[t - 1] : null).holes.push(this.currentPath); + } else this.paths.push(this.currentPath), (this.preClockWiseStatus = e); + (this.currentPath = null), (this.isDirty = !0); + } + this._samplerPoints.length = 0; + } + closePath() { + this.currentPath.closePath(); + } + stroke() { + this.endPath(), (this.drawType = 'stroke'); + } + fill() { + null !== this.currentPath && (this.closePath(), this.endPath(), (this.drawType = 'fill')); + } + _renderWebGL(t) { + t.setObjectRenderer(t.plugins.lottiegraphics), t.plugins.lottiegraphics.render(this); + } + _renderCanvas(t) { + t.plugins.lottiegraphics.render(this); + } +} +class z extends X { + constructor(t, e) { + super(), (this.lottieElement = t), (this.config = e), (this.passMatrix = new f()); + } + setShapeTransform() { + const t = this.lottieElement.preTransforms.finalTransform.props; + this.passMatrix.set(t[0], t[1], t[4], t[5], t[12], t[13]), this.transform.setFromMatrix(this.passMatrix); + } + updateTransform() { + this.setShapeTransform(), + this.transform.updateTransform(this.parent.transform), + (this.worldAlpha = this.alpha * this.parent.worldAlpha), + this._bounds.updateID++; + } + updateLottieGrahpics(e) { + const s = e.type; + if ((this.clear(), (('st' === s || 'gs' === s) && 0 === e.wi) || !e.data._shouldRender || 0 === e.coOp)) return; + const i = e.elements, + n = i.length; + for (let t = 0; t < n; t += 1) { + const e = i[t].trNodes, + s = e.length; + for (let t = 0; t < s; t++) + 'm' == e[t].t + ? this.moveTo(e[t].p[0], e[t].p[1]) + : 'c' == e[t].t + ? this.bezierCurveTo(e[t].pts[0], e[t].pts[1], e[t].pts[2], e[t].pts[3], e[t].pts[4], e[t].pts[5]) + : this.closePath(); + } + ('st' !== s && 'gs' !== s) || + (e.da + ? ((this.lineStyle.lineDash = e.da), (this.lineStyle.lineDashOffset = e.do)) + : (this.lineStyle.lineDash = [])), + 'st' === s || 'gs' === s + ? ((this.lineStyle.lineWidth = e.wi), + (this.lineStyle.lineCap = e.lc), + (this.lineStyle.lineJoin = e.lj), + (this.lineStyle.miterLimit = e.ml || 0), + (this.color = t.rgb2hex(e.co || e.grd)), + (this.alpha = e.coOp), + this.stroke()) + : ((this.color = t.rgb2hex(e.co || e.grd)), (this.alpha = e.coOp), this.fill()); + } +} +class G extends r { + constructor(t, e) { + super(), (this.lottieElement = t), (this.config = e); + const s = parseInt(e.color.replace('#', ''), 16); + this.beginFill(s), this.drawRect(0, 0, e.rect.width, e.rect.height), this.endFill(); + } + onSetupLottie() { + if (this.lottieElement.hasValidMasks()) { + const t = this.config.session.local; + (this.graphicsMasks = new T(t)), (this.mask = this.graphicsMasks), this.addChild(this.mask); + } + } + setHierarchy(t) { + this.hierarchy = t; + } + show() { + this.visible = !0; + } + hide() { + this.visible = !1; + } + updateLottieTransform(t) { + (this.x = t.x), + (this.y = t.y), + (this.pivot.x = t.anchorX), + (this.pivot.y = t.anchorY), + (this.scale.x = t.scaleX), + (this.scale.y = t.scaleY), + (this.rotation = t.rotation), + (this.alpha = t.alpha); + } + updateLottieMasks(t) { + this.graphicsMasks && this.graphicsMasks.updateMasks(t); + } +} +class R extends m { + constructor(t, e) { + const { texture: s, asset: i } = e; + super(s), + s.baseTexture.hasLoaded + ? ((s.orig = new g(0, 0, i.w, i.h)), s._updateUvs()) + : s.baseTexture.on('loaded', () => { + (s.orig = new g(0, 0, i.w, i.h)), s._updateUvs(); + }), + (this.lottieElement = t), + (this.config = e); + } + onSetupLottie() { + if (this.lottieElement.hasValidMasks()) { + const t = this.config.session.local; + (this.graphicsMasks = new T(t)), (this.mask = this.graphicsMasks), this.addChild(this.mask); + } + } + setHierarchy(t) { + this.hierarchy = t; + } + show() { + this.visible = !0; + } + hide() { + this.visible = !1; + } + updateLottieTransform(t) { + (this.x = t.x), + (this.y = t.y), + (this.pivot.x = t.anchorX), + (this.pivot.y = t.anchorY), + (this.scale.x = t.scaleX), + (this.scale.y = t.scaleY), + (this.rotation = t.rotation), + (this.alpha = t.alpha); + } + updateLottieMasks(t) { + this.graphicsMasks && this.graphicsMasks.updateMasks(t); + } +} +const U = /^(https?:)?\/\//; +class N extends e { + constructor(t, { prefix: e, autoLoad: s = !0 }) { + super(), + (this.assets = t), + (this.prefix = e || ''), + (this.textures = {}), + (this._total = 0), + (this._failed = 0), + (this._received = 0), + (this.loaded = !1), + s && this.load(); + } + load() { + this.assets.forEach(t => { + const e = t.id, + s = (function (t, e) { + if (1 === t.e) return t.p; + e && (e = e.replace(/\/?$/, '/')); + const s = t.u + t.p; + let i = ''; + return (i = t.up ? t.up : U.test(s) ? s : e + s), i; + })(t, this.prefix), + i = y.fromImage(s, '*'); + (this.textures[e] = i), + this._total++, + i.baseTexture.hasLoaded + ? (this._received++, this.emit('update'), this._received + this._failed >= this._total && this._onComplete()) + : (i.baseTexture.once('loaded', () => { + this._received++, this.emit('update'), this._received + this._failed >= this._total && this._onComplete(); + }), + i.baseTexture.once('error', () => { + this._failed++, this.emit('update'), this._received + this._failed >= this._total && this._onComplete(); + })); + }); + } + _onComplete() { + (this.loaded = !0), + this.emit('complete'), + this._failed > 0 && (this._failed >= this._total ? this.emit('fail') : this.emit('partlyfail', this._failed)); + } + getTextureById(t) { + return this.textures[t]; + } +} +function j(t) { + return t.response && 'object' == typeof t.response + ? t.response + : t.response && 'string' == typeof t.response + ? JSON.parse(t.response) + : t.responseText + ? JSON.parse(t.responseText) + : void 0; +} +class q extends e { + constructor(t) { + super(), + (this.path = t), + (this.onSuccess = this.onSuccess.bind(this)), + (this.onFail = this.onFail.bind(this)), + (function (t, e, s) { + let i, + n = new XMLHttpRequest(); + n.open('GET', t, !0); + try { + n.responseType = 'json'; + } catch (t) { + console.error('lottie-pixi loadAjax:', t); + } + n.send(), + (n.onreadystatechange = function () { + if (4 == n.readyState) + if (200 == n.status) (i = j(n)), e(i); + else + try { + (i = j(n)), e(i); + } catch (t) { + s && s(t); + } + }); + })(t, this.onSuccess, this.onFail); + } + onSuccess(t) { + this.emit('success', t), this.emit('complete', t); + } + onFail(t) { + this.emit('fail', t), this.emit('error', t); + } +} +const Y = { + Linear: { None: t => t }, + Ease: { + In: (function () { + const t = new s(0.42, 0, 1, 1); + return function (e) { + return t.get(e); + }; + })(), + Out: (function () { + const t = new s(0, 0, 0.58, 1); + return function (e) { + return t.get(e); + }; + })(), + InOut: (function () { + const t = new s(0.42, 0, 0.58, 1); + return function (e) { + return t.get(e); + }; + })(), + Bezier(t, e, i, n) { + const r = new s(t, e, i, n); + return function (t) { + return r.get(t); + }; + }, + }, + Elastic: { + In: t => (0 === t ? 0 : 1 === t ? 1 : -Math.pow(2, 10 * (t - 1)) * Math.sin(5 * (t - 1.1) * Math.PI)), + Out: t => (0 === t ? 0 : 1 === t ? 1 : Math.pow(2, -10 * t) * Math.sin(5 * (t - 0.1) * Math.PI) + 1), + InOut: t => + 0 === t + ? 0 + : 1 === t + ? 1 + : (t *= 2) < 1 + ? -0.5 * Math.pow(2, 10 * (t - 1)) * Math.sin(5 * (t - 1.1) * Math.PI) + : 0.5 * Math.pow(2, -10 * (t - 1)) * Math.sin(5 * (t - 1.1) * Math.PI) + 1, + }, + Back: { + In(t) { + const e = 1.70158; + return t * t * ((e + 1) * t - e); + }, + Out(t) { + const e = 1.70158; + return --t * t * ((e + 1) * t + e) + 1; + }, + InOut(t) { + const e = 2.5949095; + return (t *= 2) < 1 ? t * t * ((e + 1) * t - e) * 0.5 : 0.5 * ((t -= 2) * t * ((e + 1) * t + e) + 2); + }, + }, + Bounce: { + In: t => 1 - Y.Bounce.Out(1 - t), + Out: t => + t < 1 / 2.75 + ? 7.5625 * t * t + : t < 2 / 2.75 + ? 7.5625 * (t -= 1.5 / 2.75) * t + 0.75 + : t < 2.5 / 2.75 + ? 7.5625 * (t -= 2.25 / 2.75) * t + 0.9375 + : 7.5625 * (t -= 2.625 / 2.75) * t + 0.984375, + InOut: t => (t < 0.5 ? 0.5 * Y.Bounce.In(2 * t) : 0.5 * Y.Bounce.Out(2 * t - 1) + 0.5), + }, +}; +function J(s) { + e.call(this), + (this.element = s.element || {}), + (this.duration = s.duration || 300), + (this.living = !0), + (this.resident = s.resident || !1), + (this.infinite = s.infinite || !1), + (this.alternate = s.alternate || !1), + (this.repeats = s.repeats || 0), + (this.delay = s.delay || 0), + (this.wait = s.wait || 0), + (this.timeScale = t.isNumber(s.timeScale) ? s.timeScale : 1), + s.onComplete && this.on('complete', s.onComplete.bind(this)), + s.onUpdate && this.on('update', s.onUpdate.bind(this)), + this.init(), + (this.paused = !1); +} +function V(e) { + J.call(this, e), (e.from = e.from || {}); + for (const s in e.to) t.isUndefined(e.from[s]) && (e.from[s] = this.element[s]); + (this.ease = e.ease || Y.Ease.InOut), (this.from = e.from), (this.to = e.to); +} +function H(e) { + J.call(this, e), + (this.dynamicProperties = []), + (this._mdf = !1), + (this.keyframes = t.copyJSON(e.keyframes)), + (this.frameRate = e.frameRate || 30), + (this.tpf = 1e3 / this.frameRate), + (this.ip = t.isUndefined(e.ip) ? this.keyframes.ip : e.ip), + (this.op = t.isUndefined(e.ip) ? this.keyframes.op : e.op), + (this.tfs = this.op - this.ip), + (this.duration = this.tfs * this.tpf), + (this.ignoreProps = t.isArray(e.ignoreProps) ? e.ignoreProps : []), + (this.transform = new i(this, this.keyframes.ks)); +} +function $(t, e) { + J.call(this, e), + (this.runners = []), + (this.queues = []), + (this.cursor = 0), + (this.total = 0), + (this.alternate = !1), + t && this.then(t); +} +(J.prototype = Object.create(e.prototype)), + (J.prototype.update = function (e) { + const s = this.direction * this.timeScale * e; + if (this.waitCut > 0) return void (this.waitCut -= Math.abs(s)); + if (this.paused || !this.living || this.delayCut > 0) + return void (this.delayCut > 0 && (this.delayCut -= Math.abs(s))); + this.progress += s; + let i = !1; + const n = this.progress; + let r; + return ( + this.spill() && + (this.repeatsCut > 0 || this.infinite + ? (this.repeatsCut > 0 && --this.repeatsCut, + (this.delayCut = this.delay), + this.alternate + ? ((this.direction *= -1), (this.progress = t.codomainBounce(this.progress, 0, this.duration))) + : ((this.direction = 1), (this.progress = t.euclideanModulo(this.progress, this.duration)))) + : (i = !0)), + i + ? (this.resident || (this.living = !1), + (this.progress = t.clamp(n, 0, this.duration)), + (r = this.nextPose()), + this.emit('complete', r, n - this.progress)) + : ((r = this.nextPose()), this.emit('update', r, this.progress / this.duration)), + r + ); + }), + (J.prototype.spill = function () { + const t = this.progress <= 0 && -1 === this.direction, + e = this.progress >= this.duration && 1 === this.direction; + return t || e; + }), + (J.prototype.init = function () { + (this.direction = 1), + (this.progress = 0), + (this.repeatsCut = this.repeats), + (this.delayCut = this.delay), + (this.waitCut = this.wait); + }), + (J.prototype.nextPose = function () { + console.warn('should be overwrite'); + }), + (J.prototype.linear = function (t, e, s) { + return (e - t) * s + t; + }), + (J.prototype.setSpeed = function (t) { + return (this.timeScale = t), this; + }), + (J.prototype.pause = function () { + return (this.paused = !0), this; + }), + (J.prototype.resume = function () { + return (this.paused = !1), this; + }), + (J.prototype.restart = J.prototype.resume), + (J.prototype.stop = function () { + return (this.repeats = 0), (this.infinite = !1), (this.progress = this.duration), this; + }), + (J.prototype.cancel = function () { + return (this.living = !1), this; + }), + (V.prototype = Object.create(J.prototype)), + (V.prototype.nextPose = function () { + const t = {}, + e = this.ease(this.progress / this.duration); + for (const s in this.to) + void 0 !== this.element[s] && (this.element[s] = t[s] = this.linear(this.from[s], this.to[s], e)); + return t; + }), + (H.prototype = Object.create(J.prototype)), + (H.prototype.prepareProperties = function (t) { + const e = this.dynamicProperties.length; + let s; + for (s = 0; s < e; s += 1) + this.dynamicProperties[s].getValue(t), this.dynamicProperties[s]._mdf && (this._mdf = !0); + }), + (H.prototype.addDynamicProperty = function (t) { + -1 === this.dynamicProperties.indexOf(t) && this.dynamicProperties.push(t); + }), + (H.prototype.nextPose = function () { + const t = {}, + e = this.ip + this.progress / this.tpf; + return ( + this.prepareProperties(e), + -1 === this.ignoreProps.indexOf('position') && + (-1 === this.ignoreProps.indexOf('x') && (t.x = this.element.x = this.transform.x), + -1 === this.ignoreProps.indexOf('y') && (t.y = this.element.y = this.transform.y)), + -1 === this.ignoreProps.indexOf('pivot') && + ((t.pivot = {}), + -1 === this.ignoreProps.indexOf('pivotX') && (t.pivot.x = this.element.pivot.x = this.transform.anchorX), + -1 === this.ignoreProps.indexOf('pivotY') && (t.pivot.y = this.element.pivot.y = this.transform.anchorY)), + -1 === this.ignoreProps.indexOf('scale') && + ((t.scale = {}), + -1 === this.ignoreProps.indexOf('scaleX') && (t.scale.x = this.element.scale.x = this.transform.scaleX), + -1 === this.ignoreProps.indexOf('scaleY') && (t.scale.y = this.element.scale.y = this.transform.scaleY)), + -1 === this.ignoreProps.indexOf('rotation') && (t.rotation = this.element.rotation = this.transform.rotation), + -1 === this.ignoreProps.indexOf('alpha') && (t.alpha = this.element.alpha = this.transform.alpha), + t + ); + }), + ($.prototype = Object.create(J.prototype)), + ($.prototype.then = function (t) { + return this.queues.push(t), (this.total = this.queues.length), this; + }), + ($.prototype.nextOne = function (t, e) { + this.runners[this.cursor].init(), this.cursor++, (this._residueTime = Math.abs(e)); + }), + ($.prototype.initOne = function () { + const t = this.queues[this.cursor]; + (t.infinite = !1), (t.resident = !0), (t.element = this.element); + let e = null; + t.keyframes ? (e = new H(t)) : t.to && (e = new V(t)), + null !== e && (e.on('complete', this.nextOne.bind(this)), this.runners.push(e)); + }), + ($.prototype.nextPose = function (t) { + return ( + !this.runners[this.cursor] && this.queues[this.cursor] && this.initOne(), + this._residueTime > 0 && ((t += this._residueTime), (this._residueTime = 0)), + this.runners[this.cursor].update(t) + ); + }), + ($.prototype.update = function (t) { + if (this.wait > 0) return void (this.wait -= Math.abs(t)); + if (this.paused || !this.living || this.delayCut > 0) + return void (this.delayCut > 0 && (this.delayCut -= Math.abs(t))); + const e = this.cursor, + s = this.nextPose(this.timeScale * t); + return ( + this.emit('update', { index: e, pose: s }, this.progress / this.duration), + this.spill() && + (this.repeats > 0 || this.infinite + ? (this.repeats > 0 && --this.repeats, (this.delayCut = this.delay), (this.cursor = 0)) + : (this.resident || (this.living = !1), this.emit('complete', s))), + s + ); + }), + ($.prototype.spill = function () { + return this.cursor >= this.total; + }); +const K = { settings: w, UPDATE_PRIORITY: v, animationTicker: x.shared }; +function Q(t) { + K.animationTicker = t; +} +function Z(t) { + (this.element = t), + (this.animates = []), + (this.timeScale = 1), + (this.paused = !1), + (this.updateDeltaTime = this.updateDeltaTime.bind(this)), + K.animationTicker.add(this.updateDeltaTime, K.UPDATE_PRIORITY.HIGH); +} +(Z.prototype.clearAnimators = function (t) { + if (this.paused) return; + const e = this.animates; + for (let s = 0; s < t.length; s++) { + const i = t[s]; + e[i].living || e[i].resident || this.animates.splice(i, 1); + } +}), + (Z.prototype.updateDeltaTime = function (t) { + if (this.animates.length <= 0) return; + const e = t / K.settings.TARGET_FPMS; + this.update(e); + }), + (Z.prototype.update = function (t) { + if (this.paused) return; + if (this.animates.length <= 0) return; + t = this.timeScale * t; + const e = []; + for (let s = 0; s < this.animates.length; s++) + this.animates[s].living || this.animates[s].resident ? this.animates[s].update(t) : e.push(s); + e.length > 0 && this.clearAnimators(e); + }), + (Z.prototype.animate = function (t, e) { + return (t.element = this.element), this._addMove(new V(t), e); + }), + (Z.prototype.queues = function (t, e, s) { + return (e.element = this.element), this._addMove(new $(t, e), s); + }), + (Z.prototype.bodymovin = function (t, e) { + return (t.element = this.element), this._addMove(new H(t), e); + }), + (Z.prototype._addMove = function (t, e) { + return e && this.clearAll(), this.animates.push(t), t; + }), + (Z.prototype.pause = function () { + this.paused = !0; + }), + (Z.prototype.resume = function () { + this.paused = !1; + }), + (Z.prototype.restart = Z.prototype.resume), + (Z.prototype.setSpeed = function (t) { + this.timeScale = t; + }), + (Z.prototype.clearAll = function () { + this.animates.length = 0; + }), + (b.prototype.setupAnimations = function () { + this.animations || (this.animations = new Z(this)); + }), + (b.prototype.animate = function (t, e) { + return this.animations || this.setupAnimations(), this.animations.animate(t, e); + }), + (b.prototype.queues = function (t, e = {}, s) { + return this.animations || this.setupAnimations(), this.animations.queues(t, e, s); + }), + (b.prototype.bodymovin = function (t, e) { + return this.animations || this.setupAnimations(), this.animations.bodymovin(t, e); + }), + Object.defineProperties(b.prototype, { + scaleXY: { + get() { + return this.scale.x; + }, + set(t) { + this.scale.set(t); + }, + }, + scaleX: { + get() { + return this.scale.x; + }, + set(t) { + this.scale.x = t; + }, + }, + scaleY: { + get() { + return this.scale.y; + }, + set(t) { + this.scale.y = t; + }, + }, + pivotX: { + get() { + return this.pivot.x; + }, + set(t) { + this.pivot.x = t; + }, + }, + pivotY: { + get() { + return this.pivot.y; + }, + set(t) { + this.pivot.y = t; + }, + }, + }), + (h.prototype.updateTransform = function () { + this.emit('pretransform'), + this._boundsID++, + this.hierarchy && this.hierarchy.transform + ? (this.hierarchy.updateTransform(), this.transform.updateTransform(this.hierarchy.transform)) + : this.transform.updateTransform(this.parent.transform), + (this.worldAlpha = this.alpha * this.parent.worldAlpha); + for (let t = 0, e = this.children.length; t < e; ++t) { + const e = this.children[t]; + e.visible && e.updateTransform(); + } + this.emit('posttransform'); + }), + (h.prototype.containerUpdateTransform = h.prototype.updateTransform); +class tt extends e { + constructor(t) { + super(), + (this.animate = null), + t.keyframes && + t.useAESize && + (t.width !== t.keyframes.w || t.height !== t.keyframes.h) && + ((t.width = t.keyframes.w), (t.height = t.keyframes.h)); + const { + view: e, + width: s, + height: i, + transparent: r, + antialias: h, + preserveDrawingBuffer: o, + resolution: a, + forceCanvas: l, + backgroundColor: p, + clearBeforeRender: c, + roundPixels: u, + forceFXAA: d, + legacy: f, + powerPreference: m, + sharedTicker: g, + sharedLoader: y, + } = t; + (this.app = new P({ + view: e, + width: s, + height: i, + transparent: r, + antialias: h, + preserveDrawingBuffer: o, + resolution: a, + forceCanvas: l, + backgroundColor: p, + clearBeforeRender: c, + roundPixels: u, + forceFXAA: d, + legacy: f, + powerPreference: m, + sharedTicker: g, + sharedLoader: y, + })), + (this.manager = new n(this.app)), + (this.loaded = !1), + this.parseData(t); + } + resizeWithAESize() { + const { width: t, height: e } = this.app.renderer; + (t === this.animate.keyframes.w && e === this.animate.keyframes.h) || + this.app.renderer.resize(this.animate.keyframes.w, this.animate.keyframes.h); + } + parseData(t) { + (this.animate = this.manager.parseAnimation(t)), + this.animate.isDisplayLoaded + ? (t.useAESize && this.resizeWithAESize(), this.app.stage.addChild(this.animate.group)) + : this.animate.once('DisplayReady', () => { + t.useAESize && this.resizeWithAESize(), + this.app.stage.addChild(this.animate.group), + this.emit('DisplayReady', this); + }), + this.animate.isImagesLoaded + ? (this.loaded = !0) + : (this.animate.once('success', () => { + (this.loaded = !0), this.emit('success', this); + }), + this.animate.once('error', t => { + this.emit('error', t); + })); + } +} +function et(e) { + return ( + e.container && !e.view && (e.view = e.container), + e.animationData && !e.keyframes && (e.keyframes = e.animationData), + e.assetsPath && !e.prefix && (e.prefix = e.assetsPath.replace(/images\/?$/, '')), + e.initialSegment && !e.initSegment && (e.initSegment = e.initialSegment), + t.isBoolean(e.autoplay) && !t.isBoolean(e.autoStart) && (e.autoStart = e.autoplay), + t.isBoolean(e.loop) && !t.isBoolean(e.infinite) && (e.infinite = e.loop), + (e.view = t.isString(e.view) ? document.querySelector(e.view) : e.view), + (e.useAESize = !t.isBoolean(e.useAESize) || e.useAESize), + new tt(e) + ); +} +export { + Y as Tween, + et as loadAnimation, + Q as useTicker, + k as CompElement, + z as PathLottie, + G as SolidElement, + R as SpriteElement, + h as Container, + q as LoadJson, + N as LoadTexture, +}; +export { + AnimationGroup, + AnimationManager, + BezierEasing, + DisplayRegister, + Eventer, + LoaderRegister, + PropertyFactory, + Tools, + TransformFrames, + TransformProperty, +} from './lottie-core'; diff --git a/packages/plugin-renderer-lottie/lib/types.ts b/packages/plugin-renderer-lottie/lib/types.ts index 7aa2fb1f..99e36422 100644 --- a/packages/plugin-renderer-lottie/lib/types.ts +++ b/packages/plugin-renderer-lottie/lib/types.ts @@ -3,12 +3,12 @@ export interface IExpandOpts { infinite?: boolean; slot?: Array<{ name: string; - type: 'TEXT' | 'IMAGE' + type: 'TEXT' | 'IMAGE'; value: string; style: { [key: string]: any; }; - }> + }>; } export interface IOptions { diff --git a/packages/plugin-renderer-lottie/lib/utils.js b/packages/plugin-renderer-lottie/lib/utils.js index 36c4c41e..66c25e37 100644 --- a/packages/plugin-renderer-lottie/lib/utils.js +++ b/packages/plugin-renderer-lottie/lib/utils.js @@ -1,6 +1,6 @@ import iOSVersion from 'ios-version'; -const {major} = iOSVersion(window.navigator.userAgent) || {}; +const { major } = iOSVersion(window.navigator.userAgent) || {}; /** * dataURL 转成 blob @@ -18,7 +18,7 @@ function dataURL2blob(dataURL) { let data = [intArray]; let result; try { - result = new Blob(data, {type: mime}); + result = new Blob(data, { type: mime }); } catch (error) { console.log(error); } diff --git a/packages/plugin-renderer-mask/README.md b/packages/plugin-renderer-mask/README.md index 1b140d73..b9a552b9 100644 --- a/packages/plugin-renderer-mask/README.md +++ b/packages/plugin-renderer-mask/README.md @@ -1,7 +1,6 @@ - # @eva/plugin-renderer-mask More Introduction + - [EN](https://eva.js.org) - [中文](https://eva-engine.gitee.io) - \ No newline at end of file diff --git a/packages/plugin-renderer-mask/api-extractor.json b/packages/plugin-renderer-mask/api-extractor.json index 82bf5c21..14e6145e 100644 --- a/packages/plugin-renderer-mask/api-extractor.json +++ b/packages/plugin-renderer-mask/api-extractor.json @@ -4,4 +4,4 @@ "dtsRollup": { "publicTrimmedFilePath": "./dist/plugin-renderer-mask.d.ts" } -} \ No newline at end of file +} diff --git a/packages/plugin-renderer-mask/index.js b/packages/plugin-renderer-mask/index.js index c207c2bf..41ddd667 100644 --- a/packages/plugin-renderer-mask/index.js +++ b/packages/plugin-renderer-mask/index.js @@ -1,7 +1,7 @@ -'use strict' +'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/plugin-renderer-mask.cjs.prod.js') + module.exports = require('./dist/plugin-renderer-mask.cjs.prod.js'); } else { - module.exports = require('./dist/plugin-renderer-mask.cjs.js') + module.exports = require('./dist/plugin-renderer-mask.cjs.js'); } diff --git a/packages/plugin-renderer-mask/lib/component.ts b/packages/plugin-renderer-mask/lib/component.ts index 3329718e..1829b593 100644 --- a/packages/plugin-renderer-mask/lib/component.ts +++ b/packages/plugin-renderer-mask/lib/component.ts @@ -1,4 +1,4 @@ -import {Component, decorators} from '@eva/eva.js'; +import { Component, decorators } from '@eva/eva.js'; export enum MASK_TYPE { Circle = 'Circle', diff --git a/packages/plugin-renderer-mask/lib/system.ts b/packages/plugin-renderer-mask/lib/system.ts index 42fc725e..d4d43c2d 100644 --- a/packages/plugin-renderer-mask/lib/system.ts +++ b/packages/plugin-renderer-mask/lib/system.ts @@ -1,16 +1,6 @@ -import { - decorators, - resource, - ComponentChanged, - OBSERVER_TYPE, -} from '@eva/eva.js'; -import { - Renderer, - RendererManager, - ContainerManager, - RendererSystem, -} from '@eva/plugin-renderer'; -import {Sprite as SpriteEngine, Graphics} from '@eva/renderer-adapter'; +import { decorators, resource, ComponentChanged, OBSERVER_TYPE } from '@eva/eva.js'; +import { Renderer, RendererManager, ContainerManager, RendererSystem } from '@eva/plugin-renderer'; +import { Sprite as SpriteEngine, Graphics } from '@eva/renderer-adapter'; import MaskComponent from './component'; const resourceKeySplit = '_s|r|c_'; // Notice: This key be created by sprite system. @@ -41,13 +31,13 @@ enum MASK_TYPE { } @decorators.componentObserver({ - Mask: ['type', {prop: ['style'], deep: true}, 'resource', 'spriteName'], + Mask: ['type', { prop: ['style'], deep: true }, 'resource', 'spriteName'], }) export default class Mask extends Renderer { static systemName = 'Mask'; name: string = 'Mask'; - changedCache: {[propName: number]: boolean} = {}; - maskSpriteCache: {[propName: number]: SpriteEngine} = {}; + changedCache: { [propName: number]: boolean } = {}; + maskSpriteCache: { [propName: number]: SpriteEngine } = {}; renderSystem: RendererSystem; rendererManager: RendererManager; containerManager: ContainerManager; @@ -107,9 +97,7 @@ export default class Mask extends Renderer { break; } if (!mask) { - throw new Error( - 'no have mask instance, check your mask params: ' + component.type, - ); + throw new Error('no have mask instance, check your mask params: ' + component.type); } const container = this.containerManager.getContainer(changed.gameObject.id); container.mask = mask; @@ -118,9 +106,9 @@ export default class Mask extends Renderer { remove(changed: ComponentChanged) { const container = this.containerManager.getContainer(changed.gameObject.id); container.removeChild(container.mask); - container.mask.destroy({ children: true }) + container.mask.destroy({ children: true }); container.mask = null; - delete this.maskSpriteCache[changed.component.gameObject.id] + delete this.maskSpriteCache[changed.component.gameObject.id]; } change(changed: ComponentChanged) { if (this.changedCache[changed.gameObject.id]) return; @@ -175,18 +163,14 @@ export default class Mask extends Renderer { return sprite.sprite; } changeSpriteStyle(component: MaskComponent) { - const sprite = this.maskSpriteCache[ - component.gameObject.id - ] as SpriteEngine; + const sprite = this.maskSpriteCache[component.gameObject.id] as SpriteEngine; sprite.sprite.width = component.style.width; sprite.sprite.height = component.style.height; sprite.sprite.position.x = component.style.x; sprite.sprite.position.y = component.style.y; } changeSprite(component: MaskComponent) { - const sprite = this.maskSpriteCache[ - component.gameObject.id - ] as SpriteEngine; + const sprite = this.maskSpriteCache[component.gameObject.id] as SpriteEngine; this.setSprite(component, sprite); } async setSprite(component: MaskComponent, sprite) { diff --git a/packages/plugin-renderer-nine-patch/README.md b/packages/plugin-renderer-nine-patch/README.md index 5b35e45a..c531f686 100644 --- a/packages/plugin-renderer-nine-patch/README.md +++ b/packages/plugin-renderer-nine-patch/README.md @@ -1,7 +1,6 @@ - # @eva/plugin-renderer-nine-patch More Introduction + - [EN](https://eva.js.org) - [中文](https://eva-engine.gitee.io) - \ No newline at end of file diff --git a/packages/plugin-renderer-nine-patch/api-extractor.json b/packages/plugin-renderer-nine-patch/api-extractor.json index a453a897..4252f98a 100644 --- a/packages/plugin-renderer-nine-patch/api-extractor.json +++ b/packages/plugin-renderer-nine-patch/api-extractor.json @@ -4,4 +4,4 @@ "dtsRollup": { "publicTrimmedFilePath": "./dist/plugin-renderer-nine-patch.d.ts" } -} \ No newline at end of file +} diff --git a/packages/plugin-renderer-nine-patch/index.js b/packages/plugin-renderer-nine-patch/index.js index 83e7ca56..6d963fce 100644 --- a/packages/plugin-renderer-nine-patch/index.js +++ b/packages/plugin-renderer-nine-patch/index.js @@ -1,7 +1,7 @@ -'use strict' +'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/plugin-renderer-nine-patch.cjs.prod.js') + module.exports = require('./dist/plugin-renderer-nine-patch.cjs.prod.js'); } else { - module.exports = require('./dist/plugin-renderer-nine-patch.cjs.js') + module.exports = require('./dist/plugin-renderer-nine-patch.cjs.js'); } diff --git a/packages/plugin-renderer-nine-patch/lib/component.ts b/packages/plugin-renderer-nine-patch/lib/component.ts index 027185e0..66cf2bed 100644 --- a/packages/plugin-renderer-nine-patch/lib/component.ts +++ b/packages/plugin-renderer-nine-patch/lib/component.ts @@ -1,4 +1,4 @@ -import {Component, decorators} from '@eva/eva.js'; +import { Component, decorators } from '@eva/eva.js'; export interface NinePatchParams { resource: string; diff --git a/packages/plugin-renderer-nine-patch/lib/system.ts b/packages/plugin-renderer-nine-patch/lib/system.ts index 2ed84a1a..49e5f477 100644 --- a/packages/plugin-renderer-nine-patch/lib/system.ts +++ b/packages/plugin-renderer-nine-patch/lib/system.ts @@ -1,36 +1,17 @@ -import { - GameObject, - decorators, - resource, - ComponentChanged, - RESOURCE_TYPE, - OBSERVER_TYPE, -} from '@eva/eva.js'; -import { - RendererManager, - ContainerManager, - RendererSystem, - Renderer, -} from '@eva/plugin-renderer'; -import {NinePatch as NinePatchSprite} from '@eva/renderer-adapter'; +import { GameObject, decorators, resource, ComponentChanged, RESOURCE_TYPE, OBSERVER_TYPE } from '@eva/eva.js'; +import { RendererManager, ContainerManager, RendererSystem, Renderer } from '@eva/plugin-renderer'; +import { NinePatch as NinePatchSprite } from '@eva/renderer-adapter'; import NinePatchComponent from './component'; const resourceKeySplit = '_s|r|c_'; // Notice: This key be created by sprite system. @decorators.componentObserver({ - NinePatch: [ - 'resource', - 'spriteName', - 'leftWidth', - 'topHeight', - 'rightWidth', - 'bottomHeight', - ], + NinePatch: ['resource', 'spriteName', 'leftWidth', 'topHeight', 'rightWidth', 'bottomHeight'], }) export default class NinePatch extends Renderer { static systemName: string = 'NinePatch'; name: string = 'NinePatch'; - ninePatch: {[propName: number]: any} = {}; + ninePatch: { [propName: number]: any } = {}; renderSystem: RendererSystem; rendererManager: RendererManager; containerManager: ContainerManager; @@ -39,7 +20,7 @@ export default class NinePatch extends Renderer { this.renderSystem.rendererManager.register(this); } rendererUpdate(gameObject: GameObject) { - const {width, height} = gameObject.transform.size; + const { width, height } = gameObject.transform.size; if (this.ninePatch[gameObject.id]) { this.ninePatch[gameObject.id].width = width; this.ninePatch[gameObject.id].height = height; @@ -59,11 +40,9 @@ export default class NinePatch extends Renderer { } async add(changed) { const component = changed.component as NinePatchComponent; - const {type, data} = await resource.getResource(component.resource); + const { type, data } = await resource.getResource(component.resource); if (!data) { - throw new Error( - `GameObject:${changed.gameObject.name}'s NinePatch resource load error`, - ); + throw new Error(`GameObject:${changed.gameObject.name}'s NinePatch resource load error`); } let img: any; if (type === RESOURCE_TYPE.SPRITE) { @@ -71,14 +50,8 @@ export default class NinePatch extends Renderer { } else { img = data.image; } - const {leftWidth, topHeight, rightWidth, bottomHeight} = component; - const np = new NinePatchSprite( - img, - leftWidth, - topHeight, - rightWidth, - bottomHeight, - ); + const { leftWidth, topHeight, rightWidth, bottomHeight } = component; + const np = new NinePatchSprite(img, leftWidth, topHeight, rightWidth, bottomHeight); this.ninePatch[changed.gameObject.id] = np; component.ninePatch = np; @@ -90,9 +63,7 @@ export default class NinePatch extends Renderer { remove(changed) { const sprite = this.ninePatch[changed.gameObject.id]; if (sprite) { - this.containerManager - .getContainer(changed.gameObject.id) - .removeChild(sprite); + this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite); delete this.ninePatch[changed.gameObject.id]; sprite.destroy({ children: true }); } diff --git a/packages/plugin-renderer-render/README.md b/packages/plugin-renderer-render/README.md index 8ed3a09f..f6bd5649 100644 --- a/packages/plugin-renderer-render/README.md +++ b/packages/plugin-renderer-render/README.md @@ -1,7 +1,6 @@ - # @eva/plugin-renderer-render More Introduction + - [EN](https://eva.js.org) - [中文](https://eva-engine.gitee.io) - \ No newline at end of file diff --git a/packages/plugin-renderer-render/api-extractor.json b/packages/plugin-renderer-render/api-extractor.json index 6364b795..adfdcdfb 100644 --- a/packages/plugin-renderer-render/api-extractor.json +++ b/packages/plugin-renderer-render/api-extractor.json @@ -4,4 +4,4 @@ "dtsRollup": { "publicTrimmedFilePath": "./dist/plugin-renderer-render.d.ts" } -} \ No newline at end of file +} diff --git a/packages/plugin-renderer-render/index.js b/packages/plugin-renderer-render/index.js index 93be88b1..e83c5ec1 100644 --- a/packages/plugin-renderer-render/index.js +++ b/packages/plugin-renderer-render/index.js @@ -1,7 +1,7 @@ -'use strict' +'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/plugin-renderer-render.cjs.prod.js') + module.exports = require('./dist/plugin-renderer-render.cjs.prod.js'); } else { - module.exports = require('./dist/plugin-renderer-render.cjs.js') + module.exports = require('./dist/plugin-renderer-render.cjs.js'); } diff --git a/packages/plugin-renderer-render/lib/component.ts b/packages/plugin-renderer-render/lib/component.ts index 2a9bfde4..ac84f6f7 100644 --- a/packages/plugin-renderer-render/lib/component.ts +++ b/packages/plugin-renderer-render/lib/component.ts @@ -1,4 +1,4 @@ -import {Component, decorators} from '@eva/eva.js'; +import { Component, decorators } from '@eva/eva.js'; export interface RenderParams { alpha?: number; zIndex?: number; diff --git a/packages/plugin-renderer-render/lib/system.ts b/packages/plugin-renderer-render/lib/system.ts index 3cb99305..71ea905c 100644 --- a/packages/plugin-renderer-render/lib/system.ts +++ b/packages/plugin-renderer-render/lib/system.ts @@ -1,15 +1,5 @@ -import { - GameObject, - decorators, - ComponentChanged, - OBSERVER_TYPE, -} from '@eva/eva.js'; -import { - RendererManager, - ContainerManager, - RendererSystem, - Renderer, -} from '@eva/plugin-renderer'; +import { GameObject, decorators, ComponentChanged, OBSERVER_TYPE } from '@eva/eva.js'; +import { RendererManager, ContainerManager, RendererSystem, Renderer } from '@eva/plugin-renderer'; import RenderComponent from './component'; @@ -32,9 +22,7 @@ export default class Render extends Renderer { container.alpha = component.alpha; container.visible = component.visible; if (component.sortDirty && component.sortableChildren) { - const gameObjects = gameObject.transform.children.map( - ({gameObject}) => gameObject, - ); + const gameObjects = gameObject.transform.children.map(({ gameObject }) => gameObject); const children = gameObjects .sort((a, b) => { const aRender = a.getComponent('Render') as RenderComponent; @@ -50,22 +38,15 @@ export default class Render extends Renderer { .map(gameObject => { return this.containerManager.getContainer(gameObject.id); }); - const oldChildren = this.containerManager.getContainer( - component.gameObject.id, - ).children; - const elements = oldChildren.filter( - c => children.indexOf(c as any) === -1, - ); + const oldChildren = this.containerManager.getContainer(component.gameObject.id).children; + const elements = oldChildren.filter(c => children.indexOf(c as any) === -1); oldChildren.length = 0; oldChildren.push(...elements, ...children); component.sortDirty = false; } } componentChanged(changed: ComponentChanged) { - if ( - changed.type === OBSERVER_TYPE.ADD || - changed.type === OBSERVER_TYPE.REMOVE - ) { + if (changed.type === OBSERVER_TYPE.ADD || changed.type === OBSERVER_TYPE.REMOVE) { this.add(changed); } if (changed.type === OBSERVER_TYPE.CHANGE) { @@ -81,25 +62,19 @@ export default class Render extends Renderer { } } change(changed: ComponentChanged) { - if ( - changed.component.name === 'Render' && - changed.prop.prop[0] === 'zIndex' - ) { + if (changed.component.name === 'Render' && changed.prop.prop[0] === 'zIndex') { this.setDirty(changed); } } remove(changed: ComponentChanged) { if (changed.component.name === 'Render') { - const container = this.containerManager.getContainer( - changed.gameObject.id, - ); + const container = this.containerManager.getContainer(changed.gameObject.id); container.alpha = 1; } } setDirty(changed: ComponentChanged) { const parentRender = - changed.gameObject.parent && - (changed.gameObject.parent.getComponent('Render') as RenderComponent); + changed.gameObject.parent && (changed.gameObject.parent.getComponent('Render') as RenderComponent); if (parentRender) { parentRender.sortDirty = true; } diff --git a/packages/plugin-renderer-spine/README.md b/packages/plugin-renderer-spine/README.md index 08dfd52c..4da8b705 100644 --- a/packages/plugin-renderer-spine/README.md +++ b/packages/plugin-renderer-spine/README.md @@ -1,7 +1,6 @@ - # @eva/plugin-renderer-spine More Introduction + - [EN](https://eva.js.org) - [中文](https://eva-engine.gitee.io) - \ No newline at end of file diff --git a/packages/plugin-renderer-spine/api-extractor.json b/packages/plugin-renderer-spine/api-extractor.json index ef2beeb4..a9430cb9 100644 --- a/packages/plugin-renderer-spine/api-extractor.json +++ b/packages/plugin-renderer-spine/api-extractor.json @@ -4,4 +4,4 @@ "dtsRollup": { "publicTrimmedFilePath": "./dist/plugin-renderer-spine.d.ts" } -} \ No newline at end of file +} diff --git a/packages/plugin-renderer-spine/index.js b/packages/plugin-renderer-spine/index.js index c95cea38..f6960183 100644 --- a/packages/plugin-renderer-spine/index.js +++ b/packages/plugin-renderer-spine/index.js @@ -1,7 +1,7 @@ -'use strict' +'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/plugin-renderer-spine.cjs.prod.js') + module.exports = require('./dist/plugin-renderer-spine.cjs.prod.js'); } else { - module.exports = require('./dist/plugin-renderer-spine.cjs.js') + module.exports = require('./dist/plugin-renderer-spine.cjs.js'); } diff --git a/packages/plugin-renderer-spine/lib/Spine.ts b/packages/plugin-renderer-spine/lib/Spine.ts index 8385b8a0..b91099c3 100644 --- a/packages/plugin-renderer-spine/lib/Spine.ts +++ b/packages/plugin-renderer-spine/lib/Spine.ts @@ -1,4 +1,4 @@ -import {Component, decorators} from '@eva/eva.js'; +import { Component, decorators } from '@eva/eva.js'; export interface SpineParams { resource: string; diff --git a/packages/plugin-renderer-spine/lib/SpineData.ts b/packages/plugin-renderer-spine/lib/SpineData.ts index b6153419..c51316c3 100644 --- a/packages/plugin-renderer-spine/lib/SpineData.ts +++ b/packages/plugin-renderer-spine/lib/SpineData.ts @@ -1,11 +1,6 @@ -import {resource} from '@eva/eva.js'; +import { resource } from '@eva/eva.js'; import pixispine from './pixi-spine.js'; -import { - cleanTextures, - getTexture, - releaseTexture, - retainTexture, -} from './TexCache'; +import { cleanTextures, getTexture, releaseTexture, retainTexture } from './TexCache'; let dataMap: any = {}; function createSpineData(name, imgName, data, scale) { @@ -22,13 +17,9 @@ function createSpineData(name, imgName, data, scale) { spineAtlas => { if (spineAtlas) { // @ts-ignore - const attachmentLoader = new pixispine.core.AtlasAttachmentLoader( - spineAtlas, - ); + const attachmentLoader = new pixispine.core.AtlasAttachmentLoader(spineAtlas); // @ts-ignore - const spineJsonParser = new pixispine.core.SkeletonJson( - attachmentLoader, - ); + const spineJsonParser = new pixispine.core.SkeletonJson(attachmentLoader); if (scale) { spineJsonParser.scale = scale; } @@ -36,7 +27,7 @@ function createSpineData(name, imgName, data, scale) { } }, ); - const obj = {spineData, ref: 0, imgName: imgName}; + const obj = { spineData, ref: 0, imgName: imgName }; dataMap[name] = obj; return obj; } @@ -103,6 +94,6 @@ export function releaseSpineData(name) { if (data.ref <= 0) { releaseTexture(data.imgName as string); delete dataMap[name]; - resource.destroy(name) + resource.destroy(name); } } diff --git a/packages/plugin-renderer-spine/lib/SpineSystem.ts b/packages/plugin-renderer-spine/lib/SpineSystem.ts index 162173dd..4d3d9c14 100644 --- a/packages/plugin-renderer-spine/lib/SpineSystem.ts +++ b/packages/plugin-renderer-spine/lib/SpineSystem.ts @@ -1,14 +1,9 @@ -import {DisplayObject} from 'pixi.js'; -import {decorators, ComponentChanged, OBSERVER_TYPE} from '@eva/eva.js'; -import { - Renderer, - RendererSystem, - RendererManager, - ContainerManager, -} from '@eva/plugin-renderer'; +import { DisplayObject } from 'pixi.js'; +import { decorators, ComponentChanged, OBSERVER_TYPE } from '@eva/eva.js'; +import { Renderer, RendererSystem, RendererManager, ContainerManager } from '@eva/plugin-renderer'; import Spine from './Spine'; import pixispine from './pixi-spine.js'; -import getSpineData, {releaseSpineData} from './SpineData'; +import getSpineData, { releaseSpineData } from './SpineData'; const MaxRetryCount = 20; @decorators.componentObserver({ @@ -102,9 +97,7 @@ export default class SpineSystem extends Renderer { return; } this.remove(changed); - const container = this.renderSystem.containerManager.getContainer( - changed.gameObject.id, - ); + const container = this.renderSystem.containerManager.getContainer(changed.gameObject.id); if (!container) { // console.warn('添加spine的container不存在'); return; @@ -129,25 +122,25 @@ export default class SpineSystem extends Renderer { } } // @ts-ignore - component.emit('loaded', {resource: component.resource}); + component.emit('loaded', { resource: component.resource }); armature.state.addListener({ // @ts-ignore start: (track, event) => { - component.emit('start', {track, name: track.animation.name}); + component.emit('start', { track, name: track.animation.name }); }, // @ts-ignore complete: (track, event) => { - component.emit('complete', {track, name: track.animation.name}); + component.emit('complete', { track, name: track.animation.name }); }, // @ts-ignore interrupt: (track, event) => { - component.emit('interrupt', {track, name: track.animation.name}); + component.emit('interrupt', { track, name: track.animation.name }); }, end: ( track, // @ts-ignore event, ) => { - component.emit('end', {track, name: track.animation.name}); + component.emit('end', { track, name: track.animation.name }); }, event: (track, event) => { // @ts-ignore @@ -164,9 +157,7 @@ export default class SpineSystem extends Renderer { clearTimeout(component.addHandler); const armature = this.armatures[changed.gameObject.id]; - const container = this.renderSystem.containerManager.getContainer( - changed.gameObject.id, - ); + const container = this.renderSystem.containerManager.getContainer(changed.gameObject.id); if (container && armature) { container.removeChild(armature); } else { @@ -174,7 +165,7 @@ export default class SpineSystem extends Renderer { } if (component.armature) { - component.armature.destroy({children: true}); + component.armature.destroy({ children: true }); if (component.usingResource) { releaseSpineData(component.usingResource); diff --git a/packages/plugin-renderer-spine/lib/TexCache.ts b/packages/plugin-renderer-spine/lib/TexCache.ts index 6739aaed..526a6dfa 100644 --- a/packages/plugin-renderer-spine/lib/TexCache.ts +++ b/packages/plugin-renderer-spine/lib/TexCache.ts @@ -1,6 +1,6 @@ -import {Texture} from 'pixi.js'; +import { Texture } from 'pixi.js'; -let texCache: {[name: string]: {tex: Texture; count: number}} = {}; +let texCache: { [name: string]: { tex: Texture; count: number } } = {}; function cacheImage(data: any) { const oldImg = data.image; diff --git a/packages/plugin-renderer-spine/lib/index.ts b/packages/plugin-renderer-spine/lib/index.ts index db7b873d..838937cc 100644 --- a/packages/plugin-renderer-spine/lib/index.ts +++ b/packages/plugin-renderer-spine/lib/index.ts @@ -1,3 +1,3 @@ export { default as SpineSystem } from './SpineSystem'; export { default as Spine } from './Spine'; -export type { SpineParams } from './Spine'; \ No newline at end of file +export type { SpineParams } from './Spine'; diff --git a/packages/plugin-renderer-spine/lib/pixi-spine.js b/packages/plugin-renderer-spine/lib/pixi-spine.js index 4d759dd4..b99a1b0b 100644 --- a/packages/plugin-renderer-spine/lib/pixi-spine.js +++ b/packages/plugin-renderer-spine/lib/pixi-spine.js @@ -1,9145 +1,7702 @@ -import { - Texture, - Rectangle, - Sprite, - Graphics, - mesh, - Matrix, - Container, - SCALE_MODES, - utils, - loaders, - TransformBase, - TransformStatic, - DisplayObject, - Polygon, - BaseTexture, -} from 'pixi.js'; - -const VERSION = '4.8.9'; -const loader = loaders.shared; - -const PIXI = { - Texture, - Rectangle, - Sprite, - Graphics, - mesh, - Matrix, - Container, - VERSION, - loaders, - loader, - SCALE_MODES, - utils, - TransformBase, - TransformStatic, - DisplayObject, - Polygon, - BaseTexture, -}; - -('use strict'); -var __extends = - (this && this.__extends) || - (function() { - var extendStatics = - Object.setPrototypeOf || - ({__proto__: []} instanceof Array && - function(d, b) { - d.__proto__ = b; - }) || - function(d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - }; - return function(d, b) { - extendStatics(d, b); - function __() { - this.constructor = d; - } - d.prototype = - b === null - ? Object.create(b) - : ((__.prototype = b.prototype), new __()); - }; - })(); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var Animation = (function() { - function Animation(name, timelines, duration) { - if (name == null) throw new Error('name cannot be null.'); - if (timelines == null) throw new Error('timelines cannot be null.'); - this.name = name; - this.timelines = timelines; - this.duration = duration; - } - Animation.prototype.apply = function( - skeleton, - lastTime, - time, - loop, - events, - alpha, - blend, - direction, - ) { - if (skeleton == null) throw new Error('skeleton cannot be null.'); - if (loop && this.duration != 0) { - time %= this.duration; - if (lastTime > 0) lastTime %= this.duration; - } - var timelines = this.timelines; - for (var i = 0, n = timelines.length; i < n; i++) - timelines[i].apply( - skeleton, - lastTime, - time, - events, - alpha, - blend, - direction, - ); - }; - Animation.binarySearch = function(values, target, step) { - if (step === void 0) { - step = 1; - } - var low = 0; - var high = values.length / step - 2; - if (high == 0) return step; - var current = high >>> 1; - while (true) { - if (values[(current + 1) * step] <= target) low = current + 1; - else high = current; - if (low == high) return (low + 1) * step; - current = (low + high) >>> 1; - } - }; - Animation.linearSearch = function(values, target, step) { - for (var i = 0, last = values.length - step; i <= last; i += step) - if (values[i] > target) return i; - return -1; - }; - return Animation; - })(); - core.Animation = Animation; - var MixBlend; - (function(MixBlend) { - MixBlend[(MixBlend['setup'] = 0)] = 'setup'; - MixBlend[(MixBlend['first'] = 1)] = 'first'; - MixBlend[(MixBlend['replace'] = 2)] = 'replace'; - MixBlend[(MixBlend['add'] = 3)] = 'add'; - })((MixBlend = core.MixBlend || (core.MixBlend = {}))); - var MixDirection; - (function(MixDirection) { - MixDirection[(MixDirection['in'] = 0)] = 'in'; - MixDirection[(MixDirection['out'] = 1)] = 'out'; - })((MixDirection = core.MixDirection || (core.MixDirection = {}))); - var TimelineType; - (function(TimelineType) { - TimelineType[(TimelineType['rotate'] = 0)] = 'rotate'; - TimelineType[(TimelineType['translate'] = 1)] = 'translate'; - TimelineType[(TimelineType['scale'] = 2)] = 'scale'; - TimelineType[(TimelineType['shear'] = 3)] = 'shear'; - TimelineType[(TimelineType['attachment'] = 4)] = 'attachment'; - TimelineType[(TimelineType['color'] = 5)] = 'color'; - TimelineType[(TimelineType['deform'] = 6)] = 'deform'; - TimelineType[(TimelineType['event'] = 7)] = 'event'; - TimelineType[(TimelineType['drawOrder'] = 8)] = 'drawOrder'; - TimelineType[(TimelineType['ikConstraint'] = 9)] = 'ikConstraint'; - TimelineType[(TimelineType['transformConstraint'] = 10)] = - 'transformConstraint'; - TimelineType[(TimelineType['pathConstraintPosition'] = 11)] = - 'pathConstraintPosition'; - TimelineType[(TimelineType['pathConstraintSpacing'] = 12)] = - 'pathConstraintSpacing'; - TimelineType[(TimelineType['pathConstraintMix'] = 13)] = - 'pathConstraintMix'; - TimelineType[(TimelineType['twoColor'] = 14)] = 'twoColor'; - })((TimelineType = core.TimelineType || (core.TimelineType = {}))); - var CurveTimeline = (function() { - function CurveTimeline(frameCount) { - if (frameCount <= 0) - throw new Error('frameCount must be > 0: ' + frameCount); - this.curves = core.Utils.newFloatArray( - (frameCount - 1) * CurveTimeline.BEZIER_SIZE, - ); - } - CurveTimeline.prototype.getFrameCount = function() { - return this.curves.length / CurveTimeline.BEZIER_SIZE + 1; - }; - CurveTimeline.prototype.setLinear = function(frameIndex) { - this.curves[frameIndex * CurveTimeline.BEZIER_SIZE] = - CurveTimeline.LINEAR; - }; - CurveTimeline.prototype.setStepped = function(frameIndex) { - this.curves[frameIndex * CurveTimeline.BEZIER_SIZE] = - CurveTimeline.STEPPED; - }; - CurveTimeline.prototype.getCurveType = function(frameIndex) { - var index = frameIndex * CurveTimeline.BEZIER_SIZE; - if (index == this.curves.length) return CurveTimeline.LINEAR; - var type = this.curves[index]; - if (type == CurveTimeline.LINEAR) return CurveTimeline.LINEAR; - if (type == CurveTimeline.STEPPED) return CurveTimeline.STEPPED; - return CurveTimeline.BEZIER; - }; - CurveTimeline.prototype.setCurve = function( - frameIndex, - cx1, - cy1, - cx2, - cy2, - ) { - var tmpx = (-cx1 * 2 + cx2) * 0.03, - tmpy = (-cy1 * 2 + cy2) * 0.03; - var dddfx = ((cx1 - cx2) * 3 + 1) * 0.006, - dddfy = ((cy1 - cy2) * 3 + 1) * 0.006; - var ddfx = tmpx * 2 + dddfx, - ddfy = tmpy * 2 + dddfy; - var dfx = cx1 * 0.3 + tmpx + dddfx * 0.16666667, - dfy = cy1 * 0.3 + tmpy + dddfy * 0.16666667; - var i = frameIndex * CurveTimeline.BEZIER_SIZE; - var curves = this.curves; - curves[i++] = CurveTimeline.BEZIER; - var x = dfx, - y = dfy; - for (var n = i + CurveTimeline.BEZIER_SIZE - 1; i < n; i += 2) { - curves[i] = x; - curves[i + 1] = y; - dfx += ddfx; - dfy += ddfy; - ddfx += dddfx; - ddfy += dddfy; - x += dfx; - y += dfy; - } - }; - CurveTimeline.prototype.getCurvePercent = function(frameIndex, percent) { - percent = core.MathUtils.clamp(percent, 0, 1); - var curves = this.curves; - var i = frameIndex * CurveTimeline.BEZIER_SIZE; - var type = curves[i]; - if (type == CurveTimeline.LINEAR) return percent; - if (type == CurveTimeline.STEPPED) return 0; - i++; - var x = 0; - for ( - var start = i, n = i + CurveTimeline.BEZIER_SIZE - 1; - i < n; - i += 2 - ) { - x = curves[i]; - if (x >= percent) { - var prevX = void 0, - prevY = void 0; - if (i == start) { - prevX = 0; - prevY = 0; - } else { - prevX = curves[i - 2]; - prevY = curves[i - 1]; - } - return ( - prevY + - ((curves[i + 1] - prevY) * (percent - prevX)) / (x - prevX) - ); - } - } - var y = curves[i - 1]; - return y + ((1 - y) * (percent - x)) / (1 - x); - }; - CurveTimeline.LINEAR = 0; - CurveTimeline.STEPPED = 1; - CurveTimeline.BEZIER = 2; - CurveTimeline.BEZIER_SIZE = 10 * 2 - 1; - return CurveTimeline; - })(); - core.CurveTimeline = CurveTimeline; - var RotateTimeline = (function(_super) { - __extends(RotateTimeline, _super); - function RotateTimeline(frameCount) { - var _this = _super.call(this, frameCount) || this; - _this.frames = core.Utils.newFloatArray(frameCount << 1); - return _this; - } - RotateTimeline.prototype.getPropertyId = function() { - return (TimelineType.rotate << 24) + this.boneIndex; - }; - RotateTimeline.prototype.setFrame = function(frameIndex, time, degrees) { - frameIndex <<= 1; - this.frames[frameIndex] = time; - this.frames[frameIndex + RotateTimeline.ROTATION] = degrees; - }; - RotateTimeline.prototype.apply = function( - skeleton, - lastTime, - time, - events, - alpha, - blend, - direction, - ) { - var frames = this.frames; - var bone = skeleton.bones[this.boneIndex]; - if (time < frames[0]) { - switch (blend) { - case MixBlend.setup: - bone.rotation = bone.data.rotation; - return; - case MixBlend.first: - var r_1 = bone.data.rotation - bone.rotation; - bone.rotation += - (r_1 - (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360) * - alpha; - } - return; - } - if (time >= frames[frames.length - RotateTimeline.ENTRIES]) { - var r_2 = frames[frames.length + RotateTimeline.PREV_ROTATION]; - switch (blend) { - case MixBlend.setup: - bone.rotation = bone.data.rotation + r_2 * alpha; - break; - case MixBlend.first: - case MixBlend.replace: - r_2 += bone.data.rotation - bone.rotation; - r_2 -= (16384 - ((16384.499999999996 - r_2 / 360) | 0)) * 360; - case MixBlend.add: - bone.rotation += r_2 * alpha; - } - return; - } - var frame = Animation.binarySearch( - frames, - time, - RotateTimeline.ENTRIES, - ); - var prevRotation = frames[frame + RotateTimeline.PREV_ROTATION]; - var frameTime = frames[frame]; - var percent = this.getCurvePercent( - (frame >> 1) - 1, - 1 - - (time - frameTime) / - (frames[frame + RotateTimeline.PREV_TIME] - frameTime), - ); - var r = frames[frame + RotateTimeline.ROTATION] - prevRotation; - r = - prevRotation + - (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * percent; - switch (blend) { - case MixBlend.setup: - bone.rotation = - bone.data.rotation + - (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * - alpha; - break; - case MixBlend.first: - case MixBlend.replace: - r += bone.data.rotation - bone.rotation; - case MixBlend.add: - bone.rotation += - (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * - alpha; - } - }; - RotateTimeline.ENTRIES = 2; - RotateTimeline.PREV_TIME = -2; - RotateTimeline.PREV_ROTATION = -1; - RotateTimeline.ROTATION = 1; - return RotateTimeline; - })(CurveTimeline); - core.RotateTimeline = RotateTimeline; - var TranslateTimeline = (function(_super) { - __extends(TranslateTimeline, _super); - function TranslateTimeline(frameCount) { - var _this = _super.call(this, frameCount) || this; - _this.frames = core.Utils.newFloatArray( - frameCount * TranslateTimeline.ENTRIES, - ); - return _this; - } - TranslateTimeline.prototype.getPropertyId = function() { - return (TimelineType.translate << 24) + this.boneIndex; - }; - TranslateTimeline.prototype.setFrame = function(frameIndex, time, x, y) { - frameIndex *= TranslateTimeline.ENTRIES; - this.frames[frameIndex] = time; - this.frames[frameIndex + TranslateTimeline.X] = x; - this.frames[frameIndex + TranslateTimeline.Y] = y; - }; - TranslateTimeline.prototype.apply = function( - skeleton, - lastTime, - time, - events, - alpha, - blend, - direction, - ) { - var frames = this.frames; - var bone = skeleton.bones[this.boneIndex]; - if (time < frames[0]) { - switch (blend) { - case MixBlend.setup: - bone.x = bone.data.x; - bone.y = bone.data.y; - return; - case MixBlend.first: - bone.x += (bone.data.x - bone.x) * alpha; - bone.y += (bone.data.y - bone.y) * alpha; - } - return; - } - var x = 0, - y = 0; - if (time >= frames[frames.length - TranslateTimeline.ENTRIES]) { - x = frames[frames.length + TranslateTimeline.PREV_X]; - y = frames[frames.length + TranslateTimeline.PREV_Y]; - } else { - var frame = Animation.binarySearch( - frames, - time, - TranslateTimeline.ENTRIES, - ); - x = frames[frame + TranslateTimeline.PREV_X]; - y = frames[frame + TranslateTimeline.PREV_Y]; - var frameTime = frames[frame]; - var percent = this.getCurvePercent( - frame / TranslateTimeline.ENTRIES - 1, - 1 - - (time - frameTime) / - (frames[frame + TranslateTimeline.PREV_TIME] - frameTime), - ); - x += (frames[frame + TranslateTimeline.X] - x) * percent; - y += (frames[frame + TranslateTimeline.Y] - y) * percent; - } - switch (blend) { - case MixBlend.setup: - bone.x = bone.data.x + x * alpha; - bone.y = bone.data.y + y * alpha; - break; - case MixBlend.first: - case MixBlend.replace: - bone.x += (bone.data.x + x - bone.x) * alpha; - bone.y += (bone.data.y + y - bone.y) * alpha; - break; - case MixBlend.add: - bone.x += x * alpha; - bone.y += y * alpha; - } - }; - TranslateTimeline.ENTRIES = 3; - TranslateTimeline.PREV_TIME = -3; - TranslateTimeline.PREV_X = -2; - TranslateTimeline.PREV_Y = -1; - TranslateTimeline.X = 1; - TranslateTimeline.Y = 2; - return TranslateTimeline; - })(CurveTimeline); - core.TranslateTimeline = TranslateTimeline; - var ScaleTimeline = (function(_super) { - __extends(ScaleTimeline, _super); - function ScaleTimeline(frameCount) { - return _super.call(this, frameCount) || this; - } - ScaleTimeline.prototype.getPropertyId = function() { - return (TimelineType.scale << 24) + this.boneIndex; - }; - ScaleTimeline.prototype.apply = function( - skeleton, - lastTime, - time, - events, - alpha, - blend, - direction, - ) { - var frames = this.frames; - var bone = skeleton.bones[this.boneIndex]; - if (time < frames[0]) { - switch (blend) { - case MixBlend.setup: - bone.scaleX = bone.data.scaleX; - bone.scaleY = bone.data.scaleY; - return; - case MixBlend.first: - bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha; - bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha; - } - return; - } - var x = 0, - y = 0; - if (time >= frames[frames.length - ScaleTimeline.ENTRIES]) { - x = frames[frames.length + ScaleTimeline.PREV_X] * bone.data.scaleX; - y = frames[frames.length + ScaleTimeline.PREV_Y] * bone.data.scaleY; - } else { - var frame = Animation.binarySearch( - frames, - time, - ScaleTimeline.ENTRIES, - ); - x = frames[frame + ScaleTimeline.PREV_X]; - y = frames[frame + ScaleTimeline.PREV_Y]; - var frameTime = frames[frame]; - var percent = this.getCurvePercent( - frame / ScaleTimeline.ENTRIES - 1, - 1 - - (time - frameTime) / - (frames[frame + ScaleTimeline.PREV_TIME] - frameTime), - ); - x = - (x + (frames[frame + ScaleTimeline.X] - x) * percent) * - bone.data.scaleX; - y = - (y + (frames[frame + ScaleTimeline.Y] - y) * percent) * - bone.data.scaleY; - } - if (alpha == 1) { - if (blend == MixBlend.add) { - bone.scaleX += x - bone.data.scaleX; - bone.scaleY += y - bone.data.scaleY; - } else { - bone.scaleX = x; - bone.scaleY = y; - } - } else { - var bx = 0, - by = 0; - if (direction == MixDirection.out) { - switch (blend) { - case MixBlend.setup: - bx = bone.data.scaleX; - by = bone.data.scaleY; - bone.scaleX = - bx + (Math.abs(x) * core.MathUtils.signum(bx) - bx) * alpha; - bone.scaleY = - by + (Math.abs(y) * core.MathUtils.signum(by) - by) * alpha; - break; - case MixBlend.first: - case MixBlend.replace: - bx = bone.scaleX; - by = bone.scaleY; - bone.scaleX = - bx + (Math.abs(x) * core.MathUtils.signum(bx) - bx) * alpha; - bone.scaleY = - by + (Math.abs(y) * core.MathUtils.signum(by) - by) * alpha; - break; - case MixBlend.add: - bx = bone.scaleX; - by = bone.scaleY; - bone.scaleX = - bx + - (Math.abs(x) * core.MathUtils.signum(bx) - bone.data.scaleX) * - alpha; - bone.scaleY = - by + - (Math.abs(y) * core.MathUtils.signum(by) - bone.data.scaleY) * - alpha; - } - } else { - switch (blend) { - case MixBlend.setup: - bx = Math.abs(bone.data.scaleX) * core.MathUtils.signum(x); - by = Math.abs(bone.data.scaleY) * core.MathUtils.signum(y); - bone.scaleX = bx + (x - bx) * alpha; - bone.scaleY = by + (y - by) * alpha; - break; - case MixBlend.first: - case MixBlend.replace: - bx = Math.abs(bone.scaleX) * core.MathUtils.signum(x); - by = Math.abs(bone.scaleY) * core.MathUtils.signum(y); - bone.scaleX = bx + (x - bx) * alpha; - bone.scaleY = by + (y - by) * alpha; - break; - case MixBlend.add: - bx = core.MathUtils.signum(x); - by = core.MathUtils.signum(y); - bone.scaleX = - Math.abs(bone.scaleX) * bx + - (x - Math.abs(bone.data.scaleX) * bx) * alpha; - bone.scaleY = - Math.abs(bone.scaleY) * by + - (y - Math.abs(bone.data.scaleY) * by) * alpha; - } - } - } - }; - return ScaleTimeline; - })(TranslateTimeline); - core.ScaleTimeline = ScaleTimeline; - var ShearTimeline = (function(_super) { - __extends(ShearTimeline, _super); - function ShearTimeline(frameCount) { - return _super.call(this, frameCount) || this; - } - ShearTimeline.prototype.getPropertyId = function() { - return (TimelineType.shear << 24) + this.boneIndex; - }; - ShearTimeline.prototype.apply = function( - skeleton, - lastTime, - time, - events, - alpha, - blend, - direction, - ) { - var frames = this.frames; - var bone = skeleton.bones[this.boneIndex]; - if (time < frames[0]) { - switch (blend) { - case MixBlend.setup: - bone.shearX = bone.data.shearX; - bone.shearY = bone.data.shearY; - return; - case MixBlend.first: - bone.shearX += (bone.data.shearX - bone.shearX) * alpha; - bone.shearY += (bone.data.shearY - bone.shearY) * alpha; - } - return; - } - var x = 0, - y = 0; - if (time >= frames[frames.length - ShearTimeline.ENTRIES]) { - x = frames[frames.length + ShearTimeline.PREV_X]; - y = frames[frames.length + ShearTimeline.PREV_Y]; - } else { - var frame = Animation.binarySearch( - frames, - time, - ShearTimeline.ENTRIES, - ); - x = frames[frame + ShearTimeline.PREV_X]; - y = frames[frame + ShearTimeline.PREV_Y]; - var frameTime = frames[frame]; - var percent = this.getCurvePercent( - frame / ShearTimeline.ENTRIES - 1, - 1 - - (time - frameTime) / - (frames[frame + ShearTimeline.PREV_TIME] - frameTime), - ); - x = x + (frames[frame + ShearTimeline.X] - x) * percent; - y = y + (frames[frame + ShearTimeline.Y] - y) * percent; - } - switch (blend) { - case MixBlend.setup: - bone.shearX = bone.data.shearX + x * alpha; - bone.shearY = bone.data.shearY + y * alpha; - break; - case MixBlend.first: - case MixBlend.replace: - bone.shearX += (bone.data.shearX + x - bone.shearX) * alpha; - bone.shearY += (bone.data.shearY + y - bone.shearY) * alpha; - break; - case MixBlend.add: - bone.shearX += x * alpha; - bone.shearY += y * alpha; - } - }; - return ShearTimeline; - })(TranslateTimeline); - core.ShearTimeline = ShearTimeline; - var ColorTimeline = (function(_super) { - __extends(ColorTimeline, _super); - function ColorTimeline(frameCount) { - var _this = _super.call(this, frameCount) || this; - _this.frames = core.Utils.newFloatArray( - frameCount * ColorTimeline.ENTRIES, - ); - return _this; - } - ColorTimeline.prototype.getPropertyId = function() { - return (TimelineType.color << 24) + this.slotIndex; - }; - ColorTimeline.prototype.setFrame = function( - frameIndex, - time, - r, - g, - b, - a, - ) { - frameIndex *= ColorTimeline.ENTRIES; - this.frames[frameIndex] = time; - this.frames[frameIndex + ColorTimeline.R] = r; - this.frames[frameIndex + ColorTimeline.G] = g; - this.frames[frameIndex + ColorTimeline.B] = b; - this.frames[frameIndex + ColorTimeline.A] = a; - }; - ColorTimeline.prototype.apply = function( - skeleton, - lastTime, - time, - events, - alpha, - blend, - direction, - ) { - var slot = skeleton.slots[this.slotIndex]; - var frames = this.frames; - if (time < frames[0]) { - switch (blend) { - case MixBlend.setup: - slot.color.setFromColor(slot.data.color); - return; - case MixBlend.first: - var color = slot.color, - setup = slot.data.color; - color.add( - (setup.r - color.r) * alpha, - (setup.g - color.g) * alpha, - (setup.b - color.b) * alpha, - (setup.a - color.a) * alpha, - ); - } - return; - } - var r = 0, - g = 0, - b = 0, - a = 0; - if (time >= frames[frames.length - ColorTimeline.ENTRIES]) { - var i = frames.length; - r = frames[i + ColorTimeline.PREV_R]; - g = frames[i + ColorTimeline.PREV_G]; - b = frames[i + ColorTimeline.PREV_B]; - a = frames[i + ColorTimeline.PREV_A]; - } else { - var frame = Animation.binarySearch( - frames, - time, - ColorTimeline.ENTRIES, - ); - r = frames[frame + ColorTimeline.PREV_R]; - g = frames[frame + ColorTimeline.PREV_G]; - b = frames[frame + ColorTimeline.PREV_B]; - a = frames[frame + ColorTimeline.PREV_A]; - var frameTime = frames[frame]; - var percent = this.getCurvePercent( - frame / ColorTimeline.ENTRIES - 1, - 1 - - (time - frameTime) / - (frames[frame + ColorTimeline.PREV_TIME] - frameTime), - ); - r += (frames[frame + ColorTimeline.R] - r) * percent; - g += (frames[frame + ColorTimeline.G] - g) * percent; - b += (frames[frame + ColorTimeline.B] - b) * percent; - a += (frames[frame + ColorTimeline.A] - a) * percent; - } - if (alpha == 1) slot.color.set(r, g, b, a); - else { - var color = slot.color; - if (blend == MixBlend.setup) color.setFromColor(slot.data.color); - color.add( - (r - color.r) * alpha, - (g - color.g) * alpha, - (b - color.b) * alpha, - (a - color.a) * alpha, - ); - } - }; - ColorTimeline.ENTRIES = 5; - ColorTimeline.PREV_TIME = -5; - ColorTimeline.PREV_R = -4; - ColorTimeline.PREV_G = -3; - ColorTimeline.PREV_B = -2; - ColorTimeline.PREV_A = -1; - ColorTimeline.R = 1; - ColorTimeline.G = 2; - ColorTimeline.B = 3; - ColorTimeline.A = 4; - return ColorTimeline; - })(CurveTimeline); - core.ColorTimeline = ColorTimeline; - var TwoColorTimeline = (function(_super) { - __extends(TwoColorTimeline, _super); - function TwoColorTimeline(frameCount) { - var _this = _super.call(this, frameCount) || this; - _this.frames = core.Utils.newFloatArray( - frameCount * TwoColorTimeline.ENTRIES, - ); - return _this; - } - TwoColorTimeline.prototype.getPropertyId = function() { - return (TimelineType.twoColor << 24) + this.slotIndex; - }; - TwoColorTimeline.prototype.setFrame = function( - frameIndex, - time, - r, - g, - b, - a, - r2, - g2, - b2, - ) { - frameIndex *= TwoColorTimeline.ENTRIES; - this.frames[frameIndex] = time; - this.frames[frameIndex + TwoColorTimeline.R] = r; - this.frames[frameIndex + TwoColorTimeline.G] = g; - this.frames[frameIndex + TwoColorTimeline.B] = b; - this.frames[frameIndex + TwoColorTimeline.A] = a; - this.frames[frameIndex + TwoColorTimeline.R2] = r2; - this.frames[frameIndex + TwoColorTimeline.G2] = g2; - this.frames[frameIndex + TwoColorTimeline.B2] = b2; - }; - TwoColorTimeline.prototype.apply = function( - skeleton, - lastTime, - time, - events, - alpha, - blend, - direction, - ) { - var slot = skeleton.slots[this.slotIndex]; - var frames = this.frames; - if (time < frames[0]) { - switch (blend) { - case MixBlend.setup: - slot.color.setFromColor(slot.data.color); - slot.darkColor.setFromColor(slot.data.darkColor); - return; - case MixBlend.first: - var light = slot.color, - dark = slot.darkColor, - setupLight = slot.data.color, - setupDark = slot.data.darkColor; - light.add( - (setupLight.r - light.r) * alpha, - (setupLight.g - light.g) * alpha, - (setupLight.b - light.b) * alpha, - (setupLight.a - light.a) * alpha, - ); - dark.add( - (setupDark.r - dark.r) * alpha, - (setupDark.g - dark.g) * alpha, - (setupDark.b - dark.b) * alpha, - 0, - ); - } - return; - } - var r = 0, - g = 0, - b = 0, - a = 0, - r2 = 0, - g2 = 0, - b2 = 0; - if (time >= frames[frames.length - TwoColorTimeline.ENTRIES]) { - var i = frames.length; - r = frames[i + TwoColorTimeline.PREV_R]; - g = frames[i + TwoColorTimeline.PREV_G]; - b = frames[i + TwoColorTimeline.PREV_B]; - a = frames[i + TwoColorTimeline.PREV_A]; - r2 = frames[i + TwoColorTimeline.PREV_R2]; - g2 = frames[i + TwoColorTimeline.PREV_G2]; - b2 = frames[i + TwoColorTimeline.PREV_B2]; - } else { - var frame = Animation.binarySearch( - frames, - time, - TwoColorTimeline.ENTRIES, - ); - r = frames[frame + TwoColorTimeline.PREV_R]; - g = frames[frame + TwoColorTimeline.PREV_G]; - b = frames[frame + TwoColorTimeline.PREV_B]; - a = frames[frame + TwoColorTimeline.PREV_A]; - r2 = frames[frame + TwoColorTimeline.PREV_R2]; - g2 = frames[frame + TwoColorTimeline.PREV_G2]; - b2 = frames[frame + TwoColorTimeline.PREV_B2]; - var frameTime = frames[frame]; - var percent = this.getCurvePercent( - frame / TwoColorTimeline.ENTRIES - 1, - 1 - - (time - frameTime) / - (frames[frame + TwoColorTimeline.PREV_TIME] - frameTime), - ); - r += (frames[frame + TwoColorTimeline.R] - r) * percent; - g += (frames[frame + TwoColorTimeline.G] - g) * percent; - b += (frames[frame + TwoColorTimeline.B] - b) * percent; - a += (frames[frame + TwoColorTimeline.A] - a) * percent; - r2 += (frames[frame + TwoColorTimeline.R2] - r2) * percent; - g2 += (frames[frame + TwoColorTimeline.G2] - g2) * percent; - b2 += (frames[frame + TwoColorTimeline.B2] - b2) * percent; - } - if (alpha == 1) { - slot.color.set(r, g, b, a); - slot.darkColor.set(r2, g2, b2, 1); - } else { - var light = slot.color, - dark = slot.darkColor; - if (blend == MixBlend.setup) { - light.setFromColor(slot.data.color); - dark.setFromColor(slot.data.darkColor); - } - light.add( - (r - light.r) * alpha, - (g - light.g) * alpha, - (b - light.b) * alpha, - (a - light.a) * alpha, - ); - dark.add( - (r2 - dark.r) * alpha, - (g2 - dark.g) * alpha, - (b2 - dark.b) * alpha, - 0, - ); - } - }; - TwoColorTimeline.ENTRIES = 8; - TwoColorTimeline.PREV_TIME = -8; - TwoColorTimeline.PREV_R = -7; - TwoColorTimeline.PREV_G = -6; - TwoColorTimeline.PREV_B = -5; - TwoColorTimeline.PREV_A = -4; - TwoColorTimeline.PREV_R2 = -3; - TwoColorTimeline.PREV_G2 = -2; - TwoColorTimeline.PREV_B2 = -1; - TwoColorTimeline.R = 1; - TwoColorTimeline.G = 2; - TwoColorTimeline.B = 3; - TwoColorTimeline.A = 4; - TwoColorTimeline.R2 = 5; - TwoColorTimeline.G2 = 6; - TwoColorTimeline.B2 = 7; - return TwoColorTimeline; - })(CurveTimeline); - core.TwoColorTimeline = TwoColorTimeline; - var AttachmentTimeline = (function() { - function AttachmentTimeline(frameCount) { - this.frames = core.Utils.newFloatArray(frameCount); - this.attachmentNames = new Array(frameCount); - } - AttachmentTimeline.prototype.getPropertyId = function() { - return (TimelineType.attachment << 24) + this.slotIndex; - }; - AttachmentTimeline.prototype.getFrameCount = function() { - return this.frames.length; - }; - AttachmentTimeline.prototype.setFrame = function( - frameIndex, - time, - attachmentName, - ) { - this.frames[frameIndex] = time; - this.attachmentNames[frameIndex] = attachmentName; - }; - AttachmentTimeline.prototype.apply = function( - skeleton, - lastTime, - time, - events, - alpha, - blend, - direction, - ) { - var slot = skeleton.slots[this.slotIndex]; - if (direction == MixDirection.out && blend == MixBlend.setup) { - var attachmentName_1 = slot.data.attachmentName; - slot.setAttachment( - attachmentName_1 == null - ? null - : skeleton.getAttachment(this.slotIndex, attachmentName_1), - ); - return; - } - var frames = this.frames; - if (time < frames[0]) { - if (blend == MixBlend.setup || blend == MixBlend.first) { - var attachmentName_2 = slot.data.attachmentName; - slot.setAttachment( - attachmentName_2 == null - ? null - : skeleton.getAttachment(this.slotIndex, attachmentName_2), - ); - } - return; - } - var frameIndex = 0; - if (time >= frames[frames.length - 1]) frameIndex = frames.length - 1; - else frameIndex = Animation.binarySearch(frames, time, 1) - 1; - var attachmentName = this.attachmentNames[frameIndex]; - skeleton.slots[this.slotIndex].setAttachment( - attachmentName == null - ? null - : skeleton.getAttachment(this.slotIndex, attachmentName), - ); - }; - return AttachmentTimeline; - })(); - core.AttachmentTimeline = AttachmentTimeline; - var zeros = null; - var DeformTimeline = (function(_super) { - __extends(DeformTimeline, _super); - function DeformTimeline(frameCount) { - var _this = _super.call(this, frameCount) || this; - _this.frames = core.Utils.newFloatArray(frameCount); - _this.frameVertices = new Array(frameCount); - if (zeros == null) zeros = core.Utils.newFloatArray(64); - return _this; - } - DeformTimeline.prototype.getPropertyId = function() { - return ( - (TimelineType.deform << 27) + +this.attachment.id + this.slotIndex - ); - }; - DeformTimeline.prototype.setFrame = function(frameIndex, time, vertices) { - this.frames[frameIndex] = time; - this.frameVertices[frameIndex] = vertices; - }; - DeformTimeline.prototype.apply = function( - skeleton, - lastTime, - time, - firedEvents, - alpha, - blend, - direction, - ) { - var slot = skeleton.slots[this.slotIndex]; - var slotAttachment = slot.getAttachment(); - if ( - !(slotAttachment instanceof core.VertexAttachment) || - !slotAttachment.applyDeform(this.attachment) - ) - return; - var verticesArray = slot.attachmentVertices; - if (verticesArray.length == 0) blend = MixBlend.setup; - var frameVertices = this.frameVertices; - var vertexCount = frameVertices[0].length; - var frames = this.frames; - if (time < frames[0]) { - var vertexAttachment = slotAttachment; - switch (blend) { - case MixBlend.setup: - verticesArray.length = 0; - return; - case MixBlend.first: - if (alpha == 1) { - verticesArray.length = 0; - break; - } - var vertices_1 = core.Utils.setArraySize( - verticesArray, - vertexCount, - ); - if (vertexAttachment.bones == null) { - var setupVertices = vertexAttachment.vertices; - for (var i = 0; i < vertexCount; i++) - vertices_1[i] += (setupVertices[i] - vertices_1[i]) * alpha; - } else { - alpha = 1 - alpha; - for (var i = 0; i < vertexCount; i++) vertices_1[i] *= alpha; - } - } - return; - } - var vertices = core.Utils.setArraySize(verticesArray, vertexCount); - if (time >= frames[frames.length - 1]) { - var lastVertices = frameVertices[frames.length - 1]; - if (alpha == 1) { - if (blend == MixBlend.add) { - var vertexAttachment = slotAttachment; - if (vertexAttachment.bones == null) { - var setupVertices = vertexAttachment.vertices; - for (var i = 0; i < vertexCount; i++) { - vertices[i] += lastVertices[i] - setupVertices[i]; - } - } else { - for (var i = 0; i < vertexCount; i++) - vertices[i] += lastVertices[i]; - } - } else { - core.Utils.arrayCopy(lastVertices, 0, vertices, 0, vertexCount); - } - } else { - switch (blend) { - case MixBlend.setup: { - var vertexAttachment_1 = slotAttachment; - if (vertexAttachment_1.bones == null) { - var setupVertices = vertexAttachment_1.vertices; - for (var i = 0; i < vertexCount; i++) { - var setup = setupVertices[i]; - vertices[i] = setup + (lastVertices[i] - setup) * alpha; - } - } else { - for (var i = 0; i < vertexCount; i++) - vertices[i] = lastVertices[i] * alpha; - } - break; - } - case MixBlend.first: - case MixBlend.replace: - for (var i = 0; i < vertexCount; i++) - vertices[i] += (lastVertices[i] - vertices[i]) * alpha; - case MixBlend.add: - var vertexAttachment = slotAttachment; - if (vertexAttachment.bones == null) { - var setupVertices = vertexAttachment.vertices; - for (var i = 0; i < vertexCount; i++) { - vertices[i] += (lastVertices[i] - setupVertices[i]) * alpha; - } - } else { - for (var i = 0; i < vertexCount; i++) - vertices[i] += lastVertices[i] * alpha; - } - } - } - return; - } - var frame = Animation.binarySearch(frames, time); - var prevVertices = frameVertices[frame - 1]; - var nextVertices = frameVertices[frame]; - var frameTime = frames[frame]; - var percent = this.getCurvePercent( - frame - 1, - 1 - (time - frameTime) / (frames[frame - 1] - frameTime), - ); - if (alpha == 1) { - if (blend == MixBlend.add) { - var vertexAttachment = slotAttachment; - if (vertexAttachment.bones == null) { - var setupVertices = vertexAttachment.vertices; - for (var i = 0; i < vertexCount; i++) { - var prev = prevVertices[i]; - vertices[i] += - prev + (nextVertices[i] - prev) * percent - setupVertices[i]; - } - } else { - for (var i = 0; i < vertexCount; i++) { - var prev = prevVertices[i]; - vertices[i] += prev + (nextVertices[i] - prev) * percent; - } - } - } else { - for (var i = 0; i < vertexCount; i++) { - var prev = prevVertices[i]; - vertices[i] = prev + (nextVertices[i] - prev) * percent; - } - } - } else { - switch (blend) { - case MixBlend.setup: { - var vertexAttachment_2 = slotAttachment; - if (vertexAttachment_2.bones == null) { - var setupVertices = vertexAttachment_2.vertices; - for (var i = 0; i < vertexCount; i++) { - var prev = prevVertices[i], - setup = setupVertices[i]; - vertices[i] = - setup + - (prev + (nextVertices[i] - prev) * percent - setup) * alpha; - } - } else { - for (var i = 0; i < vertexCount; i++) { - var prev = prevVertices[i]; - vertices[i] = - (prev + (nextVertices[i] - prev) * percent) * alpha; - } - } - break; - } - case MixBlend.first: - case MixBlend.replace: - for (var i = 0; i < vertexCount; i++) { - var prev = prevVertices[i]; - vertices[i] += - (prev + (nextVertices[i] - prev) * percent - vertices[i]) * - alpha; - } - break; - case MixBlend.add: - var vertexAttachment = slotAttachment; - if (vertexAttachment.bones == null) { - var setupVertices = vertexAttachment.vertices; - for (var i = 0; i < vertexCount; i++) { - var prev = prevVertices[i]; - vertices[i] += - (prev + - (nextVertices[i] - prev) * percent - - setupVertices[i]) * - alpha; - } - } else { - for (var i = 0; i < vertexCount; i++) { - var prev = prevVertices[i]; - vertices[i] += - (prev + (nextVertices[i] - prev) * percent) * alpha; - } - } - } - } - }; - return DeformTimeline; - })(CurveTimeline); - core.DeformTimeline = DeformTimeline; - var EventTimeline = (function() { - function EventTimeline(frameCount) { - this.frames = core.Utils.newFloatArray(frameCount); - this.events = new Array(frameCount); - } - EventTimeline.prototype.getPropertyId = function() { - return TimelineType.event << 24; - }; - EventTimeline.prototype.getFrameCount = function() { - return this.frames.length; - }; - EventTimeline.prototype.setFrame = function(frameIndex, event) { - this.frames[frameIndex] = event.time; - this.events[frameIndex] = event; - }; - EventTimeline.prototype.apply = function( - skeleton, - lastTime, - time, - firedEvents, - alpha, - blend, - direction, - ) { - if (firedEvents == null) return; - var frames = this.frames; - var frameCount = this.frames.length; - if (lastTime > time) { - this.apply( - skeleton, - lastTime, - Number.MAX_VALUE, - firedEvents, - alpha, - blend, - direction, - ); - lastTime = -1; - } else if (lastTime >= frames[frameCount - 1]) return; - if (time < frames[0]) return; - var frame = 0; - if (lastTime < frames[0]) frame = 0; - else { - frame = Animation.binarySearch(frames, lastTime); - var frameTime = frames[frame]; - while (frame > 0) { - if (frames[frame - 1] != frameTime) break; - frame--; - } - } - for (; frame < frameCount && time >= frames[frame]; frame++) - firedEvents.push(this.events[frame]); - }; - return EventTimeline; - })(); - core.EventTimeline = EventTimeline; - var DrawOrderTimeline = (function() { - function DrawOrderTimeline(frameCount) { - this.frames = core.Utils.newFloatArray(frameCount); - this.drawOrders = new Array(frameCount); - } - DrawOrderTimeline.prototype.getPropertyId = function() { - return TimelineType.drawOrder << 24; - }; - DrawOrderTimeline.prototype.getFrameCount = function() { - return this.frames.length; - }; - DrawOrderTimeline.prototype.setFrame = function( - frameIndex, - time, - drawOrder, - ) { - this.frames[frameIndex] = time; - this.drawOrders[frameIndex] = drawOrder; - }; - DrawOrderTimeline.prototype.apply = function( - skeleton, - lastTime, - time, - firedEvents, - alpha, - blend, - direction, - ) { - var drawOrder = skeleton.drawOrder; - var slots = skeleton.slots; - if (direction == MixDirection.out && blend == MixBlend.setup) { - core.Utils.arrayCopy( - skeleton.slots, - 0, - skeleton.drawOrder, - 0, - skeleton.slots.length, - ); - return; - } - var frames = this.frames; - if (time < frames[0]) { - if (blend == MixBlend.setup || blend == MixBlend.first) - core.Utils.arrayCopy( - skeleton.slots, - 0, - skeleton.drawOrder, - 0, - skeleton.slots.length, - ); - return; - } - var frame = 0; - if (time >= frames[frames.length - 1]) frame = frames.length - 1; - else frame = Animation.binarySearch(frames, time) - 1; - var drawOrderToSetupIndex = this.drawOrders[frame]; - if (drawOrderToSetupIndex == null) - core.Utils.arrayCopy(slots, 0, drawOrder, 0, slots.length); - else { - for (var i = 0, n = drawOrderToSetupIndex.length; i < n; i++) - drawOrder[i] = slots[drawOrderToSetupIndex[i]]; - } - }; - return DrawOrderTimeline; - })(); - core.DrawOrderTimeline = DrawOrderTimeline; - var IkConstraintTimeline = (function(_super) { - __extends(IkConstraintTimeline, _super); - function IkConstraintTimeline(frameCount) { - var _this = _super.call(this, frameCount) || this; - _this.frames = core.Utils.newFloatArray( - frameCount * IkConstraintTimeline.ENTRIES, - ); - return _this; - } - IkConstraintTimeline.prototype.getPropertyId = function() { - return (TimelineType.ikConstraint << 24) + this.ikConstraintIndex; - }; - IkConstraintTimeline.prototype.setFrame = function( - frameIndex, - time, - mix, - bendDirection, - compress, - stretch, - ) { - frameIndex *= IkConstraintTimeline.ENTRIES; - this.frames[frameIndex] = time; - this.frames[frameIndex + IkConstraintTimeline.MIX] = mix; - this.frames[ - frameIndex + IkConstraintTimeline.BEND_DIRECTION - ] = bendDirection; - this.frames[frameIndex + IkConstraintTimeline.COMPRESS] = compress - ? 1 - : 0; - this.frames[frameIndex + IkConstraintTimeline.STRETCH] = stretch - ? 1 - : 0; - }; - IkConstraintTimeline.prototype.apply = function( - skeleton, - lastTime, - time, - firedEvents, - alpha, - blend, - direction, - ) { - var frames = this.frames; - var constraint = skeleton.ikConstraints[this.ikConstraintIndex]; - if (time < frames[0]) { - switch (blend) { - case MixBlend.setup: - constraint.mix = constraint.data.mix; - constraint.bendDirection = constraint.data.bendDirection; - constraint.compress = constraint.data.compress; - constraint.stretch = constraint.data.stretch; - return; - case MixBlend.first: - constraint.mix += (constraint.data.mix - constraint.mix) * alpha; - constraint.bendDirection = constraint.data.bendDirection; - constraint.compress = constraint.data.compress; - constraint.stretch = constraint.data.stretch; - } - return; - } - if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) { - if (blend == MixBlend.setup) { - constraint.mix = - constraint.data.mix + - (frames[frames.length + IkConstraintTimeline.PREV_MIX] - - constraint.data.mix) * - alpha; - if (direction == MixDirection.out) { - constraint.bendDirection = constraint.data.bendDirection; - constraint.compress = constraint.data.compress; - constraint.stretch = constraint.data.stretch; - } else { - constraint.bendDirection = - frames[ - frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION - ]; - constraint.compress = - frames[frames.length + IkConstraintTimeline.PREV_COMPRESS] != 0; - constraint.stretch = - frames[frames.length + IkConstraintTimeline.PREV_STRETCH] != 0; - } - } else { - constraint.mix += - (frames[frames.length + IkConstraintTimeline.PREV_MIX] - - constraint.mix) * - alpha; - if (direction == MixDirection.in) { - constraint.bendDirection = - frames[ - frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION - ]; - constraint.compress = - frames[frames.length + IkConstraintTimeline.PREV_COMPRESS] != 0; - constraint.stretch = - frames[frames.length + IkConstraintTimeline.PREV_STRETCH] != 0; - } - } - return; - } - var frame = Animation.binarySearch( - frames, - time, - IkConstraintTimeline.ENTRIES, - ); - var mix = frames[frame + IkConstraintTimeline.PREV_MIX]; - var frameTime = frames[frame]; - var percent = this.getCurvePercent( - frame / IkConstraintTimeline.ENTRIES - 1, - 1 - - (time - frameTime) / - (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime), - ); - if (blend == MixBlend.setup) { - constraint.mix = - constraint.data.mix + - (mix + - (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - - constraint.data.mix) * - alpha; - if (direction == MixDirection.out) { - constraint.bendDirection = constraint.data.bendDirection; - constraint.compress = constraint.data.compress; - constraint.stretch = constraint.data.stretch; - } else { - constraint.bendDirection = - frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION]; - constraint.compress = - frames[frame + IkConstraintTimeline.PREV_COMPRESS] != 0; - constraint.stretch = - frames[frame + IkConstraintTimeline.PREV_STRETCH] != 0; - } - } else { - constraint.mix += - (mix + - (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - - constraint.mix) * - alpha; - if (direction == MixDirection.in) { - constraint.bendDirection = - frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION]; - constraint.compress = - frames[frame + IkConstraintTimeline.PREV_COMPRESS] != 0; - constraint.stretch = - frames[frame + IkConstraintTimeline.PREV_STRETCH] != 0; - } - } - }; - IkConstraintTimeline.ENTRIES = 5; - IkConstraintTimeline.PREV_TIME = -5; - IkConstraintTimeline.PREV_MIX = -4; - IkConstraintTimeline.PREV_BEND_DIRECTION = -3; - IkConstraintTimeline.PREV_COMPRESS = -2; - IkConstraintTimeline.PREV_STRETCH = -1; - IkConstraintTimeline.MIX = 1; - IkConstraintTimeline.BEND_DIRECTION = 2; - IkConstraintTimeline.COMPRESS = 3; - IkConstraintTimeline.STRETCH = 4; - return IkConstraintTimeline; - })(CurveTimeline); - core.IkConstraintTimeline = IkConstraintTimeline; - var TransformConstraintTimeline = (function(_super) { - __extends(TransformConstraintTimeline, _super); - function TransformConstraintTimeline(frameCount) { - var _this = _super.call(this, frameCount) || this; - _this.frames = core.Utils.newFloatArray( - frameCount * TransformConstraintTimeline.ENTRIES, - ); - return _this; - } - TransformConstraintTimeline.prototype.getPropertyId = function() { - return ( - (TimelineType.transformConstraint << 24) + - this.transformConstraintIndex - ); - }; - TransformConstraintTimeline.prototype.setFrame = function( - frameIndex, - time, - rotateMix, - translateMix, - scaleMix, - shearMix, - ) { - frameIndex *= TransformConstraintTimeline.ENTRIES; - this.frames[frameIndex] = time; - this.frames[ - frameIndex + TransformConstraintTimeline.ROTATE - ] = rotateMix; - this.frames[ - frameIndex + TransformConstraintTimeline.TRANSLATE - ] = translateMix; - this.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix; - this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix; - }; - TransformConstraintTimeline.prototype.apply = function( - skeleton, - lastTime, - time, - firedEvents, - alpha, - blend, - direction, - ) { - var frames = this.frames; - var constraint = - skeleton.transformConstraints[this.transformConstraintIndex]; - if (time < frames[0]) { - var data = constraint.data; - switch (blend) { - case MixBlend.setup: - constraint.rotateMix = data.rotateMix; - constraint.translateMix = data.translateMix; - constraint.scaleMix = data.scaleMix; - constraint.shearMix = data.shearMix; - return; - case MixBlend.first: - constraint.rotateMix += - (data.rotateMix - constraint.rotateMix) * alpha; - constraint.translateMix += - (data.translateMix - constraint.translateMix) * alpha; - constraint.scaleMix += - (data.scaleMix - constraint.scaleMix) * alpha; - constraint.shearMix += - (data.shearMix - constraint.shearMix) * alpha; - } - return; - } - var rotate = 0, - translate = 0, - scale = 0, - shear = 0; - if ( - time >= frames[frames.length - TransformConstraintTimeline.ENTRIES] - ) { - var i = frames.length; - rotate = frames[i + TransformConstraintTimeline.PREV_ROTATE]; - translate = frames[i + TransformConstraintTimeline.PREV_TRANSLATE]; - scale = frames[i + TransformConstraintTimeline.PREV_SCALE]; - shear = frames[i + TransformConstraintTimeline.PREV_SHEAR]; - } else { - var frame = Animation.binarySearch( - frames, - time, - TransformConstraintTimeline.ENTRIES, - ); - rotate = frames[frame + TransformConstraintTimeline.PREV_ROTATE]; - translate = - frames[frame + TransformConstraintTimeline.PREV_TRANSLATE]; - scale = frames[frame + TransformConstraintTimeline.PREV_SCALE]; - shear = frames[frame + TransformConstraintTimeline.PREV_SHEAR]; - var frameTime = frames[frame]; - var percent = this.getCurvePercent( - frame / TransformConstraintTimeline.ENTRIES - 1, - 1 - - (time - frameTime) / - (frames[frame + TransformConstraintTimeline.PREV_TIME] - - frameTime), - ); - rotate += - (frames[frame + TransformConstraintTimeline.ROTATE] - rotate) * - percent; - translate += - (frames[frame + TransformConstraintTimeline.TRANSLATE] - - translate) * - percent; - scale += - (frames[frame + TransformConstraintTimeline.SCALE] - scale) * - percent; - shear += - (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * - percent; - } - if (blend == MixBlend.setup) { - var data = constraint.data; - constraint.rotateMix = - data.rotateMix + (rotate - data.rotateMix) * alpha; - constraint.translateMix = - data.translateMix + (translate - data.translateMix) * alpha; - constraint.scaleMix = data.scaleMix + (scale - data.scaleMix) * alpha; - constraint.shearMix = data.shearMix + (shear - data.shearMix) * alpha; - } else { - constraint.rotateMix += (rotate - constraint.rotateMix) * alpha; - constraint.translateMix += - (translate - constraint.translateMix) * alpha; - constraint.scaleMix += (scale - constraint.scaleMix) * alpha; - constraint.shearMix += (shear - constraint.shearMix) * alpha; - } - }; - TransformConstraintTimeline.ENTRIES = 5; - TransformConstraintTimeline.PREV_TIME = -5; - TransformConstraintTimeline.PREV_ROTATE = -4; - TransformConstraintTimeline.PREV_TRANSLATE = -3; - TransformConstraintTimeline.PREV_SCALE = -2; - TransformConstraintTimeline.PREV_SHEAR = -1; - TransformConstraintTimeline.ROTATE = 1; - TransformConstraintTimeline.TRANSLATE = 2; - TransformConstraintTimeline.SCALE = 3; - TransformConstraintTimeline.SHEAR = 4; - return TransformConstraintTimeline; - })(CurveTimeline); - core.TransformConstraintTimeline = TransformConstraintTimeline; - var PathConstraintPositionTimeline = (function(_super) { - __extends(PathConstraintPositionTimeline, _super); - function PathConstraintPositionTimeline(frameCount) { - var _this = _super.call(this, frameCount) || this; - _this.frames = core.Utils.newFloatArray( - frameCount * PathConstraintPositionTimeline.ENTRIES, - ); - return _this; - } - PathConstraintPositionTimeline.prototype.getPropertyId = function() { - return ( - (TimelineType.pathConstraintPosition << 24) + this.pathConstraintIndex - ); - }; - PathConstraintPositionTimeline.prototype.setFrame = function( - frameIndex, - time, - value, - ) { - frameIndex *= PathConstraintPositionTimeline.ENTRIES; - this.frames[frameIndex] = time; - this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value; - }; - PathConstraintPositionTimeline.prototype.apply = function( - skeleton, - lastTime, - time, - firedEvents, - alpha, - blend, - direction, - ) { - var frames = this.frames; - var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; - if (time < frames[0]) { - switch (blend) { - case MixBlend.setup: - constraint.position = constraint.data.position; - return; - case MixBlend.first: - constraint.position += - (constraint.data.position - constraint.position) * alpha; - } - return; - } - var position = 0; - if ( - time >= frames[frames.length - PathConstraintPositionTimeline.ENTRIES] - ) - position = - frames[frames.length + PathConstraintPositionTimeline.PREV_VALUE]; - else { - var frame = Animation.binarySearch( - frames, - time, - PathConstraintPositionTimeline.ENTRIES, - ); - position = frames[frame + PathConstraintPositionTimeline.PREV_VALUE]; - var frameTime = frames[frame]; - var percent = this.getCurvePercent( - frame / PathConstraintPositionTimeline.ENTRIES - 1, - 1 - - (time - frameTime) / - (frames[frame + PathConstraintPositionTimeline.PREV_TIME] - - frameTime), - ); - position += - (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * - percent; - } - if (blend == MixBlend.setup) - constraint.position = - constraint.data.position + - (position - constraint.data.position) * alpha; - else constraint.position += (position - constraint.position) * alpha; - }; - PathConstraintPositionTimeline.ENTRIES = 2; - PathConstraintPositionTimeline.PREV_TIME = -2; - PathConstraintPositionTimeline.PREV_VALUE = -1; - PathConstraintPositionTimeline.VALUE = 1; - return PathConstraintPositionTimeline; - })(CurveTimeline); - core.PathConstraintPositionTimeline = PathConstraintPositionTimeline; - var PathConstraintSpacingTimeline = (function(_super) { - __extends(PathConstraintSpacingTimeline, _super); - function PathConstraintSpacingTimeline(frameCount) { - return _super.call(this, frameCount) || this; - } - PathConstraintSpacingTimeline.prototype.getPropertyId = function() { - return ( - (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex - ); - }; - PathConstraintSpacingTimeline.prototype.apply = function( - skeleton, - lastTime, - time, - firedEvents, - alpha, - blend, - direction, - ) { - var frames = this.frames; - var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; - if (time < frames[0]) { - switch (blend) { - case MixBlend.setup: - constraint.spacing = constraint.data.spacing; - return; - case MixBlend.first: - constraint.spacing += - (constraint.data.spacing - constraint.spacing) * alpha; - } - return; - } - var spacing = 0; - if ( - time >= frames[frames.length - PathConstraintSpacingTimeline.ENTRIES] - ) - spacing = - frames[frames.length + PathConstraintSpacingTimeline.PREV_VALUE]; - else { - var frame = Animation.binarySearch( - frames, - time, - PathConstraintSpacingTimeline.ENTRIES, - ); - spacing = frames[frame + PathConstraintSpacingTimeline.PREV_VALUE]; - var frameTime = frames[frame]; - var percent = this.getCurvePercent( - frame / PathConstraintSpacingTimeline.ENTRIES - 1, - 1 - - (time - frameTime) / - (frames[frame + PathConstraintSpacingTimeline.PREV_TIME] - - frameTime), - ); - spacing += - (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * - percent; - } - if (blend == MixBlend.setup) - constraint.spacing = - constraint.data.spacing + - (spacing - constraint.data.spacing) * alpha; - else constraint.spacing += (spacing - constraint.spacing) * alpha; - }; - return PathConstraintSpacingTimeline; - })(PathConstraintPositionTimeline); - core.PathConstraintSpacingTimeline = PathConstraintSpacingTimeline; - var PathConstraintMixTimeline = (function(_super) { - __extends(PathConstraintMixTimeline, _super); - function PathConstraintMixTimeline(frameCount) { - var _this = _super.call(this, frameCount) || this; - _this.frames = core.Utils.newFloatArray( - frameCount * PathConstraintMixTimeline.ENTRIES, - ); - return _this; - } - PathConstraintMixTimeline.prototype.getPropertyId = function() { - return ( - (TimelineType.pathConstraintMix << 24) + this.pathConstraintIndex - ); - }; - PathConstraintMixTimeline.prototype.setFrame = function( - frameIndex, - time, - rotateMix, - translateMix, - ) { - frameIndex *= PathConstraintMixTimeline.ENTRIES; - this.frames[frameIndex] = time; - this.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix; - this.frames[ - frameIndex + PathConstraintMixTimeline.TRANSLATE - ] = translateMix; - }; - PathConstraintMixTimeline.prototype.apply = function( - skeleton, - lastTime, - time, - firedEvents, - alpha, - blend, - direction, - ) { - var frames = this.frames; - var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; - if (time < frames[0]) { - switch (blend) { - case MixBlend.setup: - constraint.rotateMix = constraint.data.rotateMix; - constraint.translateMix = constraint.data.translateMix; - return; - case MixBlend.first: - constraint.rotateMix += - (constraint.data.rotateMix - constraint.rotateMix) * alpha; - constraint.translateMix += - (constraint.data.translateMix - constraint.translateMix) * - alpha; - } - return; - } - var rotate = 0, - translate = 0; - if (time >= frames[frames.length - PathConstraintMixTimeline.ENTRIES]) { - rotate = - frames[frames.length + PathConstraintMixTimeline.PREV_ROTATE]; - translate = - frames[frames.length + PathConstraintMixTimeline.PREV_TRANSLATE]; - } else { - var frame = Animation.binarySearch( - frames, - time, - PathConstraintMixTimeline.ENTRIES, - ); - rotate = frames[frame + PathConstraintMixTimeline.PREV_ROTATE]; - translate = frames[frame + PathConstraintMixTimeline.PREV_TRANSLATE]; - var frameTime = frames[frame]; - var percent = this.getCurvePercent( - frame / PathConstraintMixTimeline.ENTRIES - 1, - 1 - - (time - frameTime) / - (frames[frame + PathConstraintMixTimeline.PREV_TIME] - - frameTime), - ); - rotate += - (frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * - percent; - translate += - (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * - percent; - } - if (blend == MixBlend.setup) { - constraint.rotateMix = - constraint.data.rotateMix + - (rotate - constraint.data.rotateMix) * alpha; - constraint.translateMix = - constraint.data.translateMix + - (translate - constraint.data.translateMix) * alpha; - } else { - constraint.rotateMix += (rotate - constraint.rotateMix) * alpha; - constraint.translateMix += - (translate - constraint.translateMix) * alpha; - } - }; - PathConstraintMixTimeline.ENTRIES = 3; - PathConstraintMixTimeline.PREV_TIME = -3; - PathConstraintMixTimeline.PREV_ROTATE = -2; - PathConstraintMixTimeline.PREV_TRANSLATE = -1; - PathConstraintMixTimeline.ROTATE = 1; - PathConstraintMixTimeline.TRANSLATE = 2; - return PathConstraintMixTimeline; - })(CurveTimeline); - core.PathConstraintMixTimeline = PathConstraintMixTimeline; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var AnimationState = (function() { - function AnimationState(data) { - this.tracks = new Array(); - this.events = new Array(); - this.listeners = new Array(); - this.queue = new EventQueue(this); - this.propertyIDs = new core.IntSet(); - this.animationsChanged = false; - this.timeScale = 1; - this.trackEntryPool = new core.Pool(function() { - return new TrackEntry(); - }); - this.data = data; - } - AnimationState.prototype.update = function(delta) { - delta *= this.timeScale; - var tracks = this.tracks; - for (var i = 0, n = tracks.length; i < n; i++) { - var current = tracks[i]; - if (current == null) continue; - current.animationLast = current.nextAnimationLast; - current.trackLast = current.nextTrackLast; - var currentDelta = delta * current.timeScale; - if (current.delay > 0) { - current.delay -= currentDelta; - if (current.delay > 0) continue; - currentDelta = -current.delay; - current.delay = 0; - } - var next = current.next; - if (next != null) { - var nextTime = current.trackLast - next.delay; - if (nextTime >= 0) { - next.delay = 0; - next.trackTime = - current.timeScale == 0 - ? 0 - : (nextTime / current.timeScale + delta) * next.timeScale; - current.trackTime += currentDelta; - this.setCurrent(i, next, true); - while (next.mixingFrom != null) { - next.mixTime += delta; - next = next.mixingFrom; - } - continue; - } - } else if ( - current.trackLast >= current.trackEnd && - current.mixingFrom == null - ) { - tracks[i] = null; - this.queue.end(current); - this.disposeNext(current); - continue; - } - if ( - current.mixingFrom != null && - this.updateMixingFrom(current, delta) - ) { - var from = current.mixingFrom; - current.mixingFrom = null; - if (from != null) from.mixingTo = null; - while (from != null) { - this.queue.end(from); - from = from.mixingFrom; - } - } - current.trackTime += currentDelta; - } - this.queue.drain(); - }; - AnimationState.prototype.updateMixingFrom = function(to, delta) { - var from = to.mixingFrom; - if (from == null) return true; - var finished = this.updateMixingFrom(from, delta); - from.animationLast = from.nextAnimationLast; - from.trackLast = from.nextTrackLast; - if (to.mixTime > 0 && to.mixTime >= to.mixDuration) { - if (from.totalAlpha == 0 || to.mixDuration == 0) { - to.mixingFrom = from.mixingFrom; - if (from.mixingFrom != null) from.mixingFrom.mixingTo = to; - to.interruptAlpha = from.interruptAlpha; - this.queue.end(from); - } - return finished; - } - from.trackTime += delta * from.timeScale; - to.mixTime += delta; - return false; - }; - AnimationState.prototype.apply = function(skeleton) { - if (skeleton == null) throw new Error('skeleton cannot be null.'); - if (this.animationsChanged) this._animationsChanged(); - var events = this.events; - var tracks = this.tracks; - var applied = false; - for (var i = 0, n = tracks.length; i < n; i++) { - var current = tracks[i]; - if (current == null || current.delay > 0) continue; - applied = true; - var blend = i == 0 ? core.MixBlend.first : current.mixBlend; - var mix = current.alpha; - if (current.mixingFrom != null) - mix *= this.applyMixingFrom(current, skeleton, blend); - else if ( - current.trackTime >= current.trackEnd && - current.next == null - ) - mix = 0; - var animationLast = current.animationLast, - animationTime = current.getAnimationTime(); - var timelineCount = current.animation.timelines.length; - var timelines = current.animation.timelines; - if (i == 0 && (mix == 1 || blend == core.MixBlend.add)) { - for (var ii = 0; ii < timelineCount; ii++) { - core.Utils.webkit602BugfixHelper(mix, blend); - timelines[ii].apply( - skeleton, - animationLast, - animationTime, - events, - mix, - blend, - core.MixDirection.in, - ); - } - } else { - var timelineMode = current.timelineMode; - var firstFrame = current.timelinesRotation.length == 0; - if (firstFrame) - core.Utils.setArraySize( - current.timelinesRotation, - timelineCount << 1, - null, - ); - var timelinesRotation = current.timelinesRotation; - for (var ii = 0; ii < timelineCount; ii++) { - var timeline = timelines[ii]; - var timelineBlend = - timelineMode[ii] == AnimationState.SUBSEQUENT - ? blend - : core.MixBlend.setup; - if (timeline instanceof core.RotateTimeline) { - this.applyRotateTimeline( - timeline, - skeleton, - animationTime, - mix, - timelineBlend, - timelinesRotation, - ii << 1, - firstFrame, - ); - } else { - core.Utils.webkit602BugfixHelper(mix, blend); - timeline.apply( - skeleton, - animationLast, - animationTime, - events, - mix, - timelineBlend, - core.MixDirection.in, - ); - } - } - } - this.queueEvents(current, animationTime); - events.length = 0; - current.nextAnimationLast = animationTime; - current.nextTrackLast = current.trackTime; - } - this.queue.drain(); - return applied; - }; - AnimationState.prototype.applyMixingFrom = function(to, skeleton, blend) { - var from = to.mixingFrom; - if (from.mixingFrom != null) - this.applyMixingFrom(from, skeleton, blend); - var mix = 0; - if (to.mixDuration == 0) { - mix = 1; - if (blend == core.MixBlend.first) blend = core.MixBlend.setup; - } else { - mix = to.mixTime / to.mixDuration; - if (mix > 1) mix = 1; - if (blend != core.MixBlend.first) blend = from.mixBlend; - } - var events = mix < from.eventThreshold ? this.events : null; - var attachments = mix < from.attachmentThreshold, - drawOrder = mix < from.drawOrderThreshold; - var animationLast = from.animationLast, - animationTime = from.getAnimationTime(); - var timelineCount = from.animation.timelines.length; - var timelines = from.animation.timelines; - var alphaHold = from.alpha * to.interruptAlpha, - alphaMix = alphaHold * (1 - mix); - if (blend == core.MixBlend.add) { - for (var i = 0; i < timelineCount; i++) - timelines[i].apply( - skeleton, - animationLast, - animationTime, - events, - alphaMix, - blend, - core.MixDirection.out, - ); - } else { - var timelineMode = from.timelineMode; - var timelineHoldMix = from.timelineHoldMix; - var firstFrame = from.timelinesRotation.length == 0; - if (firstFrame) - core.Utils.setArraySize( - from.timelinesRotation, - timelineCount << 1, - null, - ); - var timelinesRotation = from.timelinesRotation; - from.totalAlpha = 0; - for (var i = 0; i < timelineCount; i++) { - var timeline = timelines[i]; - var direction = core.MixDirection.out; - var timelineBlend = void 0; - var alpha = 0; - switch (timelineMode[i]) { - case AnimationState.SUBSEQUENT: - if (!attachments && timeline instanceof core.AttachmentTimeline) - continue; - if (!drawOrder && timeline instanceof core.DrawOrderTimeline) - continue; - timelineBlend = blend; - alpha = alphaMix; - break; - case AnimationState.FIRST: - timelineBlend = core.MixBlend.setup; - alpha = alphaMix; - break; - case AnimationState.HOLD: - timelineBlend = core.MixBlend.setup; - alpha = alphaHold; - break; - default: - timelineBlend = core.MixBlend.setup; - var holdMix = timelineHoldMix[i]; - alpha = - alphaHold * - Math.max(0, 1 - holdMix.mixTime / holdMix.mixDuration); - break; - } - from.totalAlpha += alpha; - if (timeline instanceof core.RotateTimeline) - this.applyRotateTimeline( - timeline, - skeleton, - animationTime, - alpha, - timelineBlend, - timelinesRotation, - i << 1, - firstFrame, - ); - else { - core.Utils.webkit602BugfixHelper(alpha, blend); - if (timelineBlend == core.MixBlend.setup) { - if (timeline instanceof core.AttachmentTimeline) { - if (attachments) direction = core.MixDirection.out; - } else if (timeline instanceof core.DrawOrderTimeline) { - if (drawOrder) direction = core.MixDirection.out; - } - } - timeline.apply( - skeleton, - animationLast, - animationTime, - events, - alpha, - timelineBlend, - direction, - ); - } - } - } - if (to.mixDuration > 0) this.queueEvents(from, animationTime); - this.events.length = 0; - from.nextAnimationLast = animationTime; - from.nextTrackLast = from.trackTime; - return mix; - }; - AnimationState.prototype.applyRotateTimeline = function( - timeline, - skeleton, - time, - alpha, - blend, - timelinesRotation, - i, - firstFrame, - ) { - if (firstFrame) timelinesRotation[i] = 0; - if (alpha == 1) { - timeline.apply( - skeleton, - 0, - time, - null, - 1, - blend, - core.MixDirection.in, - ); - return; - } - var rotateTimeline = timeline; - var frames = rotateTimeline.frames; - var bone = skeleton.bones[rotateTimeline.boneIndex]; - var r1 = 0, - r2 = 0; - if (time < frames[0]) { - switch (blend) { - case core.MixBlend.setup: - bone.rotation = bone.data.rotation; - default: - return; - case core.MixBlend.first: - r1 = bone.rotation; - r2 = bone.data.rotation; - } - } else { - r1 = - blend == core.MixBlend.setup ? bone.data.rotation : bone.rotation; - if (time >= frames[frames.length - core.RotateTimeline.ENTRIES]) - r2 = - bone.data.rotation + - frames[frames.length + core.RotateTimeline.PREV_ROTATION]; - else { - var frame = core.Animation.binarySearch( - frames, - time, - core.RotateTimeline.ENTRIES, - ); - var prevRotation = - frames[frame + core.RotateTimeline.PREV_ROTATION]; - var frameTime = frames[frame]; - var percent = rotateTimeline.getCurvePercent( - (frame >> 1) - 1, - 1 - - (time - frameTime) / - (frames[frame + core.RotateTimeline.PREV_TIME] - frameTime), - ); - r2 = frames[frame + core.RotateTimeline.ROTATION] - prevRotation; - r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360; - r2 = prevRotation + r2 * percent + bone.data.rotation; - r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360; - } - } - var total = 0, - diff = r2 - r1; - diff -= (16384 - ((16384.499999999996 - diff / 360) | 0)) * 360; - if (diff == 0) { - total = timelinesRotation[i]; - } else { - var lastTotal = 0, - lastDiff = 0; - if (firstFrame) { - lastTotal = 0; - lastDiff = diff; - } else { - lastTotal = timelinesRotation[i]; - lastDiff = timelinesRotation[i + 1]; - } - var current = diff > 0, - dir = lastTotal >= 0; - if ( - core.MathUtils.signum(lastDiff) != core.MathUtils.signum(diff) && - Math.abs(lastDiff) <= 90 - ) { - if (Math.abs(lastTotal) > 180) - lastTotal += 360 * core.MathUtils.signum(lastTotal); - dir = current; - } - total = diff + lastTotal - (lastTotal % 360); - if (dir != current) total += 360 * core.MathUtils.signum(lastTotal); - timelinesRotation[i] = total; - } - timelinesRotation[i + 1] = diff; - r1 += total * alpha; - bone.rotation = - r1 - (16384 - ((16384.499999999996 - r1 / 360) | 0)) * 360; - }; - AnimationState.prototype.queueEvents = function(entry, animationTime) { - var animationStart = entry.animationStart, - animationEnd = entry.animationEnd; - var duration = animationEnd - animationStart; - var trackLastWrapped = entry.trackLast % duration; - var events = this.events; - var i = 0, - n = events.length; - for (; i < n; i++) { - var event_1 = events[i]; - if (event_1.time < trackLastWrapped) break; - if (event_1.time > animationEnd) continue; - this.queue.event(entry, event_1); - } - var complete = false; - if (entry.loop) - complete = - duration == 0 || trackLastWrapped > entry.trackTime % duration; - else - complete = - animationTime >= animationEnd && entry.animationLast < animationEnd; - if (complete) this.queue.complete(entry); - for (; i < n; i++) { - var event_2 = events[i]; - if (event_2.time < animationStart) continue; - this.queue.event(entry, events[i]); - } - }; - AnimationState.prototype.clearTracks = function() { - var oldDrainDisabled = this.queue.drainDisabled; - this.queue.drainDisabled = true; - for (var i = 0, n = this.tracks.length; i < n; i++) this.clearTrack(i); - this.tracks.length = 0; - this.queue.drainDisabled = oldDrainDisabled; - this.queue.drain(); - }; - AnimationState.prototype.clearTrack = function(trackIndex) { - if (trackIndex >= this.tracks.length) return; - var current = this.tracks[trackIndex]; - if (current == null) return; - this.queue.end(current); - this.disposeNext(current); - var entry = current; - while (true) { - var from = entry.mixingFrom; - if (from == null) break; - this.queue.end(from); - entry.mixingFrom = null; - entry.mixingTo = null; - entry = from; - } - this.tracks[current.trackIndex] = null; - this.queue.drain(); - }; - AnimationState.prototype.setCurrent = function( - index, - current, - interrupt, - ) { - var from = this.expandToIndex(index); - this.tracks[index] = current; - if (from != null) { - if (interrupt) this.queue.interrupt(from); - current.mixingFrom = from; - from.mixingTo = current; - current.mixTime = 0; - if (from.mixingFrom != null && from.mixDuration > 0) - current.interruptAlpha *= Math.min( - 1, - from.mixTime / from.mixDuration, - ); - from.timelinesRotation.length = 0; - } - this.queue.start(current); - }; - AnimationState.prototype.setAnimation = function( - trackIndex, - animationName, - loop, - ) { - var animation = this.data.skeletonData.findAnimation(animationName); - if (animation == null) - throw new Error('Animation not found: ' + animationName); - return this.setAnimationWith(trackIndex, animation, loop); - }; - AnimationState.prototype.setAnimationWith = function( - trackIndex, - animation, - loop, - ) { - if (animation == null) throw new Error('animation cannot be null.'); - var interrupt = true; - var current = this.expandToIndex(trackIndex); - if (current != null) { - if (current.nextTrackLast == -1) { - this.tracks[trackIndex] = current.mixingFrom; - this.queue.interrupt(current); - this.queue.end(current); - this.disposeNext(current); - current = current.mixingFrom; - interrupt = false; - } else this.disposeNext(current); - } - var entry = this.trackEntry(trackIndex, animation, loop, current); - this.setCurrent(trackIndex, entry, interrupt); - this.queue.drain(); - return entry; - }; - AnimationState.prototype.addAnimation = function( - trackIndex, - animationName, - loop, - delay, - ) { - var animation = this.data.skeletonData.findAnimation(animationName); - if (animation == null) - throw new Error('Animation not found: ' + animationName); - return this.addAnimationWith(trackIndex, animation, loop, delay); - }; - AnimationState.prototype.addAnimationWith = function( - trackIndex, - animation, - loop, - delay, - ) { - if (animation == null) throw new Error('animation cannot be null.'); - var last = this.expandToIndex(trackIndex); - if (last != null) { - while (last.next != null) last = last.next; - } - var entry = this.trackEntry(trackIndex, animation, loop, last); - if (last == null) { - this.setCurrent(trackIndex, entry, true); - this.queue.drain(); - } else { - last.next = entry; - if (delay <= 0) { - var duration = last.animationEnd - last.animationStart; - if (duration != 0) { - if (last.loop) - delay += duration * (1 + ((last.trackTime / duration) | 0)); - else delay += Math.max(duration, last.trackTime); - delay -= this.data.getMix(last.animation, animation); - } else delay = last.trackTime; - } - } - entry.delay = delay; - return entry; - }; - AnimationState.prototype.setEmptyAnimation = function( - trackIndex, - mixDuration, - ) { - var entry = this.setAnimationWith( - trackIndex, - AnimationState.emptyAnimation, - false, - ); - entry.mixDuration = mixDuration; - entry.trackEnd = mixDuration; - return entry; - }; - AnimationState.prototype.addEmptyAnimation = function( - trackIndex, - mixDuration, - delay, - ) { - if (delay <= 0) delay -= mixDuration; - var entry = this.addAnimationWith( - trackIndex, - AnimationState.emptyAnimation, - false, - delay, - ); - entry.mixDuration = mixDuration; - entry.trackEnd = mixDuration; - return entry; - }; - AnimationState.prototype.setEmptyAnimations = function(mixDuration) { - var oldDrainDisabled = this.queue.drainDisabled; - this.queue.drainDisabled = true; - for (var i = 0, n = this.tracks.length; i < n; i++) { - var current = this.tracks[i]; - if (current != null) - this.setEmptyAnimation(current.trackIndex, mixDuration); - } - this.queue.drainDisabled = oldDrainDisabled; - this.queue.drain(); - }; - AnimationState.prototype.expandToIndex = function(index) { - if (index < this.tracks.length) return this.tracks[index]; - core.Utils.ensureArrayCapacity( - this.tracks, - index - this.tracks.length + 1, - null, - ); - this.tracks.length = index + 1; - return null; - }; - AnimationState.prototype.trackEntry = function( - trackIndex, - animation, - loop, - last, - ) { - var entry = this.trackEntryPool.obtain(); - entry.trackIndex = trackIndex; - entry.animation = animation; - entry.loop = loop; - entry.holdPrevious = false; - entry.eventThreshold = 0; - entry.attachmentThreshold = 0; - entry.drawOrderThreshold = 0; - entry.animationStart = 0; - entry.animationEnd = animation.duration; - entry.animationLast = -1; - entry.nextAnimationLast = -1; - entry.delay = 0; - entry.trackTime = 0; - entry.trackLast = -1; - entry.nextTrackLast = -1; - entry.trackEnd = Number.MAX_VALUE; - entry.timeScale = 1; - entry.alpha = 1; - entry.interruptAlpha = 1; - entry.mixTime = 0; - entry.mixDuration = - last == null ? 0 : this.data.getMix(last.animation, animation); - return entry; - }; - AnimationState.prototype.disposeNext = function(entry) { - var next = entry.next; - while (next != null) { - this.queue.dispose(next); - next = next.next; - } - entry.next = null; - }; - AnimationState.prototype._animationsChanged = function() { - this.animationsChanged = false; - this.propertyIDs.clear(); - for (var i = 0, n = this.tracks.length; i < n; i++) { - var entry = this.tracks[i]; - if (entry == null) continue; - while (entry.mixingFrom != null) entry = entry.mixingFrom; - do { - if (entry.mixingFrom == null || entry.mixBlend != core.MixBlend.add) - this.setTimelineModes(entry); - entry = entry.mixingTo; - } while (entry != null); - } - }; - AnimationState.prototype.setTimelineModes = function(entry) { - var to = entry.mixingTo; - var timelines = entry.animation.timelines; - var timelinesCount = entry.animation.timelines.length; - var timelineMode = core.Utils.setArraySize( - entry.timelineMode, - timelinesCount, - ); - entry.timelineHoldMix.length = 0; - var timelineDipMix = core.Utils.setArraySize( - entry.timelineHoldMix, - timelinesCount, - ); - var propertyIDs = this.propertyIDs; - if (to != null && to.holdPrevious) { - for (var i = 0; i < timelinesCount; i++) { - propertyIDs.add(timelines[i].getPropertyId()); - timelineMode[i] = AnimationState.HOLD; - } - return; - } - outer: for (var i = 0; i < timelinesCount; i++) { - var id = timelines[i].getPropertyId(); - if (!propertyIDs.add(id)) timelineMode[i] = AnimationState.SUBSEQUENT; - else if (to == null || !this.hasTimeline(to, id)) - timelineMode[i] = AnimationState.FIRST; - else { - for (var next = to.mixingTo; next != null; next = next.mixingTo) { - if (this.hasTimeline(next, id)) continue; - if (entry.mixDuration > 0) { - timelineMode[i] = AnimationState.HOLD_MIX; - timelineDipMix[i] = next; - continue outer; - } - break; - } - timelineMode[i] = AnimationState.HOLD; - } - } - }; - AnimationState.prototype.hasTimeline = function(entry, id) { - var timelines = entry.animation.timelines; - for (var i = 0, n = timelines.length; i < n; i++) - if (timelines[i].getPropertyId() == id) return true; - return false; - }; - AnimationState.prototype.getCurrent = function(trackIndex) { - if (trackIndex >= this.tracks.length) return null; - return this.tracks[trackIndex]; - }; - AnimationState.prototype.addListener = function(listener) { - if (listener == null) throw new Error('listener cannot be null.'); - this.listeners.push(listener); - }; - AnimationState.prototype.removeListener = function(listener) { - var index = this.listeners.indexOf(listener); - if (index >= 0) this.listeners.splice(index, 1); - }; - AnimationState.prototype.clearListeners = function() { - this.listeners.length = 0; - }; - AnimationState.prototype.clearListenerNotifications = function() { - this.queue.clear(); - }; - AnimationState.prototype.setAnimationByName = function( - trackIndex, - animationName, - loop, - ) { - if (!AnimationState.deprecatedWarning1) { - AnimationState.deprecatedWarning1 = true; - console.warn( - 'Spine Deprecation Warning: AnimationState.setAnimationByName is deprecated, please use setAnimation from now on.', - ); - } - this.setAnimation(trackIndex, animationName, loop); - }; - AnimationState.prototype.addAnimationByName = function( - trackIndex, - animationName, - loop, - delay, - ) { - if (!AnimationState.deprecatedWarning2) { - AnimationState.deprecatedWarning2 = true; - console.warn( - 'Spine Deprecation Warning: AnimationState.addAnimationByName is deprecated, please use addAnimation from now on.', - ); - } - this.addAnimation(trackIndex, animationName, loop, delay); - }; - AnimationState.prototype.hasAnimation = function(animationName) { - var animation = this.data.skeletonData.findAnimation(animationName); - return animation !== null; - }; - AnimationState.prototype.hasAnimationByName = function(animationName) { - if (!AnimationState.deprecatedWarning3) { - AnimationState.deprecatedWarning3 = true; - console.warn( - 'Spine Deprecation Warning: AnimationState.hasAnimationByName is deprecated, please use hasAnimation from now on.', - ); - } - return this.hasAnimation(animationName); - }; - AnimationState.emptyAnimation = new core.Animation('', [], 0); - AnimationState.SUBSEQUENT = 0; - AnimationState.FIRST = 1; - AnimationState.HOLD = 2; - AnimationState.HOLD_MIX = 3; - AnimationState.deprecatedWarning1 = false; - AnimationState.deprecatedWarning2 = false; - AnimationState.deprecatedWarning3 = false; - return AnimationState; - })(); - core.AnimationState = AnimationState; - var TrackEntry = (function() { - function TrackEntry() { - this.mixBlend = core.MixBlend.replace; - this.timelineMode = new Array(); - this.timelineHoldMix = new Array(); - this.timelinesRotation = new Array(); - } - TrackEntry.prototype.reset = function() { - this.next = null; - this.mixingFrom = null; - this.mixingTo = null; - this.animation = null; - this.listener = null; - this.timelineMode.length = 0; - this.timelineHoldMix.length = 0; - this.timelinesRotation.length = 0; - }; - TrackEntry.prototype.getAnimationTime = function() { - if (this.loop) { - var duration = this.animationEnd - this.animationStart; - if (duration == 0) return this.animationStart; - return (this.trackTime % duration) + this.animationStart; - } - return Math.min( - this.trackTime + this.animationStart, - this.animationEnd, - ); - }; - TrackEntry.prototype.setAnimationLast = function(animationLast) { - this.animationLast = animationLast; - this.nextAnimationLast = animationLast; - }; - TrackEntry.prototype.isComplete = function() { - return this.trackTime >= this.animationEnd - this.animationStart; - }; - TrackEntry.prototype.resetRotationDirections = function() { - this.timelinesRotation.length = 0; - }; - Object.defineProperty(TrackEntry.prototype, 'time', { - get: function() { - if (!TrackEntry.deprecatedWarning1) { - TrackEntry.deprecatedWarning1 = true; - console.warn( - 'Spine Deprecation Warning: TrackEntry.time is deprecated, please use trackTime from now on.', - ); - } - return this.trackTime; - }, - set: function(value) { - if (!TrackEntry.deprecatedWarning1) { - TrackEntry.deprecatedWarning1 = true; - console.warn( - 'Spine Deprecation Warning: TrackEntry.time is deprecated, please use trackTime from now on.', - ); - } - this.trackTime = value; - }, - enumerable: true, - configurable: true, - }); - Object.defineProperty(TrackEntry.prototype, 'endTime', { - get: function() { - if (!TrackEntry.deprecatedWarning2) { - TrackEntry.deprecatedWarning2 = true; - console.warn( - 'Spine Deprecation Warning: TrackEntry.endTime is deprecated, please use trackEnd from now on.', - ); - } - return this.trackTime; - }, - set: function(value) { - if (!TrackEntry.deprecatedWarning2) { - TrackEntry.deprecatedWarning2 = true; - console.warn( - 'Spine Deprecation Warning: TrackEntry.endTime is deprecated, please use trackEnd from now on.', - ); - } - this.trackTime = value; - }, - enumerable: true, - configurable: true, - }); - TrackEntry.prototype.loopsCount = function() { - return Math.floor(this.trackTime / this.trackEnd); - }; - TrackEntry.deprecatedWarning1 = false; - TrackEntry.deprecatedWarning2 = false; - return TrackEntry; - })(); - core.TrackEntry = TrackEntry; - var EventQueue = (function() { - function EventQueue(animState) { - this.objects = []; - this.drainDisabled = false; - this.animState = animState; - } - EventQueue.prototype.start = function(entry) { - this.objects.push(EventType.start); - this.objects.push(entry); - this.animState.animationsChanged = true; - }; - EventQueue.prototype.interrupt = function(entry) { - this.objects.push(EventType.interrupt); - this.objects.push(entry); - }; - EventQueue.prototype.end = function(entry) { - this.objects.push(EventType.end); - this.objects.push(entry); - this.animState.animationsChanged = true; - }; - EventQueue.prototype.dispose = function(entry) { - this.objects.push(EventType.dispose); - this.objects.push(entry); - }; - EventQueue.prototype.complete = function(entry) { - this.objects.push(EventType.complete); - this.objects.push(entry); - }; - EventQueue.prototype.event = function(entry, event) { - this.objects.push(EventType.event); - this.objects.push(entry); - this.objects.push(event); - }; - EventQueue.prototype.deprecateStuff = function() { - if (!EventQueue.deprecatedWarning1) { - EventQueue.deprecatedWarning1 = true; - console.warn( - "Spine Deprecation Warning: onComplete, onStart, onEnd, onEvent art deprecated, please use listeners from now on. 'state.addListener({ complete: function(track, event) { } })'", - ); - } - return true; - }; - EventQueue.prototype.drain = function() { - if (this.drainDisabled) return; - this.drainDisabled = true; - var objects = this.objects; - var listeners = this.animState.listeners; - for (var i = 0; i < objects.length; i += 2) { - var type = objects[i]; - var entry = objects[i + 1]; - switch (type) { - case EventType.start: - if (entry.listener != null && entry.listener.start) - entry.listener.start(entry); - for (var ii = 0; ii < listeners.length; ii++) - if (listeners[ii].start) listeners[ii].start(entry); - entry.onStart && - this.deprecateStuff() && - entry.onStart(entry.trackIndex); - this.animState.onStart && - this.deprecateStuff() && - this.deprecateStuff && - this.animState.onStart(entry.trackIndex); - break; - case EventType.interrupt: - if (entry.listener != null && entry.listener.interrupt) - entry.listener.interrupt(entry); - for (var ii = 0; ii < listeners.length; ii++) - if (listeners[ii].interrupt) listeners[ii].interrupt(entry); - break; - case EventType.end: - if (entry.listener != null && entry.listener.end) - entry.listener.end(entry); - for (var ii = 0; ii < listeners.length; ii++) - if (listeners[ii].end) listeners[ii].end(entry); - entry.onEnd && - this.deprecateStuff() && - entry.onEnd(entry.trackIndex); - this.animState.onEnd && - this.deprecateStuff() && - this.animState.onEnd(entry.trackIndex); - case EventType.dispose: - if (entry.listener != null && entry.listener.dispose) - entry.listener.dispose(entry); - for (var ii = 0; ii < listeners.length; ii++) - if (listeners[ii].dispose) listeners[ii].dispose(entry); - this.animState.trackEntryPool.free(entry); - break; - case EventType.complete: - if (entry.listener != null && entry.listener.complete) - entry.listener.complete(entry); - for (var ii = 0; ii < listeners.length; ii++) - if (listeners[ii].complete) listeners[ii].complete(entry); - var count = core.MathUtils.toInt(entry.loopsCount()); - entry.onComplete && - this.deprecateStuff() && - entry.onComplete(entry.trackIndex, count); - this.animState.onComplete && - this.deprecateStuff() && - this.animState.onComplete(entry.trackIndex, count); - break; - case EventType.event: - var event_3 = objects[i++ + 2]; - if (entry.listener != null && entry.listener.event) - entry.listener.event(entry, event_3); - for (var ii = 0; ii < listeners.length; ii++) - if (listeners[ii].event) listeners[ii].event(entry, event_3); - entry.onEvent && - this.deprecateStuff() && - entry.onEvent(entry.trackIndex, event_3); - this.animState.onEvent && - this.deprecateStuff() && - this.animState.onEvent(entry.trackIndex, event_3); - break; - } - } - this.clear(); - this.drainDisabled = false; - }; - EventQueue.prototype.clear = function() { - this.objects.length = 0; - }; - EventQueue.deprecatedWarning1 = false; - return EventQueue; - })(); - core.EventQueue = EventQueue; - var EventType; - (function(EventType) { - EventType[(EventType['start'] = 0)] = 'start'; - EventType[(EventType['interrupt'] = 1)] = 'interrupt'; - EventType[(EventType['end'] = 2)] = 'end'; - EventType[(EventType['dispose'] = 3)] = 'dispose'; - EventType[(EventType['complete'] = 4)] = 'complete'; - EventType[(EventType['event'] = 5)] = 'event'; - })((EventType = core.EventType || (core.EventType = {}))); - var AnimationStateAdapter2 = (function() { - function AnimationStateAdapter2() {} - AnimationStateAdapter2.prototype.start = function(entry) {}; - AnimationStateAdapter2.prototype.interrupt = function(entry) {}; - AnimationStateAdapter2.prototype.end = function(entry) {}; - AnimationStateAdapter2.prototype.dispose = function(entry) {}; - AnimationStateAdapter2.prototype.complete = function(entry) {}; - AnimationStateAdapter2.prototype.event = function(entry, event) {}; - return AnimationStateAdapter2; - })(); - core.AnimationStateAdapter2 = AnimationStateAdapter2; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var AnimationStateData = (function() { - function AnimationStateData(skeletonData) { - this.animationToMixTime = {}; - this.defaultMix = 0; - if (skeletonData == null) - throw new Error('skeletonData cannot be null.'); - this.skeletonData = skeletonData; - } - AnimationStateData.prototype.setMix = function( - fromName, - toName, - duration, - ) { - var from = this.skeletonData.findAnimation(fromName); - if (from == null) throw new Error('Animation not found: ' + fromName); - var to = this.skeletonData.findAnimation(toName); - if (to == null) throw new Error('Animation not found: ' + toName); - this.setMixWith(from, to, duration); - }; - AnimationStateData.prototype.setMixByName = function( - fromName, - toName, - duration, - ) { - if (!AnimationStateData.deprecatedWarning1) { - AnimationStateData.deprecatedWarning1 = true; - console.warn( - 'Deprecation Warning: AnimationStateData.setMixByName is deprecated, please use setMix from now on.', - ); - } - this.setMix(fromName, toName, duration); - }; - AnimationStateData.prototype.setMixWith = function(from, to, duration) { - if (from == null) throw new Error('from cannot be null.'); - if (to == null) throw new Error('to cannot be null.'); - var key = from.name + '.' + to.name; - this.animationToMixTime[key] = duration; - }; - AnimationStateData.prototype.getMix = function(from, to) { - var key = from.name + '.' + to.name; - var value = this.animationToMixTime[key]; - return value === undefined ? this.defaultMix : value; - }; - AnimationStateData.deprecatedWarning1 = false; - return AnimationStateData; - })(); - core.AnimationStateData = AnimationStateData; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var AtlasAttachmentLoader = (function() { - function AtlasAttachmentLoader(atlas) { - this.atlas = atlas; - } - AtlasAttachmentLoader.prototype.newRegionAttachment = function( - skin, - name, - path, - ) { - var region = this.atlas.findRegion(path); - if (region == null) - throw new Error( - 'Region not found in atlas: ' + - path + - ' (region attachment: ' + - name + - ')', - ); - var attachment = new core.RegionAttachment(name); - attachment.region = region; - return attachment; - }; - AtlasAttachmentLoader.prototype.newMeshAttachment = function( - skin, - name, - path, - ) { - var region = this.atlas.findRegion(path); - if (region == null) - throw new Error( - 'Region not found in atlas: ' + - path + - ' (mesh attachment: ' + - name + - ')', - ); - var attachment = new core.MeshAttachment(name); - attachment.region = region; - return attachment; - }; - AtlasAttachmentLoader.prototype.newBoundingBoxAttachment = function( - skin, - name, - ) { - return new core.BoundingBoxAttachment(name); - }; - AtlasAttachmentLoader.prototype.newPathAttachment = function(skin, name) { - return new core.PathAttachment(name); - }; - AtlasAttachmentLoader.prototype.newPointAttachment = function( - skin, - name, - ) { - return new core.PointAttachment(name); - }; - AtlasAttachmentLoader.prototype.newClippingAttachment = function( - skin, - name, - ) { - return new core.ClippingAttachment(name); - }; - return AtlasAttachmentLoader; - })(); - core.AtlasAttachmentLoader = AtlasAttachmentLoader; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var BlendMode; - (function(BlendMode) { - BlendMode[(BlendMode['Normal'] = 0)] = 'Normal'; - BlendMode[(BlendMode['Additive'] = 1)] = 'Additive'; - BlendMode[(BlendMode['Multiply'] = 2)] = 'Multiply'; - BlendMode[(BlendMode['Screen'] = 3)] = 'Screen'; - })((BlendMode = core.BlendMode || (core.BlendMode = {}))); - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var Bone = (function() { - function Bone(data, skeleton, parent) { - this.matrix = new PIXI.Matrix(); - this.children = new Array(); - this.x = 0; - this.y = 0; - this.rotation = 0; - this.scaleX = 0; - this.scaleY = 0; - this.shearX = 0; - this.shearY = 0; - this.ax = 0; - this.ay = 0; - this.arotation = 0; - this.ascaleX = 0; - this.ascaleY = 0; - this.ashearX = 0; - this.ashearY = 0; - this.appliedValid = false; - this.sorted = false; - if (data == null) throw new Error('data cannot be null.'); - if (skeleton == null) throw new Error('skeleton cannot be null.'); - this.data = data; - this.skeleton = skeleton; - this.parent = parent; - this.setToSetupPose(); - } - Object.defineProperty(Bone.prototype, 'worldX', { - get: function() { - return this.matrix.tx; - }, - enumerable: true, - configurable: true, - }); - Object.defineProperty(Bone.prototype, 'worldY', { - get: function() { - return this.matrix.ty; - }, - enumerable: true, - configurable: true, - }); - Bone.prototype.update = function() { - this.updateWorldTransformWith( - this.x, - this.y, - this.rotation, - this.scaleX, - this.scaleY, - this.shearX, - this.shearY, - ); - }; - Bone.prototype.updateWorldTransform = function() { - this.updateWorldTransformWith( - this.x, - this.y, - this.rotation, - this.scaleX, - this.scaleY, - this.shearX, - this.shearY, - ); - }; - Bone.prototype.updateWorldTransformWith = function( - x, - y, - rotation, - scaleX, - scaleY, - shearX, - shearY, - ) { - this.ax = x; - this.ay = y; - this.arotation = rotation; - this.ascaleX = scaleX; - this.ascaleY = scaleY; - this.ashearX = shearX; - this.ashearY = shearY; - this.appliedValid = true; - var parent = this.parent; - var m = this.matrix; - var sx = this.skeleton.scaleX; - var sy = Bone.yDown ? -this.skeleton.scaleY : this.skeleton.scaleY; - if (parent == null) { - if (Bone.yDown) { - rotation = -rotation; - this.arotation = rotation; - } - var skeleton = this.skeleton; - var rotationY = rotation + 90 + shearY; - m.a = core.MathUtils.cosDeg(rotation + shearX) * scaleX * sx; - m.c = core.MathUtils.cosDeg(rotationY) * scaleY * sy; - m.b = core.MathUtils.sinDeg(rotation + shearX) * scaleX * sx; - m.d = core.MathUtils.sinDeg(rotationY) * scaleY * sy; - m.tx = x * sx + skeleton.x; - m.ty = y * sy + skeleton.y; - return; - } - var pa = parent.matrix.a, - pb = parent.matrix.c, - pc = parent.matrix.b, - pd = parent.matrix.d; - m.tx = pa * x + pb * y + parent.matrix.tx; - m.ty = pc * x + pd * y + parent.matrix.ty; - switch (this.data.transformMode) { - case core.TransformMode.Normal: { - var rotationY = rotation + 90 + shearY; - var la = core.MathUtils.cosDeg(rotation + shearX) * scaleX; - var lb = core.MathUtils.cosDeg(rotationY) * scaleY; - var lc = core.MathUtils.sinDeg(rotation + shearX) * scaleX; - var ld = core.MathUtils.sinDeg(rotationY) * scaleY; - m.a = pa * la + pb * lc; - m.c = pa * lb + pb * ld; - m.b = pc * la + pd * lc; - m.d = pc * lb + pd * ld; - return; - } - case core.TransformMode.OnlyTranslation: { - var rotationY = rotation + 90 + shearY; - m.a = core.MathUtils.cosDeg(rotation + shearX) * scaleX; - m.c = core.MathUtils.cosDeg(rotationY) * scaleY; - m.b = core.MathUtils.sinDeg(rotation + shearX) * scaleX; - m.d = core.MathUtils.sinDeg(rotationY) * scaleY; - break; - } - case core.TransformMode.NoRotationOrReflection: { - var s = pa * pa + pc * pc; - var prx = 0; - if (s > 0.0001) { - s = Math.abs(pa * pd - pb * pc) / s; - pb = pc * s; - pd = pa * s; - prx = Math.atan2(pc, pa) * core.MathUtils.radDeg; - } else { - pa = 0; - pc = 0; - prx = 90 - Math.atan2(pd, pb) * core.MathUtils.radDeg; - } - var rx = rotation + shearX - prx; - var ry = rotation + shearY - prx + 90; - var la = core.MathUtils.cosDeg(rx) * scaleX; - var lb = core.MathUtils.cosDeg(ry) * scaleY; - var lc = core.MathUtils.sinDeg(rx) * scaleX; - var ld = core.MathUtils.sinDeg(ry) * scaleY; - m.a = pa * la - pb * lc; - m.c = pa * lb - pb * ld; - m.b = pc * la + pd * lc; - m.d = pc * lb + pd * ld; - break; - } - case core.TransformMode.NoScale: - case core.TransformMode.NoScaleOrReflection: { - var cos = core.MathUtils.cosDeg(rotation); - var sin = core.MathUtils.sinDeg(rotation); - var za = (pa * cos + pb * sin) / sx; - var zc = (pc * cos + pd * sin) / sy; - var s = Math.sqrt(za * za + zc * zc); - if (s > 0.00001) s = 1 / s; - za *= s; - zc *= s; - s = Math.sqrt(za * za + zc * zc); - if ( - this.data.transformMode == core.TransformMode.NoScale && - pa * pd - pb * pc < 0 != - (Bone.yDown - ? this.skeleton.scaleX < 0 != this.skeleton.scaleY > 0 - : this.skeleton.scaleX < 0 != this.skeleton.scaleY < 0) - ) - s = -s; - var r = Math.PI / 2 + Math.atan2(zc, za); - var zb = Math.cos(r) * s; - var zd = Math.sin(r) * s; - var la = core.MathUtils.cosDeg(shearX) * scaleX; - var lb = core.MathUtils.cosDeg(90 + shearY) * scaleY; - var lc = core.MathUtils.sinDeg(shearX) * scaleX; - var ld = core.MathUtils.sinDeg(90 + shearY) * scaleY; - m.a = za * la + zb * lc; - m.c = za * lb + zb * ld; - m.b = zc * la + zd * lc; - m.d = zc * lb + zd * ld; - break; - } - } - m.a *= sx; - m.c *= sx; - m.b *= sy; - m.d *= sy; - }; - Bone.prototype.setToSetupPose = function() { - var data = this.data; - this.x = data.x; - this.y = data.y; - this.rotation = data.rotation; - this.scaleX = data.scaleX; - this.scaleY = data.scaleY; - this.shearX = data.shearX; - this.shearY = data.shearY; - }; - Bone.prototype.getWorldRotationX = function() { - return Math.atan2(this.matrix.b, this.matrix.a) * core.MathUtils.radDeg; - }; - Bone.prototype.getWorldRotationY = function() { - return Math.atan2(this.matrix.d, this.matrix.c) * core.MathUtils.radDeg; - }; - Bone.prototype.getWorldScaleX = function() { - var m = this.matrix; - return Math.sqrt(m.a * m.a + m.c * m.c); - }; - Bone.prototype.getWorldScaleY = function() { - var m = this.matrix; - return Math.sqrt(m.b * m.b + m.d * m.d); - }; - Bone.prototype.updateAppliedTransform = function() { - this.appliedValid = true; - var parent = this.parent; - var m = this.matrix; - if (parent == null) { - this.ax = m.tx; - this.ay = m.ty; - this.arotation = Math.atan2(m.b, m.a) * core.MathUtils.radDeg; - this.ascaleX = Math.sqrt(m.a * m.a + m.b * m.b); - this.ascaleY = Math.sqrt(m.c * m.c + m.d * m.d); - this.ashearX = 0; - this.ashearY = - Math.atan2(m.a * m.c + m.b * m.d, m.a * m.d - m.b * m.c) * - core.MathUtils.radDeg; - return; - } - var pm = parent.matrix; - var pid = 1 / (pm.a * pm.d - pm.b * pm.c); - var dx = m.tx - pm.tx, - dy = m.ty - pm.ty; - this.ax = dx * pm.d * pid - dy * pm.c * pid; - this.ay = dy * pm.a * pid - dx * pm.b * pid; - var ia = pid * pm.d; - var id = pid * pm.a; - var ib = pid * pm.c; - var ic = pid * pm.b; - var ra = ia * m.a - ib * m.b; - var rb = ia * m.c - ib * m.d; - var rc = id * m.b - ic * m.a; - var rd = id * m.d - ic * m.c; - this.ashearX = 0; - this.ascaleX = Math.sqrt(ra * ra + rc * rc); - if (this.ascaleX > 0.0001) { - var det = ra * rd - rb * rc; - this.ascaleY = det / this.ascaleX; - this.ashearY = - Math.atan2(ra * rb + rc * rd, det) * core.MathUtils.radDeg; - this.arotation = Math.atan2(rc, ra) * core.MathUtils.radDeg; - } else { - this.ascaleX = 0; - this.ascaleY = Math.sqrt(rb * rb + rd * rd); - this.ashearY = 0; - this.arotation = 90 - Math.atan2(rd, rb) * core.MathUtils.radDeg; - } - }; - Bone.prototype.worldToLocal = function(world) { - var m = this.matrix; - var a = m.a, - b = m.c, - c = m.b, - d = m.d; - var invDet = 1 / (a * d - b * c); - var x = world.x - m.tx, - y = world.y - m.ty; - world.x = x * d * invDet - y * b * invDet; - world.y = y * a * invDet - x * c * invDet; - return world; - }; - Bone.prototype.localToWorld = function(local) { - var m = this.matrix; - var x = local.x, - y = local.y; - local.x = x * m.a + y * m.c + m.tx; - local.y = x * m.b + y * m.d + m.ty; - return local; - }; - Bone.prototype.worldToLocalRotation = function(worldRotation) { - var sin = core.MathUtils.sinDeg(worldRotation), - cos = core.MathUtils.cosDeg(worldRotation); - var mat = this.matrix; - return ( - Math.atan2(mat.a * sin - mat.b * cos, mat.d * cos - mat.c * sin) * - core.MathUtils.radDeg - ); - }; - Bone.prototype.localToWorldRotation = function(localRotation) { - var sin = core.MathUtils.sinDeg(localRotation), - cos = core.MathUtils.cosDeg(localRotation); - var mat = this.matrix; - return ( - Math.atan2(cos * mat.b + sin * mat.d, cos * mat.a + sin * mat.c) * - core.MathUtils.radDeg - ); - }; - Bone.prototype.rotateWorld = function(degrees) { - var mat = this.matrix; - var a = mat.a, - b = mat.c, - c = mat.b, - d = mat.d; - var cos = core.MathUtils.cosDeg(degrees), - sin = core.MathUtils.sinDeg(degrees); - mat.a = cos * a - sin * c; - mat.c = cos * b - sin * d; - mat.b = sin * a + cos * c; - mat.d = sin * b + cos * d; - this.appliedValid = false; - }; - Bone.yDown = false; - return Bone; - })(); - core.Bone = Bone; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var BoneData = (function() { - function BoneData(index, name, parent) { - this.x = 0; - this.y = 0; - this.rotation = 0; - this.scaleX = 1; - this.scaleY = 1; - this.shearX = 0; - this.shearY = 0; - this.transformMode = TransformMode.Normal; - if (index < 0) throw new Error('index must be >= 0.'); - if (name == null) throw new Error('name cannot be null.'); - this.index = index; - this.name = name; - this.parent = parent; - } - return BoneData; - })(); - core.BoneData = BoneData; - var TransformMode; - (function(TransformMode) { - TransformMode[(TransformMode['Normal'] = 0)] = 'Normal'; - TransformMode[(TransformMode['OnlyTranslation'] = 1)] = 'OnlyTranslation'; - TransformMode[(TransformMode['NoRotationOrReflection'] = 2)] = - 'NoRotationOrReflection'; - TransformMode[(TransformMode['NoScale'] = 3)] = 'NoScale'; - TransformMode[(TransformMode['NoScaleOrReflection'] = 4)] = - 'NoScaleOrReflection'; - })((TransformMode = core.TransformMode || (core.TransformMode = {}))); - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var Event = (function() { - function Event(time, data) { - if (data == null) throw new Error('data cannot be null.'); - this.time = time; - this.data = data; - } - return Event; - })(); - core.Event = Event; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var EventData = (function() { - function EventData(name) { - this.name = name; - } - return EventData; - })(); - core.EventData = EventData; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var IkConstraint = (function() { - function IkConstraint(data, skeleton) { - this.bendDirection = 0; - this.compress = false; - this.stretch = false; - this.mix = 1; - if (data == null) throw new Error('data cannot be null.'); - if (skeleton == null) throw new Error('skeleton cannot be null.'); - this.data = data; - this.mix = data.mix; - this.bendDirection = data.bendDirection; - this.compress = data.compress; - this.stretch = data.stretch; - this.bones = new Array(); - for (var i = 0; i < data.bones.length; i++) - this.bones.push(skeleton.findBone(data.bones[i].name)); - this.target = skeleton.findBone(data.target.name); - } - IkConstraint.prototype.getOrder = function() { - return this.data.order; - }; - IkConstraint.prototype.apply = function() { - this.update(); - }; - IkConstraint.prototype.update = function() { - var target = this.target; - var bones = this.bones; - switch (bones.length) { - case 1: - this.apply1( - bones[0], - target.worldX, - target.worldY, - this.compress, - this.stretch, - this.data.uniform, - this.mix, - ); - break; - case 2: - this.apply2( - bones[0], - bones[1], - target.worldX, - target.worldY, - this.bendDirection, - this.stretch, - this.mix, - ); - break; - } - }; - IkConstraint.prototype.apply1 = function( - bone, - targetX, - targetY, - compress, - stretch, - uniform, - alpha, - ) { - if (!bone.appliedValid) bone.updateAppliedTransform(); - var p = bone.parent.matrix; - var id = 1 / (p.a * p.d - p.b * p.c); - var x = targetX - p.tx, - y = targetY - p.ty; - var tx = (x * p.d - y * p.c) * id - bone.ax, - ty = (y * p.a - x * p.b) * id - bone.ay; - var rotationIK = - Math.atan2(ty, tx) * core.MathUtils.radDeg - - bone.ashearX - - bone.arotation; - if (bone.ascaleX < 0) rotationIK += 180; - if (rotationIK > 180) rotationIK -= 360; - else if (rotationIK < -180) rotationIK += 360; - var sx = bone.ascaleX, - sy = bone.ascaleY; - if (compress || stretch) { - var b = bone.data.length * sx, - dd = Math.sqrt(tx * tx + ty * ty); - if ((compress && dd < b) || (stretch && dd > b && b > 0.0001)) { - var s = (dd / b - 1) * alpha + 1; - sx *= s; - if (uniform) sy *= s; - } - } - bone.updateWorldTransformWith( - bone.ax, - bone.ay, - bone.arotation + rotationIK * alpha, - sx, - sy, - bone.ashearX, - bone.ashearY, - ); - }; - IkConstraint.prototype.apply2 = function( - parent, - child, - targetX, - targetY, - bendDir, - stretch, - alpha, - ) { - if (alpha == 0) { - child.updateWorldTransform(); - return; - } - if (!parent.appliedValid) parent.updateAppliedTransform(); - if (!child.appliedValid) child.updateAppliedTransform(); - var px = parent.ax, - py = parent.ay, - psx = parent.ascaleX, - sx = psx, - psy = parent.ascaleY, - csx = child.ascaleX; - var pmat = parent.matrix; - var os1 = 0, - os2 = 0, - s2 = 0; - if (psx < 0) { - psx = -psx; - os1 = 180; - s2 = -1; - } else { - os1 = 0; - s2 = 1; - } - if (psy < 0) { - psy = -psy; - s2 = -s2; - } - if (csx < 0) { - csx = -csx; - os2 = 180; - } else os2 = 0; - var cx = child.ax, - cy = 0, - cwx = 0, - cwy = 0, - a = pmat.a, - b = pmat.c, - c = pmat.b, - d = pmat.d; - var u = Math.abs(psx - psy) <= 0.0001; - if (!u) { - cy = 0; - cwx = a * cx + pmat.tx; - cwy = c * cx + pmat.ty; - } else { - cy = child.ay; - cwx = a * cx + b * cy + pmat.tx; - cwy = c * cx + d * cy + pmat.ty; - } - var pp = parent.parent.matrix; - a = pp.a; - b = pp.c; - c = pp.b; - d = pp.d; - var id = 1 / (a * d - b * c), - x = targetX - pp.tx, - y = targetY - pp.ty; - var tx = (x * d - y * b) * id - px, - ty = (y * a - x * c) * id - py, - dd = tx * tx + ty * ty; - x = cwx - pp.tx; - y = cwy - pp.ty; - var dx = (x * d - y * b) * id - px, - dy = (y * a - x * c) * id - py; - var l1 = Math.sqrt(dx * dx + dy * dy), - l2 = child.data.length * csx, - a1 = 0, - a2 = 0; - outer: if (u) { - l2 *= psx; - var cos = (dd - l1 * l1 - l2 * l2) / (2 * l1 * l2); - if (cos < -1) cos = -1; - else if (cos > 1) { - cos = 1; - if (stretch && l1 + l2 > 0.0001) - sx *= (Math.sqrt(dd) / (l1 + l2) - 1) * alpha + 1; - } - a2 = Math.acos(cos) * bendDir; - a = l1 + l2 * cos; - b = l2 * Math.sin(a2); - a1 = Math.atan2(ty * a - tx * b, tx * a + ty * b); - } else { - a = psx * l2; - b = psy * l2; - var aa = a * a, - bb = b * b, - ta = Math.atan2(ty, tx); - c = bb * l1 * l1 + aa * dd - aa * bb; - var c1 = -2 * bb * l1, - c2 = bb - aa; - d = c1 * c1 - 4 * c2 * c; - if (d >= 0) { - var q = Math.sqrt(d); - if (c1 < 0) q = -q; - q = -(c1 + q) / 2; - var r0 = q / c2, - r1 = c / q; - var r = Math.abs(r0) < Math.abs(r1) ? r0 : r1; - if (r * r <= dd) { - y = Math.sqrt(dd - r * r) * bendDir; - a1 = ta - Math.atan2(y, r); - a2 = Math.atan2(y / psy, (r - l1) / psx); - break outer; - } - } - var minAngle = core.MathUtils.PI, - minX = l1 - a, - minDist = minX * minX, - minY = 0; - var maxAngle = 0, - maxX = l1 + a, - maxDist = maxX * maxX, - maxY = 0; - c = (-a * l1) / (aa - bb); - if (c >= -1 && c <= 1) { - c = Math.acos(c); - x = a * Math.cos(c) + l1; - y = b * Math.sin(c); - d = x * x + y * y; - if (d < minDist) { - minAngle = c; - minDist = d; - minX = x; - minY = y; - } - if (d > maxDist) { - maxAngle = c; - maxDist = d; - maxX = x; - maxY = y; - } - } - if (dd <= (minDist + maxDist) / 2) { - a1 = ta - Math.atan2(minY * bendDir, minX); - a2 = minAngle * bendDir; - } else { - a1 = ta - Math.atan2(maxY * bendDir, maxX); - a2 = maxAngle * bendDir; - } - } - var os = Math.atan2(cy, cx) * s2; - var rotation = parent.arotation; - a1 = (a1 - os) * core.MathUtils.radDeg + os1 - rotation; - if (a1 > 180) a1 -= 360; - else if (a1 < -180) a1 += 360; - parent.updateWorldTransformWith( - px, - py, - rotation + a1 * alpha, - sx, - parent.ascaleY, - 0, - 0, - ); - rotation = child.arotation; - a2 = - ((a2 + os) * core.MathUtils.radDeg - child.ashearX) * s2 + - os2 - - rotation; - if (a2 > 180) a2 -= 360; - else if (a2 < -180) a2 += 360; - child.updateWorldTransformWith( - cx, - cy, - rotation + a2 * alpha, - child.ascaleX, - child.ascaleY, - child.ashearX, - child.ashearY, - ); - }; - return IkConstraint; - })(); - core.IkConstraint = IkConstraint; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var IkConstraintData = (function() { - function IkConstraintData(name) { - this.order = 0; - this.bones = new Array(); - this.bendDirection = 1; - this.compress = false; - this.stretch = false; - this.uniform = false; - this.mix = 1; - this.name = name; - } - return IkConstraintData; - })(); - core.IkConstraintData = IkConstraintData; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var PathConstraint = (function() { - function PathConstraint(data, skeleton) { - this.position = 0; - this.spacing = 0; - this.rotateMix = 0; - this.translateMix = 0; - this.spaces = new Array(); - this.positions = new Array(); - this.world = new Array(); - this.curves = new Array(); - this.lengths = new Array(); - this.segments = new Array(); - if (data == null) throw new Error('data cannot be null.'); - if (skeleton == null) throw new Error('skeleton cannot be null.'); - this.data = data; - this.bones = new Array(); - for (var i = 0, n = data.bones.length; i < n; i++) - this.bones.push(skeleton.findBone(data.bones[i].name)); - this.target = skeleton.findSlot(data.target.name); - this.position = data.position; - this.spacing = data.spacing; - this.rotateMix = data.rotateMix; - this.translateMix = data.translateMix; - } - PathConstraint.prototype.apply = function() { - this.update(); - }; - PathConstraint.prototype.update = function() { - var attachment = this.target.getAttachment(); - if (!(attachment instanceof core.PathAttachment)) return; - var rotateMix = this.rotateMix, - translateMix = this.translateMix; - var translate = translateMix > 0, - rotate = rotateMix > 0; - if (!translate && !rotate) return; - var data = this.data; - var spacingMode = data.spacingMode; - var lengthSpacing = spacingMode == core.SpacingMode.Length; - var rotateMode = data.rotateMode; - var tangents = rotateMode == core.RotateMode.Tangent, - scale = rotateMode == core.RotateMode.ChainScale; - var boneCount = this.bones.length, - spacesCount = tangents ? boneCount : boneCount + 1; - var bones = this.bones; - var spaces = core.Utils.setArraySize(this.spaces, spacesCount), - lengths = null; - var spacing = this.spacing; - if (scale || lengthSpacing) { - if (scale) lengths = core.Utils.setArraySize(this.lengths, boneCount); - for (var i = 0, n = spacesCount - 1; i < n; ) { - var bone = bones[i]; - var setupLength = bone.data.length; - if (setupLength < PathConstraint.epsilon) { - if (scale) lengths[i] = 0; - spaces[++i] = 0; - } else { - var x = setupLength * bone.matrix.a, - y = setupLength * bone.matrix.b; - var length_1 = Math.sqrt(x * x + y * y); - if (scale) lengths[i] = length_1; - spaces[++i] = - ((lengthSpacing ? setupLength + spacing : spacing) * length_1) / - setupLength; - } - } - } else { - for (var i = 1; i < spacesCount; i++) spaces[i] = spacing; - } - var positions = this.computeWorldPositions( - attachment, - spacesCount, - tangents, - data.positionMode == core.PositionMode.Percent, - spacingMode == core.SpacingMode.Percent, - ); - var boneX = positions[0], - boneY = positions[1], - offsetRotation = data.offsetRotation; - var tip = false; - if (offsetRotation == 0) tip = rotateMode == core.RotateMode.Chain; - else { - tip = false; - var p = this.target.bone.matrix; - offsetRotation *= - p.a * p.d - p.b * p.c > 0 - ? core.MathUtils.degRad - : -core.MathUtils.degRad; - } - for (var i = 0, p = 3; i < boneCount; i++, p += 3) { - var bone = bones[i]; - var mat = bone.matrix; - mat.tx += (boneX - mat.tx) * translateMix; - mat.ty += (boneY - mat.ty) * translateMix; - var x = positions[p], - y = positions[p + 1], - dx = x - boneX, - dy = y - boneY; - if (scale) { - var length_2 = lengths[i]; - if (length_2 != 0) { - var s = - (Math.sqrt(dx * dx + dy * dy) / length_2 - 1) * rotateMix + 1; - mat.a *= s; - mat.b *= s; - } - } - boneX = x; - boneY = y; - if (rotate) { - var a = mat.a, - b = mat.c, - c = mat.b, - d = mat.d, - r = 0, - cos = 0, - sin = 0; - if (tangents) r = positions[p - 1]; - else if (spaces[i + 1] == 0) r = positions[p + 2]; - else r = Math.atan2(dy, dx); - r -= Math.atan2(c, a); - if (tip) { - cos = Math.cos(r); - sin = Math.sin(r); - var length_3 = bone.data.length; - boneX += (length_3 * (cos * a - sin * c) - dx) * rotateMix; - boneY += (length_3 * (sin * a + cos * c) - dy) * rotateMix; - } else { - r += offsetRotation; - } - if (r > core.MathUtils.PI) r -= core.MathUtils.PI2; - else if (r < -core.MathUtils.PI) r += core.MathUtils.PI2; - r *= rotateMix; - cos = Math.cos(r); - sin = Math.sin(r); - mat.a = cos * a - sin * c; - mat.c = cos * b - sin * d; - mat.b = sin * a + cos * c; - mat.d = sin * b + cos * d; - } - bone.appliedValid = false; - } - }; - PathConstraint.prototype.computeWorldPositions = function( - path, - spacesCount, - tangents, - percentPosition, - percentSpacing, - ) { - var target = this.target; - var position = this.position; - var spaces = this.spaces, - out = core.Utils.setArraySize(this.positions, spacesCount * 3 + 2), - world = null; - var closed = path.closed; - var verticesLength = path.worldVerticesLength, - curveCount = verticesLength / 6, - prevCurve = PathConstraint.NONE; - if (!path.constantSpeed) { - var lengths = path.lengths; - curveCount -= closed ? 1 : 2; - var pathLength_1 = lengths[curveCount]; - if (percentPosition) position *= pathLength_1; - if (percentSpacing) { - for (var i = 0; i < spacesCount; i++) spaces[i] *= pathLength_1; - } - world = core.Utils.setArraySize(this.world, 8); - for (var i = 0, o = 0, curve = 0; i < spacesCount; i++, o += 3) { - var space = spaces[i]; - position += space; - var p = position; - if (closed) { - p %= pathLength_1; - if (p < 0) p += pathLength_1; - curve = 0; - } else if (p < 0) { - if (prevCurve != PathConstraint.BEFORE) { - prevCurve = PathConstraint.BEFORE; - path.computeWorldVertices(target, 2, 4, world, 0, 2); - } - this.addBeforePosition(p, world, 0, out, o); - continue; - } else if (p > pathLength_1) { - if (prevCurve != PathConstraint.AFTER) { - prevCurve = PathConstraint.AFTER; - path.computeWorldVertices( - target, - verticesLength - 6, - 4, - world, - 0, - 2, - ); - } - this.addAfterPosition(p - pathLength_1, world, 0, out, o); - continue; - } - for (; ; curve++) { - var length_4 = lengths[curve]; - if (p > length_4) continue; - if (curve == 0) p /= length_4; - else { - var prev = lengths[curve - 1]; - p = (p - prev) / (length_4 - prev); - } - break; - } - if (curve != prevCurve) { - prevCurve = curve; - if (closed && curve == curveCount) { - path.computeWorldVertices( - target, - verticesLength - 4, - 4, - world, - 0, - 2, - ); - path.computeWorldVertices(target, 0, 4, world, 4, 2); - } else - path.computeWorldVertices( - target, - curve * 6 + 2, - 8, - world, - 0, - 2, - ); - } - this.addCurvePosition( - p, - world[0], - world[1], - world[2], - world[3], - world[4], - world[5], - world[6], - world[7], - out, - o, - tangents || (i > 0 && space == 0), - ); - } - return out; - } - if (closed) { - verticesLength += 2; - world = core.Utils.setArraySize(this.world, verticesLength); - path.computeWorldVertices(target, 2, verticesLength - 4, world, 0, 2); - path.computeWorldVertices(target, 0, 2, world, verticesLength - 4, 2); - world[verticesLength - 2] = world[0]; - world[verticesLength - 1] = world[1]; - } else { - curveCount--; - verticesLength -= 4; - world = core.Utils.setArraySize(this.world, verticesLength); - path.computeWorldVertices(target, 2, verticesLength, world, 0, 2); - } - var curves = core.Utils.setArraySize(this.curves, curveCount); - var pathLength = 0; - var x1 = world[0], - y1 = world[1], - cx1 = 0, - cy1 = 0, - cx2 = 0, - cy2 = 0, - x2 = 0, - y2 = 0; - var tmpx = 0, - tmpy = 0, - dddfx = 0, - dddfy = 0, - ddfx = 0, - ddfy = 0, - dfx = 0, - dfy = 0; - for (var i = 0, w = 2; i < curveCount; i++, w += 6) { - cx1 = world[w]; - cy1 = world[w + 1]; - cx2 = world[w + 2]; - cy2 = world[w + 3]; - x2 = world[w + 4]; - y2 = world[w + 5]; - tmpx = (x1 - cx1 * 2 + cx2) * 0.1875; - tmpy = (y1 - cy1 * 2 + cy2) * 0.1875; - dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.09375; - dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.09375; - ddfx = tmpx * 2 + dddfx; - ddfy = tmpy * 2 + dddfy; - dfx = (cx1 - x1) * 0.75 + tmpx + dddfx * 0.16666667; - dfy = (cy1 - y1) * 0.75 + tmpy + dddfy * 0.16666667; - pathLength += Math.sqrt(dfx * dfx + dfy * dfy); - dfx += ddfx; - dfy += ddfy; - ddfx += dddfx; - ddfy += dddfy; - pathLength += Math.sqrt(dfx * dfx + dfy * dfy); - dfx += ddfx; - dfy += ddfy; - pathLength += Math.sqrt(dfx * dfx + dfy * dfy); - dfx += ddfx + dddfx; - dfy += ddfy + dddfy; - pathLength += Math.sqrt(dfx * dfx + dfy * dfy); - curves[i] = pathLength; - x1 = x2; - y1 = y2; - } - if (percentPosition) position *= pathLength; - if (percentSpacing) { - for (var i = 0; i < spacesCount; i++) spaces[i] *= pathLength; - } - var segments = this.segments; - var curveLength = 0; - for ( - var i = 0, o = 0, curve = 0, segment = 0; - i < spacesCount; - i++, o += 3 - ) { - var space = spaces[i]; - position += space; - var p = position; - if (closed) { - p %= pathLength; - if (p < 0) p += pathLength; - curve = 0; - } else if (p < 0) { - this.addBeforePosition(p, world, 0, out, o); - continue; - } else if (p > pathLength) { - this.addAfterPosition( - p - pathLength, - world, - verticesLength - 4, - out, - o, - ); - continue; - } - for (; ; curve++) { - var length_5 = curves[curve]; - if (p > length_5) continue; - if (curve == 0) p /= length_5; - else { - var prev = curves[curve - 1]; - p = (p - prev) / (length_5 - prev); - } - break; - } - if (curve != prevCurve) { - prevCurve = curve; - var ii = curve * 6; - x1 = world[ii]; - y1 = world[ii + 1]; - cx1 = world[ii + 2]; - cy1 = world[ii + 3]; - cx2 = world[ii + 4]; - cy2 = world[ii + 5]; - x2 = world[ii + 6]; - y2 = world[ii + 7]; - tmpx = (x1 - cx1 * 2 + cx2) * 0.03; - tmpy = (y1 - cy1 * 2 + cy2) * 0.03; - dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.006; - dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.006; - ddfx = tmpx * 2 + dddfx; - ddfy = tmpy * 2 + dddfy; - dfx = (cx1 - x1) * 0.3 + tmpx + dddfx * 0.16666667; - dfy = (cy1 - y1) * 0.3 + tmpy + dddfy * 0.16666667; - curveLength = Math.sqrt(dfx * dfx + dfy * dfy); - segments[0] = curveLength; - for (ii = 1; ii < 8; ii++) { - dfx += ddfx; - dfy += ddfy; - ddfx += dddfx; - ddfy += dddfy; - curveLength += Math.sqrt(dfx * dfx + dfy * dfy); - segments[ii] = curveLength; - } - dfx += ddfx; - dfy += ddfy; - curveLength += Math.sqrt(dfx * dfx + dfy * dfy); - segments[8] = curveLength; - dfx += ddfx + dddfx; - dfy += ddfy + dddfy; - curveLength += Math.sqrt(dfx * dfx + dfy * dfy); - segments[9] = curveLength; - segment = 0; - } - p *= curveLength; - for (; ; segment++) { - var length_6 = segments[segment]; - if (p > length_6) continue; - if (segment == 0) p /= length_6; - else { - var prev = segments[segment - 1]; - p = segment + (p - prev) / (length_6 - prev); - } - break; - } - this.addCurvePosition( - p * 0.1, - x1, - y1, - cx1, - cy1, - cx2, - cy2, - x2, - y2, - out, - o, - tangents || (i > 0 && space == 0), - ); - } - return out; - }; - PathConstraint.prototype.addBeforePosition = function( - p, - temp, - i, - out, - o, - ) { - var x1 = temp[i], - y1 = temp[i + 1], - dx = temp[i + 2] - x1, - dy = temp[i + 3] - y1, - r = Math.atan2(dy, dx); - out[o] = x1 + p * Math.cos(r); - out[o + 1] = y1 + p * Math.sin(r); - out[o + 2] = r; - }; - PathConstraint.prototype.addAfterPosition = function(p, temp, i, out, o) { - var x1 = temp[i + 2], - y1 = temp[i + 3], - dx = x1 - temp[i], - dy = y1 - temp[i + 1], - r = Math.atan2(dy, dx); - out[o] = x1 + p * Math.cos(r); - out[o + 1] = y1 + p * Math.sin(r); - out[o + 2] = r; - }; - PathConstraint.prototype.addCurvePosition = function( - p, - x1, - y1, - cx1, - cy1, - cx2, - cy2, - x2, - y2, - out, - o, - tangents, - ) { - if (p == 0 || isNaN(p)) p = 0.0001; - var tt = p * p, - ttt = tt * p, - u = 1 - p, - uu = u * u, - uuu = uu * u; - var ut = u * p, - ut3 = ut * 3, - uut3 = u * ut3, - utt3 = ut3 * p; - var x = x1 * uuu + cx1 * uut3 + cx2 * utt3 + x2 * ttt, - y = y1 * uuu + cy1 * uut3 + cy2 * utt3 + y2 * ttt; - out[o] = x; - out[o + 1] = y; - if (tangents) - out[o + 2] = Math.atan2( - y - (y1 * uu + cy1 * ut * 2 + cy2 * tt), - x - (x1 * uu + cx1 * ut * 2 + cx2 * tt), - ); - }; - PathConstraint.prototype.getOrder = function() { - return this.data.order; - }; - PathConstraint.NONE = -1; - PathConstraint.BEFORE = -2; - PathConstraint.AFTER = -3; - PathConstraint.epsilon = 0.00001; - return PathConstraint; - })(); - core.PathConstraint = PathConstraint; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var PathConstraintData = (function() { - function PathConstraintData(name) { - this.order = 0; - this.bones = new Array(); - this.name = name; - } - return PathConstraintData; - })(); - core.PathConstraintData = PathConstraintData; - var PositionMode; - (function(PositionMode) { - PositionMode[(PositionMode['Fixed'] = 0)] = 'Fixed'; - PositionMode[(PositionMode['Percent'] = 1)] = 'Percent'; - })((PositionMode = core.PositionMode || (core.PositionMode = {}))); - var SpacingMode; - (function(SpacingMode) { - SpacingMode[(SpacingMode['Length'] = 0)] = 'Length'; - SpacingMode[(SpacingMode['Fixed'] = 1)] = 'Fixed'; - SpacingMode[(SpacingMode['Percent'] = 2)] = 'Percent'; - })((SpacingMode = core.SpacingMode || (core.SpacingMode = {}))); - var RotateMode; - (function(RotateMode) { - RotateMode[(RotateMode['Tangent'] = 0)] = 'Tangent'; - RotateMode[(RotateMode['Chain'] = 1)] = 'Chain'; - RotateMode[(RotateMode['ChainScale'] = 2)] = 'ChainScale'; - })((RotateMode = core.RotateMode || (core.RotateMode = {}))); - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var Skeleton = (function() { - function Skeleton(data) { - this._updateCache = new Array(); - this.updateCacheReset = new Array(); - this.time = 0; - this.scaleX = 1; - this.scaleY = 1; - this.x = 0; - this.y = 0; - if (data == null) throw new Error('data cannot be null.'); - this.data = data; - this.bones = new Array(); - for (var i = 0; i < data.bones.length; i++) { - var boneData = data.bones[i]; - var bone = void 0; - if (boneData.parent == null) - bone = new core.Bone(boneData, this, null); - else { - var parent_1 = this.bones[boneData.parent.index]; - bone = new core.Bone(boneData, this, parent_1); - parent_1.children.push(bone); - } - this.bones.push(bone); - } - this.slots = new Array(); - this.drawOrder = new Array(); - for (var i = 0; i < data.slots.length; i++) { - var slotData = data.slots[i]; - var bone = this.bones[slotData.boneData.index]; - var slot = new core.Slot(slotData, bone); - this.slots.push(slot); - this.drawOrder.push(slot); - } - this.ikConstraints = new Array(); - for (var i = 0; i < data.ikConstraints.length; i++) { - var ikConstraintData = data.ikConstraints[i]; - this.ikConstraints.push( - new core.IkConstraint(ikConstraintData, this), - ); - } - this.transformConstraints = new Array(); - for (var i = 0; i < data.transformConstraints.length; i++) { - var transformConstraintData = data.transformConstraints[i]; - this.transformConstraints.push( - new core.TransformConstraint(transformConstraintData, this), - ); - } - this.pathConstraints = new Array(); - for (var i = 0; i < data.pathConstraints.length; i++) { - var pathConstraintData = data.pathConstraints[i]; - this.pathConstraints.push( - new core.PathConstraint(pathConstraintData, this), - ); - } - this.color = new core.Color(1, 1, 1, 1); - this.updateCache(); - } - Skeleton.prototype.updateCache = function() { - var updateCache = this._updateCache; - updateCache.length = 0; - this.updateCacheReset.length = 0; - var bones = this.bones; - for (var i = 0, n = bones.length; i < n; i++) bones[i].sorted = false; - var ikConstraints = this.ikConstraints; - var transformConstraints = this.transformConstraints; - var pathConstraints = this.pathConstraints; - var ikCount = ikConstraints.length, - transformCount = transformConstraints.length, - pathCount = pathConstraints.length; - var constraintCount = ikCount + transformCount + pathCount; - outer: for (var i = 0; i < constraintCount; i++) { - for (var ii = 0; ii < ikCount; ii++) { - var constraint = ikConstraints[ii]; - if (constraint.data.order == i) { - this.sortIkConstraint(constraint); - continue outer; - } - } - for (var ii = 0; ii < transformCount; ii++) { - var constraint = transformConstraints[ii]; - if (constraint.data.order == i) { - this.sortTransformConstraint(constraint); - continue outer; - } - } - for (var ii = 0; ii < pathCount; ii++) { - var constraint = pathConstraints[ii]; - if (constraint.data.order == i) { - this.sortPathConstraint(constraint); - continue outer; - } - } - } - for (var i = 0, n = bones.length; i < n; i++) this.sortBone(bones[i]); - }; - Skeleton.prototype.sortIkConstraint = function(constraint) { - var target = constraint.target; - this.sortBone(target); - var constrained = constraint.bones; - var parent = constrained[0]; - this.sortBone(parent); - if (constrained.length > 1) { - var child = constrained[constrained.length - 1]; - if (!(this._updateCache.indexOf(child) > -1)) - this.updateCacheReset.push(child); - } - this._updateCache.push(constraint); - this.sortReset(parent.children); - constrained[constrained.length - 1].sorted = true; - }; - Skeleton.prototype.sortPathConstraint = function(constraint) { - var slot = constraint.target; - var slotIndex = slot.data.index; - var slotBone = slot.bone; - if (this.skin != null) - this.sortPathConstraintAttachment(this.skin, slotIndex, slotBone); - if (this.data.defaultSkin != null && this.data.defaultSkin != this.skin) - this.sortPathConstraintAttachment( - this.data.defaultSkin, - slotIndex, - slotBone, - ); - for (var i = 0, n = this.data.skins.length; i < n; i++) - this.sortPathConstraintAttachment( - this.data.skins[i], - slotIndex, - slotBone, - ); - var attachment = slot.getAttachment(); - if (attachment instanceof core.PathAttachment) - this.sortPathConstraintAttachmentWith(attachment, slotBone); - var constrained = constraint.bones; - var boneCount = constrained.length; - for (var i = 0; i < boneCount; i++) this.sortBone(constrained[i]); - this._updateCache.push(constraint); - for (var i = 0; i < boneCount; i++) - this.sortReset(constrained[i].children); - for (var i = 0; i < boneCount; i++) constrained[i].sorted = true; - }; - Skeleton.prototype.sortTransformConstraint = function(constraint) { - this.sortBone(constraint.target); - var constrained = constraint.bones; - var boneCount = constrained.length; - if (constraint.data.local) { - for (var i = 0; i < boneCount; i++) { - var child = constrained[i]; - this.sortBone(child.parent); - if (!(this._updateCache.indexOf(child) > -1)) - this.updateCacheReset.push(child); - } - } else { - for (var i = 0; i < boneCount; i++) { - this.sortBone(constrained[i]); - } - } - this._updateCache.push(constraint); - for (var ii = 0; ii < boneCount; ii++) - this.sortReset(constrained[ii].children); - for (var ii = 0; ii < boneCount; ii++) constrained[ii].sorted = true; - }; - Skeleton.prototype.sortPathConstraintAttachment = function( - skin, - slotIndex, - slotBone, - ) { - var attachments = skin.attachments[slotIndex]; - if (!attachments) return; - for (var key in attachments) { - this.sortPathConstraintAttachmentWith(attachments[key], slotBone); - } - }; - Skeleton.prototype.sortPathConstraintAttachmentWith = function( - attachment, - slotBone, - ) { - if (!(attachment instanceof core.PathAttachment)) return; - var pathBones = attachment.bones; - if (pathBones == null) this.sortBone(slotBone); - else { - var bones = this.bones; - var i = 0; - while (i < pathBones.length) { - var boneCount = pathBones[i++]; - for (var n = i + boneCount; i < n; i++) { - var boneIndex = pathBones[i]; - this.sortBone(bones[boneIndex]); - } - } - } - }; - Skeleton.prototype.sortBone = function(bone) { - if (bone.sorted) return; - var parent = bone.parent; - if (parent != null) this.sortBone(parent); - bone.sorted = true; - this._updateCache.push(bone); - }; - Skeleton.prototype.sortReset = function(bones) { - for (var i = 0, n = bones.length; i < n; i++) { - var bone = bones[i]; - if (bone.sorted) this.sortReset(bone.children); - bone.sorted = false; - } - }; - Skeleton.prototype.updateWorldTransform = function() { - var updateCacheReset = this.updateCacheReset; - for (var i = 0, n = updateCacheReset.length; i < n; i++) { - var bone = updateCacheReset[i]; - bone.ax = bone.x; - bone.ay = bone.y; - bone.arotation = bone.rotation; - bone.ascaleX = bone.scaleX; - bone.ascaleY = bone.scaleY; - bone.ashearX = bone.shearX; - bone.ashearY = bone.shearY; - bone.appliedValid = true; - } - var updateCache = this._updateCache; - for (var i = 0, n = updateCache.length; i < n; i++) - updateCache[i].update(); - }; - Skeleton.prototype.setToSetupPose = function() { - this.setBonesToSetupPose(); - this.setSlotsToSetupPose(); - }; - Skeleton.prototype.setBonesToSetupPose = function() { - var bones = this.bones; - for (var i = 0, n = bones.length; i < n; i++) bones[i].setToSetupPose(); - var ikConstraints = this.ikConstraints; - for (var i = 0, n = ikConstraints.length; i < n; i++) { - var constraint = ikConstraints[i]; - constraint.bendDirection = constraint.data.bendDirection; - constraint.mix = constraint.data.mix; - } - var transformConstraints = this.transformConstraints; - for (var i = 0, n = transformConstraints.length; i < n; i++) { - var constraint = transformConstraints[i]; - var data = constraint.data; - constraint.rotateMix = data.rotateMix; - constraint.translateMix = data.translateMix; - constraint.scaleMix = data.scaleMix; - constraint.shearMix = data.shearMix; - } - var pathConstraints = this.pathConstraints; - for (var i = 0, n = pathConstraints.length; i < n; i++) { - var constraint = pathConstraints[i]; - var data = constraint.data; - constraint.position = data.position; - constraint.spacing = data.spacing; - constraint.rotateMix = data.rotateMix; - constraint.translateMix = data.translateMix; - } - }; - Skeleton.prototype.setSlotsToSetupPose = function() { - var slots = this.slots; - core.Utils.arrayCopy(slots, 0, this.drawOrder, 0, slots.length); - for (var i = 0, n = slots.length; i < n; i++) slots[i].setToSetupPose(); - }; - Skeleton.prototype.getRootBone = function() { - if (this.bones.length == 0) return null; - return this.bones[0]; - }; - Skeleton.prototype.findBone = function(boneName) { - if (boneName == null) throw new Error('boneName cannot be null.'); - var bones = this.bones; - for (var i = 0, n = bones.length; i < n; i++) { - var bone = bones[i]; - if (bone.data.name == boneName) return bone; - } - return null; - }; - Skeleton.prototype.findBoneIndex = function(boneName) { - if (boneName == null) throw new Error('boneName cannot be null.'); - var bones = this.bones; - for (var i = 0, n = bones.length; i < n; i++) - if (bones[i].data.name == boneName) return i; - return -1; - }; - Skeleton.prototype.findSlot = function(slotName) { - if (slotName == null) throw new Error('slotName cannot be null.'); - var slots = this.slots; - for (var i = 0, n = slots.length; i < n; i++) { - var slot = slots[i]; - if (slot.data.name == slotName) return slot; - } - return null; - }; - Skeleton.prototype.findSlotIndex = function(slotName) { - if (slotName == null) throw new Error('slotName cannot be null.'); - var slots = this.slots; - for (var i = 0, n = slots.length; i < n; i++) - if (slots[i].data.name == slotName) return i; - return -1; - }; - Skeleton.prototype.setSkinByName = function(skinName) { - var skin = this.data.findSkin(skinName); - if (skin == null) throw new Error('Skin not found: ' + skinName); - this.setSkin(skin); - }; - Skeleton.prototype.setSkin = function(newSkin) { - if (newSkin != null) { - if (this.skin != null) newSkin.attachAll(this, this.skin); - else { - var slots = this.slots; - for (var i = 0, n = slots.length; i < n; i++) { - var slot = slots[i]; - var name_1 = slot.data.attachmentName; - if (name_1 != null) { - var attachment = newSkin.getAttachment(i, name_1); - if (attachment != null) slot.setAttachment(attachment); - } - } - } - } - this.skin = newSkin; - }; - Skeleton.prototype.getAttachmentByName = function( - slotName, - attachmentName, - ) { - return this.getAttachment( - this.data.findSlotIndex(slotName), - attachmentName, - ); - }; - Skeleton.prototype.getAttachment = function(slotIndex, attachmentName) { - if (attachmentName == null) - throw new Error('attachmentName cannot be null.'); - if (this.skin != null) { - var attachment = this.skin.getAttachment(slotIndex, attachmentName); - if (attachment != null) return attachment; - } - if (this.data.defaultSkin != null) - return this.data.defaultSkin.getAttachment(slotIndex, attachmentName); - return null; - }; - Skeleton.prototype.setAttachment = function(slotName, attachmentName) { - if (slotName == null) throw new Error('slotName cannot be null.'); - var slots = this.slots; - for (var i = 0, n = slots.length; i < n; i++) { - var slot = slots[i]; - if (slot.data.name == slotName) { - var attachment = null; - if (attachmentName != null) { - attachment = this.getAttachment(i, attachmentName); - if (attachment == null) - throw new Error( - 'Attachment not found: ' + - attachmentName + - ', for slot: ' + - slotName, - ); - } - slot.setAttachment(attachment); - return; - } - } - throw new Error('Slot not found: ' + slotName); - }; - Skeleton.prototype.findIkConstraint = function(constraintName) { - if (constraintName == null) - throw new Error('constraintName cannot be null.'); - var ikConstraints = this.ikConstraints; - for (var i = 0, n = ikConstraints.length; i < n; i++) { - var ikConstraint = ikConstraints[i]; - if (ikConstraint.data.name == constraintName) return ikConstraint; - } - return null; - }; - Skeleton.prototype.findTransformConstraint = function(constraintName) { - if (constraintName == null) - throw new Error('constraintName cannot be null.'); - var transformConstraints = this.transformConstraints; - for (var i = 0, n = transformConstraints.length; i < n; i++) { - var constraint = transformConstraints[i]; - if (constraint.data.name == constraintName) return constraint; - } - return null; - }; - Skeleton.prototype.findPathConstraint = function(constraintName) { - if (constraintName == null) - throw new Error('constraintName cannot be null.'); - var pathConstraints = this.pathConstraints; - for (var i = 0, n = pathConstraints.length; i < n; i++) { - var constraint = pathConstraints[i]; - if (constraint.data.name == constraintName) return constraint; - } - return null; - }; - Skeleton.prototype.getBounds = function(offset, size, temp) { - if (offset == null) throw new Error('offset cannot be null.'); - if (size == null) throw new Error('size cannot be null.'); - var drawOrder = this.drawOrder; - var minX = Number.POSITIVE_INFINITY, - minY = Number.POSITIVE_INFINITY, - maxX = Number.NEGATIVE_INFINITY, - maxY = Number.NEGATIVE_INFINITY; - for (var i = 0, n = drawOrder.length; i < n; i++) { - var slot = drawOrder[i]; - var verticesLength = 0; - var vertices = null; - var attachment = slot.getAttachment(); - if (attachment instanceof core.RegionAttachment) { - verticesLength = 8; - vertices = core.Utils.setArraySize(temp, verticesLength, 0); - attachment.computeWorldVertices(slot.bone, vertices, 0, 2); - } else if (attachment instanceof core.MeshAttachment) { - var mesh = attachment; - verticesLength = mesh.worldVerticesLength; - vertices = core.Utils.setArraySize(temp, verticesLength, 0); - mesh.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2); - } - if (vertices != null) { - for (var ii = 0, nn = vertices.length; ii < nn; ii += 2) { - var x = vertices[ii], - y = vertices[ii + 1]; - minX = Math.min(minX, x); - minY = Math.min(minY, y); - maxX = Math.max(maxX, x); - maxY = Math.max(maxY, y); - } - } - } - offset.set(minX, minY); - size.set(maxX - minX, maxY - minY); - }; - Skeleton.prototype.update = function(delta) { - this.time += delta; - }; - Object.defineProperty(Skeleton.prototype, 'flipX', { - get: function() { - return this.scaleX == -1; - }, - set: function(value) { - if (!Skeleton.deprecatedWarning1) { - Skeleton.deprecatedWarning1 = true; - console.warn( - 'Spine Deprecation Warning: `Skeleton.flipX/flipY` was deprecated, please use scaleX/scaleY', - ); - } - this.scaleX = value ? 1.0 : -1.0; - }, - enumerable: true, - configurable: true, - }); - Object.defineProperty(Skeleton.prototype, 'flipY', { - get: function() { - return this.scaleY == -1; - }, - set: function(value) { - if (!Skeleton.deprecatedWarning1) { - Skeleton.deprecatedWarning1 = true; - console.warn( - 'Spine Deprecation Warning: `Skeleton.flipX/flipY` was deprecated, please use scaleX/scaleY', - ); - } - this.scaleY = value ? 1.0 : -1.0; - }, - enumerable: true, - configurable: true, - }); - Skeleton.deprecatedWarning1 = false; - return Skeleton; - })(); - core.Skeleton = Skeleton; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var SkeletonBounds = (function() { - function SkeletonBounds() { - this.minX = 0; - this.minY = 0; - this.maxX = 0; - this.maxY = 0; - this.boundingBoxes = new Array(); - this.polygons = new Array(); - this.polygonPool = new core.Pool(function() { - return core.Utils.newFloatArray(16); - }); - } - SkeletonBounds.prototype.update = function(skeleton, updateAabb) { - if (skeleton == null) throw new Error('skeleton cannot be null.'); - var boundingBoxes = this.boundingBoxes; - var polygons = this.polygons; - var polygonPool = this.polygonPool; - var slots = skeleton.slots; - var slotCount = slots.length; - boundingBoxes.length = 0; - polygonPool.freeAll(polygons); - polygons.length = 0; - for (var i = 0; i < slotCount; i++) { - var slot = slots[i]; - var attachment = slot.getAttachment(); - if (attachment instanceof core.BoundingBoxAttachment) { - var boundingBox = attachment; - boundingBoxes.push(boundingBox); - var polygon = polygonPool.obtain(); - if (polygon.length != boundingBox.worldVerticesLength) { - polygon = core.Utils.newFloatArray( - boundingBox.worldVerticesLength, - ); - } - polygons.push(polygon); - boundingBox.computeWorldVertices( - slot, - 0, - boundingBox.worldVerticesLength, - polygon, - 0, - 2, - ); - } - } - if (updateAabb) { - this.aabbCompute(); - } else { - this.minX = Number.POSITIVE_INFINITY; - this.minY = Number.POSITIVE_INFINITY; - this.maxX = Number.NEGATIVE_INFINITY; - this.maxY = Number.NEGATIVE_INFINITY; - } - }; - SkeletonBounds.prototype.aabbCompute = function() { - var minX = Number.POSITIVE_INFINITY, - minY = Number.POSITIVE_INFINITY, - maxX = Number.NEGATIVE_INFINITY, - maxY = Number.NEGATIVE_INFINITY; - var polygons = this.polygons; - for (var i = 0, n = polygons.length; i < n; i++) { - var polygon = polygons[i]; - var vertices = polygon; - for (var ii = 0, nn = polygon.length; ii < nn; ii += 2) { - var x = vertices[ii]; - var y = vertices[ii + 1]; - minX = Math.min(minX, x); - minY = Math.min(minY, y); - maxX = Math.max(maxX, x); - maxY = Math.max(maxY, y); - } - } - this.minX = minX; - this.minY = minY; - this.maxX = maxX; - this.maxY = maxY; - }; - SkeletonBounds.prototype.aabbContainsPoint = function(x, y) { - return ( - x >= this.minX && x <= this.maxX && y >= this.minY && y <= this.maxY - ); - }; - SkeletonBounds.prototype.aabbIntersectsSegment = function( - x1, - y1, - x2, - y2, - ) { - var minX = this.minX; - var minY = this.minY; - var maxX = this.maxX; - var maxY = this.maxY; - if ( - (x1 <= minX && x2 <= minX) || - (y1 <= minY && y2 <= minY) || - (x1 >= maxX && x2 >= maxX) || - (y1 >= maxY && y2 >= maxY) - ) - return false; - var m = (y2 - y1) / (x2 - x1); - var y = m * (minX - x1) + y1; - if (y > minY && y < maxY) return true; - y = m * (maxX - x1) + y1; - if (y > minY && y < maxY) return true; - var x = (minY - y1) / m + x1; - if (x > minX && x < maxX) return true; - x = (maxY - y1) / m + x1; - if (x > minX && x < maxX) return true; - return false; - }; - SkeletonBounds.prototype.aabbIntersectsSkeleton = function(bounds) { - return ( - this.minX < bounds.maxX && - this.maxX > bounds.minX && - this.minY < bounds.maxY && - this.maxY > bounds.minY - ); - }; - SkeletonBounds.prototype.containsPoint = function(x, y) { - var polygons = this.polygons; - for (var i = 0, n = polygons.length; i < n; i++) - if (this.containsPointPolygon(polygons[i], x, y)) - return this.boundingBoxes[i]; - return null; - }; - SkeletonBounds.prototype.containsPointPolygon = function(polygon, x, y) { - var vertices = polygon; - var nn = polygon.length; - var prevIndex = nn - 2; - var inside = false; - for (var ii = 0; ii < nn; ii += 2) { - var vertexY = vertices[ii + 1]; - var prevY = vertices[prevIndex + 1]; - if ((vertexY < y && prevY >= y) || (prevY < y && vertexY >= y)) { - var vertexX = vertices[ii]; - if ( - vertexX + - ((y - vertexY) / (prevY - vertexY)) * - (vertices[prevIndex] - vertexX) < - x - ) - inside = !inside; - } - prevIndex = ii; - } - return inside; - }; - SkeletonBounds.prototype.intersectsSegment = function(x1, y1, x2, y2) { - var polygons = this.polygons; - for (var i = 0, n = polygons.length; i < n; i++) - if (this.intersectsSegmentPolygon(polygons[i], x1, y1, x2, y2)) - return this.boundingBoxes[i]; - return null; - }; - SkeletonBounds.prototype.intersectsSegmentPolygon = function( - polygon, - x1, - y1, - x2, - y2, - ) { - var vertices = polygon; - var nn = polygon.length; - var width12 = x1 - x2, - height12 = y1 - y2; - var det1 = x1 * y2 - y1 * x2; - var x3 = vertices[nn - 2], - y3 = vertices[nn - 1]; - for (var ii = 0; ii < nn; ii += 2) { - var x4 = vertices[ii], - y4 = vertices[ii + 1]; - var det2 = x3 * y4 - y3 * x4; - var width34 = x3 - x4, - height34 = y3 - y4; - var det3 = width12 * height34 - height12 * width34; - var x = (det1 * width34 - width12 * det2) / det3; - if ( - ((x >= x3 && x <= x4) || (x >= x4 && x <= x3)) && - ((x >= x1 && x <= x2) || (x >= x2 && x <= x1)) - ) { - var y = (det1 * height34 - height12 * det2) / det3; - if ( - ((y >= y3 && y <= y4) || (y >= y4 && y <= y3)) && - ((y >= y1 && y <= y2) || (y >= y2 && y <= y1)) - ) - return true; - } - x3 = x4; - y3 = y4; - } - return false; - }; - SkeletonBounds.prototype.getPolygon = function(boundingBox) { - if (boundingBox == null) throw new Error('boundingBox cannot be null.'); - var index = this.boundingBoxes.indexOf(boundingBox); - return index == -1 ? null : this.polygons[index]; - }; - SkeletonBounds.prototype.getWidth = function() { - return this.maxX - this.minX; - }; - SkeletonBounds.prototype.getHeight = function() { - return this.maxY - this.minY; - }; - return SkeletonBounds; - })(); - core.SkeletonBounds = SkeletonBounds; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var SkeletonClipping = (function() { - function SkeletonClipping() { - this.triangulator = new core.Triangulator(); - this.clippingPolygon = new Array(); - this.clipOutput = new Array(); - this.clippedVertices = new Array(); - this.clippedTriangles = new Array(); - this.scratch = new Array(); - } - SkeletonClipping.prototype.clipStart = function(slot, clip) { - if (this.clipAttachment != null) return 0; - this.clipAttachment = clip; - var n = clip.worldVerticesLength; - var vertices = core.Utils.setArraySize(this.clippingPolygon, n); - clip.computeWorldVertices(slot, 0, n, vertices, 0, 2); - var clippingPolygon = this.clippingPolygon; - SkeletonClipping.makeClockwise(clippingPolygon); - var clippingPolygons = (this.clippingPolygons = this.triangulator.decompose( - clippingPolygon, - this.triangulator.triangulate(clippingPolygon), - )); - for (var i = 0, n_1 = clippingPolygons.length; i < n_1; i++) { - var polygon = clippingPolygons[i]; - SkeletonClipping.makeClockwise(polygon); - polygon.push(polygon[0]); - polygon.push(polygon[1]); - } - return clippingPolygons.length; - }; - SkeletonClipping.prototype.clipEndWithSlot = function(slot) { - if ( - this.clipAttachment != null && - this.clipAttachment.endSlot == slot.data - ) - this.clipEnd(); - }; - SkeletonClipping.prototype.clipEnd = function() { - if (this.clipAttachment == null) return; - this.clipAttachment = null; - this.clippingPolygons = null; - this.clippedVertices.length = 0; - this.clippedTriangles.length = 0; - this.clippingPolygon.length = 0; - }; - SkeletonClipping.prototype.isClipping = function() { - return this.clipAttachment != null; - }; - SkeletonClipping.prototype.clipTriangles = function( - vertices, - verticesLength, - triangles, - trianglesLength, - uvs, - light, - dark, - twoColor, - ) { - var clipOutput = this.clipOutput, - clippedVertices = this.clippedVertices; - var clippedTriangles = this.clippedTriangles; - var polygons = this.clippingPolygons; - var polygonsCount = this.clippingPolygons.length; - var vertexSize = twoColor ? 12 : 8; - var index = 0; - clippedVertices.length = 0; - clippedTriangles.length = 0; - outer: for (var i = 0; i < trianglesLength; i += 3) { - var vertexOffset = triangles[i] << 1; - var x1 = vertices[vertexOffset], - y1 = vertices[vertexOffset + 1]; - var u1 = uvs[vertexOffset], - v1 = uvs[vertexOffset + 1]; - vertexOffset = triangles[i + 1] << 1; - var x2 = vertices[vertexOffset], - y2 = vertices[vertexOffset + 1]; - var u2 = uvs[vertexOffset], - v2 = uvs[vertexOffset + 1]; - vertexOffset = triangles[i + 2] << 1; - var x3 = vertices[vertexOffset], - y3 = vertices[vertexOffset + 1]; - var u3 = uvs[vertexOffset], - v3 = uvs[vertexOffset + 1]; - for (var p = 0; p < polygonsCount; p++) { - var s = clippedVertices.length; - if (this.clip(x1, y1, x2, y2, x3, y3, polygons[p], clipOutput)) { - var clipOutputLength = clipOutput.length; - if (clipOutputLength == 0) continue; - var d0 = y2 - y3, - d1 = x3 - x2, - d2 = x1 - x3, - d4 = y3 - y1; - var d = 1 / (d0 * d2 + d1 * (y1 - y3)); - var clipOutputCount = clipOutputLength >> 1; - var clipOutputItems = this.clipOutput; - var clippedVerticesItems = core.Utils.setArraySize( - clippedVertices, - s + clipOutputCount * vertexSize, - ); - for (var ii = 0; ii < clipOutputLength; ii += 2) { - var x = clipOutputItems[ii], - y = clipOutputItems[ii + 1]; - clippedVerticesItems[s] = x; - clippedVerticesItems[s + 1] = y; - clippedVerticesItems[s + 2] = light.r; - clippedVerticesItems[s + 3] = light.g; - clippedVerticesItems[s + 4] = light.b; - clippedVerticesItems[s + 5] = light.a; - var c0 = x - x3, - c1 = y - y3; - var a = (d0 * c0 + d1 * c1) * d; - var b = (d4 * c0 + d2 * c1) * d; - var c = 1 - a - b; - clippedVerticesItems[s + 6] = u1 * a + u2 * b + u3 * c; - clippedVerticesItems[s + 7] = v1 * a + v2 * b + v3 * c; - if (twoColor) { - clippedVerticesItems[s + 8] = dark.r; - clippedVerticesItems[s + 9] = dark.g; - clippedVerticesItems[s + 10] = dark.b; - clippedVerticesItems[s + 11] = dark.a; - } - s += vertexSize; - } - s = clippedTriangles.length; - var clippedTrianglesItems = core.Utils.setArraySize( - clippedTriangles, - s + 3 * (clipOutputCount - 2), - ); - clipOutputCount--; - for (var ii = 1; ii < clipOutputCount; ii++) { - clippedTrianglesItems[s] = index; - clippedTrianglesItems[s + 1] = index + ii; - clippedTrianglesItems[s + 2] = index + ii + 1; - s += 3; - } - index += clipOutputCount + 1; - } else { - var clippedVerticesItems = core.Utils.setArraySize( - clippedVertices, - s + 3 * vertexSize, - ); - clippedVerticesItems[s] = x1; - clippedVerticesItems[s + 1] = y1; - clippedVerticesItems[s + 2] = light.r; - clippedVerticesItems[s + 3] = light.g; - clippedVerticesItems[s + 4] = light.b; - clippedVerticesItems[s + 5] = light.a; - if (!twoColor) { - clippedVerticesItems[s + 6] = u1; - clippedVerticesItems[s + 7] = v1; - clippedVerticesItems[s + 8] = x2; - clippedVerticesItems[s + 9] = y2; - clippedVerticesItems[s + 10] = light.r; - clippedVerticesItems[s + 11] = light.g; - clippedVerticesItems[s + 12] = light.b; - clippedVerticesItems[s + 13] = light.a; - clippedVerticesItems[s + 14] = u2; - clippedVerticesItems[s + 15] = v2; - clippedVerticesItems[s + 16] = x3; - clippedVerticesItems[s + 17] = y3; - clippedVerticesItems[s + 18] = light.r; - clippedVerticesItems[s + 19] = light.g; - clippedVerticesItems[s + 20] = light.b; - clippedVerticesItems[s + 21] = light.a; - clippedVerticesItems[s + 22] = u3; - clippedVerticesItems[s + 23] = v3; - } else { - clippedVerticesItems[s + 6] = u1; - clippedVerticesItems[s + 7] = v1; - clippedVerticesItems[s + 8] = dark.r; - clippedVerticesItems[s + 9] = dark.g; - clippedVerticesItems[s + 10] = dark.b; - clippedVerticesItems[s + 11] = dark.a; - clippedVerticesItems[s + 12] = x2; - clippedVerticesItems[s + 13] = y2; - clippedVerticesItems[s + 14] = light.r; - clippedVerticesItems[s + 15] = light.g; - clippedVerticesItems[s + 16] = light.b; - clippedVerticesItems[s + 17] = light.a; - clippedVerticesItems[s + 18] = u2; - clippedVerticesItems[s + 19] = v2; - clippedVerticesItems[s + 20] = dark.r; - clippedVerticesItems[s + 21] = dark.g; - clippedVerticesItems[s + 22] = dark.b; - clippedVerticesItems[s + 23] = dark.a; - clippedVerticesItems[s + 24] = x3; - clippedVerticesItems[s + 25] = y3; - clippedVerticesItems[s + 26] = light.r; - clippedVerticesItems[s + 27] = light.g; - clippedVerticesItems[s + 28] = light.b; - clippedVerticesItems[s + 29] = light.a; - clippedVerticesItems[s + 30] = u3; - clippedVerticesItems[s + 31] = v3; - clippedVerticesItems[s + 32] = dark.r; - clippedVerticesItems[s + 33] = dark.g; - clippedVerticesItems[s + 34] = dark.b; - clippedVerticesItems[s + 35] = dark.a; - } - s = clippedTriangles.length; - var clippedTrianglesItems = core.Utils.setArraySize( - clippedTriangles, - s + 3, - ); - clippedTrianglesItems[s] = index; - clippedTrianglesItems[s + 1] = index + 1; - clippedTrianglesItems[s + 2] = index + 2; - index += 3; - continue outer; - } - } - } - }; - SkeletonClipping.prototype.clip = function( - x1, - y1, - x2, - y2, - x3, - y3, - clippingArea, - output, - ) { - var originalOutput = output; - var clipped = false; - var input = null; - if (clippingArea.length % 4 >= 2) { - input = output; - output = this.scratch; - } else input = this.scratch; - input.length = 0; - input.push(x1); - input.push(y1); - input.push(x2); - input.push(y2); - input.push(x3); - input.push(y3); - input.push(x1); - input.push(y1); - output.length = 0; - var clippingVertices = clippingArea; - var clippingVerticesLast = clippingArea.length - 4; - for (var i = 0; ; i += 2) { - var edgeX = clippingVertices[i], - edgeY = clippingVertices[i + 1]; - var edgeX2 = clippingVertices[i + 2], - edgeY2 = clippingVertices[i + 3]; - var deltaX = edgeX - edgeX2, - deltaY = edgeY - edgeY2; - var inputVertices = input; - var inputVerticesLength = input.length - 2, - outputStart = output.length; - for (var ii = 0; ii < inputVerticesLength; ii += 2) { - var inputX = inputVertices[ii], - inputY = inputVertices[ii + 1]; - var inputX2 = inputVertices[ii + 2], - inputY2 = inputVertices[ii + 3]; - var side2 = - deltaX * (inputY2 - edgeY2) - deltaY * (inputX2 - edgeX2) > 0; - if (deltaX * (inputY - edgeY2) - deltaY * (inputX - edgeX2) > 0) { - if (side2) { - output.push(inputX2); - output.push(inputY2); - continue; - } - var c0 = inputY2 - inputY, - c2 = inputX2 - inputX; - var ua = - (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / - (c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY)); - output.push(edgeX + (edgeX2 - edgeX) * ua); - output.push(edgeY + (edgeY2 - edgeY) * ua); - } else if (side2) { - var c0 = inputY2 - inputY, - c2 = inputX2 - inputX; - var ua = - (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / - (c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY)); - output.push(edgeX + (edgeX2 - edgeX) * ua); - output.push(edgeY + (edgeY2 - edgeY) * ua); - output.push(inputX2); - output.push(inputY2); - } - clipped = true; - } - if (outputStart == output.length) { - originalOutput.length = 0; - return true; - } - output.push(output[0]); - output.push(output[1]); - if (i == clippingVerticesLast) break; - var temp = output; - output = input; - output.length = 0; - input = temp; - } - if (originalOutput != output) { - originalOutput.length = 0; - for (var i = 0, n = output.length - 2; i < n; i++) - originalOutput[i] = output[i]; - } else originalOutput.length = originalOutput.length - 2; - return clipped; - }; - SkeletonClipping.makeClockwise = function(polygon) { - var vertices = polygon; - var verticeslength = polygon.length; - var area = - vertices[verticeslength - 2] * vertices[1] - - vertices[0] * vertices[verticeslength - 1], - p1x = 0, - p1y = 0, - p2x = 0, - p2y = 0; - for (var i = 0, n = verticeslength - 3; i < n; i += 2) { - p1x = vertices[i]; - p1y = vertices[i + 1]; - p2x = vertices[i + 2]; - p2y = vertices[i + 3]; - area += p1x * p2y - p2x * p1y; - } - if (area < 0) return; - for ( - var i = 0, lastX = verticeslength - 2, n = verticeslength >> 1; - i < n; - i += 2 - ) { - var x = vertices[i], - y = vertices[i + 1]; - var other = lastX - i; - vertices[i] = vertices[other]; - vertices[i + 1] = vertices[other + 1]; - vertices[other] = x; - vertices[other + 1] = y; - } - }; - return SkeletonClipping; - })(); - core.SkeletonClipping = SkeletonClipping; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var SkeletonData = (function() { - function SkeletonData() { - this.bones = new Array(); - this.slots = new Array(); - this.skins = new Array(); - this.events = new Array(); - this.animations = new Array(); - this.ikConstraints = new Array(); - this.transformConstraints = new Array(); - this.pathConstraints = new Array(); - this.fps = 0; - } - SkeletonData.prototype.findBone = function(boneName) { - if (boneName == null) throw new Error('boneName cannot be null.'); - var bones = this.bones; - for (var i = 0, n = bones.length; i < n; i++) { - var bone = bones[i]; - if (bone.name == boneName) return bone; - } - return null; - }; - SkeletonData.prototype.findBoneIndex = function(boneName) { - if (boneName == null) throw new Error('boneName cannot be null.'); - var bones = this.bones; - for (var i = 0, n = bones.length; i < n; i++) - if (bones[i].name == boneName) return i; - return -1; - }; - SkeletonData.prototype.findSlot = function(slotName) { - if (slotName == null) throw new Error('slotName cannot be null.'); - var slots = this.slots; - for (var i = 0, n = slots.length; i < n; i++) { - var slot = slots[i]; - if (slot.name == slotName) return slot; - } - return null; - }; - SkeletonData.prototype.findSlotIndex = function(slotName) { - if (slotName == null) throw new Error('slotName cannot be null.'); - var slots = this.slots; - for (var i = 0, n = slots.length; i < n; i++) - if (slots[i].name == slotName) return i; - return -1; - }; - SkeletonData.prototype.findSkin = function(skinName) { - if (skinName == null) throw new Error('skinName cannot be null.'); - var skins = this.skins; - for (var i = 0, n = skins.length; i < n; i++) { - var skin = skins[i]; - if (skin.name == skinName) return skin; - } - return null; - }; - SkeletonData.prototype.findEvent = function(eventDataName) { - if (eventDataName == null) - throw new Error('eventDataName cannot be null.'); - var events = this.events; - for (var i = 0, n = events.length; i < n; i++) { - var event_4 = events[i]; - if (event_4.name == eventDataName) return event_4; - } - return null; - }; - SkeletonData.prototype.findAnimation = function(animationName) { - if (animationName == null) - throw new Error('animationName cannot be null.'); - var animations = this.animations; - for (var i = 0, n = animations.length; i < n; i++) { - var animation = animations[i]; - if (animation.name == animationName) return animation; - } - return null; - }; - SkeletonData.prototype.findIkConstraint = function(constraintName) { - if (constraintName == null) - throw new Error('constraintName cannot be null.'); - var ikConstraints = this.ikConstraints; - for (var i = 0, n = ikConstraints.length; i < n; i++) { - var constraint = ikConstraints[i]; - if (constraint.name == constraintName) return constraint; - } - return null; - }; - SkeletonData.prototype.findTransformConstraint = function( - constraintName, - ) { - if (constraintName == null) - throw new Error('constraintName cannot be null.'); - var transformConstraints = this.transformConstraints; - for (var i = 0, n = transformConstraints.length; i < n; i++) { - var constraint = transformConstraints[i]; - if (constraint.name == constraintName) return constraint; - } - return null; - }; - SkeletonData.prototype.findPathConstraint = function(constraintName) { - if (constraintName == null) - throw new Error('constraintName cannot be null.'); - var pathConstraints = this.pathConstraints; - for (var i = 0, n = pathConstraints.length; i < n; i++) { - var constraint = pathConstraints[i]; - if (constraint.name == constraintName) return constraint; - } - return null; - }; - SkeletonData.prototype.findPathConstraintIndex = function( - pathConstraintName, - ) { - if (pathConstraintName == null) - throw new Error('pathConstraintName cannot be null.'); - var pathConstraints = this.pathConstraints; - for (var i = 0, n = pathConstraints.length; i < n; i++) - if (pathConstraints[i].name == pathConstraintName) return i; - return -1; - }; - return SkeletonData; - })(); - core.SkeletonData = SkeletonData; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var SkeletonJson = (function() { - function SkeletonJson(attachmentLoader) { - this.scale = 1; - this.linkedMeshes = new Array(); - this.attachmentLoader = attachmentLoader; - } - SkeletonJson.prototype.readSkeletonData = function(json) { - var scale = this.scale; - var skeletonData = new core.SkeletonData(); - var root = typeof json === 'string' ? JSON.parse(json) : json; - var skeletonMap = root.skeleton; - if (skeletonMap != null) { - skeletonData.hash = skeletonMap.hash; - skeletonData.version = skeletonMap.spine; - skeletonData.width = skeletonMap.width; - skeletonData.height = skeletonMap.height; - skeletonData.fps = skeletonMap.fps; - skeletonData.imagesPath = skeletonMap.images; - } - if (root.bones) { - for (var i = 0; i < root.bones.length; i++) { - var boneMap = root.bones[i]; - var parent_2 = null; - var parentName = this.getValue(boneMap, 'parent', null); - if (parentName != null) { - parent_2 = skeletonData.findBone(parentName); - if (parent_2 == null) - throw new Error('Parent bone not found: ' + parentName); - } - var data = new core.BoneData( - skeletonData.bones.length, - boneMap.name, - parent_2, - ); - data.length = this.getValue(boneMap, 'length', 0) * scale; - data.x = this.getValue(boneMap, 'x', 0) * scale; - data.y = this.getValue(boneMap, 'y', 0) * scale; - data.rotation = this.getValue(boneMap, 'rotation', 0); - data.scaleX = this.getValue(boneMap, 'scaleX', 1); - data.scaleY = this.getValue(boneMap, 'scaleY', 1); - data.shearX = this.getValue(boneMap, 'shearX', 0); - data.shearY = this.getValue(boneMap, 'shearY', 0); - data.transformMode = SkeletonJson.transformModeFromString( - this.getValue(boneMap, 'transform', 'normal'), - ); - skeletonData.bones.push(data); - } - } - if (root.slots) { - for (var i = 0; i < root.slots.length; i++) { - var slotMap = root.slots[i]; - var slotName = slotMap.name; - var boneName = slotMap.bone; - var boneData = skeletonData.findBone(boneName); - if (boneData == null) - throw new Error('Slot bone not found: ' + boneName); - var data = new core.SlotData( - skeletonData.slots.length, - slotName, - boneData, - ); - var color = this.getValue(slotMap, 'color', null); - if (color != null) data.color.setFromString(color); - var dark = this.getValue(slotMap, 'dark', null); - if (dark != null) { - data.darkColor = new core.Color(1, 1, 1, 1); - data.darkColor.setFromString(dark); - } - data.attachmentName = this.getValue(slotMap, 'attachment', null); - data.blendMode = SkeletonJson.blendModeFromString( - this.getValue(slotMap, 'blend', 'normal'), - ); - skeletonData.slots.push(data); - } - } - if (root.ik) { - for (var i = 0; i < root.ik.length; i++) { - var constraintMap = root.ik[i]; - var data = new core.IkConstraintData(constraintMap.name); - data.order = this.getValue(constraintMap, 'order', 0); - for (var j = 0; j < constraintMap.bones.length; j++) { - var boneName = constraintMap.bones[j]; - var bone = skeletonData.findBone(boneName); - if (bone == null) - throw new Error('IK bone not found: ' + boneName); - data.bones.push(bone); - } - var targetName = constraintMap.target; - data.target = skeletonData.findBone(targetName); - if (data.target == null) - throw new Error('IK target bone not found: ' + targetName); - data.bendDirection = this.getValue( - constraintMap, - 'bendPositive', - true, - ) - ? 1 - : -1; - data.mix = this.getValue(constraintMap, 'mix', 1); - skeletonData.ikConstraints.push(data); - } - } - if (root.transform) { - for (var i = 0; i < root.transform.length; i++) { - var constraintMap = root.transform[i]; - var data = new core.TransformConstraintData(constraintMap.name); - data.order = this.getValue(constraintMap, 'order', 0); - for (var j = 0; j < constraintMap.bones.length; j++) { - var boneName = constraintMap.bones[j]; - var bone = skeletonData.findBone(boneName); - if (bone == null) - throw new Error( - 'Transform constraint bone not found: ' + boneName, - ); - data.bones.push(bone); - } - var targetName = constraintMap.target; - data.target = skeletonData.findBone(targetName); - if (data.target == null) - throw new Error( - 'Transform constraint target bone not found: ' + targetName, - ); - data.local = this.getValue(constraintMap, 'local', false); - data.relative = this.getValue(constraintMap, 'relative', false); - data.offsetRotation = this.getValue(constraintMap, 'rotation', 0); - data.offsetX = this.getValue(constraintMap, 'x', 0) * scale; - data.offsetY = this.getValue(constraintMap, 'y', 0) * scale; - data.offsetScaleX = this.getValue(constraintMap, 'scaleX', 0); - data.offsetScaleY = this.getValue(constraintMap, 'scaleY', 0); - data.offsetShearY = this.getValue(constraintMap, 'shearY', 0); - data.rotateMix = this.getValue(constraintMap, 'rotateMix', 1); - data.translateMix = this.getValue(constraintMap, 'translateMix', 1); - data.scaleMix = this.getValue(constraintMap, 'scaleMix', 1); - data.shearMix = this.getValue(constraintMap, 'shearMix', 1); - skeletonData.transformConstraints.push(data); - } - } - if (root.path) { - for (var i = 0; i < root.path.length; i++) { - var constraintMap = root.path[i]; - var data = new core.PathConstraintData(constraintMap.name); - data.order = this.getValue(constraintMap, 'order', 0); - for (var j = 0; j < constraintMap.bones.length; j++) { - var boneName = constraintMap.bones[j]; - var bone = skeletonData.findBone(boneName); - if (bone == null) - throw new Error( - 'Transform constraint bone not found: ' + boneName, - ); - data.bones.push(bone); - } - var targetName = constraintMap.target; - data.target = skeletonData.findSlot(targetName); - if (data.target == null) - throw new Error('Path target slot not found: ' + targetName); - data.positionMode = SkeletonJson.positionModeFromString( - this.getValue(constraintMap, 'positionMode', 'percent'), - ); - data.spacingMode = SkeletonJson.spacingModeFromString( - this.getValue(constraintMap, 'spacingMode', 'length'), - ); - data.rotateMode = SkeletonJson.rotateModeFromString( - this.getValue(constraintMap, 'rotateMode', 'tangent'), - ); - data.offsetRotation = this.getValue(constraintMap, 'rotation', 0); - data.position = this.getValue(constraintMap, 'position', 0); - if (data.positionMode == core.PositionMode.Fixed) - data.position *= scale; - data.spacing = this.getValue(constraintMap, 'spacing', 0); - if ( - data.spacingMode == core.SpacingMode.Length || - data.spacingMode == core.SpacingMode.Fixed - ) - data.spacing *= scale; - data.rotateMix = this.getValue(constraintMap, 'rotateMix', 1); - data.translateMix = this.getValue(constraintMap, 'translateMix', 1); - skeletonData.pathConstraints.push(data); - } - } - if (root.skins) { - for (var skinName in root.skins) { - var skinMap = root.skins[skinName]; - var skin = new core.Skin(skinName); - for (var slotName in skinMap) { - var slotIndex = skeletonData.findSlotIndex(slotName); - if (slotIndex == -1) - throw new Error('Slot not found: ' + slotName); - var slotMap = skinMap[slotName]; - for (var entryName in slotMap) { - var attachment = this.readAttachment( - slotMap[entryName], - skin, - slotIndex, - entryName, - skeletonData, - ); - if (attachment != null) - skin.addAttachment(slotIndex, entryName, attachment); - } - } - skeletonData.skins.push(skin); - if (skin.name == 'default') skeletonData.defaultSkin = skin; - } - } - for (var i = 0, n = this.linkedMeshes.length; i < n; i++) { - var linkedMesh = this.linkedMeshes[i]; - var skin = - linkedMesh.skin == null - ? skeletonData.defaultSkin - : skeletonData.findSkin(linkedMesh.skin); - if (skin == null) - throw new Error('Skin not found: ' + linkedMesh.skin); - var parent_3 = skin.getAttachment( - linkedMesh.slotIndex, - linkedMesh.parent, - ); - if (parent_3 == null) - throw new Error('Parent mesh not found: ' + linkedMesh.parent); - linkedMesh.mesh.setParentMesh(parent_3); - } - this.linkedMeshes.length = 0; - if (root.events) { - for (var eventName in root.events) { - var eventMap = root.events[eventName]; - var data = new core.EventData(eventName); - data.intValue = this.getValue(eventMap, 'int', 0); - data.floatValue = this.getValue(eventMap, 'float', 0); - data.stringValue = this.getValue(eventMap, 'string', ''); - data.audioPath = this.getValue(eventMap, 'audio', null); - if (data.audioPath != null) { - data.volume = this.getValue(eventMap, 'volume', 1); - data.balance = this.getValue(eventMap, 'balance', 0); - } - skeletonData.events.push(data); - } - } - if (root.animations) { - for (var animationName in root.animations) { - var animationMap = root.animations[animationName]; - this.readAnimation(animationMap, animationName, skeletonData); - } - } - return skeletonData; - }; - SkeletonJson.prototype.readAttachment = function( - map, - skin, - slotIndex, - name, - skeletonData, - ) { - var scale = this.scale; - name = this.getValue(map, 'name', name); - var type = this.getValue(map, 'type', 'region'); - switch (type) { - case 'region': { - var path = this.getValue(map, 'path', name); - var region = this.attachmentLoader.newRegionAttachment( - skin, - name, - path, - ); - if (region == null) return null; - region.path = path; - region.x = this.getValue(map, 'x', 0) * scale; - region.y = this.getValue(map, 'y', 0) * scale; - region.scaleX = this.getValue(map, 'scaleX', 1); - region.scaleY = this.getValue(map, 'scaleY', 1); - region.rotation = this.getValue(map, 'rotation', 0); - region.width = map.width * scale; - region.height = map.height * scale; - var color = this.getValue(map, 'color', null); - if (color != null) region.color.setFromString(color); - return region; - } - case 'boundingbox': { - var box = this.attachmentLoader.newBoundingBoxAttachment( - skin, - name, - ); - if (box == null) return null; - this.readVertices(map, box, map.vertexCount << 1); - var color = this.getValue(map, 'color', null); - if (color != null) box.color.setFromString(color); - return box; - } - case 'mesh': - case 'linkedmesh': { - var path = this.getValue(map, 'path', name); - var mesh = this.attachmentLoader.newMeshAttachment( - skin, - name, - path, - ); - if (mesh == null) return null; - mesh.path = path; - var color = this.getValue(map, 'color', null); - if (color != null) mesh.color.setFromString(color); - var parent_4 = this.getValue(map, 'parent', null); - if (parent_4 != null) { - mesh.inheritDeform = this.getValue(map, 'deform', true); - this.linkedMeshes.push( - new LinkedMesh( - mesh, - this.getValue(map, 'skin', null), - slotIndex, - parent_4, - ), - ); - return mesh; - } - var uvs = map.uvs; - this.readVertices(map, mesh, uvs.length); - mesh.triangles = map.triangles; - mesh.regionUVs = uvs; - mesh.hullLength = this.getValue(map, 'hull', 0) * 2; - return mesh; - } - case 'path': { - var path = this.attachmentLoader.newPathAttachment(skin, name); - if (path == null) return null; - path.closed = this.getValue(map, 'closed', false); - path.constantSpeed = this.getValue(map, 'constantSpeed', true); - var vertexCount = map.vertexCount; - this.readVertices(map, path, vertexCount << 1); - var lengths = core.Utils.newArray(vertexCount / 3, 0); - for (var i = 0; i < map.lengths.length; i++) - lengths[i] = map.lengths[i] * scale; - path.lengths = lengths; - var color = this.getValue(map, 'color', null); - if (color != null) path.color.setFromString(color); - return path; - } - case 'point': { - var point = this.attachmentLoader.newPointAttachment(skin, name); - if (point == null) return null; - point.x = this.getValue(map, 'x', 0) * scale; - point.y = this.getValue(map, 'y', 0) * scale; - point.rotation = this.getValue(map, 'rotation', 0); - var color = this.getValue(map, 'color', null); - if (color != null) point.color.setFromString(color); - return point; - } - case 'clipping': { - var clip = this.attachmentLoader.newClippingAttachment(skin, name); - if (clip == null) return null; - var end = this.getValue(map, 'end', null); - if (end != null) { - var slot = skeletonData.findSlot(end); - if (slot == null) - throw new Error('Clipping end slot not found: ' + end); - clip.endSlot = slot; - } - var vertexCount = map.vertexCount; - this.readVertices(map, clip, vertexCount << 1); - var color = this.getValue(map, 'color', null); - if (color != null) clip.color.setFromString(color); - return clip; - } - } - return null; - }; - SkeletonJson.prototype.readVertices = function( - map, - attachment, - verticesLength, - ) { - var scale = this.scale; - attachment.worldVerticesLength = verticesLength; - var vertices = map.vertices; - if (verticesLength == vertices.length) { - var scaledVertices = core.Utils.toFloatArray(vertices); - if (scale != 1) { - for (var i = 0, n = vertices.length; i < n; i++) - scaledVertices[i] *= scale; - } - attachment.vertices = scaledVertices; - return; - } - var weights = new Array(); - var bones = new Array(); - for (var i = 0, n = vertices.length; i < n; ) { - var boneCount = vertices[i++]; - bones.push(boneCount); - for (var nn = i + boneCount * 4; i < nn; i += 4) { - bones.push(vertices[i]); - weights.push(vertices[i + 1] * scale); - weights.push(vertices[i + 2] * scale); - weights.push(vertices[i + 3]); - } - } - attachment.bones = bones; - attachment.vertices = core.Utils.toFloatArray(weights); - }; - SkeletonJson.prototype.readAnimation = function(map, name, skeletonData) { - var scale = this.scale; - var timelines = new Array(); - var duration = 0; - if (map.slots) { - for (var slotName in map.slots) { - var slotMap = map.slots[slotName]; - var slotIndex = skeletonData.findSlotIndex(slotName); - if (slotIndex == -1) throw new Error('Slot not found: ' + slotName); - for (var timelineName in slotMap) { - var timelineMap = slotMap[timelineName]; - if (timelineName == 'attachment') { - var timeline = new core.AttachmentTimeline(timelineMap.length); - timeline.slotIndex = slotIndex; - var frameIndex = 0; - for (var i = 0; i < timelineMap.length; i++) { - var valueMap = timelineMap[i]; - timeline.setFrame(frameIndex++, valueMap.time, valueMap.name); - } - timelines.push(timeline); - duration = Math.max( - duration, - timeline.frames[timeline.getFrameCount() - 1], - ); - } else if (timelineName == 'color') { - var timeline = new core.ColorTimeline(timelineMap.length); - timeline.slotIndex = slotIndex; - var frameIndex = 0; - for (var i = 0; i < timelineMap.length; i++) { - var valueMap = timelineMap[i]; - var color = new core.Color(); - color.setFromString(valueMap.color || 'ffffffff'); - timeline.setFrame( - frameIndex, - valueMap.time, - color.r, - color.g, - color.b, - color.a, - ); - this.readCurve(valueMap, timeline, frameIndex); - frameIndex++; - } - timelines.push(timeline); - duration = Math.max( - duration, - timeline.frames[ - (timeline.getFrameCount() - 1) * core.ColorTimeline.ENTRIES - ], - ); - } else if (timelineName == 'twoColor') { - var timeline = new core.TwoColorTimeline(timelineMap.length); - timeline.slotIndex = slotIndex; - var frameIndex = 0; - for (var i = 0; i < timelineMap.length; i++) { - var valueMap = timelineMap[i]; - var light = new core.Color(); - var dark = new core.Color(); - light.setFromString(valueMap.light); - dark.setFromString(valueMap.dark); - timeline.setFrame( - frameIndex, - valueMap.time, - light.r, - light.g, - light.b, - light.a, - dark.r, - dark.g, - dark.b, - ); - this.readCurve(valueMap, timeline, frameIndex); - frameIndex++; - } - timelines.push(timeline); - duration = Math.max( - duration, - timeline.frames[ - (timeline.getFrameCount() - 1) * - core.TwoColorTimeline.ENTRIES - ], - ); - } else - throw new Error( - 'Invalid timeline type for a slot: ' + - timelineName + - ' (' + - slotName + - ')', - ); - } - } - } - if (map.bones) { - for (var boneName in map.bones) { - var boneMap = map.bones[boneName]; - var boneIndex = skeletonData.findBoneIndex(boneName); - if (boneIndex == -1) throw new Error('Bone not found: ' + boneName); - for (var timelineName in boneMap) { - var timelineMap = boneMap[timelineName]; - if (timelineName === 'rotate') { - var timeline = new core.RotateTimeline(timelineMap.length); - timeline.boneIndex = boneIndex; - var frameIndex = 0; - for (var i = 0; i < timelineMap.length; i++) { - var valueMap = timelineMap[i]; - timeline.setFrame(frameIndex, valueMap.time, valueMap.angle); - this.readCurve(valueMap, timeline, frameIndex); - frameIndex++; - } - timelines.push(timeline); - duration = Math.max( - duration, - timeline.frames[ - (timeline.getFrameCount() - 1) * core.RotateTimeline.ENTRIES - ], - ); - } else if ( - timelineName === 'translate' || - timelineName === 'scale' || - timelineName === 'shear' - ) { - var timeline = null; - var timelineScale = 1; - if (timelineName === 'scale') - timeline = new core.ScaleTimeline(timelineMap.length); - else if (timelineName === 'shear') - timeline = new core.ShearTimeline(timelineMap.length); - else { - timeline = new core.TranslateTimeline(timelineMap.length); - timelineScale = scale; - } - timeline.boneIndex = boneIndex; - var frameIndex = 0; - for (var i = 0; i < timelineMap.length; i++) { - var valueMap = timelineMap[i]; - var x = this.getValue(valueMap, 'x', 0), - y = this.getValue(valueMap, 'y', 0); - timeline.setFrame( - frameIndex, - valueMap.time, - x * timelineScale, - y * timelineScale, - ); - this.readCurve(valueMap, timeline, frameIndex); - frameIndex++; - } - timelines.push(timeline); - duration = Math.max( - duration, - timeline.frames[ - (timeline.getFrameCount() - 1) * - core.TranslateTimeline.ENTRIES - ], - ); - } else - throw new Error( - 'Invalid timeline type for a bone: ' + - timelineName + - ' (' + - boneName + - ')', - ); - } - } - } - if (map.ik) { - for (var constraintName in map.ik) { - var constraintMap = map.ik[constraintName]; - var constraint = skeletonData.findIkConstraint(constraintName); - var timeline = new core.IkConstraintTimeline(constraintMap.length); - timeline.ikConstraintIndex = skeletonData.ikConstraints.indexOf( - constraint, - ); - var frameIndex = 0; - for (var i = 0; i < constraintMap.length; i++) { - var valueMap = constraintMap[i]; - timeline.setFrame( - frameIndex, - valueMap.time, - this.getValue(valueMap, 'mix', 1), - this.getValue(valueMap, 'bendPositive', true) ? 1 : -1, - this.getValue(valueMap, 'compress', false), - this.getValue(valueMap, 'stretch', false), - ); - this.readCurve(valueMap, timeline, frameIndex); - frameIndex++; - } - timelines.push(timeline); - duration = Math.max( - duration, - timeline.frames[ - (timeline.getFrameCount() - 1) * - core.IkConstraintTimeline.ENTRIES - ], - ); - } - } - if (map.transform) { - for (var constraintName in map.transform) { - var constraintMap = map.transform[constraintName]; - var constraint = skeletonData.findTransformConstraint( - constraintName, - ); - var timeline = new core.TransformConstraintTimeline( - constraintMap.length, - ); - timeline.transformConstraintIndex = skeletonData.transformConstraints.indexOf( - constraint, - ); - var frameIndex = 0; - for (var i = 0; i < constraintMap.length; i++) { - var valueMap = constraintMap[i]; - timeline.setFrame( - frameIndex, - valueMap.time, - this.getValue(valueMap, 'rotateMix', 1), - this.getValue(valueMap, 'translateMix', 1), - this.getValue(valueMap, 'scaleMix', 1), - this.getValue(valueMap, 'shearMix', 1), - ); - this.readCurve(valueMap, timeline, frameIndex); - frameIndex++; - } - timelines.push(timeline); - duration = Math.max( - duration, - timeline.frames[ - (timeline.getFrameCount() - 1) * - core.TransformConstraintTimeline.ENTRIES - ], - ); - } - } - if (map.paths) { - for (var constraintName in map.paths) { - var constraintMap = map.paths[constraintName]; - var index = skeletonData.findPathConstraintIndex(constraintName); - if (index == -1) - throw new Error('Path constraint not found: ' + constraintName); - var data = skeletonData.pathConstraints[index]; - for (var timelineName in constraintMap) { - var timelineMap = constraintMap[timelineName]; - if (timelineName === 'position' || timelineName === 'spacing') { - var timeline = null; - var timelineScale = 1; - if (timelineName === 'spacing') { - timeline = new core.PathConstraintSpacingTimeline( - timelineMap.length, - ); - if ( - data.spacingMode == core.SpacingMode.Length || - data.spacingMode == core.SpacingMode.Fixed - ) - timelineScale = scale; - } else { - timeline = new core.PathConstraintPositionTimeline( - timelineMap.length, - ); - if (data.positionMode == core.PositionMode.Fixed) - timelineScale = scale; - } - timeline.pathConstraintIndex = index; - var frameIndex = 0; - for (var i = 0; i < timelineMap.length; i++) { - var valueMap = timelineMap[i]; - timeline.setFrame( - frameIndex, - valueMap.time, - this.getValue(valueMap, timelineName, 0) * timelineScale, - ); - this.readCurve(valueMap, timeline, frameIndex); - frameIndex++; - } - timelines.push(timeline); - duration = Math.max( - duration, - timeline.frames[ - (timeline.getFrameCount() - 1) * - core.PathConstraintPositionTimeline.ENTRIES - ], - ); - } else if (timelineName === 'mix') { - var timeline = new core.PathConstraintMixTimeline( - timelineMap.length, - ); - timeline.pathConstraintIndex = index; - var frameIndex = 0; - for (var i = 0; i < timelineMap.length; i++) { - var valueMap = timelineMap[i]; - timeline.setFrame( - frameIndex, - valueMap.time, - this.getValue(valueMap, 'rotateMix', 1), - this.getValue(valueMap, 'translateMix', 1), - ); - this.readCurve(valueMap, timeline, frameIndex); - frameIndex++; - } - timelines.push(timeline); - duration = Math.max( - duration, - timeline.frames[ - (timeline.getFrameCount() - 1) * - core.PathConstraintMixTimeline.ENTRIES - ], - ); - } - } - } - } - if (map.deform) { - for (var deformName in map.deform) { - var deformMap = map.deform[deformName]; - var skin = skeletonData.findSkin(deformName); - if (skin == null) throw new Error('Skin not found: ' + deformName); - for (var slotName in deformMap) { - var slotMap = deformMap[slotName]; - var slotIndex = skeletonData.findSlotIndex(slotName); - if (slotIndex == -1) - throw new Error('Slot not found: ' + slotMap.name); - for (var timelineName in slotMap) { - var timelineMap = slotMap[timelineName]; - var attachment = skin.getAttachment(slotIndex, timelineName); - if (attachment == null) - throw new Error( - 'Deform attachment not found: ' + timelineMap.name, - ); - var weighted = attachment.bones != null; - var vertices = attachment.vertices; - var deformLength = weighted - ? (vertices.length / 3) * 2 - : vertices.length; - var timeline = new core.DeformTimeline(timelineMap.length); - timeline.slotIndex = slotIndex; - timeline.attachment = attachment; - var frameIndex = 0; - for (var j = 0; j < timelineMap.length; j++) { - var valueMap = timelineMap[j]; - var deform = void 0; - var verticesValue = this.getValue(valueMap, 'vertices', null); - if (verticesValue == null) - deform = weighted - ? core.Utils.newFloatArray(deformLength) - : vertices; - else { - deform = core.Utils.newFloatArray(deformLength); - var start = this.getValue(valueMap, 'offset', 0); - core.Utils.arrayCopy( - verticesValue, - 0, - deform, - start, - verticesValue.length, - ); - if (scale != 1) { - for ( - var i = start, n = i + verticesValue.length; - i < n; - i++ - ) - deform[i] *= scale; - } - if (!weighted) { - for (var i = 0; i < deformLength; i++) - deform[i] += vertices[i]; - } - } - timeline.setFrame(frameIndex, valueMap.time, deform); - this.readCurve(valueMap, timeline, frameIndex); - frameIndex++; - } - timelines.push(timeline); - duration = Math.max( - duration, - timeline.frames[timeline.getFrameCount() - 1], - ); - } - } - } - } - var drawOrderNode = map.drawOrder; - if (drawOrderNode == null) drawOrderNode = map.draworder; - if (drawOrderNode != null) { - var timeline = new core.DrawOrderTimeline(drawOrderNode.length); - var slotCount = skeletonData.slots.length; - var frameIndex = 0; - for (var j = 0; j < drawOrderNode.length; j++) { - var drawOrderMap = drawOrderNode[j]; - var drawOrder = null; - var offsets = this.getValue(drawOrderMap, 'offsets', null); - if (offsets != null) { - drawOrder = core.Utils.newArray(slotCount, -1); - var unchanged = core.Utils.newArray( - slotCount - offsets.length, - 0, - ); - var originalIndex = 0, - unchangedIndex = 0; - for (var i = 0; i < offsets.length; i++) { - var offsetMap = offsets[i]; - var slotIndex = skeletonData.findSlotIndex(offsetMap.slot); - if (slotIndex == -1) - throw new Error('Slot not found: ' + offsetMap.slot); - while (originalIndex != slotIndex) - unchanged[unchangedIndex++] = originalIndex++; - drawOrder[originalIndex + offsetMap.offset] = originalIndex++; - } - while (originalIndex < slotCount) - unchanged[unchangedIndex++] = originalIndex++; - for (var i = slotCount - 1; i >= 0; i--) - if (drawOrder[i] == -1) - drawOrder[i] = unchanged[--unchangedIndex]; - } - timeline.setFrame(frameIndex++, drawOrderMap.time, drawOrder); - } - timelines.push(timeline); - duration = Math.max( - duration, - timeline.frames[timeline.getFrameCount() - 1], - ); - } - if (map.events) { - var timeline = new core.EventTimeline(map.events.length); - var frameIndex = 0; - for (var i = 0; i < map.events.length; i++) { - var eventMap = map.events[i]; - var eventData = skeletonData.findEvent(eventMap.name); - if (eventData == null) - throw new Error('Event not found: ' + eventMap.name); - var event_5 = new core.Event( - core.Utils.toSinglePrecision(eventMap.time), - eventData, - ); - event_5.intValue = this.getValue( - eventMap, - 'int', - eventData.intValue, - ); - event_5.floatValue = this.getValue( - eventMap, - 'float', - eventData.floatValue, - ); - event_5.stringValue = this.getValue( - eventMap, - 'string', - eventData.stringValue, - ); - if (event_5.data.audioPath != null) { - event_5.volume = this.getValue(eventMap, 'volume', 1); - event_5.balance = this.getValue(eventMap, 'balance', 0); - } - timeline.setFrame(frameIndex++, event_5); - } - timelines.push(timeline); - duration = Math.max( - duration, - timeline.frames[timeline.getFrameCount() - 1], - ); - } - if (isNaN(duration)) { - throw new Error('Error while parsing animation, duration is NaN'); - } - skeletonData.animations.push( - new core.Animation(name, timelines, duration), - ); - }; - SkeletonJson.prototype.readCurve = function(map, timeline, frameIndex) { - if (!map.curve) return; - if (map.curve === 'stepped') timeline.setStepped(frameIndex); - else if ( - Object.prototype.toString.call(map.curve) === '[object Array]' - ) { - var curve = map.curve; - timeline.setCurve(frameIndex, curve[0], curve[1], curve[2], curve[3]); - } - }; - SkeletonJson.prototype.getValue = function(map, prop, defaultValue) { - return map[prop] !== undefined ? map[prop] : defaultValue; - }; - SkeletonJson.blendModeFromString = function(str) { - str = str.toLowerCase(); - if (str == 'normal') return core.BlendMode.Normal; - if (str == 'additive') return core.BlendMode.Additive; - if (str == 'multiply') return core.BlendMode.Multiply; - if (str == 'screen') return core.BlendMode.Screen; - throw new Error('Unknown blend mode: ' + str); - }; - SkeletonJson.positionModeFromString = function(str) { - str = str.toLowerCase(); - if (str == 'fixed') return core.PositionMode.Fixed; - if (str == 'percent') return core.PositionMode.Percent; - throw new Error('Unknown position mode: ' + str); - }; - SkeletonJson.spacingModeFromString = function(str) { - str = str.toLowerCase(); - if (str == 'length') return core.SpacingMode.Length; - if (str == 'fixed') return core.SpacingMode.Fixed; - if (str == 'percent') return core.SpacingMode.Percent; - throw new Error('Unknown position mode: ' + str); - }; - SkeletonJson.rotateModeFromString = function(str) { - str = str.toLowerCase(); - if (str == 'tangent') return core.RotateMode.Tangent; - if (str == 'chain') return core.RotateMode.Chain; - if (str == 'chainscale') return core.RotateMode.ChainScale; - throw new Error('Unknown rotate mode: ' + str); - }; - SkeletonJson.transformModeFromString = function(str) { - str = str.toLowerCase(); - if (str == 'normal') return core.TransformMode.Normal; - if (str == 'onlytranslation') return core.TransformMode.OnlyTranslation; - if (str == 'norotationorreflection') - return core.TransformMode.NoRotationOrReflection; - if (str == 'noscale') return core.TransformMode.NoScale; - if (str == 'noscaleorreflection') - return core.TransformMode.NoScaleOrReflection; - throw new Error('Unknown transform mode: ' + str); - }; - return SkeletonJson; - })(); - core.SkeletonJson = SkeletonJson; - var LinkedMesh = (function() { - function LinkedMesh(mesh, skin, slotIndex, parent) { - this.mesh = mesh; - this.skin = skin; - this.slotIndex = slotIndex; - this.parent = parent; - } - return LinkedMesh; - })(); - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var Skin = (function() { - function Skin(name) { - this.attachments = new Array(); - if (name == null) throw new Error('name cannot be null.'); - this.name = name; - } - Skin.prototype.addAttachment = function(slotIndex, name, attachment) { - if (attachment == null) throw new Error('attachment cannot be null.'); - var attachments = this.attachments; - if (slotIndex >= attachments.length) attachments.length = slotIndex + 1; - if (!attachments[slotIndex]) attachments[slotIndex] = {}; - attachments[slotIndex][name] = attachment; - }; - Skin.prototype.getAttachment = function(slotIndex, name) { - var dictionary = this.attachments[slotIndex]; - return dictionary ? dictionary[name] : null; - }; - Skin.prototype.attachAll = function(skeleton, oldSkin) { - var slotIndex = 0; - for (var i = 0; i < skeleton.slots.length; i++) { - var slot = skeleton.slots[i]; - var slotAttachment = slot.getAttachment(); - if (slotAttachment && slotIndex < oldSkin.attachments.length) { - var dictionary = oldSkin.attachments[slotIndex]; - for (var key in dictionary) { - var skinAttachment = dictionary[key]; - if (slotAttachment == skinAttachment) { - var attachment = this.getAttachment(slotIndex, key); - if (attachment != null) slot.setAttachment(attachment); - break; - } - } - } - slotIndex++; - } - }; - return Skin; - })(); - core.Skin = Skin; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var Slot = (function() { - function Slot(data, bone) { - this.attachmentVertices = new Array(); - if (data == null) throw new Error('data cannot be null.'); - if (bone == null) throw new Error('bone cannot be null.'); - this.data = data; - this.bone = bone; - this.color = new core.Color(); - this.darkColor = data.darkColor == null ? null : new core.Color(); - this.setToSetupPose(); - this.blendMode = this.data.blendMode; - } - Slot.prototype.getAttachment = function() { - return this.attachment; - }; - Slot.prototype.setAttachment = function(attachment) { - if (this.attachment == attachment) return; - this.attachment = attachment; - this.attachmentTime = this.bone.skeleton.time; - this.attachmentVertices.length = 0; - }; - Slot.prototype.setAttachmentTime = function(time) { - this.attachmentTime = this.bone.skeleton.time - time; - }; - Slot.prototype.getAttachmentTime = function() { - return this.bone.skeleton.time - this.attachmentTime; - }; - Slot.prototype.setToSetupPose = function() { - this.color.setFromColor(this.data.color); - if (this.darkColor != null) - this.darkColor.setFromColor(this.data.darkColor); - if (this.data.attachmentName == null) this.attachment = null; - else { - this.attachment = null; - this.setAttachment( - this.bone.skeleton.getAttachment( - this.data.index, - this.data.attachmentName, - ), - ); - } - }; - return Slot; - })(); - core.Slot = Slot; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var SlotData = (function() { - function SlotData(index, name, boneData) { - this.color = new core.Color(1, 1, 1, 1); - if (index < 0) throw new Error('index must be >= 0.'); - if (name == null) throw new Error('name cannot be null.'); - if (boneData == null) throw new Error('boneData cannot be null.'); - this.index = index; - this.name = name; - this.boneData = boneData; - } - return SlotData; - })(); - core.SlotData = SlotData; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var Texture = (function() { - function Texture(image) { - this._image = image; - } - Texture.prototype.getImage = function() { - return this._image; - }; - Texture.filterFromString = function(text) { - switch (text.toLowerCase()) { - case 'nearest': - return TextureFilter.Nearest; - case 'linear': - return TextureFilter.Linear; - case 'mipmap': - return TextureFilter.MipMap; - case 'mipmapnearestnearest': - return TextureFilter.MipMapNearestNearest; - case 'mipmaplinearnearest': - return TextureFilter.MipMapLinearNearest; - case 'mipmapnearestlinear': - return TextureFilter.MipMapNearestLinear; - case 'mipmaplinearlinear': - return TextureFilter.MipMapLinearLinear; - default: - throw new Error('Unknown texture filter ' + text); - } - }; - Texture.wrapFromString = function(text) { - switch (text.toLowerCase()) { - case 'mirroredtepeat': - return TextureWrap.MirroredRepeat; - case 'clamptoedge': - return TextureWrap.ClampToEdge; - case 'repeat': - return TextureWrap.Repeat; - default: - throw new Error('Unknown texture wrap ' + text); - } - }; - return Texture; - })(); - core.Texture = Texture; - var TextureFilter; - (function(TextureFilter) { - TextureFilter[(TextureFilter['Nearest'] = 9728)] = 'Nearest'; - TextureFilter[(TextureFilter['Linear'] = 9729)] = 'Linear'; - TextureFilter[(TextureFilter['MipMap'] = 9987)] = 'MipMap'; - TextureFilter[(TextureFilter['MipMapNearestNearest'] = 9984)] = - 'MipMapNearestNearest'; - TextureFilter[(TextureFilter['MipMapLinearNearest'] = 9985)] = - 'MipMapLinearNearest'; - TextureFilter[(TextureFilter['MipMapNearestLinear'] = 9986)] = - 'MipMapNearestLinear'; - TextureFilter[(TextureFilter['MipMapLinearLinear'] = 9987)] = - 'MipMapLinearLinear'; - })((TextureFilter = core.TextureFilter || (core.TextureFilter = {}))); - var TextureWrap; - (function(TextureWrap) { - TextureWrap[(TextureWrap['MirroredRepeat'] = 33648)] = 'MirroredRepeat'; - TextureWrap[(TextureWrap['ClampToEdge'] = 33071)] = 'ClampToEdge'; - TextureWrap[(TextureWrap['Repeat'] = 10497)] = 'Repeat'; - })((TextureWrap = core.TextureWrap || (core.TextureWrap = {}))); - var TextureRegion = (function() { - function TextureRegion() { - this.size = null; - } - Object.defineProperty(TextureRegion.prototype, 'width', { - get: function() { - var tex = this.texture; - if (PIXI.VERSION[0] == '3') { - return tex.crop.width; - } - if (tex.trim) { - return tex.trim.width; - } - return tex.orig.width; - }, - enumerable: true, - configurable: true, - }); - Object.defineProperty(TextureRegion.prototype, 'height', { - get: function() { - var tex = this.texture; - if (PIXI.VERSION[0] == '3') { - return tex.crop.height; - } - if (tex.trim) { - return tex.trim.height; - } - return tex.orig.height; - }, - enumerable: true, - configurable: true, - }); - Object.defineProperty(TextureRegion.prototype, 'u', { - get: function() { - return this.texture._uvs.x0; - }, - enumerable: true, - configurable: true, - }); - Object.defineProperty(TextureRegion.prototype, 'v', { - get: function() { - return this.texture._uvs.y0; - }, - enumerable: true, - configurable: true, - }); - Object.defineProperty(TextureRegion.prototype, 'u2', { - get: function() { - return this.texture._uvs.x2; - }, - enumerable: true, - configurable: true, - }); - Object.defineProperty(TextureRegion.prototype, 'v2', { - get: function() { - return this.texture._uvs.y2; - }, - enumerable: true, - configurable: true, - }); - Object.defineProperty(TextureRegion.prototype, 'offsetX', { - get: function() { - var tex = this.texture; - return tex.trim ? tex.trim.x : 0; - }, - enumerable: true, - configurable: true, - }); - Object.defineProperty(TextureRegion.prototype, 'offsetY', { - get: function() { - console.warn( - 'Deprecation Warning: @Hackerham: I guess, if you are using PIXI-SPINE ATLAS region.offsetY, you want a texture, right? Use region.texture from now on.', - ); - return this.spineOffsetY; - }, - enumerable: true, - configurable: true, - }); - Object.defineProperty(TextureRegion.prototype, 'pixiOffsetY', { - get: function() { - var tex = this.texture; - return tex.trim ? tex.trim.y : 0; - }, - enumerable: true, - configurable: true, - }); - Object.defineProperty(TextureRegion.prototype, 'spineOffsetY', { - get: function() { - var tex = this.texture; - return ( - this.originalHeight - this.height - (tex.trim ? tex.trim.y : 0) - ); - }, - enumerable: true, - configurable: true, - }); - Object.defineProperty(TextureRegion.prototype, 'originalWidth', { - get: function() { - var tex = this.texture; - if (PIXI.VERSION[0] == '3') { - if (tex.trim) { - return tex.trim.width; - } - return tex.crop.width; - } - return tex.orig.width; - }, - enumerable: true, - configurable: true, - }); - Object.defineProperty(TextureRegion.prototype, 'originalHeight', { - get: function() { - var tex = this.texture; - if (PIXI.VERSION[0] == '3') { - if (tex.trim) { - return tex.trim.height; - } - return tex.crop.height; - } - return tex.orig.height; - }, - enumerable: true, - configurable: true, - }); - Object.defineProperty(TextureRegion.prototype, 'x', { - get: function() { - return this.texture.frame.x; - }, - enumerable: true, - configurable: true, - }); - Object.defineProperty(TextureRegion.prototype, 'y', { - get: function() { - return this.texture.frame.y; - }, - enumerable: true, - configurable: true, - }); - Object.defineProperty(TextureRegion.prototype, 'rotate', { - get: function() { - return this.texture.rotate !== 0; - }, - enumerable: true, - configurable: true, - }); - return TextureRegion; - })(); - core.TextureRegion = TextureRegion; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var TextureAtlas = (function() { - function TextureAtlas(atlasText, textureLoader, callback) { - this.pages = new Array(); - this.regions = new Array(); - if (atlasText) { - this.addSpineAtlas(atlasText, textureLoader, callback); - } - } - TextureAtlas.prototype.addTexture = function(name, texture) { - var pages = this.pages; - var page = null; - for (var i = 0; i < pages.length; i++) { - if (pages[i].baseTexture === texture.baseTexture) { - page = pages[i]; - break; - } - } - if (page === null) { - page = new TextureAtlasPage(); - page.name = 'texturePage'; - var baseTexture = texture.baseTexture; - page.width = baseTexture.realWidth; - page.height = baseTexture.realHeight; - page.baseTexture = baseTexture; - page.minFilter = page.magFilter = core.TextureFilter.Nearest; - page.uWrap = core.TextureWrap.ClampToEdge; - page.vWrap = core.TextureWrap.ClampToEdge; - pages.push(page); - } - var region = new TextureAtlasRegion(); - region.name = name; - region.page = page; - region.texture = texture; - region.index = -1; - this.regions.push(region); - return region; - }; - TextureAtlas.prototype.addTextureHash = function( - textures, - stripExtension, - ) { - for (var key in textures) { - if (textures.hasOwnProperty(key)) { - this.addTexture( - stripExtension && key.indexOf('.') !== -1 - ? key.substr(0, key.lastIndexOf('.')) - : key, - textures[key], - ); - } - } - }; - TextureAtlas.prototype.addSpineAtlas = function( - atlasText, - textureLoader, - callback, - ) { - return this.load(atlasText, textureLoader, callback); - }; - TextureAtlas.prototype.load = function( - atlasText, - textureLoader, - callback, - ) { - var _this = this; - if (textureLoader == null) - throw new Error('textureLoader cannot be null.'); - var reader = new TextureAtlasReader(atlasText); - var tuple = new Array(4); - var page = null; - var iterateParser = function() { - while (true) { - var line = reader.readLine(); - if (line == null) { - return callback && callback(_this); - } - line = line.trim(); - if (line.length == 0) page = null; - else if (!page) { - page = new TextureAtlasPage(); - page.name = line; - if (reader.readTuple(tuple) == 2) { - page.width = parseInt(tuple[0]); - page.height = parseInt(tuple[1]); - reader.readTuple(tuple); - } - reader.readTuple(tuple); - page.minFilter = core.Texture.filterFromString(tuple[0]); - page.magFilter = core.Texture.filterFromString(tuple[1]); - var direction = reader.readValue(); - page.uWrap = core.TextureWrap.ClampToEdge; - page.vWrap = core.TextureWrap.ClampToEdge; - if (direction == 'x') page.uWrap = core.TextureWrap.Repeat; - else if (direction == 'y') page.vWrap = core.TextureWrap.Repeat; - else if (direction == 'xy') - page.uWrap = page.vWrap = core.TextureWrap.Repeat; - textureLoader(line, function(texture) { - if (texture === null) { - _this.pages.splice(_this.pages.indexOf(page), 1); - return callback && callback(null); - } - page.baseTexture = texture; - if (!texture.hasLoaded) { - texture.width = page.width; - texture.height = page.height; - } - _this.pages.push(page); - page.setFilters(); - if (!page.width || !page.height) { - page.width = texture.realWidth; - page.height = texture.realHeight; - if (!page.width || !page.height) { - console.log( - 'ERROR spine atlas page ' + - page.name + - ': meshes wont work if you dont specify size in atlas (http://www.html5gamedevs.com/topic/18888-pixi-spines-and-meshes/?p=107121)', - ); - } - } - iterateParser(); - }); - _this.pages.push(page); - break; - } else { - var region = new TextureAtlasRegion(); - region.name = line; - region.page = page; - var rotate = reader.readValue() == 'true' ? 6 : 0; - reader.readTuple(tuple); - var x = parseInt(tuple[0]); - var y = parseInt(tuple[1]); - reader.readTuple(tuple); - var width = parseInt(tuple[0]); - var height = parseInt(tuple[1]); - var resolution = page.baseTexture.resolution; - x /= resolution; - y /= resolution; - width /= resolution; - height /= resolution; - var frame = new PIXI.Rectangle( - x, - y, - rotate ? height : width, - rotate ? width : height, - ); - if (reader.readTuple(tuple) == 4) { - if (reader.readTuple(tuple) == 4) { - reader.readTuple(tuple); - } - } - var originalWidth = parseInt(tuple[0]) / resolution; - var originalHeight = parseInt(tuple[1]) / resolution; - reader.readTuple(tuple); - var offsetX = parseInt(tuple[0]) / resolution; - var offsetY = parseInt(tuple[1]) / resolution; - var orig = new PIXI.Rectangle( - 0, - 0, - originalWidth, - originalHeight, - ); - var trim = new PIXI.Rectangle( - offsetX, - originalHeight - height - offsetY, - width, - height, - ); - if (PIXI.VERSION[0] != '3') { - region.texture = new PIXI.Texture( - region.page.baseTexture, - frame, - orig, - trim, - rotate, - ); - } else { - var frame2 = new PIXI.Rectangle(x, y, width, height); - var crop = frame2.clone(); - trim.width = originalWidth; - trim.height = originalHeight; - region.texture = new PIXI.Texture( - region.page.baseTexture, - frame2, - crop, - trim, - rotate, - ); - } - region.index = parseInt(reader.readValue()); - region.texture._updateUvs(); - _this.regions.push(region); - } - } - }; - iterateParser(); - }; - TextureAtlas.prototype.findRegion = function(name) { - for (var i = 0; i < this.regions.length; i++) { - if (this.regions[i].name == name) { - return this.regions[i]; - } - } - return null; - }; - TextureAtlas.prototype.dispose = function() { - for (var i = 0; i < this.pages.length; i++) { - this.pages[i].baseTexture.dispose(); - } - }; - return TextureAtlas; - })(); - core.TextureAtlas = TextureAtlas; - var TextureAtlasReader = (function() { - function TextureAtlasReader(text) { - this.index = 0; - this.lines = text.split(/\r\n|\r|\n/); - } - TextureAtlasReader.prototype.readLine = function() { - if (this.index >= this.lines.length) return null; - return this.lines[this.index++]; - }; - TextureAtlasReader.prototype.readValue = function() { - var line = this.readLine(); - var colon = line.indexOf(':'); - if (colon == -1) throw new Error('Invalid line: ' + line); - return line.substring(colon + 1).trim(); - }; - TextureAtlasReader.prototype.readTuple = function(tuple) { - var line = this.readLine(); - var colon = line.indexOf(':'); - if (colon == -1) throw new Error('Invalid line: ' + line); - var i = 0, - lastMatch = colon + 1; - for (; i < 3; i++) { - var comma = line.indexOf(',', lastMatch); - if (comma == -1) break; - tuple[i] = line.substr(lastMatch, comma - lastMatch).trim(); - lastMatch = comma + 1; - } - tuple[i] = line.substring(lastMatch).trim(); - return i + 1; - }; - return TextureAtlasReader; - })(); - var TextureAtlasPage = (function() { - function TextureAtlasPage() {} - TextureAtlasPage.prototype.setFilters = function() { - var tex = this.baseTexture; - var filter = this.minFilter; - if (filter == core.TextureFilter.Linear) { - tex.scaleMode = PIXI.SCALE_MODES.LINEAR; - } else if (this.minFilter == core.TextureFilter.Nearest) { - tex.scaleMode = PIXI.SCALE_MODES.NEAREST; - } else { - tex.mipmap = true; - if (filter == core.TextureFilter.MipMapNearestNearest) { - tex.scaleMode = PIXI.SCALE_MODES.NEAREST; - } else { - tex.scaleMode = PIXI.SCALE_MODES.LINEAR; - } - } - }; - return TextureAtlasPage; - })(); - core.TextureAtlasPage = TextureAtlasPage; - var TextureAtlasRegion = (function(_super) { - __extends(TextureAtlasRegion, _super); - function TextureAtlasRegion() { - return (_super !== null && _super.apply(this, arguments)) || this; - } - return TextureAtlasRegion; - })(core.TextureRegion); - core.TextureAtlasRegion = TextureAtlasRegion; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var TransformConstraint = (function() { - function TransformConstraint(data, skeleton) { - this.rotateMix = 0; - this.translateMix = 0; - this.scaleMix = 0; - this.shearMix = 0; - this.temp = new core.Vector2(); - if (data == null) throw new Error('data cannot be null.'); - if (skeleton == null) throw new Error('skeleton cannot be null.'); - this.data = data; - this.rotateMix = data.rotateMix; - this.translateMix = data.translateMix; - this.scaleMix = data.scaleMix; - this.shearMix = data.shearMix; - this.bones = new Array(); - for (var i = 0; i < data.bones.length; i++) - this.bones.push(skeleton.findBone(data.bones[i].name)); - this.target = skeleton.findBone(data.target.name); - } - TransformConstraint.prototype.apply = function() { - this.update(); - }; - TransformConstraint.prototype.update = function() { - if (this.data.local) { - if (this.data.relative) this.applyRelativeLocal(); - else this.applyAbsoluteLocal(); - } else { - if (this.data.relative) this.applyRelativeWorld(); - else this.applyAbsoluteWorld(); - } - }; - TransformConstraint.prototype.applyAbsoluteWorld = function() { - var rotateMix = this.rotateMix, - translateMix = this.translateMix, - scaleMix = this.scaleMix, - shearMix = this.shearMix; - var target = this.target; - var targetMat = target.matrix; - var ta = targetMat.a, - tb = targetMat.c, - tc = targetMat.b, - td = targetMat.d; - var degRadReflect = - ta * td - tb * tc > 0 - ? core.MathUtils.degRad - : -core.MathUtils.degRad; - var offsetRotation = this.data.offsetRotation * degRadReflect; - var offsetShearY = this.data.offsetShearY * degRadReflect; - var bones = this.bones; - for (var i = 0, n = bones.length; i < n; i++) { - var bone = bones[i]; - var modified = false; - var mat = bone.matrix; - if (rotateMix != 0) { - var a = mat.a, - b = mat.c, - c = mat.b, - d = mat.d; - var r = Math.atan2(tc, ta) - Math.atan2(c, a) + offsetRotation; - if (r > core.MathUtils.PI) r -= core.MathUtils.PI2; - else if (r < -core.MathUtils.PI) r += core.MathUtils.PI2; - r *= rotateMix; - var cos = Math.cos(r), - sin = Math.sin(r); - mat.a = cos * a - sin * c; - mat.c = cos * b - sin * d; - mat.b = sin * a + cos * c; - mat.d = sin * b + cos * d; - modified = true; - } - if (translateMix != 0) { - var temp = this.temp; - target.localToWorld(temp.set(this.data.offsetX, this.data.offsetY)); - mat.tx += (temp.x - mat.tx) * translateMix; - mat.ty += (temp.y - mat.ty) * translateMix; - modified = true; - } - if (scaleMix > 0) { - var s = Math.sqrt(mat.a * mat.a + mat.b * mat.b); - var ts = Math.sqrt(ta * ta + tc * tc); - if (s > 0.00001) - s = (s + (ts - s + this.data.offsetScaleX) * scaleMix) / s; - mat.a *= s; - mat.b *= s; - s = Math.sqrt(mat.c * mat.c + mat.d * mat.d); - ts = Math.sqrt(tb * tb + td * td); - if (s > 0.00001) - s = (s + (ts - s + this.data.offsetScaleY) * scaleMix) / s; - mat.c *= s; - mat.d *= s; - modified = true; - } - if (shearMix > 0) { - var b = mat.c, - d = mat.d; - var by = Math.atan2(d, b); - var r = - Math.atan2(td, tb) - - Math.atan2(tc, ta) - - (by - Math.atan2(mat.b, mat.a)); - if (r > core.MathUtils.PI) r -= core.MathUtils.PI2; - else if (r < -core.MathUtils.PI) r += core.MathUtils.PI2; - r = by + (r + offsetShearY) * shearMix; - var s = Math.sqrt(b * b + d * d); - mat.c = Math.cos(r) * s; - mat.d = Math.sin(r) * s; - modified = true; - } - if (modified) bone.appliedValid = false; - } - }; - TransformConstraint.prototype.applyRelativeWorld = function() { - var rotateMix = this.rotateMix, - translateMix = this.translateMix, - scaleMix = this.scaleMix, - shearMix = this.shearMix; - var target = this.target; - var targetMat = target.matrix; - var ta = targetMat.a, - tb = targetMat.c, - tc = targetMat.b, - td = targetMat.d; - var degRadReflect = - ta * td - tb * tc > 0 - ? core.MathUtils.degRad - : -core.MathUtils.degRad; - var offsetRotation = this.data.offsetRotation * degRadReflect, - offsetShearY = this.data.offsetShearY * degRadReflect; - var bones = this.bones; - for (var i = 0, n = bones.length; i < n; i++) { - var bone = bones[i]; - var modified = false; - var mat = bone.matrix; - if (rotateMix != 0) { - var a = mat.a, - b = mat.c, - c = mat.b, - d = mat.d; - var r = Math.atan2(tc, ta) + offsetRotation; - if (r > core.MathUtils.PI) r -= core.MathUtils.PI2; - else if (r < -core.MathUtils.PI) r += core.MathUtils.PI2; - r *= rotateMix; - var cos = Math.cos(r), - sin = Math.sin(r); - mat.a = cos * a - sin * c; - mat.c = cos * b - sin * d; - mat.b = sin * a + cos * c; - mat.d = sin * b + cos * d; - modified = true; - } - if (translateMix != 0) { - var temp = this.temp; - target.localToWorld(temp.set(this.data.offsetX, this.data.offsetY)); - mat.tx += temp.x * translateMix; - mat.ty += temp.y * translateMix; - modified = true; - } - if (scaleMix > 0) { - var s = - (Math.sqrt(ta * ta + tc * tc) - 1 + this.data.offsetScaleX) * - scaleMix + - 1; - mat.a *= s; - mat.b *= s; - s = - (Math.sqrt(tb * tb + td * td) - 1 + this.data.offsetScaleY) * - scaleMix + - 1; - mat.c *= s; - mat.d *= s; - modified = true; - } - if (shearMix > 0) { - var r = Math.atan2(td, tb) - Math.atan2(tc, ta); - if (r > core.MathUtils.PI) r -= core.MathUtils.PI2; - else if (r < -core.MathUtils.PI) r += core.MathUtils.PI2; - var b = mat.c, - d = mat.d; - r = - Math.atan2(d, b) + - (r - core.MathUtils.PI / 2 + offsetShearY) * shearMix; - var s = Math.sqrt(b * b + d * d); - mat.c = Math.cos(r) * s; - mat.d = Math.sin(r) * s; - modified = true; - } - if (modified) bone.appliedValid = false; - } - }; - TransformConstraint.prototype.applyAbsoluteLocal = function() { - var rotateMix = this.rotateMix, - translateMix = this.translateMix, - scaleMix = this.scaleMix, - shearMix = this.shearMix; - var target = this.target; - if (!target.appliedValid) target.updateAppliedTransform(); - var bones = this.bones; - for (var i = 0, n = bones.length; i < n; i++) { - var bone = bones[i]; - if (!bone.appliedValid) bone.updateAppliedTransform(); - var rotation = bone.arotation; - if (rotateMix != 0) { - var r = target.arotation - rotation + this.data.offsetRotation; - r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; - rotation += r * rotateMix; - } - var x = bone.ax, - y = bone.ay; - if (translateMix != 0) { - x += (target.ax - x + this.data.offsetX) * translateMix; - y += (target.ay - y + this.data.offsetY) * translateMix; - } - var scaleX = bone.ascaleX, - scaleY = bone.ascaleY; - if (scaleMix > 0) { - if (scaleX > 0.00001) - scaleX = - (scaleX + - (target.ascaleX - scaleX + this.data.offsetScaleX) * - scaleMix) / - scaleX; - if (scaleY > 0.00001) - scaleY = - (scaleY + - (target.ascaleY - scaleY + this.data.offsetScaleY) * - scaleMix) / - scaleY; - } - var shearY = bone.ashearY; - if (shearMix > 0) { - var r = target.ashearY - shearY + this.data.offsetShearY; - r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; - bone.shearY += r * shearMix; - } - bone.updateWorldTransformWith( - x, - y, - rotation, - scaleX, - scaleY, - bone.ashearX, - shearY, - ); - } - }; - TransformConstraint.prototype.applyRelativeLocal = function() { - var rotateMix = this.rotateMix, - translateMix = this.translateMix, - scaleMix = this.scaleMix, - shearMix = this.shearMix; - var target = this.target; - if (!target.appliedValid) target.updateAppliedTransform(); - var bones = this.bones; - for (var i = 0, n = bones.length; i < n; i++) { - var bone = bones[i]; - if (!bone.appliedValid) bone.updateAppliedTransform(); - var rotation = bone.arotation; - if (rotateMix != 0) - rotation += - (target.arotation + this.data.offsetRotation) * rotateMix; - var x = bone.ax, - y = bone.ay; - if (translateMix != 0) { - x += (target.ax + this.data.offsetX) * translateMix; - y += (target.ay + this.data.offsetY) * translateMix; - } - var scaleX = bone.ascaleX, - scaleY = bone.ascaleY; - if (scaleMix > 0) { - if (scaleX > 0.00001) - scaleX *= - (target.ascaleX - 1 + this.data.offsetScaleX) * scaleMix + 1; - if (scaleY > 0.00001) - scaleY *= - (target.ascaleY - 1 + this.data.offsetScaleY) * scaleMix + 1; - } - var shearY = bone.ashearY; - if (shearMix > 0) - shearY += (target.ashearY + this.data.offsetShearY) * shearMix; - bone.updateWorldTransformWith( - x, - y, - rotation, - scaleX, - scaleY, - bone.ashearX, - shearY, - ); - } - }; - TransformConstraint.prototype.getOrder = function() { - return this.data.order; - }; - return TransformConstraint; - })(); - core.TransformConstraint = TransformConstraint; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var TransformConstraintData = (function() { - function TransformConstraintData(name) { - this.order = 0; - this.bones = new Array(); - this.rotateMix = 0; - this.translateMix = 0; - this.scaleMix = 0; - this.shearMix = 0; - this.offsetRotation = 0; - this.offsetX = 0; - this.offsetY = 0; - this.offsetScaleX = 0; - this.offsetScaleY = 0; - this.offsetShearY = 0; - this.relative = false; - this.local = false; - if (name == null) throw new Error('name cannot be null.'); - this.name = name; - } - return TransformConstraintData; - })(); - core.TransformConstraintData = TransformConstraintData; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var Triangulator = (function() { - function Triangulator() { - this.convexPolygons = new Array(); - this.convexPolygonsIndices = new Array(); - this.indicesArray = new Array(); - this.isConcaveArray = new Array(); - this.triangles = new Array(); - this.polygonPool = new core.Pool(function() { - return new Array(); - }); - this.polygonIndicesPool = new core.Pool(function() { - return new Array(); - }); - } - Triangulator.prototype.triangulate = function(verticesArray) { - var vertices = verticesArray; - var vertexCount = verticesArray.length >> 1; - var indices = this.indicesArray; - indices.length = 0; - for (var i = 0; i < vertexCount; i++) indices[i] = i; - var isConcave = this.isConcaveArray; - isConcave.length = 0; - for (var i = 0, n = vertexCount; i < n; ++i) - isConcave[i] = Triangulator.isConcave( - i, - vertexCount, - vertices, - indices, - ); - var triangles = this.triangles; - triangles.length = 0; - while (vertexCount > 3) { - var previous = vertexCount - 1, - i = 0, - next = 1; - while (true) { - outer: if (!isConcave[i]) { - var p1 = indices[previous] << 1, - p2 = indices[i] << 1, - p3 = indices[next] << 1; - var p1x = vertices[p1], - p1y = vertices[p1 + 1]; - var p2x = vertices[p2], - p2y = vertices[p2 + 1]; - var p3x = vertices[p3], - p3y = vertices[p3 + 1]; - for ( - var ii = (next + 1) % vertexCount; - ii != previous; - ii = (ii + 1) % vertexCount - ) { - if (!isConcave[ii]) continue; - var v = indices[ii] << 1; - var vx = vertices[v], - vy = vertices[v + 1]; - if (Triangulator.positiveArea(p3x, p3y, p1x, p1y, vx, vy)) { - if (Triangulator.positiveArea(p1x, p1y, p2x, p2y, vx, vy)) { - if (Triangulator.positiveArea(p2x, p2y, p3x, p3y, vx, vy)) - break outer; - } - } - } - break; - } - if (next == 0) { - do { - if (!isConcave[i]) break; - i--; - } while (i > 0); - break; - } - previous = i; - i = next; - next = (next + 1) % vertexCount; - } - triangles.push(indices[(vertexCount + i - 1) % vertexCount]); - triangles.push(indices[i]); - triangles.push(indices[(i + 1) % vertexCount]); - indices.splice(i, 1); - isConcave.splice(i, 1); - vertexCount--; - var previousIndex = (vertexCount + i - 1) % vertexCount; - var nextIndex = i == vertexCount ? 0 : i; - isConcave[previousIndex] = Triangulator.isConcave( - previousIndex, - vertexCount, - vertices, - indices, - ); - isConcave[nextIndex] = Triangulator.isConcave( - nextIndex, - vertexCount, - vertices, - indices, - ); - } - if (vertexCount == 3) { - triangles.push(indices[2]); - triangles.push(indices[0]); - triangles.push(indices[1]); - } - return triangles; - }; - Triangulator.prototype.decompose = function(verticesArray, triangles) { - var vertices = verticesArray; - var convexPolygons = this.convexPolygons; - this.polygonPool.freeAll(convexPolygons); - convexPolygons.length = 0; - var convexPolygonsIndices = this.convexPolygonsIndices; - this.polygonIndicesPool.freeAll(convexPolygonsIndices); - convexPolygonsIndices.length = 0; - var polygonIndices = this.polygonIndicesPool.obtain(); - polygonIndices.length = 0; - var polygon = this.polygonPool.obtain(); - polygon.length = 0; - var fanBaseIndex = -1, - lastWinding = 0; - for (var i = 0, n = triangles.length; i < n; i += 3) { - var t1 = triangles[i] << 1, - t2 = triangles[i + 1] << 1, - t3 = triangles[i + 2] << 1; - var x1 = vertices[t1], - y1 = vertices[t1 + 1]; - var x2 = vertices[t2], - y2 = vertices[t2 + 1]; - var x3 = vertices[t3], - y3 = vertices[t3 + 1]; - var merged = false; - if (fanBaseIndex == t1) { - var o = polygon.length - 4; - var winding1 = Triangulator.winding( - polygon[o], - polygon[o + 1], - polygon[o + 2], - polygon[o + 3], - x3, - y3, - ); - var winding2 = Triangulator.winding( - x3, - y3, - polygon[0], - polygon[1], - polygon[2], - polygon[3], - ); - if (winding1 == lastWinding && winding2 == lastWinding) { - polygon.push(x3); - polygon.push(y3); - polygonIndices.push(t3); - merged = true; - } - } - if (!merged) { - if (polygon.length > 0) { - convexPolygons.push(polygon); - convexPolygonsIndices.push(polygonIndices); - } else { - this.polygonPool.free(polygon); - this.polygonIndicesPool.free(polygonIndices); - } - polygon = this.polygonPool.obtain(); - polygon.length = 0; - polygon.push(x1); - polygon.push(y1); - polygon.push(x2); - polygon.push(y2); - polygon.push(x3); - polygon.push(y3); - polygonIndices = this.polygonIndicesPool.obtain(); - polygonIndices.length = 0; - polygonIndices.push(t1); - polygonIndices.push(t2); - polygonIndices.push(t3); - lastWinding = Triangulator.winding(x1, y1, x2, y2, x3, y3); - fanBaseIndex = t1; - } - } - if (polygon.length > 0) { - convexPolygons.push(polygon); - convexPolygonsIndices.push(polygonIndices); - } - for (var i = 0, n = convexPolygons.length; i < n; i++) { - polygonIndices = convexPolygonsIndices[i]; - if (polygonIndices.length == 0) continue; - var firstIndex = polygonIndices[0]; - var lastIndex = polygonIndices[polygonIndices.length - 1]; - polygon = convexPolygons[i]; - var o = polygon.length - 4; - var prevPrevX = polygon[o], - prevPrevY = polygon[o + 1]; - var prevX = polygon[o + 2], - prevY = polygon[o + 3]; - var firstX = polygon[0], - firstY = polygon[1]; - var secondX = polygon[2], - secondY = polygon[3]; - var winding = Triangulator.winding( - prevPrevX, - prevPrevY, - prevX, - prevY, - firstX, - firstY, - ); - for (var ii = 0; ii < n; ii++) { - if (ii == i) continue; - var otherIndices = convexPolygonsIndices[ii]; - if (otherIndices.length != 3) continue; - var otherFirstIndex = otherIndices[0]; - var otherSecondIndex = otherIndices[1]; - var otherLastIndex = otherIndices[2]; - var otherPoly = convexPolygons[ii]; - var x3 = otherPoly[otherPoly.length - 2], - y3 = otherPoly[otherPoly.length - 1]; - if (otherFirstIndex != firstIndex || otherSecondIndex != lastIndex) - continue; - var winding1 = Triangulator.winding( - prevPrevX, - prevPrevY, - prevX, - prevY, - x3, - y3, - ); - var winding2 = Triangulator.winding( - x3, - y3, - firstX, - firstY, - secondX, - secondY, - ); - if (winding1 == winding && winding2 == winding) { - otherPoly.length = 0; - otherIndices.length = 0; - polygon.push(x3); - polygon.push(y3); - polygonIndices.push(otherLastIndex); - prevPrevX = prevX; - prevPrevY = prevY; - prevX = x3; - prevY = y3; - ii = 0; - } - } - } - for (var i = convexPolygons.length - 1; i >= 0; i--) { - polygon = convexPolygons[i]; - if (polygon.length == 0) { - convexPolygons.splice(i, 1); - this.polygonPool.free(polygon); - polygonIndices = convexPolygonsIndices[i]; - convexPolygonsIndices.splice(i, 1); - this.polygonIndicesPool.free(polygonIndices); - } - } - return convexPolygons; - }; - Triangulator.isConcave = function(index, vertexCount, vertices, indices) { - var previous = indices[(vertexCount + index - 1) % vertexCount] << 1; - var current = indices[index] << 1; - var next = indices[(index + 1) % vertexCount] << 1; - return !this.positiveArea( - vertices[previous], - vertices[previous + 1], - vertices[current], - vertices[current + 1], - vertices[next], - vertices[next + 1], - ); - }; - Triangulator.positiveArea = function(p1x, p1y, p2x, p2y, p3x, p3y) { - return p1x * (p3y - p2y) + p2x * (p1y - p3y) + p3x * (p2y - p1y) >= 0; - }; - Triangulator.winding = function(p1x, p1y, p2x, p2y, p3x, p3y) { - var px = p2x - p1x, - py = p2y - p1y; - return p3x * py - p3y * px + px * p1y - p1x * py >= 0 ? 1 : -1; - }; - return Triangulator; - })(); - core.Triangulator = Triangulator; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var IntSet = (function() { - function IntSet() { - this.array = new Array(); - } - IntSet.prototype.add = function(value) { - var contains = this.contains(value); - this.array[value | 0] = value | 0; - return !contains; - }; - IntSet.prototype.contains = function(value) { - return this.array[value | 0] != undefined; - }; - IntSet.prototype.remove = function(value) { - this.array[value | 0] = undefined; - }; - IntSet.prototype.clear = function() { - this.array.length = 0; - }; - return IntSet; - })(); - core.IntSet = IntSet; - var Color = (function() { - function Color(r, g, b, a) { - if (r === void 0) { - r = 0; - } - if (g === void 0) { - g = 0; - } - if (b === void 0) { - b = 0; - } - if (a === void 0) { - a = 0; - } - this.r = r; - this.g = g; - this.b = b; - this.a = a; - } - Color.prototype.set = function(r, g, b, a) { - this.r = r; - this.g = g; - this.b = b; - this.a = a; - this.clamp(); - return this; - }; - Color.prototype.setFromColor = function(c) { - this.r = c.r; - this.g = c.g; - this.b = c.b; - this.a = c.a; - return this; - }; - Color.prototype.setFromString = function(hex) { - hex = hex.charAt(0) == '#' ? hex.substr(1) : hex; - this.r = parseInt(hex.substr(0, 2), 16) / 255.0; - this.g = parseInt(hex.substr(2, 2), 16) / 255.0; - this.b = parseInt(hex.substr(4, 2), 16) / 255.0; - this.a = - (hex.length != 8 ? 255 : parseInt(hex.substr(6, 2), 16)) / 255.0; - return this; - }; - Color.prototype.add = function(r, g, b, a) { - this.r += r; - this.g += g; - this.b += b; - this.a += a; - this.clamp(); - return this; - }; - Color.prototype.clamp = function() { - if (this.r < 0) this.r = 0; - else if (this.r > 1) this.r = 1; - if (this.g < 0) this.g = 0; - else if (this.g > 1) this.g = 1; - if (this.b < 0) this.b = 0; - else if (this.b > 1) this.b = 1; - if (this.a < 0) this.a = 0; - else if (this.a > 1) this.a = 1; - return this; - }; - Color.WHITE = new Color(1, 1, 1, 1); - Color.RED = new Color(1, 0, 0, 1); - Color.GREEN = new Color(0, 1, 0, 1); - Color.BLUE = new Color(0, 0, 1, 1); - Color.MAGENTA = new Color(1, 0, 1, 1); - return Color; - })(); - core.Color = Color; - var MathUtils = (function() { - function MathUtils() {} - MathUtils.clamp = function(value, min, max) { - if (value < min) return min; - if (value > max) return max; - return value; - }; - MathUtils.cosDeg = function(degrees) { - return Math.cos(degrees * MathUtils.degRad); - }; - MathUtils.sinDeg = function(degrees) { - return Math.sin(degrees * MathUtils.degRad); - }; - MathUtils.signum = function(value) { - return value > 0 ? 1 : value < 0 ? -1 : 0; - }; - MathUtils.toInt = function(x) { - return x > 0 ? Math.floor(x) : Math.ceil(x); - }; - MathUtils.cbrt = function(x) { - var y = Math.pow(Math.abs(x), 1 / 3); - return x < 0 ? -y : y; - }; - MathUtils.randomTriangular = function(min, max) { - return MathUtils.randomTriangularWith(min, max, (min + max) * 0.5); - }; - MathUtils.randomTriangularWith = function(min, max, mode) { - var u = Math.random(); - var d = max - min; - if (u <= (mode - min) / d) return min + Math.sqrt(u * d * (mode - min)); - return max - Math.sqrt((1 - u) * d * (max - mode)); - }; - MathUtils.PI = 3.1415927; - MathUtils.PI2 = MathUtils.PI * 2; - MathUtils.radiansToDegrees = 180 / MathUtils.PI; - MathUtils.radDeg = MathUtils.radiansToDegrees; - MathUtils.degreesToRadians = MathUtils.PI / 180; - MathUtils.degRad = MathUtils.degreesToRadians; - return MathUtils; - })(); - core.MathUtils = MathUtils; - var Interpolation = (function() { - function Interpolation() {} - Interpolation.prototype.apply = function(start, end, a) { - return start + (end - start) * this.applyInternal(a); - }; - return Interpolation; - })(); - core.Interpolation = Interpolation; - var Pow = (function(_super) { - __extends(Pow, _super); - function Pow(power) { - var _this = _super.call(this) || this; - _this.power = 2; - _this.power = power; - return _this; - } - Pow.prototype.applyInternal = function(a) { - if (a <= 0.5) return Math.pow(a * 2, this.power) / 2; - return ( - Math.pow((a - 1) * 2, this.power) / (this.power % 2 == 0 ? -2 : 2) + 1 - ); - }; - return Pow; - })(Interpolation); - core.Pow = Pow; - var PowOut = (function(_super) { - __extends(PowOut, _super); - function PowOut(power) { - return _super.call(this, power) || this; - } - PowOut.prototype.applyInternal = function(a) { - return Math.pow(a - 1, this.power) * (this.power % 2 == 0 ? -1 : 1) + 1; - }; - return PowOut; - })(Pow); - core.PowOut = PowOut; - var Utils = (function() { - function Utils() {} - Utils.arrayCopy = function( - source, - sourceStart, - dest, - destStart, - numElements, - ) { - for ( - var i = sourceStart, j = destStart; - i < sourceStart + numElements; - i++, j++ - ) { - dest[j] = source[i]; - } - }; - Utils.setArraySize = function(array, size, value) { - if (value === void 0) { - value = 0; - } - var oldSize = array.length; - if (oldSize == size) return array; - array.length = size; - if (oldSize < size) { - for (var i = oldSize; i < size; i++) array[i] = value; - } - return array; - }; - Utils.ensureArrayCapacity = function(array, size, value) { - if (value === void 0) { - value = 0; - } - if (array.length >= size) return array; - return Utils.setArraySize(array, size, value); - }; - Utils.newArray = function(size, defaultValue) { - var array = new Array(size); - for (var i = 0; i < size; i++) array[i] = defaultValue; - return array; - }; - Utils.newFloatArray = function(size) { - if (Utils.SUPPORTS_TYPED_ARRAYS) { - return new Float32Array(size); - } else { - var array = new Array(size); - for (var i = 0; i < array.length; i++) array[i] = 0; - return array; - } - }; - Utils.newShortArray = function(size) { - if (Utils.SUPPORTS_TYPED_ARRAYS) { - return new Int16Array(size); - } else { - var array = new Array(size); - for (var i = 0; i < array.length; i++) array[i] = 0; - return array; - } - }; - Utils.toFloatArray = function(array) { - return Utils.SUPPORTS_TYPED_ARRAYS ? new Float32Array(array) : array; - }; - Utils.toSinglePrecision = function(value) { - return Utils.SUPPORTS_TYPED_ARRAYS ? Math.fround(value) : value; - }; - Utils.webkit602BugfixHelper = function(alpha, blend) {}; - Utils.SUPPORTS_TYPED_ARRAYS = typeof Float32Array !== 'undefined'; - return Utils; - })(); - core.Utils = Utils; - var DebugUtils = (function() { - function DebugUtils() {} - DebugUtils.logBones = function(skeleton) { - for (var i = 0; i < skeleton.bones.length; i++) { - var bone = skeleton.bones[i]; - var mat = bone.matrix; - console.log( - bone.data.name + - ', ' + - mat.a + - ', ' + - mat.b + - ', ' + - mat.c + - ', ' + - mat.d + - ', ' + - mat.tx + - ', ' + - mat.ty, - ); - } - }; - return DebugUtils; - })(); - core.DebugUtils = DebugUtils; - var Pool = (function() { - function Pool(instantiator) { - this.items = new Array(); - this.instantiator = instantiator; - } - Pool.prototype.obtain = function() { - return this.items.length > 0 ? this.items.pop() : this.instantiator(); - }; - Pool.prototype.free = function(item) { - if (item.reset) item.reset(); - this.items.push(item); - }; - Pool.prototype.freeAll = function(items) { - for (var i = 0; i < items.length; i++) { - if (items[i].reset) items[i].reset(); - this.items[i] = items[i]; - } - }; - Pool.prototype.clear = function() { - this.items.length = 0; - }; - return Pool; - })(); - core.Pool = Pool; - var Vector2 = (function() { - function Vector2(x, y) { - if (x === void 0) { - x = 0; - } - if (y === void 0) { - y = 0; - } - this.x = x; - this.y = y; - } - Vector2.prototype.set = function(x, y) { - this.x = x; - this.y = y; - return this; - }; - Vector2.prototype.length = function() { - var x = this.x; - var y = this.y; - return Math.sqrt(x * x + y * y); - }; - Vector2.prototype.normalize = function() { - var len = this.length(); - if (len != 0) { - this.x /= len; - this.y /= len; - } - return this; - }; - return Vector2; - })(); - core.Vector2 = Vector2; - var TimeKeeper = (function() { - function TimeKeeper() { - this.maxDelta = 0.064; - this.framesPerSecond = 0; - this.delta = 0; - this.totalTime = 0; - this.lastTime = Date.now() / 1000; - this.frameCount = 0; - this.frameTime = 0; - } - TimeKeeper.prototype.update = function() { - var now = Date.now() / 1000; - this.delta = now - this.lastTime; - this.frameTime += this.delta; - this.totalTime += this.delta; - if (this.delta > this.maxDelta) this.delta = this.maxDelta; - this.lastTime = now; - this.frameCount++; - if (this.frameTime > 1) { - this.framesPerSecond = this.frameCount / this.frameTime; - this.frameTime = 0; - this.frameCount = 0; - } - }; - return TimeKeeper; - })(); - core.TimeKeeper = TimeKeeper; - var WindowedMean = (function() { - function WindowedMean(windowSize) { - if (windowSize === void 0) { - windowSize = 32; - } - this.addedValues = 0; - this.lastValue = 0; - this.mean = 0; - this.dirty = true; - this.values = new Array(windowSize); - } - WindowedMean.prototype.hasEnoughData = function() { - return this.addedValues >= this.values.length; - }; - WindowedMean.prototype.addValue = function(value) { - if (this.addedValues < this.values.length) this.addedValues++; - this.values[this.lastValue++] = value; - if (this.lastValue > this.values.length - 1) this.lastValue = 0; - this.dirty = true; - }; - WindowedMean.prototype.getMean = function() { - if (this.hasEnoughData()) { - if (this.dirty) { - var mean = 0; - for (var i = 0; i < this.values.length; i++) { - mean += this.values[i]; - } - this.mean = mean / this.values.length; - this.dirty = false; - } - return this.mean; - } else { - return 0; - } - }; - return WindowedMean; - })(); - core.WindowedMean = WindowedMean; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var Attachment = (function() { - function Attachment(name) { - if (name == null) throw new Error('name cannot be null.'); - this.name = name; - } - return Attachment; - })(); - core.Attachment = Attachment; - var VertexAttachment = (function(_super) { - __extends(VertexAttachment, _super); - function VertexAttachment(name) { - var _this = _super.call(this, name) || this; - _this.id = (VertexAttachment.nextID++ & 65535) << 11; - _this.worldVerticesLength = 0; - return _this; - } - VertexAttachment.prototype.computeWorldVerticesOld = function( - slot, - worldVertices, - ) { - this.computeWorldVertices( - slot, - 0, - this.worldVerticesLength, - worldVertices, - 0, - 2, - ); - }; - VertexAttachment.prototype.computeWorldVertices = function( - slot, - start, - count, - worldVertices, - offset, - stride, - ) { - count = offset + (count >> 1) * stride; - var skeleton = slot.bone.skeleton; - var deformArray = slot.attachmentVertices; - var vertices = this.vertices; - var bones = this.bones; - if (bones == null) { - if (deformArray.length > 0) vertices = deformArray; - var mat = slot.bone.matrix; - var x = mat.tx; - var y = mat.ty; - var a = mat.a, - b = mat.c, - c = mat.b, - d = mat.d; - for (var v_1 = start, w = offset; w < count; v_1 += 2, w += stride) { - var vx = vertices[v_1], - vy = vertices[v_1 + 1]; - worldVertices[w] = vx * a + vy * b + x; - worldVertices[w + 1] = vx * c + vy * d + y; - } - return; - } - var v = 0, - skip = 0; - for (var i = 0; i < start; i += 2) { - var n = bones[v]; - v += n + 1; - skip += n; - } - var skeletonBones = skeleton.bones; - if (deformArray.length == 0) { - for (var w = offset, b = skip * 3; w < count; w += stride) { - var wx = 0, - wy = 0; - var n = bones[v++]; - n += v; - for (; v < n; v++, b += 3) { - var mat = skeletonBones[bones[v]].matrix; - var vx = vertices[b], - vy = vertices[b + 1], - weight = vertices[b + 2]; - wx += (vx * mat.a + vy * mat.c + mat.tx) * weight; - wy += (vx * mat.b + vy * mat.d + mat.ty) * weight; - } - worldVertices[w] = wx; - worldVertices[w + 1] = wy; - } - } else { - var deform = deformArray; - for ( - var w = offset, b = skip * 3, f = skip << 1; - w < count; - w += stride - ) { - var wx = 0, - wy = 0; - var n = bones[v++]; - n += v; - for (; v < n; v++, b += 3, f += 2) { - var mat = skeletonBones[bones[v]].matrix; - var vx = vertices[b] + deform[f], - vy = vertices[b + 1] + deform[f + 1], - weight = vertices[b + 2]; - wx += (vx * mat.a + vy * mat.c + mat.tx) * weight; - wy += (vx * mat.b + vy * mat.d + mat.ty) * weight; - } - worldVertices[w] = wx; - worldVertices[w + 1] = wy; - } - } - }; - VertexAttachment.prototype.applyDeform = function(sourceAttachment) { - return this == sourceAttachment; - }; - VertexAttachment.nextID = 0; - return VertexAttachment; - })(Attachment); - core.VertexAttachment = VertexAttachment; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var AttachmentType; - (function(AttachmentType) { - AttachmentType[(AttachmentType['Region'] = 0)] = 'Region'; - AttachmentType[(AttachmentType['BoundingBox'] = 1)] = 'BoundingBox'; - AttachmentType[(AttachmentType['Mesh'] = 2)] = 'Mesh'; - AttachmentType[(AttachmentType['LinkedMesh'] = 3)] = 'LinkedMesh'; - AttachmentType[(AttachmentType['Path'] = 4)] = 'Path'; - AttachmentType[(AttachmentType['Point'] = 5)] = 'Point'; - })((AttachmentType = core.AttachmentType || (core.AttachmentType = {}))); - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var BoundingBoxAttachment = (function(_super) { - __extends(BoundingBoxAttachment, _super); - function BoundingBoxAttachment(name) { - var _this = _super.call(this, name) || this; - _this.color = new core.Color(1, 1, 1, 1); - return _this; - } - return BoundingBoxAttachment; - })(core.VertexAttachment); - core.BoundingBoxAttachment = BoundingBoxAttachment; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var ClippingAttachment = (function(_super) { - __extends(ClippingAttachment, _super); - function ClippingAttachment(name) { - var _this = _super.call(this, name) || this; - _this.color = new core.Color(0.2275, 0.2275, 0.8078, 1); - return _this; - } - return ClippingAttachment; - })(core.VertexAttachment); - core.ClippingAttachment = ClippingAttachment; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var MeshAttachment = (function(_super) { - __extends(MeshAttachment, _super); - function MeshAttachment(name) { - var _this = _super.call(this, name) || this; - _this.color = new core.Color(1, 1, 1, 1); - _this.inheritDeform = false; - _this.tempColor = new core.Color(0, 0, 0, 0); - return _this; - } - MeshAttachment.prototype.updateUVs = function(region, uvs) { - var regionUVs = this.regionUVs; - var n = regionUVs.length; - if (!uvs || uvs.length != n) { - uvs = core.Utils.newFloatArray(n); - } - if (region == null) { - return; - } - var texture = region.texture; - var r = texture._uvs; - var w1 = region.width, - h1 = region.height, - w2 = region.originalWidth, - h2 = region.originalHeight; - var x = region.offsetX, - y = region.pixiOffsetY; - for (var i = 0; i < n; i += 2) { - var u = this.regionUVs[i], - v = this.regionUVs[i + 1]; - u = (u * w2 - x) / w1; - v = (v * h2 - y) / h1; - uvs[i] = - (r.x0 * (1 - u) + r.x1 * u) * (1 - v) + - (r.x3 * (1 - u) + r.x2 * u) * v; - uvs[i + 1] = - (r.y0 * (1 - u) + r.y1 * u) * (1 - v) + - (r.y3 * (1 - u) + r.y2 * u) * v; - } - return uvs; - }; - MeshAttachment.prototype.applyDeform = function(sourceAttachment) { - return ( - this == sourceAttachment || - (this.inheritDeform && this.parentMesh == sourceAttachment) - ); - }; - MeshAttachment.prototype.getParentMesh = function() { - return this.parentMesh; - }; - MeshAttachment.prototype.setParentMesh = function(parentMesh) { - this.parentMesh = parentMesh; - if (parentMesh != null) { - this.bones = parentMesh.bones; - this.vertices = parentMesh.vertices; - this.worldVerticesLength = parentMesh.worldVerticesLength; - this.regionUVs = parentMesh.regionUVs; - this.triangles = parentMesh.triangles; - this.hullLength = parentMesh.hullLength; - this.worldVerticesLength = parentMesh.worldVerticesLength; - } - }; - return MeshAttachment; - })(core.VertexAttachment); - core.MeshAttachment = MeshAttachment; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var PathAttachment = (function(_super) { - __extends(PathAttachment, _super); - function PathAttachment(name) { - var _this = _super.call(this, name) || this; - _this.closed = false; - _this.constantSpeed = false; - _this.color = new core.Color(1, 1, 1, 1); - return _this; - } - return PathAttachment; - })(core.VertexAttachment); - core.PathAttachment = PathAttachment; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var PointAttachment = (function(_super) { - __extends(PointAttachment, _super); - function PointAttachment(name) { - var _this = _super.call(this, name) || this; - _this.color = new core.Color(0.38, 0.94, 0, 1); - return _this; - } - PointAttachment.prototype.computeWorldPosition = function(bone, point) { - var mat = bone.matrix; - point.x = this.x * mat.a + this.y * mat.c + bone.worldX; - point.y = this.x * mat.b + this.y * mat.d + bone.worldY; - return point; - }; - PointAttachment.prototype.computeWorldRotation = function(bone) { - var mat = bone.matrix; - var cos = core.MathUtils.cosDeg(this.rotation), - sin = core.MathUtils.sinDeg(this.rotation); - var x = cos * mat.a + sin * mat.c; - var y = cos * mat.b + sin * mat.d; - return Math.atan2(y, x) * core.MathUtils.radDeg; - }; - return PointAttachment; - })(core.VertexAttachment); - core.PointAttachment = PointAttachment; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var RegionAttachment = (function(_super) { - __extends(RegionAttachment, _super); - function RegionAttachment(name) { - var _this = _super.call(this, name) || this; - _this.x = 0; - _this.y = 0; - _this.scaleX = 1; - _this.scaleY = 1; - _this.rotation = 0; - _this.width = 0; - _this.height = 0; - _this.color = new core.Color(1, 1, 1, 1); - _this.offset = core.Utils.newFloatArray(8); - _this.uvs = core.Utils.newFloatArray(8); - _this.tempColor = new core.Color(1, 1, 1, 1); - return _this; - } - RegionAttachment.prototype.updateOffset = function() { - var regionScaleX = - (this.width / this.region.originalWidth) * this.scaleX; - var regionScaleY = - (this.height / this.region.originalHeight) * this.scaleY; - var localX = - (-this.width / 2) * this.scaleX + this.region.offsetX * regionScaleX; - var localY = - (-this.height / 2) * this.scaleY + this.region.offsetY * regionScaleY; - var localX2 = localX + this.region.width * regionScaleX; - var localY2 = localY + this.region.height * regionScaleY; - var radians = (this.rotation * Math.PI) / 180; - var cos = Math.cos(radians); - var sin = Math.sin(radians); - var localXCos = localX * cos + this.x; - var localXSin = localX * sin; - var localYCos = localY * cos + this.y; - var localYSin = localY * sin; - var localX2Cos = localX2 * cos + this.x; - var localX2Sin = localX2 * sin; - var localY2Cos = localY2 * cos + this.y; - var localY2Sin = localY2 * sin; - var offset = this.offset; - offset[RegionAttachment.OX1] = localXCos - localYSin; - offset[RegionAttachment.OY1] = localYCos + localXSin; - offset[RegionAttachment.OX2] = localXCos - localY2Sin; - offset[RegionAttachment.OY2] = localY2Cos + localXSin; - offset[RegionAttachment.OX3] = localX2Cos - localY2Sin; - offset[RegionAttachment.OY3] = localY2Cos + localX2Sin; - offset[RegionAttachment.OX4] = localX2Cos - localYSin; - offset[RegionAttachment.OY4] = localYCos + localX2Sin; - }; - RegionAttachment.prototype.setRegion = function(region) { - this.region = region; - var uvs = this.uvs; - if (region.rotate) { - uvs[2] = region.u; - uvs[3] = region.v2; - uvs[4] = region.u; - uvs[5] = region.v; - uvs[6] = region.u2; - uvs[7] = region.v; - uvs[0] = region.u2; - uvs[1] = region.v2; - } else { - uvs[0] = region.u; - uvs[1] = region.v2; - uvs[2] = region.u; - uvs[3] = region.v; - uvs[4] = region.u2; - uvs[5] = region.v; - uvs[6] = region.u2; - uvs[7] = region.v2; - } - }; - RegionAttachment.prototype.computeWorldVertices = function( - bone, - worldVertices, - offset, - stride, - ) { - var vertexOffset = this.offset; - var mat = bone.matrix; - var x = mat.tx, - y = mat.ty; - var a = mat.a, - b = mat.c, - c = mat.b, - d = mat.d; - var offsetX = 0, - offsetY = 0; - offsetX = vertexOffset[RegionAttachment.OX1]; - offsetY = vertexOffset[RegionAttachment.OY1]; - worldVertices[offset] = offsetX * a + offsetY * b + x; - worldVertices[offset + 1] = offsetX * c + offsetY * d + y; - offset += stride; - offsetX = vertexOffset[RegionAttachment.OX2]; - offsetY = vertexOffset[RegionAttachment.OY2]; - worldVertices[offset] = offsetX * a + offsetY * b + x; - worldVertices[offset + 1] = offsetX * c + offsetY * d + y; - offset += stride; - offsetX = vertexOffset[RegionAttachment.OX3]; - offsetY = vertexOffset[RegionAttachment.OY3]; - worldVertices[offset] = offsetX * a + offsetY * b + x; - worldVertices[offset + 1] = offsetX * c + offsetY * d + y; - offset += stride; - offsetX = vertexOffset[RegionAttachment.OX4]; - offsetY = vertexOffset[RegionAttachment.OY4]; - worldVertices[offset] = offsetX * a + offsetY * b + x; - worldVertices[offset + 1] = offsetX * c + offsetY * d + y; - }; - RegionAttachment.OX1 = 0; - RegionAttachment.OY1 = 1; - RegionAttachment.OX2 = 2; - RegionAttachment.OY2 = 3; - RegionAttachment.OX3 = 4; - RegionAttachment.OY3 = 5; - RegionAttachment.OX4 = 6; - RegionAttachment.OY4 = 7; - RegionAttachment.X1 = 0; - RegionAttachment.Y1 = 1; - RegionAttachment.C1R = 2; - RegionAttachment.C1G = 3; - RegionAttachment.C1B = 4; - RegionAttachment.C1A = 5; - RegionAttachment.U1 = 6; - RegionAttachment.V1 = 7; - RegionAttachment.X2 = 8; - RegionAttachment.Y2 = 9; - RegionAttachment.C2R = 10; - RegionAttachment.C2G = 11; - RegionAttachment.C2B = 12; - RegionAttachment.C2A = 13; - RegionAttachment.U2 = 14; - RegionAttachment.V2 = 15; - RegionAttachment.X3 = 16; - RegionAttachment.Y3 = 17; - RegionAttachment.C3R = 18; - RegionAttachment.C3G = 19; - RegionAttachment.C3B = 20; - RegionAttachment.C3A = 21; - RegionAttachment.U3 = 22; - RegionAttachment.V3 = 23; - RegionAttachment.X4 = 24; - RegionAttachment.Y4 = 25; - RegionAttachment.C4R = 26; - RegionAttachment.C4G = 27; - RegionAttachment.C4B = 28; - RegionAttachment.C4A = 29; - RegionAttachment.U4 = 30; - RegionAttachment.V4 = 31; - return RegionAttachment; - })(core.Attachment); - core.RegionAttachment = RegionAttachment; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var JitterEffect = (function() { - function JitterEffect(jitterX, jitterY) { - this.jitterX = 0; - this.jitterY = 0; - this.jitterX = jitterX; - this.jitterY = jitterY; - } - JitterEffect.prototype.begin = function(skeleton) {}; - JitterEffect.prototype.transform = function(position, uv, light, dark) { - position.x += core.MathUtils.randomTriangular( - -this.jitterX, - this.jitterY, - ); - position.y += core.MathUtils.randomTriangular( - -this.jitterX, - this.jitterY, - ); - }; - JitterEffect.prototype.end = function() {}; - return JitterEffect; - })(); - core.JitterEffect = JitterEffect; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - var core; - (function(core) { - var SwirlEffect = (function() { - function SwirlEffect(radius) { - this.centerX = 0; - this.centerY = 0; - this.radius = 0; - this.angle = 0; - this.worldX = 0; - this.worldY = 0; - this.radius = radius; - } - SwirlEffect.prototype.begin = function(skeleton) { - this.worldX = skeleton.x + this.centerX; - this.worldY = skeleton.y + this.centerY; - }; - SwirlEffect.prototype.transform = function(position, uv, light, dark) { - var radAngle = this.angle * core.MathUtils.degreesToRadians; - var x = position.x - this.worldX; - var y = position.y - this.worldY; - var dist = Math.sqrt(x * x + y * y); - if (dist < this.radius) { - var theta = SwirlEffect.interpolation.apply( - 0, - radAngle, - (this.radius - dist) / this.radius, - ); - var cos = Math.cos(theta); - var sin = Math.sin(theta); - position.x = cos * x - sin * y + this.worldX; - position.y = sin * x + cos * y + this.worldY; - } - }; - SwirlEffect.prototype.end = function() {}; - SwirlEffect.interpolation = new core.PowOut(2); - return SwirlEffect; - })(); - core.SwirlEffect = SwirlEffect; - })((core = pixi_spine.core || (pixi_spine.core = {}))); -})(pixi_spine || (pixi_spine = {})); -(function() { - if (!Math.fround) { - Math.fround = Math.fround = (function(array) { - return function(x) { - return (array[0] = x), array[0]; - }; - })(new Float32Array(1)); - } -})(); -var pixi_spine; -(function(pixi_spine) { - pixi_spine.core.Bone.yDown = true; - var tempRgb = [0, 0, 0]; - var SpineSprite = (function(_super) { - __extends(SpineSprite, _super); - function SpineSprite() { - var _this = (_super !== null && _super.apply(this, arguments)) || this; - _this.region = null; - return _this; - } - return SpineSprite; - })(PIXI.Sprite); - pixi_spine.SpineSprite = SpineSprite; - var SpineMesh = (function(_super) { - __extends(SpineMesh, _super); - function SpineMesh(texture, vertices, uvs, indices, drawMode) { - return ( - _super.call(this, texture, vertices, uvs, indices, drawMode) || this - ); - } - return SpineMesh; - })(PIXI.mesh.Mesh); - pixi_spine.SpineMesh = SpineMesh; - var Spine = (function(_super) { - __extends(Spine, _super); - function Spine(spineData) { - var _this = _super.call(this) || this; - if (!spineData) { - throw new Error('The spineData param is required.'); - } - if (typeof spineData === 'string') { - throw new Error( - 'spineData param cant be string. Please use spine.Spine.fromAtlas("YOUR_RESOURCE_NAME") from now on.', - ); - } - _this.spineData = spineData; - _this.skeleton = new pixi_spine.core.Skeleton(spineData); - _this.skeleton.updateWorldTransform(); - _this.stateData = new pixi_spine.core.AnimationStateData(spineData); - _this.state = new pixi_spine.core.AnimationState(_this.stateData); - _this.slotContainers = []; - _this.tempClipContainers = []; - for (var i = 0, n = _this.skeleton.slots.length; i < n; i++) { - var slot = _this.skeleton.slots[i]; - var attachment = slot.attachment; - var slotContainer = _this.newContainer(); - _this.slotContainers.push(slotContainer); - _this.addChild(slotContainer); - _this.tempClipContainers.push(null); - if (attachment instanceof pixi_spine.core.RegionAttachment) { - var spriteName = attachment.region.name; - var sprite = _this.createSprite(slot, attachment, spriteName); - slot.currentSprite = sprite; - slot.currentSpriteName = spriteName; - slotContainer.addChild(sprite); - } else if (attachment instanceof pixi_spine.core.MeshAttachment) { - var mesh = _this.createMesh(slot, attachment); - slot.currentMesh = mesh; - slot.currentMeshName = attachment.name; - slotContainer.addChild(mesh); - } else if (attachment instanceof pixi_spine.core.ClippingAttachment) { - _this.createGraphics(slot, attachment); - slotContainer.addChild(slot.clippingContainer); - slotContainer.addChild(slot.currentGraphics); - } else { - continue; - } - } - _this.autoUpdate = true; - _this.tintRgb = new Float32Array([1, 1, 1]); - return _this; - } - Object.defineProperty(Spine.prototype, 'autoUpdate', { - get: function() { - return this.updateTransform === Spine.prototype.autoUpdateTransform; - }, - set: function(value) { - this.updateTransform = value - ? Spine.prototype.autoUpdateTransform - : PIXI.Container.prototype.updateTransform; - }, - enumerable: true, - configurable: true, - }); - Object.defineProperty(Spine.prototype, 'tint', { - get: function() { - return PIXI.utils.rgb2hex(this.tintRgb); - }, - set: function(value) { - this.tintRgb = PIXI.utils.hex2rgb(value, this.tintRgb); - }, - enumerable: true, - configurable: true, - }); - Object.defineProperty(Spine.prototype, 'delayLimit', { - get: function() { - var limit = - typeof this.localDelayLimit !== 'undefined' - ? this.localDelayLimit - : Spine.globalDelayLimit; - return limit || Number.MAX_VALUE; - }, - enumerable: true, - configurable: true, - }); - Spine.prototype.update = function(dt) { - var delayLimit = this.delayLimit; - if (dt > delayLimit) dt = delayLimit; - this.state.update(dt); - this.state.apply(this.skeleton); - if (!this.skeleton) return; - this.skeleton.updateWorldTransform(); - var slots = this.skeleton.slots; - var globalClr = this.color; - var light = null, - dark = null; - if (globalClr) { - light = globalClr.light; - dark = globalClr.dark; - } else { - light = this.tintRgb; - } - var thack = PIXI.TransformBase && this.transformHack() == 1; - for (var i = 0, n = slots.length; i < n; i++) { - var slot = slots[i]; - var attachment = slot.attachment; - var slotContainer = this.slotContainers[i]; - if (!attachment) { - slotContainer.visible = false; - continue; - } - var spriteColor = null; - var attColor = attachment.color; - if (attachment instanceof pixi_spine.core.RegionAttachment) { - var region = attachment.region; - if (region) { - if (slot.currentMesh) { - slot.currentMesh.visible = false; - slot.currentMesh = null; - slot.currentMeshName = undefined; - } - var ar = region; - if (!slot.currentSpriteName || slot.currentSpriteName !== ar.name) { - var spriteName = ar.name; - if (slot.currentSprite) { - slot.currentSprite.visible = false; - } - slot.sprites = slot.sprites || {}; - if (slot.sprites[spriteName] !== undefined) { - slot.sprites[spriteName].visible = true; - } else { - var sprite = this.createSprite(slot, attachment, spriteName); - slotContainer.addChild(sprite); - } - slot.currentSprite = slot.sprites[spriteName]; - slot.currentSpriteName = spriteName; - } - } - if (slotContainer.transform) { - var transform = slotContainer.transform; - var transAny = transform; - var lt = null; - if (transAny.matrix2d) { - lt = transAny.matrix2d; - transAny._dirtyVersion++; - transAny.version = transAny._dirtyVersion; - transAny.isStatic = true; - transAny.operMode = 0; - } else { - if (thack) { - if (transAny.position) { - transform = new PIXI.TransformBase(); - transform._parentID = -1; - transform._worldID = slotContainer.transform._worldID; - slotContainer.transform = transform; - } - lt = transform.localTransform; - } else { - transAny.setFromMatrix(slot.bone.matrix); - } - } - if (lt) { - slot.bone.matrix.copy(lt); - } - } else { - var lt = slotContainer.localTransform || new PIXI.Matrix(); - slot.bone.matrix.copy(lt); - slotContainer.localTransform = lt; - slotContainer.displayObjectUpdateTransform = SlotContainerUpdateTransformV3; - } - if (slot.currentSprite.color) { - spriteColor = slot.currentSprite.color; - } else { - tempRgb[0] = light[0] * slot.color.r * attColor.r; - tempRgb[1] = light[1] * slot.color.g * attColor.g; - tempRgb[2] = light[2] * slot.color.b * attColor.b; - slot.currentSprite.tint = PIXI.utils.rgb2hex(tempRgb); - } - slot.currentSprite.blendMode = slot.blendMode; - } else if (attachment instanceof pixi_spine.core.MeshAttachment) { - if (slot.currentSprite) { - slot.currentSprite.visible = false; - slot.currentSprite = null; - slot.currentSpriteName = undefined; - if (slotContainer.transform) { - var transform = new PIXI.TransformStatic(); - transform._parentID = -1; - transform._worldID = slotContainer.transform._worldID; - slotContainer.transform = transform; - } else { - slotContainer.localTransform = new PIXI.Matrix(); - slotContainer.displayObjectUpdateTransform = - PIXI.DisplayObject.prototype.updateTransform; - } - } - if ( - !slot.currentMeshName || - slot.currentMeshName !== attachment.name - ) { - var meshName = attachment.name; - if (slot.currentMesh) { - slot.currentMesh.visible = false; - } - slot.meshes = slot.meshes || {}; - if (slot.meshes[meshName] !== undefined) { - slot.meshes[meshName].visible = true; - } else { - var mesh = this.createMesh(slot, attachment); - slotContainer.addChild(mesh); - } - slot.currentMesh = slot.meshes[meshName]; - slot.currentMeshName = meshName; - } - attachment.computeWorldVerticesOld(slot, slot.currentMesh.vertices); - if (slot.currentMesh.color) { - spriteColor = slot.currentMesh.color; - } else if (PIXI.VERSION[0] !== '3') { - var tintRgb = slot.currentMesh.tintRgb; - tintRgb[0] = light[0] * slot.color.r * attColor.r; - tintRgb[1] = light[1] * slot.color.g * attColor.g; - tintRgb[2] = light[2] * slot.color.b * attColor.b; - } - slot.currentMesh.blendMode = slot.blendMode; - } else if (attachment instanceof pixi_spine.core.ClippingAttachment) { - if (!slot.currentGraphics) { - this.createGraphics(slot, attachment); - slotContainer.addChild(slot.clippingContainer); - slotContainer.addChild(slot.currentGraphics); - } - this.updateGraphics(slot, attachment); - } else { - slotContainer.visible = false; - continue; - } - slotContainer.visible = true; - if (spriteColor) { - var r0 = slot.color.r * attColor.r; - var g0 = slot.color.g * attColor.g; - var b0 = slot.color.b * attColor.b; - spriteColor.setLight( - light[0] * r0 + dark[0] * (1.0 - r0), - light[1] * g0 + dark[1] * (1.0 - g0), - light[2] * b0 + dark[2] * (1.0 - b0), - ); - if (slot.darkColor) { - r0 = slot.darkColor.r; - g0 = slot.darkColor.g; - b0 = slot.darkColor.b; - } else { - r0 = 0.0; - g0 = 0.0; - b0 = 0.0; - } - spriteColor.setDark( - light[0] * r0 + dark[0] * (1 - r0), - light[1] * g0 + dark[1] * (1 - g0), - light[2] * b0 + dark[2] * (1 - b0), - ); - } - slotContainer.alpha = slot.color.a; - } - var drawOrder = this.skeleton.drawOrder; - var clippingAttachment = null; - var clippingContainer = null; - for (var i = 0, n = drawOrder.length; i < n; i++) { - var slot = slots[drawOrder[i].data.index]; - var slotContainer = this.slotContainers[drawOrder[i].data.index]; - if (!clippingContainer) { - if (slotContainer.parent !== null && slotContainer.parent !== this) { - slotContainer.parent.removeChild(slotContainer); - slotContainer.parent = this; - } - } - if (slot.currentGraphics && slot.attachment) { - clippingContainer = slot.clippingContainer; - clippingAttachment = slot.attachment; - clippingContainer.children.length = 0; - this.children[i] = slotContainer; - if (clippingAttachment.endSlot == slot.data) { - clippingAttachment.endSlot = null; - } - } else { - if (clippingContainer) { - var c = this.tempClipContainers[i]; - if (!c) { - c = this.tempClipContainers[i] = this.newContainer(); - c.visible = false; - } - this.children[i] = c; - slotContainer.parent = null; - clippingContainer.addChild(slotContainer); - if (clippingAttachment.endSlot == slot.data) { - clippingContainer.renderable = true; - clippingContainer = null; - clippingAttachment = null; - } - } else { - this.children[i] = slotContainer; - } - } - } - }; - Spine.prototype.setSpriteRegion = function(attachment, sprite, region) { - sprite.region = region; - sprite.texture = region.texture; - if (!region.size) { - sprite.scale.x = - (attachment.scaleX * attachment.width) / region.originalWidth; - sprite.scale.y = - (-attachment.scaleY * attachment.height) / region.originalHeight; - } else { - sprite.scale.x = region.size.width / region.originalWidth; - sprite.scale.y = -region.size.height / region.originalHeight; - } - }; - Spine.prototype.setMeshRegion = function(attachment, mesh, region) { - mesh.region = region; - mesh.texture = region.texture; - region.texture._updateUvs(); - attachment.updateUVs(region, mesh.uvs); - mesh.dirty++; - }; - Spine.prototype.autoUpdateTransform = function() { - if (Spine.globalAutoUpdate) { - this.lastTime = this.lastTime || Date.now(); - var timeDelta = (Date.now() - this.lastTime) * 0.001; - this.lastTime = Date.now(); - this.update(timeDelta); - } else { - this.lastTime = 0; - } - PIXI.Container.prototype.updateTransform.call(this); - }; - Spine.prototype.createSprite = function(slot, attachment, defName) { - var region = attachment.region; - if (slot.tempAttachment === attachment) { - region = slot.tempRegion; - slot.tempAttachment = null; - slot.tempRegion = null; - } - var texture = region.texture; - var sprite = this.newSprite(texture); - sprite.rotation = attachment.rotation * pixi_spine.core.MathUtils.degRad; - sprite.anchor.x = 0.5; - sprite.anchor.y = 0.5; - sprite.position.x = attachment.x; - sprite.position.y = attachment.y; - sprite.alpha = attachment.color.a; - sprite.region = attachment.region; - this.setSpriteRegion(attachment, sprite, attachment.region); - slot.sprites = slot.sprites || {}; - slot.sprites[defName] = sprite; - return sprite; - }; - Spine.prototype.createMesh = function(slot, attachment) { - var region = attachment.region; - if (slot.tempAttachment === attachment) { - region = slot.tempRegion; - slot.tempAttachment = null; - slot.tempRegion = null; - } - var strip = this.newMesh( - region.texture, - new Float32Array(attachment.regionUVs.length), - new Float32Array(attachment.regionUVs.length), - new Uint16Array(attachment.triangles), - PIXI.mesh.Mesh.DRAW_MODES.TRIANGLES, - ); - strip.canvasPadding = 1.5; - strip.alpha = attachment.color.a; - strip.region = attachment.region; - this.setMeshRegion(attachment, strip, region); - slot.meshes = slot.meshes || {}; - slot.meshes[attachment.name] = strip; - return strip; - }; - Spine.prototype.createGraphics = function(slot, clip) { - var graphics = this.newGraphics(); - var poly = new PIXI.Polygon([]); - graphics.clear(); - graphics.beginFill(0xffffff, 1); - graphics.drawPolygon(poly); - graphics.renderable = false; - slot.currentGraphics = graphics; - slot.clippingContainer = this.newContainer(); - slot.clippingContainer.mask = slot.currentGraphics; - return graphics; - }; - Spine.prototype.updateGraphics = function(slot, clip) { - var vertices = slot.currentGraphics.graphicsData[0].shape.points; - var n = clip.worldVerticesLength; - vertices.length = n; - clip.computeWorldVertices(slot, 0, n, vertices, 0, 2); - slot.currentGraphics.dirty++; - slot.currentGraphics.clearDirty++; - }; - Spine.prototype.hackTextureBySlotIndex = function( - slotIndex, - texture, - size, - ) { - if (texture === void 0) { - texture = null; - } - if (size === void 0) { - size = null; - } - var slot = this.skeleton.slots[slotIndex]; - if (!slot) { - return false; - } - var attachment = slot.attachment; - var region = attachment.region; - if (texture) { - region = new pixi_spine.core.TextureRegion(); - region.texture = texture; - region.size = size; - } - if (slot.currentSprite && slot.currentSprite.region != region) { - this.setSpriteRegion(attachment, slot.currentSprite, region); - slot.currentSprite.region = region; - } else if (slot.currentMesh && slot.currentMesh.region != region) { - this.setMeshRegion(attachment, slot.currentMesh, region); - } else { - slot.tempRegion = region; - slot.tempAttachment = attachment; - } - return true; - }; - Spine.prototype.hackTextureBySlotName = function(slotName, texture, size) { - if (texture === void 0) { - texture = null; - } - if (size === void 0) { - size = null; - } - var index = this.skeleton.findSlotIndex(slotName); - if (index == -1) { - return false; - } - return this.hackTextureBySlotIndex(index, texture, size); - }; - Spine.prototype.newContainer = function() { - return new PIXI.Container(); - }; - Spine.prototype.newSprite = function(tex) { - return new SpineSprite(tex); - }; - Spine.prototype.newGraphics = function() { - return new PIXI.Graphics(); - }; - Spine.prototype.newMesh = function( - texture, - vertices, - uvs, - indices, - drawMode, - ) { - return new SpineMesh(texture, vertices, uvs, indices, drawMode); - }; - Spine.prototype.transformHack = function() { - return 1; - }; - Spine.prototype.hackAttachmentGroups = function( - nameSuffix, - group, - outGroup, - ) { - if (!nameSuffix) { - return; - } - var list_d = [], - list_n = []; - for (var i = 0, len = this.skeleton.slots.length; i < len; i++) { - var slot = this.skeleton.slots[i]; - var name_2 = slot.currentSpriteName || slot.currentMeshName || ''; - var target = slot.currentSprite || slot.currentMesh; - if (name_2.endsWith(nameSuffix)) { - target.parentGroup = group; - list_n.push(target); - } else if (outGroup && target) { - target.parentGroup = outGroup; - list_d.push(target); - } - } - return [list_d, list_n]; - }; - Spine.prototype.destroy = function(options) { - for (var i = 0, n = this.skeleton.slots.length; i < n; i++) { - var slot = this.skeleton.slots[i]; - for (var name_3 in slot.meshes) { - slot.meshes[name_3].destroy(options); - } - slot.meshes = null; - for (var name_4 in slot.sprites) { - slot.sprites[name_4].destroy(options); - } - slot.sprites = null; - } - for (var i = 0, n = this.slotContainers.length; i < n; i++) { - this.slotContainers[i].destroy(options); - } - this.spineData = null; - this.skeleton = null; - this.slotContainers = null; - this.stateData = null; - this.state = null; - this.tempClipContainers = null; - _super.prototype.destroy.call(this, options); - }; - Spine.globalAutoUpdate = true; - Spine.globalDelayLimit = 0; - Spine.clippingPolygon = []; - return Spine; - })(PIXI.Container); - pixi_spine.Spine = Spine; - function SlotContainerUpdateTransformV3() { - var pt = this.parent.worldTransform; - var wt = this.worldTransform; - var lt = this.localTransform; - wt.a = lt.a * pt.a + lt.b * pt.c; - wt.b = lt.a * pt.b + lt.b * pt.d; - wt.c = lt.c * pt.a + lt.d * pt.c; - wt.d = lt.c * pt.b + lt.d * pt.d; - wt.tx = lt.tx * pt.a + lt.ty * pt.c + pt.tx; - wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; - this.worldAlpha = this.alpha * this.parent.worldAlpha; - this._currentBounds = null; - } -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - PIXI.spine = pixi_spine; - var TextureProto = PIXI.Texture.prototype; - if (!TextureProto._updateUvs) { - TextureProto._updateUvs = TextureProto.updateUvs; - } -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function(pixi_spine) { - function isJson(resource) { - return resource.type === PIXI.loaders.Resource.TYPE.JSON; - } - function atlasParser() { - return function atlasParser(resource, next) { - if (!resource.data || !isJson(resource) || !resource.data.bones) { - return next(); - } - var metadata = resource.metadata || {}; - var metadataSkeletonScale = metadata - ? resource.metadata.spineSkeletonScale - : null; - var metadataAtlas = metadata ? resource.metadata.spineAtlas : null; - if (metadataAtlas === false) { - return next(); - } - if (metadataAtlas && metadataAtlas.pages) { - var spineJsonParser = new pixi_spine.core.SkeletonJson( - new pixi_spine.core.AtlasAttachmentLoader(metadataAtlas), - ); - if (metadataSkeletonScale) { - spineJsonParser.scale = metadataSkeletonScale; - } - var skeletonData = spineJsonParser.readSkeletonData(resource.data); - resource.spineData = skeletonData; - resource.spineAtlas = metadataAtlas; - return next(); - } - var metadataAtlasSuffix = metadata.spineAtlasSuffix || '.atlas'; - var atlasPath = resource.url; - var queryStringPos = atlasPath.indexOf('?'); - if (queryStringPos > 0) { - atlasPath = atlasPath.substr(0, queryStringPos); - } - atlasPath = - atlasPath.substr(0, atlasPath.lastIndexOf('.')) + metadataAtlasSuffix; - if (resource.metadata && resource.metadata.spineAtlasFile) { - atlasPath = resource.metadata.spineAtlasFile; - } - atlasPath = atlasPath.replace(this.baseUrl, ''); - var atlasOptions = { - crossOrigin: resource.crossOrigin, - xhrType: PIXI.loaders.Resource.XHR_RESPONSE_TYPE.TEXT, - metadata: metadata.spineMetadata || null, - parentResource: resource, - }; - var imageOptions = { - crossOrigin: resource.crossOrigin, - metadata: metadata.imageMetadata || null, - parentResource: resource, - }; - var baseUrl = resource.url.substr(0, resource.url.lastIndexOf('/') + 1); - baseUrl = baseUrl.replace(this.baseUrl, ''); - var namePrefix = - metadata.imageNamePrefix || resource.name + '_atlas_page_'; - var adapter = metadata.images - ? staticImageLoader(metadata.images) - : metadata.image - ? staticImageLoader({default: metadata.image}) - : metadata.imageLoader - ? metadata.imageLoader(this, namePrefix, baseUrl, imageOptions) - : imageLoaderAdapter(this, namePrefix, baseUrl, imageOptions); - var createSkeletonWithRawAtlas = function(rawData) { - new pixi_spine.core.TextureAtlas(rawData, adapter, function( - spineAtlas, - ) { - if (spineAtlas) { - var spineJsonParser = new pixi_spine.core.SkeletonJson( - new pixi_spine.core.AtlasAttachmentLoader(spineAtlas), - ); - if (metadataSkeletonScale) { - spineJsonParser.scale = metadataSkeletonScale; - } - resource.spineData = spineJsonParser.readSkeletonData( - resource.data, - ); - resource.spineAtlas = spineAtlas; - } - next(); - }); - }; - if (resource.metadata && resource.metadata.atlasRawData) { - createSkeletonWithRawAtlas(resource.metadata.atlasRawData); - } else { - this.add(resource.name + '_atlas', atlasPath, atlasOptions, function( - atlasResource, - ) { - if (!atlasResource.error) { - createSkeletonWithRawAtlas(atlasResource.data); - } else { - next(); - } - }); - } - }; - } - pixi_spine.atlasParser = atlasParser; - function imageLoaderAdapter(loader, namePrefix, baseUrl, imageOptions) { - if (baseUrl && baseUrl.lastIndexOf('/') !== baseUrl.length - 1) { - baseUrl += '/'; - } - return function(line, callback) { - var name = namePrefix + line; - var url = baseUrl + line; - var cachedResource = loader.resources[name]; - if (cachedResource) { - function done() { - callback(cachedResource.texture.baseTexture); - } - if (cachedResource.texture) { - done(); - } else { - cachedResource.onAfterMiddleware.add(done); - } - } else { - loader.add(name, url, imageOptions, function(resource) { - if (!resource.error) { - callback(resource.texture.baseTexture); - } else { - callback(null); - } - }); - } - }; - } - pixi_spine.imageLoaderAdapter = imageLoaderAdapter; - function syncImageLoaderAdapter(baseUrl, crossOrigin) { - if (baseUrl && baseUrl.lastIndexOf('/') !== baseUrl.length - 1) { - baseUrl += '/'; - } - return function(line, callback) { - callback(PIXI.BaseTexture.fromImage(line, crossOrigin)); - }; - } - pixi_spine.syncImageLoaderAdapter = syncImageLoaderAdapter; - function staticImageLoader(pages) { - return function(line, callback) { - var page = pages[line] || pages['default']; - if (page && page.baseTexture) callback(page.baseTexture); - else callback(page); - }; - } - pixi_spine.staticImageLoader = staticImageLoader; - if (PIXI.loaders.Loader) { - PIXI.loaders.Loader.addPixiMiddleware(atlasParser); - PIXI.loader.use(atlasParser()); - } -})(pixi_spine || (pixi_spine = {})); - -export default pixi_spine; -//# sourceMappingURL=pixi-spine.js.map +import { + Texture, + Rectangle, + Sprite, + Graphics, + mesh, + Matrix, + Container, + SCALE_MODES, + utils, + loaders, + TransformBase, + TransformStatic, + DisplayObject, + Polygon, + BaseTexture, +} from 'pixi.js'; + +const VERSION = '4.8.9'; +const loader = loaders.shared; + +const PIXI = { + Texture, + Rectangle, + Sprite, + Graphics, + mesh, + Matrix, + Container, + VERSION, + loaders, + loader, + SCALE_MODES, + utils, + TransformBase, + TransformStatic, + DisplayObject, + Polygon, + BaseTexture, +}; + +('use strict'); +var __extends = + (this && this.__extends) || + (function () { + var extendStatics = + Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && + function (d, b) { + d.__proto__ = b; + }) || + function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + }; + return function (d, b) { + extendStatics(d, b); + function __() { + this.constructor = d; + } + d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __()); + }; + })(); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var Animation = (function () { + function Animation(name, timelines, duration) { + if (name == null) throw new Error('name cannot be null.'); + if (timelines == null) throw new Error('timelines cannot be null.'); + this.name = name; + this.timelines = timelines; + this.duration = duration; + } + Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, blend, direction) { + if (skeleton == null) throw new Error('skeleton cannot be null.'); + if (loop && this.duration != 0) { + time %= this.duration; + if (lastTime > 0) lastTime %= this.duration; + } + var timelines = this.timelines; + for (var i = 0, n = timelines.length; i < n; i++) + timelines[i].apply(skeleton, lastTime, time, events, alpha, blend, direction); + }; + Animation.binarySearch = function (values, target, step) { + if (step === void 0) { + step = 1; + } + var low = 0; + var high = values.length / step - 2; + if (high == 0) return step; + var current = high >>> 1; + while (true) { + if (values[(current + 1) * step] <= target) low = current + 1; + else high = current; + if (low == high) return (low + 1) * step; + current = (low + high) >>> 1; + } + }; + Animation.linearSearch = function (values, target, step) { + for (var i = 0, last = values.length - step; i <= last; i += step) if (values[i] > target) return i; + return -1; + }; + return Animation; + })(); + core.Animation = Animation; + var MixBlend; + (function (MixBlend) { + MixBlend[(MixBlend['setup'] = 0)] = 'setup'; + MixBlend[(MixBlend['first'] = 1)] = 'first'; + MixBlend[(MixBlend['replace'] = 2)] = 'replace'; + MixBlend[(MixBlend['add'] = 3)] = 'add'; + })((MixBlend = core.MixBlend || (core.MixBlend = {}))); + var MixDirection; + (function (MixDirection) { + MixDirection[(MixDirection['in'] = 0)] = 'in'; + MixDirection[(MixDirection['out'] = 1)] = 'out'; + })((MixDirection = core.MixDirection || (core.MixDirection = {}))); + var TimelineType; + (function (TimelineType) { + TimelineType[(TimelineType['rotate'] = 0)] = 'rotate'; + TimelineType[(TimelineType['translate'] = 1)] = 'translate'; + TimelineType[(TimelineType['scale'] = 2)] = 'scale'; + TimelineType[(TimelineType['shear'] = 3)] = 'shear'; + TimelineType[(TimelineType['attachment'] = 4)] = 'attachment'; + TimelineType[(TimelineType['color'] = 5)] = 'color'; + TimelineType[(TimelineType['deform'] = 6)] = 'deform'; + TimelineType[(TimelineType['event'] = 7)] = 'event'; + TimelineType[(TimelineType['drawOrder'] = 8)] = 'drawOrder'; + TimelineType[(TimelineType['ikConstraint'] = 9)] = 'ikConstraint'; + TimelineType[(TimelineType['transformConstraint'] = 10)] = 'transformConstraint'; + TimelineType[(TimelineType['pathConstraintPosition'] = 11)] = 'pathConstraintPosition'; + TimelineType[(TimelineType['pathConstraintSpacing'] = 12)] = 'pathConstraintSpacing'; + TimelineType[(TimelineType['pathConstraintMix'] = 13)] = 'pathConstraintMix'; + TimelineType[(TimelineType['twoColor'] = 14)] = 'twoColor'; + })((TimelineType = core.TimelineType || (core.TimelineType = {}))); + var CurveTimeline = (function () { + function CurveTimeline(frameCount) { + if (frameCount <= 0) throw new Error('frameCount must be > 0: ' + frameCount); + this.curves = core.Utils.newFloatArray((frameCount - 1) * CurveTimeline.BEZIER_SIZE); + } + CurveTimeline.prototype.getFrameCount = function () { + return this.curves.length / CurveTimeline.BEZIER_SIZE + 1; + }; + CurveTimeline.prototype.setLinear = function (frameIndex) { + this.curves[frameIndex * CurveTimeline.BEZIER_SIZE] = CurveTimeline.LINEAR; + }; + CurveTimeline.prototype.setStepped = function (frameIndex) { + this.curves[frameIndex * CurveTimeline.BEZIER_SIZE] = CurveTimeline.STEPPED; + }; + CurveTimeline.prototype.getCurveType = function (frameIndex) { + var index = frameIndex * CurveTimeline.BEZIER_SIZE; + if (index == this.curves.length) return CurveTimeline.LINEAR; + var type = this.curves[index]; + if (type == CurveTimeline.LINEAR) return CurveTimeline.LINEAR; + if (type == CurveTimeline.STEPPED) return CurveTimeline.STEPPED; + return CurveTimeline.BEZIER; + }; + CurveTimeline.prototype.setCurve = function (frameIndex, cx1, cy1, cx2, cy2) { + var tmpx = (-cx1 * 2 + cx2) * 0.03, + tmpy = (-cy1 * 2 + cy2) * 0.03; + var dddfx = ((cx1 - cx2) * 3 + 1) * 0.006, + dddfy = ((cy1 - cy2) * 3 + 1) * 0.006; + var ddfx = tmpx * 2 + dddfx, + ddfy = tmpy * 2 + dddfy; + var dfx = cx1 * 0.3 + tmpx + dddfx * 0.16666667, + dfy = cy1 * 0.3 + tmpy + dddfy * 0.16666667; + var i = frameIndex * CurveTimeline.BEZIER_SIZE; + var curves = this.curves; + curves[i++] = CurveTimeline.BEZIER; + var x = dfx, + y = dfy; + for (var n = i + CurveTimeline.BEZIER_SIZE - 1; i < n; i += 2) { + curves[i] = x; + curves[i + 1] = y; + dfx += ddfx; + dfy += ddfy; + ddfx += dddfx; + ddfy += dddfy; + x += dfx; + y += dfy; + } + }; + CurveTimeline.prototype.getCurvePercent = function (frameIndex, percent) { + percent = core.MathUtils.clamp(percent, 0, 1); + var curves = this.curves; + var i = frameIndex * CurveTimeline.BEZIER_SIZE; + var type = curves[i]; + if (type == CurveTimeline.LINEAR) return percent; + if (type == CurveTimeline.STEPPED) return 0; + i++; + var x = 0; + for (var start = i, n = i + CurveTimeline.BEZIER_SIZE - 1; i < n; i += 2) { + x = curves[i]; + if (x >= percent) { + var prevX = void 0, + prevY = void 0; + if (i == start) { + prevX = 0; + prevY = 0; + } else { + prevX = curves[i - 2]; + prevY = curves[i - 1]; + } + return prevY + ((curves[i + 1] - prevY) * (percent - prevX)) / (x - prevX); + } + } + var y = curves[i - 1]; + return y + ((1 - y) * (percent - x)) / (1 - x); + }; + CurveTimeline.LINEAR = 0; + CurveTimeline.STEPPED = 1; + CurveTimeline.BEZIER = 2; + CurveTimeline.BEZIER_SIZE = 10 * 2 - 1; + return CurveTimeline; + })(); + core.CurveTimeline = CurveTimeline; + var RotateTimeline = (function (_super) { + __extends(RotateTimeline, _super); + function RotateTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = core.Utils.newFloatArray(frameCount << 1); + return _this; + } + RotateTimeline.prototype.getPropertyId = function () { + return (TimelineType.rotate << 24) + this.boneIndex; + }; + RotateTimeline.prototype.setFrame = function (frameIndex, time, degrees) { + frameIndex <<= 1; + this.frames[frameIndex] = time; + this.frames[frameIndex + RotateTimeline.ROTATION] = degrees; + }; + RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) { + var frames = this.frames; + var bone = skeleton.bones[this.boneIndex]; + if (time < frames[0]) { + switch (blend) { + case MixBlend.setup: + bone.rotation = bone.data.rotation; + return; + case MixBlend.first: + var r_1 = bone.data.rotation - bone.rotation; + bone.rotation += (r_1 - (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360) * alpha; + } + return; + } + if (time >= frames[frames.length - RotateTimeline.ENTRIES]) { + var r_2 = frames[frames.length + RotateTimeline.PREV_ROTATION]; + switch (blend) { + case MixBlend.setup: + bone.rotation = bone.data.rotation + r_2 * alpha; + break; + case MixBlend.first: + case MixBlend.replace: + r_2 += bone.data.rotation - bone.rotation; + r_2 -= (16384 - ((16384.499999999996 - r_2 / 360) | 0)) * 360; + case MixBlend.add: + bone.rotation += r_2 * alpha; + } + return; + } + var frame = Animation.binarySearch(frames, time, RotateTimeline.ENTRIES); + var prevRotation = frames[frame + RotateTimeline.PREV_ROTATION]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent( + (frame >> 1) - 1, + 1 - (time - frameTime) / (frames[frame + RotateTimeline.PREV_TIME] - frameTime), + ); + var r = frames[frame + RotateTimeline.ROTATION] - prevRotation; + r = prevRotation + (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * percent; + switch (blend) { + case MixBlend.setup: + bone.rotation = bone.data.rotation + (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * alpha; + break; + case MixBlend.first: + case MixBlend.replace: + r += bone.data.rotation - bone.rotation; + case MixBlend.add: + bone.rotation += (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * alpha; + } + }; + RotateTimeline.ENTRIES = 2; + RotateTimeline.PREV_TIME = -2; + RotateTimeline.PREV_ROTATION = -1; + RotateTimeline.ROTATION = 1; + return RotateTimeline; + })(CurveTimeline); + core.RotateTimeline = RotateTimeline; + var TranslateTimeline = (function (_super) { + __extends(TranslateTimeline, _super); + function TranslateTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = core.Utils.newFloatArray(frameCount * TranslateTimeline.ENTRIES); + return _this; + } + TranslateTimeline.prototype.getPropertyId = function () { + return (TimelineType.translate << 24) + this.boneIndex; + }; + TranslateTimeline.prototype.setFrame = function (frameIndex, time, x, y) { + frameIndex *= TranslateTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + TranslateTimeline.X] = x; + this.frames[frameIndex + TranslateTimeline.Y] = y; + }; + TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) { + var frames = this.frames; + var bone = skeleton.bones[this.boneIndex]; + if (time < frames[0]) { + switch (blend) { + case MixBlend.setup: + bone.x = bone.data.x; + bone.y = bone.data.y; + return; + case MixBlend.first: + bone.x += (bone.data.x - bone.x) * alpha; + bone.y += (bone.data.y - bone.y) * alpha; + } + return; + } + var x = 0, + y = 0; + if (time >= frames[frames.length - TranslateTimeline.ENTRIES]) { + x = frames[frames.length + TranslateTimeline.PREV_X]; + y = frames[frames.length + TranslateTimeline.PREV_Y]; + } else { + var frame = Animation.binarySearch(frames, time, TranslateTimeline.ENTRIES); + x = frames[frame + TranslateTimeline.PREV_X]; + y = frames[frame + TranslateTimeline.PREV_Y]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent( + frame / TranslateTimeline.ENTRIES - 1, + 1 - (time - frameTime) / (frames[frame + TranslateTimeline.PREV_TIME] - frameTime), + ); + x += (frames[frame + TranslateTimeline.X] - x) * percent; + y += (frames[frame + TranslateTimeline.Y] - y) * percent; + } + switch (blend) { + case MixBlend.setup: + bone.x = bone.data.x + x * alpha; + bone.y = bone.data.y + y * alpha; + break; + case MixBlend.first: + case MixBlend.replace: + bone.x += (bone.data.x + x - bone.x) * alpha; + bone.y += (bone.data.y + y - bone.y) * alpha; + break; + case MixBlend.add: + bone.x += x * alpha; + bone.y += y * alpha; + } + }; + TranslateTimeline.ENTRIES = 3; + TranslateTimeline.PREV_TIME = -3; + TranslateTimeline.PREV_X = -2; + TranslateTimeline.PREV_Y = -1; + TranslateTimeline.X = 1; + TranslateTimeline.Y = 2; + return TranslateTimeline; + })(CurveTimeline); + core.TranslateTimeline = TranslateTimeline; + var ScaleTimeline = (function (_super) { + __extends(ScaleTimeline, _super); + function ScaleTimeline(frameCount) { + return _super.call(this, frameCount) || this; + } + ScaleTimeline.prototype.getPropertyId = function () { + return (TimelineType.scale << 24) + this.boneIndex; + }; + ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) { + var frames = this.frames; + var bone = skeleton.bones[this.boneIndex]; + if (time < frames[0]) { + switch (blend) { + case MixBlend.setup: + bone.scaleX = bone.data.scaleX; + bone.scaleY = bone.data.scaleY; + return; + case MixBlend.first: + bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha; + bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha; + } + return; + } + var x = 0, + y = 0; + if (time >= frames[frames.length - ScaleTimeline.ENTRIES]) { + x = frames[frames.length + ScaleTimeline.PREV_X] * bone.data.scaleX; + y = frames[frames.length + ScaleTimeline.PREV_Y] * bone.data.scaleY; + } else { + var frame = Animation.binarySearch(frames, time, ScaleTimeline.ENTRIES); + x = frames[frame + ScaleTimeline.PREV_X]; + y = frames[frame + ScaleTimeline.PREV_Y]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent( + frame / ScaleTimeline.ENTRIES - 1, + 1 - (time - frameTime) / (frames[frame + ScaleTimeline.PREV_TIME] - frameTime), + ); + x = (x + (frames[frame + ScaleTimeline.X] - x) * percent) * bone.data.scaleX; + y = (y + (frames[frame + ScaleTimeline.Y] - y) * percent) * bone.data.scaleY; + } + if (alpha == 1) { + if (blend == MixBlend.add) { + bone.scaleX += x - bone.data.scaleX; + bone.scaleY += y - bone.data.scaleY; + } else { + bone.scaleX = x; + bone.scaleY = y; + } + } else { + var bx = 0, + by = 0; + if (direction == MixDirection.out) { + switch (blend) { + case MixBlend.setup: + bx = bone.data.scaleX; + by = bone.data.scaleY; + bone.scaleX = bx + (Math.abs(x) * core.MathUtils.signum(bx) - bx) * alpha; + bone.scaleY = by + (Math.abs(y) * core.MathUtils.signum(by) - by) * alpha; + break; + case MixBlend.first: + case MixBlend.replace: + bx = bone.scaleX; + by = bone.scaleY; + bone.scaleX = bx + (Math.abs(x) * core.MathUtils.signum(bx) - bx) * alpha; + bone.scaleY = by + (Math.abs(y) * core.MathUtils.signum(by) - by) * alpha; + break; + case MixBlend.add: + bx = bone.scaleX; + by = bone.scaleY; + bone.scaleX = bx + (Math.abs(x) * core.MathUtils.signum(bx) - bone.data.scaleX) * alpha; + bone.scaleY = by + (Math.abs(y) * core.MathUtils.signum(by) - bone.data.scaleY) * alpha; + } + } else { + switch (blend) { + case MixBlend.setup: + bx = Math.abs(bone.data.scaleX) * core.MathUtils.signum(x); + by = Math.abs(bone.data.scaleY) * core.MathUtils.signum(y); + bone.scaleX = bx + (x - bx) * alpha; + bone.scaleY = by + (y - by) * alpha; + break; + case MixBlend.first: + case MixBlend.replace: + bx = Math.abs(bone.scaleX) * core.MathUtils.signum(x); + by = Math.abs(bone.scaleY) * core.MathUtils.signum(y); + bone.scaleX = bx + (x - bx) * alpha; + bone.scaleY = by + (y - by) * alpha; + break; + case MixBlend.add: + bx = core.MathUtils.signum(x); + by = core.MathUtils.signum(y); + bone.scaleX = Math.abs(bone.scaleX) * bx + (x - Math.abs(bone.data.scaleX) * bx) * alpha; + bone.scaleY = Math.abs(bone.scaleY) * by + (y - Math.abs(bone.data.scaleY) * by) * alpha; + } + } + } + }; + return ScaleTimeline; + })(TranslateTimeline); + core.ScaleTimeline = ScaleTimeline; + var ShearTimeline = (function (_super) { + __extends(ShearTimeline, _super); + function ShearTimeline(frameCount) { + return _super.call(this, frameCount) || this; + } + ShearTimeline.prototype.getPropertyId = function () { + return (TimelineType.shear << 24) + this.boneIndex; + }; + ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) { + var frames = this.frames; + var bone = skeleton.bones[this.boneIndex]; + if (time < frames[0]) { + switch (blend) { + case MixBlend.setup: + bone.shearX = bone.data.shearX; + bone.shearY = bone.data.shearY; + return; + case MixBlend.first: + bone.shearX += (bone.data.shearX - bone.shearX) * alpha; + bone.shearY += (bone.data.shearY - bone.shearY) * alpha; + } + return; + } + var x = 0, + y = 0; + if (time >= frames[frames.length - ShearTimeline.ENTRIES]) { + x = frames[frames.length + ShearTimeline.PREV_X]; + y = frames[frames.length + ShearTimeline.PREV_Y]; + } else { + var frame = Animation.binarySearch(frames, time, ShearTimeline.ENTRIES); + x = frames[frame + ShearTimeline.PREV_X]; + y = frames[frame + ShearTimeline.PREV_Y]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent( + frame / ShearTimeline.ENTRIES - 1, + 1 - (time - frameTime) / (frames[frame + ShearTimeline.PREV_TIME] - frameTime), + ); + x = x + (frames[frame + ShearTimeline.X] - x) * percent; + y = y + (frames[frame + ShearTimeline.Y] - y) * percent; + } + switch (blend) { + case MixBlend.setup: + bone.shearX = bone.data.shearX + x * alpha; + bone.shearY = bone.data.shearY + y * alpha; + break; + case MixBlend.first: + case MixBlend.replace: + bone.shearX += (bone.data.shearX + x - bone.shearX) * alpha; + bone.shearY += (bone.data.shearY + y - bone.shearY) * alpha; + break; + case MixBlend.add: + bone.shearX += x * alpha; + bone.shearY += y * alpha; + } + }; + return ShearTimeline; + })(TranslateTimeline); + core.ShearTimeline = ShearTimeline; + var ColorTimeline = (function (_super) { + __extends(ColorTimeline, _super); + function ColorTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = core.Utils.newFloatArray(frameCount * ColorTimeline.ENTRIES); + return _this; + } + ColorTimeline.prototype.getPropertyId = function () { + return (TimelineType.color << 24) + this.slotIndex; + }; + ColorTimeline.prototype.setFrame = function (frameIndex, time, r, g, b, a) { + frameIndex *= ColorTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + ColorTimeline.R] = r; + this.frames[frameIndex + ColorTimeline.G] = g; + this.frames[frameIndex + ColorTimeline.B] = b; + this.frames[frameIndex + ColorTimeline.A] = a; + }; + ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) { + var slot = skeleton.slots[this.slotIndex]; + var frames = this.frames; + if (time < frames[0]) { + switch (blend) { + case MixBlend.setup: + slot.color.setFromColor(slot.data.color); + return; + case MixBlend.first: + var color = slot.color, + setup = slot.data.color; + color.add( + (setup.r - color.r) * alpha, + (setup.g - color.g) * alpha, + (setup.b - color.b) * alpha, + (setup.a - color.a) * alpha, + ); + } + return; + } + var r = 0, + g = 0, + b = 0, + a = 0; + if (time >= frames[frames.length - ColorTimeline.ENTRIES]) { + var i = frames.length; + r = frames[i + ColorTimeline.PREV_R]; + g = frames[i + ColorTimeline.PREV_G]; + b = frames[i + ColorTimeline.PREV_B]; + a = frames[i + ColorTimeline.PREV_A]; + } else { + var frame = Animation.binarySearch(frames, time, ColorTimeline.ENTRIES); + r = frames[frame + ColorTimeline.PREV_R]; + g = frames[frame + ColorTimeline.PREV_G]; + b = frames[frame + ColorTimeline.PREV_B]; + a = frames[frame + ColorTimeline.PREV_A]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent( + frame / ColorTimeline.ENTRIES - 1, + 1 - (time - frameTime) / (frames[frame + ColorTimeline.PREV_TIME] - frameTime), + ); + r += (frames[frame + ColorTimeline.R] - r) * percent; + g += (frames[frame + ColorTimeline.G] - g) * percent; + b += (frames[frame + ColorTimeline.B] - b) * percent; + a += (frames[frame + ColorTimeline.A] - a) * percent; + } + if (alpha == 1) slot.color.set(r, g, b, a); + else { + var color = slot.color; + if (blend == MixBlend.setup) color.setFromColor(slot.data.color); + color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha); + } + }; + ColorTimeline.ENTRIES = 5; + ColorTimeline.PREV_TIME = -5; + ColorTimeline.PREV_R = -4; + ColorTimeline.PREV_G = -3; + ColorTimeline.PREV_B = -2; + ColorTimeline.PREV_A = -1; + ColorTimeline.R = 1; + ColorTimeline.G = 2; + ColorTimeline.B = 3; + ColorTimeline.A = 4; + return ColorTimeline; + })(CurveTimeline); + core.ColorTimeline = ColorTimeline; + var TwoColorTimeline = (function (_super) { + __extends(TwoColorTimeline, _super); + function TwoColorTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = core.Utils.newFloatArray(frameCount * TwoColorTimeline.ENTRIES); + return _this; + } + TwoColorTimeline.prototype.getPropertyId = function () { + return (TimelineType.twoColor << 24) + this.slotIndex; + }; + TwoColorTimeline.prototype.setFrame = function (frameIndex, time, r, g, b, a, r2, g2, b2) { + frameIndex *= TwoColorTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + TwoColorTimeline.R] = r; + this.frames[frameIndex + TwoColorTimeline.G] = g; + this.frames[frameIndex + TwoColorTimeline.B] = b; + this.frames[frameIndex + TwoColorTimeline.A] = a; + this.frames[frameIndex + TwoColorTimeline.R2] = r2; + this.frames[frameIndex + TwoColorTimeline.G2] = g2; + this.frames[frameIndex + TwoColorTimeline.B2] = b2; + }; + TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) { + var slot = skeleton.slots[this.slotIndex]; + var frames = this.frames; + if (time < frames[0]) { + switch (blend) { + case MixBlend.setup: + slot.color.setFromColor(slot.data.color); + slot.darkColor.setFromColor(slot.data.darkColor); + return; + case MixBlend.first: + var light = slot.color, + dark = slot.darkColor, + setupLight = slot.data.color, + setupDark = slot.data.darkColor; + light.add( + (setupLight.r - light.r) * alpha, + (setupLight.g - light.g) * alpha, + (setupLight.b - light.b) * alpha, + (setupLight.a - light.a) * alpha, + ); + dark.add( + (setupDark.r - dark.r) * alpha, + (setupDark.g - dark.g) * alpha, + (setupDark.b - dark.b) * alpha, + 0, + ); + } + return; + } + var r = 0, + g = 0, + b = 0, + a = 0, + r2 = 0, + g2 = 0, + b2 = 0; + if (time >= frames[frames.length - TwoColorTimeline.ENTRIES]) { + var i = frames.length; + r = frames[i + TwoColorTimeline.PREV_R]; + g = frames[i + TwoColorTimeline.PREV_G]; + b = frames[i + TwoColorTimeline.PREV_B]; + a = frames[i + TwoColorTimeline.PREV_A]; + r2 = frames[i + TwoColorTimeline.PREV_R2]; + g2 = frames[i + TwoColorTimeline.PREV_G2]; + b2 = frames[i + TwoColorTimeline.PREV_B2]; + } else { + var frame = Animation.binarySearch(frames, time, TwoColorTimeline.ENTRIES); + r = frames[frame + TwoColorTimeline.PREV_R]; + g = frames[frame + TwoColorTimeline.PREV_G]; + b = frames[frame + TwoColorTimeline.PREV_B]; + a = frames[frame + TwoColorTimeline.PREV_A]; + r2 = frames[frame + TwoColorTimeline.PREV_R2]; + g2 = frames[frame + TwoColorTimeline.PREV_G2]; + b2 = frames[frame + TwoColorTimeline.PREV_B2]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent( + frame / TwoColorTimeline.ENTRIES - 1, + 1 - (time - frameTime) / (frames[frame + TwoColorTimeline.PREV_TIME] - frameTime), + ); + r += (frames[frame + TwoColorTimeline.R] - r) * percent; + g += (frames[frame + TwoColorTimeline.G] - g) * percent; + b += (frames[frame + TwoColorTimeline.B] - b) * percent; + a += (frames[frame + TwoColorTimeline.A] - a) * percent; + r2 += (frames[frame + TwoColorTimeline.R2] - r2) * percent; + g2 += (frames[frame + TwoColorTimeline.G2] - g2) * percent; + b2 += (frames[frame + TwoColorTimeline.B2] - b2) * percent; + } + if (alpha == 1) { + slot.color.set(r, g, b, a); + slot.darkColor.set(r2, g2, b2, 1); + } else { + var light = slot.color, + dark = slot.darkColor; + if (blend == MixBlend.setup) { + light.setFromColor(slot.data.color); + dark.setFromColor(slot.data.darkColor); + } + light.add((r - light.r) * alpha, (g - light.g) * alpha, (b - light.b) * alpha, (a - light.a) * alpha); + dark.add((r2 - dark.r) * alpha, (g2 - dark.g) * alpha, (b2 - dark.b) * alpha, 0); + } + }; + TwoColorTimeline.ENTRIES = 8; + TwoColorTimeline.PREV_TIME = -8; + TwoColorTimeline.PREV_R = -7; + TwoColorTimeline.PREV_G = -6; + TwoColorTimeline.PREV_B = -5; + TwoColorTimeline.PREV_A = -4; + TwoColorTimeline.PREV_R2 = -3; + TwoColorTimeline.PREV_G2 = -2; + TwoColorTimeline.PREV_B2 = -1; + TwoColorTimeline.R = 1; + TwoColorTimeline.G = 2; + TwoColorTimeline.B = 3; + TwoColorTimeline.A = 4; + TwoColorTimeline.R2 = 5; + TwoColorTimeline.G2 = 6; + TwoColorTimeline.B2 = 7; + return TwoColorTimeline; + })(CurveTimeline); + core.TwoColorTimeline = TwoColorTimeline; + var AttachmentTimeline = (function () { + function AttachmentTimeline(frameCount) { + this.frames = core.Utils.newFloatArray(frameCount); + this.attachmentNames = new Array(frameCount); + } + AttachmentTimeline.prototype.getPropertyId = function () { + return (TimelineType.attachment << 24) + this.slotIndex; + }; + AttachmentTimeline.prototype.getFrameCount = function () { + return this.frames.length; + }; + AttachmentTimeline.prototype.setFrame = function (frameIndex, time, attachmentName) { + this.frames[frameIndex] = time; + this.attachmentNames[frameIndex] = attachmentName; + }; + AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) { + var slot = skeleton.slots[this.slotIndex]; + if (direction == MixDirection.out && blend == MixBlend.setup) { + var attachmentName_1 = slot.data.attachmentName; + slot.setAttachment( + attachmentName_1 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_1), + ); + return; + } + var frames = this.frames; + if (time < frames[0]) { + if (blend == MixBlend.setup || blend == MixBlend.first) { + var attachmentName_2 = slot.data.attachmentName; + slot.setAttachment( + attachmentName_2 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2), + ); + } + return; + } + var frameIndex = 0; + if (time >= frames[frames.length - 1]) frameIndex = frames.length - 1; + else frameIndex = Animation.binarySearch(frames, time, 1) - 1; + var attachmentName = this.attachmentNames[frameIndex]; + skeleton.slots[this.slotIndex].setAttachment( + attachmentName == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName), + ); + }; + return AttachmentTimeline; + })(); + core.AttachmentTimeline = AttachmentTimeline; + var zeros = null; + var DeformTimeline = (function (_super) { + __extends(DeformTimeline, _super); + function DeformTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = core.Utils.newFloatArray(frameCount); + _this.frameVertices = new Array(frameCount); + if (zeros == null) zeros = core.Utils.newFloatArray(64); + return _this; + } + DeformTimeline.prototype.getPropertyId = function () { + return (TimelineType.deform << 27) + +this.attachment.id + this.slotIndex; + }; + DeformTimeline.prototype.setFrame = function (frameIndex, time, vertices) { + this.frames[frameIndex] = time; + this.frameVertices[frameIndex] = vertices; + }; + DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) { + var slot = skeleton.slots[this.slotIndex]; + var slotAttachment = slot.getAttachment(); + if (!(slotAttachment instanceof core.VertexAttachment) || !slotAttachment.applyDeform(this.attachment)) return; + var verticesArray = slot.attachmentVertices; + if (verticesArray.length == 0) blend = MixBlend.setup; + var frameVertices = this.frameVertices; + var vertexCount = frameVertices[0].length; + var frames = this.frames; + if (time < frames[0]) { + var vertexAttachment = slotAttachment; + switch (blend) { + case MixBlend.setup: + verticesArray.length = 0; + return; + case MixBlend.first: + if (alpha == 1) { + verticesArray.length = 0; + break; + } + var vertices_1 = core.Utils.setArraySize(verticesArray, vertexCount); + if (vertexAttachment.bones == null) { + var setupVertices = vertexAttachment.vertices; + for (var i = 0; i < vertexCount; i++) vertices_1[i] += (setupVertices[i] - vertices_1[i]) * alpha; + } else { + alpha = 1 - alpha; + for (var i = 0; i < vertexCount; i++) vertices_1[i] *= alpha; + } + } + return; + } + var vertices = core.Utils.setArraySize(verticesArray, vertexCount); + if (time >= frames[frames.length - 1]) { + var lastVertices = frameVertices[frames.length - 1]; + if (alpha == 1) { + if (blend == MixBlend.add) { + var vertexAttachment = slotAttachment; + if (vertexAttachment.bones == null) { + var setupVertices = vertexAttachment.vertices; + for (var i = 0; i < vertexCount; i++) { + vertices[i] += lastVertices[i] - setupVertices[i]; + } + } else { + for (var i = 0; i < vertexCount; i++) vertices[i] += lastVertices[i]; + } + } else { + core.Utils.arrayCopy(lastVertices, 0, vertices, 0, vertexCount); + } + } else { + switch (blend) { + case MixBlend.setup: { + var vertexAttachment_1 = slotAttachment; + if (vertexAttachment_1.bones == null) { + var setupVertices = vertexAttachment_1.vertices; + for (var i = 0; i < vertexCount; i++) { + var setup = setupVertices[i]; + vertices[i] = setup + (lastVertices[i] - setup) * alpha; + } + } else { + for (var i = 0; i < vertexCount; i++) vertices[i] = lastVertices[i] * alpha; + } + break; + } + case MixBlend.first: + case MixBlend.replace: + for (var i = 0; i < vertexCount; i++) vertices[i] += (lastVertices[i] - vertices[i]) * alpha; + case MixBlend.add: + var vertexAttachment = slotAttachment; + if (vertexAttachment.bones == null) { + var setupVertices = vertexAttachment.vertices; + for (var i = 0; i < vertexCount; i++) { + vertices[i] += (lastVertices[i] - setupVertices[i]) * alpha; + } + } else { + for (var i = 0; i < vertexCount; i++) vertices[i] += lastVertices[i] * alpha; + } + } + } + return; + } + var frame = Animation.binarySearch(frames, time); + var prevVertices = frameVertices[frame - 1]; + var nextVertices = frameVertices[frame]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame - 1, 1 - (time - frameTime) / (frames[frame - 1] - frameTime)); + if (alpha == 1) { + if (blend == MixBlend.add) { + var vertexAttachment = slotAttachment; + if (vertexAttachment.bones == null) { + var setupVertices = vertexAttachment.vertices; + for (var i = 0; i < vertexCount; i++) { + var prev = prevVertices[i]; + vertices[i] += prev + (nextVertices[i] - prev) * percent - setupVertices[i]; + } + } else { + for (var i = 0; i < vertexCount; i++) { + var prev = prevVertices[i]; + vertices[i] += prev + (nextVertices[i] - prev) * percent; + } + } + } else { + for (var i = 0; i < vertexCount; i++) { + var prev = prevVertices[i]; + vertices[i] = prev + (nextVertices[i] - prev) * percent; + } + } + } else { + switch (blend) { + case MixBlend.setup: { + var vertexAttachment_2 = slotAttachment; + if (vertexAttachment_2.bones == null) { + var setupVertices = vertexAttachment_2.vertices; + for (var i = 0; i < vertexCount; i++) { + var prev = prevVertices[i], + setup = setupVertices[i]; + vertices[i] = setup + (prev + (nextVertices[i] - prev) * percent - setup) * alpha; + } + } else { + for (var i = 0; i < vertexCount; i++) { + var prev = prevVertices[i]; + vertices[i] = (prev + (nextVertices[i] - prev) * percent) * alpha; + } + } + break; + } + case MixBlend.first: + case MixBlend.replace: + for (var i = 0; i < vertexCount; i++) { + var prev = prevVertices[i]; + vertices[i] += (prev + (nextVertices[i] - prev) * percent - vertices[i]) * alpha; + } + break; + case MixBlend.add: + var vertexAttachment = slotAttachment; + if (vertexAttachment.bones == null) { + var setupVertices = vertexAttachment.vertices; + for (var i = 0; i < vertexCount; i++) { + var prev = prevVertices[i]; + vertices[i] += (prev + (nextVertices[i] - prev) * percent - setupVertices[i]) * alpha; + } + } else { + for (var i = 0; i < vertexCount; i++) { + var prev = prevVertices[i]; + vertices[i] += (prev + (nextVertices[i] - prev) * percent) * alpha; + } + } + } + } + }; + return DeformTimeline; + })(CurveTimeline); + core.DeformTimeline = DeformTimeline; + var EventTimeline = (function () { + function EventTimeline(frameCount) { + this.frames = core.Utils.newFloatArray(frameCount); + this.events = new Array(frameCount); + } + EventTimeline.prototype.getPropertyId = function () { + return TimelineType.event << 24; + }; + EventTimeline.prototype.getFrameCount = function () { + return this.frames.length; + }; + EventTimeline.prototype.setFrame = function (frameIndex, event) { + this.frames[frameIndex] = event.time; + this.events[frameIndex] = event; + }; + EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) { + if (firedEvents == null) return; + var frames = this.frames; + var frameCount = this.frames.length; + if (lastTime > time) { + this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, blend, direction); + lastTime = -1; + } else if (lastTime >= frames[frameCount - 1]) return; + if (time < frames[0]) return; + var frame = 0; + if (lastTime < frames[0]) frame = 0; + else { + frame = Animation.binarySearch(frames, lastTime); + var frameTime = frames[frame]; + while (frame > 0) { + if (frames[frame - 1] != frameTime) break; + frame--; + } + } + for (; frame < frameCount && time >= frames[frame]; frame++) firedEvents.push(this.events[frame]); + }; + return EventTimeline; + })(); + core.EventTimeline = EventTimeline; + var DrawOrderTimeline = (function () { + function DrawOrderTimeline(frameCount) { + this.frames = core.Utils.newFloatArray(frameCount); + this.drawOrders = new Array(frameCount); + } + DrawOrderTimeline.prototype.getPropertyId = function () { + return TimelineType.drawOrder << 24; + }; + DrawOrderTimeline.prototype.getFrameCount = function () { + return this.frames.length; + }; + DrawOrderTimeline.prototype.setFrame = function (frameIndex, time, drawOrder) { + this.frames[frameIndex] = time; + this.drawOrders[frameIndex] = drawOrder; + }; + DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) { + var drawOrder = skeleton.drawOrder; + var slots = skeleton.slots; + if (direction == MixDirection.out && blend == MixBlend.setup) { + core.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length); + return; + } + var frames = this.frames; + if (time < frames[0]) { + if (blend == MixBlend.setup || blend == MixBlend.first) + core.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length); + return; + } + var frame = 0; + if (time >= frames[frames.length - 1]) frame = frames.length - 1; + else frame = Animation.binarySearch(frames, time) - 1; + var drawOrderToSetupIndex = this.drawOrders[frame]; + if (drawOrderToSetupIndex == null) core.Utils.arrayCopy(slots, 0, drawOrder, 0, slots.length); + else { + for (var i = 0, n = drawOrderToSetupIndex.length; i < n; i++) drawOrder[i] = slots[drawOrderToSetupIndex[i]]; + } + }; + return DrawOrderTimeline; + })(); + core.DrawOrderTimeline = DrawOrderTimeline; + var IkConstraintTimeline = (function (_super) { + __extends(IkConstraintTimeline, _super); + function IkConstraintTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = core.Utils.newFloatArray(frameCount * IkConstraintTimeline.ENTRIES); + return _this; + } + IkConstraintTimeline.prototype.getPropertyId = function () { + return (TimelineType.ikConstraint << 24) + this.ikConstraintIndex; + }; + IkConstraintTimeline.prototype.setFrame = function (frameIndex, time, mix, bendDirection, compress, stretch) { + frameIndex *= IkConstraintTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + IkConstraintTimeline.MIX] = mix; + this.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection; + this.frames[frameIndex + IkConstraintTimeline.COMPRESS] = compress ? 1 : 0; + this.frames[frameIndex + IkConstraintTimeline.STRETCH] = stretch ? 1 : 0; + }; + IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) { + var frames = this.frames; + var constraint = skeleton.ikConstraints[this.ikConstraintIndex]; + if (time < frames[0]) { + switch (blend) { + case MixBlend.setup: + constraint.mix = constraint.data.mix; + constraint.bendDirection = constraint.data.bendDirection; + constraint.compress = constraint.data.compress; + constraint.stretch = constraint.data.stretch; + return; + case MixBlend.first: + constraint.mix += (constraint.data.mix - constraint.mix) * alpha; + constraint.bendDirection = constraint.data.bendDirection; + constraint.compress = constraint.data.compress; + constraint.stretch = constraint.data.stretch; + } + return; + } + if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) { + if (blend == MixBlend.setup) { + constraint.mix = + constraint.data.mix + + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha; + if (direction == MixDirection.out) { + constraint.bendDirection = constraint.data.bendDirection; + constraint.compress = constraint.data.compress; + constraint.stretch = constraint.data.stretch; + } else { + constraint.bendDirection = frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION]; + constraint.compress = frames[frames.length + IkConstraintTimeline.PREV_COMPRESS] != 0; + constraint.stretch = frames[frames.length + IkConstraintTimeline.PREV_STRETCH] != 0; + } + } else { + constraint.mix += (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.mix) * alpha; + if (direction == MixDirection.in) { + constraint.bendDirection = frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION]; + constraint.compress = frames[frames.length + IkConstraintTimeline.PREV_COMPRESS] != 0; + constraint.stretch = frames[frames.length + IkConstraintTimeline.PREV_STRETCH] != 0; + } + } + return; + } + var frame = Animation.binarySearch(frames, time, IkConstraintTimeline.ENTRIES); + var mix = frames[frame + IkConstraintTimeline.PREV_MIX]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent( + frame / IkConstraintTimeline.ENTRIES - 1, + 1 - (time - frameTime) / (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime), + ); + if (blend == MixBlend.setup) { + constraint.mix = + constraint.data.mix + + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha; + if (direction == MixDirection.out) { + constraint.bendDirection = constraint.data.bendDirection; + constraint.compress = constraint.data.compress; + constraint.stretch = constraint.data.stretch; + } else { + constraint.bendDirection = frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION]; + constraint.compress = frames[frame + IkConstraintTimeline.PREV_COMPRESS] != 0; + constraint.stretch = frames[frame + IkConstraintTimeline.PREV_STRETCH] != 0; + } + } else { + constraint.mix += (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.mix) * alpha; + if (direction == MixDirection.in) { + constraint.bendDirection = frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION]; + constraint.compress = frames[frame + IkConstraintTimeline.PREV_COMPRESS] != 0; + constraint.stretch = frames[frame + IkConstraintTimeline.PREV_STRETCH] != 0; + } + } + }; + IkConstraintTimeline.ENTRIES = 5; + IkConstraintTimeline.PREV_TIME = -5; + IkConstraintTimeline.PREV_MIX = -4; + IkConstraintTimeline.PREV_BEND_DIRECTION = -3; + IkConstraintTimeline.PREV_COMPRESS = -2; + IkConstraintTimeline.PREV_STRETCH = -1; + IkConstraintTimeline.MIX = 1; + IkConstraintTimeline.BEND_DIRECTION = 2; + IkConstraintTimeline.COMPRESS = 3; + IkConstraintTimeline.STRETCH = 4; + return IkConstraintTimeline; + })(CurveTimeline); + core.IkConstraintTimeline = IkConstraintTimeline; + var TransformConstraintTimeline = (function (_super) { + __extends(TransformConstraintTimeline, _super); + function TransformConstraintTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = core.Utils.newFloatArray(frameCount * TransformConstraintTimeline.ENTRIES); + return _this; + } + TransformConstraintTimeline.prototype.getPropertyId = function () { + return (TimelineType.transformConstraint << 24) + this.transformConstraintIndex; + }; + TransformConstraintTimeline.prototype.setFrame = function ( + frameIndex, + time, + rotateMix, + translateMix, + scaleMix, + shearMix, + ) { + frameIndex *= TransformConstraintTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + TransformConstraintTimeline.ROTATE] = rotateMix; + this.frames[frameIndex + TransformConstraintTimeline.TRANSLATE] = translateMix; + this.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix; + this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix; + }; + TransformConstraintTimeline.prototype.apply = function ( + skeleton, + lastTime, + time, + firedEvents, + alpha, + blend, + direction, + ) { + var frames = this.frames; + var constraint = skeleton.transformConstraints[this.transformConstraintIndex]; + if (time < frames[0]) { + var data = constraint.data; + switch (blend) { + case MixBlend.setup: + constraint.rotateMix = data.rotateMix; + constraint.translateMix = data.translateMix; + constraint.scaleMix = data.scaleMix; + constraint.shearMix = data.shearMix; + return; + case MixBlend.first: + constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha; + constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha; + constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha; + constraint.shearMix += (data.shearMix - constraint.shearMix) * alpha; + } + return; + } + var rotate = 0, + translate = 0, + scale = 0, + shear = 0; + if (time >= frames[frames.length - TransformConstraintTimeline.ENTRIES]) { + var i = frames.length; + rotate = frames[i + TransformConstraintTimeline.PREV_ROTATE]; + translate = frames[i + TransformConstraintTimeline.PREV_TRANSLATE]; + scale = frames[i + TransformConstraintTimeline.PREV_SCALE]; + shear = frames[i + TransformConstraintTimeline.PREV_SHEAR]; + } else { + var frame = Animation.binarySearch(frames, time, TransformConstraintTimeline.ENTRIES); + rotate = frames[frame + TransformConstraintTimeline.PREV_ROTATE]; + translate = frames[frame + TransformConstraintTimeline.PREV_TRANSLATE]; + scale = frames[frame + TransformConstraintTimeline.PREV_SCALE]; + shear = frames[frame + TransformConstraintTimeline.PREV_SHEAR]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent( + frame / TransformConstraintTimeline.ENTRIES - 1, + 1 - (time - frameTime) / (frames[frame + TransformConstraintTimeline.PREV_TIME] - frameTime), + ); + rotate += (frames[frame + TransformConstraintTimeline.ROTATE] - rotate) * percent; + translate += (frames[frame + TransformConstraintTimeline.TRANSLATE] - translate) * percent; + scale += (frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent; + shear += (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent; + } + if (blend == MixBlend.setup) { + var data = constraint.data; + constraint.rotateMix = data.rotateMix + (rotate - data.rotateMix) * alpha; + constraint.translateMix = data.translateMix + (translate - data.translateMix) * alpha; + constraint.scaleMix = data.scaleMix + (scale - data.scaleMix) * alpha; + constraint.shearMix = data.shearMix + (shear - data.shearMix) * alpha; + } else { + constraint.rotateMix += (rotate - constraint.rotateMix) * alpha; + constraint.translateMix += (translate - constraint.translateMix) * alpha; + constraint.scaleMix += (scale - constraint.scaleMix) * alpha; + constraint.shearMix += (shear - constraint.shearMix) * alpha; + } + }; + TransformConstraintTimeline.ENTRIES = 5; + TransformConstraintTimeline.PREV_TIME = -5; + TransformConstraintTimeline.PREV_ROTATE = -4; + TransformConstraintTimeline.PREV_TRANSLATE = -3; + TransformConstraintTimeline.PREV_SCALE = -2; + TransformConstraintTimeline.PREV_SHEAR = -1; + TransformConstraintTimeline.ROTATE = 1; + TransformConstraintTimeline.TRANSLATE = 2; + TransformConstraintTimeline.SCALE = 3; + TransformConstraintTimeline.SHEAR = 4; + return TransformConstraintTimeline; + })(CurveTimeline); + core.TransformConstraintTimeline = TransformConstraintTimeline; + var PathConstraintPositionTimeline = (function (_super) { + __extends(PathConstraintPositionTimeline, _super); + function PathConstraintPositionTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = core.Utils.newFloatArray(frameCount * PathConstraintPositionTimeline.ENTRIES); + return _this; + } + PathConstraintPositionTimeline.prototype.getPropertyId = function () { + return (TimelineType.pathConstraintPosition << 24) + this.pathConstraintIndex; + }; + PathConstraintPositionTimeline.prototype.setFrame = function (frameIndex, time, value) { + frameIndex *= PathConstraintPositionTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value; + }; + PathConstraintPositionTimeline.prototype.apply = function ( + skeleton, + lastTime, + time, + firedEvents, + alpha, + blend, + direction, + ) { + var frames = this.frames; + var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; + if (time < frames[0]) { + switch (blend) { + case MixBlend.setup: + constraint.position = constraint.data.position; + return; + case MixBlend.first: + constraint.position += (constraint.data.position - constraint.position) * alpha; + } + return; + } + var position = 0; + if (time >= frames[frames.length - PathConstraintPositionTimeline.ENTRIES]) + position = frames[frames.length + PathConstraintPositionTimeline.PREV_VALUE]; + else { + var frame = Animation.binarySearch(frames, time, PathConstraintPositionTimeline.ENTRIES); + position = frames[frame + PathConstraintPositionTimeline.PREV_VALUE]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent( + frame / PathConstraintPositionTimeline.ENTRIES - 1, + 1 - (time - frameTime) / (frames[frame + PathConstraintPositionTimeline.PREV_TIME] - frameTime), + ); + position += (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * percent; + } + if (blend == MixBlend.setup) + constraint.position = constraint.data.position + (position - constraint.data.position) * alpha; + else constraint.position += (position - constraint.position) * alpha; + }; + PathConstraintPositionTimeline.ENTRIES = 2; + PathConstraintPositionTimeline.PREV_TIME = -2; + PathConstraintPositionTimeline.PREV_VALUE = -1; + PathConstraintPositionTimeline.VALUE = 1; + return PathConstraintPositionTimeline; + })(CurveTimeline); + core.PathConstraintPositionTimeline = PathConstraintPositionTimeline; + var PathConstraintSpacingTimeline = (function (_super) { + __extends(PathConstraintSpacingTimeline, _super); + function PathConstraintSpacingTimeline(frameCount) { + return _super.call(this, frameCount) || this; + } + PathConstraintSpacingTimeline.prototype.getPropertyId = function () { + return (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex; + }; + PathConstraintSpacingTimeline.prototype.apply = function ( + skeleton, + lastTime, + time, + firedEvents, + alpha, + blend, + direction, + ) { + var frames = this.frames; + var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; + if (time < frames[0]) { + switch (blend) { + case MixBlend.setup: + constraint.spacing = constraint.data.spacing; + return; + case MixBlend.first: + constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha; + } + return; + } + var spacing = 0; + if (time >= frames[frames.length - PathConstraintSpacingTimeline.ENTRIES]) + spacing = frames[frames.length + PathConstraintSpacingTimeline.PREV_VALUE]; + else { + var frame = Animation.binarySearch(frames, time, PathConstraintSpacingTimeline.ENTRIES); + spacing = frames[frame + PathConstraintSpacingTimeline.PREV_VALUE]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent( + frame / PathConstraintSpacingTimeline.ENTRIES - 1, + 1 - (time - frameTime) / (frames[frame + PathConstraintSpacingTimeline.PREV_TIME] - frameTime), + ); + spacing += (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * percent; + } + if (blend == MixBlend.setup) + constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha; + else constraint.spacing += (spacing - constraint.spacing) * alpha; + }; + return PathConstraintSpacingTimeline; + })(PathConstraintPositionTimeline); + core.PathConstraintSpacingTimeline = PathConstraintSpacingTimeline; + var PathConstraintMixTimeline = (function (_super) { + __extends(PathConstraintMixTimeline, _super); + function PathConstraintMixTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = core.Utils.newFloatArray(frameCount * PathConstraintMixTimeline.ENTRIES); + return _this; + } + PathConstraintMixTimeline.prototype.getPropertyId = function () { + return (TimelineType.pathConstraintMix << 24) + this.pathConstraintIndex; + }; + PathConstraintMixTimeline.prototype.setFrame = function (frameIndex, time, rotateMix, translateMix) { + frameIndex *= PathConstraintMixTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix; + this.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix; + }; + PathConstraintMixTimeline.prototype.apply = function ( + skeleton, + lastTime, + time, + firedEvents, + alpha, + blend, + direction, + ) { + var frames = this.frames; + var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; + if (time < frames[0]) { + switch (blend) { + case MixBlend.setup: + constraint.rotateMix = constraint.data.rotateMix; + constraint.translateMix = constraint.data.translateMix; + return; + case MixBlend.first: + constraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha; + constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha; + } + return; + } + var rotate = 0, + translate = 0; + if (time >= frames[frames.length - PathConstraintMixTimeline.ENTRIES]) { + rotate = frames[frames.length + PathConstraintMixTimeline.PREV_ROTATE]; + translate = frames[frames.length + PathConstraintMixTimeline.PREV_TRANSLATE]; + } else { + var frame = Animation.binarySearch(frames, time, PathConstraintMixTimeline.ENTRIES); + rotate = frames[frame + PathConstraintMixTimeline.PREV_ROTATE]; + translate = frames[frame + PathConstraintMixTimeline.PREV_TRANSLATE]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent( + frame / PathConstraintMixTimeline.ENTRIES - 1, + 1 - (time - frameTime) / (frames[frame + PathConstraintMixTimeline.PREV_TIME] - frameTime), + ); + rotate += (frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * percent; + translate += (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * percent; + } + if (blend == MixBlend.setup) { + constraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha; + constraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha; + } else { + constraint.rotateMix += (rotate - constraint.rotateMix) * alpha; + constraint.translateMix += (translate - constraint.translateMix) * alpha; + } + }; + PathConstraintMixTimeline.ENTRIES = 3; + PathConstraintMixTimeline.PREV_TIME = -3; + PathConstraintMixTimeline.PREV_ROTATE = -2; + PathConstraintMixTimeline.PREV_TRANSLATE = -1; + PathConstraintMixTimeline.ROTATE = 1; + PathConstraintMixTimeline.TRANSLATE = 2; + return PathConstraintMixTimeline; + })(CurveTimeline); + core.PathConstraintMixTimeline = PathConstraintMixTimeline; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var AnimationState = (function () { + function AnimationState(data) { + this.tracks = new Array(); + this.events = new Array(); + this.listeners = new Array(); + this.queue = new EventQueue(this); + this.propertyIDs = new core.IntSet(); + this.animationsChanged = false; + this.timeScale = 1; + this.trackEntryPool = new core.Pool(function () { + return new TrackEntry(); + }); + this.data = data; + } + AnimationState.prototype.update = function (delta) { + delta *= this.timeScale; + var tracks = this.tracks; + for (var i = 0, n = tracks.length; i < n; i++) { + var current = tracks[i]; + if (current == null) continue; + current.animationLast = current.nextAnimationLast; + current.trackLast = current.nextTrackLast; + var currentDelta = delta * current.timeScale; + if (current.delay > 0) { + current.delay -= currentDelta; + if (current.delay > 0) continue; + currentDelta = -current.delay; + current.delay = 0; + } + var next = current.next; + if (next != null) { + var nextTime = current.trackLast - next.delay; + if (nextTime >= 0) { + next.delay = 0; + next.trackTime = current.timeScale == 0 ? 0 : (nextTime / current.timeScale + delta) * next.timeScale; + current.trackTime += currentDelta; + this.setCurrent(i, next, true); + while (next.mixingFrom != null) { + next.mixTime += delta; + next = next.mixingFrom; + } + continue; + } + } else if (current.trackLast >= current.trackEnd && current.mixingFrom == null) { + tracks[i] = null; + this.queue.end(current); + this.disposeNext(current); + continue; + } + if (current.mixingFrom != null && this.updateMixingFrom(current, delta)) { + var from = current.mixingFrom; + current.mixingFrom = null; + if (from != null) from.mixingTo = null; + while (from != null) { + this.queue.end(from); + from = from.mixingFrom; + } + } + current.trackTime += currentDelta; + } + this.queue.drain(); + }; + AnimationState.prototype.updateMixingFrom = function (to, delta) { + var from = to.mixingFrom; + if (from == null) return true; + var finished = this.updateMixingFrom(from, delta); + from.animationLast = from.nextAnimationLast; + from.trackLast = from.nextTrackLast; + if (to.mixTime > 0 && to.mixTime >= to.mixDuration) { + if (from.totalAlpha == 0 || to.mixDuration == 0) { + to.mixingFrom = from.mixingFrom; + if (from.mixingFrom != null) from.mixingFrom.mixingTo = to; + to.interruptAlpha = from.interruptAlpha; + this.queue.end(from); + } + return finished; + } + from.trackTime += delta * from.timeScale; + to.mixTime += delta; + return false; + }; + AnimationState.prototype.apply = function (skeleton) { + if (skeleton == null) throw new Error('skeleton cannot be null.'); + if (this.animationsChanged) this._animationsChanged(); + var events = this.events; + var tracks = this.tracks; + var applied = false; + for (var i = 0, n = tracks.length; i < n; i++) { + var current = tracks[i]; + if (current == null || current.delay > 0) continue; + applied = true; + var blend = i == 0 ? core.MixBlend.first : current.mixBlend; + var mix = current.alpha; + if (current.mixingFrom != null) mix *= this.applyMixingFrom(current, skeleton, blend); + else if (current.trackTime >= current.trackEnd && current.next == null) mix = 0; + var animationLast = current.animationLast, + animationTime = current.getAnimationTime(); + var timelineCount = current.animation.timelines.length; + var timelines = current.animation.timelines; + if (i == 0 && (mix == 1 || blend == core.MixBlend.add)) { + for (var ii = 0; ii < timelineCount; ii++) { + core.Utils.webkit602BugfixHelper(mix, blend); + timelines[ii].apply(skeleton, animationLast, animationTime, events, mix, blend, core.MixDirection.in); + } + } else { + var timelineMode = current.timelineMode; + var firstFrame = current.timelinesRotation.length == 0; + if (firstFrame) core.Utils.setArraySize(current.timelinesRotation, timelineCount << 1, null); + var timelinesRotation = current.timelinesRotation; + for (var ii = 0; ii < timelineCount; ii++) { + var timeline = timelines[ii]; + var timelineBlend = timelineMode[ii] == AnimationState.SUBSEQUENT ? blend : core.MixBlend.setup; + if (timeline instanceof core.RotateTimeline) { + this.applyRotateTimeline( + timeline, + skeleton, + animationTime, + mix, + timelineBlend, + timelinesRotation, + ii << 1, + firstFrame, + ); + } else { + core.Utils.webkit602BugfixHelper(mix, blend); + timeline.apply( + skeleton, + animationLast, + animationTime, + events, + mix, + timelineBlend, + core.MixDirection.in, + ); + } + } + } + this.queueEvents(current, animationTime); + events.length = 0; + current.nextAnimationLast = animationTime; + current.nextTrackLast = current.trackTime; + } + this.queue.drain(); + return applied; + }; + AnimationState.prototype.applyMixingFrom = function (to, skeleton, blend) { + var from = to.mixingFrom; + if (from.mixingFrom != null) this.applyMixingFrom(from, skeleton, blend); + var mix = 0; + if (to.mixDuration == 0) { + mix = 1; + if (blend == core.MixBlend.first) blend = core.MixBlend.setup; + } else { + mix = to.mixTime / to.mixDuration; + if (mix > 1) mix = 1; + if (blend != core.MixBlend.first) blend = from.mixBlend; + } + var events = mix < from.eventThreshold ? this.events : null; + var attachments = mix < from.attachmentThreshold, + drawOrder = mix < from.drawOrderThreshold; + var animationLast = from.animationLast, + animationTime = from.getAnimationTime(); + var timelineCount = from.animation.timelines.length; + var timelines = from.animation.timelines; + var alphaHold = from.alpha * to.interruptAlpha, + alphaMix = alphaHold * (1 - mix); + if (blend == core.MixBlend.add) { + for (var i = 0; i < timelineCount; i++) + timelines[i].apply(skeleton, animationLast, animationTime, events, alphaMix, blend, core.MixDirection.out); + } else { + var timelineMode = from.timelineMode; + var timelineHoldMix = from.timelineHoldMix; + var firstFrame = from.timelinesRotation.length == 0; + if (firstFrame) core.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null); + var timelinesRotation = from.timelinesRotation; + from.totalAlpha = 0; + for (var i = 0; i < timelineCount; i++) { + var timeline = timelines[i]; + var direction = core.MixDirection.out; + var timelineBlend = void 0; + var alpha = 0; + switch (timelineMode[i]) { + case AnimationState.SUBSEQUENT: + if (!attachments && timeline instanceof core.AttachmentTimeline) continue; + if (!drawOrder && timeline instanceof core.DrawOrderTimeline) continue; + timelineBlend = blend; + alpha = alphaMix; + break; + case AnimationState.FIRST: + timelineBlend = core.MixBlend.setup; + alpha = alphaMix; + break; + case AnimationState.HOLD: + timelineBlend = core.MixBlend.setup; + alpha = alphaHold; + break; + default: + timelineBlend = core.MixBlend.setup; + var holdMix = timelineHoldMix[i]; + alpha = alphaHold * Math.max(0, 1 - holdMix.mixTime / holdMix.mixDuration); + break; + } + from.totalAlpha += alpha; + if (timeline instanceof core.RotateTimeline) + this.applyRotateTimeline( + timeline, + skeleton, + animationTime, + alpha, + timelineBlend, + timelinesRotation, + i << 1, + firstFrame, + ); + else { + core.Utils.webkit602BugfixHelper(alpha, blend); + if (timelineBlend == core.MixBlend.setup) { + if (timeline instanceof core.AttachmentTimeline) { + if (attachments) direction = core.MixDirection.out; + } else if (timeline instanceof core.DrawOrderTimeline) { + if (drawOrder) direction = core.MixDirection.out; + } + } + timeline.apply(skeleton, animationLast, animationTime, events, alpha, timelineBlend, direction); + } + } + } + if (to.mixDuration > 0) this.queueEvents(from, animationTime); + this.events.length = 0; + from.nextAnimationLast = animationTime; + from.nextTrackLast = from.trackTime; + return mix; + }; + AnimationState.prototype.applyRotateTimeline = function ( + timeline, + skeleton, + time, + alpha, + blend, + timelinesRotation, + i, + firstFrame, + ) { + if (firstFrame) timelinesRotation[i] = 0; + if (alpha == 1) { + timeline.apply(skeleton, 0, time, null, 1, blend, core.MixDirection.in); + return; + } + var rotateTimeline = timeline; + var frames = rotateTimeline.frames; + var bone = skeleton.bones[rotateTimeline.boneIndex]; + var r1 = 0, + r2 = 0; + if (time < frames[0]) { + switch (blend) { + case core.MixBlend.setup: + bone.rotation = bone.data.rotation; + default: + return; + case core.MixBlend.first: + r1 = bone.rotation; + r2 = bone.data.rotation; + } + } else { + r1 = blend == core.MixBlend.setup ? bone.data.rotation : bone.rotation; + if (time >= frames[frames.length - core.RotateTimeline.ENTRIES]) + r2 = bone.data.rotation + frames[frames.length + core.RotateTimeline.PREV_ROTATION]; + else { + var frame = core.Animation.binarySearch(frames, time, core.RotateTimeline.ENTRIES); + var prevRotation = frames[frame + core.RotateTimeline.PREV_ROTATION]; + var frameTime = frames[frame]; + var percent = rotateTimeline.getCurvePercent( + (frame >> 1) - 1, + 1 - (time - frameTime) / (frames[frame + core.RotateTimeline.PREV_TIME] - frameTime), + ); + r2 = frames[frame + core.RotateTimeline.ROTATION] - prevRotation; + r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360; + r2 = prevRotation + r2 * percent + bone.data.rotation; + r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360; + } + } + var total = 0, + diff = r2 - r1; + diff -= (16384 - ((16384.499999999996 - diff / 360) | 0)) * 360; + if (diff == 0) { + total = timelinesRotation[i]; + } else { + var lastTotal = 0, + lastDiff = 0; + if (firstFrame) { + lastTotal = 0; + lastDiff = diff; + } else { + lastTotal = timelinesRotation[i]; + lastDiff = timelinesRotation[i + 1]; + } + var current = diff > 0, + dir = lastTotal >= 0; + if (core.MathUtils.signum(lastDiff) != core.MathUtils.signum(diff) && Math.abs(lastDiff) <= 90) { + if (Math.abs(lastTotal) > 180) lastTotal += 360 * core.MathUtils.signum(lastTotal); + dir = current; + } + total = diff + lastTotal - (lastTotal % 360); + if (dir != current) total += 360 * core.MathUtils.signum(lastTotal); + timelinesRotation[i] = total; + } + timelinesRotation[i + 1] = diff; + r1 += total * alpha; + bone.rotation = r1 - (16384 - ((16384.499999999996 - r1 / 360) | 0)) * 360; + }; + AnimationState.prototype.queueEvents = function (entry, animationTime) { + var animationStart = entry.animationStart, + animationEnd = entry.animationEnd; + var duration = animationEnd - animationStart; + var trackLastWrapped = entry.trackLast % duration; + var events = this.events; + var i = 0, + n = events.length; + for (; i < n; i++) { + var event_1 = events[i]; + if (event_1.time < trackLastWrapped) break; + if (event_1.time > animationEnd) continue; + this.queue.event(entry, event_1); + } + var complete = false; + if (entry.loop) complete = duration == 0 || trackLastWrapped > entry.trackTime % duration; + else complete = animationTime >= animationEnd && entry.animationLast < animationEnd; + if (complete) this.queue.complete(entry); + for (; i < n; i++) { + var event_2 = events[i]; + if (event_2.time < animationStart) continue; + this.queue.event(entry, events[i]); + } + }; + AnimationState.prototype.clearTracks = function () { + var oldDrainDisabled = this.queue.drainDisabled; + this.queue.drainDisabled = true; + for (var i = 0, n = this.tracks.length; i < n; i++) this.clearTrack(i); + this.tracks.length = 0; + this.queue.drainDisabled = oldDrainDisabled; + this.queue.drain(); + }; + AnimationState.prototype.clearTrack = function (trackIndex) { + if (trackIndex >= this.tracks.length) return; + var current = this.tracks[trackIndex]; + if (current == null) return; + this.queue.end(current); + this.disposeNext(current); + var entry = current; + while (true) { + var from = entry.mixingFrom; + if (from == null) break; + this.queue.end(from); + entry.mixingFrom = null; + entry.mixingTo = null; + entry = from; + } + this.tracks[current.trackIndex] = null; + this.queue.drain(); + }; + AnimationState.prototype.setCurrent = function (index, current, interrupt) { + var from = this.expandToIndex(index); + this.tracks[index] = current; + if (from != null) { + if (interrupt) this.queue.interrupt(from); + current.mixingFrom = from; + from.mixingTo = current; + current.mixTime = 0; + if (from.mixingFrom != null && from.mixDuration > 0) + current.interruptAlpha *= Math.min(1, from.mixTime / from.mixDuration); + from.timelinesRotation.length = 0; + } + this.queue.start(current); + }; + AnimationState.prototype.setAnimation = function (trackIndex, animationName, loop) { + var animation = this.data.skeletonData.findAnimation(animationName); + if (animation == null) throw new Error('Animation not found: ' + animationName); + return this.setAnimationWith(trackIndex, animation, loop); + }; + AnimationState.prototype.setAnimationWith = function (trackIndex, animation, loop) { + if (animation == null) throw new Error('animation cannot be null.'); + var interrupt = true; + var current = this.expandToIndex(trackIndex); + if (current != null) { + if (current.nextTrackLast == -1) { + this.tracks[trackIndex] = current.mixingFrom; + this.queue.interrupt(current); + this.queue.end(current); + this.disposeNext(current); + current = current.mixingFrom; + interrupt = false; + } else this.disposeNext(current); + } + var entry = this.trackEntry(trackIndex, animation, loop, current); + this.setCurrent(trackIndex, entry, interrupt); + this.queue.drain(); + return entry; + }; + AnimationState.prototype.addAnimation = function (trackIndex, animationName, loop, delay) { + var animation = this.data.skeletonData.findAnimation(animationName); + if (animation == null) throw new Error('Animation not found: ' + animationName); + return this.addAnimationWith(trackIndex, animation, loop, delay); + }; + AnimationState.prototype.addAnimationWith = function (trackIndex, animation, loop, delay) { + if (animation == null) throw new Error('animation cannot be null.'); + var last = this.expandToIndex(trackIndex); + if (last != null) { + while (last.next != null) last = last.next; + } + var entry = this.trackEntry(trackIndex, animation, loop, last); + if (last == null) { + this.setCurrent(trackIndex, entry, true); + this.queue.drain(); + } else { + last.next = entry; + if (delay <= 0) { + var duration = last.animationEnd - last.animationStart; + if (duration != 0) { + if (last.loop) delay += duration * (1 + ((last.trackTime / duration) | 0)); + else delay += Math.max(duration, last.trackTime); + delay -= this.data.getMix(last.animation, animation); + } else delay = last.trackTime; + } + } + entry.delay = delay; + return entry; + }; + AnimationState.prototype.setEmptyAnimation = function (trackIndex, mixDuration) { + var entry = this.setAnimationWith(trackIndex, AnimationState.emptyAnimation, false); + entry.mixDuration = mixDuration; + entry.trackEnd = mixDuration; + return entry; + }; + AnimationState.prototype.addEmptyAnimation = function (trackIndex, mixDuration, delay) { + if (delay <= 0) delay -= mixDuration; + var entry = this.addAnimationWith(trackIndex, AnimationState.emptyAnimation, false, delay); + entry.mixDuration = mixDuration; + entry.trackEnd = mixDuration; + return entry; + }; + AnimationState.prototype.setEmptyAnimations = function (mixDuration) { + var oldDrainDisabled = this.queue.drainDisabled; + this.queue.drainDisabled = true; + for (var i = 0, n = this.tracks.length; i < n; i++) { + var current = this.tracks[i]; + if (current != null) this.setEmptyAnimation(current.trackIndex, mixDuration); + } + this.queue.drainDisabled = oldDrainDisabled; + this.queue.drain(); + }; + AnimationState.prototype.expandToIndex = function (index) { + if (index < this.tracks.length) return this.tracks[index]; + core.Utils.ensureArrayCapacity(this.tracks, index - this.tracks.length + 1, null); + this.tracks.length = index + 1; + return null; + }; + AnimationState.prototype.trackEntry = function (trackIndex, animation, loop, last) { + var entry = this.trackEntryPool.obtain(); + entry.trackIndex = trackIndex; + entry.animation = animation; + entry.loop = loop; + entry.holdPrevious = false; + entry.eventThreshold = 0; + entry.attachmentThreshold = 0; + entry.drawOrderThreshold = 0; + entry.animationStart = 0; + entry.animationEnd = animation.duration; + entry.animationLast = -1; + entry.nextAnimationLast = -1; + entry.delay = 0; + entry.trackTime = 0; + entry.trackLast = -1; + entry.nextTrackLast = -1; + entry.trackEnd = Number.MAX_VALUE; + entry.timeScale = 1; + entry.alpha = 1; + entry.interruptAlpha = 1; + entry.mixTime = 0; + entry.mixDuration = last == null ? 0 : this.data.getMix(last.animation, animation); + return entry; + }; + AnimationState.prototype.disposeNext = function (entry) { + var next = entry.next; + while (next != null) { + this.queue.dispose(next); + next = next.next; + } + entry.next = null; + }; + AnimationState.prototype._animationsChanged = function () { + this.animationsChanged = false; + this.propertyIDs.clear(); + for (var i = 0, n = this.tracks.length; i < n; i++) { + var entry = this.tracks[i]; + if (entry == null) continue; + while (entry.mixingFrom != null) entry = entry.mixingFrom; + do { + if (entry.mixingFrom == null || entry.mixBlend != core.MixBlend.add) this.setTimelineModes(entry); + entry = entry.mixingTo; + } while (entry != null); + } + }; + AnimationState.prototype.setTimelineModes = function (entry) { + var to = entry.mixingTo; + var timelines = entry.animation.timelines; + var timelinesCount = entry.animation.timelines.length; + var timelineMode = core.Utils.setArraySize(entry.timelineMode, timelinesCount); + entry.timelineHoldMix.length = 0; + var timelineDipMix = core.Utils.setArraySize(entry.timelineHoldMix, timelinesCount); + var propertyIDs = this.propertyIDs; + if (to != null && to.holdPrevious) { + for (var i = 0; i < timelinesCount; i++) { + propertyIDs.add(timelines[i].getPropertyId()); + timelineMode[i] = AnimationState.HOLD; + } + return; + } + outer: for (var i = 0; i < timelinesCount; i++) { + var id = timelines[i].getPropertyId(); + if (!propertyIDs.add(id)) timelineMode[i] = AnimationState.SUBSEQUENT; + else if (to == null || !this.hasTimeline(to, id)) timelineMode[i] = AnimationState.FIRST; + else { + for (var next = to.mixingTo; next != null; next = next.mixingTo) { + if (this.hasTimeline(next, id)) continue; + if (entry.mixDuration > 0) { + timelineMode[i] = AnimationState.HOLD_MIX; + timelineDipMix[i] = next; + continue outer; + } + break; + } + timelineMode[i] = AnimationState.HOLD; + } + } + }; + AnimationState.prototype.hasTimeline = function (entry, id) { + var timelines = entry.animation.timelines; + for (var i = 0, n = timelines.length; i < n; i++) if (timelines[i].getPropertyId() == id) return true; + return false; + }; + AnimationState.prototype.getCurrent = function (trackIndex) { + if (trackIndex >= this.tracks.length) return null; + return this.tracks[trackIndex]; + }; + AnimationState.prototype.addListener = function (listener) { + if (listener == null) throw new Error('listener cannot be null.'); + this.listeners.push(listener); + }; + AnimationState.prototype.removeListener = function (listener) { + var index = this.listeners.indexOf(listener); + if (index >= 0) this.listeners.splice(index, 1); + }; + AnimationState.prototype.clearListeners = function () { + this.listeners.length = 0; + }; + AnimationState.prototype.clearListenerNotifications = function () { + this.queue.clear(); + }; + AnimationState.prototype.setAnimationByName = function (trackIndex, animationName, loop) { + if (!AnimationState.deprecatedWarning1) { + AnimationState.deprecatedWarning1 = true; + console.warn( + 'Spine Deprecation Warning: AnimationState.setAnimationByName is deprecated, please use setAnimation from now on.', + ); + } + this.setAnimation(trackIndex, animationName, loop); + }; + AnimationState.prototype.addAnimationByName = function (trackIndex, animationName, loop, delay) { + if (!AnimationState.deprecatedWarning2) { + AnimationState.deprecatedWarning2 = true; + console.warn( + 'Spine Deprecation Warning: AnimationState.addAnimationByName is deprecated, please use addAnimation from now on.', + ); + } + this.addAnimation(trackIndex, animationName, loop, delay); + }; + AnimationState.prototype.hasAnimation = function (animationName) { + var animation = this.data.skeletonData.findAnimation(animationName); + return animation !== null; + }; + AnimationState.prototype.hasAnimationByName = function (animationName) { + if (!AnimationState.deprecatedWarning3) { + AnimationState.deprecatedWarning3 = true; + console.warn( + 'Spine Deprecation Warning: AnimationState.hasAnimationByName is deprecated, please use hasAnimation from now on.', + ); + } + return this.hasAnimation(animationName); + }; + AnimationState.emptyAnimation = new core.Animation('', [], 0); + AnimationState.SUBSEQUENT = 0; + AnimationState.FIRST = 1; + AnimationState.HOLD = 2; + AnimationState.HOLD_MIX = 3; + AnimationState.deprecatedWarning1 = false; + AnimationState.deprecatedWarning2 = false; + AnimationState.deprecatedWarning3 = false; + return AnimationState; + })(); + core.AnimationState = AnimationState; + var TrackEntry = (function () { + function TrackEntry() { + this.mixBlend = core.MixBlend.replace; + this.timelineMode = new Array(); + this.timelineHoldMix = new Array(); + this.timelinesRotation = new Array(); + } + TrackEntry.prototype.reset = function () { + this.next = null; + this.mixingFrom = null; + this.mixingTo = null; + this.animation = null; + this.listener = null; + this.timelineMode.length = 0; + this.timelineHoldMix.length = 0; + this.timelinesRotation.length = 0; + }; + TrackEntry.prototype.getAnimationTime = function () { + if (this.loop) { + var duration = this.animationEnd - this.animationStart; + if (duration == 0) return this.animationStart; + return (this.trackTime % duration) + this.animationStart; + } + return Math.min(this.trackTime + this.animationStart, this.animationEnd); + }; + TrackEntry.prototype.setAnimationLast = function (animationLast) { + this.animationLast = animationLast; + this.nextAnimationLast = animationLast; + }; + TrackEntry.prototype.isComplete = function () { + return this.trackTime >= this.animationEnd - this.animationStart; + }; + TrackEntry.prototype.resetRotationDirections = function () { + this.timelinesRotation.length = 0; + }; + Object.defineProperty(TrackEntry.prototype, 'time', { + get: function () { + if (!TrackEntry.deprecatedWarning1) { + TrackEntry.deprecatedWarning1 = true; + console.warn('Spine Deprecation Warning: TrackEntry.time is deprecated, please use trackTime from now on.'); + } + return this.trackTime; + }, + set: function (value) { + if (!TrackEntry.deprecatedWarning1) { + TrackEntry.deprecatedWarning1 = true; + console.warn('Spine Deprecation Warning: TrackEntry.time is deprecated, please use trackTime from now on.'); + } + this.trackTime = value; + }, + enumerable: true, + configurable: true, + }); + Object.defineProperty(TrackEntry.prototype, 'endTime', { + get: function () { + if (!TrackEntry.deprecatedWarning2) { + TrackEntry.deprecatedWarning2 = true; + console.warn( + 'Spine Deprecation Warning: TrackEntry.endTime is deprecated, please use trackEnd from now on.', + ); + } + return this.trackTime; + }, + set: function (value) { + if (!TrackEntry.deprecatedWarning2) { + TrackEntry.deprecatedWarning2 = true; + console.warn( + 'Spine Deprecation Warning: TrackEntry.endTime is deprecated, please use trackEnd from now on.', + ); + } + this.trackTime = value; + }, + enumerable: true, + configurable: true, + }); + TrackEntry.prototype.loopsCount = function () { + return Math.floor(this.trackTime / this.trackEnd); + }; + TrackEntry.deprecatedWarning1 = false; + TrackEntry.deprecatedWarning2 = false; + return TrackEntry; + })(); + core.TrackEntry = TrackEntry; + var EventQueue = (function () { + function EventQueue(animState) { + this.objects = []; + this.drainDisabled = false; + this.animState = animState; + } + EventQueue.prototype.start = function (entry) { + this.objects.push(EventType.start); + this.objects.push(entry); + this.animState.animationsChanged = true; + }; + EventQueue.prototype.interrupt = function (entry) { + this.objects.push(EventType.interrupt); + this.objects.push(entry); + }; + EventQueue.prototype.end = function (entry) { + this.objects.push(EventType.end); + this.objects.push(entry); + this.animState.animationsChanged = true; + }; + EventQueue.prototype.dispose = function (entry) { + this.objects.push(EventType.dispose); + this.objects.push(entry); + }; + EventQueue.prototype.complete = function (entry) { + this.objects.push(EventType.complete); + this.objects.push(entry); + }; + EventQueue.prototype.event = function (entry, event) { + this.objects.push(EventType.event); + this.objects.push(entry); + this.objects.push(event); + }; + EventQueue.prototype.deprecateStuff = function () { + if (!EventQueue.deprecatedWarning1) { + EventQueue.deprecatedWarning1 = true; + console.warn( + "Spine Deprecation Warning: onComplete, onStart, onEnd, onEvent art deprecated, please use listeners from now on. 'state.addListener({ complete: function(track, event) { } })'", + ); + } + return true; + }; + EventQueue.prototype.drain = function () { + if (this.drainDisabled) return; + this.drainDisabled = true; + var objects = this.objects; + var listeners = this.animState.listeners; + for (var i = 0; i < objects.length; i += 2) { + var type = objects[i]; + var entry = objects[i + 1]; + switch (type) { + case EventType.start: + if (entry.listener != null && entry.listener.start) entry.listener.start(entry); + for (var ii = 0; ii < listeners.length; ii++) if (listeners[ii].start) listeners[ii].start(entry); + entry.onStart && this.deprecateStuff() && entry.onStart(entry.trackIndex); + this.animState.onStart && + this.deprecateStuff() && + this.deprecateStuff && + this.animState.onStart(entry.trackIndex); + break; + case EventType.interrupt: + if (entry.listener != null && entry.listener.interrupt) entry.listener.interrupt(entry); + for (var ii = 0; ii < listeners.length; ii++) if (listeners[ii].interrupt) listeners[ii].interrupt(entry); + break; + case EventType.end: + if (entry.listener != null && entry.listener.end) entry.listener.end(entry); + for (var ii = 0; ii < listeners.length; ii++) if (listeners[ii].end) listeners[ii].end(entry); + entry.onEnd && this.deprecateStuff() && entry.onEnd(entry.trackIndex); + this.animState.onEnd && this.deprecateStuff() && this.animState.onEnd(entry.trackIndex); + case EventType.dispose: + if (entry.listener != null && entry.listener.dispose) entry.listener.dispose(entry); + for (var ii = 0; ii < listeners.length; ii++) if (listeners[ii].dispose) listeners[ii].dispose(entry); + this.animState.trackEntryPool.free(entry); + break; + case EventType.complete: + if (entry.listener != null && entry.listener.complete) entry.listener.complete(entry); + for (var ii = 0; ii < listeners.length; ii++) if (listeners[ii].complete) listeners[ii].complete(entry); + var count = core.MathUtils.toInt(entry.loopsCount()); + entry.onComplete && this.deprecateStuff() && entry.onComplete(entry.trackIndex, count); + this.animState.onComplete && this.deprecateStuff() && this.animState.onComplete(entry.trackIndex, count); + break; + case EventType.event: + var event_3 = objects[i++ + 2]; + if (entry.listener != null && entry.listener.event) entry.listener.event(entry, event_3); + for (var ii = 0; ii < listeners.length; ii++) + if (listeners[ii].event) listeners[ii].event(entry, event_3); + entry.onEvent && this.deprecateStuff() && entry.onEvent(entry.trackIndex, event_3); + this.animState.onEvent && this.deprecateStuff() && this.animState.onEvent(entry.trackIndex, event_3); + break; + } + } + this.clear(); + this.drainDisabled = false; + }; + EventQueue.prototype.clear = function () { + this.objects.length = 0; + }; + EventQueue.deprecatedWarning1 = false; + return EventQueue; + })(); + core.EventQueue = EventQueue; + var EventType; + (function (EventType) { + EventType[(EventType['start'] = 0)] = 'start'; + EventType[(EventType['interrupt'] = 1)] = 'interrupt'; + EventType[(EventType['end'] = 2)] = 'end'; + EventType[(EventType['dispose'] = 3)] = 'dispose'; + EventType[(EventType['complete'] = 4)] = 'complete'; + EventType[(EventType['event'] = 5)] = 'event'; + })((EventType = core.EventType || (core.EventType = {}))); + var AnimationStateAdapter2 = (function () { + function AnimationStateAdapter2() {} + AnimationStateAdapter2.prototype.start = function (entry) {}; + AnimationStateAdapter2.prototype.interrupt = function (entry) {}; + AnimationStateAdapter2.prototype.end = function (entry) {}; + AnimationStateAdapter2.prototype.dispose = function (entry) {}; + AnimationStateAdapter2.prototype.complete = function (entry) {}; + AnimationStateAdapter2.prototype.event = function (entry, event) {}; + return AnimationStateAdapter2; + })(); + core.AnimationStateAdapter2 = AnimationStateAdapter2; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var AnimationStateData = (function () { + function AnimationStateData(skeletonData) { + this.animationToMixTime = {}; + this.defaultMix = 0; + if (skeletonData == null) throw new Error('skeletonData cannot be null.'); + this.skeletonData = skeletonData; + } + AnimationStateData.prototype.setMix = function (fromName, toName, duration) { + var from = this.skeletonData.findAnimation(fromName); + if (from == null) throw new Error('Animation not found: ' + fromName); + var to = this.skeletonData.findAnimation(toName); + if (to == null) throw new Error('Animation not found: ' + toName); + this.setMixWith(from, to, duration); + }; + AnimationStateData.prototype.setMixByName = function (fromName, toName, duration) { + if (!AnimationStateData.deprecatedWarning1) { + AnimationStateData.deprecatedWarning1 = true; + console.warn( + 'Deprecation Warning: AnimationStateData.setMixByName is deprecated, please use setMix from now on.', + ); + } + this.setMix(fromName, toName, duration); + }; + AnimationStateData.prototype.setMixWith = function (from, to, duration) { + if (from == null) throw new Error('from cannot be null.'); + if (to == null) throw new Error('to cannot be null.'); + var key = from.name + '.' + to.name; + this.animationToMixTime[key] = duration; + }; + AnimationStateData.prototype.getMix = function (from, to) { + var key = from.name + '.' + to.name; + var value = this.animationToMixTime[key]; + return value === undefined ? this.defaultMix : value; + }; + AnimationStateData.deprecatedWarning1 = false; + return AnimationStateData; + })(); + core.AnimationStateData = AnimationStateData; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var AtlasAttachmentLoader = (function () { + function AtlasAttachmentLoader(atlas) { + this.atlas = atlas; + } + AtlasAttachmentLoader.prototype.newRegionAttachment = function (skin, name, path) { + var region = this.atlas.findRegion(path); + if (region == null) + throw new Error('Region not found in atlas: ' + path + ' (region attachment: ' + name + ')'); + var attachment = new core.RegionAttachment(name); + attachment.region = region; + return attachment; + }; + AtlasAttachmentLoader.prototype.newMeshAttachment = function (skin, name, path) { + var region = this.atlas.findRegion(path); + if (region == null) throw new Error('Region not found in atlas: ' + path + ' (mesh attachment: ' + name + ')'); + var attachment = new core.MeshAttachment(name); + attachment.region = region; + return attachment; + }; + AtlasAttachmentLoader.prototype.newBoundingBoxAttachment = function (skin, name) { + return new core.BoundingBoxAttachment(name); + }; + AtlasAttachmentLoader.prototype.newPathAttachment = function (skin, name) { + return new core.PathAttachment(name); + }; + AtlasAttachmentLoader.prototype.newPointAttachment = function (skin, name) { + return new core.PointAttachment(name); + }; + AtlasAttachmentLoader.prototype.newClippingAttachment = function (skin, name) { + return new core.ClippingAttachment(name); + }; + return AtlasAttachmentLoader; + })(); + core.AtlasAttachmentLoader = AtlasAttachmentLoader; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var BlendMode; + (function (BlendMode) { + BlendMode[(BlendMode['Normal'] = 0)] = 'Normal'; + BlendMode[(BlendMode['Additive'] = 1)] = 'Additive'; + BlendMode[(BlendMode['Multiply'] = 2)] = 'Multiply'; + BlendMode[(BlendMode['Screen'] = 3)] = 'Screen'; + })((BlendMode = core.BlendMode || (core.BlendMode = {}))); + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var Bone = (function () { + function Bone(data, skeleton, parent) { + this.matrix = new PIXI.Matrix(); + this.children = new Array(); + this.x = 0; + this.y = 0; + this.rotation = 0; + this.scaleX = 0; + this.scaleY = 0; + this.shearX = 0; + this.shearY = 0; + this.ax = 0; + this.ay = 0; + this.arotation = 0; + this.ascaleX = 0; + this.ascaleY = 0; + this.ashearX = 0; + this.ashearY = 0; + this.appliedValid = false; + this.sorted = false; + if (data == null) throw new Error('data cannot be null.'); + if (skeleton == null) throw new Error('skeleton cannot be null.'); + this.data = data; + this.skeleton = skeleton; + this.parent = parent; + this.setToSetupPose(); + } + Object.defineProperty(Bone.prototype, 'worldX', { + get: function () { + return this.matrix.tx; + }, + enumerable: true, + configurable: true, + }); + Object.defineProperty(Bone.prototype, 'worldY', { + get: function () { + return this.matrix.ty; + }, + enumerable: true, + configurable: true, + }); + Bone.prototype.update = function () { + this.updateWorldTransformWith( + this.x, + this.y, + this.rotation, + this.scaleX, + this.scaleY, + this.shearX, + this.shearY, + ); + }; + Bone.prototype.updateWorldTransform = function () { + this.updateWorldTransformWith( + this.x, + this.y, + this.rotation, + this.scaleX, + this.scaleY, + this.shearX, + this.shearY, + ); + }; + Bone.prototype.updateWorldTransformWith = function (x, y, rotation, scaleX, scaleY, shearX, shearY) { + this.ax = x; + this.ay = y; + this.arotation = rotation; + this.ascaleX = scaleX; + this.ascaleY = scaleY; + this.ashearX = shearX; + this.ashearY = shearY; + this.appliedValid = true; + var parent = this.parent; + var m = this.matrix; + var sx = this.skeleton.scaleX; + var sy = Bone.yDown ? -this.skeleton.scaleY : this.skeleton.scaleY; + if (parent == null) { + if (Bone.yDown) { + rotation = -rotation; + this.arotation = rotation; + } + var skeleton = this.skeleton; + var rotationY = rotation + 90 + shearY; + m.a = core.MathUtils.cosDeg(rotation + shearX) * scaleX * sx; + m.c = core.MathUtils.cosDeg(rotationY) * scaleY * sy; + m.b = core.MathUtils.sinDeg(rotation + shearX) * scaleX * sx; + m.d = core.MathUtils.sinDeg(rotationY) * scaleY * sy; + m.tx = x * sx + skeleton.x; + m.ty = y * sy + skeleton.y; + return; + } + var pa = parent.matrix.a, + pb = parent.matrix.c, + pc = parent.matrix.b, + pd = parent.matrix.d; + m.tx = pa * x + pb * y + parent.matrix.tx; + m.ty = pc * x + pd * y + parent.matrix.ty; + switch (this.data.transformMode) { + case core.TransformMode.Normal: { + var rotationY = rotation + 90 + shearY; + var la = core.MathUtils.cosDeg(rotation + shearX) * scaleX; + var lb = core.MathUtils.cosDeg(rotationY) * scaleY; + var lc = core.MathUtils.sinDeg(rotation + shearX) * scaleX; + var ld = core.MathUtils.sinDeg(rotationY) * scaleY; + m.a = pa * la + pb * lc; + m.c = pa * lb + pb * ld; + m.b = pc * la + pd * lc; + m.d = pc * lb + pd * ld; + return; + } + case core.TransformMode.OnlyTranslation: { + var rotationY = rotation + 90 + shearY; + m.a = core.MathUtils.cosDeg(rotation + shearX) * scaleX; + m.c = core.MathUtils.cosDeg(rotationY) * scaleY; + m.b = core.MathUtils.sinDeg(rotation + shearX) * scaleX; + m.d = core.MathUtils.sinDeg(rotationY) * scaleY; + break; + } + case core.TransformMode.NoRotationOrReflection: { + var s = pa * pa + pc * pc; + var prx = 0; + if (s > 0.0001) { + s = Math.abs(pa * pd - pb * pc) / s; + pb = pc * s; + pd = pa * s; + prx = Math.atan2(pc, pa) * core.MathUtils.radDeg; + } else { + pa = 0; + pc = 0; + prx = 90 - Math.atan2(pd, pb) * core.MathUtils.radDeg; + } + var rx = rotation + shearX - prx; + var ry = rotation + shearY - prx + 90; + var la = core.MathUtils.cosDeg(rx) * scaleX; + var lb = core.MathUtils.cosDeg(ry) * scaleY; + var lc = core.MathUtils.sinDeg(rx) * scaleX; + var ld = core.MathUtils.sinDeg(ry) * scaleY; + m.a = pa * la - pb * lc; + m.c = pa * lb - pb * ld; + m.b = pc * la + pd * lc; + m.d = pc * lb + pd * ld; + break; + } + case core.TransformMode.NoScale: + case core.TransformMode.NoScaleOrReflection: { + var cos = core.MathUtils.cosDeg(rotation); + var sin = core.MathUtils.sinDeg(rotation); + var za = (pa * cos + pb * sin) / sx; + var zc = (pc * cos + pd * sin) / sy; + var s = Math.sqrt(za * za + zc * zc); + if (s > 0.00001) s = 1 / s; + za *= s; + zc *= s; + s = Math.sqrt(za * za + zc * zc); + if ( + this.data.transformMode == core.TransformMode.NoScale && + pa * pd - pb * pc < 0 != + (Bone.yDown + ? this.skeleton.scaleX < 0 != this.skeleton.scaleY > 0 + : this.skeleton.scaleX < 0 != this.skeleton.scaleY < 0) + ) + s = -s; + var r = Math.PI / 2 + Math.atan2(zc, za); + var zb = Math.cos(r) * s; + var zd = Math.sin(r) * s; + var la = core.MathUtils.cosDeg(shearX) * scaleX; + var lb = core.MathUtils.cosDeg(90 + shearY) * scaleY; + var lc = core.MathUtils.sinDeg(shearX) * scaleX; + var ld = core.MathUtils.sinDeg(90 + shearY) * scaleY; + m.a = za * la + zb * lc; + m.c = za * lb + zb * ld; + m.b = zc * la + zd * lc; + m.d = zc * lb + zd * ld; + break; + } + } + m.a *= sx; + m.c *= sx; + m.b *= sy; + m.d *= sy; + }; + Bone.prototype.setToSetupPose = function () { + var data = this.data; + this.x = data.x; + this.y = data.y; + this.rotation = data.rotation; + this.scaleX = data.scaleX; + this.scaleY = data.scaleY; + this.shearX = data.shearX; + this.shearY = data.shearY; + }; + Bone.prototype.getWorldRotationX = function () { + return Math.atan2(this.matrix.b, this.matrix.a) * core.MathUtils.radDeg; + }; + Bone.prototype.getWorldRotationY = function () { + return Math.atan2(this.matrix.d, this.matrix.c) * core.MathUtils.radDeg; + }; + Bone.prototype.getWorldScaleX = function () { + var m = this.matrix; + return Math.sqrt(m.a * m.a + m.c * m.c); + }; + Bone.prototype.getWorldScaleY = function () { + var m = this.matrix; + return Math.sqrt(m.b * m.b + m.d * m.d); + }; + Bone.prototype.updateAppliedTransform = function () { + this.appliedValid = true; + var parent = this.parent; + var m = this.matrix; + if (parent == null) { + this.ax = m.tx; + this.ay = m.ty; + this.arotation = Math.atan2(m.b, m.a) * core.MathUtils.radDeg; + this.ascaleX = Math.sqrt(m.a * m.a + m.b * m.b); + this.ascaleY = Math.sqrt(m.c * m.c + m.d * m.d); + this.ashearX = 0; + this.ashearY = Math.atan2(m.a * m.c + m.b * m.d, m.a * m.d - m.b * m.c) * core.MathUtils.radDeg; + return; + } + var pm = parent.matrix; + var pid = 1 / (pm.a * pm.d - pm.b * pm.c); + var dx = m.tx - pm.tx, + dy = m.ty - pm.ty; + this.ax = dx * pm.d * pid - dy * pm.c * pid; + this.ay = dy * pm.a * pid - dx * pm.b * pid; + var ia = pid * pm.d; + var id = pid * pm.a; + var ib = pid * pm.c; + var ic = pid * pm.b; + var ra = ia * m.a - ib * m.b; + var rb = ia * m.c - ib * m.d; + var rc = id * m.b - ic * m.a; + var rd = id * m.d - ic * m.c; + this.ashearX = 0; + this.ascaleX = Math.sqrt(ra * ra + rc * rc); + if (this.ascaleX > 0.0001) { + var det = ra * rd - rb * rc; + this.ascaleY = det / this.ascaleX; + this.ashearY = Math.atan2(ra * rb + rc * rd, det) * core.MathUtils.radDeg; + this.arotation = Math.atan2(rc, ra) * core.MathUtils.radDeg; + } else { + this.ascaleX = 0; + this.ascaleY = Math.sqrt(rb * rb + rd * rd); + this.ashearY = 0; + this.arotation = 90 - Math.atan2(rd, rb) * core.MathUtils.radDeg; + } + }; + Bone.prototype.worldToLocal = function (world) { + var m = this.matrix; + var a = m.a, + b = m.c, + c = m.b, + d = m.d; + var invDet = 1 / (a * d - b * c); + var x = world.x - m.tx, + y = world.y - m.ty; + world.x = x * d * invDet - y * b * invDet; + world.y = y * a * invDet - x * c * invDet; + return world; + }; + Bone.prototype.localToWorld = function (local) { + var m = this.matrix; + var x = local.x, + y = local.y; + local.x = x * m.a + y * m.c + m.tx; + local.y = x * m.b + y * m.d + m.ty; + return local; + }; + Bone.prototype.worldToLocalRotation = function (worldRotation) { + var sin = core.MathUtils.sinDeg(worldRotation), + cos = core.MathUtils.cosDeg(worldRotation); + var mat = this.matrix; + return Math.atan2(mat.a * sin - mat.b * cos, mat.d * cos - mat.c * sin) * core.MathUtils.radDeg; + }; + Bone.prototype.localToWorldRotation = function (localRotation) { + var sin = core.MathUtils.sinDeg(localRotation), + cos = core.MathUtils.cosDeg(localRotation); + var mat = this.matrix; + return Math.atan2(cos * mat.b + sin * mat.d, cos * mat.a + sin * mat.c) * core.MathUtils.radDeg; + }; + Bone.prototype.rotateWorld = function (degrees) { + var mat = this.matrix; + var a = mat.a, + b = mat.c, + c = mat.b, + d = mat.d; + var cos = core.MathUtils.cosDeg(degrees), + sin = core.MathUtils.sinDeg(degrees); + mat.a = cos * a - sin * c; + mat.c = cos * b - sin * d; + mat.b = sin * a + cos * c; + mat.d = sin * b + cos * d; + this.appliedValid = false; + }; + Bone.yDown = false; + return Bone; + })(); + core.Bone = Bone; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var BoneData = (function () { + function BoneData(index, name, parent) { + this.x = 0; + this.y = 0; + this.rotation = 0; + this.scaleX = 1; + this.scaleY = 1; + this.shearX = 0; + this.shearY = 0; + this.transformMode = TransformMode.Normal; + if (index < 0) throw new Error('index must be >= 0.'); + if (name == null) throw new Error('name cannot be null.'); + this.index = index; + this.name = name; + this.parent = parent; + } + return BoneData; + })(); + core.BoneData = BoneData; + var TransformMode; + (function (TransformMode) { + TransformMode[(TransformMode['Normal'] = 0)] = 'Normal'; + TransformMode[(TransformMode['OnlyTranslation'] = 1)] = 'OnlyTranslation'; + TransformMode[(TransformMode['NoRotationOrReflection'] = 2)] = 'NoRotationOrReflection'; + TransformMode[(TransformMode['NoScale'] = 3)] = 'NoScale'; + TransformMode[(TransformMode['NoScaleOrReflection'] = 4)] = 'NoScaleOrReflection'; + })((TransformMode = core.TransformMode || (core.TransformMode = {}))); + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var Event = (function () { + function Event(time, data) { + if (data == null) throw new Error('data cannot be null.'); + this.time = time; + this.data = data; + } + return Event; + })(); + core.Event = Event; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var EventData = (function () { + function EventData(name) { + this.name = name; + } + return EventData; + })(); + core.EventData = EventData; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var IkConstraint = (function () { + function IkConstraint(data, skeleton) { + this.bendDirection = 0; + this.compress = false; + this.stretch = false; + this.mix = 1; + if (data == null) throw new Error('data cannot be null.'); + if (skeleton == null) throw new Error('skeleton cannot be null.'); + this.data = data; + this.mix = data.mix; + this.bendDirection = data.bendDirection; + this.compress = data.compress; + this.stretch = data.stretch; + this.bones = new Array(); + for (var i = 0; i < data.bones.length; i++) this.bones.push(skeleton.findBone(data.bones[i].name)); + this.target = skeleton.findBone(data.target.name); + } + IkConstraint.prototype.getOrder = function () { + return this.data.order; + }; + IkConstraint.prototype.apply = function () { + this.update(); + }; + IkConstraint.prototype.update = function () { + var target = this.target; + var bones = this.bones; + switch (bones.length) { + case 1: + this.apply1( + bones[0], + target.worldX, + target.worldY, + this.compress, + this.stretch, + this.data.uniform, + this.mix, + ); + break; + case 2: + this.apply2(bones[0], bones[1], target.worldX, target.worldY, this.bendDirection, this.stretch, this.mix); + break; + } + }; + IkConstraint.prototype.apply1 = function (bone, targetX, targetY, compress, stretch, uniform, alpha) { + if (!bone.appliedValid) bone.updateAppliedTransform(); + var p = bone.parent.matrix; + var id = 1 / (p.a * p.d - p.b * p.c); + var x = targetX - p.tx, + y = targetY - p.ty; + var tx = (x * p.d - y * p.c) * id - bone.ax, + ty = (y * p.a - x * p.b) * id - bone.ay; + var rotationIK = Math.atan2(ty, tx) * core.MathUtils.radDeg - bone.ashearX - bone.arotation; + if (bone.ascaleX < 0) rotationIK += 180; + if (rotationIK > 180) rotationIK -= 360; + else if (rotationIK < -180) rotationIK += 360; + var sx = bone.ascaleX, + sy = bone.ascaleY; + if (compress || stretch) { + var b = bone.data.length * sx, + dd = Math.sqrt(tx * tx + ty * ty); + if ((compress && dd < b) || (stretch && dd > b && b > 0.0001)) { + var s = (dd / b - 1) * alpha + 1; + sx *= s; + if (uniform) sy *= s; + } + } + bone.updateWorldTransformWith( + bone.ax, + bone.ay, + bone.arotation + rotationIK * alpha, + sx, + sy, + bone.ashearX, + bone.ashearY, + ); + }; + IkConstraint.prototype.apply2 = function (parent, child, targetX, targetY, bendDir, stretch, alpha) { + if (alpha == 0) { + child.updateWorldTransform(); + return; + } + if (!parent.appliedValid) parent.updateAppliedTransform(); + if (!child.appliedValid) child.updateAppliedTransform(); + var px = parent.ax, + py = parent.ay, + psx = parent.ascaleX, + sx = psx, + psy = parent.ascaleY, + csx = child.ascaleX; + var pmat = parent.matrix; + var os1 = 0, + os2 = 0, + s2 = 0; + if (psx < 0) { + psx = -psx; + os1 = 180; + s2 = -1; + } else { + os1 = 0; + s2 = 1; + } + if (psy < 0) { + psy = -psy; + s2 = -s2; + } + if (csx < 0) { + csx = -csx; + os2 = 180; + } else os2 = 0; + var cx = child.ax, + cy = 0, + cwx = 0, + cwy = 0, + a = pmat.a, + b = pmat.c, + c = pmat.b, + d = pmat.d; + var u = Math.abs(psx - psy) <= 0.0001; + if (!u) { + cy = 0; + cwx = a * cx + pmat.tx; + cwy = c * cx + pmat.ty; + } else { + cy = child.ay; + cwx = a * cx + b * cy + pmat.tx; + cwy = c * cx + d * cy + pmat.ty; + } + var pp = parent.parent.matrix; + a = pp.a; + b = pp.c; + c = pp.b; + d = pp.d; + var id = 1 / (a * d - b * c), + x = targetX - pp.tx, + y = targetY - pp.ty; + var tx = (x * d - y * b) * id - px, + ty = (y * a - x * c) * id - py, + dd = tx * tx + ty * ty; + x = cwx - pp.tx; + y = cwy - pp.ty; + var dx = (x * d - y * b) * id - px, + dy = (y * a - x * c) * id - py; + var l1 = Math.sqrt(dx * dx + dy * dy), + l2 = child.data.length * csx, + a1 = 0, + a2 = 0; + outer: if (u) { + l2 *= psx; + var cos = (dd - l1 * l1 - l2 * l2) / (2 * l1 * l2); + if (cos < -1) cos = -1; + else if (cos > 1) { + cos = 1; + if (stretch && l1 + l2 > 0.0001) sx *= (Math.sqrt(dd) / (l1 + l2) - 1) * alpha + 1; + } + a2 = Math.acos(cos) * bendDir; + a = l1 + l2 * cos; + b = l2 * Math.sin(a2); + a1 = Math.atan2(ty * a - tx * b, tx * a + ty * b); + } else { + a = psx * l2; + b = psy * l2; + var aa = a * a, + bb = b * b, + ta = Math.atan2(ty, tx); + c = bb * l1 * l1 + aa * dd - aa * bb; + var c1 = -2 * bb * l1, + c2 = bb - aa; + d = c1 * c1 - 4 * c2 * c; + if (d >= 0) { + var q = Math.sqrt(d); + if (c1 < 0) q = -q; + q = -(c1 + q) / 2; + var r0 = q / c2, + r1 = c / q; + var r = Math.abs(r0) < Math.abs(r1) ? r0 : r1; + if (r * r <= dd) { + y = Math.sqrt(dd - r * r) * bendDir; + a1 = ta - Math.atan2(y, r); + a2 = Math.atan2(y / psy, (r - l1) / psx); + break outer; + } + } + var minAngle = core.MathUtils.PI, + minX = l1 - a, + minDist = minX * minX, + minY = 0; + var maxAngle = 0, + maxX = l1 + a, + maxDist = maxX * maxX, + maxY = 0; + c = (-a * l1) / (aa - bb); + if (c >= -1 && c <= 1) { + c = Math.acos(c); + x = a * Math.cos(c) + l1; + y = b * Math.sin(c); + d = x * x + y * y; + if (d < minDist) { + minAngle = c; + minDist = d; + minX = x; + minY = y; + } + if (d > maxDist) { + maxAngle = c; + maxDist = d; + maxX = x; + maxY = y; + } + } + if (dd <= (minDist + maxDist) / 2) { + a1 = ta - Math.atan2(minY * bendDir, minX); + a2 = minAngle * bendDir; + } else { + a1 = ta - Math.atan2(maxY * bendDir, maxX); + a2 = maxAngle * bendDir; + } + } + var os = Math.atan2(cy, cx) * s2; + var rotation = parent.arotation; + a1 = (a1 - os) * core.MathUtils.radDeg + os1 - rotation; + if (a1 > 180) a1 -= 360; + else if (a1 < -180) a1 += 360; + parent.updateWorldTransformWith(px, py, rotation + a1 * alpha, sx, parent.ascaleY, 0, 0); + rotation = child.arotation; + a2 = ((a2 + os) * core.MathUtils.radDeg - child.ashearX) * s2 + os2 - rotation; + if (a2 > 180) a2 -= 360; + else if (a2 < -180) a2 += 360; + child.updateWorldTransformWith( + cx, + cy, + rotation + a2 * alpha, + child.ascaleX, + child.ascaleY, + child.ashearX, + child.ashearY, + ); + }; + return IkConstraint; + })(); + core.IkConstraint = IkConstraint; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var IkConstraintData = (function () { + function IkConstraintData(name) { + this.order = 0; + this.bones = new Array(); + this.bendDirection = 1; + this.compress = false; + this.stretch = false; + this.uniform = false; + this.mix = 1; + this.name = name; + } + return IkConstraintData; + })(); + core.IkConstraintData = IkConstraintData; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var PathConstraint = (function () { + function PathConstraint(data, skeleton) { + this.position = 0; + this.spacing = 0; + this.rotateMix = 0; + this.translateMix = 0; + this.spaces = new Array(); + this.positions = new Array(); + this.world = new Array(); + this.curves = new Array(); + this.lengths = new Array(); + this.segments = new Array(); + if (data == null) throw new Error('data cannot be null.'); + if (skeleton == null) throw new Error('skeleton cannot be null.'); + this.data = data; + this.bones = new Array(); + for (var i = 0, n = data.bones.length; i < n; i++) this.bones.push(skeleton.findBone(data.bones[i].name)); + this.target = skeleton.findSlot(data.target.name); + this.position = data.position; + this.spacing = data.spacing; + this.rotateMix = data.rotateMix; + this.translateMix = data.translateMix; + } + PathConstraint.prototype.apply = function () { + this.update(); + }; + PathConstraint.prototype.update = function () { + var attachment = this.target.getAttachment(); + if (!(attachment instanceof core.PathAttachment)) return; + var rotateMix = this.rotateMix, + translateMix = this.translateMix; + var translate = translateMix > 0, + rotate = rotateMix > 0; + if (!translate && !rotate) return; + var data = this.data; + var spacingMode = data.spacingMode; + var lengthSpacing = spacingMode == core.SpacingMode.Length; + var rotateMode = data.rotateMode; + var tangents = rotateMode == core.RotateMode.Tangent, + scale = rotateMode == core.RotateMode.ChainScale; + var boneCount = this.bones.length, + spacesCount = tangents ? boneCount : boneCount + 1; + var bones = this.bones; + var spaces = core.Utils.setArraySize(this.spaces, spacesCount), + lengths = null; + var spacing = this.spacing; + if (scale || lengthSpacing) { + if (scale) lengths = core.Utils.setArraySize(this.lengths, boneCount); + for (var i = 0, n = spacesCount - 1; i < n; ) { + var bone = bones[i]; + var setupLength = bone.data.length; + if (setupLength < PathConstraint.epsilon) { + if (scale) lengths[i] = 0; + spaces[++i] = 0; + } else { + var x = setupLength * bone.matrix.a, + y = setupLength * bone.matrix.b; + var length_1 = Math.sqrt(x * x + y * y); + if (scale) lengths[i] = length_1; + spaces[++i] = ((lengthSpacing ? setupLength + spacing : spacing) * length_1) / setupLength; + } + } + } else { + for (var i = 1; i < spacesCount; i++) spaces[i] = spacing; + } + var positions = this.computeWorldPositions( + attachment, + spacesCount, + tangents, + data.positionMode == core.PositionMode.Percent, + spacingMode == core.SpacingMode.Percent, + ); + var boneX = positions[0], + boneY = positions[1], + offsetRotation = data.offsetRotation; + var tip = false; + if (offsetRotation == 0) tip = rotateMode == core.RotateMode.Chain; + else { + tip = false; + var p = this.target.bone.matrix; + offsetRotation *= p.a * p.d - p.b * p.c > 0 ? core.MathUtils.degRad : -core.MathUtils.degRad; + } + for (var i = 0, p = 3; i < boneCount; i++, p += 3) { + var bone = bones[i]; + var mat = bone.matrix; + mat.tx += (boneX - mat.tx) * translateMix; + mat.ty += (boneY - mat.ty) * translateMix; + var x = positions[p], + y = positions[p + 1], + dx = x - boneX, + dy = y - boneY; + if (scale) { + var length_2 = lengths[i]; + if (length_2 != 0) { + var s = (Math.sqrt(dx * dx + dy * dy) / length_2 - 1) * rotateMix + 1; + mat.a *= s; + mat.b *= s; + } + } + boneX = x; + boneY = y; + if (rotate) { + var a = mat.a, + b = mat.c, + c = mat.b, + d = mat.d, + r = 0, + cos = 0, + sin = 0; + if (tangents) r = positions[p - 1]; + else if (spaces[i + 1] == 0) r = positions[p + 2]; + else r = Math.atan2(dy, dx); + r -= Math.atan2(c, a); + if (tip) { + cos = Math.cos(r); + sin = Math.sin(r); + var length_3 = bone.data.length; + boneX += (length_3 * (cos * a - sin * c) - dx) * rotateMix; + boneY += (length_3 * (sin * a + cos * c) - dy) * rotateMix; + } else { + r += offsetRotation; + } + if (r > core.MathUtils.PI) r -= core.MathUtils.PI2; + else if (r < -core.MathUtils.PI) r += core.MathUtils.PI2; + r *= rotateMix; + cos = Math.cos(r); + sin = Math.sin(r); + mat.a = cos * a - sin * c; + mat.c = cos * b - sin * d; + mat.b = sin * a + cos * c; + mat.d = sin * b + cos * d; + } + bone.appliedValid = false; + } + }; + PathConstraint.prototype.computeWorldPositions = function ( + path, + spacesCount, + tangents, + percentPosition, + percentSpacing, + ) { + var target = this.target; + var position = this.position; + var spaces = this.spaces, + out = core.Utils.setArraySize(this.positions, spacesCount * 3 + 2), + world = null; + var closed = path.closed; + var verticesLength = path.worldVerticesLength, + curveCount = verticesLength / 6, + prevCurve = PathConstraint.NONE; + if (!path.constantSpeed) { + var lengths = path.lengths; + curveCount -= closed ? 1 : 2; + var pathLength_1 = lengths[curveCount]; + if (percentPosition) position *= pathLength_1; + if (percentSpacing) { + for (var i = 0; i < spacesCount; i++) spaces[i] *= pathLength_1; + } + world = core.Utils.setArraySize(this.world, 8); + for (var i = 0, o = 0, curve = 0; i < spacesCount; i++, o += 3) { + var space = spaces[i]; + position += space; + var p = position; + if (closed) { + p %= pathLength_1; + if (p < 0) p += pathLength_1; + curve = 0; + } else if (p < 0) { + if (prevCurve != PathConstraint.BEFORE) { + prevCurve = PathConstraint.BEFORE; + path.computeWorldVertices(target, 2, 4, world, 0, 2); + } + this.addBeforePosition(p, world, 0, out, o); + continue; + } else if (p > pathLength_1) { + if (prevCurve != PathConstraint.AFTER) { + prevCurve = PathConstraint.AFTER; + path.computeWorldVertices(target, verticesLength - 6, 4, world, 0, 2); + } + this.addAfterPosition(p - pathLength_1, world, 0, out, o); + continue; + } + for (; ; curve++) { + var length_4 = lengths[curve]; + if (p > length_4) continue; + if (curve == 0) p /= length_4; + else { + var prev = lengths[curve - 1]; + p = (p - prev) / (length_4 - prev); + } + break; + } + if (curve != prevCurve) { + prevCurve = curve; + if (closed && curve == curveCount) { + path.computeWorldVertices(target, verticesLength - 4, 4, world, 0, 2); + path.computeWorldVertices(target, 0, 4, world, 4, 2); + } else path.computeWorldVertices(target, curve * 6 + 2, 8, world, 0, 2); + } + this.addCurvePosition( + p, + world[0], + world[1], + world[2], + world[3], + world[4], + world[5], + world[6], + world[7], + out, + o, + tangents || (i > 0 && space == 0), + ); + } + return out; + } + if (closed) { + verticesLength += 2; + world = core.Utils.setArraySize(this.world, verticesLength); + path.computeWorldVertices(target, 2, verticesLength - 4, world, 0, 2); + path.computeWorldVertices(target, 0, 2, world, verticesLength - 4, 2); + world[verticesLength - 2] = world[0]; + world[verticesLength - 1] = world[1]; + } else { + curveCount--; + verticesLength -= 4; + world = core.Utils.setArraySize(this.world, verticesLength); + path.computeWorldVertices(target, 2, verticesLength, world, 0, 2); + } + var curves = core.Utils.setArraySize(this.curves, curveCount); + var pathLength = 0; + var x1 = world[0], + y1 = world[1], + cx1 = 0, + cy1 = 0, + cx2 = 0, + cy2 = 0, + x2 = 0, + y2 = 0; + var tmpx = 0, + tmpy = 0, + dddfx = 0, + dddfy = 0, + ddfx = 0, + ddfy = 0, + dfx = 0, + dfy = 0; + for (var i = 0, w = 2; i < curveCount; i++, w += 6) { + cx1 = world[w]; + cy1 = world[w + 1]; + cx2 = world[w + 2]; + cy2 = world[w + 3]; + x2 = world[w + 4]; + y2 = world[w + 5]; + tmpx = (x1 - cx1 * 2 + cx2) * 0.1875; + tmpy = (y1 - cy1 * 2 + cy2) * 0.1875; + dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.09375; + dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.09375; + ddfx = tmpx * 2 + dddfx; + ddfy = tmpy * 2 + dddfy; + dfx = (cx1 - x1) * 0.75 + tmpx + dddfx * 0.16666667; + dfy = (cy1 - y1) * 0.75 + tmpy + dddfy * 0.16666667; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + dfx += ddfx; + dfy += ddfy; + ddfx += dddfx; + ddfy += dddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + dfx += ddfx; + dfy += ddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + dfx += ddfx + dddfx; + dfy += ddfy + dddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + curves[i] = pathLength; + x1 = x2; + y1 = y2; + } + if (percentPosition) position *= pathLength; + if (percentSpacing) { + for (var i = 0; i < spacesCount; i++) spaces[i] *= pathLength; + } + var segments = this.segments; + var curveLength = 0; + for (var i = 0, o = 0, curve = 0, segment = 0; i < spacesCount; i++, o += 3) { + var space = spaces[i]; + position += space; + var p = position; + if (closed) { + p %= pathLength; + if (p < 0) p += pathLength; + curve = 0; + } else if (p < 0) { + this.addBeforePosition(p, world, 0, out, o); + continue; + } else if (p > pathLength) { + this.addAfterPosition(p - pathLength, world, verticesLength - 4, out, o); + continue; + } + for (; ; curve++) { + var length_5 = curves[curve]; + if (p > length_5) continue; + if (curve == 0) p /= length_5; + else { + var prev = curves[curve - 1]; + p = (p - prev) / (length_5 - prev); + } + break; + } + if (curve != prevCurve) { + prevCurve = curve; + var ii = curve * 6; + x1 = world[ii]; + y1 = world[ii + 1]; + cx1 = world[ii + 2]; + cy1 = world[ii + 3]; + cx2 = world[ii + 4]; + cy2 = world[ii + 5]; + x2 = world[ii + 6]; + y2 = world[ii + 7]; + tmpx = (x1 - cx1 * 2 + cx2) * 0.03; + tmpy = (y1 - cy1 * 2 + cy2) * 0.03; + dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.006; + dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.006; + ddfx = tmpx * 2 + dddfx; + ddfy = tmpy * 2 + dddfy; + dfx = (cx1 - x1) * 0.3 + tmpx + dddfx * 0.16666667; + dfy = (cy1 - y1) * 0.3 + tmpy + dddfy * 0.16666667; + curveLength = Math.sqrt(dfx * dfx + dfy * dfy); + segments[0] = curveLength; + for (ii = 1; ii < 8; ii++) { + dfx += ddfx; + dfy += ddfy; + ddfx += dddfx; + ddfy += dddfy; + curveLength += Math.sqrt(dfx * dfx + dfy * dfy); + segments[ii] = curveLength; + } + dfx += ddfx; + dfy += ddfy; + curveLength += Math.sqrt(dfx * dfx + dfy * dfy); + segments[8] = curveLength; + dfx += ddfx + dddfx; + dfy += ddfy + dddfy; + curveLength += Math.sqrt(dfx * dfx + dfy * dfy); + segments[9] = curveLength; + segment = 0; + } + p *= curveLength; + for (; ; segment++) { + var length_6 = segments[segment]; + if (p > length_6) continue; + if (segment == 0) p /= length_6; + else { + var prev = segments[segment - 1]; + p = segment + (p - prev) / (length_6 - prev); + } + break; + } + this.addCurvePosition(p * 0.1, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, o, tangents || (i > 0 && space == 0)); + } + return out; + }; + PathConstraint.prototype.addBeforePosition = function (p, temp, i, out, o) { + var x1 = temp[i], + y1 = temp[i + 1], + dx = temp[i + 2] - x1, + dy = temp[i + 3] - y1, + r = Math.atan2(dy, dx); + out[o] = x1 + p * Math.cos(r); + out[o + 1] = y1 + p * Math.sin(r); + out[o + 2] = r; + }; + PathConstraint.prototype.addAfterPosition = function (p, temp, i, out, o) { + var x1 = temp[i + 2], + y1 = temp[i + 3], + dx = x1 - temp[i], + dy = y1 - temp[i + 1], + r = Math.atan2(dy, dx); + out[o] = x1 + p * Math.cos(r); + out[o + 1] = y1 + p * Math.sin(r); + out[o + 2] = r; + }; + PathConstraint.prototype.addCurvePosition = function (p, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, o, tangents) { + if (p == 0 || isNaN(p)) p = 0.0001; + var tt = p * p, + ttt = tt * p, + u = 1 - p, + uu = u * u, + uuu = uu * u; + var ut = u * p, + ut3 = ut * 3, + uut3 = u * ut3, + utt3 = ut3 * p; + var x = x1 * uuu + cx1 * uut3 + cx2 * utt3 + x2 * ttt, + y = y1 * uuu + cy1 * uut3 + cy2 * utt3 + y2 * ttt; + out[o] = x; + out[o + 1] = y; + if (tangents) + out[o + 2] = Math.atan2(y - (y1 * uu + cy1 * ut * 2 + cy2 * tt), x - (x1 * uu + cx1 * ut * 2 + cx2 * tt)); + }; + PathConstraint.prototype.getOrder = function () { + return this.data.order; + }; + PathConstraint.NONE = -1; + PathConstraint.BEFORE = -2; + PathConstraint.AFTER = -3; + PathConstraint.epsilon = 0.00001; + return PathConstraint; + })(); + core.PathConstraint = PathConstraint; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var PathConstraintData = (function () { + function PathConstraintData(name) { + this.order = 0; + this.bones = new Array(); + this.name = name; + } + return PathConstraintData; + })(); + core.PathConstraintData = PathConstraintData; + var PositionMode; + (function (PositionMode) { + PositionMode[(PositionMode['Fixed'] = 0)] = 'Fixed'; + PositionMode[(PositionMode['Percent'] = 1)] = 'Percent'; + })((PositionMode = core.PositionMode || (core.PositionMode = {}))); + var SpacingMode; + (function (SpacingMode) { + SpacingMode[(SpacingMode['Length'] = 0)] = 'Length'; + SpacingMode[(SpacingMode['Fixed'] = 1)] = 'Fixed'; + SpacingMode[(SpacingMode['Percent'] = 2)] = 'Percent'; + })((SpacingMode = core.SpacingMode || (core.SpacingMode = {}))); + var RotateMode; + (function (RotateMode) { + RotateMode[(RotateMode['Tangent'] = 0)] = 'Tangent'; + RotateMode[(RotateMode['Chain'] = 1)] = 'Chain'; + RotateMode[(RotateMode['ChainScale'] = 2)] = 'ChainScale'; + })((RotateMode = core.RotateMode || (core.RotateMode = {}))); + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var Skeleton = (function () { + function Skeleton(data) { + this._updateCache = new Array(); + this.updateCacheReset = new Array(); + this.time = 0; + this.scaleX = 1; + this.scaleY = 1; + this.x = 0; + this.y = 0; + if (data == null) throw new Error('data cannot be null.'); + this.data = data; + this.bones = new Array(); + for (var i = 0; i < data.bones.length; i++) { + var boneData = data.bones[i]; + var bone = void 0; + if (boneData.parent == null) bone = new core.Bone(boneData, this, null); + else { + var parent_1 = this.bones[boneData.parent.index]; + bone = new core.Bone(boneData, this, parent_1); + parent_1.children.push(bone); + } + this.bones.push(bone); + } + this.slots = new Array(); + this.drawOrder = new Array(); + for (var i = 0; i < data.slots.length; i++) { + var slotData = data.slots[i]; + var bone = this.bones[slotData.boneData.index]; + var slot = new core.Slot(slotData, bone); + this.slots.push(slot); + this.drawOrder.push(slot); + } + this.ikConstraints = new Array(); + for (var i = 0; i < data.ikConstraints.length; i++) { + var ikConstraintData = data.ikConstraints[i]; + this.ikConstraints.push(new core.IkConstraint(ikConstraintData, this)); + } + this.transformConstraints = new Array(); + for (var i = 0; i < data.transformConstraints.length; i++) { + var transformConstraintData = data.transformConstraints[i]; + this.transformConstraints.push(new core.TransformConstraint(transformConstraintData, this)); + } + this.pathConstraints = new Array(); + for (var i = 0; i < data.pathConstraints.length; i++) { + var pathConstraintData = data.pathConstraints[i]; + this.pathConstraints.push(new core.PathConstraint(pathConstraintData, this)); + } + this.color = new core.Color(1, 1, 1, 1); + this.updateCache(); + } + Skeleton.prototype.updateCache = function () { + var updateCache = this._updateCache; + updateCache.length = 0; + this.updateCacheReset.length = 0; + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) bones[i].sorted = false; + var ikConstraints = this.ikConstraints; + var transformConstraints = this.transformConstraints; + var pathConstraints = this.pathConstraints; + var ikCount = ikConstraints.length, + transformCount = transformConstraints.length, + pathCount = pathConstraints.length; + var constraintCount = ikCount + transformCount + pathCount; + outer: for (var i = 0; i < constraintCount; i++) { + for (var ii = 0; ii < ikCount; ii++) { + var constraint = ikConstraints[ii]; + if (constraint.data.order == i) { + this.sortIkConstraint(constraint); + continue outer; + } + } + for (var ii = 0; ii < transformCount; ii++) { + var constraint = transformConstraints[ii]; + if (constraint.data.order == i) { + this.sortTransformConstraint(constraint); + continue outer; + } + } + for (var ii = 0; ii < pathCount; ii++) { + var constraint = pathConstraints[ii]; + if (constraint.data.order == i) { + this.sortPathConstraint(constraint); + continue outer; + } + } + } + for (var i = 0, n = bones.length; i < n; i++) this.sortBone(bones[i]); + }; + Skeleton.prototype.sortIkConstraint = function (constraint) { + var target = constraint.target; + this.sortBone(target); + var constrained = constraint.bones; + var parent = constrained[0]; + this.sortBone(parent); + if (constrained.length > 1) { + var child = constrained[constrained.length - 1]; + if (!(this._updateCache.indexOf(child) > -1)) this.updateCacheReset.push(child); + } + this._updateCache.push(constraint); + this.sortReset(parent.children); + constrained[constrained.length - 1].sorted = true; + }; + Skeleton.prototype.sortPathConstraint = function (constraint) { + var slot = constraint.target; + var slotIndex = slot.data.index; + var slotBone = slot.bone; + if (this.skin != null) this.sortPathConstraintAttachment(this.skin, slotIndex, slotBone); + if (this.data.defaultSkin != null && this.data.defaultSkin != this.skin) + this.sortPathConstraintAttachment(this.data.defaultSkin, slotIndex, slotBone); + for (var i = 0, n = this.data.skins.length; i < n; i++) + this.sortPathConstraintAttachment(this.data.skins[i], slotIndex, slotBone); + var attachment = slot.getAttachment(); + if (attachment instanceof core.PathAttachment) this.sortPathConstraintAttachmentWith(attachment, slotBone); + var constrained = constraint.bones; + var boneCount = constrained.length; + for (var i = 0; i < boneCount; i++) this.sortBone(constrained[i]); + this._updateCache.push(constraint); + for (var i = 0; i < boneCount; i++) this.sortReset(constrained[i].children); + for (var i = 0; i < boneCount; i++) constrained[i].sorted = true; + }; + Skeleton.prototype.sortTransformConstraint = function (constraint) { + this.sortBone(constraint.target); + var constrained = constraint.bones; + var boneCount = constrained.length; + if (constraint.data.local) { + for (var i = 0; i < boneCount; i++) { + var child = constrained[i]; + this.sortBone(child.parent); + if (!(this._updateCache.indexOf(child) > -1)) this.updateCacheReset.push(child); + } + } else { + for (var i = 0; i < boneCount; i++) { + this.sortBone(constrained[i]); + } + } + this._updateCache.push(constraint); + for (var ii = 0; ii < boneCount; ii++) this.sortReset(constrained[ii].children); + for (var ii = 0; ii < boneCount; ii++) constrained[ii].sorted = true; + }; + Skeleton.prototype.sortPathConstraintAttachment = function (skin, slotIndex, slotBone) { + var attachments = skin.attachments[slotIndex]; + if (!attachments) return; + for (var key in attachments) { + this.sortPathConstraintAttachmentWith(attachments[key], slotBone); + } + }; + Skeleton.prototype.sortPathConstraintAttachmentWith = function (attachment, slotBone) { + if (!(attachment instanceof core.PathAttachment)) return; + var pathBones = attachment.bones; + if (pathBones == null) this.sortBone(slotBone); + else { + var bones = this.bones; + var i = 0; + while (i < pathBones.length) { + var boneCount = pathBones[i++]; + for (var n = i + boneCount; i < n; i++) { + var boneIndex = pathBones[i]; + this.sortBone(bones[boneIndex]); + } + } + } + }; + Skeleton.prototype.sortBone = function (bone) { + if (bone.sorted) return; + var parent = bone.parent; + if (parent != null) this.sortBone(parent); + bone.sorted = true; + this._updateCache.push(bone); + }; + Skeleton.prototype.sortReset = function (bones) { + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (bone.sorted) this.sortReset(bone.children); + bone.sorted = false; + } + }; + Skeleton.prototype.updateWorldTransform = function () { + var updateCacheReset = this.updateCacheReset; + for (var i = 0, n = updateCacheReset.length; i < n; i++) { + var bone = updateCacheReset[i]; + bone.ax = bone.x; + bone.ay = bone.y; + bone.arotation = bone.rotation; + bone.ascaleX = bone.scaleX; + bone.ascaleY = bone.scaleY; + bone.ashearX = bone.shearX; + bone.ashearY = bone.shearY; + bone.appliedValid = true; + } + var updateCache = this._updateCache; + for (var i = 0, n = updateCache.length; i < n; i++) updateCache[i].update(); + }; + Skeleton.prototype.setToSetupPose = function () { + this.setBonesToSetupPose(); + this.setSlotsToSetupPose(); + }; + Skeleton.prototype.setBonesToSetupPose = function () { + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) bones[i].setToSetupPose(); + var ikConstraints = this.ikConstraints; + for (var i = 0, n = ikConstraints.length; i < n; i++) { + var constraint = ikConstraints[i]; + constraint.bendDirection = constraint.data.bendDirection; + constraint.mix = constraint.data.mix; + } + var transformConstraints = this.transformConstraints; + for (var i = 0, n = transformConstraints.length; i < n; i++) { + var constraint = transformConstraints[i]; + var data = constraint.data; + constraint.rotateMix = data.rotateMix; + constraint.translateMix = data.translateMix; + constraint.scaleMix = data.scaleMix; + constraint.shearMix = data.shearMix; + } + var pathConstraints = this.pathConstraints; + for (var i = 0, n = pathConstraints.length; i < n; i++) { + var constraint = pathConstraints[i]; + var data = constraint.data; + constraint.position = data.position; + constraint.spacing = data.spacing; + constraint.rotateMix = data.rotateMix; + constraint.translateMix = data.translateMix; + } + }; + Skeleton.prototype.setSlotsToSetupPose = function () { + var slots = this.slots; + core.Utils.arrayCopy(slots, 0, this.drawOrder, 0, slots.length); + for (var i = 0, n = slots.length; i < n; i++) slots[i].setToSetupPose(); + }; + Skeleton.prototype.getRootBone = function () { + if (this.bones.length == 0) return null; + return this.bones[0]; + }; + Skeleton.prototype.findBone = function (boneName) { + if (boneName == null) throw new Error('boneName cannot be null.'); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (bone.data.name == boneName) return bone; + } + return null; + }; + Skeleton.prototype.findBoneIndex = function (boneName) { + if (boneName == null) throw new Error('boneName cannot be null.'); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) if (bones[i].data.name == boneName) return i; + return -1; + }; + Skeleton.prototype.findSlot = function (slotName) { + if (slotName == null) throw new Error('slotName cannot be null.'); + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + if (slot.data.name == slotName) return slot; + } + return null; + }; + Skeleton.prototype.findSlotIndex = function (slotName) { + if (slotName == null) throw new Error('slotName cannot be null.'); + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) if (slots[i].data.name == slotName) return i; + return -1; + }; + Skeleton.prototype.setSkinByName = function (skinName) { + var skin = this.data.findSkin(skinName); + if (skin == null) throw new Error('Skin not found: ' + skinName); + this.setSkin(skin); + }; + Skeleton.prototype.setSkin = function (newSkin) { + if (newSkin != null) { + if (this.skin != null) newSkin.attachAll(this, this.skin); + else { + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + var name_1 = slot.data.attachmentName; + if (name_1 != null) { + var attachment = newSkin.getAttachment(i, name_1); + if (attachment != null) slot.setAttachment(attachment); + } + } + } + } + this.skin = newSkin; + }; + Skeleton.prototype.getAttachmentByName = function (slotName, attachmentName) { + return this.getAttachment(this.data.findSlotIndex(slotName), attachmentName); + }; + Skeleton.prototype.getAttachment = function (slotIndex, attachmentName) { + if (attachmentName == null) throw new Error('attachmentName cannot be null.'); + if (this.skin != null) { + var attachment = this.skin.getAttachment(slotIndex, attachmentName); + if (attachment != null) return attachment; + } + if (this.data.defaultSkin != null) return this.data.defaultSkin.getAttachment(slotIndex, attachmentName); + return null; + }; + Skeleton.prototype.setAttachment = function (slotName, attachmentName) { + if (slotName == null) throw new Error('slotName cannot be null.'); + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + if (slot.data.name == slotName) { + var attachment = null; + if (attachmentName != null) { + attachment = this.getAttachment(i, attachmentName); + if (attachment == null) + throw new Error('Attachment not found: ' + attachmentName + ', for slot: ' + slotName); + } + slot.setAttachment(attachment); + return; + } + } + throw new Error('Slot not found: ' + slotName); + }; + Skeleton.prototype.findIkConstraint = function (constraintName) { + if (constraintName == null) throw new Error('constraintName cannot be null.'); + var ikConstraints = this.ikConstraints; + for (var i = 0, n = ikConstraints.length; i < n; i++) { + var ikConstraint = ikConstraints[i]; + if (ikConstraint.data.name == constraintName) return ikConstraint; + } + return null; + }; + Skeleton.prototype.findTransformConstraint = function (constraintName) { + if (constraintName == null) throw new Error('constraintName cannot be null.'); + var transformConstraints = this.transformConstraints; + for (var i = 0, n = transformConstraints.length; i < n; i++) { + var constraint = transformConstraints[i]; + if (constraint.data.name == constraintName) return constraint; + } + return null; + }; + Skeleton.prototype.findPathConstraint = function (constraintName) { + if (constraintName == null) throw new Error('constraintName cannot be null.'); + var pathConstraints = this.pathConstraints; + for (var i = 0, n = pathConstraints.length; i < n; i++) { + var constraint = pathConstraints[i]; + if (constraint.data.name == constraintName) return constraint; + } + return null; + }; + Skeleton.prototype.getBounds = function (offset, size, temp) { + if (offset == null) throw new Error('offset cannot be null.'); + if (size == null) throw new Error('size cannot be null.'); + var drawOrder = this.drawOrder; + var minX = Number.POSITIVE_INFINITY, + minY = Number.POSITIVE_INFINITY, + maxX = Number.NEGATIVE_INFINITY, + maxY = Number.NEGATIVE_INFINITY; + for (var i = 0, n = drawOrder.length; i < n; i++) { + var slot = drawOrder[i]; + var verticesLength = 0; + var vertices = null; + var attachment = slot.getAttachment(); + if (attachment instanceof core.RegionAttachment) { + verticesLength = 8; + vertices = core.Utils.setArraySize(temp, verticesLength, 0); + attachment.computeWorldVertices(slot.bone, vertices, 0, 2); + } else if (attachment instanceof core.MeshAttachment) { + var mesh = attachment; + verticesLength = mesh.worldVerticesLength; + vertices = core.Utils.setArraySize(temp, verticesLength, 0); + mesh.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2); + } + if (vertices != null) { + for (var ii = 0, nn = vertices.length; ii < nn; ii += 2) { + var x = vertices[ii], + y = vertices[ii + 1]; + minX = Math.min(minX, x); + minY = Math.min(minY, y); + maxX = Math.max(maxX, x); + maxY = Math.max(maxY, y); + } + } + } + offset.set(minX, minY); + size.set(maxX - minX, maxY - minY); + }; + Skeleton.prototype.update = function (delta) { + this.time += delta; + }; + Object.defineProperty(Skeleton.prototype, 'flipX', { + get: function () { + return this.scaleX == -1; + }, + set: function (value) { + if (!Skeleton.deprecatedWarning1) { + Skeleton.deprecatedWarning1 = true; + console.warn('Spine Deprecation Warning: `Skeleton.flipX/flipY` was deprecated, please use scaleX/scaleY'); + } + this.scaleX = value ? 1.0 : -1.0; + }, + enumerable: true, + configurable: true, + }); + Object.defineProperty(Skeleton.prototype, 'flipY', { + get: function () { + return this.scaleY == -1; + }, + set: function (value) { + if (!Skeleton.deprecatedWarning1) { + Skeleton.deprecatedWarning1 = true; + console.warn('Spine Deprecation Warning: `Skeleton.flipX/flipY` was deprecated, please use scaleX/scaleY'); + } + this.scaleY = value ? 1.0 : -1.0; + }, + enumerable: true, + configurable: true, + }); + Skeleton.deprecatedWarning1 = false; + return Skeleton; + })(); + core.Skeleton = Skeleton; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var SkeletonBounds = (function () { + function SkeletonBounds() { + this.minX = 0; + this.minY = 0; + this.maxX = 0; + this.maxY = 0; + this.boundingBoxes = new Array(); + this.polygons = new Array(); + this.polygonPool = new core.Pool(function () { + return core.Utils.newFloatArray(16); + }); + } + SkeletonBounds.prototype.update = function (skeleton, updateAabb) { + if (skeleton == null) throw new Error('skeleton cannot be null.'); + var boundingBoxes = this.boundingBoxes; + var polygons = this.polygons; + var polygonPool = this.polygonPool; + var slots = skeleton.slots; + var slotCount = slots.length; + boundingBoxes.length = 0; + polygonPool.freeAll(polygons); + polygons.length = 0; + for (var i = 0; i < slotCount; i++) { + var slot = slots[i]; + var attachment = slot.getAttachment(); + if (attachment instanceof core.BoundingBoxAttachment) { + var boundingBox = attachment; + boundingBoxes.push(boundingBox); + var polygon = polygonPool.obtain(); + if (polygon.length != boundingBox.worldVerticesLength) { + polygon = core.Utils.newFloatArray(boundingBox.worldVerticesLength); + } + polygons.push(polygon); + boundingBox.computeWorldVertices(slot, 0, boundingBox.worldVerticesLength, polygon, 0, 2); + } + } + if (updateAabb) { + this.aabbCompute(); + } else { + this.minX = Number.POSITIVE_INFINITY; + this.minY = Number.POSITIVE_INFINITY; + this.maxX = Number.NEGATIVE_INFINITY; + this.maxY = Number.NEGATIVE_INFINITY; + } + }; + SkeletonBounds.prototype.aabbCompute = function () { + var minX = Number.POSITIVE_INFINITY, + minY = Number.POSITIVE_INFINITY, + maxX = Number.NEGATIVE_INFINITY, + maxY = Number.NEGATIVE_INFINITY; + var polygons = this.polygons; + for (var i = 0, n = polygons.length; i < n; i++) { + var polygon = polygons[i]; + var vertices = polygon; + for (var ii = 0, nn = polygon.length; ii < nn; ii += 2) { + var x = vertices[ii]; + var y = vertices[ii + 1]; + minX = Math.min(minX, x); + minY = Math.min(minY, y); + maxX = Math.max(maxX, x); + maxY = Math.max(maxY, y); + } + } + this.minX = minX; + this.minY = minY; + this.maxX = maxX; + this.maxY = maxY; + }; + SkeletonBounds.prototype.aabbContainsPoint = function (x, y) { + return x >= this.minX && x <= this.maxX && y >= this.minY && y <= this.maxY; + }; + SkeletonBounds.prototype.aabbIntersectsSegment = function (x1, y1, x2, y2) { + var minX = this.minX; + var minY = this.minY; + var maxX = this.maxX; + var maxY = this.maxY; + if ( + (x1 <= minX && x2 <= minX) || + (y1 <= minY && y2 <= minY) || + (x1 >= maxX && x2 >= maxX) || + (y1 >= maxY && y2 >= maxY) + ) + return false; + var m = (y2 - y1) / (x2 - x1); + var y = m * (minX - x1) + y1; + if (y > minY && y < maxY) return true; + y = m * (maxX - x1) + y1; + if (y > minY && y < maxY) return true; + var x = (minY - y1) / m + x1; + if (x > minX && x < maxX) return true; + x = (maxY - y1) / m + x1; + if (x > minX && x < maxX) return true; + return false; + }; + SkeletonBounds.prototype.aabbIntersectsSkeleton = function (bounds) { + return this.minX < bounds.maxX && this.maxX > bounds.minX && this.minY < bounds.maxY && this.maxY > bounds.minY; + }; + SkeletonBounds.prototype.containsPoint = function (x, y) { + var polygons = this.polygons; + for (var i = 0, n = polygons.length; i < n; i++) + if (this.containsPointPolygon(polygons[i], x, y)) return this.boundingBoxes[i]; + return null; + }; + SkeletonBounds.prototype.containsPointPolygon = function (polygon, x, y) { + var vertices = polygon; + var nn = polygon.length; + var prevIndex = nn - 2; + var inside = false; + for (var ii = 0; ii < nn; ii += 2) { + var vertexY = vertices[ii + 1]; + var prevY = vertices[prevIndex + 1]; + if ((vertexY < y && prevY >= y) || (prevY < y && vertexY >= y)) { + var vertexX = vertices[ii]; + if (vertexX + ((y - vertexY) / (prevY - vertexY)) * (vertices[prevIndex] - vertexX) < x) inside = !inside; + } + prevIndex = ii; + } + return inside; + }; + SkeletonBounds.prototype.intersectsSegment = function (x1, y1, x2, y2) { + var polygons = this.polygons; + for (var i = 0, n = polygons.length; i < n; i++) + if (this.intersectsSegmentPolygon(polygons[i], x1, y1, x2, y2)) return this.boundingBoxes[i]; + return null; + }; + SkeletonBounds.prototype.intersectsSegmentPolygon = function (polygon, x1, y1, x2, y2) { + var vertices = polygon; + var nn = polygon.length; + var width12 = x1 - x2, + height12 = y1 - y2; + var det1 = x1 * y2 - y1 * x2; + var x3 = vertices[nn - 2], + y3 = vertices[nn - 1]; + for (var ii = 0; ii < nn; ii += 2) { + var x4 = vertices[ii], + y4 = vertices[ii + 1]; + var det2 = x3 * y4 - y3 * x4; + var width34 = x3 - x4, + height34 = y3 - y4; + var det3 = width12 * height34 - height12 * width34; + var x = (det1 * width34 - width12 * det2) / det3; + if (((x >= x3 && x <= x4) || (x >= x4 && x <= x3)) && ((x >= x1 && x <= x2) || (x >= x2 && x <= x1))) { + var y = (det1 * height34 - height12 * det2) / det3; + if (((y >= y3 && y <= y4) || (y >= y4 && y <= y3)) && ((y >= y1 && y <= y2) || (y >= y2 && y <= y1))) + return true; + } + x3 = x4; + y3 = y4; + } + return false; + }; + SkeletonBounds.prototype.getPolygon = function (boundingBox) { + if (boundingBox == null) throw new Error('boundingBox cannot be null.'); + var index = this.boundingBoxes.indexOf(boundingBox); + return index == -1 ? null : this.polygons[index]; + }; + SkeletonBounds.prototype.getWidth = function () { + return this.maxX - this.minX; + }; + SkeletonBounds.prototype.getHeight = function () { + return this.maxY - this.minY; + }; + return SkeletonBounds; + })(); + core.SkeletonBounds = SkeletonBounds; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var SkeletonClipping = (function () { + function SkeletonClipping() { + this.triangulator = new core.Triangulator(); + this.clippingPolygon = new Array(); + this.clipOutput = new Array(); + this.clippedVertices = new Array(); + this.clippedTriangles = new Array(); + this.scratch = new Array(); + } + SkeletonClipping.prototype.clipStart = function (slot, clip) { + if (this.clipAttachment != null) return 0; + this.clipAttachment = clip; + var n = clip.worldVerticesLength; + var vertices = core.Utils.setArraySize(this.clippingPolygon, n); + clip.computeWorldVertices(slot, 0, n, vertices, 0, 2); + var clippingPolygon = this.clippingPolygon; + SkeletonClipping.makeClockwise(clippingPolygon); + var clippingPolygons = (this.clippingPolygons = this.triangulator.decompose( + clippingPolygon, + this.triangulator.triangulate(clippingPolygon), + )); + for (var i = 0, n_1 = clippingPolygons.length; i < n_1; i++) { + var polygon = clippingPolygons[i]; + SkeletonClipping.makeClockwise(polygon); + polygon.push(polygon[0]); + polygon.push(polygon[1]); + } + return clippingPolygons.length; + }; + SkeletonClipping.prototype.clipEndWithSlot = function (slot) { + if (this.clipAttachment != null && this.clipAttachment.endSlot == slot.data) this.clipEnd(); + }; + SkeletonClipping.prototype.clipEnd = function () { + if (this.clipAttachment == null) return; + this.clipAttachment = null; + this.clippingPolygons = null; + this.clippedVertices.length = 0; + this.clippedTriangles.length = 0; + this.clippingPolygon.length = 0; + }; + SkeletonClipping.prototype.isClipping = function () { + return this.clipAttachment != null; + }; + SkeletonClipping.prototype.clipTriangles = function ( + vertices, + verticesLength, + triangles, + trianglesLength, + uvs, + light, + dark, + twoColor, + ) { + var clipOutput = this.clipOutput, + clippedVertices = this.clippedVertices; + var clippedTriangles = this.clippedTriangles; + var polygons = this.clippingPolygons; + var polygonsCount = this.clippingPolygons.length; + var vertexSize = twoColor ? 12 : 8; + var index = 0; + clippedVertices.length = 0; + clippedTriangles.length = 0; + outer: for (var i = 0; i < trianglesLength; i += 3) { + var vertexOffset = triangles[i] << 1; + var x1 = vertices[vertexOffset], + y1 = vertices[vertexOffset + 1]; + var u1 = uvs[vertexOffset], + v1 = uvs[vertexOffset + 1]; + vertexOffset = triangles[i + 1] << 1; + var x2 = vertices[vertexOffset], + y2 = vertices[vertexOffset + 1]; + var u2 = uvs[vertexOffset], + v2 = uvs[vertexOffset + 1]; + vertexOffset = triangles[i + 2] << 1; + var x3 = vertices[vertexOffset], + y3 = vertices[vertexOffset + 1]; + var u3 = uvs[vertexOffset], + v3 = uvs[vertexOffset + 1]; + for (var p = 0; p < polygonsCount; p++) { + var s = clippedVertices.length; + if (this.clip(x1, y1, x2, y2, x3, y3, polygons[p], clipOutput)) { + var clipOutputLength = clipOutput.length; + if (clipOutputLength == 0) continue; + var d0 = y2 - y3, + d1 = x3 - x2, + d2 = x1 - x3, + d4 = y3 - y1; + var d = 1 / (d0 * d2 + d1 * (y1 - y3)); + var clipOutputCount = clipOutputLength >> 1; + var clipOutputItems = this.clipOutput; + var clippedVerticesItems = core.Utils.setArraySize(clippedVertices, s + clipOutputCount * vertexSize); + for (var ii = 0; ii < clipOutputLength; ii += 2) { + var x = clipOutputItems[ii], + y = clipOutputItems[ii + 1]; + clippedVerticesItems[s] = x; + clippedVerticesItems[s + 1] = y; + clippedVerticesItems[s + 2] = light.r; + clippedVerticesItems[s + 3] = light.g; + clippedVerticesItems[s + 4] = light.b; + clippedVerticesItems[s + 5] = light.a; + var c0 = x - x3, + c1 = y - y3; + var a = (d0 * c0 + d1 * c1) * d; + var b = (d4 * c0 + d2 * c1) * d; + var c = 1 - a - b; + clippedVerticesItems[s + 6] = u1 * a + u2 * b + u3 * c; + clippedVerticesItems[s + 7] = v1 * a + v2 * b + v3 * c; + if (twoColor) { + clippedVerticesItems[s + 8] = dark.r; + clippedVerticesItems[s + 9] = dark.g; + clippedVerticesItems[s + 10] = dark.b; + clippedVerticesItems[s + 11] = dark.a; + } + s += vertexSize; + } + s = clippedTriangles.length; + var clippedTrianglesItems = core.Utils.setArraySize(clippedTriangles, s + 3 * (clipOutputCount - 2)); + clipOutputCount--; + for (var ii = 1; ii < clipOutputCount; ii++) { + clippedTrianglesItems[s] = index; + clippedTrianglesItems[s + 1] = index + ii; + clippedTrianglesItems[s + 2] = index + ii + 1; + s += 3; + } + index += clipOutputCount + 1; + } else { + var clippedVerticesItems = core.Utils.setArraySize(clippedVertices, s + 3 * vertexSize); + clippedVerticesItems[s] = x1; + clippedVerticesItems[s + 1] = y1; + clippedVerticesItems[s + 2] = light.r; + clippedVerticesItems[s + 3] = light.g; + clippedVerticesItems[s + 4] = light.b; + clippedVerticesItems[s + 5] = light.a; + if (!twoColor) { + clippedVerticesItems[s + 6] = u1; + clippedVerticesItems[s + 7] = v1; + clippedVerticesItems[s + 8] = x2; + clippedVerticesItems[s + 9] = y2; + clippedVerticesItems[s + 10] = light.r; + clippedVerticesItems[s + 11] = light.g; + clippedVerticesItems[s + 12] = light.b; + clippedVerticesItems[s + 13] = light.a; + clippedVerticesItems[s + 14] = u2; + clippedVerticesItems[s + 15] = v2; + clippedVerticesItems[s + 16] = x3; + clippedVerticesItems[s + 17] = y3; + clippedVerticesItems[s + 18] = light.r; + clippedVerticesItems[s + 19] = light.g; + clippedVerticesItems[s + 20] = light.b; + clippedVerticesItems[s + 21] = light.a; + clippedVerticesItems[s + 22] = u3; + clippedVerticesItems[s + 23] = v3; + } else { + clippedVerticesItems[s + 6] = u1; + clippedVerticesItems[s + 7] = v1; + clippedVerticesItems[s + 8] = dark.r; + clippedVerticesItems[s + 9] = dark.g; + clippedVerticesItems[s + 10] = dark.b; + clippedVerticesItems[s + 11] = dark.a; + clippedVerticesItems[s + 12] = x2; + clippedVerticesItems[s + 13] = y2; + clippedVerticesItems[s + 14] = light.r; + clippedVerticesItems[s + 15] = light.g; + clippedVerticesItems[s + 16] = light.b; + clippedVerticesItems[s + 17] = light.a; + clippedVerticesItems[s + 18] = u2; + clippedVerticesItems[s + 19] = v2; + clippedVerticesItems[s + 20] = dark.r; + clippedVerticesItems[s + 21] = dark.g; + clippedVerticesItems[s + 22] = dark.b; + clippedVerticesItems[s + 23] = dark.a; + clippedVerticesItems[s + 24] = x3; + clippedVerticesItems[s + 25] = y3; + clippedVerticesItems[s + 26] = light.r; + clippedVerticesItems[s + 27] = light.g; + clippedVerticesItems[s + 28] = light.b; + clippedVerticesItems[s + 29] = light.a; + clippedVerticesItems[s + 30] = u3; + clippedVerticesItems[s + 31] = v3; + clippedVerticesItems[s + 32] = dark.r; + clippedVerticesItems[s + 33] = dark.g; + clippedVerticesItems[s + 34] = dark.b; + clippedVerticesItems[s + 35] = dark.a; + } + s = clippedTriangles.length; + var clippedTrianglesItems = core.Utils.setArraySize(clippedTriangles, s + 3); + clippedTrianglesItems[s] = index; + clippedTrianglesItems[s + 1] = index + 1; + clippedTrianglesItems[s + 2] = index + 2; + index += 3; + continue outer; + } + } + } + }; + SkeletonClipping.prototype.clip = function (x1, y1, x2, y2, x3, y3, clippingArea, output) { + var originalOutput = output; + var clipped = false; + var input = null; + if (clippingArea.length % 4 >= 2) { + input = output; + output = this.scratch; + } else input = this.scratch; + input.length = 0; + input.push(x1); + input.push(y1); + input.push(x2); + input.push(y2); + input.push(x3); + input.push(y3); + input.push(x1); + input.push(y1); + output.length = 0; + var clippingVertices = clippingArea; + var clippingVerticesLast = clippingArea.length - 4; + for (var i = 0; ; i += 2) { + var edgeX = clippingVertices[i], + edgeY = clippingVertices[i + 1]; + var edgeX2 = clippingVertices[i + 2], + edgeY2 = clippingVertices[i + 3]; + var deltaX = edgeX - edgeX2, + deltaY = edgeY - edgeY2; + var inputVertices = input; + var inputVerticesLength = input.length - 2, + outputStart = output.length; + for (var ii = 0; ii < inputVerticesLength; ii += 2) { + var inputX = inputVertices[ii], + inputY = inputVertices[ii + 1]; + var inputX2 = inputVertices[ii + 2], + inputY2 = inputVertices[ii + 3]; + var side2 = deltaX * (inputY2 - edgeY2) - deltaY * (inputX2 - edgeX2) > 0; + if (deltaX * (inputY - edgeY2) - deltaY * (inputX - edgeX2) > 0) { + if (side2) { + output.push(inputX2); + output.push(inputY2); + continue; + } + var c0 = inputY2 - inputY, + c2 = inputX2 - inputX; + var ua = + (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / (c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY)); + output.push(edgeX + (edgeX2 - edgeX) * ua); + output.push(edgeY + (edgeY2 - edgeY) * ua); + } else if (side2) { + var c0 = inputY2 - inputY, + c2 = inputX2 - inputX; + var ua = + (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / (c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY)); + output.push(edgeX + (edgeX2 - edgeX) * ua); + output.push(edgeY + (edgeY2 - edgeY) * ua); + output.push(inputX2); + output.push(inputY2); + } + clipped = true; + } + if (outputStart == output.length) { + originalOutput.length = 0; + return true; + } + output.push(output[0]); + output.push(output[1]); + if (i == clippingVerticesLast) break; + var temp = output; + output = input; + output.length = 0; + input = temp; + } + if (originalOutput != output) { + originalOutput.length = 0; + for (var i = 0, n = output.length - 2; i < n; i++) originalOutput[i] = output[i]; + } else originalOutput.length = originalOutput.length - 2; + return clipped; + }; + SkeletonClipping.makeClockwise = function (polygon) { + var vertices = polygon; + var verticeslength = polygon.length; + var area = vertices[verticeslength - 2] * vertices[1] - vertices[0] * vertices[verticeslength - 1], + p1x = 0, + p1y = 0, + p2x = 0, + p2y = 0; + for (var i = 0, n = verticeslength - 3; i < n; i += 2) { + p1x = vertices[i]; + p1y = vertices[i + 1]; + p2x = vertices[i + 2]; + p2y = vertices[i + 3]; + area += p1x * p2y - p2x * p1y; + } + if (area < 0) return; + for (var i = 0, lastX = verticeslength - 2, n = verticeslength >> 1; i < n; i += 2) { + var x = vertices[i], + y = vertices[i + 1]; + var other = lastX - i; + vertices[i] = vertices[other]; + vertices[i + 1] = vertices[other + 1]; + vertices[other] = x; + vertices[other + 1] = y; + } + }; + return SkeletonClipping; + })(); + core.SkeletonClipping = SkeletonClipping; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var SkeletonData = (function () { + function SkeletonData() { + this.bones = new Array(); + this.slots = new Array(); + this.skins = new Array(); + this.events = new Array(); + this.animations = new Array(); + this.ikConstraints = new Array(); + this.transformConstraints = new Array(); + this.pathConstraints = new Array(); + this.fps = 0; + } + SkeletonData.prototype.findBone = function (boneName) { + if (boneName == null) throw new Error('boneName cannot be null.'); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (bone.name == boneName) return bone; + } + return null; + }; + SkeletonData.prototype.findBoneIndex = function (boneName) { + if (boneName == null) throw new Error('boneName cannot be null.'); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) if (bones[i].name == boneName) return i; + return -1; + }; + SkeletonData.prototype.findSlot = function (slotName) { + if (slotName == null) throw new Error('slotName cannot be null.'); + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + if (slot.name == slotName) return slot; + } + return null; + }; + SkeletonData.prototype.findSlotIndex = function (slotName) { + if (slotName == null) throw new Error('slotName cannot be null.'); + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) if (slots[i].name == slotName) return i; + return -1; + }; + SkeletonData.prototype.findSkin = function (skinName) { + if (skinName == null) throw new Error('skinName cannot be null.'); + var skins = this.skins; + for (var i = 0, n = skins.length; i < n; i++) { + var skin = skins[i]; + if (skin.name == skinName) return skin; + } + return null; + }; + SkeletonData.prototype.findEvent = function (eventDataName) { + if (eventDataName == null) throw new Error('eventDataName cannot be null.'); + var events = this.events; + for (var i = 0, n = events.length; i < n; i++) { + var event_4 = events[i]; + if (event_4.name == eventDataName) return event_4; + } + return null; + }; + SkeletonData.prototype.findAnimation = function (animationName) { + if (animationName == null) throw new Error('animationName cannot be null.'); + var animations = this.animations; + for (var i = 0, n = animations.length; i < n; i++) { + var animation = animations[i]; + if (animation.name == animationName) return animation; + } + return null; + }; + SkeletonData.prototype.findIkConstraint = function (constraintName) { + if (constraintName == null) throw new Error('constraintName cannot be null.'); + var ikConstraints = this.ikConstraints; + for (var i = 0, n = ikConstraints.length; i < n; i++) { + var constraint = ikConstraints[i]; + if (constraint.name == constraintName) return constraint; + } + return null; + }; + SkeletonData.prototype.findTransformConstraint = function (constraintName) { + if (constraintName == null) throw new Error('constraintName cannot be null.'); + var transformConstraints = this.transformConstraints; + for (var i = 0, n = transformConstraints.length; i < n; i++) { + var constraint = transformConstraints[i]; + if (constraint.name == constraintName) return constraint; + } + return null; + }; + SkeletonData.prototype.findPathConstraint = function (constraintName) { + if (constraintName == null) throw new Error('constraintName cannot be null.'); + var pathConstraints = this.pathConstraints; + for (var i = 0, n = pathConstraints.length; i < n; i++) { + var constraint = pathConstraints[i]; + if (constraint.name == constraintName) return constraint; + } + return null; + }; + SkeletonData.prototype.findPathConstraintIndex = function (pathConstraintName) { + if (pathConstraintName == null) throw new Error('pathConstraintName cannot be null.'); + var pathConstraints = this.pathConstraints; + for (var i = 0, n = pathConstraints.length; i < n; i++) + if (pathConstraints[i].name == pathConstraintName) return i; + return -1; + }; + return SkeletonData; + })(); + core.SkeletonData = SkeletonData; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var SkeletonJson = (function () { + function SkeletonJson(attachmentLoader) { + this.scale = 1; + this.linkedMeshes = new Array(); + this.attachmentLoader = attachmentLoader; + } + SkeletonJson.prototype.readSkeletonData = function (json) { + var scale = this.scale; + var skeletonData = new core.SkeletonData(); + var root = typeof json === 'string' ? JSON.parse(json) : json; + var skeletonMap = root.skeleton; + if (skeletonMap != null) { + skeletonData.hash = skeletonMap.hash; + skeletonData.version = skeletonMap.spine; + skeletonData.width = skeletonMap.width; + skeletonData.height = skeletonMap.height; + skeletonData.fps = skeletonMap.fps; + skeletonData.imagesPath = skeletonMap.images; + } + if (root.bones) { + for (var i = 0; i < root.bones.length; i++) { + var boneMap = root.bones[i]; + var parent_2 = null; + var parentName = this.getValue(boneMap, 'parent', null); + if (parentName != null) { + parent_2 = skeletonData.findBone(parentName); + if (parent_2 == null) throw new Error('Parent bone not found: ' + parentName); + } + var data = new core.BoneData(skeletonData.bones.length, boneMap.name, parent_2); + data.length = this.getValue(boneMap, 'length', 0) * scale; + data.x = this.getValue(boneMap, 'x', 0) * scale; + data.y = this.getValue(boneMap, 'y', 0) * scale; + data.rotation = this.getValue(boneMap, 'rotation', 0); + data.scaleX = this.getValue(boneMap, 'scaleX', 1); + data.scaleY = this.getValue(boneMap, 'scaleY', 1); + data.shearX = this.getValue(boneMap, 'shearX', 0); + data.shearY = this.getValue(boneMap, 'shearY', 0); + data.transformMode = SkeletonJson.transformModeFromString(this.getValue(boneMap, 'transform', 'normal')); + skeletonData.bones.push(data); + } + } + if (root.slots) { + for (var i = 0; i < root.slots.length; i++) { + var slotMap = root.slots[i]; + var slotName = slotMap.name; + var boneName = slotMap.bone; + var boneData = skeletonData.findBone(boneName); + if (boneData == null) throw new Error('Slot bone not found: ' + boneName); + var data = new core.SlotData(skeletonData.slots.length, slotName, boneData); + var color = this.getValue(slotMap, 'color', null); + if (color != null) data.color.setFromString(color); + var dark = this.getValue(slotMap, 'dark', null); + if (dark != null) { + data.darkColor = new core.Color(1, 1, 1, 1); + data.darkColor.setFromString(dark); + } + data.attachmentName = this.getValue(slotMap, 'attachment', null); + data.blendMode = SkeletonJson.blendModeFromString(this.getValue(slotMap, 'blend', 'normal')); + skeletonData.slots.push(data); + } + } + if (root.ik) { + for (var i = 0; i < root.ik.length; i++) { + var constraintMap = root.ik[i]; + var data = new core.IkConstraintData(constraintMap.name); + data.order = this.getValue(constraintMap, 'order', 0); + for (var j = 0; j < constraintMap.bones.length; j++) { + var boneName = constraintMap.bones[j]; + var bone = skeletonData.findBone(boneName); + if (bone == null) throw new Error('IK bone not found: ' + boneName); + data.bones.push(bone); + } + var targetName = constraintMap.target; + data.target = skeletonData.findBone(targetName); + if (data.target == null) throw new Error('IK target bone not found: ' + targetName); + data.bendDirection = this.getValue(constraintMap, 'bendPositive', true) ? 1 : -1; + data.mix = this.getValue(constraintMap, 'mix', 1); + skeletonData.ikConstraints.push(data); + } + } + if (root.transform) { + for (var i = 0; i < root.transform.length; i++) { + var constraintMap = root.transform[i]; + var data = new core.TransformConstraintData(constraintMap.name); + data.order = this.getValue(constraintMap, 'order', 0); + for (var j = 0; j < constraintMap.bones.length; j++) { + var boneName = constraintMap.bones[j]; + var bone = skeletonData.findBone(boneName); + if (bone == null) throw new Error('Transform constraint bone not found: ' + boneName); + data.bones.push(bone); + } + var targetName = constraintMap.target; + data.target = skeletonData.findBone(targetName); + if (data.target == null) throw new Error('Transform constraint target bone not found: ' + targetName); + data.local = this.getValue(constraintMap, 'local', false); + data.relative = this.getValue(constraintMap, 'relative', false); + data.offsetRotation = this.getValue(constraintMap, 'rotation', 0); + data.offsetX = this.getValue(constraintMap, 'x', 0) * scale; + data.offsetY = this.getValue(constraintMap, 'y', 0) * scale; + data.offsetScaleX = this.getValue(constraintMap, 'scaleX', 0); + data.offsetScaleY = this.getValue(constraintMap, 'scaleY', 0); + data.offsetShearY = this.getValue(constraintMap, 'shearY', 0); + data.rotateMix = this.getValue(constraintMap, 'rotateMix', 1); + data.translateMix = this.getValue(constraintMap, 'translateMix', 1); + data.scaleMix = this.getValue(constraintMap, 'scaleMix', 1); + data.shearMix = this.getValue(constraintMap, 'shearMix', 1); + skeletonData.transformConstraints.push(data); + } + } + if (root.path) { + for (var i = 0; i < root.path.length; i++) { + var constraintMap = root.path[i]; + var data = new core.PathConstraintData(constraintMap.name); + data.order = this.getValue(constraintMap, 'order', 0); + for (var j = 0; j < constraintMap.bones.length; j++) { + var boneName = constraintMap.bones[j]; + var bone = skeletonData.findBone(boneName); + if (bone == null) throw new Error('Transform constraint bone not found: ' + boneName); + data.bones.push(bone); + } + var targetName = constraintMap.target; + data.target = skeletonData.findSlot(targetName); + if (data.target == null) throw new Error('Path target slot not found: ' + targetName); + data.positionMode = SkeletonJson.positionModeFromString( + this.getValue(constraintMap, 'positionMode', 'percent'), + ); + data.spacingMode = SkeletonJson.spacingModeFromString( + this.getValue(constraintMap, 'spacingMode', 'length'), + ); + data.rotateMode = SkeletonJson.rotateModeFromString(this.getValue(constraintMap, 'rotateMode', 'tangent')); + data.offsetRotation = this.getValue(constraintMap, 'rotation', 0); + data.position = this.getValue(constraintMap, 'position', 0); + if (data.positionMode == core.PositionMode.Fixed) data.position *= scale; + data.spacing = this.getValue(constraintMap, 'spacing', 0); + if (data.spacingMode == core.SpacingMode.Length || data.spacingMode == core.SpacingMode.Fixed) + data.spacing *= scale; + data.rotateMix = this.getValue(constraintMap, 'rotateMix', 1); + data.translateMix = this.getValue(constraintMap, 'translateMix', 1); + skeletonData.pathConstraints.push(data); + } + } + if (root.skins) { + for (var skinName in root.skins) { + var skinMap = root.skins[skinName]; + var skin = new core.Skin(skinName); + for (var slotName in skinMap) { + var slotIndex = skeletonData.findSlotIndex(slotName); + if (slotIndex == -1) throw new Error('Slot not found: ' + slotName); + var slotMap = skinMap[slotName]; + for (var entryName in slotMap) { + var attachment = this.readAttachment(slotMap[entryName], skin, slotIndex, entryName, skeletonData); + if (attachment != null) skin.addAttachment(slotIndex, entryName, attachment); + } + } + skeletonData.skins.push(skin); + if (skin.name == 'default') skeletonData.defaultSkin = skin; + } + } + for (var i = 0, n = this.linkedMeshes.length; i < n; i++) { + var linkedMesh = this.linkedMeshes[i]; + var skin = linkedMesh.skin == null ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin); + if (skin == null) throw new Error('Skin not found: ' + linkedMesh.skin); + var parent_3 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent); + if (parent_3 == null) throw new Error('Parent mesh not found: ' + linkedMesh.parent); + linkedMesh.mesh.setParentMesh(parent_3); + } + this.linkedMeshes.length = 0; + if (root.events) { + for (var eventName in root.events) { + var eventMap = root.events[eventName]; + var data = new core.EventData(eventName); + data.intValue = this.getValue(eventMap, 'int', 0); + data.floatValue = this.getValue(eventMap, 'float', 0); + data.stringValue = this.getValue(eventMap, 'string', ''); + data.audioPath = this.getValue(eventMap, 'audio', null); + if (data.audioPath != null) { + data.volume = this.getValue(eventMap, 'volume', 1); + data.balance = this.getValue(eventMap, 'balance', 0); + } + skeletonData.events.push(data); + } + } + if (root.animations) { + for (var animationName in root.animations) { + var animationMap = root.animations[animationName]; + this.readAnimation(animationMap, animationName, skeletonData); + } + } + return skeletonData; + }; + SkeletonJson.prototype.readAttachment = function (map, skin, slotIndex, name, skeletonData) { + var scale = this.scale; + name = this.getValue(map, 'name', name); + var type = this.getValue(map, 'type', 'region'); + switch (type) { + case 'region': { + var path = this.getValue(map, 'path', name); + var region = this.attachmentLoader.newRegionAttachment(skin, name, path); + if (region == null) return null; + region.path = path; + region.x = this.getValue(map, 'x', 0) * scale; + region.y = this.getValue(map, 'y', 0) * scale; + region.scaleX = this.getValue(map, 'scaleX', 1); + region.scaleY = this.getValue(map, 'scaleY', 1); + region.rotation = this.getValue(map, 'rotation', 0); + region.width = map.width * scale; + region.height = map.height * scale; + var color = this.getValue(map, 'color', null); + if (color != null) region.color.setFromString(color); + return region; + } + case 'boundingbox': { + var box = this.attachmentLoader.newBoundingBoxAttachment(skin, name); + if (box == null) return null; + this.readVertices(map, box, map.vertexCount << 1); + var color = this.getValue(map, 'color', null); + if (color != null) box.color.setFromString(color); + return box; + } + case 'mesh': + case 'linkedmesh': { + var path = this.getValue(map, 'path', name); + var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path); + if (mesh == null) return null; + mesh.path = path; + var color = this.getValue(map, 'color', null); + if (color != null) mesh.color.setFromString(color); + var parent_4 = this.getValue(map, 'parent', null); + if (parent_4 != null) { + mesh.inheritDeform = this.getValue(map, 'deform', true); + this.linkedMeshes.push(new LinkedMesh(mesh, this.getValue(map, 'skin', null), slotIndex, parent_4)); + return mesh; + } + var uvs = map.uvs; + this.readVertices(map, mesh, uvs.length); + mesh.triangles = map.triangles; + mesh.regionUVs = uvs; + mesh.hullLength = this.getValue(map, 'hull', 0) * 2; + return mesh; + } + case 'path': { + var path = this.attachmentLoader.newPathAttachment(skin, name); + if (path == null) return null; + path.closed = this.getValue(map, 'closed', false); + path.constantSpeed = this.getValue(map, 'constantSpeed', true); + var vertexCount = map.vertexCount; + this.readVertices(map, path, vertexCount << 1); + var lengths = core.Utils.newArray(vertexCount / 3, 0); + for (var i = 0; i < map.lengths.length; i++) lengths[i] = map.lengths[i] * scale; + path.lengths = lengths; + var color = this.getValue(map, 'color', null); + if (color != null) path.color.setFromString(color); + return path; + } + case 'point': { + var point = this.attachmentLoader.newPointAttachment(skin, name); + if (point == null) return null; + point.x = this.getValue(map, 'x', 0) * scale; + point.y = this.getValue(map, 'y', 0) * scale; + point.rotation = this.getValue(map, 'rotation', 0); + var color = this.getValue(map, 'color', null); + if (color != null) point.color.setFromString(color); + return point; + } + case 'clipping': { + var clip = this.attachmentLoader.newClippingAttachment(skin, name); + if (clip == null) return null; + var end = this.getValue(map, 'end', null); + if (end != null) { + var slot = skeletonData.findSlot(end); + if (slot == null) throw new Error('Clipping end slot not found: ' + end); + clip.endSlot = slot; + } + var vertexCount = map.vertexCount; + this.readVertices(map, clip, vertexCount << 1); + var color = this.getValue(map, 'color', null); + if (color != null) clip.color.setFromString(color); + return clip; + } + } + return null; + }; + SkeletonJson.prototype.readVertices = function (map, attachment, verticesLength) { + var scale = this.scale; + attachment.worldVerticesLength = verticesLength; + var vertices = map.vertices; + if (verticesLength == vertices.length) { + var scaledVertices = core.Utils.toFloatArray(vertices); + if (scale != 1) { + for (var i = 0, n = vertices.length; i < n; i++) scaledVertices[i] *= scale; + } + attachment.vertices = scaledVertices; + return; + } + var weights = new Array(); + var bones = new Array(); + for (var i = 0, n = vertices.length; i < n; ) { + var boneCount = vertices[i++]; + bones.push(boneCount); + for (var nn = i + boneCount * 4; i < nn; i += 4) { + bones.push(vertices[i]); + weights.push(vertices[i + 1] * scale); + weights.push(vertices[i + 2] * scale); + weights.push(vertices[i + 3]); + } + } + attachment.bones = bones; + attachment.vertices = core.Utils.toFloatArray(weights); + }; + SkeletonJson.prototype.readAnimation = function (map, name, skeletonData) { + var scale = this.scale; + var timelines = new Array(); + var duration = 0; + if (map.slots) { + for (var slotName in map.slots) { + var slotMap = map.slots[slotName]; + var slotIndex = skeletonData.findSlotIndex(slotName); + if (slotIndex == -1) throw new Error('Slot not found: ' + slotName); + for (var timelineName in slotMap) { + var timelineMap = slotMap[timelineName]; + if (timelineName == 'attachment') { + var timeline = new core.AttachmentTimeline(timelineMap.length); + timeline.slotIndex = slotIndex; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + timeline.setFrame(frameIndex++, valueMap.time, valueMap.name); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); + } else if (timelineName == 'color') { + var timeline = new core.ColorTimeline(timelineMap.length); + timeline.slotIndex = slotIndex; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + var color = new core.Color(); + color.setFromString(valueMap.color || 'ffffffff'); + timeline.setFrame(frameIndex, valueMap.time, color.r, color.g, color.b, color.a); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max( + duration, + timeline.frames[(timeline.getFrameCount() - 1) * core.ColorTimeline.ENTRIES], + ); + } else if (timelineName == 'twoColor') { + var timeline = new core.TwoColorTimeline(timelineMap.length); + timeline.slotIndex = slotIndex; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + var light = new core.Color(); + var dark = new core.Color(); + light.setFromString(valueMap.light); + dark.setFromString(valueMap.dark); + timeline.setFrame( + frameIndex, + valueMap.time, + light.r, + light.g, + light.b, + light.a, + dark.r, + dark.g, + dark.b, + ); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max( + duration, + timeline.frames[(timeline.getFrameCount() - 1) * core.TwoColorTimeline.ENTRIES], + ); + } else throw new Error('Invalid timeline type for a slot: ' + timelineName + ' (' + slotName + ')'); + } + } + } + if (map.bones) { + for (var boneName in map.bones) { + var boneMap = map.bones[boneName]; + var boneIndex = skeletonData.findBoneIndex(boneName); + if (boneIndex == -1) throw new Error('Bone not found: ' + boneName); + for (var timelineName in boneMap) { + var timelineMap = boneMap[timelineName]; + if (timelineName === 'rotate') { + var timeline = new core.RotateTimeline(timelineMap.length); + timeline.boneIndex = boneIndex; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + timeline.setFrame(frameIndex, valueMap.time, valueMap.angle); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max( + duration, + timeline.frames[(timeline.getFrameCount() - 1) * core.RotateTimeline.ENTRIES], + ); + } else if (timelineName === 'translate' || timelineName === 'scale' || timelineName === 'shear') { + var timeline = null; + var timelineScale = 1; + if (timelineName === 'scale') timeline = new core.ScaleTimeline(timelineMap.length); + else if (timelineName === 'shear') timeline = new core.ShearTimeline(timelineMap.length); + else { + timeline = new core.TranslateTimeline(timelineMap.length); + timelineScale = scale; + } + timeline.boneIndex = boneIndex; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + var x = this.getValue(valueMap, 'x', 0), + y = this.getValue(valueMap, 'y', 0); + timeline.setFrame(frameIndex, valueMap.time, x * timelineScale, y * timelineScale); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max( + duration, + timeline.frames[(timeline.getFrameCount() - 1) * core.TranslateTimeline.ENTRIES], + ); + } else throw new Error('Invalid timeline type for a bone: ' + timelineName + ' (' + boneName + ')'); + } + } + } + if (map.ik) { + for (var constraintName in map.ik) { + var constraintMap = map.ik[constraintName]; + var constraint = skeletonData.findIkConstraint(constraintName); + var timeline = new core.IkConstraintTimeline(constraintMap.length); + timeline.ikConstraintIndex = skeletonData.ikConstraints.indexOf(constraint); + var frameIndex = 0; + for (var i = 0; i < constraintMap.length; i++) { + var valueMap = constraintMap[i]; + timeline.setFrame( + frameIndex, + valueMap.time, + this.getValue(valueMap, 'mix', 1), + this.getValue(valueMap, 'bendPositive', true) ? 1 : -1, + this.getValue(valueMap, 'compress', false), + this.getValue(valueMap, 'stretch', false), + ); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max( + duration, + timeline.frames[(timeline.getFrameCount() - 1) * core.IkConstraintTimeline.ENTRIES], + ); + } + } + if (map.transform) { + for (var constraintName in map.transform) { + var constraintMap = map.transform[constraintName]; + var constraint = skeletonData.findTransformConstraint(constraintName); + var timeline = new core.TransformConstraintTimeline(constraintMap.length); + timeline.transformConstraintIndex = skeletonData.transformConstraints.indexOf(constraint); + var frameIndex = 0; + for (var i = 0; i < constraintMap.length; i++) { + var valueMap = constraintMap[i]; + timeline.setFrame( + frameIndex, + valueMap.time, + this.getValue(valueMap, 'rotateMix', 1), + this.getValue(valueMap, 'translateMix', 1), + this.getValue(valueMap, 'scaleMix', 1), + this.getValue(valueMap, 'shearMix', 1), + ); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max( + duration, + timeline.frames[(timeline.getFrameCount() - 1) * core.TransformConstraintTimeline.ENTRIES], + ); + } + } + if (map.paths) { + for (var constraintName in map.paths) { + var constraintMap = map.paths[constraintName]; + var index = skeletonData.findPathConstraintIndex(constraintName); + if (index == -1) throw new Error('Path constraint not found: ' + constraintName); + var data = skeletonData.pathConstraints[index]; + for (var timelineName in constraintMap) { + var timelineMap = constraintMap[timelineName]; + if (timelineName === 'position' || timelineName === 'spacing') { + var timeline = null; + var timelineScale = 1; + if (timelineName === 'spacing') { + timeline = new core.PathConstraintSpacingTimeline(timelineMap.length); + if (data.spacingMode == core.SpacingMode.Length || data.spacingMode == core.SpacingMode.Fixed) + timelineScale = scale; + } else { + timeline = new core.PathConstraintPositionTimeline(timelineMap.length); + if (data.positionMode == core.PositionMode.Fixed) timelineScale = scale; + } + timeline.pathConstraintIndex = index; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + timeline.setFrame( + frameIndex, + valueMap.time, + this.getValue(valueMap, timelineName, 0) * timelineScale, + ); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max( + duration, + timeline.frames[(timeline.getFrameCount() - 1) * core.PathConstraintPositionTimeline.ENTRIES], + ); + } else if (timelineName === 'mix') { + var timeline = new core.PathConstraintMixTimeline(timelineMap.length); + timeline.pathConstraintIndex = index; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + timeline.setFrame( + frameIndex, + valueMap.time, + this.getValue(valueMap, 'rotateMix', 1), + this.getValue(valueMap, 'translateMix', 1), + ); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max( + duration, + timeline.frames[(timeline.getFrameCount() - 1) * core.PathConstraintMixTimeline.ENTRIES], + ); + } + } + } + } + if (map.deform) { + for (var deformName in map.deform) { + var deformMap = map.deform[deformName]; + var skin = skeletonData.findSkin(deformName); + if (skin == null) throw new Error('Skin not found: ' + deformName); + for (var slotName in deformMap) { + var slotMap = deformMap[slotName]; + var slotIndex = skeletonData.findSlotIndex(slotName); + if (slotIndex == -1) throw new Error('Slot not found: ' + slotMap.name); + for (var timelineName in slotMap) { + var timelineMap = slotMap[timelineName]; + var attachment = skin.getAttachment(slotIndex, timelineName); + if (attachment == null) throw new Error('Deform attachment not found: ' + timelineMap.name); + var weighted = attachment.bones != null; + var vertices = attachment.vertices; + var deformLength = weighted ? (vertices.length / 3) * 2 : vertices.length; + var timeline = new core.DeformTimeline(timelineMap.length); + timeline.slotIndex = slotIndex; + timeline.attachment = attachment; + var frameIndex = 0; + for (var j = 0; j < timelineMap.length; j++) { + var valueMap = timelineMap[j]; + var deform = void 0; + var verticesValue = this.getValue(valueMap, 'vertices', null); + if (verticesValue == null) deform = weighted ? core.Utils.newFloatArray(deformLength) : vertices; + else { + deform = core.Utils.newFloatArray(deformLength); + var start = this.getValue(valueMap, 'offset', 0); + core.Utils.arrayCopy(verticesValue, 0, deform, start, verticesValue.length); + if (scale != 1) { + for (var i = start, n = i + verticesValue.length; i < n; i++) deform[i] *= scale; + } + if (!weighted) { + for (var i = 0; i < deformLength; i++) deform[i] += vertices[i]; + } + } + timeline.setFrame(frameIndex, valueMap.time, deform); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); + } + } + } + } + var drawOrderNode = map.drawOrder; + if (drawOrderNode == null) drawOrderNode = map.draworder; + if (drawOrderNode != null) { + var timeline = new core.DrawOrderTimeline(drawOrderNode.length); + var slotCount = skeletonData.slots.length; + var frameIndex = 0; + for (var j = 0; j < drawOrderNode.length; j++) { + var drawOrderMap = drawOrderNode[j]; + var drawOrder = null; + var offsets = this.getValue(drawOrderMap, 'offsets', null); + if (offsets != null) { + drawOrder = core.Utils.newArray(slotCount, -1); + var unchanged = core.Utils.newArray(slotCount - offsets.length, 0); + var originalIndex = 0, + unchangedIndex = 0; + for (var i = 0; i < offsets.length; i++) { + var offsetMap = offsets[i]; + var slotIndex = skeletonData.findSlotIndex(offsetMap.slot); + if (slotIndex == -1) throw new Error('Slot not found: ' + offsetMap.slot); + while (originalIndex != slotIndex) unchanged[unchangedIndex++] = originalIndex++; + drawOrder[originalIndex + offsetMap.offset] = originalIndex++; + } + while (originalIndex < slotCount) unchanged[unchangedIndex++] = originalIndex++; + for (var i = slotCount - 1; i >= 0; i--) + if (drawOrder[i] == -1) drawOrder[i] = unchanged[--unchangedIndex]; + } + timeline.setFrame(frameIndex++, drawOrderMap.time, drawOrder); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); + } + if (map.events) { + var timeline = new core.EventTimeline(map.events.length); + var frameIndex = 0; + for (var i = 0; i < map.events.length; i++) { + var eventMap = map.events[i]; + var eventData = skeletonData.findEvent(eventMap.name); + if (eventData == null) throw new Error('Event not found: ' + eventMap.name); + var event_5 = new core.Event(core.Utils.toSinglePrecision(eventMap.time), eventData); + event_5.intValue = this.getValue(eventMap, 'int', eventData.intValue); + event_5.floatValue = this.getValue(eventMap, 'float', eventData.floatValue); + event_5.stringValue = this.getValue(eventMap, 'string', eventData.stringValue); + if (event_5.data.audioPath != null) { + event_5.volume = this.getValue(eventMap, 'volume', 1); + event_5.balance = this.getValue(eventMap, 'balance', 0); + } + timeline.setFrame(frameIndex++, event_5); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); + } + if (isNaN(duration)) { + throw new Error('Error while parsing animation, duration is NaN'); + } + skeletonData.animations.push(new core.Animation(name, timelines, duration)); + }; + SkeletonJson.prototype.readCurve = function (map, timeline, frameIndex) { + if (!map.curve) return; + if (map.curve === 'stepped') timeline.setStepped(frameIndex); + else if (Object.prototype.toString.call(map.curve) === '[object Array]') { + var curve = map.curve; + timeline.setCurve(frameIndex, curve[0], curve[1], curve[2], curve[3]); + } + }; + SkeletonJson.prototype.getValue = function (map, prop, defaultValue) { + return map[prop] !== undefined ? map[prop] : defaultValue; + }; + SkeletonJson.blendModeFromString = function (str) { + str = str.toLowerCase(); + if (str == 'normal') return core.BlendMode.Normal; + if (str == 'additive') return core.BlendMode.Additive; + if (str == 'multiply') return core.BlendMode.Multiply; + if (str == 'screen') return core.BlendMode.Screen; + throw new Error('Unknown blend mode: ' + str); + }; + SkeletonJson.positionModeFromString = function (str) { + str = str.toLowerCase(); + if (str == 'fixed') return core.PositionMode.Fixed; + if (str == 'percent') return core.PositionMode.Percent; + throw new Error('Unknown position mode: ' + str); + }; + SkeletonJson.spacingModeFromString = function (str) { + str = str.toLowerCase(); + if (str == 'length') return core.SpacingMode.Length; + if (str == 'fixed') return core.SpacingMode.Fixed; + if (str == 'percent') return core.SpacingMode.Percent; + throw new Error('Unknown position mode: ' + str); + }; + SkeletonJson.rotateModeFromString = function (str) { + str = str.toLowerCase(); + if (str == 'tangent') return core.RotateMode.Tangent; + if (str == 'chain') return core.RotateMode.Chain; + if (str == 'chainscale') return core.RotateMode.ChainScale; + throw new Error('Unknown rotate mode: ' + str); + }; + SkeletonJson.transformModeFromString = function (str) { + str = str.toLowerCase(); + if (str == 'normal') return core.TransformMode.Normal; + if (str == 'onlytranslation') return core.TransformMode.OnlyTranslation; + if (str == 'norotationorreflection') return core.TransformMode.NoRotationOrReflection; + if (str == 'noscale') return core.TransformMode.NoScale; + if (str == 'noscaleorreflection') return core.TransformMode.NoScaleOrReflection; + throw new Error('Unknown transform mode: ' + str); + }; + return SkeletonJson; + })(); + core.SkeletonJson = SkeletonJson; + var LinkedMesh = (function () { + function LinkedMesh(mesh, skin, slotIndex, parent) { + this.mesh = mesh; + this.skin = skin; + this.slotIndex = slotIndex; + this.parent = parent; + } + return LinkedMesh; + })(); + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var Skin = (function () { + function Skin(name) { + this.attachments = new Array(); + if (name == null) throw new Error('name cannot be null.'); + this.name = name; + } + Skin.prototype.addAttachment = function (slotIndex, name, attachment) { + if (attachment == null) throw new Error('attachment cannot be null.'); + var attachments = this.attachments; + if (slotIndex >= attachments.length) attachments.length = slotIndex + 1; + if (!attachments[slotIndex]) attachments[slotIndex] = {}; + attachments[slotIndex][name] = attachment; + }; + Skin.prototype.getAttachment = function (slotIndex, name) { + var dictionary = this.attachments[slotIndex]; + return dictionary ? dictionary[name] : null; + }; + Skin.prototype.attachAll = function (skeleton, oldSkin) { + var slotIndex = 0; + for (var i = 0; i < skeleton.slots.length; i++) { + var slot = skeleton.slots[i]; + var slotAttachment = slot.getAttachment(); + if (slotAttachment && slotIndex < oldSkin.attachments.length) { + var dictionary = oldSkin.attachments[slotIndex]; + for (var key in dictionary) { + var skinAttachment = dictionary[key]; + if (slotAttachment == skinAttachment) { + var attachment = this.getAttachment(slotIndex, key); + if (attachment != null) slot.setAttachment(attachment); + break; + } + } + } + slotIndex++; + } + }; + return Skin; + })(); + core.Skin = Skin; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var Slot = (function () { + function Slot(data, bone) { + this.attachmentVertices = new Array(); + if (data == null) throw new Error('data cannot be null.'); + if (bone == null) throw new Error('bone cannot be null.'); + this.data = data; + this.bone = bone; + this.color = new core.Color(); + this.darkColor = data.darkColor == null ? null : new core.Color(); + this.setToSetupPose(); + this.blendMode = this.data.blendMode; + } + Slot.prototype.getAttachment = function () { + return this.attachment; + }; + Slot.prototype.setAttachment = function (attachment) { + if (this.attachment == attachment) return; + this.attachment = attachment; + this.attachmentTime = this.bone.skeleton.time; + this.attachmentVertices.length = 0; + }; + Slot.prototype.setAttachmentTime = function (time) { + this.attachmentTime = this.bone.skeleton.time - time; + }; + Slot.prototype.getAttachmentTime = function () { + return this.bone.skeleton.time - this.attachmentTime; + }; + Slot.prototype.setToSetupPose = function () { + this.color.setFromColor(this.data.color); + if (this.darkColor != null) this.darkColor.setFromColor(this.data.darkColor); + if (this.data.attachmentName == null) this.attachment = null; + else { + this.attachment = null; + this.setAttachment(this.bone.skeleton.getAttachment(this.data.index, this.data.attachmentName)); + } + }; + return Slot; + })(); + core.Slot = Slot; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var SlotData = (function () { + function SlotData(index, name, boneData) { + this.color = new core.Color(1, 1, 1, 1); + if (index < 0) throw new Error('index must be >= 0.'); + if (name == null) throw new Error('name cannot be null.'); + if (boneData == null) throw new Error('boneData cannot be null.'); + this.index = index; + this.name = name; + this.boneData = boneData; + } + return SlotData; + })(); + core.SlotData = SlotData; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var Texture = (function () { + function Texture(image) { + this._image = image; + } + Texture.prototype.getImage = function () { + return this._image; + }; + Texture.filterFromString = function (text) { + switch (text.toLowerCase()) { + case 'nearest': + return TextureFilter.Nearest; + case 'linear': + return TextureFilter.Linear; + case 'mipmap': + return TextureFilter.MipMap; + case 'mipmapnearestnearest': + return TextureFilter.MipMapNearestNearest; + case 'mipmaplinearnearest': + return TextureFilter.MipMapLinearNearest; + case 'mipmapnearestlinear': + return TextureFilter.MipMapNearestLinear; + case 'mipmaplinearlinear': + return TextureFilter.MipMapLinearLinear; + default: + throw new Error('Unknown texture filter ' + text); + } + }; + Texture.wrapFromString = function (text) { + switch (text.toLowerCase()) { + case 'mirroredtepeat': + return TextureWrap.MirroredRepeat; + case 'clamptoedge': + return TextureWrap.ClampToEdge; + case 'repeat': + return TextureWrap.Repeat; + default: + throw new Error('Unknown texture wrap ' + text); + } + }; + return Texture; + })(); + core.Texture = Texture; + var TextureFilter; + (function (TextureFilter) { + TextureFilter[(TextureFilter['Nearest'] = 9728)] = 'Nearest'; + TextureFilter[(TextureFilter['Linear'] = 9729)] = 'Linear'; + TextureFilter[(TextureFilter['MipMap'] = 9987)] = 'MipMap'; + TextureFilter[(TextureFilter['MipMapNearestNearest'] = 9984)] = 'MipMapNearestNearest'; + TextureFilter[(TextureFilter['MipMapLinearNearest'] = 9985)] = 'MipMapLinearNearest'; + TextureFilter[(TextureFilter['MipMapNearestLinear'] = 9986)] = 'MipMapNearestLinear'; + TextureFilter[(TextureFilter['MipMapLinearLinear'] = 9987)] = 'MipMapLinearLinear'; + })((TextureFilter = core.TextureFilter || (core.TextureFilter = {}))); + var TextureWrap; + (function (TextureWrap) { + TextureWrap[(TextureWrap['MirroredRepeat'] = 33648)] = 'MirroredRepeat'; + TextureWrap[(TextureWrap['ClampToEdge'] = 33071)] = 'ClampToEdge'; + TextureWrap[(TextureWrap['Repeat'] = 10497)] = 'Repeat'; + })((TextureWrap = core.TextureWrap || (core.TextureWrap = {}))); + var TextureRegion = (function () { + function TextureRegion() { + this.size = null; + } + Object.defineProperty(TextureRegion.prototype, 'width', { + get: function () { + var tex = this.texture; + if (PIXI.VERSION[0] == '3') { + return tex.crop.width; + } + if (tex.trim) { + return tex.trim.width; + } + return tex.orig.width; + }, + enumerable: true, + configurable: true, + }); + Object.defineProperty(TextureRegion.prototype, 'height', { + get: function () { + var tex = this.texture; + if (PIXI.VERSION[0] == '3') { + return tex.crop.height; + } + if (tex.trim) { + return tex.trim.height; + } + return tex.orig.height; + }, + enumerable: true, + configurable: true, + }); + Object.defineProperty(TextureRegion.prototype, 'u', { + get: function () { + return this.texture._uvs.x0; + }, + enumerable: true, + configurable: true, + }); + Object.defineProperty(TextureRegion.prototype, 'v', { + get: function () { + return this.texture._uvs.y0; + }, + enumerable: true, + configurable: true, + }); + Object.defineProperty(TextureRegion.prototype, 'u2', { + get: function () { + return this.texture._uvs.x2; + }, + enumerable: true, + configurable: true, + }); + Object.defineProperty(TextureRegion.prototype, 'v2', { + get: function () { + return this.texture._uvs.y2; + }, + enumerable: true, + configurable: true, + }); + Object.defineProperty(TextureRegion.prototype, 'offsetX', { + get: function () { + var tex = this.texture; + return tex.trim ? tex.trim.x : 0; + }, + enumerable: true, + configurable: true, + }); + Object.defineProperty(TextureRegion.prototype, 'offsetY', { + get: function () { + console.warn( + 'Deprecation Warning: @Hackerham: I guess, if you are using PIXI-SPINE ATLAS region.offsetY, you want a texture, right? Use region.texture from now on.', + ); + return this.spineOffsetY; + }, + enumerable: true, + configurable: true, + }); + Object.defineProperty(TextureRegion.prototype, 'pixiOffsetY', { + get: function () { + var tex = this.texture; + return tex.trim ? tex.trim.y : 0; + }, + enumerable: true, + configurable: true, + }); + Object.defineProperty(TextureRegion.prototype, 'spineOffsetY', { + get: function () { + var tex = this.texture; + return this.originalHeight - this.height - (tex.trim ? tex.trim.y : 0); + }, + enumerable: true, + configurable: true, + }); + Object.defineProperty(TextureRegion.prototype, 'originalWidth', { + get: function () { + var tex = this.texture; + if (PIXI.VERSION[0] == '3') { + if (tex.trim) { + return tex.trim.width; + } + return tex.crop.width; + } + return tex.orig.width; + }, + enumerable: true, + configurable: true, + }); + Object.defineProperty(TextureRegion.prototype, 'originalHeight', { + get: function () { + var tex = this.texture; + if (PIXI.VERSION[0] == '3') { + if (tex.trim) { + return tex.trim.height; + } + return tex.crop.height; + } + return tex.orig.height; + }, + enumerable: true, + configurable: true, + }); + Object.defineProperty(TextureRegion.prototype, 'x', { + get: function () { + return this.texture.frame.x; + }, + enumerable: true, + configurable: true, + }); + Object.defineProperty(TextureRegion.prototype, 'y', { + get: function () { + return this.texture.frame.y; + }, + enumerable: true, + configurable: true, + }); + Object.defineProperty(TextureRegion.prototype, 'rotate', { + get: function () { + return this.texture.rotate !== 0; + }, + enumerable: true, + configurable: true, + }); + return TextureRegion; + })(); + core.TextureRegion = TextureRegion; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var TextureAtlas = (function () { + function TextureAtlas(atlasText, textureLoader, callback) { + this.pages = new Array(); + this.regions = new Array(); + if (atlasText) { + this.addSpineAtlas(atlasText, textureLoader, callback); + } + } + TextureAtlas.prototype.addTexture = function (name, texture) { + var pages = this.pages; + var page = null; + for (var i = 0; i < pages.length; i++) { + if (pages[i].baseTexture === texture.baseTexture) { + page = pages[i]; + break; + } + } + if (page === null) { + page = new TextureAtlasPage(); + page.name = 'texturePage'; + var baseTexture = texture.baseTexture; + page.width = baseTexture.realWidth; + page.height = baseTexture.realHeight; + page.baseTexture = baseTexture; + page.minFilter = page.magFilter = core.TextureFilter.Nearest; + page.uWrap = core.TextureWrap.ClampToEdge; + page.vWrap = core.TextureWrap.ClampToEdge; + pages.push(page); + } + var region = new TextureAtlasRegion(); + region.name = name; + region.page = page; + region.texture = texture; + region.index = -1; + this.regions.push(region); + return region; + }; + TextureAtlas.prototype.addTextureHash = function (textures, stripExtension) { + for (var key in textures) { + if (textures.hasOwnProperty(key)) { + this.addTexture( + stripExtension && key.indexOf('.') !== -1 ? key.substr(0, key.lastIndexOf('.')) : key, + textures[key], + ); + } + } + }; + TextureAtlas.prototype.addSpineAtlas = function (atlasText, textureLoader, callback) { + return this.load(atlasText, textureLoader, callback); + }; + TextureAtlas.prototype.load = function (atlasText, textureLoader, callback) { + var _this = this; + if (textureLoader == null) throw new Error('textureLoader cannot be null.'); + var reader = new TextureAtlasReader(atlasText); + var tuple = new Array(4); + var page = null; + var iterateParser = function () { + while (true) { + var line = reader.readLine(); + if (line == null) { + return callback && callback(_this); + } + line = line.trim(); + if (line.length == 0) page = null; + else if (!page) { + page = new TextureAtlasPage(); + page.name = line; + if (reader.readTuple(tuple) == 2) { + page.width = parseInt(tuple[0]); + page.height = parseInt(tuple[1]); + reader.readTuple(tuple); + } + reader.readTuple(tuple); + page.minFilter = core.Texture.filterFromString(tuple[0]); + page.magFilter = core.Texture.filterFromString(tuple[1]); + var direction = reader.readValue(); + page.uWrap = core.TextureWrap.ClampToEdge; + page.vWrap = core.TextureWrap.ClampToEdge; + if (direction == 'x') page.uWrap = core.TextureWrap.Repeat; + else if (direction == 'y') page.vWrap = core.TextureWrap.Repeat; + else if (direction == 'xy') page.uWrap = page.vWrap = core.TextureWrap.Repeat; + textureLoader(line, function (texture) { + if (texture === null) { + _this.pages.splice(_this.pages.indexOf(page), 1); + return callback && callback(null); + } + page.baseTexture = texture; + if (!texture.hasLoaded) { + texture.width = page.width; + texture.height = page.height; + } + _this.pages.push(page); + page.setFilters(); + if (!page.width || !page.height) { + page.width = texture.realWidth; + page.height = texture.realHeight; + if (!page.width || !page.height) { + console.log( + 'ERROR spine atlas page ' + + page.name + + ': meshes wont work if you dont specify size in atlas (http://www.html5gamedevs.com/topic/18888-pixi-spines-and-meshes/?p=107121)', + ); + } + } + iterateParser(); + }); + _this.pages.push(page); + break; + } else { + var region = new TextureAtlasRegion(); + region.name = line; + region.page = page; + var rotate = reader.readValue() == 'true' ? 6 : 0; + reader.readTuple(tuple); + var x = parseInt(tuple[0]); + var y = parseInt(tuple[1]); + reader.readTuple(tuple); + var width = parseInt(tuple[0]); + var height = parseInt(tuple[1]); + var resolution = page.baseTexture.resolution; + x /= resolution; + y /= resolution; + width /= resolution; + height /= resolution; + var frame = new PIXI.Rectangle(x, y, rotate ? height : width, rotate ? width : height); + if (reader.readTuple(tuple) == 4) { + if (reader.readTuple(tuple) == 4) { + reader.readTuple(tuple); + } + } + var originalWidth = parseInt(tuple[0]) / resolution; + var originalHeight = parseInt(tuple[1]) / resolution; + reader.readTuple(tuple); + var offsetX = parseInt(tuple[0]) / resolution; + var offsetY = parseInt(tuple[1]) / resolution; + var orig = new PIXI.Rectangle(0, 0, originalWidth, originalHeight); + var trim = new PIXI.Rectangle(offsetX, originalHeight - height - offsetY, width, height); + if (PIXI.VERSION[0] != '3') { + region.texture = new PIXI.Texture(region.page.baseTexture, frame, orig, trim, rotate); + } else { + var frame2 = new PIXI.Rectangle(x, y, width, height); + var crop = frame2.clone(); + trim.width = originalWidth; + trim.height = originalHeight; + region.texture = new PIXI.Texture(region.page.baseTexture, frame2, crop, trim, rotate); + } + region.index = parseInt(reader.readValue()); + region.texture._updateUvs(); + _this.regions.push(region); + } + } + }; + iterateParser(); + }; + TextureAtlas.prototype.findRegion = function (name) { + for (var i = 0; i < this.regions.length; i++) { + if (this.regions[i].name == name) { + return this.regions[i]; + } + } + return null; + }; + TextureAtlas.prototype.dispose = function () { + for (var i = 0; i < this.pages.length; i++) { + this.pages[i].baseTexture.dispose(); + } + }; + return TextureAtlas; + })(); + core.TextureAtlas = TextureAtlas; + var TextureAtlasReader = (function () { + function TextureAtlasReader(text) { + this.index = 0; + this.lines = text.split(/\r\n|\r|\n/); + } + TextureAtlasReader.prototype.readLine = function () { + if (this.index >= this.lines.length) return null; + return this.lines[this.index++]; + }; + TextureAtlasReader.prototype.readValue = function () { + var line = this.readLine(); + var colon = line.indexOf(':'); + if (colon == -1) throw new Error('Invalid line: ' + line); + return line.substring(colon + 1).trim(); + }; + TextureAtlasReader.prototype.readTuple = function (tuple) { + var line = this.readLine(); + var colon = line.indexOf(':'); + if (colon == -1) throw new Error('Invalid line: ' + line); + var i = 0, + lastMatch = colon + 1; + for (; i < 3; i++) { + var comma = line.indexOf(',', lastMatch); + if (comma == -1) break; + tuple[i] = line.substr(lastMatch, comma - lastMatch).trim(); + lastMatch = comma + 1; + } + tuple[i] = line.substring(lastMatch).trim(); + return i + 1; + }; + return TextureAtlasReader; + })(); + var TextureAtlasPage = (function () { + function TextureAtlasPage() {} + TextureAtlasPage.prototype.setFilters = function () { + var tex = this.baseTexture; + var filter = this.minFilter; + if (filter == core.TextureFilter.Linear) { + tex.scaleMode = PIXI.SCALE_MODES.LINEAR; + } else if (this.minFilter == core.TextureFilter.Nearest) { + tex.scaleMode = PIXI.SCALE_MODES.NEAREST; + } else { + tex.mipmap = true; + if (filter == core.TextureFilter.MipMapNearestNearest) { + tex.scaleMode = PIXI.SCALE_MODES.NEAREST; + } else { + tex.scaleMode = PIXI.SCALE_MODES.LINEAR; + } + } + }; + return TextureAtlasPage; + })(); + core.TextureAtlasPage = TextureAtlasPage; + var TextureAtlasRegion = (function (_super) { + __extends(TextureAtlasRegion, _super); + function TextureAtlasRegion() { + return (_super !== null && _super.apply(this, arguments)) || this; + } + return TextureAtlasRegion; + })(core.TextureRegion); + core.TextureAtlasRegion = TextureAtlasRegion; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var TransformConstraint = (function () { + function TransformConstraint(data, skeleton) { + this.rotateMix = 0; + this.translateMix = 0; + this.scaleMix = 0; + this.shearMix = 0; + this.temp = new core.Vector2(); + if (data == null) throw new Error('data cannot be null.'); + if (skeleton == null) throw new Error('skeleton cannot be null.'); + this.data = data; + this.rotateMix = data.rotateMix; + this.translateMix = data.translateMix; + this.scaleMix = data.scaleMix; + this.shearMix = data.shearMix; + this.bones = new Array(); + for (var i = 0; i < data.bones.length; i++) this.bones.push(skeleton.findBone(data.bones[i].name)); + this.target = skeleton.findBone(data.target.name); + } + TransformConstraint.prototype.apply = function () { + this.update(); + }; + TransformConstraint.prototype.update = function () { + if (this.data.local) { + if (this.data.relative) this.applyRelativeLocal(); + else this.applyAbsoluteLocal(); + } else { + if (this.data.relative) this.applyRelativeWorld(); + else this.applyAbsoluteWorld(); + } + }; + TransformConstraint.prototype.applyAbsoluteWorld = function () { + var rotateMix = this.rotateMix, + translateMix = this.translateMix, + scaleMix = this.scaleMix, + shearMix = this.shearMix; + var target = this.target; + var targetMat = target.matrix; + var ta = targetMat.a, + tb = targetMat.c, + tc = targetMat.b, + td = targetMat.d; + var degRadReflect = ta * td - tb * tc > 0 ? core.MathUtils.degRad : -core.MathUtils.degRad; + var offsetRotation = this.data.offsetRotation * degRadReflect; + var offsetShearY = this.data.offsetShearY * degRadReflect; + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + var modified = false; + var mat = bone.matrix; + if (rotateMix != 0) { + var a = mat.a, + b = mat.c, + c = mat.b, + d = mat.d; + var r = Math.atan2(tc, ta) - Math.atan2(c, a) + offsetRotation; + if (r > core.MathUtils.PI) r -= core.MathUtils.PI2; + else if (r < -core.MathUtils.PI) r += core.MathUtils.PI2; + r *= rotateMix; + var cos = Math.cos(r), + sin = Math.sin(r); + mat.a = cos * a - sin * c; + mat.c = cos * b - sin * d; + mat.b = sin * a + cos * c; + mat.d = sin * b + cos * d; + modified = true; + } + if (translateMix != 0) { + var temp = this.temp; + target.localToWorld(temp.set(this.data.offsetX, this.data.offsetY)); + mat.tx += (temp.x - mat.tx) * translateMix; + mat.ty += (temp.y - mat.ty) * translateMix; + modified = true; + } + if (scaleMix > 0) { + var s = Math.sqrt(mat.a * mat.a + mat.b * mat.b); + var ts = Math.sqrt(ta * ta + tc * tc); + if (s > 0.00001) s = (s + (ts - s + this.data.offsetScaleX) * scaleMix) / s; + mat.a *= s; + mat.b *= s; + s = Math.sqrt(mat.c * mat.c + mat.d * mat.d); + ts = Math.sqrt(tb * tb + td * td); + if (s > 0.00001) s = (s + (ts - s + this.data.offsetScaleY) * scaleMix) / s; + mat.c *= s; + mat.d *= s; + modified = true; + } + if (shearMix > 0) { + var b = mat.c, + d = mat.d; + var by = Math.atan2(d, b); + var r = Math.atan2(td, tb) - Math.atan2(tc, ta) - (by - Math.atan2(mat.b, mat.a)); + if (r > core.MathUtils.PI) r -= core.MathUtils.PI2; + else if (r < -core.MathUtils.PI) r += core.MathUtils.PI2; + r = by + (r + offsetShearY) * shearMix; + var s = Math.sqrt(b * b + d * d); + mat.c = Math.cos(r) * s; + mat.d = Math.sin(r) * s; + modified = true; + } + if (modified) bone.appliedValid = false; + } + }; + TransformConstraint.prototype.applyRelativeWorld = function () { + var rotateMix = this.rotateMix, + translateMix = this.translateMix, + scaleMix = this.scaleMix, + shearMix = this.shearMix; + var target = this.target; + var targetMat = target.matrix; + var ta = targetMat.a, + tb = targetMat.c, + tc = targetMat.b, + td = targetMat.d; + var degRadReflect = ta * td - tb * tc > 0 ? core.MathUtils.degRad : -core.MathUtils.degRad; + var offsetRotation = this.data.offsetRotation * degRadReflect, + offsetShearY = this.data.offsetShearY * degRadReflect; + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + var modified = false; + var mat = bone.matrix; + if (rotateMix != 0) { + var a = mat.a, + b = mat.c, + c = mat.b, + d = mat.d; + var r = Math.atan2(tc, ta) + offsetRotation; + if (r > core.MathUtils.PI) r -= core.MathUtils.PI2; + else if (r < -core.MathUtils.PI) r += core.MathUtils.PI2; + r *= rotateMix; + var cos = Math.cos(r), + sin = Math.sin(r); + mat.a = cos * a - sin * c; + mat.c = cos * b - sin * d; + mat.b = sin * a + cos * c; + mat.d = sin * b + cos * d; + modified = true; + } + if (translateMix != 0) { + var temp = this.temp; + target.localToWorld(temp.set(this.data.offsetX, this.data.offsetY)); + mat.tx += temp.x * translateMix; + mat.ty += temp.y * translateMix; + modified = true; + } + if (scaleMix > 0) { + var s = (Math.sqrt(ta * ta + tc * tc) - 1 + this.data.offsetScaleX) * scaleMix + 1; + mat.a *= s; + mat.b *= s; + s = (Math.sqrt(tb * tb + td * td) - 1 + this.data.offsetScaleY) * scaleMix + 1; + mat.c *= s; + mat.d *= s; + modified = true; + } + if (shearMix > 0) { + var r = Math.atan2(td, tb) - Math.atan2(tc, ta); + if (r > core.MathUtils.PI) r -= core.MathUtils.PI2; + else if (r < -core.MathUtils.PI) r += core.MathUtils.PI2; + var b = mat.c, + d = mat.d; + r = Math.atan2(d, b) + (r - core.MathUtils.PI / 2 + offsetShearY) * shearMix; + var s = Math.sqrt(b * b + d * d); + mat.c = Math.cos(r) * s; + mat.d = Math.sin(r) * s; + modified = true; + } + if (modified) bone.appliedValid = false; + } + }; + TransformConstraint.prototype.applyAbsoluteLocal = function () { + var rotateMix = this.rotateMix, + translateMix = this.translateMix, + scaleMix = this.scaleMix, + shearMix = this.shearMix; + var target = this.target; + if (!target.appliedValid) target.updateAppliedTransform(); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (!bone.appliedValid) bone.updateAppliedTransform(); + var rotation = bone.arotation; + if (rotateMix != 0) { + var r = target.arotation - rotation + this.data.offsetRotation; + r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; + rotation += r * rotateMix; + } + var x = bone.ax, + y = bone.ay; + if (translateMix != 0) { + x += (target.ax - x + this.data.offsetX) * translateMix; + y += (target.ay - y + this.data.offsetY) * translateMix; + } + var scaleX = bone.ascaleX, + scaleY = bone.ascaleY; + if (scaleMix > 0) { + if (scaleX > 0.00001) + scaleX = (scaleX + (target.ascaleX - scaleX + this.data.offsetScaleX) * scaleMix) / scaleX; + if (scaleY > 0.00001) + scaleY = (scaleY + (target.ascaleY - scaleY + this.data.offsetScaleY) * scaleMix) / scaleY; + } + var shearY = bone.ashearY; + if (shearMix > 0) { + var r = target.ashearY - shearY + this.data.offsetShearY; + r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; + bone.shearY += r * shearMix; + } + bone.updateWorldTransformWith(x, y, rotation, scaleX, scaleY, bone.ashearX, shearY); + } + }; + TransformConstraint.prototype.applyRelativeLocal = function () { + var rotateMix = this.rotateMix, + translateMix = this.translateMix, + scaleMix = this.scaleMix, + shearMix = this.shearMix; + var target = this.target; + if (!target.appliedValid) target.updateAppliedTransform(); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (!bone.appliedValid) bone.updateAppliedTransform(); + var rotation = bone.arotation; + if (rotateMix != 0) rotation += (target.arotation + this.data.offsetRotation) * rotateMix; + var x = bone.ax, + y = bone.ay; + if (translateMix != 0) { + x += (target.ax + this.data.offsetX) * translateMix; + y += (target.ay + this.data.offsetY) * translateMix; + } + var scaleX = bone.ascaleX, + scaleY = bone.ascaleY; + if (scaleMix > 0) { + if (scaleX > 0.00001) scaleX *= (target.ascaleX - 1 + this.data.offsetScaleX) * scaleMix + 1; + if (scaleY > 0.00001) scaleY *= (target.ascaleY - 1 + this.data.offsetScaleY) * scaleMix + 1; + } + var shearY = bone.ashearY; + if (shearMix > 0) shearY += (target.ashearY + this.data.offsetShearY) * shearMix; + bone.updateWorldTransformWith(x, y, rotation, scaleX, scaleY, bone.ashearX, shearY); + } + }; + TransformConstraint.prototype.getOrder = function () { + return this.data.order; + }; + return TransformConstraint; + })(); + core.TransformConstraint = TransformConstraint; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var TransformConstraintData = (function () { + function TransformConstraintData(name) { + this.order = 0; + this.bones = new Array(); + this.rotateMix = 0; + this.translateMix = 0; + this.scaleMix = 0; + this.shearMix = 0; + this.offsetRotation = 0; + this.offsetX = 0; + this.offsetY = 0; + this.offsetScaleX = 0; + this.offsetScaleY = 0; + this.offsetShearY = 0; + this.relative = false; + this.local = false; + if (name == null) throw new Error('name cannot be null.'); + this.name = name; + } + return TransformConstraintData; + })(); + core.TransformConstraintData = TransformConstraintData; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var Triangulator = (function () { + function Triangulator() { + this.convexPolygons = new Array(); + this.convexPolygonsIndices = new Array(); + this.indicesArray = new Array(); + this.isConcaveArray = new Array(); + this.triangles = new Array(); + this.polygonPool = new core.Pool(function () { + return new Array(); + }); + this.polygonIndicesPool = new core.Pool(function () { + return new Array(); + }); + } + Triangulator.prototype.triangulate = function (verticesArray) { + var vertices = verticesArray; + var vertexCount = verticesArray.length >> 1; + var indices = this.indicesArray; + indices.length = 0; + for (var i = 0; i < vertexCount; i++) indices[i] = i; + var isConcave = this.isConcaveArray; + isConcave.length = 0; + for (var i = 0, n = vertexCount; i < n; ++i) + isConcave[i] = Triangulator.isConcave(i, vertexCount, vertices, indices); + var triangles = this.triangles; + triangles.length = 0; + while (vertexCount > 3) { + var previous = vertexCount - 1, + i = 0, + next = 1; + while (true) { + outer: if (!isConcave[i]) { + var p1 = indices[previous] << 1, + p2 = indices[i] << 1, + p3 = indices[next] << 1; + var p1x = vertices[p1], + p1y = vertices[p1 + 1]; + var p2x = vertices[p2], + p2y = vertices[p2 + 1]; + var p3x = vertices[p3], + p3y = vertices[p3 + 1]; + for (var ii = (next + 1) % vertexCount; ii != previous; ii = (ii + 1) % vertexCount) { + if (!isConcave[ii]) continue; + var v = indices[ii] << 1; + var vx = vertices[v], + vy = vertices[v + 1]; + if (Triangulator.positiveArea(p3x, p3y, p1x, p1y, vx, vy)) { + if (Triangulator.positiveArea(p1x, p1y, p2x, p2y, vx, vy)) { + if (Triangulator.positiveArea(p2x, p2y, p3x, p3y, vx, vy)) break outer; + } + } + } + break; + } + if (next == 0) { + do { + if (!isConcave[i]) break; + i--; + } while (i > 0); + break; + } + previous = i; + i = next; + next = (next + 1) % vertexCount; + } + triangles.push(indices[(vertexCount + i - 1) % vertexCount]); + triangles.push(indices[i]); + triangles.push(indices[(i + 1) % vertexCount]); + indices.splice(i, 1); + isConcave.splice(i, 1); + vertexCount--; + var previousIndex = (vertexCount + i - 1) % vertexCount; + var nextIndex = i == vertexCount ? 0 : i; + isConcave[previousIndex] = Triangulator.isConcave(previousIndex, vertexCount, vertices, indices); + isConcave[nextIndex] = Triangulator.isConcave(nextIndex, vertexCount, vertices, indices); + } + if (vertexCount == 3) { + triangles.push(indices[2]); + triangles.push(indices[0]); + triangles.push(indices[1]); + } + return triangles; + }; + Triangulator.prototype.decompose = function (verticesArray, triangles) { + var vertices = verticesArray; + var convexPolygons = this.convexPolygons; + this.polygonPool.freeAll(convexPolygons); + convexPolygons.length = 0; + var convexPolygonsIndices = this.convexPolygonsIndices; + this.polygonIndicesPool.freeAll(convexPolygonsIndices); + convexPolygonsIndices.length = 0; + var polygonIndices = this.polygonIndicesPool.obtain(); + polygonIndices.length = 0; + var polygon = this.polygonPool.obtain(); + polygon.length = 0; + var fanBaseIndex = -1, + lastWinding = 0; + for (var i = 0, n = triangles.length; i < n; i += 3) { + var t1 = triangles[i] << 1, + t2 = triangles[i + 1] << 1, + t3 = triangles[i + 2] << 1; + var x1 = vertices[t1], + y1 = vertices[t1 + 1]; + var x2 = vertices[t2], + y2 = vertices[t2 + 1]; + var x3 = vertices[t3], + y3 = vertices[t3 + 1]; + var merged = false; + if (fanBaseIndex == t1) { + var o = polygon.length - 4; + var winding1 = Triangulator.winding(polygon[o], polygon[o + 1], polygon[o + 2], polygon[o + 3], x3, y3); + var winding2 = Triangulator.winding(x3, y3, polygon[0], polygon[1], polygon[2], polygon[3]); + if (winding1 == lastWinding && winding2 == lastWinding) { + polygon.push(x3); + polygon.push(y3); + polygonIndices.push(t3); + merged = true; + } + } + if (!merged) { + if (polygon.length > 0) { + convexPolygons.push(polygon); + convexPolygonsIndices.push(polygonIndices); + } else { + this.polygonPool.free(polygon); + this.polygonIndicesPool.free(polygonIndices); + } + polygon = this.polygonPool.obtain(); + polygon.length = 0; + polygon.push(x1); + polygon.push(y1); + polygon.push(x2); + polygon.push(y2); + polygon.push(x3); + polygon.push(y3); + polygonIndices = this.polygonIndicesPool.obtain(); + polygonIndices.length = 0; + polygonIndices.push(t1); + polygonIndices.push(t2); + polygonIndices.push(t3); + lastWinding = Triangulator.winding(x1, y1, x2, y2, x3, y3); + fanBaseIndex = t1; + } + } + if (polygon.length > 0) { + convexPolygons.push(polygon); + convexPolygonsIndices.push(polygonIndices); + } + for (var i = 0, n = convexPolygons.length; i < n; i++) { + polygonIndices = convexPolygonsIndices[i]; + if (polygonIndices.length == 0) continue; + var firstIndex = polygonIndices[0]; + var lastIndex = polygonIndices[polygonIndices.length - 1]; + polygon = convexPolygons[i]; + var o = polygon.length - 4; + var prevPrevX = polygon[o], + prevPrevY = polygon[o + 1]; + var prevX = polygon[o + 2], + prevY = polygon[o + 3]; + var firstX = polygon[0], + firstY = polygon[1]; + var secondX = polygon[2], + secondY = polygon[3]; + var winding = Triangulator.winding(prevPrevX, prevPrevY, prevX, prevY, firstX, firstY); + for (var ii = 0; ii < n; ii++) { + if (ii == i) continue; + var otherIndices = convexPolygonsIndices[ii]; + if (otherIndices.length != 3) continue; + var otherFirstIndex = otherIndices[0]; + var otherSecondIndex = otherIndices[1]; + var otherLastIndex = otherIndices[2]; + var otherPoly = convexPolygons[ii]; + var x3 = otherPoly[otherPoly.length - 2], + y3 = otherPoly[otherPoly.length - 1]; + if (otherFirstIndex != firstIndex || otherSecondIndex != lastIndex) continue; + var winding1 = Triangulator.winding(prevPrevX, prevPrevY, prevX, prevY, x3, y3); + var winding2 = Triangulator.winding(x3, y3, firstX, firstY, secondX, secondY); + if (winding1 == winding && winding2 == winding) { + otherPoly.length = 0; + otherIndices.length = 0; + polygon.push(x3); + polygon.push(y3); + polygonIndices.push(otherLastIndex); + prevPrevX = prevX; + prevPrevY = prevY; + prevX = x3; + prevY = y3; + ii = 0; + } + } + } + for (var i = convexPolygons.length - 1; i >= 0; i--) { + polygon = convexPolygons[i]; + if (polygon.length == 0) { + convexPolygons.splice(i, 1); + this.polygonPool.free(polygon); + polygonIndices = convexPolygonsIndices[i]; + convexPolygonsIndices.splice(i, 1); + this.polygonIndicesPool.free(polygonIndices); + } + } + return convexPolygons; + }; + Triangulator.isConcave = function (index, vertexCount, vertices, indices) { + var previous = indices[(vertexCount + index - 1) % vertexCount] << 1; + var current = indices[index] << 1; + var next = indices[(index + 1) % vertexCount] << 1; + return !this.positiveArea( + vertices[previous], + vertices[previous + 1], + vertices[current], + vertices[current + 1], + vertices[next], + vertices[next + 1], + ); + }; + Triangulator.positiveArea = function (p1x, p1y, p2x, p2y, p3x, p3y) { + return p1x * (p3y - p2y) + p2x * (p1y - p3y) + p3x * (p2y - p1y) >= 0; + }; + Triangulator.winding = function (p1x, p1y, p2x, p2y, p3x, p3y) { + var px = p2x - p1x, + py = p2y - p1y; + return p3x * py - p3y * px + px * p1y - p1x * py >= 0 ? 1 : -1; + }; + return Triangulator; + })(); + core.Triangulator = Triangulator; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var IntSet = (function () { + function IntSet() { + this.array = new Array(); + } + IntSet.prototype.add = function (value) { + var contains = this.contains(value); + this.array[value | 0] = value | 0; + return !contains; + }; + IntSet.prototype.contains = function (value) { + return this.array[value | 0] != undefined; + }; + IntSet.prototype.remove = function (value) { + this.array[value | 0] = undefined; + }; + IntSet.prototype.clear = function () { + this.array.length = 0; + }; + return IntSet; + })(); + core.IntSet = IntSet; + var Color = (function () { + function Color(r, g, b, a) { + if (r === void 0) { + r = 0; + } + if (g === void 0) { + g = 0; + } + if (b === void 0) { + b = 0; + } + if (a === void 0) { + a = 0; + } + this.r = r; + this.g = g; + this.b = b; + this.a = a; + } + Color.prototype.set = function (r, g, b, a) { + this.r = r; + this.g = g; + this.b = b; + this.a = a; + this.clamp(); + return this; + }; + Color.prototype.setFromColor = function (c) { + this.r = c.r; + this.g = c.g; + this.b = c.b; + this.a = c.a; + return this; + }; + Color.prototype.setFromString = function (hex) { + hex = hex.charAt(0) == '#' ? hex.substr(1) : hex; + this.r = parseInt(hex.substr(0, 2), 16) / 255.0; + this.g = parseInt(hex.substr(2, 2), 16) / 255.0; + this.b = parseInt(hex.substr(4, 2), 16) / 255.0; + this.a = (hex.length != 8 ? 255 : parseInt(hex.substr(6, 2), 16)) / 255.0; + return this; + }; + Color.prototype.add = function (r, g, b, a) { + this.r += r; + this.g += g; + this.b += b; + this.a += a; + this.clamp(); + return this; + }; + Color.prototype.clamp = function () { + if (this.r < 0) this.r = 0; + else if (this.r > 1) this.r = 1; + if (this.g < 0) this.g = 0; + else if (this.g > 1) this.g = 1; + if (this.b < 0) this.b = 0; + else if (this.b > 1) this.b = 1; + if (this.a < 0) this.a = 0; + else if (this.a > 1) this.a = 1; + return this; + }; + Color.WHITE = new Color(1, 1, 1, 1); + Color.RED = new Color(1, 0, 0, 1); + Color.GREEN = new Color(0, 1, 0, 1); + Color.BLUE = new Color(0, 0, 1, 1); + Color.MAGENTA = new Color(1, 0, 1, 1); + return Color; + })(); + core.Color = Color; + var MathUtils = (function () { + function MathUtils() {} + MathUtils.clamp = function (value, min, max) { + if (value < min) return min; + if (value > max) return max; + return value; + }; + MathUtils.cosDeg = function (degrees) { + return Math.cos(degrees * MathUtils.degRad); + }; + MathUtils.sinDeg = function (degrees) { + return Math.sin(degrees * MathUtils.degRad); + }; + MathUtils.signum = function (value) { + return value > 0 ? 1 : value < 0 ? -1 : 0; + }; + MathUtils.toInt = function (x) { + return x > 0 ? Math.floor(x) : Math.ceil(x); + }; + MathUtils.cbrt = function (x) { + var y = Math.pow(Math.abs(x), 1 / 3); + return x < 0 ? -y : y; + }; + MathUtils.randomTriangular = function (min, max) { + return MathUtils.randomTriangularWith(min, max, (min + max) * 0.5); + }; + MathUtils.randomTriangularWith = function (min, max, mode) { + var u = Math.random(); + var d = max - min; + if (u <= (mode - min) / d) return min + Math.sqrt(u * d * (mode - min)); + return max - Math.sqrt((1 - u) * d * (max - mode)); + }; + MathUtils.PI = 3.1415927; + MathUtils.PI2 = MathUtils.PI * 2; + MathUtils.radiansToDegrees = 180 / MathUtils.PI; + MathUtils.radDeg = MathUtils.radiansToDegrees; + MathUtils.degreesToRadians = MathUtils.PI / 180; + MathUtils.degRad = MathUtils.degreesToRadians; + return MathUtils; + })(); + core.MathUtils = MathUtils; + var Interpolation = (function () { + function Interpolation() {} + Interpolation.prototype.apply = function (start, end, a) { + return start + (end - start) * this.applyInternal(a); + }; + return Interpolation; + })(); + core.Interpolation = Interpolation; + var Pow = (function (_super) { + __extends(Pow, _super); + function Pow(power) { + var _this = _super.call(this) || this; + _this.power = 2; + _this.power = power; + return _this; + } + Pow.prototype.applyInternal = function (a) { + if (a <= 0.5) return Math.pow(a * 2, this.power) / 2; + return Math.pow((a - 1) * 2, this.power) / (this.power % 2 == 0 ? -2 : 2) + 1; + }; + return Pow; + })(Interpolation); + core.Pow = Pow; + var PowOut = (function (_super) { + __extends(PowOut, _super); + function PowOut(power) { + return _super.call(this, power) || this; + } + PowOut.prototype.applyInternal = function (a) { + return Math.pow(a - 1, this.power) * (this.power % 2 == 0 ? -1 : 1) + 1; + }; + return PowOut; + })(Pow); + core.PowOut = PowOut; + var Utils = (function () { + function Utils() {} + Utils.arrayCopy = function (source, sourceStart, dest, destStart, numElements) { + for (var i = sourceStart, j = destStart; i < sourceStart + numElements; i++, j++) { + dest[j] = source[i]; + } + }; + Utils.setArraySize = function (array, size, value) { + if (value === void 0) { + value = 0; + } + var oldSize = array.length; + if (oldSize == size) return array; + array.length = size; + if (oldSize < size) { + for (var i = oldSize; i < size; i++) array[i] = value; + } + return array; + }; + Utils.ensureArrayCapacity = function (array, size, value) { + if (value === void 0) { + value = 0; + } + if (array.length >= size) return array; + return Utils.setArraySize(array, size, value); + }; + Utils.newArray = function (size, defaultValue) { + var array = new Array(size); + for (var i = 0; i < size; i++) array[i] = defaultValue; + return array; + }; + Utils.newFloatArray = function (size) { + if (Utils.SUPPORTS_TYPED_ARRAYS) { + return new Float32Array(size); + } else { + var array = new Array(size); + for (var i = 0; i < array.length; i++) array[i] = 0; + return array; + } + }; + Utils.newShortArray = function (size) { + if (Utils.SUPPORTS_TYPED_ARRAYS) { + return new Int16Array(size); + } else { + var array = new Array(size); + for (var i = 0; i < array.length; i++) array[i] = 0; + return array; + } + }; + Utils.toFloatArray = function (array) { + return Utils.SUPPORTS_TYPED_ARRAYS ? new Float32Array(array) : array; + }; + Utils.toSinglePrecision = function (value) { + return Utils.SUPPORTS_TYPED_ARRAYS ? Math.fround(value) : value; + }; + Utils.webkit602BugfixHelper = function (alpha, blend) {}; + Utils.SUPPORTS_TYPED_ARRAYS = typeof Float32Array !== 'undefined'; + return Utils; + })(); + core.Utils = Utils; + var DebugUtils = (function () { + function DebugUtils() {} + DebugUtils.logBones = function (skeleton) { + for (var i = 0; i < skeleton.bones.length; i++) { + var bone = skeleton.bones[i]; + var mat = bone.matrix; + console.log( + bone.data.name + ', ' + mat.a + ', ' + mat.b + ', ' + mat.c + ', ' + mat.d + ', ' + mat.tx + ', ' + mat.ty, + ); + } + }; + return DebugUtils; + })(); + core.DebugUtils = DebugUtils; + var Pool = (function () { + function Pool(instantiator) { + this.items = new Array(); + this.instantiator = instantiator; + } + Pool.prototype.obtain = function () { + return this.items.length > 0 ? this.items.pop() : this.instantiator(); + }; + Pool.prototype.free = function (item) { + if (item.reset) item.reset(); + this.items.push(item); + }; + Pool.prototype.freeAll = function (items) { + for (var i = 0; i < items.length; i++) { + if (items[i].reset) items[i].reset(); + this.items[i] = items[i]; + } + }; + Pool.prototype.clear = function () { + this.items.length = 0; + }; + return Pool; + })(); + core.Pool = Pool; + var Vector2 = (function () { + function Vector2(x, y) { + if (x === void 0) { + x = 0; + } + if (y === void 0) { + y = 0; + } + this.x = x; + this.y = y; + } + Vector2.prototype.set = function (x, y) { + this.x = x; + this.y = y; + return this; + }; + Vector2.prototype.length = function () { + var x = this.x; + var y = this.y; + return Math.sqrt(x * x + y * y); + }; + Vector2.prototype.normalize = function () { + var len = this.length(); + if (len != 0) { + this.x /= len; + this.y /= len; + } + return this; + }; + return Vector2; + })(); + core.Vector2 = Vector2; + var TimeKeeper = (function () { + function TimeKeeper() { + this.maxDelta = 0.064; + this.framesPerSecond = 0; + this.delta = 0; + this.totalTime = 0; + this.lastTime = Date.now() / 1000; + this.frameCount = 0; + this.frameTime = 0; + } + TimeKeeper.prototype.update = function () { + var now = Date.now() / 1000; + this.delta = now - this.lastTime; + this.frameTime += this.delta; + this.totalTime += this.delta; + if (this.delta > this.maxDelta) this.delta = this.maxDelta; + this.lastTime = now; + this.frameCount++; + if (this.frameTime > 1) { + this.framesPerSecond = this.frameCount / this.frameTime; + this.frameTime = 0; + this.frameCount = 0; + } + }; + return TimeKeeper; + })(); + core.TimeKeeper = TimeKeeper; + var WindowedMean = (function () { + function WindowedMean(windowSize) { + if (windowSize === void 0) { + windowSize = 32; + } + this.addedValues = 0; + this.lastValue = 0; + this.mean = 0; + this.dirty = true; + this.values = new Array(windowSize); + } + WindowedMean.prototype.hasEnoughData = function () { + return this.addedValues >= this.values.length; + }; + WindowedMean.prototype.addValue = function (value) { + if (this.addedValues < this.values.length) this.addedValues++; + this.values[this.lastValue++] = value; + if (this.lastValue > this.values.length - 1) this.lastValue = 0; + this.dirty = true; + }; + WindowedMean.prototype.getMean = function () { + if (this.hasEnoughData()) { + if (this.dirty) { + var mean = 0; + for (var i = 0; i < this.values.length; i++) { + mean += this.values[i]; + } + this.mean = mean / this.values.length; + this.dirty = false; + } + return this.mean; + } else { + return 0; + } + }; + return WindowedMean; + })(); + core.WindowedMean = WindowedMean; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var Attachment = (function () { + function Attachment(name) { + if (name == null) throw new Error('name cannot be null.'); + this.name = name; + } + return Attachment; + })(); + core.Attachment = Attachment; + var VertexAttachment = (function (_super) { + __extends(VertexAttachment, _super); + function VertexAttachment(name) { + var _this = _super.call(this, name) || this; + _this.id = (VertexAttachment.nextID++ & 65535) << 11; + _this.worldVerticesLength = 0; + return _this; + } + VertexAttachment.prototype.computeWorldVerticesOld = function (slot, worldVertices) { + this.computeWorldVertices(slot, 0, this.worldVerticesLength, worldVertices, 0, 2); + }; + VertexAttachment.prototype.computeWorldVertices = function (slot, start, count, worldVertices, offset, stride) { + count = offset + (count >> 1) * stride; + var skeleton = slot.bone.skeleton; + var deformArray = slot.attachmentVertices; + var vertices = this.vertices; + var bones = this.bones; + if (bones == null) { + if (deformArray.length > 0) vertices = deformArray; + var mat = slot.bone.matrix; + var x = mat.tx; + var y = mat.ty; + var a = mat.a, + b = mat.c, + c = mat.b, + d = mat.d; + for (var v_1 = start, w = offset; w < count; v_1 += 2, w += stride) { + var vx = vertices[v_1], + vy = vertices[v_1 + 1]; + worldVertices[w] = vx * a + vy * b + x; + worldVertices[w + 1] = vx * c + vy * d + y; + } + return; + } + var v = 0, + skip = 0; + for (var i = 0; i < start; i += 2) { + var n = bones[v]; + v += n + 1; + skip += n; + } + var skeletonBones = skeleton.bones; + if (deformArray.length == 0) { + for (var w = offset, b = skip * 3; w < count; w += stride) { + var wx = 0, + wy = 0; + var n = bones[v++]; + n += v; + for (; v < n; v++, b += 3) { + var mat = skeletonBones[bones[v]].matrix; + var vx = vertices[b], + vy = vertices[b + 1], + weight = vertices[b + 2]; + wx += (vx * mat.a + vy * mat.c + mat.tx) * weight; + wy += (vx * mat.b + vy * mat.d + mat.ty) * weight; + } + worldVertices[w] = wx; + worldVertices[w + 1] = wy; + } + } else { + var deform = deformArray; + for (var w = offset, b = skip * 3, f = skip << 1; w < count; w += stride) { + var wx = 0, + wy = 0; + var n = bones[v++]; + n += v; + for (; v < n; v++, b += 3, f += 2) { + var mat = skeletonBones[bones[v]].matrix; + var vx = vertices[b] + deform[f], + vy = vertices[b + 1] + deform[f + 1], + weight = vertices[b + 2]; + wx += (vx * mat.a + vy * mat.c + mat.tx) * weight; + wy += (vx * mat.b + vy * mat.d + mat.ty) * weight; + } + worldVertices[w] = wx; + worldVertices[w + 1] = wy; + } + } + }; + VertexAttachment.prototype.applyDeform = function (sourceAttachment) { + return this == sourceAttachment; + }; + VertexAttachment.nextID = 0; + return VertexAttachment; + })(Attachment); + core.VertexAttachment = VertexAttachment; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var AttachmentType; + (function (AttachmentType) { + AttachmentType[(AttachmentType['Region'] = 0)] = 'Region'; + AttachmentType[(AttachmentType['BoundingBox'] = 1)] = 'BoundingBox'; + AttachmentType[(AttachmentType['Mesh'] = 2)] = 'Mesh'; + AttachmentType[(AttachmentType['LinkedMesh'] = 3)] = 'LinkedMesh'; + AttachmentType[(AttachmentType['Path'] = 4)] = 'Path'; + AttachmentType[(AttachmentType['Point'] = 5)] = 'Point'; + })((AttachmentType = core.AttachmentType || (core.AttachmentType = {}))); + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var BoundingBoxAttachment = (function (_super) { + __extends(BoundingBoxAttachment, _super); + function BoundingBoxAttachment(name) { + var _this = _super.call(this, name) || this; + _this.color = new core.Color(1, 1, 1, 1); + return _this; + } + return BoundingBoxAttachment; + })(core.VertexAttachment); + core.BoundingBoxAttachment = BoundingBoxAttachment; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var ClippingAttachment = (function (_super) { + __extends(ClippingAttachment, _super); + function ClippingAttachment(name) { + var _this = _super.call(this, name) || this; + _this.color = new core.Color(0.2275, 0.2275, 0.8078, 1); + return _this; + } + return ClippingAttachment; + })(core.VertexAttachment); + core.ClippingAttachment = ClippingAttachment; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var MeshAttachment = (function (_super) { + __extends(MeshAttachment, _super); + function MeshAttachment(name) { + var _this = _super.call(this, name) || this; + _this.color = new core.Color(1, 1, 1, 1); + _this.inheritDeform = false; + _this.tempColor = new core.Color(0, 0, 0, 0); + return _this; + } + MeshAttachment.prototype.updateUVs = function (region, uvs) { + var regionUVs = this.regionUVs; + var n = regionUVs.length; + if (!uvs || uvs.length != n) { + uvs = core.Utils.newFloatArray(n); + } + if (region == null) { + return; + } + var texture = region.texture; + var r = texture._uvs; + var w1 = region.width, + h1 = region.height, + w2 = region.originalWidth, + h2 = region.originalHeight; + var x = region.offsetX, + y = region.pixiOffsetY; + for (var i = 0; i < n; i += 2) { + var u = this.regionUVs[i], + v = this.regionUVs[i + 1]; + u = (u * w2 - x) / w1; + v = (v * h2 - y) / h1; + uvs[i] = (r.x0 * (1 - u) + r.x1 * u) * (1 - v) + (r.x3 * (1 - u) + r.x2 * u) * v; + uvs[i + 1] = (r.y0 * (1 - u) + r.y1 * u) * (1 - v) + (r.y3 * (1 - u) + r.y2 * u) * v; + } + return uvs; + }; + MeshAttachment.prototype.applyDeform = function (sourceAttachment) { + return this == sourceAttachment || (this.inheritDeform && this.parentMesh == sourceAttachment); + }; + MeshAttachment.prototype.getParentMesh = function () { + return this.parentMesh; + }; + MeshAttachment.prototype.setParentMesh = function (parentMesh) { + this.parentMesh = parentMesh; + if (parentMesh != null) { + this.bones = parentMesh.bones; + this.vertices = parentMesh.vertices; + this.worldVerticesLength = parentMesh.worldVerticesLength; + this.regionUVs = parentMesh.regionUVs; + this.triangles = parentMesh.triangles; + this.hullLength = parentMesh.hullLength; + this.worldVerticesLength = parentMesh.worldVerticesLength; + } + }; + return MeshAttachment; + })(core.VertexAttachment); + core.MeshAttachment = MeshAttachment; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var PathAttachment = (function (_super) { + __extends(PathAttachment, _super); + function PathAttachment(name) { + var _this = _super.call(this, name) || this; + _this.closed = false; + _this.constantSpeed = false; + _this.color = new core.Color(1, 1, 1, 1); + return _this; + } + return PathAttachment; + })(core.VertexAttachment); + core.PathAttachment = PathAttachment; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var PointAttachment = (function (_super) { + __extends(PointAttachment, _super); + function PointAttachment(name) { + var _this = _super.call(this, name) || this; + _this.color = new core.Color(0.38, 0.94, 0, 1); + return _this; + } + PointAttachment.prototype.computeWorldPosition = function (bone, point) { + var mat = bone.matrix; + point.x = this.x * mat.a + this.y * mat.c + bone.worldX; + point.y = this.x * mat.b + this.y * mat.d + bone.worldY; + return point; + }; + PointAttachment.prototype.computeWorldRotation = function (bone) { + var mat = bone.matrix; + var cos = core.MathUtils.cosDeg(this.rotation), + sin = core.MathUtils.sinDeg(this.rotation); + var x = cos * mat.a + sin * mat.c; + var y = cos * mat.b + sin * mat.d; + return Math.atan2(y, x) * core.MathUtils.radDeg; + }; + return PointAttachment; + })(core.VertexAttachment); + core.PointAttachment = PointAttachment; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var RegionAttachment = (function (_super) { + __extends(RegionAttachment, _super); + function RegionAttachment(name) { + var _this = _super.call(this, name) || this; + _this.x = 0; + _this.y = 0; + _this.scaleX = 1; + _this.scaleY = 1; + _this.rotation = 0; + _this.width = 0; + _this.height = 0; + _this.color = new core.Color(1, 1, 1, 1); + _this.offset = core.Utils.newFloatArray(8); + _this.uvs = core.Utils.newFloatArray(8); + _this.tempColor = new core.Color(1, 1, 1, 1); + return _this; + } + RegionAttachment.prototype.updateOffset = function () { + var regionScaleX = (this.width / this.region.originalWidth) * this.scaleX; + var regionScaleY = (this.height / this.region.originalHeight) * this.scaleY; + var localX = (-this.width / 2) * this.scaleX + this.region.offsetX * regionScaleX; + var localY = (-this.height / 2) * this.scaleY + this.region.offsetY * regionScaleY; + var localX2 = localX + this.region.width * regionScaleX; + var localY2 = localY + this.region.height * regionScaleY; + var radians = (this.rotation * Math.PI) / 180; + var cos = Math.cos(radians); + var sin = Math.sin(radians); + var localXCos = localX * cos + this.x; + var localXSin = localX * sin; + var localYCos = localY * cos + this.y; + var localYSin = localY * sin; + var localX2Cos = localX2 * cos + this.x; + var localX2Sin = localX2 * sin; + var localY2Cos = localY2 * cos + this.y; + var localY2Sin = localY2 * sin; + var offset = this.offset; + offset[RegionAttachment.OX1] = localXCos - localYSin; + offset[RegionAttachment.OY1] = localYCos + localXSin; + offset[RegionAttachment.OX2] = localXCos - localY2Sin; + offset[RegionAttachment.OY2] = localY2Cos + localXSin; + offset[RegionAttachment.OX3] = localX2Cos - localY2Sin; + offset[RegionAttachment.OY3] = localY2Cos + localX2Sin; + offset[RegionAttachment.OX4] = localX2Cos - localYSin; + offset[RegionAttachment.OY4] = localYCos + localX2Sin; + }; + RegionAttachment.prototype.setRegion = function (region) { + this.region = region; + var uvs = this.uvs; + if (region.rotate) { + uvs[2] = region.u; + uvs[3] = region.v2; + uvs[4] = region.u; + uvs[5] = region.v; + uvs[6] = region.u2; + uvs[7] = region.v; + uvs[0] = region.u2; + uvs[1] = region.v2; + } else { + uvs[0] = region.u; + uvs[1] = region.v2; + uvs[2] = region.u; + uvs[3] = region.v; + uvs[4] = region.u2; + uvs[5] = region.v; + uvs[6] = region.u2; + uvs[7] = region.v2; + } + }; + RegionAttachment.prototype.computeWorldVertices = function (bone, worldVertices, offset, stride) { + var vertexOffset = this.offset; + var mat = bone.matrix; + var x = mat.tx, + y = mat.ty; + var a = mat.a, + b = mat.c, + c = mat.b, + d = mat.d; + var offsetX = 0, + offsetY = 0; + offsetX = vertexOffset[RegionAttachment.OX1]; + offsetY = vertexOffset[RegionAttachment.OY1]; + worldVertices[offset] = offsetX * a + offsetY * b + x; + worldVertices[offset + 1] = offsetX * c + offsetY * d + y; + offset += stride; + offsetX = vertexOffset[RegionAttachment.OX2]; + offsetY = vertexOffset[RegionAttachment.OY2]; + worldVertices[offset] = offsetX * a + offsetY * b + x; + worldVertices[offset + 1] = offsetX * c + offsetY * d + y; + offset += stride; + offsetX = vertexOffset[RegionAttachment.OX3]; + offsetY = vertexOffset[RegionAttachment.OY3]; + worldVertices[offset] = offsetX * a + offsetY * b + x; + worldVertices[offset + 1] = offsetX * c + offsetY * d + y; + offset += stride; + offsetX = vertexOffset[RegionAttachment.OX4]; + offsetY = vertexOffset[RegionAttachment.OY4]; + worldVertices[offset] = offsetX * a + offsetY * b + x; + worldVertices[offset + 1] = offsetX * c + offsetY * d + y; + }; + RegionAttachment.OX1 = 0; + RegionAttachment.OY1 = 1; + RegionAttachment.OX2 = 2; + RegionAttachment.OY2 = 3; + RegionAttachment.OX3 = 4; + RegionAttachment.OY3 = 5; + RegionAttachment.OX4 = 6; + RegionAttachment.OY4 = 7; + RegionAttachment.X1 = 0; + RegionAttachment.Y1 = 1; + RegionAttachment.C1R = 2; + RegionAttachment.C1G = 3; + RegionAttachment.C1B = 4; + RegionAttachment.C1A = 5; + RegionAttachment.U1 = 6; + RegionAttachment.V1 = 7; + RegionAttachment.X2 = 8; + RegionAttachment.Y2 = 9; + RegionAttachment.C2R = 10; + RegionAttachment.C2G = 11; + RegionAttachment.C2B = 12; + RegionAttachment.C2A = 13; + RegionAttachment.U2 = 14; + RegionAttachment.V2 = 15; + RegionAttachment.X3 = 16; + RegionAttachment.Y3 = 17; + RegionAttachment.C3R = 18; + RegionAttachment.C3G = 19; + RegionAttachment.C3B = 20; + RegionAttachment.C3A = 21; + RegionAttachment.U3 = 22; + RegionAttachment.V3 = 23; + RegionAttachment.X4 = 24; + RegionAttachment.Y4 = 25; + RegionAttachment.C4R = 26; + RegionAttachment.C4G = 27; + RegionAttachment.C4B = 28; + RegionAttachment.C4A = 29; + RegionAttachment.U4 = 30; + RegionAttachment.V4 = 31; + return RegionAttachment; + })(core.Attachment); + core.RegionAttachment = RegionAttachment; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var JitterEffect = (function () { + function JitterEffect(jitterX, jitterY) { + this.jitterX = 0; + this.jitterY = 0; + this.jitterX = jitterX; + this.jitterY = jitterY; + } + JitterEffect.prototype.begin = function (skeleton) {}; + JitterEffect.prototype.transform = function (position, uv, light, dark) { + position.x += core.MathUtils.randomTriangular(-this.jitterX, this.jitterY); + position.y += core.MathUtils.randomTriangular(-this.jitterX, this.jitterY); + }; + JitterEffect.prototype.end = function () {}; + return JitterEffect; + })(); + core.JitterEffect = JitterEffect; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var SwirlEffect = (function () { + function SwirlEffect(radius) { + this.centerX = 0; + this.centerY = 0; + this.radius = 0; + this.angle = 0; + this.worldX = 0; + this.worldY = 0; + this.radius = radius; + } + SwirlEffect.prototype.begin = function (skeleton) { + this.worldX = skeleton.x + this.centerX; + this.worldY = skeleton.y + this.centerY; + }; + SwirlEffect.prototype.transform = function (position, uv, light, dark) { + var radAngle = this.angle * core.MathUtils.degreesToRadians; + var x = position.x - this.worldX; + var y = position.y - this.worldY; + var dist = Math.sqrt(x * x + y * y); + if (dist < this.radius) { + var theta = SwirlEffect.interpolation.apply(0, radAngle, (this.radius - dist) / this.radius); + var cos = Math.cos(theta); + var sin = Math.sin(theta); + position.x = cos * x - sin * y + this.worldX; + position.y = sin * x + cos * y + this.worldY; + } + }; + SwirlEffect.prototype.end = function () {}; + SwirlEffect.interpolation = new core.PowOut(2); + return SwirlEffect; + })(); + core.SwirlEffect = SwirlEffect; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +(function () { + if (!Math.fround) { + Math.fround = Math.fround = (function (array) { + return function (x) { + return (array[0] = x), array[0]; + }; + })(new Float32Array(1)); + } +})(); +var pixi_spine; +(function (pixi_spine) { + pixi_spine.core.Bone.yDown = true; + var tempRgb = [0, 0, 0]; + var SpineSprite = (function (_super) { + __extends(SpineSprite, _super); + function SpineSprite() { + var _this = (_super !== null && _super.apply(this, arguments)) || this; + _this.region = null; + return _this; + } + return SpineSprite; + })(PIXI.Sprite); + pixi_spine.SpineSprite = SpineSprite; + var SpineMesh = (function (_super) { + __extends(SpineMesh, _super); + function SpineMesh(texture, vertices, uvs, indices, drawMode) { + return _super.call(this, texture, vertices, uvs, indices, drawMode) || this; + } + return SpineMesh; + })(PIXI.mesh.Mesh); + pixi_spine.SpineMesh = SpineMesh; + var Spine = (function (_super) { + __extends(Spine, _super); + function Spine(spineData) { + var _this = _super.call(this) || this; + if (!spineData) { + throw new Error('The spineData param is required.'); + } + if (typeof spineData === 'string') { + throw new Error( + 'spineData param cant be string. Please use spine.Spine.fromAtlas("YOUR_RESOURCE_NAME") from now on.', + ); + } + _this.spineData = spineData; + _this.skeleton = new pixi_spine.core.Skeleton(spineData); + _this.skeleton.updateWorldTransform(); + _this.stateData = new pixi_spine.core.AnimationStateData(spineData); + _this.state = new pixi_spine.core.AnimationState(_this.stateData); + _this.slotContainers = []; + _this.tempClipContainers = []; + for (var i = 0, n = _this.skeleton.slots.length; i < n; i++) { + var slot = _this.skeleton.slots[i]; + var attachment = slot.attachment; + var slotContainer = _this.newContainer(); + _this.slotContainers.push(slotContainer); + _this.addChild(slotContainer); + _this.tempClipContainers.push(null); + if (attachment instanceof pixi_spine.core.RegionAttachment) { + var spriteName = attachment.region.name; + var sprite = _this.createSprite(slot, attachment, spriteName); + slot.currentSprite = sprite; + slot.currentSpriteName = spriteName; + slotContainer.addChild(sprite); + } else if (attachment instanceof pixi_spine.core.MeshAttachment) { + var mesh = _this.createMesh(slot, attachment); + slot.currentMesh = mesh; + slot.currentMeshName = attachment.name; + slotContainer.addChild(mesh); + } else if (attachment instanceof pixi_spine.core.ClippingAttachment) { + _this.createGraphics(slot, attachment); + slotContainer.addChild(slot.clippingContainer); + slotContainer.addChild(slot.currentGraphics); + } else { + continue; + } + } + _this.autoUpdate = true; + _this.tintRgb = new Float32Array([1, 1, 1]); + return _this; + } + Object.defineProperty(Spine.prototype, 'autoUpdate', { + get: function () { + return this.updateTransform === Spine.prototype.autoUpdateTransform; + }, + set: function (value) { + this.updateTransform = value ? Spine.prototype.autoUpdateTransform : PIXI.Container.prototype.updateTransform; + }, + enumerable: true, + configurable: true, + }); + Object.defineProperty(Spine.prototype, 'tint', { + get: function () { + return PIXI.utils.rgb2hex(this.tintRgb); + }, + set: function (value) { + this.tintRgb = PIXI.utils.hex2rgb(value, this.tintRgb); + }, + enumerable: true, + configurable: true, + }); + Object.defineProperty(Spine.prototype, 'delayLimit', { + get: function () { + var limit = typeof this.localDelayLimit !== 'undefined' ? this.localDelayLimit : Spine.globalDelayLimit; + return limit || Number.MAX_VALUE; + }, + enumerable: true, + configurable: true, + }); + Spine.prototype.update = function (dt) { + var delayLimit = this.delayLimit; + if (dt > delayLimit) dt = delayLimit; + this.state.update(dt); + this.state.apply(this.skeleton); + if (!this.skeleton) return; + this.skeleton.updateWorldTransform(); + var slots = this.skeleton.slots; + var globalClr = this.color; + var light = null, + dark = null; + if (globalClr) { + light = globalClr.light; + dark = globalClr.dark; + } else { + light = this.tintRgb; + } + var thack = PIXI.TransformBase && this.transformHack() == 1; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + var attachment = slot.attachment; + var slotContainer = this.slotContainers[i]; + if (!attachment) { + slotContainer.visible = false; + continue; + } + var spriteColor = null; + var attColor = attachment.color; + if (attachment instanceof pixi_spine.core.RegionAttachment) { + var region = attachment.region; + if (region) { + if (slot.currentMesh) { + slot.currentMesh.visible = false; + slot.currentMesh = null; + slot.currentMeshName = undefined; + } + var ar = region; + if (!slot.currentSpriteName || slot.currentSpriteName !== ar.name) { + var spriteName = ar.name; + if (slot.currentSprite) { + slot.currentSprite.visible = false; + } + slot.sprites = slot.sprites || {}; + if (slot.sprites[spriteName] !== undefined) { + slot.sprites[spriteName].visible = true; + } else { + var sprite = this.createSprite(slot, attachment, spriteName); + slotContainer.addChild(sprite); + } + slot.currentSprite = slot.sprites[spriteName]; + slot.currentSpriteName = spriteName; + } + } + if (slotContainer.transform) { + var transform = slotContainer.transform; + var transAny = transform; + var lt = null; + if (transAny.matrix2d) { + lt = transAny.matrix2d; + transAny._dirtyVersion++; + transAny.version = transAny._dirtyVersion; + transAny.isStatic = true; + transAny.operMode = 0; + } else { + if (thack) { + if (transAny.position) { + transform = new PIXI.TransformBase(); + transform._parentID = -1; + transform._worldID = slotContainer.transform._worldID; + slotContainer.transform = transform; + } + lt = transform.localTransform; + } else { + transAny.setFromMatrix(slot.bone.matrix); + } + } + if (lt) { + slot.bone.matrix.copy(lt); + } + } else { + var lt = slotContainer.localTransform || new PIXI.Matrix(); + slot.bone.matrix.copy(lt); + slotContainer.localTransform = lt; + slotContainer.displayObjectUpdateTransform = SlotContainerUpdateTransformV3; + } + if (slot.currentSprite.color) { + spriteColor = slot.currentSprite.color; + } else { + tempRgb[0] = light[0] * slot.color.r * attColor.r; + tempRgb[1] = light[1] * slot.color.g * attColor.g; + tempRgb[2] = light[2] * slot.color.b * attColor.b; + slot.currentSprite.tint = PIXI.utils.rgb2hex(tempRgb); + } + slot.currentSprite.blendMode = slot.blendMode; + } else if (attachment instanceof pixi_spine.core.MeshAttachment) { + if (slot.currentSprite) { + slot.currentSprite.visible = false; + slot.currentSprite = null; + slot.currentSpriteName = undefined; + if (slotContainer.transform) { + var transform = new PIXI.TransformStatic(); + transform._parentID = -1; + transform._worldID = slotContainer.transform._worldID; + slotContainer.transform = transform; + } else { + slotContainer.localTransform = new PIXI.Matrix(); + slotContainer.displayObjectUpdateTransform = PIXI.DisplayObject.prototype.updateTransform; + } + } + if (!slot.currentMeshName || slot.currentMeshName !== attachment.name) { + var meshName = attachment.name; + if (slot.currentMesh) { + slot.currentMesh.visible = false; + } + slot.meshes = slot.meshes || {}; + if (slot.meshes[meshName] !== undefined) { + slot.meshes[meshName].visible = true; + } else { + var mesh = this.createMesh(slot, attachment); + slotContainer.addChild(mesh); + } + slot.currentMesh = slot.meshes[meshName]; + slot.currentMeshName = meshName; + } + attachment.computeWorldVerticesOld(slot, slot.currentMesh.vertices); + if (slot.currentMesh.color) { + spriteColor = slot.currentMesh.color; + } else if (PIXI.VERSION[0] !== '3') { + var tintRgb = slot.currentMesh.tintRgb; + tintRgb[0] = light[0] * slot.color.r * attColor.r; + tintRgb[1] = light[1] * slot.color.g * attColor.g; + tintRgb[2] = light[2] * slot.color.b * attColor.b; + } + slot.currentMesh.blendMode = slot.blendMode; + } else if (attachment instanceof pixi_spine.core.ClippingAttachment) { + if (!slot.currentGraphics) { + this.createGraphics(slot, attachment); + slotContainer.addChild(slot.clippingContainer); + slotContainer.addChild(slot.currentGraphics); + } + this.updateGraphics(slot, attachment); + } else { + slotContainer.visible = false; + continue; + } + slotContainer.visible = true; + if (spriteColor) { + var r0 = slot.color.r * attColor.r; + var g0 = slot.color.g * attColor.g; + var b0 = slot.color.b * attColor.b; + spriteColor.setLight( + light[0] * r0 + dark[0] * (1.0 - r0), + light[1] * g0 + dark[1] * (1.0 - g0), + light[2] * b0 + dark[2] * (1.0 - b0), + ); + if (slot.darkColor) { + r0 = slot.darkColor.r; + g0 = slot.darkColor.g; + b0 = slot.darkColor.b; + } else { + r0 = 0.0; + g0 = 0.0; + b0 = 0.0; + } + spriteColor.setDark( + light[0] * r0 + dark[0] * (1 - r0), + light[1] * g0 + dark[1] * (1 - g0), + light[2] * b0 + dark[2] * (1 - b0), + ); + } + slotContainer.alpha = slot.color.a; + } + var drawOrder = this.skeleton.drawOrder; + var clippingAttachment = null; + var clippingContainer = null; + for (var i = 0, n = drawOrder.length; i < n; i++) { + var slot = slots[drawOrder[i].data.index]; + var slotContainer = this.slotContainers[drawOrder[i].data.index]; + if (!clippingContainer) { + if (slotContainer.parent !== null && slotContainer.parent !== this) { + slotContainer.parent.removeChild(slotContainer); + slotContainer.parent = this; + } + } + if (slot.currentGraphics && slot.attachment) { + clippingContainer = slot.clippingContainer; + clippingAttachment = slot.attachment; + clippingContainer.children.length = 0; + this.children[i] = slotContainer; + if (clippingAttachment.endSlot == slot.data) { + clippingAttachment.endSlot = null; + } + } else { + if (clippingContainer) { + var c = this.tempClipContainers[i]; + if (!c) { + c = this.tempClipContainers[i] = this.newContainer(); + c.visible = false; + } + this.children[i] = c; + slotContainer.parent = null; + clippingContainer.addChild(slotContainer); + if (clippingAttachment.endSlot == slot.data) { + clippingContainer.renderable = true; + clippingContainer = null; + clippingAttachment = null; + } + } else { + this.children[i] = slotContainer; + } + } + } + }; + Spine.prototype.setSpriteRegion = function (attachment, sprite, region) { + sprite.region = region; + sprite.texture = region.texture; + if (!region.size) { + sprite.scale.x = (attachment.scaleX * attachment.width) / region.originalWidth; + sprite.scale.y = (-attachment.scaleY * attachment.height) / region.originalHeight; + } else { + sprite.scale.x = region.size.width / region.originalWidth; + sprite.scale.y = -region.size.height / region.originalHeight; + } + }; + Spine.prototype.setMeshRegion = function (attachment, mesh, region) { + mesh.region = region; + mesh.texture = region.texture; + region.texture._updateUvs(); + attachment.updateUVs(region, mesh.uvs); + mesh.dirty++; + }; + Spine.prototype.autoUpdateTransform = function () { + if (Spine.globalAutoUpdate) { + this.lastTime = this.lastTime || Date.now(); + var timeDelta = (Date.now() - this.lastTime) * 0.001; + this.lastTime = Date.now(); + this.update(timeDelta); + } else { + this.lastTime = 0; + } + PIXI.Container.prototype.updateTransform.call(this); + }; + Spine.prototype.createSprite = function (slot, attachment, defName) { + var region = attachment.region; + if (slot.tempAttachment === attachment) { + region = slot.tempRegion; + slot.tempAttachment = null; + slot.tempRegion = null; + } + var texture = region.texture; + var sprite = this.newSprite(texture); + sprite.rotation = attachment.rotation * pixi_spine.core.MathUtils.degRad; + sprite.anchor.x = 0.5; + sprite.anchor.y = 0.5; + sprite.position.x = attachment.x; + sprite.position.y = attachment.y; + sprite.alpha = attachment.color.a; + sprite.region = attachment.region; + this.setSpriteRegion(attachment, sprite, attachment.region); + slot.sprites = slot.sprites || {}; + slot.sprites[defName] = sprite; + return sprite; + }; + Spine.prototype.createMesh = function (slot, attachment) { + var region = attachment.region; + if (slot.tempAttachment === attachment) { + region = slot.tempRegion; + slot.tempAttachment = null; + slot.tempRegion = null; + } + var strip = this.newMesh( + region.texture, + new Float32Array(attachment.regionUVs.length), + new Float32Array(attachment.regionUVs.length), + new Uint16Array(attachment.triangles), + PIXI.mesh.Mesh.DRAW_MODES.TRIANGLES, + ); + strip.canvasPadding = 1.5; + strip.alpha = attachment.color.a; + strip.region = attachment.region; + this.setMeshRegion(attachment, strip, region); + slot.meshes = slot.meshes || {}; + slot.meshes[attachment.name] = strip; + return strip; + }; + Spine.prototype.createGraphics = function (slot, clip) { + var graphics = this.newGraphics(); + var poly = new PIXI.Polygon([]); + graphics.clear(); + graphics.beginFill(0xffffff, 1); + graphics.drawPolygon(poly); + graphics.renderable = false; + slot.currentGraphics = graphics; + slot.clippingContainer = this.newContainer(); + slot.clippingContainer.mask = slot.currentGraphics; + return graphics; + }; + Spine.prototype.updateGraphics = function (slot, clip) { + var vertices = slot.currentGraphics.graphicsData[0].shape.points; + var n = clip.worldVerticesLength; + vertices.length = n; + clip.computeWorldVertices(slot, 0, n, vertices, 0, 2); + slot.currentGraphics.dirty++; + slot.currentGraphics.clearDirty++; + }; + Spine.prototype.hackTextureBySlotIndex = function (slotIndex, texture, size) { + if (texture === void 0) { + texture = null; + } + if (size === void 0) { + size = null; + } + var slot = this.skeleton.slots[slotIndex]; + if (!slot) { + return false; + } + var attachment = slot.attachment; + var region = attachment.region; + if (texture) { + region = new pixi_spine.core.TextureRegion(); + region.texture = texture; + region.size = size; + } + if (slot.currentSprite && slot.currentSprite.region != region) { + this.setSpriteRegion(attachment, slot.currentSprite, region); + slot.currentSprite.region = region; + } else if (slot.currentMesh && slot.currentMesh.region != region) { + this.setMeshRegion(attachment, slot.currentMesh, region); + } else { + slot.tempRegion = region; + slot.tempAttachment = attachment; + } + return true; + }; + Spine.prototype.hackTextureBySlotName = function (slotName, texture, size) { + if (texture === void 0) { + texture = null; + } + if (size === void 0) { + size = null; + } + var index = this.skeleton.findSlotIndex(slotName); + if (index == -1) { + return false; + } + return this.hackTextureBySlotIndex(index, texture, size); + }; + Spine.prototype.newContainer = function () { + return new PIXI.Container(); + }; + Spine.prototype.newSprite = function (tex) { + return new SpineSprite(tex); + }; + Spine.prototype.newGraphics = function () { + return new PIXI.Graphics(); + }; + Spine.prototype.newMesh = function (texture, vertices, uvs, indices, drawMode) { + return new SpineMesh(texture, vertices, uvs, indices, drawMode); + }; + Spine.prototype.transformHack = function () { + return 1; + }; + Spine.prototype.hackAttachmentGroups = function (nameSuffix, group, outGroup) { + if (!nameSuffix) { + return; + } + var list_d = [], + list_n = []; + for (var i = 0, len = this.skeleton.slots.length; i < len; i++) { + var slot = this.skeleton.slots[i]; + var name_2 = slot.currentSpriteName || slot.currentMeshName || ''; + var target = slot.currentSprite || slot.currentMesh; + if (name_2.endsWith(nameSuffix)) { + target.parentGroup = group; + list_n.push(target); + } else if (outGroup && target) { + target.parentGroup = outGroup; + list_d.push(target); + } + } + return [list_d, list_n]; + }; + Spine.prototype.destroy = function (options) { + for (var i = 0, n = this.skeleton.slots.length; i < n; i++) { + var slot = this.skeleton.slots[i]; + for (var name_3 in slot.meshes) { + slot.meshes[name_3].destroy(options); + } + slot.meshes = null; + for (var name_4 in slot.sprites) { + slot.sprites[name_4].destroy(options); + } + slot.sprites = null; + } + for (var i = 0, n = this.slotContainers.length; i < n; i++) { + this.slotContainers[i].destroy(options); + } + this.spineData = null; + this.skeleton = null; + this.slotContainers = null; + this.stateData = null; + this.state = null; + this.tempClipContainers = null; + _super.prototype.destroy.call(this, options); + }; + Spine.globalAutoUpdate = true; + Spine.globalDelayLimit = 0; + Spine.clippingPolygon = []; + return Spine; + })(PIXI.Container); + pixi_spine.Spine = Spine; + function SlotContainerUpdateTransformV3() { + var pt = this.parent.worldTransform; + var wt = this.worldTransform; + var lt = this.localTransform; + wt.a = lt.a * pt.a + lt.b * pt.c; + wt.b = lt.a * pt.b + lt.b * pt.d; + wt.c = lt.c * pt.a + lt.d * pt.c; + wt.d = lt.c * pt.b + lt.d * pt.d; + wt.tx = lt.tx * pt.a + lt.ty * pt.c + pt.tx; + wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; + this.worldAlpha = this.alpha * this.parent.worldAlpha; + this._currentBounds = null; + } +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + PIXI.spine = pixi_spine; + var TextureProto = PIXI.Texture.prototype; + if (!TextureProto._updateUvs) { + TextureProto._updateUvs = TextureProto.updateUvs; + } +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + function isJson(resource) { + return resource.type === PIXI.loaders.Resource.TYPE.JSON; + } + function atlasParser() { + return function atlasParser(resource, next) { + if (!resource.data || !isJson(resource) || !resource.data.bones) { + return next(); + } + var metadata = resource.metadata || {}; + var metadataSkeletonScale = metadata ? resource.metadata.spineSkeletonScale : null; + var metadataAtlas = metadata ? resource.metadata.spineAtlas : null; + if (metadataAtlas === false) { + return next(); + } + if (metadataAtlas && metadataAtlas.pages) { + var spineJsonParser = new pixi_spine.core.SkeletonJson( + new pixi_spine.core.AtlasAttachmentLoader(metadataAtlas), + ); + if (metadataSkeletonScale) { + spineJsonParser.scale = metadataSkeletonScale; + } + var skeletonData = spineJsonParser.readSkeletonData(resource.data); + resource.spineData = skeletonData; + resource.spineAtlas = metadataAtlas; + return next(); + } + var metadataAtlasSuffix = metadata.spineAtlasSuffix || '.atlas'; + var atlasPath = resource.url; + var queryStringPos = atlasPath.indexOf('?'); + if (queryStringPos > 0) { + atlasPath = atlasPath.substr(0, queryStringPos); + } + atlasPath = atlasPath.substr(0, atlasPath.lastIndexOf('.')) + metadataAtlasSuffix; + if (resource.metadata && resource.metadata.spineAtlasFile) { + atlasPath = resource.metadata.spineAtlasFile; + } + atlasPath = atlasPath.replace(this.baseUrl, ''); + var atlasOptions = { + crossOrigin: resource.crossOrigin, + xhrType: PIXI.loaders.Resource.XHR_RESPONSE_TYPE.TEXT, + metadata: metadata.spineMetadata || null, + parentResource: resource, + }; + var imageOptions = { + crossOrigin: resource.crossOrigin, + metadata: metadata.imageMetadata || null, + parentResource: resource, + }; + var baseUrl = resource.url.substr(0, resource.url.lastIndexOf('/') + 1); + baseUrl = baseUrl.replace(this.baseUrl, ''); + var namePrefix = metadata.imageNamePrefix || resource.name + '_atlas_page_'; + var adapter = metadata.images + ? staticImageLoader(metadata.images) + : metadata.image + ? staticImageLoader({ default: metadata.image }) + : metadata.imageLoader + ? metadata.imageLoader(this, namePrefix, baseUrl, imageOptions) + : imageLoaderAdapter(this, namePrefix, baseUrl, imageOptions); + var createSkeletonWithRawAtlas = function (rawData) { + new pixi_spine.core.TextureAtlas(rawData, adapter, function (spineAtlas) { + if (spineAtlas) { + var spineJsonParser = new pixi_spine.core.SkeletonJson( + new pixi_spine.core.AtlasAttachmentLoader(spineAtlas), + ); + if (metadataSkeletonScale) { + spineJsonParser.scale = metadataSkeletonScale; + } + resource.spineData = spineJsonParser.readSkeletonData(resource.data); + resource.spineAtlas = spineAtlas; + } + next(); + }); + }; + if (resource.metadata && resource.metadata.atlasRawData) { + createSkeletonWithRawAtlas(resource.metadata.atlasRawData); + } else { + this.add(resource.name + '_atlas', atlasPath, atlasOptions, function (atlasResource) { + if (!atlasResource.error) { + createSkeletonWithRawAtlas(atlasResource.data); + } else { + next(); + } + }); + } + }; + } + pixi_spine.atlasParser = atlasParser; + function imageLoaderAdapter(loader, namePrefix, baseUrl, imageOptions) { + if (baseUrl && baseUrl.lastIndexOf('/') !== baseUrl.length - 1) { + baseUrl += '/'; + } + return function (line, callback) { + var name = namePrefix + line; + var url = baseUrl + line; + var cachedResource = loader.resources[name]; + if (cachedResource) { + function done() { + callback(cachedResource.texture.baseTexture); + } + if (cachedResource.texture) { + done(); + } else { + cachedResource.onAfterMiddleware.add(done); + } + } else { + loader.add(name, url, imageOptions, function (resource) { + if (!resource.error) { + callback(resource.texture.baseTexture); + } else { + callback(null); + } + }); + } + }; + } + pixi_spine.imageLoaderAdapter = imageLoaderAdapter; + function syncImageLoaderAdapter(baseUrl, crossOrigin) { + if (baseUrl && baseUrl.lastIndexOf('/') !== baseUrl.length - 1) { + baseUrl += '/'; + } + return function (line, callback) { + callback(PIXI.BaseTexture.fromImage(line, crossOrigin)); + }; + } + pixi_spine.syncImageLoaderAdapter = syncImageLoaderAdapter; + function staticImageLoader(pages) { + return function (line, callback) { + var page = pages[line] || pages['default']; + if (page && page.baseTexture) callback(page.baseTexture); + else callback(page); + }; + } + pixi_spine.staticImageLoader = staticImageLoader; + if (PIXI.loaders.Loader) { + PIXI.loaders.Loader.addPixiMiddleware(atlasParser); + PIXI.loader.use(atlasParser()); + } +})(pixi_spine || (pixi_spine = {})); + +export default pixi_spine; +//# sourceMappingURL=pixi-spine.js.map diff --git a/packages/plugin-renderer-spine38/README.md b/packages/plugin-renderer-spine38/README.md index 08dfd52c..4da8b705 100644 --- a/packages/plugin-renderer-spine38/README.md +++ b/packages/plugin-renderer-spine38/README.md @@ -1,7 +1,6 @@ - # @eva/plugin-renderer-spine More Introduction + - [EN](https://eva.js.org) - [中文](https://eva-engine.gitee.io) - \ No newline at end of file diff --git a/packages/plugin-renderer-spine38/api-extractor.json b/packages/plugin-renderer-spine38/api-extractor.json index ef2beeb4..a9430cb9 100644 --- a/packages/plugin-renderer-spine38/api-extractor.json +++ b/packages/plugin-renderer-spine38/api-extractor.json @@ -4,4 +4,4 @@ "dtsRollup": { "publicTrimmedFilePath": "./dist/plugin-renderer-spine.d.ts" } -} \ No newline at end of file +} diff --git a/packages/plugin-renderer-spine38/index.js b/packages/plugin-renderer-spine38/index.js index c95cea38..f6960183 100644 --- a/packages/plugin-renderer-spine38/index.js +++ b/packages/plugin-renderer-spine38/index.js @@ -1,7 +1,7 @@ -'use strict' +'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/plugin-renderer-spine.cjs.prod.js') + module.exports = require('./dist/plugin-renderer-spine.cjs.prod.js'); } else { - module.exports = require('./dist/plugin-renderer-spine.cjs.js') + module.exports = require('./dist/plugin-renderer-spine.cjs.js'); } diff --git a/packages/plugin-renderer-spine38/lib/Spine.ts b/packages/plugin-renderer-spine38/lib/Spine.ts index 9bceccdb..02e1e477 100644 --- a/packages/plugin-renderer-spine38/lib/Spine.ts +++ b/packages/plugin-renderer-spine38/lib/Spine.ts @@ -1,4 +1,4 @@ -import {Component, decorators} from '@eva/eva.js'; +import { Component, decorators } from '@eva/eva.js'; export interface SpineParams { resource: string; diff --git a/packages/plugin-renderer-spine38/lib/SpineData.ts b/packages/plugin-renderer-spine38/lib/SpineData.ts index 75a9e7a4..c7820c1b 100644 --- a/packages/plugin-renderer-spine38/lib/SpineData.ts +++ b/packages/plugin-renderer-spine38/lib/SpineData.ts @@ -1,11 +1,6 @@ -import {resource} from '@eva/eva.js'; +import { resource } from '@eva/eva.js'; import pixispine from './pixi-spine.js'; -import { - cleanTextures, - getTexture, - releaseTexture, - retainTexture, -} from './TexCache'; +import { cleanTextures, getTexture, releaseTexture, retainTexture } from './TexCache'; let dataMap: any = {}; function createSpineData(name, imgName, data, scale) { @@ -22,13 +17,9 @@ function createSpineData(name, imgName, data, scale) { spineAtlas => { if (spineAtlas) { // @ts-ignore - const attachmentLoader = new pixispine.core.AtlasAttachmentLoader( - spineAtlas, - ); + const attachmentLoader = new pixispine.core.AtlasAttachmentLoader(spineAtlas); // @ts-ignore - const spineJsonParser = new pixispine.core.SkeletonJson( - attachmentLoader, - ); + const spineJsonParser = new pixispine.core.SkeletonJson(attachmentLoader); if (scale) { spineJsonParser.scale = scale; } @@ -36,7 +27,7 @@ function createSpineData(name, imgName, data, scale) { } }, ); - const obj = {spineData, ref: 0, imgName: imgName}; + const obj = { spineData, ref: 0, imgName: imgName }; dataMap[name] = obj; return obj; } diff --git a/packages/plugin-renderer-spine38/lib/SpineSystem.ts b/packages/plugin-renderer-spine38/lib/SpineSystem.ts index 162173dd..4d3d9c14 100644 --- a/packages/plugin-renderer-spine38/lib/SpineSystem.ts +++ b/packages/plugin-renderer-spine38/lib/SpineSystem.ts @@ -1,14 +1,9 @@ -import {DisplayObject} from 'pixi.js'; -import {decorators, ComponentChanged, OBSERVER_TYPE} from '@eva/eva.js'; -import { - Renderer, - RendererSystem, - RendererManager, - ContainerManager, -} from '@eva/plugin-renderer'; +import { DisplayObject } from 'pixi.js'; +import { decorators, ComponentChanged, OBSERVER_TYPE } from '@eva/eva.js'; +import { Renderer, RendererSystem, RendererManager, ContainerManager } from '@eva/plugin-renderer'; import Spine from './Spine'; import pixispine from './pixi-spine.js'; -import getSpineData, {releaseSpineData} from './SpineData'; +import getSpineData, { releaseSpineData } from './SpineData'; const MaxRetryCount = 20; @decorators.componentObserver({ @@ -102,9 +97,7 @@ export default class SpineSystem extends Renderer { return; } this.remove(changed); - const container = this.renderSystem.containerManager.getContainer( - changed.gameObject.id, - ); + const container = this.renderSystem.containerManager.getContainer(changed.gameObject.id); if (!container) { // console.warn('添加spine的container不存在'); return; @@ -129,25 +122,25 @@ export default class SpineSystem extends Renderer { } } // @ts-ignore - component.emit('loaded', {resource: component.resource}); + component.emit('loaded', { resource: component.resource }); armature.state.addListener({ // @ts-ignore start: (track, event) => { - component.emit('start', {track, name: track.animation.name}); + component.emit('start', { track, name: track.animation.name }); }, // @ts-ignore complete: (track, event) => { - component.emit('complete', {track, name: track.animation.name}); + component.emit('complete', { track, name: track.animation.name }); }, // @ts-ignore interrupt: (track, event) => { - component.emit('interrupt', {track, name: track.animation.name}); + component.emit('interrupt', { track, name: track.animation.name }); }, end: ( track, // @ts-ignore event, ) => { - component.emit('end', {track, name: track.animation.name}); + component.emit('end', { track, name: track.animation.name }); }, event: (track, event) => { // @ts-ignore @@ -164,9 +157,7 @@ export default class SpineSystem extends Renderer { clearTimeout(component.addHandler); const armature = this.armatures[changed.gameObject.id]; - const container = this.renderSystem.containerManager.getContainer( - changed.gameObject.id, - ); + const container = this.renderSystem.containerManager.getContainer(changed.gameObject.id); if (container && armature) { container.removeChild(armature); } else { @@ -174,7 +165,7 @@ export default class SpineSystem extends Renderer { } if (component.armature) { - component.armature.destroy({children: true}); + component.armature.destroy({ children: true }); if (component.usingResource) { releaseSpineData(component.usingResource); diff --git a/packages/plugin-renderer-spine38/lib/TexCache.ts b/packages/plugin-renderer-spine38/lib/TexCache.ts index 6739aaed..526a6dfa 100644 --- a/packages/plugin-renderer-spine38/lib/TexCache.ts +++ b/packages/plugin-renderer-spine38/lib/TexCache.ts @@ -1,6 +1,6 @@ -import {Texture} from 'pixi.js'; +import { Texture } from 'pixi.js'; -let texCache: {[name: string]: {tex: Texture; count: number}} = {}; +let texCache: { [name: string]: { tex: Texture; count: number } } = {}; function cacheImage(data: any) { const oldImg = data.image; diff --git a/packages/plugin-renderer-spine38/lib/pixi-spine.js b/packages/plugin-renderer-spine38/lib/pixi-spine.js index 1eb27965..b3910d10 100644 --- a/packages/plugin-renderer-spine38/lib/pixi-spine.js +++ b/packages/plugin-renderer-spine38/lib/pixi-spine.js @@ -1,8945 +1,9092 @@ -import { - Texture, - Rectangle, - Sprite, - Graphics, - mesh, - Matrix, - Container, - SCALE_MODES, - utils, - loaders, - TransformBase, - TransformStatic, - DisplayObject, - Polygon, - BaseTexture, -} from 'pixi.js'; - -const VERSION = '4.8.9'; -const loader = loaders.shared; - -const PIXI = { - Texture, - Rectangle, - Sprite, - Graphics, - mesh, - Matrix, - Container, - VERSION, - loaders, - loader, - SCALE_MODES, - utils, - TransformBase, - TransformStatic, - DisplayObject, - Polygon, - BaseTexture, -}; - -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var Animation = (function () { - function Animation(name, timelines, duration) { - if (name == null) - throw new Error("name cannot be null."); - if (timelines == null) - throw new Error("timelines cannot be null."); - this.name = name; - this.timelines = timelines; - this.timelineIds = []; - for (var i = 0; i < timelines.length; i++) - this.timelineIds[timelines[i].getPropertyId()] = true; - this.duration = duration; - } - Animation.prototype.hasTimeline = function (id) { - return this.timelineIds[id] == true; - }; - Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, blend, direction) { - if (skeleton == null) - throw new Error("skeleton cannot be null."); - if (loop && this.duration != 0) { - time %= this.duration; - if (lastTime > 0) - lastTime %= this.duration; - } - var timelines = this.timelines; - for (var i = 0, n = timelines.length; i < n; i++) - timelines[i].apply(skeleton, lastTime, time, events, alpha, blend, direction); - }; - Animation.binarySearch = function (values, target, step) { - if (step === void 0) { step = 1; } - var low = 0; - var high = values.length / step - 2; - if (high == 0) - return step; - var current = high >>> 1; - while (true) { - if (values[(current + 1) * step] <= target) - low = current + 1; - else - high = current; - if (low == high) - return (low + 1) * step; - current = (low + high) >>> 1; - } - }; - Animation.linearSearch = function (values, target, step) { - for (var i = 0, last = values.length - step; i <= last; i += step) - if (values[i] > target) - return i; - return -1; - }; - return Animation; - }()); - core.Animation = Animation; - var MixBlend; - (function (MixBlend) { - MixBlend[MixBlend["setup"] = 0] = "setup"; - MixBlend[MixBlend["first"] = 1] = "first"; - MixBlend[MixBlend["replace"] = 2] = "replace"; - MixBlend[MixBlend["add"] = 3] = "add"; - })(MixBlend = core.MixBlend || (core.MixBlend = {})); - var MixDirection; - (function (MixDirection) { - MixDirection[MixDirection["mixIn"] = 0] = "mixIn"; - MixDirection[MixDirection["mixOut"] = 1] = "mixOut"; - })(MixDirection = core.MixDirection || (core.MixDirection = {})); - var TimelineType; - (function (TimelineType) { - TimelineType[TimelineType["rotate"] = 0] = "rotate"; - TimelineType[TimelineType["translate"] = 1] = "translate"; - TimelineType[TimelineType["scale"] = 2] = "scale"; - TimelineType[TimelineType["shear"] = 3] = "shear"; - TimelineType[TimelineType["attachment"] = 4] = "attachment"; - TimelineType[TimelineType["color"] = 5] = "color"; - TimelineType[TimelineType["deform"] = 6] = "deform"; - TimelineType[TimelineType["event"] = 7] = "event"; - TimelineType[TimelineType["drawOrder"] = 8] = "drawOrder"; - TimelineType[TimelineType["ikConstraint"] = 9] = "ikConstraint"; - TimelineType[TimelineType["transformConstraint"] = 10] = "transformConstraint"; - TimelineType[TimelineType["pathConstraintPosition"] = 11] = "pathConstraintPosition"; - TimelineType[TimelineType["pathConstraintSpacing"] = 12] = "pathConstraintSpacing"; - TimelineType[TimelineType["pathConstraintMix"] = 13] = "pathConstraintMix"; - TimelineType[TimelineType["twoColor"] = 14] = "twoColor"; - })(TimelineType = core.TimelineType || (core.TimelineType = {})); - var CurveTimeline = (function () { - function CurveTimeline(frameCount) { - if (frameCount <= 0) - throw new Error("frameCount must be > 0: " + frameCount); - this.curves = core.Utils.newFloatArray((frameCount - 1) * CurveTimeline.BEZIER_SIZE); - } - CurveTimeline.prototype.getFrameCount = function () { - return this.curves.length / CurveTimeline.BEZIER_SIZE + 1; - }; - CurveTimeline.prototype.setLinear = function (frameIndex) { - this.curves[frameIndex * CurveTimeline.BEZIER_SIZE] = CurveTimeline.LINEAR; - }; - CurveTimeline.prototype.setStepped = function (frameIndex) { - this.curves[frameIndex * CurveTimeline.BEZIER_SIZE] = CurveTimeline.STEPPED; - }; - CurveTimeline.prototype.getCurveType = function (frameIndex) { - var index = frameIndex * CurveTimeline.BEZIER_SIZE; - if (index == this.curves.length) - return CurveTimeline.LINEAR; - var type = this.curves[index]; - if (type == CurveTimeline.LINEAR) - return CurveTimeline.LINEAR; - if (type == CurveTimeline.STEPPED) - return CurveTimeline.STEPPED; - return CurveTimeline.BEZIER; - }; - CurveTimeline.prototype.setCurve = function (frameIndex, cx1, cy1, cx2, cy2) { - var tmpx = (-cx1 * 2 + cx2) * 0.03, tmpy = (-cy1 * 2 + cy2) * 0.03; - var dddfx = ((cx1 - cx2) * 3 + 1) * 0.006, dddfy = ((cy1 - cy2) * 3 + 1) * 0.006; - var ddfx = tmpx * 2 + dddfx, ddfy = tmpy * 2 + dddfy; - var dfx = cx1 * 0.3 + tmpx + dddfx * 0.16666667, dfy = cy1 * 0.3 + tmpy + dddfy * 0.16666667; - var i = frameIndex * CurveTimeline.BEZIER_SIZE; - var curves = this.curves; - curves[i++] = CurveTimeline.BEZIER; - var x = dfx, y = dfy; - for (var n = i + CurveTimeline.BEZIER_SIZE - 1; i < n; i += 2) { - curves[i] = x; - curves[i + 1] = y; - dfx += ddfx; - dfy += ddfy; - ddfx += dddfx; - ddfy += dddfy; - x += dfx; - y += dfy; - } - }; - CurveTimeline.prototype.getCurvePercent = function (frameIndex, percent) { - percent = core.MathUtils.clamp(percent, 0, 1); - var curves = this.curves; - var i = frameIndex * CurveTimeline.BEZIER_SIZE; - var type = curves[i]; - if (type == CurveTimeline.LINEAR) - return percent; - if (type == CurveTimeline.STEPPED) - return 0; - i++; - var x = 0; - for (var start = i, n = i + CurveTimeline.BEZIER_SIZE - 1; i < n; i += 2) { - x = curves[i]; - if (x >= percent) { - var prevX = void 0, prevY = void 0; - if (i == start) { - prevX = 0; - prevY = 0; - } - else { - prevX = curves[i - 2]; - prevY = curves[i - 1]; - } - return prevY + (curves[i + 1] - prevY) * (percent - prevX) / (x - prevX); - } - } - var y = curves[i - 1]; - return y + (1 - y) * (percent - x) / (1 - x); - }; - CurveTimeline.LINEAR = 0; - CurveTimeline.STEPPED = 1; - CurveTimeline.BEZIER = 2; - CurveTimeline.BEZIER_SIZE = 10 * 2 - 1; - return CurveTimeline; - }()); - core.CurveTimeline = CurveTimeline; - var RotateTimeline = (function (_super) { - __extends(RotateTimeline, _super); - function RotateTimeline(frameCount) { - var _this = _super.call(this, frameCount) || this; - _this.frames = core.Utils.newFloatArray(frameCount << 1); - return _this; - } - RotateTimeline.prototype.getPropertyId = function () { - return (TimelineType.rotate << 24) + this.boneIndex; - }; - RotateTimeline.prototype.setFrame = function (frameIndex, time, degrees) { - frameIndex <<= 1; - this.frames[frameIndex] = time; - this.frames[frameIndex + RotateTimeline.ROTATION] = degrees; - }; - RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) { - var frames = this.frames; - var bone = skeleton.bones[this.boneIndex]; - if (!bone.active) - return; - if (time < frames[0]) { - switch (blend) { - case MixBlend.setup: - bone.rotation = bone.data.rotation; - return; - case MixBlend.first: - var r_1 = bone.data.rotation - bone.rotation; - bone.rotation += (r_1 - (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360) * alpha; - } - return; - } - if (time >= frames[frames.length - RotateTimeline.ENTRIES]) { - var r_2 = frames[frames.length + RotateTimeline.PREV_ROTATION]; - switch (blend) { - case MixBlend.setup: - bone.rotation = bone.data.rotation + r_2 * alpha; - break; - case MixBlend.first: - case MixBlend.replace: - r_2 += bone.data.rotation - bone.rotation; - r_2 -= (16384 - ((16384.499999999996 - r_2 / 360) | 0)) * 360; - case MixBlend.add: - bone.rotation += r_2 * alpha; - } - return; - } - var frame = Animation.binarySearch(frames, time, RotateTimeline.ENTRIES); - var prevRotation = frames[frame + RotateTimeline.PREV_ROTATION]; - var frameTime = frames[frame]; - var percent = this.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + RotateTimeline.PREV_TIME] - frameTime)); - var r = frames[frame + RotateTimeline.ROTATION] - prevRotation; - r = prevRotation + (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * percent; - switch (blend) { - case MixBlend.setup: - bone.rotation = bone.data.rotation + (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * alpha; - break; - case MixBlend.first: - case MixBlend.replace: - r += bone.data.rotation - bone.rotation; - case MixBlend.add: - bone.rotation += (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * alpha; - } - }; - RotateTimeline.ENTRIES = 2; - RotateTimeline.PREV_TIME = -2; - RotateTimeline.PREV_ROTATION = -1; - RotateTimeline.ROTATION = 1; - return RotateTimeline; - }(CurveTimeline)); - core.RotateTimeline = RotateTimeline; - var TranslateTimeline = (function (_super) { - __extends(TranslateTimeline, _super); - function TranslateTimeline(frameCount) { - var _this = _super.call(this, frameCount) || this; - _this.frames = core.Utils.newFloatArray(frameCount * TranslateTimeline.ENTRIES); - return _this; - } - TranslateTimeline.prototype.getPropertyId = function () { - return (TimelineType.translate << 24) + this.boneIndex; - }; - TranslateTimeline.prototype.setFrame = function (frameIndex, time, x, y) { - frameIndex *= TranslateTimeline.ENTRIES; - this.frames[frameIndex] = time; - this.frames[frameIndex + TranslateTimeline.X] = x; - this.frames[frameIndex + TranslateTimeline.Y] = y; - }; - TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) { - var frames = this.frames; - var bone = skeleton.bones[this.boneIndex]; - if (!bone.active) - return; - if (time < frames[0]) { - switch (blend) { - case MixBlend.setup: - bone.x = bone.data.x; - bone.y = bone.data.y; - return; - case MixBlend.first: - bone.x += (bone.data.x - bone.x) * alpha; - bone.y += (bone.data.y - bone.y) * alpha; - } - return; - } - var x = 0, y = 0; - if (time >= frames[frames.length - TranslateTimeline.ENTRIES]) { - x = frames[frames.length + TranslateTimeline.PREV_X]; - y = frames[frames.length + TranslateTimeline.PREV_Y]; - } - else { - var frame = Animation.binarySearch(frames, time, TranslateTimeline.ENTRIES); - x = frames[frame + TranslateTimeline.PREV_X]; - y = frames[frame + TranslateTimeline.PREV_Y]; - var frameTime = frames[frame]; - var percent = this.getCurvePercent(frame / TranslateTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + TranslateTimeline.PREV_TIME] - frameTime)); - x += (frames[frame + TranslateTimeline.X] - x) * percent; - y += (frames[frame + TranslateTimeline.Y] - y) * percent; - } - switch (blend) { - case MixBlend.setup: - bone.x = bone.data.x + x * alpha; - bone.y = bone.data.y + y * alpha; - break; - case MixBlend.first: - case MixBlend.replace: - bone.x += (bone.data.x + x - bone.x) * alpha; - bone.y += (bone.data.y + y - bone.y) * alpha; - break; - case MixBlend.add: - bone.x += x * alpha; - bone.y += y * alpha; - } - }; - TranslateTimeline.ENTRIES = 3; - TranslateTimeline.PREV_TIME = -3; - TranslateTimeline.PREV_X = -2; - TranslateTimeline.PREV_Y = -1; - TranslateTimeline.X = 1; - TranslateTimeline.Y = 2; - return TranslateTimeline; - }(CurveTimeline)); - core.TranslateTimeline = TranslateTimeline; - var ScaleTimeline = (function (_super) { - __extends(ScaleTimeline, _super); - function ScaleTimeline(frameCount) { - return _super.call(this, frameCount) || this; - } - ScaleTimeline.prototype.getPropertyId = function () { - return (TimelineType.scale << 24) + this.boneIndex; - }; - ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) { - var frames = this.frames; - var bone = skeleton.bones[this.boneIndex]; - if (!bone.active) - return; - if (time < frames[0]) { - switch (blend) { - case MixBlend.setup: - bone.scaleX = bone.data.scaleX; - bone.scaleY = bone.data.scaleY; - return; - case MixBlend.first: - bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha; - bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha; - } - return; - } - var x = 0, y = 0; - if (time >= frames[frames.length - ScaleTimeline.ENTRIES]) { - x = frames[frames.length + ScaleTimeline.PREV_X] * bone.data.scaleX; - y = frames[frames.length + ScaleTimeline.PREV_Y] * bone.data.scaleY; - } - else { - var frame = Animation.binarySearch(frames, time, ScaleTimeline.ENTRIES); - x = frames[frame + ScaleTimeline.PREV_X]; - y = frames[frame + ScaleTimeline.PREV_Y]; - var frameTime = frames[frame]; - var percent = this.getCurvePercent(frame / ScaleTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + ScaleTimeline.PREV_TIME] - frameTime)); - x = (x + (frames[frame + ScaleTimeline.X] - x) * percent) * bone.data.scaleX; - y = (y + (frames[frame + ScaleTimeline.Y] - y) * percent) * bone.data.scaleY; - } - if (alpha == 1) { - if (blend == MixBlend.add) { - bone.scaleX += x - bone.data.scaleX; - bone.scaleY += y - bone.data.scaleY; - } - else { - bone.scaleX = x; - bone.scaleY = y; - } - } - else { - var bx = 0, by = 0; - if (direction == MixDirection.mixOut) { - switch (blend) { - case MixBlend.setup: - bx = bone.data.scaleX; - by = bone.data.scaleY; - bone.scaleX = bx + (Math.abs(x) * core.MathUtils.signum(bx) - bx) * alpha; - bone.scaleY = by + (Math.abs(y) * core.MathUtils.signum(by) - by) * alpha; - break; - case MixBlend.first: - case MixBlend.replace: - bx = bone.scaleX; - by = bone.scaleY; - bone.scaleX = bx + (Math.abs(x) * core.MathUtils.signum(bx) - bx) * alpha; - bone.scaleY = by + (Math.abs(y) * core.MathUtils.signum(by) - by) * alpha; - break; - case MixBlend.add: - bx = bone.scaleX; - by = bone.scaleY; - bone.scaleX = bx + (Math.abs(x) * core.MathUtils.signum(bx) - bone.data.scaleX) * alpha; - bone.scaleY = by + (Math.abs(y) * core.MathUtils.signum(by) - bone.data.scaleY) * alpha; - } - } - else { - switch (blend) { - case MixBlend.setup: - bx = Math.abs(bone.data.scaleX) * core.MathUtils.signum(x); - by = Math.abs(bone.data.scaleY) * core.MathUtils.signum(y); - bone.scaleX = bx + (x - bx) * alpha; - bone.scaleY = by + (y - by) * alpha; - break; - case MixBlend.first: - case MixBlend.replace: - bx = Math.abs(bone.scaleX) * core.MathUtils.signum(x); - by = Math.abs(bone.scaleY) * core.MathUtils.signum(y); - bone.scaleX = bx + (x - bx) * alpha; - bone.scaleY = by + (y - by) * alpha; - break; - case MixBlend.add: - bx = core.MathUtils.signum(x); - by = core.MathUtils.signum(y); - bone.scaleX = Math.abs(bone.scaleX) * bx + (x - Math.abs(bone.data.scaleX) * bx) * alpha; - bone.scaleY = Math.abs(bone.scaleY) * by + (y - Math.abs(bone.data.scaleY) * by) * alpha; - } - } - } - }; - return ScaleTimeline; - }(TranslateTimeline)); - core.ScaleTimeline = ScaleTimeline; - var ShearTimeline = (function (_super) { - __extends(ShearTimeline, _super); - function ShearTimeline(frameCount) { - return _super.call(this, frameCount) || this; - } - ShearTimeline.prototype.getPropertyId = function () { - return (TimelineType.shear << 24) + this.boneIndex; - }; - ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) { - var frames = this.frames; - var bone = skeleton.bones[this.boneIndex]; - if (!bone.active) - return; - if (time < frames[0]) { - switch (blend) { - case MixBlend.setup: - bone.shearX = bone.data.shearX; - bone.shearY = bone.data.shearY; - return; - case MixBlend.first: - bone.shearX += (bone.data.shearX - bone.shearX) * alpha; - bone.shearY += (bone.data.shearY - bone.shearY) * alpha; - } - return; - } - var x = 0, y = 0; - if (time >= frames[frames.length - ShearTimeline.ENTRIES]) { - x = frames[frames.length + ShearTimeline.PREV_X]; - y = frames[frames.length + ShearTimeline.PREV_Y]; - } - else { - var frame = Animation.binarySearch(frames, time, ShearTimeline.ENTRIES); - x = frames[frame + ShearTimeline.PREV_X]; - y = frames[frame + ShearTimeline.PREV_Y]; - var frameTime = frames[frame]; - var percent = this.getCurvePercent(frame / ShearTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + ShearTimeline.PREV_TIME] - frameTime)); - x = x + (frames[frame + ShearTimeline.X] - x) * percent; - y = y + (frames[frame + ShearTimeline.Y] - y) * percent; - } - switch (blend) { - case MixBlend.setup: - bone.shearX = bone.data.shearX + x * alpha; - bone.shearY = bone.data.shearY + y * alpha; - break; - case MixBlend.first: - case MixBlend.replace: - bone.shearX += (bone.data.shearX + x - bone.shearX) * alpha; - bone.shearY += (bone.data.shearY + y - bone.shearY) * alpha; - break; - case MixBlend.add: - bone.shearX += x * alpha; - bone.shearY += y * alpha; - } - }; - return ShearTimeline; - }(TranslateTimeline)); - core.ShearTimeline = ShearTimeline; - var ColorTimeline = (function (_super) { - __extends(ColorTimeline, _super); - function ColorTimeline(frameCount) { - var _this = _super.call(this, frameCount) || this; - _this.frames = core.Utils.newFloatArray(frameCount * ColorTimeline.ENTRIES); - return _this; - } - ColorTimeline.prototype.getPropertyId = function () { - return (TimelineType.color << 24) + this.slotIndex; - }; - ColorTimeline.prototype.setFrame = function (frameIndex, time, r, g, b, a) { - frameIndex *= ColorTimeline.ENTRIES; - this.frames[frameIndex] = time; - this.frames[frameIndex + ColorTimeline.R] = r; - this.frames[frameIndex + ColorTimeline.G] = g; - this.frames[frameIndex + ColorTimeline.B] = b; - this.frames[frameIndex + ColorTimeline.A] = a; - }; - ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) { - var slot = skeleton.slots[this.slotIndex]; - if (!slot.bone.active) - return; - var frames = this.frames; - if (time < frames[0]) { - switch (blend) { - case MixBlend.setup: - slot.color.setFromColor(slot.data.color); - return; - case MixBlend.first: - var color = slot.color, setup = slot.data.color; - color.add((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha, (setup.a - color.a) * alpha); - } - return; - } - var r = 0, g = 0, b = 0, a = 0; - if (time >= frames[frames.length - ColorTimeline.ENTRIES]) { - var i = frames.length; - r = frames[i + ColorTimeline.PREV_R]; - g = frames[i + ColorTimeline.PREV_G]; - b = frames[i + ColorTimeline.PREV_B]; - a = frames[i + ColorTimeline.PREV_A]; - } - else { - var frame = Animation.binarySearch(frames, time, ColorTimeline.ENTRIES); - r = frames[frame + ColorTimeline.PREV_R]; - g = frames[frame + ColorTimeline.PREV_G]; - b = frames[frame + ColorTimeline.PREV_B]; - a = frames[frame + ColorTimeline.PREV_A]; - var frameTime = frames[frame]; - var percent = this.getCurvePercent(frame / ColorTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + ColorTimeline.PREV_TIME] - frameTime)); - r += (frames[frame + ColorTimeline.R] - r) * percent; - g += (frames[frame + ColorTimeline.G] - g) * percent; - b += (frames[frame + ColorTimeline.B] - b) * percent; - a += (frames[frame + ColorTimeline.A] - a) * percent; - } - if (alpha == 1) - slot.color.set(r, g, b, a); - else { - var color = slot.color; - if (blend == MixBlend.setup) - color.setFromColor(slot.data.color); - color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha); - } - }; - ColorTimeline.ENTRIES = 5; - ColorTimeline.PREV_TIME = -5; - ColorTimeline.PREV_R = -4; - ColorTimeline.PREV_G = -3; - ColorTimeline.PREV_B = -2; - ColorTimeline.PREV_A = -1; - ColorTimeline.R = 1; - ColorTimeline.G = 2; - ColorTimeline.B = 3; - ColorTimeline.A = 4; - return ColorTimeline; - }(CurveTimeline)); - core.ColorTimeline = ColorTimeline; - var TwoColorTimeline = (function (_super) { - __extends(TwoColorTimeline, _super); - function TwoColorTimeline(frameCount) { - var _this = _super.call(this, frameCount) || this; - _this.frames = core.Utils.newFloatArray(frameCount * TwoColorTimeline.ENTRIES); - return _this; - } - TwoColorTimeline.prototype.getPropertyId = function () { - return (TimelineType.twoColor << 24) + this.slotIndex; - }; - TwoColorTimeline.prototype.setFrame = function (frameIndex, time, r, g, b, a, r2, g2, b2) { - frameIndex *= TwoColorTimeline.ENTRIES; - this.frames[frameIndex] = time; - this.frames[frameIndex + TwoColorTimeline.R] = r; - this.frames[frameIndex + TwoColorTimeline.G] = g; - this.frames[frameIndex + TwoColorTimeline.B] = b; - this.frames[frameIndex + TwoColorTimeline.A] = a; - this.frames[frameIndex + TwoColorTimeline.R2] = r2; - this.frames[frameIndex + TwoColorTimeline.G2] = g2; - this.frames[frameIndex + TwoColorTimeline.B2] = b2; - }; - TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) { - var slot = skeleton.slots[this.slotIndex]; - if (!slot.bone.active) - return; - var frames = this.frames; - if (time < frames[0]) { - switch (blend) { - case MixBlend.setup: - slot.color.setFromColor(slot.data.color); - slot.darkColor.setFromColor(slot.data.darkColor); - return; - case MixBlend.first: - var light = slot.color, dark = slot.darkColor, setupLight = slot.data.color, setupDark = slot.data.darkColor; - light.add((setupLight.r - light.r) * alpha, (setupLight.g - light.g) * alpha, (setupLight.b - light.b) * alpha, (setupLight.a - light.a) * alpha); - dark.add((setupDark.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, (setupDark.b - dark.b) * alpha, 0); - } - return; - } - var r = 0, g = 0, b = 0, a = 0, r2 = 0, g2 = 0, b2 = 0; - if (time >= frames[frames.length - TwoColorTimeline.ENTRIES]) { - var i = frames.length; - r = frames[i + TwoColorTimeline.PREV_R]; - g = frames[i + TwoColorTimeline.PREV_G]; - b = frames[i + TwoColorTimeline.PREV_B]; - a = frames[i + TwoColorTimeline.PREV_A]; - r2 = frames[i + TwoColorTimeline.PREV_R2]; - g2 = frames[i + TwoColorTimeline.PREV_G2]; - b2 = frames[i + TwoColorTimeline.PREV_B2]; - } - else { - var frame = Animation.binarySearch(frames, time, TwoColorTimeline.ENTRIES); - r = frames[frame + TwoColorTimeline.PREV_R]; - g = frames[frame + TwoColorTimeline.PREV_G]; - b = frames[frame + TwoColorTimeline.PREV_B]; - a = frames[frame + TwoColorTimeline.PREV_A]; - r2 = frames[frame + TwoColorTimeline.PREV_R2]; - g2 = frames[frame + TwoColorTimeline.PREV_G2]; - b2 = frames[frame + TwoColorTimeline.PREV_B2]; - var frameTime = frames[frame]; - var percent = this.getCurvePercent(frame / TwoColorTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + TwoColorTimeline.PREV_TIME] - frameTime)); - r += (frames[frame + TwoColorTimeline.R] - r) * percent; - g += (frames[frame + TwoColorTimeline.G] - g) * percent; - b += (frames[frame + TwoColorTimeline.B] - b) * percent; - a += (frames[frame + TwoColorTimeline.A] - a) * percent; - r2 += (frames[frame + TwoColorTimeline.R2] - r2) * percent; - g2 += (frames[frame + TwoColorTimeline.G2] - g2) * percent; - b2 += (frames[frame + TwoColorTimeline.B2] - b2) * percent; - } - if (alpha == 1) { - slot.color.set(r, g, b, a); - slot.darkColor.set(r2, g2, b2, 1); - } - else { - var light = slot.color, dark = slot.darkColor; - if (blend == MixBlend.setup) { - light.setFromColor(slot.data.color); - dark.setFromColor(slot.data.darkColor); - } - light.add((r - light.r) * alpha, (g - light.g) * alpha, (b - light.b) * alpha, (a - light.a) * alpha); - dark.add((r2 - dark.r) * alpha, (g2 - dark.g) * alpha, (b2 - dark.b) * alpha, 0); - } - }; - TwoColorTimeline.ENTRIES = 8; - TwoColorTimeline.PREV_TIME = -8; - TwoColorTimeline.PREV_R = -7; - TwoColorTimeline.PREV_G = -6; - TwoColorTimeline.PREV_B = -5; - TwoColorTimeline.PREV_A = -4; - TwoColorTimeline.PREV_R2 = -3; - TwoColorTimeline.PREV_G2 = -2; - TwoColorTimeline.PREV_B2 = -1; - TwoColorTimeline.R = 1; - TwoColorTimeline.G = 2; - TwoColorTimeline.B = 3; - TwoColorTimeline.A = 4; - TwoColorTimeline.R2 = 5; - TwoColorTimeline.G2 = 6; - TwoColorTimeline.B2 = 7; - return TwoColorTimeline; - }(CurveTimeline)); - core.TwoColorTimeline = TwoColorTimeline; - var AttachmentTimeline = (function () { - function AttachmentTimeline(frameCount) { - this.frames = core.Utils.newFloatArray(frameCount); - this.attachmentNames = new Array(frameCount); - } - AttachmentTimeline.prototype.getPropertyId = function () { - return (TimelineType.attachment << 24) + this.slotIndex; - }; - AttachmentTimeline.prototype.getFrameCount = function () { - return this.frames.length; - }; - AttachmentTimeline.prototype.setFrame = function (frameIndex, time, attachmentName) { - this.frames[frameIndex] = time; - this.attachmentNames[frameIndex] = attachmentName; - }; - AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) { - var slot = skeleton.slots[this.slotIndex]; - if (!slot.bone.active) - return; - if (direction == MixDirection.mixOut) { - if (blend == MixBlend.setup) - this.setAttachment(skeleton, slot, slot.data.attachmentName); - return; - } - var frames = this.frames; - if (time < frames[0]) { - if (blend == MixBlend.setup || blend == MixBlend.first) - this.setAttachment(skeleton, slot, slot.data.attachmentName); - return; - } - var frameIndex = 0; - if (time >= frames[frames.length - 1]) - frameIndex = frames.length - 1; - else - frameIndex = Animation.binarySearch(frames, time, 1) - 1; - var attachmentName = this.attachmentNames[frameIndex]; - skeleton.slots[this.slotIndex] - .setAttachment(attachmentName == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName)); - }; - AttachmentTimeline.prototype.setAttachment = function (skeleton, slot, attachmentName) { - slot.attachment = attachmentName == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName); - }; - return AttachmentTimeline; - }()); - core.AttachmentTimeline = AttachmentTimeline; - var zeros = null; - var DeformTimeline = (function (_super) { - __extends(DeformTimeline, _super); - function DeformTimeline(frameCount) { - var _this = _super.call(this, frameCount) || this; - _this.frames = core.Utils.newFloatArray(frameCount); - _this.frameVertices = new Array(frameCount); - if (zeros == null) - zeros = core.Utils.newFloatArray(64); - return _this; - } - DeformTimeline.prototype.getPropertyId = function () { - return (TimelineType.deform << 27) + +this.attachment.id + this.slotIndex; - }; - DeformTimeline.prototype.setFrame = function (frameIndex, time, vertices) { - this.frames[frameIndex] = time; - this.frameVertices[frameIndex] = vertices; - }; - DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) { - var slot = skeleton.slots[this.slotIndex]; - if (!slot.bone.active) - return; - var slotAttachment = slot.getAttachment(); - if (!(slotAttachment instanceof core.VertexAttachment) || !(slotAttachment.deformAttachment == this.attachment)) - return; - var deformArray = slot.deform; - if (deformArray.length == 0) - blend = MixBlend.setup; - var frameVertices = this.frameVertices; - var vertexCount = frameVertices[0].length; - var frames = this.frames; - if (time < frames[0]) { - var vertexAttachment = slotAttachment; - switch (blend) { - case MixBlend.setup: - deformArray.length = 0; - return; - case MixBlend.first: - if (alpha == 1) { - deformArray.length = 0; - break; - } - var deform_1 = core.Utils.setArraySize(deformArray, vertexCount); - if (vertexAttachment.bones == null) { - var setupVertices = vertexAttachment.vertices; - for (var i = 0; i < vertexCount; i++) - deform_1[i] += (setupVertices[i] - deform_1[i]) * alpha; - } - else { - alpha = 1 - alpha; - for (var i = 0; i < vertexCount; i++) - deform_1[i] *= alpha; - } - } - return; - } - var deform = core.Utils.setArraySize(deformArray, vertexCount); - if (time >= frames[frames.length - 1]) { - var lastVertices = frameVertices[frames.length - 1]; - if (alpha == 1) { - if (blend == MixBlend.add) { - var vertexAttachment = slotAttachment; - if (vertexAttachment.bones == null) { - var setupVertices = vertexAttachment.vertices; - for (var i_1 = 0; i_1 < vertexCount; i_1++) { - deform[i_1] += lastVertices[i_1] - setupVertices[i_1]; - } - } - else { - for (var i_2 = 0; i_2 < vertexCount; i_2++) - deform[i_2] += lastVertices[i_2]; - } - } - else { - core.Utils.arrayCopy(lastVertices, 0, deform, 0, vertexCount); - } - } - else { - switch (blend) { - case MixBlend.setup: { - var vertexAttachment_1 = slotAttachment; - if (vertexAttachment_1.bones == null) { - var setupVertices = vertexAttachment_1.vertices; - for (var i_3 = 0; i_3 < vertexCount; i_3++) { - var setup = setupVertices[i_3]; - deform[i_3] = setup + (lastVertices[i_3] - setup) * alpha; - } - } - else { - for (var i_4 = 0; i_4 < vertexCount; i_4++) - deform[i_4] = lastVertices[i_4] * alpha; - } - break; - } - case MixBlend.first: - case MixBlend.replace: - for (var i_5 = 0; i_5 < vertexCount; i_5++) - deform[i_5] += (lastVertices[i_5] - deform[i_5]) * alpha; - break; - case MixBlend.add: - var vertexAttachment = slotAttachment; - if (vertexAttachment.bones == null) { - var setupVertices = vertexAttachment.vertices; - for (var i_6 = 0; i_6 < vertexCount; i_6++) { - deform[i_6] += (lastVertices[i_6] - setupVertices[i_6]) * alpha; - } - } - else { - for (var i_7 = 0; i_7 < vertexCount; i_7++) - deform[i_7] += lastVertices[i_7] * alpha; - } - } - } - return; - } - var frame = Animation.binarySearch(frames, time); - var prevVertices = frameVertices[frame - 1]; - var nextVertices = frameVertices[frame]; - var frameTime = frames[frame]; - var percent = this.getCurvePercent(frame - 1, 1 - (time - frameTime) / (frames[frame - 1] - frameTime)); - if (alpha == 1) { - if (blend == MixBlend.add) { - var vertexAttachment = slotAttachment; - if (vertexAttachment.bones == null) { - var setupVertices = vertexAttachment.vertices; - for (var i_8 = 0; i_8 < vertexCount; i_8++) { - var prev = prevVertices[i_8]; - deform[i_8] += prev + (nextVertices[i_8] - prev) * percent - setupVertices[i_8]; - } - } - else { - for (var i_9 = 0; i_9 < vertexCount; i_9++) { - var prev = prevVertices[i_9]; - deform[i_9] += prev + (nextVertices[i_9] - prev) * percent; - } - } - } - else { - for (var i_10 = 0; i_10 < vertexCount; i_10++) { - var prev = prevVertices[i_10]; - deform[i_10] = prev + (nextVertices[i_10] - prev) * percent; - } - } - } - else { - switch (blend) { - case MixBlend.setup: { - var vertexAttachment_2 = slotAttachment; - if (vertexAttachment_2.bones == null) { - var setupVertices = vertexAttachment_2.vertices; - for (var i_11 = 0; i_11 < vertexCount; i_11++) { - var prev = prevVertices[i_11], setup = setupVertices[i_11]; - deform[i_11] = setup + (prev + (nextVertices[i_11] - prev) * percent - setup) * alpha; - } - } - else { - for (var i_12 = 0; i_12 < vertexCount; i_12++) { - var prev = prevVertices[i_12]; - deform[i_12] = (prev + (nextVertices[i_12] - prev) * percent) * alpha; - } - } - break; - } - case MixBlend.first: - case MixBlend.replace: - for (var i_13 = 0; i_13 < vertexCount; i_13++) { - var prev = prevVertices[i_13]; - deform[i_13] += (prev + (nextVertices[i_13] - prev) * percent - deform[i_13]) * alpha; - } - break; - case MixBlend.add: - var vertexAttachment = slotAttachment; - if (vertexAttachment.bones == null) { - var setupVertices = vertexAttachment.vertices; - for (var i_14 = 0; i_14 < vertexCount; i_14++) { - var prev = prevVertices[i_14]; - deform[i_14] += (prev + (nextVertices[i_14] - prev) * percent - setupVertices[i_14]) * alpha; - } - } - else { - for (var i_15 = 0; i_15 < vertexCount; i_15++) { - var prev = prevVertices[i_15]; - deform[i_15] += (prev + (nextVertices[i_15] - prev) * percent) * alpha; - } - } - } - } - }; - return DeformTimeline; - }(CurveTimeline)); - core.DeformTimeline = DeformTimeline; - var EventTimeline = (function () { - function EventTimeline(frameCount) { - this.frames = core.Utils.newFloatArray(frameCount); - this.events = new Array(frameCount); - } - EventTimeline.prototype.getPropertyId = function () { - return TimelineType.event << 24; - }; - EventTimeline.prototype.getFrameCount = function () { - return this.frames.length; - }; - EventTimeline.prototype.setFrame = function (frameIndex, event) { - this.frames[frameIndex] = event.time; - this.events[frameIndex] = event; - }; - EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) { - if (firedEvents == null) - return; - var frames = this.frames; - var frameCount = this.frames.length; - if (lastTime > time) { - this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, blend, direction); - lastTime = -1; - } - else if (lastTime >= frames[frameCount - 1]) - return; - if (time < frames[0]) - return; - var frame = 0; - if (lastTime < frames[0]) - frame = 0; - else { - frame = Animation.binarySearch(frames, lastTime); - var frameTime = frames[frame]; - while (frame > 0) { - if (frames[frame - 1] != frameTime) - break; - frame--; - } - } - for (; frame < frameCount && time >= frames[frame]; frame++) - firedEvents.push(this.events[frame]); - }; - return EventTimeline; - }()); - core.EventTimeline = EventTimeline; - var DrawOrderTimeline = (function () { - function DrawOrderTimeline(frameCount) { - this.frames = core.Utils.newFloatArray(frameCount); - this.drawOrders = new Array(frameCount); - } - DrawOrderTimeline.prototype.getPropertyId = function () { - return TimelineType.drawOrder << 24; - }; - DrawOrderTimeline.prototype.getFrameCount = function () { - return this.frames.length; - }; - DrawOrderTimeline.prototype.setFrame = function (frameIndex, time, drawOrder) { - this.frames[frameIndex] = time; - this.drawOrders[frameIndex] = drawOrder; - }; - DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) { - var drawOrder = skeleton.drawOrder; - var slots = skeleton.slots; - if (direction == MixDirection.mixOut && blend == MixBlend.setup) { - core.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length); - return; - } - var frames = this.frames; - if (time < frames[0]) { - if (blend == MixBlend.setup || blend == MixBlend.first) - core.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length); - return; - } - var frame = 0; - if (time >= frames[frames.length - 1]) - frame = frames.length - 1; - else - frame = Animation.binarySearch(frames, time) - 1; - var drawOrderToSetupIndex = this.drawOrders[frame]; - if (drawOrderToSetupIndex == null) - core.Utils.arrayCopy(slots, 0, drawOrder, 0, slots.length); - else { - for (var i = 0, n = drawOrderToSetupIndex.length; i < n; i++) - drawOrder[i] = slots[drawOrderToSetupIndex[i]]; - } - }; - return DrawOrderTimeline; - }()); - core.DrawOrderTimeline = DrawOrderTimeline; - var IkConstraintTimeline = (function (_super) { - __extends(IkConstraintTimeline, _super); - function IkConstraintTimeline(frameCount) { - var _this = _super.call(this, frameCount) || this; - _this.frames = core.Utils.newFloatArray(frameCount * IkConstraintTimeline.ENTRIES); - return _this; - } - IkConstraintTimeline.prototype.getPropertyId = function () { - return (TimelineType.ikConstraint << 24) + this.ikConstraintIndex; - }; - IkConstraintTimeline.prototype.setFrame = function (frameIndex, time, mix, softness, bendDirection, compress, stretch) { - frameIndex *= IkConstraintTimeline.ENTRIES; - this.frames[frameIndex] = time; - this.frames[frameIndex + IkConstraintTimeline.MIX] = mix; - this.frames[frameIndex + IkConstraintTimeline.SOFTNESS] = softness; - this.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection; - this.frames[frameIndex + IkConstraintTimeline.COMPRESS] = compress ? 1 : 0; - this.frames[frameIndex + IkConstraintTimeline.STRETCH] = stretch ? 1 : 0; - }; - IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) { - var frames = this.frames; - var constraint = skeleton.ikConstraints[this.ikConstraintIndex]; - if (!constraint.active) - return; - if (time < frames[0]) { - switch (blend) { - case MixBlend.setup: - constraint.mix = constraint.data.mix; - constraint.softness = constraint.data.softness; - constraint.bendDirection = constraint.data.bendDirection; - constraint.compress = constraint.data.compress; - constraint.stretch = constraint.data.stretch; - return; - case MixBlend.first: - constraint.mix += (constraint.data.mix - constraint.mix) * alpha; - constraint.softness += (constraint.data.softness - constraint.softness) * alpha; - constraint.bendDirection = constraint.data.bendDirection; - constraint.compress = constraint.data.compress; - constraint.stretch = constraint.data.stretch; - } - return; - } - if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) { - if (blend == MixBlend.setup) { - constraint.mix = constraint.data.mix + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha; - constraint.softness = constraint.data.softness - + (frames[frames.length + IkConstraintTimeline.PREV_SOFTNESS] - constraint.data.softness) * alpha; - if (direction == MixDirection.mixOut) { - constraint.bendDirection = constraint.data.bendDirection; - constraint.compress = constraint.data.compress; - constraint.stretch = constraint.data.stretch; - } - else { - constraint.bendDirection = frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION]; - constraint.compress = frames[frames.length + IkConstraintTimeline.PREV_COMPRESS] != 0; - constraint.stretch = frames[frames.length + IkConstraintTimeline.PREV_STRETCH] != 0; - } - } - else { - constraint.mix += (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.mix) * alpha; - constraint.softness += (frames[frames.length + IkConstraintTimeline.PREV_SOFTNESS] - constraint.softness) * alpha; - if (direction == MixDirection.mixIn) { - constraint.bendDirection = frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION]; - constraint.compress = frames[frames.length + IkConstraintTimeline.PREV_COMPRESS] != 0; - constraint.stretch = frames[frames.length + IkConstraintTimeline.PREV_STRETCH] != 0; - } - } - return; - } - var frame = Animation.binarySearch(frames, time, IkConstraintTimeline.ENTRIES); - var mix = frames[frame + IkConstraintTimeline.PREV_MIX]; - var softness = frames[frame + IkConstraintTimeline.PREV_SOFTNESS]; - var frameTime = frames[frame]; - var percent = this.getCurvePercent(frame / IkConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime)); - if (blend == MixBlend.setup) { - constraint.mix = constraint.data.mix + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha; - constraint.softness = constraint.data.softness - + (softness + (frames[frame + IkConstraintTimeline.SOFTNESS] - softness) * percent - constraint.data.softness) * alpha; - if (direction == MixDirection.mixOut) { - constraint.bendDirection = constraint.data.bendDirection; - constraint.compress = constraint.data.compress; - constraint.stretch = constraint.data.stretch; - } - else { - constraint.bendDirection = frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION]; - constraint.compress = frames[frame + IkConstraintTimeline.PREV_COMPRESS] != 0; - constraint.stretch = frames[frame + IkConstraintTimeline.PREV_STRETCH] != 0; - } - } - else { - constraint.mix += (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.mix) * alpha; - constraint.softness += (softness + (frames[frame + IkConstraintTimeline.SOFTNESS] - softness) * percent - constraint.softness) * alpha; - if (direction == MixDirection.mixIn) { - constraint.bendDirection = frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION]; - constraint.compress = frames[frame + IkConstraintTimeline.PREV_COMPRESS] != 0; - constraint.stretch = frames[frame + IkConstraintTimeline.PREV_STRETCH] != 0; - } - } - }; - IkConstraintTimeline.ENTRIES = 6; - IkConstraintTimeline.PREV_TIME = -6; - IkConstraintTimeline.PREV_MIX = -5; - IkConstraintTimeline.PREV_SOFTNESS = -4; - IkConstraintTimeline.PREV_BEND_DIRECTION = -3; - IkConstraintTimeline.PREV_COMPRESS = -2; - IkConstraintTimeline.PREV_STRETCH = -1; - IkConstraintTimeline.MIX = 1; - IkConstraintTimeline.SOFTNESS = 2; - IkConstraintTimeline.BEND_DIRECTION = 3; - IkConstraintTimeline.COMPRESS = 4; - IkConstraintTimeline.STRETCH = 5; - return IkConstraintTimeline; - }(CurveTimeline)); - core.IkConstraintTimeline = IkConstraintTimeline; - var TransformConstraintTimeline = (function (_super) { - __extends(TransformConstraintTimeline, _super); - function TransformConstraintTimeline(frameCount) { - var _this = _super.call(this, frameCount) || this; - _this.frames = core.Utils.newFloatArray(frameCount * TransformConstraintTimeline.ENTRIES); - return _this; - } - TransformConstraintTimeline.prototype.getPropertyId = function () { - return (TimelineType.transformConstraint << 24) + this.transformConstraintIndex; - }; - TransformConstraintTimeline.prototype.setFrame = function (frameIndex, time, rotateMix, translateMix, scaleMix, shearMix) { - frameIndex *= TransformConstraintTimeline.ENTRIES; - this.frames[frameIndex] = time; - this.frames[frameIndex + TransformConstraintTimeline.ROTATE] = rotateMix; - this.frames[frameIndex + TransformConstraintTimeline.TRANSLATE] = translateMix; - this.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix; - this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix; - }; - TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) { - var frames = this.frames; - var constraint = skeleton.transformConstraints[this.transformConstraintIndex]; - if (!constraint.active) - return; - if (time < frames[0]) { - var data = constraint.data; - switch (blend) { - case MixBlend.setup: - constraint.rotateMix = data.rotateMix; - constraint.translateMix = data.translateMix; - constraint.scaleMix = data.scaleMix; - constraint.shearMix = data.shearMix; - return; - case MixBlend.first: - constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha; - constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha; - constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha; - constraint.shearMix += (data.shearMix - constraint.shearMix) * alpha; - } - return; - } - var rotate = 0, translate = 0, scale = 0, shear = 0; - if (time >= frames[frames.length - TransformConstraintTimeline.ENTRIES]) { - var i = frames.length; - rotate = frames[i + TransformConstraintTimeline.PREV_ROTATE]; - translate = frames[i + TransformConstraintTimeline.PREV_TRANSLATE]; - scale = frames[i + TransformConstraintTimeline.PREV_SCALE]; - shear = frames[i + TransformConstraintTimeline.PREV_SHEAR]; - } - else { - var frame = Animation.binarySearch(frames, time, TransformConstraintTimeline.ENTRIES); - rotate = frames[frame + TransformConstraintTimeline.PREV_ROTATE]; - translate = frames[frame + TransformConstraintTimeline.PREV_TRANSLATE]; - scale = frames[frame + TransformConstraintTimeline.PREV_SCALE]; - shear = frames[frame + TransformConstraintTimeline.PREV_SHEAR]; - var frameTime = frames[frame]; - var percent = this.getCurvePercent(frame / TransformConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + TransformConstraintTimeline.PREV_TIME] - frameTime)); - rotate += (frames[frame + TransformConstraintTimeline.ROTATE] - rotate) * percent; - translate += (frames[frame + TransformConstraintTimeline.TRANSLATE] - translate) * percent; - scale += (frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent; - shear += (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent; - } - if (blend == MixBlend.setup) { - var data = constraint.data; - constraint.rotateMix = data.rotateMix + (rotate - data.rotateMix) * alpha; - constraint.translateMix = data.translateMix + (translate - data.translateMix) * alpha; - constraint.scaleMix = data.scaleMix + (scale - data.scaleMix) * alpha; - constraint.shearMix = data.shearMix + (shear - data.shearMix) * alpha; - } - else { - constraint.rotateMix += (rotate - constraint.rotateMix) * alpha; - constraint.translateMix += (translate - constraint.translateMix) * alpha; - constraint.scaleMix += (scale - constraint.scaleMix) * alpha; - constraint.shearMix += (shear - constraint.shearMix) * alpha; - } - }; - TransformConstraintTimeline.ENTRIES = 5; - TransformConstraintTimeline.PREV_TIME = -5; - TransformConstraintTimeline.PREV_ROTATE = -4; - TransformConstraintTimeline.PREV_TRANSLATE = -3; - TransformConstraintTimeline.PREV_SCALE = -2; - TransformConstraintTimeline.PREV_SHEAR = -1; - TransformConstraintTimeline.ROTATE = 1; - TransformConstraintTimeline.TRANSLATE = 2; - TransformConstraintTimeline.SCALE = 3; - TransformConstraintTimeline.SHEAR = 4; - return TransformConstraintTimeline; - }(CurveTimeline)); - core.TransformConstraintTimeline = TransformConstraintTimeline; - var PathConstraintPositionTimeline = (function (_super) { - __extends(PathConstraintPositionTimeline, _super); - function PathConstraintPositionTimeline(frameCount) { - var _this = _super.call(this, frameCount) || this; - _this.frames = core.Utils.newFloatArray(frameCount * PathConstraintPositionTimeline.ENTRIES); - return _this; - } - PathConstraintPositionTimeline.prototype.getPropertyId = function () { - return (TimelineType.pathConstraintPosition << 24) + this.pathConstraintIndex; - }; - PathConstraintPositionTimeline.prototype.setFrame = function (frameIndex, time, value) { - frameIndex *= PathConstraintPositionTimeline.ENTRIES; - this.frames[frameIndex] = time; - this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value; - }; - PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) { - var frames = this.frames; - var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; - if (!constraint.active) - return; - if (time < frames[0]) { - switch (blend) { - case MixBlend.setup: - constraint.position = constraint.data.position; - return; - case MixBlend.first: - constraint.position += (constraint.data.position - constraint.position) * alpha; - } - return; - } - var position = 0; - if (time >= frames[frames.length - PathConstraintPositionTimeline.ENTRIES]) - position = frames[frames.length + PathConstraintPositionTimeline.PREV_VALUE]; - else { - var frame = Animation.binarySearch(frames, time, PathConstraintPositionTimeline.ENTRIES); - position = frames[frame + PathConstraintPositionTimeline.PREV_VALUE]; - var frameTime = frames[frame]; - var percent = this.getCurvePercent(frame / PathConstraintPositionTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintPositionTimeline.PREV_TIME] - frameTime)); - position += (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * percent; - } - if (blend == MixBlend.setup) - constraint.position = constraint.data.position + (position - constraint.data.position) * alpha; - else - constraint.position += (position - constraint.position) * alpha; - }; - PathConstraintPositionTimeline.ENTRIES = 2; - PathConstraintPositionTimeline.PREV_TIME = -2; - PathConstraintPositionTimeline.PREV_VALUE = -1; - PathConstraintPositionTimeline.VALUE = 1; - return PathConstraintPositionTimeline; - }(CurveTimeline)); - core.PathConstraintPositionTimeline = PathConstraintPositionTimeline; - var PathConstraintSpacingTimeline = (function (_super) { - __extends(PathConstraintSpacingTimeline, _super); - function PathConstraintSpacingTimeline(frameCount) { - return _super.call(this, frameCount) || this; - } - PathConstraintSpacingTimeline.prototype.getPropertyId = function () { - return (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex; - }; - PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) { - var frames = this.frames; - var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; - if (!constraint.active) - return; - if (time < frames[0]) { - switch (blend) { - case MixBlend.setup: - constraint.spacing = constraint.data.spacing; - return; - case MixBlend.first: - constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha; - } - return; - } - var spacing = 0; - if (time >= frames[frames.length - PathConstraintSpacingTimeline.ENTRIES]) - spacing = frames[frames.length + PathConstraintSpacingTimeline.PREV_VALUE]; - else { - var frame = Animation.binarySearch(frames, time, PathConstraintSpacingTimeline.ENTRIES); - spacing = frames[frame + PathConstraintSpacingTimeline.PREV_VALUE]; - var frameTime = frames[frame]; - var percent = this.getCurvePercent(frame / PathConstraintSpacingTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintSpacingTimeline.PREV_TIME] - frameTime)); - spacing += (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * percent; - } - if (blend == MixBlend.setup) - constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha; - else - constraint.spacing += (spacing - constraint.spacing) * alpha; - }; - return PathConstraintSpacingTimeline; - }(PathConstraintPositionTimeline)); - core.PathConstraintSpacingTimeline = PathConstraintSpacingTimeline; - var PathConstraintMixTimeline = (function (_super) { - __extends(PathConstraintMixTimeline, _super); - function PathConstraintMixTimeline(frameCount) { - var _this = _super.call(this, frameCount) || this; - _this.frames = core.Utils.newFloatArray(frameCount * PathConstraintMixTimeline.ENTRIES); - return _this; - } - PathConstraintMixTimeline.prototype.getPropertyId = function () { - return (TimelineType.pathConstraintMix << 24) + this.pathConstraintIndex; - }; - PathConstraintMixTimeline.prototype.setFrame = function (frameIndex, time, rotateMix, translateMix) { - frameIndex *= PathConstraintMixTimeline.ENTRIES; - this.frames[frameIndex] = time; - this.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix; - this.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix; - }; - PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) { - var frames = this.frames; - var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; - if (!constraint.active) - return; - if (time < frames[0]) { - switch (blend) { - case MixBlend.setup: - constraint.rotateMix = constraint.data.rotateMix; - constraint.translateMix = constraint.data.translateMix; - return; - case MixBlend.first: - constraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha; - constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha; - } - return; - } - var rotate = 0, translate = 0; - if (time >= frames[frames.length - PathConstraintMixTimeline.ENTRIES]) { - rotate = frames[frames.length + PathConstraintMixTimeline.PREV_ROTATE]; - translate = frames[frames.length + PathConstraintMixTimeline.PREV_TRANSLATE]; - } - else { - var frame = Animation.binarySearch(frames, time, PathConstraintMixTimeline.ENTRIES); - rotate = frames[frame + PathConstraintMixTimeline.PREV_ROTATE]; - translate = frames[frame + PathConstraintMixTimeline.PREV_TRANSLATE]; - var frameTime = frames[frame]; - var percent = this.getCurvePercent(frame / PathConstraintMixTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintMixTimeline.PREV_TIME] - frameTime)); - rotate += (frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * percent; - translate += (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * percent; - } - if (blend == MixBlend.setup) { - constraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha; - constraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha; - } - else { - constraint.rotateMix += (rotate - constraint.rotateMix) * alpha; - constraint.translateMix += (translate - constraint.translateMix) * alpha; - } - }; - PathConstraintMixTimeline.ENTRIES = 3; - PathConstraintMixTimeline.PREV_TIME = -3; - PathConstraintMixTimeline.PREV_ROTATE = -2; - PathConstraintMixTimeline.PREV_TRANSLATE = -1; - PathConstraintMixTimeline.ROTATE = 1; - PathConstraintMixTimeline.TRANSLATE = 2; - return PathConstraintMixTimeline; - }(CurveTimeline)); - core.PathConstraintMixTimeline = PathConstraintMixTimeline; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var AnimationState = (function () { - function AnimationState(data) { - this.tracks = new Array(); - this.timeScale = 1; - this.unkeyedState = 0; - this.events = new Array(); - this.listeners = new Array(); - this.queue = new EventQueue(this); - this.propertyIDs = new core.IntSet(); - this.animationsChanged = false; - this.trackEntryPool = new core.Pool(function () { return new TrackEntry(); }); - this.data = data; - } - AnimationState.prototype.update = function (delta) { - delta *= this.timeScale; - var tracks = this.tracks; - for (var i = 0, n = tracks.length; i < n; i++) { - var current = tracks[i]; - if (current == null) - continue; - current.animationLast = current.nextAnimationLast; - current.trackLast = current.nextTrackLast; - var currentDelta = delta * current.timeScale; - if (current.delay > 0) { - current.delay -= currentDelta; - if (current.delay > 0) - continue; - currentDelta = -current.delay; - current.delay = 0; - } - var next = current.next; - if (next != null) { - var nextTime = current.trackLast - next.delay; - if (nextTime >= 0) { - next.delay = 0; - next.trackTime += current.timeScale == 0 ? 0 : (nextTime / current.timeScale + delta) * next.timeScale; - current.trackTime += currentDelta; - this.setCurrent(i, next, true); - while (next.mixingFrom != null) { - next.mixTime += delta; - next = next.mixingFrom; - } - continue; - } - } - else if (current.trackLast >= current.trackEnd && current.mixingFrom == null) { - tracks[i] = null; - this.queue.end(current); - this.disposeNext(current); - continue; - } - if (current.mixingFrom != null && this.updateMixingFrom(current, delta)) { - var from = current.mixingFrom; - current.mixingFrom = null; - if (from != null) - from.mixingTo = null; - while (from != null) { - this.queue.end(from); - from = from.mixingFrom; - } - } - current.trackTime += currentDelta; - } - this.queue.drain(); - }; - AnimationState.prototype.updateMixingFrom = function (to, delta) { - var from = to.mixingFrom; - if (from == null) - return true; - var finished = this.updateMixingFrom(from, delta); - from.animationLast = from.nextAnimationLast; - from.trackLast = from.nextTrackLast; - if (to.mixTime > 0 && to.mixTime >= to.mixDuration) { - if (from.totalAlpha == 0 || to.mixDuration == 0) { - to.mixingFrom = from.mixingFrom; - if (from.mixingFrom != null) - from.mixingFrom.mixingTo = to; - to.interruptAlpha = from.interruptAlpha; - this.queue.end(from); - } - return finished; - } - from.trackTime += delta * from.timeScale; - to.mixTime += delta; - return false; - }; - AnimationState.prototype.apply = function (skeleton) { - if (skeleton == null) - throw new Error("skeleton cannot be null."); - if (this.animationsChanged) - this._animationsChanged(); - var events = this.events; - var tracks = this.tracks; - var applied = false; - for (var i_16 = 0, n_1 = tracks.length; i_16 < n_1; i_16++) { - var current = tracks[i_16]; - if (current == null || current.delay > 0) - continue; - applied = true; - var blend = i_16 == 0 ? core.MixBlend.first : current.mixBlend; - var mix = current.alpha; - if (current.mixingFrom != null) - mix *= this.applyMixingFrom(current, skeleton, blend); - else if (current.trackTime >= current.trackEnd && current.next == null) - mix = 0; - var animationLast = current.animationLast, animationTime = current.getAnimationTime(); - var timelineCount = current.animation.timelines.length; - var timelines = current.animation.timelines; - if ((i_16 == 0 && mix == 1) || blend == core.MixBlend.add) { - for (var ii = 0; ii < timelineCount; ii++) { - core.Utils.webkit602BugfixHelper(mix, blend); - var timeline = timelines[ii]; - if (timeline instanceof core.AttachmentTimeline) - this.applyAttachmentTimeline(timeline, skeleton, animationTime, blend, true); - else - timeline.apply(skeleton, animationLast, animationTime, events, mix, blend, core.MixDirection.mixIn); - } - } - else { - var timelineMode = current.timelineMode; - var firstFrame = current.timelinesRotation.length == 0; - if (firstFrame) - core.Utils.setArraySize(current.timelinesRotation, timelineCount << 1, null); - var timelinesRotation = current.timelinesRotation; - for (var ii = 0; ii < timelineCount; ii++) { - var timeline_1 = timelines[ii]; - var timelineBlend = timelineMode[ii] == AnimationState.SUBSEQUENT ? blend : core.MixBlend.setup; - if (timeline_1 instanceof core.RotateTimeline) { - this.applyRotateTimeline(timeline_1, skeleton, animationTime, mix, timelineBlend, timelinesRotation, ii << 1, firstFrame); - } - else if (timeline_1 instanceof core.AttachmentTimeline) { - this.applyAttachmentTimeline(timeline_1, skeleton, animationTime, blend, true); - } - else { - core.Utils.webkit602BugfixHelper(mix, blend); - timeline_1.apply(skeleton, animationLast, animationTime, events, mix, timelineBlend, core.MixDirection.mixIn); - } - } - } - this.queueEvents(current, animationTime); - events.length = 0; - current.nextAnimationLast = animationTime; - current.nextTrackLast = current.trackTime; - } - var setupState = this.unkeyedState + AnimationState.SETUP; - var slots = skeleton.slots; - for (var i = 0, n = skeleton.slots.length; i < n; i++) { - var slot = slots[i]; - if (slot.attachmentState == setupState) { - var attachmentName = slot.data.attachmentName; - slot.attachment = (attachmentName == null ? null : skeleton.getAttachment(slot.data.index, attachmentName)); - } - } - this.unkeyedState += 2; - this.queue.drain(); - return applied; - }; - AnimationState.prototype.applyMixingFrom = function (to, skeleton, blend) { - var from = to.mixingFrom; - if (from.mixingFrom != null) - this.applyMixingFrom(from, skeleton, blend); - var mix = 0; - if (to.mixDuration == 0) { - mix = 1; - if (blend == core.MixBlend.first) - blend = core.MixBlend.setup; - } - else { - mix = to.mixTime / to.mixDuration; - if (mix > 1) - mix = 1; - if (blend != core.MixBlend.first) - blend = from.mixBlend; - } - var events = mix < from.eventThreshold ? this.events : null; - var attachments = mix < from.attachmentThreshold, drawOrder = mix < from.drawOrderThreshold; - var animationLast = from.animationLast, animationTime = from.getAnimationTime(); - var timelineCount = from.animation.timelines.length; - var timelines = from.animation.timelines; - var alphaHold = from.alpha * to.interruptAlpha, alphaMix = alphaHold * (1 - mix); - if (blend == core.MixBlend.add) { - for (var i = 0; i < timelineCount; i++) - timelines[i].apply(skeleton, animationLast, animationTime, events, alphaMix, blend, core.MixDirection.mixOut); - } - else { - var timelineMode = from.timelineMode; - var timelineHoldMix = from.timelineHoldMix; - var firstFrame = from.timelinesRotation.length == 0; - if (firstFrame) - core.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null); - var timelinesRotation = from.timelinesRotation; - from.totalAlpha = 0; - for (var i = 0; i < timelineCount; i++) { - var timeline = timelines[i]; - var direction = core.MixDirection.mixOut; - var timelineBlend = void 0; - var alpha = 0; - switch (timelineMode[i]) { - case AnimationState.SUBSEQUENT: - if (!drawOrder && timeline instanceof core.DrawOrderTimeline) - continue; - timelineBlend = blend; - alpha = alphaMix; - break; - case AnimationState.FIRST: - timelineBlend = core.MixBlend.setup; - alpha = alphaMix; - break; - case AnimationState.HOLD_SUBSEQUENT: - timelineBlend = blend; - alpha = alphaHold; - break; - case AnimationState.HOLD_FIRST: - timelineBlend = core.MixBlend.setup; - alpha = alphaHold; - break; - default: - timelineBlend = core.MixBlend.setup; - var holdMix = timelineHoldMix[i]; - alpha = alphaHold * Math.max(0, 1 - holdMix.mixTime / holdMix.mixDuration); - break; - } - from.totalAlpha += alpha; - if (timeline instanceof core.RotateTimeline) - this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, timelineBlend, timelinesRotation, i << 1, firstFrame); - else if (timeline instanceof core.AttachmentTimeline) - this.applyAttachmentTimeline(timeline, skeleton, animationTime, timelineBlend, attachments); - else { - core.Utils.webkit602BugfixHelper(alpha, blend); - if (drawOrder && timeline instanceof core.DrawOrderTimeline && timelineBlend == core.MixBlend.setup) - direction = core.MixDirection.mixIn; - timeline.apply(skeleton, animationLast, animationTime, events, alpha, timelineBlend, direction); - } - } - } - if (to.mixDuration > 0) - this.queueEvents(from, animationTime); - this.events.length = 0; - from.nextAnimationLast = animationTime; - from.nextTrackLast = from.trackTime; - return mix; - }; - AnimationState.prototype.applyAttachmentTimeline = function (timeline, skeleton, time, blend, attachments) { - var slot = skeleton.slots[timeline.slotIndex]; - if (!slot.bone.active) - return; - var frames = timeline.frames; - if (time < frames[0]) { - if (blend == core.MixBlend.setup || blend == core.MixBlend.first) - this.setAttachment(skeleton, slot, slot.data.attachmentName, attachments); - } - else { - var frameIndex; - if (time >= frames[frames.length - 1]) - frameIndex = frames.length - 1; - else - frameIndex = core.Animation.binarySearch(frames, time) - 1; - this.setAttachment(skeleton, slot, timeline.attachmentNames[frameIndex], attachments); - } - if (slot.attachmentState <= this.unkeyedState) - slot.attachmentState = this.unkeyedState + AnimationState.SETUP; - }; - AnimationState.prototype.setAttachment = function (skeleton, slot, attachmentName, attachments) { - slot.attachment = attachmentName == null ? null : skeleton.getAttachment(slot.data.index, attachmentName); - if (attachments) - slot.attachmentState = this.unkeyedState + AnimationState.CURRENT; - }; - AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, blend, timelinesRotation, i, firstFrame) { - if (firstFrame) - timelinesRotation[i] = 0; - if (alpha == 1) { - timeline.apply(skeleton, 0, time, null, 1, blend, core.MixDirection.mixIn); - return; - } - var rotateTimeline = timeline; - var frames = rotateTimeline.frames; - var bone = skeleton.bones[rotateTimeline.boneIndex]; - if (!bone.active) - return; - var r1 = 0, r2 = 0; - if (time < frames[0]) { - switch (blend) { - case core.MixBlend.setup: - bone.rotation = bone.data.rotation; - default: - return; - case core.MixBlend.first: - r1 = bone.rotation; - r2 = bone.data.rotation; - } - } - else { - r1 = blend == core.MixBlend.setup ? bone.data.rotation : bone.rotation; - if (time >= frames[frames.length - core.RotateTimeline.ENTRIES]) - r2 = bone.data.rotation + frames[frames.length + core.RotateTimeline.PREV_ROTATION]; - else { - var frame = core.Animation.binarySearch(frames, time, core.RotateTimeline.ENTRIES); - var prevRotation = frames[frame + core.RotateTimeline.PREV_ROTATION]; - var frameTime = frames[frame]; - var percent = rotateTimeline.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + core.RotateTimeline.PREV_TIME] - frameTime)); - r2 = frames[frame + core.RotateTimeline.ROTATION] - prevRotation; - r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360; - r2 = prevRotation + r2 * percent + bone.data.rotation; - r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360; - } - } - var total = 0, diff = r2 - r1; - diff -= (16384 - ((16384.499999999996 - diff / 360) | 0)) * 360; - if (diff == 0) { - total = timelinesRotation[i]; - } - else { - var lastTotal = 0, lastDiff = 0; - if (firstFrame) { - lastTotal = 0; - lastDiff = diff; - } - else { - lastTotal = timelinesRotation[i]; - lastDiff = timelinesRotation[i + 1]; - } - var current = diff > 0, dir = lastTotal >= 0; - if (core.MathUtils.signum(lastDiff) != core.MathUtils.signum(diff) && Math.abs(lastDiff) <= 90) { - if (Math.abs(lastTotal) > 180) - lastTotal += 360 * core.MathUtils.signum(lastTotal); - dir = current; - } - total = diff + lastTotal - lastTotal % 360; - if (dir != current) - total += 360 * core.MathUtils.signum(lastTotal); - timelinesRotation[i] = total; - } - timelinesRotation[i + 1] = diff; - r1 += total * alpha; - bone.rotation = r1 - (16384 - ((16384.499999999996 - r1 / 360) | 0)) * 360; - }; - AnimationState.prototype.queueEvents = function (entry, animationTime) { - var animationStart = entry.animationStart, animationEnd = entry.animationEnd; - var duration = animationEnd - animationStart; - var trackLastWrapped = entry.trackLast % duration; - var events = this.events; - var i = 0, n = events.length; - for (; i < n; i++) { - var event_1 = events[i]; - if (event_1.time < trackLastWrapped) - break; - if (event_1.time > animationEnd) - continue; - this.queue.event(entry, event_1); - } - var complete = false; - if (entry.loop) - complete = duration == 0 || trackLastWrapped > entry.trackTime % duration; - else - complete = animationTime >= animationEnd && entry.animationLast < animationEnd; - if (complete) - this.queue.complete(entry); - for (; i < n; i++) { - var event_2 = events[i]; - if (event_2.time < animationStart) - continue; - this.queue.event(entry, events[i]); - } - }; - AnimationState.prototype.clearTracks = function () { - var oldDrainDisabled = this.queue.drainDisabled; - this.queue.drainDisabled = true; - for (var i = 0, n = this.tracks.length; i < n; i++) - this.clearTrack(i); - this.tracks.length = 0; - this.queue.drainDisabled = oldDrainDisabled; - this.queue.drain(); - }; - AnimationState.prototype.clearTrack = function (trackIndex) { - if (trackIndex >= this.tracks.length) - return; - var current = this.tracks[trackIndex]; - if (current == null) - return; - this.queue.end(current); - this.disposeNext(current); - var entry = current; - while (true) { - var from = entry.mixingFrom; - if (from == null) - break; - this.queue.end(from); - entry.mixingFrom = null; - entry.mixingTo = null; - entry = from; - } - this.tracks[current.trackIndex] = null; - this.queue.drain(); - }; - AnimationState.prototype.setCurrent = function (index, current, interrupt) { - var from = this.expandToIndex(index); - this.tracks[index] = current; - if (from != null) { - if (interrupt) - this.queue.interrupt(from); - current.mixingFrom = from; - from.mixingTo = current; - current.mixTime = 0; - if (from.mixingFrom != null && from.mixDuration > 0) - current.interruptAlpha *= Math.min(1, from.mixTime / from.mixDuration); - from.timelinesRotation.length = 0; - } - this.queue.start(current); - }; - AnimationState.prototype.setAnimation = function (trackIndex, animationName, loop) { - var animation = this.data.skeletonData.findAnimation(animationName); - if (animation == null) - throw new Error("Animation not found: " + animationName); - return this.setAnimationWith(trackIndex, animation, loop); - }; - AnimationState.prototype.setAnimationWith = function (trackIndex, animation, loop) { - if (animation == null) - throw new Error("animation cannot be null."); - var interrupt = true; - var current = this.expandToIndex(trackIndex); - if (current != null) { - if (current.nextTrackLast == -1) { - this.tracks[trackIndex] = current.mixingFrom; - this.queue.interrupt(current); - this.queue.end(current); - this.disposeNext(current); - current = current.mixingFrom; - interrupt = false; - } - else - this.disposeNext(current); - } - var entry = this.trackEntry(trackIndex, animation, loop, current); - this.setCurrent(trackIndex, entry, interrupt); - this.queue.drain(); - return entry; - }; - AnimationState.prototype.addAnimation = function (trackIndex, animationName, loop, delay) { - var animation = this.data.skeletonData.findAnimation(animationName); - if (animation == null) - throw new Error("Animation not found: " + animationName); - return this.addAnimationWith(trackIndex, animation, loop, delay); - }; - AnimationState.prototype.addAnimationWith = function (trackIndex, animation, loop, delay) { - if (animation == null) - throw new Error("animation cannot be null."); - var last = this.expandToIndex(trackIndex); - if (last != null) { - while (last.next != null) - last = last.next; - } - var entry = this.trackEntry(trackIndex, animation, loop, last); - if (last == null) { - this.setCurrent(trackIndex, entry, true); - this.queue.drain(); - } - else { - last.next = entry; - if (delay <= 0) { - var duration = last.animationEnd - last.animationStart; - if (duration != 0) { - if (last.loop) - delay += duration * (1 + ((last.trackTime / duration) | 0)); - else - delay += Math.max(duration, last.trackTime); - delay -= this.data.getMix(last.animation, animation); - } - else - delay = last.trackTime; - } - } - entry.delay = delay; - return entry; - }; - AnimationState.prototype.setEmptyAnimation = function (trackIndex, mixDuration) { - var entry = this.setAnimationWith(trackIndex, AnimationState.emptyAnimation, false); - entry.mixDuration = mixDuration; - entry.trackEnd = mixDuration; - return entry; - }; - AnimationState.prototype.addEmptyAnimation = function (trackIndex, mixDuration, delay) { - if (delay <= 0) - delay -= mixDuration; - var entry = this.addAnimationWith(trackIndex, AnimationState.emptyAnimation, false, delay); - entry.mixDuration = mixDuration; - entry.trackEnd = mixDuration; - return entry; - }; - AnimationState.prototype.setEmptyAnimations = function (mixDuration) { - var oldDrainDisabled = this.queue.drainDisabled; - this.queue.drainDisabled = true; - for (var i = 0, n = this.tracks.length; i < n; i++) { - var current = this.tracks[i]; - if (current != null) - this.setEmptyAnimation(current.trackIndex, mixDuration); - } - this.queue.drainDisabled = oldDrainDisabled; - this.queue.drain(); - }; - AnimationState.prototype.expandToIndex = function (index) { - if (index < this.tracks.length) - return this.tracks[index]; - core.Utils.ensureArrayCapacity(this.tracks, index + 1, null); - this.tracks.length = index + 1; - return null; - }; - AnimationState.prototype.trackEntry = function (trackIndex, animation, loop, last) { - var entry = this.trackEntryPool.obtain(); - entry.trackIndex = trackIndex; - entry.animation = animation; - entry.loop = loop; - entry.holdPrevious = false; - entry.eventThreshold = 0; - entry.attachmentThreshold = 0; - entry.drawOrderThreshold = 0; - entry.animationStart = 0; - entry.animationEnd = animation.duration; - entry.animationLast = -1; - entry.nextAnimationLast = -1; - entry.delay = 0; - entry.trackTime = 0; - entry.trackLast = -1; - entry.nextTrackLast = -1; - entry.trackEnd = Number.MAX_VALUE; - entry.timeScale = 1; - entry.alpha = 1; - entry.interruptAlpha = 1; - entry.mixTime = 0; - entry.mixDuration = last == null ? 0 : this.data.getMix(last.animation, animation); - entry.mixBlend = core.MixBlend.replace; - return entry; - }; - AnimationState.prototype.disposeNext = function (entry) { - var next = entry.next; - while (next != null) { - this.queue.dispose(next); - next = next.next; - } - entry.next = null; - }; - AnimationState.prototype._animationsChanged = function () { - this.animationsChanged = false; - this.propertyIDs.clear(); - for (var i = 0, n = this.tracks.length; i < n; i++) { - var entry = this.tracks[i]; - if (entry == null) - continue; - while (entry.mixingFrom != null) - entry = entry.mixingFrom; - do { - if (entry.mixingFrom == null || entry.mixBlend != core.MixBlend.add) - this.computeHold(entry); - entry = entry.mixingTo; - } while (entry != null); - } - }; - AnimationState.prototype.computeHold = function (entry) { - var to = entry.mixingTo; - var timelines = entry.animation.timelines; - var timelinesCount = entry.animation.timelines.length; - var timelineMode = core.Utils.setArraySize(entry.timelineMode, timelinesCount); - entry.timelineHoldMix.length = 0; - var timelineDipMix = core.Utils.setArraySize(entry.timelineHoldMix, timelinesCount); - var propertyIDs = this.propertyIDs; - if (to != null && to.holdPrevious) { - for (var i = 0; i < timelinesCount; i++) { - timelineMode[i] = propertyIDs.add(timelines[i].getPropertyId()) ? AnimationState.HOLD_FIRST : AnimationState.HOLD_SUBSEQUENT; - } - return; - } - outer: for (var i = 0; i < timelinesCount; i++) { - var timeline = timelines[i]; - var id = timeline.getPropertyId(); - if (!propertyIDs.add(id)) - timelineMode[i] = AnimationState.SUBSEQUENT; - else if (to == null || timeline instanceof core.AttachmentTimeline || timeline instanceof core.DrawOrderTimeline - || timeline instanceof core.EventTimeline || !to.animation.hasTimeline(id)) { - timelineMode[i] = AnimationState.FIRST; - } - else { - for (var next = to.mixingTo; next != null; next = next.mixingTo) { - if (next.animation.hasTimeline(id)) - continue; - if (entry.mixDuration > 0) { - timelineMode[i] = AnimationState.HOLD_MIX; - timelineDipMix[i] = next; - continue outer; - } - break; - } - timelineMode[i] = AnimationState.HOLD_FIRST; - } - } - }; - AnimationState.prototype.getCurrent = function (trackIndex) { - if (trackIndex >= this.tracks.length) - return null; - return this.tracks[trackIndex]; - }; - AnimationState.prototype.addListener = function (listener) { - if (listener == null) - throw new Error("listener cannot be null."); - this.listeners.push(listener); - }; - AnimationState.prototype.removeListener = function (listener) { - var index = this.listeners.indexOf(listener); - if (index >= 0) - this.listeners.splice(index, 1); - }; - AnimationState.prototype.clearListeners = function () { - this.listeners.length = 0; - }; - AnimationState.prototype.clearListenerNotifications = function () { - this.queue.clear(); - }; - AnimationState.prototype.setAnimationByName = function (trackIndex, animationName, loop) { - if (!AnimationState.deprecatedWarning1) { - AnimationState.deprecatedWarning1 = true; - console.warn("Spine Deprecation Warning: AnimationState.setAnimationByName is deprecated, please use setAnimation from now on."); - } - this.setAnimation(trackIndex, animationName, loop); - }; - AnimationState.prototype.addAnimationByName = function (trackIndex, animationName, loop, delay) { - if (!AnimationState.deprecatedWarning2) { - AnimationState.deprecatedWarning2 = true; - console.warn("Spine Deprecation Warning: AnimationState.addAnimationByName is deprecated, please use addAnimation from now on."); - } - this.addAnimation(trackIndex, animationName, loop, delay); - }; - AnimationState.prototype.hasAnimation = function (animationName) { - var animation = this.data.skeletonData.findAnimation(animationName); - return animation !== null; - }; - AnimationState.prototype.hasAnimationByName = function (animationName) { - if (!AnimationState.deprecatedWarning3) { - AnimationState.deprecatedWarning3 = true; - console.warn("Spine Deprecation Warning: AnimationState.hasAnimationByName is deprecated, please use hasAnimation from now on."); - } - return this.hasAnimation(animationName); - }; - AnimationState.emptyAnimation = new core.Animation("", [], 0); - AnimationState.SUBSEQUENT = 0; - AnimationState.FIRST = 1; - AnimationState.HOLD_SUBSEQUENT = 2; - AnimationState.HOLD_FIRST = 3; - AnimationState.HOLD_MIX = 4; - AnimationState.SETUP = 1; - AnimationState.CURRENT = 2; - AnimationState.deprecatedWarning1 = false; - AnimationState.deprecatedWarning2 = false; - AnimationState.deprecatedWarning3 = false; - return AnimationState; - }()); - core.AnimationState = AnimationState; - var TrackEntry = (function () { - function TrackEntry() { - this.mixBlend = core.MixBlend.replace; - this.timelineMode = new Array(); - this.timelineHoldMix = new Array(); - this.timelinesRotation = new Array(); - } - TrackEntry.prototype.reset = function () { - this.next = null; - this.mixingFrom = null; - this.mixingTo = null; - this.animation = null; - this.listener = null; - this.timelineMode.length = 0; - this.timelineHoldMix.length = 0; - this.timelinesRotation.length = 0; - }; - TrackEntry.prototype.getAnimationTime = function () { - if (this.loop) { - var duration = this.animationEnd - this.animationStart; - if (duration == 0) - return this.animationStart; - return (this.trackTime % duration) + this.animationStart; - } - return Math.min(this.trackTime + this.animationStart, this.animationEnd); - }; - TrackEntry.prototype.setAnimationLast = function (animationLast) { - this.animationLast = animationLast; - this.nextAnimationLast = animationLast; - }; - TrackEntry.prototype.isComplete = function () { - return this.trackTime >= this.animationEnd - this.animationStart; - }; - TrackEntry.prototype.resetRotationDirections = function () { - this.timelinesRotation.length = 0; - }; - Object.defineProperty(TrackEntry.prototype, "time", { - get: function () { - if (!TrackEntry.deprecatedWarning1) { - TrackEntry.deprecatedWarning1 = true; - console.warn("Spine Deprecation Warning: TrackEntry.time is deprecated, please use trackTime from now on."); - } - return this.trackTime; - }, - set: function (value) { - if (!TrackEntry.deprecatedWarning1) { - TrackEntry.deprecatedWarning1 = true; - console.warn("Spine Deprecation Warning: TrackEntry.time is deprecated, please use trackTime from now on."); - } - this.trackTime = value; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(TrackEntry.prototype, "endTime", { - get: function () { - if (!TrackEntry.deprecatedWarning2) { - TrackEntry.deprecatedWarning2 = true; - console.warn("Spine Deprecation Warning: TrackEntry.endTime is deprecated, please use trackEnd from now on."); - } - return this.trackTime; - }, - set: function (value) { - if (!TrackEntry.deprecatedWarning2) { - TrackEntry.deprecatedWarning2 = true; - console.warn("Spine Deprecation Warning: TrackEntry.endTime is deprecated, please use trackEnd from now on."); - } - this.trackTime = value; - }, - enumerable: false, - configurable: true - }); - TrackEntry.prototype.loopsCount = function () { - return Math.floor(this.trackTime / this.trackEnd); - }; - TrackEntry.deprecatedWarning1 = false; - TrackEntry.deprecatedWarning2 = false; - return TrackEntry; - }()); - core.TrackEntry = TrackEntry; - var EventQueue = (function () { - function EventQueue(animState) { - this.objects = []; - this.drainDisabled = false; - this.animState = animState; - } - EventQueue.prototype.start = function (entry) { - this.objects.push(EventType.start); - this.objects.push(entry); - this.animState.animationsChanged = true; - }; - EventQueue.prototype.interrupt = function (entry) { - this.objects.push(EventType.interrupt); - this.objects.push(entry); - }; - EventQueue.prototype.end = function (entry) { - this.objects.push(EventType.end); - this.objects.push(entry); - this.animState.animationsChanged = true; - }; - EventQueue.prototype.dispose = function (entry) { - this.objects.push(EventType.dispose); - this.objects.push(entry); - }; - EventQueue.prototype.complete = function (entry) { - this.objects.push(EventType.complete); - this.objects.push(entry); - }; - EventQueue.prototype.event = function (entry, event) { - this.objects.push(EventType.event); - this.objects.push(entry); - this.objects.push(event); - }; - EventQueue.prototype.deprecateStuff = function () { - if (!EventQueue.deprecatedWarning1) { - EventQueue.deprecatedWarning1 = true; - console.warn("Spine Deprecation Warning: onComplete, onStart, onEnd, onEvent art deprecated, please use listeners from now on. 'state.addListener({ complete: function(track, event) { } })'"); - } - return true; - }; - EventQueue.prototype.drain = function () { - if (this.drainDisabled) - return; - this.drainDisabled = true; - var objects = this.objects; - var listeners = this.animState.listeners; - for (var i = 0; i < objects.length; i += 2) { - var type = objects[i]; - var entry = objects[i + 1]; - switch (type) { - case EventType.start: - if (entry.listener != null && entry.listener.start) - entry.listener.start(entry); - for (var ii = 0; ii < listeners.length; ii++) - if (listeners[ii].start) - listeners[ii].start(entry); - entry.onStart && this.deprecateStuff() && entry.onStart(entry.trackIndex); - this.animState.onStart && this.deprecateStuff() && this.deprecateStuff && this.animState.onStart(entry.trackIndex); - break; - case EventType.interrupt: - if (entry.listener != null && entry.listener.interrupt) - entry.listener.interrupt(entry); - for (var ii = 0; ii < listeners.length; ii++) - if (listeners[ii].interrupt) - listeners[ii].interrupt(entry); - break; - case EventType.end: - if (entry.listener != null && entry.listener.end) - entry.listener.end(entry); - for (var ii = 0; ii < listeners.length; ii++) - if (listeners[ii].end) - listeners[ii].end(entry); - entry.onEnd && this.deprecateStuff() && entry.onEnd(entry.trackIndex); - this.animState.onEnd && this.deprecateStuff() && this.animState.onEnd(entry.trackIndex); - case EventType.dispose: - if (entry.listener != null && entry.listener.dispose) - entry.listener.dispose(entry); - for (var ii = 0; ii < listeners.length; ii++) - if (listeners[ii].dispose) - listeners[ii].dispose(entry); - this.animState.trackEntryPool.free(entry); - break; - case EventType.complete: - if (entry.listener != null && entry.listener.complete) - entry.listener.complete(entry); - for (var ii = 0; ii < listeners.length; ii++) - if (listeners[ii].complete) - listeners[ii].complete(entry); - var count = core.MathUtils.toInt(entry.loopsCount()); - entry.onComplete && this.deprecateStuff() && entry.onComplete(entry.trackIndex, count); - this.animState.onComplete && this.deprecateStuff() && this.animState.onComplete(entry.trackIndex, count); - break; - case EventType.event: - var event_3 = objects[i++ + 2]; - if (entry.listener != null && entry.listener.event) - entry.listener.event(entry, event_3); - for (var ii = 0; ii < listeners.length; ii++) - if (listeners[ii].event) - listeners[ii].event(entry, event_3); - entry.onEvent && this.deprecateStuff() && entry.onEvent(entry.trackIndex, event_3); - this.animState.onEvent && this.deprecateStuff() && this.animState.onEvent(entry.trackIndex, event_3); - break; - } - } - this.clear(); - this.drainDisabled = false; - }; - EventQueue.prototype.clear = function () { - this.objects.length = 0; - }; - EventQueue.deprecatedWarning1 = false; - return EventQueue; - }()); - core.EventQueue = EventQueue; - var EventType; - (function (EventType) { - EventType[EventType["start"] = 0] = "start"; - EventType[EventType["interrupt"] = 1] = "interrupt"; - EventType[EventType["end"] = 2] = "end"; - EventType[EventType["dispose"] = 3] = "dispose"; - EventType[EventType["complete"] = 4] = "complete"; - EventType[EventType["event"] = 5] = "event"; - })(EventType = core.EventType || (core.EventType = {})); - var AnimationStateAdapter = (function () { - function AnimationStateAdapter() { - } - AnimationStateAdapter.prototype.start = function (entry) { - }; - AnimationStateAdapter.prototype.interrupt = function (entry) { - }; - AnimationStateAdapter.prototype.end = function (entry) { - }; - AnimationStateAdapter.prototype.dispose = function (entry) { - }; - AnimationStateAdapter.prototype.complete = function (entry) { - }; - AnimationStateAdapter.prototype.event = function (entry, event) { - }; - return AnimationStateAdapter; - }()); - core.AnimationStateAdapter = AnimationStateAdapter; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var AnimationStateData = (function () { - function AnimationStateData(skeletonData) { - this.animationToMixTime = {}; - this.defaultMix = 0; - if (skeletonData == null) - throw new Error("skeletonData cannot be null."); - this.skeletonData = skeletonData; - } - AnimationStateData.prototype.setMix = function (fromName, toName, duration) { - var from = this.skeletonData.findAnimation(fromName); - if (from == null) - throw new Error("Animation not found: " + fromName); - var to = this.skeletonData.findAnimation(toName); - if (to == null) - throw new Error("Animation not found: " + toName); - this.setMixWith(from, to, duration); - }; - AnimationStateData.prototype.setMixByName = function (fromName, toName, duration) { - if (!AnimationStateData.deprecatedWarning1) { - AnimationStateData.deprecatedWarning1 = true; - console.warn("Deprecation Warning: AnimationStateData.setMixByName is deprecated, please use setMix from now on."); - } - this.setMix(fromName, toName, duration); - }; - AnimationStateData.prototype.setMixWith = function (from, to, duration) { - if (from == null) - throw new Error("from cannot be null."); - if (to == null) - throw new Error("to cannot be null."); - var key = from.name + "." + to.name; - this.animationToMixTime[key] = duration; - }; - AnimationStateData.prototype.getMix = function (from, to) { - var key = from.name + "." + to.name; - var value = this.animationToMixTime[key]; - return value === undefined ? this.defaultMix : value; - }; - AnimationStateData.deprecatedWarning1 = false; - return AnimationStateData; - }()); - core.AnimationStateData = AnimationStateData; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var AtlasAttachmentLoader = (function () { - function AtlasAttachmentLoader(atlas) { - this.atlas = atlas; - } - AtlasAttachmentLoader.prototype.newRegionAttachment = function (skin, name, path) { - var region = this.atlas.findRegion(path); - if (region == null) - throw new Error("Region not found in atlas: " + path + " (region attachment: " + name + ")"); - var attachment = new core.RegionAttachment(name); - attachment.region = region; - return attachment; - }; - AtlasAttachmentLoader.prototype.newMeshAttachment = function (skin, name, path) { - var region = this.atlas.findRegion(path); - if (region == null) - throw new Error("Region not found in atlas: " + path + " (mesh attachment: " + name + ")"); - var attachment = new core.MeshAttachment(name); - attachment.region = region; - return attachment; - }; - AtlasAttachmentLoader.prototype.newBoundingBoxAttachment = function (skin, name) { - return new core.BoundingBoxAttachment(name); - }; - AtlasAttachmentLoader.prototype.newPathAttachment = function (skin, name) { - return new core.PathAttachment(name); - }; - AtlasAttachmentLoader.prototype.newPointAttachment = function (skin, name) { - return new core.PointAttachment(name); - }; - AtlasAttachmentLoader.prototype.newClippingAttachment = function (skin, name) { - return new core.ClippingAttachment(name); - }; - return AtlasAttachmentLoader; - }()); - core.AtlasAttachmentLoader = AtlasAttachmentLoader; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var BlendMode; - (function (BlendMode) { - BlendMode[BlendMode["Normal"] = 0] = "Normal"; - BlendMode[BlendMode["Additive"] = 1] = "Additive"; - BlendMode[BlendMode["Multiply"] = 2] = "Multiply"; - BlendMode[BlendMode["Screen"] = 3] = "Screen"; - })(BlendMode = core.BlendMode || (core.BlendMode = {})); - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var Bone = (function () { - function Bone(data, skeleton, parent) { - this.matrix = new PIXI.Matrix(); - this.children = new Array(); - this.x = 0; - this.y = 0; - this.rotation = 0; - this.scaleX = 0; - this.scaleY = 0; - this.shearX = 0; - this.shearY = 0; - this.ax = 0; - this.ay = 0; - this.arotation = 0; - this.ascaleX = 0; - this.ascaleY = 0; - this.ashearX = 0; - this.ashearY = 0; - this.appliedValid = false; - this.sorted = false; - this.active = false; - if (data == null) - throw new Error("data cannot be null."); - if (skeleton == null) - throw new Error("skeleton cannot be null."); - this.data = data; - this.skeleton = skeleton; - this.parent = parent; - this.setToSetupPose(); - } - Object.defineProperty(Bone.prototype, "worldX", { - get: function () { - return this.matrix.tx; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Bone.prototype, "worldY", { - get: function () { - return this.matrix.ty; - }, - enumerable: false, - configurable: true - }); - Bone.prototype.isActive = function () { - return this.active; - }; - Bone.prototype.update = function () { - this.updateWorldTransformWith(this.x, this.y, this.rotation, this.scaleX, this.scaleY, this.shearX, this.shearY); - }; - Bone.prototype.updateWorldTransform = function () { - this.updateWorldTransformWith(this.x, this.y, this.rotation, this.scaleX, this.scaleY, this.shearX, this.shearY); - }; - Bone.prototype.updateWorldTransformWith = function (x, y, rotation, scaleX, scaleY, shearX, shearY) { - this.ax = x; - this.ay = y; - this.arotation = rotation; - this.ascaleX = scaleX; - this.ascaleY = scaleY; - this.ashearX = shearX; - this.ashearY = shearY; - this.appliedValid = true; - var parent = this.parent; - var m = this.matrix; - var sx = this.skeleton.scaleX; - var sy = Bone.yDown ? -this.skeleton.scaleY : this.skeleton.scaleY; - if (parent == null) { - var skeleton = this.skeleton; - var rotationY = rotation + 90 + shearY; - m.a = core.MathUtils.cosDeg(rotation + shearX) * scaleX * sx; - m.c = core.MathUtils.cosDeg(rotationY) * scaleY * sx; - m.b = core.MathUtils.sinDeg(rotation + shearX) * scaleX * sy; - m.d = core.MathUtils.sinDeg(rotationY) * scaleY * sy; - m.tx = x * sx + skeleton.x; - m.ty = y * sy + skeleton.y; - return; - } - var pa = parent.matrix.a, pb = parent.matrix.c, pc = parent.matrix.b, pd = parent.matrix.d; - m.tx = pa * x + pb * y + parent.matrix.tx; - m.ty = pc * x + pd * y + parent.matrix.ty; - switch (this.data.transformMode) { - case core.TransformMode.Normal: { - var rotationY = rotation + 90 + shearY; - var la = core.MathUtils.cosDeg(rotation + shearX) * scaleX; - var lb = core.MathUtils.cosDeg(rotationY) * scaleY; - var lc = core.MathUtils.sinDeg(rotation + shearX) * scaleX; - var ld = core.MathUtils.sinDeg(rotationY) * scaleY; - m.a = pa * la + pb * lc; - m.c = pa * lb + pb * ld; - m.b = pc * la + pd * lc; - m.d = pc * lb + pd * ld; - return; - } - case core.TransformMode.OnlyTranslation: { - var rotationY = rotation + 90 + shearY; - m.a = core.MathUtils.cosDeg(rotation + shearX) * scaleX; - m.c = core.MathUtils.cosDeg(rotationY) * scaleY; - m.b = core.MathUtils.sinDeg(rotation + shearX) * scaleX; - m.d = core.MathUtils.sinDeg(rotationY) * scaleY; - break; - } - case core.TransformMode.NoRotationOrReflection: { - var s = pa * pa + pc * pc; - var prx = 0; - if (s > 0.0001) { - s = Math.abs(pa * pd - pb * pc) / s; - pa /= this.skeleton.scaleX; - pc /= this.skeleton.scaleY; - pb = pc * s; - pd = pa * s; - prx = Math.atan2(pc, pa) * core.MathUtils.radDeg; - } - else { - pa = 0; - pc = 0; - prx = 90 - Math.atan2(pd, pb) * core.MathUtils.radDeg; - } - var rx = rotation + shearX - prx; - var ry = rotation + shearY - prx + 90; - var la = core.MathUtils.cosDeg(rx) * scaleX; - var lb = core.MathUtils.cosDeg(ry) * scaleY; - var lc = core.MathUtils.sinDeg(rx) * scaleX; - var ld = core.MathUtils.sinDeg(ry) * scaleY; - m.a = pa * la - pb * lc; - m.c = pa * lb - pb * ld; - m.b = pc * la + pd * lc; - m.d = pc * lb + pd * ld; - break; - } - case core.TransformMode.NoScale: - case core.TransformMode.NoScaleOrReflection: { - var cos = core.MathUtils.cosDeg(rotation); - var sin = core.MathUtils.sinDeg(rotation); - var za = (pa * cos + pb * sin) / sx; - var zc = (pc * cos + pd * sin) / sy; - var s = Math.sqrt(za * za + zc * zc); - if (s > 0.00001) - s = 1 / s; - za *= s; - zc *= s; - s = Math.sqrt(za * za + zc * zc); - if (this.data.transformMode == core.TransformMode.NoScale - && (pa * pd - pb * pc < 0) != (Bone.yDown ? - (this.skeleton.scaleX < 0 != this.skeleton.scaleY > 0) : - (this.skeleton.scaleX < 0 != this.skeleton.scaleY < 0))) - s = -s; - var r = Math.PI / 2 + Math.atan2(zc, za); - var zb = Math.cos(r) * s; - var zd = Math.sin(r) * s; - var la = core.MathUtils.cosDeg(shearX) * scaleX; - var lb = core.MathUtils.cosDeg(90 + shearY) * scaleY; - var lc = core.MathUtils.sinDeg(shearX) * scaleX; - var ld = core.MathUtils.sinDeg(90 + shearY) * scaleY; - m.a = za * la + zb * lc; - m.c = za * lb + zb * ld; - m.b = zc * la + zd * lc; - m.d = zc * lb + zd * ld; - break; - } - } - m.a *= sx; - m.c *= sx; - m.b *= sy; - m.d *= sy; - }; - Bone.prototype.setToSetupPose = function () { - var data = this.data; - this.x = data.x; - this.y = data.y; - this.rotation = data.rotation; - this.scaleX = data.scaleX; - this.scaleY = data.scaleY; - this.shearX = data.shearX; - this.shearY = data.shearY; - }; - Bone.prototype.getWorldRotationX = function () { - return Math.atan2(this.matrix.b, this.matrix.a) * core.MathUtils.radDeg; - }; - Bone.prototype.getWorldRotationY = function () { - return Math.atan2(this.matrix.d, this.matrix.c) * core.MathUtils.radDeg; - }; - Bone.prototype.getWorldScaleX = function () { - var m = this.matrix; - return Math.sqrt(m.a * m.a + m.c * m.c); - }; - Bone.prototype.getWorldScaleY = function () { - var m = this.matrix; - return Math.sqrt(m.b * m.b + m.d * m.d); - }; - Bone.prototype.updateAppliedTransform = function () { - this.appliedValid = true; - var parent = this.parent; - var m = this.matrix; - if (parent == null) { - this.ax = m.tx; - this.ay = m.ty; - this.arotation = Math.atan2(m.b, m.a) * core.MathUtils.radDeg; - this.ascaleX = Math.sqrt(m.a * m.a + m.b * m.b); - this.ascaleY = Math.sqrt(m.c * m.c + m.d * m.d); - this.ashearX = 0; - this.ashearY = Math.atan2(m.a * m.c + m.b * m.d, m.a * m.d - m.b * m.c) * core.MathUtils.radDeg; - return; - } - var pm = parent.matrix; - var pid = 1 / (pm.a * pm.d - pm.b * pm.c); - var dx = m.tx - pm.tx, dy = m.ty - pm.ty; - this.ax = (dx * pm.d * pid - dy * pm.c * pid); - this.ay = (dy * pm.a * pid - dx * pm.b * pid); - var ia = pid * pm.d; - var id = pid * pm.a; - var ib = pid * pm.c; - var ic = pid * pm.b; - var ra = ia * m.a - ib * m.b; - var rb = ia * m.c - ib * m.d; - var rc = id * m.b - ic * m.a; - var rd = id * m.d - ic * m.c; - this.ashearX = 0; - this.ascaleX = Math.sqrt(ra * ra + rc * rc); - if (this.ascaleX > 0.0001) { - var det = ra * rd - rb * rc; - this.ascaleY = det / this.ascaleX; - this.ashearY = Math.atan2(ra * rb + rc * rd, det) * core.MathUtils.radDeg; - this.arotation = Math.atan2(rc, ra) * core.MathUtils.radDeg; - } - else { - this.ascaleX = 0; - this.ascaleY = Math.sqrt(rb * rb + rd * rd); - this.ashearY = 0; - this.arotation = 90 - Math.atan2(rd, rb) * core.MathUtils.radDeg; - } - }; - Bone.prototype.worldToLocal = function (world) { - var m = this.matrix; - var a = m.a, b = m.c, c = m.b, d = m.d; - var invDet = 1 / (a * d - b * c); - var x = world.x - m.tx, y = world.y - m.ty; - world.x = (x * d * invDet - y * b * invDet); - world.y = (y * a * invDet - x * c * invDet); - return world; - }; - Bone.prototype.localToWorld = function (local) { - var m = this.matrix; - var x = local.x, y = local.y; - local.x = x * m.a + y * m.c + m.tx; - local.y = x * m.b + y * m.d + m.ty; - return local; - }; - Bone.prototype.worldToLocalRotation = function (worldRotation) { - var sin = core.MathUtils.sinDeg(worldRotation), cos = core.MathUtils.cosDeg(worldRotation); - var mat = this.matrix; - return Math.atan2(mat.a * sin - mat.b * cos, mat.d * cos - mat.c * sin) * core.MathUtils.radDeg; - }; - Bone.prototype.localToWorldRotation = function (localRotation) { - var sin = core.MathUtils.sinDeg(localRotation), cos = core.MathUtils.cosDeg(localRotation); - var mat = this.matrix; - return Math.atan2(cos * mat.b + sin * mat.d, cos * mat.a + sin * mat.c) * core.MathUtils.radDeg; - }; - Bone.prototype.rotateWorld = function (degrees) { - var mat = this.matrix; - var a = mat.a, b = mat.c, c = mat.b, d = mat.d; - var cos = core.MathUtils.cosDeg(degrees), sin = core.MathUtils.sinDeg(degrees); - mat.a = cos * a - sin * c; - mat.c = cos * b - sin * d; - mat.b = sin * a + cos * c; - mat.d = sin * b + cos * d; - this.appliedValid = false; - }; - Bone.yDown = false; - return Bone; - }()); - core.Bone = Bone; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var BoneData = (function () { - function BoneData(index, name, parent) { - this.x = 0; - this.y = 0; - this.rotation = 0; - this.scaleX = 1; - this.scaleY = 1; - this.shearX = 0; - this.shearY = 0; - this.transformMode = TransformMode.Normal; - this.skinRequired = false; - this.color = new core.Color(); - if (index < 0) - throw new Error("index must be >= 0."); - if (name == null) - throw new Error("name cannot be null."); - this.index = index; - this.name = name; - this.parent = parent; - } - return BoneData; - }()); - core.BoneData = BoneData; - var TransformMode; - (function (TransformMode) { - TransformMode[TransformMode["Normal"] = 0] = "Normal"; - TransformMode[TransformMode["OnlyTranslation"] = 1] = "OnlyTranslation"; - TransformMode[TransformMode["NoRotationOrReflection"] = 2] = "NoRotationOrReflection"; - TransformMode[TransformMode["NoScale"] = 3] = "NoScale"; - TransformMode[TransformMode["NoScaleOrReflection"] = 4] = "NoScaleOrReflection"; - })(TransformMode = core.TransformMode || (core.TransformMode = {})); - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var ConstraintData = (function () { - function ConstraintData(name, order, skinRequired) { - this.name = name; - this.order = order; - this.skinRequired = skinRequired; - } - return ConstraintData; - }()); - core.ConstraintData = ConstraintData; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var Event = (function () { - function Event(time, data) { - if (data == null) - throw new Error("data cannot be null."); - this.time = time; - this.data = data; - } - return Event; - }()); - core.Event = Event; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var EventData = (function () { - function EventData(name) { - this.name = name; - } - return EventData; - }()); - core.EventData = EventData; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var IkConstraint = (function () { - function IkConstraint(data, skeleton) { - this.bendDirection = 0; - this.compress = false; - this.stretch = false; - this.mix = 1; - this.softness = 0; - this.active = false; - if (data == null) - throw new Error("data cannot be null."); - if (skeleton == null) - throw new Error("skeleton cannot be null."); - this.data = data; - this.mix = data.mix; - this.softness = data.softness; - this.bendDirection = data.bendDirection; - this.compress = data.compress; - this.stretch = data.stretch; - this.bones = new Array(); - for (var i = 0; i < data.bones.length; i++) - this.bones.push(skeleton.findBone(data.bones[i].name)); - this.target = skeleton.findBone(data.target.name); - } - IkConstraint.prototype.isActive = function () { - return this.active; - }; - IkConstraint.prototype.apply = function () { - this.update(); - }; - IkConstraint.prototype.update = function () { - var target = this.target; - var bones = this.bones; - switch (bones.length) { - case 1: - this.apply1(bones[0], target.worldX, target.worldY, this.compress, this.stretch, this.data.uniform, this.mix); - break; - case 2: - this.apply2(bones[0], bones[1], target.worldX, target.worldY, this.bendDirection, this.stretch, this.softness, this.mix); - break; - } - }; - IkConstraint.prototype.apply1 = function (bone, targetX, targetY, compress, stretch, uniform, alpha) { - if (!bone.appliedValid) - bone.updateAppliedTransform(); - var p = bone.parent.matrix; - var pa = p.a, pb = p.c, pc = p.b, pd = p.d; - var rotationIK = -bone.ashearX - bone.arotation, tx = 0, ty = 0; - switch (bone.data.transformMode) { - case core.TransformMode.OnlyTranslation: - tx = targetX - bone.worldX; - ty = targetY - bone.worldY; - break; - case core.TransformMode.NoRotationOrReflection: - var s = Math.abs(pa * pd - pb * pc) / (pa * pa + pc * pc); - var sa = pa / bone.skeleton.scaleX; - var sc = pc / bone.skeleton.scaleY; - pb = -sc * s * bone.skeleton.scaleX; - pd = sa * s * bone.skeleton.scaleY; - rotationIK += Math.atan2(sc, sa) * core.MathUtils.radDeg; - default: - var x = targetX - p.tx, y = targetY - p.ty; - var d = pa * pd - pb * pc; - tx = (x * pd - y * pb) / d - bone.ax; - ty = (y * pa - x * pc) / d - bone.ay; - } - rotationIK += Math.atan2(ty, tx) * core.MathUtils.radDeg; - if (bone.ascaleX < 0) - rotationIK += 180; - if (rotationIK > 180) - rotationIK -= 360; - else if (rotationIK < -180) - rotationIK += 360; - var sx = bone.ascaleX, sy = bone.ascaleY; - if (compress || stretch) { - switch (bone.data.transformMode) { - case core.TransformMode.NoScale: - case core.TransformMode.NoScaleOrReflection: - tx = targetX - bone.worldX; - ty = targetY - bone.worldY; - } - var b = bone.data.length * sx, dd = Math.sqrt(tx * tx + ty * ty); - if ((compress && dd < b) || (stretch && dd > b) && b > 0.0001) { - var s = (dd / b - 1) * alpha + 1; - sx *= s; - if (uniform) - sy *= s; - } - } - bone.updateWorldTransformWith(bone.ax, bone.ay, bone.arotation + rotationIK * alpha, sx, sy, bone.ashearX, bone.ashearY); - }; - IkConstraint.prototype.apply2 = function (parent, child, targetX, targetY, bendDir, stretch, softness, alpha) { - if (alpha == 0) { - child.updateWorldTransform(); - return; - } - if (!parent.appliedValid) - parent.updateAppliedTransform(); - if (!child.appliedValid) - child.updateAppliedTransform(); - var px = parent.ax, py = parent.ay, psx = parent.ascaleX, sx = psx, psy = parent.ascaleY, csx = child.ascaleX; - var pmat = parent.matrix; - var os1 = 0, os2 = 0, s2 = 0; - if (psx < 0) { - psx = -psx; - os1 = 180; - s2 = -1; - } - else { - os1 = 0; - s2 = 1; - } - if (psy < 0) { - psy = -psy; - s2 = -s2; - } - if (csx < 0) { - csx = -csx; - os2 = 180; - } - else - os2 = 0; - var cx = child.ax, cy = 0, cwx = 0, cwy = 0, a = pmat.a, b = pmat.c, c = pmat.b, d = pmat.d; - var u = Math.abs(psx - psy) <= 0.0001; - if (!u) { - cy = 0; - cwx = a * cx + pmat.tx; - cwy = c * cx + pmat.ty; - } - else { - cy = child.ay; - cwx = a * cx + b * cy + pmat.tx; - cwy = c * cx + d * cy + pmat.ty; - } - var pp = parent.parent.matrix; - a = pp.a; - b = pp.c; - c = pp.b; - d = pp.d; - var id = 1 / (a * d - b * c), x = cwx - pp.tx, y = cwy - pp.ty; - var dx = (x * d - y * b) * id - px, dy = (y * a - x * c) * id - py; - var l1 = Math.sqrt(dx * dx + dy * dy), l2 = child.data.length * csx, a1, a2; - if (l1 < 0.0001) { - this.apply1(parent, targetX, targetY, false, stretch, false, alpha); - child.updateWorldTransformWith(cx, cy, 0, child.ascaleX, child.ascaleY, child.ashearX, child.ashearY); - return; - } - x = targetX - pp.tx; - y = targetY - pp.ty; - var tx = (x * d - y * b) * id - px, ty = (y * a - x * c) * id - py; - var dd = tx * tx + ty * ty; - if (softness != 0) { - softness *= psx * (csx + 1) / 2; - var td = Math.sqrt(dd), sd = td - l1 - l2 * psx + softness; - if (sd > 0) { - var p = Math.min(1, sd / (softness * 2)) - 1; - p = (sd - softness * (1 - p * p)) / td; - tx -= p * tx; - ty -= p * ty; - dd = tx * tx + ty * ty; - } - } - outer: if (u) { - l2 *= psx; - var cos = (dd - l1 * l1 - l2 * l2) / (2 * l1 * l2); - if (cos < -1) - cos = -1; - else if (cos > 1) { - cos = 1; - if (stretch) - sx *= (Math.sqrt(dd) / (l1 + l2) - 1) * alpha + 1; - } - a2 = Math.acos(cos) * bendDir; - a = l1 + l2 * cos; - b = l2 * Math.sin(a2); - a1 = Math.atan2(ty * a - tx * b, tx * a + ty * b); - } - else { - a = psx * l2; - b = psy * l2; - var aa = a * a, bb = b * b, ta = Math.atan2(ty, tx); - c = bb * l1 * l1 + aa * dd - aa * bb; - var c1 = -2 * bb * l1, c2 = bb - aa; - d = c1 * c1 - 4 * c2 * c; - if (d >= 0) { - var q = Math.sqrt(d); - if (c1 < 0) - q = -q; - q = -(c1 + q) / 2; - var r0 = q / c2, r1 = c / q; - var r = Math.abs(r0) < Math.abs(r1) ? r0 : r1; - if (r * r <= dd) { - y = Math.sqrt(dd - r * r) * bendDir; - a1 = ta - Math.atan2(y, r); - a2 = Math.atan2(y / psy, (r - l1) / psx); - break outer; - } - } - var minAngle = core.MathUtils.PI, minX = l1 - a, minDist = minX * minX, minY = 0; - var maxAngle = 0, maxX = l1 + a, maxDist = maxX * maxX, maxY = 0; - c = -a * l1 / (aa - bb); - if (c >= -1 && c <= 1) { - c = Math.acos(c); - x = a * Math.cos(c) + l1; - y = b * Math.sin(c); - d = x * x + y * y; - if (d < minDist) { - minAngle = c; - minDist = d; - minX = x; - minY = y; - } - if (d > maxDist) { - maxAngle = c; - maxDist = d; - maxX = x; - maxY = y; - } - } - if (dd <= (minDist + maxDist) / 2) { - a1 = ta - Math.atan2(minY * bendDir, minX); - a2 = minAngle * bendDir; - } - else { - a1 = ta - Math.atan2(maxY * bendDir, maxX); - a2 = maxAngle * bendDir; - } - } - var os = Math.atan2(cy, cx) * s2; - var rotation = parent.arotation; - a1 = (a1 - os) * core.MathUtils.radDeg + os1 - rotation; - if (a1 > 180) - a1 -= 360; - else if (a1 < -180) - a1 += 360; - parent.updateWorldTransformWith(px, py, rotation + a1 * alpha, sx, parent.ascaleY, 0, 0); - rotation = child.arotation; - a2 = ((a2 + os) * core.MathUtils.radDeg - child.ashearX) * s2 + os2 - rotation; - if (a2 > 180) - a2 -= 360; - else if (a2 < -180) - a2 += 360; - child.updateWorldTransformWith(cx, cy, rotation + a2 * alpha, child.ascaleX, child.ascaleY, child.ashearX, child.ashearY); - }; - return IkConstraint; - }()); - core.IkConstraint = IkConstraint; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var IkConstraintData = (function (_super) { - __extends(IkConstraintData, _super); - function IkConstraintData(name) { - var _this = _super.call(this, name, 0, false) || this; - _this.bones = new Array(); - _this.bendDirection = 1; - _this.compress = false; - _this.stretch = false; - _this.uniform = false; - _this.mix = 1; - _this.softness = 0; - return _this; - } - return IkConstraintData; - }(core.ConstraintData)); - core.IkConstraintData = IkConstraintData; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var PathConstraint = (function () { - function PathConstraint(data, skeleton) { - this.position = 0; - this.spacing = 0; - this.rotateMix = 0; - this.translateMix = 0; - this.spaces = new Array(); - this.positions = new Array(); - this.world = new Array(); - this.curves = new Array(); - this.lengths = new Array(); - this.segments = new Array(); - this.active = false; - if (data == null) - throw new Error("data cannot be null."); - if (skeleton == null) - throw new Error("skeleton cannot be null."); - this.data = data; - this.bones = new Array(); - for (var i = 0, n = data.bones.length; i < n; i++) - this.bones.push(skeleton.findBone(data.bones[i].name)); - this.target = skeleton.findSlot(data.target.name); - this.position = data.position; - this.spacing = data.spacing; - this.rotateMix = data.rotateMix; - this.translateMix = data.translateMix; - } - PathConstraint.prototype.isActive = function () { - return this.active; - }; - PathConstraint.prototype.apply = function () { - this.update(); - }; - PathConstraint.prototype.update = function () { - var attachment = this.target.getAttachment(); - if (!(attachment instanceof core.PathAttachment)) - return; - var rotateMix = this.rotateMix, translateMix = this.translateMix; - var translate = translateMix > 0, rotate = rotateMix > 0; - if (!translate && !rotate) - return; - var data = this.data; - var spacingMode = data.spacingMode; - var lengthSpacing = spacingMode == core.SpacingMode.Length; - var rotateMode = data.rotateMode; - var tangents = rotateMode == core.RotateMode.Tangent, scale = rotateMode == core.RotateMode.ChainScale; - var boneCount = this.bones.length, spacesCount = tangents ? boneCount : boneCount + 1; - var bones = this.bones; - var spaces = core.Utils.setArraySize(this.spaces, spacesCount), lengths = null; - var spacing = this.spacing; - if (scale || lengthSpacing) { - if (scale) - lengths = core.Utils.setArraySize(this.lengths, boneCount); - for (var i = 0, n = spacesCount - 1; i < n;) { - var bone = bones[i]; - var setupLength = bone.data.length; - if (setupLength < PathConstraint.epsilon) { - if (scale) - lengths[i] = 0; - spaces[++i] = 0; - } - else { - var x = setupLength * bone.matrix.a, y = setupLength * bone.matrix.b; - var length_1 = Math.sqrt(x * x + y * y); - if (scale) - lengths[i] = length_1; - spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_1 / setupLength; - } - } - } - else { - for (var i = 1; i < spacesCount; i++) - spaces[i] = spacing; - } - var positions = this.computeWorldPositions(attachment, spacesCount, tangents, data.positionMode == core.PositionMode.Percent, spacingMode == core.SpacingMode.Percent); - var boneX = positions[0], boneY = positions[1], offsetRotation = data.offsetRotation; - var tip = false; - if (offsetRotation == 0) - tip = rotateMode == core.RotateMode.Chain; - else { - tip = false; - var p = this.target.bone.matrix; - offsetRotation *= p.a * p.d - p.b * p.c > 0 ? core.MathUtils.degRad : -core.MathUtils.degRad; - } - for (var i = 0, p = 3; i < boneCount; i++, p += 3) { - var bone = bones[i]; - var mat = bone.matrix; - mat.tx += (boneX - mat.tx) * translateMix; - mat.ty += (boneY - mat.ty) * translateMix; - var x = positions[p], y = positions[p + 1], dx = x - boneX, dy = y - boneY; - if (scale) { - var length_2 = lengths[i]; - if (length_2 != 0) { - var s = (Math.sqrt(dx * dx + dy * dy) / length_2 - 1) * rotateMix + 1; - mat.a *= s; - mat.b *= s; - } - } - boneX = x; - boneY = y; - if (rotate) { - var a = mat.a, b = mat.c, c = mat.b, d = mat.d, r = 0, cos = 0, sin = 0; - if (tangents) - r = positions[p - 1]; - else if (spaces[i + 1] == 0) - r = positions[p + 2]; - else - r = Math.atan2(dy, dx); - r -= Math.atan2(c, a); - if (tip) { - cos = Math.cos(r); - sin = Math.sin(r); - var length_3 = bone.data.length; - boneX += (length_3 * (cos * a - sin * c) - dx) * rotateMix; - boneY += (length_3 * (sin * a + cos * c) - dy) * rotateMix; - } - else { - r += offsetRotation; - } - if (r > core.MathUtils.PI) - r -= core.MathUtils.PI2; - else if (r < -core.MathUtils.PI) - r += core.MathUtils.PI2; - r *= rotateMix; - cos = Math.cos(r); - sin = Math.sin(r); - mat.a = cos * a - sin * c; - mat.c = cos * b - sin * d; - mat.b = sin * a + cos * c; - mat.d = sin * b + cos * d; - } - bone.appliedValid = false; - } - }; - PathConstraint.prototype.computeWorldPositions = function (path, spacesCount, tangents, percentPosition, percentSpacing) { - var target = this.target; - var position = this.position; - var spaces = this.spaces, out = core.Utils.setArraySize(this.positions, spacesCount * 3 + 2), world = null; - var closed = path.closed; - var verticesLength = path.worldVerticesLength, curveCount = verticesLength / 6, prevCurve = PathConstraint.NONE; - if (!path.constantSpeed) { - var lengths = path.lengths; - curveCount -= closed ? 1 : 2; - var pathLength_1 = lengths[curveCount]; - if (percentPosition) - position *= pathLength_1; - if (percentSpacing) { - for (var i = 0; i < spacesCount; i++) - spaces[i] *= pathLength_1; - } - world = core.Utils.setArraySize(this.world, 8); - for (var i = 0, o = 0, curve = 0; i < spacesCount; i++, o += 3) { - var space = spaces[i]; - position += space; - var p = position; - if (closed) { - p %= pathLength_1; - if (p < 0) - p += pathLength_1; - curve = 0; - } - else if (p < 0) { - if (prevCurve != PathConstraint.BEFORE) { - prevCurve = PathConstraint.BEFORE; - path.computeWorldVertices(target, 2, 4, world, 0, 2); - } - this.addBeforePosition(p, world, 0, out, o); - continue; - } - else if (p > pathLength_1) { - if (prevCurve != PathConstraint.AFTER) { - prevCurve = PathConstraint.AFTER; - path.computeWorldVertices(target, verticesLength - 6, 4, world, 0, 2); - } - this.addAfterPosition(p - pathLength_1, world, 0, out, o); - continue; - } - for (;; curve++) { - var length_4 = lengths[curve]; - if (p > length_4) - continue; - if (curve == 0) - p /= length_4; - else { - var prev = lengths[curve - 1]; - p = (p - prev) / (length_4 - prev); - } - break; - } - if (curve != prevCurve) { - prevCurve = curve; - if (closed && curve == curveCount) { - path.computeWorldVertices(target, verticesLength - 4, 4, world, 0, 2); - path.computeWorldVertices(target, 0, 4, world, 4, 2); - } - else - path.computeWorldVertices(target, curve * 6 + 2, 8, world, 0, 2); - } - this.addCurvePosition(p, world[0], world[1], world[2], world[3], world[4], world[5], world[6], world[7], out, o, tangents || (i > 0 && space == 0)); - } - return out; - } - if (closed) { - verticesLength += 2; - world = core.Utils.setArraySize(this.world, verticesLength); - path.computeWorldVertices(target, 2, verticesLength - 4, world, 0, 2); - path.computeWorldVertices(target, 0, 2, world, verticesLength - 4, 2); - world[verticesLength - 2] = world[0]; - world[verticesLength - 1] = world[1]; - } - else { - curveCount--; - verticesLength -= 4; - world = core.Utils.setArraySize(this.world, verticesLength); - path.computeWorldVertices(target, 2, verticesLength, world, 0, 2); - } - var curves = core.Utils.setArraySize(this.curves, curveCount); - var pathLength = 0; - var x1 = world[0], y1 = world[1], cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0, x2 = 0, y2 = 0; - var tmpx = 0, tmpy = 0, dddfx = 0, dddfy = 0, ddfx = 0, ddfy = 0, dfx = 0, dfy = 0; - for (var i = 0, w = 2; i < curveCount; i++, w += 6) { - cx1 = world[w]; - cy1 = world[w + 1]; - cx2 = world[w + 2]; - cy2 = world[w + 3]; - x2 = world[w + 4]; - y2 = world[w + 5]; - tmpx = (x1 - cx1 * 2 + cx2) * 0.1875; - tmpy = (y1 - cy1 * 2 + cy2) * 0.1875; - dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.09375; - dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.09375; - ddfx = tmpx * 2 + dddfx; - ddfy = tmpy * 2 + dddfy; - dfx = (cx1 - x1) * 0.75 + tmpx + dddfx * 0.16666667; - dfy = (cy1 - y1) * 0.75 + tmpy + dddfy * 0.16666667; - pathLength += Math.sqrt(dfx * dfx + dfy * dfy); - dfx += ddfx; - dfy += ddfy; - ddfx += dddfx; - ddfy += dddfy; - pathLength += Math.sqrt(dfx * dfx + dfy * dfy); - dfx += ddfx; - dfy += ddfy; - pathLength += Math.sqrt(dfx * dfx + dfy * dfy); - dfx += ddfx + dddfx; - dfy += ddfy + dddfy; - pathLength += Math.sqrt(dfx * dfx + dfy * dfy); - curves[i] = pathLength; - x1 = x2; - y1 = y2; - } - if (percentPosition) - position *= pathLength; - if (percentSpacing) { - for (var i = 0; i < spacesCount; i++) - spaces[i] *= pathLength; - } - var segments = this.segments; - var curveLength = 0; - for (var i = 0, o = 0, curve = 0, segment = 0; i < spacesCount; i++, o += 3) { - var space = spaces[i]; - position += space; - var p = position; - if (closed) { - p %= pathLength; - if (p < 0) - p += pathLength; - curve = 0; - } - else if (p < 0) { - this.addBeforePosition(p, world, 0, out, o); - continue; - } - else if (p > pathLength) { - this.addAfterPosition(p - pathLength, world, verticesLength - 4, out, o); - continue; - } - for (;; curve++) { - var length_5 = curves[curve]; - if (p > length_5) - continue; - if (curve == 0) - p /= length_5; - else { - var prev = curves[curve - 1]; - p = (p - prev) / (length_5 - prev); - } - break; - } - if (curve != prevCurve) { - prevCurve = curve; - var ii = curve * 6; - x1 = world[ii]; - y1 = world[ii + 1]; - cx1 = world[ii + 2]; - cy1 = world[ii + 3]; - cx2 = world[ii + 4]; - cy2 = world[ii + 5]; - x2 = world[ii + 6]; - y2 = world[ii + 7]; - tmpx = (x1 - cx1 * 2 + cx2) * 0.03; - tmpy = (y1 - cy1 * 2 + cy2) * 0.03; - dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.006; - dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.006; - ddfx = tmpx * 2 + dddfx; - ddfy = tmpy * 2 + dddfy; - dfx = (cx1 - x1) * 0.3 + tmpx + dddfx * 0.16666667; - dfy = (cy1 - y1) * 0.3 + tmpy + dddfy * 0.16666667; - curveLength = Math.sqrt(dfx * dfx + dfy * dfy); - segments[0] = curveLength; - for (ii = 1; ii < 8; ii++) { - dfx += ddfx; - dfy += ddfy; - ddfx += dddfx; - ddfy += dddfy; - curveLength += Math.sqrt(dfx * dfx + dfy * dfy); - segments[ii] = curveLength; - } - dfx += ddfx; - dfy += ddfy; - curveLength += Math.sqrt(dfx * dfx + dfy * dfy); - segments[8] = curveLength; - dfx += ddfx + dddfx; - dfy += ddfy + dddfy; - curveLength += Math.sqrt(dfx * dfx + dfy * dfy); - segments[9] = curveLength; - segment = 0; - } - p *= curveLength; - for (;; segment++) { - var length_6 = segments[segment]; - if (p > length_6) - continue; - if (segment == 0) - p /= length_6; - else { - var prev = segments[segment - 1]; - p = segment + (p - prev) / (length_6 - prev); - } - break; - } - this.addCurvePosition(p * 0.1, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, o, tangents || (i > 0 && space == 0)); - } - return out; - }; - PathConstraint.prototype.addBeforePosition = function (p, temp, i, out, o) { - var x1 = temp[i], y1 = temp[i + 1], dx = temp[i + 2] - x1, dy = temp[i + 3] - y1, r = Math.atan2(dy, dx); - out[o] = x1 + p * Math.cos(r); - out[o + 1] = y1 + p * Math.sin(r); - out[o + 2] = r; - }; - PathConstraint.prototype.addAfterPosition = function (p, temp, i, out, o) { - var x1 = temp[i + 2], y1 = temp[i + 3], dx = x1 - temp[i], dy = y1 - temp[i + 1], r = Math.atan2(dy, dx); - out[o] = x1 + p * Math.cos(r); - out[o + 1] = y1 + p * Math.sin(r); - out[o + 2] = r; - }; - PathConstraint.prototype.addCurvePosition = function (p, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, o, tangents) { - if (p == 0 || isNaN(p)) - p = 0.0001; - var tt = p * p, ttt = tt * p, u = 1 - p, uu = u * u, uuu = uu * u; - var ut = u * p, ut3 = ut * 3, uut3 = u * ut3, utt3 = ut3 * p; - var x = x1 * uuu + cx1 * uut3 + cx2 * utt3 + x2 * ttt, y = y1 * uuu + cy1 * uut3 + cy2 * utt3 + y2 * ttt; - out[o] = x; - out[o + 1] = y; - if (tangents) - out[o + 2] = Math.atan2(y - (y1 * uu + cy1 * ut * 2 + cy2 * tt), x - (x1 * uu + cx1 * ut * 2 + cx2 * tt)); - }; - PathConstraint.NONE = -1; - PathConstraint.BEFORE = -2; - PathConstraint.AFTER = -3; - PathConstraint.epsilon = 0.00001; - return PathConstraint; - }()); - core.PathConstraint = PathConstraint; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var PathConstraintData = (function (_super) { - __extends(PathConstraintData, _super); - function PathConstraintData(name) { - var _this = _super.call(this, name, 0, false) || this; - _this.bones = new Array(); - return _this; - } - return PathConstraintData; - }(core.ConstraintData)); - core.PathConstraintData = PathConstraintData; - var PositionMode; - (function (PositionMode) { - PositionMode[PositionMode["Fixed"] = 0] = "Fixed"; - PositionMode[PositionMode["Percent"] = 1] = "Percent"; - })(PositionMode = core.PositionMode || (core.PositionMode = {})); - var SpacingMode; - (function (SpacingMode) { - SpacingMode[SpacingMode["Length"] = 0] = "Length"; - SpacingMode[SpacingMode["Fixed"] = 1] = "Fixed"; - SpacingMode[SpacingMode["Percent"] = 2] = "Percent"; - })(SpacingMode = core.SpacingMode || (core.SpacingMode = {})); - var RotateMode; - (function (RotateMode) { - RotateMode[RotateMode["Tangent"] = 0] = "Tangent"; - RotateMode[RotateMode["Chain"] = 1] = "Chain"; - RotateMode[RotateMode["ChainScale"] = 2] = "ChainScale"; - })(RotateMode = core.RotateMode || (core.RotateMode = {})); - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var Skeleton = (function () { - function Skeleton(data) { - this._updateCache = new Array(); - this.updateCacheReset = new Array(); - this.time = 0; - this.scaleX = 1; - this.scaleY = 1; - this.x = 0; - this.y = 0; - if (data == null) - throw new Error("data cannot be null."); - this.data = data; - this.bones = new Array(); - for (var i = 0; i < data.bones.length; i++) { - var boneData = data.bones[i]; - var bone = void 0; - if (boneData.parent == null) - bone = new core.Bone(boneData, this, null); - else { - var parent_1 = this.bones[boneData.parent.index]; - bone = new core.Bone(boneData, this, parent_1); - parent_1.children.push(bone); - } - this.bones.push(bone); - } - this.slots = new Array(); - this.drawOrder = new Array(); - for (var i = 0; i < data.slots.length; i++) { - var slotData = data.slots[i]; - var bone = this.bones[slotData.boneData.index]; - var slot = new core.Slot(slotData, bone); - this.slots.push(slot); - this.drawOrder.push(slot); - } - this.ikConstraints = new Array(); - for (var i = 0; i < data.ikConstraints.length; i++) { - var ikConstraintData = data.ikConstraints[i]; - this.ikConstraints.push(new core.IkConstraint(ikConstraintData, this)); - } - this.transformConstraints = new Array(); - for (var i = 0; i < data.transformConstraints.length; i++) { - var transformConstraintData = data.transformConstraints[i]; - this.transformConstraints.push(new core.TransformConstraint(transformConstraintData, this)); - } - this.pathConstraints = new Array(); - for (var i = 0; i < data.pathConstraints.length; i++) { - var pathConstraintData = data.pathConstraints[i]; - this.pathConstraints.push(new core.PathConstraint(pathConstraintData, this)); - } - this.color = new core.Color(1, 1, 1, 1); - this.updateCache(); - } - Skeleton.prototype.updateCache = function () { - var updateCache = this._updateCache; - updateCache.length = 0; - this.updateCacheReset.length = 0; - var bones = this.bones; - for (var i = 0, n = bones.length; i < n; i++) { - var bone = bones[i]; - bone.sorted = bone.data.skinRequired; - bone.active = !bone.sorted; - } - if (this.skin != null) { - var skinBones = this.skin.bones; - for (var i = 0, n = this.skin.bones.length; i < n; i++) { - var bone = this.bones[skinBones[i].index]; - do { - bone.sorted = false; - bone.active = true; - bone = bone.parent; - } while (bone != null); - } - } - var ikConstraints = this.ikConstraints; - var transformConstraints = this.transformConstraints; - var pathConstraints = this.pathConstraints; - var ikCount = ikConstraints.length, transformCount = transformConstraints.length, pathCount = pathConstraints.length; - var constraintCount = ikCount + transformCount + pathCount; - outer: for (var i = 0; i < constraintCount; i++) { - for (var ii = 0; ii < ikCount; ii++) { - var constraint = ikConstraints[ii]; - if (constraint.data.order == i) { - this.sortIkConstraint(constraint); - continue outer; - } - } - for (var ii = 0; ii < transformCount; ii++) { - var constraint = transformConstraints[ii]; - if (constraint.data.order == i) { - this.sortTransformConstraint(constraint); - continue outer; - } - } - for (var ii = 0; ii < pathCount; ii++) { - var constraint = pathConstraints[ii]; - if (constraint.data.order == i) { - this.sortPathConstraint(constraint); - continue outer; - } - } - } - for (var i = 0, n = bones.length; i < n; i++) - this.sortBone(bones[i]); - }; - Skeleton.prototype.sortIkConstraint = function (constraint) { - constraint.active = constraint.target.isActive() && (!constraint.data.skinRequired || (this.skin != null && core.Utils.contains(this.skin.constraints, constraint.data, true))); - if (!constraint.active) - return; - var target = constraint.target; - this.sortBone(target); - var constrained = constraint.bones; - var parent = constrained[0]; - this.sortBone(parent); - if (constrained.length > 1) { - var child = constrained[constrained.length - 1]; - if (!(this._updateCache.indexOf(child) > -1)) - this.updateCacheReset.push(child); - } - this._updateCache.push(constraint); - this.sortReset(parent.children); - constrained[constrained.length - 1].sorted = true; - }; - Skeleton.prototype.sortPathConstraint = function (constraint) { - constraint.active = constraint.target.bone.isActive() && (!constraint.data.skinRequired || (this.skin != null && core.Utils.contains(this.skin.constraints, constraint.data, true))); - if (!constraint.active) - return; - var slot = constraint.target; - var slotIndex = slot.data.index; - var slotBone = slot.bone; - if (this.skin != null) - this.sortPathConstraintAttachment(this.skin, slotIndex, slotBone); - if (this.data.defaultSkin != null && this.data.defaultSkin != this.skin) - this.sortPathConstraintAttachment(this.data.defaultSkin, slotIndex, slotBone); - for (var i = 0, n = this.data.skins.length; i < n; i++) - this.sortPathConstraintAttachment(this.data.skins[i], slotIndex, slotBone); - var attachment = slot.getAttachment(); - if (attachment instanceof core.PathAttachment) - this.sortPathConstraintAttachmentWith(attachment, slotBone); - var constrained = constraint.bones; - var boneCount = constrained.length; - for (var i = 0; i < boneCount; i++) - this.sortBone(constrained[i]); - this._updateCache.push(constraint); - for (var i = 0; i < boneCount; i++) - this.sortReset(constrained[i].children); - for (var i = 0; i < boneCount; i++) - constrained[i].sorted = true; - }; - Skeleton.prototype.sortTransformConstraint = function (constraint) { - constraint.active = constraint.target.isActive() && (!constraint.data.skinRequired || (this.skin != null && core.Utils.contains(this.skin.constraints, constraint.data, true))); - if (!constraint.active) - return; - this.sortBone(constraint.target); - var constrained = constraint.bones; - var boneCount = constrained.length; - if (constraint.data.local) { - for (var i = 0; i < boneCount; i++) { - var child = constrained[i]; - this.sortBone(child.parent); - if (!(this._updateCache.indexOf(child) > -1)) - this.updateCacheReset.push(child); - } - } - else { - for (var i = 0; i < boneCount; i++) { - this.sortBone(constrained[i]); - } - } - this._updateCache.push(constraint); - for (var ii = 0; ii < boneCount; ii++) - this.sortReset(constrained[ii].children); - for (var ii = 0; ii < boneCount; ii++) - constrained[ii].sorted = true; - }; - Skeleton.prototype.sortPathConstraintAttachment = function (skin, slotIndex, slotBone) { - var attachments = skin.attachments[slotIndex]; - if (!attachments) - return; - for (var key in attachments) { - this.sortPathConstraintAttachmentWith(attachments[key], slotBone); - } - }; - Skeleton.prototype.sortPathConstraintAttachmentWith = function (attachment, slotBone) { - if (!(attachment instanceof core.PathAttachment)) - return; - var pathBones = attachment.bones; - if (pathBones == null) - this.sortBone(slotBone); - else { - var bones = this.bones; - var i = 0; - while (i < pathBones.length) { - var boneCount = pathBones[i++]; - for (var n = i + boneCount; i < n; i++) { - var boneIndex = pathBones[i]; - this.sortBone(bones[boneIndex]); - } - } - } - }; - Skeleton.prototype.sortBone = function (bone) { - if (bone.sorted) - return; - var parent = bone.parent; - if (parent != null) - this.sortBone(parent); - bone.sorted = true; - this._updateCache.push(bone); - }; - Skeleton.prototype.sortReset = function (bones) { - for (var i = 0, n = bones.length; i < n; i++) { - var bone = bones[i]; - if (!bone.active) - continue; - if (bone.sorted) - this.sortReset(bone.children); - bone.sorted = false; - } - }; - Skeleton.prototype.updateWorldTransform = function () { - var updateCacheReset = this.updateCacheReset; - for (var i = 0, n = updateCacheReset.length; i < n; i++) { - var bone = updateCacheReset[i]; - bone.ax = bone.x; - bone.ay = bone.y; - bone.arotation = bone.rotation; - bone.ascaleX = bone.scaleX; - bone.ascaleY = bone.scaleY; - bone.ashearX = bone.shearX; - bone.ashearY = bone.shearY; - bone.appliedValid = true; - } - var updateCache = this._updateCache; - for (var i = 0, n = updateCache.length; i < n; i++) - updateCache[i].update(); - }; - Skeleton.prototype.setToSetupPose = function () { - this.setBonesToSetupPose(); - this.setSlotsToSetupPose(); - }; - Skeleton.prototype.setBonesToSetupPose = function () { - var bones = this.bones; - for (var i = 0, n = bones.length; i < n; i++) - bones[i].setToSetupPose(); - var ikConstraints = this.ikConstraints; - for (var i = 0, n = ikConstraints.length; i < n; i++) { - var constraint = ikConstraints[i]; - constraint.mix = constraint.data.mix; - constraint.softness = constraint.data.softness; - constraint.bendDirection = constraint.data.bendDirection; - constraint.compress = constraint.data.compress; - constraint.stretch = constraint.data.stretch; - } - var transformConstraints = this.transformConstraints; - for (var i = 0, n = transformConstraints.length; i < n; i++) { - var constraint = transformConstraints[i]; - var data = constraint.data; - constraint.rotateMix = data.rotateMix; - constraint.translateMix = data.translateMix; - constraint.scaleMix = data.scaleMix; - constraint.shearMix = data.shearMix; - } - var pathConstraints = this.pathConstraints; - for (var i = 0, n = pathConstraints.length; i < n; i++) { - var constraint = pathConstraints[i]; - var data = constraint.data; - constraint.position = data.position; - constraint.spacing = data.spacing; - constraint.rotateMix = data.rotateMix; - constraint.translateMix = data.translateMix; - } - }; - Skeleton.prototype.setSlotsToSetupPose = function () { - var slots = this.slots; - core.Utils.arrayCopy(slots, 0, this.drawOrder, 0, slots.length); - for (var i = 0, n = slots.length; i < n; i++) - slots[i].setToSetupPose(); - }; - Skeleton.prototype.getRootBone = function () { - if (this.bones.length == 0) - return null; - return this.bones[0]; - }; - Skeleton.prototype.findBone = function (boneName) { - if (boneName == null) - throw new Error("boneName cannot be null."); - var bones = this.bones; - for (var i = 0, n = bones.length; i < n; i++) { - var bone = bones[i]; - if (bone.data.name == boneName) - return bone; - } - return null; - }; - Skeleton.prototype.findBoneIndex = function (boneName) { - if (boneName == null) - throw new Error("boneName cannot be null."); - var bones = this.bones; - for (var i = 0, n = bones.length; i < n; i++) - if (bones[i].data.name == boneName) - return i; - return -1; - }; - Skeleton.prototype.findSlot = function (slotName) { - if (slotName == null) - throw new Error("slotName cannot be null."); - var slots = this.slots; - for (var i = 0, n = slots.length; i < n; i++) { - var slot = slots[i]; - if (slot.data.name == slotName) - return slot; - } - return null; - }; - Skeleton.prototype.findSlotIndex = function (slotName) { - if (slotName == null) - throw new Error("slotName cannot be null."); - var slots = this.slots; - for (var i = 0, n = slots.length; i < n; i++) - if (slots[i].data.name == slotName) - return i; - return -1; - }; - Skeleton.prototype.setSkinByName = function (skinName) { - var skin = this.data.findSkin(skinName); - if (skin == null) - throw new Error("Skin not found: " + skinName); - this.setSkin(skin); - }; - Skeleton.prototype.setSkin = function (newSkin) { - if (newSkin == this.skin) - return; - if (newSkin != null) { - if (this.skin != null) - newSkin.attachAll(this, this.skin); - else { - var slots = this.slots; - for (var i = 0, n = slots.length; i < n; i++) { - var slot = slots[i]; - var name_1 = slot.data.attachmentName; - if (name_1 != null) { - var attachment = newSkin.getAttachment(i, name_1); - if (attachment != null) - slot.setAttachment(attachment); - } - } - } - } - this.skin = newSkin; - this.updateCache(); - }; - Skeleton.prototype.getAttachmentByName = function (slotName, attachmentName) { - return this.getAttachment(this.data.findSlotIndex(slotName), attachmentName); - }; - Skeleton.prototype.getAttachment = function (slotIndex, attachmentName) { - if (attachmentName == null) - throw new Error("attachmentName cannot be null."); - if (this.skin != null) { - var attachment = this.skin.getAttachment(slotIndex, attachmentName); - if (attachment != null) - return attachment; - } - if (this.data.defaultSkin != null) - return this.data.defaultSkin.getAttachment(slotIndex, attachmentName); - return null; - }; - Skeleton.prototype.setAttachment = function (slotName, attachmentName) { - if (slotName == null) - throw new Error("slotName cannot be null."); - var slots = this.slots; - for (var i = 0, n = slots.length; i < n; i++) { - var slot = slots[i]; - if (slot.data.name == slotName) { - var attachment = null; - if (attachmentName != null) { - attachment = this.getAttachment(i, attachmentName); - if (attachment == null) - throw new Error("Attachment not found: " + attachmentName + ", for slot: " + slotName); - } - slot.setAttachment(attachment); - return; - } - } - throw new Error("Slot not found: " + slotName); - }; - Skeleton.prototype.findIkConstraint = function (constraintName) { - if (constraintName == null) - throw new Error("constraintName cannot be null."); - var ikConstraints = this.ikConstraints; - for (var i = 0, n = ikConstraints.length; i < n; i++) { - var ikConstraint = ikConstraints[i]; - if (ikConstraint.data.name == constraintName) - return ikConstraint; - } - return null; - }; - Skeleton.prototype.findTransformConstraint = function (constraintName) { - if (constraintName == null) - throw new Error("constraintName cannot be null."); - var transformConstraints = this.transformConstraints; - for (var i = 0, n = transformConstraints.length; i < n; i++) { - var constraint = transformConstraints[i]; - if (constraint.data.name == constraintName) - return constraint; - } - return null; - }; - Skeleton.prototype.findPathConstraint = function (constraintName) { - if (constraintName == null) - throw new Error("constraintName cannot be null."); - var pathConstraints = this.pathConstraints; - for (var i = 0, n = pathConstraints.length; i < n; i++) { - var constraint = pathConstraints[i]; - if (constraint.data.name == constraintName) - return constraint; - } - return null; - }; - Skeleton.prototype.getBounds = function (offset, size, temp) { - if (temp === void 0) { temp = new Array(2); } - if (offset == null) - throw new Error("offset cannot be null."); - if (size == null) - throw new Error("size cannot be null."); - var drawOrder = this.drawOrder; - var minX = Number.POSITIVE_INFINITY, minY = Number.POSITIVE_INFINITY, maxX = Number.NEGATIVE_INFINITY, maxY = Number.NEGATIVE_INFINITY; - for (var i = 0, n = drawOrder.length; i < n; i++) { - var slot = drawOrder[i]; - if (!slot.bone.active) - continue; - var verticesLength = 0; - var vertices = null; - var attachment = slot.getAttachment(); - if (attachment instanceof core.RegionAttachment) { - verticesLength = 8; - vertices = core.Utils.setArraySize(temp, verticesLength, 0); - attachment.computeWorldVertices(slot.bone, vertices, 0, 2); - } - else if (attachment instanceof core.MeshAttachment) { - var mesh = attachment; - verticesLength = mesh.worldVerticesLength; - vertices = core.Utils.setArraySize(temp, verticesLength, 0); - mesh.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2); - } - if (vertices != null) { - for (var ii = 0, nn = vertices.length; ii < nn; ii += 2) { - var x = vertices[ii], y = vertices[ii + 1]; - minX = Math.min(minX, x); - minY = Math.min(minY, y); - maxX = Math.max(maxX, x); - maxY = Math.max(maxY, y); - } - } - } - offset.set(minX, minY); - size.set(maxX - minX, maxY - minY); - }; - Skeleton.prototype.update = function (delta) { - this.time += delta; - }; - Object.defineProperty(Skeleton.prototype, "flipX", { - get: function () { - return this.scaleX == -1; - }, - set: function (value) { - if (!Skeleton.deprecatedWarning1) { - Skeleton.deprecatedWarning1 = true; - console.warn("Spine Deprecation Warning: `Skeleton.flipX/flipY` was deprecated, please use scaleX/scaleY"); - } - this.scaleX = value ? 1.0 : -1.0; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Skeleton.prototype, "flipY", { - get: function () { - return this.scaleY == -1; - }, - set: function (value) { - if (!Skeleton.deprecatedWarning1) { - Skeleton.deprecatedWarning1 = true; - console.warn("Spine Deprecation Warning: `Skeleton.flipX/flipY` was deprecated, please use scaleX/scaleY"); - } - this.scaleY = value ? 1.0 : -1.0; - }, - enumerable: false, - configurable: true - }); - Skeleton.deprecatedWarning1 = false; - return Skeleton; - }()); - core.Skeleton = Skeleton; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var SkeletonBinary = (function () { - function SkeletonBinary(attachmentLoader) { - this.scale = 1; - this.linkedMeshes = new Array(); - this.attachmentLoader = attachmentLoader; - } - SkeletonBinary.prototype.readSkeletonData = function (binary) { - var scale = this.scale; - var skeletonData = new core.SkeletonData(); - skeletonData.name = ""; - var input = new BinaryInput(binary); - skeletonData.hash = input.readString(); - skeletonData.version = input.readString(); - if (skeletonData.version === '3.8.75') { - var error = "Unsupported skeleton data, 3.8.75 is deprecated, please export with a newer version of Spine."; - console.error(error); - } - skeletonData.x = input.readFloat(); - skeletonData.y = input.readFloat(); - skeletonData.width = input.readFloat(); - skeletonData.height = input.readFloat(); - var nonessential = input.readBoolean(); - if (nonessential) { - skeletonData.fps = input.readFloat(); - skeletonData.imagesPath = input.readString(); - skeletonData.audioPath = input.readString(); - } - var n = 0; - n = input.readInt(true); - for (var i = 0; i < n; i++) - input.strings.push(input.readString()); - n = input.readInt(true); - for (var i = 0; i < n; i++) { - var name_2 = input.readString(); - var parent_2 = i == 0 ? null : skeletonData.bones[input.readInt(true)]; - var data = new core.BoneData(i, name_2, parent_2); - data.rotation = input.readFloat(); - data.x = input.readFloat() * scale; - data.y = input.readFloat() * scale; - data.scaleX = input.readFloat(); - data.scaleY = input.readFloat(); - data.shearX = input.readFloat(); - data.shearY = input.readFloat(); - data.length = input.readFloat() * scale; - data.transformMode = SkeletonBinary.TransformModeValues[input.readInt(true)]; - data.skinRequired = input.readBoolean(); - if (nonessential) - core.Color.rgba8888ToColor(data.color, input.readInt32()); - skeletonData.bones.push(data); - } - n = input.readInt(true); - for (var i = 0; i < n; i++) { - var slotName = input.readString(); - var boneData = skeletonData.bones[input.readInt(true)]; - var data = new core.SlotData(i, slotName, boneData); - core.Color.rgba8888ToColor(data.color, input.readInt32()); - var darkColor = input.readInt32(); - if (darkColor != -1) - core.Color.rgb888ToColor(data.darkColor = new core.Color(), darkColor); - data.attachmentName = input.readStringRef(); - data.blendMode = SkeletonBinary.BlendModeValues[input.readInt(true)]; - skeletonData.slots.push(data); - } - n = input.readInt(true); - for (var i = 0, nn = void 0; i < n; i++) { - var data = new core.IkConstraintData(input.readString()); - data.order = input.readInt(true); - data.skinRequired = input.readBoolean(); - nn = input.readInt(true); - for (var ii = 0; ii < nn; ii++) - data.bones.push(skeletonData.bones[input.readInt(true)]); - data.target = skeletonData.bones[input.readInt(true)]; - data.mix = input.readFloat(); - data.softness = input.readFloat() * scale; - data.bendDirection = input.readByte(); - data.compress = input.readBoolean(); - data.stretch = input.readBoolean(); - data.uniform = input.readBoolean(); - skeletonData.ikConstraints.push(data); - } - n = input.readInt(true); - for (var i = 0, nn = void 0; i < n; i++) { - var data = new core.TransformConstraintData(input.readString()); - data.order = input.readInt(true); - data.skinRequired = input.readBoolean(); - nn = input.readInt(true); - for (var ii = 0; ii < nn; ii++) - data.bones.push(skeletonData.bones[input.readInt(true)]); - data.target = skeletonData.bones[input.readInt(true)]; - data.local = input.readBoolean(); - data.relative = input.readBoolean(); - data.offsetRotation = input.readFloat(); - data.offsetX = input.readFloat() * scale; - data.offsetY = input.readFloat() * scale; - data.offsetScaleX = input.readFloat(); - data.offsetScaleY = input.readFloat(); - data.offsetShearY = input.readFloat(); - data.rotateMix = input.readFloat(); - data.translateMix = input.readFloat(); - data.scaleMix = input.readFloat(); - data.shearMix = input.readFloat(); - skeletonData.transformConstraints.push(data); - } - n = input.readInt(true); - for (var i = 0, nn = void 0; i < n; i++) { - var data = new core.PathConstraintData(input.readString()); - data.order = input.readInt(true); - data.skinRequired = input.readBoolean(); - nn = input.readInt(true); - for (var ii = 0; ii < nn; ii++) - data.bones.push(skeletonData.bones[input.readInt(true)]); - data.target = skeletonData.slots[input.readInt(true)]; - data.positionMode = SkeletonBinary.PositionModeValues[input.readInt(true)]; - data.spacingMode = SkeletonBinary.SpacingModeValues[input.readInt(true)]; - data.rotateMode = SkeletonBinary.RotateModeValues[input.readInt(true)]; - data.offsetRotation = input.readFloat(); - data.position = input.readFloat(); - if (data.positionMode == core.PositionMode.Fixed) - data.position *= scale; - data.spacing = input.readFloat(); - if (data.spacingMode == core.SpacingMode.Length || data.spacingMode == core.SpacingMode.Fixed) - data.spacing *= scale; - data.rotateMix = input.readFloat(); - data.translateMix = input.readFloat(); - skeletonData.pathConstraints.push(data); - } - var defaultSkin = this.readSkin(input, skeletonData, true, nonessential); - if (defaultSkin != null) { - skeletonData.defaultSkin = defaultSkin; - skeletonData.skins.push(defaultSkin); - } - { - var i = skeletonData.skins.length; - core.Utils.setArraySize(skeletonData.skins, n = i + input.readInt(true)); - for (; i < n; i++) - skeletonData.skins[i] = this.readSkin(input, skeletonData, false, nonessential); - } - n = this.linkedMeshes.length; - for (var i = 0; i < n; i++) { - var linkedMesh = this.linkedMeshes[i]; - var skin = linkedMesh.skin == null ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin); - if (skin == null) - throw new Error("Skin not found: " + linkedMesh.skin); - var parent_3 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent); - if (parent_3 == null) - throw new Error("Parent mesh not found: " + linkedMesh.parent); - linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent_3 : linkedMesh.mesh; - linkedMesh.mesh.setParentMesh(parent_3); - } - this.linkedMeshes.length = 0; - n = input.readInt(true); - for (var i = 0; i < n; i++) { - var data = new core.EventData(input.readStringRef()); - data.intValue = input.readInt(false); - data.floatValue = input.readFloat(); - data.stringValue = input.readString(); - data.audioPath = input.readString(); - if (data.audioPath != null) { - data.volume = input.readFloat(); - data.balance = input.readFloat(); - } - skeletonData.events.push(data); - } - n = input.readInt(true); - for (var i = 0; i < n; i++) - skeletonData.animations.push(this.readAnimation(input, input.readString(), skeletonData)); - return skeletonData; - }; - SkeletonBinary.prototype.readSkin = function (input, skeletonData, defaultSkin, nonessential) { - var skin = null; - var slotCount = 0; - if (defaultSkin) { - slotCount = input.readInt(true); - if (slotCount == 0) - return null; - skin = new core.Skin("default"); - } - else { - skin = new core.Skin(input.readStringRef()); - skin.bones.length = input.readInt(true); - for (var i = 0, n = skin.bones.length; i < n; i++) - skin.bones[i] = skeletonData.bones[input.readInt(true)]; - for (var i = 0, n = input.readInt(true); i < n; i++) - skin.constraints.push(skeletonData.ikConstraints[input.readInt(true)]); - for (var i = 0, n = input.readInt(true); i < n; i++) - skin.constraints.push(skeletonData.transformConstraints[input.readInt(true)]); - for (var i = 0, n = input.readInt(true); i < n; i++) - skin.constraints.push(skeletonData.pathConstraints[input.readInt(true)]); - slotCount = input.readInt(true); - } - for (var i = 0; i < slotCount; i++) { - var slotIndex = input.readInt(true); - for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) { - var name_3 = input.readStringRef(); - var attachment = this.readAttachment(input, skeletonData, skin, slotIndex, name_3, nonessential); - if (attachment != null) - skin.setAttachment(slotIndex, name_3, attachment); - } - } - return skin; - }; - SkeletonBinary.prototype.readAttachment = function (input, skeletonData, skin, slotIndex, attachmentName, nonessential) { - var scale = this.scale; - var name = input.readStringRef(); - if (name == null) - name = attachmentName; - var typeIndex = input.readByte(); - var type = SkeletonBinary.AttachmentTypeValues[typeIndex]; - switch (type) { - case core.AttachmentType.Region: { - var path = input.readStringRef(); - var rotation = input.readFloat(); - var x = input.readFloat(); - var y = input.readFloat(); - var scaleX = input.readFloat(); - var scaleY = input.readFloat(); - var width = input.readFloat(); - var height = input.readFloat(); - var color = input.readInt32(); - if (path == null) - path = name; - var region = this.attachmentLoader.newRegionAttachment(skin, name, path); - if (region == null) - return null; - region.path = path; - region.x = x * scale; - region.y = y * scale; - region.scaleX = scaleX; - region.scaleY = scaleY; - region.rotation = rotation; - region.width = width * scale; - region.height = height * scale; - core.Color.rgba8888ToColor(region.color, color); - return region; - } - case core.AttachmentType.BoundingBox: { - var vertexCount = input.readInt(true); - var vertices = this.readVertices(input, vertexCount); - var color = nonessential ? input.readInt32() : 0; - var box = this.attachmentLoader.newBoundingBoxAttachment(skin, name); - if (box == null) - return null; - box.worldVerticesLength = vertexCount << 1; - box.vertices = vertices.vertices; - box.bones = vertices.bones; - if (nonessential) - core.Color.rgba8888ToColor(box.color, color); - return box; - } - case core.AttachmentType.Mesh: { - var path = input.readStringRef(); - var color = input.readInt32(); - var vertexCount = input.readInt(true); - var uvs = this.readFloatArray(input, vertexCount << 1, 1); - var triangles = this.readShortArray(input); - var vertices = this.readVertices(input, vertexCount); - var hullLength = input.readInt(true); - var edges = null; - var width = 0, height = 0; - if (nonessential) { - edges = this.readShortArray(input); - width = input.readFloat(); - height = input.readFloat(); - } - if (path == null) - path = name; - var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path); - if (mesh == null) - return null; - mesh.path = path; - core.Color.rgba8888ToColor(mesh.color, color); - mesh.bones = vertices.bones; - mesh.vertices = vertices.vertices; - mesh.worldVerticesLength = vertexCount << 1; - mesh.triangles = triangles; - mesh.regionUVs = new Float32Array(uvs); - mesh.hullLength = hullLength << 1; - if (nonessential) { - mesh.edges = edges; - mesh.width = width * scale; - mesh.height = height * scale; - } - return mesh; - } - case core.AttachmentType.LinkedMesh: { - var path = input.readStringRef(); - var color = input.readInt32(); - var skinName = input.readStringRef(); - var parent_4 = input.readStringRef(); - var inheritDeform = input.readBoolean(); - var width = 0, height = 0; - if (nonessential) { - width = input.readFloat(); - height = input.readFloat(); - } - if (path == null) - path = name; - var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path); - if (mesh == null) - return null; - mesh.path = path; - core.Color.rgba8888ToColor(mesh.color, color); - if (nonessential) { - mesh.width = width * scale; - mesh.height = height * scale; - } - this.linkedMeshes.push(new LinkedMesh(mesh, skinName, slotIndex, parent_4, inheritDeform)); - return mesh; - } - case core.AttachmentType.Path: { - var closed_1 = input.readBoolean(); - var constantSpeed = input.readBoolean(); - var vertexCount = input.readInt(true); - var vertices = this.readVertices(input, vertexCount); - var lengths = core.Utils.newArray(vertexCount / 3, 0); - for (var i = 0, n = lengths.length; i < n; i++) - lengths[i] = input.readFloat() * scale; - var color = nonessential ? input.readInt32() : 0; - var path = this.attachmentLoader.newPathAttachment(skin, name); - if (path == null) - return null; - path.closed = closed_1; - path.constantSpeed = constantSpeed; - path.worldVerticesLength = vertexCount << 1; - path.vertices = vertices.vertices; - path.bones = vertices.bones; - path.lengths = lengths; - if (nonessential) - core.Color.rgba8888ToColor(path.color, color); - return path; - } - case core.AttachmentType.Point: { - var rotation = input.readFloat(); - var x = input.readFloat(); - var y = input.readFloat(); - var color = nonessential ? input.readInt32() : 0; - var point = this.attachmentLoader.newPointAttachment(skin, name); - if (point == null) - return null; - point.x = x * scale; - point.y = y * scale; - point.rotation = rotation; - if (nonessential) - core.Color.rgba8888ToColor(point.color, color); - return point; - } - case core.AttachmentType.Clipping: { - var endSlotIndex = input.readInt(true); - var vertexCount = input.readInt(true); - var vertices = this.readVertices(input, vertexCount); - var color = nonessential ? input.readInt32() : 0; - var clip = this.attachmentLoader.newClippingAttachment(skin, name); - if (clip == null) - return null; - clip.endSlot = skeletonData.slots[endSlotIndex]; - clip.worldVerticesLength = vertexCount << 1; - clip.vertices = vertices.vertices; - clip.bones = vertices.bones; - if (nonessential) - core.Color.rgba8888ToColor(clip.color, color); - return clip; - } - } - return null; - }; - SkeletonBinary.prototype.readVertices = function (input, vertexCount) { - var verticesLength = vertexCount << 1; - var vertices = new Vertices(); - var scale = this.scale; - if (!input.readBoolean()) { - vertices.vertices = this.readFloatArray(input, verticesLength, scale); - return vertices; - } - var weights = new Array(); - var bonesArray = new Array(); - for (var i = 0; i < vertexCount; i++) { - var boneCount = input.readInt(true); - bonesArray.push(boneCount); - for (var ii = 0; ii < boneCount; ii++) { - bonesArray.push(input.readInt(true)); - weights.push(input.readFloat() * scale); - weights.push(input.readFloat() * scale); - weights.push(input.readFloat()); - } - } - vertices.vertices = core.Utils.toFloatArray(weights); - vertices.bones = bonesArray; - return vertices; - }; - SkeletonBinary.prototype.readFloatArray = function (input, n, scale) { - var array = new Array(n); - if (scale == 1) { - for (var i = 0; i < n; i++) - array[i] = input.readFloat(); - } - else { - for (var i = 0; i < n; i++) - array[i] = input.readFloat() * scale; - } - return array; - }; - SkeletonBinary.prototype.readShortArray = function (input) { - var n = input.readInt(true); - var array = new Array(n); - for (var i = 0; i < n; i++) - array[i] = input.readShort(); - return array; - }; - SkeletonBinary.prototype.readAnimation = function (input, name, skeletonData) { - var timelines = new Array(); - var scale = this.scale; - var duration = 0; - var tempColor1 = new core.Color(); - var tempColor2 = new core.Color(); - for (var i = 0, n = input.readInt(true); i < n; i++) { - var slotIndex = input.readInt(true); - for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) { - var timelineType = input.readByte(); - var frameCount = input.readInt(true); - switch (timelineType) { - case SkeletonBinary.SLOT_ATTACHMENT: { - var timeline = new core.AttachmentTimeline(frameCount); - timeline.slotIndex = slotIndex; - for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) - timeline.setFrame(frameIndex, input.readFloat(), input.readStringRef()); - timelines.push(timeline); - duration = Math.max(duration, timeline.frames[frameCount - 1]); - break; - } - case SkeletonBinary.SLOT_COLOR: { - var timeline = new core.ColorTimeline(frameCount); - timeline.slotIndex = slotIndex; - for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) { - var time = input.readFloat(); - core.Color.rgba8888ToColor(tempColor1, input.readInt32()); - timeline.setFrame(frameIndex, time, tempColor1.r, tempColor1.g, tempColor1.b, tempColor1.a); - if (frameIndex < frameCount - 1) - this.readCurve(input, frameIndex, timeline); - } - timelines.push(timeline); - duration = Math.max(duration, timeline.frames[(frameCount - 1) * core.ColorTimeline.ENTRIES]); - break; - } - case SkeletonBinary.SLOT_TWO_COLOR: { - var timeline = new core.TwoColorTimeline(frameCount); - timeline.slotIndex = slotIndex; - for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) { - var time = input.readFloat(); - core.Color.rgba8888ToColor(tempColor1, input.readInt32()); - core.Color.rgb888ToColor(tempColor2, input.readInt32()); - timeline.setFrame(frameIndex, time, tempColor1.r, tempColor1.g, tempColor1.b, tempColor1.a, tempColor2.r, tempColor2.g, tempColor2.b); - if (frameIndex < frameCount - 1) - this.readCurve(input, frameIndex, timeline); - } - timelines.push(timeline); - duration = Math.max(duration, timeline.frames[(frameCount - 1) * core.TwoColorTimeline.ENTRIES]); - break; - } - } - } - } - for (var i = 0, n = input.readInt(true); i < n; i++) { - var boneIndex = input.readInt(true); - for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) { - var timelineType = input.readByte(); - var frameCount = input.readInt(true); - switch (timelineType) { - case SkeletonBinary.BONE_ROTATE: { - var timeline = new core.RotateTimeline(frameCount); - timeline.boneIndex = boneIndex; - for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) { - timeline.setFrame(frameIndex, input.readFloat(), input.readFloat()); - if (frameIndex < frameCount - 1) - this.readCurve(input, frameIndex, timeline); - } - timelines.push(timeline); - duration = Math.max(duration, timeline.frames[(frameCount - 1) * core.RotateTimeline.ENTRIES]); - break; - } - case SkeletonBinary.BONE_TRANSLATE: - case SkeletonBinary.BONE_SCALE: - case SkeletonBinary.BONE_SHEAR: { - var timeline = void 0; - var timelineScale = 1; - if (timelineType == SkeletonBinary.BONE_SCALE) - timeline = new core.ScaleTimeline(frameCount); - else if (timelineType == SkeletonBinary.BONE_SHEAR) - timeline = new core.ShearTimeline(frameCount); - else { - timeline = new core.TranslateTimeline(frameCount); - timelineScale = scale; - } - timeline.boneIndex = boneIndex; - for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) { - timeline.setFrame(frameIndex, input.readFloat(), input.readFloat() * timelineScale, input.readFloat() * timelineScale); - if (frameIndex < frameCount - 1) - this.readCurve(input, frameIndex, timeline); - } - timelines.push(timeline); - duration = Math.max(duration, timeline.frames[(frameCount - 1) * core.TranslateTimeline.ENTRIES]); - break; - } - } - } - } - for (var i = 0, n = input.readInt(true); i < n; i++) { - var index = input.readInt(true); - var frameCount = input.readInt(true); - var timeline = new core.IkConstraintTimeline(frameCount); - timeline.ikConstraintIndex = index; - for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) { - timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readFloat() * scale, input.readByte(), input.readBoolean(), input.readBoolean()); - if (frameIndex < frameCount - 1) - this.readCurve(input, frameIndex, timeline); - } - timelines.push(timeline); - duration = Math.max(duration, timeline.frames[(frameCount - 1) * core.IkConstraintTimeline.ENTRIES]); - } - for (var i = 0, n = input.readInt(true); i < n; i++) { - var index = input.readInt(true); - var frameCount = input.readInt(true); - var timeline = new core.TransformConstraintTimeline(frameCount); - timeline.transformConstraintIndex = index; - for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) { - timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat()); - if (frameIndex < frameCount - 1) - this.readCurve(input, frameIndex, timeline); - } - timelines.push(timeline); - duration = Math.max(duration, timeline.frames[(frameCount - 1) * core.TransformConstraintTimeline.ENTRIES]); - } - for (var i = 0, n = input.readInt(true); i < n; i++) { - var index = input.readInt(true); - var data = skeletonData.pathConstraints[index]; - for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) { - var timelineType = input.readByte(); - var frameCount = input.readInt(true); - switch (timelineType) { - case SkeletonBinary.PATH_POSITION: - case SkeletonBinary.PATH_SPACING: { - var timeline = void 0; - var timelineScale = 1; - if (timelineType == SkeletonBinary.PATH_SPACING) { - timeline = new core.PathConstraintSpacingTimeline(frameCount); - if (data.spacingMode == core.SpacingMode.Length || data.spacingMode == core.SpacingMode.Fixed) - timelineScale = scale; - } - else { - timeline = new core.PathConstraintPositionTimeline(frameCount); - if (data.positionMode == core.PositionMode.Fixed) - timelineScale = scale; - } - timeline.pathConstraintIndex = index; - for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) { - timeline.setFrame(frameIndex, input.readFloat(), input.readFloat() * timelineScale); - if (frameIndex < frameCount - 1) - this.readCurve(input, frameIndex, timeline); - } - timelines.push(timeline); - duration = Math.max(duration, timeline.frames[(frameCount - 1) * core.PathConstraintPositionTimeline.ENTRIES]); - break; - } - case SkeletonBinary.PATH_MIX: { - var timeline = new core.PathConstraintMixTimeline(frameCount); - timeline.pathConstraintIndex = index; - for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) { - timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readFloat()); - if (frameIndex < frameCount - 1) - this.readCurve(input, frameIndex, timeline); - } - timelines.push(timeline); - duration = Math.max(duration, timeline.frames[(frameCount - 1) * core.PathConstraintMixTimeline.ENTRIES]); - break; - } - } - } - } - for (var i = 0, n = input.readInt(true); i < n; i++) { - var skin = skeletonData.skins[input.readInt(true)]; - for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) { - var slotIndex = input.readInt(true); - for (var iii = 0, nnn = input.readInt(true); iii < nnn; iii++) { - var attachment = skin.getAttachment(slotIndex, input.readStringRef()); - var weighted = attachment.bones != null; - var vertices = attachment.vertices; - var deformLength = weighted ? vertices.length / 3 * 2 : vertices.length; - var frameCount = input.readInt(true); - var timeline = new core.DeformTimeline(frameCount); - timeline.slotIndex = slotIndex; - timeline.attachment = attachment; - for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) { - var time = input.readFloat(); - var deform = void 0; - var end = input.readInt(true); - if (end == 0) - deform = weighted ? core.Utils.newFloatArray(deformLength) : vertices; - else { - deform = core.Utils.newFloatArray(deformLength); - var start = input.readInt(true); - end += start; - if (scale == 1) { - for (var v = start; v < end; v++) - deform[v] = input.readFloat(); - } - else { - for (var v = start; v < end; v++) - deform[v] = input.readFloat() * scale; - } - if (!weighted) { - for (var v = 0, vn = deform.length; v < vn; v++) - deform[v] += vertices[v]; - } - } - timeline.setFrame(frameIndex, time, deform); - if (frameIndex < frameCount - 1) - this.readCurve(input, frameIndex, timeline); - } - timelines.push(timeline); - duration = Math.max(duration, timeline.frames[frameCount - 1]); - } - } - } - var drawOrderCount = input.readInt(true); - if (drawOrderCount > 0) { - var timeline = new core.DrawOrderTimeline(drawOrderCount); - var slotCount = skeletonData.slots.length; - for (var i = 0; i < drawOrderCount; i++) { - var time = input.readFloat(); - var offsetCount = input.readInt(true); - var drawOrder = core.Utils.newArray(slotCount, 0); - for (var ii = slotCount - 1; ii >= 0; ii--) - drawOrder[ii] = -1; - var unchanged = core.Utils.newArray(slotCount - offsetCount, 0); - var originalIndex = 0, unchangedIndex = 0; - for (var ii = 0; ii < offsetCount; ii++) { - var slotIndex = input.readInt(true); - while (originalIndex != slotIndex) - unchanged[unchangedIndex++] = originalIndex++; - drawOrder[originalIndex + input.readInt(true)] = originalIndex++; - } - while (originalIndex < slotCount) - unchanged[unchangedIndex++] = originalIndex++; - for (var ii = slotCount - 1; ii >= 0; ii--) - if (drawOrder[ii] == -1) - drawOrder[ii] = unchanged[--unchangedIndex]; - timeline.setFrame(i, time, drawOrder); - } - timelines.push(timeline); - duration = Math.max(duration, timeline.frames[drawOrderCount - 1]); - } - var eventCount = input.readInt(true); - if (eventCount > 0) { - var timeline = new core.EventTimeline(eventCount); - for (var i = 0; i < eventCount; i++) { - var time = input.readFloat(); - var eventData = skeletonData.events[input.readInt(true)]; - var event_4 = new core.Event(time, eventData); - event_4.intValue = input.readInt(false); - event_4.floatValue = input.readFloat(); - event_4.stringValue = input.readBoolean() ? input.readString() : eventData.stringValue; - if (event_4.data.audioPath != null) { - event_4.volume = input.readFloat(); - event_4.balance = input.readFloat(); - } - timeline.setFrame(i, event_4); - } - timelines.push(timeline); - duration = Math.max(duration, timeline.frames[eventCount - 1]); - } - return new core.Animation(name, timelines, duration); - }; - SkeletonBinary.prototype.readCurve = function (input, frameIndex, timeline) { - switch (input.readByte()) { - case SkeletonBinary.CURVE_STEPPED: - timeline.setStepped(frameIndex); - break; - case SkeletonBinary.CURVE_BEZIER: - this.setCurve(timeline, frameIndex, input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat()); - break; - } - }; - SkeletonBinary.prototype.setCurve = function (timeline, frameIndex, cx1, cy1, cx2, cy2) { - timeline.setCurve(frameIndex, cx1, cy1, cx2, cy2); - }; - SkeletonBinary.AttachmentTypeValues = [0, 1, 2, 3, 4, 5, 6]; - SkeletonBinary.TransformModeValues = [core.TransformMode.Normal, core.TransformMode.OnlyTranslation, core.TransformMode.NoRotationOrReflection, core.TransformMode.NoScale, core.TransformMode.NoScaleOrReflection]; - SkeletonBinary.PositionModeValues = [core.PositionMode.Fixed, core.PositionMode.Percent]; - SkeletonBinary.SpacingModeValues = [core.SpacingMode.Length, core.SpacingMode.Fixed, core.SpacingMode.Percent]; - SkeletonBinary.RotateModeValues = [core.RotateMode.Tangent, core.RotateMode.Chain, core.RotateMode.ChainScale]; - SkeletonBinary.BlendModeValues = [core.BlendMode.Normal, core.BlendMode.Additive, core.BlendMode.Multiply, core.BlendMode.Screen]; - SkeletonBinary.BONE_ROTATE = 0; - SkeletonBinary.BONE_TRANSLATE = 1; - SkeletonBinary.BONE_SCALE = 2; - SkeletonBinary.BONE_SHEAR = 3; - SkeletonBinary.SLOT_ATTACHMENT = 0; - SkeletonBinary.SLOT_COLOR = 1; - SkeletonBinary.SLOT_TWO_COLOR = 2; - SkeletonBinary.PATH_POSITION = 0; - SkeletonBinary.PATH_SPACING = 1; - SkeletonBinary.PATH_MIX = 2; - SkeletonBinary.CURVE_LINEAR = 0; - SkeletonBinary.CURVE_STEPPED = 1; - SkeletonBinary.CURVE_BEZIER = 2; - return SkeletonBinary; - }()); - core.SkeletonBinary = SkeletonBinary; - var BinaryInput = (function () { - function BinaryInput(data, strings, index, buffer) { - if (strings === void 0) { strings = new Array(); } - if (index === void 0) { index = 0; } - if (buffer === void 0) { buffer = new DataView(data.buffer); } - this.strings = strings; - this.index = index; - this.buffer = buffer; - } - BinaryInput.prototype.readByte = function () { - return this.buffer.getInt8(this.index++); - }; - BinaryInput.prototype.readShort = function () { - var value = this.buffer.getInt16(this.index); - this.index += 2; - return value; - }; - BinaryInput.prototype.readInt32 = function () { - var value = this.buffer.getInt32(this.index); - this.index += 4; - return value; - }; - BinaryInput.prototype.readInt = function (optimizePositive) { - var b = this.readByte(); - var result = b & 0x7F; - if ((b & 0x80) != 0) { - b = this.readByte(); - result |= (b & 0x7F) << 7; - if ((b & 0x80) != 0) { - b = this.readByte(); - result |= (b & 0x7F) << 14; - if ((b & 0x80) != 0) { - b = this.readByte(); - result |= (b & 0x7F) << 21; - if ((b & 0x80) != 0) { - b = this.readByte(); - result |= (b & 0x7F) << 28; - } - } - } - } - return optimizePositive ? result : ((result >>> 1) ^ -(result & 1)); - }; - BinaryInput.prototype.readStringRef = function () { - var index = this.readInt(true); - return index == 0 ? null : this.strings[index - 1]; - }; - BinaryInput.prototype.readString = function () { - var byteCount = this.readInt(true); - switch (byteCount) { - case 0: - return null; - case 1: - return ""; - } - byteCount--; - var chars = ""; - var charCount = 0; - for (var i = 0; i < byteCount;) { - var b = this.readByte(); - switch (b >> 4) { - case 12: - case 13: - chars += String.fromCharCode(((b & 0x1F) << 6 | this.readByte() & 0x3F)); - i += 2; - break; - case 14: - chars += String.fromCharCode(((b & 0x0F) << 12 | (this.readByte() & 0x3F) << 6 | this.readByte() & 0x3F)); - i += 3; - break; - default: - chars += String.fromCharCode(b); - i++; - } - } - return chars; - }; - BinaryInput.prototype.readFloat = function () { - var value = this.buffer.getFloat32(this.index); - this.index += 4; - return value; - }; - BinaryInput.prototype.readBoolean = function () { - return this.readByte() != 0; - }; - return BinaryInput; - }()); - var LinkedMesh = (function () { - function LinkedMesh(mesh, skin, slotIndex, parent, inheritDeform) { - this.mesh = mesh; - this.skin = skin; - this.slotIndex = slotIndex; - this.parent = parent; - this.inheritDeform = inheritDeform; - } - return LinkedMesh; - }()); - var Vertices = (function () { - function Vertices(bones, vertices) { - if (bones === void 0) { bones = null; } - if (vertices === void 0) { vertices = null; } - this.bones = bones; - this.vertices = vertices; - } - return Vertices; - }()); - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var SkeletonBounds = (function () { - function SkeletonBounds() { - this.minX = 0; - this.minY = 0; - this.maxX = 0; - this.maxY = 0; - this.boundingBoxes = new Array(); - this.polygons = new Array(); - this.polygonPool = new core.Pool(function () { - return core.Utils.newFloatArray(16); - }); - } - SkeletonBounds.prototype.update = function (skeleton, updateAabb) { - if (skeleton == null) - throw new Error("skeleton cannot be null."); - var boundingBoxes = this.boundingBoxes; - var polygons = this.polygons; - var polygonPool = this.polygonPool; - var slots = skeleton.slots; - var slotCount = slots.length; - boundingBoxes.length = 0; - polygonPool.freeAll(polygons); - polygons.length = 0; - for (var i = 0; i < slotCount; i++) { - var slot = slots[i]; - if (!slot.bone.active) - continue; - var attachment = slot.getAttachment(); - if (attachment instanceof core.BoundingBoxAttachment) { - var boundingBox = attachment; - boundingBoxes.push(boundingBox); - var polygon = polygonPool.obtain(); - if (polygon.length != boundingBox.worldVerticesLength) { - polygon = core.Utils.newFloatArray(boundingBox.worldVerticesLength); - } - polygons.push(polygon); - boundingBox.computeWorldVertices(slot, 0, boundingBox.worldVerticesLength, polygon, 0, 2); - } - } - if (updateAabb) { - this.aabbCompute(); - } - else { - this.minX = Number.POSITIVE_INFINITY; - this.minY = Number.POSITIVE_INFINITY; - this.maxX = Number.NEGATIVE_INFINITY; - this.maxY = Number.NEGATIVE_INFINITY; - } - }; - SkeletonBounds.prototype.aabbCompute = function () { - var minX = Number.POSITIVE_INFINITY, minY = Number.POSITIVE_INFINITY, maxX = Number.NEGATIVE_INFINITY, maxY = Number.NEGATIVE_INFINITY; - var polygons = this.polygons; - for (var i = 0, n = polygons.length; i < n; i++) { - var polygon = polygons[i]; - var vertices = polygon; - for (var ii = 0, nn = polygon.length; ii < nn; ii += 2) { - var x = vertices[ii]; - var y = vertices[ii + 1]; - minX = Math.min(minX, x); - minY = Math.min(minY, y); - maxX = Math.max(maxX, x); - maxY = Math.max(maxY, y); - } - } - this.minX = minX; - this.minY = minY; - this.maxX = maxX; - this.maxY = maxY; - }; - SkeletonBounds.prototype.aabbContainsPoint = function (x, y) { - return x >= this.minX && x <= this.maxX && y >= this.minY && y <= this.maxY; - }; - SkeletonBounds.prototype.aabbIntersectsSegment = function (x1, y1, x2, y2) { - var minX = this.minX; - var minY = this.minY; - var maxX = this.maxX; - var maxY = this.maxY; - if ((x1 <= minX && x2 <= minX) || (y1 <= minY && y2 <= minY) || (x1 >= maxX && x2 >= maxX) || (y1 >= maxY && y2 >= maxY)) - return false; - var m = (y2 - y1) / (x2 - x1); - var y = m * (minX - x1) + y1; - if (y > minY && y < maxY) - return true; - y = m * (maxX - x1) + y1; - if (y > minY && y < maxY) - return true; - var x = (minY - y1) / m + x1; - if (x > minX && x < maxX) - return true; - x = (maxY - y1) / m + x1; - if (x > minX && x < maxX) - return true; - return false; - }; - SkeletonBounds.prototype.aabbIntersectsSkeleton = function (bounds) { - return this.minX < bounds.maxX && this.maxX > bounds.minX && this.minY < bounds.maxY && this.maxY > bounds.minY; - }; - SkeletonBounds.prototype.containsPoint = function (x, y) { - var polygons = this.polygons; - for (var i = 0, n = polygons.length; i < n; i++) - if (this.containsPointPolygon(polygons[i], x, y)) - return this.boundingBoxes[i]; - return null; - }; - SkeletonBounds.prototype.containsPointPolygon = function (polygon, x, y) { - var vertices = polygon; - var nn = polygon.length; - var prevIndex = nn - 2; - var inside = false; - for (var ii = 0; ii < nn; ii += 2) { - var vertexY = vertices[ii + 1]; - var prevY = vertices[prevIndex + 1]; - if ((vertexY < y && prevY >= y) || (prevY < y && vertexY >= y)) { - var vertexX = vertices[ii]; - if (vertexX + (y - vertexY) / (prevY - vertexY) * (vertices[prevIndex] - vertexX) < x) - inside = !inside; - } - prevIndex = ii; - } - return inside; - }; - SkeletonBounds.prototype.intersectsSegment = function (x1, y1, x2, y2) { - var polygons = this.polygons; - for (var i = 0, n = polygons.length; i < n; i++) - if (this.intersectsSegmentPolygon(polygons[i], x1, y1, x2, y2)) - return this.boundingBoxes[i]; - return null; - }; - SkeletonBounds.prototype.intersectsSegmentPolygon = function (polygon, x1, y1, x2, y2) { - var vertices = polygon; - var nn = polygon.length; - var width12 = x1 - x2, height12 = y1 - y2; - var det1 = x1 * y2 - y1 * x2; - var x3 = vertices[nn - 2], y3 = vertices[nn - 1]; - for (var ii = 0; ii < nn; ii += 2) { - var x4 = vertices[ii], y4 = vertices[ii + 1]; - var det2 = x3 * y4 - y3 * x4; - var width34 = x3 - x4, height34 = y3 - y4; - var det3 = width12 * height34 - height12 * width34; - var x = (det1 * width34 - width12 * det2) / det3; - if (((x >= x3 && x <= x4) || (x >= x4 && x <= x3)) && ((x >= x1 && x <= x2) || (x >= x2 && x <= x1))) { - var y = (det1 * height34 - height12 * det2) / det3; - if (((y >= y3 && y <= y4) || (y >= y4 && y <= y3)) && ((y >= y1 && y <= y2) || (y >= y2 && y <= y1))) - return true; - } - x3 = x4; - y3 = y4; - } - return false; - }; - SkeletonBounds.prototype.getPolygon = function (boundingBox) { - if (boundingBox == null) - throw new Error("boundingBox cannot be null."); - var index = this.boundingBoxes.indexOf(boundingBox); - return index == -1 ? null : this.polygons[index]; - }; - SkeletonBounds.prototype.getWidth = function () { - return this.maxX - this.minX; - }; - SkeletonBounds.prototype.getHeight = function () { - return this.maxY - this.minY; - }; - return SkeletonBounds; - }()); - core.SkeletonBounds = SkeletonBounds; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var SkeletonClipping = (function () { - function SkeletonClipping() { - this.triangulator = new core.Triangulator(); - this.clippingPolygon = new Array(); - this.clipOutput = new Array(); - this.clippedVertices = new Array(); - this.clippedTriangles = new Array(); - this.scratch = new Array(); - } - SkeletonClipping.prototype.clipStart = function (slot, clip) { - if (this.clipAttachment != null) - return 0; - this.clipAttachment = clip; - var n = clip.worldVerticesLength; - var vertices = core.Utils.setArraySize(this.clippingPolygon, n); - clip.computeWorldVertices(slot, 0, n, vertices, 0, 2); - var clippingPolygon = this.clippingPolygon; - SkeletonClipping.makeClockwise(clippingPolygon); - var clippingPolygons = this.clippingPolygons = this.triangulator.decompose(clippingPolygon, this.triangulator.triangulate(clippingPolygon)); - for (var i = 0, n_2 = clippingPolygons.length; i < n_2; i++) { - var polygon = clippingPolygons[i]; - SkeletonClipping.makeClockwise(polygon); - polygon.push(polygon[0]); - polygon.push(polygon[1]); - } - return clippingPolygons.length; - }; - SkeletonClipping.prototype.clipEndWithSlot = function (slot) { - if (this.clipAttachment != null && this.clipAttachment.endSlot == slot.data) - this.clipEnd(); - }; - SkeletonClipping.prototype.clipEnd = function () { - if (this.clipAttachment == null) - return; - this.clipAttachment = null; - this.clippingPolygons = null; - this.clippedVertices.length = 0; - this.clippedTriangles.length = 0; - this.clippingPolygon.length = 0; - }; - SkeletonClipping.prototype.isClipping = function () { - return this.clipAttachment != null; - }; - SkeletonClipping.prototype.clipTriangles = function (vertices, verticesLength, triangles, trianglesLength, uvs, light, dark, twoColor) { - var clipOutput = this.clipOutput, clippedVertices = this.clippedVertices; - var clippedTriangles = this.clippedTriangles; - var polygons = this.clippingPolygons; - var polygonsCount = this.clippingPolygons.length; - var vertexSize = twoColor ? 12 : 8; - var index = 0; - clippedVertices.length = 0; - clippedTriangles.length = 0; - outer: for (var i = 0; i < trianglesLength; i += 3) { - var vertexOffset = triangles[i] << 1; - var x1 = vertices[vertexOffset], y1 = vertices[vertexOffset + 1]; - var u1 = uvs[vertexOffset], v1 = uvs[vertexOffset + 1]; - vertexOffset = triangles[i + 1] << 1; - var x2 = vertices[vertexOffset], y2 = vertices[vertexOffset + 1]; - var u2 = uvs[vertexOffset], v2 = uvs[vertexOffset + 1]; - vertexOffset = triangles[i + 2] << 1; - var x3 = vertices[vertexOffset], y3 = vertices[vertexOffset + 1]; - var u3 = uvs[vertexOffset], v3 = uvs[vertexOffset + 1]; - for (var p = 0; p < polygonsCount; p++) { - var s = clippedVertices.length; - if (this.clip(x1, y1, x2, y2, x3, y3, polygons[p], clipOutput)) { - var clipOutputLength = clipOutput.length; - if (clipOutputLength == 0) - continue; - var d0 = y2 - y3, d1 = x3 - x2, d2 = x1 - x3, d4 = y3 - y1; - var d = 1 / (d0 * d2 + d1 * (y1 - y3)); - var clipOutputCount = clipOutputLength >> 1; - var clipOutputItems = this.clipOutput; - var clippedVerticesItems = core.Utils.setArraySize(clippedVertices, s + clipOutputCount * vertexSize); - for (var ii = 0; ii < clipOutputLength; ii += 2) { - var x = clipOutputItems[ii], y = clipOutputItems[ii + 1]; - clippedVerticesItems[s] = x; - clippedVerticesItems[s + 1] = y; - clippedVerticesItems[s + 2] = light.r; - clippedVerticesItems[s + 3] = light.g; - clippedVerticesItems[s + 4] = light.b; - clippedVerticesItems[s + 5] = light.a; - var c0 = x - x3, c1 = y - y3; - var a = (d0 * c0 + d1 * c1) * d; - var b = (d4 * c0 + d2 * c1) * d; - var c = 1 - a - b; - clippedVerticesItems[s + 6] = u1 * a + u2 * b + u3 * c; - clippedVerticesItems[s + 7] = v1 * a + v2 * b + v3 * c; - if (twoColor) { - clippedVerticesItems[s + 8] = dark.r; - clippedVerticesItems[s + 9] = dark.g; - clippedVerticesItems[s + 10] = dark.b; - clippedVerticesItems[s + 11] = dark.a; - } - s += vertexSize; - } - s = clippedTriangles.length; - var clippedTrianglesItems = core.Utils.setArraySize(clippedTriangles, s + 3 * (clipOutputCount - 2)); - clipOutputCount--; - for (var ii = 1; ii < clipOutputCount; ii++) { - clippedTrianglesItems[s] = index; - clippedTrianglesItems[s + 1] = (index + ii); - clippedTrianglesItems[s + 2] = (index + ii + 1); - s += 3; - } - index += clipOutputCount + 1; - } - else { - var clippedVerticesItems = core.Utils.setArraySize(clippedVertices, s + 3 * vertexSize); - clippedVerticesItems[s] = x1; - clippedVerticesItems[s + 1] = y1; - clippedVerticesItems[s + 2] = light.r; - clippedVerticesItems[s + 3] = light.g; - clippedVerticesItems[s + 4] = light.b; - clippedVerticesItems[s + 5] = light.a; - if (!twoColor) { - clippedVerticesItems[s + 6] = u1; - clippedVerticesItems[s + 7] = v1; - clippedVerticesItems[s + 8] = x2; - clippedVerticesItems[s + 9] = y2; - clippedVerticesItems[s + 10] = light.r; - clippedVerticesItems[s + 11] = light.g; - clippedVerticesItems[s + 12] = light.b; - clippedVerticesItems[s + 13] = light.a; - clippedVerticesItems[s + 14] = u2; - clippedVerticesItems[s + 15] = v2; - clippedVerticesItems[s + 16] = x3; - clippedVerticesItems[s + 17] = y3; - clippedVerticesItems[s + 18] = light.r; - clippedVerticesItems[s + 19] = light.g; - clippedVerticesItems[s + 20] = light.b; - clippedVerticesItems[s + 21] = light.a; - clippedVerticesItems[s + 22] = u3; - clippedVerticesItems[s + 23] = v3; - } - else { - clippedVerticesItems[s + 6] = u1; - clippedVerticesItems[s + 7] = v1; - clippedVerticesItems[s + 8] = dark.r; - clippedVerticesItems[s + 9] = dark.g; - clippedVerticesItems[s + 10] = dark.b; - clippedVerticesItems[s + 11] = dark.a; - clippedVerticesItems[s + 12] = x2; - clippedVerticesItems[s + 13] = y2; - clippedVerticesItems[s + 14] = light.r; - clippedVerticesItems[s + 15] = light.g; - clippedVerticesItems[s + 16] = light.b; - clippedVerticesItems[s + 17] = light.a; - clippedVerticesItems[s + 18] = u2; - clippedVerticesItems[s + 19] = v2; - clippedVerticesItems[s + 20] = dark.r; - clippedVerticesItems[s + 21] = dark.g; - clippedVerticesItems[s + 22] = dark.b; - clippedVerticesItems[s + 23] = dark.a; - clippedVerticesItems[s + 24] = x3; - clippedVerticesItems[s + 25] = y3; - clippedVerticesItems[s + 26] = light.r; - clippedVerticesItems[s + 27] = light.g; - clippedVerticesItems[s + 28] = light.b; - clippedVerticesItems[s + 29] = light.a; - clippedVerticesItems[s + 30] = u3; - clippedVerticesItems[s + 31] = v3; - clippedVerticesItems[s + 32] = dark.r; - clippedVerticesItems[s + 33] = dark.g; - clippedVerticesItems[s + 34] = dark.b; - clippedVerticesItems[s + 35] = dark.a; - } - s = clippedTriangles.length; - var clippedTrianglesItems = core.Utils.setArraySize(clippedTriangles, s + 3); - clippedTrianglesItems[s] = index; - clippedTrianglesItems[s + 1] = (index + 1); - clippedTrianglesItems[s + 2] = (index + 2); - index += 3; - continue outer; - } - } - } - }; - SkeletonClipping.prototype.clip = function (x1, y1, x2, y2, x3, y3, clippingArea, output) { - var originalOutput = output; - var clipped = false; - var input = null; - if (clippingArea.length % 4 >= 2) { - input = output; - output = this.scratch; - } - else - input = this.scratch; - input.length = 0; - input.push(x1); - input.push(y1); - input.push(x2); - input.push(y2); - input.push(x3); - input.push(y3); - input.push(x1); - input.push(y1); - output.length = 0; - var clippingVertices = clippingArea; - var clippingVerticesLast = clippingArea.length - 4; - for (var i = 0;; i += 2) { - var edgeX = clippingVertices[i], edgeY = clippingVertices[i + 1]; - var edgeX2 = clippingVertices[i + 2], edgeY2 = clippingVertices[i + 3]; - var deltaX = edgeX - edgeX2, deltaY = edgeY - edgeY2; - var inputVertices = input; - var inputVerticesLength = input.length - 2, outputStart = output.length; - for (var ii = 0; ii < inputVerticesLength; ii += 2) { - var inputX = inputVertices[ii], inputY = inputVertices[ii + 1]; - var inputX2 = inputVertices[ii + 2], inputY2 = inputVertices[ii + 3]; - var side2 = deltaX * (inputY2 - edgeY2) - deltaY * (inputX2 - edgeX2) > 0; - if (deltaX * (inputY - edgeY2) - deltaY * (inputX - edgeX2) > 0) { - if (side2) { - output.push(inputX2); - output.push(inputY2); - continue; - } - var c0 = inputY2 - inputY, c2 = inputX2 - inputX; - var ua = (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / (c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY)); - output.push(edgeX + (edgeX2 - edgeX) * ua); - output.push(edgeY + (edgeY2 - edgeY) * ua); - } - else if (side2) { - var c0 = inputY2 - inputY, c2 = inputX2 - inputX; - var ua = (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / (c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY)); - output.push(edgeX + (edgeX2 - edgeX) * ua); - output.push(edgeY + (edgeY2 - edgeY) * ua); - output.push(inputX2); - output.push(inputY2); - } - clipped = true; - } - if (outputStart == output.length) { - originalOutput.length = 0; - return true; - } - output.push(output[0]); - output.push(output[1]); - if (i == clippingVerticesLast) - break; - var temp = output; - output = input; - output.length = 0; - input = temp; - } - if (originalOutput != output) { - originalOutput.length = 0; - for (var i = 0, n = output.length - 2; i < n; i++) - originalOutput[i] = output[i]; - } - else - originalOutput.length = originalOutput.length - 2; - return clipped; - }; - SkeletonClipping.makeClockwise = function (polygon) { - var vertices = polygon; - var verticeslength = polygon.length; - var area = vertices[verticeslength - 2] * vertices[1] - vertices[0] * vertices[verticeslength - 1], p1x = 0, p1y = 0, p2x = 0, p2y = 0; - for (var i = 0, n = verticeslength - 3; i < n; i += 2) { - p1x = vertices[i]; - p1y = vertices[i + 1]; - p2x = vertices[i + 2]; - p2y = vertices[i + 3]; - area += p1x * p2y - p2x * p1y; - } - if (area < 0) - return; - for (var i = 0, lastX = verticeslength - 2, n = verticeslength >> 1; i < n; i += 2) { - var x = vertices[i], y = vertices[i + 1]; - var other = lastX - i; - vertices[i] = vertices[other]; - vertices[i + 1] = vertices[other + 1]; - vertices[other] = x; - vertices[other + 1] = y; - } - }; - return SkeletonClipping; - }()); - core.SkeletonClipping = SkeletonClipping; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var SkeletonData = (function () { - function SkeletonData() { - this.bones = new Array(); - this.slots = new Array(); - this.skins = new Array(); - this.events = new Array(); - this.animations = new Array(); - this.ikConstraints = new Array(); - this.transformConstraints = new Array(); - this.pathConstraints = new Array(); - this.fps = 0; - } - SkeletonData.prototype.findBone = function (boneName) { - if (boneName == null) - throw new Error("boneName cannot be null."); - var bones = this.bones; - for (var i = 0, n = bones.length; i < n; i++) { - var bone = bones[i]; - if (bone.name == boneName) - return bone; - } - return null; - }; - SkeletonData.prototype.findBoneIndex = function (boneName) { - if (boneName == null) - throw new Error("boneName cannot be null."); - var bones = this.bones; - for (var i = 0, n = bones.length; i < n; i++) - if (bones[i].name == boneName) - return i; - return -1; - }; - SkeletonData.prototype.findSlot = function (slotName) { - if (slotName == null) - throw new Error("slotName cannot be null."); - var slots = this.slots; - for (var i = 0, n = slots.length; i < n; i++) { - var slot = slots[i]; - if (slot.name == slotName) - return slot; - } - return null; - }; - SkeletonData.prototype.findSlotIndex = function (slotName) { - if (slotName == null) - throw new Error("slotName cannot be null."); - var slots = this.slots; - for (var i = 0, n = slots.length; i < n; i++) - if (slots[i].name == slotName) - return i; - return -1; - }; - SkeletonData.prototype.findSkin = function (skinName) { - if (skinName == null) - throw new Error("skinName cannot be null."); - var skins = this.skins; - for (var i = 0, n = skins.length; i < n; i++) { - var skin = skins[i]; - if (skin.name == skinName) - return skin; - } - return null; - }; - SkeletonData.prototype.findEvent = function (eventDataName) { - if (eventDataName == null) - throw new Error("eventDataName cannot be null."); - var events = this.events; - for (var i = 0, n = events.length; i < n; i++) { - var event_5 = events[i]; - if (event_5.name == eventDataName) - return event_5; - } - return null; - }; - SkeletonData.prototype.findAnimation = function (animationName) { - if (animationName == null) - throw new Error("animationName cannot be null."); - var animations = this.animations; - for (var i = 0, n = animations.length; i < n; i++) { - var animation = animations[i]; - if (animation.name == animationName) - return animation; - } - return null; - }; - SkeletonData.prototype.findIkConstraint = function (constraintName) { - if (constraintName == null) - throw new Error("constraintName cannot be null."); - var ikConstraints = this.ikConstraints; - for (var i = 0, n = ikConstraints.length; i < n; i++) { - var constraint = ikConstraints[i]; - if (constraint.name == constraintName) - return constraint; - } - return null; - }; - SkeletonData.prototype.findTransformConstraint = function (constraintName) { - if (constraintName == null) - throw new Error("constraintName cannot be null."); - var transformConstraints = this.transformConstraints; - for (var i = 0, n = transformConstraints.length; i < n; i++) { - var constraint = transformConstraints[i]; - if (constraint.name == constraintName) - return constraint; - } - return null; - }; - SkeletonData.prototype.findPathConstraint = function (constraintName) { - if (constraintName == null) - throw new Error("constraintName cannot be null."); - var pathConstraints = this.pathConstraints; - for (var i = 0, n = pathConstraints.length; i < n; i++) { - var constraint = pathConstraints[i]; - if (constraint.name == constraintName) - return constraint; - } - return null; - }; - SkeletonData.prototype.findPathConstraintIndex = function (pathConstraintName) { - if (pathConstraintName == null) - throw new Error("pathConstraintName cannot be null."); - var pathConstraints = this.pathConstraints; - for (var i = 0, n = pathConstraints.length; i < n; i++) - if (pathConstraints[i].name == pathConstraintName) - return i; - return -1; - }; - return SkeletonData; - }()); - core.SkeletonData = SkeletonData; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - core.FAIL_ON_NON_EXISTING_SKIN = false; - var SkeletonJson = (function () { - function SkeletonJson(attachmentLoader) { - this.scale = 1; - this.linkedMeshes = new Array(); - this.attachmentLoader = attachmentLoader; - } - SkeletonJson.prototype.readSkeletonData = function (json) { - var scale = this.scale; - var skeletonData = new core.SkeletonData(); - var root = typeof (json) === "string" ? JSON.parse(json) : json; - var skeletonMap = root.skeleton; - if (skeletonMap != null) { - skeletonData.hash = skeletonMap.hash; - skeletonData.version = skeletonMap.spine; - if (skeletonData.version.substr(0, 3) !== '3.8') { - var error = "PixiJS Spine plugin supports only format for Spine 3.8. Your model has version " + skeletonMap.spine + ". Please look in pixi-spine repository README for another branch."; - console.error(error); - } - if (skeletonData.version === '3.8.75') { - var error = "Unsupported skeleton data, 3.8.75 is deprecated, please export with a newer version of Spine."; - console.error(error); - } - skeletonData.x = skeletonMap.x; - skeletonData.y = skeletonMap.y; - skeletonData.width = skeletonMap.width; - skeletonData.height = skeletonMap.height; - skeletonData.fps = skeletonMap.fps; - skeletonData.imagesPath = skeletonMap.images; - } - if (root.bones) { - for (var i = 0; i < root.bones.length; i++) { - var boneMap = root.bones[i]; - var parent_5 = null; - var parentName = this.getValue(boneMap, "parent", null); - if (parentName != null) { - parent_5 = skeletonData.findBone(parentName); - if (parent_5 == null) - throw new Error("Parent bone not found: " + parentName); - } - var data = new core.BoneData(skeletonData.bones.length, boneMap.name, parent_5); - data.length = this.getValue(boneMap, "length", 0) * scale; - data.x = this.getValue(boneMap, "x", 0) * scale; - data.y = this.getValue(boneMap, "y", 0) * scale; - data.rotation = this.getValue(boneMap, "rotation", 0); - data.scaleX = this.getValue(boneMap, "scaleX", 1); - data.scaleY = this.getValue(boneMap, "scaleY", 1); - data.shearX = this.getValue(boneMap, "shearX", 0); - data.shearY = this.getValue(boneMap, "shearY", 0); - data.transformMode = SkeletonJson.transformModeFromString(this.getValue(boneMap, "transform", "normal")); - data.skinRequired = this.getValue(boneMap, "skin", false); - skeletonData.bones.push(data); - } - } - if (root.slots) { - for (var i = 0; i < root.slots.length; i++) { - var slotMap = root.slots[i]; - var slotName = slotMap.name; - var boneName = slotMap.bone; - var boneData = skeletonData.findBone(boneName); - if (boneData == null) - throw new Error("Slot bone not found: " + boneName); - var data = new core.SlotData(skeletonData.slots.length, slotName, boneData); - var color = this.getValue(slotMap, "color", null); - if (color != null) - data.color.setFromString(color); - var dark = this.getValue(slotMap, "dark", null); - if (dark != null) { - data.darkColor = new core.Color(1, 1, 1, 1); - data.darkColor.setFromString(dark); - } - data.attachmentName = this.getValue(slotMap, "attachment", null); - data.blendMode = SkeletonJson.blendModeFromString(this.getValue(slotMap, "blend", "normal")); - skeletonData.slots.push(data); - } - } - if (root.ik) { - for (var i = 0; i < root.ik.length; i++) { - var constraintMap = root.ik[i]; - var data = new core.IkConstraintData(constraintMap.name); - data.order = this.getValue(constraintMap, "order", 0); - data.skinRequired = this.getValue(constraintMap, "skin", false); - for (var j = 0; j < constraintMap.bones.length; j++) { - var boneName = constraintMap.bones[j]; - var bone = skeletonData.findBone(boneName); - if (bone == null) - throw new Error("IK bone not found: " + boneName); - data.bones.push(bone); - } - var targetName = constraintMap.target; - data.target = skeletonData.findBone(targetName); - if (data.target == null) - throw new Error("IK target bone not found: " + targetName); - data.mix = this.getValue(constraintMap, "mix", 1); - data.softness = this.getValue(constraintMap, "softness", 0) * scale; - data.bendDirection = this.getValue(constraintMap, "bendPositive", true) ? 1 : -1; - data.compress = this.getValue(constraintMap, "compress", false); - data.stretch = this.getValue(constraintMap, "stretch", false); - data.uniform = this.getValue(constraintMap, "uniform", false); - skeletonData.ikConstraints.push(data); - } - } - if (root.transform) { - for (var i = 0; i < root.transform.length; i++) { - var constraintMap = root.transform[i]; - var data = new core.TransformConstraintData(constraintMap.name); - data.order = this.getValue(constraintMap, "order", 0); - data.skinRequired = this.getValue(constraintMap, "skin", false); - for (var j = 0; j < constraintMap.bones.length; j++) { - var boneName = constraintMap.bones[j]; - var bone = skeletonData.findBone(boneName); - if (bone == null) - throw new Error("Transform constraint bone not found: " + boneName); - data.bones.push(bone); - } - var targetName = constraintMap.target; - data.target = skeletonData.findBone(targetName); - if (data.target == null) - throw new Error("Transform constraint target bone not found: " + targetName); - data.local = this.getValue(constraintMap, "local", false); - data.relative = this.getValue(constraintMap, "relative", false); - data.offsetRotation = this.getValue(constraintMap, "rotation", 0); - data.offsetX = this.getValue(constraintMap, "x", 0) * scale; - data.offsetY = this.getValue(constraintMap, "y", 0) * scale; - data.offsetScaleX = this.getValue(constraintMap, "scaleX", 0); - data.offsetScaleY = this.getValue(constraintMap, "scaleY", 0); - data.offsetShearY = this.getValue(constraintMap, "shearY", 0); - data.rotateMix = this.getValue(constraintMap, "rotateMix", 1); - data.translateMix = this.getValue(constraintMap, "translateMix", 1); - data.scaleMix = this.getValue(constraintMap, "scaleMix", 1); - data.shearMix = this.getValue(constraintMap, "shearMix", 1); - skeletonData.transformConstraints.push(data); - } - } - if (root.path) { - for (var i = 0; i < root.path.length; i++) { - var constraintMap = root.path[i]; - var data = new core.PathConstraintData(constraintMap.name); - data.order = this.getValue(constraintMap, "order", 0); - data.skinRequired = this.getValue(constraintMap, "skin", false); - for (var j = 0; j < constraintMap.bones.length; j++) { - var boneName = constraintMap.bones[j]; - var bone = skeletonData.findBone(boneName); - if (bone == null) - throw new Error("Transform constraint bone not found: " + boneName); - data.bones.push(bone); - } - var targetName = constraintMap.target; - data.target = skeletonData.findSlot(targetName); - if (data.target == null) - throw new Error("Path target slot not found: " + targetName); - data.positionMode = SkeletonJson.positionModeFromString(this.getValue(constraintMap, "positionMode", "percent")); - data.spacingMode = SkeletonJson.spacingModeFromString(this.getValue(constraintMap, "spacingMode", "length")); - data.rotateMode = SkeletonJson.rotateModeFromString(this.getValue(constraintMap, "rotateMode", "tangent")); - data.offsetRotation = this.getValue(constraintMap, "rotation", 0); - data.position = this.getValue(constraintMap, "position", 0); - if (data.positionMode == core.PositionMode.Fixed) - data.position *= scale; - data.spacing = this.getValue(constraintMap, "spacing", 0); - if (data.spacingMode == core.SpacingMode.Length || data.spacingMode == core.SpacingMode.Fixed) - data.spacing *= scale; - data.rotateMix = this.getValue(constraintMap, "rotateMix", 1); - data.translateMix = this.getValue(constraintMap, "translateMix", 1); - skeletonData.pathConstraints.push(data); - } - } - if (root.skins) { - for (var i = 0; i < root.skins.length; i++) { - var skinMap = root.skins[i]; - var skin = new core.Skin(skinMap.name); - if (skinMap.bones) { - for (var ii = 0; ii < skinMap.bones.length; ii++) { - var bone = skeletonData.findBone(skinMap.bones[ii]); - if (bone == null) - throw new Error("Skin bone not found: " + skinMap.bones[i]); - skin.bones.push(bone); - } - } - if (skinMap.ik) { - for (var ii = 0; ii < skinMap.ik.length; ii++) { - var constraint = skeletonData.findIkConstraint(skinMap.ik[ii]); - if (constraint == null) - throw new Error("Skin IK constraint not found: " + skinMap.ik[i]); - skin.constraints.push(constraint); - } - } - if (skinMap.transform) { - for (var ii = 0; ii < skinMap.transform.length; ii++) { - var constraint = skeletonData.findTransformConstraint(skinMap.transform[ii]); - if (constraint == null) - throw new Error("Skin transform constraint not found: " + skinMap.transform[i]); - skin.constraints.push(constraint); - } - } - if (skinMap.path) { - for (var ii = 0; ii < skinMap.path.length; ii++) { - var constraint = skeletonData.findPathConstraint(skinMap.path[ii]); - if (constraint == null) - throw new Error("Skin path constraint not found: " + skinMap.path[i]); - skin.constraints.push(constraint); - } - } - for (var slotName in skinMap.attachments) { - var slot = skeletonData.findSlot(slotName); - if (slot == null) - throw new Error("Slot not found: " + slotName); - var slotMap = skinMap.attachments[slotName]; - for (var entryName in slotMap) { - var attachment = this.readAttachment(slotMap[entryName], skin, slot.index, entryName, skeletonData); - if (attachment != null) - skin.setAttachment(slot.index, entryName, attachment); - } - } - skeletonData.skins.push(skin); - if (skin.name == "default") - skeletonData.defaultSkin = skin; - } - } - for (var i = 0, n = this.linkedMeshes.length; i < n; i++) { - var linkedMesh = this.linkedMeshes[i]; - var skin = linkedMesh.skin == null ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin); - if (skin == null) - throw new Error("Skin not found: " + linkedMesh.skin); - var parent_6 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent); - if (parent_6 == null) - throw new Error("Parent mesh not found: " + linkedMesh.parent); - linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent_6 : linkedMesh.mesh; - linkedMesh.mesh.setParentMesh(parent_6); - } - this.linkedMeshes.length = 0; - if (root.events) { - for (var eventName in root.events) { - var eventMap = root.events[eventName]; - var data = new core.EventData(eventName); - data.intValue = this.getValue(eventMap, "int", 0); - data.floatValue = this.getValue(eventMap, "float", 0); - data.stringValue = this.getValue(eventMap, "string", ""); - data.audioPath = this.getValue(eventMap, "audio", null); - if (data.audioPath != null) { - data.volume = this.getValue(eventMap, "volume", 1); - data.balance = this.getValue(eventMap, "balance", 0); - } - skeletonData.events.push(data); - } - } - if (root.animations) { - for (var animationName in root.animations) { - var animationMap = root.animations[animationName]; - this.readAnimation(animationMap, animationName, skeletonData); - } - } - return skeletonData; - }; - SkeletonJson.prototype.readAttachment = function (map, skin, slotIndex, name, skeletonData) { - var scale = this.scale; - name = this.getValue(map, "name", name); - var type = this.getValue(map, "type", "region"); - switch (type) { - case "region": { - var path = this.getValue(map, "path", name); - var region = this.attachmentLoader.newRegionAttachment(skin, name, path); - if (region == null) - return null; - region.path = path; - region.x = this.getValue(map, "x", 0) * scale; - region.y = this.getValue(map, "y", 0) * scale; - region.scaleX = this.getValue(map, "scaleX", 1); - region.scaleY = this.getValue(map, "scaleY", 1); - region.rotation = this.getValue(map, "rotation", 0); - region.width = map.width * scale; - region.height = map.height * scale; - var color = this.getValue(map, "color", null); - if (color != null) - region.color.setFromString(color); - return region; - } - case "boundingbox": { - var box = this.attachmentLoader.newBoundingBoxAttachment(skin, name); - if (box == null) - return null; - this.readVertices(map, box, map.vertexCount << 1); - var color = this.getValue(map, "color", null); - if (color != null) - box.color.setFromString(color); - return box; - } - case "mesh": - case "linkedmesh": { - var path = this.getValue(map, "path", name); - var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path); - if (mesh == null) - return null; - mesh.path = path; - var color = this.getValue(map, "color", null); - if (color != null) - mesh.color.setFromString(color); - mesh.width = this.getValue(map, "width", 0) * scale; - mesh.height = this.getValue(map, "height", 0) * scale; - var parent_7 = this.getValue(map, "parent", null); - if (parent_7 != null) { - this.linkedMeshes.push(new LinkedMesh(mesh, this.getValue(map, "skin", null), slotIndex, parent_7, this.getValue(map, "deform", true))); - return mesh; - } - var uvs = map.uvs; - this.readVertices(map, mesh, uvs.length); - mesh.triangles = map.triangles; - mesh.regionUVs = new Float32Array(uvs); - mesh.edges = this.getValue(map, "edges", null); - mesh.hullLength = this.getValue(map, "hull", 0) * 2; - return mesh; - } - case "path": { - var path = this.attachmentLoader.newPathAttachment(skin, name); - if (path == null) - return null; - path.closed = this.getValue(map, "closed", false); - path.constantSpeed = this.getValue(map, "constantSpeed", true); - var vertexCount = map.vertexCount; - this.readVertices(map, path, vertexCount << 1); - var lengths = core.Utils.newArray(vertexCount / 3, 0); - for (var i = 0; i < map.lengths.length; i++) - lengths[i] = map.lengths[i] * scale; - path.lengths = lengths; - var color = this.getValue(map, "color", null); - if (color != null) - path.color.setFromString(color); - return path; - } - case "point": { - var point = this.attachmentLoader.newPointAttachment(skin, name); - if (point == null) - return null; - point.x = this.getValue(map, "x", 0) * scale; - point.y = this.getValue(map, "y", 0) * scale; - point.rotation = this.getValue(map, "rotation", 0); - var color = this.getValue(map, "color", null); - if (color != null) - point.color.setFromString(color); - return point; - } - case "clipping": { - var clip = this.attachmentLoader.newClippingAttachment(skin, name); - if (clip == null) - return null; - var end = this.getValue(map, "end", null); - if (end != null) { - var slot = skeletonData.findSlot(end); - if (slot == null) - throw new Error("Clipping end slot not found: " + end); - clip.endSlot = slot; - } - var vertexCount = map.vertexCount; - this.readVertices(map, clip, vertexCount << 1); - var color = this.getValue(map, "color", null); - if (color != null) - clip.color.setFromString(color); - return clip; - } - } - return null; - }; - SkeletonJson.prototype.readVertices = function (map, attachment, verticesLength) { - var scale = this.scale; - attachment.worldVerticesLength = verticesLength; - var vertices = map.vertices; - if (verticesLength == vertices.length) { - var scaledVertices = core.Utils.toFloatArray(vertices); - if (scale != 1) { - for (var i = 0, n = vertices.length; i < n; i++) - scaledVertices[i] *= scale; - } - attachment.vertices = scaledVertices; - return; - } - var weights = new Array(); - var bones = new Array(); - for (var i = 0, n = vertices.length; i < n;) { - var boneCount = vertices[i++]; - bones.push(boneCount); - for (var nn = i + boneCount * 4; i < nn; i += 4) { - bones.push(vertices[i]); - weights.push(vertices[i + 1] * scale); - weights.push(vertices[i + 2] * scale); - weights.push(vertices[i + 3]); - } - } - attachment.bones = bones; - attachment.vertices = core.Utils.toFloatArray(weights); - }; - SkeletonJson.prototype.readAnimation = function (map, name, skeletonData) { - var scale = this.scale; - var timelines = new Array(); - var duration = 0; - if (map.slots) { - for (var slotName in map.slots) { - var slotMap = map.slots[slotName]; - var slotIndex = skeletonData.findSlotIndex(slotName); - if (slotIndex == -1) - throw new Error("Slot not found: " + slotName); - for (var timelineName in slotMap) { - var timelineMap = slotMap[timelineName]; - if (timelineName == "attachment") { - var timeline = new core.AttachmentTimeline(timelineMap.length); - timeline.slotIndex = slotIndex; - var frameIndex = 0; - for (var i = 0; i < timelineMap.length; i++) { - var valueMap = timelineMap[i]; - timeline.setFrame(frameIndex++, this.getValue(valueMap, "time", 0), valueMap.name); - } - timelines.push(timeline); - duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); - } - else if (timelineName == "color") { - var timeline = new core.ColorTimeline(timelineMap.length); - timeline.slotIndex = slotIndex; - var frameIndex = 0; - for (var i = 0; i < timelineMap.length; i++) { - var valueMap = timelineMap[i]; - var color = new core.Color(); - color.setFromString(valueMap.color || "ffffffff"); - timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), color.r, color.g, color.b, color.a); - this.readCurve(valueMap, timeline, frameIndex); - frameIndex++; - } - timelines.push(timeline); - duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * core.ColorTimeline.ENTRIES]); - } - else if (timelineName == "twoColor") { - var timeline = new core.TwoColorTimeline(timelineMap.length); - timeline.slotIndex = slotIndex; - var frameIndex = 0; - for (var i = 0; i < timelineMap.length; i++) { - var valueMap = timelineMap[i]; - var light = new core.Color(); - var dark = new core.Color(); - light.setFromString(valueMap.light); - dark.setFromString(valueMap.dark); - timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), light.r, light.g, light.b, light.a, dark.r, dark.g, dark.b); - this.readCurve(valueMap, timeline, frameIndex); - frameIndex++; - } - timelines.push(timeline); - duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * core.TwoColorTimeline.ENTRIES]); - } - else - throw new Error("Invalid timeline type for a slot: " + timelineName + " (" + slotName + ")"); - } - } - } - if (map.bones) { - for (var boneName in map.bones) { - var boneMap = map.bones[boneName]; - var boneIndex = skeletonData.findBoneIndex(boneName); - if (boneIndex == -1) - throw new Error("Bone not found: " + boneName); - for (var timelineName in boneMap) { - var timelineMap = boneMap[timelineName]; - if (timelineName === "rotate") { - var timeline = new core.RotateTimeline(timelineMap.length); - timeline.boneIndex = boneIndex; - var frameIndex = 0; - for (var i = 0; i < timelineMap.length; i++) { - var valueMap = timelineMap[i]; - timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), this.getValue(valueMap, "angle", 0)); - this.readCurve(valueMap, timeline, frameIndex); - frameIndex++; - } - timelines.push(timeline); - duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * core.RotateTimeline.ENTRIES]); - } - else if (timelineName === "translate" || timelineName === "scale" || timelineName === "shear") { - var timeline = null; - var timelineScale = 1, defaultValue = 0; - if (timelineName === "scale") { - timeline = new core.ScaleTimeline(timelineMap.length); - defaultValue = 1; - } - else if (timelineName === "shear") - timeline = new core.ShearTimeline(timelineMap.length); - else { - timeline = new core.TranslateTimeline(timelineMap.length); - timelineScale = scale; - } - timeline.boneIndex = boneIndex; - var frameIndex = 0; - for (var i = 0; i < timelineMap.length; i++) { - var valueMap = timelineMap[i]; - var x = this.getValue(valueMap, "x", defaultValue), y = this.getValue(valueMap, "y", defaultValue); - timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), x * timelineScale, y * timelineScale); - this.readCurve(valueMap, timeline, frameIndex); - frameIndex++; - } - timelines.push(timeline); - duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * core.TranslateTimeline.ENTRIES]); - } - else - throw new Error("Invalid timeline type for a bone: " + timelineName + " (" + boneName + ")"); - } - } - } - if (map.ik) { - for (var constraintName in map.ik) { - var constraintMap = map.ik[constraintName]; - var constraint = skeletonData.findIkConstraint(constraintName); - var timeline = new core.IkConstraintTimeline(constraintMap.length); - timeline.ikConstraintIndex = skeletonData.ikConstraints.indexOf(constraint); - var frameIndex = 0; - for (var i = 0; i < constraintMap.length; i++) { - var valueMap = constraintMap[i]; - timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), this.getValue(valueMap, "mix", 1), this.getValue(valueMap, "softness", 0) * scale, this.getValue(valueMap, "bendPositive", true) ? 1 : -1, this.getValue(valueMap, "compress", false), this.getValue(valueMap, "stretch", false)); - this.readCurve(valueMap, timeline, frameIndex); - frameIndex++; - } - timelines.push(timeline); - duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * core.IkConstraintTimeline.ENTRIES]); - } - } - if (map.transform) { - for (var constraintName in map.transform) { - var constraintMap = map.transform[constraintName]; - var constraint = skeletonData.findTransformConstraint(constraintName); - var timeline = new core.TransformConstraintTimeline(constraintMap.length); - timeline.transformConstraintIndex = skeletonData.transformConstraints.indexOf(constraint); - var frameIndex = 0; - for (var i = 0; i < constraintMap.length; i++) { - var valueMap = constraintMap[i]; - timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), this.getValue(valueMap, "rotateMix", 1), this.getValue(valueMap, "translateMix", 1), this.getValue(valueMap, "scaleMix", 1), this.getValue(valueMap, "shearMix", 1)); - this.readCurve(valueMap, timeline, frameIndex); - frameIndex++; - } - timelines.push(timeline); - duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * core.TransformConstraintTimeline.ENTRIES]); - } - } - if (map.path) { - for (var constraintName in map.path) { - var constraintMap = map.path[constraintName]; - var index = skeletonData.findPathConstraintIndex(constraintName); - if (index == -1) - throw new Error("Path constraint not found: " + constraintName); - var data = skeletonData.pathConstraints[index]; - for (var timelineName in constraintMap) { - var timelineMap = constraintMap[timelineName]; - if (timelineName === "position" || timelineName === "spacing") { - var timeline = null; - var timelineScale = 1; - if (timelineName === "spacing") { - timeline = new core.PathConstraintSpacingTimeline(timelineMap.length); - if (data.spacingMode == core.SpacingMode.Length || data.spacingMode == core.SpacingMode.Fixed) - timelineScale = scale; - } - else { - timeline = new core.PathConstraintPositionTimeline(timelineMap.length); - if (data.positionMode == core.PositionMode.Fixed) - timelineScale = scale; - } - timeline.pathConstraintIndex = index; - var frameIndex = 0; - for (var i = 0; i < timelineMap.length; i++) { - var valueMap = timelineMap[i]; - timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), this.getValue(valueMap, timelineName, 0) * timelineScale); - this.readCurve(valueMap, timeline, frameIndex); - frameIndex++; - } - timelines.push(timeline); - duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * core.PathConstraintPositionTimeline.ENTRIES]); - } - else if (timelineName === "mix") { - var timeline = new core.PathConstraintMixTimeline(timelineMap.length); - timeline.pathConstraintIndex = index; - var frameIndex = 0; - for (var i = 0; i < timelineMap.length; i++) { - var valueMap = timelineMap[i]; - timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), this.getValue(valueMap, "rotateMix", 1), this.getValue(valueMap, "translateMix", 1)); - this.readCurve(valueMap, timeline, frameIndex); - frameIndex++; - } - timelines.push(timeline); - duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * core.PathConstraintMixTimeline.ENTRIES]); - } - } - } - } - if (map.deform) { - for (var deformName in map.deform) { - var deformMap = map.deform[deformName]; - var skin = skeletonData.findSkin(deformName); - if (skin == null) { - if (core.FAIL_ON_NON_EXISTING_SKIN) { - throw new Error("Skin not found: " + deformName); - } - else { - continue; - } - } - for (var slotName in deformMap) { - var slotMap = deformMap[slotName]; - var slotIndex = skeletonData.findSlotIndex(slotName); - if (slotIndex == -1) - throw new Error("Slot not found: " + slotMap.name); - for (var timelineName in slotMap) { - var timelineMap = slotMap[timelineName]; - var attachment = skin.getAttachment(slotIndex, timelineName); - if (attachment == null) - throw new Error("Deform attachment not found: " + timelineMap.name); - var weighted = attachment.bones != null; - var vertices = attachment.vertices; - var deformLength = weighted ? vertices.length / 3 * 2 : vertices.length; - var timeline = new core.DeformTimeline(timelineMap.length); - timeline.slotIndex = slotIndex; - timeline.attachment = attachment; - var frameIndex = 0; - for (var j = 0; j < timelineMap.length; j++) { - var valueMap = timelineMap[j]; - var deform = void 0; - var verticesValue = this.getValue(valueMap, "vertices", null); - if (verticesValue == null) - deform = weighted ? core.Utils.newFloatArray(deformLength) : vertices; - else { - deform = core.Utils.newFloatArray(deformLength); - var start = this.getValue(valueMap, "offset", 0); - core.Utils.arrayCopy(verticesValue, 0, deform, start, verticesValue.length); - if (scale != 1) { - for (var i = start, n = i + verticesValue.length; i < n; i++) - deform[i] *= scale; - } - if (!weighted) { - for (var i = 0; i < deformLength; i++) - deform[i] += vertices[i]; - } - } - timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), deform); - this.readCurve(valueMap, timeline, frameIndex); - frameIndex++; - } - timelines.push(timeline); - duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); - } - } - } - } - var drawOrderNode = map.drawOrder; - if (drawOrderNode == null) - drawOrderNode = map.draworder; - if (drawOrderNode != null) { - var timeline = new core.DrawOrderTimeline(drawOrderNode.length); - var slotCount = skeletonData.slots.length; - var frameIndex = 0; - for (var j = 0; j < drawOrderNode.length; j++) { - var drawOrderMap = drawOrderNode[j]; - var drawOrder = null; - var offsets = this.getValue(drawOrderMap, "offsets", null); - if (offsets != null) { - drawOrder = core.Utils.newArray(slotCount, -1); - var unchanged = core.Utils.newArray(slotCount - offsets.length, 0); - var originalIndex = 0, unchangedIndex = 0; - for (var i = 0; i < offsets.length; i++) { - var offsetMap = offsets[i]; - var slotIndex = skeletonData.findSlotIndex(offsetMap.slot); - if (slotIndex == -1) - throw new Error("Slot not found: " + offsetMap.slot); - while (originalIndex != slotIndex) - unchanged[unchangedIndex++] = originalIndex++; - drawOrder[originalIndex + offsetMap.offset] = originalIndex++; - } - while (originalIndex < slotCount) - unchanged[unchangedIndex++] = originalIndex++; - for (var i = slotCount - 1; i >= 0; i--) - if (drawOrder[i] == -1) - drawOrder[i] = unchanged[--unchangedIndex]; - } - timeline.setFrame(frameIndex++, this.getValue(drawOrderMap, "time", 0), drawOrder); - } - timelines.push(timeline); - duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); - } - if (map.events) { - var timeline = new core.EventTimeline(map.events.length); - var frameIndex = 0; - for (var i = 0; i < map.events.length; i++) { - var eventMap = map.events[i]; - var eventData = skeletonData.findEvent(eventMap.name); - if (eventData == null) - throw new Error("Event not found: " + eventMap.name); - var event_6 = new core.Event(core.Utils.toSinglePrecision(this.getValue(eventMap, "time", 0)), eventData); - event_6.intValue = this.getValue(eventMap, "int", eventData.intValue); - event_6.floatValue = this.getValue(eventMap, "float", eventData.floatValue); - event_6.stringValue = this.getValue(eventMap, "string", eventData.stringValue); - if (event_6.data.audioPath != null) { - event_6.volume = this.getValue(eventMap, "volume", 1); - event_6.balance = this.getValue(eventMap, "balance", 0); - } - timeline.setFrame(frameIndex++, event_6); - } - timelines.push(timeline); - duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); - } - if (isNaN(duration)) { - throw new Error("Error while parsing animation, duration is NaN"); - } - skeletonData.animations.push(new core.Animation(name, timelines, duration)); - }; - SkeletonJson.prototype.readCurve = function (map, timeline, frameIndex) { - if (!map.hasOwnProperty("curve")) - return; - if (map.curve === "stepped") - timeline.setStepped(frameIndex); - else { - var curve = map.curve; - timeline.setCurve(frameIndex, curve, this.getValue(map, "c2", 0), this.getValue(map, "c3", 1), this.getValue(map, "c4", 1)); - } - }; - SkeletonJson.prototype.getValue = function (map, prop, defaultValue) { - return map[prop] !== undefined ? map[prop] : defaultValue; - }; - SkeletonJson.blendModeFromString = function (str) { - str = str.toLowerCase(); - if (str == "normal") - return core.BlendMode.Normal; - if (str == "additive") - return core.BlendMode.Additive; - if (str == "multiply") - return core.BlendMode.Multiply; - if (str == "screen") - return core.BlendMode.Screen; - throw new Error("Unknown blend mode: " + str); - }; - SkeletonJson.positionModeFromString = function (str) { - str = str.toLowerCase(); - if (str == "fixed") - return core.PositionMode.Fixed; - if (str == "percent") - return core.PositionMode.Percent; - throw new Error("Unknown position mode: " + str); - }; - SkeletonJson.spacingModeFromString = function (str) { - str = str.toLowerCase(); - if (str == "length") - return core.SpacingMode.Length; - if (str == "fixed") - return core.SpacingMode.Fixed; - if (str == "percent") - return core.SpacingMode.Percent; - throw new Error("Unknown position mode: " + str); - }; - SkeletonJson.rotateModeFromString = function (str) { - str = str.toLowerCase(); - if (str == "tangent") - return core.RotateMode.Tangent; - if (str == "chain") - return core.RotateMode.Chain; - if (str == "chainscale") - return core.RotateMode.ChainScale; - throw new Error("Unknown rotate mode: " + str); - }; - SkeletonJson.transformModeFromString = function (str) { - str = str.toLowerCase(); - if (str == "normal") - return core.TransformMode.Normal; - if (str == "onlytranslation") - return core.TransformMode.OnlyTranslation; - if (str == "norotationorreflection") - return core.TransformMode.NoRotationOrReflection; - if (str == "noscale") - return core.TransformMode.NoScale; - if (str == "noscaleorreflection") - return core.TransformMode.NoScaleOrReflection; - throw new Error("Unknown transform mode: " + str); - }; - return SkeletonJson; - }()); - core.SkeletonJson = SkeletonJson; - var LinkedMesh = (function () { - function LinkedMesh(mesh, skin, slotIndex, parent, inheritDeform) { - this.mesh = mesh; - this.skin = skin; - this.slotIndex = slotIndex; - this.parent = parent; - this.inheritDeform = inheritDeform; - } - return LinkedMesh; - }()); - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var SkinEntry = (function () { - function SkinEntry(slotIndex, name, attachment) { - this.slotIndex = slotIndex; - this.name = name; - this.attachment = attachment; - } - return SkinEntry; - }()); - core.SkinEntry = SkinEntry; - var Skin = (function () { - function Skin(name) { - this.attachments = new Array(); - this.bones = Array(); - this.constraints = new Array(); - if (name == null) - throw new Error("name cannot be null."); - this.name = name; - } - Skin.prototype.setAttachment = function (slotIndex, name, attachment) { - if (attachment == null) - throw new Error("attachment cannot be null."); - var attachments = this.attachments; - if (slotIndex >= attachments.length) - attachments.length = slotIndex + 1; - if (!attachments[slotIndex]) - attachments[slotIndex] = {}; - attachments[slotIndex][name] = attachment; - }; - Skin.prototype.addSkin = function (skin) { - for (var i = 0; i < skin.bones.length; i++) { - var bone = skin.bones[i]; - var contained = false; - for (var j = 0; j < this.bones.length; j++) { - if (this.bones[j] == bone) { - contained = true; - break; - } - } - if (!contained) - this.bones.push(bone); - } - for (var i = 0; i < skin.constraints.length; i++) { - var constraint = skin.constraints[i]; - var contained = false; - for (var j = 0; j < this.constraints.length; j++) { - if (this.constraints[j] == constraint) { - contained = true; - break; - } - } - if (!contained) - this.constraints.push(constraint); - } - var attachments = skin.getAttachments(); - for (var i = 0; i < attachments.length; i++) { - var attachment = attachments[i]; - this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment); - } - }; - Skin.prototype.copySkin = function (skin) { - for (var i = 0; i < skin.bones.length; i++) { - var bone = skin.bones[i]; - var contained = false; - for (var j = 0; j < this.bones.length; j++) { - if (this.bones[j] == bone) { - contained = true; - break; - } - } - if (!contained) - this.bones.push(bone); - } - for (var i = 0; i < skin.constraints.length; i++) { - var constraint = skin.constraints[i]; - var contained = false; - for (var j = 0; j < this.constraints.length; j++) { - if (this.constraints[j] == constraint) { - contained = true; - break; - } - } - if (!contained) - this.constraints.push(constraint); - } - var attachments = skin.getAttachments(); - for (var i = 0; i < attachments.length; i++) { - var attachment = attachments[i]; - if (attachment.attachment == null) - continue; - if (attachment.attachment instanceof core.MeshAttachment) { - attachment.attachment = attachment.attachment.newLinkedMesh(); - this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment); - } - else { - attachment.attachment = attachment.attachment.copy(); - this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment); - } - } - }; - Skin.prototype.getAttachment = function (slotIndex, name) { - var dictionary = this.attachments[slotIndex]; - return dictionary ? dictionary[name] : null; - }; - Skin.prototype.removeAttachment = function (slotIndex, name) { - var dictionary = this.attachments[slotIndex]; - if (dictionary) - dictionary[name] = null; - }; - Skin.prototype.getAttachments = function () { - var entries = new Array(); - for (var i = 0; i < this.attachments.length; i++) { - var slotAttachments = this.attachments[i]; - if (slotAttachments) { - for (var name_4 in slotAttachments) { - var attachment = slotAttachments[name_4]; - if (attachment) - entries.push(new SkinEntry(i, name_4, attachment)); - } - } - } - return entries; - }; - Skin.prototype.getAttachmentsForSlot = function (slotIndex, attachments) { - var slotAttachments = this.attachments[slotIndex]; - if (slotAttachments) { - for (var name_5 in slotAttachments) { - var attachment = slotAttachments[name_5]; - if (attachment) - attachments.push(new SkinEntry(slotIndex, name_5, attachment)); - } - } - }; - Skin.prototype.clear = function () { - this.attachments.length = 0; - this.bones.length = 0; - this.constraints.length = 0; - }; - Skin.prototype.attachAll = function (skeleton, oldSkin) { - var slotIndex = 0; - for (var i = 0; i < skeleton.slots.length; i++) { - var slot = skeleton.slots[i]; - var slotAttachment = slot.getAttachment(); - if (slotAttachment && slotIndex < oldSkin.attachments.length) { - var dictionary = oldSkin.attachments[slotIndex]; - for (var key in dictionary) { - var skinAttachment = dictionary[key]; - if (slotAttachment == skinAttachment) { - var attachment = this.getAttachment(slotIndex, key); - if (attachment != null) - slot.setAttachment(attachment); - break; - } - } - } - slotIndex++; - } - }; - return Skin; - }()); - core.Skin = Skin; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var Slot = (function () { - function Slot(data, bone) { - this.deform = new Array(); - if (data == null) - throw new Error("data cannot be null."); - if (bone == null) - throw new Error("bone cannot be null."); - this.data = data; - this.bone = bone; - this.color = new core.Color(); - this.darkColor = data.darkColor == null ? null : new core.Color(); - this.setToSetupPose(); - this.blendMode = this.data.blendMode; - } - Slot.prototype.getAttachment = function () { - return this.attachment; - }; - Slot.prototype.setAttachment = function (attachment) { - if (this.attachment == attachment) - return; - this.attachment = attachment; - this.attachmentTime = this.bone.skeleton.time; - this.deform.length = 0; - }; - Slot.prototype.setAttachmentTime = function (time) { - this.attachmentTime = this.bone.skeleton.time - time; - }; - Slot.prototype.getAttachmentTime = function () { - return this.bone.skeleton.time - this.attachmentTime; - }; - Slot.prototype.setToSetupPose = function () { - this.color.setFromColor(this.data.color); - if (this.darkColor != null) - this.darkColor.setFromColor(this.data.darkColor); - if (this.data.attachmentName == null) - this.attachment = null; - else { - this.attachment = null; - this.setAttachment(this.bone.skeleton.getAttachment(this.data.index, this.data.attachmentName)); - } - }; - return Slot; - }()); - core.Slot = Slot; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var SlotData = (function () { - function SlotData(index, name, boneData) { - this.color = new core.Color(1, 1, 1, 1); - if (index < 0) - throw new Error("index must be >= 0."); - if (name == null) - throw new Error("name cannot be null."); - if (boneData == null) - throw new Error("boneData cannot be null."); - this.index = index; - this.name = name; - this.boneData = boneData; - } - return SlotData; - }()); - core.SlotData = SlotData; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var Texture = (function () { - function Texture(image) { - this._image = image; - } - Texture.prototype.getImage = function () { - return this._image; - }; - Texture.filterFromString = function (text) { - switch (text.toLowerCase()) { - case "nearest": return TextureFilter.Nearest; - case "linear": return TextureFilter.Linear; - case "mipmap": return TextureFilter.MipMap; - case "mipmapnearestnearest": return TextureFilter.MipMapNearestNearest; - case "mipmaplinearnearest": return TextureFilter.MipMapLinearNearest; - case "mipmapnearestlinear": return TextureFilter.MipMapNearestLinear; - case "mipmaplinearlinear": return TextureFilter.MipMapLinearLinear; - default: throw new Error("Unknown texture filter " + text); - } - }; - Texture.wrapFromString = function (text) { - switch (text.toLowerCase()) { - case "mirroredtepeat": return TextureWrap.MirroredRepeat; - case "clamptoedge": return TextureWrap.ClampToEdge; - case "repeat": return TextureWrap.Repeat; - default: throw new Error("Unknown texture wrap " + text); - } - }; - return Texture; - }()); - core.Texture = Texture; - var TextureFilter; - (function (TextureFilter) { - TextureFilter[TextureFilter["Nearest"] = 9728] = "Nearest"; - TextureFilter[TextureFilter["Linear"] = 9729] = "Linear"; - TextureFilter[TextureFilter["MipMap"] = 9987] = "MipMap"; - TextureFilter[TextureFilter["MipMapNearestNearest"] = 9984] = "MipMapNearestNearest"; - TextureFilter[TextureFilter["MipMapLinearNearest"] = 9985] = "MipMapLinearNearest"; - TextureFilter[TextureFilter["MipMapNearestLinear"] = 9986] = "MipMapNearestLinear"; - TextureFilter[TextureFilter["MipMapLinearLinear"] = 9987] = "MipMapLinearLinear"; - })(TextureFilter = core.TextureFilter || (core.TextureFilter = {})); - var TextureWrap; - (function (TextureWrap) { - TextureWrap[TextureWrap["MirroredRepeat"] = 33648] = "MirroredRepeat"; - TextureWrap[TextureWrap["ClampToEdge"] = 33071] = "ClampToEdge"; - TextureWrap[TextureWrap["Repeat"] = 10497] = "Repeat"; - })(TextureWrap = core.TextureWrap || (core.TextureWrap = {})); - var TextureRegion = (function () { - function TextureRegion() { - this.size = null; - } - Object.defineProperty(TextureRegion.prototype, "width", { - get: function () { - var tex = this.texture; - if (PIXI.VERSION[0] == '3') { - return tex.crop.width; - } - if (tex.trim) { - return tex.trim.width; - } - return tex.orig.width; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(TextureRegion.prototype, "height", { - get: function () { - var tex = this.texture; - if (PIXI.VERSION[0] == '3') { - return tex.crop.height; - } - if (tex.trim) { - return tex.trim.height; - } - return tex.orig.height; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(TextureRegion.prototype, "u", { - get: function () { - return this.texture._uvs.x0; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(TextureRegion.prototype, "v", { - get: function () { - return this.texture._uvs.y0; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(TextureRegion.prototype, "u2", { - get: function () { - return this.texture._uvs.x2; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(TextureRegion.prototype, "v2", { - get: function () { - return this.texture._uvs.y2; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(TextureRegion.prototype, "offsetX", { - get: function () { - var tex = this.texture; - return tex.trim ? tex.trim.x : 0; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(TextureRegion.prototype, "offsetY", { - get: function () { - console.warn("Deprecation Warning: @Hackerham: I guess, if you are using PIXI-SPINE ATLAS region.offsetY, you want a texture, right? Use region.texture from now on."); - return this.spineOffsetY; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(TextureRegion.prototype, "pixiOffsetY", { - get: function () { - var tex = this.texture; - return tex.trim ? tex.trim.y : 0; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(TextureRegion.prototype, "spineOffsetY", { - get: function () { - var tex = this.texture; - return this.originalHeight - this.height - (tex.trim ? tex.trim.y : 0); - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(TextureRegion.prototype, "originalWidth", { - get: function () { - var tex = this.texture; - if (PIXI.VERSION[0] == '3') { - if (tex.trim) { - return tex.trim.width; - } - return tex.crop.width; - } - return tex.orig.width; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(TextureRegion.prototype, "originalHeight", { - get: function () { - var tex = this.texture; - if (PIXI.VERSION[0] == '3') { - if (tex.trim) { - return tex.trim.height; - } - return tex.crop.height; - } - return tex.orig.height; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(TextureRegion.prototype, "x", { - get: function () { - return this.texture.frame.x; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(TextureRegion.prototype, "y", { - get: function () { - return this.texture.frame.y; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(TextureRegion.prototype, "rotate", { - get: function () { - return this.texture.rotate !== 0; - }, - enumerable: false, - configurable: true - }); - return TextureRegion; - }()); - core.TextureRegion = TextureRegion; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var TextureAtlas = (function () { - function TextureAtlas(atlasText, textureLoader, callback) { - this.pages = new Array(); - this.regions = new Array(); - if (atlasText) { - this.addSpineAtlas(atlasText, textureLoader, callback); - } - } - TextureAtlas.prototype.addTexture = function (name, texture) { - var pages = this.pages; - var page = null; - for (var i = 0; i < pages.length; i++) { - if (pages[i].baseTexture === texture.baseTexture) { - page = pages[i]; - break; - } - } - if (page === null) { - page = new TextureAtlasPage(); - page.name = 'texturePage'; - var baseTexture = texture.baseTexture; - page.width = baseTexture.realWidth; - page.height = baseTexture.realHeight; - page.baseTexture = baseTexture; - page.minFilter = page.magFilter = core.TextureFilter.Nearest; - page.uWrap = core.TextureWrap.ClampToEdge; - page.vWrap = core.TextureWrap.ClampToEdge; - pages.push(page); - } - var region = new TextureAtlasRegion(); - region.name = name; - region.page = page; - region.texture = texture; - region.index = -1; - this.regions.push(region); - return region; - }; - TextureAtlas.prototype.addTextureHash = function (textures, stripExtension) { - for (var key in textures) { - if (textures.hasOwnProperty(key)) { - this.addTexture(stripExtension && key.indexOf('.') !== -1 ? key.substr(0, key.lastIndexOf('.')) : key, textures[key]); - } - } - }; - TextureAtlas.prototype.addSpineAtlas = function (atlasText, textureLoader, callback) { - return this.load(atlasText, textureLoader, callback); - }; - TextureAtlas.prototype.load = function (atlasText, textureLoader, callback) { - var _this = this; - if (textureLoader == null) - throw new Error("textureLoader cannot be null."); - var reader = new TextureAtlasReader(atlasText); - var tuple = new Array(4); - var page = null; - var iterateParser = function () { - while (true) { - var line = reader.readLine(); - if (line == null) { - return callback && callback(_this); - } - line = line.trim(); - if (line.length == 0) - page = null; - else if (!page) { - page = new TextureAtlasPage(); - page.name = line; - if (reader.readTuple(tuple) == 2) { - page.width = parseInt(tuple[0]); - page.height = parseInt(tuple[1]); - reader.readTuple(tuple); - } - reader.readTuple(tuple); - page.minFilter = core.Texture.filterFromString(tuple[0]); - page.magFilter = core.Texture.filterFromString(tuple[1]); - var direction = reader.readValue(); - page.uWrap = core.TextureWrap.ClampToEdge; - page.vWrap = core.TextureWrap.ClampToEdge; - if (direction == "x") - page.uWrap = core.TextureWrap.Repeat; - else if (direction == "y") - page.vWrap = core.TextureWrap.Repeat; - else if (direction == "xy") - page.uWrap = page.vWrap = core.TextureWrap.Repeat; - textureLoader(line, function (texture) { - if (texture === null) { - _this.pages.splice(_this.pages.indexOf(page), 1); - return callback && callback(null); - } - page.baseTexture = texture; - if (!texture.hasLoaded) { - texture.width = page.width; - texture.height = page.height; - } - _this.pages.push(page); - page.setFilters(); - if (!page.width || !page.height) { - page.width = texture.realWidth; - page.height = texture.realHeight; - if (!page.width || !page.height) { - console.log("ERROR spine atlas page " + page.name + ": meshes wont work if you dont specify size in atlas (http://www.html5gamedevs.com/topic/18888-pixi-spines-and-meshes/?p=107121)"); - } - } - iterateParser(); - }); - _this.pages.push(page); - break; - } - else { - var region = new TextureAtlasRegion(); - region.name = line; - region.page = page; - var rotateValue = reader.readValue(); - var rotate = 0; - if (rotateValue.toLocaleLowerCase() == "true") { - rotate = 6; - } - else if (rotateValue.toLocaleLowerCase() == "false") { - rotate = 0; - } - else { - rotate = ((720 - parseFloat(rotateValue)) % 360) / 45; - } - reader.readTuple(tuple); - var x = parseInt(tuple[0]); - var y = parseInt(tuple[1]); - reader.readTuple(tuple); - var width = parseInt(tuple[0]); - var height = parseInt(tuple[1]); - var resolution = page.baseTexture.resolution; - x /= resolution; - y /= resolution; - width /= resolution; - height /= resolution; - var swapWH = rotate % 4 != 0; - var frame = new PIXI.Rectangle(x, y, swapWH ? height : width, swapWH ? width : height); - if (reader.readTuple(tuple) == 4) { - if (reader.readTuple(tuple) == 4) { - reader.readTuple(tuple); - } - } - var originalWidth = parseInt(tuple[0]) / resolution; - var originalHeight = parseInt(tuple[1]) / resolution; - reader.readTuple(tuple); - var offsetX = parseInt(tuple[0]) / resolution; - var offsetY = parseInt(tuple[1]) / resolution; - var orig = new PIXI.Rectangle(0, 0, originalWidth, originalHeight); - var trim = new PIXI.Rectangle(offsetX, originalHeight - height - offsetY, width, height); - if (PIXI.VERSION[0] != '3') { - region.texture = new PIXI.Texture(region.page.baseTexture, frame, orig, trim, rotate); - } - else { - var frame2 = new PIXI.Rectangle(x, y, width, height); - var crop = frame2.clone(); - trim.width = originalWidth; - trim.height = originalHeight; - region.texture = new PIXI.Texture(region.page.baseTexture, frame2, crop, trim, rotate); - } - region.index = parseInt(reader.readValue()); - region.texture._updateUvs(); - _this.regions.push(region); - } - } - }; - iterateParser(); - }; - TextureAtlas.prototype.findRegion = function (name) { - for (var i = 0; i < this.regions.length; i++) { - if (this.regions[i].name == name) { - return this.regions[i]; - } - } - return null; - }; - TextureAtlas.prototype.dispose = function () { - for (var i = 0; i < this.pages.length; i++) { - this.pages[i].baseTexture.dispose(); - } - }; - return TextureAtlas; - }()); - core.TextureAtlas = TextureAtlas; - var TextureAtlasReader = (function () { - function TextureAtlasReader(text) { - this.index = 0; - this.lines = text.split(/\r\n|\r|\n/); - } - TextureAtlasReader.prototype.readLine = function () { - if (this.index >= this.lines.length) - return null; - return this.lines[this.index++]; - }; - TextureAtlasReader.prototype.readValue = function () { - var line = this.readLine(); - var colon = line.indexOf(":"); - if (colon == -1) - throw new Error("Invalid line: " + line); - return line.substring(colon + 1).trim(); - }; - TextureAtlasReader.prototype.readTuple = function (tuple) { - var line = this.readLine(); - var colon = line.indexOf(":"); - if (colon == -1) - throw new Error("Invalid line: " + line); - var i = 0, lastMatch = colon + 1; - for (; i < 3; i++) { - var comma = line.indexOf(",", lastMatch); - if (comma == -1) - break; - tuple[i] = line.substr(lastMatch, comma - lastMatch).trim(); - lastMatch = comma + 1; - } - tuple[i] = line.substring(lastMatch).trim(); - return i + 1; - }; - return TextureAtlasReader; - }()); - var TextureAtlasPage = (function () { - function TextureAtlasPage() { - } - TextureAtlasPage.prototype.setFilters = function () { - var tex = this.baseTexture; - var filter = this.minFilter; - if (filter == core.TextureFilter.Linear) { - tex.scaleMode = PIXI.SCALE_MODES.LINEAR; - } - else if (this.minFilter == core.TextureFilter.Nearest) { - tex.scaleMode = PIXI.SCALE_MODES.NEAREST; - } - else { - tex.mipmap = true; - if (filter == core.TextureFilter.MipMapNearestNearest) { - tex.scaleMode = PIXI.SCALE_MODES.NEAREST; - } - else { - tex.scaleMode = PIXI.SCALE_MODES.LINEAR; - } - } - }; - return TextureAtlasPage; - }()); - core.TextureAtlasPage = TextureAtlasPage; - var TextureAtlasRegion = (function (_super) { - __extends(TextureAtlasRegion, _super); - function TextureAtlasRegion() { - return _super !== null && _super.apply(this, arguments) || this; - } - return TextureAtlasRegion; - }(core.TextureRegion)); - core.TextureAtlasRegion = TextureAtlasRegion; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var TransformConstraint = (function () { - function TransformConstraint(data, skeleton) { - this.rotateMix = 0; - this.translateMix = 0; - this.scaleMix = 0; - this.shearMix = 0; - this.temp = new core.Vector2(); - this.active = false; - if (data == null) - throw new Error("data cannot be null."); - if (skeleton == null) - throw new Error("skeleton cannot be null."); - this.data = data; - this.rotateMix = data.rotateMix; - this.translateMix = data.translateMix; - this.scaleMix = data.scaleMix; - this.shearMix = data.shearMix; - this.bones = new Array(); - for (var i = 0; i < data.bones.length; i++) - this.bones.push(skeleton.findBone(data.bones[i].name)); - this.target = skeleton.findBone(data.target.name); - } - TransformConstraint.prototype.isActive = function () { - return this.active; - }; - TransformConstraint.prototype.apply = function () { - this.update(); - }; - TransformConstraint.prototype.update = function () { - if (this.data.local) { - if (this.data.relative) - this.applyRelativeLocal(); - else - this.applyAbsoluteLocal(); - } - else { - if (this.data.relative) - this.applyRelativeWorld(); - else - this.applyAbsoluteWorld(); - } - }; - TransformConstraint.prototype.applyAbsoluteWorld = function () { - var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix; - var target = this.target; - var targetMat = target.matrix; - var ta = targetMat.a, tb = targetMat.c, tc = targetMat.b, td = targetMat.d; - var degRadReflect = ta * td - tb * tc > 0 ? core.MathUtils.degRad : -core.MathUtils.degRad; - var offsetRotation = this.data.offsetRotation * degRadReflect; - var offsetShearY = this.data.offsetShearY * degRadReflect; - var bones = this.bones; - for (var i = 0, n = bones.length; i < n; i++) { - var bone = bones[i]; - var modified = false; - var mat = bone.matrix; - if (rotateMix != 0) { - var a = mat.a, b = mat.c, c = mat.b, d = mat.d; - var r = Math.atan2(tc, ta) - Math.atan2(c, a) + offsetRotation; - if (r > core.MathUtils.PI) - r -= core.MathUtils.PI2; - else if (r < -core.MathUtils.PI) - r += core.MathUtils.PI2; - r *= rotateMix; - var cos = Math.cos(r), sin = Math.sin(r); - mat.a = cos * a - sin * c; - mat.c = cos * b - sin * d; - mat.b = sin * a + cos * c; - mat.d = sin * b + cos * d; - modified = true; - } - if (translateMix != 0) { - var temp = this.temp; - target.localToWorld(temp.set(this.data.offsetX, this.data.offsetY)); - mat.tx += (temp.x - mat.tx) * translateMix; - mat.ty += (temp.y - mat.ty) * translateMix; - modified = true; - } - if (scaleMix > 0) { - var s = Math.sqrt(mat.a * mat.a + mat.b * mat.b); - var ts = Math.sqrt(ta * ta + tc * tc); - if (s > 0.00001) - s = (s + (ts - s + this.data.offsetScaleX) * scaleMix) / s; - mat.a *= s; - mat.b *= s; - s = Math.sqrt(mat.c * mat.c + mat.d * mat.d); - ts = Math.sqrt(tb * tb + td * td); - if (s > 0.00001) - s = (s + (ts - s + this.data.offsetScaleY) * scaleMix) / s; - mat.c *= s; - mat.d *= s; - modified = true; - } - if (shearMix > 0) { - var b = mat.c, d = mat.d; - var by = Math.atan2(d, b); - var r = Math.atan2(td, tb) - Math.atan2(tc, ta) - (by - Math.atan2(mat.b, mat.a)); - if (r > core.MathUtils.PI) - r -= core.MathUtils.PI2; - else if (r < -core.MathUtils.PI) - r += core.MathUtils.PI2; - r = by + (r + offsetShearY) * shearMix; - var s = Math.sqrt(b * b + d * d); - mat.c = Math.cos(r) * s; - mat.d = Math.sin(r) * s; - modified = true; - } - if (modified) - bone.appliedValid = false; - } - }; - TransformConstraint.prototype.applyRelativeWorld = function () { - var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix; - var target = this.target; - var targetMat = target.matrix; - var ta = targetMat.a, tb = targetMat.c, tc = targetMat.b, td = targetMat.d; - var degRadReflect = ta * td - tb * tc > 0 ? core.MathUtils.degRad : -core.MathUtils.degRad; - var offsetRotation = this.data.offsetRotation * degRadReflect, offsetShearY = this.data.offsetShearY * degRadReflect; - var bones = this.bones; - for (var i = 0, n = bones.length; i < n; i++) { - var bone = bones[i]; - var modified = false; - var mat = bone.matrix; - if (rotateMix != 0) { - var a = mat.a, b = mat.c, c = mat.b, d = mat.d; - var r = Math.atan2(tc, ta) + offsetRotation; - if (r > core.MathUtils.PI) - r -= core.MathUtils.PI2; - else if (r < -core.MathUtils.PI) - r += core.MathUtils.PI2; - r *= rotateMix; - var cos = Math.cos(r), sin = Math.sin(r); - mat.a = cos * a - sin * c; - mat.c = cos * b - sin * d; - mat.b = sin * a + cos * c; - mat.d = sin * b + cos * d; - modified = true; - } - if (translateMix != 0) { - var temp = this.temp; - target.localToWorld(temp.set(this.data.offsetX, this.data.offsetY)); - mat.tx += temp.x * translateMix; - mat.ty += temp.y * translateMix; - modified = true; - } - if (scaleMix > 0) { - var s = (Math.sqrt(ta * ta + tc * tc) - 1 + this.data.offsetScaleX) * scaleMix + 1; - mat.a *= s; - mat.b *= s; - s = (Math.sqrt(tb * tb + td * td) - 1 + this.data.offsetScaleY) * scaleMix + 1; - mat.c *= s; - mat.d *= s; - modified = true; - } - if (shearMix > 0) { - var r = Math.atan2(td, tb) - Math.atan2(tc, ta); - if (r > core.MathUtils.PI) - r -= core.MathUtils.PI2; - else if (r < -core.MathUtils.PI) - r += core.MathUtils.PI2; - var b = mat.c, d = mat.d; - r = Math.atan2(d, b) + (r - core.MathUtils.PI / 2 + offsetShearY) * shearMix; - var s = Math.sqrt(b * b + d * d); - mat.c = Math.cos(r) * s; - mat.d = Math.sin(r) * s; - modified = true; - } - if (modified) - bone.appliedValid = false; - } - }; - TransformConstraint.prototype.applyAbsoluteLocal = function () { - var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix; - var target = this.target; - if (!target.appliedValid) - target.updateAppliedTransform(); - var bones = this.bones; - for (var i = 0, n = bones.length; i < n; i++) { - var bone = bones[i]; - if (!bone.appliedValid) - bone.updateAppliedTransform(); - var rotation = bone.arotation; - if (rotateMix != 0) { - var r = target.arotation - rotation + this.data.offsetRotation; - r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; - rotation += r * rotateMix; - } - var x = bone.ax, y = bone.ay; - if (translateMix != 0) { - x += (target.ax - x + this.data.offsetX) * translateMix; - y += (target.ay - y + this.data.offsetY) * translateMix; - } - var scaleX = bone.ascaleX, scaleY = bone.ascaleY; - if (scaleMix > 0) { - if (scaleX > 0.00001) - scaleX = (scaleX + (target.ascaleX - scaleX + this.data.offsetScaleX) * scaleMix) / scaleX; - if (scaleY > 0.00001) - scaleY = (scaleY + (target.ascaleY - scaleY + this.data.offsetScaleY) * scaleMix) / scaleY; - } - var shearY = bone.ashearY; - if (shearMix > 0) { - var r = target.ashearY - shearY + this.data.offsetShearY; - r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; - bone.shearY += r * shearMix; - } - bone.updateWorldTransformWith(x, y, rotation, scaleX, scaleY, bone.ashearX, shearY); - } - }; - TransformConstraint.prototype.applyRelativeLocal = function () { - var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix; - var target = this.target; - if (!target.appliedValid) - target.updateAppliedTransform(); - var bones = this.bones; - for (var i = 0, n = bones.length; i < n; i++) { - var bone = bones[i]; - if (!bone.appliedValid) - bone.updateAppliedTransform(); - var rotation = bone.arotation; - if (rotateMix != 0) - rotation += (target.arotation + this.data.offsetRotation) * rotateMix; - var x = bone.ax, y = bone.ay; - if (translateMix != 0) { - x += (target.ax + this.data.offsetX) * translateMix; - y += (target.ay + this.data.offsetY) * translateMix; - } - var scaleX = bone.ascaleX, scaleY = bone.ascaleY; - if (scaleMix > 0) { - if (scaleX > 0.00001) - scaleX *= ((target.ascaleX - 1 + this.data.offsetScaleX) * scaleMix) + 1; - if (scaleY > 0.00001) - scaleY *= ((target.ascaleY - 1 + this.data.offsetScaleY) * scaleMix) + 1; - } - var shearY = bone.ashearY; - if (shearMix > 0) - shearY += (target.ashearY + this.data.offsetShearY) * shearMix; - bone.updateWorldTransformWith(x, y, rotation, scaleX, scaleY, bone.ashearX, shearY); - } - }; - return TransformConstraint; - }()); - core.TransformConstraint = TransformConstraint; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var TransformConstraintData = (function (_super) { - __extends(TransformConstraintData, _super); - function TransformConstraintData(name) { - var _this = _super.call(this, name, 0, false) || this; - _this.bones = new Array(); - _this.rotateMix = 0; - _this.translateMix = 0; - _this.scaleMix = 0; - _this.shearMix = 0; - _this.offsetRotation = 0; - _this.offsetX = 0; - _this.offsetY = 0; - _this.offsetScaleX = 0; - _this.offsetScaleY = 0; - _this.offsetShearY = 0; - _this.relative = false; - _this.local = false; - return _this; - } - return TransformConstraintData; - }(core.ConstraintData)); - core.TransformConstraintData = TransformConstraintData; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var Triangulator = (function () { - function Triangulator() { - this.convexPolygons = new Array(); - this.convexPolygonsIndices = new Array(); - this.indicesArray = new Array(); - this.isConcaveArray = new Array(); - this.triangles = new Array(); - this.polygonPool = new core.Pool(function () { - return new Array(); - }); - this.polygonIndicesPool = new core.Pool(function () { - return new Array(); - }); - } - Triangulator.prototype.triangulate = function (verticesArray) { - var vertices = verticesArray; - var vertexCount = verticesArray.length >> 1; - var indices = this.indicesArray; - indices.length = 0; - for (var i = 0; i < vertexCount; i++) - indices[i] = i; - var isConcave = this.isConcaveArray; - isConcave.length = 0; - for (var i = 0, n = vertexCount; i < n; ++i) - isConcave[i] = Triangulator.isConcave(i, vertexCount, vertices, indices); - var triangles = this.triangles; - triangles.length = 0; - while (vertexCount > 3) { - var previous = vertexCount - 1, i = 0, next = 1; - while (true) { - outer: if (!isConcave[i]) { - var p1 = indices[previous] << 1, p2 = indices[i] << 1, p3 = indices[next] << 1; - var p1x = vertices[p1], p1y = vertices[p1 + 1]; - var p2x = vertices[p2], p2y = vertices[p2 + 1]; - var p3x = vertices[p3], p3y = vertices[p3 + 1]; - for (var ii = (next + 1) % vertexCount; ii != previous; ii = (ii + 1) % vertexCount) { - if (!isConcave[ii]) - continue; - var v = indices[ii] << 1; - var vx = vertices[v], vy = vertices[v + 1]; - if (Triangulator.positiveArea(p3x, p3y, p1x, p1y, vx, vy)) { - if (Triangulator.positiveArea(p1x, p1y, p2x, p2y, vx, vy)) { - if (Triangulator.positiveArea(p2x, p2y, p3x, p3y, vx, vy)) - break outer; - } - } - } - break; - } - if (next == 0) { - do { - if (!isConcave[i]) - break; - i--; - } while (i > 0); - break; - } - previous = i; - i = next; - next = (next + 1) % vertexCount; - } - triangles.push(indices[(vertexCount + i - 1) % vertexCount]); - triangles.push(indices[i]); - triangles.push(indices[(i + 1) % vertexCount]); - indices.splice(i, 1); - isConcave.splice(i, 1); - vertexCount--; - var previousIndex = (vertexCount + i - 1) % vertexCount; - var nextIndex = i == vertexCount ? 0 : i; - isConcave[previousIndex] = Triangulator.isConcave(previousIndex, vertexCount, vertices, indices); - isConcave[nextIndex] = Triangulator.isConcave(nextIndex, vertexCount, vertices, indices); - } - if (vertexCount == 3) { - triangles.push(indices[2]); - triangles.push(indices[0]); - triangles.push(indices[1]); - } - return triangles; - }; - Triangulator.prototype.decompose = function (verticesArray, triangles) { - var vertices = verticesArray; - var convexPolygons = this.convexPolygons; - this.polygonPool.freeAll(convexPolygons); - convexPolygons.length = 0; - var convexPolygonsIndices = this.convexPolygonsIndices; - this.polygonIndicesPool.freeAll(convexPolygonsIndices); - convexPolygonsIndices.length = 0; - var polygonIndices = this.polygonIndicesPool.obtain(); - polygonIndices.length = 0; - var polygon = this.polygonPool.obtain(); - polygon.length = 0; - var fanBaseIndex = -1, lastWinding = 0; - for (var i = 0, n = triangles.length; i < n; i += 3) { - var t1 = triangles[i] << 1, t2 = triangles[i + 1] << 1, t3 = triangles[i + 2] << 1; - var x1 = vertices[t1], y1 = vertices[t1 + 1]; - var x2 = vertices[t2], y2 = vertices[t2 + 1]; - var x3 = vertices[t3], y3 = vertices[t3 + 1]; - var merged = false; - if (fanBaseIndex == t1) { - var o = polygon.length - 4; - var winding1 = Triangulator.winding(polygon[o], polygon[o + 1], polygon[o + 2], polygon[o + 3], x3, y3); - var winding2 = Triangulator.winding(x3, y3, polygon[0], polygon[1], polygon[2], polygon[3]); - if (winding1 == lastWinding && winding2 == lastWinding) { - polygon.push(x3); - polygon.push(y3); - polygonIndices.push(t3); - merged = true; - } - } - if (!merged) { - if (polygon.length > 0) { - convexPolygons.push(polygon); - convexPolygonsIndices.push(polygonIndices); - } - else { - this.polygonPool.free(polygon); - this.polygonIndicesPool.free(polygonIndices); - } - polygon = this.polygonPool.obtain(); - polygon.length = 0; - polygon.push(x1); - polygon.push(y1); - polygon.push(x2); - polygon.push(y2); - polygon.push(x3); - polygon.push(y3); - polygonIndices = this.polygonIndicesPool.obtain(); - polygonIndices.length = 0; - polygonIndices.push(t1); - polygonIndices.push(t2); - polygonIndices.push(t3); - lastWinding = Triangulator.winding(x1, y1, x2, y2, x3, y3); - fanBaseIndex = t1; - } - } - if (polygon.length > 0) { - convexPolygons.push(polygon); - convexPolygonsIndices.push(polygonIndices); - } - for (var i = 0, n = convexPolygons.length; i < n; i++) { - polygonIndices = convexPolygonsIndices[i]; - if (polygonIndices.length == 0) - continue; - var firstIndex = polygonIndices[0]; - var lastIndex = polygonIndices[polygonIndices.length - 1]; - polygon = convexPolygons[i]; - var o = polygon.length - 4; - var prevPrevX = polygon[o], prevPrevY = polygon[o + 1]; - var prevX = polygon[o + 2], prevY = polygon[o + 3]; - var firstX = polygon[0], firstY = polygon[1]; - var secondX = polygon[2], secondY = polygon[3]; - var winding = Triangulator.winding(prevPrevX, prevPrevY, prevX, prevY, firstX, firstY); - for (var ii = 0; ii < n; ii++) { - if (ii == i) - continue; - var otherIndices = convexPolygonsIndices[ii]; - if (otherIndices.length != 3) - continue; - var otherFirstIndex = otherIndices[0]; - var otherSecondIndex = otherIndices[1]; - var otherLastIndex = otherIndices[2]; - var otherPoly = convexPolygons[ii]; - var x3 = otherPoly[otherPoly.length - 2], y3 = otherPoly[otherPoly.length - 1]; - if (otherFirstIndex != firstIndex || otherSecondIndex != lastIndex) - continue; - var winding1 = Triangulator.winding(prevPrevX, prevPrevY, prevX, prevY, x3, y3); - var winding2 = Triangulator.winding(x3, y3, firstX, firstY, secondX, secondY); - if (winding1 == winding && winding2 == winding) { - otherPoly.length = 0; - otherIndices.length = 0; - polygon.push(x3); - polygon.push(y3); - polygonIndices.push(otherLastIndex); - prevPrevX = prevX; - prevPrevY = prevY; - prevX = x3; - prevY = y3; - ii = 0; - } - } - } - for (var i = convexPolygons.length - 1; i >= 0; i--) { - polygon = convexPolygons[i]; - if (polygon.length == 0) { - convexPolygons.splice(i, 1); - this.polygonPool.free(polygon); - polygonIndices = convexPolygonsIndices[i]; - convexPolygonsIndices.splice(i, 1); - this.polygonIndicesPool.free(polygonIndices); - } - } - return convexPolygons; - }; - Triangulator.isConcave = function (index, vertexCount, vertices, indices) { - var previous = indices[(vertexCount + index - 1) % vertexCount] << 1; - var current = indices[index] << 1; - var next = indices[(index + 1) % vertexCount] << 1; - return !this.positiveArea(vertices[previous], vertices[previous + 1], vertices[current], vertices[current + 1], vertices[next], vertices[next + 1]); - }; - Triangulator.positiveArea = function (p1x, p1y, p2x, p2y, p3x, p3y) { - return p1x * (p3y - p2y) + p2x * (p1y - p3y) + p3x * (p2y - p1y) >= 0; - }; - Triangulator.winding = function (p1x, p1y, p2x, p2y, p3x, p3y) { - var px = p2x - p1x, py = p2y - p1y; - return p3x * py - p3y * px + px * p1y - p1x * py >= 0 ? 1 : -1; - }; - return Triangulator; - }()); - core.Triangulator = Triangulator; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var IntSet = (function () { - function IntSet() { - this.array = new Array(); - } - IntSet.prototype.add = function (value) { - var contains = this.contains(value); - this.array[value | 0] = value | 0; - return !contains; - }; - IntSet.prototype.contains = function (value) { - return this.array[value | 0] != undefined; - }; - IntSet.prototype.remove = function (value) { - this.array[value | 0] = undefined; - }; - IntSet.prototype.clear = function () { - this.array.length = 0; - }; - return IntSet; - }()); - core.IntSet = IntSet; - var Color = (function () { - function Color(r, g, b, a) { - if (r === void 0) { r = 0; } - if (g === void 0) { g = 0; } - if (b === void 0) { b = 0; } - if (a === void 0) { a = 0; } - this.r = r; - this.g = g; - this.b = b; - this.a = a; - } - Color.prototype.set = function (r, g, b, a) { - this.r = r; - this.g = g; - this.b = b; - this.a = a; - this.clamp(); - return this; - }; - Color.prototype.setFromColor = function (c) { - this.r = c.r; - this.g = c.g; - this.b = c.b; - this.a = c.a; - return this; - }; - Color.prototype.setFromString = function (hex) { - hex = hex.charAt(0) == '#' ? hex.substr(1) : hex; - this.r = parseInt(hex.substr(0, 2), 16) / 255.0; - this.g = parseInt(hex.substr(2, 2), 16) / 255.0; - this.b = parseInt(hex.substr(4, 2), 16) / 255.0; - this.a = (hex.length != 8 ? 255 : parseInt(hex.substr(6, 2), 16)) / 255.0; - return this; - }; - Color.prototype.add = function (r, g, b, a) { - this.r += r; - this.g += g; - this.b += b; - this.a += a; - this.clamp(); - return this; - }; - Color.prototype.clamp = function () { - if (this.r < 0) - this.r = 0; - else if (this.r > 1) - this.r = 1; - if (this.g < 0) - this.g = 0; - else if (this.g > 1) - this.g = 1; - if (this.b < 0) - this.b = 0; - else if (this.b > 1) - this.b = 1; - if (this.a < 0) - this.a = 0; - else if (this.a > 1) - this.a = 1; - return this; - }; - Color.rgba8888ToColor = function (color, value) { - color.r = ((value & 0xff000000) >>> 24) / 255; - color.g = ((value & 0x00ff0000) >>> 16) / 255; - color.b = ((value & 0x0000ff00) >>> 8) / 255; - color.a = ((value & 0x000000ff)) / 255; - }; - Color.rgb888ToColor = function (color, value) { - color.r = ((value & 0x00ff0000) >>> 16) / 255; - color.g = ((value & 0x0000ff00) >>> 8) / 255; - color.b = ((value & 0x000000ff)) / 255; - }; - Color.WHITE = new Color(1, 1, 1, 1); - Color.RED = new Color(1, 0, 0, 1); - Color.GREEN = new Color(0, 1, 0, 1); - Color.BLUE = new Color(0, 0, 1, 1); - Color.MAGENTA = new Color(1, 0, 1, 1); - return Color; - }()); - core.Color = Color; - var MathUtils = (function () { - function MathUtils() { - } - MathUtils.clamp = function (value, min, max) { - if (value < min) - return min; - if (value > max) - return max; - return value; - }; - MathUtils.cosDeg = function (degrees) { - return Math.cos(degrees * MathUtils.degRad); - }; - MathUtils.sinDeg = function (degrees) { - return Math.sin(degrees * MathUtils.degRad); - }; - MathUtils.signum = function (value) { - return value > 0 ? 1 : value < 0 ? -1 : 0; - }; - MathUtils.toInt = function (x) { - return x > 0 ? Math.floor(x) : Math.ceil(x); - }; - MathUtils.cbrt = function (x) { - var y = Math.pow(Math.abs(x), 1 / 3); - return x < 0 ? -y : y; - }; - MathUtils.randomTriangular = function (min, max) { - return MathUtils.randomTriangularWith(min, max, (min + max) * 0.5); - }; - MathUtils.randomTriangularWith = function (min, max, mode) { - var u = Math.random(); - var d = max - min; - if (u <= (mode - min) / d) - return min + Math.sqrt(u * d * (mode - min)); - return max - Math.sqrt((1 - u) * d * (max - mode)); - }; - MathUtils.PI = 3.1415927; - MathUtils.PI2 = MathUtils.PI * 2; - MathUtils.radiansToDegrees = 180 / MathUtils.PI; - MathUtils.radDeg = MathUtils.radiansToDegrees; - MathUtils.degreesToRadians = MathUtils.PI / 180; - MathUtils.degRad = MathUtils.degreesToRadians; - return MathUtils; - }()); - core.MathUtils = MathUtils; - var Interpolation = (function () { - function Interpolation() { - } - Interpolation.prototype.apply = function (start, end, a) { - return start + (end - start) * this.applyInternal(a); - }; - return Interpolation; - }()); - core.Interpolation = Interpolation; - var Pow = (function (_super) { - __extends(Pow, _super); - function Pow(power) { - var _this = _super.call(this) || this; - _this.power = 2; - _this.power = power; - return _this; - } - Pow.prototype.applyInternal = function (a) { - if (a <= 0.5) - return Math.pow(a * 2, this.power) / 2; - return Math.pow((a - 1) * 2, this.power) / (this.power % 2 == 0 ? -2 : 2) + 1; - }; - return Pow; - }(Interpolation)); - core.Pow = Pow; - var PowOut = (function (_super) { - __extends(PowOut, _super); - function PowOut(power) { - return _super.call(this, power) || this; - } - PowOut.prototype.applyInternal = function (a) { - return Math.pow(a - 1, this.power) * (this.power % 2 == 0 ? -1 : 1) + 1; - }; - return PowOut; - }(Pow)); - core.PowOut = PowOut; - var Utils = (function () { - function Utils() { - } - Utils.arrayCopy = function (source, sourceStart, dest, destStart, numElements) { - for (var i = sourceStart, j = destStart; i < sourceStart + numElements; i++, j++) { - dest[j] = source[i]; - } - }; - Utils.setArraySize = function (array, size, value) { - if (value === void 0) { value = 0; } - var oldSize = array.length; - if (oldSize == size) - return array; - array.length = size; - if (oldSize < size) { - for (var i = oldSize; i < size; i++) - array[i] = value; - } - return array; - }; - Utils.ensureArrayCapacity = function (array, size, value) { - if (value === void 0) { value = 0; } - if (array.length >= size) - return array; - return Utils.setArraySize(array, size, value); - }; - Utils.newArray = function (size, defaultValue) { - var array = new Array(size); - for (var i = 0; i < size; i++) - array[i] = defaultValue; - return array; - }; - Utils.newFloatArray = function (size) { - if (Utils.SUPPORTS_TYPED_ARRAYS) { - return new Float32Array(size); - } - else { - var array = new Array(size); - for (var i = 0; i < array.length; i++) - array[i] = 0; - return array; - } - }; - Utils.newShortArray = function (size) { - if (Utils.SUPPORTS_TYPED_ARRAYS) { - return new Int16Array(size); - } - else { - var array = new Array(size); - for (var i = 0; i < array.length; i++) - array[i] = 0; - return array; - } - }; - Utils.toFloatArray = function (array) { - return Utils.SUPPORTS_TYPED_ARRAYS ? new Float32Array(array) : array; - }; - Utils.toSinglePrecision = function (value) { - return Utils.SUPPORTS_TYPED_ARRAYS ? Math.fround(value) : value; - }; - Utils.webkit602BugfixHelper = function (alpha, blend) { - }; - Utils.contains = function (array, element, identity) { - if (identity === void 0) { identity = true; } - for (var i = 0; i < array.length; i++) { - if (array[i] == element) - return true; - } - return false; - }; - Utils.SUPPORTS_TYPED_ARRAYS = typeof (Float32Array) !== "undefined"; - return Utils; - }()); - core.Utils = Utils; - var DebugUtils = (function () { - function DebugUtils() { - } - DebugUtils.logBones = function (skeleton) { - for (var i = 0; i < skeleton.bones.length; i++) { - var bone = skeleton.bones[i]; - var mat = bone.matrix; - console.log(bone.data.name + ", " + mat.a + ", " + mat.b + ", " + mat.c + ", " + mat.d + ", " + mat.tx + ", " + mat.ty); - } - }; - return DebugUtils; - }()); - core.DebugUtils = DebugUtils; - var Pool = (function () { - function Pool(instantiator) { - this.items = new Array(); - this.instantiator = instantiator; - } - Pool.prototype.obtain = function () { - return this.items.length > 0 ? this.items.pop() : this.instantiator(); - }; - Pool.prototype.free = function (item) { - if (item.reset) - item.reset(); - this.items.push(item); - }; - Pool.prototype.freeAll = function (items) { - for (var i = 0; i < items.length; i++) { - this.free(items[i]); - } - }; - Pool.prototype.clear = function () { - this.items.length = 0; - }; - return Pool; - }()); - core.Pool = Pool; - var Vector2 = (function () { - function Vector2(x, y) { - if (x === void 0) { x = 0; } - if (y === void 0) { y = 0; } - this.x = x; - this.y = y; - } - Vector2.prototype.set = function (x, y) { - this.x = x; - this.y = y; - return this; - }; - Vector2.prototype.length = function () { - var x = this.x; - var y = this.y; - return Math.sqrt(x * x + y * y); - }; - Vector2.prototype.normalize = function () { - var len = this.length(); - if (len != 0) { - this.x /= len; - this.y /= len; - } - return this; - }; - return Vector2; - }()); - core.Vector2 = Vector2; - var TimeKeeper = (function () { - function TimeKeeper() { - this.maxDelta = 0.064; - this.framesPerSecond = 0; - this.delta = 0; - this.totalTime = 0; - this.lastTime = Date.now() / 1000; - this.frameCount = 0; - this.frameTime = 0; - } - TimeKeeper.prototype.update = function () { - var now = Date.now() / 1000; - this.delta = now - this.lastTime; - this.frameTime += this.delta; - this.totalTime += this.delta; - if (this.delta > this.maxDelta) - this.delta = this.maxDelta; - this.lastTime = now; - this.frameCount++; - if (this.frameTime > 1) { - this.framesPerSecond = this.frameCount / this.frameTime; - this.frameTime = 0; - this.frameCount = 0; - } - }; - return TimeKeeper; - }()); - core.TimeKeeper = TimeKeeper; - var WindowedMean = (function () { - function WindowedMean(windowSize) { - if (windowSize === void 0) { windowSize = 32; } - this.addedValues = 0; - this.lastValue = 0; - this.mean = 0; - this.dirty = true; - this.values = new Array(windowSize); - } - WindowedMean.prototype.hasEnoughData = function () { - return this.addedValues >= this.values.length; - }; - WindowedMean.prototype.addValue = function (value) { - if (this.addedValues < this.values.length) - this.addedValues++; - this.values[this.lastValue++] = value; - if (this.lastValue > this.values.length - 1) - this.lastValue = 0; - this.dirty = true; - }; - WindowedMean.prototype.getMean = function () { - if (this.hasEnoughData()) { - if (this.dirty) { - var mean = 0; - for (var i = 0; i < this.values.length; i++) { - mean += this.values[i]; - } - this.mean = mean / this.values.length; - this.dirty = false; - } - return this.mean; - } - else { - return 0; - } - }; - return WindowedMean; - }()); - core.WindowedMean = WindowedMean; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var Attachment = (function () { - function Attachment(name) { - if (name == null) - throw new Error("name cannot be null."); - this.name = name; - } - return Attachment; - }()); - core.Attachment = Attachment; - var VertexAttachment = (function (_super) { - __extends(VertexAttachment, _super); - function VertexAttachment(name) { - var _this = _super.call(this, name) || this; - _this.id = (VertexAttachment.nextID++ & 65535) << 11; - _this.worldVerticesLength = 0; - _this.deformAttachment = _this; - return _this; - } - VertexAttachment.prototype.computeWorldVerticesOld = function (slot, worldVertices) { - this.computeWorldVertices(slot, 0, this.worldVerticesLength, worldVertices, 0, 2); - }; - VertexAttachment.prototype.computeWorldVertices = function (slot, start, count, worldVertices, offset, stride) { - count = offset + (count >> 1) * stride; - var skeleton = slot.bone.skeleton; - var deformArray = slot.deform; - var vertices = this.vertices; - var bones = this.bones; - if (bones == null) { - if (deformArray.length > 0) - vertices = deformArray; - var mat = slot.bone.matrix; - var x = mat.tx; - var y = mat.ty; - var a = mat.a, b = mat.c, c = mat.b, d = mat.d; - for (var v_1 = start, w = offset; w < count; v_1 += 2, w += stride) { - var vx = vertices[v_1], vy = vertices[v_1 + 1]; - worldVertices[w] = vx * a + vy * b + x; - worldVertices[w + 1] = vx * c + vy * d + y; - } - return; - } - var v = 0, skip = 0; - for (var i = 0; i < start; i += 2) { - var n = bones[v]; - v += n + 1; - skip += n; - } - var skeletonBones = skeleton.bones; - if (deformArray.length == 0) { - for (var w = offset, b = skip * 3; w < count; w += stride) { - var wx = 0, wy = 0; - var n = bones[v++]; - n += v; - for (; v < n; v++, b += 3) { - var mat = skeletonBones[bones[v]].matrix; - var vx = vertices[b], vy = vertices[b + 1], weight = vertices[b + 2]; - wx += (vx * mat.a + vy * mat.c + mat.tx) * weight; - wy += (vx * mat.b + vy * mat.d + mat.ty) * weight; - } - worldVertices[w] = wx; - worldVertices[w + 1] = wy; - } - } - else { - var deform = deformArray; - for (var w = offset, b = skip * 3, f = skip << 1; w < count; w += stride) { - var wx = 0, wy = 0; - var n = bones[v++]; - n += v; - for (; v < n; v++, b += 3, f += 2) { - var mat = skeletonBones[bones[v]].matrix; - var vx = vertices[b] + deform[f], vy = vertices[b + 1] + deform[f + 1], weight = vertices[b + 2]; - wx += (vx * mat.a + vy * mat.c + mat.tx) * weight; - wy += (vx * mat.b + vy * mat.d + mat.ty) * weight; - } - worldVertices[w] = wx; - worldVertices[w + 1] = wy; - } - } - }; - VertexAttachment.prototype.copyTo = function (attachment) { - if (this.bones != null) { - attachment.bones = new Array(this.bones.length); - core.Utils.arrayCopy(this.bones, 0, attachment.bones, 0, this.bones.length); - } - else - attachment.bones = null; - if (this.vertices != null) { - attachment.vertices = core.Utils.newFloatArray(this.vertices.length); - core.Utils.arrayCopy(this.vertices, 0, attachment.vertices, 0, this.vertices.length); - } - else - attachment.vertices = null; - attachment.worldVerticesLength = this.worldVerticesLength; - attachment.deformAttachment = this.deformAttachment; - }; - VertexAttachment.nextID = 0; - return VertexAttachment; - }(Attachment)); - core.VertexAttachment = VertexAttachment; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var AttachmentType; - (function (AttachmentType) { - AttachmentType[AttachmentType["Region"] = 0] = "Region"; - AttachmentType[AttachmentType["BoundingBox"] = 1] = "BoundingBox"; - AttachmentType[AttachmentType["Mesh"] = 2] = "Mesh"; - AttachmentType[AttachmentType["LinkedMesh"] = 3] = "LinkedMesh"; - AttachmentType[AttachmentType["Path"] = 4] = "Path"; - AttachmentType[AttachmentType["Point"] = 5] = "Point"; - AttachmentType[AttachmentType["Clipping"] = 6] = "Clipping"; - })(AttachmentType = core.AttachmentType || (core.AttachmentType = {})); - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var BoundingBoxAttachment = (function (_super) { - __extends(BoundingBoxAttachment, _super); - function BoundingBoxAttachment(name) { - var _this = _super.call(this, name) || this; - _this.color = new core.Color(1, 1, 1, 1); - return _this; - } - BoundingBoxAttachment.prototype.copy = function () { - var copy = new BoundingBoxAttachment(this.name); - this.copyTo(copy); - copy.color.setFromColor(this.color); - return copy; - }; - return BoundingBoxAttachment; - }(core.VertexAttachment)); - core.BoundingBoxAttachment = BoundingBoxAttachment; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var ClippingAttachment = (function (_super) { - __extends(ClippingAttachment, _super); - function ClippingAttachment(name) { - var _this = _super.call(this, name) || this; - _this.color = new core.Color(0.2275, 0.2275, 0.8078, 1); - return _this; - } - ClippingAttachment.prototype.copy = function () { - var copy = new ClippingAttachment(this.name); - this.copyTo(copy); - copy.endSlot = this.endSlot; - copy.color.setFromColor(this.color); - return copy; - }; - return ClippingAttachment; - }(core.VertexAttachment)); - core.ClippingAttachment = ClippingAttachment; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var MeshAttachment = (function (_super) { - __extends(MeshAttachment, _super); - function MeshAttachment(name) { - var _this = _super.call(this, name) || this; - _this.color = new core.Color(1, 1, 1, 1); - _this.tempColor = new core.Color(0, 0, 0, 0); - return _this; - } - MeshAttachment.prototype.updateUVs = function (region, uvs) { - var regionUVs = this.regionUVs; - var n = regionUVs.length; - if (!uvs || uvs.length != n) { - uvs = core.Utils.newFloatArray(n); - } - if (region == null) { - return; - } - var texture = region.texture; - var r = texture._uvs; - var w1 = region.width, h1 = region.height, w2 = region.originalWidth, h2 = region.originalHeight; - var x = region.offsetX, y = region.pixiOffsetY; - for (var i = 0; i < n; i += 2) { - var u = this.regionUVs[i], v = this.regionUVs[i + 1]; - u = (u * w2 - x) / w1; - v = (v * h2 - y) / h1; - uvs[i] = (r.x0 * (1 - u) + r.x1 * u) * (1 - v) + (r.x3 * (1 - u) + r.x2 * u) * v; - uvs[i + 1] = (r.y0 * (1 - u) + r.y1 * u) * (1 - v) + (r.y3 * (1 - u) + r.y2 * u) * v; - } - return uvs; - }; - MeshAttachment.prototype.getParentMesh = function () { - return this.parentMesh; - }; - MeshAttachment.prototype.setParentMesh = function (parentMesh) { - this.parentMesh = parentMesh; - if (parentMesh != null) { - this.bones = parentMesh.bones; - this.vertices = parentMesh.vertices; - this.worldVerticesLength = parentMesh.worldVerticesLength; - this.regionUVs = parentMesh.regionUVs; - this.triangles = parentMesh.triangles; - this.hullLength = parentMesh.hullLength; - this.worldVerticesLength = parentMesh.worldVerticesLength; - } - }; - MeshAttachment.prototype.copy = function () { - if (this.parentMesh != null) - return this.newLinkedMesh(); - var copy = new MeshAttachment(this.name); - copy.region = this.region; - copy.path = this.path; - copy.color.setFromColor(this.color); - this.copyTo(copy); - copy.regionUVs = new Float32Array(this.regionUVs.length); - core.Utils.arrayCopy(this.regionUVs, 0, copy.regionUVs, 0, this.regionUVs.length); - copy.uvs = new Array(this.uvs.length); - core.Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, this.uvs.length); - copy.triangles = new Array(this.triangles.length); - core.Utils.arrayCopy(this.triangles, 0, copy.triangles, 0, this.triangles.length); - copy.hullLength = this.hullLength; - if (this.edges != null) { - copy.edges = new Array(this.edges.length); - core.Utils.arrayCopy(this.edges, 0, copy.edges, 0, this.edges.length); - } - copy.width = this.width; - copy.height = this.height; - return copy; - }; - MeshAttachment.prototype.newLinkedMesh = function () { - var copy = new MeshAttachment(this.name); - copy.region = this.region; - copy.path = this.path; - copy.color.setFromColor(this.color); - copy.deformAttachment = this.deformAttachment; - copy.setParentMesh(this.parentMesh != null ? this.parentMesh : this); - return copy; - }; - return MeshAttachment; - }(core.VertexAttachment)); - core.MeshAttachment = MeshAttachment; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var PathAttachment = (function (_super) { - __extends(PathAttachment, _super); - function PathAttachment(name) { - var _this = _super.call(this, name) || this; - _this.closed = false; - _this.constantSpeed = false; - _this.color = new core.Color(1, 1, 1, 1); - return _this; - } - PathAttachment.prototype.copy = function () { - var copy = new PathAttachment(this.name); - this.copyTo(copy); - copy.lengths = new Array(this.lengths.length); - core.Utils.arrayCopy(this.lengths, 0, copy.lengths, 0, this.lengths.length); - copy.closed = closed; - copy.constantSpeed = this.constantSpeed; - copy.color.setFromColor(this.color); - return copy; - }; - return PathAttachment; - }(core.VertexAttachment)); - core.PathAttachment = PathAttachment; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var PointAttachment = (function (_super) { - __extends(PointAttachment, _super); - function PointAttachment(name) { - var _this = _super.call(this, name) || this; - _this.color = new core.Color(0.38, 0.94, 0, 1); - return _this; - } - PointAttachment.prototype.computeWorldPosition = function (bone, point) { - var mat = bone.matrix; - point.x = this.x * mat.a + this.y * mat.c + bone.worldX; - point.y = this.x * mat.b + this.y * mat.d + bone.worldY; - return point; - }; - PointAttachment.prototype.computeWorldRotation = function (bone) { - var mat = bone.matrix; - var cos = core.MathUtils.cosDeg(this.rotation), sin = core.MathUtils.sinDeg(this.rotation); - var x = cos * mat.a + sin * mat.c; - var y = cos * mat.b + sin * mat.d; - return Math.atan2(y, x) * core.MathUtils.radDeg; - }; - PointAttachment.prototype.copy = function () { - var copy = new PointAttachment(this.name); - copy.x = this.x; - copy.y = this.y; - copy.rotation = this.rotation; - copy.color.setFromColor(this.color); - return copy; - }; - return PointAttachment; - }(core.VertexAttachment)); - core.PointAttachment = PointAttachment; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var RegionAttachment = (function (_super) { - __extends(RegionAttachment, _super); - function RegionAttachment(name) { - var _this = _super.call(this, name) || this; - _this.x = 0; - _this.y = 0; - _this.scaleX = 1; - _this.scaleY = 1; - _this.rotation = 0; - _this.width = 0; - _this.height = 0; - _this.color = new core.Color(1, 1, 1, 1); - _this.offset = core.Utils.newFloatArray(8); - _this.uvs = core.Utils.newFloatArray(8); - _this.tempColor = new core.Color(1, 1, 1, 1); - return _this; - } - RegionAttachment.prototype.updateOffset = function () { - var regionScaleX = this.width / this.region.originalWidth * this.scaleX; - var regionScaleY = this.height / this.region.originalHeight * this.scaleY; - var localX = -this.width / 2 * this.scaleX + this.region.offsetX * regionScaleX; - var localY = -this.height / 2 * this.scaleY + this.region.offsetY * regionScaleY; - var localX2 = localX + this.region.width * regionScaleX; - var localY2 = localY + this.region.height * regionScaleY; - var radians = this.rotation * Math.PI / 180; - var cos = Math.cos(radians); - var sin = Math.sin(radians); - var localXCos = localX * cos + this.x; - var localXSin = localX * sin; - var localYCos = localY * cos + this.y; - var localYSin = localY * sin; - var localX2Cos = localX2 * cos + this.x; - var localX2Sin = localX2 * sin; - var localY2Cos = localY2 * cos + this.y; - var localY2Sin = localY2 * sin; - var offset = this.offset; - offset[RegionAttachment.OX1] = localXCos - localYSin; - offset[RegionAttachment.OY1] = localYCos + localXSin; - offset[RegionAttachment.OX2] = localXCos - localY2Sin; - offset[RegionAttachment.OY2] = localY2Cos + localXSin; - offset[RegionAttachment.OX3] = localX2Cos - localY2Sin; - offset[RegionAttachment.OY3] = localY2Cos + localX2Sin; - offset[RegionAttachment.OX4] = localX2Cos - localYSin; - offset[RegionAttachment.OY4] = localYCos + localX2Sin; - }; - RegionAttachment.prototype.setRegion = function (region) { - this.region = region; - var uvs = this.uvs; - if (region.rotate) { - uvs[2] = region.u; - uvs[3] = region.v2; - uvs[4] = region.u; - uvs[5] = region.v; - uvs[6] = region.u2; - uvs[7] = region.v; - uvs[0] = region.u2; - uvs[1] = region.v2; - } - else { - uvs[0] = region.u; - uvs[1] = region.v2; - uvs[2] = region.u; - uvs[3] = region.v; - uvs[4] = region.u2; - uvs[5] = region.v; - uvs[6] = region.u2; - uvs[7] = region.v2; - } - }; - RegionAttachment.prototype.computeWorldVertices = function (bone, worldVertices, offset, stride) { - var vertexOffset = this.offset; - var mat = bone.matrix; - var x = mat.tx, y = mat.ty; - var a = mat.a, b = mat.c, c = mat.b, d = mat.d; - var offsetX = 0, offsetY = 0; - offsetX = vertexOffset[RegionAttachment.OX1]; - offsetY = vertexOffset[RegionAttachment.OY1]; - worldVertices[offset] = offsetX * a + offsetY * b + x; - worldVertices[offset + 1] = offsetX * c + offsetY * d + y; - offset += stride; - offsetX = vertexOffset[RegionAttachment.OX2]; - offsetY = vertexOffset[RegionAttachment.OY2]; - worldVertices[offset] = offsetX * a + offsetY * b + x; - worldVertices[offset + 1] = offsetX * c + offsetY * d + y; - offset += stride; - offsetX = vertexOffset[RegionAttachment.OX3]; - offsetY = vertexOffset[RegionAttachment.OY3]; - worldVertices[offset] = offsetX * a + offsetY * b + x; - worldVertices[offset + 1] = offsetX * c + offsetY * d + y; - offset += stride; - offsetX = vertexOffset[RegionAttachment.OX4]; - offsetY = vertexOffset[RegionAttachment.OY4]; - worldVertices[offset] = offsetX * a + offsetY * b + x; - worldVertices[offset + 1] = offsetX * c + offsetY * d + y; - }; - RegionAttachment.prototype.copy = function () { - var copy = new RegionAttachment(this.name); - copy.region = this.region; - copy.rendererObject = this.rendererObject; - copy.path = this.path; - copy.x = this.x; - copy.y = this.y; - copy.scaleX = this.scaleX; - copy.scaleY = this.scaleY; - copy.rotation = this.rotation; - copy.width = this.width; - copy.height = this.height; - core.Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, 8); - core.Utils.arrayCopy(this.offset, 0, copy.offset, 0, 8); - copy.color.setFromColor(this.color); - return copy; - }; - RegionAttachment.OX1 = 0; - RegionAttachment.OY1 = 1; - RegionAttachment.OX2 = 2; - RegionAttachment.OY2 = 3; - RegionAttachment.OX3 = 4; - RegionAttachment.OY3 = 5; - RegionAttachment.OX4 = 6; - RegionAttachment.OY4 = 7; - RegionAttachment.X1 = 0; - RegionAttachment.Y1 = 1; - RegionAttachment.C1R = 2; - RegionAttachment.C1G = 3; - RegionAttachment.C1B = 4; - RegionAttachment.C1A = 5; - RegionAttachment.U1 = 6; - RegionAttachment.V1 = 7; - RegionAttachment.X2 = 8; - RegionAttachment.Y2 = 9; - RegionAttachment.C2R = 10; - RegionAttachment.C2G = 11; - RegionAttachment.C2B = 12; - RegionAttachment.C2A = 13; - RegionAttachment.U2 = 14; - RegionAttachment.V2 = 15; - RegionAttachment.X3 = 16; - RegionAttachment.Y3 = 17; - RegionAttachment.C3R = 18; - RegionAttachment.C3G = 19; - RegionAttachment.C3B = 20; - RegionAttachment.C3A = 21; - RegionAttachment.U3 = 22; - RegionAttachment.V3 = 23; - RegionAttachment.X4 = 24; - RegionAttachment.Y4 = 25; - RegionAttachment.C4R = 26; - RegionAttachment.C4G = 27; - RegionAttachment.C4B = 28; - RegionAttachment.C4A = 29; - RegionAttachment.U4 = 30; - RegionAttachment.V4 = 31; - return RegionAttachment; - }(core.Attachment)); - core.RegionAttachment = RegionAttachment; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var JitterEffect = (function () { - function JitterEffect(jitterX, jitterY) { - this.jitterX = 0; - this.jitterY = 0; - this.jitterX = jitterX; - this.jitterY = jitterY; - } - JitterEffect.prototype.begin = function (skeleton) { - }; - JitterEffect.prototype.transform = function (position, uv, light, dark) { - position.x += core.MathUtils.randomTriangular(-this.jitterX, this.jitterY); - position.y += core.MathUtils.randomTriangular(-this.jitterX, this.jitterY); - }; - JitterEffect.prototype.end = function () { - }; - return JitterEffect; - }()); - core.JitterEffect = JitterEffect; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var core; - (function (core) { - var SwirlEffect = (function () { - function SwirlEffect(radius) { - this.centerX = 0; - this.centerY = 0; - this.radius = 0; - this.angle = 0; - this.worldX = 0; - this.worldY = 0; - this.radius = radius; - } - SwirlEffect.prototype.begin = function (skeleton) { - this.worldX = skeleton.x + this.centerX; - this.worldY = skeleton.y + this.centerY; - }; - SwirlEffect.prototype.transform = function (position, uv, light, dark) { - var radAngle = this.angle * core.MathUtils.degreesToRadians; - var x = position.x - this.worldX; - var y = position.y - this.worldY; - var dist = Math.sqrt(x * x + y * y); - if (dist < this.radius) { - var theta = SwirlEffect.interpolation.apply(0, radAngle, (this.radius - dist) / this.radius); - var cos = Math.cos(theta); - var sin = Math.sin(theta); - position.x = cos * x - sin * y + this.worldX; - position.y = sin * x + cos * y + this.worldY; - } - }; - SwirlEffect.prototype.end = function () { - }; - SwirlEffect.interpolation = new core.PowOut(2); - return SwirlEffect; - }()); - core.SwirlEffect = SwirlEffect; - })(core = pixi_spine.core || (pixi_spine.core = {})); -})(pixi_spine || (pixi_spine = {})); -(function () { - if (!Math.fround) { - Math.fround = Math.fround = (function (array) { - return function (x) { - return array[0] = x, array[0]; - }; - })(new Float32Array(1)); - } -})(); -var pixi_spine; -(function (pixi_spine) { - pixi_spine.core.Bone.yDown = true; - var tempRgb = [0, 0, 0]; - var SpineSprite = (function (_super) { - __extends(SpineSprite, _super); - function SpineSprite() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.region = null; - return _this; - } - return SpineSprite; - }(PIXI.Sprite)); - pixi_spine.SpineSprite = SpineSprite; - var SpineMesh = (function (_super) { - __extends(SpineMesh, _super); - function SpineMesh(texture, vertices, uvs, indices, drawMode) { - return _super.call(this, texture, vertices, uvs, indices, drawMode) || this; - } - return SpineMesh; - }(PIXI.mesh.Mesh)); - pixi_spine.SpineMesh = SpineMesh; - var Spine = (function (_super) { - __extends(Spine, _super); - function Spine(spineData) { - var _this = _super.call(this) || this; - if (!spineData) { - throw new Error('The spineData param is required.'); - } - if ((typeof spineData) === "string") { - throw new Error('spineData param cant be string. Please use spine.Spine.fromAtlas("YOUR_RESOURCE_NAME") from now on.'); - } - _this.spineData = spineData; - _this.skeleton = new pixi_spine.core.Skeleton(spineData); - _this.skeleton.updateWorldTransform(); - _this.stateData = new pixi_spine.core.AnimationStateData(spineData); - _this.state = new pixi_spine.core.AnimationState(_this.stateData); - _this.slotContainers = []; - _this.tempClipContainers = []; - for (var i = 0, n = _this.skeleton.slots.length; i < n; i++) { - var slot = _this.skeleton.slots[i]; - var attachment = slot.getAttachment(); - var slotContainer = _this.newContainer(); - _this.slotContainers.push(slotContainer); - _this.addChild(slotContainer); - _this.tempClipContainers.push(null); - if (attachment instanceof pixi_spine.core.RegionAttachment) { - var spriteName = attachment.region.name; - var sprite = _this.createSprite(slot, attachment, spriteName); - slot.currentSprite = sprite; - slot.currentSpriteName = spriteName; - slotContainer.addChild(sprite); - } - else if (attachment instanceof pixi_spine.core.MeshAttachment) { - var mesh = _this.createMesh(slot, attachment); - slot.currentMesh = mesh; - slot.currentMeshName = attachment.name; - slotContainer.addChild(mesh); - } - else if (attachment instanceof pixi_spine.core.ClippingAttachment) { - _this.createGraphics(slot, attachment); - slotContainer.addChild(slot.clippingContainer); - slotContainer.addChild(slot.currentGraphics); - } - else { - continue; - } - } - _this.autoUpdate = true; - _this.tintRgb = new Float32Array([1, 1, 1]); - return _this; - } - Object.defineProperty(Spine.prototype, "autoUpdate", { - get: function () { - return (this.updateTransform === Spine.prototype.autoUpdateTransform); - }, - set: function (value) { - this.updateTransform = value ? Spine.prototype.autoUpdateTransform : PIXI.Container.prototype.updateTransform; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Spine.prototype, "visible", { - get: function () { - return this._visible; - }, - set: function (value) { - if (value !== this._visible) { - this._visible = value; - if (value) { - this.lastTime = 0; - } - } - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Spine.prototype, "tint", { - get: function () { - return PIXI.utils.rgb2hex(this.tintRgb); - }, - set: function (value) { - this.tintRgb = PIXI.utils.hex2rgb(value, this.tintRgb); - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Spine.prototype, "delayLimit", { - get: function () { - var limit = typeof this.localDelayLimit !== "undefined" ? - this.localDelayLimit : Spine.globalDelayLimit; - return limit || Number.MAX_VALUE; - }, - enumerable: false, - configurable: true - }); - Spine.prototype.update = function (dt) { - var delayLimit = this.delayLimit; - if (dt > delayLimit) - dt = delayLimit; - this.state.update(dt); - this.state.apply(this.skeleton); - if (!this.skeleton) - return; - this.skeleton.updateWorldTransform(); - var slots = this.skeleton.slots; - var globalClr = this.color; - var light = null, dark = null; - if (globalClr) { - light = globalClr.light; - dark = globalClr.dark; - } - else { - light = this.tintRgb; - } - var thack = PIXI.TransformBase && (this.transformHack() == 1); - for (var i = 0, n = slots.length; i < n; i++) { - var slot = slots[i]; - var attachment = slot.getAttachment(); - var slotContainer = this.slotContainers[i]; - if (!attachment) { - slotContainer.visible = false; - continue; - } - var spriteColor = null; - var attColor = attachment.color; - if (attachment instanceof pixi_spine.core.RegionAttachment) { - var region = attachment.region; - if (region) { - if (slot.currentMesh) { - slot.currentMesh.visible = false; - slot.currentMesh = null; - slot.currentMeshName = undefined; - } - var ar = region; - if (!slot.currentSpriteName || slot.currentSpriteName !== ar.name) { - var spriteName = ar.name; - if (slot.currentSprite) { - slot.currentSprite.visible = false; - } - slot.sprites = slot.sprites || {}; - if (slot.sprites[spriteName] !== undefined) { - slot.sprites[spriteName].visible = true; - } - else { - var sprite = this.createSprite(slot, attachment, spriteName); - slotContainer.addChild(sprite); - } - slot.currentSprite = slot.sprites[spriteName]; - slot.currentSpriteName = spriteName; - } - } - if (slotContainer.transform) { - var transform = slotContainer.transform; - var transAny = transform; - var lt = null; - if (transAny.matrix2d) { - lt = transAny.matrix2d; - transAny._dirtyVersion++; - transAny.version = transAny._dirtyVersion; - transAny.isStatic = true; - transAny.operMode = 0; - } - else { - if (thack) { - if (transAny.position) { - transform = new PIXI.TransformBase(); - transform._parentID = -1; - transform._worldID = slotContainer.transform._worldID; - slotContainer.transform = transform; - } - lt = transform.localTransform; - } - else { - transAny.setFromMatrix(slot.bone.matrix); - } - } - if (lt) { - slot.bone.matrix.copy(lt); - } - } - else { - var lt = slotContainer.localTransform || new PIXI.Matrix(); - slot.bone.matrix.copy(lt); - slotContainer.localTransform = lt; - slotContainer.displayObjectUpdateTransform = SlotContainerUpdateTransformV3; - } - if (slot.currentSprite.color) { - spriteColor = slot.currentSprite.color; - } - else { - tempRgb[0] = light[0] * slot.color.r * attColor.r; - tempRgb[1] = light[1] * slot.color.g * attColor.g; - tempRgb[2] = light[2] * slot.color.b * attColor.b; - slot.currentSprite.tint = PIXI.utils.rgb2hex(tempRgb); - } - slot.currentSprite.blendMode = slot.blendMode; - } - else if (attachment instanceof pixi_spine.core.MeshAttachment) { - if (slot.currentSprite) { - slot.currentSprite.visible = false; - slot.currentSprite = null; - slot.currentSpriteName = undefined; - if (slotContainer.transform) { - var transform = new PIXI.TransformStatic(); - transform._parentID = -1; - transform._worldID = slotContainer.transform._worldID; - slotContainer.transform = transform; - } - else { - slotContainer.localTransform = new PIXI.Matrix(); - slotContainer.displayObjectUpdateTransform = PIXI.DisplayObject.prototype.updateTransform; - } - } - if (!slot.currentMeshName || slot.currentMeshName !== attachment.name) { - var meshName = attachment.name; - if (slot.currentMesh) { - slot.currentMesh.visible = false; - } - slot.meshes = slot.meshes || {}; - if (slot.meshes[meshName] !== undefined) { - slot.meshes[meshName].visible = true; - } - else { - var mesh = this.createMesh(slot, attachment); - slotContainer.addChild(mesh); - } - slot.currentMesh = slot.meshes[meshName]; - slot.currentMeshName = meshName; - } - attachment.computeWorldVerticesOld(slot, slot.currentMesh.vertices); - if (slot.currentMesh.color) { - spriteColor = slot.currentMesh.color; - } - else if (PIXI.VERSION[0] !== '3') { - var tintRgb = slot.currentMesh.tintRgb; - tintRgb[0] = light[0] * slot.color.r * attColor.r; - tintRgb[1] = light[1] * slot.color.g * attColor.g; - tintRgb[2] = light[2] * slot.color.b * attColor.b; - } - slot.currentMesh.blendMode = slot.blendMode; - } - else if (attachment instanceof pixi_spine.core.ClippingAttachment) { - if (!slot.currentGraphics) { - this.createGraphics(slot, attachment); - slotContainer.addChild(slot.clippingContainer); - slotContainer.addChild(slot.currentGraphics); - } - this.updateGraphics(slot, attachment); - } - else { - slotContainer.visible = false; - continue; - } - slotContainer.visible = true; - if (spriteColor) { - var r0 = slot.color.r * attColor.r; - var g0 = slot.color.g * attColor.g; - var b0 = slot.color.b * attColor.b; - spriteColor.setLight(light[0] * r0 + dark[0] * (1.0 - r0), light[1] * g0 + dark[1] * (1.0 - g0), light[2] * b0 + dark[2] * (1.0 - b0)); - if (slot.darkColor) { - r0 = slot.darkColor.r; - g0 = slot.darkColor.g; - b0 = slot.darkColor.b; - } - else { - r0 = 0.0; - g0 = 0.0; - b0 = 0.0; - } - spriteColor.setDark(light[0] * r0 + dark[0] * (1 - r0), light[1] * g0 + dark[1] * (1 - g0), light[2] * b0 + dark[2] * (1 - b0)); - } - slotContainer.alpha = slot.color.a; - } - var drawOrder = this.skeleton.drawOrder; - var clippingAttachment = null; - var clippingContainer = null; - for (var i = 0, n = drawOrder.length; i < n; i++) { - var slot = slots[drawOrder[i].data.index]; - var slotContainer = this.slotContainers[drawOrder[i].data.index]; - if (!clippingContainer) { - if (slotContainer.parent !== null && slotContainer.parent !== this) { - slotContainer.parent.removeChild(slotContainer); - slotContainer.parent = this; - } - } - if (slot.currentGraphics && slot.getAttachment()) { - clippingContainer = slot.clippingContainer; - clippingAttachment = slot.getAttachment(); - clippingContainer.children.length = 0; - this.children[i] = slotContainer; - if (clippingAttachment.endSlot == slot.data) { - clippingAttachment.endSlot = null; - } - } - else { - if (clippingContainer) { - var c = this.tempClipContainers[i]; - if (!c) { - c = this.tempClipContainers[i] = this.newContainer(); - c.visible = false; - } - this.children[i] = c; - slotContainer.parent = null; - clippingContainer.addChild(slotContainer); - if (clippingAttachment.endSlot == slot.data) { - clippingContainer.renderable = true; - clippingContainer = null; - clippingAttachment = null; - } - } - else { - this.children[i] = slotContainer; - } - } - } - }; - ; - Spine.prototype.setSpriteRegion = function (attachment, sprite, region) { - sprite.region = region; - sprite.texture = region.texture; - if (!region.size) { - sprite.scale.x = attachment.scaleX * attachment.width / region.originalWidth; - sprite.scale.y = -attachment.scaleY * attachment.height / region.originalHeight; - } - else { - sprite.scale.x = region.size.width / region.originalWidth; - sprite.scale.y = -region.size.height / region.originalHeight; - } - }; - Spine.prototype.setMeshRegion = function (attachment, mesh, region) { - mesh.region = region; - mesh.texture = region.texture; - region.texture._updateUvs(); - attachment.updateUVs(region, mesh.uvs); - mesh.dirty++; - }; - Spine.prototype.autoUpdateTransform = function () { - if (Spine.globalAutoUpdate) { - this.lastTime = this.lastTime || Date.now(); - var timeDelta = (Date.now() - this.lastTime) * 0.001; - this.lastTime = Date.now(); - this.update(timeDelta); - } - else { - this.lastTime = 0; - } - PIXI.Container.prototype.updateTransform.call(this); - }; - ; - Spine.prototype.createSprite = function (slot, attachment, defName) { - var region = attachment.region; - if (slot.hackAttachment === attachment) { - region = slot.hackRegion; - } - var texture = region.texture; - var sprite = this.newSprite(texture); - sprite.rotation = attachment.rotation * pixi_spine.core.MathUtils.degRad; - sprite.anchor.x = 0.5; - sprite.anchor.y = 0.5; - sprite.position.x = attachment.x; - sprite.position.y = attachment.y; - sprite.alpha = attachment.color.a; - sprite.region = attachment.region; - this.setSpriteRegion(attachment, sprite, attachment.region); - slot.sprites = slot.sprites || {}; - slot.sprites[defName] = sprite; - return sprite; - }; - ; - Spine.prototype.createMesh = function (slot, attachment) { - var region = attachment.region; - if (slot.hackAttachment === attachment) { - region = slot.hackRegion; - slot.hackAttachment = null; - slot.hackRegion = null; - } - var strip = this.newMesh(region.texture, new Float32Array(attachment.regionUVs.length), new Float32Array(attachment.regionUVs.length), new Uint16Array(attachment.triangles), PIXI.mesh.Mesh.DRAW_MODES.TRIANGLES); - strip.canvasPadding = 1.5; - strip.alpha = attachment.color.a; - strip.region = attachment.region; - this.setMeshRegion(attachment, strip, region); - slot.meshes = slot.meshes || {}; - slot.meshes[attachment.name] = strip; - return strip; - }; - ; - Spine.prototype.createGraphics = function (slot, clip) { - var graphics = this.newGraphics(); - var poly = new PIXI.Polygon([]); - graphics.clear(); - graphics.beginFill(0xffffff, 1); - graphics.drawPolygon(poly); - graphics.renderable = false; - slot.currentGraphics = graphics; - slot.clippingContainer = this.newContainer(); - slot.clippingContainer.mask = slot.currentGraphics; - return graphics; - }; - Spine.prototype.updateGraphics = function (slot, clip) { - var vertices = slot.currentGraphics.graphicsData[0].shape.points; - var n = clip.worldVerticesLength; - vertices.length = n; - clip.computeWorldVertices(slot, 0, n, vertices, 0, 2); - slot.currentGraphics.dirty++; - slot.currentGraphics.clearDirty++; - }; - Spine.prototype.hackTextureBySlotIndex = function (slotIndex, texture, size) { - if (texture === void 0) { texture = null; } - if (size === void 0) { size = null; } - var slot = this.skeleton.slots[slotIndex]; - if (!slot) { - return false; - } - var attachment = slot.getAttachment(); - var region = attachment.region; - if (texture) { - region = new pixi_spine.core.TextureRegion(); - region.texture = texture; - region.size = size; - slot.hackRegion = region; - slot.hackAttachment = attachment; - } - else { - slot.hackRegion = null; - slot.hackAttachment = null; - } - if (slot.currentSprite && slot.currentSprite.region != region) { - this.setSpriteRegion(attachment, slot.currentSprite, region); - slot.currentSprite.region = region; - } - else if (slot.currentMesh && slot.currentMesh.region != region) { - this.setMeshRegion(attachment, slot.currentMesh, region); - } - return true; - }; - Spine.prototype.hackTextureBySlotName = function (slotName, texture, size) { - if (texture === void 0) { texture = null; } - if (size === void 0) { size = null; } - var index = this.skeleton.findSlotIndex(slotName); - if (index == -1) { - return false; - } - return this.hackTextureBySlotIndex(index, texture, size); - }; - Spine.prototype.newContainer = function () { - return new PIXI.Container(); - }; - Spine.prototype.newSprite = function (tex) { - return new SpineSprite(tex); - }; - Spine.prototype.newGraphics = function () { - return new PIXI.Graphics(); - }; - Spine.prototype.newMesh = function (texture, vertices, uvs, indices, drawMode) { - return new SpineMesh(texture, vertices, uvs, indices, drawMode); - }; - Spine.prototype.transformHack = function () { - return 1; - }; - Spine.prototype.hackAttachmentGroups = function (nameSuffix, group, outGroup) { - if (!nameSuffix) { - return; - } - var list_d = [], list_n = []; - for (var i = 0, len = this.skeleton.slots.length; i < len; i++) { - var slot = this.skeleton.slots[i]; - var name_6 = slot.currentSpriteName || slot.currentMeshName || ""; - var target = slot.currentSprite || slot.currentMesh; - if (name_6.endsWith(nameSuffix)) { - target.parentGroup = group; - list_n.push(target); - } - else if (outGroup && target) { - target.parentGroup = outGroup; - list_d.push(target); - } - } - return [list_d, list_n]; - }; - ; - Spine.prototype.destroy = function (options) { - for (var i = 0, n = this.skeleton.slots.length; i < n; i++) { - var slot = this.skeleton.slots[i]; - for (var name_7 in slot.meshes) { - slot.meshes[name_7].destroy(options); - } - slot.meshes = null; - for (var name_8 in slot.sprites) { - slot.sprites[name_8].destroy(options); - } - slot.sprites = null; - } - for (var i = 0, n = this.slotContainers.length; i < n; i++) { - this.slotContainers[i].destroy(options); - } - this.spineData = null; - this.skeleton = null; - this.slotContainers = null; - this.stateData = null; - this.state = null; - this.tempClipContainers = null; - _super.prototype.destroy.call(this, options); - }; - Spine.globalAutoUpdate = true; - Spine.globalDelayLimit = 0; - Spine.clippingPolygon = []; - return Spine; - }(PIXI.Container)); - pixi_spine.Spine = Spine; - function SlotContainerUpdateTransformV3() { - var pt = this.parent.worldTransform; - var wt = this.worldTransform; - var lt = this.localTransform; - wt.a = lt.a * pt.a + lt.b * pt.c; - wt.b = lt.a * pt.b + lt.b * pt.d; - wt.c = lt.c * pt.a + lt.d * pt.c; - wt.d = lt.c * pt.b + lt.d * pt.d; - wt.tx = lt.tx * pt.a + lt.ty * pt.c + pt.tx; - wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; - this.worldAlpha = this.alpha * this.parent.worldAlpha; - this._currentBounds = null; - } -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - PIXI.spine = pixi_spine; - var TextureProto = PIXI.Texture.prototype; - if (!TextureProto._updateUvs) { - TextureProto._updateUvs = TextureProto.updateUvs; - } -})(pixi_spine || (pixi_spine = {})); -var pixi_spine; -(function (pixi_spine) { - var Resource = PIXI.loaders.Resource; - function isJson(resource) { - return resource.type == Resource.TYPE.JSON; - } - function isBuffer(resource) { - return resource.xhrType == Resource.XHR_RESPONSE_TYPE.BUFFER; - } - Resource.setExtensionXhrType('skel', Resource.XHR_RESPONSE_TYPE.BUFFER); - function atlasParser() { - return function atlasParser(resource, next) { - if (!resource.data) { - return next(); - } - var isJsonSpineModel = isJson(resource) && resource.data.bones; - var isBinarySpineModel = isBuffer(resource) && (resource.extension === 'skel' || resource.metadata.spineMetadata); - if (!isJsonSpineModel && !isBinarySpineModel) { - return next(); - } - var parser = null; - var dataToParse = resource.data; - if (isJsonSpineModel) { - parser = new pixi_spine.core.SkeletonJson(null); - } - else { - parser = new pixi_spine.core.SkeletonBinary(null); - if (resource.data instanceof ArrayBuffer) { - dataToParse = new Uint8Array(resource.data); - } - } - var metadata = resource.metadata || {}; - var metadataSkeletonScale = metadata ? resource.metadata.spineSkeletonScale : null; - if (metadataSkeletonScale) { - parser.scale = metadataSkeletonScale; - } - var metadataAtlas = metadata ? resource.metadata.spineAtlas : null; - if (metadataAtlas === false) { - return next(); - } - if (metadataAtlas && metadataAtlas.pages) { - parser.attachmentLoader = new pixi_spine.core.AtlasAttachmentLoader(metadataAtlas); - resource.spineData = parser.readSkeletonData(dataToParse); - resource.spineAtlas = metadataAtlas; - return next(); - } - var metadataAtlasSuffix = metadata.spineAtlasSuffix || '.atlas'; - var atlasPath = resource.url; - var queryStringPos = atlasPath.indexOf('?'); - if (queryStringPos > 0) { - atlasPath = atlasPath.substr(0, queryStringPos); - } - atlasPath = atlasPath.substr(0, atlasPath.lastIndexOf('.')) + metadataAtlasSuffix; - if (resource.metadata && resource.metadata.spineAtlasFile) { - atlasPath = resource.metadata.spineAtlasFile; - } - atlasPath = atlasPath.replace(this.baseUrl, ''); - var atlasOptions = { - crossOrigin: resource.crossOrigin, - xhrType: Resource.XHR_RESPONSE_TYPE.TEXT, - metadata: metadata.spineMetadata || null, - parentResource: resource - }; - var imageOptions = { - crossOrigin: resource.crossOrigin, - metadata: metadata.imageMetadata || null, - parentResource: resource - }; - var baseUrl = resource.url.substr(0, resource.url.lastIndexOf('/') + 1); - baseUrl = baseUrl.replace(this.baseUrl, ''); - var namePrefix = metadata.imageNamePrefix || (resource.name + '_atlas_page_'); - var adapter = metadata.images ? staticImageLoader(metadata.images) - : metadata.image ? staticImageLoader({ 'default': metadata.image }) - : metadata.imageLoader ? metadata.imageLoader(this, namePrefix, baseUrl, imageOptions) - : imageLoaderAdapter(this, namePrefix, baseUrl, imageOptions); - var createSkeletonWithRawAtlas = function (rawData) { - new pixi_spine.core.TextureAtlas(rawData, adapter, function (spineAtlas) { - if (spineAtlas) { - parser.attachmentLoader = new pixi_spine.core.AtlasAttachmentLoader(spineAtlas); - resource.spineData = parser.readSkeletonData(dataToParse); - resource.spineAtlas = spineAtlas; - } - next(); - }); - }; - if (resource.metadata && resource.metadata.atlasRawData) { - createSkeletonWithRawAtlas(resource.metadata.atlasRawData); - } - else { - this.add(resource.name + '_atlas', atlasPath, atlasOptions, function (atlasResource) { - if (!atlasResource.error) { - createSkeletonWithRawAtlas(atlasResource.data); - } - else { - next(); - } - }); - } - }; - } - pixi_spine.atlasParser = atlasParser; - function imageLoaderAdapter(loader, namePrefix, baseUrl, imageOptions) { - if (baseUrl && baseUrl.lastIndexOf('/') !== (baseUrl.length - 1)) { - baseUrl += '/'; - } - return function (line, callback) { - var name = namePrefix + line; - var url = baseUrl + line; - var cachedResource = loader.resources[name]; - if (cachedResource) { - function done() { - callback(cachedResource.texture.baseTexture); - } - if (cachedResource.texture) { - done(); - } - else { - cachedResource.onAfterMiddleware.add(done); - } - } - else { - loader.add(name, url, imageOptions, function (resource) { - if (!resource.error) { - callback(resource.texture.baseTexture); - } - else { - callback(null); - } - }); - } - }; - } - pixi_spine.imageLoaderAdapter = imageLoaderAdapter; - function syncImageLoaderAdapter(baseUrl, crossOrigin) { - if (baseUrl && baseUrl.lastIndexOf('/') !== (baseUrl.length - 1)) { - baseUrl += '/'; - } - return function (line, callback) { - callback(PIXI.BaseTexture.fromImage(line, crossOrigin)); - }; - } - pixi_spine.syncImageLoaderAdapter = syncImageLoaderAdapter; - function staticImageLoader(pages) { - return function (line, callback) { - var page = pages[line] || pages['default']; - if (page && page.baseTexture) - callback(page.baseTexture); - else - callback(page); - }; - } - pixi_spine.staticImageLoader = staticImageLoader; - if (PIXI.loaders.Loader) { - PIXI.loaders.Loader.addPixiMiddleware(atlasParser); - PIXI.loader.use(atlasParser()); - } -})(pixi_spine || (pixi_spine = {})); -export default pixi_spine \ No newline at end of file +import { + Texture, + Rectangle, + Sprite, + Graphics, + mesh, + Matrix, + Container, + SCALE_MODES, + utils, + loaders, + TransformBase, + TransformStatic, + DisplayObject, + Polygon, + BaseTexture, +} from 'pixi.js'; + +const VERSION = '4.8.9'; +const loader = loaders.shared; + +const PIXI = { + Texture, + Rectangle, + Sprite, + Graphics, + mesh, + Matrix, + Container, + VERSION, + loaders, + loader, + SCALE_MODES, + utils, + TransformBase, + TransformStatic, + DisplayObject, + Polygon, + BaseTexture, +}; + +var __extends = + (this && this.__extends) || + (function () { + var extendStatics = function (d, b) { + extendStatics = + Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && + function (d, b) { + d.__proto__ = b; + }) || + function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { + this.constructor = d; + } + d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __()); + }; + })(); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var Animation = (function () { + function Animation(name, timelines, duration) { + if (name == null) throw new Error('name cannot be null.'); + if (timelines == null) throw new Error('timelines cannot be null.'); + this.name = name; + this.timelines = timelines; + this.timelineIds = []; + for (var i = 0; i < timelines.length; i++) this.timelineIds[timelines[i].getPropertyId()] = true; + this.duration = duration; + } + Animation.prototype.hasTimeline = function (id) { + return this.timelineIds[id] == true; + }; + Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, blend, direction) { + if (skeleton == null) throw new Error('skeleton cannot be null.'); + if (loop && this.duration != 0) { + time %= this.duration; + if (lastTime > 0) lastTime %= this.duration; + } + var timelines = this.timelines; + for (var i = 0, n = timelines.length; i < n; i++) + timelines[i].apply(skeleton, lastTime, time, events, alpha, blend, direction); + }; + Animation.binarySearch = function (values, target, step) { + if (step === void 0) { + step = 1; + } + var low = 0; + var high = values.length / step - 2; + if (high == 0) return step; + var current = high >>> 1; + while (true) { + if (values[(current + 1) * step] <= target) low = current + 1; + else high = current; + if (low == high) return (low + 1) * step; + current = (low + high) >>> 1; + } + }; + Animation.linearSearch = function (values, target, step) { + for (var i = 0, last = values.length - step; i <= last; i += step) if (values[i] > target) return i; + return -1; + }; + return Animation; + })(); + core.Animation = Animation; + var MixBlend; + (function (MixBlend) { + MixBlend[(MixBlend['setup'] = 0)] = 'setup'; + MixBlend[(MixBlend['first'] = 1)] = 'first'; + MixBlend[(MixBlend['replace'] = 2)] = 'replace'; + MixBlend[(MixBlend['add'] = 3)] = 'add'; + })((MixBlend = core.MixBlend || (core.MixBlend = {}))); + var MixDirection; + (function (MixDirection) { + MixDirection[(MixDirection['mixIn'] = 0)] = 'mixIn'; + MixDirection[(MixDirection['mixOut'] = 1)] = 'mixOut'; + })((MixDirection = core.MixDirection || (core.MixDirection = {}))); + var TimelineType; + (function (TimelineType) { + TimelineType[(TimelineType['rotate'] = 0)] = 'rotate'; + TimelineType[(TimelineType['translate'] = 1)] = 'translate'; + TimelineType[(TimelineType['scale'] = 2)] = 'scale'; + TimelineType[(TimelineType['shear'] = 3)] = 'shear'; + TimelineType[(TimelineType['attachment'] = 4)] = 'attachment'; + TimelineType[(TimelineType['color'] = 5)] = 'color'; + TimelineType[(TimelineType['deform'] = 6)] = 'deform'; + TimelineType[(TimelineType['event'] = 7)] = 'event'; + TimelineType[(TimelineType['drawOrder'] = 8)] = 'drawOrder'; + TimelineType[(TimelineType['ikConstraint'] = 9)] = 'ikConstraint'; + TimelineType[(TimelineType['transformConstraint'] = 10)] = 'transformConstraint'; + TimelineType[(TimelineType['pathConstraintPosition'] = 11)] = 'pathConstraintPosition'; + TimelineType[(TimelineType['pathConstraintSpacing'] = 12)] = 'pathConstraintSpacing'; + TimelineType[(TimelineType['pathConstraintMix'] = 13)] = 'pathConstraintMix'; + TimelineType[(TimelineType['twoColor'] = 14)] = 'twoColor'; + })((TimelineType = core.TimelineType || (core.TimelineType = {}))); + var CurveTimeline = (function () { + function CurveTimeline(frameCount) { + if (frameCount <= 0) throw new Error('frameCount must be > 0: ' + frameCount); + this.curves = core.Utils.newFloatArray((frameCount - 1) * CurveTimeline.BEZIER_SIZE); + } + CurveTimeline.prototype.getFrameCount = function () { + return this.curves.length / CurveTimeline.BEZIER_SIZE + 1; + }; + CurveTimeline.prototype.setLinear = function (frameIndex) { + this.curves[frameIndex * CurveTimeline.BEZIER_SIZE] = CurveTimeline.LINEAR; + }; + CurveTimeline.prototype.setStepped = function (frameIndex) { + this.curves[frameIndex * CurveTimeline.BEZIER_SIZE] = CurveTimeline.STEPPED; + }; + CurveTimeline.prototype.getCurveType = function (frameIndex) { + var index = frameIndex * CurveTimeline.BEZIER_SIZE; + if (index == this.curves.length) return CurveTimeline.LINEAR; + var type = this.curves[index]; + if (type == CurveTimeline.LINEAR) return CurveTimeline.LINEAR; + if (type == CurveTimeline.STEPPED) return CurveTimeline.STEPPED; + return CurveTimeline.BEZIER; + }; + CurveTimeline.prototype.setCurve = function (frameIndex, cx1, cy1, cx2, cy2) { + var tmpx = (-cx1 * 2 + cx2) * 0.03, + tmpy = (-cy1 * 2 + cy2) * 0.03; + var dddfx = ((cx1 - cx2) * 3 + 1) * 0.006, + dddfy = ((cy1 - cy2) * 3 + 1) * 0.006; + var ddfx = tmpx * 2 + dddfx, + ddfy = tmpy * 2 + dddfy; + var dfx = cx1 * 0.3 + tmpx + dddfx * 0.16666667, + dfy = cy1 * 0.3 + tmpy + dddfy * 0.16666667; + var i = frameIndex * CurveTimeline.BEZIER_SIZE; + var curves = this.curves; + curves[i++] = CurveTimeline.BEZIER; + var x = dfx, + y = dfy; + for (var n = i + CurveTimeline.BEZIER_SIZE - 1; i < n; i += 2) { + curves[i] = x; + curves[i + 1] = y; + dfx += ddfx; + dfy += ddfy; + ddfx += dddfx; + ddfy += dddfy; + x += dfx; + y += dfy; + } + }; + CurveTimeline.prototype.getCurvePercent = function (frameIndex, percent) { + percent = core.MathUtils.clamp(percent, 0, 1); + var curves = this.curves; + var i = frameIndex * CurveTimeline.BEZIER_SIZE; + var type = curves[i]; + if (type == CurveTimeline.LINEAR) return percent; + if (type == CurveTimeline.STEPPED) return 0; + i++; + var x = 0; + for (var start = i, n = i + CurveTimeline.BEZIER_SIZE - 1; i < n; i += 2) { + x = curves[i]; + if (x >= percent) { + var prevX = void 0, + prevY = void 0; + if (i == start) { + prevX = 0; + prevY = 0; + } else { + prevX = curves[i - 2]; + prevY = curves[i - 1]; + } + return prevY + ((curves[i + 1] - prevY) * (percent - prevX)) / (x - prevX); + } + } + var y = curves[i - 1]; + return y + ((1 - y) * (percent - x)) / (1 - x); + }; + CurveTimeline.LINEAR = 0; + CurveTimeline.STEPPED = 1; + CurveTimeline.BEZIER = 2; + CurveTimeline.BEZIER_SIZE = 10 * 2 - 1; + return CurveTimeline; + })(); + core.CurveTimeline = CurveTimeline; + var RotateTimeline = (function (_super) { + __extends(RotateTimeline, _super); + function RotateTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = core.Utils.newFloatArray(frameCount << 1); + return _this; + } + RotateTimeline.prototype.getPropertyId = function () { + return (TimelineType.rotate << 24) + this.boneIndex; + }; + RotateTimeline.prototype.setFrame = function (frameIndex, time, degrees) { + frameIndex <<= 1; + this.frames[frameIndex] = time; + this.frames[frameIndex + RotateTimeline.ROTATION] = degrees; + }; + RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) { + var frames = this.frames; + var bone = skeleton.bones[this.boneIndex]; + if (!bone.active) return; + if (time < frames[0]) { + switch (blend) { + case MixBlend.setup: + bone.rotation = bone.data.rotation; + return; + case MixBlend.first: + var r_1 = bone.data.rotation - bone.rotation; + bone.rotation += (r_1 - (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360) * alpha; + } + return; + } + if (time >= frames[frames.length - RotateTimeline.ENTRIES]) { + var r_2 = frames[frames.length + RotateTimeline.PREV_ROTATION]; + switch (blend) { + case MixBlend.setup: + bone.rotation = bone.data.rotation + r_2 * alpha; + break; + case MixBlend.first: + case MixBlend.replace: + r_2 += bone.data.rotation - bone.rotation; + r_2 -= (16384 - ((16384.499999999996 - r_2 / 360) | 0)) * 360; + case MixBlend.add: + bone.rotation += r_2 * alpha; + } + return; + } + var frame = Animation.binarySearch(frames, time, RotateTimeline.ENTRIES); + var prevRotation = frames[frame + RotateTimeline.PREV_ROTATION]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent( + (frame >> 1) - 1, + 1 - (time - frameTime) / (frames[frame + RotateTimeline.PREV_TIME] - frameTime), + ); + var r = frames[frame + RotateTimeline.ROTATION] - prevRotation; + r = prevRotation + (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * percent; + switch (blend) { + case MixBlend.setup: + bone.rotation = bone.data.rotation + (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * alpha; + break; + case MixBlend.first: + case MixBlend.replace: + r += bone.data.rotation - bone.rotation; + case MixBlend.add: + bone.rotation += (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * alpha; + } + }; + RotateTimeline.ENTRIES = 2; + RotateTimeline.PREV_TIME = -2; + RotateTimeline.PREV_ROTATION = -1; + RotateTimeline.ROTATION = 1; + return RotateTimeline; + })(CurveTimeline); + core.RotateTimeline = RotateTimeline; + var TranslateTimeline = (function (_super) { + __extends(TranslateTimeline, _super); + function TranslateTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = core.Utils.newFloatArray(frameCount * TranslateTimeline.ENTRIES); + return _this; + } + TranslateTimeline.prototype.getPropertyId = function () { + return (TimelineType.translate << 24) + this.boneIndex; + }; + TranslateTimeline.prototype.setFrame = function (frameIndex, time, x, y) { + frameIndex *= TranslateTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + TranslateTimeline.X] = x; + this.frames[frameIndex + TranslateTimeline.Y] = y; + }; + TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) { + var frames = this.frames; + var bone = skeleton.bones[this.boneIndex]; + if (!bone.active) return; + if (time < frames[0]) { + switch (blend) { + case MixBlend.setup: + bone.x = bone.data.x; + bone.y = bone.data.y; + return; + case MixBlend.first: + bone.x += (bone.data.x - bone.x) * alpha; + bone.y += (bone.data.y - bone.y) * alpha; + } + return; + } + var x = 0, + y = 0; + if (time >= frames[frames.length - TranslateTimeline.ENTRIES]) { + x = frames[frames.length + TranslateTimeline.PREV_X]; + y = frames[frames.length + TranslateTimeline.PREV_Y]; + } else { + var frame = Animation.binarySearch(frames, time, TranslateTimeline.ENTRIES); + x = frames[frame + TranslateTimeline.PREV_X]; + y = frames[frame + TranslateTimeline.PREV_Y]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent( + frame / TranslateTimeline.ENTRIES - 1, + 1 - (time - frameTime) / (frames[frame + TranslateTimeline.PREV_TIME] - frameTime), + ); + x += (frames[frame + TranslateTimeline.X] - x) * percent; + y += (frames[frame + TranslateTimeline.Y] - y) * percent; + } + switch (blend) { + case MixBlend.setup: + bone.x = bone.data.x + x * alpha; + bone.y = bone.data.y + y * alpha; + break; + case MixBlend.first: + case MixBlend.replace: + bone.x += (bone.data.x + x - bone.x) * alpha; + bone.y += (bone.data.y + y - bone.y) * alpha; + break; + case MixBlend.add: + bone.x += x * alpha; + bone.y += y * alpha; + } + }; + TranslateTimeline.ENTRIES = 3; + TranslateTimeline.PREV_TIME = -3; + TranslateTimeline.PREV_X = -2; + TranslateTimeline.PREV_Y = -1; + TranslateTimeline.X = 1; + TranslateTimeline.Y = 2; + return TranslateTimeline; + })(CurveTimeline); + core.TranslateTimeline = TranslateTimeline; + var ScaleTimeline = (function (_super) { + __extends(ScaleTimeline, _super); + function ScaleTimeline(frameCount) { + return _super.call(this, frameCount) || this; + } + ScaleTimeline.prototype.getPropertyId = function () { + return (TimelineType.scale << 24) + this.boneIndex; + }; + ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) { + var frames = this.frames; + var bone = skeleton.bones[this.boneIndex]; + if (!bone.active) return; + if (time < frames[0]) { + switch (blend) { + case MixBlend.setup: + bone.scaleX = bone.data.scaleX; + bone.scaleY = bone.data.scaleY; + return; + case MixBlend.first: + bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha; + bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha; + } + return; + } + var x = 0, + y = 0; + if (time >= frames[frames.length - ScaleTimeline.ENTRIES]) { + x = frames[frames.length + ScaleTimeline.PREV_X] * bone.data.scaleX; + y = frames[frames.length + ScaleTimeline.PREV_Y] * bone.data.scaleY; + } else { + var frame = Animation.binarySearch(frames, time, ScaleTimeline.ENTRIES); + x = frames[frame + ScaleTimeline.PREV_X]; + y = frames[frame + ScaleTimeline.PREV_Y]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent( + frame / ScaleTimeline.ENTRIES - 1, + 1 - (time - frameTime) / (frames[frame + ScaleTimeline.PREV_TIME] - frameTime), + ); + x = (x + (frames[frame + ScaleTimeline.X] - x) * percent) * bone.data.scaleX; + y = (y + (frames[frame + ScaleTimeline.Y] - y) * percent) * bone.data.scaleY; + } + if (alpha == 1) { + if (blend == MixBlend.add) { + bone.scaleX += x - bone.data.scaleX; + bone.scaleY += y - bone.data.scaleY; + } else { + bone.scaleX = x; + bone.scaleY = y; + } + } else { + var bx = 0, + by = 0; + if (direction == MixDirection.mixOut) { + switch (blend) { + case MixBlend.setup: + bx = bone.data.scaleX; + by = bone.data.scaleY; + bone.scaleX = bx + (Math.abs(x) * core.MathUtils.signum(bx) - bx) * alpha; + bone.scaleY = by + (Math.abs(y) * core.MathUtils.signum(by) - by) * alpha; + break; + case MixBlend.first: + case MixBlend.replace: + bx = bone.scaleX; + by = bone.scaleY; + bone.scaleX = bx + (Math.abs(x) * core.MathUtils.signum(bx) - bx) * alpha; + bone.scaleY = by + (Math.abs(y) * core.MathUtils.signum(by) - by) * alpha; + break; + case MixBlend.add: + bx = bone.scaleX; + by = bone.scaleY; + bone.scaleX = bx + (Math.abs(x) * core.MathUtils.signum(bx) - bone.data.scaleX) * alpha; + bone.scaleY = by + (Math.abs(y) * core.MathUtils.signum(by) - bone.data.scaleY) * alpha; + } + } else { + switch (blend) { + case MixBlend.setup: + bx = Math.abs(bone.data.scaleX) * core.MathUtils.signum(x); + by = Math.abs(bone.data.scaleY) * core.MathUtils.signum(y); + bone.scaleX = bx + (x - bx) * alpha; + bone.scaleY = by + (y - by) * alpha; + break; + case MixBlend.first: + case MixBlend.replace: + bx = Math.abs(bone.scaleX) * core.MathUtils.signum(x); + by = Math.abs(bone.scaleY) * core.MathUtils.signum(y); + bone.scaleX = bx + (x - bx) * alpha; + bone.scaleY = by + (y - by) * alpha; + break; + case MixBlend.add: + bx = core.MathUtils.signum(x); + by = core.MathUtils.signum(y); + bone.scaleX = Math.abs(bone.scaleX) * bx + (x - Math.abs(bone.data.scaleX) * bx) * alpha; + bone.scaleY = Math.abs(bone.scaleY) * by + (y - Math.abs(bone.data.scaleY) * by) * alpha; + } + } + } + }; + return ScaleTimeline; + })(TranslateTimeline); + core.ScaleTimeline = ScaleTimeline; + var ShearTimeline = (function (_super) { + __extends(ShearTimeline, _super); + function ShearTimeline(frameCount) { + return _super.call(this, frameCount) || this; + } + ShearTimeline.prototype.getPropertyId = function () { + return (TimelineType.shear << 24) + this.boneIndex; + }; + ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) { + var frames = this.frames; + var bone = skeleton.bones[this.boneIndex]; + if (!bone.active) return; + if (time < frames[0]) { + switch (blend) { + case MixBlend.setup: + bone.shearX = bone.data.shearX; + bone.shearY = bone.data.shearY; + return; + case MixBlend.first: + bone.shearX += (bone.data.shearX - bone.shearX) * alpha; + bone.shearY += (bone.data.shearY - bone.shearY) * alpha; + } + return; + } + var x = 0, + y = 0; + if (time >= frames[frames.length - ShearTimeline.ENTRIES]) { + x = frames[frames.length + ShearTimeline.PREV_X]; + y = frames[frames.length + ShearTimeline.PREV_Y]; + } else { + var frame = Animation.binarySearch(frames, time, ShearTimeline.ENTRIES); + x = frames[frame + ShearTimeline.PREV_X]; + y = frames[frame + ShearTimeline.PREV_Y]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent( + frame / ShearTimeline.ENTRIES - 1, + 1 - (time - frameTime) / (frames[frame + ShearTimeline.PREV_TIME] - frameTime), + ); + x = x + (frames[frame + ShearTimeline.X] - x) * percent; + y = y + (frames[frame + ShearTimeline.Y] - y) * percent; + } + switch (blend) { + case MixBlend.setup: + bone.shearX = bone.data.shearX + x * alpha; + bone.shearY = bone.data.shearY + y * alpha; + break; + case MixBlend.first: + case MixBlend.replace: + bone.shearX += (bone.data.shearX + x - bone.shearX) * alpha; + bone.shearY += (bone.data.shearY + y - bone.shearY) * alpha; + break; + case MixBlend.add: + bone.shearX += x * alpha; + bone.shearY += y * alpha; + } + }; + return ShearTimeline; + })(TranslateTimeline); + core.ShearTimeline = ShearTimeline; + var ColorTimeline = (function (_super) { + __extends(ColorTimeline, _super); + function ColorTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = core.Utils.newFloatArray(frameCount * ColorTimeline.ENTRIES); + return _this; + } + ColorTimeline.prototype.getPropertyId = function () { + return (TimelineType.color << 24) + this.slotIndex; + }; + ColorTimeline.prototype.setFrame = function (frameIndex, time, r, g, b, a) { + frameIndex *= ColorTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + ColorTimeline.R] = r; + this.frames[frameIndex + ColorTimeline.G] = g; + this.frames[frameIndex + ColorTimeline.B] = b; + this.frames[frameIndex + ColorTimeline.A] = a; + }; + ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) { + var slot = skeleton.slots[this.slotIndex]; + if (!slot.bone.active) return; + var frames = this.frames; + if (time < frames[0]) { + switch (blend) { + case MixBlend.setup: + slot.color.setFromColor(slot.data.color); + return; + case MixBlend.first: + var color = slot.color, + setup = slot.data.color; + color.add( + (setup.r - color.r) * alpha, + (setup.g - color.g) * alpha, + (setup.b - color.b) * alpha, + (setup.a - color.a) * alpha, + ); + } + return; + } + var r = 0, + g = 0, + b = 0, + a = 0; + if (time >= frames[frames.length - ColorTimeline.ENTRIES]) { + var i = frames.length; + r = frames[i + ColorTimeline.PREV_R]; + g = frames[i + ColorTimeline.PREV_G]; + b = frames[i + ColorTimeline.PREV_B]; + a = frames[i + ColorTimeline.PREV_A]; + } else { + var frame = Animation.binarySearch(frames, time, ColorTimeline.ENTRIES); + r = frames[frame + ColorTimeline.PREV_R]; + g = frames[frame + ColorTimeline.PREV_G]; + b = frames[frame + ColorTimeline.PREV_B]; + a = frames[frame + ColorTimeline.PREV_A]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent( + frame / ColorTimeline.ENTRIES - 1, + 1 - (time - frameTime) / (frames[frame + ColorTimeline.PREV_TIME] - frameTime), + ); + r += (frames[frame + ColorTimeline.R] - r) * percent; + g += (frames[frame + ColorTimeline.G] - g) * percent; + b += (frames[frame + ColorTimeline.B] - b) * percent; + a += (frames[frame + ColorTimeline.A] - a) * percent; + } + if (alpha == 1) slot.color.set(r, g, b, a); + else { + var color = slot.color; + if (blend == MixBlend.setup) color.setFromColor(slot.data.color); + color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha); + } + }; + ColorTimeline.ENTRIES = 5; + ColorTimeline.PREV_TIME = -5; + ColorTimeline.PREV_R = -4; + ColorTimeline.PREV_G = -3; + ColorTimeline.PREV_B = -2; + ColorTimeline.PREV_A = -1; + ColorTimeline.R = 1; + ColorTimeline.G = 2; + ColorTimeline.B = 3; + ColorTimeline.A = 4; + return ColorTimeline; + })(CurveTimeline); + core.ColorTimeline = ColorTimeline; + var TwoColorTimeline = (function (_super) { + __extends(TwoColorTimeline, _super); + function TwoColorTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = core.Utils.newFloatArray(frameCount * TwoColorTimeline.ENTRIES); + return _this; + } + TwoColorTimeline.prototype.getPropertyId = function () { + return (TimelineType.twoColor << 24) + this.slotIndex; + }; + TwoColorTimeline.prototype.setFrame = function (frameIndex, time, r, g, b, a, r2, g2, b2) { + frameIndex *= TwoColorTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + TwoColorTimeline.R] = r; + this.frames[frameIndex + TwoColorTimeline.G] = g; + this.frames[frameIndex + TwoColorTimeline.B] = b; + this.frames[frameIndex + TwoColorTimeline.A] = a; + this.frames[frameIndex + TwoColorTimeline.R2] = r2; + this.frames[frameIndex + TwoColorTimeline.G2] = g2; + this.frames[frameIndex + TwoColorTimeline.B2] = b2; + }; + TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) { + var slot = skeleton.slots[this.slotIndex]; + if (!slot.bone.active) return; + var frames = this.frames; + if (time < frames[0]) { + switch (blend) { + case MixBlend.setup: + slot.color.setFromColor(slot.data.color); + slot.darkColor.setFromColor(slot.data.darkColor); + return; + case MixBlend.first: + var light = slot.color, + dark = slot.darkColor, + setupLight = slot.data.color, + setupDark = slot.data.darkColor; + light.add( + (setupLight.r - light.r) * alpha, + (setupLight.g - light.g) * alpha, + (setupLight.b - light.b) * alpha, + (setupLight.a - light.a) * alpha, + ); + dark.add( + (setupDark.r - dark.r) * alpha, + (setupDark.g - dark.g) * alpha, + (setupDark.b - dark.b) * alpha, + 0, + ); + } + return; + } + var r = 0, + g = 0, + b = 0, + a = 0, + r2 = 0, + g2 = 0, + b2 = 0; + if (time >= frames[frames.length - TwoColorTimeline.ENTRIES]) { + var i = frames.length; + r = frames[i + TwoColorTimeline.PREV_R]; + g = frames[i + TwoColorTimeline.PREV_G]; + b = frames[i + TwoColorTimeline.PREV_B]; + a = frames[i + TwoColorTimeline.PREV_A]; + r2 = frames[i + TwoColorTimeline.PREV_R2]; + g2 = frames[i + TwoColorTimeline.PREV_G2]; + b2 = frames[i + TwoColorTimeline.PREV_B2]; + } else { + var frame = Animation.binarySearch(frames, time, TwoColorTimeline.ENTRIES); + r = frames[frame + TwoColorTimeline.PREV_R]; + g = frames[frame + TwoColorTimeline.PREV_G]; + b = frames[frame + TwoColorTimeline.PREV_B]; + a = frames[frame + TwoColorTimeline.PREV_A]; + r2 = frames[frame + TwoColorTimeline.PREV_R2]; + g2 = frames[frame + TwoColorTimeline.PREV_G2]; + b2 = frames[frame + TwoColorTimeline.PREV_B2]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent( + frame / TwoColorTimeline.ENTRIES - 1, + 1 - (time - frameTime) / (frames[frame + TwoColorTimeline.PREV_TIME] - frameTime), + ); + r += (frames[frame + TwoColorTimeline.R] - r) * percent; + g += (frames[frame + TwoColorTimeline.G] - g) * percent; + b += (frames[frame + TwoColorTimeline.B] - b) * percent; + a += (frames[frame + TwoColorTimeline.A] - a) * percent; + r2 += (frames[frame + TwoColorTimeline.R2] - r2) * percent; + g2 += (frames[frame + TwoColorTimeline.G2] - g2) * percent; + b2 += (frames[frame + TwoColorTimeline.B2] - b2) * percent; + } + if (alpha == 1) { + slot.color.set(r, g, b, a); + slot.darkColor.set(r2, g2, b2, 1); + } else { + var light = slot.color, + dark = slot.darkColor; + if (blend == MixBlend.setup) { + light.setFromColor(slot.data.color); + dark.setFromColor(slot.data.darkColor); + } + light.add((r - light.r) * alpha, (g - light.g) * alpha, (b - light.b) * alpha, (a - light.a) * alpha); + dark.add((r2 - dark.r) * alpha, (g2 - dark.g) * alpha, (b2 - dark.b) * alpha, 0); + } + }; + TwoColorTimeline.ENTRIES = 8; + TwoColorTimeline.PREV_TIME = -8; + TwoColorTimeline.PREV_R = -7; + TwoColorTimeline.PREV_G = -6; + TwoColorTimeline.PREV_B = -5; + TwoColorTimeline.PREV_A = -4; + TwoColorTimeline.PREV_R2 = -3; + TwoColorTimeline.PREV_G2 = -2; + TwoColorTimeline.PREV_B2 = -1; + TwoColorTimeline.R = 1; + TwoColorTimeline.G = 2; + TwoColorTimeline.B = 3; + TwoColorTimeline.A = 4; + TwoColorTimeline.R2 = 5; + TwoColorTimeline.G2 = 6; + TwoColorTimeline.B2 = 7; + return TwoColorTimeline; + })(CurveTimeline); + core.TwoColorTimeline = TwoColorTimeline; + var AttachmentTimeline = (function () { + function AttachmentTimeline(frameCount) { + this.frames = core.Utils.newFloatArray(frameCount); + this.attachmentNames = new Array(frameCount); + } + AttachmentTimeline.prototype.getPropertyId = function () { + return (TimelineType.attachment << 24) + this.slotIndex; + }; + AttachmentTimeline.prototype.getFrameCount = function () { + return this.frames.length; + }; + AttachmentTimeline.prototype.setFrame = function (frameIndex, time, attachmentName) { + this.frames[frameIndex] = time; + this.attachmentNames[frameIndex] = attachmentName; + }; + AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) { + var slot = skeleton.slots[this.slotIndex]; + if (!slot.bone.active) return; + if (direction == MixDirection.mixOut) { + if (blend == MixBlend.setup) this.setAttachment(skeleton, slot, slot.data.attachmentName); + return; + } + var frames = this.frames; + if (time < frames[0]) { + if (blend == MixBlend.setup || blend == MixBlend.first) + this.setAttachment(skeleton, slot, slot.data.attachmentName); + return; + } + var frameIndex = 0; + if (time >= frames[frames.length - 1]) frameIndex = frames.length - 1; + else frameIndex = Animation.binarySearch(frames, time, 1) - 1; + var attachmentName = this.attachmentNames[frameIndex]; + skeleton.slots[this.slotIndex].setAttachment( + attachmentName == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName), + ); + }; + AttachmentTimeline.prototype.setAttachment = function (skeleton, slot, attachmentName) { + slot.attachment = attachmentName == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName); + }; + return AttachmentTimeline; + })(); + core.AttachmentTimeline = AttachmentTimeline; + var zeros = null; + var DeformTimeline = (function (_super) { + __extends(DeformTimeline, _super); + function DeformTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = core.Utils.newFloatArray(frameCount); + _this.frameVertices = new Array(frameCount); + if (zeros == null) zeros = core.Utils.newFloatArray(64); + return _this; + } + DeformTimeline.prototype.getPropertyId = function () { + return (TimelineType.deform << 27) + +this.attachment.id + this.slotIndex; + }; + DeformTimeline.prototype.setFrame = function (frameIndex, time, vertices) { + this.frames[frameIndex] = time; + this.frameVertices[frameIndex] = vertices; + }; + DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) { + var slot = skeleton.slots[this.slotIndex]; + if (!slot.bone.active) return; + var slotAttachment = slot.getAttachment(); + if (!(slotAttachment instanceof core.VertexAttachment) || !(slotAttachment.deformAttachment == this.attachment)) + return; + var deformArray = slot.deform; + if (deformArray.length == 0) blend = MixBlend.setup; + var frameVertices = this.frameVertices; + var vertexCount = frameVertices[0].length; + var frames = this.frames; + if (time < frames[0]) { + var vertexAttachment = slotAttachment; + switch (blend) { + case MixBlend.setup: + deformArray.length = 0; + return; + case MixBlend.first: + if (alpha == 1) { + deformArray.length = 0; + break; + } + var deform_1 = core.Utils.setArraySize(deformArray, vertexCount); + if (vertexAttachment.bones == null) { + var setupVertices = vertexAttachment.vertices; + for (var i = 0; i < vertexCount; i++) deform_1[i] += (setupVertices[i] - deform_1[i]) * alpha; + } else { + alpha = 1 - alpha; + for (var i = 0; i < vertexCount; i++) deform_1[i] *= alpha; + } + } + return; + } + var deform = core.Utils.setArraySize(deformArray, vertexCount); + if (time >= frames[frames.length - 1]) { + var lastVertices = frameVertices[frames.length - 1]; + if (alpha == 1) { + if (blend == MixBlend.add) { + var vertexAttachment = slotAttachment; + if (vertexAttachment.bones == null) { + var setupVertices = vertexAttachment.vertices; + for (var i_1 = 0; i_1 < vertexCount; i_1++) { + deform[i_1] += lastVertices[i_1] - setupVertices[i_1]; + } + } else { + for (var i_2 = 0; i_2 < vertexCount; i_2++) deform[i_2] += lastVertices[i_2]; + } + } else { + core.Utils.arrayCopy(lastVertices, 0, deform, 0, vertexCount); + } + } else { + switch (blend) { + case MixBlend.setup: { + var vertexAttachment_1 = slotAttachment; + if (vertexAttachment_1.bones == null) { + var setupVertices = vertexAttachment_1.vertices; + for (var i_3 = 0; i_3 < vertexCount; i_3++) { + var setup = setupVertices[i_3]; + deform[i_3] = setup + (lastVertices[i_3] - setup) * alpha; + } + } else { + for (var i_4 = 0; i_4 < vertexCount; i_4++) deform[i_4] = lastVertices[i_4] * alpha; + } + break; + } + case MixBlend.first: + case MixBlend.replace: + for (var i_5 = 0; i_5 < vertexCount; i_5++) deform[i_5] += (lastVertices[i_5] - deform[i_5]) * alpha; + break; + case MixBlend.add: + var vertexAttachment = slotAttachment; + if (vertexAttachment.bones == null) { + var setupVertices = vertexAttachment.vertices; + for (var i_6 = 0; i_6 < vertexCount; i_6++) { + deform[i_6] += (lastVertices[i_6] - setupVertices[i_6]) * alpha; + } + } else { + for (var i_7 = 0; i_7 < vertexCount; i_7++) deform[i_7] += lastVertices[i_7] * alpha; + } + } + } + return; + } + var frame = Animation.binarySearch(frames, time); + var prevVertices = frameVertices[frame - 1]; + var nextVertices = frameVertices[frame]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame - 1, 1 - (time - frameTime) / (frames[frame - 1] - frameTime)); + if (alpha == 1) { + if (blend == MixBlend.add) { + var vertexAttachment = slotAttachment; + if (vertexAttachment.bones == null) { + var setupVertices = vertexAttachment.vertices; + for (var i_8 = 0; i_8 < vertexCount; i_8++) { + var prev = prevVertices[i_8]; + deform[i_8] += prev + (nextVertices[i_8] - prev) * percent - setupVertices[i_8]; + } + } else { + for (var i_9 = 0; i_9 < vertexCount; i_9++) { + var prev = prevVertices[i_9]; + deform[i_9] += prev + (nextVertices[i_9] - prev) * percent; + } + } + } else { + for (var i_10 = 0; i_10 < vertexCount; i_10++) { + var prev = prevVertices[i_10]; + deform[i_10] = prev + (nextVertices[i_10] - prev) * percent; + } + } + } else { + switch (blend) { + case MixBlend.setup: { + var vertexAttachment_2 = slotAttachment; + if (vertexAttachment_2.bones == null) { + var setupVertices = vertexAttachment_2.vertices; + for (var i_11 = 0; i_11 < vertexCount; i_11++) { + var prev = prevVertices[i_11], + setup = setupVertices[i_11]; + deform[i_11] = setup + (prev + (nextVertices[i_11] - prev) * percent - setup) * alpha; + } + } else { + for (var i_12 = 0; i_12 < vertexCount; i_12++) { + var prev = prevVertices[i_12]; + deform[i_12] = (prev + (nextVertices[i_12] - prev) * percent) * alpha; + } + } + break; + } + case MixBlend.first: + case MixBlend.replace: + for (var i_13 = 0; i_13 < vertexCount; i_13++) { + var prev = prevVertices[i_13]; + deform[i_13] += (prev + (nextVertices[i_13] - prev) * percent - deform[i_13]) * alpha; + } + break; + case MixBlend.add: + var vertexAttachment = slotAttachment; + if (vertexAttachment.bones == null) { + var setupVertices = vertexAttachment.vertices; + for (var i_14 = 0; i_14 < vertexCount; i_14++) { + var prev = prevVertices[i_14]; + deform[i_14] += (prev + (nextVertices[i_14] - prev) * percent - setupVertices[i_14]) * alpha; + } + } else { + for (var i_15 = 0; i_15 < vertexCount; i_15++) { + var prev = prevVertices[i_15]; + deform[i_15] += (prev + (nextVertices[i_15] - prev) * percent) * alpha; + } + } + } + } + }; + return DeformTimeline; + })(CurveTimeline); + core.DeformTimeline = DeformTimeline; + var EventTimeline = (function () { + function EventTimeline(frameCount) { + this.frames = core.Utils.newFloatArray(frameCount); + this.events = new Array(frameCount); + } + EventTimeline.prototype.getPropertyId = function () { + return TimelineType.event << 24; + }; + EventTimeline.prototype.getFrameCount = function () { + return this.frames.length; + }; + EventTimeline.prototype.setFrame = function (frameIndex, event) { + this.frames[frameIndex] = event.time; + this.events[frameIndex] = event; + }; + EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) { + if (firedEvents == null) return; + var frames = this.frames; + var frameCount = this.frames.length; + if (lastTime > time) { + this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, blend, direction); + lastTime = -1; + } else if (lastTime >= frames[frameCount - 1]) return; + if (time < frames[0]) return; + var frame = 0; + if (lastTime < frames[0]) frame = 0; + else { + frame = Animation.binarySearch(frames, lastTime); + var frameTime = frames[frame]; + while (frame > 0) { + if (frames[frame - 1] != frameTime) break; + frame--; + } + } + for (; frame < frameCount && time >= frames[frame]; frame++) firedEvents.push(this.events[frame]); + }; + return EventTimeline; + })(); + core.EventTimeline = EventTimeline; + var DrawOrderTimeline = (function () { + function DrawOrderTimeline(frameCount) { + this.frames = core.Utils.newFloatArray(frameCount); + this.drawOrders = new Array(frameCount); + } + DrawOrderTimeline.prototype.getPropertyId = function () { + return TimelineType.drawOrder << 24; + }; + DrawOrderTimeline.prototype.getFrameCount = function () { + return this.frames.length; + }; + DrawOrderTimeline.prototype.setFrame = function (frameIndex, time, drawOrder) { + this.frames[frameIndex] = time; + this.drawOrders[frameIndex] = drawOrder; + }; + DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) { + var drawOrder = skeleton.drawOrder; + var slots = skeleton.slots; + if (direction == MixDirection.mixOut && blend == MixBlend.setup) { + core.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length); + return; + } + var frames = this.frames; + if (time < frames[0]) { + if (blend == MixBlend.setup || blend == MixBlend.first) + core.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length); + return; + } + var frame = 0; + if (time >= frames[frames.length - 1]) frame = frames.length - 1; + else frame = Animation.binarySearch(frames, time) - 1; + var drawOrderToSetupIndex = this.drawOrders[frame]; + if (drawOrderToSetupIndex == null) core.Utils.arrayCopy(slots, 0, drawOrder, 0, slots.length); + else { + for (var i = 0, n = drawOrderToSetupIndex.length; i < n; i++) drawOrder[i] = slots[drawOrderToSetupIndex[i]]; + } + }; + return DrawOrderTimeline; + })(); + core.DrawOrderTimeline = DrawOrderTimeline; + var IkConstraintTimeline = (function (_super) { + __extends(IkConstraintTimeline, _super); + function IkConstraintTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = core.Utils.newFloatArray(frameCount * IkConstraintTimeline.ENTRIES); + return _this; + } + IkConstraintTimeline.prototype.getPropertyId = function () { + return (TimelineType.ikConstraint << 24) + this.ikConstraintIndex; + }; + IkConstraintTimeline.prototype.setFrame = function ( + frameIndex, + time, + mix, + softness, + bendDirection, + compress, + stretch, + ) { + frameIndex *= IkConstraintTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + IkConstraintTimeline.MIX] = mix; + this.frames[frameIndex + IkConstraintTimeline.SOFTNESS] = softness; + this.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection; + this.frames[frameIndex + IkConstraintTimeline.COMPRESS] = compress ? 1 : 0; + this.frames[frameIndex + IkConstraintTimeline.STRETCH] = stretch ? 1 : 0; + }; + IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) { + var frames = this.frames; + var constraint = skeleton.ikConstraints[this.ikConstraintIndex]; + if (!constraint.active) return; + if (time < frames[0]) { + switch (blend) { + case MixBlend.setup: + constraint.mix = constraint.data.mix; + constraint.softness = constraint.data.softness; + constraint.bendDirection = constraint.data.bendDirection; + constraint.compress = constraint.data.compress; + constraint.stretch = constraint.data.stretch; + return; + case MixBlend.first: + constraint.mix += (constraint.data.mix - constraint.mix) * alpha; + constraint.softness += (constraint.data.softness - constraint.softness) * alpha; + constraint.bendDirection = constraint.data.bendDirection; + constraint.compress = constraint.data.compress; + constraint.stretch = constraint.data.stretch; + } + return; + } + if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) { + if (blend == MixBlend.setup) { + constraint.mix = + constraint.data.mix + + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha; + constraint.softness = + constraint.data.softness + + (frames[frames.length + IkConstraintTimeline.PREV_SOFTNESS] - constraint.data.softness) * alpha; + if (direction == MixDirection.mixOut) { + constraint.bendDirection = constraint.data.bendDirection; + constraint.compress = constraint.data.compress; + constraint.stretch = constraint.data.stretch; + } else { + constraint.bendDirection = frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION]; + constraint.compress = frames[frames.length + IkConstraintTimeline.PREV_COMPRESS] != 0; + constraint.stretch = frames[frames.length + IkConstraintTimeline.PREV_STRETCH] != 0; + } + } else { + constraint.mix += (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.mix) * alpha; + constraint.softness += + (frames[frames.length + IkConstraintTimeline.PREV_SOFTNESS] - constraint.softness) * alpha; + if (direction == MixDirection.mixIn) { + constraint.bendDirection = frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION]; + constraint.compress = frames[frames.length + IkConstraintTimeline.PREV_COMPRESS] != 0; + constraint.stretch = frames[frames.length + IkConstraintTimeline.PREV_STRETCH] != 0; + } + } + return; + } + var frame = Animation.binarySearch(frames, time, IkConstraintTimeline.ENTRIES); + var mix = frames[frame + IkConstraintTimeline.PREV_MIX]; + var softness = frames[frame + IkConstraintTimeline.PREV_SOFTNESS]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent( + frame / IkConstraintTimeline.ENTRIES - 1, + 1 - (time - frameTime) / (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime), + ); + if (blend == MixBlend.setup) { + constraint.mix = + constraint.data.mix + + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha; + constraint.softness = + constraint.data.softness + + (softness + + (frames[frame + IkConstraintTimeline.SOFTNESS] - softness) * percent - + constraint.data.softness) * + alpha; + if (direction == MixDirection.mixOut) { + constraint.bendDirection = constraint.data.bendDirection; + constraint.compress = constraint.data.compress; + constraint.stretch = constraint.data.stretch; + } else { + constraint.bendDirection = frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION]; + constraint.compress = frames[frame + IkConstraintTimeline.PREV_COMPRESS] != 0; + constraint.stretch = frames[frame + IkConstraintTimeline.PREV_STRETCH] != 0; + } + } else { + constraint.mix += (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.mix) * alpha; + constraint.softness += + (softness + (frames[frame + IkConstraintTimeline.SOFTNESS] - softness) * percent - constraint.softness) * + alpha; + if (direction == MixDirection.mixIn) { + constraint.bendDirection = frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION]; + constraint.compress = frames[frame + IkConstraintTimeline.PREV_COMPRESS] != 0; + constraint.stretch = frames[frame + IkConstraintTimeline.PREV_STRETCH] != 0; + } + } + }; + IkConstraintTimeline.ENTRIES = 6; + IkConstraintTimeline.PREV_TIME = -6; + IkConstraintTimeline.PREV_MIX = -5; + IkConstraintTimeline.PREV_SOFTNESS = -4; + IkConstraintTimeline.PREV_BEND_DIRECTION = -3; + IkConstraintTimeline.PREV_COMPRESS = -2; + IkConstraintTimeline.PREV_STRETCH = -1; + IkConstraintTimeline.MIX = 1; + IkConstraintTimeline.SOFTNESS = 2; + IkConstraintTimeline.BEND_DIRECTION = 3; + IkConstraintTimeline.COMPRESS = 4; + IkConstraintTimeline.STRETCH = 5; + return IkConstraintTimeline; + })(CurveTimeline); + core.IkConstraintTimeline = IkConstraintTimeline; + var TransformConstraintTimeline = (function (_super) { + __extends(TransformConstraintTimeline, _super); + function TransformConstraintTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = core.Utils.newFloatArray(frameCount * TransformConstraintTimeline.ENTRIES); + return _this; + } + TransformConstraintTimeline.prototype.getPropertyId = function () { + return (TimelineType.transformConstraint << 24) + this.transformConstraintIndex; + }; + TransformConstraintTimeline.prototype.setFrame = function ( + frameIndex, + time, + rotateMix, + translateMix, + scaleMix, + shearMix, + ) { + frameIndex *= TransformConstraintTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + TransformConstraintTimeline.ROTATE] = rotateMix; + this.frames[frameIndex + TransformConstraintTimeline.TRANSLATE] = translateMix; + this.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix; + this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix; + }; + TransformConstraintTimeline.prototype.apply = function ( + skeleton, + lastTime, + time, + firedEvents, + alpha, + blend, + direction, + ) { + var frames = this.frames; + var constraint = skeleton.transformConstraints[this.transformConstraintIndex]; + if (!constraint.active) return; + if (time < frames[0]) { + var data = constraint.data; + switch (blend) { + case MixBlend.setup: + constraint.rotateMix = data.rotateMix; + constraint.translateMix = data.translateMix; + constraint.scaleMix = data.scaleMix; + constraint.shearMix = data.shearMix; + return; + case MixBlend.first: + constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha; + constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha; + constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha; + constraint.shearMix += (data.shearMix - constraint.shearMix) * alpha; + } + return; + } + var rotate = 0, + translate = 0, + scale = 0, + shear = 0; + if (time >= frames[frames.length - TransformConstraintTimeline.ENTRIES]) { + var i = frames.length; + rotate = frames[i + TransformConstraintTimeline.PREV_ROTATE]; + translate = frames[i + TransformConstraintTimeline.PREV_TRANSLATE]; + scale = frames[i + TransformConstraintTimeline.PREV_SCALE]; + shear = frames[i + TransformConstraintTimeline.PREV_SHEAR]; + } else { + var frame = Animation.binarySearch(frames, time, TransformConstraintTimeline.ENTRIES); + rotate = frames[frame + TransformConstraintTimeline.PREV_ROTATE]; + translate = frames[frame + TransformConstraintTimeline.PREV_TRANSLATE]; + scale = frames[frame + TransformConstraintTimeline.PREV_SCALE]; + shear = frames[frame + TransformConstraintTimeline.PREV_SHEAR]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent( + frame / TransformConstraintTimeline.ENTRIES - 1, + 1 - (time - frameTime) / (frames[frame + TransformConstraintTimeline.PREV_TIME] - frameTime), + ); + rotate += (frames[frame + TransformConstraintTimeline.ROTATE] - rotate) * percent; + translate += (frames[frame + TransformConstraintTimeline.TRANSLATE] - translate) * percent; + scale += (frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent; + shear += (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent; + } + if (blend == MixBlend.setup) { + var data = constraint.data; + constraint.rotateMix = data.rotateMix + (rotate - data.rotateMix) * alpha; + constraint.translateMix = data.translateMix + (translate - data.translateMix) * alpha; + constraint.scaleMix = data.scaleMix + (scale - data.scaleMix) * alpha; + constraint.shearMix = data.shearMix + (shear - data.shearMix) * alpha; + } else { + constraint.rotateMix += (rotate - constraint.rotateMix) * alpha; + constraint.translateMix += (translate - constraint.translateMix) * alpha; + constraint.scaleMix += (scale - constraint.scaleMix) * alpha; + constraint.shearMix += (shear - constraint.shearMix) * alpha; + } + }; + TransformConstraintTimeline.ENTRIES = 5; + TransformConstraintTimeline.PREV_TIME = -5; + TransformConstraintTimeline.PREV_ROTATE = -4; + TransformConstraintTimeline.PREV_TRANSLATE = -3; + TransformConstraintTimeline.PREV_SCALE = -2; + TransformConstraintTimeline.PREV_SHEAR = -1; + TransformConstraintTimeline.ROTATE = 1; + TransformConstraintTimeline.TRANSLATE = 2; + TransformConstraintTimeline.SCALE = 3; + TransformConstraintTimeline.SHEAR = 4; + return TransformConstraintTimeline; + })(CurveTimeline); + core.TransformConstraintTimeline = TransformConstraintTimeline; + var PathConstraintPositionTimeline = (function (_super) { + __extends(PathConstraintPositionTimeline, _super); + function PathConstraintPositionTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = core.Utils.newFloatArray(frameCount * PathConstraintPositionTimeline.ENTRIES); + return _this; + } + PathConstraintPositionTimeline.prototype.getPropertyId = function () { + return (TimelineType.pathConstraintPosition << 24) + this.pathConstraintIndex; + }; + PathConstraintPositionTimeline.prototype.setFrame = function (frameIndex, time, value) { + frameIndex *= PathConstraintPositionTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value; + }; + PathConstraintPositionTimeline.prototype.apply = function ( + skeleton, + lastTime, + time, + firedEvents, + alpha, + blend, + direction, + ) { + var frames = this.frames; + var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; + if (!constraint.active) return; + if (time < frames[0]) { + switch (blend) { + case MixBlend.setup: + constraint.position = constraint.data.position; + return; + case MixBlend.first: + constraint.position += (constraint.data.position - constraint.position) * alpha; + } + return; + } + var position = 0; + if (time >= frames[frames.length - PathConstraintPositionTimeline.ENTRIES]) + position = frames[frames.length + PathConstraintPositionTimeline.PREV_VALUE]; + else { + var frame = Animation.binarySearch(frames, time, PathConstraintPositionTimeline.ENTRIES); + position = frames[frame + PathConstraintPositionTimeline.PREV_VALUE]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent( + frame / PathConstraintPositionTimeline.ENTRIES - 1, + 1 - (time - frameTime) / (frames[frame + PathConstraintPositionTimeline.PREV_TIME] - frameTime), + ); + position += (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * percent; + } + if (blend == MixBlend.setup) + constraint.position = constraint.data.position + (position - constraint.data.position) * alpha; + else constraint.position += (position - constraint.position) * alpha; + }; + PathConstraintPositionTimeline.ENTRIES = 2; + PathConstraintPositionTimeline.PREV_TIME = -2; + PathConstraintPositionTimeline.PREV_VALUE = -1; + PathConstraintPositionTimeline.VALUE = 1; + return PathConstraintPositionTimeline; + })(CurveTimeline); + core.PathConstraintPositionTimeline = PathConstraintPositionTimeline; + var PathConstraintSpacingTimeline = (function (_super) { + __extends(PathConstraintSpacingTimeline, _super); + function PathConstraintSpacingTimeline(frameCount) { + return _super.call(this, frameCount) || this; + } + PathConstraintSpacingTimeline.prototype.getPropertyId = function () { + return (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex; + }; + PathConstraintSpacingTimeline.prototype.apply = function ( + skeleton, + lastTime, + time, + firedEvents, + alpha, + blend, + direction, + ) { + var frames = this.frames; + var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; + if (!constraint.active) return; + if (time < frames[0]) { + switch (blend) { + case MixBlend.setup: + constraint.spacing = constraint.data.spacing; + return; + case MixBlend.first: + constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha; + } + return; + } + var spacing = 0; + if (time >= frames[frames.length - PathConstraintSpacingTimeline.ENTRIES]) + spacing = frames[frames.length + PathConstraintSpacingTimeline.PREV_VALUE]; + else { + var frame = Animation.binarySearch(frames, time, PathConstraintSpacingTimeline.ENTRIES); + spacing = frames[frame + PathConstraintSpacingTimeline.PREV_VALUE]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent( + frame / PathConstraintSpacingTimeline.ENTRIES - 1, + 1 - (time - frameTime) / (frames[frame + PathConstraintSpacingTimeline.PREV_TIME] - frameTime), + ); + spacing += (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * percent; + } + if (blend == MixBlend.setup) + constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha; + else constraint.spacing += (spacing - constraint.spacing) * alpha; + }; + return PathConstraintSpacingTimeline; + })(PathConstraintPositionTimeline); + core.PathConstraintSpacingTimeline = PathConstraintSpacingTimeline; + var PathConstraintMixTimeline = (function (_super) { + __extends(PathConstraintMixTimeline, _super); + function PathConstraintMixTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = core.Utils.newFloatArray(frameCount * PathConstraintMixTimeline.ENTRIES); + return _this; + } + PathConstraintMixTimeline.prototype.getPropertyId = function () { + return (TimelineType.pathConstraintMix << 24) + this.pathConstraintIndex; + }; + PathConstraintMixTimeline.prototype.setFrame = function (frameIndex, time, rotateMix, translateMix) { + frameIndex *= PathConstraintMixTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix; + this.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix; + }; + PathConstraintMixTimeline.prototype.apply = function ( + skeleton, + lastTime, + time, + firedEvents, + alpha, + blend, + direction, + ) { + var frames = this.frames; + var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; + if (!constraint.active) return; + if (time < frames[0]) { + switch (blend) { + case MixBlend.setup: + constraint.rotateMix = constraint.data.rotateMix; + constraint.translateMix = constraint.data.translateMix; + return; + case MixBlend.first: + constraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha; + constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha; + } + return; + } + var rotate = 0, + translate = 0; + if (time >= frames[frames.length - PathConstraintMixTimeline.ENTRIES]) { + rotate = frames[frames.length + PathConstraintMixTimeline.PREV_ROTATE]; + translate = frames[frames.length + PathConstraintMixTimeline.PREV_TRANSLATE]; + } else { + var frame = Animation.binarySearch(frames, time, PathConstraintMixTimeline.ENTRIES); + rotate = frames[frame + PathConstraintMixTimeline.PREV_ROTATE]; + translate = frames[frame + PathConstraintMixTimeline.PREV_TRANSLATE]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent( + frame / PathConstraintMixTimeline.ENTRIES - 1, + 1 - (time - frameTime) / (frames[frame + PathConstraintMixTimeline.PREV_TIME] - frameTime), + ); + rotate += (frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * percent; + translate += (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * percent; + } + if (blend == MixBlend.setup) { + constraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha; + constraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha; + } else { + constraint.rotateMix += (rotate - constraint.rotateMix) * alpha; + constraint.translateMix += (translate - constraint.translateMix) * alpha; + } + }; + PathConstraintMixTimeline.ENTRIES = 3; + PathConstraintMixTimeline.PREV_TIME = -3; + PathConstraintMixTimeline.PREV_ROTATE = -2; + PathConstraintMixTimeline.PREV_TRANSLATE = -1; + PathConstraintMixTimeline.ROTATE = 1; + PathConstraintMixTimeline.TRANSLATE = 2; + return PathConstraintMixTimeline; + })(CurveTimeline); + core.PathConstraintMixTimeline = PathConstraintMixTimeline; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var AnimationState = (function () { + function AnimationState(data) { + this.tracks = new Array(); + this.timeScale = 1; + this.unkeyedState = 0; + this.events = new Array(); + this.listeners = new Array(); + this.queue = new EventQueue(this); + this.propertyIDs = new core.IntSet(); + this.animationsChanged = false; + this.trackEntryPool = new core.Pool(function () { + return new TrackEntry(); + }); + this.data = data; + } + AnimationState.prototype.update = function (delta) { + delta *= this.timeScale; + var tracks = this.tracks; + for (var i = 0, n = tracks.length; i < n; i++) { + var current = tracks[i]; + if (current == null) continue; + current.animationLast = current.nextAnimationLast; + current.trackLast = current.nextTrackLast; + var currentDelta = delta * current.timeScale; + if (current.delay > 0) { + current.delay -= currentDelta; + if (current.delay > 0) continue; + currentDelta = -current.delay; + current.delay = 0; + } + var next = current.next; + if (next != null) { + var nextTime = current.trackLast - next.delay; + if (nextTime >= 0) { + next.delay = 0; + next.trackTime += current.timeScale == 0 ? 0 : (nextTime / current.timeScale + delta) * next.timeScale; + current.trackTime += currentDelta; + this.setCurrent(i, next, true); + while (next.mixingFrom != null) { + next.mixTime += delta; + next = next.mixingFrom; + } + continue; + } + } else if (current.trackLast >= current.trackEnd && current.mixingFrom == null) { + tracks[i] = null; + this.queue.end(current); + this.disposeNext(current); + continue; + } + if (current.mixingFrom != null && this.updateMixingFrom(current, delta)) { + var from = current.mixingFrom; + current.mixingFrom = null; + if (from != null) from.mixingTo = null; + while (from != null) { + this.queue.end(from); + from = from.mixingFrom; + } + } + current.trackTime += currentDelta; + } + this.queue.drain(); + }; + AnimationState.prototype.updateMixingFrom = function (to, delta) { + var from = to.mixingFrom; + if (from == null) return true; + var finished = this.updateMixingFrom(from, delta); + from.animationLast = from.nextAnimationLast; + from.trackLast = from.nextTrackLast; + if (to.mixTime > 0 && to.mixTime >= to.mixDuration) { + if (from.totalAlpha == 0 || to.mixDuration == 0) { + to.mixingFrom = from.mixingFrom; + if (from.mixingFrom != null) from.mixingFrom.mixingTo = to; + to.interruptAlpha = from.interruptAlpha; + this.queue.end(from); + } + return finished; + } + from.trackTime += delta * from.timeScale; + to.mixTime += delta; + return false; + }; + AnimationState.prototype.apply = function (skeleton) { + if (skeleton == null) throw new Error('skeleton cannot be null.'); + if (this.animationsChanged) this._animationsChanged(); + var events = this.events; + var tracks = this.tracks; + var applied = false; + for (var i_16 = 0, n_1 = tracks.length; i_16 < n_1; i_16++) { + var current = tracks[i_16]; + if (current == null || current.delay > 0) continue; + applied = true; + var blend = i_16 == 0 ? core.MixBlend.first : current.mixBlend; + var mix = current.alpha; + if (current.mixingFrom != null) mix *= this.applyMixingFrom(current, skeleton, blend); + else if (current.trackTime >= current.trackEnd && current.next == null) mix = 0; + var animationLast = current.animationLast, + animationTime = current.getAnimationTime(); + var timelineCount = current.animation.timelines.length; + var timelines = current.animation.timelines; + if ((i_16 == 0 && mix == 1) || blend == core.MixBlend.add) { + for (var ii = 0; ii < timelineCount; ii++) { + core.Utils.webkit602BugfixHelper(mix, blend); + var timeline = timelines[ii]; + if (timeline instanceof core.AttachmentTimeline) + this.applyAttachmentTimeline(timeline, skeleton, animationTime, blend, true); + else timeline.apply(skeleton, animationLast, animationTime, events, mix, blend, core.MixDirection.mixIn); + } + } else { + var timelineMode = current.timelineMode; + var firstFrame = current.timelinesRotation.length == 0; + if (firstFrame) core.Utils.setArraySize(current.timelinesRotation, timelineCount << 1, null); + var timelinesRotation = current.timelinesRotation; + for (var ii = 0; ii < timelineCount; ii++) { + var timeline_1 = timelines[ii]; + var timelineBlend = timelineMode[ii] == AnimationState.SUBSEQUENT ? blend : core.MixBlend.setup; + if (timeline_1 instanceof core.RotateTimeline) { + this.applyRotateTimeline( + timeline_1, + skeleton, + animationTime, + mix, + timelineBlend, + timelinesRotation, + ii << 1, + firstFrame, + ); + } else if (timeline_1 instanceof core.AttachmentTimeline) { + this.applyAttachmentTimeline(timeline_1, skeleton, animationTime, blend, true); + } else { + core.Utils.webkit602BugfixHelper(mix, blend); + timeline_1.apply( + skeleton, + animationLast, + animationTime, + events, + mix, + timelineBlend, + core.MixDirection.mixIn, + ); + } + } + } + this.queueEvents(current, animationTime); + events.length = 0; + current.nextAnimationLast = animationTime; + current.nextTrackLast = current.trackTime; + } + var setupState = this.unkeyedState + AnimationState.SETUP; + var slots = skeleton.slots; + for (var i = 0, n = skeleton.slots.length; i < n; i++) { + var slot = slots[i]; + if (slot.attachmentState == setupState) { + var attachmentName = slot.data.attachmentName; + slot.attachment = attachmentName == null ? null : skeleton.getAttachment(slot.data.index, attachmentName); + } + } + this.unkeyedState += 2; + this.queue.drain(); + return applied; + }; + AnimationState.prototype.applyMixingFrom = function (to, skeleton, blend) { + var from = to.mixingFrom; + if (from.mixingFrom != null) this.applyMixingFrom(from, skeleton, blend); + var mix = 0; + if (to.mixDuration == 0) { + mix = 1; + if (blend == core.MixBlend.first) blend = core.MixBlend.setup; + } else { + mix = to.mixTime / to.mixDuration; + if (mix > 1) mix = 1; + if (blend != core.MixBlend.first) blend = from.mixBlend; + } + var events = mix < from.eventThreshold ? this.events : null; + var attachments = mix < from.attachmentThreshold, + drawOrder = mix < from.drawOrderThreshold; + var animationLast = from.animationLast, + animationTime = from.getAnimationTime(); + var timelineCount = from.animation.timelines.length; + var timelines = from.animation.timelines; + var alphaHold = from.alpha * to.interruptAlpha, + alphaMix = alphaHold * (1 - mix); + if (blend == core.MixBlend.add) { + for (var i = 0; i < timelineCount; i++) + timelines[i].apply( + skeleton, + animationLast, + animationTime, + events, + alphaMix, + blend, + core.MixDirection.mixOut, + ); + } else { + var timelineMode = from.timelineMode; + var timelineHoldMix = from.timelineHoldMix; + var firstFrame = from.timelinesRotation.length == 0; + if (firstFrame) core.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null); + var timelinesRotation = from.timelinesRotation; + from.totalAlpha = 0; + for (var i = 0; i < timelineCount; i++) { + var timeline = timelines[i]; + var direction = core.MixDirection.mixOut; + var timelineBlend = void 0; + var alpha = 0; + switch (timelineMode[i]) { + case AnimationState.SUBSEQUENT: + if (!drawOrder && timeline instanceof core.DrawOrderTimeline) continue; + timelineBlend = blend; + alpha = alphaMix; + break; + case AnimationState.FIRST: + timelineBlend = core.MixBlend.setup; + alpha = alphaMix; + break; + case AnimationState.HOLD_SUBSEQUENT: + timelineBlend = blend; + alpha = alphaHold; + break; + case AnimationState.HOLD_FIRST: + timelineBlend = core.MixBlend.setup; + alpha = alphaHold; + break; + default: + timelineBlend = core.MixBlend.setup; + var holdMix = timelineHoldMix[i]; + alpha = alphaHold * Math.max(0, 1 - holdMix.mixTime / holdMix.mixDuration); + break; + } + from.totalAlpha += alpha; + if (timeline instanceof core.RotateTimeline) + this.applyRotateTimeline( + timeline, + skeleton, + animationTime, + alpha, + timelineBlend, + timelinesRotation, + i << 1, + firstFrame, + ); + else if (timeline instanceof core.AttachmentTimeline) + this.applyAttachmentTimeline(timeline, skeleton, animationTime, timelineBlend, attachments); + else { + core.Utils.webkit602BugfixHelper(alpha, blend); + if (drawOrder && timeline instanceof core.DrawOrderTimeline && timelineBlend == core.MixBlend.setup) + direction = core.MixDirection.mixIn; + timeline.apply(skeleton, animationLast, animationTime, events, alpha, timelineBlend, direction); + } + } + } + if (to.mixDuration > 0) this.queueEvents(from, animationTime); + this.events.length = 0; + from.nextAnimationLast = animationTime; + from.nextTrackLast = from.trackTime; + return mix; + }; + AnimationState.prototype.applyAttachmentTimeline = function (timeline, skeleton, time, blend, attachments) { + var slot = skeleton.slots[timeline.slotIndex]; + if (!slot.bone.active) return; + var frames = timeline.frames; + if (time < frames[0]) { + if (blend == core.MixBlend.setup || blend == core.MixBlend.first) + this.setAttachment(skeleton, slot, slot.data.attachmentName, attachments); + } else { + var frameIndex; + if (time >= frames[frames.length - 1]) frameIndex = frames.length - 1; + else frameIndex = core.Animation.binarySearch(frames, time) - 1; + this.setAttachment(skeleton, slot, timeline.attachmentNames[frameIndex], attachments); + } + if (slot.attachmentState <= this.unkeyedState) slot.attachmentState = this.unkeyedState + AnimationState.SETUP; + }; + AnimationState.prototype.setAttachment = function (skeleton, slot, attachmentName, attachments) { + slot.attachment = attachmentName == null ? null : skeleton.getAttachment(slot.data.index, attachmentName); + if (attachments) slot.attachmentState = this.unkeyedState + AnimationState.CURRENT; + }; + AnimationState.prototype.applyRotateTimeline = function ( + timeline, + skeleton, + time, + alpha, + blend, + timelinesRotation, + i, + firstFrame, + ) { + if (firstFrame) timelinesRotation[i] = 0; + if (alpha == 1) { + timeline.apply(skeleton, 0, time, null, 1, blend, core.MixDirection.mixIn); + return; + } + var rotateTimeline = timeline; + var frames = rotateTimeline.frames; + var bone = skeleton.bones[rotateTimeline.boneIndex]; + if (!bone.active) return; + var r1 = 0, + r2 = 0; + if (time < frames[0]) { + switch (blend) { + case core.MixBlend.setup: + bone.rotation = bone.data.rotation; + default: + return; + case core.MixBlend.first: + r1 = bone.rotation; + r2 = bone.data.rotation; + } + } else { + r1 = blend == core.MixBlend.setup ? bone.data.rotation : bone.rotation; + if (time >= frames[frames.length - core.RotateTimeline.ENTRIES]) + r2 = bone.data.rotation + frames[frames.length + core.RotateTimeline.PREV_ROTATION]; + else { + var frame = core.Animation.binarySearch(frames, time, core.RotateTimeline.ENTRIES); + var prevRotation = frames[frame + core.RotateTimeline.PREV_ROTATION]; + var frameTime = frames[frame]; + var percent = rotateTimeline.getCurvePercent( + (frame >> 1) - 1, + 1 - (time - frameTime) / (frames[frame + core.RotateTimeline.PREV_TIME] - frameTime), + ); + r2 = frames[frame + core.RotateTimeline.ROTATION] - prevRotation; + r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360; + r2 = prevRotation + r2 * percent + bone.data.rotation; + r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360; + } + } + var total = 0, + diff = r2 - r1; + diff -= (16384 - ((16384.499999999996 - diff / 360) | 0)) * 360; + if (diff == 0) { + total = timelinesRotation[i]; + } else { + var lastTotal = 0, + lastDiff = 0; + if (firstFrame) { + lastTotal = 0; + lastDiff = diff; + } else { + lastTotal = timelinesRotation[i]; + lastDiff = timelinesRotation[i + 1]; + } + var current = diff > 0, + dir = lastTotal >= 0; + if (core.MathUtils.signum(lastDiff) != core.MathUtils.signum(diff) && Math.abs(lastDiff) <= 90) { + if (Math.abs(lastTotal) > 180) lastTotal += 360 * core.MathUtils.signum(lastTotal); + dir = current; + } + total = diff + lastTotal - (lastTotal % 360); + if (dir != current) total += 360 * core.MathUtils.signum(lastTotal); + timelinesRotation[i] = total; + } + timelinesRotation[i + 1] = diff; + r1 += total * alpha; + bone.rotation = r1 - (16384 - ((16384.499999999996 - r1 / 360) | 0)) * 360; + }; + AnimationState.prototype.queueEvents = function (entry, animationTime) { + var animationStart = entry.animationStart, + animationEnd = entry.animationEnd; + var duration = animationEnd - animationStart; + var trackLastWrapped = entry.trackLast % duration; + var events = this.events; + var i = 0, + n = events.length; + for (; i < n; i++) { + var event_1 = events[i]; + if (event_1.time < trackLastWrapped) break; + if (event_1.time > animationEnd) continue; + this.queue.event(entry, event_1); + } + var complete = false; + if (entry.loop) complete = duration == 0 || trackLastWrapped > entry.trackTime % duration; + else complete = animationTime >= animationEnd && entry.animationLast < animationEnd; + if (complete) this.queue.complete(entry); + for (; i < n; i++) { + var event_2 = events[i]; + if (event_2.time < animationStart) continue; + this.queue.event(entry, events[i]); + } + }; + AnimationState.prototype.clearTracks = function () { + var oldDrainDisabled = this.queue.drainDisabled; + this.queue.drainDisabled = true; + for (var i = 0, n = this.tracks.length; i < n; i++) this.clearTrack(i); + this.tracks.length = 0; + this.queue.drainDisabled = oldDrainDisabled; + this.queue.drain(); + }; + AnimationState.prototype.clearTrack = function (trackIndex) { + if (trackIndex >= this.tracks.length) return; + var current = this.tracks[trackIndex]; + if (current == null) return; + this.queue.end(current); + this.disposeNext(current); + var entry = current; + while (true) { + var from = entry.mixingFrom; + if (from == null) break; + this.queue.end(from); + entry.mixingFrom = null; + entry.mixingTo = null; + entry = from; + } + this.tracks[current.trackIndex] = null; + this.queue.drain(); + }; + AnimationState.prototype.setCurrent = function (index, current, interrupt) { + var from = this.expandToIndex(index); + this.tracks[index] = current; + if (from != null) { + if (interrupt) this.queue.interrupt(from); + current.mixingFrom = from; + from.mixingTo = current; + current.mixTime = 0; + if (from.mixingFrom != null && from.mixDuration > 0) + current.interruptAlpha *= Math.min(1, from.mixTime / from.mixDuration); + from.timelinesRotation.length = 0; + } + this.queue.start(current); + }; + AnimationState.prototype.setAnimation = function (trackIndex, animationName, loop) { + var animation = this.data.skeletonData.findAnimation(animationName); + if (animation == null) throw new Error('Animation not found: ' + animationName); + return this.setAnimationWith(trackIndex, animation, loop); + }; + AnimationState.prototype.setAnimationWith = function (trackIndex, animation, loop) { + if (animation == null) throw new Error('animation cannot be null.'); + var interrupt = true; + var current = this.expandToIndex(trackIndex); + if (current != null) { + if (current.nextTrackLast == -1) { + this.tracks[trackIndex] = current.mixingFrom; + this.queue.interrupt(current); + this.queue.end(current); + this.disposeNext(current); + current = current.mixingFrom; + interrupt = false; + } else this.disposeNext(current); + } + var entry = this.trackEntry(trackIndex, animation, loop, current); + this.setCurrent(trackIndex, entry, interrupt); + this.queue.drain(); + return entry; + }; + AnimationState.prototype.addAnimation = function (trackIndex, animationName, loop, delay) { + var animation = this.data.skeletonData.findAnimation(animationName); + if (animation == null) throw new Error('Animation not found: ' + animationName); + return this.addAnimationWith(trackIndex, animation, loop, delay); + }; + AnimationState.prototype.addAnimationWith = function (trackIndex, animation, loop, delay) { + if (animation == null) throw new Error('animation cannot be null.'); + var last = this.expandToIndex(trackIndex); + if (last != null) { + while (last.next != null) last = last.next; + } + var entry = this.trackEntry(trackIndex, animation, loop, last); + if (last == null) { + this.setCurrent(trackIndex, entry, true); + this.queue.drain(); + } else { + last.next = entry; + if (delay <= 0) { + var duration = last.animationEnd - last.animationStart; + if (duration != 0) { + if (last.loop) delay += duration * (1 + ((last.trackTime / duration) | 0)); + else delay += Math.max(duration, last.trackTime); + delay -= this.data.getMix(last.animation, animation); + } else delay = last.trackTime; + } + } + entry.delay = delay; + return entry; + }; + AnimationState.prototype.setEmptyAnimation = function (trackIndex, mixDuration) { + var entry = this.setAnimationWith(trackIndex, AnimationState.emptyAnimation, false); + entry.mixDuration = mixDuration; + entry.trackEnd = mixDuration; + return entry; + }; + AnimationState.prototype.addEmptyAnimation = function (trackIndex, mixDuration, delay) { + if (delay <= 0) delay -= mixDuration; + var entry = this.addAnimationWith(trackIndex, AnimationState.emptyAnimation, false, delay); + entry.mixDuration = mixDuration; + entry.trackEnd = mixDuration; + return entry; + }; + AnimationState.prototype.setEmptyAnimations = function (mixDuration) { + var oldDrainDisabled = this.queue.drainDisabled; + this.queue.drainDisabled = true; + for (var i = 0, n = this.tracks.length; i < n; i++) { + var current = this.tracks[i]; + if (current != null) this.setEmptyAnimation(current.trackIndex, mixDuration); + } + this.queue.drainDisabled = oldDrainDisabled; + this.queue.drain(); + }; + AnimationState.prototype.expandToIndex = function (index) { + if (index < this.tracks.length) return this.tracks[index]; + core.Utils.ensureArrayCapacity(this.tracks, index + 1, null); + this.tracks.length = index + 1; + return null; + }; + AnimationState.prototype.trackEntry = function (trackIndex, animation, loop, last) { + var entry = this.trackEntryPool.obtain(); + entry.trackIndex = trackIndex; + entry.animation = animation; + entry.loop = loop; + entry.holdPrevious = false; + entry.eventThreshold = 0; + entry.attachmentThreshold = 0; + entry.drawOrderThreshold = 0; + entry.animationStart = 0; + entry.animationEnd = animation.duration; + entry.animationLast = -1; + entry.nextAnimationLast = -1; + entry.delay = 0; + entry.trackTime = 0; + entry.trackLast = -1; + entry.nextTrackLast = -1; + entry.trackEnd = Number.MAX_VALUE; + entry.timeScale = 1; + entry.alpha = 1; + entry.interruptAlpha = 1; + entry.mixTime = 0; + entry.mixDuration = last == null ? 0 : this.data.getMix(last.animation, animation); + entry.mixBlend = core.MixBlend.replace; + return entry; + }; + AnimationState.prototype.disposeNext = function (entry) { + var next = entry.next; + while (next != null) { + this.queue.dispose(next); + next = next.next; + } + entry.next = null; + }; + AnimationState.prototype._animationsChanged = function () { + this.animationsChanged = false; + this.propertyIDs.clear(); + for (var i = 0, n = this.tracks.length; i < n; i++) { + var entry = this.tracks[i]; + if (entry == null) continue; + while (entry.mixingFrom != null) entry = entry.mixingFrom; + do { + if (entry.mixingFrom == null || entry.mixBlend != core.MixBlend.add) this.computeHold(entry); + entry = entry.mixingTo; + } while (entry != null); + } + }; + AnimationState.prototype.computeHold = function (entry) { + var to = entry.mixingTo; + var timelines = entry.animation.timelines; + var timelinesCount = entry.animation.timelines.length; + var timelineMode = core.Utils.setArraySize(entry.timelineMode, timelinesCount); + entry.timelineHoldMix.length = 0; + var timelineDipMix = core.Utils.setArraySize(entry.timelineHoldMix, timelinesCount); + var propertyIDs = this.propertyIDs; + if (to != null && to.holdPrevious) { + for (var i = 0; i < timelinesCount; i++) { + timelineMode[i] = propertyIDs.add(timelines[i].getPropertyId()) + ? AnimationState.HOLD_FIRST + : AnimationState.HOLD_SUBSEQUENT; + } + return; + } + outer: for (var i = 0; i < timelinesCount; i++) { + var timeline = timelines[i]; + var id = timeline.getPropertyId(); + if (!propertyIDs.add(id)) timelineMode[i] = AnimationState.SUBSEQUENT; + else if ( + to == null || + timeline instanceof core.AttachmentTimeline || + timeline instanceof core.DrawOrderTimeline || + timeline instanceof core.EventTimeline || + !to.animation.hasTimeline(id) + ) { + timelineMode[i] = AnimationState.FIRST; + } else { + for (var next = to.mixingTo; next != null; next = next.mixingTo) { + if (next.animation.hasTimeline(id)) continue; + if (entry.mixDuration > 0) { + timelineMode[i] = AnimationState.HOLD_MIX; + timelineDipMix[i] = next; + continue outer; + } + break; + } + timelineMode[i] = AnimationState.HOLD_FIRST; + } + } + }; + AnimationState.prototype.getCurrent = function (trackIndex) { + if (trackIndex >= this.tracks.length) return null; + return this.tracks[trackIndex]; + }; + AnimationState.prototype.addListener = function (listener) { + if (listener == null) throw new Error('listener cannot be null.'); + this.listeners.push(listener); + }; + AnimationState.prototype.removeListener = function (listener) { + var index = this.listeners.indexOf(listener); + if (index >= 0) this.listeners.splice(index, 1); + }; + AnimationState.prototype.clearListeners = function () { + this.listeners.length = 0; + }; + AnimationState.prototype.clearListenerNotifications = function () { + this.queue.clear(); + }; + AnimationState.prototype.setAnimationByName = function (trackIndex, animationName, loop) { + if (!AnimationState.deprecatedWarning1) { + AnimationState.deprecatedWarning1 = true; + console.warn( + 'Spine Deprecation Warning: AnimationState.setAnimationByName is deprecated, please use setAnimation from now on.', + ); + } + this.setAnimation(trackIndex, animationName, loop); + }; + AnimationState.prototype.addAnimationByName = function (trackIndex, animationName, loop, delay) { + if (!AnimationState.deprecatedWarning2) { + AnimationState.deprecatedWarning2 = true; + console.warn( + 'Spine Deprecation Warning: AnimationState.addAnimationByName is deprecated, please use addAnimation from now on.', + ); + } + this.addAnimation(trackIndex, animationName, loop, delay); + }; + AnimationState.prototype.hasAnimation = function (animationName) { + var animation = this.data.skeletonData.findAnimation(animationName); + return animation !== null; + }; + AnimationState.prototype.hasAnimationByName = function (animationName) { + if (!AnimationState.deprecatedWarning3) { + AnimationState.deprecatedWarning3 = true; + console.warn( + 'Spine Deprecation Warning: AnimationState.hasAnimationByName is deprecated, please use hasAnimation from now on.', + ); + } + return this.hasAnimation(animationName); + }; + AnimationState.emptyAnimation = new core.Animation('', [], 0); + AnimationState.SUBSEQUENT = 0; + AnimationState.FIRST = 1; + AnimationState.HOLD_SUBSEQUENT = 2; + AnimationState.HOLD_FIRST = 3; + AnimationState.HOLD_MIX = 4; + AnimationState.SETUP = 1; + AnimationState.CURRENT = 2; + AnimationState.deprecatedWarning1 = false; + AnimationState.deprecatedWarning2 = false; + AnimationState.deprecatedWarning3 = false; + return AnimationState; + })(); + core.AnimationState = AnimationState; + var TrackEntry = (function () { + function TrackEntry() { + this.mixBlend = core.MixBlend.replace; + this.timelineMode = new Array(); + this.timelineHoldMix = new Array(); + this.timelinesRotation = new Array(); + } + TrackEntry.prototype.reset = function () { + this.next = null; + this.mixingFrom = null; + this.mixingTo = null; + this.animation = null; + this.listener = null; + this.timelineMode.length = 0; + this.timelineHoldMix.length = 0; + this.timelinesRotation.length = 0; + }; + TrackEntry.prototype.getAnimationTime = function () { + if (this.loop) { + var duration = this.animationEnd - this.animationStart; + if (duration == 0) return this.animationStart; + return (this.trackTime % duration) + this.animationStart; + } + return Math.min(this.trackTime + this.animationStart, this.animationEnd); + }; + TrackEntry.prototype.setAnimationLast = function (animationLast) { + this.animationLast = animationLast; + this.nextAnimationLast = animationLast; + }; + TrackEntry.prototype.isComplete = function () { + return this.trackTime >= this.animationEnd - this.animationStart; + }; + TrackEntry.prototype.resetRotationDirections = function () { + this.timelinesRotation.length = 0; + }; + Object.defineProperty(TrackEntry.prototype, 'time', { + get: function () { + if (!TrackEntry.deprecatedWarning1) { + TrackEntry.deprecatedWarning1 = true; + console.warn('Spine Deprecation Warning: TrackEntry.time is deprecated, please use trackTime from now on.'); + } + return this.trackTime; + }, + set: function (value) { + if (!TrackEntry.deprecatedWarning1) { + TrackEntry.deprecatedWarning1 = true; + console.warn('Spine Deprecation Warning: TrackEntry.time is deprecated, please use trackTime from now on.'); + } + this.trackTime = value; + }, + enumerable: false, + configurable: true, + }); + Object.defineProperty(TrackEntry.prototype, 'endTime', { + get: function () { + if (!TrackEntry.deprecatedWarning2) { + TrackEntry.deprecatedWarning2 = true; + console.warn( + 'Spine Deprecation Warning: TrackEntry.endTime is deprecated, please use trackEnd from now on.', + ); + } + return this.trackTime; + }, + set: function (value) { + if (!TrackEntry.deprecatedWarning2) { + TrackEntry.deprecatedWarning2 = true; + console.warn( + 'Spine Deprecation Warning: TrackEntry.endTime is deprecated, please use trackEnd from now on.', + ); + } + this.trackTime = value; + }, + enumerable: false, + configurable: true, + }); + TrackEntry.prototype.loopsCount = function () { + return Math.floor(this.trackTime / this.trackEnd); + }; + TrackEntry.deprecatedWarning1 = false; + TrackEntry.deprecatedWarning2 = false; + return TrackEntry; + })(); + core.TrackEntry = TrackEntry; + var EventQueue = (function () { + function EventQueue(animState) { + this.objects = []; + this.drainDisabled = false; + this.animState = animState; + } + EventQueue.prototype.start = function (entry) { + this.objects.push(EventType.start); + this.objects.push(entry); + this.animState.animationsChanged = true; + }; + EventQueue.prototype.interrupt = function (entry) { + this.objects.push(EventType.interrupt); + this.objects.push(entry); + }; + EventQueue.prototype.end = function (entry) { + this.objects.push(EventType.end); + this.objects.push(entry); + this.animState.animationsChanged = true; + }; + EventQueue.prototype.dispose = function (entry) { + this.objects.push(EventType.dispose); + this.objects.push(entry); + }; + EventQueue.prototype.complete = function (entry) { + this.objects.push(EventType.complete); + this.objects.push(entry); + }; + EventQueue.prototype.event = function (entry, event) { + this.objects.push(EventType.event); + this.objects.push(entry); + this.objects.push(event); + }; + EventQueue.prototype.deprecateStuff = function () { + if (!EventQueue.deprecatedWarning1) { + EventQueue.deprecatedWarning1 = true; + console.warn( + "Spine Deprecation Warning: onComplete, onStart, onEnd, onEvent art deprecated, please use listeners from now on. 'state.addListener({ complete: function(track, event) { } })'", + ); + } + return true; + }; + EventQueue.prototype.drain = function () { + if (this.drainDisabled) return; + this.drainDisabled = true; + var objects = this.objects; + var listeners = this.animState.listeners; + for (var i = 0; i < objects.length; i += 2) { + var type = objects[i]; + var entry = objects[i + 1]; + switch (type) { + case EventType.start: + if (entry.listener != null && entry.listener.start) entry.listener.start(entry); + for (var ii = 0; ii < listeners.length; ii++) if (listeners[ii].start) listeners[ii].start(entry); + entry.onStart && this.deprecateStuff() && entry.onStart(entry.trackIndex); + this.animState.onStart && + this.deprecateStuff() && + this.deprecateStuff && + this.animState.onStart(entry.trackIndex); + break; + case EventType.interrupt: + if (entry.listener != null && entry.listener.interrupt) entry.listener.interrupt(entry); + for (var ii = 0; ii < listeners.length; ii++) if (listeners[ii].interrupt) listeners[ii].interrupt(entry); + break; + case EventType.end: + if (entry.listener != null && entry.listener.end) entry.listener.end(entry); + for (var ii = 0; ii < listeners.length; ii++) if (listeners[ii].end) listeners[ii].end(entry); + entry.onEnd && this.deprecateStuff() && entry.onEnd(entry.trackIndex); + this.animState.onEnd && this.deprecateStuff() && this.animState.onEnd(entry.trackIndex); + case EventType.dispose: + if (entry.listener != null && entry.listener.dispose) entry.listener.dispose(entry); + for (var ii = 0; ii < listeners.length; ii++) if (listeners[ii].dispose) listeners[ii].dispose(entry); + this.animState.trackEntryPool.free(entry); + break; + case EventType.complete: + if (entry.listener != null && entry.listener.complete) entry.listener.complete(entry); + for (var ii = 0; ii < listeners.length; ii++) if (listeners[ii].complete) listeners[ii].complete(entry); + var count = core.MathUtils.toInt(entry.loopsCount()); + entry.onComplete && this.deprecateStuff() && entry.onComplete(entry.trackIndex, count); + this.animState.onComplete && this.deprecateStuff() && this.animState.onComplete(entry.trackIndex, count); + break; + case EventType.event: + var event_3 = objects[i++ + 2]; + if (entry.listener != null && entry.listener.event) entry.listener.event(entry, event_3); + for (var ii = 0; ii < listeners.length; ii++) + if (listeners[ii].event) listeners[ii].event(entry, event_3); + entry.onEvent && this.deprecateStuff() && entry.onEvent(entry.trackIndex, event_3); + this.animState.onEvent && this.deprecateStuff() && this.animState.onEvent(entry.trackIndex, event_3); + break; + } + } + this.clear(); + this.drainDisabled = false; + }; + EventQueue.prototype.clear = function () { + this.objects.length = 0; + }; + EventQueue.deprecatedWarning1 = false; + return EventQueue; + })(); + core.EventQueue = EventQueue; + var EventType; + (function (EventType) { + EventType[(EventType['start'] = 0)] = 'start'; + EventType[(EventType['interrupt'] = 1)] = 'interrupt'; + EventType[(EventType['end'] = 2)] = 'end'; + EventType[(EventType['dispose'] = 3)] = 'dispose'; + EventType[(EventType['complete'] = 4)] = 'complete'; + EventType[(EventType['event'] = 5)] = 'event'; + })((EventType = core.EventType || (core.EventType = {}))); + var AnimationStateAdapter = (function () { + function AnimationStateAdapter() {} + AnimationStateAdapter.prototype.start = function (entry) {}; + AnimationStateAdapter.prototype.interrupt = function (entry) {}; + AnimationStateAdapter.prototype.end = function (entry) {}; + AnimationStateAdapter.prototype.dispose = function (entry) {}; + AnimationStateAdapter.prototype.complete = function (entry) {}; + AnimationStateAdapter.prototype.event = function (entry, event) {}; + return AnimationStateAdapter; + })(); + core.AnimationStateAdapter = AnimationStateAdapter; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var AnimationStateData = (function () { + function AnimationStateData(skeletonData) { + this.animationToMixTime = {}; + this.defaultMix = 0; + if (skeletonData == null) throw new Error('skeletonData cannot be null.'); + this.skeletonData = skeletonData; + } + AnimationStateData.prototype.setMix = function (fromName, toName, duration) { + var from = this.skeletonData.findAnimation(fromName); + if (from == null) throw new Error('Animation not found: ' + fromName); + var to = this.skeletonData.findAnimation(toName); + if (to == null) throw new Error('Animation not found: ' + toName); + this.setMixWith(from, to, duration); + }; + AnimationStateData.prototype.setMixByName = function (fromName, toName, duration) { + if (!AnimationStateData.deprecatedWarning1) { + AnimationStateData.deprecatedWarning1 = true; + console.warn( + 'Deprecation Warning: AnimationStateData.setMixByName is deprecated, please use setMix from now on.', + ); + } + this.setMix(fromName, toName, duration); + }; + AnimationStateData.prototype.setMixWith = function (from, to, duration) { + if (from == null) throw new Error('from cannot be null.'); + if (to == null) throw new Error('to cannot be null.'); + var key = from.name + '.' + to.name; + this.animationToMixTime[key] = duration; + }; + AnimationStateData.prototype.getMix = function (from, to) { + var key = from.name + '.' + to.name; + var value = this.animationToMixTime[key]; + return value === undefined ? this.defaultMix : value; + }; + AnimationStateData.deprecatedWarning1 = false; + return AnimationStateData; + })(); + core.AnimationStateData = AnimationStateData; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var AtlasAttachmentLoader = (function () { + function AtlasAttachmentLoader(atlas) { + this.atlas = atlas; + } + AtlasAttachmentLoader.prototype.newRegionAttachment = function (skin, name, path) { + var region = this.atlas.findRegion(path); + if (region == null) + throw new Error('Region not found in atlas: ' + path + ' (region attachment: ' + name + ')'); + var attachment = new core.RegionAttachment(name); + attachment.region = region; + return attachment; + }; + AtlasAttachmentLoader.prototype.newMeshAttachment = function (skin, name, path) { + var region = this.atlas.findRegion(path); + if (region == null) throw new Error('Region not found in atlas: ' + path + ' (mesh attachment: ' + name + ')'); + var attachment = new core.MeshAttachment(name); + attachment.region = region; + return attachment; + }; + AtlasAttachmentLoader.prototype.newBoundingBoxAttachment = function (skin, name) { + return new core.BoundingBoxAttachment(name); + }; + AtlasAttachmentLoader.prototype.newPathAttachment = function (skin, name) { + return new core.PathAttachment(name); + }; + AtlasAttachmentLoader.prototype.newPointAttachment = function (skin, name) { + return new core.PointAttachment(name); + }; + AtlasAttachmentLoader.prototype.newClippingAttachment = function (skin, name) { + return new core.ClippingAttachment(name); + }; + return AtlasAttachmentLoader; + })(); + core.AtlasAttachmentLoader = AtlasAttachmentLoader; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var BlendMode; + (function (BlendMode) { + BlendMode[(BlendMode['Normal'] = 0)] = 'Normal'; + BlendMode[(BlendMode['Additive'] = 1)] = 'Additive'; + BlendMode[(BlendMode['Multiply'] = 2)] = 'Multiply'; + BlendMode[(BlendMode['Screen'] = 3)] = 'Screen'; + })((BlendMode = core.BlendMode || (core.BlendMode = {}))); + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var Bone = (function () { + function Bone(data, skeleton, parent) { + this.matrix = new PIXI.Matrix(); + this.children = new Array(); + this.x = 0; + this.y = 0; + this.rotation = 0; + this.scaleX = 0; + this.scaleY = 0; + this.shearX = 0; + this.shearY = 0; + this.ax = 0; + this.ay = 0; + this.arotation = 0; + this.ascaleX = 0; + this.ascaleY = 0; + this.ashearX = 0; + this.ashearY = 0; + this.appliedValid = false; + this.sorted = false; + this.active = false; + if (data == null) throw new Error('data cannot be null.'); + if (skeleton == null) throw new Error('skeleton cannot be null.'); + this.data = data; + this.skeleton = skeleton; + this.parent = parent; + this.setToSetupPose(); + } + Object.defineProperty(Bone.prototype, 'worldX', { + get: function () { + return this.matrix.tx; + }, + enumerable: false, + configurable: true, + }); + Object.defineProperty(Bone.prototype, 'worldY', { + get: function () { + return this.matrix.ty; + }, + enumerable: false, + configurable: true, + }); + Bone.prototype.isActive = function () { + return this.active; + }; + Bone.prototype.update = function () { + this.updateWorldTransformWith( + this.x, + this.y, + this.rotation, + this.scaleX, + this.scaleY, + this.shearX, + this.shearY, + ); + }; + Bone.prototype.updateWorldTransform = function () { + this.updateWorldTransformWith( + this.x, + this.y, + this.rotation, + this.scaleX, + this.scaleY, + this.shearX, + this.shearY, + ); + }; + Bone.prototype.updateWorldTransformWith = function (x, y, rotation, scaleX, scaleY, shearX, shearY) { + this.ax = x; + this.ay = y; + this.arotation = rotation; + this.ascaleX = scaleX; + this.ascaleY = scaleY; + this.ashearX = shearX; + this.ashearY = shearY; + this.appliedValid = true; + var parent = this.parent; + var m = this.matrix; + var sx = this.skeleton.scaleX; + var sy = Bone.yDown ? -this.skeleton.scaleY : this.skeleton.scaleY; + if (parent == null) { + var skeleton = this.skeleton; + var rotationY = rotation + 90 + shearY; + m.a = core.MathUtils.cosDeg(rotation + shearX) * scaleX * sx; + m.c = core.MathUtils.cosDeg(rotationY) * scaleY * sx; + m.b = core.MathUtils.sinDeg(rotation + shearX) * scaleX * sy; + m.d = core.MathUtils.sinDeg(rotationY) * scaleY * sy; + m.tx = x * sx + skeleton.x; + m.ty = y * sy + skeleton.y; + return; + } + var pa = parent.matrix.a, + pb = parent.matrix.c, + pc = parent.matrix.b, + pd = parent.matrix.d; + m.tx = pa * x + pb * y + parent.matrix.tx; + m.ty = pc * x + pd * y + parent.matrix.ty; + switch (this.data.transformMode) { + case core.TransformMode.Normal: { + var rotationY = rotation + 90 + shearY; + var la = core.MathUtils.cosDeg(rotation + shearX) * scaleX; + var lb = core.MathUtils.cosDeg(rotationY) * scaleY; + var lc = core.MathUtils.sinDeg(rotation + shearX) * scaleX; + var ld = core.MathUtils.sinDeg(rotationY) * scaleY; + m.a = pa * la + pb * lc; + m.c = pa * lb + pb * ld; + m.b = pc * la + pd * lc; + m.d = pc * lb + pd * ld; + return; + } + case core.TransformMode.OnlyTranslation: { + var rotationY = rotation + 90 + shearY; + m.a = core.MathUtils.cosDeg(rotation + shearX) * scaleX; + m.c = core.MathUtils.cosDeg(rotationY) * scaleY; + m.b = core.MathUtils.sinDeg(rotation + shearX) * scaleX; + m.d = core.MathUtils.sinDeg(rotationY) * scaleY; + break; + } + case core.TransformMode.NoRotationOrReflection: { + var s = pa * pa + pc * pc; + var prx = 0; + if (s > 0.0001) { + s = Math.abs(pa * pd - pb * pc) / s; + pa /= this.skeleton.scaleX; + pc /= this.skeleton.scaleY; + pb = pc * s; + pd = pa * s; + prx = Math.atan2(pc, pa) * core.MathUtils.radDeg; + } else { + pa = 0; + pc = 0; + prx = 90 - Math.atan2(pd, pb) * core.MathUtils.radDeg; + } + var rx = rotation + shearX - prx; + var ry = rotation + shearY - prx + 90; + var la = core.MathUtils.cosDeg(rx) * scaleX; + var lb = core.MathUtils.cosDeg(ry) * scaleY; + var lc = core.MathUtils.sinDeg(rx) * scaleX; + var ld = core.MathUtils.sinDeg(ry) * scaleY; + m.a = pa * la - pb * lc; + m.c = pa * lb - pb * ld; + m.b = pc * la + pd * lc; + m.d = pc * lb + pd * ld; + break; + } + case core.TransformMode.NoScale: + case core.TransformMode.NoScaleOrReflection: { + var cos = core.MathUtils.cosDeg(rotation); + var sin = core.MathUtils.sinDeg(rotation); + var za = (pa * cos + pb * sin) / sx; + var zc = (pc * cos + pd * sin) / sy; + var s = Math.sqrt(za * za + zc * zc); + if (s > 0.00001) s = 1 / s; + za *= s; + zc *= s; + s = Math.sqrt(za * za + zc * zc); + if ( + this.data.transformMode == core.TransformMode.NoScale && + pa * pd - pb * pc < 0 != + (Bone.yDown + ? this.skeleton.scaleX < 0 != this.skeleton.scaleY > 0 + : this.skeleton.scaleX < 0 != this.skeleton.scaleY < 0) + ) + s = -s; + var r = Math.PI / 2 + Math.atan2(zc, za); + var zb = Math.cos(r) * s; + var zd = Math.sin(r) * s; + var la = core.MathUtils.cosDeg(shearX) * scaleX; + var lb = core.MathUtils.cosDeg(90 + shearY) * scaleY; + var lc = core.MathUtils.sinDeg(shearX) * scaleX; + var ld = core.MathUtils.sinDeg(90 + shearY) * scaleY; + m.a = za * la + zb * lc; + m.c = za * lb + zb * ld; + m.b = zc * la + zd * lc; + m.d = zc * lb + zd * ld; + break; + } + } + m.a *= sx; + m.c *= sx; + m.b *= sy; + m.d *= sy; + }; + Bone.prototype.setToSetupPose = function () { + var data = this.data; + this.x = data.x; + this.y = data.y; + this.rotation = data.rotation; + this.scaleX = data.scaleX; + this.scaleY = data.scaleY; + this.shearX = data.shearX; + this.shearY = data.shearY; + }; + Bone.prototype.getWorldRotationX = function () { + return Math.atan2(this.matrix.b, this.matrix.a) * core.MathUtils.radDeg; + }; + Bone.prototype.getWorldRotationY = function () { + return Math.atan2(this.matrix.d, this.matrix.c) * core.MathUtils.radDeg; + }; + Bone.prototype.getWorldScaleX = function () { + var m = this.matrix; + return Math.sqrt(m.a * m.a + m.c * m.c); + }; + Bone.prototype.getWorldScaleY = function () { + var m = this.matrix; + return Math.sqrt(m.b * m.b + m.d * m.d); + }; + Bone.prototype.updateAppliedTransform = function () { + this.appliedValid = true; + var parent = this.parent; + var m = this.matrix; + if (parent == null) { + this.ax = m.tx; + this.ay = m.ty; + this.arotation = Math.atan2(m.b, m.a) * core.MathUtils.radDeg; + this.ascaleX = Math.sqrt(m.a * m.a + m.b * m.b); + this.ascaleY = Math.sqrt(m.c * m.c + m.d * m.d); + this.ashearX = 0; + this.ashearY = Math.atan2(m.a * m.c + m.b * m.d, m.a * m.d - m.b * m.c) * core.MathUtils.radDeg; + return; + } + var pm = parent.matrix; + var pid = 1 / (pm.a * pm.d - pm.b * pm.c); + var dx = m.tx - pm.tx, + dy = m.ty - pm.ty; + this.ax = dx * pm.d * pid - dy * pm.c * pid; + this.ay = dy * pm.a * pid - dx * pm.b * pid; + var ia = pid * pm.d; + var id = pid * pm.a; + var ib = pid * pm.c; + var ic = pid * pm.b; + var ra = ia * m.a - ib * m.b; + var rb = ia * m.c - ib * m.d; + var rc = id * m.b - ic * m.a; + var rd = id * m.d - ic * m.c; + this.ashearX = 0; + this.ascaleX = Math.sqrt(ra * ra + rc * rc); + if (this.ascaleX > 0.0001) { + var det = ra * rd - rb * rc; + this.ascaleY = det / this.ascaleX; + this.ashearY = Math.atan2(ra * rb + rc * rd, det) * core.MathUtils.radDeg; + this.arotation = Math.atan2(rc, ra) * core.MathUtils.radDeg; + } else { + this.ascaleX = 0; + this.ascaleY = Math.sqrt(rb * rb + rd * rd); + this.ashearY = 0; + this.arotation = 90 - Math.atan2(rd, rb) * core.MathUtils.radDeg; + } + }; + Bone.prototype.worldToLocal = function (world) { + var m = this.matrix; + var a = m.a, + b = m.c, + c = m.b, + d = m.d; + var invDet = 1 / (a * d - b * c); + var x = world.x - m.tx, + y = world.y - m.ty; + world.x = x * d * invDet - y * b * invDet; + world.y = y * a * invDet - x * c * invDet; + return world; + }; + Bone.prototype.localToWorld = function (local) { + var m = this.matrix; + var x = local.x, + y = local.y; + local.x = x * m.a + y * m.c + m.tx; + local.y = x * m.b + y * m.d + m.ty; + return local; + }; + Bone.prototype.worldToLocalRotation = function (worldRotation) { + var sin = core.MathUtils.sinDeg(worldRotation), + cos = core.MathUtils.cosDeg(worldRotation); + var mat = this.matrix; + return Math.atan2(mat.a * sin - mat.b * cos, mat.d * cos - mat.c * sin) * core.MathUtils.radDeg; + }; + Bone.prototype.localToWorldRotation = function (localRotation) { + var sin = core.MathUtils.sinDeg(localRotation), + cos = core.MathUtils.cosDeg(localRotation); + var mat = this.matrix; + return Math.atan2(cos * mat.b + sin * mat.d, cos * mat.a + sin * mat.c) * core.MathUtils.radDeg; + }; + Bone.prototype.rotateWorld = function (degrees) { + var mat = this.matrix; + var a = mat.a, + b = mat.c, + c = mat.b, + d = mat.d; + var cos = core.MathUtils.cosDeg(degrees), + sin = core.MathUtils.sinDeg(degrees); + mat.a = cos * a - sin * c; + mat.c = cos * b - sin * d; + mat.b = sin * a + cos * c; + mat.d = sin * b + cos * d; + this.appliedValid = false; + }; + Bone.yDown = false; + return Bone; + })(); + core.Bone = Bone; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var BoneData = (function () { + function BoneData(index, name, parent) { + this.x = 0; + this.y = 0; + this.rotation = 0; + this.scaleX = 1; + this.scaleY = 1; + this.shearX = 0; + this.shearY = 0; + this.transformMode = TransformMode.Normal; + this.skinRequired = false; + this.color = new core.Color(); + if (index < 0) throw new Error('index must be >= 0.'); + if (name == null) throw new Error('name cannot be null.'); + this.index = index; + this.name = name; + this.parent = parent; + } + return BoneData; + })(); + core.BoneData = BoneData; + var TransformMode; + (function (TransformMode) { + TransformMode[(TransformMode['Normal'] = 0)] = 'Normal'; + TransformMode[(TransformMode['OnlyTranslation'] = 1)] = 'OnlyTranslation'; + TransformMode[(TransformMode['NoRotationOrReflection'] = 2)] = 'NoRotationOrReflection'; + TransformMode[(TransformMode['NoScale'] = 3)] = 'NoScale'; + TransformMode[(TransformMode['NoScaleOrReflection'] = 4)] = 'NoScaleOrReflection'; + })((TransformMode = core.TransformMode || (core.TransformMode = {}))); + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var ConstraintData = (function () { + function ConstraintData(name, order, skinRequired) { + this.name = name; + this.order = order; + this.skinRequired = skinRequired; + } + return ConstraintData; + })(); + core.ConstraintData = ConstraintData; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var Event = (function () { + function Event(time, data) { + if (data == null) throw new Error('data cannot be null.'); + this.time = time; + this.data = data; + } + return Event; + })(); + core.Event = Event; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var EventData = (function () { + function EventData(name) { + this.name = name; + } + return EventData; + })(); + core.EventData = EventData; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var IkConstraint = (function () { + function IkConstraint(data, skeleton) { + this.bendDirection = 0; + this.compress = false; + this.stretch = false; + this.mix = 1; + this.softness = 0; + this.active = false; + if (data == null) throw new Error('data cannot be null.'); + if (skeleton == null) throw new Error('skeleton cannot be null.'); + this.data = data; + this.mix = data.mix; + this.softness = data.softness; + this.bendDirection = data.bendDirection; + this.compress = data.compress; + this.stretch = data.stretch; + this.bones = new Array(); + for (var i = 0; i < data.bones.length; i++) this.bones.push(skeleton.findBone(data.bones[i].name)); + this.target = skeleton.findBone(data.target.name); + } + IkConstraint.prototype.isActive = function () { + return this.active; + }; + IkConstraint.prototype.apply = function () { + this.update(); + }; + IkConstraint.prototype.update = function () { + var target = this.target; + var bones = this.bones; + switch (bones.length) { + case 1: + this.apply1( + bones[0], + target.worldX, + target.worldY, + this.compress, + this.stretch, + this.data.uniform, + this.mix, + ); + break; + case 2: + this.apply2( + bones[0], + bones[1], + target.worldX, + target.worldY, + this.bendDirection, + this.stretch, + this.softness, + this.mix, + ); + break; + } + }; + IkConstraint.prototype.apply1 = function (bone, targetX, targetY, compress, stretch, uniform, alpha) { + if (!bone.appliedValid) bone.updateAppliedTransform(); + var p = bone.parent.matrix; + var pa = p.a, + pb = p.c, + pc = p.b, + pd = p.d; + var rotationIK = -bone.ashearX - bone.arotation, + tx = 0, + ty = 0; + switch (bone.data.transformMode) { + case core.TransformMode.OnlyTranslation: + tx = targetX - bone.worldX; + ty = targetY - bone.worldY; + break; + case core.TransformMode.NoRotationOrReflection: + var s = Math.abs(pa * pd - pb * pc) / (pa * pa + pc * pc); + var sa = pa / bone.skeleton.scaleX; + var sc = pc / bone.skeleton.scaleY; + pb = -sc * s * bone.skeleton.scaleX; + pd = sa * s * bone.skeleton.scaleY; + rotationIK += Math.atan2(sc, sa) * core.MathUtils.radDeg; + default: + var x = targetX - p.tx, + y = targetY - p.ty; + var d = pa * pd - pb * pc; + tx = (x * pd - y * pb) / d - bone.ax; + ty = (y * pa - x * pc) / d - bone.ay; + } + rotationIK += Math.atan2(ty, tx) * core.MathUtils.radDeg; + if (bone.ascaleX < 0) rotationIK += 180; + if (rotationIK > 180) rotationIK -= 360; + else if (rotationIK < -180) rotationIK += 360; + var sx = bone.ascaleX, + sy = bone.ascaleY; + if (compress || stretch) { + switch (bone.data.transformMode) { + case core.TransformMode.NoScale: + case core.TransformMode.NoScaleOrReflection: + tx = targetX - bone.worldX; + ty = targetY - bone.worldY; + } + var b = bone.data.length * sx, + dd = Math.sqrt(tx * tx + ty * ty); + if ((compress && dd < b) || (stretch && dd > b && b > 0.0001)) { + var s = (dd / b - 1) * alpha + 1; + sx *= s; + if (uniform) sy *= s; + } + } + bone.updateWorldTransformWith( + bone.ax, + bone.ay, + bone.arotation + rotationIK * alpha, + sx, + sy, + bone.ashearX, + bone.ashearY, + ); + }; + IkConstraint.prototype.apply2 = function (parent, child, targetX, targetY, bendDir, stretch, softness, alpha) { + if (alpha == 0) { + child.updateWorldTransform(); + return; + } + if (!parent.appliedValid) parent.updateAppliedTransform(); + if (!child.appliedValid) child.updateAppliedTransform(); + var px = parent.ax, + py = parent.ay, + psx = parent.ascaleX, + sx = psx, + psy = parent.ascaleY, + csx = child.ascaleX; + var pmat = parent.matrix; + var os1 = 0, + os2 = 0, + s2 = 0; + if (psx < 0) { + psx = -psx; + os1 = 180; + s2 = -1; + } else { + os1 = 0; + s2 = 1; + } + if (psy < 0) { + psy = -psy; + s2 = -s2; + } + if (csx < 0) { + csx = -csx; + os2 = 180; + } else os2 = 0; + var cx = child.ax, + cy = 0, + cwx = 0, + cwy = 0, + a = pmat.a, + b = pmat.c, + c = pmat.b, + d = pmat.d; + var u = Math.abs(psx - psy) <= 0.0001; + if (!u) { + cy = 0; + cwx = a * cx + pmat.tx; + cwy = c * cx + pmat.ty; + } else { + cy = child.ay; + cwx = a * cx + b * cy + pmat.tx; + cwy = c * cx + d * cy + pmat.ty; + } + var pp = parent.parent.matrix; + a = pp.a; + b = pp.c; + c = pp.b; + d = pp.d; + var id = 1 / (a * d - b * c), + x = cwx - pp.tx, + y = cwy - pp.ty; + var dx = (x * d - y * b) * id - px, + dy = (y * a - x * c) * id - py; + var l1 = Math.sqrt(dx * dx + dy * dy), + l2 = child.data.length * csx, + a1, + a2; + if (l1 < 0.0001) { + this.apply1(parent, targetX, targetY, false, stretch, false, alpha); + child.updateWorldTransformWith(cx, cy, 0, child.ascaleX, child.ascaleY, child.ashearX, child.ashearY); + return; + } + x = targetX - pp.tx; + y = targetY - pp.ty; + var tx = (x * d - y * b) * id - px, + ty = (y * a - x * c) * id - py; + var dd = tx * tx + ty * ty; + if (softness != 0) { + softness *= (psx * (csx + 1)) / 2; + var td = Math.sqrt(dd), + sd = td - l1 - l2 * psx + softness; + if (sd > 0) { + var p = Math.min(1, sd / (softness * 2)) - 1; + p = (sd - softness * (1 - p * p)) / td; + tx -= p * tx; + ty -= p * ty; + dd = tx * tx + ty * ty; + } + } + outer: if (u) { + l2 *= psx; + var cos = (dd - l1 * l1 - l2 * l2) / (2 * l1 * l2); + if (cos < -1) cos = -1; + else if (cos > 1) { + cos = 1; + if (stretch) sx *= (Math.sqrt(dd) / (l1 + l2) - 1) * alpha + 1; + } + a2 = Math.acos(cos) * bendDir; + a = l1 + l2 * cos; + b = l2 * Math.sin(a2); + a1 = Math.atan2(ty * a - tx * b, tx * a + ty * b); + } else { + a = psx * l2; + b = psy * l2; + var aa = a * a, + bb = b * b, + ta = Math.atan2(ty, tx); + c = bb * l1 * l1 + aa * dd - aa * bb; + var c1 = -2 * bb * l1, + c2 = bb - aa; + d = c1 * c1 - 4 * c2 * c; + if (d >= 0) { + var q = Math.sqrt(d); + if (c1 < 0) q = -q; + q = -(c1 + q) / 2; + var r0 = q / c2, + r1 = c / q; + var r = Math.abs(r0) < Math.abs(r1) ? r0 : r1; + if (r * r <= dd) { + y = Math.sqrt(dd - r * r) * bendDir; + a1 = ta - Math.atan2(y, r); + a2 = Math.atan2(y / psy, (r - l1) / psx); + break outer; + } + } + var minAngle = core.MathUtils.PI, + minX = l1 - a, + minDist = minX * minX, + minY = 0; + var maxAngle = 0, + maxX = l1 + a, + maxDist = maxX * maxX, + maxY = 0; + c = (-a * l1) / (aa - bb); + if (c >= -1 && c <= 1) { + c = Math.acos(c); + x = a * Math.cos(c) + l1; + y = b * Math.sin(c); + d = x * x + y * y; + if (d < minDist) { + minAngle = c; + minDist = d; + minX = x; + minY = y; + } + if (d > maxDist) { + maxAngle = c; + maxDist = d; + maxX = x; + maxY = y; + } + } + if (dd <= (minDist + maxDist) / 2) { + a1 = ta - Math.atan2(minY * bendDir, minX); + a2 = minAngle * bendDir; + } else { + a1 = ta - Math.atan2(maxY * bendDir, maxX); + a2 = maxAngle * bendDir; + } + } + var os = Math.atan2(cy, cx) * s2; + var rotation = parent.arotation; + a1 = (a1 - os) * core.MathUtils.radDeg + os1 - rotation; + if (a1 > 180) a1 -= 360; + else if (a1 < -180) a1 += 360; + parent.updateWorldTransformWith(px, py, rotation + a1 * alpha, sx, parent.ascaleY, 0, 0); + rotation = child.arotation; + a2 = ((a2 + os) * core.MathUtils.radDeg - child.ashearX) * s2 + os2 - rotation; + if (a2 > 180) a2 -= 360; + else if (a2 < -180) a2 += 360; + child.updateWorldTransformWith( + cx, + cy, + rotation + a2 * alpha, + child.ascaleX, + child.ascaleY, + child.ashearX, + child.ashearY, + ); + }; + return IkConstraint; + })(); + core.IkConstraint = IkConstraint; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var IkConstraintData = (function (_super) { + __extends(IkConstraintData, _super); + function IkConstraintData(name) { + var _this = _super.call(this, name, 0, false) || this; + _this.bones = new Array(); + _this.bendDirection = 1; + _this.compress = false; + _this.stretch = false; + _this.uniform = false; + _this.mix = 1; + _this.softness = 0; + return _this; + } + return IkConstraintData; + })(core.ConstraintData); + core.IkConstraintData = IkConstraintData; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var PathConstraint = (function () { + function PathConstraint(data, skeleton) { + this.position = 0; + this.spacing = 0; + this.rotateMix = 0; + this.translateMix = 0; + this.spaces = new Array(); + this.positions = new Array(); + this.world = new Array(); + this.curves = new Array(); + this.lengths = new Array(); + this.segments = new Array(); + this.active = false; + if (data == null) throw new Error('data cannot be null.'); + if (skeleton == null) throw new Error('skeleton cannot be null.'); + this.data = data; + this.bones = new Array(); + for (var i = 0, n = data.bones.length; i < n; i++) this.bones.push(skeleton.findBone(data.bones[i].name)); + this.target = skeleton.findSlot(data.target.name); + this.position = data.position; + this.spacing = data.spacing; + this.rotateMix = data.rotateMix; + this.translateMix = data.translateMix; + } + PathConstraint.prototype.isActive = function () { + return this.active; + }; + PathConstraint.prototype.apply = function () { + this.update(); + }; + PathConstraint.prototype.update = function () { + var attachment = this.target.getAttachment(); + if (!(attachment instanceof core.PathAttachment)) return; + var rotateMix = this.rotateMix, + translateMix = this.translateMix; + var translate = translateMix > 0, + rotate = rotateMix > 0; + if (!translate && !rotate) return; + var data = this.data; + var spacingMode = data.spacingMode; + var lengthSpacing = spacingMode == core.SpacingMode.Length; + var rotateMode = data.rotateMode; + var tangents = rotateMode == core.RotateMode.Tangent, + scale = rotateMode == core.RotateMode.ChainScale; + var boneCount = this.bones.length, + spacesCount = tangents ? boneCount : boneCount + 1; + var bones = this.bones; + var spaces = core.Utils.setArraySize(this.spaces, spacesCount), + lengths = null; + var spacing = this.spacing; + if (scale || lengthSpacing) { + if (scale) lengths = core.Utils.setArraySize(this.lengths, boneCount); + for (var i = 0, n = spacesCount - 1; i < n; ) { + var bone = bones[i]; + var setupLength = bone.data.length; + if (setupLength < PathConstraint.epsilon) { + if (scale) lengths[i] = 0; + spaces[++i] = 0; + } else { + var x = setupLength * bone.matrix.a, + y = setupLength * bone.matrix.b; + var length_1 = Math.sqrt(x * x + y * y); + if (scale) lengths[i] = length_1; + spaces[++i] = ((lengthSpacing ? setupLength + spacing : spacing) * length_1) / setupLength; + } + } + } else { + for (var i = 1; i < spacesCount; i++) spaces[i] = spacing; + } + var positions = this.computeWorldPositions( + attachment, + spacesCount, + tangents, + data.positionMode == core.PositionMode.Percent, + spacingMode == core.SpacingMode.Percent, + ); + var boneX = positions[0], + boneY = positions[1], + offsetRotation = data.offsetRotation; + var tip = false; + if (offsetRotation == 0) tip = rotateMode == core.RotateMode.Chain; + else { + tip = false; + var p = this.target.bone.matrix; + offsetRotation *= p.a * p.d - p.b * p.c > 0 ? core.MathUtils.degRad : -core.MathUtils.degRad; + } + for (var i = 0, p = 3; i < boneCount; i++, p += 3) { + var bone = bones[i]; + var mat = bone.matrix; + mat.tx += (boneX - mat.tx) * translateMix; + mat.ty += (boneY - mat.ty) * translateMix; + var x = positions[p], + y = positions[p + 1], + dx = x - boneX, + dy = y - boneY; + if (scale) { + var length_2 = lengths[i]; + if (length_2 != 0) { + var s = (Math.sqrt(dx * dx + dy * dy) / length_2 - 1) * rotateMix + 1; + mat.a *= s; + mat.b *= s; + } + } + boneX = x; + boneY = y; + if (rotate) { + var a = mat.a, + b = mat.c, + c = mat.b, + d = mat.d, + r = 0, + cos = 0, + sin = 0; + if (tangents) r = positions[p - 1]; + else if (spaces[i + 1] == 0) r = positions[p + 2]; + else r = Math.atan2(dy, dx); + r -= Math.atan2(c, a); + if (tip) { + cos = Math.cos(r); + sin = Math.sin(r); + var length_3 = bone.data.length; + boneX += (length_3 * (cos * a - sin * c) - dx) * rotateMix; + boneY += (length_3 * (sin * a + cos * c) - dy) * rotateMix; + } else { + r += offsetRotation; + } + if (r > core.MathUtils.PI) r -= core.MathUtils.PI2; + else if (r < -core.MathUtils.PI) r += core.MathUtils.PI2; + r *= rotateMix; + cos = Math.cos(r); + sin = Math.sin(r); + mat.a = cos * a - sin * c; + mat.c = cos * b - sin * d; + mat.b = sin * a + cos * c; + mat.d = sin * b + cos * d; + } + bone.appliedValid = false; + } + }; + PathConstraint.prototype.computeWorldPositions = function ( + path, + spacesCount, + tangents, + percentPosition, + percentSpacing, + ) { + var target = this.target; + var position = this.position; + var spaces = this.spaces, + out = core.Utils.setArraySize(this.positions, spacesCount * 3 + 2), + world = null; + var closed = path.closed; + var verticesLength = path.worldVerticesLength, + curveCount = verticesLength / 6, + prevCurve = PathConstraint.NONE; + if (!path.constantSpeed) { + var lengths = path.lengths; + curveCount -= closed ? 1 : 2; + var pathLength_1 = lengths[curveCount]; + if (percentPosition) position *= pathLength_1; + if (percentSpacing) { + for (var i = 0; i < spacesCount; i++) spaces[i] *= pathLength_1; + } + world = core.Utils.setArraySize(this.world, 8); + for (var i = 0, o = 0, curve = 0; i < spacesCount; i++, o += 3) { + var space = spaces[i]; + position += space; + var p = position; + if (closed) { + p %= pathLength_1; + if (p < 0) p += pathLength_1; + curve = 0; + } else if (p < 0) { + if (prevCurve != PathConstraint.BEFORE) { + prevCurve = PathConstraint.BEFORE; + path.computeWorldVertices(target, 2, 4, world, 0, 2); + } + this.addBeforePosition(p, world, 0, out, o); + continue; + } else if (p > pathLength_1) { + if (prevCurve != PathConstraint.AFTER) { + prevCurve = PathConstraint.AFTER; + path.computeWorldVertices(target, verticesLength - 6, 4, world, 0, 2); + } + this.addAfterPosition(p - pathLength_1, world, 0, out, o); + continue; + } + for (; ; curve++) { + var length_4 = lengths[curve]; + if (p > length_4) continue; + if (curve == 0) p /= length_4; + else { + var prev = lengths[curve - 1]; + p = (p - prev) / (length_4 - prev); + } + break; + } + if (curve != prevCurve) { + prevCurve = curve; + if (closed && curve == curveCount) { + path.computeWorldVertices(target, verticesLength - 4, 4, world, 0, 2); + path.computeWorldVertices(target, 0, 4, world, 4, 2); + } else path.computeWorldVertices(target, curve * 6 + 2, 8, world, 0, 2); + } + this.addCurvePosition( + p, + world[0], + world[1], + world[2], + world[3], + world[4], + world[5], + world[6], + world[7], + out, + o, + tangents || (i > 0 && space == 0), + ); + } + return out; + } + if (closed) { + verticesLength += 2; + world = core.Utils.setArraySize(this.world, verticesLength); + path.computeWorldVertices(target, 2, verticesLength - 4, world, 0, 2); + path.computeWorldVertices(target, 0, 2, world, verticesLength - 4, 2); + world[verticesLength - 2] = world[0]; + world[verticesLength - 1] = world[1]; + } else { + curveCount--; + verticesLength -= 4; + world = core.Utils.setArraySize(this.world, verticesLength); + path.computeWorldVertices(target, 2, verticesLength, world, 0, 2); + } + var curves = core.Utils.setArraySize(this.curves, curveCount); + var pathLength = 0; + var x1 = world[0], + y1 = world[1], + cx1 = 0, + cy1 = 0, + cx2 = 0, + cy2 = 0, + x2 = 0, + y2 = 0; + var tmpx = 0, + tmpy = 0, + dddfx = 0, + dddfy = 0, + ddfx = 0, + ddfy = 0, + dfx = 0, + dfy = 0; + for (var i = 0, w = 2; i < curveCount; i++, w += 6) { + cx1 = world[w]; + cy1 = world[w + 1]; + cx2 = world[w + 2]; + cy2 = world[w + 3]; + x2 = world[w + 4]; + y2 = world[w + 5]; + tmpx = (x1 - cx1 * 2 + cx2) * 0.1875; + tmpy = (y1 - cy1 * 2 + cy2) * 0.1875; + dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.09375; + dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.09375; + ddfx = tmpx * 2 + dddfx; + ddfy = tmpy * 2 + dddfy; + dfx = (cx1 - x1) * 0.75 + tmpx + dddfx * 0.16666667; + dfy = (cy1 - y1) * 0.75 + tmpy + dddfy * 0.16666667; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + dfx += ddfx; + dfy += ddfy; + ddfx += dddfx; + ddfy += dddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + dfx += ddfx; + dfy += ddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + dfx += ddfx + dddfx; + dfy += ddfy + dddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + curves[i] = pathLength; + x1 = x2; + y1 = y2; + } + if (percentPosition) position *= pathLength; + if (percentSpacing) { + for (var i = 0; i < spacesCount; i++) spaces[i] *= pathLength; + } + var segments = this.segments; + var curveLength = 0; + for (var i = 0, o = 0, curve = 0, segment = 0; i < spacesCount; i++, o += 3) { + var space = spaces[i]; + position += space; + var p = position; + if (closed) { + p %= pathLength; + if (p < 0) p += pathLength; + curve = 0; + } else if (p < 0) { + this.addBeforePosition(p, world, 0, out, o); + continue; + } else if (p > pathLength) { + this.addAfterPosition(p - pathLength, world, verticesLength - 4, out, o); + continue; + } + for (; ; curve++) { + var length_5 = curves[curve]; + if (p > length_5) continue; + if (curve == 0) p /= length_5; + else { + var prev = curves[curve - 1]; + p = (p - prev) / (length_5 - prev); + } + break; + } + if (curve != prevCurve) { + prevCurve = curve; + var ii = curve * 6; + x1 = world[ii]; + y1 = world[ii + 1]; + cx1 = world[ii + 2]; + cy1 = world[ii + 3]; + cx2 = world[ii + 4]; + cy2 = world[ii + 5]; + x2 = world[ii + 6]; + y2 = world[ii + 7]; + tmpx = (x1 - cx1 * 2 + cx2) * 0.03; + tmpy = (y1 - cy1 * 2 + cy2) * 0.03; + dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.006; + dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.006; + ddfx = tmpx * 2 + dddfx; + ddfy = tmpy * 2 + dddfy; + dfx = (cx1 - x1) * 0.3 + tmpx + dddfx * 0.16666667; + dfy = (cy1 - y1) * 0.3 + tmpy + dddfy * 0.16666667; + curveLength = Math.sqrt(dfx * dfx + dfy * dfy); + segments[0] = curveLength; + for (ii = 1; ii < 8; ii++) { + dfx += ddfx; + dfy += ddfy; + ddfx += dddfx; + ddfy += dddfy; + curveLength += Math.sqrt(dfx * dfx + dfy * dfy); + segments[ii] = curveLength; + } + dfx += ddfx; + dfy += ddfy; + curveLength += Math.sqrt(dfx * dfx + dfy * dfy); + segments[8] = curveLength; + dfx += ddfx + dddfx; + dfy += ddfy + dddfy; + curveLength += Math.sqrt(dfx * dfx + dfy * dfy); + segments[9] = curveLength; + segment = 0; + } + p *= curveLength; + for (; ; segment++) { + var length_6 = segments[segment]; + if (p > length_6) continue; + if (segment == 0) p /= length_6; + else { + var prev = segments[segment - 1]; + p = segment + (p - prev) / (length_6 - prev); + } + break; + } + this.addCurvePosition(p * 0.1, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, o, tangents || (i > 0 && space == 0)); + } + return out; + }; + PathConstraint.prototype.addBeforePosition = function (p, temp, i, out, o) { + var x1 = temp[i], + y1 = temp[i + 1], + dx = temp[i + 2] - x1, + dy = temp[i + 3] - y1, + r = Math.atan2(dy, dx); + out[o] = x1 + p * Math.cos(r); + out[o + 1] = y1 + p * Math.sin(r); + out[o + 2] = r; + }; + PathConstraint.prototype.addAfterPosition = function (p, temp, i, out, o) { + var x1 = temp[i + 2], + y1 = temp[i + 3], + dx = x1 - temp[i], + dy = y1 - temp[i + 1], + r = Math.atan2(dy, dx); + out[o] = x1 + p * Math.cos(r); + out[o + 1] = y1 + p * Math.sin(r); + out[o + 2] = r; + }; + PathConstraint.prototype.addCurvePosition = function (p, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, o, tangents) { + if (p == 0 || isNaN(p)) p = 0.0001; + var tt = p * p, + ttt = tt * p, + u = 1 - p, + uu = u * u, + uuu = uu * u; + var ut = u * p, + ut3 = ut * 3, + uut3 = u * ut3, + utt3 = ut3 * p; + var x = x1 * uuu + cx1 * uut3 + cx2 * utt3 + x2 * ttt, + y = y1 * uuu + cy1 * uut3 + cy2 * utt3 + y2 * ttt; + out[o] = x; + out[o + 1] = y; + if (tangents) + out[o + 2] = Math.atan2(y - (y1 * uu + cy1 * ut * 2 + cy2 * tt), x - (x1 * uu + cx1 * ut * 2 + cx2 * tt)); + }; + PathConstraint.NONE = -1; + PathConstraint.BEFORE = -2; + PathConstraint.AFTER = -3; + PathConstraint.epsilon = 0.00001; + return PathConstraint; + })(); + core.PathConstraint = PathConstraint; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var PathConstraintData = (function (_super) { + __extends(PathConstraintData, _super); + function PathConstraintData(name) { + var _this = _super.call(this, name, 0, false) || this; + _this.bones = new Array(); + return _this; + } + return PathConstraintData; + })(core.ConstraintData); + core.PathConstraintData = PathConstraintData; + var PositionMode; + (function (PositionMode) { + PositionMode[(PositionMode['Fixed'] = 0)] = 'Fixed'; + PositionMode[(PositionMode['Percent'] = 1)] = 'Percent'; + })((PositionMode = core.PositionMode || (core.PositionMode = {}))); + var SpacingMode; + (function (SpacingMode) { + SpacingMode[(SpacingMode['Length'] = 0)] = 'Length'; + SpacingMode[(SpacingMode['Fixed'] = 1)] = 'Fixed'; + SpacingMode[(SpacingMode['Percent'] = 2)] = 'Percent'; + })((SpacingMode = core.SpacingMode || (core.SpacingMode = {}))); + var RotateMode; + (function (RotateMode) { + RotateMode[(RotateMode['Tangent'] = 0)] = 'Tangent'; + RotateMode[(RotateMode['Chain'] = 1)] = 'Chain'; + RotateMode[(RotateMode['ChainScale'] = 2)] = 'ChainScale'; + })((RotateMode = core.RotateMode || (core.RotateMode = {}))); + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var Skeleton = (function () { + function Skeleton(data) { + this._updateCache = new Array(); + this.updateCacheReset = new Array(); + this.time = 0; + this.scaleX = 1; + this.scaleY = 1; + this.x = 0; + this.y = 0; + if (data == null) throw new Error('data cannot be null.'); + this.data = data; + this.bones = new Array(); + for (var i = 0; i < data.bones.length; i++) { + var boneData = data.bones[i]; + var bone = void 0; + if (boneData.parent == null) bone = new core.Bone(boneData, this, null); + else { + var parent_1 = this.bones[boneData.parent.index]; + bone = new core.Bone(boneData, this, parent_1); + parent_1.children.push(bone); + } + this.bones.push(bone); + } + this.slots = new Array(); + this.drawOrder = new Array(); + for (var i = 0; i < data.slots.length; i++) { + var slotData = data.slots[i]; + var bone = this.bones[slotData.boneData.index]; + var slot = new core.Slot(slotData, bone); + this.slots.push(slot); + this.drawOrder.push(slot); + } + this.ikConstraints = new Array(); + for (var i = 0; i < data.ikConstraints.length; i++) { + var ikConstraintData = data.ikConstraints[i]; + this.ikConstraints.push(new core.IkConstraint(ikConstraintData, this)); + } + this.transformConstraints = new Array(); + for (var i = 0; i < data.transformConstraints.length; i++) { + var transformConstraintData = data.transformConstraints[i]; + this.transformConstraints.push(new core.TransformConstraint(transformConstraintData, this)); + } + this.pathConstraints = new Array(); + for (var i = 0; i < data.pathConstraints.length; i++) { + var pathConstraintData = data.pathConstraints[i]; + this.pathConstraints.push(new core.PathConstraint(pathConstraintData, this)); + } + this.color = new core.Color(1, 1, 1, 1); + this.updateCache(); + } + Skeleton.prototype.updateCache = function () { + var updateCache = this._updateCache; + updateCache.length = 0; + this.updateCacheReset.length = 0; + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + bone.sorted = bone.data.skinRequired; + bone.active = !bone.sorted; + } + if (this.skin != null) { + var skinBones = this.skin.bones; + for (var i = 0, n = this.skin.bones.length; i < n; i++) { + var bone = this.bones[skinBones[i].index]; + do { + bone.sorted = false; + bone.active = true; + bone = bone.parent; + } while (bone != null); + } + } + var ikConstraints = this.ikConstraints; + var transformConstraints = this.transformConstraints; + var pathConstraints = this.pathConstraints; + var ikCount = ikConstraints.length, + transformCount = transformConstraints.length, + pathCount = pathConstraints.length; + var constraintCount = ikCount + transformCount + pathCount; + outer: for (var i = 0; i < constraintCount; i++) { + for (var ii = 0; ii < ikCount; ii++) { + var constraint = ikConstraints[ii]; + if (constraint.data.order == i) { + this.sortIkConstraint(constraint); + continue outer; + } + } + for (var ii = 0; ii < transformCount; ii++) { + var constraint = transformConstraints[ii]; + if (constraint.data.order == i) { + this.sortTransformConstraint(constraint); + continue outer; + } + } + for (var ii = 0; ii < pathCount; ii++) { + var constraint = pathConstraints[ii]; + if (constraint.data.order == i) { + this.sortPathConstraint(constraint); + continue outer; + } + } + } + for (var i = 0, n = bones.length; i < n; i++) this.sortBone(bones[i]); + }; + Skeleton.prototype.sortIkConstraint = function (constraint) { + constraint.active = + constraint.target.isActive() && + (!constraint.data.skinRequired || + (this.skin != null && core.Utils.contains(this.skin.constraints, constraint.data, true))); + if (!constraint.active) return; + var target = constraint.target; + this.sortBone(target); + var constrained = constraint.bones; + var parent = constrained[0]; + this.sortBone(parent); + if (constrained.length > 1) { + var child = constrained[constrained.length - 1]; + if (!(this._updateCache.indexOf(child) > -1)) this.updateCacheReset.push(child); + } + this._updateCache.push(constraint); + this.sortReset(parent.children); + constrained[constrained.length - 1].sorted = true; + }; + Skeleton.prototype.sortPathConstraint = function (constraint) { + constraint.active = + constraint.target.bone.isActive() && + (!constraint.data.skinRequired || + (this.skin != null && core.Utils.contains(this.skin.constraints, constraint.data, true))); + if (!constraint.active) return; + var slot = constraint.target; + var slotIndex = slot.data.index; + var slotBone = slot.bone; + if (this.skin != null) this.sortPathConstraintAttachment(this.skin, slotIndex, slotBone); + if (this.data.defaultSkin != null && this.data.defaultSkin != this.skin) + this.sortPathConstraintAttachment(this.data.defaultSkin, slotIndex, slotBone); + for (var i = 0, n = this.data.skins.length; i < n; i++) + this.sortPathConstraintAttachment(this.data.skins[i], slotIndex, slotBone); + var attachment = slot.getAttachment(); + if (attachment instanceof core.PathAttachment) this.sortPathConstraintAttachmentWith(attachment, slotBone); + var constrained = constraint.bones; + var boneCount = constrained.length; + for (var i = 0; i < boneCount; i++) this.sortBone(constrained[i]); + this._updateCache.push(constraint); + for (var i = 0; i < boneCount; i++) this.sortReset(constrained[i].children); + for (var i = 0; i < boneCount; i++) constrained[i].sorted = true; + }; + Skeleton.prototype.sortTransformConstraint = function (constraint) { + constraint.active = + constraint.target.isActive() && + (!constraint.data.skinRequired || + (this.skin != null && core.Utils.contains(this.skin.constraints, constraint.data, true))); + if (!constraint.active) return; + this.sortBone(constraint.target); + var constrained = constraint.bones; + var boneCount = constrained.length; + if (constraint.data.local) { + for (var i = 0; i < boneCount; i++) { + var child = constrained[i]; + this.sortBone(child.parent); + if (!(this._updateCache.indexOf(child) > -1)) this.updateCacheReset.push(child); + } + } else { + for (var i = 0; i < boneCount; i++) { + this.sortBone(constrained[i]); + } + } + this._updateCache.push(constraint); + for (var ii = 0; ii < boneCount; ii++) this.sortReset(constrained[ii].children); + for (var ii = 0; ii < boneCount; ii++) constrained[ii].sorted = true; + }; + Skeleton.prototype.sortPathConstraintAttachment = function (skin, slotIndex, slotBone) { + var attachments = skin.attachments[slotIndex]; + if (!attachments) return; + for (var key in attachments) { + this.sortPathConstraintAttachmentWith(attachments[key], slotBone); + } + }; + Skeleton.prototype.sortPathConstraintAttachmentWith = function (attachment, slotBone) { + if (!(attachment instanceof core.PathAttachment)) return; + var pathBones = attachment.bones; + if (pathBones == null) this.sortBone(slotBone); + else { + var bones = this.bones; + var i = 0; + while (i < pathBones.length) { + var boneCount = pathBones[i++]; + for (var n = i + boneCount; i < n; i++) { + var boneIndex = pathBones[i]; + this.sortBone(bones[boneIndex]); + } + } + } + }; + Skeleton.prototype.sortBone = function (bone) { + if (bone.sorted) return; + var parent = bone.parent; + if (parent != null) this.sortBone(parent); + bone.sorted = true; + this._updateCache.push(bone); + }; + Skeleton.prototype.sortReset = function (bones) { + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (!bone.active) continue; + if (bone.sorted) this.sortReset(bone.children); + bone.sorted = false; + } + }; + Skeleton.prototype.updateWorldTransform = function () { + var updateCacheReset = this.updateCacheReset; + for (var i = 0, n = updateCacheReset.length; i < n; i++) { + var bone = updateCacheReset[i]; + bone.ax = bone.x; + bone.ay = bone.y; + bone.arotation = bone.rotation; + bone.ascaleX = bone.scaleX; + bone.ascaleY = bone.scaleY; + bone.ashearX = bone.shearX; + bone.ashearY = bone.shearY; + bone.appliedValid = true; + } + var updateCache = this._updateCache; + for (var i = 0, n = updateCache.length; i < n; i++) updateCache[i].update(); + }; + Skeleton.prototype.setToSetupPose = function () { + this.setBonesToSetupPose(); + this.setSlotsToSetupPose(); + }; + Skeleton.prototype.setBonesToSetupPose = function () { + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) bones[i].setToSetupPose(); + var ikConstraints = this.ikConstraints; + for (var i = 0, n = ikConstraints.length; i < n; i++) { + var constraint = ikConstraints[i]; + constraint.mix = constraint.data.mix; + constraint.softness = constraint.data.softness; + constraint.bendDirection = constraint.data.bendDirection; + constraint.compress = constraint.data.compress; + constraint.stretch = constraint.data.stretch; + } + var transformConstraints = this.transformConstraints; + for (var i = 0, n = transformConstraints.length; i < n; i++) { + var constraint = transformConstraints[i]; + var data = constraint.data; + constraint.rotateMix = data.rotateMix; + constraint.translateMix = data.translateMix; + constraint.scaleMix = data.scaleMix; + constraint.shearMix = data.shearMix; + } + var pathConstraints = this.pathConstraints; + for (var i = 0, n = pathConstraints.length; i < n; i++) { + var constraint = pathConstraints[i]; + var data = constraint.data; + constraint.position = data.position; + constraint.spacing = data.spacing; + constraint.rotateMix = data.rotateMix; + constraint.translateMix = data.translateMix; + } + }; + Skeleton.prototype.setSlotsToSetupPose = function () { + var slots = this.slots; + core.Utils.arrayCopy(slots, 0, this.drawOrder, 0, slots.length); + for (var i = 0, n = slots.length; i < n; i++) slots[i].setToSetupPose(); + }; + Skeleton.prototype.getRootBone = function () { + if (this.bones.length == 0) return null; + return this.bones[0]; + }; + Skeleton.prototype.findBone = function (boneName) { + if (boneName == null) throw new Error('boneName cannot be null.'); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (bone.data.name == boneName) return bone; + } + return null; + }; + Skeleton.prototype.findBoneIndex = function (boneName) { + if (boneName == null) throw new Error('boneName cannot be null.'); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) if (bones[i].data.name == boneName) return i; + return -1; + }; + Skeleton.prototype.findSlot = function (slotName) { + if (slotName == null) throw new Error('slotName cannot be null.'); + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + if (slot.data.name == slotName) return slot; + } + return null; + }; + Skeleton.prototype.findSlotIndex = function (slotName) { + if (slotName == null) throw new Error('slotName cannot be null.'); + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) if (slots[i].data.name == slotName) return i; + return -1; + }; + Skeleton.prototype.setSkinByName = function (skinName) { + var skin = this.data.findSkin(skinName); + if (skin == null) throw new Error('Skin not found: ' + skinName); + this.setSkin(skin); + }; + Skeleton.prototype.setSkin = function (newSkin) { + if (newSkin == this.skin) return; + if (newSkin != null) { + if (this.skin != null) newSkin.attachAll(this, this.skin); + else { + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + var name_1 = slot.data.attachmentName; + if (name_1 != null) { + var attachment = newSkin.getAttachment(i, name_1); + if (attachment != null) slot.setAttachment(attachment); + } + } + } + } + this.skin = newSkin; + this.updateCache(); + }; + Skeleton.prototype.getAttachmentByName = function (slotName, attachmentName) { + return this.getAttachment(this.data.findSlotIndex(slotName), attachmentName); + }; + Skeleton.prototype.getAttachment = function (slotIndex, attachmentName) { + if (attachmentName == null) throw new Error('attachmentName cannot be null.'); + if (this.skin != null) { + var attachment = this.skin.getAttachment(slotIndex, attachmentName); + if (attachment != null) return attachment; + } + if (this.data.defaultSkin != null) return this.data.defaultSkin.getAttachment(slotIndex, attachmentName); + return null; + }; + Skeleton.prototype.setAttachment = function (slotName, attachmentName) { + if (slotName == null) throw new Error('slotName cannot be null.'); + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + if (slot.data.name == slotName) { + var attachment = null; + if (attachmentName != null) { + attachment = this.getAttachment(i, attachmentName); + if (attachment == null) + throw new Error('Attachment not found: ' + attachmentName + ', for slot: ' + slotName); + } + slot.setAttachment(attachment); + return; + } + } + throw new Error('Slot not found: ' + slotName); + }; + Skeleton.prototype.findIkConstraint = function (constraintName) { + if (constraintName == null) throw new Error('constraintName cannot be null.'); + var ikConstraints = this.ikConstraints; + for (var i = 0, n = ikConstraints.length; i < n; i++) { + var ikConstraint = ikConstraints[i]; + if (ikConstraint.data.name == constraintName) return ikConstraint; + } + return null; + }; + Skeleton.prototype.findTransformConstraint = function (constraintName) { + if (constraintName == null) throw new Error('constraintName cannot be null.'); + var transformConstraints = this.transformConstraints; + for (var i = 0, n = transformConstraints.length; i < n; i++) { + var constraint = transformConstraints[i]; + if (constraint.data.name == constraintName) return constraint; + } + return null; + }; + Skeleton.prototype.findPathConstraint = function (constraintName) { + if (constraintName == null) throw new Error('constraintName cannot be null.'); + var pathConstraints = this.pathConstraints; + for (var i = 0, n = pathConstraints.length; i < n; i++) { + var constraint = pathConstraints[i]; + if (constraint.data.name == constraintName) return constraint; + } + return null; + }; + Skeleton.prototype.getBounds = function (offset, size, temp) { + if (temp === void 0) { + temp = new Array(2); + } + if (offset == null) throw new Error('offset cannot be null.'); + if (size == null) throw new Error('size cannot be null.'); + var drawOrder = this.drawOrder; + var minX = Number.POSITIVE_INFINITY, + minY = Number.POSITIVE_INFINITY, + maxX = Number.NEGATIVE_INFINITY, + maxY = Number.NEGATIVE_INFINITY; + for (var i = 0, n = drawOrder.length; i < n; i++) { + var slot = drawOrder[i]; + if (!slot.bone.active) continue; + var verticesLength = 0; + var vertices = null; + var attachment = slot.getAttachment(); + if (attachment instanceof core.RegionAttachment) { + verticesLength = 8; + vertices = core.Utils.setArraySize(temp, verticesLength, 0); + attachment.computeWorldVertices(slot.bone, vertices, 0, 2); + } else if (attachment instanceof core.MeshAttachment) { + var mesh = attachment; + verticesLength = mesh.worldVerticesLength; + vertices = core.Utils.setArraySize(temp, verticesLength, 0); + mesh.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2); + } + if (vertices != null) { + for (var ii = 0, nn = vertices.length; ii < nn; ii += 2) { + var x = vertices[ii], + y = vertices[ii + 1]; + minX = Math.min(minX, x); + minY = Math.min(minY, y); + maxX = Math.max(maxX, x); + maxY = Math.max(maxY, y); + } + } + } + offset.set(minX, minY); + size.set(maxX - minX, maxY - minY); + }; + Skeleton.prototype.update = function (delta) { + this.time += delta; + }; + Object.defineProperty(Skeleton.prototype, 'flipX', { + get: function () { + return this.scaleX == -1; + }, + set: function (value) { + if (!Skeleton.deprecatedWarning1) { + Skeleton.deprecatedWarning1 = true; + console.warn('Spine Deprecation Warning: `Skeleton.flipX/flipY` was deprecated, please use scaleX/scaleY'); + } + this.scaleX = value ? 1.0 : -1.0; + }, + enumerable: false, + configurable: true, + }); + Object.defineProperty(Skeleton.prototype, 'flipY', { + get: function () { + return this.scaleY == -1; + }, + set: function (value) { + if (!Skeleton.deprecatedWarning1) { + Skeleton.deprecatedWarning1 = true; + console.warn('Spine Deprecation Warning: `Skeleton.flipX/flipY` was deprecated, please use scaleX/scaleY'); + } + this.scaleY = value ? 1.0 : -1.0; + }, + enumerable: false, + configurable: true, + }); + Skeleton.deprecatedWarning1 = false; + return Skeleton; + })(); + core.Skeleton = Skeleton; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var SkeletonBinary = (function () { + function SkeletonBinary(attachmentLoader) { + this.scale = 1; + this.linkedMeshes = new Array(); + this.attachmentLoader = attachmentLoader; + } + SkeletonBinary.prototype.readSkeletonData = function (binary) { + var scale = this.scale; + var skeletonData = new core.SkeletonData(); + skeletonData.name = ''; + var input = new BinaryInput(binary); + skeletonData.hash = input.readString(); + skeletonData.version = input.readString(); + if (skeletonData.version === '3.8.75') { + var error = 'Unsupported skeleton data, 3.8.75 is deprecated, please export with a newer version of Spine.'; + console.error(error); + } + skeletonData.x = input.readFloat(); + skeletonData.y = input.readFloat(); + skeletonData.width = input.readFloat(); + skeletonData.height = input.readFloat(); + var nonessential = input.readBoolean(); + if (nonessential) { + skeletonData.fps = input.readFloat(); + skeletonData.imagesPath = input.readString(); + skeletonData.audioPath = input.readString(); + } + var n = 0; + n = input.readInt(true); + for (var i = 0; i < n; i++) input.strings.push(input.readString()); + n = input.readInt(true); + for (var i = 0; i < n; i++) { + var name_2 = input.readString(); + var parent_2 = i == 0 ? null : skeletonData.bones[input.readInt(true)]; + var data = new core.BoneData(i, name_2, parent_2); + data.rotation = input.readFloat(); + data.x = input.readFloat() * scale; + data.y = input.readFloat() * scale; + data.scaleX = input.readFloat(); + data.scaleY = input.readFloat(); + data.shearX = input.readFloat(); + data.shearY = input.readFloat(); + data.length = input.readFloat() * scale; + data.transformMode = SkeletonBinary.TransformModeValues[input.readInt(true)]; + data.skinRequired = input.readBoolean(); + if (nonessential) core.Color.rgba8888ToColor(data.color, input.readInt32()); + skeletonData.bones.push(data); + } + n = input.readInt(true); + for (var i = 0; i < n; i++) { + var slotName = input.readString(); + var boneData = skeletonData.bones[input.readInt(true)]; + var data = new core.SlotData(i, slotName, boneData); + core.Color.rgba8888ToColor(data.color, input.readInt32()); + var darkColor = input.readInt32(); + if (darkColor != -1) core.Color.rgb888ToColor((data.darkColor = new core.Color()), darkColor); + data.attachmentName = input.readStringRef(); + data.blendMode = SkeletonBinary.BlendModeValues[input.readInt(true)]; + skeletonData.slots.push(data); + } + n = input.readInt(true); + for (var i = 0, nn = void 0; i < n; i++) { + var data = new core.IkConstraintData(input.readString()); + data.order = input.readInt(true); + data.skinRequired = input.readBoolean(); + nn = input.readInt(true); + for (var ii = 0; ii < nn; ii++) data.bones.push(skeletonData.bones[input.readInt(true)]); + data.target = skeletonData.bones[input.readInt(true)]; + data.mix = input.readFloat(); + data.softness = input.readFloat() * scale; + data.bendDirection = input.readByte(); + data.compress = input.readBoolean(); + data.stretch = input.readBoolean(); + data.uniform = input.readBoolean(); + skeletonData.ikConstraints.push(data); + } + n = input.readInt(true); + for (var i = 0, nn = void 0; i < n; i++) { + var data = new core.TransformConstraintData(input.readString()); + data.order = input.readInt(true); + data.skinRequired = input.readBoolean(); + nn = input.readInt(true); + for (var ii = 0; ii < nn; ii++) data.bones.push(skeletonData.bones[input.readInt(true)]); + data.target = skeletonData.bones[input.readInt(true)]; + data.local = input.readBoolean(); + data.relative = input.readBoolean(); + data.offsetRotation = input.readFloat(); + data.offsetX = input.readFloat() * scale; + data.offsetY = input.readFloat() * scale; + data.offsetScaleX = input.readFloat(); + data.offsetScaleY = input.readFloat(); + data.offsetShearY = input.readFloat(); + data.rotateMix = input.readFloat(); + data.translateMix = input.readFloat(); + data.scaleMix = input.readFloat(); + data.shearMix = input.readFloat(); + skeletonData.transformConstraints.push(data); + } + n = input.readInt(true); + for (var i = 0, nn = void 0; i < n; i++) { + var data = new core.PathConstraintData(input.readString()); + data.order = input.readInt(true); + data.skinRequired = input.readBoolean(); + nn = input.readInt(true); + for (var ii = 0; ii < nn; ii++) data.bones.push(skeletonData.bones[input.readInt(true)]); + data.target = skeletonData.slots[input.readInt(true)]; + data.positionMode = SkeletonBinary.PositionModeValues[input.readInt(true)]; + data.spacingMode = SkeletonBinary.SpacingModeValues[input.readInt(true)]; + data.rotateMode = SkeletonBinary.RotateModeValues[input.readInt(true)]; + data.offsetRotation = input.readFloat(); + data.position = input.readFloat(); + if (data.positionMode == core.PositionMode.Fixed) data.position *= scale; + data.spacing = input.readFloat(); + if (data.spacingMode == core.SpacingMode.Length || data.spacingMode == core.SpacingMode.Fixed) + data.spacing *= scale; + data.rotateMix = input.readFloat(); + data.translateMix = input.readFloat(); + skeletonData.pathConstraints.push(data); + } + var defaultSkin = this.readSkin(input, skeletonData, true, nonessential); + if (defaultSkin != null) { + skeletonData.defaultSkin = defaultSkin; + skeletonData.skins.push(defaultSkin); + } + { + var i = skeletonData.skins.length; + core.Utils.setArraySize(skeletonData.skins, (n = i + input.readInt(true))); + for (; i < n; i++) skeletonData.skins[i] = this.readSkin(input, skeletonData, false, nonessential); + } + n = this.linkedMeshes.length; + for (var i = 0; i < n; i++) { + var linkedMesh = this.linkedMeshes[i]; + var skin = linkedMesh.skin == null ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin); + if (skin == null) throw new Error('Skin not found: ' + linkedMesh.skin); + var parent_3 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent); + if (parent_3 == null) throw new Error('Parent mesh not found: ' + linkedMesh.parent); + linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent_3 : linkedMesh.mesh; + linkedMesh.mesh.setParentMesh(parent_3); + } + this.linkedMeshes.length = 0; + n = input.readInt(true); + for (var i = 0; i < n; i++) { + var data = new core.EventData(input.readStringRef()); + data.intValue = input.readInt(false); + data.floatValue = input.readFloat(); + data.stringValue = input.readString(); + data.audioPath = input.readString(); + if (data.audioPath != null) { + data.volume = input.readFloat(); + data.balance = input.readFloat(); + } + skeletonData.events.push(data); + } + n = input.readInt(true); + for (var i = 0; i < n; i++) + skeletonData.animations.push(this.readAnimation(input, input.readString(), skeletonData)); + return skeletonData; + }; + SkeletonBinary.prototype.readSkin = function (input, skeletonData, defaultSkin, nonessential) { + var skin = null; + var slotCount = 0; + if (defaultSkin) { + slotCount = input.readInt(true); + if (slotCount == 0) return null; + skin = new core.Skin('default'); + } else { + skin = new core.Skin(input.readStringRef()); + skin.bones.length = input.readInt(true); + for (var i = 0, n = skin.bones.length; i < n; i++) skin.bones[i] = skeletonData.bones[input.readInt(true)]; + for (var i = 0, n = input.readInt(true); i < n; i++) + skin.constraints.push(skeletonData.ikConstraints[input.readInt(true)]); + for (var i = 0, n = input.readInt(true); i < n; i++) + skin.constraints.push(skeletonData.transformConstraints[input.readInt(true)]); + for (var i = 0, n = input.readInt(true); i < n; i++) + skin.constraints.push(skeletonData.pathConstraints[input.readInt(true)]); + slotCount = input.readInt(true); + } + for (var i = 0; i < slotCount; i++) { + var slotIndex = input.readInt(true); + for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) { + var name_3 = input.readStringRef(); + var attachment = this.readAttachment(input, skeletonData, skin, slotIndex, name_3, nonessential); + if (attachment != null) skin.setAttachment(slotIndex, name_3, attachment); + } + } + return skin; + }; + SkeletonBinary.prototype.readAttachment = function ( + input, + skeletonData, + skin, + slotIndex, + attachmentName, + nonessential, + ) { + var scale = this.scale; + var name = input.readStringRef(); + if (name == null) name = attachmentName; + var typeIndex = input.readByte(); + var type = SkeletonBinary.AttachmentTypeValues[typeIndex]; + switch (type) { + case core.AttachmentType.Region: { + var path = input.readStringRef(); + var rotation = input.readFloat(); + var x = input.readFloat(); + var y = input.readFloat(); + var scaleX = input.readFloat(); + var scaleY = input.readFloat(); + var width = input.readFloat(); + var height = input.readFloat(); + var color = input.readInt32(); + if (path == null) path = name; + var region = this.attachmentLoader.newRegionAttachment(skin, name, path); + if (region == null) return null; + region.path = path; + region.x = x * scale; + region.y = y * scale; + region.scaleX = scaleX; + region.scaleY = scaleY; + region.rotation = rotation; + region.width = width * scale; + region.height = height * scale; + core.Color.rgba8888ToColor(region.color, color); + return region; + } + case core.AttachmentType.BoundingBox: { + var vertexCount = input.readInt(true); + var vertices = this.readVertices(input, vertexCount); + var color = nonessential ? input.readInt32() : 0; + var box = this.attachmentLoader.newBoundingBoxAttachment(skin, name); + if (box == null) return null; + box.worldVerticesLength = vertexCount << 1; + box.vertices = vertices.vertices; + box.bones = vertices.bones; + if (nonessential) core.Color.rgba8888ToColor(box.color, color); + return box; + } + case core.AttachmentType.Mesh: { + var path = input.readStringRef(); + var color = input.readInt32(); + var vertexCount = input.readInt(true); + var uvs = this.readFloatArray(input, vertexCount << 1, 1); + var triangles = this.readShortArray(input); + var vertices = this.readVertices(input, vertexCount); + var hullLength = input.readInt(true); + var edges = null; + var width = 0, + height = 0; + if (nonessential) { + edges = this.readShortArray(input); + width = input.readFloat(); + height = input.readFloat(); + } + if (path == null) path = name; + var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path); + if (mesh == null) return null; + mesh.path = path; + core.Color.rgba8888ToColor(mesh.color, color); + mesh.bones = vertices.bones; + mesh.vertices = vertices.vertices; + mesh.worldVerticesLength = vertexCount << 1; + mesh.triangles = triangles; + mesh.regionUVs = new Float32Array(uvs); + mesh.hullLength = hullLength << 1; + if (nonessential) { + mesh.edges = edges; + mesh.width = width * scale; + mesh.height = height * scale; + } + return mesh; + } + case core.AttachmentType.LinkedMesh: { + var path = input.readStringRef(); + var color = input.readInt32(); + var skinName = input.readStringRef(); + var parent_4 = input.readStringRef(); + var inheritDeform = input.readBoolean(); + var width = 0, + height = 0; + if (nonessential) { + width = input.readFloat(); + height = input.readFloat(); + } + if (path == null) path = name; + var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path); + if (mesh == null) return null; + mesh.path = path; + core.Color.rgba8888ToColor(mesh.color, color); + if (nonessential) { + mesh.width = width * scale; + mesh.height = height * scale; + } + this.linkedMeshes.push(new LinkedMesh(mesh, skinName, slotIndex, parent_4, inheritDeform)); + return mesh; + } + case core.AttachmentType.Path: { + var closed_1 = input.readBoolean(); + var constantSpeed = input.readBoolean(); + var vertexCount = input.readInt(true); + var vertices = this.readVertices(input, vertexCount); + var lengths = core.Utils.newArray(vertexCount / 3, 0); + for (var i = 0, n = lengths.length; i < n; i++) lengths[i] = input.readFloat() * scale; + var color = nonessential ? input.readInt32() : 0; + var path = this.attachmentLoader.newPathAttachment(skin, name); + if (path == null) return null; + path.closed = closed_1; + path.constantSpeed = constantSpeed; + path.worldVerticesLength = vertexCount << 1; + path.vertices = vertices.vertices; + path.bones = vertices.bones; + path.lengths = lengths; + if (nonessential) core.Color.rgba8888ToColor(path.color, color); + return path; + } + case core.AttachmentType.Point: { + var rotation = input.readFloat(); + var x = input.readFloat(); + var y = input.readFloat(); + var color = nonessential ? input.readInt32() : 0; + var point = this.attachmentLoader.newPointAttachment(skin, name); + if (point == null) return null; + point.x = x * scale; + point.y = y * scale; + point.rotation = rotation; + if (nonessential) core.Color.rgba8888ToColor(point.color, color); + return point; + } + case core.AttachmentType.Clipping: { + var endSlotIndex = input.readInt(true); + var vertexCount = input.readInt(true); + var vertices = this.readVertices(input, vertexCount); + var color = nonessential ? input.readInt32() : 0; + var clip = this.attachmentLoader.newClippingAttachment(skin, name); + if (clip == null) return null; + clip.endSlot = skeletonData.slots[endSlotIndex]; + clip.worldVerticesLength = vertexCount << 1; + clip.vertices = vertices.vertices; + clip.bones = vertices.bones; + if (nonessential) core.Color.rgba8888ToColor(clip.color, color); + return clip; + } + } + return null; + }; + SkeletonBinary.prototype.readVertices = function (input, vertexCount) { + var verticesLength = vertexCount << 1; + var vertices = new Vertices(); + var scale = this.scale; + if (!input.readBoolean()) { + vertices.vertices = this.readFloatArray(input, verticesLength, scale); + return vertices; + } + var weights = new Array(); + var bonesArray = new Array(); + for (var i = 0; i < vertexCount; i++) { + var boneCount = input.readInt(true); + bonesArray.push(boneCount); + for (var ii = 0; ii < boneCount; ii++) { + bonesArray.push(input.readInt(true)); + weights.push(input.readFloat() * scale); + weights.push(input.readFloat() * scale); + weights.push(input.readFloat()); + } + } + vertices.vertices = core.Utils.toFloatArray(weights); + vertices.bones = bonesArray; + return vertices; + }; + SkeletonBinary.prototype.readFloatArray = function (input, n, scale) { + var array = new Array(n); + if (scale == 1) { + for (var i = 0; i < n; i++) array[i] = input.readFloat(); + } else { + for (var i = 0; i < n; i++) array[i] = input.readFloat() * scale; + } + return array; + }; + SkeletonBinary.prototype.readShortArray = function (input) { + var n = input.readInt(true); + var array = new Array(n); + for (var i = 0; i < n; i++) array[i] = input.readShort(); + return array; + }; + SkeletonBinary.prototype.readAnimation = function (input, name, skeletonData) { + var timelines = new Array(); + var scale = this.scale; + var duration = 0; + var tempColor1 = new core.Color(); + var tempColor2 = new core.Color(); + for (var i = 0, n = input.readInt(true); i < n; i++) { + var slotIndex = input.readInt(true); + for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) { + var timelineType = input.readByte(); + var frameCount = input.readInt(true); + switch (timelineType) { + case SkeletonBinary.SLOT_ATTACHMENT: { + var timeline = new core.AttachmentTimeline(frameCount); + timeline.slotIndex = slotIndex; + for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) + timeline.setFrame(frameIndex, input.readFloat(), input.readStringRef()); + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[frameCount - 1]); + break; + } + case SkeletonBinary.SLOT_COLOR: { + var timeline = new core.ColorTimeline(frameCount); + timeline.slotIndex = slotIndex; + for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) { + var time = input.readFloat(); + core.Color.rgba8888ToColor(tempColor1, input.readInt32()); + timeline.setFrame(frameIndex, time, tempColor1.r, tempColor1.g, tempColor1.b, tempColor1.a); + if (frameIndex < frameCount - 1) this.readCurve(input, frameIndex, timeline); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(frameCount - 1) * core.ColorTimeline.ENTRIES]); + break; + } + case SkeletonBinary.SLOT_TWO_COLOR: { + var timeline = new core.TwoColorTimeline(frameCount); + timeline.slotIndex = slotIndex; + for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) { + var time = input.readFloat(); + core.Color.rgba8888ToColor(tempColor1, input.readInt32()); + core.Color.rgb888ToColor(tempColor2, input.readInt32()); + timeline.setFrame( + frameIndex, + time, + tempColor1.r, + tempColor1.g, + tempColor1.b, + tempColor1.a, + tempColor2.r, + tempColor2.g, + tempColor2.b, + ); + if (frameIndex < frameCount - 1) this.readCurve(input, frameIndex, timeline); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(frameCount - 1) * core.TwoColorTimeline.ENTRIES]); + break; + } + } + } + } + for (var i = 0, n = input.readInt(true); i < n; i++) { + var boneIndex = input.readInt(true); + for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) { + var timelineType = input.readByte(); + var frameCount = input.readInt(true); + switch (timelineType) { + case SkeletonBinary.BONE_ROTATE: { + var timeline = new core.RotateTimeline(frameCount); + timeline.boneIndex = boneIndex; + for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) { + timeline.setFrame(frameIndex, input.readFloat(), input.readFloat()); + if (frameIndex < frameCount - 1) this.readCurve(input, frameIndex, timeline); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(frameCount - 1) * core.RotateTimeline.ENTRIES]); + break; + } + case SkeletonBinary.BONE_TRANSLATE: + case SkeletonBinary.BONE_SCALE: + case SkeletonBinary.BONE_SHEAR: { + var timeline = void 0; + var timelineScale = 1; + if (timelineType == SkeletonBinary.BONE_SCALE) timeline = new core.ScaleTimeline(frameCount); + else if (timelineType == SkeletonBinary.BONE_SHEAR) timeline = new core.ShearTimeline(frameCount); + else { + timeline = new core.TranslateTimeline(frameCount); + timelineScale = scale; + } + timeline.boneIndex = boneIndex; + for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) { + timeline.setFrame( + frameIndex, + input.readFloat(), + input.readFloat() * timelineScale, + input.readFloat() * timelineScale, + ); + if (frameIndex < frameCount - 1) this.readCurve(input, frameIndex, timeline); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(frameCount - 1) * core.TranslateTimeline.ENTRIES]); + break; + } + } + } + } + for (var i = 0, n = input.readInt(true); i < n; i++) { + var index = input.readInt(true); + var frameCount = input.readInt(true); + var timeline = new core.IkConstraintTimeline(frameCount); + timeline.ikConstraintIndex = index; + for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) { + timeline.setFrame( + frameIndex, + input.readFloat(), + input.readFloat(), + input.readFloat() * scale, + input.readByte(), + input.readBoolean(), + input.readBoolean(), + ); + if (frameIndex < frameCount - 1) this.readCurve(input, frameIndex, timeline); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(frameCount - 1) * core.IkConstraintTimeline.ENTRIES]); + } + for (var i = 0, n = input.readInt(true); i < n; i++) { + var index = input.readInt(true); + var frameCount = input.readInt(true); + var timeline = new core.TransformConstraintTimeline(frameCount); + timeline.transformConstraintIndex = index; + for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) { + timeline.setFrame( + frameIndex, + input.readFloat(), + input.readFloat(), + input.readFloat(), + input.readFloat(), + input.readFloat(), + ); + if (frameIndex < frameCount - 1) this.readCurve(input, frameIndex, timeline); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(frameCount - 1) * core.TransformConstraintTimeline.ENTRIES]); + } + for (var i = 0, n = input.readInt(true); i < n; i++) { + var index = input.readInt(true); + var data = skeletonData.pathConstraints[index]; + for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) { + var timelineType = input.readByte(); + var frameCount = input.readInt(true); + switch (timelineType) { + case SkeletonBinary.PATH_POSITION: + case SkeletonBinary.PATH_SPACING: { + var timeline = void 0; + var timelineScale = 1; + if (timelineType == SkeletonBinary.PATH_SPACING) { + timeline = new core.PathConstraintSpacingTimeline(frameCount); + if (data.spacingMode == core.SpacingMode.Length || data.spacingMode == core.SpacingMode.Fixed) + timelineScale = scale; + } else { + timeline = new core.PathConstraintPositionTimeline(frameCount); + if (data.positionMode == core.PositionMode.Fixed) timelineScale = scale; + } + timeline.pathConstraintIndex = index; + for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) { + timeline.setFrame(frameIndex, input.readFloat(), input.readFloat() * timelineScale); + if (frameIndex < frameCount - 1) this.readCurve(input, frameIndex, timeline); + } + timelines.push(timeline); + duration = Math.max( + duration, + timeline.frames[(frameCount - 1) * core.PathConstraintPositionTimeline.ENTRIES], + ); + break; + } + case SkeletonBinary.PATH_MIX: { + var timeline = new core.PathConstraintMixTimeline(frameCount); + timeline.pathConstraintIndex = index; + for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) { + timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readFloat()); + if (frameIndex < frameCount - 1) this.readCurve(input, frameIndex, timeline); + } + timelines.push(timeline); + duration = Math.max( + duration, + timeline.frames[(frameCount - 1) * core.PathConstraintMixTimeline.ENTRIES], + ); + break; + } + } + } + } + for (var i = 0, n = input.readInt(true); i < n; i++) { + var skin = skeletonData.skins[input.readInt(true)]; + for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) { + var slotIndex = input.readInt(true); + for (var iii = 0, nnn = input.readInt(true); iii < nnn; iii++) { + var attachment = skin.getAttachment(slotIndex, input.readStringRef()); + var weighted = attachment.bones != null; + var vertices = attachment.vertices; + var deformLength = weighted ? (vertices.length / 3) * 2 : vertices.length; + var frameCount = input.readInt(true); + var timeline = new core.DeformTimeline(frameCount); + timeline.slotIndex = slotIndex; + timeline.attachment = attachment; + for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) { + var time = input.readFloat(); + var deform = void 0; + var end = input.readInt(true); + if (end == 0) deform = weighted ? core.Utils.newFloatArray(deformLength) : vertices; + else { + deform = core.Utils.newFloatArray(deformLength); + var start = input.readInt(true); + end += start; + if (scale == 1) { + for (var v = start; v < end; v++) deform[v] = input.readFloat(); + } else { + for (var v = start; v < end; v++) deform[v] = input.readFloat() * scale; + } + if (!weighted) { + for (var v = 0, vn = deform.length; v < vn; v++) deform[v] += vertices[v]; + } + } + timeline.setFrame(frameIndex, time, deform); + if (frameIndex < frameCount - 1) this.readCurve(input, frameIndex, timeline); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[frameCount - 1]); + } + } + } + var drawOrderCount = input.readInt(true); + if (drawOrderCount > 0) { + var timeline = new core.DrawOrderTimeline(drawOrderCount); + var slotCount = skeletonData.slots.length; + for (var i = 0; i < drawOrderCount; i++) { + var time = input.readFloat(); + var offsetCount = input.readInt(true); + var drawOrder = core.Utils.newArray(slotCount, 0); + for (var ii = slotCount - 1; ii >= 0; ii--) drawOrder[ii] = -1; + var unchanged = core.Utils.newArray(slotCount - offsetCount, 0); + var originalIndex = 0, + unchangedIndex = 0; + for (var ii = 0; ii < offsetCount; ii++) { + var slotIndex = input.readInt(true); + while (originalIndex != slotIndex) unchanged[unchangedIndex++] = originalIndex++; + drawOrder[originalIndex + input.readInt(true)] = originalIndex++; + } + while (originalIndex < slotCount) unchanged[unchangedIndex++] = originalIndex++; + for (var ii = slotCount - 1; ii >= 0; ii--) + if (drawOrder[ii] == -1) drawOrder[ii] = unchanged[--unchangedIndex]; + timeline.setFrame(i, time, drawOrder); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[drawOrderCount - 1]); + } + var eventCount = input.readInt(true); + if (eventCount > 0) { + var timeline = new core.EventTimeline(eventCount); + for (var i = 0; i < eventCount; i++) { + var time = input.readFloat(); + var eventData = skeletonData.events[input.readInt(true)]; + var event_4 = new core.Event(time, eventData); + event_4.intValue = input.readInt(false); + event_4.floatValue = input.readFloat(); + event_4.stringValue = input.readBoolean() ? input.readString() : eventData.stringValue; + if (event_4.data.audioPath != null) { + event_4.volume = input.readFloat(); + event_4.balance = input.readFloat(); + } + timeline.setFrame(i, event_4); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[eventCount - 1]); + } + return new core.Animation(name, timelines, duration); + }; + SkeletonBinary.prototype.readCurve = function (input, frameIndex, timeline) { + switch (input.readByte()) { + case SkeletonBinary.CURVE_STEPPED: + timeline.setStepped(frameIndex); + break; + case SkeletonBinary.CURVE_BEZIER: + this.setCurve( + timeline, + frameIndex, + input.readFloat(), + input.readFloat(), + input.readFloat(), + input.readFloat(), + ); + break; + } + }; + SkeletonBinary.prototype.setCurve = function (timeline, frameIndex, cx1, cy1, cx2, cy2) { + timeline.setCurve(frameIndex, cx1, cy1, cx2, cy2); + }; + SkeletonBinary.AttachmentTypeValues = [0, 1, 2, 3, 4, 5, 6]; + SkeletonBinary.TransformModeValues = [ + core.TransformMode.Normal, + core.TransformMode.OnlyTranslation, + core.TransformMode.NoRotationOrReflection, + core.TransformMode.NoScale, + core.TransformMode.NoScaleOrReflection, + ]; + SkeletonBinary.PositionModeValues = [core.PositionMode.Fixed, core.PositionMode.Percent]; + SkeletonBinary.SpacingModeValues = [core.SpacingMode.Length, core.SpacingMode.Fixed, core.SpacingMode.Percent]; + SkeletonBinary.RotateModeValues = [core.RotateMode.Tangent, core.RotateMode.Chain, core.RotateMode.ChainScale]; + SkeletonBinary.BlendModeValues = [ + core.BlendMode.Normal, + core.BlendMode.Additive, + core.BlendMode.Multiply, + core.BlendMode.Screen, + ]; + SkeletonBinary.BONE_ROTATE = 0; + SkeletonBinary.BONE_TRANSLATE = 1; + SkeletonBinary.BONE_SCALE = 2; + SkeletonBinary.BONE_SHEAR = 3; + SkeletonBinary.SLOT_ATTACHMENT = 0; + SkeletonBinary.SLOT_COLOR = 1; + SkeletonBinary.SLOT_TWO_COLOR = 2; + SkeletonBinary.PATH_POSITION = 0; + SkeletonBinary.PATH_SPACING = 1; + SkeletonBinary.PATH_MIX = 2; + SkeletonBinary.CURVE_LINEAR = 0; + SkeletonBinary.CURVE_STEPPED = 1; + SkeletonBinary.CURVE_BEZIER = 2; + return SkeletonBinary; + })(); + core.SkeletonBinary = SkeletonBinary; + var BinaryInput = (function () { + function BinaryInput(data, strings, index, buffer) { + if (strings === void 0) { + strings = new Array(); + } + if (index === void 0) { + index = 0; + } + if (buffer === void 0) { + buffer = new DataView(data.buffer); + } + this.strings = strings; + this.index = index; + this.buffer = buffer; + } + BinaryInput.prototype.readByte = function () { + return this.buffer.getInt8(this.index++); + }; + BinaryInput.prototype.readShort = function () { + var value = this.buffer.getInt16(this.index); + this.index += 2; + return value; + }; + BinaryInput.prototype.readInt32 = function () { + var value = this.buffer.getInt32(this.index); + this.index += 4; + return value; + }; + BinaryInput.prototype.readInt = function (optimizePositive) { + var b = this.readByte(); + var result = b & 0x7f; + if ((b & 0x80) != 0) { + b = this.readByte(); + result |= (b & 0x7f) << 7; + if ((b & 0x80) != 0) { + b = this.readByte(); + result |= (b & 0x7f) << 14; + if ((b & 0x80) != 0) { + b = this.readByte(); + result |= (b & 0x7f) << 21; + if ((b & 0x80) != 0) { + b = this.readByte(); + result |= (b & 0x7f) << 28; + } + } + } + } + return optimizePositive ? result : (result >>> 1) ^ -(result & 1); + }; + BinaryInput.prototype.readStringRef = function () { + var index = this.readInt(true); + return index == 0 ? null : this.strings[index - 1]; + }; + BinaryInput.prototype.readString = function () { + var byteCount = this.readInt(true); + switch (byteCount) { + case 0: + return null; + case 1: + return ''; + } + byteCount--; + var chars = ''; + var charCount = 0; + for (var i = 0; i < byteCount; ) { + var b = this.readByte(); + switch (b >> 4) { + case 12: + case 13: + chars += String.fromCharCode(((b & 0x1f) << 6) | (this.readByte() & 0x3f)); + i += 2; + break; + case 14: + chars += String.fromCharCode( + ((b & 0x0f) << 12) | ((this.readByte() & 0x3f) << 6) | (this.readByte() & 0x3f), + ); + i += 3; + break; + default: + chars += String.fromCharCode(b); + i++; + } + } + return chars; + }; + BinaryInput.prototype.readFloat = function () { + var value = this.buffer.getFloat32(this.index); + this.index += 4; + return value; + }; + BinaryInput.prototype.readBoolean = function () { + return this.readByte() != 0; + }; + return BinaryInput; + })(); + var LinkedMesh = (function () { + function LinkedMesh(mesh, skin, slotIndex, parent, inheritDeform) { + this.mesh = mesh; + this.skin = skin; + this.slotIndex = slotIndex; + this.parent = parent; + this.inheritDeform = inheritDeform; + } + return LinkedMesh; + })(); + var Vertices = (function () { + function Vertices(bones, vertices) { + if (bones === void 0) { + bones = null; + } + if (vertices === void 0) { + vertices = null; + } + this.bones = bones; + this.vertices = vertices; + } + return Vertices; + })(); + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var SkeletonBounds = (function () { + function SkeletonBounds() { + this.minX = 0; + this.minY = 0; + this.maxX = 0; + this.maxY = 0; + this.boundingBoxes = new Array(); + this.polygons = new Array(); + this.polygonPool = new core.Pool(function () { + return core.Utils.newFloatArray(16); + }); + } + SkeletonBounds.prototype.update = function (skeleton, updateAabb) { + if (skeleton == null) throw new Error('skeleton cannot be null.'); + var boundingBoxes = this.boundingBoxes; + var polygons = this.polygons; + var polygonPool = this.polygonPool; + var slots = skeleton.slots; + var slotCount = slots.length; + boundingBoxes.length = 0; + polygonPool.freeAll(polygons); + polygons.length = 0; + for (var i = 0; i < slotCount; i++) { + var slot = slots[i]; + if (!slot.bone.active) continue; + var attachment = slot.getAttachment(); + if (attachment instanceof core.BoundingBoxAttachment) { + var boundingBox = attachment; + boundingBoxes.push(boundingBox); + var polygon = polygonPool.obtain(); + if (polygon.length != boundingBox.worldVerticesLength) { + polygon = core.Utils.newFloatArray(boundingBox.worldVerticesLength); + } + polygons.push(polygon); + boundingBox.computeWorldVertices(slot, 0, boundingBox.worldVerticesLength, polygon, 0, 2); + } + } + if (updateAabb) { + this.aabbCompute(); + } else { + this.minX = Number.POSITIVE_INFINITY; + this.minY = Number.POSITIVE_INFINITY; + this.maxX = Number.NEGATIVE_INFINITY; + this.maxY = Number.NEGATIVE_INFINITY; + } + }; + SkeletonBounds.prototype.aabbCompute = function () { + var minX = Number.POSITIVE_INFINITY, + minY = Number.POSITIVE_INFINITY, + maxX = Number.NEGATIVE_INFINITY, + maxY = Number.NEGATIVE_INFINITY; + var polygons = this.polygons; + for (var i = 0, n = polygons.length; i < n; i++) { + var polygon = polygons[i]; + var vertices = polygon; + for (var ii = 0, nn = polygon.length; ii < nn; ii += 2) { + var x = vertices[ii]; + var y = vertices[ii + 1]; + minX = Math.min(minX, x); + minY = Math.min(minY, y); + maxX = Math.max(maxX, x); + maxY = Math.max(maxY, y); + } + } + this.minX = minX; + this.minY = minY; + this.maxX = maxX; + this.maxY = maxY; + }; + SkeletonBounds.prototype.aabbContainsPoint = function (x, y) { + return x >= this.minX && x <= this.maxX && y >= this.minY && y <= this.maxY; + }; + SkeletonBounds.prototype.aabbIntersectsSegment = function (x1, y1, x2, y2) { + var minX = this.minX; + var minY = this.minY; + var maxX = this.maxX; + var maxY = this.maxY; + if ( + (x1 <= minX && x2 <= minX) || + (y1 <= minY && y2 <= minY) || + (x1 >= maxX && x2 >= maxX) || + (y1 >= maxY && y2 >= maxY) + ) + return false; + var m = (y2 - y1) / (x2 - x1); + var y = m * (minX - x1) + y1; + if (y > minY && y < maxY) return true; + y = m * (maxX - x1) + y1; + if (y > minY && y < maxY) return true; + var x = (minY - y1) / m + x1; + if (x > minX && x < maxX) return true; + x = (maxY - y1) / m + x1; + if (x > minX && x < maxX) return true; + return false; + }; + SkeletonBounds.prototype.aabbIntersectsSkeleton = function (bounds) { + return this.minX < bounds.maxX && this.maxX > bounds.minX && this.minY < bounds.maxY && this.maxY > bounds.minY; + }; + SkeletonBounds.prototype.containsPoint = function (x, y) { + var polygons = this.polygons; + for (var i = 0, n = polygons.length; i < n; i++) + if (this.containsPointPolygon(polygons[i], x, y)) return this.boundingBoxes[i]; + return null; + }; + SkeletonBounds.prototype.containsPointPolygon = function (polygon, x, y) { + var vertices = polygon; + var nn = polygon.length; + var prevIndex = nn - 2; + var inside = false; + for (var ii = 0; ii < nn; ii += 2) { + var vertexY = vertices[ii + 1]; + var prevY = vertices[prevIndex + 1]; + if ((vertexY < y && prevY >= y) || (prevY < y && vertexY >= y)) { + var vertexX = vertices[ii]; + if (vertexX + ((y - vertexY) / (prevY - vertexY)) * (vertices[prevIndex] - vertexX) < x) inside = !inside; + } + prevIndex = ii; + } + return inside; + }; + SkeletonBounds.prototype.intersectsSegment = function (x1, y1, x2, y2) { + var polygons = this.polygons; + for (var i = 0, n = polygons.length; i < n; i++) + if (this.intersectsSegmentPolygon(polygons[i], x1, y1, x2, y2)) return this.boundingBoxes[i]; + return null; + }; + SkeletonBounds.prototype.intersectsSegmentPolygon = function (polygon, x1, y1, x2, y2) { + var vertices = polygon; + var nn = polygon.length; + var width12 = x1 - x2, + height12 = y1 - y2; + var det1 = x1 * y2 - y1 * x2; + var x3 = vertices[nn - 2], + y3 = vertices[nn - 1]; + for (var ii = 0; ii < nn; ii += 2) { + var x4 = vertices[ii], + y4 = vertices[ii + 1]; + var det2 = x3 * y4 - y3 * x4; + var width34 = x3 - x4, + height34 = y3 - y4; + var det3 = width12 * height34 - height12 * width34; + var x = (det1 * width34 - width12 * det2) / det3; + if (((x >= x3 && x <= x4) || (x >= x4 && x <= x3)) && ((x >= x1 && x <= x2) || (x >= x2 && x <= x1))) { + var y = (det1 * height34 - height12 * det2) / det3; + if (((y >= y3 && y <= y4) || (y >= y4 && y <= y3)) && ((y >= y1 && y <= y2) || (y >= y2 && y <= y1))) + return true; + } + x3 = x4; + y3 = y4; + } + return false; + }; + SkeletonBounds.prototype.getPolygon = function (boundingBox) { + if (boundingBox == null) throw new Error('boundingBox cannot be null.'); + var index = this.boundingBoxes.indexOf(boundingBox); + return index == -1 ? null : this.polygons[index]; + }; + SkeletonBounds.prototype.getWidth = function () { + return this.maxX - this.minX; + }; + SkeletonBounds.prototype.getHeight = function () { + return this.maxY - this.minY; + }; + return SkeletonBounds; + })(); + core.SkeletonBounds = SkeletonBounds; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var SkeletonClipping = (function () { + function SkeletonClipping() { + this.triangulator = new core.Triangulator(); + this.clippingPolygon = new Array(); + this.clipOutput = new Array(); + this.clippedVertices = new Array(); + this.clippedTriangles = new Array(); + this.scratch = new Array(); + } + SkeletonClipping.prototype.clipStart = function (slot, clip) { + if (this.clipAttachment != null) return 0; + this.clipAttachment = clip; + var n = clip.worldVerticesLength; + var vertices = core.Utils.setArraySize(this.clippingPolygon, n); + clip.computeWorldVertices(slot, 0, n, vertices, 0, 2); + var clippingPolygon = this.clippingPolygon; + SkeletonClipping.makeClockwise(clippingPolygon); + var clippingPolygons = (this.clippingPolygons = this.triangulator.decompose( + clippingPolygon, + this.triangulator.triangulate(clippingPolygon), + )); + for (var i = 0, n_2 = clippingPolygons.length; i < n_2; i++) { + var polygon = clippingPolygons[i]; + SkeletonClipping.makeClockwise(polygon); + polygon.push(polygon[0]); + polygon.push(polygon[1]); + } + return clippingPolygons.length; + }; + SkeletonClipping.prototype.clipEndWithSlot = function (slot) { + if (this.clipAttachment != null && this.clipAttachment.endSlot == slot.data) this.clipEnd(); + }; + SkeletonClipping.prototype.clipEnd = function () { + if (this.clipAttachment == null) return; + this.clipAttachment = null; + this.clippingPolygons = null; + this.clippedVertices.length = 0; + this.clippedTriangles.length = 0; + this.clippingPolygon.length = 0; + }; + SkeletonClipping.prototype.isClipping = function () { + return this.clipAttachment != null; + }; + SkeletonClipping.prototype.clipTriangles = function ( + vertices, + verticesLength, + triangles, + trianglesLength, + uvs, + light, + dark, + twoColor, + ) { + var clipOutput = this.clipOutput, + clippedVertices = this.clippedVertices; + var clippedTriangles = this.clippedTriangles; + var polygons = this.clippingPolygons; + var polygonsCount = this.clippingPolygons.length; + var vertexSize = twoColor ? 12 : 8; + var index = 0; + clippedVertices.length = 0; + clippedTriangles.length = 0; + outer: for (var i = 0; i < trianglesLength; i += 3) { + var vertexOffset = triangles[i] << 1; + var x1 = vertices[vertexOffset], + y1 = vertices[vertexOffset + 1]; + var u1 = uvs[vertexOffset], + v1 = uvs[vertexOffset + 1]; + vertexOffset = triangles[i + 1] << 1; + var x2 = vertices[vertexOffset], + y2 = vertices[vertexOffset + 1]; + var u2 = uvs[vertexOffset], + v2 = uvs[vertexOffset + 1]; + vertexOffset = triangles[i + 2] << 1; + var x3 = vertices[vertexOffset], + y3 = vertices[vertexOffset + 1]; + var u3 = uvs[vertexOffset], + v3 = uvs[vertexOffset + 1]; + for (var p = 0; p < polygonsCount; p++) { + var s = clippedVertices.length; + if (this.clip(x1, y1, x2, y2, x3, y3, polygons[p], clipOutput)) { + var clipOutputLength = clipOutput.length; + if (clipOutputLength == 0) continue; + var d0 = y2 - y3, + d1 = x3 - x2, + d2 = x1 - x3, + d4 = y3 - y1; + var d = 1 / (d0 * d2 + d1 * (y1 - y3)); + var clipOutputCount = clipOutputLength >> 1; + var clipOutputItems = this.clipOutput; + var clippedVerticesItems = core.Utils.setArraySize(clippedVertices, s + clipOutputCount * vertexSize); + for (var ii = 0; ii < clipOutputLength; ii += 2) { + var x = clipOutputItems[ii], + y = clipOutputItems[ii + 1]; + clippedVerticesItems[s] = x; + clippedVerticesItems[s + 1] = y; + clippedVerticesItems[s + 2] = light.r; + clippedVerticesItems[s + 3] = light.g; + clippedVerticesItems[s + 4] = light.b; + clippedVerticesItems[s + 5] = light.a; + var c0 = x - x3, + c1 = y - y3; + var a = (d0 * c0 + d1 * c1) * d; + var b = (d4 * c0 + d2 * c1) * d; + var c = 1 - a - b; + clippedVerticesItems[s + 6] = u1 * a + u2 * b + u3 * c; + clippedVerticesItems[s + 7] = v1 * a + v2 * b + v3 * c; + if (twoColor) { + clippedVerticesItems[s + 8] = dark.r; + clippedVerticesItems[s + 9] = dark.g; + clippedVerticesItems[s + 10] = dark.b; + clippedVerticesItems[s + 11] = dark.a; + } + s += vertexSize; + } + s = clippedTriangles.length; + var clippedTrianglesItems = core.Utils.setArraySize(clippedTriangles, s + 3 * (clipOutputCount - 2)); + clipOutputCount--; + for (var ii = 1; ii < clipOutputCount; ii++) { + clippedTrianglesItems[s] = index; + clippedTrianglesItems[s + 1] = index + ii; + clippedTrianglesItems[s + 2] = index + ii + 1; + s += 3; + } + index += clipOutputCount + 1; + } else { + var clippedVerticesItems = core.Utils.setArraySize(clippedVertices, s + 3 * vertexSize); + clippedVerticesItems[s] = x1; + clippedVerticesItems[s + 1] = y1; + clippedVerticesItems[s + 2] = light.r; + clippedVerticesItems[s + 3] = light.g; + clippedVerticesItems[s + 4] = light.b; + clippedVerticesItems[s + 5] = light.a; + if (!twoColor) { + clippedVerticesItems[s + 6] = u1; + clippedVerticesItems[s + 7] = v1; + clippedVerticesItems[s + 8] = x2; + clippedVerticesItems[s + 9] = y2; + clippedVerticesItems[s + 10] = light.r; + clippedVerticesItems[s + 11] = light.g; + clippedVerticesItems[s + 12] = light.b; + clippedVerticesItems[s + 13] = light.a; + clippedVerticesItems[s + 14] = u2; + clippedVerticesItems[s + 15] = v2; + clippedVerticesItems[s + 16] = x3; + clippedVerticesItems[s + 17] = y3; + clippedVerticesItems[s + 18] = light.r; + clippedVerticesItems[s + 19] = light.g; + clippedVerticesItems[s + 20] = light.b; + clippedVerticesItems[s + 21] = light.a; + clippedVerticesItems[s + 22] = u3; + clippedVerticesItems[s + 23] = v3; + } else { + clippedVerticesItems[s + 6] = u1; + clippedVerticesItems[s + 7] = v1; + clippedVerticesItems[s + 8] = dark.r; + clippedVerticesItems[s + 9] = dark.g; + clippedVerticesItems[s + 10] = dark.b; + clippedVerticesItems[s + 11] = dark.a; + clippedVerticesItems[s + 12] = x2; + clippedVerticesItems[s + 13] = y2; + clippedVerticesItems[s + 14] = light.r; + clippedVerticesItems[s + 15] = light.g; + clippedVerticesItems[s + 16] = light.b; + clippedVerticesItems[s + 17] = light.a; + clippedVerticesItems[s + 18] = u2; + clippedVerticesItems[s + 19] = v2; + clippedVerticesItems[s + 20] = dark.r; + clippedVerticesItems[s + 21] = dark.g; + clippedVerticesItems[s + 22] = dark.b; + clippedVerticesItems[s + 23] = dark.a; + clippedVerticesItems[s + 24] = x3; + clippedVerticesItems[s + 25] = y3; + clippedVerticesItems[s + 26] = light.r; + clippedVerticesItems[s + 27] = light.g; + clippedVerticesItems[s + 28] = light.b; + clippedVerticesItems[s + 29] = light.a; + clippedVerticesItems[s + 30] = u3; + clippedVerticesItems[s + 31] = v3; + clippedVerticesItems[s + 32] = dark.r; + clippedVerticesItems[s + 33] = dark.g; + clippedVerticesItems[s + 34] = dark.b; + clippedVerticesItems[s + 35] = dark.a; + } + s = clippedTriangles.length; + var clippedTrianglesItems = core.Utils.setArraySize(clippedTriangles, s + 3); + clippedTrianglesItems[s] = index; + clippedTrianglesItems[s + 1] = index + 1; + clippedTrianglesItems[s + 2] = index + 2; + index += 3; + continue outer; + } + } + } + }; + SkeletonClipping.prototype.clip = function (x1, y1, x2, y2, x3, y3, clippingArea, output) { + var originalOutput = output; + var clipped = false; + var input = null; + if (clippingArea.length % 4 >= 2) { + input = output; + output = this.scratch; + } else input = this.scratch; + input.length = 0; + input.push(x1); + input.push(y1); + input.push(x2); + input.push(y2); + input.push(x3); + input.push(y3); + input.push(x1); + input.push(y1); + output.length = 0; + var clippingVertices = clippingArea; + var clippingVerticesLast = clippingArea.length - 4; + for (var i = 0; ; i += 2) { + var edgeX = clippingVertices[i], + edgeY = clippingVertices[i + 1]; + var edgeX2 = clippingVertices[i + 2], + edgeY2 = clippingVertices[i + 3]; + var deltaX = edgeX - edgeX2, + deltaY = edgeY - edgeY2; + var inputVertices = input; + var inputVerticesLength = input.length - 2, + outputStart = output.length; + for (var ii = 0; ii < inputVerticesLength; ii += 2) { + var inputX = inputVertices[ii], + inputY = inputVertices[ii + 1]; + var inputX2 = inputVertices[ii + 2], + inputY2 = inputVertices[ii + 3]; + var side2 = deltaX * (inputY2 - edgeY2) - deltaY * (inputX2 - edgeX2) > 0; + if (deltaX * (inputY - edgeY2) - deltaY * (inputX - edgeX2) > 0) { + if (side2) { + output.push(inputX2); + output.push(inputY2); + continue; + } + var c0 = inputY2 - inputY, + c2 = inputX2 - inputX; + var ua = + (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / (c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY)); + output.push(edgeX + (edgeX2 - edgeX) * ua); + output.push(edgeY + (edgeY2 - edgeY) * ua); + } else if (side2) { + var c0 = inputY2 - inputY, + c2 = inputX2 - inputX; + var ua = + (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / (c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY)); + output.push(edgeX + (edgeX2 - edgeX) * ua); + output.push(edgeY + (edgeY2 - edgeY) * ua); + output.push(inputX2); + output.push(inputY2); + } + clipped = true; + } + if (outputStart == output.length) { + originalOutput.length = 0; + return true; + } + output.push(output[0]); + output.push(output[1]); + if (i == clippingVerticesLast) break; + var temp = output; + output = input; + output.length = 0; + input = temp; + } + if (originalOutput != output) { + originalOutput.length = 0; + for (var i = 0, n = output.length - 2; i < n; i++) originalOutput[i] = output[i]; + } else originalOutput.length = originalOutput.length - 2; + return clipped; + }; + SkeletonClipping.makeClockwise = function (polygon) { + var vertices = polygon; + var verticeslength = polygon.length; + var area = vertices[verticeslength - 2] * vertices[1] - vertices[0] * vertices[verticeslength - 1], + p1x = 0, + p1y = 0, + p2x = 0, + p2y = 0; + for (var i = 0, n = verticeslength - 3; i < n; i += 2) { + p1x = vertices[i]; + p1y = vertices[i + 1]; + p2x = vertices[i + 2]; + p2y = vertices[i + 3]; + area += p1x * p2y - p2x * p1y; + } + if (area < 0) return; + for (var i = 0, lastX = verticeslength - 2, n = verticeslength >> 1; i < n; i += 2) { + var x = vertices[i], + y = vertices[i + 1]; + var other = lastX - i; + vertices[i] = vertices[other]; + vertices[i + 1] = vertices[other + 1]; + vertices[other] = x; + vertices[other + 1] = y; + } + }; + return SkeletonClipping; + })(); + core.SkeletonClipping = SkeletonClipping; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var SkeletonData = (function () { + function SkeletonData() { + this.bones = new Array(); + this.slots = new Array(); + this.skins = new Array(); + this.events = new Array(); + this.animations = new Array(); + this.ikConstraints = new Array(); + this.transformConstraints = new Array(); + this.pathConstraints = new Array(); + this.fps = 0; + } + SkeletonData.prototype.findBone = function (boneName) { + if (boneName == null) throw new Error('boneName cannot be null.'); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (bone.name == boneName) return bone; + } + return null; + }; + SkeletonData.prototype.findBoneIndex = function (boneName) { + if (boneName == null) throw new Error('boneName cannot be null.'); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) if (bones[i].name == boneName) return i; + return -1; + }; + SkeletonData.prototype.findSlot = function (slotName) { + if (slotName == null) throw new Error('slotName cannot be null.'); + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + if (slot.name == slotName) return slot; + } + return null; + }; + SkeletonData.prototype.findSlotIndex = function (slotName) { + if (slotName == null) throw new Error('slotName cannot be null.'); + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) if (slots[i].name == slotName) return i; + return -1; + }; + SkeletonData.prototype.findSkin = function (skinName) { + if (skinName == null) throw new Error('skinName cannot be null.'); + var skins = this.skins; + for (var i = 0, n = skins.length; i < n; i++) { + var skin = skins[i]; + if (skin.name == skinName) return skin; + } + return null; + }; + SkeletonData.prototype.findEvent = function (eventDataName) { + if (eventDataName == null) throw new Error('eventDataName cannot be null.'); + var events = this.events; + for (var i = 0, n = events.length; i < n; i++) { + var event_5 = events[i]; + if (event_5.name == eventDataName) return event_5; + } + return null; + }; + SkeletonData.prototype.findAnimation = function (animationName) { + if (animationName == null) throw new Error('animationName cannot be null.'); + var animations = this.animations; + for (var i = 0, n = animations.length; i < n; i++) { + var animation = animations[i]; + if (animation.name == animationName) return animation; + } + return null; + }; + SkeletonData.prototype.findIkConstraint = function (constraintName) { + if (constraintName == null) throw new Error('constraintName cannot be null.'); + var ikConstraints = this.ikConstraints; + for (var i = 0, n = ikConstraints.length; i < n; i++) { + var constraint = ikConstraints[i]; + if (constraint.name == constraintName) return constraint; + } + return null; + }; + SkeletonData.prototype.findTransformConstraint = function (constraintName) { + if (constraintName == null) throw new Error('constraintName cannot be null.'); + var transformConstraints = this.transformConstraints; + for (var i = 0, n = transformConstraints.length; i < n; i++) { + var constraint = transformConstraints[i]; + if (constraint.name == constraintName) return constraint; + } + return null; + }; + SkeletonData.prototype.findPathConstraint = function (constraintName) { + if (constraintName == null) throw new Error('constraintName cannot be null.'); + var pathConstraints = this.pathConstraints; + for (var i = 0, n = pathConstraints.length; i < n; i++) { + var constraint = pathConstraints[i]; + if (constraint.name == constraintName) return constraint; + } + return null; + }; + SkeletonData.prototype.findPathConstraintIndex = function (pathConstraintName) { + if (pathConstraintName == null) throw new Error('pathConstraintName cannot be null.'); + var pathConstraints = this.pathConstraints; + for (var i = 0, n = pathConstraints.length; i < n; i++) + if (pathConstraints[i].name == pathConstraintName) return i; + return -1; + }; + return SkeletonData; + })(); + core.SkeletonData = SkeletonData; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + core.FAIL_ON_NON_EXISTING_SKIN = false; + var SkeletonJson = (function () { + function SkeletonJson(attachmentLoader) { + this.scale = 1; + this.linkedMeshes = new Array(); + this.attachmentLoader = attachmentLoader; + } + SkeletonJson.prototype.readSkeletonData = function (json) { + var scale = this.scale; + var skeletonData = new core.SkeletonData(); + var root = typeof json === 'string' ? JSON.parse(json) : json; + var skeletonMap = root.skeleton; + if (skeletonMap != null) { + skeletonData.hash = skeletonMap.hash; + skeletonData.version = skeletonMap.spine; + if (skeletonData.version.substr(0, 3) !== '3.8') { + var error = + 'PixiJS Spine plugin supports only format for Spine 3.8. Your model has version ' + + skeletonMap.spine + + '. Please look in pixi-spine repository README for another branch.'; + console.error(error); + } + if (skeletonData.version === '3.8.75') { + var error = 'Unsupported skeleton data, 3.8.75 is deprecated, please export with a newer version of Spine.'; + console.error(error); + } + skeletonData.x = skeletonMap.x; + skeletonData.y = skeletonMap.y; + skeletonData.width = skeletonMap.width; + skeletonData.height = skeletonMap.height; + skeletonData.fps = skeletonMap.fps; + skeletonData.imagesPath = skeletonMap.images; + } + if (root.bones) { + for (var i = 0; i < root.bones.length; i++) { + var boneMap = root.bones[i]; + var parent_5 = null; + var parentName = this.getValue(boneMap, 'parent', null); + if (parentName != null) { + parent_5 = skeletonData.findBone(parentName); + if (parent_5 == null) throw new Error('Parent bone not found: ' + parentName); + } + var data = new core.BoneData(skeletonData.bones.length, boneMap.name, parent_5); + data.length = this.getValue(boneMap, 'length', 0) * scale; + data.x = this.getValue(boneMap, 'x', 0) * scale; + data.y = this.getValue(boneMap, 'y', 0) * scale; + data.rotation = this.getValue(boneMap, 'rotation', 0); + data.scaleX = this.getValue(boneMap, 'scaleX', 1); + data.scaleY = this.getValue(boneMap, 'scaleY', 1); + data.shearX = this.getValue(boneMap, 'shearX', 0); + data.shearY = this.getValue(boneMap, 'shearY', 0); + data.transformMode = SkeletonJson.transformModeFromString(this.getValue(boneMap, 'transform', 'normal')); + data.skinRequired = this.getValue(boneMap, 'skin', false); + skeletonData.bones.push(data); + } + } + if (root.slots) { + for (var i = 0; i < root.slots.length; i++) { + var slotMap = root.slots[i]; + var slotName = slotMap.name; + var boneName = slotMap.bone; + var boneData = skeletonData.findBone(boneName); + if (boneData == null) throw new Error('Slot bone not found: ' + boneName); + var data = new core.SlotData(skeletonData.slots.length, slotName, boneData); + var color = this.getValue(slotMap, 'color', null); + if (color != null) data.color.setFromString(color); + var dark = this.getValue(slotMap, 'dark', null); + if (dark != null) { + data.darkColor = new core.Color(1, 1, 1, 1); + data.darkColor.setFromString(dark); + } + data.attachmentName = this.getValue(slotMap, 'attachment', null); + data.blendMode = SkeletonJson.blendModeFromString(this.getValue(slotMap, 'blend', 'normal')); + skeletonData.slots.push(data); + } + } + if (root.ik) { + for (var i = 0; i < root.ik.length; i++) { + var constraintMap = root.ik[i]; + var data = new core.IkConstraintData(constraintMap.name); + data.order = this.getValue(constraintMap, 'order', 0); + data.skinRequired = this.getValue(constraintMap, 'skin', false); + for (var j = 0; j < constraintMap.bones.length; j++) { + var boneName = constraintMap.bones[j]; + var bone = skeletonData.findBone(boneName); + if (bone == null) throw new Error('IK bone not found: ' + boneName); + data.bones.push(bone); + } + var targetName = constraintMap.target; + data.target = skeletonData.findBone(targetName); + if (data.target == null) throw new Error('IK target bone not found: ' + targetName); + data.mix = this.getValue(constraintMap, 'mix', 1); + data.softness = this.getValue(constraintMap, 'softness', 0) * scale; + data.bendDirection = this.getValue(constraintMap, 'bendPositive', true) ? 1 : -1; + data.compress = this.getValue(constraintMap, 'compress', false); + data.stretch = this.getValue(constraintMap, 'stretch', false); + data.uniform = this.getValue(constraintMap, 'uniform', false); + skeletonData.ikConstraints.push(data); + } + } + if (root.transform) { + for (var i = 0; i < root.transform.length; i++) { + var constraintMap = root.transform[i]; + var data = new core.TransformConstraintData(constraintMap.name); + data.order = this.getValue(constraintMap, 'order', 0); + data.skinRequired = this.getValue(constraintMap, 'skin', false); + for (var j = 0; j < constraintMap.bones.length; j++) { + var boneName = constraintMap.bones[j]; + var bone = skeletonData.findBone(boneName); + if (bone == null) throw new Error('Transform constraint bone not found: ' + boneName); + data.bones.push(bone); + } + var targetName = constraintMap.target; + data.target = skeletonData.findBone(targetName); + if (data.target == null) throw new Error('Transform constraint target bone not found: ' + targetName); + data.local = this.getValue(constraintMap, 'local', false); + data.relative = this.getValue(constraintMap, 'relative', false); + data.offsetRotation = this.getValue(constraintMap, 'rotation', 0); + data.offsetX = this.getValue(constraintMap, 'x', 0) * scale; + data.offsetY = this.getValue(constraintMap, 'y', 0) * scale; + data.offsetScaleX = this.getValue(constraintMap, 'scaleX', 0); + data.offsetScaleY = this.getValue(constraintMap, 'scaleY', 0); + data.offsetShearY = this.getValue(constraintMap, 'shearY', 0); + data.rotateMix = this.getValue(constraintMap, 'rotateMix', 1); + data.translateMix = this.getValue(constraintMap, 'translateMix', 1); + data.scaleMix = this.getValue(constraintMap, 'scaleMix', 1); + data.shearMix = this.getValue(constraintMap, 'shearMix', 1); + skeletonData.transformConstraints.push(data); + } + } + if (root.path) { + for (var i = 0; i < root.path.length; i++) { + var constraintMap = root.path[i]; + var data = new core.PathConstraintData(constraintMap.name); + data.order = this.getValue(constraintMap, 'order', 0); + data.skinRequired = this.getValue(constraintMap, 'skin', false); + for (var j = 0; j < constraintMap.bones.length; j++) { + var boneName = constraintMap.bones[j]; + var bone = skeletonData.findBone(boneName); + if (bone == null) throw new Error('Transform constraint bone not found: ' + boneName); + data.bones.push(bone); + } + var targetName = constraintMap.target; + data.target = skeletonData.findSlot(targetName); + if (data.target == null) throw new Error('Path target slot not found: ' + targetName); + data.positionMode = SkeletonJson.positionModeFromString( + this.getValue(constraintMap, 'positionMode', 'percent'), + ); + data.spacingMode = SkeletonJson.spacingModeFromString( + this.getValue(constraintMap, 'spacingMode', 'length'), + ); + data.rotateMode = SkeletonJson.rotateModeFromString(this.getValue(constraintMap, 'rotateMode', 'tangent')); + data.offsetRotation = this.getValue(constraintMap, 'rotation', 0); + data.position = this.getValue(constraintMap, 'position', 0); + if (data.positionMode == core.PositionMode.Fixed) data.position *= scale; + data.spacing = this.getValue(constraintMap, 'spacing', 0); + if (data.spacingMode == core.SpacingMode.Length || data.spacingMode == core.SpacingMode.Fixed) + data.spacing *= scale; + data.rotateMix = this.getValue(constraintMap, 'rotateMix', 1); + data.translateMix = this.getValue(constraintMap, 'translateMix', 1); + skeletonData.pathConstraints.push(data); + } + } + if (root.skins) { + for (var i = 0; i < root.skins.length; i++) { + var skinMap = root.skins[i]; + var skin = new core.Skin(skinMap.name); + if (skinMap.bones) { + for (var ii = 0; ii < skinMap.bones.length; ii++) { + var bone = skeletonData.findBone(skinMap.bones[ii]); + if (bone == null) throw new Error('Skin bone not found: ' + skinMap.bones[i]); + skin.bones.push(bone); + } + } + if (skinMap.ik) { + for (var ii = 0; ii < skinMap.ik.length; ii++) { + var constraint = skeletonData.findIkConstraint(skinMap.ik[ii]); + if (constraint == null) throw new Error('Skin IK constraint not found: ' + skinMap.ik[i]); + skin.constraints.push(constraint); + } + } + if (skinMap.transform) { + for (var ii = 0; ii < skinMap.transform.length; ii++) { + var constraint = skeletonData.findTransformConstraint(skinMap.transform[ii]); + if (constraint == null) throw new Error('Skin transform constraint not found: ' + skinMap.transform[i]); + skin.constraints.push(constraint); + } + } + if (skinMap.path) { + for (var ii = 0; ii < skinMap.path.length; ii++) { + var constraint = skeletonData.findPathConstraint(skinMap.path[ii]); + if (constraint == null) throw new Error('Skin path constraint not found: ' + skinMap.path[i]); + skin.constraints.push(constraint); + } + } + for (var slotName in skinMap.attachments) { + var slot = skeletonData.findSlot(slotName); + if (slot == null) throw new Error('Slot not found: ' + slotName); + var slotMap = skinMap.attachments[slotName]; + for (var entryName in slotMap) { + var attachment = this.readAttachment(slotMap[entryName], skin, slot.index, entryName, skeletonData); + if (attachment != null) skin.setAttachment(slot.index, entryName, attachment); + } + } + skeletonData.skins.push(skin); + if (skin.name == 'default') skeletonData.defaultSkin = skin; + } + } + for (var i = 0, n = this.linkedMeshes.length; i < n; i++) { + var linkedMesh = this.linkedMeshes[i]; + var skin = linkedMesh.skin == null ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin); + if (skin == null) throw new Error('Skin not found: ' + linkedMesh.skin); + var parent_6 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent); + if (parent_6 == null) throw new Error('Parent mesh not found: ' + linkedMesh.parent); + linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? parent_6 : linkedMesh.mesh; + linkedMesh.mesh.setParentMesh(parent_6); + } + this.linkedMeshes.length = 0; + if (root.events) { + for (var eventName in root.events) { + var eventMap = root.events[eventName]; + var data = new core.EventData(eventName); + data.intValue = this.getValue(eventMap, 'int', 0); + data.floatValue = this.getValue(eventMap, 'float', 0); + data.stringValue = this.getValue(eventMap, 'string', ''); + data.audioPath = this.getValue(eventMap, 'audio', null); + if (data.audioPath != null) { + data.volume = this.getValue(eventMap, 'volume', 1); + data.balance = this.getValue(eventMap, 'balance', 0); + } + skeletonData.events.push(data); + } + } + if (root.animations) { + for (var animationName in root.animations) { + var animationMap = root.animations[animationName]; + this.readAnimation(animationMap, animationName, skeletonData); + } + } + return skeletonData; + }; + SkeletonJson.prototype.readAttachment = function (map, skin, slotIndex, name, skeletonData) { + var scale = this.scale; + name = this.getValue(map, 'name', name); + var type = this.getValue(map, 'type', 'region'); + switch (type) { + case 'region': { + var path = this.getValue(map, 'path', name); + var region = this.attachmentLoader.newRegionAttachment(skin, name, path); + if (region == null) return null; + region.path = path; + region.x = this.getValue(map, 'x', 0) * scale; + region.y = this.getValue(map, 'y', 0) * scale; + region.scaleX = this.getValue(map, 'scaleX', 1); + region.scaleY = this.getValue(map, 'scaleY', 1); + region.rotation = this.getValue(map, 'rotation', 0); + region.width = map.width * scale; + region.height = map.height * scale; + var color = this.getValue(map, 'color', null); + if (color != null) region.color.setFromString(color); + return region; + } + case 'boundingbox': { + var box = this.attachmentLoader.newBoundingBoxAttachment(skin, name); + if (box == null) return null; + this.readVertices(map, box, map.vertexCount << 1); + var color = this.getValue(map, 'color', null); + if (color != null) box.color.setFromString(color); + return box; + } + case 'mesh': + case 'linkedmesh': { + var path = this.getValue(map, 'path', name); + var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path); + if (mesh == null) return null; + mesh.path = path; + var color = this.getValue(map, 'color', null); + if (color != null) mesh.color.setFromString(color); + mesh.width = this.getValue(map, 'width', 0) * scale; + mesh.height = this.getValue(map, 'height', 0) * scale; + var parent_7 = this.getValue(map, 'parent', null); + if (parent_7 != null) { + this.linkedMeshes.push( + new LinkedMesh( + mesh, + this.getValue(map, 'skin', null), + slotIndex, + parent_7, + this.getValue(map, 'deform', true), + ), + ); + return mesh; + } + var uvs = map.uvs; + this.readVertices(map, mesh, uvs.length); + mesh.triangles = map.triangles; + mesh.regionUVs = new Float32Array(uvs); + mesh.edges = this.getValue(map, 'edges', null); + mesh.hullLength = this.getValue(map, 'hull', 0) * 2; + return mesh; + } + case 'path': { + var path = this.attachmentLoader.newPathAttachment(skin, name); + if (path == null) return null; + path.closed = this.getValue(map, 'closed', false); + path.constantSpeed = this.getValue(map, 'constantSpeed', true); + var vertexCount = map.vertexCount; + this.readVertices(map, path, vertexCount << 1); + var lengths = core.Utils.newArray(vertexCount / 3, 0); + for (var i = 0; i < map.lengths.length; i++) lengths[i] = map.lengths[i] * scale; + path.lengths = lengths; + var color = this.getValue(map, 'color', null); + if (color != null) path.color.setFromString(color); + return path; + } + case 'point': { + var point = this.attachmentLoader.newPointAttachment(skin, name); + if (point == null) return null; + point.x = this.getValue(map, 'x', 0) * scale; + point.y = this.getValue(map, 'y', 0) * scale; + point.rotation = this.getValue(map, 'rotation', 0); + var color = this.getValue(map, 'color', null); + if (color != null) point.color.setFromString(color); + return point; + } + case 'clipping': { + var clip = this.attachmentLoader.newClippingAttachment(skin, name); + if (clip == null) return null; + var end = this.getValue(map, 'end', null); + if (end != null) { + var slot = skeletonData.findSlot(end); + if (slot == null) throw new Error('Clipping end slot not found: ' + end); + clip.endSlot = slot; + } + var vertexCount = map.vertexCount; + this.readVertices(map, clip, vertexCount << 1); + var color = this.getValue(map, 'color', null); + if (color != null) clip.color.setFromString(color); + return clip; + } + } + return null; + }; + SkeletonJson.prototype.readVertices = function (map, attachment, verticesLength) { + var scale = this.scale; + attachment.worldVerticesLength = verticesLength; + var vertices = map.vertices; + if (verticesLength == vertices.length) { + var scaledVertices = core.Utils.toFloatArray(vertices); + if (scale != 1) { + for (var i = 0, n = vertices.length; i < n; i++) scaledVertices[i] *= scale; + } + attachment.vertices = scaledVertices; + return; + } + var weights = new Array(); + var bones = new Array(); + for (var i = 0, n = vertices.length; i < n; ) { + var boneCount = vertices[i++]; + bones.push(boneCount); + for (var nn = i + boneCount * 4; i < nn; i += 4) { + bones.push(vertices[i]); + weights.push(vertices[i + 1] * scale); + weights.push(vertices[i + 2] * scale); + weights.push(vertices[i + 3]); + } + } + attachment.bones = bones; + attachment.vertices = core.Utils.toFloatArray(weights); + }; + SkeletonJson.prototype.readAnimation = function (map, name, skeletonData) { + var scale = this.scale; + var timelines = new Array(); + var duration = 0; + if (map.slots) { + for (var slotName in map.slots) { + var slotMap = map.slots[slotName]; + var slotIndex = skeletonData.findSlotIndex(slotName); + if (slotIndex == -1) throw new Error('Slot not found: ' + slotName); + for (var timelineName in slotMap) { + var timelineMap = slotMap[timelineName]; + if (timelineName == 'attachment') { + var timeline = new core.AttachmentTimeline(timelineMap.length); + timeline.slotIndex = slotIndex; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + timeline.setFrame(frameIndex++, this.getValue(valueMap, 'time', 0), valueMap.name); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); + } else if (timelineName == 'color') { + var timeline = new core.ColorTimeline(timelineMap.length); + timeline.slotIndex = slotIndex; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + var color = new core.Color(); + color.setFromString(valueMap.color || 'ffffffff'); + timeline.setFrame(frameIndex, this.getValue(valueMap, 'time', 0), color.r, color.g, color.b, color.a); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max( + duration, + timeline.frames[(timeline.getFrameCount() - 1) * core.ColorTimeline.ENTRIES], + ); + } else if (timelineName == 'twoColor') { + var timeline = new core.TwoColorTimeline(timelineMap.length); + timeline.slotIndex = slotIndex; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + var light = new core.Color(); + var dark = new core.Color(); + light.setFromString(valueMap.light); + dark.setFromString(valueMap.dark); + timeline.setFrame( + frameIndex, + this.getValue(valueMap, 'time', 0), + light.r, + light.g, + light.b, + light.a, + dark.r, + dark.g, + dark.b, + ); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max( + duration, + timeline.frames[(timeline.getFrameCount() - 1) * core.TwoColorTimeline.ENTRIES], + ); + } else throw new Error('Invalid timeline type for a slot: ' + timelineName + ' (' + slotName + ')'); + } + } + } + if (map.bones) { + for (var boneName in map.bones) { + var boneMap = map.bones[boneName]; + var boneIndex = skeletonData.findBoneIndex(boneName); + if (boneIndex == -1) throw new Error('Bone not found: ' + boneName); + for (var timelineName in boneMap) { + var timelineMap = boneMap[timelineName]; + if (timelineName === 'rotate') { + var timeline = new core.RotateTimeline(timelineMap.length); + timeline.boneIndex = boneIndex; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + timeline.setFrame( + frameIndex, + this.getValue(valueMap, 'time', 0), + this.getValue(valueMap, 'angle', 0), + ); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max( + duration, + timeline.frames[(timeline.getFrameCount() - 1) * core.RotateTimeline.ENTRIES], + ); + } else if (timelineName === 'translate' || timelineName === 'scale' || timelineName === 'shear') { + var timeline = null; + var timelineScale = 1, + defaultValue = 0; + if (timelineName === 'scale') { + timeline = new core.ScaleTimeline(timelineMap.length); + defaultValue = 1; + } else if (timelineName === 'shear') timeline = new core.ShearTimeline(timelineMap.length); + else { + timeline = new core.TranslateTimeline(timelineMap.length); + timelineScale = scale; + } + timeline.boneIndex = boneIndex; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + var x = this.getValue(valueMap, 'x', defaultValue), + y = this.getValue(valueMap, 'y', defaultValue); + timeline.setFrame( + frameIndex, + this.getValue(valueMap, 'time', 0), + x * timelineScale, + y * timelineScale, + ); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max( + duration, + timeline.frames[(timeline.getFrameCount() - 1) * core.TranslateTimeline.ENTRIES], + ); + } else throw new Error('Invalid timeline type for a bone: ' + timelineName + ' (' + boneName + ')'); + } + } + } + if (map.ik) { + for (var constraintName in map.ik) { + var constraintMap = map.ik[constraintName]; + var constraint = skeletonData.findIkConstraint(constraintName); + var timeline = new core.IkConstraintTimeline(constraintMap.length); + timeline.ikConstraintIndex = skeletonData.ikConstraints.indexOf(constraint); + var frameIndex = 0; + for (var i = 0; i < constraintMap.length; i++) { + var valueMap = constraintMap[i]; + timeline.setFrame( + frameIndex, + this.getValue(valueMap, 'time', 0), + this.getValue(valueMap, 'mix', 1), + this.getValue(valueMap, 'softness', 0) * scale, + this.getValue(valueMap, 'bendPositive', true) ? 1 : -1, + this.getValue(valueMap, 'compress', false), + this.getValue(valueMap, 'stretch', false), + ); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max( + duration, + timeline.frames[(timeline.getFrameCount() - 1) * core.IkConstraintTimeline.ENTRIES], + ); + } + } + if (map.transform) { + for (var constraintName in map.transform) { + var constraintMap = map.transform[constraintName]; + var constraint = skeletonData.findTransformConstraint(constraintName); + var timeline = new core.TransformConstraintTimeline(constraintMap.length); + timeline.transformConstraintIndex = skeletonData.transformConstraints.indexOf(constraint); + var frameIndex = 0; + for (var i = 0; i < constraintMap.length; i++) { + var valueMap = constraintMap[i]; + timeline.setFrame( + frameIndex, + this.getValue(valueMap, 'time', 0), + this.getValue(valueMap, 'rotateMix', 1), + this.getValue(valueMap, 'translateMix', 1), + this.getValue(valueMap, 'scaleMix', 1), + this.getValue(valueMap, 'shearMix', 1), + ); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max( + duration, + timeline.frames[(timeline.getFrameCount() - 1) * core.TransformConstraintTimeline.ENTRIES], + ); + } + } + if (map.path) { + for (var constraintName in map.path) { + var constraintMap = map.path[constraintName]; + var index = skeletonData.findPathConstraintIndex(constraintName); + if (index == -1) throw new Error('Path constraint not found: ' + constraintName); + var data = skeletonData.pathConstraints[index]; + for (var timelineName in constraintMap) { + var timelineMap = constraintMap[timelineName]; + if (timelineName === 'position' || timelineName === 'spacing') { + var timeline = null; + var timelineScale = 1; + if (timelineName === 'spacing') { + timeline = new core.PathConstraintSpacingTimeline(timelineMap.length); + if (data.spacingMode == core.SpacingMode.Length || data.spacingMode == core.SpacingMode.Fixed) + timelineScale = scale; + } else { + timeline = new core.PathConstraintPositionTimeline(timelineMap.length); + if (data.positionMode == core.PositionMode.Fixed) timelineScale = scale; + } + timeline.pathConstraintIndex = index; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + timeline.setFrame( + frameIndex, + this.getValue(valueMap, 'time', 0), + this.getValue(valueMap, timelineName, 0) * timelineScale, + ); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max( + duration, + timeline.frames[(timeline.getFrameCount() - 1) * core.PathConstraintPositionTimeline.ENTRIES], + ); + } else if (timelineName === 'mix') { + var timeline = new core.PathConstraintMixTimeline(timelineMap.length); + timeline.pathConstraintIndex = index; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + timeline.setFrame( + frameIndex, + this.getValue(valueMap, 'time', 0), + this.getValue(valueMap, 'rotateMix', 1), + this.getValue(valueMap, 'translateMix', 1), + ); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max( + duration, + timeline.frames[(timeline.getFrameCount() - 1) * core.PathConstraintMixTimeline.ENTRIES], + ); + } + } + } + } + if (map.deform) { + for (var deformName in map.deform) { + var deformMap = map.deform[deformName]; + var skin = skeletonData.findSkin(deformName); + if (skin == null) { + if (core.FAIL_ON_NON_EXISTING_SKIN) { + throw new Error('Skin not found: ' + deformName); + } else { + continue; + } + } + for (var slotName in deformMap) { + var slotMap = deformMap[slotName]; + var slotIndex = skeletonData.findSlotIndex(slotName); + if (slotIndex == -1) throw new Error('Slot not found: ' + slotMap.name); + for (var timelineName in slotMap) { + var timelineMap = slotMap[timelineName]; + var attachment = skin.getAttachment(slotIndex, timelineName); + if (attachment == null) throw new Error('Deform attachment not found: ' + timelineMap.name); + var weighted = attachment.bones != null; + var vertices = attachment.vertices; + var deformLength = weighted ? (vertices.length / 3) * 2 : vertices.length; + var timeline = new core.DeformTimeline(timelineMap.length); + timeline.slotIndex = slotIndex; + timeline.attachment = attachment; + var frameIndex = 0; + for (var j = 0; j < timelineMap.length; j++) { + var valueMap = timelineMap[j]; + var deform = void 0; + var verticesValue = this.getValue(valueMap, 'vertices', null); + if (verticesValue == null) deform = weighted ? core.Utils.newFloatArray(deformLength) : vertices; + else { + deform = core.Utils.newFloatArray(deformLength); + var start = this.getValue(valueMap, 'offset', 0); + core.Utils.arrayCopy(verticesValue, 0, deform, start, verticesValue.length); + if (scale != 1) { + for (var i = start, n = i + verticesValue.length; i < n; i++) deform[i] *= scale; + } + if (!weighted) { + for (var i = 0; i < deformLength; i++) deform[i] += vertices[i]; + } + } + timeline.setFrame(frameIndex, this.getValue(valueMap, 'time', 0), deform); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); + } + } + } + } + var drawOrderNode = map.drawOrder; + if (drawOrderNode == null) drawOrderNode = map.draworder; + if (drawOrderNode != null) { + var timeline = new core.DrawOrderTimeline(drawOrderNode.length); + var slotCount = skeletonData.slots.length; + var frameIndex = 0; + for (var j = 0; j < drawOrderNode.length; j++) { + var drawOrderMap = drawOrderNode[j]; + var drawOrder = null; + var offsets = this.getValue(drawOrderMap, 'offsets', null); + if (offsets != null) { + drawOrder = core.Utils.newArray(slotCount, -1); + var unchanged = core.Utils.newArray(slotCount - offsets.length, 0); + var originalIndex = 0, + unchangedIndex = 0; + for (var i = 0; i < offsets.length; i++) { + var offsetMap = offsets[i]; + var slotIndex = skeletonData.findSlotIndex(offsetMap.slot); + if (slotIndex == -1) throw new Error('Slot not found: ' + offsetMap.slot); + while (originalIndex != slotIndex) unchanged[unchangedIndex++] = originalIndex++; + drawOrder[originalIndex + offsetMap.offset] = originalIndex++; + } + while (originalIndex < slotCount) unchanged[unchangedIndex++] = originalIndex++; + for (var i = slotCount - 1; i >= 0; i--) + if (drawOrder[i] == -1) drawOrder[i] = unchanged[--unchangedIndex]; + } + timeline.setFrame(frameIndex++, this.getValue(drawOrderMap, 'time', 0), drawOrder); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); + } + if (map.events) { + var timeline = new core.EventTimeline(map.events.length); + var frameIndex = 0; + for (var i = 0; i < map.events.length; i++) { + var eventMap = map.events[i]; + var eventData = skeletonData.findEvent(eventMap.name); + if (eventData == null) throw new Error('Event not found: ' + eventMap.name); + var event_6 = new core.Event(core.Utils.toSinglePrecision(this.getValue(eventMap, 'time', 0)), eventData); + event_6.intValue = this.getValue(eventMap, 'int', eventData.intValue); + event_6.floatValue = this.getValue(eventMap, 'float', eventData.floatValue); + event_6.stringValue = this.getValue(eventMap, 'string', eventData.stringValue); + if (event_6.data.audioPath != null) { + event_6.volume = this.getValue(eventMap, 'volume', 1); + event_6.balance = this.getValue(eventMap, 'balance', 0); + } + timeline.setFrame(frameIndex++, event_6); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); + } + if (isNaN(duration)) { + throw new Error('Error while parsing animation, duration is NaN'); + } + skeletonData.animations.push(new core.Animation(name, timelines, duration)); + }; + SkeletonJson.prototype.readCurve = function (map, timeline, frameIndex) { + if (!map.hasOwnProperty('curve')) return; + if (map.curve === 'stepped') timeline.setStepped(frameIndex); + else { + var curve = map.curve; + timeline.setCurve( + frameIndex, + curve, + this.getValue(map, 'c2', 0), + this.getValue(map, 'c3', 1), + this.getValue(map, 'c4', 1), + ); + } + }; + SkeletonJson.prototype.getValue = function (map, prop, defaultValue) { + return map[prop] !== undefined ? map[prop] : defaultValue; + }; + SkeletonJson.blendModeFromString = function (str) { + str = str.toLowerCase(); + if (str == 'normal') return core.BlendMode.Normal; + if (str == 'additive') return core.BlendMode.Additive; + if (str == 'multiply') return core.BlendMode.Multiply; + if (str == 'screen') return core.BlendMode.Screen; + throw new Error('Unknown blend mode: ' + str); + }; + SkeletonJson.positionModeFromString = function (str) { + str = str.toLowerCase(); + if (str == 'fixed') return core.PositionMode.Fixed; + if (str == 'percent') return core.PositionMode.Percent; + throw new Error('Unknown position mode: ' + str); + }; + SkeletonJson.spacingModeFromString = function (str) { + str = str.toLowerCase(); + if (str == 'length') return core.SpacingMode.Length; + if (str == 'fixed') return core.SpacingMode.Fixed; + if (str == 'percent') return core.SpacingMode.Percent; + throw new Error('Unknown position mode: ' + str); + }; + SkeletonJson.rotateModeFromString = function (str) { + str = str.toLowerCase(); + if (str == 'tangent') return core.RotateMode.Tangent; + if (str == 'chain') return core.RotateMode.Chain; + if (str == 'chainscale') return core.RotateMode.ChainScale; + throw new Error('Unknown rotate mode: ' + str); + }; + SkeletonJson.transformModeFromString = function (str) { + str = str.toLowerCase(); + if (str == 'normal') return core.TransformMode.Normal; + if (str == 'onlytranslation') return core.TransformMode.OnlyTranslation; + if (str == 'norotationorreflection') return core.TransformMode.NoRotationOrReflection; + if (str == 'noscale') return core.TransformMode.NoScale; + if (str == 'noscaleorreflection') return core.TransformMode.NoScaleOrReflection; + throw new Error('Unknown transform mode: ' + str); + }; + return SkeletonJson; + })(); + core.SkeletonJson = SkeletonJson; + var LinkedMesh = (function () { + function LinkedMesh(mesh, skin, slotIndex, parent, inheritDeform) { + this.mesh = mesh; + this.skin = skin; + this.slotIndex = slotIndex; + this.parent = parent; + this.inheritDeform = inheritDeform; + } + return LinkedMesh; + })(); + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var SkinEntry = (function () { + function SkinEntry(slotIndex, name, attachment) { + this.slotIndex = slotIndex; + this.name = name; + this.attachment = attachment; + } + return SkinEntry; + })(); + core.SkinEntry = SkinEntry; + var Skin = (function () { + function Skin(name) { + this.attachments = new Array(); + this.bones = Array(); + this.constraints = new Array(); + if (name == null) throw new Error('name cannot be null.'); + this.name = name; + } + Skin.prototype.setAttachment = function (slotIndex, name, attachment) { + if (attachment == null) throw new Error('attachment cannot be null.'); + var attachments = this.attachments; + if (slotIndex >= attachments.length) attachments.length = slotIndex + 1; + if (!attachments[slotIndex]) attachments[slotIndex] = {}; + attachments[slotIndex][name] = attachment; + }; + Skin.prototype.addSkin = function (skin) { + for (var i = 0; i < skin.bones.length; i++) { + var bone = skin.bones[i]; + var contained = false; + for (var j = 0; j < this.bones.length; j++) { + if (this.bones[j] == bone) { + contained = true; + break; + } + } + if (!contained) this.bones.push(bone); + } + for (var i = 0; i < skin.constraints.length; i++) { + var constraint = skin.constraints[i]; + var contained = false; + for (var j = 0; j < this.constraints.length; j++) { + if (this.constraints[j] == constraint) { + contained = true; + break; + } + } + if (!contained) this.constraints.push(constraint); + } + var attachments = skin.getAttachments(); + for (var i = 0; i < attachments.length; i++) { + var attachment = attachments[i]; + this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment); + } + }; + Skin.prototype.copySkin = function (skin) { + for (var i = 0; i < skin.bones.length; i++) { + var bone = skin.bones[i]; + var contained = false; + for (var j = 0; j < this.bones.length; j++) { + if (this.bones[j] == bone) { + contained = true; + break; + } + } + if (!contained) this.bones.push(bone); + } + for (var i = 0; i < skin.constraints.length; i++) { + var constraint = skin.constraints[i]; + var contained = false; + for (var j = 0; j < this.constraints.length; j++) { + if (this.constraints[j] == constraint) { + contained = true; + break; + } + } + if (!contained) this.constraints.push(constraint); + } + var attachments = skin.getAttachments(); + for (var i = 0; i < attachments.length; i++) { + var attachment = attachments[i]; + if (attachment.attachment == null) continue; + if (attachment.attachment instanceof core.MeshAttachment) { + attachment.attachment = attachment.attachment.newLinkedMesh(); + this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment); + } else { + attachment.attachment = attachment.attachment.copy(); + this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment); + } + } + }; + Skin.prototype.getAttachment = function (slotIndex, name) { + var dictionary = this.attachments[slotIndex]; + return dictionary ? dictionary[name] : null; + }; + Skin.prototype.removeAttachment = function (slotIndex, name) { + var dictionary = this.attachments[slotIndex]; + if (dictionary) dictionary[name] = null; + }; + Skin.prototype.getAttachments = function () { + var entries = new Array(); + for (var i = 0; i < this.attachments.length; i++) { + var slotAttachments = this.attachments[i]; + if (slotAttachments) { + for (var name_4 in slotAttachments) { + var attachment = slotAttachments[name_4]; + if (attachment) entries.push(new SkinEntry(i, name_4, attachment)); + } + } + } + return entries; + }; + Skin.prototype.getAttachmentsForSlot = function (slotIndex, attachments) { + var slotAttachments = this.attachments[slotIndex]; + if (slotAttachments) { + for (var name_5 in slotAttachments) { + var attachment = slotAttachments[name_5]; + if (attachment) attachments.push(new SkinEntry(slotIndex, name_5, attachment)); + } + } + }; + Skin.prototype.clear = function () { + this.attachments.length = 0; + this.bones.length = 0; + this.constraints.length = 0; + }; + Skin.prototype.attachAll = function (skeleton, oldSkin) { + var slotIndex = 0; + for (var i = 0; i < skeleton.slots.length; i++) { + var slot = skeleton.slots[i]; + var slotAttachment = slot.getAttachment(); + if (slotAttachment && slotIndex < oldSkin.attachments.length) { + var dictionary = oldSkin.attachments[slotIndex]; + for (var key in dictionary) { + var skinAttachment = dictionary[key]; + if (slotAttachment == skinAttachment) { + var attachment = this.getAttachment(slotIndex, key); + if (attachment != null) slot.setAttachment(attachment); + break; + } + } + } + slotIndex++; + } + }; + return Skin; + })(); + core.Skin = Skin; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var Slot = (function () { + function Slot(data, bone) { + this.deform = new Array(); + if (data == null) throw new Error('data cannot be null.'); + if (bone == null) throw new Error('bone cannot be null.'); + this.data = data; + this.bone = bone; + this.color = new core.Color(); + this.darkColor = data.darkColor == null ? null : new core.Color(); + this.setToSetupPose(); + this.blendMode = this.data.blendMode; + } + Slot.prototype.getAttachment = function () { + return this.attachment; + }; + Slot.prototype.setAttachment = function (attachment) { + if (this.attachment == attachment) return; + this.attachment = attachment; + this.attachmentTime = this.bone.skeleton.time; + this.deform.length = 0; + }; + Slot.prototype.setAttachmentTime = function (time) { + this.attachmentTime = this.bone.skeleton.time - time; + }; + Slot.prototype.getAttachmentTime = function () { + return this.bone.skeleton.time - this.attachmentTime; + }; + Slot.prototype.setToSetupPose = function () { + this.color.setFromColor(this.data.color); + if (this.darkColor != null) this.darkColor.setFromColor(this.data.darkColor); + if (this.data.attachmentName == null) this.attachment = null; + else { + this.attachment = null; + this.setAttachment(this.bone.skeleton.getAttachment(this.data.index, this.data.attachmentName)); + } + }; + return Slot; + })(); + core.Slot = Slot; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var SlotData = (function () { + function SlotData(index, name, boneData) { + this.color = new core.Color(1, 1, 1, 1); + if (index < 0) throw new Error('index must be >= 0.'); + if (name == null) throw new Error('name cannot be null.'); + if (boneData == null) throw new Error('boneData cannot be null.'); + this.index = index; + this.name = name; + this.boneData = boneData; + } + return SlotData; + })(); + core.SlotData = SlotData; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var Texture = (function () { + function Texture(image) { + this._image = image; + } + Texture.prototype.getImage = function () { + return this._image; + }; + Texture.filterFromString = function (text) { + switch (text.toLowerCase()) { + case 'nearest': + return TextureFilter.Nearest; + case 'linear': + return TextureFilter.Linear; + case 'mipmap': + return TextureFilter.MipMap; + case 'mipmapnearestnearest': + return TextureFilter.MipMapNearestNearest; + case 'mipmaplinearnearest': + return TextureFilter.MipMapLinearNearest; + case 'mipmapnearestlinear': + return TextureFilter.MipMapNearestLinear; + case 'mipmaplinearlinear': + return TextureFilter.MipMapLinearLinear; + default: + throw new Error('Unknown texture filter ' + text); + } + }; + Texture.wrapFromString = function (text) { + switch (text.toLowerCase()) { + case 'mirroredtepeat': + return TextureWrap.MirroredRepeat; + case 'clamptoedge': + return TextureWrap.ClampToEdge; + case 'repeat': + return TextureWrap.Repeat; + default: + throw new Error('Unknown texture wrap ' + text); + } + }; + return Texture; + })(); + core.Texture = Texture; + var TextureFilter; + (function (TextureFilter) { + TextureFilter[(TextureFilter['Nearest'] = 9728)] = 'Nearest'; + TextureFilter[(TextureFilter['Linear'] = 9729)] = 'Linear'; + TextureFilter[(TextureFilter['MipMap'] = 9987)] = 'MipMap'; + TextureFilter[(TextureFilter['MipMapNearestNearest'] = 9984)] = 'MipMapNearestNearest'; + TextureFilter[(TextureFilter['MipMapLinearNearest'] = 9985)] = 'MipMapLinearNearest'; + TextureFilter[(TextureFilter['MipMapNearestLinear'] = 9986)] = 'MipMapNearestLinear'; + TextureFilter[(TextureFilter['MipMapLinearLinear'] = 9987)] = 'MipMapLinearLinear'; + })((TextureFilter = core.TextureFilter || (core.TextureFilter = {}))); + var TextureWrap; + (function (TextureWrap) { + TextureWrap[(TextureWrap['MirroredRepeat'] = 33648)] = 'MirroredRepeat'; + TextureWrap[(TextureWrap['ClampToEdge'] = 33071)] = 'ClampToEdge'; + TextureWrap[(TextureWrap['Repeat'] = 10497)] = 'Repeat'; + })((TextureWrap = core.TextureWrap || (core.TextureWrap = {}))); + var TextureRegion = (function () { + function TextureRegion() { + this.size = null; + } + Object.defineProperty(TextureRegion.prototype, 'width', { + get: function () { + var tex = this.texture; + if (PIXI.VERSION[0] == '3') { + return tex.crop.width; + } + if (tex.trim) { + return tex.trim.width; + } + return tex.orig.width; + }, + enumerable: false, + configurable: true, + }); + Object.defineProperty(TextureRegion.prototype, 'height', { + get: function () { + var tex = this.texture; + if (PIXI.VERSION[0] == '3') { + return tex.crop.height; + } + if (tex.trim) { + return tex.trim.height; + } + return tex.orig.height; + }, + enumerable: false, + configurable: true, + }); + Object.defineProperty(TextureRegion.prototype, 'u', { + get: function () { + return this.texture._uvs.x0; + }, + enumerable: false, + configurable: true, + }); + Object.defineProperty(TextureRegion.prototype, 'v', { + get: function () { + return this.texture._uvs.y0; + }, + enumerable: false, + configurable: true, + }); + Object.defineProperty(TextureRegion.prototype, 'u2', { + get: function () { + return this.texture._uvs.x2; + }, + enumerable: false, + configurable: true, + }); + Object.defineProperty(TextureRegion.prototype, 'v2', { + get: function () { + return this.texture._uvs.y2; + }, + enumerable: false, + configurable: true, + }); + Object.defineProperty(TextureRegion.prototype, 'offsetX', { + get: function () { + var tex = this.texture; + return tex.trim ? tex.trim.x : 0; + }, + enumerable: false, + configurable: true, + }); + Object.defineProperty(TextureRegion.prototype, 'offsetY', { + get: function () { + console.warn( + 'Deprecation Warning: @Hackerham: I guess, if you are using PIXI-SPINE ATLAS region.offsetY, you want a texture, right? Use region.texture from now on.', + ); + return this.spineOffsetY; + }, + enumerable: false, + configurable: true, + }); + Object.defineProperty(TextureRegion.prototype, 'pixiOffsetY', { + get: function () { + var tex = this.texture; + return tex.trim ? tex.trim.y : 0; + }, + enumerable: false, + configurable: true, + }); + Object.defineProperty(TextureRegion.prototype, 'spineOffsetY', { + get: function () { + var tex = this.texture; + return this.originalHeight - this.height - (tex.trim ? tex.trim.y : 0); + }, + enumerable: false, + configurable: true, + }); + Object.defineProperty(TextureRegion.prototype, 'originalWidth', { + get: function () { + var tex = this.texture; + if (PIXI.VERSION[0] == '3') { + if (tex.trim) { + return tex.trim.width; + } + return tex.crop.width; + } + return tex.orig.width; + }, + enumerable: false, + configurable: true, + }); + Object.defineProperty(TextureRegion.prototype, 'originalHeight', { + get: function () { + var tex = this.texture; + if (PIXI.VERSION[0] == '3') { + if (tex.trim) { + return tex.trim.height; + } + return tex.crop.height; + } + return tex.orig.height; + }, + enumerable: false, + configurable: true, + }); + Object.defineProperty(TextureRegion.prototype, 'x', { + get: function () { + return this.texture.frame.x; + }, + enumerable: false, + configurable: true, + }); + Object.defineProperty(TextureRegion.prototype, 'y', { + get: function () { + return this.texture.frame.y; + }, + enumerable: false, + configurable: true, + }); + Object.defineProperty(TextureRegion.prototype, 'rotate', { + get: function () { + return this.texture.rotate !== 0; + }, + enumerable: false, + configurable: true, + }); + return TextureRegion; + })(); + core.TextureRegion = TextureRegion; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var TextureAtlas = (function () { + function TextureAtlas(atlasText, textureLoader, callback) { + this.pages = new Array(); + this.regions = new Array(); + if (atlasText) { + this.addSpineAtlas(atlasText, textureLoader, callback); + } + } + TextureAtlas.prototype.addTexture = function (name, texture) { + var pages = this.pages; + var page = null; + for (var i = 0; i < pages.length; i++) { + if (pages[i].baseTexture === texture.baseTexture) { + page = pages[i]; + break; + } + } + if (page === null) { + page = new TextureAtlasPage(); + page.name = 'texturePage'; + var baseTexture = texture.baseTexture; + page.width = baseTexture.realWidth; + page.height = baseTexture.realHeight; + page.baseTexture = baseTexture; + page.minFilter = page.magFilter = core.TextureFilter.Nearest; + page.uWrap = core.TextureWrap.ClampToEdge; + page.vWrap = core.TextureWrap.ClampToEdge; + pages.push(page); + } + var region = new TextureAtlasRegion(); + region.name = name; + region.page = page; + region.texture = texture; + region.index = -1; + this.regions.push(region); + return region; + }; + TextureAtlas.prototype.addTextureHash = function (textures, stripExtension) { + for (var key in textures) { + if (textures.hasOwnProperty(key)) { + this.addTexture( + stripExtension && key.indexOf('.') !== -1 ? key.substr(0, key.lastIndexOf('.')) : key, + textures[key], + ); + } + } + }; + TextureAtlas.prototype.addSpineAtlas = function (atlasText, textureLoader, callback) { + return this.load(atlasText, textureLoader, callback); + }; + TextureAtlas.prototype.load = function (atlasText, textureLoader, callback) { + var _this = this; + if (textureLoader == null) throw new Error('textureLoader cannot be null.'); + var reader = new TextureAtlasReader(atlasText); + var tuple = new Array(4); + var page = null; + var iterateParser = function () { + while (true) { + var line = reader.readLine(); + if (line == null) { + return callback && callback(_this); + } + line = line.trim(); + if (line.length == 0) page = null; + else if (!page) { + page = new TextureAtlasPage(); + page.name = line; + if (reader.readTuple(tuple) == 2) { + page.width = parseInt(tuple[0]); + page.height = parseInt(tuple[1]); + reader.readTuple(tuple); + } + reader.readTuple(tuple); + page.minFilter = core.Texture.filterFromString(tuple[0]); + page.magFilter = core.Texture.filterFromString(tuple[1]); + var direction = reader.readValue(); + page.uWrap = core.TextureWrap.ClampToEdge; + page.vWrap = core.TextureWrap.ClampToEdge; + if (direction == 'x') page.uWrap = core.TextureWrap.Repeat; + else if (direction == 'y') page.vWrap = core.TextureWrap.Repeat; + else if (direction == 'xy') page.uWrap = page.vWrap = core.TextureWrap.Repeat; + textureLoader(line, function (texture) { + if (texture === null) { + _this.pages.splice(_this.pages.indexOf(page), 1); + return callback && callback(null); + } + page.baseTexture = texture; + if (!texture.hasLoaded) { + texture.width = page.width; + texture.height = page.height; + } + _this.pages.push(page); + page.setFilters(); + if (!page.width || !page.height) { + page.width = texture.realWidth; + page.height = texture.realHeight; + if (!page.width || !page.height) { + console.log( + 'ERROR spine atlas page ' + + page.name + + ': meshes wont work if you dont specify size in atlas (http://www.html5gamedevs.com/topic/18888-pixi-spines-and-meshes/?p=107121)', + ); + } + } + iterateParser(); + }); + _this.pages.push(page); + break; + } else { + var region = new TextureAtlasRegion(); + region.name = line; + region.page = page; + var rotateValue = reader.readValue(); + var rotate = 0; + if (rotateValue.toLocaleLowerCase() == 'true') { + rotate = 6; + } else if (rotateValue.toLocaleLowerCase() == 'false') { + rotate = 0; + } else { + rotate = ((720 - parseFloat(rotateValue)) % 360) / 45; + } + reader.readTuple(tuple); + var x = parseInt(tuple[0]); + var y = parseInt(tuple[1]); + reader.readTuple(tuple); + var width = parseInt(tuple[0]); + var height = parseInt(tuple[1]); + var resolution = page.baseTexture.resolution; + x /= resolution; + y /= resolution; + width /= resolution; + height /= resolution; + var swapWH = rotate % 4 != 0; + var frame = new PIXI.Rectangle(x, y, swapWH ? height : width, swapWH ? width : height); + if (reader.readTuple(tuple) == 4) { + if (reader.readTuple(tuple) == 4) { + reader.readTuple(tuple); + } + } + var originalWidth = parseInt(tuple[0]) / resolution; + var originalHeight = parseInt(tuple[1]) / resolution; + reader.readTuple(tuple); + var offsetX = parseInt(tuple[0]) / resolution; + var offsetY = parseInt(tuple[1]) / resolution; + var orig = new PIXI.Rectangle(0, 0, originalWidth, originalHeight); + var trim = new PIXI.Rectangle(offsetX, originalHeight - height - offsetY, width, height); + if (PIXI.VERSION[0] != '3') { + region.texture = new PIXI.Texture(region.page.baseTexture, frame, orig, trim, rotate); + } else { + var frame2 = new PIXI.Rectangle(x, y, width, height); + var crop = frame2.clone(); + trim.width = originalWidth; + trim.height = originalHeight; + region.texture = new PIXI.Texture(region.page.baseTexture, frame2, crop, trim, rotate); + } + region.index = parseInt(reader.readValue()); + region.texture._updateUvs(); + _this.regions.push(region); + } + } + }; + iterateParser(); + }; + TextureAtlas.prototype.findRegion = function (name) { + for (var i = 0; i < this.regions.length; i++) { + if (this.regions[i].name == name) { + return this.regions[i]; + } + } + return null; + }; + TextureAtlas.prototype.dispose = function () { + for (var i = 0; i < this.pages.length; i++) { + this.pages[i].baseTexture.dispose(); + } + }; + return TextureAtlas; + })(); + core.TextureAtlas = TextureAtlas; + var TextureAtlasReader = (function () { + function TextureAtlasReader(text) { + this.index = 0; + this.lines = text.split(/\r\n|\r|\n/); + } + TextureAtlasReader.prototype.readLine = function () { + if (this.index >= this.lines.length) return null; + return this.lines[this.index++]; + }; + TextureAtlasReader.prototype.readValue = function () { + var line = this.readLine(); + var colon = line.indexOf(':'); + if (colon == -1) throw new Error('Invalid line: ' + line); + return line.substring(colon + 1).trim(); + }; + TextureAtlasReader.prototype.readTuple = function (tuple) { + var line = this.readLine(); + var colon = line.indexOf(':'); + if (colon == -1) throw new Error('Invalid line: ' + line); + var i = 0, + lastMatch = colon + 1; + for (; i < 3; i++) { + var comma = line.indexOf(',', lastMatch); + if (comma == -1) break; + tuple[i] = line.substr(lastMatch, comma - lastMatch).trim(); + lastMatch = comma + 1; + } + tuple[i] = line.substring(lastMatch).trim(); + return i + 1; + }; + return TextureAtlasReader; + })(); + var TextureAtlasPage = (function () { + function TextureAtlasPage() {} + TextureAtlasPage.prototype.setFilters = function () { + var tex = this.baseTexture; + var filter = this.minFilter; + if (filter == core.TextureFilter.Linear) { + tex.scaleMode = PIXI.SCALE_MODES.LINEAR; + } else if (this.minFilter == core.TextureFilter.Nearest) { + tex.scaleMode = PIXI.SCALE_MODES.NEAREST; + } else { + tex.mipmap = true; + if (filter == core.TextureFilter.MipMapNearestNearest) { + tex.scaleMode = PIXI.SCALE_MODES.NEAREST; + } else { + tex.scaleMode = PIXI.SCALE_MODES.LINEAR; + } + } + }; + return TextureAtlasPage; + })(); + core.TextureAtlasPage = TextureAtlasPage; + var TextureAtlasRegion = (function (_super) { + __extends(TextureAtlasRegion, _super); + function TextureAtlasRegion() { + return (_super !== null && _super.apply(this, arguments)) || this; + } + return TextureAtlasRegion; + })(core.TextureRegion); + core.TextureAtlasRegion = TextureAtlasRegion; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var TransformConstraint = (function () { + function TransformConstraint(data, skeleton) { + this.rotateMix = 0; + this.translateMix = 0; + this.scaleMix = 0; + this.shearMix = 0; + this.temp = new core.Vector2(); + this.active = false; + if (data == null) throw new Error('data cannot be null.'); + if (skeleton == null) throw new Error('skeleton cannot be null.'); + this.data = data; + this.rotateMix = data.rotateMix; + this.translateMix = data.translateMix; + this.scaleMix = data.scaleMix; + this.shearMix = data.shearMix; + this.bones = new Array(); + for (var i = 0; i < data.bones.length; i++) this.bones.push(skeleton.findBone(data.bones[i].name)); + this.target = skeleton.findBone(data.target.name); + } + TransformConstraint.prototype.isActive = function () { + return this.active; + }; + TransformConstraint.prototype.apply = function () { + this.update(); + }; + TransformConstraint.prototype.update = function () { + if (this.data.local) { + if (this.data.relative) this.applyRelativeLocal(); + else this.applyAbsoluteLocal(); + } else { + if (this.data.relative) this.applyRelativeWorld(); + else this.applyAbsoluteWorld(); + } + }; + TransformConstraint.prototype.applyAbsoluteWorld = function () { + var rotateMix = this.rotateMix, + translateMix = this.translateMix, + scaleMix = this.scaleMix, + shearMix = this.shearMix; + var target = this.target; + var targetMat = target.matrix; + var ta = targetMat.a, + tb = targetMat.c, + tc = targetMat.b, + td = targetMat.d; + var degRadReflect = ta * td - tb * tc > 0 ? core.MathUtils.degRad : -core.MathUtils.degRad; + var offsetRotation = this.data.offsetRotation * degRadReflect; + var offsetShearY = this.data.offsetShearY * degRadReflect; + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + var modified = false; + var mat = bone.matrix; + if (rotateMix != 0) { + var a = mat.a, + b = mat.c, + c = mat.b, + d = mat.d; + var r = Math.atan2(tc, ta) - Math.atan2(c, a) + offsetRotation; + if (r > core.MathUtils.PI) r -= core.MathUtils.PI2; + else if (r < -core.MathUtils.PI) r += core.MathUtils.PI2; + r *= rotateMix; + var cos = Math.cos(r), + sin = Math.sin(r); + mat.a = cos * a - sin * c; + mat.c = cos * b - sin * d; + mat.b = sin * a + cos * c; + mat.d = sin * b + cos * d; + modified = true; + } + if (translateMix != 0) { + var temp = this.temp; + target.localToWorld(temp.set(this.data.offsetX, this.data.offsetY)); + mat.tx += (temp.x - mat.tx) * translateMix; + mat.ty += (temp.y - mat.ty) * translateMix; + modified = true; + } + if (scaleMix > 0) { + var s = Math.sqrt(mat.a * mat.a + mat.b * mat.b); + var ts = Math.sqrt(ta * ta + tc * tc); + if (s > 0.00001) s = (s + (ts - s + this.data.offsetScaleX) * scaleMix) / s; + mat.a *= s; + mat.b *= s; + s = Math.sqrt(mat.c * mat.c + mat.d * mat.d); + ts = Math.sqrt(tb * tb + td * td); + if (s > 0.00001) s = (s + (ts - s + this.data.offsetScaleY) * scaleMix) / s; + mat.c *= s; + mat.d *= s; + modified = true; + } + if (shearMix > 0) { + var b = mat.c, + d = mat.d; + var by = Math.atan2(d, b); + var r = Math.atan2(td, tb) - Math.atan2(tc, ta) - (by - Math.atan2(mat.b, mat.a)); + if (r > core.MathUtils.PI) r -= core.MathUtils.PI2; + else if (r < -core.MathUtils.PI) r += core.MathUtils.PI2; + r = by + (r + offsetShearY) * shearMix; + var s = Math.sqrt(b * b + d * d); + mat.c = Math.cos(r) * s; + mat.d = Math.sin(r) * s; + modified = true; + } + if (modified) bone.appliedValid = false; + } + }; + TransformConstraint.prototype.applyRelativeWorld = function () { + var rotateMix = this.rotateMix, + translateMix = this.translateMix, + scaleMix = this.scaleMix, + shearMix = this.shearMix; + var target = this.target; + var targetMat = target.matrix; + var ta = targetMat.a, + tb = targetMat.c, + tc = targetMat.b, + td = targetMat.d; + var degRadReflect = ta * td - tb * tc > 0 ? core.MathUtils.degRad : -core.MathUtils.degRad; + var offsetRotation = this.data.offsetRotation * degRadReflect, + offsetShearY = this.data.offsetShearY * degRadReflect; + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + var modified = false; + var mat = bone.matrix; + if (rotateMix != 0) { + var a = mat.a, + b = mat.c, + c = mat.b, + d = mat.d; + var r = Math.atan2(tc, ta) + offsetRotation; + if (r > core.MathUtils.PI) r -= core.MathUtils.PI2; + else if (r < -core.MathUtils.PI) r += core.MathUtils.PI2; + r *= rotateMix; + var cos = Math.cos(r), + sin = Math.sin(r); + mat.a = cos * a - sin * c; + mat.c = cos * b - sin * d; + mat.b = sin * a + cos * c; + mat.d = sin * b + cos * d; + modified = true; + } + if (translateMix != 0) { + var temp = this.temp; + target.localToWorld(temp.set(this.data.offsetX, this.data.offsetY)); + mat.tx += temp.x * translateMix; + mat.ty += temp.y * translateMix; + modified = true; + } + if (scaleMix > 0) { + var s = (Math.sqrt(ta * ta + tc * tc) - 1 + this.data.offsetScaleX) * scaleMix + 1; + mat.a *= s; + mat.b *= s; + s = (Math.sqrt(tb * tb + td * td) - 1 + this.data.offsetScaleY) * scaleMix + 1; + mat.c *= s; + mat.d *= s; + modified = true; + } + if (shearMix > 0) { + var r = Math.atan2(td, tb) - Math.atan2(tc, ta); + if (r > core.MathUtils.PI) r -= core.MathUtils.PI2; + else if (r < -core.MathUtils.PI) r += core.MathUtils.PI2; + var b = mat.c, + d = mat.d; + r = Math.atan2(d, b) + (r - core.MathUtils.PI / 2 + offsetShearY) * shearMix; + var s = Math.sqrt(b * b + d * d); + mat.c = Math.cos(r) * s; + mat.d = Math.sin(r) * s; + modified = true; + } + if (modified) bone.appliedValid = false; + } + }; + TransformConstraint.prototype.applyAbsoluteLocal = function () { + var rotateMix = this.rotateMix, + translateMix = this.translateMix, + scaleMix = this.scaleMix, + shearMix = this.shearMix; + var target = this.target; + if (!target.appliedValid) target.updateAppliedTransform(); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (!bone.appliedValid) bone.updateAppliedTransform(); + var rotation = bone.arotation; + if (rotateMix != 0) { + var r = target.arotation - rotation + this.data.offsetRotation; + r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; + rotation += r * rotateMix; + } + var x = bone.ax, + y = bone.ay; + if (translateMix != 0) { + x += (target.ax - x + this.data.offsetX) * translateMix; + y += (target.ay - y + this.data.offsetY) * translateMix; + } + var scaleX = bone.ascaleX, + scaleY = bone.ascaleY; + if (scaleMix > 0) { + if (scaleX > 0.00001) + scaleX = (scaleX + (target.ascaleX - scaleX + this.data.offsetScaleX) * scaleMix) / scaleX; + if (scaleY > 0.00001) + scaleY = (scaleY + (target.ascaleY - scaleY + this.data.offsetScaleY) * scaleMix) / scaleY; + } + var shearY = bone.ashearY; + if (shearMix > 0) { + var r = target.ashearY - shearY + this.data.offsetShearY; + r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; + bone.shearY += r * shearMix; + } + bone.updateWorldTransformWith(x, y, rotation, scaleX, scaleY, bone.ashearX, shearY); + } + }; + TransformConstraint.prototype.applyRelativeLocal = function () { + var rotateMix = this.rotateMix, + translateMix = this.translateMix, + scaleMix = this.scaleMix, + shearMix = this.shearMix; + var target = this.target; + if (!target.appliedValid) target.updateAppliedTransform(); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (!bone.appliedValid) bone.updateAppliedTransform(); + var rotation = bone.arotation; + if (rotateMix != 0) rotation += (target.arotation + this.data.offsetRotation) * rotateMix; + var x = bone.ax, + y = bone.ay; + if (translateMix != 0) { + x += (target.ax + this.data.offsetX) * translateMix; + y += (target.ay + this.data.offsetY) * translateMix; + } + var scaleX = bone.ascaleX, + scaleY = bone.ascaleY; + if (scaleMix > 0) { + if (scaleX > 0.00001) scaleX *= (target.ascaleX - 1 + this.data.offsetScaleX) * scaleMix + 1; + if (scaleY > 0.00001) scaleY *= (target.ascaleY - 1 + this.data.offsetScaleY) * scaleMix + 1; + } + var shearY = bone.ashearY; + if (shearMix > 0) shearY += (target.ashearY + this.data.offsetShearY) * shearMix; + bone.updateWorldTransformWith(x, y, rotation, scaleX, scaleY, bone.ashearX, shearY); + } + }; + return TransformConstraint; + })(); + core.TransformConstraint = TransformConstraint; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var TransformConstraintData = (function (_super) { + __extends(TransformConstraintData, _super); + function TransformConstraintData(name) { + var _this = _super.call(this, name, 0, false) || this; + _this.bones = new Array(); + _this.rotateMix = 0; + _this.translateMix = 0; + _this.scaleMix = 0; + _this.shearMix = 0; + _this.offsetRotation = 0; + _this.offsetX = 0; + _this.offsetY = 0; + _this.offsetScaleX = 0; + _this.offsetScaleY = 0; + _this.offsetShearY = 0; + _this.relative = false; + _this.local = false; + return _this; + } + return TransformConstraintData; + })(core.ConstraintData); + core.TransformConstraintData = TransformConstraintData; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var Triangulator = (function () { + function Triangulator() { + this.convexPolygons = new Array(); + this.convexPolygonsIndices = new Array(); + this.indicesArray = new Array(); + this.isConcaveArray = new Array(); + this.triangles = new Array(); + this.polygonPool = new core.Pool(function () { + return new Array(); + }); + this.polygonIndicesPool = new core.Pool(function () { + return new Array(); + }); + } + Triangulator.prototype.triangulate = function (verticesArray) { + var vertices = verticesArray; + var vertexCount = verticesArray.length >> 1; + var indices = this.indicesArray; + indices.length = 0; + for (var i = 0; i < vertexCount; i++) indices[i] = i; + var isConcave = this.isConcaveArray; + isConcave.length = 0; + for (var i = 0, n = vertexCount; i < n; ++i) + isConcave[i] = Triangulator.isConcave(i, vertexCount, vertices, indices); + var triangles = this.triangles; + triangles.length = 0; + while (vertexCount > 3) { + var previous = vertexCount - 1, + i = 0, + next = 1; + while (true) { + outer: if (!isConcave[i]) { + var p1 = indices[previous] << 1, + p2 = indices[i] << 1, + p3 = indices[next] << 1; + var p1x = vertices[p1], + p1y = vertices[p1 + 1]; + var p2x = vertices[p2], + p2y = vertices[p2 + 1]; + var p3x = vertices[p3], + p3y = vertices[p3 + 1]; + for (var ii = (next + 1) % vertexCount; ii != previous; ii = (ii + 1) % vertexCount) { + if (!isConcave[ii]) continue; + var v = indices[ii] << 1; + var vx = vertices[v], + vy = vertices[v + 1]; + if (Triangulator.positiveArea(p3x, p3y, p1x, p1y, vx, vy)) { + if (Triangulator.positiveArea(p1x, p1y, p2x, p2y, vx, vy)) { + if (Triangulator.positiveArea(p2x, p2y, p3x, p3y, vx, vy)) break outer; + } + } + } + break; + } + if (next == 0) { + do { + if (!isConcave[i]) break; + i--; + } while (i > 0); + break; + } + previous = i; + i = next; + next = (next + 1) % vertexCount; + } + triangles.push(indices[(vertexCount + i - 1) % vertexCount]); + triangles.push(indices[i]); + triangles.push(indices[(i + 1) % vertexCount]); + indices.splice(i, 1); + isConcave.splice(i, 1); + vertexCount--; + var previousIndex = (vertexCount + i - 1) % vertexCount; + var nextIndex = i == vertexCount ? 0 : i; + isConcave[previousIndex] = Triangulator.isConcave(previousIndex, vertexCount, vertices, indices); + isConcave[nextIndex] = Triangulator.isConcave(nextIndex, vertexCount, vertices, indices); + } + if (vertexCount == 3) { + triangles.push(indices[2]); + triangles.push(indices[0]); + triangles.push(indices[1]); + } + return triangles; + }; + Triangulator.prototype.decompose = function (verticesArray, triangles) { + var vertices = verticesArray; + var convexPolygons = this.convexPolygons; + this.polygonPool.freeAll(convexPolygons); + convexPolygons.length = 0; + var convexPolygonsIndices = this.convexPolygonsIndices; + this.polygonIndicesPool.freeAll(convexPolygonsIndices); + convexPolygonsIndices.length = 0; + var polygonIndices = this.polygonIndicesPool.obtain(); + polygonIndices.length = 0; + var polygon = this.polygonPool.obtain(); + polygon.length = 0; + var fanBaseIndex = -1, + lastWinding = 0; + for (var i = 0, n = triangles.length; i < n; i += 3) { + var t1 = triangles[i] << 1, + t2 = triangles[i + 1] << 1, + t3 = triangles[i + 2] << 1; + var x1 = vertices[t1], + y1 = vertices[t1 + 1]; + var x2 = vertices[t2], + y2 = vertices[t2 + 1]; + var x3 = vertices[t3], + y3 = vertices[t3 + 1]; + var merged = false; + if (fanBaseIndex == t1) { + var o = polygon.length - 4; + var winding1 = Triangulator.winding(polygon[o], polygon[o + 1], polygon[o + 2], polygon[o + 3], x3, y3); + var winding2 = Triangulator.winding(x3, y3, polygon[0], polygon[1], polygon[2], polygon[3]); + if (winding1 == lastWinding && winding2 == lastWinding) { + polygon.push(x3); + polygon.push(y3); + polygonIndices.push(t3); + merged = true; + } + } + if (!merged) { + if (polygon.length > 0) { + convexPolygons.push(polygon); + convexPolygonsIndices.push(polygonIndices); + } else { + this.polygonPool.free(polygon); + this.polygonIndicesPool.free(polygonIndices); + } + polygon = this.polygonPool.obtain(); + polygon.length = 0; + polygon.push(x1); + polygon.push(y1); + polygon.push(x2); + polygon.push(y2); + polygon.push(x3); + polygon.push(y3); + polygonIndices = this.polygonIndicesPool.obtain(); + polygonIndices.length = 0; + polygonIndices.push(t1); + polygonIndices.push(t2); + polygonIndices.push(t3); + lastWinding = Triangulator.winding(x1, y1, x2, y2, x3, y3); + fanBaseIndex = t1; + } + } + if (polygon.length > 0) { + convexPolygons.push(polygon); + convexPolygonsIndices.push(polygonIndices); + } + for (var i = 0, n = convexPolygons.length; i < n; i++) { + polygonIndices = convexPolygonsIndices[i]; + if (polygonIndices.length == 0) continue; + var firstIndex = polygonIndices[0]; + var lastIndex = polygonIndices[polygonIndices.length - 1]; + polygon = convexPolygons[i]; + var o = polygon.length - 4; + var prevPrevX = polygon[o], + prevPrevY = polygon[o + 1]; + var prevX = polygon[o + 2], + prevY = polygon[o + 3]; + var firstX = polygon[0], + firstY = polygon[1]; + var secondX = polygon[2], + secondY = polygon[3]; + var winding = Triangulator.winding(prevPrevX, prevPrevY, prevX, prevY, firstX, firstY); + for (var ii = 0; ii < n; ii++) { + if (ii == i) continue; + var otherIndices = convexPolygonsIndices[ii]; + if (otherIndices.length != 3) continue; + var otherFirstIndex = otherIndices[0]; + var otherSecondIndex = otherIndices[1]; + var otherLastIndex = otherIndices[2]; + var otherPoly = convexPolygons[ii]; + var x3 = otherPoly[otherPoly.length - 2], + y3 = otherPoly[otherPoly.length - 1]; + if (otherFirstIndex != firstIndex || otherSecondIndex != lastIndex) continue; + var winding1 = Triangulator.winding(prevPrevX, prevPrevY, prevX, prevY, x3, y3); + var winding2 = Triangulator.winding(x3, y3, firstX, firstY, secondX, secondY); + if (winding1 == winding && winding2 == winding) { + otherPoly.length = 0; + otherIndices.length = 0; + polygon.push(x3); + polygon.push(y3); + polygonIndices.push(otherLastIndex); + prevPrevX = prevX; + prevPrevY = prevY; + prevX = x3; + prevY = y3; + ii = 0; + } + } + } + for (var i = convexPolygons.length - 1; i >= 0; i--) { + polygon = convexPolygons[i]; + if (polygon.length == 0) { + convexPolygons.splice(i, 1); + this.polygonPool.free(polygon); + polygonIndices = convexPolygonsIndices[i]; + convexPolygonsIndices.splice(i, 1); + this.polygonIndicesPool.free(polygonIndices); + } + } + return convexPolygons; + }; + Triangulator.isConcave = function (index, vertexCount, vertices, indices) { + var previous = indices[(vertexCount + index - 1) % vertexCount] << 1; + var current = indices[index] << 1; + var next = indices[(index + 1) % vertexCount] << 1; + return !this.positiveArea( + vertices[previous], + vertices[previous + 1], + vertices[current], + vertices[current + 1], + vertices[next], + vertices[next + 1], + ); + }; + Triangulator.positiveArea = function (p1x, p1y, p2x, p2y, p3x, p3y) { + return p1x * (p3y - p2y) + p2x * (p1y - p3y) + p3x * (p2y - p1y) >= 0; + }; + Triangulator.winding = function (p1x, p1y, p2x, p2y, p3x, p3y) { + var px = p2x - p1x, + py = p2y - p1y; + return p3x * py - p3y * px + px * p1y - p1x * py >= 0 ? 1 : -1; + }; + return Triangulator; + })(); + core.Triangulator = Triangulator; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var IntSet = (function () { + function IntSet() { + this.array = new Array(); + } + IntSet.prototype.add = function (value) { + var contains = this.contains(value); + this.array[value | 0] = value | 0; + return !contains; + }; + IntSet.prototype.contains = function (value) { + return this.array[value | 0] != undefined; + }; + IntSet.prototype.remove = function (value) { + this.array[value | 0] = undefined; + }; + IntSet.prototype.clear = function () { + this.array.length = 0; + }; + return IntSet; + })(); + core.IntSet = IntSet; + var Color = (function () { + function Color(r, g, b, a) { + if (r === void 0) { + r = 0; + } + if (g === void 0) { + g = 0; + } + if (b === void 0) { + b = 0; + } + if (a === void 0) { + a = 0; + } + this.r = r; + this.g = g; + this.b = b; + this.a = a; + } + Color.prototype.set = function (r, g, b, a) { + this.r = r; + this.g = g; + this.b = b; + this.a = a; + this.clamp(); + return this; + }; + Color.prototype.setFromColor = function (c) { + this.r = c.r; + this.g = c.g; + this.b = c.b; + this.a = c.a; + return this; + }; + Color.prototype.setFromString = function (hex) { + hex = hex.charAt(0) == '#' ? hex.substr(1) : hex; + this.r = parseInt(hex.substr(0, 2), 16) / 255.0; + this.g = parseInt(hex.substr(2, 2), 16) / 255.0; + this.b = parseInt(hex.substr(4, 2), 16) / 255.0; + this.a = (hex.length != 8 ? 255 : parseInt(hex.substr(6, 2), 16)) / 255.0; + return this; + }; + Color.prototype.add = function (r, g, b, a) { + this.r += r; + this.g += g; + this.b += b; + this.a += a; + this.clamp(); + return this; + }; + Color.prototype.clamp = function () { + if (this.r < 0) this.r = 0; + else if (this.r > 1) this.r = 1; + if (this.g < 0) this.g = 0; + else if (this.g > 1) this.g = 1; + if (this.b < 0) this.b = 0; + else if (this.b > 1) this.b = 1; + if (this.a < 0) this.a = 0; + else if (this.a > 1) this.a = 1; + return this; + }; + Color.rgba8888ToColor = function (color, value) { + color.r = ((value & 0xff000000) >>> 24) / 255; + color.g = ((value & 0x00ff0000) >>> 16) / 255; + color.b = ((value & 0x0000ff00) >>> 8) / 255; + color.a = (value & 0x000000ff) / 255; + }; + Color.rgb888ToColor = function (color, value) { + color.r = ((value & 0x00ff0000) >>> 16) / 255; + color.g = ((value & 0x0000ff00) >>> 8) / 255; + color.b = (value & 0x000000ff) / 255; + }; + Color.WHITE = new Color(1, 1, 1, 1); + Color.RED = new Color(1, 0, 0, 1); + Color.GREEN = new Color(0, 1, 0, 1); + Color.BLUE = new Color(0, 0, 1, 1); + Color.MAGENTA = new Color(1, 0, 1, 1); + return Color; + })(); + core.Color = Color; + var MathUtils = (function () { + function MathUtils() {} + MathUtils.clamp = function (value, min, max) { + if (value < min) return min; + if (value > max) return max; + return value; + }; + MathUtils.cosDeg = function (degrees) { + return Math.cos(degrees * MathUtils.degRad); + }; + MathUtils.sinDeg = function (degrees) { + return Math.sin(degrees * MathUtils.degRad); + }; + MathUtils.signum = function (value) { + return value > 0 ? 1 : value < 0 ? -1 : 0; + }; + MathUtils.toInt = function (x) { + return x > 0 ? Math.floor(x) : Math.ceil(x); + }; + MathUtils.cbrt = function (x) { + var y = Math.pow(Math.abs(x), 1 / 3); + return x < 0 ? -y : y; + }; + MathUtils.randomTriangular = function (min, max) { + return MathUtils.randomTriangularWith(min, max, (min + max) * 0.5); + }; + MathUtils.randomTriangularWith = function (min, max, mode) { + var u = Math.random(); + var d = max - min; + if (u <= (mode - min) / d) return min + Math.sqrt(u * d * (mode - min)); + return max - Math.sqrt((1 - u) * d * (max - mode)); + }; + MathUtils.PI = 3.1415927; + MathUtils.PI2 = MathUtils.PI * 2; + MathUtils.radiansToDegrees = 180 / MathUtils.PI; + MathUtils.radDeg = MathUtils.radiansToDegrees; + MathUtils.degreesToRadians = MathUtils.PI / 180; + MathUtils.degRad = MathUtils.degreesToRadians; + return MathUtils; + })(); + core.MathUtils = MathUtils; + var Interpolation = (function () { + function Interpolation() {} + Interpolation.prototype.apply = function (start, end, a) { + return start + (end - start) * this.applyInternal(a); + }; + return Interpolation; + })(); + core.Interpolation = Interpolation; + var Pow = (function (_super) { + __extends(Pow, _super); + function Pow(power) { + var _this = _super.call(this) || this; + _this.power = 2; + _this.power = power; + return _this; + } + Pow.prototype.applyInternal = function (a) { + if (a <= 0.5) return Math.pow(a * 2, this.power) / 2; + return Math.pow((a - 1) * 2, this.power) / (this.power % 2 == 0 ? -2 : 2) + 1; + }; + return Pow; + })(Interpolation); + core.Pow = Pow; + var PowOut = (function (_super) { + __extends(PowOut, _super); + function PowOut(power) { + return _super.call(this, power) || this; + } + PowOut.prototype.applyInternal = function (a) { + return Math.pow(a - 1, this.power) * (this.power % 2 == 0 ? -1 : 1) + 1; + }; + return PowOut; + })(Pow); + core.PowOut = PowOut; + var Utils = (function () { + function Utils() {} + Utils.arrayCopy = function (source, sourceStart, dest, destStart, numElements) { + for (var i = sourceStart, j = destStart; i < sourceStart + numElements; i++, j++) { + dest[j] = source[i]; + } + }; + Utils.setArraySize = function (array, size, value) { + if (value === void 0) { + value = 0; + } + var oldSize = array.length; + if (oldSize == size) return array; + array.length = size; + if (oldSize < size) { + for (var i = oldSize; i < size; i++) array[i] = value; + } + return array; + }; + Utils.ensureArrayCapacity = function (array, size, value) { + if (value === void 0) { + value = 0; + } + if (array.length >= size) return array; + return Utils.setArraySize(array, size, value); + }; + Utils.newArray = function (size, defaultValue) { + var array = new Array(size); + for (var i = 0; i < size; i++) array[i] = defaultValue; + return array; + }; + Utils.newFloatArray = function (size) { + if (Utils.SUPPORTS_TYPED_ARRAYS) { + return new Float32Array(size); + } else { + var array = new Array(size); + for (var i = 0; i < array.length; i++) array[i] = 0; + return array; + } + }; + Utils.newShortArray = function (size) { + if (Utils.SUPPORTS_TYPED_ARRAYS) { + return new Int16Array(size); + } else { + var array = new Array(size); + for (var i = 0; i < array.length; i++) array[i] = 0; + return array; + } + }; + Utils.toFloatArray = function (array) { + return Utils.SUPPORTS_TYPED_ARRAYS ? new Float32Array(array) : array; + }; + Utils.toSinglePrecision = function (value) { + return Utils.SUPPORTS_TYPED_ARRAYS ? Math.fround(value) : value; + }; + Utils.webkit602BugfixHelper = function (alpha, blend) {}; + Utils.contains = function (array, element, identity) { + if (identity === void 0) { + identity = true; + } + for (var i = 0; i < array.length; i++) { + if (array[i] == element) return true; + } + return false; + }; + Utils.SUPPORTS_TYPED_ARRAYS = typeof Float32Array !== 'undefined'; + return Utils; + })(); + core.Utils = Utils; + var DebugUtils = (function () { + function DebugUtils() {} + DebugUtils.logBones = function (skeleton) { + for (var i = 0; i < skeleton.bones.length; i++) { + var bone = skeleton.bones[i]; + var mat = bone.matrix; + console.log( + bone.data.name + ', ' + mat.a + ', ' + mat.b + ', ' + mat.c + ', ' + mat.d + ', ' + mat.tx + ', ' + mat.ty, + ); + } + }; + return DebugUtils; + })(); + core.DebugUtils = DebugUtils; + var Pool = (function () { + function Pool(instantiator) { + this.items = new Array(); + this.instantiator = instantiator; + } + Pool.prototype.obtain = function () { + return this.items.length > 0 ? this.items.pop() : this.instantiator(); + }; + Pool.prototype.free = function (item) { + if (item.reset) item.reset(); + this.items.push(item); + }; + Pool.prototype.freeAll = function (items) { + for (var i = 0; i < items.length; i++) { + this.free(items[i]); + } + }; + Pool.prototype.clear = function () { + this.items.length = 0; + }; + return Pool; + })(); + core.Pool = Pool; + var Vector2 = (function () { + function Vector2(x, y) { + if (x === void 0) { + x = 0; + } + if (y === void 0) { + y = 0; + } + this.x = x; + this.y = y; + } + Vector2.prototype.set = function (x, y) { + this.x = x; + this.y = y; + return this; + }; + Vector2.prototype.length = function () { + var x = this.x; + var y = this.y; + return Math.sqrt(x * x + y * y); + }; + Vector2.prototype.normalize = function () { + var len = this.length(); + if (len != 0) { + this.x /= len; + this.y /= len; + } + return this; + }; + return Vector2; + })(); + core.Vector2 = Vector2; + var TimeKeeper = (function () { + function TimeKeeper() { + this.maxDelta = 0.064; + this.framesPerSecond = 0; + this.delta = 0; + this.totalTime = 0; + this.lastTime = Date.now() / 1000; + this.frameCount = 0; + this.frameTime = 0; + } + TimeKeeper.prototype.update = function () { + var now = Date.now() / 1000; + this.delta = now - this.lastTime; + this.frameTime += this.delta; + this.totalTime += this.delta; + if (this.delta > this.maxDelta) this.delta = this.maxDelta; + this.lastTime = now; + this.frameCount++; + if (this.frameTime > 1) { + this.framesPerSecond = this.frameCount / this.frameTime; + this.frameTime = 0; + this.frameCount = 0; + } + }; + return TimeKeeper; + })(); + core.TimeKeeper = TimeKeeper; + var WindowedMean = (function () { + function WindowedMean(windowSize) { + if (windowSize === void 0) { + windowSize = 32; + } + this.addedValues = 0; + this.lastValue = 0; + this.mean = 0; + this.dirty = true; + this.values = new Array(windowSize); + } + WindowedMean.prototype.hasEnoughData = function () { + return this.addedValues >= this.values.length; + }; + WindowedMean.prototype.addValue = function (value) { + if (this.addedValues < this.values.length) this.addedValues++; + this.values[this.lastValue++] = value; + if (this.lastValue > this.values.length - 1) this.lastValue = 0; + this.dirty = true; + }; + WindowedMean.prototype.getMean = function () { + if (this.hasEnoughData()) { + if (this.dirty) { + var mean = 0; + for (var i = 0; i < this.values.length; i++) { + mean += this.values[i]; + } + this.mean = mean / this.values.length; + this.dirty = false; + } + return this.mean; + } else { + return 0; + } + }; + return WindowedMean; + })(); + core.WindowedMean = WindowedMean; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var Attachment = (function () { + function Attachment(name) { + if (name == null) throw new Error('name cannot be null.'); + this.name = name; + } + return Attachment; + })(); + core.Attachment = Attachment; + var VertexAttachment = (function (_super) { + __extends(VertexAttachment, _super); + function VertexAttachment(name) { + var _this = _super.call(this, name) || this; + _this.id = (VertexAttachment.nextID++ & 65535) << 11; + _this.worldVerticesLength = 0; + _this.deformAttachment = _this; + return _this; + } + VertexAttachment.prototype.computeWorldVerticesOld = function (slot, worldVertices) { + this.computeWorldVertices(slot, 0, this.worldVerticesLength, worldVertices, 0, 2); + }; + VertexAttachment.prototype.computeWorldVertices = function (slot, start, count, worldVertices, offset, stride) { + count = offset + (count >> 1) * stride; + var skeleton = slot.bone.skeleton; + var deformArray = slot.deform; + var vertices = this.vertices; + var bones = this.bones; + if (bones == null) { + if (deformArray.length > 0) vertices = deformArray; + var mat = slot.bone.matrix; + var x = mat.tx; + var y = mat.ty; + var a = mat.a, + b = mat.c, + c = mat.b, + d = mat.d; + for (var v_1 = start, w = offset; w < count; v_1 += 2, w += stride) { + var vx = vertices[v_1], + vy = vertices[v_1 + 1]; + worldVertices[w] = vx * a + vy * b + x; + worldVertices[w + 1] = vx * c + vy * d + y; + } + return; + } + var v = 0, + skip = 0; + for (var i = 0; i < start; i += 2) { + var n = bones[v]; + v += n + 1; + skip += n; + } + var skeletonBones = skeleton.bones; + if (deformArray.length == 0) { + for (var w = offset, b = skip * 3; w < count; w += stride) { + var wx = 0, + wy = 0; + var n = bones[v++]; + n += v; + for (; v < n; v++, b += 3) { + var mat = skeletonBones[bones[v]].matrix; + var vx = vertices[b], + vy = vertices[b + 1], + weight = vertices[b + 2]; + wx += (vx * mat.a + vy * mat.c + mat.tx) * weight; + wy += (vx * mat.b + vy * mat.d + mat.ty) * weight; + } + worldVertices[w] = wx; + worldVertices[w + 1] = wy; + } + } else { + var deform = deformArray; + for (var w = offset, b = skip * 3, f = skip << 1; w < count; w += stride) { + var wx = 0, + wy = 0; + var n = bones[v++]; + n += v; + for (; v < n; v++, b += 3, f += 2) { + var mat = skeletonBones[bones[v]].matrix; + var vx = vertices[b] + deform[f], + vy = vertices[b + 1] + deform[f + 1], + weight = vertices[b + 2]; + wx += (vx * mat.a + vy * mat.c + mat.tx) * weight; + wy += (vx * mat.b + vy * mat.d + mat.ty) * weight; + } + worldVertices[w] = wx; + worldVertices[w + 1] = wy; + } + } + }; + VertexAttachment.prototype.copyTo = function (attachment) { + if (this.bones != null) { + attachment.bones = new Array(this.bones.length); + core.Utils.arrayCopy(this.bones, 0, attachment.bones, 0, this.bones.length); + } else attachment.bones = null; + if (this.vertices != null) { + attachment.vertices = core.Utils.newFloatArray(this.vertices.length); + core.Utils.arrayCopy(this.vertices, 0, attachment.vertices, 0, this.vertices.length); + } else attachment.vertices = null; + attachment.worldVerticesLength = this.worldVerticesLength; + attachment.deformAttachment = this.deformAttachment; + }; + VertexAttachment.nextID = 0; + return VertexAttachment; + })(Attachment); + core.VertexAttachment = VertexAttachment; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var AttachmentType; + (function (AttachmentType) { + AttachmentType[(AttachmentType['Region'] = 0)] = 'Region'; + AttachmentType[(AttachmentType['BoundingBox'] = 1)] = 'BoundingBox'; + AttachmentType[(AttachmentType['Mesh'] = 2)] = 'Mesh'; + AttachmentType[(AttachmentType['LinkedMesh'] = 3)] = 'LinkedMesh'; + AttachmentType[(AttachmentType['Path'] = 4)] = 'Path'; + AttachmentType[(AttachmentType['Point'] = 5)] = 'Point'; + AttachmentType[(AttachmentType['Clipping'] = 6)] = 'Clipping'; + })((AttachmentType = core.AttachmentType || (core.AttachmentType = {}))); + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var BoundingBoxAttachment = (function (_super) { + __extends(BoundingBoxAttachment, _super); + function BoundingBoxAttachment(name) { + var _this = _super.call(this, name) || this; + _this.color = new core.Color(1, 1, 1, 1); + return _this; + } + BoundingBoxAttachment.prototype.copy = function () { + var copy = new BoundingBoxAttachment(this.name); + this.copyTo(copy); + copy.color.setFromColor(this.color); + return copy; + }; + return BoundingBoxAttachment; + })(core.VertexAttachment); + core.BoundingBoxAttachment = BoundingBoxAttachment; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var ClippingAttachment = (function (_super) { + __extends(ClippingAttachment, _super); + function ClippingAttachment(name) { + var _this = _super.call(this, name) || this; + _this.color = new core.Color(0.2275, 0.2275, 0.8078, 1); + return _this; + } + ClippingAttachment.prototype.copy = function () { + var copy = new ClippingAttachment(this.name); + this.copyTo(copy); + copy.endSlot = this.endSlot; + copy.color.setFromColor(this.color); + return copy; + }; + return ClippingAttachment; + })(core.VertexAttachment); + core.ClippingAttachment = ClippingAttachment; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var MeshAttachment = (function (_super) { + __extends(MeshAttachment, _super); + function MeshAttachment(name) { + var _this = _super.call(this, name) || this; + _this.color = new core.Color(1, 1, 1, 1); + _this.tempColor = new core.Color(0, 0, 0, 0); + return _this; + } + MeshAttachment.prototype.updateUVs = function (region, uvs) { + var regionUVs = this.regionUVs; + var n = regionUVs.length; + if (!uvs || uvs.length != n) { + uvs = core.Utils.newFloatArray(n); + } + if (region == null) { + return; + } + var texture = region.texture; + var r = texture._uvs; + var w1 = region.width, + h1 = region.height, + w2 = region.originalWidth, + h2 = region.originalHeight; + var x = region.offsetX, + y = region.pixiOffsetY; + for (var i = 0; i < n; i += 2) { + var u = this.regionUVs[i], + v = this.regionUVs[i + 1]; + u = (u * w2 - x) / w1; + v = (v * h2 - y) / h1; + uvs[i] = (r.x0 * (1 - u) + r.x1 * u) * (1 - v) + (r.x3 * (1 - u) + r.x2 * u) * v; + uvs[i + 1] = (r.y0 * (1 - u) + r.y1 * u) * (1 - v) + (r.y3 * (1 - u) + r.y2 * u) * v; + } + return uvs; + }; + MeshAttachment.prototype.getParentMesh = function () { + return this.parentMesh; + }; + MeshAttachment.prototype.setParentMesh = function (parentMesh) { + this.parentMesh = parentMesh; + if (parentMesh != null) { + this.bones = parentMesh.bones; + this.vertices = parentMesh.vertices; + this.worldVerticesLength = parentMesh.worldVerticesLength; + this.regionUVs = parentMesh.regionUVs; + this.triangles = parentMesh.triangles; + this.hullLength = parentMesh.hullLength; + this.worldVerticesLength = parentMesh.worldVerticesLength; + } + }; + MeshAttachment.prototype.copy = function () { + if (this.parentMesh != null) return this.newLinkedMesh(); + var copy = new MeshAttachment(this.name); + copy.region = this.region; + copy.path = this.path; + copy.color.setFromColor(this.color); + this.copyTo(copy); + copy.regionUVs = new Float32Array(this.regionUVs.length); + core.Utils.arrayCopy(this.regionUVs, 0, copy.regionUVs, 0, this.regionUVs.length); + copy.uvs = new Array(this.uvs.length); + core.Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, this.uvs.length); + copy.triangles = new Array(this.triangles.length); + core.Utils.arrayCopy(this.triangles, 0, copy.triangles, 0, this.triangles.length); + copy.hullLength = this.hullLength; + if (this.edges != null) { + copy.edges = new Array(this.edges.length); + core.Utils.arrayCopy(this.edges, 0, copy.edges, 0, this.edges.length); + } + copy.width = this.width; + copy.height = this.height; + return copy; + }; + MeshAttachment.prototype.newLinkedMesh = function () { + var copy = new MeshAttachment(this.name); + copy.region = this.region; + copy.path = this.path; + copy.color.setFromColor(this.color); + copy.deformAttachment = this.deformAttachment; + copy.setParentMesh(this.parentMesh != null ? this.parentMesh : this); + return copy; + }; + return MeshAttachment; + })(core.VertexAttachment); + core.MeshAttachment = MeshAttachment; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var PathAttachment = (function (_super) { + __extends(PathAttachment, _super); + function PathAttachment(name) { + var _this = _super.call(this, name) || this; + _this.closed = false; + _this.constantSpeed = false; + _this.color = new core.Color(1, 1, 1, 1); + return _this; + } + PathAttachment.prototype.copy = function () { + var copy = new PathAttachment(this.name); + this.copyTo(copy); + copy.lengths = new Array(this.lengths.length); + core.Utils.arrayCopy(this.lengths, 0, copy.lengths, 0, this.lengths.length); + copy.closed = closed; + copy.constantSpeed = this.constantSpeed; + copy.color.setFromColor(this.color); + return copy; + }; + return PathAttachment; + })(core.VertexAttachment); + core.PathAttachment = PathAttachment; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var PointAttachment = (function (_super) { + __extends(PointAttachment, _super); + function PointAttachment(name) { + var _this = _super.call(this, name) || this; + _this.color = new core.Color(0.38, 0.94, 0, 1); + return _this; + } + PointAttachment.prototype.computeWorldPosition = function (bone, point) { + var mat = bone.matrix; + point.x = this.x * mat.a + this.y * mat.c + bone.worldX; + point.y = this.x * mat.b + this.y * mat.d + bone.worldY; + return point; + }; + PointAttachment.prototype.computeWorldRotation = function (bone) { + var mat = bone.matrix; + var cos = core.MathUtils.cosDeg(this.rotation), + sin = core.MathUtils.sinDeg(this.rotation); + var x = cos * mat.a + sin * mat.c; + var y = cos * mat.b + sin * mat.d; + return Math.atan2(y, x) * core.MathUtils.radDeg; + }; + PointAttachment.prototype.copy = function () { + var copy = new PointAttachment(this.name); + copy.x = this.x; + copy.y = this.y; + copy.rotation = this.rotation; + copy.color.setFromColor(this.color); + return copy; + }; + return PointAttachment; + })(core.VertexAttachment); + core.PointAttachment = PointAttachment; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var RegionAttachment = (function (_super) { + __extends(RegionAttachment, _super); + function RegionAttachment(name) { + var _this = _super.call(this, name) || this; + _this.x = 0; + _this.y = 0; + _this.scaleX = 1; + _this.scaleY = 1; + _this.rotation = 0; + _this.width = 0; + _this.height = 0; + _this.color = new core.Color(1, 1, 1, 1); + _this.offset = core.Utils.newFloatArray(8); + _this.uvs = core.Utils.newFloatArray(8); + _this.tempColor = new core.Color(1, 1, 1, 1); + return _this; + } + RegionAttachment.prototype.updateOffset = function () { + var regionScaleX = (this.width / this.region.originalWidth) * this.scaleX; + var regionScaleY = (this.height / this.region.originalHeight) * this.scaleY; + var localX = (-this.width / 2) * this.scaleX + this.region.offsetX * regionScaleX; + var localY = (-this.height / 2) * this.scaleY + this.region.offsetY * regionScaleY; + var localX2 = localX + this.region.width * regionScaleX; + var localY2 = localY + this.region.height * regionScaleY; + var radians = (this.rotation * Math.PI) / 180; + var cos = Math.cos(radians); + var sin = Math.sin(radians); + var localXCos = localX * cos + this.x; + var localXSin = localX * sin; + var localYCos = localY * cos + this.y; + var localYSin = localY * sin; + var localX2Cos = localX2 * cos + this.x; + var localX2Sin = localX2 * sin; + var localY2Cos = localY2 * cos + this.y; + var localY2Sin = localY2 * sin; + var offset = this.offset; + offset[RegionAttachment.OX1] = localXCos - localYSin; + offset[RegionAttachment.OY1] = localYCos + localXSin; + offset[RegionAttachment.OX2] = localXCos - localY2Sin; + offset[RegionAttachment.OY2] = localY2Cos + localXSin; + offset[RegionAttachment.OX3] = localX2Cos - localY2Sin; + offset[RegionAttachment.OY3] = localY2Cos + localX2Sin; + offset[RegionAttachment.OX4] = localX2Cos - localYSin; + offset[RegionAttachment.OY4] = localYCos + localX2Sin; + }; + RegionAttachment.prototype.setRegion = function (region) { + this.region = region; + var uvs = this.uvs; + if (region.rotate) { + uvs[2] = region.u; + uvs[3] = region.v2; + uvs[4] = region.u; + uvs[5] = region.v; + uvs[6] = region.u2; + uvs[7] = region.v; + uvs[0] = region.u2; + uvs[1] = region.v2; + } else { + uvs[0] = region.u; + uvs[1] = region.v2; + uvs[2] = region.u; + uvs[3] = region.v; + uvs[4] = region.u2; + uvs[5] = region.v; + uvs[6] = region.u2; + uvs[7] = region.v2; + } + }; + RegionAttachment.prototype.computeWorldVertices = function (bone, worldVertices, offset, stride) { + var vertexOffset = this.offset; + var mat = bone.matrix; + var x = mat.tx, + y = mat.ty; + var a = mat.a, + b = mat.c, + c = mat.b, + d = mat.d; + var offsetX = 0, + offsetY = 0; + offsetX = vertexOffset[RegionAttachment.OX1]; + offsetY = vertexOffset[RegionAttachment.OY1]; + worldVertices[offset] = offsetX * a + offsetY * b + x; + worldVertices[offset + 1] = offsetX * c + offsetY * d + y; + offset += stride; + offsetX = vertexOffset[RegionAttachment.OX2]; + offsetY = vertexOffset[RegionAttachment.OY2]; + worldVertices[offset] = offsetX * a + offsetY * b + x; + worldVertices[offset + 1] = offsetX * c + offsetY * d + y; + offset += stride; + offsetX = vertexOffset[RegionAttachment.OX3]; + offsetY = vertexOffset[RegionAttachment.OY3]; + worldVertices[offset] = offsetX * a + offsetY * b + x; + worldVertices[offset + 1] = offsetX * c + offsetY * d + y; + offset += stride; + offsetX = vertexOffset[RegionAttachment.OX4]; + offsetY = vertexOffset[RegionAttachment.OY4]; + worldVertices[offset] = offsetX * a + offsetY * b + x; + worldVertices[offset + 1] = offsetX * c + offsetY * d + y; + }; + RegionAttachment.prototype.copy = function () { + var copy = new RegionAttachment(this.name); + copy.region = this.region; + copy.rendererObject = this.rendererObject; + copy.path = this.path; + copy.x = this.x; + copy.y = this.y; + copy.scaleX = this.scaleX; + copy.scaleY = this.scaleY; + copy.rotation = this.rotation; + copy.width = this.width; + copy.height = this.height; + core.Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, 8); + core.Utils.arrayCopy(this.offset, 0, copy.offset, 0, 8); + copy.color.setFromColor(this.color); + return copy; + }; + RegionAttachment.OX1 = 0; + RegionAttachment.OY1 = 1; + RegionAttachment.OX2 = 2; + RegionAttachment.OY2 = 3; + RegionAttachment.OX3 = 4; + RegionAttachment.OY3 = 5; + RegionAttachment.OX4 = 6; + RegionAttachment.OY4 = 7; + RegionAttachment.X1 = 0; + RegionAttachment.Y1 = 1; + RegionAttachment.C1R = 2; + RegionAttachment.C1G = 3; + RegionAttachment.C1B = 4; + RegionAttachment.C1A = 5; + RegionAttachment.U1 = 6; + RegionAttachment.V1 = 7; + RegionAttachment.X2 = 8; + RegionAttachment.Y2 = 9; + RegionAttachment.C2R = 10; + RegionAttachment.C2G = 11; + RegionAttachment.C2B = 12; + RegionAttachment.C2A = 13; + RegionAttachment.U2 = 14; + RegionAttachment.V2 = 15; + RegionAttachment.X3 = 16; + RegionAttachment.Y3 = 17; + RegionAttachment.C3R = 18; + RegionAttachment.C3G = 19; + RegionAttachment.C3B = 20; + RegionAttachment.C3A = 21; + RegionAttachment.U3 = 22; + RegionAttachment.V3 = 23; + RegionAttachment.X4 = 24; + RegionAttachment.Y4 = 25; + RegionAttachment.C4R = 26; + RegionAttachment.C4G = 27; + RegionAttachment.C4B = 28; + RegionAttachment.C4A = 29; + RegionAttachment.U4 = 30; + RegionAttachment.V4 = 31; + return RegionAttachment; + })(core.Attachment); + core.RegionAttachment = RegionAttachment; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var JitterEffect = (function () { + function JitterEffect(jitterX, jitterY) { + this.jitterX = 0; + this.jitterY = 0; + this.jitterX = jitterX; + this.jitterY = jitterY; + } + JitterEffect.prototype.begin = function (skeleton) {}; + JitterEffect.prototype.transform = function (position, uv, light, dark) { + position.x += core.MathUtils.randomTriangular(-this.jitterX, this.jitterY); + position.y += core.MathUtils.randomTriangular(-this.jitterX, this.jitterY); + }; + JitterEffect.prototype.end = function () {}; + return JitterEffect; + })(); + core.JitterEffect = JitterEffect; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var core; + (function (core) { + var SwirlEffect = (function () { + function SwirlEffect(radius) { + this.centerX = 0; + this.centerY = 0; + this.radius = 0; + this.angle = 0; + this.worldX = 0; + this.worldY = 0; + this.radius = radius; + } + SwirlEffect.prototype.begin = function (skeleton) { + this.worldX = skeleton.x + this.centerX; + this.worldY = skeleton.y + this.centerY; + }; + SwirlEffect.prototype.transform = function (position, uv, light, dark) { + var radAngle = this.angle * core.MathUtils.degreesToRadians; + var x = position.x - this.worldX; + var y = position.y - this.worldY; + var dist = Math.sqrt(x * x + y * y); + if (dist < this.radius) { + var theta = SwirlEffect.interpolation.apply(0, radAngle, (this.radius - dist) / this.radius); + var cos = Math.cos(theta); + var sin = Math.sin(theta); + position.x = cos * x - sin * y + this.worldX; + position.y = sin * x + cos * y + this.worldY; + } + }; + SwirlEffect.prototype.end = function () {}; + SwirlEffect.interpolation = new core.PowOut(2); + return SwirlEffect; + })(); + core.SwirlEffect = SwirlEffect; + })((core = pixi_spine.core || (pixi_spine.core = {}))); +})(pixi_spine || (pixi_spine = {})); +(function () { + if (!Math.fround) { + Math.fround = Math.fround = (function (array) { + return function (x) { + return (array[0] = x), array[0]; + }; + })(new Float32Array(1)); + } +})(); +var pixi_spine; +(function (pixi_spine) { + pixi_spine.core.Bone.yDown = true; + var tempRgb = [0, 0, 0]; + var SpineSprite = (function (_super) { + __extends(SpineSprite, _super); + function SpineSprite() { + var _this = (_super !== null && _super.apply(this, arguments)) || this; + _this.region = null; + return _this; + } + return SpineSprite; + })(PIXI.Sprite); + pixi_spine.SpineSprite = SpineSprite; + var SpineMesh = (function (_super) { + __extends(SpineMesh, _super); + function SpineMesh(texture, vertices, uvs, indices, drawMode) { + return _super.call(this, texture, vertices, uvs, indices, drawMode) || this; + } + return SpineMesh; + })(PIXI.mesh.Mesh); + pixi_spine.SpineMesh = SpineMesh; + var Spine = (function (_super) { + __extends(Spine, _super); + function Spine(spineData) { + var _this = _super.call(this) || this; + if (!spineData) { + throw new Error('The spineData param is required.'); + } + if (typeof spineData === 'string') { + throw new Error( + 'spineData param cant be string. Please use spine.Spine.fromAtlas("YOUR_RESOURCE_NAME") from now on.', + ); + } + _this.spineData = spineData; + _this.skeleton = new pixi_spine.core.Skeleton(spineData); + _this.skeleton.updateWorldTransform(); + _this.stateData = new pixi_spine.core.AnimationStateData(spineData); + _this.state = new pixi_spine.core.AnimationState(_this.stateData); + _this.slotContainers = []; + _this.tempClipContainers = []; + for (var i = 0, n = _this.skeleton.slots.length; i < n; i++) { + var slot = _this.skeleton.slots[i]; + var attachment = slot.getAttachment(); + var slotContainer = _this.newContainer(); + _this.slotContainers.push(slotContainer); + _this.addChild(slotContainer); + _this.tempClipContainers.push(null); + if (attachment instanceof pixi_spine.core.RegionAttachment) { + var spriteName = attachment.region.name; + var sprite = _this.createSprite(slot, attachment, spriteName); + slot.currentSprite = sprite; + slot.currentSpriteName = spriteName; + slotContainer.addChild(sprite); + } else if (attachment instanceof pixi_spine.core.MeshAttachment) { + var mesh = _this.createMesh(slot, attachment); + slot.currentMesh = mesh; + slot.currentMeshName = attachment.name; + slotContainer.addChild(mesh); + } else if (attachment instanceof pixi_spine.core.ClippingAttachment) { + _this.createGraphics(slot, attachment); + slotContainer.addChild(slot.clippingContainer); + slotContainer.addChild(slot.currentGraphics); + } else { + continue; + } + } + _this.autoUpdate = true; + _this.tintRgb = new Float32Array([1, 1, 1]); + return _this; + } + Object.defineProperty(Spine.prototype, 'autoUpdate', { + get: function () { + return this.updateTransform === Spine.prototype.autoUpdateTransform; + }, + set: function (value) { + this.updateTransform = value ? Spine.prototype.autoUpdateTransform : PIXI.Container.prototype.updateTransform; + }, + enumerable: false, + configurable: true, + }); + Object.defineProperty(Spine.prototype, 'visible', { + get: function () { + return this._visible; + }, + set: function (value) { + if (value !== this._visible) { + this._visible = value; + if (value) { + this.lastTime = 0; + } + } + }, + enumerable: false, + configurable: true, + }); + Object.defineProperty(Spine.prototype, 'tint', { + get: function () { + return PIXI.utils.rgb2hex(this.tintRgb); + }, + set: function (value) { + this.tintRgb = PIXI.utils.hex2rgb(value, this.tintRgb); + }, + enumerable: false, + configurable: true, + }); + Object.defineProperty(Spine.prototype, 'delayLimit', { + get: function () { + var limit = typeof this.localDelayLimit !== 'undefined' ? this.localDelayLimit : Spine.globalDelayLimit; + return limit || Number.MAX_VALUE; + }, + enumerable: false, + configurable: true, + }); + Spine.prototype.update = function (dt) { + var delayLimit = this.delayLimit; + if (dt > delayLimit) dt = delayLimit; + this.state.update(dt); + this.state.apply(this.skeleton); + if (!this.skeleton) return; + this.skeleton.updateWorldTransform(); + var slots = this.skeleton.slots; + var globalClr = this.color; + var light = null, + dark = null; + if (globalClr) { + light = globalClr.light; + dark = globalClr.dark; + } else { + light = this.tintRgb; + } + var thack = PIXI.TransformBase && this.transformHack() == 1; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + var attachment = slot.getAttachment(); + var slotContainer = this.slotContainers[i]; + if (!attachment) { + slotContainer.visible = false; + continue; + } + var spriteColor = null; + var attColor = attachment.color; + if (attachment instanceof pixi_spine.core.RegionAttachment) { + var region = attachment.region; + if (region) { + if (slot.currentMesh) { + slot.currentMesh.visible = false; + slot.currentMesh = null; + slot.currentMeshName = undefined; + } + var ar = region; + if (!slot.currentSpriteName || slot.currentSpriteName !== ar.name) { + var spriteName = ar.name; + if (slot.currentSprite) { + slot.currentSprite.visible = false; + } + slot.sprites = slot.sprites || {}; + if (slot.sprites[spriteName] !== undefined) { + slot.sprites[spriteName].visible = true; + } else { + var sprite = this.createSprite(slot, attachment, spriteName); + slotContainer.addChild(sprite); + } + slot.currentSprite = slot.sprites[spriteName]; + slot.currentSpriteName = spriteName; + } + } + if (slotContainer.transform) { + var transform = slotContainer.transform; + var transAny = transform; + var lt = null; + if (transAny.matrix2d) { + lt = transAny.matrix2d; + transAny._dirtyVersion++; + transAny.version = transAny._dirtyVersion; + transAny.isStatic = true; + transAny.operMode = 0; + } else { + if (thack) { + if (transAny.position) { + transform = new PIXI.TransformBase(); + transform._parentID = -1; + transform._worldID = slotContainer.transform._worldID; + slotContainer.transform = transform; + } + lt = transform.localTransform; + } else { + transAny.setFromMatrix(slot.bone.matrix); + } + } + if (lt) { + slot.bone.matrix.copy(lt); + } + } else { + var lt = slotContainer.localTransform || new PIXI.Matrix(); + slot.bone.matrix.copy(lt); + slotContainer.localTransform = lt; + slotContainer.displayObjectUpdateTransform = SlotContainerUpdateTransformV3; + } + if (slot.currentSprite.color) { + spriteColor = slot.currentSprite.color; + } else { + tempRgb[0] = light[0] * slot.color.r * attColor.r; + tempRgb[1] = light[1] * slot.color.g * attColor.g; + tempRgb[2] = light[2] * slot.color.b * attColor.b; + slot.currentSprite.tint = PIXI.utils.rgb2hex(tempRgb); + } + slot.currentSprite.blendMode = slot.blendMode; + } else if (attachment instanceof pixi_spine.core.MeshAttachment) { + if (slot.currentSprite) { + slot.currentSprite.visible = false; + slot.currentSprite = null; + slot.currentSpriteName = undefined; + if (slotContainer.transform) { + var transform = new PIXI.TransformStatic(); + transform._parentID = -1; + transform._worldID = slotContainer.transform._worldID; + slotContainer.transform = transform; + } else { + slotContainer.localTransform = new PIXI.Matrix(); + slotContainer.displayObjectUpdateTransform = PIXI.DisplayObject.prototype.updateTransform; + } + } + if (!slot.currentMeshName || slot.currentMeshName !== attachment.name) { + var meshName = attachment.name; + if (slot.currentMesh) { + slot.currentMesh.visible = false; + } + slot.meshes = slot.meshes || {}; + if (slot.meshes[meshName] !== undefined) { + slot.meshes[meshName].visible = true; + } else { + var mesh = this.createMesh(slot, attachment); + slotContainer.addChild(mesh); + } + slot.currentMesh = slot.meshes[meshName]; + slot.currentMeshName = meshName; + } + attachment.computeWorldVerticesOld(slot, slot.currentMesh.vertices); + if (slot.currentMesh.color) { + spriteColor = slot.currentMesh.color; + } else if (PIXI.VERSION[0] !== '3') { + var tintRgb = slot.currentMesh.tintRgb; + tintRgb[0] = light[0] * slot.color.r * attColor.r; + tintRgb[1] = light[1] * slot.color.g * attColor.g; + tintRgb[2] = light[2] * slot.color.b * attColor.b; + } + slot.currentMesh.blendMode = slot.blendMode; + } else if (attachment instanceof pixi_spine.core.ClippingAttachment) { + if (!slot.currentGraphics) { + this.createGraphics(slot, attachment); + slotContainer.addChild(slot.clippingContainer); + slotContainer.addChild(slot.currentGraphics); + } + this.updateGraphics(slot, attachment); + } else { + slotContainer.visible = false; + continue; + } + slotContainer.visible = true; + if (spriteColor) { + var r0 = slot.color.r * attColor.r; + var g0 = slot.color.g * attColor.g; + var b0 = slot.color.b * attColor.b; + spriteColor.setLight( + light[0] * r0 + dark[0] * (1.0 - r0), + light[1] * g0 + dark[1] * (1.0 - g0), + light[2] * b0 + dark[2] * (1.0 - b0), + ); + if (slot.darkColor) { + r0 = slot.darkColor.r; + g0 = slot.darkColor.g; + b0 = slot.darkColor.b; + } else { + r0 = 0.0; + g0 = 0.0; + b0 = 0.0; + } + spriteColor.setDark( + light[0] * r0 + dark[0] * (1 - r0), + light[1] * g0 + dark[1] * (1 - g0), + light[2] * b0 + dark[2] * (1 - b0), + ); + } + slotContainer.alpha = slot.color.a; + } + var drawOrder = this.skeleton.drawOrder; + var clippingAttachment = null; + var clippingContainer = null; + for (var i = 0, n = drawOrder.length; i < n; i++) { + var slot = slots[drawOrder[i].data.index]; + var slotContainer = this.slotContainers[drawOrder[i].data.index]; + if (!clippingContainer) { + if (slotContainer.parent !== null && slotContainer.parent !== this) { + slotContainer.parent.removeChild(slotContainer); + slotContainer.parent = this; + } + } + if (slot.currentGraphics && slot.getAttachment()) { + clippingContainer = slot.clippingContainer; + clippingAttachment = slot.getAttachment(); + clippingContainer.children.length = 0; + this.children[i] = slotContainer; + if (clippingAttachment.endSlot == slot.data) { + clippingAttachment.endSlot = null; + } + } else { + if (clippingContainer) { + var c = this.tempClipContainers[i]; + if (!c) { + c = this.tempClipContainers[i] = this.newContainer(); + c.visible = false; + } + this.children[i] = c; + slotContainer.parent = null; + clippingContainer.addChild(slotContainer); + if (clippingAttachment.endSlot == slot.data) { + clippingContainer.renderable = true; + clippingContainer = null; + clippingAttachment = null; + } + } else { + this.children[i] = slotContainer; + } + } + } + }; + Spine.prototype.setSpriteRegion = function (attachment, sprite, region) { + sprite.region = region; + sprite.texture = region.texture; + if (!region.size) { + sprite.scale.x = (attachment.scaleX * attachment.width) / region.originalWidth; + sprite.scale.y = (-attachment.scaleY * attachment.height) / region.originalHeight; + } else { + sprite.scale.x = region.size.width / region.originalWidth; + sprite.scale.y = -region.size.height / region.originalHeight; + } + }; + Spine.prototype.setMeshRegion = function (attachment, mesh, region) { + mesh.region = region; + mesh.texture = region.texture; + region.texture._updateUvs(); + attachment.updateUVs(region, mesh.uvs); + mesh.dirty++; + }; + Spine.prototype.autoUpdateTransform = function () { + if (Spine.globalAutoUpdate) { + this.lastTime = this.lastTime || Date.now(); + var timeDelta = (Date.now() - this.lastTime) * 0.001; + this.lastTime = Date.now(); + this.update(timeDelta); + } else { + this.lastTime = 0; + } + PIXI.Container.prototype.updateTransform.call(this); + }; + Spine.prototype.createSprite = function (slot, attachment, defName) { + var region = attachment.region; + if (slot.hackAttachment === attachment) { + region = slot.hackRegion; + } + var texture = region.texture; + var sprite = this.newSprite(texture); + sprite.rotation = attachment.rotation * pixi_spine.core.MathUtils.degRad; + sprite.anchor.x = 0.5; + sprite.anchor.y = 0.5; + sprite.position.x = attachment.x; + sprite.position.y = attachment.y; + sprite.alpha = attachment.color.a; + sprite.region = attachment.region; + this.setSpriteRegion(attachment, sprite, attachment.region); + slot.sprites = slot.sprites || {}; + slot.sprites[defName] = sprite; + return sprite; + }; + Spine.prototype.createMesh = function (slot, attachment) { + var region = attachment.region; + if (slot.hackAttachment === attachment) { + region = slot.hackRegion; + slot.hackAttachment = null; + slot.hackRegion = null; + } + var strip = this.newMesh( + region.texture, + new Float32Array(attachment.regionUVs.length), + new Float32Array(attachment.regionUVs.length), + new Uint16Array(attachment.triangles), + PIXI.mesh.Mesh.DRAW_MODES.TRIANGLES, + ); + strip.canvasPadding = 1.5; + strip.alpha = attachment.color.a; + strip.region = attachment.region; + this.setMeshRegion(attachment, strip, region); + slot.meshes = slot.meshes || {}; + slot.meshes[attachment.name] = strip; + return strip; + }; + Spine.prototype.createGraphics = function (slot, clip) { + var graphics = this.newGraphics(); + var poly = new PIXI.Polygon([]); + graphics.clear(); + graphics.beginFill(0xffffff, 1); + graphics.drawPolygon(poly); + graphics.renderable = false; + slot.currentGraphics = graphics; + slot.clippingContainer = this.newContainer(); + slot.clippingContainer.mask = slot.currentGraphics; + return graphics; + }; + Spine.prototype.updateGraphics = function (slot, clip) { + var vertices = slot.currentGraphics.graphicsData[0].shape.points; + var n = clip.worldVerticesLength; + vertices.length = n; + clip.computeWorldVertices(slot, 0, n, vertices, 0, 2); + slot.currentGraphics.dirty++; + slot.currentGraphics.clearDirty++; + }; + Spine.prototype.hackTextureBySlotIndex = function (slotIndex, texture, size) { + if (texture === void 0) { + texture = null; + } + if (size === void 0) { + size = null; + } + var slot = this.skeleton.slots[slotIndex]; + if (!slot) { + return false; + } + var attachment = slot.getAttachment(); + var region = attachment.region; + if (texture) { + region = new pixi_spine.core.TextureRegion(); + region.texture = texture; + region.size = size; + slot.hackRegion = region; + slot.hackAttachment = attachment; + } else { + slot.hackRegion = null; + slot.hackAttachment = null; + } + if (slot.currentSprite && slot.currentSprite.region != region) { + this.setSpriteRegion(attachment, slot.currentSprite, region); + slot.currentSprite.region = region; + } else if (slot.currentMesh && slot.currentMesh.region != region) { + this.setMeshRegion(attachment, slot.currentMesh, region); + } + return true; + }; + Spine.prototype.hackTextureBySlotName = function (slotName, texture, size) { + if (texture === void 0) { + texture = null; + } + if (size === void 0) { + size = null; + } + var index = this.skeleton.findSlotIndex(slotName); + if (index == -1) { + return false; + } + return this.hackTextureBySlotIndex(index, texture, size); + }; + Spine.prototype.newContainer = function () { + return new PIXI.Container(); + }; + Spine.prototype.newSprite = function (tex) { + return new SpineSprite(tex); + }; + Spine.prototype.newGraphics = function () { + return new PIXI.Graphics(); + }; + Spine.prototype.newMesh = function (texture, vertices, uvs, indices, drawMode) { + return new SpineMesh(texture, vertices, uvs, indices, drawMode); + }; + Spine.prototype.transformHack = function () { + return 1; + }; + Spine.prototype.hackAttachmentGroups = function (nameSuffix, group, outGroup) { + if (!nameSuffix) { + return; + } + var list_d = [], + list_n = []; + for (var i = 0, len = this.skeleton.slots.length; i < len; i++) { + var slot = this.skeleton.slots[i]; + var name_6 = slot.currentSpriteName || slot.currentMeshName || ''; + var target = slot.currentSprite || slot.currentMesh; + if (name_6.endsWith(nameSuffix)) { + target.parentGroup = group; + list_n.push(target); + } else if (outGroup && target) { + target.parentGroup = outGroup; + list_d.push(target); + } + } + return [list_d, list_n]; + }; + Spine.prototype.destroy = function (options) { + for (var i = 0, n = this.skeleton.slots.length; i < n; i++) { + var slot = this.skeleton.slots[i]; + for (var name_7 in slot.meshes) { + slot.meshes[name_7].destroy(options); + } + slot.meshes = null; + for (var name_8 in slot.sprites) { + slot.sprites[name_8].destroy(options); + } + slot.sprites = null; + } + for (var i = 0, n = this.slotContainers.length; i < n; i++) { + this.slotContainers[i].destroy(options); + } + this.spineData = null; + this.skeleton = null; + this.slotContainers = null; + this.stateData = null; + this.state = null; + this.tempClipContainers = null; + _super.prototype.destroy.call(this, options); + }; + Spine.globalAutoUpdate = true; + Spine.globalDelayLimit = 0; + Spine.clippingPolygon = []; + return Spine; + })(PIXI.Container); + pixi_spine.Spine = Spine; + function SlotContainerUpdateTransformV3() { + var pt = this.parent.worldTransform; + var wt = this.worldTransform; + var lt = this.localTransform; + wt.a = lt.a * pt.a + lt.b * pt.c; + wt.b = lt.a * pt.b + lt.b * pt.d; + wt.c = lt.c * pt.a + lt.d * pt.c; + wt.d = lt.c * pt.b + lt.d * pt.d; + wt.tx = lt.tx * pt.a + lt.ty * pt.c + pt.tx; + wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; + this.worldAlpha = this.alpha * this.parent.worldAlpha; + this._currentBounds = null; + } +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + PIXI.spine = pixi_spine; + var TextureProto = PIXI.Texture.prototype; + if (!TextureProto._updateUvs) { + TextureProto._updateUvs = TextureProto.updateUvs; + } +})(pixi_spine || (pixi_spine = {})); +var pixi_spine; +(function (pixi_spine) { + var Resource = PIXI.loaders.Resource; + function isJson(resource) { + return resource.type == Resource.TYPE.JSON; + } + function isBuffer(resource) { + return resource.xhrType == Resource.XHR_RESPONSE_TYPE.BUFFER; + } + Resource.setExtensionXhrType('skel', Resource.XHR_RESPONSE_TYPE.BUFFER); + function atlasParser() { + return function atlasParser(resource, next) { + if (!resource.data) { + return next(); + } + var isJsonSpineModel = isJson(resource) && resource.data.bones; + var isBinarySpineModel = isBuffer(resource) && (resource.extension === 'skel' || resource.metadata.spineMetadata); + if (!isJsonSpineModel && !isBinarySpineModel) { + return next(); + } + var parser = null; + var dataToParse = resource.data; + if (isJsonSpineModel) { + parser = new pixi_spine.core.SkeletonJson(null); + } else { + parser = new pixi_spine.core.SkeletonBinary(null); + if (resource.data instanceof ArrayBuffer) { + dataToParse = new Uint8Array(resource.data); + } + } + var metadata = resource.metadata || {}; + var metadataSkeletonScale = metadata ? resource.metadata.spineSkeletonScale : null; + if (metadataSkeletonScale) { + parser.scale = metadataSkeletonScale; + } + var metadataAtlas = metadata ? resource.metadata.spineAtlas : null; + if (metadataAtlas === false) { + return next(); + } + if (metadataAtlas && metadataAtlas.pages) { + parser.attachmentLoader = new pixi_spine.core.AtlasAttachmentLoader(metadataAtlas); + resource.spineData = parser.readSkeletonData(dataToParse); + resource.spineAtlas = metadataAtlas; + return next(); + } + var metadataAtlasSuffix = metadata.spineAtlasSuffix || '.atlas'; + var atlasPath = resource.url; + var queryStringPos = atlasPath.indexOf('?'); + if (queryStringPos > 0) { + atlasPath = atlasPath.substr(0, queryStringPos); + } + atlasPath = atlasPath.substr(0, atlasPath.lastIndexOf('.')) + metadataAtlasSuffix; + if (resource.metadata && resource.metadata.spineAtlasFile) { + atlasPath = resource.metadata.spineAtlasFile; + } + atlasPath = atlasPath.replace(this.baseUrl, ''); + var atlasOptions = { + crossOrigin: resource.crossOrigin, + xhrType: Resource.XHR_RESPONSE_TYPE.TEXT, + metadata: metadata.spineMetadata || null, + parentResource: resource, + }; + var imageOptions = { + crossOrigin: resource.crossOrigin, + metadata: metadata.imageMetadata || null, + parentResource: resource, + }; + var baseUrl = resource.url.substr(0, resource.url.lastIndexOf('/') + 1); + baseUrl = baseUrl.replace(this.baseUrl, ''); + var namePrefix = metadata.imageNamePrefix || resource.name + '_atlas_page_'; + var adapter = metadata.images + ? staticImageLoader(metadata.images) + : metadata.image + ? staticImageLoader({ default: metadata.image }) + : metadata.imageLoader + ? metadata.imageLoader(this, namePrefix, baseUrl, imageOptions) + : imageLoaderAdapter(this, namePrefix, baseUrl, imageOptions); + var createSkeletonWithRawAtlas = function (rawData) { + new pixi_spine.core.TextureAtlas(rawData, adapter, function (spineAtlas) { + if (spineAtlas) { + parser.attachmentLoader = new pixi_spine.core.AtlasAttachmentLoader(spineAtlas); + resource.spineData = parser.readSkeletonData(dataToParse); + resource.spineAtlas = spineAtlas; + } + next(); + }); + }; + if (resource.metadata && resource.metadata.atlasRawData) { + createSkeletonWithRawAtlas(resource.metadata.atlasRawData); + } else { + this.add(resource.name + '_atlas', atlasPath, atlasOptions, function (atlasResource) { + if (!atlasResource.error) { + createSkeletonWithRawAtlas(atlasResource.data); + } else { + next(); + } + }); + } + }; + } + pixi_spine.atlasParser = atlasParser; + function imageLoaderAdapter(loader, namePrefix, baseUrl, imageOptions) { + if (baseUrl && baseUrl.lastIndexOf('/') !== baseUrl.length - 1) { + baseUrl += '/'; + } + return function (line, callback) { + var name = namePrefix + line; + var url = baseUrl + line; + var cachedResource = loader.resources[name]; + if (cachedResource) { + function done() { + callback(cachedResource.texture.baseTexture); + } + if (cachedResource.texture) { + done(); + } else { + cachedResource.onAfterMiddleware.add(done); + } + } else { + loader.add(name, url, imageOptions, function (resource) { + if (!resource.error) { + callback(resource.texture.baseTexture); + } else { + callback(null); + } + }); + } + }; + } + pixi_spine.imageLoaderAdapter = imageLoaderAdapter; + function syncImageLoaderAdapter(baseUrl, crossOrigin) { + if (baseUrl && baseUrl.lastIndexOf('/') !== baseUrl.length - 1) { + baseUrl += '/'; + } + return function (line, callback) { + callback(PIXI.BaseTexture.fromImage(line, crossOrigin)); + }; + } + pixi_spine.syncImageLoaderAdapter = syncImageLoaderAdapter; + function staticImageLoader(pages) { + return function (line, callback) { + var page = pages[line] || pages['default']; + if (page && page.baseTexture) callback(page.baseTexture); + else callback(page); + }; + } + pixi_spine.staticImageLoader = staticImageLoader; + if (PIXI.loaders.Loader) { + PIXI.loaders.Loader.addPixiMiddleware(atlasParser); + PIXI.loader.use(atlasParser()); + } +})(pixi_spine || (pixi_spine = {})); +export default pixi_spine; diff --git a/packages/plugin-renderer-sprite-animation/README.md b/packages/plugin-renderer-sprite-animation/README.md index dd5ebad1..27a646bc 100644 --- a/packages/plugin-renderer-sprite-animation/README.md +++ b/packages/plugin-renderer-sprite-animation/README.md @@ -1,7 +1,6 @@ - # @eva/plugin-renderer-sprite-animation More Introduction + - [EN](https://eva.js.org) - [中文](https://eva-engine.gitee.io) - \ No newline at end of file diff --git a/packages/plugin-renderer-sprite-animation/api-extractor.json b/packages/plugin-renderer-sprite-animation/api-extractor.json index 66aded78..3fe820d0 100644 --- a/packages/plugin-renderer-sprite-animation/api-extractor.json +++ b/packages/plugin-renderer-sprite-animation/api-extractor.json @@ -4,4 +4,4 @@ "dtsRollup": { "publicTrimmedFilePath": "./dist/plugin-renderer-sprite-animation.d.ts" } -} \ No newline at end of file +} diff --git a/packages/plugin-renderer-sprite-animation/index.js b/packages/plugin-renderer-sprite-animation/index.js index 73334f4f..892ee6b7 100644 --- a/packages/plugin-renderer-sprite-animation/index.js +++ b/packages/plugin-renderer-sprite-animation/index.js @@ -1,7 +1,7 @@ -'use strict' +'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/plugin-renderer-sprite-animation.cjs.prod.js') + module.exports = require('./dist/plugin-renderer-sprite-animation.cjs.prod.js'); } else { - module.exports = require('./dist/plugin-renderer-sprite-animation.cjs.js') + module.exports = require('./dist/plugin-renderer-sprite-animation.cjs.js'); } diff --git a/packages/plugin-renderer-sprite-animation/lib/component.ts b/packages/plugin-renderer-sprite-animation/lib/component.ts index 92d8d571..af2ea137 100644 --- a/packages/plugin-renderer-sprite-animation/lib/component.ts +++ b/packages/plugin-renderer-sprite-animation/lib/component.ts @@ -1,5 +1,5 @@ -import {Component, decorators} from '@eva/eva.js'; -import {SpriteAnimation as SpriteAnimationEngine} from '@eva/renderer-adapter'; +import { Component, decorators } from '@eva/eva.js'; +import { SpriteAnimation as SpriteAnimationEngine } from '@eva/renderer-adapter'; export interface SpriteAnimationParams { resource: string; diff --git a/packages/plugin-renderer-sprite-animation/lib/system.ts b/packages/plugin-renderer-sprite-animation/lib/system.ts index e3e2e4bd..f7075057 100644 --- a/packages/plugin-renderer-sprite-animation/lib/system.ts +++ b/packages/plugin-renderer-sprite-animation/lib/system.ts @@ -1,25 +1,13 @@ -import { - GameObject, - decorators, - resource, - ComponentChanged, - RESOURCE_TYPE, - OBSERVER_TYPE, -} from '@eva/eva.js'; -import { - RendererManager, - ContainerManager, - RendererSystem, - Renderer, -} from '@eva/plugin-renderer'; -import {SpriteAnimation as SpriteAnimationEngine} from '@eva/renderer-adapter'; -import {Spritesheet, BaseTexture} from 'pixi.js'; +import { GameObject, decorators, resource, ComponentChanged, RESOURCE_TYPE, OBSERVER_TYPE } from '@eva/eva.js'; +import { RendererManager, ContainerManager, RendererSystem, Renderer } from '@eva/plugin-renderer'; +import { SpriteAnimation as SpriteAnimationEngine } from '@eva/renderer-adapter'; +import { Spritesheet, BaseTexture } from 'pixi.js'; import SpriteAnimationComponent from './component'; const resourceKeySplit = '_s|r|c_'; -resource.registerInstance(RESOURCE_TYPE.SPRITE_ANIMATION, ({name, data}) => { +resource.registerInstance(RESOURCE_TYPE.SPRITE_ANIMATION, ({ name, data }) => { return new Promise(r => { const textureObj = data.json; const texture = BaseTexture.from(data.image); @@ -43,7 +31,7 @@ resource.registerInstance(RESOURCE_TYPE.SPRITE_ANIMATION, ({name, data}) => { textureObj.frames = newFrames; const spriteSheet = new Spritesheet(texture, textureObj); spriteSheet.parse(() => { - const {textures} = spriteSheet; + const { textures } = spriteSheet; const spriteFrames = []; for (const key in textures) { spriteFrames.push(textures[key]); @@ -52,7 +40,7 @@ resource.registerInstance(RESOURCE_TYPE.SPRITE_ANIMATION, ({name, data}) => { }); }); }); -resource.registerDestroy(RESOURCE_TYPE.SPRITE_ANIMATION, ({instance}) => { +resource.registerDestroy(RESOURCE_TYPE.SPRITE_ANIMATION, ({ instance }) => { if (!instance) return; for (const texture of instance) { texture.destroy(true); @@ -65,8 +53,8 @@ resource.registerDestroy(RESOURCE_TYPE.SPRITE_ANIMATION, ({instance}) => { export default class SpriteAnimation extends Renderer { static systemName = 'SpriteAnimation'; name: string = 'SpriteAnimation'; - animates: {[propName: number]: SpriteAnimationEngine} = {}; - autoPlay: {[propName: number]: boolean} = {}; + animates: { [propName: number]: SpriteAnimationEngine } = {}; + autoPlay: { [propName: number]: boolean } = {}; renderSystem: RendererSystem; rendererManager: RendererManager; containerManager: ContainerManager; @@ -75,7 +63,7 @@ export default class SpriteAnimation extends Renderer { this.renderSystem.rendererManager.register(this); } rendererUpdate(gameObject: GameObject) { - const {width, height} = gameObject.transform.size; + const { width, height } = gameObject.transform.size; if (this.animates[gameObject.id]) { this.animates[gameObject.id].animatedSprite.width = width; this.animates[gameObject.id].animatedSprite.height = height; @@ -86,13 +74,9 @@ export default class SpriteAnimation extends Renderer { const component: SpriteAnimationComponent = changed.component as SpriteAnimationComponent; this.autoPlay[changed.gameObject.id] = component.autoPlay; if (changed.type === OBSERVER_TYPE.ADD) { - const {instance: frames} = await resource.getResource( - component.resource, - ); + const { instance: frames } = await resource.getResource(component.resource); if (!frames) { - console.error( - `GameObject:${changed.gameObject.name}'s Img resource load error`, - ); + console.error(`GameObject:${changed.gameObject.name}'s Img resource load error`); } this.add({ frames: frames, @@ -101,16 +85,11 @@ export default class SpriteAnimation extends Renderer { }); } else if (changed.type === OBSERVER_TYPE.CHANGE) { if (changed.prop && changed.prop.prop[0] === 'speed') { - this.animates[changed.gameObject.id].speed = - 1000 / 60 / component.speed; + this.animates[changed.gameObject.id].speed = 1000 / 60 / component.speed; } else { - const {instance: frames} = await resource.getResource( - component.resource, - ); + const { instance: frames } = await resource.getResource(component.resource); if (!frames) { - console.error( - `GameObject:${changed.gameObject.name}'s Img resource load error`, - ); + console.error(`GameObject:${changed.gameObject.name}'s Img resource load error`); } this.change({ frames: frames, @@ -123,22 +102,20 @@ export default class SpriteAnimation extends Renderer { } } } - add({frames, id, component}) { - const animate = new SpriteAnimationEngine({frames}); + add({ frames, id, component }) { + const animate = new SpriteAnimationEngine({ frames }); this.animates[id] = animate; - this.containerManager - .getContainer(id) - .addChildAt(animate.animatedSprite, 0); + this.containerManager.getContainer(id).addChildAt(animate.animatedSprite, 0); - animate.animatedSprite.onComplete = () =>{ - component.emit('complete') - } - animate.animatedSprite.onFrameChange = () =>{ - component.emit('frameChange') - } - animate.animatedSprite.onLoop = () =>{ - component.emit('loop') - } + animate.animatedSprite.onComplete = () => { + component.emit('complete'); + }; + animate.animatedSprite.onFrameChange = () => { + component.emit('frameChange'); + }; + animate.animatedSprite.onLoop = () => { + component.emit('loop'); + }; component.animate = this.animates[id]; this.animates[id].speed = 1000 / 60 / component.speed; @@ -146,9 +123,9 @@ export default class SpriteAnimation extends Renderer { animate.animatedSprite.play(); } } - change({frames, id, component}) { + change({ frames, id, component }) { this.remove(id, true); - this.add({frames, id, component}); + this.add({ frames, id, component }); } remove(id, isChange?: boolean) { const animate = this.animates[id]; diff --git a/packages/plugin-renderer-sprite/README.md b/packages/plugin-renderer-sprite/README.md index 63b658a3..8bd4c86a 100644 --- a/packages/plugin-renderer-sprite/README.md +++ b/packages/plugin-renderer-sprite/README.md @@ -1,7 +1,6 @@ - # @eva/plugin-renderer-sprite More Introduction + - [EN](https://eva.js.org) - [中文](https://eva-engine.gitee.io) - \ No newline at end of file diff --git a/packages/plugin-renderer-sprite/api-extractor.json b/packages/plugin-renderer-sprite/api-extractor.json index d92b9cf7..7a68d176 100644 --- a/packages/plugin-renderer-sprite/api-extractor.json +++ b/packages/plugin-renderer-sprite/api-extractor.json @@ -4,4 +4,4 @@ "dtsRollup": { "publicTrimmedFilePath": "./dist/plugin-renderer-sprite.d.ts" } -} \ No newline at end of file +} diff --git a/packages/plugin-renderer-sprite/index.js b/packages/plugin-renderer-sprite/index.js index f0a03080..10b39076 100644 --- a/packages/plugin-renderer-sprite/index.js +++ b/packages/plugin-renderer-sprite/index.js @@ -1,7 +1,7 @@ -'use strict' +'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/plugin-renderer-sprite.cjs.prod.js') + module.exports = require('./dist/plugin-renderer-sprite.cjs.prod.js'); } else { - module.exports = require('./dist/plugin-renderer-sprite.cjs.js') + module.exports = require('./dist/plugin-renderer-sprite.cjs.js'); } diff --git a/packages/plugin-renderer-sprite/lib/component.ts b/packages/plugin-renderer-sprite/lib/component.ts index 77fe956b..dd24cbbd 100644 --- a/packages/plugin-renderer-sprite/lib/component.ts +++ b/packages/plugin-renderer-sprite/lib/component.ts @@ -15,4 +15,4 @@ export default class Sprite extends Component { this.spriteName = obj.spriteName; } } -} \ No newline at end of file +} diff --git a/packages/plugin-renderer-sprite/lib/system.ts b/packages/plugin-renderer-sprite/lib/system.ts index 081c4646..65298728 100644 --- a/packages/plugin-renderer-sprite/lib/system.ts +++ b/packages/plugin-renderer-sprite/lib/system.ts @@ -1,25 +1,13 @@ -import { - GameObject, - decorators, - resource, - ComponentChanged, - RESOURCE_TYPE, - OBSERVER_TYPE, -} from '@eva/eva.js'; -import { - RendererManager, - ContainerManager, - RendererSystem, - Renderer, -} from '@eva/plugin-renderer'; +import { GameObject, decorators, resource, ComponentChanged, RESOURCE_TYPE, OBSERVER_TYPE } from '@eva/eva.js'; +import { RendererManager, ContainerManager, RendererSystem, Renderer } from '@eva/plugin-renderer'; import SpriteComponent from './component'; -import {Sprite as SpriteEngine} from '@eva/renderer-adapter'; -import {Spritesheet, BaseTexture} from 'pixi.js'; +import { Sprite as SpriteEngine } from '@eva/renderer-adapter'; +import { Spritesheet, BaseTexture } from 'pixi.js'; const resourceKeySplit = '_s|r|c_'; // Notice: This key be used in ninepatch system. -resource.registerInstance(RESOURCE_TYPE.SPRITE, ({name, data}) => { +resource.registerInstance(RESOURCE_TYPE.SPRITE, ({ name, data }) => { return new Promise(r => { const textureObj = data.json; const texture = BaseTexture.from(data.image); @@ -43,13 +31,13 @@ resource.registerInstance(RESOURCE_TYPE.SPRITE, ({name, data}) => { textureObj.frames = newFrames; const spriteSheet = new Spritesheet(texture, textureObj); spriteSheet.parse(() => { - const {textures} = spriteSheet; + const { textures } = spriteSheet; r(textures); }); }); }); -resource.registerDestroy(RESOURCE_TYPE.SPRITE, ({instance}) => { +resource.registerDestroy(RESOURCE_TYPE.SPRITE, ({ instance }) => { if (!instance) return; for (const key in instance) { instance[key].destroy(true); @@ -62,7 +50,7 @@ resource.registerDestroy(RESOURCE_TYPE.SPRITE, ({instance}) => { export default class Sprite extends Renderer { static systemName = 'Sprite'; name: string = 'Sprite'; - sprites: {[propName: number]: SpriteEngine} = {}; + sprites: { [propName: number]: SpriteEngine } = {}; renderSystem: RendererSystem; rendererManager: RendererManager; containerManager: ContainerManager; @@ -71,7 +59,7 @@ export default class Sprite extends Renderer { this.renderSystem.rendererManager.register(this); } rendererUpdate(gameObject: GameObject) { - const {width, height} = gameObject.transform.size; + const { width, height } = gameObject.transform.size; if (this.sprites[gameObject.id]) { this.sprites[gameObject.id].sprite.width = width; this.sprites[gameObject.id].sprite.height = height; @@ -82,38 +70,25 @@ export default class Sprite extends Renderer { const component: SpriteComponent = changed.component as SpriteComponent; if (changed.type === OBSERVER_TYPE.ADD) { const sprite = new SpriteEngine(null); - resource.getResource(component.resource).then(async ({instance}) => { + resource.getResource(component.resource).then(async ({ instance }) => { if (!instance) { - throw new Error( - `GameObject:${changed.gameObject.name}'s Sprite resource load error`, - ); + throw new Error(`GameObject:${changed.gameObject.name}'s Sprite resource load error`); } - sprite.image = - instance[ - component.resource + resourceKeySplit + component.spriteName - ]; + sprite.image = instance[component.resource + resourceKeySplit + component.spriteName]; }); this.sprites[changed.gameObject.id] = sprite; - this.containerManager - .getContainer(changed.gameObject.id) - .addChildAt(sprite.sprite, 0); + this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite.sprite, 0); } else if (changed.type === OBSERVER_TYPE.CHANGE) { - const {instance} = await resource.getResource(component.resource); + const { instance } = await resource.getResource(component.resource); if (!instance) { - throw new Error( - `GameObject:${changed.gameObject.name}'s Sprite resource load error`, - ); + throw new Error(`GameObject:${changed.gameObject.name}'s Sprite resource load error`); } this.sprites[changed.gameObject.id].image = - instance[ - component.resource + resourceKeySplit + component.spriteName - ]; + instance[component.resource + resourceKeySplit + component.spriteName]; } else if (changed.type === OBSERVER_TYPE.REMOVE) { const sprite = this.sprites[changed.gameObject.id]; - this.containerManager - .getContainer(changed.gameObject.id) - .removeChild(sprite.sprite); - sprite.sprite.destroy({ children: true }) + this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite.sprite); + sprite.sprite.destroy({ children: true }); delete this.sprites[changed.gameObject.id]; } } diff --git a/packages/plugin-renderer-test/lib/component.ts b/packages/plugin-renderer-test/lib/component.ts index 93e76529..2998cbd4 100644 --- a/packages/plugin-renderer-test/lib/component.ts +++ b/packages/plugin-renderer-test/lib/component.ts @@ -1,6 +1,5 @@ import { Component } from '../../eva.js/lib'; -import type { ComponentParams, Transform } from '../../eva.js/lib' - +import type { ComponentParams, Transform } from '../../eva.js/lib'; export default class Test extends Component { static componentName = 'Test'; @@ -11,14 +10,13 @@ export default class Test extends Component { geomerty = { data: undefined }; transform: Transform; + start() {} - start() { } - - onResume() { } + onResume() {} - update() { } + update() {} - onPause() { } + onPause() {} - lateUpdate() { } + lateUpdate() {} } diff --git a/packages/plugin-renderer-test/lib/index.ts b/packages/plugin-renderer-test/lib/index.ts index fe369696..a9f69fd9 100644 --- a/packages/plugin-renderer-test/lib/index.ts +++ b/packages/plugin-renderer-test/lib/index.ts @@ -1,3 +1,3 @@ export { default as TestSystem } from './system'; export { default as Test2System } from './system2'; -export { default as TestComponent } from './component'; \ No newline at end of file +export { default as TestComponent } from './component'; diff --git a/packages/plugin-renderer-test/lib/system.ts b/packages/plugin-renderer-test/lib/system.ts index b4a6404c..dadeeeae 100644 --- a/packages/plugin-renderer-test/lib/system.ts +++ b/packages/plugin-renderer-test/lib/system.ts @@ -11,21 +11,21 @@ export default class Test extends System { ], }; - init() { } + init() {} - awake() { } + awake() {} - start() { } + start() {} - onResume() { } + onResume() {} - onPause() { } + onPause() {} - onDestroy() { } + onDestroy() {} - update() { } + update() {} - lateUpdate() { } + lateUpdate() {} - destroy() { } + destroy() {} } diff --git a/packages/plugin-renderer-test/lib/system2.ts b/packages/plugin-renderer-test/lib/system2.ts index ea66af60..c22e2dce 100644 --- a/packages/plugin-renderer-test/lib/system2.ts +++ b/packages/plugin-renderer-test/lib/system2.ts @@ -1,13 +1,13 @@ -import {System} from '../../eva.js/lib'; +import { System } from '../../eva.js/lib'; export default class Test2 extends System { static systemName = 'Test'; readonly name = 'Test'; static observerInfo = { Test: [ - {prop: ['size'], deep: false}, - {prop: ['geomerty', 'data', 'vertex'], deep: true}, - {prop: ['style'], deep: true}, + { prop: ['size'], deep: false }, + { prop: ['geomerty', 'data', 'vertex'], deep: true }, + { prop: ['style'], deep: true }, ], }; } diff --git a/packages/plugin-renderer-text/README.md b/packages/plugin-renderer-text/README.md index 3fb3689f..1ada9db7 100644 --- a/packages/plugin-renderer-text/README.md +++ b/packages/plugin-renderer-text/README.md @@ -1,7 +1,6 @@ - # @eva/plugin-renderer-text More Introduction + - [EN](https://eva.js.org) - [中文](https://eva-engine.gitee.io) - \ No newline at end of file diff --git a/packages/plugin-renderer-text/api-extractor.json b/packages/plugin-renderer-text/api-extractor.json index 94aad24b..1a5b8e3c 100644 --- a/packages/plugin-renderer-text/api-extractor.json +++ b/packages/plugin-renderer-text/api-extractor.json @@ -4,4 +4,4 @@ "dtsRollup": { "publicTrimmedFilePath": "./dist/plugin-renderer-text.d.ts" } -} \ No newline at end of file +} diff --git a/packages/plugin-renderer-text/index.js b/packages/plugin-renderer-text/index.js index 1e04689e..45b573c4 100644 --- a/packages/plugin-renderer-text/index.js +++ b/packages/plugin-renderer-text/index.js @@ -1,7 +1,7 @@ -'use strict' +'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/plugin-renderer-text.cjs.prod.js') + module.exports = require('./dist/plugin-renderer-text.cjs.prod.js'); } else { - module.exports = require('./dist/plugin-renderer-text.cjs.js') + module.exports = require('./dist/plugin-renderer-text.cjs.js'); } diff --git a/packages/plugin-renderer-text/lib/component.ts b/packages/plugin-renderer-text/lib/component.ts index 1afd2785..ad253138 100644 --- a/packages/plugin-renderer-text/lib/component.ts +++ b/packages/plugin-renderer-text/lib/component.ts @@ -1,5 +1,5 @@ -import {TextStyle} from 'pixi.js'; -import {Component, decorators} from '@eva/eva.js'; +import { TextStyle } from 'pixi.js'; +import { Component, decorators } from '@eva/eva.js'; export interface TextParams { text: string; @@ -12,13 +12,7 @@ export interface TextParams { dropShadowBlur?: number; dropShadowColor?: string | number; dropShadowDistance?: number; - fill?: - | string - | string[] - | number - | number[] - | CanvasGradient - | CanvasPattern; + fill?: string | string[] | number | number[] | CanvasGradient | CanvasPattern; fillGradientType?: number; fillGradientStops?: number[]; fontFamily?: string | string[]; diff --git a/packages/plugin-renderer-text/lib/system.ts b/packages/plugin-renderer-text/lib/system.ts index c7554404..92125a14 100644 --- a/packages/plugin-renderer-text/lib/system.ts +++ b/packages/plugin-renderer-text/lib/system.ts @@ -1,22 +1,17 @@ -import {decorators, ComponentChanged, OBSERVER_TYPE} from '@eva/eva.js'; +import { decorators, ComponentChanged, OBSERVER_TYPE } from '@eva/eva.js'; -import { - RendererManager, - ContainerManager, - RendererSystem, - Renderer, -} from '@eva/plugin-renderer'; -import {Text as TextEngine} from '@eva/renderer-adapter'; +import { RendererManager, ContainerManager, RendererSystem, Renderer } from '@eva/plugin-renderer'; +import { Text as TextEngine } from '@eva/renderer-adapter'; import TextComponent from './component'; @decorators.componentObserver({ - Text: ['text', {prop: ['style'], deep: true}], + Text: ['text', { prop: ['style'], deep: true }], }) export default class Text extends Renderer { static systemName = 'Text'; name: string = 'Text'; texts: { - [propName: number]: {text: TextEngine; component: TextComponent}; + [propName: number]: { text: TextEngine; component: TextComponent }; } = {}; renderSystem: RendererSystem; rendererManager: RendererManager; @@ -30,19 +25,15 @@ export default class Text extends Renderer { if (changed.type === OBSERVER_TYPE.ADD) { const component = changed.component as TextComponent; const text = new TextEngine(component.text, component.style); - this.containerManager - .getContainer(changed.gameObject.id) - .addChildAt(text, 0); + this.containerManager.getContainer(changed.gameObject.id).addChildAt(text, 0); this.texts[changed.gameObject.id] = { text, component: changed.component as TextComponent, }; this.setSize(changed); } else if (changed.type === OBSERVER_TYPE.REMOVE) { - this.containerManager - .getContainer(changed.gameObject.id) - .removeChild(this.texts[changed.gameObject.id].text); - this.texts[changed.gameObject.id].text.destroy({ children: true }) + this.containerManager.getContainer(changed.gameObject.id).removeChild(this.texts[changed.gameObject.id].text); + this.texts[changed.gameObject.id].text.destroy({ children: true }); delete this.texts[changed.gameObject.id]; } else { this.change(changed); @@ -50,7 +41,7 @@ export default class Text extends Renderer { } } change(changed: ComponentChanged) { - const {text, component} = this.texts[changed.gameObject.id]; + const { text, component } = this.texts[changed.gameObject.id]; if (changed.prop.prop[0] === 'text') { text.text = component.text; } else if (changed.prop.prop[0] === 'style') { @@ -58,7 +49,7 @@ export default class Text extends Renderer { } } setSize(changed: ComponentChanged) { - const {transform} = changed.gameObject; + const { transform } = changed.gameObject; if (!transform) return; transform.size.width = this.texts[changed.gameObject.id].text.width; transform.size.height = this.texts[changed.gameObject.id].text.height; diff --git a/packages/plugin-renderer-tiling-sprite/README.md b/packages/plugin-renderer-tiling-sprite/README.md index 7157b316..f6907b95 100644 --- a/packages/plugin-renderer-tiling-sprite/README.md +++ b/packages/plugin-renderer-tiling-sprite/README.md @@ -1,7 +1,6 @@ - # @eva/plugin-renderer-tiling-sprite More Introduction + - [EN](https://eva.js.org) - [中文](https://eva-engine.gitee.io) - \ No newline at end of file diff --git a/packages/plugin-renderer-tiling-sprite/api-extractor.json b/packages/plugin-renderer-tiling-sprite/api-extractor.json index 69cb0d8f..43623177 100644 --- a/packages/plugin-renderer-tiling-sprite/api-extractor.json +++ b/packages/plugin-renderer-tiling-sprite/api-extractor.json @@ -4,4 +4,4 @@ "dtsRollup": { "publicTrimmedFilePath": "./dist/plugin-renderer-tiling-sprite.d.ts" } -} \ No newline at end of file +} diff --git a/packages/plugin-renderer-tiling-sprite/index.js b/packages/plugin-renderer-tiling-sprite/index.js index 4ca04da0..b73ee800 100644 --- a/packages/plugin-renderer-tiling-sprite/index.js +++ b/packages/plugin-renderer-tiling-sprite/index.js @@ -1,7 +1,7 @@ -'use strict' +'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/plugin-renderer-tiling-sprite.cjs.prod.js') + module.exports = require('./dist/plugin-renderer-tiling-sprite.cjs.prod.js'); } else { - module.exports = require('./dist/plugin-renderer-tiling-sprite.cjs.js') + module.exports = require('./dist/plugin-renderer-tiling-sprite.cjs.js'); } diff --git a/packages/plugin-renderer-tiling-sprite/lib/component.ts b/packages/plugin-renderer-tiling-sprite/lib/component.ts index 58fb585d..c726c281 100644 --- a/packages/plugin-renderer-tiling-sprite/lib/component.ts +++ b/packages/plugin-renderer-tiling-sprite/lib/component.ts @@ -1,9 +1,9 @@ -import {Component, decorators} from '@eva/eva.js'; +import { Component, decorators } from '@eva/eva.js'; export interface TilingSpriteParams { resource: string; - tileScale: {x: number; y: number}; - tilePosition: {x: number; y: number}; + tileScale: { x: number; y: number }; + tilePosition: { x: number; y: number }; } export default class TilingSprite extends Component { diff --git a/packages/plugin-renderer-tiling-sprite/lib/system.ts b/packages/plugin-renderer-tiling-sprite/lib/system.ts index 06167f21..6482b9c1 100644 --- a/packages/plugin-renderer-tiling-sprite/lib/system.ts +++ b/packages/plugin-renderer-tiling-sprite/lib/system.ts @@ -1,16 +1,5 @@ -import { - GameObject, - decorators, - resource, - ComponentChanged, - OBSERVER_TYPE, -} from '@eva/eva.js'; -import { - RendererManager, - ContainerManager, - RendererSystem, - Renderer, -} from '@eva/plugin-renderer'; +import { GameObject, decorators, resource, ComponentChanged, OBSERVER_TYPE } from '@eva/eva.js'; +import { RendererManager, ContainerManager, RendererSystem, Renderer } from '@eva/plugin-renderer'; import TilingSpriteComponent from './component'; import { TilingSprite as TilingSpriteEngine } from '@eva/renderer-adapter'; @@ -46,24 +35,18 @@ export default class TilingSprite extends Renderer { const sprite = new TilingSpriteEngine(null); resource.getResource(component.resource).then(({ data }) => { if (!data) { - throw new Error( - `GameObject:${changed.gameObject.name}'s TilingSprite resource load error`, - ); + throw new Error(`GameObject:${changed.gameObject.name}'s TilingSprite resource load error`); } sprite.image = data.image; }); this.imgs[changed.gameObject.id] = sprite; - this.containerManager - .getContainer(changed.gameObject.id) - .addChildAt(sprite.tilingSprite, 0); + this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite.tilingSprite, 0); this.setProp(changed.gameObject.id, component); } else if (changed.type === OBSERVER_TYPE.CHANGE) { if (changed.prop.prop[0] === 'resource') { const { data } = await resource.getResource(component.resource); if (!data) { - throw new Error( - `GameObject:${changed.gameObject.name}'s TilingSprite resource load error`, - ); + throw new Error(`GameObject:${changed.gameObject.name}'s TilingSprite resource load error`); } this.imgs[changed.gameObject.id].image = data.image; } else { @@ -71,9 +54,7 @@ export default class TilingSprite extends Renderer { } } else if (changed.type === OBSERVER_TYPE.REMOVE) { const sprite = this.imgs[changed.gameObject.id]; - this.containerManager - .getContainer(changed.gameObject.id) - .removeChild(sprite.tilingSprite); + this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite.tilingSprite); sprite.tilingSprite.destory(true); delete this.imgs[changed.gameObject.id]; } diff --git a/packages/plugin-renderer/README.md b/packages/plugin-renderer/README.md index e15bf367..6ac29e78 100644 --- a/packages/plugin-renderer/README.md +++ b/packages/plugin-renderer/README.md @@ -1,7 +1,6 @@ - # @eva/plugin-renderer More Introduction + - [EN](https://eva.js.org) - [中文](https://eva-engine.gitee.io) - \ No newline at end of file diff --git a/packages/plugin-renderer/api-extractor.json b/packages/plugin-renderer/api-extractor.json index 7fd57123..ed8dd173 100644 --- a/packages/plugin-renderer/api-extractor.json +++ b/packages/plugin-renderer/api-extractor.json @@ -4,4 +4,4 @@ "dtsRollup": { "publicTrimmedFilePath": "./dist/plugin-renderer.d.ts" } -} \ No newline at end of file +} diff --git a/packages/plugin-renderer/index.js b/packages/plugin-renderer/index.js index 700b398d..112aabb2 100644 --- a/packages/plugin-renderer/index.js +++ b/packages/plugin-renderer/index.js @@ -1,7 +1,7 @@ -'use strict' +'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/plugin-renderer.cjs.prod.js') + module.exports = require('./dist/plugin-renderer.cjs.prod.js'); } else { - module.exports = require('./dist/plugin-renderer.cjs.js') + module.exports = require('./dist/plugin-renderer.cjs.js'); } diff --git a/packages/plugin-renderer/lib/Renderer.ts b/packages/plugin-renderer/lib/Renderer.ts index 847b5326..29e98b8b 100644 --- a/packages/plugin-renderer/lib/Renderer.ts +++ b/packages/plugin-renderer/lib/Renderer.ts @@ -1,12 +1,6 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ -import { - GameObject, - Game, - PureObserverInfo, - ComponentChanged, - System, -} from '@eva/eva.js'; +import { GameObject, Game, PureObserverInfo, ComponentChanged, System } from '@eva/eva.js'; import ContainerManager from './manager/ContainerManager'; import RendererManager from './manager/RendererManager'; @@ -50,7 +44,7 @@ export default class Renderer extends System { * * called while the observed component props change. */ - componentChanged(_changed: ComponentChanged) { } + componentChanged(_changed: ComponentChanged) {} /** * 每帧调用 @@ -58,7 +52,7 @@ export default class Renderer extends System { * called by every loop * @param _gameObject gameObject */ - rendererUpdate(_gameObject: GameObject) { } + rendererUpdate(_gameObject: GameObject) {} update() { const changes = this.componentObserver.clear(); diff --git a/packages/plugin-renderer/lib/Transform.ts b/packages/plugin-renderer/lib/Transform.ts index d93df9df..1d19ceb1 100644 --- a/packages/plugin-renderer/lib/Transform.ts +++ b/packages/plugin-renderer/lib/Transform.ts @@ -1,12 +1,5 @@ -import { - Transform as Trans, - decorators, - ComponentChanged, - OBSERVER_TYPE, - Scene, - LOAD_SCENE_MODE -} from '@eva/eva.js'; -import EventEmitter from 'eventemitter3' +import { Transform as Trans, decorators, ComponentChanged, OBSERVER_TYPE, Scene, LOAD_SCENE_MODE } from '@eva/eva.js'; +import EventEmitter from 'eventemitter3'; import { Application, Container } from '@eva/renderer-adapter'; import Render from './System'; import ContainerManager from './manager/ContainerManager'; @@ -80,26 +73,18 @@ export default class Transform extends EventEmitter { change(changed: ComponentChanged) { const transform = changed.component as Trans; if (transform.parent) { - const parentContainer = this.containerManager.getContainer( - transform.parent.gameObject.id, - ); - parentContainer.addChild( - this.containerManager.getContainer(changed.gameObject.id), - ); + const parentContainer = this.containerManager.getContainer(transform.parent.gameObject.id); + parentContainer.addChild(this.containerManager.getContainer(changed.gameObject.id)); const render = changed.gameObject.transform.parent && - (changed.gameObject.transform.parent.gameObject.getComponent( - 'Render', - ) as any); + (changed.gameObject.transform.parent.gameObject.getComponent('Render') as any); if (render) { render.sortDirty = true; } } else { - const container = this.containerManager.getContainer( - changed.gameObject.id, - ); - delete transform.worldTransform + const container = this.containerManager.getContainer(changed.gameObject.id); + delete transform.worldTransform; container.parent && container.parent.removeChild(container); } } diff --git a/packages/plugin-renderer/lib/index.ts b/packages/plugin-renderer/lib/index.ts index 8f458ce6..4e864477 100644 --- a/packages/plugin-renderer/lib/index.ts +++ b/packages/plugin-renderer/lib/index.ts @@ -1,12 +1,6 @@ -import RendererSystem, {RENDERER_TYPE} from './System'; +import RendererSystem, { RENDERER_TYPE } from './System'; import RendererManager from './manager/RendererManager'; import ContainerManager from './manager/ContainerManager'; import Renderer from './Renderer'; -export { - RendererManager, - ContainerManager, - RendererSystem, - RENDERER_TYPE, - Renderer, -}; +export { RendererManager, ContainerManager, RendererSystem, RENDERER_TYPE, Renderer }; diff --git a/packages/plugin-renderer/lib/manager/ContainerManager.ts b/packages/plugin-renderer/lib/manager/ContainerManager.ts index cf787d72..d53acd2f 100644 --- a/packages/plugin-renderer/lib/manager/ContainerManager.ts +++ b/packages/plugin-renderer/lib/manager/ContainerManager.ts @@ -1,23 +1,23 @@ -import {Transform} from '@eva/eva.js'; -import {Point, ObservablePoint} from 'pixi.js'; -import {Container} from '@eva/renderer-adapter'; +import { Transform } from '@eva/eva.js'; +import { Point, ObservablePoint } from 'pixi.js'; +import { Container } from '@eva/renderer-adapter'; export default class ContainerManager { - containerMap: {[propName: number]: Container} = {}; - addContainer({name, container}: {name: number; container: Container}) { + containerMap: { [propName: number]: Container } = {}; + addContainer({ name, container }: { name: number; container: Container }) { this.containerMap[name] = container; } getContainer(name: number) { return this.containerMap[name]; } removeContainer(name: number) { - this.containerMap[name]?.destroy({ children: true }) + this.containerMap[name]?.destroy({ children: true }); delete this.containerMap[name]; } - updateTransform({name, transform}: {name: number; transform: Transform}) { + updateTransform({ name, transform }: { name: number; transform: Transform }) { const container = this.containerMap[name]; if (!container) return; - const {anchor, origin, position, rotation, scale, size, skew} = transform; + const { anchor, origin, position, rotation, scale, size, skew } = transform; container.rotation = rotation; container.scale = scale as Point; container.pivot.x = size.width * origin.x; @@ -31,6 +31,6 @@ export default class ContainerManager { y = y + parent.size.height * anchor.y; } - container.position = {x, y} as Point; + container.position = { x, y } as Point; } } diff --git a/packages/plugin-renderer/lib/manager/RendererManager.ts b/packages/plugin-renderer/lib/manager/RendererManager.ts index 41447794..89ee3925 100644 --- a/packages/plugin-renderer/lib/manager/RendererManager.ts +++ b/packages/plugin-renderer/lib/manager/RendererManager.ts @@ -24,17 +24,11 @@ class RendererManager { for (const renderer of this.renderers) { const props = renderer.observerInfo[changed.componentName]; if (props) { - if ( - [OBSERVER_TYPE.ADD, OBSERVER_TYPE.REMOVE].indexOf(changed.type) > -1 - ) { + if ([OBSERVER_TYPE.ADD, OBSERVER_TYPE.REMOVE].indexOf(changed.type) > -1) { try { renderer.componentChanged && renderer.componentChanged(changed); } catch (e) { - console.error( - `gameObject: ${changed.gameObject.name}, ${changed.componentName} is error.`, - changed, - e, - ); + console.error(`gameObject: ${changed.gameObject.name}, ${changed.componentName} is error.`, changed, e); } continue; } @@ -48,8 +42,9 @@ class RendererManager { renderer.componentChanged && renderer.componentChanged(changed); } catch (e) { console.error( - `gameObject: ${changed.gameObject && changed.gameObject.name - }, ${changed.componentName} is componentChanged error.`, + `gameObject: ${changed.gameObject && changed.gameObject.name}, ${ + changed.componentName + } is componentChanged error.`, changed, e, ); @@ -69,10 +64,7 @@ class RendererManager { try { renderer.rendererUpdate && renderer.rendererUpdate(gameObject); } catch (e) { - console.info( - `gameObject: ${gameObject.name}, ${component.name} is update error`, - e, - ); + console.info(`gameObject: ${gameObject.name}, ${component.name} is update error`, e); } } } diff --git a/packages/plugin-sound/README.md b/packages/plugin-sound/README.md index e758c69f..ff096286 100644 --- a/packages/plugin-sound/README.md +++ b/packages/plugin-sound/README.md @@ -1,7 +1,6 @@ - # @eva/plugin-sound More Introduction + - [EN](https://eva.js.org) - [中文](https://eva-engine.gitee.io) - \ No newline at end of file diff --git a/packages/plugin-sound/api-extractor.json b/packages/plugin-sound/api-extractor.json index 4e21b017..9927a5c3 100644 --- a/packages/plugin-sound/api-extractor.json +++ b/packages/plugin-sound/api-extractor.json @@ -4,4 +4,4 @@ "dtsRollup": { "publicTrimmedFilePath": "./dist/plugin-sound.d.ts" } -} \ No newline at end of file +} diff --git a/packages/plugin-sound/index.js b/packages/plugin-sound/index.js index 635e958a..d043d3d4 100644 --- a/packages/plugin-sound/index.js +++ b/packages/plugin-sound/index.js @@ -1,7 +1,7 @@ -'use strict' +'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/plugin-sound.cjs.prod.js') + module.exports = require('./dist/plugin-sound.cjs.prod.js'); } else { - module.exports = require('./dist/plugin-sound.cjs.js') + module.exports = require('./dist/plugin-sound.cjs.js'); } diff --git a/packages/plugin-sound/lib/Sound.ts b/packages/plugin-sound/lib/Sound.ts index 1abaaaf5..6ffcf3af 100644 --- a/packages/plugin-sound/lib/Sound.ts +++ b/packages/plugin-sound/lib/Sound.ts @@ -153,7 +153,7 @@ class Sound extends Component { this.state = 'loaded'; this.buffer = buffer; this.duration = this.buffer.duration; - this.actionQueue.forEach((action) => action()); + this.actionQueue.forEach(action => action()); this.actionQueue.length = 0; } diff --git a/packages/plugin-sound/lib/SoundSystem.ts b/packages/plugin-sound/lib/SoundSystem.ts index 97d63efe..92978666 100644 --- a/packages/plugin-sound/lib/SoundSystem.ts +++ b/packages/plugin-sound/lib/SoundSystem.ts @@ -1,10 +1,4 @@ -import { - System, - decorators, - ComponentChanged, - OBSERVER_TYPE, - resource, -} from '@eva/eva.js'; +import { System, decorators, ComponentChanged, OBSERVER_TYPE, resource } from '@eva/eva.js'; import SoundComponent from './Sound'; interface SoundSystemParams { @@ -74,7 +68,7 @@ class SoundSystem extends System { */ resumeAll() { const handleResume = () => { - this.pausedComponents.forEach((component) => { + this.pausedComponents.forEach(component => { component.play(); }); // 清理之前缓存的暂停列表 @@ -87,7 +81,7 @@ class SoundSystem extends System { * 暂停所有正在播放的音频 */ pauseAll() { - this.components.forEach((component) => { + this.components.forEach(component => { if (component.playing) { this.pausedComponents.push(component); component.pause(); @@ -100,7 +94,7 @@ class SoundSystem extends System { * 停止所有正在播放的音频 */ stopAll() { - this.components.forEach((component) => { + this.components.forEach(component => { if (component.playing) { component.stop(); } @@ -155,7 +149,7 @@ class SoundSystem extends System { * Called while the system be destroyed. */ onDestroy() { - this.components.forEach((component) => { + this.components.forEach(component => { component.onDestroy(); }); this.components = []; @@ -178,8 +172,7 @@ class SoundSystem extends System { private setupAudioContext() { try { - const AudioContext = - window.AudioContext || (window as any).webkitAudioContext; + const AudioContext = window.AudioContext || (window as any).webkitAudioContext; this.ctx = new AudioContext(); } catch (error) { console.error(error); @@ -192,13 +185,8 @@ class SoundSystem extends System { return; } this.gainNode = - typeof this.ctx.createGain === 'undefined' - ? (this.ctx as any).createGainNode() - : this.ctx.createGain(); - this.gainNode.gain.setValueAtTime( - this.muted ? 0 : this.volume, - this.ctx.currentTime - ); + typeof this.ctx.createGain === 'undefined' ? (this.ctx as any).createGainNode() : this.ctx.createGain(); + this.gainNode.gain.setValueAtTime(this.muted ? 0 : this.volume, this.ctx.currentTime); this.gainNode.connect(this.ctx.destination); this.unlockAudio(); } @@ -232,10 +220,7 @@ class SoundSystem extends System { const audio = await resource.getResource(config.resource); if (!this.audioBufferCache[audio.name]) { - this.audioBufferCache[audio.name] = await this.decodeAudioData( - audio.data.audio, - audio.name, - ); + this.audioBufferCache[audio.name] = await this.decodeAudioData(audio.data.audio, audio.name); } if (this.audioBufferCache[audio.name]) { component.systemContext = this.ctx; @@ -262,8 +247,7 @@ class SoundSystem extends System { if (this.decodeAudioPromiseMap[name]) { delete this.decodeAudioPromiseMap[name]; } - reject(new Error(`${err}. arrayBuffer byteLength: ${arraybuffer ? arraybuffer.byteLength : 0 - }`)); + reject(new Error(`${err}. arrayBuffer byteLength: ${arraybuffer ? arraybuffer.byteLength : 0}`)); }; const success = (decodedData: AudioBuffer) => { if (this.decodeAudioPromiseMap[name]) { diff --git a/packages/plugin-stats/README.md b/packages/plugin-stats/README.md index 51e83458..f80a0ed1 100644 --- a/packages/plugin-stats/README.md +++ b/packages/plugin-stats/README.md @@ -1,7 +1,6 @@ - # @eva/plugin-stats More Introduction + - [EN](https://eva.js.org) - [中文](https://eva-engine.gitee.io) - \ No newline at end of file diff --git a/packages/plugin-stats/api-extractor.json b/packages/plugin-stats/api-extractor.json index 1e9d10a2..af5db147 100644 --- a/packages/plugin-stats/api-extractor.json +++ b/packages/plugin-stats/api-extractor.json @@ -4,4 +4,4 @@ "dtsRollup": { "publicTrimmedFilePath": "./dist/plugin-stats.d.ts" } -} \ No newline at end of file +} diff --git a/packages/plugin-stats/index.js b/packages/plugin-stats/index.js index 3181a5bb..b7fa14ea 100644 --- a/packages/plugin-stats/index.js +++ b/packages/plugin-stats/index.js @@ -1,7 +1,7 @@ -'use strict' +'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/plugin-stats.cjs.prod.js') + module.exports = require('./dist/plugin-stats.cjs.prod.js'); } else { - module.exports = require('./dist/plugin-stats.cjs.js') + module.exports = require('./dist/plugin-stats.cjs.js'); } diff --git a/packages/plugin-stats/lib/Stats.ts b/packages/plugin-stats/lib/Stats.ts index 68593044..f597fc96 100644 --- a/packages/plugin-stats/lib/Stats.ts +++ b/packages/plugin-stats/lib/Stats.ts @@ -2,16 +2,16 @@ * @author mrdoob / http://mrdoob.com/ */ -const Stats = function(style) { - style = {...{width: 20, height: 12, x: 0, y: 0}, ...style}; - const {width, height, x, y} = style; +const Stats = function (style) { + style = { ...{ width: 20, height: 12, x: 0, y: 0 }, ...style }; + const { width, height, x, y } = style; let mode = 0; const container = document.createElement('div'); container.style.cssText = `position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000;width: ${width}vw;height: ${height}vw;left: ${x}vw;top: ${y}vw;`; container.addEventListener( 'click', - function(event) { + function (event) { event.preventDefault(); showPanel(++mode % container.children.length); }, @@ -54,11 +54,11 @@ const Stats = function(style) { addPanel: addPanel, showPanel: showPanel, - begin: function(time) { + begin: function (time) { beginTime = time || (performance || Date).now(); }, - end: function() { + end: function () { frames++; const time = (performance || Date).now(); @@ -74,17 +74,14 @@ const Stats = function(style) { if (memPanel) { // @ts-ignore const memory = performance.memory; - memPanel.update( - memory.usedJSHeapSize / 1048576, - memory.jsHeapSizeLimit / 1048576, - ); + memPanel.update(memory.usedJSHeapSize / 1048576, memory.jsHeapSizeLimit / 1048576); } } return time; }, - update: function() { + update: function () { beginTime = this.end(); }, @@ -95,7 +92,7 @@ const Stats = function(style) { }; }; -Stats.Panel = function(name, fg, bg) { +Stats.Panel = function (name, fg, bg) { let min = Infinity, max = 0; const round = Math.round; @@ -133,7 +130,7 @@ Stats.Panel = function(name, fg, bg) { return { dom: canvas, - update: function(value, maxValue) { + update: function (value, maxValue) { min = Math.min(min, value); max = Math.max(max, value); @@ -141,11 +138,7 @@ Stats.Panel = function(name, fg, bg) { context.globalAlpha = 1; context.fillRect(0, 0, WIDTH, GRAPH_Y); context.fillStyle = fg; - context.fillText( - round(value) + ' ' + name + ' (' + round(min) + '-' + round(max) + ')', - TEXT_X, - TEXT_Y, - ); + context.fillText(round(value) + ' ' + name + ' (' + round(min) + '-' + round(max) + ')', TEXT_X, TEXT_Y); context.drawImage( canvas, @@ -163,12 +156,7 @@ Stats.Panel = function(name, fg, bg) { context.fillStyle = bg; context.globalAlpha = 0.9; - context.fillRect( - GRAPH_X + GRAPH_WIDTH - PR, - GRAPH_Y, - PR, - round((1 - value / maxValue) * GRAPH_HEIGHT), - ); + context.fillRect(GRAPH_X + GRAPH_WIDTH - PR, GRAPH_Y, PR, round((1 - value / maxValue) * GRAPH_HEIGHT)); }, }; }; diff --git a/packages/plugin-stats/lib/StatsComponent.ts b/packages/plugin-stats/lib/StatsComponent.ts index ddc4a0bf..22e424b2 100644 --- a/packages/plugin-stats/lib/StatsComponent.ts +++ b/packages/plugin-stats/lib/StatsComponent.ts @@ -1,4 +1,4 @@ -import {Component} from '@eva/eva.js'; +import { Component } from '@eva/eva.js'; export default class StatsComponent extends Component { static componentName: string = 'Stats'; diff --git a/packages/plugin-stats/lib/StatsSystem.ts b/packages/plugin-stats/lib/StatsSystem.ts index c9667302..3c0fe113 100644 --- a/packages/plugin-stats/lib/StatsSystem.ts +++ b/packages/plugin-stats/lib/StatsSystem.ts @@ -1,4 +1,4 @@ -import {System} from '@eva/eva.js'; +import { System } from '@eva/eva.js'; import StatsComponent from './StatsComponent'; import Stats from './Stats'; @@ -18,7 +18,7 @@ export default class StatsSystem extends System { stats; style; component: StatsComponent; - init(param: StatsParams = {show: true}) { + init(param: StatsParams = { show: true }) { this.show = param.show; this.style = param.style; } diff --git a/packages/plugin-transition/README.md b/packages/plugin-transition/README.md index 3581ff86..2c8302a3 100644 --- a/packages/plugin-transition/README.md +++ b/packages/plugin-transition/README.md @@ -1,7 +1,6 @@ - # @eva/plugin-transition More Introduction + - [EN](https://eva.js.org) - [中文](https://eva-engine.gitee.io) - \ No newline at end of file diff --git a/packages/plugin-transition/api-extractor.json b/packages/plugin-transition/api-extractor.json index 84ce2f49..4c8f7f47 100644 --- a/packages/plugin-transition/api-extractor.json +++ b/packages/plugin-transition/api-extractor.json @@ -4,4 +4,4 @@ "dtsRollup": { "publicTrimmedFilePath": "./dist/plugin-transition.d.ts" } -} \ No newline at end of file +} diff --git a/packages/plugin-transition/index.js b/packages/plugin-transition/index.js index 67c5b8a7..c7aeb9bb 100644 --- a/packages/plugin-transition/index.js +++ b/packages/plugin-transition/index.js @@ -1,7 +1,7 @@ -'use strict' +'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/plugin-transition.cjs.prod.js') + module.exports = require('./dist/plugin-transition.cjs.prod.js'); } else { - module.exports = require('./dist/plugin-transition.cjs.js') + module.exports = require('./dist/plugin-transition.cjs.js'); } diff --git a/packages/plugin-transition/lib/component.ts b/packages/plugin-transition/lib/component.ts index 8c448684..cb7d7bc2 100644 --- a/packages/plugin-transition/lib/component.ts +++ b/packages/plugin-transition/lib/component.ts @@ -12,7 +12,7 @@ interface AnimationStruct { }[]; } interface TransitionParams { - group: Record + group: Record; } export default class Transition extends Component { static componentName: string = 'Transition'; diff --git a/packages/renderer-adapter/README.md b/packages/renderer-adapter/README.md index 2eea8705..71a5ac6e 100644 --- a/packages/renderer-adapter/README.md +++ b/packages/renderer-adapter/README.md @@ -1,7 +1,6 @@ - # @eva/renderer-adapter More Introduction + - [EN](https://eva.js.org) - [中文](https://eva-engine.gitee.io) - \ No newline at end of file diff --git a/packages/renderer-adapter/api-extractor.json b/packages/renderer-adapter/api-extractor.json index 224d5177..ab4183fa 100644 --- a/packages/renderer-adapter/api-extractor.json +++ b/packages/renderer-adapter/api-extractor.json @@ -4,4 +4,4 @@ "dtsRollup": { "publicTrimmedFilePath": "./dist/renderer-adapter.d.ts" } -} \ No newline at end of file +} diff --git a/packages/renderer-adapter/index.js b/packages/renderer-adapter/index.js index ce3e65ce..a1f7c957 100644 --- a/packages/renderer-adapter/index.js +++ b/packages/renderer-adapter/index.js @@ -1,7 +1,7 @@ -'use strict' +'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./dist/renderer-adapter.cjs.prod.js') + module.exports = require('./dist/renderer-adapter.cjs.prod.js'); } else { - module.exports = require('./dist/renderer-adapter.cjs.js') + module.exports = require('./dist/renderer-adapter.cjs.js'); } diff --git a/packages/renderer-adapter/lib/Application.ts b/packages/renderer-adapter/lib/Application.ts index 67393304..bdd91e17 100644 --- a/packages/renderer-adapter/lib/Application.ts +++ b/packages/renderer-adapter/lib/Application.ts @@ -1,4 +1,4 @@ -import {Application as PIXIApplication} from 'pixi.js'; +import { Application as PIXIApplication } from 'pixi.js'; export default class Application extends PIXIApplication { constructor(params?: any) { params.autoStart = false; diff --git a/packages/renderer-adapter/lib/Container.ts b/packages/renderer-adapter/lib/Container.ts index ecbda969..7b00da85 100644 --- a/packages/renderer-adapter/lib/Container.ts +++ b/packages/renderer-adapter/lib/Container.ts @@ -1,4 +1,4 @@ -import {Container as PIXIContainer} from 'pixi.js'; +import { Container as PIXIContainer } from 'pixi.js'; export default class Container extends PIXIContainer { [propName: string]: any; diff --git a/packages/renderer-adapter/lib/Graphics.ts b/packages/renderer-adapter/lib/Graphics.ts index 74869c2b..7de96d6f 100644 --- a/packages/renderer-adapter/lib/Graphics.ts +++ b/packages/renderer-adapter/lib/Graphics.ts @@ -1,4 +1,4 @@ -import {Graphics as PIXIGraphics} from 'pixi.js'; +import { Graphics as PIXIGraphics } from 'pixi.js'; export default class Graphics extends PIXIGraphics { [propName: string]: any; } diff --git a/packages/renderer-adapter/lib/NinePatch.ts b/packages/renderer-adapter/lib/NinePatch.ts index bb08daaf..ba3eb839 100644 --- a/packages/renderer-adapter/lib/NinePatch.ts +++ b/packages/renderer-adapter/lib/NinePatch.ts @@ -1,4 +1,4 @@ -import {Texture, mesh} from 'pixi.js'; +import { Texture, mesh } from 'pixi.js'; export default class NinePatch extends mesh.NineSlicePlane { constructor(img, leftWidth, topHeight, rightWidth, bottomHeight) { diff --git a/packages/renderer-adapter/lib/Sprite.ts b/packages/renderer-adapter/lib/Sprite.ts index 9cb76280..767f2887 100644 --- a/packages/renderer-adapter/lib/Sprite.ts +++ b/packages/renderer-adapter/lib/Sprite.ts @@ -1,4 +1,4 @@ -import {Texture as PIXITexture, Sprite as PIXISprite} from 'pixi.js'; +import { Texture as PIXITexture, Sprite as PIXISprite } from 'pixi.js'; export default class Sprite { _image: HTMLImageElement | PIXITexture = null; diff --git a/packages/renderer-adapter/lib/SpriteAnimation.ts b/packages/renderer-adapter/lib/SpriteAnimation.ts index dd278bb5..43a47da9 100644 --- a/packages/renderer-adapter/lib/SpriteAnimation.ts +++ b/packages/renderer-adapter/lib/SpriteAnimation.ts @@ -1,8 +1,8 @@ -import {extras} from 'pixi.js'; +import { extras } from 'pixi.js'; export default class SpriteAnimation { animatedSprite: extras.AnimatedSprite; - constructor({frames}) { + constructor({ frames }) { this.animatedSprite = new extras.AnimatedSprite(frames); } play() { diff --git a/packages/renderer-adapter/lib/Text.ts b/packages/renderer-adapter/lib/Text.ts index ba25a428..857c8e9a 100644 --- a/packages/renderer-adapter/lib/Text.ts +++ b/packages/renderer-adapter/lib/Text.ts @@ -1,4 +1,4 @@ -import {Text as PIXIText} from 'pixi.js'; +import { Text as PIXIText } from 'pixi.js'; export default class Text extends PIXIText { text: string; diff --git a/packages/renderer-adapter/lib/TilingSprite.ts b/packages/renderer-adapter/lib/TilingSprite.ts index 2d5d36a8..9f5c482b 100644 --- a/packages/renderer-adapter/lib/TilingSprite.ts +++ b/packages/renderer-adapter/lib/TilingSprite.ts @@ -1,4 +1,4 @@ -import {Texture as PIXITexture, extras} from 'pixi.js'; +import { Texture as PIXITexture, extras } from 'pixi.js'; const PIXITilingSprite = extras.TilingSprite; export default class TilingSprite {