diff --git a/frontend/js/labs/opticsbench.js b/frontend/js/labs/opticsbench.js index 0181e1b..8d57a76 100644 --- a/frontend/js/labs/opticsbench.js +++ b/frontend/js/labs/opticsbench.js @@ -2614,7 +2614,9 @@ class PrismSim { efNorm = { x: -efNorm.x, y: -efNorm.y }; } const eX = (v[0].x + v[2].x) / 2, eY = (v[0].y + v[2].y) / 2; - const tangDir = { x: efVec.x / efLen, y: efVec.y / efLen }; + /* tangDir = 90° CW rotation of efNorm so that positive incAngle + tilts the ray toward the apex side (natural source-from-left setup) */ + const tangDir = { x: efNorm.y, y: -efNorm.x }; const incRad = this.incAngle * Math.PI / 180; /* incDir = propagation direction (INTO the prism) */ const incDir = { @@ -3306,6 +3308,12 @@ function obSwitchMode(mode, silent) { if (!prismSim) { const cv = document.getElementById('ob-prism-canvas'); if (cv) prismSim = new PrismSim(cv); + /* enable white-light dispersion by default on first prism entry */ + if (window._obWhiteLight === false) { + window._obWhiteLight = true; + const wlBtn = document.getElementById('ob-prism-white-btn'); + if (wlBtn) wlBtn.classList.add('active'); + } } if (prismSim) { prismSim.fit(); prismSim.draw(); } _obDrawSpectrometer(); @@ -3459,6 +3467,16 @@ function prismPreset(n0, incAngle) { if (prismSim) prismSim.setParams({ n0, incAngle }); } +function prismToggleWhite(on, btn) { + window._obWhiteLight = !!on; + const wb = document.getElementById('ob-prism-white-btn'); + const mb = document.getElementById('ob-prism-mono-btn'); + if (wb) wb.classList.toggle('active', !!on); + if (mb) mb.classList.toggle('active', !on); + if (prismSim) prismSim.draw(); + _obDrawSpectrometer(); +} + /* ── Thin Lens controls ── */ function lensParam(name, val) { const v = parseFloat(val); diff --git a/frontend/lab.html b/frontend/lab.html index 54eb690..b73bcc6 100644 --- a/frontend/lab.html +++ b/frontend/lab.html @@ -3173,6 +3173,11 @@