Documentation
¶
Overview ¶
gltf_types.go contains glTF 2.0 spec data structures for JSON deserialization. These types map directly to the glTF 2.0 JSON schema and are internal to the loader package. Reference: https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Loader ¶
type Loader interface {
common.Delegate[Loader]
// Load imports a model file and caches the result.
// If the model is already cached (by file path), the cached version is returned.
// The backend is selected based on the file extension (.gltf/.glb → glTF backend).
// The returned model contains CPU-side data only; GPU resources (mesh buffers,
// material textures/samplers/bind groups) are initialized by the Scene when
// the model is added via Add().
//
// Parameters:
// - path: the file path to the model file
//
// Returns:
// - model.Model: the loaded and cached model
// - error: error if loading fails
Load(path string) (model.Model, error)
// Get retrieves a cached model by name. Returns nil if not found.
//
// Parameters:
// - name: the cache key to look up
//
// Returns:
// - model.Model: the cached model or nil
Get(name string) model.Model
// Models returns the full model cache.
//
// Returns:
// - map[string]model.Model: all cached models keyed by name
Models() map[string]model.Model
}
Loader defines the public-facing interface for loading and caching 3D models. It abstracts the file format (glTF, GLB, etc.) behind a generic backend and manages a cache of previously loaded models.
func NewLoader ¶
func NewLoader(backendType LoaderBackendType, options ...LoaderBuilderOption) Loader
NewLoader creates a new Loader instance with the specified backend type and options applied.
Parameters:
- backendType: the type of loader backend to use (e.g., BackendTypeGLTF)
- options: a variadic list of LoaderBuilderOption functions to configure the Loader
Returns:
- Loader: a new instance of Loader configured with the provided backend and options
type LoaderBackendType ¶
type LoaderBackendType int
LoaderBackendType identifies the model file format backend to use.
const ( // BackendTypeGLTF selects the glTF/GLB loader backend. BackendTypeGLTF LoaderBackendType = iota )
type LoaderBuilderOption ¶
type LoaderBuilderOption func(*loader)
LoaderBuilderOption is a functional option for configuring a Loader via NewLoader.
func WithModel ¶
func WithModel(key string, model model.Model) LoaderBuilderOption
WithModel is an option builder that pre-populates the model cache with a model.
Parameters:
- key: the cache key for the model
- model: the model to cache
Returns:
- LoaderBuilderOption: a function that applies the model option to a loader