From 0e2fe5c6c946617cfa2117745dcf74967fc50231 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Mon, 13 Dec 2021 17:24:10 +0100 Subject: [PATCH 1/3] [unity] Minor: documentation improvement of SpineAtlasAsset.CreateRuntimeInstance method description. --- .../spine-unity/Asset Types/SpineAtlasAsset.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SpineAtlasAsset.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SpineAtlasAsset.cs index de458b665..41354b957 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SpineAtlasAsset.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SpineAtlasAsset.cs @@ -63,7 +63,14 @@ namespace Spine.Unity { } /// - /// Creates a runtime AtlasAsset. Only providing the textures is slower because it has to search for atlas page matches. + /// Creates a runtime AtlasAsset. Only providing the textures is slower + /// because it has to search for atlas page matches. + /// + /// An array of all textures referenced in the provided atlasText + /// atlas asset JSON file. When procedurally creating textures, each Texture.name + /// 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'. + /// 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 { } /// - /// Creates a runtime AtlasAsset. Only providing the textures is slower because it has to search for atlas page matches. + /// Creates a runtime AtlasAsset. Only providing the textures is slower because it has to search for atlas page matches. + /// An array of all textures referenced in the provided atlasText + /// atlas asset JSON file. When procedurally creating textures, each Texture.name + /// 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'. + /// public static SpineAtlasAsset CreateRuntimeInstance (TextAsset atlasText, Texture2D[] textures, Shader shader, bool initialize) { if (shader == null) shader = Shader.Find("Spine/Skeleton"); From 44e34cb26445d2ed040f0e0567560632947a6263 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Wed, 15 Dec 2021 15:00:19 +0100 Subject: [PATCH 2/3] [ts] Fixes #2003, ensure all fields are initialized as per reference implementation. --- spine-ts/spine-core/src/Animation.ts | 24 ++++---- spine-ts/spine-core/src/AnimationState.ts | 55 ++++++++++--------- spine-ts/spine-core/src/AnimationStateData.ts | 2 +- spine-ts/spine-core/src/AssetManagerBase.ts | 2 +- .../spine-core/src/AtlasAttachmentLoader.ts | 2 +- spine-ts/spine-core/src/Bone.ts | 6 +- spine-ts/spine-core/src/BoneData.ts | 8 +-- spine-ts/spine-core/src/Event.ts | 14 ++--- spine-ts/spine-core/src/EventData.ts | 14 ++--- spine-ts/spine-core/src/IkConstraint.ts | 6 +- spine-ts/spine-core/src/IkConstraintData.ts | 2 +- spine-ts/spine-core/src/PathConstraint.ts | 6 +- spine-ts/spine-core/src/PathConstraintData.ts | 14 ++--- spine-ts/spine-core/src/Skeleton.ts | 18 +++--- spine-ts/spine-core/src/SkeletonBinary.ts | 2 +- spine-ts/spine-core/src/SkeletonData.ts | 20 +++---- spine-ts/spine-core/src/SkeletonJson.ts | 2 +- spine-ts/spine-core/src/Skin.ts | 4 +- spine-ts/spine-core/src/Slot.ts | 14 ++--- spine-ts/spine-core/src/SlotData.ts | 12 ++-- spine-ts/spine-core/src/TextureAtlas.ts | 36 ++++++------ .../spine-core/src/TransformConstraint.ts | 6 +- .../spine-core/src/TransformConstraintData.ts | 2 +- .../spine-core/src/attachments/Attachment.ts | 4 +- .../src/attachments/ClippingAttachment.ts | 2 +- .../src/attachments/MeshAttachment.ts | 20 +++---- .../src/attachments/PathAttachment.ts | 2 +- .../src/attachments/PointAttachment.ts | 4 +- .../src/attachments/RegionAttachment.ts | 6 +- spine-ts/tsconfig.base.json | 4 +- 30 files changed, 159 insertions(+), 154 deletions(-) diff --git a/spine-ts/spine-core/src/Animation.ts b/spine-ts/spine-core/src/Animation.ts index 9333c0cba..0f5964a7c 100644 --- a/spine-ts/spine-core/src/Animation.ts +++ b/spine-ts/spine-core/src/Animation.ts @@ -40,8 +40,8 @@ import { Event } from "./Event"; export class Animation { /** The animation's name, which is unique across all animations in the skeleton. */ name: string; - timelines: Array; - timelineIds: StringSet; + timelines: Array = null; + timelineIds: StringSet = null; /** The duration of the animation in seconds, which is the highest time of all keys in the timeline. */ duration: number; @@ -151,8 +151,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; @@ -204,7 +204,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); @@ -1426,10 +1426,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; + vertices: Array = null; constructor (frameCount: number, bezierCount: number, slotIndex: number, attachment: VertexAttachment) { super(frameCount, bezierCount, [ @@ -1681,7 +1681,7 @@ export class EventTimeline extends Timeline { static propertyIds = ["" + Property.event]; /** The event for each key frame. */ - events: Array; + events: Array = null; constructor (frameCount: number) { super(frameCount, EventTimeline.propertyIds); @@ -1734,7 +1734,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>; + drawOrders: Array> = null; constructor (frameCount: number) { super(frameCount, DrawOrderTimeline.propertyIds); @@ -1780,7 +1780,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, [ @@ -1878,7 +1878,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, [ @@ -1991,7 +1991,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); diff --git a/spine-ts/spine-core/src/AnimationState.ts b/spine-ts/spine-core/src/AnimationState.ts index 4dac3da2d..e02fd90c6 100644 --- a/spine-ts/spine-core/src/AnimationState.ts +++ b/spine-ts/spine-core/src/AnimationState.ts @@ -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(); @@ -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 = []; drainDisabled = false; - animState: AnimationState; + animState: AnimationState = null; constructor (animState: AnimationState) { this.animState = animState; diff --git a/spine-ts/spine-core/src/AnimationStateData.ts b/spine-ts/spine-core/src/AnimationStateData.ts index 8a68b7c73..def489f9c 100644 --- a/spine-ts/spine-core/src/AnimationStateData.ts +++ b/spine-ts/spine-core/src/AnimationStateData.ts @@ -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 = {}; diff --git a/spine-ts/spine-core/src/AssetManagerBase.ts b/spine-ts/spine-core/src/AssetManagerBase.ts index a852a40ff..c68517603 100644 --- a/spine-ts/spine-core/src/AssetManagerBase.ts +++ b/spine-ts/spine-core/src/AssetManagerBase.ts @@ -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 = {}; diff --git a/spine-ts/spine-core/src/AtlasAttachmentLoader.ts b/spine-ts/spine-core/src/AtlasAttachmentLoader.ts index c61dd0aea..56e808154 100644 --- a/spine-ts/spine-core/src/AtlasAttachmentLoader.ts +++ b/spine-ts/spine-core/src/AtlasAttachmentLoader.ts @@ -42,7 +42,7 @@ import { TextureAtlas } from "./TextureAtlas"; * 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; diff --git a/spine-ts/spine-core/src/Bone.ts b/spine-ts/spine-core/src/Bone.ts index 548d8adaf..ab2f85d2a 100644 --- a/spine-ts/spine-core/src/Bone.ts +++ b/spine-ts/spine-core/src/Bone.ts @@ -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(); diff --git a/spine-ts/spine-core/src/BoneData.ts b/spine-ts/spine-core/src/BoneData.ts index a236d2494..cb65b4836 100644 --- a/spine-ts/spine-core/src/BoneData.ts +++ b/spine-ts/spine-core/src/BoneData.ts @@ -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; diff --git a/spine-ts/spine-core/src/Event.ts b/spine-ts/spine-core/src/Event.ts index 720768310..dc73e034f 100644 --- a/spine-ts/spine-core/src/Event.ts +++ b/spine-ts/spine-core/src/Event.ts @@ -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."); diff --git a/spine-ts/spine-core/src/EventData.ts b/spine-ts/spine-core/src/EventData.ts index 5429b9ccd..57b986bf5 100644 --- a/spine-ts/spine-core/src/EventData.ts +++ b/spine-ts/spine-core/src/EventData.ts @@ -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; diff --git a/spine-ts/spine-core/src/IkConstraint.ts b/spine-ts/spine-core/src/IkConstraint.ts index eca4444a5..f403449fc 100644 --- a/spine-ts/spine-core/src/IkConstraint.ts +++ b/spine-ts/spine-core/src/IkConstraint.ts @@ -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; + bones: Array = 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; diff --git a/spine-ts/spine-core/src/IkConstraintData.ts b/spine-ts/spine-core/src/IkConstraintData.ts index 5743a80d0..5a1893840 100644 --- a/spine-ts/spine-core/src/IkConstraintData.ts +++ b/spine-ts/spine-core/src/IkConstraintData.ts @@ -39,7 +39,7 @@ export class IkConstraintData extends ConstraintData { bones = new Array(); /** 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; diff --git a/spine-ts/spine-core/src/PathConstraint.ts b/spine-ts/spine-core/src/PathConstraint.ts index be5f95b0e..917fce637 100644 --- a/spine-ts/spine-core/src/PathConstraint.ts +++ b/spine-ts/spine-core/src/PathConstraint.ts @@ -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; + bones: Array = 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; diff --git a/spine-ts/spine-core/src/PathConstraintData.ts b/spine-ts/spine-core/src/PathConstraintData.ts index b3da75df7..d8c72577e 100644 --- a/spine-ts/spine-core/src/PathConstraintData.ts +++ b/spine-ts/spine-core/src/PathConstraintData.ts @@ -41,25 +41,25 @@ export class PathConstraintData extends ConstraintData { bones = new Array(); /** 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; diff --git a/spine-ts/spine-core/src/Skeleton.ts b/spine-ts/spine-core/src/Skeleton.ts index 1030c27b4..3be52c8f2 100644 --- a/spine-ts/spine-core/src/Skeleton.ts +++ b/spine-ts/spine-core/src/Skeleton.ts @@ -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; + bones: Array = null; /** The skeleton's slots. */ - slots: Array; + slots: Array = 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; + drawOrder: Array = null; /** The skeleton's IK constraints. */ - ikConstraints: Array; + ikConstraints: Array = null; /** The skeleton's transform constraints. */ - transformConstraints: Array; + transformConstraints: Array = null; /** The skeleton's path constraints. */ - pathConstraints: Array; + pathConstraints: Array = null; /** The list of bones and constraints, sorted in the order they should be updated, as computed by {@link #updateCache()}. */ _updateCache = new Array(); /** 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; /** Returns the skeleton's time. This can be used for tracking, such as with Slot {@link Slot#attachmentTime}. *

