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:
Maxim Dolgolyov
2026-05-08 14:54:54 +03:00
parent d5f77bb648
commit ae31e4c4e8
35 changed files with 3657 additions and 3589 deletions
+49 -1
View File
@@ -1,4 +1,4 @@
'use strict';
'use strict';
/**
* NormalDistSim v2 — интерактивное нормальное распределение
* μ, σ · правило 68-95-99.7 · Z-score · закрашивание области
@@ -392,3 +392,51 @@ class NormalDistSim {
cv.addEventListener('touchend', () => { this.hx = null; this.draw(); });
}
}
/* ─── lab UI init ─────────────────────────────────── */
var ndSim = null;
function _openNormalDist() {
document.getElementById('sim-topbar-title').textContent = 'Нормальное распределение';
_simShow('sim-normaldist');
_registerSimState('normaldist', () => ndSim?.getParams(), st => ndSim?.setParams(st));
if (_embedMode) _startStateEmit('normaldist');
requestAnimationFrame(() => requestAnimationFrame(() => {
if (!ndSim) {
ndSim = new NormalDistSim(document.getElementById('normaldist-canvas'));
ndSim.onUpdate = _ndUpdateUI;
}
ndSim.fit();
ndSim.draw();
ndSim._emit();
}));
}
function ndParam(name, val) {
const v = parseFloat(val);
const elId = name === 'mu' ? 'nd-mu-val' : 'nd-sigma-val';
document.getElementById(elId).textContent = v % 1 === 0 ? v : v.toFixed(1);
if (ndSim) ndSim.setParams({ [name]: v });
}
function ndShade(mode, btn) {
document.querySelectorAll('.nd-shade-btn').forEach(b => b.classList.remove('active'));
if (btn) btn.classList.add('active');
if (ndSim) ndSim.setParams({ shade: mode });
}
function ndPreset(mu, sigma) {
document.getElementById('sl-nd-mu').value = mu; document.getElementById('nd-mu-val').textContent = mu;
document.getElementById('sl-nd-sigma').value = sigma; document.getElementById('nd-sigma-val').textContent = sigma;
if (ndSim) ndSim.setParams({ mu, sigma });
}
function _ndUpdateUI(info) {
const v = (id, val) => { const el = document.getElementById(id); if (el) el.textContent = val; };
v('ndbar-v1', info.mu);
v('ndbar-v2', info.sigma);
v('ndbar-v3', info.peak);
v('ndbar-v4', info.area);
}
/* ── graph transform ── */