1import{_ as J,c as R,O as Ie,d as Le,V as Z,M as y,e as V,f as ye,E as Be,I as Ue,P as Fe,B as Pe,g as A,G as Ge,s as w,h as S,i as De,b as Ve}from"./index-nSxm2Zdt.js";function we(e,o,s=!1){const u=o.width,l=o.height;if(e instanceof Float32Array){let g=e.byteLength/e.BYTES_PER_ELEMENT;const f=new Uint8Array(g);for(;--g>=0;){let m=e[g];m<0?m=0:m>1&&(m=1),f[g]=m*255}e=f}const d=document.createElement("canvas");d.width=u,d.height=l;const a=d.getContext("2d");if(!a)return null;const h=a.createImageData(u,l);if(h.data.set(e),a.putImageData(h,0,0),s){const g=document.createElement("canvas");g.width=u,g.height=l;const f=g.getContext("2d");return f?(f.translate(0,l),f.scale(1,-1),f.drawImage(d,0,0),g.toDataURL("image/png")):null}return d.toDataURL("image/png")}function Se(e,o=0,s=0){const u=e.getInternalTexture();if(!u)return null;const l=e._readPixelsSync(o,s);return l?we(l,e.getSize(),u.invertY):null}async function Oe(e,o=0,s=0){const u=e.getInternalTexture();if(!u)return null;const l=await e.readPixels(o,s);return l?we(l,e.getSize(),u.invertY):null}let Ae=(()=>{var e;let o=Pe,s=[],u,l=[],d=[],a,h=[],c=[],g,f=[],m=[],x,I=[],M=[],L,U=[],P=[],B,G=[],W=[],oe,le=[],ce=[],he,fe=[],de=[],ue,_e=[],ge=[],me,Re=[],Te=[],Ce,Ee=[],pe=[],xe,Me=[],ve=[],be;return e=class extends o{static _CreateVideoTexture(t,i,n,T=!1,v=!1,b=e.TRILINEAR_SAMPLINGMODE,F={},_,r=5){throw J("VideoTexture")}get noMipmap(){return this._noMipmap}get mimeType(){return this._mimeType}set isBlocking(t){this._isBlocking=t}get isBlocking(){return this._isBlocking}get invertY(){return this._invertY}constructor(t,i,n,T,v=e.TRILINEAR_SAMPLINGMODE,b=null,F=null,_=null,r=!1,C,p,O,K,ee){super(i),this.url=(R(this,s),R(this,l,null)),this.uOffset=(R(this,d),R(this,h,0)),this.vOffset=(R(this,c),R(this,f,0)),this.uScale=(R(this,m),R(this,I,1)),this.vScale=(R(this,M),R(this,U,1)),this.uAng=(R(this,P),R(this,G,0)),this.vAng=(R(this,W),R(this,le,0)),this.wAng=(R(this,ce),R(this,fe,0)),this.uRotationCenter=(R(this,de),R(this,_e,.5)),this.vRotationCenter=(R(this,ge),R(this,Re,.5)),this.wRotationCenter=(R(this,Te),R(this,Ee,.5)),this.homogeneousRotationInUVTransform=(R(this,pe),R(this,Me,!1)),this.inspectableCustomProperties=(R(this,ve),null),this._noMipmap=!1,this._invertY=!1,this._rowGenerationMatrix=null,this._cachedTextureMatrix=null,this._projectionModeMatrix=null,this._t0=null,this._t1=null,this._t2=null,this._cachedUOffset=-1,this._cachedVOffset=-1,this._cachedUScale=0,this._cachedVScale=0,this._cachedUAng=-1,this._cachedVAng=-1,this._cachedWAng=-1,this._cachedReflectionProjectionMatrixId=-1,this._cachedURotationCenter=-1,this._cachedVRotationCenter=-1,this._cachedWRotationCenter=-1,this._cachedHomogeneousRotationInUVTransform=!1,this._cachedIdentity3x2=!0,this._cachedReflectionTextureMatrix=null,this._cachedReflectionUOffset=-1,this._cachedReflectionVOffset=-1,this._cachedReflectionUScale=0,this._cachedReflectionVScale=0,this._cachedReflectionCoordinatesMode=-1,this._buffer=null,this._deleteBuffer=!1,this._format=null,this._delayedOnLoad=null,this._delayedOnError=null,this.onLoadObservable=new Ie,this._isBlocking=!0,this.name=t||"",this.url=t;let k,X=!1,te=null,ie=!0;typeof n=="object"&&n!==null?(k=n.noMipmap??!1,T=n.invertY??!0,v=n.samplingMode??e.TRILINEAR_SAMPLINGMODE,b=n.onLoad??null,F=n.onError??null,_=n.buffer??null,r=n.deleteBuffer??!1,C=n.format,p=n.mimeType,O=n.loaderOptions,K=n.creationFlags,X=n.useSRGBBuffer??!1,te=n.internalTexture??null,ie=n.gammaSpace??ie,ee=n.forcedExtension??ee):k=!!n,this._gammaSpace=ie,this._noMipmap=k,this._invertY=T===void 0?!0:T,this._initialSamplingMode=v,this._buffer=_,this._deleteBuffer=r,this._mimeType=p,this._loaderOptions=O,this._creationFlags=K,this._useSRGBBuffer=X,this._forcedExtension=ee,C!==void 0&&(this._format=C);const Y=this.getScene(),ae=this._getEngine();if(!ae)return;ae.onBeforeTextureInitObservable.notifyObservers(this);const j=()=>{this._texture&&(this._texture._invertVScale&&(this.vScale*=-1,this.vOffset+=1),this._texture._cachedWrapU!==null&&(this.wrapU=this._texture._cachedWrapU,this._texture._cachedWrapU=null),this._texture._cachedWrapV!==null&&(this.wrapV=this._texture._cachedWrapV,this._texture._cachedWrapV=null),this._texture._cachedWrapR!==null&&(this.wrapR=this._texture._cachedWrapR,this._texture._cachedWrapR=null)),this.onLoadObservable.hasObservers()&&this.onLoadObservable.notifyObservers(this),b&&b(),!this.isBlocking&&Y&&Y.resetCachedMaterial()},H=(N,q)=>{this._loadingError=!0,this._errorObject={message:N,exception:q},F&&F(N,q),e.OnTextureLoadErrorObservable.notifyObservers(this)};if(!this.url&&!te){this._delayedOnLoad=j,this._delayedOnError=H;return}if(this._texture=te??this._getFromCache(this.url,k,v,this._invertY,X,this.isCube),this._texture)if(this._texture.isReady)Le.SetImmediate(()=>j());else{const N=this._texture.onLoadedObservable.add(j);this._texture.onErrorObservable.add(q=>{H(q.message,q.exception),this._texture?.onLoadedObservable.remove(N)})}else if(!Y||!Y.useDelayedTextureLoading){try{this._texture=ae.createTexture(this.url,k,this._invertY,Y,v,j,H,this._buffer,void 0,this._format,this._forcedExtension,p,O,K,X)}catch(N){throw H("error loading",N),N}r&&(this._buffer=null)}else this.delayLoadState=4,this._delayedOnLoad=j,this._delayedOnError=H}updateURL(t,i=null,n,T){this.url&&(this.releaseInternalTexture(),this.get
1Scene().markAllMaterialsAsDirty(1,F=>F.hasTexture(this))),(!this.name||this.name.startsWith("data:"))&&(this.name=t),this.url=t,this._buffer=i,this._forcedExtension=T,this.delayLoadState=4;const v=this._delayedOnLoad,b=()=>{v?v():this.onLoadObservable.hasObservers()&&this.onLoadObservable.notifyObservers(this),n&&n()};this._delayedOnLoad=b,this.delayLoad()}delayLoad(){if(this.delayLoadState!==4)return;const t=this.getScene();if(!t)return;let i=this.url;!i&&(this.name.indexOf("://")>0||this.name.startsWith("data:"))&&(i=this.name),this.delayLoadState=1,this._texture=this._getFromCache(i,this._noMipmap,this.samplingMode,this._invertY,this._useSRGBBuffer,this.isCube),this._texture?this._delayedOnLoad&&(this._texture.isReady?Le.SetImmediate(this._delayedOnLoad):this._texture.onLoadedObservable.add(this._delayedOnLoad)):(this._texture=t.getEngine().createTexture(i,this._noMipmap,this._invertY,t,this.samplingMode,this._delayedOnLoad,this._delayedOnError,this._buffer,null,this._format,this._forcedExtension,this._mimeType,this._loaderOptions,this._creationFlags,this._useSRGBBuffer),this._deleteBuffer&&(this._buffer=null)),this._delayedOnLoad=null,this._delayedOnError=null}_prepareRowForTextureGeneration(t,i,n,T){t*=this._cachedUScale,i*=this._cachedVScale,t-=this.uRotationCenter*this._cachedUScale,i-=this.vRotationCenter*this._cachedVScale,n-=this.wRotationCenter,Z.TransformCoordinatesFromFloatsToRef(t,i,n,this._rowGenerationMatrix,T),T.x+=this.uRotationCenter*this._cachedUScale+this._cachedUOffset,T.y+=this.vRotationCenter*this._cachedVScale+this._cachedVOffset,T.z+=this.wRotationCenter}getTextureMatrix(t=1){if(this.uOffset===this._cachedUOffset&&this.vOffset===this._cachedVOffset&&this.uScale*t===this._cachedUScale&&this.vScale===this._cachedVScale&&this.uAng===this._cachedUAng&&this.vAng===this._cachedVAng&&this.wAng===this._cachedWAng&&this.uRotationCenter===this._cachedURotationCenter&&this.vRotationCenter===this._cachedVRotationCenter&&this.wRotationCenter===this._cachedWRotationCenter&&this.homogeneousRotationInUVTransform===this._cachedHomogeneousRotationInUVTransform)return this._cachedTextureMatrix;this._cachedUOffset=this.uOffset,this._cachedVOffset=this.vOffset,this._cachedUScale=this.uScale*t,this._cachedVScale=this.vScale,this._cachedUAng=this.uAng,this._cachedVAng=this.vAng,this._cachedWAng=this.wAng,this._cachedURotationCenter=this.uRotationCenter,this._cachedVRotationCenter=this.vRotationCenter,this._cachedWRotationCenter=this.wRotationCenter,this._cachedHomogeneousRotationInUVTransform=this.homogeneousRotationInUVTransform,(!this._cachedTextureMatrix||!this._rowGenerationMatrix)&&(this._cachedTextureMatrix=y.Zero(),this._rowGenerationMatrix=new y,this._t0=Z.Zero(),this._t1=Z.Zero(),this._t2=Z.Zero()),y.RotationYawPitchRollToRef(this.vAng,this.uAng,this.wAng,this._rowGenerationMatrix),this.homogeneousRotationInUVTransform?(y.TranslationToRef(-this._cachedURotationCenter,-this._cachedVRotationCenter,-this._cachedWRotationCenter,V.Matrix[0]),y.TranslationToRef(this._cachedURotationCenter,this._cachedVRotationCenter,this._cachedWRotationCenter,V.Matrix[1]),y.ScalingToRef(this._cachedUScale,this._cachedVScale,0,V.Matrix[2]),y.TranslationToRef(this._cachedUOffset,this._cachedVOffset,0,V.Matrix[3]),V.Matrix[0].multiplyToRef(this._rowGenerationMatrix,this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(V.Matrix[1],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(V.Matrix[2],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(V.Matrix[3],this._cachedTextureMatrix),this._cachedTextureMatrix.setRowFromFloats(2,this._cachedTextureMatrix.m[12],this._cachedTextureMatrix.m[13],this._cachedTextureMatrix.m[14],1)):(this._prepareRowForTextureGeneration(0,0,0,this._t0),this._prepareRowForTextureGeneration(1,0,0,this._t1),this._prepareRowForTextureGeneration(0,1,0,this._t2),this._t1.subtractInPlace(this._t0),this._t2.subtractInPlace(this._t0),y.FromValuesToRef(this._t1.x,this._t1.y,this._t1.z,0,this._t2.x,this._t2.y,this._t2.z,0,this._t0.x,this._t0.y,this._t0.z,0,0,0,0,1,this._cachedTextureMatrix));const i=this.getScene();if(!i)return this._cachedTextureMatrix;const n=this._cachedIdentity3x2;return this._cachedIdentity3x2=this._cachedTextureMatrix.isIdentityAs3x2(
vendor: 5,719 bytes, line 1
1),this.optimizeUVAllocation&&n!==this._cachedIdentity3x2&&i.markAllMaterialsAsDirty(1,T=>T.hasTexture(this)),this._cachedTextureMatrix}getReflectionTextureMatrix(){const t=this.getScene();if(!t)return this._cachedReflectionTextureMatrix;if(this.uOffset===this._cachedReflectionUOffset&&this.vOffset===this._cachedReflectionVOffset&&this.uScale===this._cachedReflectionUScale&&this.vScale===this._cachedReflectionVScale&&this.coordinatesMode===this._cachedReflectionCoordinatesMode)if(this.coordinatesMode===e.PROJECTION_MODE){if(this._cachedReflectionProjectionMatrixId===t.getProjectionMatrix().updateFlag)return this._cachedReflectionTextureMatrix}else return this._cachedReflectionTextureMatrix;this._cachedReflectionTextureMatrix||(this._cachedReflectionTextureMatrix=y.Zero()),this._projectionModeMatrix||(this._projectionModeMatrix=y.Zero());const i=this._cachedReflectionCoordinatesMode!==this.coordinatesMode;switch(this._cachedReflectionUOffset=this.uOffset,this._cachedReflectionVOffset=this.vOffset,this._cachedReflectionUScale=this.uScale,this._cachedReflectionVScale=this.vScale,this._cachedReflectionCoordinatesMode=this.coordinatesMode,this.coordinatesMode){case e.PLANAR_MODE:{y.IdentityToRef(this._cachedReflectionTextureMatrix),this._cachedReflectionTextureMatrix[0]=this.uScale,this._cachedReflectionTextureMatrix[5]=this.vScale,this._cachedReflectionTextureMatrix[12]=this.uOffset,this._cachedReflectionTextureMatrix[13]=this.vOffset;break}case e.PROJECTION_MODE:{y.FromValuesToRef(.5,0,0,0,0,-.5,0,0,0,0,0,0,.5,.5,1,1,this._projectionModeMatrix);const n=t.getProjectionMatrix();this._cachedReflectionProjectionMatrixId=n.updateFlag,n.multiplyToRef(this._projectionModeMatrix,this._cachedReflectionTextureMatrix);break}default:y.IdentityToRef(this._cachedReflectionTextureMatrix);break}return i&&t.markAllMaterialsAsDirty(1,n=>n.hasTexture(this)),this._cachedReflectionTextureMatrix}clone(){const t={noMipmap:this._noMipmap,invertY:this._invertY,samplingMode:this.samplingMode,onLoad:void 0,onError:void 0,buffer:this._texture?this._texture._buffer:void 0,deleteBuffer:this._deleteBuffer,format:this.textureFormat,mimeType:this.mimeType,loaderOptions:this._loaderOptions,creationFlags:this._creationFlags,useSRGBBuffer:this._useSRGBBuffer};return ye.Clone(()=>new e(this._texture?this._texture.url:null,this.getScene(),t),this)}serialize(){const t=this.name;e.SerializeBuffers||this.name.startsWith("data:")&&(this.name=""),this.name.startsWith("data:")&&this.url===this.name&&(this.url="");const i=super.serialize(e._SerializeInternalTextureUniqueId);if(!i)return null;if(e.SerializeBuffers||e.ForceSerializeBuffers)if(typeof this._buffer=="string"&&this._buffer.startsWith("data:"))i.base64String=this._buffer,i.name=i.name.replace("data:","");else if(this.url&&this.url.startsWith("data:")&&this._buffer instanceof Uint8Array){const n=this.mimeType||"image/png";i.base64String=`data:${n};base64,${Be(this._buffer)}`}else(e.ForceSerializeBuffers||this.url&&this.url.startsWith("blob:")||this._forceSerialize)&&(i.base64String=!this._engine||this._engine._features.supportSyncTextureRead?Se(this):Oe(this));return i.invertY=this._invertY,i.samplingMode=this.samplingMode,i._creationFlags=this._creationFlags,i._useSRGBBuffer=this._useSRGBBuffer,e._SerializeInternalTextureUniqueId&&(i.internalTextureUniqueId=this._texture?.uniqueId),i.internalTextureLabel=this._texture?.label,i.noMipmap=this._noMipmap,this.name=t,i}getClassName(){return"Texture"}dispose(){super.dispose(),this.onLoadObservable.clear(),this._delayedOnLoad=null,this._delayedOnError=null,this._buffer=null}static Parse(t,i,n){if(t.customType){const r=Ue.Instantiate(t.customType).Parse(t,i,n);return t.samplingMode&&r.updateSamplingMode&&r._samplingMode&&r._samplingMode!==t.samplingMode&&r.updateSamplingMode(t.samplingMode),r}if(t.isCube&&!t.isRenderTarget)return e._CubeTextureParser(t,i,n);const T=t.internalTextureUniqueId!==void 0;if(!t.name&&!t.isRenderTarget&&!T)return null;let v;if(T){const _=i.getEngine().getLoadedTexturesCache();for(const r of _)if(r.uniqueId===t.internalTextureUniqueId){v=r;break}}const b=_=>{if(_&&_._texture&&(_._texture._cachedWrapU=null,_._texture._cachedWrapV=null,_._texture._cachedWrapR=null),t.samplingMode){const r=t.samplingMode;_&&_.samplingMode!==r&&_.updateSamplingMode(r)}if(_&&t.animations)for(let r=0;r<t.animations.length;r++){const C=t.animations[r],p=Ge("BABYLON.Animation");p&&_.animations.push(p.Parse(C))}_&&_._texture&&(T&&!v&&_._texture._setUniqueId(t.internalTextureUniqueId),_._texture.label=t.internalTextureLabel)};return ye.Parse(()=>{let _=!0;if(t.noMipmap&&(_=!1),t.mirrorPlane){const r=e._CreateMirror(t.name,t.renderTargetSize,i,_);return r._waitingRenderList=t.renderList,r.mirrorPlane=Fe.FromArray(t.mirrorPlane),b(r),r}else if(t.isRenderTarget&&!t.base64String){let r=null;if(t.isCube){if(i.reflectionProbes)for(let C=0;C<i.reflectionProbes.length;C++){const p=i.reflectionProbes[C];if(p.name===t.name)return p.cubeTexture}}else r=e._CreateRenderTargetTexture(t.name,t.renderTargetSize,i,_,t._creationFlags??0),r._waitingRenderList=t.renderList;return b(r),r}else if(t.isVideo){const r=e._CreateVideoTexture(n+(t.url||t.name),n+(t.src||t.url),i,_,t.invertY,t.samplingMode,t.settings||{});return b(r),r}else{let r;if(typeof t.base64String=="string"&&t.base64String&&!v){const C={buffer:t.base64String,noMipmap:!_,invertY:t.invertY,samplingMode:t.samplingMode,useSRGBBuffer:t._useSRGBBuffer??!1,creationFlags:t._creationFlags??0,onLoad:()=>{b(r)}},p=t.base64String,O=p.startsWith("data:")?p.substring(5):p;r=e.CreateFromBase64String("",O,i,C),r.name=t.name}else{let C;t.name&&(t.name.indexOf("://")>0||t.name.startsWith("data:"))?C=t.name:C=n+t.name,t.url&&(t.url.
1startsWith("data:")||e.UseSerializedUrlIfAny)&&(C=t.url);const p={noMipmap:!_,invertY:t.invertY,samplingMode:t.samplingMode,useSRGBBuffer:t._useSRGBBuffer??!1,creationFlags:t._creationFlags??0,onLoad:()=>{b(r)},internalTexture:v};r=new e(C,i,p)}return r}},t,i)}static CreateFromBase64String(t,i,n,T,v,b=e.TRILINEAR_SAMPLINGMODE,F=null,_=null,r=5,C,p){return new e("data:"+i,n,T,v,b,F,_,t,!1,r,void 0,void 0,C,p)}static LoadFromDataString(t,i,n,T=!1,v,b=!0,F=e.TRILINEAR_SAMPLINGMODE,_=null,r=null,C=5,p,O){return t.substring(0,5)!=="data:"&&(t="data:"+t),new e(t,n,v,b,F,_,r,i,T,C,void 0,void 0,p,O)}},(()=>{const E=typeof Symbol=="function"&&Symbol.metadata?Object.create(o[Symbol.metadata]??null):void 0;u=[w()],a=[w()],g=[w()],x=[w()],L=[w()],B=[w()],oe=[w()],he=[w()],ue=[w()],me=[w()],Ce=[w()],xe=[w()],be=[w()],A(e,null,be,{kind:"getter",name:"isBlocking",static:!1,private:!1,access:{has:t=>"isBlocking"in t,get:t=>t.isBlocking},metadata:E},null,s),A(null,null,u,{kind:"field",name:"url",static:!1,private:!1,access:{has:t=>"url"in t,get:t=>t.url,set:(t,i)=>{t.url=i}},metadata:E},l,d),A(null,null,a,{kind:"field",name:"uOffset",static:!1,private:!1,access:{has:t=>"uOffset"in t,get:t=>t.uOffset,set:(t,i)=>{t.uOffset=i}},metadata:E},h,c),A(null,null,g,{kind:"field",name:"vOffset",static:!1,private:!1,access:{has:t=>"vOffset"in t,get:t=>t.vOffset,set:(t,i)=>{t.vOffset=i}},metadata:E},f,m),A(null,null,x,{kind:"field",name:"uScale",static:!1,private:!1,access:{has:t=>"uScale"in t,get:t=>t.uScale,set:(t,i)=>{t.uScale=i}},metadata:E},I,M),A(null,null,L,{kind:"field",name:"vScale",static:!1,private:!1,access:{has:t=>"vScale"in t,get:t=>t.vScale,set:(t,i)=>{t.vScale=i}},metadata:E},U,P),A(null,null,B,{kind:"field",name:"uAng",static:!1,private:!1,access:{has:t=>"uAng"in t,get:t=>t.uAng,set:(t,i)=>{t.uAng=i}},metadata:E},G,W),A(null,null,oe,{kind:"field",name:"vAng",static:!1,private:!1,access:{has:t=>"vAng"in t,get:t=>t.vAng,set:(t,i)=>{t.vAng=i}},metadata:E},le,ce),A(null,null,he,{kind:"field",name:"wAng",static:!1,private:!1,access:{has:t=>"wAng"in t,get:t=>t.wAng,set:(t,i)=>{t.wAng=i}},metadata:E},fe,de),A(null,null,ue,{kind:"field",name:"uRotationCenter",static:!1,private:!1,access:{has:t=>"uRotationCenter"in t,get:t=>t.uRotationCenter,set:(t,i)=>{t.uRotationCenter=i}},metadata:E},_e,ge),A(null,null,me,{kind:"field",name:"vRotationCenter",static:!1,private:!1,access:{has:t=>"vRotationCenter"in t,get:t=>t.vRotationCenter,set:(t,i)=>{t.vRotationCenter=i}},metadata:E},Re,Te),A(null,null,Ce,{kind:"field",name:"wRotationCenter",static:!1,private:!1,access:{has:t=>"wRotationCenter"in t,get:t=>t.wRotationCenter,set:(t,i)=>{t.wRotationCenter=i}},metadata:E},Ee,pe),A(null,null,xe,{kind:"field",name:"homogeneousRotationInUVTransform",static:!1,private:!1,access:{has:t=>"homogeneousRotationInUVTransform"in t,get:t=>t.homogeneousRotationInUVTransform,set:(t,i)=>{t.homogeneousRotationInUVTransform=i}},metadata:E},Me,ve),E&&Object.defineProperty(e,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:E})})(),e.SerializeBuffers=!0,e.ForceSerializeBuffers=!1,e.OnTextureLoadErrorObservable=new Ie,e._SerializeInternalTextureUniqueId=!1,e._CubeTextureParser=(E,t,i)=>{throw J("CubeTexture")},e._CreateMirror=(E,t,i,n)=>{throw J("MirrorTexture")},e._CreateRenderTargetTexture=(E,t,i,n,T)=>{throw J("RenderTargetTexture")},e.NEAREST_SAMPLINGMODE=1,e.NEAREST_NEAREST_MIPLINEAR=8,e.BILINEAR_SAMPLINGMODE=2,e.LINEAR_LINEAR_MIPNEAREST=11,e.TRILINEAR_SAMPLINGMODE=3,e.LINEAR_LINEAR_MIPLINEAR=3,e.NEAREST_NEAREST_MIPNEAREST=4,e.NEAREST_LINEAR_MIPNEAREST=5,e.NEAREST_LINEAR_MIPLINEAR=6,e.NEAREST_LINEAR=7,e.NEAREST_NEAREST=1,e.LINEAR_NEAREST_MIPNEAREST=9,e.LINEAR_NEAREST_MIPLINEAR=10,e.LINEAR_LINEAR=2,e.LINEAR_NEAREST=12,e.EXPLICIT_MODE=0,e.SPHERICAL_MODE=1,e.PLANAR_MODE=2,e.CUBIC_MODE=3,e.PROJECTION_MODE=4,e.SKYBOX_MODE=5,e.INVCUBIC_MODE=6,e.EQUIRECTANGULAR_MODE=7,e.FIXED_EQUIRECTANGULAR_MODE=8,e.FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9,e.CLAMP_ADDRESSMODE=0,e.WRAP_ADDRESSMODE=1,e.MIRROR_ADDRESSMODE=2,e.UseSerializedUrlIfAny=!1,e})();function Ne(){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 o=null;onmessage=a=>{if(a.data.action==="init"){if(a.data.url)try{importScripts(a.data.url)}catch(h){postMessage({action:"error",error:h})}o||(o=BASIS({wasmBinary:a.data.wasmBinary})),o!==null&&o.then(h=>{BASIS=h,h.initializeBasis(),postMessage({action:"init"})})}else if(a.data.action==="transcode"){const h=a.data.config,c=a.data.imageData,g=new BASIS.BasisFile(c),f=u(g);let m=a.data.ignoreSupportedFormats?null:s(a.data.config,f),x=!1;m===null&&(x=!0,m=f.hasAlpha?e.cTFBC3:e.cTFBC1);let I=!0;g.startTranscoding()||(I=!1);const M=[];for(let L=0;L<f.images.length&&I;L++){const U=f.images[L];if(h.loadSingleImage===void 0||h.loadSingleImage===L){let P=U.levels.length;h.loadMipmapLevels===!1&&(P=1);for(let B=0;B<P;B++){const G=U.levels[B],W=l(g,L,B,m,x);if(!W){I=!1;break}G.transcodedPixels=W,M.push(G.transcodedPixels.buffer)}}}g.close(),g.delete(),x&&(m=-1),I?postMessage({action:"transcode",success:I,id:a.data.id,fileInfo:f,format:m},M):postMessage({action:"transcode",success:I,id:a.data.id})}};function s(a,h){let c=null;return a.supportedCompressionFormats&&(a.supportedCompressionFormats.astc?c=e.cTFASTC_4x4:a.supportedCompressionFormats.bc7?c=e.cTFBC7:a.supportedCompressionFormats.s3tc?c=h.hasAlpha?e.cTFBC3:e.cTFBC1:a.supportedCompressionFormats.pvrtc?c=h.hasAlpha?e.cTFPVRTC1_4_RGBA:e.cTFPVRTC1_4_RGB:a.supportedCompressionFormats.etc2?c=e.cTFETC2:a.supportedCompressionFormats.etc1?c=e.cTFETC1:c=e.cTFRGB565),c}function u(a){const h=a.getHasAlpha(),c=a.getNumImages(),g=[];for(let m=0;m<c;m++){const x={levels:[]},I=a.getNumLevels(m);for(let M=0;M<I;M++){const L={width:a.getImageWidth(m,M),height:a.getImageHeight(m,M)};x.levels.push(L)}g.push(x)}return{hasAlpha:h,images:g}}function l(a,h,c,g,f){const m=a.getImageTranscodedSizeInBytes(h,c,g);let x=new Uint8Array(m);if(!a.transcodeImage(x,h,c,g,1,0))return null;
vendor: 5,957 bytes, line 1
1if(f){const I=a.getImageWidth(h,c)+3&-4,M=a.getImageHeight(h,c)+3&-4;x=d(x,0,I,M)}return x}function d(a,h,c,g){const f=new Uint16Array(4),m=new Uint16Array(c*g),x=c/4,I=g/4;for(let M=0;M<I;M++)for(let L=0;L<x;L++){const U=h+8*(M*x+L);f[0]=a[U]|a[U+1]<<8,f[1]=a[U+2]|a[U+3]<<8,f[2]=(2*(f[0]&31)+1*(f[1]&31))/3|(2*(f[0]&2016)+1*(f[1]&2016))/3&2016|(2*(f[0]&63488)+1*(f[1]&63488))/3&63488,f[3]=(2*(f[1]&31)+1*(f[0]&31))/3|(2*(f[1]&2016)+1*(f[0]&2016))/3&2016|(2*(f[1]&63488)+1*(f[0]&63488))/3&63488;for(let P=0;P<4;P++){const B=a[U+4+P];let G=(M*4+P)*c+L*4;m[G++]=f[B&3],m[G++]=f[B>>2&3],m[G++]=f[B>>4&3],m[G]=f[B>>6&3]}}return m}}async function ze(e,o,s){return await new Promise((u,l)=>{const d=a=>{a.data.action==="init"?(e.removeEventListener("message",d),u(e)):a.data.action==="error"&&l(a.data.error||"error initializing worker")};e.addEventListener("message",d),e.postMessage({action:"init",url:s?S.GetBabylonScriptURL(s):void 0,wasmBinary:o},[o])})}var D;(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"})(D||(D={}));const Q={JSModuleURL:`${S._DefaultCdnUrl}/basisTranscoder/1/basis_transcoder.js`,WasmModuleURL:`${S._DefaultCdnUrl}/basisTranscoder/1/basis_transcoder.wasm`},We=(e,o)=>{let s;switch(e){case D.cTFETC1:s=36196;break;case D.cTFBC1:s=33776;break;case D.cTFBC4:s=33779;break;case D.cTFASTC_4x4:s=37808;break;case D.cTFETC2:s=37496;break;case D.cTFBC7:s=36492;break}if(s===void 0)throw"The chosen Basis transcoder format is not currently supported";return s};let se=null,z=null,ke=0;const Ye=!1,je=async()=>(se||(se=new Promise((e,o)=>{z?e(z):S.LoadFileAsync(S.GetBabylonScriptURL(Q.WasmModuleURL)).then(s=>{if(typeof URL!="function")return o("Basis transcoder requires an environment with a URL constructor");const u=URL.createObjectURL(new Blob([`(${Ne})()`],{type:"application/javascript"}));z=new Worker(u),ze(z,s,Q.JSModuleURL).then(e,o)}).catch(o)})),await se),ne=async(e,o)=>{const s=e instanceof ArrayBuffer?new Uint8Array(e):e;return await new Promise((u,l)=>{je().then(()=>{const d=ke++,a=c=>{c.data.action==="transcode"&&c.data.id===d&&(z.removeEventListener("message",a),c.data.success?u(c.data):l("Transcode is not supported on this device"))};z.addEventListener("message",a);const h=new Uint8Array(s.byteLength);h.set(new Uint8Array(s.buffer,s.byteOffset,s.byteLength)),z.postMessage({action:"transcode",id:d,imageData:h,config:o,ignoreSupportedFormats:Ye},[h.buffer])},d=>{l(d)})})},$=(e,o)=>{let s=o._gl?.TEXTURE_2D;e.isCube&&(s=o._gl?.TEXTURE_CUBE_MAP),o._bindTextureDirectly(s,e,!0)},re=(e,o)=>{const s=e.getEngine();for(let u=0;u<o.fileInfo.images.length;u++){const l=o.fileInfo.images[u].levels[0];if(e._invertVScale=e.invertY,o.format===-1||o.format===D.cTFRGB565)if(e.type=10,e.format=4,s._features.basisNeedsPOT&&(Math.log2(l.width)%1!==0||Math.log2(l.height)%1!==0)){const d=new De(s,2);e._invertVScale=e.invertY,d.type=10,d.format=4,d.width=l.width+3&-4,d.height=l.height+3&-4,$(d,s),s._uploadDataToTextureDirectly(d,new Uint16Array(l.transcodedPixels.buffer),u,0,4,!0),s._rescaleTexture(d,e,s.scenes[0],s._getInternalFormat(4),()=>{s._releaseTexture(d),$(e,s)})}else e._invertVScale=!e.invertY,e.width=l.width+3&-4,e.height=l.height+3&-4,e.samplingMode=2,$(e,s),s._uploadDataToTextureDirectly(e,new Uint16Array(l.transcodedPixels.buffer),u,0,4,!0);else{e.width=l.width,e.height=l.height,e.generateMipMaps=o.fileInfo.images[u].levels.length>1;const d=He.GetInternalFormatFromBasisFormat(o.format,s);e.format=d,$(e,s);const a=o.fileInfo.images[u].levels;for(let h=0;h<a.length;h++){const c=a[h];s._uploadCompressedDataToTextureDirectly(e,d,c.width,c.height,c.transcodedPixels,u,h)}s._features.basisNeedsPOT&&(Math.log2(e.width)%1!==0||Math.log2(e.height)%1!==0)&&(Ve.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=Ae.CLAMP_ADDRESSMODE,e._cachedWrapV=Ae.CLAMP_ADDRESSMODE)}}},He={JSModuleURL:Q.JSModuleURL,WasmModuleURL:Q.WasmModuleURL,GetInternalFormatFromBasisFormat:We,TranscodeAsync:ne,LoadTextureFromTranscodeResult:re};class Je{constructor(){this.supportCascades=!1}loadCubeData(o,s,u,l,d){if(Array.isArray(o))return;const a=s.getEngine().getCaps(),h={supportedCompressionFormats:{etc1:!!a.etc1,s3tc:!!a.s3tc,pvrtc:!!a.pvrtc,etc2:!!a.etc2,astc:!!a.astc,bc7:!!a.bptc}};ne(o,h).then(c=>{const g=c.fileInfo.images[0].levels.length>1&&s.generateMipMaps;re(s,c),s.getEngine()._setCubeMapTextureParams(s,g),s.isReady=!0,s.onLoadedObservable.notifyObservers(s),s.onLoadedObservable.clear(),l&&l()}).catch(c=>{S.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),s.isReady=!0,d&&d(c)})}loadData(o,s,u){const l=s.getEngine().getCaps(),d={supportedCompressionFormats:{etc1:!!l.etc1,s3tc:!!l.s3tc,pvrtc:!!l.pvrtc,etc2:!!l.etc2,astc:!!l.astc,bc7:!!l.bptc}};ne(o,d).then(a=>{const h=a.fileInfo.images[0].levels[0],c=a.fileInfo.images[0].levels.length>1&&s.generateMipMaps;u(h.width,h.height,c,a.format!==-1,()=>{re(s,a)})}).catch(a=>{S.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),S.Warn(`Failed to transcode Basis file: ${a}`),u(0,0,!1,!1,()=>{},!0)})}}export{Je 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.