[ts] Refactored AssetManager and TextureAtlas to be in core/ package for sharing between backends

This commit is contained in:
badlogic 2016-08-16 10:27:50 +02:00
parent 3b90df58a5
commit e72c9030eb
20 changed files with 670 additions and 3453 deletions

View File

@ -1815,688 +1815,3 @@ declare module spine {
originalHeight: number;
}
}
/******************************************************************************
* Spine Runtimes Software License
* Version 2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
declare module spine.webgl {
class AssetManager implements Disposable {
private _gl;
private _assets;
private _errors;
private _toLoad;
private _loaded;
constructor(gl: WebGLRenderingContext);
loadText(path: string, success?: (path: string, text: string) => void, error?: (path: string, error: string) => void): void;
loadTexture(path: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void;
get(path: string): string | Texture;
remove(path: string): void;
removeAll(): void;
isLoadingComplete(): boolean;
toLoad(): number;
loaded(): number;
dispose(): void;
hasErrors(): boolean;
errors(): Map<string>;
}
}
/******************************************************************************
* Spine Runtimes Software License
* Version 2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
declare module spine.webgl {
const M00: number;
const M01: number;
const M02: number;
const M03: number;
const M10: number;
const M11: number;
const M12: number;
const M13: number;
const M20: number;
const M21: number;
const M22: number;
const M23: number;
const M30: number;
const M31: number;
const M32: number;
const M33: number;
class Matrix4 {
temp: Float32Array;
values: Float32Array;
constructor();
set(values: ArrayLike<number>): Matrix4;
transpose(): Matrix4;
identity(): Matrix4;
invert(): Matrix4;
determinant(): number;
translate(x: number, y: number, z: number): Matrix4;
copy(): Matrix4;
projection(near: number, far: number, fovy: number, aspectRatio: number): Matrix4;
ortho2d(x: number, y: number, width: number, height: number): Matrix4;
ortho(left: number, right: number, bottom: number, top: number, near: number, far: number): Matrix4;
multiply(matrix: Matrix4): Matrix4;
multiplyLeft(matrix: Matrix4): Matrix4;
}
}
/******************************************************************************
* Spine Runtimes Software License
* Version 2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
declare module spine.webgl {
class Mesh implements Disposable {
private _attributes;
private _gl;
private _vertices;
private _verticesBuffer;
private _verticesLength;
private _dirtyVertices;
private _indices;
private _indicesBuffer;
private _indicesLength;
private _dirtyIndices;
private _elementsPerVertex;
attributes(): VertexAttribute[];
maxVertices(): number;
numVertices(): number;
setVerticesLength(length: number): void;
vertices(): Float32Array;
maxIndices(): number;
numIndices(): number;
setIndicesLength(length: number): void;
indices(): Uint16Array;
constructor(gl: WebGLRenderingContext, _attributes: VertexAttribute[], maxVertices: number, maxIndices: number);
setVertices(vertices: Array<number>): void;
setIndices(indices: Array<number>): void;
draw(shader: Shader, primitiveType: number): void;
drawWithOffset(shader: Shader, primitiveType: number, offset: number, count: number): void;
bind(shader: Shader): void;
unbind(shader: Shader): void;
private update();
dispose(): void;
}
class VertexAttribute {
name: string;
type: VertexAttributeType;
numElements: number;
constructor(name: string, type: VertexAttributeType, numElements: number);
}
class Position2Attribute extends VertexAttribute {
constructor();
}
class Position3Attribute extends VertexAttribute {
constructor();
}
class TexCoordAttribute extends VertexAttribute {
constructor(unit?: number);
}
class ColorAttribute extends VertexAttribute {
constructor();
}
enum VertexAttributeType {
Float = 0,
}
}
/******************************************************************************
* Spine Runtimes Software License
* Version 2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
declare module spine.webgl {
class PolygonBatcher {
private _gl;
private _drawCalls;
private _drawing;
private _mesh;
private _shader;
private _lastTexture;
private _verticesLength;
private _indicesLength;
private _srcBlend;
private _dstBlend;
constructor(gl: WebGLRenderingContext, maxVertices?: number);
begin(shader: Shader): void;
setBlendMode(srcBlend: number, dstBlend: number): void;
draw(texture: Texture, vertices: ArrayLike<number>, indices: Array<number>): void;
private flush();
end(): void;
drawCalls(): number;
}
}
/******************************************************************************
* Spine Runtimes Software License
* Version 2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
declare module spine.webgl {
class Shader implements Disposable {
private _vertexShader;
private _fragmentShader;
static MVP_MATRIX: string;
static POSITION: string;
static COLOR: string;
static TEXCOORDS: string;
static SAMPLER: string;
private _gl;
private _vs;
private _fs;
private _program;
private _tmp2x2;
private _tmp3x3;
private _tmp4x4;
program(): WebGLProgram;
vertexShader(): string;
fragmentShader(): string;
constructor(gl: WebGLRenderingContext, _vertexShader: string, _fragmentShader: string);
private compile();
private compileShader(type, source);
private compileProgram(vs, fs);
bind(): void;
unbind(): void;
setUniformi(uniform: string, value: number): void;
setUniformf(uniform: string, value: number): void;
setUniform2f(uniform: string, value: number, value2: number): void;
setUniform3f(uniform: string, value: number, value2: number, value3: number): void;
setUniform4f(uniform: string, value: number, value2: number, value3: number, value4: number): void;
setUniform2x2f(uniform: string, value: ArrayLike<number>): void;
setUniform3x3f(uniform: string, value: ArrayLike<number>): void;
setUniform4x4f(uniform: string, value: ArrayLike<number>): void;
getUniformLocation(uniform: string): WebGLUniformLocation;
getAttributeLocation(attribute: string): number;
dispose(): void;
static newColoredTextured(gl: WebGLRenderingContext): Shader;
static newColored(gl: WebGLRenderingContext): Shader;
}
}
/******************************************************************************
* Spine Runtimes Software License
* Version 2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
declare module spine.webgl {
class SkeletonRenderer {
static QUAD_TRIANGLES: number[];
premultipliedAlpha: boolean;
private _gl;
constructor(gl: WebGLRenderingContext);
draw(batcher: PolygonBatcher, skeleton: Skeleton): void;
}
}
/******************************************************************************
* Spine Runtimes Software License
* Version 2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
declare module spine.webgl {
class Texture implements Disposable {
private _gl;
private _texture;
private _image;
private _boundUnit;
constructor(gl: WebGLRenderingContext, image: HTMLImageElement, useMipMaps?: boolean);
getImage(): HTMLImageElement;
setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
update(useMipMaps: boolean): void;
bind(unit?: number): void;
unbind(): void;
dispose(): void;
static filterFromString(text: string): TextureFilter;
static wrapFromString(text: string): TextureWrap;
}
enum TextureFilter {
Nearest,
Linear,
MipMap,
MipMapNearestNearest,
MipMapLinearNearest,
MipMapNearestLinear,
MipMapLinearLinear,
}
enum TextureWrap {
MirroredRepeat,
ClampToEdge,
Repeat,
}
}
/******************************************************************************
* Spine Runtimes Software License
* Version 2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
declare module spine.webgl {
class TextureAtlas implements Disposable {
pages: TextureAtlasPage[];
regions: TextureAtlasRegion[];
constructor(atlasText: string, textureLoader: (path: string) => Texture);
private load(atlasText, textureLoader);
findRegion(name: string): TextureAtlasRegion;
dispose(): void;
}
class TextureAtlasPage {
name: string;
minFilter: TextureFilter;
magFilter: TextureFilter;
uWrap: TextureWrap;
vWrap: TextureWrap;
texture: Texture;
width: number;
height: number;
}
class TextureAtlasRegion extends TextureRegion {
page: TextureAtlasPage;
name: string;
x: number;
y: number;
index: number;
rotate: boolean;
texture: Texture;
}
}
/******************************************************************************
* Spine Runtimes Software License
* Version 2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
declare module spine.webgl {
class TextureAtlasAttachmentLoader implements AttachmentLoader {
atlas: TextureAtlas;
constructor(atlas: TextureAtlas);
/** @return May be null to not load an attachment. */
newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment;
/** @return May be null to not load an attachment. */
newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment;
/** @return May be null to not load an attachment. */
newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment;
/** @return May be null to not load an attachment */
newPathAttachment(skin: Skin, name: string): PathAttachment;
}
}
/******************************************************************************
* Spine Runtimes Software License
* Version 2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
declare module spine.webgl {
class Vector3 {
x: number;
y: number;
z: number;
set(x: number, y: number, z: number): Vector3;
add(v: Vector3): Vector3;
sub(v: Vector3): Vector3;
scale(s: number): Vector3;
normalize(): Vector3;
cross(v: Vector3): Vector3;
multiply(matrix: Matrix4): Vector3;
project(matrix: Matrix4): Vector3;
dot(v: Vector3): number;
length(): number;
distance(v: Vector3): number;
}
}
/******************************************************************************
* Spine Runtimes Software License
* Version 2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
declare module spine.webgl {
function getSourceGLBlendMode(gl: WebGLRenderingContext, blendMode: BlendMode, premultipliedAlpha?: boolean): number;
function getDestGLBlendMode(gl: WebGLRenderingContext, blendMode: BlendMode): number;
}
/******************************************************************************
* Spine Runtimes Software License
* Version 2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
declare module spine {
class SpineWidget {
skeleton: Skeleton;
state: AnimationState;
gl: WebGLRenderingContext;
canvas: HTMLCanvasElement;
private _config;
private _assetManager;
private _shader;
private _batcher;
private _mvp;
private _skeletonRenderer;
private _paused;
private _lastFrameTime;
private _backgroundColor;
private _loaded;
constructor(element: Element | string, config: SpineWidgetConfig);
private validateConfig(config);
private load();
private render();
pause(): void;
play(): void;
isPlaying(): boolean;
setAnimation(animationName: string): void;
static loadWidgets(): void;
static loadWidget(widget: Element): void;
static pageLoaded: boolean;
private static ready();
static setupDOMListener(): void;
}
class SpineWidgetConfig {
json: string;
atlas: string;
animation: string;
imagesPath: string;
skin: string;
loop: boolean;
scale: number;
x: number;
y: number;
width: number;
height: number;
backgroundColor: string;
premultipliedAlpha: boolean;
success: (widget: SpineWidget) => void;
error: (widget: SpineWidget, msg: string) => void;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -354,6 +354,57 @@ declare module spine {
getMix(from: Animation, to: Animation): number;
}
}
/******************************************************************************
* Spine Runtimes Software License
* Version 2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
declare module spine.webgl {
class AssetManager implements Disposable {
private _textureLoader;
private _assets;
private _errors;
private _toLoad;
private _loaded;
constructor(textureLoader: (image: HTMLImageElement) => any);
loadText(path: string, success?: (path: string, text: string) => void, error?: (path: string, error: string) => void): void;
loadTexture(path: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void;
get(path: string): any;
remove(path: string): void;
removeAll(): void;
isLoadingComplete(): boolean;
toLoad(): number;
loaded(): number;
dispose(): void;
hasErrors(): boolean;
errors(): Map<string>;
}
}
/******************************************************************************
* Spine Runtimes Software License
* Version 2.5
@ -1206,6 +1257,91 @@ declare module spine {
constructor(index: number, name: string, boneData: BoneData);
}
}
declare module spine {
abstract class Texture {
protected _image: HTMLImageElement;
constructor(image: HTMLImageElement);
getImage(): HTMLImageElement;
abstract setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
abstract setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
abstract dispose(): void;
static filterFromString(text: string): TextureFilter;
static wrapFromString(text: string): TextureWrap;
}
enum TextureFilter {
Nearest = 9728,
Linear = 9729,
MipMap = 9987,
MipMapNearestNearest = 9984,
MipMapLinearNearest = 9985,
MipMapNearestLinear = 9986,
MipMapLinearLinear = 9987,
}
enum TextureWrap {
MirroredRepeat = 33648,
ClampToEdge = 33071,
Repeat = 10497,
}
}
/******************************************************************************
* Spine Runtimes Software License
* Version 2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
declare module spine.webgl {
class TextureAtlas implements Disposable {
pages: TextureAtlasPage[];
regions: TextureAtlasRegion[];
constructor(atlasText: string, textureLoader: (path: string, minFilter: TextureFilter, magFilter: TextureFilter, uWrap: TextureWrap, vWrap: TextureWrap) => any);
private load(atlasText, textureLoader);
findRegion(name: string): TextureAtlasRegion;
dispose(): void;
}
class TextureAtlasPage {
name: string;
minFilter: TextureFilter;
magFilter: TextureFilter;
uWrap: TextureWrap;
vWrap: TextureWrap;
texture: Texture;
width: number;
height: number;
}
class TextureAtlasRegion extends TextureRegion {
page: TextureAtlasPage;
name: string;
x: number;
y: number;
index: number;
rotate: boolean;
texture: Texture;
}
}
/******************************************************************************
* Spine Runtimes Software License
* Version 2.5
@ -1846,24 +1982,17 @@ declare module spine {
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
declare module spine.webgl {
class AssetManager implements Disposable {
class GLTexture extends Texture implements Disposable {
private _gl;
private _assets;
private _errors;
private _toLoad;
private _loaded;
constructor(gl: WebGLRenderingContext);
loadText(path: string, success?: (path: string, text: string) => void, error?: (path: string, error: string) => void): void;
loadTexture(path: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void;
get(path: string): string | Texture;
remove(path: string): void;
removeAll(): void;
isLoadingComplete(): boolean;
toLoad(): number;
loaded(): number;
private _texture;
private _boundUnit;
constructor(gl: WebGLRenderingContext, image: HTMLImageElement, useMipMaps?: boolean);
setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
update(useMipMaps: boolean): void;
bind(unit?: number): void;
unbind(): void;
dispose(): void;
hasErrors(): boolean;
errors(): Map<string>;
}
}
/******************************************************************************
@ -2060,7 +2189,7 @@ declare module spine.webgl {
constructor(gl: WebGLRenderingContext, maxVertices?: number);
begin(shader: Shader): void;
setBlendMode(srcBlend: number, dstBlend: number): void;
draw(texture: Texture, vertices: ArrayLike<number>, indices: Array<number>): void;
draw(texture: GLTexture, vertices: ArrayLike<number>, indices: Array<number>): void;
private flush();
end(): void;
drawCalls(): number;
@ -2175,127 +2304,6 @@ declare module spine.webgl {
draw(batcher: PolygonBatcher, skeleton: Skeleton): void;
}
}
/******************************************************************************
* Spine Runtimes Software License
* Version 2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
declare module spine.webgl {
class Texture implements Disposable {
private _gl;
private _texture;
private _image;
private _boundUnit;
constructor(gl: WebGLRenderingContext, image: HTMLImageElement, useMipMaps?: boolean);
getImage(): HTMLImageElement;
setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
update(useMipMaps: boolean): void;
bind(unit?: number): void;
unbind(): void;
dispose(): void;
static filterFromString(text: string): TextureFilter;
static wrapFromString(text: string): TextureWrap;
}
enum TextureFilter {
Nearest,
Linear,
MipMap,
MipMapNearestNearest,
MipMapLinearNearest,
MipMapNearestLinear,
MipMapLinearLinear,
}
enum TextureWrap {
MirroredRepeat,
ClampToEdge,
Repeat,
}
}
/******************************************************************************
* Spine Runtimes Software License
* Version 2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
declare module spine.webgl {
class TextureAtlas implements Disposable {
pages: TextureAtlasPage[];
regions: TextureAtlasRegion[];
constructor(atlasText: string, textureLoader: (path: string) => Texture);
private load(atlasText, textureLoader);
findRegion(name: string): TextureAtlasRegion;
dispose(): void;
}
class TextureAtlasPage {
name: string;
minFilter: TextureFilter;
magFilter: TextureFilter;
uWrap: TextureWrap;
vWrap: TextureWrap;
texture: Texture;
width: number;
height: number;
}
class TextureAtlasRegion extends TextureRegion {
page: TextureAtlasPage;
name: string;
x: number;
y: number;
index: number;
rotate: boolean;
texture: Texture;
}
}
/******************************************************************************
* Spine Runtimes Software License
* Version 2.5
@ -2422,81 +2430,3 @@ declare module spine.webgl {
function getSourceGLBlendMode(gl: WebGLRenderingContext, blendMode: BlendMode, premultipliedAlpha?: boolean): number;
function getDestGLBlendMode(gl: WebGLRenderingContext, blendMode: BlendMode): number;
}
/******************************************************************************
* Spine Runtimes Software License
* Version 2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
* the Spine Software License Agreement), you may not (a) modify, translate,
* adapt, or develop new applications using the Spine Runtimes or otherwise
* create derivative works or improvements of the Spine Runtimes or (b) remove,
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
* or other intellectual property or proprietary rights notices on or in the
* Software, including any copy thereof. Redistributions in binary or source
* form must include this license and terms.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
declare module spine {
class SpineWidget {
skeleton: Skeleton;
state: AnimationState;
gl: WebGLRenderingContext;
canvas: HTMLCanvasElement;
private _config;
private _assetManager;
private _shader;
private _batcher;
private _mvp;
private _skeletonRenderer;
private _paused;
private _lastFrameTime;
private _backgroundColor;
private _loaded;
constructor(element: Element | string, config: SpineWidgetConfig);
private validateConfig(config);
private load();
private render();
pause(): void;
play(): void;
isPlaying(): boolean;
setAnimation(animationName: string): void;
static loadWidgets(): void;
static loadWidget(widget: Element): void;
static pageLoaded: boolean;
private static ready();
static setupDOMListener(): void;
}
class SpineWidgetConfig {
json: string;
atlas: string;
animation: string;
imagesPath: string;
skin: string;
loop: boolean;
scale: number;
x: number;
y: number;
width: number;
height: number;
backgroundColor: string;
premultipliedAlpha: boolean;
success: (widget: SpineWidget) => void;
error: (widget: SpineWidget, msg: string) => void;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,12 @@
<html>
<script src="../../build/spine-canvas.js"></script>
<script src="https://code.jquery.com/jquery-3.1.0.min.js"></script>
<body>
<center>
<canvas id="canvas" style="width: 640; height: 480"></canvas>
</center>
</body>
<script>
</script>
</html>

View File

@ -0,0 +1,5 @@
module spine.canvas {
export class SkeletonRenderer {
}
}

View File

@ -31,14 +31,14 @@
module spine.webgl {
export class AssetManager implements Disposable {
private _gl: WebGLRenderingContext;
private _assets: Map<string | Texture> = {};
private _textureLoader: (image: HTMLImageElement) => any;
private _assets: Map<any> = {};
private _errors: Map<string> = {};
private _toLoad = 0;
private _loaded = 0;
constructor (gl: WebGLRenderingContext) {
this._gl = gl;
constructor (textureLoader: (image: HTMLImageElement) => any) {
this._textureLoader = textureLoader;
}
loadText(path: string,
@ -73,7 +73,7 @@ module spine.webgl {
img.src = path;
img.onload = (ev) => {
if (success) success(path, img);
let texture = new Texture(this._gl, img);
let texture = this._textureLoader(img);
this._assets[path] = texture;
this._toLoad--;
this._loaded++;
@ -92,16 +92,14 @@ module spine.webgl {
remove (path: string) {
let asset = this._assets[path];
if (asset instanceof Texture) {
asset.dispose();
}
if ((<any>asset).dispose) (<any>asset).dispose();
this._assets[path] = null;
}
removeAll () {
for (let key in this._assets) {
let asset = this._assets[key];
if (asset instanceof Texture) asset.dispose();
if ((<any>asset).dispose) (<any>asset).dispose();
}
this._assets = {};
}

View File

@ -0,0 +1,56 @@
module spine {
export abstract class Texture {
protected _image: HTMLImageElement;
constructor (image: HTMLImageElement) {
this._image = image;
}
getImage (): HTMLImageElement {
return this._image;
}
abstract setFilters (minFilter: TextureFilter, magFilter: TextureFilter): void;
abstract setWraps (uWrap: TextureWrap, vWrap: TextureWrap): void;
abstract dispose (): void;
public static filterFromString (text: string): TextureFilter {
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}`);
}
}
public static wrapFromString (text: string): TextureWrap {
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}`);
}
}
}
export enum TextureFilter {
Nearest = 9728, // WebGLRenderingContext.NEAREST
Linear = 9729, // WebGLRenderingContext.LINEAR
MipMap = 9987, // WebGLRenderingContext.LINEAR_MIPMAP_LINEAR
MipMapNearestNearest = 9984, // WebGLRenderingContext.NEAREST_MIPMAP_NEAREST
MipMapLinearNearest = 9985, // WebGLRenderingContext.LINEAR_MIPMAP_NEAREST
MipMapNearestLinear = 9986, // WebGLRenderingContext.NEAREST_MIPMAP_LINEAR
MipMapLinearLinear = 9987 // WebGLRenderingContext.LINEAR_MIPMAP_LINEAR
}
export enum TextureWrap {
MirroredRepeat = 33648, // WebGLRenderingContext.MIRRORED_REPEAT
ClampToEdge = 33071, // WebGLRenderingContext.CLAMP_TO_EDGE
Repeat = 10497 // WebGLRenderingContext.REPEAT
}
}

View File

@ -34,11 +34,11 @@ module spine.webgl {
pages = new Array<TextureAtlasPage>();
regions = new Array<TextureAtlasRegion>();
constructor (atlasText: string, textureLoader: (path: string) => Texture) {
constructor (atlasText: string, textureLoader: (path: string, minFilter: TextureFilter, magFilter: TextureFilter, uWrap: TextureWrap, vWrap: TextureWrap) => any) {
this.load(atlasText, textureLoader);
}
private load (atlasText: string, textureLoader: (path: string) => Texture) {
private load (atlasText: string, textureLoader: (path: string, minFilter: TextureFilter, magFilter: TextureFilter, uWrap: TextureWrap, vWrap: TextureWrap) => any) {
if (textureLoader == null)
throw new Error("textureLoader cannot be null.");
@ -77,9 +77,7 @@ module spine.webgl {
else if (direction == "xy")
page.uWrap = page.vWrap = TextureWrap.Repeat;
page.texture = textureLoader(line);
page.texture.setFilters(page.minFilter, page.magFilter);
page.texture.setWraps(page.uWrap, page.vWrap);
page.texture = textureLoader(line, page.minFilter, page.magFilter, page.uWrap, page.vWrap);
page.width = page.texture.getImage().width;
page.height = page.texture.getImage().height;
this.pages.push(page);

View File

@ -13,11 +13,8 @@
"canvas/src/**/*"
],
"exclude": [
"webgl/src/*.ts",
"widget/src/*.ts",
"build",
"build/*.d.ts",
"build/*.js",
"build/*.js.map"
"webgl",
"widget",
"build"
]
}

