Comments (8)
Thank you for using tinygltf and the proposal!
Validating the loaded model is important, but at the moment I have no enough dev resource for data validation so the contribution is welcome!
Sorry for late response. For some reason, there is no e-mail notification so I've missed this issue for a week.
Option 3 or 4 looks good for me. The code would be something like this:
#include "tinygltf.h"
#include "tinygltf-validator.h" // tinygltf_validator::Validator
tinygltf::Model model = ...;
tinygltf_validator::Validator validator;
std::string err;
bool ret = validator.Validate(model, &err);
if (!err.empty()) {
std::cerr << err << std::endl;
}
...
from tinygltf.
Good point @brycehutchings, and the issues you mention are already well detected by the official glTF validator: https://github.com/KhronosGroup/glTF-Validator, you can have an overview of the detected issues here.
To be honest, I'm wondering if validation should be part of tinygltf, I guess this responsibility should be given to a dedicated tool. We are using it for glTF import and export on Sketchfab but our validation is different on each process. Tinygltf performs a validation for glTF import/processing, and for export we validate output files with the official glTF validator: https://github.com/KhronosGroup/glTF-Validator.
The glTF-Validator is updated very quickly after any change in the specification, and it's a very useful tool to assert that the glTF you read or write is sane.
So I would say 4) with the official and up-to-date glTF-Validator.
@syoyo what's your opinion on this ?
from tinygltf.
Thank you for the comment, @AurL !
So I would say 4) with the official and up-to-date glTF-Validator.
It looks gTF-Validator
is now very mature, so I would also like to go with 4) + use gltf-Validator for a while.
I have a plan to rewrite tinygltf parser/writer using a code generator from JSON spec #10 which can also be used for creating validator program especially suited for TinyGLTF
as a derivative(approach 3), but I cannot promise when I could finish implementing #10 ...
from tinygltf.
Absolutely glTF-Validator should be used to validate glTF files when possible. My thinking was more about consuming glTF files from unknown sources, potentially malicious sources. For example, I made a glTF file with circular node references. When I upload and view it on BablyonJS's Sandbox, I get the error "Unable to load from 'Cube.gltf': Maximum call stack size exceeded". To me, it would be nice to have glTF parsers catch issues like this, which would remove the burden of doing checks at a later stage. glTF-Validator can't be used in many cases at runtime, especially for native applications. To me this falls into a set of functionality that TinyGLTF doesn't expose but I assume many people need, like parsing accessors into more structured data (e.g. primitive POSITION attribute into vector of Vec3). These are both kinds of optional things which could be built on top of TinyGLTF and consumers could find useful.
from tinygltf.
I made a glTF file with circular node references
For detecting circular node references, we could implement DFA(Data Flow Analysis) e.g. using topological sort.
Maximum call stack size exceeded
I guess this is an error in JavaScript runtime layer, not in JavaScript program itself. In C++, it is difficult to detect out-of-memory, stack-overflow, etc in pure C++ programming level without specialized compiler options and runtime library(e.g. AddressSanitizer, MemorySanitizer, VC's CRT stack protection mechanism).
Another way is to introduce secure tiny VM layer e.g. using duktape https://github.com/svaarala/duktape . This kind of approach would be better when we load unknown, malcious glTF model in Mobile environment(Android, iOS) but may be a bit overkill for TinyGLTF
library...
from tinygltf.
https://github.com/syoyo/tinygltf/tree/validator/examples/validator
I have created validator
example using https://github.com/pboettch/json-schema-validator in validator
branch.
Currently it only tests the syntax of glTF, but it would be a good starting point of the validation of glTF files in a C++ program.
from tinygltf.
And now validator
has been merged into devel
from tinygltf.
devel
is now master
.
from tinygltf.
Related Issues (20)
- No default initialization of `light` and `emitter` in `tinygltf::Node` HOT 1
- Inclusion of third-party libraries causes conflicts HOT 2
- MinGW don't have an implementation of the function "_wfopen_s" HOT 4
- enable draco
- compile failed after enable draco
- Deprecate Travis build
- LoadBinaryFromMemory fails for empty but not omitted binary chunk HOT 2
- Version numbers in header file is outdate HOT 1
- hows to get model coordinates
- How can I retreive referenced file names in GLB/GLTF file?
- Convert .B3DM to .glb, .glb file has lost its geospatial coordinates
- Unused string in LoadBinaryFromFile in tiny_gltf.h HOT 2
- Empty nodes are wrongly serialized as null HOT 5
- Light reference in the node HOT 3
- Default constructed Material has wrong emissiveFactor
- how to enable EXT_Meshopt_compression
- Empty scenes are wrongly serialized as null HOT 2
- Enabling the file "tiny_gltf.h" to another header file HOT 1
- stbi_load and stbi_free_image are disabled
- model.nodes[idx].name returned wrong string when name is unicode string? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tinygltf.