[ts] Port to 4.3 (WIP) - Format.

This commit is contained in:
Davide Tantillo 2025-06-10 17:42:39 +02:00
parent d7212370f6
commit 59d138124d
9 changed files with 35 additions and 35 deletions

View File

@ -283,7 +283,7 @@ export interface SlotTimeline {
slotIndex: number;
}
export function isSlotTimeline(obj: any): obj is SlotTimeline {
export function isSlotTimeline (obj: any): obj is SlotTimeline {
return typeof obj === 'object' && obj !== null && typeof obj.slotIndex === 'number';
}
@ -436,7 +436,7 @@ export abstract class CurveTimeline1 extends CurveTimeline {
}
}
getAbsoluteValue(time: number, alpha: number, blend: MixBlend, current: number, setup: number, value?: number) {
getAbsoluteValue (time: number, alpha: number, blend: MixBlend, current: number, setup: number, value?: number) {
if (value === undefined)
return this.getAbsoluteValue1(time, alpha, blend, current, setup);
else
@ -543,7 +543,7 @@ export abstract class BoneTimeline2 extends CurveTimeline implements BoneTimelin
if (bone.active) this.apply1(appliedPose ? bone.applied : bone.pose, bone.data.setup, time, alpha, blend, direction);
}
protected abstract apply1 (pose: BoneLocal, setup: BoneLocal, time: number, alpha:number, blend: MixBlend,
protected abstract apply1 (pose: BoneLocal, setup: BoneLocal, time: number, alpha: number, blend: MixBlend,
direction: MixDirection): void;
}
@ -552,7 +552,7 @@ export interface BoneTimeline {
boneIndex: number;
}
export function isBoneTimeline(obj: any): obj is BoneTimeline {
export function isBoneTimeline (obj: any): obj is BoneTimeline {
return typeof obj === 'object' && obj !== null && typeof obj.boneIndex === 'number';
}
@ -571,7 +571,7 @@ export abstract class BoneTimeline1 extends CurveTimeline1 implements BoneTimeli
if (bone.active) this.apply1(appliedPose ? bone.applied : bone.pose, bone.data.setup, time, alpha, blend, direction);
}
protected abstract apply1 (pose: BoneLocal, setup: BoneLocal, time: number, alpha:number, blend: MixBlend,
protected abstract apply1 (pose: BoneLocal, setup: BoneLocal, time: number, alpha: number, blend: MixBlend,
direction: MixDirection): void;
}
@ -581,7 +581,7 @@ export class RotateTimeline extends BoneTimeline1 {
super(frameCount, bezierCount, boneIndex, Property.rotate);
}
apply1 (pose: BoneLocal, setup: BoneLocal, time: number, alpha:number, blend: MixBlend, direction: MixDirection) {
apply1 (pose: BoneLocal, setup: BoneLocal, time: number, alpha: number, blend: MixBlend, direction: MixDirection) {
pose.rotation = this.getRelativeValue(time, alpha, blend, pose.rotation, setup.rotation);
}
}
@ -592,7 +592,7 @@ export class TranslateTimeline extends BoneTimeline2 {
super(frameCount, bezierCount, boneIndex, Property.x, Property.y);
}
apply1 (pose: BoneLocal, setup: BoneLocal, time: number, alpha:number, blend: MixBlend,direction: MixDirection) {
apply1 (pose: BoneLocal, setup: BoneLocal, time: number, alpha: number, blend: MixBlend, direction: MixDirection) {
let frames = this.frames;
if (time < frames[0]) {
switch (blend) {
@ -651,7 +651,7 @@ export class TranslateXTimeline extends BoneTimeline1 {
super(frameCount, bezierCount, boneIndex, Property.x);
}
protected apply1 (pose: BoneLocal, setup: BoneLocal, time: number, alpha:number, blend: MixBlend,direction: MixDirection) {
protected apply1 (pose: BoneLocal, setup: BoneLocal, time: number, alpha: number, blend: MixBlend, direction: MixDirection) {
pose.x = this.getRelativeValue(time, alpha, blend, pose.x, setup.x);
}
}
@ -662,7 +662,7 @@ export class TranslateYTimeline extends BoneTimeline1 {
super(frameCount, bezierCount, boneIndex, Property.y);
}
protected apply1 (pose: BoneLocal, setup: BoneLocal, time: number, alpha:number, blend: MixBlend,direction: MixDirection) {
protected apply1 (pose: BoneLocal, setup: BoneLocal, time: number, alpha: number, blend: MixBlend, direction: MixDirection) {
pose.y = this.getRelativeValue(time, alpha, blend, pose.y, setup.y);
}
}
@ -673,7 +673,7 @@ export class ScaleTimeline extends BoneTimeline2 {
super(frameCount, bezierCount, boneIndex, Property.scaleX, Property.scaleY);
}
protected apply1 (pose: BoneLocal, setup: BoneLocal, time: number, alpha:number, blend: MixBlend, direction: MixDirection) {
protected apply1 (pose: BoneLocal, setup: BoneLocal, time: number, alpha: number, blend: MixBlend, direction: MixDirection) {
let frames = this.frames;
if (time < frames[0]) {
switch (blend) {
@ -770,7 +770,7 @@ export class ScaleXTimeline extends BoneTimeline1 {
super(frameCount, bezierCount, boneIndex, Property.scaleX);
}
protected apply1 (pose: BoneLocal, setup: BoneLocal, time: number, alpha:number, blend: MixBlend,direction: MixDirection) {
protected apply1 (pose: BoneLocal, setup: BoneLocal, time: number, alpha: number, blend: MixBlend, direction: MixDirection) {
pose.scaleX = this.getScaleValue(time, alpha, blend, direction, pose.scaleX, setup.scaleX);
}
}
@ -781,7 +781,7 @@ export class ScaleYTimeline extends BoneTimeline1 {
super(frameCount, bezierCount, boneIndex, Property.scaleY);
}
protected apply1 (pose: BoneLocal, setup: BoneLocal, time: number, alpha:number, blend: MixBlend,direction: MixDirection) {
protected apply1 (pose: BoneLocal, setup: BoneLocal, time: number, alpha: number, blend: MixBlend, direction: MixDirection) {
pose.scaleY = this.getScaleValue(time, alpha, blend, direction, pose.scaleY, setup.scaleY);
}
}
@ -792,7 +792,7 @@ export class ShearTimeline extends BoneTimeline2 {
super(frameCount, bezierCount, boneIndex, Property.shearX, Property.shearY);
}
protected apply1 (pose: BoneLocal, setup: BoneLocal, time: number, alpha:number, blend: MixBlend,direction: MixDirection) {
protected apply1 (pose: BoneLocal, setup: BoneLocal, time: number, alpha: number, blend: MixBlend, direction: MixDirection) {
let frames = this.frames;
if (time < frames[0]) {
switch (blend) {
@ -851,7 +851,7 @@ export class ShearXTimeline extends BoneTimeline1 {
super(frameCount, bezierCount, boneIndex, Property.shearX);
}
protected apply1 (pose: BoneLocal, setup: BoneLocal, time: number, alpha:number, blend: MixBlend,direction: MixDirection) {
protected apply1 (pose: BoneLocal, setup: BoneLocal, time: number, alpha: number, blend: MixBlend, direction: MixDirection) {
pose.shearX = this.getRelativeValue(time, alpha, blend, pose.shearX, setup.shearX);
}
}
@ -862,7 +862,7 @@ export class ShearYTimeline extends BoneTimeline1 {
super(frameCount, bezierCount, boneIndex, Property.shearY);
}
protected apply1 (pose: BoneLocal, setup: BoneLocal, time: number, alpha:number, blend: MixBlend,direction: MixDirection) {
protected apply1 (pose: BoneLocal, setup: BoneLocal, time: number, alpha: number, blend: MixBlend, direction: MixDirection) {
pose.shearY = this.getRelativeValue(time, alpha, blend, pose.shearY, setup.shearY);
}
}
@ -957,7 +957,7 @@ export class RGBATimeline extends SlotCurveTimeline {
switch (blend) {
case MixBlend.setup: color.setFromColor(setup); break;
case MixBlend.first: color.add((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha,
(setup.a - color.a) * alpha); break;
(setup.a - color.a) * alpha); break;
}
return;
}
@ -1228,7 +1228,7 @@ export class RGBA2Timeline extends SlotCurveTimeline {
}
/** Changes a slot's {@link SlotPose.color} and {@link SlotPose.darkColor} for two color tinting. */
export class RGB2Timeline extends SlotCurveTimeline {
export class RGB2Timeline extends SlotCurveTimeline {
constructor (frameCount: number, bezierCount: number, slotIndex: number) {
super(frameCount, bezierCount, slotIndex, //
Property.rgb + "|" + slotIndex, //
@ -1826,7 +1826,7 @@ export interface ConstraintTimeline {
readonly constraintIndex: number;
}
export function isConstraintTimeline(obj: any): obj is ConstraintTimeline {
export function isConstraintTimeline (obj: any): obj is ConstraintTimeline {
return typeof obj === 'object' && obj !== null && typeof obj.constraintIndex === 'number';
}
@ -2103,11 +2103,11 @@ export class PathConstraintSpacingTimeline extends ConstraintTimeline1 {
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend,
direction: MixDirection, appliedPose: boolean) {
const constraint = skeleton.constraints[this.constraintIndex];
if (constraint.active) {
const pose = appliedPose ? constraint.applied : constraint.pose;
pose.spacing = this.getAbsoluteValue(time, alpha, blend, pose.spacing, constraint.data.setup.spacing);
}
const constraint = skeleton.constraints[this.constraintIndex];
if (constraint.active) {
const pose = appliedPose ? constraint.applied : constraint.pose;
pose.spacing = this.getAbsoluteValue(time, alpha, blend, pose.spacing, constraint.data.setup.spacing);
}
}
}

View File

@ -73,9 +73,9 @@ export class BoneLocal implements Pose<BoneLocal> {
this.y = y;
}
setScale(scaleX: number, scaleY: number): void;
setScale(scale: number): void;
setScale(scaleOrX: number, scaleY?: number): void {
setScale (scaleX: number, scaleY: number): void;
setScale (scale: number): void;
setScale (scaleOrX: number, scaleY?: number): void {
this.scaleX = scaleOrX;
this.scaleY = scaleY === undefined ? scaleOrX : scaleY;
}

View File

@ -280,19 +280,19 @@ export class BonePose extends BoneLocal implements Update {
if (this.local === skeleton._update) this.updateLocalTransform(skeleton);
}
modifyLocal (skeleton: Skeleton): void {
modifyLocal (skeleton: Skeleton): void {
if (this.local === skeleton._update) this.updateLocalTransform(skeleton);
this.world = 0;
this.resetWorld(skeleton._update);
}
modifyWorld (update: number): void {
modifyWorld (update: number): void {
this.local = update;
this.world = update;
this.resetWorld(update);
}
resetWorld (update: number): void {
resetWorld (update: number): void {
const children = this.bone.children;
for (let i = 0, n = children.length; i < n; i++) {
const child = children[i].applied;

View File

@ -110,7 +110,7 @@ export class IkConstraint extends Constraint<IkConstraint, IkConstraintData, IkC
this.apply1(skeleton, boneOrParent, targetXorChild, targetYOrTargetX, compressOrTargetY as boolean, stretchOrBendDir as boolean, uniformOrStretch, mixOrUniform as number);
else
this.apply2(skeleton, boneOrParent, targetXorChild as BonePose, targetYOrTargetX, compressOrTargetY as number, stretchOrBendDir as number,
uniformOrStretch, mixOrUniform as boolean, softness as number, mix as number);
uniformOrStretch, mixOrUniform as boolean, softness as number, mix as number);
}
private static apply1 (skeleton: Skeleton, bone: BonePose, targetX: number, targetY: number, compress: boolean, stretch: boolean, uniform: boolean, mix: number) {

View File

@ -46,7 +46,7 @@ export class PathConstraintData extends ConstraintData<PathConstraint, PathConst
public set slot (slotData: SlotData) { this._slot = slotData; }
public get slot () {
if (!this._slot) throw new Error("SlotData not set.")
else return this._slot;
else return this._slot;
}
private _slot: SlotData | null = null;

View File

@ -127,7 +127,7 @@ export class PhysicsConstraint extends Constraint<PhysicsConstraint, PhysicsCons
return;
case Physics.reset:
this.reset(skeleton);
// Fall through.
// Fall through.
case Physics.update:
const delta = Math.max(skeleton.time - this.lastTime, 0), aa = this.remaining;
this.remaining += delta;

View File

@ -42,7 +42,7 @@ export class PhysicsConstraintData extends ConstraintData<PhysicsConstraint, Phy
public set bone (boneData: BoneData) { this._bone = boneData; }
public get bone () {
if (!this._bone) throw new Error("BoneData not set.")
else return this._bone;
else return this._bone;
}
private _bone: BoneData | null = null;

View File

@ -243,7 +243,7 @@ export class Skeleton {
* <p>
* See <a href="https://esotericsoftware.com/spine-runtime-skeletons#World-transforms">World transforms</a> in the Spine
* Runtimes Guide. */
updateWorldTransform(physics: Physics): void {
updateWorldTransform (physics: Physics): void {
this._update++;
const resetCache = this.resetCache;

View File

@ -46,7 +46,7 @@ export class TransformConstraintData extends ConstraintData<TransformConstraint,
public set source (source: BoneData) { this._source = source; }
public get source () {
if (!this._source) throw new Error("BoneData not set.")
else return this._source;
else return this._source;
}
private _source: BoneData | null = null;