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

Adds 3DTILES_binary_buffers extension #415

Closed
wants to merge 7 commits into from

Conversation

sanjeetsuhag
Copy link
Contributor

This extension enables storage of binary buffers. Specification is available here.

@sanjeetsuhag sanjeetsuhag marked this pull request as draft June 8, 2020 20:31
extensions/3DTILES_binary_buffers/README.md Outdated Show resolved Hide resolved
extensions/3DTILES_binary_buffers/README.md Show resolved Hide resolved
extensions/3DTILES_binary_buffers/README.md Outdated Show resolved Hide resolved
extensions/3DTILES_binary_buffers/README.md Outdated Show resolved Hide resolved
|**byteOffset**|`integer`|The offset relative to the start of the buffer in bytes.|☑️ Yes|
|**byteLength**|`integer`|The length of the bufferView in bytes.| ☑️ Yes|
|**elementCount**|`integer`|The number of elements in the buffer view.| ☑️ Yes|
|**elementByteOffsetsBufferView**|`integer`|The index of the bufferView containing byte offsets for each element. Must be defined for the STRING type.|No|
Copy link
Contributor

Choose a reason for hiding this comment

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

Can elementByteOffsetBufferView be used for properties containing arbitrary sized chunks of binary data? What would be the elementType in that case?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, duplicate comment to #415 (comment). I thought github lost this one.

Copy link
Contributor Author

@sanjeetsuhag sanjeetsuhag Jun 9, 2020

Choose a reason for hiding this comment

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

Yes, a NONUNIFORM element type will be introduced in next draft to meet the requirements for EXT_3dtiles_feature_metadata.

extensions/3DTILES_binary_buffers/README.md Outdated Show resolved Hide resolved
extensions/3DTILES_binary_buffers/README.md Outdated Show resolved Hide resolved
| DOUBLE | 64 |


*Note: The buffer views for the `BIT` component type must be padded with trailing `0`s to meet the nearest byte boundary.*
Copy link
Contributor

Choose a reason for hiding this comment

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

The padding requirements should be defined for the other component types. In general properties must start on a byte offset that's a multiple of the size of the component type.

See https://github.com/CesiumGS/3d-tiles/tree/master/specification/TileFormats/BatchTable#padding

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What's the reason behind this? As long as the byte boundary is respected, the data can be read using byte offsets and byte lengths. What is gained by having the offset be a multiple of the size of the component type?

Copy link
Contributor

Choose a reason for hiding this comment

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

Talked offline about this, but it's for performance reasons. In JavaScript typed arrays need to be aligned to their component type within the underlying array buffer which means unaligned data needs to be cloned into a new typed array. Proper alignment also provides performance benefits in systems level languages.

Early on glTF had the same rationale: KhronosGroup/glTF#167

https://github.com/CesiumGS/cesium/blob/2a9ca28dcbb38eee7013505987516446a8eacb4f/Source/Scene/Batched3DModel3DTileContent.js#L370-L382 - this is where CesiumJS clones the typed array if it isn't aligned. 3D Tiles didn't always have byte alignment requirements which lead to slow paths like this.

@pjcozzi
Copy link
Contributor

pjcozzi commented Jun 9, 2020

@sanjeetsuhag @lilleyse excited to see this. Just a reminder to please bump to me when ready for review. 😄

@lilleyse
Copy link
Contributor

This extension may need a way to indicate whether a string property is stringified JSON

@lilleyse
Copy link
Contributor

A lot of the data alignment rules in this spec are now OBE since we're moving to Apache Arrow. I'll open a PR with the new, simplified version of the spec.

@lilleyse lilleyse closed this Sep 21, 2020
@lilleyse lilleyse deleted the 3DTILES_binary_buffers branch September 21, 2020 23:53
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