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';
|
||||
/* ════════════════════════════════════════════════════════════════
|
||||
PhotosynthesisSim — Фотосинтез и клеточное дыхание
|
||||
Световые реакции · цикл Кальвина · митохондриальное дыхание
|
||||
@@ -809,3 +809,53 @@ function _psRRect(ctx, x, y, w, h, r) {
|
||||
ctx.arcTo(x, y, x + w, y, r);
|
||||
ctx.closePath();
|
||||
}
|
||||
|
||||
/* ─── lab UI init ─────────────────────────────────── */
|
||||
function _openPhotosynthesis(mode) {
|
||||
document.getElementById('sim-topbar-title').textContent = 'Фотосинтез и дыхание';
|
||||
_simShow('sim-photosynthesis');
|
||||
_simShow('ctrl-photosynthesis');
|
||||
requestAnimationFrame(() => requestAnimationFrame(() => {
|
||||
const canvas = document.getElementById('photosyn-canvas');
|
||||
if (!photosynSim) {
|
||||
photosynSim = new PhotosynthesisSim(canvas);
|
||||
photosynSim.onUpdate = _psUpdateUI;
|
||||
}
|
||||
photosynSim.fit();
|
||||
photosynSim.setMode(mode || 'photo');
|
||||
photosynSim.start();
|
||||
}));
|
||||
}
|
||||
|
||||
function psSetMode(mode, btn) {
|
||||
document.querySelectorAll('.ps-mode-btn').forEach(b => b.classList.remove('active'));
|
||||
if (btn) btn.classList.add('active');
|
||||
if (photosynSim) photosynSim.setMode(mode);
|
||||
}
|
||||
|
||||
function psLightChange() {
|
||||
const v = +document.getElementById('sl-ps-light').value;
|
||||
document.getElementById('ps-light-val').textContent = v + '%';
|
||||
if (photosynSim) photosynSim.setLightIntensity(v);
|
||||
}
|
||||
|
||||
function psCO2Change() {
|
||||
const v = +document.getElementById('sl-ps-co2').value;
|
||||
document.getElementById('ps-co2-val').textContent = v + '%';
|
||||
if (photosynSim) photosynSim.setCO2(v);
|
||||
}
|
||||
|
||||
function psReset() {
|
||||
if (photosynSim) photosynSim.reset();
|
||||
}
|
||||
|
||||
function _psUpdateUI(info) {
|
||||
const v = (id, val) => { const el = document.getElementById(id); if (el) el.textContent = val; };
|
||||
v('psbar-v1', info.atpRate || '0');
|
||||
v('psbar-v2', info.o2 || '0');
|
||||
v('psbar-v3', info.co2 || '0');
|
||||
v('psbar-v4', info.efficiency ? info.efficiency + '%' : '—');
|
||||
v('psbar-v5', info.mode === 'photo' ? 'Фотосинтез' : 'Дыхание');
|
||||
}
|
||||
|
||||
/* ── Angry Birds ── */
|
||||
|
||||
Reference in New Issue
Block a user