PageSourceSearch

https://auramrcomp-b3pjowqc.manus.space/assets/basisTextureLoader-BPItgXz4.js

js auramrcomp-b3pjowqc.manus.space collected 2026-10-03 05:00:08 UTC 8,181 bytes, 1 lines download raw bytes

vendor: 8,181 bytes, line 1
1import{T as h,I as R,d as U}from"./index-0LhFotdt.js";function D(){const e={cTFETC1:0,cTFETC2:1,cTFBC1:2,cTFBC3:3,cTFBC7:6,cTFPVRTC1_4_RGB:8,cTFPVRTC1_4_RGBA:9,cTFASTC_4x4:10,cTFRGB565:14};let n=null;onmessage=t=>{if(t.data.action==="init"){if(t.data.url)try{importScripts(t.data.url)}catch(o){postMessage({action:"error",error:o})}n||(n=BASIS({wasmBinary:t.data.wasmBinary})),n!==null&&n.then(o=>{BASIS=o,o.initializeBasis(),postMessage({action:"init"})})}else if(t.data.action==="transcode"){const o=t.data.config,a=t.data.imageData,f=new BASIS.BasisFile(a),r=l(f);let d=t.data.ignoreSupportedFormats?null:s(t.data.config,r),p=!1;d===null&&(p=!0,d=r.hasAlpha?e.cTFBC3:e.cTFBC1);let g=!0;f.startTranscoding()||(g=!1);const T=[];for(let m=0;m<r.images.length&&g;m++){const F=r.images[m];if(o.loadSingleImage===void 0||o.loadSingleImage===m){let w=F.levels.length;o.loadMipmapLevels===!1&&(w=1);for(let u=0;u<w;u++){const y=F.levels[u],B=i(f,m,u,d,p);if(!B){g=!1;break}y.transcodedPixels=B,T.push(y.transcodedPixels.buffer)}}}f.close(),f.delete(),p&&(d=-1),g?postMessage({action:"transcode",success:g,id:t.data.id,fileInfo:r,format:d},T):postMessage({action:"transcode",success:g,id:t.data.id})}};function s(t,o){let a=null;return t.supportedCompressionFormats&&(t.supportedCompressionFormats.astc?a=e.cTFASTC_4x4:t.supportedCompressionFormats.bc7?a=e.cTFBC7:t.supportedCompressionFormats.s3tc?a=o.hasAlpha?e.cTFBC3:e.cTFBC1:t.supportedCompressionFormats.pvrtc?a=o.hasAlpha?e.cTFPVRTC1_4_RGBA:e.cTFPVRTC1_4_RGB:t.supportedCompressionFormats.etc2?a=e.cTFETC2:t.supportedCompressionFormats.etc1?a=e.cTFETC1:a=e.cTFRGB565),a}function l(t){const o=t.getHasAlpha(),a=t.getNumImages(),f=[];for(let d=0;d<a;d++){const p={levels:[]},g=t.getNumLevels(d);for(let T=0;T<g;T++){const m={width:t.getImageWidth(d,T),height:t.getImageHeight(d,T)};p.levels.push(m)}f.push(p)}return{hasAlpha:o,images:f}}function i(t,o,a,f,r){const d=t.getImageTranscodedSizeInBytes(o,a,f);let p=new Uint8Array(d);if(!t.transcodeImage(p,o,a,f,1,0))return null;if(r){const g=t.getImageWidth(o,a)+3&-4,T=t.getImageHeight(o,a)+3&-4;p=c(p,0,g,T)}return p}function c(t,o,a,f){const r=new Uint16Array(4),d=new Uint16Array(a*f),p=a/4,g=f/4;for(let T=0;T<g;T++)for(let m=0;m<p;m++){const F=o+8*(T*p+m);r[0]=t[F]|t[F+1]<<8,r[1]=t[F+2]|t[F+3]<<8,r[2]=(2*(r[0]&31)+1*(r[1]&31))/3|(2*(r[0]&2016)+1*(r[1]&2016))/3&2016|(2*(r[0]&63488)+1*(r[1]&63488))/3&63488,r[3]=(2*(r[1]&31)+1*(r[0]&31))/3|(2*(r[1]&2016)+1*(r[0]&2016))/3&2016|(2*(r[1]&63488)+1*(r[0]&63488))/3&63488;for(let w=0;w<4;w++){const u=t[F+4+w];let y=(T*4+w)*a+m*4;d[y++]=r[u&3],d[y++]=r[u>>2&3],d[y++]=r[u>>4&3],d[y++]=r[u>>6&3]}}return d}}async function W(e,n,s){return await new Promise((l,i)=>{const c=t=>{t.data.action==="init"?(e.removeEventListener("message",c),l(e)):t.data.action==="error"&&i(t.data.error||"error initializing worker")};e.addEventListener("message",c),e.postMessage({action:"init",url:s?h.GetBabylonScriptURL(s):void 0,wasmBinary:n},[n])})}var C;(function(e){e[e.cTFETC1=0]="cTFETC1",e[e.cTFETC2=1]="cTFETC2",e[e.cTFBC1=2]="cTFBC1",e[e.cTFBC3=3]="cTFBC3",e[e.cTFBC4=4]="cTFBC4",e[e.cTFBC5=5]="cTFBC5",e[e.cTFBC7=6]="cTFBC7",e[e.cTFPVRTC1_4_RGB=8]="cTFPVRTC1_4_RGB",e[e.cTFPVRTC1_4_RGBA=9]="cTFPVRTC1_4_RGBA",e[e.cTFASTC_4x4=10]="cTFASTC_4x4",e[e.cTFATC_RGB=11]="cTFATC_RGB",e[e.cTFATC_RGBA_INTERPOLATED_ALPHA=12]="cTFATC_RGBA_INTERPOLATED_ALPHA",e[e.cTFRGBA32=13]="cTFRGBA32",e[e.cTFRGB565=14]="cTFRGB565",e[e.cTFBGR565=15]="cTFBGR565",e[e.cTFRGBA4444=16]="cTFRGBA4444",e[e.cTFFXT1_RGB=17]="cTFFXT1_RGB",e[e.cTFPVRTC2_4_RGB=18]="cTFPVRTC2_4_RGB",e[e.cTFPVRTC2_4_RGBA=19]="cTFPVRTC2_4_RGBA",e[e.cTFETC2_EAC_R11=20]="cTFETC2_EAC_R11",e[e.cTFETC2_EAC_RG11=21]="cTFETC2_EAC_RG11"})(C||(C={}));const b={JSModuleURL:`${h._DefaultCdnUrl}/basisTranscoder/1/basis_transcoder.js`,WasmModuleURL:`${h._DefaultCdnUrl}/basisTranscoder/1/basis_transcoder.wasm`},V=(e,n)=>{let s;switch(e){case C.cTFETC1:s=36196;break;case C.cTFBC1:s=33776;break;case C.cTFBC4:s=33779;break;case C.cTFASTC_4x4:s=37808;break;case C.cTFETC2:s=37496;break;case C.cTFBC7:s=36492;break}if(s===void 0)throw"The chosen Basis transcoder format is not currently supported";return s};let G=null,L=null,k=0;const H=!1,x=async()=>(G||(G=new Promise((e,n)=>{L?e(L):h.LoadFileAsync(h.GetBabylonScriptURL(b.WasmModuleURL)).then(s=>{if(typeof URL!="function")return n("Basis transcoder requires an environment with a URL constructor");const l=URL.createObjectURL(new Blob([`(${D})()`],{type:"application/javascript"}));L=new Worker(l),W(L,s,b.JSModuleURL).then(e,n)}).catch(n)})),await G),_=async(e,n)=>{const s=e instanceof ArrayBuffer?new Uint8Array(e):e;return await new Promise((l,i)=>{x().then(()=>{const c=k++,t=a=>{a.data.action==="transcode"&&a.data.id===c&&(L.removeEventListener("message",t),a.data.success?l(a.data):i("Transcode is not supported on this device"))};L.addEventListener("message",t);const o=new Uint8Array(s.byteLength);o.set(new Uint8Array(s.buffer,s.byteOffset,s.byteLength)),L.postMessage({action:"transcode",id:c,imageData:o,config:n,ignoreSupportedFormats:H},[o.buffer])},c=>{i(c)})})},E=(e,n)=>{let s=n._gl?.TEXTURE_2D;e.isCube&&(s=n._gl?.TEXTURE_CUBE_MAP),n._bindTextureDirectly(s,e,!0)},P=(e,n)=>{const s=e.getEngine();for(let l=0;l<n.fileInfo.images.length;l++){const i=n.fileInfo.images[l].levels[0];if(e._invertVScale=e.invertY,n.format===-1||n.format===C.cTFRGB565)if(e.type=10,e.format=4,s._features.basisNeedsPOT&&(Math.log2(i.width)%1!==0||Math.log2(i.height)%1!==0)){const c=new R(s,2);e._invertVScale=e.invertY,c.type=10,c.format=4,c.width=i.width+3&-4,c.height=i.height+3&-4,E(c,s),s._uploadDataToTextureDirectly(c,new Uint16Array(i.transcodedPixels.buffer),l,0,4,!0),s._rescaleTexture(c,e,s.scenes[0],s._getInternalFormat(4),()=>{s._releaseTexture(c),E(e,s)})}else e._invertVScale=!e.invertY,e.width=i.width+3&-4,e.height=i.height+3&-4,e.samplingMode=2,E(e,s),s._uploadDataToTextureDirectly(e,new Uint16Array(i.transcodedPixels.buffer),l,0,4,!0);else{e.width=i.width,e.height=i.height,e.generateMipMaps=n.fileInfo.images[l].levels.length>1;const c=v.GetInternalFormatFromBasisFormat(n.format,s);e.format=c,E(e,s);const t=n.fileInfo.images[l].levels;for(let o=0;o<t.length;o++){const a=t[o];s._uploadCompressedDataToTextureDirectly(e,c,a.width,a.height,a.transcodedPixels,l,o)}s._features.basisNeedsPOT&&(Math.log2(e.width)%1!==0||Math.log2(e.height)%1!==0)&&(h.Warn("Loaded .basis texture width and height are not a power of two. Texture wrapping will be set to Texture.CLAMP_ADDRESSMODE as other modes are not supported with non power of two dimensions in webGL 1."),e._cachedWrapU=U.CLAMP_ADDRESSMODE,e._cachedWrapV=U.CLAMP_ADDRESSMODE)}}},v={JSModuleURL:b.JSModuleURL,WasmModuleURL:b.WasmModuleURL,GetInternalFormatFromBasisFormat:V,TranscodeAsync:_,LoadTextureFromTranscodeResult:P};Object.defineProperty(v,"JSModuleURL",{get:function(){return b.JSModuleURL},set:function(e){b.JSModuleURL=e}});Object.defineProperty(v,"WasmModuleURL",{get:function(){return b.WasmModuleURL},set:function(e){b.WasmModuleURL=e}});class M{constructor(){this.supportCascades=!1}loadCubeData(n,s,l,i,c){if(Array.isArray(n))return;const t=s.getEngine().getCaps(),o={supportedCompressionFormats:{etc1:!!t.etc1,s3tc:!!t.s3tc,pvrtc:!!t.pvrtc,etc2:!!t.etc2,astc:!!t.astc,bc7:!!t.bptc}};_(n,o).then(a=>{const f=a.fileInfo.images[0].levels.length>1&&s.generateMipMaps;P(s,a),s.getEngine()._setCubeMapTextureParams(s,f),s.isReady=!0,s.onLoadedObservable.notifyObservers(s),s.onLoadedObservable.clear(),i&&i()}).catch(a=>{h.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),s.isReady=!0,c&&c(a)})}loadData(n,s,l){const i=s.getEngine().getCaps(),c={supportedCompressionFormats:{etc1:!!i.etc1,s3tc:!!i.s3tc,pvrtc:!!i.pvrtc,etc2:!!i.etc2,astc:!!i.astc,bc7:!!i.bptc}};_(n,c).then(t=>{const o=t.fileInfo.images[0].levels[0],a=t.fileInfo.images[0].levels.length>1&&s.generateMipMaps;l(o.width,o.height,a,t.format!==-1,()=>{P(s,t)})}).catch(t=>{h.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),h.Warn(`Failed to transcode Basis file: ${t}`),l(0,0,!1,!1,()=>{},!0)})}}export{M as _BasisTextureLoader};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.