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:
@@ -417,6 +417,13 @@ class ChemSandboxSim {
|
||||
this.mixContents.push(formula);
|
||||
const sub = ChemSandboxSim.SUBSTANCES[formula];
|
||||
|
||||
if (window.LabFX) {
|
||||
LabFX.sound.play('pour');
|
||||
const { cx, nt, nw } = this._g;
|
||||
LabFX.particles.emit({ ctx: this.ctx, x: cx, y: nt - 10, count: 15, color: sub.color,
|
||||
speed: 60, spread: 1.8, angle: Math.PI / 2, gravity: 300, life: 800, shape: 'splash' });
|
||||
}
|
||||
|
||||
// pour animation
|
||||
this._pouring = true;
|
||||
this._pourColor = sub.color;
|
||||
@@ -552,6 +559,33 @@ class ChemSandboxSim {
|
||||
this._spawnSteam(fx.violent ? 25 : 12);
|
||||
if (fx.violent) this._spawnSparks(35);
|
||||
}
|
||||
|
||||
if (window.LabFX) {
|
||||
const { cx, cy } = this._g;
|
||||
if (fx.violent) {
|
||||
// Combustion-like: flame sparks + shake
|
||||
LabFX.sound.play('fizz');
|
||||
LabFX.particles.emit({ ctx: this.ctx, x: cx, y: cy - 20, count: 30,
|
||||
color: '#FFA500', speed: 90, spread: 2.5, angle: -Math.PI / 2,
|
||||
gravity: -100, life: 600, shape: 'spark', glow: true });
|
||||
LabFX.shake(this.canvas, { intensity: 3, durMs: 300 });
|
||||
} else if (fx.gas) {
|
||||
// Gas evolution: fizz + rising bubbles
|
||||
LabFX.sound.play('fizz');
|
||||
LabFX.particles.emit({ ctx: this.ctx, x: cx, y: cy, count: 10,
|
||||
color: '#FFFFFF', speed: 40, spread: 1.2, angle: -Math.PI / 2,
|
||||
gravity: -80, life: 1200, shape: 'ring' });
|
||||
} else if (fx.precip) {
|
||||
// Precipitate: settling dust
|
||||
LabFX.sound.play('fizz');
|
||||
LabFX.particles.emit({ ctx: this.ctx, x: cx, y: cy - 10, count: 12,
|
||||
color: fx.precip.c || '#888888', speed: 20, spread: 1.5, angle: Math.PI / 2,
|
||||
gravity: 60, life: 1500, shape: 'dust' });
|
||||
} else {
|
||||
LabFX.sound.play('fizz');
|
||||
}
|
||||
}
|
||||
|
||||
this._fireInfo();
|
||||
}
|
||||
|
||||
@@ -648,6 +682,8 @@ class ChemSandboxSim {
|
||||
this._wave3 += dt * 0.88;
|
||||
this._glowPulse += dt * 3.2;
|
||||
|
||||
if (window.LabFX) LabFX.particles.update(dt);
|
||||
|
||||
if (this._animPhase === 1) {
|
||||
this._reacTimer += dt;
|
||||
if (this._reacTimer > 5.0) this._animPhase = 2;
|
||||
@@ -784,6 +820,7 @@ class ChemSandboxSim {
|
||||
this._drawDragGhost();
|
||||
if (this.mixContents.length === 0 && !this.lastReaction && !this._quizMode) this._drawHint();
|
||||
if (this._quizMode) this._drawQuizOverlay();
|
||||
if (window.LabFX) LabFX.particles.draw(ctx);
|
||||
}
|
||||
|
||||
_drawBackground() {
|
||||
@@ -1541,6 +1578,7 @@ class ChemSandboxSim {
|
||||
|
||||
handleContextMenu(e) {
|
||||
e.preventDefault();
|
||||
if (window.LabFX) LabFX.sound.play('whoosh', { pitch: 0.7, volume: 0.3 });
|
||||
this.reset();
|
||||
}
|
||||
|
||||
@@ -1718,7 +1756,7 @@ class ChemSandboxSim {
|
||||
}
|
||||
|
||||
function chemSandPreset(name) { if (chemSandSim) { chemSandSim.preset(name); _chemSandBuildReagents(chemSandSim.filterCat); } }
|
||||
function chemSandReset() { if (chemSandSim) { chemSandSim.reset(); _chemSandBuildReagents(chemSandSim.filterCat); } }
|
||||
function chemSandReset() { if (chemSandSim) { if (window.LabFX) LabFX.sound.play('whoosh', { pitch: 0.7, volume: 0.3 }); chemSandSim.reset(); _chemSandBuildReagents(chemSandSim.filterCat); } }
|
||||
function chemSandResetReaction() { if (chemSandSim) { chemSandSim.resetReaction(); _chemSandBuildReagents(chemSandSim.filterCat); } }
|
||||
|
||||
function chemSandConcChange() {
|
||||
@@ -1736,6 +1774,7 @@ class ChemSandboxSim {
|
||||
if (chemSandSim.mixContents.includes(formula)) {
|
||||
chemSandSim.removeFromMix(formula);
|
||||
} else {
|
||||
if (window.LabFX) LabFX.sound.play('click', { pitch: 1.2 });
|
||||
chemSandSim.addToMix(formula);
|
||||
}
|
||||
_chemSandBuildReagents(chemSandSim.filterCat);
|
||||
|
||||
Reference in New Issue
Block a user