Add existing to tracked
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
||||
export declare class BufferReader {
|
||||
private _dataView;
|
||||
private _littleEndian;
|
||||
_offset: number;
|
||||
constructor(data: Uint8Array, byteOffset: number, byteLength: number, littleEndian: boolean);
|
||||
_nextUint8(): number;
|
||||
_nextUint16(): number;
|
||||
_nextUint32(): number;
|
||||
_nextUint64(): number;
|
||||
_nextInt32(): number;
|
||||
_nextUint8Array(len: number): Uint8Array;
|
||||
_skip(bytes: number): this;
|
||||
_scan(maxByteLength: number, term?: number): Uint8Array;
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
export declare const KTX_WRITER: string;
|
||||
export declare const NUL: Uint8Array;
|
||||
export type vec3 = [number, number, number];
|
||||
export type vec2 = [number, number, number];
|
||||
export declare const KTX2_ID: number[];
|
||||
export declare const HEADER_BYTE_LENGTH = 68;
|
||||
+251
File diff suppressed because one or more lines are too long
+104
@@ -0,0 +1,104 @@
|
||||
import type { Supercompression, VKFormat } from './constants.js';
|
||||
/**
|
||||
* Represents an unpacked KTX 2.0 texture container. Data for individual mip levels are stored in
|
||||
* the `.levels` array, typically compressed in Basis Universal formats. Additional properties
|
||||
* provide metadata required to process, transcode, and upload these textures.
|
||||
*/
|
||||
export interface KTX2Container {
|
||||
/**
|
||||
* Specifies the image format using Vulkan VkFormat enum values. When using Basis Universal
|
||||
* texture formats, `vkFormat` must be VK_FORMAT_UNDEFINED.
|
||||
*/
|
||||
vkFormat: VKFormat;
|
||||
/**
|
||||
* Size of the data type in bytes used to upload the data to a graphics API. When `vkFormat` is
|
||||
* VK_FORMAT_UNDEFINED, `typeSize` must be 1.
|
||||
*/
|
||||
typeSize: number;
|
||||
/** Width of the texture image for level 0, in pixels. */
|
||||
pixelWidth: number;
|
||||
/** Height of the texture image for level 0, in pixels. */
|
||||
pixelHeight: number;
|
||||
/** Depth of the texture image for level 0, in pixels (3D textures only). */
|
||||
pixelDepth: number;
|
||||
/** Number of array elements (array textures only). */
|
||||
layerCount: number;
|
||||
/**
|
||||
* Number of cubemap faces. For cubemaps and cubemap arrays, `faceCount` must be 6. For all
|
||||
* other textures, `faceCount` must be 1. Cubemap faces are stored in +X, -X, +Y, -Y, +Z, -Z
|
||||
* order.
|
||||
*/
|
||||
faceCount: number;
|
||||
/**
|
||||
* Number of levels in the mipmap level array. Mipmap pyramid may not necessarily be complete.
|
||||
* `levelCount = 1` implies that the file contains only the base level, and is not meant to have
|
||||
* other levels. `levelCount = 0` implies that the file contains only the base level, and that
|
||||
* other levels should be generated by the loader at runtime. For block-compressed formats,
|
||||
* `levelCount = 0` is disallowed.
|
||||
*/
|
||||
levelCount: number;
|
||||
/** Indicates which supercompression scheme has been applied to mip level images, if any. */
|
||||
supercompressionScheme: Supercompression;
|
||||
/** Mip levels, ordered largest (original) to smallest (~1px). */
|
||||
levels: KTX2Level[];
|
||||
/** Data Format Descriptor. */
|
||||
dataFormatDescriptor: KTX2DataFormatDescriptorBasicFormat[];
|
||||
/** Key/Value Data. */
|
||||
keyValue: {
|
||||
[key: string]: string | Uint8Array;
|
||||
};
|
||||
/** Supercompression Global Data. */
|
||||
globalData: KTX2GlobalDataBasisLZ | null;
|
||||
}
|
||||
export interface KTX2Level {
|
||||
/** Compressed data of the mip level. */
|
||||
levelData: Uint8Array;
|
||||
/**
|
||||
* Size of the mip level after reflation from supercompression, if applicable. When
|
||||
* `supercompressionType` is BASISLZ, `uncompressedByteLength` must be 0. When
|
||||
* `supercompressionType` is `NONE`, `uncompressedByteLength` must match the `levelData` byte
|
||||
* length.
|
||||
*
|
||||
* _**NOTICE:** this implies that for formats such as UASTC, `uncompressedByteLength` may
|
||||
* indicate size after ZSTD reflation (and of transcoded ASTC data), but does _not_ indicate
|
||||
* size of decoded RGBA32 pixels._
|
||||
*/
|
||||
uncompressedByteLength: number;
|
||||
}
|
||||
export interface KTX2DataFormatDescriptorBasicFormat {
|
||||
vendorId: number;
|
||||
descriptorType: number;
|
||||
versionNumber: number;
|
||||
colorModel: number;
|
||||
colorPrimaries: number;
|
||||
transferFunction: number;
|
||||
flags: number;
|
||||
texelBlockDimension: [number, number, number, number];
|
||||
bytesPlane: [number, number, number, number, number, number, number, number];
|
||||
samples: KTX2BasicFormatSample[];
|
||||
}
|
||||
export interface KTX2BasicFormatSample {
|
||||
bitOffset: number;
|
||||
bitLength: number;
|
||||
channelType: number;
|
||||
samplePosition: number[];
|
||||
sampleLower: number;
|
||||
sampleUpper: number;
|
||||
}
|
||||
export interface KTX2GlobalDataBasisLZ {
|
||||
endpointCount: number;
|
||||
selectorCount: number;
|
||||
imageDescs: KTX2GlobalDataBasisLZImageDesc[];
|
||||
endpointsData: Uint8Array;
|
||||
selectorsData: Uint8Array;
|
||||
tablesData: Uint8Array;
|
||||
extendedData: Uint8Array;
|
||||
}
|
||||
interface KTX2GlobalDataBasisLZImageDesc {
|
||||
imageFlags: number;
|
||||
rgbSliceByteOffset: number;
|
||||
rgbSliceByteLength: number;
|
||||
alphaSliceByteOffset: number;
|
||||
alphaSliceByteLength: number;
|
||||
}
|
||||
export {};
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import type { KTX2Container } from './container.js';
|
||||
/**
|
||||
* Creates a 'default' {@link KTX2Container} object, initialized with common
|
||||
* configuration wfor BT709 primaries and sRGB transfer, without pixel data.
|
||||
* There's nothing particularly special about the 'default' container; creating
|
||||
* the KTX2Container object explicitly is also fine.
|
||||
*/
|
||||
export declare function createDefaultContainer(): KTX2Container;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
export * from './create-default-container.js';
|
||||
export * from './container.js';
|
||||
export * from './constants.js';
|
||||
export * from './read.js';
|
||||
export * from './write.js';
|
||||
+1041
File diff suppressed because it is too large
Load Diff
+1
File diff suppressed because one or more lines are too long
+794
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+798
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+9
@@ -0,0 +1,9 @@
|
||||
import type { KTX2Container } from './container.js';
|
||||
/**
|
||||
* Parses a KTX 2.0 file, returning an unpacked {@link KTX2Container} instance with all associated
|
||||
* data. The container's mip levels and other binary data are pointers into the original file, not
|
||||
* copies, so the original file should not be overwritten after reading.
|
||||
*
|
||||
* @param data Bytes of KTX 2.0 file, as Uint8Array or Buffer.
|
||||
*/
|
||||
export declare function read(data: Uint8Array): KTX2Container;
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
import type { vec3 } from './constants-internal.js';
|
||||
import { type VKFormat } from './constants.js';
|
||||
import type { KTX2Container } from './container.js';
|
||||
/** Encodes text to an ArrayBuffer. */
|
||||
export declare function encodeText(text: string): Uint8Array;
|
||||
/** Decodes an ArrayBuffer to text. */
|
||||
export declare function decodeText(buffer: Uint8Array): string;
|
||||
/** Concatenates N ArrayBuffers. */
|
||||
export declare function concat(buffers: (ArrayBuffer | Uint8Array)[]): Uint8Array;
|
||||
/** Returns the least common multiple (LCM) for two positive integers. */
|
||||
export declare function leastCommonMultiple(a: number, b: number): number;
|
||||
/**
|
||||
* Returns amount of padding, in bytes, required to pad a value V to N-byte
|
||||
* boundaries. Both V and N must be positive integers.
|
||||
*/
|
||||
export declare function getPadding(v: number, n?: number): number;
|
||||
/** Returns byte length per texel block. */
|
||||
export declare function getBlockByteLength(container: KTX2Container): number;
|
||||
/**
|
||||
* Returns total number of blocks for given level. For VK_FORMAT_UNDEFINED, DFD is required.
|
||||
*
|
||||
* References:
|
||||
* - https://github.khronos.org/KTX-Specification/ktxspec.v2.html#levelImages
|
||||
*/
|
||||
export declare function getBlockCount(container: KTX2Container, levelIndex: number): number;
|
||||
/**
|
||||
* Given a KTX2 container, returns block dimensions as [width, height, depth]. Requires valid DFD.
|
||||
*/
|
||||
export declare function getBlockDimensions(container: KTX2Container): vec3;
|
||||
/**
|
||||
* Given `vkFormat`, returns block dimensions as [width, height, depth]. Does not support
|
||||
* VK_FORMAT_UNDEFINED.
|
||||
*
|
||||
* References:
|
||||
* - https://github.khronos.org/KTX-Specification/ktxspec.v2.html#_mippadding
|
||||
* - https://registry.khronos.org/vulkan/specs/1.2-extensions/html/vkspec.html#formats-compatibility
|
||||
*/
|
||||
export declare function getBlockDimensionsByVKFormat(vkFormat: VKFormat): vec3;
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
import type { KTX2Container } from './container.js';
|
||||
interface WriteOptions {
|
||||
keepWriter?: boolean;
|
||||
}
|
||||
/**
|
||||
* Serializes a {@link KTX2Container} instance to a KTX 2.0 file. Mip levels and other binary data
|
||||
* are copied into the resulting Uint8Array, so the original container can safely be edited or
|
||||
* destroyed after it is serialized.
|
||||
*
|
||||
* Options:
|
||||
* - keepWriter: If true, 'KTXWriter' key/value field is written as provided by the container.
|
||||
* Otherwise, a string for the current ktx-parse version is generated. Default: false.
|
||||
*
|
||||
* @param container
|
||||
* @param options
|
||||
*/
|
||||
export declare function write(container: KTX2Container, options?: WriteOptions): Uint8Array;
|
||||
export {};
|
||||
Reference in New Issue
Block a user