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:
@@ -174,6 +174,7 @@ class AngryBirdsSim {
|
||||
const tick = (ts) => {
|
||||
const dt = this._lastTs ? Math.min((ts - this._lastTs) / 1000, 0.05) : 0.016;
|
||||
this._lastTs = ts;
|
||||
if (window.LabFX) LabFX.particles.update(dt);
|
||||
this._update(dt);
|
||||
this.draw();
|
||||
this._raf = requestAnimationFrame(tick);
|
||||
@@ -198,6 +199,8 @@ class AngryBirdsSim {
|
||||
this._drawQueue();
|
||||
this._drawHUD();
|
||||
if (this.state === 'win' || this.state === 'lose') this._drawOverlay();
|
||||
/* LabFX: particles overlay */
|
||||
if (window.LabFX) LabFX.particles.draw(this.ctx);
|
||||
}
|
||||
|
||||
info() {
|
||||
@@ -319,6 +322,8 @@ class AngryBirdsSim {
|
||||
this.bird.launched = true;
|
||||
this.state = 'flying';
|
||||
this._emit('launch', this.bird.x, this.bird.y, this.bird.color, 8);
|
||||
/* LabFX: launch sound */
|
||||
if (window.LabFX) LabFX.sound.play('whoosh', { pitch: 0.8 });
|
||||
if (this.onUpdate) this.onUpdate(this.info());
|
||||
}
|
||||
|
||||
@@ -482,10 +487,28 @@ class AngryBirdsSim {
|
||||
b.hp -= dmg;
|
||||
this.score += Math.max(0, Math.floor(dmg * 3));
|
||||
this._emit('hit', cx, cy, AB_MATS[b.mat]?.debris || '#888', 5);
|
||||
/* LabFX: bird-block collision */
|
||||
if (window.LabFX) {
|
||||
LabFX.sound.play('bounce');
|
||||
LabFX.particles.emit({
|
||||
ctx: this.ctx, x: cx, y: cy,
|
||||
count: 15, color: '#FFD166', speed: 80,
|
||||
spread: Math.PI * 2, life: 400, shape: 'spark',
|
||||
});
|
||||
}
|
||||
if (b.hp <= 0) {
|
||||
b.destroyed = true;
|
||||
this.score += 500;
|
||||
this._emit('destroy', b.x + b.w / 2, b.y + b.h / 2, AB_MATS[b.mat]?.debris || '#888', 15);
|
||||
/* LabFX: block destroyed */
|
||||
if (window.LabFX) {
|
||||
LabFX.sound.play('fizz');
|
||||
LabFX.particles.emit({
|
||||
ctx: this.ctx, x: b.x + b.w / 2, y: b.y + b.h / 2,
|
||||
count: 25, color: AB_MATS[b.mat]?.debris || '#888',
|
||||
speed: 100, spread: Math.PI * 2, life: 700, shape: 'splash',
|
||||
});
|
||||
}
|
||||
}
|
||||
bird.x += nx * (bird.r - dist + 1);
|
||||
bird.y += ny * (bird.r - dist + 1);
|
||||
@@ -519,6 +542,16 @@ class AngryBirdsSim {
|
||||
p.destroyed = true;
|
||||
this.score += 5000;
|
||||
this._emit('destroy', p.x, p.y, '#4ade80', 20);
|
||||
/* LabFX: pig defeated */
|
||||
if (window.LabFX) {
|
||||
LabFX.sound.play('chime');
|
||||
LabFX.particles.emit({
|
||||
ctx: this.ctx, x: p.x, y: p.y,
|
||||
count: 30, color: ['#06D6E0', '#FFD166', '#EF476F'],
|
||||
speed: 130, spread: Math.PI * 2, life: 800,
|
||||
glow: true, shape: 'spark',
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this._emit('hit', p.x, p.y, '#86efac', 5);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user