Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 64 additions & 39 deletions site/preview-v2/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@
// Invalid/canceled operations never touch selection.
const accepted=ops.filter(op=>['CONNECT','ROUTE_ONLY','RETARGET'].includes(op.type)).at(-1);
if(accepted){
if(String(accepted.sourceId)===wireRetractOverlay?.dataset.wireRetract)
stopWireRetraction();
const committed=accepted.edgeId!=null?
wireEdges.find(e=>e.enabled&&e.id===accepted.edgeId&&e.destId===accepted.destId):
wireEdges.find(e=>e.enabled&&e.sourceId===accepted.sourceId&&e.destId===accepted.destId);
Expand Down Expand Up @@ -921,28 +923,32 @@
const WIRE_IMPACT_TRAVEL_MS=520,WIRE_IMPACT_SETTLE_MS=160;
const WIRE_IMPACT_DURATION_MS=WIRE_IMPACT_TRAVEL_MS+WIRE_IMPACT_SETTLE_MS;
function wireImpactPathData(x0,y0,x1,y1,limit,elapsedMs){
const span=Math.abs(x1-x0),ceiling=Math.max(12,Math.min(100,Number(limit)||72));
const span=Math.abs(x1-x0),chord=Math.hypot(x1-x0,y1-y0);
const ceiling=Math.max(12,Math.min(100,Number(limit)||72));
const sag=Math.max(10,Math.min(ceiling,Math.min(ceiling-5,28+Math.sqrt(span)*1.55)));
const c=sag*4/3;
const u=Math.max(0,Math.min(1,elapsedMs/WIRE_IMPACT_TRAVEL_MS));
// Physical launch occurs at the IN end (t=1), never at OUT (t=0).
// Ease-out front makes the receiving plug flick briskly, rather than creep.
// A short physical patch cable has little slack: scale its displacement,
// number of visible lobes AND propagation time, continuously with length.
// Long cables preserve the user-approved V62 520ms whip and end damping.
const length01=Math.max(0,Math.min(1,(chord-95)/300));
const longMix=length01*length01*(3-2*length01);
const travel=360+160*longMix;
const width=.65-.29*longMix; // broad single curl at short distances
const u=Math.max(0,Math.min(1,elapsedMs/travel));
const front=1-Math.pow(1-u,1.45);
const settle=Math.max(0,Math.min(1,(elapsedMs-WIRE_IMPACT_TRAVEL_MS)/WIRE_IMPACT_SETTLE_MS));
const settle=Math.max(0,Math.min(1,(elapsedMs-travel)/WIRE_IMPACT_SETTLE_MS));
const fade=Math.pow(1-settle,2);
const strength=Math.min(22,Math.max(14,Math.sqrt(span)*1.6))*fade;
const amplitude=Math.min(22,Math.max(14,Math.sqrt(span)*1.6))*
(.27+.73*longMix)*fade;
let d='M '+x0.toFixed(1)+' '+y0.toFixed(1);
for(let i=1;i<=64;i++){
const t=i/64,v=1-t;
const x=v*v*v*x0+3*v*v*t*x0+3*v*t*t*x1+t*t*t*x1;
const y=v*v*v*y0+3*v*v*t*(y0+c)+3*v*t*t*(y1+c)+t*t*t*y1;
const distance=1-t; // distance travelled from IN toward OUT
const passed=front-distance; // material behind the advancing wavefront
const distance=1-t,passed=front-distance;
const tether=Math.min(1,t/.025,(1-t)/.025);
// Finite causal travelling sine: first lobe moves UP at the IN socket,
// trailing lobes alternate and decay over time AND along cable length.
const wave=passed>0?
-strength*Math.sin(2*Math.PI*passed/.36)*
-amplitude*Math.sin(2*Math.PI*passed/width)*
Math.exp(-2.1*passed-2.9*distance)*tether:0;
d+=' L '+x.toFixed(1)+' '+(y+wave).toFixed(1);
}
Expand Down Expand Up @@ -981,33 +987,55 @@
noninteractive cable jacket falls and reels back to its real OUT jack.
Own overlay SVG is independent of the canonical routing/PCM projection.
A canceled drag cannot call this effect. Reduced-motion skips it. */
const WIRE_RETRACT_MS=690;
const WIRE_RETRACT_FALL_MS=320,WIRE_RETRACT_HANG_MS=150,WIRE_RETRACT_REEL_MS=660;
const WIRE_RETRACT_MS=WIRE_RETRACT_FALL_MS+WIRE_RETRACT_HANG_MS+WIRE_RETRACT_REEL_MS;
let wireRetractToken=0,wireRetractOverlay=null;
function stopWireRetraction(){
++wireRetractToken;
wireRetractOverlay?.remove();wireRetractOverlay=null;
}
// Deterministic three-phase cable physics: first the free plug falls while
// staying at its released X, then a fully slack cable HANGS without reeling.
// Only after the visible pause does the reel pull the plug to the fixed OUT.
function wireRetractPose(x0,y0,rx,ry,drop,elapsedMs){
const falling=Math.max(0,Math.min(1,elapsedMs/WIRE_RETRACT_FALL_MS));
const fallEase=falling*falling*(3-2*falling);
const reelT=Math.max(0,Math.min(1,
(elapsedMs-WIRE_RETRACT_FALL_MS-WIRE_RETRACT_HANG_MS)/WIRE_RETRACT_REEL_MS));
const pull=1-Math.pow(1-reelT,2.15);
const remaining=1-pull;
const x=x0+(rx-x0)*remaining;
const y=y0+(ry-y0+drop*fallEase)*remaining;
const baseSag=Math.min(48,Math.max(12,Math.abs(rx-x0)*.25));
const hangSag=Math.min(105,Math.max(58,43+Math.abs(rx-x0)*.19));
const sag=(baseSag*(1-fallEase)+hangSag*fallEase)*remaining;
// Gentle trailing ripple while the reel pulls, never while freely falling
// or paused; both endpoints retain exactly their physical positions.
const wave=5.2*Math.sin(Math.PI*reelT)*Math.pow(remaining,.55)*
Math.min(1,Math.abs(rx-x0)/125);
return {x,y,sag,wave,reelT,phase:reelT>0?'reel':falling<1?'fall':'hang'};
}
function startWireRetraction(sourceId,releasePoint){
stopWireRetraction();
if(document.hidden||window.matchMedia?.('(prefers-reduced-motion: reduce)')?.matches)return;
const viewport=document.getElementById('viewport'),base=document.getElementById('wireLayer');
const viewport=document.getElementById('viewport');
const out=viewport?.querySelector('.strip[data-id="'+sourceId+'"] .wire-node-out');
const source=wireSourceTrack(sourceId),vp=viewport?.getBoundingClientRect?.();
const jack=wireJackRect(out);
if(!source||!vp?.width||!vp.height||!jack?.width||!releasePoint)return;
const x0=jack.left-vp.left+jack.width*.5,y0=jack.top-vp.top+jack.height*.5;
const rx=Math.max(2,Math.min(vp.width-2,releasePoint.x-vp.left));
const ry=Math.max(2,Math.min(vp.height-2,releasePoint.y-vp.top));
const drop=Math.max(20,Math.min(vp.height-ry-25,
Math.min(100,68+Math.abs(rx-x0)*.07)));
const svgNS='http://www.w3.org/2000/svg';
const svg=document.createElementNS(svgNS,'svg');
svg.id='wireRetractLayer';svg.classList.add('routing-wire-overlay');
svg.dataset.wireRetract=String(sourceId);
svg.setAttribute('viewBox','0 0 '+vp.width+' '+vp.height);
// Permit a short visible gravity drop beneath the normal WIRE bay,
// while retaining the original horizontally clipped channel viewport.
const bay=out.closest('.send-section')?.getBoundingClientRect?.();
if(bay)svg.style.clipPath='inset('+Math.max(0,bay.top-vp.top-5)+'px 0px '+
Math.max(0,vp.bottom-bay.bottom-48)+'px 0px)';
// V62 clipped everything below the SEND bay after only ~48px: a limp
// hanging cable was therefore impossible to see. Clip only to viewport.
svg.style.clipPath='none';
svg.style.pointerEvents='none';svg.style.zIndex='4';svg.style.filter='none';
const mk=(tag,attrs)=>{
const el=document.createElementNS(svgNS,tag);
Expand All @@ -1030,29 +1058,26 @@
stopWireRetraction();return;
}
if(began===null)began=now;
const p=Math.min(1,(now-began)/WIRE_RETRACT_MS);
const falling=Math.min(1,p/.29);
const reel=p<=.29?0:(p-.29)/.71;
const pull=1-Math.pow(1-reel,2.4);
const remaining=1-pull;
const x=x0+(rx-x0)*remaining;
const y=y0+(ry-y0)*remaining+26*falling*falling*remaining+
7*Math.sin(Math.PI*reel)*remaining;
const len=Math.hypot(x-x0,y-y0);
const sag=Math.min(43,len*.44)*(1-.45*pull);
const dx=x-x0;
const d='M '+x0.toFixed(1)+' '+y0.toFixed(1)+
' C '+(x0+dx*.04).toFixed(1)+' '+(y0+sag).toFixed(1)+
', '+(x-dx*.09).toFixed(1)+' '+(y+sag).toFixed(1)+
', '+x.toFixed(1)+' '+y.toFixed(1);
const elapsed=Math.min(WIRE_RETRACT_MS,Math.max(0,now-began));
const pose=wireRetractPose(x0,y0,rx,ry,drop,elapsed);
svg.dataset.wirePhase=pose.phase;
let d='M '+x0.toFixed(1)+' '+y0.toFixed(1);
for(let i=1;i<=40;i++){
const t=i/40;
const bow=Math.sin(Math.PI*t);
const x=x0+(pose.x-x0)*t;
const curl=pose.wave*bow*Math.sin(2*Math.PI*((1-t)*1.2-pose.reelT*1.7));
const y=y0+(pose.y-y0)*t+pose.sag*bow+curl;
d+=' L '+x.toFixed(1)+' '+y.toFixed(1);
}
shadow.setAttribute('d',d);jacket.setAttribute('d',d);
plug.setAttribute('cx',x.toFixed(1));plug.setAttribute('cy',y.toFixed(1));
plug.setAttribute('r',Math.max(0,5.2*remaining).toFixed(2));
if(p<1)requestAnimationFrame(step);
else stopWireRetraction(); // no ghost cable or hitbox after collapse
plug.setAttribute('cx',pose.x.toFixed(1));
plug.setAttribute('cy',pose.y.toFixed(1));
plug.setAttribute('r',Math.max(0,5.2*(1-pose.reelT)).toFixed(2));
if(elapsed<WIRE_RETRACT_MS)requestAnimationFrame(step);
else stopWireRetraction(); // no phantom WIRE or hit area after reel-in
}
// Paint the first detached frame before returning from pointerup; this
// avoids a blank frame while the old committed path has been removed.
// Paint immediately after accepted REMOVE (no blank intermediate frame).
step(performance.now());
}
/* V23 Smart Wire: visible lit socket means preview is center-snapped and
Expand Down
73 changes: 65 additions & 8 deletions tests/pages_v60_fader_wire_tactile_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ def source_contract():
"gesture.unityLatched=true", "if(!ev.altKey&&Math.abs",
"handleField({target:g.input,type:'change'",
"WIRE_IMPACT_TRAVEL_MS=520,WIRE_IMPACT_SETTLE_MS=160",
"const WIRE_RETRACT_MS=690",
"const WIRE_RETRACT_FALL_MS=320,WIRE_RETRACT_HANG_MS=150,WIRE_RETRACT_REEL_MS=660",
"function wireRetractPose(x0,y0,rx,ry,drop,elapsedMs)",
"svg.style.clipPath='none'",
"const width=.65-.29*longMix",
"const length01=Math.max(0,Math.min(1,(chord-95)/300))",
"function startWireRetraction(sourceId,releasePoint)",
"if(replugRequest)kickWireSpring(replugRequest.sourceId,replugRequest.destId)",
"const distance=1-t; // distance travelled from IN toward OUT",
"const distance=1-t,passed=front-distance;",
"const wave=passed>0?",
"const accepted=ops.filter(op=>['CONNECT','ROUTE_ONLY','RETARGET'].includes(op.type)).at(-1)",
"wire-drag-line is-wire-selected",
Expand Down Expand Up @@ -186,7 +190,7 @@ def test_wire(page):
motion=HTML[HTML.index("const WIRE_IMPACT_TRAVEL_MS="):
HTML.index("function kickWireSpring(")]
physics=page.evaluate("()=>{\n"+motion+"""\n
const g=[0,0,180,0,72]; // representative wire with anchored plugs
const g=[0,0,500,0,72]; // approved long wire with anchored plugs
const [x0,y0,x1,y1,limit]=g;
const span=Math.abs(x1-x0),ceiling=Math.max(12,Math.min(100,Number(limit)||72));
const sag=Math.max(10,Math.min(ceiling,Math.min(ceiling-5,28+Math.sqrt(span)*1.55)));
Expand All @@ -195,14 +199,32 @@ def test_wire(page):
const v=1-t;
return v*v*v*y0+3*v*v*t*(y0+c)+3*v*t*t*(y1+c)+t*t*t*y1;
};
// Same production physics for short and long spans; measure the
// maximum deformation against the natural slack cable at each length.
const peak=span=>{
const geom=[0,0,span,0,72];
const sag=Math.max(10,Math.min(72,Math.min(67,28+Math.sqrt(span)*1.55)));
const ctrl=sag*4/3;
let max=0;
for(const ms of [45,85,150,230,300,390,460,520]){
const pts=wireImpactPathData(...geom,ms).match(/-?\\d+(?:\\.\\d+)?/g).map(Number);
for(let i=1;i<64;i++){
const t=i/64,v=1-t;
const y=3*v*v*t*ctrl+3*v*t*t*ctrl;
max=Math.max(max,Math.abs(pts[2*i+1]-y));
}
}
return max;
};
const displaced=(ms,i)=>{
const points=wireImpactPathData(...g,ms).match(/-?\\d+(?:\\.\\d+)?/g).map(Number);
return points[2*i+1]-baseline(i/64);
};
return {
nearInEarly:displaced(45,60),nearOutEarly:displaced(45,10),
nearOutLate:displaced(420,10),
pluggedOut:displaced(0,0),pluggedIn:displaced(45,64)
pluggedOut:displaced(0,0),pluggedIn:displaced(45,64),
tinyPeak:peak(70),shortPeak:peak(170),longPeak:peak(500)
};
}""")
assert physics and physics["nearInEarly"]< -2.5,("no upward jerk at receiving IN",physics)
Expand All @@ -211,6 +233,10 @@ def test_wire(page):
assert abs(physics["nearOutLate"])<abs(physics["nearInEarly"])*.25,\
("outgoing wave did not decay strongly toward OUT",physics)
assert abs(physics["pluggedOut"])<.25 and abs(physics["pluggedIn"])<.25,physics
assert 0.8<physics["tinyPeak"]<physics["shortPeak"]*.65,\
("one-channel wave is too violent or imperceptible",physics)
assert physics["shortPeak"]<physics["longPeak"]*.65,\
("short cable retains long cable amplitude",physics)
assert len(samples)>=5,("no finite spring movement",len(samples))
assert any(" L " in x["d"] for x in samples),("no cable impact",len(samples))
settled=cable.get_attribute("d")
Expand Down Expand Up @@ -329,13 +355,44 @@ def test_replug_and_retract(page):
first=plug.evaluate("(el)=>[Number(el.getAttribute('cx')),Number(el.getAttribute('cy'))]")
page.wait_for_timeout(125)
dropped=plug.evaluate("(el)=>[Number(el.getAttribute('cx')),Number(el.getAttribute('cy'))]")
assert dropped[1]>first[1]+3,("unplugged plug did not fall downward",first,dropped)
assert dropped[1]>first[1]+3,("free plug did not fall",first,dropped)
assert abs(dropped[0]-first[0])<1.2,("reel began while the plug was still falling",first,dropped)
page.wait_for_timeout(220)
hang=plug.evaluate("(el)=>[Number(el.getAttribute('cx')),Number(el.getAttribute('cy'))]")
assert overlay.get_attribute("data-wire-phase")=="hang","no hanging phase"
assert hang[1]>first[1]+38 and abs(hang[0]-first[0])<1.2,\
("plug did not remain freely hanging below release",first,hang)
assert overlay.evaluate("(el)=>getComputedStyle(el).clipPath")=="none",\
"the dangling cable is still clipped to the SEND tray"
sag=overlay.locator('[data-wire-retract-jacket]').evaluate("""el=>{
const length=el.getTotalLength(),mid=el.getPointAtLength(length/2),
a=el.getPointAtLength(0),b=el.getPointAtLength(length);
return mid.y-(a.y+b.y)/2;
}""")
assert sag>15,("hanging wire lacks a visible slack belly",sag)
page.wait_for_timeout(75)
hold=plug.evaluate("(el)=>[Number(el.getAttribute('cx')),Number(el.getAttribute('cy'))]")
assert abs(hold[0]-hang[0])<1.2 and abs(hold[1]-hang[1])<1.2,\
("the wire should pause hanging before reeling",hang,hold)
page.wait_for_timeout(230)
reel=plug.evaluate("(el)=>[Number(el.getAttribute('cx')),Number(el.getAttribute('cy'))]")
start_dist=abs(first[0]-cx(src.bounding_box()))
assert abs(reel[0]-cx(src.bounding_box()))<start_dist*.85,\
("cable did not retract toward OUT",first,reel)
page.wait_for_timeout(550)
("reeling did not draw the plug toward OUT",first,reel)
assert overlay.get_attribute("data-wire-phase")=="reel"
model=HTML[HTML.index("const WIRE_RETRACT_FALL_MS="):
HTML.index("function startWireRetraction(")]
response=page.evaluate("()=>{\n"+model+"""\n
const a=wireRetractPose(0,0,300,0,82,180);
const b=wireRetractPose(0,0,300,0,82,400);
const c=wireRetractPose(0,0,300,0,82,680);
return {fall:a,hang:b,reel:c};
}""")
assert response["fall"]["wave"]==response["hang"]["wave"]==0,response
assert response["reel"]["wave"]>1.2,response
assert response["fall"]["phase"]=="fall" and response["hang"]["phase"]=="hang" and response["reel"]["phase"]=="reel"
assert page.locator('#wireLayer path.wire-interaction-hit[data-cable-key="1-5"]').count()==0
page.wait_for_timeout(580)
assert page.locator('#wireRetractLayer').count()==0,"retraction left a ghost cable"
assert page.locator('#wireLayer path.wire-interaction-hit[data-cable-key="1-5"]').count()==0
page.evaluate("window.__v62Obs.disconnect()")
Expand Down Expand Up @@ -364,7 +421,7 @@ def run():
page.close()
finally:
browser.close()
print("PASS V62 Chromium: damped IN-to-OUT whip, accepted relocated wavy, falling/unspooling unplug, no ghost graph")
print("PASS V63 Chromium: adaptive 1/2/4-channel waves, real fall-hang-reel with trailing flex, no phantom graph")


if __name__=="__main__":
Expand Down
Loading