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:
@@ -0,0 +1,46 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
|
||||
import {
|
||||
FIELD_STAMP_MAX_SPRITES,
|
||||
decimateFieldStampPoints,
|
||||
fieldStampMinSpacingN,
|
||||
} from './fieldEffectStampPoints';
|
||||
import type { NPoint } from './types/effects';
|
||||
|
||||
function pt(x: number, y: number, tMs = 0): NPoint {
|
||||
return { x, y, tMs };
|
||||
}
|
||||
|
||||
void test('decimateFieldStampPoints: пустой и одна точка', () => {
|
||||
assert.deepEqual(decimateFieldStampPoints([], 0.05), []);
|
||||
const one = [pt(0.2, 0.3)];
|
||||
assert.deepEqual(decimateFieldStampPoints(one, 0.05), one);
|
||||
});
|
||||
|
||||
void test('decimateFieldStampPoints: оставляет концы и выкидывает близкие середины', () => {
|
||||
const points = [pt(0, 0.5), pt(0.01, 0.5), pt(0.02, 0.5), pt(0.5, 0.5), pt(0.51, 0.5), pt(1, 0.5)];
|
||||
const out = decimateFieldStampPoints(points, 0.1);
|
||||
assert.equal(out[0]?.x, 0);
|
||||
assert.equal(out[out.length - 1]?.x, 1);
|
||||
assert.ok(out.length < points.length);
|
||||
assert.ok(out.length >= 3);
|
||||
});
|
||||
|
||||
void test('decimateFieldStampPoints: maxPoints режет длинный штрих', () => {
|
||||
const points: NPoint[] = [];
|
||||
for (let i = 0; i <= 200; i += 1) {
|
||||
points.push(pt(i / 200, 0.4, i));
|
||||
}
|
||||
const out = decimateFieldStampPoints(points, 0.001, 16);
|
||||
assert.ok(out.length <= 16);
|
||||
assert.equal(out[0]?.x, 0);
|
||||
assert.equal(out[out.length - 1]?.x, 1);
|
||||
});
|
||||
|
||||
void test('fieldStampMinSpacingN: огонь реже тумана', () => {
|
||||
const r = 0.04;
|
||||
assert.ok(fieldStampMinSpacingN('fire', r) > fieldStampMinSpacingN('fog', r));
|
||||
assert.ok(fieldStampMinSpacingN('fog', r) >= 0.006);
|
||||
assert.equal(FIELD_STAMP_MAX_SPRITES, 40);
|
||||
});
|
||||
Reference in New Issue
Block a user