Files
Foundry-VTT-Docker/resources/app/node_modules/@pixi/sprite-animated/lib/AnimatedSprite.mjs.map

1 line
17 KiB
Plaintext
Raw Normal View History

2025-01-04 00:34:03 +01:00
{"version":3,"file":"AnimatedSprite.mjs","sources":["../src/AnimatedSprite.ts"],"sourcesContent":["import { Texture, Ticker, UPDATE_PRIORITY } from '@pixi/core';\nimport { Sprite } from '@pixi/sprite';\n\nimport type { IDestroyOptions } from '@pixi/display';\n\n/**\n * An AnimatedSprite is a simple way to display an animation depicted by a list of textures.\n *\n * ```js\n * import { AnimatedSprite, Texture } from 'pixi.js';\n *\n * const alienImages = [\n * 'image_sequence_01.png',\n * 'image_sequence_02.png',\n * 'image_sequence_03.png',\n * 'image_sequence_04.png',\n * ];\n * const textureArray = [];\n *\n * for (let i = 0; i < 4; i++)\n * {\n * const texture = Texture.from(alienImages[i]);\n * textureArray.push(texture);\n * }\n *\n * const animatedSprite = new AnimatedSprite(textureArray);\n * ```\n *\n * The more efficient and simpler way to create an animated sprite is using a {@link PIXI.Spritesheet}\n * containing the animation definitions:\n * @example\n * import { AnimatedSprite, Assets } from 'pixi.js';\n *\n * const sheet = await Assets.load('assets/spritesheet.json');\n * animatedSprite = new AnimatedSprite(sheet.animations['image_sequence']);\n * @memberof PIXI\n */\nexport class AnimatedSprite extends Sprite\n{\n /**\n * The speed that the AnimatedSprite will play at. Higher is faster, lower is slower.\n * @default 1\n */\n public animationSpeed: number;\n\n /**\n * Whether or not the animate sprite repeats after playing.\n * @default true\n */\n public loop: boolean;\n\n /**\n * Update anchor to [Texture's defaultAnchor]{@link PIXI.Texture#defaultAnchor} when frame changes.\n *\n * Useful with [sprite sheet animations]{@link PIXI.Spritesheet#animations} created with tools.\n * Changing anchor for each frame allows to pin sprite origin to certain moving feature\n * of the frame (e.g. left foot).\n *\n * Note: Enabling this will override any previously set `anchor` on each frame change.\n * @default false\n */\n public updateAnchor: boolean;\n\n /**\n * User-assigned function to call when an AnimatedSprite finishes playing.\n * @example\n * animation.onComplete = () => {\n * // Finished!\n * };\n */\n public onComplete?: () => void;\n\n /**\n * User-assigned function to call when an AnimatedSprite changes which texture is being rendered.\n * @example\n * animation.onFrameChange = () => {\n * // Updated!\n * };\n */\n public onFrameChange?: (currentFrame: number) => void;\n\n /**\n * User-assigned function to call when `loop` is true, and an AnimatedSprite is played and\n * loops around to start again.\n * @example\n * animation.onLoop = () => {\n * // Looped!\n * };\n */\n public onLoop?: () => void;\n\n private _playing: boolean;\n private _textures: Texture[];\n private _durations: number[];\n\n /**\n * `true` uses PIXI.Ticker.shared to auto update animation time.\n * @default true\n */\n private _autoUpdate: boolean;\n\n /**\n * `true` if the instance is currently connected to PIXI.Ticker.shared to auto update animation time.\n * @default false\n */\n private _isConnectedToTicker: boolean;\n\n /** Elapsed time since animation has been started, used internally to display current texture. */\n private _currentTime: number;\n\n /** The texture index that was displayed last time. */\n private _previousFrame: number;\n\n /**\n * @param textures - An array of {@link PIXI.Texture} or frame\n * objects that make up the animation.\n * @param {boolean} [autoUpdate=true] - Whether to use Ticker.shared to auto update animation time.\n */\n constructor(textures: Texture[] | FrameObject[], autoUpdate = true)\n {\n super(textures[0] instanceof Texture ? textures[0] : textures[0].texture);\n\n this._textures = null;\n this._durations = null;\n this._autoUpdate = autoUpdate;\n this._isConnectedToTic