fix(effects): снизить лаги сцены на Mac
Pixi режется по contentRect, пульт идёт в preview (12 FPS, 0.5 DPR), штампы тумана/огня/дождя прореживаются, draft темноты и маркера не чаще 20 Гц. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -95,6 +95,8 @@ import { getSunbeamEffectLifeMs, playSunbeamEffectSound } from './sunbeamSfx';
|
||||
|
||||
/** Длительность молнии: быстрый удар + акцент в точке попадания. */
|
||||
const LIGHTNING_EFFECT_MS = 840;
|
||||
/** Темнота/маркер на презентацию — не чаще 20 Гц (полный canvas replay в обоих окнах). */
|
||||
const OVERLAY_DRAFT_IPC_MS = 50;
|
||||
|
||||
function dispositionMakeKey(d: NpcDisposition): string {
|
||||
if (d === 'hostile') return 'npcs.makeHostile';
|
||||
@@ -305,6 +307,7 @@ export function ControlApp() {
|
||||
const brushCursorElRef = useRef<HTMLDivElement | null>(null);
|
||||
const cursorPosRef = useRef<{ x: number; y: number } | null>(null);
|
||||
const draftPaintRafRef = useRef(0);
|
||||
const overlayDraftIpcAtRef = useRef(0);
|
||||
const effectsOverlayRef = useRef<PixiEffectsOverlayHandle | null>(null);
|
||||
const [explosionDraft, setExplosionDraft] = useState<ExplosionInstance | null>(null);
|
||||
const draftMetaRef = useRef<{ createdAtMs: number; seed: number } | null>(null);
|
||||
@@ -1387,6 +1390,9 @@ export function ControlApp() {
|
||||
draftPaintRafRef.current = 0;
|
||||
pushDraftToPixi();
|
||||
const b = brushRef.current;
|
||||
const now = performance.now();
|
||||
if (now - overlayDraftIpcAtRef.current < OVERLAY_DRAFT_IPC_MS) return;
|
||||
overlayDraftIpcAtRef.current = now;
|
||||
if (
|
||||
(b?.tool === 'exploreBrush' || b?.tool === 'closeBrush') &&
|
||||
b.points
|
||||
@@ -2512,6 +2518,7 @@ export function ControlApp() {
|
||||
<PixiEffectsOverlay
|
||||
ref={effectsOverlayRef}
|
||||
state={fxState}
|
||||
perfProfile="preview"
|
||||
style={{ zIndex: 6 }}
|
||||
viewport={
|
||||
previewContentRect
|
||||
|
||||
@@ -32,6 +32,8 @@ void test('ControlApp: draft кисти без корневого draftFxTick',
|
||||
assert.ok(pixi.includes('setDraft'));
|
||||
assert.ok(pixi.includes('mergeDraftState'));
|
||||
assert.ok(pixi.includes('forwardRef'));
|
||||
assert.ok(app.includes('perfProfile="preview"'));
|
||||
assert.ok(app.includes('OVERLAY_DRAFT_IPC_MS'));
|
||||
});
|
||||
|
||||
void test('ControlApp: path playback не гоняет setState корня', () => {
|
||||
|
||||
Reference in New Issue
Block a user