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
64 changes: 39 additions & 25 deletions site/preview-v2/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -996,54 +996,68 @@
Single visual-only transient, no synthetic route or native DSP mutation.
The travelling wave spans the shrinking jacket and the detached plug
is a FREE end: it moves with the final wave rather than being pinned. */
const WIRE_RETRACT_MS=520;
/* V66 fast, lively elastic recoil: OUT stays fixed while a travelling
whip reaches the entire shrinking cable. The disconnected dot is free:
a damped tip response makes it wobble rather than ride a rigid chord.
Visual-only; graph REMOVE always commits before this animation exists. */
const WIRE_RETRACT_MS=330;
let wireRetractToken=0,wireRetractOverlay=null;
function stopWireRetraction(){
++wireRetractToken;
wireRetractOverlay?.remove();wireRetractOverlay=null;
}
function wireRetractPose(x0,y0,rx,ry,elapsedMs){
const p=Math.max(0,Math.min(1,elapsedMs/WIRE_RETRACT_MS));
// 42% shorter than V64, brisk at the beginning and softly decelerating.
const remaining=Math.pow(1-p,2.25);
// Fast pull from the first frame, no preceding fall/hang/idle phase.
const remaining=Math.pow(1-p,2.65);
const x=x0+(rx-x0)*remaining,y=y0+(ry-y0)*remaining;
const chord=Math.hypot(rx-x0,ry-y0);
const length01=Math.max(0,Math.min(1,(chord-85)/270));
const length01=Math.max(0,Math.min(1,(chord-90)/270));
const longMix=length01*length01*(3-2*length01);
// The pulse traverses the *whole* cable before reel-in is over.
// OUT -> FREE end, then leaves a short damped trailing tail.
const front=1.5*(1-Math.pow(1-Math.min(1,p/.55),1.35));
const width=.62-.25*longMix; // fewer smoother lobes on short cables
const sag=Math.min(46,Math.max(9,Math.sqrt(chord)*2.1))*
Math.pow(remaining,.72);
const amplitude=Math.min(19,Math.max(7,Math.sqrt(chord)*.95))*
(.42+.58*longMix)*Math.pow(remaining,.47)*Math.min(1,p/.095);
return {x,y,remaining,sag,front,width,amplitude,phase:'reel'};
// Front originates at OUT and reaches the loose tip early enough that
// the tip can swing repeatedly BEFORE the wire disappears.
const front=1.42*(1-Math.pow(1-Math.min(1,p/.40),1.35));
const catchUp=Math.max(0,Math.min(1,(front-.78)/.30));
const width=.59-.24*longMix;
const sag=Math.min(44,Math.max(10,Math.sqrt(chord)*2.1))*
Math.pow(remaining,.78);
const amplitude=Math.min(32,Math.max(14,Math.sqrt(chord)*1.5))*
(.46+.54*longMix)*Math.pow(remaining,.29)*
Math.min(1,p/.07)*Math.min(1,chord*remaining/55);
const recoil=amplitude*.13*catchUp*
Math.sin(2*Math.PI*Math.max(0,p-.19)/.26);
return {p,x,y,remaining,sag,front,catchUp,width,amplitude,recoil,phase:'reel'};
}
function wireRetractWave(pose,t){
const passed=pose.front-t; // first near OUT, then all along the cable
if(passed<=0)return 0;
const sourceAnchor=Math.min(1,t/.035);
// Unlike the connected socket, the unplugged end is not tethered:
// the sine displaces the plug itself, so it never looks rigid.
return -pose.amplitude*Math.sin(2*Math.PI*passed/pose.width)*
Math.exp(-1.05*passed-.32*t)*sourceAnchor;
const passed=pose.front-t;
const travelling=passed>0?
-Math.sin(2*Math.PI*passed/pose.width)*
Math.exp(-.77*passed-.35*t):0;
// The travelling pulse excites an inertial after-swing at the FREE tip.
// Its influence smoothly increases toward that end, without moving OUT.
const lag=Math.max(0,pose.p-.19);
const tipSwing=1.15*pose.catchUp*Math.sin(2*Math.PI*lag/.26)*
Math.exp(-1.25*lag)*Math.pow(t,1.65);
return pose.amplitude*Math.min(1,t/.04)*(travelling+tipSwing);
}
function wireRetractPathData(x0,y0,rx,ry,elapsedMs){
const pose=wireRetractPose(x0,y0,rx,ry,elapsedMs);
const dx=pose.x-x0,dy=pose.y-y0;
const norm=Math.max(1,Math.hypot(dx,dy));
const nx=-dy/norm,ny=dx/norm;
const nx=-dy/norm,ny=dx/norm,tx=dx/norm,ty=dy/norm;
let d='M '+x0.toFixed(1)+' '+y0.toFixed(1);
for(let i=1;i<=64;i++){
const t=i/64;
const wave=wireRetractWave(pose,t);
const x=x0+dx*t+nx*wave;
const y=y0+dy*t+pose.sag*Math.sin(Math.PI*t)+ny*wave;
const surge=pose.recoil*t*t;
const x=x0+dx*t+nx*wave+tx*surge;
const y=y0+dy*t+pose.sag*Math.sin(Math.PI*t)+ny*wave+ty*surge;
d+=' L '+x.toFixed(1)+' '+y.toFixed(1);
}
const endWave=wireRetractWave(pose,1);
return {d,pose:{...pose,tipX:pose.x+nx*endWave,tipY:pose.y+ny*endWave}};
return {d,pose:{...pose,
tipX:pose.x+nx*endWave+tx*pose.recoil,
tipY:pose.y+ny*endWave+ty*pose.recoil}};
}
function startWireRetraction(sourceId,releasePoint){
stopWireRetraction();
Expand Down Expand Up @@ -1091,7 +1105,7 @@
// Visual plug follows the same free endpoint as the final SVG sample.
plug.setAttribute('cx',shape.pose.tipX.toFixed(1));
plug.setAttribute('cy',shape.pose.tipY.toFixed(1));
plug.setAttribute('r',Math.max(0,5.2*Math.pow(shape.pose.remaining,.6)).toFixed(2));
plug.setAttribute('r',Math.max(0,5.8*Math.pow(shape.pose.remaining,.48)).toFixed(2));
if(elapsed<WIRE_RETRACT_MS)requestAnimationFrame(step);
else stopWireRetraction(); // no ghost cable or hitbox
}
Expand Down
140 changes: 73 additions & 67 deletions tests/pages_v60_fader_wire_tactile_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ 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=520",
"const WIRE_RETRACT_MS=330",
"const tipSwing=1.15*pose.catchUp",
"const recoil=amplitude*.13*catchUp",
"function wireRetractPose(x0,y0,rx,ry,elapsedMs)",
"function wireRetractWave(pose,t)",
"function wireRetractPathData(x0,y0,rx,ry,elapsedMs)",
"const endWave=wireRetractWave(pose,1)",
"plug.setAttribute('cy',shape.pose.tipY.toFixed(1))",
"const passed=pose.front-t; // first near OUT, then all along the cable",
"const passed=pose.front-t;",
"svg.style.clipPath='none'",
"const width=.65-.29*longMix",
"const length01=Math.max(0,Math.min(1,(chord-95)/300))",
Expand Down Expand Up @@ -342,95 +344,99 @@ 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"

