mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[ts][pixi] Fix existing meshes when attachments are remove, and clippings for slot objects.
This commit is contained in:
parent
8d39c09de0
commit
29369493db
@ -143,6 +143,7 @@ export class Spine extends Container {
|
||||
|
||||
private lightColor = new Color();
|
||||
private darkColor = new Color();
|
||||
private clippingVertAux = new Float32Array(6);
|
||||
|
||||
constructor (skeletonData: SkeletonData, options?: ISpineOptions) {
|
||||
super();
|
||||
@ -225,6 +226,7 @@ export class Spine extends Container {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the existence of a mesh for the given slot.
|
||||
* If you want to manually handle which meshes go on which slot and how you cache, overwrite this method.
|
||||
*/
|
||||
protected hasMeshForSlot(slot: Slot) {
|
||||
@ -232,6 +234,7 @@ export class Spine extends Container {
|
||||
}
|
||||
|
||||
/**
|
||||
* Search the mesh corresponding to the given slot or create it, if it does not exists.
|
||||
* If you want to manually handle which meshes go on which slot and how you cache, overwrite this method.
|
||||
*/
|
||||
protected getMeshForSlot(slot: Slot): ISlotMesh {
|
||||
@ -341,9 +344,15 @@ export class Spine extends Container {
|
||||
if (!pixiMaskSource.computed) {
|
||||
pixiMaskSource.computed = true;
|
||||
const clippingAttachment = pixiMaskSource.slot.attachment as ClippingAttachment;
|
||||
const world = new Array(clippingAttachment.worldVerticesLength);
|
||||
clippingAttachment.computeWorldVertices(pixiMaskSource.slot, 0, clippingAttachment.worldVerticesLength, world, 0, 2);
|
||||
mask.clear().lineStyle(0).beginFill(0x000000).drawPolygon(world);
|
||||
const worldVerticesLength = clippingAttachment.worldVerticesLength;
|
||||
if (this.clippingVertAux.length < worldVerticesLength) this.clippingVertAux = new Float32Array(worldVerticesLength);
|
||||
clippingAttachment.computeWorldVertices(pixiMaskSource.slot, 0, worldVerticesLength, this.clippingVertAux, 0, 2);
|
||||
mask.clear().lineStyle(0).beginFill(0x000000);
|
||||
mask.moveTo(this.clippingVertAux[0], this.clippingVertAux[1]);
|
||||
for (let i = 2; i < worldVerticesLength; i+=2) {
|
||||
mask.lineTo(this.clippingVertAux[i], this.clippingVertAux[i+1]);
|
||||
}
|
||||
mask.finishPoly();
|
||||
}
|
||||
pixiObject.mask = mask;
|
||||
} else if (pixiObject.mask) {
|
||||
@ -418,7 +427,7 @@ export class Spine extends Container {
|
||||
continue;
|
||||
} else {
|
||||
if (this.hasMeshForSlot(slot)) {
|
||||
this.getMeshForSlot(slot).renderable = false;
|
||||
this.getMeshForSlot(slot).visible = false;
|
||||
}
|
||||
Spine.clipper.clipEndWithSlot(slot);
|
||||
this.pixiMaskCleanup(slot);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user