@esotericsoftware/spine-pixi-v8
Version:
The official Spine Runtimes for PixiJS v8.
967 lines • 146 kB
JavaScript
/******************************************************************************
* Spine Runtimes License Agreement
* Last updated April 5, 2025. Replaces all prior versions.
*
* Copyright (c) 2013-2025, Esoteric Software LLC
*
* Integration of the Spine Runtimes into software or otherwise creating
* derivative works of the Spine Runtimes is permitted under the terms and
* conditions of Section 2 of the Spine Editor License Agreement:
* http://esotericsoftware.com/spine-editor-license
*
* Otherwise, it is permitted to integrate the Spine Runtimes into software
* or otherwise create derivative works of the Spine Runtimes (collectively,
* "Products"), provided that each user of the Products must obtain their own
* Spine Editor license and redistribution of the Products in any form must
* include this license and copyright notice.
*
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
import { AnimationState, AnimationStateData, AtlasAttachmentLoader, ClippingAttachment, Color, MeshAttachment, Physics, Pool, RegionAttachment, Skeleton, SkeletonBinary, SkeletonBounds, SkeletonClipping, SkeletonData, SkeletonJson, Skin, Vector2, } from '@esotericsoftware/spine-core';
import { Assets, Cache, Container, Graphics, Texture, Ticker, ViewContainer, } from 'pixi.js';
;
const vectorAux = new Vector2();
Skeleton.yDown = true;
const clipper = new SkeletonClipping();
/** A bounds provider that provides a fixed size given by the user. */
export class AABBRectangleBoundsProvider {
x;
y;
width;
height;
constructor(x, y, width, height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
calculateBounds() {
return { x: this.x, y: this.y, width: this.width, height: this.height };
}
}
/** A bounds provider that calculates the bounding box from the setup pose. */
export class SetupPoseBoundsProvider {
clipping;
/**
* @param clipping If true, clipping attachments are used to compute the bounds. False, by default.
*/
constructor(clipping = false) {
this.clipping = clipping;
}
calculateBounds(gameObject) {
if (!gameObject.skeleton)
return { x: 0, y: 0, width: 0, height: 0 };
// Make a copy of animation state and skeleton as this might be called while
// the skeleton in the GameObject has already been heavily modified. We can not
// reconstruct that state.
const skeleton = new Skeleton(gameObject.skeleton.data);
skeleton.setupPose();
skeleton.updateWorldTransform(Physics.update);
const bounds = skeleton.getBoundsRect(this.clipping ? new SkeletonClipping() : undefined);
return bounds.width === Number.NEGATIVE_INFINITY
? { x: 0, y: 0, width: 0, height: 0 }
: bounds;
}
}
/** A bounds provider that calculates the bounding box by taking the maximumg bounding box for a combination of skins and specific animation. */
export class SkinsAndAnimationBoundsProvider {
animation;
skins;
timeStep;
clipping;
/**
* @param animation The animation to use for calculating the bounds. If null, the setup pose is used.
* @param skins The skins to use for calculating the bounds. If empty, the default skin is used.
* @param timeStep The time step to use for calculating the bounds. A smaller time step means more precision, but slower calculation.
* @param clipping If true, clipping attachments are used to compute the bounds. False, by default.
*/
constructor(animation, skins = [], timeStep = 0.05, clipping = false) {
this.animation = animation;
this.skins = skins;
this.timeStep = timeStep;
this.clipping = clipping;
}
calculateBounds(gameObject) {
if (!gameObject.skeleton || !gameObject.state)
return { x: 0, y: 0, width: 0, height: 0 };
// Make a copy of animation state and skeleton as this might be called while
// the skeleton in the GameObject has already been heavily modified. We can not
// reconstruct that state.
const animationState = new AnimationState(gameObject.state.data);
const skeleton = new Skeleton(gameObject.skeleton.data);
const clipper = this.clipping ? new SkeletonClipping() : undefined;
const data = skeleton.data;
if (this.skins.length > 0) {
const customSkin = new Skin("custom-skin");
for (const skinName of this.skins) {
const skin = data.findSkin(skinName);
if (skin == null)
continue;
customSkin.addSkin(skin);
}
skeleton.setSkin(customSkin);
}
skeleton.setupPose();
const animation = this.animation != null ? data.findAnimation(this.animation) : null;
if (animation == null) {
skeleton.updateWorldTransform(Physics.update);
const bounds = skeleton.getBoundsRect(clipper);
return bounds.width === Number.NEGATIVE_INFINITY
? { x: 0, y: 0, width: 0, height: 0 }
: bounds;
}
else {
let minX = Number.POSITIVE_INFINITY, minY = Number.POSITIVE_INFINITY, maxX = Number.NEGATIVE_INFINITY, maxY = Number.NEGATIVE_INFINITY;
animationState.clearTracks();
animationState.setAnimation(0, animation, false);
const steps = Math.max(animation.duration / this.timeStep, 1.0);
for (let i = 0; i < steps; i++) {
const delta = i > 0 ? this.timeStep : 0;
animationState.update(delta);
animationState.apply(skeleton);
skeleton.update(delta);
skeleton.updateWorldTransform(Physics.update);
const bounds = skeleton.getBoundsRect(clipper);
minX = Math.min(minX, bounds.x);
minY = Math.min(minY, bounds.y);
maxX = Math.max(maxX, bounds.x + bounds.width);
maxY = Math.max(maxY, bounds.y + bounds.height);
}
const bounds = {
x: minX,
y: minY,
width: maxX - minX,
height: maxY - minY,
};
return bounds.width === Number.NEGATIVE_INFINITY
? { x: 0, y: 0, width: 0, height: 0 }
: bounds;
}
}
}
;
const maskPool = new Pool(() => new Graphics);
/**
* The class to instantiate a {@link Spine} game object in Pixi.
* Create and customize the default configuration using the static method {@link Spine.createOptions},
* then pass it to the constructor.
*/
export class Spine extends ViewContainer {
// Pixi properties
batched = true;
buildId = 0;
renderPipeId = 'spine';
_didSpineUpdate = false;
beforeUpdateWorldTransforms = () => { };
afterUpdateWorldTransforms = () => { };
// Spine properties
/** The skeleton for this Spine game object. */
skeleton;
/** The animation state for this Spine game object. */
state;
skeletonBounds;
darkTint = false;
_debug = undefined;
_slotsObject = Object.create(null);
clippingSlotToPixiMasks = Object.create(null);
getSlotFromRef(slotRef) {
let slot;
if (typeof slotRef === 'number')
slot = this.skeleton.slots[slotRef];
else if (typeof slotRef === 'string')
slot = this.skeleton.findSlot(slotRef);
else
slot = slotRef;
if (!slot)
throw new Error(`No slot found with the given slot reference: ${slotRef}`);
return slot;
}
spineAttachmentsDirty = true;
spineTexturesDirty = true;
_lastAttachments = [];
_stateChanged = true;
attachmentCacheData = [];
get debug() {
return this._debug;
}
/** Pass a {@link SpineDebugRenderer} or create your own {@link ISpineDebugRenderer} to render bones, meshes, ...
* @example spineGO.debug = new SpineDebugRenderer();
*/
set debug(value) {
if (this._debug) {
this._debug.unregisterSpine(this);
}
if (value) {
value.registerSpine(this);
}
this._debug = value;
}
_autoUpdate = false;
_ticker = Ticker.shared;
get autoUpdate() {
return this._autoUpdate;
}
/** When `true`, the Spine AnimationState and the Skeleton will be automatically updated using the {@link ticker}. */
set autoUpdate(value) {
if (value && !this._autoUpdate) {
this._ticker.add(this.internalUpdate, this);
}
else if (!value && this._autoUpdate) {
this._ticker.remove(this.internalUpdate, this);
}
this._autoUpdate = value;
}
/** The ticker to use when {@link autoUpdate} is `true`. Defaults to {@link Ticker.shared}. */
get ticker() {
return this._ticker;
}
/** Sets the ticker to use when {@link autoUpdate} is `true`. If `autoUpdate` is already `true`, the update callback will be moved from the old ticker to the new one. */
set ticker(value) {
value = value ?? Ticker.shared;
if (this._ticker === value)
return;
if (this._autoUpdate) {
this._ticker.remove(this.internalUpdate, this);
value.add(this.internalUpdate, this);
}
this._ticker = value;
}
_boundsProvider;
/** The bounds provider to use. If undefined the bounds will be dynamic, calculated when requested and based on the current frame. */
get boundsProvider() {
return this._boundsProvider;
}
set boundsProvider(value) {
this._boundsProvider = value;
if (value) {
this._boundsDirty = false;
}
this.updateBounds();
}
hasNeverUpdated = true;
_physicsPositionInheritanceFactorX = 1;
_physicsPositionInheritanceFactorY = 1;
_physicsRotationInheritanceFactor = 1;
hasLastPhysicsTransform = false;
lastPhysicsX = 0;
lastPhysicsY = 0;
lastPhysicsRotation = 0;
currentPhysicsPosition = { x: 0, y: 0 };
lastPhysicsPosition = { x: 0, y: 0 };
/** Scales how much horizontal translation of this Pixi container is inherited by skeleton physics constraints. */
get physicsPositionInheritanceFactorX() {
return this._physicsPositionInheritanceFactorX;
}
/** Scales how much vertical translation of this Pixi container is inherited by skeleton physics constraints. */
get physicsPositionInheritanceFactorY() {
return this._physicsPositionInheritanceFactorY;
}
/**
* Sets how much translation of this Pixi container is inherited by skeleton physics constraints.
* The default is (1, 1), which applies container translation normally. Use (0, 0)
* to prevent container translation from affecting physics constraints.
*/
setPhysicsPositionInheritanceFactor(x, y) {
const wasDisabled = this._physicsPositionInheritanceFactorX === 0 && this._physicsPositionInheritanceFactorY === 0;
const isEnabled = x !== 0 || y !== 0;
this._physicsPositionInheritanceFactorX = x;
this._physicsPositionInheritanceFactorY = y;
if (wasDisabled && isEnabled)
this.resetPhysicsPosition();
}
/**
* Scales how much rotation of this Pixi container is inherited by skeleton physics constraints.
* The default is `1`, which applies container rotation normally. Use `0` to prevent container
* rotation from affecting physics constraints.
*/
get physicsRotationInheritanceFactor() {
return this._physicsRotationInheritanceFactor;
}
set physicsRotationInheritanceFactor(value) {
const wasDisabled = this._physicsRotationInheritanceFactor === 0;
this._physicsRotationInheritanceFactor = value;
if (wasDisabled && value !== 0)
this.resetPhysicsRotation();
}
constructor(options) {
super({});
if (options instanceof SkeletonData)
options = { skeletonData: options };
else if ("skeleton" in options)
options = new.target.createOptions(options);
this.allowChildren = true;
const { autoUpdate, boundsProvider, darkTint, skeletonData, ticker } = options;
this.skeleton = new Skeleton(skeletonData);
this.state = new AnimationState(new AnimationStateData(skeletonData));
if (ticker)
this._ticker = ticker;
this.autoUpdate = autoUpdate ?? true;
this._boundsProvider = boundsProvider;
// dark tint can be enabled by options, otherwise is enable if at least one slot has tint black
this.darkTint = darkTint === undefined
? this.skeleton.slots.some(slot => !!slot.data.setupPose.darkColor)
: darkTint;
const slots = this.skeleton.slots;
for (let i = 0; i < slots.length; i++)
this.attachmentCacheData[i] = Object.create(null);
}
/** If {@link Spine.autoUpdate} is `false`, this method allows to update the AnimationState and the Skeleton with the given delta. */
update(dt) {
this.internalUpdate(undefined, dt);
}
internalUpdate(ticker, deltaSeconds) {
this._updateAndApplyState(deltaSeconds ?? this._ticker.deltaMS / 1000);
}
/** Resets the position used for calculating inherited physics translation. */
resetPhysicsPosition() {
const transform = this.worldTransform;
this.lastPhysicsX = transform.tx;
this.lastPhysicsY = transform.ty;
if (!this.hasLastPhysicsTransform)
this.lastPhysicsRotation = this.getPhysicsRotation();
this.hasLastPhysicsTransform = true;
}
/** Resets the rotation used for calculating inherited physics rotation. */
resetPhysicsRotation() {
const transform = this.worldTransform;
this.lastPhysicsRotation = this.getPhysicsRotation();
if (!this.hasLastPhysicsTransform) {
this.lastPhysicsX = transform.tx;
this.lastPhysicsY = transform.ty;
}
this.hasLastPhysicsTransform = true;
}
/** Resets the transform used for calculating inherited physics translation and rotation. */
resetPhysicsTransform() {
this.resetPhysicsPosition();
this.resetPhysicsRotation();
}
applyTransformMovementToPhysics() {
const { tx, ty } = this.worldTransform;
const currentRotation = this.getPhysicsRotation();
if (this.hasLastPhysicsTransform) {
this.applyPositionMovementToPhysics(tx, ty);
this.applyRotationMovementToPhysics(currentRotation);
}
this.setLastPhysicsTransform(tx, ty, currentRotation);
}
applyPositionMovementToPhysics(currentX, currentY) {
if (this._physicsPositionInheritanceFactorX === 0 && this._physicsPositionInheritanceFactorY === 0)
return;
const currentPosition = this.currentPhysicsPosition;
currentPosition.x = currentX;
currentPosition.y = currentY;
this.pixiWorldCoordinatesToSkeleton(currentPosition);
const lastPosition = this.lastPhysicsPosition;
lastPosition.x = this.lastPhysicsX;
lastPosition.y = this.lastPhysicsY;
this.pixiWorldCoordinatesToSkeleton(lastPosition);
this.skeleton.physicsTranslate((currentPosition.x - lastPosition.x) * this._physicsPositionInheritanceFactorX, (currentPosition.y - lastPosition.y) * this._physicsPositionInheritanceFactorY);
}
applyRotationMovementToPhysics(currentRotation) {
const rotationFactor = this._physicsRotationInheritanceFactor;
if (rotationFactor === 0)
return;
this.skeleton.physicsRotate(0, 0, this.getRotationDelta(currentRotation, this.lastPhysicsRotation) * rotationFactor);
}
setLastPhysicsTransform(x, y, rotation) {
this.lastPhysicsX = x;
this.lastPhysicsY = y;
this.lastPhysicsRotation = rotation;
this.hasLastPhysicsTransform = true;
}
getPhysicsRotation() {
const transform = this.worldTransform;
return Math.atan2(transform.b, transform.a) * 180 / Math.PI;
}
getRotationDelta(current, previous) {
let delta = current - previous;
delta = (delta + 180) % 360 - 180;
return delta < -180 ? delta + 360 : delta;
}
get bounds() {
if (this._boundsDirty) {
this.updateBounds();
}
return this._bounds;
}
/**
* Set the position of the bone given in input through a {@link IPointData}.
* @param bone: the bone name or the bone instance to set the position
* @param outPos: the new position of the bone.
* @throws {Error}: if the given bone is not found in the skeleton, an error is thrown
*/
setBonePosition(bone, position) {
const boneAux = bone;
if (typeof bone === 'string') {
bone = this.skeleton.findBone(bone);
}
if (!bone)
throw Error(`Cant set bone position, bone ${String(boneAux)} not found`);
vectorAux.set(position.x, position.y);
const applied = bone.appliedPose;
if (bone.parent) {
const aux = bone.parent.appliedPose.worldToLocal(vectorAux);
applied.x = aux.x;
applied.y = -aux.y;
}
else {
applied.x = vectorAux.x;
applied.y = vectorAux.y;
}
}
/**
* Return the position of the bone given in input into an {@link IPointData}.
* @param bone: the bone name or the bone instance to get the position from
* @param outPos: an optional {@link IPointData} to use to return the bone position, rathern than instantiating a new object.
* @returns {IPointData | undefined}: the position of the bone, or undefined if no matching bone is found in the skeleton
*/
getBonePosition(bone, outPos) {
const boneAux = bone;
if (typeof bone === 'string') {
bone = this.skeleton.findBone(bone);
}
if (!bone) {
console.error(`Cant set bone position! Bone ${String(boneAux)} not found`);
return outPos;
}
if (!outPos) {
outPos = { x: 0, y: 0 };
}
outPos.x = bone.appliedPose.worldX;
outPos.y = bone.appliedPose.worldY;
return outPos;
}
/**
* Advance the state and skeleton by the given time, then update slot objects too.
* The container transform is not updated.
*
* @param time the time at which to set the state
*/
_updateAndApplyState(time) {
this.hasNeverUpdated = false;
this.state.update(time);
this.skeleton.update(time);
const { skeleton } = this;
this.state.apply(skeleton);
this.applyTransformMovementToPhysics();
this.beforeUpdateWorldTransforms(this);
skeleton.updateWorldTransform(Physics.update);
this.afterUpdateWorldTransforms(this);
this.updateSlotObjects();
this._stateChanged = true;
this.onViewUpdate();
}
/**
* - validates the attachments - to flag if the attachments have changed this state
* - transforms the attachments - to update the vertices of the attachments based on the new positions
* @internal
*/
_validateAndTransformAttachments() {
if (!this._stateChanged)
return;
this._stateChanged = false;
this.validateAttachments();
this.transformAttachments();
}
validateAttachments() {
const currentDrawOrder = this.skeleton.drawOrder.appliedPose;
const lastAttachments = this._lastAttachments;
let index = 0;
let spineAttachmentsDirty = false;
for (let i = 0; i < currentDrawOrder.length; i++) {
const slot = currentDrawOrder[i];
const attachment = slot.appliedPose.attachment;
if (attachment) {
if (attachment !== lastAttachments[index]) {
spineAttachmentsDirty = true;
lastAttachments[index] = attachment;
}
index++;
}
}
if (index !== lastAttachments.length) {
spineAttachmentsDirty = true;
lastAttachments.length = index;
}
this.spineAttachmentsDirty ||= spineAttachmentsDirty;
}
currentClippingSlot;
updateAndSetPixiMask(slot, last) {
// assign/create the currentClippingSlot
const pose = slot.appliedPose;
const attachment = pose.attachment;
if (attachment && attachment instanceof ClippingAttachment) {
const clip = (this.clippingSlotToPixiMasks[slot.data.name] ||= { slot, vertices: [] });
clip.maskComputed = false;
this.currentClippingSlot = this.clippingSlotToPixiMasks[slot.data.name];
return;
}
// assign the currentClippingSlot mask to the slot object
const currentClippingSlot = this.currentClippingSlot;
const slotObject = this._slotsObject[slot.data.name];
if (currentClippingSlot && slotObject) {
const slotClipping = currentClippingSlot.slot;
const clippingAttachment = slotClipping.pose.attachment;
// create the pixi mask, only the first time and if the clipped slot is the first one clipped by this currentClippingSlot
let mask = currentClippingSlot.mask;
if (!mask) {
mask = maskPool.obtain();
currentClippingSlot.mask = mask;
this.addChild(mask);
}
// compute the pixi mask polygon, if the clipped slot is the first one clipped by this currentClippingSlot
if (!currentClippingSlot.maskComputed) {
currentClippingSlot.maskComputed = true;
const worldVerticesLength = clippingAttachment.worldVerticesLength;
const vertices = currentClippingSlot.vertices;
clippingAttachment.computeWorldVertices(this.skeleton, slotClipping, 0, worldVerticesLength, vertices, 0, 2);
mask.clear().poly(vertices).stroke({ width: 0 }).fill({ alpha: .25 });
}
slotObject.container.mask = mask;
}
else if (slotObject?.container.mask) {
// remove the mask, if slot object has a mask, but currentClippingSlot is undefined
slotObject.container.mask = null;
}
// if current slot is the ending one of the currentClippingSlot mask, set currentClippingSlot to undefined
if (currentClippingSlot && currentClippingSlot.slot.appliedPose.attachment.endSlot === slot.data) {
this.currentClippingSlot = undefined;
}
// clean up unused masks
if (last) {
for (const key in this.clippingSlotToPixiMasks) {
const clippingSlotToPixiMask = this.clippingSlotToPixiMasks[key];
if ((!(clippingSlotToPixiMask.slot.appliedPose.attachment instanceof ClippingAttachment) || !clippingSlotToPixiMask.maskComputed) && clippingSlotToPixiMask.mask) {
this.removeChild(clippingSlotToPixiMask.mask);
maskPool.free(clippingSlotToPixiMask.mask);
clippingSlotToPixiMask.mask = undefined;
}
}
this.currentClippingSlot = undefined;
}
}
transformAttachments() {
const currentDrawOrder = this.skeleton.drawOrder.appliedPose;
const skeleton = this.skeleton;
for (let i = 0; i < currentDrawOrder.length; i++) {
const slot = currentDrawOrder[i];
this.updateAndSetPixiMask(slot, i === currentDrawOrder.length - 1);
const pose = slot.appliedPose;
const attachment = pose.attachment;
if (attachment) {
if (attachment instanceof MeshAttachment || attachment instanceof RegionAttachment) {
const cacheData = this._getCachedData(slot, attachment);
const sequence = attachment.sequence;
const sequenceIndex = sequence.resolveIndex(pose);
if (attachment instanceof RegionAttachment) {
attachment.computeWorldVertices(slot, attachment.getOffsets(pose), cacheData.vertices, 0, 2);
}
else {
attachment.computeWorldVertices(skeleton, slot, 0, attachment.worldVerticesLength, cacheData.vertices, 0, 2);
}
cacheData.uvs = sequence.getUVs(sequenceIndex);
const skeletonColor = skeleton.color;
const slotColor = pose.color;
const attachmentColor = attachment.color;
const alpha = skeletonColor.a * slotColor.a * attachmentColor.a;
if (this.alpha === 0 || alpha === 0) {
if (!cacheData.skipRender)
this.spineAttachmentsDirty = true;
cacheData.skipRender = true;
}
else {
if (cacheData.skipRender)
this.spineAttachmentsDirty = true;
cacheData.skipRender = cacheData.clipped = false;
cacheData.color.set(skeletonColor.r * slotColor.r * attachmentColor.r, skeletonColor.g * slotColor.g * attachmentColor.g, skeletonColor.b * slotColor.b * attachmentColor.b, alpha);
if (pose.darkColor) {
cacheData.darkColor.setFromColor(pose.darkColor);
}
const texture = sequence.regions[sequenceIndex]?.texture?.texture || Texture.EMPTY;
if (cacheData.texture !== texture) {
cacheData.texture = texture;
this.spineTexturesDirty = true;
}
if (clipper.isClipping()) {
this.updateClippingData(cacheData);
}
}
}
else if (attachment instanceof ClippingAttachment) {
clipper.clipEnd(slot);
clipper.clipStart(skeleton, slot, attachment);
continue;
}
}
clipper.clipEnd(slot);
}
clipper.clipEnd();
}
updateClippingData(cacheData) {
cacheData.clipped = true;
clipper.clipTrianglesUnpacked(cacheData.vertices, 0, cacheData.indices, cacheData.indices.length, cacheData.uvs);
const { clippedVerticesTyped, clippedUVsTyped, clippedTrianglesTyped } = clipper;
const verticesCount = clipper.clippedVerticesLength / 2;
const indicesCount = clipper.clippedTrianglesLength;
if (!cacheData.clippedData) {
cacheData.clippedData = {
vertices: new Float32Array(verticesCount * 2),
uvs: new Float32Array(verticesCount * 2),
vertexCount: verticesCount,
indices: new Uint16Array(indicesCount),
indicesCount,
};
this.spineAttachmentsDirty = true;
}
const clippedData = cacheData.clippedData;
const sizeChange = clippedData.vertexCount !== verticesCount || indicesCount !== clippedData.indicesCount;
cacheData.skipRender = verticesCount === 0;
if (sizeChange) {
this.spineAttachmentsDirty = true;
if (clippedData.vertexCount < verticesCount) {
// buffer reuse!
clippedData.vertices = new Float32Array(verticesCount * 2);
clippedData.uvs = new Float32Array(verticesCount * 2);
}
if (clippedData.indices.length < indicesCount) {
clippedData.indices = new Uint16Array(indicesCount);
}
}
const { vertices, uvs, indices } = clippedData;
vertices.set(clippedVerticesTyped);
uvs.set(clippedUVsTyped);
for (let i = 0; i < indicesCount; i++) {
const index = clippedTrianglesTyped[i];
// Pixi's Batcher.updateElement() repacks vertex attributes (positions, UVs, colors),
// but it does not repack the index buffer. So we need to check indices differences.
if (indices[i] !== index)
this.spineAttachmentsDirty = true;
indices[i] = index;
}
clippedData.vertexCount = verticesCount;
clippedData.indicesCount = indicesCount;
}
/**
* ensure that attached containers map correctly to their slots
* along with their position, rotation, scale, and visibility.
*/
updateSlotObjects() {
for (const i in this._slotsObject) {
const slotAttachment = this._slotsObject[i];
if (!slotAttachment)
continue;
this.updateSlotObject(slotAttachment);
}
}
updateSlotObject(slotAttachment) {
const { slot, container } = slotAttachment;
const pose = slot.appliedPose;
const followAttachmentValue = slotAttachment.followAttachmentTimeline ? Boolean(pose.attachment) : true;
const slotAlpha = this.skeleton.color.a * pose.color.a;
container.visible = this.skeleton.drawOrder.appliedPose.includes(slot) && followAttachmentValue
&& this.alpha > 0 && slotAlpha > 0;
if (container.visible) {
const applied = slot.bone.appliedPose;
const matrix = container.localTransform;
matrix.a = applied.a;
matrix.b = applied.c;
matrix.c = -applied.b;
matrix.d = -applied.d;
matrix.tx = applied.worldX;
matrix.ty = applied.worldY;
container.setFromMatrix(matrix);
container.alpha = slotAlpha;
if (slotAttachment.followSlotColor) {
container.tint =
((255 * this.skeleton.color.r * pose.color.r) << 16) |
((255 * this.skeleton.color.g * pose.color.g) << 8) |
(255 * this.skeleton.color.b * pose.color.b);
}
}
}
/** @internal */
_getCachedData(slot, attachment) {
return this.attachmentCacheData[slot.data.index][attachment.name] || this.initCachedData(slot, attachment);
}
initCachedData(slot, attachment) {
let vertices;
if (attachment instanceof RegionAttachment) {
vertices = new Float32Array(8);
const sequence = attachment.sequence;
this.attachmentCacheData[slot.data.index][attachment.name] = {
id: `${slot.data.index}-${attachment.name}`,
vertices,
clipped: false,
indices: [0, 1, 2, 0, 2, 3],
uvs: new Float32Array(sequence.getUVs(0).length),
color: new Color(1, 1, 1, 1),
darkColor: new Color(0, 0, 0, 0),
darkTint: this.darkTint,
skipRender: false,
texture: sequence.regions[0]?.texture?.texture,
};
}
else {
vertices = new Float32Array(attachment.worldVerticesLength);
const sequence = attachment.sequence;
this.attachmentCacheData[slot.data.index][attachment.name] = {
id: `${slot.data.index}-${attachment.name}`,
vertices,
clipped: false,
indices: attachment.triangles,
uvs: new Float32Array(sequence.getUVs(0).length),
color: new Color(1, 1, 1, 1),
darkColor: new Color(0, 0, 0, 0),
darkTint: this.darkTint,
skipRender: false,
texture: sequence.regions[0]?.texture?.texture,
};
}
return this.attachmentCacheData[slot.data.index][attachment.name];
}
onViewUpdate() {
// increment from the 12th bit!
this._didViewChangeTick++;
if (!this._boundsProvider) {
this._boundsDirty = true;
}
if (this.didViewUpdate)
return;
this.didViewUpdate = true;
const renderGroup = this.renderGroup || this.parentRenderGroup;
if (renderGroup) {
renderGroup.onChildViewUpdate(this);
}
this.debug?.renderDebug(this);
}
/**
* Attaches a PixiJS container to a specified slot. This will map the world transform of the slots bone
* to the attached container. A container can only be attached to one slot at a time.
*
* @param container - The container to attach to the slot
* @param slotRef - The slot id or slot to attach to
* @param options - Optional settings for the attachment.
* @param options.followAttachmentTimeline - If true, the attachment will follow the slot's attachment timeline.
* @param options.followSlotColor - If true, the container tint will follow the skeleton and slot colors.
*/
addSlotObject(slot, container, options) {
slot = this.getSlotFromRef(slot);
// need to check in on the container too...
for (const i in this._slotsObject) {
if (this._slotsObject[i]?.container === container) {
this.removeSlotObject(this._slotsObject[i].slot);
}
}
this.removeSlotObject(slot);
container.includeInBuild = false;
// TODO only add once??
this.addChild(container);
const slotObject = {
container,
slot,
followAttachmentTimeline: options?.followAttachmentTimeline || false,
followSlotColor: options?.followSlotColor || false,
};
this._slotsObject[slot.data.name] = slotObject;
this.updateSlotObject(slotObject);
}
/**
* Removes a PixiJS container from the slot it is attached to.
*
* @param container - The container to detach from the slot
* @param slotOrContainer - The container, slot id or slot to detach from
*/
removeSlotObject(slotOrContainer) {
let containerToRemove;
if (slotOrContainer instanceof Container) {
for (const i in this._slotsObject) {
if (this._slotsObject[i]?.container === slotOrContainer) {
this._slotsObject[i] = null;
containerToRemove = slotOrContainer;
break;
}
}
}
else {
const slot = this.getSlotFromRef(slotOrContainer);
containerToRemove = this._slotsObject[slot.data.name]?.container;
this._slotsObject[slot.data.name] = null;
}
if (containerToRemove) {
this.removeChild(containerToRemove);
containerToRemove.includeInBuild = true;
}
}
/**
* Removes all PixiJS containers attached to any slot.
*/
removeSlotObjects() {
Object.entries(this._slotsObject).forEach(([slotName, slotObject]) => {
if (slotObject)
slotObject.container.removeFromParent();
delete this._slotsObject[slotName];
});
}
/**
* Returns a container attached to a slot, or undefined if no container is attached.
*
* @param slotRef - The slot id or slot to get the attachment from
* @returns - The container attached to the slot
*/
getSlotObject(slot) {
slot = this.getSlotFromRef(slot);
return this._slotsObject[slot.data.name]?.container;
}
updateBounds() {
this._boundsDirty = false;
this.skeletonBounds ||= new SkeletonBounds();
const skeletonBounds = this.skeletonBounds;
skeletonBounds.update(this.skeleton, true);
if (this._boundsProvider) {
const boundsSpine = this._boundsProvider.calculateBounds(this);
const bounds = this._bounds;
bounds.clear();
bounds.x = boundsSpine.x;
bounds.y = boundsSpine.y;
bounds.width = boundsSpine.width;
bounds.height = boundsSpine.height;
}
else if (skeletonBounds.minX === Infinity) {
if (this.hasNeverUpdated) {
this._updateAndApplyState(0);
this._boundsDirty = false;
}
this._validateAndTransformAttachments();
const drawOrder = this.skeleton.drawOrder.appliedPose;
const bounds = this._bounds;
bounds.clear();
for (let i = 0; i < drawOrder.length; i++) {
const slot = drawOrder[i];
const attachment = slot.appliedPose.attachment;
if (attachment && (attachment instanceof RegionAttachment || attachment instanceof MeshAttachment)) {
const cacheData = this._getCachedData(slot, attachment);
bounds.addVertexData(cacheData.vertices, 0, cacheData.vertices.length);
}
}
}
else {
this._bounds.minX = skeletonBounds.minX;
this._bounds.minY = skeletonBounds.minY;
this._bounds.maxX = skeletonBounds.maxX;
this._bounds.maxY = skeletonBounds.maxY;
}
}
/** @internal */
addBounds(bounds) {
bounds.addBounds(this.bounds);
}
/**
* Destroys this sprite renderable and optionally its texture.
* @param options - Options parameter. A boolean will act as if all options
* have been set to that value
* @param {boolean} [options.texture=false] - Should it destroy the current texture of the renderable as well
* @param {boolean} [options.textureSource=false] - Should it destroy the textureSource of the renderable as well
*/
destroy(options = false) {
super.destroy(options);
this._ticker.remove(this.internalUpdate, this);
this._ticker = null;
this.state.clearListeners();
this.debug = undefined;
this.skeleton = null;
this.state = null;
this._slotsObject = null;
this.attachmentCacheData = null;
this._lastAttachments.length = 0;
}
/** Converts a point from the skeleton coordinate system to the Pixi world coordinate system. */
skeletonToPixiWorldCoordinates(point) {
this.worldTransform.apply(point, point);
}
/** Converts a point from the Pixi world coordinate system to the skeleton coordinate system. */
pixiWorldCoordinatesToSkeleton(point) {
this.worldTransform.applyInverse(point, point);
}
/** Converts a point from the Pixi world coordinate system to the bone's local coordinate system. */
pixiWorldCoordinatesToBone(point, bone) {
this.pixiWorldCoordinatesToSkeleton(point);
if (bone.parent) {
bone.parent.appliedPose.worldToLocal(point);
}
else {
bone.appliedPose.worldToLocal(point);
}
}
/**
* Get a convenient initialization configuration for your Spine game object.
* Before instantiating a Spine game object, the skeleton (`.skel` or `.json`) and the atlas text files must be loaded into the {@link 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 Cache} using the key:
* `${skeletonAssetName}-${atlasAssetName}-${options?.scale ?? 1}`
*
* @param options - Options to configure the Spine game object. See {@link SpineFromOptions}
* @returns {SpineOptions} The configuration ready to be passed to the Spine constructor
*/
static createOptions({ skeleton, atlas, scale = 1, darkTint, autoUpdate = true, boundsProvider, allowMissingRegions = false, ticker }) {
const cacheKey = `${skeleton}-${atlas}-${scale}`;
if (Cache.has(cacheKey)) {
return {
skeletonData: Cache.get(cacheKey),
darkTint,
autoUpdate,
boundsProvider,
ticker,
};
}
const atlasAsset = Assets.get(atlas);
const attachmentLoader = new AtlasAttachmentLoader(atlasAsset, allowMissingRegions);
// biome-ignore lint/suspicious/noExplicitAny: json skeleton data is any
const skeletonAsset = Assets.get(skeleton);
const parser = skeletonAsset instanceof Uint8Array
? new SkeletonBinary(attachmentLoader)
: new SkeletonJson(attachmentLoader);
parser.scale = scale;
const skeletonData = parser.readSkeletonData(skeletonAsset);
Cache.set(cacheKey, skeletonData);
return {
skeletonData,
darkTint,
autoUpdate,
boundsProvider,
ticker,
};
}
/**
* @deprecated Use directly the Spine constructor or {@link createOptions} to make options and customize it to pass to the constructor
* 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 Cache} using the key:
* `${skeletonAssetName}-${atlasAssetName}-${options?.scale ?? 1}`
*
* @param options - Options to configure the Spine game object. See {@link SpineFromOptions}
* @returns {Spine} The Spine game object instantiated
*/
static from(options) {
return new Spine(Spine.createOptions(options));
}
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiU3BpbmUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlc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