This is a simple module for loading .gltf and .glb files into a Scene which is friendly for rendering applications.
Currently the following features are not supported:
- Sparse accessors
- Extensions
- Cameras
- Animations and anything related to them (weights, morph targets, etc)
Simply clone/copy/add as a submodule this repo into your project_name/modules/ directory.
There are only two procederus.
create_converter :: () -> *GLTF_Converter;
destroy_converter :: (converter: *GLTF_Converter);
load_scene :: (converter: *GLTF_Converter, gltf_path: string) -> ok: bool, error: string, Scene;
release_scene :: (scene: *Scene);Scene outlives the converter. The converter is needed only to call load_scene and can be immetiately released afterwards.
Check the examples directory to see the module in action.
This module has a single dependency as a git submodule - jaison
So to clone this repo, you need to run git clone --recurse-submodules
Tools for more pleasant development can be installed by running the install_tools.jai routine.
Currently it adds a pre-commit hook which runs tests and checks for @``no_commit entries in the diff.
module.jaiSimply imports other source files.src/Contains all the source files with the GLTF parsing logic. Jai files in other places are used only for develompent.src/gltf_reader.jaiThis file parser JSON (.gltf) into Jai types without transforming any of the data.
As Jai has zero-initialization, optional GLTF fields have sentinels. All the fields that have sentinels are prefixed with_.src/gltf_converter.jaiHere we convert GTF into aScene.src/scene.jaiHere we have the definition ofScene.test.jaiRuns simple tests.assets/Contains.gltffiles for testing.modules/Contains third party dependencies.examples/Usage examples. Run withjai ./build_example.jai - <example_directory_name> +Autorun
- Use unions where possible (especiall in GLTF types declarations) when unions are fully supported
- Add mesh merging
- Support data uris
- Support TEXCOORD_N (>0) in attributes
- Support sparse accessors (
sparsefield inGLTF_Accessor) - Support animations (
animations) - Support
weightsinGLTF_Mesh - Support
targetsinGLTF_Mesh.Primitive - Support
skininGLTF_Node - Support
weightsinGLTF_Node - Support
skins - Support cameras
cameras - Support
camerainGLTF_Node