@pixi/basis
Version:
Loader for the *.basis supercompressed texture file format. This package also ships with the transcoder!
104 lines (103 loc) • 3.08 kB
TypeScript
import { INTERNAL_FORMATS } from '@pixi/compressed-textures';
import { TYPES } from '@pixi/core';
/**
* The transcoding formats provided by basis_universal.
*
* NOTE: Not all of these formats are supported on WebGL!
* @ignore
*/
export declare enum BASIS_FORMATS {
cTFETC1 = 0,
cTFETC2 = 1,
cTFBC1 = 2,
cTFBC3 = 3,
cTFBC4 = 4,
cTFBC5 = 5,
cTFBC7 = 6,
cTFPVRTC1_4_RGB = 8,
cTFPVRTC1_4_RGBA = 9,
cTFASTC_4x4 = 10,
cTFATC_RGB = 11,
cTFATC_RGBA_INTERPOLATED_ALPHA = 12,
cTFRGBA32 = 13,
cTFRGB565 = 14,
cTFBGR565 = 15,
cTFRGBA4444 = 16
}
/**
* Maps {@link BASIS_FORMATS} to {@link PIXI.INTERNAL_FORMATS}
* @ignore
*/
export declare const BASIS_FORMAT_TO_INTERNAL_FORMAT: {
[id: number]: INTERNAL_FORMATS;
};
/**
* Maps {@link BASIS_FORMATS} to {@link PIXI.TYPES}. These formats are a fallback when the basis file cannot be transcoded
* to a valid compressed texture format.
*
* NOTE: {@link BASIS_FORMATS.cTFBGR565} is not supported, while {@link BASIS_FORMATS.cTFRGBA4444} is not implemented by
* [at]pixi/basis.
* @ignore
*/
export declare const BASIS_FORMAT_TO_TYPE: {
[id: number]: TYPES;
};
/**
* Maps {@link PIXI.INTERNAL_FORMATS} to {@link BASIS_FORMATS}
* @ignore
*/
export declare const INTERNAL_FORMAT_TO_BASIS_FORMAT: {
[id: number]: number;
};
/**
* Enumerates the basis formats with alpha components
* @ignore
*/
export declare const BASIS_FORMATS_ALPHA: {
[id: number]: boolean;
};
/**
* Binding to C++ {@code BasisFile} wrapper class.
* @see https://github.com/BinomialLLC/basis_universal/blob/master/webgl/transcoder/basis_wrappers.cpp
* @private
*/
export declare class BasisFile {
constructor(buffer: Uint8Array);
getNumImages(): number;
getNumLevels(imageId: number): number;
getImageWidth(imageId: number, level: number): number;
getImageHeight(imageId: number, level: number): number;
getHasAlpha(): boolean;
startTranscoding(): boolean;
getImageTranscodedSizeInBytes(imageId: number, level: number, basisFormat: number): number;
transcodeImage(dstBuff: Uint8Array, imageId: number, level: number, basisFormat: BASIS_FORMATS, pvrtcWrapAddressing: boolean, getAlphaForOpaqueFormats: boolean): number;
close(): void;
delete(): void;
}
/**
* Compressed texture extensions relevant to the formats into which Basis can decompress into.
* @ignore
*/
export type BasisTextureExtensions = {
s3tc?: WEBGL_compressed_texture_s3tc;
s3tc_sRGB: WEBGL_compressed_texture_s3tc_srgb;
etc: any;
etc1: any;
pvrtc: any;
atc: any;
astc: WEBGL_compressed_texture_astc;
bptc: any;
};
/** API provided by basis_universal WebGL library. */
export type BasisBinding = {
BasisFile: typeof BasisFile;
initializeBasis: () => void;
};
/**
* Binding to basis_universal WebGL library.
* @see https://github.com/BinomialLLC/basis_universal/blob/master/webgl/transcoder/build/basis_transcoder.js
* @ignore
*/
export type BASIS = (opts?: {
wasmBinary: ArrayBuffer;
}) => Promise<BasisBinding>;