KhronosGroup / glTF-CSharp-Loader

C# Reference Loader for glTF
Other
219 stars 58 forks source link

Buffer created from GLB file is null. #48

Open Nickpofig opened 1 year ago

Nickpofig commented 1 year ago

The GLB file support is incomplete. The loader is able to parse the JSON structure, however, the resulting buffer is null. So you have a file structure, but you don't have data.

Please fix it.

Blogbotana commented 1 year ago

They don't fix it. I wrote special class for that

bghgary commented 1 year ago

If you can provide a repro or what you are doing, that would be helpful.

Blogbotana commented 1 year ago

image I separated bin data from model data and connect it back

Blogbotana commented 1 year ago

image You can try to search this code how to work with binary data of the model

bikemurt commented 1 year ago

If you can provide a repro or what you are doing, that would be helpful.

From the SampleModelsTest.cs file it looks like there should be a LoadBinaryBuffer method. Is it intended that this needs to be called for each buffer in a glb file? Or should Interface.LoadModel automatically parse each buffer? In any case, the LaodBinaryBuffer method is not available when using the NuGet package.

bghgary commented 1 year ago

Which version of the NuGet package are you using?

bikemurt commented 1 year ago

Version 1.0.0. Update: Tested on the 1.1.4 pre-release, and glb loading is still not working as expected. Is it supposed to populate the Buffer.Uri field? Or is functionality missing to convert the binary data into a Base64 string? I am able to see the LoadModel method but that's not related to this issue.

bghgary commented 1 year ago

glb loading is still not working as expected. Is it supposed to populate the Buffer.Uri field?

I still don't know what the repro is. You sent some code of your helper method, but what are you doing such that you expect Buffer.Uri to be populated?

Or is functionality missing to convert the binary data into a Base64 string?

Why do you want the binary data converted to a Base64 string? That would be extremely slow. If the original gltf/glb had a base64 string for the binary buffer, then Buffer.Uri will have a base64 string.

I think there might be a misunderstanding of what the API is supposed to do. LoadModel will load the JSON in the gltf/glb asset and return it as is. In a typical self-contained glb, the Buffer.Uri is blank because the spec requires it to be when pointing to the BIN chunk in the glb. There is a helper function LoadBinaryBuffer that helps with loading this BIN chunk once LoadModel is called.

bikemurt commented 1 year ago

I definitely misunderstood the standard. Thank you for clarifying this, will test it out later