CompressedTextureWriter 🚧
The experimental
CompressedTextureWriterclass can encode a binary encoded image into a compressed texture.
caution
This writer works by spawning the texture-compressor command line utility via npx. That utility is an optional peer and is not installed by @loaders.gl/textures. Applications that use this writer must install it themselves:
npm install --save-dev texture-compressor
The utility is invoked with npx --no, so it is never downloaded on demand. If it cannot be resolved locally, encodeURLtoURL() rejects.
| Loader | Characteristic |
|---|---|
| File Extension | |
| File Type | Binary |
| Data Format | |
| File Format | |
| Encoder Type | Asynchronous |
| Worker Thread | No (but may run on separate native thread in browsers) |
| Streaming | No |
Usage​
import '@loaders.gl/polyfill'; // only if using under Node
import {encodeURLtoURL} from '@loaders.gl/core';
import {CompressedTextureWriter} from '@loaders.gl/textures';
export const IMAGE_URL = 'image.png';
const outputFilename = await encodeURLtoURL(IMAGE_URL, '/tmp/test.ktx', CompressedTextureWriter);
// app can now read the file from outputFilename
Data Format​
TBA
Options​
| Option | Type | Default | Description |
|---|
Remarks​
- Requires the
texture-compressorCLI to be installed by the application, see the note above. - Output is currently hardcoded to the S3TC/DXT1 compression format, and the CLI only writes
.ktxcontainers, sooutputUrlmust end in.ktxdespite the writer being registered under theddsid. - For more information, see
texture-compressor.