fix(motion): stop a long departure from playing for seventeen seconds
Exit timing was linear in path length with no ceiling, so the longest route in the shipped set animated for 17.4s and 19% of all departures ran past two seconds. MOTION already carried exitMaxTravelMs and exitLongMaxMs for this; nothing read them. Below the knee nothing changes — every piece still cruises at the same speed, which is the property the old test protected and the reason motion reads as physical. Past it the piece accelerates rather than taking longer, approaching a ceiling. Length is still legible: longer routes still play longer, just with a compressing tail. The test now states the rule it is protecting instead of "no duration cap": constant speed below the knee, a bounded and monotone tail above it. labs/exit-timing plays the same real route side by side, uncapped against a candidate setting, with knee and ceiling on sliders — the numbers say 3.5s but only watching it says whether that is right. Defaults are provisional at 2.4s / 3.2s pending that call. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+19
-2
@@ -52,9 +52,11 @@ test('motion ramps gently at both ends, never reverses or overshoots',async()=>{
|
||||
});
|
||||
|
||||
|
||||
test('curved and long routes share the same cruising speed without a duration cap',async()=>{
|
||||
test('routes below the knee cruise at one speed; longer ones accelerate instead of dragging',async()=>{
|
||||
const {exitTiming,travelProgress}=await import('../src/exit-animation.js');
|
||||
for(const distance of [1,5,15,30]){
|
||||
// Below the knee the old guarantee still holds exactly: same cruising speed
|
||||
// for every piece, no cap. distance*120 stays under 2400ms up to distance 20.
|
||||
for(const distance of [1,5,15]){
|
||||
const timing=exitTiming({travelPoints:[{x:0,y:0},{x:distance,y:0}],steps:[]});
|
||||
assert.equal(timing.travelMs,distance*120+Math.min(80,distance*40));
|
||||
const t=timing.travelMs*.5,dt=1;
|
||||
@@ -62,6 +64,21 @@ test('curved and long routes share the same cruising speed without a duration ca
|
||||
assert.ok(Math.abs(speed-1/120)<1e-9);
|
||||
assert.equal(travelProgress(0,timing.travelMs),0);assert.equal(travelProgress(1,timing.travelMs),1);
|
||||
assert.ok(Math.abs(timing.duration-timing.travelMs-180)<1e-9);
|
||||
assert.equal(timing.capped,false);
|
||||
}
|
||||
// Past the knee the piece speeds up so the journey stays watchable. Uncapped
|
||||
// linear timing put a single departure at seventeen seconds.
|
||||
const long=exitTiming({travelPoints:[{x:0,y:0},{x:150,y:0}],steps:[]});
|
||||
assert.equal(long.capped,true);
|
||||
assert.ok(long.duration<4200,`一条超长路线不该超过 4.2s,实际 ${long.duration}`);
|
||||
assert.ok(long.duration>exitTiming({travelPoints:[{x:0,y:0},{x:20,y:0}],steps:[]}).duration,
|
||||
'再长的路线仍然要比中等路线久,长度感不能丢');
|
||||
// Monotone: a longer route never plays shorter than a shorter one.
|
||||
let prev=0;
|
||||
for(const d of [1,5,15,25,40,80,150,400]){
|
||||
const ms=exitTiming({travelPoints:[{x:0,y:0},{x:d,y:0}],steps:[]}).duration;
|
||||
assert.ok(ms>=prev,`距离 ${d} 的时长 ${ms} 不该短于更短的路线 ${prev}`);
|
||||
prev=ms;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user