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:
@@ -140,6 +140,21 @@ class ProjectileSim {
|
||||
this._lastTs = null;
|
||||
/* reset p2 at launch so both start simultaneously */
|
||||
if (this.dualMode) { this._p2.t = 0; this._p2.trail = []; }
|
||||
/* LabFX: launch effects */
|
||||
if (window.LabFX) {
|
||||
const _vp = this._viewParams;
|
||||
const _H = _vp ? _vp.H : (this._ch || this.c.height);
|
||||
const _PL = _vp ? _vp.PL : 54, _PB = _vp ? _vp.PB : 44;
|
||||
const launchX = _vp ? _PL : 54;
|
||||
const launchY = _vp ? _H - _PB - (this.h0 || 0) * (_H - _PB - (_vp.PT || 26)) / _vp.yMax : _H - 44;
|
||||
LabFX.sound.play('whoosh');
|
||||
LabFX.particles.emit({
|
||||
ctx: this.ctx, x: launchX, y: launchY,
|
||||
count: 18, color: '#FFD166', speed: 120,
|
||||
spread: Math.PI / 3, angle: -Math.PI / 3,
|
||||
life: 500, glow: true, shape: 'spark',
|
||||
});
|
||||
}
|
||||
this._tick();
|
||||
}
|
||||
|
||||
@@ -228,6 +243,19 @@ class ProjectileSim {
|
||||
tgt.hit = true;
|
||||
tgt.flashTs = performance.now();
|
||||
this._emitTargets();
|
||||
/* LabFX: target hit effects */
|
||||
if (window.LabFX) {
|
||||
const hx = this.tx ? this.tx(st.x) : st.x;
|
||||
const hy = this.ty ? this.ty(st.y) : st.y;
|
||||
LabFX.sound.play('chime');
|
||||
LabFX.particles.emit({
|
||||
ctx: this.ctx, x: hx, y: hy,
|
||||
count: 40, color: ['#FFD700', '#FFA500', '#FF6B35'],
|
||||
speed: 140, spread: Math.PI * 2, life: 900,
|
||||
glow: true, shape: 'spark',
|
||||
});
|
||||
LabFX.haptic([15, 30, 15]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -722,6 +750,8 @@ class ProjectileSim {
|
||||
const rawDt = Math.min((ts - this._lastTs) / 1000, 0.05);
|
||||
this._lastTs = ts;
|
||||
|
||||
if (window.LabFX) LabFX.particles.update(rawDt);
|
||||
|
||||
this._launchFlash = Math.max(0, this._launchFlash - rawDt * 2.5);
|
||||
|
||||
const prevT = this.t;
|
||||
@@ -765,6 +795,26 @@ class ProjectileSim {
|
||||
const spd = 40 + Math.random() * 80;
|
||||
return { ang, spd, mx: end.x };
|
||||
});
|
||||
/* LabFX: landing effects */
|
||||
if (window.LabFX) {
|
||||
const _vp = this._viewParams;
|
||||
const _W = _vp ? _vp.W : (this._cw || this.c.width);
|
||||
const _H = _vp ? _vp.H : (this._ch || this.c.height);
|
||||
const _PL = _vp ? _vp.PL : 54, _PB = _vp ? _vp.PB : 44;
|
||||
const _scX = _vp ? (_W - _PL - (_vp.PR || 20)) / _vp.xMax : 1;
|
||||
const _scY = _vp ? (_H - _PB - (_vp.PT || 26)) / _vp.yMax : 1;
|
||||
const landX = _vp ? _PL + end.x * _scX : 54;
|
||||
const landY = _vp ? _H - _PB : _H - 44;
|
||||
LabFX.sound.play('bounce', { pitch: 0.6 });
|
||||
LabFX.particles.emit({
|
||||
ctx: this.ctx, x: landX, y: landY,
|
||||
count: 30, color: '#8B7355', speed: 80,
|
||||
spread: Math.PI, angle: -Math.PI / 2,
|
||||
gravity: 200, life: 1200, shape: 'splash',
|
||||
});
|
||||
LabFX.shake(this.c, { intensity: 4, durMs: 200 });
|
||||
LabFX.haptic(15);
|
||||
}
|
||||
this._tickFX();
|
||||
}
|
||||
|
||||
@@ -854,6 +904,22 @@ class ProjectileSim {
|
||||
/* ── 2.5. Wind streaks ── */
|
||||
if (this.wind !== 0) {
|
||||
this._drawWind(ctx, PL, PT, pw, gy - PT);
|
||||
/* LabFX: wind dust particles */
|
||||
if (window.LabFX && this.playing) {
|
||||
const dir = this.wind > 0 ? 1 : -1;
|
||||
const dustCount = Math.floor(3 + Math.random() * 3);
|
||||
for (let _d = 0; _d < dustCount; _d++) {
|
||||
const dustX = dir > 0 ? PL : PL + pw;
|
||||
const dustY = PT + Math.random() * (gy - PT);
|
||||
LabFX.particles.emit({
|
||||
ctx, x: dustX, y: dustY,
|
||||
count: 1, color: 'rgba(255,255,255,0.3)',
|
||||
speed: 0, spread: 0, angle: 0,
|
||||
life: 1500, shape: 'dust', gravity: 0,
|
||||
_vx: this.wind * 5, _vy: -10,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ── 3. Ground ── */
|
||||
@@ -1336,6 +1402,9 @@ class ProjectileSim {
|
||||
if (!this.playing && this._hover) {
|
||||
this._drawInspector(ctx, tpx, tpy, PL, gy, W, H, PB, PT);
|
||||
}
|
||||
|
||||
/* LabFX: particles overlay */
|
||||
if (window.LabFX) LabFX.particles.draw(this.ctx);
|
||||
}
|
||||
|
||||
/* ── hover inspector ── */
|
||||
|
||||
Reference in New Issue
Block a user