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:
@@ -54,7 +54,13 @@ class IsoprocessSim {
|
||||
this.W = w; this.H = h;
|
||||
}
|
||||
|
||||
setProcess(p) { this.process = p; this.draw(); this._emit(); }
|
||||
setProcess(p) {
|
||||
this.process = p;
|
||||
if (window.LabFX) LabFX.sound.play('click');
|
||||
this._dustFrame = 0;
|
||||
this.draw();
|
||||
this._emit();
|
||||
}
|
||||
setGamma(g) { this.gamma = +g; this.draw(); this._emit(); }
|
||||
getParams() { return { P1: this.P1, V1: this.V1, process: this.process }; }
|
||||
setParams({ P1, V1 } = {}) {
|
||||
@@ -158,6 +164,30 @@ class IsoprocessSim {
|
||||
this._drawActiveCurve(ctx);
|
||||
this._drawPoints(ctx);
|
||||
this._drawInfoBox(ctx);
|
||||
/* emit dust particle along PV curve every ~5 draw calls */
|
||||
if (window.LabFX) {
|
||||
this._dustFrame = (this._dustFrame || 0) + 1;
|
||||
if (this._dustFrame % 5 === 0) {
|
||||
const { P2, V2 } = this._state2();
|
||||
/* interpolated point at 50% of curve for dust */
|
||||
const u = ((this._dustFrame / 5) % 10) / 10;
|
||||
let px, py;
|
||||
switch (this.process) {
|
||||
case 'isothermal': { const v = this.V1 + u * (V2 - this.V1); px = this._vx(v); py = this._py(this.P1 * this.V1 / v); break; }
|
||||
case 'isochoric': { px = this._vx(this.V1); py = this._py(this.P1 + u * (P2 - this.P1)); break; }
|
||||
case 'isobaric': { const v2 = this.V1 + u * (V2 - this.V1); px = this._vx(v2); py = this._py(this.P1); break; }
|
||||
case 'adiabatic': { const v3 = this.V1 + u * (V2 - this.V1); px = this._vx(v3); py = this._py(this.P1 * Math.pow(this.V1 / v3, this.gamma)); break; }
|
||||
default: px = this._vx(this.V1); py = this._py(this.P1);
|
||||
}
|
||||
LabFX.particles.emit({
|
||||
ctx, x: px, y: py,
|
||||
count: 1, color: '#06D6E0', speed: 8,
|
||||
spread: Math.PI * 2, angle: 0, gravity: 0,
|
||||
life: 300, shape: 'dust', size: 2,
|
||||
});
|
||||
}
|
||||
LabFX.particles.draw(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
_drawGrid(ctx) {
|
||||
@@ -488,6 +518,7 @@ class IsoprocessSim {
|
||||
document.querySelectorAll('.iso-proc-btn').forEach(b => b.classList.remove('active'));
|
||||
if (el) el.classList.add('active');
|
||||
if (isoSim) isoSim.setProcess(proc);
|
||||
/* sound already emitted inside setProcess */
|
||||
}
|
||||
|
||||
function isoGamma(g, el) {
|
||||
|
||||
Reference in New Issue
Block a user