Convert STEP to GLB and enforce a 3D asset budget
说明与用途
将STEP转换为GLB,并执行大小、三角形和节点预算检查,集成到CI中。
问题
Need to convert CAD STEP files to web‑friendly GLB meshes while ensuring the resulting asset stays within size, triangle, and node limits for efficient web delivery.
结果
The workflow produces a 3,356‑byte GLB with 8 triangles, 24 vertices, and 5 nodes from a two‑tetrahedra STEP fixture, and the budget check passes. When the byte budget is tightened to 3,000, the check fails with exit code 1, demonstrating the gate.
工作流
- Install Node.js 22+ and Rust toolchain.
Run
npm init -yandnpm install --save-exact [email protected]. Install glbscope withcargo install glbscope --version 0.3.0 --locked. Download a test STEP fixture. Runnpx step2glb inspect sample.stepto view assembly manifest. Runnpx step2glb build sample.step --out sample.glb --preset webto generate GLB. Createbudget.tomlwith max_bytes, max_triangles, max_nodes. Runglbscope --budget budget.toml sample.glbto validate against budget. Generate reports:glbscope --format markdown --budget budget.toml sample.glb > model-report.mdandglbscope --json sample.glb > baseline.json. Useglbscope --baseline baseline.json sample.glbto detect regressions. Integrate budget check into CI as a build step.
证据
Use Node.js 22 or later and a current Rust toolchain:
npx step2glb inspect sample.step npx step2glb build sample.step --out sample.glb --preset web
The sample passes. To prove that the gate works, temporarily set max_bytes = 3_000 and run it again. The 3,356-byte sample fails with exit code 1
- 记录日期: 2026-10-15T11:56:08.818Z