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]
});
Made by Don McCurdy • Documented with greendoc • © 2023 MIT License
compressTexture