mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[ts] Fixed TSdoc.
This commit is contained in:
parent
e89a7e15d2
commit
a486907520
@ -30,19 +30,26 @@
|
||||
import { type Attachment, VertexAttachment } from "./attachments/Attachment.js";
|
||||
import { type HasSequence, isHasSequence } from "./attachments/HasSequence.js";
|
||||
import { SequenceMode, SequenceModeValues } from "./attachments/Sequence.js";
|
||||
import type { Bone } from "./Bone.js";
|
||||
import type { Inherit } from "./BoneData.js";
|
||||
import type { BonePose } from "./BonePose.js";
|
||||
import type { Event } from "./Event.js";
|
||||
import type { IkConstraint } from "./IkConstraint.js";
|
||||
import type { IkConstraintPose } from "./IkConstraintPose.js";
|
||||
import type { PathConstraint } from "./PathConstraint.js";
|
||||
import type { PathConstraintPose } from "./PathConstraintPose.js";
|
||||
import type { PhysicsConstraint } from "./PhysicsConstraint.js";
|
||||
import type { PhysicsConstraintData } from "./PhysicsConstraintData.js";
|
||||
import type { PhysicsConstraintPose } from "./PhysicsConstraintPose.js";
|
||||
import type { Posed } from "./Posed.js";
|
||||
import type { Skeleton } from "./Skeleton.js";
|
||||
import type { SkeletonData } from "./SkeletonData.js";
|
||||
import type { Slider } from "./Slider.js";
|
||||
import type { SliderPose } from "./SliderPose.js";
|
||||
import type { Slot } from "./Slot.js";
|
||||
import type { SlotPose } from "./SlotPose.js";
|
||||
import type { TransformConstraint } from "./TransformConstraint.js";
|
||||
import type { TransformConstraintPose } from "./TransformConstraintPose.js";
|
||||
import { type NumberArrayLike, StringSet, Utils } from "./Utils.js";
|
||||
|
||||
/** Stores a list of timelines to animate a skeleton's pose over time.
|
||||
@ -52,7 +59,7 @@ import { type NumberArrayLike, StringSet, Utils } from "./Utils.js";
|
||||
export class Animation {
|
||||
/** The animation's name, unique across all animations in the skeleton.
|
||||
*
|
||||
* See {@link SkeletonData#findAnimation(String)}. */
|
||||
* See {@link SkeletonData.findAnimation}. */
|
||||
readonly name: string;
|
||||
|
||||
/** The duration of the animation in seconds, which is usually the highest time of all frames in the timelines. The duration is
|
||||
@ -61,9 +68,9 @@ export class Animation {
|
||||
|
||||
readonly timelineIds: StringSet;
|
||||
|
||||
/** {@link Skeleton#getBones()} indices that this animation's timelines modify.
|
||||
/** {@link Skeleton.getBones} indices that this animation's timelines modify.
|
||||
*
|
||||
* See {@link BoneTimeline#bones}. */
|
||||
* See {@link BoneTimeline.bones}. */
|
||||
readonly bones: Array<number>;
|
||||
|
||||
/** The duration of the animation in seconds, which is usually the highest time of all frames in the timeline. The duration is
|
||||
@ -98,7 +105,7 @@ export class Animation {
|
||||
|
||||
/** Returns true if this animation contains a timeline with any of the specified property IDs.
|
||||
*
|
||||
* See {@link Timeline#propertyIds()}. */
|
||||
* See {@link Timeline.propertyIds}. */
|
||||
hasTimeline (ids: string[]): boolean {
|
||||
for (let i = 0; i < ids.length; i++)
|
||||
if (this.timelineIds.contains(ids[i])) return true;
|
||||
@ -106,30 +113,30 @@ export class Animation {
|
||||
}
|
||||
|
||||
/** Applies the animation's timelines to the specified skeleton.
|
||||
* <p>
|
||||
* See {@link Timeline#apply(Skeleton, float, float, Array, float, boolean, boolean, boolean, boolean)} and
|
||||
*
|
||||
* See {@link Timeline.apply} and
|
||||
* <a href='https://esotericsoftware.com/spine-applying-animations#Timeline-API'>Applying Animations</a> in the Spine Runtimes
|
||||
* Guide.
|
||||
* @param skeleton The skeleton the animation is applied to. This provides access to the bones, slots, and other skeleton
|
||||
* components the timelines may change.
|
||||
* @param lastTime The last time in seconds this animation was applied. Some timelines trigger only at discrete times, in which
|
||||
* case all keys are triggered between <code>lastTime</code> (exclusive) and <code>time</code> (inclusive). Pass -1
|
||||
* case all keys are triggered between `lastTime` (exclusive) and `time` (inclusive). Pass -1
|
||||
* the first time an animation is applied to ensure frame 0 is triggered.
|
||||
* @param time The time in seconds the skeleton is being posed for. Timelines find the frame before and after this time and
|
||||
* interpolate between the frame values.
|
||||
* @param loop True if <code>time</code> beyond the {@link #duration} repeats the animation, else the last frame is used.
|
||||
* @param loop True if `time` beyond the {@link duration} repeats the animation, else the last frame is used.
|
||||
* @param events If any events are fired, they are added to this list. Pass null to ignore fired events or if no timelines fire
|
||||
* events.
|
||||
* @param alpha 0 applies setup or current values (depending on <code>fromSetup</code>), 1 uses timeline values, and
|
||||
* intermediate values interpolate between them. Adjusting <code>alpha</code> over time can mix an animation in or
|
||||
* @param alpha 0 applies setup or current values (depending on `fromSetup`), 1 uses timeline values, and
|
||||
* intermediate values interpolate between them. Adjusting `alpha` over time can mix an animation in or
|
||||
* out.
|
||||
* @param fromSetup If true, <code>alpha</code> transitions between setup and timeline values, setup values are used before the
|
||||
* first frame (current values are not used). If false, <code>alpha</code> transitions between current and timeline
|
||||
* @param fromSetup If true, `alpha` transitions between setup and timeline values, setup values are used before the
|
||||
* first frame (current values are not used). If false, `alpha` transitions between current and timeline
|
||||
* values, no change is made before the first frame.
|
||||
* @param add If true, for timelines that support it, their values are added to the setup or current values (depending on
|
||||
* <code>fromSetup</code>).
|
||||
* `fromSetup`).
|
||||
* @param out True when the animation is mixing out, else it is mixing in. Used by timelines that perform instant transitions.
|
||||
* @param appliedPose True to modify {@link Posed#appliedPose}, else {@link Posed#pose} is modified. */
|
||||
* @param appliedPose True to modify {@link Posed.appliedPose}, else {@link Posed.pose} is modified. */
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, loop: boolean, events: Array<Event> | null, alpha: number,
|
||||
fromSetup: boolean, add: boolean, out: boolean, appliedPose: boolean) {
|
||||
if (!skeleton) throw new Error("skeleton cannot be null.");
|
||||
@ -181,7 +188,7 @@ export enum Property {
|
||||
}
|
||||
|
||||
/** The base class for all timelines.
|
||||
* <p>
|
||||
*
|
||||
* See <a href='https://esotericsoftware.com/spine-applying-animations#Timeline-API'>Applying Animations</a> in the Spine
|
||||
* Runtimes Guide. */
|
||||
export abstract class Timeline {
|
||||
@ -219,35 +226,35 @@ export abstract class Timeline {
|
||||
}
|
||||
|
||||
/** Applies this timeline to the skeleton.
|
||||
* <p>
|
||||
*
|
||||
* See <a href='https://esotericsoftware.com/spine-applying-animations#Timeline-API'>Applying Animations</a> in the Spine
|
||||
* Runtimes Guide.
|
||||
* @param skeleton The skeleton the timeline is applied to. This provides access to the bones, slots, and other skeleton
|
||||
* components the timelines may change.
|
||||
* @param lastTime The last time in seconds this timeline was applied. Some timelines trigger only at discrete times, in
|
||||
* which case all keys are triggered between <code>lastTime</code> (exclusive) and <code>time</code> (inclusive).
|
||||
* which case all keys are triggered between `lastTime` (exclusive) and `time` (inclusive).
|
||||
* Pass -1 the first time a timeline is applied to ensure frame 0 is triggered.
|
||||
* @param time The time in seconds the skeleton is being posed for. Timelines find the frame before and after this time and
|
||||
* interpolate between the frame values.
|
||||
* @param events If any events are fired, they are added to this list. Pass null to ignore fired events or if no timelines
|
||||
* fire events.
|
||||
* @param alpha 0 applies setup or current values (depending on <code>fromSetup</code>), 1 uses timeline values, and
|
||||
* intermediate values interpolate between them. Adjusting <code>alpha</code> over time can mix a timeline in or
|
||||
* @param alpha 0 applies setup or current values (depending on `fromSetup`), 1 uses timeline values, and
|
||||
* intermediate values interpolate between them. Adjusting `alpha` over time can mix a timeline in or
|
||||
* out.
|
||||
* @param fromSetup If true, <code>alpha</code> transitions between setup and timeline values, setup values are used before
|
||||
* the first frame (current values are not used). If false, <code>alpha</code> transitions between current and
|
||||
* @param fromSetup If true, `alpha` transitions between setup and timeline values, setup values are used before
|
||||
* the first frame (current values are not used). If false, `alpha` transitions between current and
|
||||
* timeline values, no change is made before the first frame.
|
||||
* @param add If true, for timelines that support it, their values are added to the setup or current values (depending on
|
||||
* <code>fromSetup</code>).
|
||||
* `fromSetup`).
|
||||
* @param out True when the animation is mixing out, else it is mixing in. Used by timelines that perform instant
|
||||
* transitions.
|
||||
* @param appliedPose True to modify {@link Posed#appliedPose}, else {@link Posed#pose} is modified. */
|
||||
* @param appliedPose True to modify {@link Posed.appliedPose}, else {@link Posed.pose} is modified. */
|
||||
abstract apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event> | null, alpha: number,
|
||||
fromSetup: boolean, add: boolean, out: boolean, appliedPose: boolean): void;
|
||||
|
||||
/** Linear search using the specified stride (default 1).
|
||||
* @param time Must be >= the first value in <code>frames</code>.
|
||||
* @return The index of the first value <= <code>time</code>. */
|
||||
* @param time Must be >= the first value in `frames`.
|
||||
* @return The index of the first value <= `time`. */
|
||||
static search (frames: NumberArrayLike, time: number, step = 1) {
|
||||
const n = frames.length;
|
||||
for (let i = step; i < n; i += step)
|
||||
@ -286,7 +293,7 @@ export abstract class CurveTimeline extends Timeline {
|
||||
this.curves[frame] = 1/*STEPPED*/;
|
||||
}
|
||||
|
||||
/** Shrinks the storage for Bezier curves, for use when <code>bezierCount</code> (specified in the constructor) was larger
|
||||
/** Shrinks the storage for Bezier curves, for use when `bezierCount` (specified in the constructor) was larger
|
||||
* than the actual number of Bezier curves. */
|
||||
shrink (bezierCount: number) {
|
||||
const size = this.getFrameCount() + bezierCount * 18/*BEZIER_SIZE*/;
|
||||
@ -299,9 +306,9 @@ export abstract class CurveTimeline extends Timeline {
|
||||
|
||||
/** Stores the segments for the specified Bezier curve. For timelines that modify multiple values, there may be more than
|
||||
* one curve per frame.
|
||||
* @param bezier The ordinal of this Bezier curve for this timeline, between 0 and <code>bezierCount - 1</code> (specified
|
||||
* @param bezier The ordinal of this Bezier curve for this timeline, between 0 and `bezierCount - 1` (specified
|
||||
* in the constructor), inclusive.
|
||||
* @param frame Between 0 and <code>frameCount - 1</code>, inclusive.
|
||||
* @param frame Between 0 and `frameCount - 1`, inclusive.
|
||||
* @param value The index of the value for this frame that this curve is used for.
|
||||
* @param time1 The time for the first key.
|
||||
* @param value1 The value for the first key.
|
||||
@ -334,9 +341,9 @@ export abstract class CurveTimeline extends Timeline {
|
||||
}
|
||||
|
||||
/** Returns the Bezier interpolated value for the specified time.
|
||||
* @param frameIndex The index into {@link #frames} for the values of the frame before <code>time</code>.
|
||||
* @param valueOffset The offset from <code>frameIndex</code> to the value this curve is used for.
|
||||
* @param i The index of the Bezier segments. See {@link #getCurveType(int)}. */
|
||||
* @param frameIndex The index into {@link frames} for the values of the frame before `time`.
|
||||
* @param valueOffset The offset from `frameIndex` to the value this curve is used for.
|
||||
* @param i The index of the Bezier segments. See {@link getCurveType}. */
|
||||
getBezierValue (time: number, frameIndex: number, valueOffset: number, i: number) {
|
||||
const curves = this.curves;
|
||||
if (curves[i] > time) {
|
||||
@ -367,7 +374,7 @@ export abstract class CurveTimeline1 extends CurveTimeline {
|
||||
}
|
||||
|
||||
/** Sets the time and value for the specified frame.
|
||||
* @param frame Between 0 and <code>frameCount</code>, inclusive.
|
||||
* @param frame Between 0 and `frameCount`, inclusive.
|
||||
* @param time The frame time in seconds. */
|
||||
setFrame (frame: number, time: number, value: number) {
|
||||
frame <<= 1;
|
||||
@ -400,8 +407,8 @@ export abstract class CurveTimeline1 extends CurveTimeline {
|
||||
|
||||
/** Returns the interpolated value for properties relative to the setup value. The timeline value is added to the setup
|
||||
* value, rather than replacing it.
|
||||
* <p>
|
||||
* See {@link Timeline#apply(Skeleton, float, float, Array, float, boolean, boolean, boolean, boolean)}.
|
||||
*
|
||||
* See {@link Timeline.apply}.
|
||||
* @param current The current value for the property.
|
||||
* @param setup The setup value for the property. */
|
||||
getRelativeValue (time: number, alpha: number, fromSetup: boolean, add: boolean, current: number, setup: number) {
|
||||
@ -412,16 +419,16 @@ export abstract class CurveTimeline1 extends CurveTimeline {
|
||||
|
||||
/** Returns the interpolated value for properties set as absolute values. The timeline value replaces the setup value,
|
||||
* rather than being relative to it.
|
||||
* <p>
|
||||
* See {@link Timeline#apply(Skeleton, float, float, Array, float, boolean, boolean, boolean, boolean)}.
|
||||
*
|
||||
* See {@link Timeline.apply}.
|
||||
* @param current The current value for the property.
|
||||
* @param setup The setup value for the property. */
|
||||
getAbsoluteValue (time: number, alpha: number, fromSetup: boolean, add: boolean, current: number, setup: number): number;
|
||||
|
||||
/** Returns the interpolated value for properties set as absolute values, using the specified timeline value rather than
|
||||
* calling {@link #getCurveValue(float)}.
|
||||
* <p>
|
||||
* See {@link Timeline#apply(Skeleton, float, float, Array, float, boolean, boolean, boolean, boolean)}.
|
||||
* calling {@link getCurveValue}.
|
||||
*
|
||||
* See {@link Timeline.apply}.
|
||||
* @param current The current value for the property.
|
||||
* @param setup The setup value for the property.
|
||||
* @param value The timeline value to apply. */
|
||||
@ -447,7 +454,7 @@ export abstract class CurveTimeline1 extends CurveTimeline {
|
||||
|
||||
/** Returns the interpolated value for scale properties. The timeline and setup values are multiplied and sign adjusted.
|
||||
*
|
||||
* See {@link Timeline#apply(Skeleton, float, float, Array, float, boolean, boolean, boolean, boolean)}.
|
||||
* See {@link Timeline.apply}.
|
||||
* @param current The current value for the property.
|
||||
* @param setup The setup value for the property. */
|
||||
getScaleValue (time: number, alpha: number, fromSetup: boolean, add: boolean, out: boolean, current: number, setup: number) {
|
||||
@ -497,7 +504,7 @@ export abstract class BoneTimeline1 extends CurveTimeline1 implements BoneTimeli
|
||||
export abstract class BoneTimeline2 extends CurveTimeline implements BoneTimeline {
|
||||
readonly boneIndex;
|
||||
|
||||
/** @param bezierCount The maximum number of Bezier curves. See {@link #shrink(int)}.
|
||||
/** @param bezierCount The maximum number of Bezier curves. See {@link shrink}.
|
||||
* @param propertyIds Unique identifiers for the properties the timeline modifies. */
|
||||
constructor (frameCount: number, bezierCount: number, boneIndex: number, property1: Property, property2: Property) {
|
||||
super(frameCount, bezierCount, `${property1}|${boneIndex}`, `${property2}|${boneIndex}`);
|
||||
@ -510,7 +517,7 @@ export abstract class BoneTimeline2 extends CurveTimeline implements BoneTimelin
|
||||
}
|
||||
|
||||
/** Sets the time and values for the specified frame.
|
||||
* @param frame Between 0 and <code>frameCount</code>, inclusive.
|
||||
* @param frame Between 0 and `frameCount`, inclusive.
|
||||
* @param time The frame time in seconds. */
|
||||
setFrame (frame: number, time: number, value1: number, value2: number) {
|
||||
frame *= 3/*ENTRIES*/;
|
||||
@ -530,7 +537,7 @@ export abstract class BoneTimeline2 extends CurveTimeline implements BoneTimelin
|
||||
out: boolean,): void;
|
||||
}
|
||||
|
||||
/** Changes {@link BonePose#rotation}. */
|
||||
/** Changes {@link BonePose.rotation}. */
|
||||
export class RotateTimeline extends BoneTimeline1 {
|
||||
constructor (frameCount: number, bezierCount: number, boneIndex: number) {
|
||||
super(frameCount, bezierCount, boneIndex, Property.rotate);
|
||||
@ -711,7 +718,7 @@ export class ScaleYTimeline extends BoneTimeline1 {
|
||||
}
|
||||
}
|
||||
|
||||
/** Changes {@link Bone#shearX} and {@link Bone#shearY}. */
|
||||
/** Changes {@link Bone.shearX} and {@link Bone.shearY}. */
|
||||
export class ShearTimeline extends BoneTimeline2 {
|
||||
constructor (frameCount: number, bezierCount: number, boneIndex: number) {
|
||||
super(frameCount, bezierCount, boneIndex, Property.shearX, Property.shearY);
|
||||
@ -762,7 +769,7 @@ export class ShearTimeline extends BoneTimeline2 {
|
||||
}
|
||||
}
|
||||
|
||||
/** Changes {@link Bone#shearX} and {@link Bone#shearY}. */
|
||||
/** Changes {@link Bone.shearX} and {@link Bone.shearY}. */
|
||||
export class ShearXTimeline extends BoneTimeline1 {
|
||||
constructor (frameCount: number, bezierCount: number, boneIndex: number) {
|
||||
super(frameCount, bezierCount, boneIndex, Property.shearX);
|
||||
@ -774,7 +781,7 @@ export class ShearXTimeline extends BoneTimeline1 {
|
||||
}
|
||||
}
|
||||
|
||||
/** Changes {@link Bone#shearX} and {@link Bone#shearY}. */
|
||||
/** Changes {@link Bone.shearX} and {@link Bone.shearY}. */
|
||||
export class ShearYTimeline extends BoneTimeline1 {
|
||||
constructor (frameCount: number, bezierCount: number, boneIndex: number) {
|
||||
super(frameCount, bezierCount, boneIndex, Property.shearY);
|
||||
@ -801,7 +808,7 @@ export class InheritTimeline extends Timeline implements BoneTimeline {
|
||||
}
|
||||
|
||||
/** Sets the inherit transform mode for the specified frame.
|
||||
* @param frame Between 0 and <code>frameCount</code>, inclusive.
|
||||
* @param frame Between 0 and `frameCount`, inclusive.
|
||||
* @param time The frame time in seconds. */
|
||||
public setFrame (frame: number, time: number, inherit: Inherit) {
|
||||
frame *= 2/*ENTRIES*/;
|
||||
@ -1295,7 +1302,7 @@ export class AttachmentTimeline extends Timeline implements SlotTimeline {
|
||||
export class DeformTimeline extends SlotCurveTimeline {
|
||||
/** The attachment that will be deformed.
|
||||
*
|
||||
* See {@link VertexAttachment.getTimelineAttachment()}. */
|
||||
* See {@link VertexAttachment.getTimelineAttachment}. */
|
||||
readonly attachment: VertexAttachment;
|
||||
|
||||
/** The vertices for each key frame. */
|
||||
@ -1313,7 +1320,7 @@ export class DeformTimeline extends SlotCurveTimeline {
|
||||
}
|
||||
|
||||
/** Sets the time and vertices for the specified frame.
|
||||
* @param frame Between 0 and <code>frameCount</code>, inclusive.
|
||||
* @param frame Between 0 and `frameCount`, inclusive.
|
||||
* @param time The frame time in seconds.
|
||||
* @param vertices Vertex positions for an unweighted VertexAttachment, or deform offsets if it has weights. */
|
||||
setFrame (frame: number, time: number, vertices: NumberArrayLike) {
|
||||
@ -1493,7 +1500,7 @@ export class DeformTimeline extends SlotCurveTimeline {
|
||||
}
|
||||
}
|
||||
|
||||
/** Changes {@link Slot#getSequenceIndex()} for an attachment's {@link Sequence}. */
|
||||
/** Changes {@link Slot.getSequenceIndex} for an attachment's {@link Sequence}. */
|
||||
export class SequenceTimeline extends Timeline implements SlotTimeline {
|
||||
static ENTRIES = 3;
|
||||
static MODE = 1;
|
||||
@ -1518,15 +1525,15 @@ export class SequenceTimeline extends Timeline implements SlotTimeline {
|
||||
return this.slotIndex;
|
||||
}
|
||||
|
||||
/** The attachment for which the {@link SlotPose#getSequenceIndex()} will be set.
|
||||
* <p>
|
||||
/** The attachment for which the {@link SlotPose.getSequenceIndex} will be set.
|
||||
*
|
||||
* See {@link VertexAttachment.timelineAttachment}. */
|
||||
getAttachment () {
|
||||
return this.attachment as unknown as Attachment;
|
||||
}
|
||||
|
||||
/** Sets the time, mode, index, and frame time for the specified frame.
|
||||
* @param frame Between 0 and <code>frameCount</code>, inclusive.
|
||||
* @param frame Between 0 and `frameCount`, inclusive.
|
||||
* @param time Seconds between frames. */
|
||||
setFrame (frame: number, time: number, mode: SequenceMode, index: number, delay: number) {
|
||||
const frames = this.frames;
|
||||
@ -1645,12 +1652,12 @@ export class EventTimeline extends Timeline {
|
||||
}
|
||||
}
|
||||
|
||||
/** Changes the {@link Skeleton#getDrawOrder()}. */
|
||||
/** Changes the {@link Skeleton.getDrawOrder}. */
|
||||
export class DrawOrderTimeline extends Timeline {
|
||||
static readonly propertyID = `${Property.drawOrder}`;
|
||||
static propertyIds = [DrawOrderTimeline.propertyID];
|
||||
|
||||
/** The draw order for each key frame. See {@link #setFrame(int, float, int[])}. */
|
||||
/** The draw order for each key frame. See {@link setFrame}. */
|
||||
private readonly drawOrders: Array<Array<number> | null>;
|
||||
|
||||
constructor (frameCount: number) {
|
||||
@ -1664,7 +1671,7 @@ export class DrawOrderTimeline extends Timeline {
|
||||
}
|
||||
|
||||
/** Sets the time in seconds and the draw order for the specified key frame.
|
||||
* @param drawOrder Ordered {@link Skeleton#slots} indices, or null to use setup pose
|
||||
* @param drawOrder Ordered {@link Skeleton.slots} indices, or null to use setup pose
|
||||
* draw order. */
|
||||
setFrame (frame: number, time: number, drawOrder: Array<number> | null) {
|
||||
this.frames[frame] = time;
|
||||
@ -1690,13 +1697,13 @@ export class DrawOrderTimeline extends Timeline {
|
||||
}
|
||||
}
|
||||
|
||||
/** Changes a subset of the {@link Skeleton#getDrawOrder() draw order}. */
|
||||
/** Changes a subset of the {@link Skeleton.getDrawOrder | draw order}. */
|
||||
export class DrawOrderFolderTimeline extends Timeline {
|
||||
private readonly slots: number[];
|
||||
private readonly inFolder: boolean[];
|
||||
private readonly drawOrders: Array<Array<number> | null>;
|
||||
|
||||
/** @param slots {@link Skeleton#slots} indices controlled by this timeline, in setup order.
|
||||
/** @param slots {@link Skeleton.slots} indices controlled by this timeline, in setup order.
|
||||
* @param slotCount The maximum number of slots in the skeleton. */
|
||||
constructor (frameCount: number, slots: number[], slotCount: number) {
|
||||
super(frameCount, ...DrawOrderFolderTimeline.propertyIds(slots));
|
||||
@ -1720,20 +1727,20 @@ export class DrawOrderFolderTimeline extends Timeline {
|
||||
return this.frames.length;
|
||||
}
|
||||
|
||||
/** The {@link Skeleton#getSlots()} indices that this timeline affects, in setup order. */
|
||||
/** The {@link Skeleton.getSlots} indices that this timeline affects, in setup order. */
|
||||
getSlots (): number[] {
|
||||
return this.slots;
|
||||
}
|
||||
|
||||
/** The draw order for each frame. See {@link #setFrame(int, float, int[])}. */
|
||||
/** The draw order for each frame. See {@link setFrame}. */
|
||||
getDrawOrders (): Array<Array<number> | null> {
|
||||
return this.drawOrders;
|
||||
}
|
||||
|
||||
/** Sets the time and draw order for the specified frame.
|
||||
* @param frame Between 0 and <code>frameCount</code>, inclusive.
|
||||
* @param frame Between 0 and `frameCount`, inclusive.
|
||||
* @param time The frame time in seconds.
|
||||
* @param drawOrder Ordered {@link #getSlots()} indices, or null to use setup pose order. */
|
||||
* @param drawOrder Ordered {@link getSlots} indices, or null to use setup pose order. */
|
||||
setFrame (frame: number, time: number, drawOrder: Array<number> | null): void {
|
||||
this.frames[frame] = time;
|
||||
this.drawOrders[frame] = drawOrder;
|
||||
@ -1774,7 +1781,7 @@ export class DrawOrderFolderTimeline extends Timeline {
|
||||
}
|
||||
|
||||
export interface ConstraintTimeline {
|
||||
/** The index of the constraint in {@link Skeleton#constraints} that will be changed when this timeline is applied, or -1 if
|
||||
/** The index of the constraint in {@link Skeleton.constraints} that will be changed when this timeline is applied, or -1 if
|
||||
* a specific constraint will not be changed. */
|
||||
readonly constraintIndex: number;
|
||||
}
|
||||
@ -1799,7 +1806,7 @@ export class IkConstraintTimeline extends CurveTimeline implements ConstraintTim
|
||||
}
|
||||
|
||||
/** Sets the time, mix, softness, bend direction, compress, and stretch for the specified frame.
|
||||
* @param frame Between 0 and <code>frameCount</code>, inclusive.
|
||||
* @param frame Between 0 and `frameCount`, inclusive.
|
||||
* @param time The frame time in seconds.
|
||||
* @param bendDirection 1 or -1. */
|
||||
setFrame (frame: number, time: number, mix: number, softness: number, bendDirection: number, compress: boolean, stretch: boolean) {
|
||||
@ -1889,7 +1896,7 @@ export class TransformConstraintTimeline extends CurveTimeline implements Constr
|
||||
}
|
||||
|
||||
/** Sets the time, rotate mix, translate mix, scale mix, and shear mix for the specified frame.
|
||||
* @param frame Between 0 and <code>frameCount</code>, inclusive.
|
||||
* @param frame Between 0 and `frameCount`, inclusive.
|
||||
* @param time The frame time in seconds. */
|
||||
setFrame (frame: number, time: number, mixRotate: number, mixX: number, mixY: number, mixScaleX: number, mixScaleY: number,
|
||||
mixShearY: number) {
|
||||
@ -2028,8 +2035,8 @@ export class PathConstraintSpacingTimeline extends ConstraintTimeline1 {
|
||||
}
|
||||
}
|
||||
|
||||
/** Changes {@link PathConstraint.mixRotate()}, {@link PathConstraint.mixX()}, and
|
||||
* {@link PathConstraint.mixY()}. */
|
||||
/** Changes {@link PathConstraint.mixRotate}, {@link PathConstraint.mixX}, and
|
||||
* {@link PathConstraint.mixY}. */
|
||||
export class PathConstraintMixTimeline extends CurveTimeline implements ConstraintTimeline {
|
||||
readonly constraintIndex: number;
|
||||
|
||||
@ -2044,7 +2051,7 @@ export class PathConstraintMixTimeline extends CurveTimeline implements Constrai
|
||||
}
|
||||
|
||||
/** Sets the time and color for the specified frame.
|
||||
* @param frame Between 0 and <code>frameCount</code>, inclusive.
|
||||
* @param frame Between 0 and `frameCount`, inclusive.
|
||||
* @param time The frame time in seconds. */
|
||||
setFrame (frame: number, time: number, mixRotate: number, mixX: number, mixY: number) {
|
||||
const frames = this.frames;
|
||||
@ -2302,12 +2309,12 @@ export class PhysicsConstraintResetTimeline extends Timeline implements Constrai
|
||||
}
|
||||
|
||||
/** Sets the time for the specified frame.
|
||||
* @param frame Between 0 and <code>frameCount</code>, inclusive. */
|
||||
* @param frame Between 0 and `frameCount`, inclusive. */
|
||||
setFrame (frame: number, time: number) {
|
||||
this.frames[frame] = time;
|
||||
}
|
||||
|
||||
/** Resets the physics constraint when frames > <code>lastTime</code> and <= <code>time</code>. */
|
||||
/** Resets the physics constraint when frames > `lastTime` and <= `time`. */
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, fromSetup: boolean,
|
||||
add: boolean, out: boolean, appliedPose: boolean) {
|
||||
|
||||
@ -2338,7 +2345,7 @@ export class PhysicsConstraintResetTimeline extends Timeline implements Constrai
|
||||
}
|
||||
}
|
||||
|
||||
/** Changes {@link SliderPose.time()}. */
|
||||
/** Changes {@link SliderPose.time}. */
|
||||
export class SliderTimeline extends ConstraintTimeline1 {
|
||||
constructor (frameCount: number, bezierCount: number, constraintIndex: number) {
|
||||
super(frameCount, bezierCount, constraintIndex, Property.sliderTime);
|
||||
@ -2356,7 +2363,7 @@ export class SliderTimeline extends ConstraintTimeline1 {
|
||||
}
|
||||
}
|
||||
|
||||
/** Changes {@link SliderPose.mix()}. */
|
||||
/** Changes {@link SliderPose.mix}. */
|
||||
export class SliderMixTimeline extends ConstraintTimeline1 {
|
||||
constructor (frameCount: number, bezierCount: number, constraintIndex: number) {
|
||||
super(frameCount, bezierCount, constraintIndex, Property.sliderMix);
|
||||
|
||||
@ -53,7 +53,7 @@ export class AnimationState {
|
||||
/** Multiplier for the delta time when the animation state is updated, causing time for all animations and mixes to play slower
|
||||
* or faster. Defaults to 1.
|
||||
*
|
||||
* See {@link TrackEntry#timeScale} to affect a single animation. */
|
||||
* See {@link TrackEntry.timeScale} to affect a single animation. */
|
||||
timeScale = 1;
|
||||
unkeyedState = 0;
|
||||
|
||||
@ -69,7 +69,7 @@ export class AnimationState {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/** Increments each track entry {@link TrackEntry#trackTime}, setting queued animations as current if needed. */
|
||||
/** Increments each track entry {@link TrackEntry.trackTime}, setting queued animations as current if needed. */
|
||||
update (delta: number) {
|
||||
delta *= this.timeScale;
|
||||
const tracks = this.tracks;
|
||||
@ -306,7 +306,7 @@ export class AnimationState {
|
||||
return mix;
|
||||
}
|
||||
|
||||
/** Applies the attachment timeline and sets {@link Slot#attachmentState}.
|
||||
/** Applies the attachment timeline and sets {@link Slot.attachmentState}.
|
||||
* @param attachments False when: 1) the attachment timeline is mixing out, 2) mix < attachmentThreshold, and 3) the timeline
|
||||
* is not the last timeline to set the slot's attachment. In that case the timeline is applied only so subsequent
|
||||
* timelines see any deform. */
|
||||
@ -423,7 +423,7 @@ export class AnimationState {
|
||||
|
||||
/** Removes all animations from all tracks, leaving skeletons in their current pose.
|
||||
*
|
||||
* Usually you want to use {@link #setEmptyAnimations(float)} to mix the skeletons back to the setup pose, rather than leaving
|
||||
* Usually you want to use {@link setEmptyAnimations} to mix the skeletons back to the setup pose, rather than leaving
|
||||
* them in their current pose. */
|
||||
clearTracks () {
|
||||
const oldDrainDisabled = this.queue.drainDisabled;
|
||||
@ -437,7 +437,7 @@ export class AnimationState {
|
||||
|
||||
/** Removes all animations from the track, leaving skeletons in their current pose.
|
||||
*
|
||||
* Usually you want to use {@link #setEmptyAnimation(int, float)} to mix the skeletons back to the setup pose, rather than
|
||||
* Usually you want to use {@link setEmptyAnimation} to mix the skeletons back to the setup pose, rather than
|
||||
* leaving them in their current pose. */
|
||||
clearTrack (trackIndex: number) {
|
||||
if (trackIndex >= this.tracks.length) return;
|
||||
@ -512,9 +512,9 @@ export class AnimationState {
|
||||
* If the formerly current track entry is for the same animation and was never applied to a skeleton, it is replaced (not mixed
|
||||
* from).
|
||||
* @param loop If true, the animation will repeat. If false it will not, instead its last frame is applied if played beyond its
|
||||
* duration. In either case {@link TrackEntry#getTrackEnd()} determines when the track is cleared.
|
||||
* duration. In either case {@link TrackEntry.getTrackEnd} determines when the track is cleared.
|
||||
* @return A track entry to allow further customization of animation playback. References to the track entry must not be kept
|
||||
* after the {@link AnimationStateListener#dispose(TrackEntry)} event occurs. */
|
||||
* after the {@link AnimationStateListener.dispose} event occurs. */
|
||||
private setAnimation2 (trackIndex: number, animation: Animation, loop: boolean = false) {
|
||||
if (trackIndex < 0) throw new Error("trackIndex must be >= 0.");
|
||||
if (!animation) throw new Error("animation cannot be null.");
|
||||
@ -546,7 +546,7 @@ export class AnimationState {
|
||||
/** Adds an animation to be played after the current or last queued animation for a track. If the track has no entries, this is
|
||||
* equivalent to calling {@link setAnimation}.
|
||||
* @param delay If > 0, sets {@link TrackEntry.delay}. If <= 0, the delay set is the duration of the previous track entry
|
||||
* minus any mix duration (from {@link #data}) plus the specified `delay` (ie the mix ends at (when
|
||||
* minus any mix duration (from {@link data}) plus the specified `delay` (ie the mix ends at (when
|
||||
* `delay` = 0) or before (when `delay` < 0) the previous track entry duration). If the
|
||||
* previous entry is looping, its next loop completion is used instead of its duration.
|
||||
* @return A track entry to allow further customization of animation playback. References to the track entry must not be kept
|
||||
@ -591,17 +591,17 @@ export class AnimationState {
|
||||
}
|
||||
|
||||
/** Sets an empty animation for a track, discarding any queued animations, and sets the track entry's
|
||||
* {@link TrackEntry#mixduration}. An empty animation has no timelines and serves as a placeholder for mixing in or out.
|
||||
* {@link TrackEntry.mixduration}. An empty animation has no timelines and serves as a placeholder for mixing in or out.
|
||||
*
|
||||
* Mixing out is done by setting an empty animation with a mix duration using either {@link #setEmptyAnimation()},
|
||||
* {@link #setEmptyAnimations()}, or {@link #addEmptyAnimation()}. Mixing to an empty animation causes
|
||||
* Mixing out is done by setting an empty animation with a mix duration using either {@link setEmptyAnimation},
|
||||
* {@link setEmptyAnimations}, or {@link addEmptyAnimation}. Mixing to an empty animation causes
|
||||
* the previous animation to be applied less and less over the mix duration. Properties keyed in the previous animation
|
||||
* transition to the value from lower tracks or to the setup pose value if no lower tracks key the property. A mix duration of
|
||||
* 0 still needs to be applied one more time to mix out, so the properties it was animating are reverted.
|
||||
*
|
||||
* Mixing in is done by first setting an empty animation, then adding an animation using
|
||||
* {@link #addAnimation(int, Animation, boolean, float)} with the desired delay (an empty animation has a duration of 0) and on
|
||||
* the returned track entry, set the {@link TrackEntry#setMixDuration(float)}. Mixing from an empty animation causes the new
|
||||
* {@link addAnimation} with the desired delay (an empty animation has a duration of 0) and on
|
||||
* the returned track entry, set the {@link TrackEntry.setMixDuration}. Mixing from an empty animation causes the new
|
||||
* animation to be applied more and more over the mix duration. Properties keyed in the new animation transition from the value
|
||||
* from lower tracks or from the setup pose value if no lower tracks key the property to the value keyed in the new animation.
|
||||
*
|
||||
@ -615,18 +615,18 @@ export class AnimationState {
|
||||
}
|
||||
|
||||
/** Adds an empty animation to be played after the current or last queued animation for a track, and sets the track entry's
|
||||
* {@link TrackEntry#mixDuration}. If the track has no entries, it is equivalent to calling
|
||||
* {@link #setEmptyAnimation(int, float)}.
|
||||
* {@link TrackEntry.mixDuration}. If the track has no entries, it is equivalent to calling
|
||||
* {@link setEmptyAnimation}.
|
||||
*
|
||||
* See {@link #setEmptyAnimation(int, float)} and
|
||||
* See {@link setEmptyAnimation} and
|
||||
* <a href='https://esotericsoftware.com/spine-applying-animations#Empty-animations'>Empty animations</a> in the Spine Runtimes
|
||||
* Guide.
|
||||
* @param delay If > 0, sets {@link TrackEntry#delay}. If <= 0, the delay set is the duration of the previous track entry minus
|
||||
* any mix duration plus the specified <code>delay</code> (ie the mix ends at (when <code>delay</code> = 0) or before
|
||||
* (when <code>delay</code> < 0) the previous track entry duration). If the previous entry is looping, its next loop
|
||||
* @param delay If > 0, sets {@link TrackEntry.delay}. If <= 0, the delay set is the duration of the previous track entry minus
|
||||
* any mix duration plus the specified `delay` (ie the mix ends at (when `delay` = 0) or before
|
||||
* (when `delay` < 0) the previous track entry duration). If the previous entry is looping, its next loop
|
||||
* completion is used instead of its duration.
|
||||
* @return A track entry to allow further customization of animation playback. References to the track entry must not be kept
|
||||
* after the {@link AnimationStateListener#dispose(TrackEntry)} event occurs. */
|
||||
* after the {@link AnimationStateListener.dispose} event occurs. */
|
||||
addEmptyAnimation (trackIndex: number, mixDuration: number = 0, delay: number = 0) {
|
||||
const entry = this.addAnimation(trackIndex, AnimationState.emptyAnimation, false, delay);
|
||||
if (delay <= 0) entry.delay = Math.max(entry.delay + entry.mixDuration - mixDuration, 0);
|
||||
@ -694,7 +694,7 @@ export class AnimationState {
|
||||
return entry;
|
||||
}
|
||||
|
||||
/** Removes {@link TrackEntry#next} and all entries after it for the specified entry. */
|
||||
/** Removes {@link TrackEntry.next} and all entries after it for the specified entry. */
|
||||
clearNext (entry: TrackEntry) {
|
||||
let next = entry.next;
|
||||
while (next) {
|
||||
@ -783,13 +783,13 @@ export class AnimationState {
|
||||
this.listeners.push(listener);
|
||||
}
|
||||
|
||||
/** Removes the listener added with {@link #addListener()}. */
|
||||
/** Removes the listener added with {@link addListener}. */
|
||||
removeListener (listener: AnimationStateListener) {
|
||||
const index = this.listeners.indexOf(listener);
|
||||
if (index >= 0) this.listeners.splice(index, 1);
|
||||
}
|
||||
|
||||
/** Removes all listeners added with {@link #addListener()}. */
|
||||
/** Removes all listeners added with {@link addListener}. */
|
||||
clearListeners () {
|
||||
this.listeners.length = 0;
|
||||
}
|
||||
@ -804,7 +804,7 @@ export class AnimationState {
|
||||
|
||||
/** Stores settings and other state for the playback of an animation on an {@link AnimationState} track.
|
||||
*
|
||||
* References to a track entry must not be kept after the {@link AnimationStateListener#dispose()} event occurs. */
|
||||
* References to a track entry must not be kept after the {@link AnimationStateListener.dispose} event occurs. */
|
||||
export class TrackEntry {
|
||||
/** The animation to apply for this track entry. */
|
||||
animation: Animation | null = null;
|
||||
@ -815,22 +815,22 @@ export class TrackEntry {
|
||||
next: TrackEntry | null = null;
|
||||
|
||||
/** The track entry for the previous animation when mixing to this animation, or null if no mixing is currently occurring.
|
||||
* When mixing from multiple animations, <code>mixingFrom</code> makes up a doubly linked list. */
|
||||
* When mixing from multiple animations, `mixingFrom` makes up a doubly linked list. */
|
||||
mixingFrom: TrackEntry | null = null;
|
||||
|
||||
/** The track entry for the next animation when mixing from this animation, or null if no mixing is currently occurring.
|
||||
* When mixing to multiple animations, <code>mixingTo</code> makes up a doubly linked list. */
|
||||
* When mixing to multiple animations, `mixingTo` makes up a doubly linked list. */
|
||||
mixingTo: TrackEntry | null = null;
|
||||
|
||||
/** The listener for events generated by this track entry, or null.
|
||||
*
|
||||
* A track entry returned from {@link AnimationState#setAnimation()} is already the current animation
|
||||
* for the track, so the callback for listener {@link AnimationStateListener#start()} will not be called. */
|
||||
* A track entry returned from {@link AnimationState.setAnimation} is already the current animation
|
||||
* for the track, so the callback for listener {@link AnimationStateListener.start} will not be called. */
|
||||
listener: AnimationStateListener | null = null;
|
||||
|
||||
/** The index of the track where this track entry is either current or queued.
|
||||
*
|
||||
* See {@link AnimationState#getCurrent()}. */
|
||||
* See {@link AnimationState.getCurrent}. */
|
||||
trackIndex = 0;
|
||||
|
||||
/** If true, the animation will repeat. If false it will not, instead its last frame is applied if played beyond its
|
||||
@ -838,7 +838,7 @@ export class TrackEntry {
|
||||
loop = false;
|
||||
|
||||
/** When true, timelines in this animation that support additive have their values added to the setup or current pose values
|
||||
* instead of replacing them. Additive can be set for a new track entry only before {@link AnimationState#apply(Skeleton)}
|
||||
* instead of replacing them. Additive can be set for a new track entry only before {@link AnimationState.apply}
|
||||
* is next called. */
|
||||
additive = false;
|
||||
|
||||
@ -851,39 +851,39 @@ export class TrackEntry {
|
||||
* If false, the shortest rotation direction is remembered when the mix starts and the same direction is used for the rest
|
||||
* of the mix. Defaults to false.
|
||||
*
|
||||
* See {@link #resetRotationDirections()}. */
|
||||
* See {@link resetRotationDirections}. */
|
||||
shortestRotation = false;
|
||||
|
||||
keepHold = false;
|
||||
|
||||
/** When the mix percentage ({@link #mixTime} / {@link #mixDuration}) is less than the `eventThreshold`, event
|
||||
/** When the mix percentage ({@link mixTime} / {@link mixDuration}) is less than the `eventThreshold`, event
|
||||
* timelines are applied while this animation is being mixed out. Defaults to 0, so event timelines are not applied while
|
||||
* this animation is being mixed out. */
|
||||
eventThreshold = 0;
|
||||
|
||||
/** When the mix percentage ({@link #mixTime} / {@link #mixDuration}) is less than the `mixAttachmentThreshold`,
|
||||
/** When the mix percentage ({@link mixTime} / {@link mixDuration}) is less than the `mixAttachmentThreshold`,
|
||||
* attachment timelines are applied while this animation is being mixed out. Defaults to 0, so attachment timelines are not
|
||||
* applied while this animation is being mixed out. */
|
||||
mixAttachmentThreshold = 0;
|
||||
|
||||
/** When the computed alpha is greater than `alphaAttachmentThreshold`, attachment timelines are applied. The
|
||||
* computed alpha includes {@link #alpha} and the mix percentage. Defaults to 0, so attachment timelines are always
|
||||
* computed alpha includes {@link alpha} and the mix percentage. Defaults to 0, so attachment timelines are always
|
||||
* applied. */
|
||||
alphaAttachmentThreshold = 0;
|
||||
|
||||
/** When the mix percentage ({@link #mixTime} / {@link #mixDuration}) is less than the `mixDrawOrderThreshold`,
|
||||
/** When the mix percentage ({@link mixTime} / {@link mixDuration}) is less than the `mixDrawOrderThreshold`,
|
||||
* draw order timelines are applied while this animation is being mixed out. Defaults to 0, so draw order timelines are not
|
||||
* applied while this animation is being mixed out. */
|
||||
mixDrawOrderThreshold = 0;
|
||||
|
||||
/** Seconds when this animation starts, both initially and after looping. Defaults to 0.
|
||||
*
|
||||
* When changing the `animationStart` time, it often makes sense to set {@link #animationLast} to the same value
|
||||
* When changing the `animationStart` time, it often makes sense to set {@link animationLast} to the same value
|
||||
* to prevent timeline keys before the start time from triggering. */
|
||||
animationStart = 0;
|
||||
|
||||
/** Seconds for the last frame of this animation. Non-looping animations won't play past this time. Looping animations will
|
||||
* loop back to {@link #animationStart} at this time. Defaults to the animation {@link Animation#duration}. */
|
||||
* loop back to {@link animationStart} at this time. Defaults to the animation {@link Animation.duration}. */
|
||||
animationEnd = 0;
|
||||
|
||||
|
||||
@ -896,19 +896,19 @@ export class TrackEntry {
|
||||
nextAnimationLast = 0;
|
||||
|
||||
/** Seconds to postpone playing the animation. Must be >= 0. When this track entry is the current track entry,
|
||||
* `delay` postpones incrementing the {@link #trackTime}. When this track entry is queued, `delay` is
|
||||
* `delay` postpones incrementing the {@link trackTime}. When this track entry is queued, `delay` is
|
||||
* the time from the start of the previous animation to when this track entry will become the current track entry (ie when
|
||||
* the previous track entry {@link #trackTime} >= this track entry's `delay`).
|
||||
* the previous track entry {@link trackTime} >= this track entry's `delay`).
|
||||
*
|
||||
* {@link #timeScale} affects the delay.
|
||||
* {@link timeScale} affects the delay.
|
||||
*
|
||||
* When passing `delay` <= 0 to {@link AnimationState#addAnimation(int, Animation, boolean, float)} this
|
||||
* `delay` is set using a mix duration from {@link AnimationStateData}. To change the {@link #mixDuration}
|
||||
* afterward, use {@link #setMixDuration(float, float)} so this `delay` is adjusted. */
|
||||
* When passing `delay` <= 0 to {@link AnimationState.addAnimation} this
|
||||
* `delay` is set using a mix duration from {@link AnimationStateData}. To change the {@link mixDuration}
|
||||
* afterward, use {@link setMixDuration} so this `delay` is adjusted. */
|
||||
delay = 0;
|
||||
|
||||
/** Current time in seconds this track entry has been the current track entry. The track time determines
|
||||
* {@link #animationTime}. The track time can be set to start the animation at a time other than 0, without affecting
|
||||
* {@link animationTime}. The track time can be set to start the animation at a time other than 0, without affecting
|
||||
* looping. */
|
||||
trackTime = 0;
|
||||
|
||||
@ -919,23 +919,23 @@ export class TrackEntry {
|
||||
* is reached, no other animations are queued for playback, and mixing from any previous animations is complete, then the
|
||||
* properties keyed by the animation are set to the setup pose and the track is cleared.
|
||||
*
|
||||
* Usually you want to use {@link AnimationState#addEmptyAnimation()} rather than have the animation
|
||||
* Usually you want to use {@link AnimationState.addEmptyAnimation} rather than have the animation
|
||||
* abruptly cease being applied. */
|
||||
trackEnd = 0;
|
||||
|
||||
/** Multiplier for the delta time when this track entry is updated, causing time for this animation to pass slower or
|
||||
* faster. Defaults to 1.
|
||||
*
|
||||
* Values < 0 are not supported. To play an animation in reverse, use {@link #reverse}.
|
||||
* Values < 0 are not supported. To play an animation in reverse, use {@link reverse}.
|
||||
*
|
||||
* {@link #mixTime} is not affected by track entry time scale, so {@link #mixDuration} may need to be adjusted to match the
|
||||
* {@link mixTime} is not affected by track entry time scale, so {@link mixDuration} may need to be adjusted to match the
|
||||
* animation speed.
|
||||
*
|
||||
* When using {@link AnimationState#addAnimation(int, Animation, boolean, float)} with a `delay` <= 0, the
|
||||
* {@link #delay} is set using the mix duration from {@link AnimationState#data}, assuming time scale to be 1. If the time
|
||||
* When using {@link AnimationState.addAnimation} with a `delay` <= 0, the
|
||||
* {@link delay} is set using the mix duration from {@link AnimationState.data}, assuming time scale to be 1. If the time
|
||||
* scale is not 1, the delay may need to be adjusted.
|
||||
*
|
||||
* See {@link AnimationState#timeScale} to affect all animations. */
|
||||
* See {@link AnimationState.timeScale} to affect all animations. */
|
||||
timeScale = 0;
|
||||
|
||||
/** Values < 1 mix this animation with the skeleton's current pose (either the setup pose or the pose from lower tracks).
|
||||
@ -943,26 +943,26 @@ export class TrackEntry {
|
||||
*
|
||||
* Alpha should be 1 on track 0.
|
||||
*
|
||||
* See {@link #getAlphaAttachmentThreshold()}. */
|
||||
* See {@link getAlphaAttachmentThreshold}. */
|
||||
alpha = 0;
|
||||
|
||||
/** Seconds elapsed from 0 to the {@link #mixDuration()} when mixing from the previous animation to this animation. May
|
||||
/** Seconds elapsed from 0 to the {@link mixDuration} when mixing from the previous animation to this animation. May
|
||||
* be slightly more than `mixDuration` when the mix is complete. */
|
||||
mixTime = 0;
|
||||
|
||||
/** Seconds for mixing from the previous animation to this animation. Defaults to the value provided by
|
||||
* {@link AnimationStateData#getMix(Animation, Animation)} based on the animation before this animation (if any).
|
||||
* {@link AnimationStateData.getMix} based on the animation before this animation (if any).
|
||||
*
|
||||
* A mix duration of 0 still needs to be applied one more time to mix out, so the the properties it was animating are
|
||||
* reverted. A mix duration of 0 can be set at any time to end the mix on the next {@link AnimationState#update(float)
|
||||
* update}.
|
||||
* reverted. A mix duration of 0 can be set at any time to end the mix on the next
|
||||
* {@link AnimationState.update | update}.
|
||||
*
|
||||
* The `mixDuration` can be set manually rather than use the value from
|
||||
* {@link AnimationStateData#getMix(Animation, Animation)}. In that case, the `mixDuration` can be set for a new
|
||||
* track entry only before {@link AnimationState#update(float)} is next called.
|
||||
* {@link AnimationStateData.getMix}. In that case, the `mixDuration` can be set for a new
|
||||
* track entry only before {@link AnimationState.update} is next called.
|
||||
*
|
||||
* When using {@link AnimationState#addAnimation(int, Animation, boolean, float)} with a `delay` <= 0, the
|
||||
* {@link #getDelay()} is set using the mix duration from {@link AnimationState#data}. If `mixDuration` is set
|
||||
* When using {@link AnimationState.addAnimation} with a `delay` <= 0, the
|
||||
* {@link getDelay} is set using the mix duration from {@link AnimationState.data}. If `mixDuration` is set
|
||||
* afterward, the delay needs to be adjusted:
|
||||
*
|
||||
* <pre>
|
||||
@ -970,7 +970,7 @@ export class TrackEntry {
|
||||
* entry.delay = entry.previous.getTrackComplete() - entry.mixDuration + 0;
|
||||
* </pre>
|
||||
*
|
||||
* Alternatively, use {@link #setMixDuration(float, float)} to set both the mix duration and recompute the delay:<br>
|
||||
* Alternatively, use {@link setMixDuration} to set both the mix duration and recompute the delay:<br>
|
||||
*
|
||||
* <pre>
|
||||
entry.setMixDuration(0.25f, 0); // mixDuration, delay
|
||||
@ -980,10 +980,10 @@ export class TrackEntry {
|
||||
|
||||
totalAlpha = 0;
|
||||
|
||||
/** Sets both {@link #getMixDuration()} and {@link #getDelay()}.
|
||||
* @param delay If > 0, sets {@link #getDelay()}. If <= 0, the delay set is the duration of the previous track entry minus
|
||||
* the specified mix duration plus the specified <code>delay</code> (ie the mix ends at (when <code>delay</code> =
|
||||
* 0) or before (when <code>delay</code> < 0) the previous track entry duration). If the previous entry is
|
||||
/** Sets both {@link getMixDuration} and {@link getDelay}.
|
||||
* @param delay If > 0, sets {@link getDelay}. If <= 0, the delay set is the duration of the previous track entry minus
|
||||
* the specified mix duration plus the specified `delay` (ie the mix ends at (when `delay` =
|
||||
* 0) or before (when `delay` < 0) the previous track entry duration). If the previous entry is
|
||||
* looping, its next loop completion is used instead of its duration. */
|
||||
setMixDuration (mixDuration: number, delay?: number) {
|
||||
this.mixDuration = mixDuration;
|
||||
@ -994,8 +994,8 @@ export class TrackEntry {
|
||||
}
|
||||
|
||||
/** For each timeline:
|
||||
* <li>Bit 0, FIRST: 0 = mix from current pose, 1 = mix from setup pose. Timeline is first to set the property.
|
||||
* <li>Bit 1, HOLD: 0 = mix out using alphaMix, 1 = apply full alpha to prevent dipping. Timeline is first on its track to
|
||||
* - Bit 0, FIRST: 0 = mix from current pose, 1 = mix from setup pose. Timeline is first to set the property.
|
||||
* - Bit 1, HOLD: 0 = mix out using alphaMix, 1 = apply full alpha to prevent dipping. Timeline is first on its track to
|
||||
* set the property and the next entry (mixingTo) also sets it. When held, timelineHoldMix's mix controls how the hold fades
|
||||
* out (for 3+ entry chains where the chain eventually stops setting the property). */
|
||||
timelineMode = [] as number[];
|
||||
@ -1014,12 +1014,12 @@ export class TrackEntry {
|
||||
this.timelinesRotation.length = 0;
|
||||
}
|
||||
|
||||
/** Uses {@link #trackTime} to compute the `animationTime`. When the `trackTime` is 0, the
|
||||
/** Uses {@link trackTime} to compute the `animationTime`. When the `trackTime` is 0, the
|
||||
* `animationTime` is equal to the `animationStart` time.
|
||||
*
|
||||
* The `animationTime` is between {@link #animationStart} and {@link #animationEnd}, except if this track entry
|
||||
* is non-looping and {@link #animationEnd} is >= to the {@link Animation#duration}, then `animationTime`
|
||||
* continues to increase past {@link #animationEnd}. */
|
||||
* The `animationTime` is between {@link animationStart} and {@link animationEnd}, except if this track entry
|
||||
* is non-looping and {@link animationEnd} is >= to the {@link Animation.duration}, then `animationTime`
|
||||
* continues to increase past {@link animationEnd}. */
|
||||
getAnimationTime () {
|
||||
if (this.loop) {
|
||||
const duration = this.animationEnd - this.animationStart;
|
||||
@ -1036,13 +1036,13 @@ export class TrackEntry {
|
||||
|
||||
/** Returns true if at least one loop has been completed.
|
||||
*
|
||||
* See {@link AnimationStateListener#complete()}. */
|
||||
* See {@link AnimationStateListener.complete}. */
|
||||
isComplete () {
|
||||
return this.trackTime >= this.animationEnd - this.animationStart;
|
||||
}
|
||||
|
||||
/** When {@link #shortestRotation} is false, this clears the directions for mixing this entry's rotation. This can be useful
|
||||
* to avoid bones rotating the long way around when using {@link #getAlpha()} and starting animations on other tracks.
|
||||
/** When {@link shortestRotation} is false, this clears the directions for mixing this entry's rotation. This can be useful
|
||||
* to avoid bones rotating the long way around when using {@link getAlpha} and starting animations on other tracks.
|
||||
*
|
||||
* Mixing involves finding a rotation between two others. There are two possible solutions: the short or the long way
|
||||
* around. When the two rotations change over time, which direction is the short or long way can also change. If the short
|
||||
@ -1053,10 +1053,10 @@ export class TrackEntry {
|
||||
this.timelinesRotation.length = 0;
|
||||
}
|
||||
|
||||
/** If this track entry is non-looping, this is the track time in seconds when {@link #animationEnd} is reached, or the
|
||||
* current {@link #trackTime} if it has already been reached.
|
||||
/** If this track entry is non-looping, this is the track time in seconds when {@link animationEnd} is reached, or the
|
||||
* current {@link trackTime} if it has already been reached.
|
||||
*
|
||||
* If this track entry is looping, this is the track time when this animation will reach its next {@link #animationEnd} (the
|
||||
* If this track entry is looping, this is the track time when this animation will reach its next {@link animationEnd} (the
|
||||
* next loop completion). */
|
||||
getTrackComplete () {
|
||||
const duration = this.animationEnd - this.animationStart;
|
||||
@ -1069,13 +1069,13 @@ export class TrackEntry {
|
||||
|
||||
/** Returns true if this track entry has been applied at least once.
|
||||
*
|
||||
* See {@link AnimationState#apply(Skeleton)}. */
|
||||
* See {@link AnimationState.apply}. */
|
||||
wasApplied () {
|
||||
return this.nextTrackLast !== -1;
|
||||
}
|
||||
|
||||
/** Returns true if there is a {@link #next()} track entry and it will become the current track entry during the next
|
||||
* {@link AnimationState#update(float)}. */
|
||||
/** Returns true if there is a {@link next} track entry and it will become the current track entry during the next
|
||||
* {@link AnimationState.update}. */
|
||||
isNextReady () {
|
||||
return this.next != null && this.nextTrackLast - this.next.delay >= 0;
|
||||
}
|
||||
@ -1199,11 +1199,11 @@ export enum EventType {
|
||||
/** The interface to implement for receiving TrackEntry events. It is always safe to call AnimationState methods when receiving
|
||||
* events.
|
||||
*
|
||||
* TrackEntry events are collected during {@link AnimationState#update} and {@link AnimationState#apply} and
|
||||
* TrackEntry events are collected during {@link AnimationState.update} and {@link AnimationState.apply} and
|
||||
* fired only after those methods are finished.
|
||||
*
|
||||
* See {@link TrackEntry#listener} and
|
||||
* {@link AnimationState#addListener}. */
|
||||
* See {@link TrackEntry.listener} and
|
||||
* {@link AnimationState.addListener}. */
|
||||
export interface AnimationStateListener {
|
||||
/** Invoked when this entry has been set as the current entry. {@link end} will occur when this entry will no
|
||||
* longer be applied.
|
||||
@ -1217,7 +1217,7 @@ export interface AnimationStateListener {
|
||||
interrupt?: (entry: TrackEntry) => void;
|
||||
|
||||
/** Invoked when this entry will never be applied again. This only occurs if this entry has previously been set as the
|
||||
* current entry ({@link #start(TrackEntry)} was invoked). */
|
||||
* current entry ({@link start} was invoked). */
|
||||
end?: (entry: TrackEntry) => void;
|
||||
|
||||
/** Invoked when this entry will be disposed. This may occur without the entry ever being set as the current entry.
|
||||
@ -1225,11 +1225,11 @@ export interface AnimationStateListener {
|
||||
dispose?: (entry: TrackEntry) => void;
|
||||
|
||||
/** Invoked every time this entry's animation completes a loop. This may occur during mixing (after
|
||||
* {@link #interrupt(TrackEntry)}).
|
||||
* {@link interrupt}).
|
||||
*
|
||||
* If this entry's {@link TrackEntry#mixingTo} is not null, this entry is mixing out (it is not the current entry).
|
||||
* If this entry's {@link TrackEntry.mixingTo} is not null, this entry is mixing out (it is not the current entry).
|
||||
*
|
||||
* Because this event is triggered at the end of {@link AnimationState#apply(Skeleton)}, any animations set in response to
|
||||
* Because this event is triggered at the end of {@link AnimationState.apply}, any animations set in response to
|
||||
* the event won't be applied until the next time the AnimationState is applied. */
|
||||
complete?: (entry: TrackEntry) => void;
|
||||
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
*****************************************************************************/
|
||||
|
||||
import type { Animation } from "./Animation.js";
|
||||
import type { AnimationState, TrackEntry } from "./AnimationState.js";
|
||||
import type { SkeletonData } from "./SkeletonData.js";
|
||||
import type { StringMap } from "./Utils.js";
|
||||
|
||||
@ -49,12 +50,12 @@ export class AnimationStateData {
|
||||
|
||||
/** Sets a mix duration by animation name.
|
||||
*
|
||||
* See {@link #setMix()}. */
|
||||
* See {@link setMix}. */
|
||||
setMix (fromName: string, to: string, duration: number): void;
|
||||
|
||||
/** Sets the mix duration when changing from the specified animation to the other.
|
||||
*
|
||||
* See {@link TrackEntry#mixDuration}. */
|
||||
* See {@link TrackEntry.mixDuration}. */
|
||||
setMix (from: Animation, to: Animation, duration: number): void;
|
||||
|
||||
setMix (from: string | Animation, to: string | Animation, duration: number) {
|
||||
@ -79,7 +80,7 @@ export class AnimationStateData {
|
||||
}
|
||||
|
||||
/** Returns the mix duration to use when changing from the specified animation to the other on the same track, or the
|
||||
* {@link #defaultMix} if no mix duration has been set. */
|
||||
* {@link defaultMix} if no mix duration has been set. */
|
||||
getMix (from: Animation, to: Animation) {
|
||||
const key = `${from.name}.${to.name}`;
|
||||
const value = this.animationToMixTime[key];
|
||||
|
||||
@ -51,15 +51,15 @@ export class AtlasAttachmentLoader implements AttachmentLoader {
|
||||
this.allowMissingRegions = allowMissingRegions;
|
||||
}
|
||||
|
||||
/** Sets each {@link Sequence#regions} by calling {@link #findRegion(String, String)} for each texture region using
|
||||
* {@link Sequence#getPath(String, int)}. */
|
||||
/** Sets each {@link Sequence.regions} by calling {@link findRegion} for each texture region using
|
||||
* {@link Sequence.getPath}. */
|
||||
protected findRegions (name: string, basePath: string, sequence: Sequence) {
|
||||
const regions = sequence.regions;
|
||||
for (let i = 0, n = regions.length; i < n; i++)
|
||||
regions[i] = this.findRegion(name, sequence.getPath(basePath, i));
|
||||
}
|
||||
|
||||
/** Looks for the region with the specified path. If not found and {@link #allowMissingRegions} is false, an error is
|
||||
/** Looks for the region with the specified path. If not found and {@link allowMissingRegions} is false, an error is
|
||||
* raised. */
|
||||
protected findRegion (name: string, path: string) {
|
||||
const region = this.atlas.findRegion(path);
|
||||
|
||||
@ -30,16 +30,15 @@
|
||||
import type { BoneData } from "./BoneData.js";
|
||||
import { BonePose } from "./BonePose.js";
|
||||
import { PosedActive } from "./PosedActive.js";
|
||||
import type { Skeleton } from "./Skeleton.js";
|
||||
|
||||
/** A node in a skeleton's hierarchy with a transform that affects its children and their attachments. A bone has a number of
|
||||
* poses:
|
||||
* <ul>
|
||||
* <li>{@link #data}: The setup pose.
|
||||
* <li>{@link #pose}: The unconstrained local pose. Set by animations and application code.
|
||||
* <li>{@link #appliedPose}: The local pose to use for rendering. Possibly modified by constraints.
|
||||
* <li>World transform: the local pose combined with the parent world transform. Computed on a pose by
|
||||
* {@link BonePose#updateWorldTransform(Skeleton)} and {@link Skeleton#updateWorldTransform(Physics)}.
|
||||
* </ul>
|
||||
* - {@link data}: The setup pose.
|
||||
* - {@link pose}: The unconstrained local pose. Set by animations and application code.
|
||||
* - {@link appliedPose}: The local pose to use for rendering. Possibly modified by constraints.
|
||||
* - World transform: the local pose combined with the parent world transform. Computed on a pose by
|
||||
* {@link BonePose.updateWorldTransform} and {@link Skeleton.updateWorldTransform}.
|
||||
*/
|
||||
export class Bone extends PosedActive<BoneData, BonePose> {
|
||||
/** The parent bone, or null if this is the root bone. */
|
||||
@ -57,7 +56,7 @@ export class Bone extends PosedActive<BoneData, BonePose> {
|
||||
this.constrainedPose.bone = this;
|
||||
}
|
||||
|
||||
/** Copy constructor. Does not copy the {@link #children} bones. */
|
||||
/** Copy constructor. Does not copy the {@link children} bones. */
|
||||
copy (parent: Bone | null): Bone {
|
||||
const copy = new Bone(this.data, parent);
|
||||
copy.pose.set(this.pose);
|
||||
|
||||
@ -35,14 +35,14 @@ import type { Skeleton } from "./Skeleton.js";
|
||||
import type { Update } from "./Update.js";
|
||||
import { MathUtils, type Vector2 } from "./Utils.js";
|
||||
|
||||
/** The applied local pose and world transform for a bone. This is the {@link Bone#getPose()} with constraints applied and the
|
||||
* world transform computed by {@link Skeleton#updateWorldTransform(Physics)} and {@link #updateWorldTransform(Skeleton)}.
|
||||
* <p>
|
||||
* If the world transform is changed, call {@link #updateLocalTransform(Skeleton)} before using the local transform. The local
|
||||
/** The applied local pose and world transform for a bone. This is the {@link Bone.getPose} with constraints applied and the
|
||||
* world transform computed by {@link Skeleton.updateWorldTransform} and {@link updateWorldTransform}.
|
||||
*
|
||||
* If the world transform is changed, call {@link updateLocalTransform} before using the local transform. The local
|
||||
* transform may be needed by other code (eg to apply another constraint).
|
||||
* <p>
|
||||
* After changing the world transform, call {@link #updateWorldTransform(Skeleton)} on every descendant bone. It may be more
|
||||
* convenient to modify the local transform instead, then call {@link Skeleton#updateWorldTransform(Physics)} to update the world
|
||||
*
|
||||
* After changing the world transform, call {@link updateWorldTransform} on every descendant bone. It may be more
|
||||
* convenient to modify the local transform instead, then call {@link Skeleton.updateWorldTransform} to update the world
|
||||
* transforms for all bones and apply constraints. */
|
||||
export class BonePose implements Pose<BonePose>, Update {
|
||||
bone!: Bone;
|
||||
@ -70,22 +70,22 @@ export class BonePose implements Pose<BonePose>, Update {
|
||||
|
||||
inherit = Inherit.Normal;
|
||||
|
||||
/** The world transform <code>[a b][c d]</code> x-axis x component. */
|
||||
/** The world transform `[a b][c d]` x-axis x component. */
|
||||
a = 0;
|
||||
|
||||
/** The world transform <code>[a b][c d]</code> y-axis x component. */
|
||||
/** The world transform `[a b][c d]` y-axis x component. */
|
||||
b = 0;
|
||||
|
||||
/** The world transform <code>[a b][c d]</code> x-axis y component. */
|
||||
/** The world transform `[a b][c d]` x-axis y component. */
|
||||
c = 0;
|
||||
|
||||
/** The world transform <code>[a b][c d]</code> y-axis y component. */
|
||||
/** The world transform `[a b][c d]` y-axis y component. */
|
||||
d = 0;
|
||||
|
||||
/** The world X position. If changed, {@link updateLocalTransform()} should be called. */
|
||||
/** The world X position. If changed, {@link updateLocalTransform} should be called. */
|
||||
worldY = 0;
|
||||
|
||||
/** The world Y position. If changed, {@link updateLocalTransform()} should be called. */
|
||||
/** The world Y position. If changed, {@link updateLocalTransform} should be called. */
|
||||
worldX = 0;
|
||||
|
||||
world = 0;
|
||||
@ -125,7 +125,7 @@ export class BonePose implements Pose<BonePose>, Update {
|
||||
this.inherit = inherit;
|
||||
}
|
||||
|
||||
/** Called by {@link Skeleton#updateCache()} to compute the world transform, if needed. */
|
||||
/** Called by {@link Skeleton.updateCache} to compute the world transform, if needed. */
|
||||
public update (skeleton: Skeleton, physics: Physics): void {
|
||||
if (this.world !== skeleton._update) this.updateWorldTransform(skeleton);
|
||||
}
|
||||
@ -249,11 +249,11 @@ export class BonePose implements Pose<BonePose>, Update {
|
||||
}
|
||||
|
||||
/** Computes the local transform values from the world transform.
|
||||
* <p>
|
||||
* If the world transform is modified (by a constraint, {@link #rotateWorld(float)}, etc) then this method should be called so
|
||||
*
|
||||
* If the world transform is modified (by a constraint, {@link rotateWorld}, etc) then this method should be called so
|
||||
* the local transform matches the world transform. The local transform may be needed by other code (eg to apply another
|
||||
* constraint).
|
||||
* <p>
|
||||
*
|
||||
* Some information is ambiguous in the world transform, such as -1,-1 scale versus 180 rotation. The local transform after
|
||||
* calling this method is equivalent to the local transform used to compute the world transform, but may not be identical. */
|
||||
public updateLocalTransform (skeleton: Skeleton): void {
|
||||
@ -340,7 +340,7 @@ export class BonePose implements Pose<BonePose>, Update {
|
||||
}
|
||||
|
||||
/** If the world transform has been modified by constraints and the local transform no longer matches,
|
||||
* {@link #updateLocalTransform(Skeleton)} is called. Call this after {@link Skeleton#updateWorldTransform(Physics)} before
|
||||
* {@link updateLocalTransform} is called. Call this after {@link Skeleton.updateWorldTransform} before
|
||||
* using the applied local transform. */
|
||||
public validateLocalTransform (skeleton: Skeleton): void {
|
||||
if (this.local === skeleton._update) this.updateLocalTransform(skeleton);
|
||||
@ -370,7 +370,7 @@ export class BonePose implements Pose<BonePose>, Update {
|
||||
}
|
||||
}
|
||||
|
||||
/** The world rotation for the X axis, calculated using {@link #a} and {@link #c}. This is the direction the bone is
|
||||
/** The world rotation for the X axis, calculated using {@link a} and {@link c}. This is the direction the bone is
|
||||
* pointing. */
|
||||
public getWorldRotationX (): number {
|
||||
return MathUtils.atan2Deg(this.c, this.a);
|
||||
|
||||
@ -38,8 +38,8 @@ export class DrawOrder {
|
||||
readonly pose: Slot[];
|
||||
readonly constrainedPose: Slot[];
|
||||
|
||||
/** The constrained draw order for rendering. If no constraints modify the draw order, this is the same as {@link #pose}.
|
||||
* Otherwise it is a copy of {@link #pose} modified by constraints. */
|
||||
/** The constrained draw order for rendering. If no constraints modify the draw order, this is the same as {@link pose}.
|
||||
* Otherwise it is a copy of {@link pose} modified by constraints. */
|
||||
appliedPose: Slot[];
|
||||
|
||||
constructor (setupPose: Slot[]) {
|
||||
|
||||
@ -28,14 +28,14 @@
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
import type { Timeline } from "./Animation.js";
|
||||
import type { EventTimeline, Timeline } from "./Animation.js";
|
||||
import type { AnimationStateListener } from "./AnimationState.js";
|
||||
import type { EventData } from "./EventData.js";
|
||||
|
||||
/** Fired by {@link EventTimeline} when specific animation times are reached.
|
||||
*
|
||||
* See Timeline {@link Timeline.apply()},
|
||||
* AnimationStateListener {@link AnimationStateListener.event()}, and
|
||||
* See Timeline {@link Timeline.apply},
|
||||
* AnimationStateListener {@link AnimationStateListener.event}, and
|
||||
* [Events](http://esotericsoftware.com/spine-events) in the Spine User Guide. */
|
||||
export class Event {
|
||||
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
*****************************************************************************/
|
||||
|
||||
import { Event } from "./Event.js";
|
||||
import type { SkeletonData } from "./SkeletonData.js";
|
||||
|
||||
/** Stores the setup pose values for an {@link Event}.
|
||||
*
|
||||
@ -35,7 +36,7 @@ import { Event } from "./Event.js";
|
||||
export class EventData {
|
||||
/** The name of the event, unique across all events in the skeleton.
|
||||
*
|
||||
* See {@link SkeletonData#findEvent(String)}. */
|
||||
* See {@link SkeletonData.findEvent}. */
|
||||
name: string;
|
||||
|
||||
_audioPath: string | null = null;
|
||||
|
||||
@ -48,7 +48,7 @@ export class IkConstraintData extends ConstraintData<IkConstraint, IkConstraintP
|
||||
else return this._target;
|
||||
}
|
||||
|
||||
/** When true and {@link IkConstraintPose#compress} or {@link IkConstraintPose#stretch} is used, the bone is scaled on both the
|
||||
/** When true and {@link IkConstraintPose.compress} or {@link IkConstraintPose.stretch} is used, the bone is scaled on both the
|
||||
* X and Y axes. */
|
||||
uniform = false;
|
||||
|
||||
|
||||
@ -38,8 +38,8 @@ export class IkConstraintPose implements Pose<IkConstraintPose> {
|
||||
compress = false;
|
||||
|
||||
/** When true and the target is out of range, the parent bone is scaled to reach it.
|
||||
* <p>
|
||||
* For two bone IK: 1) the child bone's local Y translation is set to 0, 2) stretch is not applied if {@link #softness} is > 0,
|
||||
*
|
||||
* For two bone IK: 1) the child bone's local Y translation is set to 0, 2) stretch is not applied if {@link softness} is > 0,
|
||||
* and 3) if the parent bone has local nonuniform scale, stretch is not applied. */
|
||||
stretch = false;
|
||||
|
||||
|
||||
@ -27,12 +27,13 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
import type { PhysicsConstraint } from "./PhysicsConstraint.js";
|
||||
/** Determines how physics and other non-deterministic updates are applied. */
|
||||
export enum Physics {
|
||||
/** Physics are not updated or applied. */
|
||||
none,
|
||||
|
||||
/** Physics are {@link PhysicsConstraint#reset() reset}. */
|
||||
/** Physics are {@link PhysicsConstraint.reset | reset}. */
|
||||
reset,
|
||||
|
||||
/** Physics are updated and the pose from physics is applied. */
|
||||
|
||||
@ -37,7 +37,7 @@ import { MathUtils } from "./Utils.js";
|
||||
|
||||
|
||||
/** Applies physics to a bone.
|
||||
* <p>
|
||||
*
|
||||
* See <a href="http://esotericsoftware.com/spine-physics-constraints">Physics constraints</a> in the Spine User Guide. */
|
||||
export class PhysicsConstraint extends Constraint<PhysicsConstraint, PhysicsConstraintData, PhysicsConstraintPose> {
|
||||
bone: BonePose;
|
||||
@ -97,7 +97,7 @@ export class PhysicsConstraint extends Constraint<PhysicsConstraint, PhysicsCons
|
||||
this.scaleVelocity = 0;
|
||||
}
|
||||
|
||||
/** Translates the physics constraint so the next {@link #update(Skeleton, Physics)} forces are applied as if the bone moved an
|
||||
/** Translates the physics constraint so the next {@link update} forces are applied as if the bone moved an
|
||||
* additional amount in world space. */
|
||||
translate (x: number, y: number) {
|
||||
this.ux -= x;
|
||||
@ -106,7 +106,7 @@ export class PhysicsConstraint extends Constraint<PhysicsConstraint, PhysicsCons
|
||||
this.cy -= y;
|
||||
}
|
||||
|
||||
/** Rotates the physics constraint so the next {@link #update(Skeleton, Physics)} forces are applied as if the bone rotated
|
||||
/** Rotates the physics constraint so the next {@link update} forces are applied as if the bone rotated
|
||||
* around the specified point in world space. */
|
||||
rotate (x: number, y: number, degrees: number) {
|
||||
const r = degrees * MathUtils.degRad, cos = Math.cos(r), sin = Math.sin(r);
|
||||
|
||||
@ -35,7 +35,7 @@ import type { Skeleton } from "./Skeleton.js";
|
||||
|
||||
|
||||
/** Stores the setup pose for a {@link PhysicsConstraint}.
|
||||
* <p>
|
||||
*
|
||||
* See <a href="http://esotericsoftware.com/spine-physics-constraints">Physics constraints</a> in the Spine User Guide. */
|
||||
export class PhysicsConstraintData extends ConstraintData<PhysicsConstraint, PhysicsConstraintPose> {
|
||||
/** The bone constrained by this physics constraint. */
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
*****************************************************************************/
|
||||
|
||||
import type { Pose } from "./Pose"
|
||||
import type { Skeleton } from "./Skeleton.js";
|
||||
|
||||
/** Stores a pose for a physics constraint. */
|
||||
export class PhysicsConstraintPose implements Pose<PhysicsConstraintPose> {
|
||||
@ -44,10 +45,10 @@ export class PhysicsConstraintPose implements Pose<PhysicsConstraintPose> {
|
||||
/** Determines susceptibility to acceleration. */
|
||||
massInverse = 0;
|
||||
|
||||
/** Applies a constant force along the {@link Skeleton#windX}, {@link Skeleton#windY} vector. */
|
||||
/** Applies a constant force along the {@link Skeleton.windX}, {@link Skeleton.windY} vector. */
|
||||
wind = 0;
|
||||
|
||||
/** Applies a constant force along the {@link Skeleton#gravityX}, {@link Skeleton#gravityY} vector. */
|
||||
/** Applies a constant force along the {@link Skeleton.gravityX}, {@link Skeleton.gravityY} vector. */
|
||||
gravity = 0;
|
||||
|
||||
/** A percentage (0+) that controls the mix between the constrained and unconstrained poses. */
|
||||
|
||||
@ -31,11 +31,9 @@ import type { Pose } from "./Pose.js";
|
||||
import type { PosedData } from "./PosedData.js";
|
||||
|
||||
/** The base class for an object with a number of poses:
|
||||
* <ul>
|
||||
* <li>{@link #data}: The setup pose.
|
||||
* <li>{@link #pose}: The unconstrained pose. Set by animations and application code.
|
||||
* <li>{@link #appliedPose}: The pose to use for rendering. Possibly modified by constraints.
|
||||
* </ul>
|
||||
* - {@link data}: The setup pose.
|
||||
* - {@link pose}: The unconstrained pose. Set by animations and application code.
|
||||
* - {@link appliedPose}: The pose to use for rendering. Possibly modified by constraints.
|
||||
*/
|
||||
export abstract class Posed<
|
||||
D extends PosedData<P>,
|
||||
@ -70,8 +68,8 @@ export abstract class Posed<
|
||||
return this.pose;
|
||||
}
|
||||
|
||||
/** The pose to use for rendering. If no constraints modify this pose, this is the same as {@link #pose}. Otherwise it is a
|
||||
* copy of {@link #pose} modified by constraints. */
|
||||
/** The pose to use for rendering. If no constraints modify this pose, this is the same as {@link pose}. Otherwise it is a
|
||||
* copy of {@link pose} modified by constraints. */
|
||||
public getAppliedPose (): P {
|
||||
return this.appliedPose;
|
||||
}
|
||||
|
||||
@ -32,6 +32,7 @@ import { Posed } from "./Posed.js";
|
||||
import type { PosedData } from "./PosedData.js";
|
||||
|
||||
import type { Skeleton } from "./Skeleton";
|
||||
import type { Skin } from "./Skin.js";
|
||||
|
||||
/** A posed object that may be active or inactive. */
|
||||
export abstract class PosedActive<
|
||||
@ -47,9 +48,9 @@ export abstract class PosedActive<
|
||||
}
|
||||
|
||||
/** Returns false when this constraint won't be updated by
|
||||
* {@link Skeleton#updateWorldTransform(com.esotericsoftware.spine.Physics)} because a skin is required and the
|
||||
* {@link Skeleton#skin active skin} does not contain this item. See {@link Skin#bones}, {@link Skin#constraints},
|
||||
* {@link PosedData#skinRequired}, and {@link Skeleton#updateCache()}. */
|
||||
* {@link Skeleton.updateWorldTransform} because a skin is required and the
|
||||
* {@link Skeleton.skin active skin} does not contain this item. See {@link Skin.bones}, {@link Skin.constraints},
|
||||
* {@link PosedData.skinRequired}, and {@link Skeleton.updateCache}. */
|
||||
public isActive (): boolean {
|
||||
return this.active;
|
||||
}
|
||||
|
||||
@ -28,6 +28,8 @@
|
||||
*****************************************************************************/
|
||||
|
||||
import type { Pose } from "./Pose.js";
|
||||
import type { Skeleton } from "./Skeleton.js";
|
||||
import type { Skin } from "./Skin.js";
|
||||
|
||||
/** The base class for storing setup data for a posed object. May be shared with multiple instances. */
|
||||
export abstract class PosedData<P extends Pose<P>> {
|
||||
@ -35,10 +37,10 @@ export abstract class PosedData<P extends Pose<P>> {
|
||||
|
||||
readonly setupPose: P;
|
||||
|
||||
/** When true, {@link Skeleton#updateWorldTransform(Physics)} only updates this constraint if the {@link Skeleton#skin}
|
||||
/** When true, {@link Skeleton.updateWorldTransform} only updates this constraint if the {@link Skeleton.skin}
|
||||
* contains this constraint.
|
||||
* <p>
|
||||
* See {@link Skin#constraints}. */
|
||||
*
|
||||
* See {@link Skin.constraints}. */
|
||||
skinRequired = false;
|
||||
|
||||
constructor (name: string, setupPose: P) {
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
import type { AnimationState } from "./AnimationState.js";
|
||||
import type { Attachment } from "./attachments/Attachment.js";
|
||||
import { ClippingAttachment } from "./attachments/ClippingAttachment.js";
|
||||
import { MeshAttachment } from "./attachments/MeshAttachment.js";
|
||||
@ -35,6 +36,7 @@ import { Bone } from "./Bone.js";
|
||||
import type { Constraint } from "./Constraint.js";
|
||||
import { DrawOrder } from "./DrawOrder.js";
|
||||
import type { Physics } from "./Physics.js";
|
||||
import type { PhysicsConstraintPose } from "./PhysicsConstraintPose.js";
|
||||
import { PhysicsConstraint } from "./PhysicsConstraint.js";
|
||||
import type { Posed } from "./Posed.js";
|
||||
import type { SkeletonClipping } from "./SkeletonClipping.js";
|
||||
@ -46,7 +48,7 @@ import { Color, type NumberArrayLike, Utils, Vector2 } from "./Utils.js";
|
||||
/** Stores bones and slots to be posed by animations and application code. Multiple skeleton instances can share the same
|
||||
* {@link SkeletonData}, including animations, attachments, and skins.
|
||||
*
|
||||
* After posing, call {@link #updateWorldTransform(Physics)} to apply constraints and compute world transforms for rendering.
|
||||
* After posing, call {@link updateWorldTransform} to apply constraints and compute world transforms for rendering.
|
||||
*
|
||||
* See [Instance objects](http://esotericsoftware.com/spine-runtime-architecture#Instance-objects) in the Spine Runtimes Guide. */
|
||||
export class Skeleton {
|
||||
@ -62,10 +64,10 @@ export class Skeleton {
|
||||
/** The skeleton's bones, sorted parent first. The root bone is always the first bone. */
|
||||
readonly bones: Array<Bone>;
|
||||
|
||||
/** The skeleton's slots. To add a slot, also add it to {@link DrawOrder#pose}. */
|
||||
/** The skeleton's slots. To add a slot, also add it to {@link DrawOrder.pose}. */
|
||||
readonly slots: Array<Slot>;
|
||||
|
||||
/** The skeleton's draw order. Use {@link DrawOrder#appliedPose} for rendering and {@link DrawOrder#pose} for changing the draw
|
||||
/** The skeleton's draw order. Use {@link DrawOrder.appliedPose} for rendering and {@link DrawOrder.pose} for changing the draw
|
||||
* order. */
|
||||
readonly drawOrder: DrawOrder;
|
||||
|
||||
@ -76,7 +78,7 @@ export class Skeleton {
|
||||
/** The skeleton's physics constraints. */
|
||||
readonly physics: Array<PhysicsConstraint>;
|
||||
|
||||
/** The list of bones and constraints, sorted in the order they should be updated, as computed by {@link updateCache()}. */
|
||||
/** The list of bones and constraints, sorted in the order they should be updated, as computed by {@link updateCache}. */
|
||||
// biome-ignore lint/suspicious/noExplicitAny: reference runtime does not restrict to specific types
|
||||
readonly _updateCache = [] as any[];
|
||||
|
||||
@ -119,19 +121,19 @@ export class Skeleton {
|
||||
|
||||
/** Returns the skeleton's time, is used for time-based manipulations, such as {@link PhysicsConstraint}.
|
||||
*
|
||||
* See {@link _update()}. */
|
||||
* See {@link _update}. */
|
||||
time = 0;
|
||||
|
||||
/** The x component of a vector that defines the direction {@link PhysicsConstraintPose#wind} is applied. */
|
||||
/** The x component of a vector that defines the direction {@link PhysicsConstraintPose.wind} is applied. */
|
||||
windX = 1;
|
||||
|
||||
/** The y component of a vector that defines the direction {@link PhysicsConstraintPose#wind} is applied. */
|
||||
/** The y component of a vector that defines the direction {@link PhysicsConstraintPose.wind} is applied. */
|
||||
windY = 0;
|
||||
|
||||
/** The x component of a vector that defines the direction {@link PhysicsConstraintPose#gravity} is applied. */
|
||||
/** The x component of a vector that defines the direction {@link PhysicsConstraintPose.gravity} is applied. */
|
||||
gravityX = 0;
|
||||
|
||||
/** The y component of a vector that defines the direction {@link PhysicsConstraintPose#gravity} is applied. */
|
||||
/** The y component of a vector that defines the direction {@link PhysicsConstraintPose.gravity} is applied. */
|
||||
gravityY = 1;
|
||||
|
||||
_update = 0;
|
||||
@ -173,7 +175,7 @@ export class Skeleton {
|
||||
this.updateCache();
|
||||
}
|
||||
|
||||
/** Caches information about bones and constraints. Must be called if the {@link #skin} is modified or if bones, constraints,
|
||||
/** Caches information about bones and constraints. Must be called if the {@link skin} is modified or if bones, constraints,
|
||||
* or weighted path attachments are added or removed. */
|
||||
updateCache () {
|
||||
this._updateCache.length = 0;
|
||||
@ -254,7 +256,7 @@ export class Skeleton {
|
||||
}
|
||||
|
||||
/** Updates the world transform for each bone and applies all constraints.
|
||||
* <p>
|
||||
*
|
||||
* See <a href="https://esotericsoftware.com/spine-runtime-skeletons#World-transforms">World transforms</a> in the Spine
|
||||
* Runtimes Guide. */
|
||||
updateWorldTransform (physics: Physics): void {
|
||||
@ -323,17 +325,17 @@ export class Skeleton {
|
||||
|
||||
/** Sets a skin by name.
|
||||
*
|
||||
* See {@link setSkin()}. */
|
||||
* See {@link setSkin}. */
|
||||
setSkin (skinName: string): void;
|
||||
|
||||
/** Sets the skin used to look up attachments before looking in {@link SkeletonData#defaultSkin}. If the skin is changed,
|
||||
* {@link #updateCache()} is called.
|
||||
* <p>
|
||||
/** Sets the skin used to look up attachments before looking in {@link SkeletonData.defaultSkin}. If the skin is changed,
|
||||
* {@link updateCache} is called.
|
||||
*
|
||||
* Attachments from the new skin are attached if the corresponding attachment from the old skin was attached. If there was no
|
||||
* old skin, each slot's setup mode attachment is attached from the new skin.
|
||||
* <p>
|
||||
*
|
||||
* After changing the skin, the visible attachments can be reset to those attached in the setup pose by calling
|
||||
* {@link #setupPoseSlots()}. Also, often {@link AnimationState#apply(Skeleton)} is called before the next time the skeleton is
|
||||
* {@link setupPoseSlots}. Also, often {@link AnimationState.apply} is called before the next time the skeleton is
|
||||
* rendered to allow any attachment keys in the current animation(s) to hide or show attachments from the new skin. */
|
||||
setSkin (newSkin: Skin | null): void;
|
||||
|
||||
@ -374,7 +376,7 @@ export class Skeleton {
|
||||
/** Finds an attachment by looking in the {@link skin} and {@link SkeletonData.defaultSkin} using the slot name and attachment
|
||||
* name.
|
||||
*
|
||||
* See {@link getAttachment(number, string)}. */
|
||||
* See {@link getAttachment}. */
|
||||
getAttachment (slotName: string, placeholderName: string): Attachment | null;
|
||||
|
||||
/** Finds an attachment by looking in the {@link skin} and {@link SkeletonData.defaultSkin} using the slot index and
|
||||
@ -389,10 +391,10 @@ export class Skeleton {
|
||||
return this.getAttachmentByIndex(slotNameOrIndex, placeholderName);
|
||||
}
|
||||
|
||||
/** Finds an attachment by looking in the {@link #skin} and {@link SkeletonData#defaultSkin} using the slot name and attachment
|
||||
/** Finds an attachment by looking in the {@link skin} and {@link SkeletonData.defaultSkin} using the slot name and attachment
|
||||
* name.
|
||||
*
|
||||
* See {@link #getAttachment()}.
|
||||
* See {@link getAttachment}.
|
||||
* @returns May be null. */
|
||||
private getAttachmentByName (slotName: string, placeholderName: string): Attachment | null {
|
||||
const slot = this.data.findSlot(slotName);
|
||||
@ -400,7 +402,7 @@ export class Skeleton {
|
||||
return this.getAttachment(slot.index, placeholderName);
|
||||
}
|
||||
|
||||
/** Finds an attachment by looking in the {@link #skin} and {@link SkeletonData#defaultSkin} using the slot index and
|
||||
/** Finds an attachment by looking in the {@link skin} and {@link SkeletonData.defaultSkin} using the slot index and
|
||||
* attachment name. First the skin is checked and if the attachment was not found, the default skin is checked.
|
||||
*
|
||||
* See [Runtime skins](http://esotericsoftware.com/spine-runtime-skins) in the Spine Runtimes Guide.
|
||||
@ -415,8 +417,8 @@ export class Skeleton {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** A convenience method to set an attachment by finding the slot with {@link findSlot()}, finding the attachment with
|
||||
* {@link getAttachment()}, then setting the slot's {@link Slot.attachment}.
|
||||
/** A convenience method to set an attachment by finding the slot with {@link findSlot}, finding the attachment with
|
||||
* {@link getAttachment}, then setting the slot's {@link Slot.attachment}.
|
||||
* @param attachmentName May be null to clear the slot's attachment. */
|
||||
setAttachment (slotName: string, attachmentName: string | null) {
|
||||
if (!slotName) throw new Error("slotName cannot be null.");
|
||||
@ -461,7 +463,7 @@ export class Skeleton {
|
||||
* @param offset An output value, the distance from the skeleton origin to the bottom left corner of the AABB.
|
||||
* @param size An output value, the width and height of the AABB.
|
||||
* @param temp Working memory to temporarily store attachments' computed world vertices.
|
||||
* @param clipper {@link SkeletonClipping} to use. If <code>null</code>, no clipping is applied. */
|
||||
* @param clipper {@link SkeletonClipping} to use. If `null`, no clipping is applied. */
|
||||
getBounds (offset: Vector2, size: Vector2, temp: Array<number> = new Array<number>(2), clipper: SkeletonClipping | null = null) {
|
||||
if (!offset) throw new Error("offset cannot be null.");
|
||||
if (!size) throw new Error("size cannot be null.");
|
||||
@ -528,7 +530,7 @@ export class Skeleton {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
/** Increments the skeleton's {@link #time}. */
|
||||
/** Increments the skeleton's {@link time}. */
|
||||
update (delta: number) {
|
||||
this.time += delta;
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ export class SkeletonBounds {
|
||||
}
|
||||
|
||||
/** Returns the first bounding box attachment that contains the point, or null. When doing many checks, it is usually more
|
||||
* efficient to only call this method if {@link #aabbContainsPoint(float, float)} returns true. */
|
||||
* efficient to only call this method if {@link aabbContainsPoint} returns true. */
|
||||
containsPoint (x: number, y: number): BoundingBoxAttachment | null {
|
||||
const polygons = this.polygons;
|
||||
for (let i = 0, n = polygons.length; i < n; i++)
|
||||
@ -179,7 +179,7 @@ export class SkeletonBounds {
|
||||
}
|
||||
|
||||
/** Returns the first bounding box attachment that contains any part of the line segment, or null. When doing many checks, it
|
||||
* is usually more efficient to only call this method if {@link #aabbIntersectsSegment()} returns
|
||||
* is usually more efficient to only call this method if {@link aabbIntersectsSegment} returns
|
||||
* true. */
|
||||
intersectsSegment (x1: number, y1: number, x2: number, y2: number) {
|
||||
const polygons = this.polygons;
|
||||
|
||||
@ -27,7 +27,8 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
import type { Animation } from "./Animation.js"
|
||||
import type { Animation } from "./Animation.js";
|
||||
import type { Skeleton } from "./Skeleton.js";
|
||||
import type { BoneData } from "./BoneData.js";
|
||||
import type { ConstraintData } from "./ConstraintData.js";
|
||||
import type { EventData } from "./EventData.js";
|
||||
@ -54,7 +55,7 @@ export class SkeletonData {
|
||||
|
||||
/** The skeleton's default skin. By default this skin contains all attachments that were not in a skin in Spine.
|
||||
*
|
||||
* See {@link Skeleton#getAttachmentByName()}.
|
||||
* See {@link Skeleton.getAttachmentByName}.
|
||||
* May be null. */
|
||||
defaultSkin: Skin | null = null;
|
||||
|
||||
@ -145,7 +146,7 @@ export class SkeletonData {
|
||||
}
|
||||
|
||||
/** Collects animations used by {@link SliderData slider constraints}.
|
||||
* <p>
|
||||
*
|
||||
* Slider animations are designed to be applied by slider constraints rather than on their own. Applications that have a user
|
||||
* choose an animation may want to exclude them. */
|
||||
findSliderAnimations (animations: Animation[]): Animation[] {
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
*****************************************************************************/
|
||||
|
||||
import type { Attachment } from "./attachments/Attachment.js";
|
||||
import type { SkeletonData } from "./SkeletonData.js";
|
||||
import { MeshAttachment } from "./attachments/MeshAttachment.js";
|
||||
import type { BoneData } from "./BoneData.js";
|
||||
import type { ConstraintData } from "./ConstraintData.js";
|
||||
@ -37,7 +38,7 @@ import { Color, type StringMap } from "./Utils.js";
|
||||
/** Stores an entry in the skin consisting of the slot index, name, and attachment **/
|
||||
export class SkinEntry {
|
||||
|
||||
/** The {@link Skeleton#slots} index. */
|
||||
/** The {@link Skeleton.slots} index. */
|
||||
slotIndex: number = 0;
|
||||
|
||||
placeholderName: string;
|
||||
@ -54,12 +55,12 @@ export class SkinEntry {
|
||||
|
||||
/** Stores attachments by slot index and placeholder name. Multiple {@link Skeleton} instances can use the same skins.
|
||||
*
|
||||
* See {@link SkeletonData#defaultSkin}, {@link Skeleton#skin}, and
|
||||
* See {@link SkeletonData.defaultSkin}, {@link Skeleton.skin}, and
|
||||
* [Runtime skins](http://esotericsoftware.com/spine-runtime-skins) in the Spine Runtimes Guide. */
|
||||
export class Skin {
|
||||
/** The skin's name, unique across all skins in the skeleton.
|
||||
* <p>
|
||||
* See {@link SkeletonData#findSkin(String)}. */
|
||||
*
|
||||
* See {@link SkeletonData.findSkin}. */
|
||||
name: string;
|
||||
|
||||
attachments = [] as StringMap<Attachment>[];
|
||||
|
||||
@ -35,13 +35,13 @@ import type { Skeleton } from "./Skeleton.js";
|
||||
import type { SliderData } from "./SliderData.js";
|
||||
import { SliderPose } from "./SliderPose.js";
|
||||
|
||||
/** Applies an animation based on either the slider's {@link SliderPose#time} or a bone's transform property.
|
||||
* <p>
|
||||
/** Applies an animation based on either the slider's {@link SliderPose.time} or a bone's transform property.
|
||||
*
|
||||
* See <a href="https://esotericsoftware.com/spine-sliders">Sliders</a> in the Spine User Guide. */
|
||||
export class Slider extends Constraint<Slider, SliderData, SliderPose> {
|
||||
private static readonly offsets = [0, 0, 0, 0, 0, 0];
|
||||
|
||||
/** When set, the bone's transform property is used to set the slider's {@link SliderPose#time}. */
|
||||
/** When set, the bone's transform property is used to set the slider's {@link SliderPose.time}. */
|
||||
bone: Bone | null = null;
|
||||
|
||||
constructor (data: SliderData, skeleton: Skeleton) {
|
||||
|
||||
@ -35,7 +35,7 @@ import { Slider } from "./Slider.js";
|
||||
import { SliderPose } from "./SliderPose.js";
|
||||
import type { FromProperty } from "./TransformConstraintData.js";
|
||||
|
||||
/** Stores the setup pose for a {@link SliderConstraint}.
|
||||
/** Stores the setup pose for a {@link Slider}.
|
||||
*
|
||||
* See <a href="https://esotericsoftware.com/spine-slider-constraints">Slider constraints</a> in the Spine User Guide. */
|
||||
export class SliderData extends ConstraintData<Slider, SliderPose> {
|
||||
@ -49,13 +49,13 @@ export class SliderData extends ConstraintData<Slider, SliderPose> {
|
||||
/** When true, the animation repeats after its duration, otherwise the last frame is used. */
|
||||
loop = false;
|
||||
|
||||
/** When set, the bone's transform property is used to set the slider's {@link SliderPose#time}. */
|
||||
/** When set, the bone's transform property is used to set the slider's {@link SliderPose.time}. */
|
||||
bone: BoneData | null = null;
|
||||
|
||||
/** When a bone is set, the specified transform property is used to set the slider's {@link SliderPose#time}. */
|
||||
/** When a bone is set, the specified transform property is used to set the slider's {@link SliderPose.time}. */
|
||||
property!: FromProperty;
|
||||
|
||||
/** When a bone is set, this is the scale of the {@link #property} value in relation to the slider time. */
|
||||
/** When a bone is set, this is the scale of the {@link property} value in relation to the slider time. */
|
||||
scale = 0;
|
||||
|
||||
/** When a bone is set, the offset is added to the property. */
|
||||
|
||||
@ -28,11 +28,12 @@
|
||||
*****************************************************************************/
|
||||
|
||||
import type { Pose } from "./Pose.js";
|
||||
import type { SliderData } from "./SliderData.js";
|
||||
|
||||
/** Stores a pose for a slider. */
|
||||
export class SliderPose implements Pose<SliderPose> {
|
||||
|
||||
/** The time in the {@link SliderData#animation} to apply the animation. */
|
||||
/** The time in the {@link SliderData.animation} to apply the animation. */
|
||||
time = 0;
|
||||
|
||||
/** A percentage that controls the mix between the constrained and unconstrained poses. */
|
||||
|
||||
@ -34,8 +34,8 @@ import type { SlotData } from "./SlotData.js";
|
||||
import { SlotPose } from "./SlotPose.js";
|
||||
import { Color } from "./Utils.js";
|
||||
|
||||
/** Organizes attachments for {@link Skeleton#drawOrder} purposes and provide a place to store state for an attachment.
|
||||
* <p>
|
||||
/** Organizes attachments for {@link Skeleton.drawOrder} purposes and provide a place to store state for an attachment.
|
||||
*
|
||||
* State cannot be stored in an attachment itself because attachments are stateless and may be shared across multiple
|
||||
* skeletons. */
|
||||
export class Slot extends Posed<SlotData, SlotPose> {
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
*****************************************************************************/
|
||||
|
||||
import type { BoneData } from "./BoneData.js";
|
||||
import type { Slot } from "./Slot.js";
|
||||
import { PosedData } from "./PosedData.js";
|
||||
import type { Skeleton } from "./Skeleton.js";
|
||||
import { SlotPose } from "./SlotPose.js";
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
import type { DeformTimeline } from "./Animation.js";
|
||||
import type { Attachment } from "./attachments/Attachment.js";
|
||||
import { VertexAttachment } from "./attachments/Attachment.js";
|
||||
import type { Sequence } from "./attachments/Sequence.js";
|
||||
@ -35,7 +36,7 @@ import { Color } from "./Utils.js";
|
||||
|
||||
/** Stores a slot's pose. */
|
||||
export class SlotPose implements Pose<SlotPose> {
|
||||
/** The color used to tint the slot's attachment. If {@link #darkColor} is set, this is used as the light color for two color
|
||||
/** The color used to tint the slot's attachment. If {@link darkColor} is set, this is used as the light color for two color
|
||||
* tinting. */
|
||||
readonly color = new Color(1, 1, 1, 1);
|
||||
|
||||
@ -47,13 +48,13 @@ export class SlotPose implements Pose<SlotPose> {
|
||||
attachment: Attachment | null = null; // Not used in setup pose.
|
||||
|
||||
/** The index of the texture region to display when the slot's attachment has a {@link Sequence}. -1 represents the
|
||||
* {@link Sequence.getSetupIndex()}. */
|
||||
* {@link Sequence.getSetupIndex}. */
|
||||
sequenceIndex = 0;
|
||||
|
||||
/** Values to deform the slot's attachment. For an unweighted mesh, the entries are local positions for each vertex. For a
|
||||
* weighted mesh, the entries are an offset for each vertex which will be added to the mesh's local vertex positions.
|
||||
*
|
||||
* See {@link VertexAttachment.computeWorldVertices()} and
|
||||
* See {@link VertexAttachment.computeWorldVertices} and
|
||||
* {@link DeformTimeline}. */
|
||||
readonly deform = [] as number[];
|
||||
|
||||
@ -75,8 +76,8 @@ export class SlotPose implements Pose<SlotPose> {
|
||||
return this.attachment;
|
||||
}
|
||||
|
||||
/** Sets the slot's attachment and, if the attachment changed, resets {@link #sequenceIndex} and clears the {@link #deform}.
|
||||
* The deform is not cleared if the old attachment has the same {@link VertexAttachment.getTimelineAttachment()} as the
|
||||
/** Sets the slot's attachment and, if the attachment changed, resets {@link sequenceIndex} and clears the {@link deform}.
|
||||
* The deform is not cleared if the old attachment has the same {@link VertexAttachment.getTimelineAttachment} as the
|
||||
* specified attachment. */
|
||||
setAttachment (attachment: Attachment | null): void {
|
||||
if (this.attachment === attachment) return;
|
||||
|
||||
@ -146,7 +146,7 @@ export class TransformConstraintData extends ConstraintData<TransformConstraint,
|
||||
|
||||
/** Source property for a {@link TransformConstraint}. */
|
||||
export abstract class FromProperty {
|
||||
/** The value of this property that corresponds to {@link ToProperty#offset}. */
|
||||
/** The value of this property that corresponds to {@link ToProperty.offset}. */
|
||||
offset = 0;
|
||||
|
||||
/** Constrained properties. */
|
||||
@ -158,10 +158,10 @@ export abstract class FromProperty {
|
||||
|
||||
/** Constrained property for a {@link TransformConstraint}. */
|
||||
export abstract class ToProperty {
|
||||
/** The value of this property that corresponds to {@link FromProperty#offset}. */
|
||||
/** The value of this property that corresponds to {@link FromProperty.offset}. */
|
||||
offset = 0;
|
||||
|
||||
/** The maximum value of this property when {@link TransformConstraintData#clamp clamped}. */
|
||||
/** The maximum value of this property when {@link TransformConstraintData.clamp clamped}. */
|
||||
max = 0;
|
||||
|
||||
/** The scale of the {@link FromProperty} value in relation to this property. */
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
import type { Physics } from "./Physics.js";
|
||||
import type { Skeleton } from "./Skeleton.js";
|
||||
|
||||
/** The interface for items updated by {@link Skeleton#updateWorldTransform()}. */
|
||||
/** The interface for items updated by {@link Skeleton.updateWorldTransform}. */
|
||||
export interface Update {
|
||||
/** @param physics Determines how physics and other non-deterministic updates are applied. */
|
||||
update (skeleton: Skeleton, physics: Physics): void;
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
|
||||
import type { Skeleton } from "src/Skeleton.js";
|
||||
import type { Slot } from "../Slot.js";
|
||||
import type { SlotPose } from "../SlotPose.js";
|
||||
import { type NumberArrayLike, Utils } from "../Utils.js";
|
||||
|
||||
/** The base class for all attachments. Multiple {@link Skeleton} instances, slots, or skins can use the same attachments. */
|
||||
@ -56,8 +57,8 @@ export abstract class VertexAttachment extends Attachment {
|
||||
/** The unique ID for this attachment. */
|
||||
id = VertexAttachment.nextID++;
|
||||
|
||||
/** The bones that affect the {@link #vertices}. The entries are, for each vertex, the number of bones affecting the vertex
|
||||
* followed by that many bone indices, which is {@link Skeleton#getBones()} index. Null if this attachment has no weights. */
|
||||
/** The bones that affect the {@link vertices}. The entries are, for each vertex, the number of bones affecting the vertex
|
||||
* followed by that many bone indices, which is {@link Skeleton.getBones} index. Null if this attachment has no weights. */
|
||||
bones: Array<number> | null = null;
|
||||
|
||||
/** The vertex positions in the bone's coordinate system. For a non-weighted attachment, the values are `x,y`
|
||||
@ -73,17 +74,17 @@ export abstract class VertexAttachment extends Attachment {
|
||||
super(name);
|
||||
}
|
||||
|
||||
/** Transforms the attachment's local {@link #vertices} to world coordinates. If {@link SlotPose#getDeform()} is not empty, it
|
||||
/** Transforms the attachment's local {@link vertices} to world coordinates. If {@link SlotPose.getDeform} is not empty, it
|
||||
* is used to deform the vertices.
|
||||
* <p>
|
||||
*
|
||||
* See <a href="https://esotericsoftware.com/spine-runtime-skeletons#World-transforms">World transforms</a> in the Spine
|
||||
* Runtimes Guide.
|
||||
* @param start The index of the first {@link #vertices} value to transform. Each vertex has 2 values, x and y.
|
||||
* @param count The number of world vertex values to output. Must be <= {@link #worldVerticesLength} - <code>start</code>.
|
||||
* @param worldVertices The output world vertices. Must have a length >= <code>offset</code> + <code>count</code> *
|
||||
* <code>stride</code> / 2.
|
||||
* @param offset The <code>worldVertices</code> index to begin writing values.
|
||||
* @param stride The number of <code>worldVertices</code> entries between the value pairs written. */
|
||||
* @param start The index of the first {@link vertices} value to transform. Each vertex has 2 values, x and y.
|
||||
* @param count The number of world vertex values to output. Must be <= {@link worldVerticesLength} - `start`.
|
||||
* @param worldVertices The output world vertices. Must have a length >= `offset` + `count` *
|
||||
* `stride` / 2.
|
||||
* @param offset The `worldVertices` index to begin writing values.
|
||||
* @param stride The number of `worldVertices` entries between the value pairs written. */
|
||||
computeWorldVertices (skeleton: Skeleton, slot: Slot, start: number, count: number, worldVertices: NumberArrayLike, offset: number,
|
||||
stride: number) {
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
import type { SkeletonBounds } from "../SkeletonBounds.js";
|
||||
import { Color } from "../Utils.js";
|
||||
import { type Attachment, VertexAttachment } from "./Attachment.js";
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
import type { SlotPose } from "../SlotPose.js";
|
||||
import type { Color } from "../Utils.js"
|
||||
import type { Sequence } from "./Sequence.js"
|
||||
|
||||
@ -39,10 +40,10 @@ export interface HasSequence {
|
||||
/** The base path for the attachment's texture region. */
|
||||
path?: string;
|
||||
|
||||
/** The color the attachment is tinted, to be combined with {@link SlotPose#getColor()}. */
|
||||
/** The color the attachment is tinted, to be combined with {@link SlotPose.getColor}. */
|
||||
color: Color;
|
||||
|
||||
/** Calls {@link Sequence#update(HasSequence)} on this attachment's sequence. */
|
||||
/** Calls {@link Sequence.update} on this attachment's sequence. */
|
||||
updateSequence (): void;
|
||||
|
||||
/** The sequence that provides texture regions, UVs, and vertex offsets for rendering this attachment. */
|
||||
|
||||
@ -47,7 +47,7 @@ export class MeshAttachment extends VertexAttachment implements HasSequence {
|
||||
/** Triplets of vertex indices which describe the mesh's triangulation. */
|
||||
triangles: Array<number> = [];
|
||||
|
||||
/** The number of entries at the beginning of {@link #vertices} that make up the mesh hull. */
|
||||
/** The number of entries at the beginning of {@link vertices} that make up the mesh hull. */
|
||||
hullLength: number = 0;
|
||||
|
||||
/** The name of the texture region for this attachment. */
|
||||
@ -104,9 +104,9 @@ export class MeshAttachment extends VertexAttachment implements HasSequence {
|
||||
this.sequence.update(this);
|
||||
}
|
||||
|
||||
/** The parent mesh if this is a linked mesh, else null. A linked mesh shares the {@link #bones}, {@link #vertices},
|
||||
* {@link #regionUVs}, {@link #triangles}, {@link #hullLength}, {@link #edges}, {@link #width}, and {@link #height} with the
|
||||
* parent mesh, but may have a different {@link #name} or {@link #path}, and therefore a different texture region. */
|
||||
/** The parent mesh if this is a linked mesh, else null. A linked mesh shares the {@link bones}, {@link vertices},
|
||||
* {@link regionUVs}, {@link triangles}, {@link hullLength}, {@link edges}, {@link width}, and {@link height} with the
|
||||
* parent mesh, but may have a different {@link name} or {@link path}, and therefore a different texture region. */
|
||||
getParentMesh () {
|
||||
return this.parentMesh;
|
||||
}
|
||||
@ -125,7 +125,7 @@ export class MeshAttachment extends VertexAttachment implements HasSequence {
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns a new mesh with the {@link #parentMesh} set to this mesh's parent mesh, if any, else to this mesh. **/
|
||||
/** Returns a new mesh with the {@link parentMesh} set to this mesh's parent mesh, if any, else to this mesh. **/
|
||||
newLinkedMesh (): MeshAttachment {
|
||||
const copy = new MeshAttachment(this.name, this.sequence.copy());
|
||||
copy.timelineAttachment = this.timelineAttachment;
|
||||
@ -136,7 +136,7 @@ export class MeshAttachment extends VertexAttachment implements HasSequence {
|
||||
return copy;
|
||||
}
|
||||
|
||||
/** Computes {@link Sequence#getUVs(int) UVs} for a mesh attachment.
|
||||
/** Computes {@link Sequence.getUVs | UVs} for a mesh attachment.
|
||||
* @param uvs Output array for the computed UVs, same length as regionUVs. */
|
||||
static computeUVs (region: TextureRegion | null, regionUVs: NumberArrayLike, uvs: NumberArrayLike): void {
|
||||
if (!region) throw new Error("Region not set.");
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
import type { PathConstraint } from "../PathConstraint.js";
|
||||
import { Color, Utils } from "../Utils.js";
|
||||
import { type Attachment, VertexAttachment } from "./Attachment.js";
|
||||
|
||||
|
||||
@ -90,12 +90,12 @@ export class RegionAttachment extends Attachment implements HasSequence {
|
||||
}
|
||||
|
||||
/** Transforms the attachment's four vertices to world coordinates.
|
||||
* <p>
|
||||
*
|
||||
* See <a href="http://esotericsoftware.com/spine-runtime-skeletons#World-transforms">World transforms</a> in the Spine
|
||||
* Runtimes Guide.
|
||||
* @param worldVertices The output world vertices. Must have a length >= <code>offset</code> + 8.
|
||||
* @param offset The <code>worldVertices</code> index to begin writing values.
|
||||
* @param stride The number of <code>worldVertices</code> entries between the value pairs written. */
|
||||
* @param worldVertices The output world vertices. Must have a length >= `offset` + 8.
|
||||
* @param offset The `worldVertices` index to begin writing values.
|
||||
* @param stride The number of `worldVertices` entries between the value pairs written. */
|
||||
computeWorldVertices (slot: Slot, vertexOffsets: NumberArrayLike, worldVertices: NumberArrayLike, offset: number, stride: number) {
|
||||
|
||||
const bone = slot.bone.appliedPose;
|
||||
@ -135,7 +135,7 @@ export class RegionAttachment extends Attachment implements HasSequence {
|
||||
this.sequence.update(this);
|
||||
}
|
||||
|
||||
/** Computes {@link Sequence#getUVs(int) UVs} and {@link Sequence#getOffsets(int) offsets} for a region attachment.
|
||||
/** Computes {@link Sequence.getUVs | UVs} and {@link Sequence.getOffsets | offsets} for a region attachment.
|
||||
* @param uvs Output array for the computed UVs, length of 8.
|
||||
* @param offset Output array for the computed vertex offsets, length of 8. */
|
||||
static computeUVs (region: TextureRegion | null, x: number, y: number, scaleX: number, scaleY: number, rotation: number, width: number,
|
||||
|
||||
@ -34,8 +34,8 @@ import type { HasSequence } from "./HasSequence.js";
|
||||
import { MeshAttachment } from "./MeshAttachment.js";
|
||||
import { RegionAttachment } from "./RegionAttachment.js";
|
||||
|
||||
/** Holds texture regions, UVs, and vertex offsets for rendering a region or mesh attachment. {@link #regions Regions} must be
|
||||
* populated and {@link #update(HasSequence)} called before use. */
|
||||
/** Holds texture regions, UVs, and vertex offsets for rendering a region or mesh attachment. {@link regions Regions} must be
|
||||
* populated and {@link update} called before use. */
|
||||
export class Sequence {
|
||||
private static _nextID = 0;
|
||||
|
||||
@ -50,10 +50,10 @@ export class Sequence {
|
||||
/** Returns vertex offsets from the center of a {@link RegionAttachment}. Invalid to call for a {@link MeshAttachment}. */
|
||||
offsets?: number[][];
|
||||
|
||||
/** The starting number for the numeric {@link #getPath(String, int) path} suffix. */
|
||||
/** The starting number for the numeric {@link getPath | path} suffix. */
|
||||
start = 0;
|
||||
|
||||
/** The minimum number of digits in the numeric {@link #getPath(String, int) path} suffix, for zero padding. 0 for no zero
|
||||
/** The minimum number of digits in the numeric {@link getPath | path} suffix, for zero padding. 0 for no zero
|
||||
* padding. */
|
||||
digits = 0;
|
||||
|
||||
@ -61,8 +61,8 @@ export class Sequence {
|
||||
setupIndex = 0;
|
||||
|
||||
/** @param count The number of texture regions this sequence will display.
|
||||
* @param pathSuffix If true, the {@link #getPath(String, int) path} has a numeric suffix. If false, all regions will use the
|
||||
* same path, so <code>count</code> should be 1. */
|
||||
* @param pathSuffix If true, the {@link getPath | path} has a numeric suffix. If false, all regions will use the
|
||||
* same path, so `count` should be 1. */
|
||||
constructor (count: number, pathSuffix: boolean) {
|
||||
this.regions = new Array<TextureRegion>(count);
|
||||
this.pathSuffix = pathSuffix;
|
||||
@ -119,7 +119,7 @@ export class Sequence {
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns the {@link #regions} index for the {@link SlotPose#getSequenceIndex()}. */
|
||||
/** Returns the {@link regions} index for the {@link SlotPose.getSequenceIndex}. */
|
||||
resolveIndex (pose: SlotPose): number {
|
||||
let index = pose.sequenceIndex;
|
||||
if (index === -1) index = this.setupIndex;
|
||||
@ -127,14 +127,14 @@ export class Sequence {
|
||||
return index;
|
||||
}
|
||||
|
||||
/** Returns the UVs for the specified index. {@link #regions Regions} must be populated and {@link #update(HasSequence)} called
|
||||
/** Returns the UVs for the specified index. {@link regions Regions} must be populated and {@link update} called
|
||||
* before calling this method. */
|
||||
getUVs (index: number): Float32Array {
|
||||
// biome-ignore lint/style/noNonNullAssertion: uvs are always defined after updateSequence
|
||||
return this.uvs![index] as Float32Array;
|
||||
}
|
||||
|
||||
/** Returns true if the {@link #getPath(String, int) path} has a numeric suffix. */
|
||||
/** Returns true if the {@link getPath | path} has a numeric suffix. */
|
||||
hasPathSuffix (): boolean {
|
||||
return this.pathSuffix;
|
||||
}
|
||||
@ -155,7 +155,7 @@ export class Sequence {
|
||||
}
|
||||
}
|
||||
|
||||
/** Controls how {@link Sequence#regions} are displayed over time. */
|
||||
/** Controls how {@link Sequence.regions} are displayed over time. */
|
||||
export enum SequenceMode {
|
||||
hold = 0,
|
||||
once = 1,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user