mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 09:16:01 +08:00
[ts] Merge fix for #2003, fix ping pong reverse in Sequencetimeline
# Conflicts: # spine-ts/package-lock.json # spine-ts/package.json # spine-ts/spine-canvas/package.json # spine-ts/spine-core/package.json # spine-ts/spine-core/src/Slot.ts # spine-ts/spine-core/src/attachments/MeshAttachment.ts # spine-ts/spine-core/src/attachments/RegionAttachment.ts # spine-ts/spine-player/package.json # spine-ts/spine-threejs/package.json # spine-ts/spine-webgl/package.json
This commit is contained in:
commit
ced0771c37
@ -42,8 +42,8 @@ import { SequenceMode, SequenceModeValues } from "./attachments/Sequence";
|
||||
export class Animation {
|
||||
/** The animation's name, which is unique across all animations in the skeleton. */
|
||||
name: string;
|
||||
timelines: Array<Timeline>;
|
||||
timelineIds: StringSet;
|
||||
timelines: Array<Timeline> = null;
|
||||
timelineIds: StringSet = null;
|
||||
|
||||
/** The duration of the animation in seconds, which is the highest time of all keys in the timeline. */
|
||||
duration: number;
|
||||
@ -155,8 +155,8 @@ const Property = {
|
||||
|
||||
/** The interface for all timelines. */
|
||||
export abstract class Timeline {
|
||||
propertyIds: string[];
|
||||
frames: NumberArrayLike;
|
||||
propertyIds: string[] = null;
|
||||
frames: NumberArrayLike = null;
|
||||
|
||||
constructor (frameCount: number, propertyIds: string[]) {
|
||||
this.propertyIds = propertyIds;
|
||||
@ -208,7 +208,7 @@ export interface SlotTimeline {
|
||||
|
||||
/** The base class for timelines that use interpolation between key frame values. */
|
||||
export abstract class CurveTimeline extends Timeline {
|
||||
protected curves: NumberArrayLike; // type, x, y, ...
|
||||
protected curves: NumberArrayLike = null; // type, x, y, ...
|
||||
|
||||
constructor (frameCount: number, bezierCount: number, propertyIds: string[]) {
|
||||
super(frameCount, propertyIds);
|
||||
@ -1430,10 +1430,10 @@ export class DeformTimeline extends CurveTimeline implements SlotTimeline {
|
||||
slotIndex = 0;
|
||||
|
||||
/** The attachment that will be deformed. */
|
||||
attachment: VertexAttachment;
|
||||
attachment: VertexAttachment = null;
|
||||
|
||||
/** The vertices for each key frame. */
|
||||
vertices: Array<NumberArrayLike>;
|
||||
vertices: Array<NumberArrayLike> = null;
|
||||
|
||||
constructor (frameCount: number, bezierCount: number, slotIndex: number, attachment: VertexAttachment) {
|
||||
super(frameCount, bezierCount, [
|
||||
@ -1685,7 +1685,7 @@ export class EventTimeline extends Timeline {
|
||||
static propertyIds = ["" + Property.event];
|
||||
|
||||
/** The event for each key frame. */
|
||||
events: Array<Event>;
|
||||
events: Array<Event> = null;
|
||||
|
||||
constructor (frameCount: number) {
|
||||
super(frameCount, EventTimeline.propertyIds);
|
||||
@ -1738,7 +1738,7 @@ export class DrawOrderTimeline extends Timeline {
|
||||
static propertyIds = ["" + Property.drawOrder];
|
||||
|
||||
/** The draw order for each key frame. See {@link #setFrame(int, float, int[])}. */
|
||||
drawOrders: Array<Array<number>>;
|
||||
drawOrders: Array<Array<number>> = null;
|
||||
|
||||
constructor (frameCount: number) {
|
||||
super(frameCount, DrawOrderTimeline.propertyIds);
|
||||
@ -1784,7 +1784,7 @@ export class DrawOrderTimeline extends Timeline {
|
||||
* {@link IkConstraint#bendDirection}, {@link IkConstraint#stretch}, and {@link IkConstraint#compress}. */
|
||||
export class IkConstraintTimeline extends CurveTimeline {
|
||||
/** The index of the IK constraint slot in {@link Skeleton#ikConstraints} that will be changed. */
|
||||
ikConstraintIndex: number;
|
||||
ikConstraintIndex: number = 0;
|
||||
|
||||
constructor (frameCount: number, bezierCount: number, ikConstraintIndex: number) {
|
||||
super(frameCount, bezierCount, [
|
||||
@ -1882,7 +1882,7 @@ export class IkConstraintTimeline extends CurveTimeline {
|
||||
* {@link TransformConstraint#scaleMix}, and {@link TransformConstraint#shearMix}. */
|
||||
export class TransformConstraintTimeline extends CurveTimeline {
|
||||
/** The index of the transform constraint slot in {@link Skeleton#transformConstraints} that will be changed. */
|
||||
transformConstraintIndex: number;
|
||||
transformConstraintIndex: number = 0;
|
||||
|
||||
constructor (frameCount: number, bezierCount: number, transformConstraintIndex: number) {
|
||||
super(frameCount, bezierCount, [
|
||||
@ -1995,7 +1995,7 @@ export class TransformConstraintTimeline extends CurveTimeline {
|
||||
/** Changes a path constraint's {@link PathConstraint#position}. */
|
||||
export class PathConstraintPositionTimeline extends CurveTimeline1 {
|
||||
/** The index of the path constraint slot in {@link Skeleton#pathConstraints} that will be changed. */
|
||||
pathConstraintIndex: number;
|
||||
pathConstraintIndex: number = 0;
|
||||
|
||||
constructor (frameCount: number, bezierCount: number, pathConstraintIndex: number) {
|
||||
super(frameCount, bezierCount, Property.pathConstraintPosition + "|" + pathConstraintIndex);
|
||||
@ -2218,16 +2218,23 @@ export class SequenceTimeline extends Timeline implements SlotTimeline {
|
||||
case SequenceMode.loop:
|
||||
index %= count;
|
||||
break;
|
||||
case SequenceMode.pingpong:
|
||||
case SequenceMode.pingpong: {
|
||||
let n = (count << 1) - 2;
|
||||
index %= n;
|
||||
if (index >= count) index = n - index;
|
||||
break;
|
||||
}
|
||||
case SequenceMode.onceReverse:
|
||||
index = Math.max(count - 1 - index, 0);
|
||||
break;
|
||||
case SequenceMode.loopReverse:
|
||||
index = count - 1 - (index % count);
|
||||
break;
|
||||
case SequenceMode.pingpongReverse: {
|
||||
let n = (count << 1) - 2;
|
||||
index = (index + count - 1) % n;
|
||||
if (index >= count) index = n - index;
|
||||
}
|
||||
}
|
||||
}
|
||||
slot.sequenceIndex = index;
|
||||
|
||||
@ -46,7 +46,7 @@ export class AnimationState {
|
||||
}
|
||||
|
||||
/** The AnimationStateData to look up mix durations. */
|
||||
data: AnimationStateData;
|
||||
data: AnimationStateData = null;
|
||||
|
||||
/** The list of tracks that currently have animations, which may contain null entries. */
|
||||
tracks = new Array<TrackEntry>();
|
||||
@ -645,6 +645,7 @@ export class AnimationState {
|
||||
/** @param last May be null. */
|
||||
trackEntry (trackIndex: number, animation: Animation, loop: boolean, last: TrackEntry) {
|
||||
let entry = this.trackEntryPool.obtain();
|
||||
entry.reset();
|
||||
entry.trackIndex = trackIndex;
|
||||
entry.animation = animation;
|
||||
entry.loop = loop;
|
||||
@ -777,35 +778,35 @@ export class AnimationState {
|
||||
* 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;
|
||||
animation: Animation = null;
|
||||
|
||||
previous: TrackEntry;
|
||||
previous: TrackEntry = null;
|
||||
|
||||
/** The animation queued to start after this animation, or null. `next` makes up a linked list. */
|
||||
next: TrackEntry;
|
||||
next: TrackEntry = null;
|
||||
|
||||
/** The track entry for the previous animation when mixing from the previous animation to this animation, or null if no
|
||||
* mixing is currently occuring. When mixing from multiple animations, `mixingFrom` makes up a linked list. */
|
||||
mixingFrom: TrackEntry;
|
||||
mixingFrom: TrackEntry = null;
|
||||
|
||||
/** The track entry for the next animation when mixing from this animation to the next animation, or null if no mixing is
|
||||
* currently occuring. When mixing to multiple animations, `mixingTo` makes up a linked list. */
|
||||
mixingTo: TrackEntry;
|
||||
mixingTo: TrackEntry = 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 track entry listener {@link AnimationStateListener#start()} will not be called. */
|
||||
listener: AnimationStateListener;
|
||||
listener: AnimationStateListener = null;
|
||||
|
||||
/** The index of the track where this track entry is either current or queued.
|
||||
*
|
||||
* See {@link AnimationState#getCurrent()}. */
|
||||
trackIndex: number;
|
||||
trackIndex: number = 0;
|
||||
|
||||
/** If true, the animation will repeat. If false it will not, instead its last frame is applied if played beyond its
|
||||
* duration. */
|
||||
loop: boolean;
|
||||
loop: boolean = false;
|
||||
|
||||
/** If true, when mixing from the previous animation to this animation, the previous animation is applied as normal instead
|
||||
* of being mixed out.
|
||||
@ -818,43 +819,43 @@ export class TrackEntry {
|
||||
*
|
||||
* Snapping will occur if `holdPrevious` is true and this animation does not key all the same properties as the
|
||||
* previous animation. */
|
||||
holdPrevious: boolean;
|
||||
holdPrevious: boolean = false;
|
||||
|
||||
reverse: boolean;
|
||||
reverse: boolean = false;
|
||||
|
||||
/** 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: number;
|
||||
eventThreshold: number = 0;
|
||||
|
||||
/** When the mix percentage ({@link #mixtime} / {@link #mixDuration}) is less than the
|
||||
* `attachmentThreshold`, 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. */
|
||||
attachmentThreshold: number;
|
||||
attachmentThreshold: number = 0;
|
||||
|
||||
/** When the mix percentage ({@link #mixTime} / {@link #mixDuration}) is less than the
|
||||
* `drawOrderThreshold`, 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. */
|
||||
drawOrderThreshold: number;
|
||||
drawOrderThreshold: number = 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 to prevent timeline keys before the start time from triggering. */
|
||||
animationStart: number;
|
||||
animationStart: number = 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}. */
|
||||
animationEnd: number;
|
||||
animationEnd: number = 0;
|
||||
|
||||
|
||||
/** The time in seconds this animation was last applied. Some timelines use this for one-time triggers. Eg, when this
|
||||
* animation is applied, event timelines will fire all events between the `animationLast` time (exclusive) and
|
||||
* `animationTime` (inclusive). Defaults to -1 to ensure triggers on frame 0 happen the first time this animation
|
||||
* is applied. */
|
||||
animationLast: number;
|
||||
animationLast: number = 0;
|
||||
|
||||
nextAnimationLast: number;
|
||||
nextAnimationLast: number = 0;
|
||||
|
||||
/** Seconds to postpone playing the animation. When this track entry is the current track entry, `delay`
|
||||
* postpones incrementing the {@link #trackTime}. When this track entry is queued, `delay` is the time from
|
||||
@ -862,14 +863,14 @@ export class TrackEntry {
|
||||
* track entry {@link TrackEntry#trackTime} >= this track entry's `delay`).
|
||||
*
|
||||
* {@link #timeScale} affects the delay. */
|
||||
delay: number;
|
||||
delay: number = 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
|
||||
* looping. */
|
||||
trackTime: number;
|
||||
trackTime: number = 0;
|
||||
|
||||
trackLast: number; nextTrackLast: number;
|
||||
trackLast: number = 0; nextTrackLast: number = 0;
|
||||
|
||||
/** The track time in seconds when this animation will be removed from the track. Defaults to the highest possible float
|
||||
* value, meaning the animation will be applied until a new animation is set or the track is cleared. If the track end time
|
||||
@ -878,7 +879,7 @@ export class TrackEntry {
|
||||
*
|
||||
* It may be desired to use {@link AnimationState#addEmptyAnimation()} rather than have the animation
|
||||
* abruptly cease being applied. */
|
||||
trackEnd: number;
|
||||
trackEnd: number = 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.
|
||||
@ -891,18 +892,18 @@ export class TrackEntry {
|
||||
* the time scale is not 1, the delay may need to be adjusted.
|
||||
*
|
||||
* See AnimationState {@link AnimationState#timeScale} for affecting all animations. */
|
||||
timeScale: number;
|
||||
timeScale: number = 0;
|
||||
|
||||
/** Values < 1 mix this animation with the skeleton's current pose (usually the pose resulting from lower tracks). Defaults
|
||||
* to 1, which overwrites the skeleton's current pose with this animation.
|
||||
*
|
||||
* Typically track 0 is used to completely pose the skeleton, then alpha is used on higher tracks. It doesn't make sense to
|
||||
* use alpha on track 0 if the skeleton pose is from the last frame render. */
|
||||
alpha: number;
|
||||
alpha: number = 0;
|
||||
|
||||
/** Seconds from 0 to the {@link #getMixDuration()} when mixing from the previous animation to this animation. May be
|
||||
* slightly more than `mixDuration` when the mix is complete. */
|
||||
mixTime: number;
|
||||
mixTime: number = 0;
|
||||
|
||||
/** Seconds for mixing from the previous animation to this animation. Defaults to the value provided by AnimationStateData
|
||||
* {@link AnimationStateData#getMix()} based on the animation before this animation (if any).
|
||||
@ -917,7 +918,7 @@ export class TrackEntry {
|
||||
* When using {@link AnimationState#addAnimation()} with a `delay` <= 0, note the
|
||||
* {@link #delay} is set using the mix duration from the {@link AnimationStateData}, not a mix duration set
|
||||
* afterward. */
|
||||
mixDuration: number; interruptAlpha: number; totalAlpha: number;
|
||||
mixDuration: number = 0; interruptAlpha: number = 0; totalAlpha: number = 0;
|
||||
|
||||
/** Controls how properties keyed in the animation are mixed with lower tracks. Defaults to {@link MixBlend#replace}, which
|
||||
* replaces the values from the lower tracks with the animation values. {@link MixBlend#add} adds the animation values to
|
||||
@ -990,7 +991,7 @@ export class TrackEntry {
|
||||
export class EventQueue {
|
||||
objects: Array<any> = [];
|
||||
drainDisabled = false;
|
||||
animState: AnimationState;
|
||||
animState: AnimationState = null;
|
||||
|
||||
constructor (animState: AnimationState) {
|
||||
this.animState = animState;
|
||||
|
||||
@ -35,7 +35,7 @@ import { StringMap } from "./Utils";
|
||||
/** Stores mix (crossfade) durations to be applied when {@link AnimationState} animations are changed. */
|
||||
export class AnimationStateData {
|
||||
/** The SkeletonData to look up animations when they are specified by name. */
|
||||
skeletonData: SkeletonData;
|
||||
skeletonData: SkeletonData = null;
|
||||
|
||||
animationToMixTime: StringMap<number> = {};
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ import { TextureAtlas } from "./TextureAtlas";
|
||||
import { Disposable, StringMap } from "./Utils";
|
||||
|
||||
export class AssetManagerBase implements Disposable {
|
||||
private pathPrefix: string;
|
||||
private pathPrefix: string = null;
|
||||
private textureLoader: (image: HTMLImageElement | ImageBitmap) => Texture;
|
||||
private downloader: Downloader;
|
||||
private assets: StringMap<any> = {};
|
||||
|
||||
@ -43,7 +43,7 @@ import { Sequence } from "./attachments/Sequence"
|
||||
* See [Loading skeleton data](http://esotericsoftware.com/spine-loading-skeleton-data#JSON-and-binary-data) in the
|
||||
* Spine Runtimes Guide. */
|
||||
export class AtlasAttachmentLoader implements AttachmentLoader {
|
||||
atlas: TextureAtlas;
|
||||
atlas: TextureAtlas = null;
|
||||
|
||||
constructor (atlas: TextureAtlas) {
|
||||
this.atlas = atlas;
|
||||
|
||||
@ -39,13 +39,13 @@ import { MathUtils, Vector2 } from "./Utils";
|
||||
* constraint or application code modifies the world transform after it was computed from the local transform. */
|
||||
export class Bone implements Updatable {
|
||||
/** The bone's setup pose data. */
|
||||
data: BoneData;
|
||||
data: BoneData = null;
|
||||
|
||||
/** The skeleton this bone belongs to. */
|
||||
skeleton: Skeleton;
|
||||
skeleton: Skeleton = null;
|
||||
|
||||
/** The parent bone, or null if this is the root bone. */
|
||||
parent: Bone;
|
||||
parent: Bone = null;
|
||||
|
||||
/** The immediate children of this bone. */
|
||||
children = new Array<Bone>();
|
||||
|
||||
@ -32,16 +32,16 @@ import { Color } from "./Utils";
|
||||
/** Stores the setup pose for a {@link Bone}. */
|
||||
export class BoneData {
|
||||
/** The index of the bone in {@link Skeleton#getBones()}. */
|
||||
index: number;
|
||||
index: number = 0;
|
||||
|
||||
/** The name of the bone, which is unique across all bones in the skeleton. */
|
||||
name: string;
|
||||
name: string = null;
|
||||
|
||||
/** @returns May be null. */
|
||||
parent: BoneData;
|
||||
parent: BoneData = null;
|
||||
|
||||
/** The bone's length. */
|
||||
length: number;
|
||||
length: number = 0;
|
||||
|
||||
/** The local x translation. */
|
||||
x = 0;
|
||||
|
||||
@ -35,13 +35,13 @@ import { EventData } from "./EventData";
|
||||
* AnimationStateListener {@link AnimationStateListener#event()}, and
|
||||
* [Events](http://esotericsoftware.com/spine-events) in the Spine User Guide. */
|
||||
export class Event {
|
||||
data: EventData;
|
||||
intValue: number;
|
||||
floatValue: number;
|
||||
stringValue: string;
|
||||
time: number;
|
||||
volume: number;
|
||||
balance: number;
|
||||
data: EventData = null;
|
||||
intValue: number = 0;
|
||||
floatValue: number = 0;
|
||||
stringValue: string = null;
|
||||
time: number = 0;
|
||||
volume: number = 0;
|
||||
balance: number = 0;
|
||||
|
||||
constructor (time: number, data: EventData) {
|
||||
if (!data) throw new Error("data cannot be null.");
|
||||
|
||||
@ -31,13 +31,13 @@
|
||||
*
|
||||
* See [Events](http://esotericsoftware.com/spine-events) in the Spine User Guide. */
|
||||
export class EventData {
|
||||
name: string;
|
||||
intValue: number;
|
||||
floatValue: number;
|
||||
stringValue: string;
|
||||
audioPath: string;
|
||||
volume: number;
|
||||
balance: number;
|
||||
name: string = null;
|
||||
intValue: number = 0;
|
||||
floatValue: number = 0;
|
||||
stringValue: string = null;
|
||||
audioPath: string = null;
|
||||
volume: number = 0;
|
||||
balance: number = 0;
|
||||
|
||||
constructor (name: string) {
|
||||
this.name = name;
|
||||
|
||||
@ -40,13 +40,13 @@ import { MathUtils } from "./Utils";
|
||||
* See [IK constraints](http://esotericsoftware.com/spine-ik-constraints) in the Spine User Guide. */
|
||||
export class IkConstraint implements Updatable {
|
||||
/** The IK constraint's setup pose data. */
|
||||
data: IkConstraintData;
|
||||
data: IkConstraintData = null;
|
||||
|
||||
/** The bones that will be modified by this IK constraint. */
|
||||
bones: Array<Bone>;
|
||||
bones: Array<Bone> = null;
|
||||
|
||||
/** The bone that is the IK target. */
|
||||
target: Bone;
|
||||
target: Bone = null;
|
||||
|
||||
/** Controls the bend direction of the IK bones, either 1 or -1. */
|
||||
bendDirection = 0;
|
||||
|
||||
@ -39,7 +39,7 @@ export class IkConstraintData extends ConstraintData {
|
||||
bones = new Array<BoneData>();
|
||||
|
||||
/** The bone that is the IK target. */
|
||||
target: BoneData;
|
||||
target: BoneData = null;
|
||||
|
||||
/** Controls the bend direction of the IK bones, either 1 or -1. */
|
||||
bendDirection = 1;
|
||||
|
||||
@ -45,13 +45,13 @@ export class PathConstraint implements Updatable {
|
||||
static epsilon = 0.00001;
|
||||
|
||||
/** The path constraint's setup pose data. */
|
||||
data: PathConstraintData;
|
||||
data: PathConstraintData = null;
|
||||
|
||||
/** The bones that will be modified by this path constraint. */
|
||||
bones: Array<Bone>;
|
||||
bones: Array<Bone> = null;
|
||||
|
||||
/** The slot whose path attachment will be used to constrained the bones. */
|
||||
target: Slot;
|
||||
target: Slot = null;
|
||||
|
||||
/** The position along the path. */
|
||||
position = 0;
|
||||
|
||||
@ -41,25 +41,25 @@ export class PathConstraintData extends ConstraintData {
|
||||
bones = new Array<BoneData>();
|
||||
|
||||
/** The slot whose path attachment will be used to constrained the bones. */
|
||||
target: SlotData;
|
||||
target: SlotData = null;
|
||||
|
||||
/** The mode for positioning the first bone on the path. */
|
||||
positionMode: PositionMode;
|
||||
positionMode: PositionMode = null;
|
||||
|
||||
/** The mode for positioning the bones after the first bone on the path. */
|
||||
spacingMode: SpacingMode;
|
||||
spacingMode: SpacingMode = null;
|
||||
|
||||
/** The mode for adjusting the rotation of the bones. */
|
||||
rotateMode: RotateMode;
|
||||
rotateMode: RotateMode = null;
|
||||
|
||||
/** An offset added to the constrained bone rotation. */
|
||||
offsetRotation: number;
|
||||
offsetRotation: number = 0;
|
||||
|
||||
/** The position along the path. */
|
||||
position: number;
|
||||
position: number = 0;
|
||||
|
||||
/** The spacing between bones. */
|
||||
spacing: number;
|
||||
spacing: number = 0;
|
||||
|
||||
mixRotate = 0;
|
||||
mixX = 0;
|
||||
|
||||
@ -46,34 +46,34 @@ import { Color, Utils, MathUtils, Vector2, NumberArrayLike } from "./Utils";
|
||||
* See [Instance objects](http://esotericsoftware.com/spine-runtime-architecture#Instance-objects) in the Spine Runtimes Guide. */
|
||||
export class Skeleton {
|
||||
/** The skeleton's setup pose data. */
|
||||
data: SkeletonData;
|
||||
data: SkeletonData = null;
|
||||
|
||||
/** The skeleton's bones, sorted parent first. The root bone is always the first bone. */
|
||||
bones: Array<Bone>;
|
||||
bones: Array<Bone> = null;
|
||||
|
||||
/** The skeleton's slots. */
|
||||
slots: Array<Slot>;
|
||||
slots: Array<Slot> = null;
|
||||
|
||||
/** The skeleton's slots in the order they should be drawn. The returned array may be modified to change the draw order. */
|
||||
drawOrder: Array<Slot>;
|
||||
drawOrder: Array<Slot> = null;
|
||||
|
||||
/** The skeleton's IK constraints. */
|
||||
ikConstraints: Array<IkConstraint>;
|
||||
ikConstraints: Array<IkConstraint> = null;
|
||||
|
||||
/** The skeleton's transform constraints. */
|
||||
transformConstraints: Array<TransformConstraint>;
|
||||
transformConstraints: Array<TransformConstraint> = null;
|
||||
|
||||
/** The skeleton's path constraints. */
|
||||
pathConstraints: Array<PathConstraint>;
|
||||
pathConstraints: Array<PathConstraint> = null;
|
||||
|
||||
/** The list of bones and constraints, sorted in the order they should be updated, as computed by {@link #updateCache()}. */
|
||||
_updateCache = new Array<Updatable>();
|
||||
|
||||
/** The skeleton's current skin. May be null. */
|
||||
skin: Skin;
|
||||
skin: Skin = null;
|
||||
|
||||
/** The color to tint all the skeleton's attachments. */
|
||||
color: Color;
|
||||
color: Color = null;
|
||||
|
||||
/** Scales the entire skeleton on the X axis. This affects all bones, even if the bone's transform mode disallows scale
|
||||
* inheritance. */
|
||||
|
||||
@ -56,7 +56,7 @@ export class SkeletonBinary {
|
||||
* See [Scaling](http://esotericsoftware.com/spine-loading-skeleton-data#Scaling) in the Spine Runtimes Guide. */
|
||||
scale = 1;
|
||||
|
||||
attachmentLoader: AttachmentLoader;
|
||||
attachmentLoader: AttachmentLoader = null;
|
||||
private linkedMeshes = new Array<LinkedMesh>();
|
||||
|
||||
constructor (attachmentLoader: AttachmentLoader) {
|
||||
|
||||
@ -43,7 +43,7 @@ import { TransformConstraintData } from "./TransformConstraintData";
|
||||
export class SkeletonData {
|
||||
|
||||
/** The skeleton's name, which by default is the name of the skeleton data file, if possible. May be null. */
|
||||
name: string;
|
||||
name: string = null;
|
||||
|
||||
/** The skeleton's bones, sorted parent first. The root bone is always the first bone. */
|
||||
bones = new Array<BoneData>(); // Ordered parents first.
|
||||
@ -56,7 +56,7 @@ export class SkeletonData {
|
||||
*
|
||||
* See {@link Skeleton#getAttachmentByName()}.
|
||||
* May be null. */
|
||||
defaultSkin: Skin;
|
||||
defaultSkin: Skin = null;
|
||||
|
||||
/** The skeleton's events. */
|
||||
events = new Array<EventData>();
|
||||
@ -74,32 +74,32 @@ export class SkeletonData {
|
||||
pathConstraints = new Array<PathConstraintData>();
|
||||
|
||||
/** The X coordinate of the skeleton's axis aligned bounding box in the setup pose. */
|
||||
x: number;
|
||||
x: number = 0;
|
||||
|
||||
/** The Y coordinate of the skeleton's axis aligned bounding box in the setup pose. */
|
||||
y: number;
|
||||
y: number = 0;
|
||||
|
||||
/** The width of the skeleton's axis aligned bounding box in the setup pose. */
|
||||
width: number;
|
||||
width: number = 0;
|
||||
|
||||
/** The height of the skeleton's axis aligned bounding box in the setup pose. */
|
||||
height: number;
|
||||
height: number = 0;
|
||||
|
||||
/** The Spine version used to export the skeleton data, or null. */
|
||||
version: string;
|
||||
version: string = null;
|
||||
|
||||
/** The skeleton data hash. This value will change if any of the skeleton data has changed. May be null. */
|
||||
hash: string;
|
||||
hash: string = null;
|
||||
|
||||
// Nonessential
|
||||
/** The dopesheet FPS in Spine. Available only when nonessential data was exported. */
|
||||
fps = 0;
|
||||
|
||||
/** The path to the images directory as defined in Spine. Available only when nonessential data was exported. May be null. */
|
||||
imagesPath: string;
|
||||
imagesPath: string = null;
|
||||
|
||||
/** The path to the audio directory as defined in Spine. Available only when nonessential data was exported. May be null. */
|
||||
audioPath: string;
|
||||
audioPath: string = null;
|
||||
|
||||
/** Finds a bone by comparing each bone's name. It is more efficient to cache the results of this method than to call it
|
||||
* multiple times.
|
||||
|
||||
@ -51,7 +51,7 @@ import { HasTextureRegion } from "./attachments/HasTextureRegion";
|
||||
* [JSON and binary data](http://esotericsoftware.com/spine-loading-skeleton-data#JSON-and-binary-data) in the Spine
|
||||
* Runtimes Guide. */
|
||||
export class SkeletonJson {
|
||||
attachmentLoader: AttachmentLoader;
|
||||
attachmentLoader: AttachmentLoader = null;
|
||||
|
||||
/** Scales bone positions, image sizes, and translations as they are loaded. This allows different size images to be used at
|
||||
* runtime than were used in Spine.
|
||||
|
||||
@ -36,7 +36,7 @@ import { StringMap } from "./Utils";
|
||||
|
||||
/** Stores an entry in the skin consisting of the slot index, name, and attachment **/
|
||||
export class SkinEntry {
|
||||
constructor (public slotIndex: number, public name: string, public attachment: Attachment) { }
|
||||
constructor (public slotIndex: number = 0, public name: string = null, public attachment: Attachment = null) { }
|
||||
}
|
||||
|
||||
/** Stores attachments by slot index and attachment name.
|
||||
@ -45,7 +45,7 @@ export class SkinEntry {
|
||||
* [Runtime skins](http://esotericsoftware.com/spine-runtime-skins) in the Spine Runtimes Guide. */
|
||||
export class Skin {
|
||||
/** The skin's name, which is unique across all skins in the skeleton. */
|
||||
name: string;
|
||||
name: string = null;
|
||||
|
||||
attachments = new Array<StringMap<Attachment>>();
|
||||
bones = Array<BoneData>();
|
||||
|
||||
@ -38,22 +38,22 @@ import { Color } from "./Utils";
|
||||
* across multiple skeletons. */
|
||||
export class Slot {
|
||||
/** The slot's setup pose data. */
|
||||
data: SlotData;
|
||||
data: SlotData = null;
|
||||
|
||||
/** The bone this slot belongs to. */
|
||||
bone: Bone;
|
||||
bone: Bone = null;
|
||||
|
||||
/** The color used to tint the slot's attachment. If {@link #getDarkColor()} is set, this is used as the light color for two
|
||||
* color tinting. */
|
||||
color: Color;
|
||||
color: Color = null;
|
||||
|
||||
/** The dark color used to tint the slot's attachment for two color tinting, or null if two color tinting is not used. The dark
|
||||
* color's alpha is not used. */
|
||||
darkColor: Color;
|
||||
darkColor: Color = null;
|
||||
|
||||
attachment: Attachment;
|
||||
attachment: Attachment = null;
|
||||
|
||||
attachmentState: number;
|
||||
attachmentState: number = 0;
|
||||
|
||||
/** The index of the texture region to display when the slot's attachment has a {@link Sequence}. -1 represents the
|
||||
* {@link Sequence#getSetupIndex()}. */
|
||||
|
||||
@ -33,13 +33,13 @@ import { Color } from "./Utils";
|
||||
/** Stores the setup pose for a {@link Slot}. */
|
||||
export class SlotData {
|
||||
/** The index of the slot in {@link Skeleton#getSlots()}. */
|
||||
index: number;
|
||||
index: number = 0;
|
||||
|
||||
/** The name of the slot, which is unique across all slots in the skeleton. */
|
||||
name: string;
|
||||
name: string = null;
|
||||
|
||||
/** The bone this slot belongs to. */
|
||||
boneData: BoneData;
|
||||
boneData: BoneData = null;
|
||||
|
||||
/** The color used to tint the slot's attachment. If {@link #getDarkColor()} is set, this is used as the light color for two
|
||||
* color tinting. */
|
||||
@ -47,13 +47,13 @@ export class SlotData {
|
||||
|
||||
/** The dark color used to tint the slot's attachment for two color tinting, or null if two color tinting is not used. The dark
|
||||
* color's alpha is not used. */
|
||||
darkColor: Color;
|
||||
darkColor: Color = null;
|
||||
|
||||
/** The name of the attachment that is visible for this slot in the setup pose, or null if no attachment is visible. */
|
||||
attachmentName: string;
|
||||
attachmentName: string = null;
|
||||
|
||||
/** The blend mode for drawing the slot's attachment. */
|
||||
blendMode: BlendMode;
|
||||
blendMode: BlendMode = null;
|
||||
|
||||
constructor (index: number, name: string, boneData: BoneData) {
|
||||
if (index < 0) throw new Error("index must be >= 0.");
|
||||
|
||||
@ -198,7 +198,7 @@ export class TextureAtlas implements Disposable {
|
||||
}
|
||||
|
||||
class TextureAtlasReader {
|
||||
lines: Array<string>;
|
||||
lines: Array<string> = null;
|
||||
index: number = 0;
|
||||
|
||||
constructor (text: string) {
|
||||
@ -233,15 +233,15 @@ class TextureAtlasReader {
|
||||
}
|
||||
|
||||
export class TextureAtlasPage {
|
||||
name: string;
|
||||
name: string = null;
|
||||
minFilter: TextureFilter = TextureFilter.Nearest;
|
||||
magFilter: TextureFilter = TextureFilter.Nearest;
|
||||
uWrap: TextureWrap = TextureWrap.ClampToEdge;
|
||||
vWrap: TextureWrap = TextureWrap.ClampToEdge;
|
||||
texture: Texture;
|
||||
width: number;
|
||||
height: number;
|
||||
pma: boolean;
|
||||
texture: Texture = null;
|
||||
width: number = 0;
|
||||
height: number = 0;
|
||||
pma: boolean = false;
|
||||
|
||||
setTexture (texture: Texture) {
|
||||
this.texture = texture;
|
||||
@ -251,16 +251,16 @@ export class TextureAtlasPage {
|
||||
}
|
||||
|
||||
export class TextureAtlasRegion extends TextureRegion {
|
||||
page: TextureAtlasPage;
|
||||
name: string;
|
||||
x: number;
|
||||
y: number;
|
||||
offsetX: number;
|
||||
offsetY: number;
|
||||
originalWidth: number;
|
||||
originalHeight: number;
|
||||
index: number;
|
||||
degrees: number;
|
||||
names: string[];
|
||||
values: number[][];
|
||||
page: TextureAtlasPage = null;
|
||||
name: string = null;
|
||||
x: number = 0;
|
||||
y: number = 0;
|
||||
offsetX: number = 0;
|
||||
offsetY: number = 0;
|
||||
originalWidth: number = 0;
|
||||
originalHeight: number = 0;
|
||||
index: number = 0;
|
||||
degrees: number = 0;
|
||||
names: string[] = null;
|
||||
values: number[][] = null;
|
||||
}
|
||||
|
||||
@ -41,13 +41,13 @@ import { Vector2, MathUtils } from "./Utils";
|
||||
export class TransformConstraint implements Updatable {
|
||||
|
||||
/** The transform constraint's setup pose data. */
|
||||
data: TransformConstraintData;
|
||||
data: TransformConstraintData = null;
|
||||
|
||||
/** The bones that will be modified by this transform constraint. */
|
||||
bones: Array<Bone>;
|
||||
bones: Array<Bone> = null;
|
||||
|
||||
/** The target bone whose world transform will be copied to the constrained bones. */
|
||||
target: Bone;
|
||||
target: Bone = null;
|
||||
|
||||
mixRotate = 0; mixX = 0; mixY = 0; mixScaleX = 0; mixScaleY = 0; mixShearY = 0;
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ export class TransformConstraintData extends ConstraintData {
|
||||
bones = new Array<BoneData>();
|
||||
|
||||
/** The target bone whose world transform will be copied to the constrained bones. */
|
||||
target: BoneData;
|
||||
target: BoneData = null;
|
||||
|
||||
mixRotate = 0;
|
||||
mixX = 0;
|
||||
|
||||
@ -53,12 +53,12 @@ export abstract class VertexAttachment extends Attachment {
|
||||
/** The bones which affect the {@link #getVertices()}. The array entries are, for each vertex, the number of bones affecting
|
||||
* the vertex followed by that many bone indices, which is the index of the bone in {@link Skeleton#bones}. Will be null
|
||||
* if this attachment has no weights. */
|
||||
bones: Array<number>;
|
||||
bones: Array<number> = null;
|
||||
|
||||
/** The vertex positions in the bone's coordinate system. For a non-weighted attachment, the values are `x,y`
|
||||
* entries for each vertex. For a weighted attachment, the values are `x,y,weight` entries for each bone affecting
|
||||
* each vertex. */
|
||||
vertices: NumberArrayLike;
|
||||
vertices: NumberArrayLike = null;
|
||||
|
||||
/** The maximum number of world vertex values that can be output by
|
||||
* {@link #computeWorldVertices()} using the `count` parameter. */
|
||||
|
||||
@ -35,7 +35,7 @@ import { VertexAttachment, Attachment } from "./Attachment";
|
||||
export class ClippingAttachment extends VertexAttachment {
|
||||
/** Clipping is performed between the clipping polygon's slot and the end slot. Returns null if clipping is done until the end of
|
||||
* the skeleton's rendering. */
|
||||
endSlot: SlotData;
|
||||
endSlot: SlotData = null;
|
||||
|
||||
// Nonessential.
|
||||
/** The color of the clipping polygon as it was in Spine. Available only when nonessential data was exported. Clipping polygons
|
||||
|
||||
@ -40,41 +40,41 @@ import { Slot } from "../Slot";
|
||||
*
|
||||
* See [Mesh attachments](http://esotericsoftware.com/spine-meshes) in the Spine User Guide. */
|
||||
export class MeshAttachment extends VertexAttachment implements HasTextureRegion {
|
||||
region: TextureRegion;
|
||||
region: TextureRegion = null;
|
||||
|
||||
/** The name of the texture region for this attachment. */
|
||||
path: string;
|
||||
path: string = null;
|
||||
|
||||
/** The UV pair for each vertex, normalized within the texture region. */
|
||||
regionUVs: NumberArrayLike;
|
||||
regionUVs: NumberArrayLike = null;
|
||||
|
||||
/** The UV pair for each vertex, normalized within the entire texture.
|
||||
*
|
||||
* See {@link #updateUVs}. */
|
||||
uvs: NumberArrayLike;
|
||||
uvs: NumberArrayLike = null;
|
||||
|
||||
/** Triplets of vertex indices which describe the mesh's triangulation. */
|
||||
triangles: Array<number>;
|
||||
triangles: Array<number> = null;
|
||||
|
||||
/** The color to tint the mesh. */
|
||||
color = new Color(1, 1, 1, 1);
|
||||
|
||||
/** The width of the mesh's image. Available only when nonessential data was exported. */
|
||||
width: number;
|
||||
width: number = 0;
|
||||
|
||||
/** The height of the mesh's image. Available only when nonessential data was exported. */
|
||||
height: number;
|
||||
height: number = 0;
|
||||
|
||||
/** The number of entries at the beginning of {@link #vertices} that make up the mesh hull. */
|
||||
hullLength: number;
|
||||
hullLength: number = 0;
|
||||
|
||||
/** Vertex index pairs describing edges for controling triangulation. Mesh triangles will never cross edges. Only available if
|
||||
* nonessential data was exported. Triangulation is not performed at runtime. */
|
||||
edges: Array<number>;
|
||||
edges: Array<number> = null;
|
||||
|
||||
private parentMesh: MeshAttachment;
|
||||
private parentMesh: MeshAttachment = null;
|
||||
|
||||
sequence: Sequence;
|
||||
sequence: Sequence = null;
|
||||
|
||||
tempColor = new Color(0, 0, 0, 0);
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ import { VertexAttachment, Attachment } from "./Attachment";
|
||||
export class PathAttachment extends VertexAttachment {
|
||||
|
||||
/** The lengths along the path in the setup pose from the start of the path to the end of each Bezier curve. */
|
||||
lengths: Array<number>;
|
||||
lengths: Array<number> = null;
|
||||
|
||||
/** If true, the start and end knots are connected. */
|
||||
closed = false;
|
||||
|
||||
@ -37,7 +37,9 @@ import { VertexAttachment, Attachment } from "./Attachment";
|
||||
*
|
||||
* See [Point Attachments](http://esotericsoftware.com/spine-point-attachments) in the Spine User Guide. */
|
||||
export class PointAttachment extends VertexAttachment {
|
||||
x: number; y: number; rotation: number;
|
||||
x: number = 0;
|
||||
y: number = 0;
|
||||
rotation: number = 0;
|
||||
|
||||
/** The color of the point attachment as it was in Spine. Available only when nonessential data was exported. Point attachments
|
||||
* are not usually rendered at runtime. */
|
||||
|
||||
@ -64,11 +64,11 @@ export class RegionAttachment extends Attachment implements HasTextureRegion {
|
||||
color = new Color(1, 1, 1, 1);
|
||||
|
||||
/** The name of the texture region for this attachment. */
|
||||
path: string;
|
||||
path: string = null;
|
||||
|
||||
private rendererObject: any;
|
||||
region: TextureRegion;
|
||||
sequence: Sequence;
|
||||
private rendererObject: any = null;
|
||||
region: TextureRegion = null;
|
||||
sequence: Sequence = null;
|
||||
|
||||
/** For each of the 4 vertices, a pair of <code>x,y</code> values that is the local position of the vertex.
|
||||
*
|
||||
|
||||
@ -12,6 +12,8 @@
|
||||
],
|
||||
"declaration": true,
|
||||
"composite": true,
|
||||
"moduleResolution": "node",
|
||||
"moduleResolution": "node"
|
||||
/*"strictNullChecks": true,
|
||||
"strictPropertyInitialization": true*/
|
||||
}
|
||||
}
|
||||
@ -63,7 +63,14 @@ namespace Spine.Unity {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a runtime AtlasAsset. Only providing the textures is slower because it has to search for atlas page matches. <seealso cref="Spine.Unity.SpineAtlasAsset.CreateRuntimeInstance(TextAsset, Material[], bool)"/></summary>
|
||||
/// Creates a runtime AtlasAsset. Only providing the textures is slower
|
||||
/// because it has to search for atlas page matches.
|
||||
/// </summary>
|
||||
/// <param name="textures">An array of all textures referenced in the provided <c>atlasText</c>
|
||||
/// atlas asset JSON file. When procedurally creating textures, each <c>Texture.name</c>
|
||||
/// needs to be set to the atlas page texture filename without the .png extension,
|
||||
/// e.g. 'my_skeleton' if the png filename listed in the atlas asset file is 'my_skeleton.png'.</param>
|
||||
/// <seealso cref="Spine.Unity.SpineAtlasAsset.CreateRuntimeInstance(TextAsset, Material[], bool)"/>
|
||||
public static SpineAtlasAsset CreateRuntimeInstance (TextAsset atlasText, Texture2D[] textures, Material materialPropertySource, bool initialize) {
|
||||
// Get atlas page names.
|
||||
string atlasString = atlasText.text;
|
||||
@ -103,7 +110,12 @@ namespace Spine.Unity {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a runtime AtlasAsset. Only providing the textures is slower because it has to search for atlas page matches. <seealso cref="Spine.Unity.AtlasAssetBase.CreateRuntimeInstance(TextAsset, Material[], bool)"/></summary>
|
||||
/// Creates a runtime AtlasAsset. Only providing the textures is slower because it has to search for atlas page matches.
|
||||
/// <param name="textures">An array of all textures referenced in the provided <c>atlasText</c>
|
||||
/// atlas asset JSON file. When procedurally creating textures, each <c>Texture.name</c>
|
||||
/// needs to be set to the atlas page texture filename without the .png extension,
|
||||
/// e.g. 'my_skeleton' if the png filename listed in the atlas asset file is 'my_skeleton.png'.</param>
|
||||
/// <seealso cref="Spine.Unity.AtlasAssetBase.CreateRuntimeInstance(TextAsset, Material[], bool)"/></summary>
|
||||
public static SpineAtlasAsset CreateRuntimeInstance (TextAsset atlasText, Texture2D[] textures, Shader shader, bool initialize) {
|
||||
if (shader == null)
|
||||
shader = Shader.Find("Spine/Skeleton");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user