Pure Nim glTF™ Reader
ngltf is a pure Nim reader implementation for the glTF file specification.
glTF™ is an efficient, extensible and publishing format for transmission and loading of 3D scenes and models for engines and applications.
This library is a raw reader.
Consider using @heysokam/nimp if you prefer a more ergonomic and simple to use API.
How to use
import ngltf
let gltf = ngltf.load( "path/to/yourFile.gltf" ) # Smart load from the given path
... do something with the data ...# Other smart load options
let glb = ngltf.load("path/to/yourFile.glb") # Smart load a binary gltf
let mem1 = ngltf.load(myStringBytebuffer) # Smart load a binary from memory
# Explicit load
let file = ngltf.loadFile("path/to/yourFile.gltf") # Explicit load a .gltf from a file
let mem2 = ngltf.loadMem(myStringBytebuffer) # Explicit load a glb binary from memorySupports:
.gltf+.bin.gltfembedded (base64).glb
An example of how the data contained in the gltf object could be accessed can be seen @load/data.nim.
Said file is not maintained, and is kept only as a reference.
A complete implementation needs to depend on an image loader and a math library.
Said dependencies are purposedly kept away from this raw reader,
and are implemented in the @heysokam/nimp abstraction instead.
Dependencies:
treeform/jsonyfortoJsonfor simple json nodes without an explicit type (std/json doesn't support it)treeform/flattyfor reading binary information from.glband.bindata.
Spec Concepts Renames and Extensions
- Model : spec.Mesh
- Mesh : spec.MeshPrimitive
- MeshType : spec.MeshPrimitiveMode
- Buffer : Contains a bytebuffer with its corresponding
.binor.glbdata buffers already loaded into memory. - SceneID : spec.scene (singular). Renamed to clarify what it really is (root scene id).
License
| MIT | Copyright (C) Ivan Mar (sOkam!)
