refactor: distribute lab-init.js into 34 engine files
lab-init.js: 4098 -> 543 lines (infrastructure + THEORY only) Each sim's _open*() + UI helpers moved to its engine file: graph.js, projectile.js, collision.js, magnetic.js, triangle.js, geometry.js, trigcircle.js, gas.js (molphys), coulomb.js, circuit.js, reactions.js (chemistry), newton.js (dynamics), chemsandbox.js, celldivision.js, photosynthesis.js, angrybirds.js, quadratic.js, normaldist.js, graphtransform.js, pendulum.js, equilibrium.js, thinlens.js, mirror.js, isoprocess.js, titration.js, refraction.js, probability.js, bohratom.js, electrolysis.js, waves.js, crystal.js, orbitals.js, stereo.js, hydrostatics.js All 34 engine files syntax-checked OK.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
'use strict';
|
||||
/* ══════════════════════════════════════════════════════════════
|
||||
BohrAtomSim — Bohr atomic model simulation (hydrogen)
|
||||
E_n = −13.6 / n² eV λ = 1240 / ΔE nm
|
||||
@@ -638,3 +638,43 @@ class BohrAtomSim {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/* ─── lab UI init ─────────────────────────────────── */
|
||||
function _openBohrAtom() {
|
||||
document.getElementById('sim-topbar-title').textContent = 'Атом Бора';
|
||||
_simShow('sim-bohratom');
|
||||
_registerSimState('bohratom', () => bohrSim?.getParams(), st => bohrSim?.setParams(st));
|
||||
if (_embedMode) _startStateEmit('bohratom');
|
||||
requestAnimationFrame(() => requestAnimationFrame(() => {
|
||||
if (!bohrSim) {
|
||||
bohrSim = new BohrAtomSim(document.getElementById('bohratom-canvas'));
|
||||
bohrSim.onUpdate = _bohrUpdateUI;
|
||||
}
|
||||
bohrSim.fit();
|
||||
bohrSim.play();
|
||||
}));
|
||||
}
|
||||
|
||||
function bohrLevel(n) {
|
||||
if (bohrSim) {
|
||||
const from = bohrSim.info().level;
|
||||
if (from !== n) bohrSim.transition(from, n);
|
||||
}
|
||||
}
|
||||
|
||||
function bohrTransition(from, to) {
|
||||
if (bohrSim) bohrSim.transition(from, to);
|
||||
}
|
||||
|
||||
function _bohrUpdateUI(info) {
|
||||
const v = (id, val) => { const el = document.getElementById(id); if (el) el.textContent = val; };
|
||||
v('bohrbar-v1', info.level);
|
||||
v('bohrbar-v2', info.energy.toFixed(2));
|
||||
if (info.lastTransition) {
|
||||
v('bohrbar-v3', info.lastTransition.wavelength.toFixed(0));
|
||||
v('bohrbar-v4', info.lastTransition.series || '—');
|
||||
}
|
||||
}
|
||||
|
||||
/* ── electrolysis ── */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user