mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[ts][pixi-v7] Removed deprecated methods.
This commit is contained in:
parent
d7540f626b
commit
807706fd03
@ -46,36 +46,17 @@ import {
|
|||||||
Utils,
|
Utils,
|
||||||
Vector2,
|
Vector2,
|
||||||
} from "@esotericsoftware/spine-core";
|
} from "@esotericsoftware/spine-core";
|
||||||
import type { SpineTexture } from "./SpineTexture.js";
|
|
||||||
import { SlotMesh } from "./SlotMesh.js";
|
|
||||||
import { DarkSlotMesh } from "./DarkSlotMesh.js";
|
|
||||||
import type { ISpineDebugRenderer, SpineDebugRenderer } from "./SpineDebugRenderer.js";
|
|
||||||
import { Assets } from "@pixi/assets";
|
import { Assets } from "@pixi/assets";
|
||||||
import { IPointData, Point } from "@pixi/core";
|
import { type IPointData, Point, Ticker } from "@pixi/core";
|
||||||
import { Ticker } from "@pixi/core";
|
import type { DisplayObject, IDestroyOptions } from "@pixi/display";
|
||||||
import type { IDestroyOptions, DisplayObject } from "@pixi/display";
|
|
||||||
import { Bounds, Container } from "@pixi/display";
|
import { Bounds, Container } from "@pixi/display";
|
||||||
import { Graphics } from "@pixi/graphics";
|
import { Graphics } from "@pixi/graphics";
|
||||||
|
import { DarkSlotMesh } from "./DarkSlotMesh.js";
|
||||||
|
import { SlotMesh } from "./SlotMesh.js";
|
||||||
|
import type { ISpineDebugRenderer, SpineDebugRenderer } from "./SpineDebugRenderer.js";
|
||||||
|
import type { SpineTexture } from "./SpineTexture.js";
|
||||||
import "@pixi/events";
|
import "@pixi/events";
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use SpineFromOptions and SpineOptions.
|
|
||||||
* Options to configure a {@link Spine} game object.
|
|
||||||
*/
|
|
||||||
export interface ISpineOptions {
|
|
||||||
/** Set the {@link Spine.autoUpdate} value. If omitted, it is set to `true`. */
|
|
||||||
autoUpdate?: boolean;
|
|
||||||
/** The value passed to the skeleton reader. If omitted, 1 is passed. See {@link SkeletonBinary.scale} for details. */
|
|
||||||
scale?: number;
|
|
||||||
/**
|
|
||||||
* @deprecated Use darkTint option instead.
|
|
||||||
* A factory to override the default ones to render Spine meshes ({@link DarkSlotMesh} or {@link SlotMesh}).
|
|
||||||
* If omitted, a factory returning a ({@link DarkSlotMesh} or {@link SlotMesh}) will be used depending on the presence of
|
|
||||||
* a dark tint mesh in the skeleton.
|
|
||||||
* */
|
|
||||||
slotMeshFactory?: () => ISlotMesh;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options to create a {@link Spine} using {@link Spine.from}.
|
* Options to create a {@link Spine} using {@link Spine.from}.
|
||||||
*/
|
*/
|
||||||
@ -171,7 +152,7 @@ export class SetupPoseBoundsProvider implements SpineBoundsProvider {
|
|||||||
skeleton.setupPose();
|
skeleton.setupPose();
|
||||||
skeleton.updateWorldTransform(Physics.update);
|
skeleton.updateWorldTransform(Physics.update);
|
||||||
const bounds = skeleton.getBoundsRect(this.clipping ? new SkeletonClipping() : undefined);
|
const bounds = skeleton.getBoundsRect(this.clipping ? new SkeletonClipping() : undefined);
|
||||||
return bounds.width == Number.NEGATIVE_INFINITY
|
return bounds.width === Number.NEGATIVE_INFINITY
|
||||||
? { x: 0, y: 0, width: 0, height: 0 }
|
? { x: 0, y: 0, width: 0, height: 0 }
|
||||||
: bounds;
|
: bounds;
|
||||||
}
|
}
|
||||||
@ -209,7 +190,7 @@ export class SkinsAndAnimationBoundsProvider
|
|||||||
const clipper = this.clipping ? new SkeletonClipping() : undefined;
|
const clipper = this.clipping ? new SkeletonClipping() : undefined;
|
||||||
const data = skeleton.data;
|
const data = skeleton.data;
|
||||||
if (this.skins.length > 0) {
|
if (this.skins.length > 0) {
|
||||||
let customSkin = new Skin("custom-skin");
|
const customSkin = new Skin("custom-skin");
|
||||||
for (const skinName of this.skins) {
|
for (const skinName of this.skins) {
|
||||||
const skin = data.findSkin(skinName);
|
const skin = data.findSkin(skinName);
|
||||||
if (skin == null) continue;
|
if (skin == null) continue;
|
||||||
@ -219,12 +200,12 @@ export class SkinsAndAnimationBoundsProvider
|
|||||||
}
|
}
|
||||||
skeleton.setupPose();
|
skeleton.setupPose();
|
||||||
|
|
||||||
const animation = this.animation != null ? data.findAnimation(this.animation!) : null;
|
const animation = this.animation != null ? data.findAnimation(this.animation) : null;
|
||||||
|
|
||||||
if (animation == null) {
|
if (animation == null) {
|
||||||
skeleton.updateWorldTransform(Physics.update);
|
skeleton.updateWorldTransform(Physics.update);
|
||||||
const bounds = skeleton.getBoundsRect(clipper);
|
const bounds = skeleton.getBoundsRect(clipper);
|
||||||
return bounds.width == Number.NEGATIVE_INFINITY
|
return bounds.width === Number.NEGATIVE_INFINITY
|
||||||
? { x: 0, y: 0, width: 0, height: 0 }
|
? { x: 0, y: 0, width: 0, height: 0 }
|
||||||
: bounds;
|
: bounds;
|
||||||
} else {
|
} else {
|
||||||
@ -254,7 +235,7 @@ export class SkinsAndAnimationBoundsProvider
|
|||||||
width: maxX - minX,
|
width: maxX - minX,
|
||||||
height: maxY - minY,
|
height: maxY - minY,
|
||||||
};
|
};
|
||||||
return bounds.width == Number.NEGATIVE_INFINITY
|
return bounds.width === Number.NEGATIVE_INFINITY
|
||||||
? { x: 0, y: 0, width: 0, height: 0 }
|
? { x: 0, y: 0, width: 0, height: 0 }
|
||||||
: bounds;
|
: bounds;
|
||||||
}
|
}
|
||||||
@ -344,14 +325,11 @@ export class Spine extends Container {
|
|||||||
private _boundsSpineID = -1;
|
private _boundsSpineID = -1;
|
||||||
private _boundsSpineDirty = true;
|
private _boundsSpineDirty = true;
|
||||||
|
|
||||||
constructor (options: SpineOptions | SkeletonData, oldOptions?: ISpineOptions) {
|
constructor (options: SpineOptions | SkeletonData) {
|
||||||
if (options instanceof SkeletonData) {
|
if (options instanceof SkeletonData) {
|
||||||
options = {
|
options = {
|
||||||
...oldOptions,
|
|
||||||
skeletonData: options,
|
skeletonData: options,
|
||||||
};
|
};
|
||||||
} else if (oldOptions) {
|
|
||||||
throw new Error("You cannot use options and oldOptions together.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
super();
|
super();
|
||||||
@ -361,40 +339,15 @@ export class Spine extends Container {
|
|||||||
this.skeleton = new Skeleton(skeletonData);
|
this.skeleton = new Skeleton(skeletonData);
|
||||||
const animData = new AnimationStateData(skeletonData);
|
const animData = new AnimationStateData(skeletonData);
|
||||||
this.state = new AnimationState(animData);
|
this.state = new AnimationState(animData);
|
||||||
|
|
||||||
// dark tint can be enabled by options, otherwise is enable if at least one slot has tint black
|
|
||||||
if (options?.darkTint !== undefined || oldOptions?.slotMeshFactory === undefined) {
|
|
||||||
this.darkTint = options?.darkTint === undefined
|
|
||||||
? this.skeleton.slots.some(slot => !!slot.data.setup.darkColor)
|
|
||||||
: options?.darkTint;
|
|
||||||
if (this.darkTint) this.slotMeshFactory = () => new DarkSlotMesh();
|
|
||||||
} else {
|
|
||||||
this.initializeMeshFactory(oldOptions?.slotMeshFactory);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.autoUpdate = options?.autoUpdate ?? true;
|
this.autoUpdate = options?.autoUpdate ?? true;
|
||||||
|
|
||||||
this.boundsProvider = options.boundsProvider;
|
// dark tint can be enabled by options, otherwise is enable if at least one slot has tint black
|
||||||
}
|
this.darkTint = options?.darkTint === undefined
|
||||||
|
? this.skeleton.slots.some(slot => !!slot.data.setup.darkColor)
|
||||||
|
: options?.darkTint;
|
||||||
|
if (this.darkTint) this.slotMeshFactory = () => new DarkSlotMesh();
|
||||||
|
|
||||||
/*
|
this.boundsProvider = options.boundsProvider;
|
||||||
* @deprecated Remove when slotMeshFactory options is removed
|
|
||||||
*/
|
|
||||||
private initializeMeshFactory<T extends () => ISlotMesh> (slotMeshFactory?: T) {
|
|
||||||
if (slotMeshFactory) {
|
|
||||||
this.slotMeshFactory = slotMeshFactory;
|
|
||||||
const tempSlotMeshFactory = this.slotMeshFactory();
|
|
||||||
if (tempSlotMeshFactory instanceof DarkSlotMesh) this.darkTint = true;
|
|
||||||
tempSlotMeshFactory.destroy();
|
|
||||||
} else {
|
|
||||||
for (let i = 0; i < this.skeleton.slots.length; i++) {
|
|
||||||
if (this.skeleton.slots[i].data.setup.darkColor) {
|
|
||||||
this.slotMeshFactory = () => new DarkSlotMesh();
|
|
||||||
this.darkTint = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** If {@link Spine.autoUpdate} is `false`, this method allows to update the AnimationState and the Skeleton with the given delta. */
|
/** If {@link Spine.autoUpdate} is `false`, this method allows to update the AnimationState and the Skeleton with the given delta. */
|
||||||
@ -434,7 +387,7 @@ export class Spine extends Container {
|
|||||||
this.meshesCache.clear();
|
this.meshesCache.clear();
|
||||||
this.slotsObject.clear();
|
this.slotsObject.clear();
|
||||||
|
|
||||||
for (let maskKey in this.clippingSlotToPixiMasks) {
|
for (const maskKey in this.clippingSlotToPixiMasks) {
|
||||||
const mask = this.clippingSlotToPixiMasks[maskKey];
|
const mask = this.clippingSlotToPixiMasks[maskKey];
|
||||||
mask.destroy();
|
mask.destroy();
|
||||||
delete this.clippingSlotToPixiMasks[maskKey];
|
delete this.clippingSlotToPixiMasks[maskKey];
|
||||||
@ -470,16 +423,17 @@ export class Spine extends Container {
|
|||||||
* If you want to manually handle which meshes go on which slot and how you cache, overwrite this method.
|
* If you want to manually handle which meshes go on which slot and how you cache, overwrite this method.
|
||||||
*/
|
*/
|
||||||
protected getMeshForSlot (slot: Slot): ISlotMesh {
|
protected getMeshForSlot (slot: Slot): ISlotMesh {
|
||||||
if (!this.hasMeshForSlot(slot)) {
|
let mesh = this.hasMeshForSlot(slot) ? this.meshesCache.get(slot) : null;
|
||||||
let mesh = this.slotMeshFactory();
|
|
||||||
|
if (!mesh) {
|
||||||
|
mesh = this.slotMeshFactory();
|
||||||
this.addChild(mesh);
|
this.addChild(mesh);
|
||||||
this.meshesCache.set(slot, mesh);
|
this.meshesCache.set(slot, mesh);
|
||||||
return mesh;
|
|
||||||
} else {
|
} else {
|
||||||
let mesh = this.meshesCache.get(slot)!;
|
|
||||||
mesh.visible = true;
|
mesh.visible = true;
|
||||||
return mesh;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return mesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
public slotsObject = new Map<Slot, { container: Container, followAttachmentTimeline: boolean }>();
|
public slotsObject = new Map<Slot, { container: Container, followAttachmentTimeline: boolean }>();
|
||||||
@ -508,7 +462,7 @@ export class Spine extends Container {
|
|||||||
* @param options.followAttachmentTimeline - If true, the attachment will follow the slot's attachment timeline.
|
* @param options.followAttachmentTimeline - If true, the attachment will follow the slot's attachment timeline.
|
||||||
*/
|
*/
|
||||||
addSlotObject (slotRef: number | string | Slot, pixiObject: Container, options?: { followAttachmentTimeline?: boolean }): void {
|
addSlotObject (slotRef: number | string | Slot, pixiObject: Container, options?: { followAttachmentTimeline?: boolean }): void {
|
||||||
let slot = this.getSlotFromRef(slotRef);
|
const slot = this.getSlotFromRef(slotRef);
|
||||||
const oldPixiObject = this.slotsObject.get(slot)?.container;
|
const oldPixiObject = this.slotsObject.get(slot)?.container;
|
||||||
if (oldPixiObject && oldPixiObject === pixiObject) return;
|
if (oldPixiObject && oldPixiObject === pixiObject) return;
|
||||||
|
|
||||||
@ -547,8 +501,8 @@ export class Spine extends Container {
|
|||||||
* @param pixiObject - Optional, The pixi Container to remove.
|
* @param pixiObject - Optional, The pixi Container to remove.
|
||||||
*/
|
*/
|
||||||
removeSlotObject (slotRef: number | string | Slot, pixiObject?: Container): void {
|
removeSlotObject (slotRef: number | string | Slot, pixiObject?: Container): void {
|
||||||
let slot = this.getSlotFromRef(slotRef);
|
const slot = this.getSlotFromRef(slotRef);
|
||||||
let slotObject = this.slotsObject.get(slot)?.container;
|
const slotObject = this.slotsObject.get(slot)?.container;
|
||||||
if (!slotObject) return;
|
if (!slotObject) return;
|
||||||
|
|
||||||
// if pixiObject is passed, remove only if it is equal to the given one
|
// if pixiObject is passed, remove only if it is equal to the given one
|
||||||
@ -571,7 +525,7 @@ export class Spine extends Container {
|
|||||||
private verticesCache: NumberArrayLike = Utils.newFloatArray(1024);
|
private verticesCache: NumberArrayLike = Utils.newFloatArray(1024);
|
||||||
private clippingSlotToPixiMasks: Record<string, Graphics> = {};
|
private clippingSlotToPixiMasks: Record<string, Graphics> = {};
|
||||||
private pixiMaskCleanup (slot: Slot) {
|
private pixiMaskCleanup (slot: Slot) {
|
||||||
let mask = this.clippingSlotToPixiMasks[slot.data.name];
|
const mask = this.clippingSlotToPixiMasks[slot.data.name];
|
||||||
if (mask) {
|
if (mask) {
|
||||||
delete this.clippingSlotToPixiMasks[slot.data.name];
|
delete this.clippingSlotToPixiMasks[slot.data.name];
|
||||||
mask.destroy();
|
mask.destroy();
|
||||||
@ -661,8 +615,8 @@ export class Spine extends Container {
|
|||||||
const slot = drawOrder[i];
|
const slot = drawOrder[i];
|
||||||
|
|
||||||
// render pixi object on the current slot on top of the slot attachment
|
// render pixi object on the current slot on top of the slot attachment
|
||||||
let pixiObject = this.slotsObject.get(slot);
|
const pixiObject = this.slotsObject.get(slot);
|
||||||
let zIndex = i + slotObjectsCounter;
|
const zIndex = i + slotObjectsCounter;
|
||||||
if (pixiObject) {
|
if (pixiObject) {
|
||||||
this.updateSlotObject(pixiObject, slot, zIndex + 1);
|
this.updateSlotObject(pixiObject, slot, zIndex + 1);
|
||||||
slotObjectsCounter++;
|
slotObjectsCounter++;
|
||||||
@ -771,7 +725,7 @@ export class Spine extends Container {
|
|||||||
finalIndicesLength = triangles.length;
|
finalIndicesLength = triangles.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (finalVerticesLength == 0 || finalIndicesLength == 0) {
|
if (finalVerticesLength === 0 || finalIndicesLength === 0) {
|
||||||
Spine.clipper.clipEnd(slot);
|
Spine.clipper.clipEnd(slot);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -841,17 +795,14 @@ export class Spine extends Container {
|
|||||||
* @throws {Error}: if the given bone is not found in the skeleton, an error is thrown
|
* @throws {Error}: if the given bone is not found in the skeleton, an error is thrown
|
||||||
*/
|
*/
|
||||||
public setBonePosition (bone: string | Bone, position: IPointData): void {
|
public setBonePosition (bone: string | Bone, position: IPointData): void {
|
||||||
const boneAux = bone;
|
const actualBone = typeof bone === "string" ? this.skeleton.findBone(bone) : bone;
|
||||||
if (typeof bone === "string") {
|
|
||||||
bone = this.skeleton.findBone(bone)!;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!bone) throw Error(`Cannot set bone position, bone ${String(boneAux)} not found`);
|
if (!actualBone) throw Error(`Cannot set bone position, bone ${String(bone)} not found`);
|
||||||
Spine.vectorAux.set(position.x, position.y);
|
Spine.vectorAux.set(position.x, position.y);
|
||||||
|
|
||||||
const applied = bone.applied;
|
const applied = actualBone.applied;
|
||||||
if (bone.parent) {
|
if (actualBone.parent) {
|
||||||
const aux = bone.parent.applied.worldToLocal(Spine.vectorAux);
|
const aux = actualBone.parent.applied.worldToLocal(Spine.vectorAux);
|
||||||
applied.x = aux.x;
|
applied.x = aux.x;
|
||||||
applied.y = aux.y;
|
applied.y = aux.y;
|
||||||
} else {
|
} else {
|
||||||
@ -867,13 +818,10 @@ export class Spine extends Container {
|
|||||||
* @returns {IPointData | undefined}: the position of the bone, or undefined if no matching bone is found in the skeleton
|
* @returns {IPointData | undefined}: the position of the bone, or undefined if no matching bone is found in the skeleton
|
||||||
*/
|
*/
|
||||||
public getBonePosition (bone: string | Bone, outPos?: IPointData): IPointData | undefined {
|
public getBonePosition (bone: string | Bone, outPos?: IPointData): IPointData | undefined {
|
||||||
const boneAux = bone;
|
const actualBone = typeof bone === "string" ? this.skeleton.findBone(bone) : bone;
|
||||||
if (typeof bone === "string") {
|
|
||||||
bone = this.skeleton.findBone(bone)!;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!bone) {
|
if (!actualBone) {
|
||||||
console.error(`Cannot get bone position! Bone ${String(boneAux)} not found`);
|
console.error(`Cannot get bone position! Bone ${String(bone)} not found`);
|
||||||
return outPos;
|
return outPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -881,8 +829,8 @@ export class Spine extends Container {
|
|||||||
outPos = { x: 0, y: 0 };
|
outPos = { x: 0, y: 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
outPos.x = bone.applied.worldX;
|
outPos.x = actualBone.applied.worldX;
|
||||||
outPos.y = bone.applied.worldY;
|
outPos.y = actualBone.applied.worldY;
|
||||||
return outPos;
|
return outPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -923,43 +871,16 @@ export class Spine extends Container {
|
|||||||
* @param options - Options to configure the Spine game object. See {@link SpineFromOptions}
|
* @param options - Options to configure the Spine game object. See {@link SpineFromOptions}
|
||||||
* @returns {Spine} The Spine game object instantiated
|
* @returns {Spine} The Spine game object instantiated
|
||||||
*/
|
*/
|
||||||
public static from (options: SpineFromOptions): Spine;
|
public static from ({ skeleton, atlas, scale = 1, darkTint, autoUpdate = true, boundsProvider }: SpineFromOptions) {
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated use the `from(options: SpineFromOptions)` version.
|
|
||||||
* Use this method to instantiate a Spine game object.
|
|
||||||
* Before instantiating a Spine game object, the skeleton (`.skel` or `.json`) and the atlas text files must be loaded into the Assets. For example:
|
|
||||||
* ```
|
|
||||||
* PIXI.Assets.add("sackData", "/assets/sack-pro.skel");
|
|
||||||
* PIXI.Assets.add("sackAtlas", "/assets/sack-pma.atlas");
|
|
||||||
* await PIXI.Assets.load(["sackData", "sackAtlas"]);
|
|
||||||
* ```
|
|
||||||
* Once a Spine game object is created, its skeleton data is cached into {@link Spine.skeletonCache} using the key:
|
|
||||||
* `${skeletonAssetName}-${atlasAssetName}-${options?.scale ?? 1}`
|
|
||||||
*
|
|
||||||
* @param skeletonAssetName - the asset name for the skeleton `.skel` or `.json` file previously loaded into the Assets
|
|
||||||
* @param atlasAssetName - the asset name for the atlas file previously loaded into the Assets
|
|
||||||
* @param options - Options to configure the Spine game object
|
|
||||||
* @returns {Spine} The Spine game object instantiated
|
|
||||||
*/
|
|
||||||
public static from (skeletonAssetName: string, atlasAssetName: string, options?: ISpineOptions): Spine;
|
|
||||||
public static from (
|
|
||||||
paramOne: string | SpineFromOptions,
|
|
||||||
atlasAssetName?: string,
|
|
||||||
options?: ISpineOptions)
|
|
||||||
: Spine {
|
|
||||||
if (typeof paramOne === "string") {
|
|
||||||
return Spine.oldFrom(paramOne, atlasAssetName!, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
const { skeleton, atlas, scale = 1, darkTint, autoUpdate, boundsProvider } = paramOne;
|
|
||||||
const cacheKey = `${skeleton}-${atlas}-${scale}`;
|
const cacheKey = `${skeleton}-${atlas}-${scale}`;
|
||||||
|
|
||||||
let skeletonData = Spine.skeletonCache[cacheKey];
|
let skeletonData = Spine.skeletonCache[cacheKey];
|
||||||
if (!skeletonData) {
|
if (!skeletonData) {
|
||||||
|
// biome-ignore lint/suspicious/noExplicitAny: json skeleton is any
|
||||||
const skeletonAsset = Assets.get<any | Uint8Array>(skeleton);
|
const skeletonAsset = Assets.get<any | Uint8Array>(skeleton);
|
||||||
const atlasAsset = Assets.get<TextureAtlas>(atlas);
|
const atlasAsset = Assets.get<TextureAtlas>(atlas);
|
||||||
const attachmentLoader = new AtlasAttachmentLoader(atlasAsset);
|
const attachmentLoader = new AtlasAttachmentLoader(atlasAsset);
|
||||||
let parser = skeletonAsset instanceof Uint8Array ? new SkeletonBinary(attachmentLoader) : new SkeletonJson(attachmentLoader);
|
const parser = skeletonAsset instanceof Uint8Array ? new SkeletonBinary(attachmentLoader) : new SkeletonJson(attachmentLoader);
|
||||||
parser.scale = scale;
|
parser.scale = scale;
|
||||||
skeletonData = parser.readSkeletonData(skeletonAsset);
|
skeletonData = parser.readSkeletonData(skeletonAsset);
|
||||||
Spine.skeletonCache[cacheKey] = skeletonData;
|
Spine.skeletonCache[cacheKey] = skeletonData;
|
||||||
@ -967,23 +888,6 @@ export class Spine extends Container {
|
|||||||
return new Spine({ skeletonData, darkTint, autoUpdate, boundsProvider });
|
return new Spine({ skeletonData, darkTint, autoUpdate, boundsProvider });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static oldFrom (skeletonAssetName: string, atlasAssetName: string, options?: ISpineOptions): Spine {
|
|
||||||
const cacheKey = `${skeletonAssetName}-${atlasAssetName}-${options?.scale ?? 1}`;
|
|
||||||
let skeletonData = Spine.skeletonCache[cacheKey];
|
|
||||||
if (skeletonData) {
|
|
||||||
return new Spine(skeletonData, options);
|
|
||||||
}
|
|
||||||
const skeletonAsset = Assets.get<any | Uint8Array>(skeletonAssetName);
|
|
||||||
const atlasAsset = Assets.get<TextureAtlas>(atlasAssetName);
|
|
||||||
const attachmentLoader = new AtlasAttachmentLoader(atlasAsset);
|
|
||||||
let parser = skeletonAsset instanceof Uint8Array ? new SkeletonBinary(attachmentLoader) : new SkeletonJson(attachmentLoader);
|
|
||||||
parser.scale = options?.scale ?? 1;
|
|
||||||
skeletonData = parser.readSkeletonData(skeletonAsset);
|
|
||||||
Spine.skeletonCache[cacheKey] = skeletonData;
|
|
||||||
return new this(skeletonData, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
public get tint (): number {
|
public get tint (): number {
|
||||||
return this.skeleton.color.toRgb888();
|
return this.skeleton.color.toRgb888();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user