@pixi/basis
Version:
Loader for the *.basis supercompressed texture file format. This package also ships with the transcoder!
69 lines (68 loc) • 1.99 kB
TypeScript
import type { BASIS, BASIS_FORMATS } from './Basis';
/**
* Initialization message sent by the main thread.
* @ignore
*/
export interface IInitializeTranscoderMessage {
wasmSource: ArrayBuffer;
type: 'init';
}
/**
* Request parameters for transcoding basis files. It only supports transcoding all of the basis file at once.
* @ignore
*/
export interface ITranscodeMessage {
requestID?: number;
rgbFormat: number;
rgbaFormat?: number;
basisData?: Uint8Array;
type: 'transcode';
}
/** @ignore */
export interface ITranscodedImage {
imageID: number;
levelArray: Array<{
levelID: number;
levelWidth: number;
levelHeight: number;
levelBuffer: Uint8Array;
}>;
width: number;
height: number;
}
/**
* Response format for {@link PIXI.TranscoderWorker}.
* @ignore
*/
export interface ITranscodeResponse {
type: 'init' | 'transcode';
requestID?: number;
success: boolean;
basisFormat?: BASIS_FORMATS;
imageArray?: Array<{
imageID: number;
levelArray: Array<{
levelID: number;
levelWidth: number;
levelHeight: number;
levelBuffer: Uint8Array;
}>;
width: number;
height: number;
}>;
}
declare global {
interface Window {
BASIS: BASIS;
}
}
/**
* This wraps the transcoder web-worker functionality; it can be converted into a string to get the source code. It expects
* you to prepend the transcoder JavaScript code so that the `BASIS` namespace is available.
*
* The transcoder worker responds to two types of messages: "init" and "transcode". You must always send the first "init"
* {@link IInitializeTranscoderMessage} message with the WebAssembly binary; if the transcoder is successfully initialized,
* the web-worker will respond by sending another {@link ITranscodeResponse} message with `success: true`.
* @ignore
*/
export declare function TranscoderWorkerWrapper(): void;