Comparing version 0.2.2 to 0.3.0
@@ -10,4 +10,5 @@ export declare class BufferReader { | ||
_nextUint64(): number; | ||
_nextInt32(): number; | ||
_skip(bytes: number): this; | ||
_scan(maxByteLength: number, term?: number): Uint8Array; | ||
} |
@@ -1,8 +0,244 @@ | ||
export declare const KTX_WRITER: string; | ||
export declare const NUL: Uint8Array; | ||
export declare const KTX2_ID: number[]; | ||
export declare const HEADER_BYTE_LENGTH = 68; | ||
export declare const KHR_SUPERCOMPRESSION_NONE = 0; | ||
export declare const KHR_SUPERCOMPRESSION_BASISLZ = 1; | ||
export declare const KHR_SUPERCOMPRESSION_ZSTD = 2; | ||
export declare const KHR_SUPERCOMPRESSION_ZLIB = 3; | ||
export declare const KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT = 0; | ||
export declare const KHR_DF_VENDORID_KHRONOS = 0; | ||
export declare const KHR_DF_VERSION = 2; | ||
export declare const KHR_DF_BLOCKSIZE = 40; | ||
export declare const KHR_DF_MODEL_UNSPECIFIED = 0; | ||
export declare const KHR_DF_MODEL_RGBSDA = 1; | ||
export declare const KHR_DF_MODEL_ETC1 = 160; | ||
export declare const KHR_DF_MODEL_ETC2 = 161; | ||
export declare const KHR_DF_MODEL_ASTC = 162; | ||
export declare const KHR_DF_MODEL_ETC1S = 163; | ||
export declare const KHR_DF_FLAG_ALPHA_STRAIGHT = 0; | ||
export declare const KHR_DF_FLAG_ALPHA_PREMULTIPLIED = 1; | ||
export declare const KHR_DF_TRANSFER_UNSPECIFIED = 0; | ||
export declare const KHR_DF_TRANSFER_LINEAR = 1; | ||
export declare const KHR_DF_TRANSFER_SRGB = 2; | ||
export declare const KHR_DF_TRANSFER_ITU = 3; | ||
export declare const KHR_DF_TRANSFER_NTSC = 4; | ||
export declare const KHR_DF_TRANSFER_SLOG = 5; | ||
export declare const KHR_DF_TRANSFER_SLOG2 = 6; | ||
export declare const KHR_DF_TRANSFER_BT1886 = 7; | ||
export declare const KHR_DF_TRANSFER_HLG_OETF = 8; | ||
export declare const KHR_DF_TRANSFER_HLG_EOTF = 9; | ||
export declare const KHR_DF_TRANSFER_PQ_EOTF = 10; | ||
export declare const KHR_DF_TRANSFER_PQ_OETF = 11; | ||
export declare const KHR_DF_TRANSFER_DCIP3 = 12; | ||
export declare const KHR_DF_TRANSFER_PAL_OETF = 13; | ||
export declare const KHR_DF_TRANSFER_PAL625_EOTF = 14; | ||
export declare const KHR_DF_TRANSFER_ST240 = 15; | ||
export declare const KHR_DF_TRANSFER_ACESCC = 16; | ||
export declare const KHR_DF_TRANSFER_ACESCCT = 17; | ||
export declare const KHR_DF_TRANSFER_ADOBERGB = 18; | ||
export declare const KHR_DF_PRIMARIES_UNSPECIFIED = 0; | ||
export declare const KHR_DF_PRIMARIES_BT709 = 1; | ||
export declare const KHR_DF_PRIMARIES_BT601_EBU = 2; | ||
export declare const KHR_DF_PRIMARIES_BT601_SMPTE = 3; | ||
export declare const KHR_DF_PRIMARIES_BT2020 = 4; | ||
export declare const KHR_DF_PRIMARIES_CIEXYZ = 5; | ||
export declare const KHR_DF_PRIMARIES_ACES = 6; | ||
export declare const KHR_DF_PRIMARIES_ACESCC = 7; | ||
export declare const KHR_DF_PRIMARIES_NTSC1953 = 8; | ||
export declare const KHR_DF_PRIMARIES_PAL525 = 9; | ||
export declare const KHR_DF_PRIMARIES_DISPLAYP3 = 10; | ||
export declare const KHR_DF_PRIMARIES_ADOBERGB = 11; | ||
export declare const KHR_DF_CHANNEL_RGBSDA_RED = 0; | ||
export declare const KHR_DF_CHANNEL_RGBSDA_GREEN = 1; | ||
export declare const KHR_DF_CHANNEL_RGBSDA_BLUE = 2; | ||
export declare const KHR_DF_CHANNEL_RGBSDA_STENCIL = 13; | ||
export declare const KHR_DF_CHANNEL_RGBSDA_DEPTH = 14; | ||
export declare const KHR_DF_CHANNEL_RGBSDA_ALPHA = 15; | ||
export declare const KHR_DF_SAMPLE_DATATYPE_FLOAT = 128; | ||
export declare const KHR_DF_SAMPLE_DATATYPE_SIGNED = 64; | ||
export declare const KHR_DF_SAMPLE_DATATYPE_EXPONENT = 32; | ||
export declare const KHR_DF_SAMPLE_DATATYPE_LINEAR = 16; | ||
export declare const VK_FORMAT_UNDEFINED = 0; | ||
export declare const VK_FORMAT_R4G4_UNORM_PACK8 = 1; | ||
export declare const VK_FORMAT_R4G4B4A4_UNORM_PACK16 = 2; | ||
export declare const VK_FORMAT_B4G4R4A4_UNORM_PACK16 = 3; | ||
export declare const VK_FORMAT_R5G6B5_UNORM_PACK16 = 4; | ||
export declare const VK_FORMAT_B5G6R5_UNORM_PACK16 = 5; | ||
export declare const VK_FORMAT_R5G5B5A1_UNORM_PACK16 = 6; | ||
export declare const VK_FORMAT_B5G5R5A1_UNORM_PACK16 = 7; | ||
export declare const VK_FORMAT_A1R5G5B5_UNORM_PACK16 = 8; | ||
export declare const VK_FORMAT_R8_UNORM = 9; | ||
export declare const VK_FORMAT_R8_SNORM = 10; | ||
export declare const VK_FORMAT_R8_UINT = 13; | ||
export declare const VK_FORMAT_R8_SINT = 14; | ||
export declare const VK_FORMAT_R8_SRGB = 15; | ||
export declare const VK_FORMAT_R8G8_UNORM = 16; | ||
export declare const VK_FORMAT_R8G8_SNORM = 17; | ||
export declare const VK_FORMAT_R8G8_UINT = 20; | ||
export declare const VK_FORMAT_R8G8_SINT = 21; | ||
export declare const VK_FORMAT_R8G8_SRGB = 22; | ||
export declare const VK_FORMAT_R8G8B8_UNORM = 23; | ||
export declare const VK_FORMAT_R8G8B8_SNORM = 24; | ||
export declare const VK_FORMAT_R8G8B8_UINT = 27; | ||
export declare const VK_FORMAT_R8G8B8_SINT = 28; | ||
export declare const VK_FORMAT_R8G8B8_SRGB = 29; | ||
export declare const VK_FORMAT_B8G8R8_UNORM = 30; | ||
export declare const VK_FORMAT_B8G8R8_SNORM = 31; | ||
export declare const VK_FORMAT_B8G8R8_UINT = 34; | ||
export declare const VK_FORMAT_B8G8R8_SINT = 35; | ||
export declare const VK_FORMAT_B8G8R8_SRGB = 36; | ||
export declare const VK_FORMAT_R8G8B8A8_UNORM = 37; | ||
export declare const VK_FORMAT_R8G8B8A8_SNORM = 38; | ||
export declare const VK_FORMAT_R8G8B8A8_UINT = 41; | ||
export declare const VK_FORMAT_R8G8B8A8_SINT = 42; | ||
export declare const VK_FORMAT_R8G8B8A8_SRGB = 43; | ||
export declare const VK_FORMAT_B8G8R8A8_UNORM = 44; | ||
export declare const VK_FORMAT_B8G8R8A8_SNORM = 45; | ||
export declare const VK_FORMAT_B8G8R8A8_UINT = 48; | ||
export declare const VK_FORMAT_B8G8R8A8_SINT = 49; | ||
export declare const VK_FORMAT_B8G8R8A8_SRGB = 50; | ||
export declare const VK_FORMAT_A2R10G10B10_UNORM_PACK32 = 58; | ||
export declare const VK_FORMAT_A2R10G10B10_SNORM_PACK32 = 59; | ||
export declare const VK_FORMAT_A2R10G10B10_UINT_PACK32 = 62; | ||
export declare const VK_FORMAT_A2R10G10B10_SINT_PACK32 = 63; | ||
export declare const VK_FORMAT_A2B10G10R10_UNORM_PACK32 = 64; | ||
export declare const VK_FORMAT_A2B10G10R10_SNORM_PACK32 = 65; | ||
export declare const VK_FORMAT_A2B10G10R10_UINT_PACK32 = 68; | ||
export declare const VK_FORMAT_A2B10G10R10_SINT_PACK32 = 69; | ||
export declare const VK_FORMAT_R16_UNORM = 70; | ||
export declare const VK_FORMAT_R16_SNORM = 71; | ||
export declare const VK_FORMAT_R16_UINT = 74; | ||
export declare const VK_FORMAT_R16_SINT = 75; | ||
export declare const VK_FORMAT_R16_SFLOAT = 76; | ||
export declare const VK_FORMAT_R16G16_UNORM = 77; | ||
export declare const VK_FORMAT_R16G16_SNORM = 78; | ||
export declare const VK_FORMAT_R16G16_UINT = 81; | ||
export declare const VK_FORMAT_R16G16_SINT = 82; | ||
export declare const VK_FORMAT_R16G16_SFLOAT = 83; | ||
export declare const VK_FORMAT_R16G16B16_UNORM = 84; | ||
export declare const VK_FORMAT_R16G16B16_SNORM = 85; | ||
export declare const VK_FORMAT_R16G16B16_UINT = 88; | ||
export declare const VK_FORMAT_R16G16B16_SINT = 89; | ||
export declare const VK_FORMAT_R16G16B16_SFLOAT = 90; | ||
export declare const VK_FORMAT_R16G16B16A16_UNORM = 91; | ||
export declare const VK_FORMAT_R16G16B16A16_SNORM = 92; | ||
export declare const VK_FORMAT_R16G16B16A16_UINT = 95; | ||
export declare const VK_FORMAT_R16G16B16A16_SINT = 96; | ||
export declare const VK_FORMAT_R16G16B16A16_SFLOAT = 97; | ||
export declare const VK_FORMAT_R32_UINT = 98; | ||
export declare const VK_FORMAT_R32_SINT = 99; | ||
export declare const VK_FORMAT_R32_SFLOAT = 100; | ||
export declare const VK_FORMAT_R32G32_UINT = 101; | ||
export declare const VK_FORMAT_R32G32_SINT = 102; | ||
export declare const VK_FORMAT_R32G32_SFLOAT = 103; | ||
export declare const VK_FORMAT_R32G32B32_UINT = 104; | ||
export declare const VK_FORMAT_R32G32B32_SINT = 105; | ||
export declare const VK_FORMAT_R32G32B32_SFLOAT = 106; | ||
export declare const VK_FORMAT_R32G32B32A32_UINT = 107; | ||
export declare const VK_FORMAT_R32G32B32A32_SINT = 108; | ||
export declare const VK_FORMAT_R32G32B32A32_SFLOAT = 109; | ||
export declare const VK_FORMAT_R64_UINT = 110; | ||
export declare const VK_FORMAT_R64_SINT = 111; | ||
export declare const VK_FORMAT_R64_SFLOAT = 112; | ||
export declare const VK_FORMAT_R64G64_UINT = 113; | ||
export declare const VK_FORMAT_R64G64_SINT = 114; | ||
export declare const VK_FORMAT_R64G64_SFLOAT = 115; | ||
export declare const VK_FORMAT_R64G64B64_UINT = 116; | ||
export declare const VK_FORMAT_R64G64B64_SINT = 117; | ||
export declare const VK_FORMAT_R64G64B64_SFLOAT = 118; | ||
export declare const VK_FORMAT_R64G64B64A64_UINT = 119; | ||
export declare const VK_FORMAT_R64G64B64A64_SINT = 120; | ||
export declare const VK_FORMAT_R64G64B64A64_SFLOAT = 121; | ||
export declare const VK_FORMAT_B10G11R11_UFLOAT_PACK32 = 122; | ||
export declare const VK_FORMAT_E5B9G9R9_UFLOAT_PACK32 = 123; | ||
export declare const VK_FORMAT_D16_UNORM = 124; | ||
export declare const VK_FORMAT_X8_D24_UNORM_PACK32 = 125; | ||
export declare const VK_FORMAT_D32_SFLOAT = 126; | ||
export declare const VK_FORMAT_S8_UINT = 127; | ||
export declare const VK_FORMAT_D16_UNORM_S8_UINT = 128; | ||
export declare const VK_FORMAT_D24_UNORM_S8_UINT = 129; | ||
export declare const VK_FORMAT_D32_SFLOAT_S8_UINT = 130; | ||
export declare const VK_FORMAT_BC1_RGB_UNORM_BLOCK = 131; | ||
export declare const VK_FORMAT_BC1_RGB_SRGB_BLOCK = 132; | ||
export declare const VK_FORMAT_BC1_RGBA_UNORM_BLOCK = 133; | ||
export declare const VK_FORMAT_BC1_RGBA_SRGB_BLOCK = 134; | ||
export declare const VK_FORMAT_BC2_UNORM_BLOCK = 135; | ||
export declare const VK_FORMAT_BC2_SRGB_BLOCK = 136; | ||
export declare const VK_FORMAT_BC3_UNORM_BLOCK = 137; | ||
export declare const VK_FORMAT_BC3_SRGB_BLOCK = 138; | ||
export declare const VK_FORMAT_BC4_UNORM_BLOCK = 139; | ||
export declare const VK_FORMAT_BC4_SNORM_BLOCK = 140; | ||
export declare const VK_FORMAT_BC5_UNORM_BLOCK = 141; | ||
export declare const VK_FORMAT_BC5_SNORM_BLOCK = 142; | ||
export declare const VK_FORMAT_BC6H_UFLOAT_BLOCK = 143; | ||
export declare const VK_FORMAT_BC6H_SFLOAT_BLOCK = 144; | ||
export declare const VK_FORMAT_BC7_UNORM_BLOCK = 145; | ||
export declare const VK_FORMAT_BC7_SRGB_BLOCK = 146; | ||
export declare const VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK = 147; | ||
export declare const VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK = 148; | ||
export declare const VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK = 149; | ||
export declare const VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK = 150; | ||
export declare const VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK = 151; | ||
export declare const VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK = 152; | ||
export declare const VK_FORMAT_EAC_R11_UNORM_BLOCK = 153; | ||
export declare const VK_FORMAT_EAC_R11_SNORM_BLOCK = 154; | ||
export declare const VK_FORMAT_EAC_R11G11_UNORM_BLOCK = 155; | ||
export declare const VK_FORMAT_EAC_R11G11_SNORM_BLOCK = 156; | ||
export declare const VK_FORMAT_ASTC_4x4_UNORM_BLOCK = 157; | ||
export declare const VK_FORMAT_ASTC_4x4_SRGB_BLOCK = 158; | ||
export declare const VK_FORMAT_ASTC_5x4_UNORM_BLOCK = 159; | ||
export declare const VK_FORMAT_ASTC_5x4_SRGB_BLOCK = 160; | ||
export declare const VK_FORMAT_ASTC_5x5_UNORM_BLOCK = 161; | ||
export declare const VK_FORMAT_ASTC_5x5_SRGB_BLOCK = 162; | ||
export declare const VK_FORMAT_ASTC_6x5_UNORM_BLOCK = 163; | ||
export declare const VK_FORMAT_ASTC_6x5_SRGB_BLOCK = 164; | ||
export declare const VK_FORMAT_ASTC_6x6_UNORM_BLOCK = 165; | ||
export declare const VK_FORMAT_ASTC_6x6_SRGB_BLOCK = 166; | ||
export declare const VK_FORMAT_ASTC_8x5_UNORM_BLOCK = 167; | ||
export declare const VK_FORMAT_ASTC_8x5_SRGB_BLOCK = 168; | ||
export declare const VK_FORMAT_ASTC_8x6_UNORM_BLOCK = 169; | ||
export declare const VK_FORMAT_ASTC_8x6_SRGB_BLOCK = 170; | ||
export declare const VK_FORMAT_ASTC_8x8_UNORM_BLOCK = 171; | ||
export declare const VK_FORMAT_ASTC_8x8_SRGB_BLOCK = 172; | ||
export declare const VK_FORMAT_ASTC_10x5_UNORM_BLOCK = 173; | ||
export declare const VK_FORMAT_ASTC_10x5_SRGB_BLOCK = 174; | ||
export declare const VK_FORMAT_ASTC_10x6_UNORM_BLOCK = 175; | ||
export declare const VK_FORMAT_ASTC_10x6_SRGB_BLOCK = 176; | ||
export declare const VK_FORMAT_ASTC_10x8_UNORM_BLOCK = 177; | ||
export declare const VK_FORMAT_ASTC_10x8_SRGB_BLOCK = 178; | ||
export declare const VK_FORMAT_ASTC_10x10_UNORM_BLOCK = 179; | ||
export declare const VK_FORMAT_ASTC_10x10_SRGB_BLOCK = 180; | ||
export declare const VK_FORMAT_ASTC_12x10_UNORM_BLOCK = 181; | ||
export declare const VK_FORMAT_ASTC_12x10_SRGB_BLOCK = 182; | ||
export declare const VK_FORMAT_ASTC_12x12_UNORM_BLOCK = 183; | ||
export declare const VK_FORMAT_ASTC_12x12_SRGB_BLOCK = 184; | ||
export declare const VK_FORMAT_R10X6_UNORM_PACK16 = 1000156007; | ||
export declare const VK_FORMAT_R10X6G10X6_UNORM_2PACK16 = 1000156008; | ||
export declare const VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16 = 1000156009; | ||
export declare const VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16 = 1000156010; | ||
export declare const VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 = 1000156011; | ||
export declare const VK_FORMAT_R12X4_UNORM_PACK16 = 1000156017; | ||
export declare const VK_FORMAT_R12X4G12X4_UNORM_2PACK16 = 1000156018; | ||
export declare const VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16 = 1000156019; | ||
export declare const VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 = 1000156020; | ||
export declare const VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16 = 1000156021; | ||
export declare const VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG = 1000054000; | ||
export declare const VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG = 1000054001; | ||
export declare const VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG = 1000054002; | ||
export declare const VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG = 1000054003; | ||
export declare const VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG = 1000054004; | ||
export declare const VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG = 1000054005; | ||
export declare const VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG = 1000054006; | ||
export declare const VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG = 1000054007; | ||
export declare const VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK_EXT = 1000066000; | ||
export declare const VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK_EXT = 1000066001; | ||
export declare const VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK_EXT = 1000066002; | ||
export declare const VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK_EXT = 1000066003; | ||
export declare const VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK_EXT = 1000066004; | ||
export declare const VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK_EXT = 1000066005; | ||
export declare const VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK_EXT = 1000066006; | ||
export declare const VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK_EXT = 1000066007; | ||
export declare const VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK_EXT = 1000066008; | ||
export declare const VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK_EXT = 1000066009; | ||
export declare const VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK_EXT = 1000066010; | ||
export declare const VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK_EXT = 1000066011; | ||
export declare const VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK_EXT = 1000066012; | ||
export declare const VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK_EXT = 1000066013; | ||
export declare const VK_FORMAT_A4R4G4B4_UNORM_PACK16_EXT = 1000340000; | ||
export declare const VK_FORMAT_A4B4G4R4_UNORM_PACK16_EXT = 1000340001; |
@@ -1,2 +0,1 @@ | ||
import { KTX2SupercompressionScheme } from './enums'; | ||
/** | ||
@@ -33,3 +32,3 @@ * Represents an unpacked KTX 2.0 texture container. Data for individual mip levels are stored in | ||
/** Indicates which supercompression scheme has been applied to mip level images, if any. */ | ||
supercompressionScheme: KTX2SupercompressionScheme; | ||
supercompressionScheme: number; | ||
/** Mip levels, ordered largest (original) to smallest (~1px). */ | ||
@@ -65,2 +64,3 @@ levels: KTX2Level[]; | ||
versionNumber: number; | ||
/** @deprecated Inferred. */ | ||
descriptorBlockSize: number; | ||
@@ -71,16 +71,12 @@ colorModel: number; | ||
flags: number; | ||
texelBlockDimension: KTX2BasicFormatTexelBlockDimensions; | ||
bytesPlane: number[]; | ||
texelBlockDimension: [number, number, number, number]; | ||
bytesPlane: [number, number, number, number, number, number, number, number]; | ||
samples: KTX2BasicFormatSample[]; | ||
} | ||
export interface KTX2BasicFormatTexelBlockDimensions { | ||
x: number; | ||
y: number; | ||
z: number; | ||
w: number; | ||
} | ||
export interface KTX2BasicFormatSample { | ||
bitOffset: number; | ||
bitLength: number; | ||
channelID: number; | ||
/** @deprecated Renamed to 'channelType'. */ | ||
channelID?: number; | ||
channelType: number; | ||
samplePosition: number[]; | ||
@@ -87,0 +83,0 @@ sampleLower: number; |
export * from './container'; | ||
export * from './enums'; | ||
export * from './constants'; | ||
export * from './read'; | ||
export * from './write'; |
@@ -1,2 +0,2 @@ | ||
var t,e,n,i,r,a,s,o,l=new Uint8Array([0]),f=[171,75,84,88,32,50,48,187,13,10,26,10];(t=exports.KTX2SupercompressionScheme||(exports.KTX2SupercompressionScheme={}))[t.NONE=0]="NONE",t[t.BASISLZ=1]="BASISLZ",t[t.ZSTD=2]="ZSTD",t[t.ZLIB=3]="ZLIB",(e=exports.KTX2DescriptorType||(exports.KTX2DescriptorType={}))[e.BASICFORMAT=0]="BASICFORMAT",(n=exports.KTX2Model||(exports.KTX2Model={}))[n.UNSPECIFIED=0]="UNSPECIFIED",n[n.ETC1S=163]="ETC1S",n[n.UASTC=166]="UASTC",(i=exports.KTX2Primaries||(exports.KTX2Primaries={}))[i.UNSPECIFIED=0]="UNSPECIFIED",i[i.SRGB=1]="SRGB",(r=exports.KTX2Transfer||(exports.KTX2Transfer={}))[r.UNSPECIFIED=0]="UNSPECIFIED",r[r.LINEAR=1]="LINEAR",r[r.SRGB=2]="SRGB",r[r.ITU=3]="ITU",r[r.NTSC=4]="NTSC",r[r.SLOG=5]="SLOG",r[r.SLOG2=6]="SLOG2",(a=exports.KTX2Flags||(exports.KTX2Flags={}))[a.ALPHA_STRAIGHT=0]="ALPHA_STRAIGHT",a[a.ALPHA_PREMULTIPLIED=1]="ALPHA_PREMULTIPLIED",(s=exports.KTX2ChannelETC1S||(exports.KTX2ChannelETC1S={}))[s.RGB=0]="RGB",s[s.RRR=3]="RRR",s[s.GGG=4]="GGG",s[s.AAA=15]="AAA",(o=exports.KTX2ChannelUASTC||(exports.KTX2ChannelUASTC={}))[o.RGB=0]="RGB",o[o.RGBA=3]="RGBA",o[o.RRR=4]="RRR",o[o.RRRG=5]="RRRG";var U=function(){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=exports.KTX2SupercompressionScheme.NONE,this.levels=[],this.dataFormatDescriptor=[{vendorId:0,descriptorType:exports.KTX2DescriptorType.BASICFORMAT,versionNumber:2,descriptorBlockSize:40,colorModel:exports.KTX2Model.UNSPECIFIED,colorPrimaries:exports.KTX2Primaries.SRGB,transferFunction:exports.KTX2Primaries.SRGB,flags:exports.KTX2Flags.ALPHA_STRAIGHT,texelBlockDimension:{x:4,y:4,z:1,w:1},bytesPlane:[],samples:[]}],this.keyValue={},this.globalData=null},p=function(){function t(t,e,n,i){this._dataView=new DataView(t.buffer,t.byteOffset+e,n),this._littleEndian=i,this._offset=0}var e=t.prototype;return e._nextUint8=function(){var t=this._dataView.getUint8(this._offset);return this._offset+=1,t},e._nextUint16=function(){var t=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,t},e._nextUint32=function(){var t=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,t},e._nextUint64=function(){var t=this._dataView.getUint32(this._offset,this._littleEndian),e=this._dataView.getUint32(this._offset+4,this._littleEndian),n=t+Math.pow(2,32)*e;return this._offset+=8,n},e._skip=function(t){return this._offset+=t,this},e._scan=function(t,e){void 0===e&&(e=0);for(var n=this._offset,i=0;this._dataView.getUint8(this._offset)!==e&&i<t;)i++,this._offset++;return i<t&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+n,i)},t}();function h(){return(h=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function x(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return c(t,void 0);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(t,void 0):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0;return function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=t[Symbol.iterator]()).next.bind(n)}function u(t){return"undefined"!=typeof TextEncoder?(new TextEncoder).encode(t):Buffer.from(t)}function _(t){return"undefined"!=typeof TextDecoder?(new TextDecoder).decode(t):Buffer.from(t).toString("utf8")}function g(t){for(var e,n=0,i=x(t);!(e=i()).done;)n+=e.value.byteLength;for(var r,a=new Uint8Array(n),s=0,o=x(t);!(r=o()).done;){var l=r.value;a.set(new Uint8Array(l),s),s+=l.byteLength}return a}var y={keepWriter:!1};exports.KTX2Container=U,exports.read=function(t){var e=new Uint8Array(t.buffer,t.byteOffset,f.length);if(e[0]!==f[0]||e[1]!==f[1]||e[2]!==f[2]||e[3]!==f[3]||e[4]!==f[4]||e[5]!==f[5]||e[6]!==f[6]||e[7]!==f[7]||e[8]!==f[8]||e[9]!==f[9]||e[10]!==f[10]||e[11]!==f[11])throw new Error("Missing KTX 2.0 identifier.");var n=new U,i=17*Uint32Array.BYTES_PER_ELEMENT,r=new p(t,f.length,i,!0);n.vkFormat=r._nextUint32(),n.typeSize=r._nextUint32(),n.pixelWidth=r._nextUint32(),n.pixelHeight=r._nextUint32(),n.pixelDepth=r._nextUint32(),n.layerCount=r._nextUint32(),n.faceCount=r._nextUint32();var a=r._nextUint32();n.supercompressionScheme=r._nextUint32();for(var s=r._nextUint32(),o=r._nextUint32(),l=r._nextUint32(),h=r._nextUint32(),c=r._nextUint64(),x=r._nextUint64(),u=new p(t,f.length+i,3*a*8,!0),g=0;g<a;g++)n.levels.push({levelData:new Uint8Array(t.buffer,t.byteOffset+u._nextUint64(),u._nextUint64()),uncompressedByteLength:u._nextUint64()});for(var y=new p(t,s,o,!0),d={vendorId:y._skip(4)._nextUint16(),descriptorType:y._nextUint16(),versionNumber:y._nextUint16(),descriptorBlockSize:y._nextUint16(),colorModel:y._nextUint8(),colorPrimaries:y._nextUint8(),transferFunction:y._nextUint8(),flags:y._nextUint8(),texelBlockDimension:{x:y._nextUint8()+1,y:y._nextUint8()+1,z:y._nextUint8()+1,w:y._nextUint8()+1},bytesPlane:[y._nextUint8(),y._nextUint8(),y._nextUint8(),y._nextUint8(),y._nextUint8(),y._nextUint8(),y._nextUint8(),y._nextUint8()],samples:[]},b=(d.descriptorBlockSize/4-6)/4,D=0;D<b;D++)d.samples[D]={bitOffset:y._nextUint16(),bitLength:y._nextUint8(),channelID:y._nextUint8(),samplePosition:[y._nextUint8(),y._nextUint8(),y._nextUint8(),y._nextUint8()],sampleLower:y._nextUint32(),sampleUpper:y._nextUint32()};n.dataFormatDescriptor.length=0,n.dataFormatDescriptor.push(d);for(var m=new p(t,l,h,!0);m._offset<h;){var v=m._nextUint32(),S=m._scan(v),T=_(S),A=m._scan(v-S.byteLength);n.keyValue[T]=T.match(/^ktx/i)?_(A):A,m._offset%4&&m._skip(4-m._offset%4)}if(x<=0)return n;for(var w=new p(t,c,x,!0),B=w._nextUint16(),L=w._nextUint16(),I=w._nextUint32(),R=w._nextUint32(),E=w._nextUint32(),C=w._nextUint32(),P=[],O=0;O<a;O++)P.push({imageFlags:w._nextUint32(),rgbSliceByteOffset:w._nextUint32(),rgbSliceByteLength:w._nextUint32(),alphaSliceByteOffset:w._nextUint32(),alphaSliceByteLength:w._nextUint32()});var F=c+w._offset,G=F+I,K=G+R,X=K+E,k=new Uint8Array(t.buffer,t.byteOffset+F,I),N=new Uint8Array(t.buffer,t.byteOffset+G,R),V=new Uint8Array(t.buffer,t.byteOffset+K,E),M=new Uint8Array(t.buffer,t.byteOffset+X,C);return n.globalData={endpointCount:B,selectorCount:L,imageDescs:P,endpointsData:k,selectorsData:N,tablesData:V,extendedData:M},n},exports.write=function(t,e){void 0===e&&(e={}),e=h({},y,e);var n=new ArrayBuffer(0);if(t.globalData){var i=new ArrayBuffer(20+5*t.globalData.imageDescs.length*4),r=new DataView(i);r.setUint16(0,t.globalData.endpointCount,!0),r.setUint16(2,t.globalData.selectorCount,!0),r.setUint32(4,t.globalData.endpointsData.byteLength,!0),r.setUint32(8,t.globalData.selectorsData.byteLength,!0),r.setUint32(12,t.globalData.tablesData.byteLength,!0),r.setUint32(16,t.globalData.extendedData.byteLength,!0);for(var a=0;a<t.globalData.imageDescs.length;a++){var s=t.globalData.imageDescs[a];r.setUint32(20+5*a*4+0,s.imageFlags,!0),r.setUint32(20+5*a*4+4,s.rgbSliceByteOffset,!0),r.setUint32(20+5*a*4+8,s.rgbSliceByteLength,!0),r.setUint32(20+5*a*4+12,s.alphaSliceByteOffset,!0),r.setUint32(20+5*a*4+16,s.alphaSliceByteLength,!0)}n=g([i,t.globalData.endpointsData,t.globalData.selectorsData,t.globalData.tablesData,t.globalData.extendedData])}var o=[],U=t.keyValue;for(var p in e.keepWriter||(U=h({},t.keyValue,{KTXwriter:"KTX-Parse v0.2.2"})),U){var c=U[p],x=u(p),_="string"==typeof c?u(c):c,d=x.byteLength+1+_.byteLength+1,b=d%4?4-d%4:0;o.push(g([new Uint32Array([d]),x,l,_,l,new Uint8Array(b).fill(0)]))}var D=g(o);if(1!==t.dataFormatDescriptor.length||t.dataFormatDescriptor[0].descriptorType!==exports.KTX2DescriptorType.BASICFORMAT)throw new Error("Only BASICFORMAT Data Format Descriptor output supported.");var m=t.dataFormatDescriptor[0],v=new ArrayBuffer(28+16*m.samples.length),S=new DataView(v);S.setUint32(0,v.byteLength,!0),S.setUint16(4,m.vendorId,!0),S.setUint16(6,m.descriptorType,!0),S.setUint16(8,m.versionNumber,!0),S.setUint16(10,m.descriptorBlockSize,!0),S.setUint8(12,m.colorModel),S.setUint8(13,m.colorPrimaries),S.setUint8(14,m.transferFunction),S.setUint8(15,m.flags),S.setUint8(16,m.texelBlockDimension.x-1),S.setUint8(17,m.texelBlockDimension.y-1),S.setUint8(18,m.texelBlockDimension.z-1),S.setUint8(19,m.texelBlockDimension.w-1);for(var T=0;T<8;T++)S.setUint8(20+T,m.bytesPlane[T]);for(var A=0;A<m.samples.length;A++){var w=m.samples[A],B=28+16*A;S.setUint16(B+0,w.bitOffset,!0),S.setUint8(B+2,w.bitLength),S.setUint8(B+3,w.channelID),S.setUint8(B+4,w.samplePosition[0]),S.setUint8(B+5,w.samplePosition[1]),S.setUint8(B+6,w.samplePosition[2]),S.setUint8(B+7,w.samplePosition[3]),S.setUint32(B+8,w.sampleLower,!0),S.setUint32(B+12,w.sampleUpper,!0)}var L=f.length+68+3*t.levels.length*8,I=L+v.byteLength,R=I+D.byteLength;R%8&&(R+=8-R%8);for(var E=[],C=new DataView(new ArrayBuffer(3*t.levels.length*8)),P=R+n.byteLength,O=0;O<t.levels.length;O++){var F=t.levels[O];E.push(F.levelData),C.setBigUint64(24*O+0,BigInt(P),!0),C.setBigUint64(24*O+8,BigInt(F.levelData.byteLength),!0),C.setBigUint64(24*O+16,BigInt(F.uncompressedByteLength),!0),P+=F.levelData.byteLength}var G=new ArrayBuffer(68),K=new DataView(G);return K.setUint32(0,t.vkFormat,!0),K.setUint32(4,t.typeSize,!0),K.setUint32(8,t.pixelWidth,!0),K.setUint32(12,t.pixelHeight,!0),K.setUint32(16,t.pixelDepth,!0),K.setUint32(20,t.layerCount,!0),K.setUint32(24,t.faceCount,!0),K.setUint32(28,t.levels.length,!0),K.setUint32(32,t.supercompressionScheme,!0),K.setUint32(36,L,!0),K.setUint32(40,v.byteLength,!0),K.setUint32(44,I,!0),K.setUint32(48,D.byteLength,!0),K.setBigUint64(52,BigInt(R),!0),K.setBigUint64(60,BigInt(n.byteLength),!0),new Uint8Array(g([new Uint8Array(f).buffer,G,C.buffer,v,D,new ArrayBuffer(R-(I+D.byteLength)),n].concat(E)))}; | ||
var _=function(){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=0,this.levels=[],this.dataFormatDescriptor=[{vendorId:0,descriptorType:0,descriptorBlockSize:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],this.keyValue={},this.globalData=null},t=function(){function _(_,t,e,r){this._dataView=new DataView(_.buffer,_.byteOffset+t,e),this._littleEndian=r,this._offset=0}var t=_.prototype;return t._nextUint8=function(){var _=this._dataView.getUint8(this._offset);return this._offset+=1,_},t._nextUint16=function(){var _=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,_},t._nextUint32=function(){var _=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,_},t._nextUint64=function(){var _=this._dataView.getUint32(this._offset,this._littleEndian),t=this._dataView.getUint32(this._offset+4,this._littleEndian),e=_+Math.pow(2,32)*t;return this._offset+=8,e},t._nextInt32=function(){var _=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,_},t._skip=function(_){return this._offset+=_,this},t._scan=function(_,t){void 0===t&&(t=0);for(var e=this._offset,r=0;this._dataView.getUint8(this._offset)!==t&&r<_;)r++,this._offset++;return r<_&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+e,r)},_}(),e=new Uint8Array([0]),r=[171,75,84,88,32,50,48,187,13,10,26,10];function R(){return(R=Object.assign||function(_){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(_[r]=e[r])}return _}).apply(this,arguments)}function s(_,t){(null==t||t>_.length)&&(t=_.length);for(var e=0,r=new Array(t);e<t;e++)r[e]=_[e];return r}function n(_,t){var e;if("undefined"==typeof Symbol||null==_[Symbol.iterator]){if(Array.isArray(_)||(e=function(_,t){if(_){if("string"==typeof _)return s(_,void 0);var e=Object.prototype.toString.call(_).slice(8,-1);return"Object"===e&&_.constructor&&(e=_.constructor.name),"Map"===e||"Set"===e?Array.from(_):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?s(_,void 0):void 0}}(_))||t&&_&&"number"==typeof _.length){e&&(_=e);var r=0;return function(){return r>=_.length?{done:!0}:{done:!1,value:_[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(e=_[Symbol.iterator]()).next.bind(e)}function o(_){return"undefined"!=typeof TextEncoder?(new TextEncoder).encode(_):Buffer.from(_)}function A(_){return"undefined"!=typeof TextDecoder?(new TextDecoder).decode(_):Buffer.from(_).toString("utf8")}function O(_){for(var t,e=0,r=n(_);!(t=r()).done;)e+=t.value.byteLength;for(var R,s=new Uint8Array(e),o=0,A=n(_);!(R=A()).done;){var O=R.value;s.set(new Uint8Array(O),o),o+=O.byteLength}return s}var T={keepWriter:!1};exports.KHR_DF_CHANNEL_RGBSDA_ALPHA=15,exports.KHR_DF_CHANNEL_RGBSDA_BLUE=2,exports.KHR_DF_CHANNEL_RGBSDA_DEPTH=14,exports.KHR_DF_CHANNEL_RGBSDA_GREEN=1,exports.KHR_DF_CHANNEL_RGBSDA_RED=0,exports.KHR_DF_CHANNEL_RGBSDA_STENCIL=13,exports.KHR_DF_FLAG_ALPHA_PREMULTIPLIED=1,exports.KHR_DF_FLAG_ALPHA_STRAIGHT=0,exports.KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT=0,exports.KHR_DF_MODEL_ASTC=162,exports.KHR_DF_MODEL_ETC1=160,exports.KHR_DF_MODEL_ETC1S=163,exports.KHR_DF_MODEL_ETC2=161,exports.KHR_DF_MODEL_RGBSDA=1,exports.KHR_DF_MODEL_UNSPECIFIED=0,exports.KHR_DF_PRIMARIES_ACES=6,exports.KHR_DF_PRIMARIES_ACESCC=7,exports.KHR_DF_PRIMARIES_ADOBERGB=11,exports.KHR_DF_PRIMARIES_BT2020=4,exports.KHR_DF_PRIMARIES_BT601_EBU=2,exports.KHR_DF_PRIMARIES_BT601_SMPTE=3,exports.KHR_DF_PRIMARIES_BT709=1,exports.KHR_DF_PRIMARIES_CIEXYZ=5,exports.KHR_DF_PRIMARIES_DISPLAYP3=10,exports.KHR_DF_PRIMARIES_NTSC1953=8,exports.KHR_DF_PRIMARIES_PAL525=9,exports.KHR_DF_PRIMARIES_UNSPECIFIED=0,exports.KHR_DF_SAMPLE_DATATYPE_EXPONENT=32,exports.KHR_DF_SAMPLE_DATATYPE_FLOAT=128,exports.KHR_DF_SAMPLE_DATATYPE_LINEAR=16,exports.KHR_DF_SAMPLE_DATATYPE_SIGNED=64,exports.KHR_DF_TRANSFER_ACESCC=16,exports.KHR_DF_TRANSFER_ACESCCT=17,exports.KHR_DF_TRANSFER_ADOBERGB=18,exports.KHR_DF_TRANSFER_BT1886=7,exports.KHR_DF_TRANSFER_DCIP3=12,exports.KHR_DF_TRANSFER_HLG_EOTF=9,exports.KHR_DF_TRANSFER_HLG_OETF=8,exports.KHR_DF_TRANSFER_ITU=3,exports.KHR_DF_TRANSFER_LINEAR=1,exports.KHR_DF_TRANSFER_NTSC=4,exports.KHR_DF_TRANSFER_PAL625_EOTF=14,exports.KHR_DF_TRANSFER_PAL_OETF=13,exports.KHR_DF_TRANSFER_PQ_EOTF=10,exports.KHR_DF_TRANSFER_PQ_OETF=11,exports.KHR_DF_TRANSFER_SLOG=5,exports.KHR_DF_TRANSFER_SLOG2=6,exports.KHR_DF_TRANSFER_SRGB=2,exports.KHR_DF_TRANSFER_ST240=15,exports.KHR_DF_TRANSFER_UNSPECIFIED=0,exports.KHR_DF_VENDORID_KHRONOS=0,exports.KHR_DF_VERSION=2,exports.KHR_SUPERCOMPRESSION_BASISLZ=1,exports.KHR_SUPERCOMPRESSION_NONE=0,exports.KHR_SUPERCOMPRESSION_ZLIB=3,exports.KHR_SUPERCOMPRESSION_ZSTD=2,exports.KTX2Container=_,exports.VK_FORMAT_A1R5G5B5_UNORM_PACK16=8,exports.VK_FORMAT_A2B10G10R10_SINT_PACK32=69,exports.VK_FORMAT_A2B10G10R10_SNORM_PACK32=65,exports.VK_FORMAT_A2B10G10R10_UINT_PACK32=68,exports.VK_FORMAT_A2B10G10R10_UNORM_PACK32=64,exports.VK_FORMAT_A2R10G10B10_SINT_PACK32=63,exports.VK_FORMAT_A2R10G10B10_SNORM_PACK32=59,exports.VK_FORMAT_A2R10G10B10_UINT_PACK32=62,exports.VK_FORMAT_A2R10G10B10_UNORM_PACK32=58,exports.VK_FORMAT_A4B4G4R4_UNORM_PACK16_EXT=1000340001,exports.VK_FORMAT_A4R4G4B4_UNORM_PACK16_EXT=100034e4,exports.VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK_EXT=1000066011,exports.VK_FORMAT_ASTC_10x10_SRGB_BLOCK=180,exports.VK_FORMAT_ASTC_10x10_UNORM_BLOCK=179,exports.VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK_EXT=1000066008,exports.VK_FORMAT_ASTC_10x5_SRGB_BLOCK=174,exports.VK_FORMAT_ASTC_10x5_UNORM_BLOCK=173,exports.VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK_EXT=1000066009,exports.VK_FORMAT_ASTC_10x6_SRGB_BLOCK=176,exports.VK_FORMAT_ASTC_10x6_UNORM_BLOCK=175,exports.VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK_EXT=1000066010,exports.VK_FORMAT_ASTC_10x8_SRGB_BLOCK=178,exports.VK_FORMAT_ASTC_10x8_UNORM_BLOCK=177,exports.VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK_EXT=1000066012,exports.VK_FORMAT_ASTC_12x10_SRGB_BLOCK=182,exports.VK_FORMAT_ASTC_12x10_UNORM_BLOCK=181,exports.VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK_EXT=1000066013,exports.VK_FORMAT_ASTC_12x12_SRGB_BLOCK=184,exports.VK_FORMAT_ASTC_12x12_UNORM_BLOCK=183,exports.VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK_EXT=1000066e3,exports.VK_FORMAT_ASTC_4x4_SRGB_BLOCK=158,exports.VK_FORMAT_ASTC_4x4_UNORM_BLOCK=157,exports.VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK_EXT=1000066001,exports.VK_FORMAT_ASTC_5x4_SRGB_BLOCK=160,exports.VK_FORMAT_ASTC_5x4_UNORM_BLOCK=159,exports.VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK_EXT=1000066002,exports.VK_FORMAT_ASTC_5x5_SRGB_BLOCK=162,exports.VK_FORMAT_ASTC_5x5_UNORM_BLOCK=161,exports.VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK_EXT=1000066003,exports.VK_FORMAT_ASTC_6x5_SRGB_BLOCK=164,exports.VK_FORMAT_ASTC_6x5_UNORM_BLOCK=163,exports.VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK_EXT=1000066004,exports.VK_FORMAT_ASTC_6x6_SRGB_BLOCK=166,exports.VK_FORMAT_ASTC_6x6_UNORM_BLOCK=165,exports.VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK_EXT=1000066005,exports.VK_FORMAT_ASTC_8x5_SRGB_BLOCK=168,exports.VK_FORMAT_ASTC_8x5_UNORM_BLOCK=167,exports.VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK_EXT=1000066006,exports.VK_FORMAT_ASTC_8x6_SRGB_BLOCK=170,exports.VK_FORMAT_ASTC_8x6_UNORM_BLOCK=169,exports.VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK_EXT=1000066007,exports.VK_FORMAT_ASTC_8x8_SRGB_BLOCK=172,exports.VK_FORMAT_ASTC_8x8_UNORM_BLOCK=171,exports.VK_FORMAT_B10G11R11_UFLOAT_PACK32=122,exports.VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16=1000156011,exports.VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16=1000156021,exports.VK_FORMAT_B4G4R4A4_UNORM_PACK16=3,exports.VK_FORMAT_B5G5R5A1_UNORM_PACK16=7,exports.VK_FORMAT_B5G6R5_UNORM_PACK16=5,exports.VK_FORMAT_B8G8R8A8_SINT=49,exports.VK_FORMAT_B8G8R8A8_SNORM=45,exports.VK_FORMAT_B8G8R8A8_SRGB=50,exports.VK_FORMAT_B8G8R8A8_UINT=48,exports.VK_FORMAT_B8G8R8A8_UNORM=44,exports.VK_FORMAT_B8G8R8_SINT=35,exports.VK_FORMAT_B8G8R8_SNORM=31,exports.VK_FORMAT_B8G8R8_SRGB=36,exports.VK_FORMAT_B8G8R8_UINT=34,exports.VK_FORMAT_B8G8R8_UNORM=30,exports.VK_FORMAT_BC1_RGBA_SRGB_BLOCK=134,exports.VK_FORMAT_BC1_RGBA_UNORM_BLOCK=133,exports.VK_FORMAT_BC1_RGB_SRGB_BLOCK=132,exports.VK_FORMAT_BC1_RGB_UNORM_BLOCK=131,exports.VK_FORMAT_BC2_SRGB_BLOCK=136,exports.VK_FORMAT_BC2_UNORM_BLOCK=135,exports.VK_FORMAT_BC3_SRGB_BLOCK=138,exports.VK_FORMAT_BC3_UNORM_BLOCK=137,exports.VK_FORMAT_BC4_SNORM_BLOCK=140,exports.VK_FORMAT_BC4_UNORM_BLOCK=139,exports.VK_FORMAT_BC5_SNORM_BLOCK=142,exports.VK_FORMAT_BC5_UNORM_BLOCK=141,exports.VK_FORMAT_BC6H_SFLOAT_BLOCK=144,exports.VK_FORMAT_BC6H_UFLOAT_BLOCK=143,exports.VK_FORMAT_BC7_SRGB_BLOCK=146,exports.VK_FORMAT_BC7_UNORM_BLOCK=145,exports.VK_FORMAT_D16_UNORM=124,exports.VK_FORMAT_D16_UNORM_S8_UINT=128,exports.VK_FORMAT_D24_UNORM_S8_UINT=129,exports.VK_FORMAT_D32_SFLOAT=126,exports.VK_FORMAT_D32_SFLOAT_S8_UINT=130,exports.VK_FORMAT_E5B9G9R9_UFLOAT_PACK32=123,exports.VK_FORMAT_EAC_R11G11_SNORM_BLOCK=156,exports.VK_FORMAT_EAC_R11G11_UNORM_BLOCK=155,exports.VK_FORMAT_EAC_R11_SNORM_BLOCK=154,exports.VK_FORMAT_EAC_R11_UNORM_BLOCK=153,exports.VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK=150,exports.VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK=149,exports.VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK=152,exports.VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK=151,exports.VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK=148,exports.VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK=147,exports.VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16=1000156010,exports.VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16=1000156020,exports.VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG=1000054004,exports.VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG=1000054e3,exports.VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG=1000054005,exports.VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG=1000054001,exports.VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG=1000054006,exports.VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG=1000054002,exports.VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG=1000054007,exports.VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG=1000054003,exports.VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16=1000156009,exports.VK_FORMAT_R10X6G10X6_UNORM_2PACK16=1000156008,exports.VK_FORMAT_R10X6_UNORM_PACK16=1000156007,exports.VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16=1000156019,exports.VK_FORMAT_R12X4G12X4_UNORM_2PACK16=1000156018,exports.VK_FORMAT_R12X4_UNORM_PACK16=1000156017,exports.VK_FORMAT_R16G16B16A16_SFLOAT=97,exports.VK_FORMAT_R16G16B16A16_SINT=96,exports.VK_FORMAT_R16G16B16A16_SNORM=92,exports.VK_FORMAT_R16G16B16A16_UINT=95,exports.VK_FORMAT_R16G16B16A16_UNORM=91,exports.VK_FORMAT_R16G16B16_SFLOAT=90,exports.VK_FORMAT_R16G16B16_SINT=89,exports.VK_FORMAT_R16G16B16_SNORM=85,exports.VK_FORMAT_R16G16B16_UINT=88,exports.VK_FORMAT_R16G16B16_UNORM=84,exports.VK_FORMAT_R16G16_SFLOAT=83,exports.VK_FORMAT_R16G16_SINT=82,exports.VK_FORMAT_R16G16_SNORM=78,exports.VK_FORMAT_R16G16_UINT=81,exports.VK_FORMAT_R16G16_UNORM=77,exports.VK_FORMAT_R16_SFLOAT=76,exports.VK_FORMAT_R16_SINT=75,exports.VK_FORMAT_R16_SNORM=71,exports.VK_FORMAT_R16_UINT=74,exports.VK_FORMAT_R16_UNORM=70,exports.VK_FORMAT_R32G32B32A32_SFLOAT=109,exports.VK_FORMAT_R32G32B32A32_SINT=108,exports.VK_FORMAT_R32G32B32A32_UINT=107,exports.VK_FORMAT_R32G32B32_SFLOAT=106,exports.VK_FORMAT_R32G32B32_SINT=105,exports.VK_FORMAT_R32G32B32_UINT=104,exports.VK_FORMAT_R32G32_SFLOAT=103,exports.VK_FORMAT_R32G32_SINT=102,exports.VK_FORMAT_R32G32_UINT=101,exports.VK_FORMAT_R32_SFLOAT=100,exports.VK_FORMAT_R32_SINT=99,exports.VK_FORMAT_R32_UINT=98,exports.VK_FORMAT_R4G4B4A4_UNORM_PACK16=2,exports.VK_FORMAT_R4G4_UNORM_PACK8=1,exports.VK_FORMAT_R5G5B5A1_UNORM_PACK16=6,exports.VK_FORMAT_R5G6B5_UNORM_PACK16=4,exports.VK_FORMAT_R64G64B64A64_SFLOAT=121,exports.VK_FORMAT_R64G64B64A64_SINT=120,exports.VK_FORMAT_R64G64B64A64_UINT=119,exports.VK_FORMAT_R64G64B64_SFLOAT=118,exports.VK_FORMAT_R64G64B64_SINT=117,exports.VK_FORMAT_R64G64B64_UINT=116,exports.VK_FORMAT_R64G64_SFLOAT=115,exports.VK_FORMAT_R64G64_SINT=114,exports.VK_FORMAT_R64G64_UINT=113,exports.VK_FORMAT_R64_SFLOAT=112,exports.VK_FORMAT_R64_SINT=111,exports.VK_FORMAT_R64_UINT=110,exports.VK_FORMAT_R8G8B8A8_SINT=42,exports.VK_FORMAT_R8G8B8A8_SNORM=38,exports.VK_FORMAT_R8G8B8A8_SRGB=43,exports.VK_FORMAT_R8G8B8A8_UINT=41,exports.VK_FORMAT_R8G8B8A8_UNORM=37,exports.VK_FORMAT_R8G8B8_SINT=28,exports.VK_FORMAT_R8G8B8_SNORM=24,exports.VK_FORMAT_R8G8B8_SRGB=29,exports.VK_FORMAT_R8G8B8_UINT=27,exports.VK_FORMAT_R8G8B8_UNORM=23,exports.VK_FORMAT_R8G8_SINT=21,exports.VK_FORMAT_R8G8_SNORM=17,exports.VK_FORMAT_R8G8_SRGB=22,exports.VK_FORMAT_R8G8_UINT=20,exports.VK_FORMAT_R8G8_UNORM=16,exports.VK_FORMAT_R8_SINT=14,exports.VK_FORMAT_R8_SNORM=10,exports.VK_FORMAT_R8_SRGB=15,exports.VK_FORMAT_R8_UINT=13,exports.VK_FORMAT_R8_UNORM=9,exports.VK_FORMAT_S8_UINT=127,exports.VK_FORMAT_UNDEFINED=0,exports.VK_FORMAT_X8_D24_UNORM_PACK32=125,exports.read=function(e){var R=new Uint8Array(e.buffer,e.byteOffset,r.length);if(R[0]!==r[0]||R[1]!==r[1]||R[2]!==r[2]||R[3]!==r[3]||R[4]!==r[4]||R[5]!==r[5]||R[6]!==r[6]||R[7]!==r[7]||R[8]!==r[8]||R[9]!==r[9]||R[10]!==r[10]||R[11]!==r[11])throw new Error("Missing KTX 2.0 identifier.");var s=new _,n=17*Uint32Array.BYTES_PER_ELEMENT,o=new t(e,r.length,n,!0);s.vkFormat=o._nextUint32(),s.typeSize=o._nextUint32(),s.pixelWidth=o._nextUint32(),s.pixelHeight=o._nextUint32(),s.pixelDepth=o._nextUint32(),s.layerCount=o._nextUint32(),s.faceCount=o._nextUint32();var O=o._nextUint32();s.supercompressionScheme=o._nextUint32();for(var T=o._nextUint32(),i=o._nextUint32(),x=o._nextUint32(),p=o._nextUint32(),K=o._nextUint64(),a=o._nextUint64(),F=new t(e,r.length+n,3*O*8,!0),M=0;M<O;M++)s.levels.push({levelData:new Uint8Array(e.buffer,e.byteOffset+F._nextUint64(),F._nextUint64()),uncompressedByteLength:F._nextUint64()});for(var B=new t(e,T,i,!0),S={vendorId:B._skip(4)._nextUint16(),descriptorType:B._nextUint16(),versionNumber:B._nextUint16(),descriptorBlockSize:B._nextUint16(),colorModel:B._nextUint8(),colorPrimaries:B._nextUint8(),transferFunction:B._nextUint8(),flags:B._nextUint8(),texelBlockDimension:[B._nextUint8(),B._nextUint8(),B._nextUint8(),B._nextUint8()],bytesPlane:[B._nextUint8(),B._nextUint8(),B._nextUint8(),B._nextUint8(),B._nextUint8(),B._nextUint8(),B._nextUint8(),B._nextUint8()],samples:[]},U=(S.descriptorBlockSize/4-6)/4,C=0;C<U;C++){var V={bitOffset:B._nextUint16(),bitLength:B._nextUint8(),channelType:B._nextUint8(),samplePosition:[B._nextUint8(),B._nextUint8(),B._nextUint8(),B._nextUint8()],sampleLower:-Infinity,sampleUpper:Infinity};64&V.channelType?(V.sampleLower=B._nextInt32(),V.sampleUpper=B._nextInt32()):(V.sampleLower=B._nextUint32(),V.sampleUpper=B._nextUint32()),S.samples[C]=V}s.dataFormatDescriptor.length=0,s.dataFormatDescriptor.push(S);for(var l=new t(e,x,p,!0);l._offset<p;){var N=l._nextUint32(),L=l._scan(N),f=A(L),G=l._scan(N-L.byteLength);s.keyValue[f]=f.match(/^ktx/i)?A(G):G,l._offset%4&&l._skip(4-l._offset%4)}if(a<=0)return s;for(var D=new t(e,K,a,!0),E=D._nextUint16(),h=D._nextUint16(),I=D._nextUint32(),P=D._nextUint32(),c=D._nextUint32(),y=D._nextUint32(),u=[],g=0;g<O;g++)u.push({imageFlags:D._nextUint32(),rgbSliceByteOffset:D._nextUint32(),rgbSliceByteLength:D._nextUint32(),alphaSliceByteOffset:D._nextUint32(),alphaSliceByteLength:D._nextUint32()});var b=K+D._offset,d=b+I,m=d+P,v=m+c,H=new Uint8Array(e.buffer,e.byteOffset+b,I),w=new Uint8Array(e.buffer,e.byteOffset+d,P),X=new Uint8Array(e.buffer,e.byteOffset+m,c),k=new Uint8Array(e.buffer,e.byteOffset+v,y);return s.globalData={endpointCount:E,selectorCount:h,imageDescs:u,endpointsData:H,selectorsData:w,tablesData:X,extendedData:k},s},exports.write=function(_,t){void 0===t&&(t={}),t=R({},T,t);var s=new ArrayBuffer(0);if(_.globalData){var n=new ArrayBuffer(20+5*_.globalData.imageDescs.length*4),A=new DataView(n);A.setUint16(0,_.globalData.endpointCount,!0),A.setUint16(2,_.globalData.selectorCount,!0),A.setUint32(4,_.globalData.endpointsData.byteLength,!0),A.setUint32(8,_.globalData.selectorsData.byteLength,!0),A.setUint32(12,_.globalData.tablesData.byteLength,!0),A.setUint32(16,_.globalData.extendedData.byteLength,!0);for(var i=0;i<_.globalData.imageDescs.length;i++){var x=_.globalData.imageDescs[i];A.setUint32(20+5*i*4+0,x.imageFlags,!0),A.setUint32(20+5*i*4+4,x.rgbSliceByteOffset,!0),A.setUint32(20+5*i*4+8,x.rgbSliceByteLength,!0),A.setUint32(20+5*i*4+12,x.alphaSliceByteOffset,!0),A.setUint32(20+5*i*4+16,x.alphaSliceByteLength,!0)}s=O([n,_.globalData.endpointsData,_.globalData.selectorsData,_.globalData.tablesData,_.globalData.extendedData])}var p=[],K=_.keyValue;for(var a in t.keepWriter||(K=R({},_.keyValue,{KTXwriter:"KTX-Parse v0.3.0"})),K){var F=K[a],M=o(a),B="string"==typeof F?o(F):F,S=M.byteLength+1+B.byteLength+1,U=S%4?4-S%4:0;p.push(O([new Uint32Array([S]),M,e,B,e,new Uint8Array(U).fill(0)]))}var C=O(p);if(1!==_.dataFormatDescriptor.length||0!==_.dataFormatDescriptor[0].descriptorType)throw new Error("Only BASICFORMAT Data Format Descriptor output supported.");var V=_.dataFormatDescriptor[0],l=new ArrayBuffer(28+16*V.samples.length),N=new DataView(l),L=24+16*V.samples.length;if(N.setUint32(0,l.byteLength,!0),N.setUint16(4,V.vendorId,!0),N.setUint16(6,V.descriptorType,!0),N.setUint16(8,V.versionNumber,!0),N.setUint16(10,L,!0),N.setUint8(12,V.colorModel),N.setUint8(13,V.colorPrimaries),N.setUint8(14,V.transferFunction),N.setUint8(15,V.flags),!Array.isArray(V.texelBlockDimension))throw new Error("texelBlockDimension is now an array. For dimensionality `d`, set `d - 1`.");N.setUint8(16,V.texelBlockDimension[0]),N.setUint8(17,V.texelBlockDimension[1]),N.setUint8(18,V.texelBlockDimension[2]),N.setUint8(19,V.texelBlockDimension[3]);for(var f=0;f<8;f++)N.setUint8(20+f,V.bytesPlane[f]);for(var G=0;G<V.samples.length;G++){var D=V.samples[G],E=28+16*G;if(D.channelID)throw new Error("channelID has been renamed to channelType.");N.setUint16(E+0,D.bitOffset,!0),N.setUint8(E+2,D.bitLength),N.setUint8(E+3,D.channelType),N.setUint8(E+4,D.samplePosition[0]),N.setUint8(E+5,D.samplePosition[1]),N.setUint8(E+6,D.samplePosition[2]),N.setUint8(E+7,D.samplePosition[3]),64&D.channelType?(N.setInt32(E+8,D.sampleLower,!0),N.setInt32(E+12,D.sampleUpper,!0)):(N.setUint32(E+8,D.sampleLower,!0),N.setUint32(E+12,D.sampleUpper,!0))}var h=r.length+68+3*_.levels.length*8,I=h+l.byteLength,P=s.byteLength>0?I+C.byteLength:0;P%8&&(P+=8-P%8);for(var c=[],y=new DataView(new ArrayBuffer(3*_.levels.length*8)),u=(P||I+C.byteLength)+s.byteLength,g=0;g<_.levels.length;g++){var b=_.levels[g];c.push(b.levelData),y.setBigUint64(24*g+0,BigInt(u),!0),y.setBigUint64(24*g+8,BigInt(b.levelData.byteLength),!0),y.setBigUint64(24*g+16,BigInt(b.uncompressedByteLength),!0),u+=b.levelData.byteLength}var d=new ArrayBuffer(68),m=new DataView(d);return m.setUint32(0,_.vkFormat,!0),m.setUint32(4,_.typeSize,!0),m.setUint32(8,_.pixelWidth,!0),m.setUint32(12,_.pixelHeight,!0),m.setUint32(16,_.pixelDepth,!0),m.setUint32(20,_.layerCount,!0),m.setUint32(24,_.faceCount,!0),m.setUint32(28,_.levels.length,!0),m.setUint32(32,_.supercompressionScheme,!0),m.setUint32(36,h,!0),m.setUint32(40,l.byteLength,!0),m.setUint32(44,I,!0),m.setUint32(48,C.byteLength,!0),m.setBigUint64(52,BigInt(s.byteLength>0?P:0),!0),m.setBigUint64(60,BigInt(s.byteLength),!0),new Uint8Array(O([new Uint8Array(r).buffer,d,y.buffer,l,C,P>0?new ArrayBuffer(P-(I+C.byteLength)):new ArrayBuffer(0),s].concat(c)))}; | ||
//# sourceMappingURL=ktx-parse.js.map |
@@ -1,2 +0,2 @@ | ||
const t=new Uint8Array([0]),e=[171,75,84,88,32,50,48,187,13,10,26,10];var n,i,s,a,r,o,l,f;!function(t){t[t.NONE=0]="NONE",t[t.BASISLZ=1]="BASISLZ",t[t.ZSTD=2]="ZSTD",t[t.ZLIB=3]="ZLIB"}(n||(n={})),function(t){t[t.BASICFORMAT=0]="BASICFORMAT"}(i||(i={})),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.ETC1S=163]="ETC1S",t[t.UASTC=166]="UASTC"}(s||(s={})),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.SRGB=1]="SRGB"}(a||(a={})),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.LINEAR=1]="LINEAR",t[t.SRGB=2]="SRGB",t[t.ITU=3]="ITU",t[t.NTSC=4]="NTSC",t[t.SLOG=5]="SLOG",t[t.SLOG2=6]="SLOG2"}(r||(r={})),function(t){t[t.ALPHA_STRAIGHT=0]="ALPHA_STRAIGHT",t[t.ALPHA_PREMULTIPLIED=1]="ALPHA_PREMULTIPLIED"}(o||(o={})),function(t){t[t.RGB=0]="RGB",t[t.RRR=3]="RRR",t[t.GGG=4]="GGG",t[t.AAA=15]="AAA"}(l||(l={})),function(t){t[t.RGB=0]="RGB",t[t.RGBA=3]="RGBA",t[t.RRR=4]="RRR",t[t.RRRG=5]="RRRG"}(f||(f={}));class U{constructor(){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=n.NONE,this.levels=[],this.dataFormatDescriptor=[{vendorId:0,descriptorType:i.BASICFORMAT,versionNumber:2,descriptorBlockSize:40,colorModel:s.UNSPECIFIED,colorPrimaries:a.SRGB,transferFunction:a.SRGB,flags:o.ALPHA_STRAIGHT,texelBlockDimension:{x:4,y:4,z:1,w:1},bytesPlane:[],samples:[]}],this.keyValue={},this.globalData=null}}class c{constructor(t,e,n,i){this._dataView=new DataView(t.buffer,t.byteOffset+e,n),this._littleEndian=i,this._offset=0}_nextUint8(){const t=this._dataView.getUint8(this._offset);return this._offset+=1,t}_nextUint16(){const t=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,t}_nextUint32(){const t=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,t}_nextUint64(){const t=this._dataView.getUint32(this._offset,this._littleEndian)+2**32*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,t}_skip(t){return this._offset+=t,this}_scan(t,e=0){const n=this._offset;let i=0;for(;this._dataView.getUint8(this._offset)!==e&&i<t;)i++,this._offset++;return i<t&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+n,i)}}function h(t){return"undefined"!=typeof TextEncoder?(new TextEncoder).encode(t):Buffer.from(t)}function _(t){return"undefined"!=typeof TextDecoder?(new TextDecoder).decode(t):Buffer.from(t).toString("utf8")}function g(t){let e=0;for(const n of t)e+=n.byteLength;const n=new Uint8Array(e);let i=0;for(const e of t)n.set(new Uint8Array(e),i),i+=e.byteLength;return n}function p(t){const n=new Uint8Array(t.buffer,t.byteOffset,e.length);if(n[0]!==e[0]||n[1]!==e[1]||n[2]!==e[2]||n[3]!==e[3]||n[4]!==e[4]||n[5]!==e[5]||n[6]!==e[6]||n[7]!==e[7]||n[8]!==e[8]||n[9]!==e[9]||n[10]!==e[10]||n[11]!==e[11])throw new Error("Missing KTX 2.0 identifier.");const i=new U,s=17*Uint32Array.BYTES_PER_ELEMENT,a=new c(t,e.length,s,!0);i.vkFormat=a._nextUint32(),i.typeSize=a._nextUint32(),i.pixelWidth=a._nextUint32(),i.pixelHeight=a._nextUint32(),i.pixelDepth=a._nextUint32(),i.layerCount=a._nextUint32(),i.faceCount=a._nextUint32();const r=a._nextUint32();i.supercompressionScheme=a._nextUint32();const o=a._nextUint32(),l=a._nextUint32(),f=a._nextUint32(),h=a._nextUint32(),g=a._nextUint64(),p=a._nextUint64(),x=new c(t,e.length+s,3*r*8,!0);for(let e=0;e<r;e++)i.levels.push({levelData:new Uint8Array(t.buffer,t.byteOffset+x._nextUint64(),x._nextUint64()),uncompressedByteLength:x._nextUint64()});const u=new c(t,o,l,!0),y={vendorId:u._skip(4)._nextUint16(),descriptorType:u._nextUint16(),versionNumber:u._nextUint16(),descriptorBlockSize:u._nextUint16(),colorModel:u._nextUint8(),colorPrimaries:u._nextUint8(),transferFunction:u._nextUint8(),flags:u._nextUint8(),texelBlockDimension:{x:u._nextUint8()+1,y:u._nextUint8()+1,z:u._nextUint8()+1,w:u._nextUint8()+1},bytesPlane:[u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8()],samples:[]},D=(y.descriptorBlockSize/4-6)/4;for(let t=0;t<D;t++)y.samples[t]={bitOffset:u._nextUint16(),bitLength:u._nextUint8(),channelID:u._nextUint8(),samplePosition:[u._nextUint8(),u._nextUint8(),u._nextUint8(),u._nextUint8()],sampleLower:u._nextUint32(),sampleUpper:u._nextUint32()};i.dataFormatDescriptor.length=0,i.dataFormatDescriptor.push(y);const b=new c(t,f,h,!0);for(;b._offset<h;){const t=b._nextUint32(),e=b._scan(t),n=_(e),s=b._scan(t-e.byteLength);i.keyValue[n]=n.match(/^ktx/i)?_(s):s,b._offset%4&&b._skip(4-b._offset%4)}if(p<=0)return i;const d=new c(t,g,p,!0),B=d._nextUint16(),w=d._nextUint16(),A=d._nextUint32(),S=d._nextUint32(),m=d._nextUint32(),L=d._nextUint32(),I=[];for(let t=0;t<r;t++)I.push({imageFlags:d._nextUint32(),rgbSliceByteOffset:d._nextUint32(),rgbSliceByteLength:d._nextUint32(),alphaSliceByteOffset:d._nextUint32(),alphaSliceByteLength:d._nextUint32()});const R=g+d._offset,E=R+A,T=E+S,O=T+m,P=new Uint8Array(t.buffer,t.byteOffset+R,A),C=new Uint8Array(t.buffer,t.byteOffset+E,S),F=new Uint8Array(t.buffer,t.byteOffset+T,m),G=new Uint8Array(t.buffer,t.byteOffset+O,L);return i.globalData={endpointCount:B,selectorCount:w,imageDescs:I,endpointsData:P,selectorsData:C,tablesData:F,extendedData:G},i}function x(){return(x=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}const u={keepWriter:!1};function y(n,s={}){s=x({},u,s);let a=new ArrayBuffer(0);if(n.globalData){const t=new ArrayBuffer(20+5*n.globalData.imageDescs.length*4),e=new DataView(t);e.setUint16(0,n.globalData.endpointCount,!0),e.setUint16(2,n.globalData.selectorCount,!0),e.setUint32(4,n.globalData.endpointsData.byteLength,!0),e.setUint32(8,n.globalData.selectorsData.byteLength,!0),e.setUint32(12,n.globalData.tablesData.byteLength,!0),e.setUint32(16,n.globalData.extendedData.byteLength,!0);for(let t=0;t<n.globalData.imageDescs.length;t++){const i=n.globalData.imageDescs[t];e.setUint32(20+5*t*4+0,i.imageFlags,!0),e.setUint32(20+5*t*4+4,i.rgbSliceByteOffset,!0),e.setUint32(20+5*t*4+8,i.rgbSliceByteLength,!0),e.setUint32(20+5*t*4+12,i.alphaSliceByteOffset,!0),e.setUint32(20+5*t*4+16,i.alphaSliceByteLength,!0)}a=g([t,n.globalData.endpointsData,n.globalData.selectorsData,n.globalData.tablesData,n.globalData.extendedData])}const r=[];let o=n.keyValue;s.keepWriter||(o=x({},n.keyValue,{KTXwriter:"KTX-Parse v0.2.2"}));for(const e in o){const n=o[e],i=h(e),s="string"==typeof n?h(n):n,a=i.byteLength+1+s.byteLength+1,l=a%4?4-a%4:0;r.push(g([new Uint32Array([a]),i,t,s,t,new Uint8Array(l).fill(0)]))}const l=g(r);if(1!==n.dataFormatDescriptor.length||n.dataFormatDescriptor[0].descriptorType!==i.BASICFORMAT)throw new Error("Only BASICFORMAT Data Format Descriptor output supported.");const f=n.dataFormatDescriptor[0],U=new ArrayBuffer(28+16*f.samples.length),c=new DataView(U);c.setUint32(0,U.byteLength,!0),c.setUint16(4,f.vendorId,!0),c.setUint16(6,f.descriptorType,!0),c.setUint16(8,f.versionNumber,!0),c.setUint16(10,f.descriptorBlockSize,!0),c.setUint8(12,f.colorModel),c.setUint8(13,f.colorPrimaries),c.setUint8(14,f.transferFunction),c.setUint8(15,f.flags),c.setUint8(16,f.texelBlockDimension.x-1),c.setUint8(17,f.texelBlockDimension.y-1),c.setUint8(18,f.texelBlockDimension.z-1),c.setUint8(19,f.texelBlockDimension.w-1);for(let t=0;t<8;t++)c.setUint8(20+t,f.bytesPlane[t]);for(let t=0;t<f.samples.length;t++){const e=f.samples[t],n=28+16*t;c.setUint16(n+0,e.bitOffset,!0),c.setUint8(n+2,e.bitLength),c.setUint8(n+3,e.channelID),c.setUint8(n+4,e.samplePosition[0]),c.setUint8(n+5,e.samplePosition[1]),c.setUint8(n+6,e.samplePosition[2]),c.setUint8(n+7,e.samplePosition[3]),c.setUint32(n+8,e.sampleLower,!0),c.setUint32(n+12,e.sampleUpper,!0)}const _=e.length+68+3*n.levels.length*8,p=_+U.byteLength;let y=p+l.byteLength;y%8&&(y+=8-y%8);const D=[],b=new DataView(new ArrayBuffer(3*n.levels.length*8));let d=y+a.byteLength;for(let t=0;t<n.levels.length;t++){const e=n.levels[t];D.push(e.levelData),b.setBigUint64(24*t+0,BigInt(d),!0),b.setBigUint64(24*t+8,BigInt(e.levelData.byteLength),!0),b.setBigUint64(24*t+16,BigInt(e.uncompressedByteLength),!0),d+=e.levelData.byteLength}const B=new ArrayBuffer(68),w=new DataView(B);return w.setUint32(0,n.vkFormat,!0),w.setUint32(4,n.typeSize,!0),w.setUint32(8,n.pixelWidth,!0),w.setUint32(12,n.pixelHeight,!0),w.setUint32(16,n.pixelDepth,!0),w.setUint32(20,n.layerCount,!0),w.setUint32(24,n.faceCount,!0),w.setUint32(28,n.levels.length,!0),w.setUint32(32,n.supercompressionScheme,!0),w.setUint32(36,_,!0),w.setUint32(40,U.byteLength,!0),w.setUint32(44,p,!0),w.setUint32(48,l.byteLength,!0),w.setBigUint64(52,BigInt(y),!0),w.setBigUint64(60,BigInt(a.byteLength),!0),new Uint8Array(g([new Uint8Array(e).buffer,B,b.buffer,U,l,new ArrayBuffer(y-(p+l.byteLength)),a,...D]))}export{l as KTX2ChannelETC1S,f as KTX2ChannelUASTC,U as KTX2Container,i as KTX2DescriptorType,o as KTX2Flags,s as KTX2Model,a as KTX2Primaries,n as KTX2SupercompressionScheme,r as KTX2Transfer,p as read,y as write}; | ||
const t=0,e=1,n=2,i=3,s=0,a=0,r=2,o=0,l=1,f=160,U=161,c=162,h=163,_=0,p=1,g=0,y=1,x=2,u=3,b=4,d=5,m=6,w=7,D=8,B=9,L=10,A=11,k=12,v=13,S=14,I=15,O=16,T=17,V=18,E=0,F=1,P=2,C=3,z=4,M=5,W=6,N=7,H=8,K=9,X=10,j=11,R=0,Y=1,q=2,G=13,J=14,Q=15,Z=128,$=64,tt=32,et=16,nt=0,it=1,st=2,at=3,rt=4,ot=5,lt=6,ft=7,Ut=8,ct=9,ht=10,_t=13,pt=14,gt=15,yt=16,xt=17,ut=20,bt=21,dt=22,mt=23,wt=24,Dt=27,Bt=28,Lt=29,At=30,kt=31,vt=34,St=35,It=36,Ot=37,Tt=38,Vt=41,Et=42,Ft=43,Pt=44,Ct=45,zt=48,Mt=49,Wt=50,Nt=58,Ht=59,Kt=62,Xt=63,jt=64,Rt=65,Yt=68,qt=69,Gt=70,Jt=71,Qt=74,Zt=75,$t=76,te=77,ee=78,ne=81,ie=82,se=83,ae=84,re=85,oe=88,le=89,fe=90,Ue=91,ce=92,he=95,_e=96,pe=97,ge=98,ye=99,xe=100,ue=101,be=102,de=103,me=104,we=105,De=106,Be=107,Le=108,Ae=109,ke=110,ve=111,Se=112,Ie=113,Oe=114,Te=115,Ve=116,Ee=117,Fe=118,Pe=119,Ce=120,ze=121,Me=122,We=123,Ne=124,He=125,Ke=126,Xe=127,je=128,Re=129,Ye=130,qe=131,Ge=132,Je=133,Qe=134,Ze=135,$e=136,tn=137,en=138,nn=139,sn=140,an=141,rn=142,on=143,ln=144,fn=145,Un=146,cn=147,hn=148,_n=149,pn=150,gn=151,yn=152,xn=153,un=154,bn=155,dn=156,mn=157,wn=158,Dn=159,Bn=160,Ln=161,An=162,kn=163,vn=164,Sn=165,In=166,On=167,Tn=168,Vn=169,En=170,Fn=171,Pn=172,Cn=173,zn=174,Mn=175,Wn=176,Nn=177,Hn=178,Kn=179,Xn=180,jn=181,Rn=182,Yn=183,qn=184,Gn=1000156007,Jn=1000156008,Qn=1000156009,Zn=1000156010,$n=1000156011,ti=1000156017,ei=1000156018,ni=1000156019,ii=1000156020,si=1000156021,ai=1000054e3,ri=1000054001,oi=1000054002,li=1000054003,fi=1000054004,Ui=1000054005,ci=1000054006,hi=1000054007,_i=1000066e3,pi=1000066001,gi=1000066002,yi=1000066003,xi=1000066004,ui=1000066005,bi=1000066006,di=1000066007,mi=1000066008,wi=1000066009,Di=1000066010,Bi=1000066011,Li=1000066012,Ai=1000066013,ki=100034e4,vi=1000340001;class Si{constructor(){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=0,this.levels=[],this.dataFormatDescriptor=[{vendorId:0,descriptorType:0,descriptorBlockSize:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],this.keyValue={},this.globalData=null}}class Ii{constructor(t,e,n,i){this._dataView=new DataView(t.buffer,t.byteOffset+e,n),this._littleEndian=i,this._offset=0}_nextUint8(){const t=this._dataView.getUint8(this._offset);return this._offset+=1,t}_nextUint16(){const t=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,t}_nextUint32(){const t=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,t}_nextUint64(){const t=this._dataView.getUint32(this._offset,this._littleEndian)+2**32*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,t}_nextInt32(){const t=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,t}_skip(t){return this._offset+=t,this}_scan(t,e=0){const n=this._offset;let i=0;for(;this._dataView.getUint8(this._offset)!==e&&i<t;)i++,this._offset++;return i<t&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+n,i)}}const Oi=new Uint8Array([0]),Ti=[171,75,84,88,32,50,48,187,13,10,26,10];function Vi(t){return"undefined"!=typeof TextEncoder?(new TextEncoder).encode(t):Buffer.from(t)}function Ei(t){return"undefined"!=typeof TextDecoder?(new TextDecoder).decode(t):Buffer.from(t).toString("utf8")}function Fi(t){let e=0;for(const n of t)e+=n.byteLength;const n=new Uint8Array(e);let i=0;for(const e of t)n.set(new Uint8Array(e),i),i+=e.byteLength;return n}function Pi(t){const e=new Uint8Array(t.buffer,t.byteOffset,Ti.length);if(e[0]!==Ti[0]||e[1]!==Ti[1]||e[2]!==Ti[2]||e[3]!==Ti[3]||e[4]!==Ti[4]||e[5]!==Ti[5]||e[6]!==Ti[6]||e[7]!==Ti[7]||e[8]!==Ti[8]||e[9]!==Ti[9]||e[10]!==Ti[10]||e[11]!==Ti[11])throw new Error("Missing KTX 2.0 identifier.");const n=new Si,i=17*Uint32Array.BYTES_PER_ELEMENT,s=new Ii(t,Ti.length,i,!0);n.vkFormat=s._nextUint32(),n.typeSize=s._nextUint32(),n.pixelWidth=s._nextUint32(),n.pixelHeight=s._nextUint32(),n.pixelDepth=s._nextUint32(),n.layerCount=s._nextUint32(),n.faceCount=s._nextUint32();const a=s._nextUint32();n.supercompressionScheme=s._nextUint32();const r=s._nextUint32(),o=s._nextUint32(),l=s._nextUint32(),f=s._nextUint32(),U=s._nextUint64(),c=s._nextUint64(),h=new Ii(t,Ti.length+i,3*a*8,!0);for(let e=0;e<a;e++)n.levels.push({levelData:new Uint8Array(t.buffer,t.byteOffset+h._nextUint64(),h._nextUint64()),uncompressedByteLength:h._nextUint64()});const _=new Ii(t,r,o,!0),p={vendorId:_._skip(4)._nextUint16(),descriptorType:_._nextUint16(),versionNumber:_._nextUint16(),descriptorBlockSize:_._nextUint16(),colorModel:_._nextUint8(),colorPrimaries:_._nextUint8(),transferFunction:_._nextUint8(),flags:_._nextUint8(),texelBlockDimension:[_._nextUint8(),_._nextUint8(),_._nextUint8(),_._nextUint8()],bytesPlane:[_._nextUint8(),_._nextUint8(),_._nextUint8(),_._nextUint8(),_._nextUint8(),_._nextUint8(),_._nextUint8(),_._nextUint8()],samples:[]},g=(p.descriptorBlockSize/4-6)/4;for(let t=0;t<g;t++){const e={bitOffset:_._nextUint16(),bitLength:_._nextUint8(),channelType:_._nextUint8(),samplePosition:[_._nextUint8(),_._nextUint8(),_._nextUint8(),_._nextUint8()],sampleLower:-Infinity,sampleUpper:Infinity};64&e.channelType?(e.sampleLower=_._nextInt32(),e.sampleUpper=_._nextInt32()):(e.sampleLower=_._nextUint32(),e.sampleUpper=_._nextUint32()),p.samples[t]=e}n.dataFormatDescriptor.length=0,n.dataFormatDescriptor.push(p);const y=new Ii(t,l,f,!0);for(;y._offset<f;){const t=y._nextUint32(),e=y._scan(t),i=Ei(e),s=y._scan(t-e.byteLength);n.keyValue[i]=i.match(/^ktx/i)?Ei(s):s,y._offset%4&&y._skip(4-y._offset%4)}if(c<=0)return n;const x=new Ii(t,U,c,!0),u=x._nextUint16(),b=x._nextUint16(),d=x._nextUint32(),m=x._nextUint32(),w=x._nextUint32(),D=x._nextUint32(),B=[];for(let t=0;t<a;t++)B.push({imageFlags:x._nextUint32(),rgbSliceByteOffset:x._nextUint32(),rgbSliceByteLength:x._nextUint32(),alphaSliceByteOffset:x._nextUint32(),alphaSliceByteLength:x._nextUint32()});const L=U+x._offset,A=L+d,k=A+m,v=k+w,S=new Uint8Array(t.buffer,t.byteOffset+L,d),I=new Uint8Array(t.buffer,t.byteOffset+A,m),O=new Uint8Array(t.buffer,t.byteOffset+k,w),T=new Uint8Array(t.buffer,t.byteOffset+v,D);return n.globalData={endpointCount:u,selectorCount:b,imageDescs:B,endpointsData:S,selectorsData:I,tablesData:O,extendedData:T},n}function Ci(){return(Ci=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}const zi={keepWriter:!1};function Mi(t,e={}){e=Ci({},zi,e);let n=new ArrayBuffer(0);if(t.globalData){const e=new ArrayBuffer(20+5*t.globalData.imageDescs.length*4),i=new DataView(e);i.setUint16(0,t.globalData.endpointCount,!0),i.setUint16(2,t.globalData.selectorCount,!0),i.setUint32(4,t.globalData.endpointsData.byteLength,!0),i.setUint32(8,t.globalData.selectorsData.byteLength,!0),i.setUint32(12,t.globalData.tablesData.byteLength,!0),i.setUint32(16,t.globalData.extendedData.byteLength,!0);for(let e=0;e<t.globalData.imageDescs.length;e++){const n=t.globalData.imageDescs[e];i.setUint32(20+5*e*4+0,n.imageFlags,!0),i.setUint32(20+5*e*4+4,n.rgbSliceByteOffset,!0),i.setUint32(20+5*e*4+8,n.rgbSliceByteLength,!0),i.setUint32(20+5*e*4+12,n.alphaSliceByteOffset,!0),i.setUint32(20+5*e*4+16,n.alphaSliceByteLength,!0)}n=Fi([e,t.globalData.endpointsData,t.globalData.selectorsData,t.globalData.tablesData,t.globalData.extendedData])}const i=[];let s=t.keyValue;e.keepWriter||(s=Ci({},t.keyValue,{KTXwriter:"KTX-Parse v0.3.0"}));for(const t in s){const e=s[t],n=Vi(t),a="string"==typeof e?Vi(e):e,r=n.byteLength+1+a.byteLength+1,o=r%4?4-r%4:0;i.push(Fi([new Uint32Array([r]),n,Oi,a,Oi,new Uint8Array(o).fill(0)]))}const a=Fi(i);if(1!==t.dataFormatDescriptor.length||0!==t.dataFormatDescriptor[0].descriptorType)throw new Error("Only BASICFORMAT Data Format Descriptor output supported.");const r=t.dataFormatDescriptor[0],o=new ArrayBuffer(28+16*r.samples.length),l=new DataView(o),f=24+16*r.samples.length;if(l.setUint32(0,o.byteLength,!0),l.setUint16(4,r.vendorId,!0),l.setUint16(6,r.descriptorType,!0),l.setUint16(8,r.versionNumber,!0),l.setUint16(10,f,!0),l.setUint8(12,r.colorModel),l.setUint8(13,r.colorPrimaries),l.setUint8(14,r.transferFunction),l.setUint8(15,r.flags),!Array.isArray(r.texelBlockDimension))throw new Error("texelBlockDimension is now an array. For dimensionality `d`, set `d - 1`.");l.setUint8(16,r.texelBlockDimension[0]),l.setUint8(17,r.texelBlockDimension[1]),l.setUint8(18,r.texelBlockDimension[2]),l.setUint8(19,r.texelBlockDimension[3]);for(let t=0;t<8;t++)l.setUint8(20+t,r.bytesPlane[t]);for(let t=0;t<r.samples.length;t++){const e=r.samples[t],n=28+16*t;if(e.channelID)throw new Error("channelID has been renamed to channelType.");l.setUint16(n+0,e.bitOffset,!0),l.setUint8(n+2,e.bitLength),l.setUint8(n+3,e.channelType),l.setUint8(n+4,e.samplePosition[0]),l.setUint8(n+5,e.samplePosition[1]),l.setUint8(n+6,e.samplePosition[2]),l.setUint8(n+7,e.samplePosition[3]),64&e.channelType?(l.setInt32(n+8,e.sampleLower,!0),l.setInt32(n+12,e.sampleUpper,!0)):(l.setUint32(n+8,e.sampleLower,!0),l.setUint32(n+12,e.sampleUpper,!0))}const U=Ti.length+68+3*t.levels.length*8,c=U+o.byteLength;let h=n.byteLength>0?c+a.byteLength:0;h%8&&(h+=8-h%8);const _=[],p=new DataView(new ArrayBuffer(3*t.levels.length*8));let g=(h||c+a.byteLength)+n.byteLength;for(let e=0;e<t.levels.length;e++){const n=t.levels[e];_.push(n.levelData),p.setBigUint64(24*e+0,BigInt(g),!0),p.setBigUint64(24*e+8,BigInt(n.levelData.byteLength),!0),p.setBigUint64(24*e+16,BigInt(n.uncompressedByteLength),!0),g+=n.levelData.byteLength}const y=new ArrayBuffer(68),x=new DataView(y);return x.setUint32(0,t.vkFormat,!0),x.setUint32(4,t.typeSize,!0),x.setUint32(8,t.pixelWidth,!0),x.setUint32(12,t.pixelHeight,!0),x.setUint32(16,t.pixelDepth,!0),x.setUint32(20,t.layerCount,!0),x.setUint32(24,t.faceCount,!0),x.setUint32(28,t.levels.length,!0),x.setUint32(32,t.supercompressionScheme,!0),x.setUint32(36,U,!0),x.setUint32(40,o.byteLength,!0),x.setUint32(44,c,!0),x.setUint32(48,a.byteLength,!0),x.setBigUint64(52,BigInt(n.byteLength>0?h:0),!0),x.setBigUint64(60,BigInt(n.byteLength),!0),new Uint8Array(Fi([new Uint8Array(Ti).buffer,y,p.buffer,o,a,h>0?new ArrayBuffer(h-(c+a.byteLength)):new ArrayBuffer(0),n,..._]))}export{Q as KHR_DF_CHANNEL_RGBSDA_ALPHA,q as KHR_DF_CHANNEL_RGBSDA_BLUE,J as KHR_DF_CHANNEL_RGBSDA_DEPTH,Y as KHR_DF_CHANNEL_RGBSDA_GREEN,R as KHR_DF_CHANNEL_RGBSDA_RED,G as KHR_DF_CHANNEL_RGBSDA_STENCIL,p as KHR_DF_FLAG_ALPHA_PREMULTIPLIED,_ as KHR_DF_FLAG_ALPHA_STRAIGHT,s as KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT,c as KHR_DF_MODEL_ASTC,f as KHR_DF_MODEL_ETC1,h as KHR_DF_MODEL_ETC1S,U as KHR_DF_MODEL_ETC2,l as KHR_DF_MODEL_RGBSDA,o as KHR_DF_MODEL_UNSPECIFIED,W as KHR_DF_PRIMARIES_ACES,N as KHR_DF_PRIMARIES_ACESCC,j as KHR_DF_PRIMARIES_ADOBERGB,z as KHR_DF_PRIMARIES_BT2020,P as KHR_DF_PRIMARIES_BT601_EBU,C as KHR_DF_PRIMARIES_BT601_SMPTE,F as KHR_DF_PRIMARIES_BT709,M as KHR_DF_PRIMARIES_CIEXYZ,X as KHR_DF_PRIMARIES_DISPLAYP3,H as KHR_DF_PRIMARIES_NTSC1953,K as KHR_DF_PRIMARIES_PAL525,E as KHR_DF_PRIMARIES_UNSPECIFIED,tt as KHR_DF_SAMPLE_DATATYPE_EXPONENT,Z as KHR_DF_SAMPLE_DATATYPE_FLOAT,et as KHR_DF_SAMPLE_DATATYPE_LINEAR,$ as KHR_DF_SAMPLE_DATATYPE_SIGNED,O as KHR_DF_TRANSFER_ACESCC,T as KHR_DF_TRANSFER_ACESCCT,V as KHR_DF_TRANSFER_ADOBERGB,w as KHR_DF_TRANSFER_BT1886,k as KHR_DF_TRANSFER_DCIP3,B as KHR_DF_TRANSFER_HLG_EOTF,D as KHR_DF_TRANSFER_HLG_OETF,u as KHR_DF_TRANSFER_ITU,y as KHR_DF_TRANSFER_LINEAR,b as KHR_DF_TRANSFER_NTSC,S as KHR_DF_TRANSFER_PAL625_EOTF,v as KHR_DF_TRANSFER_PAL_OETF,L as KHR_DF_TRANSFER_PQ_EOTF,A as KHR_DF_TRANSFER_PQ_OETF,d as KHR_DF_TRANSFER_SLOG,m as KHR_DF_TRANSFER_SLOG2,x as KHR_DF_TRANSFER_SRGB,I as KHR_DF_TRANSFER_ST240,g as KHR_DF_TRANSFER_UNSPECIFIED,a as KHR_DF_VENDORID_KHRONOS,r as KHR_DF_VERSION,e as KHR_SUPERCOMPRESSION_BASISLZ,t as KHR_SUPERCOMPRESSION_NONE,i as KHR_SUPERCOMPRESSION_ZLIB,n as KHR_SUPERCOMPRESSION_ZSTD,Si as KTX2Container,Ut as VK_FORMAT_A1R5G5B5_UNORM_PACK16,qt as VK_FORMAT_A2B10G10R10_SINT_PACK32,Rt as VK_FORMAT_A2B10G10R10_SNORM_PACK32,Yt as VK_FORMAT_A2B10G10R10_UINT_PACK32,jt as VK_FORMAT_A2B10G10R10_UNORM_PACK32,Xt as VK_FORMAT_A2R10G10B10_SINT_PACK32,Ht as VK_FORMAT_A2R10G10B10_SNORM_PACK32,Kt as VK_FORMAT_A2R10G10B10_UINT_PACK32,Nt as VK_FORMAT_A2R10G10B10_UNORM_PACK32,vi as VK_FORMAT_A4B4G4R4_UNORM_PACK16_EXT,ki as VK_FORMAT_A4R4G4B4_UNORM_PACK16_EXT,Bi as VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK_EXT,Xn as VK_FORMAT_ASTC_10x10_SRGB_BLOCK,Kn as VK_FORMAT_ASTC_10x10_UNORM_BLOCK,mi as VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK_EXT,zn as VK_FORMAT_ASTC_10x5_SRGB_BLOCK,Cn as VK_FORMAT_ASTC_10x5_UNORM_BLOCK,wi as VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK_EXT,Wn as VK_FORMAT_ASTC_10x6_SRGB_BLOCK,Mn as VK_FORMAT_ASTC_10x6_UNORM_BLOCK,Di as VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK_EXT,Hn as VK_FORMAT_ASTC_10x8_SRGB_BLOCK,Nn as VK_FORMAT_ASTC_10x8_UNORM_BLOCK,Li as VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK_EXT,Rn as VK_FORMAT_ASTC_12x10_SRGB_BLOCK,jn as VK_FORMAT_ASTC_12x10_UNORM_BLOCK,Ai as VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK_EXT,qn as VK_FORMAT_ASTC_12x12_SRGB_BLOCK,Yn as VK_FORMAT_ASTC_12x12_UNORM_BLOCK,_i as VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK_EXT,wn as VK_FORMAT_ASTC_4x4_SRGB_BLOCK,mn as VK_FORMAT_ASTC_4x4_UNORM_BLOCK,pi as VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK_EXT,Bn as VK_FORMAT_ASTC_5x4_SRGB_BLOCK,Dn as VK_FORMAT_ASTC_5x4_UNORM_BLOCK,gi as VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK_EXT,An as VK_FORMAT_ASTC_5x5_SRGB_BLOCK,Ln as VK_FORMAT_ASTC_5x5_UNORM_BLOCK,yi as VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK_EXT,vn as VK_FORMAT_ASTC_6x5_SRGB_BLOCK,kn as VK_FORMAT_ASTC_6x5_UNORM_BLOCK,xi as VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK_EXT,In as VK_FORMAT_ASTC_6x6_SRGB_BLOCK,Sn as VK_FORMAT_ASTC_6x6_UNORM_BLOCK,ui as VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK_EXT,Tn as VK_FORMAT_ASTC_8x5_SRGB_BLOCK,On as VK_FORMAT_ASTC_8x5_UNORM_BLOCK,bi as VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK_EXT,En as VK_FORMAT_ASTC_8x6_SRGB_BLOCK,Vn as VK_FORMAT_ASTC_8x6_UNORM_BLOCK,di as VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK_EXT,Pn as VK_FORMAT_ASTC_8x8_SRGB_BLOCK,Fn as VK_FORMAT_ASTC_8x8_UNORM_BLOCK,Me as VK_FORMAT_B10G11R11_UFLOAT_PACK32,$n as VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16,si as VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16,at as VK_FORMAT_B4G4R4A4_UNORM_PACK16,ft as VK_FORMAT_B5G5R5A1_UNORM_PACK16,ot as VK_FORMAT_B5G6R5_UNORM_PACK16,Mt as VK_FORMAT_B8G8R8A8_SINT,Ct as VK_FORMAT_B8G8R8A8_SNORM,Wt as VK_FORMAT_B8G8R8A8_SRGB,zt as VK_FORMAT_B8G8R8A8_UINT,Pt as VK_FORMAT_B8G8R8A8_UNORM,St as VK_FORMAT_B8G8R8_SINT,kt as VK_FORMAT_B8G8R8_SNORM,It as VK_FORMAT_B8G8R8_SRGB,vt as VK_FORMAT_B8G8R8_UINT,At as VK_FORMAT_B8G8R8_UNORM,Qe as VK_FORMAT_BC1_RGBA_SRGB_BLOCK,Je as VK_FORMAT_BC1_RGBA_UNORM_BLOCK,Ge as VK_FORMAT_BC1_RGB_SRGB_BLOCK,qe as VK_FORMAT_BC1_RGB_UNORM_BLOCK,$e as VK_FORMAT_BC2_SRGB_BLOCK,Ze as VK_FORMAT_BC2_UNORM_BLOCK,en as VK_FORMAT_BC3_SRGB_BLOCK,tn as VK_FORMAT_BC3_UNORM_BLOCK,sn as VK_FORMAT_BC4_SNORM_BLOCK,nn as VK_FORMAT_BC4_UNORM_BLOCK,rn as VK_FORMAT_BC5_SNORM_BLOCK,an as VK_FORMAT_BC5_UNORM_BLOCK,ln as VK_FORMAT_BC6H_SFLOAT_BLOCK,on as VK_FORMAT_BC6H_UFLOAT_BLOCK,Un as VK_FORMAT_BC7_SRGB_BLOCK,fn as VK_FORMAT_BC7_UNORM_BLOCK,Ne as VK_FORMAT_D16_UNORM,je as VK_FORMAT_D16_UNORM_S8_UINT,Re as VK_FORMAT_D24_UNORM_S8_UINT,Ke as VK_FORMAT_D32_SFLOAT,Ye as VK_FORMAT_D32_SFLOAT_S8_UINT,We as VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,dn as VK_FORMAT_EAC_R11G11_SNORM_BLOCK,bn as VK_FORMAT_EAC_R11G11_UNORM_BLOCK,un as VK_FORMAT_EAC_R11_SNORM_BLOCK,xn as VK_FORMAT_EAC_R11_UNORM_BLOCK,pn as VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK,_n as VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK,yn as VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK,gn as VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK,hn as VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK,cn as VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK,Zn as VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16,ii as VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16,fi as VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG,ai as VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG,Ui as VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG,ri as VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG,ci as VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG,oi as VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG,hi as VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG,li as VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG,Qn as VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16,Jn as VK_FORMAT_R10X6G10X6_UNORM_2PACK16,Gn as VK_FORMAT_R10X6_UNORM_PACK16,ni as VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16,ei as VK_FORMAT_R12X4G12X4_UNORM_2PACK16,ti as VK_FORMAT_R12X4_UNORM_PACK16,pe as VK_FORMAT_R16G16B16A16_SFLOAT,_e as VK_FORMAT_R16G16B16A16_SINT,ce as VK_FORMAT_R16G16B16A16_SNORM,he as VK_FORMAT_R16G16B16A16_UINT,Ue as VK_FORMAT_R16G16B16A16_UNORM,fe as VK_FORMAT_R16G16B16_SFLOAT,le as VK_FORMAT_R16G16B16_SINT,re as VK_FORMAT_R16G16B16_SNORM,oe as VK_FORMAT_R16G16B16_UINT,ae as VK_FORMAT_R16G16B16_UNORM,se as VK_FORMAT_R16G16_SFLOAT,ie as VK_FORMAT_R16G16_SINT,ee as VK_FORMAT_R16G16_SNORM,ne as VK_FORMAT_R16G16_UINT,te as VK_FORMAT_R16G16_UNORM,$t as VK_FORMAT_R16_SFLOAT,Zt as VK_FORMAT_R16_SINT,Jt as VK_FORMAT_R16_SNORM,Qt as VK_FORMAT_R16_UINT,Gt as VK_FORMAT_R16_UNORM,Ae as VK_FORMAT_R32G32B32A32_SFLOAT,Le as VK_FORMAT_R32G32B32A32_SINT,Be as VK_FORMAT_R32G32B32A32_UINT,De as VK_FORMAT_R32G32B32_SFLOAT,we as VK_FORMAT_R32G32B32_SINT,me as VK_FORMAT_R32G32B32_UINT,de as VK_FORMAT_R32G32_SFLOAT,be as VK_FORMAT_R32G32_SINT,ue as VK_FORMAT_R32G32_UINT,xe as VK_FORMAT_R32_SFLOAT,ye as VK_FORMAT_R32_SINT,ge as VK_FORMAT_R32_UINT,st as VK_FORMAT_R4G4B4A4_UNORM_PACK16,it as VK_FORMAT_R4G4_UNORM_PACK8,lt as VK_FORMAT_R5G5B5A1_UNORM_PACK16,rt as VK_FORMAT_R5G6B5_UNORM_PACK16,ze as VK_FORMAT_R64G64B64A64_SFLOAT,Ce as VK_FORMAT_R64G64B64A64_SINT,Pe as VK_FORMAT_R64G64B64A64_UINT,Fe as VK_FORMAT_R64G64B64_SFLOAT,Ee as VK_FORMAT_R64G64B64_SINT,Ve as VK_FORMAT_R64G64B64_UINT,Te as VK_FORMAT_R64G64_SFLOAT,Oe as VK_FORMAT_R64G64_SINT,Ie as VK_FORMAT_R64G64_UINT,Se as VK_FORMAT_R64_SFLOAT,ve as VK_FORMAT_R64_SINT,ke as VK_FORMAT_R64_UINT,Et as VK_FORMAT_R8G8B8A8_SINT,Tt as VK_FORMAT_R8G8B8A8_SNORM,Ft as VK_FORMAT_R8G8B8A8_SRGB,Vt as VK_FORMAT_R8G8B8A8_UINT,Ot as VK_FORMAT_R8G8B8A8_UNORM,Bt as VK_FORMAT_R8G8B8_SINT,wt as VK_FORMAT_R8G8B8_SNORM,Lt as VK_FORMAT_R8G8B8_SRGB,Dt as VK_FORMAT_R8G8B8_UINT,mt as VK_FORMAT_R8G8B8_UNORM,bt as VK_FORMAT_R8G8_SINT,xt as VK_FORMAT_R8G8_SNORM,dt as VK_FORMAT_R8G8_SRGB,ut as VK_FORMAT_R8G8_UINT,yt as VK_FORMAT_R8G8_UNORM,pt as VK_FORMAT_R8_SINT,ht as VK_FORMAT_R8_SNORM,gt as VK_FORMAT_R8_SRGB,_t as VK_FORMAT_R8_UINT,ct as VK_FORMAT_R8_UNORM,Xe as VK_FORMAT_S8_UINT,nt as VK_FORMAT_UNDEFINED,He as VK_FORMAT_X8_D24_UNORM_PACK32,Pi as read,Mi as write}; | ||
//# sourceMappingURL=ktx-parse.modern.js.map |
{ | ||
"name": "ktx-parse", | ||
"version": "0.2.2", | ||
"version": "0.3.0", | ||
"description": "KTX 2.0 (.ktx2) parser and serializer.", | ||
@@ -29,2 +29,4 @@ "source": "src/index.ts", | ||
"eslint": "^7.15.0", | ||
"glob": "^8.0.3", | ||
"glob-promise": "^4.2.2", | ||
"microbundle": "^0.12.4", | ||
@@ -31,0 +33,0 @@ "nyc": "^15.1.0", |
@@ -72,3 +72,3 @@ # ktx-parse | ||
*Defined in [src/read.ts:13](https://github.com/donmccurdy/KTX-Parse/blob/fe08af2/src/read.ts#L13)* | ||
*Defined in [src/read.ts:14](https://github.com/donmccurdy/KTX-Parse/blob/6951be1/src/read.ts#L14)* | ||
@@ -96,3 +96,3 @@ Parses a KTX 2.0 file, returning an unpacked `KTX2Container` instance with all associated | ||
*Defined in [src/write.ts:21](https://github.com/donmccurdy/KTX-Parse/blob/fe08af2/src/write.ts#L21)* | ||
*Defined in [src/write.ts:21](https://github.com/donmccurdy/KTX-Parse/blob/6951be1/src/write.ts#L21)* | ||
@@ -130,5 +130,5 @@ Serializes a `KTX2Container` instance to a KTX 2.0 file. Mip levels and other binary data | ||
• **dataFormatDescriptor**: `KTX2DataFormatDescriptorBasicFormat`[] = [{ vendorId: KHR\_DF\_VENDORID\_KHRONOS, descriptorType: KTX2DescriptorType.BASICFORMAT, versionNumber: KHR\_DF\_VERSION, descriptorBlockSize: KHR\_DF\_BLOCKSIZE, colorModel: KTX2Model.UNSPECIFIED, colorPrimaries: KTX2Primaries.SRGB, transferFunction: KTX2Primaries.SRGB, flags: KTX2Flags.ALPHA\_STRAIGHT, texelBlockDimension: {x: 4, y: 4, z: 1, w: 1}, bytesPlane: [], samples: [], }] | ||
• **dataFormatDescriptor**: `KTX2DataFormatDescriptorBasicFormat`[] = [{ vendorId: KHR\_DF\_VENDORID\_KHRONOS, descriptorType: KHR\_DF\_KHR\_DESCRIPTORTYPE\_BASICFORMAT, descriptorBlockSize: 0, versionNumber: KHR\_DF\_VERSION, colorModel: KHR\_DF\_MODEL\_UNSPECIFIED, colorPrimaries: KHR\_DF\_PRIMARIES\_BT709, transferFunction: KHR\_DF\_TRANSFER\_SRGB, flags: KHR\_DF\_FLAG\_ALPHA\_STRAIGHT, texelBlockDimension: [0, 0, 0, 0], bytesPlane: [0, 0, 0, 0, 0, 0, 0, 0], samples: [], }] | ||
*Defined in [src/container.ts:48](https://github.com/donmccurdy/KTX-Parse/blob/fe08af2/src/container.ts#L48)* | ||
*Defined in [src/container.ts:47](https://github.com/donmccurdy/KTX-Parse/blob/6951be1/src/container.ts#L47)* | ||
@@ -143,3 +143,3 @@ Data Format Descriptor. | ||
*Defined in [src/container.ts:39](https://github.com/donmccurdy/KTX-Parse/blob/fe08af2/src/container.ts#L39)* | ||
*Defined in [src/container.ts:38](https://github.com/donmccurdy/KTX-Parse/blob/6951be1/src/container.ts#L38)* | ||
@@ -156,3 +156,3 @@ Number of cubemap faces. For cubemaps and cubemap arrays, `faceCount` must be 6. For all | ||
*Defined in [src/container.ts:66](https://github.com/donmccurdy/KTX-Parse/blob/fe08af2/src/container.ts#L66)* | ||
*Defined in [src/container.ts:65](https://github.com/donmccurdy/KTX-Parse/blob/6951be1/src/container.ts#L65)* | ||
@@ -167,3 +167,3 @@ Supercompression Global Data. | ||
*Defined in [src/container.ts:63](https://github.com/donmccurdy/KTX-Parse/blob/fe08af2/src/container.ts#L63)* | ||
*Defined in [src/container.ts:62](https://github.com/donmccurdy/KTX-Parse/blob/6951be1/src/container.ts#L62)* | ||
@@ -178,3 +178,3 @@ Key/Value Data. | ||
*Defined in [src/container.ts:32](https://github.com/donmccurdy/KTX-Parse/blob/fe08af2/src/container.ts#L32)* | ||
*Defined in [src/container.ts:31](https://github.com/donmccurdy/KTX-Parse/blob/6951be1/src/container.ts#L31)* | ||
@@ -189,3 +189,3 @@ Number of array elements (array textures only). | ||
*Defined in [src/container.ts:45](https://github.com/donmccurdy/KTX-Parse/blob/fe08af2/src/container.ts#L45)* | ||
*Defined in [src/container.ts:44](https://github.com/donmccurdy/KTX-Parse/blob/6951be1/src/container.ts#L44)* | ||
@@ -200,3 +200,3 @@ Mip levels, ordered largest (original) to smallest (~1px). | ||
*Defined in [src/container.ts:29](https://github.com/donmccurdy/KTX-Parse/blob/fe08af2/src/container.ts#L29)* | ||
*Defined in [src/container.ts:28](https://github.com/donmccurdy/KTX-Parse/blob/6951be1/src/container.ts#L28)* | ||
@@ -211,3 +211,3 @@ Depth of the texture image for level 0, in pixels (3D textures only). | ||
*Defined in [src/container.ts:26](https://github.com/donmccurdy/KTX-Parse/blob/fe08af2/src/container.ts#L26)* | ||
*Defined in [src/container.ts:25](https://github.com/donmccurdy/KTX-Parse/blob/6951be1/src/container.ts#L25)* | ||
@@ -222,3 +222,3 @@ Height of the texture image for level 0, in pixels. | ||
*Defined in [src/container.ts:23](https://github.com/donmccurdy/KTX-Parse/blob/fe08af2/src/container.ts#L23)* | ||
*Defined in [src/container.ts:22](https://github.com/donmccurdy/KTX-Parse/blob/6951be1/src/container.ts#L22)* | ||
@@ -231,5 +231,5 @@ Width of the texture image for level 0, in pixels. | ||
• **supercompressionScheme**: `KTX2SupercompressionScheme` = KTX2SupercompressionScheme.NONE | ||
• **supercompressionScheme**: number = KHR\_SUPERCOMPRESSION\_NONE | ||
*Defined in [src/container.ts:42](https://github.com/donmccurdy/KTX-Parse/blob/fe08af2/src/container.ts#L42)* | ||
*Defined in [src/container.ts:41](https://github.com/donmccurdy/KTX-Parse/blob/6951be1/src/container.ts#L41)* | ||
@@ -244,3 +244,3 @@ Indicates which supercompression scheme has been applied to mip level images, if any. | ||
*Defined in [src/container.ts:20](https://github.com/donmccurdy/KTX-Parse/blob/fe08af2/src/container.ts#L20)* | ||
*Defined in [src/container.ts:19](https://github.com/donmccurdy/KTX-Parse/blob/6951be1/src/container.ts#L19)* | ||
@@ -256,3 +256,3 @@ Size of the data type in bytes used to upload the data to a graphics API. When `vkFormat` is | ||
*Defined in [src/container.ts:14](https://github.com/donmccurdy/KTX-Parse/blob/fe08af2/src/container.ts#L14)* | ||
*Defined in [src/container.ts:13](https://github.com/donmccurdy/KTX-Parse/blob/6951be1/src/container.ts#L13)* | ||
@@ -259,0 +259,0 @@ Specifies the image format using Vulkan VkFormat enum values. When using Basis Universal |
@@ -40,2 +40,8 @@ export class BufferReader { | ||
_nextInt32() { | ||
const value = this._dataView.getInt32(this._offset, this._littleEndian); | ||
this._offset += 4; | ||
return value; | ||
} | ||
_skip(bytes: number) { | ||
@@ -42,0 +48,0 @@ this._offset += bytes; |
/////////////////////////////////////////////////// | ||
// Common. | ||
// KTX2 Header. | ||
/////////////////////////////////////////////////// | ||
// Injected at compile time, from $npm_package_version. | ||
declare const PACKAGE_VERSION: string; | ||
export const KHR_SUPERCOMPRESSION_NONE = 0; | ||
export const KHR_SUPERCOMPRESSION_BASISLZ = 1; | ||
export const KHR_SUPERCOMPRESSION_ZSTD = 2; | ||
export const KHR_SUPERCOMPRESSION_ZLIB = 3; | ||
export const KTX_WRITER = `KTX-Parse v${PACKAGE_VERSION}`; | ||
/////////////////////////////////////////////////// | ||
// Data Format Descriptor (DFD). | ||
/////////////////////////////////////////////////// | ||
export const NUL = new Uint8Array([0x00]); | ||
export const KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT = 0; | ||
export const KHR_DF_VENDORID_KHRONOS = 0; | ||
export const KHR_DF_VERSION = 2; | ||
export const KHR_DF_MODEL_UNSPECIFIED = 0; | ||
export const KHR_DF_MODEL_RGBSDA = 1; | ||
// ... | ||
export const KHR_DF_MODEL_ETC1 = 160; | ||
export const KHR_DF_MODEL_ETC2 = 161; | ||
export const KHR_DF_MODEL_ASTC = 162; | ||
export const KHR_DF_MODEL_ETC1S = 163; | ||
/////////////////////////////////////////////////// | ||
// KTX2 Header. | ||
/////////////////////////////////////////////////// | ||
export const KHR_DF_FLAG_ALPHA_STRAIGHT = 0; | ||
export const KHR_DF_FLAG_ALPHA_PREMULTIPLIED = 1; | ||
export const KTX2_ID = [ | ||
// '´', 'K', 'T', 'X', '2', '0', 'ª', '\r', '\n', '\x1A', '\n' | ||
0xAB, 0x4B, 0x54, 0x58, 0x20, 0x32, 0x30, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A | ||
]; | ||
export const KHR_DF_TRANSFER_UNSPECIFIED = 0; | ||
export const KHR_DF_TRANSFER_LINEAR = 1; | ||
export const KHR_DF_TRANSFER_SRGB = 2; | ||
export const KHR_DF_TRANSFER_ITU = 3; | ||
export const KHR_DF_TRANSFER_NTSC = 4; | ||
export const KHR_DF_TRANSFER_SLOG = 5; | ||
export const KHR_DF_TRANSFER_SLOG2 = 6; | ||
export const KHR_DF_TRANSFER_BT1886 = 7; | ||
export const KHR_DF_TRANSFER_HLG_OETF = 8; | ||
export const KHR_DF_TRANSFER_HLG_EOTF = 9; | ||
export const KHR_DF_TRANSFER_PQ_EOTF = 10; | ||
export const KHR_DF_TRANSFER_PQ_OETF = 11; | ||
export const KHR_DF_TRANSFER_DCIP3 = 12; | ||
export const KHR_DF_TRANSFER_PAL_OETF = 13; | ||
export const KHR_DF_TRANSFER_PAL625_EOTF = 14; | ||
export const KHR_DF_TRANSFER_ST240 = 15; | ||
export const KHR_DF_TRANSFER_ACESCC = 16; | ||
export const KHR_DF_TRANSFER_ACESCCT = 17; | ||
export const KHR_DF_TRANSFER_ADOBERGB = 18; | ||
export const HEADER_BYTE_LENGTH = 68; // 13 * 4 + 2 * 8 | ||
export const KHR_DF_PRIMARIES_UNSPECIFIED = 0; | ||
export const KHR_DF_PRIMARIES_BT709 = 1; | ||
export const KHR_DF_PRIMARIES_BT601_EBU = 2; | ||
export const KHR_DF_PRIMARIES_BT601_SMPTE = 3; | ||
export const KHR_DF_PRIMARIES_BT2020 = 4; | ||
export const KHR_DF_PRIMARIES_CIEXYZ = 5; | ||
export const KHR_DF_PRIMARIES_ACES = 6; | ||
export const KHR_DF_PRIMARIES_ACESCC = 7; | ||
export const KHR_DF_PRIMARIES_NTSC1953 = 8; | ||
export const KHR_DF_PRIMARIES_PAL525 = 9; | ||
export const KHR_DF_PRIMARIES_DISPLAYP3 = 10; | ||
export const KHR_DF_PRIMARIES_ADOBERGB = 11; | ||
export const KHR_DF_CHANNEL_RGBSDA_RED = 0; | ||
export const KHR_DF_CHANNEL_RGBSDA_GREEN = 1; | ||
export const KHR_DF_CHANNEL_RGBSDA_BLUE = 2; | ||
export const KHR_DF_CHANNEL_RGBSDA_STENCIL = 13; | ||
export const KHR_DF_CHANNEL_RGBSDA_DEPTH = 14; | ||
export const KHR_DF_CHANNEL_RGBSDA_ALPHA = 15; | ||
export const KHR_DF_SAMPLE_DATATYPE_FLOAT = 0x80; | ||
export const KHR_DF_SAMPLE_DATATYPE_SIGNED = 0x40; | ||
export const KHR_DF_SAMPLE_DATATYPE_EXPONENT = 0x20; | ||
export const KHR_DF_SAMPLE_DATATYPE_LINEAR = 0x10; | ||
/////////////////////////////////////////////////// | ||
// Data Format Descriptor (DFD). | ||
// VK FORMAT. | ||
/////////////////////////////////////////////////// | ||
export const KHR_DF_VENDORID_KHRONOS = 0; | ||
export const KHR_DF_VERSION = 2; | ||
export const KHR_DF_BLOCKSIZE = 40; | ||
export const VK_FORMAT_UNDEFINED = 0; | ||
export const VK_FORMAT_R4G4_UNORM_PACK8 = 1; | ||
export const VK_FORMAT_R4G4B4A4_UNORM_PACK16 = 2; | ||
export const VK_FORMAT_B4G4R4A4_UNORM_PACK16 = 3; | ||
export const VK_FORMAT_R5G6B5_UNORM_PACK16 = 4; | ||
export const VK_FORMAT_B5G6R5_UNORM_PACK16 = 5; | ||
export const VK_FORMAT_R5G5B5A1_UNORM_PACK16 = 6; | ||
export const VK_FORMAT_B5G5R5A1_UNORM_PACK16 = 7; | ||
export const VK_FORMAT_A1R5G5B5_UNORM_PACK16 = 8; | ||
export const VK_FORMAT_R8_UNORM = 9; | ||
export const VK_FORMAT_R8_SNORM = 10; | ||
export const VK_FORMAT_R8_UINT = 13; | ||
export const VK_FORMAT_R8_SINT = 14; | ||
export const VK_FORMAT_R8_SRGB = 15; | ||
export const VK_FORMAT_R8G8_UNORM = 16; | ||
export const VK_FORMAT_R8G8_SNORM = 17; | ||
export const VK_FORMAT_R8G8_UINT = 20; | ||
export const VK_FORMAT_R8G8_SINT = 21; | ||
export const VK_FORMAT_R8G8_SRGB = 22; | ||
export const VK_FORMAT_R8G8B8_UNORM = 23; | ||
export const VK_FORMAT_R8G8B8_SNORM = 24; | ||
export const VK_FORMAT_R8G8B8_UINT = 27; | ||
export const VK_FORMAT_R8G8B8_SINT = 28; | ||
export const VK_FORMAT_R8G8B8_SRGB = 29; | ||
export const VK_FORMAT_B8G8R8_UNORM = 30; | ||
export const VK_FORMAT_B8G8R8_SNORM = 31; | ||
export const VK_FORMAT_B8G8R8_UINT = 34; | ||
export const VK_FORMAT_B8G8R8_SINT = 35; | ||
export const VK_FORMAT_B8G8R8_SRGB = 36; | ||
export const VK_FORMAT_R8G8B8A8_UNORM = 37; | ||
export const VK_FORMAT_R8G8B8A8_SNORM = 38; | ||
export const VK_FORMAT_R8G8B8A8_UINT = 41; | ||
export const VK_FORMAT_R8G8B8A8_SINT = 42; | ||
export const VK_FORMAT_R8G8B8A8_SRGB = 43; | ||
export const VK_FORMAT_B8G8R8A8_UNORM = 44; | ||
export const VK_FORMAT_B8G8R8A8_SNORM = 45; | ||
export const VK_FORMAT_B8G8R8A8_UINT = 48; | ||
export const VK_FORMAT_B8G8R8A8_SINT = 49; | ||
export const VK_FORMAT_B8G8R8A8_SRGB = 50; | ||
export const VK_FORMAT_A2R10G10B10_UNORM_PACK32 = 58; | ||
export const VK_FORMAT_A2R10G10B10_SNORM_PACK32 = 59; | ||
export const VK_FORMAT_A2R10G10B10_UINT_PACK32 = 62; | ||
export const VK_FORMAT_A2R10G10B10_SINT_PACK32 = 63; | ||
export const VK_FORMAT_A2B10G10R10_UNORM_PACK32 = 64; | ||
export const VK_FORMAT_A2B10G10R10_SNORM_PACK32 = 65; | ||
export const VK_FORMAT_A2B10G10R10_UINT_PACK32 = 68; | ||
export const VK_FORMAT_A2B10G10R10_SINT_PACK32 = 69; | ||
export const VK_FORMAT_R16_UNORM = 70; | ||
export const VK_FORMAT_R16_SNORM = 71; | ||
export const VK_FORMAT_R16_UINT = 74; | ||
export const VK_FORMAT_R16_SINT = 75; | ||
export const VK_FORMAT_R16_SFLOAT = 76; | ||
export const VK_FORMAT_R16G16_UNORM = 77; | ||
export const VK_FORMAT_R16G16_SNORM = 78; | ||
export const VK_FORMAT_R16G16_UINT = 81; | ||
export const VK_FORMAT_R16G16_SINT = 82; | ||
export const VK_FORMAT_R16G16_SFLOAT = 83; | ||
export const VK_FORMAT_R16G16B16_UNORM = 84; | ||
export const VK_FORMAT_R16G16B16_SNORM = 85; | ||
export const VK_FORMAT_R16G16B16_UINT = 88; | ||
export const VK_FORMAT_R16G16B16_SINT = 89; | ||
export const VK_FORMAT_R16G16B16_SFLOAT = 90; | ||
export const VK_FORMAT_R16G16B16A16_UNORM = 91; | ||
export const VK_FORMAT_R16G16B16A16_SNORM = 92; | ||
export const VK_FORMAT_R16G16B16A16_UINT = 95; | ||
export const VK_FORMAT_R16G16B16A16_SINT = 96; | ||
export const VK_FORMAT_R16G16B16A16_SFLOAT = 97; | ||
export const VK_FORMAT_R32_UINT = 98; | ||
export const VK_FORMAT_R32_SINT = 99; | ||
export const VK_FORMAT_R32_SFLOAT = 100; | ||
export const VK_FORMAT_R32G32_UINT = 101; | ||
export const VK_FORMAT_R32G32_SINT = 102; | ||
export const VK_FORMAT_R32G32_SFLOAT = 103; | ||
export const VK_FORMAT_R32G32B32_UINT = 104; | ||
export const VK_FORMAT_R32G32B32_SINT = 105; | ||
export const VK_FORMAT_R32G32B32_SFLOAT = 106; | ||
export const VK_FORMAT_R32G32B32A32_UINT = 107; | ||
export const VK_FORMAT_R32G32B32A32_SINT = 108; | ||
export const VK_FORMAT_R32G32B32A32_SFLOAT = 109; | ||
export const VK_FORMAT_R64_UINT = 110; | ||
export const VK_FORMAT_R64_SINT = 111; | ||
export const VK_FORMAT_R64_SFLOAT = 112; | ||
export const VK_FORMAT_R64G64_UINT = 113; | ||
export const VK_FORMAT_R64G64_SINT = 114; | ||
export const VK_FORMAT_R64G64_SFLOAT = 115; | ||
export const VK_FORMAT_R64G64B64_UINT = 116; | ||
export const VK_FORMAT_R64G64B64_SINT = 117; | ||
export const VK_FORMAT_R64G64B64_SFLOAT = 118; | ||
export const VK_FORMAT_R64G64B64A64_UINT = 119; | ||
export const VK_FORMAT_R64G64B64A64_SINT = 120; | ||
export const VK_FORMAT_R64G64B64A64_SFLOAT = 121; | ||
export const VK_FORMAT_B10G11R11_UFLOAT_PACK32 = 122; | ||
export const VK_FORMAT_E5B9G9R9_UFLOAT_PACK32 = 123; | ||
export const VK_FORMAT_D16_UNORM = 124; | ||
export const VK_FORMAT_X8_D24_UNORM_PACK32 = 125; | ||
export const VK_FORMAT_D32_SFLOAT = 126; | ||
export const VK_FORMAT_S8_UINT = 127; | ||
export const VK_FORMAT_D16_UNORM_S8_UINT = 128; | ||
export const VK_FORMAT_D24_UNORM_S8_UINT = 129; | ||
export const VK_FORMAT_D32_SFLOAT_S8_UINT = 130; | ||
export const VK_FORMAT_BC1_RGB_UNORM_BLOCK = 131; | ||
export const VK_FORMAT_BC1_RGB_SRGB_BLOCK = 132; | ||
export const VK_FORMAT_BC1_RGBA_UNORM_BLOCK = 133; | ||
export const VK_FORMAT_BC1_RGBA_SRGB_BLOCK = 134; | ||
export const VK_FORMAT_BC2_UNORM_BLOCK = 135; | ||
export const VK_FORMAT_BC2_SRGB_BLOCK = 136; | ||
export const VK_FORMAT_BC3_UNORM_BLOCK = 137; | ||
export const VK_FORMAT_BC3_SRGB_BLOCK = 138; | ||
export const VK_FORMAT_BC4_UNORM_BLOCK = 139; | ||
export const VK_FORMAT_BC4_SNORM_BLOCK = 140; | ||
export const VK_FORMAT_BC5_UNORM_BLOCK = 141; | ||
export const VK_FORMAT_BC5_SNORM_BLOCK = 142; | ||
export const VK_FORMAT_BC6H_UFLOAT_BLOCK = 143; | ||
export const VK_FORMAT_BC6H_SFLOAT_BLOCK = 144; | ||
export const VK_FORMAT_BC7_UNORM_BLOCK = 145; | ||
export const VK_FORMAT_BC7_SRGB_BLOCK = 146; | ||
export const VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK = 147; | ||
export const VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK = 148; | ||
export const VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK = 149; | ||
export const VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK = 150; | ||
export const VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK = 151; | ||
export const VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK = 152; | ||
export const VK_FORMAT_EAC_R11_UNORM_BLOCK = 153; | ||
export const VK_FORMAT_EAC_R11_SNORM_BLOCK = 154; | ||
export const VK_FORMAT_EAC_R11G11_UNORM_BLOCK = 155; | ||
export const VK_FORMAT_EAC_R11G11_SNORM_BLOCK = 156; | ||
export const VK_FORMAT_ASTC_4x4_UNORM_BLOCK = 157; | ||
export const VK_FORMAT_ASTC_4x4_SRGB_BLOCK = 158; | ||
export const VK_FORMAT_ASTC_5x4_UNORM_BLOCK = 159; | ||
export const VK_FORMAT_ASTC_5x4_SRGB_BLOCK = 160; | ||
export const VK_FORMAT_ASTC_5x5_UNORM_BLOCK = 161; | ||
export const VK_FORMAT_ASTC_5x5_SRGB_BLOCK = 162; | ||
export const VK_FORMAT_ASTC_6x5_UNORM_BLOCK = 163; | ||
export const VK_FORMAT_ASTC_6x5_SRGB_BLOCK = 164; | ||
export const VK_FORMAT_ASTC_6x6_UNORM_BLOCK = 165; | ||
export const VK_FORMAT_ASTC_6x6_SRGB_BLOCK = 166; | ||
export const VK_FORMAT_ASTC_8x5_UNORM_BLOCK = 167; | ||
export const VK_FORMAT_ASTC_8x5_SRGB_BLOCK = 168; | ||
export const VK_FORMAT_ASTC_8x6_UNORM_BLOCK = 169; | ||
export const VK_FORMAT_ASTC_8x6_SRGB_BLOCK = 170; | ||
export const VK_FORMAT_ASTC_8x8_UNORM_BLOCK = 171; | ||
export const VK_FORMAT_ASTC_8x8_SRGB_BLOCK = 172; | ||
export const VK_FORMAT_ASTC_10x5_UNORM_BLOCK = 173; | ||
export const VK_FORMAT_ASTC_10x5_SRGB_BLOCK = 174; | ||
export const VK_FORMAT_ASTC_10x6_UNORM_BLOCK = 175; | ||
export const VK_FORMAT_ASTC_10x6_SRGB_BLOCK = 176; | ||
export const VK_FORMAT_ASTC_10x8_UNORM_BLOCK = 177; | ||
export const VK_FORMAT_ASTC_10x8_SRGB_BLOCK = 178; | ||
export const VK_FORMAT_ASTC_10x10_UNORM_BLOCK = 179; | ||
export const VK_FORMAT_ASTC_10x10_SRGB_BLOCK = 180; | ||
export const VK_FORMAT_ASTC_12x10_UNORM_BLOCK = 181; | ||
export const VK_FORMAT_ASTC_12x10_SRGB_BLOCK = 182; | ||
export const VK_FORMAT_ASTC_12x12_UNORM_BLOCK = 183; | ||
export const VK_FORMAT_ASTC_12x12_SRGB_BLOCK = 184; | ||
export const VK_FORMAT_R10X6_UNORM_PACK16 = 1000156007; | ||
export const VK_FORMAT_R10X6G10X6_UNORM_2PACK16 = 1000156008; | ||
export const VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16 = 1000156009; | ||
export const VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16 = 1000156010; | ||
export const VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 = 1000156011; | ||
export const VK_FORMAT_R12X4_UNORM_PACK16 = 1000156017; | ||
export const VK_FORMAT_R12X4G12X4_UNORM_2PACK16 = 1000156018; | ||
export const VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16 = 1000156019; | ||
export const VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 = 1000156020; | ||
export const VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16 = 1000156021; | ||
export const VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG = 1000054000; | ||
export const VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG = 1000054001; | ||
export const VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG = 1000054002; | ||
export const VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG = 1000054003; | ||
export const VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG = 1000054004; | ||
export const VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG = 1000054005; | ||
export const VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG = 1000054006; | ||
export const VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG = 1000054007; | ||
export const VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK_EXT = 1000066000; | ||
export const VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK_EXT = 1000066001; | ||
export const VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK_EXT = 1000066002; | ||
export const VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK_EXT = 1000066003; | ||
export const VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK_EXT = 1000066004; | ||
export const VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK_EXT = 1000066005; | ||
export const VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK_EXT = 1000066006; | ||
export const VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK_EXT = 1000066007; | ||
export const VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK_EXT = 1000066008; | ||
export const VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK_EXT = 1000066009; | ||
export const VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK_EXT = 1000066010; | ||
export const VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK_EXT = 1000066011; | ||
export const VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK_EXT = 1000066012; | ||
export const VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK_EXT = 1000066013; | ||
export const VK_FORMAT_A4R4G4B4_UNORM_PACK16_EXT = 1000340000; | ||
export const VK_FORMAT_A4B4G4R4_UNORM_PACK16_EXT = 1000340001; |
@@ -1,3 +0,2 @@ | ||
import { KHR_DF_BLOCKSIZE, KHR_DF_VENDORID_KHRONOS, KHR_DF_VERSION, VK_FORMAT_UNDEFINED } from './constants'; | ||
import { KTX2DescriptorType, KTX2Flags, KTX2Model, KTX2Primaries, KTX2SupercompressionScheme } from './enums'; | ||
import { KHR_DF_FLAG_ALPHA_STRAIGHT, KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT, KHR_DF_MODEL_UNSPECIFIED, KHR_DF_PRIMARIES_BT709, KHR_DF_TRANSFER_SRGB, KHR_DF_VENDORID_KHRONOS, KHR_DF_VERSION, KHR_SUPERCOMPRESSION_NONE, VK_FORMAT_UNDEFINED } from './constants'; | ||
@@ -42,3 +41,3 @@ /** | ||
/** Indicates which supercompression scheme has been applied to mip level images, if any. */ | ||
public supercompressionScheme = KTX2SupercompressionScheme.NONE; | ||
public supercompressionScheme = KHR_SUPERCOMPRESSION_NONE; | ||
@@ -51,11 +50,11 @@ /** Mip levels, ordered largest (original) to smallest (~1px). */ | ||
vendorId: KHR_DF_VENDORID_KHRONOS, | ||
descriptorType: KTX2DescriptorType.BASICFORMAT, | ||
descriptorType: KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT, | ||
descriptorBlockSize: 0, | ||
versionNumber: KHR_DF_VERSION, | ||
descriptorBlockSize: KHR_DF_BLOCKSIZE, | ||
colorModel: KTX2Model.UNSPECIFIED, | ||
colorPrimaries: KTX2Primaries.SRGB, | ||
transferFunction: KTX2Primaries.SRGB, | ||
flags: KTX2Flags.ALPHA_STRAIGHT, | ||
texelBlockDimension: {x: 4, y: 4, z: 1, w: 1}, | ||
bytesPlane: [], | ||
colorModel: KHR_DF_MODEL_UNSPECIFIED, | ||
colorPrimaries: KHR_DF_PRIMARIES_BT709, | ||
transferFunction: KHR_DF_TRANSFER_SRGB, | ||
flags: KHR_DF_FLAG_ALPHA_STRAIGHT, | ||
texelBlockDimension: [0, 0, 0, 0], | ||
bytesPlane: [0, 0, 0, 0, 0, 0, 0, 0], | ||
samples: [], | ||
@@ -102,2 +101,3 @@ }]; | ||
versionNumber: number; | ||
/** @deprecated Inferred. */ | ||
descriptorBlockSize: number; | ||
@@ -108,18 +108,13 @@ colorModel: number; | ||
flags: number; | ||
texelBlockDimension: KTX2BasicFormatTexelBlockDimensions; | ||
bytesPlane: number[]; | ||
texelBlockDimension: [number, number, number, number]; | ||
bytesPlane: [number, number, number, number, number, number, number, number]; | ||
samples: KTX2BasicFormatSample[], | ||
}; | ||
export interface KTX2BasicFormatTexelBlockDimensions { | ||
x: number; | ||
y: number; | ||
z: number; | ||
w: number; | ||
}; | ||
export interface KTX2BasicFormatSample { | ||
bitOffset: number; | ||
bitLength: number; | ||
channelID: number; | ||
/** @deprecated Renamed to 'channelType'. */ | ||
channelID?: number; | ||
channelType: number; | ||
samplePosition: number[]; | ||
@@ -126,0 +121,0 @@ sampleLower: number; |
export * from './container'; | ||
export * from './enums'; | ||
export * from './constants'; | ||
export * from './read'; | ||
export * from './write'; |
import { BufferReader } from './buffer-reader'; | ||
import { KTX2_ID } from './constants'; | ||
import { KHR_DF_SAMPLE_DATATYPE_SIGNED } from './constants'; | ||
import { KTX2_ID } from './constants-internal'; | ||
import { KTX2Container, KTX2DataFormatDescriptorBasicFormat } from './container'; | ||
@@ -94,8 +95,8 @@ import { decodeText } from './util'; | ||
flags: dfdReader._nextUint8(), | ||
texelBlockDimension: { | ||
x: dfdReader._nextUint8() + 1, | ||
y: dfdReader._nextUint8() + 1, | ||
z: dfdReader._nextUint8() + 1, | ||
w: dfdReader._nextUint8() + 1, | ||
}, | ||
texelBlockDimension: [ | ||
dfdReader._nextUint8(), | ||
dfdReader._nextUint8(), | ||
dfdReader._nextUint8(), | ||
dfdReader._nextUint8(), | ||
], | ||
bytesPlane: [ | ||
@@ -119,6 +120,6 @@ dfdReader._nextUint8(), | ||
for (let i = 0; i < numSamples; i ++) { | ||
dfd.samples[ i ] = { | ||
const sample = { | ||
bitOffset: dfdReader._nextUint16(), | ||
bitLength: dfdReader._nextUint8(), | ||
channelID: dfdReader._nextUint8(), | ||
channelType: dfdReader._nextUint8(), | ||
samplePosition: [ | ||
@@ -130,5 +131,15 @@ dfdReader._nextUint8(), | ||
], | ||
sampleLower: dfdReader._nextUint32(), | ||
sampleUpper: dfdReader._nextUint32(), | ||
sampleLower: -Infinity, | ||
sampleUpper: Infinity, | ||
}; | ||
if (sample.channelType & KHR_DF_SAMPLE_DATATYPE_SIGNED) { | ||
sample.sampleLower = dfdReader._nextInt32(); | ||
sample.sampleUpper = dfdReader._nextInt32(); | ||
} else { | ||
sample.sampleLower = dfdReader._nextUint32(); | ||
sample.sampleUpper = dfdReader._nextUint32(); | ||
} | ||
dfd.samples[ i ] = sample; | ||
} | ||
@@ -135,0 +146,0 @@ |
@@ -1,4 +0,4 @@ | ||
import { HEADER_BYTE_LENGTH, KTX2_ID, KTX_WRITER, NUL } from './constants'; | ||
import { HEADER_BYTE_LENGTH, KTX2_ID, KTX_WRITER, NUL } from './constants-internal'; | ||
import { KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT, KHR_DF_SAMPLE_DATATYPE_SIGNED } from './constants'; | ||
import { KTX2Container } from './container'; | ||
import { KTX2DescriptorType } from './enums'; | ||
import { concat, encodeText } from './util'; | ||
@@ -93,3 +93,3 @@ | ||
if (container.dataFormatDescriptor.length !== 1 | ||
|| container.dataFormatDescriptor[0].descriptorType !== KTX2DescriptorType.BASICFORMAT) { | ||
|| container.dataFormatDescriptor[0].descriptorType !== KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT) { | ||
throw new Error('Only BASICFORMAT Data Format Descriptor output supported.'); | ||
@@ -102,2 +102,3 @@ } | ||
const dfdView = new DataView(dfdBuffer); | ||
const descriptorBlockSize = 24 + dfd.samples.length * 16; | ||
@@ -108,3 +109,3 @@ dfdView.setUint32(0, dfdBuffer.byteLength, true); | ||
dfdView.setUint16(8, dfd.versionNumber, true); | ||
dfdView.setUint16(10, dfd.descriptorBlockSize, true); | ||
dfdView.setUint16(10, descriptorBlockSize, true); | ||
@@ -116,7 +117,11 @@ dfdView.setUint8(12, dfd.colorModel); | ||
dfdView.setUint8(16, dfd.texelBlockDimension.x - 1); | ||
dfdView.setUint8(17, dfd.texelBlockDimension.y - 1); | ||
dfdView.setUint8(18, dfd.texelBlockDimension.z - 1); | ||
dfdView.setUint8(19, dfd.texelBlockDimension.w - 1); | ||
if (!Array.isArray(dfd.texelBlockDimension)) { | ||
throw new Error('texelBlockDimension is now an array. For dimensionality `d`, set `d - 1`.'); | ||
} | ||
dfdView.setUint8(16, dfd.texelBlockDimension[0]); | ||
dfdView.setUint8(17, dfd.texelBlockDimension[1]); | ||
dfdView.setUint8(18, dfd.texelBlockDimension[2]); | ||
dfdView.setUint8(19, dfd.texelBlockDimension[3]); | ||
for (let i = 0; i < 8; i++) dfdView.setUint8(20 + i, dfd.bytesPlane[i]); | ||
@@ -128,5 +133,9 @@ | ||
if (sample.channelID) { | ||
throw new Error('channelID has been renamed to channelType.'); | ||
} | ||
dfdView.setUint16(sampleByteOffset + 0, sample.bitOffset, true); | ||
dfdView.setUint8(sampleByteOffset + 2, sample.bitLength); | ||
dfdView.setUint8(sampleByteOffset + 3, sample.channelID); | ||
dfdView.setUint8(sampleByteOffset + 3, sample.channelType); | ||
@@ -138,4 +147,9 @@ dfdView.setUint8(sampleByteOffset + 4, sample.samplePosition[0]); | ||
dfdView.setUint32(sampleByteOffset + 8, sample.sampleLower, true); | ||
dfdView.setUint32(sampleByteOffset + 12, sample.sampleUpper, true); | ||
if (sample.channelType & KHR_DF_SAMPLE_DATATYPE_SIGNED) { | ||
dfdView.setInt32(sampleByteOffset + 8, sample.sampleLower, true); | ||
dfdView.setInt32(sampleByteOffset + 12, sample.sampleUpper, true); | ||
} else { | ||
dfdView.setUint32(sampleByteOffset + 8, sample.sampleLower, true); | ||
dfdView.setUint32(sampleByteOffset + 12, sample.sampleUpper, true); | ||
} | ||
} | ||
@@ -150,3 +164,3 @@ | ||
const kvdByteOffset = dfdByteOffset + dfdBuffer.byteLength; | ||
let sgdByteOffset = kvdByteOffset + kvdBuffer.byteLength; | ||
let sgdByteOffset = sgdBuffer.byteLength > 0 ? kvdByteOffset + kvdBuffer.byteLength : 0; | ||
if (sgdByteOffset % 8) sgdByteOffset += 8 - (sgdByteOffset % 8); // align(8) | ||
@@ -162,3 +176,3 @@ | ||
let levelDataByteOffset = sgdByteOffset + sgdBuffer.byteLength; | ||
let levelDataByteOffset = (sgdByteOffset || (kvdByteOffset + kvdBuffer.byteLength)) + sgdBuffer.byteLength; | ||
for (let i = 0; i < container.levels.length; i++) { | ||
@@ -194,3 +208,3 @@ const level = container.levels[i]; | ||
headerView.setUint32(48, kvdBuffer.byteLength, true); | ||
headerView.setBigUint64(52, BigInt(sgdByteOffset), true); | ||
headerView.setBigUint64(52, BigInt(sgdBuffer.byteLength > 0 ? sgdByteOffset : 0), true); | ||
headerView.setBigUint64(60, BigInt(sgdBuffer.byteLength), true); | ||
@@ -209,3 +223,5 @@ | ||
kvdBuffer, | ||
new ArrayBuffer(sgdByteOffset - (kvdByteOffset + kvdBuffer.byteLength)), // align(8) | ||
sgdByteOffset > 0 | ||
? new ArrayBuffer(sgdByteOffset - (kvdByteOffset + kvdBuffer.byteLength)) // align(8) | ||
: new ArrayBuffer(0), | ||
sgdBuffer, | ||
@@ -212,0 +228,0 @@ ...levelData, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
219507
24
1422
15