PageSourceSearch

https://hypn0-ironfly-p3-merge-proposer-trackio.hf.space/assets/engine-CpuWTyJz.js

js hypn0-ironfly-p3-merge-proposer-trackio.hf.space collected 2026-10-04 16:57:03 UTC 69,935 bytes, 2 lines download raw bytes

vendor: 5,021 bytes, lines 1-2
1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dds-CKoTuDuX.js","assets/math.scalar.functions-DkeaWAWz.js","assets/bufferUtils-DTRdUD8L.js","assets/cubemapToSphericalPolynomial-DuWiqS6A.js","assets/math.vector-C1xyPDEl.js","assets/math.color-CzLaKyb6.js","assets/textureTools-BldP_JF7.js","assets/texture-BEqhDl5Y.js","assets/baseTexture-CgAggsey.js","assets/decorators.serialization-C7d7ykGG.js","assets/tools-D01N7ptR.js","assets/math.plane-Ce_75-g5.js","assets/renderTargetTexture-BB8nhK2f.js","assets/index-DeFvE6lu.js","assets/index-B_L8IJka.css","assets/renderingManager-CiY2OUrf.js","assets/buffer-DqKlo1ts.js","assets/dataBuffer-CgoqiUzT.js","assets/smartArray-CO6iJ0u5.js","assets/lightConstants-B1TSTh-k.js","assets/passPostProcess-D9n088ny.js","assets/effectRenderer-CSz5fi0n.js","assets/math.viewport-CgkTt1RS.js","assets/drawWrapper-CZVk0xN-.js","assets/abstractEngine.cubeTexture-0PJJEs45.js","assets/thinEngine-D5ynu8Dd.js","assets/drawWrapper.functions-Dzz0ghog.js","assets/math.axis-Ck7JfPPj.js","assets/math.path-DFucxaHn.js","assets/perfCounter-DusmGz8t.js","assets/iesTextureLoader-DekH8UxR.js","assets/ddsTextureLoader-C0ZNRpnB.js","assets/basisTextureLoader-DdLfyHqy.js","assets/envTextureLoader-M9N9qobF.js","assets/environmentTextureTools-Bxqq-W7n.js","assets/scene-gn_hoGMy.js","assets/sceneComponent-Dflhczui.js","assets/deviceInputEvents-BTza-zoR.js","assets/dumpTools-DCwESy1L.js","assets/baseTexture.polynomial-DF3NS0nO.js","assets/hdrTextureLoader-KSyNFpIa.js","assets/ktxTextureLoader-DM759aiC.js","assets/workerPool-CfMXSLnf.js","assets/tgaTextureLoader-BtQVr-HR.js","assets/exrTextureLoader-Dj4jBvs0.js"])))=>i.map(i=>d[i]);
2import{P as ee,a as N,h as k,j as te,k as re,A as f,c as Z,l as K}from"./decorators.serialization-C7d7ykGG.js";import{V as d,T as A,E as v}from"./math.vector-C1xyPDEl.js";import{T as R,H as z,W as q,a as ie}from"./thinEngine-D5ynu8Dd.js";import{L as y,f as se}from"./bufferUtils-DTRdUD8L.js";import{_ as D}from"./index-DeFvE6lu.js";import"./math.axis-Ck7JfPPj.js";import"./math.color-CzLaKyb6.js";import"./math.plane-Ce_75-g5.js";import"./math.path-DFucxaHn.js";import{B as ne}from"./baseTexture-CgAggsey.js";import{P as ae}from"./perfCounter-DusmGz8t.js";class le{constructor(e=30){this._enabled=!0,this._rollingFrameTime=new oe(e)}sampleFrame(e=ee.Now){if(this._enabled){if(this._lastFrameTimeMs!=null){const r=e-this._lastFrameTimeMs;this._rollingFrameTime.add(r)}this._lastFrameTimeMs=e}}get averageFrameTime(){return this._rollingFrameTime.average}get averageFrameTimeVariance(){return this._rollingFrameTime.variance}get instantaneousFrameTime(){return this._rollingFrameTime.history(0)}get averageFPS(){return 1e3/this._rollingFrameTime.average}get instantaneousFPS(){const e=this._rollingFrameTime.history(0);return e===0?0:1e3/e}get isSaturated(){return this._rollingFrameTime.isSaturated()}enable(){this._enabled=!0}disable(){this._enabled=!1,this._lastFrameTimeMs=null}get isEnabled(){return this._enabled}reset(){this._lastFrameTimeMs=null,this._rollingFrameTime.reset()}}class oe{constructor(e){this._samples=new Array(e),this.reset()}add(e){let r;if(this.isSaturated()){const i=this._samples[this._pos];r=i-this.average,this.average-=r/(this._sampleCount-1),this._m2-=r*(i-this.average)}else this._sampleCount++;r=e-this.average,this.average+=r/this._sampleCount,this._m2+=r*(e-this.average),this.variance=this._m2/(this._sampleCount-1),this._samples[this._pos]=e,this._pos++,this._pos%=this._samples.length}history(e){if(e>=this._sampleCount||e>=this._samples.length)return 0;const r=this._wrapPosition(this._pos-1);return this._samples[this._wrapPosition(r-e)]}isSaturated(){return this._sampleCount>=this._samples.length}reset(){this.average=0,this.variance=0,this._sampleCount=0,this._pos=0,this._m2=0}_wrapPosition(e){const r=this._samples.length;return(e%r+r)%r}}R.prototype.setAlphaMode=function(t,e=!1,r=0){if(this._alphaMode[r]===t){if(!e){const s=t===0;this.depthCullingState.depthMask!==s&&(this.depthCullingState.depthMask=s)}return}const i=t===0;this._alphaState.setAlphaBlend(!i,r),this._alphaState.setAlphaMode(t,r),e||(this.depthCullingState.depthMask=i),this._alphaMode[r]=t};R.prototype.updateRawTexture=function(t,e,r,i,s=null,n=0,o=!1){if(!t)return;const a=this._getRGBABufferInternalSizedFormat(n,r,o),u=this._getInternalFormat(r),l=this._getWebGLTextureType(n);this._bindTextureDirectly(this._gl.TEXTURE_2D,t,!0),this._unpackFlipY(i===void 0?!0:!!i),this._doNotHandleContextLost||(t._bufferView=e,t.format=r,t.type=n,t.invertY=i,t._compression=s),t.width%4!==0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),s&&e?this._gl.compressedTexImage2D(this._gl.TEXTURE_2D,0,this.getCaps().s3tc[s],t.width,t.height,0,e):this._gl.texImage2D(this._gl.TEXTURE_2D,0,a,t.width,t.height,0,u,l,e),t.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),t.isReady=!0};R.prototype.createRawTexture=function(t,e,r,i,s,n,o,a=null,u=0,l=0,_=!1){const T=new N(this,3);
2T.baseWidth=e,T.baseHeight=r,T.width=e,T.height=r,T.format=i,T.generateMipMaps=s,T.samplingMode=o,T.invertY=n,T._compression=a,T.type=u,T._useSRGBBuffer=this._getUseSRGBBuffer(_,!s),this._doNotHandleContextLost||(T._bufferView=t),this.updateRawTexture(T,t,i,n,a,u,T._useSRGBBuffer),this._bindTextureDirectly(this._gl.TEXTURE_2D,T,!0);const E=this._getSamplingParameters(o,s);return this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,E.mag),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,E.min),s&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._internalTexturesCache.push(T),T};R.prototype.createRawCubeTexture=function(t,e,r,i,s,n,o,a=null){const u=this._gl,l=new N(this,8);l.isCube=!0,l.format=r,l.type=i,this._doNotHandleContextLost||(l._bufferViewArray=t);const _=this._getWebGLTextureType(i);let T=this._getInternalFormat(r);T===u.RGB&&(T=u.RGBA),_===u.FLOAT&&!this._caps.textureFloatLinearFiltering?(s=!1,o=1,y.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")):_===this._gl.HALF_FLOAT_OES&&!this._caps.textureHalfFloatLinearFiltering?(s=!1,o=1,y.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")):_===u.FLOAT&&!this._caps.textureFloatRender?(s=!1,y.Warn("Render to float textures is not supported. Mipmap generation forced to false.")):_===u.HALF_FLOAT&&!this._caps.colorBufferFloat&&(s=!1,y.Warn("Render to half float textures is not supported. Mipmap generation forced to false."));const E=e,c=E;if(l.width=E,l.height=c,l.invertY=n,l._compression=a,!this.needPOTTextures||k(l.width)&&k(l.height)||(s=!1),t)this.updateRawCubeTexture(l,t,r,i,n,a);else{const g=this._getRGBABufferInternalSizedFormat(i),m=0;this._bindTextureDirectly(u.TEXTURE_CUBE_MAP,l,!0);for(let P=0;P<6;P++)a?u.compressedTexImage2D(u.TEXTURE_CUBE_MAP_POSITIVE_X+P,m,this.getCaps().s3tc[a],l.width,l.height,0,void 0):u.texImage2D(u.TEXTURE_CUBE_MAP_POSITIVE_X+P,m,g,l.width,l.height,0,T,_,null);this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)}this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,l,!0),t&&s&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);const p=this._getSamplingParameters(o,s);return u.texParameteri(u.TEXTURE_CUBE_MAP,u.TEXTURE_MAG_FILTER,p.mag),u.texParameteri(u.TEXTURE_CUBE_MAP,u.TEXTURE_MIN_FILTER,p.min),u.texParameteri(u.TEXTURE_CUBE_MAP,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_CUBE_MAP,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),this._bindTextureDirectly(u.TEXTURE_CUBE_MAP,null),l.generateMipMaps=s,l.samplingMode=o,l.isReady=!0,l};R.prototype.updateRawCubeTexture=function(t,e,r,i,s,n=null,o=0){t._bufferViewArray=e,t.format=r,t.type=i,t.invertY=s,t._compression=n;const a=this._gl,u=this._getWebGLTextureType(i);let l=this._getInternalFormat(r);const _=this._getRGBABufferInternalSizedFormat(i);let T=!1;l===a.RGB&&(l=a.RGBA,T=!0),this._bindTextureDirectly(a.TEXTURE_CUBE_MAP,t,!0),this._unpackFlipY(s===void 0?!0:!!s),t.width%4!==0&&a.pixelStorei(a.UNPACK_ALIGNMENT,1);for(let c=0;c<6;c++){let S=e[c];n?a.compressedTexImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+c,o,this.getCaps().s3tc[n],t.width,t.height,0,S):(T&&(S=j(S,t.width,t.height,i)),a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+c,o,_,t.width,t.height,0,l,u,S))}(!this.needPOTTextures||k(t.width)&&k(t.height))&&t.generateMipMaps&&o===0&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),t.isReady=!0};R.prototype.createRawCubeTextureFromUrl=function(t,e,r,i,s,n,o,a,u=null,l=null,_=3,T=!1){const E=this._gl,c=this.createRawCubeTexture(null,r,i,s,!n,T,_,null);e==null||e.addPendingData(c),c.url=t,c.isReady=!1,this._internalTexturesCache.push(c);const S=(g,m)=>{e==null||e.removePendingData(c),l&&l(g?g.status+" "+g.statusText:"Failed to parse texture data",m)},p=async g=>{if(!c._hardwareTexture)return;const m=o(g);if(!m)return;const P=m instanceof Promise?await m:m,M=c.width;if(a){const x=this._getWebGLTextureType(s);let I=this._getInternalFormat(i);const b=this._getRGBABufferInternalSizedFormat(s);let F=!1;I===E.RGB&&(I=E.RGBA,F=!0),this._bindTextureDirectly(E.TEXTURE_CUBE_MAP,c,!0),this._unpackFlipY(!1);const U=a(P);for(let B=0;B<U.length;B++){const X=M>>B;for(let G=0;G<6;G++){let Y=U[B][G];F&&(Y=j(Y,X,X,s)),E.texImage2D(G,B,b,X,X,0,I,x,Y)}}this._bindTextureDirectly(E.TEXTURE_CUBE_MAP,null)}else this.updateRawCubeTexture(c,P,i,s,T);c.isReady=!0,e==null||e.removePendingData(c),c.onLoadedObservable.notifyObservers(c),c.onLoadedObservable.clear(),u&&u()};return this._loadFile(t,g=>
2{p(g).catch(m=>{S(void 0,m)})},void 0,e==null?void 0:e.offlineProvider,!0,S),c};function j(t,e,r,i){let s,n=1;i===1?s=new Float32Array(e*r*4):i===2?(s=new Uint16Array(e*r*4),n=15360):i===7?s=new Uint32Array(e*r*4):s=new Uint8Array(e*r*4);for(let o=0;o<e;o++)for(let a=0;a<r;a++){const u=(a*e+o)*3,l=(a*e+o)*4;s[l+0]=t[u+0],s[l+1]=t[u+1],s[l+2]=t[u+2],s[l+3]=n}return s}function Q(t){return function(e,r,i,s,n,o,a,u,l=null,_=0){const T=t?this._gl.TEXTURE_3D:this._gl.TEXTURE_2D_ARRAY,E=t?10:11,c=new N(this,E);c.baseWidth=r,c.baseHeight=i,c.baseDepth=s,c.width=r,c.height=i,c.depth=s,c.format=n,c.type=_,c.generateMipMaps=o,c.samplingMode=u,t?c.is3D=!0:c.is2DArray=!0,this._doNotHandleContextLost||(c._bufferView=e),t?this.updateRawTexture3D(c,e,n,a,l,_):this.updateRawTexture2DArray(c,e,n,a,l,_),this._bindTextureDirectly(T,c,!0);const S=this._getSamplingParameters(u,o);return this._gl.texParameteri(T,this._gl.TEXTURE_MAG_FILTER,S.mag),this._gl.texParameteri(T,this._gl.TEXTURE_MIN_FILTER,S.min),o&&this._gl.generateMipmap(T),this._bindTextureDirectly(T,null),this._internalTexturesCache.push(c),c}}R.prototype.createRawTexture2DArray=Q(!1);R.prototype.createRawTexture3D=Q(!0);function $(t){return function(e,r,i,s,n=null,o=0){const a=t?this._gl.TEXTURE_3D:this._gl.TEXTURE_2D_ARRAY,u=this._getWebGLTextureType(o),l=this._getInternalFormat(i),_=this._getRGBABufferInternalSizedFormat(o,i);this._bindTextureDirectly(a,e,!0),this._unpackFlipY(s===void 0?!0:!!s),this._doNotHandleContextLost||(e._bufferView=r,e.format=i,e.invertY=s,e._compression=n),e.width%4!==0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),n&&r?this._gl.compressedTexImage3D(a,0,this.getCaps().s3tc[n],e.width,e.height,e.depth,0,r):this._gl.texImage3D(a,0,_,e.width,e.height,e.depth,0,l,u,r),e.generateMipMaps&&this._gl.generateMipmap(a),this._bindTextureDirectly(a,null),e.isReady=!0}}R.prototype.updateRawTexture2DArray=$(!1);R.prototype.updateRawTexture3D=$(!0);R.prototype._readTexturePixelsSync=function(t,e,r,i=-1,s=0,n=null,o=!0,a=!1,u=0,l=0){var E,c,S;const _=this._gl;if(!_)throw new Error("Engine does not have gl rendering context.");if(!this._dummyFramebuffer){const p=_.createFramebuffer();if(!p)throw new Error("Unable to create dummy framebuffer");this._dummyFramebuffer=p}_.bindFramebuffer(_.FRAMEBUFFER,this._dummyFramebuffer),i>-1&&(t.is2DArray||t.is3D)?_.framebufferTextureLayer(_.FRAMEBUFFER,_.COLOR_ATTACHMENT0,(E=t._hardwareTexture)==null?void 0:E.underlyingResource,s,i):i>-1?_.framebufferTexture2D(_.FRAMEBUFFER,_.COLOR_ATTACHMENT0,_.TEXTURE_CUBE_MAP_POSITIVE_X+i,(c=t._hardwareTexture)==null?void 0:c.underlyingResource,s):_.framebufferTexture2D(_.FRAMEBUFFER,_.COLOR_ATTACHMENT0,_.TEXTURE_2D,(S=t._hardwareTexture)==null?void 0:S.underlyingResource,s);let T=t.type!==void 0?this._getWebGLTextureType(t.type):_.UNSIGNED_BYTE;if(a)n||(n=te(t.type,4*e*r));else switch(T){case _.UNSIGNED_BYTE:n||(n=new Uint8Array(4*e*r)),T=_.UNSIGNED_BYTE;break;default:n||(n=new Float32Array(4*e*r)),T=_.FLOAT;break}return o&&this.flushFramebuffer(),_.readPixels(u,l,e,r,_.RGBA,T,n),_.bindFramebuffer(_.FRAMEBUFFER,this._currentFramebuffer),n};R.prototype._readTexturePixels=function(t,e,r,i=-1,s=0,n=null,o=!0,a=!1,u=0,l=0){return Promise.resolve(this._readTexturePixelsSync(t,e,r,i,s,n,o,a,u,l))};R.prototype.updateDynamicIndexBuffer=function(t,e,r=0){this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER]=null,this.bindIndexBuffer(t);let i;t.is32Bits?i=e instanceof Uint32Array?e:new Uint32Array(e):i=e instanceof Uint16Array?e:new Uint16Array(e),this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,i,this._gl.DYNAMIC_DRAW),this._resetIndexBufferBinding()};R.prototype.updateDynamicVertexBuffer=function(t,e,r,i){this.bindArrayBuffer(t),r===void 0&&(r=0);const s=e.byteLength||e.length;i===void 0||i>=s&&r===0?e instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,r,new Float32Array(e)):this._gl.bufferSubData(this._gl.ARRAY_BUFFER,r,e):e instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,r,new Float32Array(e).subarray(0,i/4)):(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,i):e=new Uint8Array(e,0,i),this._gl.bufferSubData(this._gl.ARRAY_BUFFER,r,e)),this._resetVertexBufferBinding()};R.prototype._createDepthStencilCubeTexture=function(t,e){const r=new N(this,12);if(r.isCube=!0,this.webGLVersion===1)return y.Error("Depth cube texture is not supported by WebGL 1."),r;const i={bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1,...e},s=this._gl;this._bindTextureDirectly(s.TEXTURE_CUBE_MAP,r,!0),this._setupDepthStencilTexture(r,t,i.bilinearFiltering,i.comparisonFunction);for(let n=0;n<6;n++)i.generateStencil?s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+n,0,s.DEPTH24_STENCIL8,t,t,0,s.DEPTH_STENCIL,s.UNSIGNED_INT_24_8,null):s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+n,0,s.DEPTH_COMPONENT24,t,t,0,s.DEPTH_COMPONENT,s.UNSIGNED_INT,null);return this._bindTextureDirectly(s.TEXTURE_CUBE_MAP,null),this._internalTexturesCache.push(r),r};
2R.prototype._setCubeMapTextureParams=function(t,e,r){const i=this._gl;i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MIN_FILTER,e?i.LINEAR_MIPMAP_LINEAR:i.LINEAR),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),t.samplingMode=e?3:2,e&&this.getCaps().textureMaxLevel&&r!==void 0&&r>0&&(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MAX_LEVEL,r),t._maxLodLevel=r),this._bindTextureDirectly(i.TEXTURE_CUBE_MAP,null)};R.prototype.createCubeTexture=function(t,e,r,i,s=null,n=null,o,a=null,u=!1,l=0,_=0,T=null,E,c=!1,S=null){const p=this._gl;return this.createCubeTextureBase(t,e,r,!!i,s,n,o,a,u,l,_,T,g=>this._bindTextureDirectly(p.TEXTURE_CUBE_MAP,g,!0),(g,m)=>{const P=this.needPOTTextures?re(m[0].width,this._caps.maxCubemapTextureSize):m[0].width,M=P,x=[p.TEXTURE_CUBE_MAP_POSITIVE_X,p.TEXTURE_CUBE_MAP_POSITIVE_Y,p.TEXTURE_CUBE_MAP_POSITIVE_Z,p.TEXTURE_CUBE_MAP_NEGATIVE_X,p.TEXTURE_CUBE_MAP_NEGATIVE_Y,p.TEXTURE_CUBE_MAP_NEGATIVE_Z];this._bindTextureDirectly(p.TEXTURE_CUBE_MAP,g,!0),this._unpackFlipY(!1);const I=o?this._getInternalFormat(o,g._useSRGBBuffer):g._useSRGBBuffer?this._glSRGBExtensionValues.SRGB8_ALPHA8:p.RGBA;let b=o?this._getInternalFormat(o):p.RGBA;g._useSRGBBuffer&&this.webGLVersion===1&&(b=I);for(let F=0;F<x.length;F++)if(m[F].width!==P||m[F].height!==M){if(this._prepareWorkingCanvas(),!this._workingCanvas||!this._workingContext){y.Warn("Cannot create canvas to resize texture.");return}this._workingCanvas.width=P,this._workingCanvas.height=M,this._workingContext.drawImage(m[F],0,0,m[F].width,m[F].height,0,0,P,M),p.texImage2D(x[F],0,I,b,p.UNSIGNED_BYTE,this._workingCanvas)}else p.texImage2D(x[F],0,I,b,p.UNSIGNED_BYTE,m[F]);i||p.generateMipmap(p.TEXTURE_CUBE_MAP),this._setCubeMapTextureParams(g,!i),g.width=P,g.height=M,g.isReady=!0,o&&(g.format=o),g.onLoadedObservable.notifyObservers(g),g.onLoadedObservable.clear(),s&&s()},!!c,S)};R.prototype.generateMipMapsForCubemap=function(t,e=!0){if(t.generateMipMaps){const r=this._gl;this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,t,!0),r.generateMipmap(r.TEXTURE_CUBE_MAP),e&&this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,null)}};class ue{get depthStencilTexture(){return this._depthStencilTexture}setDepthStencilTexture(e,r=!0){r&&this._depthStencilTexture&&this._depthStencilTexture.dispose(),this._depthStencilTexture=e,this._generateDepthBuffer=this._generateStencilBuffer=this._depthStencilTextureWithStencil=!1,e&&(this._generateDepthBuffer=!0,this._generateStencilBuffer=this._depthStencilTextureWithStencil=z(e.format))}get depthStencilTextureWithStencil(){return this._depthStencilTextureWithStencil}get isCube(){return this._isCube}get isMulti(){return this._isMulti}get is2DArray(){return this.layers>0}get is3D(){return this.depth>0}get size(){return this.width}get width(){return this._size.width??this._size}get height(){return this._size.height??this._size}get layers(){return this._size.layers||0}get depth(){return this._size.depth||0}get texture(){var e;return((e=this._textures)==null?void 0:e[0])??null}get textures(){return this._textures}get faceIndices(){return this._faceIndices}get layerIndices(){return this._layerIndices}getBaseArrayLayer(e){var n,o;if(!this._textures)return-1;const r=this._textures[e],i=((n=this._layerIndices)==null?void 0:n[e])??0,s=((o=this._faceIndices)==null?void 0:o[e])??0;return r.isCube?i*6+s:r.is3D?0:i}get samples(){return this._samples}setSamples(e,r=!0,i=!1){if(this.samples===e&&!i)return e;const s=this._isMulti?this._engine.updateMultipleRenderTargetTextureSampleCount(this,e,r):this._engine.updateRenderTargetTextureSampleCount(this,e);return this._samples=e,s}resolveMSAATextures(){this.isMulti?this._engine.resolveMultiFramebuffer(this):this._engine.resolveFramebuffer(this)}generateMipMaps(){this._engine._currentRenderTarget===this&&(this.isMulti?this._engine.unBindMultiColorAttachmentFramebuffer(this,!0):this._engine.unBindFramebuffer(this,!0)),this.isMulti?this._engine.generateMipMapsMultiFramebuffer(this):this._engine.generateMipMapsFramebuffer(this)}constructor(e,r,i,s,n){this._textures=null,this._faceIndices=null,this._layerIndices=null,this._samples=1,this._attachments=null,this._generateStencilBuffer=!1,this._generateDepthBuffer=!1,this._depthStencilTextureWithStencil=!1,this.disableAutomaticMSAAResolve=!1,this.resolveMSAAColors=!0,this.resolveMSAADepth=!1,this.resolveMSAAStencil=!1,this.depthReadOnly=!1,this.stencilReadOnly=!1,this._isMulti=e,this._isCube=r,this._size=i,this._engine=s,this._depthStencilTexture=null,this.label=n}setTextures(e){Array.isArray(e)?this._textures=e:e?this._textures=[e]:this._textures=null}setTexture(e,r=0,i=!0){this._textures||(this._textures=[]),this._textures[r]!==e&&(this._textures[r]&&i&&this._textures[r].dispose(),this._textures[r]=e)}setLayerAndFaceIndices(e,r){this._layerIndices=e,this._faceIndices=r}setLayerAndFaceIndex(e=0,r,i){this._layerIndices||(this._layerIndices=[]),this._faceIndices||(this._faceIndices=[]),r!==void 0&&r>=0&&(this._layerIndices[e]=r),i!==void 0&&i>=0&&(this._faceIndices[e]=i)}createDepthStencilTexture(e=0,r=!0,i=!1,s=1,n=14,o){var a;return(a=this._depthStencilTexture)==null||a.dispose(),this._depthStencilTextureWithStencil=i,this._depthStencilTextureLabel=o,this._depthStencilTexture=this._engine.createDepthStencilTexture(this._size,{bilinearFiltering:r,comparisonFunction:e,generateStencil:i,isCube:this._isCube,samples:s,depthTextureFormat:n,label:o},this),this._depthStencilTexture}_shareDepth(e){this.shareDepth(e)}
2shareDepth(e){this._depthStencilTexture&&(e._depthStencilTexture&&e._depthStencilTexture.dispose(),e._depthStencilTexture=this._depthStencilTexture,e._depthStencilTextureWithStencil=this._depthStencilTextureWithStencil,this._depthStencilTexture.incrementReferences())}_swapAndDie(e){this.texture&&this.texture._swapAndDie(e),this._textures=null,this.dispose(!0)}_cloneRenderTargetWrapper(){var r,i,s,n,o;let e=null;if(this._isMulti){const a=this.textures;if(a&&a.length>0){let u=!1,l=a.length,_=-1;const T=a[a.length-1]._source;(T===14||T===12)&&(u=!0,_=a[a.length-1].format,l--);const E=[],c=[],S=[],p=[],g=[],m=[],P=[],M={};for(let b=0;b<l;++b){const F=a[b];E.push(F.samplingMode),c.push(F.type),S.push(F.format),M[F.uniqueId]!==void 0?(p.push(-1),P.push(0)):(M[F.uniqueId]=b,F.is2DArray?(p.push(35866),P.push(F.depth)):F.isCube?(p.push(34067),P.push(0)):F.is3D?(p.push(32879),P.push(F.depth)):(p.push(3553),P.push(0))),this._faceIndices&&g.push(this._faceIndices[b]??0),this._layerIndices&&m.push(this._layerIndices[b]??0)}const x={samplingModes:E,generateMipMaps:a[0].generateMipMaps,generateDepthBuffer:this._generateDepthBuffer,generateStencilBuffer:this._generateStencilBuffer,generateDepthTexture:u,depthTextureFormat:_,types:c,formats:S,textureCount:l,targetTypes:p,faceIndex:g,layerIndex:m,layerCounts:P,label:this.label},I={width:this.width,height:this.height,depth:this.depth};e=this._engine.createMultipleRenderTarget(I,x);for(let b=0;b<l;++b){if(p[b]!==-1)continue;const F=M[a[b].uniqueId];e.setTexture(e.textures[F],b)}}}else{const a={};if(a.generateDepthBuffer=this._generateDepthBuffer,a.generateMipMaps=((r=this.texture)==null?void 0:r.generateMipMaps)??!1,a.generateStencilBuffer=this._generateStencilBuffer,a.samplingMode=(i=this.texture)==null?void 0:i.samplingMode,a.type=(s=this.texture)==null?void 0:s.type,a.format=(n=this.texture)==null?void 0:n.format,a.noColorAttachment=!this._textures,a.label=this.label,this.isCube)e=this._engine.createRenderTargetCubeTexture(this.width,a);else{const u={width:this.width,height:this.height,layers:this.is2DArray||this.is3D?(o=this.texture)==null?void 0:o.depth:void 0};e=this._engine.createRenderTargetTexture(u,a)}e.texture&&(e.texture.isReady=!0)}return e}_swapRenderTargetWrapper(e){if(this._textures&&e._textures)for(let r=0;r<this._textures.length;++r)this._textures[r]._swapAndDie(e._textures[r],!1),e._textures[r].isReady=!0;this._depthStencilTexture&&e._depthStencilTexture&&(this._depthStencilTexture._swapAndDie(e._depthStencilTexture),e._depthStencilTexture.isReady=!0),this._textures=null,this._depthStencilTexture=null}_rebuild(){const e=this._cloneRenderTargetWrapper();if(e){if(this._depthStencilTexture){const r=this._depthStencilTexture.samplingMode,i=this._depthStencilTexture.format,s=r===2||r===3||r===11;e.createDepthStencilTexture(this._depthStencilTexture._comparisonFunction,s,this._depthStencilTextureWithStencil,this._depthStencilTexture.samples,i,this._depthStencilTextureLabel)}this.samples>1&&e.setSamples(this.samples),e._swapRenderTargetWrapper(this),e.dispose()}}releaseTextures(){if(this._textures)for(let e=0;e<this._textures.length;++e)this._textures[e].dispose();this._textures=null}dispose(e=!1){var r;e||((r=this._depthStencilTexture)==null||r.dispose(),this._depthStencilTexture=null,this.releaseTextures()),this._engine._releaseRenderTargetWrapper(this)}}class he extends ue{setDepthStencilTexture(e,r=!0){if(super.setDepthStencilTexture(e,r),!e)return;const i=this._engine,s=this._context,n=e._hardwareTexture;if(n&&e._autoMSAAManagement&&this._MSAAFramebuffer){const o=i._currentFramebuffer;i._bindUnboundFramebuffer(this._MSAAFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,z(e.format)?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,s.RENDERBUFFER,n.getMSAARenderBuffer()),i._bindUnboundFramebuffer(o)}}constructor(e,r,i,s,n){super(e,r,i,s),this._framebuffer=null,this._depthStencilBuffer=null,this._MSAAFramebuffer=null,this._colorTextureArray=null,this._depthStencilTextureArray=null,this._disposeOnlyFramebuffers=!1,this._currentLOD=0,this._context=n}_cloneRenderTargetWrapper(){let e;return this._colorTextureArray&&this._depthStencilTextureArray?(e=this._engine.createMultiviewRenderTargetTexture(this.width,this.height),e.texture.isReady=!0):e=super._cloneRenderTargetWrapper(),e}_swapRenderTargetWrapper(e){super._swapRenderTargetWrapper(e),e._framebuffer=this._framebuffer,e._depthStencilBuffer=this._depthStencilBuffer,e._MSAAFramebuffer=this._MSAAFramebuffer,e._colorTextureArray=this._colorTextureArray,e._depthStencilTextureArray=this._depthStencilTextureArray,this._framebuffer=this._depthStencilBuffer=this._MSAAFramebuffer=this._colorTextureArray=this._depthStencilTextureArray=null}createDepthStencilTexture(e=0,r=!0,i=!1,s=1,n=14,o){if(this._depthStencilBuffer){const a=this._engine,u=a._currentFramebuffer,l=this._context;a._bindUnboundFramebuffer(this._framebuffer),l.framebufferRenderbuffer(l.FRAMEBUFFER,l.DEPTH_STENCIL_ATTACHMENT,l.RENDERBUFFER,null),l.framebufferRenderbuffer(l.FRAMEBUFFER,l.DEPTH_ATTACHMENT,l.RENDERBUFFER,null),l.framebufferRenderbuffer(l.FRAMEBUFFER,l.STENCIL_ATTACHMENT,l.RENDERBUFFER,null),a._bindUnboundFramebuffer(u),l.deleteRenderbuffer(this._depthStencilBuffer),this._depthStencilBuffer=null}return super.createDepthStencilTexture(e,r,i,s,n,o)}shareDepth(e){super.shareDepth(e);const r=this._context,i=this._depthStencilBuffer,s=e._MSAAFramebuffer||e._framebuffer,n=this._engine;e._depthStencilBuffer&&e._depthStencilBuffer!==i&&r.deleteRenderbuffer(e._depthStencilBuffer),e._depthStencilBuffer=i;const o=e._generateStencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;n._bindUnboundFramebuffer(s),r.framebufferRenderbuffer(r.FRAMEBUFFER,o,r.RENDERBUFFER,i),n._bindUnboundFramebuffer(null)}_bindTextureRenderTarget(e,r=0,i,s=0){var _,T;const n=e._hardwareTexture;if(!n)return;const o=this._framebuffer,a=this._engine,u=a._currentFramebuffer;
2a._bindUnboundFramebuffer(o);let l;if(a.webGLVersion>1){const E=this._context;l=E["COLOR_ATTACHMENT"+r],e.is2DArray||e.is3D?(i=i??((_=this.layerIndices)==null?void 0:_[r])??0,E.framebufferTextureLayer(E.FRAMEBUFFER,l,n.underlyingResource,s,i)):e.isCube?(i=i??((T=this.faceIndices)==null?void 0:T[r])??0,E.framebufferTexture2D(E.FRAMEBUFFER,l,E.TEXTURE_CUBE_MAP_POSITIVE_X+i,n.underlyingResource,s)):E.framebufferTexture2D(E.FRAMEBUFFER,l,E.TEXTURE_2D,n.underlyingResource,s)}else{const E=this._context;l=E["COLOR_ATTACHMENT"+r+"_WEBGL"];const c=i!==void 0?E.TEXTURE_CUBE_MAP_POSITIVE_X+i:E.TEXTURE_2D;E.framebufferTexture2D(E.FRAMEBUFFER,l,c,n.underlyingResource,s)}if(e._autoMSAAManagement&&this._MSAAFramebuffer){const E=this._context;a._bindUnboundFramebuffer(this._MSAAFramebuffer),E.framebufferRenderbuffer(E.FRAMEBUFFER,l,E.RENDERBUFFER,n.getMSAARenderBuffer())}a._bindUnboundFramebuffer(u)}setTexture(e,r=0,i=!0){super.setTexture(e,r,i),this._bindTextureRenderTarget(e,r)}setLayerAndFaceIndices(e,r){var s;if(super.setLayerAndFaceIndices(e,r),!this.textures||!this.layerIndices||!this.faceIndices)return;const i=((s=this._attachments)==null?void 0:s.length)??this.textures.length;for(let n=0;n<i;n++){const o=this.textures[n];o&&(o.is2DArray||o.is3D?this._bindTextureRenderTarget(o,n,this.layerIndices[n]):o.isCube?this._bindTextureRenderTarget(o,n,this.faceIndices[n]):this._bindTextureRenderTarget(o,n))}}setLayerAndFaceIndex(e=0,r,i){if(super.setLayerAndFaceIndex(e,r,i),!this.textures||!this.layerIndices||!this.faceIndices)return;const s=this.textures[e];s.is2DArray||s.is3D?this._bindTextureRenderTarget(this.textures[e],e,this.layerIndices[e]):s.isCube&&this._bindTextureRenderTarget(this.textures[e],e,this.faceIndices[e])}resolveMSAATextures(){const e=this._engine,r=e._currentFramebuffer;e._bindUnboundFramebuffer(this._MSAAFramebuffer),super.resolveMSAATextures(),e._bindUnboundFramebuffer(r)}dispose(e=this._disposeOnlyFramebuffers){const r=this._context;e||(this._colorTextureArray&&(this._context.deleteTexture(this._colorTextureArray),this._colorTextureArray=null),this._depthStencilTextureArray&&(this._context.deleteTexture(this._depthStencilTextureArray),this._depthStencilTextureArray=null)),this._framebuffer&&(r.deleteFramebuffer(this._framebuffer),this._framebuffer=null),this._depthStencilBuffer&&(r.deleteRenderbuffer(this._depthStencilBuffer),this._depthStencilBuffer=null),this._MSAAFramebuffer&&(r.deleteFramebuffer(this._MSAAFramebuffer),this._MSAAFramebuffer=null),super.dispose(e)}}f.prototype.createDepthStencilTexture=function(t,e,r){if(e.isCube){const i=t.
vendor: 23,444 bytes, line 2
2width||t;return this._createDepthStencilCubeTexture(i,e)}else return this._createDepthStencilTexture(t,e,r)};R.prototype._createHardwareRenderTargetWrapper=function(t,e,r){const i=new he(t,e,r,this,this._gl);return this._renderTargetWrapperCache.push(i),i};R.prototype.createRenderTargetTexture=function(t,e){const r=this._createHardwareRenderTargetWrapper(!1,!1,t);let i=!0,s=!1,n=!1,o,a=1,u;e!==void 0&&typeof e=="object"&&(i=e.generateDepthBuffer??!0,s=!!e.generateStencilBuffer,n=!!e.noColorAttachment,o=e.colorAttachment,a=e.samples??1,u=e.label);const l=o||(n?null:this._createInternalTexture(t,e,!0,5)),_=t.width||t,T=t.height||t,E=this._currentFramebuffer,c=this._gl,S=c.createFramebuffer();if(this._bindUnboundFramebuffer(S),r._depthStencilBuffer=this._setupFramebufferDepthAttachments(s,i,_,T),l&&!l.is2DArray&&!l.is3D&&c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,l._hardwareTexture.underlyingResource,0),this._bindUnboundFramebuffer(E),r.label=u??"RenderTargetWrapper",r._framebuffer=S,r._generateDepthBuffer=i,r._generateStencilBuffer=s,r.setTextures(l),!o)this.updateRenderTargetTextureSampleCount(r,a);else if(r._samples=o.samples,o.samples>1){const p=o._hardwareTexture.getMSAARenderBuffer(0);r._MSAAFramebuffer=c.createFramebuffer(),this._bindUnboundFramebuffer(r._MSAAFramebuffer),c.framebufferRenderbuffer(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.RENDERBUFFER,p),this._bindUnboundFramebuffer(null)}return r};R.prototype._createDepthStencilTexture=function(t,e,r){const i=this._gl,s=t.layers||0,n=t.depth||0;let o=i.TEXTURE_2D;s!==0?o=i.TEXTURE_2D_ARRAY:n!==0&&(o=i.TEXTURE_3D);const a=new N(this,12);if(a.label=e.label,!this._caps.depthTextureExtension)return y.Error("Depth texture is not supported by your browser or hardware."),a;const u={bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1,...e};if(this._bindTextureDirectly(o,a,!0),this._setupDepthStencilTexture(a,t,u.comparisonFunction===0?!1:u.bilinearFiltering,u.comparisonFunction,u.samples),u.depthTextureFormat!==void 0){if(u.depthTextureFormat!==15&&u.depthTextureFormat!==16&&u.depthTextureFormat!==17&&u.depthTextureFormat!==13&&u.depthTextureFormat!==14&&u.depthTextureFormat!==18)return y.Error(`Depth texture ${u.depthTextureFormat} format is not supported.`),a;a.format=u.depthTextureFormat}else a.format=u.generateStencil?13:16;const l=z(a.format),_=this._getWebGLTextureTypeFromDepthTextureFormat(a.format),T=l?i.DEPTH_STENCIL:i.DEPTH_COMPONENT,E=this._getInternalFormatFromDepthTextureFormat(a.format,!0,l);return a.is2DArray?i.texImage3D(o,0,E,a.width,a.height,s,0,T,_,null):a.is3D?i.texImage3D(o,0,E,a.width,a.height,n,0,T,_,null):i.texImage2D(o,0,E,a.width,a.height,0,T,_,null),this._bindTextureDirectly(o,null),this._internalTexturesCache.push(a),r._depthStencilBuffer&&(i.deleteRenderbuffer(r._depthStencilBuffer),r._depthStencilBuffer=null),this._bindUnboundFramebuffer(r._MSAAFramebuffer??r._framebuffer),r._generateStencilBuffer=l,r._depthStencilTextureWithStencil=l,r._depthStencilBuffer=this._setupFramebufferDepthAttachments(r._generateStencilBuffer,r._generateDepthBuffer,r.width,r.height,r.samples,a.format),this._bindUnboundFramebuffer(null),a};R.prototype.updateRenderTargetTextureSampleCount=function(t,e){var n;if(this.webGLVersion<2||!t)return 1;if(t.samples===e)return e;const r=this._gl;e=Math.min(e,this.getCaps().maxMSAASamples),t._depthStencilBuffer&&(r.deleteRenderbuffer(t._depthStencilBuffer),t._depthStencilBuffer=null),t._MSAAFramebuffer&&(r.deleteFramebuffer(t._MSAAFramebuffer),t._MSAAFramebuffer=null);const i=(n=t.texture)==null?void 0:n._hardwareTexture;if(i==null||i.releaseMSAARenderBuffers(),t.texture&&e>1&&typeof r.renderbufferStorageMultisample=="function"){const o=r.createFramebuffer();if(!o)throw new Error("Unable to create multi sampled framebuffer");t._MSAAFramebuffer=o,this._bindUnboundFramebuffer(t._MSAAFramebuffer);const a=this._createRenderBuffer(t.texture.width,t.texture.height,e,-1,this._getRGBABufferInternalSizedFormat(t.texture.type,t.texture.format,t.texture._useSRGBBuffer),r.COLOR_ATTACHMENT0,!1);if(!a)throw new Error("Unable to create multi sampled framebuffer");i==null||i.addMSAARenderBuffer(a)}this._bindUnboundFramebuffer(t._MSAAFramebuffer??t._framebuffer),t.texture&&(t.texture.samples=e),t._samples=e;const s=t._depthStencilTexture?t._depthStencilTexture.format:void 0;return t._depthStencilBuffer=this._setupFramebufferDepthAttachments(t._generateStencilBuffer,t._generateDepthBuffer,t.width,t.height,e,s),this._bindUnboundFramebuffer(null),e};R.prototype._setupDepthStencilTexture=function(t,e,r,i,s=1){const n=e.width??e,o=e.height??e,a=e.layers||0,u=e.depth||0;t.baseWidth=n,t.baseHeight=o,t.width=n,t.height=o,t.is2DArray=a>0,t.depth=a||u,t.isReady=!0,t.samples=s,t.generateMipMaps=!1,t.samplingMode=r?2:1,t.type=0,t._comparisonFunction=i;const l=this._gl,_=this._getTextureTarget(t),T=this._getSamplingParameters(t.samplingMode,!1);l.texParameteri(_,l.TEXTURE_MAG_FILTER,T.mag),l.texParameteri(_,l.TEXTURE_MIN_FILTER,T.min),l.texParameteri(_,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(_,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),this.webGLVersion>1&&(i===0?(l.texParameteri(_,l.TEXTURE_COMPARE_FUNC,515),l.texParameteri(_,l.TEXTURE_COMPARE_MODE,l.NONE)):(l.texParameteri(_,l.TEXTURE_COMPARE_FUNC,i),l.texParameteri(_,l.TEXTURE_COMPARE_MODE,l.COMPARE_REF_TO_TEXTURE)))};R.prototype.setDepthStencilTexture=function(t,e,r,i){t!==void 0&&(e&&(this._boundUniforms[t]=e),!r||!r.depthStencilTexture?this._setTexture(t,null,void 0,void 0,i):this._setTexture(t,r,!1,!0,i))};R.prototype.createRenderTargetCubeTexture=function(t,e){const r=this._createHardwareRenderTargetWrapper(!1,!0,t),i={generateMipMaps:!0,generateDepthBuffer:!0,generateStencilBuffer:!1,type:0,samplingMode:3,format:5,...e};i.generateStencilBuffer=i.generateDepthBuffer&&i.generateStencilBuffer,(i.type===1&&!this._caps.textureFloatLinearFiltering||i.type===2&&!this._caps.textureHalfFloatLinearFiltering)&&(i.samplingMode=1);const s=this._gl,n=new N(this,5);this._bindTextureDirectly(s.TEXTURE_CUBE_MAP,n,!0);const o=this._getSamplingParameters(i.samplingMode,i.generateMipMaps);i.type===1&&!this._caps.textureFloat&&(i.type=0,y.Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type")),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MAG_FILTER,o.mag),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MIN_FILTER,o.min),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE);for(let u=0;u<6;u++)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+u,0,this._getRGBABufferInternalSizedFormat(i.type,i.format),t,t,0,this._getInternalFormat(i.format),this._getWebGLTextureType(i.type),null);const a=s.createFramebuffer();return this._bindUnboundFramebuffer(a),r._depthStencilBuffer=this._setupFramebufferDepthAttachments(i.generateStencilBuffer,i.generateDepthBuffer,t,t),i.generateMipMaps&&s.generateMipmap(s.TEXTURE_CUBE_MAP),this._bindTextureDirectly(s.TEXTURE_CUBE_MAP,null),this._bindUnboundFramebuffer(null),r._framebuffer=a,r._generateDepthBuffer=i.generateDepthBuffer,r._generateStencilBuffer=i.generateStencilBuffer,n.width=t,n.height=t,n.isReady=!0,n.isCube=!0,n.samples=1,n.generateMipMaps=i.generateMipMaps,n.samplingMode=i.samplingMode,n.type=i.type,n.format=i.format,this._internalTexturesCache.push(n),r.setTextures(n),r};const C=[Math.sqrt(1/(4*Math.PI)),-Math.sqrt(3/(4*Math.PI)),Math.sqrt(3/(4*Math.PI)),-Math.sqrt(3/(4*Math.PI)),Math.sqrt(15/(4*Math.PI)),-Math.sqrt(15/(4*Math.PI)),Math.sqrt(5/(16*Math.PI)),-Math.sqrt(15/(4*Math.PI)),Math.sqrt(15/(16*Math.PI))],_e=[()=>1,t=>t.y,t=>t.z,t=>t.x,t=>t.x*t.y,t=>t.y*t.z,t=>3*t.z*t.z-1,t=>t.x*t.z,t=>t.x*t.x-t.y*t.y],L=(t,e)=>C[t]*_e[t](e),O=[Math.PI,2*Math.PI/3,2*Math.PI/3,2*Math.PI/3,Math.PI/4,Math.PI/4,Math.PI/4,Math.PI/4,Math.PI/4];class V{constructor(){this.preScaled=!1,this.l00=d.Zero(),this.l1_1=d.Zero(),this.l10=d.Zero(),this.l11=d.Zero(),this.l2_2=d.Zero(),this.l2_1=d.Zero(),this.l20=d.Zero(),this.l21=d.Zero(),this.l22=d.Zero()}addLight(e,r,i){A.Vector3[0].set(r.r,r.g,r.b);const s=A.Vector3[0],n=A.Vector3[1];s.scaleToRef(i,n),n.scaleToRef(L(0,e),A.Vector3[2]),this.l00.addInPlace(A.Vector3[2]),n.scaleToRef(L(1,e),A.Vector3[2]),this.l1_1.addInPlace(A.Vector3[2]),n.scaleToRef(L(2,e),A.Vector3[2]),this.l10.addInPlace(A.Vector3[2]),n.scaleToRef(L(3,e),A.Vector3[2]),this.l11.addInPlace(A.Vector3[2]),n.scaleToRef(L(4,e),A.Vector3[2]),this.l2_2.addInPlace(A.Vector3[2]),n.scaleToRef(L(5,e),A.Vector3[2]),this.l2_1.addInPlace(A.Vector3[2]),n.scaleToRef(L(6,e),A.Vector3[2]),this.l20.addInPlace(A.Vector3[2]),n.scaleToRef(L(7,e),A.Vector3[2]),this.l21.addInPlace(A.Vector3[2]),n.scaleToRef(L(8,e),A.Vector3[2]),this.l22.addInPlace(A.Vector3[2])}scaleInPlace(e){this.l00.scaleInPlace(e),this.l1_1.scaleInPlace(e),this.l10.scaleInPlace(e),this.l11.scaleInPlace(e),this.l2_2.scaleInPlace(e),this.l2_1.scaleInPlace(e),this.l20.scaleInPlace(e),this.l21.scaleInPlace(e),this.l22.scaleInPlace(e)}convertIncidentRadianceToIrradiance(){this.l00.scaleInPlace(O[0]),this.l1_1.scaleInPlace(O[1]),this.l10.scaleInPlace(O[2]),this.l11.scaleInPlace(O[3]),this.l2_2.scaleInPlace(O[4]),this.l2_1.scaleInPlace(O[5]),this.l20.scaleInPlace(O[6]),this.l21.scaleInPlace(O[7]),this.l22.scaleInPlace(O[8])}convertIrradianceToLambertianRadiance(){this.scaleInPlace(1/Math.PI)}preScaleForRendering(){this.preScaled=!0,this.l00.scaleInPlace(C[0]),this.l1_1.scaleInPlace(C[1]),this.l10.scaleInPlace(C[2]),this.l11.scaleInPlace(C[3]),this.l2_2.scaleInPlace(C[4]),this.l2_1.scaleInPlace(C[5]),this.l20.scaleInPlace(C[6]),this.l21.scaleInPlace(C[7]),this.l22.scaleInPlace(C[8])}updateFromArray(e){return d.FromArrayToRef(e[0],0,this.l00),d.FromArrayToRef(e[1],0,this.l1_1),d.FromArrayToRef(e[2],0,this.l10),d.FromArrayToRef(e[3],0,this.l11),d.FromArrayToRef(e[4],0,this.l2_2),d.FromArrayToRef(e[5],0,this.l2_1),d.FromArrayToRef(e[6],0,this.l20),d.FromArrayToRef(e[7],0,this.l21),d.FromArrayToRef(e[8],0,this.l22),this}updateFromFloatsArray(e){return d.FromFloatsToRef(e[0],e[1],e[2],this.l00),d.FromFloatsToRef(e[3],e[4],e[5],this.l1_1),d.FromFloatsToRef(e[6],e[7],e[8],this.l10),d.FromFloatsToRef(e[9],e[10],e[11],this.l11),d.FromFloatsToRef(e[12],e[13],e[14],this.l2_2),d.FromFloatsToRef(e[15],e[16],e[17],this.l2_1),d.FromFloatsToRef(e[18],e[19],e[20],this.l20),d.FromFloatsToRef(e[21],e[22],e[23],this.l21),d.FromFloatsToRef(e[24],e[25],e[26],this.l22),this}static FromArray(e){return new V().updateFromArray(e)}static FromPolynomial(e){const r=new V;return r.l00=e.xx.scale(.376127).add(e.yy.scale(.376127)).add(e.zz.scale(.376126)),r.l1_1=e.y.scale(.977204),r.l10=e.z.scale(.977204),r.l11=e.x.scale(.977204),r.l2_2=e.xy.scale(1.16538),r.l2_1=e.yz.scale(1.16538),r.l20=e.zz.scale(1.34567).subtract(e.xx.scale(.672834)).subtract(e.yy.scale(.672834)),r.l21=e.zx.scale(1.16538),r.l22=e.xx.scale(1.16538).subtract(e.yy.scale(1.16538)),r.l1_1.scaleInPlace(-1),r.l11.scaleInPlace(-1),r.l2_1.scaleInPlace(-1),r.l21.scaleInPlace(-1),r.scaleInPlace(Math.PI),r}}class H{constructor(){this.x=d.Zero(),this.y=d.Zero(),this.z=d.Zero(),this.xx=d.Zero(),this.yy=d.Zero(),this.zz=d.Zero(),this.xy=d.Zero(),this.yz=d.Zero(),this.zx=d.Zero()}get preScaledHarmonics(){return this._harmonics||(this._harmonics=V.FromPolynomial(this)),this._harmonics.preScaled||this._harmonics.preScaleForRendering(),this._harmonics}addAmbient(e){A.Vector3[0].copyFromFloats(e.r,e.g,e.b);const r=A.Vector3[0];this.xx.addInPlace(r),this.yy.addInPlace(r),this.zz.addInPlace(r)}scaleInPlace(e){this.x.scaleInPlace(e),this.y.scaleInPlace(e),this.z.scaleInPlace(e),this.xx.scaleInPlace(e),this.yy.scaleInPlace(e),this.zz.scaleInPlace(e),this.yz.scaleInPlace(e),this.zx.scaleInPlace(e),this.xy.scaleInPlace(e)}updateFromHarmonics(e){return this._harmonics=e,this.x.copyFrom(e.l11),this.x.scaleInPlace(1.02333).scaleInPlace(-1),this.y.copyFrom(e.l1_1),this.y.scaleInPlace(1.02333).scaleInPlace(-1),this.z.copyFrom(e.l10),this.z.scaleInPlace(1.02333),this.xx.copyFrom(e.l00),A.Vector3[0].copyFrom(e.l20).scaleInPlace(.247708),A.Vector3[1].copyFrom(e.l22).scaleInPlace(.429043),this.xx.scaleInPlace(.886277).subtractInPlace(A.Vector3[0]).addInPlace(A.Vector3[1]),this.yy.copyFrom(e.l00),this.yy.scaleInPlace(.886277).subtractInPlace(A.Vector3[0]).subtractInPlace(A.Vector3[1]),this.zz.copyFrom(e.l00),A.Vector3[0].copyFrom(e.l20).scaleInPlace(.495417),this.zz.scaleInPlace(.886277).addInPlace(A.Vector3[0]),this.yz.copyFrom(e.l2_1),this.yz.scaleInPlace(.858086).scaleInPlace(-1),this.zx.copyFrom(e.l21),this.zx.scaleInPlace(.858086).scaleInPlace(-1),this.xy.copyFrom(e.l2_2),this.xy.scaleInPlace(.858086),this.scaleInPlace(1/Math.PI),this}static FromHarmonics(e){return new H().updateFromHarmonics(e)}static FromArray(e){const r=new H;return d.FromArrayToRef(e[0],0,r.x),d.FromArrayToRef(e[1],0,r.y),d.FromArrayToRef(e[2],0,r.z),d.FromArrayToRef(e[3],0,r.xx),d.FromArrayToRef(e[4],0,r.yy),d.FromArrayToRef(e[5],0,r.zz),d.FromArrayToRef(e[6],0,r.yz),d.FromArrayToRef(e[7],0,r.zx),d.FromArrayToRef(e[8],0,r.xy),r}}R.prototype.createPrefilteredCubeTexture=function(t,e,r,i,s=null,n=null,o,a=null,u=!0){const l=async _=>{if(!_){s&&s(null);return}const T=_.texture;if(u?_.info.sphericalPolynomial&&(T._sphericalPolynomial=_.info.sphericalPolynomial):T._sphericalPolynomial=T._sphericalPolynomial??new H,T._source=9,this.getCaps().textureLOD){s&&s(T);return}const E=3,c=this._gl,S=_.width;if(!S)return;const{DDSTools:p}=await D(async()=>{const{DDSTools:m}=await import("./dds-CKoTuDuX.js");return{DDSTools:m}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29])),g=[];for(let m=0;m<E;m++){const M=1-m/(E-1),x=i,I=Math.log2(S)*r+i,b=x+(I-x)*M,F=Math.round(Math.min(Math.max(b,0),I)),U=new N(this,2);if(U.type=T.type,U.format=T.format,U.width=Math.pow(2,Math.max(Math.log2(S)-F,0)),U.height=U.width,U.isCube=!0,U._cachedWrapU=0,U._cachedWrapV=0,this._bindTextureDirectly(c.TEXTURE_CUBE_MAP,U,!0),U.samplingMode=2,c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),_.isDDS){const X=_.info,G=_.data;this._unpackFlipY(X.isCompressed),p.UploadDDSLevels(this,U,G,X,!0,6,F)}else y.Warn("DDS is the only prefiltered cube map supported so far.");this._bindTextureDirectly(c.TEXTURE_CUBE_MAP,null);const B=new ne(e);B._isCube=!0,B._texture=U,U.isReady=!0,g.push(B)}T._lodTextureHigh=g[2],T._lodTextureMid=g[1],T._lodTextureLow=g[0],s&&s(T)};return this.createCubeTexture(t,e,null,!1,l,n,o,a,u,r,i)};R.prototype.createUniformBuffer=function(t,e){const r=this._gl.createBuffer();if(!r)throw new Error("Unable to create uniform buffer");const i=new q(r);return this.bindUniformBuffer(i),t instanceof Float32Array?this._gl.bufferData(this._gl.UNIFORM_BUFFER,t,this._gl.STATIC_DRAW):this._gl.bufferData(this._gl.UNIFORM_BUFFER,new Float32Array(t),this._gl.STATIC_DRAW),this.bindUniformBuffer(null),i.references=1,i};R.prototype.createDynamicUniformBuffer=function(t,e){const r=this._gl.createBuffer();if(!r)throw new Error("Unable to create dynamic uniform buffer");const i=new q(r);return this.bindUniformBuffer(i),t instanceof Float32Array?this._gl.bufferData(this._gl.UNIFORM_BUFFER,t,this._gl.DYNAMIC_DRAW):this._gl.bufferData(this._gl.UNIFORM_BUFFER,new Float32Array(t),this._gl.DYNAMIC_DRAW),this.bindUniformBuffer(null),i.references=1,i};R.prototype.updateUniformBuffer=function(t,e,r,i){this.bindUniformBuffer(t),r===void 0&&(r=0),i===void 0?e instanceof Float32Array?this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,r,e):this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,r,new Float32Array(e)):e instanceof Float32Array?this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,0,e.subarray(r,r+i)):this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,0,new Float32Array(e).subarray(r,r+i)),this.bindUniformBuffer(null)};R.prototype.bindUniformBuffer=function(t){this._gl.bindBuffer(this._gl.UNIFORM_BUFFER,t?t.underlyingResource:null)};R.prototype.bindUniformBufferBase=function(t,e,r){this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER,e,t?t.underlyingResource:null)};R.prototype.bindUniformBlock=function(t,e,r){const i=t.program,s=this._gl.getUniformBlockIndex(i,e);s!==4294967295&&this._gl.uniformBlockBinding(i,s,r)};f.prototype.displayLoadingUI=function(){if(!Z())return;const t=this.loadingScreen;t&&t.displayLoadingUI()};f.prototype.hideLoadingUI=function(){if(!Z())return;const t=this._loadingScreen;t&&t.hideLoadingUI()};Object.defineProperty(f.prototype,"loadingScreen",{get:function(){return!this._loadingScreen&&this._renderingCanvas&&(this._loadingScreen=f.DefaultLoadingScreenFactory(this._renderingCanvas)),this._loadingScreen},set:function(t){this._loadingScreen=t},enumerable:!0,configurable:!0});Object.defineProperty(f.prototype,"loadingUIText",{set:function(t){this.loadingScreen.loadingUIText=t},enumerable:!0,configurable:!0});Object.defineProperty(f.prototype,"loadingUIBackgroundColor",{set:function(t){this.loadingScreen.loadingUIBackgroundColor=t},enumerable:!0,configurable:!0});f.prototype.getInputElement=function(){return this._renderingCanvas};f.prototype.getRenderingCanvasClientRect=function(){return this._renderingCanvas?this._renderingCanvas.getBoundingClientRect():null};f.prototype.getInputElementClientRect=function(){return this._renderingCanvas?this.getInputElement().getBoundingClientRect():null};f.prototype.getAspectRatio=function(t,e=!1){const r=t.viewport;return this.getRenderWidth(e)*r.width/(this.getRenderHeight(e)*r.height)};f.prototype.getScreenAspectRatio=function(){return this.getRenderWidth(!0)/this.getRenderHeight(!0)};f.prototype._verifyPointerLock=function(){var t;(t=this._onPointerLockChange)==null||t.call(this)};f.prototype.setAlphaEquation=function(t,e=0){if(this._alphaEquation[e]!==t){switch(t){case 0:this._alphaState.setAlphaEquationParameters(32774,32774,e);break;case 1:this._alphaState.setAlphaEquationParameters(32778,32778,e);break;case 2:this._alphaState.setAlphaEquationParameters(32779,32779,e);break;case 3:this._alphaState.setAlphaEquationParameters(32776,32776,e);break;case 4:this._alphaState.setAlphaEquationParameters(32775,32775,e);break;case 5:this._alphaState.setAlphaEquationParameters(32775,32774,e);break}this._alphaEquation[e]=t}};f.prototype.getInputElement=function(){return this._renderingCanvas};f.prototype.getDepthFunction=function(){return this._depthCullingState.depthFunc};f.prototype.setDepthFunction=function(t){this._depthCullingState.depthFunc=t};f.prototype.setDepthFunctionToGreater=function(){this.setDepthFunction(516)};f.prototype.setDepthFunctionToGreaterOrEqual=function(){this.setDepthFunction(518)};f.prototype.setDepthFunctionToLess=function(){this.setDepthFunction(513)};f.prototype.setDepthFunctionToLessOrEqual=function(){this.setDepthFunction(515)};f.prototype.getDepthWrite=function(){return this._depthCullingState.depthMask};f.prototype.setDepthWrite=function(t){this._depthCullingState.depthMask=t};f.prototype.setAlphaConstants=function(t,e,r,i){this._alphaState.setAlphaBlendConstants(t,e,r,i)};f.prototype.getAlphaMode=function(t=0){return this._alphaMode[t]};f.prototype.getAlphaEquation=function(t=0){return this._alphaEquation[t]};f.prototype.getStencilBuffer=function(){return this._stencilState.stencilTest};f.prototype.setStencilBuffer=function(t){this._stencilState.stencilTest=t};f.prototype.getStencilMask=function(){return this._stencilState.stencilMask};f.prototype.setStencilMask=function(t){this._stencilState.stencilMask=t};f.prototype.getStencilFunction=function(){return this._stencilState.stencilFunc};f.prototype.getStencilBackFunction=function(){return this._stencilState.stencilBackFunc};f.prototype.getStencilFunctionReference=function(){return this._stencilState.stencilFuncRef};f.prototype.getStencilFunctionMask=function(){return this._stencilState.stencilFuncMask};f.prototype.setStencilFunction=function(t){this._stencilState.stencilFunc=t};f.prototype.setStencilBackFunction=function(t){this._stencilState.stencilBackFunc=t};f.prototype.setStencilFunctionReference=function(t){this._stencilState.stencilFuncRef=t};f.prototype.setStencilFunctionMask=function(t){this._stencilState.stencilFuncMask=t};f.prototype.getStencilOperationFail=function(){return this._stencilState.stencilOpStencilFail};f.prototype.getStencilBackOperationFail=function(){return this._stencilState.stencilBackOpStencilFail};f.prototype.getStencilOperationDepthFail=function(){return this._stencilState.stencilOpDepthFail};f.prototype.getStencilBackOperationDepthFail=function(){return this._stencilState.stencilBackOpDepthFail};f.prototype.getStencilOperationPass=function(){return this._stencilState.stencilOpStencilDepthPass};f.prototype.getStencilBackOperationPass=function(){return this._stencilState.stencilBackOpStencilDepthPass};f.prototype.setStencilOperationFail=function(t){this._stencilState.stencilOpStencilFail=t};f.prototype.setStencilBackOperationFail=function(t){this._stencilState.stencilBackOpStencilFail=t};f.prototype.setStencilOperationDepthFail=function(t){this._stencilState.stencilOpDepthFail=t};f.prototype.setStencilBackOperationDepthFail=function(t){this._stencilState.stencilBackOpDepthFail=t};f.prototype.setStencilOperationPass=function(t){this._stencilState.stencilOpStencilDepthPass=t};f.prototype.setStencilBackOperationPass=function(t){this._stencilState.stencilBackOpStencilDepthPass=t};f.prototype.cacheStencilState=function(){this._cachedStencilBuffer=this.getStencilBuffer(),this._cachedStencilFunction=this.getStencilFunction(),this._cachedStencilMask=this.getStencilMask(),this._cachedStencilOperationPass=this.getStencilOperationPass(),this._cachedStencilOperationFail=this.getStencilOperationFail(),this._cachedStencilOperationDepthFail=this.getStencilOperationDepthFail(),this._cachedStencilReference=this.getStencilFunctionReference()};f.prototype.restoreStencilState=function(){this.setStencilFunction(this._cachedStencilFunction),this.setStencilMask(this._cachedStencilMask),this.setStencilBuffer(this._cachedStencilBuffer),this.setStencilOperationPass(this._cachedStencilOperationPass),this.setStencilOperationFail(this._cachedStencilOperationFail),this.setStencilOperationDepthFail(this._cachedStencilOperationDepthFail),this.setStencilFunctionReference(this._cachedStencilReference)};f.prototype.getRenderPassNames=function(){return this._renderPassNames};f.prototype.getCurrentRenderPassName=function(){return this._renderPassNames[this.currentRenderPassId]};f.prototype.createRenderPassId=function(t){const e=++f._RenderPassIdCounter;return this._renderPassNames[e]=t??"NONAME",e};f.prototype.releaseRenderPassId=function(t){this._renderPassNames[t]=void 0;for(let e=0;e<this.scenes.length;++e){const r=this.scenes[e];for(let i=0;i<r.meshes.length;++i){const s=r.meshes[i];if(s._releaseRenderPassId(t),s.subMeshes)for(let n=0;n<s.subMeshes.length;++n)s.subMeshes[n]._removeDrawWrapper(t)}}};f.prototype._loadFileAsync=async function(t,e,r){return await new Promise((i,s)=>{this._loadFile(t,n=>{i(n)},void 0,e,r,(n,o)=>{s(o)})})};const W=new Map;function w(t,e){ce(t)&&y.Warn(`Extension with the name '${t}' already exists`),W.set(t,e)}function ce(t){return W.delete(t)}function fe(t,e){(e==="image/ktx"||e==="image/ktx2")&&(t=".ktx"),W.has(t)||(t.endsWith(".ies")&&w(".
2ies",async()=>await D(()=>import("./iesTextureLoader-DekH8UxR.js"),__vite__mapDeps([30,1])).then(i=>new i._IESTextureLoader)),t.endsWith(".dds")&&w(".dds",async()=>await D(()=>import("./ddsTextureLoader-C0ZNRpnB.js"),__vite__mapDeps([31,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29])).then(i=>new i._DDSTextureLoader)),t.endsWith(".basis")&&w(".basis",async()=>await D(()=>import("./basisTextureLoader-DdLfyHqy.js"),__vite__mapDeps([32,10,4,1,9,2,5,7,8,11])).then(i=>new i._BasisTextureLoader)),t.endsWith(".env")&&w(".env",async()=>await D(()=>import("./envTextureLoader-M9N9qobF.js"),__vite__mapDeps([33,34,13,14,10,4,1,9,2,5,8,35,18,19,36,11,16,17,15,37,29,20,21,22,23,7,12,38,39,3,25,26,27,28])).then(i=>new i._ENVTextureLoader)),t.endsWith(".hdr")&&w(".hdr",async()=>await D(()=>import("./hdrTextureLoader-KSyNFpIa.js"),__vite__mapDeps([40,4,1])).then(i=>new i._HDRTextureLoader)),(t.endsWith(".ktx")||t.endsWith(".ktx2"))&&(w(".ktx",async()=>await D(()=>import("./ktxTextureLoader-DM759aiC.js"),__vite__mapDeps([41,2,42,10,4,1,9,5])).then(i=>new i._KTXTextureLoader)),w(".ktx2",async()=>await D(()=>import("./ktxTextureLoader-DM759aiC.js"),__vite__mapDeps([41,2,42,10,4,1,9,5])).then(i=>new i._KTXTextureLoader))),t.endsWith(".tga")&&w(".tga",async()=>await D(()=>import("./tgaTextureLoader-BtQVr-HR.js"),__vite__mapDeps([43,2])).then(i=>new i._TGATextureLoader)),t.endsWith(".exr")&&w(".exr",async()=>await D(()=>import("./exrTextureLoader-Dj4jBvs0.js"),__vite__mapDeps([44,2,1,10,4,9,5])).then(i=>new i._ExrTextureLoader)));const r=W.get(t);return r?Promise.resolve(r(e)):null}f.GetCompatibleTextureLoader=fe;function Te(t){!t||!t.setAttribute||(t.setAttribute("touch-action","none"),t.style.touchAction="none",t.style.webkitTapHighlightColor="transparent")}function Ee(t,e,r){t._onCanvasFocus=()=>{t.onCanvasFocusObservable.notifyObservers(t)},t._onCanvasBlur=()=>{t.onCanvasBlurObservable.notifyObservers(t)},t._onCanvasContextMenu=s=>{t.disableContextMenu&&s.preventDefault()},e.addEventListener("focus",t._onCanvasFocus),e.addEventListener("blur",t._onCanvasBlur),e.addEventListener("contextmenu",t._onCanvasContextMenu),t._onBlur=()=>{t.disablePerformanceMonitorInBackground&&t.performanceMonitor.disable(),t._windowIsBackground=!0},t._onFocus=()=>{t.disablePerformanceMonitorInBackground&&t.performanceMonitor.enable(),t._windowIsBackground=!1},t._onCanvasPointerOut=s=>{document.elementFromPoint(s.clientX,s.clientY)!==e&&t.onCanvasPointerOutObservable.notifyObservers(s)};const i=t.getHostWindow();i&&typeof i.addEventListener=="function"&&(i.addEventListener("blur",t._onBlur),i.addEventListener("focus",t._onFocus)),e.addEventListener("pointerout",t._onCanvasPointerOut),r.doNotHandleTouchAction||Te(e),!f.audioEngine&&r.audioEngine&&f.AudioEngineFactory&&(f.audioEngine=f.AudioEngineFactory(t.getRenderingCanvas(),t.getAudioContext(),t.getAudioDestination())),K()&&(t._onFullscreenChange=()=>{t.isFullscreen=!!document.fullscreenElement,t.isFullscreen&&t._pointerLockRequested&&e&&J(e)},document.addEventListener("fullscreenchange",t._onFullscreenChange,!1),document.addEventListener("webkitfullscreenchange",t._onFullscreenChange,!1),t._onPointerLockChange=()=>{t.isPointerLock=document.pointerLockElement===e},document.addEventListener("pointerlockchange",t._onPointerLockChange,!1),document.addEventListener("webkitpointerlockchange",t._onPointerLockChange,!1)),t.enableOfflineSupport=f.OfflineProviderFactory!==void 0,t._deterministicLockstep=!!r.deterministicLockstep,t._lockstepMaxSteps=r.lockstepMaxSteps||0,t._timeStep=r.timeStep||1/60}function de(t,e){v.Instances.length===1&&f.audioEngine&&(f.audioEngine.dispose(),f.audioEngine=null);const r=t.getHostWindow();r&&typeof r.removeEventListener=="function"&&(r.removeEventListener("blur",t._onBlur),r.removeEventListener("focus",t._onFocus)),e&&(e.removeEventListener("focus",t._onCanvasFocus),e.removeEventListener("blur",t._onCanvasBlur),e.removeEventListener("pointerout",t._onCanvasPointerOut),e.removeEventListener("contextmenu",t._onCanvasContextMenu)),K()&&(document.removeEventListener("fullscreenchange",t._onFullscreenChange),document.removeEventListener("mozfullscreenchange",t._onFullscreenChange),document.removeEventListener("webkitfullscreenchange",t._onFullscreenChange),document.removeEventListener("msfullscreenchange",t._onFullscreenChange),document.removeEventListener("pointerlockchange",t._onPointerLockChange),document.removeEventListener("mspointerlockchange",t._onPointerLockChange),document.removeEventListener("mozpointerlockchange",t._onPointerLockChange),document.removeEventListener("webkitpointerlockchange",t._onPointerLockChange))}function pe(t){const e=document.createElement("span");e.textContent="Hg",e.style.font=t;const r=document.createElement("div");r.style.display="inline-block",r.style.width="1px",r.style.height="0px",r.style.verticalAlign="bottom";const i=document.createElement("div");i.style.whiteSpace="nowrap",i.appendChild(e),i.appendChild(r),document.body.appendChild(i);let s,n;try{n=r.getBoundingClientRect().top-e.getBoundingClientRect().top,r.style.verticalAlign="baseline",s=r.getBoundingClientRect().top-e.getBoundingClientRect().top}finally{document.body.removeChild(i)}return{ascent:s,height:n,descent:n-s}}async function Re(t,e,r){return await new Promise((i,s)=>{const n=new Image;n.onload=()=>{n.decode().then(()=>{t.createImageBitmap(n,r).then(o=>{i(o)})})},n.onerror=()=>{s(`Error loading image ${n.src}`)},n.src=e})}function ge(t,e,r,i){const n=t.createCanvas(r,i).getContext("2d");if(!n)throw new Error("Unable to get 2d context for resizeImageBitmap");return n.drawImage(e,0,0),n.getImageData(0,0,r,i).data}function Ae(t){const e=t.requestFullscreen||t.webkitRequestFullscreen;e&&e.call(t)}function me(){const t=document;document.exitFullscreen?document.exitFullscreen():t.webkitCancelFullScreen&&t.webkitCancelFullScreen()}function J(t){if(t.requestPointerLock){const e=t.requestPointerLock();e instanceof Promise?e.then(()=>{t.focus()}).catch(()=>{}):t.focus()}}function Fe(){document.exitPointerLock&&document.exitPointerLock()}class h extends R{static get NpmPackage(){return f.NpmPackage}static get Version(){return f.Version}static get Instances(){return v.Instances}static get LastCreatedEngine(){return v.LastCreatedEngine}static get LastCreatedScene(){return v.LastCreatedScene}static DefaultLoadingScreenFactory(e){return f.DefaultLoadingScreenFactory(e)}get _supportsHardwareTextureRescaling(){return!!h._RescalePostProcessFactory}_measureFps(){this._performanceMonitor.sampleFrame(),this._fps=this._performanceMonitor.averageFPS,this._deltaT
vendor: 9,978 bytes, line 2
2ime=this._performanceMonitor.instantaneousFrameTime||0}get performanceMonitor(){return this._performanceMonitor}constructor(e,r,i,s=!1){super(e,r,i,s),this.customAnimationFrameRequester=null,this._performanceMonitor=new le,this._drawCalls=new ae,e&&(this._features.supportRenderPasses=!0)}_initGLContext(){super._initGLContext(),this._rescalePostProcess=null}_sharedInit(e){super._sharedInit(e),Ee(this,e,this._creationOptions)}resizeImageBitmap(e,r,i){return ge(this,e,r,i)}async _createImageBitmapFromSource(e,r){return await Re(this,e,r)}switchFullscreen(e){this.isFullscreen?this.exitFullscreen():this.enterFullscreen(e)}enterFullscreen(e){this.isFullscreen||(this._pointerLockRequested=e,this._renderingCanvas&&Ae(this._renderingCanvas))}exitFullscreen(){this.isFullscreen&&me()}setDitheringState(e){e?this._gl.enable(this._gl.DITHER):this._gl.disable(this._gl.DITHER)}setRasterizerState(e){e?this._gl.disable(this._gl.RASTERIZER_DISCARD):this._gl.enable(this._gl.RASTERIZER_DISCARD)}setDirectViewport(e,r,i,s){const n=this._cachedViewport;return this._cachedViewport=null,this._viewport(e,r,i,s),n}scissorClear(e,r,i,s,n){this.enableScissor(e,r,i,s),this.clear(n,!0,!0,!0),this.disableScissor()}enableScissor(e,r,i,s){const n=this._gl;n.enable(n.SCISSOR_TEST),n.scissor(e,r,i,s)}disableScissor(){const e=this._gl;e.disable(e.SCISSOR_TEST)}getVertexShaderSource(e){const r=this._gl.getAttachedShaders(e);return r?this._gl.getShaderSource(r[0]):null}getFragmentShaderSource(e){const r=this._gl.getAttachedShaders(e);return r?this._gl.getShaderSource(r[1]):null}set framebufferDimensionsObject(e){this._framebufferDimensionsObject=e,this._framebufferDimensionsObject&&this.onResizeObservable.notifyObservers(this)}_rebuildBuffers(){for(const e of this.scenes)e.resetCachedMaterial(),e._rebuildGeometries();for(const e of this._virtualScenes)e.resetCachedMaterial(),e._rebuildGeometries();super._rebuildBuffers()}getFontOffset(e){return pe(e)}_cancelFrame(){if(this.customAnimationFrameRequester){if(this._frameHandler!==0){this._frameHandler=0;const{cancelAnimationFrame:e}=this.customAnimationFrameRequester;e&&e(this.customAnimationFrameRequester.requestID)}}else super._cancelFrame()}_renderLoop(e){this._processFrame(e),this._activeRenderLoops.length>0&&this._frameHandler===0&&(this.customAnimationFrameRequester?(this.customAnimationFrameRequester.requestID=this._queueNewFrame(this.customAnimationFrameRequester.renderFunction||this._boundRenderFunction,this.customAnimationFrameRequester),this._frameHandler=this.customAnimationFrameRequester.requestID):this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow()))}enterPointerlock(){this._renderingCanvas&&J(this._renderingCanvas)}exitPointerlock(){Fe()}beginFrame(){this._measureFps(),super.beginFrame()}_deletePipelineContext(e){const r=e;r&&r.program&&r.transformFeedback&&(this.deleteTransformFeedback(r.transformFeedback),r.transformFeedback=null),super._deletePipelineContext(e)}createShaderProgram(e,r,i,s,n,o=null){n=n||this._gl,this.onBeforeShaderCompilationObservable.notifyObservers(this);const a=super.createShaderProgram(e,r,i,s,n,o);return this.onAfterShaderCompilationObservable.notifyObservers(this),a}_createShaderProgram(e,r,i,s,n=null){const o=s.createProgram();if(e.program=o,!o)throw new Error("Unable to create program");if(s.attachShader(o,r),s.attachShader(o,i),this.webGLVersion>1&&n){const a=this.createTransformFeedback();this.bindTransformFeedback(a),this.setTranformFeedbackVaryings(o,n),e.transformFeedback=a}return s.linkProgram(o),this.webGLVersion>1&&n&&this.bindTransformFeedback(null),e.context=s,e.vertexShader=r,e.fragmentShader=i,e.isParallelCompiled||this._finalizePipelineContext(e),o}_releaseTexture(e){super._releaseTexture(e)}_releaseRenderTargetWrapper(e){super._releaseRenderTargetWrapper(e);for(const r of this.scenes){for(const i of r.postProcesses)i._outputTexture===e&&(i._outputTexture=null);for(const i of r.cameras)for(const s of i._postProcesses)s&&s._outputTexture===e&&(s._outputTexture=null)}}_rescaleTexture(e,r,i,s,n){this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,this._gl.LINEAR),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,this._gl.LINEAR),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.CLAMP_TO_EDGE),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.CLAMP_TO_EDGE);const o=this.createRenderTargetTexture({width:r.width,height:r.height},{generateMipMaps:!1,type:0,samplingMode:2,generateDepthBuffer:!1,generateStencilBuffer:!1});if(!this._rescalePostProcess&&h._RescalePostProcessFactory&&(this._rescalePostProcess=h._RescalePostProcessFactory(this)),this._rescalePostProcess){this._rescalePostProcess.externalTextureSamplerBinding=!0;const a=()=>{this._rescalePostProcess.onApply=function(_){_._bindTexture("textureSampler",e)};let l=i;l||(l=this.scenes[this.scenes.length-1]),l.postProcessManager.directRender([this._rescalePostProcess],o,!0),this._bindTextureDirectly(this._gl.TEXTURE_2D,r,!0),this._gl.copyTexImage2D(this._gl.TEXTURE_2D,0,s,0,0,r.width,r.height,0),this.unBindFramebuffer(o),o.dispose(),n&&n()},u=this._rescalePostProcess.getEffect();u?u.executeWhenCompiled(a):this._rescalePostProcess.onEffectCreatedObservable.addOnce(l=>{l.executeWhenCompiled(a)})}}wrapWebGLTexture(e,r=!1,i=3,s=0,n=0){const o=new ie(e,this._gl),a=new N(this,0,!0);return a._hardwareTexture=o,a.baseWidth=s,a.baseHeight=n,a.width=s,a.height=n,a.isReady=!0,a.useMipMaps=r,this.updateTextureSamplingMode(i,a),a}_uploadImageToTexture(e,r,i=0,s=0){const n=this._gl,o=this._getWebGLTextureType(e.type),a=this._getInternalFormat(e.format),u=this._getRGBABufferInternalSizedFormat(e.type,a),l=e.isCube?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D;this._bindTextureDirectly(l,e,!0),this._unpackFlipY(e.invertY);let _=n.TEXTURE_2D;e.isCube&&(_=n.TEXTURE_CUBE_MAP_POSITIVE_X+i),n.texImage2D(_,s,u,a,o,r),this._bindTextureDirectly(l,null,!0)}updateTextureComparisonFunction(e,r){if(this.webGLVersion===1){y.Error("WebGL 1 does not support texture comparison.");return}const i=this._gl;e.isCube?(this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,e,!0),r===0?(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_FUNC,515),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_MODE,i.NONE)):(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_FUNC,r),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):(this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0),r===0?(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_FUNC,515),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_MODE,i.NONE)):(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_FUNC,r),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_2D,null)),e._comparisonFunction=r}createInstancesBuffer(e){const r=this._gl.createBuffer();if(!r)throw new Error("Unable to create instance buffer");const i=new q(r);return i.capacity=e,this.bindArrayBuffer(i),this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.DYNAMIC_DRAW),i.references=1,i}deleteInstancesBuffer(e){this._gl.deleteBuffer(e)}async _clientWaitAsync(e,r=0,i=10){const s=this._gl;return await new Promise((n,o)=>{se(()=>{const a=s.clientWaitSync(e,r,0);if(a==s.WAIT_FAILED)throw new Error("clientWaitSync failed");return a!=s.TIMEOUT_EXPIRED},n,o,i)})}_readPixelsAsync(e,r,i,s,n,o,a){if(this._webGLVersion<2)throw new Error("_readPixelsAsync only work on WebGL2+");const u=this._gl,l=u.createBuffer();u.bindBuffer(u.PIXEL_PACK_BUFFER,l),u.bufferData(u.PIXEL_PACK_BUFFER,a.byteLength,u.STREAM_READ),u.readPixels(e,r,i,s,n,o,0),u.bindBuffer(u.PIXEL_PACK_BUFFER,null);const _=u.fenceSync(u.SYNC_GPU_COMMANDS_COMPLETE,0);return _?(u.flush(),this._clientWaitAsync(_,0,10).then(()=>(u.deleteSync(_),u.bindBuffer(u.PIXEL_PACK_BUFFER,l),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,a),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),u.deleteBuffer(l),a))):null}dispose(){this.hideLoadingUI(),this._rescalePostProcess&&this._rescalePostProcess.dispose(),de(this,this._renderingCanvas),super.dispose()}}h.ALPHA_DISABLE=0;h.ALPHA_ADD=1;h.ALPHA_COMBINE=2;h.ALPHA_SUBTRACT=3;h.ALPHA_MULTIPLY=4;h.ALPHA_MAXIMIZED=5;h.ALPHA_ONEONE=6;h.ALPHA_PREMULTIPLIED=7;h.ALPHA_PREMULTIPLIED_PORTERDUFF=8;h.ALPHA_INTERPOLATE=9;h.ALPHA_SCREENMODE=10;h.DELAYLOADSTATE_NONE=0;h.DELAYLOADSTATE_LOADED=1;h.DELAYLOADSTATE_LOADING=2;h.DELAYLOADSTATE_NOTLOADED=4;h.NEVER=512;h.ALWAYS=519;h.LESS=513;h.EQUAL=514;h.LEQUAL=515;h.GREATER=516;h.GEQUAL=518;h.NOTEQUAL=517;h.KEEP=7680;h.REPLACE=7681;h.INCR=7682;h.DECR=7683;h.INVERT=5386;h.INCR_WRAP=34055;h.DECR_WRAP=34056;h.TEXTURE_CLAMP_ADDRESSMODE=0;h.TEXTURE_WRAP_ADDRESSMODE=1;h.TEXTURE_MIRROR_ADDRESSMODE=2;h.TEXTUREFORMAT_ALPHA=0;h.TEXTUREFORMAT_LUMINANCE=1;h.TEXTUREFORMAT_LUMINANCE_ALPHA=2;h.TEXTUREFORMAT_RGB=4;h.TEXTUREFORMAT_RGBA=5;h.TEXTUREFORMAT_RED=6;h.TEXTUREFORMAT_R=6;h.TEXTUREFORMAT_R16_UNORM=33322;h.TEXTUREFORMAT_RG16_UNORM=33324;h.TEXTUREFORMAT_RGB16_UNORM=32852;h.TEXTUREFORMAT_RGBA16_UNORM=32859;h.TEXTUREFORMAT_R16_SNORM=36760;h.TEXTUREFORMAT_RG16_SNORM=36761;h.TEXTUREFORMAT_RGB16_SNORM=36762;h.TEXTUREFORMAT_RGBA16_SNORM=36763;h.TEXTUREFORMAT_RG=7;h.TEXTUREFORMAT_RED_INTEGER=8;h.TEXTUREFORMAT_R_INTEGER=8;h.TEXTUREFORMAT_RG_INTEGER=9;h.TEXTUREFORMAT_RGB_INTEGER=10;h.TEXTUREFORMAT_RGBA_INTEGER=11;h.TEXTURETYPE_UNSIGNED_BYTE=0;h.TEXTURETYPE_UNSIGNED_INT=0;h.TEXTURETYPE_FLOAT=1;h.TEXTURETYPE_HALF_FLOAT=2;h.TEXTURETYPE_BYTE=3;h.TEXTURETYPE_SHORT=4;h.TEXTURETYPE_UNSIGNED_SHORT=5;h.TEXTURETYPE_INT=6;h.TEXTURETYPE_UNSIGNED_INTEGER=7;h.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=8;h.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=9;h.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=10;h.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=11;h.TEXTURETYPE_UNSIGNED_INT_24_8=12;h.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=13;h.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=14;h.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=15;
2h.TEXTURE_NEAREST_SAMPLINGMODE=1;h.TEXTURE_BILINEAR_SAMPLINGMODE=2;h.TEXTURE_TRILINEAR_SAMPLINGMODE=3;h.TEXTURE_NEAREST_NEAREST_MIPLINEAR=8;h.TEXTURE_LINEAR_LINEAR_MIPNEAREST=11;h.TEXTURE_LINEAR_LINEAR_MIPLINEAR=3;h.TEXTURE_NEAREST_NEAREST_MIPNEAREST=4;h.TEXTURE_NEAREST_LINEAR_MIPNEAREST=5;h.TEXTURE_NEAREST_LINEAR_MIPLINEAR=6;h.TEXTURE_NEAREST_LINEAR=7;h.TEXTURE_NEAREST_NEAREST=1;h.TEXTURE_LINEAR_NEAREST_MIPNEAREST=9;h.TEXTURE_LINEAR_NEAREST_MIPLINEAR=10;h.TEXTURE_LINEAR_LINEAR=2;h.TEXTURE_LINEAR_NEAREST=12;h.TEXTURE_EXPLICIT_MODE=0;h.TEXTURE_SPHERICAL_MODE=1;h.TEXTURE_PLANAR_MODE=2;h.TEXTURE_CUBIC_MODE=3;h.TEXTURE_PROJECTION_MODE=4;h.TEXTURE_SKYBOX_MODE=5;h.TEXTURE_INVCUBIC_MODE=6;h.TEXTURE_EQUIRECTANGULAR_MODE=7;h.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=8;h.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9;h.SCALEMODE_FLOOR=1;h.SCALEMODE_NEAREST=2;h.SCALEMODE_CEILING=3;const Le=Object.freeze(Object.defineProperty({__proto__:null,Engine:h},Symbol.toStringTag,{value:"Module"}));export{h as E,H as S,fe as _,V as a,Le as e};

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.