$ show donmccurdy/glTF-Transform
glTF-Transform is a comprehensive SDK and CLI tool for processing, optimizing, and inspecting glTF/GLB 3D assets. It provides a rich property graph model (Document) for reading, editing, and writing glTF files, with full support for the glTF 2.0 specification and dozens of official extensions (KHR_materials_*, EXT_meshopt_compression, etc.). The library includes a broad set of transforms (compression, quantization, deduplication, welding, palette optimization, texture compression, etc.) that can be composed into custom pipelines. A command-line interface wraps all transforms for batch processing, and a viewer package provides real-time Three.js integration. Built as a monorepo with packages for core, extensions, functions, CLI, view, and docs, it demonstrates strong software engineering practices: property-graph architecture, extension system, observer patterns, and comprehensive unit/integration tests. Designed for both scripting in Node.js/Deno/Web and direct use from the command line.
The LLM identified 5 files worth highlighting for reuse:
Base class for all glTF extensions. Provides hooks (preread, read, prewrite, write) for reading/writing extension properties from/to JSON. Can be extended to add new glTF extension support with minimal boilerplate. Demonstrates a clean plugin system that can be reused for any JSON-based format that needs extensible properties.
Base property class using a graph structure (GraphNode from property-graph library). Manages references between properties (e.g., Mesh references Accessors, Materials reference Textures). Enables efficient traversal, disposal, and copying of complex 3D scenes. The pattern of using a directed graph for entity relationships is reusable in any domain requiring interdependent objects.
Implements a reactive observer that watches a reference (e.g., a glTF property reference) and triggers callbacks on add, remove, or update. Part of a family of observers (RefListObserver, RefMapObserver) that enable real-time synchronization between a data model and a Three.js scene. This pattern is reusable for any reactive UI or data-binding system.
Provides `createTransform` and `assignDefaults` utilities used by all transform functions. `createTransform` wraps an async function with a name and optional logging; it standardizes the transform interface. `assignDefaults` merges user options with defaults. This pattern for composing operations into a pipeline is reusable in any processing pipeline where steps need to be named, ordered, and configurable.
Collection of functions for working with typed arrays: creating typed arrays from numbers, padding arrays, computing byte strides, packing/unpacking interleaved data. These are essential for low-level binary buffer manipulation and are reusable in any application that needs to handle binary data with typed arrays (e.g., game engines, file format converters).