vpenades / SharpGLTF

glTF reader and writer for .NET Standard
MIT License
454 stars 72 forks source link

Validation Method only available for loading from file #154

Open famda opened 1 year ago

famda commented 1 year ago

Hey,

The Validate method from ModelRoot available for models from a filePath. Is it possible to add the same method for Stream or byte array (ParseGLB and ReadGLB)?

Thanks in advance.

vpenades commented 1 year ago

these methods already have a ReadSettings argument, you can call:

ParseGLB( bytes, ValidationMode.Strict);
ReadGLB( stream, ValidationMode.Strict);
famda commented 1 year ago

That's true but you can't validate before you read it. When you read it from file you can check before and select the option (strick, tryfix, skip) based on the validation errors.

On those methods it's a try catch experience and I can't know what is happening with the GLB (there's no way to see why it's failing).

I have a bunch of glb's that have assessors out of bounds. To fix it, I just need to update bounds of the arrays. This is something that I can't solve without knowing the reason.

vpenades commented 1 year ago

you can create an instance of ReadContext.CreateFromFile and then call Validate(fileName)

famda commented 1 year ago

I actually tried but that method accepts a string. If you have a stream or a byte array, what would you pass to it? There's no filename in that case.

vpenades commented 1 year ago

I'll review the code to see if there's a path through... it'll take some time

famda commented 1 year ago

Thanks. 😉