feat(labs): visual polish wave — LabFX foundation + 33 sims juiced up

ФУНДАМЕНТ (4 новых файла):
- _fx_core.js: LabFX namespace, glow.drawGlow, glow.pulse, haptic, shake
- _fx_particles.js: пул 1500 объектов, 6 shapes (dot/spark/ring/smoke/splash/dust)
- _fx_motion.js: tween + 12 easings + critically-damped spring
- _fx_sound.js: 9 procedural synth-звуков (click/tick/whoosh/chime/fizz/spark/bounce/pour/drone), Web Audio API
- Sound toggle в шапке lab.html с localStorage-persist

UX МИКРО (CSS + JS):
- Button states: hover scale+brightness, active scale-down, disabled grayscale
- Slider polish: custom thumb с тенью, filled-track gradient, hover/active
- Focus rings через :focus-visible
- Tooltip system .tt-host data-tt= с 400ms hover, fade-in
- Marching ants для selection
- Loading skeleton с shimmer
- Empty state .sim-empty-* паттерн
- Toast: progress bar внизу, icons по типу
- Cursor states utility classes
- View Transitions API для smooth sim-switch, fallback на CSS fade

PHASE 2 — визуальные эффекты для 33 симуляций:

Physics motion: projectile (launch whoosh + landing splash/shake/haptic + target chime), pendulum (max-extension tick + bob glow), collision (bounce + sparks + shake), angrybirds (whoosh/bounce/fizz/chime + confetti), newton (rocket flame trail + scene transitions), forcesandbox (spring glow + impact sparks)

Physics fields: emfield (field-lines glow + particle trail + lightning при high field + Gauss-drag haptic + rod motion sparks), circuit (energized-wire glow ∝ current + LED bloom + short-circuit shake/spark + heat shimmer smoke + place/erase/switch sounds), opticsbench (beam glow на всех режимах + caustics dust у фокуса + TIR/Brewster one-shot sounds)

Thermo+waves: waves (mode-switch whoosh + Mach-cone particles + spectrum harmonic chime + waveform glow), hydrostatics (pour sound + splash при погружении + valve click), isoprocess (PV-trail dust), heatengine (drone цикла + hot/cold reservoir smoke/dust + phase-change ticks), radioactive (Geiger tick throttle + decay sparks + half-life chime + α/β/γ glow)

Chemistry: chemsandbox (pour splash + fizz bubbles/dust/spark по типу реакции + shake при горении), equilibrium/electrolysis/reactions/titration/flask/ionexchange/redox (pour/fizz/spark/chime по событиям, частицы при ключевых моментах), stoichiometry (fizz bubbles + recipe-change click)

Math+geom: geometry (tool-click + object-create tick + locus glow + challenge confetti via LabFX + haptic), triangle (vertex-drop tick + special-point glow), stereo (figure-change whoosh + cross-section chime, no particles — Three.js), trigcircle (drag-haptic + pitch∝angle tick + sin/cos glow), graph/graphtransform/quadratic (slider-tick throttled + curve glow + discriminant-cross chime), probability (bounce + finish-chime burst), normaldist (pulsing shade + bell glow)

Bio+misc: celldivision (phase-change whoosh + prophase dust + anaphase poles spark + cytokinesis chime), photosynthesis (photon tick + ATP chime + glucose sparkle), bohratom (electron-jump chime ∝ levels + photon spark), orbitals/crystal (mode-change whoosh — Three.js, sound only), logic (gate-place + wire-connect + LED bloom + HIGH wire flowing dots + preset chime), gas/brownian/diffusion/states (preset whoosh, throttled tick по событиям)

Все LabFX вызовы обёрнуты в if (window.LabFX) guard — graceful degradation если фундамент не загружен. 47 JS файлов прошли syntax check.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Maxim Dolgolyov
2026-05-23 13:58:49 +03:00
parent 8b3159b529
commit 6afe928c0d
50 changed files with 2748 additions and 215 deletions
+39 -3
View File
@@ -62,6 +62,11 @@ class PhotosynthesisSim {
this._krebsAngle = 0;
this._etcOffset = 0;
// LabFX throttle timers
this._fxPhotonThrottle = 0;
this._fxAtpSound = 0;
this._fxGlucoseSound = 0;
// layout (computed in fit)
this._layout = {};
@@ -109,6 +114,7 @@ class PhotosynthesisSim {
setMode(mode) {
this.mode = mode;
if (window.LabFX) LabFX.sound.play('whoosh', { volume: 0.3 });
this.reset();
}
@@ -168,6 +174,7 @@ class PhotosynthesisSim {
this._updateResp(dt);
}
if (window.LabFX) LabFX.particles.update(dt);
this._updateParticles(dt);
this._draw();
this._emitUpdate();
@@ -186,6 +193,12 @@ class PhotosynthesisSim {
while (this._photonTimer > photonInterval) {
this._photonTimer -= photonInterval;
this._spawnPhoton();
// throttled photon absorption sound (~5/sec max)
this._fxPhotonThrottle += photonInterval;
if (this._fxPhotonThrottle >= 200 && window.LabFX) {
LabFX.sound.play('tick', { pitch: 1.8, volume: 0.1 });
this._fxPhotonThrottle = 0;
}
}
// H2O splitting (thylakoid)
@@ -202,18 +215,40 @@ class PhotosynthesisSim {
if (CO > 0.05) this._spawnCO2();
}
// ATP from thylakoid <svg class="ic" viewBox="0 0 24 24"><line x1="5" y1="12" x2="19" y2="12"/><polyline points="12 5 19 12 12 19"/></svg> stroma
// ATP from thylakoid stroma
this._atpTimer += dt;
if (this._atpTimer > 400 / (rate + 0.1)) {
this._atpTimer = 0;
if (L > 0.05) this._spawnATP();
if (L > 0.05) {
this._spawnATP();
// subtle chime on ATP formation (throttled)
this._fxAtpSound += 400 / (rate + 0.1);
if (this._fxAtpSound >= 1200 && window.LabFX) {
LabFX.sound.play('chime', { pitch: 1.2, volume: 0.15 });
this._fxAtpSound = 0;
}
}
}
// G3P output
this._glucoseTimer += dt;
if (this._glucoseTimer > 800 / (rate * CO + 0.1)) {
this._glucoseTimer = 0;
if (L > 0.1 && CO > 0.05) this._spawnG3P();
if (L > 0.1 && CO > 0.05) {
this._spawnG3P();
// Calvin cycle complete — glucose sparkle + chime (throttled)
this._fxGlucoseSound = (this._fxGlucoseSound || 0) + 1;
if (this._fxGlucoseSound >= 3 && window.LabFX) {
this._fxGlucoseSound = 0;
LabFX.sound.play('chime', { pitch: 0.8, volume: 0.3 });
const L2 = this._layout;
if (L2.cx) {
LabFX.particles.emit({ ctx: this.ctx, x: L2.cx, y: L2.cy - (L2.thylH || 0) * 0.8,
count: 8, color: '#FFD166', speed: 28, spread: Math.PI * 2, angle: 0,
gravity: -8, life: 700, fade: true, glow: true, shape: 'spark', size: 3, sizeFade: true });
}
}
}
}
// Calvin cycle rotation
@@ -435,6 +470,7 @@ class PhotosynthesisSim {
this._drawParticles();
this._drawEquation();
if (window.LabFX) LabFX.particles.draw(this.ctx);
}
/* ── Chloroplast ──────────────────────────────────────────── */