20 lines
883 B
JavaScript
20 lines
883 B
JavaScript
import { execFileSync } from "node:child_process";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
|
|
const probe = path.join(root, "tools/web/probe-collapse-ratio.mjs");
|
|
const ratios = [1, 0.9, 0.8, 0.75, 0.7, 0.65, 0.5, 0.25];
|
|
const results = [];
|
|
|
|
for (const ratio of ratios) {
|
|
const output = execFileSync(process.execPath, [probe, String(ratio)], { cwd: root, encoding: "utf8" }).trim();
|
|
const result = JSON.parse(output.split("\n").at(-1) ?? "{}");
|
|
if (result.result !== 0 || !result.output || result.output.triangleCount <= 0) {
|
|
throw new Error(`Collapse ratio ${ratio} failed: ${output}`);
|
|
}
|
|
results.push({ ratio, triangles: result.output.triangleCount, vertices: result.output.vertexCount });
|
|
}
|
|
|
|
console.log(`collapse-ratios-ok ${JSON.stringify(results)}`);
|