2.2 KiB
glTF mapping to luma.gl
luma.gl v7 API contains classes that closely follow the objects defined in the glTF2 specification, making the instantiation of a glTF 2.0 file in luma.gl rather trivial. However it can still be good to be able to reference a map of how various concepts are loaded.
GLTF structure
sceneon the highest level, a glTF file is a list of scenes, each scene containing a list ofnodes.nodecan hold a list of child nodes, and/or amesh, and/or acamera. It also holds a transformation that should be applied to all of these.meshis a list ofprimitives(and optionally, also some "morph weights")primitiveis just a geometry: a draw mode, a bunch of accessors, optional indices (and optionally, also some "morph targets")
Top-level Mapping
| glTF concept | luma.gl class | |
| --- | --- | |
| accessors | Accessor | |
| animations | N/A | |
| asset | N/A | metadata, handled by loaders.gl |
| buffers | ArrayBuffer | |
| bufferView | Buffer | |
| cameras | N/A | |
| images | HTMLImage? | |
| materials | Material (7.0) | |
| meshes | Group/Model | |
| nodes | Group, Model | A single node can generate one or more of these objects |
| primitives | Model (7.0) | |
| programs | Program | |
| samplers | Sampler (WebGL2) or Texture2D (WebGL1) | |
| scene | N/A | Selects one scene from scenes |
| scenes | Group |
| shaders | Shader |
| skins | Not yet supported | |
| techniques | TBD? | |
| textures | Texture2D| |
Unsupported glTF Features
- skins (needs new
Skinclass) - morph targets (
Primitive.targets,Mesh.weights) - Animations (needs new
Animationclass)
Remarks
- Overloaded Nodes - The biggest deviation from a one-to-one mapping comes from the mapping of the glTF
nodeobject which can contain several different things at the same time. For some background on why glTF nodes were designed the way they are, see for instance this discussion.