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:
@@ -207,8 +207,10 @@ class ElectrolysisSim {
|
||||
if (!this.playing) return;
|
||||
this._raf = requestAnimationFrame(ts => {
|
||||
if (!this._lastTs) this._lastTs = ts;
|
||||
const dt = Math.min((ts - this._lastTs) / 1000, 0.05) * this.speed;
|
||||
const rawDt = Math.min((ts - this._lastTs) / 1000, 0.05);
|
||||
const dt = rawDt * this.speed;
|
||||
this._lastTs = ts;
|
||||
if (window.LabFX) LabFX.particles.update(rawDt);
|
||||
this._step(dt); this.draw(); this._emit(); this._tick();
|
||||
});
|
||||
}
|
||||
@@ -231,6 +233,9 @@ class ElectrolysisSim {
|
||||
|
||||
// Ion drift + thermal jitter
|
||||
const drift = I * 0.45;
|
||||
this._fxIonTrailAcc = (this._fxIonTrailAcc || 0) + dt;
|
||||
const doTrail = this._fxIonTrailAcc >= 0.1;
|
||||
if (doTrail) this._fxIonTrailAcc = 0;
|
||||
for (const ion of this._ions) {
|
||||
ion.vx += (ion.charge > 0 ? -drift : drift) * dt + (Math.random() - 0.5) * 0.18;
|
||||
ion.vy += (Math.random() - 0.5) * 0.14;
|
||||
@@ -239,6 +244,12 @@ class ElectrolysisSim {
|
||||
ion.x += ion.vx; ion.y += ion.vy;
|
||||
ion.x = Math.max(cx + 4, Math.min(cx + cw - 4, ion.x));
|
||||
ion.y = Math.max(cy + 4, Math.min(cy + ch - 4, ion.y));
|
||||
// LabFX: ion trail dot
|
||||
if (window.LabFX && doTrail && Math.random() < 0.3) {
|
||||
LabFX.particles.emit({ ctx: this.ctx, x: ion.x, y: ion.y, count: 1,
|
||||
color: '#FFD166', speed: 4, spread: 3.14, angle: 0,
|
||||
gravity: 0, life: 300, shape: 'dot', glow: true });
|
||||
}
|
||||
}
|
||||
|
||||
// Ions reaching electrodes → discharge + bubbles
|
||||
@@ -253,6 +264,14 @@ class ElectrolysisSim {
|
||||
elec.cathode.x + elec.cathode.w + 2 + Math.random() * 4,
|
||||
elec.cathode.y + Math.random() * elec.cathode.h,
|
||||
el.cathodeBubColor);
|
||||
// LabFX: rising ring bubble from cathode
|
||||
if (window.LabFX) {
|
||||
LabFX.particles.emit({ ctx: this.ctx,
|
||||
x: elec.cathode.x + elec.cathode.w + 3,
|
||||
y: elec.cathode.y + Math.random() * elec.cathode.h,
|
||||
count: 1, color: '#FFFFFF', speed: 20, spread: 0.4, angle: -Math.PI / 2,
|
||||
gravity: -60, life: 1500, shape: 'ring' });
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ion.charge < 0 && ion.x >= elec.anode.x - 5) {
|
||||
@@ -263,9 +282,25 @@ class ElectrolysisSim {
|
||||
elec.anode.x - 2 - Math.random() * 4,
|
||||
elec.anode.y + Math.random() * elec.anode.h,
|
||||
el.anodeBubColor);
|
||||
// LabFX: rising ring bubble from anode
|
||||
if (window.LabFX) {
|
||||
LabFX.particles.emit({ ctx: this.ctx,
|
||||
x: elec.anode.x - 3,
|
||||
y: elec.anode.y + Math.random() * elec.anode.h,
|
||||
count: 1, color: '#FFFFFF', speed: 20, spread: 0.4, angle: -Math.PI / 2,
|
||||
gravity: -60, life: 1500, shape: 'ring' });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Periodic fizz sound when current is flowing
|
||||
if (window.LabFX && I > 0.01) {
|
||||
this._fxFizzAcc = (this._fxFizzAcc || 0) + dt;
|
||||
if (this._fxFizzAcc >= 2.0) {
|
||||
this._fxFizzAcc = 0;
|
||||
LabFX.sound.play('fizz', { volume: 0.2 });
|
||||
}
|
||||
}
|
||||
this._ions = this._ions.filter((_, i) => !rm.has(i));
|
||||
|
||||
// Replenish ions to keep count ~15 each
|
||||
@@ -308,6 +343,7 @@ class ElectrolysisSim {
|
||||
this._drawIons();
|
||||
this._drawLabels();
|
||||
this._drawInfoPanel();
|
||||
if (window.LabFX) LabFX.particles.draw(this.ctx);
|
||||
}
|
||||
|
||||
_drawCellBody() {
|
||||
@@ -559,7 +595,10 @@ if (typeof module !== 'undefined') module.exports = ElectrolysisSim;
|
||||
|
||||
function elecParam(name, val) {
|
||||
const v = parseFloat(val);
|
||||
if (name === 'voltage') document.getElementById('elec-V-val').textContent = v;
|
||||
if (name === 'voltage') {
|
||||
document.getElementById('elec-V-val').textContent = v;
|
||||
if (window.LabFX) LabFX.sound.play('spark', { volume: 0.3 });
|
||||
}
|
||||
if (elecSim) elecSim.setParams({ [name]: v });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user