gltf2loader 0.1.0
A simple glTF2 loader in D.
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
Getting started
Add gltf2loader
to your project's dependencies or copy gltf2.d into your source folder and then import the module:
import glTF2Loader;
Usage
Loading an asset
To load and parse an asset:
glTF2Asset asset = glTF2Asset (fileName);
or
glTF2Asset asset;
asset.load (fileName);
The glTF2Asset
struct is reset every time a new asset is loaded.
Reading JSON data
All JSON data is stored in arrays of structs within glTF2Asset
. They map one-to-one to corresponding JSON objects and match their structures, with a few exceptions:
extensions
andextra
fields are ignored for the time being, since no extensions are supported as of right now;- there are no separate
perspective
andorthographic
objects inglTF2Camera
struct; instead, it containszfar
,znear
,aspectRatio
,yfov
,xmag
andymag
fields, camera type is stored in an enum and unused fields are ignored; - most importantly,
glTF2Buffer
andglTF2Image
have adata
field of typevoid[]
where binary data is stored.
Reading binary data
asset.accessData (accessorIndex)
retrieves data through the specified accessor. It returns void[]
; you're supposed to know what to do with the data.
asset.accessSparseData (accessorIndex)
retrieves data through the specified sparse accessor. It returns void[][uint]
; again, you're supposed to know what to do with the data.
asset.accessImage (imageIndex)
retrieves raw data for the specified image. NB: image data stored in buffers is not duplicated in glTF2Image
structs; for this reason, reading image data directly from glTF2Image.data
is not recommended.
Capabilities and spec conformance
All standard glTF2 objects are currently supported, as well as embedded buffers and .glb files. As mentioned earlier, no extensions are currently supported; if the asset specifies any required extensions, loader will output an error message to stdout and return without loading the asset (though it will still reset the glTF2Asset
struct).
All assets from the official sample models repository should load and parse correctly (except the ones with Draco-compressed buffers).
- Registered by azure
- 0.1.0 released 5 years ago
- azure-v/glTF2Loader
- MIT
- Copyright © 2019, azure
- Authors:
- Dependencies:
- none
- Versions:
-
0.1.1 2020-Jan-03 0.1.0 2019-Jan-21 ~master 2020-Jan-03 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
0 downloads this month
-
31 downloads total
-
- Score:
- 0.1
- Short URL:
- gltf2loader.dub.pm