Skip to content

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