@vctrl/hooks
Version:
vctrl/hooks is a React hooks package designed to simplify 3D model loading and management within React applications. It's part of the vectreal-core ecosystem and is primarily used in the vctrl/viewer React component and the official website application.
42 lines (41 loc) • 1.27 kB
TypeScript
/**
* Creates a sharp-constructor-compatible browser encoder.
*
* The returned function matches the sharp API surface that gltf-transform uses:
* `encoder(buffer)` → instance with `.resize()`, `.webp/jpeg/png()`,
* `.toBuffer()`, and `.metadata()`.
*
* Pass the result directly to `TextureCompressOptions.encoder`:
* ```ts
* await optimizer.compressTextures({
* encoder: createBrowserTextureEncoder(),
* targetFormat: 'webp',
* quality: 80,
* })
* ```
*/
export declare function createBrowserTextureEncoder(): (inputBuffer: Uint8Array | ArrayBuffer) => {
resize(w?: number, h?: number, _opts?: unknown): /*elided*/ any;
webp(opts?: {
quality?: number;
}): /*elided*/ any;
jpeg(opts?: {
quality?: number;
}): /*elided*/ any;
png(_opts?: unknown): /*elided*/ any;
/**
* sharp-compatible `.toFormat(format, opts)` — gltf-transform calls this
* instead of `.webp()` / `.jpeg()` / `.png()` directly.
*/
toFormat(format: string, opts?: {
quality?: number;
lossless?: boolean;
nearLossless?: boolean;
}): /*elided*/ any;
toBuffer(): Promise<Uint8Array>;
metadata(): Promise<{
width: number;
height: number;
format: string;
}>;
};