mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-07 03:06:55 +08:00
[ts] Added AssetManager#require which throws an error for an asset that isn't loaded.
This commit is contained in:
parent
1fbe75cd71
commit
b8bf2a9bbb
26
spine-ts/build/spine-all.d.ts
vendored
26
spine-ts/build/spine-all.d.ts
vendored
@ -361,6 +361,7 @@ declare module spine {
|
|||||||
loadTexture(path: string, success?: (path: string, texture: Texture) => void, error?: (path: string, message: string) => void): void;
|
loadTexture(path: string, success?: (path: string, texture: Texture) => void, error?: (path: string, message: string) => void): void;
|
||||||
loadTextureAtlas(path: string, success?: (path: string, atlas: TextureAtlas) => void, error?: (path: string, message: string) => void): void;
|
loadTextureAtlas(path: string, success?: (path: string, atlas: TextureAtlas) => void, error?: (path: string, message: string) => void): void;
|
||||||
get(path: string): any;
|
get(path: string): any;
|
||||||
|
require(path: string): any;
|
||||||
remove(path: string): any;
|
remove(path: string): any;
|
||||||
removeAll(): void;
|
removeAll(): void;
|
||||||
isLoadingComplete(): boolean;
|
isLoadingComplete(): boolean;
|
||||||
@ -1778,7 +1779,7 @@ declare module spine {
|
|||||||
interface SpinePlayerConfig {
|
interface SpinePlayerConfig {
|
||||||
jsonUrl: string;
|
jsonUrl: string;
|
||||||
jsonField: string;
|
jsonField: string;
|
||||||
skelUrl: string;
|
binaryUrl: string;
|
||||||
atlasUrl: string;
|
atlasUrl: string;
|
||||||
rawDataURIs: Map<string>;
|
rawDataURIs: Map<string>;
|
||||||
animation: string;
|
animation: string;
|
||||||
@ -1826,9 +1827,10 @@ declare module spine {
|
|||||||
controlBones: string[];
|
controlBones: string[];
|
||||||
success: (player: SpinePlayer) => void;
|
success: (player: SpinePlayer) => void;
|
||||||
error: (player: SpinePlayer, msg: string) => void;
|
error: (player: SpinePlayer, msg: string) => void;
|
||||||
frame: (player: SpinePlayer) => void;
|
frame: (player: SpinePlayer, delta: number) => void;
|
||||||
update: (player: SpinePlayer) => void;
|
update: (player: SpinePlayer, delta: number) => void;
|
||||||
draw: (player: SpinePlayer) => void;
|
draw: (player: SpinePlayer, delta: number) => void;
|
||||||
|
loading: (player: SpinePlayer, delta: number) => void;
|
||||||
downloader: spine.Downloader;
|
downloader: spine.Downloader;
|
||||||
}
|
}
|
||||||
interface Viewport {
|
interface Viewport {
|
||||||
@ -1843,12 +1845,12 @@ declare module spine {
|
|||||||
}
|
}
|
||||||
class SpinePlayer {
|
class SpinePlayer {
|
||||||
private config;
|
private config;
|
||||||
private parent;
|
parent: HTMLElement;
|
||||||
dom: HTMLElement;
|
dom: HTMLElement;
|
||||||
canvas: HTMLCanvasElement;
|
canvas: HTMLCanvasElement;
|
||||||
private context;
|
context: spine.webgl.ManagedWebGLRenderingContext;
|
||||||
private sceneRenderer;
|
sceneRenderer: spine.webgl.SceneRenderer;
|
||||||
private loadingScreen;
|
loadingScreen: spine.webgl.LoadingScreen;
|
||||||
assetManager: spine.webgl.AssetManager;
|
assetManager: spine.webgl.AssetManager;
|
||||||
bg: Color;
|
bg: Color;
|
||||||
bgFullscreen: Color;
|
bgFullscreen: Color;
|
||||||
@ -1864,16 +1866,17 @@ declare module spine {
|
|||||||
error: boolean;
|
error: boolean;
|
||||||
skeleton: Skeleton;
|
skeleton: Skeleton;
|
||||||
animationState: AnimationState;
|
animationState: AnimationState;
|
||||||
private paused;
|
paused: boolean;
|
||||||
speed: number;
|
speed: number;
|
||||||
private time;
|
time: TimeKeeper;
|
||||||
private stopRequestAnimationFrame;
|
private stopRequestAnimationFrame;
|
||||||
|
private viewport;
|
||||||
private currentViewport;
|
private currentViewport;
|
||||||
private previousViewport;
|
private previousViewport;
|
||||||
private viewportTransitionStart;
|
private viewportTransitionStart;
|
||||||
constructor(parent: HTMLElement | string, config: SpinePlayerConfig);
|
constructor(parent: HTMLElement | string, config: SpinePlayerConfig);
|
||||||
private validateConfig;
|
private validateConfig;
|
||||||
private create;
|
private initialize;
|
||||||
private loadSkeleton;
|
private loadSkeleton;
|
||||||
private setupInput;
|
private setupInput;
|
||||||
play(): void;
|
play(): void;
|
||||||
@ -1884,7 +1887,6 @@ declare module spine {
|
|||||||
private percentageToWorldUnit;
|
private percentageToWorldUnit;
|
||||||
private calculateAnimationViewport;
|
private calculateAnimationViewport;
|
||||||
private drawFrame;
|
private drawFrame;
|
||||||
private scale;
|
|
||||||
stopRendering(): void;
|
stopRendering(): void;
|
||||||
private showSpeedDialog;
|
private showSpeedDialog;
|
||||||
private showAnimationsDialog;
|
private showAnimationsDialog;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
spine-ts/build/spine-canvas.d.ts
vendored
1
spine-ts/build/spine-canvas.d.ts
vendored
@ -361,6 +361,7 @@ declare module spine {
|
|||||||
loadTexture(path: string, success?: (path: string, texture: Texture) => void, error?: (path: string, message: string) => void): void;
|
loadTexture(path: string, success?: (path: string, texture: Texture) => void, error?: (path: string, message: string) => void): void;
|
||||||
loadTextureAtlas(path: string, success?: (path: string, atlas: TextureAtlas) => void, error?: (path: string, message: string) => void): void;
|
loadTextureAtlas(path: string, success?: (path: string, atlas: TextureAtlas) => void, error?: (path: string, message: string) => void): void;
|
||||||
get(path: string): any;
|
get(path: string): any;
|
||||||
|
require(path: string): any;
|
||||||
remove(path: string): any;
|
remove(path: string): any;
|
||||||
removeAll(): void;
|
removeAll(): void;
|
||||||
isLoadingComplete(): boolean;
|
isLoadingComplete(): boolean;
|
||||||
|
|||||||
@ -2882,7 +2882,7 @@ var spine;
|
|||||||
}
|
}
|
||||||
}, function (imagePath, message) {
|
}, function (imagePath, message) {
|
||||||
if (!abort_1)
|
if (!abort_1)
|
||||||
_this.error(error, path, "Couldn't load texture atlas " + path + " page " + imagePath + ": " + message);
|
_this.error(error, path, "Couldn't load texture atlas " + path + " page image: " + imagePath);
|
||||||
abort_1 = true;
|
abort_1 = true;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -2901,6 +2901,14 @@ var spine;
|
|||||||
AssetManager.prototype.get = function (path) {
|
AssetManager.prototype.get = function (path) {
|
||||||
return this.assets[this.pathPrefix + path];
|
return this.assets[this.pathPrefix + path];
|
||||||
};
|
};
|
||||||
|
AssetManager.prototype.require = function (path) {
|
||||||
|
path = this.pathPrefix + path;
|
||||||
|
var asset = this.assets[path];
|
||||||
|
if (asset)
|
||||||
|
return asset;
|
||||||
|
var error = this.errors[path];
|
||||||
|
throw Error("Asset not found: " + path + (error ? "\n" + error : ""));
|
||||||
|
};
|
||||||
AssetManager.prototype.remove = function (path) {
|
AssetManager.prototype.remove = function (path) {
|
||||||
path = this.pathPrefix + path;
|
path = this.pathPrefix + path;
|
||||||
var asset = this.assets[path];
|
var asset = this.assets[path];
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
1
spine-ts/build/spine-core.d.ts
vendored
1
spine-ts/build/spine-core.d.ts
vendored
@ -361,6 +361,7 @@ declare module spine {
|
|||||||
loadTexture(path: string, success?: (path: string, texture: Texture) => void, error?: (path: string, message: string) => void): void;
|
loadTexture(path: string, success?: (path: string, texture: Texture) => void, error?: (path: string, message: string) => void): void;
|
||||||
loadTextureAtlas(path: string, success?: (path: string, atlas: TextureAtlas) => void, error?: (path: string, message: string) => void): void;
|
loadTextureAtlas(path: string, success?: (path: string, atlas: TextureAtlas) => void, error?: (path: string, message: string) => void): void;
|
||||||
get(path: string): any;
|
get(path: string): any;
|
||||||
|
require(path: string): any;
|
||||||
remove(path: string): any;
|
remove(path: string): any;
|
||||||
removeAll(): void;
|
removeAll(): void;
|
||||||
isLoadingComplete(): boolean;
|
isLoadingComplete(): boolean;
|
||||||
|
|||||||
@ -2882,7 +2882,7 @@ var spine;
|
|||||||
}
|
}
|
||||||
}, function (imagePath, message) {
|
}, function (imagePath, message) {
|
||||||
if (!abort_1)
|
if (!abort_1)
|
||||||
_this.error(error, path, "Couldn't load texture atlas " + path + " page " + imagePath + ": " + message);
|
_this.error(error, path, "Couldn't load texture atlas " + path + " page image: " + imagePath);
|
||||||
abort_1 = true;
|
abort_1 = true;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -2901,6 +2901,14 @@ var spine;
|
|||||||
AssetManager.prototype.get = function (path) {
|
AssetManager.prototype.get = function (path) {
|
||||||
return this.assets[this.pathPrefix + path];
|
return this.assets[this.pathPrefix + path];
|
||||||
};
|
};
|
||||||
|
AssetManager.prototype.require = function (path) {
|
||||||
|
path = this.pathPrefix + path;
|
||||||
|
var asset = this.assets[path];
|
||||||
|
if (asset)
|
||||||
|
return asset;
|
||||||
|
var error = this.errors[path];
|
||||||
|
throw Error("Asset not found: " + path + (error ? "\n" + error : ""));
|
||||||
|
};
|
||||||
AssetManager.prototype.remove = function (path) {
|
AssetManager.prototype.remove = function (path) {
|
||||||
path = this.pathPrefix + path;
|
path = this.pathPrefix + path;
|
||||||
var asset = this.assets[path];
|
var asset = this.assets[path];
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
1
spine-ts/build/spine-player.d.ts
vendored
1
spine-ts/build/spine-player.d.ts
vendored
@ -361,6 +361,7 @@ declare module spine {
|
|||||||
loadTexture(path: string, success?: (path: string, texture: Texture) => void, error?: (path: string, message: string) => void): void;
|
loadTexture(path: string, success?: (path: string, texture: Texture) => void, error?: (path: string, message: string) => void): void;
|
||||||
loadTextureAtlas(path: string, success?: (path: string, atlas: TextureAtlas) => void, error?: (path: string, message: string) => void): void;
|
loadTextureAtlas(path: string, success?: (path: string, atlas: TextureAtlas) => void, error?: (path: string, message: string) => void): void;
|
||||||
get(path: string): any;
|
get(path: string): any;
|
||||||
|
require(path: string): any;
|
||||||
remove(path: string): any;
|
remove(path: string): any;
|
||||||
removeAll(): void;
|
removeAll(): void;
|
||||||
isLoadingComplete(): boolean;
|
isLoadingComplete(): boolean;
|
||||||
|
|||||||
@ -2882,7 +2882,7 @@ var spine;
|
|||||||
}
|
}
|
||||||
}, function (imagePath, message) {
|
}, function (imagePath, message) {
|
||||||
if (!abort_1)
|
if (!abort_1)
|
||||||
_this.error(error, path, "Couldn't load texture atlas " + path + " page " + imagePath + ": " + message);
|
_this.error(error, path, "Couldn't load texture atlas " + path + " page image: " + imagePath);
|
||||||
abort_1 = true;
|
abort_1 = true;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -2901,6 +2901,14 @@ var spine;
|
|||||||
AssetManager.prototype.get = function (path) {
|
AssetManager.prototype.get = function (path) {
|
||||||
return this.assets[this.pathPrefix + path];
|
return this.assets[this.pathPrefix + path];
|
||||||
};
|
};
|
||||||
|
AssetManager.prototype.require = function (path) {
|
||||||
|
path = this.pathPrefix + path;
|
||||||
|
var asset = this.assets[path];
|
||||||
|
if (asset)
|
||||||
|
return asset;
|
||||||
|
var error = this.errors[path];
|
||||||
|
throw Error("Asset not found: " + path + (error ? "\n" + error : ""));
|
||||||
|
};
|
||||||
AssetManager.prototype.remove = function (path) {
|
AssetManager.prototype.remove = function (path) {
|
||||||
path = this.pathPrefix + path;
|
path = this.pathPrefix + path;
|
||||||
var asset = this.assets[path];
|
var asset = this.assets[path];
|
||||||
@ -11799,7 +11807,7 @@ var spine;
|
|||||||
if (this.assetManager.hasErrors())
|
if (this.assetManager.hasErrors())
|
||||||
this.showError("Error: Assets could not be loaded.\n" + toString(this.assetManager.getErrors()));
|
this.showError("Error: Assets could not be loaded.\n" + toString(this.assetManager.getErrors()));
|
||||||
var config = this.config;
|
var config = this.config;
|
||||||
var atlas = this.assetManager.get(config.atlasUrl);
|
var atlas = this.assetManager.require(config.atlasUrl);
|
||||||
var gl = this.context.gl, anisotropic = gl.getExtension("EXT_texture_filter_anisotropic");
|
var gl = this.context.gl, anisotropic = gl.getExtension("EXT_texture_filter_anisotropic");
|
||||||
for (var _i = 0, _a = atlas.pages; _i < _a.length; _i++) {
|
for (var _i = 0, _a = atlas.pages; _i < _a.length; _i++) {
|
||||||
var page = _a[_i];
|
var page = _a[_i];
|
||||||
@ -12191,7 +12199,7 @@ var spine;
|
|||||||
renderer.begin();
|
renderer.begin();
|
||||||
var bgImage = config.backgroundImage;
|
var bgImage = config.backgroundImage;
|
||||||
if (bgImage) {
|
if (bgImage) {
|
||||||
var texture = this.assetManager.get(bgImage.url);
|
var texture = this.assetManager.require(bgImage.url);
|
||||||
if (bgImage.x !== void 0 && bgImage.y !== void 0 && bgImage.width && bgImage.height)
|
if (bgImage.x !== void 0 && bgImage.y !== void 0 && bgImage.width && bgImage.height)
|
||||||
renderer.drawTexture(texture, bgImage.x, bgImage.y, bgImage.width, bgImage.height);
|
renderer.drawTexture(texture, bgImage.x, bgImage.y, bgImage.width, bgImage.height);
|
||||||
else
|
else
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
1
spine-ts/build/spine-threejs.d.ts
vendored
1
spine-ts/build/spine-threejs.d.ts
vendored
@ -361,6 +361,7 @@ declare module spine {
|
|||||||
loadTexture(path: string, success?: (path: string, texture: Texture) => void, error?: (path: string, message: string) => void): void;
|
loadTexture(path: string, success?: (path: string, texture: Texture) => void, error?: (path: string, message: string) => void): void;
|
||||||
loadTextureAtlas(path: string, success?: (path: string, atlas: TextureAtlas) => void, error?: (path: string, message: string) => void): void;
|
loadTextureAtlas(path: string, success?: (path: string, atlas: TextureAtlas) => void, error?: (path: string, message: string) => void): void;
|
||||||
get(path: string): any;
|
get(path: string): any;
|
||||||
|
require(path: string): any;
|
||||||
remove(path: string): any;
|
remove(path: string): any;
|
||||||
removeAll(): void;
|
removeAll(): void;
|
||||||
isLoadingComplete(): boolean;
|
isLoadingComplete(): boolean;
|
||||||
|
|||||||
@ -2882,7 +2882,7 @@ var spine;
|
|||||||
}
|
}
|
||||||
}, function (imagePath, message) {
|
}, function (imagePath, message) {
|
||||||
if (!abort_1)
|
if (!abort_1)
|
||||||
_this.error(error, path, "Couldn't load texture atlas " + path + " page " + imagePath + ": " + message);
|
_this.error(error, path, "Couldn't load texture atlas " + path + " page image: " + imagePath);
|
||||||
abort_1 = true;
|
abort_1 = true;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -2901,6 +2901,14 @@ var spine;
|
|||||||
AssetManager.prototype.get = function (path) {
|
AssetManager.prototype.get = function (path) {
|
||||||
return this.assets[this.pathPrefix + path];
|
return this.assets[this.pathPrefix + path];
|
||||||
};
|
};
|
||||||
|
AssetManager.prototype.require = function (path) {
|
||||||
|
path = this.pathPrefix + path;
|
||||||
|
var asset = this.assets[path];
|
||||||
|
if (asset)
|
||||||
|
return asset;
|
||||||
|
var error = this.errors[path];
|
||||||
|
throw Error("Asset not found: " + path + (error ? "\n" + error : ""));
|
||||||
|
};
|
||||||
AssetManager.prototype.remove = function (path) {
|
AssetManager.prototype.remove = function (path) {
|
||||||
path = this.pathPrefix + path;
|
path = this.pathPrefix + path;
|
||||||
var asset = this.assets[path];
|
var asset = this.assets[path];
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
1
spine-ts/build/spine-webgl.d.ts
vendored
1
spine-ts/build/spine-webgl.d.ts
vendored
@ -361,6 +361,7 @@ declare module spine {
|
|||||||
loadTexture(path: string, success?: (path: string, texture: Texture) => void, error?: (path: string, message: string) => void): void;
|
loadTexture(path: string, success?: (path: string, texture: Texture) => void, error?: (path: string, message: string) => void): void;
|
||||||
loadTextureAtlas(path: string, success?: (path: string, atlas: TextureAtlas) => void, error?: (path: string, message: string) => void): void;
|
loadTextureAtlas(path: string, success?: (path: string, atlas: TextureAtlas) => void, error?: (path: string, message: string) => void): void;
|
||||||
get(path: string): any;
|
get(path: string): any;
|
||||||
|
require(path: string): any;
|
||||||
remove(path: string): any;
|
remove(path: string): any;
|
||||||
removeAll(): void;
|
removeAll(): void;
|
||||||
isLoadingComplete(): boolean;
|
isLoadingComplete(): boolean;
|
||||||
|
|||||||
@ -2882,7 +2882,7 @@ var spine;
|
|||||||
}
|
}
|
||||||
}, function (imagePath, message) {
|
}, function (imagePath, message) {
|
||||||
if (!abort_1)
|
if (!abort_1)
|
||||||
_this.error(error, path, "Couldn't load texture atlas " + path + " page " + imagePath + ": " + message);
|
_this.error(error, path, "Couldn't load texture atlas " + path + " page image: " + imagePath);
|
||||||
abort_1 = true;
|
abort_1 = true;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -2901,6 +2901,14 @@ var spine;
|
|||||||
AssetManager.prototype.get = function (path) {
|
AssetManager.prototype.get = function (path) {
|
||||||
return this.assets[this.pathPrefix + path];
|
return this.assets[this.pathPrefix + path];
|
||||||
};
|
};
|
||||||
|
AssetManager.prototype.require = function (path) {
|
||||||
|
path = this.pathPrefix + path;
|
||||||
|
var asset = this.assets[path];
|
||||||
|
if (asset)
|
||||||
|
return asset;
|
||||||
|
var error = this.errors[path];
|
||||||
|
throw Error("Asset not found: " + path + (error ? "\n" + error : ""));
|
||||||
|
};
|
||||||
AssetManager.prototype.remove = function (path) {
|
AssetManager.prototype.remove = function (path) {
|
||||||
path = this.pathPrefix + path;
|
path = this.pathPrefix + path;
|
||||||
var asset = this.assets[path];
|
var asset = this.assets[path];
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -58,7 +58,7 @@ function loadSkeleton (name, initialAnimation, skin) {
|
|||||||
|
|
||||||
// Load the texture atlas using name.atlas and name.png from the AssetManager.
|
// Load the texture atlas using name.atlas and name.png from the AssetManager.
|
||||||
// The function passed to TextureAtlas is used to resolve relative paths.
|
// The function passed to TextureAtlas is used to resolve relative paths.
|
||||||
atlas = new spine.TextureAtlas(assetManager.get(name.replace("-pro", "").replace("-ess", "") + ".atlas"));
|
atlas = new spine.TextureAtlas(assetManager.require(name.replace("-pro", "").replace("-ess", "") + ".atlas"));
|
||||||
atlas.setTextures(assetManager);
|
atlas.setTextures(assetManager);
|
||||||
|
|
||||||
// Create a AtlasAttachmentLoader, which is specific to the WebGL backend.
|
// Create a AtlasAttachmentLoader, which is specific to the WebGL backend.
|
||||||
@ -68,7 +68,7 @@ function loadSkeleton (name, initialAnimation, skin) {
|
|||||||
var skeletonJson = new spine.SkeletonJson(atlasLoader);
|
var skeletonJson = new spine.SkeletonJson(atlasLoader);
|
||||||
|
|
||||||
// Set the scale to apply during parsing, parse the file, and create a new skeleton.
|
// Set the scale to apply during parsing, parse the file, and create a new skeleton.
|
||||||
var skeletonData = skeletonJson.readSkeletonData(assetManager.get(name + ".json"));
|
var skeletonData = skeletonJson.readSkeletonData(assetManager.require(name + ".json"));
|
||||||
var skeleton = new spine.Skeleton(skeletonData);
|
var skeleton = new spine.Skeleton(skeletonData);
|
||||||
skeleton.scaleY = -1;
|
skeleton.scaleY = -1;
|
||||||
var bounds = calculateBounds(skeleton);
|
var bounds = calculateBounds(skeleton);
|
||||||
|
|||||||
@ -154,7 +154,7 @@ module spine {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
(imagePath: string, message: string) => {
|
(imagePath: string, message: string) => {
|
||||||
if (!abort) this.error(error, path, `Couldn't load texture atlas ${path} page ${imagePath}: ${message}`);
|
if (!abort) this.error(error, path, `Couldn't load texture atlas ${path} page image: ${imagePath}`);
|
||||||
abort = true;
|
abort = true;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -171,6 +171,14 @@ module spine {
|
|||||||
return this.assets[this.pathPrefix + path];
|
return this.assets[this.pathPrefix + path];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
require (path: string) {
|
||||||
|
path = this.pathPrefix + path;
|
||||||
|
let asset = this.assets[path];
|
||||||
|
if (asset) return asset;
|
||||||
|
let error = this.errors[path];
|
||||||
|
throw Error("Asset not found: " + path + (error ? "\n" + error : ""));
|
||||||
|
}
|
||||||
|
|
||||||
remove (path: string) {
|
remove (path: string) {
|
||||||
path = this.pathPrefix + path;
|
path = this.pathPrefix + path;
|
||||||
let asset = this.assets[path];
|
let asset = this.assets[path];
|
||||||
|
|||||||
@ -397,7 +397,7 @@ module spine {
|
|||||||
let config = this.config;
|
let config = this.config;
|
||||||
|
|
||||||
// Configure filtering.
|
// Configure filtering.
|
||||||
let atlas = this.assetManager.get(config.atlasUrl);
|
let atlas = this.assetManager.require(config.atlasUrl);
|
||||||
let gl = this.context.gl, anisotropic = gl.getExtension("EXT_texture_filter_anisotropic");
|
let gl = this.context.gl, anisotropic = gl.getExtension("EXT_texture_filter_anisotropic");
|
||||||
for (let page of atlas.pages) {
|
for (let page of atlas.pages) {
|
||||||
let minFilter = page.minFilter;
|
let minFilter = page.minFilter;
|
||||||
@ -818,7 +818,7 @@ module spine {
|
|||||||
// Draw the background image.
|
// Draw the background image.
|
||||||
let bgImage = config.backgroundImage;
|
let bgImage = config.backgroundImage;
|
||||||
if (bgImage) {
|
if (bgImage) {
|
||||||
let texture = this.assetManager.get(bgImage.url);
|
let texture = this.assetManager.require(bgImage.url);
|
||||||
if (bgImage.x !== void 0 && bgImage.y !== void 0 && bgImage.width && bgImage.height)
|
if (bgImage.x !== void 0 && bgImage.y !== void 0 && bgImage.width && bgImage.height)
|
||||||
renderer.drawTexture(texture, bgImage.x, bgImage.y, bgImage.width, bgImage.height);
|
renderer.drawTexture(texture, bgImage.x, bgImage.y, bgImage.width, bgImage.height);
|
||||||
else
|
else
|
||||||
|
|||||||
@ -54,7 +54,7 @@ function load (name, scale) {
|
|||||||
|
|
||||||
// Load the texture atlas using name.atlas and name.png from the AssetManager.
|
// Load the texture atlas using name.atlas and name.png from the AssetManager.
|
||||||
// The function passed to TextureAtlas is used to resolve relative paths.
|
// The function passed to TextureAtlas is used to resolve relative paths.
|
||||||
atlas = assetManager.get(atlasFile);
|
atlas = assetManager.require(atlasFile);
|
||||||
|
|
||||||
// Create a AtlasAttachmentLoader that resolves region, mesh, boundingbox and path attachments
|
// Create a AtlasAttachmentLoader that resolves region, mesh, boundingbox and path attachments
|
||||||
atlasLoader = new spine.AtlasAttachmentLoader(atlas);
|
atlasLoader = new spine.AtlasAttachmentLoader(atlas);
|
||||||
@ -64,7 +64,7 @@ function load (name, scale) {
|
|||||||
|
|
||||||
// Set the scale to apply during parsing, parse the file, and create a new skeleton.
|
// Set the scale to apply during parsing, parse the file, and create a new skeleton.
|
||||||
skeletonJson.scale = 0.4;
|
skeletonJson.scale = 0.4;
|
||||||
var skeletonData = skeletonJson.readSkeletonData(assetManager.get(skeletonFile));
|
var skeletonData = skeletonJson.readSkeletonData(assetManager.require(skeletonFile));
|
||||||
|
|
||||||
// Create a SkeletonMesh from the data and attach it to the scene
|
// Create a SkeletonMesh from the data and attach it to the scene
|
||||||
skeletonMesh = new spine.threejs.SkeletonMesh(skeletonData, function(parameters) {
|
skeletonMesh = new spine.threejs.SkeletonMesh(skeletonData, function(parameters) {
|
||||||
|
|||||||
@ -60,7 +60,7 @@ function load () {
|
|||||||
|
|
||||||
function loadSpineboy (initialAnimation, premultipliedAlpha) {
|
function loadSpineboy (initialAnimation, premultipliedAlpha) {
|
||||||
// Load the texture atlas from the AssetManager.
|
// Load the texture atlas from the AssetManager.
|
||||||
var atlas = assetManager.get("assets/spineboy-pma.atlas");
|
var atlas = assetManager.require("assets/spineboy-pma.atlas");
|
||||||
|
|
||||||
// Create a AtlasAttachmentLoader that resolves region, mesh, boundingbox and path attachments
|
// Create a AtlasAttachmentLoader that resolves region, mesh, boundingbox and path attachments
|
||||||
var atlasLoader = new spine.AtlasAttachmentLoader(atlas);
|
var atlasLoader = new spine.AtlasAttachmentLoader(atlas);
|
||||||
@ -70,7 +70,7 @@ function loadSpineboy (initialAnimation, premultipliedAlpha) {
|
|||||||
|
|
||||||
// Set the scale to apply during parsing, parse the file, and create a new skeleton.
|
// Set the scale to apply during parsing, parse the file, and create a new skeleton.
|
||||||
skeletonBinary.scale = 1;
|
skeletonBinary.scale = 1;
|
||||||
var skeletonData = skeletonBinary.readSkeletonData(assetManager.get("assets/spineboy-pro.skel"));
|
var skeletonData = skeletonBinary.readSkeletonData(assetManager.require("assets/spineboy-pro.skel"));
|
||||||
var skeleton = new spine.Skeleton(skeletonData);
|
var skeleton = new spine.Skeleton(skeletonData);
|
||||||
var bounds = calculateSetupPoseBounds(skeleton);
|
var bounds = calculateSetupPoseBounds(skeleton);
|
||||||
|
|
||||||
|
|||||||
@ -58,7 +58,7 @@ function init () {
|
|||||||
batcher = new spine.webgl.PolygonBatcher(gl);
|
batcher = new spine.webgl.PolygonBatcher(gl);
|
||||||
mvp.ortho2d(0, 0, canvas.width - 1, canvas.height - 1);
|
mvp.ortho2d(0, 0, canvas.width - 1, canvas.height - 1);
|
||||||
skeletonRenderer = new spine.webgl.SkeletonRenderer(gl);
|
skeletonRenderer = new spine.webgl.SkeletonRenderer(gl);
|
||||||
assetManager = new spine.webgl.AssetManager(gl);
|
assetManager = new spine.webgl.AssetManager(gl, "assets/");
|
||||||
|
|
||||||
// Create a debug renderer and the ShapeRenderer it needs to render lines.
|
// Create a debug renderer and the ShapeRenderer it needs to render lines.
|
||||||
debugRenderer = new spine.webgl.SkeletonDebugRenderer(gl);
|
debugRenderer = new spine.webgl.SkeletonDebugRenderer(gl);
|
||||||
@ -72,30 +72,30 @@ function init () {
|
|||||||
|
|
||||||
// Tell AssetManager to load the resources for each skeleton, including the exported data file, the .atlas file and the .png
|
// Tell AssetManager to load the resources for each skeleton, including the exported data file, the .atlas file and the .png
|
||||||
// file for the atlas. We then wait until all resources are loaded in the load() method.
|
// file for the atlas. We then wait until all resources are loaded in the load() method.
|
||||||
assetManager.loadBinary("assets/spineboy-pro.skel");
|
assetManager.loadBinary("spineboy-pro.skel");
|
||||||
assetManager.loadText("assets/spineboy-pro.json");
|
assetManager.loadText("spineboy-pro.json");
|
||||||
assetManager.loadTextureAtlas("assets/spineboy-pma.atlas");
|
assetManager.loadTextureAtlas("spineboy-pma.atlas");
|
||||||
assetManager.loadBinary("assets/raptor-pro.skel");
|
assetManager.loadBinary("raptor-pro.skel");
|
||||||
assetManager.loadText("assets/raptor-pro.json");
|
assetManager.loadText("raptor-pro.json");
|
||||||
assetManager.loadTextureAtlas("assets/raptor-pma.atlas");
|
assetManager.loadTextureAtlas("raptor-pma.atlas");
|
||||||
assetManager.loadBinary("assets/tank-pro.skel");
|
assetManager.loadBinary("tank-pro.skel");
|
||||||
assetManager.loadText("assets/tank-pro.json");
|
assetManager.loadText("tank-pro.json");
|
||||||
assetManager.loadTextureAtlas("assets/tank-pma.atlas");
|
assetManager.loadTextureAtlas("tank-pma.atlas");
|
||||||
assetManager.loadBinary("assets/goblins-pro.skel");
|
assetManager.loadBinary("goblins-pro.skel");
|
||||||
assetManager.loadText("assets/goblins-pro.json");
|
assetManager.loadText("goblins-pro.json");
|
||||||
assetManager.loadTextureAtlas("assets/goblins-pma.atlas");
|
assetManager.loadTextureAtlas("goblins-pma.atlas");
|
||||||
assetManager.loadBinary("assets/vine-pro.skel");
|
assetManager.loadBinary("vine-pro.skel");
|
||||||
assetManager.loadText("assets/vine-pro.json");
|
assetManager.loadText("vine-pro.json");
|
||||||
assetManager.loadTextureAtlas("assets/vine-pma.atlas");
|
assetManager.loadTextureAtlas("vine-pma.atlas");
|
||||||
assetManager.loadBinary("assets/stretchyman-pro.skel");
|
assetManager.loadBinary("stretchyman-pro.skel");
|
||||||
assetManager.loadText("assets/stretchyman-pro.json");
|
assetManager.loadText("stretchyman-pro.json");
|
||||||
assetManager.loadTextureAtlas("assets/stretchyman-pma.atlas");
|
assetManager.loadTextureAtlas("stretchyman-pma.atlas");
|
||||||
assetManager.loadBinary("assets/coin-pro.skel");
|
assetManager.loadBinary("coin-pro.skel");
|
||||||
assetManager.loadText("assets/coin-pro.json");
|
assetManager.loadText("coin-pro.json");
|
||||||
assetManager.loadTextureAtlas("assets/coin-pma.atlas");
|
assetManager.loadTextureAtlas("coin-pma.atlas");
|
||||||
assetManager.loadBinary("assets/mix-and-match-pro.skel");
|
assetManager.loadBinary("mix-and-match-pro.skel");
|
||||||
assetManager.loadText("assets/mix-and-match-pro.json");
|
assetManager.loadText("mix-and-match-pro.json");
|
||||||
assetManager.loadTextureAtlas("assets/mix-and-match-pma.atlas");
|
assetManager.loadTextureAtlas("mix-and-match-pma.atlas");
|
||||||
requestAnimationFrame(load);
|
requestAnimationFrame(load);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ function loadSkeleton (name, initialAnimation, premultipliedAlpha, skin) {
|
|||||||
if (skin === undefined) skin = "default";
|
if (skin === undefined) skin = "default";
|
||||||
|
|
||||||
// Load the texture atlas using name.atlas from the AssetManager.
|
// Load the texture atlas using name.atlas from the AssetManager.
|
||||||
var atlas = assetManager.get("assets/" + name.replace(/(?:-ess|-pro)\.(skel|json)/, "") + (premultipliedAlpha ? "-pma": "") + ".atlas");
|
var atlas = assetManager.require(name.replace(/(?:-ess|-pro)\.(skel|json)/, "") + (premultipliedAlpha ? "-pma": "") + ".atlas");
|
||||||
|
|
||||||
// Create an AtlasAttachmentLoader that resolves region, mesh, boundingbox and path attachments
|
// Create an AtlasAttachmentLoader that resolves region, mesh, boundingbox and path attachments
|
||||||
var atlasLoader = new spine.AtlasAttachmentLoader(atlas);
|
var atlasLoader = new spine.AtlasAttachmentLoader(atlas);
|
||||||
@ -157,7 +157,7 @@ function loadSkeleton (name, initialAnimation, premultipliedAlpha, skin) {
|
|||||||
|
|
||||||
// Set the scale to apply during parsing, parse the file, and create a new skeleton.
|
// Set the scale to apply during parsing, parse the file, and create a new skeleton.
|
||||||
skeletonLoader.scale = 1;
|
skeletonLoader.scale = 1;
|
||||||
var skeletonData = skeletonLoader.readSkeletonData(assetManager.get("assets/" + name));
|
var skeletonData = skeletonLoader.readSkeletonData(assetManager.require(name));
|
||||||
var skeleton = new spine.Skeleton(skeletonData);
|
var skeleton = new spine.Skeleton(skeletonData);
|
||||||
skeleton.setSkinByName(skin);
|
skeleton.setSkinByName(skin);
|
||||||
var bounds = calculateSetupPoseBounds(skeleton);
|
var bounds = calculateSetupPoseBounds(skeleton);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user