babylonjs-addons 8.26.1 → 8.26.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE.md +33 -0
- package/babylonjs.addons.d.ts +1139 -0
- package/babylonjs.addons.js +1 -1
- package/babylonjs.addons.min.js +1 -1
- package/babylonjs.addons.min.js.map +1 -1
- package/babylonjs.addons.module.d.ts +2972 -563
- package/package.json +2 -2
package/babylonjs.addons.min.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-addons",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-addons"]=t(require("babylonjs")):e.ADDONS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(e=>(()=>{"use strict";var t={36:(e,t,r)=>{r.r(t),r.d(t,{msdfVertexShader:()=>s});var i=r(597),n="msdfVertexShader",o="#define BILLBOARD 1\n#define BILLBOARDSCREENPROJECTED 2\nattribute vec2 offsets;attribute vec4 world0;attribute vec4 world1;attribute vec4 world2;attribute vec4 world3;attribute vec4 uvs;uniform mat4 transform;uniform mat4 parentWorld;uniform mat4 view;uniform mat4 projection;uniform vec3 center;uniform int mode;varying vec2 atlasUV;void main(void) {mat4 world=mat4(world0,world1,world2,world3);vec4 worldPos=transform*(world*vec4(offsets.xy-vec2(0.5,0.5),0.,1.0));if (mode>=BILLBOARD) {vec3 viewPos=(view*parentWorld*vec4(0.,0.,0.,1.0)).xyz; \nif (mode==BILLBOARDSCREENPROJECTED) {viewPos.x/=viewPos.z;viewPos.y/=viewPos.z;viewPos.z=1.0;}\ngl_Position=projection*vec4(viewPos+worldPos.xyz,1.0); } else {vec3 viewPos=(view*parentWorld*worldPos).xyz; \ngl_Position=projection*vec4(viewPos,1.0); }\natlasUV=vec2(uvs.x+offsets.x*uvs.z,uvs.y+(1.0-offsets.y)*uvs.w);}";i.ShaderStore.ShadersStore[n]||(i.ShaderStore.ShadersStore[n]=o);var s={name:n,shader:o}},115:(e,t,r)=>{r.r(t),r.d(t,{msdfPixelShaderWGSL:()=>s});var i=r(597),n="msdfPixelShader",o="var fontAtlas: texture_2d<f32>;var fontAtlasSampler: sampler;uniform uColor: vec4f;uniform thickness: f32;uniform uStrokeColor: vec4f;uniform uStrokeInsetWidth: f32;uniform uStrokeOutsetWidth: f32;varying atlasUV: vec2f;fn median(msdf: vec3<f32>)->f32 {let a=min(msdf.r,msdf.g);let b=max(msdf.r,msdf.g);return max(a,min(b,msdf.b));}\n@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {let s=textureSample(fontAtlas,fontAtlasSampler,input.atlasUV).rgb;let sigDist=median(s)-0.5+uniforms.thickness;let afwidth=length(vec2<f32>(dpdx(sigDist),dpdy(sigDist)));let alpha=clamp(sigDist/afwidth+0.5,0.0,1.0);let sigDistOutset=sigDist+uniforms.uStrokeOutsetWidth*0.5;let sigDistInset=sigDist-uniforms.uStrokeInsetWidth*0.5;let afwidthOutset=length(vec2<f32>(dpdx(sigDistOutset),dpdy(sigDistOutset)));let afwidthInset=length(vec2<f32>(dpdx(sigDistInset),dpdy(sigDistInset)));let outset=clamp(sigDistOutset/afwidthOutset+0.5,0.0,1.0);let inset=1.0-clamp(sigDistInset/afwidthInset+0.5,0.0,1.0);let border=outset*inset;let filledFragColor=vec4<f32>(uniforms.uColor.rgb,alpha*uniforms.uColor.a);let strokedFragColor=vec4<f32>(uniforms.uStrokeColor.rgb,border*uniforms.uStrokeColor.a);fragmentOutputs.color=mix(filledFragColor,strokedFragColor,border);}";i.ShaderStore.ShadersStoreWGSL[n]||(i.ShaderStore.ShadersStoreWGSL[n]=o);var s={name:n,shader:o}},370:(e,t,r)=>{r.r(t),r.d(t,{msdfPixelShader:()=>s});var i=r(597),n="msdfPixelShader",o="#extension GL_OES_standard_derivatives : enable\nprecision highp float;uniform sampler2D fontAtlas;uniform vec4 uColor;uniform vec4 uStrokeColor;uniform float uStrokeInsetWidth;uniform float uStrokeOutsetWidth;uniform float thickness;varying vec2 atlasUV;float median(vec3 msdf) {return max(min(msdf.r,msdf.g),min(max(msdf.r,msdf.g),msdf.b));}\nvoid main(void)\n{vec3 s=texture2D(fontAtlas,atlasUV).rgb;float sigDist=median(s)-0.5+thickness;float alpha=clamp(sigDist/fwidth(sigDist)+0.5,0.0,1.0);float sigDistOutset=sigDist+uStrokeOutsetWidth*0.5;float sigDistInset=sigDist-uStrokeInsetWidth*0.5;float outset=clamp(sigDistOutset/fwidth(sigDistOutset)+0.5,0.0,1.0);float inset=1.0-clamp(sigDistInset/fwidth(sigDistInset)+0.5,0.0,1.0);float border=outset*inset;vec4 filledFragColor=vec4(uColor.rgb,alpha*uColor.a);vec4 strokedFragColor=vec4(uStrokeColor.rgb,border*uStrokeColor.a);gl_FragColor=mix(filledFragColor,strokedFragColor,border);}";i.ShaderStore.ShadersStore[n]||(i.ShaderStore.ShadersStore[n]=o);var s={name:n,shader:o}},597:t=>{t.exports=e},681:(e,t,r)=>{r.r(t),r.d(t,{msdfVertexShaderWGSL:()=>s});var i=r(597),n="msdfVertexShader",o="#define BILLBOARD 1\n#define BILLBOARDSCREENPROJECTED 2\nattribute offsets: vec2f;attribute world0: vec4f;attribute world1: vec4f;attribute world2: vec4f;attribute world3: vec4f;attribute uvs: vec4f;uniform transform: mat4x4f;uniform parentWorld: mat4x4f;uniform view: mat4x4f;uniform projection: mat4x4f;uniform mode: u32;varying atlasUV: vec2f;@vertex\nfn main(input: VertexInputs)->FragmentInputs {let world=mat4x4<f32>(input.world0,input.world1,input.world2,input.world3);let localOffset=vec4<f32>(input.offsets-vec2<f32>(0.5,0.5),0.0,1.0);let worldPos=uniforms.transform*world*localOffset;if (uniforms.mode>=BILLBOARD) { \nvar viewPos=(uniforms.view*uniforms.parentWorld*vec4f(0.,0.,0.,1.0)).xyz;if (uniforms.mode==BILLBOARDSCREENPROJECTED) {viewPos=vec3f(viewPos.x/viewPos.z,viewPos.y/viewPos.z,1.0);} \nvertexOutputs.position=uniforms.projection*vec4<f32>(viewPos+worldPos.xyz,1.0);} else { \nlet viewPos=(uniforms.view*uniforms.parentWorld*worldPos).xyz;vertexOutputs.position=uniforms.projection*vec4<f32>(viewPos,1.0);}\nvertexOutputs.atlasUV=vec2<f32>(\ninput.uvs.x+input.offsets.x*input.uvs.z,\ninput.uvs.y+(1.0-input.offsets.y)*input.uvs.w\n);}";i.ShaderStore.ShadersStoreWGSL[n]||(i.ShaderStore.ShadersStoreWGSL[n]=o);var s={name:n,shader:o}}},r={};function i(e){var n=r[e];if(void 0!==n)return n.exports;var o=r[e]={exports:{}};return t[e](o,o.exports,i),o.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};i.d(n,{default:()=>U});var o={};i.r(o),i.d(o,{DefaultParagraphOptions:()=>D,FitStrategy:()=>R,FontAsset:()=>W,HtmlMesh:()=>T,HtmlMeshRenderer:()=>c,PointerEventsCaptureBehavior:()=>I,SdfTextParagraph:()=>k,TextRenderer:()=>L,msdfPixelShader:()=>z.msdfPixelShader,msdfPixelShaderWGSL:()=>F.msdfPixelShaderWGSL,msdfVertexShader:()=>j.msdfVertexShader,msdfVertexShaderWGSL:()=>V.msdfVertexShaderWGSL});var s=i(597),a=100,l=function(e){return function(t,r){var i=t.getMesh(),n=r.getMesh(),o=i.isHtmlMesh,s=n.isHtmlMesh;return o?s&&i.absolutePosition.z<=n.absolutePosition.z?1:-1:s?1:e(t,r)}},c=function(){function e(e,t){var r=void 0===t?{}:t,i=r.parentContainerId,n=void 0===i?null:i,o=r._containerId,a=void 0===o?"css-container":o,l=r.enableOverlayRender,c=void 0===l||l,h=r.defaultOpaqueRenderOrder,d=void 0===h?s.RenderingGroup.PainterSortCompare:h,u=r.defaultAlphaTestRenderOrder,f=void 0===u?s.RenderingGroup.PainterSortCompare:u,p=r.defaultTransparentRenderOrder,v=void 0===p?s.RenderingGroup.defaultTransparentSortCompare:p,m=this;this._cache={cameraData:{fov:0,position:new s.Vector3,style:""},htmlMeshData:new WeakMap},this._width=0,this._height=0,this._heightHalf=0,this._temp={scaleTransform:new s.Vector3,rotationTransform:new s.Quaternion,positionTransform:new s.Vector3,objectMatrix:s.Matrix.Identity(),cameraWorldMatrix:s.Matrix.Identity(),cameraRotationMatrix:s.Matrix.Identity(),cameraWorldMatrixAsArray:new Array(16)},this._lastDevicePixelRatio=window.devicePixelRatio,this._cameraMatrixUpdated=!0,this._previousCanvasDocumentPosition={top:0,left:0},this._renderObserver=null,this._onCameraMatrixChanged=function(e){m._cameraWorldMatrix=e.getWorldMatrix(),m._cameraMatrixUpdated=!0},"undefined"!=typeof document&&(this._containerId=a,this._init(e,n,c,d,f,v))}return e.prototype.dispose=function(){var e,t;this._renderObserver&&(this._renderObserver.remove(),this._renderObserver=null),null===(e=this._overlayElements)||void 0===e||e.container.remove(),this._overlayElements=null,null===(t=this._inSceneElements)||void 0===t||t.container.remove(),this._inSceneElements=null},e.prototype._init=function(e,t,r,i,n,o){var s,a=this;if("undefined"!=typeof document){var c=t?document.getElementById(t):document.body;c||(c=document.body);var h="".concat(this._containerId,"_in_scene");if(this._inSceneElements=this._createRenderLayerElements(h),c.insertBefore(this._inSceneElements.container,c.firstChild),r){var d="".concat(this._containerId,"_overlay");this._overlayElements=this._createRenderLayerElements(d);var u=+(null!==(s=e.getEngine().getRenderingCanvas().style.zIndex)&&void 0!==s?s:"0")+1;this._overlayElements.container.style.zIndex="".concat(u),this._overlayElements.container.style.pointerEvents="none",c.insertBefore(this._overlayElements.container,c.firstChild)}this._engine=e.getEngine();var f,p,v=this._engine.getRenderingCanvasClientRect();if(!v)throw new Error("Failed to get client rect for rendering canvas");this._setSize(v.width,v.height),this._engine.onResizeObservable.add((function(){var e=a._engine.getRenderingCanvasClientRect();e&&a._setSize(e.width,e.height)}));var m=function(){var t=e.activeCamera;t&&(f=t.onProjectionMatrixChangedObservable.add((function(){a._onCameraMatrixChanged(t)})),p=t.onViewMatrixChangedObservable.add((function(){a._onCameraMatrixChanged(t)})))};m(),e.onActiveCameraChanged.add((function(){var t,r;f&&(null===(t=e.activeCamera)||void 0===t||t.onProjectionMatrixChangedObservable.remove(f)),p&&(null===(r=e.activeCamera)||void 0===r||r.onViewMatrixChangedObservable.remove(p)),m()}));var _=l(i),g=l(n),y=l(o);e.setRenderingOrder(0,_,g,y),this._renderObserver=e.onBeforeRenderObservable.add((function(){a._render(e,e.activeCamera)}))}},e.prototype._createRenderLayerElements=function(e){var t=document.getElementById(e);t&&t.remove();var r=document.createElement("div");r.id=e,r.style.position="absolute",r.style.width="100%",r.style.height="100%",r.style.zIndex="-1";var i=document.createElement("div");i.style.overflow="hidden";var n=document.createElement("div");return n.style.webkitTransformStyle="preserve-3d",n.style.transformStyle="preserve-3d",n.style.pointerEvents="none",i.appendChild(n),r.appendChild(i),{container:r,domElement:i,cameraElement:n}},e.prototype._getSize=function(){return{width:this._width,height:this._height}},e.prototype._setSize=function(e,t){if(this._width=e,this._height=t,this._heightHalf=this._height/2,this._inSceneElements&&this._overlayElements)for(var r=0,i=[this._inSceneElements.domElement,this._overlayElements.domElement,this._inSceneElements.cameraElement,this._overlayElements.cameraElement];r<i.length;r++){var n=i[r];n&&(n.style.width="".concat(e,"px"),n.style.height="".concat(t,"px"))}},e.prototype._getCameraCssMatrix=function(e){var t=e.m;return"matrix3d(".concat(this._epsilon(t[0]),",").concat(this._epsilon(-t[1]),",").concat(this._epsilon(t[2]),",").concat(this._epsilon(t[3]),",").concat(this._epsilon(t[4]),",").concat(this._epsilon(-t[5]),",").concat(this._epsilon(t[6]),",").concat(this._epsilon(t[7]),",").concat(this._epsilon(t[8]),",").concat(this._epsilon(-t[9]),",").concat(this._epsilon(t[10]),",").concat(this._epsilon(t[11]),",").concat(this._epsilon(t[12]),",").concat(this._epsilon(-t[13]),",").concat(this._epsilon(t[14]),",").concat(this._epsilon(t[15]),")")},e.prototype._getHtmlContentCssMatrix=function(e,t){var r=e.m,i=t?-1:1;return"matrix3d(".concat(this._epsilon(r[0]),",").concat(this._epsilon(r[1]),",").concat(this._epsilon(r[2]*-i),",").concat(this._epsilon(r[3]),",").concat(this._epsilon(-r[4]),",").concat(this._epsilon(-r[5]),",").concat(this._epsilon(r[6]*i),",").concat(this._epsilon(-r[7]),",").concat(this._epsilon(r[8]*-i),",").concat(this._epsilon(r[9]*-i),",").concat(this._epsilon(r[10]),",").concat(this._epsilon(r[11]*i),",").concat(this._epsilon(r[12]*i),",").concat(this._epsilon(r[13]*i),",").concat(this._epsilon(r[14]*i),",").concat(this._epsilon(r[15]),")")},e.prototype._getTransformationMatrix=function(t,r){var i;if(this._cameraWorldMatrix||(this._cameraWorldMatrix=null===(i=t.getScene().activeCamera)||void 0===i?void 0:i.getWorldMatrix()),!this._cameraWorldMatrix)return s.Matrix.Identity();var n=t.getWorldMatrix(),o=1,l=1;t.sourceWidth&&t.sourceHeight&&(o=t.width/(t.sourceWidth/a),l=t.height/(t.sourceHeight/a));var c=this._temp.scaleTransform,h=this._temp.rotationTransform,d=this._temp.positionTransform,u=this._temp.objectMatrix;n.decompose(c,h,d),c.x*=o,c.y*=l,s.Matrix.ComposeToRef(c,h,d,u);var f=r?-1:1,p=t.getAbsolutePosition();return u.setRowFromFloats(3,(-this._cameraWorldMatrix.m[12]+p.x)*a*f,(-this._cameraWorldMatrix.m[13]+p.y)*a*f,(this._cameraWorldMatrix.m[14]-p.z)*a,this._cameraWorldMatrix.m[15]*e.PROJECTION_SCALE_FACTOR*a),u.multiplyAtIndex(3,a),u.multiplyAtIndex(7,a),u.multiplyAtIndex(11,a),u},e.prototype._renderHtmlMesh=function(e,t){var r,i;if(e.element&&e.element.firstElementChild){var n=this._cache.htmlMeshData.get(e);n||(n={style:""},this._cache.htmlMeshData.set(e,n));var o=e._isCanvasOverlay?null===(r=this._overlayElements)||void 0===r?void 0:r.cameraElement:null===(i=this._inSceneElements)||void 0===i?void 0:i.cameraElement;e.element.parentNode!==o&&o.appendChild(e.element),e.requiresUpdate&&this._updateBaseScaleFactor(e);var a=this._getTransformationMatrix(e,t),l="translate(-50%, -50%) ".concat(this._getHtmlContentCssMatrix(a,t));l+="".concat(t?"matrix3d(".concat(e.billboardMode!==s.TransformNode.BILLBOARDMODE_NONE?1:-1,", 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1)"):""),n.style!==l&&(e.element.style.webkitTransform=l,e.element.style.transform=l),e._markAsUpdated()}},e.prototype._render=function(e,t){var r,i,n,o,a=!1,l=e.useRightHandedSystem;this._updateContainerPositionIfNeeded(),this._cameraMatrixUpdated&&(this._cameraMatrixUpdated=!1,a=!0),t.position.x===this._cache.cameraData.position.x&&t.position.y===this._cache.cameraData.position.y&&t.position.z===this._cache.cameraData.position.z||(this._cache.cameraData.position.copyFrom(t.position),a=!0),window.devicePixelRatio!==this._lastDevicePixelRatio&&(this._lastDevicePixelRatio=window.devicePixelRatio,s.Logger.Log("In render - dpr changed: ",this._lastDevicePixelRatio),a=!0);var c=e.meshes.filter((function(e){return e.isHtmlMesh&&(a||e.requiresUpdate)}));if(a=a||c.length>0){var h=t.getProjectionMatrix().m[5]*this._heightHalf;if(this._cache.cameraData.fov!==h){var d=[null===(r=this._overlayElements)||void 0===r?void 0:r.domElement,null===(i=this._inSceneElements)||void 0===i?void 0:i.domElement];if(t.mode==s.Camera.PERSPECTIVE_CAMERA)for(var u=0,f=d;u<f.length;u++)(M=f[u])&&(M.style.webkitPerspective=h+"px",M.style.perspective=h+"px");else for(var p=0,v=d;p<v.length;p++)(M=v[p])&&(M.style.webkitPerspective="",M.style.perspective="");this._cache.cameraData.fov=h}null===t.parent&&t.computeWorldMatrix();var m=this._temp.cameraWorldMatrix;m.copyFrom(t.getWorldMatrix());var _=this._temp.cameraRotationMatrix;m.getRotationMatrix().transposeToRef(_);var g=this._temp.cameraWorldMatrixAsArray;m.copyToArray(g);var y=l?1:-1;g[1]=_.m[1],g[2]=_.m[2]*y,g[4]=_.m[4]*y,g[6]=_.m[6]*y,g[8]=_.m[8]*y,g[9]=_.m[9]*y,s.Matrix.FromArrayToRef(g,0,m);var x=this._getCameraCssMatrix(m);if(this._cache.cameraData.style!==x){for(var b=0,w=d=[null===(n=this._inSceneElements)||void 0===n?void 0:n.cameraElement,null===(o=this._overlayElements)||void 0===o?void 0:o.cameraElement];b<w.length;b++){var M;(M=w[b])&&(M.style.webkitTransform=x,M.style.transform=x)}this._cache.cameraData.style=x}for(var S=0,C=c;S<C.length;S++){var E=C[S];this._renderHtmlMesh(E,l)}}},e.prototype._updateBaseScaleFactor=function(e){var t=this._width,r=this._height,i=(e.width||1)/(e.height||1);i>t/r?t=r*i:r=t/i,e.setContentSizePx(t,r)},e.prototype._updateContainerPositionIfNeeded=function(){var e,t,r=this._engine.getRenderingCanvasClientRect();if(r){var i=window.scrollY,n=window.scrollX,o=r.top+i,a=r.left+n;if(this._previousCanvasDocumentPosition.top!==o||this._previousCanvasDocumentPosition.left!==a){this._previousCanvasDocumentPosition.top=o,this._previousCanvasDocumentPosition.left=a;for(var l=0,c=[null===(e=this._inSceneElements)||void 0===e?void 0:e.container,null===(t=this._overlayElements)||void 0===t?void 0:t.container];l<c.length;l++){var h=c[l];if(h){var d=h.offsetParent,u=d.getBoundingClientRect(),f=u.top+i,p=u.left+n,v=this._getAncestorMarginsAndPadding(d),m=window.getComputedStyle(document.body),_=parseInt(m.marginTop,10),g=parseInt(m.marginLeft,10);h.style.top="".concat(o-f-v.marginTop+v.paddingTop+_,"px"),h.style.left="".concat(a-p-v.marginLeft+v.paddingLeft+g,"px")}}}}else s.Logger.Warn("Failed to update html mesh renderer position due to failure to get canvas rect. HtmlMesh instances may not render correctly")},e.prototype._epsilon=function(e){return Math.abs(e)<1e-10?0:e},e.prototype._getAncestorMarginsAndPadding=function(e){for(var t=0,r=0,i=0,n=0;e&&e!==document.body&&e!==document.documentElement;){var o=window.getComputedStyle(e);t+=parseInt(o.marginTop,10),r+=parseInt(o.marginLeft,10),i+=parseInt(o.paddingTop,10),n+=parseInt(o.paddingLeft,10),e=e.offsetParent}return{marginTop:t,marginLeft:r,paddingTop:i,paddingLeft:n}},e.PROJECTION_SCALE_FACTOR=1e-5,e}(),h=function(e,t){return h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},h(e,t)};var d=function(){return d=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},d.apply(this,arguments)};Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var u,f=[],p=new Map,v=[],m=null,_=function(e){M("In pointerEventsCapture.requestRelease - Pointer events release requested for ".concat(e)),e&&e!==m?g(e)?p.delete(e):(M("In pointerEventsCapture.requestRelease - Received release request ".concat(e," but no matching capture request was received")),v.includes(e)||v.push(e)):y()},g=function(e){var t=!1;return f=f.filter((function(r){return r!==e||(t=!0,M("In pointerEventsCapture.cancelRequest - Canceling pointer events capture request ".concat(e)),!1)})),t},y=function(){var e=w();M("In pointerEventsCapture.transferPointerEventsOwnership - Transferrring pointer events from ".concat(m," to ").concat(e)),x(),e&&b(e)},x=function(){var e;M("In pointerEventsCapture.doRelease - Releasing pointer events from ".concat(m)),m&&(null===(e=p.get(m))||void 0===e||e.release(),p.delete(m),m=null)},b=function(e){var t;e&&(null===(t=p.get(e))||void 0===t||t.capture()),m=e,M("In pointerEventsCapture.doCapture - Pointer events now captured by ".concat(e))},w=function(){return f.length>0?f.shift():null},M=function(e){("undefined"==typeof window||window["pointer-events-capture-debug"])&&s.Tools.Log("".concat(performance.now()," - game.scene.pointerEvents - ").concat(e,"\ncurrentOwner: ").concat(m,"\nqueue: ").concat(f,"\nunmatched: ").concat(v))},S=null,C=0,E=new WeakMap,O=function(e){"undefined"!=typeof document&&(0===C&&(document.addEventListener("pointermove",A),document.addEventListener("touchstart",A),S=null!=S?S:e,s.Logger.Log("PointerEventsCaptureBehavior: Starting observation of pointer move events."),S.onDisposeObservable.add(P)),C++)},P=function(){document.removeEventListener("pointermove",A),document.removeEventListener("touchstart",A),S=null,s.Logger.Log("PointerEventsCaptureBehavior: Stopping observation of pointer move events."),C=0},B=function(){"undefined"!=typeof document&&S&&--C<=0&&P()},A=function(e){if(S){var t=S.getEngine().getRenderingCanvasClientRect();if(t){var r,i="touches"in e?e.touches[0]:e,n=i.clientX,o=i.clientY,s=n-t.left,a=o-t.top,l=S.pick(s,a,(function(e){var t=E.get(e);return e.isEnabled()&&void 0!==t&&t._captureOnPointerEnter}));r=l.hit?l.pickedMesh:null;var c=parseInt(m||"");r&&r.uniqueId===c||(!c||r&&r.uniqueId===c||_(m),r&&E.get(r).capturePointerEvents())}}},I=function(){function e(e,t,r){var i=(void 0===r?{}:r).captureOnPointerEnter,n=void 0===i||i;this._captureCallback=e,this._releaseCallback=t,this.name="PointerEventsCaptureBehavior",this._attachedMesh=null,this._captureOnPointerEnter=n,"undefined"==typeof document&&s.Logger.Warn("Creating an instance of PointerEventsCaptureBehavior outside of a browser. The behavior will not work.")}return Object.defineProperty(e.prototype,"attachedMesh",{get:function(){return this._attachedMesh},set:function(e){this._attachedMesh=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"captureOnPointerEnter",{set:function(e){this._captureOnPointerEnter!==e&&(this._captureOnPointerEnter=e,this._attachedMesh&&(this._captureOnPointerEnter?O(this._attachedMesh.getScene()):B()))},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){this.attachedMesh=e,E.set(e,this),this._captureOnPointerEnter&&O(e.getScene())},e.prototype.detach=function(){this.attachedMesh&&(E.delete(this.attachedMesh),this._captureOnPointerEnter&&B(),this.attachedMesh=null)},e.prototype.dispose=function(){this.detach()},e.prototype.releasePointerEvents=function(){this.attachedMesh&&_(this.attachedMesh.uniqueId.toString())},e.prototype.capturePointerEvents=function(){var e,t,r;this.attachedMesh&&(e=this.attachedMesh.uniqueId.toString(),t=this._captureCallback,r=this._releaseCallback,M("In pointerEventsCapture.requestCapture - Pointer events capture requested for ".concat(e)),function(e){var t=!1;return v=v.filter((function(r){return r!==e||(t=!0,!1)})),t}(e)?M("In pointerEventsCapture.requestCapture - Capture request matched previous release request ".concat(e,". Cancelling capture request")):(e!==m&&function(e,t,r){M("In pointerEventsCapture.enqueueCaptureRequest - Enqueueing capture request for ".concat(e)),f.includes(e)||(f.push(e),p.set(e,{capture:t,release:r}))}(e,t,r),m||y()))},e}(),R={CONTAIN:{wrapElement:function(e){var t=document.createElement("div");t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center";var r=document.createElement("div");return r.style.visibility="hidden",r.appendChild(e),t.appendChild(r),t},updateSize:function(e,t,r){var i=e.firstElementChild;e.style.width="".concat(t,"px"),e.style.height="".concat(r,"px");var n=[i.offsetWidth,i.offsetHeight],o=n[0],s=n[1],a=Math.min(t/o,r/s);i.style.transform="scale(".concat(a,")"),i.style.visibility="visible"}},COVER:{wrapElement:function(e){var t=document.createElement("div");t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center",t.style.overflow="hidden";var r=document.createElement("div");return r.style.visibility="hidden",r.appendChild(e),t.appendChild(r),t},updateSize:function(e,t,r){var i=e.firstElementChild;e.style.width="".concat(t,"px"),e.style.height="".concat(r,"px");var n=[i.offsetWidth,i.offsetHeight],o=n[0],s=n[1],a=Math.max(t/o,r/s);i.style.transform="scale(".concat(a,")"),i.style.visibility="visible"}},STRETCH:{wrapElement:function(e){var t=document.createElement("div");t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center";var r=document.createElement("div");return r.style.visibility="hidden",r.appendChild(e),t.appendChild(r),t},updateSize:function(e,t,r){var i=e.firstElementChild;e.style.width="".concat(t,"px"),e.style.height="".concat(r,"px");var n=[i.offsetWidth,i.offsetHeight],o=n[0],s=n[1];i.style.transform="scale(".concat(t/o,", ").concat(r/s,")"),i.style.visibility="visible"}},NONE:{wrapElement:function(e){return e},updateSize:function(e,t,r){e&&(e.style.width="".concat(t,"px"),e.style.height="".concat(r,"px"))}}},T=function(e){function t(t,r,i){var n=void 0===i?{}:i,o=n.captureOnPointerEnter,a=void 0===o||o,l=n.isCanvasOverlay,c=void 0!==l&&l,h=n.fitStrategy,d=void 0===h?R.NONE:h,u=e.call(this,r,t)||this;return u._enabled=!1,u._ready=!1,u._isCanvasOverlay=!1,u._requiresUpdate=!0,u._inverseScaleMatrix=null,u._captureOnPointerEnter=!0,u._pointerEventCaptureBehavior=null,u._sourceWidth=null,u._sourceHeight=null,u._fitStrategy=R.NONE,"undefined"==typeof document?(s.Logger.Warn("Creating an instance of an HtmlMesh with id ".concat(r," outside of a browser. The mesh will not be visible.")),u):(u._fitStrategy=d,u._isCanvasOverlay=c,u._createMask(),u._element=u._createElement(),u.setEnabled(!0),u._captureOnPointerEnter=a,u._pointerEventCaptureBehavior=new I(u.capturePointerEvents.bind(u),u.releasePointerEvents.bind(u),{captureOnPointerEnter:u._captureOnPointerEnter}),u.addBehavior(u._pointerEventCaptureBehavior),u)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}h(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(t,e),Object.defineProperty(t.prototype,"isHtmlMesh",{get:function(){return!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sourceWidth",{get:function(){return this._sourceWidth},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sourceHeight",{get:function(){return this._sourceHeight},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return this._width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this._height},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"element",{get:function(){return this._element},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"requiresUpdate",{get:function(){return this._requiresUpdate},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"captureOnPointerEnter",{set:function(e){this._captureOnPointerEnter=e,this._pointerEventCaptureBehavior&&(this._pointerEventCaptureBehavior.captureOnPointerEnter=e)},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){var t;e.prototype.dispose.call(this),null===(t=this._element)||void 0===t||t.remove(),this._element=void 0,this._pointerEventCaptureBehavior&&(this._pointerEventCaptureBehavior.dispose(),this._pointerEventCaptureBehavior=null)},t.prototype._markAsUpdated=function(){this._requiresUpdate=!1},t.prototype.setContent=function(e,t,r){this._setAsReady(!1),this._sourceWidth=null,this._sourceHeight=null,this._element&&(this._width=t,this._height=r,this._requiresUpdate=!0,this.scaling.setAll(1),e&&(this._element.appendChild(this._fitStrategy.wrapElement(e)),this._updateScaleIfNecessary()),this.sourceWidth&&this.sourceHeight&&this._setAsReady(!0))},t.prototype.setEnabled=function(e){this._enabled=e,e&&!this._ready||this._doSetEnabled(e)},t.prototype.setContentSizePx=function(e,t){this._sourceWidth=e,this._sourceHeight=t,this._element&&this._element.firstElementChild&&(this._fitStrategy.updateSize(this._element.firstElementChild,e,t),this._updateScaleIfNecessary(),this.width&&this.height&&this._setAsReady(!0))},t.prototype._setAsReady=function(e){this._ready=e,e?this._doSetEnabled(this._enabled):this._doSetEnabled(!1)},t.prototype._doSetEnabled=function(t){var r,i=this;this._element&&(t&&!this._worldMatrixUpdateObserver?this._worldMatrixUpdateObserver=this.onAfterWorldMatrixUpdateObservable.add((function(){i._requiresUpdate=!0})):t||(null===(r=this._worldMatrixUpdateObserver)||void 0===r||r.remove(),this._worldMatrixUpdateObserver=null),this._element.style.display=t?"":"none",this._setElementzIndex(-1e4*this.position.z),e.prototype.setEnabled.call(this,t))},t.prototype._updateScaleIfNecessary=function(){this.scaling.setAll(1),this._inverseScaleMatrix&&(this.bakeTransformIntoVertices(this._inverseScaleMatrix),this._inverseScaleMatrix=null);var e=this._width||1,t=this._height||1,r=s.Matrix.Scaling(e,t,1);this.bakeTransformIntoVertices(r),this._inverseScaleMatrix=new s.Matrix,r.invertToRef(this._inverseScaleMatrix)},t.prototype._createMask=function(){(0,s.CreatePlaneVertexData)({width:1,height:1}).applyToMesh(this);var e=this.getScene();this.checkCollisions=!0;var t=new s.StandardMaterial("".concat(this.id,"-mat"),e);this._isCanvasOverlay||(t.backFaceCulling=!1,t.disableColorWrite=!0,t.disableLighting=!0),this.material=t,this.material.freeze()},t.prototype._setElementzIndex=function(e){this._element&&(this._element.style.zIndex="".concat(e))},t.prototype.capturePointerEvents=function(){this._element&&(this._element.style.pointerEvents="auto",document.getElementsByTagName("body")[0].style.pointerEvents="none")},t.prototype.releasePointerEvents=function(){this._element&&(document.getElementsByTagName("body")[0].style.pointerEvents="auto",this._element.style.pointerEvents="none")},t.prototype._createElement=function(){if("undefined"!=typeof document){var e=document.createElement("div");return e.id=this.id,e.style.backgroundColor=this._isCanvasOverlay?"transparent":"#000",e.style.zIndex="1",e.style.position="absolute",e.style.pointerEvents="none",e.style.backfaceVisibility="hidden",e}},t}(s.Mesh);!function(e){e[e.SPACE=32]="SPACE",e[e.TOFU=65532]="TOFU"}(u||(u={}));var W=function(){function e(e,t,r){var i=this;this._chars=new Map,this._kernings=new Map,this._font=JSON.parse(e),this._font.pages=[t],this._font.chars.forEach((function(e){return i._chars.set(e.id,e)})),this._font.kernings.forEach((function(e){var t=i._kernings.get(e.first);t||(t=new Map,i._kernings.set(e.first,t)),t.set(e.second,e.amount)})),this._charsRegex=new RegExp("[".concat(this._font.chars.map((function(e){return e.char.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")})).join(""),"]"),"g"),this._updateFallbacks(),this.scale=1/this._font.info.size,this.textures=this._font.pages.map((function(e){var t=new s.Texture(e,r,{noMipmap:!1,invertY:!1});return t.anisotropicFilteringLevel=16,t}))}return e.prototype.dispose=function(){for(var e=0,t=this.textures;e<t.length;e++)t[e].dispose();this.textures.length=0},e.prototype._updateFallbacks=function(){this._chars.has(u.SPACE)||this._chars.set(u.SPACE,{id:u.SPACE,x:0,y:0,width:0,height:0,xoffset:0,yoffset:0,xadvance:.5*this._font.info.size,page:-1,chnl:-1,index:-1,char:" "}),this._chars.has(u.TOFU)||this._chars.set(u.TOFU,{id:u.TOFU,x:0,y:0,width:this._font.info.size,height:this._font.info.size,xoffset:0,yoffset:0,xadvance:.5*this._font.info.size,page:-1,chnl:-1,index:-1,char:""})},e.prototype._getChar=function(e){return this._chars.get(e)||this._chars.get(u.TOFU)},e.prototype._getKerning=function(e,t){var r;return(null===(r=this._kernings.get(e))||void 0===r?void 0:r.get(t))||0},e.prototype._unsupportedChars=function(e){return e.replace(this._charsRegex,"")},e}(),D={maxWidth:1/0,lineHeight:1,letterSpacing:1,tabSize:4,whiteSpace:"pre-line",textAlign:"center",translate:{x:-.5,y:-.5}},k=function(){function e(e,t,r){this.text=e,this.fontAsset=t,this.options=d(d({},D),r);var i=this._computeMetrics(e),n=i.paragraph,o=i.lines,s=i.glyphs,a=i.width,l=i.height;this.paragraph=n,this.lines=o,this.glyphs=s,this.width=a,this.height=l}return Object.defineProperty(e.prototype,"lineHeight",{get:function(){return this.fontAsset._font.common.lineHeight*this.options.lineHeight},enumerable:!1,configurable:!0}),e.prototype._computeMetrics=function(e){for(var t=this,r=this._collapse(e),i=this._breakLines(r).map((function(e){return e.trim()})),n=[],o=0,s=i;o<s.length;o++){var a=s[o];n.push.apply(n,this._wrap(a,n.length))}var l=Math.max.apply(Math,n.map((function(e){return e.width}))),c=this.lineHeight*n.length;("left"!==this.options.textAlign||this.options.translate)&&n.forEach((function(e){for(var r=function(){switch(t.options.textAlign){case"right":return l-e.width;case"center":return(l-e.width)/2;default:return 0}}(),i=t.options.translate?t.options.translate.x*l:0,n=t.options.translate?t.options.translate.y*c:0,o=0,s=e.glyphs;o<s.length;o++){var a=s[o];a.x+=r,a.x+=i,a.y+=n}}));var h=n.flatMap((function(e){return e.glyphs}));return{paragraph:i.join("\n"),lines:n,glyphs:h,width:l,height:c}},e.prototype._breakLines=function(e){return e.split("\n")},e.prototype._collapse=function(e){return e.replace(/\t/g," ".repeat(this.options.tabSize)).replace(/ +/g," ")},e.prototype._wrap=function(e,t){void 0===t&&(t=0);for(var r,i=new Array,n=t,o=new Array,s=0,a=0,l=0,c=l,h=function(){i.push({text:e.slice(l,c),glyphs:o,start:l,end:c,width:a})};c<e.length;){var d=c,u=e.charCodeAt(d),f=this.fontAsset._getChar(u),p=f.width,v=(s+=r?this.fontAsset._getKerning(r.id,f.id):0)+p,m=f.xadvance+this.options.letterSpacing,_=s+m,g=_>this.options.maxWidth||v>this.options.maxWidth;g&&(h(),n++,r=void 0,s=0,a=0,c=(l=c)+1,o=[]);var y=s,x=n*this.lineHeight;o.push({char:f,line:n,position:o.length,x:y,y:x}),g?s=m:(r=f,s=_,a=v,c++)}return o.length>0&&h(),i},e}(),L=function(){function e(e,t,r){void 0===t&&(t=0),this._useVAO=!1,this._vertexBuffers={},this._charMatrices=new Array,this._charUvs=new Array,this._isDirty=!0,this._baseLine=0,this._scalingMatrix=new s.ThinMatrix,this._fontScaleMatrix=new s.ThinMatrix,this._offsetMatrix=new s.ThinMatrix,this._translationMatrix=new s.ThinMatrix,this._baseMatrix=new s.ThinMatrix,this._scaledMatrix=new s.ThinMatrix,this._localMatrix=new s.ThinMatrix,this._finalMatrix=new s.ThinMatrix,this._lineMatrix=new s.ThinMatrix,this._parentWorldMatrix=new s.ThinMatrix,this.color={r:1,g:1,b:1,a:1},this.strokeColor={r:1,g:1,b:1,a:1},this.strokeInsetWidth=0,this.strokeOutsetWidth=0,this.thicknessControl=0,this._parent=null,this._transformMatrix=new s.ThinMatrix,this.isBillboard=!1,this.isBillboardScreenProjected=!1,this.ignoreDepthBuffer=!1,this._engine=e,this._shaderLanguage=t,this._font=r,this._baseLine=r._font.common.lineHeight*r.scale,this._useVAO=e.getCaps().vertexArrayObject&&!e.disableVertexArrayObjects;var i=new Float32Array([0,0,1,0,0,1,1,1]);this._spriteBuffer=new s.Buffer(e,i,!1,2),this._vertexBuffers.offsets=this._spriteBuffer.createVertexBuffer("offsets",0,2),this._resizeBuffers(128)}return Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},set:function(e){this._parent=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transformMatrix",{get:function(){return this._transformMatrix},set:function(e){this._transformMatrix=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"characterCount",{get:function(){return this._charMatrices.length/16},enumerable:!1,configurable:!0}),e.prototype._resizeBuffers=function(e){this._worldBuffer&&(this._worldBuffer.dispose(),this._worldBuffer=null),this._uvBuffer&&(this._uvBuffer.dispose(),this._uvBuffer=null),this._worldBuffer=new s.Buffer(this._engine,new Float32Array(16*e),!0,16),this._vertexBuffers.world0=this._worldBuffer.createVertexBuffer("world0",0,4,16,!0),this._vertexBuffers.world1=this._worldBuffer.createVertexBuffer("world1",4,4,16,!0),this._vertexBuffers.world2=this._worldBuffer.createVertexBuffer("world2",8,4,16,!0),this._vertexBuffers.world3=this._worldBuffer.createVertexBuffer("world3",12,4,16,!0),this._uvBuffer=new s.Buffer(this._engine,new Float32Array(4*e),!0,4),this._vertexBuffers.uvs=this._uvBuffer.createVertexBuffer("uvs",0,4,4,!0)},e.prototype._setShaders=function(e,t){var r;null===(r=this._drawWrapperBase)||void 0===r||r.dispose(),this._drawWrapperBase=new s.DrawWrapper(this._engine),this._drawWrapperBase.drawContext&&(this._drawWrapperBase.drawContext.useInstancing=!0),this._drawWrapperBase.effect=this._engine.createEffect({vertexSource:e,fragmentSource:t},["offsets","world0","world1","world2","world3","uvs"],["parentWorld","view","projection","uColor","thickness","uStrokeColor","uStrokeInsetWidth","uStrokeOutsetWidth","mode","transform"],["fontAtlas"],"",void 0,void 0,void 0,void 0,this._shaderLanguage),this._drawWrapperBase.effect._refCount++},e.prototype.addParagraph=function(e,t,r){var i=this,n=new k(e,this._font,t),o=this._font.scale,a=this._font._font.common.scaleW,l=this._font._font.common.scaleH,c=n.glyphs.filter((function(e){return e.char.page>=0})),h=r;if(!h){var d=n.lineHeight*o,u=n.lines.length*d/2;(0,s.TranslationMatrixToRef)(0,this._baseLine-u,0,this._lineMatrix),h=this._lineMatrix}(0,s.ScalingMatrixToRef)(o,o,1,this._fontScaleMatrix),(0,s.TranslationMatrixToRef)(.5,-.5,0,this._offsetMatrix);var f=this._charUvs.length,p=this._charMatrices.length;c.forEach((function(e,t){i._charUvs[f+4*t+0]=e.char.x/a,i._charUvs[f+4*t+1]=e.char.y/l,i._charUvs[f+4*t+2]=e.char.width/a,i._charUvs[f+4*t+3]=e.char.height/l;var r=e.x+e.char.xoffset,n=1-(e.y+e.char.yoffset);(0,s.ScalingMatrixToRef)(e.char.width,e.char.height,1,i._scalingMatrix),(0,s.MultiplyMatricesToRef)(i._offsetMatrix,i._scalingMatrix,i._baseMatrix),(0,s.TranslationMatrixToRef)(r*o,n*o,0,i._translationMatrix),(0,s.MultiplyMatricesToRef)(i._baseMatrix,i._fontScaleMatrix,i._scaledMatrix),(0,s.MultiplyMatricesToRef)(i._scaledMatrix,i._translationMatrix,i._localMatrix),(0,s.MultiplyMatricesToRef)(i._localMatrix,h,i._finalMatrix),(0,s.CopyMatrixToArray)(i._finalMatrix,i._charMatrices,p+16*t)})),this._isDirty=!0,this._baseLine-=n.lineHeight*o*n.lines.length},e.prototype.render=function(e,t){var r=this._drawWrapperBase,i=r.effect;if(i.isReady()){var n=this._engine;n.setState(!1),n.enableEffect(r),this.ignoreDepthBuffer&&n.setDepthBuffer(!1),this._parent?(0,s.CopyMatrixToRef)(this._parent.getWorldMatrix(),this._parentWorldMatrix):(0,s.IdentityMatrixToRef)(this._parentWorldMatrix),i.setInt("mode",this.isBillboard?this.isBillboardScreenProjected?2:1:0),i.setMatrix("parentWorld",this._parentWorldMatrix),i.setMatrix("view",e),i.setMatrix("projection",t),i.setMatrix("transform",this.transformMatrix),i.setTexture("fontAtlas",this._font.textures[0]),i.setDirectColor4("uColor",this.color),i.setDirectColor4("uStrokeColor",this.strokeColor),i.setFloat("thickness",.9*this.thicknessControl),i.setFloat("uStrokeInsetWidth",this.strokeInsetWidth),i.setFloat("uStrokeOutsetWidth",this.strokeOutsetWidth);var o=this._charMatrices.length/16;this._isDirty&&(this._isDirty=!1,this._worldBuffer.getBuffer().capacity/4<16*o&&this._resizeBuffers(o),this._worldBuffer.update(this._charMatrices),this._uvBuffer.update(this._charUvs)),this._useVAO?(this._vertexArrayObject||(this._vertexArrayObject=n.recordVertexArrayObject(this._vertexBuffers,null,i)),n.bindVertexArrayObject(this._vertexArrayObject,null)):n.bindBuffers(this._vertexBuffers,null,i),n.setAlphaMode(s.Constants.ALPHA_COMBINE),n.drawArraysType(s.Constants.MATERIAL_TriangleStripDrawMode,0,4,o),n.unbindInstanceAttributes(),n.setAlphaMode(s.Constants.ALPHA_DISABLE),this.ignoreDepthBuffer&&n.setDepthBuffer(!0)}},e.prototype.dispose=function(){this._worldBuffer&&(this._worldBuffer.dispose(),this._worldBuffer=null),this._uvBuffer&&(this._uvBuffer.dispose(),this._uvBuffer=null),this._spriteBuffer&&(this._spriteBuffer.dispose(),this._spriteBuffer=null),this._vertexArrayObject&&(this._engine.releaseVertexArrayObject(this._vertexArrayObject),this._vertexArrayObject=null)},e.CreateTextRendererAsync=function(t,r){return n=this,o=void 0,a=function(){var n,o,s,a;return function(e,t){var r,i,n,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(l){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(r=1,i&&(n=2&a[0]?i.return:a[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,a[1])).done)return n;switch(i=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,i=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((n=(n=o.trys).length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){o.label=a[1];break}if(6===a[0]&&o.label<n[1]){o.label=n[1],n=a;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(a);break}n[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],i=0}finally{r=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,l])}}}(this,(function(l){switch(l.label){case 0:if(!r.getCaps().instancedArrays||!r._features.supportSpriteInstancing)throw new Error("Instanced arrays are required for MSDF text rendering.");return n=0,o="",s="",r.isWebGPU?(n=1,[4,Promise.resolve().then(i.bind(i,681))]):[3,3];case 1:return o=l.sent().msdfVertexShaderWGSL.shader,[4,Promise.resolve().then(i.bind(i,115))];case 2:return s=l.sent().msdfPixelShaderWGSL.shader,[3,6];case 3:return[4,Promise.resolve().then(i.bind(i,36))];case 4:return o=l.sent().msdfVertexShader.shader,[4,Promise.resolve().then(i.bind(i,370))];case 5:s=l.sent().msdfPixelShader.shader,l.label=6;case 6:return(a=new e(r,n,t))._setShaders(o,s),[2,a]}}))},new((s=void 0)||(s=Promise))((function(e,t){function r(e){try{l(a.next(e))}catch(e){t(e)}}function i(e){try{l(a.throw(e))}catch(e){t(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof s?n:new s((function(e){e(n)}))).then(r,i)}l((a=a.apply(n,o||[])).next())}));var n,o,s,a},e}(),j=i(36),z=i(370),V=i(681),F=i(115);const U=o;return n.default})()));
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-addons",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-addons"]=t(require("babylonjs")):e.ADDONS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(e=>(()=>{"use strict";var t={36:(e,t,i)=>{i.r(t),i.d(t,{msdfVertexShader:()=>o});var r=i(597),n="msdfVertexShader",a="#define BILLBOARD 1\n#define BILLBOARDSCREENPROJECTED 2\nattribute vec2 offsets;attribute vec4 world0;attribute vec4 world1;attribute vec4 world2;attribute vec4 world3;attribute vec4 uvs;uniform mat4 transform;uniform mat4 parentWorld;uniform mat4 view;uniform mat4 projection;uniform vec3 center;uniform int mode;varying vec2 atlasUV;void main(void) {mat4 world=mat4(world0,world1,world2,world3);vec4 worldPos=transform*(world*vec4(offsets.xy-vec2(0.5,0.5),0.,1.0));if (mode>=BILLBOARD) {vec3 viewPos=(view*parentWorld*vec4(0.,0.,0.,1.0)).xyz; \nif (mode==BILLBOARDSCREENPROJECTED) {viewPos.x/=viewPos.z;viewPos.y/=viewPos.z;viewPos.z=1.0;}\ngl_Position=projection*vec4(viewPos+worldPos.xyz,1.0); } else {vec3 viewPos=(view*parentWorld*worldPos).xyz; \ngl_Position=projection*vec4(viewPos,1.0); }\natlasUV=vec2(uvs.x+offsets.x*uvs.z,uvs.y+(1.0-offsets.y)*uvs.w);}";r.ShaderStore.ShadersStore[n]||(r.ShaderStore.ShadersStore[n]=a);var o={name:n,shader:a}},115:(e,t,i)=>{i.r(t),i.d(t,{msdfPixelShaderWGSL:()=>o});var r=i(597),n="msdfPixelShader",a="var fontAtlas: texture_2d<f32>;var fontAtlasSampler: sampler;uniform uColor: vec4f;uniform thickness: f32;uniform uStrokeColor: vec4f;uniform uStrokeInsetWidth: f32;uniform uStrokeOutsetWidth: f32;varying atlasUV: vec2f;fn median(msdf: vec3<f32>)->f32 {let a=min(msdf.r,msdf.g);let b=max(msdf.r,msdf.g);return max(a,min(b,msdf.b));}\n@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {let s=textureSample(fontAtlas,fontAtlasSampler,input.atlasUV).rgb;let sigDist=median(s)-0.5+uniforms.thickness;let afwidth=length(vec2<f32>(dpdx(sigDist),dpdy(sigDist)));let alpha=clamp(sigDist/afwidth+0.5,0.0,1.0);let sigDistOutset=sigDist+uniforms.uStrokeOutsetWidth*0.5;let sigDistInset=sigDist-uniforms.uStrokeInsetWidth*0.5;let afwidthOutset=length(vec2<f32>(dpdx(sigDistOutset),dpdy(sigDistOutset)));let afwidthInset=length(vec2<f32>(dpdx(sigDistInset),dpdy(sigDistInset)));let outset=clamp(sigDistOutset/afwidthOutset+0.5,0.0,1.0);let inset=1.0-clamp(sigDistInset/afwidthInset+0.5,0.0,1.0);let border=outset*inset;let filledFragColor=vec4<f32>(uniforms.uColor.rgb,alpha*uniforms.uColor.a);let strokedFragColor=vec4<f32>(uniforms.uStrokeColor.rgb,border*uniforms.uStrokeColor.a);fragmentOutputs.color=mix(filledFragColor,strokedFragColor,border);}";r.ShaderStore.ShadersStoreWGSL[n]||(r.ShaderStore.ShadersStoreWGSL[n]=a);var o={name:n,shader:a}},370:(e,t,i)=>{i.r(t),i.d(t,{msdfPixelShader:()=>o});var r=i(597),n="msdfPixelShader",a="#extension GL_OES_standard_derivatives : enable\nprecision highp float;uniform sampler2D fontAtlas;uniform vec4 uColor;uniform vec4 uStrokeColor;uniform float uStrokeInsetWidth;uniform float uStrokeOutsetWidth;uniform float thickness;varying vec2 atlasUV;float median(vec3 msdf) {return max(min(msdf.r,msdf.g),min(max(msdf.r,msdf.g),msdf.b));}\nvoid main(void)\n{vec3 s=texture2D(fontAtlas,atlasUV).rgb;float sigDist=median(s)-0.5+thickness;float alpha=clamp(sigDist/fwidth(sigDist)+0.5,0.0,1.0);float sigDistOutset=sigDist+uStrokeOutsetWidth*0.5;float sigDistInset=sigDist-uStrokeInsetWidth*0.5;float outset=clamp(sigDistOutset/fwidth(sigDistOutset)+0.5,0.0,1.0);float inset=1.0-clamp(sigDistInset/fwidth(sigDistInset)+0.5,0.0,1.0);float border=outset*inset;vec4 filledFragColor=vec4(uColor.rgb,alpha*uColor.a);vec4 strokedFragColor=vec4(uStrokeColor.rgb,border*uStrokeColor.a);gl_FragColor=mix(filledFragColor,strokedFragColor,border);}";r.ShaderStore.ShadersStore[n]||(r.ShaderStore.ShadersStore[n]=a);var o={name:n,shader:a}},597:t=>{t.exports=e},681:(e,t,i)=>{i.r(t),i.d(t,{msdfVertexShaderWGSL:()=>o});var r=i(597),n="msdfVertexShader",a="#define BILLBOARD 1\n#define BILLBOARDSCREENPROJECTED 2\nattribute offsets: vec2f;attribute world0: vec4f;attribute world1: vec4f;attribute world2: vec4f;attribute world3: vec4f;attribute uvs: vec4f;uniform transform: mat4x4f;uniform parentWorld: mat4x4f;uniform view: mat4x4f;uniform projection: mat4x4f;uniform mode: u32;varying atlasUV: vec2f;@vertex\nfn main(input: VertexInputs)->FragmentInputs {let world=mat4x4<f32>(input.world0,input.world1,input.world2,input.world3);let localOffset=vec4<f32>(input.offsets-vec2<f32>(0.5,0.5),0.0,1.0);let worldPos=uniforms.transform*world*localOffset;if (uniforms.mode>=BILLBOARD) { \nvar viewPos=(uniforms.view*uniforms.parentWorld*vec4f(0.,0.,0.,1.0)).xyz;if (uniforms.mode==BILLBOARDSCREENPROJECTED) {viewPos=vec3f(viewPos.x/viewPos.z,viewPos.y/viewPos.z,1.0);} \nvertexOutputs.position=uniforms.projection*vec4<f32>(viewPos+worldPos.xyz,1.0);} else { \nlet viewPos=(uniforms.view*uniforms.parentWorld*worldPos).xyz;vertexOutputs.position=uniforms.projection*vec4<f32>(viewPos,1.0);}\nvertexOutputs.atlasUV=vec2<f32>(\ninput.uvs.x+input.offsets.x*input.uvs.z,\ninput.uvs.y+(1.0-input.offsets.y)*input.uvs.w\n);}";r.ShaderStore.ShadersStoreWGSL[n]||(r.ShaderStore.ShadersStoreWGSL[n]=a);var o={name:n,shader:a}}},i={};function r(e){var n=i[e];if(void 0!==n)return n.exports;var a=i[e]={exports:{}};return t[e](a,a.exports,r),a.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};r.d(n,{default:()=>Ge});var a={};r.r(a),r.d(a,{Atmosphere:()=>te,AtmospherePhysicalProperties:()=>b,DefaultParagraphOptions:()=>ke,DiffuseSkyIrradianceLut:()=>N,FitStrategy:()=>Ie,FontAsset:()=>De,HtmlMesh:()=>Oe,HtmlMeshRenderer:()=>de,PointerEventsCaptureBehavior:()=>Me,SdfTextParagraph:()=>Ve,TextRenderer:()=>Ne,TransmittanceLut:()=>j,msdfPixelShader:()=>Ue.msdfPixelShader,msdfPixelShaderWGSL:()=>ze.msdfPixelShaderWGSL,msdfVertexShader:()=>Fe.msdfVertexShader,msdfVertexShaderWGSL:()=>Be.msdfVertexShaderWGSL});var o=function(e,t){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},o(e,t)};function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var l=function(){return l=Object.assign||function(e){for(var t,i=1,r=arguments.length;i<r;i++)for(var n in t=arguments[i])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},l.apply(this,arguments)};function c(e,t,i){if(i||2===arguments.length)for(var r,n=0,a=t.length;n<a;n++)!r&&n in t||(r||(r=Array.prototype.slice.call(t,0,n)),r[n]=t[n]);return e.concat(r||Array.prototype.slice.call(t))}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var u,p=r(597),d=(s((function(e){var t=u.call(this)||this;return t.APPLY_AERIAL_PERSPECTIVE_INTENSITY=!1,t.APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS=!1,t.USE_AERIAL_PERSPECTIVE_LUT=e,t}),u=p.MaterialDefines),[{name:"inverseViewportSize",size:2,type:"vec2"}]),h=function(e){function t(t,i,r){void 0===r&&(r=!1);var n=e.call(this,t,"AtmospherePBRMaterialPlugin",600,{USE_CUSTOM_REFLECTION:null!==i.diffuseSkyIrradianceLut,CUSTOM_FRAGMENT_BEFORE_FOG:r,USE_AERIAL_PERSPECTIVE_LUT:r&&i.isAerialPerspectiveLutEnabled,APPLY_AERIAL_PERSPECTIVE_INTENSITY:r&&1!==i.aerialPerspectiveIntensity,APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS:r&&0!==i.aerialPerspectiveRadianceBias},!1,!0,!0)||this;return n._atmosphere=i,n._isAerialPerspectiveEnabled=r,n.doNotSerialize=!0,n._pluginManager._addPlugin(n),n}return s(t,e),t.prototype.getUniformBuffersNames=function(e){var t=this._atmosphere.uniformBuffer;t.useUbo&&e.push(t.name)},t.prototype.getUniforms=function(){return e=this._atmosphere,{ubo:d,fragment:"uniform vec2 inverseViewportSize;\n",externalUniforms:e.uniformBuffer.getUniformNames()};var e},t.prototype.isReadyForSubMesh=function(){var e,t,i=!0,r=this._atmosphere;if(this._isAerialPerspectiveEnabled&&r.isAerialPerspectiveLutEnabled){var n=r.aerialPerspectiveLutRenderTarget;i=i&&!!(null==n?void 0:n.isReady())}var a=null!==(t=null===(e=r.transmittanceLut)||void 0===e?void 0:e.renderTarget)&&void 0!==t?t:null;return i&&!!(null==a?void 0:a.isReady())},t.prototype.getActiveTextures=function(e){var t,i,r=this._atmosphere;if(this._isAerialPerspectiveEnabled&&r.isAerialPerspectiveLutEnabled){var n=r.aerialPerspectiveLutRenderTarget;n&&e.push(n)}var a=null!==(i=null===(t=r.transmittanceLut)||void 0===t?void 0:t.renderTarget)&&void 0!==i?i:null;a&&e.push(a)},t.prototype.bindForSubMesh=function(e){var t,i,r=this._atmosphere,n=r.scene.getEngine(),a=e.currentEffect;a&&this._atmosphere.bindUniformBufferToEffect(a);var o=n.getRenderWidth(),s=n.getRenderHeight();if(e.updateFloat2("inverseViewportSize",1/o,1/s),this._isAerialPerspectiveEnabled&&r.isAerialPerspectiveLutEnabled){var l=r.aerialPerspectiveLutRenderTarget;e.setTexture("aerialPerspectiveLut",l)}var c=null!==(i=null===(t=r.transmittanceLut)||void 0===t?void 0:t.renderTarget)&&void 0!==i?i:null;e.setTexture("transmittanceLut",c)},t.prototype.prepareDefines=function(e){var t=e.USE_AERIAL_PERSPECTIVE_LUT,i=e.APPLY_AERIAL_PERSPECTIVE_INTENSITY,r=e.APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS;e.USE_AERIAL_PERSPECTIVE_LUT=this._isAerialPerspectiveEnabled&&this._atmosphere.isAerialPerspectiveLutEnabled,e.APPLY_AERIAL_PERSPECTIVE_INTENSITY=this._isAerialPerspectiveEnabled&&1!==this._atmosphere.aerialPerspectiveIntensity,e.APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS=this._isAerialPerspectiveEnabled&&0!==this._atmosphere.aerialPerspectiveRadianceBias,t===e.USE_AERIAL_PERSPECTIVE_LUT&&i===e.APPLY_AERIAL_PERSPECTIVE_INTENSITY&&r===e.APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS||e.markAllAsDirty()},t.prototype.getSamplers=function(e){e.push("transmittanceLut"),this._isAerialPerspectiveEnabled&&this._atmosphere.isAerialPerspectiveLutEnabled&&e.push("aerialPerspectiveLut")},t.prototype.getCustomCode=function(e){if("fragment"!==e)return null;var t=this._atmosphere.scene.getEngine().supportsUniformBuffers?"-light0.vLightData.xyz":"-vLightData0.xyz",i=this._atmosphere.uniformBuffer.useUbo?"#include<atmosphereUboDeclaration>":"#include<atmosphereFragmentDeclaration>";return{CUSTOM_FRAGMENT_DEFINITIONS:this._isAerialPerspectiveEnabled&&this._atmosphere.isAerialPerspectiveLutEnabled?"uniform sampler2D transmittanceLut;\r\nprecision highp sampler2DArray;\r\nuniform sampler2DArray aerialPerspectiveLut;\r\n".concat(i,"\r\n#include<atmosphereFunctions>"):"uniform sampler2D transmittanceLut;\r\n".concat(i,"\r\n#include<atmosphereFunctions>"),CUSTOM_LIGHT0_COLOR:"\n {\n vec3 positionGlobal = 0.001 * vPositionW + vec3(0., planetRadius, 0.);\n float positionRadius = length(positionGlobal);\n vec3 geocentricNormal = positionGlobal / positionRadius;\n vec3 directionToLight = ".concat(t,";\n float cosAngleLightToZenith = dot(directionToLight, geocentricNormal);\n diffuse0 = lightIntensity * sampleTransmittanceLut(transmittanceLut, positionRadius, cosAngleLightToZenith);\n }\n"),CUSTOM_REFLECTION:"\n {\n vec3 positionGlobal = 0.001 * vPositionW + vec3(0., planetRadius, 0.);\n float positionRadius = length(positionGlobal);\n vec3 geocentricNormal = positionGlobal / positionRadius;\n\n vec3 directionToLight = ".concat(t,";\n float cosAngleLightToZenith = dot(directionToLight, geocentricNormal);\n\n vec2 uv = vec2(0.5 + 0.5 * cosAngleLightToZenith, (positionRadius - planetRadius) / atmosphereThickness);\n float irradianceScaleT = 0.5 * dot(normalW, geocentricNormal) + 0.5;\n float irradianceScale = ((-0.6652 * irradianceScaleT) + 1.5927) * irradianceScaleT + 0.1023;\n vec3 environmentIrradiance = lightIntensity * sampleReflection(irradianceSampler, uv).rgb;\n\n // Add a contribution here to estimate indirect lighting.\n const float r = 0.2;\n float indirect = getLuminance(environmentIrradiance) / max(0.00001, 1. - r);\n environmentIrradiance *= irradianceScale;\n environmentIrradiance += indirect;\n\n environmentIrradiance += additionalDiffuseSkyIrradiance;\n\n const float diffuseBrdf = 1. / PI;\n environmentIrradiance *= diffuseBrdf * diffuseSkyIrradianceIntensity;\n\n reflectionOut.environmentIrradiance = environmentIrradiance;\n reflectionOut.environmentRadiance.rgb = reflectionOut.environmentIrradiance;\n }\n"),CUSTOM_FRAGMENT_BEFORE_FOG:"\n #if USE_AERIAL_PERSPECTIVE_LUT\n {\n vec3 positionGlobal = 0.001 * vPositionW + vec3(0., planetRadius, 0.);\n float distanceFromCamera = distance(positionGlobal, cameraPositionGlobal);\n\n vec4 aerialPerspective = vec4(0.);\n if (sampleAerialPerspectiveLut(\n gl_FragCoord.xy * inverseViewportSize,\n true,\n distanceFromCamera,\n NumAerialPerspectiveLutLayers,\n AerialPerspectiveLutKMPerSlice,\n AerialPerspectiveLutRangeKM,\n aerialPerspective)) {\n finalColor = aerialPerspective + (1. - aerialPerspective.a) * finalColor;\n }\n }\n #endif\n"}},t}(p.MaterialPluginBase),m=new p.Ray(p.Vector3.Zero(),p.Vector3.Zero()),f=function(){function e(){this._inverseViewProjectionMatrixWithoutTranslation=p.Matrix.Identity(),this._directionToLightRelativeToCameraGeocentricNormal=p.Vector3.Up(),this._cosAngleLightToZenith=0,this._cameraRadius=0,this._clampedCameraRadius=0,this._cameraHeight=0,this._clampedCameraHeight=0,this._cameraPositionGlobal=new p.Vector3,this._clampedCameraPositionGlobal=new p.Vector3,this._cosCameraHorizonAngleFromZenith=0,this._sinCameraAtmosphereHorizonAngleFromNadir=0,this._cameraGeocentricNormal=p.Vector3.Up(),this._cameraForward=p.Vector3.Down(),this._cameraNearPlane=0,this._cameraPosition=new p.Vector3,this._viewport=new p.Vector4,this._lastViewMatrix=p.Matrix.Identity(),this._lastProjectionMatrix=p.Matrix.Identity(),this._inverseViewMatrixWithoutTranslation=p.Matrix.Identity(),this._inverseProjectionMatrix=p.Matrix.Identity()}return Object.defineProperty(e.prototype,"inverseViewProjectionMatrixWithoutTranslation",{get:function(){return this._inverseViewProjectionMatrixWithoutTranslation},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"directionToLightRelativeToCameraGeocentricNormal",{get:function(){return this._directionToLightRelativeToCameraGeocentricNormal},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cosAngleLightToZenith",{get:function(){return this._cosAngleLightToZenith},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cameraRadius",{get:function(){return this._cameraRadius},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clampedCameraRadius",{get:function(){return this._clampedCameraRadius},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cameraHeight",{get:function(){return this._cameraHeight},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clampedCameraHeight",{get:function(){return this._clampedCameraHeight},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cameraPositionGlobal",{get:function(){return this._cameraPositionGlobal},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clampedCameraPositionGlobal",{get:function(){return this._clampedCameraPositionGlobal},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cosCameraHorizonAngleFromZenith",{get:function(){return this._cosCameraHorizonAngleFromZenith},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sinCameraAtmosphereHorizonAngleFromNadir",{get:function(){return this._sinCameraAtmosphereHorizonAngleFromNadir},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cameraGeocentricNormal",{get:function(){return this._cameraGeocentricNormal},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cameraForward",{get:function(){return this._cameraForward},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cameraNearPlane",{get:function(){return this._cameraNearPlane},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cameraPosition",{get:function(){return this._cameraPosition},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewport",{get:function(){return this._viewport},enumerable:!1,configurable:!0}),e.prototype.update=function(e,t,i,r,n,a){this._cameraNearPlane=e.minZ,this._cameraForward.copyFrom(e.getForwardRayToRef(m,1).direction);var o=e.getScene().getEngine();this._viewport.copyFromFloats(0,0,o.getRenderWidth(),o.getRenderHeight());var s=e.getViewMatrix(),l=e.getProjectionMatrix();this._lastViewMatrix.equals(s)&&this._lastProjectionMatrix.equals(l)||(this._lastViewMatrix.copyFrom(s),this._lastViewMatrix.setTranslation(p.Vector3.ZeroReadOnly),this._lastViewMatrix.invertToRef(this._inverseViewMatrixWithoutTranslation),this._lastProjectionMatrix.copyFrom(l),this._lastProjectionMatrix.invertToRef(this._inverseProjectionMatrix),this._inverseProjectionMatrix.multiplyToRef(this._inverseViewMatrixWithoutTranslation,this._inverseViewProjectionMatrixWithoutTranslation)),this._cameraPosition.copyFrom(e.globalPosition),this._cameraPosition.scaleToRef(.001,this._cameraPositionGlobal),this._cameraPositionGlobal.y+=t+a,this._cameraHeight=this._cameraPositionGlobal.y-t,this._cameraRadius=this._cameraPositionGlobal.length(),this._clampedCameraRadius=this._cameraRadius,this._cameraPositionGlobal.normalizeToRef(this._cameraGeocentricNormal),this._clampedCameraRadius<i?(this._clampedCameraRadius=i,this._cameraGeocentricNormal.scaleToRef(i,this._clampedCameraPositionGlobal)):this._clampedCameraPositionGlobal.copyFrom(this._cameraPositionGlobal),this._cosCameraHorizonAngleFromZenith=g(t,this._clampedCameraRadius),this._sinCameraAtmosphereHorizonAngleFromNadir=Math.min(1,r/this._clampedCameraRadius),this._clampedCameraHeight=this._clampedCameraRadius-t,this._cosAngleLightToZenith=(0,p.Vector3Dot)(n,this._cameraGeocentricNormal);var c=Math.sqrt(Math.max(0,1-this._cosAngleLightToZenith*this._cosAngleLightToZenith));this._directionToLightRelativeToCameraGeocentricNormal.copyFromFloats(c,this._cosAngleLightToZenith,0),this._directionToLightRelativeToCameraGeocentricNormal.normalize()},e}(),g=function(e,t){var i=Math.min(1,e/t);return-Math.sqrt(1-i*i)},v=new p.Vector3(.005802,.013558,.0331),_=new p.Vector3(.003996,.003996,.003996),y=new p.Vector3(444e-6,444e-6,444e-6),S=new p.Vector3(65e-5,.001881,85e-6),b=function(){function e(e){var t,i,r,n,a,o,s,l,c,u,d;this.onChangedObservable=new p.Observable,this._peakRayleighScattering=new p.Vector3,this._peakMieScattering=new p.Vector3,this._peakMieAbsorption=new p.Vector3,this._peakOzoneAbsorption=new p.Vector3,this._planetRadiusWithOffset=0,this._planetRadiusSquared=0,this._atmosphereRadius=0,this._atmosphereRadiusSquared=0,this._horizonDistanceToAtmosphereEdge=0,this._horizonDistanceToAtmosphereEdgeSquared=0,this._rayleighScattering=new p.Vector3,this._mieScattering=new p.Vector3,this._mieAbsorption=new p.Vector3,this._mieExtinction=new p.Vector3,this._ozoneAbsorption=new p.Vector3,this._planetRadius=null!==(t=null==e?void 0:e.planetRadius)&&void 0!==t?t:6360,this._planetRadiusOffset=null!==(i=null==e?void 0:e.planetRadiusOffset)&&void 0!==i?i:.01,this._atmosphereThickness=null!==(r=null==e?void 0:e.atmosphereThickness)&&void 0!==r?r:100,this._rayleighScatteringScale=null!==(n=null==e?void 0:e.rayleighScatteringScale)&&void 0!==n?n:1,this._peakRayleighScattering.copyFrom(null!==(a=null==e?void 0:e.peakRayleighScattering)&&void 0!==a?a:v),this._mieScatteringScale=null!==(o=null==e?void 0:e.mieScatteringScale)&&void 0!==o?o:1,this._peakMieScattering.copyFrom(null!==(s=null==e?void 0:e.peakMieScattering)&&void 0!==s?s:_),this._mieAbsorptionScale=null!==(l=null==e?void 0:e.mieAbsorptionScale)&&void 0!==l?l:1,this._peakMieAbsorption.copyFrom(null!==(c=null==e?void 0:e.peakMieAbsorption)&&void 0!==c?c:y),this._ozoneAbsorptionScale=null!==(u=null==e?void 0:e.ozoneAbsorptionScale)&&void 0!==u?u:1,this._peakOzoneAbsorption.copyFrom(null!==(d=null==e?void 0:e.peakOzoneAbsorption)&&void 0!==d?d:S),this._recomputeDimensionalParameters(),this._recomputeRayleighScattering(),this._recomputeMieScattering(),this._recomputeMieAbsorption(),this._recomputeOzoneAbsorption()}return Object.defineProperty(e.prototype,"planetRadius",{get:function(){return this._planetRadius},set:function(e){this._planetRadius!==e&&(this._planetRadius=e,this._recomputeDimensionalParameters(),this.onChangedObservable.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"planetRadiusSquared",{get:function(){return this._planetRadiusSquared},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"planetRadiusOffset",{get:function(){return this._planetRadiusOffset},set:function(e){this._planetRadiusOffset!==e&&(this._planetRadiusOffset=e,this._recomputeDimensionalParameters(),this.onChangedObservable.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"planetRadiusWithOffset",{get:function(){return this._planetRadiusWithOffset},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"atmosphereThickness",{get:function(){return this._atmosphereThickness},set:function(e){this._atmosphereThickness!==e&&(this._atmosphereThickness=e,this._recomputeDimensionalParameters(),this.onChangedObservable.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"atmosphereRadius",{get:function(){return this._atmosphereRadius},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"atmosphereRadiusSquared",{get:function(){return this._atmosphereRadiusSquared},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"horizonDistanceToAtmosphereEdge",{get:function(){return this._horizonDistanceToAtmosphereEdge},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"horizonDistanceToAtmosphereEdgeSquared",{get:function(){return this._horizonDistanceToAtmosphereEdgeSquared},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rayleighScatteringScale",{get:function(){return this._rayleighScatteringScale},set:function(e){this._rayleighScatteringScale!==e&&(this._rayleighScatteringScale=e,this._recomputeRayleighScattering(),this.onChangedObservable.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"peakRayleighScattering",{get:function(){return this._peakRayleighScattering},set:function(e){this._peakRayleighScattering.equals(e)||(this._peakRayleighScattering.copyFrom(e),this._recomputeRayleighScattering(),this.onChangedObservable.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rayleighScattering",{get:function(){return this._rayleighScattering},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mieScatteringScale",{get:function(){return this._mieScatteringScale},set:function(e){this._mieScatteringScale!==e&&(this._mieScatteringScale=e,this._recomputeMieScattering(),this.onChangedObservable.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"peakMieScattering",{get:function(){return this._peakMieScattering},set:function(e){this._peakMieScattering.equals(e)||(this._peakMieScattering.copyFrom(e),this._recomputeMieScattering(),this.onChangedObservable.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mieScattering",{get:function(){return this._mieScattering},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mieAbsorptionScale",{get:function(){return this._mieAbsorptionScale},set:function(e){this._mieAbsorptionScale!==e&&(this._mieAbsorptionScale=e,this._recomputeMieAbsorption(),this.onChangedObservable.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"peakMieAbsorption",{get:function(){return this._peakMieAbsorption},set:function(e){this._peakMieAbsorption.equals(e)||(this._peakMieAbsorption.copyFrom(e),this._recomputeMieAbsorption(),this.onChangedObservable.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mieAbsorption",{get:function(){return this._mieAbsorption},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mieExtinction",{get:function(){return this._mieExtinction},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ozoneAbsorptionScale",{get:function(){return this._ozoneAbsorptionScale},set:function(e){this._ozoneAbsorptionScale!==e&&(this._ozoneAbsorptionScale=e,this._recomputeOzoneAbsorption(),this.onChangedObservable.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"peakOzoneAbsorption",{get:function(){return this._peakOzoneAbsorption},set:function(e){this._peakOzoneAbsorption.equals(e)||(this._peakOzoneAbsorption.copyFrom(e),this._recomputeOzoneAbsorption(),this.onChangedObservable.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ozoneAbsorption",{get:function(){return this._ozoneAbsorption},enumerable:!1,configurable:!0}),e.prototype._recomputeDimensionalParameters=function(){this._planetRadiusWithOffset=this._planetRadius+this._planetRadiusOffset,this._planetRadiusSquared=this._planetRadius*this._planetRadius,this._atmosphereRadius=this._planetRadius+this._atmosphereThickness,this._atmosphereRadiusSquared=this._atmosphereRadius*this._atmosphereRadius,this._horizonDistanceToAtmosphereEdgeSquared=this._atmosphereRadiusSquared-this._planetRadiusSquared,this._horizonDistanceToAtmosphereEdge=Math.sqrt(this._horizonDistanceToAtmosphereEdgeSquared)},e.prototype._recomputeRayleighScattering=function(){this._peakRayleighScattering.scaleToRef(this._rayleighScatteringScale,this._rayleighScattering)},e.prototype._recomputeMieScattering=function(){this._peakMieScattering.scaleToRef(this._mieScatteringScale,this._mieScattering),this._recomputeMieExtinction()},e.prototype._recomputeMieAbsorption=function(){this._peakMieAbsorption.scaleToRef(this._mieAbsorptionScale,this._mieAbsorption),this._recomputeMieExtinction()},e.prototype._recomputeMieExtinction=function(){this._mieAbsorption.addToRef(this._mieScattering,this._mieExtinction)},e.prototype._recomputeOzoneAbsorption=function(){this._peakOzoneAbsorption.scaleToRef(this._ozoneAbsorptionScale,this._ozoneAbsorption)},e}(),P=function(){return{r:Number.NaN,g:Number.NaN,b:Number.NaN,a:Number.NaN}},T=P(),A=P(),R=P(),L=P(),E=function(e,t,i,r,n,a,o){void 0===o&&(o=function(e){return e/255}),e=(0,p.Clamp)(e),t=(0,p.Clamp)(t);var s=Math.max(e*i-.5,0),l=Math.max(t*r-.5,0),c=Math.floor(s),u=Math.min(c+1,i-1),d=Math.floor(l),h=Math.min(d+1,r-1),m=C(c,d,i,r,n,T,o),f=C(c,h,i,r,n,A,o),g=C(u,d,i,r,n,R,o),v=C(u,h,i,r,n,L,o),_=s-c,y=l-d,S=1-_,b=1-y,P=S*b,E=_*b,x=S*y,w=_*y;return a.r=m.r*P+g.r*E+f.r*x+v.r*w,a.g=m.g*P+g.g*E+f.g*x+v.g*w,a.b=m.b*P+g.b*E+f.b*x+v.b*w,a.a=m.a*P+g.a*E+f.a*x+v.a*w,a},C=function(e,t,i,r,n,a,o){void 0===o&&(o=function(e){return e/255});var s=(0,p.Clamp)(e,0,i-1),l=4*((0,p.Clamp)(t,0,r-1)*i+s);return a.r=o(n[l]),a.g=o(n[l+1]),a.b=o(n[l+2]),a.a=o(n[l+3]),a},x="atmosphereFragmentDeclaration";p.ShaderStore.IncludesShadersStore[x]||(p.ShaderStore.IncludesShadersStore[x]="uniform vec3 peakRayleighScattering;uniform float planetRadius;uniform vec3 peakMieScattering;uniform float atmosphereThickness;uniform vec3 peakMieAbsorption;uniform float planetRadiusSquared;uniform vec3 peakMieExtinction;uniform float atmosphereRadius;uniform vec3 peakOzoneAbsorption;uniform float atmosphereRadiusSquared;uniform float horizonDistanceToAtmosphereEdge;uniform float horizonDistanceToAtmosphereEdgeSquared;uniform float planetRadiusWithOffset;uniform float planetRadiusOffset;uniform float atmosphereExposure;uniform float aerialPerspectiveRadianceBias;uniform float inverseAtmosphereThickness;uniform float aerialPerspectiveTransmittanceScale;uniform mat4 inverseViewProjectionWithoutTranslation;uniform vec3 directionToLight;uniform float multiScatteringIntensity;uniform vec3 directionToLightRelativeToCameraGeocentricNormal;uniform float cameraRadius;uniform vec3 lightRadianceAtCamera;uniform float diffuseSkyIrradianceDesaturationFactor;uniform vec3 groundAlbedo;uniform float aerialPerspectiveSaturation;uniform vec3 minMultiScattering;uniform float diffuseSkyIrradianceIntensity;uniform vec3 cameraPositionGlobal;uniform float lightIntensity;uniform vec3 clampedCameraPositionGlobal;uniform float aerialPerspectiveIntensity;uniform vec3 cameraGeocentricNormal;uniform float clampedCameraRadius;uniform vec3 cameraForward;uniform float clampedCameraHeight;uniform vec3 cameraPosition;uniform float cosCameraHorizonAngleFromZenith;uniform vec4 viewport;uniform vec3 additionalDiffuseSkyIrradiance;uniform float cameraHeight;uniform float cameraNearPlane;uniform float originHeight;uniform float sinCameraAtmosphereHorizonAngleFromNadir;\n");var w="atmosphereUboDeclaration";p.ShaderStore.IncludesShadersStore[w]||(p.ShaderStore.IncludesShadersStore[w]="layout(std140,column_major) uniform;uniform Atmosphere {vec3 peakRayleighScattering;float planetRadius;vec3 peakMieScattering;float atmosphereThickness;vec3 peakMieAbsorption;float planetRadiusSquared;vec3 peakMieExtinction;float atmosphereRadius;vec3 peakOzoneAbsorption;float atmosphereRadiusSquared;float horizonDistanceToAtmosphereEdge;float horizonDistanceToAtmosphereEdgeSquared;float planetRadiusWithOffset;float planetRadiusOffset;float atmosphereExposure;float aerialPerspectiveRadianceBias;float inverseAtmosphereThickness;float aerialPerspectiveTransmittanceScale;mat4 inverseViewProjectionWithoutTranslation;vec3 directionToLight;float multiScatteringIntensity;vec3 directionToLightRelativeToCameraGeocentricNormal;float cameraRadius;vec3 lightRadianceAtCamera;float diffuseSkyIrradianceDesaturationFactor;vec3 groundAlbedo;float aerialPerspectiveSaturation;vec3 minMultiScattering;float diffuseSkyIrradianceIntensity;vec3 cameraPositionGlobal;float lightIntensity;vec3 clampedCameraPositionGlobal;float aerialPerspectiveIntensity;vec3 cameraGeocentricNormal;float clampedCameraRadius;vec3 cameraForward;float clampedCameraHeight;vec3 cameraPosition;float cosCameraHorizonAngleFromZenith;vec4 viewport;vec3 additionalDiffuseSkyIrradiance;float cameraHeight;float cameraNearPlane;float originHeight;float sinCameraAtmosphereHorizonAngleFromNadir;};\n");var M="depthFunctions";p.ShaderStore.IncludesShadersStore[M]||(p.ShaderStore.IncludesShadersStore[M]="float reconstructDistanceFromCameraPlane(float depth,float cameraNearPlane) {return cameraNearPlane/(1.0-depth);}\nfloat sampleDistanceFromCameraPlane(sampler2D depthTexture,vec2 uv,float cameraNearPlane) {float depth=textureLod(depthTexture,uv,0.).r;return depth>=1. ? 0. : reconstructDistanceFromCameraPlane(depth,cameraNearPlane);}\nfloat reconstructDistanceFromCamera(float depth,vec3 cameraRayDirection,vec3 cameraForward,float cameraNearPlane) {float distanceFromCameraPlane=reconstructDistanceFromCameraPlane(depth,cameraNearPlane);return distanceFromCameraPlane/max(0.00001,dot(cameraForward,cameraRayDirection));}\nfloat reconstructDistanceFromCamera(\nsampler2D depthTexture,\nvec2 uv,\nvec3 cameraRayDirection,\nvec3 cameraForward,\nfloat cameraNearPlane) {float depth=textureLod(depthTexture,uv,0.).r;return depth>=1. ? 0. : reconstructDistanceFromCamera(depth,cameraRayDirection,cameraForward,cameraNearPlane);}");var I="atmosphereFunctions";p.ShaderStore.IncludesShadersStore[I]||(p.ShaderStore.IncludesShadersStore[I]="#include<intersectionFunctions>\nconst vec2 MultiScatteringLutSize=vec2(32.0,32.0);const vec2 MultiScatteringLutDomainInUVSpace=(MultiScatteringLutSize-vec2(1.0))/MultiScatteringLutSize;const vec2 MultiScatteringLutHalfTexelSize=vec2(0.5)/MultiScatteringLutSize;const float NumAerialPerspectiveLutLayers=32.0;const vec3 AerialPerspectiveLutSize=vec3(16.0,64.0,NumAerialPerspectiveLutLayers);const vec2 DiffuseSkyIrradianceLutSize=vec2(64.0,16.0);const vec2 DiffuseSkyIrradianceLutDomainInUVSpace=(DiffuseSkyIrradianceLutSize-vec2(1.0))/DiffuseSkyIrradianceLutSize;const vec2 DiffuseSkyIrradianceLutHalfTexelSize=vec2(0.5)/DiffuseSkyIrradianceLutSize;const vec2 SkyViewLutSize=vec2(128.0,128.0);const vec2 SkyViewLutDomainInUVSpace=(SkyViewLutSize-vec2(1.0))/SkyViewLutSize;const vec2 SkyViewLutHalfTexelSize=vec2(0.5)/SkyViewLutSize;const float AerialPerspectiveLutKMPerSlice=4.0;const float AerialPerspectiveLutRangeKM=AerialPerspectiveLutKMPerSlice*NumAerialPerspectiveLutLayers;const float TransmittanceSampleCount=128.0;const float SkyViewLutSampleCount=30.0;const vec2 TransmittanceLutSize=vec2(256.,64.);const vec2 TransmittanceLutDomainInUVSpace=(TransmittanceLutSize-vec2(1.))/TransmittanceLutSize;const vec2 TransmittanceLutHalfTexelSize=vec2(0.5)/TransmittanceLutSize;const float TransmittanceHorizonRange=2.*TransmittanceLutHalfTexelSize.x;const float TransmittanceMaxUnoccludedU=1.-0.5*TransmittanceHorizonRange;const float TransmittanceMinOccludedU=1.+0.5*TransmittanceHorizonRange;vec2 uvToUnit(vec2 uv,vec2 domainInUVSpace,vec2 halfTexelSize) {return (uv-halfTexelSize)/domainInUVSpace;}\nvec2 unitToUV(vec2 unit,vec2 domainInUVSpace,vec2 halfTexelSize) {return unit*domainInUVSpace+halfTexelSize;}\nfloat sphereIntersectNearest(vec3 rayOrigin,vec3 rayDirection,float sphereRadius) {vec2 result=sphereIntersectFromOrigin(rayOrigin,rayDirection,sphereRadius);float c=dot(rayOrigin,rayOrigin)-sphereRadius*sphereRadius;return c>=0.0 ?\nresult.y :\nresult.x;}\nvoid moveToTopAtmosphere(\nvec3 cameraPosition,\nfloat positionRadius,\nvec3 positionGeocentricNormal,\nvec3 rayDirection,\nout bool intersectsAtmosphere,\nout vec3 cameraPositionClampedToTopOfAtmosphere) {intersectsAtmosphere=true;cameraPositionClampedToTopOfAtmosphere=cameraPosition;if (positionRadius>atmosphereRadius) {float tTop=sphereIntersectNearest(cameraPosition,rayDirection,atmosphereRadius);if (tTop>=0.0) {vec3 upOffset=-planetRadiusOffset*positionGeocentricNormal;cameraPositionClampedToTopOfAtmosphere=cameraPosition+rayDirection*tTop+upOffset;} else {intersectsAtmosphere=false;}}}\nvoid getSkyViewUVFromParameters(\nbool intersectsGround,\nfloat cosHorizonAngleFromZenith,\nfloat cosAngleBetweenViewAndZenith,\nfloat cosAngleBetweenViewAndLightOnPlane,\nout vec2 uv)\n{vec2 unit=vec2(0.0);if (intersectsGround) {float coord=(cosAngleBetweenViewAndZenith+1.0)/(cosHorizonAngleFromZenith+1.0);coord=sqrtClamped(coord); \nunit.y=0.5*coord; } else {float coord=(cosAngleBetweenViewAndZenith-cosHorizonAngleFromZenith)/(1.0-cosHorizonAngleFromZenith);coord=sqrtClamped(coord); \nunit.y=0.5*coord+0.5; }\n{float coord=0.5-0.5*cosAngleBetweenViewAndLightOnPlane;unit.x=coord;}\nuv=unitToUV(unit,SkyViewLutDomainInUVSpace,SkyViewLutHalfTexelSize);}\nvec4 sampleSkyViewLut(\nsampler2D skyViewLut,\nfloat positionRadius,\nvec3 geocentricNormal,\nvec3 rayDirection,\nvec3 directionToLight,\nfloat cosHorizonAngleFromZenith,\nout float cosAngleBetweenViewAndZenith,\nout bool isRayIntersectingGround) {cosAngleBetweenViewAndZenith=dot(rayDirection,geocentricNormal);if (positionRadius>atmosphereRadius) {float sinAngleBetweenViewAndNadir=sqrtClamped(1.-cosAngleBetweenViewAndZenith*cosAngleBetweenViewAndZenith);if (sinAngleBetweenViewAndNadir>sinCameraAtmosphereHorizonAngleFromNadir) {isRayIntersectingGround=false;return vec4(0.);}}\nvec3 sideVector=normalize(cross(geocentricNormal,rayDirection));vec3 forwardVector=normalize(cross(sideVector,geocentricNormal));vec2 lightOnPlane=normalize(vec2(dot(directionToLight,forwardVector),dot(directionToLight,sideVector)));float cosAngleBetweenViewAndLightOnPlane=lightOnPlane.x;float rayIntersectionScale=mix(0.95,1.,saturate((positionRadius-planetRadius)/atmosphereThickness));isRayIntersectingGround =\npositionRadius>planetRadius &&\n(rayIntersectionScale*cosAngleBetweenViewAndZenith)<=cosHorizonAngleFromZenith;vec2 uv;getSkyViewUVFromParameters(\nisRayIntersectingGround,\ncosHorizonAngleFromZenith,\ncosAngleBetweenViewAndZenith,\ncosAngleBetweenViewAndLightOnPlane,\nuv);return textureLod(skyViewLut,uv,0.);}\nfloat computeRayleighPhase(float onePlusCosThetaSq) {return 0.0596831037*onePlusCosThetaSq;}\nfloat computeMiePhaseCornetteShanks(float cosTheta,float onePlusCosThetaSq) {const float g=0.8;const float gSquared=g*g;const float oneMinusGSquared=1.-gSquared;const float onePlusGSquared=1.+gSquared;const float twoPlusGSquared=2.+gSquared;const float twoG=2.*g;const float threeOverEightPi=3./(8.*PI);return threeOverEightPi*oneMinusGSquared*onePlusCosThetaSq/(twoPlusGSquared*pow(onePlusGSquared-twoG*cosTheta,1.5));}\nfloat computeOzoneDensity(float normalizedViewHeight) {const float MinOzoneDensity=0.135;const float OneMinusMinOzoneDensity=1.-MinOzoneDensity;const float OzoneStartHeight=.15; \nconst float PeakOzoneHeight=.25;const float MaxOzoneHeight=0.6;const float InverseRampupDistance=1./(PeakOzoneHeight-OzoneStartHeight);const float InverseRampdownDistance=1./(MaxOzoneHeight-PeakOzoneHeight);float lowerAtmosphereDensity=MinOzoneDensity+OneMinusMinOzoneDensity*max(0.,normalizedViewHeight-OzoneStartHeight)*InverseRampupDistance;float sqrtUpperAtmosphereDensity=max(0.,1.-(normalizedViewHeight-PeakOzoneHeight)*InverseRampdownDistance);float upperAtmosphereDensity=sqrtUpperAtmosphereDensity*sqrtUpperAtmosphereDensity;float densityOzone=normalizedViewHeight<PeakOzoneHeight ? lowerAtmosphereDensity : upperAtmosphereDensity;return densityOzone;}\nvoid sampleMediumRGB(\nfloat viewHeight,\nout vec3 scatteringRayleigh,\nout vec3 scatteringMie,\nout vec3 extinction,\nout vec3 scattering) {float normalizedViewHeight=saturate(viewHeight*inverseAtmosphereThickness);float densityMie=exp(-83.333*normalizedViewHeight);float densityRayleigh=exp(-12.5*normalizedViewHeight);float densityOzone=computeOzoneDensity(normalizedViewHeight);scatteringRayleigh=densityRayleigh*peakRayleighScattering;scatteringMie=densityMie*peakMieScattering;scattering=scatteringMie+scatteringRayleigh;vec3 extinctionRayleigh=scatteringRayleigh;vec3 extinctionMie=densityMie*peakMieExtinction;vec3 extinctionOzone=densityOzone*peakOzoneAbsorption;extinction=extinctionRayleigh+extinctionMie+extinctionOzone;}\nvec3 computeTransmittance(vec3 rayOriginGlobal,vec3 rayDirection,float tMax,float sampleCount) {vec3 opticalDepth=vec3(0.);float t=0.;float sampleSegmentWeight=tMax/sampleCount;const float sampleSegmentT=0.3;for (float s=0.; s<sampleCount; s+=1.) {float newT=sampleSegmentWeight*(s+sampleSegmentT);float dt=newT-t;t=newT;vec3 scatteringRayleigh,scatteringMie,extinction,scattering;vec3 samplePositionGlobal=rayOriginGlobal+t*rayDirection;sampleMediumRGB(length(samplePositionGlobal)-planetRadius,scatteringRayleigh,scatteringMie,extinction,scattering);opticalDepth+=extinction*dt;}\nreturn exp(-opticalDepth);}\nvec2 getTransmittanceUV(float radius,float cosAngleLightToZenith,out float distanceToHorizon) {float radiusSquared=radius*radius;distanceToHorizon=sqrtClamped(radiusSquared-planetRadiusSquared);float cosAngleLightToZenithSquared=cosAngleLightToZenith*cosAngleLightToZenith;float discriminant=radiusSquared*(cosAngleLightToZenithSquared-1.)+atmosphereRadiusSquared;float distanceToAtmosphereEdge=max(0.,-radius*cosAngleLightToZenith+sqrtClamped(discriminant));float minDistanceToAtmosphereEdge=max(0.,atmosphereRadius-radius);float maxDistanceToAtmosphereEdge=distanceToHorizon+horizonDistanceToAtmosphereEdge;float cosAngleLightToZenithCoordinate=(distanceToAtmosphereEdge-minDistanceToAtmosphereEdge)/max(0.000001,maxDistanceToAtmosphereEdge-minDistanceToAtmosphereEdge);float distanceToHorizonCoordinate=distanceToHorizon/max(0.000001,horizonDistanceToAtmosphereEdge);vec2 unit=vec2(cosAngleLightToZenithCoordinate,distanceToHorizonCoordinate);return unit*TransmittanceLutDomainInUVSpace+TransmittanceLutHalfTexelSize; }\nvec4 sampleTransmittanceLut(sampler2D transmittanceLut,float positionRadius,float cosAngleLightToZenith) {float distanceToHorizon;vec2 uv=getTransmittanceUV(positionRadius,cosAngleLightToZenith,distanceToHorizon);float weight=smoothstep(TransmittanceMinOccludedU,TransmittanceMaxUnoccludedU,uv.x);return weight*textureLod(transmittanceLut,uv,0.);}\nvec3 sampleMultiScatteringLut(sampler2D multiScatteringLut,float radius,float cosAngleLightToZenith) {vec2 unit=vec2(0.5+0.5*cosAngleLightToZenith,(radius-planetRadius)/atmosphereThickness);vec2 uv=unitToUV(unit,MultiScatteringLutDomainInUVSpace,MultiScatteringLutHalfTexelSize);vec3 multiScattering=textureLod(multiScatteringLut,uv,0.).rgb;return max(minMultiScattering,multiScattering);}\nconst float uniformPhase=RECIPROCAL_PI4;void integrateScatteredRadiance(\nbool isAerialPerspectiveLut,\nfloat lightIntensity,\nsampler2D transmittanceLut,\n#ifndef COMPUTE_MULTI_SCATTERING\nsampler2D multiScatteringLut,\nfloat multiScatteringIntensity,\n#endif\nvec3 rayOriginGlobal,\nvec3 rayDirection,\nvec3 directionToLight,\nfloat tMaxMax,\nfloat sampleCount,\nfloat distanceToSurface,\nout vec3 radiance,\nout vec3 transmittance\n#if COMPUTE_MULTI_SCATTERING\n,out vec3 multiScattering\n#endif\n) {radiance=vec3(0.);transmittance=vec3(1.);\n#if COMPUTE_MULTI_SCATTERING\nmultiScattering=vec3(0.);\n#endif\nfloat tBottom=sphereIntersectNearest(rayOriginGlobal,rayDirection,planetRadius);float tTop=sphereIntersectNearest(rayOriginGlobal,rayDirection,atmosphereRadius);float tMax=0.;if (tBottom<0.) {if (tTop<0.) {return;} else {tMax=tTop;}} else {if (tTop>0.) {if (isAerialPerspectiveLut) {tMax=tTop;} else {tMax=min(tBottom,tTop);}}}\nif (distanceToSurface>0. && distanceToSurface<tMax) {tMax=distanceToSurface;}\ntMax=min(tMax,tMaxMax);\n#ifndef COMPUTE_MULTI_SCATTERING\nfloat cosTheta=dot(rayDirection,directionToLight);float onePlusCosThetaSq=1.+cosTheta*cosTheta;float rayleighPhase=computeRayleighPhase(onePlusCosThetaSq);float miePhase=computeMiePhaseCornetteShanks(cosTheta,onePlusCosThetaSq);\n#endif\nfloat transmittanceScale=isAerialPerspectiveLut ? aerialPerspectiveTransmittanceScale : 1.;float t=0.;float sampleSegmentWeight=tMax/sampleCount;const float sampleSegmentT=0.3;for (float s=0.; s<sampleCount; s+=1.) {float newT=sampleSegmentWeight*(s+sampleSegmentT);float dt=newT-t;t=newT;vec3 samplePositionGlobal=rayOriginGlobal+t*rayDirection;float sampleRadiusGlobal=length(samplePositionGlobal);vec3 sampleGeocentricNormal=samplePositionGlobal/sampleRadiusGlobal;float sampleCosAngleLightToZenith=dot(directionToLight,sampleGeocentricNormal);vec3 scatteringRayleigh,scatteringMie,extinction,scattering;sampleMediumRGB(sampleRadiusGlobal-planetRadius,scatteringRayleigh,scatteringMie,extinction,scattering);vec3 transmittanceToLight=sampleTransmittanceLut(transmittanceLut,sampleRadiusGlobal,sampleCosAngleLightToZenith).rgb;\n#if COMPUTE_MULTI_SCATTERING\nvec3 phaseTimesScattering=uniformPhase*scattering;vec3 S=transmittanceToLight*phaseTimesScattering;\n#else\nvec3 phaseTimesScattering=scatteringMie*miePhase+scatteringRayleigh*rayleighPhase;vec3 multiScatteredRadiance=sampleMultiScatteringLut(multiScatteringLut,sampleRadiusGlobal,sampleCosAngleLightToZenith);vec3 S=transmittanceScale*transmittanceToLight*phaseTimesScattering+multiScatteringIntensity*multiScatteredRadiance*scattering;\n#endif\nvec3 sampleOpticalDepth=extinction*dt;vec3 sampleTransmittance=exp(-sampleOpticalDepth);vec3 clampedExtinction=max(vec3(0.0000001),extinction);vec3 SInt=(S-S*sampleTransmittance)/clampedExtinction;radiance+=transmittance*SInt;\n#if COMPUTE_MULTI_SCATTERING\nvec3 MSInt=(scattering-scattering*sampleTransmittance)/clampedExtinction;multiScattering+=transmittance*MSInt;\n#endif\ntransmittance*=sampleTransmittance;}\n#if USE_GROUND_ALBEDO\nif (tMax==tBottom && tBottom>0.) {vec3 planetPos=rayOriginGlobal+tBottom*rayDirection;float planetPosRadius=length(planetPos);vec3 planetPosGeocentricNormal=planetPos/planetPosRadius;float nDotL=dot(directionToLight,planetPosGeocentricNormal);vec3 lightTransmittance=sampleTransmittanceLut(transmittanceLut,planetPosRadius,nDotL).rgb;const float diffuseBrdf=RECIPROCAL_PI;radiance+=lightTransmittance*transmittance*groundAlbedo*(nDotL*diffuseBrdf);}\n#endif\nradiance*=lightIntensity;}\nfloat layerIdxToAerialPerspectiveLayer(float layerIdx) {float layer=(layerIdx+1.)/NumAerialPerspectiveLutLayers;layer*=layer; \nlayer*=NumAerialPerspectiveLutLayers;return layer;}\nfloat toAerialPerspectiveDepth(float layer) {return layer*AerialPerspectiveLutKMPerSlice;}\nfloat toAerialPerspectiveLayer(float distance,float aerialPerspectiveLutDistancePerSlice) {return distance/aerialPerspectiveLutDistancePerSlice;}\nvec4 applyAerialPerspectiveSaturation(vec4 aerialPerspective) {float previousRadiance=getLuminance(aerialPerspective.rgb);aerialPerspective.rgb=mix(vec3(previousRadiance),aerialPerspective.rgb,aerialPerspectiveSaturation);return aerialPerspective;}\nvec4 applyAerialPerspectiveIntensity(vec4 aerialPerspective) {\n#if APPLY_AERIAL_PERSPECTIVE_INTENSITY\nif (aerialPerspectiveIntensity==0.) {aerialPerspective=vec4(0.);} else {float previousAlpha=aerialPerspective.a;aerialPerspective/=max(0.00001,previousAlpha);aerialPerspective*=pow(previousAlpha,1./aerialPerspectiveIntensity);}\n#endif\nreturn aerialPerspective;}\nvec4 applyAerialPerspectiveRadianceBias(vec4 aerialPerspective) {\n#if APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS\nfloat originalRadiance=dot(aerialPerspective.rgb,LuminanceEncodeApprox);float targetRadiance=originalRadiance+aerialPerspectiveRadianceBias;if (originalRadiance>0.) {aerialPerspective*=max(0.,targetRadiance/originalRadiance);} else {aerialPerspective=max(vec4(0.),vec4(vec3(aerialPerspectiveRadianceBias),aerialPerspectiveRadianceBias));}\naerialPerspective.a=min(aerialPerspective.a,1.);\n#endif\nreturn aerialPerspective;}\nbool sampleAerialPerspectiveLut(\nvec2 screenUV,\nbool clampToLutRange,\nfloat distanceFromCamera,\nfloat numAerialPerspectiveLutLayers,\nfloat aerialPerspectiveLutKMPerSlice,\nfloat aerialPerspectiveLutRangeKM,\nout vec4 aerialPerspective) {aerialPerspective=vec4(0.);\n#if USE_AERIAL_PERSPECTIVE_LUT\nif (distanceFromCamera>0. &&\n(clampToLutRange || distanceFromCamera<aerialPerspectiveLutRangeKM) &&\nclampedCameraRadius<=atmosphereRadius) {float layer=toAerialPerspectiveLayer(distanceFromCamera,aerialPerspectiveLutKMPerSlice);float normalizedLayer=sqrt(layer/numAerialPerspectiveLutLayers); \nlayer=min(normalizedLayer*numAerialPerspectiveLutLayers,numAerialPerspectiveLutLayers);float weight=min(layer,1.);float layerIdx=max(0.,layer-1.);float floorLayerIdx=floor(layerIdx);vec4 aerialPerspectiveLayer0=textureLod(aerialPerspectiveLut,vec3(screenUV,floorLayerIdx),0.);vec4 aerialPerspectiveLayer1=textureLod(aerialPerspectiveLut,vec3(screenUV,floorLayerIdx+1.),0.);aerialPerspective=mix(aerialPerspectiveLayer0,aerialPerspectiveLayer1,layerIdx-floorLayerIdx);aerialPerspective.rgb*=atmosphereExposure;aerialPerspective=applyAerialPerspectiveSaturation(aerialPerspective);aerialPerspective=weight*applyAerialPerspectiveIntensity(aerialPerspective);aerialPerspective=applyAerialPerspectiveRadianceBias(aerialPerspective);return true;}\n#endif\nreturn false;}\n#if RENDER_TRANSMITTANCE\nvoid getTransmittanceParameters(vec2 uv,out float radius,out float cosAngleLightToZenith,out float distanceToAtmosphereEdge) {vec2 unit=uvToUnit(uv,TransmittanceLutDomainInUVSpace,TransmittanceLutHalfTexelSize);float distanceToHorizon=unit.y*horizonDistanceToAtmosphereEdge;float distanceToHorizonSquared=distanceToHorizon*distanceToHorizon;radius=sqrtClamped(distanceToHorizonSquared+planetRadiusSquared);float minDistanceToAtmosphereEdge=atmosphereRadius-radius;float maxDistanceToAtmosphereEdge=distanceToHorizon+horizonDistanceToAtmosphereEdge;distanceToAtmosphereEdge=minDistanceToAtmosphereEdge+unit.x*(maxDistanceToAtmosphereEdge-minDistanceToAtmosphereEdge);float distanceToAtmosphereEdgeSquared=distanceToAtmosphereEdge*distanceToAtmosphereEdge;cosAngleLightToZenith =\ndistanceToAtmosphereEdge<=0. ?\n1. :\n(horizonDistanceToAtmosphereEdgeSquared-distanceToAtmosphereEdgeSquared-distanceToHorizonSquared)/(2.*radius*distanceToAtmosphereEdge);cosAngleLightToZenith=clamp(cosAngleLightToZenith,-1.,1.);}\nvec4 renderTransmittance(vec2 uv) {float radius,cosAngleLightToZenith,distanceToAtmosphereEdgeAlongAngle;getTransmittanceParameters(uv,radius,cosAngleLightToZenith,distanceToAtmosphereEdgeAlongAngle);float sinAngleLightToZenith=sqrtClamped(1.-cosAngleLightToZenith*cosAngleLightToZenith);vec3 directionToLight=normalize(vec3(0.,cosAngleLightToZenith,sinAngleLightToZenith));vec3 transmittance=computeTransmittance(vec3(0.,radius,0.),directionToLight,distanceToAtmosphereEdgeAlongAngle,TransmittanceSampleCount);return vec4(transmittance,avg(transmittance));}\n#endif\n#if RENDER_MULTI_SCATTERING\nvec3 getSphereSample(float azimuth,float inclination,out float sinInclination) {sinInclination=sin(inclination);return vec3(sinInclination*sin(azimuth),cos(inclination),sinInclination*cos(azimuth));}\nconst float MultiScatteringInclinationSampleCount=8.;const float MultiScatteringAzimuthSampleCount=2.*MultiScatteringInclinationSampleCount;const float MultiScatteringLutSampleCount=64.;const float MultiScatteringAzimuthIterationAngle=TWO_PI/MultiScatteringAzimuthSampleCount;const float MultiScatteringInclinationIterationAngle=PI/MultiScatteringInclinationSampleCount;const float MultiScatteringAngleStepProduct=MultiScatteringAzimuthIterationAngle*MultiScatteringInclinationIterationAngle;vec4 renderMultiScattering(vec2 uv,sampler2D transmittanceLut) {vec2 unit=uvToUnit(uv,MultiScatteringLutDomainInUVSpace,MultiScatteringLutHalfTexelSize);float cosAngleLightToZenith=2.*unit.x-1.;float sinAngleLightToZenith=sqrtClamped(1.-cosAngleLightToZenith*cosAngleLightToZenith);vec3 directionToLight=normalize(vec3(0.,cosAngleLightToZenith,sinAngleLightToZenith));float rayOriginRadius=planetRadius+max(unit.y,0.001)*atmosphereThickness;vec3 rayOrigin=vec3(0.,rayOriginRadius,0.);vec3 inscattered=vec3(0.);vec3 multiScatteringTotal=vec3(0.);for (float i=0.5; i<MultiScatteringAzimuthSampleCount; ++i) {float azimuth=MultiScatteringAzimuthIterationAngle*i;for (float j=0.5; j<MultiScatteringInclinationSampleCount; ++j) {float inclination=MultiScatteringInclinationIterationAngle*j;float sinInclination;vec3 rayDirection=getSphereSample(azimuth,inclination,sinInclination);vec3 radiance;vec3 transmittance;vec3 multiScattering;integrateScatteredRadiance(\nfalse,\n1.,\ntransmittanceLut,\nrayOrigin,\nrayDirection,\ndirectionToLight,\n100000000.,\nMultiScatteringLutSampleCount,\n-1.,\nradiance,\ntransmittance,\nmultiScattering);float weight=RECIPROCAL_PI4*abs(sinInclination)*MultiScatteringAngleStepProduct;multiScatteringTotal+=multiScattering*weight;inscattered+=radiance*weight;}}\nvec3 multiScattering=inscattered/max(vec3(0.000001),vec3(1.)-multiScatteringTotal);return vec4(multiScattering,1.);}\n#endif\n#if RENDER_SKY_VIEW\nfloat computeCosHorizonAngleFromZenith(float radius) {float sinAngleBetweenHorizonAndNadir=min(1.,planetRadius/radius);float cosHorizonAngleFromNadir=sqrt(1.-sinAngleBetweenHorizonAndNadir*sinAngleBetweenHorizonAndNadir);float cosHorizonAngleFromZenith=-cosHorizonAngleFromNadir;return cosHorizonAngleFromZenith;}\nvoid getSkyViewParametersFromUV(\nfloat radius,\nvec2 uv,\nout float cosAngleBetweenViewAndZenith,\nout float cosAngleBetweenViewAndLightOnPlane) {vec2 unit=uvToUnit(uv,SkyViewLutDomainInUVSpace,SkyViewLutHalfTexelSize);float cosHorizonAngleFromZenith=computeCosHorizonAngleFromZenith(radius);if (unit.y<0.5) {float coord=2.*unit.y; \ncoord*=coord; \ncosAngleBetweenViewAndZenith=mix(-1.,cosHorizonAngleFromZenith,coord); } else {float coord=2.*unit.y-1.; \ncoord*=coord; \ncosAngleBetweenViewAndZenith=mix(cosHorizonAngleFromZenith,1.,coord); }\n{float coord=unit.x;cosAngleBetweenViewAndLightOnPlane=1.-2.*coord;}}\nvec4 renderSkyView(vec2 uv,sampler2D transmittanceLut,sampler2D multiScatteringLut) {float cosAngleBetweenViewAndZenith;float cosAngleBetweenViewAndLightOnPlane;getSkyViewParametersFromUV(clampedCameraRadius,uv,cosAngleBetweenViewAndZenith,cosAngleBetweenViewAndLightOnPlane);float sinAngleBetweenViewAndZenith=sqrtClamped(1.-cosAngleBetweenViewAndZenith*cosAngleBetweenViewAndZenith);float sinAngleBetweenViewAndLightOnPlane=sqrtClamped(1.-cosAngleBetweenViewAndLightOnPlane*cosAngleBetweenViewAndLightOnPlane);vec3 rayDirection =\nvec3(\nsinAngleBetweenViewAndZenith*cosAngleBetweenViewAndLightOnPlane,\ncosAngleBetweenViewAndZenith,\nsinAngleBetweenViewAndZenith*sinAngleBetweenViewAndLightOnPlane);bool intersectsAtmosphere=false;vec3 cameraPositionGlobalClampedToTopOfAtmosphere=vec3(0.);moveToTopAtmosphere(\nvec3(0.,clampedCameraRadius,0.),\nclampedCameraRadius,\nvec3(0.,1.,0.),\nrayDirection,\nintersectsAtmosphere,\ncameraPositionGlobalClampedToTopOfAtmosphere);if (!intersectsAtmosphere) {return vec4(0.);}\nvec3 transmittance;vec3 radiance;integrateScatteredRadiance(\nfalse,\natmosphereExposure*lightIntensity,\ntransmittanceLut,\nmultiScatteringLut,\nmultiScatteringIntensity,\ncameraPositionGlobalClampedToTopOfAtmosphere,\nrayDirection,\ndirectionToLightRelativeToCameraGeocentricNormal,\n100000000.,\nSkyViewLutSampleCount,\n-1.,\nradiance,\ntransmittance);float transparency=1.-avg(transmittance);return vec4(radiance,transparency);}\n#endif\n#if RENDER_CAMERA_VOLUME\nvec4 renderCameraVolume(\nvec3 positionOnNearPlane,\nfloat layerIdx,\nsampler2D transmittanceLut,\nsampler2D multiScatteringLut) {vec4 result=vec4(0.);vec3 rayDirection=normalize(positionOnNearPlane);float layer=layerIdxToAerialPerspectiveLayer(layerIdx);float tMax=toAerialPerspectiveDepth(layer);float tMaxMax=tMax;vec3 cameraPositionGlobalClampedToTopOfAtmosphere=clampedCameraPositionGlobal;if (clampedCameraRadius>=atmosphereRadius) {bool intersectsAtmosphere=false;moveToTopAtmosphere(\nclampedCameraPositionGlobal,\nclampedCameraRadius,\ncameraGeocentricNormal,\nrayDirection,\nintersectsAtmosphere,\ncameraPositionGlobalClampedToTopOfAtmosphere);if (!intersectsAtmosphere) {return result;}\nfloat distanceToAtmosphere=distance(clampedCameraPositionGlobal,cameraPositionGlobalClampedToTopOfAtmosphere);if (tMaxMax<distanceToAtmosphere) {return result;}\ntMaxMax=max(0.,tMaxMax-distanceToAtmosphere);}\nfloat sampleCount=min(SkyViewLutSampleCount,2.*layer+2.);vec3 transmittance;vec3 radiance;integrateScatteredRadiance(\ntrue,\nlightIntensity,\ntransmittanceLut,\nmultiScatteringLut,\nmultiScatteringIntensity,\ncameraPositionGlobalClampedToTopOfAtmosphere,\nrayDirection,\ndirectionToLight,\ntMaxMax,\nsampleCount,\n-1.,\nradiance,\ntransmittance);float transparency=1.-avg(transmittance);result=vec4(radiance,transparency);return result;}\n#endif\n");var O="diffuseSkyIrradiancePixelShader";p.ShaderStore.ShadersStore[O]||(p.ShaderStore.ShadersStore[O]="precision highp float;const float DiffuseSkyIrradianceLutSampleCount=32.0;\n#include<__decl__atmosphereFragment>\n#include<helperFunctions>\n#include<depthFunctions>\n#include<atmosphereFunctions>\nuniform sampler2D transmittanceLut;uniform sampler2D multiScatteringLut;vec3 integrateForIrradiance(vec3 directionToLight,vec3 rayDirection,vec3 rayOrigin) {vec3 radiance;vec3 transmittance;integrateScatteredRadiance(\nfalse,\n1.,\ntransmittanceLut,\nmultiScatteringLut,\nmultiScatteringIntensity,\nrayOrigin,\nrayDirection.xzy,\ndirectionToLight.xzy,\n100000000.,\nDiffuseSkyIrradianceLutSampleCount,\n-1.,\nradiance,\ntransmittance);return radiance;}\n#include<importanceSampling>\n#include<pbrBRDFFunctions>\n#include<hdrFilteringFunctions>\nvarying vec2 uv;void main() {vec2 unit=uvToUnit(uv,DiffuseSkyIrradianceLutDomainInUVSpace,DiffuseSkyIrradianceLutHalfTexelSize);float cosLightInclination=2.*unit.x-1.;float sinLightInclination=sqrtClamped(1.-cosLightInclination*cosLightInclination);vec3 directionToLight=normalize(vec3(0.,cosLightInclination,sinLightInclination));float radius=max(planetRadiusWithOffset,unit.y*atmosphereThickness+planetRadius);vec3 swappedDirectionToLight=vec3(directionToLight.x,directionToLight.z,directionToLight.y); \nvec3 irradiance =\nPI *\nirradiance(\nswappedDirectionToLight,\nvec2(radius,0.),\n1.,\nvec3(1.),\nvec3(1.));float averageIrradiance=getLuminance(irradiance);vec3 newIrradiance=mix(irradiance,vec3(averageIrradiance),diffuseSkyIrradianceDesaturationFactor);float newIrradianceScale=getLuminance(newIrradiance);float rescaling=averageIrradiance/max(0.000001,newIrradianceScale);irradiance=newIrradiance*rescaling;gl_FragColor=vec4(irradiance,1.);}");var D="fullscreenTriangleVertexShader";p.ShaderStore.ShadersStore[D]||(p.ShaderStore.ShadersStore[D]="precision highp float;\n#include<__decl__atmosphereFragment>\n#if POSITION_VEC2\nattribute vec2 position;\n#else\nattribute vec3 position;\n#endif\nuniform float depth;varying vec2 uv;\n#if COMPUTE_WORLD_RAY\nvarying vec3 positionOnNearPlane;\n#endif\n#if COMPUTE_WORLD_RAY\nconst float nearPlaneNDC=-1.;\n#endif\nvoid main() {gl_Position=vec4(position.xy,depth,1.);uv=0.5*position.xy+vec2(0.5);\n#if COMPUTE_WORLD_RAY\npositionOnNearPlane=(inverseViewProjectionWithoutTranslation*vec4(position.xy,nearPlaneNDC,1.)).xyz;\n#endif\n}");var k={x:Number.NaN,y:Number.NaN},V={r:Number.NaN,g:Number.NaN,b:Number.NaN,a:Number.NaN},N=function(){function e(e){this._renderTarget=null,this._effectWrapper=null,this._effectRenderer=null,this._isDirty=!0,this._isDisposed=!1,this._lutData=new Uint16Array(0),this._atmosphere=e;var t=e.scene,i=t.getEngine(),r="atmo-diffuseSkyIrradiance",n=this._renderTarget=new p.RenderTargetTexture(r,{width:64,height:16},t,{generateMipMaps:!1,type:p.Constants.TEXTURETYPE_HALF_FLOAT,samplingMode:p.Constants.TEXTURE_BILINEAR_SAMPLINGMODE,generateDepthBuffer:!1,gammaSpace:!1});n.wrapU=p.Constants.TEXTURE_CLAMP_ADDRESSMODE,n.wrapV=p.Constants.TEXTURE_CLAMP_ADDRESSMODE,n.anisotropicFilteringLevel=1,n.skipInitialClear=!0;var a=e.uniformBuffer.useUbo;this._effectWrapper=new p.EffectWrapper({engine:i,name:r,vertexShader:"fullscreenTriangle",fragmentShader:"diffuseSkyIrradiance",attributeNames:["position"],uniformNames:c(["depth"],a?[]:e.uniformBuffer.getUniformNames(),!0),uniformBuffers:a?[e.uniformBuffer.name]:[],defines:["#define POSITION_VEC2","#define NUM_SAMPLES ".concat(128,"u"),"#define CUSTOM_IRRADIANCE_FILTERING_INPUT /* empty */","#define CUSTOM_IRRADIANCE_FILTERING_FUNCTION vec3 c = integrateForIrradiance(n, Ls, vec3(0., filteringInfo.x, 0.));"],samplers:["transmittanceLut","multiScatteringLut"],useShaderStore:!0}),this._effectRenderer=new p.EffectRenderer(i,{indices:[0,2,1],positions:[-1,-1,-1,3,3,-1]}),t.environmentTexture=n,t.environmentTexture.irradianceTexture=n,t.environmentIntensity=1,t.environmentTexture.isRenderTarget=!1}return Object.defineProperty(e.prototype,"isDirty",{get:function(){return this._isDirty},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"renderTarget",{get:function(){if(this._isDisposed||null===this._renderTarget)throw new Error;return this._renderTarget},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasLutData",{get:function(){return void 0!==this._lutData[0]},enumerable:!1,configurable:!0}),e.prototype.getDiffuseSkyIrradianceToRef=function(e,t,i,r,n){var a=this._atmosphere,o=a.additionalDiffuseSkyIrradiance,s=a.physicalProperties;if(void 0===this._lutData[0]||t>s.atmosphereRadius)return n.r=o.r,n.g=o.g,n.b=o.b,n;!function(e,t,i,r){var n=(0,p.Clamp)(.5+.5*i),a=(0,p.Clamp)((t-e.planetRadius)/e.atmosphereThickness);r.x=.984375*n+.0078125,r.y=.9375*a+.03125}(s,t,e.x*i.x+e.y*i.y+e.z*i.z,k),E(k.x,k.y,64,16,this._lutData,V,p.FromHalfFloat);var l=a.diffuseSkyIrradianceIntensity;return n.r=l*(r*V.r+o.r),n.g=l*(r*V.g+o.g),n.b=l*(r*V.b+o.b),n},e.prototype.render=function(){var e,t,i=this,r=this._effectWrapper;if(!this._isDirty||!(null==r?void 0:r.isReady())||!(null===(e=this._renderTarget)||void 0===e?void 0:e.isReady()))return!1;var n=this._atmosphere.scene.getEngine();n.bindFramebuffer(this.renderTarget.renderTarget,void 0,void 0,void 0,!0);var a=this._effectRenderer;a.applyEffectWrapper(r),a.saveStates(),a.setViewport();var o=r.effect;return a.bindBuffers(o),o.setTexture("transmittanceLut",this._atmosphere.transmittanceLut.renderTarget),o.setTexture("multiScatteringLut",this._atmosphere.multiScatteringLutRenderTarget),this._atmosphere.bindUniformBufferToEffect(o),o.setFloat("depth",0),a.draw(),a.restoreStates(),n.restoreDefaultFramebuffer(),this._isDirty=!1,null===(t=this.renderTarget.readPixels(0,0,void 0,void 0,!0))||void 0===t||t.then((function(e){i._isDisposed||(i._lutData=e)})),!0},e.prototype.markDirty=function(){this._isDirty=!0},e.prototype.dispose=function(){var e,t;this._renderTarget&&(this._renderTarget.irradianceTexture=null,this._renderTarget.dispose()),this._renderTarget=null,null===(e=this._effectWrapper)||void 0===e||e.dispose(),this._effectWrapper=null,null===(t=this._effectRenderer)||void 0===t||t.dispose(),this._effectRenderer=null,this._isDisposed=!0},e}(),F="transmittancePixelShader";p.ShaderStore.ShadersStore[F]||(p.ShaderStore.ShadersStore[F]="#define RENDER_TRANSMITTANCE 1\nprecision highp float;\n#include<__decl__atmosphereFragment>\n#include<helperFunctions>\n#include<atmosphereFunctions>\nvarying vec2 uv;void main() {gl_FragColor=renderTransmittance(uv);}");var U=.001953125,B=.00390625,z={x:Number.NaN,y:Number.NaN},G={r:Number.NaN,g:Number.NaN,b:Number.NaN},W={x:Number.NaN,y:Number.NaN,z:Number.NaN},H={r:Number.NaN,g:Number.NaN,b:Number.NaN,a:Number.NaN},j=function(){function e(e){this.onUpdatedObservable=new p.Observable,this._lutData=new Uint8Array(0),this._isDirty=!0,this._isDisposed=!1,this._atmosphere=e;var t=this._atmosphere.scene,i=t.getEngine(),r="atmo-transmittance",n=this._renderTarget=new p.RenderTargetTexture(r,{width:256,height:64},t,{type:p.Constants.TEXTURETYPE_UNSIGNED_BYTE,samplingMode:p.Constants.TEXTURE_BILINEAR_SAMPLINGMODE,generateDepthBuffer:!1,gammaSpace:!1});n.wrapU=p.Constants.TEXTURE_CLAMP_ADDRESSMODE,n.wrapV=p.Constants.TEXTURE_CLAMP_ADDRESSMODE,n.anisotropicFilteringLevel=1,n.skipInitialClear=!0;var a=this._atmosphere.uniformBuffer.useUbo;this._effectWrapper=new p.EffectWrapper({engine:i,name:r,vertexShader:"fullscreenTriangle",fragmentShader:"transmittance",attributeNames:["position"],uniformNames:c(["depth"],a?[]:this._atmosphere.uniformBuffer.getUniformNames(),!0),uniformBuffers:a?[this._atmosphere.uniformBuffer.name]:[],defines:["#define POSITION_VEC2"],useShaderStore:!0}),this._effectRenderer=new p.EffectRenderer(i,{indices:[0,2,1],positions:[-1,-1,-1,3,3,-1]})}return Object.defineProperty(e.prototype,"isDirty",{get:function(){return this._isDirty},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"renderTarget",{get:function(){if(this._isDisposed||null===this._renderTarget)throw new Error;return this._renderTarget},enumerable:!1,configurable:!0}),e.prototype.getTransmittedColorToRef=function(e,t,i,r){if(void 0!==this._lutData[0]){var n=e.x*i.x+e.y*i.y+e.z*i.z;(function(e,t,i,r,n){if(i>e.atmosphereRadius)n.r=n.g=n.b=n.a=1;else{!function(e,t,i,r){var n=t*t,a=Math.sqrt(Math.max(0,n-e.planetRadiusSquared)),o=n*(i*i-1)+e.atmosphereRadiusSquared,s=Math.max(0,-t*i+Math.sqrt(Math.max(0,o))),l=Math.max(0,e.atmosphereRadius-t),c=a+e.horizonDistanceToAtmosphereEdge,u=(s-l)/Math.max(1e-6,c-l),p=a/Math.max(1e-6,e.horizonDistanceToAtmosphereEdge);r.x=.99609375*u+U,r.y=.984375*p+.0078125}(e,i,r,z),E(z.x,z.y,256,64,t,n,(function(e){return e/255}));var a=(0,p.Clamp)((0,p.SmoothStep)(1,0,(0,p.Clamp)((z.x-.998046875)/B)));n.r*=a,n.g*=a,n.b*=a,n.a*=a}})(this._atmosphere.physicalProperties,this._lutData,t,n,H),r.r=H.r,r.g=H.g,r.b=H.b}else r.r=r.g=r.b=1;return r},e.prototype.updateLightParameters=function(e,t,i){var r=e.direction;W.x=-r.x,W.y=-r.y,W.z=-r.z,this.getTransmittedColorToRef(W,t,i,G),e.diffuse.copyFromFloats(G.r,G.g,G.b),e.specular.copyFromFloats(G.r,G.g,G.b)},e.prototype.render=function(){var e,t,i=this,r=this._effectWrapper;if(!this._isDirty||!(null==r?void 0:r.isReady())||!(null===(e=this._renderTarget)||void 0===e?void 0:e.isReady()))return!1;var n=this._atmosphere.scene.getEngine();n.bindFramebuffer(this.renderTarget.renderTarget,void 0,void 0,void 0,!0);var a=this._effectRenderer;a.applyEffectWrapper(r),a.saveStates(),a.setViewport();var o=r.effect;return a.bindBuffers(o),this._atmosphere.bindUniformBufferToEffect(o),o.setFloat("depth",0),a.draw(),a.restoreStates(),n.restoreDefaultFramebuffer(),this._isDirty=!1,null===(t=this.renderTarget.readPixels(0,0,void 0,void 0,false))||void 0===t||t.then((function(e){i._isDisposed||(i._lutData=e,i.onUpdatedObservable.notifyObservers())})),!0},e.prototype.markDirty=function(){this._isDirty=!0},e.prototype.dispose=function(){var e,t,i;null===(e=this._renderTarget)||void 0===e||e.dispose(),this._renderTarget=null,null===(t=this._effectWrapper)||void 0===t||t.dispose(),this._effectWrapper=null,null===(i=this._effectRenderer)||void 0===i||i.dispose(),this._effectRenderer=null,this._isDisposed=!0},e}(),q="compositeAerialPerspectivePixelShader";p.ShaderStore.ShadersStore[q]||(p.ShaderStore.ShadersStore[q]="precision highp float;precision highp sampler2D;precision highp sampler2DArray;\n#include<__decl__atmosphereFragment>\n#if USE_AERIAL_PERSPECTIVE_LUT\nuniform sampler2DArray aerialPerspectiveLut;\n#endif\n#include<helperFunctions>\n#include<depthFunctions>\n#include<atmosphereFunctions>\nuniform sampler2D depthTexture;uniform sampler2D transmittanceLut;uniform sampler2D multiScatteringLut;varying vec2 uv;varying vec3 positionOnNearPlane;void main() {gl_FragColor=vec4(0.);float depth=textureLod(depthTexture,uv,0.).r;if (depth>=1.) {discard;}\nvec3 rayDirection=normalize(positionOnNearPlane);float distanceFromCamera =\nreconstructDistanceFromCamera(\ndepth,\nrayDirection,\ncameraForward,\ncameraNearPlane);float distanceToSurface=distanceFromCamera/1000.;vec4 aerialPerspective=vec4(0.);if (sampleAerialPerspectiveLut(\nuv,\nfalse,\ndistanceToSurface,\nNumAerialPerspectiveLutLayers,\nAerialPerspectiveLutKMPerSlice,\nAerialPerspectiveLutRangeKM,\naerialPerspective)) {\n#ifndef APPLY_TRANSMITTANCE_BLENDING\naerialPerspective.a=0.;\n#endif\ngl_FragColor=aerialPerspective;} else {bool intersectsAtmosphere=false;vec3 cameraPositionGlobalClampedToTopOfAtmosphere=vec3(0.);moveToTopAtmosphere(\nclampedCameraPositionGlobal,\nclampedCameraRadius,\ncameraGeocentricNormal,\nrayDirection,\nintersectsAtmosphere,\ncameraPositionGlobalClampedToTopOfAtmosphere);if (!intersectsAtmosphere) {gl_FragColor=vec4(0.);return;}\nvec3 transmittance;vec3 radiance;bool isAerialPerspectiveLut=clampedCameraRadius<atmosphereRadius;integrateScatteredRadiance(\nisAerialPerspectiveLut,\natmosphereExposure*lightIntensity,\ntransmittanceLut,\nmultiScatteringLut,\nmultiScatteringIntensity,\ncameraPositionGlobalClampedToTopOfAtmosphere,\nrayDirection,\ndirectionToLight,\n100000000.,\nSkyViewLutSampleCount,\ndistanceToSurface,\nradiance,\ntransmittance);float transparency=1.-avg(transmittance);gl_FragColor =\napplyAerialPerspectiveRadianceBias(\napplyAerialPerspectiveIntensity(\napplyAerialPerspectiveSaturation(vec4(radiance,transparency))));\n#ifndef APPLY_TRANSMITTANCE_BLENDING\ngl_FragColor.a=0.;\n#endif\n}\n#if OUTPUT_TO_SRGB\ngl_FragColor=toGammaSpace(gl_FragColor);\n#endif\n}");var Z="compositeSkyPixelShader";p.ShaderStore.ShadersStore[Z]||(p.ShaderStore.ShadersStore[Z]="precision highp float;precision highp sampler2D;\n#include<__decl__atmosphereFragment>\n#include<helperFunctions>\n#include<depthFunctions>\n#include<atmosphereFunctions>\nvarying vec2 uv;varying vec3 positionOnNearPlane;\n#if USE_SKY_VIEW_LUT\nuniform sampler2D skyViewLut;\n#else\nuniform sampler2D transmittanceLut;uniform sampler2D multiScatteringLut;\n#endif\nvoid main() {gl_FragColor=vec4(0.);vec3 rayDirection=normalize(positionOnNearPlane);\n#if USE_SKY_VIEW_LUT\nfloat cosAngleBetweenViewAndZenith;bool isRayIntersectingGround;vec4 skyColor =\nsampleSkyViewLut(\nskyViewLut,\nclampedCameraRadius,\ncameraGeocentricNormal,\nrayDirection,\ndirectionToLight,\ncosCameraHorizonAngleFromZenith,\ncosAngleBetweenViewAndZenith,\nisRayIntersectingGround);\n#ifndef APPLY_TRANSMITTANCE_BLENDING\nskyColor.a=0.;\n#endif\ngl_FragColor=skyColor;gl_FragColor.a=isRayIntersectingGround ? 1. : gl_FragColor.a;\n#else\nbool intersectsAtmosphere=false;vec3 cameraPositionGlobalClampedToTopOfAtmosphere=vec3(0.);moveToTopAtmosphere(\nclampedCameraPositionGlobal,\nclampedCameraRadius,\ncameraGeocentricNormal,\nrayDirection,\nintersectsAtmosphere,\ncameraPositionGlobalClampedToTopOfAtmosphere);if (!intersectsAtmosphere) {return;}\nvec3 transmittance;vec3 radiance;integrateScatteredRadiance(\nfalse,\natmosphereExposure*lightIntensity,\ntransmittanceLut,\nmultiScatteringLut,\nmultiScatteringIntensity,\ncameraPositionGlobalClampedToTopOfAtmosphere,\nrayDirection,\ndirectionToLight,\n100000000.,\nSkyViewLutSampleCount,\n-1.,\nradiance,\ntransmittance);\n#if APPLY_TRANSMITTANCE_BLENDING\nfloat transparency=1.-avg(transmittance);\n#else\nfloat transparency=0.;\n#endif\ngl_FragColor=vec4(radiance,transparency);\n#endif\n#if OUTPUT_TO_SRGB\ngl_FragColor=toGammaSpace(gl_FragColor);\n#endif\n}");var Y="compositeGlobeAtmospherePixelShader";p.ShaderStore.ShadersStore[Y]||(p.ShaderStore.ShadersStore[Y]="precision highp float;precision highp sampler2D;\n#include<__decl__atmosphereFragment>\n#include<helperFunctions>\n#include<depthFunctions>\n#include<atmosphereFunctions>\nvarying vec2 uv;varying vec3 positionOnNearPlane;\n#if HAS_DEPTH_TEXTURE\nuniform sampler2D depthTexture;\n#endif\n#if USE_SKY_VIEW_LUT\nuniform sampler2D skyViewLut;\n#else\nuniform sampler2D transmittanceLut;uniform sampler2D multiScatteringLut;\n#endif\nvoid main() {gl_FragColor=vec4(0.);\n#if HAS_DEPTH_TEXTURE\nfloat depth=textureLod(depthTexture,uv,0.).r;\n#endif\nvec3 rayDirection=normalize(positionOnNearPlane);\n#if USE_SKY_VIEW_LUT\nfloat cosAngleBetweenViewAndZenith;bool isRayIntersectingGround;vec4 skyColor =\nsampleSkyViewLut(\nskyViewLut,\nclampedCameraRadius,\ncameraGeocentricNormal,\nrayDirection,\ndirectionToLight,\ncosCameraHorizonAngleFromZenith,\ncosAngleBetweenViewAndZenith,\nisRayIntersectingGround);gl_FragColor=skyColor;if (isRayIntersectingGround) {gl_FragColor =\napplyAerialPerspectiveRadianceBias(\napplyAerialPerspectiveIntensity(\napplyAerialPerspectiveSaturation(gl_FragColor)));\n#if HAS_DEPTH_TEXTURE\ngl_FragColor.a=depth>=1. ? 1. : gl_FragColor.a;\n#endif\n}\n#else\nbool intersectsAtmosphere=false;vec3 cameraPositionGlobalClampedToTopOfAtmosphere=vec3(0.);moveToTopAtmosphere(\nclampedCameraPositionGlobal,\nclampedCameraRadius,\ncameraGeocentricNormal,\nrayDirection,\nintersectsAtmosphere,\ncameraPositionGlobalClampedToTopOfAtmosphere);if (!intersectsAtmosphere) {return;}\n#if HAS_DEPTH_TEXTURE\nfloat distanceFromCamera =\nreconstructDistanceFromCamera(\ndepth,\nrayDirection,\ncameraForward,\ncameraNearPlane);float distanceToSurface=distanceFromCamera/1000.;\n#else\nfloat distanceToSurface=0.;\n#endif\nvec3 transmittance;vec3 radiance;integrateScatteredRadiance(\nfalse,\natmosphereExposure*lightIntensity,\ntransmittanceLut,\nmultiScatteringLut,\nmultiScatteringIntensity,\ncameraPositionGlobalClampedToTopOfAtmosphere,\nrayDirection,\ndirectionToLight,\n100000000.,\nSkyViewLutSampleCount,\ndistanceToSurface,\nradiance,\ntransmittance);float transparency=1.-avg(transmittance);gl_FragColor=vec4(radiance,transparency);if (distanceToSurface>0.) {gl_FragColor =\napplyAerialPerspectiveRadianceBias(\napplyAerialPerspectiveIntensity(\napplyAerialPerspectiveSaturation(gl_FragColor)));\n#if HAS_DEPTH_TEXTURE\ngl_FragColor.a=depth>=1. ? 1. : gl_FragColor.a;\n#endif\n}\n#endif\n#if OUTPUT_TO_SRGB\ngl_FragColor=toGammaSpace(gl_FragColor);\n#endif\n}");var K="multiScatteringPixelShader";p.ShaderStore.ShadersStore[K]||(p.ShaderStore.ShadersStore[K]="#define RENDER_MULTI_SCATTERING 1\nprecision highp float;\n#define COMPUTE_MULTI_SCATTERING 1\n#include<__decl__atmosphereFragment>\n#include<helperFunctions>\n#include<atmosphereFunctions>\nvarying vec2 uv;uniform sampler2D transmittanceLut;void main() {gl_FragColor=renderMultiScattering(uv,transmittanceLut);}");var X="skyViewPixelShader";p.ShaderStore.ShadersStore[X]||(p.ShaderStore.ShadersStore[X]="#define RENDER_SKY_VIEW 1\nprecision highp float;precision highp sampler2D;\n#include<__decl__atmosphereFragment>\n#include<helperFunctions>\n#include<atmosphereFunctions>\nvarying vec2 uv;uniform sampler2D transmittanceLut;uniform sampler2D multiScatteringLut;void main() {gl_FragColor=renderSkyView(uv,transmittanceLut,multiScatteringLut);}");var J="aerialPerspectivePixelShader";p.ShaderStore.ShadersStore[J]||(p.ShaderStore.ShadersStore[J]="#define RENDER_CAMERA_VOLUME 1\nprecision highp float;\n#include<__decl__atmosphereFragment>\n#include<helperFunctions>\n#include<atmosphereFunctions>\nvarying vec3 positionOnNearPlane;uniform float layerIdx;uniform sampler2D transmittanceLut;uniform sampler2D multiScatteringLut;void main() {gl_FragColor=renderCameraVolume(\npositionOnNearPlane,\nlayerIdx,\ntransmittanceLut,\nmultiScatteringLut\n);}");var Q="atmosphereVertexDeclaration";p.ShaderStore.IncludesShadersStore[Q]||(p.ShaderStore.IncludesShadersStore[Q]="uniform mat4 inverseViewProjectionWithoutTranslation;\n");var $,ee="atmo-pbr",te=function(){function e(e,t,i,r){var n,a,o,s,l,c,u,d,m,g,v,_,y,S,P,T,A,R,L,E,C,x,w=this;this.name=e,this.scene=t,this._directionToLight=p.Vector3.Zero(),this._tempSceneAmbient=new p.Color3,this._additionalDiffuseSkyIrradiance=new p.Color3,this._atmosphereUbo=null,this._minimumMultiScattering=new p.Vector3,this._cameraAtmosphereVariables=new f,this._lightRadianceAtCamera=new p.Vector3,this._linearLightColor=new p.Color3,this._atmosphereUniformBufferAsArray=[],this._effectRenderer=null,this._isEnabled=!0,this._hasRenderedMultiScatteringLut=!1,this._multiScatteringEffectWrapper=null,this._multiScatteringLutRenderTarget=null,this._aerialPerspectiveLutEffectWrapper=null,this._aerialPerspectiveLutEffectRenderer=null,this._aerialPerspectiveLutRenderTarget=null,this._skyViewLutEffectWrapper=null,this._skyViewLutEffectRenderer=null,this._skyViewLutRenderTarget=null,this._aerialPerspectiveCompositorEffectWrapper=null,this._skyCompositorEffectWrapper=null,this._globeAtmosphereCompositorEffectWrapper=null,this._onBeforeCameraRenderObserver=null,this._onBeforeDrawPhaseObserver=null,this._onAfterRenderingGroupObserver=null,this.onAfterUpdateVariablesForCameraObservable=new p.Observable,this.onBeforeLightVariablesUpdateObservable=new p.Observable,this.onBeforeRenderLutsForCameraObservable=new p.Observable,this.onAfterRenderLutsForCameraObservable=new p.Observable,this.depthTexture=null,this._peakRayleighScatteringMmInternal=new p.Vector3,this._peakRayleighScatteringKm=new p.Vector3,this._peakMieScatteringMmInternal=new p.Vector3,this._peakMieScatteringKm=new p.Vector3,this._peakMieAbsorptionMmInternal=new p.Vector3,this._peakMieAbsorptionKm=new p.Vector3,this._peakOzoneAbsorptionMmInternal=new p.Vector3,this._peakOzoneAbsorptionKm=new p.Vector3,this.getTransmittedColorToRef=function(e,t,i,r){return w._transmittanceLut.getTransmittedColorToRef(e,t,i,r)},this.getDiffuseSkyIrradianceToRef=function(e,t,i,r,n){var a,o;return null!==(o=null===(a=w._diffuseSkyIrradianceLut)||void 0===a?void 0:a.getDiffuseSkyIrradianceToRef(e,t,i,r,n))&&void 0!==o?o:(n.r=0,n.g=0,n.b=0,n)};var M=this._engine=t.getEngine();if(M.isWebGPU)throw new Error("Atmosphere is not supported on WebGPU.");if(M.version<2)throw new Error("Atmosphere is not supported on WebGL ".concat(M.version,"."));if(this._physicalProperties=null!==(n=null==r?void 0:r.physicalProperties)&&void 0!==n?n:new b,this._physicalProperties.onChangedObservable.add((function(){var e;null===(e=w._transmittanceLut)||void 0===e||e.markDirty()})),1!==i.length)throw new Error("Atmosphere only supports one light source currently.");this._lights=i,this.depthTexture=null!==(a=null==r?void 0:r.depthTexture)&&void 0!==a?a:null,this._exposure=null!==(o=null==r?void 0:r.exposure)&&void 0!==o?o:1,this._isLinearSpaceLight=null!==(s=null==r?void 0:r.isLinearSpaceLight)&&void 0!==s&&s,this._isLinearSpaceComposition=null!==(l=null==r?void 0:r.isLinearSpaceComposition)&&void 0!==l&&l,this._applyApproximateTransmittance=null===(c=null==r?void 0:r.applyApproximateTransmittance)||void 0===c||c,this._aerialPerspectiveRadianceBias=null!==(u=null==r?void 0:r.aerialPerspectiveRadianceBias)&&void 0!==u?u:0,this._aerialPerspectiveTransmittanceScale=null!==(d=null==r?void 0:r.aerialPerspectiveTransmittanceScale)&&void 0!==d?d:1,this._aerialPerspectiveSaturation=null!==(m=null==r?void 0:r.aerialPerspectiveSaturation)&&void 0!==m?m:1,this._aerialPerspectiveIntensity=null!==(g=null==r?void 0:r.aerialPerspectiveIntensity)&&void 0!==g?g:1,this._diffuseSkyIrradianceDesaturationFactor=null!==(v=null==r?void 0:r.diffuseSkyIrradianceDesaturationFactor)&&void 0!==v?v:.5,this._diffuseSkyIrradianceIntensity=null!==(_=null==r?void 0:r.diffuseSkyIrradianceIntensity)&&void 0!==_?_:1,this._additionalDiffuseSkyIrradianceIntensity=null!==(y=null==r?void 0:r.additionalDiffuseSkyIrradianceIntensity)&&void 0!==y?y:.01,this._multiScatteringIntensity=null!==(S=null==r?void 0:r.multiScatteringIntensity)&&void 0!==S?S:1,this._minimumMultiScatteringIntensity=null!==(P=null==r?void 0:r.minimumMultiScatteringIntensity)&&void 0!==P?P:618e-6,this._isSkyViewLutEnabled=null===(T=null==r?void 0:r.isSkyViewLutEnabled)||void 0===T||T,this._isAerialPerspectiveLutEnabled=null===(A=null==r?void 0:r.isAerialPerspectiveLutEnabled)||void 0===A||A,this._originHeight=null!==(R=null==r?void 0:r.originHeight)&&void 0!==R?R:0,this._additionalDiffuseSkyIrradianceColor=(null==r?void 0:r.additionalDiffuseSkyIrradianceColor)?(new p.Color3).copyFrom(r.additionalDiffuseSkyIrradianceColor):new p.Color3(163/255,199/255,1),this._groundAlbedo=(null==r?void 0:r.groundAlbedo)?(new p.Color3).copyFrom(r.groundAlbedo):(new p.Color3).set(124/255,165/255,1);var I=this._minimumMultiScatteringColor=(null==r?void 0:r.minimumMultiScatteringColor)?(new p.Color3).copyFrom(r.minimumMultiScatteringColor):new p.Color3(30/255,40/255,77/255);this._skyRenderingGroup=null!==(L=null==r?void 0:r.skyRenderingGroup)&&void 0!==L?L:0,this._aerialPerspectiveRenderingGroup=null!==(E=null==r?void 0:r.aerialPerspectiveRenderingGroup)&&void 0!==E?E:0,this._globeAtmosphereRenderingGroup=null!==(C=null==r?void 0:r.globeAtmosphereRenderingGroup)&&void 0!==C?C:0,this._additionalDiffuseSkyIrradianceColor.scaleToRef(this._additionalDiffuseSkyIrradianceIntensity,this._additionalDiffuseSkyIrradiance),this._minimumMultiScattering.x=I.r*this._minimumMultiScatteringIntensity,this._minimumMultiScattering.y=I.g*this._minimumMultiScatteringIntensity,this._minimumMultiScattering.z=I.b*this._minimumMultiScatteringIntensity,this._effectRenderer=new p.EffectRenderer(M,{indices:[0,2,1],positions:[-1,-1,-1,3,3,-1]}),this._transmittanceLut=new j(this),this._multiScatteringLutRenderTarget=re("atmo-multiScattering",{width:32,height:32},t),(null===(x=null==r?void 0:r.isDiffuseSkyIrradianceLutEnabled)||void 0===x||x)&&(this._diffuseSkyIrradianceLut=new N(this)),this._isSkyViewLutEnabled&&this.skyViewLutRenderTarget,this._isAerialPerspectiveLutEnabled&&this.aerialPerspectiveLutRenderTarget,this._onBeforeCameraRenderObserver=t.onBeforeCameraRenderObservable.add((function(e){w._updatePerCameraVariables(e),w._renderLutsForCamera()}));var O=t.renderingManager;O.getRenderingGroup(this._skyRenderingGroup),O.getRenderingGroup(this._aerialPerspectiveRenderingGroup),O.getRenderingGroup(this._globeAtmosphereRenderingGroup),this._onBeforeDrawPhaseObserver=t.onBeforeDrawPhaseObservable.add((function(){O.getRenderingGroup(w._skyRenderingGroup)._empty=!1,O.getRenderingGroup(w._aerialPerspectiveRenderingGroup)._empty=!1,O.getRenderingGroup(w._globeAtmosphereRenderingGroup)._empty=!1})),this._onAfterRenderingGroupObserver=t.onAfterRenderingGroupObservable.add((function(e){if(e.renderingManager===t.renderingManager){var i=e.renderingGroupId;w._skyRenderingGroup===i&&w._drawSkyCompositor(),w._aerialPerspectiveRenderingGroup===i&&w._drawAerialPerspectiveCompositor(),w._globeAtmosphereRenderingGroup===i&&w._drawGlobeAtmosphereCompositor()}})),t.onDisposeObservable.addOnce((function(){w.dispose()})),(0,p.UnregisterMaterialPlugin)(ee),(0,p.RegisterMaterialPlugin)(ee,(function(e){return"PBRMaterial"===e.getClassName()?new h(e,w,null===w.depthTexture):null}))}return e.IsSupported=function(e){return!e._badOS&&!e.isWebGPU&&e.version>=2},Object.defineProperty(e.prototype,"exposure",{get:function(){return this._exposure},set:function(e){this._exposure=Math.max(0,e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"multiScatteringIntensity",{get:function(){return this._multiScatteringIntensity},set:function(e){var t;Math.max(0,e)!==this._multiScatteringIntensity&&(this._multiScatteringIntensity=e,null===(t=this._diffuseSkyIrradianceLut)||void 0===t||t.markDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"groundAlbedo",{get:function(){return this._groundAlbedo},set:function(e){var t;this._groundAlbedo.equals(e)||(this._groundAlbedo.copyFrom(e),null===(t=this._multiScatteringEffectWrapper)||void 0===t||t.dispose(),this._multiScatteringEffectWrapper=null,this._hasRenderedMultiScatteringLut=!1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minimumMultiScatteringColor",{get:function(){return this._minimumMultiScatteringColor},set:function(e){var t;if(!this._minimumMultiScatteringColor.equals(e)){var i=this._minimumMultiScatteringColor.copyFrom(e);this._minimumMultiScattering.x=i.r*this._minimumMultiScatteringIntensity,this._minimumMultiScattering.y=i.g*this._minimumMultiScatteringIntensity,this._minimumMultiScattering.z=i.b*this._minimumMultiScatteringIntensity,null===(t=this._diffuseSkyIrradianceLut)||void 0===t||t.markDirty()}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minimumMultiScatteringIntensity",{get:function(){return this._minimumMultiScatteringIntensity},set:function(e){var t;Math.max(0,e)!==this._minimumMultiScatteringIntensity&&(this._minimumMultiScatteringIntensity=e,this._minimumMultiScattering.x=this._minimumMultiScatteringColor.r*e,this._minimumMultiScattering.y=this._minimumMultiScatteringColor.g*e,this._minimumMultiScattering.z=this._minimumMultiScatteringColor.b*e,null===(t=this._diffuseSkyIrradianceLut)||void 0===t||t.markDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"diffuseSkyIrradianceDesaturationFactor",{get:function(){return this._diffuseSkyIrradianceDesaturationFactor},set:function(e){var t,i=Math.max(e,0);i!==this._diffuseSkyIrradianceDesaturationFactor&&(this._diffuseSkyIrradianceDesaturationFactor=i,null===(t=this._diffuseSkyIrradianceLut)||void 0===t||t.markDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"additionalDiffuseSkyIrradianceIntensity",{get:function(){return this._additionalDiffuseSkyIrradianceIntensity},set:function(e){(e=Math.max(0,e))!==this._additionalDiffuseSkyIrradianceIntensity&&(this._additionalDiffuseSkyIrradianceIntensity=e,this._additionalDiffuseSkyIrradianceColor.scaleToRef(e,this._additionalDiffuseSkyIrradiance))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"additionalDiffuseSkyIrradianceColor",{get:function(){return this._additionalDiffuseSkyIrradianceColor},set:function(e){this._additionalDiffuseSkyIrradianceColor.equals(e)||this._additionalDiffuseSkyIrradianceColor.copyFrom(e).scaleToRef(this._additionalDiffuseSkyIrradianceIntensity,this._additionalDiffuseSkyIrradiance)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"additionalDiffuseSkyIrradiance",{get:function(){return this._additionalDiffuseSkyIrradiance},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"diffuseSkyIrradianceIntensity",{get:function(){return this._diffuseSkyIrradianceIntensity},set:function(e){this._diffuseSkyIrradianceIntensity=Math.max(e,0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isSkyViewLutEnabled",{get:function(){return this._isSkyViewLutEnabled},set:function(e){this._isSkyViewLutEnabled=e,this._disposeSkyCompositor(),this._disposeGlobeAtmosphereCompositor()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"skyViewLutRenderTarget",{get:function(){if(!this._isSkyViewLutEnabled)return null;if(null!==this._skyViewLutRenderTarget)return this._skyViewLutRenderTarget;var e=this._skyViewLutRenderTarget=re("atmo-skyView",{width:128,height:128},this.scene);return e.coordinatesMode=p.Constants.TEXTURE_EQUIRECTANGULAR_MODE,this._skyViewLutEffectWrapper=ce(this._engine,this.uniformBuffer),e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isAerialPerspectiveLutEnabled",{get:function(){return this._isAerialPerspectiveLutEnabled},set:function(e){this._isAerialPerspectiveLutEnabled=e,this._disposeAerialPerspectiveCompositor()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"aerialPerspectiveLutRenderTarget",{get:function(){if(!this._isAerialPerspectiveLutEnabled)return null;if(null!==this._aerialPerspectiveLutRenderTarget)return this._aerialPerspectiveLutRenderTarget;var e=this.scene,t=this._aerialPerspectiveLutRenderTarget=re("atmo-aerialPerspective",{width:16,height:64,layers:32},e,{});return this._aerialPerspectiveLutEffectWrapper=oe(this._engine,this.uniformBuffer),t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"aerialPerspectiveIntensity",{get:function(){return this._aerialPerspectiveIntensity},set:function(e){if((e=Math.max(.001,e))!==this._aerialPerspectiveIntensity){var t=1===e!=(1===this._aerialPerspectiveIntensity);this._aerialPerspectiveIntensity=e,t&&(this._disposeAerialPerspectiveCompositor(),this._disposeGlobeAtmosphereCompositor())}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"aerialPerspectiveTransmittanceScale",{get:function(){return this._aerialPerspectiveTransmittanceScale},set:function(e){(e=Math.max(0,e))!==this._aerialPerspectiveTransmittanceScale&&(this._aerialPerspectiveTransmittanceScale=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"aerialPerspectiveSaturation",{get:function(){return this._aerialPerspectiveSaturation},set:function(e){(e=Math.max(0,e))!==this._aerialPerspectiveSaturation&&(this._aerialPerspectiveSaturation=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"aerialPerspectiveRadianceBias",{get:function(){return this._aerialPerspectiveRadianceBias},set:function(e){if(e!==this._aerialPerspectiveRadianceBias){var t=0===e!=(0===this._aerialPerspectiveRadianceBias);this._aerialPerspectiveRadianceBias=e,t&&(this._disposeAerialPerspectiveCompositor(),this._disposeGlobeAtmosphereCompositor())}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLinearSpaceComposition",{get:function(){return this._isLinearSpaceComposition},set:function(e){e!==this._isLinearSpaceComposition&&(this._isLinearSpaceComposition=e,this._disposeSkyCompositor(),this._disposeAerialPerspectiveCompositor(),this._disposeGlobeAtmosphereCompositor())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLinearSpaceLight",{get:function(){return this._isLinearSpaceLight},set:function(e){this._isLinearSpaceLight=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmittanceLut",{get:function(){return this._transmittanceLut},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"multiScatteringLutRenderTarget",{get:function(){return this._multiScatteringLutRenderTarget},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"diffuseSkyIrradianceLut",{get:function(){return this._diffuseSkyIrradianceLut},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"physicalProperties",{get:function(){return this._physicalProperties},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"originHeight",{get:function(){return this._originHeight},set:function(e){this._originHeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"applyApproximateTransmittance",{get:function(){return this._applyApproximateTransmittance},set:function(e){this._applyApproximateTransmittance!==e&&(this._applyApproximateTransmittance=e,this._disposeSkyCompositor(),this._disposeAerialPerspectiveCompositor(),this._disposeGlobeAtmosphereCompositor())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lights",{get:function(){return this._lights},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"skyRenderingGroup",{get:function(){return this._skyRenderingGroup},set:function(e){this._skyRenderingGroup=e,this.scene.renderingManager.getRenderingGroup(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"aerialPerspectiveRenderingGroup",{get:function(){return this._aerialPerspectiveRenderingGroup},set:function(e){this._aerialPerspectiveRenderingGroup=e,this.scene.renderingManager.getRenderingGroup(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"globeAtmosphereRenderingGroup",{get:function(){return this._globeAtmosphereRenderingGroup},set:function(e){this._globeAtmosphereRenderingGroup=e,this.scene.renderingManager.getRenderingGroup(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"uniformBuffer",{get:function(){if(null===this._atmosphereUbo){var e=this._atmosphereUbo=new p.UniformBuffer(this._engine,void 0,!0,"Atmosphere");e.addUniform("peakRayleighScattering",3),e.addUniform("planetRadius",1),e.addUniform("peakMieScattering",3),e.addUniform("atmosphereThickness",1),e.addUniform("peakMieAbsorption",3),e.addUniform("planetRadiusSquared",1),e.addUniform("peakMieExtinction",3),e.addUniform("atmosphereRadius",1),e.addUniform("peakOzoneAbsorption",3),e.addUniform("atmosphereRadiusSquared",1),e.addUniform("horizonDistanceToAtmosphereEdge",1),e.addUniform("horizonDistanceToAtmosphereEdgeSquared",1),e.addUniform("planetRadiusWithOffset",1),e.addUniform("planetRadiusOffset",1),e.addUniform("atmosphereExposure",1),e.addUniform("aerialPerspectiveRadianceBias",1),e.addUniform("inverseAtmosphereThickness",1),e.addUniform("aerialPerspectiveTransmittanceScale",1),e.addUniform("inverseViewProjectionWithoutTranslation",16),e.addUniform("directionToLight",3),e.addUniform("multiScatteringIntensity",1),e.addUniform("directionToLightRelativeToCameraGeocentricNormal",3),e.addUniform("cameraRadius",1),e.addUniform("lightRadianceAtCamera",3),e.addUniform("diffuseSkyIrradianceDesaturationFactor",1),e.addUniform("groundAlbedo",3),e.addUniform("aerialPerspectiveSaturation",1),e.addUniform("minMultiScattering",3),e.addUniform("diffuseSkyIrradianceIntensity",1),e.addUniform("cameraPositionGlobal",3),e.addUniform("lightIntensity",1),e.addUniform("clampedCameraPositionGlobal",3),e.addUniform("aerialPerspectiveIntensity",1),e.addUniform("cameraGeocentricNormal",3),e.addUniform("clampedCameraRadius",1),e.addUniform("cameraForward",3),e.addUniform("clampedCameraHeight",1),e.addUniform("cameraPosition",3),e.addUniform("cosCameraHorizonAngleFromZenith",1),e.addUniform("viewport",4),e.addUniform("additionalDiffuseSkyIrradiance",3),e.addUniform("cameraHeight",1),e.addUniform("cameraNearPlane",1),e.addUniform("originHeight",1),e.addUniform("sinCameraAtmosphereHorizonAngleFromNadir",1),e.create()}return this._atmosphereUbo},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cameraAtmosphereVariables",{get:function(){return this._cameraAtmosphereVariables},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_planetRadius",{get:function(){return this._physicalProperties.planetRadius},set:function(e){this._physicalProperties.planetRadius=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_planetRadiusOffset",{get:function(){return this._physicalProperties.planetRadiusOffset},set:function(e){this._physicalProperties.planetRadiusOffset=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_atmosphereThickness",{get:function(){return this._physicalProperties.atmosphereThickness},set:function(e){this._physicalProperties.atmosphereThickness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_rayleighScatteringScale",{get:function(){return this._physicalProperties.rayleighScatteringScale},set:function(e){this._physicalProperties.rayleighScatteringScale=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_peakRayleighScatteringMm",{get:function(){return this._physicalProperties.peakRayleighScattering.scaleToRef(1e3,this._peakRayleighScatteringMmInternal),this._peakRayleighScatteringMmInternal},set:function(e){this._peakRayleighScatteringMmInternal.copyFrom(e),this._peakRayleighScatteringMmInternal.scaleToRef(.001,this._peakRayleighScatteringKm),this._physicalProperties.peakRayleighScattering=this._peakRayleighScatteringKm},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_mieScatteringScale",{get:function(){return this._physicalProperties.mieScatteringScale},set:function(e){this._physicalProperties.mieScatteringScale=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_peakMieScatteringMm",{get:function(){return this._physicalProperties.peakMieScattering.scaleToRef(1e3,this._peakMieScatteringMmInternal),this._peakMieScatteringMmInternal},set:function(e){this._peakMieScatteringMmInternal.copyFrom(e),this._peakMieScatteringMmInternal.scaleToRef(.001,this._peakMieScatteringKm),this._physicalProperties.peakMieScattering=this._peakMieScatteringKm},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_mieAbsorptionScale",{get:function(){return this._physicalProperties.mieAbsorptionScale},set:function(e){this._physicalProperties.mieAbsorptionScale=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_peakMieAbsorptionMm",{get:function(){return this._physicalProperties.peakMieAbsorption.scaleToRef(1e3,this._peakMieAbsorptionMmInternal),this._peakMieAbsorptionMmInternal},set:function(e){this._peakMieAbsorptionMmInternal.copyFrom(e),this._peakMieAbsorptionMmInternal.scaleToRef(.001,this._peakMieAbsorptionKm),this._physicalProperties.peakMieAbsorption=this._peakMieAbsorptionKm},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_ozoneAbsorptionScale",{get:function(){return this._physicalProperties.ozoneAbsorptionScale},set:function(e){this._physicalProperties.ozoneAbsorptionScale=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_peakOzoneAbsorptionMm",{get:function(){return this._physicalProperties.peakOzoneAbsorption.scaleToRef(1e3,this._peakOzoneAbsorptionMmInternal),this._peakOzoneAbsorptionMmInternal},set:function(e){this._peakOzoneAbsorptionMmInternal.copyFrom(e),this._peakOzoneAbsorptionMmInternal.scaleToRef(.001,this._peakOzoneAbsorptionKm),this._physicalProperties.peakOzoneAbsorption=this._peakOzoneAbsorptionKm},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){var e,t,i,r,n,a,o,s,l,c,u,d,h,m,f,g,v,_;null===(e=this._onBeforeCameraRenderObserver)||void 0===e||e.remove(),this._onBeforeCameraRenderObserver=null,null===(t=this._onBeforeDrawPhaseObserver)||void 0===t||t.remove(),this._onBeforeDrawPhaseObserver=null,null===(i=this._onAfterRenderingGroupObserver)||void 0===i||i.remove(),this._onAfterRenderingGroupObserver=null,null===(r=this._globeAtmosphereCompositorEffectWrapper)||void 0===r||r.dispose(),this._globeAtmosphereCompositorEffectWrapper=null,null===(n=this._skyCompositorEffectWrapper)||void 0===n||n.dispose(),this._skyCompositorEffectWrapper=null,null===(a=this._aerialPerspectiveCompositorEffectWrapper)||void 0===a||a.dispose(),this._aerialPerspectiveCompositorEffectWrapper=null,null===(o=this._skyViewLutRenderTarget)||void 0===o||o.dispose(),this._skyViewLutRenderTarget=null,null===(s=this._skyViewLutEffectWrapper)||void 0===s||s.dispose(),this._skyViewLutEffectWrapper=null,null===(l=this._skyViewLutEffectRenderer)||void 0===l||l.dispose(),this._skyViewLutEffectRenderer=null,null===(c=this._aerialPerspectiveLutRenderTarget)||void 0===c||c.dispose(),this._aerialPerspectiveLutRenderTarget=null,null===(u=this._aerialPerspectiveLutEffectWrapper)||void 0===u||u.dispose(),this._aerialPerspectiveLutEffectWrapper=null,null===(d=this._aerialPerspectiveLutEffectRenderer)||void 0===d||d.dispose(),this._aerialPerspectiveLutEffectRenderer=null,null===(h=this._multiScatteringEffectWrapper)||void 0===h||h.dispose(),this._multiScatteringEffectWrapper=null,null===(m=this._multiScatteringLutRenderTarget)||void 0===m||m.dispose(),this._multiScatteringLutRenderTarget=null,null===(f=this._transmittanceLut)||void 0===f||f.dispose(),this._transmittanceLut=null,null===(g=this._diffuseSkyIrradianceLut)||void 0===g||g.dispose(),this._diffuseSkyIrradianceLut=null,null===(v=this._atmosphereUbo)||void 0===v||v.dispose(),this._atmosphereUbo=null,null===(_=this._effectRenderer)||void 0===_||_.dispose(),this._effectRenderer=null,this._atmosphereUniformBufferAsArray.length=0,(0,p.UnregisterMaterialPlugin)(ee)},e.prototype.isEnabled=function(){return this._isEnabled},e.prototype.setEnabled=function(e){this._isEnabled=e},e.prototype.getClassName=function(){return"Atmosphere"},e.prototype._createMultiScatteringEffectWrapper=function(){var e=this._engine,t=this.uniformBuffer.useUbo,i=["#define POSITION_VEC2"];return this._groundAlbedo.equals(p.Color3.BlackReadOnly)||i.push("#define USE_GROUND_ALBEDO"),new p.EffectWrapper({engine:e,name:"atmo-multiScattering",vertexShader:"fullscreenTriangle",fragmentShader:"multiScattering",attributeNames:["position"],uniformNames:c(["depth"],t?[]:this.uniformBuffer.getUniformNames(),!0),uniformBuffers:t?[this.uniformBuffer.name]:[],samplerNames:["transmittanceLut"],defines:i,useShaderStore:!0})},e.prototype._drawMultiScatteringLut=function(){var e=this,t=this._transmittanceLut.renderTarget;ne(this._engine,this._effectRenderer,this._multiScatteringEffectWrapper,this._multiScatteringLutRenderTarget,(function(i,r,n,a){e.bindUniformBufferToEffect(n),a.bindFramebuffer(r,void 0,void 0,void 0,!0),i.bindBuffers(n),n.setTexture("transmittanceLut",t),i.draw()}))},e.prototype._drawAerialPerspectiveCompositor=function(){var e,t,i,r=this;if(null!==this.depthTexture&&this.isEnabled()&&!(this._cameraAtmosphereVariables.clampedCameraRadius>this._physicalProperties.atmosphereRadius)){var n=this._engine;null!==(e=this._aerialPerspectiveCompositorEffectWrapper)&&void 0!==e||(this._aerialPerspectiveCompositorEffectWrapper=se(n,this.uniformBuffer,this._isAerialPerspectiveLutEnabled,this._isSkyViewLutEnabled,this._isLinearSpaceComposition,this._applyApproximateTransmittance,this._aerialPerspectiveIntensity,this._aerialPerspectiveRadianceBias));var a=this._isSkyViewLutEnabled?this.skyViewLutRenderTarget:null,o=this._multiScatteringLutRenderTarget,s=this._transmittanceLut.renderTarget,l=this._isAerialPerspectiveLutEnabled?this.aerialPerspectiveLutRenderTarget:null;this._aerialPerspectiveCompositorEffectWrapper.isReady()&&(null===(t=null==a?void 0:a.isReady())||void 0===t||t)&&o.isReady()&&s.isReady()&&(null===(i=null==l?void 0:l.isReady())||void 0===i||i)&&this.depthTexture.isReady()&&ne(n,this._effectRenderer,this._aerialPerspectiveCompositorEffectWrapper,null,(function(e,t,i){if(null===r.depthTexture)throw new Error("Depth texture is required for aerial perspective compositor.");r.bindUniformBufferToEffect(i),e.bindBuffers(i),i.setTexture("transmittanceLut",s),i.setTexture("multiScatteringLut",o),r._isSkyViewLutEnabled&&i.setTexture("skyViewLut",a),r._isAerialPerspectiveLutEnabled&&i.setTexture("aerialPerspectiveLut",l),i.setTexture("depthTexture",r.depthTexture),e.draw()}),1,this.applyApproximateTransmittance?p.Constants.ALPHA_PREMULTIPLIED_PORTERDUFF:p.Constants.ALPHA_ONEONE,!0,!1,p.Constants.ALWAYS,!1)}},e.prototype._drawSkyCompositor=function(){var e,t,i=this;if(this.isEnabled()&&!(this._cameraAtmosphereVariables.clampedCameraRadius>this._physicalProperties.atmosphereRadius)&&(null===this.depthTexture||this.depthTexture.isReady())){var r=this._engine;null!==(e=this._skyCompositorEffectWrapper)&&void 0!==e||(this._skyCompositorEffectWrapper=ae(r,this.uniformBuffer,this._isSkyViewLutEnabled,this._isLinearSpaceComposition,this._applyApproximateTransmittance));var n=this._isSkyViewLutEnabled?this.skyViewLutRenderTarget:null,a=this._multiScatteringLutRenderTarget,o=this._transmittanceLut.renderTarget;this._skyCompositorEffectWrapper.isReady()&&(null===(t=null==n?void 0:n.isReady())||void 0===t||t)&&a.isReady()&&o.isReady()&&ne(r,this._effectRenderer,this._skyCompositorEffectWrapper,null,(function(e,t,r){i.bindUniformBufferToEffect(r),e.bindBuffers(r),r.setTexture("multiScatteringLut",a),r.setTexture("transmittanceLut",o),i._isSkyViewLutEnabled&&r.setTexture("skyViewLut",n),e.draw()}),1,this._applyApproximateTransmittance?p.Constants.ALPHA_PREMULTIPLIED_PORTERDUFF:p.Constants.ALPHA_ONEONE,!0,!1,p.Constants.EQUAL,!1)}},e.prototype._drawGlobeAtmosphereCompositor=function(){var e,t,i=this;if(this.isEnabled()&&this._cameraAtmosphereVariables.clampedCameraRadius>this._physicalProperties.atmosphereRadius){var r=this._engine;null!==(e=this._globeAtmosphereCompositorEffectWrapper)&&void 0!==e||(this._globeAtmosphereCompositorEffectWrapper=le(r,this.uniformBuffer,this._isSkyViewLutEnabled,this._isLinearSpaceComposition,this._applyApproximateTransmittance,this._aerialPerspectiveIntensity,this._aerialPerspectiveRadianceBias,null!==this.depthTexture));var n=this._isSkyViewLutEnabled?this.skyViewLutRenderTarget:null,a=this._multiScatteringLutRenderTarget,o=this._transmittanceLut.renderTarget;this._globeAtmosphereCompositorEffectWrapper.isReady()&&(null===(t=null==n?void 0:n.isReady())||void 0===t||t)&&a.isReady()&&o.isReady()&&(null===this.depthTexture||this.depthTexture.isReady())&&ne(r,this._effectRenderer,this._globeAtmosphereCompositorEffectWrapper,null,(function(e,t,r){i.bindUniformBufferToEffect(r),e.bindBuffers(r),r.setTexture("transmittanceLut",o),r.setTexture("multiScatteringLut",a),i._isSkyViewLutEnabled&&r.setTexture("skyViewLut",n),null!==i.depthTexture&&r.setTexture("depthTexture",i.depthTexture),e.draw()}),1,this._applyApproximateTransmittance?p.Constants.ALPHA_PREMULTIPLIED_PORTERDUFF:p.Constants.ALPHA_ONEONE,!0,!1,p.Constants.ALWAYS,!1)}},e.prototype._disposeSkyCompositor=function(){var e;null===(e=this._skyCompositorEffectWrapper)||void 0===e||e.dispose(),this._skyCompositorEffectWrapper=null},e.prototype._disposeAerialPerspectiveCompositor=function(){var e;null===(e=this._aerialPerspectiveCompositorEffectWrapper)||void 0===e||e.dispose(),this._aerialPerspectiveCompositorEffectWrapper=null},e.prototype._disposeGlobeAtmosphereCompositor=function(){var e;null===(e=this._globeAtmosphereCompositorEffectWrapper)||void 0===e||e.dispose(),this._globeAtmosphereCompositorEffectWrapper=null},e.prototype._updatePerCameraVariables=function(e){var t=this._lights[0];this._directionToLight.copyFrom(t.direction),this._directionToLight.scaleInPlace(-1);var i=this._physicalProperties,r=this._cameraAtmosphereVariables;r.update(e,i.planetRadius,i.planetRadiusWithOffset,i.atmosphereRadius,this._directionToLight,this.originHeight),this._transmittanceLut.updateLightParameters(t,r.clampedCameraRadius,r.cameraGeocentricNormal),this._linearLightColor.copyFrom(t.diffuse),this.getDiffuseSkyIrradianceToRef(this._directionToLight,0,r.cameraGeocentricNormal,this.lights[0].intensity,this._tempSceneAmbient),this.isLinearSpaceLight||this._tempSceneAmbient.toGammaSpaceToRef(this._tempSceneAmbient),this.scene.ambientColor=this._tempSceneAmbient,this.onAfterUpdateVariablesForCameraObservable.notifyObservers(e)},e.prototype._renderLutsForCamera=function(){this.onBeforeLightVariablesUpdateObservable.notifyObservers();var e=this.lights[0];this.isLinearSpaceLight||(e.diffuse=e.diffuse.toGammaSpaceToRef(e.diffuse),e.specular=e.specular.toGammaSpaceToRef(e.specular));var t=e.intensity;this._lightRadianceAtCamera.set(t*this._linearLightColor.r,t*this._linearLightColor.g,t*this._linearLightColor.b),this.uniformBuffer.useUbo&&this._updateUniformBuffer();var i=this.isEnabled();this.onBeforeRenderLutsForCameraObservable.notifyObservers(),this.renderGlobalLuts(),i&&!this._transmittanceLut.isDirty&&this._hasRenderedMultiScatteringLut&&(this._isSkyViewLutEnabled&&this._drawSkyViewLut(),this._isAerialPerspectiveLutEnabled&&this._cameraAtmosphereVariables.clampedCameraRadius<=this._physicalProperties.atmosphereRadius&&this._drawAerialPerspectiveLut()),this.onAfterRenderLutsForCameraObservable.notifyObservers()},e.prototype.renderGlobalLuts=function(){var e,t,i,r,n;this._transmittanceLut.render()&&(this._hasRenderedMultiScatteringLut=!1,null===(e=this._diffuseSkyIrradianceLut)||void 0===e||e.markDirty()),this._transmittanceLut.isDirty||this._hasRenderedMultiScatteringLut||(null!==(t=this._multiScatteringEffectWrapper)&&void 0!==t||(this._multiScatteringEffectWrapper=this._createMultiScatteringEffectWrapper()),(null===(i=this._multiScatteringEffectWrapper)||void 0===i?void 0:i.isReady())&&(null===(r=this._multiScatteringLutRenderTarget)||void 0===r?void 0:r.isReady())&&(this._drawMultiScatteringLut(),this._hasRenderedMultiScatteringLut=!0)),!this._transmittanceLut.isDirty&&this._hasRenderedMultiScatteringLut&&(null===(n=this._diffuseSkyIrradianceLut)||void 0===n||n.render())},e.prototype.bindUniformBufferToEffect=function(e){var t=this.uniformBuffer,i=t.name;t.bindToEffect(e,i),t.useUbo?this.scene.getEngine().bindUniformBufferBase(t.getBuffer(),e._uniformBuffersNames[i],i):this._updateUniformBuffer()},e.prototype._updateUniformBuffer=function(){var e=this._physicalProperties,t=this._cameraAtmosphereVariables,i=this.uniformBuffer;i.updateVector3("peakRayleighScattering",e.rayleighScattering),i.updateFloat("planetRadius",e.planetRadius),i.updateVector3("peakMieScattering",e.mieScattering),i.updateFloat("atmosphereThickness",e.atmosphereThickness),i.updateVector3("peakMieAbsorption",e.mieAbsorption),i.updateFloat("planetRadiusSquared",e.planetRadiusSquared),i.updateVector3("peakMieExtinction",e.mieExtinction),i.updateFloat("atmosphereRadius",e.atmosphereRadius),i.updateVector3("peakOzoneAbsorption",e.ozoneAbsorption),i.updateFloat("atmosphereRadiusSquared",e.atmosphereRadiusSquared),i.updateFloat("horizonDistanceToAtmosphereEdge",e.horizonDistanceToAtmosphereEdge),i.updateFloat("horizonDistanceToAtmosphereEdgeSquared",e.horizonDistanceToAtmosphereEdgeSquared),i.updateFloat("planetRadiusWithOffset",e.planetRadiusWithOffset),i.updateFloat("planetRadiusOffset",e.planetRadiusOffset),i.updateFloat("aerialPerspectiveRadianceBias",this._aerialPerspectiveRadianceBias),i.updateFloat("inverseAtmosphereThickness",1/e.atmosphereThickness),i.updateFloat("aerialPerspectiveTransmittanceScale",this._aerialPerspectiveTransmittanceScale),i.updateMatrix("inverseViewProjectionWithoutTranslation",t.inverseViewProjectionMatrixWithoutTranslation),i.updateVector3("directionToLight",this._directionToLight),i.updateFloat("multiScatteringIntensity",this.multiScatteringIntensity),i.updateVector3("directionToLightRelativeToCameraGeocentricNormal",t.directionToLightRelativeToCameraGeocentricNormal),i.updateFloat("cameraRadius",t.cameraRadius),i.updateVector3("lightRadianceAtCamera",this._lightRadianceAtCamera),i.updateFloat("diffuseSkyIrradianceDesaturationFactor",this._diffuseSkyIrradianceDesaturationFactor),i.updateColor3("groundAlbedo",this._groundAlbedo),i.updateFloat("aerialPerspectiveSaturation",this._aerialPerspectiveSaturation),i.updateVector3("minMultiScattering",this._minimumMultiScattering),i.updateFloat("diffuseSkyIrradianceIntensity",this._diffuseSkyIrradianceIntensity),i.updateVector3("cameraPositionGlobal",t.cameraPositionGlobal),i.updateFloat("lightIntensity",this.lights[0].intensity),i.updateVector3("clampedCameraPositionGlobal",t.clampedCameraPositionGlobal),i.updateFloat("aerialPerspectiveIntensity",this._aerialPerspectiveIntensity),i.updateVector3("cameraGeocentricNormal",t.cameraGeocentricNormal),i.updateFloat("clampedCameraRadius",t.clampedCameraRadius),i.updateVector3("cameraForward",t.cameraForward),i.updateFloat("clampedCameraHeight",t.clampedCameraHeight),i.updateVector3("cameraPosition",t.cameraPosition),i.updateFloat("cosCameraHorizonAngleFromZenith",t.cosCameraHorizonAngleFromZenith),i.updateVector4("viewport",t.viewport),i.updateColor3("additionalDiffuseSkyIrradiance",this._additionalDiffuseSkyIrradiance),i.updateFloat("cameraHeight",t.cameraHeight),i.updateFloat("cameraNearPlane",t.cameraNearPlane),i.updateFloat("originHeight",this._originHeight),i.updateFloat("sinCameraAtmosphereHorizonAngleFromNadir",t.sinCameraAtmosphereHorizonAngleFromNadir),i.updateFloat("atmosphereExposure",this._exposure),i.update()},e.prototype._drawAerialPerspectiveLut=function(){var e=this,t=this._transmittanceLut.renderTarget,i=this._multiScatteringLutRenderTarget;ne(this._engine,this._effectRenderer,this._aerialPerspectiveLutEffectWrapper,this._aerialPerspectiveLutRenderTarget,(function(r,n,a,o){e.bindUniformBufferToEffect(a),a.setTexture("transmittanceLut",t),a.setTexture("multiScatteringLut",i);for(var s=0;s<32;s++)o.bindFramebuffer(n,void 0,void 0,void 0,!0,void 0,s),r.bindBuffers(a),a.setFloat("layerIdx",s),r.draw()}))},e.prototype._drawSkyViewLut=function(){var e=this,t=this._transmittanceLut.renderTarget,i=this._multiScatteringLutRenderTarget;ne(this._engine,this._effectRenderer,this._skyViewLutEffectWrapper,this._skyViewLutRenderTarget,(function(r,n,a,o){e.bindUniformBufferToEffect(a),o.bindFramebuffer(n,void 0,void 0,void 0,!0),r.bindBuffers(a),a.setTexture("transmittanceLut",t),a.setTexture("multiScatteringLut",i),r.draw()}))},e}(),ie=function(e,t,i,r,n,a,o){var s,l=null!==(s=null==o?void 0:o.map((function(e){return"#define ".concat(e)})))&&void 0!==s?s:[];return new p.EffectWrapper({engine:e,name:t,vertexShader:"fullscreenTriangle",fragmentShader:i,attributeNames:["position"],uniformNames:r,uniformBuffers:a,samplerNames:n,defines:l,useShaderStore:!0})},re=function(e,t,i,r){var n=l({generateMipMaps:!1,generateDepthBuffer:!1,generateStencilBuffer:!1,gammaSpace:!1,samplingMode:p.Constants.TEXTURE_BILINEAR_SAMPLINGMODE,type:p.Constants.TEXTURETYPE_HALF_FLOAT,format:p.Constants.TEXTUREFORMAT_RGBA},r),a=new p.RenderTargetTexture(e,t,i,n);return a.wrapU=p.Constants.TEXTURE_CLAMP_ADDRESSMODE,a.wrapV=p.Constants.TEXTURE_CLAMP_ADDRESSMODE,a.anisotropicFilteringLevel=1,a.skipInitialClear=!0,a},ne=function(e,t,i,r,n,a,o,s,l,c,u){if(void 0===a&&(a=0),void 0===o&&(o=p.Constants.ALPHA_DISABLE),void 0===s&&(s=!0),void 0===c&&(c=p.Constants.LEQUAL),void 0===u&&(u=!0),(null===r||r.isReady())&&(null==i?void 0:i.isReady())){var d=e.getDepthWrite();void 0!==l&&e.setDepthWrite(l);var h=e.getDepthFunction();e.setDepthFunction(c);var m=e.getAlphaMode();o!==p.Constants.ALPHA_DISABLE&&e.setAlphaMode(o),t.saveStates(),t.setViewport(),t.applyEffectWrapper(i,s);var f=i.effect;f.setFloat("depth",a),n(t,null==r?void 0:r.renderTarget,f,e),e.setAlphaMode(m),void 0!==d&&e.setDepthWrite(d),h&&e.setDepthFunction(h),t.restoreStates(),u&&e.restoreDefaultFramebuffer()}},ae=function(e,t,i,r,n){var a=t.useUbo,o=["COMPUTE_WORLD_RAY"];i&&o.push("USE_SKY_VIEW_LUT"),r||o.push("OUTPUT_TO_SRGB"),n&&o.push("APPLY_TRANSMITTANCE_BLENDING");var s=i?["skyViewLut"]:["transmittanceLut","multiScatteringLut"];return ie(e,"atmo-skyCompositor","compositeSky",c(["depth"],a?[]:t.getUniformNames(),!0),s,a?[t.name]:[],o)},oe=function(e,t){return ie(e,"atmo-aerialPerspective","aerialPerspective",c(["layerIdx","depth"],t.useUbo?[]:t.getUniformNames(),!0),["transmittanceLut","multiScatteringLut"],t.useUbo?[t.name]:[],["COMPUTE_WORLD_RAY"])},se=function(e,t,i,r,n,a,o,s){var l=t.useUbo,u=["COMPUTE_WORLD_RAY"];i&&u.push("USE_AERIAL_PERSPECTIVE_LUT"),r&&u.push("USE_SKY_VIEW_LUT"),1!==o&&u.push("APPLY_AERIAL_PERSPECTIVE_INTENSITY"),n||u.push("OUTPUT_TO_SRGB"),a&&u.push("APPLY_TRANSMITTANCE_BLENDING"),0!==s&&u.push("APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS");var p=["transmittanceLut","multiScatteringLut","depthTexture"];return r&&p.push("skyViewLut"),i&&p.push("aerialPerspectiveLut"),ie(e,"atmo-aerialPerspectiveCompositor","compositeAerialPerspective",c(["depth"],l?[]:t.getUniformNames(),!0),p,l?[t.name]:[],u)},le=function(e,t,i,r,n,a,o,s){var l=t.useUbo,u=["COMPUTE_WORLD_RAY"];i&&u.push("USE_SKY_VIEW_LUT"),1!==a&&u.push("APPLY_AERIAL_PERSPECTIVE_INTENSITY"),r||u.push("OUTPUT_TO_SRGB"),s&&u.push("HAS_DEPTH_TEXTURE"),n&&u.push("APPLY_TRANSMITTANCE_BLENDING"),0!==o&&u.push("APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS");var p=["transmittanceLut","multiScatteringLut"];return i&&p.push("skyViewLut"),s&&p.push("depthTexture"),ie(e,"atmo-globeAtmosphereCompositor","compositeGlobeAtmosphere",c(["depth"],l?[]:t.getUniformNames(),!0),p,l?[t.name]:[],u)},ce=function(e,t){return ie(e,"atmo-skyView","skyView",c(["depth"],t.useUbo?[]:t.getUniformNames(),!0),["transmittanceLut","multiScatteringLut"],t.useUbo?[t.name]:[])},ue=100,pe=function(e){return function(t,i){var r=t.getMesh(),n=i.getMesh(),a=r.isHtmlMesh,o=n.isHtmlMesh;return a?o&&r.absolutePosition.z<=n.absolutePosition.z?1:-1:o?1:e(t,i)}},de=function(){function e(e,t){var i=void 0===t?{}:t,r=i.parentContainerId,n=void 0===r?null:r,a=i._containerId,o=void 0===a?"css-container":a,s=i.enableOverlayRender,l=void 0===s||s,c=i.defaultOpaqueRenderOrder,u=void 0===c?p.RenderingGroup.PainterSortCompare:c,d=i.defaultAlphaTestRenderOrder,h=void 0===d?p.RenderingGroup.PainterSortCompare:d,m=i.defaultTransparentRenderOrder,f=void 0===m?p.RenderingGroup.defaultTransparentSortCompare:m,g=this;this._cache={cameraData:{fov:0,position:new p.Vector3,style:""},htmlMeshData:new WeakMap},this._width=0,this._height=0,this._heightHalf=0,this._temp={scaleTransform:new p.Vector3,rotationTransform:new p.Quaternion,positionTransform:new p.Vector3,objectMatrix:p.Matrix.Identity(),cameraWorldMatrix:p.Matrix.Identity(),cameraRotationMatrix:p.Matrix.Identity(),cameraWorldMatrixAsArray:new Array(16)},this._lastDevicePixelRatio=window.devicePixelRatio,this._cameraMatrixUpdated=!0,this._previousCanvasDocumentPosition={top:0,left:0},this._renderObserver=null,this._onCameraMatrixChanged=function(e){g._cameraWorldMatrix=e.getWorldMatrix(),g._cameraMatrixUpdated=!0},"undefined"!=typeof document&&(this._containerId=o,this._init(e,n,l,u,h,f))}return e.prototype.dispose=function(){var e,t;this._renderObserver&&(this._renderObserver.remove(),this._renderObserver=null),null===(e=this._overlayElements)||void 0===e||e.container.remove(),this._overlayElements=null,null===(t=this._inSceneElements)||void 0===t||t.container.remove(),this._inSceneElements=null},e.prototype._init=function(e,t,i,r,n,a){var o,s=this;if("undefined"!=typeof document){var l=t?document.getElementById(t):document.body;l||(l=document.body);var c="".concat(this._containerId,"_in_scene");if(this._inSceneElements=this._createRenderLayerElements(c),l.insertBefore(this._inSceneElements.container,l.firstChild),i){var u="".concat(this._containerId,"_overlay");this._overlayElements=this._createRenderLayerElements(u);var p=+(null!==(o=e.getEngine().getRenderingCanvas().style.zIndex)&&void 0!==o?o:"0")+1;this._overlayElements.container.style.zIndex="".concat(p),this._overlayElements.container.style.pointerEvents="none",l.insertBefore(this._overlayElements.container,l.firstChild)}this._engine=e.getEngine();var d,h,m=this._engine.getRenderingCanvasClientRect();if(!m)throw new Error("Failed to get client rect for rendering canvas");this._setSize(m.width,m.height),this._engine.onResizeObservable.add((function(){var e=s._engine.getRenderingCanvasClientRect();e&&s._setSize(e.width,e.height)}));var f=function(){var t=e.activeCamera;t&&(d=t.onProjectionMatrixChangedObservable.add((function(){s._onCameraMatrixChanged(t)})),h=t.onViewMatrixChangedObservable.add((function(){s._onCameraMatrixChanged(t)})))};f(),e.onActiveCameraChanged.add((function(){var t,i;d&&(null===(t=e.activeCamera)||void 0===t||t.onProjectionMatrixChangedObservable.remove(d)),h&&(null===(i=e.activeCamera)||void 0===i||i.onViewMatrixChangedObservable.remove(h)),f()}));var g=pe(r),v=pe(n),_=pe(a);e.setRenderingOrder(0,g,v,_),this._renderObserver=e.onBeforeRenderObservable.add((function(){s._render(e,e.activeCamera)}))}},e.prototype._createRenderLayerElements=function(e){var t=document.getElementById(e);t&&t.remove();var i=document.createElement("div");i.id=e,i.style.position="absolute",i.style.width="100%",i.style.height="100%",i.style.zIndex="-1";var r=document.createElement("div");r.style.overflow="hidden";var n=document.createElement("div");return n.style.webkitTransformStyle="preserve-3d",n.style.transformStyle="preserve-3d",n.style.pointerEvents="none",r.appendChild(n),i.appendChild(r),{container:i,domElement:r,cameraElement:n}},e.prototype._getSize=function(){return{width:this._width,height:this._height}},e.prototype._setSize=function(e,t){if(this._width=e,this._height=t,this._heightHalf=this._height/2,this._inSceneElements&&this._overlayElements)for(var i=0,r=[this._inSceneElements.domElement,this._overlayElements.domElement,this._inSceneElements.cameraElement,this._overlayElements.cameraElement];i<r.length;i++){var n=r[i];n&&(n.style.width="".concat(e,"px"),n.style.height="".concat(t,"px"))}},e.prototype._getCameraCssMatrix=function(e){var t=e.m;return"matrix3d(".concat(this._epsilon(t[0]),",").concat(this._epsilon(-t[1]),",").concat(this._epsilon(t[2]),",").concat(this._epsilon(t[3]),",").concat(this._epsilon(t[4]),",").concat(this._epsilon(-t[5]),",").concat(this._epsilon(t[6]),",").concat(this._epsilon(t[7]),",").concat(this._epsilon(t[8]),",").concat(this._epsilon(-t[9]),",").concat(this._epsilon(t[10]),",").concat(this._epsilon(t[11]),",").concat(this._epsilon(t[12]),",").concat(this._epsilon(-t[13]),",").concat(this._epsilon(t[14]),",").concat(this._epsilon(t[15]),")")},e.prototype._getHtmlContentCssMatrix=function(e,t){var i=e.m,r=t?-1:1;return"matrix3d(".concat(this._epsilon(i[0]),",").concat(this._epsilon(i[1]),",").concat(this._epsilon(i[2]*-r),",").concat(this._epsilon(i[3]),",").concat(this._epsilon(-i[4]),",").concat(this._epsilon(-i[5]),",").concat(this._epsilon(i[6]*r),",").concat(this._epsilon(-i[7]),",").concat(this._epsilon(i[8]*-r),",").concat(this._epsilon(i[9]*-r),",").concat(this._epsilon(i[10]),",").concat(this._epsilon(i[11]*r),",").concat(this._epsilon(i[12]*r),",").concat(this._epsilon(i[13]*r),",").concat(this._epsilon(i[14]*r),",").concat(this._epsilon(i[15]),")")},e.prototype._getTransformationMatrix=function(t,i){var r;if(this._cameraWorldMatrix||(this._cameraWorldMatrix=null===(r=t.getScene().activeCamera)||void 0===r?void 0:r.getWorldMatrix()),!this._cameraWorldMatrix)return p.Matrix.Identity();var n=t.getWorldMatrix(),a=1,o=1;t.sourceWidth&&t.sourceHeight&&(a=t.width/(t.sourceWidth/ue),o=t.height/(t.sourceHeight/ue));var s=this._temp.scaleTransform,l=this._temp.rotationTransform,c=this._temp.positionTransform,u=this._temp.objectMatrix;n.decompose(s,l,c),s.x*=a,s.y*=o,p.Matrix.ComposeToRef(s,l,c,u);var d=i?-1:1,h=t.getAbsolutePosition();return u.setRowFromFloats(3,(-this._cameraWorldMatrix.m[12]+h.x)*ue*d,(-this._cameraWorldMatrix.m[13]+h.y)*ue*d,(this._cameraWorldMatrix.m[14]-h.z)*ue,this._cameraWorldMatrix.m[15]*e.PROJECTION_SCALE_FACTOR*ue),u.multiplyAtIndex(3,ue),u.multiplyAtIndex(7,ue),u.multiplyAtIndex(11,ue),u},e.prototype._renderHtmlMesh=function(e,t){var i,r;if(e.element&&e.element.firstElementChild){var n=this._cache.htmlMeshData.get(e);n||(n={style:""},this._cache.htmlMeshData.set(e,n));var a=e._isCanvasOverlay?null===(i=this._overlayElements)||void 0===i?void 0:i.cameraElement:null===(r=this._inSceneElements)||void 0===r?void 0:r.cameraElement;e.element.parentNode!==a&&a.appendChild(e.element),e.requiresUpdate&&this._updateBaseScaleFactor(e);var o=this._getTransformationMatrix(e,t),s="translate(-50%, -50%) ".concat(this._getHtmlContentCssMatrix(o,t));s+="".concat(t?"matrix3d(".concat(e.billboardMode!==p.TransformNode.BILLBOARDMODE_NONE?1:-1,", 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1)"):""),n.style!==s&&(e.element.style.webkitTransform=s,e.element.style.transform=s),e._markAsUpdated()}},e.prototype._render=function(e,t){var i,r,n,a,o=!1,s=e.useRightHandedSystem;this._updateContainerPositionIfNeeded(),this._cameraMatrixUpdated&&(this._cameraMatrixUpdated=!1,o=!0),t.position.x===this._cache.cameraData.position.x&&t.position.y===this._cache.cameraData.position.y&&t.position.z===this._cache.cameraData.position.z||(this._cache.cameraData.position.copyFrom(t.position),o=!0),window.devicePixelRatio!==this._lastDevicePixelRatio&&(this._lastDevicePixelRatio=window.devicePixelRatio,p.Logger.Log("In render - dpr changed: ",this._lastDevicePixelRatio),o=!0);var l=e.meshes.filter((function(e){return e.isHtmlMesh&&(o||e.requiresUpdate)}));if(o=o||l.length>0){var c=t.getProjectionMatrix().m[5]*this._heightHalf;if(this._cache.cameraData.fov!==c){var u=[null===(i=this._overlayElements)||void 0===i?void 0:i.domElement,null===(r=this._inSceneElements)||void 0===r?void 0:r.domElement];if(t.mode==p.Camera.PERSPECTIVE_CAMERA)for(var d=0,h=u;d<h.length;d++)(T=h[d])&&(T.style.webkitPerspective=c+"px",T.style.perspective=c+"px");else for(var m=0,f=u;m<f.length;m++)(T=f[m])&&(T.style.webkitPerspective="",T.style.perspective="");this._cache.cameraData.fov=c}null===t.parent&&t.computeWorldMatrix();var g=this._temp.cameraWorldMatrix;g.copyFrom(t.getWorldMatrix());var v=this._temp.cameraRotationMatrix;g.getRotationMatrix().transposeToRef(v);var _=this._temp.cameraWorldMatrixAsArray;g.copyToArray(_);var y=s?1:-1;_[1]=v.m[1],_[2]=v.m[2]*y,_[4]=v.m[4]*y,_[6]=v.m[6]*y,_[8]=v.m[8]*y,_[9]=v.m[9]*y,p.Matrix.FromArrayToRef(_,0,g);var S=this._getCameraCssMatrix(g);if(this._cache.cameraData.style!==S){for(var b=0,P=u=[null===(n=this._inSceneElements)||void 0===n?void 0:n.cameraElement,null===(a=this._overlayElements)||void 0===a?void 0:a.cameraElement];b<P.length;b++){var T;(T=P[b])&&(T.style.webkitTransform=S,T.style.transform=S)}this._cache.cameraData.style=S}for(var A=0,R=l;A<R.length;A++){var L=R[A];this._renderHtmlMesh(L,s)}}},e.prototype._updateBaseScaleFactor=function(e){var t=this._width,i=this._height,r=(e.width||1)/(e.height||1);r>t/i?t=i*r:i=t/r,e.setContentSizePx(t,i)},e.prototype._updateContainerPositionIfNeeded=function(){var e,t,i=this._engine.getRenderingCanvasClientRect();if(i){var r=window.scrollY,n=window.scrollX,a=i.top+r,o=i.left+n;if(this._previousCanvasDocumentPosition.top!==a||this._previousCanvasDocumentPosition.left!==o){this._previousCanvasDocumentPosition.top=a,this._previousCanvasDocumentPosition.left=o;for(var s=0,l=[null===(e=this._inSceneElements)||void 0===e?void 0:e.container,null===(t=this._overlayElements)||void 0===t?void 0:t.container];s<l.length;s++){var c=l[s];if(c){var u=c.offsetParent,d=u.getBoundingClientRect(),h=d.top+r,m=d.left+n,f=this._getAncestorMarginsAndPadding(u),g=window.getComputedStyle(document.body),v=parseInt(g.marginTop,10),_=parseInt(g.marginLeft,10);c.style.top="".concat(a-h-f.marginTop+f.paddingTop+v,"px"),c.style.left="".concat(o-m-f.marginLeft+f.paddingLeft+_,"px")}}}}else p.Logger.Warn("Failed to update html mesh renderer position due to failure to get canvas rect. HtmlMesh instances may not render correctly")},e.prototype._epsilon=function(e){return Math.abs(e)<1e-10?0:e},e.prototype._getAncestorMarginsAndPadding=function(e){for(var t=0,i=0,r=0,n=0;e&&e!==document.body&&e!==document.documentElement;){var a=window.getComputedStyle(e);t+=parseInt(a.marginTop,10),i+=parseInt(a.marginLeft,10),r+=parseInt(a.paddingTop,10),n+=parseInt(a.paddingLeft,10),e=e.offsetParent}return{marginTop:t,marginLeft:i,paddingTop:r,paddingLeft:n}},e.PROJECTION_SCALE_FACTOR=1e-5,e}(),he=[],me=new Map,fe=[],ge=null,ve=function(e){Te("In pointerEventsCapture.requestRelease - Pointer events release requested for ".concat(e)),e&&e!==ge?_e(e)?me.delete(e):(Te("In pointerEventsCapture.requestRelease - Received release request ".concat(e," but no matching capture request was received")),fe.includes(e)||fe.push(e)):ye()},_e=function(e){var t=!1;return he=he.filter((function(i){return i!==e||(t=!0,Te("In pointerEventsCapture.cancelRequest - Canceling pointer events capture request ".concat(e)),!1)})),t},ye=function(){var e=Pe();Te("In pointerEventsCapture.transferPointerEventsOwnership - Transferrring pointer events from ".concat(ge," to ").concat(e)),Se(),e&&be(e)},Se=function(){var e;Te("In pointerEventsCapture.doRelease - Releasing pointer events from ".concat(ge)),ge&&(null===(e=me.get(ge))||void 0===e||e.release(),me.delete(ge),ge=null)},be=function(e){var t;e&&(null===(t=me.get(e))||void 0===t||t.capture()),ge=e,Te("In pointerEventsCapture.doCapture - Pointer events now captured by ".concat(e))},Pe=function(){return he.length>0?he.shift():null},Te=function(e){("undefined"==typeof window||window["pointer-events-capture-debug"])&&p.Tools.Log("".concat(performance.now()," - game.scene.pointerEvents - ").concat(e,"\ncurrentOwner: ").concat(ge,"\nqueue: ").concat(he,"\nunmatched: ").concat(fe))},Ae=null,Re=0,Le=new WeakMap,Ee=function(e){"undefined"!=typeof document&&(0===Re&&(document.addEventListener("pointermove",we),document.addEventListener("touchstart",we),Ae=null!=Ae?Ae:e,p.Logger.Log("PointerEventsCaptureBehavior: Starting observation of pointer move events."),Ae.onDisposeObservable.add(Ce)),Re++)},Ce=function(){document.removeEventListener("pointermove",we),document.removeEventListener("touchstart",we),Ae=null,p.Logger.Log("PointerEventsCaptureBehavior: Stopping observation of pointer move events."),Re=0},xe=function(){"undefined"!=typeof document&&Ae&&--Re<=0&&Ce()},we=function(e){if(Ae){var t=Ae.getEngine().getRenderingCanvasClientRect();if(t){var i,r="touches"in e?e.touches[0]:e,n=r.clientX,a=r.clientY,o=n-t.left,s=a-t.top,l=Ae.pick(o,s,(function(e){var t=Le.get(e);return e.isEnabled()&&void 0!==t&&t._captureOnPointerEnter}));i=l.hit?l.pickedMesh:null;var c=parseInt(ge||"");i&&i.uniqueId===c||(!c||i&&i.uniqueId===c||ve(ge),i&&Le.get(i).capturePointerEvents())}}},Me=function(){function e(e,t,i){var r=(void 0===i?{}:i).captureOnPointerEnter,n=void 0===r||r;this._captureCallback=e,this._releaseCallback=t,this.name="PointerEventsCaptureBehavior",this._attachedMesh=null,this._captureOnPointerEnter=n,"undefined"==typeof document&&p.Logger.Warn("Creating an instance of PointerEventsCaptureBehavior outside of a browser. The behavior will not work.")}return Object.defineProperty(e.prototype,"attachedMesh",{get:function(){return this._attachedMesh},set:function(e){this._attachedMesh=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"captureOnPointerEnter",{set:function(e){this._captureOnPointerEnter!==e&&(this._captureOnPointerEnter=e,this._attachedMesh&&(this._captureOnPointerEnter?Ee(this._attachedMesh.getScene()):xe()))},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){this.attachedMesh=e,Le.set(e,this),this._captureOnPointerEnter&&Ee(e.getScene())},e.prototype.detach=function(){this.attachedMesh&&(Le.delete(this.attachedMesh),this._captureOnPointerEnter&&xe(),this.attachedMesh=null)},e.prototype.dispose=function(){this.detach()},e.prototype.releasePointerEvents=function(){this.attachedMesh&&ve(this.attachedMesh.uniqueId.toString())},e.prototype.capturePointerEvents=function(){var e,t,i;this.attachedMesh&&(e=this.attachedMesh.uniqueId.toString(),t=this._captureCallback,i=this._releaseCallback,Te("In pointerEventsCapture.requestCapture - Pointer events capture requested for ".concat(e)),function(e){var t=!1;return fe=fe.filter((function(i){return i!==e||(t=!0,!1)})),t}(e)?Te("In pointerEventsCapture.requestCapture - Capture request matched previous release request ".concat(e,". Cancelling capture request")):(e!==ge&&function(e,t,i){Te("In pointerEventsCapture.enqueueCaptureRequest - Enqueueing capture request for ".concat(e)),he.includes(e)||(he.push(e),me.set(e,{capture:t,release:i}))}(e,t,i),ge||ye()))},e}(),Ie={CONTAIN:{wrapElement:function(e){var t=document.createElement("div");t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center";var i=document.createElement("div");return i.style.visibility="hidden",i.appendChild(e),t.appendChild(i),t},updateSize:function(e,t,i){var r=e.firstElementChild;e.style.width="".concat(t,"px"),e.style.height="".concat(i,"px");var n=[r.offsetWidth,r.offsetHeight],a=n[0],o=n[1],s=Math.min(t/a,i/o);r.style.transform="scale(".concat(s,")"),r.style.visibility="visible"}},COVER:{wrapElement:function(e){var t=document.createElement("div");t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center",t.style.overflow="hidden";var i=document.createElement("div");return i.style.visibility="hidden",i.appendChild(e),t.appendChild(i),t},updateSize:function(e,t,i){var r=e.firstElementChild;e.style.width="".concat(t,"px"),e.style.height="".concat(i,"px");var n=[r.offsetWidth,r.offsetHeight],a=n[0],o=n[1],s=Math.max(t/a,i/o);r.style.transform="scale(".concat(s,")"),r.style.visibility="visible"}},STRETCH:{wrapElement:function(e){var t=document.createElement("div");t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center";var i=document.createElement("div");return i.style.visibility="hidden",i.appendChild(e),t.appendChild(i),t},updateSize:function(e,t,i){var r=e.firstElementChild;e.style.width="".concat(t,"px"),e.style.height="".concat(i,"px");var n=[r.offsetWidth,r.offsetHeight],a=n[0],o=n[1];r.style.transform="scale(".concat(t/a,", ").concat(i/o,")"),r.style.visibility="visible"}},NONE:{wrapElement:function(e){return e},updateSize:function(e,t,i){e&&(e.style.width="".concat(t,"px"),e.style.height="".concat(i,"px"))}}},Oe=function(e){function t(t,i,r){var n=void 0===r?{}:r,a=n.captureOnPointerEnter,o=void 0===a||a,s=n.isCanvasOverlay,l=void 0!==s&&s,c=n.fitStrategy,u=void 0===c?Ie.NONE:c,d=e.call(this,i,t)||this;return d._enabled=!1,d._ready=!1,d._isCanvasOverlay=!1,d._requiresUpdate=!0,d._inverseScaleMatrix=null,d._captureOnPointerEnter=!0,d._pointerEventCaptureBehavior=null,d._sourceWidth=null,d._sourceHeight=null,d._fitStrategy=Ie.NONE,"undefined"==typeof document?(p.Logger.Warn("Creating an instance of an HtmlMesh with id ".concat(i," outside of a browser. The mesh will not be visible.")),d):(d._fitStrategy=u,d._isCanvasOverlay=l,d._createMask(),d._element=d._createElement(),d.setEnabled(!0),d._captureOnPointerEnter=o,d._pointerEventCaptureBehavior=new Me(d.capturePointerEvents.bind(d),d.releasePointerEvents.bind(d),{captureOnPointerEnter:d._captureOnPointerEnter}),d.addBehavior(d._pointerEventCaptureBehavior),d)}return s(t,e),Object.defineProperty(t.prototype,"isHtmlMesh",{get:function(){return!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sourceWidth",{get:function(){return this._sourceWidth},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sourceHeight",{get:function(){return this._sourceHeight},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return this._width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this._height},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"element",{get:function(){return this._element},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"requiresUpdate",{get:function(){return this._requiresUpdate},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"captureOnPointerEnter",{set:function(e){this._captureOnPointerEnter=e,this._pointerEventCaptureBehavior&&(this._pointerEventCaptureBehavior.captureOnPointerEnter=e)},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){var t;e.prototype.dispose.call(this),null===(t=this._element)||void 0===t||t.remove(),this._element=void 0,this._pointerEventCaptureBehavior&&(this._pointerEventCaptureBehavior.dispose(),this._pointerEventCaptureBehavior=null)},t.prototype._markAsUpdated=function(){this._requiresUpdate=!1},t.prototype.setContent=function(e,t,i){this._setAsReady(!1),this._sourceWidth=null,this._sourceHeight=null,this._element&&(this._width=t,this._height=i,this._requiresUpdate=!0,this.scaling.setAll(1),e&&(this._element.appendChild(this._fitStrategy.wrapElement(e)),this._updateScaleIfNecessary()),this.sourceWidth&&this.sourceHeight&&this._setAsReady(!0))},t.prototype.setEnabled=function(e){this._enabled=e,e&&!this._ready||this._doSetEnabled(e)},t.prototype.setContentSizePx=function(e,t){this._sourceWidth=e,this._sourceHeight=t,this._element&&this._element.firstElementChild&&(this._fitStrategy.updateSize(this._element.firstElementChild,e,t),this._updateScaleIfNecessary(),this.width&&this.height&&this._setAsReady(!0))},t.prototype._setAsReady=function(e){this._ready=e,e?this._doSetEnabled(this._enabled):this._doSetEnabled(!1)},t.prototype._doSetEnabled=function(t){var i,r=this;this._element&&(t&&!this._worldMatrixUpdateObserver?this._worldMatrixUpdateObserver=this.onAfterWorldMatrixUpdateObservable.add((function(){r._requiresUpdate=!0})):t||(null===(i=this._worldMatrixUpdateObserver)||void 0===i||i.remove(),this._worldMatrixUpdateObserver=null),this._element.style.display=t?"":"none",this._setElementzIndex(-1e4*this.position.z),e.prototype.setEnabled.call(this,t))},t.prototype._updateScaleIfNecessary=function(){this.scaling.setAll(1),this._inverseScaleMatrix&&(this.bakeTransformIntoVertices(this._inverseScaleMatrix),this._inverseScaleMatrix=null);var e=this._width||1,t=this._height||1,i=p.Matrix.Scaling(e,t,1);this.bakeTransformIntoVertices(i),this._inverseScaleMatrix=new p.Matrix,i.invertToRef(this._inverseScaleMatrix)},t.prototype._createMask=function(){(0,p.CreatePlaneVertexData)({width:1,height:1}).applyToMesh(this);var e=this.getScene();this.checkCollisions=!0;var t=new p.StandardMaterial("".concat(this.id,"-mat"),e);this._isCanvasOverlay||(t.backFaceCulling=!1,t.disableColorWrite=!0,t.disableLighting=!0),this.material=t,this.material.freeze()},t.prototype._setElementzIndex=function(e){this._element&&(this._element.style.zIndex="".concat(e))},t.prototype.capturePointerEvents=function(){this._element&&(this._element.style.pointerEvents="auto",document.getElementsByTagName("body")[0].style.pointerEvents="none")},t.prototype.releasePointerEvents=function(){this._element&&(document.getElementsByTagName("body")[0].style.pointerEvents="auto",this._element.style.pointerEvents="none")},t.prototype._createElement=function(){if("undefined"!=typeof document){var e=document.createElement("div");return e.id=this.id,e.style.backgroundColor=this._isCanvasOverlay?"transparent":"#000",e.style.zIndex="1",e.style.position="absolute",e.style.pointerEvents="none",e.style.backfaceVisibility="hidden",e}},t}(p.Mesh);!function(e){e[e.SPACE=32]="SPACE",e[e.TOFU=65532]="TOFU"}($||($={}));var De=function(){function e(e,t,i){var r=this;this._chars=new Map,this._kernings=new Map,this._font=JSON.parse(e),this._font.pages=[t],this._font.chars.forEach((function(e){return r._chars.set(e.id,e)})),this._font.kernings.forEach((function(e){var t=r._kernings.get(e.first);t||(t=new Map,r._kernings.set(e.first,t)),t.set(e.second,e.amount)})),this._charsRegex=new RegExp("[".concat(this._font.chars.map((function(e){return e.char.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")})).join(""),"]"),"g"),this._updateFallbacks(),this.scale=1/this._font.info.size,this.textures=this._font.pages.map((function(e){var t=new p.Texture(e,i,{noMipmap:!1,invertY:!1});return t.anisotropicFilteringLevel=16,t}))}return e.prototype.dispose=function(){for(var e=0,t=this.textures;e<t.length;e++)t[e].dispose();this.textures.length=0},e.prototype._updateFallbacks=function(){this._chars.has($.SPACE)||this._chars.set($.SPACE,{id:$.SPACE,x:0,y:0,width:0,height:0,xoffset:0,yoffset:0,xadvance:.5*this._font.info.size,page:-1,chnl:-1,index:-1,char:" "}),this._chars.has($.TOFU)||this._chars.set($.TOFU,{id:$.TOFU,x:0,y:0,width:this._font.info.size,height:this._font.info.size,xoffset:0,yoffset:0,xadvance:.5*this._font.info.size,page:-1,chnl:-1,index:-1,char:""})},e.prototype._getChar=function(e){return this._chars.get(e)||this._chars.get($.TOFU)},e.prototype._getKerning=function(e,t){var i;return(null===(i=this._kernings.get(e))||void 0===i?void 0:i.get(t))||0},e.prototype._unsupportedChars=function(e){return e.replace(this._charsRegex,"")},e}(),ke={maxWidth:1/0,lineHeight:1,letterSpacing:1,tabSize:4,whiteSpace:"pre-line",textAlign:"center",translate:{x:-.5,y:-.5}},Ve=function(){function e(e,t,i){this.text=e,this.fontAsset=t,this.options=l(l({},ke),i);var r=this._computeMetrics(e),n=r.paragraph,a=r.lines,o=r.glyphs,s=r.width,c=r.height;this.paragraph=n,this.lines=a,this.glyphs=o,this.width=s,this.height=c}return Object.defineProperty(e.prototype,"lineHeight",{get:function(){return this.fontAsset._font.common.lineHeight*this.options.lineHeight},enumerable:!1,configurable:!0}),e.prototype._computeMetrics=function(e){for(var t=this,i=this._collapse(e),r=this._breakLines(i).map((function(e){return e.trim()})),n=[],a=0,o=r;a<o.length;a++){var s=o[a];n.push.apply(n,this._wrap(s,n.length))}var l=Math.max.apply(Math,n.map((function(e){return e.width}))),c=this.lineHeight*n.length;("left"!==this.options.textAlign||this.options.translate)&&n.forEach((function(e){for(var i=function(){switch(t.options.textAlign){case"right":return l-e.width;case"center":return(l-e.width)/2;default:return 0}}(),r=t.options.translate?t.options.translate.x*l:0,n=t.options.translate?t.options.translate.y*c:0,a=0,o=e.glyphs;a<o.length;a++){var s=o[a];s.x+=i,s.x+=r,s.y+=n}}));var u=n.flatMap((function(e){return e.glyphs}));return{paragraph:r.join("\n"),lines:n,glyphs:u,width:l,height:c}},e.prototype._breakLines=function(e){return e.split("\n")},e.prototype._collapse=function(e){return e.replace(/\t/g," ".repeat(this.options.tabSize)).replace(/ +/g," ")},e.prototype._wrap=function(e,t){void 0===t&&(t=0);for(var i,r=new Array,n=t,a=new Array,o=0,s=0,l=0,c=l,u=function(){r.push({text:e.slice(l,c),glyphs:a,start:l,end:c,width:s})};c<e.length;){var p=c,d=e.charCodeAt(p),h=this.fontAsset._getChar(d),m=h.width,f=(o+=i?this.fontAsset._getKerning(i.id,h.id):0)+m,g=h.xadvance+this.options.letterSpacing,v=o+g,_=v>this.options.maxWidth||f>this.options.maxWidth;_&&(u(),n++,i=void 0,o=0,s=0,c=(l=c)+1,a=[]);var y=o,S=n*this.lineHeight;a.push({char:h,line:n,position:a.length,x:y,y:S}),_?o=g:(i=h,o=v,s=f,c++)}return a.length>0&&u(),r},e}(),Ne=function(){function e(e,t,i){void 0===t&&(t=0),this._useVAO=!1,this._vertexBuffers={},this._charMatrices=new Array,this._charUvs=new Array,this._isDirty=!0,this._baseLine=0,this._scalingMatrix=new p.ThinMatrix,this._fontScaleMatrix=new p.ThinMatrix,this._offsetMatrix=new p.ThinMatrix,this._translationMatrix=new p.ThinMatrix,this._baseMatrix=new p.ThinMatrix,this._scaledMatrix=new p.ThinMatrix,this._localMatrix=new p.ThinMatrix,this._finalMatrix=new p.ThinMatrix,this._lineMatrix=new p.ThinMatrix,this._parentWorldMatrix=new p.ThinMatrix,this.color={r:1,g:1,b:1,a:1},this.strokeColor={r:1,g:1,b:1,a:1},this.strokeInsetWidth=0,this.strokeOutsetWidth=0,this.thicknessControl=0,this._parent=null,this._transformMatrix=new p.ThinMatrix,this.isBillboard=!1,this.isBillboardScreenProjected=!1,this.ignoreDepthBuffer=!1,this._engine=e,this._shaderLanguage=t,this._font=i,this._baseLine=i._font.common.lineHeight*i.scale,this._useVAO=e.getCaps().vertexArrayObject&&!e.disableVertexArrayObjects;var r=new Float32Array([0,0,1,0,0,1,1,1]);this._spriteBuffer=new p.Buffer(e,r,!1,2),this._vertexBuffers.offsets=this._spriteBuffer.createVertexBuffer("offsets",0,2),this._resizeBuffers(128)}return Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},set:function(e){this._parent=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transformMatrix",{get:function(){return this._transformMatrix},set:function(e){this._transformMatrix=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"characterCount",{get:function(){return this._charMatrices.length/16},enumerable:!1,configurable:!0}),e.prototype._resizeBuffers=function(e){this._worldBuffer&&(this._worldBuffer.dispose(),this._worldBuffer=null),this._uvBuffer&&(this._uvBuffer.dispose(),this._uvBuffer=null),this._worldBuffer=new p.Buffer(this._engine,new Float32Array(16*e),!0,16),this._vertexBuffers.world0=this._worldBuffer.createVertexBuffer("world0",0,4,16,!0),this._vertexBuffers.world1=this._worldBuffer.createVertexBuffer("world1",4,4,16,!0),this._vertexBuffers.world2=this._worldBuffer.createVertexBuffer("world2",8,4,16,!0),this._vertexBuffers.world3=this._worldBuffer.createVertexBuffer("world3",12,4,16,!0),this._uvBuffer=new p.Buffer(this._engine,new Float32Array(4*e),!0,4),this._vertexBuffers.uvs=this._uvBuffer.createVertexBuffer("uvs",0,4,4,!0)},e.prototype._setShaders=function(e,t){var i;null===(i=this._drawWrapperBase)||void 0===i||i.dispose(),this._drawWrapperBase=new p.DrawWrapper(this._engine),this._drawWrapperBase.drawContext&&(this._drawWrapperBase.drawContext.useInstancing=!0),this._drawWrapperBase.effect=this._engine.createEffect({vertexSource:e,fragmentSource:t},["offsets","world0","world1","world2","world3","uvs"],["parentWorld","view","projection","uColor","thickness","uStrokeColor","uStrokeInsetWidth","uStrokeOutsetWidth","mode","transform"],["fontAtlas"],"",void 0,void 0,void 0,void 0,this._shaderLanguage),this._drawWrapperBase.effect._refCount++},e.prototype.addParagraph=function(e,t,i){var r=this,n=new Ve(e,this._font,t),a=this._font.scale,o=this._font._font.common.scaleW,s=this._font._font.common.scaleH,l=n.glyphs.filter((function(e){return e.char.page>=0})),c=i;if(!c){var u=n.lineHeight*a,d=n.lines.length*u/2;(0,p.TranslationMatrixToRef)(0,this._baseLine-d,0,this._lineMatrix),c=this._lineMatrix}(0,p.ScalingMatrixToRef)(a,a,1,this._fontScaleMatrix),(0,p.TranslationMatrixToRef)(.5,-.5,0,this._offsetMatrix);var h=this._charUvs.length,m=this._charMatrices.length;l.forEach((function(e,t){r._charUvs[h+4*t+0]=e.char.x/o,r._charUvs[h+4*t+1]=e.char.y/s,r._charUvs[h+4*t+2]=e.char.width/o,r._charUvs[h+4*t+3]=e.char.height/s;var i=e.x+e.char.xoffset,n=1-(e.y+e.char.yoffset);(0,p.ScalingMatrixToRef)(e.char.width,e.char.height,1,r._scalingMatrix),(0,p.MultiplyMatricesToRef)(r._offsetMatrix,r._scalingMatrix,r._baseMatrix),(0,p.TranslationMatrixToRef)(i*a,n*a,0,r._translationMatrix),(0,p.MultiplyMatricesToRef)(r._baseMatrix,r._fontScaleMatrix,r._scaledMatrix),(0,p.MultiplyMatricesToRef)(r._scaledMatrix,r._translationMatrix,r._localMatrix),(0,p.MultiplyMatricesToRef)(r._localMatrix,c,r._finalMatrix),(0,p.CopyMatrixToArray)(r._finalMatrix,r._charMatrices,m+16*t)})),this._isDirty=!0,this._baseLine-=n.lineHeight*a*n.lines.length},e.prototype.render=function(e,t){var i=this._drawWrapperBase,r=i.effect;if(r.isReady()){var n=this._engine;n.setState(!1),n.enableEffect(i),this.ignoreDepthBuffer&&n.setDepthBuffer(!1),this._parent?(0,p.CopyMatrixToRef)(this._parent.getWorldMatrix(),this._parentWorldMatrix):(0,p.IdentityMatrixToRef)(this._parentWorldMatrix),r.setInt("mode",this.isBillboard?this.isBillboardScreenProjected?2:1:0),r.setMatrix("parentWorld",this._parentWorldMatrix),r.setMatrix("view",e),r.setMatrix("projection",t),r.setMatrix("transform",this.transformMatrix),r.setTexture("fontAtlas",this._font.textures[0]),r.setDirectColor4("uColor",this.color),r.setDirectColor4("uStrokeColor",this.strokeColor),r.setFloat("thickness",.9*this.thicknessControl),r.setFloat("uStrokeInsetWidth",this.strokeInsetWidth),r.setFloat("uStrokeOutsetWidth",this.strokeOutsetWidth);var a=this._charMatrices.length/16;this._isDirty&&(this._isDirty=!1,this._worldBuffer.getBuffer().capacity/4<16*a&&this._resizeBuffers(a),this._worldBuffer.update(this._charMatrices),this._uvBuffer.update(this._charUvs)),this._useVAO?(this._vertexArrayObject||(this._vertexArrayObject=n.recordVertexArrayObject(this._vertexBuffers,null,r)),n.bindVertexArrayObject(this._vertexArrayObject,null)):n.bindBuffers(this._vertexBuffers,null,r),n.setAlphaMode(p.Constants.ALPHA_COMBINE),n.drawArraysType(p.Constants.MATERIAL_TriangleStripDrawMode,0,4,a),n.unbindInstanceAttributes(),n.setAlphaMode(p.Constants.ALPHA_DISABLE),this.ignoreDepthBuffer&&n.setDepthBuffer(!0)}},e.prototype.dispose=function(){this._worldBuffer&&(this._worldBuffer.dispose(),this._worldBuffer=null),this._uvBuffer&&(this._uvBuffer.dispose(),this._uvBuffer=null),this._spriteBuffer&&(this._spriteBuffer.dispose(),this._spriteBuffer=null),this._vertexArrayObject&&(this._engine.releaseVertexArrayObject(this._vertexArrayObject),this._vertexArrayObject=null)},e.CreateTextRendererAsync=function(t,i){return n=this,a=void 0,s=function(){var n,a,o,s;return function(e,t){var i,r,n,a={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(l){return function(s){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(i=1,r&&(n=2&s[0]?r.return:s[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,s[1])).done)return n;switch(r=0,n&&(s=[2&s[0],n.value]),s[0]){case 0:case 1:n=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((n=(n=a.trys).length>0&&n[n.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!n||s[1]>n[0]&&s[1]<n[3])){a.label=s[1];break}if(6===s[0]&&a.label<n[1]){a.label=n[1],n=s;break}if(n&&a.label<n[2]){a.label=n[2],a.ops.push(s);break}n[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{i=n=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}(this,(function(l){switch(l.label){case 0:if(!i.getCaps().instancedArrays||!i._features.supportSpriteInstancing)throw new Error("Instanced arrays are required for MSDF text rendering.");return n=0,a="",o="",i.isWebGPU?(n=1,[4,Promise.resolve().then(r.bind(r,681))]):[3,3];case 1:return a=l.sent().msdfVertexShaderWGSL.shader,[4,Promise.resolve().then(r.bind(r,115))];case 2:return o=l.sent().msdfPixelShaderWGSL.shader,[3,6];case 3:return[4,Promise.resolve().then(r.bind(r,36))];case 4:return a=l.sent().msdfVertexShader.shader,[4,Promise.resolve().then(r.bind(r,370))];case 5:o=l.sent().msdfPixelShader.shader,l.label=6;case 6:return(s=new e(i,n,t))._setShaders(a,o),[2,s]}}))},new((o=void 0)||(o=Promise))((function(e,t){function i(e){try{l(s.next(e))}catch(e){t(e)}}function r(e){try{l(s.throw(e))}catch(e){t(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o((function(e){e(n)}))).then(i,r)}l((s=s.apply(n,a||[])).next())}));var n,a,o,s},e}(),Fe=r(36),Ue=r(370),Be=r(681),ze=r(115);const Ge=a;return n.default})()));
|
2
2
|
//# sourceMappingURL=babylonjs.addons.min.js.map
|