[ts] Port of mesh whitespaces stripping. See #1232.

This commit is contained in:
badlogic 2018-12-22 13:07:10 +01:00
parent 2433a87792
commit 52f9ab8984
16 changed files with 12321 additions and 12124 deletions

View File

@ -1791,7 +1791,6 @@ declare module spine {
defaultMix: number; defaultMix: number;
skin: string; skin: string;
skins: string[]; skins: string[];
controlBones: string[];
premultipliedAlpha: boolean; premultipliedAlpha: boolean;
showControls: boolean; showControls: boolean;
debug: { debug: {
@ -1827,11 +1826,11 @@ declare module spine {
height: number; height: number;
}; };
fullScreenBackgroundColor: string; fullScreenBackgroundColor: string;
controlBones: string[];
success: (widget: SpinePlayer) => void; success: (widget: SpinePlayer) => void;
error: (widget: SpinePlayer, msg: string) => void; error: (widget: SpinePlayer, msg: string) => void;
} }
class SpinePlayer { class SpinePlayer {
parent: HTMLElement | string;
private config; private config;
static HOVER_COLOR_INNER: Color; static HOVER_COLOR_INNER: Color;
static HOVER_COLOR_OUTER: Color; static HOVER_COLOR_OUTER: Color;
@ -1860,6 +1859,7 @@ declare module spine {
private previousViewport; private previousViewport;
private viewportTransitionStart; private viewportTransitionStart;
private selectedBones; private selectedBones;
private parent;
constructor(parent: HTMLElement | string, config: SpinePlayerConfig); constructor(parent: HTMLElement | string, config: SpinePlayerConfig);
validateConfig(config: SpinePlayerConfig): SpinePlayerConfig; validateConfig(config: SpinePlayerConfig): SpinePlayerConfig;
showError(error: string): void; showError(error: string): void;
@ -1881,3 +1881,19 @@ declare module spine {
private calculateAnimationViewport(animationName); private calculateAnimationViewport(animationName);
} }
} }
declare function CodeMirror(el: Element, config: any): void;
declare module spine {
class SpinePlayerEditor {
private static DEFAULT_CODE;
private prefix;
private postfix;
private code;
private player;
constructor(parent: HTMLElement);
private render(parent);
setPreAndPostfix(prefix: string, postfix: string): void;
setCode(code: string): void;
private timerId;
startPlayer(): void;
}
}

View File

