[ts] 4.3 porting WIP.

This commit is contained in:
Davide Tantillo 2025-06-11 15:09:56 +02:00
parent 5347aed45a
commit cb7872274d
2 changed files with 11 additions and 30 deletions

View File

@ -245,31 +245,10 @@ export abstract class Timeline {
abstract apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event> | null, alpha: number, abstract apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event> | null, alpha: number,
blend: MixBlend, direction: MixDirection, appliedPose: boolean): void; 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 <code>frames</code>. * @param time Must be >= the first value in <code>frames</code>.
* @return The index of the first value <= <code>time</code>. */ * @return The index of the first value <= <code>time</code>. */
static search (frames: NumberArrayLike, time: number): number; static search (frames: NumberArrayLike, time: number, step = 1) {
/** Linear search using the specified stride.
* @param time Must be >= the first value in <code>frames</code>.
* @return The index of the first value <= <code>time</code>. */
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) {
let n = frames.length; let n = frames.length;
for (let i = step; i < n; i += step) for (let i = step; i < n; i += step)
if (frames[i] > time) return i - step; if (frames[i] > time) return i - step;

View File

@ -989,15 +989,17 @@ export class TrackEntry {
* entry minus the specified mix duration plus the specified <code>delay</code> (ie the mix ends at * entry minus the specified mix duration plus the specified <code>delay</code> (ie the mix ends at
* (<code>delay</code> = 0) or before (<code>delay</code> < 0) the previous track entry duration). If the previous * (<code>delay</code> = 0) or before (<code>delay</code> < 0) the previous track entry duration). If the previous
* entry is looping, its next loop completion is used instead of its duration. */ * 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; this.mixDuration = mixDuration;
if (delay <= 0) { if (delay !== undefined) {
if (this.previous != null) if (delay <= 0) {
delay = Math.max(delay + this.previous.getTrackComplete() - mixDuration, 0); if (this.previous != null)
else delay = Math.max(delay + this.previous.getTrackComplete() - mixDuration, 0);
delay = 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 /** Controls how properties keyed in the animation are mixed with lower tracks. Defaults to {@link MixBlend#replace}, which