@loaders.gl/textures
Version:
Framework-independent loaders for compressed and super compressed (basis) textures
34 lines (31 loc) • 909 B
text/typescript
// loaders.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
import {ChildProcessProxy} from '@loaders.gl/worker-utils';
import {CompressedTextureWriterOptions} from '../../compressed-texture-writer';
/*
* @see https://github.com/TimvanScherpenzeel/texture-compressor
*/
export async function encodeImageURLToCompressedTextureURL(
inputUrl: string,
outputUrl: string,
options?: CompressedTextureWriterOptions
): Promise<string> {
// prettier-ignore
const args = [
// Note: our actual executable is `npx`, so `texture-compressor` is an argument
'texture-compressor',
'--type', 's3tc',
'--compression', 'DXT1',
'--quality', 'normal',
'--input', inputUrl,
'--output', outputUrl
];
const childProcess = new ChildProcessProxy();
await childProcess.start({
command: 'npx',
arguments: args,
spawn: options
});
return outputUrl;
}