UNPKG

@esotericsoftware/spine-player

Version:
168 lines (167 loc) 5.98 kB
/****************************************************************************** * 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 { Animation, AnimationState, Color, Disposable, Downloader, Skeleton, StringMap, TimeKeeper, TrackEntry } from "@esotericsoftware/spine-core"; import { AssetManager, LoadingScreen, ManagedWebGLRenderingContext, SceneRenderer } from "@esotericsoftware/spine-webgl"; export interface SpinePlayerConfig { jsonUrl?: string; jsonField?: string; binaryUrl?: string; atlasUrl?: string; rawDataURIs?: StringMap<string>; animation?: string; animations?: string[]; defaultMix?: number; skin?: string; skins?: string[]; premultipliedAlpha?: boolean; showControls?: boolean; showLoading?: boolean; debug?: { bones: boolean; regions: boolean; meshes: boolean; bounds: boolean; paths: boolean; clipping: boolean; points: boolean; hulls: boolean; }; viewport?: { x?: number; y?: number; width?: number; height?: number; padLeft?: string | number; padRight?: string | number; padTop?: string | number; padBottom?: string | number; debugRender?: boolean; transitionTime?: number; animations?: StringMap<Viewport>; }; alpha?: boolean; preserveDrawingBuffer: boolean; backgroundColor?: string; fullScreenBackgroundColor?: string; backgroundImage?: { url: string; x?: number; y?: number; width?: number; height?: number; }; mipmaps?: boolean; controlBones?: string[]; success?: (player: SpinePlayer) => void; error?: (player: SpinePlayer, msg: string) => void; frame?: (player: SpinePlayer, delta: number) => void; update?: (player: SpinePlayer, delta: number) => void; draw?: (player: SpinePlayer, delta: number) => void; loading?: (player: SpinePlayer, delta: number) => void; downloader?: Downloader; } export interface Viewport { x: number; y: number; width: number; height: number; padLeft: string | number; padRight: string | number; padTop: string | number; padBottom: string | number; } export declare class SpinePlayer implements Disposable { private config; parent: HTMLElement; dom: HTMLElement; canvas: HTMLCanvasElement | null; context: ManagedWebGLRenderingContext | null; sceneRenderer: SceneRenderer | null; loadingScreen: LoadingScreen | null; assetManager: AssetManager | null; bg: Color; bgFullscreen: Color; private playerControls; private timelineSlider; private playButton; private skinButton; private animationButton; private playTime; private selectedBones; private cancelId; popup: Popup | null; error: boolean; skeleton: Skeleton | null; animationState: AnimationState | null; paused: boolean; speed: number; time: TimeKeeper; private stopRequestAnimationFrame; private disposed; private viewport; private currentViewport; private previousViewport; private viewportTransitionStart; private eventListeners; constructor(parent: HTMLElement | string, config: SpinePlayerConfig); dispose(): void; addEventListener(target: any, event: any, func: any): void; private validateConfig; private initialize; private loadSkeleton; private setupInput; play(): void; pause(): void; setAnimation(animation: string | Animation, loop?: boolean): TrackEntry; addAnimation(animation: string | Animation, loop?: boolean, delay?: number): TrackEntry; setViewport(animation: string | Animation): Animation; private percentageToWorldUnit; private calculateAnimationViewport; private drawFrame; stopRendering(): void; private hidePopup; private showSpeedDialog; private showAnimationsDialog; private showSkinsDialog; private showSettingsDialog; private showError; } declare class Popup { private id; private button; private player; dom: HTMLElement; private className; private windowClickListener; constructor(id: string, button: HTMLElement, player: SpinePlayer, parent: HTMLElement, htmlContent: string); dispose(): void; hide(id: string): boolean; show(): void; } export {};