Ping-pong turns on the last key, and stepped rows hold the key they last passed (#112)
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f68941fa3a
commit
cc14988338
7 files changed
+72
-22
No files matched your search
@@ -88,12 +88,37 @@ describe('where the playhead stands', () => {
|
||||
expect(playheadAt(10, 10, 'loop', 1.05).frame).toBeCloseTo(0.5);
|
||||
});
|
||||
|
||||
it('finishes only in the two once modes, and ping-pong turns at the end', () => {
|
||||
expect(playheadAt(10, 10, 'once', 1.2)).toEqual({ frame: 10, finished: true });
|
||||
it('finishes only in the two once modes, and ping-pong turns on the last key', () => {
|
||||
expect(playheadAt(10, 10, 'once', 1.2)).toEqual({ frame: 10, finished: true, reverse: false });
|
||||
expect(playheadAt(10, 10, 'once-reset', 0.5).finished).toBe(false);
|
||||
expect(playheadAt(10, 10, 'pingpong', 1.5).frame).toBeCloseTo(5);
|
||||
expect(playheadAt(10, 10, 'pingpong', 0.95)).toMatchObject({ reverse: true });
|
||||
expect(playheadAt(10, 10, 'pingpong', 0.95).frame).toBeCloseTo(8.5);
|
||||
expect(playheadAt(10, 10, 'pingpong', 1.5).frame).toBeCloseTo(3);
|
||||
expect(playheadAt(10, 10, 'loop', 30).finished).toBe(false);
|
||||
});
|
||||
|
||||
it('shows each ping-pong frame once per bounce, the two ends included (#112)', () => {
|
||||
const row = keys(...Array.from({ length: 10 }, (_, i): [number, string] => [i, `f${i}`]));
|
||||
const shown: string[] = [];
|
||||
for (let tick = 0; tick < 18 * 6; tick++) {
|
||||
const head = playheadAt(10, 10, 'pingpong', tick / 60);
|
||||
if (tick % 6 === 0) shown.push(trackValueAt(row, 'texture', head.frame, head.reverse) as string);
|
||||
}
|
||||
expect(shown.join(' ')).toBe('f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 f8 f7 f6 f5 f4 f3 f2 f1');
|
||||
expect(trackValueAt(row, 'texture', playheadAt(10, 10, 'pingpong', 1.8).frame)).toBe('f0');
|
||||
});
|
||||
|
||||
it('turns a blended ping-pong value on the last key without standing still', () => {
|
||||
const row = keys([0, 0], [9, 90]);
|
||||
const at = (time: number) => {
|
||||
const head = playheadAt(10, 10, 'pingpong', time);
|
||||
return Number(trackValueAt(row, 'number', head.frame, head.reverse));
|
||||
};
|
||||
expect(at(0.85)).toBeCloseTo(85);
|
||||
expect(at(0.9)).toBeCloseTo(90);
|
||||
expect(at(0.95)).toBeCloseTo(85);
|
||||
expect(at(1.8)).toBeCloseTo(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('the value of a row', () => {
|
||||
|
||||
Reference in new issue
Block a user