A MoonBit toolkit for inspecting, validating, and optimizing glTF 2.0 and GLB
assets. It is designed for asset importers, build pipelines, CI checks, and
offline diagnostics—not for rendering.
Project positioning
moonbit-gltf-tools helps catch malformed or inefficient 3D assets before they
reach a runtime or an editor. The library keeps parsing and analysis
deterministic: external URIs are reported as dependencies and are not read
implicitly during parsing.
The project currently focuses on:
glTF 2.0 JSON documents and GLB containers;
structural validation and actionable diagnostics;
scene graph, transform, resource, accessor, and mesh analysis;
binary accessor decoding, GLB writing, semantic validation, and extension audits;
The implementation is organized as independent analysis passes over the typed
document model. Applications can use individual passes or compose them through
build_asset_report. Supporting passes cover attribute validation, derived
geometry metrics and sampling, LOD quality, material sampling, resource
integrity, animation compression, scene scheduling/snapshots, runtime budgets,
asset diffs, extension audits, normalization, and release-quality matrices.
Benchmarks
The benchmark protocol and recorded local baseline are maintained in
benchmarks documentation. Run the CLI benchmark fixture with:
moon run --target native cmd/main benchmarks/minimal.gltf --json
Recorded local baseline (2026-08-24): on Windows PowerShell with Moonc 0.10.10
and the native backend, five end-to-end samples were 2171.24, 418.56, 346.46,
263.58, and 272.16 ms; the median was 346.46 ms. The first sample included
build/cache warm-up. The fixture contains one scene and one node, and the JSON
report contains zero diagnostics. These figures are host-dependent; historical
samples and the exact protocol are documented in BENCHMARKS.md.
Benchmark comparisons should record the MoonBit version, target backend,
operating system, CPU, sample count, and whether the run includes a cold build.
Wall-clock results are host-dependent and should not be treated as universal
performance guarantees.
Testing
The test suite covers parser behavior, GLB boundaries, reference validation,
scene cycles, accessor layouts, URI classification, transforms, mesh analysis,
quality gates, and report generation.
Recommended local checks:
moon fmt
moon check --target all --deny-warn
moon test --target all --deny-warn
moon build --target native --deny-warn
moon info
moon info regenerates the public interface snapshots in pkg.generated.mbti
files. Review those files when public APIs change.
CI
The GitHub Actions workflow runs on Ubuntu, macOS, and Windows. It installs
Node.js and the official stable MoonBit toolchain (verified locally at Moonc
v0.10.10), then runs:
moon check –target all –deny-warn;
native build verification;
formatting and public-interface drift checks;
moon test –target all –deny-warn.
See the CI workflow at
.github/workflows/test.yml.
License
Apache License 2.0. See LICENSE.
关于
首个基于纯 MoonBit 开发的 glTF 2.0 / GLB 3D 资产解析、格式校验与性能优化诊断工具箱。
moonbit-gltf-tools
A MoonBit toolkit for inspecting, validating, and optimizing glTF 2.0 and GLB assets. It is designed for asset importers, build pipelines, CI checks, and offline diagnostics—not for rendering.
Project positioning
moonbit-gltf-tools helps catch malformed or inefficient 3D assets before they reach a runtime or an editor. The library keeps parsing and analysis deterministic: external URIs are reported as dependencies and are not read implicitly during parsing.
The project currently focuses on:
Core capabilities
Parsing
Validation and diagnostics
Analysis and optimization
Reporting
Quick start
Prerequisites
Install the current stable MoonBit toolchain and ensure moon is available on your PATH.
Build and test the repository
Run the sample asset
The repository includes a small deterministic fixture at benchmarks/minimal.gltf.
The first command prints a human-readable inspection report. The –json variant prints the machine-readable asset report for scripts and CI jobs.
Library usage
Add the package to a MoonBit project with:
Import the public gltf package:
For GLB input, call @gltf.unpack_glb first and pass the returned JSON string to @gltf.parse_gltf_string.
CLI
The CLI accepts a .gltf or .glb path:
The CLI reports:
Use –json when another tool should consume the complete AssetReport.
Architecture
The implementation is organized as independent analysis passes over the typed document model. Applications can use individual passes or compose them through build_asset_report. Supporting passes cover attribute validation, derived geometry metrics and sampling, LOD quality, material sampling, resource integrity, animation compression, scene scheduling/snapshots, runtime budgets, asset diffs, extension audits, normalization, and release-quality matrices.
Benchmarks
The benchmark protocol and recorded local baseline are maintained in benchmarks documentation. Run the CLI benchmark fixture with:
Recorded local baseline (2026-08-24): on Windows PowerShell with Moonc 0.10.10 and the native backend, five end-to-end samples were 2171.24, 418.56, 346.46, 263.58, and 272.16 ms; the median was 346.46 ms. The first sample included build/cache warm-up. The fixture contains one scene and one node, and the JSON report contains zero diagnostics. These figures are host-dependent; historical samples and the exact protocol are documented in BENCHMARKS.md.
Benchmark comparisons should record the MoonBit version, target backend, operating system, CPU, sample count, and whether the run includes a cold build. Wall-clock results are host-dependent and should not be treated as universal performance guarantees.
Testing
The test suite covers parser behavior, GLB boundaries, reference validation, scene cycles, accessor layouts, URI classification, transforms, mesh analysis, quality gates, and report generation.
Recommended local checks:
moon info regenerates the public interface snapshots in pkg.generated.mbti files. Review those files when public APIs change.
CI
The GitHub Actions workflow runs on Ubuntu, macOS, and Windows. It installs Node.js and the official stable MoonBit toolchain (verified locally at Moonc v0.10.10), then runs:
See the CI workflow at .github/workflows/test.yml.
License
Apache License 2.0. See LICENSE.