# 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.
# Observe the actual detached SVG during an accepted pointer unplug.
# A 330ms reel MUST be measured with RAF/DOM evidence, not a sequence
# of slow locator reads that might miss a fast short-lived animation.
page.evaluate("""()=>{
window.__v66ReelFrames=[];
window.__v66ReelObserver=new MutationObserver(()=>{
const layer=document.querySelector('#wireRetractLayer');
const plug=layer?.querySelector('[data-wire-retract-plug]');
const jacket=layer?.querySelector('[data-wire-retract-jacket]');
if(!plug||!jacket)return;
const x=Number(plug.getAttribute('cx')),y=Number(plug.getAttribute('cy'));
if(Number.isFinite(x)&&Number.isFinite(y))
window.__v66ReelFrames.push({x,y,r:Number(plug.getAttribute('r')),
phase:layer.dataset.wirePhase,
d:jacket.getAttribute('d')});
});
window.__v66ReelObserver.observe(document.getElementById('viewport'),
{childList:true,subtree:true,attributes:true,attributeFilter:['cx','cy','d']});
}""")
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 edge immediately"
overlay=page.locator('#wireRetractLayer[data-wire-retract="1"]')
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'))]")
first_path=jacket.get_attribute("d")
page.wait_for_timeout(175)
moved=plug.evaluate("(el)=>[Number(el.getAttribute('cx')),Number(el.getAttribute('cy'))]")
assert page.locator('#wireLayer path.wire-interaction-hit[data-cable-key="1-5"]').count()==0, \
"unplug must REMOVE the graph edge immediately"
page.wait_for_timeout(450)
frames=page.evaluate("window.__v66ReelFrames")
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 abs(moved[1]-first[1])<18,("free plug whipped beyond elastic envelope",first,moved)
# The free plug must be attached to the *moving wave tip*, not a
# rigid circle on the straight interpolation chord.
tip_gap=overlay.evaluate("""el=>{
const path=el.querySelector('[data-wire-retract-jacket]');
const plug=el.querySelector('[data-wire-retract-plug]');
const end=path.getPointAtLength(path.getTotalLength());
return Math.hypot(end.x-Number(plug.getAttribute('cx')),
end.y-Number(plug.getAttribute('cy')));
}""")
assert tip_gap<.25,("free plug is detached from the wavy jacket",tip_gap)
assert jacket.get_attribute("d")!=first_path,"reel never animated the jacket"
assert overlay.evaluate("(el)=>getComputedStyle(el).clipPath")=="none"
assert len(frames)>=6,("fast plug-out never animated in real browser",frames[:2])
distances=[abs(item["x"]-source_x) for item in frames]
assert distances[0]>max(25,distances[-1]*2.5), \
("free plug did not reel briskly toward OUT",distances)
delta=max(item["y"] for item in frames)-min(item["y"] for item in frames)
assert delta>12,("plug dot did not visibly swing with the WIRE",delta)
assert frames[-1]["r"]<frames[0]["r"],"free plug does not shrink into OUT"
assert all(item["phase"]=="reel" for item in frames),"unexpected fall/hang phase"
assert not page.locator('#wireRetractLayer').count(),"reel left ghost visual"
assert page.locator('#wireLayer path.wire-interaction-hit[data-cable-key="1-5"]').count()==0
page.evaluate("window.__v66ReelObserver.disconnect()")

