mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[ts] Added Canvas backend, also does meshes
This commit is contained in:
parent
847bd2a76c
commit
23f2a50821
1352
spine-ts/build/spine-webgl.d.ts
vendored
1352
spine-ts/build/spine-webgl.d.ts
vendored
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
344
spine-ts/build/spine-widget.d.ts
vendored
344
spine-ts/build/spine-widget.d.ts
vendored
@ -354,6 +354,57 @@ declare module spine {
|
|||||||
getMix(from: Animation, to: Animation): number;
|
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 {
|
||||||
|
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
|
* Spine Runtimes Software License
|
||||||
* Version 2.5
|
* Version 2.5
|
||||||
@ -1206,6 +1257,105 @@ declare module spine {
|
|||||||
constructor(index: number, name: string, boneData: BoneData);
|
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,
|
||||||
|
}
|
||||||
|
class TextureRegion {
|
||||||
|
renderObject: any;
|
||||||
|
u: number;
|
||||||
|
v: number;
|
||||||
|
u2: number;
|
||||||
|
v2: number;
|
||||||
|
width: number;
|
||||||
|
height: number;
|
||||||
|
rotate: boolean;
|
||||||
|
offsetX: number;
|
||||||
|
offsetY: number;
|
||||||
|
originalWidth: number;
|
||||||
|
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 {
|
||||||
|
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
|
* Spine Runtimes Software License
|
||||||
* Version 2.5
|
* Version 2.5
|
||||||
@ -1769,52 +1919,6 @@ declare module spine {
|
|||||||
updateWorldVertices(slot: Slot, premultipliedAlpha: boolean): ArrayLike<number>;
|
updateWorldVertices(slot: Slot, premultipliedAlpha: boolean): ArrayLike<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 TextureRegion {
|
|
||||||
renderObject: any;
|
|
||||||
u: number;
|
|
||||||
v: number;
|
|
||||||
u2: number;
|
|
||||||
v2: number;
|
|
||||||
width: number;
|
|
||||||
height: number;
|
|
||||||
rotate: boolean;
|
|
||||||
offsetX: number;
|
|
||||||
offsetY: number;
|
|
||||||
originalWidth: number;
|
|
||||||
originalHeight: number;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Spine Runtimes Software License
|
* Spine Runtimes Software License
|
||||||
* Version 2.5
|
* Version 2.5
|
||||||
@ -1846,24 +1950,17 @@ declare module spine {
|
|||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
declare module spine.webgl {
|
declare module spine.webgl {
|
||||||
class AssetManager implements Disposable {
|
class GLTexture extends Texture implements Disposable {
|
||||||
private _gl;
|
private _gl;
|
||||||
private _assets;
|
private _texture;
|
||||||
private _errors;
|
private _boundUnit;
|
||||||
private _toLoad;
|
constructor(gl: WebGLRenderingContext, image: HTMLImageElement, useMipMaps?: boolean);
|
||||||
private _loaded;
|
setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
|
||||||
constructor(gl: WebGLRenderingContext);
|
setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
|
||||||
loadText(path: string, success?: (path: string, text: string) => void, error?: (path: string, error: string) => void): void;
|
update(useMipMaps: boolean): void;
|
||||||
loadTexture(path: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void;
|
bind(unit?: number): void;
|
||||||
get(path: string): string | Texture;
|
unbind(): void;
|
||||||
remove(path: string): void;
|
|
||||||
removeAll(): void;
|
|
||||||
isLoadingComplete(): boolean;
|
|
||||||
toLoad(): number;
|
|
||||||
loaded(): number;
|
|
||||||
dispose(): void;
|
dispose(): void;
|
||||||
hasErrors(): boolean;
|
|
||||||
errors(): Map<string>;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@ -2060,7 +2157,7 @@ declare module spine.webgl {
|
|||||||
constructor(gl: WebGLRenderingContext, maxVertices?: number);
|
constructor(gl: WebGLRenderingContext, maxVertices?: number);
|
||||||
begin(shader: Shader): void;
|
begin(shader: Shader): void;
|
||||||
setBlendMode(srcBlend: number, dstBlend: number): 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();
|
private flush();
|
||||||
end(): void;
|
end(): void;
|
||||||
drawCalls(): number;
|
drawCalls(): number;
|
||||||
@ -2175,127 +2272,6 @@ declare module spine.webgl {
|
|||||||
draw(batcher: PolygonBatcher, skeleton: Skeleton): void;
|
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
|
* Spine Runtimes Software License
|
||||||
* Version 2.5
|
* Version 2.5
|
||||||
|
|||||||
@ -1146,6 +1146,133 @@ var spine;
|
|||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
var spine;
|
var spine;
|
||||||
|
(function (spine) {
|
||||||
|
var AssetManager = (function () {
|
||||||
|
function AssetManager(textureLoader) {
|
||||||
|
this._assets = {};
|
||||||
|
this._errors = {};
|
||||||
|
this._toLoad = 0;
|
||||||
|
this._loaded = 0;
|
||||||
|
this._textureLoader = textureLoader;
|
||||||
|
}
|
||||||
|
AssetManager.prototype.loadText = function (path, success, error) {
|
||||||
|
var _this = this;
|
||||||
|
if (success === void 0) { success = null; }
|
||||||
|
if (error === void 0) { error = null; }
|
||||||
|
this._toLoad++;
|
||||||
|
var request = new XMLHttpRequest();
|
||||||
|
request.onreadystatechange = function () {
|
||||||
|
if (request.readyState == XMLHttpRequest.DONE) {
|
||||||
|
if (request.status >= 200 && request.status < 300) {
|
||||||
|
if (success)
|
||||||
|
success(path, request.responseText);
|
||||||
|
_this._assets[path] = request.responseText;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (error)
|
||||||
|
error(path, "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText);
|
||||||
|
_this._errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText;
|
||||||
|
}
|
||||||
|
_this._toLoad--;
|
||||||
|
_this._loaded++;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
request.open("GET", path, true);
|
||||||
|
request.send();
|
||||||
|
};
|
||||||
|
AssetManager.prototype.loadTexture = function (path, success, error) {
|
||||||
|
var _this = this;
|
||||||
|
if (success === void 0) { success = null; }
|
||||||
|
if (error === void 0) { error = null; }
|
||||||
|
this._toLoad++;
|
||||||
|
var img = new Image();
|
||||||
|
img.src = path;
|
||||||
|
img.onload = function (ev) {
|
||||||
|
if (success)
|
||||||
|
success(path, img);
|
||||||
|
var texture = _this._textureLoader(img);
|
||||||
|
_this._assets[path] = texture;
|
||||||
|
_this._toLoad--;
|
||||||
|
_this._loaded++;
|
||||||
|
};
|
||||||
|
img.onerror = function (ev) {
|
||||||
|
if (error)
|
||||||
|
error(path, "Couldn't load image " + path);
|
||||||
|
_this._errors[path] = "Couldn't load image " + path;
|
||||||
|
_this._toLoad--;
|
||||||
|
_this._loaded++;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
AssetManager.prototype.get = function (path) {
|
||||||
|
return this._assets[path];
|
||||||
|
};
|
||||||
|
AssetManager.prototype.remove = function (path) {
|
||||||
|
var asset = this._assets[path];
|
||||||
|
if (asset.dispose)
|
||||||
|
asset.dispose();
|
||||||
|
this._assets[path] = null;
|
||||||
|
};
|
||||||
|
AssetManager.prototype.removeAll = function () {
|
||||||
|
for (var key in this._assets) {
|
||||||
|
var asset = this._assets[key];
|
||||||
|
if (asset.dispose)
|
||||||
|
asset.dispose();
|
||||||
|
}
|
||||||
|
this._assets = {};
|
||||||
|
};
|
||||||
|
AssetManager.prototype.isLoadingComplete = function () {
|
||||||
|
return this._toLoad == 0;
|
||||||
|
};
|
||||||
|
AssetManager.prototype.toLoad = function () {
|
||||||
|
return this._toLoad;
|
||||||
|
};
|
||||||
|
AssetManager.prototype.loaded = function () {
|
||||||
|
return this._loaded;
|
||||||
|
};
|
||||||
|
AssetManager.prototype.dispose = function () {
|
||||||
|
this.removeAll();
|
||||||
|
};
|
||||||
|
AssetManager.prototype.hasErrors = function () {
|
||||||
|
return Object.keys(this._errors).length > 0;
|
||||||
|
};
|
||||||
|
AssetManager.prototype.errors = function () {
|
||||||
|
return this._errors;
|
||||||
|
};
|
||||||
|
return AssetManager;
|
||||||
|
}());
|
||||||
|
spine.AssetManager = AssetManager;
|
||||||
|
})(spine || (spine = {}));
|
||||||
|
/******************************************************************************
|
||||||
|
* 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.
|
||||||
|
*****************************************************************************/
|
||||||
|
var spine;
|
||||||
(function (spine) {
|
(function (spine) {
|
||||||
(function (BlendMode) {
|
(function (BlendMode) {
|
||||||
BlendMode[BlendMode["Normal"] = 0] = "Normal";
|
BlendMode[BlendMode["Normal"] = 0] = "Normal";
|
||||||
@ -3997,6 +4124,258 @@ var spine;
|
|||||||
}());
|
}());
|
||||||
spine.SlotData = SlotData;
|
spine.SlotData = SlotData;
|
||||||
})(spine || (spine = {}));
|
})(spine || (spine = {}));
|
||||||
|
var spine;
|
||||||
|
(function (spine) {
|
||||||
|
var Texture = (function () {
|
||||||
|
function Texture(image) {
|
||||||
|
this._image = image;
|
||||||
|
}
|
||||||
|
Texture.prototype.getImage = function () {
|
||||||
|
return this._image;
|
||||||
|
};
|
||||||
|
Texture.filterFromString = function (text) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Texture.wrapFromString = function (text) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return Texture;
|
||||||
|
}());
|
||||||
|
spine.Texture = Texture;
|
||||||
|
(function (TextureFilter) {
|
||||||
|
TextureFilter[TextureFilter["Nearest"] = 9728] = "Nearest";
|
||||||
|
TextureFilter[TextureFilter["Linear"] = 9729] = "Linear";
|
||||||
|
TextureFilter[TextureFilter["MipMap"] = 9987] = "MipMap";
|
||||||
|
TextureFilter[TextureFilter["MipMapNearestNearest"] = 9984] = "MipMapNearestNearest";
|
||||||
|
TextureFilter[TextureFilter["MipMapLinearNearest"] = 9985] = "MipMapLinearNearest";
|
||||||
|
TextureFilter[TextureFilter["MipMapNearestLinear"] = 9986] = "MipMapNearestLinear";
|
||||||
|
TextureFilter[TextureFilter["MipMapLinearLinear"] = 9987] = "MipMapLinearLinear"; // WebGLRenderingContext.LINEAR_MIPMAP_LINEAR
|
||||||
|
})(spine.TextureFilter || (spine.TextureFilter = {}));
|
||||||
|
var TextureFilter = spine.TextureFilter;
|
||||||
|
(function (TextureWrap) {
|
||||||
|
TextureWrap[TextureWrap["MirroredRepeat"] = 33648] = "MirroredRepeat";
|
||||||
|
TextureWrap[TextureWrap["ClampToEdge"] = 33071] = "ClampToEdge";
|
||||||
|
TextureWrap[TextureWrap["Repeat"] = 10497] = "Repeat"; // WebGLRenderingContext.REPEAT
|
||||||
|
})(spine.TextureWrap || (spine.TextureWrap = {}));
|
||||||
|
var TextureWrap = spine.TextureWrap;
|
||||||
|
var TextureRegion = (function () {
|
||||||
|
function TextureRegion() {
|
||||||
|
this.u = 0;
|
||||||
|
this.v = 0;
|
||||||
|
this.u2 = 0;
|
||||||
|
this.v2 = 0;
|
||||||
|
this.width = 0;
|
||||||
|
this.height = 0;
|
||||||
|
this.rotate = false;
|
||||||
|
this.offsetX = 0;
|
||||||
|
this.offsetY = 0;
|
||||||
|
this.originalWidth = 0;
|
||||||
|
this.originalHeight = 0;
|
||||||
|
}
|
||||||
|
return TextureRegion;
|
||||||
|
}());
|
||||||
|
spine.TextureRegion = TextureRegion;
|
||||||
|
})(spine || (spine = {}));
|
||||||
|
/******************************************************************************
|
||||||
|
* 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.
|
||||||
|
*****************************************************************************/
|
||||||
|
var spine;
|
||||||
|
(function (spine) {
|
||||||
|
var TextureAtlas = (function () {
|
||||||
|
function TextureAtlas(atlasText, textureLoader) {
|
||||||
|
this.pages = new Array();
|
||||||
|
this.regions = new Array();
|
||||||
|
this.load(atlasText, textureLoader);
|
||||||
|
}
|
||||||
|
TextureAtlas.prototype.load = function (atlasText, textureLoader) {
|
||||||
|
if (textureLoader == null)
|
||||||
|
throw new Error("textureLoader cannot be null.");
|
||||||
|
var reader = new TextureAtlasReader(atlasText);
|
||||||
|
var tuple = new Array(4);
|
||||||
|
var page = null;
|
||||||
|
while (true) {
|
||||||
|
var line = reader.readLine();
|
||||||
|
if (line == null)
|
||||||
|
break;
|
||||||
|
line = line.trim();
|
||||||
|
if (line.length == 0)
|
||||||
|
page = null;
|
||||||
|
else if (!page) {
|
||||||
|
page = new TextureAtlasPage();
|
||||||
|
page.name = line;
|
||||||
|
if (reader.readTuple(tuple) == 2) {
|
||||||
|
page.width = parseInt(tuple[0]);
|
||||||
|
page.height = parseInt(tuple[1]);
|
||||||
|
reader.readTuple(tuple);
|
||||||
|
}
|
||||||
|
// page.format = Format[tuple[0]]; we don't need format in WebGL
|
||||||
|
reader.readTuple(tuple);
|
||||||
|
page.minFilter = spine.Texture.filterFromString(tuple[0]);
|
||||||
|
page.magFilter = spine.Texture.filterFromString(tuple[1]);
|
||||||
|
var direction = reader.readValue();
|
||||||
|
page.uWrap = spine.TextureWrap.ClampToEdge;
|
||||||
|
page.vWrap = spine.TextureWrap.ClampToEdge;
|
||||||
|
if (direction == "x")
|
||||||
|
page.uWrap = spine.TextureWrap.Repeat;
|
||||||
|
else if (direction == "y")
|
||||||
|
page.vWrap = spine.TextureWrap.Repeat;
|
||||||
|
else if (direction == "xy")
|
||||||
|
page.uWrap = page.vWrap = spine.TextureWrap.Repeat;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var region = new TextureAtlasRegion();
|
||||||
|
region.name = line;
|
||||||
|
region.page = page;
|
||||||
|
region.rotate = reader.readValue() == "true";
|
||||||
|
reader.readTuple(tuple);
|
||||||
|
var x = parseInt(tuple[0]);
|
||||||
|
var y = parseInt(tuple[1]);
|
||||||
|
reader.readTuple(tuple);
|
||||||
|
var width = parseInt(tuple[0]);
|
||||||
|
var height = parseInt(tuple[1]);
|
||||||
|
region.u = x / page.width;
|
||||||
|
region.v = y / page.height;
|
||||||
|
if (region.rotate) {
|
||||||
|
region.u2 = (x + height) / page.width;
|
||||||
|
region.v2 = (y + width) / page.height;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
region.u2 = (x + width) / page.width;
|
||||||
|
region.v2 = (y + height) / page.height;
|
||||||
|
}
|
||||||
|
region.x = x;
|
||||||
|
region.y = y;
|
||||||
|
region.width = Math.abs(width);
|
||||||
|
region.height = Math.abs(height);
|
||||||
|
if (reader.readTuple(tuple) == 4) {
|
||||||
|
// region.splits = new Vector.<int>(parseInt(tuple[0]), parseInt(tuple[1]), parseInt(tuple[2]), parseInt(tuple[3]));
|
||||||
|
if (reader.readTuple(tuple) == 4) {
|
||||||
|
//region.pads = Vector.<int>(parseInt(tuple[0]), parseInt(tuple[1]), parseInt(tuple[2]), parseInt(tuple[3]));
|
||||||
|
reader.readTuple(tuple);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
region.originalWidth = parseInt(tuple[0]);
|
||||||
|
region.originalHeight = parseInt(tuple[1]);
|
||||||
|
reader.readTuple(tuple);
|
||||||
|
region.offsetX = parseInt(tuple[0]);
|
||||||
|
region.offsetY = parseInt(tuple[1]);
|
||||||
|
region.index = parseInt(reader.readValue());
|
||||||
|
region.texture = page.texture;
|
||||||
|
this.regions.push(region);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
TextureAtlas.prototype.findRegion = function (name) {
|
||||||
|
for (var i = 0; i < this.regions.length; i++) {
|
||||||
|
if (this.regions[i].name == name) {
|
||||||
|
return this.regions[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
TextureAtlas.prototype.dispose = function () {
|
||||||
|
for (var i = 0; i < this.pages.length; i++) {
|
||||||
|
this.pages[i].texture.dispose();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return TextureAtlas;
|
||||||
|
}());
|
||||||
|
spine.TextureAtlas = TextureAtlas;
|
||||||
|
var TextureAtlasReader = (function () {
|
||||||
|
function TextureAtlasReader(text) {
|
||||||
|
this.index = 0;
|
||||||
|
this.lines = text.split(/\r\n|\r|\n/);
|
||||||
|
}
|
||||||
|
TextureAtlasReader.prototype.readLine = function () {
|
||||||
|
if (this.index >= this.lines.length)
|
||||||
|
return null;
|
||||||
|
return this.lines[this.index++];
|
||||||
|
};
|
||||||
|
TextureAtlasReader.prototype.readValue = function () {
|
||||||
|
var line = this.readLine();
|
||||||
|
var colon = line.indexOf(":");
|
||||||
|
if (colon == -1)
|
||||||
|
throw new Error("Invalid line: " + line);
|
||||||
|
return line.substring(colon + 1).trim();
|
||||||
|
};
|
||||||
|
TextureAtlasReader.prototype.readTuple = function (tuple) {
|
||||||
|
var line = this.readLine();
|
||||||
|
var colon = line.indexOf(":");
|
||||||
|
if (colon == -1)
|
||||||
|
throw new Error("Invalid line: " + line);
|
||||||
|
var i = 0, lastMatch = colon + 1;
|
||||||
|
for (; i < 3; i++) {
|
||||||
|
var comma = line.indexOf(",", lastMatch);
|
||||||
|
if (comma == -1)
|
||||||
|
break;
|
||||||
|
tuple[i] = line.substr(lastMatch, comma - lastMatch).trim();
|
||||||
|
lastMatch = comma + 1;
|
||||||
|
}
|
||||||
|
tuple[i] = line.substring(lastMatch).trim();
|
||||||
|
return i + 1;
|
||||||
|
};
|
||||||
|
return TextureAtlasReader;
|
||||||
|
}());
|
||||||
|
var TextureAtlasPage = (function () {
|
||||||
|
function TextureAtlasPage() {
|
||||||
|
}
|
||||||
|
return TextureAtlasPage;
|
||||||
|
}());
|
||||||
|
spine.TextureAtlasPage = TextureAtlasPage;
|
||||||
|
var TextureAtlasRegion = (function (_super) {
|
||||||
|
__extends(TextureAtlasRegion, _super);
|
||||||
|
function TextureAtlasRegion() {
|
||||||
|
_super.apply(this, arguments);
|
||||||
|
}
|
||||||
|
return TextureAtlasRegion;
|
||||||
|
}(spine.TextureRegion));
|
||||||
|
spine.TextureAtlasRegion = TextureAtlasRegion;
|
||||||
|
})(spine || (spine = {}));
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Spine Runtimes Software License
|
* Spine Runtimes Software License
|
||||||
* Version 2.5
|
* Version 2.5
|
||||||
@ -5061,154 +5440,61 @@ var spine;
|
|||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
var spine;
|
var spine;
|
||||||
(function (spine) {
|
|
||||||
var TextureRegion = (function () {
|
|
||||||
function TextureRegion() {
|
|
||||||
this.u = 0;
|
|
||||||
this.v = 0;
|
|
||||||
this.u2 = 0;
|
|
||||||
this.v2 = 0;
|
|
||||||
this.width = 0;
|
|
||||||
this.height = 0;
|
|
||||||
this.rotate = false;
|
|
||||||
this.offsetX = 0;
|
|
||||||
this.offsetY = 0;
|
|
||||||
this.originalWidth = 0;
|
|
||||||
this.originalHeight = 0;
|
|
||||||
}
|
|
||||||
return TextureRegion;
|
|
||||||
}());
|
|
||||||
spine.TextureRegion = TextureRegion;
|
|
||||||
})(spine || (spine = {}));
|
|
||||||
/******************************************************************************
|
|
||||||
* 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.
|
|
||||||
*****************************************************************************/
|
|
||||||
var spine;
|
|
||||||
(function (spine) {
|
(function (spine) {
|
||||||
var webgl;
|
var webgl;
|
||||||
(function (webgl) {
|
(function (webgl) {
|
||||||
var AssetManager = (function () {
|
var GLTexture = (function (_super) {
|
||||||
function AssetManager(gl) {
|
__extends(GLTexture, _super);
|
||||||
this._assets = {};
|
function GLTexture(gl, image, useMipMaps) {
|
||||||
this._errors = {};
|
if (useMipMaps === void 0) { useMipMaps = false; }
|
||||||
this._toLoad = 0;
|
_super.call(this, image);
|
||||||
this._loaded = 0;
|
this._boundUnit = 0;
|
||||||
this._gl = gl;
|
this._gl = gl;
|
||||||
|
this._texture = gl.createTexture();
|
||||||
|
this.update(useMipMaps);
|
||||||
}
|
}
|
||||||
AssetManager.prototype.loadText = function (path, success, error) {
|
GLTexture.prototype.setFilters = function (minFilter, magFilter) {
|
||||||
var _this = this;
|
var gl = this._gl;
|
||||||
if (success === void 0) { success = null; }
|
this.bind();
|
||||||
if (error === void 0) { error = null; }
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);
|
||||||
this._toLoad++;
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter);
|
||||||
var request = new XMLHttpRequest();
|
|
||||||
request.onreadystatechange = function () {
|
|
||||||
if (request.readyState == XMLHttpRequest.DONE) {
|
|
||||||
if (request.status >= 200 && request.status < 300) {
|
|
||||||
if (success)
|
|
||||||
success(path, request.responseText);
|
|
||||||
_this._assets[path] = request.responseText;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (error)
|
|
||||||
error(path, "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText);
|
|
||||||
_this._errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText;
|
|
||||||
}
|
|
||||||
_this._toLoad--;
|
|
||||||
_this._loaded++;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
request.open("GET", path, true);
|
|
||||||
request.send();
|
|
||||||
};
|
};
|
||||||
AssetManager.prototype.loadTexture = function (path, success, error) {
|
GLTexture.prototype.setWraps = function (uWrap, vWrap) {
|
||||||
var _this = this;
|
var gl = this._gl;
|
||||||
if (success === void 0) { success = null; }
|
this.bind();
|
||||||
if (error === void 0) { error = null; }
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, uWrap);
|
||||||
this._toLoad++;
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, vWrap);
|
||||||
var img = new Image();
|
|
||||||
img.src = path;
|
|
||||||
img.onload = function (ev) {
|
|
||||||
if (success)
|
|
||||||
success(path, img);
|
|
||||||
var texture = new webgl.Texture(_this._gl, img);
|
|
||||||
_this._assets[path] = texture;
|
|
||||||
_this._toLoad--;
|
|
||||||
_this._loaded++;
|
|
||||||
};
|
|
||||||
img.onerror = function (ev) {
|
|
||||||
if (error)
|
|
||||||
error(path, "Couldn't load image " + path);
|
|
||||||
_this._errors[path] = "Couldn't load image " + path;
|
|
||||||
_this._toLoad--;
|
|
||||||
_this._loaded++;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
AssetManager.prototype.get = function (path) {
|
GLTexture.prototype.update = function (useMipMaps) {
|
||||||
return this._assets[path];
|
var gl = this._gl;
|
||||||
|
this.bind();
|
||||||
|
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this._image);
|
||||||
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
||||||
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, useMipMaps ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);
|
||||||
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
||||||
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
||||||
|
if (useMipMaps)
|
||||||
|
gl.generateMipmap(gl.TEXTURE_2D);
|
||||||
};
|
};
|
||||||
AssetManager.prototype.remove = function (path) {
|
GLTexture.prototype.bind = function (unit) {
|
||||||
var asset = this._assets[path];
|
if (unit === void 0) { unit = 0; }
|
||||||
if (asset instanceof webgl.Texture) {
|
var gl = this._gl;
|
||||||
asset.dispose();
|
this._boundUnit = unit;
|
||||||
}
|
gl.activeTexture(gl.TEXTURE0 + unit);
|
||||||
this._assets[path] = null;
|
gl.bindTexture(gl.TEXTURE_2D, this._texture);
|
||||||
};
|
};
|
||||||
AssetManager.prototype.removeAll = function () {
|
GLTexture.prototype.unbind = function () {
|
||||||
for (var key in this._assets) {
|
var gl = this._gl;
|
||||||
var asset = this._assets[key];
|
gl.activeTexture(gl.TEXTURE0 + this._boundUnit);
|
||||||
if (asset instanceof webgl.Texture)
|
gl.bindTexture(gl.TEXTURE_2D, null);
|
||||||
asset.dispose();
|
|
||||||
}
|
|
||||||
this._assets = {};
|
|
||||||
};
|
};
|
||||||
AssetManager.prototype.isLoadingComplete = function () {
|
GLTexture.prototype.dispose = function () {
|
||||||
return this._toLoad == 0;
|
var gl = this._gl;
|
||||||
|
gl.deleteTexture(this._texture);
|
||||||
};
|
};
|
||||||
AssetManager.prototype.toLoad = function () {
|
return GLTexture;
|
||||||
return this._toLoad;
|
}(spine.Texture));
|
||||||
};
|
webgl.GLTexture = GLTexture;
|
||||||
AssetManager.prototype.loaded = function () {
|
|
||||||
return this._loaded;
|
|
||||||
};
|
|
||||||
AssetManager.prototype.dispose = function () {
|
|
||||||
this.removeAll();
|
|
||||||
};
|
|
||||||
AssetManager.prototype.hasErrors = function () {
|
|
||||||
return Object.keys(this._errors).length > 0;
|
|
||||||
};
|
|
||||||
AssetManager.prototype.errors = function () {
|
|
||||||
return this._errors;
|
|
||||||
};
|
|
||||||
return AssetManager;
|
|
||||||
}());
|
|
||||||
webgl.AssetManager = AssetManager;
|
|
||||||
})(webgl = spine.webgl || (spine.webgl = {}));
|
})(webgl = spine.webgl || (spine.webgl = {}));
|
||||||
})(spine || (spine = {}));
|
})(spine || (spine = {}));
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@ -6095,323 +6381,6 @@ var spine;
|
|||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
var spine;
|
var spine;
|
||||||
(function (spine) {
|
|
||||||
var webgl;
|
|
||||||
(function (webgl) {
|
|
||||||
var Texture = (function () {
|
|
||||||
function Texture(gl, image, useMipMaps) {
|
|
||||||
if (useMipMaps === void 0) { useMipMaps = false; }
|
|
||||||
this._boundUnit = 0;
|
|
||||||
this._gl = gl;
|
|
||||||
this._texture = gl.createTexture();
|
|
||||||
this._image = image;
|
|
||||||
this.update(useMipMaps);
|
|
||||||
}
|
|
||||||
Texture.prototype.getImage = function () {
|
|
||||||
return this._image;
|
|
||||||
};
|
|
||||||
Texture.prototype.setFilters = function (minFilter, magFilter) {
|
|
||||||
var gl = this._gl;
|
|
||||||
this.bind();
|
|
||||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);
|
|
||||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter);
|
|
||||||
};
|
|
||||||
Texture.prototype.setWraps = function (uWrap, vWrap) {
|
|
||||||
var gl = this._gl;
|
|
||||||
this.bind();
|
|
||||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, uWrap);
|
|
||||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, vWrap);
|
|
||||||
};
|
|
||||||
Texture.prototype.update = function (useMipMaps) {
|
|
||||||
var gl = this._gl;
|
|
||||||
this.bind();
|
|
||||||
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this._image);
|
|
||||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
||||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, useMipMaps ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);
|
|
||||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
||||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
||||||
if (useMipMaps)
|
|
||||||
gl.generateMipmap(gl.TEXTURE_2D);
|
|
||||||
};
|
|
||||||
Texture.prototype.bind = function (unit) {
|
|
||||||
if (unit === void 0) { unit = 0; }
|
|
||||||
var gl = this._gl;
|
|
||||||
this._boundUnit = unit;
|
|
||||||
gl.activeTexture(gl.TEXTURE0 + unit);
|
|
||||||
gl.bindTexture(gl.TEXTURE_2D, this._texture);
|
|
||||||
};
|
|
||||||
Texture.prototype.unbind = function () {
|
|
||||||
var gl = this._gl;
|
|
||||||
gl.activeTexture(gl.TEXTURE0 + this._boundUnit);
|
|
||||||
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
||||||
};
|
|
||||||
Texture.prototype.dispose = function () {
|
|
||||||
var gl = this._gl;
|
|
||||||
gl.deleteTexture(this._texture);
|
|
||||||
};
|
|
||||||
Texture.filterFromString = function (text) {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Texture.wrapFromString = function (text) {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return Texture;
|
|
||||||
}());
|
|
||||||
webgl.Texture = Texture;
|
|
||||||
(function (TextureFilter) {
|
|
||||||
TextureFilter[TextureFilter["Nearest"] = WebGLRenderingContext.NEAREST] = "Nearest";
|
|
||||||
TextureFilter[TextureFilter["Linear"] = WebGLRenderingContext.LINEAR] = "Linear";
|
|
||||||
TextureFilter[TextureFilter["MipMap"] = WebGLRenderingContext.LINEAR_MIPMAP_LINEAR] = "MipMap";
|
|
||||||
TextureFilter[TextureFilter["MipMapNearestNearest"] = WebGLRenderingContext.NEAREST_MIPMAP_NEAREST] = "MipMapNearestNearest";
|
|
||||||
TextureFilter[TextureFilter["MipMapLinearNearest"] = WebGLRenderingContext.LINEAR_MIPMAP_NEAREST] = "MipMapLinearNearest";
|
|
||||||
TextureFilter[TextureFilter["MipMapNearestLinear"] = WebGLRenderingContext.NEAREST_MIPMAP_LINEAR] = "MipMapNearestLinear";
|
|
||||||
TextureFilter[TextureFilter["MipMapLinearLinear"] = WebGLRenderingContext.LINEAR_MIPMAP_LINEAR] = "MipMapLinearLinear";
|
|
||||||
})(webgl.TextureFilter || (webgl.TextureFilter = {}));
|
|
||||||
var TextureFilter = webgl.TextureFilter;
|
|
||||||
(function (TextureWrap) {
|
|
||||||
TextureWrap[TextureWrap["MirroredRepeat"] = WebGLRenderingContext.MIRRORED_REPEAT] = "MirroredRepeat";
|
|
||||||
TextureWrap[TextureWrap["ClampToEdge"] = WebGLRenderingContext.CLAMP_TO_EDGE] = "ClampToEdge";
|
|
||||||
TextureWrap[TextureWrap["Repeat"] = WebGLRenderingContext.REPEAT] = "Repeat";
|
|
||||||
})(webgl.TextureWrap || (webgl.TextureWrap = {}));
|
|
||||||
var TextureWrap = webgl.TextureWrap;
|
|
||||||
})(webgl = spine.webgl || (spine.webgl = {}));
|
|
||||||
})(spine || (spine = {}));
|
|
||||||
/******************************************************************************
|
|
||||||
* 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.
|
|
||||||
*****************************************************************************/
|
|
||||||
var spine;
|
|
||||||
(function (spine) {
|
|
||||||
var webgl;
|
|
||||||
(function (webgl) {
|
|
||||||
var TextureAtlas = (function () {
|
|
||||||
function TextureAtlas(atlasText, textureLoader) {
|
|
||||||
this.pages = new Array();
|
|
||||||
this.regions = new Array();
|
|
||||||
this.load(atlasText, textureLoader);
|
|
||||||
}
|
|
||||||
TextureAtlas.prototype.load = function (atlasText, textureLoader) {
|
|
||||||
if (textureLoader == null)
|
|
||||||
throw new Error("textureLoader cannot be null.");
|
|
||||||
var reader = new TextureAtlasReader(atlasText);
|
|
||||||
var tuple = new Array(4);
|
|
||||||
var page = null;
|
|
||||||
while (true) {
|
|
||||||
var line = reader.readLine();
|
|
||||||
if (line == null)
|
|
||||||
break;
|
|
||||||
line = line.trim();
|
|
||||||
if (line.length == 0)
|
|
||||||
page = null;
|
|
||||||
else if (!page) {
|
|
||||||
page = new TextureAtlasPage();
|
|
||||||
page.name = line;
|
|
||||||
if (reader.readTuple(tuple) == 2) {
|
|
||||||
page.width = parseInt(tuple[0]);
|
|
||||||
page.height = parseInt(tuple[1]);
|
|
||||||
reader.readTuple(tuple);
|
|
||||||
}
|
|
||||||
// page.format = Format[tuple[0]]; we don't need format in WebGL
|
|
||||||
reader.readTuple(tuple);
|
|
||||||
page.minFilter = webgl.Texture.filterFromString(tuple[0]);
|
|
||||||
page.magFilter = webgl.Texture.filterFromString(tuple[1]);
|
|
||||||
var direction = reader.readValue();
|
|
||||||
page.uWrap = webgl.TextureWrap.ClampToEdge;
|
|
||||||
page.vWrap = webgl.TextureWrap.ClampToEdge;
|
|
||||||
if (direction == "x")
|
|
||||||
page.uWrap = webgl.TextureWrap.Repeat;
|
|
||||||
else if (direction == "y")
|
|
||||||
page.vWrap = webgl.TextureWrap.Repeat;
|
|
||||||
else if (direction == "xy")
|
|
||||||
page.uWrap = page.vWrap = webgl.TextureWrap.Repeat;
|
|
||||||
page.texture = textureLoader(line);
|
|
||||||
page.texture.setFilters(page.minFilter, page.magFilter);
|
|
||||||
page.texture.setWraps(page.uWrap, page.vWrap);
|
|
||||||
page.width = page.texture.getImage().width;
|
|
||||||
page.height = page.texture.getImage().height;
|
|
||||||
this.pages.push(page);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var region = new TextureAtlasRegion();
|
|
||||||
region.name = line;
|
|
||||||
region.page = page;
|
|
||||||
region.rotate = reader.readValue() == "true";
|
|
||||||
reader.readTuple(tuple);
|
|
||||||
var x = parseInt(tuple[0]);
|
|
||||||
var y = parseInt(tuple[1]);
|
|
||||||
reader.readTuple(tuple);
|
|
||||||
var width = parseInt(tuple[0]);
|
|
||||||
var height = parseInt(tuple[1]);
|
|
||||||
region.u = x / page.width;
|
|
||||||
region.v = y / page.height;
|
|
||||||
if (region.rotate) {
|
|
||||||
region.u2 = (x + height) / page.width;
|
|
||||||
region.v2 = (y + width) / page.height;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
region.u2 = (x + width) / page.width;
|
|
||||||
region.v2 = (y + height) / page.height;
|
|
||||||
}
|
|
||||||
region.x = x;
|
|
||||||
region.y = y;
|
|
||||||
region.width = Math.abs(width);
|
|
||||||
region.height = Math.abs(height);
|
|
||||||
if (reader.readTuple(tuple) == 4) {
|
|
||||||
// region.splits = new Vector.<int>(parseInt(tuple[0]), parseInt(tuple[1]), parseInt(tuple[2]), parseInt(tuple[3]));
|
|
||||||
if (reader.readTuple(tuple) == 4) {
|
|
||||||
//region.pads = Vector.<int>(parseInt(tuple[0]), parseInt(tuple[1]), parseInt(tuple[2]), parseInt(tuple[3]));
|
|
||||||
reader.readTuple(tuple);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
region.originalWidth = parseInt(tuple[0]);
|
|
||||||
region.originalHeight = parseInt(tuple[1]);
|
|
||||||
reader.readTuple(tuple);
|
|
||||||
region.offsetX = parseInt(tuple[0]);
|
|
||||||
region.offsetY = parseInt(tuple[1]);
|
|
||||||
region.index = parseInt(reader.readValue());
|
|
||||||
region.texture = page.texture;
|
|
||||||
this.regions.push(region);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
TextureAtlas.prototype.findRegion = function (name) {
|
|
||||||
for (var i = 0; i < this.regions.length; i++) {
|
|
||||||
if (this.regions[i].name == name) {
|
|
||||||
return this.regions[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
TextureAtlas.prototype.dispose = function () {
|
|
||||||
for (var i = 0; i < this.pages.length; i++) {
|
|
||||||
this.pages[i].texture.dispose();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return TextureAtlas;
|
|
||||||
}());
|
|
||||||
webgl.TextureAtlas = TextureAtlas;
|
|
||||||
var TextureAtlasReader = (function () {
|
|
||||||
function TextureAtlasReader(text) {
|
|
||||||
this.index = 0;
|
|
||||||
this.lines = text.split(/\r\n|\r|\n/);
|
|
||||||
}
|
|
||||||
TextureAtlasReader.prototype.readLine = function () {
|
|
||||||
if (this.index >= this.lines.length)
|
|
||||||
return null;
|
|
||||||
return this.lines[this.index++];
|
|
||||||
};
|
|
||||||
TextureAtlasReader.prototype.readValue = function () {
|
|
||||||
var line = this.readLine();
|
|
||||||
var colon = line.indexOf(":");
|
|
||||||
if (colon == -1)
|
|
||||||
throw new Error("Invalid line: " + line);
|
|
||||||
return line.substring(colon + 1).trim();
|
|
||||||
};
|
|
||||||
TextureAtlasReader.prototype.readTuple = function (tuple) {
|
|
||||||
var line = this.readLine();
|
|
||||||
var colon = line.indexOf(":");
|
|
||||||
if (colon == -1)
|
|
||||||
throw new Error("Invalid line: " + line);
|
|
||||||
var i = 0, lastMatch = colon + 1;
|
|
||||||
for (; i < 3; i++) {
|
|
||||||
var comma = line.indexOf(",", lastMatch);
|
|
||||||
if (comma == -1)
|
|
||||||
break;
|
|
||||||
tuple[i] = line.substr(lastMatch, comma - lastMatch).trim();
|
|
||||||
lastMatch = comma + 1;
|
|
||||||
}
|
|
||||||
tuple[i] = line.substring(lastMatch).trim();
|
|
||||||
return i + 1;
|
|
||||||
};
|
|
||||||
return TextureAtlasReader;
|
|
||||||
}());
|
|
||||||
var TextureAtlasPage = (function () {
|
|
||||||
function TextureAtlasPage() {
|
|
||||||
}
|
|
||||||
return TextureAtlasPage;
|
|
||||||
}());
|
|
||||||
webgl.TextureAtlasPage = TextureAtlasPage;
|
|
||||||
var TextureAtlasRegion = (function (_super) {
|
|
||||||
__extends(TextureAtlasRegion, _super);
|
|
||||||
function TextureAtlasRegion() {
|
|
||||||
_super.apply(this, arguments);
|
|
||||||
}
|
|
||||||
return TextureAtlasRegion;
|
|
||||||
}(spine.TextureRegion));
|
|
||||||
webgl.TextureAtlasRegion = TextureAtlasRegion;
|
|
||||||
})(webgl = spine.webgl || (spine.webgl = {}));
|
|
||||||
})(spine || (spine = {}));
|
|
||||||
/******************************************************************************
|
|
||||||
* 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.
|
|
||||||
*****************************************************************************/
|
|
||||||
var spine;
|
|
||||||
(function (spine) {
|
(function (spine) {
|
||||||
var webgl;
|
var webgl;
|
||||||
(function (webgl) {
|
(function (webgl) {
|
||||||
@ -6673,7 +6642,9 @@ var spine;
|
|||||||
this._batcher = new spine.webgl.PolygonBatcher(gl);
|
this._batcher = new spine.webgl.PolygonBatcher(gl);
|
||||||
this._mvp.ortho2d(0, 0, 639, 479);
|
this._mvp.ortho2d(0, 0, 639, 479);
|
||||||
this._skeletonRenderer = new spine.webgl.SkeletonRenderer(gl);
|
this._skeletonRenderer = new spine.webgl.SkeletonRenderer(gl);
|
||||||
var assets = this._assetManager = new spine.webgl.AssetManager(gl);
|
var assets = this._assetManager = new spine.AssetManager(function (image) {
|
||||||
|
return new spine.webgl.GLTexture(gl, image);
|
||||||
|
});
|
||||||
assets.loadText(config.atlas);
|
assets.loadText(config.atlas);
|
||||||
assets.loadText(config.json);
|
assets.loadText(config.json);
|
||||||
assets.loadTexture(config.atlas.replace(".atlas", ".png"));
|
assets.loadTexture(config.atlas.replace(".atlas", ".png"));
|
||||||
@ -6728,8 +6699,11 @@ var spine;
|
|||||||
else
|
else
|
||||||
throw new Error("Failed to load assets: " + JSON.stringify(assetManager.errors));
|
throw new Error("Failed to load assets: " + JSON.stringify(assetManager.errors));
|
||||||
}
|
}
|
||||||
var atlas = new spine.webgl.TextureAtlas(this._assetManager.get(this._config.atlas), function (path) {
|
var atlas = new spine.TextureAtlas(this._assetManager.get(this._config.atlas), function (path, minFilter, magFilter, uWrap, vWrap) {
|
||||||
return assetManager.get(imagesPath + path);
|
var texture = assetManager.get(imagesPath + path);
|
||||||
|
texture.setFilters(minFilter, magFilter);
|
||||||
|
texture.setWraps(uWrap, vWrap);
|
||||||
|
return texture;
|
||||||
});
|
});
|
||||||
var atlasLoader = new spine.webgl.TextureAtlasAttachmentLoader(atlas);
|
var atlasLoader = new spine.webgl.TextureAtlasAttachmentLoader(atlas);
|
||||||
var skeletonJson = new spine.SkeletonJson(atlasLoader);
|
var skeletonJson = new spine.SkeletonJson(atlasLoader);
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
293
spine-ts/canvas/example/assets/goblins-mesh.atlas
Normal file
293
spine-ts/canvas/example/assets/goblins-mesh.atlas
Normal file
@ -0,0 +1,293 @@
|
|||||||
|
|
||||||
|
goblins-mesh.png
|
||||||
|
size: 1024,128
|
||||||
|
format: RGBA8888
|
||||||
|
filter: Linear,Linear
|
||||||
|
repeat: none
|
||||||
|
dagger
|
||||||
|
rotate: true
|
||||||
|
xy: 372, 100
|
||||||
|
size: 26, 108
|
||||||
|
orig: 26, 108
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblin/eyes-closed
|
||||||
|
rotate: false
|
||||||
|
xy: 2, 7
|
||||||
|
size: 34, 12
|
||||||
|
orig: 34, 12
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblin/head
|
||||||
|
rotate: false
|
||||||
|
xy: 107, 36
|
||||||
|
size: 103, 66
|
||||||
|
orig: 103, 66
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblin/left-arm
|
||||||
|
rotate: false
|
||||||
|
xy: 901, 56
|
||||||
|
size: 37, 35
|
||||||
|
orig: 37, 35
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblin/left-foot
|
||||||
|
rotate: false
|
||||||
|
xy: 929, 95
|
||||||
|
size: 65, 31
|
||||||
|
orig: 65, 31
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblin/left-hand
|
||||||
|
rotate: false
|
||||||
|
xy: 452, 2
|
||||||
|
size: 36, 41
|
||||||
|
orig: 36, 41
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblin/left-lower-leg
|
||||||
|
rotate: true
|
||||||
|
xy: 713, 93
|
||||||
|
size: 33, 70
|
||||||
|
orig: 33, 70
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblin/left-shoulder
|
||||||
|
rotate: false
|
||||||
|
xy: 610, 44
|
||||||
|
size: 29, 44
|
||||||
|
orig: 29, 44
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblin/left-upper-leg
|
||||||
|
rotate: true
|
||||||
|
xy: 638, 93
|
||||||
|
size: 33, 73
|
||||||
|
orig: 33, 73
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblin/neck
|
||||||
|
rotate: false
|
||||||
|
xy: 490, 2
|
||||||
|
size: 36, 41
|
||||||
|
orig: 36, 41
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblin/pelvis
|
||||||
|
rotate: false
|
||||||
|
xy: 482, 45
|
||||||
|
size: 62, 43
|
||||||
|
orig: 62, 43
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblin/right-arm
|
||||||
|
rotate: true
|
||||||
|
xy: 690, 2
|
||||||
|
size: 23, 50
|
||||||
|
orig: 23, 50
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblin/right-foot
|
||||||
|
rotate: false
|
||||||
|
xy: 771, 58
|
||||||
|
size: 63, 33
|
||||||
|
orig: 63, 33
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblin/right-hand
|
||||||
|
rotate: false
|
||||||
|
xy: 940, 56
|
||||||
|
size: 36, 37
|
||||||
|
orig: 36, 37
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblin/right-lower-leg
|
||||||
|
rotate: true
|
||||||
|
xy: 482, 90
|
||||||
|
size: 36, 76
|
||||||
|
orig: 36, 76
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblin/right-shoulder
|
||||||
|
rotate: true
|
||||||
|
xy: 602, 3
|
||||||
|
size: 39, 45
|
||||||
|
orig: 39, 45
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblin/right-upper-leg
|
||||||
|
rotate: true
|
||||||
|
xy: 641, 57
|
||||||
|
size: 34, 63
|
||||||
|
orig: 34, 63
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblin/torso
|
||||||
|
rotate: true
|
||||||
|
xy: 212, 34
|
||||||
|
size: 68, 96
|
||||||
|
orig: 68, 96
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblin/undie-straps
|
||||||
|
rotate: false
|
||||||
|
xy: 380, 5
|
||||||
|
size: 55, 19
|
||||||
|
orig: 55, 19
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblin/undies
|
||||||
|
rotate: false
|
||||||
|
xy: 174, 5
|
||||||
|
size: 36, 29
|
||||||
|
orig: 36, 29
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblingirl/eyes-closed
|
||||||
|
rotate: false
|
||||||
|
xy: 269, 11
|
||||||
|
size: 37, 21
|
||||||
|
orig: 37, 21
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblingirl/head
|
||||||
|
rotate: false
|
||||||
|
xy: 2, 21
|
||||||
|
size: 103, 81
|
||||||
|
orig: 103, 81
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblingirl/left-arm
|
||||||
|
rotate: true
|
||||||
|
xy: 978, 56
|
||||||
|
size: 37, 35
|
||||||
|
orig: 37, 35
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblingirl/left-foot
|
||||||
|
rotate: false
|
||||||
|
xy: 107, 3
|
||||||
|
size: 65, 31
|
||||||
|
orig: 65, 31
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblingirl/left-hand
|
||||||
|
rotate: false
|
||||||
|
xy: 565, 2
|
||||||
|
size: 35, 40
|
||||||
|
orig: 35, 40
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblingirl/left-lower-leg
|
||||||
|
rotate: true
|
||||||
|
xy: 785, 93
|
||||||
|
size: 33, 70
|
||||||
|
orig: 33, 70
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblingirl/left-shoulder
|
||||||
|
rotate: true
|
||||||
|
xy: 690, 27
|
||||||
|
size: 28, 46
|
||||||
|
orig: 28, 46
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblingirl/left-upper-leg
|
||||||
|
rotate: true
|
||||||
|
xy: 857, 93
|
||||||
|
size: 33, 70
|
||||||
|
orig: 33, 70
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblingirl/neck
|
||||||
|
rotate: false
|
||||||
|
xy: 528, 2
|
||||||
|
size: 35, 41
|
||||||
|
orig: 35, 41
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblingirl/pelvis
|
||||||
|
rotate: false
|
||||||
|
xy: 546, 45
|
||||||
|
size: 62, 43
|
||||||
|
orig: 62, 43
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblingirl/right-arm
|
||||||
|
rotate: false
|
||||||
|
xy: 452, 48
|
||||||
|
size: 28, 50
|
||||||
|
orig: 28, 50
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblingirl/right-foot
|
||||||
|
rotate: false
|
||||||
|
xy: 836, 58
|
||||||
|
size: 63, 33
|
||||||
|
orig: 63, 33
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblingirl/right-hand
|
||||||
|
rotate: true
|
||||||
|
xy: 771, 20
|
||||||
|
size: 36, 37
|
||||||
|
orig: 36, 37
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblingirl/right-lower-leg
|
||||||
|
rotate: true
|
||||||
|
xy: 560, 90
|
||||||
|
size: 36, 76
|
||||||
|
orig: 36, 76
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblingirl/right-shoulder
|
||||||
|
rotate: false
|
||||||
|
xy: 649, 10
|
||||||
|
size: 39, 45
|
||||||
|
orig: 39, 45
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblingirl/right-upper-leg
|
||||||
|
rotate: true
|
||||||
|
xy: 706, 57
|
||||||
|
size: 34, 63
|
||||||
|
orig: 34, 63
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblingirl/torso
|
||||||
|
rotate: false
|
||||||
|
xy: 310, 2
|
||||||
|
size: 68, 96
|
||||||
|
orig: 68, 96
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblingirl/undie-straps
|
||||||
|
rotate: false
|
||||||
|
xy: 212, 13
|
||||||
|
size: 55, 19
|
||||||
|
orig: 55, 19
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goblingirl/undies
|
||||||
|
rotate: false
|
||||||
|
xy: 810, 27
|
||||||
|
size: 36, 29
|
||||||
|
orig: 36, 29
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
shield
|
||||||
|
rotate: false
|
||||||
|
xy: 380, 26
|
||||||
|
size: 70, 72
|
||||||
|
orig: 70, 72
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
spear
|
||||||
|
rotate: true
|
||||||
|
xy: 2, 104
|
||||||
|
size: 22, 368
|
||||||
|
orig: 22, 368
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
1082
spine-ts/canvas/example/assets/goblins-mesh.json
Normal file
1082
spine-ts/canvas/example/assets/goblins-mesh.json
Normal file
File diff suppressed because it is too large
Load Diff
BIN
spine-ts/canvas/example/assets/goblins-mesh.png
Normal file
BIN
spine-ts/canvas/example/assets/goblins-mesh.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 157 KiB |
279
spine-ts/canvas/example/assets/raptor.atlas
Normal file
279
spine-ts/canvas/example/assets/raptor.atlas
Normal file
@ -0,0 +1,279 @@
|
|||||||
|
|
||||||
|
raptor.png
|
||||||
|
size: 1024,1024
|
||||||
|
format: RGBA8888
|
||||||
|
filter: Linear,Linear
|
||||||
|
repeat: none
|
||||||
|
back_arm
|
||||||
|
rotate: true
|
||||||
|
xy: 140, 191
|
||||||
|
size: 46, 29
|
||||||
|
orig: 46, 29
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
back_bracer
|
||||||
|
rotate: true
|
||||||
|
xy: 167, 317
|
||||||
|
size: 39, 28
|
||||||
|
orig: 39, 28
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
back_hand
|
||||||
|
rotate: false
|
||||||
|
xy: 167, 358
|
||||||
|
size: 36, 34
|
||||||
|
orig: 36, 34
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
back_knee
|
||||||
|
rotate: false
|
||||||
|
xy: 299, 478
|
||||||
|
size: 49, 67
|
||||||
|
orig: 49, 67
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
back_thigh
|
||||||
|
rotate: true
|
||||||
|
xy: 167, 437
|
||||||
|
size: 39, 24
|
||||||
|
orig: 39, 24
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
eyes_closed
|
||||||
|
rotate: true
|
||||||
|
xy: 2, 2
|
||||||
|
size: 47, 45
|
||||||
|
orig: 47, 45
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
eyes_open
|
||||||
|
rotate: true
|
||||||
|
xy: 49, 2
|
||||||
|
size: 47, 45
|
||||||
|
orig: 47, 45
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
eyes_surprised
|
||||||
|
rotate: true
|
||||||
|
xy: 96, 2
|
||||||
|
size: 47, 45
|
||||||
|
orig: 47, 45
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
front_arm
|
||||||
|
rotate: false
|
||||||
|
xy: 419, 544
|
||||||
|
size: 48, 30
|
||||||
|
orig: 48, 30
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
front_bracer
|
||||||
|
rotate: false
|
||||||
|
xy: 880, 695
|
||||||
|
size: 41, 29
|
||||||
|
orig: 41, 29
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
front_hand
|
||||||
|
rotate: true
|
||||||
|
xy: 167, 394
|
||||||
|
size: 41, 38
|
||||||
|
orig: 41, 38
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
front_open_hand
|
||||||
|
rotate: false
|
||||||
|
xy: 880, 726
|
||||||
|
size: 43, 44
|
||||||
|
orig: 43, 44
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
front_thigh
|
||||||
|
rotate: false
|
||||||
|
xy: 360, 545
|
||||||
|
size: 57, 29
|
||||||
|
orig: 57, 29
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
gun
|
||||||
|
rotate: false
|
||||||
|
xy: 785, 774
|
||||||
|
size: 107, 103
|
||||||
|
orig: 107, 103
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
gun_nohand
|
||||||
|
rotate: false
|
||||||
|
xy: 614, 703
|
||||||
|
size: 105, 102
|
||||||
|
orig: 105, 102
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
head
|
||||||
|
rotate: false
|
||||||
|
xy: 2, 137
|
||||||
|
size: 136, 149
|
||||||
|
orig: 136, 149
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
lower_leg
|
||||||
|
rotate: true
|
||||||
|
xy: 780, 699
|
||||||
|
size: 73, 98
|
||||||
|
orig: 73, 98
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
mouth_grind
|
||||||
|
rotate: false
|
||||||
|
xy: 469, 544
|
||||||
|
size: 47, 30
|
||||||
|
orig: 47, 30
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
mouth_oooo
|
||||||
|
rotate: true
|
||||||
|
xy: 894, 772
|
||||||
|
size: 105, 30
|
||||||
|
orig: 105, 30
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
mouth_smile
|
||||||
|
rotate: true
|
||||||
|
xy: 140, 239
|
||||||
|
size: 47, 30
|
||||||
|
orig: 47, 30
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
neck
|
||||||
|
rotate: true
|
||||||
|
xy: 538, 577
|
||||||
|
size: 18, 21
|
||||||
|
orig: 18, 21
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
raptor_arm_back
|
||||||
|
rotate: false
|
||||||
|
xy: 940, 936
|
||||||
|
size: 82, 86
|
||||||
|
orig: 82, 86
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
raptor_body
|
||||||
|
rotate: false
|
||||||
|
xy: 2, 737
|
||||||
|
size: 610, 285
|
||||||
|
orig: 610, 285
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
raptor_front_arm
|
||||||
|
rotate: true
|
||||||
|
xy: 195, 464
|
||||||
|
size: 81, 102
|
||||||
|
orig: 81, 102
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
raptor_front_leg
|
||||||
|
rotate: false
|
||||||
|
xy: 2, 478
|
||||||
|
size: 191, 257
|
||||||
|
orig: 191, 257
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
raptor_hindleg_back
|
||||||
|
rotate: false
|
||||||
|
xy: 614, 807
|
||||||
|
size: 169, 215
|
||||||
|
orig: 169, 215
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
raptor_horn
|
||||||
|
rotate: false
|
||||||
|
xy: 360, 655
|
||||||
|
size: 182, 80
|
||||||
|
orig: 182, 80
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
raptor_horn_back
|
||||||
|
rotate: false
|
||||||
|
xy: 360, 576
|
||||||
|
size: 176, 77
|
||||||
|
orig: 176, 77
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
raptor_jaw
|
||||||
|
rotate: false
|
||||||
|
xy: 785, 879
|
||||||
|
size: 153, 143
|
||||||
|
orig: 153, 143
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
raptor_saddle_noshadow
|
||||||
|
rotate: false
|
||||||
|
xy: 2, 288
|
||||||
|
size: 163, 188
|
||||||
|
orig: 163, 188
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
raptor_saddle_strap_front
|
||||||
|
rotate: false
|
||||||
|
xy: 721, 710
|
||||||
|
size: 57, 95
|
||||||
|
orig: 57, 95
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
raptor_saddle_strap_rear
|
||||||
|
rotate: true
|
||||||
|
xy: 940, 880
|
||||||
|
size: 54, 74
|
||||||
|
orig: 54, 74
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
raptor_saddle_w_shadow
|
||||||
|
rotate: false
|
||||||
|
xy: 195, 547
|
||||||
|
size: 163, 188
|
||||||
|
orig: 163, 188
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
raptor_tongue
|
||||||
|
rotate: true
|
||||||
|
xy: 544, 649
|
||||||
|
size: 86, 64
|
||||||
|
orig: 86, 64
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
stirrup_back
|
||||||
|
rotate: true
|
||||||
|
xy: 140, 145
|
||||||
|
size: 44, 35
|
||||||
|
orig: 44, 35
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
stirrup_front
|
||||||
|
rotate: false
|
||||||
|
xy: 538, 597
|
||||||
|
size: 45, 50
|
||||||
|
orig: 45, 50
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
stirrup_strap
|
||||||
|
rotate: false
|
||||||
|
xy: 350, 497
|
||||||
|
size: 49, 46
|
||||||
|
orig: 49, 46
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
torso
|
||||||
|
rotate: true
|
||||||
|
xy: 610, 647
|
||||||
|
size: 54, 91
|
||||||
|
orig: 54, 91
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
visor
|
||||||
|
rotate: false
|
||||||
|
xy: 2, 51
|
||||||
|
size: 131, 84
|
||||||
|
orig: 131, 84
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
2621
spine-ts/canvas/example/assets/raptor.json
Normal file
2621
spine-ts/canvas/example/assets/raptor.json
Normal file
File diff suppressed because one or more lines are too long
BIN
spine-ts/canvas/example/assets/raptor.png
Normal file
BIN
spine-ts/canvas/example/assets/raptor.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 495 KiB |
125
spine-ts/canvas/example/assets/tank.atlas
Normal file
125
spine-ts/canvas/example/assets/tank.atlas
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
|
||||||
|
tank.png
|
||||||
|
size: 2048,1024
|
||||||
|
format: RGBA8888
|
||||||
|
filter: Linear,Linear
|
||||||
|
repeat: none
|
||||||
|
images/antenna
|
||||||
|
rotate: true
|
||||||
|
xy: 1295, 683
|
||||||
|
size: 22, 303
|
||||||
|
orig: 22, 303
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
images/cannon
|
||||||
|
rotate: false
|
||||||
|
xy: 2, 93
|
||||||
|
size: 931, 58
|
||||||
|
orig: 931, 58
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
images/cannonConnector
|
||||||
|
rotate: true
|
||||||
|
xy: 1676, 455
|
||||||
|
size: 112, 135
|
||||||
|
orig: 112, 135
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
images/guntower
|
||||||
|
rotate: false
|
||||||
|
xy: 1295, 707
|
||||||
|
size: 730, 289
|
||||||
|
orig: 730, 289
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
images/machinegun
|
||||||
|
rotate: false
|
||||||
|
xy: 2, 34
|
||||||
|
size: 331, 57
|
||||||
|
orig: 331, 57
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
images/machinegun-mount
|
||||||
|
rotate: false
|
||||||
|
xy: 1952, 609
|
||||||
|
size: 72, 96
|
||||||
|
orig: 72, 96
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
images/rock
|
||||||
|
rotate: false
|
||||||
|
xy: 935, 96
|
||||||
|
size: 252, 55
|
||||||
|
orig: 252, 55
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
images/tankBottom
|
||||||
|
rotate: false
|
||||||
|
xy: 2, 377
|
||||||
|
size: 1285, 276
|
||||||
|
orig: 1285, 276
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
images/tankBottom-shadow
|
||||||
|
rotate: false
|
||||||
|
xy: 2, 655
|
||||||
|
size: 1291, 341
|
||||||
|
orig: 1291, 341
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
images/tankTop
|
||||||
|
rotate: false
|
||||||
|
xy: 2, 153
|
||||||
|
size: 1407, 222
|
||||||
|
orig: 1407, 222
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
images/tread
|
||||||
|
rotate: false
|
||||||
|
xy: 2, 2
|
||||||
|
size: 96, 30
|
||||||
|
orig: 96, 30
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
images/tread-inside
|
||||||
|
rotate: false
|
||||||
|
xy: 335, 63
|
||||||
|
size: 25, 28
|
||||||
|
orig: 25, 28
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
images/wheel-big
|
||||||
|
rotate: false
|
||||||
|
xy: 1295, 490
|
||||||
|
size: 191, 191
|
||||||
|
orig: 191, 191
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
images/wheel-big-overlay
|
||||||
|
rotate: false
|
||||||
|
xy: 1488, 495
|
||||||
|
size: 186, 186
|
||||||
|
orig: 186, 186
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
images/wheel-mid
|
||||||
|
rotate: false
|
||||||
|
xy: 1676, 569
|
||||||
|
size: 136, 136
|
||||||
|
orig: 136, 136
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
images/wheel-mid-overlay
|
||||||
|
rotate: false
|
||||||
|
xy: 1814, 569
|
||||||
|
size: 136, 136
|
||||||
|
orig: 136, 136
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
images/wheel-small
|
||||||
|
rotate: false
|
||||||
|
xy: 1813, 496
|
||||||
|
size: 71, 71
|
||||||
|
orig: 71, 71
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
1899
spine-ts/canvas/example/assets/tank.json
Normal file
1899
spine-ts/canvas/example/assets/tank.json
Normal file
File diff suppressed because it is too large
Load Diff
BIN
spine-ts/canvas/example/assets/tank.png
Normal file
BIN
spine-ts/canvas/example/assets/tank.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 MiB |
13
spine-ts/canvas/example/assets/test.atlas
Normal file
13
spine-ts/canvas/example/assets/test.atlas
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
test.png
|
||||||
|
size: 512,512
|
||||||
|
format: RGBA8888
|
||||||
|
filter: Linear,Linear
|
||||||
|
repeat: none
|
||||||
|
badlogic
|
||||||
|
rotate: false
|
||||||
|
xy: 2, 2
|
||||||
|
size: 460, 460
|
||||||
|
orig: 460, 460
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
19
spine-ts/canvas/example/assets/test.json
Normal file
19
spine-ts/canvas/example/assets/test.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"skeleton": { "hash": "lDI/ipVg9yXAdln1ZwTDAuXPGng", "spine": "3.4.02", "width": 650.27, "height": 650.27, "images": "./images/" },
|
||||||
|
"bones": [
|
||||||
|
{ "name": "root" }
|
||||||
|
],
|
||||||
|
"slots": [
|
||||||
|
{ "name": "badlogic", "bone": "root", "attachment": "badlogic" }
|
||||||
|
],
|
||||||
|
"skins": {
|
||||||
|
"default": {
|
||||||
|
"badlogic": {
|
||||||
|
"badlogic": { "rotation": 43.36, "width": 460, "height": 460 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"animations": {
|
||||||
|
"animation": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
spine-ts/canvas/example/assets/test.png
Normal file
BIN
spine-ts/canvas/example/assets/test.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 43 KiB |
13
spine-ts/canvas/example/assets/vine.atlas
Normal file
13
spine-ts/canvas/example/assets/vine.atlas
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
vine.png
|
||||||
|
size: 128,1024
|
||||||
|
format: RGBA8888
|
||||||
|
filter: Linear,Linear
|
||||||
|
repeat: none
|
||||||
|
images/vine
|
||||||
|
rotate: false
|
||||||
|
xy: 2, 2
|
||||||
|
size: 68, 962
|
||||||
|
orig: 68, 962
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
300
spine-ts/canvas/example/assets/vine.json
Normal file
300
spine-ts/canvas/example/assets/vine.json
Normal file
File diff suppressed because one or more lines are too long
BIN
spine-ts/canvas/example/assets/vine.png
Normal file
BIN
spine-ts/canvas/example/assets/vine.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 156 KiB |
@ -10,13 +10,108 @@
|
|||||||
|
|
||||||
var lastFrameTime = Date.now() / 1000;
|
var lastFrameTime = Date.now() / 1000;
|
||||||
var canvas;
|
var canvas;
|
||||||
|
var context;
|
||||||
var assetManager;
|
var assetManager;
|
||||||
|
var skeleton;
|
||||||
|
var state;
|
||||||
var skeletonRenderer;
|
var skeletonRenderer;
|
||||||
|
|
||||||
function init () {
|
function init () {
|
||||||
|
canvas = document.getElementById("canvas");
|
||||||
|
canvas.width = 640;
|
||||||
|
canvas.height = 480;
|
||||||
|
context = canvas.getContext("2d");
|
||||||
|
|
||||||
|
skeletonRenderer = new spine.canvas.SkeletonRenderer(context);
|
||||||
|
|
||||||
assetManager = new spine.AssetManager(function(image) {
|
assetManager = new spine.AssetManager(function(image) {
|
||||||
return CanvasTexture(image);
|
return new spine.canvas.CanvasTexture(image);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
assetManager.loadText("assets/spineboy.json");
|
||||||
|
assetManager.loadText("assets/spineboy.atlas");
|
||||||
|
assetManager.loadTexture("assets/spineboy.png");
|
||||||
|
assetManager.loadText("assets/test.json");
|
||||||
|
assetManager.loadText("assets/test.atlas");
|
||||||
|
assetManager.loadTexture("assets/test.png");
|
||||||
|
assetManager.loadText("assets/raptor.json");
|
||||||
|
assetManager.loadText("assets/raptor.atlas");
|
||||||
|
assetManager.loadTexture("assets/raptor.png");
|
||||||
|
|
||||||
|
requestAnimationFrame(load);
|
||||||
|
}
|
||||||
|
|
||||||
|
function load () {
|
||||||
|
if (assetManager.isLoadingComplete()) {
|
||||||
|
var data = loadSkeleton("raptor", 0.3, "walk", 320, 20, "default");
|
||||||
|
skeleton = data.skeleton;
|
||||||
|
state = data.state;
|
||||||
|
requestAnimationFrame(render);
|
||||||
|
} else {
|
||||||
|
requestAnimationFrame(load);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadSkeleton (name, scale, initialAnimation, positionX, positionY, skin) {
|
||||||
|
if (skin === undefined) skin = "default";
|
||||||
|
|
||||||
|
// 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.TextureAtlas(assetManager.get("assets/" + name + ".atlas"), function(path) {
|
||||||
|
return assetManager.get("assets/" + path);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create a TextureAtlasAttachmentLoader, which is specific to the WebGL backend.
|
||||||
|
atlasLoader = new spine.TextureAtlasAttachmentLoader(atlas);
|
||||||
|
|
||||||
|
// Create a SkeletonJson instance for parsing the .json file.
|
||||||
|
var skeletonJson = new spine.SkeletonJson(atlasLoader);
|
||||||
|
|
||||||
|
// Set the scale to apply during parsing, parse the file, and create a new skeleton.
|
||||||
|
skeletonJson.scale = scale;
|
||||||
|
var skeletonData = skeletonJson.readSkeletonData(assetManager.get("assets/" + name + ".json"));
|
||||||
|
var skeleton = new spine.Skeleton(skeletonData);
|
||||||
|
skeleton.x = positionX;
|
||||||
|
skeleton.y = positionY;
|
||||||
|
skeleton.setSkinByName(skin);
|
||||||
|
|
||||||
|
// Create an AnimationState, and set the initial animation in looping mode.
|
||||||
|
var animationState = new spine.AnimationState(new spine.AnimationStateData(skeleton.data));
|
||||||
|
animationState.setAnimation(0, initialAnimation, true);
|
||||||
|
animationState.addListener({
|
||||||
|
event: function(trackIndex, event) {
|
||||||
|
// console.log("Event on track " + trackIndex + ": " + JSON.stringify(event));
|
||||||
|
},
|
||||||
|
complete: function(trackIndex, loopCount) {
|
||||||
|
// console.log("Animation on track " + trackIndex + " completed, loop count: " + loopCount);
|
||||||
|
},
|
||||||
|
start: function(trackIndex) {
|
||||||
|
// console.log("Animation on track " + trackIndex + " started");
|
||||||
|
},
|
||||||
|
end: function(trackIndex) {
|
||||||
|
// console.log("Animation on track " + trackIndex + " ended");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// Pack everything up and return to caller.
|
||||||
|
return { skeleton: skeleton, state: animationState };
|
||||||
|
}
|
||||||
|
|
||||||
|
function render () {
|
||||||
|
var now = Date.now() / 1000;
|
||||||
|
var delta = now - lastFrameTime;
|
||||||
|
lastFrameTime = now;
|
||||||
|
|
||||||
|
state.update(delta);
|
||||||
|
state.apply(skeleton);
|
||||||
|
skeleton.updateWorldTransform();
|
||||||
|
|
||||||
|
context.fillStyle = "#cccccc";
|
||||||
|
context.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
skeletonRenderer.draw(skeleton);
|
||||||
|
|
||||||
|
requestAnimationFrame(render);
|
||||||
}
|
}
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|||||||
@ -1,3 +1,36 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* 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.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
/// <reference path="../../core/src/Texture.ts"/>
|
||||||
|
|
||||||
module spine.canvas {
|
module spine.canvas {
|
||||||
export class CanvasTexture extends Texture {
|
export class CanvasTexture extends Texture {
|
||||||
constructor (image: HTMLImageElement) {
|
constructor (image: HTMLImageElement) {
|
||||||
|
|||||||
@ -1,5 +1,143 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* 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.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
module spine.canvas {
|
module spine.canvas {
|
||||||
export class SkeletonRenderer {
|
export class SkeletonRenderer {
|
||||||
|
static QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0];
|
||||||
|
|
||||||
|
private _ctx: CanvasRenderingContext2D;
|
||||||
|
|
||||||
|
constructor (context: CanvasRenderingContext2D) {
|
||||||
|
this._ctx = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
draw (skeleton: Skeleton) {
|
||||||
|
let blendMode: BlendMode = null;
|
||||||
|
let ctx = this._ctx;
|
||||||
|
|
||||||
|
let vertices: ArrayLike<number> = null;
|
||||||
|
let triangles: Array<number> = null;
|
||||||
|
let drawOrder = skeleton.drawOrder;
|
||||||
|
|
||||||
|
for (let i = 0, n = drawOrder.length; i < n; i++) {
|
||||||
|
let slot = drawOrder[i];
|
||||||
|
let attachment = slot.getAttachment();
|
||||||
|
let texture: HTMLImageElement = null;
|
||||||
|
let region: TextureAtlasRegion = null;
|
||||||
|
if (attachment instanceof RegionAttachment) {
|
||||||
|
let regionAttachment = <RegionAttachment>attachment;
|
||||||
|
vertices = regionAttachment.updateWorldVertices(slot, false);
|
||||||
|
triangles = SkeletonRenderer.QUAD_TRIANGLES;
|
||||||
|
region = <TextureAtlasRegion>regionAttachment.region;
|
||||||
|
texture = (<CanvasTexture>region.texture).getImage();
|
||||||
|
|
||||||
|
} else if (attachment instanceof MeshAttachment) {
|
||||||
|
let mesh = <MeshAttachment>attachment;
|
||||||
|
vertices = mesh.updateWorldVertices(slot, false);
|
||||||
|
triangles = mesh.triangles;
|
||||||
|
texture = (<TextureAtlasRegion>mesh.region.renderObject).texture.getImage();
|
||||||
|
} else continue;
|
||||||
|
|
||||||
|
if (texture != null) {
|
||||||
|
let slotBlendMode = slot.data.blendMode;
|
||||||
|
if (slotBlendMode != blendMode) {
|
||||||
|
blendMode = slotBlendMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.drawTriangles(texture, vertices, triangles);
|
||||||
|
|
||||||
|
// ctx.drawImage(texture, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
drawTriangles(texture: HTMLImageElement, vertices: ArrayLike<number>, triangles: ArrayLike<number>) {
|
||||||
|
let ctx = this._ctx;
|
||||||
|
|
||||||
|
for (var i = 0; i < triangles.length; i+=3) {
|
||||||
|
let t1 = triangles[i] * 8, t2 = triangles[i+1] * 8, t3 = triangles[i+2] * 8;
|
||||||
|
|
||||||
|
let x0 = vertices[t1], y0 = vertices[t1 + 1], u0 = vertices[t1 + 6], v0 = vertices[t1 + 7];
|
||||||
|
let x1 = vertices[t2], y1 = vertices[t2 + 1], u1 = vertices[t2 + 6], v1 = vertices[t2 + 7];
|
||||||
|
let x2 = vertices[t3], y2 = vertices[t3 + 1], u2 = vertices[t3 + 6], v2 = vertices[t3 + 7];
|
||||||
|
|
||||||
|
this.drawTriangle(texture, x0, y0, u0, v0, x1, y1, u1, v1, x2, y2, u2, v2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
drawTriangle(img: HTMLImageElement, x0: number, y0: number, u0: number, v0: number,
|
||||||
|
x1: number, y1: number, u1: number, v1: number,
|
||||||
|
x2: number, y2: number, u2: number, v2: number) {
|
||||||
|
let ctx = this._ctx;
|
||||||
|
|
||||||
|
u0 *= img.width;
|
||||||
|
v0 *= img.height;
|
||||||
|
u1 *= img.width;
|
||||||
|
v1 *= img.height;
|
||||||
|
u2 *= img.width;
|
||||||
|
v2 *= img.height;
|
||||||
|
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(x0, y0);
|
||||||
|
ctx.lineTo(x1, y1);
|
||||||
|
ctx.lineTo(x2, y2);
|
||||||
|
ctx.closePath();
|
||||||
|
|
||||||
|
x1 -= x0;
|
||||||
|
y1 -= y0;
|
||||||
|
x2 -= x0;
|
||||||
|
y2 -= y0;
|
||||||
|
|
||||||
|
u1 -= u0;
|
||||||
|
v1 -= v0;
|
||||||
|
u2 -= u0;
|
||||||
|
v2 -= v0;
|
||||||
|
|
||||||
|
var det = 1 / (u1*v2 - u2*v1),
|
||||||
|
|
||||||
|
// linear transformation
|
||||||
|
a = (v2*x1 - v1*x2) * det,
|
||||||
|
b = (v2*y1 - v1*y2) * det,
|
||||||
|
c = (u1*x2 - u2*x1) * det,
|
||||||
|
d = (u1*y2 - u2*y1) * det,
|
||||||
|
|
||||||
|
// translation
|
||||||
|
e = x0 - a*u0 - c*v0,
|
||||||
|
f = y0 - b*u0 - d*v0;
|
||||||
|
|
||||||
|
ctx.save();
|
||||||
|
ctx.transform(a, b, c, d, e, f);
|
||||||
|
ctx.clip();
|
||||||
|
ctx.drawImage(img, 0, 0);
|
||||||
|
ctx.restore();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -34,11 +34,11 @@ module spine {
|
|||||||
pages = new Array<TextureAtlasPage>();
|
pages = new Array<TextureAtlasPage>();
|
||||||
regions = new Array<TextureAtlasRegion>();
|
regions = new Array<TextureAtlasRegion>();
|
||||||
|
|
||||||
constructor (atlasText: string, textureLoader: (path: string, minFilter: TextureFilter, magFilter: TextureFilter, uWrap: TextureWrap, vWrap: TextureWrap) => any) {
|
constructor (atlasText: string, textureLoader: (path: string) => any) {
|
||||||
this.load(atlasText, textureLoader);
|
this.load(atlasText, textureLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
private load (atlasText: string, textureLoader: (path: string, minFilter: TextureFilter, magFilter: TextureFilter, uWrap: TextureWrap, vWrap: TextureWrap) => any) {
|
private load (atlasText: string, textureLoader: (path: string) => any) {
|
||||||
if (textureLoader == null)
|
if (textureLoader == null)
|
||||||
throw new Error("textureLoader cannot be null.");
|
throw new Error("textureLoader cannot be null.");
|
||||||
|
|
||||||
@ -77,7 +77,9 @@ module spine {
|
|||||||
else if (direction == "xy")
|
else if (direction == "xy")
|
||||||
page.uWrap = page.vWrap = TextureWrap.Repeat;
|
page.uWrap = page.vWrap = TextureWrap.Repeat;
|
||||||
|
|
||||||
page.texture = textureLoader(line, page.minFilter, page.magFilter, page.uWrap, page.vWrap);
|
page.texture = textureLoader(line);
|
||||||
|
page.texture.setFilters(page.minFilter, page.magFilter);
|
||||||
|
page.texture.setWraps(page.uWrap, page.vWrap);
|
||||||
page.width = page.texture.getImage().width;
|
page.width = page.texture.getImage().width;
|
||||||
page.height = page.texture.getImage().height;
|
page.height = page.texture.getImage().height;
|
||||||
this.pages.push(page);
|
this.pages.push(page);
|
||||||
|
|||||||
@ -29,7 +29,7 @@
|
|||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
module spine.webgl {
|
module spine {
|
||||||
export class TextureAtlasAttachmentLoader implements AttachmentLoader {
|
export class TextureAtlasAttachmentLoader implements AttachmentLoader {
|
||||||
atlas: TextureAtlas;
|
atlas: TextureAtlas;
|
||||||
|
|
||||||
@ -2,7 +2,7 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"module": "none",
|
"module": "none",
|
||||||
"noImplicitAny": true,
|
"noImplicitAny": true,
|
||||||
"removeComments": false,
|
"removeComments": true,
|
||||||
"preserveConstEnums": true,
|
"preserveConstEnums": true,
|
||||||
"outFile": "build/spine-canvas.js",
|
"outFile": "build/spine-canvas.js",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"module": "none",
|
"module": "none",
|
||||||
"noImplicitAny": true,
|
"noImplicitAny": true,
|
||||||
"removeComments": false,
|
"removeComments": true,
|
||||||
"preserveConstEnums": true,
|
"preserveConstEnums": true,
|
||||||
"outFile": "build/spine-core.js",
|
"outFile": "build/spine-core.js",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"module": "none",
|
"module": "none",
|
||||||
"noImplicitAny": true,
|
"noImplicitAny": true,
|
||||||
"removeComments": false,
|
"removeComments": true,
|
||||||
"preserveConstEnums": true,
|
"preserveConstEnums": true,
|
||||||
"outFile": "build/spine-all.js",
|
"outFile": "build/spine-all.js",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"module": "none",
|
"module": "none",
|
||||||
"noImplicitAny": true,
|
"noImplicitAny": true,
|
||||||
"removeComments": false,
|
"removeComments": true,
|
||||||
"preserveConstEnums": true,
|
"preserveConstEnums": true,
|
||||||
"outFile": "build/spine-webgl.js",
|
"outFile": "build/spine-webgl.js",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"module": "none",
|
"module": "none",
|
||||||
"noImplicitAny": true,
|
"noImplicitAny": true,
|
||||||
"removeComments": false,
|
"removeComments": true,
|
||||||
"preserveConstEnums": true,
|
"preserveConstEnums": true,
|
||||||
"outFile": "build/spine-widget.js",
|
"outFile": "build/spine-widget.js",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
|
|||||||
@ -80,15 +80,12 @@ function loadSkeleton (name, scale, initialAnimation, positionX, positionY, prem
|
|||||||
|
|
||||||
// Load the texture atlas using name.atlas and name.png from the AssetManager.
|
// Load the texture atlas using name.atlas and name.png from the AssetManager.
|
||||||
// The function passed to TextureAtlas is used to resolve relative paths.
|
// The function passed to TextureAtlas is used to resolve relative paths.
|
||||||
atlas = new spine.TextureAtlas(assetManager.get("assets/" + name + ".atlas"), function(path, minFilter, magFilter, uWrap, vWrap) {
|
atlas = new spine.TextureAtlas(assetManager.get("assets/" + name + ".atlas"), function(path) {
|
||||||
var texture = assetManager.get("assets/" + path);
|
return assetManager.get("assets/" + path);
|
||||||
texture.setFilters(minFilter, magFilter);
|
|
||||||
texture.setWraps(uWrap, vWrap);
|
|
||||||
return texture;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create a TextureAtlasAttachmentLoader, which is specific to the WebGL backend.
|
// Create a TextureAtlasAttachmentLoader that resolves region, mesh, boundingbox and path attachments
|
||||||
atlasLoader = new spine.webgl.TextureAtlasAttachmentLoader(atlas);
|
atlasLoader = new spine.TextureAtlasAttachmentLoader(atlas);
|
||||||
|
|
||||||
// Create a SkeletonJson instance for parsing the .json file.
|
// Create a SkeletonJson instance for parsing the .json file.
|
||||||
var skeletonJson = new spine.SkeletonJson(atlasLoader);
|
var skeletonJson = new spine.SkeletonJson(atlasLoader);
|
||||||
|
|||||||
@ -62,7 +62,7 @@ module spine.webgl {
|
|||||||
vertices = mesh.updateWorldVertices(slot, premultipliedAlpha);
|
vertices = mesh.updateWorldVertices(slot, premultipliedAlpha);
|
||||||
triangles = mesh.triangles;
|
triangles = mesh.triangles;
|
||||||
texture = <GLTexture>(<TextureAtlasRegion>mesh.region.renderObject).texture;
|
texture = <GLTexture>(<TextureAtlasRegion>mesh.region.renderObject).texture;
|
||||||
}
|
} else continue;
|
||||||
|
|
||||||
if (texture != null) {
|
if (texture != null) {
|
||||||
let slotBlendMode = slot.data.blendMode;
|
let slotBlendMode = slot.data.blendMode;
|
||||||
|
|||||||
@ -37,7 +37,7 @@ module spine {
|
|||||||
canvas: HTMLCanvasElement;
|
canvas: HTMLCanvasElement;
|
||||||
|
|
||||||
private _config: SpineWidgetConfig;
|
private _config: SpineWidgetConfig;
|
||||||
private _assetManager: spine.webgl.AssetManager;
|
private _assetManager: spine.AssetManager;
|
||||||
private _shader: spine.webgl.Shader;
|
private _shader: spine.webgl.Shader;
|
||||||
private _batcher: spine.webgl.PolygonBatcher;
|
private _batcher: spine.webgl.PolygonBatcher;
|
||||||
private _mvp = new spine.webgl.Matrix4();
|
private _mvp = new spine.webgl.Matrix4();
|
||||||
@ -69,7 +69,9 @@ module spine {
|
|||||||
this._mvp.ortho2d(0, 0, 639, 479);
|
this._mvp.ortho2d(0, 0, 639, 479);
|
||||||
this._skeletonRenderer = new spine.webgl.SkeletonRenderer(gl);
|
this._skeletonRenderer = new spine.webgl.SkeletonRenderer(gl);
|
||||||
|
|
||||||
let assets = this._assetManager = new spine.webgl.AssetManager(gl);
|
let assets = this._assetManager = new spine.AssetManager((image: HTMLImageElement) => {
|
||||||
|
return new spine.webgl.GLTexture(gl, image);
|
||||||
|
});
|
||||||
assets.loadText(config.atlas);
|
assets.loadText(config.atlas);
|
||||||
assets.loadText(config.json);
|
assets.loadText(config.json);
|
||||||
assets.loadTexture(config.atlas.replace(".atlas", ".png"));
|
assets.loadTexture(config.atlas.replace(".atlas", ".png"));
|
||||||
@ -112,8 +114,11 @@ module spine {
|
|||||||
else throw new Error("Failed to load assets: " + JSON.stringify(assetManager.errors));
|
else throw new Error("Failed to load assets: " + JSON.stringify(assetManager.errors));
|
||||||
}
|
}
|
||||||
|
|
||||||
let atlas = new spine.webgl.TextureAtlas(this._assetManager.get(this._config.atlas) as string, (path) => {
|
let atlas = new spine.TextureAtlas(this._assetManager.get(this._config.atlas) as string, (path: string, minFilter: TextureFilter, magFilter: TextureFilter, uWrap: TextureWrap, vWrap: TextureWrap) => {
|
||||||
return assetManager.get(imagesPath + path) as spine.webgl.Texture;
|
let texture = assetManager.get(imagesPath + path) as spine.webgl.GLTexture;
|
||||||
|
texture.setFilters(minFilter, magFilter);
|
||||||
|
texture.setWraps(uWrap, vWrap);
|
||||||
|
return texture;
|
||||||
});
|
});
|
||||||
|
|
||||||
let atlasLoader = new spine.webgl.TextureAtlasAttachmentLoader(atlas);
|
let atlasLoader = new spine.webgl.TextureAtlasAttachmentLoader(atlas);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user