Decode 3D texture coordinates in upgrade #148
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This replaces the draft at #146 with a ... somewhat cleaned-up version that focusses only at the decoding part:
SHORT
The exact encoding of the texture coordinates is not yet clear. It just seems to be "one (arbitrary) way" of not storing the
VEC2/FLOAT
(2 * 4 = 8 bytes), but instead, storingVEC3/SHORT
(3 * 2 = 6 bytes). At the time of writing this, one glTF file that has this structure is stored publicly at https://assets.agi.com/models/f-16_falcon.gltf (unclear licensing, therefore, not replicated here). In this asset, the decoding is done like this:This PR implements the decoding of VEC3/SHORT (or VEC3/BYTE) texture coordinates into VEC2/FLOAT texture coordinates. From a quick test with a B3DM file that contained the glTF data given above, the result can be rendered in CesiumJS.
Note: There seems to be no agreed-upon name for this compression technique or its details. Therefore, the implementation here can only be a best-effort guess. But it has little or no negative impact: When there are 3D texture coordinates, then the asset is invalid. We'll try to decode them into a valid form. When it works, everything is fine. Otherwise, the result is still invalid 🤷♂️ .
(I'd like to add a spec/unit test case. But I'd first have to create such old/invalid data, which would involve some manual work. Not sure whether this is worth the effort...)