mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
[ts][pixi-v8] Updated loaders to use new properties introduced in Pixi 8.12.
This commit is contained in:
parent
b61733da75
commit
5f381ec1ca
28
spine-ts/package-lock.json
generated
28
spine-ts/package-lock.json
generated
@ -1581,27 +1581,47 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/pixi.js": {
|
"node_modules/pixi.js": {
|
||||||
"version": "8.9.1",
|
"version": "8.12.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/pixi.js/-/pixi.js-8.12.0.tgz",
|
||||||
|
"integrity": "sha512-or7vrH7WajLevu/JnGMdD80JaSpTlXfjwCLtzhg2BL60LWPf1pF0w08Qleiqr1Saj012gevguM//+6HzzVlnfA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pixi/colord": "^2.9.6",
|
"@pixi/colord": "^2.9.6",
|
||||||
"@types/css-font-loading-module": "^0.0.12",
|
"@types/css-font-loading-module": "^0.0.12",
|
||||||
"@types/earcut": "^2.1.4",
|
"@types/earcut": "^3.0.0",
|
||||||
"@webgpu/types": "^0.1.40",
|
"@webgpu/types": "^0.1.40",
|
||||||
"@xmldom/xmldom": "^0.8.10",
|
"@xmldom/xmldom": "^0.8.10",
|
||||||
"earcut": "^2.2.4",
|
"earcut": "^3.0.2",
|
||||||
"eventemitter3": "^5.0.1",
|
"eventemitter3": "^5.0.1",
|
||||||
"gifuct-js": "^2.1.2",
|
"gifuct-js": "^2.1.2",
|
||||||
"ismobilejs": "^1.1.1",
|
"ismobilejs": "^1.1.1",
|
||||||
"parse-svg-path": "^0.1.2"
|
"parse-svg-path": "^0.1.2"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/pixijs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/pixi.js/node_modules/@types/earcut": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/earcut/-/earcut-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-k/9fOUGO39yd2sCjrbAJvGDEQvRwRnQIZlBz43roGwUZo5SHAmyVvSFyaVVZkicRVCaDXPKlbxrUcBuJoSWunQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"peer": true
|
||||||
|
},
|
||||||
"node_modules/pixi.js/node_modules/@webgpu/types": {
|
"node_modules/pixi.js/node_modules/@webgpu/types": {
|
||||||
"version": "0.1.60",
|
"version": "0.1.60",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"peer": true
|
"peer": true
|
||||||
},
|
},
|
||||||
|
"node_modules/pixi.js/node_modules/earcut": {
|
||||||
|
"version": "3.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/earcut/-/earcut-3.0.2.tgz",
|
||||||
|
"integrity": "sha512-X7hshQbLyMJ/3RPhyObLARM2sNxxmRALLKx1+NVFFnQ9gKzmCrxm9+uLIAdBcvc8FNLpctqlQ2V6AE92Ol9UDQ==",
|
||||||
|
"license": "ISC",
|
||||||
|
"peer": true
|
||||||
|
},
|
||||||
"node_modules/pixi.js/node_modules/eventemitter3": {
|
"node_modules/pixi.js/node_modules/eventemitter3": {
|
||||||
"version": "5.0.1",
|
"version": "5.0.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@ -2286,7 +2306,7 @@
|
|||||||
"@esotericsoftware/spine-core": "4.2.88"
|
"@esotericsoftware/spine-core": "4.2.88"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"pixi.js": "^8.4.0"
|
"pixi.js": "^8.12.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"spine-player": {
|
"spine-player": {
|
||||||
|
|||||||
@ -62,11 +62,11 @@ const spineTextureAtlasLoader: AssetExtension<RawAtlas | TextureAtlas, ISpineAtl
|
|||||||
name: loaderName,
|
name: loaderName,
|
||||||
},
|
},
|
||||||
|
|
||||||
test(url: string): boolean {
|
test (url: string): boolean {
|
||||||
return checkExtension(url, ".atlas");
|
return checkExtension(url, ".atlas");
|
||||||
},
|
},
|
||||||
|
|
||||||
async load(url: string): Promise<RawAtlas> {
|
async load (url: string): Promise<RawAtlas> {
|
||||||
const response = await settings.ADAPTER.fetch(url);
|
const response = await settings.ADAPTER.fetch(url);
|
||||||
|
|
||||||
const txt = await response.text();
|
const txt = await response.text();
|
||||||
@ -74,7 +74,7 @@ const spineTextureAtlasLoader: AssetExtension<RawAtlas | TextureAtlas, ISpineAtl
|
|||||||
return txt;
|
return txt;
|
||||||
},
|
},
|
||||||
|
|
||||||
testParse(asset: unknown, options: ResolvedAsset): Promise<boolean> {
|
testParse (asset: unknown, options: ResolvedAsset): Promise<boolean> {
|
||||||
const isExtensionRight = checkExtension(options.src!, ".atlas");
|
const isExtensionRight = checkExtension(options.src!, ".atlas");
|
||||||
const isString = typeof asset === "string";
|
const isString = typeof asset === "string";
|
||||||
const isExplicitLoadParserSet = options.loadParser === loaderName;
|
const isExplicitLoadParserSet = options.loadParser === loaderName;
|
||||||
@ -82,11 +82,11 @@ const spineTextureAtlasLoader: AssetExtension<RawAtlas | TextureAtlas, ISpineAtl
|
|||||||
return Promise.resolve((isExtensionRight || isExplicitLoadParserSet) && isString);
|
return Promise.resolve((isExtensionRight || isExplicitLoadParserSet) && isString);
|
||||||
},
|
},
|
||||||
|
|
||||||
unload(atlas: TextureAtlas) {
|
unload (atlas: TextureAtlas) {
|
||||||
atlas.dispose();
|
atlas.dispose();
|
||||||
},
|
},
|
||||||
|
|
||||||
async parse(asset: RawAtlas, options: {src: string, data: ISpineAtlasMetadata}, loader: Loader): Promise<TextureAtlas> {
|
async parse (asset: RawAtlas, options: { src: string, data: ISpineAtlasMetadata }, loader: Loader): Promise<TextureAtlas> {
|
||||||
const metadata: ISpineAtlasMetadata = options.data || {};
|
const metadata: ISpineAtlasMetadata = options.data || {};
|
||||||
let basePath = utils.path.dirname(options.src);
|
let basePath = utils.path.dirname(options.src);
|
||||||
|
|
||||||
|
|||||||
@ -34,6 +34,6 @@
|
|||||||
"@esotericsoftware/spine-core": "4.2.88"
|
"@esotericsoftware/spine-core": "4.2.88"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"pixi.js": "^8.4.0"
|
"pixi.js": "^8.12.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,21 +27,25 @@
|
|||||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
import { TextureAtlas } from '@esotericsoftware/spine-core';
|
||||||
import {
|
import {
|
||||||
|
type AssetExtension,
|
||||||
checkExtension,
|
checkExtension,
|
||||||
copySearchParams,
|
copySearchParams,
|
||||||
DOMAdapter,
|
DOMAdapter,
|
||||||
extensions,
|
|
||||||
ExtensionType,
|
ExtensionType,
|
||||||
|
extensions,
|
||||||
|
type Loader,
|
||||||
LoaderParserPriority,
|
LoaderParserPriority,
|
||||||
path,
|
path,
|
||||||
|
type ResolvedAsset,
|
||||||
Resolver,
|
Resolver,
|
||||||
TextureSource
|
type Texture,
|
||||||
|
TextureSource,
|
||||||
|
type UnresolvedAsset,
|
||||||
} from 'pixi.js';
|
} from 'pixi.js';
|
||||||
import { SpineTexture } from '../SpineTexture.js';
|
import { SpineTexture } from '../SpineTexture.js';
|
||||||
import { TextureAtlas } from '@esotericsoftware/spine-core';
|
|
||||||
|
|
||||||
import type { AssetExtension, Loader, ResolvedAsset, Texture, UnresolvedAsset } from 'pixi.js';
|
|
||||||
|
|
||||||
type RawAtlas = string;
|
type RawAtlas = string;
|
||||||
|
|
||||||
@ -64,6 +68,7 @@ const spineTextureAtlasLoader: AssetExtension<RawAtlas | TextureAtlas, ISpineAtl
|
|||||||
},
|
},
|
||||||
|
|
||||||
loader: {
|
loader: {
|
||||||
|
id: loaderName,
|
||||||
name: loaderName,
|
name: loaderName,
|
||||||
extension: {
|
extension: {
|
||||||
type: ExtensionType.LoadParser,
|
type: ExtensionType.LoadParser,
|
||||||
@ -86,7 +91,7 @@ const spineTextureAtlasLoader: AssetExtension<RawAtlas | TextureAtlas, ISpineAtl
|
|||||||
testParse (asset: unknown, options: ResolvedAsset): Promise<boolean> {
|
testParse (asset: unknown, options: ResolvedAsset): Promise<boolean> {
|
||||||
const isExtensionRight = checkExtension(options.src as string, '.atlas');
|
const isExtensionRight = checkExtension(options.src as string, '.atlas');
|
||||||
const isString = typeof asset === 'string';
|
const isString = typeof asset === 'string';
|
||||||
const isExplicitLoadParserSet = options.loadParser === loaderName;
|
const isExplicitLoadParserSet = options.parser === loaderName || options.loadParser === loaderName;
|
||||||
|
|
||||||
return Promise.resolve((isExtensionRight || isExplicitLoadParserSet) && isString);
|
return Promise.resolve((isExtensionRight || isExplicitLoadParserSet) && isString);
|
||||||
},
|
},
|
||||||
|
|||||||
@ -31,10 +31,10 @@ import {
|
|||||||
type AssetExtension,
|
type AssetExtension,
|
||||||
checkExtension,
|
checkExtension,
|
||||||
DOMAdapter,
|
DOMAdapter,
|
||||||
extensions,
|
|
||||||
ExtensionType,
|
ExtensionType,
|
||||||
|
extensions,
|
||||||
LoaderParserPriority,
|
LoaderParserPriority,
|
||||||
ResolvedAsset
|
type ResolvedAsset
|
||||||
} from 'pixi.js';
|
} from 'pixi.js';
|
||||||
|
|
||||||
type SkeletonJsonAsset = any;
|
type SkeletonJsonAsset = any;
|
||||||
@ -54,6 +54,7 @@ const spineLoaderExtension: AssetExtension<SkeletonJsonAsset | SkeletonBinaryAss
|
|||||||
extension: ExtensionType.Asset,
|
extension: ExtensionType.Asset,
|
||||||
|
|
||||||
loader: {
|
loader: {
|
||||||
|
id: loaderName,
|
||||||
name: loaderName,
|
name: loaderName,
|
||||||
extension: {
|
extension: {
|
||||||
type: ExtensionType.LoadParser,
|
type: ExtensionType.LoadParser,
|
||||||
@ -75,7 +76,7 @@ const spineLoaderExtension: AssetExtension<SkeletonJsonAsset | SkeletonBinaryAss
|
|||||||
testParse (asset: unknown, options: ResolvedAsset): Promise<boolean> {
|
testParse (asset: unknown, options: ResolvedAsset): Promise<boolean> {
|
||||||
const isJsonSpineModel = checkExtension(options.src!, '.json') && isJson(asset);
|
const isJsonSpineModel = checkExtension(options.src!, '.json') && isJson(asset);
|
||||||
const isBinarySpineModel = checkExtension(options.src!, '.skel') && isBuffer(asset);
|
const isBinarySpineModel = checkExtension(options.src!, '.skel') && isBuffer(asset);
|
||||||
const isExplicitLoadParserSet = options.loadParser === loaderName;
|
const isExplicitLoadParserSet = options.parser === loaderName || options.loadParser === loaderName;
|
||||||
|
|
||||||
return Promise.resolve(isJsonSpineModel || isBinarySpineModel || isExplicitLoadParserSet);
|
return Promise.resolve(isJsonSpineModel || isBinarySpineModel || isExplicitLoadParserSet);
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user