@ -6543,8 +6543,31 @@ var spine;
return _this; return _this;
} }
MeshAttachment.prototype.updateUVs = function () { MeshAttachment.prototype.updateUVs = function () {
var regionUVs = this.regionUVs;
if (this.uvs == null || this.uvs.length != regionUVs.length)
this.uvs = spine.Utils.newFloatArray(regionUVs.length);
var uvs = this.uvs;
var u = 0, v = 0, width = 0, height = 0; var u = 0, v = 0, width = 0, height = 0;
if (this.region == null) { if (this.region instanceof spine.TextureAtlasRegion) {
var region = this.region;
var textureWidth = region.texture.getImage().width, textureHeight = region.texture.getImage().height;
if (region.rotate) {
u = region.u - (region.originalHeight - region.offsetY - region.height) / textureWidth;
v = region.v - (region.originalWidth - region.offsetX - region.width) / textureHeight;
width = region.originalHeight / textureWidth;
height = region.originalWidth / textureHeight;
for (var i = 0, n = uvs.length; i < n; i += 2) {
uvs[i] = u + regionUVs[i + 1] * width;
uvs[i + 1] = v + height - regionUVs[i] * height;
}
return;
}
u = region.u - region.offsetX / textureWidth;
v = region.v - (region.originalHeight - region.offsetY - region.height) / textureHeight;
width = region.originalWidth / textureWidth;
height = region.originalHeight / textureHeight;
}
else if (this.region == null) {
u = v = 0; u = v = 0;
width = height = 1; width = height = 1;
} }
@ -6554,21 +6577,9 @@ var spine;
width = this.region.u2 - u; width = this.region.u2 - u;
height = this.region.v2 - v; height = this.region.v2 - v;
} }
var regionUVs = this.regionUVs; for (var i = 0, n = uvs.length; i < n; i += 2) {
if (this.uvs == null || this.uvs.length != regionUVs.length) uvs[i] = u + regionUVs[i] * width;
this.uvs = spine.Utils.newFloatArray(regionUVs.length); uvs[i + 1] = v + regionUVs[i + 1] * height;
var uvs = this.uvs;
if (this.region.rotate) {
for (var i = 0, n = uvs.length; i < n; i += 2) {
uvs[i] = u + regionUVs[i + 1] * width;
uvs[i + 1] = v + height - regionUVs[i] * height;
}
}
else {
for (var i = 0, n = uvs.length; i < n; i += 2) {
uvs[i] = u + regionUVs[i] * width;
uvs[i + 1] = v + regionUVs[i + 1] * height;
}
} }
}; };
MeshAttachment.prototype.applyDeform = function (sourceAttachment) { MeshAttachment.prototype.applyDeform = function (sourceAttachment) {
@ -7465,7 +7476,7 @@ var spine;
return; return;
this.timeKeeper.update(); this.timeKeeper.update();
var a = Math.abs(Math.sin(this.timeKeeper.totalTime + 0.75)); var a = Math.abs(Math.sin(this.timeKeeper.totalTime + 0.75));
this.angle -= this.timeKeeper.delta * 360 * (1 + 1.5 * Math.pow(a, 5)); this.angle -= this.timeKeeper.delta / 1.4 * 360 * (1 + 1.5 * Math.pow(a, 5));
var renderer = this.renderer; var renderer = this.renderer;
var canvas = renderer.canvas; var canvas = renderer.canvas;
var gl = renderer.context.gl; var gl = renderer.context.gl;
@ -10101,7 +10112,6 @@ var spine;
} }
Popup.prototype.show = function (dismissedListener) { Popup.prototype.show = function (dismissedListener) {
var _this = this; var _this = this;
if (dismissedListener === void 0) { dismissedListener = function () { }; }
this.dom.classList.remove("spine-player-hidden"); this.dom.classList.remove("spine-player-hidden");
var dismissed = false; var dismissed = false;
var resize = function () { var resize = function () {
@ -10225,7 +10235,6 @@ var spine;
}()); }());
var SpinePlayer = (function () { var SpinePlayer = (function () {
function SpinePlayer(parent, config) { function SpinePlayer(parent, config) {
this.parent = parent;
this.config = config; this.config = config;
this.time = new spine.TimeKeeper(); this.time = new spine.TimeKeeper();
this.paused = true; this.paused = true;
@ -10237,8 +10246,10 @@ var spine;
this.viewportTransitionStart = 0; this.viewportTransitionStart = 0;
this.cancelId = 0; this.cancelId = 0;
if (typeof parent === "string") if (typeof parent === "string")
parent = document.getElementById(parent); this.parent = document.getElementById(parent);
parent.appendChild(this.render()); else
this.parent = parent;
this.parent.appendChild(this.render());
} }
SpinePlayer.prototype.validateConfig = function (config) { SpinePlayer.prototype.validateConfig = function (config) {
if (!config) if (!config)
@ -10253,8 +10264,8 @@ var spine;
config.backgroundColor = "#000000"; config.backgroundColor = "#000000";
if (!config.fullScreenBackgroundColor) if (!config.fullScreenBackgroundColor)
config.fullScreenBackgroundColor = config.backgroundColor; config.fullScreenBackgroundColor = config.backgroundColor;
if (!config.premultipliedAlpha) if (typeof config.premultipliedAlpha === "undefined")
config.premultipliedAlpha = false; config.premultipliedAlpha = true;
if (!config.success) if (!config.success)
config.success = function (widget) { }; config.success = function (widget) { };
if (!config.error) if (!config.error)
@ -10270,21 +10281,21 @@ var spine;
points: false, points: false,
hulls: false hulls: false
}; };
if (!config.debug.bones) if (typeof config.debug.bones === "undefined")
config.debug.bones = false; config.debug.bones = false;
if (!config.debug.bounds) if (typeof config.debug.bounds === "undefined")
config.debug.bounds = false; config.debug.bounds = false;
if (!config.debug.clipping) if (typeof config.debug.clipping === "undefined")
config.debug.clipping = false; config.debug.clipping = false;
if (!config.debug.hulls) if (typeof config.debug.hulls === "undefined")
config.debug.hulls = false; config.debug.hulls = false;
if (!config.debug.paths) if (typeof config.debug.paths === "undefined")
config.debug.paths = false; config.debug.paths = false;
if (!config.debug.points) if (typeof config.debug.points === "undefined")
config.debug.points = false; config.debug.points = false;
if (!config.debug.regions) if (typeof config.debug.regions === "undefined")
config.debug.regions = false; config.debug.regions = false;
if (!config.debug.meshes) if (typeof config.debug.meshes === "undefined")
config.debug.meshes = false; config.debug.meshes = false;
if (config.animations && config.animation) { if (config.animations && config.animation) {
if (config.animations.indexOf(config.animation) < 0) if (config.animations.indexOf(config.animation) < 0)
@ -10440,6 +10451,8 @@ var spine;
speedButton.classList.add("spine-player-button-icon-speed-selected"); speedButton.classList.add("spine-player-button-icon-speed-selected");
popup.show(function () { popup.show(function () {
speedButton.classList.remove("spine-player-button-icon-speed-selected"); speedButton.classList.remove("spine-player-button-icon-speed-selected");
popup.dom.remove();
_this.lastPopup = null;
}); });
this.lastPopup = popup; this.lastPopup = popup;
}; };
@ -10476,6 +10489,8 @@ var spine;
animationsButton.classList.add("spine-player-button-icon-animations-selected"); animationsButton.classList.add("spine-player-button-icon-animations-selected");
popup.show(function () { popup.show(function () {
animationsButton.classList.remove("spine-player-button-icon-animations-selected"); animationsButton.classList.remove("spine-player-button-icon-animations-selected");
popup.dom.remove();
_this.lastPopup = null;
}); });
this.lastPopup = popup; this.lastPopup = popup;
}; };
@ -10512,6 +10527,8 @@ var spine;
skinButton.classList.add("spine-player-button-icon-skins-selected"); skinButton.classList.add("spine-player-button-icon-skins-selected");
popup.show(function () { popup.show(function () {
skinButton.classList.remove("spine-player-button-icon-skins-selected"); skinButton.classList.remove("spine-player-button-icon-skins-selected");
popup.dom.remove();
_this.lastPopup = null;
}); });
this.lastPopup = popup; this.lastPopup = popup;
}; };
@ -10549,6 +10566,8 @@ var spine;
settingsButton.classList.add("spine-player-button-icon-settings-selected"); settingsButton.classList.add("spine-player-button-icon-settings-selected");
popup.show(function () { popup.show(function () {
settingsButton.classList.remove("spine-player-button-icon-settings-selected"); settingsButton.classList.remove("spine-player-button-icon-settings-selected");
popup.dom.remove();
_this.lastPopup = null;
}); });
this.lastPopup = popup; this.lastPopup = popup;
}; };
@ -10838,33 +10857,45 @@ var spine;
}); });
var mouseOverControls = true; var mouseOverControls = true;
var mouseOverCanvas = false; var mouseOverCanvas = false;
parent.addEventListener("mousemove", function (ev) { document.addEventListener("mousemove", function (ev) {
if (ev instanceof MouseEvent) { if (ev instanceof MouseEvent) {
if (!_this.config.showControls) handleHover(ev.clientX, ev.clientY);
return; }
var popup = findWithClass(_this.dom, "spine-player-popup"); });
mouseOverControls = overlap(ev, _this.playerControls.getBoundingClientRect()); document.addEventListener("touchmove", function (ev) {
mouseOverCanvas = overlap(ev, _this.canvas.getBoundingClientRect()); if (ev instanceof TouchEvent) {
clearTimeout(_this.cancelId); var touches = ev.changedTouches;
var hide = popup.length == 0 && !mouseOverControls && !mouseOverCanvas && !_this.paused; if (touches.length > 0) {
if (hide) { var touch = touches[0];
_this.playerControls.classList.add("spine-player-controls-hidden"); handleHover(touch.clientX, touch.clientY);
}
else {
_this.playerControls.classList.remove("spine-player-controls-hidden");
}
if (!mouseOverControls && popup.length == 0 && !_this.paused) {
var remove = function () {
if (!_this.paused)
_this.playerControls.classList.add("spine-player-controls-hidden");
};
_this.cancelId = setTimeout(remove, 500);
} }
} }
}); });
var overlap = function (ev, rect) { var handleHover = function (mouseX, mouseY) {
var x = ev.clientX - rect.left; if (!_this.config.showControls)
var y = ev.clientY - rect.top; return;
var popup = findWithClass(_this.dom, "spine-player-popup");
mouseOverControls = overlap(mouseX, mouseY, _this.playerControls.getBoundingClientRect());
mouseOverCanvas = overlap(mouseX, mouseY, _this.canvas.getBoundingClientRect());
clearTimeout(_this.cancelId);
var hide = popup.length == 0 && !mouseOverControls && !mouseOverCanvas && !_this.paused;
if (hide) {
_this.playerControls.classList.add("spine-player-controls-hidden");
}
else {
_this.playerControls.classList.remove("spine-player-controls-hidden");
}
if (!mouseOverControls && popup.length == 0 && !_this.paused) {
var remove = function () {
if (!_this.paused)
_this.playerControls.classList.add("spine-player-controls-hidden");
};
_this.cancelId = setTimeout(remove, 1000);
}
};
var overlap = function (mouseX, mouseY, rect) {
var x = mouseX - rect.left;
var y = mouseY - rect.top;
return x >= 0 && x <= rect.width && y >= 0 && y <= rect.height; return x >= 0 && x <= rect.width && y >= 0 && y <= rect.height;
}; };
}; };
@ -10875,7 +10906,7 @@ var spine;
if (!_this.paused) if (!_this.paused)
_this.playerControls.classList.add("spine-player-controls-hidden"); _this.playerControls.classList.add("spine-player-controls-hidden");
}; };
this.cancelId = setTimeout(remove, 500); this.cancelId = setTimeout(remove, 1000);
this.playButton.classList.remove("spine-player-button-icon-play"); this.playButton.classList.remove("spine-player-button-icon-play");
this.playButton.classList.add("spine-player-button-icon-pause"); this.playButton.classList.add("spine-player-button-icon-pause");
if (this.config.animation) { if (this.config.animation) {
@ -11057,4 +11088,60 @@ var spine;
.replace(/'/g, "&#39;"); .replace(/'/g, "&#39;");
} }
})(spine || (spine = {})); })(spine || (spine = {}));
var spine;
(function (spine) {
var SpinePlayerEditor = (function () {
function SpinePlayerEditor(parent) {
this.prefix = "<html>\n<head>\n<style>\nbody {\n\tmargin: 0px;\n}\n</style>\n</head>\n<body>".trim();
this.postfix = "</body>";
this.timerId = 0;
this.render(parent);
}
SpinePlayerEditor.prototype.render = function (parent) {
var _this = this;
var dom = "\n\t\t\t\t<div class=\"spine-player-editor-container\">\n\t\t\t\t\t<div class=\"spine-player-editor-code\"></div>\n\t\t\t\t\t<iframe class=\"spine-player-editor-player\"></iframe>\n\t\t\t\t</div>\n\t\t\t";
parent.innerHTML = dom;
var codeElement = parent.getElementsByClassName("spine-player-editor-code")[0];
this.player = parent.getElementsByClassName("spine-player-editor-player")[0];
requestAnimationFrame(function () {
_this.code = CodeMirror(codeElement, {
lineNumbers: true,
tabSize: 3,
indentUnit: 3,
indentWithTabs: true,
scrollBarStyle: "native",
mode: "htmlmixed",
theme: "monokai"
});
_this.code.on("change", function () {
_this.startPlayer();
});
_this.setCode(SpinePlayerEditor.DEFAULT_CODE);
});
};
SpinePlayerEditor.prototype.setPreAndPostfix = function (prefix, postfix) {
this.prefix = prefix;
this.postfix = postfix;
this.startPlayer();
};
SpinePlayerEditor.prototype.setCode = function (code) {
this.code.setValue(code);
this.startPlayer();
};
SpinePlayerEditor.prototype.startPlayer = function () {
var _this = this;
clearTimeout(this.timerId);
this.timerId = setTimeout(function () {
var code = _this.code.getDoc().getValue();
code = _this.prefix + code + _this.postfix;
code = window.btoa(code);
_this.player.src = "";
_this.player.src = "data:text/html;base64," + code;
}, 500);
};
SpinePlayerEditor.DEFAULT_CODE = "\n<script src=\"https://esotericsoftware.com/files/spine-player/3.7/spine-player.js\"></script>\n<link rel=\"stylesheet\" href=\"https://esotericsoftware.com/files/spine-player/3.7/spine-player.css\">\n\n<div id=\"player-container\" style=\"width: 100%; height: 100vh;\"></div>\n\n<script>\nnew spine.SpinePlayer(\"player-container\", {\n\tjsonUrl: \"https://esotericsoftware.com/files/examples/spineboy/export/spineboy-pro.json\",\n\tatlasUrl: \"https://esotericsoftware.com/files/examples/spineboy/export/spineboy-pma.atlas\"\n});\n</script>\n\t\t".trim();
return SpinePlayerEditor;
}());
spine.SpinePlayerEditor = SpinePlayerEditor;
})(spine || (spine = {}));
//# sourceMappingURL=spine-all.js.map //# sourceMappingURL=spine-all.js.map

