UNPKG

@babylonjs/viewer

Version:

The Babylon Viewer aims to simplify a specific but common Babylon.js use case: loading, viewing, and interacting with a 3D model.

3 lines (2 loc) 17.1 kB
import{y as e,aY as t,C as r}from"./index-BPURObVq.esm.min.js";import{A as s}from"./workerPool-DfuLEPTk.esm.min.js";class a{constructor(t,r){if(this.data=t,this.isInvalid=!1,!a.IsValid(t))return this.isInvalid=!0,void e.Error("texture missing KTX identifier");const s=Uint32Array.BYTES_PER_ELEMENT,o=new DataView(this.data.buffer,this.data.byteOffset+12,13*s),i=67305985===o.getUint32(0,!0);return this.glType=o.getUint32(1*s,i),this.glTypeSize=o.getUint32(2*s,i),this.glFormat=o.getUint32(3*s,i),this.glInternalFormat=o.getUint32(4*s,i),this.glBaseInternalFormat=o.getUint32(5*s,i),this.pixelWidth=o.getUint32(6*s,i),this.pixelHeight=o.getUint32(7*s,i),this.pixelDepth=o.getUint32(8*s,i),this.numberOfArrayElements=o.getUint32(9*s,i),this.numberOfFaces=o.getUint32(10*s,i),this.numberOfMipmapLevels=o.getUint32(11*s,i),this.bytesOfKeyValueData=o.getUint32(12*s,i),0!==this.glType?(e.Error("only compressed formats currently supported"),void(this.isInvalid=!0)):(this.numberOfMipmapLevels=Math.max(1,this.numberOfMipmapLevels),0===this.pixelHeight||0!==this.pixelDepth?(e.Error("only 2D textures currently supported"),void(this.isInvalid=!0)):0!==this.numberOfArrayElements?(e.Error("texture arrays not currently supported"),void(this.isInvalid=!0)):this.numberOfFaces!==r?(e.Error("number of faces expected"+r+", but found "+this.numberOfFaces),void(this.isInvalid=!0)):void(this.loadType=a.COMPRESSED_2D))}uploadLevels(e,t){if(this.loadType===a.COMPRESSED_2D)this._upload2DCompressedLevels(e,t)}_upload2DCompressedLevels(e,t){let r=a.HEADER_LEN+this.bytesOfKeyValueData,s=this.pixelWidth,o=this.pixelHeight;const i=t?this.numberOfMipmapLevels:1;for(let t=0;t<i;t++){const a=new Int32Array(this.data.buffer,this.data.byteOffset+r,1)[0];r+=4;for(let i=0;i<this.numberOfFaces;i++){const T=new Uint8Array(this.data.buffer,this.data.byteOffset+r,a);e.getEngine()._uploadCompressedDataToTextureDirectly(e,e.format,s,o,T,i,t),r+=a,r+=3-(a+3)%4}s=Math.max(1,.5*s),o=Math.max(1,.5*o)}}static IsValid(e){if(e.byteLength>=12){const t=new Uint8Array(e.buffer,e.byteOffset,12);if(171===t[0]&&75===t[1]&&84===t[2]&&88===t[3]&&32===t[4]&&49===t[5]&&49===t[6]&&187===t[7]&&13===t[8]&&10===t[9]&&26===t[10]&&10===t[11])return!0}return!1}}var o,i,T;function _(e,t){const r=t?.jsDecoderModule||KTX2DECODER;e&&(e.wasmBaseUrl&&(r.Transcoder.WasmBaseUrl=e.wasmBaseUrl),e.wasmUASTCToASTC&&(r.LiteTranscoder_UASTC_ASTC.WasmModuleURL=e.wasmUASTCToASTC),e.wasmUASTCToBC7&&(r.LiteTranscoder_UASTC_BC7.WasmModuleURL=e.wasmUASTCToBC7),e.wasmUASTCToRGBA_UNORM&&(r.LiteTranscoder_UASTC_RGBA_UNORM.WasmModuleURL=e.wasmUASTCToRGBA_UNORM),e.wasmUASTCToRGBA_SRGB&&(r.LiteTranscoder_UASTC_RGBA_SRGB.WasmModuleURL=e.wasmUASTCToRGBA_SRGB),e.wasmUASTCToR8_UNORM&&(r.LiteTranscoder_UASTC_R8_UNORM.WasmModuleURL=e.wasmUASTCToR8_UNORM),e.wasmUASTCToRG8_UNORM&&(r.LiteTranscoder_UASTC_RG8_UNORM.WasmModuleURL=e.wasmUASTCToRG8_UNORM),e.jsMSCTranscoder&&(r.MSCTranscoder.JSModuleURL=e.jsMSCTranscoder),e.wasmMSCTranscoder&&(r.MSCTranscoder.WasmModuleURL=e.wasmMSCTranscoder),e.wasmZSTDDecoder&&(r.ZSTDDecoder.WasmModuleURL=e.wasmZSTDDecoder)),t&&(t.wasmUASTCToASTC&&(r.LiteTranscoder_UASTC_ASTC.WasmBinary=t.wasmUASTCToASTC),t.wasmUASTCToBC7&&(r.LiteTranscoder_UASTC_BC7.WasmBinary=t.wasmUASTCToBC7),t.wasmUASTCToRGBA_UNORM&&(r.LiteTranscoder_UASTC_RGBA_UNORM.WasmBinary=t.wasmUASTCToRGBA_UNORM),t.wasmUASTCToRGBA_SRGB&&(r.LiteTranscoder_UASTC_RGBA_SRGB.WasmBinary=t.wasmUASTCToRGBA_SRGB),t.wasmUASTCToR8_UNORM&&(r.LiteTranscoder_UASTC_R8_UNORM.WasmBinary=t.wasmUASTCToR8_UNORM),t.wasmUASTCToRG8_UNORM&&(r.LiteTranscoder_UASTC_RG8_UNORM.WasmBinary=t.wasmUASTCToRG8_UNORM),t.jsMSCTranscoder&&(r.MSCTranscoder.JSModule=t.jsMSCTranscoder),t.wasmMSCTranscoder&&(r.MSCTranscoder.WasmBinary=t.wasmMSCTranscoder),t.wasmZSTDDecoder&&(r.ZSTDDecoder.WasmBinary=t.wasmZSTDDecoder))}function n(e){let t;void 0===e&&"undefined"!=typeof KTX2DECODER&&(e=KTX2DECODER),onmessage=r=>{if(r.data)switch(r.data.action){case"init":{const s=r.data.urls;s&&(s.jsDecoderModule&&void 0===e&&(importScripts(s.jsDecoderModule),e=KTX2DECODER),_(s)),r.data.wasmBinaries&&_(void 0,{...r.data.wasmBinaries,jsDecoderModule:e}),t=new e.KTX2Decoder,postMessage({action:"init"});break}case"setDefaultDecoderOptions":e.KTX2Decoder.DefaultDecoderOptions=r.data.options;break;case"decode":t.decode(r.data.data,r.data.caps,r.data.options).then(e=>{const t=[];for(let r=0;r<e.mipmaps.length;++r){const s=e.mipmaps[r];s&&s.data&&t.push(s.data.buffer)}postMessage({action:"decoded",success:!0,decodedData:e},t)}).catch(e=>{postMessage({action:"decoded",success:!1,msg:e})})}}}a.HEADER_LEN=64,a.COMPRESSED_2D=0,a.COMPRESSED_3D=1,a.TEX_2D=2,a.TEX_3D=3,function(e){e[e.ETC1S=0]="ETC1S",e[e.UASTC4x4=1]="UASTC4x4",e[e.RGBA32=2]="RGBA32"}(o||(o={})),function(e){e[e.ASTC_4X4_RGBA=0]="ASTC_4X4_RGBA",e[e.ASTC_4x4_RGBA=0]="ASTC_4x4_RGBA",e[e.BC7_RGBA=1]="BC7_RGBA",e[e.BC3_RGBA=2]="BC3_RGBA",e[e.BC1_RGB=3]="BC1_RGB",e[e.PVRTC1_4_RGBA=4]="PVRTC1_4_RGBA",e[e.PVRTC1_4_RGB=5]="PVRTC1_4_RGB",e[e.ETC2_RGBA=6]="ETC2_RGBA",e[e.ETC1_RGB=7]="ETC1_RGB",e[e.RGBA32=8]="RGBA32",e[e.R8=9]="R8",e[e.RG8=10]="RG8"}(i||(i={})),function(e){e[e.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",e[e.COMPRESSED_RGBA_ASTC_4X4_KHR=37808]="COMPRESSED_RGBA_ASTC_4X4_KHR",e[e.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",e[e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",e[e.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",e[e.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",e[e.RGBA8Format=32856]="RGBA8Format",e[e.R8Format=33321]="R8Format",e[e.RG8Format=33323]="RG8Format"}(T||(T={}));class R{static GetDefaultNumWorkers(){return"object"==typeof navigator&&navigator.hardwareConcurrency?Math.min(Math.floor(.5*navigator.hardwareConcurrency),4):1}static _Initialize(e){if(R._WorkerPoolPromise||R._DecoderModulePromise)return;const r={wasmBaseUrl:t.ScriptBaseUrl,jsDecoderModule:t.GetBabylonScriptURL(this.URLConfig.jsDecoderModule,!0),wasmUASTCToASTC:t.GetBabylonScriptURL(this.URLConfig.wasmUASTCToASTC,!0),wasmUASTCToBC7:t.GetBabylonScriptURL(this.URLConfig.wasmUASTCToBC7,!0),wasmUASTCToRGBA_UNORM:t.GetBabylonScriptURL(this.URLConfig.wasmUASTCToRGBA_UNORM,!0),wasmUASTCToRGBA_SRGB:t.GetBabylonScriptURL(this.URLConfig.wasmUASTCToRGBA_SRGB,!0),wasmUASTCToR8_UNORM:t.GetBabylonScriptURL(this.URLConfig.wasmUASTCToR8_UNORM,!0),wasmUASTCToRG8_UNORM:t.GetBabylonScriptURL(this.URLConfig.wasmUASTCToRG8_UNORM,!0),jsMSCTranscoder:t.GetBabylonScriptURL(this.URLConfig.jsMSCTranscoder,!0),wasmMSCTranscoder:t.GetBabylonScriptURL(this.URLConfig.wasmMSCTranscoder,!0),wasmZSTDDecoder:t.GetBabylonScriptURL(this.URLConfig.wasmZSTDDecoder,!0)};e&&"function"==typeof Worker&&"undefined"!=typeof URL?R._WorkerPoolPromise=new Promise(t=>{const a=`${_}(${n})()`,o=URL.createObjectURL(new Blob([a],{type:"application/javascript"}));t(new s(e,async()=>await async function(e,t,r){return await new Promise((s,a)=>{const o=t=>{e.removeEventListener("error",o),e.removeEventListener("message",i),a(t)},i=t=>{"init"===t.data.action&&(e.removeEventListener("error",o),e.removeEventListener("message",i),s(e))};e.addEventListener("error",o),e.addEventListener("message",i),e.postMessage({action:"init",urls:r,wasmBinaries:t})})}(new Worker(o),void 0,r)))}):void 0===R._KTX2DecoderModule?R._DecoderModulePromise=t.LoadBabylonScriptAsync(r.jsDecoderModule).then(()=>(R._KTX2DecoderModule=KTX2DECODER,R._KTX2DecoderModule.MSCTranscoder.UseFromWorkerThread=!1,R._KTX2DecoderModule.WASMMemoryManager.LoadBinariesFromCurrentThread=!0,_(r,R._KTX2DecoderModule),new R._KTX2DecoderModule.KTX2Decoder)):(R._KTX2DecoderModule.MSCTranscoder.UseFromWorkerThread=!1,R._KTX2DecoderModule.WASMMemoryManager.LoadBinariesFromCurrentThread=!0,R._DecoderModulePromise=Promise.resolve(new R._KTX2DecoderModule.KTX2Decoder))}constructor(e,t=R.DefaultNumWorkers){this._engine=e;const r="object"==typeof t&&t.workerPool||R.WorkerPool;if(r)R._WorkerPoolPromise=Promise.resolve(r);else{"object"==typeof t?R._KTX2DecoderModule=t?.binariesAndModulesContainer?.jsDecoderModule:"undefined"!=typeof KTX2DECODER&&(R._KTX2DecoderModule=KTX2DECODER);const e="number"==typeof t?t:t.numWorkers??R.DefaultNumWorkers;R._Initialize(e)}}async _uploadAsync(e,t,r){const s=await this._decodeAsync(e,r);this._createTexture(s,t,r)}async _decodeAsync(e,t){const r=this._engine.getCaps(),s={astc:!!r.astc,bptc:!!r.bptc,s3tc:!!r.s3tc,pvrtc:!!r.pvrtc,etc2:!!r.etc2,etc1:!!r.etc1};if(R._WorkerPoolPromise){const r=await R._WorkerPoolPromise;return await new Promise((a,o)=>{r.push((r,i)=>{const T=e=>{r.removeEventListener("error",T),r.removeEventListener("message",_),o(e),i()},_=e=>{"decoded"===e.data.action&&(r.removeEventListener("error",T),r.removeEventListener("message",_),e.data.success?a(e.data.decodedData):o({message:e.data.msg}),i())};r.addEventListener("error",T),r.addEventListener("message",_),r.postMessage({action:"setDefaultDecoderOptions",options:R.DefaultDecoderOptions._getKTX2DecoderOptions()});const n=new Uint8Array(e.byteLength);n.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),r.postMessage({action:"decode",data:n,caps:s,options:t},[n.buffer])})})}if(R._DecoderModulePromise){const s=await R._DecoderModulePromise;return R.DefaultDecoderOptions.isDirty&&(R._KTX2DecoderModule.KTX2Decoder.DefaultDecoderOptions=R.DefaultDecoderOptions._getKTX2DecoderOptions()),await new Promise((a,o)=>{s.decode(e,r,t).then(e=>{a(e)}).catch(e=>{o({message:e})})})}throw new Error("KTX2 decoder module is not available")}_createTexture(e,t,s){if((e.layerCount??1)>1)throw new Error("KTX2 container - array textures are not supported by this texture loader.");this._engine._bindTextureDirectly(3553,t),s&&(s.transcodedFormat=e.transcodedFormat,s.isInGammaSpace=e.isInGammaSpace,s.hasAlpha=e.hasAlpha,s.transcoderName=e.transcoderName);let a=!0;switch(e.transcodedFormat){case 32856:t.type=r.TEXTURETYPE_UNSIGNED_BYTE,t.format=r.TEXTUREFORMAT_RGBA;break;case 33321:t.type=r.TEXTURETYPE_UNSIGNED_BYTE,t.format=r.TEXTUREFORMAT_R;break;case 33323:t.type=r.TEXTURETYPE_UNSIGNED_BYTE,t.format=r.TEXTUREFORMAT_RG;break;default:t.format=e.transcodedFormat,a=!1}if(t._gammaSpace=e.isInGammaSpace,t.generateMipMaps=e.mipmaps.length>1,t.width=e.mipmaps[0].width,t.height=e.mipmaps[0].height,e.errors)throw new Error("KTX2 container - could not transcode the data. "+e.errors);for(let r=0;r<e.mipmaps.length;++r){const s=e.mipmaps[r];if(!s||!s.data)throw new Error("KTX2 container - could not transcode one of the image");a?(t.width=s.width,t.height=s.height,this._engine._uploadDataToTextureDirectly(t,s.data,0,r,void 0,!0)):this._engine._uploadCompressedDataToTextureDirectly(t,e.transcodedFormat,s.width,s.height,s.data,0,r)}t._extension=".ktx2",t.isReady=!0,this._engine._bindTextureDirectly(3553,null)}static IsValid(e){if(e.byteLength>=12){const t=new Uint8Array(e.buffer,e.byteOffset,12);if(171===t[0]&&75===t[1]&&84===t[2]&&88===t[3]&&32===t[4]&&50===t[5]&&48===t[6]&&187===t[7]&&13===t[8]&&10===t[9]&&26===t[10]&&10===t[11])return!0}return!1}}function S(e){switch(e){case r.TEXTUREFORMAT_COMPRESSED_SRGB_S3TC_DXT1_EXT:return r.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1;case r.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:return r.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3;case r.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:return r.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5;case r.TEXTUREFORMAT_COMPRESSED_SRGB8_ETC2:return r.TEXTUREFORMAT_COMPRESSED_RGB8_ETC2;case r.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:return r.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC;case r.TEXTUREFORMAT_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:return r.TEXTUREFORMAT_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;case r.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:return r.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4;case r.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:return r.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_5x4;case r.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:return r.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_5x5;case r.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:return r.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_6x5;case r.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:return r.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_6x6;case r.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:return r.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_8x5;case r.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:return r.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_8x6;case r.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:return r.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_8x8;case r.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:return r.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_10x5;case r.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:return r.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_10x6;case r.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:return r.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_10x8;case r.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:return r.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_10x10;case r.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:return r.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_12x10;case r.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:return r.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_12x12;case r.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_BPTC_UNORM:return r.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM}return null}R.URLConfig={jsDecoderModule:"https://cdn.babylonjs.com/babylon.ktx2Decoder.js",wasmUASTCToASTC:null,wasmUASTCToBC7:null,wasmUASTCToRGBA_UNORM:null,wasmUASTCToRGBA_SRGB:null,wasmUASTCToR8_UNORM:null,wasmUASTCToRG8_UNORM:null,jsMSCTranscoder:null,wasmMSCTranscoder:null,wasmZSTDDecoder:null},R.DefaultNumWorkers=R.GetDefaultNumWorkers(),R.DefaultDecoderOptions=new class{constructor(){this._isDirty=!0,this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC=!0,this._ktx2DecoderOptions={}}get isDirty(){return this._isDirty}get useRGBAIfASTCBC7NotAvailableWhenUASTC(){return this._useRGBAIfASTCBC7NotAvailableWhenUASTC}set useRGBAIfASTCBC7NotAvailableWhenUASTC(e){this._useRGBAIfASTCBC7NotAvailableWhenUASTC!==e&&(this._useRGBAIfASTCBC7NotAvailableWhenUASTC=e,this._isDirty=!0)}get useRGBAIfOnlyBC1BC3AvailableWhenUASTC(){return this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC}set useRGBAIfOnlyBC1BC3AvailableWhenUASTC(e){this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC!==e&&(this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC=e,this._isDirty=!0)}get forceRGBA(){return this._forceRGBA}set forceRGBA(e){this._forceRGBA!==e&&(this._forceRGBA=e,this._isDirty=!0)}get forceR8(){return this._forceR8}set forceR8(e){this._forceR8!==e&&(this._forceR8=e,this._isDirty=!0)}get forceRG8(){return this._forceRG8}set forceRG8(e){this._forceRG8!==e&&(this._forceRG8=e,this._isDirty=!0)}get bypassTranscoders(){return this._bypassTranscoders}set bypassTranscoders(e){this._bypassTranscoders!==e&&(this._bypassTranscoders=e,this._isDirty=!0)}_getKTX2DecoderOptions(){if(!this._isDirty)return this._ktx2DecoderOptions;this._isDirty=!1;const e={};return void 0!==this._useRGBAIfASTCBC7NotAvailableWhenUASTC&&(e.useRGBAIfASTCBC7NotAvailableWhenUASTC=this._useRGBAIfASTCBC7NotAvailableWhenUASTC),void 0!==this._forceRGBA&&(e.forceRGBA=this._forceRGBA),void 0!==this._forceR8&&(e.forceR8=this._forceR8),void 0!==this._forceRG8&&(e.forceRG8=this._forceRG8),void 0!==this._bypassTranscoders&&(e.bypassTranscoders=this._bypassTranscoders),this.useRGBAIfOnlyBC1BC3AvailableWhenUASTC&&(e.transcodeFormatDecisionTree={UASTC:{transcodeFormat:[i.BC1_RGB,i.BC3_RGBA],yes:{transcodeFormat:i.RGBA32,engineFormat:32856,roundToMultiple4:!1}}}),this._ktx2DecoderOptions=e,e}};class A{constructor(){this.supportCascades=!1}loadCubeData(e,t,r,s){if(Array.isArray(e))return;t._invertVScale=!t.invertY;const o=t.getEngine(),i=new a(e,6),T=S(i.glInternalFormat);null!==T?(t.format=T,t._useSRGBBuffer=o._getUseSRGBBuffer(!0,!t.generateMipMaps),t._gammaSpace=!0):t.format=i.glInternalFormat;const _=i.numberOfMipmapLevels>1&&t.generateMipMaps;o._unpackFlipY(!0),i.uploadLevels(t,t.generateMipMaps),t.width=i.pixelWidth,t.height=i.pixelHeight,o._setCubeMapTextureParams(t,_,i.numberOfMipmapLevels-1),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),s&&s()}loadData(t,r,s,o){if(a.IsValid(t)){r._invertVScale=!r.invertY;const e=new a(t,1),o=S(e.glInternalFormat);null!==o?(r.format=o,r._useSRGBBuffer=r.getEngine()._getUseSRGBBuffer(!0,!r.generateMipMaps),r._gammaSpace=!0):r.format=e.glInternalFormat,s(e.pixelWidth,e.pixelHeight,r.generateMipMaps,!0,()=>{e.uploadLevels(r,r.generateMipMaps)},e.isInvalid)}else if(R.IsValid(t)){new R(r.getEngine())._uploadAsync(t,r,o).then(()=>{s(r.width,r.height,r.generateMipMaps,!0,()=>{},!1)},t=>{e.Warn(`Failed to load KTX2 texture data: ${t.message}`),s(0,0,!1,!1,()=>{},!0)})}else e.Error("texture missing KTX identifier"),s(0,0,!1,!1,()=>{},!0)}}export{A as _KTXTextureLoader}; //# sourceMappingURL=ktxTextureLoader-Bb92Jc4W.esm.min.js.map