[ts] More refactoring for greater code reuse

This commit is contained in:
badlogic 2016-08-16 10:41:28 +02:00
parent e72c9030eb
commit 847bd2a76c
14 changed files with 2914 additions and 381 deletions

View File

@ -384,7 +384,7 @@ declare module spine {
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
declare module spine.webgl {
declare module spine {
class AssetManager implements Disposable {
private _textureLoader;
private _assets;
@ -1282,6 +1282,20 @@ declare module spine {
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
@ -1313,7 +1327,7 @@ declare module spine {
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
declare module spine.webgl {
declare module spine {
class TextureAtlas implements Disposable {
pages: TextureAtlasPage[];
regions: TextureAtlasRegion[];
@ -1905,52 +1919,6 @@ declare module spine {
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
* Version 2.5

View File

@ -1147,103 +1147,100 @@ var spine;
*****************************************************************************/
var spine;
(function (spine) {
var webgl;
(function (webgl) {
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++;
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;
}
};
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];
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++;
};
AssetManager.prototype.remove = function (path) {
var asset = this._assets[path];
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[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;
}());
webgl.AssetManager = AssetManager;
})(webgl = spine.webgl || (spine.webgl = {}));
}
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
@ -4175,6 +4172,23 @@ var spine;
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
@ -4208,162 +4222,159 @@ var spine;
*****************************************************************************/
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
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.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);
}
// 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 {
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);
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.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.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++) {
if (this.regions[i].name == name) {
return this.regions[i];
}
}
};
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;
};
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/);
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;
}
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 = {}));
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
@ -5429,56 +5440,6 @@ var spine;
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
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) {
var webgl;
(function (webgl) {

File diff suppressed because one or more lines are too long

View 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

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 593 KiB

View File

@ -8,5 +8,20 @@
</body>
<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>
</html>

View 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 () { }
}
}

View File

@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
module spine.webgl {
module spine {
export class AssetManager implements Disposable {
private _textureLoader: (image: HTMLImageElement) => any;
private _assets: Map<any> = {};

View File

@ -53,4 +53,14 @@ module spine {
ClampToEdge = 33071, // WebGLRenderingContext.CLAMP_TO_EDGE
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;
}
}

View File

@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
module spine.webgl {
module spine {
export class TextureAtlas implements Disposable {
pages = new Array<TextureAtlasPage>();
regions = new Array<TextureAtlasRegion>();

View File

@ -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;
}
}

View File

@ -36,7 +36,9 @@ function init () {
batcher = new spine.webgl.PolygonBatcher(gl);
mvp.ortho2d(0, 0, 639, 479);
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
// 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.
// 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);
texture.setFilters(minFilter, magFilter);
texture.setWraps(uWrap, vWrap);
return texture;
});
// Create a TextureAtlasAttachmentLoader, which is specific to the WebGL backend.