File diff suppressed because one or more lines are too long

View File

@ -6543,8 +6543,31 @@ var spine;
return _this; return _this;
} }
MeshAttachment.prototype.updateUVs = function () { MeshAttachment.prototype.updateUVs = function () {
var regionUVs = this.regionUVs;
if (this.uvs == null || this.uvs.length != regionUVs.length)
this.uvs = spine.Utils.newFloatArray(regionUVs.length);
var uvs = this.uvs;
var u = 0, v = 0, width = 0, height = 0; var u = 0, v = 0, width = 0, height = 0;
if (this.region == null) { if (this.region instanceof spine.TextureAtlasRegion) {
var region = this.region;
var textureWidth = region.texture.getImage().width, textureHeight = region.texture.getImage().height;
if (region.rotate) {
u = region.u - (region.originalHeight - region.offsetY - region.height) / textureWidth;
v = region.v - (region.originalWidth - region.offsetX - region.width) / textureHeight;
width = region.originalHeight / textureWidth;
height = region.originalWidth / textureHeight;
for (var i = 0, n = uvs.length; i < n; i += 2) {
uvs[i] = u + regionUVs[i + 1] * width;
uvs[i + 1] = v + height - regionUVs[i] * height;
}
return;
}
u = region.u - region.offsetX / textureWidth;
v = region.v - (region.originalHeight - region.offsetY - region.height) / textureHeight;
width = region.originalWidth / textureWidth;
height = region.originalHeight / textureHeight;
}
else if (this.region == null) {
u = v = 0; u = v = 0;
width = height = 1; width = height = 1;
} }
@ -6554,21 +6577,9 @@ var spine;
width = this.region.u2 - u; width = this.region.u2 - u;
height = this.region.v2 - v; height = this.region.v2 - v;
} }
var regionUVs = this.regionUVs; for (var i = 0, n = uvs.length; i < n; i += 2) {
if (this.uvs == null || this.uvs.length != regionUVs.length) uvs[i] = u + regionUVs[i] * width;
this.uvs = spine.Utils.newFloatArray(regionUVs.length); uvs[i + 1] = v + regionUVs[i + 1] * height;
var uvs = this.uvs;
if (this.region.rotate) {
for (var i = 0, n = uvs.length; i < n; i += 2) {
uvs[i] = u + regionUVs[i + 1] * width;
uvs[i + 1] = v + height - regionUVs[i] * height;
}
}
else {
for (var i = 0, n = uvs.length; i < n; i += 2) {
uvs[i] = u + regionUVs[i] * width;
uvs[i + 1] = v + regionUVs[i + 1] * height;
}
} }
}; };
MeshAttachment.prototype.applyDeform = function (sourceAttachment) { MeshAttachment.prototype.applyDeform = function (sourceAttachment) {

File diff suppressed because one or more lines are too long

View File

@ -6543,8 +6543,31 @@ var spine;
return _this; return _this;
} }
MeshAttachment.prototype.updateUVs = function () { MeshAttachment.prototype.updateUVs = function () {
var regionUVs = this.regionUVs;
if (this.uvs == null || this.uvs.length != regionUVs.length)
this.uvs = spine.Utils.newFloatArray(regionUVs.length);
var uvs = this.uvs;
var u = 0, v = 0, width = 0, height = 0; var u = 0, v = 0, width = 0, height = 0;
if (this.region == null) { if (this.region instanceof spine.TextureAtlasRegion) {
var region = this.region;
var textureWidth = region.texture.getImage().width, textureHeight = region.texture.getImage().height;
if (region.rotate) {
u = region.u - (region.originalHeight - region.offsetY - region.height) / textureWidth;
v = region.v - (region.originalWidth - region.offsetX - region.width) / textureHeight;
width = region.originalHeight / textureWidth;
height = region.originalWidth / textureHeight;
for (var i = 0, n = uvs.length; i < n; i += 2) {
uvs[i] = u + regionUVs[i + 1] * width;
uvs[i + 1] = v + height - regionUVs[i] * height;
}
return;
}
u = region.u - region.offsetX / textureWidth;
v = region.v - (region.originalHeight - region.offsetY - region.height) / textureHeight;
width = region.originalWidth / textureWidth;
height = region.originalHeight / textureHeight;
}
else if (this.region == null) {
u = v = 0; u = v = 0;
width = height = 1; width = height = 1;
} }
@ -6554,21 +6577,9 @@ var spine;
width = this.region.u2 - u; width = this.region.u2 - u;
height = this.region.v2 - v; height = this.region.v2 - v;
} }
var regionUVs = this.regionUVs; for (var i = 0, n = uvs.length; i < n; i += 2) {
if (this.uvs == null || this.uvs.length != regionUVs.length) uvs[i] = u + regionUVs[i] * width;
this.uvs = spine.Utils.newFloatArray(regionUVs.length); uvs[i + 1] = v + regionUVs[i + 1] * height;
var uvs = this.uvs;
if (this.region.rotate) {
for (var i = 0, n = uvs.length; i < n; i += 2) {
uvs[i] = u + regionUVs[i + 1] * width;
uvs[i + 1] = v + height - regionUVs[i] * height;
}
}
else {
for (var i = 0, n = uvs.length; i < n; i += 2) {
uvs[i] = u + regionUVs[i] * width;
uvs[i + 1] = v + regionUVs[i + 1] * height;
}
} }
}; };
MeshAttachment.prototype.applyDeform = function (sourceAttachment) { MeshAttachment.prototype.applyDeform = function (sourceAttachment) {

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -6543,8 +6543,31 @@ var spine;
return _this; return _this;
} }
MeshAttachment.prototype.updateUVs = function () { MeshAttachment.prototype.updateUVs = function () {
var regionUVs = this.regionUVs;
if (this.uvs == null || this.uvs.length != regionUVs.length)
this.uvs = spine.Utils.newFloatArray(regionUVs.length);
var uvs = this.uvs;
var u = 0, v = 0, width = 0, height = 0; var u = 0, v = 0, width = 0, height = 0;
if (this.region == null) { if (this.region instanceof spine.TextureAtlasRegion) {
var region = this.region;
var textureWidth = region.texture.getImage().width, textureHeight = region.texture.getImage().height;
if (region.rotate) {
u = region.u - (region.originalHeight - region.offsetY - region.height) / textureWidth;
v = region.v - (region.originalWidth - region.offsetX - region.width) / textureHeight;
width = region.originalHeight / textureWidth;
height = region.originalWidth / textureHeight;
for (var i = 0, n = uvs.length; i < n; i += 2) {
uvs[i] = u + regionUVs[i + 1] * width;
uvs[i + 1] = v + height - regionUVs[i] * height;
}
return;
}
u = region.u - region.offsetX / textureWidth;
v = region.v - (region.originalHeight - region.offsetY - region.height) / textureHeight;
width = region.originalWidth / textureWidth;
height = region.originalHeight / textureHeight;
}
else if (this.region == null) {
u = v = 0; u = v = 0;
width = height = 1; width = height = 1;
} }
@ -6554,21 +6577,9 @@ var spine;
width = this.region.u2 - u; width = this.region.u2 - u;
height = this.region.v2 - v; height = this.region.v2 - v;
} }
var regionUVs = this.regionUVs; for (var i = 0, n = uvs.length; i < n; i += 2) {
if (this.uvs == null || this.uvs.length != regionUVs.length) uvs[i] = u + regionUVs[i] * width;
this.uvs = spine.Utils.newFloatArray(regionUVs.length); uvs[i + 1] = v + regionUVs[i + 1] * height;
var uvs = this.uvs;
if (this.region.rotate) {
for (var i = 0, n = uvs.length; i < n; i += 2) {
uvs[i] = u + regionUVs[i + 1] * width;
uvs[i + 1] = v + height - regionUVs[i] * height;
}
}
else {
for (var i = 0, n = uvs.length; i < n; i += 2) {
uvs[i] = u + regionUVs[i] * width;
uvs[i + 1] = v + regionUVs[i + 1] * height;
}
} }
}; };
MeshAttachment.prototype.applyDeform = function (sourceAttachment) { MeshAttachment.prototype.applyDeform = function (sourceAttachment) {

File diff suppressed because one or more lines are too long

View File

@ -6543,8 +6543,31 @@ var spine;
return _this; return _this;
} }
MeshAttachment.prototype.updateUVs = function () { MeshAttachment.prototype.updateUVs = function () {
var regionUVs = this.regionUVs;
if (this.uvs == null || this.uvs.length != regionUVs.length)
this.uvs = spine.Utils.newFloatArray(regionUVs.length);
var uvs = this.uvs;
var u = 0, v = 0, width = 0, height = 0; var u = 0, v = 0, width = 0, height = 0;
if (this.region == null) { if (this.region instanceof spine.TextureAtlasRegion) {
var region = this.region;
var textureWidth = region.texture.getImage().width, textureHeight = region.texture.getImage().height;
if (region.rotate) {
u = region.u - (region.originalHeight - region.offsetY - region.height) / textureWidth;
v = region.v - (region.originalWidth - region.offsetX - region.width) / textureHeight;
width = region.originalHeight / textureWidth;
height = region.originalWidth / textureHeight;
for (var i = 0, n = uvs.length; i < n; i += 2) {
uvs[i] = u + regionUVs[i + 1] * width;
uvs[i + 1] = v + height - regionUVs[i] * height;
}
return;
}
u = region.u - region.offsetX / textureWidth;
v = region.v - (region.originalHeight - region.offsetY - region.height) / textureHeight;
width = region.originalWidth / textureWidth;
height = region.originalHeight / textureHeight;
}
else if (this.region == null) {
u = v = 0; u = v = 0;
width = height = 1; width = height = 1;
} }
@ -6554,21 +6577,9 @@ var spine;
width = this.region.u2 - u; width = this.region.u2 - u;
height = this.region.v2 - v; height = this.region.v2 - v;
} }
var regionUVs = this.regionUVs; for (var i = 0, n = uvs.length; i < n; i += 2) {
if (this.uvs == null || this.uvs.length != regionUVs.length) uvs[i] = u + regionUVs[i] * width;
this.uvs = spine.Utils.newFloatArray(regionUVs.length); uvs[i + 1] = v + regionUVs[i + 1] * height;
var uvs = this.uvs;
if (this.region.rotate) {
for (var i = 0, n = uvs.length; i < n; i += 2) {
uvs[i] = u + regionUVs[i + 1] * width;
uvs[i + 1] = v + height - regionUVs[i] * height;
}
}
else {
for (var i = 0, n = uvs.length; i < n; i += 2) {
uvs[i] = u + regionUVs[i] * width;
uvs[i + 1] = v + regionUVs[i + 1] * height;
}
} }
}; };
MeshAttachment.prototype.applyDeform = function (sourceAttachment) { MeshAttachment.prototype.applyDeform = function (sourceAttachment) {
@ -7199,7 +7210,7 @@ var spine;
return; return;
this.timeKeeper.update(); this.timeKeeper.update();
var a = Math.abs(Math.sin(this.timeKeeper.totalTime + 0.75)); var a = Math.abs(Math.sin(this.timeKeeper.totalTime + 0.75));
this.angle -= this.timeKeeper.delta * 360 * (1 + 1.5 * Math.pow(a, 5)); this.angle -= this.timeKeeper.delta / 1.4 * 360 * (1 + 1.5 * Math.pow(a, 5));
var renderer = this.renderer; var renderer = this.renderer;
var canvas = renderer.canvas; var canvas = renderer.canvas;
var gl = renderer.context.gl; var gl = renderer.context.gl;

File diff suppressed because one or more lines are too long

View File

@ -45,6 +45,45 @@ module spine {
} }
updateUVs () { updateUVs () {
let regionUVs = this.regionUVs;
if (this.uvs == null || this.uvs.length != regionUVs.length) this.uvs = Utils.newFloatArray(regionUVs.length);
let uvs = this.uvs;
let u = 0, v = 0, width = 0, height = 0;
if (this.region instanceof TextureAtlasRegion) {
let region = this.region;
let textureWidth = region.texture.getImage().width, textureHeight = region.texture.getImage().height;
if (region.rotate) {
u = region.u - (region.originalHeight - region.offsetY - region.height) / textureWidth;
v = region.v - (region.originalWidth - region.offsetX - region.width) / textureHeight;
width = region.originalHeight / textureWidth;
height = region.originalWidth / textureHeight;
for (let i = 0, n = uvs.length; i < n; i += 2) {
uvs[i] = u + regionUVs[i + 1] * width;
uvs[i + 1] = v + height - regionUVs[i] * height;
}
return;
}
u = region.u - region.offsetX / textureWidth;
v = region.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 {
u = this.region.u;
v = this.region.v;
width = this.region.u2 - u;
height = this.region.v2 - v;
}
for (let i = 0, n = uvs.length; i < n; i += 2) {
uvs[i] = u + regionUVs[i] * width;
uvs[i + 1] = v + regionUVs[i + 1] * height;
}
}
/*updateUVs () {
let u = 0, v = 0, width = 0, height = 0; let u = 0, v = 0, width = 0, height = 0;
if (this.region == null) { if (this.region == null) {
u = v = 0; u = v = 0;
@ -69,7 +108,7 @@ module spine {
uvs[i + 1] = v + regionUVs[i + 1] * height; uvs[i + 1] = v + regionUVs[i + 1] * height;
} }
} }
} }*/
applyDeform (sourceAttachment: VertexAttachment): boolean { applyDeform (sourceAttachment: VertexAttachment): boolean {
return this == sourceAttachment || (this.inheritDeform && this.parentMesh == sourceAttachment); return this == sourceAttachment || (this.inheritDeform && this.parentMesh == sourceAttachment);

View File

@ -325,7 +325,7 @@
if (!config.alpha) config.alpha = false; if (!config.alpha) config.alpha = false;
if (!config.backgroundColor) config.backgroundColor = "#000000"; if (!config.backgroundColor) config.backgroundColor = "#000000";
if (!config.fullScreenBackgroundColor) config.fullScreenBackgroundColor = config.backgroundColor; if (!config.fullScreenBackgroundColor) config.fullScreenBackgroundColor = config.backgroundColor;
if (!config.premultipliedAlpha) config.premultipliedAlpha = true; if (typeof config.premultipliedAlpha === "undefined") config.premultipliedAlpha = true;
if (!config.success) config.success = (widget) => {}; if (!config.success) config.success = (widget) => {};
if (!config.error) config.error = (widget, msg) => {}; if (!config.error) config.error = (widget, msg) => {};
if (!config.debug) config.debug = { if (!config.debug) config.debug = {
@ -338,14 +338,14 @@
points: false, points: false,
hulls: false hulls: false
} }
if (!config.debug.bones) config.debug.bones = false; if (typeof config.debug.bones === "undefined") config.debug.bones = false;
if (!config.debug.bounds) config.debug.bounds = false; if (typeof config.debug.bounds === "undefined") config.debug.bounds = false;
if (!config.debug.clipping) config.debug.clipping = false; if (typeof config.debug.clipping === "undefined") config.debug.clipping = false;
if (!config.debug.hulls) config.debug.hulls = false; if (typeof config.debug.hulls === "undefined") config.debug.hulls = false;
if (!config.debug.paths) config.debug.paths = false; if (typeof config.debug.paths === "undefined") config.debug.paths = false;
if (!config.debug.points) config.debug.points = false; if (typeof config.debug.points === "undefined") config.debug.points = false;
if (!config.debug.regions) config.debug.regions = false; if (typeof config.debug.regions === "undefined") config.debug.regions = false;
if (!config.debug.meshes) config.debug.meshes = false; if (typeof config.debug.meshes === "undefined") config.debug.meshes = false;
if (config.animations && config.animation) { if (config.animations && config.animation) {
if (config.animations.indexOf(config.animation) < 0) throw new Error("Default animation '" + config.animation + "' is not contained in the list of selectable animations " + escapeHtml(JSON.stringify(this.config.animations)) + "."); if (config.animations.indexOf(config.animation) < 0) throw new Error("Default animation '" + config.animation + "' is not contained in the list of selectable animations " + escapeHtml(JSON.stringify(this.config.animations)) + ".");