mirror of
https://github.com/photonstorm/phaser
synced 2024-11-24 21:53:59 +00:00
Rebuilt for latest Spine Runtimes
This commit is contained in:
parent
1de2bb8616
commit
2ffe15109b
11 changed files with 1818 additions and 1384 deletions
2900
plugins/spine/dist/SpinePluginDebug.js
vendored
2900
plugins/spine/dist/SpinePluginDebug.js
vendored
File diff suppressed because it is too large
Load diff
2
plugins/spine/dist/SpinePluginDebug.js.map
vendored
2
plugins/spine/dist/SpinePluginDebug.js.map
vendored
File diff suppressed because one or more lines are too long
13
plugins/spine/src/runtimes/spine-both.d.ts
vendored
13
plugins/spine/src/runtimes/spine-both.d.ts
vendored
|
@ -636,7 +636,7 @@ declare module spine {
|
||||||
private queueAsset;
|
private queueAsset;
|
||||||
loadText(clientId: string, path: string): void;
|
loadText(clientId: string, path: string): void;
|
||||||
loadJson(clientId: string, path: string): void;
|
loadJson(clientId: string, path: string): void;
|
||||||
loadTexture(clientId: string, textureLoader: (image: HTMLImageElement) => any, path: string): void;
|
loadTexture(clientId: string, textureLoader: (image: HTMLImageElement | ImageBitmap) => any, path: string): void;
|
||||||
get(clientId: string, path: string): any;
|
get(clientId: string, path: string): any;
|
||||||
private updateClientAssets;
|
private updateClientAssets;
|
||||||
isLoadingComplete(clientId: string): boolean;
|
isLoadingComplete(clientId: string): boolean;
|
||||||
|
@ -881,9 +881,9 @@ declare module spine {
|
||||||
}
|
}
|
||||||
declare module spine {
|
declare module spine {
|
||||||
abstract class Texture {
|
abstract class Texture {
|
||||||
protected _image: HTMLImageElement;
|
protected _image: HTMLImageElement | ImageBitmap;
|
||||||
constructor(image: HTMLImageElement);
|
constructor(image: HTMLImageElement | ImageBitmap);
|
||||||
getImage(): HTMLImageElement;
|
getImage(): HTMLImageElement | ImageBitmap;
|
||||||
abstract setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
|
abstract setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
|
||||||
abstract setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
|
abstract setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
|
||||||
abstract dispose(): void;
|
abstract dispose(): void;
|
||||||
|
@ -1400,7 +1400,7 @@ declare module spine.webgl {
|
||||||
private boundUnit;
|
private boundUnit;
|
||||||
private useMipMaps;
|
private useMipMaps;
|
||||||
static DISABLE_UNPACK_PREMULTIPLIED_ALPHA_WEBGL: boolean;
|
static DISABLE_UNPACK_PREMULTIPLIED_ALPHA_WEBGL: boolean;
|
||||||
constructor(context: ManagedWebGLRenderingContext | WebGLRenderingContext, image: HTMLImageElement, useMipMaps?: boolean);
|
constructor(context: ManagedWebGLRenderingContext | WebGLRenderingContext, image: HTMLImageElement | ImageBitmap, useMipMaps?: boolean);
|
||||||
setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
|
setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
|
||||||
static validateMagFilter(magFilter: TextureFilter): TextureFilter.Nearest | TextureFilter.Linear | TextureFilter.Linear;
|
static validateMagFilter(magFilter: TextureFilter): TextureFilter.Nearest | TextureFilter.Linear | TextureFilter.Linear;
|
||||||
setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
|
setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
|
||||||
|
@ -1738,7 +1738,8 @@ declare module spine.webgl {
|
||||||
canvas: HTMLCanvasElement | OffscreenCanvas;
|
canvas: HTMLCanvasElement | OffscreenCanvas;
|
||||||
gl: WebGLRenderingContext;
|
gl: WebGLRenderingContext;
|
||||||
private restorables;
|
private restorables;
|
||||||
constructor(canvasOrContext: HTMLCanvasElement | WebGLRenderingContext, contextConfig?: any);
|
constructor(canvasOrContext: HTMLCanvasElement | WebGLRenderingContext | EventTarget | WebGL2RenderingContext, contextConfig?: any);
|
||||||
|
private setupCanvas;
|
||||||
addRestorable(restorable: Restorable): void;
|
addRestorable(restorable: Restorable): void;
|
||||||
removeRestorable(restorable: Restorable): void;
|
removeRestorable(restorable: Restorable): void;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3572,15 +3572,35 @@ var spine;
|
||||||
path = this.pathPrefix + path;
|
path = this.pathPrefix + path;
|
||||||
if (!this.queueAsset(clientId, textureLoader, path))
|
if (!this.queueAsset(clientId, textureLoader, path))
|
||||||
return;
|
return;
|
||||||
var img = new Image();
|
var isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document);
|
||||||
img.crossOrigin = "anonymous";
|
var isWebWorker = !isBrowser && typeof importScripts !== 'undefined';
|
||||||
img.onload = function (ev) {
|
if (isWebWorker) {
|
||||||
_this.rawAssets[path] = img;
|
var options = { mode: "cors" };
|
||||||
};
|
fetch(path, options).then(function (response) {
|
||||||
img.onerror = function (ev) {
|
if (!response.ok) {
|
||||||
_this.errors[path] = "Couldn't load image " + path;
|
_this.errors[path] = "Couldn't load image " + path;
|
||||||
};
|
}
|
||||||
img.src = path;
|
return response.blob();
|
||||||
|
}).then(function (blob) {
|
||||||
|
return createImageBitmap(blob, {
|
||||||
|
premultiplyAlpha: 'none',
|
||||||
|
colorSpaceConversion: 'none'
|
||||||
|
});
|
||||||
|
}).then(function (bitmap) {
|
||||||
|
_this.rawAssets[path] = bitmap;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var img_1 = new Image();
|
||||||
|
img_1.crossOrigin = "anonymous";
|
||||||
|
img_1.onload = function (ev) {
|
||||||
|
_this.rawAssets[path] = img_1;
|
||||||
|
};
|
||||||
|
img_1.onerror = function (ev) {
|
||||||
|
_this.errors[path] = "Couldn't load image " + path;
|
||||||
|
};
|
||||||
|
img_1.src = path;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
SharedAssetManager.prototype.get = function (clientId, path) {
|
SharedAssetManager.prototype.get = function (clientId, path) {
|
||||||
path = this.pathPrefix + path;
|
path = this.pathPrefix + path;
|
||||||
|
@ -3590,6 +3610,8 @@ var spine;
|
||||||
return clientAssets.assets[path];
|
return clientAssets.assets[path];
|
||||||
};
|
};
|
||||||
SharedAssetManager.prototype.updateClientAssets = function (clientAssets) {
|
SharedAssetManager.prototype.updateClientAssets = function (clientAssets) {
|
||||||
|
var isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document);
|
||||||
|
var isWebWorker = !isBrowser && typeof importScripts !== 'undefined';
|
||||||
for (var i = 0; i < clientAssets.toLoad.length; i++) {
|
for (var i = 0; i < clientAssets.toLoad.length; i++) {
|
||||||
var path = clientAssets.toLoad[i];
|
var path = clientAssets.toLoad[i];
|
||||||
var asset = clientAssets.assets[path];
|
var asset = clientAssets.assets[path];
|
||||||
|
@ -3597,11 +3619,21 @@ var spine;
|
||||||
var rawAsset = this.rawAssets[path];
|
var rawAsset = this.rawAssets[path];
|
||||||
if (rawAsset === null || rawAsset === undefined)
|
if (rawAsset === null || rawAsset === undefined)
|
||||||
continue;
|
continue;
|
||||||
if (rawAsset instanceof HTMLImageElement) {
|
if (isWebWorker) {
|
||||||
clientAssets.assets[path] = clientAssets.textureLoader(rawAsset);
|
if (rawAsset instanceof ImageBitmap) {
|
||||||
|
clientAssets.assets[path] = clientAssets.textureLoader(rawAsset);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
clientAssets.assets[path] = rawAsset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
clientAssets.assets[path] = rawAsset;
|
if (rawAsset instanceof HTMLImageElement) {
|
||||||
|
clientAssets.assets[path] = clientAssets.textureLoader(rawAsset);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
clientAssets.assets[path] = rawAsset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7749,7 +7781,7 @@ var spine;
|
||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
BoundingBoxAttachment.prototype.copy = function () {
|
BoundingBoxAttachment.prototype.copy = function () {
|
||||||
var copy = new BoundingBoxAttachment(name);
|
var copy = new BoundingBoxAttachment(this.name);
|
||||||
this.copyTo(copy);
|
this.copyTo(copy);
|
||||||
copy.color.setFromColor(this.color);
|
copy.color.setFromColor(this.color);
|
||||||
return copy;
|
return copy;
|
||||||
|
@ -7768,7 +7800,7 @@ var spine;
|
||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
ClippingAttachment.prototype.copy = function () {
|
ClippingAttachment.prototype.copy = function () {
|
||||||
var copy = new ClippingAttachment(name);
|
var copy = new ClippingAttachment(this.name);
|
||||||
this.copyTo(copy);
|
this.copyTo(copy);
|
||||||
copy.endSlot = this.endSlot;
|
copy.endSlot = this.endSlot;
|
||||||
copy.color.setFromColor(this.color);
|
copy.color.setFromColor(this.color);
|
||||||
|
@ -7912,7 +7944,7 @@ var spine;
|
||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
PathAttachment.prototype.copy = function () {
|
PathAttachment.prototype.copy = function () {
|
||||||
var copy = new PathAttachment(name);
|
var copy = new PathAttachment(this.name);
|
||||||
this.copyTo(copy);
|
this.copyTo(copy);
|
||||||
copy.lengths = new Array(this.lengths.length);
|
copy.lengths = new Array(this.lengths.length);
|
||||||
spine.Utils.arrayCopy(this.lengths, 0, copy.lengths, 0, this.lengths.length);
|
spine.Utils.arrayCopy(this.lengths, 0, copy.lengths, 0, this.lengths.length);
|
||||||
|
@ -7946,7 +7978,7 @@ var spine;
|
||||||
return Math.atan2(y, x) * spine.MathUtils.radDeg;
|
return Math.atan2(y, x) * spine.MathUtils.radDeg;
|
||||||
};
|
};
|
||||||
PointAttachment.prototype.copy = function () {
|
PointAttachment.prototype.copy = function () {
|
||||||
var copy = new PointAttachment(name);
|
var copy = new PointAttachment(this.name);
|
||||||
copy.x = this.x;
|
copy.x = this.x;
|
||||||
copy.y = this.y;
|
copy.y = this.y;
|
||||||
copy.rotation = this.rotation;
|
copy.rotation = this.rotation;
|
||||||
|
@ -10706,30 +10738,32 @@ var spine;
|
||||||
(function (webgl) {
|
(function (webgl) {
|
||||||
var ManagedWebGLRenderingContext = (function () {
|
var ManagedWebGLRenderingContext = (function () {
|
||||||
function ManagedWebGLRenderingContext(canvasOrContext, contextConfig) {
|
function ManagedWebGLRenderingContext(canvasOrContext, contextConfig) {
|
||||||
var _this = this;
|
|
||||||
if (contextConfig === void 0) { contextConfig = { alpha: "true" }; }
|
if (contextConfig === void 0) { contextConfig = { alpha: "true" }; }
|
||||||
this.restorables = new Array();
|
this.restorables = new Array();
|
||||||
if (canvasOrContext instanceof HTMLCanvasElement) {
|
if (canvasOrContext instanceof HTMLCanvasElement || canvasOrContext instanceof EventTarget) {
|
||||||
var canvas_1 = canvasOrContext;
|
this.setupCanvas(canvasOrContext, contextConfig);
|
||||||
this.gl = (canvas_1.getContext("webgl2", contextConfig) || canvas_1.getContext("webgl", contextConfig));
|
|
||||||
this.canvas = canvas_1;
|
|
||||||
canvas_1.addEventListener("webglcontextlost", function (e) {
|
|
||||||
var event = e;
|
|
||||||
if (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
canvas_1.addEventListener("webglcontextrestored", function (e) {
|
|
||||||
for (var i = 0, n = _this.restorables.length; i < n; i++) {
|
|
||||||
_this.restorables[i].restore();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.gl = canvasOrContext;
|
this.gl = canvasOrContext;
|
||||||
this.canvas = this.gl.canvas;
|
this.canvas = this.gl.canvas;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ManagedWebGLRenderingContext.prototype.setupCanvas = function (canvas, contextConfig) {
|
||||||
|
var _this = this;
|
||||||
|
this.gl = (canvas.getContext("webgl2", contextConfig) || canvas.getContext("webgl", contextConfig));
|
||||||
|
this.canvas = canvas;
|
||||||
|
canvas.addEventListener("webglcontextlost", function (e) {
|
||||||
|
var event = e;
|
||||||
|
if (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
canvas.addEventListener("webglcontextrestored", function (e) {
|
||||||
|
for (var i = 0, n = _this.restorables.length; i < n; i++) {
|
||||||
|
_this.restorables[i].restore();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
ManagedWebGLRenderingContext.prototype.addRestorable = function (restorable) {
|
ManagedWebGLRenderingContext.prototype.addRestorable = function (restorable) {
|
||||||
this.restorables.push(restorable);
|
this.restorables.push(restorable);
|
||||||
};
|
};
|
||||||
|
|
File diff suppressed because one or more lines are too long
8
plugins/spine/src/runtimes/spine-canvas.d.ts
vendored
8
plugins/spine/src/runtimes/spine-canvas.d.ts
vendored
|
@ -636,7 +636,7 @@ declare module spine {
|
||||||
private queueAsset;
|
private queueAsset;
|
||||||
loadText(clientId: string, path: string): void;
|
loadText(clientId: string, path: string): void;
|
||||||
loadJson(clientId: string, path: string): void;
|
loadJson(clientId: string, path: string): void;
|
||||||
loadTexture(clientId: string, textureLoader: (image: HTMLImageElement) => any, path: string): void;
|
loadTexture(clientId: string, textureLoader: (image: HTMLImageElement | ImageBitmap) => any, path: string): void;
|
||||||
get(clientId: string, path: string): any;
|
get(clientId: string, path: string): any;
|
||||||
private updateClientAssets;
|
private updateClientAssets;
|
||||||
isLoadingComplete(clientId: string): boolean;
|
isLoadingComplete(clientId: string): boolean;
|
||||||
|
@ -881,9 +881,9 @@ declare module spine {
|
||||||
}
|
}
|
||||||
declare module spine {
|
declare module spine {
|
||||||
abstract class Texture {
|
abstract class Texture {
|
||||||
protected _image: HTMLImageElement;
|
protected _image: HTMLImageElement | ImageBitmap;
|
||||||
constructor(image: HTMLImageElement);
|
constructor(image: HTMLImageElement | ImageBitmap);
|
||||||
getImage(): HTMLImageElement;
|
getImage(): HTMLImageElement | ImageBitmap;
|
||||||
abstract setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
|
abstract setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
|
||||||
abstract setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
|
abstract setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
|
||||||
abstract dispose(): void;
|
abstract dispose(): void;
|
||||||
|
|
|
@ -3572,15 +3572,35 @@ var spine;
|
||||||
path = this.pathPrefix + path;
|
path = this.pathPrefix + path;
|
||||||
if (!this.queueAsset(clientId, textureLoader, path))
|
if (!this.queueAsset(clientId, textureLoader, path))
|
||||||
return;
|
return;
|
||||||
var img = new Image();
|
var isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document);
|
||||||
img.crossOrigin = "anonymous";
|
var isWebWorker = !isBrowser && typeof importScripts !== 'undefined';
|
||||||
img.onload = function (ev) {
|
if (isWebWorker) {
|
||||||
_this.rawAssets[path] = img;
|
var options = { mode: "cors" };
|
||||||
};
|
fetch(path, options).then(function (response) {
|
||||||
img.onerror = function (ev) {
|
if (!response.ok) {
|
||||||
_this.errors[path] = "Couldn't load image " + path;
|
_this.errors[path] = "Couldn't load image " + path;
|
||||||
};
|
}
|
||||||
img.src = path;
|
return response.blob();
|
||||||
|
}).then(function (blob) {
|
||||||
|
return createImageBitmap(blob, {
|
||||||
|
premultiplyAlpha: 'none',
|
||||||
|
colorSpaceConversion: 'none'
|
||||||
|
});
|
||||||
|
}).then(function (bitmap) {
|
||||||
|
_this.rawAssets[path] = bitmap;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var img_1 = new Image();
|
||||||
|
img_1.crossOrigin = "anonymous";
|
||||||
|
img_1.onload = function (ev) {
|
||||||
|
_this.rawAssets[path] = img_1;
|
||||||
|
};
|
||||||
|
img_1.onerror = function (ev) {
|
||||||
|
_this.errors[path] = "Couldn't load image " + path;
|
||||||
|
};
|
||||||
|
img_1.src = path;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
SharedAssetManager.prototype.get = function (clientId, path) {
|
SharedAssetManager.prototype.get = function (clientId, path) {
|
||||||
path = this.pathPrefix + path;
|
path = this.pathPrefix + path;
|
||||||
|
@ -3590,6 +3610,8 @@ var spine;
|
||||||
return clientAssets.assets[path];
|
return clientAssets.assets[path];
|
||||||
};
|
};
|
||||||
SharedAssetManager.prototype.updateClientAssets = function (clientAssets) {
|
SharedAssetManager.prototype.updateClientAssets = function (clientAssets) {
|
||||||
|
var isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document);
|
||||||
|
var isWebWorker = !isBrowser && typeof importScripts !== 'undefined';
|
||||||
for (var i = 0; i < clientAssets.toLoad.length; i++) {
|
for (var i = 0; i < clientAssets.toLoad.length; i++) {
|
||||||
var path = clientAssets.toLoad[i];
|
var path = clientAssets.toLoad[i];
|
||||||
var asset = clientAssets.assets[path];
|
var asset = clientAssets.assets[path];
|
||||||
|
@ -3597,11 +3619,21 @@ var spine;
|
||||||
var rawAsset = this.rawAssets[path];
|
var rawAsset = this.rawAssets[path];
|
||||||
if (rawAsset === null || rawAsset === undefined)
|
if (rawAsset === null || rawAsset === undefined)
|
||||||
continue;
|
continue;
|
||||||
if (rawAsset instanceof HTMLImageElement) {
|
if (isWebWorker) {
|
||||||
clientAssets.assets[path] = clientAssets.textureLoader(rawAsset);
|
if (rawAsset instanceof ImageBitmap) {
|
||||||
|
clientAssets.assets[path] = clientAssets.textureLoader(rawAsset);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
clientAssets.assets[path] = rawAsset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
clientAssets.assets[path] = rawAsset;
|
if (rawAsset instanceof HTMLImageElement) {
|
||||||
|
clientAssets.assets[path] = clientAssets.textureLoader(rawAsset);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
clientAssets.assets[path] = rawAsset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7749,7 +7781,7 @@ var spine;
|
||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
BoundingBoxAttachment.prototype.copy = function () {
|
BoundingBoxAttachment.prototype.copy = function () {
|
||||||
var copy = new BoundingBoxAttachment(name);
|
var copy = new BoundingBoxAttachment(this.name);
|
||||||
this.copyTo(copy);
|
this.copyTo(copy);
|
||||||
copy.color.setFromColor(this.color);
|
copy.color.setFromColor(this.color);
|
||||||
return copy;
|
return copy;
|
||||||
|
@ -7768,7 +7800,7 @@ var spine;
|
||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
ClippingAttachment.prototype.copy = function () {
|
ClippingAttachment.prototype.copy = function () {
|
||||||
var copy = new ClippingAttachment(name);
|
var copy = new ClippingAttachment(this.name);
|
||||||
this.copyTo(copy);
|
this.copyTo(copy);
|
||||||
copy.endSlot = this.endSlot;
|
copy.endSlot = this.endSlot;
|
||||||
copy.color.setFromColor(this.color);
|
copy.color.setFromColor(this.color);
|
||||||
|
@ -7912,7 +7944,7 @@ var spine;
|
||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
PathAttachment.prototype.copy = function () {
|
PathAttachment.prototype.copy = function () {
|
||||||
var copy = new PathAttachment(name);
|
var copy = new PathAttachment(this.name);
|
||||||
this.copyTo(copy);
|
this.copyTo(copy);
|
||||||
copy.lengths = new Array(this.lengths.length);
|
copy.lengths = new Array(this.lengths.length);
|
||||||
spine.Utils.arrayCopy(this.lengths, 0, copy.lengths, 0, this.lengths.length);
|
spine.Utils.arrayCopy(this.lengths, 0, copy.lengths, 0, this.lengths.length);
|
||||||
|
@ -7946,7 +7978,7 @@ var spine;
|
||||||
return Math.atan2(y, x) * spine.MathUtils.radDeg;
|
return Math.atan2(y, x) * spine.MathUtils.radDeg;
|
||||||
};
|
};
|
||||||
PointAttachment.prototype.copy = function () {
|
PointAttachment.prototype.copy = function () {
|
||||||
var copy = new PointAttachment(name);
|
var copy = new PointAttachment(this.name);
|
||||||
copy.x = this.x;
|
copy.x = this.x;
|
||||||
copy.y = this.y;
|
copy.y = this.y;
|
||||||
copy.rotation = this.rotation;
|
copy.rotation = this.rotation;
|
||||||
|
|
File diff suppressed because one or more lines are too long
13
plugins/spine/src/runtimes/spine-webgl.d.ts
vendored
13
plugins/spine/src/runtimes/spine-webgl.d.ts
vendored
|
@ -636,7 +636,7 @@ declare module spine {
|
||||||
private queueAsset;
|
private queueAsset;
|
||||||
loadText(clientId: string, path: string): void;
|
loadText(clientId: string, path: string): void;
|
||||||
loadJson(clientId: string, path: string): void;
|
loadJson(clientId: string, path: string): void;
|
||||||
loadTexture(clientId: string, textureLoader: (image: HTMLImageElement) => any, path: string): void;
|
loadTexture(clientId: string, textureLoader: (image: HTMLImageElement | ImageBitmap) => any, path: string): void;
|
||||||
get(clientId: string, path: string): any;
|
get(clientId: string, path: string): any;
|
||||||
private updateClientAssets;
|
private updateClientAssets;
|
||||||
isLoadingComplete(clientId: string): boolean;
|
isLoadingComplete(clientId: string): boolean;
|
||||||
|
@ -881,9 +881,9 @@ declare module spine {
|
||||||
}
|
}
|
||||||
declare module spine {
|
declare module spine {
|
||||||
abstract class Texture {
|
abstract class Texture {
|
||||||
protected _image: HTMLImageElement;
|
protected _image: HTMLImageElement | ImageBitmap;
|
||||||
constructor(image: HTMLImageElement);
|
constructor(image: HTMLImageElement | ImageBitmap);
|
||||||
getImage(): HTMLImageElement;
|
getImage(): HTMLImageElement | ImageBitmap;
|
||||||
abstract setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
|
abstract setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
|
||||||
abstract setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
|
abstract setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
|
||||||
abstract dispose(): void;
|
abstract dispose(): void;
|
||||||
|
@ -1369,7 +1369,7 @@ declare module spine.webgl {
|
||||||
private boundUnit;
|
private boundUnit;
|
||||||
private useMipMaps;
|
private useMipMaps;
|
||||||
static DISABLE_UNPACK_PREMULTIPLIED_ALPHA_WEBGL: boolean;
|
static DISABLE_UNPACK_PREMULTIPLIED_ALPHA_WEBGL: boolean;
|
||||||
constructor(context: ManagedWebGLRenderingContext | WebGLRenderingContext, image: HTMLImageElement, useMipMaps?: boolean);
|
constructor(context: ManagedWebGLRenderingContext | WebGLRenderingContext, image: HTMLImageElement | ImageBitmap, useMipMaps?: boolean);
|
||||||
setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
|
setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
|
||||||
static validateMagFilter(magFilter: TextureFilter): TextureFilter.Nearest | TextureFilter.Linear | TextureFilter.Linear;
|
static validateMagFilter(magFilter: TextureFilter): TextureFilter.Nearest | TextureFilter.Linear | TextureFilter.Linear;
|
||||||
setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
|
setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
|
||||||
|
@ -1707,7 +1707,8 @@ declare module spine.webgl {
|
||||||
canvas: HTMLCanvasElement | OffscreenCanvas;
|
canvas: HTMLCanvasElement | OffscreenCanvas;
|
||||||
gl: WebGLRenderingContext;
|
gl: WebGLRenderingContext;
|
||||||
private restorables;
|
private restorables;
|
||||||
constructor(canvasOrContext: HTMLCanvasElement | WebGLRenderingContext, contextConfig?: any);
|
constructor(canvasOrContext: HTMLCanvasElement | WebGLRenderingContext | EventTarget | WebGL2RenderingContext, contextConfig?: any);
|
||||||
|
private setupCanvas;
|
||||||
addRestorable(restorable: Restorable): void;
|
addRestorable(restorable: Restorable): void;
|
||||||
removeRestorable(restorable: Restorable): void;
|
removeRestorable(restorable: Restorable): void;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3572,15 +3572,35 @@ var spine;
|
||||||
path = this.pathPrefix + path;
|
path = this.pathPrefix + path;
|
||||||
if (!this.queueAsset(clientId, textureLoader, path))
|
if (!this.queueAsset(clientId, textureLoader, path))
|
||||||
return;
|
return;
|
||||||
var img = new Image();
|
var isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document);
|
||||||
img.crossOrigin = "anonymous";
|
var isWebWorker = !isBrowser && typeof importScripts !== 'undefined';
|
||||||
img.onload = function (ev) {
|
if (isWebWorker) {
|
||||||
_this.rawAssets[path] = img;
|
var options = { mode: "cors" };
|
||||||
};
|
fetch(path, options).then(function (response) {
|
||||||
img.onerror = function (ev) {
|
if (!response.ok) {
|
||||||
_this.errors[path] = "Couldn't load image " + path;
|
_this.errors[path] = "Couldn't load image " + path;
|
||||||
};
|
}
|
||||||
img.src = path;
|
return response.blob();
|
||||||
|
}).then(function (blob) {
|
||||||
|
return createImageBitmap(blob, {
|
||||||
|
premultiplyAlpha: 'none',
|
||||||
|
colorSpaceConversion: 'none'
|
||||||
|
});
|
||||||
|
}).then(function (bitmap) {
|
||||||
|
_this.rawAssets[path] = bitmap;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var img_1 = new Image();
|
||||||
|
img_1.crossOrigin = "anonymous";
|
||||||
|
img_1.onload = function (ev) {
|
||||||
|
_this.rawAssets[path] = img_1;
|
||||||
|
};
|
||||||
|
img_1.onerror = function (ev) {
|
||||||
|
_this.errors[path] = "Couldn't load image " + path;
|
||||||
|
};
|
||||||
|
img_1.src = path;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
SharedAssetManager.prototype.get = function (clientId, path) {
|
SharedAssetManager.prototype.get = function (clientId, path) {
|
||||||
path = this.pathPrefix + path;
|
path = this.pathPrefix + path;
|
||||||
|
@ -3590,6 +3610,8 @@ var spine;
|
||||||
return clientAssets.assets[path];
|
return clientAssets.assets[path];
|
||||||
};
|
};
|
||||||
SharedAssetManager.prototype.updateClientAssets = function (clientAssets) {
|
SharedAssetManager.prototype.updateClientAssets = function (clientAssets) {
|
||||||
|
var isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document);
|
||||||
|
var isWebWorker = !isBrowser && typeof importScripts !== 'undefined';
|
||||||
for (var i = 0; i < clientAssets.toLoad.length; i++) {
|
for (var i = 0; i < clientAssets.toLoad.length; i++) {
|
||||||
var path = clientAssets.toLoad[i];
|
var path = clientAssets.toLoad[i];
|
||||||
var asset = clientAssets.assets[path];
|
var asset = clientAssets.assets[path];
|
||||||
|
@ -3597,11 +3619,21 @@ var spine;
|
||||||
var rawAsset = this.rawAssets[path];
|
var rawAsset = this.rawAssets[path];
|
||||||
if (rawAsset === null || rawAsset === undefined)
|
if (rawAsset === null || rawAsset === undefined)
|
||||||
continue;
|
continue;
|
||||||
if (rawAsset instanceof HTMLImageElement) {
|
if (isWebWorker) {
|
||||||
clientAssets.assets[path] = clientAssets.textureLoader(rawAsset);
|
if (rawAsset instanceof ImageBitmap) {
|
||||||
|
clientAssets.assets[path] = clientAssets.textureLoader(rawAsset);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
clientAssets.assets[path] = rawAsset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
clientAssets.assets[path] = rawAsset;
|
if (rawAsset instanceof HTMLImageElement) {
|
||||||
|
clientAssets.assets[path] = clientAssets.textureLoader(rawAsset);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
clientAssets.assets[path] = rawAsset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7749,7 +7781,7 @@ var spine;
|
||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
BoundingBoxAttachment.prototype.copy = function () {
|
BoundingBoxAttachment.prototype.copy = function () {
|
||||||
var copy = new BoundingBoxAttachment(name);
|
var copy = new BoundingBoxAttachment(this.name);
|
||||||
this.copyTo(copy);
|
this.copyTo(copy);
|
||||||
copy.color.setFromColor(this.color);
|
copy.color.setFromColor(this.color);
|
||||||
return copy;
|
return copy;
|
||||||
|
@ -7768,7 +7800,7 @@ var spine;
|
||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
ClippingAttachment.prototype.copy = function () {
|
ClippingAttachment.prototype.copy = function () {
|
||||||
var copy = new ClippingAttachment(name);
|
var copy = new ClippingAttachment(this.name);
|
||||||
this.copyTo(copy);
|
this.copyTo(copy);
|
||||||
copy.endSlot = this.endSlot;
|
copy.endSlot = this.endSlot;
|
||||||
copy.color.setFromColor(this.color);
|
copy.color.setFromColor(this.color);
|
||||||
|
@ -7912,7 +7944,7 @@ var spine;
|
||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
PathAttachment.prototype.copy = function () {
|
PathAttachment.prototype.copy = function () {
|
||||||
var copy = new PathAttachment(name);
|
var copy = new PathAttachment(this.name);
|
||||||
this.copyTo(copy);
|
this.copyTo(copy);
|
||||||
copy.lengths = new Array(this.lengths.length);
|
copy.lengths = new Array(this.lengths.length);
|
||||||
spine.Utils.arrayCopy(this.lengths, 0, copy.lengths, 0, this.lengths.length);
|
spine.Utils.arrayCopy(this.lengths, 0, copy.lengths, 0, this.lengths.length);
|
||||||
|
@ -7946,7 +7978,7 @@ var spine;
|
||||||
return Math.atan2(y, x) * spine.MathUtils.radDeg;
|
return Math.atan2(y, x) * spine.MathUtils.radDeg;
|
||||||
};
|
};
|
||||||
PointAttachment.prototype.copy = function () {
|
PointAttachment.prototype.copy = function () {
|
||||||
var copy = new PointAttachment(name);
|
var copy = new PointAttachment(this.name);
|
||||||
copy.x = this.x;
|
copy.x = this.x;
|
||||||
copy.y = this.y;
|
copy.y = this.y;
|
||||||
copy.rotation = this.rotation;
|
copy.rotation = this.rotation;
|
||||||
|
@ -10438,30 +10470,32 @@ var spine;
|
||||||
(function (webgl) {
|
(function (webgl) {
|
||||||
var ManagedWebGLRenderingContext = (function () {
|
var ManagedWebGLRenderingContext = (function () {
|
||||||
function ManagedWebGLRenderingContext(canvasOrContext, contextConfig) {
|
function ManagedWebGLRenderingContext(canvasOrContext, contextConfig) {
|
||||||
var _this = this;
|
|
||||||
if (contextConfig === void 0) { contextConfig = { alpha: "true" }; }
|
if (contextConfig === void 0) { contextConfig = { alpha: "true" }; }
|
||||||
this.restorables = new Array();
|
this.restorables = new Array();
|
||||||
if (canvasOrContext instanceof HTMLCanvasElement) {
|
if (canvasOrContext instanceof HTMLCanvasElement || canvasOrContext instanceof EventTarget) {
|
||||||
var canvas = canvasOrContext;
|
this.setupCanvas(canvasOrContext, contextConfig);
|
||||||
this.gl = (canvas.getContext("webgl2", contextConfig) || canvas.getContext("webgl", contextConfig));
|
|
||||||
this.canvas = canvas;
|
|
||||||
canvas.addEventListener("webglcontextlost", function (e) {
|
|
||||||
var event = e;
|
|
||||||
if (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
canvas.addEventListener("webglcontextrestored", function (e) {
|
|
||||||
for (var i = 0, n = _this.restorables.length; i < n; i++) {
|
|
||||||
_this.restorables[i].restore();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.gl = canvasOrContext;
|
this.gl = canvasOrContext;
|
||||||
this.canvas = this.gl.canvas;
|
this.canvas = this.gl.canvas;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ManagedWebGLRenderingContext.prototype.setupCanvas = function (canvas, contextConfig) {
|
||||||
|
var _this = this;
|
||||||
|
this.gl = (canvas.getContext("webgl2", contextConfig) || canvas.getContext("webgl", contextConfig));
|
||||||
|
this.canvas = canvas;
|
||||||
|
canvas.addEventListener("webglcontextlost", function (e) {
|
||||||
|
var event = e;
|
||||||
|
if (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
canvas.addEventListener("webglcontextrestored", function (e) {
|
||||||
|
for (var i = 0, n = _this.restorables.length; i < n; i++) {
|
||||||
|
_this.restorables[i].restore();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
ManagedWebGLRenderingContext.prototype.addRestorable = function (restorable) {
|
ManagedWebGLRenderingContext.prototype.addRestorable = function (restorable) {
|
||||||
this.restorables.push(restorable);
|
this.restorables.push(restorable);
|
||||||
};
|
};
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue