-
-
Notifications
You must be signed in to change notification settings - Fork 151
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
Exposing functions - e.g. running textureCompress
for individual textures
#853
Comments
textureCompress
for individual texturestextureCompress
for individual textures
Related: I think we could do a It's worth noting that texture compression can be done in less code than I'm using, and import sharp from 'sharp';
import { BufferUtils, HTTPUtils } from '@gltf-transform/core';
for (const texture of document.getRoot().listTextures()) {
const buffer = await sharp(texture.getImage()).toFormat('webp', {lossless: true}).toBuffer();
texture
.setMimeType('image/webp')
.setImage(BufferUtils.toView(buffer))
.setURI(HTTPUtils.basename(texture.getURI()) + '.webp');
}
document.createExtension(EXTTextureWebP).setRequired(true); |
Yes happy to PR this, just wanted to run some tests before to make sure I didnt break anything and it's working as intended. Thanks for the code snippet. That's goo to know and maybe something I'll be doing then instead in our code and just handle the settings we ship in our extension (that being said having a fallback to the default gltf-transform compression function is still handy in cases where no explicit compression settings were assigned to a texture but we still want to apply defaults) |
Fixed by #859. |
Is your feature request related to a problem? Please describe.
I'd like to use existing compression functions for individual textures/primitives/...
Describe the solution you'd like
Similarly to #767 It would be nice to be able to run the
textureCompress
function on individual textures (providing the texture compression options per texture?)Describe alternatives you've considered
Copying and modifying the code I need (e.g. the inner textures.map loop of
textureCompress
to apply webp compression to individual textures)Additional context
glTF-Transform/packages/functions/src/texture-compress.ts
Line 107 in 32dc66e
Something like this:
needle-tools@45fedf0
https://github.com/needle-tools/glTF-Transform/blob/45fedf070b0983e9de384893497780a2fbf2bb27/packages/functions/src/texture-compress.ts#L164
The text was updated successfully, but these errors were encountered: