{"id":13532039,"url":"https://github.com/syoyo/tinygltf","last_synced_at":"2025-05-14T01:04:13.168Z","repository":{"id":37852985,"uuid":"92255456","full_name":"syoyo/tinygltf","owner":"syoyo","description":"Header only C++11 tiny glTF 2.0 library","archived":false,"fork":false,"pushed_at":"2025-01-22T13:45:53.000Z","size":21185,"stargazers_count":2157,"open_issues_count":39,"forks_count":448,"subscribers_count":47,"default_branch":"release","last_synced_at":"2025-04-03T07:57:55.740Z","etag":null,"topics":["cpp","gltf"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/syoyo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"syoyo"}},"created_at":"2017-05-24T05:59:28.000Z","updated_at":"2025-04-01T14:04:42.000Z","dependencies_parsed_at":"2023-02-09T23:45:33.205Z","dependency_job_id":"48fc051e-3c07-4f94-b4ab-5934b5eff59e","html_url":"https://github.com/syoyo/tinygltf","commit_stats":{"total_commits":682,"total_committers":107,"mean_commits":6.373831775700935,"dds":0.5439882697947214,"last_synced_commit":"350c2968025882bdf823e7892d02328548b46435"},"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syoyo%2Ftinygltf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syoyo%2Ftinygltf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syoyo%2Ftinygltf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syoyo%2Ftinygltf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/syoyo","download_url":"https://codeload.github.com/syoyo/tinygltf/tar.gz/refs/heads/release","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248223828,"owners_count":21068069,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","gltf"],"created_at":"2024-08-01T07:01:07.739Z","updated_at":"2025-04-10T13:06:18.989Z","avatar_url":"https://github.com/syoyo.png","language":"C++","readme":"# Header only C++ tiny glTF library(loader/saver).\n\n`TinyGLTF` is a header only C++11 glTF 2.0 https://github.com/KhronosGroup/glTF library.\n\n`TinyGLTF` uses Niels Lohmann's json library (https://github.com/nlohmann/json), so now it requires C++11 compiler.\n(Also, you can use RadpidJSON as an JSON backend)\nIf you are looking for old, C++03 version, please use `devel-picojson` branch (but not maintained anymore).\n\n## Status\n\nCurrently TinyGLTF is stable and maintenance mode. No drastic changes and feature additions planned.\n - v2.9.0 Various fixes and improvements. Filesystem callback API change.\n - v2.8.0 Add URICallbacks for custom URI handling in Buffer and Image. PR#397\n - v2.7.0 Change WriteImageDataFunction user callback function signature. PR#393\n - v2.6.0 Support serializing sparse accessor(Thanks to @fynv).\n - v2.5.0 Add SetPreserveImageChannels() option to load image data as is.\n - v2.4.0 Experimental RapidJSON support. Experimental C++14 support(C++14 may give better performance)\n - v2.3.0 Modified Material representation according to glTF 2.0 schema(and introduced TextureInfo class)\n - v2.2.0 release(Support loading 16bit PNG. Sparse accessor support)\n - v2.1.0 release(Draco decoding support)\n - v2.0.0 release(22 Aug, 2018)!\n\n### Branches\n\n* `sajson` : Use sajson to parse JSON. Parsing only but faster compile time(2x reduction compared to json.hpp and RapidJson), but not well maintained.\n\n## Builds\n\n[![Build status](https://ci.appveyor.com/api/projects/status/warngenu9wjjhlm8?svg=true)](https://ci.appveyor.com/project/syoyo/tinygltf)\n\n![C/C++ CI](https://github.com/syoyo/tinygltf/workflows/C/C++%20CI/badge.svg)\n\n## Features\n\nProbably mostly feature-complete. Last missing feature is Draco encoding: https://github.com/syoyo/tinygltf/issues/207\n\n* Written in portable C++. C++-11 with STL dependency only.\n  * [x] macOS + clang(LLVM)\n  * [x] iOS + clang\n  * [x] Linux + gcc/clang\n  * [x] Windows + MinGW\n  * [x] Windows + Visual Studio 2015 Update 3 or later.\n    * Visual Studio 2013 is not supported since they have limited C++11 support and failed to compile `json.hpp`.\n  * [x] Android NDK\n  * [x] Android + CrystaX(NDK drop-in replacement) GCC\n  * [x] Web using Emscripten(LLVM)\n* Moderate parsing time and memory consumption.\n* glTF specification v2.0.0\n  * [x] ASCII glTF\n    * [x] Load\n    * [x] Save\n  * [x] Binary glTF(GLB)\n    * [x] Load\n    * [x] Save(.bin embedded .glb)\n* Buffers\n  * [x] Parse BASE64 encoded embedded buffer data(DataURI).\n  * [x] Load `.bin` file.\n* Image(Using stb_image)\n  * [x] Parse BASE64 encoded embedded image data(DataURI).\n  * [x] Load external image file.\n  * [x] Load PNG(8bit and 16bit)\n  * [x] Load JPEG(8bit only)\n  * [x] Load BMP\n  * [x] Load GIF\n  * [x] Custom Image decoder callback(e.g. for decoding OpenEXR image)\n* Morph traget\n  * [x] Sparse accessor\n* Load glTF from memory\n* Custom callback handler\n  * [x] Image load\n  * [x] Image save\n* Extensions\n  * [x] Draco mesh decoding\n  * [ ] Draco mesh encoding\n\n## Note on extension property\n\nIn extension(`ExtensionMap`), JSON number value is parsed as int or float(number) and stored as `tinygltf::Value` object. If you want a floating point value from `tinygltf::Value`, use `GetNumberAsDouble()` method.\n\n`IsNumber()` returns true if the underlying value is an int value or a floating point value.\n\n## Examples\n\n* [glview](examples/glview) : Simple glTF geometry viewer.\n* [validator](examples/validator) : Simple glTF validator with JSON schema.\n* [basic](examples/basic) : Basic glTF viewer with texturing support.\n* [build-gltf](examples/build-gltf) : Build simple glTF scene from a scratch.\n\n### WASI/WASM build\n\nUsers who want to run TinyGLTF securely and safely(e.g. need to handle malcious glTF file to serve online glTF conver),\nI recommend to build TinyGLTF for WASM target.\nWASI build example is located in [wasm](wasm) .\n\n## Projects using TinyGLTF\n\n* px_render Single header C++ Libraries for Thread Scheduling, Rendering, and so on... https://github.com/pplux/px\n* Physical based rendering with Vulkan using glTF 2.0 models https://github.com/SaschaWillems/Vulkan-glTF-PBR\n* GLTF loader plugin for OGRE 2.1. Support for PBR materials via HLMS/PBS https://github.com/Ybalrid/Ogre_glTF\n* [TinyGltfImporter](http://doc.magnum.graphics/magnum/classMagnum_1_1Trade_1_1TinyGltfImporter.html) plugin for [Magnum](https://github.com/mosra/magnum), a lightweight and modular C++11/C++14 graphics middleware for games and data visualization.\n* [Diligent Engine](https://github.com/DiligentGraphics/DiligentEngine) - A modern cross-platform low-level graphics library and rendering framework\n* Lighthouse 2: a rendering framework for real-time ray tracing / path tracing experiments. https://github.com/jbikker/lighthouse2\n* [QuickLook GLTF](https://github.com/toshiks/glTF-quicklook) - quicklook plugin for macos. Also SceneKit wrapper for tinygltf.\n* [GlslViewer](https://github.com/patriciogonzalezvivo/glslViewer) - live GLSL coding for MacOS and Linux\n* [Vulkan-Samples](https://github.com/KhronosGroup/Vulkan-Samples) - The Vulkan Samples is collection of resources to help you develop optimized Vulkan applications.\n* [TDME2](https://github.com/andreasdr/tdme2) - TDME2 - ThreeDeeMiniEngine2 is a lightweight 3D engine including tools suited for 3D game development using C++11\n* [SanityEngine](https://github.com/DethRaid/SanityEngine) - A C++/D3D12 renderer focused on the personal and professional development of its developer\n* [Open3D](http://www.open3d.org/) - A Modern Library for 3D Data Processing\n* [Supernova Engine](https://github.com/supernovaengine/supernova) - Game engine for 2D and 3D projects with Lua or C++ in data oriented design.\n* [Wicked Engine\u003cimg src=\"https://github.com/turanszkij/WickedEngine/blob/master/Content/logo_small.png\" width=\"28px\" align=\"center\"/\u003e](https://github.com/turanszkij/WickedEngine) - 3D engine with modern graphics\n* Your projects here! (Please send PR)\n\n## TODOs\n\n* [ ] Robust URI decoding/encoding. https://github.com/syoyo/tinygltf/issues/369\n* [ ] Mesh Compression/decompression(Open3DGC, etc)\n  * [x] Load Draco compressed mesh\n  * [ ] Save Draco compressed mesh\n  * [ ] Open3DGC?\n* [x] Support `extensions` and `extras` property\n* [ ] HDR image?\n  * [ ] OpenEXR extension through TinyEXR.\n* [ ] 16bit PNG support in Serialization\n* [ ] Write example and tests for `animation` and `skin`\n\n### Optional\n\n* [ ] Write C++ code generator which emits C++ code from JSON schema for robust parsing?\n\n## Licenses\n\nTinyGLTF is licensed under MIT license.\n\nTinyGLTF uses the following third party libraries.\n\n* json.hpp : Copyright (c) 2013-2017 Niels Lohmann. MIT license.\n* base64 : Copyright (C) 2004-2008 René Nyffenegger\n* stb_image.h : v2.08 - public domain image loader - [Github link](https://github.com/nothings/stb/blob/master/stb_image.h)\n* stb_image_write.h : v1.09 - public domain image writer - [Github link](https://github.com/nothings/stb/blob/master/stb_image_write.h)\n\n\n## Build and example\n\nCopy `stb_image.h`, `stb_image_write.h`, `json.hpp` and `tiny_gltf.h` to your project.\n\n### Loading glTF 2.0 model\n\n```c++\n// Define these only in *one* .cc file.\n#define TINYGLTF_IMPLEMENTATION\n#define STB_IMAGE_IMPLEMENTATION\n#define STB_IMAGE_WRITE_IMPLEMENTATION\n// #define TINYGLTF_NOEXCEPTION // optional. disable exception handling.\n#include \"tiny_gltf.h\"\n\nusing namespace tinygltf;\n\nModel model;\nTinyGLTF loader;\nstd::string err;\nstd::string warn;\n\nbool ret = loader.LoadASCIIFromFile(\u0026model, \u0026err, \u0026warn, argv[1]);\n//bool ret = loader.LoadBinaryFromFile(\u0026model, \u0026err, \u0026warn, argv[1]); // for binary glTF(.glb)\n\nif (!warn.empty()) {\n  printf(\"Warn: %s\\n\", warn.c_str());\n}\n\nif (!err.empty()) {\n  printf(\"Err: %s\\n\", err.c_str());\n}\n\nif (!ret) {\n  printf(\"Failed to parse glTF\\n\");\n  return -1;\n}\n```\n\n#### Loader options\n\n* `TinyGLTF::SetPreserveimageChannels(bool onoff)`. `true` to preserve image channels as stored in image file for loaded image. `false` by default for backward compatibility(image channels are widen to `RGBA` 4 channels). Effective only when using builtin image loader(STB image loader).\n\n## Compile options\n\n* `TINYGLTF_NOEXCEPTION` : Disable C++ exception in JSON parsing. You can use `-fno-exceptions` or by defining the symbol `JSON_NOEXCEPTION` and `TINYGLTF_NOEXCEPTION`  to fully remove C++ exception codes when compiling TinyGLTF.\n* `TINYGLTF_NO_STB_IMAGE` : Do not load images with stb_image. Instead use `TinyGLTF::SetImageLoader(LoadimageDataFunction LoadImageData, void *user_data)` to set a callback for loading images.\n* `TINYGLTF_NO_STB_IMAGE_WRITE` : Do not write images with stb_image_write. Instead use `TinyGLTF::SetImageWriter(WriteimageDataFunction WriteImageData, void *user_data)` to set a callback for writing images.\n* `TINYGLTF_NO_EXTERNAL_IMAGE` : Do not try to load external image file. This option would be helpful if you do not want to load image files during glTF parsing.\n* `TINYGLTF_ANDROID_LOAD_FROM_ASSETS`: Load all files from packaged app assets instead of the regular file system. **Note:** You must pass a valid asset manager from your android app to `tinygltf::asset_manager` beforehand.\n* `TINYGLTF_ENABLE_DRACO`: Enable Draco compression. User must provide include path and link correspnding libraries in your project file.\n* `TINYGLTF_NO_INCLUDE_JSON `: Disable including `json.hpp` from within `tiny_gltf.h` because it has been already included before or you want to include it using custom path before including `tiny_gltf.h`.\n* `TINYGLTF_NO_INCLUDE_RAPIDJSON `: Disable including RapidJson's header files from within `tiny_gltf.h` because it has been already included before or you want to include it using custom path before including `tiny_gltf.h`.\n* `TINYGLTF_NO_INCLUDE_STB_IMAGE `: Disable including `stb_image.h` from within `tiny_gltf.h` because it has been already included before or you want to include it using custom path before including `tiny_gltf.h`.\n* `TINYGLTF_NO_INCLUDE_STB_IMAGE_WRITE `: Disable including `stb_image_write.h` from within `tiny_gltf.h` because it has been already included before or you want to include it using custom path before including `tiny_gltf.h`.\n* `TINYGLTF_USE_RAPIDJSON` : Use RapidJSON as a JSON parser/serializer. RapidJSON files are not included in TinyGLTF repo. Please set an include path to RapidJSON if you enable this feature.\n* `TINYGLTF_USE_CPP14` : Use C++14 feature(requires C++14 compiler). This may give better performance than C++11.\n\n\n## CMake options\n\nYou can add tinygltf using `add_subdirectory` feature.\nIf you add tinygltf to your project using `add_subdirectory`, it would be better to set `TINYGLTF_HEADER_ONLY` on(just add an include path to tinygltf) and `TINYGLTF_INSTALL` off(Which does not install tinygltf files).\n\n```\n// Your project's CMakeLists.txt\n...\n\nset(TINYGLTF_HEADER_ONLY ON CACHE INTERNAL \"\" FORCE)\nset(TINYGLTF_INSTALL OFF CACHE INTERNAL \"\" FORCE)\nadd_subdirectory(/path/to/tinygltf)\n```\n\nNOTE: Using tinygltf as a submodule doesn't automatically add the headers to your include path (as standard for many libraries). To get this functionality, add the following to the CMakeLists.txt file from above:\n\n```\ntarget_include_directories(${PROJECT_NAME} PRIVATE \"/path/to/tinygltf\")\n```\n\n### Saving gltTF 2.0 model\n\n* Buffers.\n  * [x] To file\n  * [x] Embedded\n  * [ ] Draco compressed?\n* [x] Images\n  * [x] To file\n  * [x] Embedded\n* Binary(.glb)\n  * [x] .bin embedded single .glb\n  * [ ] External .bin\n\n## Running tests.\n\n### glTF parsing test\n\n#### Setup\n\nPython required.\nGit clone https://github.com/KhronosGroup/glTF-Sample-Models to your local dir.\n\n#### Run parsing test\n\nAfter building `loader_example`, edit `test_runner.py`, then,\n\n```bash\n$ python test_runner.py\n```\n\n### Unit tests\n\n```bash\n$ cd tests\n$ make\n$ ./tester\n$ ./tester_noexcept\n```\n\n### Fuzzing tests\n\nSee `tests/fuzzer` for details.\n\nAfter running fuzzer on Ryzen9 3950X a week, at least `LoadASCIIFromString` looks safe except for out-of-memory error in Fuzzer.\nWe may be better to introduce bounded memory size checking when parsing glTF data.\n\n## Third party licenses\n\n* json.hpp : Licensed under the MIT License \u003chttp://opensource.org/licenses/MIT\u003e. Copyright (c) 2013-2017 Niels Lohmann \u003chttp://nlohmann.me\u003e.\n* stb_image : Public domain.\n* catch : Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. Distributed under the Boost Software License, Version 1.0.\n* RapidJSON : Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. http://rapidjson.org/\n* dlib(uridecode, uriencode) : Copyright (C) 2003  Davis E. King Boost Software License 1.0. http://dlib.net/dlib/server/server_http.cpp.html\n","funding_links":["https://github.com/sponsors/syoyo"],"categories":["Libraries","C++","Libraries \u0026 Frameworks:","Geometry, Graphics Processing, and Game Development","Graphics"],"sub_categories":["C++","Other"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyoyo%2Ftinygltf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyoyo%2Ftinygltf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyoyo%2Ftinygltf/lists"}