/****************************************************************************** * Spine Runtimes License Agreement * Last updated April 5, 2025. Replaces all prior versions. * * Copyright (c) 2013-2025, 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 { SkeletonRenderer } from "@esotericsoftware/spine-canvas"; import { type SceneRenderer, Skeleton, type SkeletonData } from "@esotericsoftware/spine-webgl"; import * as Phaser from "phaser"; import { SPINE_GAME_OBJECT_TYPE } from "./keys.js"; import { type SpineGameObjectRendererType } from "./SpineGameObject.js"; import { type SpineGameObjectBoundsProvider } from "./SpineGameObjectBounds.js"; /** * 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; /** Renderer backend, optional, default: `phaser` in WebGL games and `spine-canvas` in Canvas games */ renderer?: SpineGameObjectRendererType; } /** Options for loading a skeleton data file with `this.load.spineSkeleton(...)`. */ export interface SpineSkeletonFileOptions { /** Explicit data format. When omitted, the format is inferred from the `.json` or `.skel` URL extension. */ format?: "json" | "binary"; /** Optional Phaser XHR settings used to load the skeleton data file. */ xhrSettings?: Phaser.Types.Loader.XHRSettingsObject; } /** Options for loading a texture atlas file with `this.load.spineAtlas(...)`. */ export interface SpineAtlasFileOptions { /** Optional Phaser XHR settings used to load the texture atlas file. */ xhrSettings?: Phaser.Types.Loader.XHRSettingsObject; } /** Adds Spine asset loading, GameObject creation, and runtime accessors to a Phaser scene. */ export declare class SpinePlugin extends Phaser.Plugins.ScenePlugin { game: Phaser.Game; readonly isWebGL: boolean; gl: WebGLRenderingContext | null; /** Lazily created Spine WebGL scene renderer shared by every scene in this game, or `null` in Canvas games. */ get webGLRenderer(): SceneRenderer | null; canvasRenderer: SkeletonRenderer | null; phaserRenderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; currentWebGLDrawingContext: Phaser.Renderer.WebGL.DrawingContext | null; spineAdditiveBlendMode: Phaser.BlendModes; private skeletonDataCache; private atlasCache; constructor(scene: Phaser.Scene, pluginManager: Phaser.Plugins.PluginManager, pluginKey: string); static rendererId: number; /** Initializes renderer resources and plugin event listeners. */ boot(): void; /** Updates the shared Spine WebGL renderer camera after Phaser renderer size changes. */ onResize(): void; onStart(): void; shutdown(): void; destroy(): void; gameDestroy(): void; /** * Returns the TextureAtlas instance for the given key. * @param atlasKey Phaser cache key for the loaded Spine atlas. * @returns The Spine TextureAtlas instance. */ getAtlas(atlasKey: string): any; /** * Returns whether the TextureAtlas uses premultiplied alpha. * @param atlasKey Phaser cache key for the loaded Spine atlas. * @returns True if the first atlas page is marked PMA. */ isAtlasPremultiplied(atlasKey: string): boolean; /** * Returns the SkeletonData instance for the given data and atlas keys. * @param dataKey Phaser cache key for the loaded Spine skeleton data. * @param atlasKey Phaser cache key for the loaded Spine atlas. * @returns The Spine SkeletonData instance. */ getSkeletonData(dataKey: string, atlasKey: string): SkeletonData; /** * Creates a new Skeleton instance from the data and atlas keys. * @param dataKey Phaser cache key for the loaded Spine skeleton data. * @param atlasKey Phaser cache key for the loaded Spine atlas. * @returns A new Spine Skeleton instance. */ createSkeleton(dataKey: string, atlasKey: string): Skeleton; } declare global { interface Window { SPINE_GAME_OBJECT_TYPE?: typeof SPINE_GAME_OBJECT_TYPE; } }