From cb7872274d441c414e0b0659dc507b73ea3dd8d5 Mon Sep 17 00:00:00 2001 From: Davide Tantillo Date: Wed, 11 Jun 2025 15:09:56 +0200 Subject: [PATCH] [ts] 4.3 porting WIP. --- spine-ts/spine-core/src/Animation.ts | 25 ++--------------------- spine-ts/spine-core/src/AnimationState.ts | 16 ++++++++------- 2 files changed, 11 insertions(+), 30 deletions(-) diff --git a/spine-ts/spine-core/src/Animation.ts b/spine-ts/spine-core/src/Animation.ts index d627bd024..c945918ad 100644 --- a/spine-ts/spine-core/src/Animation.ts +++ b/spine-ts/spine-core/src/Animation.ts @@ -245,31 +245,10 @@ export abstract class Timeline { abstract apply (skeleton: Skeleton, lastTime: number, time: number, events: Array | null, alpha: number, blend: MixBlend, direction: MixDirection, appliedPose: boolean): void; - /** Linear search using a stride of 1. + /** Linear search using the specified stride (default 1). * @param time Must be >= the first value in frames. * @return The index of the first value <= time. */ - static search (frames: NumberArrayLike, time: number): number; - - /** Linear search using the specified stride. - * @param time Must be >= the first value in frames. - * @return The index of the first value <= time. */ - static search (frames: NumberArrayLike, time: number, step: number): number; - - static search (frames: NumberArrayLike, time: number, step?: number): number { - if (step === undefined) - return Timeline.search1(frames, time); - else - return Timeline.search2(frames, time, step); - } - - private static search1 (frames: NumberArrayLike, time: number) { - let n = frames.length; - for (let i = 1; i < n; i++) - if (frames[i] > time) return i - 1; - return n - 1; - } - - private static search2 (frames: NumberArrayLike, time: number, step: number) { + static search (frames: NumberArrayLike, time: number, step = 1) { let n = frames.length; for (let i = step; i < n; i += step) if (frames[i] > time) return i - step; diff --git a/spine-ts/spine-core/src/AnimationState.ts b/spine-ts/spine-core/src/AnimationState.ts index a3a587ea0..ddb011c38 100644 --- a/spine-ts/spine-core/src/AnimationState.ts +++ b/spine-ts/spine-core/src/AnimationState.ts @@ -989,15 +989,17 @@ export class TrackEntry { * entry minus the specified mix duration plus the specified delay (ie the mix ends at * (delay = 0) or before (delay < 0) the previous track entry duration). If the previous * entry is looping, its next loop completion is used instead of its duration. */ - setMixDuration (mixDuration: number, delay: number) { + setMixDuration (mixDuration: number, delay?: number) { this.mixDuration = mixDuration; - if (delay <= 0) { - if (this.previous != null) - delay = Math.max(delay + this.previous.getTrackComplete() - mixDuration, 0); - else - delay = 0; + if (delay !== undefined) { + if (delay <= 0) { + if (this.previous != null) + delay = Math.max(delay + this.previous.getTrackComplete() - mixDuration, 0); + else + delay = 0; + } + this.delay = delay; } - this.delay = delay; } /** Controls how properties keyed in the animation are mixed with lower tracks. Defaults to {@link MixBlend#replace}, which