tarinai/scripts/render_stack_regression_audit.js
2026-07-18 13:06:02 +09:00

16 lines
1.7 KiB
JavaScript

const fs = require("fs");
const path = require("path");
const root = path.resolve(__dirname, "..");
const render = fs.readFileSync(path.join(root, "js", "render.js"), "utf8");
const spatial = fs.readFileSync(path.join(root, "js", "sim_core.js"), "utf8");
const budget = fs.readFileSync(path.join(root, "js", "world_spatial_budget.js"), "utf8");
function ok(cond, msg) { if (!cond) throw new Error(msg); console.log(`[OK] ${msg}`); }
ok(render.includes("_renderStaticVisibleCache") && render.includes("renderStaticVersion"), "static visible render stacks are version-cached");
ok(!render.includes("insertionSortNearPrevious") && render.includes("dynamicLayered.sort(compareRenderEntries)"), "dynamic sorting uses native sort without previous-order bookkeeping");
ok(render.includes("mergeSortedRenderEntries") && render.includes("mergeSortedBackItems"), "static and dynamic sorted stacks are merged linearly");
ok(spatial.includes("linkRenderCells") && spatial.includes("addLinkRenderItem") && spatial.includes("rebuildLinkRenderItems"), "links use dedicated AABB render spatial cells");
ok(!render.includes("for (const type of LINK_RENDER_TYPES)"), "per-frame full link type fallback scan is removed");
ok(render.includes("drawCarriedPlushieAtOwner") && !render.includes("syncCarriedPlushieToOwner"), "carried plushie rendering no longer synchronizes simulation coordinates");
ok(render.includes("entity._renderCullRadius = value"), "eligible fixed cull radii are cached");
ok(render.includes("it._renderSortY = renderLayerSortY(it)"), "back-layer sort keys are computed before sorting");
ok(budget.includes("this.renderStaticVersion = (this.renderStaticVersion || 0) + 1"), "static spatial rebuilds invalidate the render cache");