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
87 changes: 44 additions & 43 deletions site/preview-v2/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -987,33 +987,47 @@
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_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;
/* V64 unplug/reel: the OUT socket is the ONLY impulse source.
Unplug removes routing immediately; this detached SVG is visual only.
The free plug is pulled straight home while a damped traveling sine
starts at OUT and crosses the shortening, naturally slack cable.
No falling, hanging pause, constant wobble or phantom input edge. */
const WIRE_RETRACT_MS=900;
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 wireRetractPose(x0,y0,rx,ry,elapsedMs){
const p=Math.max(0,Math.min(1,elapsedMs/WIRE_RETRACT_MS));
// Continuous winch acceleration/deceleration without a waiting/fall stage.
const pull=p*p*(3-2*p),remaining=1-pull;
const x=x0+(rx-x0)*remaining,y=y0+(ry-y0)*remaining;
const chord=Math.hypot(rx-x0,ry-y0);
// Loose but restrained curve shrinks with available cable length.
const sag=Math.min(48,Math.max(11,Math.sqrt(chord)*2.1))*Math.pow(remaining,.86);
// Propagation from OUT (t=0) toward the moving free plug (t=1).
const front=1-Math.pow(1-Math.min(1,p/.76),1.3);
const amplitude=Math.min(13,Math.max(5,Math.sqrt(chord)*.76))*
Math.pow(remaining,.62)*Math.min(1,p/.08);
return {x,y,remaining,sag,front,amplitude,phase:'reel'};
}
function wireRetractPathData(x0,y0,rx,ry,elapsedMs){
const pose=wireRetractPose(x0,y0,rx,ry,elapsedMs);
let d='M '+x0.toFixed(1)+' '+y0.toFixed(1);
for(let i=1;i<=64;i++){
const t=i/64;
const x=x0+(pose.x-x0)*t;
// Gravity creates gentle static slack, not a falling plug trajectory.
const y=y0+(pose.y-y0)*t+pose.sag*Math.sin(Math.PI*t);
const passed=pose.front-t; // positive only AFTER OUT-origin front passes
const anchor=Math.min(1,t/.035,(1-t)/.035);
const wave=passed>0?
-pose.amplitude*Math.sin(2*Math.PI*passed/.39)*
Math.exp(-1.8*passed-1.45*t)*anchor:0;
d+=' L '+x.toFixed(1)+' '+(y+wave).toFixed(1);
}
return {d,pose};
}
function startWireRetraction(sourceId,releasePoint){
stopWireRetraction();
Expand All @@ -1026,15 +1040,11 @@
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);
// 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)=>{
Expand All @@ -1059,25 +1069,16 @@
}
if(began===null)began=now;
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',pose.x.toFixed(1));
plug.setAttribute('cy',pose.y.toFixed(1));
plug.setAttribute('r',Math.max(0,5.2*(1-pose.reelT)).toFixed(2));
const shape=wireRetractPathData(x0,y0,rx,ry,elapsed);
svg.dataset.wirePhase=shape.pose.phase;
shadow.setAttribute('d',shape.d);jacket.setAttribute('d',shape.d);
plug.setAttribute('cx',shape.pose.x.toFixed(1));
plug.setAttribute('cy',shape.pose.y.toFixed(1));
plug.setAttribute('r',Math.max(0,5.2*Math.pow(shape.pose.remaining,.6)).toFixed(2));
if(elapsed<WIRE_RETRACT_MS)requestAnimationFrame(step);
else stopWireRetraction(); // no phantom WIRE or hit area after reel-in
else stopWireRetraction(); // no ghost cable or hitbox
}
// Paint immediately after accepted REMOVE (no blank intermediate frame).
// Paint immediately after accepted REMOVE; no missing frame.
step(performance.now());
}
/* V23 Smart Wire: visible lit socket means preview is center-snapped and
Expand Down
107 changes: 57 additions & 50 deletions tests/pages_v60_fader_wire_tactile_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ 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_FALL_MS=320,WIRE_RETRACT_HANG_MS=150,WIRE_RETRACT_REEL_MS=660",
"function wireRetractPose(x0,y0,rx,ry,drop,elapsedMs)",
"const WIRE_RETRACT_MS=900",
"function wireRetractPose(x0,y0,rx,ry,elapsedMs)",
"function wireRetractPathData(x0,y0,rx,ry,elapsedMs)",
"const passed=pose.front-t; // positive only AFTER OUT-origin front passes",
"svg.style.clipPath='none'",
"const width=.65-.29*longMix",
"const length01=Math.max(0,Math.min(1,(chord-95)/300))",
Expand Down Expand Up @@ -337,67 +339,72 @@ def test_replug_and_retract(page):
new_jacket=page.locator('#wireLayer path.wire-outgoing-line[data-cable-key="1-5"],#wireLayer path.wire-incoming-line[data-cable-key="1-5"]').first
assert " C " in new_jacket.get_attribute("d"),"replug must settle to canonical cubic"

# Pull the receiver out into free space BETWEEN sockets (valid blank
# receiving bay), then release. The graph removes immediately; ONLY
# the nonpainting visual cable falls and reels back to its real OUT.
# Drag receiver to a valid blank WIRE bay. The committed graph REMOVE
# is immediate; the detached jacket is visual-only and actively reels
# back to OUT. V64 intentionally has NO falling / hanging phase.
other=page.locator('#tracks .strip[data-id="4"] .wire-node-in')
t=dst.bounding_box();q=other.bounding_box()
blank_x=(cx(t)+cx(q))/2
blank_y=cy(t)
page.mouse.move(cx(t),cy(t));page.mouse.down()
page.mouse.move(blank_x,blank_y,steps=12);page.mouse.up()
assert page.locator('#wireLayer path.wire-interaction-hit[data-cable-key="1-5"]').count()==0,\
"unplug must remove committed graph immediately"
"unplug must remove committed edge immediately"
overlay=page.locator('#wireRetractLayer[data-wire-retract="1"]')
assert overlay.count()==1,"accepted unplug must leave transient falling cable"
assert overlay.count()==1,"accepted unplug must have transient cable"
assert overlay.get_attribute("data-wire-phase")=="reel"
assert overlay.evaluate("(el)=>getComputedStyle(el).pointerEvents")=="none"
jacket=overlay.locator('[data-wire-retract-jacket]')
plug=overlay.locator('[data-wire-retract-plug]')
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,("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)
# CI/browser scheduling can exceed a short hang interval between
# getPointAtLength and a second DOM read. The actual DOM phase above
# proves the hang occurred; check stationary positions at two precise
# timeline samples from the *production function*, not wall-clock sleep.
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,\
("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="):
first_path=jacket.get_attribute("d")
page.wait_for_timeout(175)
moved=plug.evaluate("(el)=>[Number(el.getAttribute('cx')),Number(el.getAttribute('cy'))]")
source_x=cx(src.bounding_box())
assert abs(moved[0]-source_x)<abs(first[0]-source_x)-3,\
("unplug cable did not begin retracting immediately",first,moved)
assert moved[1]<=first[1]+2,("unplug must not drop free plug downward",first,moved)
assert jacket.get_attribute("d")!=first_path,"reel never animated the jacket"
assert overlay.evaluate("(el)=>getComputedStyle(el).clipPath")=="none"

# Evaluate the very same committed runtime production math. A wave must
# launch near OUT first and only later reach the moving free end. Both
# physical endpoints must remain welded to their sockets and the source
# of the wave must not reverse into IN->OUT plug-in behavior.
model=HTML[HTML.index("const WIRE_RETRACT_MS=900"):
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,350);
const held=wireRetractPose(0,0,300,0,82,445);
const c=wireRetractPose(0,0,300,0,82,680);
return {fall:a,hang:b,held,reel:c};
physics=page.evaluate("()=>{\\n"+model+"""\\n
const chord=400;
const deviation=(ms,i)=>{
const {d,pose}=wireRetractPathData(0,0,chord,0,ms);
const ys=d.match(/-?\\d+(?:\\.\\d+)?/g).map(Number);
const t=i/64;
const baseline=pose.sag*Math.sin(Math.PI*t);
return ys[2*i+1]-baseline;
};
const early=wireRetractPathData(0,0,chord,0,145);
const middle=wireRetractPathData(0,0,chord,0,570);
const finished=wireRetractPathData(0,0,chord,0,WIRE_RETRACT_MS);
return {
nearOutEarly:deviation(145,8),farEarly:deviation(145,51),
farLater:deviation(570,48),sourceAnchor:deviation(145,0),
freeAnchor:deviation(145,64),
halfwayX:middle.pose.x,earlyX:early.pose.x,
completeX:finished.pose.x,completeY:finished.pose.y,
startPhase:early.pose.phase,finishAmplitude:finished.pose.amplitude
};
}""")
assert response["fall"]["wave"]==response["hang"]["wave"]==response["held"]["wave"]==0,response
assert abs(response["hang"]["x"]-response["held"]["x"])<.01 and \
abs(response["hang"]["y"]-response["held"]["y"])<.01,\
("production hang pose moved before reel began",response)
assert response["reel"]["wave"]>1.2,response
assert response["fall"]["phase"]=="fall" and response["hang"]["phase"]=="hang" and response["reel"]["phase"]=="reel"
assert physics["nearOutEarly"]< -2,("outgoing whip did not launch at OUT",physics)
assert abs(physics["farEarly"])<.4,("wave appears at free end before leaving OUT",physics)
assert physics["farLater"]<-.25,("wavy failed to travel toward moving end",physics)
assert abs(physics["sourceAnchor"])<.25 and abs(physics["freeAnchor"])<.25,\
("cable path cannot pull physical sockets off anchor",physics)
assert 0<physics["halfwayX"]<physics["earlyX"]<400,physics
assert abs(physics["completeX"])<.01 and abs(physics["completeY"])<.01,physics
assert physics["startPhase"]=="reel" and physics["finishAmplitude"]==0,physics
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"
overlay.wait_for(state="detached",timeout=2500)
assert page.locator('#wireRetractLayer').count()==0,"reel left ghost path"
assert page.locator('#wireLayer path.wire-interaction-hit[data-cable-key="1-5"]').count()==0
page.evaluate("window.__v62Obs.disconnect()")

Expand Down Expand Up @@ -425,7 +432,7 @@ def run():
page.close()
finally:
browser.close()
print("PASS V63 Chromium: adaptive 1/2/4-channel waves, real fall-hang-reel with trailing flex, no phantom graph")
print("PASS V64 Chromium: accepted plug IN-to-OUT and unplug OUT-to-free-end wave while active reel, no ghost graph")


if __name__=="__main__":
Expand Down
Loading