diff --git a/spine-ts/spine-core/src/SkeletonBinary.ts b/spine-ts/spine-core/src/SkeletonBinary.ts index bd0866d0e..f61e80788 100644 --- a/spine-ts/spine-core/src/SkeletonBinary.ts +++ b/spine-ts/spine-core/src/SkeletonBinary.ts @@ -54,7 +54,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(); constructor (attachmentLoader: AttachmentLoader) { diff --git a/spine-ts/spine-core/src/SkeletonData.ts b/spine-ts/spine-core/src/SkeletonData.ts index 1298eeb74..6204714a9 100644 --- a/spine-ts/spine-core/src/SkeletonData.ts +++ b/spine-ts/spine-core/src/SkeletonData.ts @@ -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(); // 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(); @@ -74,32 +74,32 @@ export class SkeletonData { pathConstraints = new Array(); /** 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. diff --git a/spine-ts/spine-core/src/SkeletonJson.ts b/spine-ts/spine-core/src/SkeletonJson.ts index d28289ef1..9048e84b6 100644 --- a/spine-ts/spine-core/src/SkeletonJson.ts +++ b/spine-ts/spine-core/src/SkeletonJson.ts @@ -48,7 +48,7 @@ import { Utils, Color, NumberArrayLike } from "./Utils"; * [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. diff --git a/spine-ts/spine-core/src/Skin.ts b/spine-ts/spine-core/src/Skin.ts index b58866801..1d7f74425 100644 --- a/spine-ts/spine-core/src/Skin.ts +++ b/spine-ts/spine-core/src/Skin.ts @@ -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>(); bones = Array(); diff --git a/spine-ts/spine-core/src/Slot.ts b/spine-ts/spine-core/src/Slot.ts index dcf6d2f47..3399d47c9 100644 --- a/spine-ts/spine-core/src/Slot.ts +++ b/spine-ts/spine-core/src/Slot.ts @@ -38,24 +38,24 @@ 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; - private attachmentTime: number; + private attachmentTime: number = 0; - attachmentState: number; + attachmentState: number = 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. diff --git a/spine-ts/spine-core/src/SlotData.ts b/spine-ts/spine-core/src/SlotData.ts index c118406c0..3ce6a2ff1 100644 --- a/spine-ts/spine-core/src/SlotData.ts +++ b/spine-ts/spine-core/src/SlotData.ts @@ -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."); diff --git a/spine-ts/spine-core/src/TextureAtlas.ts b/spine-ts/spine-core/src/TextureAtlas.ts index 78b24be50..07d1d4109 100644 --- a/spine-ts/spine-core/src/TextureAtlas.ts +++ b/spine-ts/spine-core/src/TextureAtlas.ts @@ -198,7 +198,7 @@ export class TextureAtlas implements Disposable { } class TextureAtlasReader { - lines: Array; + lines: Array = 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; } diff --git a/spine-ts/spine-core/src/TransformConstraint.ts b/spine-ts/spine-core/src/TransformConstraint.ts index 766c36001..1b1263e56 100644 --- a/spine-ts/spine-core/src/TransformConstraint.ts +++ b/spine-ts/spine-core/src/TransformConstraint.ts @@ -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; + bones: Array = 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; diff --git a/spine-ts/spine-core/src/TransformConstraintData.ts b/spine-ts/spine-core/src/TransformConstraintData.ts index 3c74d87fb..4f9f17f75 100644 --- a/spine-ts/spine-core/src/TransformConstraintData.ts +++ b/spine-ts/spine-core/src/TransformConstraintData.ts @@ -39,7 +39,7 @@ export class TransformConstraintData extends ConstraintData { bones = new Array(); /** The target bone whose world transform will be copied to the constrained bones. */ - target: BoneData; + target: BoneData = null; mixRotate = 0; mixX = 0; diff --git a/spine-ts/spine-core/src/attachments/Attachment.ts b/spine-ts/spine-core/src/attachments/Attachment.ts index b7bb21af6..de349174f 100644 --- a/spine-ts/spine-core/src/attachments/Attachment.ts +++ b/spine-ts/spine-core/src/attachments/Attachment.ts @@ -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; + bones: Array = 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. */ diff --git a/spine-ts/spine-core/src/attachments/ClippingAttachment.ts b/spine-ts/spine-core/src/attachments/ClippingAttachment.ts index f8b1a4b73..9b09b3834 100644 --- a/spine-ts/spine-core/src/attachments/ClippingAttachment.ts +++ b/spine-ts/spine-core/src/attachments/ClippingAttachment.ts @@ -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 diff --git a/spine-ts/spine-core/src/attachments/MeshAttachment.ts b/spine-ts/spine-core/src/attachments/MeshAttachment.ts index 419911f3f..51476fd1f 100644 --- a/spine-ts/spine-core/src/attachments/MeshAttachment.ts +++ b/spine-ts/spine-core/src/attachments/MeshAttachment.ts @@ -37,39 +37,39 @@ import { VertexAttachment, Attachment } from "./Attachment"; * * See [Mesh attachments](http://esotericsoftware.com/spine-meshes) in the Spine User Guide. */ export class MeshAttachment extends VertexAttachment { - 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; + triangles: Array = 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; + edges: Array = null; - private parentMesh: MeshAttachment; + private parentMesh: MeshAttachment = null; tempColor = new Color(0, 0, 0, 0); constructor (name: string) { diff --git a/spine-ts/spine-core/src/attachments/PathAttachment.ts b/spine-ts/spine-core/src/attachments/PathAttachment.ts index 5230fd77e..cccd7dbf5 100644 --- a/spine-ts/spine-core/src/attachments/PathAttachment.ts +++ b/spine-ts/spine-core/src/attachments/PathAttachment.ts @@ -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; + lengths: Array = null; /** If true, the start and end knots are connected. */ closed = false; diff --git a/spine-ts/spine-core/src/attachments/PointAttachment.ts b/spine-ts/spine-core/src/attachments/PointAttachment.ts index 755a550d7..74fd56233 100644 --- a/spine-ts/spine-core/src/attachments/PointAttachment.ts +++ b/spine-ts/spine-core/src/attachments/PointAttachment.ts @@ -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. */ diff --git a/spine-ts/spine-core/src/attachments/RegionAttachment.ts b/spine-ts/spine-core/src/attachments/RegionAttachment.ts index 828a60ffc..f11b88d0b 100644 --- a/spine-ts/spine-core/src/attachments/RegionAttachment.ts +++ b/spine-ts/spine-core/src/attachments/RegionAttachment.ts @@ -61,10 +61,10 @@ export class RegionAttachment extends Attachment { color = new Color(1, 1, 1, 1); /** The name of the texture region for this attachment. */ - path: string; + path: string = null; - rendererObject: any; - region: TextureRegion; + rendererObject: any = null; + region: TextureRegion = null; /** For each of the 4 vertices, a pair of x,y values that is the local position of the vertex. * diff --git a/spine-ts/tsconfig.base.json b/spine-ts/tsconfig.base.json index 354041202..f4f702711 100644 --- a/spine-ts/tsconfig.base.json +++ b/spine-ts/tsconfig.base.json @@ -12,6 +12,8 @@ ], "declaration": true, "composite": true, - "moduleResolution": "node", + "moduleResolution": "node" + /*"strictNullChecks": true, + "strictPropertyInitialization": true*/ } } \ No newline at end of file From 3bace5406ec421e52a92cdb32b34eee48ed02954 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Wed, 15 Dec 2021 15:01:37 +0100 Subject: [PATCH 3/3] [ts] Update version to 4.0.17 --- spine-ts/package-lock.json | 4 ++-- spine-ts/package.json | 2 +- spine-ts/spine-canvas/package.json | 6 +++--- spine-ts/spine-core/package.json | 2 +- spine-ts/spine-player/package.json | 6 +++--- spine-ts/spine-threejs/package.json | 6 +++--- spine-ts/spine-webgl/package.json | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/spine-ts/package-lock.json b/spine-ts/package-lock.json index 92abd3df8..e300edc40 100644 --- a/spine-ts/package-lock.json +++ b/spine-ts/package-lock.json @@ -1,12 +1,12 @@ { "name": "@esotericsoftware/spine-ts", - "version": "4.0.16", + "version": "4.0.17", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@esotericsoftware/spine-ts", - "version": "4.0.16", + "version": "4.0.17", "license": "LicenseRef-LICENSE", "workspaces": [ "spine-core", diff --git a/spine-ts/package.json b/spine-ts/package.json index 81e513c79..5cc15ca8e 100644 --- a/spine-ts/package.json +++ b/spine-ts/package.json @@ -1,6 +1,6 @@ { "name": "@esotericsoftware/spine-ts", - "version": "4.0.16", + "version": "4.0.17", "description": "The official Spine Runtimes for the web.", "files": [ "README.md" diff --git a/spine-ts/spine-canvas/package.json b/spine-ts/spine-canvas/package.json index cc3aa73f9..3f9d4dc6c 100644 --- a/spine-ts/spine-canvas/package.json +++ b/spine-ts/spine-canvas/package.json @@ -1,6 +1,6 @@ { "name": "@esotericsoftware/spine-canvas", - "version": "4.0.16", + "version": "4.0.17", "description": "The official Spine Runtimes for the web.", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -30,6 +30,6 @@ }, "homepage": "https://github.com/esotericsoftware/spine-runtimes#readme", "dependencies": { - "@esotericsoftware/spine-core": "^4.0.15" + "@esotericsoftware/spine-core": "^4.0.17" } -} +} \ No newline at end of file diff --git a/spine-ts/spine-core/package.json b/spine-ts/spine-core/package.json index 538957e84..4e7842718 100644 --- a/spine-ts/spine-core/package.json +++ b/spine-ts/spine-core/package.json @@ -1,6 +1,6 @@ { "name": "@esotericsoftware/spine-core", - "version": "4.0.16", + "version": "4.0.17", "description": "The official Spine Runtimes for the web.", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/spine-ts/spine-player/package.json b/spine-ts/spine-player/package.json index a6537f89b..43dab1eef 100644 --- a/spine-ts/spine-player/package.json +++ b/spine-ts/spine-player/package.json @@ -1,6 +1,6 @@ { "name": "@esotericsoftware/spine-player", - "version": "4.0.16", + "version": "4.0.17", "description": "The official Spine Runtimes for the web.", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -30,6 +30,6 @@ }, "homepage": "https://github.com/esotericsoftware/spine-runtimes#readme", "dependencies": { - "@esotericsoftware/spine-webgl": "^4.0.15" + "@esotericsoftware/spine-webgl": "^4.0.17" } -} +} \ No newline at end of file diff --git a/spine-ts/spine-threejs/package.json b/spine-ts/spine-threejs/package.json index 59687f3ac..1c362abcb 100644 --- a/spine-ts/spine-threejs/package.json +++ b/spine-ts/spine-threejs/package.json @@ -1,6 +1,6 @@ { "name": "@esotericsoftware/spine-threejs", - "version": "4.0.16", + "version": "4.0.17", "description": "The official Spine Runtimes for the web.", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -32,6 +32,6 @@ "dependencies": { "@types/three": "^0.133.1", "three": "^0.133.1", - "@esotericsoftware/spine-core": "^4.0.15" + "@esotericsoftware/spine-core": "^4.0.17" } -} +} \ No newline at end of file diff --git a/spine-ts/spine-webgl/package.json b/spine-ts/spine-webgl/package.json index 6727f6ee9..f40b599f2 100644 --- a/spine-ts/spine-webgl/package.json +++ b/spine-ts/spine-webgl/package.json @@ -1,6 +1,6 @@ { "name": "@esotericsoftware/spine-webgl", - "version": "4.0.16", + "version": "4.0.17", "description": "The official Spine Runtimes for the web.", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -30,6 +30,6 @@ }, "homepage": "https://github.com/esotericsoftware/spine-runtimes#readme", "dependencies": { - "@esotericsoftware/spine-core": "^4.0.16" + "@esotericsoftware/spine-core": "^4.0.17" } } \ No newline at end of file