Repository navigation
Conversation
three's USDZExporter can only write compressed textures (e.g. KTX2 via KHR_texture_basisu) after texture utils have been set; otherwise it throws "setTextureUtils() must be called to process compressed textures" and activating AR on iOS silently does nothing. Provide a decompress implementation based on WebGLTextureUtils. A single dedicated WebGL context is shared for all textures and disposed after the export, and textures are decompressed at ar-usdz-max-texture-size to limit peak memory on mobile devices.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
When a model uses KTX2 textures (
KHR_texture_basisu) and noios-srcis set, generating the USDZ for Quick Look fails with:prepareUSDZ()rejects, and on iOS tapping the AR button silently does nothing.Repro (4.4.0): https://jsfiddle.net/ps5mcLf9/. It loads
shared-assets/models/BarramundiFish.mixed.glband callsprepareUSDZ(). It also works on desktop.Astronaut.glbis included as a working comparison.Fix
Give
USDZExporteradecompressimplementation built on three'sWebGLTextureUtils:WebGLRendereris created only when a compressed texture is found. All textures in the export use it, and it is disposed in the existingfinallyblock. Otherwisedecompresswould create and destroy a context for every texture.ar-usdz-max-texture-sizeinstead of full resolution. This limits peak memory on mobile devices.Tests
Added a test to
ar-spec.ts. It exportsBarramundiFish.mixed.glb(2048×2048 KTX2 textures) withar-usdz-max-texture-size="256". It then checks that the USDZ contains PNG textures that are 256×256 and contain real image data.