Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GLTFLoader: Respect file contents length defined in header #21122

Merged
merged 1 commit into from
Jan 21, 2021

Conversation

gkjohnson
Copy link
Collaborator

Related issue: --

Description

Right now GLTFLoader assumes the entire buffer makes up the contents of the file when parsing chunks in processing a binary GLTF but that can cause problems when the length defined in the GLTF header is different that the remaining size of the buffer.

I found this when helping a user in NASA-AMMOS/3DTilesRendererJS#153 load a 3d tile set and found that the B3DM files (spec), which seem to define the GLTF buffer as being 4 bytes longer than the inner GLTF header does, were failing to load. In the referenced issue the B3DM files are further packed into a CMPT file (spec), as well.

The files load correctly without error in Cesium and it parses them the same way resulting in the 4 extra bytes in the buffer. However when parsing the file contents Cesium uses the header length to iterate over the buffer chunks rather than the remaining array length, which seems like a more correct interpretation of the spec:

https://github.com/CesiumGS/cesium/blob/master/Source/ThirdParty/GltfPipeline/parseGlb.js#L83-L87

cc @donmccurdy

Copy link
Collaborator

@donmccurdy donmccurdy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks!

@mrdoob
Copy link
Owner

mrdoob commented Jan 21, 2021

Thanks!

@gkjohnson gkjohnson deleted the gltf-chunks-length-fix branch January 21, 2021 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants