The GltfModel class represents the complete glTF 2.0 structure. Because glTF relies on index-based referencing (e.g., an accessor pointing to the $n^{th}$ buffer view), the model uses a Holder<T> pattern to manage resource lifecycles and automatic index assignment.
Resource Management with Holder<T>
Each resource type (e.g., BufferData, AccessorData, MeshData) is stored within a Holder<T>. When you add a new resource via a hold() method:
- The resource is assigned a unique index (
ix) based on its position in the collection. - It is stored as a
std::shared_ptr<T> within the holder. - The holder ensures that all resources live as long as the
GltfModel instance exists.
While the model uses shared_ptr internally for ownership, it is intended that consumers pass around raw references (T&) or pointers (T*) during a single conversion run, as the GltfModel is designed to outlive the conversion activity.