/****************************************************************************** * Spine Runtimes License Agreement * Last updated July 28, 2023. Replaces all prior versions. * * Copyright (c) 2013-2023, Esoteric Software LLC * * Integration of the Spine Runtimes into software or otherwise creating * derivative works of the Spine Runtimes is permitted under the terms and * conditions of Section 2 of the Spine Editor License Agreement: * http://esotericsoftware.com/spine-editor-license * * Otherwise, it is permitted to integrate the Spine Runtimes into software or * otherwise create derivative works of the Spine Runtimes (collectively, * "Products"), provided that each user of the Products must obtain their own * Spine Editor license and redistribution of the Products in any form must * include this license and copyright notice. * * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ import * as Phaser from "phaser"; import { SceneRenderer, Skeleton, SkeletonData, TextureAtlas } from "@esotericsoftware/spine-webgl"; import { SpineGameObjectBoundsProvider } from "./SpineGameObject.js"; import { SkeletonRenderer } from "@esotericsoftware/spine-canvas"; /** * Configuration object used when creating {@link SpineGameObject} instances via a scene's * {@link GameObjectCreator} (`Scene.make`). */ export interface SpineGameObjectConfig extends Phaser.Types.GameObjects.GameObjectConfig { /** The x-position of the object, optional, default: 0 */ x?: number; /** The y-position of the object, optional, default: 0 */ y?: number; /** The skeleton data key */ dataKey: string; /** The atlas key */ atlasKey: string; /** The bounds provider, optional, default: `SetupPoseBoundsProvider` */ boundsProvider?: SpineGameObjectBoundsProvider; } /** * {@link ScenePlugin} implementation adding Spine Runtime capabilities to a scene. * * The scene's {@link LoaderPlugin} (`Scene.load`) gets these additional functions: * * `spineBinary(key: string, url: string, xhrSettings?: XHRSettingsObject)`: loads a skeleton binary `.skel` file from the `url`. * * `spineJson(key: string, url: string, xhrSettings?: XHRSettingsObject)`: loads a skeleton binary `.skel` file from the `url`. * * `spineAtlas(key: string, url: string, premultipliedAlpha: boolean = true, xhrSettings?: XHRSettingsObject)`: loads a texture atlas `.atlas` file from the `url` as well as its correponding texture atlas page images. * * The scene's {@link GameObjectFactory} (`Scene.add`) gets these additional functions: * * `spine(x: number, y: number, dataKey: string, atlasKey: string, boundsProvider: SpineGameObjectBoundsProvider = SetupPoseBoundsProvider())`: * creates a new {@link SpineGameObject} from the data and atlas at position `(x, y)`, using the {@link BoundsProvider} to calculate its bounding box. The object is automatically added to the scene. * * The scene's {@link GameObjectCreator} (`Scene.make`) gets these additional functions: * * `spine(config: SpineGameObjectConfig)`: creates a new {@link SpineGameObject} from the given configuration object. * * The plugin has additional public methods to work with Spine Runtime core API objects: * * `getAtlas(atlasKey: string)`: returns the {@link TextureAtlas} instance for the given atlas key. * * `getSkeletonData(skeletonDataKey: string)`: returns the {@link SkeletonData} instance for the given skeleton data key. * * `createSkeleton(skeletonDataKey: string, atlasKey: string, premultipliedAlpha: boolean = true)`: creates a new {@link Skeleton} instance from the given skeleton data and atlas key. * * `isPremultipliedAlpha(atlasKey: string)`: returns `true` if the atlas with the given key has premultiplied alpha. */ export declare class SpinePlugin extends Phaser.Plugins.ScenePlugin { game: Phaser.Game; private isWebGL; gl: WebGLRenderingContext | null; static gameWebGLRenderer: SceneRenderer | null; get webGLRenderer(): SceneRenderer | null; canvasRenderer: SkeletonRenderer | null; phaserRenderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; private skeletonDataCache; private atlasCache; constructor(scene: Phaser.Scene, pluginManager: Phaser.Plugins.PluginManager, pluginKey: string); static rendererId: number; boot(): void; onResize(): void; shutdown(): void; destroy(): void; gameDestroy(): void; /** Returns the TextureAtlas instance for the given key */ getAtlas(atlasKey: string): TextureAtlas; /** Returns whether the TextureAtlas uses premultiplied alpha */ isAtlasPremultiplied(atlasKey: string): any; /** Returns the SkeletonData instance for the given data and atlas key */ getSkeletonData(dataKey: string, atlasKey: string): SkeletonData; /** Creates a new Skeleton instance from the data and atlas. */ createSkeleton(dataKey: string, atlasKey: string): Skeleton; }