-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
buffer.byteLength of GLB-stored buffer #1026
Comments
I have been assuming yes. The Babylon.js glTF loader currently throws a warning if they don't match. |
Currently, COLLADA2GLTF adds padding in GLB container, but doesn't update |
@pjcozzi |
Ah 😜 |
Making Buffer's byteLength always match the actual buffer byte size would make the field redundant. So my opinion is that byteLength field should represent the "meaningful" part of the buffer, or to be removed altogether. The only practical use of the field is to do an early check to know if we have all the bytes. And if that's the case, a less-equal test would be good enough, there's no need for an exact match. |
@vpenadea Surely the main use of the field is to allow preallocation of memory when loading? Buffers can be of non-trivial size... |
@zellski True, I was thinking more in desktop environments where it's easy to open a file and check its size, I didn't considered streaming the file from web, where you usually don't know the file size until the end. So then it's a matter of telling which value is more important for the scene to be processed correctly, the byteLength field, or the file size itself. If the file size is larger than byteLength, we can simply stop filling the buffer when we've read byteLength bytes. |
Discussed on a 3D Formats call. If the asset uses more data than the .glb contains it is an error. If it uses less - up to 3 bytes to allow for padding - or equal, it is OK. This allows adding padding to .glb when converting .gltf to .glb without changing the original JSON buffer part. Requires an update to the .glb part of the spec. @lexaknyazev volunteered to update the spec. |
Doesn't the spec already specify that the JSON chunk is padded with space (0x20) characters? Is that no longer desirable? |
@stevenvergenz |
Must the length of GLB-stored
BIN
chunk be equal tobuffer.byteLength
? Spec doesn't define their relations. Since GLB chunk must be padded to 4-byte boundary, converting ASCII glTF to GLB may require adjustingbuffer.byteLength
.Otherwise we can say that
buffer.byteLength
must be less then or equal to the length ofBIN
chunk.CC @pjcozzi @sbtron @bghgary
The text was updated successfully, but these errors were encountered: