ngx-spine
Version:
[](https://travis-ci.org/PoiScript/ngx-spine)
23,975 lines • 937 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core')) :
typeof define === 'function' && define.amd ? define('ngx-spine', ['exports', '@angular/core'], factory) :
(global = global || self, factory(global['ngx-spine'] = {}, global.ng.core));
}(this, function (exports, core) { 'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
function __decorate(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
function __param(paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
}
function __metadata(metadataKey, metadataValue) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
}
function __awaiter(thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
function __exportStar(m, exports) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
function __values(o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
if (m) return m.call(o);
return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
}
function __read(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
}
function __spread() {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
}
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
function __await(v) {
return this instanceof __await ? (this.v = v, this) : new __await(v);
}
function __asyncGenerator(thisArg, _arguments, generator) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
function fulfill(value) { resume("next", value); }
function reject(value) { resume("throw", value); }
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
}
function __asyncDelegator(o) {
var i, p;
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
}
function __asyncValues(o) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
}
function __makeTemplateObject(cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
function __importStar(mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result.default = mod;
return result;
}
function __importDefault(mod) {
return (mod && mod.__esModule) ? mod : { default: mod };
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* ***************************************************************************
* Spine Runtimes License Agreement
* Last updated May 1, 2019. Replaces all prior versions.
*
* Copyright (c) 2013-2019, Esoteric Software LLC
*
* Integration of the Spine Runtimes into software or otherwise creating
* derivative works of the Spine Runtimes is permitted under the terms and
* conditions of Section 2 of the Spine Editor License Agreement:
* http://esotericsoftware.com/spine-editor-license
*
* Otherwise, it is permitted to integrate the Spine Runtimes into software
* or otherwise create derivative works of the Spine Runtimes (collectively,
* "Products"), provided that each user of the Products must obtain their own
* Spine Editor license and redistribution of the Products in any form must
* include this license and copyright notice.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
* INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ***************************************************************************
* @abstract
*/
var /**
* ***************************************************************************
* Spine Runtimes License Agreement
* Last updated May 1, 2019. Replaces all prior versions.
*
* Copyright (c) 2013-2019, Esoteric Software LLC
*
* Integration of the Spine Runtimes into software or otherwise creating
* derivative works of the Spine Runtimes is permitted under the terms and
* conditions of Section 2 of the Spine Editor License Agreement:
* http://esotericsoftware.com/spine-editor-license
*
* Otherwise, it is permitted to integrate the Spine Runtimes into software
* or otherwise create derivative works of the Spine Runtimes (collectively,
* "Products"), provided that each user of the Products must obtain their own
* Spine Editor license and redistribution of the Products in any form must
* include this license and copyright notice.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
* INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ***************************************************************************
* @abstract
*/
Texture = /** @class */ (function () {
function Texture(image) {
this._image = image;
}
/**
* @return {?}
*/
Texture.prototype.getImage = /**
* @return {?}
*/
function () {
return this._image;
};
/**
* @param {?} text
* @return {?}
*/
Texture.filterFromString = /**
* @param {?} text
* @return {?}
*/
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);
}
};
/**
* @param {?} text
* @return {?}
*/
Texture.wrapFromString = /**
* @param {?} text
* @return {?}
*/
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;
}());
if (false) {
/**
* @type {?}
* @protected
*/
Texture.prototype._image;
/**
* @abstract
* @param {?} minFilter
* @param {?} magFilter
* @return {?}
*/
Texture.prototype.setFilters = function (minFilter, magFilter) { };
/**
* @abstract
* @param {?} uWrap
* @param {?} vWrap
* @return {?}
*/
Texture.prototype.setWraps = function (uWrap, vWrap) { };
/**
* @abstract
* @return {?}
*/
Texture.prototype.dispose = function () { };
}
/** @enum {number} */
var TextureFilter = {
Nearest: 9728,
Linear: 9729,
MipMap: 9987,
MipMapNearestNearest: 9984,
MipMapLinearNearest: 9985,
MipMapNearestLinear: 9986,
MipMapLinearLinear: 9987 // WebGLRenderingContext.LINEAR_MIPMAP_LINEAR
,
};
TextureFilter[TextureFilter.Nearest] = 'Nearest';
TextureFilter[TextureFilter.Linear] = 'Linear';
TextureFilter[TextureFilter.MipMap] = 'MipMap';
TextureFilter[TextureFilter.MipMapNearestNearest] = 'MipMapNearestNearest';
TextureFilter[TextureFilter.MipMapLinearNearest] = 'MipMapLinearNearest';
TextureFilter[TextureFilter.MipMapNearestLinear] = 'MipMapNearestLinear';
TextureFilter[TextureFilter.MipMapLinearLinear] = 'MipMapLinearLinear';
/** @enum {number} */
var TextureWrap = {
MirroredRepeat: 33648,
ClampToEdge: 33071,
Repeat: 10497 // WebGLRenderingContext.REPEAT
,
};
TextureWrap[TextureWrap.MirroredRepeat] = 'MirroredRepeat';
TextureWrap[TextureWrap.ClampToEdge] = 'ClampToEdge';
TextureWrap[TextureWrap.Repeat] = 'Repeat';
var TextureRegion = /** @class */ (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;
}());
if (false) {
/** @type {?} */
TextureRegion.prototype.renderObject;
/** @type {?} */
TextureRegion.prototype.u;
/** @type {?} */
TextureRegion.prototype.v;
/** @type {?} */
TextureRegion.prototype.u2;
/** @type {?} */
TextureRegion.prototype.v2;
/** @type {?} */
TextureRegion.prototype.width;
/** @type {?} */
TextureRegion.prototype.height;
/** @type {?} */
TextureRegion.prototype.rotate;
/** @type {?} */
TextureRegion.prototype.offsetX;
/** @type {?} */
TextureRegion.prototype.offsetY;
/** @type {?} */
TextureRegion.prototype.originalWidth;
/** @type {?} */
TextureRegion.prototype.originalHeight;
}
var FakeTexture = /** @class */ (function (_super) {
__extends(FakeTexture, _super);
function FakeTexture() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* @param {?} minFilter
* @param {?} magFilter
* @return {?}
*/
FakeTexture.prototype.setFilters = /**
* @param {?} minFilter
* @param {?} magFilter
* @return {?}
*/
function (minFilter, magFilter) { };
/**
* @param {?} uWrap
* @param {?} vWrap
* @return {?}
*/
FakeTexture.prototype.setWraps = /**
* @param {?} uWrap
* @param {?} vWrap
* @return {?}
*/
function (uWrap, vWrap) { };
/**
* @return {?}
*/
FakeTexture.prototype.dispose = /**
* @return {?}
*/
function () { };
return FakeTexture;
}(Texture));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var TextureAtlas = /** @class */ (function () {
function TextureAtlas(atlasText, textureLoader) {
this.pages = new Array();
this.regions = new Array();
this.load(atlasText, textureLoader);
}
/**
* @private
* @param {?} atlasText
* @param {?} textureLoader
* @return {?}
*/
TextureAtlas.prototype.load = /**
* @private
* @param {?} atlasText
* @param {?} textureLoader
* @return {?}
*/
function (atlasText, textureLoader) {
if (textureLoader == null)
throw new Error("textureLoader cannot be null.");
/** @type {?} */
var reader = new TextureAtlasReader(atlasText);
/** @type {?} */
var tuple = new Array(4);
/** @type {?} */
var page = null;
while (true) {
/** @type {?} */
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) {
// size is only optional for an atlas packed with an old TexturePacker.
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 = Texture.filterFromString(tuple[0]);
page.magFilter = Texture.filterFromString(tuple[1]);
/** @type {?} */
var direction = reader.readValue();
page.uWrap = TextureWrap.ClampToEdge;
page.vWrap = TextureWrap.ClampToEdge;
if (direction == "x")
page.uWrap = TextureWrap.Repeat;
else if (direction == "y")
page.vWrap = TextureWrap.Repeat;
else if (direction == "xy")
page.uWrap = page.vWrap = TextureWrap.Repeat;
page.texture = textureLoader(line);
page.texture.setFilters(page.minFilter, page.magFilter);
page.texture.setWraps(page.uWrap, page.vWrap);
page.width = page.texture.getImage().width;
page.height = page.texture.getImage().height;
this.pages.push(page);
}
else {
/** @type {?} */
var region = new TextureAtlasRegion();
region.name = line;
region.page = page;
/** @type {?} */
var rotateValue = reader.readValue();
if (rotateValue.toLocaleLowerCase() == "true") {
region.degrees = 90;
}
else if (rotateValue.toLocaleLowerCase() == "false") {
region.degrees = 0;
}
else {
region.degrees = parseFloat(rotateValue);
}
region.rotate = region.degrees == 90;
reader.readTuple(tuple);
/** @type {?} */
var x = parseInt(tuple[0]);
/** @type {?} */
var y = parseInt(tuple[1]);
reader.readTuple(tuple);
/** @type {?} */
var width = parseInt(tuple[0]);
/** @type {?} */
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) {
// split is optional
// region.splits = new Vector.<int>(parseInt(tuple[0]), parseInt(tuple[1]), parseInt(tuple[2]), parseInt(tuple[3]));
if (reader.readTuple(tuple) == 4) {
// pad is optional, but only present with splits
//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);
}
}
};
/**
* @param {?} name
* @return {?}
*/
TextureAtlas.prototype.findRegion = /**
* @param {?} name
* @return {?}
*/
function (name) {
for (var i = 0; i < this.regions.length; i++) {
if (this.regions[i].name == name) {
return this.regions[i];
}
}
return null;
};
/**
* @return {?}
*/
TextureAtlas.prototype.dispose = /**
* @return {?}
*/
function () {
for (var i = 0; i < this.pages.length; i++) {
this.pages[i].texture.dispose();
}
};
return TextureAtlas;
}());
if (false) {
/** @type {?} */
TextureAtlas.prototype.pages;
/** @type {?} */
TextureAtlas.prototype.regions;
}
var TextureAtlasReader = /** @class */ (function () {
function TextureAtlasReader(text) {
this.index = 0;
this.lines = text.split(/\r\n|\r|\n/);
}
/**
* @return {?}
*/
TextureAtlasReader.prototype.readLine = /**
* @return {?}
*/
function () {
if (this.index >= this.lines.length)
return null;
return this.lines[this.index++];
};
/**
* @return {?}
*/
TextureAtlasReader.prototype.readValue = /**
* @return {?}
*/
function () {
/** @type {?} */
var line = this.readLine();
/** @type {?} */
var colon = line.indexOf(":");
if (colon == -1)
throw new Error("Invalid line: " + line);
return line.substring(colon + 1).trim();
};
/**
* @param {?} tuple
* @return {?}
*/
TextureAtlasReader.prototype.readTuple = /**
* @param {?} tuple
* @return {?}
*/
function (tuple) {
/** @type {?} */
var line = this.readLine();
/** @type {?} */
var colon = line.indexOf(":");
if (colon == -1)
throw new Error("Invalid line: " + line);
/** @type {?} */
var i = 0;
/** @type {?} */
var lastMatch = colon + 1;
for (; i < 3; i++) {
/** @type {?} */
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;
}());
if (false) {
/** @type {?} */
TextureAtlasReader.prototype.lines;
/** @type {?} */
TextureAtlasReader.prototype.index;
}
var TextureAtlasPage = /** @class */ (function () {
function TextureAtlasPage() {
}
return TextureAtlasPage;
}());
if (false) {
/** @type {?} */
TextureAtlasPage.prototype.name;
/** @type {?} */
TextureAtlasPage.prototype.minFilter;
/** @type {?} */
TextureAtlasPage.prototype.magFilter;
/** @type {?} */
TextureAtlasPage.prototype.uWrap;
/** @type {?} */
TextureAtlasPage.prototype.vWrap;
/** @type {?} */
TextureAtlasPage.prototype.texture;
/** @type {?} */
TextureAtlasPage.prototype.width;
/** @type {?} */
TextureAtlasPage.prototype.height;
}
var TextureAtlasRegion = /** @class */ (function (_super) {
__extends(TextureAtlasRegion, _super);
function TextureAtlasRegion() {
return _super !== null && _super.apply(this, arguments) || this;
}
return TextureAtlasRegion;
}(TextureRegion));
if (false) {
/** @type {?} */
TextureAtlasRegion.prototype.page;
/** @type {?} */
TextureAtlasRegion.prototype.name;
/** @type {?} */
TextureAtlasRegion.prototype.x;
/** @type {?} */
TextureAtlasRegion.prototype.y;
/** @type {?} */
TextureAtlasRegion.prototype.index;
/** @type {?} */
TextureAtlasRegion.prototype.rotate;
/** @type {?} */
TextureAtlasRegion.prototype.degrees;
/** @type {?} */
TextureAtlasRegion.prototype.texture;
/** @type {?} */
TextureAtlasRegion.prototype.u;
/** @type {?} */
TextureAtlasRegion.prototype.v;
/** @type {?} */
TextureAtlasRegion.prototype.u2;
/** @type {?} */
TextureAtlasRegion.prototype.v2;
/** @type {?} */
TextureAtlasRegion.prototype.width;
/** @type {?} */
TextureAtlasRegion.prototype.height;
/** @type {?} */
TextureAtlasRegion.prototype.originalWidth;
/** @type {?} */
TextureAtlasRegion.prototype.originalHeight;
/** @type {?} */
TextureAtlasRegion.prototype.offsetX;
/** @type {?} */
TextureAtlasRegion.prototype.offsetY;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var AssetManager = /** @class */ (function () {
function AssetManager(textureLoader, pathPrefix) {
if (pathPrefix === void 0) { pathPrefix = ""; }
this.assets = {};
this.errors = {};
this.toLoad = 0;
this.loaded = 0;
this.textureLoader = textureLoader;
this.pathPrefix = pathPrefix;
}
/**
* @private
* @param {?} url
* @param {?} success
* @param {?} error
* @return {?}
*/
AssetManager.downloadText = /**
* @private
* @param {?} url
* @param {?} success
* @param {?} error
* @return {?}
*/
function (url, success, error) {
/** @type {?} */
var request = new XMLHttpRequest();
request.open("GET", url, true);
request.onload = (/**
* @return {?}
*/
function () {
if (request.status == 200) {
success(request.responseText);
}
else {
error(request.status, request.responseText);
}
});
request.onerror = (/**
* @return {?}
*/
function () {
error(request.status, request.responseText);
});
request.send();
};
/**
* @private
* @param {?} url
* @param {?} success
* @param {?} error
* @return {?}
*/
AssetManager.downloadBinary = /**
* @private
* @param {?} url
* @param {?} success
* @param {?} error
* @return {?}
*/
function (url, success, error) {
/** @type {?} */
var request = new XMLHttpRequest();
request.open("GET", url, true);
request.responseType = "arraybuffer";
request.onload = (/**
* @return {?}
*/
function () {
if (request.status == 200) {
success(new Uint8Array((/** @type {?} */ (request.response))));
}
else {
error(request.status, request.responseText);
}
});
request.onerror = (/**
* @return {?}
*/
function () {
error(request.status, request.responseText);
});
request.send();
};
/**
* @param {?} path
* @param {?=} success
* @param {?=} error
* @return {?}
*/
AssetManager.prototype.loadBinary = /**
* @param {?} path
* @param {?=} success
* @param {?=} error
* @return {?}
*/
function (path, success, error) {
var _this = this;
if (success === void 0) { success = null; }
if (error === void 0) { error = null; }
path = this.pathPrefix + path;
this.toLoad++;
AssetManager.downloadBinary(path, (/**
* @param {?} data
* @return {?}
*/
function (data) {
_this.assets[path] = data;
if (success)
success(path, data);
_this.toLoad--;
_this.loaded++;
}), (/**
* @param {?} state
* @param {?} responseText
* @return {?}
*/
function (state, responseText) {
_this.errors[path] = "Couldn't load binary " + path + ": status " + status + ", " + responseText;
if (error)
error(path, "Couldn't load binary " + path + ": status " + status + ", " + responseText);
_this.toLoad--;
_this.loaded++;
}));
};
/**
* @param {?} path
* @param {?=} success
* @param {?=} error
* @return {?}
*/
AssetManager.prototype.loadText = /**
* @param {?} path
* @param {?=} success
* @param {?=} error
* @return {?}
*/
function (path, success, error) {
var _this = this;
if (success === void 0) { success = null; }
if (error === void 0) { error = null; }
path = this.pathPrefix + path;
this.toLoad++;
AssetManager.downloadText(path, (/**
* @param {?} data
* @return {?}
*/
function (data) {
_this.assets[path] = data;
if (success)
success(path, data);
_this.toLoad--;
_this.loaded++;
}), (/**
* @param {?} state
* @param {?} responseText
* @return {?}
*/
function (state, responseText) {
_this.errors[path] = "Couldn't load text " + path + ": status " + status + ", " + responseText;
if (error)
error(path, "Couldn't load text " + path + ": status " + status + ", " + responseText);
_this.toLoad--;
_this.loaded++;
}));
};
/**
* @param {?} path
* @param {?=} success
* @param {?=} error
* @return {?}
*/
AssetManager.prototype.loadTexture = /**
* @param {?} path
* @param {?=} success
* @param {?=} error
* @return {?}
*/
function (path, success, error) {
var _this = this;
if (success === void 0) { success = null; }
if (error === void 0) { error = null; }
path = this.pathPrefix + path;
this.toLoad++;
/** @type {?} */
var img = new Image();
img.crossOrigin = "anonymous";
img.onload = (/**
* @param {?} ev
* @return {?}
*/
function (ev) {
/** @type {?} */
var texture = _this.textureLoader(img);
_this.assets[path] = texture;
_this.toLoad--;
_this.loaded++;
if (success)
success(path, img);
});
img.onerror = (/**
* @param {?} ev
* @return {?}
*/
function (ev) {
_this.errors[path] = "Couldn't load image " + path;
_this.toLoad--;
_this.loaded++;
if (error)
error(path, "Couldn't load image " + path);
});
img.src = path;
};
/**
* @param {?} path
* @param {?} data
* @param {?=} success
* @param {?=} error
* @return {?}
*/
AssetManager.prototype.loadTextureData = /**
* @param {?} path
* @param {?} data
* @param {?=} success
* @param {?=} error
* @return {?}
*/
function (path, data, success, error) {
var _this = this;
if (success === void 0) { success = null; }
if (error === void 0) { error = null; }
path = this.pathPrefix + path;
this.toLoad++;
/** @type {?} */
var img = new Image();
img.onload = (/**
* @param {?} ev
* @return {?}
*/
function (ev) {
/** @type {?} */
var texture = _this.textureLoader(img);
_this.assets[path] = texture;
_this.toLoad--;
_this.loaded++;
if (success)
success(path, img);
});
img.onerror = (/**
* @param {?} ev
* @return {?}
*/
function (ev) {
_this.errors[path] = "Couldn't load image " + path;
_this.toLoad--;
_this.loaded++;
if (error)
error(path, "Couldn't load image " + path);
});
img.src = data;
};
/**
* @param {?} path
* @param {?=} success
* @param {?=} error
* @return {?}
*/
AssetManager.prototype.loadTextureAtlas = /**
* @param {?} path
* @param {?=} success
* @param {?=} error
* @return {?}
*/
function (path, success, error) {
var _this = this;
if (success === void 0) { success = null; }
if (error === void 0) { error = null; }
/** @type {?} */
var parent = path.lastIndexOf("/") >= 0
? path.substring(0, path.lastIndexOf("/"))
: "";
path = this.pathPrefix + path;
this.toLoad++;
AssetManager.downloadText(path, (/**
* @param {?} atlasData
* @return {?}
*/
function (atlasData) {
var e_1, _a;
/** @type {?} */
var pagesLoaded = { count: 0 };
/** @type {?} */
var atlasPages = new Array();
try {
/** @type {?} */
var atlas = new TextureAtlas(atlasData, (/**
* @param {?} path
* @return {?}
*/
function (path) {
atlasPages.push(parent + "/" + path);
/** @type {?} */
var image = (/** @type {?} */ (document.createElement("img")));
image.width = 16;
image.height = 16;
return new FakeTexture(image);
}));
}
catch (e) {
/** @type {?} */
var ex = (/** @type {?} */ (e));
_this.errors[path] = "Couldn't load texture atlas " + path + ": " + ex.message;
if (error)
error(path, "Couldn't load texture atlas " + path + ": " + ex.message);
_this.toLoad--;
_this.loaded++;
return;
}
var _loop_1 = function (atlasPage) {
/** @type {?} */
var pageLoadError = false;
_this.loadTexture(atlasPage, (/**
* @param {?} imagePath
* @param {?} image
* @return {?}
*/
function (imagePath, image) {
pagesLoaded.count++;
if (pagesLoaded.count == atlasPages.length) {
if (!pageLoadError) {
try {
/** @type {?} */
var atlas = new TextureAtlas(atlasData, (/**
* @param {?} path
* @return {?}
*/
function (path) {
return _this.get(parent + "/" + path);
}));
_this.assets[path] = atlas;
if (success)
success(path, atlas);
_this.toLoad--;
_this.loaded++;
}
catch (e) {
/** @type {?} */
var ex = (/** @type {?} */ (e));
_this.errors[path] = "Couldn't load texture atlas " + path + ": " + ex.message;
if (error)
error(path, "Couldn't load texture atlas " + path + ": " + ex.message);
_this.toLoad--;
_this.loaded++;
}
}
else {
_this.errors[path] = "Couldn't load texture atlas page " + imagePath + "} of atlas " + path;
if (error)
error(path, "Couldn't load texture atlas page " + imagePath + " of atlas " + path);
_this.toLoad--;
_this.loaded++;
}
}
}), (/**
* @param {?} imagePath
* @param {?} errorMessage
* @return {?}
*/
function (imagePath, errorMessage) {
pageLoadError = true;
pagesLoaded.count++;
if (pagesLoaded.count == atlasPages.length) {
_this.errors[path] = "Couldn't load texture atlas page " + imagePath + "} of atlas " + path;
if (error)
error(path, "Couldn't load texture atlas page " + imagePath + " of atlas " + path);
_this.toLoad--;
_this.loaded++;
}
}));
};
try {
for (var atlasPages_1 = __values(atlasPages), atlasPages_1_1 = atlasPages_1.next(); !atlasPages_1_1.done; atlasPages_1_1 = atlasPages_1.next()) {
var atlasPage = atlasPages_1_1.value;
_loop_1(atlasPage);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (atlasPages_1_1 && !atlasPages_1_1.done && (_a = atlasPages_1.return)) _a.call(atlasPages_1);
}
finally { if (e_1) throw e_1.error; }
}
}), (/**
* @param {?} state
* @param {?} responseText
* @return {?}
*/
function (state, responseText) {
_this.errors[path] = "Couldn't load texture atlas " + path + ": status " + status + ", " + responseText;
if (error)
error(path, "Couldn't load texture atlas " + path + ": status " + status + ", " + responseText);
_this.toLoad--;
_this.loaded++;
}));
};
/**
* @param {?} path
* @return {?}
*/
AssetManager.prototype.get = /**
* @param {?} path
* @return {?}
*/
function (path) {
path = this.pathPrefix + path;
return this.assets[path];
};
/**
* @param {?} path
* @return {?}
*/
AssetManager.prototype.remove = /**
* @param {?} path
* @return {?}
*/
function (path) {
path = this.pathPrefix + path;
/** @type {?} */
var asset = this.assets[path];
if (((/** @type {?} */ (asset))).dispose)
((/** @type {?} */ (asset))).dispose();
this.assets[path] = null;
};
/**
* @return {?}
*/
AssetManager.prototype.removeAll = /**
* @return {?}
*/
function () {
for (var key in this.assets) {
/** @type {?} */
var asset = this.assets[key];
if (((/** @type {?} */ (asset))).dispose)
((/** @type {?} */ (asset))).dispose();
}
this.assets = {};
};
/**
* @return {?}
*/
AssetManager.prototype.isLoadingComplete = /**
* @return {?}
*/
function () {
return this.toLoad == 0;
};
/**
* @return {?}
*/
AssetManager.prototype.getToLoad = /**
* @return {?}
*/
function () {
return this.toLoad;
};
/**
* @return {?}
*/
AssetManager.prototype.getLoaded = /**
* @return {?}
*/
function () {
return this.loaded;
};
/**
* @return {?}
*/
AssetManager.prototype.dispose = /**
* @return {?}
*/
function () {
this.removeAll();
};
/**
* @return {?}
*/
AssetManager.prototype.hasErrors = /**
* @return {?}
*/
function () {
return Object.keys(this.errors).length > 0;
};
/**
* @return {?}
*/
AssetManager.prototype.getErrors = /**
* @return {?}
*/
function () {
return this.errors;
};
return AssetManager;
}());
if (false) {
/**
* @type {?}
* @private
*/
AssetManager.prototype.pathPrefix;
/**
* @type {?}
* @private
*/
AssetManager.prototype.textureLoader;
/**
* @type {?}
* @private
*/
AssetManager.prototype.assets;
/**
* @type {?}
* @private
*/
AssetManager.prototype.errors;
/**
* @type {?}
* @private
*/
AssetManager.prototype.toLoad;
/**
* @type {?}
* @private
*/
AssetManager.prototype.loaded;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @enum {number} */
var BlendMode = {
Normal: 0,
Additive: 1,
Multiply: 2,
Screen: 3,
};
BlendMode[BlendMode.Normal] = 'Normal';
BlendMode[BlendMode.Additive] = 'Additive';
BlendMode[BlendMode.Multiply] = 'Multiply';
BlendMode[BlendMode.Screen] = 'Screen';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var ManagedWebGLRenderingContext = /** @class */ (function () {
function ManagedWebGLRenderingContext(canvasOrContext, contextConfig) {
var _this = this;
if (contextConfig === void 0) { contextConfig = { alpha: "true" }; }
this.restorables = new Array();
if (canvasOrContext instanceof HTMLCanvasElement) {
/** @type {?} */
var canvas = canvasOrContext;
this.gl = (/** @type {?} */ (((canvas.getContext("webgl", contextConfig) ||
canvas.getContext("experimental-webgl", contextConfig)))));
this.canvas = canvas;
canvas.addEventListener("webglcontextlost", (/**
* @param {?} e
* @return {?}
*/
function (e) {
/** @type {?} */
var event = (/** @type {?} */ (e));
if (e) {
e.preventDefault();
}
}));
canvas.addEventListener("webglcontextrestored", (/**
* @param {?} e
* @return {?}
*/
function (e) {
for (var i = 0, n = _this.restorables.length; i < n; i++) {
_this.restorables[i].restore();
}
}));
}
else {
this.gl = canvasOrContext;
this.canvas = (/** @type {?} */ (this.gl.canvas));
}
}
/**
* @param {?} restorable
* @return {?}
*/
ManagedWebGLRenderingContext.prototype.addRestorable = /**
* @param {?} restorable
* @return {?}
*/
function (restorable) {
this.restorables.push(restorable);
};
/**
* @param {?} restorable
* @return {?}
*/
ManagedWebGLRenderingContext.prototype.removeRestorable = /**
* @param {?} restorable
* @return {?}
*/
function (restorable) {
/** @type {?} */
var index = this.restorables.indexOf(restorable);
if (index > -1)
this.restorables.splice(index, 1);
};
return ManagedWebGLRenderingContext;
}());
if (false) {
/** @type {?} */
ManagedWebGLRenderingContext.prototype.canvas;
/** @type {?} */
ManagedWebGLRenderingContext.prototype.gl;
/**
* @type {?}
* @private
*/
ManagedWebGLRenderingContext.prototype.restorables;
}
var WebGLBlendModeConverter = /** @class */ (function () {
function WebGLBlendModeConverter() {
}
/**
* @param {?} blendMode
* @return {?}
*/
WebGLBlendModeConverter.getDestGLBlendMode = /**
* @param {?} blendMode
* @return {?}
*/
function (blendMode) {
switch (blendMode) {
case BlendMode.Normal:
return WebGLBlendModeConverter.ONE_MINUS_SRC_ALPHA;
case BlendMode.Additive:
return WebGLBlendModeConverter.ONE;
case BlendMode.Multiply:
return WebGLBlendModeConverter.ONE_MINUS_SRC_ALPHA;
case BlendMode.Screen:
return WebGLBlendModeConverter.ONE_MINUS_SRC_ALPHA;
default:
throw new Error("Unknown blend mode: " + blendMode);
}
};
/**
* @param {?} blendMode
* @param {?=} premultipliedAlpha
* @return {?}
*/
WebGLBlendModeConverter.getSourceGLBlendMode = /**
* @param {?} blendMode
* @param {?=} premultipliedAlpha
* @return {?}
*/
function (blendMode, premultipliedAlpha) {
if (premultipliedAlpha === void 0) { premultipliedAlpha = false; }
switch (blendMode) {
case BlendMode.Normal:
return premultipliedAlpha
? WebGLBlendModeConverter.ONE
: WebGLBlendModeConverter.SRC_ALPHA;
case BlendMode.Additive:
return premultipliedAlpha
? WebGLBlendModeConverter.ONE
: WebGLBlendModeConverter.SRC_ALPHA;
case BlendMode.Multiply:
return WebGLBlendModeConverter.DST_COLOR;
case BlendMode.Screen:
return WebGLBlendModeConverter.ONE;
default:
throw new Error("Unknown blend mode: " + blendMode);
}
};
WebGLBlendModeConverter.ZERO = 0;
WebGLBlendModeConverter.ONE = 1;
WebGLBlendModeConverter.SRC_COLOR = 0x0300;
WebGLBlendModeConverter.ONE_MINUS_SRC_COLOR = 0x0301;
WebGLBlendModeConverter.SRC_ALPHA = 0x0302;
WebGLBlendModeConverter.ONE_MINUS_SRC_ALPHA = 0x0303;
WebGLBlendModeConverter.DST_ALPHA = 0x0304;
WebGLBlendModeConverter.ONE_MINUS_DST_ALPHA = 0x0305;
WebGLBlendModeConverter.DST_COLOR = 0x0306;
return WebGLBlendModeConverter;
}());
if (false) {
/** @type {?} */
WebGLBlendModeConverter.ZERO;
/** @type {?} */
WebGLBlendModeConverter.ONE;
/** @type {?} */
WebGLBlendModeConverter.SRC_COLOR;
/** @type {?} */
WebGLBlendModeConverter.ONE_MINUS_SRC_COLOR;
/** @type {?} */
WebGLBlendModeConverter.SRC_ALPHA;
/** @type {?} */
WebGLBlendModeConverter.ONE_MINUS_SRC_ALPHA;
/** @type {?} */
WebGLBlendModeConverter.DST_ALPHA;
/** @type {?} */
WebGLBlendModeConverter.ONE_MINUS_DST_ALPHA;
/** @type {?} */
WebGLBlendModeConverter.DST_COLOR;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var GLTexture = /** @class */ (function (_super) {
__extends(GLTexture, _super);
function GLTexture(context, image, useMipMaps) {
if (useMipMaps === void 0) { useMipMaps = false; }
var _this = _super.call(this, image) || this;
_this.texture = null;
_this.boundUnit = 0;
_this.useMipMaps = false;
_this.context =
context instanceof ManagedWebGLRenderingContext
? context
: new ManagedWebGLRenderingContext(context);
_this.useMipMaps = useMipMaps;
_this.restore();
_this.context.addRestorable(_this);
return _this;
}
/**
* @param {?} minFilter
* @param {?} magFilter
* @return {?}
*/
GLTexture.prototype.setFilters = /**
* @param {?} minFilter
* @param {?} magFilter
* @return {?}
*/
function (minFilter, magFilter) {
/** @type {?} */
var gl = this.context.gl;
this.bind();
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter);
};
/**
* @param {?} uWrap
* @param {?} vWrap
* @return {?}
*/
GLTexture.prototype.setWraps = /**
* @param {?} uWrap
* @param {?} vWrap
* @return {?}
*/
function (uWrap, vWrap) {
/** @type {?} */
var gl = this.context.gl;
this.bind();
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, uWrap);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, vWrap);
};
/**
* @param {?} useMipMaps
* @return {?}
*/
GLTexture.prototype.update = /**
* @param {?} useMipMaps
* @return {?}
*/
function (useMipMaps) {
/** @type {?} */
var gl = this.context.gl;
if (!this.texture) {
this.texture = this.context.gl.createTexture();
}
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);
};
/**
* @return {?}
*/
GLTexture.prototype.restore = /**
* @return {?}
*/
function () {
this.texture = null;
this.update(this.useMipMaps);
};
/**
* @param {?=} unit
* @return {?}
*/
GLTexture.prototype.bind = /**
* @param {?=} unit
* @return {?}
*/
function (unit) {
if (unit === void 0) { unit = 0; }
/** @type {?} */
var gl = this.context.gl;
this.boundUnit = unit;
gl.activeTexture(gl.TEXTURE0 + unit);
gl.bindTexture(gl.TEXTURE_2D, this.texture);
};
/**
* @return {?}
*/
GLTexture.prototype.unbind = /**
* @return {?}
*/
function () {
/** @type {?} */
var gl = this.context.gl;
gl.activeTexture(gl.TEXTURE0 + this.boundUnit);
gl.bindTexture(gl.TEXTURE_2D, null);
};
/**
* @return {?}
*/
GLTexture.prototype.dispose = /**
* @return {?}
*/
function () {
this.context.removeRestorable(this);
/** @type {?} */
var gl = this.context.gl;
gl.deleteTexture(this.texture);
};
return GLTexture;
}(Texture));
if (false) {
/**
* @type {?}
* @private
*/
GLTexture.prototype.context;
/**
* @type {?}
* @private
*/
GLTexture.prototype.texture;
/**
* @type {?}
* @private
*/
GLTexture.prototype.boundUnit;
/**
* @type {?}
* @private
*/
GLTexture.prototype.useMipMaps;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var AssetManager$1 = /** @class */ (function (_super) {
__extends(AssetManager, _super);
function AssetManager(context, pathPrefix) {
if (pathPrefix === void 0) { pathPrefix = ""; }
return _super.call(this, (/**
* @param {?} image
* @return {?}
*/
function (image) {
return new GLTexture(context, image);
}), pathPrefix) || this;
}
return AssetManager;
}(AssetManager));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var M00 = 0;
/** @type {?} */
var M01 = 4;
/** @type {?} */
var M02 = 8;
/** @type {?} */
var M03 = 12;
/** @type {?} */
var M10 = 1;
/** @type {?} */
var M11 = 5;
/** @type {?} */
var M12 = 9;
/** @type {?} */
var M13 = 13;
/** @type {?} */
var M20 = 2;
/** @type {?} */
var M21 = 6;
/** @type {?} */
var M22 = 10;
/** @type {?} */
var M23 = 14;
/** @type {?} */
var M30 = 3;
/** @type {?} */
var M31 = 7;
/** @type {?} */
var M32 = 11;
/** @type {?} */
var M33 = 15;
var Matrix4 = /** @class */ (function () {
function Matrix4() {
this.temp = new Float32Array(16);
this.values = new Float32Array(16);
/** @type {?} */
var v = this.values;
v[M00] = 1;
v[M11] = 1;
v[M22] = 1;
v[M33] = 1;
}
/**
* @param {?} values
* @return {?}
*/
Matrix4.prototype.set = /**
* @param {?} values
* @return {?}
*/
function (values) {
this.values.set(values);
return this;
};
/**
* @return {?}
*/
Matrix4.prototype.transpose = /**
* @return {?}
*/
function () {
/** @type {?} */
var t = this.temp;
/** @type {?} */
var v = this.values;
t[M00] = v[M00];
t[M01] = v[M10];
t[M02] = v[M20];
t[M03] = v[M30];
t[M10] = v[M01];
t[M11] = v[M11];
t[M12] = v[M21];
t[M13] = v[M31];
t[M20] = v[M02];
t[M21] = v[M12];
t[M22] = v[M22];
t[M23] = v[M32];
t[M30] = v[M03];
t[M31] = v[M13];
t[M32] = v[M23];
t[M33] = v[M33];
return this.set(t);
};
/**
* @return {?}
*/
Matrix4.prototype.identity = /**
* @return {?}
*/
function () {
/** @type {?} */
var v = this.values;
v[M00] = 1;
v[M01] = 0;
v[M02] = 0;
v[M03] = 0;
v[M10] = 0;
v[M11] = 1;
v[M12] = 0;
v[M13] = 0;
v[M20] = 0;
v[M21] = 0;
v[M22] = 1;
v[M23] = 0;
v[M30] = 0;
v[M31] = 0;
v[M32] = 0;
v[M33] = 1;
return this;
};
/**
* @return {?}
*/
Matrix4.prototype.invert = /**
* @return {?}
*/
function () {
/** @type {?} */
var v = this.values;
/** @type {?} */
var t = this.temp;
/** @type {?} */
var l_det = v[M30] * v[M21] * v[M12] * v[M03] -
v[M20] * v[M31] * v[M12] * v[M03] -
v[M30] * v[M11] * v[M22] * v[M03] +
v[M10] * v[M31] * v[M22] * v[M03] +
v[M20] * v[M11] * v[M32] * v[M03] -
v[M10] * v[M21] * v[M32] * v[M03] -
v[M30] * v[M21] * v[M02] * v[M13] +
v[M20] * v[M31] * v[M02] * v[M13] +
v[M30] * v[M01] * v[M22] * v[M13] -
v[M00] * v[M31] * v[M22] * v[M13] -
v[M20] * v[M01] * v[M32] * v[M13] +
v[M00] * v[M21] * v[M32] * v[M13] +
v[M30] * v[M11] * v[M02] * v[M23] -
v[M10] * v[M31] * v[M02] * v[M23] -
v[M30] * v[M01] * v[M12] * v[M23] +
v[M00] * v[M31] * v[M12] * v[M23] +
v[M10] * v[M01] * v[M32] * v[M23] -
v[M00] * v[M11] * v[M32] * v[M23] -
v[M20] * v[M11] * v[M02] * v[M33] +
v[M10] * v[M21] * v[M02] * v[M33] +
v[M20] * v[M01] * v[M12] * v[M33] -
v[M00] * v[M21] * v[M12] * v[M33] -
v[M10] * v[M01] * v[M22] * v[M33] +
v[M00] * v[M11] * v[M22] * v[M33];
if (l_det == 0)
throw new Error("non-invertible matrix");
/** @type {?} */
var inv_det = 1.0 / l_det;
t[M00] =
v[M12] * v[M23] * v[M31] -
v[M13] * v[M22] * v[M31] +
v[M13] * v[M21] * v[M32] -
v[M11] * v[M23] * v[M32] -
v[M12] * v[M21] * v[M33] +
v[M11] * v[M22] * v[M33];
t[M01] =
v[M03] * v[M22] * v[M31] -
v[M02] * v[M23] * v[M31] -
v[M03] * v[M21] * v[M32] +
v[M01] * v[M23] * v[M32] +
v[M02] * v[M21] * v[M33] -
v[M01] * v[M22] * v[M33];
t[M02] =
v[M02] * v[M13] * v[M31] -
v[M03] * v[M12] * v[M31] +
v[M03] * v[M11] * v[M32] -
v[M01] * v[M13] * v[M32] -
v[M02] * v[M11] * v[M33] +
v[M01] * v[M12] * v[M33];
t[M03] =
v[M03] * v[M12] * v[M21] -
v[M02] * v[M13] * v[M21] -
v[M03] * v[M11] * v[M22] +
v[M01] * v[M13] * v[M22] +
v[M02] * v[M11] * v[M23] -
v[M01] * v[M12] * v[M23];
t[M10] =
v[M13] * v[M22] * v[M30] -
v[M12] * v[M23] * v[M30] -
v[M13] * v[M20] * v[M32] +
v[M10] * v[M23] * v[M32] +
v[M12] * v[M20] * v[M33] -
v[M10] * v[M22] * v[M33];
t[M11] =
v[M02] * v[M23] * v[M30] -
v[M03] * v[M22] * v[M30] +
v[M03] * v[M20] * v[M32] -
v[M00] * v[M23] * v[M32] -
v[M02] * v[M20] * v[M33] +
v[M00] * v[M22] * v[M33];
t[M12] =
v[M03] * v[M12] * v[M30] -
v[M02] * v[M13] * v[M30] -
v[M03] * v[M10] * v[M32] +
v[M00] * v[M13] * v[M32] +
v[M02] * v[M10] * v[M33] -
v[M00] * v[M12] * v[M33];
t[M13] =
v[M02] * v[M13] * v[M20] -
v[M03] * v[M12] * v[M20] +
v[M03] * v[M10] * v[M22] -
v[M00] * v[M13] * v[M22] -
v[M02] * v[M10] * v[M23] +
v[M00] * v[M12] * v[M23];
t[M20] =
v[M11] * v[M23] * v[M30] -
v[M13] * v[M21] * v[M30] +
v[M13] * v[M20] * v[M31] -
v[M10] * v[M23] * v[M31] -
v[M11] * v[M20] * v[M33] +
v[M10] * v[M21] * v[M33];
t[M21] =
v[M03] * v[M21] * v[M30] -
v[M01] * v[M23] * v[M30] -
v[M03] * v[M20] * v[M31] +
v[M00] * v[M23] * v[M31] +
v[M01] * v[M20] * v[M33] -
v[M00] * v[M21] * v[M33];
t[M22] =
v[M01] * v[M13] * v[M30] -
v[M03] * v[M11] * v[M30] +
v[M03] * v[M10] * v[M31] -
v[M00] * v[M13] * v[M31] -
v[M01] * v[M10] * v[M33] +
v[M00] * v[M11] * v[M33];
t[M23] =
v[M03] * v[M11] * v[M20] -
v[M01] * v[M13] * v[M20] -
v[M03] * v[M10] * v[M21] +
v[M00] * v[M13] * v[M21] +
v[M01] * v[M10] * v[M23] -
v[M00] * v[M11] * v[M23];
t[M30] =
v[M12] * v[M21] * v[M30] -
v[M11] * v[M22] * v[M30] -
v[M12] * v[M20] * v[M31] +
v[M10] * v[M22] * v[M31] +
v[M11] * v[M20] * v[M32] -
v[M10] * v[M21] * v[M32];
t[M31] =
v[M01] * v[M22] * v[M30] -
v[M02] * v[M21] * v[M30] +
v[M02] * v[M20] * v[M31] -
v[M00] * v[M22] * v[M31] -
v[M01] * v[M20] * v[M32] +
v[M00] * v[M21] * v[M32];
t[M32] =
v[M02] * v[M11] * v[M30] -
v[M01] * v[M12] * v[M30] -
v[M02] * v[M10] * v[M31] +
v[M00] * v[M12] * v[M31] +
v[M01] * v[M10] * v[M32] -
v[M00] * v[M11] * v[M32];
t[M33] =
v[M01] * v[M12] * v[M20] -
v[M02] * v[M11] * v[M20] +
v[M02] * v[M10] * v[M21] -
v[M00] * v[M12] * v[M21] -
v[M01] * v[M10] * v[M22] +
v[M00] * v[M11] * v[M22];
v[M00] = t[M00] * inv_det;
v[M01] = t[M01] * inv_det;
v[M02] = t[M02] * inv_det;
v[M03] = t[M03] * inv_det;
v[M10] = t[M10] * inv_det;
v[M11] = t[M11] * inv_det;
v[M12] = t[M12] * inv_det;
v[M13] = t[M13] * inv_det;
v[M20] = t[M20] * inv_det;
v[M21] = t[M21] * inv_det;
v[M22] = t[M22] * inv_det;
v[M23] = t[M23] * inv_det;
v[M30] = t[M30] * inv_det;
v[M31] = t[M31] * inv_det;
v[M32] = t[M32] * inv_det;
v[M33] = t[M33] * inv_det;
return this;
};
/**
* @return {?}
*/
Matrix4.prototype.determinant = /**
* @return {?}
*/
function () {
/** @type {?} */
var v = this.values;
return (v[M30] * v[M21] * v[M12] * v[M03] -
v[M20] * v[M31] * v[M12] * v[M03] -
v[M30] * v[M11] * v[M22] * v[M03] +
v[M10] * v[M31] * v[M22] * v[M03] +
v[M20] * v[M11] * v[M32] * v[M03] -
v[M10] * v[M21] * v[M32] * v[M03] -
v[M30] * v[M21] * v[M02] * v[M13] +
v[M20] * v[M31] * v[M02] * v[M13] +
v[M30] * v[M01] * v[M22] * v[M13] -
v[M00] * v[M31] * v[M22] * v[M13] -
v[M20] * v[M01] * v[M32] * v[M13] +
v[M00] * v[M21] * v[M32] * v[M13] +
v[M30] * v[M11] * v[M02] * v[M23] -
v[M10] * v[M31] * v[M02] * v[M23] -
v[M30] * v[M01] * v[M12] * v[M23] +
v[M00] * v[M31] * v[M12] * v[M23] +
v[M10] * v[M01] * v[M32] * v[M23] -
v[M00] * v[M11] * v[M32] * v[M23] -
v[M20] * v[M11] * v[M02] * v[M33] +
v[M10] * v[M21] * v[M02] * v[M33] +
v[M20] * v[M01] * v[M12] * v[M33] -
v[M00] * v[M21] * v[M12] * v[M33] -
v[M10] * v[M01] * v[M22] * v[M33] +
v[M00] * v[M11] * v[M22] * v[M33]);
};
/**
* @param {?} x
* @param {?} y
* @param {?} z
* @return {?}
*/
Matrix4.prototype.translate = /**
* @param {?} x
* @param {?} y
* @param {?} z
* @return {?}
*/
function (x, y, z) {
/** @type {?} */
var v = this.values;
v[M03] += x;
v[M13] += y;
v[M23] += z;
return this;
};
/**
* @return {?}
*/
Matrix4.prototype.copy = /**
* @return {?}
*/
function () {
return new Matrix4().set(this.values);
};
/**
* @param {?} near
* @param {?} far
* @param {?} fovy
* @param {?} aspectRatio
* @return {?}
*/
Matrix4.prototype.projection = /**
* @param {?} near
* @param {?} far
* @param {?} fovy
* @param {?} aspectRatio
* @return {?}
*/
function (near, far, fovy, aspectRatio) {
this.identity();
/** @type {?} */
var l_fd = 1.0 / Math.tan((fovy * (Math.PI / 180)) / 2.0);
/** @type {?} */
var l_a1 = (far + near) / (near - far);
/** @type {?} */
var l_a2 = (2 * far * near) / (near - far);
/** @type {?} */
var v = this.values;
v[M00] = l_fd / aspectRatio;
v[M10] = 0;
v[M20] = 0;
v[M30] = 0;
v[M01] = 0;
v[M11] = l_fd;
v[M21] = 0;
v[M31] = 0;
v[M02] = 0;
v[M12] = 0;
v[M22] = l_a1;
v[M32] = -1;
v[M03] = 0;
v[M13] = 0;
v[M23] = l_a2;
v[M33] = 0;
return this;
};
/**
* @param {?} x
* @param {?} y
* @param {?} width
* @param {?} height
* @return {?}
*/
Matrix4.prototype.ortho2d = /**
* @param {?} x
* @param {?} y
* @param {?} width
* @param {?} height
* @return {?}
*/
function (x, y, width, height) {
return this.ortho(x, x + width, y, y + height, 0, 1);
};
/**
* @param {?} left
* @param {?} right
* @param {?} bottom
* @param {?} top
* @param {?} near
* @param {?} far
* @return {?}
*/
Matrix4.prototype.ortho = /**
* @param {?} left
* @param {?} right
* @param {?} bottom
* @param {?} top
* @param {?} near
* @param {?} far
* @return {?}
*/
function (left, right, bottom, top, near, far) {
this.identity();
/** @type {?} */
var x_orth = 2 / (right - left);
/** @type {?} */
var y_orth = 2 / (top - bottom);
/** @type {?} */
var z_orth = -2 / (far - near);
/** @type {?} */
var tx = -(right + left) / (right - left);
/** @type {?} */
var ty = -(top + bottom) / (top - bottom);
/** @type {?} */
var tz = -(far + near) / (far - near);
/** @type {?} */
var v = this.values;
v[M00] = x_orth;
v[M10] = 0;
v[M20] = 0;
v[M30] = 0;
v[M01] = 0;
v[M11] = y_orth;
v[M21] = 0;
v[M31] = 0;
v[M02] = 0;
v[M12] = 0;
v[M22] = z_orth;
v[M32] = 0;
v[M03] = tx;
v[M13] = ty;
v[M23] = tz;
v[M33] = 1;
return this;
};
/**
* @param {?} matrix
* @return {?}
*/
Matrix4.prototype.multiply = /**
* @param {?} matrix
* @return {?}
*/
function (matrix) {
/** @type {?} */
var t = this.temp;
/** @type {?} */
var v = this.values;
/** @type {?} */
var m = matrix.values;
t[M00] =
v[M00] * m[M00] + v[M01] * m[M10] + v[M02] * m[M20] + v[M03] * m[M30];
t[M01] =
v[M00] * m[M01] + v[M01] * m[M11] + v[M02] * m[M21] + v[M03] * m[M31];
t[M02] =
v[M00] * m[M02] + v[M01] * m[M12] + v[M02] * m[M22] + v[M03] * m[M32];
t[M03] =
v[M00] * m[M03] + v[M01] * m[M13] + v[M02] * m[M23] + v[M03] * m[M33];
t[M10] =
v[M10] * m[M00] + v[M11] * m[M10] + v[M12] * m[M20] + v[M13] * m[M30];
t[M11] =
v[M10] * m[M01] + v[M11] * m[M11] + v[M12] * m[M21] + v[M13] * m[M31];
t[M12] =
v[M10] * m[M02] + v[M11] * m[M12] + v[M12] * m[M22] + v[M13] * m[M32];
t[M13] =
v[M10] * m[M03] + v[M11] * m[M13] + v[M12] * m[M23] + v[M13] * m[M33];
t[M20] =
v[M20] * m[M00] + v[M21] * m[M10] + v[M22] * m[M20] + v[M23] * m[M30];
t[M21] =
v[M20] * m[M01] + v[M21] * m[M11] + v[M22] * m[M21] + v[M23] * m[M31];
t[M22] =
v[M20] * m[M02] + v[M21] * m[M12] + v[M22] * m[M22] + v[M23] * m[M32];
t[M23] =
v[M20] * m[M03] + v[M21] * m[M13] + v[M22] * m[M23] + v[M23] * m[M33];
t[M30] =
v[M30] * m[M00] + v[M31] * m[M10] + v[M32] * m[M20] + v[M33] * m[M30];
t[M31] =
v[M30] * m[M01] + v[M31] * m[M11] + v[M32] * m[M21] + v[M33] * m[M31];
t[M32] =
v[M30] * m[M02] + v[M31] * m[M12] + v[M32] * m[M22] + v[M33] * m[M32];
t[M33] =
v[M30] * m[M03] + v[M31] * m[M13] + v[M32] * m[M23] + v[M33] * m[M33];
return this.set(this.temp);
};
/**
* @param {?} matrix
* @return {?}
*/
Matrix4.prototype.multiplyLeft = /**
* @param {?} matrix
* @return {?}
*/
function (matrix) {
/** @type {?} */
var t = this.temp;
/** @type {?} */
var v = this.values;
/** @type {?} */
var m = matrix.values;
t[M00] =
m[M00] * v[M00] + m[M01] * v[M10] + m[M02] * v[M20] + m[M03] * v[M30];
t[M01] =
m[M00] * v[M01] + m[M01] * v[M11] + m[M02] * v[M21] + m[M03] * v[M31];
t[M02] =
m[M00] * v[M02] + m[M01] * v[M12] + m[M02] * v[M22] + m[M03] * v[M32];
t[M03] =
m[M00] * v[M03] + m[M01] * v[M13] + m[M02] * v[M23] + m[M03] * v[M33];
t[M10] =
m[M10] * v[M00] + m[M11] * v[M10] + m[M12] * v[M20] + m[M13] * v[M30];
t[M11] =
m[M10] * v[M01] + m[M11] * v[M11] + m[M12] * v[M21] + m[M13] * v[M31];
t[M12] =
m[M10] * v[M02] + m[M11] * v[M12] + m[M12] * v[M22] + m[M13] * v[M32];
t[M13] =
m[M10] * v[M03] + m[M11] * v[M13] + m[M12] * v[M23] + m[M13] * v[M33];
t[M20] =
m[M20] * v[M00] + m[M21] * v[M10] + m[M22] * v[M20] + m[M23] * v[M30];
t[M21] =
m[M20] * v[M01] + m[M21] * v[M11] + m[M22] * v[M21] + m[M23] * v[M31];
t[M22] =
m[M20] * v[M02] + m[M21] * v[M12] + m[M22] * v[M22] + m[M23] * v[M32];
t[M23] =
m[M20] * v[M03] + m[M21] * v[M13] + m[M22] * v[M23] + m[M23] * v[M33];
t[M30] =
m[M30] * v[M00] + m[M31] * v[M10] + m[M32] * v[M20] + m[M33] * v[M30];
t[M31] =
m[M30] * v[M01] + m[M31] * v[M11] + m[M32] * v[M21] + m[M33] * v[M31];
t[M32] =
m[M30] * v[M02] + m[M31] * v[M12] + m[M32] * v[M22] + m[M33] * v[M32];
t[M33] =
m[M30] * v[M03] + m[M31] * v[M13] + m[M32] * v[M23] + m[M33] * v[M33];
return this.set(this.temp);
};
/**
* @template THIS
* @this {THIS}
* @param {?} position
* @param {?} direction
* @param {?} up
* @return {THIS}
*/
Matrix4.prototype.lookAt = /**
* @template THIS
* @this {THIS}
* @param {?} position
* @param {?} direction
* @param {?} up
* @return {THIS}
*/
function (position, direction, up) {
Matrix4.initTemps();
/** @type {?} */
var xAxis = Matrix4.xAxis;
/** @type {?} */
var yAxis = Matrix4.yAxis;
/** @type {?} */
var zAxis = Matrix4.zAxis;
zAxis.setFrom(direction).normalize();
xAxis.setFrom(direction).normalize();
xAxis.cross(up).normalize();
yAxis
.setFrom(xAxis)
.cross(zAxis)
.normalize();
(/** @type {?} */ (this)).identity();
/** @type {?} */
var val = (/** @type {?} */ (this)).values;
val[M00] = xAxis.x;
val[M01] = xAxis.y;
val[M02] = xAxis.z;
val[M10] = yAxis.x;
val[M11] = yAxis.y;
val[M12] = yAxis.z;
val[M20] = -zAxis.x;
val[M21] = -zAxis.y;
val[M22] = -zAxis.z;
Matrix4.tmpMatrix.identity();
Matrix4.tmpMatrix.values[M03] = -position.x;
Matrix4.tmpMatrix.values[M13] = -position.y;
Matrix4.tmpMatrix.values[M23] = -position.z;
(/** @type {?} */ (this)).multiply(Matrix4.tmpMatrix);
return (/** @type {?} */ (this));
};
/**
* @return {?}
*/
Matrix4.initTemps = /**
* @return {?}
*/
function () {
if (Matrix4.xAxis === null)
Matrix4.xAxis = new Vector3();
if (Matrix4.yAxis === null)
Matrix4.yAxis = new Vector3();
if (Matrix4.zAxis === null)
Matrix4.zAxis = new Vector3();
};
Matrix4.xAxis = null;
Matrix4.yAxis = null;
Matrix4.zAxis = null;
Matrix4.tmpMatrix = new Matrix4();
return Matrix4;
}());
if (false) {
/**
* @type {?}
* @private
*/
Matrix4.xAxis;
/**
* @type {?}
* @private
*/
Matrix4.yAxis;
/**
* @type {?}
* @private
*/
Matrix4.zAxis;
/**
* @type {?}
* @private
*/
Matrix4.tmpMatrix;
/** @type {?} */
Matrix4.prototype.temp;
/** @type {?} */
Matrix4.prototype.values;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var Vector3 = /** @class */ (function () {
function Vector3(x, y, z) {
if (x === void 0) { x = 0; }
if (y === void 0) { y = 0; }
if (z === void 0) { z = 0; }
this.x = 0;
this.y = 0;
this.z = 0;
this.x = x;
this.y = y;
this.z = z;
}
/**
* @param {?} v
* @return {?}
*/
Vector3.prototype.setFrom = /**
* @param {?} v
* @return {?}
*/
function (v) {
this.x = v.x;
this.y = v.y;
this.z = v.z;
return this;
};
/**
* @param {?} x
* @param {?} y
* @param {?} z
* @return {?}
*/
Vector3.prototype.set = /**
* @param {?} x
* @param {?} y
* @param {?} z
* @return {?}
*/
function (x, y, z) {
this.x = x;
this.y = y;
this.z = z;
return this;
};
/**
* @param {?} v
* @return {?}
*/
Vector3.prototype.add = /**
* @param {?} v
* @return {?}
*/
function (v) {
this.x += v.x;
this.y += v.y;
this.z += v.z;
return this;
};
/**
* @param {?} v
* @return {?}
*/
Vector3.prototype.sub = /**
* @param {?} v
* @return {?}
*/
function (v) {
this.x -= v.x;
this.y -= v.y;
this.z -= v.z;
return this;
};
/**
* @param {?} s
* @return {?}
*/
Vector3.prototype.scale = /**
* @param {?} s
* @return {?}
*/
function (s) {
this.x *= s;
this.y *= s;
this.z *= s;
return this;
};
/**
* @return {?}
*/
Vector3.prototype.normalize = /**
* @return {?}
*/
function () {
/** @type {?} */
var len = this.length();
if (len == 0)
return this;
len = 1 / len;
this.x *= len;
this.y *= len;
this.z *= len;
return this;
};
/**
* @param {?} v
* @return {?}
*/
Vector3.prototype.cross = /**
* @param {?} v
* @return {?}
*/
function (v) {
return this.set(this.y * v.z - this.z * v.y, this.z * v.x - this.x * v.z, this.x * v.y - this.y * v.x);
};
/**
* @param {?} matrix
* @return {?}
*/
Vector3.prototype.multiply = /**
* @param {?} matrix
* @return {?}
*/
function (matrix) {
/** @type {?} */
var l_mat = matrix.values;
return this.set(this.x * l_mat[M00] +
this.y * l_mat[M01] +
this.z * l_mat[M02] +
l_mat[M03], this.x * l_mat[M10] +
this.y * l_mat[M11] +
this.z * l_mat[M12] +
l_mat[M13], this.x * l_mat[M20] +
this.y * l_mat[M21] +
this.z * l_mat[M22] +
l_mat[M23]);
};
/**
* @param {?} matrix
* @return {?}
*/
Vector3.prototype.project = /**
* @param {?} matrix
* @return {?}
*/
function (matrix) {
/** @type {?} */
var l_mat = matrix.values;
/** @type {?} */
var l_w = 1 /
(this.x * l_mat[M30] +
this.y * l_mat[M31] +
this.z * l_mat[M32] +
l_mat[M33]);
return this.set((this.x * l_mat[M00] +
this.y * l_mat[M01] +
this.z * l_mat[M02] +
l_mat[M03]) *
l_w, (this.x * l_mat[M10] +
this.y * l_mat[M11] +
this.z * l_mat[M12] +
l_mat[M13]) *
l_w, (this.x * l_mat[M20] +
this.y * l_mat[M21] +
this.z * l_mat[M22] +
l_mat[M23]) *
l_w);
};
/**
* @param {?} v
* @return {?}
*/
Vector3.prototype.dot = /**
* @param {?} v
* @return {?}
*/
function (v) {
return this.x * v.x + this.y * v.y + this.z * v.z;
};
/**
* @return {?}
*/
Vector3.prototype.length = /**
* @return {?}
*/
function () {
return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
};
/**
* @param {?} v
* @return {?}
*/
Vector3.prototype.distance = /**
* @param {?} v
* @return {?}
*/
function (v) {
/** @type {?} */
var a = v.x - this.x;
/** @type {?} */
var b = v.y - this.y;
/** @type {?} */
var c = v.z - this.z;
return Math.sqrt(a * a + b * b + c * c);
};
return Vector3;
}());
if (false) {
/** @type {?} */
Vector3.prototype.x;
/** @type {?} */
Vector3.prototype.y;
/** @type {?} */
Vector3.prototype.z;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var OrthoCamera = /** @class */ (function () {
function OrthoCamera(viewportWidth, viewportHeight) {
this.position = new Vector3(0, 0, 0);
this.direction = new Vector3(0, 0, -1);
this.up = new Vector3(0, 1, 0);
this.near = 0;
this.far = 100;
this.zoom = 1;
this.viewportWidth = 0;
this.viewportHeight = 0;
this.projectionView = new Matrix4();
this.inverseProjectionView = new Matrix4();
this.projection = new Matrix4();
this.view = new Matrix4();
this.tmp = new Vector3();
this.viewportWidth = viewportWidth;
this.viewportHeight = viewportHeight;
this.update();
}
/**
* @return {?}
*/
OrthoCamera.prototype.update = /**
* @return {?}
*/
function () {
/** @type {?} */
var projection = this.projection;
/** @type {?} */
var view = this.view;
/** @type {?} */
var projectionView = this.projectionView;
/** @type {?} */
var inverseProjectionView = this.inverseProjectionView;
/** @type {?} */
var zoom = this.zoom;
/** @type {?} */
var viewportWidth = this.viewportWidth;
/** @type {?} */
var viewportHeight = this.viewportHeight;
projection.ortho(zoom * (-viewportWidth / 2), zoom * (viewportWidth / 2), zoom * (-viewportHeight / 2), zoom * (viewportHeight / 2), this.near, this.far);
view.lookAt(this.position, this.direction, this.up);
projectionView.set(projection.values);
projectionView.multiply(view);
inverseProjectionView.set(projectionView.values).invert();
};
/**
* @param {?} screenCoords
* @param {?} screenWidth
* @param {?} screenHeight
* @return {?}
*/
OrthoCamera.prototype.screenToWorld = /**
* @param {?} screenCoords
* @param {?} screenWidth
* @param {?} screenHeight
* @return {?}
*/
function (screenCoords, screenWidth, screenHeight) {
/** @type {?} */
var x = screenCoords.x;
/** @type {?} */
var y = screenHeight - screenCoords.y - 1;
/** @type {?} */
var tmp = this.tmp;
tmp.x = (2 * x) / screenWidth - 1;
tmp.y = (2 * y) / screenHeight - 1;
tmp.z = 2 * screenCoords.z - 1;
tmp.project(this.inverseProjectionView);
screenCoords.set(tmp.x, tmp.y, tmp.z);
return screenCoords;
};
/**
* @param {?} viewportWidth
* @param {?} viewportHeight
* @return {?}
*/
OrthoCamera.prototype.setViewport = /**
* @param {?} viewportWidth
* @param {?} viewportHeight
* @return {?}
*/
function (viewportWidth, viewportHeight) {
this.viewportWidth = viewportWidth;
this.viewportHeight = viewportHeight;
};
return OrthoCamera;
}());
if (false) {
/** @type {?} */
OrthoCamera.prototype.position;
/** @type {?} */
OrthoCamera.prototype.direction;
/** @type {?} */
OrthoCamera.prototype.up;
/** @type {?} */
OrthoCamera.prototype.near;
/** @type {?} */
OrthoCamera.prototype.far;
/** @type {?} */
OrthoCamera.prototype.zoom;
/** @type {?} */
OrthoCamera.prototype.viewportWidth;
/** @type {?} */
OrthoCamera.prototype.viewportHeight;
/** @type {?} */
OrthoCamera.prototype.projectionView;
/** @type {?} */
OrthoCamera.prototype.inverseProjectionView;
/** @type {?} */
OrthoCamera.prototype.projection;
/** @type {?} */
OrthoCamera.prototype.view;
/**
* @type {?}
* @private
*/
OrthoCamera.prototype.tmp;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/******************************************************************************
* Spine Runtimes License Agreement
* Last updated May 1, 2019. Replaces all prior versions.
*
* Copyright (c) 2013-2019, Esoteric Software LLC
*
* Integration of the Spine Runtimes into software or otherwise creating
* derivative works of the Spine Runtimes is permitted under the terms and
* conditions of Section 2 of the Spine Editor License Agreement:
* http://esotericsoftware.com/spine-editor-license
*
* Otherwise, it is permitted to integrate the Spine Runtimes into software
* or otherwise create derivative works of the Spine Runtimes (collectively,
* "Products"), provided that each user of the Products must obtain their own
* Spine Editor license and redistribution of the Products in any form must
* include this license and copyright notice.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
* INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
/**
* @record
* @template T
*/
function Map() { }
var IntSet = /** @class */ (function () {
function IntSet() {
this.array = new Array();
}
/**
* @param {?} value
* @return {?}
*/
IntSet.prototype.add = /**
* @param {?} value
* @return {?}
*/
function (value) {
/** @type {?} */
var contains = this.contains(value);
this.array[value | 0] = value | 0;
return !contains;
};
/**
* @param {?} value
* @return {?}
*/
IntSet.prototype.contains = /**
* @param {?} value
* @return {?}
*/
function (value) {
return this.array[value | 0] != undefined;
};
/**
* @param {?} value
* @return {?}
*/
IntSet.prototype.remove = /**
* @param {?} value
* @return {?}
*/
function (value) {
this.array[value | 0] = undefined;
};
/**
* @return {?}
*/
IntSet.prototype.clear = /**
* @return {?}
*/
function () {
this.array.length = 0;
};
return IntSet;
}());
if (false) {
/** @type {?} */
IntSet.prototype.array;
}
/**
* @record
*/
function Disposable() { }
if (false) {
/**
* @return {?}
*/
Disposable.prototype.dispose = function () { };
}
/**
* @record
*/
function Restorable() { }
if (false) {
/**
* @return {?}
*/
Restorable.prototype.restore = function () { };
}
var Color = /** @class */ (function () {
function Color(r, g, b, a) {
if (r === void 0) { r = 0; }
if (g === void 0) { g = 0; }
if (b === void 0) { b = 0; }
if (a === void 0) { a = 0; }
this.r = r;
this.g = g;
this.b = b;
this.a = a;
}
/**
* @template THIS
* @this {THIS}
* @param {?} r
* @param {?} g
* @param {?} b
* @param {?} a
* @return {THIS}
*/
Color.prototype.set = /**
* @template THIS
* @this {THIS}
* @param {?} r
* @param {?} g
* @param {?} b
* @param {?} a
* @return {THIS}
*/
function (r, g, b, a) {
(/** @type {?} */ (this)).r = r;
(/** @type {?} */ (this)).g = g;
(/** @type {?} */ (this)).b = b;
(/** @type {?} */ (this)).a = a;
(/** @type {?} */ (this)).clamp();
return (/** @type {?} */ (this));
};
/**
* @template THIS
* @this {THIS}
* @param {?} c
* @return {THIS}
*/
Color.prototype.setFromColor = /**
* @template THIS
* @this {THIS}
* @param {?} c
* @return {THIS}
*/
function (c) {
(/** @type {?} */ (this)).r = c.r;
(/** @type {?} */ (this)).g = c.g;
(/** @type {?} */ (this)).b = c.b;
(/** @type {?} */ (this)).a = c.a;
return (/** @type {?} */ (this));
};
/**
* @template THIS
* @this {THIS}
* @param {?} hex
* @return {THIS}
*/
Color.prototype.setFromString = /**
* @template THIS
* @this {THIS}
* @param {?} hex
* @return {THIS}
*/
function (hex) {
hex = hex.charAt(0) == "#" ? hex.substr(1) : hex;
(/** @type {?} */ (this)).r = parseInt(hex.substr(0, 2), 16) / 255.0;
(/** @type {?} */ (this)).g = parseInt(hex.substr(2, 2), 16) / 255.0;
(/** @type {?} */ (this)).b = parseInt(hex.substr(4, 2), 16) / 255.0;
(/** @type {?} */ (this)).a = (hex.length != 8 ? 255 : parseInt(hex.substr(6, 2), 16)) / 255.0;
return (/** @type {?} */ (this));
};
/**
* @template THIS
* @this {THIS}
* @param {?} r
* @param {?} g
* @param {?} b
* @param {?} a
* @return {THIS}
*/
Color.prototype.add = /**
* @template THIS
* @this {THIS}
* @param {?} r
* @param {?} g
* @param {?} b
* @param {?} a
* @return {THIS}
*/
function (r, g, b, a) {
(/** @type {?} */ (this)).r += r;
(/** @type {?} */ (this)).g += g;
(/** @type {?} */ (this)).b += b;
(/** @type {?} */ (this)).a += a;
(/** @type {?} */ (this)).clamp();
return (/** @type {?} */ (this));
};
/**
* @template THIS
* @this {THIS}
* @return {THIS}
*/
Color.prototype.clamp = /**
* @template THIS
* @this {THIS}
* @return {THIS}
*/
function () {
if ((/** @type {?} */ (this)).r < 0)
(/** @type {?} */ (this)).r = 0;
else if ((/** @type {?} */ (this)).r > 1)
(/** @type {?} */ (this)).r = 1;
if ((/** @type {?} */ (this)).g < 0)
(/** @type {?} */ (this)).g = 0;
else if ((/** @type {?} */ (this)).g > 1)
(/** @type {?} */ (this)).g = 1;
if ((/** @type {?} */ (this)).b < 0)
(/** @type {?} */ (this)).b = 0;
else if ((/** @type {?} */ (this)).b > 1)
(/** @type {?} */ (this)).b = 1;
if ((/** @type {?} */ (this)).a < 0)
(/** @type {?} */ (this)).a = 0;
else if ((/** @type {?} */ (this)).a > 1)
(/** @type {?} */ (this)).a = 1;
return (/** @type {?} */ (this));
};
/**
* @param {?} color
* @param {?} value
* @return {?}
*/
Color.rgba8888ToColor = /**
* @param {?} color
* @param {?} value
* @return {?}
*/
function (color, value) {
color.r = ((value & 0xff000000) >>> 24) / 255;
color.g = ((value & 0x00ff0000) >>> 16) / 255;
color.b = ((value & 0x0000ff00) >>> 8) / 255;
color.a = (value & 0x000000ff) / 255;
};
/**
* @param {?} color
* @param {?} value
* @return {?}
*/
Color.rgb888ToColor = /**
* @param {?} color
* @param {?} value
* @return {?}
*/
function (color, value) {
color.r = ((value & 0x00ff0000) >>> 16) / 255;
color.g = ((value & 0x0000ff00) >>> 8) / 255;
color.b = (value & 0x000000ff) / 255;
};
Color.WHITE = new Color(1, 1, 1, 1);
Color.RED = new Color(1, 0, 0, 1);
Color.GREEN = new Color(0, 1, 0, 1);
Color.BLUE = new Color(0, 0, 1, 1);
Color.MAGENTA = new Color(1, 0, 1, 1);
return Color;
}());
if (false) {
/** @type {?} */
Color.WHITE;
/** @type {?} */
Color.RED;
/** @type {?} */
Color.GREEN;
/** @type {?} */
Color.BLUE;
/** @type {?} */
Color.MAGENTA;
/** @type {?} */
Color.prototype.r;
/** @type {?} */
Color.prototype.g;
/** @type {?} */
Color.prototype.b;
/** @type {?} */
Color.prototype.a;
}
var MathUtils = /** @class */ (function () {
function MathUtils() {
}
/**
* @param {?} value
* @param {?} min
* @param {?} max
* @return {?}
*/
MathUtils.clamp = /**
* @param {?} value
* @param {?} min
* @param {?} max
* @return {?}
*/
function (value, min, max) {
if (value < min)
return min;
if (value > max)
return max;
return value;
};
/**
* @param {?} degrees
* @return {?}
*/
MathUtils.cosDeg = /**
* @param {?} degrees
* @return {?}
*/
function (degrees) {
return Math.cos(degrees * MathUtils.degRad);
};
/**
* @param {?} degrees
* @return {?}
*/
MathUtils.sinDeg = /**
* @param {?} degrees
* @return {?}
*/
function (degrees) {
return Math.sin(degrees * MathUtils.degRad);
};
/**
* @param {?} value
* @return {?}
*/
MathUtils.signum = /**
* @param {?} value
* @return {?}
*/
function (value) {
return value > 0 ? 1 : value < 0 ? -1 : 0;
};
/**
* @param {?} x
* @return {?}
*/
MathUtils.toInt = /**
* @param {?} x
* @return {?}
*/
function (x) {
return x > 0 ? Math.floor(x) : Math.ceil(x);
};
/**
* @param {?} x
* @return {?}
*/
MathUtils.cbrt = /**
* @param {?} x
* @return {?}
*/
function (x) {
/** @type {?} */
var y = Math.pow(Math.abs(x), 1 / 3);
return x < 0 ? -y : y;
};
/**
* @param {?} min
* @param {?} max
* @return {?}
*/
MathUtils.randomTriangular = /**
* @param {?} min
* @param {?} max
* @return {?}
*/
function (min, max) {
return MathUtils.randomTriangularWith(min, max, (min + max) * 0.5);
};
/**
* @param {?} min
* @param {?} max
* @param {?} mode
* @return {?}
*/
MathUtils.randomTriangularWith = /**
* @param {?} min
* @param {?} max
* @param {?} mode
* @return {?}
*/
function (min, max, mode) {
/** @type {?} */
var u = Math.random();
/** @type {?} */
var d = max - min;
if (u <= (mode - min) / d)
return min + Math.sqrt(u * d * (mode - min));
return max - Math.sqrt((1 - u) * d * (max - mode));
};
MathUtils.PI = 3.1415927;
MathUtils.PI2 = MathUtils.PI * 2;
MathUtils.radiansToDegrees = 180 / MathUtils.PI;
MathUtils.radDeg = MathUtils.radiansToDegrees;
MathUtils.degreesToRadians = MathUtils.PI / 180;
MathUtils.degRad = MathUtils.degreesToRadians;
return MathUtils;
}());
if (false) {
/** @type {?} */
MathUtils.PI;
/** @type {?} */
MathUtils.PI2;
/** @type {?} */
MathUtils.radiansToDegrees;
/** @type {?} */
MathUtils.radDeg;
/** @type {?} */
MathUtils.degreesToRadians;
/** @type {?} */
MathUtils.degRad;
}
/**
* @abstract
*/
var /**
* @abstract
*/
Interpolation = /** @class */ (function () {
function Interpolation() {
}
/**
* @param {?} start
* @param {?} end
* @param {?} a
* @return {?}
*/
Interpolation.prototype.apply = /**
* @param {?} start
* @param {?} end
* @param {?} a
* @return {?}
*/
function (start, end, a) {
return start + (end - start) * this.applyInternal(a);
};
return Interpolation;
}());
if (false) {
/**
* @abstract
* @protected
* @param {?} a
* @return {?}
*/
Interpolation.prototype.applyInternal = function (a) { };
}
var Pow = /** @class */ (function (_super) {
__extends(Pow, _super);
function Pow(power) {
var _this = _super.call(this) || this;
_this.power = 2;
_this.power = power;
return _this;
}
/**
* @param {?} a
* @return {?}
*/
Pow.prototype.applyInternal = /**
* @param {?} a
* @return {?}
*/
function (a) {
if (a <= 0.5)
return Math.pow(a * 2, this.power) / 2;
return (Math.pow((a - 1) * 2, this.power) / (this.power % 2 == 0 ? -2 : 2) + 1);
};
return Pow;
}(Interpolation));
if (false) {
/**
* @type {?}
* @protected
*/
Pow.prototype.power;
}
var PowOut = /** @class */ (function (_super) {
__extends(PowOut, _super);
function PowOut(power) {
return _super.call(this, power) || this;
}
/**
* @param {?} a
* @return {?}
*/
PowOut.prototype.applyInternal = /**
* @param {?} a
* @return {?}
*/
function (a) {
return Math.pow(a - 1, this.power) * (this.power % 2 == 0 ? -1 : 1) + 1;
};
return PowOut;
}(Pow));
var Utils = /** @class */ (function () {
function Utils() {
}
/**
* @template T
* @param {?} source
* @param {?} sourceStart
* @param {?} dest
* @param {?} destStart
* @param {?} numElements
* @return {?}
*/
Utils.arrayCopy = /**
* @template T
* @param {?} source
* @param {?} sourceStart
* @param {?} dest
* @param {?} destStart
* @param {?} numElements
* @return {?}
*/
function (source, sourceStart, dest, destStart, numElements) {
for (var i = sourceStart, j = destStart; i < sourceStart + numElements; i++, j++) {
dest[j] = source[i];
}
};
/**
* @template T
* @param {?} array
* @param {?} size
* @param {?=} value
* @return {?}
*/
Utils.setArraySize = /**
* @template T
* @param {?} array
* @param {?} size
* @param {?=} value
* @return {?}
*/
function (array, size, value) {
if (value === void 0) { value = 0; }
/** @type {?} */
var oldSize = array.length;
if (oldSize == size)
return array;
array.length = size;
if (oldSize < size) {
for (var i = oldSize; i < size; i++)
array[i] = value;
}
return array;
};
/**
* @template T
* @param {?} array
* @param {?} size
* @param {?=} value
* @return {?}
*/
Utils.ensureArrayCapacity = /**
* @template T
* @param {?} array
* @param {?} size
* @param {?=} value
* @return {?}
*/
function (array, size, value) {
if (value === void 0) { value = 0; }
if (array.length >= size)
return array;
return Utils.setArraySize(array, size, value);
};
/**
* @template T
* @param {?} size
* @param {?} defaultValue
* @return {?}
*/
Utils.newArray = /**
* @template T
* @param {?} size
* @param {?} defaultValue
* @return {?}
*/
function (size, defaultValue) {
/** @type {?} */
var array = new Array(size);
for (var i = 0; i < size; i++)
array[i] = defaultValue;
return array;
};
/**
* @param {?} size
* @return {?}
*/
Utils.newFloatArray = /**
* @param {?} size
* @return {?}
*/
function (size) {
if (Utils.SUPPORTS_TYPED_ARRAYS) {
return new Float32Array(size);
}
else {
/** @type {?} */
var array = new Array(size);
for (var i = 0; i < array.length; i++)
array[i] = 0;
return array;
}
};
/**
* @param {?} size
* @return {?}
*/
Utils.newShortArray = /**
* @param {?} size
* @return {?}
*/
function (size) {
if (Utils.SUPPORTS_TYPED_ARRAYS) {
return new Int16Array(size);
}
else {
/** @type {?} */
var array = new Array(size);
for (var i = 0; i < array.length; i++)
array[i] = 0;
return array;
}
};
/**
* @param {?} array
* @return {?}
*/
Utils.toFloatArray = /**
* @param {?} array
* @return {?}
*/
function (array) {
return Utils.SUPPORTS_TYPED_ARRAYS ? new Float32Array(array) : array;
};
/**
* @param {?} value
* @return {?}
*/
Utils.toSinglePrecision = /**
* @param {?} value
* @return {?}
*/
function (value) {
return Utils.SUPPORTS_TYPED_ARRAYS ? Math.fround(value) : value;
};
// This function is used to fix WebKit 602 specific issue described at http://esotericsoftware.com/forum/iOS-10-disappearing-graphics-10109
// This function is used to fix WebKit 602 specific issue described at http://esotericsoftware.com/forum/iOS-10-disappearing-graphics-10109
/**
* @param {?} alpha
* @param {?} blend
* @return {?}
*/
Utils.webkit602BugfixHelper =
// This function is used to fix WebKit 602 specific issue described at http://esotericsoftware.com/forum/iOS-10-disappearing-graphics-10109
/**
* @param {?} alpha
* @param {?} blend
* @return {?}
*/
function (alpha, blend) { };
/**
* @template T
* @param {?} array
* @param {?} element
* @param {?=} identity
* @return {?}
*/
Utils.contains = /**
* @template T
* @param {?} array
* @param {?} element
* @param {?=} identity
* @return {?}
*/
function (array, element, identity) {
if (identity === void 0) { identity = true; }
for (var i = 0; i < array.length; i++) {
if (array[i] == element)
return true;
}
return false;
};
Utils.SUPPORTS_TYPED_ARRAYS = typeof Float32Array !== "undefined";
return Utils;
}());
if (false) {
/** @type {?} */
Utils.SUPPORTS_TYPED_ARRAYS;
}
var DebugUtils = /** @class */ (function () {
function DebugUtils() {
}
/**
* @param {?} skeleton
* @return {?}
*/
DebugUtils.logBones = /**
* @param {?} skeleton
* @return {?}
*/
function (skeleton) {
for (var i = 0; i < skeleton.bones.length; i++) {
/** @type {?} */
var bone = skeleton.bones[i];
console.log(bone.data.name +
", " +
bone.a +
", " +
bone.b +
", " +
bone.c +
", " +
bone.d +
", " +
bone.worldX +
", " +
bone.worldY);
}
};
return DebugUtils;
}());
/**
* @template T
*/
var /**
* @template T
*/
Pool = /** @class */ (function () {
function Pool(instantiator) {
this.items = new Array();
this.instantiator = instantiator;
}
/**
* @return {?}
*/
Pool.prototype.obtain = /**
* @return {?}
*/
function () {
return this.items.length > 0 ? this.items.pop() : this.instantiator();
};
/**
* @param {?} item
* @return {?}
*/
Pool.prototype.free = /**
* @param {?} item
* @return {?}
*/
function (item) {
if (((/** @type {?} */ (item))).reset)
((/** @type {?} */ (item))).reset();
this.items.push(item);
};
/**
* @param {?} items
* @return {?}
*/
Pool.prototype.freeAll = /**
* @param {?} items
* @return {?}
*/
function (items) {
for (var i = 0; i < items.length; i++) {
if (((/** @type {?} */ (items[i]))).reset)
((/** @type {?} */ (items[i]))).reset();
this.items[i] = items[i];
}
};
/**
* @return {?}
*/
Pool.prototype.clear = /**
* @return {?}
*/
function () {
this.items.length = 0;
};
return Pool;
}());
if (false) {
/**
* @type {?}
* @private
*/
Pool.prototype.items;
/**
* @type {?}
* @private
*/
Pool.prototype.instantiator;
}
var Vector2 = /** @class */ (function () {
function Vector2(x, y) {
if (x === void 0) { x = 0; }
if (y === void 0) { y = 0; }
this.x = x;
this.y = y;
}
/**
* @param {?} x
* @param {?} y
* @return {?}
*/
Vector2.prototype.set = /**
* @param {?} x
* @param {?} y
* @return {?}
*/
function (x, y) {
this.x = x;
this.y = y;
return this;
};
/**
* @return {?}
*/
Vector2.prototype.length = /**
* @return {?}
*/
function () {
/** @type {?} */
var x = this.x;
/** @type {?} */
var y = this.y;
return Math.sqrt(x * x + y * y);
};
/**
* @template THIS
* @this {THIS}
* @return {THIS}
*/
Vector2.prototype.normalize = /**
* @template THIS
* @this {THIS}
* @return {THIS}
*/
function () {
/** @type {?} */
var len = (/** @type {?} */ (this)).length();
if (len != 0) {
(/** @type {?} */ (this)).x /= len;
(/** @type {?} */ (this)).y /= len;
}
return (/** @type {?} */ (this));
};
return Vector2;
}());
if (false) {
/** @type {?} */
Vector2.prototype.x;
/** @type {?} */
Vector2.prototype.y;
}
var TimeKeeper = /** @class */ (function () {
function TimeKeeper() {
this.maxDelta = 0.064;
this.framesPerSecond = 0;
this.delta = 0;
this.totalTime = 0;
this.lastTime = Date.now() / 1000;
this.frameCount = 0;
this.frameTime = 0;
}
/**
* @return {?}
*/
TimeKeeper.prototype.update = /**
* @return {?}
*/
function () {
/** @type {?} */
var now = Date.now() / 1000;
this.delta = now - this.lastTime;
this.frameTime += this.delta;
this.totalTime += this.delta;
if (this.delta > this.maxDelta)
this.delta = this.maxDelta;
this.lastTime = now;
this.frameCount++;
if (this.frameTime > 1) {
this.framesPerSecond = this.frameCount / this.frameTime;
this.frameTime = 0;
this.frameCount = 0;
}
};
return TimeKeeper;
}());
if (false) {
/** @type {?} */
TimeKeeper.prototype.maxDelta;
/** @type {?} */
TimeKeeper.prototype.framesPerSecond;
/** @type {?} */
TimeKeeper.prototype.delta;
/** @type {?} */
TimeKeeper.prototype.totalTime;
/**
* @type {?}
* @private
*/
TimeKeeper.prototype.lastTime;
/**
* @type {?}
* @private
*/
TimeKeeper.prototype.frameCount;
/**
* @type {?}
* @private
*/
TimeKeeper.prototype.frameTime;
}
/**
* @record
* @template T
*/
function ArrayLike() { }
if (false) {
/** @type {?} */
ArrayLike.prototype.length;
/* Skipping unhandled member: [n: number]: T;*/
}
var WindowedMean = /** @class */ (function () {
function WindowedMean(windowSize) {
if (windowSize === void 0) { windowSize = 32; }
this.addedValues = 0;
this.lastValue = 0;
this.mean = 0;
this.dirty = true;
this.values = new Array(windowSize);
}
/**
* @return {?}
*/
WindowedMean.prototype.hasEnoughData = /**
* @return {?}
*/
function () {
return this.addedValues >= this.values.length;
};
/**
* @param {?} value
* @return {?}
*/
WindowedMean.prototype.addValue = /**
* @param {?} value
* @return {?}
*/
function (value) {
if (this.addedValues < this.values.length)
this.addedValues++;
this.values[this.lastValue++] = value;
if (this.lastValue > this.values.length - 1)
this.lastValue = 0;
this.dirty = true;
};
/**
* @return {?}
*/
WindowedMean.prototype.getMean = /**
* @return {?}
*/
function () {
if (this.hasEnoughData()) {
if (this.dirty) {
/** @type {?} */
var mean = 0;
for (var i = 0; i < this.values.length; i++) {
mean += this.values[i];
}
this.mean = mean / this.values.length;
this.dirty = false;
}
return this.mean;
}
else {
return 0;
}
};
return WindowedMean;
}());
if (false) {
/** @type {?} */
WindowedMean.prototype.values;
/** @type {?} */
WindowedMean.prototype.addedValues;
/** @type {?} */
WindowedMean.prototype.lastValue;
/** @type {?} */
WindowedMean.prototype.mean;
/** @type {?} */
WindowedMean.prototype.dirty;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var Input = /** @class */ (function () {
function Input(element) {
this.lastX = 0;
this.lastY = 0;
this.buttonDown = false;
this.currTouch = null;
this.touchesPool = new Pool((/**
* @return {?}
*/
function () {
return new Touch(0, 0, 0);
}));
this.listeners = new Array();
this.element = element;
this.setupCallbacks(element);
}
/**
* @private
* @param {?} element
* @return {?}
*/
Input.prototype.setupCallbacks = /**
* @private
* @param {?} element
* @return {?}
*/
function (element) {
var _this = this;
/** @type {?} */
var mouseDown = (/**
* @param {?} ev
* @return {?}
*/
function (ev) {
if (ev instanceof MouseEvent) {
/** @type {?} */
var rect = element.getBoundingClientRect();
/** @type {?} */
var x = ev.clientX - rect.left;
/** @type {?} */
var y = ev.clientY - rect.top;
/** @type {?} */
var listeners = _this.listeners;
for (var i = 0; i < listeners.length; i++) {
listeners[i].down(x, y);
}
_this.lastX = x;
_this.lastY = y;
_this.buttonDown = true;
document.addEventListener("mousemove", mouseMove);
document.addEventListener("mouseup", mouseUp);
}
});
/** @type {?} */
var mouseMove = (/**
* @param {?} ev
* @return {?}
*/
function (ev) {
if (ev instanceof MouseEvent) {
/** @type {?} */
var rect = element.getBoundingClientRect();
/** @type {?} */
var x = ev.clientX - rect.left;
/** @type {?} */
var y = ev.clientY - rect.top;
/** @type {?} */
var listeners = _this.listeners;
for (var i = 0; i < listeners.length; i++) {
if (_this.buttonDown) {
listeners[i].dragged(x, y);
}
else {
listeners[i].moved(x, y);
}
}
_this.lastX = x;
_this.lastY = y;
}
});
/** @type {?} */
var mouseUp = (/**
* @param {?} ev
* @return {?}
*/
function (ev) {
if (ev instanceof MouseEvent) {
/** @type {?} */
var rect = element.getBoundingClientRect();
/** @type {?} */
var x = ev.clientX - rect.left;
/** @type {?} */
var y = ev.clientY - rect.top;
/** @type {?} */
var listeners = _this.listeners;
for (var i = 0; i < listeners.length; i++) {
listeners[i].up(x, y);
}
_this.lastX = x;
_this.lastY = y;
_this.buttonDown = false;
document.removeEventListener("mousemove", mouseMove);
document.removeEventListener("mouseup", mouseUp);
}
});
element.addEventListener("mousedown", mouseDown, true);
element.addEventListener("mousemove", mouseMove, true);
element.addEventListener("mouseup", mouseUp, true);
element.addEventListener("touchstart", (/**
* @param {?} ev
* @return {?}
*/
function (ev) {
if (_this.currTouch != null)
return;
/** @type {?} */
var touches = ev.changedTouches;
for (var i = 0; i < touches.length; i++) {
/** @type {?} */
var touch = touches[i];
/** @type {?} */
var rect = element.getBoundingClientRect();
/** @type {?} */
var x = touch.clientX - rect.left;
/** @type {?} */
var y = touch.clientY - rect.top;
_this.currTouch = _this.touchesPool.obtain();
_this.currTouch.identifier = touch.identifier;
_this.currTouch.x = x;
_this.currTouch.y = y;
break;
}
/** @type {?} */
var listeners = _this.listeners;
for (var i_1 = 0; i_1 < listeners.length; i_1++) {
listeners[i_1].down(_this.currTouch.x, _this.currTouch.y);
}
console.log("Start " + _this.currTouch.x + ", " + _this.currTouch.y);
_this.lastX = _this.currTouch.x;
_this.lastY = _this.currTouch.y;
_this.buttonDown = true;
ev.preventDefault();
}), false);
element.addEventListener("touchend", (/**
* @param {?} ev
* @return {?}
*/
function (ev) {
/** @type {?} */
var touches = ev.changedTouches;
for (var i = 0; i < touches.length; i++) {
/** @type {?} */
var touch = touches[i];
if (_this.currTouch.identifier === touch.identifier) {
/** @type {?} */
var rect = element.getBoundingClientRect();
/** @type {?} */
var x = (_this.currTouch.x = touch.clientX - rect.left);
/** @type {?} */
var y = (_this.currTouch.y = touch.clientY - rect.top);
_this.touchesPool.free(_this.currTouch);
/** @type {?} */
var listeners = _this.listeners;
for (var i_2 = 0; i_2 < listeners.length; i_2++) {
listeners[i_2].up(x, y);
}
console.log("End " + x + ", " + y);
_this.lastX = x;
_this.lastY = y;
_this.buttonDown = false;
_this.currTouch = null;
break;
}
}
ev.preventDefault();
}), false);
element.addEventListener("touchcancel", (/**
* @param {?} ev
* @return {?}
*/
function (ev) {
/** @type {?} */
var touches = ev.changedTouches;
for (var i = 0; i < touches.length; i++) {
/** @type {?} */
var touch = touches[i];
if (_this.currTouch.identifier === touch.identifier) {
/** @type {?} */
var rect = element.getBoundingClientRect();
/** @type {?} */
var x = (_this.currTouch.x = touch.clientX - rect.left);
/** @type {?} */
var y = (_this.currTouch.y = touch.clientY - rect.top);
_this.touchesPool.free(_this.currTouch);
/** @type {?} */
var listeners = _this.listeners;
for (var i_3 = 0; i_3 < listeners.length; i_3++) {
listeners[i_3].up(x, y);
}
console.log("End " + x + ", " + y);
_this.lastX = x;
_this.lastY = y;
_this.buttonDown = false;
_this.currTouch = null;
break;
}
}
ev.preventDefault();
}), false);
element.addEventListener("touchmove", (/**
* @param {?} ev
* @return {?}
*/
function (ev) {
if (_this.currTouch == null)
return;
/** @type {?} */
var touches = ev.changedTouches;
for (var i = 0; i < touches.length; i++) {
/** @type {?} */
var touch = touches[i];
if (_this.currTouch.identifier === touch.identifier) {
/** @type {?} */
var rect = element.getBoundingClientRect();
/** @type {?} */
var x = touch.clientX - rect.left;
/** @type {?} */
var y = touch.clientY - rect.top;
/** @type {?} */
var listeners = _this.listeners;
for (var i_4 = 0; i_4 < listeners.length; i_4++) {
listeners[i_4].dragged(x, y);
}
console.log("Drag " + x + ", " + y);
_this.lastX = _this.currTouch.x = x;
_this.lastY = _this.currTouch.y = y;
break;
}
}
ev.preventDefault();
}), false);
};
/**
* @param {?} listener
* @return {?}
*/
Input.prototype.addListener = /**
* @param {?} listener
* @return {?}
*/
function (listener) {
this.listeners.push(listener);
};
/**
* @param {?} listener
* @return {?}
*/
Input.prototype.removeListener = /**
* @param {?} listener
* @return {?}
*/
function (listener) {
/** @type {?} */
var idx = this.listeners.indexOf(listener);
if (idx > -1) {
this.listeners.splice(idx, 1);
}
};
return Input;
}());
if (false) {
/** @type {?} */
Input.prototype.element;
/** @type {?} */
Input.prototype.lastX;
/** @type {?} */
Input.prototype.lastY;
/** @type {?} */
Input.prototype.buttonDown;
/** @type {?} */
Input.prototype.currTouch;
/** @type {?} */
Input.prototype.touchesPool;
/**
* @type {?}
* @private
*/
Input.prototype.listeners;
}
var Touch = /** @class */ (function () {
function Touch(identifier, x, y) {
this.identifier = identifier;
this.x = x;
this.y = y;
}
return Touch;
}());
if (false) {
/** @type {?} */
Touch.prototype.identifier;
/** @type {?} */
Touch.prototype.x;
/** @type {?} */
Touch.prototype.y;
}
/**
* @record
*/
function InputListener() { }
if (false) {
/**
* @param {?} x
* @param {?} y
* @return {?}
*/
InputListener.prototype.down = function (x, y) { };
/**
* @param {?} x
* @param {?} y
* @return {?}
*/
InputListener.prototype.up = function (x, y) { };
/**
* @param {?} x
* @param {?} y
* @return {?}
*/
InputListener.prototype.moved = function (x, y) { };
/**
* @param {?} x
* @param {?} y
* @return {?}
*/
InputListener.prototype.dragged = function (x, y) { };
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var Shader = /** @class */ (function () {
function Shader(context, vertexShader, fragmentShader) {
this.vertexShader = vertexShader;
this.fragmentShader = fragmentShader;
this.vs = null;
this.fs = null;
this.program = null;
this.tmp2x2 = new Float32Array(2 * 2);
this.tmp3x3 = new Float32Array(3 * 3);
this.tmp4x4 = new Float32Array(4 * 4);
this.vsSource = vertexShader;
this.fsSource = fragmentShader;
this.context =
context instanceof ManagedWebGLRenderingContext
? context
: new ManagedWebGLRenderingContext(context);
this.context.addRestorable(this);
this.compile();
}
/**
* @return {?}
*/
Shader.prototype.getProgram = /**
* @return {?}
*/
function () {
return this.program;
};
/**
* @return {?}
*/
Shader.prototype.getVertexShader = /**
* @return {?}
*/
function () {
return this.vertexShader;
};
/**
* @return {?}
*/
Shader.prototype.getFragmentShader = /**
* @return {?}
*/
function () {
return this.fragmentShader;
};
/**
* @return {?}
*/
Shader.prototype.getVertexShaderSource = /**
* @return {?}
*/
function () {
return this.vsSource;
};
/**
* @return {?}
*/
Shader.prototype.getFragmentSource = /**
* @return {?}
*/
function () {
return this.fsSource;
};
/**
* @private
* @return {?}
*/
Shader.prototype.compile = /**
* @private
* @return {?}
*/
function () {
/** @type {?} */
var gl = this.context.gl;
try {
this.vs = this.compileShader(gl.VERTEX_SHADER, this.vertexShader);
this.fs = this.compileShader(gl.FRAGMENT_SHADER, this.fragmentShader);
this.program = this.compileProgram(this.vs, this.fs);
}
catch (e) {
this.dispose();
throw e;
}
};
/**
* @private
* @param {?} type
* @param {?} source
* @return {?}
*/
Shader.prototype.compileShader = /**
* @private
* @param {?} type
* @param {?} source
* @return {?}
*/
function (type, source) {
/** @type {?} */
var gl = this.context.gl;
/** @type {?} */
var shader = gl.createShader(type);
gl.shaderSource(shader, source);
gl.compileShader(shader);
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
/** @type {?} */
var error = "Couldn't compile shader: " + gl.getShaderInfoLog(shader);
gl.deleteShader(shader);
if (!gl.isContextLost())
throw new Error(error);
}
return shader;
};
/**
* @private
* @param {?} vs
* @param {?} fs
* @return {?}
*/
Shader.prototype.compileProgram = /**
* @private
* @param {?} vs
* @param {?} fs
* @return {?}
*/
function (vs, fs) {
/** @type {?} */
var gl = this.context.gl;
/** @type {?} */
var program = gl.createProgram();
gl.attachShader(program, vs);
gl.attachShader(program, fs);
gl.linkProgram(program);
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
/** @type {?} */
var error = "Couldn't compile shader program: " + gl.getProgramInfoLog(program);
gl.deleteProgram(program);
if (!gl.isContextLost())
throw new Error(error);
}
return program;
};
/**
* @return {?}
*/
Shader.prototype.restore = /**
* @return {?}
*/
function () {
this.compile();
};
/**
* @return {?}
*/
Shader.prototype.bind = /**
* @return {?}
*/
function () {
this.context.gl.useProgram(this.program);
};
/**
* @return {?}
*/
Shader.prototype.unbind = /**
* @return {?}
*/
function () {
this.context.gl.useProgram(null);
};
/**
* @param {?} uniform
* @param {?} value
* @return {?}
*/
Shader.prototype.setUniformi = /**
* @param {?} uniform
* @param {?} value
* @return {?}
*/
function (uniform, value) {
this.context.gl.uniform1i(this.getUniformLocation(uniform), value);
};
/**
* @param {?} uniform
* @param {?} value
* @return {?}
*/
Shader.prototype.setUniformf = /**
* @param {?} uniform
* @param {?} value
* @return {?}
*/
function (uniform, value) {
this.context.gl.uniform1f(this.getUniformLocation(uniform), value);
};
/**
* @param {?} uniform
* @param {?} value
* @param {?} value2
* @return {?}
*/
Shader.prototype.setUniform2f = /**
* @param {?} uniform
* @param {?} value
* @param {?} value2
* @return {?}
*/
function (uniform, value, value2) {
this.context.gl.uniform2f(this.getUniformLocation(uniform), value, value2);
};
/**
* @param {?} uniform
* @param {?} value
* @param {?} value2
* @param {?} value3
* @return {?}
*/
Shader.prototype.setUniform3f = /**
* @param {?} uniform
* @param {?} value
* @param {?} value2
* @param {?} value3
* @return {?}
*/
function (uniform, value, value2, value3) {
this.context.gl.uniform3f(this.getUniformLocation(uniform), value, value2, value3);
};
/**
* @param {?} uniform
* @param {?} value
* @param {?} value2
* @param {?} value3
* @param {?} value4
* @return {?}
*/
Shader.prototype.setUniform4f = /**
* @param {?} uniform
* @param {?} value
* @param {?} value2
* @param {?} value3
* @param {?} value4
* @return {?}
*/
function (uniform, value, value2, value3, value4) {
this.context.gl.uniform4f(this.getUniformLocation(uniform), value, value2, value3, value4);
};
/**
* @param {?} uniform
* @param {?} value
* @return {?}
*/
Shader.prototype.setUniform2x2f = /**
* @param {?} uniform
* @param {?} value
* @return {?}
*/
function (uniform, value) {
/** @type {?} */
var gl = this.context.gl;
this.tmp2x2.set(value);
gl.uniformMatrix2fv(this.getUniformLocation(uniform), false, this.tmp2x2);
};
/**
* @param {?} uniform
* @param {?} value
* @return {?}
*/
Shader.prototype.setUniform3x3f = /**
* @param {?} uniform
* @param {?} value
* @return {?}
*/
function (uniform, value) {
/** @type {?} */
var gl = this.context.gl;
this.tmp3x3.set(value);
gl.uniformMatrix3fv(this.getUniformLocation(uniform), false, this.tmp3x3);
};
/**
* @param {?} uniform
* @param {?} value
* @return {?}
*/
Shader.prototype.setUniform4x4f = /**
* @param {?} uniform
* @param {?} value
* @return {?}
*/
function (uniform, value) {
/** @type {?} */
var gl = this.context.gl;
this.tmp4x4.set(value);
gl.uniformMatrix4fv(this.getUniformLocation(uniform), false, this.tmp4x4);
};
/**
* @param {?} uniform
* @return {?}
*/
Shader.prototype.getUniformLocation = /**
* @param {?} uniform
* @return {?}
*/
function (uniform) {
/** @type {?} */
var gl = this.context.gl;
/** @type {?} */
var location = gl.getUniformLocation(this.program, uniform);
if (!location && !gl.isContextLost())
throw new Error("Couldn't find location for uniform " + uniform);
return location;
};
/**
* @param {?} attribute
* @return {?}
*/
Shader.prototype.getAttributeLocation = /**
* @param {?} attribute
* @return {?}
*/
function (attribute) {
/** @type {?} */
var gl = this.context.gl;
/** @type {?} */
var location = gl.getAttribLocation(this.program, attribute);
if (location == -1 && !gl.isContextLost())
throw new Error("Couldn't find location for attribute " + attribute);
return location;
};
/**
* @return {?}
*/
Shader.prototype.dispose = /**
* @return {?}
*/
function () {
this.context.removeRestorable(this);
/** @type {?} */
var gl = this.context.gl;
if (this.vs) {
gl.deleteShader(this.vs);
this.vs = null;
}
if (this.fs) {
gl.deleteShader(this.fs);
this.fs = null;
}
if (this.program) {
gl.deleteProgram(this.program);
this.program = null;
}
};
/**
* @param {?} context
* @return {?}
*/
Shader.newColoredTextured = /**
* @param {?} context
* @return {?}
*/
function (context) {
/** @type {?} */
var vs = "\n\t\t\t\tattribute vec4 " + Shader.POSITION + ";\n\t\t\t\tattribute vec4 " + Shader.COLOR + ";\n\t\t\t\tattribute vec2 " + Shader.TEXCOORDS + ";\n\t\t\t\tuniform mat4 " + Shader.MVP_MATRIX + ";\n\t\t\t\tvarying vec4 v_color;\n\t\t\t\tvarying vec2 v_texCoords;\n\t\t\t\tvoid main () {\n\t\t\t\t\tv_color = " + Shader.COLOR + ";\n\t\t\t\t\tv_texCoords = " + Shader.TEXCOORDS + ";\n\t\t\t\t\tgl_Position = " + Shader.MVP_MATRIX + " * " + Shader.POSITION + ";\n\t\t\t\t}\n\t\t\t";
/** @type {?} */
var fs = "\n\t\t\t\t#ifdef GL_ES\n\t\t\t\t\t#define LOWP lowp\n\t\t\t\t\tprecision mediump float;\n\t\t\t\t#else\n\t\t\t\t\t#define LOWP\n\t\t\t\t#endif\n\t\t\t\tvarying LOWP vec4 v_color;\n\t\t\t\tvarying vec2 v_texCoords;\n\t\t\t\tuniform sampler2D u_texture;\n\t\t\t\tvoid main () {\n\t\t\t\t\tgl_FragColor = v_color * texture2D(u_texture, v_texCoords);\n\t\t\t\t}\n\t\t\t";
return new Shader(context, vs, fs);
};
/**
* @param {?} context
* @return {?}
*/
Shader.newTwoColoredTextured = /**
* @param {?} context
* @return {?}
*/
function (context) {
/** @type {?} */
var vs = "\n\t\t\t\tattribute vec4 " + Shader.POSITION + ";\n\t\t\t\tattribute vec4 " + Shader.COLOR + ";\n\t\t\t\tattribute vec4 " + Shader.COLOR2 + ";\n\t\t\t\tattribute vec2 " + Shader.TEXCOORDS + ";\n\t\t\t\tuniform mat4 " + Shader.MVP_MATRIX + ";\n\t\t\t\tvarying vec4 v_light;\n\t\t\t\tvarying vec4 v_dark;\n\t\t\t\tvarying vec2 v_texCoords;\n\t\t\t\tvoid main () {\n\t\t\t\t\tv_light = " + Shader.COLOR + ";\n\t\t\t\t\tv_dark = " + Shader.COLOR2 + ";\n\t\t\t\t\tv_texCoords = " + Shader.TEXCOORDS + ";\n\t\t\t\t\tgl_Position = " + Shader.MVP_MATRIX + " * " + Shader.POSITION + ";\n\t\t\t\t}\n\t\t\t";
/** @type {?} */
var fs = "\n\t\t\t\t#ifdef GL_ES\n\t\t\t\t\t#define LOWP lowp\n\t\t\t\t\tprecision mediump float;\n\t\t\t\t#else\n\t\t\t\t\t#define LOWP\n\t\t\t\t#endif\n\t\t\t\tvarying LOWP vec4 v_light;\n\t\t\t\tvarying LOWP vec4 v_dark;\n\t\t\t\tvarying vec2 v_texCoords;\n\t\t\t\tuniform sampler2D u_texture;\n\t\t\t\tvoid main () {\n\t\t\t\t\tvec4 texColor = texture2D(u_texture, v_texCoords);\n\t\t\t\t\tgl_FragColor.a = texColor.a * v_light.a;\n\t\t\t\t\tgl_FragColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;\n\t\t\t\t}\n\t\t\t";
return new Shader(context, vs, fs);
};
/**
* @param {?} context
* @return {?}
*/
Shader.newColored = /**
* @param {?} context
* @return {?}
*/
function (context) {
/** @type {?} */
var vs = "\n\t\t\t\tattribute vec4 " + Shader.POSITION + ";\n\t\t\t\tattribute vec4 " + Shader.COLOR + ";\n\t\t\t\tuniform mat4 " + Shader.MVP_MATRIX + ";\n\t\t\t\tvarying vec4 v_color;\n\t\t\t\tvoid main () {\n\t\t\t\t\tv_color = " + Shader.COLOR + ";\n\t\t\t\t\tgl_Position = " + Shader.MVP_MATRIX + " * " + Shader.POSITION + ";\n\t\t\t\t}\n\t\t\t";
/** @type {?} */
var fs = "\n\t\t\t\t#ifdef GL_ES\n\t\t\t\t\t#define LOWP lowp\n\t\t\t\t\tprecision mediump float;\n\t\t\t\t#else\n\t\t\t\t\t#define LOWP\n\t\t\t\t#endif\n\t\t\t\tvarying LOWP vec4 v_color;\n\t\t\t\tvoid main () {\n\t\t\t\t\tgl_FragColor = v_color;\n\t\t\t\t}\n\t\t\t";
return new Shader(context, vs, fs);
};
Shader.MVP_MATRIX = "u_projTrans";
Shader.POSITION = "a_position";
Shader.COLOR = "a_color";
Shader.COLOR2 = "a_color2";
Shader.TEXCOORDS = "a_texCoords";
Shader.SAMPLER = "u_texture";
return Shader;
}());
if (false) {
/** @type {?} */
Shader.MVP_MATRIX;
/** @type {?} */
Shader.POSITION;
/** @type {?} */
Shader.COLOR;
/** @type {?} */
Shader.COLOR2;
/** @type {?} */
Shader.TEXCOORDS;
/** @type {?} */
Shader.SAMPLER;
/**
* @type {?}
* @private
*/
Shader.prototype.context;
/**
* @type {?}
* @private
*/
Shader.prototype.vs;
/**
* @type {?}
* @private
*/
Shader.prototype.vsSource;
/**
* @type {?}
* @private
*/
Shader.prototype.fs;
/**
* @type {?}
* @private
*/
Shader.prototype.fsSource;
/**
* @type {?}
* @private
*/
Shader.prototype.program;
/**
* @type {?}
* @private
*/
Shader.prototype.tmp2x2;
/**
* @type {?}
* @private
*/
Shader.prototype.tmp3x3;
/**
* @type {?}
* @private
*/
Shader.prototype.tmp4x4;
/**
* @type {?}
* @private
*/
Shader.prototype.vertexShader;
/**
* @type {?}
* @private
*/
Shader.prototype.fragmentShader;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var Mesh = /** @class */ (function () {
function Mesh(context, attributes, maxVertices, maxIndices) {
this.attributes = attributes;
this.verticesLength = 0;
this.dirtyVertices = false;
this.indicesLength = 0;
this.dirtyIndices = false;
this.elementsPerVertex = 0;
this.context =
context instanceof ManagedWebGLRenderingContext
? context
: new ManagedWebGLRenderingContext(context);
this.elementsPerVertex = 0;
for (var i = 0; i < attributes.length; i++) {
this.elementsPerVertex += attributes[i].numElements;
}
this.vertices = new Float32Array(maxVertices * this.elementsPerVertex);
this.indices = new Uint16Array(maxIndices);
this.context.addRestorable(this);
}
/**
* @return {?}
*/
Mesh.prototype.getAttributes = /**
* @return {?}
*/
function () {
return this.attributes;
};
/**
* @return {?}
*/
Mesh.prototype.maxVertices = /**
* @return {?}
*/
function () {
return this.vertices.length / this.elementsPerVertex;
};
/**
* @return {?}
*/
Mesh.prototype.numVertices = /**
* @return {?}
*/
function () {
return this.verticesLength / this.elementsPerVertex;
};
/**
* @param {?} length
* @return {?}
*/
Mesh.prototype.setVerticesLength = /**
* @param {?} length
* @return {?}
*/
function (length) {
this.dirtyVertices = true;
this.verticesLength = length;
};
/**
* @return {?}
*/
Mesh.prototype.getVertices = /**
* @return {?}
*/
function () {
return this.vertices;
};
/**
* @return {?}
*/
Mesh.prototype.maxIndices = /**
* @return {?}
*/
function () {
return this.indices.length;
};
/**
* @return {?}
*/
Mesh.prototype.numIndices = /**
* @return {?}
*/
function () {
return this.indicesLength;
};
/**
* @param {?} length
* @return {?}
*/
Mesh.prototype.setIndicesLength = /**
* @param {?} length
* @return {?}
*/
function (length) {
this.dirtyIndices = true;
this.indicesLength = length;
};
/**
* @return {?}
*/
Mesh.prototype.getIndices = /**
* @return {?}
*/
function () {
return this.indices;
};
/**
* @return {?}
*/
Mesh.prototype.getVertexSizeInFloats = /**
* @return {?}
*/
function () {
/** @type {?} */
var size = 0;
for (var i = 0; i < this.attributes.length; i++) {
/** @type {?} */
var attribute = this.attributes[i];
size += attribute.numElements;
}
return size;
};
/**
* @param {?} vertices
* @return {?}
*/
Mesh.prototype.setVertices = /**
* @param {?} vertices
* @return {?}
*/
function (vertices) {
this.dirtyVertices = true;
if (vertices.length > this.vertices.length)
throw Error("Mesh can't store more than " + this.maxVertices() + " vertices");
this.vertices.set(vertices, 0);
this.verticesLength = vertices.length;
};
/**
* @param {?} indices
* @return {?}
*/
Mesh.prototype.setIndices = /**
* @param {?} indices
* @return {?}
*/
function (indices) {
this.dirtyIndices = true;
if (indices.length > this.indices.length)
throw Error("Mesh can't store more than " + this.maxIndices() + " indices");
this.indices.set(indices, 0);
this.indicesLength = indices.length;
};
/**
* @param {?} shader
* @param {?} primitiveType
* @return {?}
*/
Mesh.prototype.draw = /**
* @param {?} shader
* @param {?} primitiveType
* @return {?}
*/
function (shader, primitiveType) {
this.drawWithOffset(shader, primitiveType, 0, this.indicesLength > 0
? this.indicesLength
: this.verticesLength / this.elementsPerVertex);
};
/**
* @param {?} shader
* @param {?} primitiveType
* @param {?} offset
* @param {?} count
* @return {?}
*/
Mesh.prototype.drawWithOffset = /**
* @param {?} shader
* @param {?} primitiveType
* @param {?} offset
* @param {?} count
* @return {?}
*/
function (shader, primitiveType, offset, count) {
/** @type {?} */
var gl = this.context.gl;
if (this.dirtyVertices || this.dirtyIndices)
this.update();
this.bind(shader);
if (this.indicesLength > 0) {
gl.drawElements(primitiveType, count, gl.UNSIGNED_SHORT, offset * 2);
}
else {
gl.drawArrays(primitiveType, offset, count);
}
this.unbind(shader);
};
/**
* @param {?} shader
* @return {?}
*/
Mesh.prototype.bind = /**
* @param {?} shader
* @return {?}
*/
function (shader) {
/** @type {?} */
var gl = this.context.gl;
gl.bindBuffer(gl.ARRAY_BUFFER, this.verticesBuffer);
/** @type {?} */
var offset = 0;
for (var i = 0; i < this.attributes.length; i++) {
/** @type {?} */
var attrib = this.attributes[i];
/** @type {?} */
var location_1 = shader.getAttributeLocation(attrib.name);
gl.enableVertexAttribArray(location_1);
gl.vertexAttribPointer(location_1, attrib.numElements, gl.FLOAT, false, this.elementsPerVertex * 4, offset * 4);
offset += attrib.numElements;
}
if (this.indicesLength > 0)
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer);
};
/**
* @param {?} shader
* @return {?}
*/
Mesh.prototype.unbind = /**
* @param {?} shader
* @return {?}
*/
function (shader) {
/** @type {?} */
var gl = this.context.gl;
for (var i = 0; i < this.attributes.length; i++) {
/** @type {?} */
var attrib = this.attributes[i];
/** @type {?} */
var location_2 = shader.getAttributeLocation(attrib.name);
gl.disableVertexAttribArray(location_2);
}
gl.bindBuffer(gl.ARRAY_BUFFER, null);
if (this.indicesLength > 0)
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
};
/**
* @private
* @return {?}
*/
Mesh.prototype.update = /**
* @private
* @return {?}
*/
function () {
/** @type {?} */
var gl = this.context.gl;
if (this.dirtyVertices) {
if (!this.verticesBuffer) {
this.verticesBuffer = gl.createBuffer();
}
gl.bindBuffer(gl.ARRAY_BUFFER, this.verticesBuffer);
gl.bufferData(gl.ARRAY_BUFFER, this.vertices.subarray(0, this.verticesLength), gl.DYNAMIC_DRAW);
this.dirtyVertices = false;
}
if (this.dirtyIndices) {
if (!this.indicesBuffer) {
this.indicesBuffer = gl.createBuffer();
}
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indices.subarray(0, this.indicesLength), gl.DYNAMIC_DRAW);
this.dirtyIndices = false;
}
};
/**
* @return {?}
*/
Mesh.prototype.restore = /**
* @return {?}
*/
function () {
this.verticesBuffer = null;
this.indicesBuffer = null;
this.update();
};
/**
* @return {?}
*/
Mesh.prototype.dispose = /**
* @return {?}
*/
function () {
this.context.removeRestorable(this);
/** @type {?} */
var gl = this.context.gl;
gl.deleteBuffer(this.verticesBuffer);
gl.deleteBuffer(this.indicesBuffer);
};
return Mesh;
}());
if (false) {
/**
* @type {?}
* @private
*/
Mesh.prototype.context;
/**
* @type {?}
* @private
*/
Mesh.prototype.vertices;
/**
* @type {?}
* @private
*/
Mesh.prototype.verticesBuffer;
/**
* @type {?}
* @private
*/
Mesh.prototype.verticesLength;
/**
* @type {?}
* @private
*/
Mesh.prototype.dirtyVertices;
/**
* @type {?}
* @private
*/
Mesh.prototype.indices;
/**
* @type {?}
* @private
*/
Mesh.prototype.indicesBuffer;
/**
* @type {?}
* @private
*/
Mesh.prototype.indicesLength;
/**
* @type {?}
* @private
*/
Mesh.prototype.dirtyIndices;
/**
* @type {?}
* @private
*/
Mesh.prototype.elementsPerVertex;
/**
* @type {?}
* @private
*/
Mesh.prototype.attributes;
}
var VertexAttribute = /** @class */ (function () {
function VertexAttribute(name, type, numElements) {
this.name = name;
this.type = type;
this.numElements = numElements;
}
return VertexAttribute;
}());
if (false) {
/** @type {?} */
VertexAttribute.prototype.name;
/** @type {?} */
VertexAttribute.prototype.type;
/** @type {?} */
VertexAttribute.prototype.numElements;
}
var Position2Attribute = /** @class */ (function (_super) {
__extends(Position2Attribute, _super);
function Position2Attribute() {
return _super.call(this, Shader.POSITION, VertexAttributeType.Float, 2) || this;
}
return Position2Attribute;
}(VertexAttribute));
var Position3Attribute = /** @class */ (function (_super) {
__extends(Position3Attribute, _super);
function Position3Attribute() {
return _super.call(this, Shader.POSITION, VertexAttributeType.Float, 3) || this;
}
return Position3Attribute;
}(VertexAttribute));
var TexCoordAttribute = /** @class */ (function (_super) {
__extends(TexCoordAttribute, _super);
function TexCoordAttribute(unit) {
if (unit === void 0) { unit = 0; }
return _super.call(this, Shader.TEXCOORDS + (unit == 0 ? "" : unit), VertexAttributeType.Float, 2) || this;
}
return TexCoordAttribute;
}(VertexAttribute));
var ColorAttribute = /** @class */ (function (_super) {
__extends(ColorAttribute, _super);
function ColorAttribute() {
return _super.call(this, Shader.COLOR, VertexAttributeType.Float, 4) || this;
}
return ColorAttribute;
}(VertexAttribute));
var Color2Attribute = /** @class */ (function (_super) {
__extends(Color2Attribute, _super);
function Color2Attribute() {
return _super.call(this, Shader.COLOR2, VertexAttributeType.Float, 4) || this;
}
return Color2Attribute;
}(VertexAttribute));
/** @enum {number} */
var VertexAttributeType = {
Float: 0,
};
VertexAttributeType[VertexAttributeType.Float] = 'Float';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var PolygonBatcher = /** @class */ (function () {
function PolygonBatcher(context, twoColorTint, maxVertices) {
if (twoColorTint === void 0) { twoColorTint = true; }
if (maxVertices === void 0) { maxVertices = 10920; }
this.isDrawing = false;
this.shader = null;
this.lastTexture = null;
this.verticesLength = 0;
this.indicesLength = 0;
if (maxVertices > 10920)
throw new Error("Can't have more than 10920 triangles per batch: " + maxVertices);
this.context =
context instanceof ManagedWebGLRenderingContext
? context
: new ManagedWebGLRenderingContext(context);
/** @type {?} */
var attributes = twoColorTint
? [
new Position2Attribute(),
new ColorAttribute(),
new TexCoordAttribute(),
new Color2Attribute()
]
: [
new Position2Attribute(),
new ColorAttribute(),
new TexCoordAttribute()
];
this.mesh = new Mesh(context, attributes, maxVertices, maxVertices * 3);
this.srcBlend = this.context.gl.SRC_ALPHA;
this.dstBlend = this.context.gl.ONE_MINUS_SRC_ALPHA;
}
/**
* @param {?} shader
* @return {?}
*/
PolygonBatcher.prototype.begin = /**
* @param {?} shader
* @return {?}
*/
function (shader) {
/** @type {?} */
var gl = this.context.gl;
if (this.isDrawing)
throw new Error("PolygonBatch is already drawing. Call PolygonBatch.end() before calling PolygonBatch.begin()");
this.drawCalls = 0;
this.shader = shader;
this.lastTexture = null;
this.isDrawing = true;
gl.enable(gl.BLEND);
gl.blendFunc(this.srcBlend, this.dstBlend);
};
/**
* @param {?} srcBlend
* @param {?} dstBlend
* @return {?}
*/
PolygonBatcher.prototype.setBlendMode = /**
* @param {?} srcBlend
* @param {?} dstBlend
* @return {?}
*/
function (srcBlend, dstBlend) {
/** @type {?} */
var gl = this.context.gl;
this.srcBlend = srcBlend;
this.dstBlend = dstBlend;
if (this.isDrawing) {
this.flush();
gl.blendFunc(this.srcBlend, this.dstBlend);
}
};
/**
* @param {?} texture
* @param {?} vertices
* @param {?} indices
* @return {?}
*/
PolygonBatcher.prototype.draw = /**
* @param {?} texture
* @param {?} vertices
* @param {?} indices
* @return {?}
*/
function (texture, vertices, indices) {
if (texture != this.lastTexture) {
this.flush();
this.lastTexture = texture;
}
else if (this.verticesLength + vertices.length > this.mesh.getVertices().length ||
this.indicesLength + indices.length > this.mesh.getIndices().length) {
this.flush();
}
/** @type {?} */
var indexStart = this.mesh.numVertices();
this.mesh.getVertices().set(vertices, this.verticesLength);
this.verticesLength += vertices.length;
this.mesh.setVerticesLength(this.verticesLength);
/** @type {?} */
var indicesArray = this.mesh.getIndices();
for (var i = this.indicesLength, j = 0; j < indices.length; i++, j++)
indicesArray[i] = indices[j] + indexStart;
this.indicesLength += indices.length;
this.mesh.setIndicesLength(this.indicesLength);
};
/**
* @private
* @return {?}
*/
PolygonBatcher.prototype.flush = /**
* @private
* @return {?}
*/
function () {
/** @type {?} */
var gl = this.context.gl;
if (this.verticesLength == 0)
return;
this.lastTexture.bind();
this.mesh.draw(this.shader, gl.TRIANGLES);
this.verticesLength = 0;
this.indicesLength = 0;
this.mesh.setVerticesLength(0);
this.mesh.setIndicesLength(0);
this.drawCalls++;
};
/**
* @return {?}
*/
PolygonBatcher.prototype.end = /**
* @return {?}
*/
function () {
/** @type {?} */
var gl = this.context.gl;
if (!this.isDrawing)
throw new Error("PolygonBatch is not drawing. Call PolygonBatch.begin() before calling PolygonBatch.end()");
if (this.verticesLength > 0 || this.indicesLength > 0)
this.flush();
this.shader = null;
this.lastTexture = null;
this.isDrawing = false;
gl.disable(gl.BLEND);
};
/**
* @return {?}
*/
PolygonBatcher.prototype.getDrawCalls = /**
* @return {?}
*/
function () {
return this.drawCalls;
};
/**
* @return {?}
*/
PolygonBatcher.prototype.dispose = /**
* @return {?}
*/
function () {
this.mesh.dispose();
};
return PolygonBatcher;
}());
if (false) {
/**
* @type {?}
* @private
*/
PolygonBatcher.prototype.context;
/**
* @type {?}
* @private
*/
PolygonBatcher.prototype.drawCalls;
/**
* @type {?}
* @private
*/
PolygonBatcher.prototype.isDrawing;
/**
* @type {?}
* @private
*/
PolygonBatcher.prototype.mesh;
/**
* @type {?}
* @private
*/
PolygonBatcher.prototype.shader;
/**
* @type {?}
* @private
*/
PolygonBatcher.prototype.lastTexture;
/**
* @type {?}
* @private
*/
PolygonBatcher.prototype.verticesLength;
/**
* @type {?}
* @private
*/
PolygonBatcher.prototype.indicesLength;
/**
* @type {?}
* @private
*/
PolygonBatcher.prototype.srcBlend;
/**
* @type {?}
* @private
*/
PolygonBatcher.prototype.dstBlend;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var ShapeRenderer = /** @class */ (function () {
function ShapeRenderer(context, maxVertices) {
if (maxVertices === void 0) { maxVertices = 10920; }
this.isDrawing = false;
this.shapeType = ShapeType.Filled;
this.color = new Color(1, 1, 1, 1);
this.vertexIndex = 0;
this.tmp = new Vector2();
if (maxVertices > 10920)
throw new Error("Can't have more than 10920 triangles per batch: " + maxVertices);
this.context =
context instanceof ManagedWebGLRenderingContext
? context
: new ManagedWebGLRenderingContext(context);
this.mesh = new Mesh(context, [new Position2Attribute(), new ColorAttribute()], maxVertices, 0);
this.srcBlend = this.context.gl.SRC_ALPHA;
this.dstBlend = this.context.gl.ONE_MINUS_SRC_ALPHA;
}
/**
* @param {?} shader
* @return {?}
*/
ShapeRenderer.prototype.begin = /**
* @param {?} shader
* @return {?}
*/
function (shader) {
if (this.isDrawing)
throw new Error("ShapeRenderer.begin() has already been called");
this.shader = shader;
this.vertexIndex = 0;
this.isDrawing = true;
/** @type {?} */
var gl = this.context.gl;
gl.enable(gl.BLEND);
gl.blendFunc(this.srcBlend, this.dstBlend);
};
/**
* @param {?} srcBlend
* @param {?} dstBlend
* @return {?}
*/
ShapeRenderer.prototype.setBlendMode = /**
* @param {?} srcBlend
* @param {?} dstBlend
* @return {?}
*/
function (srcBlend, dstBlend) {
/** @type {?} */
var gl = this.context.gl;
this.srcBlend = srcBlend;
this.dstBlend = dstBlend;
if (this.isDrawing) {
this.flush();
gl.blendFunc(this.srcBlend, this.dstBlend);
}
};
/**
* @param {?} color
* @return {?}
*/
ShapeRenderer.prototype.setColor = /**
* @param {?} color
* @return {?}
*/
function (color) {
this.color.setFromColor(color);
};
/**
* @param {?} r
* @param {?} g
* @param {?} b
* @param {?} a
* @return {?}
*/
ShapeRenderer.prototype.setColorWith = /**
* @param {?} r
* @param {?} g
* @param {?} b
* @param {?} a
* @return {?}
*/
function (r, g, b, a) {
this.color.set(r, g, b, a);
};
/**
* @param {?} x
* @param {?} y
* @param {?=} color
* @return {?}
*/
ShapeRenderer.prototype.point = /**
* @param {?} x
* @param {?} y
* @param {?=} color
* @return {?}
*/
function (x, y, color) {
if (color === void 0) { color = null; }
this.check(ShapeType.Point, 1);
if (color === null)
color = this.color;
this.vertex(x, y, color);
};
/**
* @param {?} x
* @param {?} y
* @param {?} x2
* @param {?} y2
* @param {?=} color
* @return {?}
*/
ShapeRenderer.prototype.line = /**
* @param {?} x
* @param {?} y
* @param {?} x2
* @param {?} y2
* @param {?=} color
* @return {?}
*/
function (x, y, x2, y2, color) {
if (color === void 0) { color = null; }
this.check(ShapeType.Line, 2);
/** @type {?} */
var vertices = this.mesh.getVertices();
/** @type {?} */
var idx = this.vertexIndex;
if (color === null)
color = this.color;
this.vertex(x, y, color);
this.vertex(x2, y2, color);
};
/**
* @param {?} filled
* @param {?} x
* @param {?} y
* @param {?} x2
* @param {?} y2
* @param {?} x3
* @param {?} y3
* @param {?=} color
* @param {?=} color2
* @param {?=} color3
* @return {?}
*/
ShapeRenderer.prototype.triangle = /**
* @param {?} filled
* @param {?} x
* @param {?} y
* @param {?} x2
* @param {?} y2
* @param {?} x3
* @param {?} y3
* @param {?=} color
* @param {?=} color2
* @param {?=} color3
* @return {?}
*/
function (filled, x, y, x2, y2, x3, y3, color, color2, color3) {
if (color === void 0) { color = null; }
if (color2 === void 0) { color2 = null; }
if (color3 === void 0) { color3 = null; }
this.check(filled ? ShapeType.Filled : ShapeType.Line, 3);
/** @type {?} */
var vertices = this.mesh.getVertices();
/** @type {?} */
var idx = this.vertexIndex;
if (color === null)
color = this.color;
if (color2 === null)
color2 = this.color;
if (color3 === null)
color3 = this.color;
if (filled) {
this.vertex(x, y, color);
this.vertex(x2, y2, color2);
this.vertex(x3, y3, color3);
}
else {
this.vertex(x, y, color);
this.vertex(x2, y2, color2);
this.vertex(x2, y2, color);
this.vertex(x3, y3, color2);
this.vertex(x3, y3, color);
this.vertex(x, y, color2);
}
};
/**
* @param {?} filled
* @param {?} x
* @param {?} y
* @param {?} x2
* @param {?} y2
* @param {?} x3
* @param {?} y3
* @param {?} x4
* @param {?} y4
* @param {?=} color
* @param {?=} color2
* @param {?=} color3
* @param {?=} color4
* @return {?}
*/
ShapeRenderer.prototype.quad = /**
* @param {?} filled
* @param {?} x
* @param {?} y
* @param {?} x2
* @param {?} y2
* @param {?} x3
* @param {?} y3
* @param {?} x4
* @param {?} y4
* @param {?=} color
* @param {?=} color2
* @param {?=} color3
* @param {?=} color4
* @return {?}
*/
function (filled, x, y, x2, y2, x3, y3, x4, y4, color, color2, color3, color4) {
if (color === void 0) { color = null; }
if (color2 === void 0) { color2 = null; }
if (color3 === void 0) { color3 = null; }
if (color4 === void 0) { color4 = null; }
this.check(filled ? ShapeType.Filled : ShapeType.Line, 3);
/** @type {?} */
var vertices = this.mesh.getVertices();
/** @type {?} */
var idx = this.vertexIndex;
if (color === null)
color = this.color;
if (color2 === null)
color2 = this.color;
if (color3 === null)
color3 = this.color;
if (color4 === null)
color4 = this.color;
if (filled) {
this.vertex(x, y, color);
this.vertex(x2, y2, color2);
this.vertex(x3, y3, color3);
this.vertex(x3, y3, color3);
this.vertex(x4, y4, color4);
this.vertex(x, y, color);
}
else {
this.vertex(x, y, color);
this.vertex(x2, y2, color2);
this.vertex(x2, y2, color2);
this.vertex(x3, y3, color3);
this.vertex(x3, y3, color3);
this.vertex(x4, y4, color4);
this.vertex(x4, y4, color4);
this.vertex(x, y, color);
}
};
/**
* @param {?} filled
* @param {?} x
* @param {?} y
* @param {?} width
* @param {?} height
* @param {?=} color
* @return {?}
*/
ShapeRenderer.prototype.rect = /**
* @param {?} filled
* @param {?} x
* @param {?} y
* @param {?} width
* @param {?} height
* @param {?=} color
* @return {?}
*/
function (filled, x, y, width, height, color) {
if (color === void 0) { color = null; }
this.quad(filled, x, y, x + width, y, x + width, y + height, x, y + height, color, color, color, color);
};
/**
* @param {?} filled
* @param {?} x1
* @param {?} y1
* @param {?} x2
* @param {?} y2
* @param {?} width
* @param {?=} color
* @return {?}
*/
ShapeRenderer.prototype.rectLine = /**
* @param {?} filled
* @param {?} x1
* @param {?} y1
* @param {?} x2
* @param {?} y2
* @param {?} width
* @param {?=} color
* @return {?}
*/
function (filled, x1, y1, x2, y2, width, color) {
if (color === void 0) { color = null; }
this.check(filled ? ShapeType.Filled : ShapeType.Line, 8);
if (color === null)
color = this.color;
/** @type {?} */
var t = this.tmp.set(y2 - y1, x1 - x2);
t.normalize();
width *= 0.5;
/** @type {?} */
var tx = t.x * width;
/** @type {?} */
var ty = t.y * width;
if (!filled) {
this.vertex(x1 + tx, y1 + ty, color);
this.vertex(x1 - tx, y1 - ty, color);
this.vertex(x2 + tx, y2 + ty, color);
this.vertex(x2 - tx, y2 - ty, color);
this.vertex(x2 + tx, y2 + ty, color);
this.vertex(x1 + tx, y1 + ty, color);
this.vertex(x2 - tx, y2 - ty, color);
this.vertex(x1 - tx, y1 - ty, color);
}
else {
this.vertex(x1 + tx, y1 + ty, color);
this.vertex(x1 - tx, y1 - ty, color);
this.vertex(x2 + tx, y2 + ty, color);
this.vertex(x2 - tx, y2 - ty, color);
this.vertex(x2 + tx, y2 + ty, color);
this.vertex(x1 - tx, y1 - ty, color);
}
};
/**
* @param {?} x
* @param {?} y
* @param {?} size
* @return {?}
*/
ShapeRenderer.prototype.x = /**
* @param {?} x
* @param {?} y
* @param {?} size
* @return {?}
*/
function (x, y, size) {
this.line(x - size, y - size, x + size, y + size);
this.line(x - size, y + size, x + size, y - size);
};
/**
* @param {?} polygonVertices
* @param {?} offset
* @param {?} count
* @param {?=} color
* @return {?}
*/
ShapeRenderer.prototype.polygon = /**
* @param {?} polygonVertices
* @param {?} offset
* @param {?} count
* @param {?=} color
* @return {?}
*/
function (polygonVertices, offset, count, color) {
if (color === void 0) { color = null; }
if (count < 3)
throw new Error("Polygon must contain at least 3 vertices");
this.check(ShapeType.Line, count * 2);
if (color === null)
color = this.color;
/** @type {?} */
var vertices = this.mesh.getVertices();
/** @type {?} */
var idx = this.vertexIndex;
offset <<= 1;
count <<= 1;
/** @type {?} */
var firstX = polygonVertices[offset];
/** @type {?} */
var firstY = polygonVertices[offset + 1];
/** @type {?} */
var last = offset + count;
for (var i = offset, n = offset + count - 2; i < n; i += 2) {
/** @type {?} */
var x1 = polygonVertices[i];
/** @type {?} */
var y1 = polygonVertices[i + 1];
/** @type {?} */
var x2 = 0;
/** @type {?} */
var y2 = 0;
if (i + 2 >= last) {
x2 = firstX;
y2 = firstY;
}
else {
x2 = polygonVertices[i + 2];
y2 = polygonVertices[i + 3];
}
this.vertex(x1, y1, color);
this.vertex(x2, y2, color);
}
};
/**
* @param {?} filled
* @param {?} x
* @param {?} y
* @param {?} radius
* @param {?=} color
* @param {?=} segments
* @return {?}
*/
ShapeRenderer.prototype.circle = /**
* @param {?} filled
* @param {?} x
* @param {?} y
* @param {?} radius
* @param {?=} color
* @param {?=} segments
* @return {?}
*/
function (filled, x, y, radius, color, segments) {
if (color === void 0) { color = null; }
if (segments === void 0) { segments = 0; }
if (segments === 0)
segments = Math.max(1, (6 * MathUtils.cbrt(radius)) | 0);
if (segments <= 0)
throw new Error("segments must be > 0.");
if (color === null)
color = this.color;
/** @type {?} */
var angle = (2 * MathUtils.PI) / segments;
/** @type {?} */
var cos = Math.cos(angle);
/** @type {?} */
var sin = Math.sin(angle);
/** @type {?} */
var cx = radius;
/** @type {?} */
var cy = 0;
if (!filled) {
this.check(ShapeType.Line, segments * 2 + 2);
for (var i = 0; i < segments; i++) {
this.vertex(x + cx, y + cy, color);
/** @type {?} */
var temp_1 = cx;
cx = cos * cx - sin * cy;
cy = sin * temp_1 + cos * cy;
this.vertex(x + cx, y + cy, color);
}
// Ensure the last segment is identical to the first.
this.vertex(x + cx, y + cy, color);
}
else {
this.check(ShapeType.Filled, segments * 3 + 3);
segments--;
for (var i = 0; i < segments; i++) {
this.vertex(x, y, color);
this.vertex(x + cx, y + cy, color);
/** @type {?} */
var temp_2 = cx;
cx = cos * cx - sin * cy;
cy = sin * temp_2 + cos * cy;
this.vertex(x + cx, y + cy, color);
}
// Ensure the last segment is identical to the first.
this.vertex(x, y, color);
this.vertex(x + cx, y + cy, color);
}
/** @type {?} */
var temp = cx;
cx = radius;
cy = 0;
this.vertex(x + cx, y + cy, color);
};
/**
* @param {?} x1
* @param {?} y1
* @param {?} cx1
* @param {?} cy1
* @param {?} cx2
* @param {?} cy2
* @param {?} x2
* @param {?} y2
* @param {?} segments
* @param {?=} color
* @return {?}
*/
ShapeRenderer.prototype.curve = /**
* @param {?} x1
* @param {?} y1
* @param {?} cx1
* @param {?} cy1
* @param {?} cx2
* @param {?} cy2
* @param {?} x2
* @param {?} y2
* @param {?} segments
* @param {?=} color
* @return {?}
*/
function (x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color) {
if (color === void 0) { color = null; }
this.check(ShapeType.Line, segments * 2 + 2);
if (color === null)
color = this.color;
// Algorithm from: http://www.antigrain.com/research/bezier_interpolation/index.html#PAGE_BEZIER_INTERPOLATION
/** @type {?} */
var subdiv_step = 1 / segments;
/** @type {?} */
var subdiv_step2 = subdiv_step * subdiv_step;
/** @type {?} */
var subdiv_step3 = subdiv_step * subdiv_step * subdiv_step;
/** @type {?} */
var pre1 = 3 * subdiv_step;
/** @type {?} */
var pre2 = 3 * subdiv_step2;
/** @type {?} */
var pre4 = 6 * subdiv_step2;
/** @type {?} */
var pre5 = 6 * subdiv_step3;
/** @type {?} */
var tmp1x = x1 - cx1 * 2 + cx2;
/** @type {?} */
var tmp1y = y1 - cy1 * 2 + cy2;
/** @type {?} */
var tmp2x = (cx1 - cx2) * 3 - x1 + x2;
/** @type {?} */
var tmp2y = (cy1 - cy2) * 3 - y1 + y2;
/** @type {?} */
var fx = x1;
/** @type {?} */
var fy = y1;
/** @type {?} */
var dfx = (cx1 - x1) * pre1 + tmp1x * pre2 + tmp2x * subdiv_step3;
/** @type {?} */
var dfy = (cy1 - y1) * pre1 + tmp1y * pre2 + tmp2y * subdiv_step3;
/** @type {?} */
var ddfx = tmp1x * pre4 + tmp2x * pre5;
/** @type {?} */
var ddfy = tmp1y * pre4 + tmp2y * pre5;
/** @type {?} */
var dddfx = tmp2x * pre5;
/** @type {?} */
var dddfy = tmp2y * pre5;
while (segments-- > 0) {
this.vertex(fx, fy, color);
fx += dfx;
fy += dfy;
dfx += ddfx;
dfy += ddfy;
ddfx += dddfx;
ddfy += dddfy;
this.vertex(fx, fy, color);
}
this.vertex(fx, fy, color);
this.vertex(x2, y2, color);
};
/**
* @private
* @param {?} x
* @param {?} y
* @param {?} color
* @return {?}
*/
ShapeRenderer.prototype.vertex = /**
* @private
* @param {?} x
* @param {?} y
* @param {?} color
* @return {?}
*/
function (x, y, color) {
/** @type {?} */
var idx = this.vertexIndex;
/** @type {?} */
var vertices = this.mesh.getVertices();
vertices[idx++] = x;
vertices[idx++] = y;
vertices[idx++] = color.r;
vertices[idx++] = color.g;
vertices[idx++] = color.b;
vertices[idx++] = color.a;
this.vertexIndex = idx;
};
/**
* @return {?}
*/
ShapeRenderer.prototype.end = /**
* @return {?}
*/
function () {
if (!this.isDrawing)
throw new Error("ShapeRenderer.begin() has not been called");
this.flush();
this.context.gl.disable(this.context.gl.BLEND);
this.isDrawing = false;
};
/**
* @private
* @return {?}
*/
ShapeRenderer.prototype.flush = /**
* @private
* @return {?}
*/
function () {
if (this.vertexIndex == 0)
return;
this.mesh.setVerticesLength(this.vertexIndex);
this.mesh.draw(this.shader, this.shapeType);
this.vertexIndex = 0;
};
/**
* @private
* @param {?} shapeType
* @param {?} numVertices
* @return {?}
*/
ShapeRenderer.prototype.check = /**
* @private
* @param {?} shapeType
* @param {?} numVertices
* @return {?}
*/
function (shapeType, numVertices) {
if (!this.isDrawing)
throw new Error("ShapeRenderer.begin() has not been called");
if (this.shapeType == shapeType) {
if (this.mesh.maxVertices() - this.mesh.numVertices() < numVertices)
this.flush();
else
return;
}
else {
this.flush();
this.shapeType = shapeType;
}
};
/**
* @return {?}
*/
ShapeRenderer.prototype.dispose = /**
* @return {?}
*/
function () {
this.mesh.dispose();
};
return ShapeRenderer;
}());
if (false) {
/**
* @type {?}
* @private
*/
ShapeRenderer.prototype.context;
/**
* @type {?}
* @private
*/
ShapeRenderer.prototype.isDrawing;
/**
* @type {?}
* @private
*/
ShapeRenderer.prototype.mesh;
/**
* @type {?}
* @private
*/
ShapeRenderer.prototype.shapeType;
/**
* @type {?}
* @private
*/
ShapeRenderer.prototype.color;
/**
* @type {?}
* @private
*/
ShapeRenderer.prototype.shader;
/**
* @type {?}
* @private
*/
ShapeRenderer.prototype.vertexIndex;
/**
* @type {?}
* @private
*/
ShapeRenderer.prototype.tmp;
/**
* @type {?}
* @private
*/
ShapeRenderer.prototype.srcBlend;
/**
* @type {?}
* @private
*/
ShapeRenderer.prototype.dstBlend;
}
/** @enum {number} */
var ShapeType = {
Point: 0,
Line: 1,
Filled: 4,
};
ShapeType[ShapeType.Point] = 'Point';
ShapeType[ShapeType.Line] = 'Line';
ShapeType[ShapeType.Filled] = 'Filled';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var Triangulator = /** @class */ (function () {
function Triangulator() {
this.convexPolygons = new Array();
this.convexPolygonsIndices = new Array();
this.indicesArray = new Array();
this.isConcaveArray = new Array();
this.triangles = new Array();
this.polygonPool = new Pool((/**
* @return {?}
*/
function () {
return new Array();
}));
this.polygonIndicesPool = new Pool((/**
* @return {?}
*/
function () {
return new Array();
}));
}
/**
* @param {?} verticesArray
* @return {?}
*/
Triangulator.prototype.triangulate = /**
* @param {?} verticesArray
* @return {?}
*/
function (verticesArray) {
/** @type {?} */
var vertices = verticesArray;
/** @type {?} */
var vertexCount = verticesArray.length >> 1;
/** @type {?} */
var indices = this.indicesArray;
indices.length = 0;
for (var i = 0; i < vertexCount; i++)
indices[i] = i;
/** @type {?} */
var isConcave = this.isConcaveArray;
isConcave.length = 0;
for (var i = 0, n = vertexCount; i < n; ++i)
isConcave[i] = Triangulator.isConcave(i, vertexCount, vertices, indices);
/** @type {?} */
var triangles = this.triangles;
triangles.length = 0;
while (vertexCount > 3) {
// Find ear tip.
/** @type {?} */
var previous = vertexCount - 1;
/** @type {?} */
var i = 0;
/** @type {?} */
var next = 1;
while (true) {
outer: if (!isConcave[i]) {
/** @type {?} */
var p1 = indices[previous] << 1;
/** @type {?} */
var p2 = indices[i] << 1;
/** @type {?} */
var p3 = indices[next] << 1;
/** @type {?} */
var p1x = vertices[p1];
/** @type {?} */
var p1y = vertices[p1 + 1];
/** @type {?} */
var p2x = vertices[p2];
/** @type {?} */
var p2y = vertices[p2 + 1];
/** @type {?} */
var p3x = vertices[p3];
/** @type {?} */
var p3y = vertices[p3 + 1];
for (var ii = (next + 1) % vertexCount; ii != previous; ii = (ii + 1) % vertexCount) {
if (!isConcave[ii])
continue;
/** @type {?} */
var v = indices[ii] << 1;
/** @type {?} */
var vx = vertices[v];
/** @type {?} */
var vy = vertices[v + 1];
if (Triangulator.positiveArea(p3x, p3y, p1x, p1y, vx, vy)) {
if (Triangulator.positiveArea(p1x, p1y, p2x, p2y, vx, vy)) {
if (Triangulator.positiveArea(p2x, p2y, p3x, p3y, vx, vy))
break outer;
}
}
}
break;
}
if (next == 0) {
do {
if (!isConcave[i])
break;
i--;
} while (i > 0);
break;
}
previous = i;
i = next;
next = (next + 1) % vertexCount;
}
// Cut ear tip.
triangles.push(indices[(vertexCount + i - 1) % vertexCount]);
triangles.push(indices[i]);
triangles.push(indices[(i + 1) % vertexCount]);
indices.splice(i, 1);
isConcave.splice(i, 1);
vertexCount--;
/** @type {?} */
var previousIndex = (vertexCount + i - 1) % vertexCount;
/** @type {?} */
var nextIndex = i == vertexCount ? 0 : i;
isConcave[previousIndex] = Triangulator.isConcave(previousIndex, vertexCount, vertices, indices);
isConcave[nextIndex] = Triangulator.isConcave(nextIndex, vertexCount, vertices, indices);
}
if (vertexCount == 3) {
triangles.push(indices[2]);
triangles.push(indices[0]);
triangles.push(indices[1]);
}
return triangles;
};
/**
* @param {?} verticesArray
* @param {?} triangles
* @return {?}
*/
Triangulator.prototype.decompose = /**
* @param {?} verticesArray
* @param {?} triangles
* @return {?}
*/
function (verticesArray, triangles) {
/** @type {?} */
var vertices = verticesArray;
/** @type {?} */
var convexPolygons = this.convexPolygons;
this.polygonPool.freeAll(convexPolygons);
convexPolygons.length = 0;
/** @type {?} */
var convexPolygonsIndices = this.convexPolygonsIndices;
this.polygonIndicesPool.freeAll(convexPolygonsIndices);
convexPolygonsIndices.length = 0;
/** @type {?} */
var polygonIndices = this.polygonIndicesPool.obtain();
polygonIndices.length = 0;
/** @type {?} */
var polygon = this.polygonPool.obtain();
polygon.length = 0;
// Merge subsequent triangles if they form a triangle fan.
/** @type {?} */
var fanBaseIndex = -1;
/** @type {?} */
var lastWinding = 0;
for (var i = 0, n = triangles.length; i < n; i += 3) {
/** @type {?} */
var t1 = triangles[i] << 1;
/** @type {?} */
var t2 = triangles[i + 1] << 1;
/** @type {?} */
var t3 = triangles[i + 2] << 1;
/** @type {?} */
var x1 = vertices[t1];
/** @type {?} */
var y1 = vertices[t1 + 1];
/** @type {?} */
var x2 = vertices[t2];
/** @type {?} */
var y2 = vertices[t2 + 1];
/** @type {?} */
var x3 = vertices[t3];
/** @type {?} */
var y3 = vertices[t3 + 1];
// If the base of the last triangle is the same as this triangle, check if they form a convex polygon (triangle fan).
/** @type {?} */
var merged = false;
if (fanBaseIndex == t1) {
/** @type {?} */
var o = polygon.length - 4;
/** @type {?} */
var winding1 = Triangulator.winding(polygon[o], polygon[o + 1], polygon[o + 2], polygon[o + 3], x3, y3);
/** @type {?} */
var winding2 = Triangulator.winding(x3, y3, polygon[0], polygon[1], polygon[2], polygon[3]);
if (winding1 == lastWinding && winding2 == lastWinding) {
polygon.push(x3);
polygon.push(y3);
polygonIndices.push(t3);
merged = true;
}
}
// Otherwise make this triangle the new base.
if (!merged) {
if (polygon.length > 0) {
convexPolygons.push(polygon);
convexPolygonsIndices.push(polygonIndices);
}
else {
this.polygonPool.free(polygon);
this.polygonIndicesPool.free(polygonIndices);
}
polygon = this.polygonPool.obtain();
polygon.length = 0;
polygon.push(x1);
polygon.push(y1);
polygon.push(x2);
polygon.push(y2);
polygon.push(x3);
polygon.push(y3);
polygonIndices = this.polygonIndicesPool.obtain();
polygonIndices.length = 0;
polygonIndices.push(t1);
polygonIndices.push(t2);
polygonIndices.push(t3);
lastWinding = Triangulator.winding(x1, y1, x2, y2, x3, y3);
fanBaseIndex = t1;
}
}
if (polygon.length > 0) {
convexPolygons.push(polygon);
convexPolygonsIndices.push(polygonIndices);
}
// Go through the list of polygons and try to merge the remaining triangles with the found triangle fans.
for (var i = 0, n = convexPolygons.length; i < n; i++) {
polygonIndices = convexPolygonsIndices[i];
if (polygonIndices.length == 0)
continue;
/** @type {?} */
var firstIndex = polygonIndices[0];
/** @type {?} */
var lastIndex = polygonIndices[polygonIndices.length - 1];
polygon = convexPolygons[i];
/** @type {?} */
var o = polygon.length - 4;
/** @type {?} */
var prevPrevX = polygon[o];
/** @type {?} */
var prevPrevY = polygon[o + 1];
/** @type {?} */
var prevX = polygon[o + 2];
/** @type {?} */
var prevY = polygon[o + 3];
/** @type {?} */
var firstX = polygon[0];
/** @type {?} */
var firstY = polygon[1];
/** @type {?} */
var secondX = polygon[2];
/** @type {?} */
var secondY = polygon[3];
/** @type {?} */
var winding = Triangulator.winding(prevPrevX, prevPrevY, prevX, prevY, firstX, firstY);
for (var ii = 0; ii < n; ii++) {
if (ii == i)
continue;
/** @type {?} */
var otherIndices = convexPolygonsIndices[ii];
if (otherIndices.length != 3)
continue;
/** @type {?} */
var otherFirstIndex = otherIndices[0];
/** @type {?} */
var otherSecondIndex = otherIndices[1];
/** @type {?} */
var otherLastIndex = otherIndices[2];
/** @type {?} */
var otherPoly = convexPolygons[ii];
/** @type {?} */
var x3 = otherPoly[otherPoly.length - 2];
/** @type {?} */
var y3 = otherPoly[otherPoly.length - 1];
if (otherFirstIndex != firstIndex || otherSecondIndex != lastIndex)
continue;
/** @type {?} */
var winding1 = Triangulator.winding(prevPrevX, prevPrevY, prevX, prevY, x3, y3);
/** @type {?} */
var winding2 = Triangulator.winding(x3, y3, firstX, firstY, secondX, secondY);
if (winding1 == winding && winding2 == winding) {
otherPoly.length = 0;
otherIndices.length = 0;
polygon.push(x3);
polygon.push(y3);
polygonIndices.push(otherLastIndex);
prevPrevX = prevX;
prevPrevY = prevY;
prevX = x3;
prevY = y3;
ii = 0;
}
}
}
// Remove empty polygons that resulted from the merge step above.
for (var i = convexPolygons.length - 1; i >= 0; i--) {
polygon = convexPolygons[i];
if (polygon.length == 0) {
convexPolygons.splice(i, 1);
this.polygonPool.free(polygon);
polygonIndices = convexPolygonsIndices[i];
convexPolygonsIndices.splice(i, 1);
this.polygonIndicesPool.free(polygonIndices);
}
}
return convexPolygons;
};
/**
* @private
* @param {?} index
* @param {?} vertexCount
* @param {?} vertices
* @param {?} indices
* @return {?}
*/
Triangulator.isConcave = /**
* @private
* @param {?} index
* @param {?} vertexCount
* @param {?} vertices
* @param {?} indices
* @return {?}
*/
function (index, vertexCount, vertices, indices) {
/** @type {?} */
var previous = indices[(vertexCount + index - 1) % vertexCount] << 1;
/** @type {?} */
var current = indices[index] << 1;
/** @type {?} */
var next = indices[(index + 1) % vertexCount] << 1;
return !this.positiveArea(vertices[previous], vertices[previous + 1], vertices[current], vertices[current + 1], vertices[next], vertices[next + 1]);
};
/**
* @private
* @param {?} p1x
* @param {?} p1y
* @param {?} p2x
* @param {?} p2y
* @param {?} p3x
* @param {?} p3y
* @return {?}
*/
Triangulator.positiveArea = /**
* @private
* @param {?} p1x
* @param {?} p1y
* @param {?} p2x
* @param {?} p2y
* @param {?} p3x
* @param {?} p3y
* @return {?}
*/
function (p1x, p1y, p2x, p2y, p3x, p3y) {
return p1x * (p3y - p2y) + p2x * (p1y - p3y) + p3x * (p2y - p1y) >= 0;
};
/**
* @private
* @param {?} p1x
* @param {?} p1y
* @param {?} p2x
* @param {?} p2y
* @param {?} p3x
* @param {?} p3y
* @return {?}
*/
Triangulator.winding = /**
* @private
* @param {?} p1x
* @param {?} p1y
* @param {?} p2x
* @param {?} p2y
* @param {?} p3x
* @param {?} p3y
* @return {?}
*/
function (p1x, p1y, p2x, p2y, p3x, p3y) {
/** @type {?} */
var px = p2x - p1x;
/** @type {?} */
var py = p2y - p1y;
return p3x * py - p3y * px + px * p1y - p1x * py >= 0 ? 1 : -1;
};
return Triangulator;
}());
if (false) {
/**
* @type {?}
* @private
*/
Triangulator.prototype.convexPolygons;
/**
* @type {?}
* @private
*/
Triangulator.prototype.convexPolygonsIndices;
/**
* @type {?}
* @private
*/
Triangulator.prototype.indicesArray;
/**
* @type {?}
* @private
*/
Triangulator.prototype.isConcaveArray;
/**
* @type {?}
* @private
*/
Triangulator.prototype.triangles;
/**
* @type {?}
* @private
*/
Triangulator.prototype.polygonPool;
/**
* @type {?}
* @private
*/
Triangulator.prototype.polygonIndicesPool;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var SkeletonClipping = /** @class */ (function () {
function SkeletonClipping() {
this.triangulator = new Triangulator();
this.clippingPolygon = new Array();
this.clipOutput = new Array();
this.clippedVertices = new Array();
this.clippedTriangles = new Array();
this.scratch = new Array();
}
/**
* @param {?} slot
* @param {?} clip
* @return {?}
*/
SkeletonClipping.prototype.clipStart = /**
* @param {?} slot
* @param {?} clip
* @return {?}
*/
function (slot, clip) {
if (this.clipAttachment != null)
return 0;
this.clipAttachment = clip;
/** @type {?} */
var n = clip.worldVerticesLength;
/** @type {?} */
var vertices = Utils.setArraySize(this.clippingPolygon, n);
clip.computeWorldVertices(slot, 0, n, vertices, 0, 2);
/** @type {?} */
var clippingPolygon = this.clippingPolygon;
SkeletonClipping.makeClockwise(clippingPolygon);
/** @type {?} */
var clippingPolygons = (this.clippingPolygons = this.triangulator.decompose(clippingPolygon, this.triangulator.triangulate(clippingPolygon)));
for (var i = 0, n_1 = clippingPolygons.length; i < n_1; i++) {
/** @type {?} */
var polygon = clippingPolygons[i];
SkeletonClipping.makeClockwise(polygon);
polygon.push(polygon[0]);
polygon.push(polygon[1]);
}
return clippingPolygons.length;
};
/**
* @param {?} slot
* @return {?}
*/
SkeletonClipping.prototype.clipEndWithSlot = /**
* @param {?} slot
* @return {?}
*/
function (slot) {
if (this.clipAttachment != null && this.clipAttachment.endSlot == slot.data)
this.clipEnd();
};
/**
* @return {?}
*/
SkeletonClipping.prototype.clipEnd = /**
* @return {?}
*/
function () {
if (this.clipAttachment == null)
return;
this.clipAttachment = null;
this.clippingPolygons = null;
this.clippedVertices.length = 0;
this.clippedTriangles.length = 0;
this.clippingPolygon.length = 0;
};
/**
* @return {?}
*/
SkeletonClipping.prototype.isClipping = /**
* @return {?}
*/
function () {
return this.clipAttachment != null;
};
/**
* @param {?} vertices
* @param {?} verticesLength
* @param {?} triangles
* @param {?} trianglesLength
* @param {?} uvs
* @param {?} light
* @param {?} dark
* @param {?} twoColor
* @return {?}
*/
SkeletonClipping.prototype.clipTriangles = /**
* @param {?} vertices
* @param {?} verticesLength
* @param {?} triangles
* @param {?} trianglesLength
* @param {?} uvs
* @param {?} light
* @param {?} dark
* @param {?} twoColor
* @return {?}
*/
function (vertices, verticesLength, triangles, trianglesLength, uvs, light, dark, twoColor) {
/** @type {?} */
var clipOutput = this.clipOutput;
/** @type {?} */
var clippedVertices = this.clippedVertices;
/** @type {?} */
var clippedTriangles = this.clippedTriangles;
/** @type {?} */
var polygons = this.clippingPolygons;
/** @type {?} */
var polygonsCount = this.clippingPolygons.length;
/** @type {?} */
var vertexSize = twoColor ? 12 : 8;
/** @type {?} */
var index = 0;
clippedVertices.length = 0;
clippedTriangles.length = 0;
outer: for (var i = 0; i < trianglesLength; i += 3) {
/** @type {?} */
var vertexOffset = triangles[i] << 1;
/** @type {?} */
var x1 = vertices[vertexOffset];
/** @type {?} */
var y1 = vertices[vertexOffset + 1];
/** @type {?} */
var u1 = uvs[vertexOffset];
/** @type {?} */
var v1 = uvs[vertexOffset + 1];
vertexOffset = triangles[i + 1] << 1;
/** @type {?} */
var x2 = vertices[vertexOffset];
/** @type {?} */
var y2 = vertices[vertexOffset + 1];
/** @type {?} */
var u2 = uvs[vertexOffset];
/** @type {?} */
var v2 = uvs[vertexOffset + 1];
vertexOffset = triangles[i + 2] << 1;
/** @type {?} */
var x3 = vertices[vertexOffset];
/** @type {?} */
var y3 = vertices[vertexOffset + 1];
/** @type {?} */
var u3 = uvs[vertexOffset];
/** @type {?} */
var v3 = uvs[vertexOffset + 1];
for (var p = 0; p < polygonsCount; p++) {
/** @type {?} */
var s = clippedVertices.length;
if (this.clip(x1, y1, x2, y2, x3, y3, polygons[p], clipOutput)) {
/** @type {?} */
var clipOutputLength = clipOutput.length;
if (clipOutputLength == 0)
continue;
/** @type {?} */
var d0 = y2 - y3;
/** @type {?} */
var d1 = x3 - x2;
/** @type {?} */
var d2 = x1 - x3;
/** @type {?} */
var d4 = y3 - y1;
/** @type {?} */
var d = 1 / (d0 * d2 + d1 * (y1 - y3));
/** @type {?} */
var clipOutputCount = clipOutputLength >> 1;
/** @type {?} */
var clipOutputItems = this.clipOutput;
/** @type {?} */
var clippedVerticesItems = Utils.setArraySize(clippedVertices, s + clipOutputCount * vertexSize);
for (var ii = 0; ii < clipOutputLength; ii += 2) {
/** @type {?} */
var x = clipOutputItems[ii];
/** @type {?} */
var y = clipOutputItems[ii + 1];
clippedVerticesItems[s] = x;
clippedVerticesItems[s + 1] = y;
clippedVerticesItems[s + 2] = light.r;
clippedVerticesItems[s + 3] = light.g;
clippedVerticesItems[s + 4] = light.b;
clippedVerticesItems[s + 5] = light.a;
/** @type {?} */
var c0 = x - x3;
/** @type {?} */
var c1 = y - y3;
/** @type {?} */
var a = (d0 * c0 + d1 * c1) * d;
/** @type {?} */
var b = (d4 * c0 + d2 * c1) * d;
/** @type {?} */
var c = 1 - a - b;
clippedVerticesItems[s + 6] = u1 * a + u2 * b + u3 * c;
clippedVerticesItems[s + 7] = v1 * a + v2 * b + v3 * c;
if (twoColor) {
clippedVerticesItems[s + 8] = dark.r;
clippedVerticesItems[s + 9] = dark.g;
clippedVerticesItems[s + 10] = dark.b;
clippedVerticesItems[s + 11] = dark.a;
}
s += vertexSize;
}
s = clippedTriangles.length;
/** @type {?} */
var clippedTrianglesItems = Utils.setArraySize(clippedTriangles, s + 3 * (clipOutputCount - 2));
clipOutputCount--;
for (var ii = 1; ii < clipOutputCount; ii++) {
clippedTrianglesItems[s] = index;
clippedTrianglesItems[s + 1] = index + ii;
clippedTrianglesItems[s + 2] = index + ii + 1;
s += 3;
}
index += clipOutputCount + 1;
}
else {
/** @type {?} */
var clippedVerticesItems = Utils.setArraySize(clippedVertices, s + 3 * vertexSize);
clippedVerticesItems[s] = x1;
clippedVerticesItems[s + 1] = y1;
clippedVerticesItems[s + 2] = light.r;
clippedVerticesItems[s + 3] = light.g;
clippedVerticesItems[s + 4] = light.b;
clippedVerticesItems[s + 5] = light.a;
if (!twoColor) {
clippedVerticesItems[s + 6] = u1;
clippedVerticesItems[s + 7] = v1;
clippedVerticesItems[s + 8] = x2;
clippedVerticesItems[s + 9] = y2;
clippedVerticesItems[s + 10] = light.r;
clippedVerticesItems[s + 11] = light.g;
clippedVerticesItems[s + 12] = light.b;
clippedVerticesItems[s + 13] = light.a;
clippedVerticesItems[s + 14] = u2;
clippedVerticesItems[s + 15] = v2;
clippedVerticesItems[s + 16] = x3;
clippedVerticesItems[s + 17] = y3;
clippedVerticesItems[s + 18] = light.r;
clippedVerticesItems[s + 19] = light.g;
clippedVerticesItems[s + 20] = light.b;
clippedVerticesItems[s + 21] = light.a;
clippedVerticesItems[s + 22] = u3;
clippedVerticesItems[s + 23] = v3;
}
else {
clippedVerticesItems[s + 6] = u1;
clippedVerticesItems[s + 7] = v1;
clippedVerticesItems[s + 8] = dark.r;
clippedVerticesItems[s + 9] = dark.g;
clippedVerticesItems[s + 10] = dark.b;
clippedVerticesItems[s + 11] = dark.a;
clippedVerticesItems[s + 12] = x2;
clippedVerticesItems[s + 13] = y2;
clippedVerticesItems[s + 14] = light.r;
clippedVerticesItems[s + 15] = light.g;
clippedVerticesItems[s + 16] = light.b;
clippedVerticesItems[s + 17] = light.a;
clippedVerticesItems[s + 18] = u2;
clippedVerticesItems[s + 19] = v2;
clippedVerticesItems[s + 20] = dark.r;
clippedVerticesItems[s + 21] = dark.g;
clippedVerticesItems[s + 22] = dark.b;
clippedVerticesItems[s + 23] = dark.a;
clippedVerticesItems[s + 24] = x3;
clippedVerticesItems[s + 25] = y3;
clippedVerticesItems[s + 26] = light.r;
clippedVerticesItems[s + 27] = light.g;
clippedVerticesItems[s + 28] = light.b;
clippedVerticesItems[s + 29] = light.a;
clippedVerticesItems[s + 30] = u3;
clippedVerticesItems[s + 31] = v3;
clippedVerticesItems[s + 32] = dark.r;
clippedVerticesItems[s + 33] = dark.g;
clippedVerticesItems[s + 34] = dark.b;
clippedVerticesItems[s + 35] = dark.a;
}
s = clippedTriangles.length;
/** @type {?} */
var clippedTrianglesItems = Utils.setArraySize(clippedTriangles, s + 3);
clippedTrianglesItems[s] = index;
clippedTrianglesItems[s + 1] = index + 1;
clippedTrianglesItems[s + 2] = index + 2;
index += 3;
continue outer;
}
}
}
};
/** Clips the input triangle against the convex, clockwise clipping area. If the triangle lies entirely within the clipping
* area, false is returned. The clipping area must duplicate the first vertex at the end of the vertices list. */
/**
* Clips the input triangle against the convex, clockwise clipping area. If the triangle lies entirely within the clipping
* area, false is returned. The clipping area must duplicate the first vertex at the end of the vertices list.
* @param {?} x1
* @param {?} y1
* @param {?} x2
* @param {?} y2
* @param {?} x3
* @param {?} y3
* @param {?} clippingArea
* @param {?} output
* @return {?}
*/
SkeletonClipping.prototype.clip = /**
* Clips the input triangle against the convex, clockwise clipping area. If the triangle lies entirely within the clipping
* area, false is returned. The clipping area must duplicate the first vertex at the end of the vertices list.
* @param {?} x1
* @param {?} y1
* @param {?} x2
* @param {?} y2
* @param {?} x3
* @param {?} y3
* @param {?} clippingArea
* @param {?} output
* @return {?}
*/
function (x1, y1, x2, y2, x3, y3, clippingArea, output) {
/** @type {?} */
var originalOutput = output;
/** @type {?} */
var clipped = false;
// Avoid copy at the end.
/** @type {?} */
var input = null;
if (clippingArea.length % 4 >= 2) {
input = output;
output = this.scratch;
}
else
input = this.scratch;
input.length = 0;
input.push(x1);
input.push(y1);
input.push(x2);
input.push(y2);
input.push(x3);
input.push(y3);
input.push(x1);
input.push(y1);
output.length = 0;
/** @type {?} */
var clippingVertices = clippingArea;
/** @type {?} */
var clippingVerticesLast = clippingArea.length - 4;
for (var i = 0;; i += 2) {
/** @type {?} */
var edgeX = clippingVertices[i];
/** @type {?} */
var edgeY = clippingVertices[i + 1];
/** @type {?} */
var edgeX2 = clippingVertices[i + 2];
/** @type {?} */
var edgeY2 = clippingVertices[i + 3];
/** @type {?} */
var deltaX = edgeX - edgeX2;
/** @type {?} */
var deltaY = edgeY - edgeY2;
/** @type {?} */
var inputVertices = input;
/** @type {?} */
var inputVerticesLength = input.length - 2;
/** @type {?} */
var outputStart = output.length;
for (var ii = 0; ii < inputVerticesLength; ii += 2) {
/** @type {?} */
var inputX = inputVertices[ii];
/** @type {?} */
var inputY = inputVertices[ii + 1];
/** @type {?} */
var inputX2 = inputVertices[ii + 2];
/** @type {?} */
var inputY2 = inputVertices[ii + 3];
/** @type {?} */
var side2 = deltaX * (inputY2 - edgeY2) - deltaY * (inputX2 - edgeX2) > 0;
if (deltaX * (inputY - edgeY2) - deltaY * (inputX - edgeX2) > 0) {
if (side2) {
// v1 inside, v2 inside
output.push(inputX2);
output.push(inputY2);
continue;
}
// v1 inside, v2 outside
/** @type {?} */
var c0 = inputY2 - inputY;
/** @type {?} */
var c2 = inputX2 - inputX;
/** @type {?} */
var s = c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY);
if (Math.abs(s) > 0.000001) {
/** @type {?} */
var ua = (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / s;
output.push(edgeX + (edgeX2 - edgeX) * ua);
output.push(edgeY + (edgeY2 - edgeY) * ua);
}
else {
output.push(edgeX);
output.push(edgeY);
}
}
else if (side2) {
// v1 outside, v2 inside
/** @type {?} */
var c0 = inputY2 - inputY;
/** @type {?} */
var c2 = inputX2 - inputX;
/** @type {?} */
var s = c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY);
if (Math.abs(s) > 0.000001) {
/** @type {?} */
var ua = (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / s;
output.push(edgeX + (edgeX2 - edgeX) * ua);
output.push(edgeY + (edgeY2 - edgeY) * ua);
}
else {
output.push(edgeX);
output.push(edgeY);
}
output.push(inputX2);
output.push(inputY2);
}
clipped = true;
}
if (outputStart == output.length) {
// All edges outside.
originalOutput.length = 0;
return true;
}
output.push(output[0]);
output.push(output[1]);
if (i == clippingVerticesLast)
break;
/** @type {?} */
var temp = output;
output = input;
output.length = 0;
input = temp;
}
if (originalOutput != output) {
originalOutput.length = 0;
for (var i = 0, n = output.length - 2; i < n; i++)
originalOutput[i] = output[i];
}
else
originalOutput.length = originalOutput.length - 2;
return clipped;
};
/**
* @param {?} polygon
* @return {?}
*/
SkeletonClipping.makeClockwise = /**
* @param {?} polygon
* @return {?}
*/
function (polygon) {
/** @type {?} */
var vertices = polygon;
/** @type {?} */
var verticeslength = polygon.length;
/** @type {?} */
var area = vertices[verticeslength - 2] * vertices[1] -
vertices[0] * vertices[verticeslength - 1];
/** @type {?} */
var p1x = 0;
/** @type {?} */
var p1y = 0;
/** @type {?} */
var p2x = 0;
/** @type {?} */
var p2y = 0;
for (var i = 0, n = verticeslength - 3; i < n; i += 2) {
p1x = vertices[i];
p1y = vertices[i + 1];
p2x = vertices[i + 2];
p2y = vertices[i + 3];
area += p1x * p2y - p2x * p1y;
}
if (area < 0)
return;
for (var i = 0, lastX = verticeslength - 2, n = verticeslength >> 1; i < n; i += 2) {
/** @type {?} */
var x = vertices[i];
/** @type {?} */
var y = vertices[i + 1];
/** @type {?} */
var other = lastX - i;
vertices[i] = vertices[other];
vertices[i + 1] = vertices[other + 1];
vertices[other] = x;
vertices[other + 1] = y;
}
};
return SkeletonClipping;
}());
if (false) {
/**
* @type {?}
* @private
*/
SkeletonClipping.prototype.triangulator;
/**
* @type {?}
* @private
*/
SkeletonClipping.prototype.clippingPolygon;
/**
* @type {?}
* @private
*/
SkeletonClipping.prototype.clipOutput;
/** @type {?} */
SkeletonClipping.prototype.clippedVertices;
/** @type {?} */
SkeletonClipping.prototype.clippedTriangles;
/**
* @type {?}
* @private
*/
SkeletonClipping.prototype.scratch;
/**
* @type {?}
* @private
*/
SkeletonClipping.prototype.clipAttachment;
/**
* @type {?}
* @private
*/
SkeletonClipping.prototype.clippingPolygons;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @abstract
*/
var /**
* @abstract
*/
Attachment = /** @class */ (function () {
function Attachment(name) {
if (name == null)
throw new Error("name cannot be null.");
this.name = name;
}
return Attachment;
}());
if (false) {
/** @type {?} */
Attachment.prototype.name;
/**
* @abstract
* @return {?}
*/
Attachment.prototype.copy = function () { };
}
/**
* @abstract
*/
var VertexAttachment = /** @class */ (function (_super) {
__extends(VertexAttachment, _super);
function VertexAttachment(name) {
var _this = _super.call(this, name) || this;
_this.id = (VertexAttachment.nextID++ & 65535) << 11;
_this.worldVerticesLength = 0;
_this.deformAttachment = _this;
return _this;
}
/** Transforms local vertices to world coordinates.
* @param start The index of the first local vertex value to transform. Each vertex has 2 values, x and y.
* @param count The number of world vertex values to output. Must be <= {@link #getWorldVerticesLength()} - start.
* @param worldVertices The output world vertices. Must have a length >= offset + count.
* @param offset The worldVertices index to begin writing values. */
/**
* Transforms local vertices to world coordinates.
* @param {?} slot
* @param {?} start The index of the first local vertex value to transform. Each vertex has 2 values, x and y.
* @param {?} count The number of world vertex values to output. Must be <= {\@link #getWorldVerticesLength()} - start.
* @param {?} worldVertices The output world vertices. Must have a length >= offset + count.
* @param {?} offset The worldVertices index to begin writing values.
* @param {?} stride
* @return {?}
*/
VertexAttachment.prototype.computeWorldVertices = /**
* Transforms local vertices to world coordinates.
* @param {?} slot
* @param {?} start The index of the first local vertex value to transform. Each vertex has 2 values, x and y.
* @param {?} count The number of world vertex values to output. Must be <= {\@link #getWorldVerticesLength()} - start.
* @param {?} worldVertices The output world vertices. Must have a length >= offset + count.
* @param {?} offset The worldVertices index to begin writing values.
* @param {?} stride
* @return {?}
*/
function (slot, start, count, worldVertices, offset, stride) {
count = offset + (count >> 1) * stride;
/** @type {?} */
var skeleton = slot.bone.skeleton;
/** @type {?} */
var deformArray = slot.deform;
/** @type {?} */
var vertices = this.vertices;
/** @type {?} */
var bones = this.bones;
if (bones == null) {
if (deformArray.length > 0)
vertices = deformArray;
/** @type {?} */
var bone = slot.bone;
/** @type {?} */
var x = bone.worldX;
/** @type {?} */
var y = bone.worldY;
/** @type {?} */
var a = bone.a;
/** @type {?} */
var b = bone.b;
/** @type {?} */
var c = bone.c;
/** @type {?} */
var d = bone.d;
for (var v_1 = start, w = offset; w < count; v_1 += 2, w += stride) {
/** @type {?} */
var vx = vertices[v_1];
/** @type {?} */
var vy = vertices[v_1 + 1];
worldVertices[w] = vx * a + vy * b + x;
worldVertices[w + 1] = vx * c + vy * d + y;
}
return;
}
/** @type {?} */
var v = 0;
/** @type {?} */
var skip = 0;
for (var i = 0; i < start; i += 2) {
/** @type {?} */
var n = bones[v];
v += n + 1;
skip += n;
}
/** @type {?} */
var skeletonBones = skeleton.bones;
if (deformArray.length == 0) {
for (var w = offset, b = skip * 3; w < count; w += stride) {
/** @type {?} */
var wx = 0;
/** @type {?} */
var wy = 0;
/** @type {?} */
var n = bones[v++];
n += v;
for (; v < n; v++, b += 3) {
/** @type {?} */
var bone = skeletonBones[bones[v]];
/** @type {?} */
var vx = vertices[b];
/** @type {?} */
var vy = vertices[b + 1];
/** @type {?} */
var weight = vertices[b + 2];
wx += (vx * bone.a + vy * bone.b + bone.worldX) * weight;
wy += (vx * bone.c + vy * bone.d + bone.worldY) * weight;
}
worldVertices[w] = wx;
worldVertices[w + 1] = wy;
}
}
else {
/** @type {?} */
var deform = deformArray;
for (var w = offset, b = skip * 3, f = skip << 1; w < count; w += stride) {
/** @type {?} */
var wx = 0;
/** @type {?} */
var wy = 0;
/** @type {?} */
var n = bones[v++];
n += v;
for (; v < n; v++, b += 3, f += 2) {
/** @type {?} */
var bone = skeletonBones[bones[v]];
/** @type {?} */
var vx = vertices[b] + deform[f];
/** @type {?} */
var vy = vertices[b + 1] + deform[f + 1];
/** @type {?} */
var weight = vertices[b + 2];
wx += (vx * bone.a + vy * bone.b + bone.worldX) * weight;
wy += (vx * bone.c + vy * bone.d + bone.worldY) * weight;
}
worldVertices[w] = wx;
worldVertices[w + 1] = wy;
}
}
};
/**
* @param {?} attachment
* @return {?}
*/
VertexAttachment.prototype.copyTo = /**
* @param {?} attachment
* @return {?}
*/
function (attachment) {
if (this.bones != null) {
attachment.bones = new Array(this.bones.length);
Utils.arrayCopy(this.bones, 0, attachment.bones, 0, this.bones.length);
}
else
attachment.bones = null;
if (this.vertices != null) {
attachment.vertices = Utils.newFloatArray(this.vertices.length);
Utils.arrayCopy(this.vertices, 0, attachment.vertices, 0, this.vertices.length);
}
else
attachment.vertices = null;
attachment.worldVerticesLength = this.worldVerticesLength;
attachment.deformAttachment = this.deformAttachment;
};
VertexAttachment.nextID = 0;
return VertexAttachment;
}(Attachment));
if (false) {
/**
* @type {?}
* @private
*/
VertexAttachment.nextID;
/** @type {?} */
VertexAttachment.prototype.id;
/** @type {?} */
VertexAttachment.prototype.bones;
/** @type {?} */
VertexAttachment.prototype.vertices;
/** @type {?} */
VertexAttachment.prototype.worldVerticesLength;
/** @type {?} */
VertexAttachment.prototype.deformAttachment;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var RegionAttachment = /** @class */ (function (_super) {
__extends(RegionAttachment, _super);
function RegionAttachment(name) {
var _this = _super.call(this, name) || this;
_this.x = 0;
_this.y = 0;
_this.scaleX = 1;
_this.scaleY = 1;
_this.rotation = 0;
_this.width = 0;
_this.height = 0;
_this.color = new Color(1, 1, 1, 1);
_this.offset = Utils.newFloatArray(8);
_this.uvs = Utils.newFloatArray(8);
_this.tempColor = new Color(1, 1, 1, 1);
return _this;
}
/**
* @return {?}
*/
RegionAttachment.prototype.updateOffset = /**
* @return {?}
*/
function () {
/** @type {?} */
var regionScaleX = (this.width / this.region.originalWidth) * this.scaleX;
/** @type {?} */
var regionScaleY = (this.height / this.region.originalHeight) * this.scaleY;
/** @type {?} */
var localX = (-this.width / 2) * this.scaleX + this.region.offsetX * regionScaleX;
/** @type {?} */
var localY = (-this.height / 2) * this.scaleY + this.region.offsetY * regionScaleY;
/** @type {?} */
var localX2 = localX + this.region.width * regionScaleX;
/** @type {?} */
var localY2 = localY + this.region.height * regionScaleY;
/** @type {?} */
var radians = (this.rotation * Math.PI) / 180;
/** @type {?} */
var cos = Math.cos(radians);
/** @type {?} */
var sin = Math.sin(radians);
/** @type {?} */
var localXCos = localX * cos + this.x;
/** @type {?} */
var localXSin = localX * sin;
/** @type {?} */
var localYCos = localY * cos + this.y;
/** @type {?} */
var localYSin = localY * sin;
/** @type {?} */
var localX2Cos = localX2 * cos + this.x;
/** @type {?} */
var localX2Sin = localX2 * sin;
/** @type {?} */
var localY2Cos = localY2 * cos + this.y;
/** @type {?} */
var localY2Sin = localY2 * sin;
/** @type {?} */
var offset = this.offset;
offset[RegionAttachment.OX1] = localXCos - localYSin;
offset[RegionAttachment.OY1] = localYCos + localXSin;
offset[RegionAttachment.OX2] = localXCos - localY2Sin;
offset[RegionAttachment.OY2] = localY2Cos + localXSin;
offset[RegionAttachment.OX3] = localX2Cos - localY2Sin;
offset[RegionAttachment.OY3] = localY2Cos + localX2Sin;
offset[RegionAttachment.OX4] = localX2Cos - localYSin;
offset[RegionAttachment.OY4] = localYCos + localX2Sin;
};
/**
* @param {?} region
* @return {?}
*/
RegionAttachment.prototype.setRegion = /**
* @param {?} region
* @return {?}
*/
function (region) {
this.region = region;
/** @type {?} */
var uvs = this.uvs;
if (region.rotate) {
uvs[2] = region.u;
uvs[3] = region.v2;
uvs[4] = region.u;
uvs[5] = region.v;
uvs[6] = region.u2;
uvs[7] = region.v;
uvs[0] = region.u2;
uvs[1] = region.v2;
}
else {
uvs[0] = region.u;
uvs[1] = region.v2;
uvs[2] = region.u;
uvs[3] = region.v;
uvs[4] = region.u2;
uvs[5] = region.v;
uvs[6] = region.u2;
uvs[7] = region.v2;
}
};
/**
* @param {?} bone
* @param {?} worldVertices
* @param {?} offset
* @param {?} stride
* @return {?}
*/
RegionAttachment.prototype.computeWorldVertices = /**
* @param {?} bone
* @param {?} worldVertices
* @param {?} offset
* @param {?} stride
* @return {?}
*/
function (bone, worldVertices, offset, stride) {
/** @type {?} */
var vertexOffset = this.offset;
/** @type {?} */
var x = bone.worldX;
/** @type {?} */
var y = bone.worldY;
/** @type {?} */
var a = bone.a;
/** @type {?} */
var b = bone.b;
/** @type {?} */
var c = bone.c;
/** @type {?} */
var d = bone.d;
/** @type {?} */
var offsetX = 0;
/** @type {?} */
var offsetY = 0;
offsetX = vertexOffset[RegionAttachment.OX1];
offsetY = vertexOffset[RegionAttachment.OY1];
worldVertices[offset] = offsetX * a + offsetY * b + x; // br
worldVertices[offset + 1] = offsetX * c + offsetY * d + y;
offset += stride;
offsetX = vertexOffset[RegionAttachment.OX2];
offsetY = vertexOffset[RegionAttachment.OY2];
worldVertices[offset] = offsetX * a + offsetY * b + x; // bl
worldVertices[offset + 1] = offsetX * c + offsetY * d + y;
offset += stride;
offsetX = vertexOffset[RegionAttachment.OX3];
offsetY = vertexOffset[RegionAttachment.OY3];
worldVertices[offset] = offsetX * a + offsetY * b + x; // ul
worldVertices[offset + 1] = offsetX * c + offsetY * d + y;
offset += stride;
offsetX = vertexOffset[RegionAttachment.OX4];
offsetY = vertexOffset[RegionAttachment.OY4];
worldVertices[offset] = offsetX * a + offsetY * b + x; // ur
worldVertices[offset + 1] = offsetX * c + offsetY * d + y;
};
/**
* @return {?}
*/
RegionAttachment.prototype.copy = /**
* @return {?}
*/
function () {
/** @type {?} */
var copy = new RegionAttachment(name);
copy.region = this.region;
copy.rendererObject = this.rendererObject;
copy.path = this.path;
copy.x = this.x;
copy.y = this.y;
copy.scaleX = this.scaleX;
copy.scaleY = this.scaleY;
copy.rotation = this.rotation;
copy.width = this.width;
copy.height = this.height;
Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, 8);
Utils.arrayCopy(this.offset, 0, copy.offset, 0, 8);
copy.color.setFromColor(this.color);
return copy;
};
RegionAttachment.OX1 = 0;
RegionAttachment.OY1 = 1;
RegionAttachment.OX2 = 2;
RegionAttachment.OY2 = 3;
RegionAttachment.OX3 = 4;
RegionAttachment.OY3 = 5;
RegionAttachment.OX4 = 6;
RegionAttachment.OY4 = 7;
RegionAttachment.X1 = 0;
RegionAttachment.Y1 = 1;
RegionAttachment.C1R = 2;
RegionAttachment.C1G = 3;
RegionAttachment.C1B = 4;
RegionAttachment.C1A = 5;
RegionAttachment.U1 = 6;
RegionAttachment.V1 = 7;
RegionAttachment.X2 = 8;
RegionAttachment.Y2 = 9;
RegionAttachment.C2R = 10;
RegionAttachment.C2G = 11;
RegionAttachment.C2B = 12;
RegionAttachment.C2A = 13;
RegionAttachment.U2 = 14;
RegionAttachment.V2 = 15;
RegionAttachment.X3 = 16;
RegionAttachment.Y3 = 17;
RegionAttachment.C3R = 18;
RegionAttachment.C3G = 19;
RegionAttachment.C3B = 20;
RegionAttachment.C3A = 21;
RegionAttachment.U3 = 22;
RegionAttachment.V3 = 23;
RegionAttachment.X4 = 24;
RegionAttachment.Y4 = 25;
RegionAttachment.C4R = 26;
RegionAttachment.C4G = 27;
RegionAttachment.C4B = 28;
RegionAttachment.C4A = 29;
RegionAttachment.U4 = 30;
RegionAttachment.V4 = 31;
return RegionAttachment;
}(Attachment));
if (false) {
/** @type {?} */
RegionAttachment.OX1;
/** @type {?} */
RegionAttachment.OY1;
/** @type {?} */
RegionAttachment.OX2;
/** @type {?} */
RegionAttachment.OY2;
/** @type {?} */
RegionAttachment.OX3;
/** @type {?} */
RegionAttachment.OY3;
/** @type {?} */
RegionAttachment.OX4;
/** @type {?} */
RegionAttachment.OY4;
/** @type {?} */
RegionAttachment.X1;
/** @type {?} */
RegionAttachment.Y1;
/** @type {?} */
RegionAttachment.C1R;
/** @type {?} */
RegionAttachment.C1G;
/** @type {?} */
RegionAttachment.C1B;
/** @type {?} */
RegionAttachment.C1A;
/** @type {?} */
RegionAttachment.U1;
/** @type {?} */
RegionAttachment.V1;
/** @type {?} */
RegionAttachment.X2;
/** @type {?} */
RegionAttachment.Y2;
/** @type {?} */
RegionAttachment.C2R;
/** @type {?} */
RegionAttachment.C2G;
/** @type {?} */
RegionAttachment.C2B;
/** @type {?} */
RegionAttachment.C2A;
/** @type {?} */
RegionAttachment.U2;
/** @type {?} */
RegionAttachment.V2;
/** @type {?} */
RegionAttachment.X3;
/** @type {?} */
RegionAttachment.Y3;
/** @type {?} */
RegionAttachment.C3R;
/** @type {?} */
RegionAttachment.C3G;
/** @type {?} */
RegionAttachment.C3B;
/** @type {?} */
RegionAttachment.C3A;
/** @type {?} */
RegionAttachment.U3;
/** @type {?} */
RegionAttachment.V3;
/** @type {?} */
RegionAttachment.X4;
/** @type {?} */
RegionAttachment.Y4;
/** @type {?} */
RegionAttachment.C4R;
/** @type {?} */
RegionAttachment.C4G;
/** @type {?} */
RegionAttachment.C4B;
/** @type {?} */
RegionAttachment.C4A;
/** @type {?} */
RegionAttachment.U4;
/** @type {?} */
RegionAttachment.V4;
/** @type {?} */
RegionAttachment.prototype.x;
/** @type {?} */
RegionAttachment.prototype.y;
/** @type {?} */
RegionAttachment.prototype.scaleX;
/** @type {?} */
RegionAttachment.prototype.scaleY;
/** @type {?} */
RegionAttachment.prototype.rotation;
/** @type {?} */
RegionAttachment.prototype.width;
/** @type {?} */
RegionAttachment.prototype.height;
/** @type {?} */
RegionAttachment.prototype.color;
/** @type {?} */
RegionAttachment.prototype.path;
/** @type {?} */
RegionAttachment.prototype.rendererObject;
/** @type {?} */
RegionAttachment.prototype.region;
/** @type {?} */
RegionAttachment.prototype.offset;
/** @type {?} */
RegionAttachment.prototype.uvs;
/** @type {?} */
RegionAttachment.prototype.tempColor;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var MeshAttachment = /** @class */ (function (_super) {
__extends(MeshAttachment, _super);
function MeshAttachment(name) {
var _this = _super.call(this, name) || this;
_this.color = new Color(1, 1, 1, 1);
_this.tempColor = new Color(0, 0, 0, 0);
return _this;
}
/**
* @return {?}
*/
MeshAttachment.prototype.updateUVs = /**
* @return {?}
*/
function () {
/** @type {?} */
var regionUVs = this.regionUVs;
if (this.uvs == null || this.uvs.length != regionUVs.length)
this.uvs = Utils.newFloatArray(regionUVs.length);
/** @type {?} */
var uvs = this.uvs;
/** @type {?} */
var n = this.uvs.length;
/** @type {?} */
var u = this.region.u;
/** @type {?} */
var v = this.region.v;
/** @type {?} */
var width = 0;
/** @type {?} */
var height = 0;
if (this.region instanceof TextureAtlasRegion) {
/** @type {?} */
var region = this.region;
/** @type {?} */
var textureWidth = region.texture.getImage().width;
/** @type {?} */
var textureHeight = region.texture.getImage().height;
switch (region.degrees) {
case 90:
u -=
(region.originalHeight - region.offsetY - region.height) /
textureWidth;
v -=
(region.originalWidth - region.offsetX - region.width) /
textureHeight;
width = region.originalHeight / textureWidth;
height = region.originalWidth / textureHeight;
for (var i = 0; i < n; i += 2) {
uvs[i] = u + regionUVs[i + 1] * width;
uvs[i + 1] = v + (1 - regionUVs[i]) * height;
}
return;
case 180:
u -=
(region.originalWidth - region.offsetX - region.width) /
textureWidth;
v -= region.offsetY / textureHeight;
width = region.originalWidth / textureWidth;
height = region.originalHeight / textureHeight;
for (var i = 0; i < n; i += 2) {
uvs[i] = u + (1 - regionUVs[i]) * width;
uvs[i + 1] = v + (1 - regionUVs[i + 1]) * height;
}
return;
case 270:
u -= region.offsetY / textureWidth;
v -= region.offsetX / textureHeight;
width = region.originalHeight / textureWidth;
height = region.originalWidth / textureHeight;
for (var i = 0; i < n; i += 2) {
uvs[i] = u + (1 - regionUVs[i + 1]) * width;
uvs[i + 1] = v + regionUVs[i] * height;
}
return;
}
u -= region.offsetX / textureWidth;
v -=
(region.originalHeight - region.offsetY - region.height) /
textureHeight;
width = region.originalWidth / textureWidth;
height = region.originalHeight / textureHeight;
}
else if (this.region == null) {
u = v = 0;
width = height = 1;
}
else {
width = this.region.u2 - u;
height = this.region.v2 - v;
}
for (var i = 0; i < n; i += 2) {
uvs[i] = u + regionUVs[i] * width;
uvs[i + 1] = v + regionUVs[i + 1] * height;
}
};
/**
* @return {?}
*/
MeshAttachment.prototype.getParentMesh = /**
* @return {?}
*/
function () {
return this.parentMesh;
};
/** @param parentMesh May be null. */
/**
* @param {?} parentMesh May be null.
* @return {?}
*/
MeshAttachment.prototype.setParentMesh = /**
* @param {?} parentMesh May be null.
* @return {?}
*/
function (parentMesh) {
this.parentMesh = parentMesh;
if (parentMesh != null) {
this.bones = parentMesh.bones;
this.vertices = parentMesh.vertices;
this.worldVerticesLength = parentMesh.worldVerticesLength;
this.regionUVs = parentMesh.regionUVs;
this.triangles = parentMesh.triangles;
this.hullLength = parentMesh.hullLength;
this.worldVerticesLength = parentMesh.worldVerticesLength;
}
};
/**
* @return {?}
*/
MeshAttachment.prototype.copy = /**
* @return {?}
*/
function () {
if (this.parentMesh != null)
return this.newLinkedMesh();
/** @type {?} */
var copy = new MeshAttachment(this.name);
copy.region = this.region;
copy.path = this.path;
copy.color.setFromColor(this.color);
this.copyTo(copy);
copy.regionUVs = new Array(this.regionUVs.length);
Utils.arrayCopy(this.regionUVs, 0, copy.regionUVs, 0, this.regionUVs.length);
copy.uvs = new Array(this.uvs.length);
Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, this.uvs.length);
copy.triangles = new Array(this.triangles.length);
Utils.arrayCopy(this.triangles, 0, copy.triangles, 0, this.triangles.length);
copy.hullLength = this.hullLength;
// Nonessential.
if (this.edges != null) {
copy.edges = new Array(this.edges.length);
Utils.arrayCopy(this.edges, 0, copy.edges, 0, this.edges.length);
}
copy.width = this.width;
copy.height = this.height;
return copy;
};
/**
* @return {?}
*/
MeshAttachment.prototype.newLinkedMesh = /**
* @return {?}
*/
function () {
/** @type {?} */
var copy = new MeshAttachment(this.name);
copy.region = this.region;
copy.path = this.path;
copy.color.setFromColor(this.color);
copy.deformAttachment = this.deformAttachment;
copy.setParentMesh(this.parentMesh != null ? this.parentMesh : this);
copy.updateUVs();
return copy;
};
return MeshAttachment;
}(VertexAttachment));
if (false) {
/** @type {?} */
MeshAttachment.prototype.region;
/** @type {?} */
MeshAttachment.prototype.path;
/** @type {?} */
MeshAttachment.prototype.regionUVs;
/** @type {?} */
MeshAttachment.prototype.uvs;
/** @type {?} */
MeshAttachment.prototype.triangles;
/** @type {?} */
MeshAttachment.prototype.color;
/** @type {?} */
MeshAttachment.prototype.width;
/** @type {?} */
MeshAttachment.prototype.height;
/** @type {?} */
MeshAttachment.prototype.hullLength;
/** @type {?} */
MeshAttachment.prototype.edges;
/**
* @type {?}
* @private
*/
MeshAttachment.prototype.parentMesh;
/** @type {?} */
MeshAttachment.prototype.tempColor;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var ClippingAttachment = /** @class */ (function (_super) {
__extends(ClippingAttachment, _super);
function ClippingAttachment(name) {
var _this = _super.call(this, name) || this;
// Nonessential.
_this.color = new Color(0.2275, 0.2275, 0.8078, 1); // ce3a3aff
return _this;
}
/**
* @return {?}
*/
ClippingAttachment.prototype.copy = /**
* @return {?}
*/
function () {
/** @type {?} */
var copy = new ClippingAttachment(name);
this.copyTo(copy);
copy.endSlot = this.endSlot;
copy.color.setFromColor(this.color);
return copy;
};
return ClippingAttachment;
}(VertexAttachment));
if (false) {
/** @type {?} */
ClippingAttachment.prototype.endSlot;
/** @type {?} */
ClippingAttachment.prototype.color;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var Renderable = /** @class */ (function () {
function Renderable(vertices, numVertices, numFloats) {
this.vertices = vertices;
this.numVertices = numVertices;
this.numFloats = numFloats;
}
return Renderable;
}());
if (false) {
/** @type {?} */
Renderable.prototype.vertices;
/** @type {?} */
Renderable.prototype.numVertices;
/** @type {?} */
Renderable.prototype.numFloats;
}
var SkeletonRenderer = /** @class */ (function () {
function SkeletonRenderer(context, twoColorTint) {
if (twoColorTint === void 0) { twoColorTint = true; }
this.premultipliedAlpha = false;
this.vertexEffect = null;
this.tempColor = new Color();
this.tempColor2 = new Color();
this.vertexSize = 2 + 2 + 4;
this.twoColorTint = false;
this.renderable = new Renderable(null, 0, 0);
this.clipper = new SkeletonClipping();
this.temp = new Vector2();
this.temp2 = new Vector2();
this.temp3 = new Color();
this.temp4 = new Color();
this.twoColorTint = twoColorTint;
if (twoColorTint)
this.vertexSize += 4;
this.vertices = Utils.newFloatArray(this.vertexSize * 1024);
}
/**
* @param {?} batcher
* @param {?} skeleton
* @param {?=} slotRangeStart
* @param {?=} slotRangeEnd
* @return {?}
*/
SkeletonRenderer.prototype.draw = /**
* @param {?} batcher
* @param {?} skeleton
* @param {?=} slotRangeStart
* @param {?=} slotRangeEnd
* @return {?}
*/
function (batcher, skeleton, slotRangeStart, slotRangeEnd) {
if (slotRangeStart === void 0) { slotRangeStart = -1; }
if (slotRangeEnd === void 0) { slotRangeEnd = -1; }
/** @type {?} */
var clipper = this.clipper;
/** @type {?} */
var premultipliedAlpha = this.premultipliedAlpha;
/** @type {?} */
var twoColorTint = this.twoColorTint;
/** @type {?} */
var blendMode = null;
/** @type {?} */
var tempPos = this.temp;
/** @type {?} */
var tempUv = this.temp2;
/** @type {?} */
var tempLight = this.temp3;
/** @type {?} */
var tempDark = this.temp4;
/** @type {?} */
var renderable = this.renderable;
/** @type {?} */
var uvs = null;
/** @type {?} */
var triangles = null;
/** @type {?} */
var drawOrder = skeleton.drawOrder;
/** @type {?} */
var attachmentColor = null;
/** @type {?} */
var skeletonColor = skeleton.color;
/** @type {?} */
var vertexSize = twoColorTint ? 12 : 8;
/** @type {?} */
var inRange = false;
if (slotRangeStart == -1)
inRange = true;
for (var i = 0, n = drawOrder.length; i < n; i++) {
/** @type {?} */
var clippedVertexSize = clipper.isClipping() ? 2 : vertexSize;
/** @type {?} */
var slot = drawOrder[i];
if (slotRangeStart >= 0 && slotRangeStart == slot.data.index) {
inRange = true;
}
if (!inRange) {
clipper.clipEndWithSlot(slot);
continue;
}
if (slotRangeEnd >= 0 && slotRangeEnd == slot.data.index) {
inRange = false;
}
/** @type {?} */
var attachment = slot.getAttachment();
/** @type {?} */
var texture = null;
if (attachment instanceof RegionAttachment) {
/** @type {?} */
var region = (/** @type {?} */ (attachment));
renderable.vertices = this.vertices;
renderable.numVertices = 4;
renderable.numFloats = clippedVertexSize << 2;
region.computeWorldVertices(slot.bone, renderable.vertices, 0, clippedVertexSize);
triangles = SkeletonRenderer.QUAD_TRIANGLES;
uvs = region.uvs;
texture = (/** @type {?} */ ((((/** @type {?} */ (region.region.renderObject))).texture)));
attachmentColor = region.color;
}
else if (attachment instanceof MeshAttachment) {
/** @type {?} */
var mesh = (/** @type {?} */ (attachment));
renderable.vertices = this.vertices;
renderable.numVertices = mesh.worldVerticesLength >> 1;
renderable.numFloats = renderable.numVertices * clippedVertexSize;
if (renderable.numFloats > renderable.vertices.length) {
renderable.vertices = this.vertices = Utils.newFloatArray(renderable.numFloats);
}
mesh.computeWorldVertices(slot, 0, mesh.worldVerticesLength, renderable.vertices, 0, clippedVertexSize);
triangles = mesh.triangles;
texture = (/** @type {?} */ ((((/** @type {?} */ (mesh.region.renderObject))).texture)));
uvs = mesh.uvs;
attachmentColor = mesh.color;
}
else if (attachment instanceof ClippingAttachment) {
/** @type {?} */
var clip = (/** @type {?} */ (attachment));
clipper.clipStart(slot, clip);
continue;
}
else {
clipper.clipEndWithSlot(slot);
continue;
}
if (texture != null) {
/** @type {?} */
var slotColor = slot.color;
/** @type {?} */
var finalColor = this.tempColor;
finalColor.r = skeletonColor.r * slotColor.r * attachmentColor.r;
finalColor.g = skeletonColor.g * slotColor.g * attachmentColor.g;
finalColor.b = skeletonColor.b * slotColor.b * attachmentColor.b;
finalColor.a = skeletonColor.a * slotColor.a * attachmentColor.a;
if (premultipliedAlpha) {
finalColor.r *= finalColor.a;
finalColor.g *= finalColor.a;
finalColor.b *= finalColor.a;
}
/** @type {?} */
var darkColor = this.tempColor2;
if (slot.darkColor == null)
darkColor.set(0, 0, 0, 1.0);
else {
if (premultipliedAlpha) {
darkColor.r = slot.darkColor.r * finalColor.a;
darkColor.g = slot.darkColor.g * finalColor.a;
darkColor.b = slot.darkColor.b * finalColor.a;
}
else {
darkColor.setFromColor(slot.darkColor);
}
darkColor.a = premultipliedAlpha ? 1.0 : 0.0;
}
/** @type {?} */
var slotBlendMode = slot.data.blendMode;
if (slotBlendMode != blendMode) {
blendMode = slotBlendMode;
batcher.setBlendMode(WebGLBlendModeConverter.getSourceGLBlendMode(blendMode, premultipliedAlpha), WebGLBlendModeConverter.getDestGLBlendMode(blendMode));
}
if (clipper.isClipping()) {
clipper.clipTriangles(renderable.vertices, renderable.numFloats, triangles, triangles.length, uvs, finalColor, darkColor, twoColorTint);
/** @type {?} */
var clippedVertices = new Float32Array(clipper.clippedVertices);
/** @type {?} */
var clippedTriangles = clipper.clippedTriangles;
if (this.vertexEffect != null) {
/** @type {?} */
var vertexEffect = this.vertexEffect;
/** @type {?} */
var verts = clippedVertices;
if (!twoColorTint) {
for (var v = 0, n_1 = clippedVertices.length; v < n_1; v += vertexSize) {
tempPos.x = verts[v];
tempPos.y = verts[v + 1];
tempLight.set(verts[v + 2], verts[v + 3], verts[v + 4], verts[v + 5]);
tempUv.x = verts[v + 6];
tempUv.y = verts[v + 7];
tempDark.set(0, 0, 0, 0);
vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
verts[v] = tempPos.x;
verts[v + 1] = tempPos.y;
verts[v + 2] = tempLight.r;
verts[v + 3] = tempLight.g;
verts[v + 4] = tempLight.b;
verts[v + 5] = tempLight.a;
verts[v + 6] = tempUv.x;
verts[v + 7] = tempUv.y;
}
}
else {
for (var v = 0, n_2 = clippedVertices.length; v < n_2; v += vertexSize) {
tempPos.x = verts[v];
tempPos.y = verts[v + 1];
tempLight.set(verts[v + 2], verts[v + 3], verts[v + 4], verts[v + 5]);
tempUv.x = verts[v + 6];
tempUv.y = verts[v + 7];
tempDark.set(verts[v + 8], verts[v + 9], verts[v + 10], verts[v + 11]);
vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
verts[v] = tempPos.x;
verts[v + 1] = tempPos.y;
verts[v + 2] = tempLight.r;
verts[v + 3] = tempLight.g;
verts[v + 4] = tempLight.b;
verts[v + 5] = tempLight.a;
verts[v + 6] = tempUv.x;
verts[v + 7] = tempUv.y;
verts[v + 8] = tempDark.r;
verts[v + 9] = tempDark.g;
verts[v + 10] = tempDark.b;
verts[v + 11] = tempDark.a;
}
}
}
batcher.draw(texture, clippedVertices, clippedTriangles);
}
else {
/** @type {?} */
var verts = renderable.vertices;
if (this.vertexEffect != null) {
/** @type {?} */
var vertexEffect = this.vertexEffect;
if (!twoColorTint) {
for (var v = 0, u = 0, n_3 = renderable.numFloats; v < n_3; v += vertexSize, u += 2) {
tempPos.x = verts[v];
tempPos.y = verts[v + 1];
tempUv.x = uvs[u];
tempUv.y = uvs[u + 1];
tempLight.setFromColor(finalColor);
tempDark.set(0, 0, 0, 0);
vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
verts[v] = tempPos.x;
verts[v + 1] = tempPos.y;
verts[v + 2] = tempLight.r;
verts[v + 3] = tempLight.g;
verts[v + 4] = tempLight.b;
verts[v + 5] = tempLight.a;
verts[v + 6] = tempUv.x;
verts[v + 7] = tempUv.y;
}
}
else {
for (var v = 0, u = 0, n_4 = renderable.numFloats; v < n_4; v += vertexSize, u += 2) {
tempPos.x = verts[v];
tempPos.y = verts[v + 1];
tempUv.x = uvs[u];
tempUv.y = uvs[u + 1];
tempLight.setFromColor(finalColor);
tempDark.setFromColor(darkColor);
vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
verts[v] = tempPos.x;
verts[v + 1] = tempPos.y;
verts[v + 2] = tempLight.r;
verts[v + 3] = tempLight.g;
verts[v + 4] = tempLight.b;
verts[v + 5] = tempLight.a;
verts[v + 6] = tempUv.x;
verts[v + 7] = tempUv.y;
verts[v + 8] = tempDark.r;
verts[v + 9] = tempDark.g;
verts[v + 10] = tempDark.b;
verts[v + 11] = tempDark.a;
}
}
}
else {
if (!twoColorTint) {
for (var v = 2, u = 0, n_5 = renderable.numFloats; v < n_5; v += vertexSize, u += 2) {
verts[v] = finalColor.r;
verts[v + 1] = finalColor.g;
verts[v + 2] = finalColor.b;
verts[v + 3] = finalColor.a;
verts[v + 4] = uvs[u];
verts[v + 5] = uvs[u + 1];
}
}
else {
for (var v = 2, u = 0, n_6 = renderable.numFloats; v < n_6; v += vertexSize, u += 2) {
verts[v] = finalColor.r;
verts[v + 1] = finalColor.g;
verts[v + 2] = finalColor.b;
verts[v + 3] = finalColor.a;
verts[v + 4] = uvs[u];
verts[v + 5] = uvs[u + 1];
verts[v + 6] = darkColor.r;
verts[v + 7] = darkColor.g;
verts[v + 8] = darkColor.b;
verts[v + 9] = darkColor.a;
}
}
}
/** @type {?} */
var view = ((/** @type {?} */ (renderable.vertices))).subarray(0, renderable.numFloats);
batcher.draw(texture, view, triangles);
}
}
clipper.clipEndWithSlot(slot);
}
clipper.clipEnd();
};
SkeletonRenderer.QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0];
return SkeletonRenderer;
}());
if (false) {
/** @type {?} */
SkeletonRenderer.QUAD_TRIANGLES;
/** @type {?} */
SkeletonRenderer.prototype.premultipliedAlpha;
/** @type {?} */
SkeletonRenderer.prototype.vertexEffect;
/**
* @type {?}
* @private
*/
SkeletonRenderer.prototype.tempColor;
/**
* @type {?}
* @private
*/
SkeletonRenderer.prototype.tempColor2;
/**
* @type {?}
* @private
*/
SkeletonRenderer.prototype.vertices;
/**
* @type {?}
* @private
*/
SkeletonRenderer.prototype.vertexSize;
/**
* @type {?}
* @private
*/
SkeletonRenderer.prototype.twoColorTint;
/**
* @type {?}
* @private
*/
SkeletonRenderer.prototype.renderable;
/**
* @type {?}
* @private
*/
SkeletonRenderer.prototype.clipper;
/**
* @type {?}
* @private
*/
SkeletonRenderer.prototype.temp;
/**
* @type {?}
* @private
*/
SkeletonRenderer.prototype.temp2;
/**
* @type {?}
* @private
*/
SkeletonRenderer.prototype.temp3;
/**
* @type {?}
* @private
*/
SkeletonRenderer.prototype.temp4;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var BoundingBoxAttachment = /** @class */ (function (_super) {
__extends(BoundingBoxAttachment, _super);
function BoundingBoxAttachment(name) {
var _this = _super.call(this, name) || this;
_this.color = new Color(1, 1, 1, 1);
return _this;
}
/**
* @return {?}
*/
BoundingBoxAttachment.prototype.copy = /**
* @return {?}
*/
function () {
/** @type {?} */
var copy = new BoundingBoxAttachment(name);
this.copyTo(copy);
copy.color.setFromColor(this.color);
return copy;
};
return BoundingBoxAttachment;
}(VertexAttachment));
if (false) {
/** @type {?} */
BoundingBoxAttachment.prototype.color;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var SkeletonBounds = /** @class */ (function () {
function SkeletonBounds() {
this.minX = 0;
this.minY = 0;
this.maxX = 0;
this.maxY = 0;
this.boundingBoxes = new Array();
this.polygons = new Array();
this.polygonPool = new Pool((/**
* @return {?}
*/
function () {
return Utils.newFloatArray(16);
}));
}
/**
* @param {?} skeleton
* @param {?} updateAabb
* @return {?}
*/
SkeletonBounds.prototype.update = /**
* @param {?} skeleton
* @param {?} updateAabb
* @return {?}
*/
function (skeleton, updateAabb) {
if (skeleton == null)
throw new Error("skeleton cannot be null.");
/** @type {?} */
var boundingBoxes = this.boundingBoxes;
/** @type {?} */
var polygons = this.polygons;
/** @type {?} */
var polygonPool = this.polygonPool;
/** @type {?} */
var slots = skeleton.slots;
/** @type {?} */
var slotCount = slots.length;
boundingBoxes.length = 0;
polygonPool.freeAll(polygons);
polygons.length = 0;
for (var i = 0; i < slotCount; i++) {
/** @type {?} */
var slot = slots[i];
if (!slot.bone.active)
continue;
/** @type {?} */
var attachment = slot.getAttachment();
if (attachment instanceof BoundingBoxAttachment) {
/** @type {?} */
var boundingBox = (/** @type {?} */ (attachment));
boundingBoxes.push(boundingBox);
/** @type {?} */
var polygon = polygonPool.obtain();
if (polygon.length != boundingBox.worldVerticesLength) {
polygon = Utils.newFloatArray(boundingBox.worldVerticesLength);
}
polygons.push(polygon);
boundingBox.computeWorldVertices(slot, 0, boundingBox.worldVerticesLength, polygon, 0, 2);
}
}
if (updateAabb) {
this.aabbCompute();
}
else {
this.minX = Number.POSITIVE_INFINITY;
this.minY = Number.POSITIVE_INFINITY;
this.maxX = Number.NEGATIVE_INFINITY;
this.maxY = Number.NEGATIVE_INFINITY;
}
};
/**
* @return {?}
*/
SkeletonBounds.prototype.aabbCompute = /**
* @return {?}
*/
function () {
/** @type {?} */
var minX = Number.POSITIVE_INFINITY;
/** @type {?} */
var minY = Number.POSITIVE_INFINITY;
/** @type {?} */
var maxX = Number.NEGATIVE_INFINITY;
/** @type {?} */
var maxY = Number.NEGATIVE_INFINITY;
/** @type {?} */
var polygons = this.polygons;
for (var i = 0, n = polygons.length; i < n; i++) {
/** @type {?} */
var polygon = polygons[i];
/** @type {?} */
var vertices = polygon;
for (var ii = 0, nn = polygon.length; ii < nn; ii += 2) {
/** @type {?} */
var x = vertices[ii];
/** @type {?} */
var y = vertices[ii + 1];
minX = Math.min(minX, x);
minY = Math.min(minY, y);
maxX = Math.max(maxX, x);
maxY = Math.max(maxY, y);
}
}
this.minX = minX;
this.minY = minY;
this.maxX = maxX;
this.maxY = maxY;
};
/** Returns true if the axis aligned bounding box contains the point. */
/**
* Returns true if the axis aligned bounding box contains the point.
* @param {?} x
* @param {?} y
* @return {?}
*/
SkeletonBounds.prototype.aabbContainsPoint = /**
* Returns true if the axis aligned bounding box contains the point.
* @param {?} x
* @param {?} y
* @return {?}
*/
function (x, y) {
return x >= this.minX && x <= this.maxX && y >= this.minY && y <= this.maxY;
};
/** Returns true if the axis aligned bounding box intersects the line segment. */
/**
* Returns true if the axis aligned bounding box intersects the line segment.
* @param {?} x1
* @param {?} y1
* @param {?} x2
* @param {?} y2
* @return {?}
*/
SkeletonBounds.prototype.aabbIntersectsSegment = /**
* Returns true if the axis aligned bounding box intersects the line segment.
* @param {?} x1
* @param {?} y1
* @param {?} x2
* @param {?} y2
* @return {?}
*/
function (x1, y1, x2, y2) {
/** @type {?} */
var minX = this.minX;
/** @type {?} */
var minY = this.minY;
/** @type {?} */
var maxX = this.maxX;
/** @type {?} */
var maxY = this.maxY;
if ((x1 <= minX && x2 <= minX) ||
(y1 <= minY && y2 <= minY) ||
(x1 >= maxX && x2 >= maxX) ||
(y1 >= maxY && y2 >= maxY))
return false;
/** @type {?} */
var m = (y2 - y1) / (x2 - x1);
/** @type {?} */
var y = m * (minX - x1) + y1;
if (y > minY && y < maxY)
return true;
y = m * (maxX - x1) + y1;
if (y > minY && y < maxY)
return true;
/** @type {?} */
var x = (minY - y1) / m + x1;
if (x > minX && x < maxX)
return true;
x = (maxY - y1) / m + x1;
if (x > minX && x < maxX)
return true;
return false;
};
/** Returns true if the axis aligned bounding box intersects the axis aligned bounding box of the specified bounds. */
/**
* Returns true if the axis aligned bounding box intersects the axis aligned bounding box of the specified bounds.
* @param {?} bounds
* @return {?}
*/
SkeletonBounds.prototype.aabbIntersectsSkeleton = /**
* Returns true if the axis aligned bounding box intersects the axis aligned bounding box of the specified bounds.
* @param {?} bounds
* @return {?}
*/
function (bounds) {
return (this.minX < bounds.maxX &&
this.maxX > bounds.minX &&
this.minY < bounds.maxY &&
this.maxY > bounds.minY);
};
/** Returns the first bounding box attachment that contains the point, or null. When doing many checks, it is usually more
* efficient to only call this method if {@link #aabbContainsPoint(float, float)} returns true. */
/**
* Returns the first bounding box attachment that contains the point, or null. When doing many checks, it is usually more
* efficient to only call this method if {\@link #aabbContainsPoint(float, float)} returns true.
* @param {?} x
* @param {?} y
* @return {?}
*/
SkeletonBounds.prototype.containsPoint = /**
* Returns the first bounding box attachment that contains the point, or null. When doing many checks, it is usually more
* efficient to only call this method if {\@link #aabbContainsPoint(float, float)} returns true.
* @param {?} x
* @param {?} y
* @return {?}
*/
function (x, y) {
/** @type {?} */
var polygons = this.polygons;
for (var i = 0, n = polygons.length; i < n; i++)
if (this.containsPointPolygon(polygons[i], x, y))
return this.boundingBoxes[i];
return null;
};
/** Returns true if the polygon contains the point. */
/**
* Returns true if the polygon contains the point.
* @param {?} polygon
* @param {?} x
* @param {?} y
* @return {?}
*/
SkeletonBounds.prototype.containsPointPolygon = /**
* Returns true if the polygon contains the point.
* @param {?} polygon
* @param {?} x
* @param {?} y
* @return {?}
*/
function (polygon, x, y) {
/** @type {?} */
var vertices = polygon;
/** @type {?} */
var nn = polygon.length;
/** @type {?} */
var prevIndex = nn - 2;
/** @type {?} */
var inside = false;
for (var ii = 0; ii < nn; ii += 2) {
/** @type {?} */
var vertexY = vertices[ii + 1];
/** @type {?} */
var prevY = vertices[prevIndex + 1];
if ((vertexY < y && prevY >= y) || (prevY < y && vertexY >= y)) {
/** @type {?} */
var vertexX = vertices[ii];
if (vertexX +
((y - vertexY) / (prevY - vertexY)) *
(vertices[prevIndex] - vertexX) <
x)
inside = !inside;
}
prevIndex = ii;
}
return inside;
};
/** Returns the first bounding box attachment that contains any part of the line segment, or null. When doing many checks, it
* is usually more efficient to only call this method if {@link #aabbIntersectsSegment(float, float, float, float)} returns
* true. */
/**
* Returns the first bounding box attachment that contains any part of the line segment, or null. When doing many checks, it
* is usually more efficient to only call this method if {\@link #aabbIntersectsSegment(float, float, float, float)} returns
* true.
* @param {?} x1
* @param {?} y1
* @param {?} x2
* @param {?} y2
* @return {?}
*/
SkeletonBounds.prototype.intersectsSegment = /**
* Returns the first bounding box attachment that contains any part of the line segment, or null. When doing many checks, it
* is usually more efficient to only call this method if {\@link #aabbIntersectsSegment(float, float, float, float)} returns
* true.
* @param {?} x1
* @param {?} y1
* @param {?} x2
* @param {?} y2
* @return {?}
*/
function (x1, y1, x2, y2) {
/** @type {?} */
var polygons = this.polygons;
for (var i = 0, n = polygons.length; i < n; i++)
if (this.intersectsSegmentPolygon(polygons[i], x1, y1, x2, y2))
return this.boundingBoxes[i];
return null;
};
/** Returns true if the polygon contains any part of the line segment. */
/**
* Returns true if the polygon contains any part of the line segment.
* @param {?} polygon
* @param {?} x1
* @param {?} y1
* @param {?} x2
* @param {?} y2
* @return {?}
*/
SkeletonBounds.prototype.intersectsSegmentPolygon = /**
* Returns true if the polygon contains any part of the line segment.
* @param {?} polygon
* @param {?} x1
* @param {?} y1
* @param {?} x2
* @param {?} y2
* @return {?}
*/
function (polygon, x1, y1, x2, y2) {
/** @type {?} */
var vertices = polygon;
/** @type {?} */
var nn = polygon.length;
/** @type {?} */
var width12 = x1 - x2;
/** @type {?} */
var height12 = y1 - y2;
/** @type {?} */
var det1 = x1 * y2 - y1 * x2;
/** @type {?} */
var x3 = vertices[nn - 2];
/** @type {?} */
var y3 = vertices[nn - 1];
for (var ii = 0; ii < nn; ii += 2) {
/** @type {?} */
var x4 = vertices[ii];
/** @type {?} */
var y4 = vertices[ii + 1];
/** @type {?} */
var det2 = x3 * y4 - y3 * x4;
/** @type {?} */
var width34 = x3 - x4;
/** @type {?} */
var height34 = y3 - y4;
/** @type {?} */
var det3 = width12 * height34 - height12 * width34;
/** @type {?} */
var x = (det1 * width34 - width12 * det2) / det3;
if (((x >= x3 && x <= x4) || (x >= x4 && x <= x3)) &&
((x >= x1 && x <= x2) || (x >= x2 && x <= x1))) {
/** @type {?} */
var y = (det1 * height34 - height12 * det2) / det3;
if (((y >= y3 && y <= y4) || (y >= y4 && y <= y3)) &&
((y >= y1 && y <= y2) || (y >= y2 && y <= y1)))
return true;
}
x3 = x4;
y3 = y4;
}
return false;
};
/** Returns the polygon for the specified bounding box, or null. */
/**
* Returns the polygon for the specified bounding box, or null.
* @param {?} boundingBox
* @return {?}
*/
SkeletonBounds.prototype.getPolygon = /**
* Returns the polygon for the specified bounding box, or null.
* @param {?} boundingBox
* @return {?}
*/
function (boundingBox) {
if (boundingBox == null)
throw new Error("boundingBox cannot be null.");
/** @type {?} */
var index = this.boundingBoxes.indexOf(boundingBox);
return index == -1 ? null : this.polygons[index];
};
/**
* @return {?}
*/
SkeletonBounds.prototype.getWidth = /**
* @return {?}
*/
function () {
return this.maxX - this.minX;
};
/**
* @return {?}
*/
SkeletonBounds.prototype.getHeight = /**
* @return {?}
*/
function () {
return this.maxY - this.minY;
};
return SkeletonBounds;
}());
if (false) {
/** @type {?} */
SkeletonBounds.prototype.minX;
/** @type {?} */
SkeletonBounds.prototype.minY;
/** @type {?} */
SkeletonBounds.prototype.maxX;
/** @type {?} */
SkeletonBounds.prototype.maxY;
/** @type {?} */
SkeletonBounds.prototype.boundingBoxes;
/** @type {?} */
SkeletonBounds.prototype.polygons;
/**
* @type {?}
* @private
*/
SkeletonBounds.prototype.polygonPool;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var PathAttachment = /** @class */ (function (_super) {
__extends(PathAttachment, _super);
function PathAttachment(name) {
var _this = _super.call(this, name) || this;
_this.closed = false;
_this.constantSpeed = false;
_this.color = new Color(1, 1, 1, 1);
return _this;
}
/**
* @return {?}
*/
PathAttachment.prototype.copy = /**
* @return {?}
*/
function () {
/** @type {?} */
var copy = new PathAttachment(name);
this.copyTo(copy);
copy.lengths = new Array(this.lengths.length);
Utils.arrayCopy(this.lengths, 0, copy.lengths, 0, this.lengths.length);
copy.closed = closed;
copy.constantSpeed = this.constantSpeed;
copy.color.setFromColor(this.color);
return copy;
};
return PathAttachment;
}(VertexAttachment));
if (false) {
/** @type {?} */
PathAttachment.prototype.lengths;
/** @type {?} */
PathAttachment.prototype.closed;
/** @type {?} */
PathAttachment.prototype.constantSpeed;
/** @type {?} */
PathAttachment.prototype.color;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var SkeletonDebugRenderer = /** @class */ (function () {
function SkeletonDebugRenderer(context) {
this.boneLineColor = new Color(1, 0, 0, 1);
this.boneOriginColor = new Color(0, 1, 0, 1);
this.attachmentLineColor = new Color(0, 0, 1, 0.5);
this.triangleLineColor = new Color(1, 0.64, 0, 0.5);
this.pathColor = new Color().setFromString("FF7F00");
this.clipColor = new Color(0.8, 0, 0, 2);
this.aabbColor = new Color(0, 1, 0, 0.5);
this.drawBones = true;
this.drawRegionAttachments = true;
this.drawBoundingBoxes = true;
this.drawMeshHull = true;
this.drawMeshTriangles = true;
this.drawPaths = true;
this.drawSkeletonXY = false;
this.drawClipping = true;
this.premultipliedAlpha = false;
this.scale = 1;
this.boneWidth = 2;
this.bounds = new SkeletonBounds();
this.temp = new Array();
this.vertices = Utils.newFloatArray(2 * 1024);
this.context =
context instanceof ManagedWebGLRenderingContext
? context
: new ManagedWebGLRenderingContext(context);
}
/**
* @param {?} shapes
* @param {?} skeleton
* @param {?=} ignoredBones
* @return {?}
*/
SkeletonDebugRenderer.prototype.draw = /**
* @param {?} shapes
* @param {?} skeleton
* @param {?=} ignoredBones
* @return {?}
*/
function (shapes, skeleton, ignoredBones) {
if (ignoredBones === void 0) { ignoredBones = null; }
/** @type {?} */
var skeletonX = skeleton.x;
/** @type {?} */
var skeletonY = skeleton.y;
/** @type {?} */
var gl = this.context.gl;
/** @type {?} */
var srcFunc = this.premultipliedAlpha ? gl.ONE : gl.SRC_ALPHA;
shapes.setBlendMode(srcFunc, gl.ONE_MINUS_SRC_ALPHA);
/** @type {?} */
var bones = skeleton.bones;
if (this.drawBones) {
shapes.setColor(this.boneLineColor);
for (var i = 0, n = bones.length; i < n; i++) {
/** @type {?} */
var bone = bones[i];
if (ignoredBones && ignoredBones.indexOf(bone.data.name) > -1)
continue;
if (bone.parent == null)
continue;
/** @type {?} */
var x = skeletonX + bone.data.length * bone.a + bone.worldX;
/** @type {?} */
var y = skeletonY + bone.data.length * bone.c + bone.worldY;
shapes.rectLine(true, skeletonX + bone.worldX, skeletonY + bone.worldY, x, y, this.boneWidth * this.scale);
}
if (this.drawSkeletonXY)
shapes.x(skeletonX, skeletonY, 4 * this.scale);
}
if (this.drawRegionAttachments) {
shapes.setColor(this.attachmentLineColor);
/** @type {?} */
var slots = skeleton.slots;
for (var i = 0, n = slots.length; i < n; i++) {
/** @type {?} */
var slot = slots[i];
/** @type {?} */
var attachment = slot.getAttachment();
if (attachment instanceof RegionAttachment) {
/** @type {?} */
var regionAttachment = (/** @type {?} */ (attachment));
/** @type {?} */
var vertices = this.vertices;
regionAttachment.computeWorldVertices(slot.bone, vertices, 0, 2);
shapes.line(vertices[0], vertices[1], vertices[2], vertices[3]);
shapes.line(vertices[2], vertices[3], vertices[4], vertices[5]);
shapes.line(vertices[4], vertices[5], vertices[6], vertices[7]);
shapes.line(vertices[6], vertices[7], vertices[0], vertices[1]);
}
}
}
if (this.drawMeshHull || this.drawMeshTriangles) {
/** @type {?} */
var slots = skeleton.slots;
for (var i = 0, n = slots.length; i < n; i++) {
/** @type {?} */
var slot = slots[i];
/** @type {?} */
var attachment = slot.getAttachment();
if (!(attachment instanceof MeshAttachment))
continue;
/** @type {?} */
var mesh = (/** @type {?} */ (attachment));
/** @type {?} */
var vertices = this.vertices;
mesh.computeWorldVertices(slot, 0, mesh.worldVerticesLength, vertices, 0, 2);
/** @type {?} */
var triangles = mesh.triangles;
/** @type {?} */
var hullLength = mesh.hullLength;
if (this.drawMeshTriangles) {
shapes.setColor(this.triangleLineColor);
for (var ii = 0, nn = triangles.length; ii < nn; ii += 3) {
/** @type {?} */
var v1 = triangles[ii] * 2;
/** @type {?} */
var v2 = triangles[ii + 1] * 2;
/** @type {?} */
var v3 = triangles[ii + 2] * 2;
shapes.triangle(false, vertices[v1], vertices[v1 + 1], //
vertices[v2], vertices[v2 + 1], //
vertices[v3], vertices[v3 + 1] //
);
}
}
if (this.drawMeshHull && hullLength > 0) {
shapes.setColor(this.attachmentLineColor);
hullLength = (hullLength >> 1) * 2;
/** @type {?} */
var lastX = vertices[hullLength - 2];
/** @type {?} */
var lastY = vertices[hullLength - 1];
for (var ii = 0, nn = hullLength; ii < nn; ii += 2) {
/** @type {?} */
var x = vertices[ii];
/** @type {?} */
var y = vertices[ii + 1];
shapes.line(x, y, lastX, lastY);
lastX = x;
lastY = y;
}
}
}
}
if (this.drawBoundingBoxes) {
/** @type {?} */
var bounds = this.bounds;
bounds.update(skeleton, true);
shapes.setColor(this.aabbColor);
shapes.rect(false, bounds.minX, bounds.minY, bounds.getWidth(), bounds.getHeight());
/** @type {?} */
var polygons = bounds.polygons;
/** @type {?} */
var boxes = bounds.boundingBoxes;
for (var i = 0, n = polygons.length; i < n; i++) {
/** @type {?} */
var polygon = polygons[i];
shapes.setColor(boxes[i].color);
shapes.polygon(polygon, 0, polygon.length);
}
}
if (this.drawPaths) {
/** @type {?} */
var slots = skeleton.slots;
for (var i = 0, n = slots.length; i < n; i++) {
/** @type {?} */
var slot = slots[i];
/** @type {?} */
var attachment = slot.getAttachment();
if (!(attachment instanceof PathAttachment))
continue;
/** @type {?} */
var path = (/** @type {?} */ (attachment));
/** @type {?} */
var nn = path.worldVerticesLength;
/** @type {?} */
var world = (this.temp = Utils.setArraySize(this.temp, nn, 0));
path.computeWorldVertices(slot, 0, nn, world, 0, 2);
/** @type {?} */
var color = this.pathColor;
/** @type {?} */
var x1 = world[2];
/** @type {?} */
var y1 = world[3];
/** @type {?} */
var x2 = 0;
/** @type {?} */
var y2 = 0;
if (path.closed) {
shapes.setColor(color);
/** @type {?} */
var cx1 = world[0];
/** @type {?} */
var cy1 = world[1];
/** @type {?} */
var cx2 = world[nn - 2];
/** @type {?} */
var cy2 = world[nn - 1];
x2 = world[nn - 4];
y2 = world[nn - 3];
shapes.curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, 32);
shapes.setColor(SkeletonDebugRenderer.LIGHT_GRAY);
shapes.line(x1, y1, cx1, cy1);
shapes.line(x2, y2, cx2, cy2);
}
nn -= 4;
for (var ii = 4; ii < nn; ii += 6) {
/** @type {?} */
var cx1 = world[ii];
/** @type {?} */
var cy1 = world[ii + 1];
/** @type {?} */
var cx2 = world[ii + 2];
/** @type {?} */
var cy2 = world[ii + 3];
x2 = world[ii + 4];
y2 = world[ii + 5];
shapes.setColor(color);
shapes.curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, 32);
shapes.setColor(SkeletonDebugRenderer.LIGHT_GRAY);
shapes.line(x1, y1, cx1, cy1);
shapes.line(x2, y2, cx2, cy2);
x1 = x2;
y1 = y2;
}
}
}
if (this.drawBones) {
shapes.setColor(this.boneOriginColor);
for (var i = 0, n = bones.length; i < n; i++) {
/** @type {?} */
var bone = bones[i];
if (ignoredBones && ignoredBones.indexOf(bone.data.name) > -1)
continue;
shapes.circle(true, skeletonX + bone.worldX, skeletonY + bone.worldY, 3 * this.scale, SkeletonDebugRenderer.GREEN, 8);
}
}
if (this.drawClipping) {
/** @type {?} */
var slots = skeleton.slots;
shapes.setColor(this.clipColor);
for (var i = 0, n = slots.length; i < n; i++) {
/** @type {?} */
var slot = slots[i];
/** @type {?} */
var attachment = slot.getAttachment();
if (!(attachment instanceof ClippingAttachment))
continue;
/** @type {?} */
var clip = (/** @type {?} */ (attachment));
/** @type {?} */
var nn = clip.worldVerticesLength;
/** @type {?} */
var world = (this.temp = Utils.setArraySize(this.temp, nn, 0));
clip.computeWorldVertices(slot, 0, nn, world, 0, 2);
for (var i_1 = 0, n_1 = world.length; i_1 < n_1; i_1 += 2) {
/** @type {?} */
var x = world[i_1];
/** @type {?} */
var y = world[i_1 + 1];
/** @type {?} */
var x2 = world[(i_1 + 2) % world.length];
/** @type {?} */
var y2 = world[(i_1 + 3) % world.length];
shapes.line(x, y, x2, y2);
}
}
}
};
/**
* @return {?}
*/
SkeletonDebugRenderer.prototype.dispose = /**
* @return {?}
*/
function () { };
SkeletonDebugRenderer.LIGHT_GRAY = new Color(192 / 255, 192 / 255, 192 / 255, 1);
SkeletonDebugRenderer.GREEN = new Color(0, 1, 0, 1);
return SkeletonDebugRenderer;
}());
if (false) {
/**
* @type {?}
* @private
*/
SkeletonDebugRenderer.LIGHT_GRAY;
/**
* @type {?}
* @private
*/
SkeletonDebugRenderer.GREEN;
/** @type {?} */
SkeletonDebugRenderer.prototype.boneLineColor;
/** @type {?} */
SkeletonDebugRenderer.prototype.boneOriginColor;
/** @type {?} */
SkeletonDebugRenderer.prototype.attachmentLineColor;
/** @type {?} */
SkeletonDebugRenderer.prototype.triangleLineColor;
/** @type {?} */
SkeletonDebugRenderer.prototype.pathColor;
/** @type {?} */
SkeletonDebugRenderer.prototype.clipColor;
/** @type {?} */
SkeletonDebugRenderer.prototype.aabbColor;
/** @type {?} */
SkeletonDebugRenderer.prototype.drawBones;
/** @type {?} */
SkeletonDebugRenderer.prototype.drawRegionAttachments;
/** @type {?} */
SkeletonDebugRenderer.prototype.drawBoundingBoxes;
/** @type {?} */
SkeletonDebugRenderer.prototype.drawMeshHull;
/** @type {?} */
SkeletonDebugRenderer.prototype.drawMeshTriangles;
/** @type {?} */
SkeletonDebugRenderer.prototype.drawPaths;
/** @type {?} */
SkeletonDebugRenderer.prototype.drawSkeletonXY;
/** @type {?} */
SkeletonDebugRenderer.prototype.drawClipping;
/** @type {?} */
SkeletonDebugRenderer.prototype.premultipliedAlpha;
/** @type {?} */
SkeletonDebugRenderer.prototype.scale;
/** @type {?} */
SkeletonDebugRenderer.prototype.boneWidth;
/**
* @type {?}
* @private
*/
SkeletonDebugRenderer.prototype.context;
/**
* @type {?}
* @private
*/
SkeletonDebugRenderer.prototype.bounds;
/**
* @type {?}
* @private
*/
SkeletonDebugRenderer.prototype.temp;
/**
* @type {?}
* @private
*/
SkeletonDebugRenderer.prototype.vertices;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var SceneRenderer = /** @class */ (function () {
function SceneRenderer(canvas, context, twoColorTint) {
if (twoColorTint === void 0) { twoColorTint = true; }
this.twoColorTint = false;
this.activeRenderer = null;
this.QUAD = [
0,
0,
1,
1,
1,
1,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0
];
this.QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0];
this.WHITE = new Color(1, 1, 1, 1);
this.canvas = canvas;
this.context =
context instanceof ManagedWebGLRenderingContext
? context
: new ManagedWebGLRenderingContext(context);
this.twoColorTint = twoColorTint;
this.camera = new OrthoCamera(canvas.width, canvas.height);
this.batcherShader = twoColorTint
? Shader.newTwoColoredTextured(this.context)
: Shader.newColoredTextured(this.context);
this.batcher = new PolygonBatcher(this.context, twoColorTint);
this.shapesShader = Shader.newColored(this.context);
this.shapes = new ShapeRenderer(this.context);
this.skeletonRenderer = new SkeletonRenderer(this.context, twoColorTint);
this.skeletonDebugRenderer = new SkeletonDebugRenderer(this.context);
}
/**
* @return {?}
*/
SceneRenderer.prototype.begin = /**
* @return {?}
*/
function () {
this.camera.update();
this.enableRenderer(this.batcher);
};
/**
* @param {?} skeleton
* @param {?=} premultipliedAlpha
* @param {?=} slotRangeStart
* @param {?=} slotRangeEnd
* @return {?}
*/
SceneRenderer.prototype.drawSkeleton = /**
* @param {?} skeleton
* @param {?=} premultipliedAlpha
* @param {?=} slotRangeStart
* @param {?=} slotRangeEnd
* @return {?}
*/
function (skeleton, premultipliedAlpha, slotRangeStart, slotRangeEnd) {
if (premultipliedAlpha === void 0) { premultipliedAlpha = false; }
if (slotRangeStart === void 0) { slotRangeStart = -1; }
if (slotRangeEnd === void 0) { slotRangeEnd = -1; }
this.enableRenderer(this.batcher);
this.skeletonRenderer.premultipliedAlpha = premultipliedAlpha;
this.skeletonRenderer.draw(this.batcher, skeleton, slotRangeStart, slotRangeEnd);
};
/**
* @param {?} skeleton
* @param {?=} premultipliedAlpha
* @param {?=} ignoredBones
* @return {?}
*/
SceneRenderer.prototype.drawSkeletonDebug = /**
* @param {?} skeleton
* @param {?=} premultipliedAlpha
* @param {?=} ignoredBones
* @return {?}
*/
function (skeleton, premultipliedAlpha, ignoredBones) {
if (premultipliedAlpha === void 0) { premultipliedAlpha = false; }
if (ignoredBones === void 0) { ignoredBones = null; }
this.enableRenderer(this.shapes);
this.skeletonDebugRenderer.premultipliedAlpha = premultipliedAlpha;
this.skeletonDebugRenderer.draw(this.shapes, skeleton, ignoredBones);
};
/**
* @param {?} texture
* @param {?} x
* @param {?} y
* @param {?} width
* @param {?} height
* @param {?=} color
* @return {?}
*/
SceneRenderer.prototype.drawTexture = /**
* @param {?} texture
* @param {?} x
* @param {?} y
* @param {?} width
* @param {?} height
* @param {?=} color
* @return {?}
*/
function (texture, x, y, width, height, color) {
if (color === void 0) { color = null; }
this.enableRenderer(this.batcher);
if (color === null)
color = this.WHITE;
/** @type {?} */
var quad = this.QUAD;
/** @type {?} */
var i = 0;
quad[i++] = x;
quad[i++] = y;
quad[i++] = color.r;
quad[i++] = color.g;
quad[i++] = color.b;
quad[i++] = color.a;
quad[i++] = 0;
quad[i++] = 1;
if (this.twoColorTint) {
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
}
quad[i++] = x + width;
quad[i++] = y;
quad[i++] = color.r;
quad[i++] = color.g;
quad[i++] = color.b;
quad[i++] = color.a;
quad[i++] = 1;
quad[i++] = 1;
if (this.twoColorTint) {
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
}
quad[i++] = x + width;
quad[i++] = y + height;
quad[i++] = color.r;
quad[i++] = color.g;
quad[i++] = color.b;
quad[i++] = color.a;
quad[i++] = 1;
quad[i++] = 0;
if (this.twoColorTint) {
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
}
quad[i++] = x;
quad[i++] = y + height;
quad[i++] = color.r;
quad[i++] = color.g;
quad[i++] = color.b;
quad[i++] = color.a;
quad[i++] = 0;
quad[i++] = 0;
if (this.twoColorTint) {
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
}
this.batcher.draw(texture, quad, this.QUAD_TRIANGLES);
};
/**
* @param {?} texture
* @param {?} x
* @param {?} y
* @param {?} width
* @param {?} height
* @param {?} u
* @param {?} v
* @param {?} u2
* @param {?} v2
* @param {?=} color
* @return {?}
*/
SceneRenderer.prototype.drawTextureUV = /**
* @param {?} texture
* @param {?} x
* @param {?} y
* @param {?} width
* @param {?} height
* @param {?} u
* @param {?} v
* @param {?} u2
* @param {?} v2
* @param {?=} color
* @return {?}
*/
function (texture, x, y, width, height, u, v, u2, v2, color) {
if (color === void 0) { color = null; }
this.enableRenderer(this.batcher);
if (color === null)
color = this.WHITE;
/** @type {?} */
var quad = this.QUAD;
/** @type {?} */
var i = 0;
quad[i++] = x;
quad[i++] = y;
quad[i++] = color.r;
quad[i++] = color.g;
quad[i++] = color.b;
quad[i++] = color.a;
quad[i++] = u;
quad[i++] = v;
if (this.twoColorTint) {
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
}
quad[i++] = x + width;
quad[i++] = y;
quad[i++] = color.r;
quad[i++] = color.g;
quad[i++] = color.b;
quad[i++] = color.a;
quad[i++] = u2;
quad[i++] = v;
if (this.twoColorTint) {
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
}
quad[i++] = x + width;
quad[i++] = y + height;
quad[i++] = color.r;
quad[i++] = color.g;
quad[i++] = color.b;
quad[i++] = color.a;
quad[i++] = u2;
quad[i++] = v2;
if (this.twoColorTint) {
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
}
quad[i++] = x;
quad[i++] = y + height;
quad[i++] = color.r;
quad[i++] = color.g;
quad[i++] = color.b;
quad[i++] = color.a;
quad[i++] = u;
quad[i++] = v2;
if (this.twoColorTint) {
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
}
this.batcher.draw(texture, quad, this.QUAD_TRIANGLES);
};
/**
* @param {?} texture
* @param {?} x
* @param {?} y
* @param {?} width
* @param {?} height
* @param {?} pivotX
* @param {?} pivotY
* @param {?} angle
* @param {?=} color
* @param {?=} premultipliedAlpha
* @return {?}
*/
SceneRenderer.prototype.drawTextureRotated = /**
* @param {?} texture
* @param {?} x
* @param {?} y
* @param {?} width
* @param {?} height
* @param {?} pivotX
* @param {?} pivotY
* @param {?} angle
* @param {?=} color
* @param {?=} premultipliedAlpha
* @return {?}
*/
function (texture, x, y, width, height, pivotX, pivotY, angle, color, premultipliedAlpha) {
if (color === void 0) { color = null; }
if (premultipliedAlpha === void 0) { premultipliedAlpha = false; }
this.enableRenderer(this.batcher);
if (color === null)
color = this.WHITE;
/** @type {?} */
var quad = this.QUAD;
// bottom left and top right corner points relative to origin
/** @type {?} */
var worldOriginX = x + pivotX;
/** @type {?} */
var worldOriginY = y + pivotY;
/** @type {?} */
var fx = -pivotX;
/** @type {?} */
var fy = -pivotY;
/** @type {?} */
var fx2 = width - pivotX;
/** @type {?} */
var fy2 = height - pivotY;
// construct corner points, start from top left and go counter clockwise
/** @type {?} */
var p1x = fx;
/** @type {?} */
var p1y = fy;
/** @type {?} */
var p2x = fx;
/** @type {?} */
var p2y = fy2;
/** @type {?} */
var p3x = fx2;
/** @type {?} */
var p3y = fy2;
/** @type {?} */
var p4x = fx2;
/** @type {?} */
var p4y = fy;
/** @type {?} */
var x1 = 0;
/** @type {?} */
var y1 = 0;
/** @type {?} */
var x2 = 0;
/** @type {?} */
var y2 = 0;
/** @type {?} */
var x3 = 0;
/** @type {?} */
var y3 = 0;
/** @type {?} */
var x4 = 0;
/** @type {?} */
var y4 = 0;
// rotate
if (angle != 0) {
/** @type {?} */
var cos = MathUtils.cosDeg(angle);
/** @type {?} */
var sin = MathUtils.sinDeg(angle);
x1 = cos * p1x - sin * p1y;
y1 = sin * p1x + cos * p1y;
x4 = cos * p2x - sin * p2y;
y4 = sin * p2x + cos * p2y;
x3 = cos * p3x - sin * p3y;
y3 = sin * p3x + cos * p3y;
x2 = x3 + (x1 - x4);
y2 = y3 + (y1 - y4);
}
else {
x1 = p1x;
y1 = p1y;
x4 = p2x;
y4 = p2y;
x3 = p3x;
y3 = p3y;
x2 = p4x;
y2 = p4y;
}
x1 += worldOriginX;
y1 += worldOriginY;
x2 += worldOriginX;
y2 += worldOriginY;
x3 += worldOriginX;
y3 += worldOriginY;
x4 += worldOriginX;
y4 += worldOriginY;
/** @type {?} */
var i = 0;
quad[i++] = x1;
quad[i++] = y1;
quad[i++] = color.r;
quad[i++] = color.g;
quad[i++] = color.b;
quad[i++] = color.a;
quad[i++] = 0;
quad[i++] = 1;
if (this.twoColorTint) {
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
}
quad[i++] = x2;
quad[i++] = y2;
quad[i++] = color.r;
quad[i++] = color.g;
quad[i++] = color.b;
quad[i++] = color.a;
quad[i++] = 1;
quad[i++] = 1;
if (this.twoColorTint) {
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
}
quad[i++] = x3;
quad[i++] = y3;
quad[i++] = color.r;
quad[i++] = color.g;
quad[i++] = color.b;
quad[i++] = color.a;
quad[i++] = 1;
quad[i++] = 0;
if (this.twoColorTint) {
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
}
quad[i++] = x4;
quad[i++] = y4;
quad[i++] = color.r;
quad[i++] = color.g;
quad[i++] = color.b;
quad[i++] = color.a;
quad[i++] = 0;
quad[i++] = 0;
if (this.twoColorTint) {
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
}
this.batcher.draw(texture, quad, this.QUAD_TRIANGLES);
};
/**
* @param {?} region
* @param {?} x
* @param {?} y
* @param {?} width
* @param {?} height
* @param {?=} color
* @param {?=} premultipliedAlpha
* @return {?}
*/
SceneRenderer.prototype.drawRegion = /**
* @param {?} region
* @param {?} x
* @param {?} y
* @param {?} width
* @param {?} height
* @param {?=} color
* @param {?=} premultipliedAlpha
* @return {?}
*/
function (region, x, y, width, height, color, premultipliedAlpha) {
if (color === void 0) { color = null; }
if (premultipliedAlpha === void 0) { premultipliedAlpha = false; }
this.enableRenderer(this.batcher);
if (color === null)
color = this.WHITE;
/** @type {?} */
var quad = this.QUAD;
/** @type {?} */
var i = 0;
quad[i++] = x;
quad[i++] = y;
quad[i++] = color.r;
quad[i++] = color.g;
quad[i++] = color.b;
quad[i++] = color.a;
quad[i++] = region.u;
quad[i++] = region.v2;
if (this.twoColorTint) {
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
}
quad[i++] = x + width;
quad[i++] = y;
quad[i++] = color.r;
quad[i++] = color.g;
quad[i++] = color.b;
quad[i++] = color.a;
quad[i++] = region.u2;
quad[i++] = region.v2;
if (this.twoColorTint) {
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
}
quad[i++] = x + width;
quad[i++] = y + height;
quad[i++] = color.r;
quad[i++] = color.g;
quad[i++] = color.b;
quad[i++] = color.a;
quad[i++] = region.u2;
quad[i++] = region.v;
if (this.twoColorTint) {
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
}
quad[i++] = x;
quad[i++] = y + height;
quad[i++] = color.r;
quad[i++] = color.g;
quad[i++] = color.b;
quad[i++] = color.a;
quad[i++] = region.u;
quad[i++] = region.v;
if (this.twoColorTint) {
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
quad[i++] = 0;
}
this.batcher.draw((/** @type {?} */ (region.texture)), quad, this.QUAD_TRIANGLES);
};
/**
* @param {?} x
* @param {?} y
* @param {?} x2
* @param {?} y2
* @param {?=} color
* @param {?=} color2
* @return {?}
*/
SceneRenderer.prototype.line = /**
* @param {?} x
* @param {?} y
* @param {?} x2
* @param {?} y2
* @param {?=} color
* @param {?=} color2
* @return {?}
*/
function (x, y, x2, y2, color, color2) {
if (color === void 0) { color = null; }
if (color2 === void 0) { color2 = null; }
this.enableRenderer(this.shapes);
this.shapes.line(x, y, x2, y2, color);
};
/**
* @param {?} filled
* @param {?} x
* @param {?} y
* @param {?} x2
* @param {?} y2
* @param {?} x3
* @param {?} y3
* @param {?=} color
* @param {?=} color2
* @param {?=} color3
* @return {?}
*/
SceneRenderer.prototype.triangle = /**
* @param {?} filled
* @param {?} x
* @param {?} y
* @param {?} x2
* @param {?} y2
* @param {?} x3
* @param {?} y3
* @param {?=} color
* @param {?=} color2
* @param {?=} color3
* @return {?}
*/
function (filled, x, y, x2, y2, x3, y3, color, color2, color3) {
if (color === void 0) { color = null; }
if (color2 === void 0) { color2 = null; }
if (color3 === void 0) { color3 = null; }
this.enableRenderer(this.shapes);
this.shapes.triangle(filled, x, y, x2, y2, x3, y3, color, color2, color3);
};
/**
* @param {?} filled
* @param {?} x
* @param {?} y
* @param {?} x2
* @param {?} y2
* @param {?} x3
* @param {?} y3
* @param {?} x4
* @param {?} y4
* @param {?=} color
* @param {?=} color2
* @param {?=} color3
* @param {?=} color4
* @return {?}
*/
SceneRenderer.prototype.quad = /**
* @param {?} filled
* @param {?} x
* @param {?} y
* @param {?} x2
* @param {?} y2
* @param {?} x3
* @param {?} y3
* @param {?} x4
* @param {?} y4
* @param {?=} color
* @param {?=} color2
* @param {?=} color3
* @param {?=} color4
* @return {?}
*/
function (filled, x, y, x2, y2, x3, y3, x4, y4, color, color2, color3, color4) {
if (color === void 0) { color = null; }
if (color2 === void 0) { color2 = null; }
if (color3 === void 0) { color3 = null; }
if (color4 === void 0) { color4 = null; }
this.enableRenderer(this.shapes);
this.shapes.quad(filled, x, y, x2, y2, x3, y3, x4, y4, color, color2, color3, color4);
};
/**
* @param {?} filled
* @param {?} x
* @param {?} y
* @param {?} width
* @param {?} height
* @param {?=} color
* @return {?}
*/
SceneRenderer.prototype.rect = /**
* @param {?} filled
* @param {?} x
* @param {?} y
* @param {?} width
* @param {?} height
* @param {?=} color
* @return {?}
*/
function (filled, x, y, width, height, color) {
if (color === void 0) { color = null; }
this.enableRenderer(this.shapes);
this.shapes.rect(filled, x, y, width, height, color);
};
/**
* @param {?} filled
* @param {?} x1
* @param {?} y1
* @param {?} x2
* @param {?} y2
* @param {?} width
* @param {?=} color
* @return {?}
*/
SceneRenderer.prototype.rectLine = /**
* @param {?} filled
* @param {?} x1
* @param {?} y1
* @param {?} x2
* @param {?} y2
* @param {?} width
* @param {?=} color
* @return {?}
*/
function (filled, x1, y1, x2, y2, width, color) {
if (color === void 0) { color = null; }
this.enableRenderer(this.shapes);
this.shapes.rectLine(filled, x1, y1, x2, y2, width, color);
};
/**
* @param {?} polygonVertices
* @param {?} offset
* @param {?} count
* @param {?=} color
* @return {?}
*/
SceneRenderer.prototype.polygon = /**
* @param {?} polygonVertices
* @param {?} offset
* @param {?} count
* @param {?=} color
* @return {?}
*/
function (polygonVertices, offset, count, color) {
if (color === void 0) { color = null; }
this.enableRenderer(this.shapes);
this.shapes.polygon(polygonVertices, offset, count, color);
};
/**
* @param {?} filled
* @param {?} x
* @param {?} y
* @param {?} radius
* @param {?=} color
* @param {?=} segments
* @return {?}
*/
SceneRenderer.prototype.circle = /**
* @param {?} filled
* @param {?} x
* @param {?} y
* @param {?} radius
* @param {?=} color
* @param {?=} segments
* @return {?}
*/
function (filled, x, y, radius, color, segments) {
if (color === void 0) { color = null; }
if (segments === void 0) { segments = 0; }
this.enableRenderer(this.shapes);
this.shapes.circle(filled, x, y, radius, color, segments);
};
/**
* @param {?} x1
* @param {?} y1
* @param {?} cx1
* @param {?} cy1
* @param {?} cx2
* @param {?} cy2
* @param {?} x2
* @param {?} y2
* @param {?} segments
* @param {?=} color
* @return {?}
*/
SceneRenderer.prototype.curve = /**
* @param {?} x1
* @param {?} y1
* @param {?} cx1
* @param {?} cy1
* @param {?} cx2
* @param {?} cy2
* @param {?} x2
* @param {?} y2
* @param {?} segments
* @param {?=} color
* @return {?}
*/
function (x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color) {
if (color === void 0) { color = null; }
this.enableRenderer(this.shapes);
this.shapes.curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color);
};
/**
* @return {?}
*/
SceneRenderer.prototype.end = /**
* @return {?}
*/
function () {
if (this.activeRenderer === this.batcher)
this.batcher.end();
else if (this.activeRenderer === this.shapes)
this.shapes.end();
this.activeRenderer = null;
};
/**
* @param {?} resizeMode
* @return {?}
*/
SceneRenderer.prototype.resize = /**
* @param {?} resizeMode
* @return {?}
*/
function (resizeMode) {
/** @type {?} */
var canvas = this.canvas;
/** @type {?} */
var w = canvas.clientWidth;
/** @type {?} */
var h = canvas.clientHeight;
if (canvas.width != w || canvas.height != h) {
canvas.width = w;
canvas.height = h;
}
this.context.gl.viewport(0, 0, canvas.width, canvas.height);
if (resizeMode === ResizeMode.Stretch) {
// nothing to do, we simply apply the viewport size of the camera
}
else if (resizeMode === ResizeMode.Expand) {
this.camera.setViewport(w, h);
}
else if (resizeMode === ResizeMode.Fit) {
/** @type {?} */
var sourceWidth = canvas.width;
/** @type {?} */
var sourceHeight = canvas.height;
/** @type {?} */
var targetWidth = this.camera.viewportWidth;
/** @type {?} */
var targetHeight = this.camera.viewportHeight;
/** @type {?} */
var targetRatio = targetHeight / targetWidth;
/** @type {?} */
var sourceRatio = sourceHeight / sourceWidth;
/** @type {?} */
var scale = targetRatio < sourceRatio
? targetWidth / sourceWidth
: targetHeight / sourceHeight;
this.camera.viewportWidth = sourceWidth * scale;
this.camera.viewportHeight = sourceHeight * scale;
}
this.camera.update();
};
/**
* @private
* @param {?} renderer
* @return {?}
*/
SceneRenderer.prototype.enableRenderer = /**
* @private
* @param {?} renderer
* @return {?}
*/
function (renderer) {
if (this.activeRenderer === renderer)
return;
this.end();
if (renderer instanceof PolygonBatcher) {
this.batcherShader.bind();
this.batcherShader.setUniform4x4f(Shader.MVP_MATRIX, this.camera.projectionView.values);
this.batcherShader.setUniformi("u_texture", 0);
this.batcher.begin(this.batcherShader);
this.activeRenderer = this.batcher;
}
else if (renderer instanceof ShapeRenderer) {
this.shapesShader.bind();
this.shapesShader.setUniform4x4f(Shader.MVP_MATRIX, this.camera.projectionView.values);
this.shapes.begin(this.shapesShader);
this.activeRenderer = this.shapes;
}
else {
this.activeRenderer = this.skeletonDebugRenderer;
}
};
/**
* @return {?}
*/
SceneRenderer.prototype.dispose = /**
* @return {?}
*/
function () {
this.batcher.dispose();
this.batcherShader.dispose();
this.shapes.dispose();
this.shapesShader.dispose();
this.skeletonDebugRenderer.dispose();
};
return SceneRenderer;
}());
if (false) {
/** @type {?} */
SceneRenderer.prototype.context;
/** @type {?} */
SceneRenderer.prototype.canvas;
/** @type {?} */
SceneRenderer.prototype.camera;
/** @type {?} */
SceneRenderer.prototype.batcher;
/**
* @type {?}
* @private
*/
SceneRenderer.prototype.twoColorTint;
/**
* @type {?}
* @private
*/
SceneRenderer.prototype.batcherShader;
/**
* @type {?}
* @private
*/
SceneRenderer.prototype.shapes;
/**
* @type {?}
* @private
*/
SceneRenderer.prototype.shapesShader;
/**
* @type {?}
* @private
*/
SceneRenderer.prototype.activeRenderer;
/** @type {?} */
SceneRenderer.prototype.skeletonRenderer;
/** @type {?} */
SceneRenderer.prototype.skeletonDebugRenderer;
/**
* @type {?}
* @private
*/
SceneRenderer.prototype.QUAD;
/**
* @type {?}
* @private
*/
SceneRenderer.prototype.QUAD_TRIANGLES;
/**
* @type {?}
* @private
*/
SceneRenderer.prototype.WHITE;
}
/** @enum {number} */
var ResizeMode = {
Stretch: 0,
Expand: 1,
Fit: 2,
};
ResizeMode[ResizeMode.Stretch] = 'Stretch';
ResizeMode[ResizeMode.Expand] = 'Expand';
ResizeMode[ResizeMode.Fit] = 'Fit';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var LoadingScreen = /** @class */ (function () {
function LoadingScreen(renderer) {
this.logo = null;
this.spinner = null;
this.angle = 0;
this.fadeOut = 0;
this.timeKeeper = new TimeKeeper();
this.backgroundColor = new Color(0.135, 0.135, 0.135, 1);
this.tempColor = new Color();
this.firstDraw = 0;
this.renderer = renderer;
this.timeKeeper.maxDelta = 9;
if (LoadingScreen.logoImg === null) {
// thank you Apple Inc.
/** @type {?} */
var isSafari = navigator.userAgent.indexOf("Safari") > -1;
LoadingScreen.logoImg = new Image();
LoadingScreen.logoImg.src = LoadingScreen.SPINE_LOGO_DATA;
if (!isSafari)
LoadingScreen.logoImg.crossOrigin = "anonymous";
LoadingScreen.logoImg.onload = (/**
* @param {?} ev
* @return {?}
*/
function (ev) {
LoadingScreen.loaded++;
});
LoadingScreen.spinnerImg = new Image();
LoadingScreen.spinnerImg.src = LoadingScreen.SPINNER_DATA;
if (!isSafari)
LoadingScreen.spinnerImg.crossOrigin = "anonymous";
LoadingScreen.spinnerImg.onload = (/**
* @param {?} ev
* @return {?}
*/
function (ev) {
LoadingScreen.loaded++;
});
}
}
/**
* @param {?=} complete
* @return {?}
*/
LoadingScreen.prototype.draw = /**
* @param {?=} complete
* @return {?}
*/
function (complete) {
if (complete === void 0) { complete = false; }
if (complete && this.fadeOut > LoadingScreen.FADE_SECONDS)
return;
this.timeKeeper.update();
/** @type {?} */
var a = Math.abs(Math.sin(this.timeKeeper.totalTime + 0.75));
this.angle -=
(this.timeKeeper.delta / 1.4) * 360 * (1 + 1.5 * Math.pow(a, 5));
/** @type {?} */
var renderer = this.renderer;
/** @type {?} */
var canvas = renderer.canvas;
/** @type {?} */
var gl = renderer.context.gl;
renderer.resize(ResizeMode.Stretch);
/** @type {?} */
var oldX = renderer.camera.position.x;
/** @type {?} */
var oldY = renderer.camera.position.y;
renderer.camera.position.set(canvas.width / 2, canvas.height / 2, 0);
renderer.camera.viewportWidth = canvas.width;
renderer.camera.viewportHeight = canvas.height;
if (!complete) {
gl.clearColor(this.backgroundColor.r, this.backgroundColor.g, this.backgroundColor.b, this.backgroundColor.a);
gl.clear(gl.COLOR_BUFFER_BIT);
this.tempColor.a = 1;
}
else {
this.fadeOut +=
this.timeKeeper.delta * (this.timeKeeper.totalTime < 1 ? 2 : 1);
if (this.fadeOut > LoadingScreen.FADE_SECONDS) {
renderer.camera.position.set(oldX, oldY, 0);
return;
}
a = 1 - this.fadeOut / LoadingScreen.FADE_SECONDS;
this.tempColor.setFromColor(this.backgroundColor);
this.tempColor.a = 1 - (a - 1) * (a - 1);
renderer.begin();
renderer.quad(true, 0, 0, canvas.width, 0, canvas.width, canvas.height, 0, canvas.height, this.tempColor, this.tempColor, this.tempColor, this.tempColor);
renderer.end();
}
this.tempColor.set(1, 1, 1, this.tempColor.a);
if (LoadingScreen.loaded != 2)
return;
if (this.logo === null) {
this.logo = new GLTexture(renderer.context, LoadingScreen.logoImg);
this.spinner = new GLTexture(renderer.context, LoadingScreen.spinnerImg);
}
this.logo.update(false);
this.spinner.update(false);
/** @type {?} */
var logoWidth = this.logo.getImage().width;
/** @type {?} */
var logoHeight = this.logo.getImage().height;
/** @type {?} */
var spinnerWidth = this.spinner.getImage().width;
/** @type {?} */
var spinnerHeight = this.spinner.getImage().height;
renderer.batcher.setBlendMode(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
renderer.begin();
renderer.drawTexture(this.logo, (canvas.width - logoWidth) / 2, (canvas.height - logoHeight) / 2, logoWidth, logoHeight, this.tempColor);
renderer.drawTextureRotated(this.spinner, (canvas.width - spinnerWidth) / 2, (canvas.height - spinnerHeight) / 2, spinnerWidth, spinnerHeight, spinnerWidth / 2, spinnerHeight / 2, this.angle, this.tempColor);
renderer.end();
renderer.camera.position.set(oldX, oldY, 0);
};
LoadingScreen.FADE_SECONDS = 1;
LoadingScreen.loaded = 0;
LoadingScreen.spinnerImg = null;
LoadingScreen.logoImg = null;
LoadingScreen.SPINNER_DATA = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKMAAACjCAYAAADmbK6AAAAACXBIWXMAAAsTAAALEwEAmpwYAAALB2lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxNDIgNzkuMTYwOTI0LCAyMDE3LzA3LzEzLTAxOjA2OjM5ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0RXZ0PSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VFdmVudCMiIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczpwaG90b3Nob3A9Imh0dHA6Ly9ucy5hZG9iZS5jb20vcGhvdG9zaG9wLzEuMC8iIHhtbG5zOnRpZmY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vdGlmZi8xLjAvIiB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ0MgMjAxNS41IChXaW5kb3dzKSIgeG1wOkNyZWF0ZURhdGU9IjIwMTYtMDktMDhUMTQ6MjU6MTIrMDI6MDAiIHhtcDpNZXRhZGF0YURhdGU9IjIwMTgtMTEtMTVUMTY6NDA6NTkrMDE6MDAiIHhtcDpNb2RpZnlEYXRlPSIyMDE4LTExLTE1VDE2OjQwOjU5KzAxOjAwIiBkYzpmb3JtYXQ9ImltYWdlL3BuZyIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpmZDhlNTljMC02NGJjLTIxNGQtODAyZi1jZDlhODJjM2ZjMGMiIHhtcE1NOkRvY3VtZW50SUQ9ImFkb2JlOmRvY2lkOnBob3Rvc2hvcDpmYmNmZWJlYS03MjY2LWE0NGQtOTI4NS0wOTJmNGNhYzk4ZWEiIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDowODMzNWIyYy04NzYyLWQzNGMtOTBhOS02ODJjYjJmYTQ2M2UiIHBob3Rvc2hvcDpDb2xvck1vZGU9IjMiIHRpZmY6T3JpZW50YXRpb249IjEiIHRpZmY6WFJlc29sdXRpb249IjcyMDAwMC8xMDAwMCIgdGlmZjpZUmVzb2x1dGlvbj0iNzIwMDAwLzEwMDAwIiB0aWZmOlJlc29sdXRpb25Vbml0PSIyIiBleGlmOkNvbG9yU3BhY2U9IjY1NTM1IiBleGlmOlBpeGVsWERpbWVuc2lvbj0iMjk3IiBleGlmOlBpeGVsWURpbWVuc2lvbj0iMjQyIj4gPHhtcE1NOkhpc3Rvcnk+IDxyZGY6U2VxPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0iY3JlYXRlZCIgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDowODMzNWIyYy04NzYyLWQzNGMtOTBhOS02ODJjYjJmYTQ2M2UiIHN0RXZ0OndoZW49IjIwMTYtMDktMDhUMTQ6MjU6MTIrMDI6MDAiIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkFkb2JlIFBob3Rvc2hvcCBDQyAyMDE1LjUgKFdpbmRvd3MpIi8+IDxyZGY6bGkgc3RFdnQ6YWN0aW9uPSJzYXZlZCIgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDpiNThlMTlkNi0xYTRjLTQyNDEtODU0ZC01MDVlZjYxMjRhODQiIHN0RXZ0OndoZW49IjIwMTgtMTEtMTVUMTY6NDA6MjMrMDE6MDAiIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkFkb2JlIFBob3Rvc2hvcCBDQyAoV2luZG93cykiIHN0RXZ0OmNoYW5nZWQ9Ii8iLz4gPHJkZjpsaSBzdEV2dDphY3Rpb249InNhdmVkIiBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOjQ3YzYzYzIwLWJkYjgtYzM0YS1hYzMyLWQ5MDdjOWEyOTA0MCIgc3RFdnQ6d2hlbj0iMjAxOC0xMS0xNVQxNjo0MDo1OSswMTowMCIgc3RFdnQ6c29mdHdhcmVBZ2VudD0iQWRvYmUgUGhvdG9zaG9wIENDIChXaW5kb3dzKSIgc3RFdnQ6Y2hhbmdlZD0iLyIvPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0iY29udmVydGVkIiBzdEV2dDpwYXJhbWV0ZXJzPSJmcm9tIGFwcGxpY2F0aW9uL3ZuZC5hZG9iZS5waG90b3Nob3AgdG8gaW1hZ2UvcG5nIi8+IDxyZGY6bGkgc3RFdnQ6YWN0aW9uPSJkZXJpdmVkIiBzdEV2dDpwYXJhbWV0ZXJzPSJjb252ZXJ0ZWQgZnJvbSBhcHBsaWNhdGlvbi92bmQuYWRvYmUucGhvdG9zaG9wIHRvIGltYWdlL3BuZyIvPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6ZmQ4ZTU5YzAtNjRiYy0yMTRkLTgwMmYtY2Q5YTgyYzNmYzBjIiBzdEV2dDp3aGVuPSIyMDE4LTExLTE1VDE2OjQwOjU5KzAxOjAwIiBzdEV2dDpzb2Z0d2FyZUFnZW50PSJBZG9iZSBQaG90b3Nob3AgQ0MgKFdpbmRvd3MpIiBzdEV2dDpjaGFuZ2VkPSIvIi8+IDwvcmRmOlNlcT4gPC94bXBNTTpIaXN0b3J5PiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo0N2M2M2MyMC1iZGI4LWMzNGEtYWMzMi1kOTA3YzlhMjkwNDAiIHN0UmVmOmRvY3VtZW50SUQ9ImFkb2JlOmRvY2lkOnBob3Rvc2hvcDo2OWRmZjljYy01YzFiLWE5NDctOTc3OS03ODgxZjM0ODk3MDMiIHN0UmVmOm9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDowODMzNWIyYy04NzYyLWQzNGMtOTBhOS02ODJjYjJmYTQ2M2UiLz4gPHBob3Rvc2hvcDpEb2N1bWVudEFuY2VzdG9ycz4gPHJkZjpCYWc+IDxyZGY6bGk+eG1wLmRpZDowODMzNWIyYy04NzYyLWQzNGMtOTBhOS02ODJjYjJmYTQ2M2U8L3JkZjpsaT4gPC9yZGY6QmFnPiA8L3Bob3Rvc2hvcDpEb2N1bWVudEFuY2VzdG9ycz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz7qS4aQAAAKZElEQVR42u2de4xVxR3HP8dd3rQryPKo4dGNbtVAQRa1YB93E1tTS7VYqCBiSWhsqGltSx+0xD60tKBorYnNkkBtFUt9xJaGNGlty6EqRAK1KlalshK2C8tzpcIigpz+MbPr5e5y987dM2fv4/tJbjC7v3P2+JvPnTMzZ85MEEURQhQClUpB7gRBAECUYiYwH6gDqoEKoA1oBDYCy4OQJgB92R3yq2S5yRilWASs6CZ0DzA5CNmn/ObOOUpB7kQpRgNLcwj9AHCnMiYZfXIT0C/H2DlRSs0gyeiPaQ6xg4FapUwy+mKUY/wwpUwy+uK4Y/xhpUwy+mKfY3yTUiYZfdHiENsahBxRyiSjL5odYncpXZLRJ3sdYhuVLslYKDKqZpSMBXObVs0oGQumA6OaUTL6Iwg5CBzNMXy7MiYZffNCDjH7g5DdSpVk9M36mGKEZOwxq4Fj3cT8UmmSjEm0Gw8At2UJaQhCtilTeeRWM5EdkmVfOwCIUtQBE4AqILC1ZQuwPgjpSKryWwgy1gfZfjsQ886IKFY2xO9N0jOR69srDOAtzCyYFuCUSrcg6AOcBIYCY4C3gVeT+uNJyvg94GPAxzFjcDuBl4C/AP+UBwXBR4AaYDYwDvgr8Drwi1KScRnwXfut6wNcYT+7Ma97LgX+JRd6jfOAucAXgCvTfl4DvAuMtJVJ0cu41IoYWRHTGWM/1TZmq/2fF8nR14r4U2BQF7+LgMW2k7bY54X4Htr5EvD99s5SlriPArcAY+VGsh1YYDpwMzAgSwy2svhWscpYA/wkx9gKm5S5wBA5kgjnAJcDX7NNpVxcWAZMLUYZJwHDHeKrgXnAdWjZlSS4BLgVuMzRlxt9eeNTxsG2veFyy7gQWAR8Sq54byfeYDssAx3LqLabJldBytgMHMjjuPHAQvTOsU++aJtE/fI4dpevTqZPGV+2veN8+DTwIHCBr29hmVJhJXwA+GAex7cBjxZjm7EFWAL8DfeX39s7NPOy9PKEO7XAV+k8xJYLrcDPgL8Xo4xgJqIuA7bkeXw9ZsBVxMMMYEqex64FfuO7e++bTcAPgD8Bpx2PvRSYKIdi61DOs3edXImAV4Cv2zJsKnYZ24B/AJ+xteRrwAmHBF4mj2JhEnCRg4QnrYh3YZ5NH/J9gUmP5zXYtsdsW+Pl8vffkEex8I5D7HHgGeBhe0dLhKRlbMJM298NXI8Z68rGk8AGeRQLu4DHMGOL2dgJPA78AXguyQvsjScdrTYp2zBDPzfbXl7mmNc64B7MFCbRc/bbfPYHrs343WnbZHsG+BXwZ8y65JS6jOnfwPuBg8BnMQtxjsWsh/0IsNJ2fkR8bAHutbfhG2x7vp9tDzZiFs5/Non2YaHJ2N6OWQf8BxiBeRx4EDPZ9nm544WNVsLtwFWYJ2Wh/fmO3ryw3noHpiv6YyZ5NsuXROhrRypeAv7nfHQJvAOTjbclYuJ3pWcL6YL03rSQjEJIRiEZhZCMQjIKIRmFZBRCMgrJKIRkFJJRCMkoJKMQklFIRiEkoxCSUUhGISSjkIxCSEYhGYWQjEIyCiEZhWQUQjIKySiEZBSSUQjJKCSjEAVCJUAQmCWPoxSjgZuAaZgF348D+zD7ADYDe+2nGWgJQg52dVJvSzOLgqHdmU5ln2IYZou9861Do+x/j8Ss2z7AOrQJWBOEZtetKIrMmt5BEBClWAQsxW3b16OY/QHXA6uD0GzpG0VRPmt6i2KSMeyQrxpYgNl4dCJmV7NcOQEsCULu6ZCR+mAmZiOannAMuC0IWS0Zy0PGKMUCzFZug3p4ullsiJ5obzPOj+H6BgGrohR1KqrSx5bzqhhE7PCvXcY4BZqgoioL4iznunQZq2M8cZXKqSyIs5yr02WsiPHEaiyWSbMxxnNVpMvYFuOJj6mcyoI4y7ktXcbGGE/conIqC+Is58Z0GTfGdNIGzJijKH3W2/KOg43pMi4n//2F92P2KJ4ShCwMQvT4pRwajCFRELIQmGLLf3+ep9pj/TvjCcwI4E5gDp1H0VsxO7k3Zvy7PQjZnXl2DXqXhYydiFKMAcYD44CajH+HZIQfBdYCtwch+854HJh2wkqgFhgGHAaagpAjLhcqGctTxqxOpKgCRgNDMXuK7whCTqU7U9khz3ucAv59xomUe9FVhePGEfs5q1eaQiYKBskoJKMQklFIRiEko5CMQkhGIRmFkIxCMgohGYVkFEIyCskohGQUklEIySiEZBSSUQjJKCSjEJJRSEYhJKOQjEJIRiEZhZCMQjIKIRmFZBSijGXMvIZ+KpZEaF8qeygwHOjb2xdUWQBJqQL6ADOBi4GHMGuGH5Iv3hiG2SJtIWaV4mZgB/AadF6jvVxkvAKzv3UdMNX+bDJm9fx10PV+1qLHIl4P3GLzfh3QBLwKbAZ+DJwuFxkDm5CZmN0Vzsv4/TTMyviVwGOYnRZEPAwBZgDfAC5K+/lo+5kKXAjcBzwPnCz1NuP77LfxO12I2M7FNmFXE+++huVOPfDNDBEz25FzgHuBa4Bzk8x/0jJeCiwCFmP2BsnGh4BbgYFyKDZmZRExnTpbGcywHZySuk0PsbeAG4HZDt+2C6yMb8mjWHgXs+NFd5v09Ac+AYzC7An0EPBKqdSM1wDfBqY7Vvubk263lDhPYHamypVa4MvAHUCq2GvGgcB8YAEwKQ/5nwa33blEVrYDLwJXOhxzLvBJzDhkK/BCMdaMA4C5wF2Y4RrXv7UF+KO9tYh42A08msfoRxVwLfBDYGwxyliLGUMclMexL9rOy075EyvvAKuBlcCbeTa3Pl+MMk7GbP/qyiHg18BWueOFNnu3ymeP8X62h11dbDKm7K3a9Zv7e+BJOeOVRmCNvQO5cgmdt4AueBkH5zCE0FWHpQH4r3zxzlPAw3kcdxg4VmwybnaMfx1YAWxTpyURjtj24wpHuZ7C0yNanzL+FnjZIX4lsEGOJEorcDewKcf4vTb+ZLHJuAeYBxzvJm4/8CPg58AJ+ZE4BzBDNk93k//jwOeAN4qxNw1m5sdV9jZwtlvv48ADujX3GpFtUt0OhPZnJzN63wdtOW7xeSFJPJvehBnBv8/2ricAp2wb8UHgETRvsRDYCiy3IrbPCWi0Mt4BPOf7AoIoivycub5TR/rDmBkjs4Df2fbHJjlQcLwfuNyW13rMXILOkyQ2REUtI5jnnG+mNRFOF3Gh1dlavgozhHUMaLEFGJWImBVnbT4VlYwlSBCYL1iUYgGw6ixhDUHIwo4GmfIrGX3JGKWotj3KbM/cpwQh2yRjYfWmS5EFdD/54ytKk2RMgukxxQjJ2GMm5hAzPEoxRqmSjN6IUgwj9xkr45UxyeiTkQ6x45QuyeiT8x1ia5QuyeiTUaoZJWMxyqiaUTIWzG1aNaNkLJgOzJAoRZVSJhl9McIxfrRSJhl94fq241ClTDL6Yq9jvCYNS0ZvuEwGPopZmlhIRi+sIfeXxtYGIaeUMsnohSCkCViSQ+gezAtOwiW/mvzpkKz3ZnrPxCz1V4dZd6YC8+JSI2YNm+VWXE2ulYyiGPk/nslB8d6ayMkAAAAASUVORK5CYII=";
LoadingScreen.SPINE_LOGO_DATA = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKUAAABsCAYAAAALzHKmAAAACXBIWXMAAAsTAAALEwEAmpwYAAALB2lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxNDIgNzkuMTYwOTI0LCAyMDE3LzA3LzEzLTAxOjA2OjM5ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0RXZ0PSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VFdmVudCMiIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczpwaG90b3Nob3A9Imh0dHA6Ly9ucy5hZG9iZS5jb20vcGhvdG9zaG9wLzEuMC8iIHhtbG5zOnRpZmY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vdGlmZi8xLjAvIiB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ0MgMjAxNS41IChXaW5kb3dzKSIgeG1wOkNyZWF0ZURhdGU9IjIwMTYtMDktMDhUMTQ6MjU6MTIrMDI6MDAiIHhtcDpNZXRhZGF0YURhdGU9IjIwMTgtMTEtMTVUMTY6NDA6NTkrMDE6MDAiIHhtcDpNb2RpZnlEYXRlPSIyMDE4LTExLTE1VDE2OjQwOjU5KzAxOjAwIiBkYzpmb3JtYXQ9ImltYWdlL3BuZyIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDowMTdhZGQ3Ni04OTZlLThlNGUtYmM5MS00ZjEyNjI1YjA3MjgiIHhtcE1NOkRvY3VtZW50SUQ9ImFkb2JlOmRvY2lkOnBob3Rvc2hvcDplMTViNGE2ZS1hMDg3LWEzNDktODdhOS1mNDYzYjE2MzQ0Y2MiIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDowODMzNWIyYy04NzYyLWQzNGMtOTBhOS02ODJjYjJmYTQ2M2UiIHBob3Rvc2hvcDpDb2xvck1vZGU9IjMiIHRpZmY6T3JpZW50YXRpb249IjEiIHRpZmY6WFJlc29sdXRpb249IjcyMDAwMC8xMDAwMCIgdGlmZjpZUmVzb2x1dGlvbj0iNzIwMDAwLzEwMDAwIiB0aWZmOlJlc29sdXRpb25Vbml0PSIyIiBleGlmOkNvbG9yU3BhY2U9IjY1NTM1IiBleGlmOlBpeGVsWERpbWVuc2lvbj0iMjk3IiBleGlmOlBpeGVsWURpbWVuc2lvbj0iMjQyIj4gPHhtcE1NOkhpc3Rvcnk+IDxyZGY6U2VxPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0iY3JlYXRlZCIgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDowODMzNWIyYy04NzYyLWQzNGMtOTBhOS02ODJjYjJmYTQ2M2UiIHN0RXZ0OndoZW49IjIwMTYtMDktMDhUMTQ6MjU6MTIrMDI6MDAiIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkFkb2JlIFBob3Rvc2hvcCBDQyAyMDE1LjUgKFdpbmRvd3MpIi8+IDxyZGY6bGkgc3RFdnQ6YWN0aW9uPSJzYXZlZCIgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDpiNThlMTlkNi0xYTRjLTQyNDEtODU0ZC01MDVlZjYxMjRhODQiIHN0RXZ0OndoZW49IjIwMTgtMTEtMTVUMTY6NDA6MjMrMDE6MDAiIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkFkb2JlIFBob3Rvc2hvcCBDQyAoV2luZG93cykiIHN0RXZ0OmNoYW5nZWQ9Ii8iLz4gPHJkZjpsaSBzdEV2dDphY3Rpb249InNhdmVkIiBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOjJlNjJiMWM2LWIxYzQtNDk0MC04MDMxLWU4ZDkyNTBmODJjNSIgc3RFdnQ6d2hlbj0iMjAxOC0xMS0xNVQxNjo0MDo1OSswMTowMCIgc3RFdnQ6c29mdHdhcmVBZ2VudD0iQWRvYmUgUGhvdG9zaG9wIENDIChXaW5kb3dzKSIgc3RFdnQ6Y2hhbmdlZD0iLyIvPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0iY29udmVydGVkIiBzdEV2dDpwYXJhbWV0ZXJzPSJmcm9tIGFwcGxpY2F0aW9uL3ZuZC5hZG9iZS5waG90b3Nob3AgdG8gaW1hZ2UvcG5nIi8+IDxyZGY6bGkgc3RFdnQ6YWN0aW9uPSJkZXJpdmVkIiBzdEV2dDpwYXJhbWV0ZXJzPSJjb252ZXJ0ZWQgZnJvbSBhcHBsaWNhdGlvbi92bmQuYWRvYmUucGhvdG9zaG9wIHRvIGltYWdlL3BuZyIvPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6MDE3YWRkNzYtODk2ZS04ZTRlLWJjOTEtNGYxMjYyNWIwNzI4IiBzdEV2dDp3aGVuPSIyMDE4LTExLTE1VDE2OjQwOjU5KzAxOjAwIiBzdEV2dDpzb2Z0d2FyZUFnZW50PSJBZG9iZSBQaG90b3Nob3AgQ0MgKFdpbmRvd3MpIiBzdEV2dDpjaGFuZ2VkPSIvIi8+IDwvcmRmOlNlcT4gPC94bXBNTTpIaXN0b3J5PiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDoyZTYyYjFjNi1iMWM0LTQ5NDAtODAzMS1lOGQ5MjUwZjgyYzUiIHN0UmVmOmRvY3VtZW50SUQ9ImFkb2JlOmRvY2lkOnBob3Rvc2hvcDo2OWRmZjljYy01YzFiLWE5NDctOTc3OS03ODgxZjM0ODk3MDMiIHN0UmVmOm9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDowODMzNWIyYy04NzYyLWQzNGMtOTBhOS02ODJjYjJmYTQ2M2UiLz4gPHBob3Rvc2hvcDpEb2N1bWVudEFuY2VzdG9ycz4gPHJkZjpCYWc+IDxyZGY6bGk+eG1wLmRpZDowODMzNWIyYy04NzYyLWQzNGMtOTBhOS02ODJjYjJmYTQ2M2U8L3JkZjpsaT4gPC9yZGY6QmFnPiA8L3Bob3Rvc2hvcDpEb2N1bWVudEFuY2VzdG9ycz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz5ayrctAAATYUlEQVR42u2dfVQV553Hv88AXq5uAAlJ0CBem912jQh60kZ8y0tdC5soJnoaXzC4Tdz4cjya1GN206Zqsu3Jpm6yeM5uTG3iaYGoJNFdEY3GaFGD0p4mqS9AXpoV0OZFUOHS3usFuc/+Idde8M7M8zr3gsw5HOCZZ2aemecz39/LPPMMMLAMLDG2kIFzjqmFDiDZP6AkN3gf0gEob8x2kj4MCx2AMnbb1BcVld6IwJJ+0oYb2YTT/gYq6WPHJP3gmtA+Biztr1CSKLevLytprCkh7ctQkj4KsK590hiGlsbSOcVCR5I+BC7pA6BEAzQaq1DqhFFH3Vg16TSG4KHRgNPpyFd1XdIHAyrdCkhjADgaTSiJw/VIP1BSp6GhUQSOOgmlkzASxSqq2zpQB+ClGiGlUb65tAUZOmDUAa5u5XRSgajibVRCR3VCSRyoQwSBE/EvYy3YkYGESuwrpuAkDgPJCg4RhFVUNUkMw6hK6agDcFInoSQxAqNqWHVdD6fUhQqUsfiaVCN41IlOUBEx88JIJCCU8T+tttOR6pEFUgRQXoCVrydRAJJw/G+2jig6llN+p0wnsZpYXsAoxzGognYzryeagBRRR8L5t4iCRsvflDHnIopINcCpGkzlUOoCkqWcKABdlznXZa5lTK7Z/6zlvMeXXqdTCVWoI696ygZN0YZSp/KxQCijmiJgUp3gyQBpVy4Kq4gPqhpWlQrCCxgPeLz70wqmyqcksgELS5kKQEWCIBn1FEn7qFBKKgmnajCloZQtlwWSZR0PoCJBkJMDMnT4iSxlsQCmFJQidVUASQS3ZSlXadqhWDVkTCoLiDKw8t40XOU6oFQBJMtvkSBJ1ITLqKaOgIbVF+y9jd3/omAqVUtViigTTfMAyKqqKnxOlWZcFEzVZjrSb11gaodSRiVVAikCo4hKyjzpkh3No8tf1AUmrxnXCmW0gSSCcIqki4hipbTqGNU+IwuMqsAUfSLVoywezi46gGSFU8Sk86bBKOd1oJzrwuuEQLIbBU8sfiPC37DYhuW8pEfex3NcQBUqyVrO+7edeZdNIfFCSi22oZwdSkzUk1jAaQcrGMA0O34kUJXAaAYl0aSMkRQMjODxAArGct6onPf68CgLbGCkNv4r4axrp4wwUUc7CAnDdkzXJ14SNFHVEQFNRjHtbg7ZoMfuOlHGDiG9/DPCCDgLjDBROFgon50ZV6mQ1/YVzwmgSniJhFryAMpybB4TLjJLRqTOZPUbZYIrwmiqZYC02lboXOIV0C3qm5nVZQGSSCiuaETOe5PygEg4AbXyM1lhJIxqqiWYUQklUaiShMGc2gFpBbDdcXl9StHXka38KVZ/i8V35DXzZibcClIWtRS90ZQpJa/ysZhtHiBV+pk8imm2TjTFwxsQWIHL42PaRd4iroW0ksZLKAFv5MoKbyQQVZl1mShc5LxYOo4Fxt4KyZPysXMhrOrwqKWyHGa8wiCHVSXtzDaxgYSA36xDEk4V5lvGpxRVIZb8pZ0Z571x7My6Up9S17SBhMGvjASfocCUi0TkvOaZMJh11vSPGVSEcT0s1JYyKKnu1BABQOMloeJ9ssMCg53phoKUkVDQs2MMcvNSsZICwfYufPZVB+o/86HxbAAXP/ah9Z2LuPSnAK5wqB1PLlIkmGEBkzVbwKuWolkE6ddXeYeb2akfEfwRTRnZRf89/r84Bf81NB73WtDQ+VUHKocfw1ob35J3QAXrYApq8X94edBmvVUZS9si/Qbr/wacWXgeN/LCCAHAQ+sNhvqhOiQOcNucZMKwQXh42XCkM95AELjZRFNjRCAPSxSmAbXlKXlNOlF0wj2WoqKi5Hnz5mdTGiQA8OCDDx4T6aiNGzeOufnmm5MBoKysrHbfvn3tVhf40hX8MSked1u1LUhx+e1mXGBIz1znC77xxtaJhmFQwzDo3LmPHBdJ6ezZs2cqIVf3UVt7unH16tWNsB4gwpItsPKdlSfTZd4EZH1MKKJkEX8WLfqnlPXr1/8oNTV1QQ8QgsG2pqamX+TkZG+OtP/y8jcn5efnb+nq6vKmpg7NfeONrZOmT5++3uVyZYTvp76+vjg3d8IWs2vy2DDcsunvUDrIQLrZBT3fgXduO4ZnrEx1aWlpbkHBrM0AkJyclFVZWZl3990TngpvT1dXl7e29vRLU6dOLTcxmT3+P3Hi5NLMzMwlhmEkh7fH7/cfraqqemHevLknTMy10yZci/mO2rR5GzZs2JaamrogGAy2Xbx4cWtTU9OLXq93r2EYyR6P52kLdQQAxMXFJR05cvSRGTNmvOZyuTJ8Pl+d1+utCa0fPXr0kydOnHzSzFRu+RLNM09j7qc+vHY5iIbe7Wu7gt8t+wwbGG9YAEBV1eHvT516z0uh9vj9/tpQW7Ozc54rL39zkt1Dh6+/Pl/h8XieNgwjORAInGpqanqxvb19TzAYbHO73VPz8vK2vfXW29kKUnuOLIZitYWFryjlq1RXV890uVxjAWD37oqFo0Z5fjR2bNYvRozIWLFx48b7zpw5s8EmqgYA5OTkrA8EAud2767452HD0ueOGJHxxLp16x7w+Xx1AODxeB5buXLlCDOf9d2L8H7rd3jFfQSzv/MBpjx7BrP/4yzmP1qP76W8j6U7m3HJzpoEg8Fr5ePHj1/n8/nqtmx5fe6wYemPpKffNreysnJxaP2999672sqi/eEPJ5YkJiZmAcDhw1WP3nrrLQVjx2Ztysi4ffmqVSunBAKBU4ZhJE+bNu1VDj81qosRZfVjyU0CABk6dGgmAHR2djYVFRWdCl+3du1Pzo0bl7PZDPxwCHw+X11R0aOPLFy4sCa0vrj4P8+9++7+jaE6P/jBY3NYgrTft8P3s0Y0rPkcn5R9jRaGtNR159zdnieeeuqpulBZYeGCmsbGxtcBwO12jzFT3Iceejh55MiRTwBAQ0PDzwsKCqrDj1NSUuL98MMPX+hW3pHvvXdwqoK+1jELs3KlVGHmbZPVgUBHGwAkJCRklpSUjBW9MB988PvXwwKaa3UWLVpUEwgEzgFAamrqnWYppZ+Owt8eHoeCfdmY/vYYTH43B9/76Nt4tP5uLHlrDCbyntd77x0oPnDggLd3nbNnz9aG/i4vf3NipG1XrFgxKeRD7tq1a2+k4+Tn570fDAbbAOD222/P5uwTJ9/41BJ9izaOKXVQXFxcWVxc/IxhGMmzZj20+5NPPn21vLx8+9q1Pzlrd/xwpWxtbfWawev3+//kcrkyUlJSJpi1618z8cs4guRIx/mmG34Aky2i0+si1bC29VgX1s4e7Q+vl5aWNiJUmJ2dnVlRUTGiWxUpAISi8M7OzqaQ66O4r7UM4HDyxTEpn+XXv/5V2/Tp/1CYn/+PryQkJGSmp6cvXbVq1dLFixdX19TUbJ49++Fjsvm1L774oqYbSMtcpOk6YrqOuwND6S7W/dx///0l6CdLfBQVkntZuHDhqfnz58/84Q9XP5iZmbkgMTExa8iQIZOnTZs2+fPP/2/7HXd8Y63uNrR04vitgzAt0rqvOnAADgyCjbScOXNmAyGEAoBhGNd+E4Jrqrl//77KGwlK6hSY27Zta922bdtWANsrKiomT5iQ+y+JiYlZaWlp83bs2LlvzpzZx0X3PXz48Nyr/utV3zLS8vgn+Onr3wK9ZRDuI93X7wpFW9Nl7J51GpsQpY+4jxuX8yqsHy9SxMAH5p1KCfGAq3R/BQUF1cuXLy8KOfKjRo3KipDQ7bGkpKQkmbXrpptuGg0AXq+33uyglRfQdtsxPJ15HJOL6pE/4xS+m3AY373jt3j59F/gtzn369oUUrXedQn5a3lYnR7n5fP5rvmdW7ZsyXKYHW1fVjMcbqjyLyjs2PF2W0dHx1nWHdx117cfz8vLS+q9r4MHD82Ji4tLAoDm5uY6WM/6gHMBdJZ+jfN7LqAVzn0cqceyb9871X/NZ9433+6GjCXwoqWUvJ1hCUFjY9O/19XVLSssLOwR+R469JsHQsnjy5cvtyHSY6swNRo8ePCdpaVl5WVlZbmhstLS0gnjx49fBVx9vPfssz/eEaFN17VrrQee34zDA59OwIrWKdjsvwf/uysL90TYhjKCyzPvOH3++efPtrS0bO+OxOedOHFyaaR9VldXz2hsbHpRQf9R8E05I8RFvNM+oY1Pavpik8vlykxJSSl85ZVNz7z00svvB4NBEhcXlxwG5OlJkyZuh/mLUSGTVzd48OA7Z84s+OX5883nuvd97Znz0aNH/u3gwYPeCBexRwDzq7/HXYvS8VrvE5mSjO8DOGzRCT0nc+oOTnp3bASzHrFD16xZs2HTpk1ZiYmJWR6P5+lLl1qXBAKBU6H1brd7Snh1sD2rjqqJNxw6sOzkobSqquoFv99/NHShhwwZMjkEZEtLy/Zly5YtMrubwzv40KFDL3/00UfPdXV1eV0uV0YIyEAgcK6iYtcTs2bN2m+iCD3KvuyAN1LDr1D8xSSwuFYW3p7m5mavHRQXLlxoM1FdunPnjtbly5cXNTQ0/DwYDLYZhpHsdrunhH6Aq4MyPv744yWM6kwZ1VFr7tDub7P/HR8lBIAUFRWlRBi2Fn6DXXec0CghAKisrFxcWLjgOABSVlY2MQRG92M+rhfHGnKxZmQiFgAgXRTeLzuwf+Vn+O//aUErg2ljnemMdZQOBUBLSkrGpqXdkhQCPz8/7wjYBveKjBLinenN1nIAoCpHnvNOEGD2zo0RATKrdbZvPJaXvzk5BOXevXsfnz9/Xg3jednlYsnEJAz5hhvuPRdwsfUKuhhUHzYdZjWvJAuwlBE8ltHoVnDa3UDCUKp8omM3QwPrdlb7sVuHSD5luLns/ttquhIzGCP6eMe9aD/uRTtnMAfoeSXCDkie9rGabuX+qFOPGSMFHdREgVjA6w0N7xt2PLNWUCur8ZwHnu8kYWTbFfiS4zHY3wX/nFr8llEZRGG0U1Fq4xebKR+PD6kN1mg80bEC1Awyq1dCbUG0UEpWv9sUrCcz8OOkePR4Xp79N7jr5J8RsIFSdo5yW//SQkV5VZIKmmKhaDxeEkKr90/AYM5Z1NIOFtuX4ktLS08TQhZRSklpaWkt+N+tNl28XfhjOJS+LtSf/DMuC4Aoo5i8QFKbDIFTSfbIT7M4Ah2WYEck+FH9Zh/AN+EVU6RtBuo3B2PQ1tGYlZYAT3sXvljXgMqdzWiTMN0qfEuegEVHlC38eq1IR7BOJgAOIKEATqt9mKWw7CJuFZPx83x+xA5Klq8+iAIJsL8kZrdOGso4zo5gnQhV9qsOVuMheYbYs3yvmmc9lagn+iUGarMPVsW0y5FSAUXXYuLjBXZMBLdhmU02UtBjFQzx+ps850EtoLfzpbnVgUN5VOQxWdVR9MtmUiki1Skhq3wiTIBkgRMCKR/CWM6bV+W581kHL7DkMXk+1sQKJK9VcWQEEq/5FjXhIsGF7Ddt7MDhufAqTBYFlHzuWORLYpRBSXnNtowvKaWULDN42W3D+hkNMOQhAfNEN8/stay5U5nv3/AGPLI5TFa/kgrUlb05uW7gOEF1UqWWdhOk8kS9Ks0uT3BDGbbn8Sl54VTla1qZZ542Sy9xnGkgcAAkOoMukQBT1L+TMfci7gGvOecxsSzmXTaYYTk/nuvODSVLmchH5cH5t+hMuyyjuFmdedFXGyij/waoiXhlHlOyHgsMbY5q9G3le/LOu83ywSHRNBXLY1GRtA9vwMPaqU59wVZFG6DoWkkppajS8XyHW8V3t4lEekP09VS7kTp2Ebmsvyli0kWyBSqsyHVlcYIAyviWsmASThhVBjY84wtZ9suaK5RJy4iaaNa8pVKVNINSRi11gSkSheu4o82UkAVmnhymKIgi0TnA/8hRNPKmqqHkVUsnwBR91Meqjiocd5ZASgQKFT4nT1DDA6TUdSOaymXAFEkniZp7FSOBdAU9LOkVqgBQp4BkLieKgLUqkzXvVuDx7EMEQl35URHoIAmODMAqFJIZyjjNKqriE8a8yXynAxsIdgRrp/KabxkYow6kjFKIqqjKZDnhvAFELYNO8w3Jjuc15yLmmjWoUQZlnIT5UgGmjGqyjLtUrXy6oGRRTl2QivqwrJaJG2KZ5DQvsKwmmccHZVVD2fSSLmXk6XxRSHgVU5U6iqqnFJSyYKqAU+QGiJVAh2oClUdhqeLjSgOpSjFkTbwOVRXNGEDB9aCSwFIFHa3DFZBRfi1Q6gBTFk4Rs63zGijrFIg/ylRt7lW3m6kOUagQqiJ5orFONKJtHR0ok/vUAaPKOrbRt2owZZVTJmhRDaKOYW26I1st06yoBFKmk4jD61UCShSfq1OdpTLgUDW6R8t87rqcfZ1BlMr6uq6Vjhf2owGvozDKmG9dyiQCeTSAiwXVdNIP1A2uls7QkYhW/fgzVgIeXVOe6ISFOnSOjjn+uuHsK5F2NM1hLG/jSGfpjoSdjLSJg7Cp7FjaR7ZzXEGcinBJDF8DnZ1Ho7wPrYNadHdINGCLdVMdrU6nMdimqHYgiaF2kn4IXJ8FMJY6iPRxsPqTksbc55ZJP2vHgOnuYwD2tU4k/eycaT891g0F5YDZ7qfQ3SidTAZgG4By4FwHgBtYBpYbZ/l/2EJnC9N0gaQAAAAASUVORK5CYII=";
return LoadingScreen;
}());
if (false) {
/** @type {?} */
LoadingScreen.FADE_SECONDS;
/**
* @type {?}
* @private
*/
LoadingScreen.loaded;
/**
* @type {?}
* @private
*/
LoadingScreen.spinnerImg;
/**
* @type {?}
* @private
*/
LoadingScreen.logoImg;
/**
* @type {?}
* @private
*/
LoadingScreen.SPINNER_DATA;
/**
* @type {?}
* @private
*/
LoadingScreen.SPINE_LOGO_DATA;
/**
* @type {?}
* @private
*/
LoadingScreen.prototype.renderer;
/**
* @type {?}
* @private
*/
LoadingScreen.prototype.logo;
/**
* @type {?}
* @private
*/
LoadingScreen.prototype.spinner;
/**
* @type {?}
* @private
*/
LoadingScreen.prototype.angle;
/**
* @type {?}
* @private
*/
LoadingScreen.prototype.fadeOut;
/**
* @type {?}
* @private
*/
LoadingScreen.prototype.timeKeeper;
/** @type {?} */
LoadingScreen.prototype.backgroundColor;
/**
* @type {?}
* @private
*/
LoadingScreen.prototype.tempColor;
/**
* @type {?}
* @private
*/
LoadingScreen.prototype.firstDraw;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var Animation = /** @class */ (function () {
function Animation(name, timelines, duration) {
if (name == null)
throw new Error("name cannot be null.");
if (timelines == null)
throw new Error("timelines cannot be null.");
this.name = name;
this.timelines = timelines;
this.timelineIds = [];
for (var i = 0; i < timelines.length; i++)
this.timelineIds[timelines[i].getPropertyId()] = true;
this.duration = duration;
}
/**
* @param {?} id
* @return {?}
*/
Animation.prototype.hasTimeline = /**
* @param {?} id
* @return {?}
*/
function (id) {
return this.timelineIds[id] == true;
};
/**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} loop
* @param {?} events
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
Animation.prototype.apply = /**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} loop
* @param {?} events
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
function (skeleton, lastTime, time, loop, events, alpha, blend, direction) {
if (skeleton == null)
throw new Error("skeleton cannot be null.");
if (loop && this.duration != 0) {
time %= this.duration;
if (lastTime > 0)
lastTime %= this.duration;
}
/** @type {?} */
var timelines = this.timelines;
for (var i = 0, n = timelines.length; i < n; i++)
timelines[i].apply(skeleton, lastTime, time, events, alpha, blend, direction);
};
/**
* @param {?} values
* @param {?} target
* @param {?=} step
* @return {?}
*/
Animation.binarySearch = /**
* @param {?} values
* @param {?} target
* @param {?=} step
* @return {?}
*/
function (values, target, step) {
if (step === void 0) { step = 1; }
/** @type {?} */
var low = 0;
/** @type {?} */
var high = values.length / step - 2;
if (high == 0)
return step;
/** @type {?} */
var current = high >>> 1;
while (true) {
if (values[(current + 1) * step] <= target)
low = current + 1;
else
high = current;
if (low == high)
return (low + 1) * step;
current = (low + high) >>> 1;
}
};
/**
* @param {?} values
* @param {?} target
* @param {?} step
* @return {?}
*/
Animation.linearSearch = /**
* @param {?} values
* @param {?} target
* @param {?} step
* @return {?}
*/
function (values, target, step) {
for (var i = 0, last = values.length - step; i <= last; i += step)
if (values[i] > target)
return i;
return -1;
};
return Animation;
}());
if (false) {
/** @type {?} */
Animation.prototype.name;
/** @type {?} */
Animation.prototype.timelines;
/** @type {?} */
Animation.prototype.timelineIds;
/** @type {?} */
Animation.prototype.duration;
}
/**
* @record
*/
function Timeline() { }
if (false) {
/**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} events
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
Timeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) { };
/**
* @return {?}
*/
Timeline.prototype.getPropertyId = function () { };
}
/** @enum {number} */
var MixBlend = {
setup: 0,
first: 1,
replace: 2,
add: 3,
};
MixBlend[MixBlend.setup] = 'setup';
MixBlend[MixBlend.first] = 'first';
MixBlend[MixBlend.replace] = 'replace';
MixBlend[MixBlend.add] = 'add';
/** @enum {number} */
var MixDirection = {
mixIn: 0,
mixOut: 1,
};
MixDirection[MixDirection.mixIn] = 'mixIn';
MixDirection[MixDirection.mixOut] = 'mixOut';
/** @enum {number} */
var TimelineType = {
rotate: 0,
translate: 1,
scale: 2,
shear: 3,
attachment: 4,
color: 5,
deform: 6,
event: 7,
drawOrder: 8,
ikConstraint: 9,
transformConstraint: 10,
pathConstraintPosition: 11,
pathConstraintSpacing: 12,
pathConstraintMix: 13,
twoColor: 14,
};
TimelineType[TimelineType.rotate] = 'rotate';
TimelineType[TimelineType.translate] = 'translate';
TimelineType[TimelineType.scale] = 'scale';
TimelineType[TimelineType.shear] = 'shear';
TimelineType[TimelineType.attachment] = 'attachment';
TimelineType[TimelineType.color] = 'color';
TimelineType[TimelineType.deform] = 'deform';
TimelineType[TimelineType.event] = 'event';
TimelineType[TimelineType.drawOrder] = 'drawOrder';
TimelineType[TimelineType.ikConstraint] = 'ikConstraint';
TimelineType[TimelineType.transformConstraint] = 'transformConstraint';
TimelineType[TimelineType.pathConstraintPosition] = 'pathConstraintPosition';
TimelineType[TimelineType.pathConstraintSpacing] = 'pathConstraintSpacing';
TimelineType[TimelineType.pathConstraintMix] = 'pathConstraintMix';
TimelineType[TimelineType.twoColor] = 'twoColor';
/**
* @abstract
*/
var CurveTimeline = /** @class */ (function () {
function CurveTimeline(frameCount) {
if (frameCount <= 0)
throw new Error("frameCount must be > 0: " + frameCount);
this.curves = Utils.newFloatArray((frameCount - 1) * CurveTimeline.BEZIER_SIZE);
}
/**
* @return {?}
*/
CurveTimeline.prototype.getFrameCount = /**
* @return {?}
*/
function () {
return this.curves.length / CurveTimeline.BEZIER_SIZE + 1;
};
/**
* @param {?} frameIndex
* @return {?}
*/
CurveTimeline.prototype.setLinear = /**
* @param {?} frameIndex
* @return {?}
*/
function (frameIndex) {
this.curves[frameIndex * CurveTimeline.BEZIER_SIZE] = CurveTimeline.LINEAR;
};
/**
* @param {?} frameIndex
* @return {?}
*/
CurveTimeline.prototype.setStepped = /**
* @param {?} frameIndex
* @return {?}
*/
function (frameIndex) {
this.curves[frameIndex * CurveTimeline.BEZIER_SIZE] = CurveTimeline.STEPPED;
};
/**
* @param {?} frameIndex
* @return {?}
*/
CurveTimeline.prototype.getCurveType = /**
* @param {?} frameIndex
* @return {?}
*/
function (frameIndex) {
/** @type {?} */
var index = frameIndex * CurveTimeline.BEZIER_SIZE;
if (index == this.curves.length)
return CurveTimeline.LINEAR;
/** @type {?} */
var type = this.curves[index];
if (type == CurveTimeline.LINEAR)
return CurveTimeline.LINEAR;
if (type == CurveTimeline.STEPPED)
return CurveTimeline.STEPPED;
return CurveTimeline.BEZIER;
};
/** Sets the control handle positions for an interpolation bezier curve used to transition from this keyframe to the next.
* cx1 and cx2 are from 0 to 1, representing the percent of time between the two keyframes. cy1 and cy2 are the percent of
* the difference between the keyframe's values. */
/**
* Sets the control handle positions for an interpolation bezier curve used to transition from this keyframe to the next.
* cx1 and cx2 are from 0 to 1, representing the percent of time between the two keyframes. cy1 and cy2 are the percent of
* the difference between the keyframe's values.
* @param {?} frameIndex
* @param {?} cx1
* @param {?} cy1
* @param {?} cx2
* @param {?} cy2
* @return {?}
*/
CurveTimeline.prototype.setCurve = /**
* Sets the control handle positions for an interpolation bezier curve used to transition from this keyframe to the next.
* cx1 and cx2 are from 0 to 1, representing the percent of time between the two keyframes. cy1 and cy2 are the percent of
* the difference between the keyframe's values.
* @param {?} frameIndex
* @param {?} cx1
* @param {?} cy1
* @param {?} cx2
* @param {?} cy2
* @return {?}
*/
function (frameIndex, cx1, cy1, cx2, cy2) {
/** @type {?} */
var tmpx = (-cx1 * 2 + cx2) * 0.03;
/** @type {?} */
var tmpy = (-cy1 * 2 + cy2) * 0.03;
/** @type {?} */
var dddfx = ((cx1 - cx2) * 3 + 1) * 0.006;
/** @type {?} */
var dddfy = ((cy1 - cy2) * 3 + 1) * 0.006;
/** @type {?} */
var ddfx = tmpx * 2 + dddfx;
/** @type {?} */
var ddfy = tmpy * 2 + dddfy;
/** @type {?} */
var dfx = cx1 * 0.3 + tmpx + dddfx * 0.16666667;
/** @type {?} */
var dfy = cy1 * 0.3 + tmpy + dddfy * 0.16666667;
/** @type {?} */
var i = frameIndex * CurveTimeline.BEZIER_SIZE;
/** @type {?} */
var curves = this.curves;
curves[i++] = CurveTimeline.BEZIER;
/** @type {?} */
var x = dfx;
/** @type {?} */
var y = dfy;
for (var n = i + CurveTimeline.BEZIER_SIZE - 1; i < n; i += 2) {
curves[i] = x;
curves[i + 1] = y;
dfx += ddfx;
dfy += ddfy;
ddfx += dddfx;
ddfy += dddfy;
x += dfx;
y += dfy;
}
};
/**
* @param {?} frameIndex
* @param {?} percent
* @return {?}
*/
CurveTimeline.prototype.getCurvePercent = /**
* @param {?} frameIndex
* @param {?} percent
* @return {?}
*/
function (frameIndex, percent) {
percent = MathUtils.clamp(percent, 0, 1);
/** @type {?} */
var curves = this.curves;
/** @type {?} */
var i = frameIndex * CurveTimeline.BEZIER_SIZE;
/** @type {?} */
var type = curves[i];
if (type == CurveTimeline.LINEAR)
return percent;
if (type == CurveTimeline.STEPPED)
return 0;
i++;
/** @type {?} */
var x = 0;
for (var start = i, n = i + CurveTimeline.BEZIER_SIZE - 1; i < n; i += 2) {
x = curves[i];
if (x >= percent) {
/** @type {?} */
var prevX = void 0;
/** @type {?} */
var prevY = void 0;
if (i == start) {
prevX = 0;
prevY = 0;
}
else {
prevX = curves[i - 2];
prevY = curves[i - 1];
}
return (prevY + ((curves[i + 1] - prevY) * (percent - prevX)) / (x - prevX));
}
}
/** @type {?} */
var y = curves[i - 1];
return y + ((1 - y) * (percent - x)) / (1 - x); // Last point is 1,1.
};
CurveTimeline.LINEAR = 0;
CurveTimeline.STEPPED = 1;
CurveTimeline.BEZIER = 2;
CurveTimeline.BEZIER_SIZE = 10 * 2 - 1;
return CurveTimeline;
}());
if (false) {
/** @type {?} */
CurveTimeline.LINEAR;
/** @type {?} */
CurveTimeline.STEPPED;
/** @type {?} */
CurveTimeline.BEZIER;
/** @type {?} */
CurveTimeline.BEZIER_SIZE;
/**
* @type {?}
* @private
*/
CurveTimeline.prototype.curves;
/**
* @abstract
* @return {?}
*/
CurveTimeline.prototype.getPropertyId = function () { };
/**
* @abstract
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} events
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
CurveTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) { };
}
var RotateTimeline = /** @class */ (function (_super) {
__extends(RotateTimeline, _super);
function RotateTimeline(frameCount) {
var _this = _super.call(this, frameCount) || this;
_this.frames = Utils.newFloatArray(frameCount << 1);
return _this;
}
/**
* @return {?}
*/
RotateTimeline.prototype.getPropertyId = /**
* @return {?}
*/
function () {
return (TimelineType.rotate << 24) + this.boneIndex;
};
/** Sets the time and angle of the specified keyframe. */
/**
* Sets the time and angle of the specified keyframe.
* @param {?} frameIndex
* @param {?} time
* @param {?} degrees
* @return {?}
*/
RotateTimeline.prototype.setFrame = /**
* Sets the time and angle of the specified keyframe.
* @param {?} frameIndex
* @param {?} time
* @param {?} degrees
* @return {?}
*/
function (frameIndex, time, degrees) {
frameIndex <<= 1;
this.frames[frameIndex] = time;
this.frames[frameIndex + RotateTimeline.ROTATION] = degrees;
};
/**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} events
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
RotateTimeline.prototype.apply = /**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} events
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
function (skeleton, lastTime, time, events, alpha, blend, direction) {
/** @type {?} */
var frames = this.frames;
/** @type {?} */
var bone = skeleton.bones[this.boneIndex];
if (!bone.active)
return;
if (time < frames[0]) {
switch (blend) {
case MixBlend.setup:
bone.rotation = bone.data.rotation;
return;
case MixBlend.first:
/** @type {?} */
var r_1 = bone.data.rotation - bone.rotation;
bone.rotation +=
(r_1 - (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360) * alpha;
}
return;
}
if (time >= frames[frames.length - RotateTimeline.ENTRIES]) {
// Time is after last frame.
/** @type {?} */
var r_2 = frames[frames.length + RotateTimeline.PREV_ROTATION];
switch (blend) {
case MixBlend.setup:
bone.rotation = bone.data.rotation + r_2 * alpha;
break;
case MixBlend.first:
case MixBlend.replace:
r_2 += bone.data.rotation - bone.rotation;
r_2 -= (16384 - ((16384.499999999996 - r_2 / 360) | 0)) * 360; // Wrap within -180 and 180.
case MixBlend.add:
bone.rotation += r_2 * alpha;
}
return;
}
// Interpolate between the previous frame and the current frame.
/** @type {?} */
var frame = Animation.binarySearch(frames, time, RotateTimeline.ENTRIES);
/** @type {?} */
var prevRotation = frames[frame + RotateTimeline.PREV_ROTATION];
/** @type {?} */
var frameTime = frames[frame];
/** @type {?} */
var percent = this.getCurvePercent((frame >> 1) - 1, 1 -
(time - frameTime) /
(frames[frame + RotateTimeline.PREV_TIME] - frameTime));
/** @type {?} */
var r = frames[frame + RotateTimeline.ROTATION] - prevRotation;
r =
prevRotation +
(r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * percent;
switch (blend) {
case MixBlend.setup:
bone.rotation =
bone.data.rotation +
(r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * alpha;
break;
case MixBlend.first:
case MixBlend.replace:
r += bone.data.rotation - bone.rotation;
case MixBlend.add:
bone.rotation +=
(r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * alpha;
}
};
RotateTimeline.ENTRIES = 2;
RotateTimeline.PREV_TIME = -2;
RotateTimeline.PREV_ROTATION = -1;
RotateTimeline.ROTATION = 1;
return RotateTimeline;
}(CurveTimeline));
if (false) {
/** @type {?} */
RotateTimeline.ENTRIES;
/** @type {?} */
RotateTimeline.PREV_TIME;
/** @type {?} */
RotateTimeline.PREV_ROTATION;
/** @type {?} */
RotateTimeline.ROTATION;
/** @type {?} */
RotateTimeline.prototype.boneIndex;
/** @type {?} */
RotateTimeline.prototype.frames;
}
var TranslateTimeline = /** @class */ (function (_super) {
__extends(TranslateTimeline, _super);
function TranslateTimeline(frameCount) {
var _this = _super.call(this, frameCount) || this;
_this.frames = Utils.newFloatArray(frameCount * TranslateTimeline.ENTRIES);
return _this;
}
/**
* @return {?}
*/
TranslateTimeline.prototype.getPropertyId = /**
* @return {?}
*/
function () {
return (TimelineType.translate << 24) + this.boneIndex;
};
/** Sets the time and value of the specified keyframe. */
/**
* Sets the time and value of the specified keyframe.
* @param {?} frameIndex
* @param {?} time
* @param {?} x
* @param {?} y
* @return {?}
*/
TranslateTimeline.prototype.setFrame = /**
* Sets the time and value of the specified keyframe.
* @param {?} frameIndex
* @param {?} time
* @param {?} x
* @param {?} y
* @return {?}
*/
function (frameIndex, time, x, y) {
frameIndex *= TranslateTimeline.ENTRIES;
this.frames[frameIndex] = time;
this.frames[frameIndex + TranslateTimeline.X] = x;
this.frames[frameIndex + TranslateTimeline.Y] = y;
};
/**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} events
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
TranslateTimeline.prototype.apply = /**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} events
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
function (skeleton, lastTime, time, events, alpha, blend, direction) {
/** @type {?} */
var frames = this.frames;
/** @type {?} */
var bone = skeleton.bones[this.boneIndex];
if (!bone.active)
return;
if (time < frames[0]) {
switch (blend) {
case MixBlend.setup:
bone.x = bone.data.x;
bone.y = bone.data.y;
return;
case MixBlend.first:
bone.x += (bone.data.x - bone.x) * alpha;
bone.y += (bone.data.y - bone.y) * alpha;
}
return;
}
/** @type {?} */
var x = 0;
/** @type {?} */
var y = 0;
if (time >= frames[frames.length - TranslateTimeline.ENTRIES]) {
// Time is after last frame.
x = frames[frames.length + TranslateTimeline.PREV_X];
y = frames[frames.length + TranslateTimeline.PREV_Y];
}
else {
// Interpolate between the previous frame and the current frame.
/** @type {?} */
var frame = Animation.binarySearch(frames, time, TranslateTimeline.ENTRIES);
x = frames[frame + TranslateTimeline.PREV_X];
y = frames[frame + TranslateTimeline.PREV_Y];
/** @type {?} */
var frameTime = frames[frame];
/** @type {?} */
var percent = this.getCurvePercent(frame / TranslateTimeline.ENTRIES - 1, 1 -
(time - frameTime) /
(frames[frame + TranslateTimeline.PREV_TIME] - frameTime));
x += (frames[frame + TranslateTimeline.X] - x) * percent;
y += (frames[frame + TranslateTimeline.Y] - y) * percent;
}
switch (blend) {
case MixBlend.setup:
bone.x = bone.data.x + x * alpha;
bone.y = bone.data.y + y * alpha;
break;
case MixBlend.first:
case MixBlend.replace:
bone.x += (bone.data.x + x - bone.x) * alpha;
bone.y += (bone.data.y + y - bone.y) * alpha;
break;
case MixBlend.add:
bone.x += x * alpha;
bone.y += y * alpha;
}
};
TranslateTimeline.ENTRIES = 3;
TranslateTimeline.PREV_TIME = -3;
TranslateTimeline.PREV_X = -2;
TranslateTimeline.PREV_Y = -1;
TranslateTimeline.X = 1;
TranslateTimeline.Y = 2;
return TranslateTimeline;
}(CurveTimeline));
if (false) {
/** @type {?} */
TranslateTimeline.ENTRIES;
/** @type {?} */
TranslateTimeline.PREV_TIME;
/** @type {?} */
TranslateTimeline.PREV_X;
/** @type {?} */
TranslateTimeline.PREV_Y;
/** @type {?} */
TranslateTimeline.X;
/** @type {?} */
TranslateTimeline.Y;
/** @type {?} */
TranslateTimeline.prototype.boneIndex;
/** @type {?} */
TranslateTimeline.prototype.frames;
}
var ScaleTimeline = /** @class */ (function (_super) {
__extends(ScaleTimeline, _super);
function ScaleTimeline(frameCount) {
return _super.call(this, frameCount) || this;
}
/**
* @return {?}
*/
ScaleTimeline.prototype.getPropertyId = /**
* @return {?}
*/
function () {
return (TimelineType.scale << 24) + this.boneIndex;
};
/**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} events
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
ScaleTimeline.prototype.apply = /**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} events
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
function (skeleton, lastTime, time, events, alpha, blend, direction) {
/** @type {?} */
var frames = this.frames;
/** @type {?} */
var bone = skeleton.bones[this.boneIndex];
if (!bone.active)
return;
if (time < frames[0]) {
switch (blend) {
case MixBlend.setup:
bone.scaleX = bone.data.scaleX;
bone.scaleY = bone.data.scaleY;
return;
case MixBlend.first:
bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha;
bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha;
}
return;
}
/** @type {?} */
var x = 0;
/** @type {?} */
var y = 0;
if (time >= frames[frames.length - ScaleTimeline.ENTRIES]) {
// Time is after last frame.
x = frames[frames.length + ScaleTimeline.PREV_X] * bone.data.scaleX;
y = frames[frames.length + ScaleTimeline.PREV_Y] * bone.data.scaleY;
}
else {
// Interpolate between the previous frame and the current frame.
/** @type {?} */
var frame = Animation.binarySearch(frames, time, ScaleTimeline.ENTRIES);
x = frames[frame + ScaleTimeline.PREV_X];
y = frames[frame + ScaleTimeline.PREV_Y];
/** @type {?} */
var frameTime = frames[frame];
/** @type {?} */
var percent = this.getCurvePercent(frame / ScaleTimeline.ENTRIES - 1, 1 -
(time - frameTime) /
(frames[frame + ScaleTimeline.PREV_TIME] - frameTime));
x =
(x + (frames[frame + ScaleTimeline.X] - x) * percent) *
bone.data.scaleX;
y =
(y + (frames[frame + ScaleTimeline.Y] - y) * percent) *
bone.data.scaleY;
}
if (alpha == 1) {
if (blend == MixBlend.add) {
bone.scaleX += x - bone.data.scaleX;
bone.scaleY += y - bone.data.scaleY;
}
else {
bone.scaleX = x;
bone.scaleY = y;
}
}
else {
/** @type {?} */
var bx = 0;
/** @type {?} */
var by = 0;
if (direction == MixDirection.mixOut) {
switch (blend) {
case MixBlend.setup:
bx = bone.data.scaleX;
by = bone.data.scaleY;
bone.scaleX =
bx + (Math.abs(x) * MathUtils.signum(bx) - bx) * alpha;
bone.scaleY =
by + (Math.abs(y) * MathUtils.signum(by) - by) * alpha;
break;
case MixBlend.first:
case MixBlend.replace:
bx = bone.scaleX;
by = bone.scaleY;
bone.scaleX =
bx + (Math.abs(x) * MathUtils.signum(bx) - bx) * alpha;
bone.scaleY =
by + (Math.abs(y) * MathUtils.signum(by) - by) * alpha;
break;
case MixBlend.add:
bx = bone.scaleX;
by = bone.scaleY;
bone.scaleX =
bx +
(Math.abs(x) * MathUtils.signum(bx) - bone.data.scaleX) * alpha;
bone.scaleY =
by +
(Math.abs(y) * MathUtils.signum(by) - bone.data.scaleY) * alpha;
}
}
else {
switch (blend) {
case MixBlend.setup:
bx = Math.abs(bone.data.scaleX) * MathUtils.signum(x);
by = Math.abs(bone.data.scaleY) * MathUtils.signum(y);
bone.scaleX = bx + (x - bx) * alpha;
bone.scaleY = by + (y - by) * alpha;
break;
case MixBlend.first:
case MixBlend.replace:
bx = Math.abs(bone.scaleX) * MathUtils.signum(x);
by = Math.abs(bone.scaleY) * MathUtils.signum(y);
bone.scaleX = bx + (x - bx) * alpha;
bone.scaleY = by + (y - by) * alpha;
break;
case MixBlend.add:
bx = MathUtils.signum(x);
by = MathUtils.signum(y);
bone.scaleX =
Math.abs(bone.scaleX) * bx +
(x - Math.abs(bone.data.scaleX) * bx) * alpha;
bone.scaleY =
Math.abs(bone.scaleY) * by +
(y - Math.abs(bone.data.scaleY) * by) * alpha;
}
}
}
};
return ScaleTimeline;
}(TranslateTimeline));
var ShearTimeline = /** @class */ (function (_super) {
__extends(ShearTimeline, _super);
function ShearTimeline(frameCount) {
return _super.call(this, frameCount) || this;
}
/**
* @return {?}
*/
ShearTimeline.prototype.getPropertyId = /**
* @return {?}
*/
function () {
return (TimelineType.shear << 24) + this.boneIndex;
};
/**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} events
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
ShearTimeline.prototype.apply = /**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} events
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
function (skeleton, lastTime, time, events, alpha, blend, direction) {
/** @type {?} */
var frames = this.frames;
/** @type {?} */
var bone = skeleton.bones[this.boneIndex];
if (!bone.active)
return;
if (time < frames[0]) {
switch (blend) {
case MixBlend.setup:
bone.shearX = bone.data.shearX;
bone.shearY = bone.data.shearY;
return;
case MixBlend.first:
bone.shearX += (bone.data.shearX - bone.shearX) * alpha;
bone.shearY += (bone.data.shearY - bone.shearY) * alpha;
}
return;
}
/** @type {?} */
var x = 0;
/** @type {?} */
var y = 0;
if (time >= frames[frames.length - ShearTimeline.ENTRIES]) {
// Time is after last frame.
x = frames[frames.length + ShearTimeline.PREV_X];
y = frames[frames.length + ShearTimeline.PREV_Y];
}
else {
// Interpolate between the previous frame and the current frame.
/** @type {?} */
var frame = Animation.binarySearch(frames, time, ShearTimeline.ENTRIES);
x = frames[frame + ShearTimeline.PREV_X];
y = frames[frame + ShearTimeline.PREV_Y];
/** @type {?} */
var frameTime = frames[frame];
/** @type {?} */
var percent = this.getCurvePercent(frame / ShearTimeline.ENTRIES - 1, 1 -
(time - frameTime) /
(frames[frame + ShearTimeline.PREV_TIME] - frameTime));
x = x + (frames[frame + ShearTimeline.X] - x) * percent;
y = y + (frames[frame + ShearTimeline.Y] - y) * percent;
}
switch (blend) {
case MixBlend.setup:
bone.shearX = bone.data.shearX + x * alpha;
bone.shearY = bone.data.shearY + y * alpha;
break;
case MixBlend.first:
case MixBlend.replace:
bone.shearX += (bone.data.shearX + x - bone.shearX) * alpha;
bone.shearY += (bone.data.shearY + y - bone.shearY) * alpha;
break;
case MixBlend.add:
bone.shearX += x * alpha;
bone.shearY += y * alpha;
}
};
return ShearTimeline;
}(TranslateTimeline));
var ColorTimeline = /** @class */ (function (_super) {
__extends(ColorTimeline, _super);
function ColorTimeline(frameCount) {
var _this = _super.call(this, frameCount) || this;
_this.frames = Utils.newFloatArray(frameCount * ColorTimeline.ENTRIES);
return _this;
}
/**
* @return {?}
*/
ColorTimeline.prototype.getPropertyId = /**
* @return {?}
*/
function () {
return (TimelineType.color << 24) + this.slotIndex;
};
/** Sets the time and value of the specified keyframe. */
/**
* Sets the time and value of the specified keyframe.
* @param {?} frameIndex
* @param {?} time
* @param {?} r
* @param {?} g
* @param {?} b
* @param {?} a
* @return {?}
*/
ColorTimeline.prototype.setFrame = /**
* Sets the time and value of the specified keyframe.
* @param {?} frameIndex
* @param {?} time
* @param {?} r
* @param {?} g
* @param {?} b
* @param {?} a
* @return {?}
*/
function (frameIndex, time, r, g, b, a) {
frameIndex *= ColorTimeline.ENTRIES;
this.frames[frameIndex] = time;
this.frames[frameIndex + ColorTimeline.R] = r;
this.frames[frameIndex + ColorTimeline.G] = g;
this.frames[frameIndex + ColorTimeline.B] = b;
this.frames[frameIndex + ColorTimeline.A] = a;
};
/**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} events
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
ColorTimeline.prototype.apply = /**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} events
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
function (skeleton, lastTime, time, events, alpha, blend, direction) {
/** @type {?} */
var slot = skeleton.slots[this.slotIndex];
if (!slot.bone.active)
return;
/** @type {?} */
var frames = this.frames;
if (time < frames[0]) {
switch (blend) {
case MixBlend.setup:
slot.color.setFromColor(slot.data.color);
return;
case MixBlend.first:
/** @type {?} */
var color = slot.color;
/** @type {?} */
var setup = slot.data.color;
color.add((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha, (setup.a - color.a) * alpha);
}
return;
}
/** @type {?} */
var r = 0;
/** @type {?} */
var g = 0;
/** @type {?} */
var b = 0;
/** @type {?} */
var a = 0;
if (time >= frames[frames.length - ColorTimeline.ENTRIES]) {
// Time is after last frame.
/** @type {?} */
var i = frames.length;
r = frames[i + ColorTimeline.PREV_R];
g = frames[i + ColorTimeline.PREV_G];
b = frames[i + ColorTimeline.PREV_B];
a = frames[i + ColorTimeline.PREV_A];
}
else {
// Interpolate between the previous frame and the current frame.
/** @type {?} */
var frame = Animation.binarySearch(frames, time, ColorTimeline.ENTRIES);
r = frames[frame + ColorTimeline.PREV_R];
g = frames[frame + ColorTimeline.PREV_G];
b = frames[frame + ColorTimeline.PREV_B];
a = frames[frame + ColorTimeline.PREV_A];
/** @type {?} */
var frameTime = frames[frame];
/** @type {?} */
var percent = this.getCurvePercent(frame / ColorTimeline.ENTRIES - 1, 1 -
(time - frameTime) /
(frames[frame + ColorTimeline.PREV_TIME] - frameTime));
r += (frames[frame + ColorTimeline.R] - r) * percent;
g += (frames[frame + ColorTimeline.G] - g) * percent;
b += (frames[frame + ColorTimeline.B] - b) * percent;
a += (frames[frame + ColorTimeline.A] - a) * percent;
}
if (alpha == 1)
slot.color.set(r, g, b, a);
else {
/** @type {?} */
var color = slot.color;
if (blend == MixBlend.setup)
color.setFromColor(slot.data.color);
color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha);
}
};
ColorTimeline.ENTRIES = 5;
ColorTimeline.PREV_TIME = -5;
ColorTimeline.PREV_R = -4;
ColorTimeline.PREV_G = -3;
ColorTimeline.PREV_B = -2;
ColorTimeline.PREV_A = -1;
ColorTimeline.R = 1;
ColorTimeline.G = 2;
ColorTimeline.B = 3;
ColorTimeline.A = 4;
return ColorTimeline;
}(CurveTimeline));
if (false) {
/** @type {?} */
ColorTimeline.ENTRIES;
/** @type {?} */
ColorTimeline.PREV_TIME;
/** @type {?} */
ColorTimeline.PREV_R;
/** @type {?} */
ColorTimeline.PREV_G;
/** @type {?} */
ColorTimeline.PREV_B;
/** @type {?} */
ColorTimeline.PREV_A;
/** @type {?} */
ColorTimeline.R;
/** @type {?} */
ColorTimeline.G;
/** @type {?} */
ColorTimeline.B;
/** @type {?} */
ColorTimeline.A;
/** @type {?} */
ColorTimeline.prototype.slotIndex;
/** @type {?} */
ColorTimeline.prototype.frames;
}
var TwoColorTimeline = /** @class */ (function (_super) {
__extends(TwoColorTimeline, _super);
function TwoColorTimeline(frameCount) {
var _this = _super.call(this, frameCount) || this;
_this.frames = Utils.newFloatArray(frameCount * TwoColorTimeline.ENTRIES);
return _this;
}
/**
* @return {?}
*/
TwoColorTimeline.prototype.getPropertyId = /**
* @return {?}
*/
function () {
return (TimelineType.twoColor << 24) + this.slotIndex;
};
/** Sets the time and value of the specified keyframe. */
/**
* Sets the time and value of the specified keyframe.
* @param {?} frameIndex
* @param {?} time
* @param {?} r
* @param {?} g
* @param {?} b
* @param {?} a
* @param {?} r2
* @param {?} g2
* @param {?} b2
* @return {?}
*/
TwoColorTimeline.prototype.setFrame = /**
* Sets the time and value of the specified keyframe.
* @param {?} frameIndex
* @param {?} time
* @param {?} r
* @param {?} g
* @param {?} b
* @param {?} a
* @param {?} r2
* @param {?} g2
* @param {?} b2
* @return {?}
*/
function (frameIndex, time, r, g, b, a, r2, g2, b2) {
frameIndex *= TwoColorTimeline.ENTRIES;
this.frames[frameIndex] = time;
this.frames[frameIndex + TwoColorTimeline.R] = r;
this.frames[frameIndex + TwoColorTimeline.G] = g;
this.frames[frameIndex + TwoColorTimeline.B] = b;
this.frames[frameIndex + TwoColorTimeline.A] = a;
this.frames[frameIndex + TwoColorTimeline.R2] = r2;
this.frames[frameIndex + TwoColorTimeline.G2] = g2;
this.frames[frameIndex + TwoColorTimeline.B2] = b2;
};
/**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} events
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
TwoColorTimeline.prototype.apply = /**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} events
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
function (skeleton, lastTime, time, events, alpha, blend, direction) {
/** @type {?} */
var slot = skeleton.slots[this.slotIndex];
if (!slot.bone.active)
return;
/** @type {?} */
var frames = this.frames;
if (time < frames[0]) {
switch (blend) {
case MixBlend.setup:
slot.color.setFromColor(slot.data.color);
slot.darkColor.setFromColor(slot.data.darkColor);
return;
case MixBlend.first:
/** @type {?} */
var light = slot.color;
/** @type {?} */
var dark = slot.darkColor;
/** @type {?} */
var setupLight = slot.data.color;
/** @type {?} */
var setupDark = slot.data.darkColor;
light.add((setupLight.r - light.r) * alpha, (setupLight.g - light.g) * alpha, (setupLight.b - light.b) * alpha, (setupLight.a - light.a) * alpha);
dark.add((setupDark.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, (setupDark.b - dark.b) * alpha, 0);
}
return;
}
/** @type {?} */
var r = 0;
/** @type {?} */
var g = 0;
/** @type {?} */
var b = 0;
/** @type {?} */
var a = 0;
/** @type {?} */
var r2 = 0;
/** @type {?} */
var g2 = 0;
/** @type {?} */
var b2 = 0;
if (time >= frames[frames.length - TwoColorTimeline.ENTRIES]) {
// Time is after last frame.
/** @type {?} */
var i = frames.length;
r = frames[i + TwoColorTimeline.PREV_R];
g = frames[i + TwoColorTimeline.PREV_G];
b = frames[i + TwoColorTimeline.PREV_B];
a = frames[i + TwoColorTimeline.PREV_A];
r2 = frames[i + TwoColorTimeline.PREV_R2];
g2 = frames[i + TwoColorTimeline.PREV_G2];
b2 = frames[i + TwoColorTimeline.PREV_B2];
}
else {
// Interpolate between the previous frame and the current frame.
/** @type {?} */
var frame = Animation.binarySearch(frames, time, TwoColorTimeline.ENTRIES);
r = frames[frame + TwoColorTimeline.PREV_R];
g = frames[frame + TwoColorTimeline.PREV_G];
b = frames[frame + TwoColorTimeline.PREV_B];
a = frames[frame + TwoColorTimeline.PREV_A];
r2 = frames[frame + TwoColorTimeline.PREV_R2];
g2 = frames[frame + TwoColorTimeline.PREV_G2];
b2 = frames[frame + TwoColorTimeline.PREV_B2];
/** @type {?} */
var frameTime = frames[frame];
/** @type {?} */
var percent = this.getCurvePercent(frame / TwoColorTimeline.ENTRIES - 1, 1 -
(time - frameTime) /
(frames[frame + TwoColorTimeline.PREV_TIME] - frameTime));
r += (frames[frame + TwoColorTimeline.R] - r) * percent;
g += (frames[frame + TwoColorTimeline.G] - g) * percent;
b += (frames[frame + TwoColorTimeline.B] - b) * percent;
a += (frames[frame + TwoColorTimeline.A] - a) * percent;
r2 += (frames[frame + TwoColorTimeline.R2] - r2) * percent;
g2 += (frames[frame + TwoColorTimeline.G2] - g2) * percent;
b2 += (frames[frame + TwoColorTimeline.B2] - b2) * percent;
}
if (alpha == 1) {
slot.color.set(r, g, b, a);
slot.darkColor.set(r2, g2, b2, 1);
}
else {
/** @type {?} */
var light = slot.color;
/** @type {?} */
var dark = slot.darkColor;
if (blend == MixBlend.setup) {
light.setFromColor(slot.data.color);
dark.setFromColor(slot.data.darkColor);
}
light.add((r - light.r) * alpha, (g - light.g) * alpha, (b - light.b) * alpha, (a - light.a) * alpha);
dark.add((r2 - dark.r) * alpha, (g2 - dark.g) * alpha, (b2 - dark.b) * alpha, 0);
}
};
TwoColorTimeline.ENTRIES = 8;
TwoColorTimeline.PREV_TIME = -8;
TwoColorTimeline.PREV_R = -7;
TwoColorTimeline.PREV_G = -6;
TwoColorTimeline.PREV_B = -5;
TwoColorTimeline.PREV_A = -4;
TwoColorTimeline.PREV_R2 = -3;
TwoColorTimeline.PREV_G2 = -2;
TwoColorTimeline.PREV_B2 = -1;
TwoColorTimeline.R = 1;
TwoColorTimeline.G = 2;
TwoColorTimeline.B = 3;
TwoColorTimeline.A = 4;
TwoColorTimeline.R2 = 5;
TwoColorTimeline.G2 = 6;
TwoColorTimeline.B2 = 7;
return TwoColorTimeline;
}(CurveTimeline));
if (false) {
/** @type {?} */
TwoColorTimeline.ENTRIES;
/** @type {?} */
TwoColorTimeline.PREV_TIME;
/** @type {?} */
TwoColorTimeline.PREV_R;
/** @type {?} */
TwoColorTimeline.PREV_G;
/** @type {?} */
TwoColorTimeline.PREV_B;
/** @type {?} */
TwoColorTimeline.PREV_A;
/** @type {?} */
TwoColorTimeline.PREV_R2;
/** @type {?} */
TwoColorTimeline.PREV_G2;
/** @type {?} */
TwoColorTimeline.PREV_B2;
/** @type {?} */
TwoColorTimeline.R;
/** @type {?} */
TwoColorTimeline.G;
/** @type {?} */
TwoColorTimeline.B;
/** @type {?} */
TwoColorTimeline.A;
/** @type {?} */
TwoColorTimeline.R2;
/** @type {?} */
TwoColorTimeline.G2;
/** @type {?} */
TwoColorTimeline.B2;
/** @type {?} */
TwoColorTimeline.prototype.slotIndex;
/** @type {?} */
TwoColorTimeline.prototype.frames;
}
var AttachmentTimeline = /** @class */ (function () {
function AttachmentTimeline(frameCount) {
this.frames = Utils.newFloatArray(frameCount);
this.attachmentNames = new Array(frameCount);
}
/**
* @return {?}
*/
AttachmentTimeline.prototype.getPropertyId = /**
* @return {?}
*/
function () {
return (TimelineType.attachment << 24) + this.slotIndex;
};
/**
* @return {?}
*/
AttachmentTimeline.prototype.getFrameCount = /**
* @return {?}
*/
function () {
return this.frames.length;
};
/** Sets the time and value of the specified keyframe. */
/**
* Sets the time and value of the specified keyframe.
* @param {?} frameIndex
* @param {?} time
* @param {?} attachmentName
* @return {?}
*/
AttachmentTimeline.prototype.setFrame = /**
* Sets the time and value of the specified keyframe.
* @param {?} frameIndex
* @param {?} time
* @param {?} attachmentName
* @return {?}
*/
function (frameIndex, time, attachmentName) {
this.frames[frameIndex] = time;
this.attachmentNames[frameIndex] = attachmentName;
};
/**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} events
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
AttachmentTimeline.prototype.apply = /**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} events
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
function (skeleton, lastTime, time, events, alpha, blend, direction) {
/** @type {?} */
var slot = skeleton.slots[this.slotIndex];
if (!slot.bone.active)
return;
if (direction == MixDirection.mixOut && blend == MixBlend.setup) {
/** @type {?} */
var attachmentName_1 = slot.data.attachmentName;
slot.setAttachment(attachmentName_1 == null
? null
: skeleton.getAttachment(this.slotIndex, attachmentName_1));
return;
}
/** @type {?} */
var frames = this.frames;
if (time < frames[0]) {
if (blend == MixBlend.setup || blend == MixBlend.first) {
/** @type {?} */
var attachmentName_2 = slot.data.attachmentName;
slot.setAttachment(attachmentName_2 == null
? null
: skeleton.getAttachment(this.slotIndex, attachmentName_2));
}
return;
}
/** @type {?} */
var frameIndex = 0;
if (time >= frames[frames.length - 1])
// Time is after last frame.
frameIndex = frames.length - 1;
else
frameIndex = Animation.binarySearch(frames, time, 1) - 1;
/** @type {?} */
var attachmentName = this.attachmentNames[frameIndex];
skeleton.slots[this.slotIndex].setAttachment(attachmentName == null
? null
: skeleton.getAttachment(this.slotIndex, attachmentName));
};
return AttachmentTimeline;
}());
if (false) {
/** @type {?} */
AttachmentTimeline.prototype.slotIndex;
/** @type {?} */
AttachmentTimeline.prototype.frames;
/** @type {?} */
AttachmentTimeline.prototype.attachmentNames;
}
/** @type {?} */
var zeros = null;
var DeformTimeline = /** @class */ (function (_super) {
__extends(DeformTimeline, _super);
function DeformTimeline(frameCount) {
var _this = _super.call(this, frameCount) || this;
_this.frames = Utils.newFloatArray(frameCount);
_this.frameVertices = new Array(frameCount);
if (zeros == null)
zeros = Utils.newFloatArray(64);
return _this;
}
/**
* @return {?}
*/
DeformTimeline.prototype.getPropertyId = /**
* @return {?}
*/
function () {
return (TimelineType.deform << 27) + +this.attachment.id + this.slotIndex;
};
/** Sets the time of the specified keyframe. */
/**
* Sets the time of the specified keyframe.
* @param {?} frameIndex
* @param {?} time
* @param {?} vertices
* @return {?}
*/
DeformTimeline.prototype.setFrame = /**
* Sets the time of the specified keyframe.
* @param {?} frameIndex
* @param {?} time
* @param {?} vertices
* @return {?}
*/
function (frameIndex, time, vertices) {
this.frames[frameIndex] = time;
this.frameVertices[frameIndex] = vertices;
};
/**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} firedEvents
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
DeformTimeline.prototype.apply = /**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} firedEvents
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
/** @type {?} */
var slot = skeleton.slots[this.slotIndex];
if (!slot.bone.active)
return;
/** @type {?} */
var slotAttachment = slot.getAttachment();
if (!(slotAttachment instanceof VertexAttachment) ||
!(((/** @type {?} */ (slotAttachment))).deformAttachment == this.attachment))
return;
/** @type {?} */
var deformArray = slot.deform;
if (deformArray.length == 0)
blend = MixBlend.setup;
/** @type {?} */
var frameVertices = this.frameVertices;
/** @type {?} */
var vertexCount = frameVertices[0].length;
/** @type {?} */
var frames = this.frames;
if (time < frames[0]) {
/** @type {?} */
var vertexAttachment = (/** @type {?} */ (slotAttachment));
switch (blend) {
case MixBlend.setup:
deformArray.length = 0;
return;
case MixBlend.first:
if (alpha == 1) {
deformArray.length = 0;
break;
}
/** @type {?} */
var deform_1 = Utils.setArraySize(deformArray, vertexCount);
if (vertexAttachment.bones == null) {
// Unweighted vertex positions.
/** @type {?} */
var setupVertices = vertexAttachment.vertices;
for (var i = 0; i < vertexCount; i++)
deform_1[i] += (setupVertices[i] - deform_1[i]) * alpha;
}
else {
// Weighted deform offsets.
alpha = 1 - alpha;
for (var i = 0; i < vertexCount; i++)
deform_1[i] *= alpha;
}
}
return;
}
/** @type {?} */
var deform = Utils.setArraySize(deformArray, vertexCount);
if (time >= frames[frames.length - 1]) {
// Time is after last frame.
/** @type {?} */
var lastVertices = frameVertices[frames.length - 1];
if (alpha == 1) {
if (blend == MixBlend.add) {
/** @type {?} */
var vertexAttachment = (/** @type {?} */ (slotAttachment));
if (vertexAttachment.bones == null) {
// Unweighted vertex positions, with alpha.
/** @type {?} */
var setupVertices = vertexAttachment.vertices;
for (var i_1 = 0; i_1 < vertexCount; i_1++) {
deform[i_1] += lastVertices[i_1] - setupVertices[i_1];
}
}
else {
// Weighted deform offsets, with alpha.
for (var i_2 = 0; i_2 < vertexCount; i_2++)
deform[i_2] += lastVertices[i_2];
}
}
else {
Utils.arrayCopy(lastVertices, 0, deform, 0, vertexCount);
}
}
else {
switch (blend) {
case MixBlend.setup: {
/** @type {?} */
var vertexAttachment_1 = (/** @type {?} */ (slotAttachment));
if (vertexAttachment_1.bones == null) {
// Unweighted vertex positions, with alpha.
/** @type {?} */
var setupVertices = vertexAttachment_1.vertices;
for (var i_3 = 0; i_3 < vertexCount; i_3++) {
/** @type {?} */
var setup = setupVertices[i_3];
deform[i_3] = setup + (lastVertices[i_3] - setup) * alpha;
}
}
else {
// Weighted deform offsets, with alpha.
for (var i_4 = 0; i_4 < vertexCount; i_4++)
deform[i_4] = lastVertices[i_4] * alpha;
}
break;
}
case MixBlend.first:
case MixBlend.replace:
for (var i_5 = 0; i_5 < vertexCount; i_5++)
deform[i_5] += (lastVertices[i_5] - deform[i_5]) * alpha;
case MixBlend.add:
/** @type {?} */
var vertexAttachment = (/** @type {?} */ (slotAttachment));
if (vertexAttachment.bones == null) {
// Unweighted vertex positions, with alpha.
/** @type {?} */
var setupVertices = vertexAttachment.vertices;
for (var i_6 = 0; i_6 < vertexCount; i_6++) {
deform[i_6] += (lastVertices[i_6] - setupVertices[i_6]) * alpha;
}
}
else {
// Weighted deform offsets, with alpha.
for (var i_7 = 0; i_7 < vertexCount; i_7++)
deform[i_7] += lastVertices[i_7] * alpha;
}
}
}
return;
}
// Interpolate between the previous frame and the current frame.
/** @type {?} */
var frame = Animation.binarySearch(frames, time);
/** @type {?} */
var prevVertices = frameVertices[frame - 1];
/** @type {?} */
var nextVertices = frameVertices[frame];
/** @type {?} */
var frameTime = frames[frame];
/** @type {?} */
var percent = this.getCurvePercent(frame - 1, 1 - (time - frameTime) / (frames[frame - 1] - frameTime));
if (alpha == 1) {
if (blend == MixBlend.add) {
/** @type {?} */
var vertexAttachment = (/** @type {?} */ (slotAttachment));
if (vertexAttachment.bones == null) {
// Unweighted vertex positions, with alpha.
/** @type {?} */
var setupVertices = vertexAttachment.vertices;
for (var i_8 = 0; i_8 < vertexCount; i_8++) {
/** @type {?} */
var prev = prevVertices[i_8];
deform[i_8] +=
prev + (nextVertices[i_8] - prev) * percent - setupVertices[i_8];
}
}
else {
// Weighted deform offsets, with alpha.
for (var i_9 = 0; i_9 < vertexCount; i_9++) {
/** @type {?} */
var prev = prevVertices[i_9];
deform[i_9] += prev + (nextVertices[i_9] - prev) * percent;
}
}
}
else {
for (var i_10 = 0; i_10 < vertexCount; i_10++) {
/** @type {?} */
var prev = prevVertices[i_10];
deform[i_10] = prev + (nextVertices[i_10] - prev) * percent;
}
}
}
else {
switch (blend) {
case MixBlend.setup: {
/** @type {?} */
var vertexAttachment_2 = (/** @type {?} */ (slotAttachment));
if (vertexAttachment_2.bones == null) {
// Unweighted vertex positions, with alpha.
/** @type {?} */
var setupVertices = vertexAttachment_2.vertices;
for (var i_11 = 0; i_11 < vertexCount; i_11++) {
/** @type {?} */
var prev = prevVertices[i_11];
/** @type {?} */
var setup = setupVertices[i_11];
deform[i_11] =
setup +
(prev + (nextVertices[i_11] - prev) * percent - setup) * alpha;
}
}
else {
// Weighted deform offsets, with alpha.
for (var i_12 = 0; i_12 < vertexCount; i_12++) {
/** @type {?} */
var prev = prevVertices[i_12];
deform[i_12] = (prev + (nextVertices[i_12] - prev) * percent) * alpha;
}
}
break;
}
case MixBlend.first:
case MixBlend.replace:
for (var i_13 = 0; i_13 < vertexCount; i_13++) {
/** @type {?} */
var prev = prevVertices[i_13];
deform[i_13] +=
(prev + (nextVertices[i_13] - prev) * percent - deform[i_13]) * alpha;
}
break;
case MixBlend.add:
/** @type {?} */
var vertexAttachment = (/** @type {?} */ (slotAttachment));
if (vertexAttachment.bones == null) {
// Unweighted vertex positions, with alpha.
/** @type {?} */
var setupVertices = vertexAttachment.vertices;
for (var i_14 = 0; i_14 < vertexCount; i_14++) {
/** @type {?} */
var prev = prevVertices[i_14];
deform[i_14] +=
(prev + (nextVertices[i_14] - prev) * percent - setupVertices[i_14]) *
alpha;
}
}
else {
// Weighted deform offsets, with alpha.
for (var i_15 = 0; i_15 < vertexCount; i_15++) {
/** @type {?} */
var prev = prevVertices[i_15];
deform[i_15] += (prev + (nextVertices[i_15] - prev) * percent) * alpha;
}
}
}
}
};
return DeformTimeline;
}(CurveTimeline));
if (false) {
/** @type {?} */
DeformTimeline.prototype.slotIndex;
/** @type {?} */
DeformTimeline.prototype.attachment;
/** @type {?} */
DeformTimeline.prototype.frames;
/** @type {?} */
DeformTimeline.prototype.frameVertices;
}
var EventTimeline = /** @class */ (function () {
function EventTimeline(frameCount) {
this.frames = Utils.newFloatArray(frameCount);
this.events = new Array(frameCount);
}
/**
* @return {?}
*/
EventTimeline.prototype.getPropertyId = /**
* @return {?}
*/
function () {
return TimelineType.event << 24;
};
/**
* @return {?}
*/
EventTimeline.prototype.getFrameCount = /**
* @return {?}
*/
function () {
return this.frames.length;
};
/** Sets the time of the specified keyframe. */
/**
* Sets the time of the specified keyframe.
* @param {?} frameIndex
* @param {?} event
* @return {?}
*/
EventTimeline.prototype.setFrame = /**
* Sets the time of the specified keyframe.
* @param {?} frameIndex
* @param {?} event
* @return {?}
*/
function (frameIndex, event) {
this.frames[frameIndex] = event.time;
this.events[frameIndex] = event;
};
/** Fires events for frames > lastTime and <= time. */
/**
* Fires events for frames > lastTime and <= time.
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} firedEvents
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
EventTimeline.prototype.apply = /**
* Fires events for frames > lastTime and <= time.
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} firedEvents
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
if (firedEvents == null)
return;
/** @type {?} */
var frames = this.frames;
/** @type {?} */
var frameCount = this.frames.length;
if (lastTime > time) {
// Fire events after last time for looped animations.
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, blend, direction);
lastTime = -1;
}
else if (lastTime >= frames[frameCount - 1])
// Last time is after last frame.
return;
if (time < frames[0])
return; // Time is before first frame.
// Time is before first frame.
/** @type {?} */
var frame = 0;
if (lastTime < frames[0])
frame = 0;
else {
frame = Animation.binarySearch(frames, lastTime);
/** @type {?} */
var frameTime = frames[frame];
while (frame > 0) {
// Fire multiple events with the same frame.
if (frames[frame - 1] != frameTime)
break;
frame--;
}
}
for (; frame < frameCount && time >= frames[frame]; frame++)
firedEvents.push(this.events[frame]);
};
return EventTimeline;
}());
if (false) {
/** @type {?} */
EventTimeline.prototype.frames;
/** @type {?} */
EventTimeline.prototype.events;
}
var DrawOrderTimeline = /** @class */ (function () {
function DrawOrderTimeline(frameCount) {
this.frames = Utils.newFloatArray(frameCount);
this.drawOrders = new Array(frameCount);
}
/**
* @return {?}
*/
DrawOrderTimeline.prototype.getPropertyId = /**
* @return {?}
*/
function () {
return TimelineType.drawOrder << 24;
};
/**
* @return {?}
*/
DrawOrderTimeline.prototype.getFrameCount = /**
* @return {?}
*/
function () {
return this.frames.length;
};
/** Sets the time of the specified keyframe.
* @param drawOrder May be null to use bind pose draw order. */
/**
* Sets the time of the specified keyframe.
* @param {?} frameIndex
* @param {?} time
* @param {?} drawOrder May be null to use bind pose draw order.
* @return {?}
*/
DrawOrderTimeline.prototype.setFrame = /**
* Sets the time of the specified keyframe.
* @param {?} frameIndex
* @param {?} time
* @param {?} drawOrder May be null to use bind pose draw order.
* @return {?}
*/
function (frameIndex, time, drawOrder) {
this.frames[frameIndex] = time;
this.drawOrders[frameIndex] = drawOrder;
};
/**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} firedEvents
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
DrawOrderTimeline.prototype.apply = /**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} firedEvents
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
/** @type {?} */
var drawOrder = skeleton.drawOrder;
/** @type {?} */
var slots = skeleton.slots;
if (direction == MixDirection.mixOut && blend == MixBlend.setup) {
Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
return;
}
/** @type {?} */
var frames = this.frames;
if (time < frames[0]) {
if (blend == MixBlend.setup || blend == MixBlend.first)
Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
return;
}
/** @type {?} */
var frame = 0;
if (time >= frames[frames.length - 1])
// Time is after last frame.
frame = frames.length - 1;
else
frame = Animation.binarySearch(frames, time) - 1;
/** @type {?} */
var drawOrderToSetupIndex = this.drawOrders[frame];
if (drawOrderToSetupIndex == null)
Utils.arrayCopy(slots, 0, drawOrder, 0, slots.length);
else {
for (var i = 0, n = drawOrderToSetupIndex.length; i < n; i++)
drawOrder[i] = slots[drawOrderToSetupIndex[i]];
}
};
return DrawOrderTimeline;
}());
if (false) {
/** @type {?} */
DrawOrderTimeline.prototype.frames;
/** @type {?} */
DrawOrderTimeline.prototype.drawOrders;
}
var IkConstraintTimeline = /** @class */ (function (_super) {
__extends(IkConstraintTimeline, _super);
function IkConstraintTimeline(frameCount) {
var _this = _super.call(this, frameCount) || this;
_this.frames = Utils.newFloatArray(frameCount * IkConstraintTimeline.ENTRIES);
return _this;
}
/**
* @return {?}
*/
IkConstraintTimeline.prototype.getPropertyId = /**
* @return {?}
*/
function () {
return (TimelineType.ikConstraint << 24) + this.ikConstraintIndex;
};
/** Sets the time, mix, softness, and bend direction of the specified keyframe. */
/**
* Sets the time, mix, softness, and bend direction of the specified keyframe.
* @param {?} frameIndex
* @param {?} time
* @param {?} mix
* @param {?} softness
* @param {?} bendDirection
* @param {?} compress
* @param {?} stretch
* @return {?}
*/
IkConstraintTimeline.prototype.setFrame = /**
* Sets the time, mix, softness, and bend direction of the specified keyframe.
* @param {?} frameIndex
* @param {?} time
* @param {?} mix
* @param {?} softness
* @param {?} bendDirection
* @param {?} compress
* @param {?} stretch
* @return {?}
*/
function (frameIndex, time, mix, softness, bendDirection, compress, stretch) {
frameIndex *= IkConstraintTimeline.ENTRIES;
this.frames[frameIndex] = time;
this.frames[frameIndex + IkConstraintTimeline.MIX] = mix;
this.frames[frameIndex + IkConstraintTimeline.SOFTNESS] = softness;
this.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection;
this.frames[frameIndex + IkConstraintTimeline.COMPRESS] = compress ? 1 : 0;
this.frames[frameIndex + IkConstraintTimeline.STRETCH] = stretch ? 1 : 0;
};
/**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} firedEvents
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
IkConstraintTimeline.prototype.apply = /**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} firedEvents
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
/** @type {?} */
var frames = this.frames;
/** @type {?} */
var constraint = skeleton.ikConstraints[this.ikConstraintIndex];
if (!constraint.active)
return;
if (time < frames[0]) {
switch (blend) {
case MixBlend.setup:
constraint.mix = constraint.data.mix;
constraint.softness = constraint.data.softness;
constraint.bendDirection = constraint.data.bendDirection;
constraint.compress = constraint.data.compress;
constraint.stretch = constraint.data.stretch;
return;
case MixBlend.first:
constraint.mix += (constraint.data.mix - constraint.mix) * alpha;
constraint.softness +=
(constraint.data.softness - constraint.softness) * alpha;
constraint.bendDirection = constraint.data.bendDirection;
constraint.compress = constraint.data.compress;
constraint.stretch = constraint.data.stretch;
}
return;
}
if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) {
// Time is after last frame.
if (blend == MixBlend.setup) {
constraint.mix =
constraint.data.mix +
(frames[frames.length + IkConstraintTimeline.PREV_MIX] -
constraint.data.mix) *
alpha;
constraint.softness =
constraint.data.softness +
(frames[frames.length + IkConstraintTimeline.PREV_SOFTNESS] -
constraint.data.softness) *
alpha;
if (direction == MixDirection.mixOut) {
constraint.bendDirection = constraint.data.bendDirection;
constraint.compress = constraint.data.compress;
constraint.stretch = constraint.data.stretch;
}
else {
constraint.bendDirection =
frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];
constraint.compress =
frames[frames.length + IkConstraintTimeline.PREV_COMPRESS] != 0;
constraint.stretch =
frames[frames.length + IkConstraintTimeline.PREV_STRETCH] != 0;
}
}
else {
constraint.mix +=
(frames[frames.length + IkConstraintTimeline.PREV_MIX] -
constraint.mix) *
alpha;
constraint.softness +=
(frames[frames.length + IkConstraintTimeline.PREV_SOFTNESS] -
constraint.softness) *
alpha;
if (direction == MixDirection.mixIn) {
constraint.bendDirection =
frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];
constraint.compress =
frames[frames.length + IkConstraintTimeline.PREV_COMPRESS] != 0;
constraint.stretch =
frames[frames.length + IkConstraintTimeline.PREV_STRETCH] != 0;
}
}
return;
}
// Interpolate between the previous frame and the current frame.
/** @type {?} */
var frame = Animation.binarySearch(frames, time, IkConstraintTimeline.ENTRIES);
/** @type {?} */
var mix = frames[frame + IkConstraintTimeline.PREV_MIX];
/** @type {?} */
var softness = frames[frame + IkConstraintTimeline.PREV_SOFTNESS];
/** @type {?} */
var frameTime = frames[frame];
/** @type {?} */
var percent = this.getCurvePercent(frame / IkConstraintTimeline.ENTRIES - 1, 1 -
(time - frameTime) /
(frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime));
if (blend == MixBlend.setup) {
constraint.mix =
constraint.data.mix +
(mix +
(frames[frame + IkConstraintTimeline.MIX] - mix) * percent -
constraint.data.mix) *
alpha;
constraint.softness =
constraint.data.softness +
(softness +
(frames[frame + IkConstraintTimeline.SOFTNESS] - softness) * percent -
constraint.data.softness) *
alpha;
if (direction == MixDirection.mixOut) {
constraint.bendDirection = constraint.data.bendDirection;
constraint.compress = constraint.data.compress;
constraint.stretch = constraint.data.stretch;
}
else {
constraint.bendDirection =
frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
constraint.compress =
frames[frame + IkConstraintTimeline.PREV_COMPRESS] != 0;
constraint.stretch =
frames[frame + IkConstraintTimeline.PREV_STRETCH] != 0;
}
}
else {
constraint.mix +=
(mix +
(frames[frame + IkConstraintTimeline.MIX] - mix) * percent -
constraint.mix) *
alpha;
constraint.softness +=
(softness +
(frames[frame + IkConstraintTimeline.SOFTNESS] - softness) * percent -
constraint.softness) *
alpha;
if (direction == MixDirection.mixIn) {
constraint.bendDirection =
frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
constraint.compress =
frames[frame + IkConstraintTimeline.PREV_COMPRESS] != 0;
constraint.stretch =
frames[frame + IkConstraintTimeline.PREV_STRETCH] != 0;
}
}
};
IkConstraintTimeline.ENTRIES = 6;
IkConstraintTimeline.PREV_TIME = -6;
IkConstraintTimeline.PREV_MIX = -5;
IkConstraintTimeline.PREV_SOFTNESS = -4;
IkConstraintTimeline.PREV_BEND_DIRECTION = -3;
IkConstraintTimeline.PREV_COMPRESS = -2;
IkConstraintTimeline.PREV_STRETCH = -1;
IkConstraintTimeline.MIX = 1;
IkConstraintTimeline.SOFTNESS = 2;
IkConstraintTimeline.BEND_DIRECTION = 3;
IkConstraintTimeline.COMPRESS = 4;
IkConstraintTimeline.STRETCH = 5;
return IkConstraintTimeline;
}(CurveTimeline));
if (false) {
/** @type {?} */
IkConstraintTimeline.ENTRIES;
/** @type {?} */
IkConstraintTimeline.PREV_TIME;
/** @type {?} */
IkConstraintTimeline.PREV_MIX;
/** @type {?} */
IkConstraintTimeline.PREV_SOFTNESS;
/** @type {?} */
IkConstraintTimeline.PREV_BEND_DIRECTION;
/** @type {?} */
IkConstraintTimeline.PREV_COMPRESS;
/** @type {?} */
IkConstraintTimeline.PREV_STRETCH;
/** @type {?} */
IkConstraintTimeline.MIX;
/** @type {?} */
IkConstraintTimeline.SOFTNESS;
/** @type {?} */
IkConstraintTimeline.BEND_DIRECTION;
/** @type {?} */
IkConstraintTimeline.COMPRESS;
/** @type {?} */
IkConstraintTimeline.STRETCH;
/** @type {?} */
IkConstraintTimeline.prototype.ikConstraintIndex;
/** @type {?} */
IkConstraintTimeline.prototype.frames;
}
var TransformConstraintTimeline = /** @class */ (function (_super) {
__extends(TransformConstraintTimeline, _super);
function TransformConstraintTimeline(frameCount) {
var _this = _super.call(this, frameCount) || this;
_this.frames = Utils.newFloatArray(frameCount * TransformConstraintTimeline.ENTRIES);
return _this;
}
/**
* @return {?}
*/
TransformConstraintTimeline.prototype.getPropertyId = /**
* @return {?}
*/
function () {
return ((TimelineType.transformConstraint << 24) + this.transformConstraintIndex);
};
/** Sets the time and mixes of the specified keyframe. */
/**
* Sets the time and mixes of the specified keyframe.
* @param {?} frameIndex
* @param {?} time
* @param {?} rotateMix
* @param {?} translateMix
* @param {?} scaleMix
* @param {?} shearMix
* @return {?}
*/
TransformConstraintTimeline.prototype.setFrame = /**
* Sets the time and mixes of the specified keyframe.
* @param {?} frameIndex
* @param {?} time
* @param {?} rotateMix
* @param {?} translateMix
* @param {?} scaleMix
* @param {?} shearMix
* @return {?}
*/
function (frameIndex, time, rotateMix, translateMix, scaleMix, shearMix) {
frameIndex *= TransformConstraintTimeline.ENTRIES;
this.frames[frameIndex] = time;
this.frames[frameIndex + TransformConstraintTimeline.ROTATE] = rotateMix;
this.frames[frameIndex + TransformConstraintTimeline.TRANSLATE] = translateMix;
this.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix;
this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix;
};
/**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} firedEvents
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
TransformConstraintTimeline.prototype.apply = /**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} firedEvents
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
/** @type {?} */
var frames = this.frames;
/** @type {?} */
var constraint = skeleton.transformConstraints[this.transformConstraintIndex];
if (!constraint.active)
return;
if (time < frames[0]) {
/** @type {?} */
var data = constraint.data;
switch (blend) {
case MixBlend.setup:
constraint.rotateMix = data.rotateMix;
constraint.translateMix = data.translateMix;
constraint.scaleMix = data.scaleMix;
constraint.shearMix = data.shearMix;
return;
case MixBlend.first:
constraint.rotateMix +=
(data.rotateMix - constraint.rotateMix) * alpha;
constraint.translateMix +=
(data.translateMix - constraint.translateMix) * alpha;
constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha;
constraint.shearMix += (data.shearMix - constraint.shearMix) * alpha;
}
return;
}
/** @type {?} */
var rotate = 0;
/** @type {?} */
var translate = 0;
/** @type {?} */
var scale = 0;
/** @type {?} */
var shear = 0;
if (time >= frames[frames.length - TransformConstraintTimeline.ENTRIES]) {
// Time is after last frame.
/** @type {?} */
var i = frames.length;
rotate = frames[i + TransformConstraintTimeline.PREV_ROTATE];
translate = frames[i + TransformConstraintTimeline.PREV_TRANSLATE];
scale = frames[i + TransformConstraintTimeline.PREV_SCALE];
shear = frames[i + TransformConstraintTimeline.PREV_SHEAR];
}
else {
// Interpolate between the previous frame and the current frame.
/** @type {?} */
var frame = Animation.binarySearch(frames, time, TransformConstraintTimeline.ENTRIES);
rotate = frames[frame + TransformConstraintTimeline.PREV_ROTATE];
translate = frames[frame + TransformConstraintTimeline.PREV_TRANSLATE];
scale = frames[frame + TransformConstraintTimeline.PREV_SCALE];
shear = frames[frame + TransformConstraintTimeline.PREV_SHEAR];
/** @type {?} */
var frameTime = frames[frame];
/** @type {?} */
var percent = this.getCurvePercent(frame / TransformConstraintTimeline.ENTRIES - 1, 1 -
(time - frameTime) /
(frames[frame + TransformConstraintTimeline.PREV_TIME] - frameTime));
rotate +=
(frames[frame + TransformConstraintTimeline.ROTATE] - rotate) * percent;
translate +=
(frames[frame + TransformConstraintTimeline.TRANSLATE] - translate) *
percent;
scale +=
(frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent;
shear +=
(frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent;
}
if (blend == MixBlend.setup) {
/** @type {?} */
var data = constraint.data;
constraint.rotateMix = data.rotateMix + (rotate - data.rotateMix) * alpha;
constraint.translateMix =
data.translateMix + (translate - data.translateMix) * alpha;
constraint.scaleMix = data.scaleMix + (scale - data.scaleMix) * alpha;
constraint.shearMix = data.shearMix + (shear - data.shearMix) * alpha;
}
else {
constraint.rotateMix += (rotate - constraint.rotateMix) * alpha;
constraint.translateMix += (translate - constraint.translateMix) * alpha;
constraint.scaleMix += (scale - constraint.scaleMix) * alpha;
constraint.shearMix += (shear - constraint.shearMix) * alpha;
}
};
TransformConstraintTimeline.ENTRIES = 5;
TransformConstraintTimeline.PREV_TIME = -5;
TransformConstraintTimeline.PREV_ROTATE = -4;
TransformConstraintTimeline.PREV_TRANSLATE = -3;
TransformConstraintTimeline.PREV_SCALE = -2;
TransformConstraintTimeline.PREV_SHEAR = -1;
TransformConstraintTimeline.ROTATE = 1;
TransformConstraintTimeline.TRANSLATE = 2;
TransformConstraintTimeline.SCALE = 3;
TransformConstraintTimeline.SHEAR = 4;
return TransformConstraintTimeline;
}(CurveTimeline));
if (false) {
/** @type {?} */
TransformConstraintTimeline.ENTRIES;
/** @type {?} */
TransformConstraintTimeline.PREV_TIME;
/** @type {?} */
TransformConstraintTimeline.PREV_ROTATE;
/** @type {?} */
TransformConstraintTimeline.PREV_TRANSLATE;
/** @type {?} */
TransformConstraintTimeline.PREV_SCALE;
/** @type {?} */
TransformConstraintTimeline.PREV_SHEAR;
/** @type {?} */
TransformConstraintTimeline.ROTATE;
/** @type {?} */
TransformConstraintTimeline.TRANSLATE;
/** @type {?} */
TransformConstraintTimeline.SCALE;
/** @type {?} */
TransformConstraintTimeline.SHEAR;
/** @type {?} */
TransformConstraintTimeline.prototype.transformConstraintIndex;
/** @type {?} */
TransformConstraintTimeline.prototype.frames;
}
var PathConstraintPositionTimeline = /** @class */ (function (_super) {
__extends(PathConstraintPositionTimeline, _super);
function PathConstraintPositionTimeline(frameCount) {
var _this = _super.call(this, frameCount) || this;
_this.frames = Utils.newFloatArray(frameCount * PathConstraintPositionTimeline.ENTRIES);
return _this;
}
/**
* @return {?}
*/
PathConstraintPositionTimeline.prototype.getPropertyId = /**
* @return {?}
*/
function () {
return ((TimelineType.pathConstraintPosition << 24) + this.pathConstraintIndex);
};
/** Sets the time and value of the specified keyframe. */
/**
* Sets the time and value of the specified keyframe.
* @param {?} frameIndex
* @param {?} time
* @param {?} value
* @return {?}
*/
PathConstraintPositionTimeline.prototype.setFrame = /**
* Sets the time and value of the specified keyframe.
* @param {?} frameIndex
* @param {?} time
* @param {?} value
* @return {?}
*/
function (frameIndex, time, value) {
frameIndex *= PathConstraintPositionTimeline.ENTRIES;
this.frames[frameIndex] = time;
this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value;
};
/**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} firedEvents
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
PathConstraintPositionTimeline.prototype.apply = /**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} firedEvents
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
/** @type {?} */
var frames = this.frames;
/** @type {?} */
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
if (!constraint.active)
return;
if (time < frames[0]) {
switch (blend) {
case MixBlend.setup:
constraint.position = constraint.data.position;
return;
case MixBlend.first:
constraint.position +=
(constraint.data.position - constraint.position) * alpha;
}
return;
}
/** @type {?} */
var position = 0;
if (time >= frames[frames.length - PathConstraintPositionTimeline.ENTRIES])
// Time is after last frame.
position =
frames[frames.length + PathConstraintPositionTimeline.PREV_VALUE];
else {
// Interpolate between the previous frame and the current frame.
/** @type {?} */
var frame = Animation.binarySearch(frames, time, PathConstraintPositionTimeline.ENTRIES);
position = frames[frame + PathConstraintPositionTimeline.PREV_VALUE];
/** @type {?} */
var frameTime = frames[frame];
/** @type {?} */
var percent = this.getCurvePercent(frame / PathConstraintPositionTimeline.ENTRIES - 1, 1 -
(time - frameTime) /
(frames[frame + PathConstraintPositionTimeline.PREV_TIME] -
frameTime));
position +=
(frames[frame + PathConstraintPositionTimeline.VALUE] - position) *
percent;
}
if (blend == MixBlend.setup)
constraint.position =
constraint.data.position +
(position - constraint.data.position) * alpha;
else
constraint.position += (position - constraint.position) * alpha;
};
PathConstraintPositionTimeline.ENTRIES = 2;
PathConstraintPositionTimeline.PREV_TIME = -2;
PathConstraintPositionTimeline.PREV_VALUE = -1;
PathConstraintPositionTimeline.VALUE = 1;
return PathConstraintPositionTimeline;
}(CurveTimeline));
if (false) {
/** @type {?} */
PathConstraintPositionTimeline.ENTRIES;
/** @type {?} */
PathConstraintPositionTimeline.PREV_TIME;
/** @type {?} */
PathConstraintPositionTimeline.PREV_VALUE;
/** @type {?} */
PathConstraintPositionTimeline.VALUE;
/** @type {?} */
PathConstraintPositionTimeline.prototype.pathConstraintIndex;
/** @type {?} */
PathConstraintPositionTimeline.prototype.frames;
}
var PathConstraintSpacingTimeline = /** @class */ (function (_super) {
__extends(PathConstraintSpacingTimeline, _super);
function PathConstraintSpacingTimeline(frameCount) {
return _super.call(this, frameCount) || this;
}
/**
* @return {?}
*/
PathConstraintSpacingTimeline.prototype.getPropertyId = /**
* @return {?}
*/
function () {
return ((TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex);
};
/**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} firedEvents
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
PathConstraintSpacingTimeline.prototype.apply = /**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} firedEvents
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
/** @type {?} */
var frames = this.frames;
/** @type {?} */
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
if (!constraint.active)
return;
if (time < frames[0]) {
switch (blend) {
case MixBlend.setup:
constraint.spacing = constraint.data.spacing;
return;
case MixBlend.first:
constraint.spacing +=
(constraint.data.spacing - constraint.spacing) * alpha;
}
return;
}
/** @type {?} */
var spacing = 0;
if (time >= frames[frames.length - PathConstraintSpacingTimeline.ENTRIES])
// Time is after last frame.
spacing =
frames[frames.length + PathConstraintSpacingTimeline.PREV_VALUE];
else {
// Interpolate between the previous frame and the current frame.
/** @type {?} */
var frame = Animation.binarySearch(frames, time, PathConstraintSpacingTimeline.ENTRIES);
spacing = frames[frame + PathConstraintSpacingTimeline.PREV_VALUE];
/** @type {?} */
var frameTime = frames[frame];
/** @type {?} */
var percent = this.getCurvePercent(frame / PathConstraintSpacingTimeline.ENTRIES - 1, 1 -
(time - frameTime) /
(frames[frame + PathConstraintSpacingTimeline.PREV_TIME] -
frameTime));
spacing +=
(frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) *
percent;
}
if (blend == MixBlend.setup)
constraint.spacing =
constraint.data.spacing + (spacing - constraint.data.spacing) * alpha;
else
constraint.spacing += (spacing - constraint.spacing) * alpha;
};
return PathConstraintSpacingTimeline;
}(PathConstraintPositionTimeline));
var PathConstraintMixTimeline = /** @class */ (function (_super) {
__extends(PathConstraintMixTimeline, _super);
function PathConstraintMixTimeline(frameCount) {
var _this = _super.call(this, frameCount) || this;
_this.frames = Utils.newFloatArray(frameCount * PathConstraintMixTimeline.ENTRIES);
return _this;
}
/**
* @return {?}
*/
PathConstraintMixTimeline.prototype.getPropertyId = /**
* @return {?}
*/
function () {
return (TimelineType.pathConstraintMix << 24) + this.pathConstraintIndex;
};
/** Sets the time and mixes of the specified keyframe. */
/**
* Sets the time and mixes of the specified keyframe.
* @param {?} frameIndex
* @param {?} time
* @param {?} rotateMix
* @param {?} translateMix
* @return {?}
*/
PathConstraintMixTimeline.prototype.setFrame = /**
* Sets the time and mixes of the specified keyframe.
* @param {?} frameIndex
* @param {?} time
* @param {?} rotateMix
* @param {?} translateMix
* @return {?}
*/
function (frameIndex, time, rotateMix, translateMix) {
frameIndex *= PathConstraintMixTimeline.ENTRIES;
this.frames[frameIndex] = time;
this.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix;
this.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix;
};
/**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} firedEvents
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
PathConstraintMixTimeline.prototype.apply = /**
* @param {?} skeleton
* @param {?} lastTime
* @param {?} time
* @param {?} firedEvents
* @param {?} alpha
* @param {?} blend
* @param {?} direction
* @return {?}
*/
function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
/** @type {?} */
var frames = this.frames;
/** @type {?} */
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
if (!constraint.active)
return;
if (time < frames[0]) {
switch (blend) {
case MixBlend.setup:
constraint.rotateMix = constraint.data.rotateMix;
constraint.translateMix = constraint.data.translateMix;
return;
case MixBlend.first:
constraint.rotateMix +=
(constraint.data.rotateMix - constraint.rotateMix) * alpha;
constraint.translateMix +=
(constraint.data.translateMix - constraint.translateMix) * alpha;
}
return;
}
/** @type {?} */
var rotate = 0;
/** @type {?} */
var translate = 0;
if (time >= frames[frames.length - PathConstraintMixTimeline.ENTRIES]) {
// Time is after last frame.
rotate = frames[frames.length + PathConstraintMixTimeline.PREV_ROTATE];
translate =
frames[frames.length + PathConstraintMixTimeline.PREV_TRANSLATE];
}
else {
// Interpolate between the previous frame and the current frame.
/** @type {?} */
var frame = Animation.binarySearch(frames, time, PathConstraintMixTimeline.ENTRIES);
rotate = frames[frame + PathConstraintMixTimeline.PREV_ROTATE];
translate = frames[frame + PathConstraintMixTimeline.PREV_TRANSLATE];
/** @type {?} */
var frameTime = frames[frame];
/** @type {?} */
var percent = this.getCurvePercent(frame / PathConstraintMixTimeline.ENTRIES - 1, 1 -
(time - frameTime) /
(frames[frame + PathConstraintMixTimeline.PREV_TIME] - frameTime));
rotate +=
(frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * percent;
translate +=
(frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) *
percent;
}
if (blend == MixBlend.setup) {
constraint.rotateMix =
constraint.data.rotateMix +
(rotate - constraint.data.rotateMix) * alpha;
constraint.translateMix =
constraint.data.translateMix +
(translate - constraint.data.translateMix) * alpha;
}
else {
constraint.rotateMix += (rotate - constraint.rotateMix) * alpha;
constraint.translateMix += (translate - constraint.translateMix) * alpha;
}
};
PathConstraintMixTimeline.ENTRIES = 3;
PathConstraintMixTimeline.PREV_TIME = -3;
PathConstraintMixTimeline.PREV_ROTATE = -2;
PathConstraintMixTimeline.PREV_TRANSLATE = -1;
PathConstraintMixTimeline.ROTATE = 1;
PathConstraintMixTimeline.TRANSLATE = 2;
return PathConstraintMixTimeline;
}(CurveTimeline));
if (false) {
/** @type {?} */
PathConstraintMixTimeline.ENTRIES;
/** @type {?} */
PathConstraintMixTimeline.PREV_TIME;
/** @type {?} */
PathConstraintMixTimeline.PREV_ROTATE;
/** @type {?} */
PathConstraintMixTimeline.PREV_TRANSLATE;
/** @type {?} */
PathConstraintMixTimeline.ROTATE;
/** @type {?} */
PathConstraintMixTimeline.TRANSLATE;
/** @type {?} */
PathConstraintMixTimeline.prototype.pathConstraintIndex;
/** @type {?} */
PathConstraintMixTimeline.prototype.frames;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var AnimationState = /** @class */ (function () {
function AnimationState(data) {
this.tracks = new Array();
this.events = new Array();
this.listeners = new Array();
this.queue = new EventQueue(this);
this.propertyIDs = new IntSet();
this.animationsChanged = false;
this.timeScale = 1;
this.trackEntryPool = new Pool((/**
* @return {?}
*/
function () { return new TrackEntry(); }));
this.data = data;
}
/**
* @param {?} delta
* @return {?}
*/
AnimationState.prototype.update = /**
* @param {?} delta
* @return {?}
*/
function (delta) {
delta *= this.timeScale;
/** @type {?} */
var tracks = this.tracks;
for (var i = 0, n = tracks.length; i < n; i++) {
/** @type {?} */
var current = tracks[i];
if (current == null)
continue;
current.animationLast = current.nextAnimationLast;
current.trackLast = current.nextTrackLast;
/** @type {?} */
var currentDelta = delta * current.timeScale;
if (current.delay > 0) {
current.delay -= currentDelta;
if (current.delay > 0)
continue;
currentDelta = -current.delay;
current.delay = 0;
}
/** @type {?} */
var next = current.next;
if (next != null) {
// When the next entry's delay is passed, change to the next entry, preserving leftover time.
/** @type {?} */
var nextTime = current.trackLast - next.delay;
if (nextTime >= 0) {
next.delay = 0;
next.trackTime +=
current.timeScale == 0
? 0
: (nextTime / current.timeScale + delta) * next.timeScale;
current.trackTime += currentDelta;
this.setCurrent(i, next, true);
while (next.mixingFrom != null) {
next.mixTime += delta;
next = next.mixingFrom;
}
continue;
}
}
else if (current.trackLast >= current.trackEnd &&
current.mixingFrom == null) {
tracks[i] = null;
this.queue.end(current);
this.disposeNext(current);
continue;
}
if (current.mixingFrom != null && this.updateMixingFrom(current, delta)) {
// End mixing from entries once all have completed.
/** @type {?} */
var from = current.mixingFrom;
current.mixingFrom = null;
if (from != null)
from.mixingTo = null;
while (from != null) {
this.queue.end(from);
from = from.mixingFrom;
}
}
current.trackTime += currentDelta;
}
this.queue.drain();
};
/**
* @param {?} to
* @param {?} delta
* @return {?}
*/
AnimationState.prototype.updateMixingFrom = /**
* @param {?} to
* @param {?} delta
* @return {?}
*/
function (to, delta) {
/** @type {?} */
var from = to.mixingFrom;
if (from == null)
return true;
/** @type {?} */
var finished = this.updateMixingFrom(from, delta);
from.animationLast = from.nextAnimationLast;
from.trackLast = from.nextTrackLast;
// Require mixTime > 0 to ensure the mixing from entry was applied at least once.
if (to.mixTime > 0 && to.mixTime >= to.mixDuration) {
// Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame).
if (from.totalAlpha == 0 || to.mixDuration == 0) {
to.mixingFrom = from.mixingFrom;
if (from.mixingFrom != null)
from.mixingFrom.mixingTo = to;
to.interruptAlpha = from.interruptAlpha;
this.queue.end(from);
}
return finished;
}
from.trackTime += delta * from.timeScale;
to.mixTime += delta;
return false;
};
/**
* @param {?} skeleton
* @return {?}
*/
AnimationState.prototype.apply = /**
* @param {?} skeleton
* @return {?}
*/
function (skeleton) {
if (skeleton == null)
throw new Error("skeleton cannot be null.");
if (this.animationsChanged)
this._animationsChanged();
/** @type {?} */
var events = this.events;
/** @type {?} */
var tracks = this.tracks;
/** @type {?} */
var applied = false;
for (var i = 0, n = tracks.length; i < n; i++) {
/** @type {?} */
var current = tracks[i];
if (current == null || current.delay > 0)
continue;
applied = true;
/** @type {?} */
var blend = i == 0 ? MixBlend.first : current.mixBlend;
// Apply mixing from entries first.
/** @type {?} */
var mix = current.alpha;
if (current.mixingFrom != null)
mix *= this.applyMixingFrom(current, skeleton, blend);
else if (current.trackTime >= current.trackEnd && current.next == null)
mix = 0;
// Apply current entry.
/** @type {?} */
var animationLast = current.animationLast;
/** @type {?} */
var animationTime = current.getAnimationTime();
/** @type {?} */
var timelineCount = current.animation.timelines.length;
/** @type {?} */
var timelines = current.animation.timelines;
if ((i == 0 && mix == 1) || blend == MixBlend.add) {
for (var ii = 0; ii < timelineCount; ii++) {
// Fixes issue #302 on IOS9 where mix, blend sometimes became undefined and caused assets
// to sometimes stop rendering when using color correction, as their RGBA values become NaN.
// (https://github.com/pixijs/pixi-spine/issues/302)
Utils.webkit602BugfixHelper(mix, blend);
timelines[ii].apply(skeleton, animationLast, animationTime, events, mix, blend, MixDirection.mixIn);
}
}
else {
/** @type {?} */
var timelineMode = current.timelineMode;
/** @type {?} */
var firstFrame = current.timelinesRotation.length == 0;
if (firstFrame)
Utils.setArraySize(current.timelinesRotation, timelineCount << 1, null);
/** @type {?} */
var timelinesRotation = current.timelinesRotation;
for (var ii = 0; ii < timelineCount; ii++) {
/** @type {?} */
var timeline = timelines[ii];
/** @type {?} */
var timelineBlend = (timelineMode[ii] & (AnimationState.NOT_LAST - 1)) ==
AnimationState.SUBSEQUENT
? blend
: MixBlend.setup;
if (timeline instanceof RotateTimeline) {
this.applyRotateTimeline(timeline, skeleton, animationTime, mix, timelineBlend, timelinesRotation, ii << 1, firstFrame);
}
else {
// This fixes the WebKit 602 specific issue described at http://esotericsoftware.com/forum/iOS-10-disappearing-graphics-10109
Utils.webkit602BugfixHelper(mix, blend);
timeline.apply(skeleton, animationLast, animationTime, events, mix, timelineBlend, MixDirection.mixIn);
}
}
}
this.queueEvents(current, animationTime);
events.length = 0;
current.nextAnimationLast = animationTime;
current.nextTrackLast = current.trackTime;
}
this.queue.drain();
return applied;
};
/**
* @param {?} to
* @param {?} skeleton
* @param {?} blend
* @return {?}
*/
AnimationState.prototype.applyMixingFrom = /**
* @param {?} to
* @param {?} skeleton
* @param {?} blend
* @return {?}
*/
function (to, skeleton, blend) {
/** @type {?} */
var from = to.mixingFrom;
if (from.mixingFrom != null)
this.applyMixingFrom(from, skeleton, blend);
/** @type {?} */
var mix = 0;
if (to.mixDuration == 0) {
// Single frame mix to undo mixingFrom changes.
mix = 1;
if (blend == MixBlend.first)
blend = MixBlend.setup;
}
else {
mix = to.mixTime / to.mixDuration;
if (mix > 1)
mix = 1;
if (blend != MixBlend.first)
blend = from.mixBlend;
}
/** @type {?} */
var events = mix < from.eventThreshold ? this.events : null;
/** @type {?} */
var attachments = mix < from.attachmentThreshold;
/** @type {?} */
var drawOrder = mix < from.drawOrderThreshold;
/** @type {?} */
var animationLast = from.animationLast;
/** @type {?} */
var animationTime = from.getAnimationTime();
/** @type {?} */
var timelineCount = from.animation.timelines.length;
/** @type {?} */
var timelines = from.animation.timelines;
/** @type {?} */
var alphaHold = from.alpha * to.interruptAlpha;
/** @type {?} */
var alphaMix = alphaHold * (1 - mix);
if (blend == MixBlend.add) {
for (var i = 0; i < timelineCount; i++)
timelines[i].apply(skeleton, animationLast, animationTime, events, alphaMix, blend, MixDirection.mixOut);
}
else {
/** @type {?} */
var timelineMode = from.timelineMode;
/** @type {?} */
var timelineHoldMix = from.timelineHoldMix;
/** @type {?} */
var firstFrame = from.timelinesRotation.length == 0;
if (firstFrame)
Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
/** @type {?} */
var timelinesRotation = from.timelinesRotation;
from.totalAlpha = 0;
for (var i = 0; i < timelineCount; i++) {
/** @type {?} */
var timeline = timelines[i];
/** @type {?} */
var direction = MixDirection.mixOut;
/** @type {?} */
var timelineBlend = void 0;
/** @type {?} */
var alpha = 0;
switch (timelineMode[i] & (AnimationState.NOT_LAST - 1)) {
case AnimationState.SUBSEQUENT:
timelineBlend = blend;
if (!attachments && timeline instanceof AttachmentTimeline) {
if ((timelineMode[i] & AnimationState.NOT_LAST) ==
AnimationState.NOT_LAST)
continue;
timelineBlend = MixBlend.setup;
}
if (!drawOrder && timeline instanceof DrawOrderTimeline)
continue;
alpha = alphaMix;
break;
case AnimationState.FIRST:
timelineBlend = MixBlend.setup;
alpha = alphaMix;
break;
case AnimationState.HOLD:
timelineBlend = MixBlend.setup;
alpha = alphaHold;
break;
default:
timelineBlend = MixBlend.setup;
/** @type {?} */
var holdMix = timelineHoldMix[i];
alpha =
alphaHold *
Math.max(0, 1 - holdMix.mixTime / holdMix.mixDuration);
break;
}
from.totalAlpha += alpha;
if (timeline instanceof RotateTimeline)
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, timelineBlend, timelinesRotation, i << 1, firstFrame);
else {
// This fixes the WebKit 602 specific issue described at http://esotericsoftware.com/forum/iOS-10-disappearing-graphics-10109
Utils.webkit602BugfixHelper(alpha, blend);
if (timelineBlend == MixBlend.setup) {
if (timeline instanceof AttachmentTimeline) {
if (attachments ||
(timelineMode[i] & AnimationState.NOT_LAST) ==
AnimationState.NOT_LAST)
direction = MixDirection.mixIn;
}
else if (timeline instanceof DrawOrderTimeline) {
if (drawOrder)
direction = MixDirection.mixIn;
}
}
timeline.apply(skeleton, animationLast, animationTime, events, alpha, timelineBlend, direction);
}
}
}
if (to.mixDuration > 0)
this.queueEvents(from, animationTime);
this.events.length = 0;
from.nextAnimationLast = animationTime;
from.nextTrackLast = from.trackTime;
return mix;
};
/**
* @param {?} timeline
* @param {?} skeleton
* @param {?} time
* @param {?} alpha
* @param {?} blend
* @param {?} timelinesRotation
* @param {?} i
* @param {?} firstFrame
* @return {?}
*/
AnimationState.prototype.applyRotateTimeline = /**
* @param {?} timeline
* @param {?} skeleton
* @param {?} time
* @param {?} alpha
* @param {?} blend
* @param {?} timelinesRotation
* @param {?} i
* @param {?} firstFrame
* @return {?}
*/
function (timeline, skeleton, time, alpha, blend, timelinesRotation, i, firstFrame) {
if (firstFrame)
timelinesRotation[i] = 0;
if (alpha == 1) {
timeline.apply(skeleton, 0, time, null, 1, blend, MixDirection.mixIn);
return;
}
/** @type {?} */
var rotateTimeline = (/** @type {?} */ (timeline));
/** @type {?} */
var frames = rotateTimeline.frames;
/** @type {?} */
var bone = skeleton.bones[rotateTimeline.boneIndex];
if (!bone.active)
return;
/** @type {?} */
var r1 = 0;
/** @type {?} */
var r2 = 0;
if (time < frames[0]) {
switch (blend) {
case MixBlend.setup:
bone.rotation = bone.data.rotation;
default:
return;
case MixBlend.first:
r1 = bone.rotation;
r2 = bone.data.rotation;
}
}
else {
r1 = blend == MixBlend.setup ? bone.data.rotation : bone.rotation;
if (time >= frames[frames.length - RotateTimeline.ENTRIES])
// Time is after last frame.
r2 =
bone.data.rotation +
frames[frames.length + RotateTimeline.PREV_ROTATION];
else {
// Interpolate between the previous frame and the current frame.
/** @type {?} */
var frame = Animation.binarySearch(frames, time, RotateTimeline.ENTRIES);
/** @type {?} */
var prevRotation = frames[frame + RotateTimeline.PREV_ROTATION];
/** @type {?} */
var frameTime = frames[frame];
/** @type {?} */
var percent = rotateTimeline.getCurvePercent((frame >> 1) - 1, 1 -
(time - frameTime) /
(frames[frame + RotateTimeline.PREV_TIME] - frameTime));
r2 = frames[frame + RotateTimeline.ROTATION] - prevRotation;
r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
r2 = prevRotation + r2 * percent + bone.data.rotation;
r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
}
}
// Mix between rotations using the direction of the shortest route on the first frame while detecting crosses.
/** @type {?} */
var total = 0;
/** @type {?} */
var diff = r2 - r1;
diff -= (16384 - ((16384.499999999996 - diff / 360) | 0)) * 360;
if (diff == 0) {
total = timelinesRotation[i];
}
else {
/** @type {?} */
var lastTotal = 0;
/** @type {?} */
var lastDiff = 0;
if (firstFrame) {
lastTotal = 0;
lastDiff = diff;
}
else {
lastTotal = timelinesRotation[i]; // Angle and direction of mix, including loops.
lastDiff = timelinesRotation[i + 1]; // Difference between bones.
}
/** @type {?} */
var current = diff > 0;
/** @type {?} */
var dir = lastTotal >= 0;
// Detect cross at 0 (not 180).
if (MathUtils.signum(lastDiff) != MathUtils.signum(diff) &&
Math.abs(lastDiff) <= 90) {
// A cross after a 360 rotation is a loop.
if (Math.abs(lastTotal) > 180)
lastTotal += 360 * MathUtils.signum(lastTotal);
dir = current;
}
total = diff + lastTotal - (lastTotal % 360); // Store loops as part of lastTotal.
if (dir != current)
total += 360 * MathUtils.signum(lastTotal);
timelinesRotation[i] = total;
}
timelinesRotation[i + 1] = diff;
r1 += total * alpha;
bone.rotation = r1 - (16384 - ((16384.499999999996 - r1 / 360) | 0)) * 360;
};
/**
* @param {?} entry
* @param {?} animationTime
* @return {?}
*/
AnimationState.prototype.queueEvents = /**
* @param {?} entry
* @param {?} animationTime
* @return {?}
*/
function (entry, animationTime) {
/** @type {?} */
var animationStart = entry.animationStart;
/** @type {?} */
var animationEnd = entry.animationEnd;
/** @type {?} */
var duration = animationEnd - animationStart;
/** @type {?} */
var trackLastWrapped = entry.trackLast % duration;
// Queue events before complete.
/** @type {?} */
var events = this.events;
/** @type {?} */
var i = 0;
/** @type {?} */
var n = events.length;
for (; i < n; i++) {
/** @type {?} */
var event_1 = events[i];
if (event_1.time < trackLastWrapped)
break;
if (event_1.time > animationEnd)
continue; // Discard events outside animation start/end.
this.queue.event(entry, event_1);
}
// Queue complete if completed a loop iteration or the animation.
/** @type {?} */
var complete = false;
if (entry.loop)
complete = duration == 0 || trackLastWrapped > entry.trackTime % duration;
else
complete =
animationTime >= animationEnd && entry.animationLast < animationEnd;
if (complete)
this.queue.complete(entry);
// Queue events after complete.
for (; i < n; i++) {
/** @type {?} */
var event_2 = events[i];
if (event_2.time < animationStart)
continue; // Discard events outside animation start/end.
this.queue.event(entry, events[i]);
}
};
/**
* @return {?}
*/
AnimationState.prototype.clearTracks = /**
* @return {?}
*/
function () {
/** @type {?} */
var oldDrainDisabled = this.queue.drainDisabled;
this.queue.drainDisabled = true;
for (var i = 0, n = this.tracks.length; i < n; i++)
this.clearTrack(i);
this.tracks.length = 0;
this.queue.drainDisabled = oldDrainDisabled;
this.queue.drain();
};
/**
* @param {?} trackIndex
* @return {?}
*/
AnimationState.prototype.clearTrack = /**
* @param {?} trackIndex
* @return {?}
*/
function (trackIndex) {
if (trackIndex >= this.tracks.length)
return;
/** @type {?} */
var current = this.tracks[trackIndex];
if (current == null)
return;
this.queue.end(current);
this.disposeNext(current);
/** @type {?} */
var entry = current;
while (true) {
/** @type {?} */
var from = entry.mixingFrom;
if (from == null)
break;
this.queue.end(from);
entry.mixingFrom = null;
entry.mixingTo = null;
entry = from;
}
this.tracks[current.trackIndex] = null;
this.queue.drain();
};
/**
* @param {?} index
* @param {?} current
* @param {?} interrupt
* @return {?}
*/
AnimationState.prototype.setCurrent = /**
* @param {?} index
* @param {?} current
* @param {?} interrupt
* @return {?}
*/
function (index, current, interrupt) {
/** @type {?} */
var from = this.expandToIndex(index);
this.tracks[index] = current;
if (from != null) {
if (interrupt)
this.queue.interrupt(from);
current.mixingFrom = from;
from.mixingTo = current;
current.mixTime = 0;
// Store the interrupted mix percentage.
if (from.mixingFrom != null && from.mixDuration > 0)
current.interruptAlpha *= Math.min(1, from.mixTime / from.mixDuration);
from.timelinesRotation.length = 0; // Reset rotation for mixing out, in case entry was mixed in.
}
this.queue.start(current);
};
/**
* @param {?} trackIndex
* @param {?} animationName
* @param {?} loop
* @return {?}
*/
AnimationState.prototype.setAnimation = /**
* @param {?} trackIndex
* @param {?} animationName
* @param {?} loop
* @return {?}
*/
function (trackIndex, animationName, loop) {
/** @type {?} */
var animation = this.data.skeletonData.findAnimation(animationName);
if (animation == null)
throw new Error("Animation not found: " + animationName);
return this.setAnimationWith(trackIndex, animation, loop);
};
/**
* @param {?} trackIndex
* @param {?} animation
* @param {?} loop
* @return {?}
*/
AnimationState.prototype.setAnimationWith = /**
* @param {?} trackIndex
* @param {?} animation
* @param {?} loop
* @return {?}
*/
function (trackIndex, animation, loop) {
if (animation == null)
throw new Error("animation cannot be null.");
/** @type {?} */
var interrupt = true;
/** @type {?} */
var current = this.expandToIndex(trackIndex);
if (current != null) {
if (current.nextTrackLast == -1) {
// Don't mix from an entry that was never applied.
this.tracks[trackIndex] = current.mixingFrom;
this.queue.interrupt(current);
this.queue.end(current);
this.disposeNext(current);
current = current.mixingFrom;
interrupt = false;
}
else
this.disposeNext(current);
}
/** @type {?} */
var entry = this.trackEntry(trackIndex, animation, loop, current);
this.setCurrent(trackIndex, entry, interrupt);
this.queue.drain();
return entry;
};
/**
* @param {?} trackIndex
* @param {?} animationName
* @param {?} loop
* @param {?} delay
* @return {?}
*/
AnimationState.prototype.addAnimation = /**
* @param {?} trackIndex
* @param {?} animationName
* @param {?} loop
* @param {?} delay
* @return {?}
*/
function (trackIndex, animationName, loop, delay) {
/** @type {?} */
var animation = this.data.skeletonData.findAnimation(animationName);
if (animation == null)
throw new Error("Animation not found: " + animationName);
return this.addAnimationWith(trackIndex, animation, loop, delay);
};
/**
* @param {?} trackIndex
* @param {?} animation
* @param {?} loop
* @param {?} delay
* @return {?}
*/
AnimationState.prototype.addAnimationWith = /**
* @param {?} trackIndex
* @param {?} animation
* @param {?} loop
* @param {?} delay
* @return {?}
*/
function (trackIndex, animation, loop, delay) {
if (animation == null)
throw new Error("animation cannot be null.");
/** @type {?} */
var last = this.expandToIndex(trackIndex);
if (last != null) {
while (last.next != null)
last = last.next;
}
/** @type {?} */
var entry = this.trackEntry(trackIndex, animation, loop, last);
if (last == null) {
this.setCurrent(trackIndex, entry, true);
this.queue.drain();
}
else {
last.next = entry;
if (delay <= 0) {
/** @type {?} */
var duration = last.animationEnd - last.animationStart;
if (duration != 0) {
if (last.loop)
delay += duration * (1 + ((last.trackTime / duration) | 0));
else
delay += Math.max(duration, last.trackTime);
delay -= this.data.getMix(last.animation, animation);
}
else
delay = last.trackTime;
}
}
entry.delay = delay;
return entry;
};
/**
* @param {?} trackIndex
* @param {?} mixDuration
* @return {?}
*/
AnimationState.prototype.setEmptyAnimation = /**
* @param {?} trackIndex
* @param {?} mixDuration
* @return {?}
*/
function (trackIndex, mixDuration) {
/** @type {?} */
var entry = this.setAnimationWith(trackIndex, AnimationState.emptyAnimation, false);
entry.mixDuration = mixDuration;
entry.trackEnd = mixDuration;
return entry;
};
/**
* @param {?} trackIndex
* @param {?} mixDuration
* @param {?} delay
* @return {?}
*/
AnimationState.prototype.addEmptyAnimation = /**
* @param {?} trackIndex
* @param {?} mixDuration
* @param {?} delay
* @return {?}
*/
function (trackIndex, mixDuration, delay) {
if (delay <= 0)
delay -= mixDuration;
/** @type {?} */
var entry = this.addAnimationWith(trackIndex, AnimationState.emptyAnimation, false, delay);
entry.mixDuration = mixDuration;
entry.trackEnd = mixDuration;
return entry;
};
/**
* @param {?} mixDuration
* @return {?}
*/
AnimationState.prototype.setEmptyAnimations = /**
* @param {?} mixDuration
* @return {?}
*/
function (mixDuration) {
/** @type {?} */
var oldDrainDisabled = this.queue.drainDisabled;
this.queue.drainDisabled = true;
for (var i = 0, n = this.tracks.length; i < n; i++) {
/** @type {?} */
var current = this.tracks[i];
if (current != null)
this.setEmptyAnimation(current.trackIndex, mixDuration);
}
this.queue.drainDisabled = oldDrainDisabled;
this.queue.drain();
};
/**
* @param {?} index
* @return {?}
*/
AnimationState.prototype.expandToIndex = /**
* @param {?} index
* @return {?}
*/
function (index) {
if (index < this.tracks.length)
return this.tracks[index];
Utils.ensureArrayCapacity(this.tracks, index + 1, null);
this.tracks.length = index + 1;
return null;
};
/**
* @param {?} trackIndex
* @param {?} animation
* @param {?} loop
* @param {?} last
* @return {?}
*/
AnimationState.prototype.trackEntry = /**
* @param {?} trackIndex
* @param {?} animation
* @param {?} loop
* @param {?} last
* @return {?}
*/
function (trackIndex, animation, loop, last) {
/** @type {?} */
var entry = this.trackEntryPool.obtain();
entry.trackIndex = trackIndex;
entry.animation = animation;
entry.loop = loop;
entry.holdPrevious = false;
entry.eventThreshold = 0;
entry.attachmentThreshold = 0;
entry.drawOrderThreshold = 0;
entry.animationStart = 0;
entry.animationEnd = animation.duration;
entry.animationLast = -1;
entry.nextAnimationLast = -1;
entry.delay = 0;
entry.trackTime = 0;
entry.trackLast = -1;
entry.nextTrackLast = -1;
entry.trackEnd = Number.MAX_VALUE;
entry.timeScale = 1;
entry.alpha = 1;
entry.interruptAlpha = 1;
entry.mixTime = 0;
entry.mixDuration =
last == null ? 0 : this.data.getMix(last.animation, animation);
return entry;
};
/**
* @param {?} entry
* @return {?}
*/
AnimationState.prototype.disposeNext = /**
* @param {?} entry
* @return {?}
*/
function (entry) {
/** @type {?} */
var next = entry.next;
while (next != null) {
this.queue.dispose(next);
next = next.next;
}
entry.next = null;
};
/**
* @return {?}
*/
AnimationState.prototype._animationsChanged = /**
* @return {?}
*/
function () {
this.animationsChanged = false;
this.propertyIDs.clear();
for (var i = 0, n = this.tracks.length; i < n; i++) {
/** @type {?} */
var entry = this.tracks[i];
if (entry == null)
continue;
while (entry.mixingFrom != null)
entry = entry.mixingFrom;
do {
if (entry.mixingFrom == null || entry.mixBlend != MixBlend.add)
this.computeHold(entry);
entry = entry.mixingTo;
} while (entry != null);
}
this.propertyIDs.clear();
for (var i = this.tracks.length - 1; i >= 0; i--) {
/** @type {?} */
var entry = this.tracks[i];
while (entry != null) {
this.computeNotLast(entry);
entry = entry.mixingFrom;
}
}
};
/**
* @param {?} entry
* @return {?}
*/
AnimationState.prototype.computeHold = /**
* @param {?} entry
* @return {?}
*/
function (entry) {
/** @type {?} */
var to = entry.mixingTo;
/** @type {?} */
var timelines = entry.animation.timelines;
/** @type {?} */
var timelinesCount = entry.animation.timelines.length;
/** @type {?} */
var timelineMode = Utils.setArraySize(entry.timelineMode, timelinesCount);
entry.timelineHoldMix.length = 0;
/** @type {?} */
var timelineDipMix = Utils.setArraySize(entry.timelineHoldMix, timelinesCount);
/** @type {?} */
var propertyIDs = this.propertyIDs;
if (to != null && to.holdPrevious) {
for (var i = 0; i < timelinesCount; i++) {
propertyIDs.add(timelines[i].getPropertyId());
timelineMode[i] = AnimationState.HOLD;
}
return;
}
outer: for (var i = 0; i < timelinesCount; i++) {
/** @type {?} */
var timeline = timelines[i];
/** @type {?} */
var id = timeline.getPropertyId();
if (!propertyIDs.add(id))
timelineMode[i] = AnimationState.SUBSEQUENT;
else if (to == null ||
timeline instanceof AttachmentTimeline ||
timeline instanceof DrawOrderTimeline ||
timeline instanceof EventTimeline ||
!to.animation.hasTimeline(id)) {
timelineMode[i] = AnimationState.FIRST;
}
else {
for (var next = to.mixingTo; next != null; next = next.mixingTo) {
if (next.animation.hasTimeline(id))
continue;
if (entry.mixDuration > 0) {
timelineMode[i] = AnimationState.HOLD_MIX;
timelineDipMix[i] = next;
continue outer;
}
break;
}
timelineMode[i] = AnimationState.HOLD;
}
}
};
/**
* @param {?} entry
* @return {?}
*/
AnimationState.prototype.computeNotLast = /**
* @param {?} entry
* @return {?}
*/
function (entry) {
/** @type {?} */
var timelines = entry.animation.timelines;
/** @type {?} */
var timelinesCount = entry.animation.timelines.length;
/** @type {?} */
var timelineMode = entry.timelineMode;
/** @type {?} */
var propertyIDs = this.propertyIDs;
for (var i = 0; i < timelinesCount; i++) {
if (timelines[i] instanceof AttachmentTimeline) {
/** @type {?} */
var timeline = (/** @type {?} */ (timelines[i]));
if (!propertyIDs.add(timeline.slotIndex))
timelineMode[i] |= AnimationState.NOT_LAST;
}
}
};
/**
* @param {?} trackIndex
* @return {?}
*/
AnimationState.prototype.getCurrent = /**
* @param {?} trackIndex
* @return {?}
*/
function (trackIndex) {
if (trackIndex >= this.tracks.length)
return null;
return this.tracks[trackIndex];
};
/**
* @param {?} listener
* @return {?}
*/
AnimationState.prototype.addListener = /**
* @param {?} listener
* @return {?}
*/
function (listener) {
if (listener == null)
throw new Error("listener cannot be null.");
this.listeners.push(listener);
};
/** Removes the listener added with {@link #addListener(AnimationStateListener)}. */
/**
* Removes the listener added with {\@link #addListener(AnimationStateListener)}.
* @param {?} listener
* @return {?}
*/
AnimationState.prototype.removeListener = /**
* Removes the listener added with {\@link #addListener(AnimationStateListener)}.
* @param {?} listener
* @return {?}
*/
function (listener) {
/** @type {?} */
var index = this.listeners.indexOf(listener);
if (index >= 0)
this.listeners.splice(index, 1);
};
/**
* @return {?}
*/
AnimationState.prototype.clearListeners = /**
* @return {?}
*/
function () {
this.listeners.length = 0;
};
/**
* @return {?}
*/
AnimationState.prototype.clearListenerNotifications = /**
* @return {?}
*/
function () {
this.queue.clear();
};
AnimationState.emptyAnimation = new Animation("<empty>", [], 0);
AnimationState.SUBSEQUENT = 0;
AnimationState.FIRST = 1;
AnimationState.HOLD = 2;
AnimationState.HOLD_MIX = 3;
AnimationState.NOT_LAST = 4;
return AnimationState;
}());
if (false) {
/** @type {?} */
AnimationState.emptyAnimation;
/** @type {?} */
AnimationState.SUBSEQUENT;
/** @type {?} */
AnimationState.FIRST;
/** @type {?} */
AnimationState.HOLD;
/** @type {?} */
AnimationState.HOLD_MIX;
/** @type {?} */
AnimationState.NOT_LAST;
/** @type {?} */
AnimationState.prototype.data;
/** @type {?} */
AnimationState.prototype.tracks;
/** @type {?} */
AnimationState.prototype.events;
/** @type {?} */
AnimationState.prototype.listeners;
/** @type {?} */
AnimationState.prototype.queue;
/** @type {?} */
AnimationState.prototype.propertyIDs;
/** @type {?} */
AnimationState.prototype.animationsChanged;
/** @type {?} */
AnimationState.prototype.timeScale;
/** @type {?} */
AnimationState.prototype.trackEntryPool;
}
var TrackEntry = /** @class */ (function () {
function TrackEntry() {
this.mixBlend = MixBlend.replace;
this.timelineMode = new Array();
this.timelineHoldMix = new Array();
this.timelinesRotation = new Array();
}
/**
* @return {?}
*/
TrackEntry.prototype.reset = /**
* @return {?}
*/
function () {
this.next = null;
this.mixingFrom = null;
this.mixingTo = null;
this.animation = null;
this.listener = null;
this.timelineMode.length = 0;
this.timelineHoldMix.length = 0;
this.timelinesRotation.length = 0;
};
/**
* @return {?}
*/
TrackEntry.prototype.getAnimationTime = /**
* @return {?}
*/
function () {
if (this.loop) {
/** @type {?} */
var duration = this.animationEnd - this.animationStart;
if (duration == 0)
return this.animationStart;
return (this.trackTime % duration) + this.animationStart;
}
return Math.min(this.trackTime + this.animationStart, this.animationEnd);
};
/**
* @param {?} animationLast
* @return {?}
*/
TrackEntry.prototype.setAnimationLast = /**
* @param {?} animationLast
* @return {?}
*/
function (animationLast) {
this.animationLast = animationLast;
this.nextAnimationLast = animationLast;
};
/**
* @return {?}
*/
TrackEntry.prototype.isComplete = /**
* @return {?}
*/
function () {
return this.trackTime >= this.animationEnd - this.animationStart;
};
/**
* @return {?}
*/
TrackEntry.prototype.resetRotationDirections = /**
* @return {?}
*/
function () {
this.timelinesRotation.length = 0;
};
return TrackEntry;
}());
if (false) {
/** @type {?} */
TrackEntry.prototype.animation;
/** @type {?} */
TrackEntry.prototype.next;
/** @type {?} */
TrackEntry.prototype.mixingFrom;
/** @type {?} */
TrackEntry.prototype.mixingTo;
/** @type {?} */
TrackEntry.prototype.listener;
/** @type {?} */
TrackEntry.prototype.trackIndex;
/** @type {?} */
TrackEntry.prototype.loop;
/** @type {?} */
TrackEntry.prototype.holdPrevious;
/** @type {?} */
TrackEntry.prototype.eventThreshold;
/** @type {?} */
TrackEntry.prototype.attachmentThreshold;
/** @type {?} */
TrackEntry.prototype.drawOrderThreshold;
/** @type {?} */
TrackEntry.prototype.animationStart;
/** @type {?} */
TrackEntry.prototype.animationEnd;
/** @type {?} */
TrackEntry.prototype.animationLast;
/** @type {?} */
TrackEntry.prototype.nextAnimationLast;
/** @type {?} */
TrackEntry.prototype.delay;
/** @type {?} */
TrackEntry.prototype.trackTime;
/** @type {?} */
TrackEntry.prototype.trackLast;
/** @type {?} */
TrackEntry.prototype.nextTrackLast;
/** @type {?} */
TrackEntry.prototype.trackEnd;
/** @type {?} */
TrackEntry.prototype.timeScale;
/** @type {?} */
TrackEntry.prototype.alpha;
/** @type {?} */
TrackEntry.prototype.mixTime;
/** @type {?} */
TrackEntry.prototype.mixDuration;
/** @type {?} */
TrackEntry.prototype.interruptAlpha;
/** @type {?} */
TrackEntry.prototype.totalAlpha;
/** @type {?} */
TrackEntry.prototype.mixBlend;
/** @type {?} */
TrackEntry.prototype.timelineMode;
/** @type {?} */
TrackEntry.prototype.timelineHoldMix;
/** @type {?} */
TrackEntry.prototype.timelinesRotation;
}
var EventQueue = /** @class */ (function () {
function EventQueue(animState) {
this.objects = [];
this.drainDisabled = false;
this.animState = animState;
}
/**
* @param {?} entry
* @return {?}
*/
EventQueue.prototype.start = /**
* @param {?} entry
* @return {?}
*/
function (entry) {
this.objects.push(EventType.start);
this.objects.push(entry);
this.animState.animationsChanged = true;
};
/**
* @param {?} entry
* @return {?}
*/
EventQueue.prototype.interrupt = /**
* @param {?} entry
* @return {?}
*/
function (entry) {
this.objects.push(EventType.interrupt);
this.objects.push(entry);
};
/**
* @param {?} entry
* @return {?}
*/
EventQueue.prototype.end = /**
* @param {?} entry
* @return {?}
*/
function (entry) {
this.objects.push(EventType.end);
this.objects.push(entry);
this.animState.animationsChanged = true;
};
/**
* @param {?} entry
* @return {?}
*/
EventQueue.prototype.dispose = /**
* @param {?} entry
* @return {?}
*/
function (entry) {
this.objects.push(EventType.dispose);
this.objects.push(entry);
};
/**
* @param {?} entry
* @return {?}
*/
EventQueue.prototype.complete = /**
* @param {?} entry
* @return {?}
*/
function (entry) {
this.objects.push(EventType.complete);
this.objects.push(entry);
};
/**
* @param {?} entry
* @param {?} event
* @return {?}
*/
EventQueue.prototype.event = /**
* @param {?} entry
* @param {?} event
* @return {?}
*/
function (entry, event) {
this.objects.push(EventType.event);
this.objects.push(entry);
this.objects.push(event);
};
/**
* @return {?}
*/
EventQueue.prototype.drain = /**
* @return {?}
*/
function () {
if (this.drainDisabled)
return;
this.drainDisabled = true;
/** @type {?} */
var objects = this.objects;
/** @type {?} */
var listeners = this.animState.listeners;
for (var i = 0; i < objects.length; i += 2) {
/** @type {?} */
var type = (/** @type {?} */ (objects[i]));
/** @type {?} */
var entry = (/** @type {?} */ (objects[i + 1]));
switch (type) {
case EventType.start:
if (entry.listener != null && entry.listener.start)
entry.listener.start(entry);
for (var ii = 0; ii < listeners.length; ii++)
if (listeners[ii].start)
listeners[ii].start(entry);
break;
case EventType.interrupt:
if (entry.listener != null && entry.listener.interrupt)
entry.listener.interrupt(entry);
for (var ii = 0; ii < listeners.length; ii++)
if (listeners[ii].interrupt)
listeners[ii].interrupt(entry);
break;
case EventType.end:
if (entry.listener != null && entry.listener.end)
entry.listener.end(entry);
for (var ii = 0; ii < listeners.length; ii++)
if (listeners[ii].end)
listeners[ii].end(entry);
// Fall through.
case EventType.dispose:
if (entry.listener != null && entry.listener.dispose)
entry.listener.dispose(entry);
for (var ii = 0; ii < listeners.length; ii++)
if (listeners[ii].dispose)
listeners[ii].dispose(entry);
this.animState.trackEntryPool.free(entry);
break;
case EventType.complete:
if (entry.listener != null && entry.listener.complete)
entry.listener.complete(entry);
for (var ii = 0; ii < listeners.length; ii++)
if (listeners[ii].complete)
listeners[ii].complete(entry);
break;
case EventType.event:
/** @type {?} */
var event_3 = (/** @type {?} */ (objects[i++ + 2]));
if (entry.listener != null && entry.listener.event)
entry.listener.event(entry, event_3);
for (var ii = 0; ii < listeners.length; ii++)
if (listeners[ii].event)
listeners[ii].event(entry, event_3);
break;
}
}
this.clear();
this.drainDisabled = false;
};
/**
* @return {?}
*/
EventQueue.prototype.clear = /**
* @return {?}
*/
function () {
this.objects.length = 0;
};
return EventQueue;
}());
if (false) {
/** @type {?} */
EventQueue.prototype.objects;
/** @type {?} */
EventQueue.prototype.drainDisabled;
/** @type {?} */
EventQueue.prototype.animState;
}
/** @enum {number} */
var EventType = {
start: 0,
interrupt: 1,
end: 2,
dispose: 3,
complete: 4,
event: 5,
};
EventType[EventType.start] = 'start';
EventType[EventType.interrupt] = 'interrupt';
EventType[EventType.end] = 'end';
EventType[EventType.dispose] = 'dispose';
EventType[EventType.complete] = 'complete';
EventType[EventType.event] = 'event';
/**
* @record
*/
function AnimationStateListener2() { }
if (false) {
/**
* Invoked when this entry has been set as the current entry.
* @param {?} entry
* @return {?}
*/
AnimationStateListener2.prototype.start = function (entry) { };
/**
* Invoked when another entry has replaced this entry as the current entry. This entry may continue being applied for
* mixing.
* @param {?} entry
* @return {?}
*/
AnimationStateListener2.prototype.interrupt = function (entry) { };
/**
* Invoked when this entry is no longer the current entry and will never be applied again.
* @param {?} entry
* @return {?}
*/
AnimationStateListener2.prototype.end = function (entry) { };
/**
* Invoked when this entry will be disposed. This may occur without the entry ever being set as the current entry.
* References to the entry should not be kept after dispose is called, as it may be destroyed or reused.
* @param {?} entry
* @return {?}
*/
AnimationStateListener2.prototype.dispose = function (entry) { };
/**
* Invoked every time this entry's animation completes a loop.
* @param {?} entry
* @return {?}
*/
AnimationStateListener2.prototype.complete = function (entry) { };
/**
* Invoked when this entry's animation triggers an event.
* @param {?} entry
* @param {?} event
* @return {?}
*/
AnimationStateListener2.prototype.event = function (entry, event) { };
}
/**
* @abstract
*/
var /**
* @abstract
*/
AnimationStateAdapter2 = /** @class */ (function () {
function AnimationStateAdapter2() {
}
/**
* @param {?} entry
* @return {?}
*/
AnimationStateAdapter2.prototype.start = /**
* @param {?} entry
* @return {?}
*/
function (entry) { };
/**
* @param {?} entry
* @return {?}
*/
AnimationStateAdapter2.prototype.interrupt = /**
* @param {?} entry
* @return {?}
*/
function (entry) { };
/**
* @param {?} entry
* @return {?}
*/
AnimationStateAdapter2.prototype.end = /**
* @param {?} entry
* @return {?}
*/
function (entry) { };
/**
* @param {?} entry
* @return {?}
*/
AnimationStateAdapter2.prototype.dispose = /**
* @param {?} entry
* @return {?}
*/
function (entry) { };
/**
* @param {?} entry
* @return {?}
*/
AnimationStateAdapter2.prototype.complete = /**
* @param {?} entry
* @return {?}
*/
function (entry) { };
/**
* @param {?} entry
* @param {?} event
* @return {?}
*/
AnimationStateAdapter2.prototype.event = /**
* @param {?} entry
* @param {?} event
* @return {?}
*/
function (entry, event) { };
return AnimationStateAdapter2;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/******************************************************************************
* Spine Runtimes License Agreement
* Last updated May 1, 2019. Replaces all prior versions.
*
* Copyright (c) 2013-2019, Esoteric Software LLC
*
* Integration of the Spine Runtimes into software or otherwise creating
* derivative works of the Spine Runtimes is permitted under the terms and
* conditions of Section 2 of the Spine Editor License Agreement:
* http://esotericsoftware.com/spine-editor-license
*
* Otherwise, it is permitted to integrate the Spine Runtimes into software
* or otherwise create derivative works of the Spine Runtimes (collectively,
* "Products"), provided that each user of the Products must obtain their own
* Spine Editor license and redistribution of the Products in any form must
* include this license and copyright notice.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
* INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
var AnimationStateData = /** @class */ (function () {
function AnimationStateData(skeletonData) {
this.animationToMixTime = {};
this.defaultMix = 0;
if (skeletonData == null)
throw new Error("skeletonData cannot be null.");
this.skeletonData = skeletonData;
}
/**
* @param {?} fromName
* @param {?} toName
* @param {?} duration
* @return {?}
*/
AnimationStateData.prototype.setMix = /**
* @param {?} fromName
* @param {?} toName
* @param {?} duration
* @return {?}
*/
function (fromName, toName, duration) {
/** @type {?} */
var from = this.skeletonData.findAnimation(fromName);
if (from == null)
throw new Error("Animation not found: " + fromName);
/** @type {?} */
var to = this.skeletonData.findAnimation(toName);
if (to == null)
throw new Error("Animation not found: " + toName);
this.setMixWith(from, to, duration);
};
/**
* @param {?} from
* @param {?} to
* @param {?} duration
* @return {?}
*/
AnimationStateData.prototype.setMixWith = /**
* @param {?} from
* @param {?} to
* @param {?} duration
* @return {?}
*/
function (from, to, duration) {
if (from == null)
throw new Error("from cannot be null.");
if (to == null)
throw new Error("to cannot be null.");
/** @type {?} */
var key = from.name + "." + to.name;
this.animationToMixTime[key] = duration;
};
/**
* @param {?} from
* @param {?} to
* @return {?}
*/
AnimationStateData.prototype.getMix = /**
* @param {?} from
* @param {?} to
* @return {?}
*/
function (from, to) {
/** @type {?} */
var key = from.name + "." + to.name;
/** @type {?} */
var value = this.animationToMixTime[key];
return value === undefined ? this.defaultMix : value;
};
return AnimationStateData;
}());
if (false) {
/** @type {?} */
AnimationStateData.prototype.skeletonData;
/** @type {?} */
AnimationStateData.prototype.animationToMixTime;
/** @type {?} */
AnimationStateData.prototype.defaultMix;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var PointAttachment = /** @class */ (function (_super) {
__extends(PointAttachment, _super);
function PointAttachment(name) {
var _this = _super.call(this, name) || this;
_this.color = new Color(0.38, 0.94, 0, 1);
return _this;
}
/**
* @param {?} bone
* @param {?} point
* @return {?}
*/
PointAttachment.prototype.computeWorldPosition = /**
* @param {?} bone
* @param {?} point
* @return {?}
*/
function (bone, point) {
point.x = this.x * bone.a + this.y * bone.b + bone.worldX;
point.y = this.x * bone.c + this.y * bone.d + bone.worldY;
return point;
};
/**
* @param {?} bone
* @return {?}
*/
PointAttachment.prototype.computeWorldRotation = /**
* @param {?} bone
* @return {?}
*/
function (bone) {
/** @type {?} */
var cos = MathUtils.cosDeg(this.rotation);
/** @type {?} */
var sin = MathUtils.sinDeg(this.rotation);
/** @type {?} */
var x = cos * bone.a + sin * bone.b;
/** @type {?} */
var y = cos * bone.c + sin * bone.d;
return Math.atan2(y, x) * MathUtils.radDeg;
};
/**
* @return {?}
*/
PointAttachment.prototype.copy = /**
* @return {?}
*/
function () {
/** @type {?} */
var copy = new PointAttachment(name);
copy.x = this.x;
copy.y = this.y;
copy.rotation = this.rotation;
copy.color.setFromColor(this.color);
return copy;
};
return PointAttachment;
}(VertexAttachment));
if (false) {
/** @type {?} */
PointAttachment.prototype.x;
/** @type {?} */
PointAttachment.prototype.y;
/** @type {?} */
PointAttachment.prototype.rotation;
/** @type {?} */
PointAttachment.prototype.color;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var AtlasAttachmentLoader = /** @class */ (function () {
function AtlasAttachmentLoader(atlas) {
this.atlas = atlas;
}
/** @return May be null to not load an attachment. */
/**
* @param {?} skin
* @param {?} name
* @param {?} path
* @return {?} May be null to not load an attachment.
*/
AtlasAttachmentLoader.prototype.newRegionAttachment = /**
* @param {?} skin
* @param {?} name
* @param {?} path
* @return {?} May be null to not load an attachment.
*/
function (skin, name, path) {
/** @type {?} */
var region = this.atlas.findRegion(path);
if (region == null)
throw new Error("Region not found in atlas: " +
path +
" (region attachment: " +
name +
")");
region.renderObject = region;
/** @type {?} */
var attachment = new RegionAttachment(name);
attachment.setRegion(region);
return attachment;
};
/** @return May be null to not load an attachment. */
/**
* @param {?} skin
* @param {?} name
* @param {?} path
* @return {?} May be null to not load an attachment.
*/
AtlasAttachmentLoader.prototype.newMeshAttachment = /**
* @param {?} skin
* @param {?} name
* @param {?} path
* @return {?} May be null to not load an attachment.
*/
function (skin, name, path) {
/** @type {?} */
var region = this.atlas.findRegion(path);
if (region == null)
throw new Error("Region not found in atlas: " +
path +
" (mesh attachment: " +
name +
")");
region.renderObject = region;
/** @type {?} */
var attachment = new MeshAttachment(name);
attachment.region = region;
return attachment;
};
/** @return May be null to not load an attachment. */
/**
* @param {?} skin
* @param {?} name
* @return {?} May be null to not load an attachment.
*/
AtlasAttachmentLoader.prototype.newBoundingBoxAttachment = /**
* @param {?} skin
* @param {?} name
* @return {?} May be null to not load an attachment.
*/
function (skin, name) {
return new BoundingBoxAttachment(name);
};
/** @return May be null to not load an attachment */
/**
* @param {?} skin
* @param {?} name
* @return {?} May be null to not load an attachment
*/
AtlasAttachmentLoader.prototype.newPathAttachment = /**
* @param {?} skin
* @param {?} name
* @return {?} May be null to not load an attachment
*/
function (skin, name) {
return new PathAttachment(name);
};
/**
* @param {?} skin
* @param {?} name
* @return {?}
*/
AtlasAttachmentLoader.prototype.newPointAttachment = /**
* @param {?} skin
* @param {?} name
* @return {?}
*/
function (skin, name) {
return new PointAttachment(name);
};
/**
* @param {?} skin
* @param {?} name
* @return {?}
*/
AtlasAttachmentLoader.prototype.newClippingAttachment = /**
* @param {?} skin
* @param {?} name
* @return {?}
*/
function (skin, name) {
return new ClippingAttachment(name);
};
return AtlasAttachmentLoader;
}());
if (false) {
/** @type {?} */
AtlasAttachmentLoader.prototype.atlas;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var BoneData = /** @class */ (function () {
function BoneData(index, name, parent) {
this.x = 0;
this.y = 0;
this.rotation = 0;
this.scaleX = 1;
this.scaleY = 1;
this.shearX = 0;
this.shearY = 0;
this.transformMode = TransformMode.Normal;
this.skinRequired = false;
this.color = new Color();
if (index < 0)
throw new Error("index must be >= 0.");
if (name == null)
throw new Error("name cannot be null.");
this.index = index;
this.name = name;
this.parent = parent;
}
return BoneData;
}());
if (false) {
/** @type {?} */
BoneData.prototype.index;
/** @type {?} */
BoneData.prototype.name;
/** @type {?} */
BoneData.prototype.parent;
/** @type {?} */
BoneData.prototype.length;
/** @type {?} */
BoneData.prototype.x;
/** @type {?} */
BoneData.prototype.y;
/** @type {?} */
BoneData.prototype.rotation;
/** @type {?} */
BoneData.prototype.scaleX;
/** @type {?} */
BoneData.prototype.scaleY;
/** @type {?} */
BoneData.prototype.shearX;
/** @type {?} */
BoneData.prototype.shearY;
/** @type {?} */
BoneData.prototype.transformMode;
/** @type {?} */
BoneData.prototype.skinRequired;
/** @type {?} */
BoneData.prototype.color;
}
/** @enum {number} */
var TransformMode = {
Normal: 0,
OnlyTranslation: 1,
NoRotationOrReflection: 2,
NoScale: 3,
NoScaleOrReflection: 4,
};
TransformMode[TransformMode.Normal] = 'Normal';
TransformMode[TransformMode.OnlyTranslation] = 'OnlyTranslation';
TransformMode[TransformMode.NoRotationOrReflection] = 'NoRotationOrReflection';
TransformMode[TransformMode.NoScale] = 'NoScale';
TransformMode[TransformMode.NoScaleOrReflection] = 'NoScaleOrReflection';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var Bone = /** @class */ (function () {
/** @param parent May be null. */
function Bone(data, skeleton, parent) {
this.children = new Array();
this.x = 0;
this.y = 0;
this.rotation = 0;
this.scaleX = 0;
this.scaleY = 0;
this.shearX = 0;
this.shearY = 0;
this.ax = 0;
this.ay = 0;
this.arotation = 0;
this.ascaleX = 0;
this.ascaleY = 0;
this.ashearX = 0;
this.ashearY = 0;
this.appliedValid = false;
this.a = 0;
this.b = 0;
this.worldX = 0;
this.c = 0;
this.d = 0;
this.worldY = 0;
this.sorted = false;
this.active = false;
if (data == null)
throw new Error("data cannot be null.");
if (skeleton == null)
throw new Error("skeleton cannot be null.");
this.data = data;
this.skeleton = skeleton;
this.parent = parent;
this.setToSetupPose();
}
/**
* @return {?}
*/
Bone.prototype.isActive = /**
* @return {?}
*/
function () {
return this.active;
};
/** Same as {@link #updateWorldTransform()}. This method exists for Bone to implement {@link Updatable}. */
/**
* Same as {\@link #updateWorldTransform()}. This method exists for Bone to implement {\@link Updatable}.
* @return {?}
*/
Bone.prototype.update = /**
* Same as {\@link #updateWorldTransform()}. This method exists for Bone to implement {\@link Updatable}.
* @return {?}
*/
function () {
this.updateWorldTransformWith(this.x, this.y, this.rotation, this.scaleX, this.scaleY, this.shearX, this.shearY);
};
/** Computes the world transform using the parent bone and this bone's local transform. */
/**
* Computes the world transform using the parent bone and this bone's local transform.
* @return {?}
*/
Bone.prototype.updateWorldTransform = /**
* Computes the world transform using the parent bone and this bone's local transform.
* @return {?}
*/
function () {
this.updateWorldTransformWith(this.x, this.y, this.rotation, this.scaleX, this.scaleY, this.shearX, this.shearY);
};
/** Computes the world transform using the parent bone and the specified local transform. */
/**
* Computes the world transform using the parent bone and the specified local transform.
* @param {?} x
* @param {?} y
* @param {?} rotation
* @param {?} scaleX
* @param {?} scaleY
* @param {?} shearX
* @param {?} shearY
* @return {?}
*/
Bone.prototype.updateWorldTransformWith = /**
* Computes the world transform using the parent bone and the specified local transform.
* @param {?} x
* @param {?} y
* @param {?} rotation
* @param {?} scaleX
* @param {?} scaleY
* @param {?} shearX
* @param {?} shearY
* @return {?}
*/
function (x, y, rotation, scaleX, scaleY, shearX, shearY) {
this.ax = x;
this.ay = y;
this.arotation = rotation;
this.ascaleX = scaleX;
this.ascaleY = scaleY;
this.ashearX = shearX;
this.ashearY = shearY;
this.appliedValid = true;
/** @type {?} */
var parent = this.parent;
if (parent == null) {
// Root bone.
/** @type {?} */
var skeleton = this.skeleton;
/** @type {?} */
var rotationY = rotation + 90 + shearY;
/** @type {?} */
var sx = skeleton.scaleX;
/** @type {?} */
var sy = skeleton.scaleY;
this.a = MathUtils.cosDeg(rotation + shearX) * scaleX * sx;
this.b = MathUtils.cosDeg(rotationY) * scaleY * sx;
this.c = MathUtils.sinDeg(rotation + shearX) * scaleX * sy;
this.d = MathUtils.sinDeg(rotationY) * scaleY * sy;
this.worldX = x * sx + skeleton.x;
this.worldY = y * sy + skeleton.y;
return;
}
/** @type {?} */
var pa = parent.a;
/** @type {?} */
var pb = parent.b;
/** @type {?} */
var pc = parent.c;
/** @type {?} */
var pd = parent.d;
this.worldX = pa * x + pb * y + parent.worldX;
this.worldY = pc * x + pd * y + parent.worldY;
switch (this.data.transformMode) {
case TransformMode.Normal: {
/** @type {?} */
var rotationY = rotation + 90 + shearY;
/** @type {?} */
var la = MathUtils.cosDeg(rotation + shearX) * scaleX;
/** @type {?} */
var lb = MathUtils.cosDeg(rotationY) * scaleY;
/** @type {?} */
var lc = MathUtils.sinDeg(rotation + shearX) * scaleX;
/** @type {?} */
var ld = MathUtils.sinDeg(rotationY) * scaleY;
this.a = pa * la + pb * lc;
this.b = pa * lb + pb * ld;
this.c = pc * la + pd * lc;
this.d = pc * lb + pd * ld;
return;
}
case TransformMode.OnlyTranslation: {
/** @type {?} */
var rotationY = rotation + 90 + shearY;
this.a = MathUtils.cosDeg(rotation + shearX) * scaleX;
this.b = MathUtils.cosDeg(rotationY) * scaleY;
this.c = MathUtils.sinDeg(rotation + shearX) * scaleX;
this.d = MathUtils.sinDeg(rotationY) * scaleY;
break;
}
case TransformMode.NoRotationOrReflection: {
/** @type {?} */
var s = pa * pa + pc * pc;
/** @type {?} */
var prx = 0;
if (s > 0.0001) {
s = Math.abs(pa * pd - pb * pc) / s;
pb = pc * s;
pd = pa * s;
prx = Math.atan2(pc, pa) * MathUtils.radDeg;
}
else {
pa = 0;
pc = 0;
prx = 90 - Math.atan2(pd, pb) * MathUtils.radDeg;
}
/** @type {?} */
var rx = rotation + shearX - prx;
/** @type {?} */
var ry = rotation + shearY - prx + 90;
/** @type {?} */
var la = MathUtils.cosDeg(rx) * scaleX;
/** @type {?} */
var lb = MathUtils.cosDeg(ry) * scaleY;
/** @type {?} */
var lc = MathUtils.sinDeg(rx) * scaleX;
/** @type {?} */
var ld = MathUtils.sinDeg(ry) * scaleY;
this.a = pa * la - pb * lc;
this.b = pa * lb - pb * ld;
this.c = pc * la + pd * lc;
this.d = pc * lb + pd * ld;
break;
}
case TransformMode.NoScale:
case TransformMode.NoScaleOrReflection: {
/** @type {?} */
var cos = MathUtils.cosDeg(rotation);
/** @type {?} */
var sin = MathUtils.sinDeg(rotation);
/** @type {?} */
var za = (pa * cos + pb * sin) / this.skeleton.scaleX;
/** @type {?} */
var zc = (pc * cos + pd * sin) / this.skeleton.scaleY;
/** @type {?} */
var s = Math.sqrt(za * za + zc * zc);
if (s > 0.00001)
s = 1 / s;
za *= s;
zc *= s;
s = Math.sqrt(za * za + zc * zc);
if (this.data.transformMode == TransformMode.NoScale &&
pa * pd - pb * pc < 0 !=
(this.skeleton.scaleX < 0 != this.skeleton.scaleY < 0))
s = -s;
/** @type {?} */
var r = Math.PI / 2 + Math.atan2(zc, za);
/** @type {?} */
var zb = Math.cos(r) * s;
/** @type {?} */
var zd = Math.sin(r) * s;
/** @type {?} */
var la = MathUtils.cosDeg(shearX) * scaleX;
/** @type {?} */
var lb = MathUtils.cosDeg(90 + shearY) * scaleY;
/** @type {?} */
var lc = MathUtils.sinDeg(shearX) * scaleX;
/** @type {?} */
var ld = MathUtils.sinDeg(90 + shearY) * scaleY;
this.a = za * la + zb * lc;
this.b = za * lb + zb * ld;
this.c = zc * la + zd * lc;
this.d = zc * lb + zd * ld;
break;
}
}
this.a *= this.skeleton.scaleX;
this.b *= this.skeleton.scaleX;
this.c *= this.skeleton.scaleY;
this.d *= this.skeleton.scaleY;
};
/**
* @return {?}
*/
Bone.prototype.setToSetupPose = /**
* @return {?}
*/
function () {
/** @type {?} */
var data = this.data;
this.x = data.x;
this.y = data.y;
this.rotation = data.rotation;
this.scaleX = data.scaleX;
this.scaleY = data.scaleY;
this.shearX = data.shearX;
this.shearY = data.shearY;
};
/**
* @return {?}
*/
Bone.prototype.getWorldRotationX = /**
* @return {?}
*/
function () {
return Math.atan2(this.c, this.a) * MathUtils.radDeg;
};
/**
* @return {?}
*/
Bone.prototype.getWorldRotationY = /**
* @return {?}
*/
function () {
return Math.atan2(this.d, this.b) * MathUtils.radDeg;
};
/**
* @return {?}
*/
Bone.prototype.getWorldScaleX = /**
* @return {?}
*/
function () {
return Math.sqrt(this.a * this.a + this.c * this.c);
};
/**
* @return {?}
*/
Bone.prototype.getWorldScaleY = /**
* @return {?}
*/
function () {
return Math.sqrt(this.b * this.b + this.d * this.d);
};
/** Computes the individual applied transform values from the world transform. This can be useful to perform processing using
* the applied transform after the world transform has been modified directly (eg, by a constraint).
* <p>
* Some information is ambiguous in the world transform, such as -1,-1 scale versus 180 rotation. */
/**
* Computes the individual applied transform values from the world transform. This can be useful to perform processing using
* the applied transform after the world transform has been modified directly (eg, by a constraint).
* <p>
* Some information is ambiguous in the world transform, such as -1,-1 scale versus 180 rotation.
* @return {?}
*/
Bone.prototype.updateAppliedTransform = /**
* Computes the individual applied transform values from the world transform. This can be useful to perform processing using
* the applied transform after the world transform has been modified directly (eg, by a constraint).
* <p>
* Some information is ambiguous in the world transform, such as -1,-1 scale versus 180 rotation.
* @return {?}
*/
function () {
this.appliedValid = true;
/** @type {?} */
var parent = this.parent;
if (parent == null) {
this.ax = this.worldX;
this.ay = this.worldY;
this.arotation = Math.atan2(this.c, this.a) * MathUtils.radDeg;
this.ascaleX = Math.sqrt(this.a * this.a + this.c * this.c);
this.ascaleY = Math.sqrt(this.b * this.b + this.d * this.d);
this.ashearX = 0;
this.ashearY =
Math.atan2(this.a * this.b + this.c * this.d, this.a * this.d - this.b * this.c) * MathUtils.radDeg;
return;
}
/** @type {?} */
var pa = parent.a;
/** @type {?} */
var pb = parent.b;
/** @type {?} */
var pc = parent.c;
/** @type {?} */
var pd = parent.d;
/** @type {?} */
var pid = 1 / (pa * pd - pb * pc);
/** @type {?} */
var dx = this.worldX - parent.worldX;
/** @type {?} */
var dy = this.worldY - parent.worldY;
this.ax = dx * pd * pid - dy * pb * pid;
this.ay = dy * pa * pid - dx * pc * pid;
/** @type {?} */
var ia = pid * pd;
/** @type {?} */
var id = pid * pa;
/** @type {?} */
var ib = pid * pb;
/** @type {?} */
var ic = pid * pc;
/** @type {?} */
var ra = ia * this.a - ib * this.c;
/** @type {?} */
var rb = ia * this.b - ib * this.d;
/** @type {?} */
var rc = id * this.c - ic * this.a;
/** @type {?} */
var rd = id * this.d - ic * this.b;
this.ashearX = 0;
this.ascaleX = Math.sqrt(ra * ra + rc * rc);
if (this.ascaleX > 0.0001) {
/** @type {?} */
var det = ra * rd - rb * rc;
this.ascaleY = det / this.ascaleX;
this.ashearY = Math.atan2(ra * rb + rc * rd, det) * MathUtils.radDeg;
this.arotation = Math.atan2(rc, ra) * MathUtils.radDeg;
}
else {
this.ascaleX = 0;
this.ascaleY = Math.sqrt(rb * rb + rd * rd);
this.ashearY = 0;
this.arotation = 90 - Math.atan2(rd, rb) * MathUtils.radDeg;
}
};
/**
* @param {?} world
* @return {?}
*/
Bone.prototype.worldToLocal = /**
* @param {?} world
* @return {?}
*/
function (world) {
/** @type {?} */
var a = this.a;
/** @type {?} */
var b = this.b;
/** @type {?} */
var c = this.c;
/** @type {?} */
var d = this.d;
/** @type {?} */
var invDet = 1 / (a * d - b * c);
/** @type {?} */
var x = world.x - this.worldX;
/** @type {?} */
var y = world.y - this.worldY;
world.x = x * d * invDet - y * b * invDet;
world.y = y * a * invDet - x * c * invDet;
return world;
};
/**
* @param {?} local
* @return {?}
*/
Bone.prototype.localToWorld = /**
* @param {?} local
* @return {?}
*/
function (local) {
/** @type {?} */
var x = local.x;
/** @type {?} */
var y = local.y;
local.x = x * this.a + y * this.b + this.worldX;
local.y = x * this.c + y * this.d + this.worldY;
return local;
};
/**
* @param {?} worldRotation
* @return {?}
*/
Bone.prototype.worldToLocalRotation = /**
* @param {?} worldRotation
* @return {?}
*/
function (worldRotation) {
/** @type {?} */
var sin = MathUtils.sinDeg(worldRotation);
/** @type {?} */
var cos = MathUtils.cosDeg(worldRotation);
return (Math.atan2(this.a * sin - this.c * cos, this.d * cos - this.b * sin) *
MathUtils.radDeg +
this.rotation -
this.shearX);
};
/**
* @param {?} localRotation
* @return {?}
*/
Bone.prototype.localToWorldRotation = /**
* @param {?} localRotation
* @return {?}
*/
function (localRotation) {
localRotation -= this.rotation - this.shearX;
/** @type {?} */
var sin = MathUtils.sinDeg(localRotation);
/** @type {?} */
var cos = MathUtils.cosDeg(localRotation);
return (Math.atan2(cos * this.c + sin * this.d, cos * this.a + sin * this.b) *
MathUtils.radDeg);
};
/**
* @param {?} degrees
* @return {?}
*/
Bone.prototype.rotateWorld = /**
* @param {?} degrees
* @return {?}
*/
function (degrees) {
/** @type {?} */
var a = this.a;
/** @type {?} */
var b = this.b;
/** @type {?} */
var c = this.c;
/** @type {?} */
var d = this.d;
/** @type {?} */
var cos = MathUtils.cosDeg(degrees);
/** @type {?} */
var sin = MathUtils.sinDeg(degrees);
this.a = cos * a - sin * c;
this.b = cos * b - sin * d;
this.c = sin * a + cos * c;
this.d = sin * b + cos * d;
this.appliedValid = false;
};
return Bone;
}());
if (false) {
/** @type {?} */
Bone.prototype.data;
/** @type {?} */
Bone.prototype.skeleton;
/** @type {?} */
Bone.prototype.parent;
/** @type {?} */
Bone.prototype.children;
/** @type {?} */
Bone.prototype.x;
/** @type {?} */
Bone.prototype.y;
/** @type {?} */
Bone.prototype.rotation;
/** @type {?} */
Bone.prototype.scaleX;
/** @type {?} */
Bone.prototype.scaleY;
/** @type {?} */
Bone.prototype.shearX;
/** @type {?} */
Bone.prototype.shearY;
/** @type {?} */
Bone.prototype.ax;
/** @type {?} */
Bone.prototype.ay;
/** @type {?} */
Bone.prototype.arotation;
/** @type {?} */
Bone.prototype.ascaleX;
/** @type {?} */
Bone.prototype.ascaleY;
/** @type {?} */
Bone.prototype.ashearX;
/** @type {?} */
Bone.prototype.ashearY;
/** @type {?} */
Bone.prototype.appliedValid;
/** @type {?} */
Bone.prototype.a;
/** @type {?} */
Bone.prototype.b;
/** @type {?} */
Bone.prototype.worldX;
/** @type {?} */
Bone.prototype.c;
/** @type {?} */
Bone.prototype.d;
/** @type {?} */
Bone.prototype.worldY;
/** @type {?} */
Bone.prototype.sorted;
/** @type {?} */
Bone.prototype.active;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/******************************************************************************
* Spine Runtimes License Agreement
* Last updated May 1, 2019. Replaces all prior versions.
*
* Copyright (c) 2013-2019, Esoteric Software LLC
*
* Integration of the Spine Runtimes into software or otherwise creating
* derivative works of the Spine Runtimes is permitted under the terms and
* conditions of Section 2 of the Spine Editor License Agreement:
* http://esotericsoftware.com/spine-editor-license
*
* Otherwise, it is permitted to integrate the Spine Runtimes into software
* or otherwise create derivative works of the Spine Runtimes (collectively,
* "Products"), provided that each user of the Products must obtain their own
* Spine Editor license and redistribution of the Products in any form must
* include this license and copyright notice.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
* INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
/**
* @abstract
*/
var /**
* @abstract
*/
ConstraintData = /** @class */ (function () {
function ConstraintData(name, order, skinRequired) {
this.name = name;
this.order = order;
this.skinRequired = skinRequired;
}
return ConstraintData;
}());
if (false) {
/** @type {?} */
ConstraintData.prototype.name;
/** @type {?} */
ConstraintData.prototype.order;
/** @type {?} */
ConstraintData.prototype.skinRequired;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var Event = /** @class */ (function () {
function Event(time, data) {
if (data == null)
throw new Error("data cannot be null.");
this.time = time;
this.data = data;
}
return Event;
}());
if (false) {
/** @type {?} */
Event.prototype.data;
/** @type {?} */
Event.prototype.intValue;
/** @type {?} */
Event.prototype.floatValue;
/** @type {?} */
Event.prototype.stringValue;
/** @type {?} */
Event.prototype.time;
/** @type {?} */
Event.prototype.volume;
/** @type {?} */
Event.prototype.balance;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* ***************************************************************************
* Spine Runtimes License Agreement
* Last updated May 1, 2019. Replaces all prior versions.
*
* Copyright (c) 2013-2019, Esoteric Software LLC
*
* Integration of the Spine Runtimes into software or otherwise creating
* derivative works of the Spine Runtimes is permitted under the terms and
* conditions of Section 2 of the Spine Editor License Agreement:
* http://esotericsoftware.com/spine-editor-license
*
* Otherwise, it is permitted to integrate the Spine Runtimes into software
* or otherwise create derivative works of the Spine Runtimes (collectively,
* "Products"), provided that each user of the Products must obtain their own
* Spine Editor license and redistribution of the Products in any form must
* include this license and copyright notice.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
* INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ***************************************************************************
*/
var /**
* ***************************************************************************
* Spine Runtimes License Agreement
* Last updated May 1, 2019. Replaces all prior versions.
*
* Copyright (c) 2013-2019, Esoteric Software LLC
*
* Integration of the Spine Runtimes into software or otherwise creating
* derivative works of the Spine Runtimes is permitted under the terms and
* conditions of Section 2 of the Spine Editor License Agreement:
* http://esotericsoftware.com/spine-editor-license
*
* Otherwise, it is permitted to integrate the Spine Runtimes into software
* or otherwise create derivative works of the Spine Runtimes (collectively,
* "Products"), provided that each user of the Products must obtain their own
* Spine Editor license and redistribution of the Products in any form must
* include this license and copyright notice.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
* INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ***************************************************************************
*/
EventData = /** @class */ (function () {
function EventData(name) {
this.name = name;
}
return EventData;
}());
if (false) {
/** @type {?} */
EventData.prototype.name;
/** @type {?} */
EventData.prototype.intValue;
/** @type {?} */
EventData.prototype.floatValue;
/** @type {?} */
EventData.prototype.stringValue;
/** @type {?} */
EventData.prototype.audioPath;
/** @type {?} */
EventData.prototype.volume;
/** @type {?} */
EventData.prototype.balance;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var IkConstraint = /** @class */ (function () {
function IkConstraint(data, skeleton) {
this.bendDirection = 0;
this.compress = false;
this.stretch = false;
this.mix = 1;
this.softness = 0;
this.active = false;
if (data == null)
throw new Error("data cannot be null.");
if (skeleton == null)
throw new Error("skeleton cannot be null.");
this.data = data;
this.mix = data.mix;
this.softness = data.softness;
this.bendDirection = data.bendDirection;
this.compress = data.compress;
this.stretch = data.stretch;
this.bones = new Array();
for (var i = 0; i < data.bones.length; i++)
this.bones.push(skeleton.findBone(data.bones[i].name));
this.target = skeleton.findBone(data.target.name);
}
/**
* @return {?}
*/
IkConstraint.prototype.isActive = /**
* @return {?}
*/
function () {
return this.active;
};
/**
* @return {?}
*/
IkConstraint.prototype.apply = /**
* @return {?}
*/
function () {
this.update();
};
/**
* @return {?}
*/
IkConstraint.prototype.update = /**
* @return {?}
*/
function () {
/** @type {?} */
var target = this.target;
/** @type {?} */
var bones = this.bones;
switch (bones.length) {
case 1:
this.apply1(bones[0], target.worldX, target.worldY, this.compress, this.stretch, this.data.uniform, this.mix);
break;
case 2:
this.apply2(bones[0], bones[1], target.worldX, target.worldY, this.bendDirection, this.stretch, this.softness, this.mix);
break;
}
};
/** Adjusts the bone rotation so the tip is as close to the target position as possible. The target is specified in the world
* coordinate system. */
/**
* Adjusts the bone rotation so the tip is as close to the target position as possible. The target is specified in the world
* coordinate system.
* @param {?} bone
* @param {?} targetX
* @param {?} targetY
* @param {?} compress
* @param {?} stretch
* @param {?} uniform
* @param {?} alpha
* @return {?}
*/
IkConstraint.prototype.apply1 = /**
* Adjusts the bone rotation so the tip is as close to the target position as possible. The target is specified in the world
* coordinate system.
* @param {?} bone
* @param {?} targetX
* @param {?} targetY
* @param {?} compress
* @param {?} stretch
* @param {?} uniform
* @param {?} alpha
* @return {?}
*/
function (bone, targetX, targetY, compress, stretch, uniform, alpha) {
if (!bone.appliedValid)
bone.updateAppliedTransform();
/** @type {?} */
var p = bone.parent;
/** @type {?} */
var id = 1 / (p.a * p.d - p.b * p.c);
/** @type {?} */
var x = targetX - p.worldX;
/** @type {?} */
var y = targetY - p.worldY;
/** @type {?} */
var tx = (x * p.d - y * p.b) * id - bone.ax;
/** @type {?} */
var ty = (y * p.a - x * p.c) * id - bone.ay;
/** @type {?} */
var rotationIK = Math.atan2(ty, tx) * MathUtils.radDeg - bone.ashearX - bone.arotation;
if (bone.ascaleX < 0)
rotationIK += 180;
if (rotationIK > 180)
rotationIK -= 360;
else if (rotationIK < -180)
rotationIK += 360;
/** @type {?} */
var sx = bone.ascaleX;
/** @type {?} */
var sy = bone.ascaleY;
if (compress || stretch) {
/** @type {?} */
var b = bone.data.length * sx;
/** @type {?} */
var dd = Math.sqrt(tx * tx + ty * ty);
if ((compress && dd < b) || (stretch && dd > b && b > 0.0001)) {
/** @type {?} */
var s = (dd / b - 1) * alpha + 1;
sx *= s;
if (uniform)
sy *= s;
}
}
bone.updateWorldTransformWith(bone.ax, bone.ay, bone.arotation + rotationIK * alpha, sx, sy, bone.ashearX, bone.ashearY);
};
/** Adjusts the parent and child bone rotations so the tip of the child is as close to the target position as possible. The
* target is specified in the world coordinate system.
* @param child A direct descendant of the parent bone. */
/**
* Adjusts the parent and child bone rotations so the tip of the child is as close to the target position as possible. The
* target is specified in the world coordinate system.
* @param {?} parent
* @param {?} child A direct descendant of the parent bone.
* @param {?} targetX
* @param {?} targetY
* @param {?} bendDir
* @param {?} stretch
* @param {?} softness
* @param {?} alpha
* @return {?}
*/
IkConstraint.prototype.apply2 = /**
* Adjusts the parent and child bone rotations so the tip of the child is as close to the target position as possible. The
* target is specified in the world coordinate system.
* @param {?} parent
* @param {?} child A direct descendant of the parent bone.
* @param {?} targetX
* @param {?} targetY
* @param {?} bendDir
* @param {?} stretch
* @param {?} softness
* @param {?} alpha
* @return {?}
*/
function (parent, child, targetX, targetY, bendDir, stretch, softness, alpha) {
if (alpha == 0) {
child.updateWorldTransform();
return;
}
if (!parent.appliedValid)
parent.updateAppliedTransform();
if (!child.appliedValid)
child.updateAppliedTransform();
/** @type {?} */
var px = parent.ax;
/** @type {?} */
var py = parent.ay;
/** @type {?} */
var psx = parent.ascaleX;
/** @type {?} */
var sx = psx;
/** @type {?} */
var psy = parent.ascaleY;
/** @type {?} */
var csx = child.ascaleX;
/** @type {?} */
var os1 = 0;
/** @type {?} */
var os2 = 0;
/** @type {?} */
var s2 = 0;
if (psx < 0) {
psx = -psx;
os1 = 180;
s2 = -1;
}
else {
os1 = 0;
s2 = 1;
}
if (psy < 0) {
psy = -psy;
s2 = -s2;
}
if (csx < 0) {
csx = -csx;
os2 = 180;
}
else
os2 = 0;
/** @type {?} */
var cx = child.ax;
/** @type {?} */
var cy = 0;
/** @type {?} */
var cwx = 0;
/** @type {?} */
var cwy = 0;
/** @type {?} */
var a = parent.a;
/** @type {?} */
var b = parent.b;
/** @type {?} */
var c = parent.c;
/** @type {?} */
var d = parent.d;
/** @type {?} */
var u = Math.abs(psx - psy) <= 0.0001;
if (!u) {
cy = 0;
cwx = a * cx + parent.worldX;
cwy = c * cx + parent.worldY;
}
else {
cy = child.ay;
cwx = a * cx + b * cy + parent.worldX;
cwy = c * cx + d * cy + parent.worldY;
}
/** @type {?} */
var pp = parent.parent;
a = pp.a;
b = pp.b;
c = pp.c;
d = pp.d;
/** @type {?} */
var id = 1 / (a * d - b * c);
/** @type {?} */
var x = cwx - pp.worldX;
/** @type {?} */
var y = cwy - pp.worldY;
/** @type {?} */
var dx = (x * d - y * b) * id - px;
/** @type {?} */
var dy = (y * a - x * c) * id - py;
/** @type {?} */
var l1 = Math.sqrt(dx * dx + dy * dy);
/** @type {?} */
var l2 = child.data.length * csx;
/** @type {?} */
var a1;
/** @type {?} */
var a2;
if (l1 < 0.0001) {
this.apply1(parent, targetX, targetY, false, stretch, false, alpha);
child.updateWorldTransformWith(cx, cy, 0, child.ascaleX, child.ascaleY, child.ashearX, child.ashearY);
return;
}
x = targetX - pp.worldX;
y = targetY - pp.worldY;
/** @type {?} */
var tx = (x * d - y * b) * id - px;
/** @type {?} */
var ty = (y * a - x * c) * id - py;
/** @type {?} */
var dd = tx * tx + ty * ty;
if (softness != 0) {
softness *= (psx * (csx + 1)) / 2;
/** @type {?} */
var td = Math.sqrt(dd);
/** @type {?} */
var sd = td - l1 - l2 * psx + softness;
if (sd > 0) {
/** @type {?} */
var p = Math.min(1, sd / (softness * 2)) - 1;
p = (sd - softness * (1 - p * p)) / td;
tx -= p * tx;
ty -= p * ty;
dd = tx * tx + ty * ty;
}
}
outer: if (u) {
l2 *= psx;
/** @type {?} */
var cos = (dd - l1 * l1 - l2 * l2) / (2 * l1 * l2);
if (cos < -1)
cos = -1;
else if (cos > 1) {
cos = 1;
if (stretch)
sx *= (Math.sqrt(dd) / (l1 + l2) - 1) * alpha + 1;
}
a2 = Math.acos(cos) * bendDir;
a = l1 + l2 * cos;
b = l2 * Math.sin(a2);
a1 = Math.atan2(ty * a - tx * b, tx * a + ty * b);
}
else {
a = psx * l2;
b = psy * l2;
/** @type {?} */
var aa = a * a;
/** @type {?} */
var bb = b * b;
/** @type {?} */
var ta = Math.atan2(ty, tx);
c = bb * l1 * l1 + aa * dd - aa * bb;
/** @type {?} */
var c1 = -2 * bb * l1;
/** @type {?} */
var c2 = bb - aa;
d = c1 * c1 - 4 * c2 * c;
if (d >= 0) {
/** @type {?} */
var q = Math.sqrt(d);
if (c1 < 0)
q = -q;
q = -(c1 + q) / 2;
/** @type {?} */
var r0 = q / c2;
/** @type {?} */
var r1 = c / q;
/** @type {?} */
var r = Math.abs(r0) < Math.abs(r1) ? r0 : r1;
if (r * r <= dd) {
y = Math.sqrt(dd - r * r) * bendDir;
a1 = ta - Math.atan2(y, r);
a2 = Math.atan2(y / psy, (r - l1) / psx);
break outer;
}
}
/** @type {?} */
var minAngle = MathUtils.PI;
/** @type {?} */
var minX = l1 - a;
/** @type {?} */
var minDist = minX * minX;
/** @type {?} */
var minY = 0;
/** @type {?} */
var maxAngle = 0;
/** @type {?} */
var maxX = l1 + a;
/** @type {?} */
var maxDist = maxX * maxX;
/** @type {?} */
var maxY = 0;
c = (-a * l1) / (aa - bb);
if (c >= -1 && c <= 1) {
c = Math.acos(c);
x = a * Math.cos(c) + l1;
y = b * Math.sin(c);
d = x * x + y * y;
if (d < minDist) {
minAngle = c;
minDist = d;
minX = x;
minY = y;
}
if (d > maxDist) {
maxAngle = c;
maxDist = d;
maxX = x;
maxY = y;
}
}
if (dd <= (minDist + maxDist) / 2) {
a1 = ta - Math.atan2(minY * bendDir, minX);
a2 = minAngle * bendDir;
}
else {
a1 = ta - Math.atan2(maxY * bendDir, maxX);
a2 = maxAngle * bendDir;
}
}
/** @type {?} */
var os = Math.atan2(cy, cx) * s2;
/** @type {?} */
var rotation = parent.arotation;
a1 = (a1 - os) * MathUtils.radDeg + os1 - rotation;
if (a1 > 180)
a1 -= 360;
else if (a1 < -180)
a1 += 360;
parent.updateWorldTransformWith(px, py, rotation + a1 * alpha, sx, parent.ascaleY, 0, 0);
rotation = child.arotation;
a2 = ((a2 + os) * MathUtils.radDeg - child.ashearX) * s2 + os2 - rotation;
if (a2 > 180)
a2 -= 360;
else if (a2 < -180)
a2 += 360;
child.updateWorldTransformWith(cx, cy, rotation + a2 * alpha, child.ascaleX, child.ascaleY, child.ashearX, child.ashearY);
};
return IkConstraint;
}());
if (false) {
/** @type {?} */
IkConstraint.prototype.data;
/** @type {?} */
IkConstraint.prototype.bones;
/** @type {?} */
IkConstraint.prototype.target;
/** @type {?} */
IkConstraint.prototype.bendDirection;
/** @type {?} */
IkConstraint.prototype.compress;
/** @type {?} */
IkConstraint.prototype.stretch;
/** @type {?} */
IkConstraint.prototype.mix;
/** @type {?} */
IkConstraint.prototype.softness;
/** @type {?} */
IkConstraint.prototype.active;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var IkConstraintData = /** @class */ (function (_super) {
__extends(IkConstraintData, _super);
function IkConstraintData(name) {
var _this = _super.call(this, name, 0, false) || this;
_this.bones = new Array();
_this.bendDirection = 1;
_this.compress = false;
_this.stretch = false;
_this.uniform = false;
_this.mix = 1;
_this.softness = 0;
return _this;
}
return IkConstraintData;
}(ConstraintData));
if (false) {
/** @type {?} */
IkConstraintData.prototype.bones;
/** @type {?} */
IkConstraintData.prototype.target;
/** @type {?} */
IkConstraintData.prototype.bendDirection;
/** @type {?} */
IkConstraintData.prototype.compress;
/** @type {?} */
IkConstraintData.prototype.stretch;
/** @type {?} */
IkConstraintData.prototype.uniform;
/** @type {?} */
IkConstraintData.prototype.mix;
/** @type {?} */
IkConstraintData.prototype.softness;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var PathConstraintData = /** @class */ (function (_super) {
__extends(PathConstraintData, _super);
function PathConstraintData(name) {
var _this = _super.call(this, name, 0, false) || this;
_this.bones = new Array();
return _this;
}
return PathConstraintData;
}(ConstraintData));
if (false) {
/** @type {?} */
PathConstraintData.prototype.bones;
/** @type {?} */
PathConstraintData.prototype.target;
/** @type {?} */
PathConstraintData.prototype.positionMode;
/** @type {?} */
PathConstraintData.prototype.spacingMode;
/** @type {?} */
PathConstraintData.prototype.rotateMode;
/** @type {?} */
PathConstraintData.prototype.offsetRotation;
/** @type {?} */
PathConstraintData.prototype.position;
/** @type {?} */
PathConstraintData.prototype.spacing;
/** @type {?} */
PathConstraintData.prototype.rotateMix;
/** @type {?} */
PathConstraintData.prototype.translateMix;
}
/** @enum {number} */
var PositionMode = {
Fixed: 0,
Percent: 1,
};
PositionMode[PositionMode.Fixed] = 'Fixed';
PositionMode[PositionMode.Percent] = 'Percent';
/** @enum {number} */
var SpacingMode = {
Length: 0,
Fixed: 1,
Percent: 2,
};
SpacingMode[SpacingMode.Length] = 'Length';
SpacingMode[SpacingMode.Fixed] = 'Fixed';
SpacingMode[SpacingMode.Percent] = 'Percent';
/** @enum {number} */
var RotateMode = {
Tangent: 0,
Chain: 1,
ChainScale: 2,
};
RotateMode[RotateMode.Tangent] = 'Tangent';
RotateMode[RotateMode.Chain] = 'Chain';
RotateMode[RotateMode.ChainScale] = 'ChainScale';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var PathConstraint = /** @class */ (function () {
function PathConstraint(data, skeleton) {
this.position = 0;
this.spacing = 0;
this.rotateMix = 0;
this.translateMix = 0;
this.spaces = new Array();
this.positions = new Array();
this.world = new Array();
this.curves = new Array();
this.lengths = new Array();
this.segments = new Array();
this.active = false;
if (data == null)
throw new Error("data cannot be null.");
if (skeleton == null)
throw new Error("skeleton cannot be null.");
this.data = data;
this.bones = new Array();
for (var i = 0, n = data.bones.length; i < n; i++)
this.bones.push(skeleton.findBone(data.bones[i].name));
this.target = skeleton.findSlot(data.target.name);
this.position = data.position;
this.spacing = data.spacing;
this.rotateMix = data.rotateMix;
this.translateMix = data.translateMix;
}
/**
* @return {?}
*/
PathConstraint.prototype.isActive = /**
* @return {?}
*/
function () {
return this.active;
};
/**
* @return {?}
*/
PathConstraint.prototype.apply = /**
* @return {?}
*/
function () {
this.update();
};
/**
* @return {?}
*/
PathConstraint.prototype.update = /**
* @return {?}
*/
function () {
/** @type {?} */
var attachment = this.target.getAttachment();
if (!(attachment instanceof PathAttachment))
return;
/** @type {?} */
var rotateMix = this.rotateMix;
/** @type {?} */
var translateMix = this.translateMix;
/** @type {?} */
var translate = translateMix > 0;
/** @type {?} */
var rotate = rotateMix > 0;
if (!translate && !rotate)
return;
/** @type {?} */
var data = this.data;
/** @type {?} */
var percentSpacing = data.spacingMode == SpacingMode.Percent;
/** @type {?} */
var rotateMode = data.rotateMode;
/** @type {?} */
var tangents = rotateMode == RotateMode.Tangent;
/** @type {?} */
var scale = rotateMode == RotateMode.ChainScale;
/** @type {?} */
var boneCount = this.bones.length;
/** @type {?} */
var spacesCount = tangents ? boneCount : boneCount + 1;
/** @type {?} */
var bones = this.bones;
/** @type {?} */
var spaces = Utils.setArraySize(this.spaces, spacesCount);
/** @type {?} */
var lengths = null;
/** @type {?} */
var spacing = this.spacing;
if (scale || !percentSpacing) {
if (scale)
lengths = Utils.setArraySize(this.lengths, boneCount);
/** @type {?} */
var lengthSpacing = data.spacingMode == SpacingMode.Length;
for (var i = 0, n = spacesCount - 1; i < n;) {
/** @type {?} */
var bone = bones[i];
/** @type {?} */
var setupLength = bone.data.length;
if (setupLength < PathConstraint.epsilon) {
if (scale)
lengths[i] = 0;
spaces[++i] = 0;
}
else if (percentSpacing) {
if (scale) {
/** @type {?} */
var x = setupLength * bone.a;
/** @type {?} */
var y = setupLength * bone.c;
/** @type {?} */
var length_1 = Math.sqrt(x * x + y * y);
lengths[i] = length_1;
}
spaces[++i] = spacing;
}
else {
/** @type {?} */
var x = setupLength * bone.a;
/** @type {?} */
var y = setupLength * bone.c;
/** @type {?} */
var length_2 = Math.sqrt(x * x + y * y);
if (scale)
lengths[i] = length_2;
spaces[++i] =
((lengthSpacing ? setupLength + spacing : spacing) * length_2) /
setupLength;
}
}
}
else {
for (var i = 1; i < spacesCount; i++)
spaces[i] = spacing;
}
/** @type {?} */
var positions = this.computeWorldPositions((/** @type {?} */ (attachment)), spacesCount, tangents, data.positionMode == PositionMode.Percent, percentSpacing);
/** @type {?} */
var boneX = positions[0];
/** @type {?} */
var boneY = positions[1];
/** @type {?} */
var offsetRotation = data.offsetRotation;
/** @type {?} */
var tip = false;
if (offsetRotation == 0)
tip = rotateMode == RotateMode.Chain;
else {
tip = false;
/** @type {?} */
var p = this.target.bone;
offsetRotation *=
p.a * p.d - p.b * p.c > 0 ? MathUtils.degRad : -MathUtils.degRad;
}
for (var i = 0, p = 3; i < boneCount; i++, p += 3) {
/** @type {?} */
var bone = bones[i];
bone.worldX += (boneX - bone.worldX) * translateMix;
bone.worldY += (boneY - bone.worldY) * translateMix;
/** @type {?} */
var x = positions[p];
/** @type {?} */
var y = positions[p + 1];
/** @type {?} */
var dx = x - boneX;
/** @type {?} */
var dy = y - boneY;
if (scale) {
/** @type {?} */
var length_3 = lengths[i];
if (length_3 != 0) {
/** @type {?} */
var s = (Math.sqrt(dx * dx + dy * dy) / length_3 - 1) * rotateMix + 1;
bone.a *= s;
bone.c *= s;
}
}
boneX = x;
boneY = y;
if (rotate) {
/** @type {?} */
var a = bone.a;
/** @type {?} */
var b = bone.b;
/** @type {?} */
var c = bone.c;
/** @type {?} */
var d = bone.d;
/** @type {?} */
var r = 0;
/** @type {?} */
var cos = 0;
/** @type {?} */
var sin = 0;
if (tangents)
r = positions[p - 1];
else if (spaces[i + 1] == 0)
r = positions[p + 2];
else
r = Math.atan2(dy, dx);
r -= Math.atan2(c, a);
if (tip) {
cos = Math.cos(r);
sin = Math.sin(r);
/** @type {?} */
var length_4 = bone.data.length;
boneX += (length_4 * (cos * a - sin * c) - dx) * rotateMix;
boneY += (length_4 * (sin * a + cos * c) - dy) * rotateMix;
}
else {
r += offsetRotation;
}
if (r > MathUtils.PI)
r -= MathUtils.PI2;
else if (r < -MathUtils.PI)
//
r += MathUtils.PI2;
r *= rotateMix;
cos = Math.cos(r);
sin = Math.sin(r);
bone.a = cos * a - sin * c;
bone.b = cos * b - sin * d;
bone.c = sin * a + cos * c;
bone.d = sin * b + cos * d;
}
bone.appliedValid = false;
}
};
/**
* @param {?} path
* @param {?} spacesCount
* @param {?} tangents
* @param {?} percentPosition
* @param {?} percentSpacing
* @return {?}
*/
PathConstraint.prototype.computeWorldPositions = /**
* @param {?} path
* @param {?} spacesCount
* @param {?} tangents
* @param {?} percentPosition
* @param {?} percentSpacing
* @return {?}
*/
function (path, spacesCount, tangents, percentPosition, percentSpacing) {
/** @type {?} */
var target = this.target;
/** @type {?} */
var position = this.position;
/** @type {?} */
var spaces = this.spaces;
/** @type {?} */
var out = Utils.setArraySize(this.positions, spacesCount * 3 + 2);
/** @type {?} */
var world = null;
/** @type {?} */
var closed = path.closed;
/** @type {?} */
var verticesLength = path.worldVerticesLength;
/** @type {?} */
var curveCount = verticesLength / 6;
/** @type {?} */
var prevCurve = PathConstraint.NONE;
if (!path.constantSpeed) {
/** @type {?} */
var lengths = path.lengths;
curveCount -= closed ? 1 : 2;
/** @type {?} */
var pathLength_1 = lengths[curveCount];
if (percentPosition)
position *= pathLength_1;
if (percentSpacing) {
for (var i = 1; i < spacesCount; i++)
spaces[i] *= pathLength_1;
}
world = Utils.setArraySize(this.world, 8);
for (var i = 0, o = 0, curve = 0; i < spacesCount; i++, o += 3) {
/** @type {?} */
var space = spaces[i];
position += space;
/** @type {?} */
var p = position;
if (closed) {
p %= pathLength_1;
if (p < 0)
p += pathLength_1;
curve = 0;
}
else if (p < 0) {
if (prevCurve != PathConstraint.BEFORE) {
prevCurve = PathConstraint.BEFORE;
path.computeWorldVertices(target, 2, 4, world, 0, 2);
}
this.addBeforePosition(p, world, 0, out, o);
continue;
}
else if (p > pathLength_1) {
if (prevCurve != PathConstraint.AFTER) {
prevCurve = PathConstraint.AFTER;
path.computeWorldVertices(target, verticesLength - 6, 4, world, 0, 2);
}
this.addAfterPosition(p - pathLength_1, world, 0, out, o);
continue;
}
// Determine curve containing position.
for (;; curve++) {
/** @type {?} */
var length_5 = lengths[curve];
if (p > length_5)
continue;
if (curve == 0)
p /= length_5;
else {
/** @type {?} */
var prev = lengths[curve - 1];
p = (p - prev) / (length_5 - prev);
}
break;
}
if (curve != prevCurve) {
prevCurve = curve;
if (closed && curve == curveCount) {
path.computeWorldVertices(target, verticesLength - 4, 4, world, 0, 2);
path.computeWorldVertices(target, 0, 4, world, 4, 2);
}
else
path.computeWorldVertices(target, curve * 6 + 2, 8, world, 0, 2);
}
this.addCurvePosition(p, world[0], world[1], world[2], world[3], world[4], world[5], world[6], world[7], out, o, tangents || (i > 0 && space == 0));
}
return out;
}
// World vertices.
if (closed) {
verticesLength += 2;
world = Utils.setArraySize(this.world, verticesLength);
path.computeWorldVertices(target, 2, verticesLength - 4, world, 0, 2);
path.computeWorldVertices(target, 0, 2, world, verticesLength - 4, 2);
world[verticesLength - 2] = world[0];
world[verticesLength - 1] = world[1];
}
else {
curveCount--;
verticesLength -= 4;
world = Utils.setArraySize(this.world, verticesLength);
path.computeWorldVertices(target, 2, verticesLength, world, 0, 2);
}
// Curve lengths.
/** @type {?} */
var curves = Utils.setArraySize(this.curves, curveCount);
/** @type {?} */
var pathLength = 0;
/** @type {?} */
var x1 = world[0];
/** @type {?} */
var y1 = world[1];
/** @type {?} */
var cx1 = 0;
/** @type {?} */
var cy1 = 0;
/** @type {?} */
var cx2 = 0;
/** @type {?} */
var cy2 = 0;
/** @type {?} */
var x2 = 0;
/** @type {?} */
var y2 = 0;
/** @type {?} */
var tmpx = 0;
/** @type {?} */
var tmpy = 0;
/** @type {?} */
var dddfx = 0;
/** @type {?} */
var dddfy = 0;
/** @type {?} */
var ddfx = 0;
/** @type {?} */
var ddfy = 0;
/** @type {?} */
var dfx = 0;
/** @type {?} */
var dfy = 0;
for (var i = 0, w = 2; i < curveCount; i++, w += 6) {
cx1 = world[w];
cy1 = world[w + 1];
cx2 = world[w + 2];
cy2 = world[w + 3];
x2 = world[w + 4];
y2 = world[w + 5];
tmpx = (x1 - cx1 * 2 + cx2) * 0.1875;
tmpy = (y1 - cy1 * 2 + cy2) * 0.1875;
dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.09375;
dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.09375;
ddfx = tmpx * 2 + dddfx;
ddfy = tmpy * 2 + dddfy;
dfx = (cx1 - x1) * 0.75 + tmpx + dddfx * 0.16666667;
dfy = (cy1 - y1) * 0.75 + tmpy + dddfy * 0.16666667;
pathLength += Math.sqrt(dfx * dfx + dfy * dfy);
dfx += ddfx;
dfy += ddfy;
ddfx += dddfx;
ddfy += dddfy;
pathLength += Math.sqrt(dfx * dfx + dfy * dfy);
dfx += ddfx;
dfy += ddfy;
pathLength += Math.sqrt(dfx * dfx + dfy * dfy);
dfx += ddfx + dddfx;
dfy += ddfy + dddfy;
pathLength += Math.sqrt(dfx * dfx + dfy * dfy);
curves[i] = pathLength;
x1 = x2;
y1 = y2;
}
if (percentPosition)
position *= pathLength;
else
position *= pathLength / path.lengths[curveCount - 1];
if (percentSpacing) {
for (var i = 1; i < spacesCount; i++)
spaces[i] *= pathLength;
}
/** @type {?} */
var segments = this.segments;
/** @type {?} */
var curveLength = 0;
for (var i = 0, o = 0, curve = 0, segment = 0; i < spacesCount; i++, o += 3) {
/** @type {?} */
var space = spaces[i];
position += space;
/** @type {?} */
var p = position;
if (closed) {
p %= pathLength;
if (p < 0)
p += pathLength;
curve = 0;
}
else if (p < 0) {
this.addBeforePosition(p, world, 0, out, o);
continue;
}
else if (p > pathLength) {
this.addAfterPosition(p - pathLength, world, verticesLength - 4, out, o);
continue;
}
// Determine curve containing position.
for (;; curve++) {
/** @type {?} */
var length_6 = curves[curve];
if (p > length_6)
continue;
if (curve == 0)
p /= length_6;
else {
/** @type {?} */
var prev = curves[curve - 1];
p = (p - prev) / (length_6 - prev);
}
break;
}
// Curve segment lengths.
if (curve != prevCurve) {
prevCurve = curve;
/** @type {?} */
var ii = curve * 6;
x1 = world[ii];
y1 = world[ii + 1];
cx1 = world[ii + 2];
cy1 = world[ii + 3];
cx2 = world[ii + 4];
cy2 = world[ii + 5];
x2 = world[ii + 6];
y2 = world[ii + 7];
tmpx = (x1 - cx1 * 2 + cx2) * 0.03;
tmpy = (y1 - cy1 * 2 + cy2) * 0.03;
dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.006;
dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.006;
ddfx = tmpx * 2 + dddfx;
ddfy = tmpy * 2 + dddfy;
dfx = (cx1 - x1) * 0.3 + tmpx + dddfx * 0.16666667;
dfy = (cy1 - y1) * 0.3 + tmpy + dddfy * 0.16666667;
curveLength = Math.sqrt(dfx * dfx + dfy * dfy);
segments[0] = curveLength;
for (ii = 1; ii < 8; ii++) {
dfx += ddfx;
dfy += ddfy;
ddfx += dddfx;
ddfy += dddfy;
curveLength += Math.sqrt(dfx * dfx + dfy * dfy);
segments[ii] = curveLength;
}
dfx += ddfx;
dfy += ddfy;
curveLength += Math.sqrt(dfx * dfx + dfy * dfy);
segments[8] = curveLength;
dfx += ddfx + dddfx;
dfy += ddfy + dddfy;
curveLength += Math.sqrt(dfx * dfx + dfy * dfy);
segments[9] = curveLength;
segment = 0;
}
// Weight by segment length.
p *= curveLength;
for (;; segment++) {
/** @type {?} */
var length_7 = segments[segment];
if (p > length_7)
continue;
if (segment == 0)
p /= length_7;
else {
/** @type {?} */
var prev = segments[segment - 1];
p = segment + (p - prev) / (length_7 - prev);
}
break;
}
this.addCurvePosition(p * 0.1, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, o, tangents || (i > 0 && space == 0));
}
return out;
};
/**
* @param {?} p
* @param {?} temp
* @param {?} i
* @param {?} out
* @param {?} o
* @return {?}
*/
PathConstraint.prototype.addBeforePosition = /**
* @param {?} p
* @param {?} temp
* @param {?} i
* @param {?} out
* @param {?} o
* @return {?}
*/
function (p, temp, i, out, o) {
/** @type {?} */
var x1 = temp[i];
/** @type {?} */
var y1 = temp[i + 1];
/** @type {?} */
var dx = temp[i + 2] - x1;
/** @type {?} */
var dy = temp[i + 3] - y1;
/** @type {?} */
var r = Math.atan2(dy, dx);
out[o] = x1 + p * Math.cos(r);
out[o + 1] = y1 + p * Math.sin(r);
out[o + 2] = r;
};
/**
* @param {?} p
* @param {?} temp
* @param {?} i
* @param {?} out
* @param {?} o
* @return {?}
*/
PathConstraint.prototype.addAfterPosition = /**
* @param {?} p
* @param {?} temp
* @param {?} i
* @param {?} out
* @param {?} o
* @return {?}
*/
function (p, temp, i, out, o) {
/** @type {?} */
var x1 = temp[i + 2];
/** @type {?} */
var y1 = temp[i + 3];
/** @type {?} */
var dx = x1 - temp[i];
/** @type {?} */
var dy = y1 - temp[i + 1];
/** @type {?} */
var r = Math.atan2(dy, dx);
out[o] = x1 + p * Math.cos(r);
out[o + 1] = y1 + p * Math.sin(r);
out[o + 2] = r;
};
/**
* @param {?} p
* @param {?} x1
* @param {?} y1
* @param {?} cx1
* @param {?} cy1
* @param {?} cx2
* @param {?} cy2
* @param {?} x2
* @param {?} y2
* @param {?} out
* @param {?} o
* @param {?} tangents
* @return {?}
*/
PathConstraint.prototype.addCurvePosition = /**
* @param {?} p
* @param {?} x1
* @param {?} y1
* @param {?} cx1
* @param {?} cy1
* @param {?} cx2
* @param {?} cy2
* @param {?} x2
* @param {?} y2
* @param {?} out
* @param {?} o
* @param {?} tangents
* @return {?}
*/
function (p, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, o, tangents) {
if (p == 0 || isNaN(p)) {
out[o] = x1;
out[o + 1] = y1;
out[o + 2] = Math.atan2(cy1 - y1, cx1 - x1);
return;
}
/** @type {?} */
var tt = p * p;
/** @type {?} */
var ttt = tt * p;
/** @type {?} */
var u = 1 - p;
/** @type {?} */
var uu = u * u;
/** @type {?} */
var uuu = uu * u;
/** @type {?} */
var ut = u * p;
/** @type {?} */
var ut3 = ut * 3;
/** @type {?} */
var uut3 = u * ut3;
/** @type {?} */
var utt3 = ut3 * p;
/** @type {?} */
var x = x1 * uuu + cx1 * uut3 + cx2 * utt3 + x2 * ttt;
/** @type {?} */
var y = y1 * uuu + cy1 * uut3 + cy2 * utt3 + y2 * ttt;
out[o] = x;
out[o + 1] = y;
if (tangents) {
if (p < 0.001)
out[o + 2] = Math.atan2(cy1 - y1, cx1 - x1);
else
out[o + 2] = Math.atan2(y - (y1 * uu + cy1 * ut * 2 + cy2 * tt), x - (x1 * uu + cx1 * ut * 2 + cx2 * tt));
}
};
PathConstraint.NONE = -1;
PathConstraint.BEFORE = -2;
PathConstraint.AFTER = -3;
PathConstraint.epsilon = 0.00001;
return PathConstraint;
}());
if (false) {
/** @type {?} */
PathConstraint.NONE;
/** @type {?} */
PathConstraint.BEFORE;
/** @type {?} */
PathConstraint.AFTER;
/** @type {?} */
PathConstraint.epsilon;
/** @type {?} */
PathConstraint.prototype.data;
/** @type {?} */
PathConstraint.prototype.bones;
/** @type {?} */
PathConstraint.prototype.target;
/** @type {?} */
PathConstraint.prototype.position;
/** @type {?} */
PathConstraint.prototype.spacing;
/** @type {?} */
PathConstraint.prototype.rotateMix;
/** @type {?} */
PathConstraint.prototype.translateMix;
/** @type {?} */
PathConstraint.prototype.spaces;
/** @type {?} */
PathConstraint.prototype.positions;
/** @type {?} */
PathConstraint.prototype.world;
/** @type {?} */
PathConstraint.prototype.curves;
/** @type {?} */
PathConstraint.prototype.lengths;
/** @type {?} */
PathConstraint.prototype.segments;
/** @type {?} */
PathConstraint.prototype.active;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/******************************************************************************
* Spine Runtimes License Agreement
* Last updated May 1, 2019. Replaces all prior versions.
*
* Copyright (c) 2013-2019, Esoteric Software LLC
*
* Integration of the Spine Runtimes into software or otherwise creating
* derivative works of the Spine Runtimes is permitted under the terms and
* conditions of Section 2 of the Spine Editor License Agreement:
* http://esotericsoftware.com/spine-editor-license
*
* Otherwise, it is permitted to integrate the Spine Runtimes into software
* or otherwise create derivative works of the Spine Runtimes (collectively,
* "Products"), provided that each user of the Products must obtain their own
* Spine Editor license and redistribution of the Products in any form must
* include this license and copyright notice.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
* INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
var Assets = /** @class */ (function () {
function Assets(clientId) {
this.toLoad = new Array();
this.assets = {};
this.clientId = clientId;
}
/**
* @return {?}
*/
Assets.prototype.loaded = /**
* @return {?}
*/
function () {
/** @type {?} */
var i = 0;
for (var v in this.assets)
i++;
return i;
};
return Assets;
}());
if (false) {
/** @type {?} */
Assets.prototype.clientId;
/** @type {?} */
Assets.prototype.toLoad;
/** @type {?} */
Assets.prototype.assets;
/** @type {?} */
Assets.prototype.textureLoader;
}
var SharedAssetManager = /** @class */ (function () {
function SharedAssetManager(pathPrefix) {
if (pathPrefix === void 0) { pathPrefix = ""; }
this.clientAssets = {};
this.queuedAssets = {};
this.rawAssets = {};
this.errors = {};
this.pathPrefix = pathPrefix;
}
/**
* @private
* @param {?} clientId
* @param {?} textureLoader
* @param {?} path
* @return {?}
*/
SharedAssetManager.prototype.queueAsset = /**
* @private
* @param {?} clientId
* @param {?} textureLoader
* @param {?} path
* @return {?}
*/
function (clientId, textureLoader, path) {
/** @type {?} */
var clientAssets = this.clientAssets[clientId];
if (clientAssets === null || clientAssets === undefined) {
clientAssets = new Assets(clientId);
this.clientAssets[clientId] = clientAssets;
}
if (textureLoader !== null)
clientAssets.textureLoader = textureLoader;
clientAssets.toLoad.push(path);
// check if already queued, in which case we can skip actual
// loading
if (this.queuedAssets[path] === path) {
return false;
}
else {
this.queuedAssets[path] = path;
return true;
}
};
/**
* @param {?} clientId
* @param {?} path
* @return {?}
*/
SharedAssetManager.prototype.loadText = /**
* @param {?} clientId
* @param {?} path
* @return {?}
*/
function (clientId, path) {
var _this = this;
path = this.pathPrefix + path;
if (!this.queueAsset(clientId, null, path))
return;
/** @type {?} */
var request = new XMLHttpRequest();
request.onreadystatechange = (/**
* @return {?}
*/
function () {
if (request.readyState == XMLHttpRequest.DONE) {
if (request.status >= 200 && request.status < 300) {
_this.rawAssets[path] = request.responseText;
}
else {
_this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText;
}
}
});
request.open("GET", path, true);
request.send();
};
/**
* @param {?} clientId
* @param {?} path
* @return {?}
*/
SharedAssetManager.prototype.loadJson = /**
* @param {?} clientId
* @param {?} path
* @return {?}
*/
function (clientId, path) {
var _this = this;
path = this.pathPrefix + path;
if (!this.queueAsset(clientId, null, path))
return;
/** @type {?} */
var request = new XMLHttpRequest();
request.onreadystatechange = (/**
* @return {?}
*/
function () {
if (request.readyState == XMLHttpRequest.DONE) {
if (request.status >= 200 && request.status < 300) {
_this.rawAssets[path] = JSON.parse(request.responseText);
}
else {
_this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText;
}
}
});
request.open("GET", path, true);
request.send();
};
/**
* @param {?} clientId
* @param {?} textureLoader
* @param {?} path
* @return {?}
*/
SharedAssetManager.prototype.loadTexture = /**
* @param {?} clientId
* @param {?} textureLoader
* @param {?} path
* @return {?}
*/
function (clientId, textureLoader, path) {
var _this = this;
path = this.pathPrefix + path;
if (!this.queueAsset(clientId, textureLoader, path))
return;
/** @type {?} */
var img = new Image();
img.src = path;
img.crossOrigin = "anonymous";
img.onload = (/**
* @param {?} ev
* @return {?}
*/
function (ev) {
_this.rawAssets[path] = img;
});
img.onerror = (/**
* @param {?} ev
* @return {?}
*/
function (ev) {
_this.errors[path] = "Couldn't load image " + path;
});
};
/**
* @param {?} clientId
* @param {?} path
* @return {?}
*/
SharedAssetManager.prototype.get = /**
* @param {?} clientId
* @param {?} path
* @return {?}
*/
function (clientId, path) {
path = this.pathPrefix + path;
/** @type {?} */
var clientAssets = this.clientAssets[clientId];
if (clientAssets === null || clientAssets === undefined)
return true;
return clientAssets.assets[path];
};
/**
* @private
* @param {?} clientAssets
* @return {?}
*/
SharedAssetManager.prototype.updateClientAssets = /**
* @private
* @param {?} clientAssets
* @return {?}
*/
function (clientAssets) {
for (var i = 0; i < clientAssets.toLoad.length; i++) {
/** @type {?} */
var path = clientAssets.toLoad[i];
/** @type {?} */
var asset = clientAssets.assets[path];
if (asset === null || asset === undefined) {
/** @type {?} */
var rawAsset = this.rawAssets[path];
if (rawAsset === null || rawAsset === undefined)
continue;
if (rawAsset instanceof HTMLImageElement) {
clientAssets.assets[path] = clientAssets.textureLoader((/** @type {?} */ (rawAsset)));
}
else {
clientAssets.assets[path] = rawAsset;
}
}
}
};
/**
* @param {?} clientId
* @return {?}
*/
SharedAssetManager.prototype.isLoadingComplete = /**
* @param {?} clientId
* @return {?}
*/
function (clientId) {
/** @type {?} */
var clientAssets = this.clientAssets[clientId];
if (clientAssets === null || clientAssets === undefined)
return true;
this.updateClientAssets(clientAssets);
return clientAssets.toLoad.length == clientAssets.loaded();
};
/*remove (clientId: string, path: string) {
path = this.pathPrefix + path;
let asset = this.assets[path];
if ((<any>asset).dispose) (<any>asset).dispose();
this.assets[path] = null;
}
removeAll () {
for (let key in this.assets) {
let asset = this.assets[key];
if ((<any>asset).dispose) (<any>asset).dispose();
}
this.assets = {};
}*/
/*remove (clientId: string, path: string) {
path = this.pathPrefix + path;
let asset = this.assets[path];
if ((<any>asset).dispose) (<any>asset).dispose();
this.assets[path] = null;
}
removeAll () {
for (let key in this.assets) {
let asset = this.assets[key];
if ((<any>asset).dispose) (<any>asset).dispose();
}
this.assets = {};
}*/
/**
* @return {?}
*/
SharedAssetManager.prototype.dispose = /*remove (clientId: string, path: string) {
path = this.pathPrefix + path;
let asset = this.assets[path];
if ((<any>asset).dispose) (<any>asset).dispose();
this.assets[path] = null;
}
removeAll () {
for (let key in this.assets) {
let asset = this.assets[key];
if ((<any>asset).dispose) (<any>asset).dispose();
}
this.assets = {};
}*/
/**
* @return {?}
*/
function () {
// this.removeAll();
};
/**
* @return {?}
*/
SharedAssetManager.prototype.hasErrors = /**
* @return {?}
*/
function () {
return Object.keys(this.errors).length > 0;
};
/**
* @return {?}
*/
SharedAssetManager.prototype.getErrors = /**
* @return {?}
*/
function () {
return this.errors;
};
return SharedAssetManager;
}());
if (false) {
/**
* @type {?}
* @private
*/
SharedAssetManager.prototype.pathPrefix;
/**
* @type {?}
* @private
*/
SharedAssetManager.prototype.clientAssets;
/**
* @type {?}
* @private
*/
SharedAssetManager.prototype.queuedAssets;
/**
* @type {?}
* @private
*/
SharedAssetManager.prototype.rawAssets;
/**
* @type {?}
* @private
*/
SharedAssetManager.prototype.errors;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var Slot = /** @class */ (function () {
function Slot(data, bone) {
this.deform = new Array();
if (data == null)
throw new Error("data cannot be null.");
if (bone == null)
throw new Error("bone cannot be null.");
this.data = data;
this.bone = bone;
this.color = new Color();
this.darkColor = data.darkColor == null ? null : new Color();
this.setToSetupPose();
}
/** @return May be null. */
/**
* @return {?} May be null.
*/
Slot.prototype.getAttachment = /**
* @return {?} May be null.
*/
function () {
return this.attachment;
};
/** Sets the attachment and if it changed, resets {@link #getAttachmentTime()} and clears {@link #getAttachmentVertices()}.
* @param attachment May be null. */
/**
* Sets the attachment and if it changed, resets {\@link #getAttachmentTime()} and clears {\@link #getAttachmentVertices()}.
* @param {?} attachment May be null.
* @return {?}
*/
Slot.prototype.setAttachment = /**
* Sets the attachment and if it changed, resets {\@link #getAttachmentTime()} and clears {\@link #getAttachmentVertices()}.
* @param {?} attachment May be null.
* @return {?}
*/
function (attachment) {
if (this.attachment == attachment)
return;
this.attachment = attachment;
this.attachmentTime = this.bone.skeleton.time;
this.deform.length = 0;
};
/**
* @param {?} time
* @return {?}
*/
Slot.prototype.setAttachmentTime = /**
* @param {?} time
* @return {?}
*/
function (time) {
this.attachmentTime = this.bone.skeleton.time - time;
};
/** Returns the time since the attachment was set. */
/**
* Returns the time since the attachment was set.
* @return {?}
*/
Slot.prototype.getAttachmentTime = /**
* Returns the time since the attachment was set.
* @return {?}
*/
function () {
return this.bone.skeleton.time - this.attachmentTime;
};
/**
* @return {?}
*/
Slot.prototype.setToSetupPose = /**
* @return {?}
*/
function () {
this.color.setFromColor(this.data.color);
if (this.darkColor != null)
this.darkColor.setFromColor(this.data.darkColor);
if (this.data.attachmentName == null)
this.attachment = null;
else {
this.attachment = null;
this.setAttachment(this.bone.skeleton.getAttachment(this.data.index, this.data.attachmentName));
}
};
return Slot;
}());
if (false) {
/** @type {?} */
Slot.prototype.data;
/** @type {?} */
Slot.prototype.bone;
/** @type {?} */
Slot.prototype.color;
/** @type {?} */
Slot.prototype.darkColor;
/**
* @type {?}
* @private
*/
Slot.prototype.attachment;
/**
* @type {?}
* @private
*/
Slot.prototype.attachmentTime;
/** @type {?} */
Slot.prototype.deform;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var TransformConstraint = /** @class */ (function () {
function TransformConstraint(data, skeleton) {
this.rotateMix = 0;
this.translateMix = 0;
this.scaleMix = 0;
this.shearMix = 0;
this.temp = new Vector2();
this.active = false;
if (data == null)
throw new Error("data cannot be null.");
if (skeleton == null)
throw new Error("skeleton cannot be null.");
this.data = data;
this.rotateMix = data.rotateMix;
this.translateMix = data.translateMix;
this.scaleMix = data.scaleMix;
this.shearMix = data.shearMix;
this.bones = new Array();
for (var i = 0; i < data.bones.length; i++)
this.bones.push(skeleton.findBone(data.bones[i].name));
this.target = skeleton.findBone(data.target.name);
}
/**
* @return {?}
*/
TransformConstraint.prototype.isActive = /**
* @return {?}
*/
function () {
return this.active;
};
/**
* @return {?}
*/
TransformConstraint.prototype.apply = /**
* @return {?}
*/
function () {
this.update();
};
/**
* @return {?}
*/
TransformConstraint.prototype.update = /**
* @return {?}
*/
function () {
if (this.data.local) {
if (this.data.relative)
this.applyRelativeLocal();
else
this.applyAbsoluteLocal();
}
else {
if (this.data.relative)
this.applyRelativeWorld();
else
this.applyAbsoluteWorld();
}
};
/**
* @return {?}
*/
TransformConstraint.prototype.applyAbsoluteWorld = /**
* @return {?}
*/
function () {
/** @type {?} */
var rotateMix = this.rotateMix;
/** @type {?} */
var translateMix = this.translateMix;
/** @type {?} */
var scaleMix = this.scaleMix;
/** @type {?} */
var shearMix = this.shearMix;
/** @type {?} */
var target = this.target;
/** @type {?} */
var ta = target.a;
/** @type {?} */
var tb = target.b;
/** @type {?} */
var tc = target.c;
/** @type {?} */
var td = target.d;
/** @type {?} */
var degRadReflect = ta * td - tb * tc > 0 ? MathUtils.degRad : -MathUtils.degRad;
/** @type {?} */
var offsetRotation = this.data.offsetRotation * degRadReflect;
/** @type {?} */
var offsetShearY = this.data.offsetShearY * degRadReflect;
/** @type {?} */
var bones = this.bones;
for (var i = 0, n = bones.length; i < n; i++) {
/** @type {?} */
var bone = bones[i];
/** @type {?} */
var modified = false;
if (rotateMix != 0) {
/** @type {?} */
var a = bone.a;
/** @type {?} */
var b = bone.b;
/** @type {?} */
var c = bone.c;
/** @type {?} */
var d = bone.d;
/** @type {?} */
var r = Math.atan2(tc, ta) - Math.atan2(c, a) + offsetRotation;
if (r > MathUtils.PI)
r -= MathUtils.PI2;
else if (r < -MathUtils.PI)
r += MathUtils.PI2;
r *= rotateMix;
/** @type {?} */
var cos = Math.cos(r);
/** @type {?} */
var sin = Math.sin(r);
bone.a = cos * a - sin * c;
bone.b = cos * b - sin * d;
bone.c = sin * a + cos * c;
bone.d = sin * b + cos * d;
modified = true;
}
if (translateMix != 0) {
/** @type {?} */
var temp = this.temp;
target.localToWorld(temp.set(this.data.offsetX, this.data.offsetY));
bone.worldX += (temp.x - bone.worldX) * translateMix;
bone.worldY += (temp.y - bone.worldY) * translateMix;
modified = true;
}
if (scaleMix > 0) {
/** @type {?} */
var s = Math.sqrt(bone.a * bone.a + bone.c * bone.c);
/** @type {?} */
var ts = Math.sqrt(ta * ta + tc * tc);
if (s > 0.00001)
s = (s + (ts - s + this.data.offsetScaleX) * scaleMix) / s;
bone.a *= s;
bone.c *= s;
s = Math.sqrt(bone.b * bone.b + bone.d * bone.d);
ts = Math.sqrt(tb * tb + td * td);
if (s > 0.00001)
s = (s + (ts - s + this.data.offsetScaleY) * scaleMix) / s;
bone.b *= s;
bone.d *= s;
modified = true;
}
if (shearMix > 0) {
/** @type {?} */
var b = bone.b;
/** @type {?} */
var d = bone.d;
/** @type {?} */
var by = Math.atan2(d, b);
/** @type {?} */
var r = Math.atan2(td, tb) -
Math.atan2(tc, ta) -
(by - Math.atan2(bone.c, bone.a));
if (r > MathUtils.PI)
r -= MathUtils.PI2;
else if (r < -MathUtils.PI)
r += MathUtils.PI2;
r = by + (r + offsetShearY) * shearMix;
/** @type {?} */
var s = Math.sqrt(b * b + d * d);
bone.b = Math.cos(r) * s;
bone.d = Math.sin(r) * s;
modified = true;
}
if (modified)
bone.appliedValid = false;
}
};
/**
* @return {?}
*/
TransformConstraint.prototype.applyRelativeWorld = /**
* @return {?}
*/
function () {
/** @type {?} */
var rotateMix = this.rotateMix;
/** @type {?} */
var translateMix = this.translateMix;
/** @type {?} */
var scaleMix = this.scaleMix;
/** @type {?} */
var shearMix = this.shearMix;
/** @type {?} */
var target = this.target;
/** @type {?} */
var ta = target.a;
/** @type {?} */
var tb = target.b;
/** @type {?} */
var tc = target.c;
/** @type {?} */
var td = target.d;
/** @type {?} */
var degRadReflect = ta * td - tb * tc > 0 ? MathUtils.degRad : -MathUtils.degRad;
/** @type {?} */
var offsetRotation = this.data.offsetRotation * degRadReflect;
/** @type {?} */
var offsetShearY = this.data.offsetShearY * degRadReflect;
/** @type {?} */
var bones = this.bones;
for (var i = 0, n = bones.length; i < n; i++) {
/** @type {?} */
var bone = bones[i];
/** @type {?} */
var modified = false;
if (rotateMix != 0) {
/** @type {?} */
var a = bone.a;
/** @type {?} */
var b = bone.b;
/** @type {?} */
var c = bone.c;
/** @type {?} */
var d = bone.d;
/** @type {?} */
var r = Math.atan2(tc, ta) + offsetRotation;
if (r > MathUtils.PI)
r -= MathUtils.PI2;
else if (r < -MathUtils.PI)
r += MathUtils.PI2;
r *= rotateMix;
/** @type {?} */
var cos = Math.cos(r);
/** @type {?} */
var sin = Math.sin(r);
bone.a = cos * a - sin * c;
bone.b = cos * b - sin * d;
bone.c = sin * a + cos * c;
bone.d = sin * b + cos * d;
modified = true;
}
if (translateMix != 0) {
/** @type {?} */
var temp = this.temp;
target.localToWorld(temp.set(this.data.offsetX, this.data.offsetY));
bone.worldX += temp.x * translateMix;
bone.worldY += temp.y * translateMix;
modified = true;
}
if (scaleMix > 0) {
/** @type {?} */
var s = (Math.sqrt(ta * ta + tc * tc) - 1 + this.data.offsetScaleX) *
scaleMix +
1;
bone.a *= s;
bone.c *= s;
s =
(Math.sqrt(tb * tb + td * td) - 1 + this.data.offsetScaleY) *
scaleMix +
1;
bone.b *= s;
bone.d *= s;
modified = true;
}
if (shearMix > 0) {
/** @type {?} */
var r = Math.atan2(td, tb) - Math.atan2(tc, ta);
if (r > MathUtils.PI)
r -= MathUtils.PI2;
else if (r < -MathUtils.PI)
r += MathUtils.PI2;
/** @type {?} */
var b = bone.b;
/** @type {?} */
var d = bone.d;
r = Math.atan2(d, b) + (r - MathUtils.PI / 2 + offsetShearY) * shearMix;
/** @type {?} */
var s = Math.sqrt(b * b + d * d);
bone.b = Math.cos(r) * s;
bone.d = Math.sin(r) * s;
modified = true;
}
if (modified)
bone.appliedValid = false;
}
};
/**
* @return {?}
*/
TransformConstraint.prototype.applyAbsoluteLocal = /**
* @return {?}
*/
function () {
/** @type {?} */
var rotateMix = this.rotateMix;
/** @type {?} */
var translateMix = this.translateMix;
/** @type {?} */
var scaleMix = this.scaleMix;
/** @type {?} */
var shearMix = this.shearMix;
/** @type {?} */
var target = this.target;
if (!target.appliedValid)
target.updateAppliedTransform();
/** @type {?} */
var bones = this.bones;
for (var i = 0, n = bones.length; i < n; i++) {
/** @type {?} */
var bone = bones[i];
if (!bone.appliedValid)
bone.updateAppliedTransform();
/** @type {?} */
var rotation = bone.arotation;
if (rotateMix != 0) {
/** @type {?} */
var r = target.arotation - rotation + this.data.offsetRotation;
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;
rotation += r * rotateMix;
}
/** @type {?} */
var x = bone.ax;
/** @type {?} */
var y = bone.ay;
if (translateMix != 0) {
x += (target.ax - x + this.data.offsetX) * translateMix;
y += (target.ay - y + this.data.offsetY) * translateMix;
}
/** @type {?} */
var scaleX = bone.ascaleX;
/** @type {?} */
var scaleY = bone.ascaleY;
if (scaleMix != 0) {
if (scaleX > 0.00001)
scaleX =
(scaleX +
(target.ascaleX - scaleX + this.data.offsetScaleX) * scaleMix) /
scaleX;
if (scaleY > 0.00001)
scaleY =
(scaleY +
(target.ascaleY - scaleY + this.data.offsetScaleY) * scaleMix) /
scaleY;
}
/** @type {?} */
var shearY = bone.ashearY;
if (shearMix != 0) {
/** @type {?} */
var r = target.ashearY - shearY + this.data.offsetShearY;
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;
bone.shearY += r * shearMix;
}
bone.updateWorldTransformWith(x, y, rotation, scaleX, scaleY, bone.ashearX, shearY);
}
};
/**
* @return {?}
*/
TransformConstraint.prototype.applyRelativeLocal = /**
* @return {?}
*/
function () {
/** @type {?} */
var rotateMix = this.rotateMix;
/** @type {?} */
var translateMix = this.translateMix;
/** @type {?} */
var scaleMix = this.scaleMix;
/** @type {?} */
var shearMix = this.shearMix;
/** @type {?} */
var target = this.target;
if (!target.appliedValid)
target.updateAppliedTransform();
/** @type {?} */
var bones = this.bones;
for (var i = 0, n = bones.length; i < n; i++) {
/** @type {?} */
var bone = bones[i];
if (!bone.appliedValid)
bone.updateAppliedTransform();
/** @type {?} */
var rotation = bone.arotation;
if (rotateMix != 0)
rotation += (target.arotation + this.data.offsetRotation) * rotateMix;
/** @type {?} */
var x = bone.ax;
/** @type {?} */
var y = bone.ay;
if (translateMix != 0) {
x += (target.ax + this.data.offsetX) * translateMix;
y += (target.ay + this.data.offsetY) * translateMix;
}
/** @type {?} */
var scaleX = bone.ascaleX;
/** @type {?} */
var scaleY = bone.ascaleY;
if (scaleMix != 0) {
if (scaleX > 0.00001)
scaleX *=
(target.ascaleX - 1 + this.data.offsetScaleX) * scaleMix + 1;
if (scaleY > 0.00001)
scaleY *=
(target.ascaleY - 1 + this.data.offsetScaleY) * scaleMix + 1;
}
/** @type {?} */
var shearY = bone.ashearY;
if (shearMix != 0)
shearY += (target.ashearY + this.data.offsetShearY) * shearMix;
bone.updateWorldTransformWith(x, y, rotation, scaleX, scaleY, bone.ashearX, shearY);
}
};
return TransformConstraint;
}());
if (false) {
/** @type {?} */
TransformConstraint.prototype.data;
/** @type {?} */
TransformConstraint.prototype.bones;
/** @type {?} */
TransformConstraint.prototype.target;
/** @type {?} */
TransformConstraint.prototype.rotateMix;
/** @type {?} */
TransformConstraint.prototype.translateMix;
/** @type {?} */
TransformConstraint.prototype.scaleMix;
/** @type {?} */
TransformConstraint.prototype.shearMix;
/** @type {?} */
TransformConstraint.prototype.temp;
/** @type {?} */
TransformConstraint.prototype.active;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var Skeleton = /** @class */ (function () {
function Skeleton(data) {
this._updateCache = new Array();
this.updateCacheReset = new Array();
this.time = 0;
this.scaleX = 1;
this.scaleY = 1;
this.x = 0;
this.y = 0;
if (data == null)
throw new Error("data cannot be null.");
this.data = data;
this.bones = new Array();
for (var i = 0; i < data.bones.length; i++) {
/** @type {?} */
var boneData = data.bones[i];
/** @type {?} */
var bone = void 0;
if (boneData.parent == null)
bone = new Bone(boneData, this, null);
else {
/** @type {?} */
var parent_1 = this.bones[boneData.parent.index];
bone = new Bone(boneData, this, parent_1);
parent_1.children.push(bone);
}
this.bones.push(bone);
}
this.slots = new Array();
this.drawOrder = new Array();
for (var i = 0; i < data.slots.length; i++) {
/** @type {?} */
var slotData = data.slots[i];
/** @type {?} */
var bone = this.bones[slotData.boneData.index];
/** @type {?} */
var slot = new Slot(slotData, bone);
this.slots.push(slot);
this.drawOrder.push(slot);
}
this.ikConstraints = new Array();
for (var i = 0; i < data.ikConstraints.length; i++) {
/** @type {?} */
var ikConstraintData = data.ikConstraints[i];
this.ikConstraints.push(new IkConstraint(ikConstraintData, this));
}
this.transformConstraints = new Array();
for (var i = 0; i < data.transformConstraints.length; i++) {
/** @type {?} */
var transformConstraintData = data.transformConstraints[i];
this.transformConstraints.push(new TransformConstraint(transformConstraintData, this));
}
this.pathConstraints = new Array();
for (var i = 0; i < data.pathConstraints.length; i++) {
/** @type {?} */
var pathConstraintData = data.pathConstraints[i];
this.pathConstraints.push(new PathConstraint(pathConstraintData, this));
}
this.color = new Color(1, 1, 1, 1);
this.updateCache();
}
/**
* @return {?}
*/
Skeleton.prototype.updateCache = /**
* @return {?}
*/
function () {
/** @type {?} */
var updateCache = this._updateCache;
updateCache.length = 0;
this.updateCacheReset.length = 0;
/** @type {?} */
var bones = this.bones;
for (var i = 0, n = bones.length; i < n; i++) {
/** @type {?} */
var bone = bones[i];
bone.sorted = bone.data.skinRequired;
bone.active = !bone.sorted;
}
if (this.skin != null) {
/** @type {?} */
var skinBones = this.skin.bones;
for (var i = 0, n = this.skin.bones.length; i < n; i++) {
/** @type {?} */
var bone = this.bones[skinBones[i].index];
do {
bone.sorted = false;
bone.active = true;
bone = bone.parent;
} while (bone != null);
}
}
// IK first, lowest hierarchy depth first.
/** @type {?} */
var ikConstraints = this.ikConstraints;
/** @type {?} */
var transformConstraints = this.transformConstraints;
/** @type {?} */
var pathConstraints = this.pathConstraints;
/** @type {?} */
var ikCount = ikConstraints.length;
/** @type {?} */
var transformCount = transformConstraints.length;
/** @type {?} */
var pathCount = pathConstraints.length;
/** @type {?} */
var constraintCount = ikCount + transformCount + pathCount;
outer: for (var i = 0; i < constraintCount; i++) {
for (var ii = 0; ii < ikCount; ii++) {
/** @type {?} */
var constraint = ikConstraints[ii];
if (constraint.data.order == i) {
this.sortIkConstraint(constraint);
continue outer;
}
}
for (var ii = 0; ii < transformCount; ii++) {
/** @type {?} */
var constraint = transformConstraints[ii];
if (constraint.data.order == i) {
this.sortTransformConstraint(constraint);
continue outer;
}
}
for (var ii = 0; ii < pathCount; ii++) {
/** @type {?} */
var constraint = pathConstraints[ii];
if (constraint.data.order == i) {
this.sortPathConstraint(constraint);
continue outer;
}
}
}
for (var i = 0, n = bones.length; i < n; i++)
this.sortBone(bones[i]);
};
/**
* @param {?} constraint
* @return {?}
*/
Skeleton.prototype.sortIkConstraint = /**
* @param {?} constraint
* @return {?}
*/
function (constraint) {
constraint.active =
constraint.target.isActive() &&
(!constraint.data.skinRequired ||
(this.skin != null &&
Utils.contains(this.skin.constraints, constraint.data, true)));
if (!constraint.active)
return;
/** @type {?} */
var target = constraint.target;
this.sortBone(target);
/** @type {?} */
var constrained = constraint.bones;
/** @type {?} */
var parent = constrained[0];
this.sortBone(parent);
if (constrained.length > 1) {
/** @type {?} */
var child = constrained[constrained.length - 1];
if (!(this._updateCache.indexOf(child) > -1))
this.updateCacheReset.push(child);
}
this._updateCache.push(constraint);
this.sortReset(parent.children);
constrained[constrained.length - 1].sorted = true;
};
/**
* @param {?} constraint
* @return {?}
*/
Skeleton.prototype.sortPathConstraint = /**
* @param {?} constraint
* @return {?}
*/
function (constraint) {
constraint.active =
constraint.target.bone.isActive() &&
(!constraint.data.skinRequired ||
(this.skin != null &&
Utils.contains(this.skin.constraints, constraint.data, true)));
if (!constraint.active)
return;
/** @type {?} */
var slot = constraint.target;
/** @type {?} */
var slotIndex = slot.data.index;
/** @type {?} */
var slotBone = slot.bone;
if (this.skin != null)
this.sortPathConstraintAttachment(this.skin, slotIndex, slotBone);
if (this.data.defaultSkin != null && this.data.defaultSkin != this.skin)
this.sortPathConstraintAttachment(this.data.defaultSkin, slotIndex, slotBone);
for (var i = 0, n = this.data.skins.length; i < n; i++)
this.sortPathConstraintAttachment(this.data.skins[i], slotIndex, slotBone);
/** @type {?} */
var attachment = slot.getAttachment();
if (attachment instanceof PathAttachment)
this.sortPathConstraintAttachmentWith(attachment, slotBone);
/** @type {?} */
var constrained = constraint.bones;
/** @type {?} */
var boneCount = constrained.length;
for (var i = 0; i < boneCount; i++)
this.sortBone(constrained[i]);
this._updateCache.push(constraint);
for (var i = 0; i < boneCount; i++)
this.sortReset(constrained[i].children);
for (var i = 0; i < boneCount; i++)
constrained[i].sorted = true;
};
/**
* @param {?} constraint
* @return {?}
*/
Skeleton.prototype.sortTransformConstraint = /**
* @param {?} constraint
* @return {?}
*/
function (constraint) {
constraint.active =
constraint.target.isActive() &&
(!constraint.data.skinRequired ||
(this.skin != null &&
Utils.contains(this.skin.constraints, constraint.data, true)));
if (!constraint.active)
return;
this.sortBone(constraint.target);
/** @type {?} */
var constrained = constraint.bones;
/** @type {?} */
var boneCount = constrained.length;
if (constraint.data.local) {
for (var i = 0; i < boneCount; i++) {
/** @type {?} */
var child = constrained[i];
this.sortBone(child.parent);
if (!(this._updateCache.indexOf(child) > -1))
this.updateCacheReset.push(child);
}
}
else {
for (var i = 0; i < boneCount; i++) {
this.sortBone(constrained[i]);
}
}
this._updateCache.push(constraint);
for (var ii = 0; ii < boneCount; ii++)
this.sortReset(constrained[ii].children);
for (var ii = 0; ii < boneCount; ii++)
constrained[ii].sorted = true;
};
/**
* @param {?} skin
* @param {?} slotIndex
* @param {?} slotBone
* @return {?}
*/
Skeleton.prototype.sortPathConstraintAttachment = /**
* @param {?} skin
* @param {?} slotIndex
* @param {?} slotBone
* @return {?}
*/
function (skin, slotIndex, slotBone) {
/** @type {?} */
var attachments = skin.attachments[slotIndex];
if (!attachments)
return;
for (var key in attachments) {
this.sortPathConstraintAttachmentWith(attachments[key], slotBone);
}
};
/**
* @param {?} attachment
* @param {?} slotBone
* @return {?}
*/
Skeleton.prototype.sortPathConstraintAttachmentWith = /**
* @param {?} attachment
* @param {?} slotBone
* @return {?}
*/
function (attachment, slotBone) {
if (!(attachment instanceof PathAttachment))
return;
/** @type {?} */
var pathBones = ((/** @type {?} */ (attachment))).bones;
if (pathBones == null)
this.sortBone(slotBone);
else {
/** @type {?} */
var bones = this.bones;
/** @type {?} */
var i = 0;
while (i < pathBones.length) {
/** @type {?} */
var boneCount = pathBones[i++];
for (var n = i + boneCount; i < n; i++) {
/** @type {?} */
var boneIndex = pathBones[i];
this.sortBone(bones[boneIndex]);
}
}
}
};
/**
* @param {?} bone
* @return {?}
*/
Skeleton.prototype.sortBone = /**
* @param {?} bone
* @return {?}
*/
function (bone) {
if (bone.sorted)
return;
/** @type {?} */
var parent = bone.parent;
if (parent != null)
this.sortBone(parent);
bone.sorted = true;
this._updateCache.push(bone);
};
/**
* @param {?} bones
* @return {?}
*/
Skeleton.prototype.sortReset = /**
* @param {?} bones
* @return {?}
*/
function (bones) {
for (var i = 0, n = bones.length; i < n; i++) {
/** @type {?} */
var bone = bones[i];
if (!bone.active)
continue;
if (bone.sorted)
this.sortReset(bone.children);
bone.sorted = false;
}
};
/** Updates the world transform for each bone and applies constraints. */
/**
* Updates the world transform for each bone and applies constraints.
* @return {?}
*/
Skeleton.prototype.updateWorldTransform = /**
* Updates the world transform for each bone and applies constraints.
* @return {?}
*/
function () {
/** @type {?} */
var updateCacheReset = this.updateCacheReset;
for (var i = 0, n = updateCacheReset.length; i < n; i++) {
/** @type {?} */
var bone = (/** @type {?} */ (updateCacheReset[i]));
bone.ax = bone.x;
bone.ay = bone.y;
bone.arotation = bone.rotation;
bone.ascaleX = bone.scaleX;
bone.ascaleY = bone.scaleY;
bone.ashearX = bone.shearX;
bone.ashearY = bone.shearY;
bone.appliedValid = true;
}
/** @type {?} */
var updateCache = this._updateCache;
for (var i = 0, n = updateCache.length; i < n; i++)
updateCache[i].update();
};
/** Sets the bones, constraints, and slots to their setup pose values. */
/**
* Sets the bones, constraints, and slots to their setup pose values.
* @return {?}
*/
Skeleton.prototype.setToSetupPose = /**
* Sets the bones, constraints, and slots to their setup pose values.
* @return {?}
*/
function () {
this.setBonesToSetupPose();
this.setSlotsToSetupPose();
};
/** Sets the bones and constraints to their setup pose values. */
/**
* Sets the bones and constraints to their setup pose values.
* @return {?}
*/
Skeleton.prototype.setBonesToSetupPose = /**
* Sets the bones and constraints to their setup pose values.
* @return {?}
*/
function () {
/** @type {?} */
var bones = this.bones;
for (var i = 0, n = bones.length; i < n; i++)
bones[i].setToSetupPose();
/** @type {?} */
var ikConstraints = this.ikConstraints;
for (var i = 0, n = ikConstraints.length; i < n; i++) {
/** @type {?} */
var constraint = ikConstraints[i];
constraint.mix = constraint.data.mix;
constraint.softness = constraint.data.softness;
constraint.bendDirection = constraint.data.bendDirection;
constraint.compress = constraint.data.compress;
constraint.stretch = constraint.data.stretch;
}
/** @type {?} */
var transformConstraints = this.transformConstraints;
for (var i = 0, n = transformConstraints.length; i < n; i++) {
/** @type {?} */
var constraint = transformConstraints[i];
/** @type {?} */
var data = constraint.data;
constraint.rotateMix = data.rotateMix;
constraint.translateMix = data.translateMix;
constraint.scaleMix = data.scaleMix;
constraint.shearMix = data.shearMix;
}
/** @type {?} */
var pathConstraints = this.pathConstraints;
for (var i = 0, n = pathConstraints.length; i < n; i++) {
/** @type {?} */
var constraint = pathConstraints[i];
/** @type {?} */
var data = constraint.data;
constraint.position = data.position;
constraint.spacing = data.spacing;
constraint.rotateMix = data.rotateMix;
constraint.translateMix = data.translateMix;
}
};
/**
* @return {?}
*/
Skeleton.prototype.setSlotsToSetupPose = /**
* @return {?}
*/
function () {
/** @type {?} */
var slots = this.slots;
Utils.arrayCopy(slots, 0, this.drawOrder, 0, slots.length);
for (var i = 0, n = slots.length; i < n; i++)
slots[i].setToSetupPose();
};
/** @return May return null. */
/**
* @return {?} May return null.
*/
Skeleton.prototype.getRootBone = /**
* @return {?} May return null.
*/
function () {
if (this.bones.length == 0)
return null;
return this.bones[0];
};
/** @return May be null. */
/**
* @param {?} boneName
* @return {?} May be null.
*/
Skeleton.prototype.findBone = /**
* @param {?} boneName
* @return {?} May be null.
*/
function (boneName) {
if (boneName == null)
throw new Error("boneName cannot be null.");
/** @type {?} */
var bones = this.bones;
for (var i = 0, n = bones.length; i < n; i++) {
/** @type {?} */
var bone = bones[i];
if (bone.data.name == boneName)
return bone;
}
return null;
};
/** @return -1 if the bone was not found. */
/**
* @param {?} boneName
* @return {?} -1 if the bone was not found.
*/
Skeleton.prototype.findBoneIndex = /**
* @param {?} boneName
* @return {?} -1 if the bone was not found.
*/
function (boneName) {
if (boneName == null)
throw new Error("boneName cannot be null.");
/** @type {?} */
var bones = this.bones;
for (var i = 0, n = bones.length; i < n; i++)
if (bones[i].data.name == boneName)
return i;
return -1;
};
/** @return May be null. */
/**
* @param {?} slotName
* @return {?} May be null.
*/
Skeleton.prototype.findSlot = /**
* @param {?} slotName
* @return {?} May be null.
*/
function (slotName) {
if (slotName == null)
throw new Error("slotName cannot be null.");
/** @type {?} */
var slots = this.slots;
for (var i = 0, n = slots.length; i < n; i++) {
/** @type {?} */
var slot = slots[i];
if (slot.data.name == slotName)
return slot;
}
return null;
};
/** @return -1 if the bone was not found. */
/**
* @param {?} slotName
* @return {?} -1 if the bone was not found.
*/
Skeleton.prototype.findSlotIndex = /**
* @param {?} slotName
* @return {?} -1 if the bone was not found.
*/
function (slotName) {
if (slotName == null)
throw new Error("slotName cannot be null.");
/** @type {?} */
var slots = this.slots;
for (var i = 0, n = slots.length; i < n; i++)
if (slots[i].data.name == slotName)
return i;
return -1;
};
/** Sets a skin by name.
* @see #setSkin(Skin) */
/**
* Sets a skin by name.
* @see #setSkin(Skin)
* @param {?} skinName
* @return {?}
*/
Skeleton.prototype.setSkinByName = /**
* Sets a skin by name.
* @see #setSkin(Skin)
* @param {?} skinName
* @return {?}
*/
function (skinName) {
/** @type {?} */
var skin = this.data.findSkin(skinName);
if (skin == null)
throw new Error("Skin not found: " + skinName);
this.setSkin(skin);
};
/** Sets the skin used to look up attachments before looking in the {@link SkeletonData#getDefaultSkin() default skin}.
* Attachments from the new skin are attached if the corresponding attachment from the old skin was attached. If there was no
* old skin, each slot's setup mode attachment is attached from the new skin.
* @param newSkin May be null. */
/**
* Sets the skin used to look up attachments before looking in the {\@link SkeletonData#getDefaultSkin() default skin}.
* Attachments from the new skin are attached if the corresponding attachment from the old skin was attached. If there was no
* old skin, each slot's setup mode attachment is attached from the new skin.
* @param {?} newSkin May be null.
* @return {?}
*/
Skeleton.prototype.setSkin = /**
* Sets the skin used to look up attachments before looking in the {\@link SkeletonData#getDefaultSkin() default skin}.
* Attachments from the new skin are attached if the corresponding attachment from the old skin was attached. If there was no
* old skin, each slot's setup mode attachment is attached from the new skin.
* @param {?} newSkin May be null.
* @return {?}
*/
function (newSkin) {
if (newSkin == this.skin)
return;
if (newSkin != null) {
if (this.skin != null)
newSkin.attachAll(this, this.skin);
else {
/** @type {?} */
var slots = this.slots;
for (var i = 0, n = slots.length; i < n; i++) {
/** @type {?} */
var slot = slots[i];
/** @type {?} */
var name_1 = slot.data.attachmentName;
if (name_1 != null) {
/** @type {?} */
var attachment = newSkin.getAttachment(i, name_1);
if (attachment != null)
slot.setAttachment(attachment);
}
}
}
}
this.skin = newSkin;
this.updateCache();
};
/** @return May be null. */
/**
* @param {?} slotName
* @param {?} attachmentName
* @return {?} May be null.
*/
Skeleton.prototype.getAttachmentByName = /**
* @param {?} slotName
* @param {?} attachmentName
* @return {?} May be null.
*/
function (slotName, attachmentName) {
return this.getAttachment(this.data.findSlotIndex(slotName), attachmentName);
};
/** @return May be null. */
/**
* @param {?} slotIndex
* @param {?} attachmentName
* @return {?} May be null.
*/
Skeleton.prototype.getAttachment = /**
* @param {?} slotIndex
* @param {?} attachmentName
* @return {?} May be null.
*/
function (slotIndex, attachmentName) {
if (attachmentName == null)
throw new Error("attachmentName cannot be null.");
if (this.skin != null) {
/** @type {?} */
var attachment = this.skin.getAttachment(slotIndex, attachmentName);
if (attachment != null)
return attachment;
}
if (this.data.defaultSkin != null)
return this.data.defaultSkin.getAttachment(slotIndex, attachmentName);
return null;
};
/** @param attachmentName May be null. */
/**
* @param {?} slotName
* @param {?} attachmentName May be null.
* @return {?}
*/
Skeleton.prototype.setAttachment = /**
* @param {?} slotName
* @param {?} attachmentName May be null.
* @return {?}
*/
function (slotName, attachmentName) {
if (slotName == null)
throw new Error("slotName cannot be null.");
/** @type {?} */
var slots = this.slots;
for (var i = 0, n = slots.length; i < n; i++) {
/** @type {?} */
var slot = slots[i];
if (slot.data.name == slotName) {
/** @type {?} */
var attachment = null;
if (attachmentName != null) {
attachment = this.getAttachment(i, attachmentName);
if (attachment == null)
throw new Error("Attachment not found: " +
attachmentName +
", for slot: " +
slotName);
}
slot.setAttachment(attachment);
return;
}
}
throw new Error("Slot not found: " + slotName);
};
/** @return May be null. */
/**
* @param {?} constraintName
* @return {?} May be null.
*/
Skeleton.prototype.findIkConstraint = /**
* @param {?} constraintName
* @return {?} May be null.
*/
function (constraintName) {
if (constraintName == null)
throw new Error("constraintName cannot be null.");
/** @type {?} */
var ikConstraints = this.ikConstraints;
for (var i = 0, n = ikConstraints.length; i < n; i++) {
/** @type {?} */
var ikConstraint = ikConstraints[i];
if (ikConstraint.data.name == constraintName)
return ikConstraint;
}
return null;
};
/** @return May be null. */
/**
* @param {?} constraintName
* @return {?} May be null.
*/
Skeleton.prototype.findTransformConstraint = /**
* @param {?} constraintName
* @return {?} May be null.
*/
function (constraintName) {
if (constraintName == null)
throw new Error("constraintName cannot be null.");
/** @type {?} */
var transformConstraints = this.transformConstraints;
for (var i = 0, n = transformConstraints.length; i < n; i++) {
/** @type {?} */
var constraint = transformConstraints[i];
if (constraint.data.name == constraintName)
return constraint;
}
return null;
};
/** @return May be null. */
/**
* @param {?} constraintName
* @return {?} May be null.
*/
Skeleton.prototype.findPathConstraint = /**
* @param {?} constraintName
* @return {?} May be null.
*/
function (constraintName) {
if (constraintName == null)
throw new Error("constraintName cannot be null.");
/** @type {?} */
var pathConstraints = this.pathConstraints;
for (var i = 0, n = pathConstraints.length; i < n; i++) {
/** @type {?} */
var constraint = pathConstraints[i];
if (constraint.data.name == constraintName)
return constraint;
}
return null;
};
/** Returns the axis aligned bounding box (AABB) of the region and mesh attachments for the current pose.
* @param offset The distance from the skeleton origin to the bottom left corner of the AABB.
* @param size The width and height of the AABB.
* @param temp Working memory */
/**
* Returns the axis aligned bounding box (AABB) of the region and mesh attachments for the current pose.
* @param {?} offset The distance from the skeleton origin to the bottom left corner of the AABB.
* @param {?} size The width and height of the AABB.
* @param {?=} temp Working memory
* @return {?}
*/
Skeleton.prototype.getBounds = /**
* Returns the axis aligned bounding box (AABB) of the region and mesh attachments for the current pose.
* @param {?} offset The distance from the skeleton origin to the bottom left corner of the AABB.
* @param {?} size The width and height of the AABB.
* @param {?=} temp Working memory
* @return {?}
*/
function (offset, size, temp) {
if (temp === void 0) { temp = new Array(2); }
if (offset == null)
throw new Error("offset cannot be null.");
if (size == null)
throw new Error("size cannot be null.");
/** @type {?} */
var drawOrder = this.drawOrder;
/** @type {?} */
var minX = Number.POSITIVE_INFINITY;
/** @type {?} */
var minY = Number.POSITIVE_INFINITY;
/** @type {?} */
var maxX = Number.NEGATIVE_INFINITY;
/** @type {?} */
var maxY = Number.NEGATIVE_INFINITY;
for (var i = 0, n = drawOrder.length; i < n; i++) {
/** @type {?} */
var slot = drawOrder[i];
if (!slot.bone.active)
continue;
/** @type {?} */
var verticesLength = 0;
/** @type {?} */
var vertices = null;
/** @type {?} */
var attachment = slot.getAttachment();
if (attachment instanceof RegionAttachment) {
verticesLength = 8;
vertices = Utils.setArraySize(temp, verticesLength, 0);
((/** @type {?} */ (attachment))).computeWorldVertices(slot.bone, vertices, 0, 2);
}
else if (attachment instanceof MeshAttachment) {
/** @type {?} */
var mesh = (/** @type {?} */ (attachment));
verticesLength = mesh.worldVerticesLength;
vertices = Utils.setArraySize(temp, verticesLength, 0);
mesh.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2);
}
if (vertices != null) {
for (var ii = 0, nn = vertices.length; ii < nn; ii += 2) {
/** @type {?} */
var x = vertices[ii];
/** @type {?} */
var y = vertices[ii + 1];
minX = Math.min(minX, x);
minY = Math.min(minY, y);
maxX = Math.max(maxX, x);
maxY = Math.max(maxY, y);
}
}
}
offset.set(minX, minY);
size.set(maxX - minX, maxY - minY);
};
/**
* @param {?} delta
* @return {?}
*/
Skeleton.prototype.update = /**
* @param {?} delta
* @return {?}
*/
function (delta) {
this.time += delta;
};
return Skeleton;
}());
if (false) {
/** @type {?} */
Skeleton.prototype.data;
/** @type {?} */
Skeleton.prototype.bones;
/** @type {?} */
Skeleton.prototype.slots;
/** @type {?} */
Skeleton.prototype.drawOrder;
/** @type {?} */
Skeleton.prototype.ikConstraints;
/** @type {?} */
Skeleton.prototype.transformConstraints;
/** @type {?} */
Skeleton.prototype.pathConstraints;
/** @type {?} */
Skeleton.prototype._updateCache;
/** @type {?} */
Skeleton.prototype.updateCacheReset;
/** @type {?} */
Skeleton.prototype.skin;
/** @type {?} */
Skeleton.prototype.color;
/** @type {?} */
Skeleton.prototype.time;
/** @type {?} */
Skeleton.prototype.scaleX;
/** @type {?} */
Skeleton.prototype.scaleY;
/** @type {?} */
Skeleton.prototype.x;
/** @type {?} */
Skeleton.prototype.y;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/******************************************************************************
* Spine Runtimes License Agreement
* Last updated May 1, 2019. Replaces all prior versions.
*
* Copyright (c) 2013-2019, Esoteric Software LLC
*
* Integration of the Spine Runtimes into software or otherwise creating
* derivative works of the Spine Runtimes is permitted under the terms and
* conditions of Section 2 of the Spine Editor License Agreement:
* http://esotericsoftware.com/spine-editor-license
*
* Otherwise, it is permitted to integrate the Spine Runtimes into software
* or otherwise create derivative works of the Spine Runtimes (collectively,
* "Products"), provided that each user of the Products must obtain their own
* Spine Editor license and redistribution of the Products in any form must
* include this license and copyright notice.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
* INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
var SkeletonData = /** @class */ (function () {
function SkeletonData() {
this.bones = new Array(); // Ordered parents first.
// Ordered parents first.
this.slots = new Array(); // Setup pose draw order.
// Setup pose draw order.
this.skins = new Array();
this.events = new Array();
this.animations = new Array();
this.ikConstraints = new Array();
this.transformConstraints = new Array();
this.pathConstraints = new Array();
// Nonessential
this.fps = 0;
}
/**
* @param {?} boneName
* @return {?}
*/
SkeletonData.prototype.findBone = /**
* @param {?} boneName
* @return {?}
*/
function (boneName) {
if (boneName == null)
throw new Error("boneName cannot be null.");
/** @type {?} */
var bones = this.bones;
for (var i = 0, n = bones.length; i < n; i++) {
/** @type {?} */
var bone = bones[i];
if (bone.name == boneName)
return bone;
}
return null;
};
/**
* @param {?} boneName
* @return {?}
*/
SkeletonData.prototype.findBoneIndex = /**
* @param {?} boneName
* @return {?}
*/
function (boneName) {
if (boneName == null)
throw new Error("boneName cannot be null.");
/** @type {?} */
var bones = this.bones;
for (var i = 0, n = bones.length; i < n; i++)
if (bones[i].name == boneName)
return i;
return -1;
};
/**
* @param {?} slotName
* @return {?}
*/
SkeletonData.prototype.findSlot = /**
* @param {?} slotName
* @return {?}
*/
function (slotName) {
if (slotName == null)
throw new Error("slotName cannot be null.");
/** @type {?} */
var slots = this.slots;
for (var i = 0, n = slots.length; i < n; i++) {
/** @type {?} */
var slot = slots[i];
if (slot.name == slotName)
return slot;
}
return null;
};
/**
* @param {?} slotName
* @return {?}
*/
SkeletonData.prototype.findSlotIndex = /**
* @param {?} slotName
* @return {?}
*/
function (slotName) {
if (slotName == null)
throw new Error("slotName cannot be null.");
/** @type {?} */
var slots = this.slots;
for (var i = 0, n = slots.length; i < n; i++)
if (slots[i].name == slotName)
return i;
return -1;
};
/**
* @param {?} skinName
* @return {?}
*/
SkeletonData.prototype.findSkin = /**
* @param {?} skinName
* @return {?}
*/
function (skinName) {
if (skinName == null)
throw new Error("skinName cannot be null.");
/** @type {?} */
var skins = this.skins;
for (var i = 0, n = skins.length; i < n; i++) {
/** @type {?} */
var skin = skins[i];
if (skin.name == skinName)
return skin;
}
return null;
};
/**
* @param {?} eventDataName
* @return {?}
*/
SkeletonData.prototype.findEvent = /**
* @param {?} eventDataName
* @return {?}
*/
function (eventDataName) {
if (eventDataName == null)
throw new Error("eventDataName cannot be null.");
/** @type {?} */
var events = this.events;
for (var i = 0, n = events.length; i < n; i++) {
/** @type {?} */
var event_1 = events[i];
if (event_1.name == eventDataName)
return event_1;
}
return null;
};
/**
* @param {?} animationName
* @return {?}
*/
SkeletonData.prototype.findAnimation = /**
* @param {?} animationName
* @return {?}
*/
function (animationName) {
if (animationName == null)
throw new Error("animationName cannot be null.");
/** @type {?} */
var animations = this.animations;
for (var i = 0, n = animations.length; i < n; i++) {
/** @type {?} */
var animation = animations[i];
if (animation.name == animationName)
return animation;
}
return null;
};
/**
* @param {?} constraintName
* @return {?}
*/
SkeletonData.prototype.findIkConstraint = /**
* @param {?} constraintName
* @return {?}
*/
function (constraintName) {
if (constraintName == null)
throw new Error("constraintName cannot be null.");
/** @type {?} */
var ikConstraints = this.ikConstraints;
for (var i = 0, n = ikConstraints.length; i < n; i++) {
/** @type {?} */
var constraint = ikConstraints[i];
if (constraint.name == constraintName)
return constraint;
}
return null;
};
/**
* @param {?} constraintName
* @return {?}
*/
SkeletonData.prototype.findTransformConstraint = /**
* @param {?} constraintName
* @return {?}
*/
function (constraintName) {
if (constraintName == null)
throw new Error("constraintName cannot be null.");
/** @type {?} */
var transformConstraints = this.transformConstraints;
for (var i = 0, n = transformConstraints.length; i < n; i++) {
/** @type {?} */
var constraint = transformConstraints[i];
if (constraint.name == constraintName)
return constraint;
}
return null;
};
/**
* @param {?} constraintName
* @return {?}
*/
SkeletonData.prototype.findPathConstraint = /**
* @param {?} constraintName
* @return {?}
*/
function (constraintName) {
if (constraintName == null)
throw new Error("constraintName cannot be null.");
/** @type {?} */
var pathConstraints = this.pathConstraints;
for (var i = 0, n = pathConstraints.length; i < n; i++) {
/** @type {?} */
var constraint = pathConstraints[i];
if (constraint.name == constraintName)
return constraint;
}
return null;
};
/**
* @param {?} pathConstraintName
* @return {?}
*/
SkeletonData.prototype.findPathConstraintIndex = /**
* @param {?} pathConstraintName
* @return {?}
*/
function (pathConstraintName) {
if (pathConstraintName == null)
throw new Error("pathConstraintName cannot be null.");
/** @type {?} */
var pathConstraints = this.pathConstraints;
for (var i = 0, n = pathConstraints.length; i < n; i++)
if (pathConstraints[i].name == pathConstraintName)
return i;
return -1;
};
return SkeletonData;
}());
if (false) {
/** @type {?} */
SkeletonData.prototype.name;
/** @type {?} */
SkeletonData.prototype.bones;
/** @type {?} */
SkeletonData.prototype.slots;
/** @type {?} */
SkeletonData.prototype.skins;
/** @type {?} */
SkeletonData.prototype.defaultSkin;
/** @type {?} */
SkeletonData.prototype.events;
/** @type {?} */
SkeletonData.prototype.animations;
/** @type {?} */
SkeletonData.prototype.ikConstraints;
/** @type {?} */
SkeletonData.prototype.transformConstraints;
/** @type {?} */
SkeletonData.prototype.pathConstraints;
/** @type {?} */
SkeletonData.prototype.x;
/** @type {?} */
SkeletonData.prototype.y;
/** @type {?} */
SkeletonData.prototype.width;
/** @type {?} */
SkeletonData.prototype.height;
/** @type {?} */
SkeletonData.prototype.version;
/** @type {?} */
SkeletonData.prototype.hash;
/** @type {?} */
SkeletonData.prototype.fps;
/** @type {?} */
SkeletonData.prototype.imagesPath;
/** @type {?} */
SkeletonData.prototype.audioPath;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var SlotData = /** @class */ (function () {
function SlotData(index, name, boneData) {
this.color = new Color(1, 1, 1, 1);
if (index < 0)
throw new Error("index must be >= 0.");
if (name == null)
throw new Error("name cannot be null.");
if (boneData == null)
throw new Error("boneData cannot be null.");
this.index = index;
this.name = name;
this.boneData = boneData;
}
return SlotData;
}());
if (false) {
/** @type {?} */
SlotData.prototype.index;
/** @type {?} */
SlotData.prototype.name;
/** @type {?} */
SlotData.prototype.boneData;
/** @type {?} */
SlotData.prototype.color;
/** @type {?} */
SlotData.prototype.darkColor;
/** @type {?} */
SlotData.prototype.attachmentName;
/** @type {?} */
SlotData.prototype.blendMode;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var SkinEntry = /** @class */ (function () {
function SkinEntry(slotIndex, name, attachment) {
this.slotIndex = slotIndex;
this.name = name;
this.attachment = attachment;
}
return SkinEntry;
}());
if (false) {
/** @type {?} */
SkinEntry.prototype.slotIndex;
/** @type {?} */
SkinEntry.prototype.name;
/** @type {?} */
SkinEntry.prototype.attachment;
}
var Skin = /** @class */ (function () {
function Skin(name) {
this.attachments = new Array();
this.bones = Array();
this.constraints = new Array();
if (name == null)
throw new Error("name cannot be null.");
this.name = name;
}
/**
* @param {?} slotIndex
* @param {?} name
* @param {?} attachment
* @return {?}
*/
Skin.prototype.setAttachment = /**
* @param {?} slotIndex
* @param {?} name
* @param {?} attachment
* @return {?}
*/
function (slotIndex, name, attachment) {
if (attachment == null)
throw new Error("attachment cannot be null.");
/** @type {?} */
var attachments = this.attachments;
if (slotIndex >= attachments.length)
attachments.length = slotIndex + 1;
if (!attachments[slotIndex])
attachments[slotIndex] = {};
attachments[slotIndex][name] = attachment;
};
/**
* @param {?} skin
* @return {?}
*/
Skin.prototype.addSkin = /**
* @param {?} skin
* @return {?}
*/
function (skin) {
for (var i = 0; i < skin.bones.length; i++) {
/** @type {?} */
var bone = skin.bones[i];
/** @type {?} */
var contained = false;
for (var j = 0; j < this.bones.length; j++) {
if (this.bones[j] == bone) {
contained = true;
break;
}
}
if (!contained)
this.bones.push(bone);
}
for (var i = 0; i < skin.constraints.length; i++) {
/** @type {?} */
var constraint = skin.constraints[i];
/** @type {?} */
var contained = false;
for (var j = 0; j < this.constraints.length; j++) {
if (this.constraints[j] == constraint) {
contained = true;
break;
}
}
if (!contained)
this.constraints.push(constraint);
}
/** @type {?} */
var attachments = skin.getAttachments();
for (var i = 0; i < attachments.length; i++) {
/** @type {?} */
var attachment = attachments[i];
this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
}
};
/**
* @param {?} skin
* @return {?}
*/
Skin.prototype.copySkin = /**
* @param {?} skin
* @return {?}
*/
function (skin) {
for (var i = 0; i < skin.bones.length; i++) {
/** @type {?} */
var bone = skin.bones[i];
/** @type {?} */
var contained = false;
for (var j = 0; j < this.bones.length; j++) {
if (this.bones[j] == bone) {
contained = true;
break;
}
}
if (!contained)
this.bones.push(bone);
}
for (var i = 0; i < skin.constraints.length; i++) {
/** @type {?} */
var constraint = skin.constraints[i];
/** @type {?} */
var contained = false;
for (var j = 0; j < this.constraints.length; j++) {
if (this.constraints[j] == constraint) {
contained = true;
break;
}
}
if (!contained)
this.constraints.push(constraint);
}
/** @type {?} */
var attachments = skin.getAttachments();
for (var i = 0; i < attachments.length; i++) {
/** @type {?} */
var attachment = attachments[i];
if (attachment.attachment == null)
continue;
if (attachment.attachment instanceof MeshAttachment) {
attachment.attachment = attachment.attachment.newLinkedMesh();
this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
}
else {
attachment.attachment = attachment.attachment.copy();
this.setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
}
}
};
/** @return May be null. */
/**
* @param {?} slotIndex
* @param {?} name
* @return {?} May be null.
*/
Skin.prototype.getAttachment = /**
* @param {?} slotIndex
* @param {?} name
* @return {?} May be null.
*/
function (slotIndex, name) {
/** @type {?} */
var dictionary = this.attachments[slotIndex];
return dictionary ? dictionary[name] : null;
};
/**
* @param {?} slotIndex
* @param {?} name
* @return {?}
*/
Skin.prototype.removeAttachment = /**
* @param {?} slotIndex
* @param {?} name
* @return {?}
*/
function (slotIndex, name) {
/** @type {?} */
var dictionary = this.attachments[slotIndex];
if (dictionary)
dictionary[name] = null;
};
/**
* @return {?}
*/
Skin.prototype.getAttachments = /**
* @return {?}
*/
function () {
/** @type {?} */
var entries = new Array();
for (var i = 0; i < this.attachments.length; i++) {
/** @type {?} */
var slotAttachments = this.attachments[i];
if (slotAttachments) {
for (var name_1 in slotAttachments) {
/** @type {?} */
var attachment = slotAttachments[name_1];
if (attachment)
entries.push(new SkinEntry(i, name_1, attachment));
}
}
}
return entries;
};
/**
* @param {?} slotIndex
* @param {?} attachments
* @return {?}
*/
Skin.prototype.getAttachmentsForSlot = /**
* @param {?} slotIndex
* @param {?} attachments
* @return {?}
*/
function (slotIndex, attachments) {
/** @type {?} */
var slotAttachments = this.attachments[slotIndex];
if (slotAttachments) {
for (var name_2 in slotAttachments) {
/** @type {?} */
var attachment = slotAttachments[name_2];
if (attachment)
attachments.push(new SkinEntry(slotIndex, name_2, attachment));
}
}
};
/**
* @return {?}
*/
Skin.prototype.clear = /**
* @return {?}
*/
function () {
this.attachments.length = 0;
this.bones.length = 0;
this.constraints.length = 0;
};
/** Attach each attachment in this skin if the corresponding attachment in the old skin is currently attached. */
/**
* Attach each attachment in this skin if the corresponding attachment in the old skin is currently attached.
* @param {?} skeleton
* @param {?} oldSkin
* @return {?}
*/
Skin.prototype.attachAll = /**
* Attach each attachment in this skin if the corresponding attachment in the old skin is currently attached.
* @param {?} skeleton
* @param {?} oldSkin
* @return {?}
*/
function (skeleton, oldSkin) {
/** @type {?} */
var slotIndex = 0;
for (var i = 0; i < skeleton.slots.length; i++) {
/** @type {?} */
var slot = skeleton.slots[i];
/** @type {?} */
var slotAttachment = slot.getAttachment();
if (slotAttachment && slotIndex < oldSkin.attachments.length) {
/** @type {?} */
var dictionary = oldSkin.attachments[slotIndex];
for (var key in dictionary) {
/** @type {?} */
var skinAttachment = dictionary[key];
if (slotAttachment == skinAttachment) {
/** @type {?} */
var attachment = this.getAttachment(slotIndex, key);
if (attachment != null)
slot.setAttachment(attachment);
break;
}
}
}
slotIndex++;
}
};
return Skin;
}());
if (false) {
/** @type {?} */
Skin.prototype.name;
/** @type {?} */
Skin.prototype.attachments;
/** @type {?} */
Skin.prototype.bones;
/** @type {?} */
Skin.prototype.constraints;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var TransformConstraintData = /** @class */ (function (_super) {
__extends(TransformConstraintData, _super);
function TransformConstraintData(name) {
var _this = _super.call(this, name, 0, false) || this;
_this.bones = new Array();
_this.rotateMix = 0;
_this.translateMix = 0;
_this.scaleMix = 0;
_this.shearMix = 0;
_this.offsetRotation = 0;
_this.offsetX = 0;
_this.offsetY = 0;
_this.offsetScaleX = 0;
_this.offsetScaleY = 0;
_this.offsetShearY = 0;
_this.relative = false;
_this.local = false;
return _this;
}
return TransformConstraintData;
}(ConstraintData));
if (false) {
/** @type {?} */
TransformConstraintData.prototype.bones;
/** @type {?} */
TransformConstraintData.prototype.target;
/** @type {?} */
TransformConstraintData.prototype.rotateMix;
/** @type {?} */
TransformConstraintData.prototype.translateMix;
/** @type {?} */
TransformConstraintData.prototype.scaleMix;
/** @type {?} */
TransformConstraintData.prototype.shearMix;
/** @type {?} */
TransformConstraintData.prototype.offsetRotation;
/** @type {?} */
TransformConstraintData.prototype.offsetX;
/** @type {?} */
TransformConstraintData.prototype.offsetY;
/** @type {?} */
TransformConstraintData.prototype.offsetScaleX;
/** @type {?} */
TransformConstraintData.prototype.offsetScaleY;
/** @type {?} */
TransformConstraintData.prototype.offsetShearY;
/** @type {?} */
TransformConstraintData.prototype.relative;
/** @type {?} */
TransformConstraintData.prototype.local;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/******************************************************************************
* Spine Runtimes License Agreement
* Last updated May 1, 2019. Replaces all prior versions.
*
* Copyright (c) 2013-2019, Esoteric Software LLC
*
* Integration of the Spine Runtimes into software or otherwise creating
* derivative works of the Spine Runtimes is permitted under the terms and
* conditions of Section 2 of the Spine Editor License Agreement:
* http://esotericsoftware.com/spine-editor-license
*
* Otherwise, it is permitted to integrate the Spine Runtimes into software
* or otherwise create derivative works of the Spine Runtimes (collectively,
* "Products"), provided that each user of the Products must obtain their own
* Spine Editor license and redistribution of the Products in any form must
* include this license and copyright notice.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
* INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
/** @enum {number} */
var AttachmentType = {
Region: 0,
BoundingBox: 1,
Mesh: 2,
LinkedMesh: 3,
Path: 4,
Point: 5,
Clipping: 6,
};
AttachmentType[AttachmentType.Region] = 'Region';
AttachmentType[AttachmentType.BoundingBox] = 'BoundingBox';
AttachmentType[AttachmentType.Mesh] = 'Mesh';
AttachmentType[AttachmentType.LinkedMesh] = 'LinkedMesh';
AttachmentType[AttachmentType.Path] = 'Path';
AttachmentType[AttachmentType.Point] = 'Point';
AttachmentType[AttachmentType.Clipping] = 'Clipping';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var SkeletonBinary = /** @class */ (function () {
function SkeletonBinary(attachmentLoader) {
this.scale = 1;
this.linkedMeshes = new Array();
this.attachmentLoader = attachmentLoader;
}
/**
* @param {?} binary
* @return {?}
*/
SkeletonBinary.prototype.readSkeletonData = /**
* @param {?} binary
* @return {?}
*/
function (binary) {
/** @type {?} */
var scale = this.scale;
/** @type {?} */
var input = new BinaryInput(binary);
/** @type {?} */
var hash = input.readString();
/** @type {?} */
var version = input.readString();
if (version.startsWith("3.6")) {
return new SkeletonBinary36(this.attachmentLoader).readSkeletonData(binary);
}
else if (version.startsWith("3.7")) {
return new SkeletonBinary37(this.attachmentLoader).readSkeletonData(binary);
}
/** @type {?} */
var skeletonData = new SkeletonData();
skeletonData.name = ""; // BOZO
skeletonData.hash = hash;
skeletonData.version = version;
skeletonData.x = input.readFloat();
skeletonData.y = input.readFloat();
skeletonData.width = input.readFloat();
skeletonData.height = input.readFloat();
/** @type {?} */
var nonessential = input.readBoolean();
if (nonessential) {
skeletonData.fps = input.readFloat();
skeletonData.imagesPath = input.readString();
skeletonData.audioPath = input.readString();
}
/** @type {?} */
var n = 0;
// Strings.
n = input.readInt(true);
for (var i = 0; i < n; i++)
input.strings.push(input.readString());
// Bones.
n = input.readInt(true);
for (var i = 0; i < n; i++) {
/** @type {?} */
var name_1 = input.readString();
/** @type {?} */
var parent_1 = i == 0 ? null : skeletonData.bones[input.readInt(true)];
/** @type {?} */
var data = new BoneData(i, name_1, parent_1);
data.rotation = input.readFloat();
data.x = input.readFloat() * scale;
data.y = input.readFloat() * scale;
data.scaleX = input.readFloat();
data.scaleY = input.readFloat();
data.shearX = input.readFloat();
data.shearY = input.readFloat();
data.length = input.readFloat() * scale;
data.transformMode =
SkeletonBinary.TransformModeValues[input.readInt(true)];
data.skinRequired = input.readBoolean();
if (nonessential)
Color.rgba8888ToColor(data.color, input.readInt32());
skeletonData.bones.push(data);
}
// Slots.
n = input.readInt(true);
for (var i = 0; i < n; i++) {
/** @type {?} */
var slotName = input.readString();
/** @type {?} */
var boneData = skeletonData.bones[input.readInt(true)];
/** @type {?} */
var data = new SlotData(i, slotName, boneData);
Color.rgba8888ToColor(data.color, input.readInt32());
/** @type {?} */
var darkColor = input.readInt32();
if (darkColor != -1)
Color.rgb888ToColor((data.darkColor = new Color()), darkColor);
data.attachmentName = input.readStringRef();
data.blendMode = SkeletonBinary.BlendModeValues[input.readInt(true)];
skeletonData.slots.push(data);
}
// IK constraints.
n = input.readInt(true);
for (var i = 0, nn = void 0; i < n; i++) {
/** @type {?} */
var data = new IkConstraintData(input.readString());
data.order = input.readInt(true);
data.skinRequired = input.readBoolean();
nn = input.readInt(true);
for (var ii = 0; ii < nn; ii++)
data.bones.push(skeletonData.bones[input.readInt(true)]);
data.target = skeletonData.bones[input.readInt(true)];
data.mix = input.readFloat();
data.softness = input.readFloat() * scale;
data.bendDirection = input.readByte();
data.compress = input.readBoolean();
data.stretch = input.readBoolean();
data.uniform = input.readBoolean();
skeletonData.ikConstraints.push(data);
}
// Transform constraints.
n = input.readInt(true);
for (var i = 0, nn = void 0; i < n; i++) {
/** @type {?} */
var data = new TransformConstraintData(input.readString());
data.order = input.readInt(true);
data.skinRequired = input.readBoolean();
nn = input.readInt(true);
for (var ii = 0; ii < nn; ii++)
data.bones.push(skeletonData.bones[input.readInt(true)]);
data.target = skeletonData.bones[input.readInt(true)];
data.local = input.readBoolean();
data.relative = input.readBoolean();
data.offsetRotation = input.readFloat();
data.offsetX = input.readFloat() * scale;
data.offsetY = input.readFloat() * scale;
data.offsetScaleX = input.readFloat();
data.offsetScaleY = input.readFloat();
data.offsetShearY = input.readFloat();
data.rotateMix = input.readFloat();
data.translateMix = input.readFloat();
data.scaleMix = input.readFloat();
data.shearMix = input.readFloat();
skeletonData.transformConstraints.push(data);
}
// Path constraints.
n = input.readInt(true);
for (var i = 0, nn = void 0; i < n; i++) {
/** @type {?} */
var data = new PathConstraintData(input.readString());
data.order = input.readInt(true);
data.skinRequired = input.readBoolean();
nn = input.readInt(true);
for (var ii = 0; ii < nn; ii++)
data.bones.push(skeletonData.bones[input.readInt(true)]);
data.target = skeletonData.slots[input.readInt(true)];
data.positionMode =
SkeletonBinary.PositionModeValues[input.readInt(true)];
data.spacingMode = SkeletonBinary.SpacingModeValues[input.readInt(true)];
data.rotateMode = SkeletonBinary.RotateModeValues[input.readInt(true)];
data.offsetRotation = input.readFloat();
data.position = input.readFloat();
if (data.positionMode == PositionMode.Fixed)
data.position *= scale;
data.spacing = input.readFloat();
if (data.spacingMode == SpacingMode.Length ||
data.spacingMode == SpacingMode.Fixed)
data.spacing *= scale;
data.rotateMix = input.readFloat();
data.translateMix = input.readFloat();
skeletonData.pathConstraints.push(data);
}
// Default skin.
/** @type {?} */
var defaultSkin = this.readSkin(input, skeletonData, true, nonessential);
if (defaultSkin != null) {
skeletonData.defaultSkin = defaultSkin;
skeletonData.skins.push(defaultSkin);
}
// Skins.
{
/** @type {?} */
var i = skeletonData.skins.length;
Utils.setArraySize(skeletonData.skins, (n = i + input.readInt(true)));
for (; i < n; i++)
skeletonData.skins[i] = this.readSkin(input, skeletonData, false, nonessential);
}
// Linked meshes.
n = this.linkedMeshes.length;
for (var i = 0; i < n; i++) {
/** @type {?} */
var linkedMesh = this.linkedMeshes[i];
/** @type {?} */
var skin = linkedMesh.skin == null
? skeletonData.defaultSkin
: skeletonData.findSkin(linkedMesh.skin);
if (skin == null)
throw new Error("Skin not found: " + linkedMesh.skin);
/** @type {?} */
var parent_2 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
if (parent_2 == null)
throw new Error("Parent mesh not found: " + linkedMesh.parent);
linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform
? ((/** @type {?} */ (parent_2)))
: linkedMesh.mesh;
linkedMesh.mesh.setParentMesh((/** @type {?} */ (parent_2)));
linkedMesh.mesh.updateUVs();
}
this.linkedMeshes.length = 0;
// Events.
n = input.readInt(true);
for (var i = 0; i < n; i++) {
/** @type {?} */
var data = new EventData(input.readStringRef());
data.intValue = input.readInt(false);
data.floatValue = input.readFloat();
data.stringValue = input.readString();
data.audioPath = input.readString();
if (data.audioPath != null) {
data.volume = input.readFloat();
data.balance = input.readFloat();
}
skeletonData.events.push(data);
}
// Animations.
n = input.readInt(true);
for (var i = 0; i < n; i++)
skeletonData.animations.push(this.readAnimation(input, input.readString(), skeletonData));
return skeletonData;
};
/**
* @protected
* @param {?} input
* @param {?} skeletonData
* @param {?} defaultSkin
* @param {?} nonessential
* @return {?}
*/
SkeletonBinary.prototype.readSkin = /**
* @protected
* @param {?} input
* @param {?} skeletonData
* @param {?} defaultSkin
* @param {?} nonessential
* @return {?}
*/
function (input, skeletonData, defaultSkin, nonessential) {
/** @type {?} */
var skin = null;
/** @type {?} */
var slotCount = 0;
if (defaultSkin) {
slotCount = input.readInt(true);
if (slotCount == 0)
return null;
skin = new Skin("default");
}
else {
skin = new Skin(input.readStringRef());
skin.bones.length = input.readInt(true);
for (var i = 0, n = skin.bones.length; i < n; i++)
skin.bones[i] = skeletonData.bones[input.readInt(true)];
for (var i = 0, n = input.readInt(true); i < n; i++)
skin.constraints.push(skeletonData.ikConstraints[input.readInt(true)]);
for (var i = 0, n = input.readInt(true); i < n; i++)
skin.constraints.push(skeletonData.transformConstraints[input.readInt(true)]);
for (var i = 0, n = input.readInt(true); i < n; i++)
skin.constraints.push(skeletonData.pathConstraints[input.readInt(true)]);
slotCount = input.readInt(true);
}
for (var i = 0; i < slotCount; i++) {
/** @type {?} */
var slotIndex = input.readInt(true);
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
/** @type {?} */
var name_2 = input.readStringRef();
/** @type {?} */
var attachment = this.readAttachment(input, skeletonData, skin, slotIndex, name_2, nonessential);
if (attachment != null)
skin.setAttachment(slotIndex, name_2, attachment);
}
}
return skin;
};
/**
* @protected
* @param {?} input
* @param {?} skeletonData
* @param {?} skin
* @param {?} slotIndex
* @param {?} attachmentName
* @param {?} nonessential
* @return {?}
*/
SkeletonBinary.prototype.readAttachment = /**
* @protected
* @param {?} input
* @param {?} skeletonData
* @param {?} skin
* @param {?} slotIndex
* @param {?} attachmentName
* @param {?} nonessential
* @return {?}
*/
function (input, skeletonData, skin, slotIndex, attachmentName, nonessential) {
/** @type {?} */
var scale = this.scale;
/** @type {?} */
var name = input.readStringRef();
if (name == null)
name = attachmentName;
/** @type {?} */
var typeIndex = input.readByte();
/** @type {?} */
var type = SkeletonBinary.AttachmentTypeValues[typeIndex];
switch (type) {
case AttachmentType.Region: {
/** @type {?} */
var path = input.readStringRef();
/** @type {?} */
var rotation = input.readFloat();
/** @type {?} */
var x = input.readFloat();
/** @type {?} */
var y = input.readFloat();
/** @type {?} */
var scaleX = input.readFloat();
/** @type {?} */
var scaleY = input.readFloat();
/** @type {?} */
var width = input.readFloat();
/** @type {?} */
var height = input.readFloat();
/** @type {?} */
var color = input.readInt32();
if (path == null)
path = name;
/** @type {?} */
var region = this.attachmentLoader.newRegionAttachment(skin, name, path);
if (region == null)
return null;
region.path = path;
region.x = x * scale;
region.y = y * scale;
region.scaleX = scaleX;
region.scaleY = scaleY;
region.rotation = rotation;
region.width = width * scale;
region.height = height * scale;
Color.rgba8888ToColor(region.color, color);
region.updateOffset();
return region;
}
case AttachmentType.BoundingBox: {
/** @type {?} */
var vertexCount = input.readInt(true);
/** @type {?} */
var vertices = this.readVertices(input, vertexCount);
/** @type {?} */
var color = nonessential ? input.readInt32() : 0;
/** @type {?} */
var box = this.attachmentLoader.newBoundingBoxAttachment(skin, name);
if (box == null)
return null;
box.worldVerticesLength = vertexCount << 1;
box.vertices = vertices.vertices;
box.bones = vertices.bones;
if (nonessential)
Color.rgba8888ToColor(box.color, color);
return box;
}
case AttachmentType.Mesh: {
/** @type {?} */
var path = input.readStringRef();
/** @type {?} */
var color = input.readInt32();
/** @type {?} */
var vertexCount = input.readInt(true);
/** @type {?} */
var uvs = this.readFloatArray(input, vertexCount << 1, 1);
/** @type {?} */
var triangles = this.readShortArray(input);
/** @type {?} */
var vertices = this.readVertices(input, vertexCount);
/** @type {?} */
var hullLength = input.readInt(true);
/** @type {?} */
var edges = null;
/** @type {?} */
var width = 0;
/** @type {?} */
var height = 0;
if (nonessential) {
edges = this.readShortArray(input);
width = input.readFloat();
height = input.readFloat();
}
if (path == null)
path = name;
/** @type {?} */
var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path);
if (mesh == null)
return null;
mesh.path = path;
Color.rgba8888ToColor(mesh.color, color);
mesh.bones = vertices.bones;
mesh.vertices = vertices.vertices;
mesh.worldVerticesLength = vertexCount << 1;
mesh.triangles = triangles;
mesh.regionUVs = uvs;
mesh.updateUVs();
mesh.hullLength = hullLength << 1;
if (nonessential) {
mesh.edges = edges;
mesh.width = width * scale;
mesh.height = height * scale;
}
return mesh;
}
case AttachmentType.LinkedMesh: {
/** @type {?} */
var path = input.readStringRef();
/** @type {?} */
var color = input.readInt32();
/** @type {?} */
var skinName = input.readStringRef();
/** @type {?} */
var parent_3 = input.readStringRef();
/** @type {?} */
var inheritDeform = input.readBoolean();
/** @type {?} */
var width = 0;
/** @type {?} */
var height = 0;
if (nonessential) {
width = input.readFloat();
height = input.readFloat();
}
if (path == null)
path = name;
/** @type {?} */
var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path);
if (mesh == null)
return null;
mesh.path = path;
Color.rgba8888ToColor(mesh.color, color);
if (nonessential) {
mesh.width = width * scale;
mesh.height = height * scale;
}
this.linkedMeshes.push(new LinkedMesh(mesh, skinName, slotIndex, parent_3, inheritDeform));
return mesh;
}
case AttachmentType.Path: {
/** @type {?} */
var closed_1 = input.readBoolean();
/** @type {?} */
var constantSpeed = input.readBoolean();
/** @type {?} */
var vertexCount = input.readInt(true);
/** @type {?} */
var vertices = this.readVertices(input, vertexCount);
/** @type {?} */
var lengths = Utils.newArray(vertexCount / 3, 0);
for (var i = 0, n = lengths.length; i < n; i++)
lengths[i] = input.readFloat() * scale;
/** @type {?} */
var color = nonessential ? input.readInt32() : 0;
/** @type {?} */
var path = this.attachmentLoader.newPathAttachment(skin, name);
if (path == null)
return null;
path.closed = closed_1;
path.constantSpeed = constantSpeed;
path.worldVerticesLength = vertexCount << 1;
path.vertices = vertices.vertices;
path.bones = vertices.bones;
path.lengths = lengths;
if (nonessential)
Color.rgba8888ToColor(path.color, color);
return path;
}
case AttachmentType.Point: {
/** @type {?} */
var rotation = input.readFloat();
/** @type {?} */
var x = input.readFloat();
/** @type {?} */
var y = input.readFloat();
/** @type {?} */
var color = nonessential ? input.readInt32() : 0;
/** @type {?} */
var point = this.attachmentLoader.newPointAttachment(skin, name);
if (point == null)
return null;
point.x = x * scale;
point.y = y * scale;
point.rotation = rotation;
if (nonessential)
Color.rgba8888ToColor(point.color, color);
return point;
}
case AttachmentType.Clipping: {
/** @type {?} */
var endSlotIndex = input.readInt(true);
/** @type {?} */
var vertexCount = input.readInt(true);
/** @type {?} */
var vertices = this.readVertices(input, vertexCount);
/** @type {?} */
var color = nonessential ? input.readInt32() : 0;
/** @type {?} */
var clip = this.attachmentLoader.newClippingAttachment(skin, name);
if (clip == null)
return null;
clip.endSlot = skeletonData.slots[endSlotIndex];
clip.worldVerticesLength = vertexCount << 1;
clip.vertices = vertices.vertices;
clip.bones = vertices.bones;
if (nonessential)
Color.rgba8888ToColor(clip.color, color);
return clip;
}
}
return null;
};
/**
* @protected
* @param {?} input
* @param {?} vertexCount
* @return {?}
*/
SkeletonBinary.prototype.readVertices = /**
* @protected
* @param {?} input
* @param {?} vertexCount
* @return {?}
*/
function (input, vertexCount) {
/** @type {?} */
var verticesLength = vertexCount << 1;
/** @type {?} */
var vertices = new Vertices();
/** @type {?} */
var scale = this.scale;
if (!input.readBoolean()) {
vertices.vertices = this.readFloatArray(input, verticesLength, scale);
return vertices;
}
/** @type {?} */
var weights = new Array();
/** @type {?} */
var bonesArray = new Array();
for (var i = 0; i < vertexCount; i++) {
/** @type {?} */
var boneCount = input.readInt(true);
bonesArray.push(boneCount);
for (var ii = 0; ii < boneCount; ii++) {
bonesArray.push(input.readInt(true));
weights.push(input.readFloat() * scale);
weights.push(input.readFloat() * scale);
weights.push(input.readFloat());
}
}
vertices.vertices = Utils.toFloatArray(weights);
vertices.bones = bonesArray;
return vertices;
};
/**
* @protected
* @param {?} input
* @param {?} n
* @param {?} scale
* @return {?}
*/
SkeletonBinary.prototype.readFloatArray = /**
* @protected
* @param {?} input
* @param {?} n
* @param {?} scale
* @return {?}
*/
function (input, n, scale) {
/** @type {?} */
var array = new Array(n);
if (scale == 1) {
for (var i = 0; i < n; i++)
array[i] = input.readFloat();
}
else {
for (var i = 0; i < n; i++)
array[i] = input.readFloat() * scale;
}
return array;
};
/**
* @protected
* @param {?} input
* @return {?}
*/
SkeletonBinary.prototype.readShortArray = /**
* @protected
* @param {?} input
* @return {?}
*/
function (input) {
/** @type {?} */
var n = input.readInt(true);
/** @type {?} */
var array = new Array(n);
for (var i = 0; i < n; i++)
array[i] = input.readShort();
return array;
};
/**
* @protected
* @param {?} input
* @param {?} name
* @param {?} skeletonData
* @return {?}
*/
SkeletonBinary.prototype.readAnimation = /**
* @protected
* @param {?} input
* @param {?} name
* @param {?} skeletonData
* @return {?}
*/
function (input, name, skeletonData) {
/** @type {?} */
var timelines = new Array();
/** @type {?} */
var scale = this.scale;
/** @type {?} */
var duration = 0;
/** @type {?} */
var tempColor1 = new Color();
/** @type {?} */
var tempColor2 = new Color();
// Slot timelines.
for (var i = 0, n = input.readInt(true); i < n; i++) {
/** @type {?} */
var slotIndex = input.readInt(true);
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
/** @type {?} */
var timelineType = input.readByte();
/** @type {?} */
var frameCount = input.readInt(true);
switch (timelineType) {
case SkeletonBinary.SLOT_ATTACHMENT: {
/** @type {?} */
var timeline = new AttachmentTimeline(frameCount);
timeline.slotIndex = slotIndex;
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++)
timeline.setFrame(frameIndex, input.readFloat(), input.readStringRef());
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[frameCount - 1]);
break;
}
case SkeletonBinary.SLOT_COLOR: {
/** @type {?} */
var timeline = new ColorTimeline(frameCount);
timeline.slotIndex = slotIndex;
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
/** @type {?} */
var time = input.readFloat();
Color.rgba8888ToColor(tempColor1, input.readInt32());
timeline.setFrame(frameIndex, time, tempColor1.r, tempColor1.g, tempColor1.b, tempColor1.a);
if (frameIndex < frameCount - 1)
this.readCurve(input, frameIndex, timeline);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(frameCount - 1) * ColorTimeline.ENTRIES]);
break;
}
case SkeletonBinary.SLOT_TWO_COLOR: {
/** @type {?} */
var timeline = new TwoColorTimeline(frameCount);
timeline.slotIndex = slotIndex;
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
/** @type {?} */
var time = input.readFloat();
Color.rgba8888ToColor(tempColor1, input.readInt32());
Color.rgb888ToColor(tempColor2, input.readInt32());
timeline.setFrame(frameIndex, time, tempColor1.r, tempColor1.g, tempColor1.b, tempColor1.a, tempColor2.r, tempColor2.g, tempColor2.b);
if (frameIndex < frameCount - 1)
this.readCurve(input, frameIndex, timeline);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(frameCount - 1) * TwoColorTimeline.ENTRIES]);
break;
}
}
}
}
// Bone timelines.
for (var i = 0, n = input.readInt(true); i < n; i++) {
/** @type {?} */
var boneIndex = input.readInt(true);
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
/** @type {?} */
var timelineType = input.readByte();
/** @type {?} */
var frameCount = input.readInt(true);
switch (timelineType) {
case SkeletonBinary.BONE_ROTATE: {
/** @type {?} */
var timeline = new RotateTimeline(frameCount);
timeline.boneIndex = boneIndex;
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat());
if (frameIndex < frameCount - 1)
this.readCurve(input, frameIndex, timeline);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(frameCount - 1) * RotateTimeline.ENTRIES]);
break;
}
case SkeletonBinary.BONE_TRANSLATE:
case SkeletonBinary.BONE_SCALE:
case SkeletonBinary.BONE_SHEAR: {
/** @type {?} */
var timeline = void 0;
/** @type {?} */
var timelineScale = 1;
if (timelineType == SkeletonBinary.BONE_SCALE)
timeline = new ScaleTimeline(frameCount);
else if (timelineType == SkeletonBinary.BONE_SHEAR)
timeline = new ShearTimeline(frameCount);
else {
timeline = new TranslateTimeline(frameCount);
timelineScale = scale;
}
timeline.boneIndex = boneIndex;
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat() * timelineScale, input.readFloat() * timelineScale);
if (frameIndex < frameCount - 1)
this.readCurve(input, frameIndex, timeline);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(frameCount - 1) * TranslateTimeline.ENTRIES]);
break;
}
}
}
}
// IK constraint timelines.
for (var i = 0, n = input.readInt(true); i < n; i++) {
/** @type {?} */
var index = input.readInt(true);
/** @type {?} */
var frameCount = input.readInt(true);
/** @type {?} */
var timeline = new IkConstraintTimeline(frameCount);
timeline.ikConstraintIndex = index;
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readFloat() * scale, input.readByte(), input.readBoolean(), input.readBoolean());
if (frameIndex < frameCount - 1)
this.readCurve(input, frameIndex, timeline);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(frameCount - 1) * IkConstraintTimeline.ENTRIES]);
}
// Transform constraint timelines.
for (var i = 0, n = input.readInt(true); i < n; i++) {
/** @type {?} */
var index = input.readInt(true);
/** @type {?} */
var frameCount = input.readInt(true);
/** @type {?} */
var timeline = new TransformConstraintTimeline(frameCount);
timeline.transformConstraintIndex = index;
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat());
if (frameIndex < frameCount - 1)
this.readCurve(input, frameIndex, timeline);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(frameCount - 1) * TransformConstraintTimeline.ENTRIES]);
}
// Path constraint timelines.
for (var i = 0, n = input.readInt(true); i < n; i++) {
/** @type {?} */
var index = input.readInt(true);
/** @type {?} */
var data = skeletonData.pathConstraints[index];
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
/** @type {?} */
var timelineType = input.readByte();
/** @type {?} */
var frameCount = input.readInt(true);
switch (timelineType) {
case SkeletonBinary.PATH_POSITION:
case SkeletonBinary.PATH_SPACING: {
/** @type {?} */
var timeline = void 0;
/** @type {?} */
var timelineScale = 1;
if (timelineType == SkeletonBinary.PATH_SPACING) {
timeline = new PathConstraintSpacingTimeline(frameCount);
if (data.spacingMode == SpacingMode.Length ||
data.spacingMode == SpacingMode.Fixed)
timelineScale = scale;
}
else {
timeline = new PathConstraintPositionTimeline(frameCount);
if (data.positionMode == PositionMode.Fixed)
timelineScale = scale;
}
timeline.pathConstraintIndex = index;
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat() * timelineScale);
if (frameIndex < frameCount - 1)
this.readCurve(input, frameIndex, timeline);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(frameCount - 1) * PathConstraintPositionTimeline.ENTRIES]);
break;
}
case SkeletonBinary.PATH_MIX: {
/** @type {?} */
var timeline = new PathConstraintMixTimeline(frameCount);
timeline.pathConstraintIndex = index;
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readFloat());
if (frameIndex < frameCount - 1)
this.readCurve(input, frameIndex, timeline);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(frameCount - 1) * PathConstraintMixTimeline.ENTRIES]);
break;
}
}
}
}
// Deform timelines.
for (var i = 0, n = input.readInt(true); i < n; i++) {
/** @type {?} */
var skin = skeletonData.skins[input.readInt(true)];
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
/** @type {?} */
var slotIndex = input.readInt(true);
for (var iii = 0, nnn = input.readInt(true); iii < nnn; iii++) {
/** @type {?} */
var attachment = (/** @type {?} */ (skin.getAttachment(slotIndex, input.readStringRef())));
/** @type {?} */
var weighted = attachment.bones != null;
/** @type {?} */
var vertices = attachment.vertices;
/** @type {?} */
var deformLength = weighted
? (vertices.length / 3) * 2
: vertices.length;
/** @type {?} */
var frameCount = input.readInt(true);
/** @type {?} */
var timeline = new DeformTimeline(frameCount);
timeline.slotIndex = slotIndex;
timeline.attachment = attachment;
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
/** @type {?} */
var time = input.readFloat();
/** @type {?} */
var deform = void 0;
/** @type {?} */
var end = input.readInt(true);
if (end == 0)
deform = weighted ? Utils.newFloatArray(deformLength) : vertices;
else {
deform = Utils.newFloatArray(deformLength);
/** @type {?} */
var start = input.readInt(true);
end += start;
if (scale == 1) {
for (var v = start; v < end; v++)
deform[v] = input.readFloat();
}
else {
for (var v = start; v < end; v++)
deform[v] = input.readFloat() * scale;
}
if (!weighted) {
for (var v = 0, vn = deform.length; v < vn; v++)
deform[v] += vertices[v];
}
}
timeline.setFrame(frameIndex, time, deform);
if (frameIndex < frameCount - 1)
this.readCurve(input, frameIndex, timeline);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[frameCount - 1]);
}
}
}
// Draw order timeline.
/** @type {?} */
var drawOrderCount = input.readInt(true);
if (drawOrderCount > 0) {
/** @type {?} */
var timeline = new DrawOrderTimeline(drawOrderCount);
/** @type {?} */
var slotCount = skeletonData.slots.length;
for (var i = 0; i < drawOrderCount; i++) {
/** @type {?} */
var time = input.readFloat();
/** @type {?} */
var offsetCount = input.readInt(true);
/** @type {?} */
var drawOrder = Utils.newArray(slotCount, 0);
for (var ii = slotCount - 1; ii >= 0; ii--)
drawOrder[ii] = -1;
/** @type {?} */
var unchanged = Utils.newArray(slotCount - offsetCount, 0);
/** @type {?} */
var originalIndex = 0;
/** @type {?} */
var unchangedIndex = 0;
for (var ii = 0; ii < offsetCount; ii++) {
/** @type {?} */
var slotIndex = input.readInt(true);
// Collect unchanged items.
while (originalIndex != slotIndex)
unchanged[unchangedIndex++] = originalIndex++;
// Set changed items.
drawOrder[originalIndex + input.readInt(true)] = originalIndex++;
}
// Collect remaining unchanged items.
while (originalIndex < slotCount)
unchanged[unchangedIndex++] = originalIndex++;
// Fill in unchanged items.
for (var ii = slotCount - 1; ii >= 0; ii--)
if (drawOrder[ii] == -1)
drawOrder[ii] = unchanged[--unchangedIndex];
timeline.setFrame(i, time, drawOrder);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[drawOrderCount - 1]);
}
// Event timeline.
/** @type {?} */
var eventCount = input.readInt(true);
if (eventCount > 0) {
/** @type {?} */
var timeline = new EventTimeline(eventCount);
for (var i = 0; i < eventCount; i++) {
/** @type {?} */
var time = input.readFloat();
/** @type {?} */
var eventData = skeletonData.events[input.readInt(true)];
/** @type {?} */
var event_1 = new Event(time, eventData);
event_1.intValue = input.readInt(false);
event_1.floatValue = input.readFloat();
event_1.stringValue = input.readBoolean()
? input.readString()
: eventData.stringValue;
if (event_1.data.audioPath != null) {
event_1.volume = input.readFloat();
event_1.balance = input.readFloat();
}
timeline.setFrame(i, event_1);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[eventCount - 1]);
}
return new Animation(name, timelines, duration);
};
/**
* @protected
* @param {?} input
* @param {?} frameIndex
* @param {?} timeline
* @return {?}
*/
SkeletonBinary.prototype.readCurve = /**
* @protected
* @param {?} input
* @param {?} frameIndex
* @param {?} timeline
* @return {?}
*/
function (input, frameIndex, timeline) {
switch (input.readByte()) {
case SkeletonBinary.CURVE_STEPPED:
timeline.setStepped(frameIndex);
break;
case SkeletonBinary.CURVE_BEZIER:
this.setCurve(timeline, frameIndex, input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat());
break;
}
};
/**
* @param {?} timeline
* @param {?} frameIndex
* @param {?} cx1
* @param {?} cy1
* @param {?} cx2
* @param {?} cy2
* @return {?}
*/
SkeletonBinary.prototype.setCurve = /**
* @param {?} timeline
* @param {?} frameIndex
* @param {?} cx1
* @param {?} cy1
* @param {?} cx2
* @param {?} cy2
* @return {?}
*/
function (timeline, frameIndex, cx1, cy1, cx2, cy2) {
timeline.setCurve(frameIndex, cx1, cy1, cx2, cy2);
};
SkeletonBinary.AttachmentTypeValues = [
0 /*AttachmentType.Region*/,
1 /*AttachmentType.BoundingBox*/,
2 /*AttachmentType.Mesh*/,
3 /*AttachmentType.LinkedMesh*/,
4 /*AttachmentType.Path*/,
5 /*AttachmentType.Point*/,
6 /*AttachmentType.Clipping*/
];
SkeletonBinary.TransformModeValues = [
TransformMode.Normal,
TransformMode.OnlyTranslation,
TransformMode.NoRotationOrReflection,
TransformMode.NoScale,
TransformMode.NoScaleOrReflection
];
SkeletonBinary.PositionModeValues = [PositionMode.Fixed, PositionMode.Percent];
SkeletonBinary.SpacingModeValues = [
SpacingMode.Length,
SpacingMode.Fixed,
SpacingMode.Percent
];
SkeletonBinary.RotateModeValues = [
RotateMode.Tangent,
RotateMode.Chain,
RotateMode.ChainScale
];
SkeletonBinary.BlendModeValues = [
BlendMode.Normal,
BlendMode.Additive,
BlendMode.Multiply,
BlendMode.Screen
];
SkeletonBinary.BONE_ROTATE = 0;
SkeletonBinary.BONE_TRANSLATE = 1;
SkeletonBinary.BONE_SCALE = 2;
SkeletonBinary.BONE_SHEAR = 3;
SkeletonBinary.SLOT_ATTACHMENT = 0;
SkeletonBinary.SLOT_COLOR = 1;
SkeletonBinary.SLOT_TWO_COLOR = 2;
SkeletonBinary.PATH_POSITION = 0;
SkeletonBinary.PATH_SPACING = 1;
SkeletonBinary.PATH_MIX = 2;
SkeletonBinary.CURVE_LINEAR = 0;
SkeletonBinary.CURVE_STEPPED = 1;
SkeletonBinary.CURVE_BEZIER = 2;
return SkeletonBinary;
}());
if (false) {
/** @type {?} */
SkeletonBinary.AttachmentTypeValues;
/** @type {?} */
SkeletonBinary.TransformModeValues;
/** @type {?} */
SkeletonBinary.PositionModeValues;
/** @type {?} */
SkeletonBinary.SpacingModeValues;
/** @type {?} */
SkeletonBinary.RotateModeValues;
/** @type {?} */
SkeletonBinary.BlendModeValues;
/** @type {?} */
SkeletonBinary.BONE_ROTATE;
/** @type {?} */
SkeletonBinary.BONE_TRANSLATE;
/** @type {?} */
SkeletonBinary.BONE_SCALE;
/** @type {?} */
SkeletonBinary.BONE_SHEAR;
/** @type {?} */
SkeletonBinary.SLOT_ATTACHMENT;
/** @type {?} */
SkeletonBinary.SLOT_COLOR;
/** @type {?} */
SkeletonBinary.SLOT_TWO_COLOR;
/** @type {?} */
SkeletonBinary.PATH_POSITION;
/** @type {?} */
SkeletonBinary.PATH_SPACING;
/** @type {?} */
SkeletonBinary.PATH_MIX;
/** @type {?} */
SkeletonBinary.CURVE_LINEAR;
/** @type {?} */
SkeletonBinary.CURVE_STEPPED;
/** @type {?} */
SkeletonBinary.CURVE_BEZIER;
/** @type {?} */
SkeletonBinary.prototype.attachmentLoader;
/** @type {?} */
SkeletonBinary.prototype.scale;
/**
* @type {?}
* @protected
*/
SkeletonBinary.prototype.linkedMeshes;
}
var SkeletonBinary37 = /** @class */ (function (_super) {
__extends(SkeletonBinary37, _super);
function SkeletonBinary37() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* @param {?} binary
* @return {?}
*/
SkeletonBinary37.prototype.readSkeletonData = /**
* @param {?} binary
* @return {?}
*/
function (binary) {
/** @type {?} */
var scale = this.scale;
/** @type {?} */
var input = new BinaryInput(binary);
/** @type {?} */
var hash = input.readString();
/** @type {?} */
var version = input.readString();
/** @type {?} */
var skeletonData = new SkeletonData();
skeletonData.name = ""; // BOZO
skeletonData.hash = hash;
skeletonData.version = version;
skeletonData.width = input.readFloat();
skeletonData.height = input.readFloat();
/** @type {?} */
var nonessential = input.readBoolean();
if (nonessential) {
skeletonData.fps = input.readFloat();
skeletonData.imagesPath = input.readString();
skeletonData.audioPath = input.readString();
}
/** @type {?} */
var n = 0;
// Bones.
n = input.readInt(true);
for (var i = 0; i < n; i++) {
/** @type {?} */
var name_3 = input.readString();
/** @type {?} */
var parent_4 = i == 0 ? null : skeletonData.bones[input.readInt(true)];
/** @type {?} */
var data = new BoneData(i, name_3, parent_4);
data.rotation = input.readFloat();
data.x = input.readFloat() * scale;
data.y = input.readFloat() * scale;
data.scaleX = input.readFloat();
data.scaleY = input.readFloat();
data.shearX = input.readFloat();
data.shearY = input.readFloat();
data.length = input.readFloat() * scale;
data.transformMode =
SkeletonBinary.TransformModeValues[input.readInt(true)];
if (nonessential)
Color.rgba8888ToColor(data.color, input.readInt32());
skeletonData.bones.push(data);
}
// Slots.
n = input.readInt(true);
for (var i = 0; i < n; i++) {
/** @type {?} */
var slotName = input.readString();
/** @type {?} */
var boneData = skeletonData.bones[input.readInt(true)];
/** @type {?} */
var data = new SlotData(i, slotName, boneData);
Color.rgba8888ToColor(data.color, input.readInt32());
/** @type {?} */
var darkColor = input.readInt32();
if (darkColor != -1)
Color.rgb888ToColor((data.darkColor = new Color()), darkColor);
data.attachmentName = input.readString();
data.blendMode = SkeletonBinary.BlendModeValues[input.readInt(true)];
skeletonData.slots.push(data);
}
// IK constraints.
n = input.readInt(true);
for (var i = 0, nn = void 0; i < n; i++) {
/** @type {?} */
var data = new IkConstraintData(input.readString());
data.order = input.readInt(true);
nn = input.readInt(true);
for (var ii = 0; ii < nn; ii++)
data.bones.push(skeletonData.bones[input.readInt(true)]);
data.target = skeletonData.bones[input.readInt(true)];
data.mix = input.readFloat();
data.bendDirection = input.readByte();
data.compress = input.readBoolean();
data.stretch = input.readBoolean();
data.uniform = input.readBoolean();
skeletonData.ikConstraints.push(data);
}
// Transform constraints.
n = input.readInt(true);
for (var i = 0, nn = void 0; i < n; i++) {
/** @type {?} */
var data = new TransformConstraintData(input.readString());
data.order = input.readInt(true);
nn = input.readInt(true);
for (var ii = 0; ii < nn; ii++)
data.bones.push(skeletonData.bones[input.readInt(true)]);
data.target = skeletonData.bones[input.readInt(true)];
data.local = input.readBoolean();
data.relative = input.readBoolean();
data.offsetRotation = input.readFloat();
data.offsetX = input.readFloat() * scale;
data.offsetY = input.readFloat() * scale;
data.offsetScaleX = input.readFloat();
data.offsetScaleY = input.readFloat();
data.offsetShearY = input.readFloat();
data.rotateMix = input.readFloat();
data.translateMix = input.readFloat();
data.scaleMix = input.readFloat();
data.shearMix = input.readFloat();
skeletonData.transformConstraints.push(data);
}
// Path constraints.
n = input.readInt(true);
for (var i = 0, nn = void 0; i < n; i++) {
/** @type {?} */
var data = new PathConstraintData(input.readString());
data.order = input.readInt(true);
nn = input.readInt(true);
for (var ii = 0; ii < nn; ii++)
data.bones.push(skeletonData.bones[input.readInt(true)]);
data.target = skeletonData.slots[input.readInt(true)];
data.positionMode =
SkeletonBinary.PositionModeValues[input.readInt(true)];
data.spacingMode = SkeletonBinary.SpacingModeValues[input.readInt(true)];
data.rotateMode = SkeletonBinary.RotateModeValues[input.readInt(true)];
data.offsetRotation = input.readFloat();
data.position = input.readFloat();
if (data.positionMode == PositionMode.Fixed)
data.position *= scale;
data.spacing = input.readFloat();
if (data.spacingMode == SpacingMode.Length ||
data.spacingMode == SpacingMode.Fixed)
data.spacing *= scale;
data.rotateMix = input.readFloat();
data.translateMix = input.readFloat();
skeletonData.pathConstraints.push(data);
}
// Default skin.
/** @type {?} */
var defaultSkin = this.readSkin(input, skeletonData, true, nonessential);
if (defaultSkin != null) {
skeletonData.defaultSkin = defaultSkin;
skeletonData.skins.push(defaultSkin);
}
// Skins.
{
/** @type {?} */
var i = skeletonData.skins.length;
Utils.setArraySize(skeletonData.skins, (n = i + input.readInt(true)));
for (; i < n; i++)
skeletonData.skins[i] = this.readSkin(input, skeletonData, false, nonessential);
}
// Linked meshes.
n = this.linkedMeshes.length;
for (var i = 0; i < n; i++) {
/** @type {?} */
var linkedMesh = this.linkedMeshes[i];
/** @type {?} */
var skin = linkedMesh.skin == null
? skeletonData.defaultSkin
: skeletonData.findSkin(linkedMesh.skin);
if (skin == null)
throw new Error("Skin not found: " + linkedMesh.skin);
/** @type {?} */
var parent_5 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
if (parent_5 == null)
throw new Error("Parent mesh not found: " + linkedMesh.parent);
linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform
? ((/** @type {?} */ (parent_5)))
: linkedMesh.mesh;
linkedMesh.mesh.setParentMesh((/** @type {?} */ (parent_5)));
linkedMesh.mesh.updateUVs();
}
this.linkedMeshes.length = 0;
// Events.
n = input.readInt(true);
for (var i = 0; i < n; i++) {
/** @type {?} */
var data = new EventData(input.readString());
data.intValue = input.readInt(false);
data.floatValue = input.readFloat();
data.stringValue = input.readString();
data.audioPath = input.readString();
if (data.audioPath != null) {
data.volume = input.readFloat();
data.balance = input.readFloat();
}
skeletonData.events.push(data);
}
// Animations.
n = input.readInt(true);
for (var i = 0; i < n; i++)
skeletonData.animations.push(this.readAnimation(input, input.readString(), skeletonData));
return skeletonData;
};
/**
* @protected
* @param {?} input
* @param {?} skeletonData
* @param {?} defaultSkin
* @param {?} nonessential
* @return {?}
*/
SkeletonBinary37.prototype.readSkin = /**
* @protected
* @param {?} input
* @param {?} skeletonData
* @param {?} defaultSkin
* @param {?} nonessential
* @return {?}
*/
function (input, skeletonData, defaultSkin, nonessential) {
/** @type {?} */
var skin = new Skin(defaultSkin ? "default" : input.readString());
/** @type {?} */
var slotCount = input.readInt(true);
if (slotCount == 0)
return null;
for (var i = 0; i < slotCount; i++) {
/** @type {?} */
var slotIndex = input.readInt(true);
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
/** @type {?} */
var name_4 = input.readString();
/** @type {?} */
var attachment = this.readAttachment(input, skeletonData, skin, slotIndex, name_4, nonessential);
if (attachment != null)
skin.setAttachment(slotIndex, name_4, attachment);
}
}
return skin;
};
/**
* @protected
* @param {?} input
* @param {?} name
* @param {?} skeletonData
* @return {?}
*/
SkeletonBinary37.prototype.readAnimation = /**
* @protected
* @param {?} input
* @param {?} name
* @param {?} skeletonData
* @return {?}
*/
function (input, name, skeletonData) {
/** @type {?} */
var timelines = new Array();
/** @type {?} */
var scale = this.scale;
/** @type {?} */
var duration = 0;
/** @type {?} */
var tempColor1 = new Color();
/** @type {?} */
var tempColor2 = new Color();
// Slot timelines.
for (var i = 0, n = input.readInt(true); i < n; i++) {
/** @type {?} */
var slotIndex = input.readInt(true);
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
/** @type {?} */
var timelineType = input.readByte();
/** @type {?} */
var frameCount = input.readInt(true);
switch (timelineType) {
case SkeletonBinary.SLOT_ATTACHMENT: {
/** @type {?} */
var timeline = new AttachmentTimeline(frameCount);
timeline.slotIndex = slotIndex;
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++)
timeline.setFrame(frameIndex, input.readFloat(), input.readString());
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[frameCount - 1]);
break;
}
case SkeletonBinary.SLOT_COLOR: {
/** @type {?} */
var timeline = new ColorTimeline(frameCount);
timeline.slotIndex = slotIndex;
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
/** @type {?} */
var time = input.readFloat();
Color.rgba8888ToColor(tempColor1, input.readInt32());
timeline.setFrame(frameIndex, time, tempColor1.r, tempColor1.g, tempColor1.b, tempColor1.a);
if (frameIndex < frameCount - 1)
this.readCurve(input, frameIndex, timeline);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(frameCount - 1) * ColorTimeline.ENTRIES]);
break;
}
case SkeletonBinary.SLOT_TWO_COLOR: {
/** @type {?} */
var timeline = new TwoColorTimeline(frameCount);
timeline.slotIndex = slotIndex;
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
/** @type {?} */
var time = input.readFloat();
Color.rgba8888ToColor(tempColor1, input.readInt32());
Color.rgb888ToColor(tempColor2, input.readInt32());
timeline.setFrame(frameIndex, time, tempColor1.r, tempColor1.g, tempColor1.b, tempColor1.a, tempColor2.r, tempColor2.g, tempColor2.b);
if (frameIndex < frameCount - 1)
this.readCurve(input, frameIndex, timeline);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(frameCount - 1) * TwoColorTimeline.ENTRIES]);
break;
}
}
}
}
// Bone timelines.
for (var i = 0, n = input.readInt(true); i < n; i++) {
/** @type {?} */
var boneIndex = input.readInt(true);
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
/** @type {?} */
var timelineType = input.readByte();
/** @type {?} */
var frameCount = input.readInt(true);
switch (timelineType) {
case SkeletonBinary.BONE_ROTATE: {
/** @type {?} */
var timeline = new RotateTimeline(frameCount);
timeline.boneIndex = boneIndex;
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat());
if (frameIndex < frameCount - 1)
this.readCurve(input, frameIndex, timeline);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(frameCount - 1) * RotateTimeline.ENTRIES]);
break;
}
case SkeletonBinary.BONE_TRANSLATE:
case SkeletonBinary.BONE_SCALE:
case SkeletonBinary.BONE_SHEAR: {
/** @type {?} */
var timeline = void 0;
/** @type {?} */
var timelineScale = 1;
if (timelineType == SkeletonBinary.BONE_SCALE)
timeline = new ScaleTimeline(frameCount);
else if (timelineType == SkeletonBinary.BONE_SHEAR)
timeline = new ShearTimeline(frameCount);
else {
timeline = new TranslateTimeline(frameCount);
timelineScale = scale;
}
timeline.boneIndex = boneIndex;
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat() * timelineScale, input.readFloat() * timelineScale);
if (frameIndex < frameCount - 1)
this.readCurve(input, frameIndex, timeline);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(frameCount - 1) * TranslateTimeline.ENTRIES]);
break;
}
}
}
}
// IK constraint timelines.
for (var i = 0, n = input.readInt(true); i < n; i++) {
/** @type {?} */
var index = input.readInt(true);
/** @type {?} */
var frameCount = input.readInt(true);
/** @type {?} */
var timeline = new IkConstraintTimeline(frameCount);
timeline.ikConstraintIndex = index;
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), 1, // softness
input.readByte(), input.readBoolean(), input.readBoolean());
if (frameIndex < frameCount - 1)
this.readCurve(input, frameIndex, timeline);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(frameCount - 1) * IkConstraintTimeline.ENTRIES]);
}
// Transform constraint timelines.
for (var i = 0, n = input.readInt(true); i < n; i++) {
/** @type {?} */
var index = input.readInt(true);
/** @type {?} */
var frameCount = input.readInt(true);
/** @type {?} */
var timeline = new TransformConstraintTimeline(frameCount);
timeline.transformConstraintIndex = index;
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat());
if (frameIndex < frameCount - 1)
this.readCurve(input, frameIndex, timeline);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(frameCount - 1) * TransformConstraintTimeline.ENTRIES]);
}
// Path constraint timelines.
for (var i = 0, n = input.readInt(true); i < n; i++) {
/** @type {?} */
var index = input.readInt(true);
/** @type {?} */
var data = skeletonData.pathConstraints[index];
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
/** @type {?} */
var timelineType = input.readByte();
/** @type {?} */
var frameCount = input.readInt(true);
switch (timelineType) {
case SkeletonBinary.PATH_POSITION:
case SkeletonBinary.PATH_SPACING: {
/** @type {?} */
var timeline = void 0;
/** @type {?} */
var timelineScale = 1;
if (timelineType == SkeletonBinary.PATH_SPACING) {
timeline = new PathConstraintSpacingTimeline(frameCount);
if (data.spacingMode == SpacingMode.Length ||
data.spacingMode == SpacingMode.Fixed)
timelineScale = scale;
}
else {
timeline = new PathConstraintPositionTimeline(frameCount);
if (data.positionMode == PositionMode.Fixed)
timelineScale = scale;
}
timeline.pathConstraintIndex = index;
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat() * timelineScale);
if (frameIndex < frameCount - 1)
this.readCurve(input, frameIndex, timeline);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(frameCount - 1) * PathConstraintPositionTimeline.ENTRIES]);
break;
}
case SkeletonBinary.PATH_MIX: {
/** @type {?} */
var timeline = new PathConstraintMixTimeline(frameCount);
timeline.pathConstraintIndex = index;
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readFloat());
if (frameIndex < frameCount - 1)
this.readCurve(input, frameIndex, timeline);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(frameCount - 1) * PathConstraintMixTimeline.ENTRIES]);
break;
}
}
}
}
// Deform timelines.
for (var i = 0, n = input.readInt(true); i < n; i++) {
/** @type {?} */
var skin = skeletonData.skins[input.readInt(true)];
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
/** @type {?} */
var slotIndex = input.readInt(true);
for (var iii = 0, nnn = input.readInt(true); iii < nnn; iii++) {
/** @type {?} */
var attachment = (/** @type {?} */ (skin.getAttachment(slotIndex, input.readString())));
/** @type {?} */
var weighted = attachment.bones != null;
/** @type {?} */
var vertices = attachment.vertices;
/** @type {?} */
var deformLength = weighted
? (vertices.length / 3) * 2
: vertices.length;
/** @type {?} */
var frameCount = input.readInt(true);
/** @type {?} */
var timeline = new DeformTimeline(frameCount);
timeline.slotIndex = slotIndex;
timeline.attachment = attachment;
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
/** @type {?} */
var time = input.readFloat();
/** @type {?} */
var deform = void 0;
/** @type {?} */
var end = input.readInt(true);
if (end == 0)
deform = weighted ? Utils.newFloatArray(deformLength) : vertices;
else {
deform = Utils.newFloatArray(deformLength);
/** @type {?} */
var start = input.readInt(true);
end += start;
if (scale == 1) {
for (var v = start; v < end; v++)
deform[v] = input.readFloat();
}
else {
for (var v = start; v < end; v++)
deform[v] = input.readFloat() * scale;
}
if (!weighted) {
for (var v = 0, vn = deform.length; v < vn; v++)
deform[v] += vertices[v];
}
}
timeline.setFrame(frameIndex, time, deform);
if (frameIndex < frameCount - 1)
this.readCurve(input, frameIndex, timeline);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[frameCount - 1]);
}
}
}
// Draw order timeline.
/** @type {?} */
var drawOrderCount = input.readInt(true);
if (drawOrderCount > 0) {
/** @type {?} */
var timeline = new DrawOrderTimeline(drawOrderCount);
/** @type {?} */
var slotCount = skeletonData.slots.length;
for (var i = 0; i < drawOrderCount; i++) {
/** @type {?} */
var time = input.readFloat();
/** @type {?} */
var offsetCount = input.readInt(true);
/** @type {?} */
var drawOrder = Utils.newArray(slotCount, 0);
for (var ii = slotCount - 1; ii >= 0; ii--)
drawOrder[ii] = -1;
/** @type {?} */
var unchanged = Utils.newArray(slotCount - offsetCount, 0);
/** @type {?} */
var originalIndex = 0;
/** @type {?} */
var unchangedIndex = 0;
for (var ii = 0; ii < offsetCount; ii++) {
/** @type {?} */
var slotIndex = input.readInt(true);
// Collect unchanged items.
while (originalIndex != slotIndex)
unchanged[unchangedIndex++] = originalIndex++;
// Set changed items.
drawOrder[originalIndex + input.readInt(true)] = originalIndex++;
}
// Collect remaining unchanged items.
while (originalIndex < slotCount)
unchanged[unchangedIndex++] = originalIndex++;
// Fill in unchanged items.
for (var ii = slotCount - 1; ii >= 0; ii--)
if (drawOrder[ii] == -1)
drawOrder[ii] = unchanged[--unchangedIndex];
timeline.setFrame(i, time, drawOrder);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[drawOrderCount - 1]);
}
// Event timeline.
/** @type {?} */
var eventCount = input.readInt(true);
if (eventCount > 0) {
/** @type {?} */
var timeline = new EventTimeline(eventCount);
for (var i = 0; i < eventCount; i++) {
/** @type {?} */
var time = input.readFloat();
/** @type {?} */
var eventData = skeletonData.events[input.readInt(true)];
/** @type {?} */
var event_2 = new Event(time, eventData);
event_2.intValue = input.readInt(false);
event_2.floatValue = input.readFloat();
event_2.stringValue = input.readBoolean()
? input.readString()
: eventData.stringValue;
if (event_2.data.audioPath != null) {
event_2.volume = input.readFloat();
event_2.balance = input.readFloat();
}
timeline.setFrame(i, event_2);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[eventCount - 1]);
}
return new Animation(name, timelines, duration);
};
return SkeletonBinary37;
}(SkeletonBinary));
var SkeletonBinary36 = /** @class */ (function (_super) {
__extends(SkeletonBinary36, _super);
function SkeletonBinary36() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* @param {?} binary
* @return {?}
*/
SkeletonBinary36.prototype.readSkeletonData = /**
* @param {?} binary
* @return {?}
*/
function (binary) {
/** @type {?} */
var scale = this.scale;
/** @type {?} */
var skeletonData = new SkeletonData();
skeletonData.name = ""; // BOZO
// BOZO
/** @type {?} */
var input = new BinaryInput(binary);
skeletonData.hash = input.readString();
skeletonData.version = input.readString();
skeletonData.width = input.readFloat();
skeletonData.height = input.readFloat();
/** @type {?} */
var nonessential = input.readBoolean();
if (nonessential) {
skeletonData.fps = input.readFloat();
skeletonData.imagesPath = input.readString();
}
/** @type {?} */
var n = 0;
// Bones.
n = input.readInt(true);
for (var i = 0; i < n; i++) {
/** @type {?} */
var name_5 = input.readString();
/** @type {?} */
var parent_6 = i == 0 ? null : skeletonData.bones[input.readInt(true)];
/** @type {?} */
var data = new BoneData(i, name_5, parent_6);
data.rotation = input.readFloat();
data.x = input.readFloat() * scale;
data.y = input.readFloat() * scale;
data.scaleX = input.readFloat();
data.scaleY = input.readFloat();
data.shearX = input.readFloat();
data.shearY = input.readFloat();
data.length = input.readFloat() * scale;
data.transformMode =
SkeletonBinary.TransformModeValues[input.readInt(true)];
if (nonessential)
Color.rgba8888ToColor(data.color, input.readInt32());
skeletonData.bones.push(data);
}
// Slots.
n = input.readInt(true);
for (var i = 0; i < n; i++) {
/** @type {?} */
var slotName = input.readString();
/** @type {?} */
var boneData = skeletonData.bones[input.readInt(true)];
/** @type {?} */
var data = new SlotData(i, slotName, boneData);
Color.rgba8888ToColor(data.color, input.readInt32());
/** @type {?} */
var darkColor = input.readInt32();
if (darkColor != -1)
Color.rgb888ToColor((data.darkColor = new Color()), darkColor);
data.attachmentName = input.readString();
data.blendMode = SkeletonBinary.BlendModeValues[input.readInt(true)];
skeletonData.slots.push(data);
}
// IK constraints.
n = input.readInt(true);
for (var i = 0, nn = void 0; i < n; i++) {
/** @type {?} */
var data = new IkConstraintData(input.readString());
data.order = input.readInt(true);
nn = input.readInt(true);
for (var ii = 0; ii < nn; ii++)
data.bones.push(skeletonData.bones[input.readInt(true)]);
data.target = skeletonData.bones[input.readInt(true)];
data.mix = input.readFloat();
data.bendDirection = input.readByte();
skeletonData.ikConstraints.push(data);
}
// Transform constraints.
n = input.readInt(true);
for (var i = 0, nn = void 0; i < n; i++) {
/** @type {?} */
var data = new TransformConstraintData(input.readString());
data.order = input.readInt(true);
nn = input.readInt(true);
for (var ii = 0; ii < nn; ii++)
data.bones.push(skeletonData.bones[input.readInt(true)]);
data.target = skeletonData.bones[input.readInt(true)];
data.local = input.readBoolean();
data.relative = input.readBoolean();
data.offsetRotation = input.readFloat();
data.offsetX = input.readFloat() * scale;
data.offsetY = input.readFloat() * scale;
data.offsetScaleX = input.readFloat();
data.offsetScaleY = input.readFloat();
data.offsetShearY = input.readFloat();
data.rotateMix = input.readFloat();
data.translateMix = input.readFloat();
data.scaleMix = input.readFloat();
data.shearMix = input.readFloat();
skeletonData.transformConstraints.push(data);
}
// Path constraints.
n = input.readInt(true);
for (var i = 0, nn = void 0; i < n; i++) {
/** @type {?} */
var data = new PathConstraintData(input.readString());
data.order = input.readInt(true);
nn = input.readInt(true);
for (var ii = 0; ii < nn; ii++)
data.bones.push(skeletonData.bones[input.readInt(true)]);
data.target = skeletonData.slots[input.readInt(true)];
data.positionMode =
SkeletonBinary.PositionModeValues[input.readInt(true)];
data.spacingMode = SkeletonBinary.SpacingModeValues[input.readInt(true)];
data.rotateMode = SkeletonBinary.RotateModeValues[input.readInt(true)];
data.offsetRotation = input.readFloat();
data.position = input.readFloat();
if (data.positionMode == PositionMode.Fixed)
data.position *= scale;
data.spacing = input.readFloat();
if (data.spacingMode == SpacingMode.Length ||
data.spacingMode == SpacingMode.Fixed)
data.spacing *= scale;
data.rotateMix = input.readFloat();
data.translateMix = input.readFloat();
skeletonData.pathConstraints.push(data);
}
// Default skin.
/** @type {?} */
var defaultSkin = this.readSkin(input, skeletonData, true, nonessential);
if (defaultSkin != null) {
skeletonData.defaultSkin = defaultSkin;
skeletonData.skins.push(defaultSkin);
}
// Skins.
{
/** @type {?} */
var i = skeletonData.skins.length;
Utils.setArraySize(skeletonData.skins, (n = i + input.readInt(true)));
for (; i < n; i++)
skeletonData.skins[i] = this.readSkin(input, skeletonData, false, nonessential);
}
// Events.
n = input.readInt(true);
for (var i = 0; i < n; i++) {
/** @type {?} */
var data = new EventData(input.readString());
data.intValue = input.readInt(false);
data.floatValue = input.readFloat();
data.stringValue = input.readString();
skeletonData.events.push(data);
}
// Animations.
n = input.readInt(true);
for (var i = 0; i < n; i++) {
/** @type {?} */
var animationName = input.readString();
/** @type {?} */
var animation = this.readAnimation(input, animationName, skeletonData);
skeletonData.animations.push(animation);
}
return skeletonData;
};
/**
* @protected
* @param {?} input
* @param {?} skeletonData
* @param {?} defaultSkin
* @param {?} nonessential
* @return {?}
*/
SkeletonBinary36.prototype.readSkin = /**
* @protected
* @param {?} input
* @param {?} skeletonData
* @param {?} defaultSkin
* @param {?} nonessential
* @return {?}
*/
function (input, skeletonData, defaultSkin, nonessential) {
/** @type {?} */
var skin = new Skin(defaultSkin ? "default" : input.readString());
/** @type {?} */
var slotCount = input.readInt(true);
if (slotCount == 0)
return null;
for (var i = 0; i < slotCount; i++) {
/** @type {?} */
var slotIndex = input.readInt(true);
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
/** @type {?} */
var name_6 = input.readString();
/** @type {?} */
var attachment = this.readAttachment(input, skeletonData, skin, slotIndex, name_6, nonessential);
if (attachment != null)
skin.setAttachment(slotIndex, name_6, attachment);
}
}
return skin;
};
/**
* @protected
* @param {?} input
* @param {?} skeletonData
* @param {?} skin
* @param {?} slotIndex
* @param {?} attachmentName
* @param {?} nonessential
* @return {?}
*/
SkeletonBinary36.prototype.readAttachment = /**
* @protected
* @param {?} input
* @param {?} skeletonData
* @param {?} skin
* @param {?} slotIndex
* @param {?} attachmentName
* @param {?} nonessential
* @return {?}
*/
function (input, skeletonData, skin, slotIndex, attachmentName, nonessential) {
/** @type {?} */
var scale = this.scale;
/** @type {?} */
var name = input.readString();
if (name == null)
name = attachmentName;
/** @type {?} */
var typeIndex = input.readByte();
/** @type {?} */
var type = SkeletonBinary.AttachmentTypeValues[typeIndex];
switch (type) {
case AttachmentType.Region: {
/** @type {?} */
var path = input.readString();
/** @type {?} */
var rotation = input.readFloat();
/** @type {?} */
var x = input.readFloat();
/** @type {?} */
var y = input.readFloat();
/** @type {?} */
var scaleX = input.readFloat();
/** @type {?} */
var scaleY = input.readFloat();
/** @type {?} */
var width = input.readFloat();
/** @type {?} */
var height = input.readFloat();
/** @type {?} */
var color = input.readInt32();
if (path == null)
path = name;
/** @type {?} */
var region = this.attachmentLoader.newRegionAttachment(skin, name, path);
if (region == null)
return null;
region.path = path.trim(); // HACK: trim path name for some SD
region.x = x * scale;
region.y = y * scale;
region.scaleX = scaleX;
region.scaleY = scaleY;
region.rotation = rotation;
region.width = width * scale;
region.height = height * scale;
Color.rgba8888ToColor(region.color, color);
region.updateOffset();
return region;
}
case AttachmentType.BoundingBox: {
/** @type {?} */
var vertexCount = input.readInt(true);
/** @type {?} */
var vertices = this.readVertices(input, vertexCount);
/** @type {?} */
var color = nonessential ? input.readInt32() : 0;
/** @type {?} */
var box = this.attachmentLoader.newBoundingBoxAttachment(skin, name);
if (box == null)
return null;
box.worldVerticesLength = vertexCount << 1;
box.vertices = vertices.vertices;
box.bones = vertices.bones;
if (nonessential)
Color.rgba8888ToColor(box.color, color);
return box;
}
case AttachmentType.Mesh: {
/** @type {?} */
var path = input.readString();
/** @type {?} */
var color = input.readInt32();
/** @type {?} */
var vertexCount = input.readInt(true);
/** @type {?} */
var uvs = this.readFloatArray(input, vertexCount << 1, 1);
/** @type {?} */
var triangles = this.readShortArray(input);
/** @type {?} */
var vertices = this.readVertices(input, vertexCount);
/** @type {?} */
var hullLength = input.readInt(true);
/** @type {?} */
var edges = null;
/** @type {?} */
var width = 0;
/** @type {?} */
var height = 0;
if (nonessential) {
edges = this.readShortArray(input);
width = input.readFloat();
height = input.readFloat();
}
if (path == null)
path = name;
/** @type {?} */
var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path);
if (mesh == null)
return null;
mesh.path = path;
Color.rgba8888ToColor(mesh.color, color);
mesh.bones = vertices.bones;
mesh.vertices = vertices.vertices;
mesh.worldVerticesLength = vertexCount << 1;
mesh.triangles = triangles;
mesh.regionUVs = uvs;
mesh.updateUVs();
mesh.hullLength = hullLength << 1;
if (nonessential) {
mesh.edges = edges;
mesh.width = width * scale;
mesh.height = height * scale;
}
return mesh;
}
case AttachmentType.LinkedMesh: {
/** @type {?} */
var path = input.readString();
/** @type {?} */
var color = input.readInt32();
/** @type {?} */
var skinName = input.readString();
/** @type {?} */
var parent_7 = input.readStringRef();
/** @type {?} */
var inheritDeform = input.readBoolean();
/** @type {?} */
var width = 0;
/** @type {?} */
var height = 0;
if (nonessential) {
width = input.readFloat();
height = input.readFloat();
}
if (path == null)
path = name;
/** @type {?} */
var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path);
if (mesh == null)
return null;
mesh.path = path;
Color.rgba8888ToColor(mesh.color, color);
if (nonessential) {
mesh.width = width * scale;
mesh.height = height * scale;
}
this.linkedMeshes.push(new LinkedMesh(mesh, skinName, slotIndex, parent_7, inheritDeform));
return mesh;
}
case AttachmentType.Path: {
/** @type {?} */
var closed_2 = input.readBoolean();
/** @type {?} */
var constantSpeed = input.readBoolean();
/** @type {?} */
var vertexCount = input.readInt(true);
/** @type {?} */
var vertices = this.readVertices(input, vertexCount);
/** @type {?} */
var lengths = Utils.newArray(vertexCount / 3, 0);
for (var i = 0, n = lengths.length; i < n; i++)
lengths[i] = input.readFloat() * scale;
/** @type {?} */
var color = nonessential ? input.readInt32() : 0;
/** @type {?} */
var path = this.attachmentLoader.newPathAttachment(skin, name);
if (path == null)
return null;
path.closed = closed_2;
path.constantSpeed = constantSpeed;
path.worldVerticesLength = vertexCount << 1;
path.vertices = vertices.vertices;
path.bones = vertices.bones;
path.lengths = lengths;
if (nonessential)
Color.rgba8888ToColor(path.color, color);
return path;
}
case AttachmentType.Point: {
/** @type {?} */
var rotation = input.readFloat();
/** @type {?} */
var x = input.readFloat();
/** @type {?} */
var y = input.readFloat();
/** @type {?} */
var color = nonessential ? input.readInt32() : 0;
/** @type {?} */
var point = this.attachmentLoader.newPointAttachment(skin, name);
if (point == null)
return null;
point.x = x * scale;
point.y = y * scale;
point.rotation = rotation;
if (nonessential)
Color.rgba8888ToColor(point.color, color);
return point;
}
case AttachmentType.Clipping: {
/** @type {?} */
var endSlotIndex = input.readInt(true);
/** @type {?} */
var vertexCount = input.readInt(true);
/** @type {?} */
var vertices = this.readVertices(input, vertexCount);
/** @type {?} */
var color = nonessential ? input.readInt32() : 0;
/** @type {?} */
var clip = this.attachmentLoader.newClippingAttachment(skin, name);
if (clip == null)
return null;
clip.endSlot = skeletonData.slots[endSlotIndex];
clip.worldVerticesLength = vertexCount << 1;
clip.vertices = vertices.vertices;
clip.bones = vertices.bones;
if (nonessential)
Color.rgba8888ToColor(clip.color, color);
return clip;
}
}
return null;
};
/**
* @protected
* @param {?} input
* @param {?} name
* @param {?} skeletonData
* @return {?}
*/
SkeletonBinary36.prototype.readAnimation = /**
* @protected
* @param {?} input
* @param {?} name
* @param {?} skeletonData
* @return {?}
*/
function (input, name, skeletonData) {
/** @type {?} */
var timelines = new Array();
/** @type {?} */
var scale = this.scale;
/** @type {?} */
var duration = 0;
/** @type {?} */
var tempColor1 = new Color();
/** @type {?} */
var tempColor2 = new Color();
// Slot timelines.
for (var i = 0, n = input.readInt(true); i < n; i++) {
/** @type {?} */
var slotIndex = input.readInt(true);
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
/** @type {?} */
var timelineType = input.readByte();
/** @type {?} */
var frameCount = input.readInt(true);
if (frameCount == 0) {
continue;
}
switch (timelineType) {
case SkeletonBinary.SLOT_ATTACHMENT: {
/** @type {?} */
var timeline = new AttachmentTimeline(frameCount);
timeline.slotIndex = slotIndex;
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
/** @type {?} */
var time = input.readFloat();
/** @type {?} */
var attachmentName = input.readString();
timeline.setFrame(frameIndex, time, attachmentName);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[frameCount - 1]);
break;
}
case SkeletonBinary.SLOT_COLOR: {
/** @type {?} */
var timeline = new ColorTimeline(frameCount);
timeline.slotIndex = slotIndex;
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
/** @type {?} */
var time = input.readFloat();
Color.rgba8888ToColor(tempColor1, input.readInt32());
timeline.setFrame(frameIndex, time, tempColor1.r, tempColor1.g, tempColor1.b, tempColor1.a);
if (frameIndex < frameCount - 1)
this.readCurve(input, frameIndex, timeline);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(frameCount - 1) * ColorTimeline.ENTRIES]);
break;
}
case SkeletonBinary.SLOT_TWO_COLOR: {
/** @type {?} */
var timeline = new TwoColorTimeline(frameCount);
timeline.slotIndex = slotIndex;
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
/** @type {?} */
var time = input.readFloat();
Color.rgba8888ToColor(tempColor1, input.readInt32());
Color.rgb888ToColor(tempColor2, input.readInt32());
timeline.setFrame(frameIndex, time, tempColor1.r, tempColor1.g, tempColor1.b, tempColor1.a, tempColor2.r, tempColor2.g, tempColor2.b);
if (frameIndex < frameCount - 1)
this.readCurve(input, frameIndex, timeline);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(frameCount - 1) * TwoColorTimeline.ENTRIES]);
break;
}
}
}
}
// Bone timelines.
for (var i = 0, n = input.readInt(true); i < n; i++) {
/** @type {?} */
var boneIndex = input.readInt(true);
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
/** @type {?} */
var timelineType = input.readByte();
/** @type {?} */
var frameCount = input.readInt(true);
switch (timelineType) {
case SkeletonBinary.BONE_ROTATE: {
/** @type {?} */
var timeline = new RotateTimeline(frameCount);
timeline.boneIndex = boneIndex;
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat());
if (frameIndex < frameCount - 1)
this.readCurve(input, frameIndex, timeline);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(frameCount - 1) * RotateTimeline.ENTRIES]);
break;
}
case SkeletonBinary.BONE_TRANSLATE:
case SkeletonBinary.BONE_SCALE:
case SkeletonBinary.BONE_SHEAR: {
/** @type {?} */
var timeline = void 0;
/** @type {?} */
var timelineScale = 1;
if (timelineType == SkeletonBinary.BONE_SCALE)
timeline = new ScaleTimeline(frameCount);
else if (timelineType == SkeletonBinary.BONE_SHEAR)
timeline = new ShearTimeline(frameCount);
else {
timeline = new TranslateTimeline(frameCount);
timelineScale = scale;
}
timeline.boneIndex = boneIndex;
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat() * timelineScale, input.readFloat() * timelineScale);
if (frameIndex < frameCount - 1)
this.readCurve(input, frameIndex, timeline);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(frameCount - 1) * TranslateTimeline.ENTRIES]);
break;
}
}
}
}
// IK constraint timelines.
for (var i = 0, n = input.readInt(true); i < n; i++) {
/** @type {?} */
var index = input.readInt(true);
/** @type {?} */
var frameCount = input.readInt(true);
/** @type {?} */
var timeline = new IkConstraintTimeline(frameCount);
timeline.ikConstraintIndex = index;
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
timeline.setFrame(frameIndex, input.readFloat(), // time
input.readFloat(), // mix
1, // softness
input.readByte(), // bendDirection
false, // compress
false // stretch
);
if (frameIndex < frameCount - 1)
this.readCurve(input, frameIndex, timeline);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(frameCount - 1) * IkConstraintTimeline.ENTRIES]);
}
// Transform constraint timelines.
for (var i = 0, n = input.readInt(true); i < n; i++) {
/** @type {?} */
var index = input.readInt(true);
/** @type {?} */
var frameCount = input.readInt(true);
/** @type {?} */
var timeline = new TransformConstraintTimeline(frameCount);
timeline.transformConstraintIndex = index;
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat());
if (frameIndex < frameCount - 1)
this.readCurve(input, frameIndex, timeline);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(frameCount - 1) * TransformConstraintTimeline.ENTRIES]);
}
// Path constraint timelines.
for (var i = 0, n = input.readInt(true); i < n; i++) {
/** @type {?} */
var index = input.readInt(true);
/** @type {?} */
var data = skeletonData.pathConstraints[index];
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
/** @type {?} */
var timelineType = input.readByte();
/** @type {?} */
var frameCount = input.readInt(true);
switch (timelineType) {
case SkeletonBinary.PATH_POSITION:
case SkeletonBinary.PATH_SPACING: {
/** @type {?} */
var timeline = void 0;
/** @type {?} */
var timelineScale = 1;
if (timelineType == SkeletonBinary.PATH_SPACING) {
timeline = new PathConstraintSpacingTimeline(frameCount);
if (data.spacingMode == SpacingMode.Length ||
data.spacingMode == SpacingMode.Fixed)
timelineScale = scale;
}
else {
timeline = new PathConstraintPositionTimeline(frameCount);
if (data.positionMode == PositionMode.Fixed)
timelineScale = scale;
}
timeline.pathConstraintIndex = index;
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat() * timelineScale);
if (frameIndex < frameCount - 1)
this.readCurve(input, frameIndex, timeline);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(frameCount - 1) * PathConstraintPositionTimeline.ENTRIES]);
break;
}
case SkeletonBinary.PATH_MIX: {
/** @type {?} */
var timeline = new PathConstraintMixTimeline(frameCount);
timeline.pathConstraintIndex = index;
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
timeline.setFrame(frameIndex, input.readFloat(), input.readFloat(), input.readFloat());
if (frameIndex < frameCount - 1)
this.readCurve(input, frameIndex, timeline);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(frameCount - 1) * PathConstraintMixTimeline.ENTRIES]);
break;
}
}
}
}
// Deform timelines.
for (var i = 0, n = input.readInt(true); i < n; i++) {
/** @type {?} */
var skin = skeletonData.skins[input.readInt(true)];
for (var ii = 0, nn = input.readInt(true); ii < nn; ii++) {
/** @type {?} */
var slotIndex = input.readInt(true);
for (var iii = 0, nnn = input.readInt(true); iii < nnn; iii++) {
/** @type {?} */
var attachment = (/** @type {?} */ (skin.getAttachment(slotIndex, input.readString())));
/** @type {?} */
var weighted = attachment.bones != null;
/** @type {?} */
var vertices = attachment.vertices;
/** @type {?} */
var deformLength = weighted
? (vertices.length / 3) * 2
: vertices.length;
/** @type {?} */
var frameCount = input.readInt(true);
/** @type {?} */
var timeline = new DeformTimeline(frameCount);
timeline.slotIndex = slotIndex;
timeline.attachment = attachment;
for (var frameIndex = 0; frameIndex < frameCount; frameIndex++) {
/** @type {?} */
var time = input.readFloat();
/** @type {?} */
var deform = void 0;
/** @type {?} */
var end = input.readInt(true);
if (end == 0)
deform = weighted ? Utils.newFloatArray(deformLength) : vertices;
else {
deform = Utils.newFloatArray(deformLength);
/** @type {?} */
var start = input.readInt(true);
end += start;
if (scale == 1) {
for (var v = start; v < end; v++)
deform[v] = input.readFloat();
}
else {
for (var v = start; v < end; v++)
deform[v] = input.readFloat() * scale;
}
if (!weighted) {
for (var v = 0, vn = deform.length; v < vn; v++)
deform[v] += vertices[v];
}
}
timeline.setFrame(frameIndex, time, deform);
if (frameIndex < frameCount - 1)
this.readCurve(input, frameIndex, timeline);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[frameCount - 1]);
}
}
}
// Draw order timeline.
/** @type {?} */
var drawOrderCount = input.readInt(true);
if (drawOrderCount > 0) {
/** @type {?} */
var timeline = new DrawOrderTimeline(drawOrderCount);
/** @type {?} */
var slotCount = skeletonData.slots.length;
for (var i = 0; i < drawOrderCount; i++) {
/** @type {?} */
var time = input.readFloat();
/** @type {?} */
var offsetCount = input.readInt(true);
/** @type {?} */
var drawOrder = Utils.newArray(slotCount, 0);
for (var ii = slotCount - 1; ii >= 0; ii--)
drawOrder[ii] = -1;
/** @type {?} */
var unchanged = Utils.newArray(slotCount - offsetCount, 0);
/** @type {?} */
var originalIndex = 0;
/** @type {?} */
var unchangedIndex = 0;
for (var ii = 0; ii < offsetCount; ii++) {
/** @type {?} */
var slotIndex = input.readInt(true);
// Collect unchanged items.
while (originalIndex != slotIndex)
unchanged[unchangedIndex++] = originalIndex++;
// Set changed items.
drawOrder[originalIndex + input.readInt(true)] = originalIndex++;
}
// Collect remaining unchanged items.
while (originalIndex < slotCount)
unchanged[unchangedIndex++] = originalIndex++;
// Fill in unchanged items.
for (var ii = slotCount - 1; ii >= 0; ii--)
if (drawOrder[ii] == -1)
drawOrder[ii] = unchanged[--unchangedIndex];
timeline.setFrame(i, time, drawOrder);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[drawOrderCount - 1]);
}
// Event timeline.
/** @type {?} */
var eventCount = input.readInt(true);
if (eventCount > 0) {
/** @type {?} */
var timeline = new EventTimeline(eventCount);
for (var i = 0; i < eventCount; i++) {
/** @type {?} */
var time = input.readFloat();
/** @type {?} */
var eventData = skeletonData.events[input.readInt(true)];
/** @type {?} */
var event_3 = new Event(time, eventData);
event_3.intValue = input.readInt(false);
event_3.floatValue = input.readFloat();
event_3.stringValue = input.readBoolean()
? input.readString()
: eventData.stringValue;
if (event_3.data.audioPath != null) {
event_3.volume = input.readFloat();
event_3.balance = input.readFloat();
}
timeline.setFrame(i, event_3);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[eventCount - 1]);
}
return new Animation(name, timelines, duration);
};
return SkeletonBinary36;
}(SkeletonBinary));
var BinaryInput = /** @class */ (function () {
function BinaryInput(data, strings, index, buffer) {
if (strings === void 0) { strings = new Array(); }
if (index === void 0) { index = 0; }
if (buffer === void 0) { buffer = new DataView(data.buffer); }
this.strings = strings;
this.index = index;
this.buffer = buffer;
}
/**
* @return {?}
*/
BinaryInput.prototype.readByte = /**
* @return {?}
*/
function () {
return this.buffer.getInt8(this.index++);
};
/**
* @return {?}
*/
BinaryInput.prototype.readShort = /**
* @return {?}
*/
function () {
/** @type {?} */
var value = this.buffer.getInt16(this.index);
this.index += 2;
return value;
};
/**
* @return {?}
*/
BinaryInput.prototype.readInt32 = /**
* @return {?}
*/
function () {
/** @type {?} */
var value = this.buffer.getInt32(this.index);
this.index += 4;
return value;
};
/**
* @param {?} optimizePositive
* @return {?}
*/
BinaryInput.prototype.readInt = /**
* @param {?} optimizePositive
* @return {?}
*/
function (optimizePositive) {
/** @type {?} */
var b = this.readByte();
/** @type {?} */
var result = b & 0x7f;
if ((b & 0x80) != 0) {
b = this.readByte();
result |= (b & 0x7f) << 7;
if ((b & 0x80) != 0) {
b = this.readByte();
result |= (b & 0x7f) << 14;
if ((b & 0x80) != 0) {
b = this.readByte();
result |= (b & 0x7f) << 21;
if ((b & 0x80) != 0) {
b = this.readByte();
result |= (b & 0x7f) << 28;
}
}
}
}
return optimizePositive ? result : (result >>> 1) ^ -(result & 1);
};
/**
* @return {?}
*/
BinaryInput.prototype.readStringRef = /**
* @return {?}
*/
function () {
/** @type {?} */
var index = this.readInt(true);
return index == 0 ? null : this.strings[index - 1];
};
/**
* @return {?}
*/
BinaryInput.prototype.readString = /**
* @return {?}
*/
function () {
/** @type {?} */
var byteCount = this.readInt(true);
switch (byteCount) {
case 0:
return null;
case 1:
return "";
}
byteCount--;
/** @type {?} */
var chars = "";
/** @type {?} */
var charCount = 0;
for (var i = 0; i < byteCount;) {
/** @type {?} */
var b = this.readByte();
switch (b >> 4) {
case 12:
case 13:
chars += String.fromCharCode(((b & 0x1f) << 6) | (this.readByte() & 0x3f));
i += 2;
break;
case 14:
chars += String.fromCharCode(((b & 0x0f) << 12) |
((this.readByte() & 0x3f) << 6) |
(this.readByte() & 0x3f));
i += 3;
break;
default:
chars += String.fromCharCode(b);
i++;
}
}
return chars;
};
/**
* @return {?}
*/
BinaryInput.prototype.readFloat = /**
* @return {?}
*/
function () {
/** @type {?} */
var value = this.buffer.getFloat32(this.index);
this.index += 4;
return value;
};
/**
* @return {?}
*/
BinaryInput.prototype.readBoolean = /**
* @return {?}
*/
function () {
return this.readByte() != 0;
};
return BinaryInput;
}());
if (false) {
/** @type {?} */
BinaryInput.prototype.strings;
/**
* @type {?}
* @private
*/
BinaryInput.prototype.index;
/**
* @type {?}
* @private
*/
BinaryInput.prototype.buffer;
}
var LinkedMesh = /** @class */ (function () {
function LinkedMesh(mesh, skin, slotIndex, parent, inheritDeform) {
this.mesh = mesh;
this.skin = skin;
this.slotIndex = slotIndex;
this.parent = parent;
this.inheritDeform = inheritDeform;
}
return LinkedMesh;
}());
if (false) {
/** @type {?} */
LinkedMesh.prototype.parent;
/** @type {?} */
LinkedMesh.prototype.skin;
/** @type {?} */
LinkedMesh.prototype.slotIndex;
/** @type {?} */
LinkedMesh.prototype.mesh;
/** @type {?} */
LinkedMesh.prototype.inheritDeform;
}
var Vertices = /** @class */ (function () {
function Vertices(bones, vertices) {
if (bones === void 0) { bones = null; }
if (vertices === void 0) { vertices = null; }
this.bones = bones;
this.vertices = vertices;
}
return Vertices;
}());
if (false) {
/** @type {?} */
Vertices.prototype.bones;
/** @type {?} */
Vertices.prototype.vertices;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var SkeletonJson = /** @class */ (function () {
function SkeletonJson(attachmentLoader) {
this.scale = 1;
this.linkedMeshes = new Array();
this.attachmentLoader = attachmentLoader;
}
/**
* @param {?} json
* @return {?}
*/
SkeletonJson.prototype.readSkeletonData = /**
* @param {?} json
* @return {?}
*/
function (json) {
/** @type {?} */
var scale = this.scale;
/** @type {?} */
var skeletonData = new SkeletonData();
/** @type {?} */
var root = typeof json === "string" ? JSON.parse(json) : json;
// Skeleton
/** @type {?} */
var skeletonMap = root.skeleton;
if (skeletonMap != null) {
skeletonData.hash = skeletonMap.hash;
skeletonData.version = skeletonMap.spine;
skeletonData.x = skeletonMap.x;
skeletonData.y = skeletonMap.y;
skeletonData.width = skeletonMap.width;
skeletonData.height = skeletonMap.height;
skeletonData.fps = skeletonMap.fps;
skeletonData.imagesPath = skeletonMap.images;
}
// Bones
if (root.bones) {
for (var i = 0; i < root.bones.length; i++) {
/** @type {?} */
var boneMap = root.bones[i];
/** @type {?} */
var parent_1 = null;
/** @type {?} */
var parentName = this.getValue(boneMap, "parent", null);
if (parentName != null) {
parent_1 = skeletonData.findBone(parentName);
if (parent_1 == null)
throw new Error("Parent bone not found: " + parentName);
}
/** @type {?} */
var data = new BoneData(skeletonData.bones.length, boneMap.name, parent_1);
data.length = this.getValue(boneMap, "length", 0) * scale;
data.x = this.getValue(boneMap, "x", 0) * scale;
data.y = this.getValue(boneMap, "y", 0) * scale;
data.rotation = this.getValue(boneMap, "rotation", 0);
data.scaleX = this.getValue(boneMap, "scaleX", 1);
data.scaleY = this.getValue(boneMap, "scaleY", 1);
data.shearX = this.getValue(boneMap, "shearX", 0);
data.shearY = this.getValue(boneMap, "shearY", 0);
data.transformMode = SkeletonJson.transformModeFromString(this.getValue(boneMap, "transform", "normal"));
data.skinRequired = this.getValue(boneMap, "skin", false);
skeletonData.bones.push(data);
}
}
// Slots.
if (root.slots) {
for (var i = 0; i < root.slots.length; i++) {
/** @type {?} */
var slotMap = root.slots[i];
/** @type {?} */
var slotName = slotMap.name;
/** @type {?} */
var boneName = slotMap.bone;
/** @type {?} */
var boneData = skeletonData.findBone(boneName);
if (boneData == null)
throw new Error("Slot bone not found: " + boneName);
/** @type {?} */
var data = new SlotData(skeletonData.slots.length, slotName, boneData);
/** @type {?} */
var color = this.getValue(slotMap, "color", null);
if (color != null)
data.color.setFromString(color);
/** @type {?} */
var dark = this.getValue(slotMap, "dark", null);
if (dark != null) {
data.darkColor = new Color(1, 1, 1, 1);
data.darkColor.setFromString(dark);
}
data.attachmentName = this.getValue(slotMap, "attachment", null);
data.blendMode = SkeletonJson.blendModeFromString(this.getValue(slotMap, "blend", "normal"));
skeletonData.slots.push(data);
}
}
// IK constraints
if (root.ik) {
for (var i = 0; i < root.ik.length; i++) {
/** @type {?} */
var constraintMap = root.ik[i];
/** @type {?} */
var data = new IkConstraintData(constraintMap.name);
data.order = this.getValue(constraintMap, "order", 0);
data.skinRequired = this.getValue(constraintMap, "skin", false);
for (var j = 0; j < constraintMap.bones.length; j++) {
/** @type {?} */
var boneName = constraintMap.bones[j];
/** @type {?} */
var bone = skeletonData.findBone(boneName);
if (bone == null)
throw new Error("IK bone not found: " + boneName);
data.bones.push(bone);
}
/** @type {?} */
var targetName = constraintMap.target;
data.target = skeletonData.findBone(targetName);
if (data.target == null)
throw new Error("IK target bone not found: " + targetName);
data.mix = this.getValue(constraintMap, "mix", 1);
data.softness = this.getValue(constraintMap, "softness", 0) * scale;
data.bendDirection = this.getValue(constraintMap, "bendPositive", true)
? 1
: -1;
data.compress = this.getValue(constraintMap, "compress", false);
data.stretch = this.getValue(constraintMap, "stretch", false);
data.uniform = this.getValue(constraintMap, "uniform", false);
skeletonData.ikConstraints.push(data);
}
}
// Transform constraints.
if (root.transform) {
for (var i = 0; i < root.transform.length; i++) {
/** @type {?} */
var constraintMap = root.transform[i];
/** @type {?} */
var data = new TransformConstraintData(constraintMap.name);
data.order = this.getValue(constraintMap, "order", 0);
data.skinRequired = this.getValue(constraintMap, "skin", false);
for (var j = 0; j < constraintMap.bones.length; j++) {
/** @type {?} */
var boneName = constraintMap.bones[j];
/** @type {?} */
var bone = skeletonData.findBone(boneName);
if (bone == null)
throw new Error("Transform constraint bone not found: " + boneName);
data.bones.push(bone);
}
/** @type {?} */
var targetName = constraintMap.target;
data.target = skeletonData.findBone(targetName);
if (data.target == null)
throw new Error("Transform constraint target bone not found: " + targetName);
data.local = this.getValue(constraintMap, "local", false);
data.relative = this.getValue(constraintMap, "relative", false);
data.offsetRotation = this.getValue(constraintMap, "rotation", 0);
data.offsetX = this.getValue(constraintMap, "x", 0) * scale;
data.offsetY = this.getValue(constraintMap, "y", 0) * scale;
data.offsetScaleX = this.getValue(constraintMap, "scaleX", 0);
data.offsetScaleY = this.getValue(constraintMap, "scaleY", 0);
data.offsetShearY = this.getValue(constraintMap, "shearY", 0);
data.rotateMix = this.getValue(constraintMap, "rotateMix", 1);
data.translateMix = this.getValue(constraintMap, "translateMix", 1);
data.scaleMix = this.getValue(constraintMap, "scaleMix", 1);
data.shearMix = this.getValue(constraintMap, "shearMix", 1);
skeletonData.transformConstraints.push(data);
}
}
// Path constraints.
if (root.path) {
for (var i = 0; i < root.path.length; i++) {
/** @type {?} */
var constraintMap = root.path[i];
/** @type {?} */
var data = new PathConstraintData(constraintMap.name);
data.order = this.getValue(constraintMap, "order", 0);
data.skinRequired = this.getValue(constraintMap, "skin", false);
for (var j = 0; j < constraintMap.bones.length; j++) {
/** @type {?} */
var boneName = constraintMap.bones[j];
/** @type {?} */
var bone = skeletonData.findBone(boneName);
if (bone == null)
throw new Error("Transform constraint bone not found: " + boneName);
data.bones.push(bone);
}
/** @type {?} */
var targetName = constraintMap.target;
data.target = skeletonData.findSlot(targetName);
if (data.target == null)
throw new Error("Path target slot not found: " + targetName);
data.positionMode = SkeletonJson.positionModeFromString(this.getValue(constraintMap, "positionMode", "percent"));
data.spacingMode = SkeletonJson.spacingModeFromString(this.getValue(constraintMap, "spacingMode", "length"));
data.rotateMode = SkeletonJson.rotateModeFromString(this.getValue(constraintMap, "rotateMode", "tangent"));
data.offsetRotation = this.getValue(constraintMap, "rotation", 0);
data.position = this.getValue(constraintMap, "position", 0);
if (data.positionMode == PositionMode.Fixed)
data.position *= scale;
data.spacing = this.getValue(constraintMap, "spacing", 0);
if (data.spacingMode == SpacingMode.Length ||
data.spacingMode == SpacingMode.Fixed)
data.spacing *= scale;
data.rotateMix = this.getValue(constraintMap, "rotateMix", 1);
data.translateMix = this.getValue(constraintMap, "translateMix", 1);
skeletonData.pathConstraints.push(data);
}
}
// Skins.
if (root.skins) {
for (var i = 0; i < root.skins.length; i++) {
/** @type {?} */
var skinMap = root.skins[i];
/** @type {?} */
var skin = new Skin(skinMap.name);
if (skinMap.bones) {
for (var ii = 0; ii < skinMap.bones.length; ii++) {
/** @type {?} */
var bone = skeletonData.findBone(skinMap.bones[ii]);
if (bone == null)
throw new Error("Skin bone not found: " + skinMap.bones[i]);
skin.bones.push(bone);
}
}
if (skinMap.ik) {
for (var ii = 0; ii < skinMap.ik.length; ii++) {
/** @type {?} */
var constraint = skeletonData.findIkConstraint(skinMap.ik[ii]);
if (constraint == null)
throw new Error("Skin IK constraint not found: " + skinMap.ik[i]);
skin.constraints.push(constraint);
}
}
if (skinMap.transform) {
for (var ii = 0; ii < skinMap.transform.length; ii++) {
/** @type {?} */
var constraint = skeletonData.findTransformConstraint(skinMap.transform[ii]);
if (constraint == null)
throw new Error("Skin transform constraint not found: " + skinMap.transform[i]);
skin.constraints.push(constraint);
}
}
if (skinMap.path) {
for (var ii = 0; ii < skinMap.path.length; ii++) {
/** @type {?} */
var constraint = skeletonData.findPathConstraint(skinMap.path[ii]);
if (constraint == null)
throw new Error("Skin path constraint not found: " + skinMap.path[i]);
skin.constraints.push(constraint);
}
}
for (var slotName in skinMap.attachments) {
/** @type {?} */
var slot = skeletonData.findSlot(slotName);
if (slot == null)
throw new Error("Slot not found: " + slotName);
/** @type {?} */
var slotMap = skinMap.attachments[slotName];
for (var entryName in slotMap) {
/** @type {?} */
var attachment = this.readAttachment(slotMap[entryName], skin, slot.index, entryName, skeletonData);
if (attachment != null)
skin.setAttachment(slot.index, entryName, attachment);
}
}
skeletonData.skins.push(skin);
if (skin.name == "default")
skeletonData.defaultSkin = skin;
}
}
// Linked meshes.
for (var i = 0, n = this.linkedMeshes.length; i < n; i++) {
/** @type {?} */
var linkedMesh = this.linkedMeshes[i];
/** @type {?} */
var skin = linkedMesh.skin == null
? skeletonData.defaultSkin
: skeletonData.findSkin(linkedMesh.skin);
if (skin == null)
throw new Error("Skin not found: " + linkedMesh.skin);
/** @type {?} */
var parent_2 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
if (parent_2 == null)
throw new Error("Parent mesh not found: " + linkedMesh.parent);
linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform
? (/** @type {?} */ (parent_2))
: (/** @type {?} */ (linkedMesh.mesh));
linkedMesh.mesh.setParentMesh((/** @type {?} */ (parent_2)));
linkedMesh.mesh.updateUVs();
}
this.linkedMeshes.length = 0;
// Events.
if (root.events) {
for (var eventName in root.events) {
/** @type {?} */
var eventMap = root.events[eventName];
/** @type {?} */
var data = new EventData(eventName);
data.intValue = this.getValue(eventMap, "int", 0);
data.floatValue = this.getValue(eventMap, "float", 0);
data.stringValue = this.getValue(eventMap, "string", "");
data.audioPath = this.getValue(eventMap, "audio", null);
if (data.audioPath != null) {
data.volume = this.getValue(eventMap, "volume", 1);
data.balance = this.getValue(eventMap, "balance", 0);
}
skeletonData.events.push(data);
}
}
// Animations.
if (root.animations) {
for (var animationName in root.animations) {
/** @type {?} */
var animationMap = root.animations[animationName];
this.readAnimation(animationMap, animationName, skeletonData);
}
}
return skeletonData;
};
/**
* @param {?} map
* @param {?} skin
* @param {?} slotIndex
* @param {?} name
* @param {?} skeletonData
* @return {?}
*/
SkeletonJson.prototype.readAttachment = /**
* @param {?} map
* @param {?} skin
* @param {?} slotIndex
* @param {?} name
* @param {?} skeletonData
* @return {?}
*/
function (map, skin, slotIndex, name, skeletonData) {
/** @type {?} */
var scale = this.scale;
name = this.getValue(map, "name", name);
/** @type {?} */
var type = this.getValue(map, "type", "region");
switch (type) {
case "region": {
/** @type {?} */
var path = this.getValue(map, "path", name);
/** @type {?} */
var region = this.attachmentLoader.newRegionAttachment(skin, name, path);
if (region == null)
return null;
region.path = path;
region.x = this.getValue(map, "x", 0) * scale;
region.y = this.getValue(map, "y", 0) * scale;
region.scaleX = this.getValue(map, "scaleX", 1);
region.scaleY = this.getValue(map, "scaleY", 1);
region.rotation = this.getValue(map, "rotation", 0);
region.width = map.width * scale;
region.height = map.height * scale;
/** @type {?} */
var color = this.getValue(map, "color", null);
if (color != null)
region.color.setFromString(color);
region.updateOffset();
return region;
}
case "boundingbox": {
/** @type {?} */
var box = this.attachmentLoader.newBoundingBoxAttachment(skin, name);
if (box == null)
return null;
this.readVertices(map, box, map.vertexCount << 1);
/** @type {?} */
var color = this.getValue(map, "color", null);
if (color != null)
box.color.setFromString(color);
return box;
}
case "mesh":
case "linkedmesh": {
/** @type {?} */
var path = this.getValue(map, "path", name);
/** @type {?} */
var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path);
if (mesh == null)
return null;
mesh.path = path;
/** @type {?} */
var color = this.getValue(map, "color", null);
if (color != null)
mesh.color.setFromString(color);
mesh.width = this.getValue(map, "width", 0) * scale;
mesh.height = this.getValue(map, "height", 0) * scale;
/** @type {?} */
var parent_3 = this.getValue(map, "parent", null);
if (parent_3 != null) {
this.linkedMeshes.push(new LinkedMesh$1(mesh, (/** @type {?} */ (this.getValue(map, "skin", null))), slotIndex, parent_3, this.getValue(map, "deform", true)));
return mesh;
}
/** @type {?} */
var uvs = map.uvs;
this.readVertices(map, mesh, uvs.length);
mesh.triangles = map.triangles;
mesh.regionUVs = uvs;
mesh.updateUVs();
mesh.edges = this.getValue(map, "edges", null);
mesh.hullLength = this.getValue(map, "hull", 0) * 2;
return mesh;
}
case "path": {
/** @type {?} */
var path = this.attachmentLoader.newPathAttachment(skin, name);
if (path == null)
return null;
path.closed = this.getValue(map, "closed", false);
path.constantSpeed = this.getValue(map, "constantSpeed", true);
/** @type {?} */
var vertexCount = map.vertexCount;
this.readVertices(map, path, vertexCount << 1);
/** @type {?} */
var lengths = Utils.newArray(vertexCount / 3, 0);
for (var i = 0; i < map.lengths.length; i++)
lengths[i] = map.lengths[i] * scale;
path.lengths = lengths;
/** @type {?} */
var color = this.getValue(map, "color", null);
if (color != null)
path.color.setFromString(color);
return path;
}
case "point": {
/** @type {?} */
var point = this.attachmentLoader.newPointAttachment(skin, name);
if (point == null)
return null;
point.x = this.getValue(map, "x", 0) * scale;
point.y = this.getValue(map, "y", 0) * scale;
point.rotation = this.getValue(map, "rotation", 0);
/** @type {?} */
var color = this.getValue(map, "color", null);
if (color != null)
point.color.setFromString(color);
return point;
}
case "clipping": {
/** @type {?} */
var clip = this.attachmentLoader.newClippingAttachment(skin, name);
if (clip == null)
return null;
/** @type {?} */
var end = this.getValue(map, "end", null);
if (end != null) {
/** @type {?} */
var slot = skeletonData.findSlot(end);
if (slot == null)
throw new Error("Clipping end slot not found: " + end);
clip.endSlot = slot;
}
/** @type {?} */
var vertexCount = map.vertexCount;
this.readVertices(map, clip, vertexCount << 1);
/** @type {?} */
var color = this.getValue(map, "color", null);
if (color != null)
clip.color.setFromString(color);
return clip;
}
}
return null;
};
/**
* @param {?} map
* @param {?} attachment
* @param {?} verticesLength
* @return {?}
*/
SkeletonJson.prototype.readVertices = /**
* @param {?} map
* @param {?} attachment
* @param {?} verticesLength
* @return {?}
*/
function (map, attachment, verticesLength) {
/** @type {?} */
var scale = this.scale;
attachment.worldVerticesLength = verticesLength;
/** @type {?} */
var vertices = map.vertices;
if (verticesLength == vertices.length) {
/** @type {?} */
var scaledVertices = Utils.toFloatArray(vertices);
if (scale != 1) {
for (var i = 0, n = vertices.length; i < n; i++)
scaledVertices[i] *= scale;
}
attachment.vertices = scaledVertices;
return;
}
/** @type {?} */
var weights = new Array();
/** @type {?} */
var bones = new Array();
for (var i = 0, n = vertices.length; i < n;) {
/** @type {?} */
var boneCount = vertices[i++];
bones.push(boneCount);
for (var nn = i + boneCount * 4; i < nn; i += 4) {
bones.push(vertices[i]);
weights.push(vertices[i + 1] * scale);
weights.push(vertices[i + 2] * scale);
weights.push(vertices[i + 3]);
}
}
attachment.bones = bones;
attachment.vertices = Utils.toFloatArray(weights);
};
/**
* @param {?} map
* @param {?} name
* @param {?} skeletonData
* @return {?}
*/
SkeletonJson.prototype.readAnimation = /**
* @param {?} map
* @param {?} name
* @param {?} skeletonData
* @return {?}
*/
function (map, name, skeletonData) {
/** @type {?} */
var scale = this.scale;
/** @type {?} */
var timelines = new Array();
/** @type {?} */
var duration = 0;
// Slot timelines.
if (map.slots) {
for (var slotName in map.slots) {
/** @type {?} */
var slotMap = map.slots[slotName];
/** @type {?} */
var slotIndex = skeletonData.findSlotIndex(slotName);
if (slotIndex == -1)
throw new Error("Slot not found: " + slotName);
for (var timelineName in slotMap) {
/** @type {?} */
var timelineMap = slotMap[timelineName];
if (timelineName == "attachment") {
/** @type {?} */
var timeline = new AttachmentTimeline(timelineMap.length);
timeline.slotIndex = slotIndex;
/** @type {?} */
var frameIndex = 0;
for (var i = 0; i < timelineMap.length; i++) {
/** @type {?} */
var valueMap = timelineMap[i];
timeline.setFrame(frameIndex++, this.getValue(valueMap, "time", 0), valueMap.name);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]);
}
else if (timelineName == "color") {
/** @type {?} */
var timeline = new ColorTimeline(timelineMap.length);
timeline.slotIndex = slotIndex;
/** @type {?} */
var frameIndex = 0;
for (var i = 0; i < timelineMap.length; i++) {
/** @type {?} */
var valueMap = timelineMap[i];
/** @type {?} */
var color = new Color();
color.setFromString(valueMap.color);
timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), color.r, color.g, color.b, color.a);
this.readCurve(valueMap, timeline, frameIndex);
frameIndex++;
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * ColorTimeline.ENTRIES]);
}
else if (timelineName == "twoColor") {
/** @type {?} */
var timeline = new TwoColorTimeline(timelineMap.length);
timeline.slotIndex = slotIndex;
/** @type {?} */
var frameIndex = 0;
for (var i = 0; i < timelineMap.length; i++) {
/** @type {?} */
var valueMap = timelineMap[i];
/** @type {?} */
var light = new Color();
/** @type {?} */
var dark = new Color();
light.setFromString(valueMap.light);
dark.setFromString(valueMap.dark);
timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), light.r, light.g, light.b, light.a, dark.r, dark.g, dark.b);
this.readCurve(valueMap, timeline, frameIndex);
frameIndex++;
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * TwoColorTimeline.ENTRIES]);
}
else
throw new Error("Invalid timeline type for a slot: " +
timelineName +
" (" +
slotName +
")");
}
}
}
// Bone timelines.
if (map.bones) {
for (var boneName in map.bones) {
/** @type {?} */
var boneMap = map.bones[boneName];
/** @type {?} */
var boneIndex = skeletonData.findBoneIndex(boneName);
if (boneIndex == -1)
throw new Error("Bone not found: " + boneName);
for (var timelineName in boneMap) {
/** @type {?} */
var timelineMap = boneMap[timelineName];
if (timelineName === "rotate") {
/** @type {?} */
var timeline = new RotateTimeline(timelineMap.length);
timeline.boneIndex = boneIndex;
/** @type {?} */
var frameIndex = 0;
for (var i = 0; i < timelineMap.length; i++) {
/** @type {?} */
var valueMap = timelineMap[i];
timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), this.getValue(valueMap, "angle", 0));
this.readCurve(valueMap, timeline, frameIndex);
frameIndex++;
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * RotateTimeline.ENTRIES]);
}
else if (timelineName === "translate" ||
timelineName === "scale" ||
timelineName === "shear") {
/** @type {?} */
var timeline = null;
/** @type {?} */
var timelineScale = 1;
/** @type {?} */
var defaultValue = 0;
if (timelineName === "scale") {
timeline = new ScaleTimeline(timelineMap.length);
defaultValue = 1;
}
else if (timelineName === "shear")
timeline = new ShearTimeline(timelineMap.length);
else {
timeline = new TranslateTimeline(timelineMap.length);
timelineScale = scale;
}
timeline.boneIndex = boneIndex;
/** @type {?} */
var frameIndex = 0;
for (var i = 0; i < timelineMap.length; i++) {
/** @type {?} */
var valueMap = timelineMap[i];
/** @type {?} */
var x = this.getValue(valueMap, "x", defaultValue);
/** @type {?} */
var y = this.getValue(valueMap, "y", defaultValue);
timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), x * timelineScale, y * timelineScale);
this.readCurve(valueMap, timeline, frameIndex);
frameIndex++;
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * TranslateTimeline.ENTRIES]);
}
else
throw new Error("Invalid timeline type for a bone: " +
timelineName +
" (" +
boneName +
")");
}
}
}
// IK constraint timelines.
if (map.ik) {
for (var constraintName in map.ik) {
/** @type {?} */
var constraintMap = map.ik[constraintName];
/** @type {?} */
var constraint = skeletonData.findIkConstraint(constraintName);
/** @type {?} */
var timeline = new IkConstraintTimeline(constraintMap.length);
timeline.ikConstraintIndex = skeletonData.ikConstraints.indexOf(constraint);
/** @type {?} */
var frameIndex = 0;
for (var i = 0; i < constraintMap.length; i++) {
/** @type {?} */
var valueMap = constraintMap[i];
timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), this.getValue(valueMap, "mix", 1), this.getValue(valueMap, "softness", 0) * scale, this.getValue(valueMap, "bendPositive", true) ? 1 : -1, this.getValue(valueMap, "compress", false), this.getValue(valueMap, "stretch", false));
this.readCurve(valueMap, timeline, frameIndex);
frameIndex++;
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * IkConstraintTimeline.ENTRIES]);
}
}
// Transform constraint timelines.
if (map.transform) {
for (var constraintName in map.transform) {
/** @type {?} */
var constraintMap = map.transform[constraintName];
/** @type {?} */
var constraint = skeletonData.findTransformConstraint(constraintName);
/** @type {?} */
var timeline = new TransformConstraintTimeline(constraintMap.length);
timeline.transformConstraintIndex = skeletonData.transformConstraints.indexOf(constraint);
/** @type {?} */
var frameIndex = 0;
for (var i = 0; i < constraintMap.length; i++) {
/** @type {?} */
var valueMap = constraintMap[i];
timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), this.getValue(valueMap, "rotateMix", 1), this.getValue(valueMap, "translateMix", 1), this.getValue(valueMap, "scaleMix", 1), this.getValue(valueMap, "shearMix", 1));
this.readCurve(valueMap, timeline, frameIndex);
frameIndex++;
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * TransformConstraintTimeline.ENTRIES]);
}
}
// Path constraint timelines.
if (map.path) {
for (var constraintName in map.path) {
/** @type {?} */
var constraintMap = map.path[constraintName];
/** @type {?} */
var index = skeletonData.findPathConstraintIndex(constraintName);
if (index == -1)
throw new Error("Path constraint not found: " + constraintName);
/** @type {?} */
var data = skeletonData.pathConstraints[index];
for (var timelineName in constraintMap) {
/** @type {?} */
var timelineMap = constraintMap[timelineName];
if (timelineName === "position" || timelineName === "spacing") {
/** @type {?} */
var timeline = null;
/** @type {?} */
var timelineScale = 1;
if (timelineName === "spacing") {
timeline = new PathConstraintSpacingTimeline(timelineMap.length);
if (data.spacingMode == SpacingMode.Length ||
data.spacingMode == SpacingMode.Fixed)
timelineScale = scale;
}
else {
timeline = new PathConstraintPositionTimeline(timelineMap.length);
if (data.positionMode == PositionMode.Fixed)
timelineScale = scale;
}
timeline.pathConstraintIndex = index;
/** @type {?} */
var frameIndex = 0;
for (var i = 0; i < timelineMap.length; i++) {
/** @type {?} */
var valueMap = timelineMap[i];
timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), this.getValue(valueMap, timelineName, 0) * timelineScale);
this.readCurve(valueMap, timeline, frameIndex);
frameIndex++;
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) *
PathConstraintPositionTimeline.ENTRIES]);
}
else if (timelineName === "mix") {
/** @type {?} */
var timeline = new PathConstraintMixTimeline(timelineMap.length);
timeline.pathConstraintIndex = index;
/** @type {?} */
var frameIndex = 0;
for (var i = 0; i < timelineMap.length; i++) {
/** @type {?} */
var valueMap = timelineMap[i];
timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), this.getValue(valueMap, "rotateMix", 1), this.getValue(valueMap, "translateMix", 1));
this.readCurve(valueMap, timeline, frameIndex);
frameIndex++;
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) *
PathConstraintMixTimeline.ENTRIES]);
}
}
}
}
// Deform timelines.
if (map.deform) {
for (var deformName in map.deform) {
/** @type {?} */
var deformMap = map.deform[deformName];
/** @type {?} */
var skin = skeletonData.findSkin(deformName);
if (skin == null)
throw new Error("Skin not found: " + deformName);
for (var slotName in deformMap) {
/** @type {?} */
var slotMap = deformMap[slotName];
/** @type {?} */
var slotIndex = skeletonData.findSlotIndex(slotName);
if (slotIndex == -1)
throw new Error("Slot not found: " + slotMap.name);
for (var timelineName in slotMap) {
/** @type {?} */
var timelineMap = slotMap[timelineName];
/** @type {?} */
var attachment = (/** @type {?} */ ((skin.getAttachment(slotIndex, timelineName))));
if (attachment == null)
throw new Error("Deform attachment not found: " + timelineMap.name);
/** @type {?} */
var weighted = attachment.bones != null;
/** @type {?} */
var vertices = attachment.vertices;
/** @type {?} */
var deformLength = weighted
? (vertices.length / 3) * 2
: vertices.length;
/** @type {?} */
var timeline = new DeformTimeline(timelineMap.length);
timeline.slotIndex = slotIndex;
timeline.attachment = attachment;
/** @type {?} */
var frameIndex = 0;
for (var j = 0; j < timelineMap.length; j++) {
/** @type {?} */
var valueMap = timelineMap[j];
/** @type {?} */
var deform = void 0;
/** @type {?} */
var verticesValue = this.getValue(valueMap, "vertices", null);
if (verticesValue == null)
deform = weighted
? Utils.newFloatArray(deformLength)
: vertices;
else {
deform = Utils.newFloatArray(deformLength);
/** @type {?} */
var start = (/** @type {?} */ (this.getValue(valueMap, "offset", 0)));
Utils.arrayCopy(verticesValue, 0, deform, start, verticesValue.length);
if (scale != 1) {
for (var i = start, n = i + verticesValue.length; i < n; i++)
deform[i] *= scale;
}
if (!weighted) {
for (var i = 0; i < deformLength; i++)
deform[i] += vertices[i];
}
}
timeline.setFrame(frameIndex, this.getValue(valueMap, "time", 0), deform);
this.readCurve(valueMap, timeline, frameIndex);
frameIndex++;
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]);
}
}
}
}
// Draw order timeline.
/** @type {?} */
var drawOrderNode = map.drawOrder;
if (drawOrderNode == null)
drawOrderNode = map.draworder;
if (drawOrderNode != null) {
/** @type {?} */
var timeline = new DrawOrderTimeline(drawOrderNode.length);
/** @type {?} */
var slotCount = skeletonData.slots.length;
/** @type {?} */
var frameIndex = 0;
for (var j = 0; j < drawOrderNode.length; j++) {
/** @type {?} */
var drawOrderMap = drawOrderNode[j];
/** @type {?} */
var drawOrder = null;
/** @type {?} */
var offsets = this.getValue(drawOrderMap, "offsets", null);
if (offsets != null) {
drawOrder = Utils.newArray(slotCount, -1);
/** @type {?} */
var unchanged = Utils.newArray(slotCount - offsets.length, 0);
/** @type {?} */
var originalIndex = 0;
/** @type {?} */
var unchangedIndex = 0;
for (var i = 0; i < offsets.length; i++) {
/** @type {?} */
var offsetMap = offsets[i];
/** @type {?} */
var slotIndex = skeletonData.findSlotIndex(offsetMap.slot);
if (slotIndex == -1)
throw new Error("Slot not found: " + offsetMap.slot);
// Collect unchanged items.
while (originalIndex != slotIndex)
unchanged[unchangedIndex++] = originalIndex++;
// Set changed items.
drawOrder[originalIndex + offsetMap.offset] = originalIndex++;
}
// Collect remaining unchanged items.
while (originalIndex < slotCount)
unchanged[unchangedIndex++] = originalIndex++;
// Fill in unchanged items.
for (var i = slotCount - 1; i >= 0; i--)
if (drawOrder[i] == -1)
drawOrder[i] = unchanged[--unchangedIndex];
}
timeline.setFrame(frameIndex++, this.getValue(drawOrderMap, "time", 0), drawOrder);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]);
}
// Event timeline.
if (map.events) {
/** @type {?} */
var timeline = new EventTimeline(map.events.length);
/** @type {?} */
var frameIndex = 0;
for (var i = 0; i < map.events.length; i++) {
/** @type {?} */
var eventMap = map.events[i];
/** @type {?} */
var eventData = skeletonData.findEvent(eventMap.name);
if (eventData == null)
throw new Error("Event not found: " + eventMap.name);
/** @type {?} */
var event_1 = new Event(Utils.toSinglePrecision(this.getValue(eventMap, "time", 0)), eventData);
event_1.intValue = this.getValue(eventMap, "int", eventData.intValue);
event_1.floatValue = this.getValue(eventMap, "float", eventData.floatValue);
event_1.stringValue = this.getValue(eventMap, "string", eventData.stringValue);
if (event_1.data.audioPath != null) {
event_1.volume = this.getValue(eventMap, "volume", 1);
event_1.balance = this.getValue(eventMap, "balance", 0);
}
timeline.setFrame(frameIndex++, event_1);
}
timelines.push(timeline);
duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]);
}
if (isNaN(duration)) {
throw new Error("Error while parsing animation, duration is NaN");
}
skeletonData.animations.push(new Animation(name, timelines, duration));
};
/**
* @param {?} map
* @param {?} timeline
* @param {?} frameIndex
* @return {?}
*/
SkeletonJson.prototype.readCurve = /**
* @param {?} map
* @param {?} timeline
* @param {?} frameIndex
* @return {?}
*/
function (map, timeline, frameIndex) {
if (!map.curve)
return;
if (map.curve == "stepped")
timeline.setStepped(frameIndex);
else {
/** @type {?} */
var curve = map.curve;
timeline.setCurve(frameIndex, curve, this.getValue(map, "c2", 0), this.getValue(map, "c3", 1), this.getValue(map, "c4", 1));
}
};
/**
* @param {?} map
* @param {?} prop
* @param {?} defaultValue
* @return {?}
*/
SkeletonJson.prototype.getValue = /**
* @param {?} map
* @param {?} prop
* @param {?} defaultValue
* @return {?}
*/
function (map, prop, defaultValue) {
return map[prop] !== undefined ? map[prop] : defaultValue;
};
/**
* @param {?} str
* @return {?}
*/
SkeletonJson.blendModeFromString = /**
* @param {?} str
* @return {?}
*/
function (str) {
str = str.toLowerCase();
if (str == "normal")
return BlendMode.Normal;
if (str == "additive")
return BlendMode.Additive;
if (str == "multiply")
return BlendMode.Multiply;
if (str == "screen")
return BlendMode.Screen;
throw new Error("Unknown blend mode: " + str);
};
/**
* @param {?} str
* @return {?}
*/
SkeletonJson.positionModeFromString = /**
* @param {?} str
* @return {?}
*/
function (str) {
str = str.toLowerCase();
if (str == "fixed")
return PositionMode.Fixed;
if (str == "percent")
return PositionMode.Percent;
throw new Error("Unknown position mode: " + str);
};
/**
* @param {?} str
* @return {?}
*/
SkeletonJson.spacingModeFromString = /**
* @param {?} str
* @return {?}
*/
function (str) {
str = str.toLowerCase();
if (str == "length")
return SpacingMode.Length;
if (str == "fixed")
return SpacingMode.Fixed;
if (str == "percent")
return SpacingMode.Percent;
throw new Error("Unknown position mode: " + str);
};
/**
* @param {?} str
* @return {?}
*/
SkeletonJson.rotateModeFromString = /**
* @param {?} str
* @return {?}
*/
function (str) {
str = str.toLowerCase();
if (str == "tangent")
return RotateMode.Tangent;
if (str == "chain")
return RotateMode.Chain;
if (str == "chainscale")
return RotateMode.ChainScale;
throw new Error("Unknown rotate mode: " + str);
};
/**
* @param {?} str
* @return {?}
*/
SkeletonJson.transformModeFromString = /**
* @param {?} str
* @return {?}
*/
function (str) {
str = str.toLowerCase();
if (str == "normal")
return TransformMode.Normal;
if (str == "onlytranslation")
return TransformMode.OnlyTranslation;
if (str == "norotationorreflection")
return TransformMode.NoRotationOrReflection;
if (str == "noscale")
return TransformMode.NoScale;
if (str == "noscaleorreflection")
return TransformMode.NoScaleOrReflection;
throw new Error("Unknown transform mode: " + str);
};
return SkeletonJson;
}());
if (false) {
/** @type {?} */
SkeletonJson.prototype.attachmentLoader;
/** @type {?} */
SkeletonJson.prototype.scale;
/**
* @type {?}
* @private
*/
SkeletonJson.prototype.linkedMeshes;
}
var LinkedMesh$1 = /** @class */ (function () {
function LinkedMesh(mesh, skin, slotIndex, parent, inheritDeform) {
this.mesh = mesh;
this.skin = skin;
this.slotIndex = slotIndex;
this.parent = parent;
this.inheritDeform = inheritDeform;
}
return LinkedMesh;
}());
if (false) {
/** @type {?} */
LinkedMesh$1.prototype.parent;
/** @type {?} */
LinkedMesh$1.prototype.skin;
/** @type {?} */
LinkedMesh$1.prototype.slotIndex;
/** @type {?} */
LinkedMesh$1.prototype.mesh;
/** @type {?} */
LinkedMesh$1.prototype.inheritDeform;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* ***************************************************************************
* Spine Runtimes License Agreement
* Last updated May 1, 2019. Replaces all prior versions.
*
* Copyright (c) 2013-2019, Esoteric Software LLC
*
* Integration of the Spine Runtimes into software or otherwise creating
* derivative works of the Spine Runtimes is permitted under the terms and
* conditions of Section 2 of the Spine Editor License Agreement:
* http://esotericsoftware.com/spine-editor-license
*
* Otherwise, it is permitted to integrate the Spine Runtimes into software
* or otherwise create derivative works of the Spine Runtimes (collectively,
* "Products"), provided that each user of the Products must obtain their own
* Spine Editor license and redistribution of the Products in any form must
* include this license and copyright notice.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
* INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ***************************************************************************
* @record
*/
function Updatable() { }
if (false) {
/**
* @return {?}
*/
Updatable.prototype.update = function () { };
/**
* @return {?}
*/
Updatable.prototype.isActive = function () { };
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/******************************************************************************
* Spine Runtimes License Agreement
* Last updated May 1, 2019. Replaces all prior versions.
*
* Copyright (c) 2013-2019, Esoteric Software LLC
*
* Integration of the Spine Runtimes into software or otherwise creating
* derivative works of the Spine Runtimes is permitted under the terms and
* conditions of Section 2 of the Spine Editor License Agreement:
* http://esotericsoftware.com/spine-editor-license
*
* Otherwise, it is permitted to integrate the Spine Runtimes into software
* or otherwise create derivative works of the Spine Runtimes (collectively,
* "Products"), provided that each user of the Products must obtain their own
* Spine Editor license and redistribution of the Products in any form must
* include this license and copyright notice.
*
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
* INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
/**
* @record
*/
function VertexEffect() { }
if (false) {
/**
* @param {?} skeleton
* @return {?}
*/
VertexEffect.prototype.begin = function (skeleton) { };
/**
* @param {?} position
* @param {?} uv
* @param {?} light
* @param {?} dark
* @return {?}
*/
VertexEffect.prototype.transform = function (position, uv, light, dark) { };
/**
* @return {?}
*/
VertexEffect.prototype.end = function () { };
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @record
*/
function AttachmentLoader() { }
if (false) {
/**
* @param {?} skin
* @param {?} name
* @param {?} path
* @return {?} May be null to not load an attachment.
*/
AttachmentLoader.prototype.newRegionAttachment = function (skin, name, path) { };
/**
* @param {?} skin
* @param {?} name
* @param {?} path
* @return {?} May be null to not load an attachment.
*/
AttachmentLoader.prototype.newMeshAttachment = function (skin, name, path) { };
/**
* @param {?} skin
* @param {?} name
* @return {?} May be null to not load an attachment.
*/
AttachmentLoader.prototype.newBoundingBoxAttachment = function (skin, name) { };
/**
* @param {?} skin
* @param {?} name
* @return {?} May be null to not load an attachment
*/
AttachmentLoader.prototype.newPathAttachment = function (skin, name) { };
/**
* @param {?} skin
* @param {?} name
* @return {?} May be null to not load an attachment
*/
AttachmentLoader.prototype.newPointAttachment = function (skin, name) { };
/**
* @param {?} skin
* @param {?} name
* @return {?} May be null to not load an attachment
*/
AttachmentLoader.prototype.newClippingAttachment = function (skin, name) { };
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var JitterEffect = /** @class */ (function () {
function JitterEffect(jitterX, jitterY) {
this.jitterX = 0;
this.jitterY = 0;
this.jitterX = jitterX;
this.jitterY = jitterY;
}
/**
* @param {?} skeleton
* @return {?}
*/
JitterEffect.prototype.begin = /**
* @param {?} skeleton
* @return {?}
*/
function (skeleton) { };
/**
* @param {?} position
* @param {?} uv
* @param {?} light
* @param {?} dark
* @return {?}
*/
JitterEffect.prototype.transform = /**
* @param {?} position
* @param {?} uv
* @param {?} light
* @param {?} dark
* @return {?}
*/
function (position, uv, light, dark) {
position.x += MathUtils.randomTriangular(-this.jitterX, this.jitterY);
position.y += MathUtils.randomTriangular(-this.jitterX, this.jitterY);
};
/**
* @return {?}
*/
JitterEffect.prototype.end = /**
* @return {?}
*/
function () { };
return JitterEffect;
}());
if (false) {
/** @type {?} */
JitterEffect.prototype.jitterX;
/** @type {?} */
JitterEffect.prototype.jitterY;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var SwirlEffect = /** @class */ (function () {
function SwirlEffect(radius) {
this.centerX = 0;
this.centerY = 0;
this.radius = 0;
this.angle = 0;
this.worldX = 0;
this.worldY = 0;
this.radius = radius;
}
/**
* @param {?} skeleton
* @return {?}
*/
SwirlEffect.prototype.begin = /**
* @param {?} skeleton
* @return {?}
*/
function (skeleton) {
this.worldX = skeleton.x + this.centerX;
this.worldY = skeleton.y + this.centerY;
};
/**
* @param {?} position
* @param {?} uv
* @param {?} light
* @param {?} dark
* @return {?}
*/
SwirlEffect.prototype.transform = /**
* @param {?} position
* @param {?} uv
* @param {?} light
* @param {?} dark
* @return {?}
*/
function (position, uv, light, dark) {
/** @type {?} */
var radAngle = this.angle * MathUtils.degreesToRadians;
/** @type {?} */
var x = position.x - this.worldX;
/** @type {?} */
var y = position.y - this.worldY;
/** @type {?} */
var dist = Math.sqrt(x * x + y * y);
if (dist < this.radius) {
/** @type {?} */
var theta = SwirlEffect.interpolation.apply(0, radAngle, (this.radius - dist) / this.radius);
/** @type {?} */
var cos = Math.cos(theta);
/** @type {?} */
var sin = Math.sin(theta);
position.x = cos * x - sin * y + this.worldX;
position.y = sin * x + cos * y + this.worldY;
}
};
/**
* @return {?}
*/
SwirlEffect.prototype.end = /**
* @return {?}
*/
function () { };
SwirlEffect.interpolation = new PowOut(2);
return SwirlEffect;
}());
if (false) {
/** @type {?} */
SwirlEffect.interpolation;
/** @type {?} */
SwirlEffect.prototype.centerX;
/** @type {?} */
SwirlEffect.prototype.centerY;
/** @type {?} */
SwirlEffect.prototype.radius;
/** @type {?} */
SwirlEffect.prototype.angle;
/**
* @type {?}
* @private
*/
SwirlEffect.prototype.worldX;
/**
* @type {?}
* @private
*/
SwirlEffect.prototype.worldY;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @record
*/
function Viewport() { }
if (false) {
/** @type {?} */
Viewport.prototype.x;
/** @type {?} */
Viewport.prototype.y;
/** @type {?} */
Viewport.prototype.width;
/** @type {?} */
Viewport.prototype.height;
/** @type {?} */
Viewport.prototype.padLeft;
/** @type {?} */
Viewport.prototype.padRight;
/** @type {?} */
Viewport.prototype.padTop;
/** @type {?} */
Viewport.prototype.padBottom;
}
/**
* @record
*/
function DataUrls() { }
if (false) {
/** @type {?|undefined} */
DataUrls.prototype.json;
/** @type {?|undefined} */
DataUrls.prototype.skel;
/** @type {?} */
DataUrls.prototype.atlas;
}
var NgxSpineWebglComponent = /** @class */ (function () {
function NgxSpineWebglComponent() {
/* Optional: the default mix time used to switch between two animations. */
this.defaultMix = 0.25;
/* Optional: whether the skeleton uses premultiplied alpha. Default: true. */
this.premultipliedAlpha = true;
this.transitionTime = 0.2;
this.speed = 1;
// The name of the animation to be played. Default: first animation in the skeleton.
this.animationValue = null;
this.animationChange = new core.EventEmitter();
/* Optional: list of animation names from which the user can choose. */
this.animationsValue = [];
this.animationsChange = new core.EventEmitter();
/* Optional: the name of the skin to be set. Default: the default skin. */
this.skinValue = null;
this.skinChange = new core.EventEmitter();
/* Optional: list of skin names from which the user can choose. */
this.skinsValue = [];
this.skinsChange = new core.EventEmitter();
this.loaded = new core.EventEmitter();
this.time = new TimeKeeper();
this.paused = true;
this.playTime = 0;
this.currentViewport = null;
this.previousViewport = null;
this.viewportTransitionStart = 0;
this.init = false;
}
Object.defineProperty(NgxSpineWebglComponent.prototype, "dataUrls", {
get: /**
* @return {?}
*/
function () {
return this.urls;
},
set: /**
* @param {?} urls
* @return {?}
*/
function (urls) {
var _this = this;
this.urls = urls;
if (!this.urls.json && !this.urls.skel) {
throw new Error("Please specify the URL of the skeleton JSON or .skel file.");
}
if (!this.urls.atlas) {
throw new Error("Please specify the URL of the atlas file.");
}
if (this.init) {
this.loaded.emit(false);
this.loadAsset().then((/**
* @return {?}
*/
function () {
console.log("load assets");
_this.loadSkeleton();
_this.loaded.emit(true);
requestAnimationFrame((/**
* @return {?}
*/
function () { return _this.drawFrame(); }));
}));
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgxSpineWebglComponent.prototype, "animation", {
get: /**
* @return {?}
*/
function () {
return this.animationValue;
},
set: /**
* @param {?} val
* @return {?}
*/
function (val) {
this.animationValue = val;
this.animationChange.emit(val);
if (this.skeleton && this.animations.length > 0) {
this.playTime = 0;
this.setAnimation(val);
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgxSpineWebglComponent.prototype, "animations", {
get: /**
* @return {?}
*/
function () {
return this.animationsValue;
},
set: /**
* @param {?} val
* @return {?}
*/
function (val) {
this.animationsValue = val;
this.animationsChange.emit(val);
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgxSpineWebglComponent.prototype, "skin", {
get: /**
* @return {?}
*/
function () {
return this.skinValue;
},
set: /**
* @param {?} val
* @return {?}
*/
function (val) {
this.skinValue = val;
this.skinChange.emit(this.skinValue);
if (this.skeleton && this.animations.length > 0) {
this.skeleton.setSkinByName(val);
this.skeleton.setSlotsToSetupPose();
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgxSpineWebglComponent.prototype, "skins", {
get: /**
* @return {?}
*/
function () {
return this.skinsValue;
},
set: /**
* @param {?} val
* @return {?}
*/
function (val) {
this.skinsValue = val;
this.skinsChange.emit(val);
},
enumerable: true,
configurable: true
});
/**
* @return {?}
*/
NgxSpineWebglComponent.prototype.ngAfterViewInit = /**
* @return {?}
*/
function () {
var _this = this;
this.loaded.emit(false);
// webgl setup
this.context = new ManagedWebGLRenderingContext(this.canvas.nativeElement, {
alpha: true
});
this.sceneRenderer = new SceneRenderer(this.canvas.nativeElement, this.context, true);
// load the assets
this.assetManager = new AssetManager$1(this.context);
this.init = true;
this.loadAsset().then((/**
* @return {?}
*/
function () {
console.log("load assets");
_this.loadSkeleton();
_this.loaded.emit(true);
requestAnimationFrame((/**
* @return {?}
*/
function () { return _this.drawFrame(); }));
}));
};
/**
* @private
* @return {?}
*/
NgxSpineWebglComponent.prototype.loadAsset = /**
* @private
* @return {?}
*/
function () {
var _this = this;
/** @type {?} */
var promises = [];
promises.push(new Promise((/**
* @param {?} resolve
* @param {?} reject
* @return {?}
*/
function (resolve, reject) {
_this.assetManager.loadTextureAtlas(_this.dataUrls.atlas, resolve, reject);
})));
if (this.dataUrls.json) {
promises.push(new Promise((/**
* @param {?} resolve
* @param {?} reject
* @return {?}
*/
function (resolve, reject) {
_this.assetManager.loadText(_this.dataUrls.json, resolve, reject);
})));
}
else {
promises.push(new Promise((/**
* @param {?} resolve
* @param {?} reject
* @return {?}
*/
function (resolve, reject) {
_this.assetManager.loadBinary(_this.dataUrls.skel, resolve, reject);
})));
}
return Promise.all(promises);
};
/**
* @private
* @return {?}
*/
NgxSpineWebglComponent.prototype.loadSkeleton = /**
* @private
* @return {?}
*/
function () {
/** @type {?} */
var atlas = this.assetManager.get(this.dataUrls.atlas);
/** @type {?} */
var skeletonData;
if (this.dataUrls.json) {
/** @type {?} */
var json = this.assetManager.get(this.dataUrls.json);
/** @type {?} */
var skeletonJson = new SkeletonJson(new AtlasAttachmentLoader(atlas));
skeletonData = skeletonJson.readSkeletonData(json);
}
else {
/** @type {?} */
var binary = this.assetManager.get(this.dataUrls.skel);
/** @type {?} */
var skeletonBinary = new SkeletonBinary(new AtlasAttachmentLoader(atlas));
skeletonData = skeletonBinary.readSkeletonData(binary);
}
this.skeleton = new Skeleton(skeletonData);
/** @type {?} */
var stateData = new AnimationStateData(skeletonData);
stateData.defaultMix = this.defaultMix;
this.animationState = new AnimationState(stateData);
/// Setup skin
if (skeletonData.skins.length > 0) {
this.skins = skeletonData.skins.map((/**
* @param {?} s
* @return {?}
*/
function (s) { return s.name; }));
}
else {
throw new Error("");
}
if (this.skin) {
if (!this.skins.includes(this.skin)) {
throw new Error("");
}
this.skeleton.setSkinByName(this.skin);
this.skeleton.setSlotsToSetupPose();
}
else {
this.skin = this.skins[0];
}
/// Setup animations
if (skeletonData.animations.length > 0) {
this.animations = skeletonData.animations.map((/**
* @param {?} a
* @return {?}
*/
function (a) { return a.name; }));
}
if (this.animation) {
if (!this.animations.includes(this.animation)) {
throw new Error("");
}
}
else {
this.animation = this.animations[0];
}
this.play();
};
/**
* @param {?=} requestNextFrame
* @return {?}
*/
NgxSpineWebglComponent.prototype.drawFrame = /**
* @param {?=} requestNextFrame
* @return {?}
*/
function (requestNextFrame) {
var _this = this;
if (requestNextFrame === void 0) { requestNextFrame = true; }
if (requestNextFrame) {
requestAnimationFrame((/**
* @return {?}
*/
function () { return _this.drawFrame(); }));
}
/** @type {?} */
var gl = this.context.gl;
gl.clearColor(0, 0, 0, 0);
gl.clear(gl.COLOR_BUFFER_BIT);
// Resize the canvas
this.sceneRenderer.resize(ResizeMode.Expand);
// Update animation and skeleton
if (!this.paused && this.animation) {
this.time.update();
/** @type {?} */
var delta = this.time.delta * this.speed;
/** @type {?} */
var animationDuration = this.animationState.getCurrent(0).animation
.duration;
this.playTime += delta;
while (this.playTime >= animationDuration && animationDuration !== 0) {
this.playTime -= animationDuration;
}
this.playTime = Math.max(0, Math.min(this.playTime, animationDuration));
// this.timelineSlider.setValue(this.playTime / animationDuration);
this.animationState.update(delta);
this.animationState.apply(this.skeleton);
}
this.skeleton.updateWorldTransform();
/** @type {?} */
var viewport = {
x: this.currentViewport.x - ((/** @type {?} */ (this.currentViewport.padLeft))),
y: this.currentViewport.y - ((/** @type {?} */ (this.currentViewport.padBottom))),
width: this.currentViewport.width +
((/** @type {?} */ (this.currentViewport.padLeft))) +
((/** @type {?} */ (this.currentViewport.padRight))),
height: this.currentViewport.height +
((/** @type {?} */ (this.currentViewport.padBottom))) +
((/** @type {?} */ (this.currentViewport.padTop)))
};
/** @type {?} */
var transitionAlpha = (performance.now() - this.viewportTransitionStart) /
1000 /
this.transitionTime;
if (this.previousViewport && transitionAlpha < 1) {
/** @type {?} */
var oldViewport = {
x: this.previousViewport.x - ((/** @type {?} */ (this.previousViewport.padLeft))),
y: this.previousViewport.y - ((/** @type {?} */ (this.previousViewport.padBottom))),
width: this.previousViewport.width +
((/** @type {?} */ (this.previousViewport.padLeft))) +
((/** @type {?} */ (this.previousViewport.padRight))),
height: this.previousViewport.height +
((/** @type {?} */ (this.previousViewport.padBottom))) +
((/** @type {?} */ (this.previousViewport.padTop)))
};
viewport = {
x: oldViewport.x + (viewport.x - oldViewport.x) * transitionAlpha,
y: oldViewport.y + (viewport.y - oldViewport.y) * transitionAlpha,
width: oldViewport.width +
(viewport.width - oldViewport.width) * transitionAlpha,
height: oldViewport.height +
(viewport.height - oldViewport.height) * transitionAlpha
};
}
/** @type {?} */
var viewportSize = this.scale(viewport.width, viewport.height, this.canvas.nativeElement.width, this.canvas.nativeElement.height);
this.sceneRenderer.camera.zoom = viewport.width / viewportSize.x;
this.sceneRenderer.camera.position.x = viewport.x + viewport.width / 2;
this.sceneRenderer.camera.position.y = viewport.y + viewport.height / 2;
this.sceneRenderer.begin();
this.sceneRenderer.drawSkeleton(this.skeleton, this.premultipliedAlpha);
this.sceneRenderer.end();
this.sceneRenderer.camera.zoom = 0;
};
/**
* @private
* @return {?}
*/
NgxSpineWebglComponent.prototype.play = /**
* @private
* @return {?}
*/
function () {
this.paused = false;
this.setAnimation(this.animation);
};
/**
* @private
* @return {?}
*/
NgxSpineWebglComponent.prototype.pause = /**
* @private
* @return {?}
*/
function () {
this.paused = true;
};
/**
* @param {?} animation
* @return {?}
*/
NgxSpineWebglComponent.prototype.setAnimation = /**
* @param {?} animation
* @return {?}
*/
function (animation) {
// Determine viewport
this.previousViewport = this.currentViewport;
/** @type {?} */
var animViewport = this.calculateAnimationViewport(animation);
// The calculated animation viewport is the base
/** @type {?} */
var viewport = {
x: animViewport.x,
y: animViewport.y,
width: animViewport.width,
height: animViewport.height,
padLeft: "10%",
padRight: "10%",
padTop: "10%",
padBottom: "10%"
};
// Translate percentage paddings to world units
viewport.padLeft = this.percentageToWorldUnit(viewport.width, viewport.padLeft);
viewport.padRight = this.percentageToWorldUnit(viewport.width, viewport.padRight);
viewport.padBottom = this.percentageToWorldUnit(viewport.height, viewport.padBottom);
viewport.padTop = this.percentageToWorldUnit(viewport.height, viewport.padTop);
// Adjust x, y, width, and height by padding.
this.currentViewport = viewport;
this.viewportTransitionStart = performance.now();
this.animationState.clearTracks();
this.skeleton.setToSetupPose();
this.animationState.setAnimation(0, animation, true);
};
/**
* @private
* @param {?} size
* @param {?} percentageOrAbsolute
* @return {?}
*/
NgxSpineWebglComponent.prototype.percentageToWorldUnit = /**
* @private
* @param {?} size
* @param {?} percentageOrAbsolute
* @return {?}
*/
function (size, percentageOrAbsolute) {
if (typeof percentageOrAbsolute === "string") {
return ((size *
parseFloat(percentageOrAbsolute.substr(0, percentageOrAbsolute.length - 1))) /
100);
}
else {
return percentageOrAbsolute;
}
};
/**
* @private
* @param {?} animationName
* @return {?}
*/
NgxSpineWebglComponent.prototype.calculateAnimationViewport = /**
* @private
* @param {?} animationName
* @return {?}
*/
function (animationName) {
/** @type {?} */
var animation = this.skeleton.data.findAnimation(animationName);
this.animationState.clearTracks();
this.skeleton.setToSetupPose();
this.animationState.setAnimationWith(0, animation, true);
/** @type {?} */
var steps = 100;
/** @type {?} */
var stepTime = animation.duration > 0 ? animation.duration / steps : 0;
/** @type {?} */
var offset = new Vector2();
/** @type {?} */
var size = new Vector2();
/** @type {?} */
var minX = 100000000;
/** @type {?} */
var maxX = -100000000;
/** @type {?} */
var minY = 100000000;
/** @type {?} */
var maxY = -100000000;
for (var i = 0; i < steps; i++) {
this.animationState.update(stepTime);
this.animationState.apply(this.skeleton);
this.skeleton.updateWorldTransform();
this.skeleton.getBounds(offset, size);
minX = Math.min(offset.x, minX);
maxX = Math.max(offset.x + size.x, maxX);
minY = Math.min(offset.y, minY);
maxY = Math.max(offset.y + size.y, maxY);
}
offset.x = minX;
offset.y = minY;
size.x = maxX - minX;
size.y = maxY - minY;
return {
x: offset.x,
y: offset.y,
width: size.x,
height: size.y
};
};
/**
* @private
* @param {?} sourceWidth
* @param {?} sourceHeight
* @param {?} targetWidth
* @param {?} targetHeight
* @return {?}
*/
NgxSpineWebglComponent.prototype.scale = /**
* @private
* @param {?} sourceWidth
* @param {?} sourceHeight
* @param {?} targetWidth
* @param {?} targetHeight
* @return {?}
*/
function (sourceWidth, sourceHeight, targetWidth, targetHeight) {
/** @type {?} */
var targetRatio = targetHeight / targetWidth;
/** @type {?} */
var sourceRatio = sourceHeight / sourceWidth;
/** @type {?} */
var scale = targetRatio > sourceRatio
? targetWidth / sourceWidth
: targetHeight / sourceHeight;
/** @type {?} */
var temp = new Vector2();
temp.x = sourceWidth * scale;
temp.y = sourceHeight * scale;
return temp;
};
NgxSpineWebglComponent.decorators = [
{ type: core.Component, args: [{
selector: "ngx-spine-webgl",
template: "\n <canvas class=\"ngx-spine-webgl\" #canvas></canvas>\n",
changeDetection: core.ChangeDetectionStrategy.OnPush
}] }
];
NgxSpineWebglComponent.propDecorators = {
dataUrls: [{ type: core.Input }],
defaultMix: [{ type: core.Input }],
premultipliedAlpha: [{ type: core.Input }],
transitionTime: [{ type: core.Input }],
speed: [{ type: core.Input }],
canvas: [{ type: core.ViewChild, args: ["canvas", { static: true, read: core.ElementRef },] }],
animationChange: [{ type: core.Output }],
animation: [{ type: core.Input }],
animationsChange: [{ type: core.Output }],
animations: [{ type: core.Input }],
skinChange: [{ type: core.Output }],
skin: [{ type: core.Input }],
skinsChange: [{ type: core.Output }],
skins: [{ type: core.Input }],
loaded: [{ type: core.Output }]
};
return NgxSpineWebglComponent;
}());
if (false) {
/**
* @type {?}
* @private
*/
NgxSpineWebglComponent.prototype.urls;
/** @type {?} */
NgxSpineWebglComponent.prototype.defaultMix;
/** @type {?} */
NgxSpineWebglComponent.prototype.premultipliedAlpha;
/** @type {?} */
NgxSpineWebglComponent.prototype.transitionTime;
/** @type {?} */
NgxSpineWebglComponent.prototype.speed;
/**
* @type {?}
* @private
*/
NgxSpineWebglComponent.prototype.canvas;
/**
* @type {?}
* @private
*/
NgxSpineWebglComponent.prototype.animationValue;
/** @type {?} */
NgxSpineWebglComponent.prototype.animationChange;
/**
* @type {?}
* @private
*/
NgxSpineWebglComponent.prototype.animationsValue;
/** @type {?} */
NgxSpineWebglComponent.prototype.animationsChange;
/**
* @type {?}
* @private
*/
NgxSpineWebglComponent.prototype.skinValue;
/** @type {?} */
NgxSpineWebglComponent.prototype.skinChange;
/**
* @type {?}
* @private
*/
NgxSpineWebglComponent.prototype.skinsValue;
/** @type {?} */
NgxSpineWebglComponent.prototype.skinsChange;
/** @type {?} */
NgxSpineWebglComponent.prototype.loaded;
/**
* @type {?}
* @private
*/
NgxSpineWebglComponent.prototype.sceneRenderer;
/**
* @type {?}
* @private
*/
NgxSpineWebglComponent.prototype.context;
/**
* @type {?}
* @private
*/
NgxSpineWebglComponent.prototype.assetManager;
/**
* @type {?}
* @private
*/
NgxSpineWebglComponent.prototype.skeleton;
/**
* @type {?}
* @private
*/
NgxSpineWebglComponent.prototype.animationState;
/**
* @type {?}
* @private
*/
NgxSpineWebglComponent.prototype.time;
/**
* @type {?}
* @private
*/
NgxSpineWebglComponent.prototype.paused;
/**
* @type {?}
* @private
*/
NgxSpineWebglComponent.prototype.playTime;
/**
* @type {?}
* @private
*/
NgxSpineWebglComponent.prototype.currentViewport;
/**
* @type {?}
* @private
*/
NgxSpineWebglComponent.prototype.previousViewport;
/**
* @type {?}
* @private
*/
NgxSpineWebglComponent.prototype.viewportTransitionStart;
/**
* @type {?}
* @private
*/
NgxSpineWebglComponent.prototype.init;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NgxSpineModule = /** @class */ (function () {
function NgxSpineModule() {
}
NgxSpineModule.decorators = [
{ type: core.NgModule, args: [{
declarations: [NgxSpineWebglComponent],
exports: [NgxSpineWebglComponent]
},] }
];
return NgxSpineModule;
}());
exports.NgxSpineModule = NgxSpineModule;
exports.NgxSpineWebglComponent = NgxSpineWebglComponent;
Object.defineProperty(exports, '__esModule', { value: true });
}));
//# sourceMappingURL=ngx-spine.umd.js.map