compressTexture

  • compressTexture(texture: Texture, _options: CompressTextureOptions): Promise<void>
  • Optimizes a single Texture, optionally resizing or converting to JPEG, PNG, WebP, or AVIF formats.

    Requires sharp, and is available only in Node.js environments.

    Example:

    import { compressTexture } from '@gltf-transform/functions';
    import sharp from 'sharp';
    
    const texture = document.getRoot().listTextures()
        .find((texture) => texture.getName() === 'MyTexture');
    
    await compressTexture(texture, {
        encoder: sharp,
        targetFormat: 'webp',
        resize: [1024, 1024]
    });
    
Function symbol, where the argument and output are a box labeled 'glTF'.

Made by Don McCurdy Documented with greendoc © 2023 MIT License