# 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=520"):
# Exact production code evaluated in Chromium: a strong pulse starts at
# OUT, travels through the middle and far cable, then throws the loose
# plug from side to side. It fades to zero as remaining length runs out.
model=HTML[HTML.index("const WIRE_RETRACT_MS=330"):
HTML.index("function startWireRetraction(")]
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;
return ys[2*i+1]-pose.sag*Math.sin(Math.PI*t);
};
const early=wireRetractPathData(0,0,chord,0,135);
const middle=wireRetractPathData(0,0,chord,0,220);
const flex=wireRetractPathData(0,0,chord,0,175);
const early=wireRetractPathData(0,0,chord,0,50);
const middle=wireRetractPathData(0,0,chord,0,120);
const crest=wireRetractPathData(0,0,chord,0,135);
const finished=wireRetractPathData(0,0,chord,0,WIRE_RETRACT_MS);
const shortPose=wireRetractPose(0,0,80,0,115);
const longPose=wireRetractPose(0,0,chord,0,115);
const shortPose=wireRetractPose(0,0,80,0,95);
const longPose=wireRetractPose(0,0,chord,0,95);
const tip=ms=>wireRetractPathData(0,0,chord,0,ms).pose.tipY;
const svgTip=crest.d.match(/-?\d+(?:\.\d+)?/g).map(Number).slice(-2);
return {
nearOutEarly:deviation(40,8),farEarly:deviation(40,51),
midAfter:deviation(125,32),farAfter:deviation(155,48),
freeTipWave:deviation(175,64),
sourceAnchor:deviation(175,0),
halfwayX:middle.pose.x,earlyX:early.pose.x,
tipX:flex.pose.tipX,tipY:flex.pose.tipY,
nearOut:deviation(20,8),farEarly:deviation(20,51),
middleSwing:deviation(60,32),farSwing:deviation(80,48),
tipFirst:tip(100),tipRebound:tip(135),
sourceAnchor:deviation(135,0),earlyX:early.pose.x,
middleX:middle.pose.x,tipX:crest.pose.tipX,
tipY:crest.pose.tipY,svgTip,
completeX:finished.pose.tipX,completeY:finished.pose.tipY,
shortAmplitude:shortPose.amplitude,longAmplitude:longPose.amplitude,
startPhase:early.pose.phase,finishAmplitude:finished.pose.amplitude
};
}""")
assert abs(physics["nearOutEarly"])>2,("reel has no abrupt OUT-origin whip",physics)
assert abs(physics["farEarly"])<.4,("free tip moves before OUT-origin front arrives",physics)
assert abs(physics["midAfter"])>2 and abs(physics["farAfter"])>2,\
("wavy must travel through the whole jacket, not just near OUT",physics)
assert abs(physics["freeTipWave"])>3,\
("loose plug remains rigid when wave arrives",physics)
assert abs(physics["sourceAnchor"])<.25,("OUT socket endpoint shifted",physics)
assert 0<physics["halfwayX"]<physics["earlyX"]<270,\
("reel does not accelerate much faster than V64",physics)
assert abs(physics["tipY"])>3,("tip never reacts to wave",physics)
assert abs(physics["nearOut"])>3 and abs(physics["farEarly"])<.4, \
("impulse must start at OUT, not at the free plug",physics)
assert abs(physics["middleSwing"])>7 and abs(physics["farSwing"])>9, \
("wave fails to excite the entire shortening cable",physics)
assert abs(physics["tipFirst"])>10 and abs(physics["tipRebound"])>17, \
("dot/loose plug does not swing enough",physics)
assert physics["tipFirst"]*physics["tipRebound"]<0, \
("free dot must whip back in the opposite direction",physics)
assert abs(physics["sourceAnchor"])<.25,"source OUT socket cannot move"
assert 0<physics["middleX"]<physics["earlyX"]<300, \
("retraction speed is not appreciably faster than V65",physics)
assert abs(physics["tipY"]-physics["svgTip"][1])<.1 and \
abs(physics["tipX"]-physics["svgTip"][0])<.1, \
("free plug circle detached from last path vertex",physics)
assert abs(physics["completeX"])<.01 and abs(physics["completeY"])<.01,physics
assert physics["shortAmplitude"]<physics["longAmplitude"]*.65,\
("one-strip WIRE should not whip as violently as four strips",physics)
assert physics["shortAmplitude"]<physics["longAmplitude"]*.7, \
("short cable should remain controlled",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
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 All @@ -457,7 +463,7 @@ def run():
page.close()
finally:
browser.close()
print("PASS V65 Chromium: fast OUT reel, full-span travelling wave, flexible free plug and no ghost graph")
print("PASS V66 Chromium: 330ms fast reel, whole cable ripple and swing-back free dot with no ghost graph")


if __name__=="__main__":
Expand Down
Loading