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
+50 -1
View File
@@ -1,4 +1,4 @@
'use strict';
'use strict';
/* ═══════════════════════════════════════════════════════════════════
AngryBirdsSim — Angry Birds Physics
@@ -853,3 +853,52 @@ class AngryBirdsSim {
return `rgb(${r},${g},${b})`;
}
}
/* ─── lab UI init ─────────────────────────────────── */
var angryBirdsSim = null;
function _openAngryBirds() {
document.getElementById('sim-topbar-title').textContent = 'Angry Birds Physics';
_simShow('sim-angrybirds');
_simShow('ctrl-angrybirds');
requestAnimationFrame(() => requestAnimationFrame(() => {
const c = document.getElementById('angrybirds-canvas');
if (!angryBirdsSim) {
angryBirdsSim = new AngryBirdsSim(c);
angryBirdsSim.onUpdate = _abUpdateUI;
c.addEventListener('mousedown', e => angryBirdsSim.handleMouseDown(e));
c.addEventListener('mousemove', e => angryBirdsSim.handleMouseMove(e));
c.addEventListener('mouseup', e => angryBirdsSim.handleMouseUp(e));
c.addEventListener('mouseleave', e => angryBirdsSim.handleMouseUp(e));
_addTouchSupport(c, angryBirdsSim);
}
angryBirdsSim.fit();
angryBirdsSim.start();
}));
}
function abLevel(n, btn) {
document.querySelectorAll('.ab-lvl-btn').forEach(b => b.classList.remove('active'));
if (btn) btn.classList.add('active');
if (angryBirdsSim) angryBirdsSim.loadLevel(n);
}
function angryBirdsRestart() {
if (angryBirdsSim) angryBirdsSim.restart();
}
function _abUpdateUI(info) {
const v = (id, val) => { const el = document.getElementById(id); if (el) el.textContent = val; };
v('abbar-v1', info.level);
v('abbar-v2', info.birds);
v('abbar-v3', info.pigs);
v('abbar-v4', info.score.toLocaleString('ru'));
v('abbar-v5', info.planet);
/* sync level button highlight */
document.querySelectorAll('.ab-lvl-btn').forEach((b, i) => {
b.classList.toggle('active', i === (info.level - 1));
});
}
/* ── quadratic ── */