File size: 3,675 Bytes
fbf5988
 
 
 
 
1
2
3
4
5
<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>Club tracer verifier</title><style>body{background:#101720;color:#edf4fa;font:15px system-ui;margin:24px}main{display:flex;gap:26px;flex-wrap:wrap}.stage{position:relative;width:min(45vh,420px);aspect-ratio:9/16;background:black}video,svg{position:absolute;width:100%;height:100%;inset:0}svg{pointer-events:none}section{max-width:650px}button,select{padding:9px;background:#263647;color:white;border:1px solid #567;border-radius:5px;margin:5px}input[type=range]{width:95%}pre{white-space:pre-wrap;background:#1d2936;padding:14px}a{color:#8acbff;margin-right:12px}</style><h1 id="title"></h1><main><div class="stage"><video id="v" playsinline preload="auto" src="source.mp4"></video><svg viewBox="0 0 720 1280"><g id="paths"></g></svg></div><section><button id="play">Play / pause</button><button id="prev">Previous frame</button><button id="next">Next frame</button><label><input type="checkbox" id="overlay" checked>Tracer</label><br><label>Speed <select id="speed"><option value="0.25">0.25×</option><option value="0.5">0.5×</option><option value="1" selected>1×</option></select></label><input type="range" id="seek" min="0" value="0" step="1"><pre id="info"></pre><p>Red 6px clubhead trace. Frame numbers start at zero. Trim grows through each recorded path segment; offscreen gaps do not connect. Annotations and interpolation are visual estimates.</p><a href="reference.mp4">Reference MP4</a><a href="tracer_animated.svg">Animated SVG</a><a href="trajectory.json">JSON</a><a href="frames.csv">CSV</a><a href="README.md">Details</a></section></main><script src="data.js"></script><script>
const D=window.TRACER,F=D.frames,v=document.querySelector('#v'),seek=document.querySelector('#seek'),g=document.querySelector('#paths');let idx=0;const P=D.paths.map(s=>{let p=document.createElementNS('http://www.w3.org/2000/svg','path');for(const [k,a]of Object.entries({d:s.d,fill:'none',stroke:'#ff0000','stroke-width':6,'stroke-linecap':'round','stroke-linejoin':'round','stroke-dasharray':s.length_px+' '+s.length_px}))p.setAttribute(k,a);g.append(p);return p});document.querySelector('#title').textContent=D.clip;seek.max=F.length-1;
function draw(i){idx=Math.max(0,Math.min(F.length-1,i));const f=F[idx];seek.value=idx;g.setAttribute('transform',f.svg_matrix);g.style.opacity=document.querySelector('#overlay').checked?1:0;f.paths.forEach((s,j)=>{P[j].setAttribute('stroke-dashoffset',s.dashoffset_px);P[j].setAttribute('stroke-width',6/f.camera_scale);P[j].style.opacity=s.visible?1:0});document.querySelector('#info').textContent=JSON.stringify({frame:idx,time_seconds:f.time_seconds,swing:f.swing,phase:f.phase,trim_end_percent:f.trim_percent,clubhead_xy:f.tip_xy,confidence:f.confidence,notes:f.notes},null,2)}
function at(t){let lo=0,hi=F.length-1;while(lo<hi){let m=Math.ceil((lo+hi)/2);if(F[m].time_seconds<=t+1e-6)lo=m;else hi=m-1}return lo}function jump(i){v.pause();draw(i);v.currentTime=F[idx].time_seconds+Math.min(F[idx].duration_seconds/4,.002)}document.querySelector('#play').onclick=()=>v.paused?v.play():v.pause();document.querySelector('#prev').onclick=()=>jump(idx-1);document.querySelector('#next').onclick=()=>jump(idx+1);seek.oninput=()=>jump(+seek.value);document.querySelector('#overlay').onchange=()=>draw(idx);document.querySelector('#speed').onchange=e=>v.playbackRate=+e.target.value;v.addEventListener('seeked',()=>draw(at(v.currentTime)));if(v.requestVideoFrameCallback){function tick(n,m){draw(at(m.mediaTime));v.requestVideoFrameCallback(tick)}v.requestVideoFrameCallback(tick)}else v.ontimeupdate=()=>draw(at(v.currentTime));draw(0);
</script>