[ts] Fixed example HTML files.

This commit is contained in:
Nathan Sweet 2021-06-22 16:54:10 -04:00
parent 61b71e1d9a
commit 6c689eb5f8
25 changed files with 99 additions and 39 deletions

View File

@ -848,6 +848,7 @@ declare module spine {
regions: TextureAtlasRegion[];
constructor(atlasText: string);
findRegion(name: string): TextureAtlasRegion;
setTextures(assetManager: AssetManager, pathPrefix?: string): void;
dispose(): void;
}
class TextureAtlasPage {

View File

@ -2866,14 +2866,15 @@ var spine;
var _this = this;
if (success === void 0) { success = null; }
if (error === void 0) { error = null; }
var parent = path.lastIndexOf("/") >= 0 ? path.substring(0, path.lastIndexOf("/")) : "";
var index = path.lastIndexOf("/");
var parent = index >= 0 ? path.substring(0, index + 1) : "";
path = this.start(path);
this.downloader.downloadText(path, function (atlasText) {
try {
var atlas_1 = new spine.TextureAtlas(atlasText);
var toLoad_1 = atlas_1.pages.length, abort_1 = false;
var _loop_1 = function (page) {
_this.loadTexture(parent == "" ? page.name : parent + "/" + page.name, function (imagePath, texture) {
_this.loadTexture(parent + page.name, function (imagePath, texture) {
if (!abort_1) {
page.setTexture(texture);
if (--toLoad_1 == 0)
@ -7502,6 +7503,13 @@ var spine;
}
return null;
};
TextureAtlas.prototype.setTextures = function (assetManager, pathPrefix) {
if (pathPrefix === void 0) { pathPrefix = ""; }
for (var _i = 0, _a = this.pages; _i < _a.length; _i++) {
var page = _a[_i];
page.setTexture(assetManager.get(pathPrefix + page.name));
}
};
TextureAtlas.prototype.dispose = function () {
for (var i = 0; i < this.pages.length; i++) {
this.pages[i].texture.dispose();

File diff suppressed because one or more lines are too long

View File

@ -848,6 +848,7 @@ declare module spine {
regions: TextureAtlasRegion[];
constructor(atlasText: string);
findRegion(name: string): TextureAtlasRegion;
setTextures(assetManager: AssetManager, pathPrefix?: string): void;
dispose(): void;
}
class TextureAtlasPage {

View File

@ -2866,14 +2866,15 @@ var spine;
var _this = this;
if (success === void 0) { success = null; }
if (error === void 0) { error = null; }
var parent = path.lastIndexOf("/") >= 0 ? path.substring(0, path.lastIndexOf("/")) : "";
var index = path.lastIndexOf("/");
var parent = index >= 0 ? path.substring(0, index + 1) : "";
path = this.start(path);
this.downloader.downloadText(path, function (atlasText) {
try {
var atlas_1 = new spine.TextureAtlas(atlasText);
var toLoad_1 = atlas_1.pages.length, abort_1 = false;
var _loop_1 = function (page) {
_this.loadTexture(parent == "" ? page.name : parent + "/" + page.name, function (imagePath, texture) {
_this.loadTexture(parent + page.name, function (imagePath, texture) {
if (!abort_1) {
page.setTexture(texture);
if (--toLoad_1 == 0)
@ -7502,6 +7503,13 @@ var spine;
}
return null;
};
TextureAtlas.prototype.setTextures = function (assetManager, pathPrefix) {
if (pathPrefix === void 0) { pathPrefix = ""; }
for (var _i = 0, _a = this.pages; _i < _a.length; _i++) {
var page = _a[_i];
page.setTexture(assetManager.get(pathPrefix + page.name));
}
};
TextureAtlas.prototype.dispose = function () {
for (var i = 0; i < this.pages.length; i++) {
this.pages[i].texture.dispose();

File diff suppressed because one or more lines are too long

View File

@ -848,6 +848,7 @@ declare module spine {
regions: TextureAtlasRegion[];
constructor(atlasText: string);
findRegion(name: string): TextureAtlasRegion;
setTextures(assetManager: AssetManager, pathPrefix?: string): void;
dispose(): void;
}
class TextureAtlasPage {

View File

@ -2866,14 +2866,15 @@ var spine;
var _this = this;
if (success === void 0) { success = null; }
if (error === void 0) { error = null; }
var parent = path.lastIndexOf("/") >= 0 ? path.substring(0, path.lastIndexOf("/")) : "";
var index = path.lastIndexOf("/");
var parent = index >= 0 ? path.substring(0, index + 1) : "";
path = this.start(path);
this.downloader.downloadText(path, function (atlasText) {
try {
var atlas_1 = new spine.TextureAtlas(atlasText);
var toLoad_1 = atlas_1.pages.length, abort_1 = false;
var _loop_1 = function (page) {
_this.loadTexture(parent == "" ? page.name : parent + "/" + page.name, function (imagePath, texture) {
_this.loadTexture(parent + page.name, function (imagePath, texture) {
if (!abort_1) {
page.setTexture(texture);
if (--toLoad_1 == 0)
@ -7502,6 +7503,13 @@ var spine;
}
return null;
};
TextureAtlas.prototype.setTextures = function (assetManager, pathPrefix) {
if (pathPrefix === void 0) { pathPrefix = ""; }
for (var _i = 0, _a = this.pages; _i < _a.length; _i++) {
var page = _a[_i];
page.setTexture(assetManager.get(pathPrefix + page.name));
}
};
TextureAtlas.prototype.dispose = function () {
for (var i = 0; i < this.pages.length; i++) {
this.pages[i].texture.dispose();

File diff suppressed because one or more lines are too long

View File

@ -848,6 +848,7 @@ declare module spine {
regions: TextureAtlasRegion[];
constructor(atlasText: string);
findRegion(name: string): TextureAtlasRegion;
setTextures(assetManager: AssetManager, pathPrefix?: string): void;
dispose(): void;
}
class TextureAtlasPage {

View File

@ -2866,14 +2866,15 @@ var spine;
var _this = this;
if (success === void 0) { success = null; }
if (error === void 0) { error = null; }
var parent = path.lastIndexOf("/") >= 0 ? path.substring(0, path.lastIndexOf("/")) : "";
var index = path.lastIndexOf("/");
var parent = index >= 0 ? path.substring(0, index + 1) : "";
path = this.start(path);
this.downloader.downloadText(path, function (atlasText) {
try {
var atlas_1 = new spine.TextureAtlas(atlasText);
var toLoad_1 = atlas_1.pages.length, abort_1 = false;
var _loop_1 = function (page) {
_this.loadTexture(parent == "" ? page.name : parent + "/" + page.name, function (imagePath, texture) {
_this.loadTexture(parent + page.name, function (imagePath, texture) {
if (!abort_1) {
page.setTexture(texture);
if (--toLoad_1 == 0)
@ -7502,6 +7503,13 @@ var spine;
}
return null;
};
TextureAtlas.prototype.setTextures = function (assetManager, pathPrefix) {
if (pathPrefix === void 0) { pathPrefix = ""; }
for (var _i = 0, _a = this.pages; _i < _a.length; _i++) {
var page = _a[_i];
page.setTexture(assetManager.get(pathPrefix + page.name));
}
};
TextureAtlas.prototype.dispose = function () {
for (var i = 0; i < this.pages.length; i++) {
this.pages[i].texture.dispose();

File diff suppressed because one or more lines are too long

View File

@ -848,6 +848,7 @@ declare module spine {
regions: TextureAtlasRegion[];
constructor(atlasText: string);
findRegion(name: string): TextureAtlasRegion;
setTextures(assetManager: AssetManager, pathPrefix?: string): void;
dispose(): void;
}
class TextureAtlasPage {

View File

@ -2866,14 +2866,15 @@ var spine;
var _this = this;
if (success === void 0) { success = null; }
if (error === void 0) { error = null; }
var parent = path.lastIndexOf("/") >= 0 ? path.substring(0, path.lastIndexOf("/")) : "";
var index = path.lastIndexOf("/");
var parent = index >= 0 ? path.substring(0, index + 1) : "";
path = this.start(path);
this.downloader.downloadText(path, function (atlasText) {
try {
var atlas_1 = new spine.TextureAtlas(atlasText);
var toLoad_1 = atlas_1.pages.length, abort_1 = false;
var _loop_1 = function (page) {
_this.loadTexture(parent == "" ? page.name : parent + "/" + page.name, function (imagePath, texture) {
_this.loadTexture(parent + page.name, function (imagePath, texture) {
if (!abort_1) {
page.setTexture(texture);
if (--toLoad_1 == 0)
@ -7502,6 +7503,13 @@ var spine;
}
return null;
};
TextureAtlas.prototype.setTextures = function (assetManager, pathPrefix) {
if (pathPrefix === void 0) { pathPrefix = ""; }
for (var _i = 0, _a = this.pages; _i < _a.length; _i++) {
var page = _a[_i];
page.setTexture(assetManager.get(pathPrefix + page.name));
}
};
TextureAtlas.prototype.dispose = function () {
for (var i = 0; i < this.pages.length; i++) {
this.pages[i].texture.dispose();

File diff suppressed because one or more lines are too long

View File

@ -848,6 +848,7 @@ declare module spine {
regions: TextureAtlasRegion[];
constructor(atlasText: string);
findRegion(name: string): TextureAtlasRegion;
setTextures(assetManager: AssetManager, pathPrefix?: string): void;
dispose(): void;
}
class TextureAtlasPage {

View File

@ -2866,14 +2866,15 @@ var spine;
var _this = this;
if (success === void 0) { success = null; }
if (error === void 0) { error = null; }
var parent = path.lastIndexOf("/") >= 0 ? path.substring(0, path.lastIndexOf("/")) : "";
var index = path.lastIndexOf("/");
var parent = index >= 0 ? path.substring(0, index + 1) : "";
path = this.start(path);
this.downloader.downloadText(path, function (atlasText) {
try {
var atlas_1 = new spine.TextureAtlas(atlasText);
var toLoad_1 = atlas_1.pages.length, abort_1 = false;
var _loop_1 = function (page) {
_this.loadTexture(parent == "" ? page.name : parent + "/" + page.name, function (imagePath, texture) {
_this.loadTexture(parent + page.name, function (imagePath, texture) {
if (!abort_1) {
page.setTexture(texture);
if (--toLoad_1 == 0)
@ -7502,6 +7503,13 @@ var spine;
}
return null;
};
TextureAtlas.prototype.setTextures = function (assetManager, pathPrefix) {
if (pathPrefix === void 0) { pathPrefix = ""; }
for (var _i = 0, _a = this.pages; _i < _a.length; _i++) {
var page = _a[_i];
page.setTexture(assetManager.get(pathPrefix + page.name));
}
};
TextureAtlas.prototype.dispose = function () {
for (var i = 0; i < this.pages.length; i++) {
this.pages[i].texture.dispose();

File diff suppressed because one or more lines are too long

View File

@ -32,11 +32,11 @@ function init () {
// enable the triangle renderer, supports meshes, but may produce artifacts in some browsers
skeletonRenderer.triangleRendering = false;
assetManager = new spine.canvas.AssetManager();
assetManager = new spine.canvas.AssetManager("assets/");
assetManager.loadText("assets/" + skelName + ".json");
assetManager.loadText("assets/" + skelName.replace("-pro", "").replace("-ess", "") + ".atlas");
assetManager.loadTexture("assets/" + skelName.replace("-pro", "").replace("-ess", "") + ".png");
assetManager.loadText(skelName + ".json");
assetManager.loadText(skelName.replace("-pro", "").replace("-ess", "") + ".atlas");
assetManager.loadTexture(skelName.replace("-pro", "").replace("-ess", "") + ".png");
requestAnimationFrame(load);
}
@ -58,9 +58,8 @@ function loadSkeleton (name, initialAnimation, skin) {
// Load the texture atlas using name.atlas and name.png from the AssetManager.
// The function passed to TextureAtlas is used to resolve relative paths.
atlas = new spine.TextureAtlas(assetManager.get("assets/" + name.replace("-pro", "").replace("-ess", "") + ".atlas"), function(path) {
return assetManager.get("assets/" + path);
});
atlas = new spine.TextureAtlas(assetManager.get(name.replace("-pro", "").replace("-ess", "") + ".atlas"));
atlas.setTextures(assetManager);
// Create a AtlasAttachmentLoader, which is specific to the WebGL backend.
atlasLoader = new spine.AtlasAttachmentLoader(atlas);
@ -69,7 +68,7 @@ function loadSkeleton (name, initialAnimation, skin) {
var skeletonJson = new spine.SkeletonJson(atlasLoader);
// Set the scale to apply during parsing, parse the file, and create a new skeleton.
var skeletonData = skeletonJson.readSkeletonData(assetManager.get("assets/" + name + ".json"));
var skeletonData = skeletonJson.readSkeletonData(assetManager.get(name + ".json"));
var skeleton = new spine.Skeleton(skeletonData);
skeleton.scaleY = -1;
var bounds = calculateBounds(skeleton);

View File

@ -137,7 +137,8 @@ module spine {
success: (path: string, atlas: TextureAtlas) => void = null,
error: (path: string, message: string) => void = null
) {
let parent = path.lastIndexOf("/") >= 0 ? path.substring(0, path.lastIndexOf("/")) : "";
let index = path.lastIndexOf("/");
let parent = index >= 0 ? path.substring(0, index + 1) : "";
path = this.start(path);
this.downloader.downloadText(path, (atlasText: string): void => {
@ -145,7 +146,7 @@ module spine {
let atlas = new TextureAtlas(atlasText);
let toLoad = atlas.pages.length, abort = false;
for (let page of atlas.pages) {
this.loadTexture(parent == "" ? page.name : parent + "/" + page.name,
this.loadTexture(parent + page.name,
(imagePath: string, texture: Texture) => {
if (!abort) {
page.setTexture(texture);

View File

@ -182,6 +182,11 @@ module spine {
return null;
}
setTextures (assetManager: AssetManager, pathPrefix: string = "") {
for (let page of this.pages)
page.setTexture(assetManager.get(pathPrefix + page.name));
}
dispose () {
for (let i = 0; i < this.pages.length; i++) {
this.pages[i].texture.dispose();

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -45,9 +45,8 @@
function load () {
if (assetManager.isLoadingComplete()) {
var atlas = new spine.TextureAtlas(assetManager.get("owl-pma.atlas"), function(path) {
return assetManager.get(path);
});
var atlas = new spine.TextureAtlas(assetManager.get("owl-pma.atlas"));
atlas.setTextures(assetManager);
var atlasLoader = new spine.AtlasAttachmentLoader(atlas);
var skeletonJson = new spine.SkeletonJson(atlasLoader);
skeletonJson.scale = 0.5;
@ -57,17 +56,18 @@
animationStateData.defaultMix = 0.3;
animationState = new spine.AnimationState(animationStateData);
animationState.setAnimation(0, "blink", true);
upEntry = animationState.setAnimation(1, "up", true);
animationState.setAnimation(0, "idle", true);
animationState.setAnimation(1, "blink", true);
upEntry = animationState.setAnimation(2, "up", true);
upEntry.alpha = 0;
upEntry.mixBlend = spine.MixBlend.add;
downEntry = animationState.setAnimation(2, "down", true);
downEntry = animationState.setAnimation(3, "down", true);
downEntry.alpha = 0;
downEntry.mixBlend = spine.MixBlend.add;
leftEntry = animationState.setAnimation(3, "left", true);
leftEntry = animationState.setAnimation(4, "left", true);
leftEntry.alpha = 0;
leftEntry.mixBlend = spine.MixBlend.add;
rightEntry = animationState.setAnimation(4, "right", true);
rightEntry = animationState.setAnimation(5, "right", true);
rightEntry.alpha = 0;
rightEntry.mixBlend = spine.MixBlend.add;
@ -80,6 +80,7 @@
function render () {
time.update();
animationState.update(time.delta);
skeleton.setToSetupPose(); // Or key all bones used in the additive animations in a lower track, like idle.
animationState.apply(skeleton);
skeleton.y = -canvas.height / 2 / 2;
skeleton.updateWorldTransform();

View File

@ -13,7 +13,7 @@
<script>
var FILE = "coin-pro";
var ANIMATION = "rotate";
var ANIMATION = "animation";
var NUM_SKELETONS = 1;
var SCALE = 0.5;