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": {
|
||||
"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",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@pixi/colord": "^2.9.6",
|
||||
"@types/css-font-loading-module": "^0.0.12",
|
||||
"@types/earcut": "^2.1.4",
|
||||
"@types/earcut": "^3.0.0",
|
||||
"@webgpu/types": "^0.1.40",
|
||||
"@xmldom/xmldom": "^0.8.10",
|
||||
"earcut": "^2.2.4",
|
||||
"earcut": "^3.0.2",
|
||||
"eventemitter3": "^5.0.1",
|
||||
"gifuct-js": "^2.1.2",
|
||||
"ismobilejs": "^1.1.1",
|
||||
"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": {
|
||||
"version": "0.1.60",
|
||||
"license": "BSD-3-Clause",
|
||||
"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": {
|
||||
"version": "5.0.1",
|
||||
"license": "MIT",
|
||||
@ -2286,7 +2306,7 @@
|
||||
"@esotericsoftware/spine-core": "4.2.88"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"pixi.js": "^8.4.0"
|
||||
"pixi.js": "^8.12.0"
|
||||
}
|
||||
},
|
||||
"spine-player": {
|
||||
|
||||
@ -62,11 +62,11 @@ const spineTextureAtlasLoader: AssetExtension<RawAtlas | TextureAtlas, ISpineAtl
|
||||
name: loaderName,
|
||||
},
|
||||
|
||||
test(url: string): boolean {
|
||||
test (url: string): boolean {
|
||||
return checkExtension(url, ".atlas");
|
||||
},
|
||||
|
||||
async load(url: string): Promise<RawAtlas> {
|
||||
async load (url: string): Promise<RawAtlas> {
|
||||
const response = await settings.ADAPTER.fetch(url);
|
||||
|
||||
const txt = await response.text();
|
||||
@ -74,7 +74,7 @@ const spineTextureAtlasLoader: AssetExtension<RawAtlas | TextureAtlas, ISpineAtl
|
||||
return txt;
|
||||
},
|
||||
|
||||
testParse(asset: unknown, options: ResolvedAsset): Promise<boolean> {
|
||||
testParse (asset: unknown, options: ResolvedAsset): Promise<boolean> {
|
||||
const isExtensionRight = checkExtension(options.src!, ".atlas");
|
||||
const isString = typeof asset === "string";
|
||||
const isExplicitLoadParserSet = options.loadParser === loaderName;
|
||||
@ -82,11 +82,11 @@ const spineTextureAtlasLoader: AssetExtension<RawAtlas | TextureAtlas, ISpineAtl
|
||||
return Promise.resolve((isExtensionRight || isExplicitLoadParserSet) && isString);
|
||||
},
|
||||
|
||||
unload(atlas: TextureAtlas) {
|
||||
unload (atlas: TextureAtlas) {
|
||||
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 || {};
|
||||
let basePath = utils.path.dirname(options.src);
|
||||
|
||||
|
||||
@ -34,6 +34,6 @@
|
||||
"@esotericsoftware/spine-core": "4.2.88"
|
||||
},
|
||||
"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.
|
||||
*****************************************************************************/
|
||||
|
||||
import { TextureAtlas } from '@esotericsoftware/spine-core';
|
||||
import {
|
||||
type AssetExtension,
|
||||
checkExtension,
|
||||
copySearchParams,
|
||||
DOMAdapter,
|
||||
extensions,
|
||||
ExtensionType,
|
||||
extensions,
|
||||
type Loader,
|
||||
LoaderParserPriority,
|
||||
path,
|
||||
type ResolvedAsset,
|
||||
Resolver,
|
||||
TextureSource
|
||||
type Texture,
|
||||
TextureSource,
|
||||
type UnresolvedAsset,
|
||||
} from 'pixi.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;
|
||||
|
||||
@ -64,6 +68,7 @@ const spineTextureAtlasLoader: AssetExtension<RawAtlas | TextureAtlas, ISpineAtl
|
||||
},
|
||||
|
||||
loader: {
|
||||
id: loaderName,
|
||||
name: loaderName,
|
||||
extension: {
|
||||
type: ExtensionType.LoadParser,
|
||||
@ -86,7 +91,7 @@ const spineTextureAtlasLoader: AssetExtension<RawAtlas | TextureAtlas, ISpineAtl
|
||||
testParse (asset: unknown, options: ResolvedAsset): Promise<boolean> {
|
||||
const isExtensionRight = checkExtension(options.src as string, '.atlas');
|
||||
const isString = typeof asset === 'string';
|
||||
const isExplicitLoadParserSet = options.loadParser === loaderName;
|
||||
const isExplicitLoadParserSet = options.parser === loaderName || options.loadParser === loaderName;
|
||||
|
||||
return Promise.resolve((isExtensionRight || isExplicitLoadParserSet) && isString);
|
||||
},
|
||||
|
||||
@ -31,10 +31,10 @@ import {
|
||||
type AssetExtension,
|
||||
checkExtension,
|
||||
DOMAdapter,
|
||||
extensions,
|
||||
ExtensionType,
|
||||
extensions,
|
||||
LoaderParserPriority,
|
||||
ResolvedAsset
|
||||
type ResolvedAsset
|
||||
} from 'pixi.js';
|
||||
|
||||
type SkeletonJsonAsset = any;
|
||||
@ -54,6 +54,7 @@ const spineLoaderExtension: AssetExtension<SkeletonJsonAsset | SkeletonBinaryAss
|
||||
extension: ExtensionType.Asset,
|
||||
|
||||
loader: {
|
||||
id: loaderName,
|
||||
name: loaderName,
|
||||
extension: {
|
||||
type: ExtensionType.LoadParser,
|
||||
@ -75,7 +76,7 @@ const spineLoaderExtension: AssetExtension<SkeletonJsonAsset | SkeletonBinaryAss
|
||||
testParse (asset: unknown, options: ResolvedAsset): Promise<boolean> {
|
||||
const isJsonSpineModel = checkExtension(options.src!, '.json') && isJson(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);
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user