mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[ts] More refactoring for greater code reuse
This commit is contained in:
parent
e72c9030eb
commit
847bd2a76c
64
spine-ts/build/spine-webgl.d.ts
vendored
64
spine-ts/build/spine-webgl.d.ts
vendored
@ -384,7 +384,7 @@ declare module spine {
|
|||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
declare module spine.webgl {
|
declare module spine {
|
||||||
class AssetManager implements Disposable {
|
class AssetManager implements Disposable {
|
||||||
private _textureLoader;
|
private _textureLoader;
|
||||||
private _assets;
|
private _assets;
|
||||||
@ -1282,6 +1282,20 @@ declare module spine {
|
|||||||
ClampToEdge = 33071,
|
ClampToEdge = 33071,
|
||||||
Repeat = 10497,
|
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
|
* Spine Runtimes Software License
|
||||||
@ -1313,7 +1327,7 @@ declare module spine {
|
|||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
declare module spine.webgl {
|
declare module spine {
|
||||||
class TextureAtlas implements Disposable {
|
class TextureAtlas implements Disposable {
|
||||||
pages: TextureAtlasPage[];
|
pages: TextureAtlasPage[];
|
||||||
regions: TextureAtlasRegion[];
|
regions: TextureAtlasRegion[];
|
||||||
@ -1905,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
|
||||||
|
|||||||
@ -1147,103 +1147,100 @@ var spine;
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
var spine;
|
var spine;
|
||||||
(function (spine) {
|
(function (spine) {
|
||||||
var webgl;
|
var AssetManager = (function () {
|
||||||
(function (webgl) {
|
function AssetManager(textureLoader) {
|
||||||
var AssetManager = (function () {
|
this._assets = {};
|
||||||
function AssetManager(textureLoader) {
|
this._errors = {};
|
||||||
this._assets = {};
|
this._toLoad = 0;
|
||||||
this._errors = {};
|
this._loaded = 0;
|
||||||
this._toLoad = 0;
|
this._textureLoader = textureLoader;
|
||||||
this._loaded = 0;
|
}
|
||||||
this._textureLoader = textureLoader;
|
AssetManager.prototype.loadText = function (path, success, error) {
|
||||||
}
|
var _this = this;
|
||||||
AssetManager.prototype.loadText = function (path, success, error) {
|
if (success === void 0) { success = null; }
|
||||||
var _this = this;
|
if (error === void 0) { error = null; }
|
||||||
if (success === void 0) { success = null; }
|
this._toLoad++;
|
||||||
if (error === void 0) { error = null; }
|
var request = new XMLHttpRequest();
|
||||||
this._toLoad++;
|
request.onreadystatechange = function () {
|
||||||
var request = new XMLHttpRequest();
|
if (request.readyState == XMLHttpRequest.DONE) {
|
||||||
request.onreadystatechange = function () {
|
if (request.status >= 200 && request.status < 300) {
|
||||||
if (request.readyState == XMLHttpRequest.DONE) {
|
if (success)
|
||||||
if (request.status >= 200 && request.status < 300) {
|
success(path, request.responseText);
|
||||||
if (success)
|
_this._assets[path] = request.responseText;
|
||||||
success(path, request.responseText);
|
}
|
||||||
_this._assets[path] = request.responseText;
|
else {
|
||||||
}
|
if (error)
|
||||||
else {
|
error(path, "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText);
|
||||||
if (error)
|
_this._errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText;
|
||||||
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._toLoad--;
|
||||||
_this._loaded++;
|
_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) {
|
request.open("GET", path, true);
|
||||||
return this._assets[path];
|
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++;
|
||||||
};
|
};
|
||||||
AssetManager.prototype.remove = function (path) {
|
img.onerror = function (ev) {
|
||||||
var asset = this._assets[path];
|
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)
|
if (asset.dispose)
|
||||||
asset.dispose();
|
asset.dispose();
|
||||||
this._assets[path] = null;
|
}
|
||||||
};
|
this._assets = {};
|
||||||
AssetManager.prototype.removeAll = function () {
|
};
|
||||||
for (var key in this._assets) {
|
AssetManager.prototype.isLoadingComplete = function () {
|
||||||
var asset = this._assets[key];
|
return this._toLoad == 0;
|
||||||
if (asset.dispose)
|
};
|
||||||
asset.dispose();
|
AssetManager.prototype.toLoad = function () {
|
||||||
}
|
return this._toLoad;
|
||||||
this._assets = {};
|
};
|
||||||
};
|
AssetManager.prototype.loaded = function () {
|
||||||
AssetManager.prototype.isLoadingComplete = function () {
|
return this._loaded;
|
||||||
return this._toLoad == 0;
|
};
|
||||||
};
|
AssetManager.prototype.dispose = function () {
|
||||||
AssetManager.prototype.toLoad = function () {
|
this.removeAll();
|
||||||
return this._toLoad;
|
};
|
||||||
};
|
AssetManager.prototype.hasErrors = function () {
|
||||||
AssetManager.prototype.loaded = function () {
|
return Object.keys(this._errors).length > 0;
|
||||||
return this._loaded;
|
};
|
||||||
};
|
AssetManager.prototype.errors = function () {
|
||||||
AssetManager.prototype.dispose = function () {
|
return this._errors;
|
||||||
this.removeAll();
|
};
|
||||||
};
|
return AssetManager;
|
||||||
AssetManager.prototype.hasErrors = function () {
|
}());
|
||||||
return Object.keys(this._errors).length > 0;
|
spine.AssetManager = AssetManager;
|
||||||
};
|
|
||||||
AssetManager.prototype.errors = function () {
|
|
||||||
return this._errors;
|
|
||||||
};
|
|
||||||
return AssetManager;
|
|
||||||
}());
|
|
||||||
webgl.AssetManager = AssetManager;
|
|
||||||
})(webgl = spine.webgl || (spine.webgl = {}));
|
|
||||||
})(spine || (spine = {}));
|
})(spine || (spine = {}));
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Spine Runtimes Software License
|
* Spine Runtimes Software License
|
||||||
@ -4175,6 +4172,23 @@ var spine;
|
|||||||
TextureWrap[TextureWrap["Repeat"] = 10497] = "Repeat"; // WebGLRenderingContext.REPEAT
|
TextureWrap[TextureWrap["Repeat"] = 10497] = "Repeat"; // WebGLRenderingContext.REPEAT
|
||||||
})(spine.TextureWrap || (spine.TextureWrap = {}));
|
})(spine.TextureWrap || (spine.TextureWrap = {}));
|
||||||
var 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 || (spine = {}));
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Spine Runtimes Software License
|
* Spine Runtimes Software License
|
||||||
@ -4208,162 +4222,159 @@ var spine;
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
var spine;
|
var spine;
|
||||||
(function (spine) {
|
(function (spine) {
|
||||||
var webgl;
|
var TextureAtlas = (function () {
|
||||||
(function (webgl) {
|
function TextureAtlas(atlasText, textureLoader) {
|
||||||
var TextureAtlas = (function () {
|
this.pages = new Array();
|
||||||
function TextureAtlas(atlasText, textureLoader) {
|
this.regions = new Array();
|
||||||
this.pages = new Array();
|
this.load(atlasText, textureLoader);
|
||||||
this.regions = new Array();
|
}
|
||||||
this.load(atlasText, textureLoader);
|
TextureAtlas.prototype.load = function (atlasText, textureLoader) {
|
||||||
}
|
if (textureLoader == null)
|
||||||
TextureAtlas.prototype.load = function (atlasText, textureLoader) {
|
throw new Error("textureLoader cannot be null.");
|
||||||
if (textureLoader == null)
|
var reader = new TextureAtlasReader(atlasText);
|
||||||
throw new Error("textureLoader cannot be null.");
|
var tuple = new Array(4);
|
||||||
var reader = new TextureAtlasReader(atlasText);
|
var page = null;
|
||||||
var tuple = new Array(4);
|
while (true) {
|
||||||
var page = null;
|
var line = reader.readLine();
|
||||||
while (true) {
|
if (line == null)
|
||||||
var line = reader.readLine();
|
break;
|
||||||
if (line == null)
|
line = line.trim();
|
||||||
break;
|
if (line.length == 0)
|
||||||
line = line.trim();
|
page = null;
|
||||||
if (line.length == 0)
|
else if (!page) {
|
||||||
page = null;
|
page = new TextureAtlasPage();
|
||||||
else if (!page) {
|
page.name = line;
|
||||||
page = new TextureAtlasPage();
|
if (reader.readTuple(tuple) == 2) {
|
||||||
page.name = line;
|
page.width = parseInt(tuple[0]);
|
||||||
if (reader.readTuple(tuple) == 2) {
|
page.height = parseInt(tuple[1]);
|
||||||
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);
|
reader.readTuple(tuple);
|
||||||
page.minFilter = spine.Texture.filterFromString(tuple[0]);
|
}
|
||||||
page.magFilter = spine.Texture.filterFromString(tuple[1]);
|
// page.format = Format[tuple[0]]; we don't need format in WebGL
|
||||||
var direction = reader.readValue();
|
reader.readTuple(tuple);
|
||||||
page.uWrap = spine.TextureWrap.ClampToEdge;
|
page.minFilter = spine.Texture.filterFromString(tuple[0]);
|
||||||
page.vWrap = spine.TextureWrap.ClampToEdge;
|
page.magFilter = spine.Texture.filterFromString(tuple[1]);
|
||||||
if (direction == "x")
|
var direction = reader.readValue();
|
||||||
page.uWrap = spine.TextureWrap.Repeat;
|
page.uWrap = spine.TextureWrap.ClampToEdge;
|
||||||
else if (direction == "y")
|
page.vWrap = spine.TextureWrap.ClampToEdge;
|
||||||
page.vWrap = spine.TextureWrap.Repeat;
|
if (direction == "x")
|
||||||
else if (direction == "xy")
|
page.uWrap = spine.TextureWrap.Repeat;
|
||||||
page.uWrap = page.vWrap = spine.TextureWrap.Repeat;
|
else if (direction == "y")
|
||||||
page.texture = textureLoader(line, page.minFilter, page.magFilter, page.uWrap, page.vWrap);
|
page.vWrap = spine.TextureWrap.Repeat;
|
||||||
page.width = page.texture.getImage().width;
|
else if (direction == "xy")
|
||||||
page.height = page.texture.getImage().height;
|
page.uWrap = page.vWrap = spine.TextureWrap.Repeat;
|
||||||
this.pages.push(page);
|
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 {
|
else {
|
||||||
var region = new TextureAtlasRegion();
|
region.u2 = (x + width) / page.width;
|
||||||
region.name = line;
|
region.v2 = (y + height) / page.height;
|
||||||
region.page = page;
|
}
|
||||||
region.rotate = reader.readValue() == "true";
|
region.x = x;
|
||||||
reader.readTuple(tuple);
|
region.y = y;
|
||||||
var x = parseInt(tuple[0]);
|
region.width = Math.abs(width);
|
||||||
var y = parseInt(tuple[1]);
|
region.height = Math.abs(height);
|
||||||
reader.readTuple(tuple);
|
if (reader.readTuple(tuple) == 4) {
|
||||||
var width = parseInt(tuple[0]);
|
// region.splits = new Vector.<int>(parseInt(tuple[0]), parseInt(tuple[1]), parseInt(tuple[2]), parseInt(tuple[3]));
|
||||||
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) {
|
if (reader.readTuple(tuple) == 4) {
|
||||||
// region.splits = new Vector.<int>(parseInt(tuple[0]), parseInt(tuple[1]), parseInt(tuple[2]), parseInt(tuple[3]));
|
//region.pads = Vector.<int>(parseInt(tuple[0]), parseInt(tuple[1]), parseInt(tuple[2]), parseInt(tuple[3]));
|
||||||
if (reader.readTuple(tuple) == 4) {
|
reader.readTuple(tuple);
|
||||||
//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);
|
|
||||||
}
|
}
|
||||||
|
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++) {
|
TextureAtlas.prototype.findRegion = function (name) {
|
||||||
if (this.regions[i].name == name) {
|
for (var i = 0; i < this.regions.length; i++) {
|
||||||
return this.regions[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 null;
|
||||||
};
|
return this.lines[this.index++];
|
||||||
TextureAtlas.prototype.dispose = function () {
|
};
|
||||||
for (var i = 0; i < this.pages.length; i++) {
|
TextureAtlasReader.prototype.readValue = function () {
|
||||||
this.pages[i].texture.dispose();
|
var line = this.readLine();
|
||||||
}
|
var colon = line.indexOf(":");
|
||||||
};
|
if (colon == -1)
|
||||||
return TextureAtlas;
|
throw new Error("Invalid line: " + line);
|
||||||
}());
|
return line.substring(colon + 1).trim();
|
||||||
webgl.TextureAtlas = TextureAtlas;
|
};
|
||||||
var TextureAtlasReader = (function () {
|
TextureAtlasReader.prototype.readTuple = function (tuple) {
|
||||||
function TextureAtlasReader(text) {
|
var line = this.readLine();
|
||||||
this.index = 0;
|
var colon = line.indexOf(":");
|
||||||
this.lines = text.split(/\r\n|\r|\n/);
|
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;
|
||||||
}
|
}
|
||||||
TextureAtlasReader.prototype.readLine = function () {
|
tuple[i] = line.substring(lastMatch).trim();
|
||||||
if (this.index >= this.lines.length)
|
return i + 1;
|
||||||
return null;
|
};
|
||||||
return this.lines[this.index++];
|
return TextureAtlasReader;
|
||||||
};
|
}());
|
||||||
TextureAtlasReader.prototype.readValue = function () {
|
var TextureAtlasPage = (function () {
|
||||||
var line = this.readLine();
|
function TextureAtlasPage() {
|
||||||
var colon = line.indexOf(":");
|
}
|
||||||
if (colon == -1)
|
return TextureAtlasPage;
|
||||||
throw new Error("Invalid line: " + line);
|
}());
|
||||||
return line.substring(colon + 1).trim();
|
spine.TextureAtlasPage = TextureAtlasPage;
|
||||||
};
|
var TextureAtlasRegion = (function (_super) {
|
||||||
TextureAtlasReader.prototype.readTuple = function (tuple) {
|
__extends(TextureAtlasRegion, _super);
|
||||||
var line = this.readLine();
|
function TextureAtlasRegion() {
|
||||||
var colon = line.indexOf(":");
|
_super.apply(this, arguments);
|
||||||
if (colon == -1)
|
}
|
||||||
throw new Error("Invalid line: " + line);
|
return TextureAtlasRegion;
|
||||||
var i = 0, lastMatch = colon + 1;
|
}(spine.TextureRegion));
|
||||||
for (; i < 3; i++) {
|
spine.TextureAtlasRegion = TextureAtlasRegion;
|
||||||
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 || (spine = {}));
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Spine Runtimes Software License
|
* Spine Runtimes Software License
|
||||||
@ -5429,56 +5440,6 @@ 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) {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
195
spine-ts/canvas/example/assets/spineboy.atlas
Normal file
195
spine-ts/canvas/example/assets/spineboy.atlas
Normal file
@ -0,0 +1,195 @@
|
|||||||
|
|
||||||
|
spineboy.png
|
||||||
|
size: 1024,1024
|
||||||
|
format: RGBA8888
|
||||||
|
filter: Linear,Linear
|
||||||
|
repeat: none
|
||||||
|
eye_indifferent
|
||||||
|
rotate: false
|
||||||
|
xy: 550, 694
|
||||||
|
size: 93, 89
|
||||||
|
orig: 93, 89
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
eye_surprised
|
||||||
|
rotate: false
|
||||||
|
xy: 834, 856
|
||||||
|
size: 93, 89
|
||||||
|
orig: 93, 89
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
front_bracer
|
||||||
|
rotate: false
|
||||||
|
xy: 678, 774
|
||||||
|
size: 58, 80
|
||||||
|
orig: 58, 80
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
front_fist_closed
|
||||||
|
rotate: true
|
||||||
|
xy: 466, 593
|
||||||
|
size: 75, 82
|
||||||
|
orig: 75, 82
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
front_fist_open
|
||||||
|
rotate: false
|
||||||
|
xy: 550, 605
|
||||||
|
size: 86, 87
|
||||||
|
orig: 86, 87
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
front_foot
|
||||||
|
rotate: false
|
||||||
|
xy: 550, 785
|
||||||
|
size: 126, 69
|
||||||
|
orig: 126, 69
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
front_foot_bend1
|
||||||
|
rotate: true
|
||||||
|
xy: 375, 492
|
||||||
|
size: 128, 70
|
||||||
|
orig: 128, 70
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
front_foot_bend2
|
||||||
|
rotate: true
|
||||||
|
xy: 275, 330
|
||||||
|
size: 108, 93
|
||||||
|
orig: 108, 93
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
front_shin
|
||||||
|
rotate: false
|
||||||
|
xy: 466, 670
|
||||||
|
size: 82, 184
|
||||||
|
orig: 82, 184
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
front_thigh
|
||||||
|
rotate: false
|
||||||
|
xy: 214, 208
|
||||||
|
size: 48, 112
|
||||||
|
orig: 48, 112
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
front_upper_arm
|
||||||
|
rotate: false
|
||||||
|
xy: 214, 109
|
||||||
|
size: 54, 97
|
||||||
|
orig: 54, 97
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
goggles
|
||||||
|
rotate: false
|
||||||
|
xy: 466, 856
|
||||||
|
size: 261, 166
|
||||||
|
orig: 261, 166
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
gun
|
||||||
|
rotate: false
|
||||||
|
xy: 2, 117
|
||||||
|
size: 210, 203
|
||||||
|
orig: 210, 203
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
head
|
||||||
|
rotate: false
|
||||||
|
xy: 2, 322
|
||||||
|
size: 271, 298
|
||||||
|
orig: 271, 298
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
mouth_grind
|
||||||
|
rotate: false
|
||||||
|
xy: 929, 896
|
||||||
|
size: 93, 59
|
||||||
|
orig: 93, 59
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
mouth_oooo
|
||||||
|
rotate: false
|
||||||
|
xy: 929, 835
|
||||||
|
size: 93, 59
|
||||||
|
orig: 93, 59
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
mouth_smile
|
||||||
|
rotate: false
|
||||||
|
xy: 447, 532
|
||||||
|
size: 93, 59
|
||||||
|
orig: 93, 59
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
muzzle
|
||||||
|
rotate: false
|
||||||
|
xy: 2, 622
|
||||||
|
size: 462, 400
|
||||||
|
orig: 462, 400
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
neck
|
||||||
|
rotate: false
|
||||||
|
xy: 796, 819
|
||||||
|
size: 36, 41
|
||||||
|
orig: 36, 41
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
rear_bracer
|
||||||
|
rotate: false
|
||||||
|
xy: 738, 788
|
||||||
|
size: 56, 72
|
||||||
|
orig: 56, 72
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
rear_foot
|
||||||
|
rotate: true
|
||||||
|
xy: 2, 2
|
||||||
|
size: 113, 60
|
||||||
|
orig: 113, 60
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
rear_foot_bend1
|
||||||
|
rotate: false
|
||||||
|
xy: 64, 49
|
||||||
|
size: 117, 66
|
||||||
|
orig: 117, 66
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
rear_foot_bend2
|
||||||
|
rotate: false
|
||||||
|
xy: 729, 862
|
||||||
|
size: 103, 83
|
||||||
|
orig: 103, 83
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
rear_shin
|
||||||
|
rotate: true
|
||||||
|
xy: 729, 947
|
||||||
|
size: 75, 178
|
||||||
|
orig: 75, 178
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
rear_thigh
|
||||||
|
rotate: true
|
||||||
|
xy: 909, 957
|
||||||
|
size: 65, 104
|
||||||
|
orig: 65, 104
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
rear_upper_arm
|
||||||
|
rotate: true
|
||||||
|
xy: 447, 483
|
||||||
|
size: 47, 87
|
||||||
|
orig: 47, 87
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
|
torso
|
||||||
|
rotate: false
|
||||||
|
xy: 275, 440
|
||||||
|
size: 98, 180
|
||||||
|
orig: 98, 180
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
2412
spine-ts/canvas/example/assets/spineboy.json
Normal file
2412
spine-ts/canvas/example/assets/spineboy.json
Normal file
File diff suppressed because it is too large
Load Diff
BIN
spine-ts/canvas/example/assets/spineboy.png
Normal file
BIN
spine-ts/canvas/example/assets/spineboy.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 593 KiB |
@ -8,5 +8,20 @@
|
|||||||
</body>
|
</body>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
var lastFrameTime = Date.now() / 1000;
|
||||||
|
var canvas;
|
||||||
|
var assetManager;
|
||||||
|
var skeletonRenderer;
|
||||||
|
|
||||||
|
function init () {
|
||||||
|
assetManager = new spine.AssetManager(function(image) {
|
||||||
|
return CanvasTexture(image);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
init();
|
||||||
|
}());
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</html>
|
</html>
|
||||||
11
spine-ts/canvas/src/CanvasTexture.ts
Normal file
11
spine-ts/canvas/src/CanvasTexture.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
module spine.canvas {
|
||||||
|
export class CanvasTexture extends Texture {
|
||||||
|
constructor (image: HTMLImageElement) {
|
||||||
|
super(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
setFilters (minFilter: TextureFilter, magFilter: TextureFilter) { }
|
||||||
|
setWraps (uWrap: TextureWrap, vWrap: TextureWrap) { }
|
||||||
|
dispose () { }
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -29,7 +29,7 @@
|
|||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
module spine.webgl {
|
module spine {
|
||||||
export class AssetManager implements Disposable {
|
export class AssetManager implements Disposable {
|
||||||
private _textureLoader: (image: HTMLImageElement) => any;
|
private _textureLoader: (image: HTMLImageElement) => any;
|
||||||
private _assets: Map<any> = {};
|
private _assets: Map<any> = {};
|
||||||
|
|||||||
@ -53,4 +53,14 @@ module spine {
|
|||||||
ClampToEdge = 33071, // WebGLRenderingContext.CLAMP_TO_EDGE
|
ClampToEdge = 33071, // WebGLRenderingContext.CLAMP_TO_EDGE
|
||||||
Repeat = 10497 // WebGLRenderingContext.REPEAT
|
Repeat = 10497 // WebGLRenderingContext.REPEAT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class TextureRegion {
|
||||||
|
renderObject: any;
|
||||||
|
u = 0; v = 0;
|
||||||
|
u2 = 0; v2 = 0;
|
||||||
|
width = 0; height = 0;
|
||||||
|
rotate = false;
|
||||||
|
offsetX = 0; offsetY = 0;
|
||||||
|
originalWidth = 0; originalHeight = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -29,7 +29,7 @@
|
|||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
module spine.webgl {
|
module spine {
|
||||||
export class TextureAtlas implements Disposable {
|
export class TextureAtlas implements Disposable {
|
||||||
pages = new Array<TextureAtlasPage>();
|
pages = new Array<TextureAtlasPage>();
|
||||||
regions = new Array<TextureAtlasRegion>();
|
regions = new Array<TextureAtlasRegion>();
|
||||||
|
|||||||
@ -1,42 +0,0 @@
|
|||||||
/******************************************************************************
|
|
||||||
* Spine Runtimes Software License
|
|
||||||
* Version 2.5
|
|
||||||
*
|
|
||||||
* Copyright (c) 2013-2016, Esoteric Software
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* You are granted a perpetual, non-exclusive, non-sublicensable, and
|
|
||||||
* non-transferable license to use, install, execute, and perform the Spine
|
|
||||||
* Runtimes software and derivative works solely for personal or internal
|
|
||||||
* use. Without the written permission of Esoteric Software (see Section 2 of
|
|
||||||
* the Spine Software License Agreement), you may not (a) modify, translate,
|
|
||||||
* adapt, or develop new applications using the Spine Runtimes or otherwise
|
|
||||||
* create derivative works or improvements of the Spine Runtimes or (b) remove,
|
|
||||||
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
|
|
||||||
* or other intellectual property or proprietary rights notices on or in the
|
|
||||||
* Software, including any copy thereof. Redistributions in binary or source
|
|
||||||
* form must include this license and terms.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
|
||||||
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
|
|
||||||
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
|
||||||
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
module spine {
|
|
||||||
export class TextureRegion {
|
|
||||||
renderObject: any;
|
|
||||||
u = 0; v = 0;
|
|
||||||
u2 = 0; v2 = 0;
|
|
||||||
width = 0; height = 0;
|
|
||||||
rotate = false;
|
|
||||||
offsetX = 0; offsetY = 0;
|
|
||||||
originalWidth = 0; originalHeight = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -36,7 +36,9 @@ function init () {
|
|||||||
batcher = new spine.webgl.PolygonBatcher(gl);
|
batcher = new spine.webgl.PolygonBatcher(gl);
|
||||||
mvp.ortho2d(0, 0, 639, 479);
|
mvp.ortho2d(0, 0, 639, 479);
|
||||||
skeletonRenderer = new spine.webgl.SkeletonRenderer(gl);
|
skeletonRenderer = new spine.webgl.SkeletonRenderer(gl);
|
||||||
assetManager = new spine.webgl.AssetManager(gl);
|
assetManager = new spine.AssetManager(function(image) {
|
||||||
|
return new spine.webgl.GLTexture(gl, image);
|
||||||
|
});
|
||||||
|
|
||||||
// Tell AssetManager to load the resources for each model, including the exported .json file, the .atlas file and the .png
|
// Tell AssetManager to load the resources for each model, including the exported .json file, the .atlas file and the .png
|
||||||
// file for the atlas. We then wait until all resources are loaded in the load() method.
|
// file for the atlas. We then wait until all resources are loaded in the load() method.
|
||||||
@ -78,10 +80,11 @@ 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.webgl.TextureAtlas(assetManager.get("assets/" + name + ".atlas"), function(path, minFilter, magFilter, uWrap, vWrap) {
|
atlas = new spine.TextureAtlas(assetManager.get("assets/" + name + ".atlas"), function(path, minFilter, magFilter, uWrap, vWrap) {
|
||||||
var texture = assetManager.get("assets/" + path);
|
var texture = assetManager.get("assets/" + path);
|
||||||
texture.setFilters(minFilter, magFilter);
|
texture.setFilters(minFilter, magFilter);
|
||||||
texture.setWraps(uWrap, vWrap);
|
texture.setWraps(uWrap, vWrap);
|
||||||
|
return texture;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create a TextureAtlasAttachmentLoader, which is specific to the WebGL backend.
|
// Create a TextureAtlasAttachmentLoader, which is specific to the WebGL backend.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user