{"job_id":"anim-job-a335f893-46ff-4d16-a42d-633ed0659eb4","request_id":"test-physics-snell-fef4a9a4-ee3c-4109-9b59-ca80c158fc36-1778702709883","status":"complete","asset":{"primary_url":"https://storage.googleapis.com/pupiltree-animation-assets/anim-job-a335f893-46ff-4d16-a42d-633ed0659eb4/walkthrough.mp4","thumbnail_url":"https://storage.googleapis.com/pupiltree-animation-assets/anim-job-a335f893-46ff-4d16-a42d-633ed0659eb4/thumb.jpg","transcript_url":"https://storage.googleapis.com/pupiltree-animation-assets/anim-job-a335f893-46ff-4d16-a42d-633ed0659eb4/transcript.vtt","interactive_url":"https://storage.googleapis.com/pupiltree-animation-assets/anim-job-a335f893-46ff-4d16-a42d-633ed0659eb4/index.html","scenefile_url":"https://storage.googleapis.com/pupiltree-animation-assets/anim-job-a335f893-46ff-4d16-a42d-633ed0659eb4/scene-source.json","duration_seconds":15,"byte_size":263065,"renderer":"html_three_js_local","parameters":{"style":"auto","executor":"native_render_executor","localPath":"/app/storage/assets/anim-job-a335f893-46ff-4d16-a42d-633ed0659eb4","interactivity":"none","renderer_style":"three_js","durationSeconds":15,"render_manifest":{"jobId":"anim-job-a335f893-46ff-4d16-a42d-633ed0659eb4","request":{"gap":{"topic":"snell-refraction-angle","severity":"moderate","error_type":"formula_misuse","memory_state":"fragile","display_topic":"Snell's Law — Refraction at an Interface","common_wrong_answer":"Refracted ray bends away from normal when going from rare to dense medium.","confidence_at_error":"high","correct_understanding":"Going from rare to dense medium (n1 < n2) the ray bends toward the normal: n1 sin θ1 = n2 sin θ2."},"target":{"style":"auto","render":{"fps":30,"format":"mp4","resolution":"1920x1080","include_thumbnail":true,"include_transcript":true},"audience":{"tone":"neutral_instructional","grade":"12","language":"en"},"interactivity":"none","duration_seconds":15},"context":{"chapter":{"name":"Ray Optics","ncert_class":12,"ncert_chapter_number":9},"sub_topics":[{"topic":"Refraction","key_concepts":["Snell's law","refractive index","critical angle","total internal reflection"]}]},"metadata":{"priority":"normal"},"exam_type":"neet","asset_type":"simulation","request_id":"test-physics-snell-fef4a9a4-ee3c-4109-9b59-ca80c158fc36-1778702709883","subject_area":"physics"},"renderer":"html_three_js_local","storyboard":{"beats":[{"label":"Topic","visual":"Show the topic title and the key physical context.","narration":"Snell's Law — Refraction at an Interface"},{"label":"Mistake","visual":"Show the wrong approach and why it seems plausible.","narration":"Refracted ray bends away from normal when going from rare to dense medium."},{"label":"Correction","visual":"Show the right approach step by step.","narration":"Going from rare to dense medium (n1 < n2) the ray bends toward the normal: n1 sin θ1 = n2 sin θ2."},{"label":"Concept","visual":"Highlight the key formula and the governing relationship.","narration":"Snell's law. refractive index. critical angle"}],"title":"Snell's Law — Refraction at an Interface","sceneCode":"<!doctype html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"utf-8\"/>\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/>\n  <title>Snell's Law Refraction Remediation</title>\n  <style>\n    :root{--bg:#0f1418;--panel:#182228;--line:#2e3e46;--accent:#e5ba67;--text:#f4f1ea;--muted:#c8d4da;--blue:#63b3ff;--green:#87e8a8;--red:#de7f76;}\n    *{box-sizing:border-box;}\n    body{margin:0;font-family:\"Plus Jakarta Sans\",\"Manrope\",ui-sans-serif,system-ui,sans-serif;background:radial-gradient(120% 90% at 20% -5%,#24343d 0%,var(--bg) 55%);color:var(--text);}\n    main{min-height:100vh;display:grid;grid-template-columns:minmax(300px,380px) 1fr;}\n    aside{border-right:1px solid var(--line);background:linear-gradient(180deg,rgba(31,46,53,.86),rgba(24,34,40,.92));padding:24px;overflow:auto;backdrop-filter:blur(6px);}\n    section{padding:24px;display:grid;place-items:center;}\n    h1{margin:0 0 10px;font-size:1.65rem;line-height:1.15;}\n    .sub{margin:0 0 16px;color:var(--muted);}\n    .formula{margin:0 0 14px;padding:10px;border:1px solid var(--line);border-radius:10px;background:#11191e;color:var(--accent);font-family:ui-monospace,monospace;font-size:0.9rem;box-shadow:inset 0 0 28px rgba(229,186,103,.08);}\n    .control{display:grid;gap:6px;margin:12px 0;}\n    .control input{width:100%;accent-color:var(--accent);}\n    ul{margin:14px 0 0 18px;padding:0;color:var(--muted);display:grid;gap:6px;}\n    .stage{width:min(1020px,95%);aspect-ratio:16/9;border:1px solid #445862;border-radius:14px;position:relative;overflow:hidden;background:radial-gradient(circle at 50% 38%,#2f4a57,#0f1418 72%);box-shadow:0 18px 60px rgba(0,0,0,.45), inset 0 0 90px rgba(255,255,255,.03);}\n    .stage::before{content:\"\";position:absolute;inset:0;background:linear-gradient(180deg,rgba(255,255,255,.06),transparent 34%);pointer-events:none;}\n    .legend{position:absolute;right:12px;top:12px;padding:8px 10px;border-radius:10px;border:1px solid #465a64;background:rgba(9,14,18,.58);font-size:0.8rem;color:var(--muted);backdrop-filter:blur(4px);}\n    @media(max-width:900px){main{grid-template-columns:1fr;}aside{border-right:0;border-bottom:1px solid var(--line);}}\n  </style>\n</head>\n<body>\n<main>\n  <aside>\n    <h1>Snell's Law Refraction</h1>\n    <p class=\"sub\">Watch light bend at the interface—rare to dense medium.</p>\n    <p class=\"formula\">n₁ sin θ₁ = n₂ sin θ₂</p>\n    <label class=\"control\"><span>Incident Angle: <strong id=\"v-angle1\">30</strong>°</span><input id=\"c-angle1\" type=\"range\" min=\"10\" max=\"80\" step=\"5\" value=\"30\"/></label>\n    <label class=\"control\"><span>n₁ (rare): <strong id=\"v-n1\">1.00</strong></span><input id=\"c-n1\" type=\"range\" min=\"1\" max=\"1.5\" step=\"0.1\" value=\"1\"/></label>\n    <label class=\"control\"><span>n₂ (dense): <strong id=\"v-n2\">1.50</strong></span><input id=\"c-n2\" type=\"range\" min=\"1.5\" max=\"2.5\" step=\"0.1\" value=\"1.5\"/></label>\n    <ul>\n      <li><strong>Rare→Dense:</strong> Ray bends <span style=\"color:var(--green);\">toward</span> normal</li>\n      <li><strong>Common Error:</strong> Thinking ray bends away</li>\n      <li><strong>Why?</strong> Light slows in dense medium, bends inward to match field lines</li>\n      <li>Use formula to verify: higher n₂ means smaller θ₂</li>\n    </ul>\n  </aside>\n  <section>\n    <div class=\"stage\" id=\"stage\">\n      <div class=\"legend\" id=\"legend\">Ready</div>\n      <canvas id=\"sim-cv\" style=\"position:absolute;inset:0;width:100%;height:100%;\"></canvas>\n    </div>\n  </section>\n</main>\n<script>\nconst controls = [{\"key\":\"angle1\",\"label\":\"Incident Angle\",\"min\":10,\"max\":80,\"step\":5,\"value\":30,\"units\":\"°\"},{\"key\":\"n1\",\"label\":\"Rare Index\",\"min\":1,\"max\":1.5,\"step\":0.1,\"value\":1,\"units\":\"\"},{\"key\":\"n2\",\"label\":\"Dense Index\",\"min\":1.5,\"max\":2.5,\"step\":0.1,\"value\":1.5,\"units\":\"\"}];\nfor(const c of controls){\n  const inp=document.getElementById('c-'+c.key);\n  const out=document.getElementById('v-'+c.key);\n  inp?.addEventListener('input',()=>{out.textContent=inp.value;window.updateModel?.();});\n}\n(function(){\n  const cv=document.getElementById('sim-cv');\n  const ctx=cv.getContext('2d');\n  function resize(){const r=cv.getBoundingClientRect();if(r.width>0){cv.width=r.width;cv.height=r.height;}}\n  resize();new ResizeObserver(resize).observe(cv);\n  let lastTs=0;\n  \n  // State variables\n  let state = {\n    angle1: 30,\n    n1: 1,\n    n2: 1.5,\n    rayPhase: 0,\n    impactTime: 0,\n    refractedRays: []\n  };\n  \n  function glowDot(x, y, r, color, a) {\n    const g = ctx.createRadialGradient(x, y, 0, x, y, r * 2.6);\n    g.addColorStop(0, color.replace('ALPHA', String(a)));\n    g.addColorStop(1, color.replace('ALPHA', '0'));\n    ctx.fillStyle = g;\n    ctx.beginPath();\n    ctx.arc(x, y, r * 2.6, 0, Math.PI * 2);\n    ctx.fill();\n  }\n  \n  function arrow(x1, y1, x2, y2, color, lw) {\n    const dx = x2 - x1, dy = y2 - y1, l = Math.sqrt(dx * dx + dy * dy);\n    if (l < 2) return;\n    const nx = dx / l, ny = dy / l, s = 12;\n    ctx.strokeStyle = color;\n    ctx.lineWidth = lw || 2;\n    ctx.beginPath();\n    ctx.moveTo(x1, y1);\n    ctx.lineTo(x2, y2);\n    ctx.stroke();\n    ctx.fillStyle = color;\n    ctx.beginPath();\n    ctx.moveTo(x2, y2);\n    ctx.lineTo(x2 - s * nx + s * 0.4 * ny, y2 - s * ny - s * 0.4 * nx);\n    ctx.lineTo(x2 - s * nx - s * 0.4 * ny, y2 - s * ny + s * 0.4 * nx);\n    ctx.fill();\n  }\n  \n  function tick(ts) {\n    const dt = Math.min(0.04, (ts - lastTs) / 1000);\n    lastTs = ts;\n    const W = cv.width, H = cv.height;\n    \n    // Read sliders\n    state.angle1 = Number(document.getElementById('c-angle1').value);\n    state.n1 = Number(document.getElementById('c-n1').value);\n    state.n2 = Number(document.getElementById('c-n2').value);\n    \n    // Physics: calculate refracted angle using Snell's Law\n    const angle1Rad = state.angle1 * Math.PI / 180;\n    const sinTheta1 = Math.sin(angle1Rad);\n    const sinTheta2 = (state.n1 / state.n2) * sinTheta1;\n    let angle2Rad = Math.asin(Math.max(-1, Math.min(1, sinTheta2)));\n    const angle2Deg = angle2Rad * 180 / Math.PI;\n    \n    // Update ray phase for animation\n    state.rayPhase = (state.rayPhase + dt * 0.8) % (Math.PI * 2);\n    state.impactTime += dt;\n    \n    // Add refracted rays to trail (for visual effect)\n    if (state.impactTime > 0.05 && state.refractedRays.length < 15) {\n      state.refractedRays.push({\n        t: state.impactTime,\n        angle2: angle2Deg\n      });\n      state.impactTime = 0;\n    }\n    // Prune old rays\n    state.refractedRays = state.refractedRays.filter(r => r.t < 2);\n    \n    // Clear canvas\n    ctx.clearRect(0, 0, W, H);\n    \n    // === LAYER 1: Background & Interface ===\n    // Rare medium (top)\n    ctx.fillStyle = 'rgba(99, 179, 255, 0.08)';\n    ctx.fillRect(0, 0, W, H * 0.45);\n    ctx.font = Math.round(H * 0.024) + 'px sans-serif';\n    ctx.fillStyle = 'rgba(99, 179, 255, 0.3)';\n    ctx.textAlign = 'left';\n    ctx.fillText('Air (n=' + state.n1.toFixed(2) + ')', 20, H * 0.08);\n    \n    // Dense medium (bottom)\n    ctx.fillStyle = 'rgba(135, 232, 168, 0.08)';\n    ctx.fillRect(0, H * 0.45, W, H * 0.55);\n    ctx.fillStyle = 'rgba(135, 232, 168, 0.3)';\n    ctx.fillText('Water (n=' + state.n2.toFixed(2) + ')', 20, H * 0.9);\n    \n    // Interface line\n    ctx.strokeStyle = '#445862';\n    ctx.lineWidth = 3;\n    ctx.setLineDash([8, 4]);\n    ctx.beginPath();\n    ctx.moveTo(0, H * 0.45);\n    ctx.lineTo(W, H * 0.45);\n    ctx.stroke();\n    ctx.setLineDash([]);\n    \n    // Normal at impact\n    const impactX = W * 0.5;\n    const impactY = H * 0.45;\n    ctx.strokeStyle = 'rgba(200, 212, 218, 0.4)';\n    ctx.lineWidth = 2;\n    ctx.setLineDash([4, 2]);\n    ctx.beginPath();\n    ctx.moveTo(impactX, 0);\n    ctx.lineTo(impactX, H);\n    ctx.stroke();\n    ctx.setLineDash([]);\n    \n    // === LAYER 2: Incident Ray ===\n    const rayStart1X = impactX - 250 * Math.sin(angle1Rad);\n    const rayStart1Y = impactY - 250 * Math.cos(angle1Rad);\n    \n    // Animated incident ray\n    const rayLen1 = 250 + 30 * Math.sin(state.rayPhase * 2);\n    ctx.strokeStyle = '#63b3ff';\n    ctx.lineWidth = 3;\n    ctx.globalAlpha = 0.8;\n    ctx.beginPath();\n    ctx.moveTo(rayStart1X, rayStart1Y);\n    ctx.lineTo(impactX, impactY);\n    ctx.stroke();\n    ctx.globalAlpha = 1;\n    \n    // Incident angle arc & label\n    const arcRad = 40;\n    ctx.strokeStyle = '#63b3ff';\n    ctx.lineWidth = 1.5;\n    ctx.beginPath();\n    ctx.arc(impactX, impactY, arcRad, -Math.PI / 2, -Math.PI / 2 + angle1Rad, false);\n    ctx.stroke();\n    ctx.fillStyle = '#63b3ff';\n    ctx.font = Math.round(H * 0.028) + 'px sans-serif';\n    ctx.textAlign = 'center';\n    ctx.fillText('θ₁=' + state.angle1.toFixed(0) + '°', impactX - 65, impactY - 25);\n    \n    // === LAYER 3: Refracted Ray (CORRECT - bends TOWARD normal) ===\n    const rayLen2 = 220;\n    const refractX = impactX + rayLen2 * Math.sin(angle2Rad);\n    const refractY = impactY + rayLen2 * Math.cos(angle2Rad);\n    \n    ctx.strokeStyle = '#87e8a8';\n    ctx.lineWidth = 3;\n    ctx.globalAlpha = 0.85;\n    ctx.beginPath();\n    ctx.moveTo(impactX, impactY);\n    ctx.lineTo(refractX, refractY);\n    ctx.stroke();\n    ctx.globalAlpha = 1;\n    \n    // Refracted angle arc & label\n    ctx.strokeStyle = '#87e8a8';\n    ctx.lineWidth = 1.5;\n    ctx.beginPath();\n    ctx.arc(impactX, impactY, arcRad * 0.75, -Math.PI / 2, -Math.PI / 2 + angle2Rad, false);\n    ctx.stroke();\n    ctx.fillStyle = '#87e8a8';\n    ctx.fillText('θ₂=' + angle2Deg.toFixed(0) + '°', impactX + 55, impactY + 35);\n    \n    // === LAYER 4: Impact Highlight & Labels ===\n    glowDot(impactX, impactY, 8, 'rgba(229, 186, 103, ALPHA)', 0.6);\n    \n    // Draw point\n    ctx.fillStyle = '#e5ba67';\n    ctx.beginPath();\n    ctx.arc(impactX, impactY, 5, 0, Math.PI * 2);\n    ctx.fill();\n    \n    // Formula display\n    ctx.font = Math.round(H * 0.022) + 'px monospace';\n    ctx.fillStyle = '#e5ba67';\n    ctx.textAlign = 'center';\n    ctx.fillText('n₁ sin θ₁ = n₂ sin θ₂', W * 0.5, H * 0.12);\n    ctx.fillStyle = '#87e8a8';","remediationGoal":"Close formula_misuse for physics."},"rendererStyle":"three_js"}}},"metadata":{"rendered_at":"2026-05-13T20:10:58.587Z","cache_hit":false,"cost_usd":0},"error":null}