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:
@@ -110,7 +110,11 @@ class CellDivisionSim {
|
||||
if (!this._raf) this._draw();
|
||||
}
|
||||
|
||||
setMode(mode) { this.mode = mode; this.reset(); }
|
||||
setMode(mode) {
|
||||
this.mode = mode;
|
||||
if (window.LabFX) LabFX.sound.play('click', { pitch: 1.2 });
|
||||
this.reset();
|
||||
}
|
||||
setSpeed(s) { this._speed = s; }
|
||||
|
||||
nextPhase() {
|
||||
@@ -118,6 +122,7 @@ class CellDivisionSim {
|
||||
this._phaseIdx = (this._phaseIdx + 1) % phases.length;
|
||||
this._phaseT = 0;
|
||||
this._particles = [];
|
||||
if (window.LabFX) LabFX.sound.play('whoosh', { pitch: 1.0 + this._phaseIdx * 0.05, volume: 0.3 });
|
||||
this._emitUpdate();
|
||||
if (!this._raf) this._draw();
|
||||
}
|
||||
@@ -127,6 +132,7 @@ class CellDivisionSim {
|
||||
this._phaseIdx = (this._phaseIdx - 1 + phases.length) % phases.length;
|
||||
this._phaseT = 0;
|
||||
this._particles = [];
|
||||
if (window.LabFX) LabFX.sound.play('whoosh', { pitch: 1.0 + this._phaseIdx * 0.05, volume: 0.3 });
|
||||
this._emitUpdate();
|
||||
if (!this._raf) this._draw();
|
||||
}
|
||||
@@ -136,6 +142,7 @@ class CellDivisionSim {
|
||||
this._phaseIdx = Math.max(0, Math.min(phases.length - 1, idx));
|
||||
this._phaseT = 0;
|
||||
this._particles = [];
|
||||
if (window.LabFX) LabFX.sound.play('whoosh', { pitch: 1.0 + this._phaseIdx * 0.05, volume: 0.3 });
|
||||
this._emitUpdate();
|
||||
if (!this._raf) this._draw();
|
||||
}
|
||||
@@ -254,9 +261,48 @@ class CellDivisionSim {
|
||||
this._phaseT > 0.34 && this._phaseT < 0.38 && this._particles.length < 5) {
|
||||
const cellR = Math.min(this.W, this.H) * 0.37;
|
||||
this._spawnEnvelopeParticles(this.W / 2, this.H / 2, cellR * 0.46);
|
||||
// dust particles from LabFX around condensing chromosomes
|
||||
if (window.LabFX) {
|
||||
const cx = this.W / 2, cy = this.H / 2;
|
||||
LabFX.particles.emit({ ctx: this.ctx, x: cx, y: cy, count: 6, color: '#9B5DE5',
|
||||
speed: 18, spread: Math.PI * 2, angle: 0, gravity: 0, life: 700, fade: true,
|
||||
glow: false, shape: 'dust', size: 3, sizeFade: true });
|
||||
}
|
||||
}
|
||||
|
||||
// anaphase: tick sound at start of separation + pole sparks
|
||||
if ((phase.id === 'anaphase' || phase.id === 'anaphase1' || phase.id === 'anaphase2') &&
|
||||
this._phaseT > 0.05 && this._phaseT < 0.10 && !this._anaphaseTickDone) {
|
||||
this._anaphaseTickDone = true;
|
||||
if (window.LabFX) {
|
||||
LabFX.sound.play('tick', { pitch: 1.3 });
|
||||
const cx = this.W / 2, cellR = Math.min(this.W, this.H) * 0.37;
|
||||
const poleY = cellR * 0.7 * this._phaseT;
|
||||
for (const sy of [-1, 1]) {
|
||||
LabFX.particles.emit({ ctx: this.ctx, x: cx, y: this.H / 2 + sy * poleY,
|
||||
count: 5, color: '#FFD166', speed: 22, spread: Math.PI * 2, angle: 0,
|
||||
gravity: 0, life: 500, fade: true, glow: true, shape: 'spark', size: 3, sizeFade: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
if (phase.id !== 'anaphase' && phase.id !== 'anaphase1' && phase.id !== 'anaphase2') {
|
||||
this._anaphaseTickDone = false;
|
||||
}
|
||||
|
||||
if (this._phaseT >= 1) {
|
||||
// cytokinesis complete
|
||||
if (phase.id === 'cytokinesis') {
|
||||
if (window.LabFX) {
|
||||
LabFX.sound.play('chime');
|
||||
const cx = this.W / 2, cy = this.H / 2;
|
||||
const cellR = Math.min(this.W, this.H) * 0.37;
|
||||
for (const sy of [-1, 1]) {
|
||||
LabFX.particles.emit({ ctx: this.ctx, x: cx, y: cy + sy * cellR * 0.5,
|
||||
count: 10, color: '#22d399', speed: 30, spread: Math.PI * 2, angle: 0,
|
||||
gravity: 0, life: 800, fade: true, glow: true, shape: 'ring', size: 5, sizeFade: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
this._phaseT = 0;
|
||||
this._phaseIdx = (this._phaseIdx + 1) % phases.length;
|
||||
this._particles = [];
|
||||
@@ -269,6 +315,7 @@ class CellDivisionSim {
|
||||
p.life -= p.decay; return p.life > 0;
|
||||
});
|
||||
|
||||
if (window.LabFX) LabFX.particles.update(dt);
|
||||
this._emitUpdate();
|
||||
this._draw();
|
||||
}
|
||||
@@ -316,6 +363,7 @@ class CellDivisionSim {
|
||||
this._drawOverlay(phase);
|
||||
this._drawProgressBar();
|
||||
this._drawHint();
|
||||
if (window.LabFX) LabFX.particles.draw(this.ctx);
|
||||
}
|
||||
|
||||
/* ── Cell / nucleus ─────────────────────────────────────────── */
|
||||
|
||||
Reference in New Issue
Block a user