View File

@ -12,9 +12,8 @@
"core/src/**/*"
],
"exclude": [
"webgl/src/*.ts",
"widget/src/*.ts",
"build",
"build/*.d.ts"
"webgl",
"widget",
"build"
]
}

View File

@ -10,13 +10,11 @@
},
"include": [
"core/src/**/*",
"canvas/src/**/*",
"webgl/src/**/*",
"widget/src/**/*"
],
"exclude": [
"build",
"build/*.js",
"build/*.d.ts",
"build/*.js.map"
"exclude": [
"build"
]
}

View File

@ -13,9 +13,8 @@
"webgl/src/**/*"
],
"exclude": [
"build",
"build/*.d.ts",
"build/*.js",
"build/*.js.map"
"canvas",
"widget",
"build"
]
}

View File

@ -14,9 +14,7 @@
"widget/src/**/*"
],
"exclude": [
"build",
"build/*.d.ts",
"build/*.js",
"build/*.js.map"
"canvas",
"build"
]
}

View File

@ -78,8 +78,10 @@ function loadSkeleton (name, scale, initialAnimation, positionX, positionY, prem
// Load the texture atlas using name.atlas and name.png from the AssetManager.
// The function passed to TextureAtlas is used to resolve relative paths.
atlas = new spine.webgl.TextureAtlas(assetManager.get("assets/" + name + ".atlas"), function(path) {
return assetManager.get("assets/" + path);
atlas = new spine.webgl.TextureAtlas(assetManager.get("assets/" + name + ".atlas"), function(path, minFilter, magFilter, uWrap, vWrap) {
var texture = assetManager.get("assets/" + path);
texture.setFilters(minFilter, magFilter);
texture.setWraps(uWrap, vWrap);
});
// Create a TextureAtlasAttachmentLoader, which is specific to the WebGL backend.

View File

@ -30,23 +30,18 @@
*****************************************************************************/
module spine.webgl {
export class Texture implements Disposable {
export class GLTexture extends Texture implements Disposable {
private _gl: WebGLRenderingContext;
private _texture: WebGLTexture;
private _image: HTMLImageElement;
private _texture: WebGLTexture;
private _boundUnit = 0;
constructor (gl: WebGLRenderingContext, image: HTMLImageElement, useMipMaps: boolean = false) {
super(image);
this._gl = gl;
this._texture = gl.createTexture();
this._image = image;
this._texture = gl.createTexture();
this.update(useMipMaps);
}
getImage (): HTMLImageElement {
return this._image;
}
setFilters (minFilter: TextureFilter, magFilter: TextureFilter) {
let gl = this._gl;
this.bind();
@ -89,43 +84,5 @@ module spine.webgl {
let gl = this._gl;
gl.deleteTexture(this._texture);
}
public static filterFromString (text: string): TextureFilter {
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}`);
}
}
public static wrapFromString (text: string): TextureWrap {
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}`);
}
}
}
export enum TextureFilter {
Nearest = WebGLRenderingContext.NEAREST,
Linear = WebGLRenderingContext.LINEAR,
MipMap = WebGLRenderingContext.LINEAR_MIPMAP_LINEAR,
MipMapNearestNearest = WebGLRenderingContext.NEAREST_MIPMAP_NEAREST,
MipMapLinearNearest = WebGLRenderingContext.LINEAR_MIPMAP_NEAREST,
MipMapNearestLinear = WebGLRenderingContext.NEAREST_MIPMAP_LINEAR,
MipMapLinearLinear = WebGLRenderingContext.LINEAR_MIPMAP_LINEAR
}
export enum TextureWrap {
MirroredRepeat = WebGLRenderingContext.MIRRORED_REPEAT,
ClampToEdge = WebGLRenderingContext.CLAMP_TO_EDGE,
Repeat = WebGLRenderingContext.REPEAT
}
}

View File

@ -36,7 +36,7 @@ module spine.webgl {
private _drawing = false;
private _mesh: Mesh;
private _shader: Shader = null;
private _lastTexture: Texture = null;
private _lastTexture: GLTexture = null;
private _verticesLength = 0;
private _indicesLength = 0;
private _srcBlend: number = WebGLRenderingContext.SRC_ALPHA;
@ -70,7 +70,7 @@ module spine.webgl {
}
}
draw (texture: Texture, vertices: ArrayLike<number>, indices: Array<number>) {
draw (texture: GLTexture, vertices: ArrayLike<number>, indices: Array<number>) {
if (texture != this._lastTexture) {
this.flush();
this._lastTexture = texture;

View File

@ -50,18 +50,18 @@ module spine.webgl {
for (let i = 0, n = drawOrder.length; i < n; i++) {
let slot = drawOrder[i];
let attachment = slot.getAttachment();
let texture: Texture = null;
let texture: GLTexture = null;
if (attachment instanceof RegionAttachment) {
let region = <RegionAttachment>attachment;
vertices = region.updateWorldVertices(slot, premultipliedAlpha);
triangles = SkeletonRenderer.QUAD_TRIANGLES;
texture = (<TextureAtlasRegion>region.region.renderObject).texture;
texture = <GLTexture>(<TextureAtlasRegion>region.region.renderObject).texture;
} else if (attachment instanceof MeshAttachment) {
let mesh = <MeshAttachment>attachment;
vertices = mesh.updateWorldVertices(slot, premultipliedAlpha);
triangles = mesh.triangles;
texture = (<TextureAtlasRegion>mesh.region.renderObject).texture;
texture = <GLTexture>(<TextureAtlasRegion>mesh.region.renderObject).texture;
}
if (texture != null) {