/** * @license * Cesium - https://github.com/CesiumGS/cesium * Version 1.99 * * Copyright 2011-2022 Cesium Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Columbus View (Pat. Pend.) * * Portions licensed separately. * See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details. */ define(["./defaultValue-135942ca","./WebGLConstants-fcb70ee3","./RuntimeError-f0dada00","./createTaskProcessorWorker"],(function(_,R,t,e){"use strict";const A={UNSIGNED_BYTE:R.WebGLConstants.UNSIGNED_BYTE,UNSIGNED_SHORT:R.WebGLConstants.UNSIGNED_SHORT,UNSIGNED_INT:R.WebGLConstants.UNSIGNED_INT,FLOAT:R.WebGLConstants.FLOAT,HALF_FLOAT:R.WebGLConstants.HALF_FLOAT_OES,UNSIGNED_INT_24_8:R.WebGLConstants.UNSIGNED_INT_24_8,UNSIGNED_SHORT_4_4_4_4:R.WebGLConstants.UNSIGNED_SHORT_4_4_4_4,UNSIGNED_SHORT_5_5_5_1:R.WebGLConstants.UNSIGNED_SHORT_5_5_5_1,UNSIGNED_SHORT_5_6_5:R.WebGLConstants.UNSIGNED_SHORT_5_6_5,toWebGLConstant:function(_,t){switch(_){case A.UNSIGNED_BYTE:return R.WebGLConstants.UNSIGNED_BYTE;case A.UNSIGNED_SHORT:return R.WebGLConstants.UNSIGNED_SHORT;case A.UNSIGNED_INT:return R.WebGLConstants.UNSIGNED_INT;case A.FLOAT:return R.WebGLConstants.FLOAT;case A.HALF_FLOAT:return t.webgl2?R.WebGLConstants.HALF_FLOAT:R.WebGLConstants.HALF_FLOAT_OES;case A.UNSIGNED_INT_24_8:return R.WebGLConstants.UNSIGNED_INT_24_8;case A.UNSIGNED_SHORT_4_4_4_4:return R.WebGLConstants.UNSIGNED_SHORT_4_4_4_4;case A.UNSIGNED_SHORT_5_5_5_1:return R.WebGLConstants.UNSIGNED_SHORT_5_5_5_1;case A.UNSIGNED_SHORT_5_6_5:return A.UNSIGNED_SHORT_5_6_5}},isPacked:function(_){return _===A.UNSIGNED_INT_24_8||_===A.UNSIGNED_SHORT_4_4_4_4||_===A.UNSIGNED_SHORT_5_5_5_1||_===A.UNSIGNED_SHORT_5_6_5},sizeInBytes:function(_){switch(_){case A.UNSIGNED_BYTE:return 1;case A.UNSIGNED_SHORT:case A.UNSIGNED_SHORT_4_4_4_4:case A.UNSIGNED_SHORT_5_5_5_1:case A.UNSIGNED_SHORT_5_6_5:case A.HALF_FLOAT:return 2;case A.UNSIGNED_INT:case A.FLOAT:case A.UNSIGNED_INT_24_8:return 4}},validate:function(_){return _===A.UNSIGNED_BYTE||_===A.UNSIGNED_SHORT||_===A.UNSIGNED_INT||_===A.FLOAT||_===A.HALF_FLOAT||_===A.UNSIGNED_INT_24_8||_===A.UNSIGNED_SHORT_4_4_4_4||_===A.UNSIGNED_SHORT_5_5_5_1||_===A.UNSIGNED_SHORT_5_6_5}};var T=Object.freeze(A);const O={DEPTH_COMPONENT:R.WebGLConstants.DEPTH_COMPONENT,DEPTH_STENCIL:R.WebGLConstants.DEPTH_STENCIL,ALPHA:R.WebGLConstants.ALPHA,RGB:R.WebGLConstants.RGB,RGBA:R.WebGLConstants.RGBA,LUMINANCE:R.WebGLConstants.LUMINANCE,LUMINANCE_ALPHA:R.WebGLConstants.LUMINANCE_ALPHA,RGB_DXT1:R.WebGLConstants.COMPRESSED_RGB_S3TC_DXT1_EXT,RGBA_DXT1:R.WebGLConstants.COMPRESSED_RGBA_S3TC_DXT1_EXT,RGBA_DXT3:R.WebGLConstants.COMPRESSED_RGBA_S3TC_DXT3_EXT,RGBA_DXT5:R.WebGLConstants.COMPRESSED_RGBA_S3TC_DXT5_EXT,RGB_PVRTC_4BPPV1:R.WebGLConstants.COMPRESSED_RGB_PVRTC_4BPPV1_IMG,RGB_PVRTC_2BPPV1:R.WebGLConstants.COMPRESSED_RGB_PVRTC_2BPPV1_IMG,RGBA_PVRTC_4BPPV1:R.WebGLConstants.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,RGBA_PVRTC_2BPPV1:R.WebGLConstants.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,RGBA_ASTC:R.WebGLConstants.COMPRESSED_RGBA_ASTC_4x4_WEBGL,RGB_ETC1:R.WebGLConstants.COMPRESSED_RGB_ETC1_WEBGL,RGB8_ETC2:R.WebGLConstants.COMPRESSED_RGB8_ETC2,RGBA8_ETC2_EAC:R.WebGLConstants.COMPRESSED_RGBA8_ETC2_EAC,RGBA_BC7:R.WebGLConstants.COMPRESSED_RGBA_BPTC_UNORM,componentsLength:function(_){switch(_){case O.RGB:return 3;case O.RGBA:return 4;case O.LUMINANCE_ALPHA:return 2;case O.ALPHA:case O.LUMINANCE:default:return 1}},validate:function(_){return _===O.DEPTH_COMPONENT||_===O.DEPTH_STENCIL||_===O.ALPHA||_===O.RGB||_===O.RGBA||_===O.LUMINANCE||_===O.LUMINANCE_ALPHA||_===O.RGB_DXT1||_===O.RGBA_DXT1||_===O.RGBA_DXT3||_===O.RGBA_DXT5||_===O.RGB_PVRTC_4BPPV1||_===O.RGB_PVRTC_2BPPV1||_===O.RGBA_PVRTC_4BPPV1||_===O.RGBA_PVRTC_2BPPV1||_===O.RGBA_ASTC||_===O.RGB_ETC1||_===O.RGB8_ETC2||_===O.RGBA8_ETC2_EAC||_===O.RGBA_BC7},isColorFormat:function(_){return _===O.ALPHA||_===O.RGB||_===O.RGBA||_===O.LUMINANCE||_===O.LUMINANCE_ALPHA},isDepthFormat:function(_){return _===O.DEPTH_COMPONENT||_===O.DEPTH_STENCIL},isCompressedFormat:function(_){return _===O.RGB_DXT1||_===O.RGBA_DXT1||_===O.RGBA_DXT3||_===O.RGBA_DXT5||_===O.RGB_PVRTC_4BPPV1||_===O.RGB_PVRTC_2BPPV1||_===O.RGBA_PVRTC_4BPPV1||_===O.RGBA_PVRTC_2BPPV1||_===O.RGBA_ASTC||_===O.RGB_ETC1||_===O.RGB8_ETC2||_===O.RGBA8_ETC2_EAC||_===O.RGBA_BC7},isDXTFormat:function(_){return _===O.RGB_DXT1||_===O.RGBA_DXT1||_===O.RGBA_DXT3||_===O.RGBA_DXT5},isPVRTCFormat:function(_){return _===O.RGB_PVRTC_4BPPV1||_===O.RGB_PVRTC_2BPPV1||_===O.RGBA_PVRTC_4BPPV1||_===O.RGBA_PVRTC_2BPPV1},isASTCFormat:function(_){return _===O.RGBA_ASTC},isETC1Format:function(_){return _===O.RGB_ETC1},isETC2Format:function(_){return _===O.RGB8_ETC2||_===O.RGBA8_ETC2_EAC},isBC7Format:function(_){return _===O.RGBA_BC7},compressedTextureSizeInBytes:function(_,R,t){switch(_){case O.RGB_DXT1:case O.RGBA_DXT1:case O.RGB_ETC1:case O.RGB8_ETC2:return Math.floor((R+3)/4)*Math.floor((t+3)/4)*8;case O.RGBA_DXT3:case O.RGBA_DXT5:case O.RGBA_ASTC:case O.RGBA8_ETC2_EAC:return Math.floor((R+3)/4)*Math.floor((t+3)/4)*16;case O.RGB_PVRTC_4BPPV1:case O.RGBA_PVRTC_4BPPV1:return Math.floor((Math.max(R,8)*Math.max(t,8)*4+7)/8);case O.RGB_PVRTC_2BPPV1:case O.RGBA_PVRTC_2BPPV1:return Math.floor((Math.max(R,16)*Math.max(t,8)*2+7)/8);case O.RGBA_BC7:return Math.ceil(R/4)*Math.ceil(t/4)*16;default:return 0}},textureSizeInBytes:function(_,R,t,e){let A=O.componentsLength(_);return T.isPacked(R)&&(A=1),A*T.sizeInBytes(R)*t*e},alignmentInBytes:function(_,R,t){const e=O.textureSizeInBytes(_,R,t,1)%4;return 0===e?4:2===e?2:1},createTypedArray:function(_,R,t,e){let A;const n=T.sizeInBytes(R);A=n===Uint8Array.BYTES_PER_ELEMENT?Uint8Array:n===Uint16Array.BYTES_PER_ELEMENT?Uint16Array:n===Float32Array.BYTES_PER_ELEMENT&&R===T.FLOAT?Float32Array:Uint32Array;return new A(O.componentsLength(_)*t*e)},flipY:function(_,R,t,e,A){if(1===A)return _;const T=O.createTypedArray(R,t,e,A),n=O.componentsLength(R),B=e*n;for(let R=0;R>O,K=R.pixelHeight>>O,C=G*K*n.componentsLength(e);for(let t=0;t0&&K>0&&C>0))throw M.close(),M.delete(),new t.RuntimeError("Invalid KTX2 file");let F,N;const i=e.dataFormatDescriptor[0],V=T.transcoder_texture_format;if(163===i.colorModel)if(A.etc)F=r?n.RGBA8_ETC2_EAC:n.RGB8_ETC2,N=r?V.cTFETC2_RGBA:V.cTFETC1_RGB;else if(A.etc1&&!r)F=n.RGB_ETC1,N=V.cTFETC1_RGB;else if(A.s3tc)F=r?n.RGBA_DXT5:n.RGB_DXT1,N=r?V.cTFBC3_RGBA:V.cTFBC1_RGB;else if(A.pvrtc)F=r?n.RGBA_PVRTC_4BPPV1:n.RGB_PVRTC_4BPPV1,N=r?V.cTFPVRTC1_4_RGBA:V.cTFPVRTC1_4_RGB;else if(A.astc)F=n.RGBA_ASTC,N=V.cTFASTC_4x4_RGBA;else{if(!A.bc7)throw new t.RuntimeError("No transcoding format target available for ETC1S compressed ktx2.");F=n.RGBA_BC7,N=V.cTFBC7_RGBA}else if(166===i.colorModel)if(A.astc)F=n.RGBA_ASTC,N=V.cTFASTC_4x4_RGBA;else if(A.bc7)F=n.RGBA_BC7,N=V.cTFBC7_RGBA;else if(A.s3tc)F=r?n.RGBA_DXT5:n.RGB_DXT1,N=r?V.cTFBC3_RGBA:V.cTFBC1_RGB;else if(A.etc)F=r?n.RGBA8_ETC2_EAC:n.RGB8_ETC2,N=r?V.cTFETC2_RGBA:V.cTFETC1_RGB;else if(A.etc1&&!r)F=n.RGB_ETC1,N=V.cTFETC1_RGB;else{if(!A.pvrtc)throw new t.RuntimeError("No transcoding format target available for UASTC compressed ktx2.");F=r?n.RGBA_PVRTC_4BPPV1:n.RGB_PVRTC_4BPPV1,N=r?V.cTFPVRTC1_4_RGBA:V.cTFPVRTC1_4_RGB}if(!M.startTranscoding())throw M.close(),M.delete(),new t.RuntimeError("startTranscoding() failed");for(let R=0;R>R,K=e.pixelHeight>>R;const T=M.getImageTranscodedSizeInBytes(R,0,0,N.value),n=new Uint8Array(T),C=M.transcodeImage(n,R,0,0,N.value,0,-1,-1);if(!_.defined(C))throw new t.RuntimeError("transcodeImage() failed.");O.push(n.buffer),A[s[0]]={internalFormat:F,width:G,height:K,levelBuffer:n}}M.close(),M.delete()}(A,F,O,r,e,i),i}function N(_){r=_,r.initializeBasis(),self.onmessage=e(F),self.postMessage(!0)}return function(R){const t=R.data.webAssemblyConfig;if(_.defined(t))return require([t.modulePath],(function(R){if(!_.defined(t.wasmBinaryFile))return R().then((function(_){N(_)}));_.defined(R)||(R=self.MSC_TRANSCODER),R(t).then((function(_){N(_)}))}))}}));