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
+51 -1
View File
@@ -1,4 +1,4 @@
'use strict';
'use strict';
/* ══════════════════════════════════════════════════════════════
GraphTransformSim — graph transformations explorer
y = a·f(k·x + b) + c with sliders for a, k, b, c
@@ -354,3 +354,53 @@ class GraphTransformSim {
cv.addEventListener('touchend', () => { t0 = null; });
}
}
/* ─── lab UI init ─────────────────────────────────── */
var gtSim = null;
function _openGraphTransform() {
document.getElementById('sim-topbar-title').textContent = 'Трансформации графиков';
_simShow('sim-graphtransform');
_registerSimState('graphtransform', () => gtSim?.getParams(), st => gtSim?.setParams(st));
if (_embedMode) _startStateEmit('graphtransform');
requestAnimationFrame(() => requestAnimationFrame(() => {
if (!gtSim) {
gtSim = new GraphTransformSim(document.getElementById('graphtransform-canvas'));
gtSim.onUpdate = _gtUpdateUI;
}
gtSim.fit();
gtSim.draw();
gtSim._emit();
}));
}
function gtParam(name, val) {
const v = parseFloat(val);
document.getElementById('gt-' + name + '-val').textContent = v % 1 === 0 ? v : v.toFixed(1);
if (gtSim) gtSim.setParams({ [name]: v });
}
function gtBase(name, btn) {
document.querySelectorAll('.gt-base-btn').forEach(b => b.classList.remove('active'));
if (btn) btn.classList.add('active');
if (gtSim) gtSim.setBase(name);
}
function gtEffect(a, k, b, c) {
document.getElementById('sl-gt-a').value = a; document.getElementById('gt-a-val').textContent = a;
document.getElementById('sl-gt-k').value = k; document.getElementById('gt-k-val').textContent = k;
document.getElementById('sl-gt-b').value = b; document.getElementById('gt-b-val').textContent = b;
document.getElementById('sl-gt-c').value = c; document.getElementById('gt-c-val').textContent = c;
if (gtSim) gtSim.setParams({ a, k, b, c });
}
function _gtUpdateUI(info) {
const v = (id, val) => { const el = document.getElementById(id); if (el) el.textContent = val; };
v('gtbar-v1', info.base);
v('gtbar-v2', info.a);
v('gtbar-v3', info.k);
v('gtbar-v4', info.b);
v('gtbar-v5', info.c);
}
/* ── pendulum ── */