diff --git a/site/preview-v2/index.html b/site/preview-v2/index.html index dd5b8c7ae..7d536e850 100644 --- a/site/preview-v2/index.html +++ b/site/preview-v2/index.html @@ -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(); @@ -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)=>{ @@ -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(elapsedgetComputedStyle(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()))[Number(el.getAttribute('cx')),Number(el.getAttribute('cy'))]") + source_x=cx(src.bounding_box()) + assert abs(moved[0]-source_x)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