Improvements to texture export functionality to handle compressed textures #5386
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.
Improvements to texture conversion code to canvas, which is internally used by Usdz and Gltf exporters. If the texture is not natively supported by the browser, it gets rendered by a simple shader to render target (which decompresses it from Basis or other compressed formats). We extract pixels from this render target and construct a canvas from it.
Note that this function has internally been made async and returns a promise, to in the future allow async getPixels call.
Additionally, the exporters themselves were update to use this modified function as async, so their internal flow has been changed a bit to handle this.
Fix: originally, those public export functions were incorrectly declaring return type as
ArrayBuffer
. This has now been fixed to declare it asPromise<ArrayBuffer>
as that is what they are returning.