babylonjs-addons 8.26.0 → 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.
@@ -1 +1 @@
1
- {"version":3,"file":"babylonjs.addons.min.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,cACR,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,mBAAoB,CAAC,aAAcJ,GAChB,iBAAZC,QACdA,QAAQ,oBAAsBD,EAAQG,QAAQ,cAE9CJ,EAAa,OAAIC,EAAQD,EAAc,QACxC,CATD,CASoB,oBAATO,KAAuBA,KAAyB,oBAAXC,OAAyBA,OAASC,MAAQC,G,2FCNpFC,EAAO,mBACPC,EAAS,m2BAQV,EAAAC,YAAYC,aAAaH,KAC1B,EAAAE,YAAYC,aAAaH,GAAQC,GAG9B,IAAMG,EAAmB,CAAEJ,KAAI,EAAEC,OAAM,E,uECbxCD,EAAO,kBACPC,EAAS,kuCAIV,EAAAC,YAAYG,iBAAiBL,KAC9B,EAAAE,YAAYG,iBAAiBL,GAAQC,GAGlC,IAAMK,EAAsB,CAAEN,KAAI,EAAEC,OAAM,E,mECT3CD,EAAO,kBACPC,EAAS,66BAKV,EAAAC,YAAYC,aAAaH,KAC1B,EAAAE,YAAYC,aAAaH,GAAQC,GAG9B,IAAMM,EAAkB,CAAEP,KAAI,EAAEC,OAAM,E,UCb7CT,EAAOD,QAAUQ,C,wECGXC,EAAO,mBACPC,EAAS,woCAYV,EAAAC,YAAYG,iBAAiBL,KAC9B,EAAAE,YAAYG,iBAAiBL,GAAQC,GAGlC,IAAMO,EAAuB,CAAER,KAAI,EAAEC,OAAM,E,GCnB9CQ,EAA2B,CAAC,EAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAarB,QAGrB,IAAIC,EAASiB,EA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IokB,GAAE,SAAUE,GAAWA,EAAQtkB,EAAQ,KAIjB2kB,KAAKH,EAAWC,EAAW,CAC7GZ,GAAMhB,EAAYA,EAAUjV,MAAM+U,EAASC,GAAc,KAAKS,OAClE,IAPK,IAAmBV,EAASC,EAAYwB,EAAGvB,C,EQ4RlD,EAtWA,G,mCCrCA,U","sources":["webpack://ADDONS/webpack/universalModuleDefinition","webpack://ADDONS/../../../dev/addons/src/msdfText/shaders/msdf.vertex.ts","webpack://ADDONS/../../../dev/addons/src/msdfText/shadersWGSL/msdf.fragment.ts","webpack://ADDONS/../../../dev/addons/src/msdfText/shaders/msdf.fragment.ts","webpack://ADDONS/external umd {\"root\":\"BABYLON\",\"commonjs\":\"babylonjs\",\"commonjs2\":\"babylonjs\",\"amd\":\"babylonjs\"}","webpack://ADDONS/../../../dev/addons/src/msdfText/shadersWGSL/msdf.vertex.ts","webpack://ADDONS/webpack/bootstrap","webpack://ADDONS/webpack/runtime/compat get default export","webpack://ADDONS/webpack/runtime/define property getters","webpack://ADDONS/webpack/runtime/hasOwnProperty shorthand","webpack://ADDONS/webpack/runtime/make namespace object","webpack://ADDONS/../../../dev/addons/src/htmlMesh/htmlMeshRenderer.ts","webpack://ADDONS/../../../../node_modules/tslib/tslib.es6.mjs","webpack://ADDONS/../../../dev/addons/src/htmlMesh/pointerEventsCapture.ts","webpack://ADDONS/../../../dev/addons/src/msdfText/fontAsset.ts","webpack://ADDONS/../../../dev/addons/src/htmlMesh/pointerEventsCaptureBehavior.ts","webpack://ADDONS/../../../dev/addons/src/htmlMesh/fitStrategy.ts","webpack://ADDONS/../../../dev/addons/src/htmlMesh/htmlMesh.ts","webpack://ADDONS/../../../dev/addons/src/msdfText/paragraphOptions.ts","webpack://ADDONS/../../../dev/addons/src/msdfText/sdf/paragraph.ts","webpack://ADDONS/../../../dev/addons/src/msdfText/textRenderer.ts","webpack://ADDONS/./src/index.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"babylonjs\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"babylonjs-addons\", [\"babylonjs\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"babylonjs-addons\"] = factory(require(\"babylonjs\"));\n\telse\n\t\troot[\"ADDONS\"] = factory(root[\"BABYLON\"]);\n})((typeof self !== \"undefined\" ? self : typeof global !== \"undefined\" ? global : this), (__WEBPACK_EXTERNAL_MODULE__597__) => {\nreturn ","// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\n\nconst name = \"msdfVertexShader\";\nconst shader = `#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);}`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const msdfVertexShader = { name, shader };\n","// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\n\nconst name = \"msdfPixelShader\";\nconst shader = `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);}`;\n// Sideeffect\nif (!ShaderStore.ShadersStoreWGSL[name]) {\n ShaderStore.ShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const msdfPixelShaderWGSL = { name, shader };\n","// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\n\nconst name = \"msdfPixelShader\";\nconst shader = `#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);}`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const msdfPixelShader = { name, shader };\n","module.exports = __WEBPACK_EXTERNAL_MODULE__597__;","// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\n\nconst name = \"msdfVertexShader\";\nconst shader = `#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);}`;\n// Sideeffect\nif (!ShaderStore.ShadersStoreWGSL[name]) {\n ShaderStore.ShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const msdfVertexShaderWGSL = { name, shader };\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { Scene } from \"core/scene\";\r\nimport { Matrix, Quaternion, Vector3 } from \"core/Maths/math\";\r\n\r\nimport type { HtmlMesh } from \"./htmlMesh\";\r\nimport { Camera } from \"core/Cameras/camera\";\r\nimport type { SubMesh } from \"core/Meshes/subMesh\";\r\nimport { RenderingGroup } from \"core/Rendering/renderingGroup\";\r\n\r\nimport type { Observer } from \"core/Misc/observable\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport type { AbstractEngine } from \"core/Engines\";\r\nimport { TransformNode } from \"core/Meshes/transformNode\";\r\n\r\nconst PositionUpdateFailMessage = \"Failed to update html mesh renderer position due to failure to get canvas rect. HtmlMesh instances may not render correctly\";\r\nconst BabylonUnitsToPixels = 100;\r\n\r\n/**\r\n * A function that compares two submeshes and returns a number indicating which\r\n * should be rendered first.\r\n */\r\ntype RenderOrderFunction = (subMeshA: SubMesh, subMeshB: SubMesh) => number;\r\n\r\ntype RenderLayerElements = {\r\n container: HTMLElement;\r\n domElement: HTMLElement;\r\n cameraElement: HTMLElement;\r\n};\r\n\r\n// Returns a function that ensures that HtmlMeshes are rendered before all other meshes.\r\n// Note this will only be applied to group 0.\r\n// If neither mesh is an HtmlMesh, then the default render order is used\r\n// This prevents HtmlMeshes from appearing in front of other meshes when they are behind them\r\nconst RenderOrderFunc = (defaultRenderOrder: RenderOrderFunction): RenderOrderFunction => {\r\n return (subMeshA: SubMesh, subMeshB: SubMesh) => {\r\n const meshA = subMeshA.getMesh();\r\n const meshB = subMeshB.getMesh();\r\n\r\n // Use property check instead of instanceof since it is less expensive and\r\n // this will be called many times per frame\r\n const meshIsHtmlMeshA = (meshA as any)[\"isHtmlMesh\"];\r\n const meshIsHtmlMeshB = (meshB as any)[\"isHtmlMesh\"];\r\n if (meshIsHtmlMeshA) {\r\n return meshIsHtmlMeshB ? (meshA.absolutePosition.z <= meshB.absolutePosition.z ? 1 : -1) : -1;\r\n } else {\r\n return meshIsHtmlMeshB ? 1 : defaultRenderOrder(subMeshA, subMeshB);\r\n }\r\n };\r\n};\r\n\r\n/**\r\n * An instance of this is required to render HtmlMeshes in the scene.\r\n * if using HtmlMeshes, you must not set render order for group 0 using\r\n * scene.setRenderingOrder. You must instead pass the compare functions\r\n * to the HtmlMeshRenderer constructor. If you do not, then your render\r\n * order will be overwritten if the HtmlMeshRenderer is created after and\r\n * the HtmlMeshes will not render correctly (they will appear in front of\r\n * meshes that are actually in front of them) if the HtmlMeshRenderer is\r\n * created before.\r\n */\r\nexport class HtmlMeshRenderer {\r\n /**\r\n * Global scale factor applied to the homogeneous `w` component (m[15]) of the\r\n * transformation matrix when projecting 3D objects into pixel space.\r\n *\r\n * This value is used to balance Babylon units against screen pixels, ensuring\r\n * that HTML-mapped or screen-space objects appear with the correct relative\r\n * size. Adjust with care, as changing it affects the projection scale of all\r\n * transformed objects.\r\n *\r\n * The default value is `0.00001`, which works well when 1 Babylon unit\r\n * corresponds to 1 meter, and the typical screen resolution is around\r\n * 100 pixels per meter (i.e., 1 pixel per centimeter).\r\n */\r\n public static PROJECTION_SCALE_FACTOR = 0.00001;\r\n\r\n private _containerId?: string;\r\n private _inSceneElements?: RenderLayerElements | null;\r\n private _overlayElements?: RenderLayerElements | null;\r\n private _engine: AbstractEngine;\r\n\r\n private _cache = {\r\n cameraData: { fov: 0, position: new Vector3(), style: \"\" },\r\n htmlMeshData: new WeakMap<object, { style: string }>(),\r\n };\r\n private _width = 0;\r\n private _height = 0;\r\n private _heightHalf = 0;\r\n\r\n private _cameraWorldMatrix?: Matrix;\r\n\r\n // Create some refs to avoid creating new objects every frame\r\n private _temp = {\r\n scaleTransform: new Vector3(),\r\n rotationTransform: new Quaternion(),\r\n positionTransform: new Vector3(),\r\n objectMatrix: Matrix.Identity(),\r\n cameraWorldMatrix: Matrix.Identity(),\r\n cameraRotationMatrix: Matrix.Identity(),\r\n cameraWorldMatrixAsArray: new Array(16),\r\n };\r\n\r\n // Keep track of DPR so we can resize if DPR changes\r\n // Otherwise the DOM content will scale, but the mesh won't\r\n private _lastDevicePixelRatio = window.devicePixelRatio;\r\n\r\n // Keep track of camera matrix changes so we only update the\r\n // DOM element styles when necessary\r\n private _cameraMatrixUpdated = true;\r\n\r\n // Keep track of position changes so we only update the DOM element\r\n // styles when necessary\r\n private _previousCanvasDocumentPosition = {\r\n top: 0,\r\n left: 0,\r\n };\r\n\r\n private _renderObserver: Observer<Scene> | null = null;\r\n\r\n /**\r\n * Contruct an instance of HtmlMeshRenderer\r\n * @param scene\r\n * @param options object containing the following optional properties:\r\n * @returns\r\n */\r\n constructor(\r\n scene: Scene,\r\n {\r\n parentContainerId = null,\r\n _containerId = \"css-container\",\r\n enableOverlayRender = true,\r\n defaultOpaqueRenderOrder = RenderingGroup.PainterSortCompare,\r\n defaultAlphaTestRenderOrder = RenderingGroup.PainterSortCompare,\r\n defaultTransparentRenderOrder = RenderingGroup.defaultTransparentSortCompare,\r\n }: {\r\n parentContainerId?: string | null;\r\n _containerId?: string;\r\n defaultOpaqueRenderOrder?: RenderOrderFunction;\r\n defaultAlphaTestRenderOrder?: RenderOrderFunction;\r\n defaultTransparentRenderOrder?: RenderOrderFunction;\r\n enableOverlayRender?: boolean;\r\n } = {}\r\n ) {\r\n // Requires a browser to work. Only init if we are in a browser\r\n if (typeof document === \"undefined\") {\r\n return;\r\n }\r\n this._containerId = _containerId;\r\n this._init(scene, parentContainerId, enableOverlayRender, defaultOpaqueRenderOrder, defaultAlphaTestRenderOrder, defaultTransparentRenderOrder);\r\n }\r\n\r\n /**\r\n * Dispose of the HtmlMeshRenderer\r\n */\r\n public dispose() {\r\n if (this._renderObserver) {\r\n this._renderObserver.remove();\r\n this._renderObserver = null;\r\n }\r\n\r\n this._overlayElements?.container.remove();\r\n this._overlayElements = null;\r\n\r\n this._inSceneElements?.container.remove();\r\n this._inSceneElements = null;\r\n }\r\n\r\n protected _init(\r\n scene: Scene,\r\n parentContainerId: string | null,\r\n enableOverlayRender: boolean,\r\n defaultOpaqueRenderOrder: RenderOrderFunction,\r\n defaultAlphaTestRenderOrder: RenderOrderFunction,\r\n defaultTransparentRenderOrder: RenderOrderFunction\r\n ): void {\r\n // Requires a browser to work. Only init if we are in a browser\r\n if (typeof document === \"undefined\") {\r\n return;\r\n }\r\n\r\n // Create the DOM containers\r\n let parentContainer = parentContainerId ? document.getElementById(parentContainerId) : document.body;\r\n\r\n if (!parentContainer) {\r\n parentContainer = document.body;\r\n }\r\n\r\n // if the container already exists, then remove it\r\n const inSceneContainerId = `${this._containerId}_in_scene`;\r\n this._inSceneElements = this._createRenderLayerElements(inSceneContainerId);\r\n\r\n parentContainer.insertBefore(this._inSceneElements.container, parentContainer.firstChild);\r\n\r\n if (enableOverlayRender) {\r\n const overlayContainerId = `${this._containerId}_overlay`;\r\n this._overlayElements = this._createRenderLayerElements(overlayContainerId);\r\n const zIndex = +(scene.getEngine().getRenderingCanvas()!.style.zIndex ?? \"0\") + 1;\r\n this._overlayElements.container.style.zIndex = `${zIndex}`;\r\n this._overlayElements.container.style.pointerEvents = \"none\";\r\n parentContainer.insertBefore(this._overlayElements.container, parentContainer.firstChild);\r\n }\r\n this._engine = scene.getEngine();\r\n const clientRect = this._engine.getRenderingCanvasClientRect();\r\n if (!clientRect) {\r\n throw new Error(\"Failed to get client rect for rendering canvas\");\r\n }\r\n\r\n // Set the size and resize behavior\r\n this._setSize(clientRect.width, clientRect.height);\r\n\r\n this._engine.onResizeObservable.add(() => {\r\n const clientRect = this._engine.getRenderingCanvasClientRect();\r\n if (clientRect) {\r\n this._setSize(clientRect.width, clientRect.height);\r\n }\r\n });\r\n\r\n let projectionObs: Observer<Camera>;\r\n let matrixObs: Observer<Camera>;\r\n\r\n const observeCamera = () => {\r\n const camera = scene.activeCamera;\r\n if (camera) {\r\n projectionObs = camera.onProjectionMatrixChangedObservable.add(() => {\r\n this._onCameraMatrixChanged(camera);\r\n });\r\n matrixObs = camera.onViewMatrixChangedObservable.add(() => {\r\n this._onCameraMatrixChanged(camera);\r\n });\r\n }\r\n };\r\n\r\n observeCamera();\r\n\r\n scene.onActiveCameraChanged.add(() => {\r\n if (projectionObs) {\r\n scene.activeCamera?.onProjectionMatrixChangedObservable.remove(projectionObs);\r\n }\r\n if (matrixObs) {\r\n scene.activeCamera?.onViewMatrixChangedObservable.remove(matrixObs);\r\n }\r\n observeCamera();\r\n });\r\n\r\n // We need to make sure that HtmlMeshes are rendered before all other meshes\r\n // so that they don't appear in front of meshes that are actually in front of them\r\n // Updating the render order isn't ideal, but it is the only way to acheive this\r\n // The implication is that an app using the HtmlMeshRendered must set the scene render order\r\n // via the HtmlMeshRendered constructor\r\n const opaqueRenderOrder = RenderOrderFunc(defaultOpaqueRenderOrder);\r\n const alphaTestRenderOrder = RenderOrderFunc(defaultAlphaTestRenderOrder);\r\n const transparentRenderOrder = RenderOrderFunc(defaultTransparentRenderOrder);\r\n scene.setRenderingOrder(0, opaqueRenderOrder, alphaTestRenderOrder, transparentRenderOrder);\r\n\r\n this._renderObserver = scene.onBeforeRenderObservable.add(() => {\r\n this._render(scene, scene.activeCamera as Camera);\r\n });\r\n }\r\n\r\n private _createRenderLayerElements(containerId: string): RenderLayerElements {\r\n const existingContainer = document.getElementById(containerId);\r\n if (existingContainer) {\r\n existingContainer.remove();\r\n }\r\n const container = document.createElement(\"div\");\r\n container.id = containerId;\r\n container.style.position = \"absolute\";\r\n container.style.width = \"100%\";\r\n container.style.height = \"100%\";\r\n container.style.zIndex = \"-1\";\r\n\r\n const domElement = document.createElement(\"div\");\r\n domElement.style.overflow = \"hidden\";\r\n\r\n const cameraElement = document.createElement(\"div\");\r\n\r\n cameraElement.style.webkitTransformStyle = \"preserve-3d\";\r\n cameraElement.style.transformStyle = \"preserve-3d\";\r\n\r\n cameraElement.style.pointerEvents = \"none\";\r\n\r\n domElement.appendChild(cameraElement);\r\n container.appendChild(domElement);\r\n return {\r\n container,\r\n domElement,\r\n cameraElement,\r\n };\r\n }\r\n\r\n protected _getSize(): { width: number; height: number } {\r\n return {\r\n width: this._width,\r\n height: this._height,\r\n };\r\n }\r\n\r\n protected _setSize(width: number, height: number): void {\r\n this._width = width;\r\n this._height = height;\r\n this._heightHalf = this._height / 2;\r\n\r\n if (!this._inSceneElements || !this._overlayElements) {\r\n return;\r\n }\r\n\r\n const domElements = [this._inSceneElements.domElement, this._overlayElements.domElement, this._inSceneElements.cameraElement, this._overlayElements.cameraElement];\r\n for (const dom of domElements) {\r\n if (dom) {\r\n dom.style.width = `${width}px`;\r\n dom.style.height = `${height}px`;\r\n }\r\n }\r\n }\r\n\r\n // prettier-ignore\r\n protected _getCameraCssMatrix(matrix: Matrix): string {\r\n const elements = matrix.m;\r\n return `matrix3d(${\r\n this._epsilon( elements[0] )\r\n },${\r\n this._epsilon( - elements[1] )\r\n },${\r\n this._epsilon( elements[2] )\r\n },${\r\n this._epsilon( elements[3] )\r\n },${\r\n this._epsilon( elements[4] )\r\n },${\r\n this._epsilon( - elements[5] )\r\n },${\r\n this._epsilon( elements[6] )\r\n },${\r\n this._epsilon( elements[7] )\r\n },${\r\n this._epsilon( elements[8] )\r\n },${\r\n this._epsilon( - elements[9] )\r\n },${\r\n this._epsilon( elements[10] )\r\n },${\r\n this._epsilon( elements[11] )\r\n },${\r\n this._epsilon( elements[12] )\r\n },${\r\n this._epsilon( - elements[13] )\r\n },${\r\n this._epsilon( elements[14] )\r\n },${\r\n this._epsilon( elements[15] )\r\n })`;\r\n }\r\n\r\n // Convert a Babylon world matrix to a CSS matrix\r\n // This also handles conversion from BJS left handed coords\r\n // to CSS right handed coords\r\n // prettier-ignore\r\n protected _getHtmlContentCssMatrix(matrix: Matrix, useRightHandedSystem: boolean): string {\r\n const elements = matrix.m;\r\n // In a right handed coordinate system, the elements 11 to 14 have to change their direction\r\n const direction = useRightHandedSystem ? -1 : 1;\r\n const matrix3d = `matrix3d(${\r\n this._epsilon( elements[0] )\r\n },${\r\n this._epsilon( elements[1] )\r\n },${\r\n this._epsilon( elements[2] * -direction )\r\n },${\r\n this._epsilon( elements[3] )\r\n },${\r\n this._epsilon( - elements[4] )\r\n },${\r\n this._epsilon( - elements[5] )\r\n },${\r\n this._epsilon( elements[6] * direction )\r\n },${\r\n this._epsilon( - elements[7] )\r\n },${\r\n this._epsilon( elements[8] * -direction )\r\n },${\r\n this._epsilon( elements[9] * -direction )\r\n },${\r\n this._epsilon( elements[10] )\r\n },${\r\n this._epsilon( elements[11] * direction )\r\n },${\r\n this._epsilon( elements[12] * direction )\r\n },${\r\n this._epsilon( elements[13] * direction )\r\n },${\r\n this._epsilon( elements[14] * direction )\r\n },${\r\n this._epsilon( elements[15] )\r\n })`;\r\n return matrix3d;\r\n }\r\n\r\n protected _getTransformationMatrix(htmlMesh: HtmlMesh, useRightHandedSystem: boolean): Matrix {\r\n // Get the camera world matrix\r\n // Make sure the camera world matrix is up to date\r\n if (!this._cameraWorldMatrix) {\r\n this._cameraWorldMatrix = htmlMesh.getScene().activeCamera?.getWorldMatrix();\r\n }\r\n if (!this._cameraWorldMatrix) {\r\n return Matrix.Identity();\r\n }\r\n\r\n const objectWorldMatrix = htmlMesh.getWorldMatrix();\r\n\r\n // Scale the object matrix by the base scale factor for the mesh\r\n // which is the ratio of the mesh width/height to the renderer\r\n // width/height divided by the babylon units to pixels ratio\r\n let widthScaleFactor = 1;\r\n let heightScaleFactor = 1;\r\n if (htmlMesh.sourceWidth && htmlMesh.sourceHeight) {\r\n widthScaleFactor = htmlMesh.width! / (htmlMesh.sourceWidth / BabylonUnitsToPixels);\r\n heightScaleFactor = htmlMesh.height! / (htmlMesh.sourceHeight / BabylonUnitsToPixels);\r\n }\r\n\r\n // Apply the scale to the object's world matrix. Note we aren't scaling\r\n // the object, just getting a matrix as though it were scaled, so we can\r\n // scale the content\r\n const scaleTransform = this._temp.scaleTransform;\r\n const rotationTransform = this._temp.rotationTransform;\r\n const positionTransform = this._temp.positionTransform;\r\n const scaledAndTranslatedObjectMatrix = this._temp.objectMatrix;\r\n\r\n objectWorldMatrix.decompose(scaleTransform, rotationTransform, positionTransform);\r\n scaleTransform.x *= widthScaleFactor;\r\n scaleTransform.y *= heightScaleFactor;\r\n\r\n Matrix.ComposeToRef(scaleTransform, rotationTransform, positionTransform, scaledAndTranslatedObjectMatrix);\r\n\r\n // Adjust direction of 12 and 13 of the transformation matrix based on the handedness of the system\r\n const direction = useRightHandedSystem ? -1 : 1;\r\n // Adjust translation values to be from camera vs world origin\r\n // Note that we are also adjusting these values to be pixels vs Babylon units\r\n const position = htmlMesh.getAbsolutePosition();\r\n scaledAndTranslatedObjectMatrix.setRowFromFloats(\r\n 3,\r\n (-this._cameraWorldMatrix.m[12] + position.x) * BabylonUnitsToPixels * direction,\r\n (-this._cameraWorldMatrix.m[13] + position.y) * BabylonUnitsToPixels * direction,\r\n (this._cameraWorldMatrix.m[14] - position.z) * BabylonUnitsToPixels,\r\n this._cameraWorldMatrix.m[15] * HtmlMeshRenderer.PROJECTION_SCALE_FACTOR * BabylonUnitsToPixels\r\n );\r\n\r\n // Adjust other values to be pixels vs Babylon units\r\n scaledAndTranslatedObjectMatrix.multiplyAtIndex(3, BabylonUnitsToPixels);\r\n scaledAndTranslatedObjectMatrix.multiplyAtIndex(7, BabylonUnitsToPixels);\r\n scaledAndTranslatedObjectMatrix.multiplyAtIndex(11, BabylonUnitsToPixels);\r\n\r\n return scaledAndTranslatedObjectMatrix;\r\n }\r\n\r\n protected _renderHtmlMesh(htmlMesh: HtmlMesh, useRightHandedSystem: boolean) {\r\n if (!htmlMesh.element || !htmlMesh.element.firstElementChild) {\r\n // nothing to render, so bail\r\n return;\r\n }\r\n\r\n // We need to ensure html mesh data is initialized before\r\n // computing the base scale factor\r\n let htmlMeshData = this._cache.htmlMeshData.get(htmlMesh);\r\n if (!htmlMeshData) {\r\n htmlMeshData = { style: \"\" };\r\n this._cache.htmlMeshData.set(htmlMesh, htmlMeshData);\r\n }\r\n\r\n const cameraElement = htmlMesh._isCanvasOverlay ? this._overlayElements?.cameraElement : this._inSceneElements?.cameraElement;\r\n\r\n if (htmlMesh.element.parentNode !== cameraElement) {\r\n cameraElement!.appendChild(htmlMesh.element);\r\n }\r\n\r\n // If the htmlMesh content has changed, update the base scale factor\r\n if (htmlMesh.requiresUpdate) {\r\n this._updateBaseScaleFactor(htmlMesh);\r\n }\r\n\r\n // Get the transformation matrix for the html mesh\r\n const scaledAndTranslatedObjectMatrix = this._getTransformationMatrix(htmlMesh, useRightHandedSystem);\r\n\r\n let style = `translate(-50%, -50%) ${this._getHtmlContentCssMatrix(scaledAndTranslatedObjectMatrix, useRightHandedSystem)}`;\r\n // In a right handed system, screens are on the wrong side of the mesh, so we have to rotate by Math.PI which results in the matrix3d seen below\r\n // Also in RH + billboard mode, we cancel the handedness so we do not need to scale on x\r\n style += `${useRightHandedSystem ? `matrix3d(${htmlMesh.billboardMode !== TransformNode.BILLBOARDMODE_NONE ? 1 : -1}, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1)` : \"\"}`;\r\n\r\n if (htmlMeshData.style !== style) {\r\n htmlMesh.element.style.webkitTransform = style;\r\n htmlMesh.element.style.transform = style;\r\n }\r\n\r\n htmlMesh._markAsUpdated();\r\n }\r\n\r\n protected _render(scene: Scene, camera: Camera) {\r\n let needsUpdate = false;\r\n\r\n const useRightHandedSystem = scene.useRightHandedSystem;\r\n\r\n // Update the container position and size if necessary\r\n this._updateContainerPositionIfNeeded();\r\n\r\n // Check for a camera change\r\n if (this._cameraMatrixUpdated) {\r\n this._cameraMatrixUpdated = false;\r\n needsUpdate = true;\r\n }\r\n\r\n // If the camera position has changed, then we also need to update\r\n if (\r\n camera.position.x !== this._cache.cameraData.position.x ||\r\n camera.position.y !== this._cache.cameraData.position.y ||\r\n camera.position.z !== this._cache.cameraData.position.z\r\n ) {\r\n this._cache.cameraData.position.copyFrom(camera.position);\r\n needsUpdate = true;\r\n }\r\n\r\n // Check for a dpr change\r\n if (window.devicePixelRatio !== this._lastDevicePixelRatio) {\r\n this._lastDevicePixelRatio = window.devicePixelRatio;\r\n Logger.Log(\"In render - dpr changed: \", this._lastDevicePixelRatio);\r\n needsUpdate = true;\r\n }\r\n\r\n // Check if any meshes need to be updated\r\n const meshesNeedingUpdate = scene.meshes.filter((mesh) => (mesh as any)[\"isHtmlMesh\"] && (needsUpdate || (mesh as HtmlMesh).requiresUpdate));\r\n needsUpdate = needsUpdate || meshesNeedingUpdate.length > 0;\r\n\r\n if (!needsUpdate) {\r\n return;\r\n }\r\n\r\n // Get a projection matrix for the camera\r\n const projectionMatrix = camera.getProjectionMatrix();\r\n const fov = projectionMatrix.m[5] * this._heightHalf;\r\n\r\n if (this._cache.cameraData.fov !== fov) {\r\n const source = [this._overlayElements?.domElement, this._inSceneElements?.domElement];\r\n if (camera.mode == Camera.PERSPECTIVE_CAMERA) {\r\n for (const el of source) {\r\n if (el) {\r\n el.style.webkitPerspective = fov + \"px\";\r\n el.style.perspective = fov + \"px\";\r\n }\r\n }\r\n } else {\r\n for (const el of source) {\r\n if (el) {\r\n el.style.webkitPerspective = \"\";\r\n el.style.perspective = \"\";\r\n }\r\n }\r\n }\r\n this._cache.cameraData.fov = fov;\r\n }\r\n\r\n // Get the CSS matrix for the camera (which will include any camera rotation)\r\n if (camera.parent === null) {\r\n camera.computeWorldMatrix();\r\n }\r\n\r\n const cameraMatrixWorld = this._temp.cameraWorldMatrix;\r\n cameraMatrixWorld.copyFrom(camera.getWorldMatrix());\r\n const cameraRotationMatrix = this._temp.cameraRotationMatrix;\r\n cameraMatrixWorld.getRotationMatrix().transposeToRef(cameraRotationMatrix);\r\n\r\n const cameraMatrixWorldAsArray = this._temp.cameraWorldMatrixAsArray;\r\n cameraMatrixWorld.copyToArray(cameraMatrixWorldAsArray);\r\n\r\n // For a few values, we have to adjust the direction based on the handedness of the system\r\n const direction = useRightHandedSystem ? 1 : -1;\r\n\r\n cameraMatrixWorldAsArray[1] = cameraRotationMatrix.m[1];\r\n cameraMatrixWorldAsArray[2] = cameraRotationMatrix.m[2] * direction;\r\n cameraMatrixWorldAsArray[4] = cameraRotationMatrix.m[4] * direction;\r\n cameraMatrixWorldAsArray[6] = cameraRotationMatrix.m[6] * direction;\r\n cameraMatrixWorldAsArray[8] = cameraRotationMatrix.m[8] * direction;\r\n cameraMatrixWorldAsArray[9] = cameraRotationMatrix.m[9] * direction;\r\n\r\n Matrix.FromArrayToRef(cameraMatrixWorldAsArray, 0, cameraMatrixWorld);\r\n\r\n const cameraCSSMatrix = this._getCameraCssMatrix(cameraMatrixWorld);\r\n const style = cameraCSSMatrix;\r\n\r\n if (this._cache.cameraData.style !== style) {\r\n const source = [this._inSceneElements?.cameraElement, this._overlayElements?.cameraElement];\r\n for (const el of source) {\r\n if (el) {\r\n el.style.webkitTransform = style;\r\n el.style.transform = style;\r\n }\r\n }\r\n this._cache.cameraData.style = style;\r\n }\r\n\r\n // _Render objects if necessary\r\n for (const mesh of meshesNeedingUpdate) {\r\n this._renderHtmlMesh(mesh as HtmlMesh, useRightHandedSystem);\r\n }\r\n }\r\n\r\n protected _updateBaseScaleFactor(htmlMesh: HtmlMesh) {\r\n // Get screen width and height\r\n let screenWidth = this._width;\r\n let screenHeight = this._height;\r\n\r\n // Calculate aspect ratios\r\n const htmlMeshAspectRatio = (htmlMesh.width || 1) / (htmlMesh.height || 1);\r\n const screenAspectRatio = screenWidth / screenHeight;\r\n\r\n // Adjust screen dimensions based on aspect ratios\r\n if (htmlMeshAspectRatio > screenAspectRatio) {\r\n // If the HTML mesh is wider relative to its height than the screen, adjust the screen width\r\n screenWidth = screenHeight * htmlMeshAspectRatio;\r\n } else {\r\n // If the HTML mesh is taller relative to its width than the screen, adjust the screen height\r\n screenHeight = screenWidth / htmlMeshAspectRatio;\r\n }\r\n\r\n // Set content to fill screen so we get max resolution when it is shrunk to fit the mesh\r\n htmlMesh.setContentSizePx(screenWidth, screenHeight);\r\n }\r\n\r\n protected _updateContainerPositionIfNeeded() {\r\n // Determine if the canvas has moved on the screen\r\n const canvasRect = this._engine.getRenderingCanvasClientRect();\r\n\r\n // canvas rect may be null if layout not complete\r\n if (!canvasRect) {\r\n Logger.Warn(PositionUpdateFailMessage);\r\n return;\r\n }\r\n const scrollTop = window.scrollY;\r\n const scrollLeft = window.scrollX;\r\n const canvasDocumentTop = canvasRect.top + scrollTop;\r\n const canvasDocumentLeft = canvasRect.left + scrollLeft;\r\n\r\n if (this._previousCanvasDocumentPosition.top !== canvasDocumentTop || this._previousCanvasDocumentPosition.left !== canvasDocumentLeft) {\r\n this._previousCanvasDocumentPosition.top = canvasDocumentTop;\r\n this._previousCanvasDocumentPosition.left = canvasDocumentLeft;\r\n\r\n const source = [this._inSceneElements?.container, this._overlayElements?.container];\r\n for (const container of source) {\r\n if (!container) {\r\n continue;\r\n }\r\n // set the top and left of the css container to match the canvas\r\n const containerParent = container.offsetParent as HTMLElement;\r\n const parentRect = containerParent.getBoundingClientRect();\r\n const parentDocumentTop = parentRect.top + scrollTop;\r\n const parentDocumentLeft = parentRect.left + scrollLeft;\r\n\r\n const ancestorMarginsAndPadding = this._getAncestorMarginsAndPadding(containerParent);\r\n\r\n // Add the body margin\r\n const bodyStyle = window.getComputedStyle(document.body);\r\n const bodyMarginTop = parseInt(bodyStyle.marginTop, 10);\r\n const bodyMarginLeft = parseInt(bodyStyle.marginLeft, 10);\r\n\r\n container.style.top = `${canvasDocumentTop - parentDocumentTop - ancestorMarginsAndPadding.marginTop + ancestorMarginsAndPadding.paddingTop + bodyMarginTop}px`;\r\n container.style.left = `${\r\n canvasDocumentLeft - parentDocumentLeft - ancestorMarginsAndPadding.marginLeft + ancestorMarginsAndPadding.paddingLeft + bodyMarginLeft\r\n }px`;\r\n }\r\n }\r\n }\r\n\r\n protected _onCameraMatrixChanged = (camera: Camera) => {\r\n this._cameraWorldMatrix = camera.getWorldMatrix();\r\n this._cameraMatrixUpdated = true;\r\n };\r\n\r\n private _epsilon(value: number) {\r\n return Math.abs(value) < 1e-10 ? 0 : value;\r\n }\r\n\r\n // Get total margins and padding for an element, excluding the body and document margins\r\n private _getAncestorMarginsAndPadding(element: HTMLElement) {\r\n let marginTop = 0;\r\n let marginLeft = 0;\r\n let paddingTop = 0;\r\n let paddingLeft = 0;\r\n\r\n while (element && element !== document.body && element !== document.documentElement) {\r\n const style = window.getComputedStyle(element);\r\n marginTop += parseInt(style.marginTop, 10);\r\n marginLeft += parseInt(style.marginLeft, 10);\r\n paddingTop += parseInt(style.paddingTop, 10);\r\n paddingLeft += parseInt(style.paddingLeft, 10);\r\n element = element.offsetParent as HTMLElement;\r\n }\r\n\r\n return { marginTop, marginLeft, paddingTop, paddingLeft };\r\n }\r\n}\r\n","/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nexport function __extends(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nexport var __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n }\n return __assign.apply(this, arguments);\n}\n\nexport function __rest(s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n}\n\nexport function __decorate(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nexport function __param(paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n var _, done = false;\n for (var i = decorators.length - 1; i >= 0; i--) {\n var context = {};\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n if (kind === \"accessor\") {\n if (result === void 0) continue;\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n if (_ = accept(result.get)) descriptor.get = _;\n if (_ = accept(result.set)) descriptor.set = _;\n if (_ = accept(result.init)) initializers.unshift(_);\n }\n else if (_ = accept(result)) {\n if (kind === \"field\") initializers.unshift(_);\n else descriptor[key] = _;\n }\n }\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\n done = true;\n};\n\nexport function __runInitializers(thisArg, initializers, value) {\n var useValue = arguments.length > 2;\n for (var i = 0; i < initializers.length; i++) {\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n }\n return useValue ? value : void 0;\n};\n\nexport function __propKey(x) {\n return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nexport function __setFunctionName(f, name, prefix) {\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nexport function __metadata(metadataKey, metadataValue) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nexport function __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nexport function __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nexport function __exportStar(m, o) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nexport function __values(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nexport function __read(o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n}\n\n/** @deprecated */\nexport function __spread() {\n for (var ar = [], i = 0; i < arguments.length; i++)\n ar = ar.concat(__read(arguments[i]));\n return ar;\n}\n\n/** @deprecated */\nexport function __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n}\n\nexport function __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nexport function __await(v) {\n return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nexport function __asyncGenerator(thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nexport function __asyncDelegator(o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nexport function __asyncValues(o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nexport function __makeTemplateObject(cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n};\n\nvar ownKeys = function(o) {\n ownKeys = Object.getOwnPropertyNames || function (o) {\n var ar = [];\n for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;\n return ar;\n };\n return ownKeys(o);\n};\n\nexport function __importStar(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== \"default\") __createBinding(result, mod, k[i]);\n __setModuleDefault(result, mod);\n return result;\n}\n\nexport function __importDefault(mod) {\n return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nexport function __classPrivateFieldIn(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nexport function __addDisposableResource(env, value, async) {\n if (value !== null && value !== void 0) {\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n var dispose, inner;\n if (async) {\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n dispose = value[Symbol.asyncDispose];\n }\n if (dispose === void 0) {\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n dispose = value[Symbol.dispose];\n if (async) inner = dispose;\n }\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\n env.stack.push({ value: value, dispose: dispose, async: async });\n }\n else if (async) {\n env.stack.push({ async: true });\n }\n return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nexport function __disposeResources(env) {\n function fail(e) {\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n env.hasError = true;\n }\n var r, s = 0;\n function next() {\n while (r = env.stack.pop()) {\n try {\n if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\n if (r.dispose) {\n var result = r.dispose.call(r.value);\n if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n }\n else s |= 1;\n }\n catch (e) {\n fail(e);\n }\n }\n if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\n if (env.hasError) throw env.error;\n }\n return next();\n}\n\nexport function __rewriteRelativeImportExtension(path, preserveJsx) {\n if (typeof path === \"string\" && /^\\.\\.?\\//.test(path)) {\n return path.replace(/\\.(tsx)$|((?:\\.d)?)((?:\\.[^./]+?)?)\\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {\n return tsx ? preserveJsx ? \".jsx\" : \".js\" : d && (!ext || !cm) ? m : (d + ext + \".\" + cm.toLowerCase() + \"js\");\n });\n }\n return path;\n}\n\nexport default {\n __extends,\n __assign,\n __rest,\n __decorate,\n __param,\n __esDecorate,\n __runInitializers,\n __propKey,\n __setFunctionName,\n __metadata,\n __awaiter,\n __generator,\n __createBinding,\n __exportStar,\n __values,\n __read,\n __spread,\n __spreadArrays,\n __spreadArray,\n __await,\n __asyncGenerator,\n __asyncDelegator,\n __asyncValues,\n __makeTemplateObject,\n __importStar,\n __importDefault,\n __classPrivateFieldGet,\n __classPrivateFieldSet,\n __classPrivateFieldIn,\n __addDisposableResource,\n __disposeResources,\n __rewriteRelativeImportExtension,\n};\n","import { Tools } from \"core/Misc/tools\";\r\n\r\n// A capture management system to ensure that the correct object has the pointer\r\n// events by eliminating race conditions that can cause the pointer events to be\r\n// released by a different object after they are captured leaving no object\r\n// as the owner. It does this by queueing requests and only allowing\r\n// capture when the current capture owner releases pointer events.\r\n\r\ntype CaptureReleaseCallback = () => void;\r\n\r\ntype CaptureReleaseCallbacks = {\r\n capture: CaptureReleaseCallback;\r\n release: CaptureReleaseCallback;\r\n};\r\n\r\nlet CaptureRequestQueue: string[] = [];\r\n\r\n// Key is request id, value is object with capture and release callbacks\r\nconst PendingRequestCallbacks: Map<string, CaptureReleaseCallbacks> = new Map();\r\n\r\n// Keep track of release requests with no matching capture request\r\n// in case the release request arrived before the capture to avoid\r\n// the capture request never getting released.\r\nlet UnmatchedReleaseRequests: string[] = [];\r\n\r\nlet CurrentOwner: string | null = null; // Called on first capture or release request\r\n\r\n/**\r\n * Get the id of the object currently capturing pointer events\r\n * @returns The id of the object currently capturing pointer events\r\n * or null if no object is capturing pointer events\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const getCapturingId = () => {\r\n return CurrentOwner;\r\n};\r\n\r\n/**\r\n * Request that the object with the given id capture pointer events. If there is no current\r\n * owner, then the request is granted immediately. If there is a current owner, then the request\r\n * is queued until the current owner releases pointer events.\r\n * @param requestId An id to identify the request. This id will be used to match the capture\r\n * request with the release request.\r\n * @param captureCallback The callback to call when the request is granted and the object is capturing\r\n * @param releaseCallback The callback to call when the object is no longer capturing pointer events\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const requestCapture = (requestId: string, captureCallback: CaptureReleaseCallback, releaseCallback: CaptureReleaseCallback) => {\r\n DebugLog(`In pointerEventsCapture.requestCapture - Pointer events capture requested for ${requestId}`);\r\n\r\n // If there is a release for this request, then ignore the request\r\n if (RemoveUnmatchedRequest(requestId)) {\r\n DebugLog(`In pointerEventsCapture.requestCapture - Capture request matched previous release request ${requestId}. Cancelling capture request`);\r\n return;\r\n } else if (requestId !== CurrentOwner) {\r\n // if the request is not already in the queue, add it to the queue\r\n EnqueueCaptureRequest(requestId, captureCallback, releaseCallback);\r\n }\r\n\r\n if (!CurrentOwner) {\r\n // If there is no current owner, go ahead and grant the request\r\n TransferPointerEventsOwnership();\r\n }\r\n // If the request id is the current owner, do nothing\r\n};\r\n\r\n/**\r\n * Release pointer events from the object with the given id. If the object is the current owner\r\n * then pointer events are released immediately. If the object is not the current owner, then the\r\n * associated capture request is removed from the queue. If there is no matching capture request\r\n * in the queue, then the release request is added to a list of unmatched release requests and will\r\n * negate the next capture request with the same id. This is to guard against the possibility that\r\n * the release request arrived before the capture request.\r\n * @param requestId The id which should match the id of the capture request\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const requestRelease = (requestId: string | null) => {\r\n DebugLog(`In pointerEventsCapture.requestRelease - Pointer events release requested for ${requestId}`);\r\n\r\n // if the requestId is the current capture holder release it\r\n if (!requestId || requestId === CurrentOwner) {\r\n TransferPointerEventsOwnership();\r\n } else if (CancelRequest(requestId)) {\r\n // if the request is in the queue, but not the current capture holder, remove it and it's callbacks\r\n PendingRequestCallbacks.delete(requestId);\r\n } else {\r\n DebugLog(`In pointerEventsCapture.requestRelease - Received release request ${requestId} but no matching capture request was received`);\r\n // request was not current and not in queue, likely because we received a release\r\n // request before the capture. Add it to the unmatched list to guard against this possibility\r\n if (!UnmatchedReleaseRequests.includes(requestId)) {\r\n UnmatchedReleaseRequests.push(requestId);\r\n }\r\n }\r\n};\r\n\r\n/**\r\n * Release pointer events from the current owner\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const releaseCurrent = () => {\r\n requestRelease(CurrentOwner);\r\n};\r\n\r\nconst EnqueueCaptureRequest = (requestId: string, capture: CaptureReleaseCallback, release: CaptureReleaseCallback) => {\r\n DebugLog(`In pointerEventsCapture.enqueueCaptureRequest - Enqueueing capture request for ${requestId}`);\r\n if (!CaptureRequestQueue.includes(requestId)) {\r\n CaptureRequestQueue.push(requestId);\r\n PendingRequestCallbacks.set(requestId, { capture, release });\r\n }\r\n};\r\n\r\n// Removes the request from the queue if it exists. Returns true\r\n// if the request was found and removed, otherwise false\r\nconst CancelRequest = (requestId: string | null) => {\r\n let removed = false;\r\n CaptureRequestQueue = CaptureRequestQueue.filter((id) => {\r\n if (id !== requestId) {\r\n return true;\r\n } else {\r\n removed = true;\r\n DebugLog(`In pointerEventsCapture.cancelRequest - Canceling pointer events capture request ${requestId}`);\r\n return false;\r\n }\r\n });\r\n return removed;\r\n};\r\n\r\nconst RemoveUnmatchedRequest = (requestId: string) => {\r\n let removed = false;\r\n UnmatchedReleaseRequests = UnmatchedReleaseRequests.filter((id) => {\r\n if (id !== requestId) {\r\n return true;\r\n } else {\r\n removed = true;\r\n return false;\r\n }\r\n });\r\n return removed;\r\n};\r\n\r\nconst TransferPointerEventsOwnership = () => {\r\n const newOwnerId = NextCaptureRequest();\r\n DebugLog(`In pointerEventsCapture.transferPointerEventsOwnership - Transferrring pointer events from ${CurrentOwner} to ${newOwnerId}`);\r\n // Release the current owner\r\n DoRelease();\r\n if (newOwnerId) {\r\n DoCapture(newOwnerId);\r\n }\r\n};\r\n\r\nconst DoRelease = () => {\r\n DebugLog(`In pointerEventsCapture.doRelease - Releasing pointer events from ${CurrentOwner}`);\r\n if (CurrentOwner) {\r\n // call the release callback\r\n PendingRequestCallbacks.get(CurrentOwner)?.release();\r\n // And remove the callbacks\r\n PendingRequestCallbacks.delete(CurrentOwner);\r\n CurrentOwner = null;\r\n }\r\n};\r\n\r\nconst DoCapture = (newOwnerId: string) => {\r\n if (newOwnerId) {\r\n // call the capture callback\r\n PendingRequestCallbacks.get(newOwnerId)?.capture();\r\n }\r\n CurrentOwner = newOwnerId;\r\n DebugLog(`In pointerEventsCapture.doCapture - Pointer events now captured by ${newOwnerId}`);\r\n};\r\n\r\nconst NextCaptureRequest = () => {\r\n return CaptureRequestQueue.length > 0 ? CaptureRequestQueue.shift() : null;\r\n};\r\n\r\n// #region Debugging support\r\ndeclare global {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n interface Window {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n \"pointer-events-capture-debug\": boolean | null;\r\n }\r\n}\r\n\r\nconst DebugLog = (message: string) => {\r\n // If we are runnning in a test runner (in node, so window is not defined)\r\n // or if the debug flag is set, then log the message\r\n if (typeof window === \"undefined\" || window[\"pointer-events-capture-debug\"]) {\r\n Tools.Log(\r\n `${performance.now()} - game.scene.pointerEvents - ${message}\\ncurrentOwner: ${CurrentOwner}\\nqueue: ${CaptureRequestQueue}\\nunmatched: ${UnmatchedReleaseRequests}`\r\n );\r\n }\r\n};\r\n// #endregion Debugging support\r\n","import type { IDisposable, Scene } from \"core/scene\";\r\nimport type { BMFontChar } from \"./sdf/bmFont\";\r\nimport type { SdfFont } from \"./sdf/font\";\r\nimport { Texture } from \"core/Materials/Textures/texture\";\r\n\r\nenum CharCode {\r\n SPACE = 32,\r\n TOFU = 0xfffc,\r\n}\r\n\r\n/**\r\n * Class representing a font asset for SDF (Signed Distance Field) rendering.\r\n */\r\nexport class FontAsset implements IDisposable {\r\n private readonly _chars = new Map<number, BMFontChar>();\r\n private readonly _charsRegex: RegExp;\r\n private readonly _kernings = new Map<number, Map<number, number>>();\r\n\r\n /** @internal */\r\n public readonly _font: SdfFont;\r\n\r\n /**\r\n * Gets the font scale value\r\n */\r\n public readonly scale: number;\r\n\r\n /**\r\n * Gets the list of used textures\r\n */\r\n public readonly textures: Texture[];\r\n\r\n /**\r\n * Creates a new FontAsset instance.\r\n * @param definitionData defines the font data in JSON format.\r\n * @param textureUrl defines the url of the texture to use for the font.\r\n * @param scene defines the hosting scene.\r\n */\r\n public constructor(definitionData: string, textureUrl: string, scene?: Scene) {\r\n this._font = JSON.parse(definitionData) as SdfFont;\r\n // So far we only consider one page\r\n this._font.pages = [textureUrl];\r\n\r\n this._font.chars.forEach((char) => this._chars.set(char.id, char));\r\n this._font.kernings.forEach((kerning) => {\r\n let submap = this._kernings.get(kerning.first);\r\n if (!submap) {\r\n submap = new Map();\r\n this._kernings.set(kerning.first, submap);\r\n }\r\n submap.set(kerning.second, kerning.amount);\r\n });\r\n this._charsRegex = new RegExp(`[${this._font.chars.map((c) => c.char.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, \"\\\\$&\")).join(\"\")}]`, \"g\");\r\n\r\n this._updateFallbacks();\r\n\r\n this.scale = 1 / this._font.info.size;\r\n this.textures = this._font.pages.map((page) => {\r\n const texture = new Texture(page, scene, { noMipmap: false, invertY: false });\r\n texture.anisotropicFilteringLevel = 16;\r\n return texture;\r\n });\r\n }\r\n\r\n dispose(): void {\r\n for (const texture of this.textures) {\r\n texture.dispose();\r\n }\r\n this.textures.length = 0;\r\n }\r\n\r\n private _updateFallbacks() {\r\n if (!this._chars.has(CharCode.SPACE)) {\r\n this._chars.set(CharCode.SPACE, {\r\n id: CharCode.SPACE,\r\n x: 0,\r\n y: 0,\r\n width: 0,\r\n height: 0,\r\n xoffset: 0,\r\n yoffset: 0,\r\n xadvance: this._font.info.size * 0.5,\r\n page: -1,\r\n chnl: -1,\r\n index: -1,\r\n char: \" \",\r\n });\r\n }\r\n\r\n if (!this._chars.has(CharCode.TOFU)) {\r\n this._chars.set(CharCode.TOFU, {\r\n id: CharCode.TOFU,\r\n x: 0,\r\n y: 0,\r\n width: this._font.info.size,\r\n height: this._font.info.size,\r\n xoffset: 0,\r\n yoffset: 0,\r\n xadvance: this._font.info.size * 0.5,\r\n page: -1,\r\n chnl: -1,\r\n index: -1,\r\n char: \"￿\",\r\n });\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _getChar(charCode: number) {\r\n return this._chars.get(charCode) || this._chars.get(CharCode.TOFU)!;\r\n }\r\n\r\n /** @internal */\r\n public _getKerning(first: number, second: number) {\r\n return this._kernings.get(first)?.get(second) || 0;\r\n }\r\n\r\n /** @internal */\r\n public _unsupportedChars(text: string) {\r\n return text.replace(this._charsRegex, \"\");\r\n }\r\n}\r\n","import type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport type { Behavior } from \"core/Behaviors/behavior\";\r\nimport type { Scene } from \"core/scene\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { requestCapture, requestRelease, releaseCurrent, getCapturingId } from \"./pointerEventsCapture\";\r\n\r\n// Module level variable for holding the current scene\r\nlet LocalScene: Scene | null = null;\r\n\r\n// Module level variable to hold the count of behavior instances that are currently capturing pointer events\r\n// on entry. This is used to determine if we need to start or stop observing pointer movement.\r\nlet CaptureOnEnterCount = 0;\r\n\r\n// Map used to store instance of the PointerEventsCaptureBehavior for a mesh\r\n// We do this because this gets checked on pointer move and we don't want to\r\n// use getBehaviorByName() because that is a linear search\r\nconst MeshToBehaviorMap = new WeakMap<AbstractMesh, PointerEventsCaptureBehavior>();\r\n\r\nconst StartCaptureOnEnter = (scene: Scene) => {\r\n // If we are not in a browser, do nothing\r\n if (typeof document === \"undefined\") {\r\n return;\r\n }\r\n if (CaptureOnEnterCount === 0) {\r\n document.addEventListener(\"pointermove\", OnPointerMove);\r\n document.addEventListener(\"touchstart\", OnPointerMove);\r\n LocalScene = LocalScene ?? scene;\r\n Logger.Log(\"PointerEventsCaptureBehavior: Starting observation of pointer move events.\");\r\n LocalScene.onDisposeObservable.add(DoStopCaptureOnEnter);\r\n }\r\n CaptureOnEnterCount++;\r\n};\r\n\r\nconst DoStopCaptureOnEnter = () => {\r\n document.removeEventListener(\"pointermove\", OnPointerMove);\r\n document.removeEventListener(\"touchstart\", OnPointerMove);\r\n LocalScene = null;\r\n Logger.Log(\"PointerEventsCaptureBehavior: Stopping observation of pointer move events.\");\r\n CaptureOnEnterCount = 0;\r\n};\r\n\r\nconst StopCaptureOnEnter = () => {\r\n // If we are not in a browser, do nothing\r\n if (typeof document === \"undefined\") {\r\n return;\r\n }\r\n\r\n // If we are not observing pointer movement, do nothing\r\n if (!LocalScene) {\r\n return;\r\n }\r\n\r\n CaptureOnEnterCount--;\r\n if (CaptureOnEnterCount <= 0) {\r\n DoStopCaptureOnEnter();\r\n }\r\n};\r\n\r\n// Module level function used to determine if an entered mesh should capture pointer events\r\nconst OnPointerMove = (evt: PointerEvent | TouchEvent) => {\r\n if (!LocalScene) {\r\n return;\r\n }\r\n\r\n const canvasRect = LocalScene.getEngine().getRenderingCanvasClientRect();\r\n if (!canvasRect) {\r\n return;\r\n }\r\n\r\n // Get the object that contains the client X and Y from either the pointer event or from the\r\n // TouchEvent touch\r\n const { clientX, clientY } = \"touches\" in evt ? evt.touches[0] : evt;\r\n\r\n // get the picked mesh, if any\r\n const pointerScreenX = clientX - canvasRect.left;\r\n const pointerScreenY = clientY - canvasRect.top;\r\n\r\n let pointerCaptureBehavior: PointerEventsCaptureBehavior | undefined;\r\n const pickResult = LocalScene.pick(pointerScreenX, pointerScreenY, (mesh) => {\r\n // If the mesh has an instance of PointerEventsCaptureBehavior attached to it,\r\n // and capture on pointer enter is true, then we want to pick it\r\n const pointerCaptureBehavior = MeshToBehaviorMap.get(mesh);\r\n return mesh.isEnabled() && typeof pointerCaptureBehavior !== \"undefined\" && pointerCaptureBehavior._captureOnPointerEnter;\r\n });\r\n\r\n let pickedMesh: AbstractMesh | null;\r\n if (pickResult.hit) {\r\n pickedMesh = pickResult.pickedMesh;\r\n } else {\r\n pickedMesh = null;\r\n }\r\n\r\n const capturingIdAsInt = parseInt(getCapturingId() || \"\");\r\n\r\n // if the picked mesh is the current capturing mesh, do nothing\r\n if (pickedMesh && pickedMesh.uniqueId === capturingIdAsInt) {\r\n return;\r\n }\r\n\r\n // If there is a capturing mesh and it is not the current picked mesh, or no\r\n // mesh is picked, release the capturing mesh\r\n if (capturingIdAsInt && (!pickedMesh || pickedMesh.uniqueId !== capturingIdAsInt)) {\r\n releaseCurrent();\r\n }\r\n\r\n // If there is a picked mesh and it is not the current capturing mesh, capture\r\n // the pointer events. Note that the current capturing mesh has already been\r\n // released above\r\n if (pickedMesh) {\r\n pointerCaptureBehavior = MeshToBehaviorMap.get(pickedMesh);\r\n pointerCaptureBehavior!.capturePointerEvents();\r\n }\r\n};\r\n\r\n/**\r\n * Behavior for any content that can capture pointer events, i.e. bypass the Babylon pointer event handling\r\n * and receive pointer events directly. It will register the capture triggers and negotiate the capture and\r\n * release of pointer events. Curerntly this applies only to HtmlMesh\r\n */\r\nexport class PointerEventsCaptureBehavior implements Behavior<AbstractMesh> {\r\n /** gets or sets behavior's name */\r\n public name = \"PointerEventsCaptureBehavior\";\r\n\r\n private _attachedMesh: AbstractMesh | null;\r\n /** @internal */\r\n public _captureOnPointerEnter: boolean;\r\n\r\n /**\r\n * Gets or sets the mesh that the behavior is attached to\r\n */\r\n public get attachedMesh() {\r\n return this._attachedMesh;\r\n }\r\n\r\n public set attachedMesh(value: AbstractMesh | null) {\r\n this._attachedMesh = value;\r\n }\r\n\r\n constructor(\r\n private _captureCallback: () => void,\r\n private _releaseCallback: () => void,\r\n { captureOnPointerEnter = true } = {}\r\n ) {\r\n this._attachedMesh = null;\r\n this._captureOnPointerEnter = captureOnPointerEnter;\r\n\r\n // Warn if we are not in a browser\r\n if (typeof document === \"undefined\") {\r\n Logger.Warn(`Creating an instance of PointerEventsCaptureBehavior outside of a browser. The behavior will not work.`);\r\n }\r\n }\r\n\r\n /**\r\n * Set if the behavior should capture pointer events when the pointer enters the mesh\r\n */\r\n public set captureOnPointerEnter(captureOnPointerEnter: boolean) {\r\n if (this._captureOnPointerEnter === captureOnPointerEnter) {\r\n return;\r\n }\r\n this._captureOnPointerEnter = captureOnPointerEnter;\r\n if (this._attachedMesh) {\r\n if (this._captureOnPointerEnter) {\r\n StartCaptureOnEnter(this._attachedMesh.getScene());\r\n } else {\r\n StopCaptureOnEnter();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Function called when the behavior needs to be initialized (before attaching it to a target)\r\n */\r\n public init() {}\r\n\r\n /**\r\n * Called when the behavior is attached to a target\r\n * @param mesh defines the target where the behavior is attached to\r\n */\r\n public attach(mesh: AbstractMesh) {\r\n // Add a reference to this behavior on the mesh. We do this so we can get a\r\n // reference to the behavior in the onPointerMove function without relying on\r\n // getBehaviorByName(), which does a linear search of the behaviors array.\r\n this.attachedMesh = mesh;\r\n MeshToBehaviorMap.set(mesh, this);\r\n if (this._captureOnPointerEnter) {\r\n StartCaptureOnEnter(mesh.getScene());\r\n }\r\n }\r\n\r\n /**\r\n * Called when the behavior is detached from its target\r\n */\r\n public detach() {\r\n if (!this.attachedMesh) {\r\n return;\r\n }\r\n // Remove the reference to this behavior from the mesh\r\n MeshToBehaviorMap.delete(this.attachedMesh);\r\n if (this._captureOnPointerEnter) {\r\n StopCaptureOnEnter();\r\n }\r\n this.attachedMesh = null;\r\n }\r\n\r\n /**\r\n * Dispose the behavior\r\n */\r\n public dispose() {\r\n this.detach();\r\n }\r\n\r\n // Release pointer events\r\n public releasePointerEvents() {\r\n if (!this.attachedMesh) {\r\n return;\r\n }\r\n requestRelease(this.attachedMesh.uniqueId.toString());\r\n }\r\n\r\n // Capture pointer events\r\n public capturePointerEvents() {\r\n if (!this.attachedMesh) {\r\n return;\r\n }\r\n requestCapture(this.attachedMesh.uniqueId.toString(), this._captureCallback, this._releaseCallback);\r\n }\r\n}\r\n","export type FitStrategyType = {\r\n wrapElement(element: HTMLElement): HTMLElement;\r\n updateSize(sizingElement: HTMLElement, width: number, height: number): void;\r\n};\r\n\r\nconst FitStrategyContain: FitStrategyType = {\r\n wrapElement(element: HTMLElement): HTMLElement {\r\n const sizingElement = document.createElement(\"div\");\r\n sizingElement.style.display = \"flex\";\r\n sizingElement.style.justifyContent = \"center\";\r\n sizingElement.style.alignItems = \"center\";\r\n const scalingElement = document.createElement(\"div\");\r\n scalingElement.style.visibility = \"hidden\";\r\n scalingElement.appendChild(element);\r\n sizingElement.appendChild(scalingElement);\r\n return sizingElement;\r\n },\r\n updateSize(sizingElement: HTMLElement, width: number, height: number) {\r\n const scalingElement = sizingElement.firstElementChild! as HTMLElement;\r\n sizingElement.style.width = `${width}px`;\r\n sizingElement.style.height = `${height}px`;\r\n\r\n const [childWidth, childHeight] = [scalingElement.offsetWidth, scalingElement.offsetHeight];\r\n const scale = Math.min(width / childWidth, height / childHeight);\r\n scalingElement.style.transform = `scale(${scale})`;\r\n scalingElement.style.visibility = \"visible\";\r\n },\r\n};\r\n\r\nconst FitStrategyCover: FitStrategyType = {\r\n wrapElement(element: HTMLElement): HTMLElement {\r\n const sizingElement = document.createElement(\"div\");\r\n sizingElement.style.display = \"flex\";\r\n sizingElement.style.justifyContent = \"center\";\r\n sizingElement.style.alignItems = \"center\";\r\n sizingElement.style.overflow = \"hidden\";\r\n const scalingElement = document.createElement(\"div\");\r\n scalingElement.style.visibility = \"hidden\";\r\n scalingElement.appendChild(element);\r\n sizingElement.appendChild(scalingElement);\r\n return sizingElement;\r\n },\r\n updateSize(sizingElement: HTMLElement, width: number, height: number) {\r\n const scalingElement = sizingElement.firstElementChild! as HTMLElement;\r\n sizingElement.style.width = `${width}px`;\r\n sizingElement.style.height = `${height}px`;\r\n\r\n const [childWidth, childHeight] = [scalingElement.offsetWidth, scalingElement.offsetHeight];\r\n const scale = Math.max(width / childWidth, height / childHeight);\r\n scalingElement.style.transform = `scale(${scale})`;\r\n scalingElement.style.visibility = \"visible\";\r\n },\r\n};\r\n\r\nconst FitStrategyStretch: FitStrategyType = {\r\n wrapElement(element: HTMLElement): HTMLElement {\r\n const sizingElement = document.createElement(\"div\");\r\n sizingElement.style.display = \"flex\";\r\n sizingElement.style.justifyContent = \"center\";\r\n sizingElement.style.alignItems = \"center\";\r\n const scalingElement = document.createElement(\"div\");\r\n scalingElement.style.visibility = \"hidden\";\r\n scalingElement.appendChild(element);\r\n sizingElement.appendChild(scalingElement);\r\n return sizingElement;\r\n },\r\n updateSize(sizingElement: HTMLElement, width: number, height: number) {\r\n const scalingElement = sizingElement.firstElementChild! as HTMLElement;\r\n sizingElement.style.width = `${width}px`;\r\n sizingElement.style.height = `${height}px`;\r\n\r\n const [childWidth, childHeight] = [scalingElement.offsetWidth, scalingElement.offsetHeight];\r\n scalingElement.style.transform = `scale(${width / childWidth}, ${height / childHeight})`;\r\n scalingElement.style.visibility = \"visible\";\r\n },\r\n};\r\n\r\nconst FitStrategyNone: FitStrategyType = {\r\n wrapElement(element: HTMLElement): HTMLElement {\r\n return element;\r\n },\r\n updateSize(sizingElement: HTMLElement, width: number, height: number) {\r\n if (sizingElement) {\r\n sizingElement.style.width = `${width}px`;\r\n sizingElement.style.height = `${height}px`;\r\n }\r\n },\r\n};\r\n\r\nexport const FitStrategy = {\r\n CONTAIN: FitStrategyContain,\r\n COVER: FitStrategyCover,\r\n STRETCH: FitStrategyStretch,\r\n NONE: FitStrategyNone,\r\n};\r\n","import { Mesh } from \"core/Meshes/mesh\";\r\nimport { CreatePlaneVertexData } from \"core/Meshes/Builders/planeBuilder\";\r\nimport { StandardMaterial } from \"core/Materials/standardMaterial\";\r\nimport { Matrix } from \"core/Maths/math\";\r\nimport { PointerEventsCaptureBehavior } from \"./pointerEventsCaptureBehavior\";\r\nimport type { Scene } from \"core/scene\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport type { FitStrategyType } from \"./fitStrategy\";\r\nimport { FitStrategy } from \"./fitStrategy\";\r\n\r\n/**\r\n * This class represents HTML content that we want to render as though it is part of the scene. The HTML content is actually\r\n * rendered below the canvas, but a depth mask is created by this class that writes to the depth buffer but does not\r\n * write to the color buffer, effectively punching a hole in the canvas. CSS transforms are used to scale, translate, and rotate\r\n * the HTML content so that it matches the camera and mesh orientation. The class supports interactions in editable and non-editable mode.\r\n * In non-editable mode (the default), events are passed to the HTML content when the pointer is over the mask (and not occluded by other meshes\r\n * in the scene).\r\n * @see https://playground.babylonjs.com/#HVHYJC#5\r\n * @see https://playground.babylonjs.com/#B17TC7#112\r\n */\r\nexport class HtmlMesh extends Mesh {\r\n /**\r\n * Helps identifying a html mesh from a regular mesh\r\n */\r\n public get isHtmlMesh() {\r\n return true;\r\n }\r\n\r\n // Override the super class's _isEnabled property so we can control when the mesh\r\n // is enabled. I.e., we don't want to render the mesh until there is content to show.\r\n private _enabled = false;\r\n\r\n // The mesh is ready when content has been set and the content size has been set\r\n // The former is done by the user, the latter is done by the renderer.\r\n private _ready = false;\r\n\r\n /**\r\n * @internal\r\n */\r\n public _isCanvasOverlay = false;\r\n\r\n private _requiresUpdate = true;\r\n\r\n private _element?: HTMLElement;\r\n private _width?: number;\r\n private _height?: number;\r\n\r\n private _inverseScaleMatrix: Matrix | null = null;\r\n\r\n private _captureOnPointerEnter: boolean = true;\r\n private _pointerEventCaptureBehavior: PointerEventsCaptureBehavior | null = null;\r\n\r\n private _sourceWidth: number | null = null;\r\n private _sourceHeight: number | null = null;\r\n\r\n /**\r\n * Return the source width of the content in pixels\r\n */\r\n public get sourceWidth() {\r\n return this._sourceWidth;\r\n }\r\n\r\n /**\r\n * Return the source height of the content in pixels\r\n */\r\n public get sourceHeight() {\r\n return this._sourceHeight;\r\n }\r\n\r\n private _worldMatrixUpdateObserver: any;\r\n\r\n private _fitStrategy: FitStrategyType = FitStrategy.NONE;\r\n\r\n /**\r\n * Contruct an instance of HtmlMesh\r\n * @param scene\r\n * @param id The id of the mesh. Will be used as the id of the HTML element as well.\r\n * @param options object with optional parameters\r\n */\r\n constructor(scene: Scene, id: string, { captureOnPointerEnter = true, isCanvasOverlay = false, fitStrategy = FitStrategy.NONE } = {}) {\r\n super(id, scene);\r\n\r\n // Requires a browser to work. Bail if we aren't running in a browser\r\n if (typeof document === \"undefined\") {\r\n Logger.Warn(`Creating an instance of an HtmlMesh with id ${id} outside of a browser. The mesh will not be visible.`);\r\n return;\r\n }\r\n\r\n this._fitStrategy = fitStrategy;\r\n this._isCanvasOverlay = isCanvasOverlay;\r\n this._createMask();\r\n this._element = this._createElement();\r\n\r\n // Set enabled by default, so this will show as soon as it's ready\r\n this.setEnabled(true);\r\n\r\n this._captureOnPointerEnter = captureOnPointerEnter;\r\n\r\n // Create a behavior to capture pointer events\r\n this._pointerEventCaptureBehavior = new PointerEventsCaptureBehavior(this.capturePointerEvents.bind(this), this.releasePointerEvents.bind(this), {\r\n captureOnPointerEnter: this._captureOnPointerEnter,\r\n });\r\n this.addBehavior(this._pointerEventCaptureBehavior);\r\n }\r\n\r\n /**\r\n * The width of the content in pixels\r\n */\r\n public get width() {\r\n return this._width;\r\n }\r\n\r\n /**\r\n * The height of the content in pixels\r\n */\r\n public get height() {\r\n return this._height;\r\n }\r\n\r\n /**\r\n * The HTML element that is being rendered as a mesh\r\n */\r\n public get element() {\r\n return this._element;\r\n }\r\n\r\n /**\r\n * True if the mesh has been moved, rotated, or scaled since the last time this\r\n * property was read. This property is reset to false after reading.\r\n */\r\n public get requiresUpdate() {\r\n return this._requiresUpdate;\r\n }\r\n\r\n /**\r\n * Enable capture for the pointer when entering the mesh area\r\n */\r\n public set captureOnPointerEnter(captureOnPointerEnter: boolean) {\r\n this._captureOnPointerEnter = captureOnPointerEnter;\r\n if (this._pointerEventCaptureBehavior) {\r\n this._pointerEventCaptureBehavior.captureOnPointerEnter = captureOnPointerEnter;\r\n }\r\n }\r\n\r\n /**\r\n * Disposes of the mesh and the HTML element\r\n */\r\n public override dispose() {\r\n super.dispose();\r\n this._element?.remove();\r\n this._element = undefined;\r\n if (this._pointerEventCaptureBehavior) {\r\n this._pointerEventCaptureBehavior.dispose();\r\n this._pointerEventCaptureBehavior = null;\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _markAsUpdated() {\r\n this._requiresUpdate = false;\r\n }\r\n\r\n /**\r\n * Sets the content of the element to the specified content adjusting the mesh scale to match and making it visible.\r\n * If the the specified content is undefined, then it will make the mesh invisible. In either case it will clear the\r\n * element content first.\r\n * @param element The element to render as a mesh\r\n * @param width The width of the mesh in Babylon units\r\n * @param height The height of the mesh in Babylon units\r\n */\r\n setContent(element: HTMLElement, width: number, height: number) {\r\n // If content is changed, we are no longer ready\r\n this._setAsReady(false);\r\n\r\n // Also invalidate the source width and height\r\n this._sourceWidth = null;\r\n this._sourceHeight = null;\r\n\r\n if (!this._element) {\r\n return;\r\n }\r\n\r\n this._width = width;\r\n this._height = height;\r\n this._requiresUpdate = true;\r\n\r\n this.scaling.setAll(1);\r\n\r\n if (element) {\r\n this._element.appendChild(this._fitStrategy.wrapElement(element));\r\n\r\n this._updateScaleIfNecessary();\r\n }\r\n\r\n if (this.sourceWidth && this.sourceHeight) {\r\n this._setAsReady(true);\r\n }\r\n }\r\n\r\n // Overides BABYLON.Mesh.setEnabled\r\n public override setEnabled(enabled: boolean) {\r\n // Capture requested enabled state\r\n this._enabled = enabled;\r\n\r\n // If disabling or enabling and we are ready\r\n if (!enabled || this._ready) {\r\n this._doSetEnabled(enabled);\r\n }\r\n }\r\n\r\n /**\r\n * Sets the content size in pixels\r\n * @param width width of the source\r\n * @param height height of the source\r\n */\r\n public setContentSizePx(width: number, height: number) {\r\n this._sourceWidth = width;\r\n this._sourceHeight = height;\r\n\r\n if (!this._element || !this._element.firstElementChild) {\r\n return;\r\n }\r\n\r\n this._fitStrategy.updateSize(this._element.firstElementChild as HTMLElement, width, height);\r\n\r\n this._updateScaleIfNecessary();\r\n\r\n if (this.width && this.height) {\r\n this._setAsReady(true);\r\n }\r\n }\r\n\r\n protected _setAsReady(ready: boolean) {\r\n this._ready = ready;\r\n if (ready) {\r\n this._doSetEnabled(this._enabled);\r\n } else {\r\n this._doSetEnabled(false);\r\n }\r\n }\r\n\r\n protected _doSetEnabled(enabled: boolean) {\r\n if (!this._element) {\r\n return;\r\n }\r\n\r\n //if enabled, then start listening for changes to the\r\n // scaling, rotation, and position. otherwise stop listening\r\n if (enabled && !this._worldMatrixUpdateObserver) {\r\n this._worldMatrixUpdateObserver = this.onAfterWorldMatrixUpdateObservable.add(() => {\r\n this._requiresUpdate = true;\r\n });\r\n } else if (!enabled) {\r\n this._worldMatrixUpdateObserver?.remove();\r\n this._worldMatrixUpdateObserver = null;\r\n }\r\n\r\n // If enabled, then revert the content element display\r\n // otherwise hide it\r\n this._element.style.display = enabled ? \"\" : \"none\";\r\n // Capture the content z index\r\n this._setElementzIndex(this.position.z * -10000);\r\n super.setEnabled(enabled);\r\n }\r\n\r\n protected _updateScaleIfNecessary() {\r\n // If we have setContent before, the content scale is baked into the mesh. If we don't reset the vertices to\r\n // the original size, then we will multiply the scale when we bake the scale below. By applying the inverse, we back out\r\n // the scaling that has been done so we are starting from the same point.\r\n // First reset the scale to 1\r\n this.scaling.setAll(1);\r\n // Then back out the original vertices changes to match the content scale\r\n if (this._inverseScaleMatrix) {\r\n this.bakeTransformIntoVertices(this._inverseScaleMatrix);\r\n // Clear out the matrix so it doesn't get applied again unless we scale\r\n this._inverseScaleMatrix = null;\r\n }\r\n\r\n // Set scale to match content. Note we can't just scale the mesh, because that will scale the content as well\r\n // What we need to do is compute a scale matrix and then bake that into the mesh vertices. This will leave the\r\n // mesh scale at 1, so our content will stay it's original width and height until we scale the mesh.\r\n const scaleX = this._width || 1;\r\n const scaleY = this._height || 1;\r\n const scaleMatrix = Matrix.Scaling(scaleX, scaleY, 1);\r\n this.bakeTransformIntoVertices(scaleMatrix);\r\n\r\n // Get an inverse of the scale matrix that we can use to back out the scale changes we have made so\r\n // we don't multiply the scale.\r\n this._inverseScaleMatrix = new Matrix();\r\n scaleMatrix.invertToRef(this._inverseScaleMatrix);\r\n }\r\n\r\n protected _createMask() {\r\n const vertexData = CreatePlaneVertexData({ width: 1, height: 1 });\r\n vertexData.applyToMesh(this);\r\n\r\n const scene = this.getScene();\r\n this.checkCollisions = true;\r\n\r\n const depthMask = new StandardMaterial(`${this.id}-mat`, scene);\r\n if (!this._isCanvasOverlay) {\r\n depthMask.backFaceCulling = false;\r\n depthMask.disableColorWrite = true;\r\n depthMask.disableLighting = true;\r\n }\r\n\r\n this.material = depthMask;\r\n\r\n // Optimization - Freeze material since it never needs to change\r\n this.material.freeze();\r\n }\r\n\r\n protected _setElementzIndex(zIndex: number) {\r\n if (this._element) {\r\n this._element.style.zIndex = `${zIndex}`;\r\n }\r\n }\r\n\r\n /**\r\n * Callback used by the PointerEventsCaptureBehavior to capture pointer events\r\n */\r\n capturePointerEvents() {\r\n if (!this._element) {\r\n return;\r\n }\r\n\r\n // Enable dom content to capture pointer events\r\n this._element.style.pointerEvents = \"auto\";\r\n\r\n // Supress events outside of the dom content\r\n document.getElementsByTagName(\"body\")[0].style.pointerEvents = \"none\";\r\n }\r\n\r\n /**\r\n * Callback used by the PointerEventsCaptureBehavior to release pointer events\r\n */\r\n releasePointerEvents() {\r\n if (!this._element) {\r\n return;\r\n }\r\n\r\n // Enable pointer events on canvas\r\n document.getElementsByTagName(\"body\")[0].style.pointerEvents = \"auto\";\r\n\r\n // Disable pointer events on dom content\r\n this._element.style.pointerEvents = \"none\";\r\n }\r\n\r\n protected _createElement() {\r\n // Requires a browser to work. Bail if we aren't running in a browser\r\n if (typeof document === \"undefined\") {\r\n return;\r\n }\r\n const div = document.createElement(\"div\");\r\n div.id = this.id;\r\n div.style.backgroundColor = this._isCanvasOverlay ? \"transparent\" : \"#000\";\r\n div.style.zIndex = \"1\";\r\n div.style.position = \"absolute\";\r\n div.style.pointerEvents = \"none\";\r\n div.style.backfaceVisibility = \"hidden\";\r\n\r\n return div;\r\n }\r\n}\r\n","/* eslint-disable jsdoc/require-jsdoc */\r\n\r\nimport type { IVector2Like } from \"core/Maths\";\r\n\r\n/** @internal */\r\nexport type ParagraphOptions = {\r\n maxWidth: number;\r\n lineHeight: number;\r\n letterSpacing: number;\r\n tabSize: number;\r\n whiteSpace: /* 'normal' | 'nowrap' | 'pre' | 'pre-wrap' | */ \"pre-line\" /* | 'break-spaces'*/;\r\n textAlign: \"left\" | \"right\" | \"center\" /* | 'justify'*/;\r\n translate: IVector2Like | undefined;\r\n};\r\n\r\n/** @internal */\r\nexport const DefaultParagraphOptions: ParagraphOptions = {\r\n maxWidth: Infinity,\r\n lineHeight: 1,\r\n letterSpacing: 1,\r\n tabSize: 4,\r\n whiteSpace: \"pre-line\",\r\n textAlign: \"center\",\r\n translate: { x: -0.5, y: -0.5 },\r\n};\r\n","/* eslint-disable babylonjs/available */\r\n/* eslint-disable jsdoc/require-jsdoc */\r\nimport type { FontAsset } from \"../fontAsset\";\r\nimport { DefaultParagraphOptions, type ParagraphOptions } from \"../paragraphOptions\";\r\nimport type { BMFontChar } from \"./bmFont\";\r\nimport type { SdfGlyph } from \"./glyph\";\r\nimport type { SdfTextLine } from \"./line\";\r\n\r\n/** @internal */\r\nexport class SdfTextParagraph {\r\n public readonly options: ParagraphOptions;\r\n\r\n get lineHeight() {\r\n return this.fontAsset._font.common.lineHeight * this.options.lineHeight;\r\n }\r\n\r\n readonly paragraph;\r\n readonly lines;\r\n readonly width;\r\n readonly height;\r\n readonly glyphs;\r\n\r\n constructor(\r\n public readonly text: string,\r\n public readonly fontAsset: FontAsset,\r\n options?: Partial<ParagraphOptions>\r\n ) {\r\n this.options = { ...DefaultParagraphOptions, ...options };\r\n\r\n const { paragraph, lines, glyphs, width, height } = this._computeMetrics(text);\r\n\r\n this.paragraph = paragraph;\r\n this.lines = lines;\r\n this.glyphs = glyphs;\r\n this.width = width;\r\n this.height = height;\r\n }\r\n\r\n private _computeMetrics(text: string) {\r\n const collapsed = this._collapse(text);\r\n const breaked = this._breakLines(collapsed);\r\n const trimmed = breaked.map((line) => line.trim());\r\n\r\n const lines: SdfTextLine[] = [];\r\n for (const line of trimmed) {\r\n lines.push(...this._wrap(line, lines.length));\r\n }\r\n\r\n const width = Math.max(...lines.map((line) => line.width));\r\n const height = this.lineHeight * lines.length;\r\n\r\n if (this.options.textAlign !== \"left\" || this.options.translate) {\r\n lines.forEach((line) => {\r\n const anchor = (() => {\r\n switch (this.options.textAlign) {\r\n case \"right\":\r\n return width - line.width;\r\n case \"center\":\r\n return (width - line.width) / 2;\r\n case \"left\":\r\n default:\r\n return 0;\r\n }\r\n })();\r\n\r\n const x = this.options.translate ? this.options.translate.x * width : 0;\r\n const y = this.options.translate ? this.options.translate.y * height : 0;\r\n for (const glyph of line.glyphs) {\r\n glyph.x += anchor;\r\n glyph.x += x;\r\n glyph.y += y;\r\n }\r\n });\r\n }\r\n\r\n const glyphs = lines.flatMap((line) => line.glyphs);\r\n\r\n return {\r\n paragraph: trimmed.join(\"\\n\"),\r\n lines,\r\n glyphs,\r\n width,\r\n height,\r\n };\r\n }\r\n\r\n private _breakLines(text: string) {\r\n return text.split(\"\\n\");\r\n }\r\n\r\n private _collapse(text: string) {\r\n return text.replace(/\\t/g, \" \".repeat(this.options.tabSize)).replace(/ +/g, \" \");\r\n }\r\n\r\n private _wrap(text: string, lineOffset = 0) {\r\n const lines = new Array<SdfTextLine>();\r\n\r\n let currentLine = lineOffset;\r\n let currentGlyphs = new Array<SdfGlyph>();\r\n let currentCursor = 0;\r\n let currentWidth = 0;\r\n let lastChar: BMFontChar | undefined;\r\n let start = 0;\r\n let end = start;\r\n\r\n const pushCurrentLine = () => {\r\n lines.push({\r\n text: text.slice(start, end),\r\n glyphs: currentGlyphs,\r\n start: start,\r\n end: end,\r\n width: currentWidth,\r\n });\r\n };\r\n\r\n while (end < text.length) {\r\n const i = end;\r\n const charCode = text.charCodeAt(i);\r\n const char = this.fontAsset._getChar(charCode);\r\n const charWidth = char.width;\r\n const kerning = lastChar ? this.fontAsset._getKerning(lastChar.id, char.id) : 0;\r\n\r\n currentCursor += kerning;\r\n const newWidth = currentCursor + charWidth;\r\n const cursorProgress = char.xadvance + this.options.letterSpacing;\r\n const nextPosition = currentCursor + cursorProgress;\r\n\r\n const shouldBreak = nextPosition > this.options.maxWidth || newWidth > this.options.maxWidth;\r\n\r\n if (shouldBreak) {\r\n pushCurrentLine();\r\n\r\n currentLine++;\r\n lastChar = undefined;\r\n currentCursor = 0;\r\n currentWidth = 0;\r\n start = end;\r\n end = start + 1;\r\n currentGlyphs = [];\r\n }\r\n\r\n const x = currentCursor;\r\n const y = currentLine * this.lineHeight;\r\n\r\n currentGlyphs.push({\r\n char,\r\n line: currentLine,\r\n position: currentGlyphs.length,\r\n x: x,\r\n y: y,\r\n });\r\n\r\n if (!shouldBreak) {\r\n lastChar = char;\r\n currentCursor = nextPosition;\r\n currentWidth = newWidth;\r\n end++;\r\n } else {\r\n currentCursor = cursorProgress;\r\n }\r\n }\r\n\r\n if (currentGlyphs.length > 0) {\r\n if (lastChar) {\r\n // currentWidth += lastChar.xadvance;\r\n }\r\n pushCurrentLine();\r\n }\r\n\r\n return lines;\r\n }\r\n}\r\n","import type { VertexBuffer } from \"core/Buffers/buffer\";\r\nimport { Buffer } from \"core/Buffers/buffer\";\r\nimport type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport type { ThinEngine } from \"core/Engines/thinEngine\";\r\nimport { DrawWrapper } from \"core/Materials/drawWrapper\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\nimport type { IDisposable } from \"core/scene\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { SdfTextParagraph } from \"./sdf/paragraph\";\r\nimport type { FontAsset } from \"./fontAsset\";\r\nimport type { ParagraphOptions } from \"./paragraphOptions\";\r\nimport { ThinMatrix } from \"core/Maths/ThinMaths/thinMath.matrix\";\r\nimport {\r\n CopyMatrixToArray,\r\n CopyMatrixToRef,\r\n IdentityMatrixToRef,\r\n MultiplyMatricesToRef,\r\n ScalingMatrixToRef,\r\n TranslationMatrixToRef,\r\n} from \"core/Maths/ThinMaths/thinMath.matrix.functions\";\r\nimport type { IColor4Like, IMatrixLike } from \"core/Maths/math.like\";\r\n\r\n/**\r\n * Abstract Node class from Babylon.js\r\n */\r\nexport interface INodeLike {\r\n getWorldMatrix(): IMatrixLike;\r\n}\r\n\r\n/**\r\n * Class used to render text using MSDF (Multi-channel Signed Distance Field) technique\r\n * Thanks a lot to the work of Bhushan_Wagh and zb_sj for their amazing work on MSDF for Babylon.js\r\n * #6RLCWP#16\r\n * Star wars scroller: #6RLCWP#29\r\n * With metrics: #6RLCWP#35\r\n * Thickness: #IABMEZ#3\r\n * Solar system: #9YCDYC#9\r\n * Stroke: #6RLCWP#37\r\n */\r\nexport class TextRenderer implements IDisposable {\r\n private readonly _useVAO: boolean = false;\r\n private _engine: AbstractEngine;\r\n private _shaderLanguage: ShaderLanguage;\r\n private _vertexBuffers: { [key: string]: VertexBuffer } = {};\r\n private _spriteBuffer: Nullable<Buffer>;\r\n private _worldBuffer: Nullable<Buffer>;\r\n private _uvBuffer: Nullable<Buffer>;\r\n private _drawWrapperBase: DrawWrapper;\r\n private _vertexArrayObject: WebGLVertexArrayObject;\r\n private _font: FontAsset;\r\n private _charMatrices = new Array<number>();\r\n private _charUvs = new Array<number>();\r\n private _isDirty = true;\r\n private _baseLine = 0;\r\n\r\n // Cache\r\n private _scalingMatrix = new ThinMatrix();\r\n private _fontScaleMatrix = new ThinMatrix();\r\n private _offsetMatrix = new ThinMatrix();\r\n private _translationMatrix = new ThinMatrix();\r\n private _baseMatrix = new ThinMatrix();\r\n private _scaledMatrix = new ThinMatrix();\r\n private _localMatrix = new ThinMatrix();\r\n private _finalMatrix = new ThinMatrix();\r\n private _lineMatrix = new ThinMatrix();\r\n private _parentWorldMatrix = new ThinMatrix();\r\n\r\n /**\r\n * Gets or sets the color of the text\r\n */\r\n public color: IColor4Like = { r: 1.0, g: 1.0, b: 1.0, a: 1.0 };\r\n\r\n /**\r\n * Gets or sets the color of the stroke around the text\r\n */\r\n public strokeColor: IColor4Like = { r: 1.0, g: 1.0, b: 1.0, a: 1.0 };\r\n\r\n /**\r\n * Gets or sets the width of the stroke around the text (inset)\r\n */\r\n public strokeInsetWidth = 0;\r\n\r\n /**\r\n * Gets or sets the width of the stroke around the text (outset)\r\n */\r\n public strokeOutsetWidth = 0;\r\n\r\n /**\r\n * Gets or sets the thickness of the text (0 means as defined in the font)\r\n * Value must be between -0.5 and 0.5\r\n */\r\n public thicknessControl = 0;\r\n\r\n private _parent: Nullable<INodeLike> = null;\r\n\r\n /**\r\n * Gets or sets the parent of the text renderer\r\n */\r\n public get parent(): Nullable<INodeLike> {\r\n return this._parent;\r\n }\r\n\r\n public set parent(value: Nullable<INodeLike>) {\r\n this._parent = value;\r\n }\r\n\r\n private _transformMatrix: IMatrixLike = new ThinMatrix();\r\n\r\n /**\r\n * Gets or sets the transform matrix of the text renderer\r\n * It will be applied in that order:\r\n * parent x transform x paragraph world\r\n */\r\n public get transformMatrix(): IMatrixLike {\r\n return this._transformMatrix;\r\n }\r\n\r\n public set transformMatrix(value: IMatrixLike) {\r\n this._transformMatrix = value;\r\n }\r\n\r\n /**\r\n * Gets or sets if the text is billboarded\r\n */\r\n public isBillboard = false;\r\n\r\n /**\r\n * Gets or sets if the text is screen projected\r\n * This will work only if the text is billboarded\r\n */\r\n public isBillboardScreenProjected = false;\r\n\r\n /**\r\n * Gets the number of characters in the text renderer\r\n */\r\n public get characterCount(): number {\r\n return this._charMatrices.length / 16;\r\n }\r\n\r\n /**\r\n * Gets or sets if the text renderer should ignore the depth buffer\r\n * Default is false\r\n */\r\n public ignoreDepthBuffer = false;\r\n\r\n private constructor(engine: AbstractEngine, shaderLanguage: ShaderLanguage = ShaderLanguage.GLSL, font: FontAsset) {\r\n this._engine = engine;\r\n this._shaderLanguage = shaderLanguage;\r\n this._font = font;\r\n this._baseLine = font._font.common.lineHeight * font.scale;\r\n\r\n this._useVAO = engine.getCaps().vertexArrayObject && !engine.disableVertexArrayObjects;\r\n\r\n // Main vertex buffer\r\n const spriteData = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]);\r\n this._spriteBuffer = new Buffer(engine, spriteData, false, 2);\r\n this._vertexBuffers[\"offsets\"] = this._spriteBuffer.createVertexBuffer(\"offsets\", 0, 2);\r\n\r\n // Instances\r\n this._resizeBuffers(128);\r\n }\r\n\r\n private _resizeBuffers(capacity: number) {\r\n if (this._worldBuffer) {\r\n this._worldBuffer.dispose();\r\n this._worldBuffer = null;\r\n }\r\n\r\n if (this._uvBuffer) {\r\n this._uvBuffer.dispose();\r\n this._uvBuffer = null;\r\n }\r\n\r\n this._worldBuffer = new Buffer(this._engine, new Float32Array(capacity * 16), true, 16);\r\n this._vertexBuffers[\"world0\"] = this._worldBuffer.createVertexBuffer(\"world0\", 0, 4, 16, true);\r\n this._vertexBuffers[\"world1\"] = this._worldBuffer.createVertexBuffer(\"world1\", 4, 4, 16, true);\r\n this._vertexBuffers[\"world2\"] = this._worldBuffer.createVertexBuffer(\"world2\", 8, 4, 16, true);\r\n this._vertexBuffers[\"world3\"] = this._worldBuffer.createVertexBuffer(\"world3\", 12, 4, 16, true);\r\n\r\n this._uvBuffer = new Buffer(this._engine, new Float32Array(capacity * 4), true, 4);\r\n this._vertexBuffers[\"uvs\"] = this._uvBuffer.createVertexBuffer(\"uvs\", 0, 4, 4, true);\r\n }\r\n\r\n private _setShaders(vertex: string, fragment: string) {\r\n this._drawWrapperBase?.dispose();\r\n\r\n this._drawWrapperBase = new DrawWrapper(this._engine);\r\n\r\n if (this._drawWrapperBase.drawContext) {\r\n this._drawWrapperBase.drawContext.useInstancing = true;\r\n }\r\n\r\n const defines = \"\";\r\n\r\n this._drawWrapperBase.effect = this._engine.createEffect(\r\n {\r\n vertexSource: vertex,\r\n fragmentSource: fragment,\r\n },\r\n [\"offsets\", \"world0\", \"world1\", \"world2\", \"world3\", \"uvs\"],\r\n [\"parentWorld\", \"view\", \"projection\", \"uColor\", \"thickness\", \"uStrokeColor\", \"uStrokeInsetWidth\", \"uStrokeOutsetWidth\", \"mode\", \"transform\"],\r\n [\"fontAtlas\"],\r\n defines,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n this._shaderLanguage\r\n );\r\n\r\n this._drawWrapperBase.effect._refCount++;\r\n }\r\n\r\n /**\r\n * Add a paragraph of text to the renderer\r\n * @param text define the text to add\r\n * @param options define the options to use for the paragraph (optional)\r\n * @param worldMatrix define the world matrix to use for the paragraph (optional)\r\n */\r\n public addParagraph(text: string, options?: Partial<ParagraphOptions>, worldMatrix?: IMatrixLike) {\r\n const paragraph = new SdfTextParagraph(text, this._font, options);\r\n\r\n const fontScale = this._font.scale;\r\n\r\n const texWidth = this._font._font.common.scaleW;\r\n const texHeight = this._font._font.common.scaleH;\r\n const glyphs = paragraph.glyphs.filter((g) => g.char.page >= 0);\r\n\r\n let worldMatrixToUse = worldMatrix;\r\n\r\n if (!worldMatrixToUse) {\r\n const lineHeight = paragraph.lineHeight * fontScale;\r\n const lineOffset = (paragraph.lines.length * lineHeight) / 2;\r\n TranslationMatrixToRef(0, this._baseLine - lineOffset, 0, this._lineMatrix);\r\n worldMatrixToUse = this._lineMatrix;\r\n }\r\n\r\n ScalingMatrixToRef(fontScale, fontScale, 1.0, this._fontScaleMatrix);\r\n TranslationMatrixToRef(0.5, -0.5, 0, this._offsetMatrix);\r\n\r\n const charsUvsBase = this._charUvs.length;\r\n const matricesBase = this._charMatrices.length;\r\n glyphs.forEach((g, i) => {\r\n this._charUvs[charsUvsBase + i * 4 + 0] = g.char.x / texWidth;\r\n this._charUvs[charsUvsBase + i * 4 + 1] = g.char.y / texHeight;\r\n this._charUvs[charsUvsBase + i * 4 + 2] = g.char.width / texWidth;\r\n this._charUvs[charsUvsBase + i * 4 + 3] = g.char.height / texHeight;\r\n\r\n const x = g.x + g.char.xoffset;\r\n const y = 1.0 - (g.y + g.char.yoffset);\r\n\r\n ScalingMatrixToRef(g.char.width, g.char.height, 1.0, this._scalingMatrix);\r\n MultiplyMatricesToRef(this._offsetMatrix, this._scalingMatrix, this._baseMatrix);\r\n\r\n TranslationMatrixToRef(x * fontScale, y * fontScale, 0.0, this._translationMatrix);\r\n MultiplyMatricesToRef(this._baseMatrix, this._fontScaleMatrix, this._scaledMatrix);\r\n MultiplyMatricesToRef(this._scaledMatrix, this._translationMatrix, this._localMatrix);\r\n\r\n MultiplyMatricesToRef(this._localMatrix, worldMatrixToUse, this._finalMatrix);\r\n CopyMatrixToArray(this._finalMatrix, this._charMatrices, matricesBase + i * 16);\r\n });\r\n\r\n this._isDirty = true;\r\n\r\n this._baseLine -= paragraph.lineHeight * fontScale * paragraph.lines.length;\r\n }\r\n\r\n /**\r\n * Render the text using the provided view and projection matrices\r\n * @param viewMatrix define the view matrix to use\r\n * @param projectionMatrix define the projection matrix to use\r\n */\r\n public render(viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike): void {\r\n const drawWrapper = this._drawWrapperBase;\r\n\r\n const effect = drawWrapper.effect!;\r\n\r\n // Check\r\n if (!effect.isReady()) {\r\n return;\r\n }\r\n const engine = this._engine;\r\n\r\n engine.setState(false);\r\n engine.enableEffect(drawWrapper);\r\n\r\n if (this.ignoreDepthBuffer) {\r\n engine.setDepthBuffer(false);\r\n }\r\n\r\n if (this._parent) {\r\n CopyMatrixToRef(this._parent.getWorldMatrix(), this._parentWorldMatrix);\r\n } else {\r\n IdentityMatrixToRef(this._parentWorldMatrix);\r\n }\r\n\r\n effect.setInt(\"mode\", this.isBillboard ? (this.isBillboardScreenProjected ? 2 : 1) : 0);\r\n effect.setMatrix(\"parentWorld\", this._parentWorldMatrix);\r\n effect.setMatrix(\"view\", viewMatrix);\r\n effect.setMatrix(\"projection\", projectionMatrix);\r\n effect.setMatrix(\"transform\", this.transformMatrix);\r\n\r\n // Texture\r\n effect.setTexture(\"fontAtlas\", this._font.textures[0]);\r\n effect.setDirectColor4(\"uColor\", this.color);\r\n effect.setDirectColor4(\"uStrokeColor\", this.strokeColor);\r\n effect.setFloat(\"thickness\", this.thicknessControl * 0.9);\r\n effect.setFloat(\"uStrokeInsetWidth\", this.strokeInsetWidth);\r\n effect.setFloat(\"uStrokeOutsetWidth\", this.strokeOutsetWidth);\r\n\r\n const instanceCount = this._charMatrices.length / 16;\r\n\r\n // Need update?\r\n if (this._isDirty) {\r\n this._isDirty = false;\r\n\r\n if (this._worldBuffer!.getBuffer()!.capacity / 4 < instanceCount * 16) {\r\n this._resizeBuffers(instanceCount);\r\n }\r\n\r\n this._worldBuffer!.update(this._charMatrices);\r\n this._uvBuffer!.update(this._charUvs);\r\n }\r\n\r\n if (this._useVAO) {\r\n if (!this._vertexArrayObject) {\r\n this._vertexArrayObject = (engine as ThinEngine).recordVertexArrayObject(this._vertexBuffers, null, effect);\r\n }\r\n (engine as ThinEngine).bindVertexArrayObject(this._vertexArrayObject, null);\r\n } else {\r\n // VBOs\r\n engine.bindBuffers(this._vertexBuffers, null, effect);\r\n }\r\n\r\n engine.setAlphaMode(Constants.ALPHA_COMBINE);\r\n engine.drawArraysType(Constants.MATERIAL_TriangleStripDrawMode, 0, 4, instanceCount);\r\n engine.unbindInstanceAttributes();\r\n engine.setAlphaMode(Constants.ALPHA_DISABLE);\r\n\r\n if (this.ignoreDepthBuffer) {\r\n engine.setDepthBuffer(true);\r\n }\r\n }\r\n\r\n /**\r\n * Release associated resources\r\n */\r\n public dispose(): void {\r\n if (this._worldBuffer) {\r\n this._worldBuffer.dispose();\r\n this._worldBuffer = null;\r\n }\r\n\r\n if (this._uvBuffer) {\r\n this._uvBuffer.dispose();\r\n this._uvBuffer = null;\r\n }\r\n\r\n if (this._spriteBuffer) {\r\n this._spriteBuffer.dispose();\r\n this._spriteBuffer = null;\r\n }\r\n\r\n if (this._vertexArrayObject) {\r\n (this._engine as ThinEngine).releaseVertexArrayObject(this._vertexArrayObject);\r\n (<any>this._vertexArrayObject) = null;\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new TextRenderer instance asynchronously\r\n * @param font define the font asset to use\r\n * @param engine define the engine to use\r\n * @returns a promise that resolves to the created TextRenderer instance\r\n */\r\n public static async CreateTextRendererAsync(font: FontAsset, engine: AbstractEngine) {\r\n if (!engine.getCaps().instancedArrays || !engine._features.supportSpriteInstancing) {\r\n throw new Error(\"Instanced arrays are required for MSDF text rendering.\");\r\n }\r\n\r\n let shaderLanguage = ShaderLanguage.GLSL;\r\n let vertex: string = \"\";\r\n let fragment: string = \"\";\r\n if (engine.isWebGPU) {\r\n shaderLanguage = ShaderLanguage.WGSL;\r\n vertex = (await import(\"./shadersWGSL/msdf.vertex\")).msdfVertexShaderWGSL.shader;\r\n fragment = (await import(\"./shadersWGSL/msdf.fragment\")).msdfPixelShaderWGSL.shader;\r\n } else {\r\n vertex = (await import(\"./shaders/msdf.vertex\")).msdfVertexShader.shader;\r\n fragment = (await import(\"./shaders/msdf.fragment\")).msdfPixelShader.shader;\r\n }\r\n\r\n const textRenderer = new TextRenderer(engine, shaderLanguage, font);\r\n textRenderer._setShaders(vertex, fragment);\r\n\r\n return textRenderer;\r\n }\r\n}\r\n","import * as addons from \"addons/index\";\r\n\r\nexport { addons };\r\nexport default addons;\r\n"],"names":["root","factory","exports","module","require","define","amd","self","global","this","__WEBPACK_EXTERNAL_MODULE__597__","name","shader","ShaderStore","ShadersStore","msdfVertexShader","ShadersStoreWGSL","msdfPixelShaderWGSL","msdfPixelShader","msdfVertexShaderWGSL","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","n","getter","__esModule","d","a","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","BabylonUnitsToPixels","RenderOrderFunc","defaultRenderOrder","subMeshA","subMeshB","meshA","getMesh","meshB","meshIsHtmlMeshA","meshIsHtmlMeshB","absolutePosition","z","scene","parentContainerId","_containerId","enableOverlayRender","defaultOpaqueRenderOrder","RenderingGroup","PainterSortCompare","defaultAlphaTestRenderOrder","defaultTransparentRenderOrder","defaultTransparentSortCompare","_cache","cameraData","fov","position","Vector3","style","htmlMeshData","WeakMap","_width","_height","_heightHalf","_temp","scaleTransform","rotationTransform","Quaternion","positionTransform","objectMatrix","Matrix","Identity","cameraWorldMatrix","cameraRotationMatrix","cameraWorldMatrixAsArray","Array","_lastDevicePixelRatio","window","devicePixelRatio","_cameraMatrixUpdated","_previousCanvasDocumentPosition","top","left","_renderObserver","_onCameraMatrixChanged","camera","_cameraWorldMatrix","getWorldMatrix","document","_init","dispose","remove","_overlayElements","container","_inSceneElements","parentContainer","getElementById","body","inSceneContainerId","_createRenderLayerElements","insertBefore","firstChild","overlayContainerId","zIndex","getEngine","getRenderingCanvas","pointerEvents","_engine","projectionObs","matrixObs","clientRect","getRenderingCanvasClientRect","Error","_setSize","width","height","onResizeObservable","add","observeCamera","activeCamera","onProjectionMatrixChangedObservable","onViewMatrixChangedObservable","onActiveCameraChanged","opaqueRenderOrder","alphaTestRenderOrder","transparentRenderOrder","setRenderingOrder","onBeforeRenderObservable","_render","containerId","existingContainer","createElement","id","domElement","overflow","cameraElement","webkitTransformStyle","transformStyle","appendChild","_getSize","dom","_getCameraCssMatrix","matrix","elements","m","_epsilon","_getHtmlContentCssMatrix","useRightHandedSystem","direction","_getTransformationMatrix","htmlMesh","getScene","objectWorldMatrix","widthScaleFactor","heightScaleFactor","sourceWidth","sourceHeight","scaledAndTranslatedObjectMatrix","decompose","x","y","ComposeToRef","getAbsolutePosition","setRowFromFloats","HtmlMeshRenderer","PROJECTION_SCALE_FACTOR","multiplyAtIndex","_renderHtmlMesh","element","firstElementChild","set","_isCanvasOverlay","parentNode","requiresUpdate","_updateBaseScaleFactor","billboardMode","TransformNode","BILLBOARDMODE_NONE","webkitTransform","transform","_markAsUpdated","needsUpdate","_updateContainerPositionIfNeeded","copyFrom","Logger","Log","meshesNeedingUpdate","meshes","filter","mesh","length","getProjectionMatrix","source","mode","Camera","PERSPECTIVE_CAMERA","el","webkitPerspective","perspective","parent","computeWorldMatrix","cameraMatrixWorld","getRotationMatrix","transposeToRef","cameraMatrixWorldAsArray","copyToArray","FromArrayToRef","screenWidth","screenHeight","htmlMeshAspectRatio","setContentSizePx","canvasRect","scrollTop","scrollY","scrollLeft","scrollX","canvasDocumentTop","canvasDocumentLeft","containerParent","offsetParent","parentRect","getBoundingClientRect","parentDocumentTop","parentDocumentLeft","ancestorMarginsAndPadding","_getAncestorMarginsAndPadding","bodyStyle","getComputedStyle","bodyMarginTop","parseInt","marginTop","bodyMarginLeft","marginLeft","paddingTop","paddingLeft","Warn","Math","abs","documentElement","extendStatics","b","setPrototypeOf","__proto__","p","__assign","assign","t","s","i","arguments","apply","create","SuppressedError","CharCode","CaptureRequestQueue","PendingRequestCallbacks","Map","UnmatchedReleaseRequests","CurrentOwner","requestRelease","requestId","DebugLog","CancelRequest","delete","includes","push","TransferPointerEventsOwnership","removed","newOwnerId","NextCaptureRequest","DoRelease","DoCapture","release","capture","shift","message","Tools","performance","now","LocalScene","CaptureOnEnterCount","MeshToBehaviorMap","StartCaptureOnEnter","addEventListener","OnPointerMove","onDisposeObservable","DoStopCaptureOnEnter","removeEventListener","StopCaptureOnEnter","evt","pickedMesh","touches","clientX","clientY","pointerScreenX","pointerScreenY","pickResult","pick","pointerCaptureBehavior","isEnabled","_captureOnPointerEnter","hit","capturingIdAsInt","uniqueId","capturePointerEvents","_captureCallback","_releaseCallback","captureOnPointerEnter","_attachedMesh","init","attach","attachedMesh","detach","releasePointerEvents","toString","captureCallback","releaseCallback","RemoveUnmatchedRequest","EnqueueCaptureRequest","FitStrategy","CONTAIN","wrapElement","sizingElement","display","justifyContent","alignItems","scalingElement","visibility","updateSize","offsetWidth","offsetHeight","childWidth","childHeight","scale","min","COVER","max","STRETCH","NONE","isCanvasOverlay","fitStrategy","_enabled","_ready","_requiresUpdate","_inverseScaleMatrix","_pointerEventCaptureBehavior","_sourceWidth","_sourceHeight","_fitStrategy","_createMask","_element","_createElement","setEnabled","PointerEventsCaptureBehavior","bind","addBehavior","TypeError","String","__","constructor","setContent","_setAsReady","scaling","setAll","_updateScaleIfNecessary","enabled","_doSetEnabled","ready","_worldMatrixUpdateObserver","onAfterWorldMatrixUpdateObservable","_setElementzIndex","bakeTransformIntoVertices","scaleX","scaleY","scaleMatrix","Scaling","invertToRef","CreatePlaneVertexData","applyToMesh","checkCollisions","depthMask","StandardMaterial","backFaceCulling","disableColorWrite","disableLighting","material","freeze","getElementsByTagName","div","backgroundColor","backfaceVisibility","Mesh","definitionData","textureUrl","_chars","_kernings","_font","JSON","parse","pages","chars","forEach","char","kernings","kerning","submap","first","second","amount","_charsRegex","RegExp","map","c","replace","join","_updateFallbacks","info","size","textures","page","texture","Texture","noMipmap","invertY","anisotropicFilteringLevel","has","SPACE","xoffset","yoffset","xadvance","chnl","index","TOFU","_getChar","charCode","_getKerning","_unsupportedChars","text","DefaultParagraphOptions","maxWidth","Infinity","lineHeight","letterSpacing","tabSize","whiteSpace","textAlign","translate","fontAsset","options","_computeMetrics","paragraph","lines","glyphs","common","collapsed","_collapse","trimmed","_breakLines","line","trim","_wrap","anchor","glyph","flatMap","split","repeat","lineOffset","lastChar","currentLine","currentGlyphs","currentCursor","currentWidth","start","end","pushCurrentLine","slice","charCodeAt","charWidth","newWidth","cursorProgress","nextPosition","shouldBreak","engine","shaderLanguage","font","_useVAO","_vertexBuffers","_charMatrices","_charUvs","_isDirty","_baseLine","_scalingMatrix","ThinMatrix","_fontScaleMatrix","_offsetMatrix","_translationMatrix","_baseMatrix","_scaledMatrix","_localMatrix","_finalMatrix","_lineMatrix","_parentWorldMatrix","color","g","strokeColor","strokeInsetWidth","strokeOutsetWidth","thicknessControl","_parent","_transformMatrix","isBillboard","isBillboardScreenProjected","ignoreDepthBuffer","_shaderLanguage","getCaps","vertexArrayObject","disableVertexArrayObjects","spriteData","Float32Array","_spriteBuffer","Buffer","createVertexBuffer","_resizeBuffers","capacity","_worldBuffer","_uvBuffer","_setShaders","vertex","fragment","_drawWrapperBase","DrawWrapper","drawContext","useInstancing","effect","createEffect","vertexSource","fragmentSource","_refCount","addParagraph","worldMatrix","SdfTextParagraph","fontScale","texWidth","scaleW","texHeight","scaleH","worldMatrixToUse","TranslationMatrixToRef","ScalingMatrixToRef","charsUvsBase","matricesBase","MultiplyMatricesToRef","CopyMatrixToArray","render","viewMatrix","projectionMatrix","drawWrapper","isReady","setState","enableEffect","setDepthBuffer","CopyMatrixToRef","IdentityMatrixToRef","setInt","setMatrix","transformMatrix","setTexture","setDirectColor4","setFloat","instanceCount","getBuffer","update","_vertexArrayObject","recordVertexArrayObject","bindVertexArrayObject","bindBuffers","setAlphaMode","Constants","ALPHA_COMBINE","drawArraysType","MATERIAL_TriangleStripDrawMode","unbindInstanceAttributes","ALPHA_DISABLE","releaseVertexArrayObject","CreateTextRendererAsync","thisArg","_arguments","generator","f","_","label","sent","trys","ops","Iterator","next","verb","iterator","v","op","done","pop","e","step","instancedArrays","_features","supportSpriteInstancing","isWebGPU","textRenderer","TextRenderer","P","Promise","resolve","reject","fulfilled","rejected","result","then"],"sourceRoot":""}
1
+ {"version":3,"file":"babylonjs.addons.min.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,cACR,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,mBAAoB,CAAC,aAAcJ,GAChB,iBAAZC,QACdA,QAAQ,oBAAsBD,EAAQG,QAAQ,cAE9CJ,EAAa,OAAIC,EAAQD,EAAc,QACxC,CATD,CASoB,oBAATO,KAAuBA,KAAyB,oBAAXC,OAAyBA,OAASC,MAAQC,G,2FCNpFC,EAAO,mBACPC,EAAS,m2BAQV,EAAAC,YAAYC,aAAaH,KAC1B,EAAAE,YAAYC,aAAaH,GAAQC,GAG9B,IAAMG,EAAmB,CAAEJ,KAAI,EAAEC,OAAM,E,uECbxCD,EAAO,kBACPC,EAAS,kuCAIV,EAAAC,YAAYG,iBAAiBL,KAC9B,EAAAE,YAAYG,iBAAiBL,GAAQC,GAGlC,IAAMK,EAAsB,CAAEN,KAAI,EAAEC,OAAM,E,mECT3CD,EAAO,kBACPC,EAAS,66BAKV,EAAAC,YAAYC,aAAaH,KAC1B,EAAAE,YAAYC,aAAaH,GAAQC,GAG9B,IAAMM,EAAkB,CAAEP,KAAI,EAAEC,OAAM,E,UCb7CT,EAAOD,QAAUQ,C,wECGXC,EAAO,mBACPC,EA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MAAOwiC,GAAKU,EAAOV,EAAI,CAAE,CAC1F,SAASY,EAASpjC,GAAS,IAAMyiC,EAAKd,EAAiB,MAAE3hC,GAAS,CAAE,MAAOwiC,GAAKU,EAAOV,EAAI,CAAE,CAC7F,SAASC,EAAKx0B,GAJlB,IAAejO,EAIaiO,EAAOq0B,KAAOW,EAAQh1B,EAAOjO,QAJ1CA,EAIyDiO,EAAOjO,MAJhDA,aAAiB+iC,EAAI/iC,EAAQ,IAAI+iC,GAAE,SAAUE,GAAWA,EAAQjjC,EAAQ,KAIjB6T,KAAKsvB,EAAWC,EAAW,CAC7GX,GAAMd,EAAYA,EAAUvgC,MAAMqgC,EAASC,GAAc,KAAKQ,OAClE,IAPK,IAAmBT,EAASC,EAAYqB,EAAGpB,C,E8B4RlD,EAtWA,G,uCCrCA,W","sources":["webpack://ADDONS/webpack/universalModuleDefinition","webpack://ADDONS/../../../dev/addons/src/msdfText/shaders/msdf.vertex.ts","webpack://ADDONS/../../../dev/addons/src/msdfText/shadersWGSL/msdf.fragment.ts","webpack://ADDONS/../../../dev/addons/src/msdfText/shaders/msdf.fragment.ts","webpack://ADDONS/external umd {\"root\":\"BABYLON\",\"commonjs\":\"babylonjs\",\"commonjs2\":\"babylonjs\",\"amd\":\"babylonjs\"}","webpack://ADDONS/../../../dev/addons/src/msdfText/shadersWGSL/msdf.vertex.ts","webpack://ADDONS/webpack/bootstrap","webpack://ADDONS/webpack/runtime/compat get default export","webpack://ADDONS/webpack/runtime/define property getters","webpack://ADDONS/webpack/runtime/hasOwnProperty shorthand","webpack://ADDONS/webpack/runtime/make namespace object","webpack://ADDONS/../../../../node_modules/tslib/tslib.es6.mjs","webpack://ADDONS/../../../dev/addons/src/atmosphere/atmospherePBRMaterialPlugin.ts","webpack://ADDONS/../../../dev/addons/src/atmosphere/atmospherePerCameraVariables.ts","webpack://ADDONS/../../../dev/addons/src/atmosphere/atmospherePhysicalProperties.ts","webpack://ADDONS/../../../dev/addons/src/atmosphere/sampling.ts","webpack://ADDONS/../../../dev/addons/src/atmosphere/Shaders/ShadersInclude/atmosphereFragmentDeclaration.ts","webpack://ADDONS/../../../dev/addons/src/atmosphere/Shaders/ShadersInclude/atmosphereUboDeclaration.ts","webpack://ADDONS/../../../dev/addons/src/atmosphere/Shaders/ShadersInclude/depthFunctions.ts","webpack://ADDONS/../../../dev/addons/src/atmosphere/Shaders/ShadersInclude/atmosphereFunctions.ts","webpack://ADDONS/../../../dev/addons/src/atmosphere/Shaders/diffuseSkyIrradiance.fragment.ts","webpack://ADDONS/../../../dev/addons/src/atmosphere/Shaders/fullscreenTriangle.vertex.ts","webpack://ADDONS/../../../dev/addons/src/atmosphere/diffuseSkyIrradianceLut.ts","webpack://ADDONS/../../../dev/addons/src/atmosphere/Shaders/transmittance.fragment.ts","webpack://ADDONS/../../../dev/addons/src/atmosphere/transmittanceLut.ts","webpack://ADDONS/../../../dev/addons/src/atmosphere/Shaders/compositeAerialPerspective.fragment.ts","webpack://ADDONS/../../../dev/addons/src/atmosphere/Shaders/compositeSky.fragment.ts","webpack://ADDONS/../../../dev/addons/src/atmosphere/Shaders/compositeGlobeAtmosphere.fragment.ts","webpack://ADDONS/../../../dev/addons/src/atmosphere/Shaders/multiScattering.fragment.ts","webpack://ADDONS/../../../dev/addons/src/atmosphere/Shaders/skyView.fragment.ts","webpack://ADDONS/../../../dev/addons/src/atmosphere/Shaders/aerialPerspective.fragment.ts","webpack://ADDONS/../../../dev/addons/src/atmosphere/Shaders/ShadersInclude/atmosphereVertexDeclaration.ts","webpack://ADDONS/../../../dev/addons/src/msdfText/fontAsset.ts","webpack://ADDONS/../../../dev/addons/src/atmosphere/atmosphere.ts","webpack://ADDONS/../../../dev/addons/src/htmlMesh/htmlMeshRenderer.ts","webpack://ADDONS/../../../dev/addons/src/htmlMesh/pointerEventsCapture.ts","webpack://ADDONS/../../../dev/addons/src/htmlMesh/pointerEventsCaptureBehavior.ts","webpack://ADDONS/../../../dev/addons/src/htmlMesh/fitStrategy.ts","webpack://ADDONS/../../../dev/addons/src/htmlMesh/htmlMesh.ts","webpack://ADDONS/../../../dev/addons/src/msdfText/paragraphOptions.ts","webpack://ADDONS/../../../dev/addons/src/msdfText/sdf/paragraph.ts","webpack://ADDONS/../../../dev/addons/src/msdfText/textRenderer.ts","webpack://ADDONS/./src/index.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"babylonjs\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"babylonjs-addons\", [\"babylonjs\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"babylonjs-addons\"] = factory(require(\"babylonjs\"));\n\telse\n\t\troot[\"ADDONS\"] = factory(root[\"BABYLON\"]);\n})((typeof self !== \"undefined\" ? self : typeof global !== \"undefined\" ? global : this), (__WEBPACK_EXTERNAL_MODULE__597__) => {\nreturn ","// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\n\nconst name = \"msdfVertexShader\";\nconst shader = `#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);}`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const msdfVertexShader = { name, shader };\n","// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\n\nconst name = \"msdfPixelShader\";\nconst shader = `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);}`;\n// Sideeffect\nif (!ShaderStore.ShadersStoreWGSL[name]) {\n ShaderStore.ShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const msdfPixelShaderWGSL = { name, shader };\n","// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\n\nconst name = \"msdfPixelShader\";\nconst shader = `#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);}`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const msdfPixelShader = { name, shader };\n","module.exports = __WEBPACK_EXTERNAL_MODULE__597__;","// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\n\nconst name = \"msdfVertexShader\";\nconst shader = `#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);}`;\n// Sideeffect\nif (!ShaderStore.ShadersStoreWGSL[name]) {\n ShaderStore.ShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const msdfVertexShaderWGSL = { name, shader };\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nexport function __extends(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nexport var __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n }\n return __assign.apply(this, arguments);\n}\n\nexport function __rest(s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n}\n\nexport function __decorate(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nexport function __param(paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n var _, done = false;\n for (var i = decorators.length - 1; i >= 0; i--) {\n var context = {};\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n if (kind === \"accessor\") {\n if (result === void 0) continue;\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n if (_ = accept(result.get)) descriptor.get = _;\n if (_ = accept(result.set)) descriptor.set = _;\n if (_ = accept(result.init)) initializers.unshift(_);\n }\n else if (_ = accept(result)) {\n if (kind === \"field\") initializers.unshift(_);\n else descriptor[key] = _;\n }\n }\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\n done = true;\n};\n\nexport function __runInitializers(thisArg, initializers, value) {\n var useValue = arguments.length > 2;\n for (var i = 0; i < initializers.length; i++) {\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n }\n return useValue ? value : void 0;\n};\n\nexport function __propKey(x) {\n return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nexport function __setFunctionName(f, name, prefix) {\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nexport function __metadata(metadataKey, metadataValue) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nexport function __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nexport function __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nexport function __exportStar(m, o) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nexport function __values(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nexport function __read(o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n}\n\n/** @deprecated */\nexport function __spread() {\n for (var ar = [], i = 0; i < arguments.length; i++)\n ar = ar.concat(__read(arguments[i]));\n return ar;\n}\n\n/** @deprecated */\nexport function __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n}\n\nexport function __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nexport function __await(v) {\n return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nexport function __asyncGenerator(thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nexport function __asyncDelegator(o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nexport function __asyncValues(o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nexport function __makeTemplateObject(cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n};\n\nvar ownKeys = function(o) {\n ownKeys = Object.getOwnPropertyNames || function (o) {\n var ar = [];\n for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;\n return ar;\n };\n return ownKeys(o);\n};\n\nexport function __importStar(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== \"default\") __createBinding(result, mod, k[i]);\n __setModuleDefault(result, mod);\n return result;\n}\n\nexport function __importDefault(mod) {\n return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nexport function __classPrivateFieldIn(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nexport function __addDisposableResource(env, value, async) {\n if (value !== null && value !== void 0) {\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n var dispose, inner;\n if (async) {\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n dispose = value[Symbol.asyncDispose];\n }\n if (dispose === void 0) {\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n dispose = value[Symbol.dispose];\n if (async) inner = dispose;\n }\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\n env.stack.push({ value: value, dispose: dispose, async: async });\n }\n else if (async) {\n env.stack.push({ async: true });\n }\n return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nexport function __disposeResources(env) {\n function fail(e) {\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n env.hasError = true;\n }\n var r, s = 0;\n function next() {\n while (r = env.stack.pop()) {\n try {\n if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\n if (r.dispose) {\n var result = r.dispose.call(r.value);\n if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n }\n else s |= 1;\n }\n catch (e) {\n fail(e);\n }\n }\n if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\n if (env.hasError) throw env.error;\n }\n return next();\n}\n\nexport function __rewriteRelativeImportExtension(path, preserveJsx) {\n if (typeof path === \"string\" && /^\\.\\.?\\//.test(path)) {\n return path.replace(/\\.(tsx)$|((?:\\.d)?)((?:\\.[^./]+?)?)\\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {\n return tsx ? preserveJsx ? \".jsx\" : \".js\" : d && (!ext || !cm) ? m : (d + ext + \".\" + cm.toLowerCase() + \"js\");\n });\n }\n return path;\n}\n\nexport default {\n __extends,\n __assign,\n __rest,\n __decorate,\n __param,\n __esDecorate,\n __runInitializers,\n __propKey,\n __setFunctionName,\n __metadata,\n __awaiter,\n __generator,\n __createBinding,\n __exportStar,\n __values,\n __read,\n __spread,\n __spreadArrays,\n __spreadArray,\n __await,\n __asyncGenerator,\n __asyncDelegator,\n __asyncValues,\n __makeTemplateObject,\n __importStar,\n __importDefault,\n __classPrivateFieldGet,\n __classPrivateFieldSet,\n __classPrivateFieldIn,\n __addDisposableResource,\n __disposeResources,\n __rewriteRelativeImportExtension,\n};\n","// Copyright (c) Microsoft Corporation.\r\n// MIT License\r\n\r\nimport type { Atmosphere } from \"./atmosphere\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { MaterialDefines } from \"core/Materials/materialDefines\";\r\nimport { MaterialPluginBase } from \"core/Materials/materialPluginBase\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { UniformBuffer } from \"core/Materials/uniformBuffer\";\r\n\r\nclass AtmospherePBRMaterialDefines extends MaterialDefines {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public USE_AERIAL_PERSPECTIVE_LUT: boolean;\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public APPLY_AERIAL_PERSPECTIVE_INTENSITY = false;\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS = false;\r\n\r\n /**\r\n * Constructs the {@link AtmospherePBRMaterialDefines}.\r\n * @param useAerialPerspectiveLut - Whether to use the aerial perspective LUT.\r\n */\r\n constructor(useAerialPerspectiveLut: boolean) {\r\n super();\r\n this.USE_AERIAL_PERSPECTIVE_LUT = useAerialPerspectiveLut;\r\n }\r\n}\r\n\r\nconst UboArray = [{ name: \"inverseViewportSize\", size: 2, type: \"vec2\" }];\r\nconst MakeUniforms = (atmosphere: Atmosphere) => ({\r\n ubo: UboArray,\r\n fragment: \"uniform vec2 inverseViewportSize;\\n\",\r\n externalUniforms: atmosphere.uniformBuffer.getUniformNames(),\r\n});\r\n\r\nconst PluginName = \"AtmospherePBRMaterialPlugin\";\r\nconst PluginPriority = 600;\r\n\r\n/**\r\n * Adds shading logic to a PBRMaterial that provides radiance, diffuse sky irradiance, and aerial perspective from the atmosphere.\r\n */\r\nexport class AtmospherePBRMaterialPlugin extends MaterialPluginBase {\r\n /**\r\n * Constructs the {@link AtmospherePBRMaterialPlugin}.\r\n * @param material - The material to apply the plugin to.\r\n * @param _atmosphere - The atmosphere to use for shading.\r\n * @param _isAerialPerspectiveEnabled - Whether to apply aerial perspective.\r\n */\r\n constructor(\r\n material: Material,\r\n private readonly _atmosphere: Atmosphere,\r\n private readonly _isAerialPerspectiveEnabled = false\r\n ) {\r\n super(\r\n material,\r\n PluginName,\r\n PluginPriority,\r\n {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n USE_CUSTOM_REFLECTION: _atmosphere.diffuseSkyIrradianceLut !== null,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CUSTOM_FRAGMENT_BEFORE_FOG: _isAerialPerspectiveEnabled,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n USE_AERIAL_PERSPECTIVE_LUT: _isAerialPerspectiveEnabled && _atmosphere.isAerialPerspectiveLutEnabled,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n APPLY_AERIAL_PERSPECTIVE_INTENSITY: _isAerialPerspectiveEnabled && _atmosphere.aerialPerspectiveIntensity !== 1.0,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS: _isAerialPerspectiveEnabled && _atmosphere.aerialPerspectiveRadianceBias !== 0.0,\r\n },\r\n false, // addPluginToList -- false because we need to control when this is added to the list\r\n true, // enable\r\n true // resolveIncludes\r\n );\r\n\r\n this.doNotSerialize = true;\r\n\r\n // This calls `getCode` so we need to do this after having initialized the class fields.\r\n this._pluginManager._addPlugin(this);\r\n }\r\n\r\n /**\r\n * @override\r\n */\r\n public override getUniformBuffersNames(_ubos: string[]): void {\r\n const uniformBuffer = this._atmosphere.uniformBuffer;\r\n if (uniformBuffer.useUbo) {\r\n _ubos.push(uniformBuffer.name);\r\n }\r\n }\r\n\r\n /**\r\n * @override\r\n */\r\n public override getUniforms() {\r\n return MakeUniforms(this._atmosphere);\r\n }\r\n\r\n /**\r\n * @override\r\n */\r\n public override isReadyForSubMesh(): boolean {\r\n let isReady = true;\r\n const atmosphere = this._atmosphere;\r\n if (this._isAerialPerspectiveEnabled && atmosphere.isAerialPerspectiveLutEnabled) {\r\n const aerialPerspectiveLutRenderTarget = atmosphere.aerialPerspectiveLutRenderTarget;\r\n isReady = isReady && !!aerialPerspectiveLutRenderTarget?.isReady();\r\n }\r\n const transmittanceLutRenderTarget = atmosphere.transmittanceLut?.renderTarget ?? null;\r\n isReady = isReady && !!transmittanceLutRenderTarget?.isReady();\r\n return isReady;\r\n }\r\n\r\n /**\r\n * @override\r\n */\r\n public override getActiveTextures(_activeTextures: BaseTexture[]): void {\r\n const atmosphere = this._atmosphere;\r\n if (this._isAerialPerspectiveEnabled && atmosphere.isAerialPerspectiveLutEnabled) {\r\n const aerialPerspectiveLutRenderTarget = atmosphere.aerialPerspectiveLutRenderTarget;\r\n if (aerialPerspectiveLutRenderTarget) {\r\n _activeTextures.push(aerialPerspectiveLutRenderTarget);\r\n }\r\n }\r\n\r\n const transmittanceLutRenderTarget = atmosphere.transmittanceLut?.renderTarget ?? null;\r\n if (transmittanceLutRenderTarget) {\r\n _activeTextures.push(transmittanceLutRenderTarget);\r\n }\r\n }\r\n\r\n /**\r\n * @override\r\n */\r\n public override bindForSubMesh(uniformBuffer: UniformBuffer): void {\r\n const atmosphere = this._atmosphere;\r\n const engine = atmosphere.scene.getEngine();\r\n\r\n // Bind the atmosphere's uniform buffer to the effect.\r\n const effect = uniformBuffer.currentEffect;\r\n if (effect) {\r\n this._atmosphere.bindUniformBufferToEffect(effect);\r\n }\r\n\r\n const width = engine.getRenderWidth();\r\n const height = engine.getRenderHeight();\r\n uniformBuffer.updateFloat2(\"inverseViewportSize\", 1.0 / width, 1.0 / height);\r\n\r\n if (this._isAerialPerspectiveEnabled && atmosphere.isAerialPerspectiveLutEnabled) {\r\n const aerialPerspectiveLutRenderTarget = atmosphere.aerialPerspectiveLutRenderTarget;\r\n uniformBuffer.setTexture(\"aerialPerspectiveLut\", aerialPerspectiveLutRenderTarget);\r\n }\r\n const transmittanceLutRenderTarget = atmosphere.transmittanceLut?.renderTarget ?? null;\r\n uniformBuffer.setTexture(\"transmittanceLut\", transmittanceLutRenderTarget);\r\n }\r\n\r\n /**\r\n * @override\r\n */\r\n public override prepareDefines(defines: AtmospherePBRMaterialDefines): void {\r\n const lastUseAerialPerspectiveLut = defines.USE_AERIAL_PERSPECTIVE_LUT;\r\n const lastApplyAerialPerspectiveIntensity = defines.APPLY_AERIAL_PERSPECTIVE_INTENSITY;\r\n const lastApplyAerialPerspectiveRadianceBias = defines.APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS;\r\n defines.USE_AERIAL_PERSPECTIVE_LUT = this._isAerialPerspectiveEnabled && this._atmosphere.isAerialPerspectiveLutEnabled;\r\n defines.APPLY_AERIAL_PERSPECTIVE_INTENSITY = this._isAerialPerspectiveEnabled && this._atmosphere.aerialPerspectiveIntensity !== 1.0;\r\n defines.APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS = this._isAerialPerspectiveEnabled && this._atmosphere.aerialPerspectiveRadianceBias !== 0.0;\r\n if (\r\n lastUseAerialPerspectiveLut !== defines.USE_AERIAL_PERSPECTIVE_LUT ||\r\n lastApplyAerialPerspectiveIntensity !== defines.APPLY_AERIAL_PERSPECTIVE_INTENSITY ||\r\n lastApplyAerialPerspectiveRadianceBias !== defines.APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS\r\n ) {\r\n defines.markAllAsDirty();\r\n }\r\n }\r\n\r\n /**\r\n * @override\r\n */\r\n public override getSamplers(samplers: string[]): void {\r\n samplers.push(\"transmittanceLut\");\r\n if (this._isAerialPerspectiveEnabled && this._atmosphere.isAerialPerspectiveLutEnabled) {\r\n samplers.push(\"aerialPerspectiveLut\");\r\n }\r\n }\r\n\r\n /**\r\n * @override\r\n */\r\n public override getCustomCode(shaderType: string): Nullable<Record<string, string>> {\r\n // Assumed inputs are light0, vPositionW, normalW.\r\n // Only works for directional lights.\r\n if (shaderType !== \"fragment\") {\r\n return null;\r\n }\r\n\r\n const useUbo = this._atmosphere.scene.getEngine().supportsUniformBuffers;\r\n const directionToLightSnippet = useUbo ? \"-light0.vLightData.xyz\" : \"-vLightData0.xyz\";\r\n\r\n const useAtmosphereUbo = this._atmosphere.uniformBuffer.useUbo;\r\n const atmosphereImportSnippet = useAtmosphereUbo ? \"#include<atmosphereUboDeclaration>\" : \"#include<atmosphereFragmentDeclaration>\";\r\n\r\n return {\r\n CUSTOM_FRAGMENT_DEFINITIONS:\r\n this._isAerialPerspectiveEnabled && this._atmosphere.isAerialPerspectiveLutEnabled\r\n ? `uniform sampler2D transmittanceLut;\\r\\nprecision highp sampler2DArray;\\r\\nuniform sampler2DArray aerialPerspectiveLut;\\r\\n${atmosphereImportSnippet}\\r\\n#include<atmosphereFunctions>`\r\n : `uniform sampler2D transmittanceLut;\\r\\n${atmosphereImportSnippet}\\r\\n#include<atmosphereFunctions>`,\r\n CUSTOM_LIGHT0_COLOR: `\r\n {\r\n vec3 positionGlobal = 0.001 * vPositionW + vec3(0., planetRadius, 0.);\r\n float positionRadius = length(positionGlobal);\r\n vec3 geocentricNormal = positionGlobal / positionRadius;\r\n vec3 directionToLight = ${directionToLightSnippet};\r\n float cosAngleLightToZenith = dot(directionToLight, geocentricNormal);\r\n diffuse0 = lightIntensity * sampleTransmittanceLut(transmittanceLut, positionRadius, cosAngleLightToZenith);\r\n }\r\n`,\r\n CUSTOM_REFLECTION: `\r\n {\r\n vec3 positionGlobal = 0.001 * vPositionW + vec3(0., planetRadius, 0.);\r\n float positionRadius = length(positionGlobal);\r\n vec3 geocentricNormal = positionGlobal / positionRadius;\r\n\r\n vec3 directionToLight = ${directionToLightSnippet};\r\n float cosAngleLightToZenith = dot(directionToLight, geocentricNormal);\r\n\r\n vec2 uv = vec2(0.5 + 0.5 * cosAngleLightToZenith, (positionRadius - planetRadius) / atmosphereThickness);\r\n float irradianceScaleT = 0.5 * dot(normalW, geocentricNormal) + 0.5;\r\n float irradianceScale = ((-0.6652 * irradianceScaleT) + 1.5927) * irradianceScaleT + 0.1023;\r\n vec3 environmentIrradiance = lightIntensity * sampleReflection(irradianceSampler, uv).rgb;\r\n\r\n // Add a contribution here to estimate indirect lighting.\r\n const float r = 0.2;\r\n float indirect = getLuminance(environmentIrradiance) / max(0.00001, 1. - r);\r\n environmentIrradiance *= irradianceScale;\r\n environmentIrradiance += indirect;\r\n\r\n environmentIrradiance += additionalDiffuseSkyIrradiance;\r\n\r\n const float diffuseBrdf = 1. / PI;\r\n environmentIrradiance *= diffuseBrdf * diffuseSkyIrradianceIntensity;\r\n\r\n reflectionOut.environmentIrradiance = environmentIrradiance;\r\n reflectionOut.environmentRadiance.rgb = reflectionOut.environmentIrradiance;\r\n }\r\n`,\r\n // TODO: Support full ray marching if USE_AERIAL_PERSPECTIVE_LUT is disabled.\r\n CUSTOM_FRAGMENT_BEFORE_FOG: `\r\n #if USE_AERIAL_PERSPECTIVE_LUT\r\n {\r\n vec3 positionGlobal = 0.001 * vPositionW + vec3(0., planetRadius, 0.);\r\n float distanceFromCamera = distance(positionGlobal, cameraPositionGlobal);\r\n\r\n vec4 aerialPerspective = vec4(0.);\r\n if (sampleAerialPerspectiveLut(\r\n gl_FragCoord.xy * inverseViewportSize,\r\n true,\r\n distanceFromCamera,\r\n NumAerialPerspectiveLutLayers,\r\n AerialPerspectiveLutKMPerSlice,\r\n AerialPerspectiveLutRangeKM,\r\n aerialPerspective)) {\r\n finalColor = aerialPerspective + (1. - aerialPerspective.a) * finalColor;\r\n }\r\n }\r\n #endif\r\n`,\r\n };\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation.\r\n// MIT License\r\n\r\nimport type { Camera } from \"core/Cameras/camera\";\r\nimport type { IMatrixLike, IVector3Like, IVector4Like } from \"core/Maths/math.like\";\r\nimport { Matrix, Vector3, Vector4 } from \"core/Maths/math.vector\";\r\nimport { Ray } from \"core/Culling/ray.core\";\r\nimport { Vector3Dot } from \"core/Maths/math.vector.functions\";\r\n\r\nconst TempRay = new Ray(Vector3.Zero(), Vector3.Zero());\r\n\r\n/**\r\n * Variables that are used to render the atmosphere and are computed per-camera.\r\n */\r\nexport class AtmospherePerCameraVariables {\r\n private _inverseViewProjectionMatrixWithoutTranslation = Matrix.Identity();\r\n private _directionToLightRelativeToCameraGeocentricNormal = Vector3.Up();\r\n private _cosAngleLightToZenith = 0;\r\n private _cameraRadius = 0;\r\n private _clampedCameraRadius = 0;\r\n private _cameraHeight = 0;\r\n private _clampedCameraHeight = 0;\r\n private _cameraPositionGlobal = new Vector3();\r\n private _clampedCameraPositionGlobal = new Vector3();\r\n private _cosCameraHorizonAngleFromZenith = 0;\r\n private _sinCameraAtmosphereHorizonAngleFromNadir = 0;\r\n private _cameraGeocentricNormal = Vector3.Up();\r\n private _cameraForward = Vector3.Down();\r\n private _cameraNearPlane = 0;\r\n private _cameraPosition = new Vector3();\r\n private _viewport = new Vector4();\r\n private _lastViewMatrix = Matrix.Identity();\r\n private _lastProjectionMatrix = Matrix.Identity();\r\n private _inverseViewMatrixWithoutTranslation = Matrix.Identity();\r\n private _inverseProjectionMatrix = Matrix.Identity();\r\n\r\n /**\r\n * The inverse view projection matrix is used to unproject rays.\r\n * To avoid precision issues, the translation part of the matrix has been removed.\r\n */\r\n public get inverseViewProjectionMatrixWithoutTranslation(): IMatrixLike {\r\n return this._inverseViewProjectionMatrixWithoutTranslation;\r\n }\r\n\r\n /**\r\n * The direction to the light relative to the geocentric normal under the camera.\r\n */\r\n public get directionToLightRelativeToCameraGeocentricNormal(): IVector3Like {\r\n return this._directionToLightRelativeToCameraGeocentricNormal;\r\n }\r\n\r\n /**\r\n * The cosine of the angle between the light direction and zenith.\r\n */\r\n public get cosAngleLightToZenith(): number {\r\n return this._cosAngleLightToZenith;\r\n }\r\n\r\n /**\r\n * The distance from the camera to the planet origin in kilometers.\r\n */\r\n public get cameraRadius(): number {\r\n return this._cameraRadius;\r\n }\r\n\r\n /**\r\n * The distance from the camera to the planet origin, clamped to the planet radius offset, in kilometers.\r\n */\r\n public get clampedCameraRadius(): number {\r\n return this._clampedCameraRadius;\r\n }\r\n\r\n /**\r\n * The height of the camera above the planet surface in kilometers.\r\n */\r\n public get cameraHeight(): number {\r\n return this._cameraHeight;\r\n }\r\n\r\n /**\r\n * The height of the camera above the planet surface, clamped to the planet radius offset, in kilometers.\r\n */\r\n public get clampedCameraHeight(): number {\r\n return this._clampedCameraHeight;\r\n }\r\n\r\n /**\r\n * The camera position in global space kilometers.\r\n */\r\n public get cameraPositionGlobal(): IVector3Like {\r\n return this._cameraPositionGlobal;\r\n }\r\n\r\n /**\r\n * The camera position, clamped to the planet radius offset, in global space kilometers.\r\n */\r\n public get clampedCameraPositionGlobal(): IVector3Like {\r\n return this._clampedCameraPositionGlobal;\r\n }\r\n\r\n /**\r\n * The cosine of the angle from the zenith to the horizon of the planet, measured from the camera position.\r\n */\r\n public get cosCameraHorizonAngleFromZenith(): number {\r\n return this._cosCameraHorizonAngleFromZenith;\r\n }\r\n\r\n /**\r\n * The sine of the angle from the nadir to the horizon of the atmosphere, measured from the camera position.\r\n */\r\n public get sinCameraAtmosphereHorizonAngleFromNadir(): number {\r\n return this._sinCameraAtmosphereHorizonAngleFromNadir;\r\n }\r\n\r\n /**\r\n * The geocentric normal of the camera in global space i.e., the normalization of {@link cameraPositionGlobal}.\r\n */\r\n public get cameraGeocentricNormal(): IVector3Like {\r\n return this._cameraGeocentricNormal;\r\n }\r\n\r\n /**\r\n * The camera's forward direction in world space.\r\n */\r\n public get cameraForward(): IVector3Like {\r\n return this._cameraForward;\r\n }\r\n\r\n /**\r\n * The distance to the near plane of the camera.\r\n */\r\n public get cameraNearPlane(): number {\r\n return this._cameraNearPlane;\r\n }\r\n\r\n /**\r\n * The camera's position in world space.\r\n */\r\n public get cameraPosition(): IVector3Like {\r\n return this._cameraPosition;\r\n }\r\n\r\n /**\r\n * The viewport for the camera.\r\n */\r\n public get viewport(): IVector4Like {\r\n return this._viewport;\r\n }\r\n\r\n /**\r\n * Updates the variables.\r\n * @param camera - The camera to update the variables for.\r\n * @param planetRadius - The radius of the planet in kilometers.\r\n * @param planetRadiusWithOffset - The radius of the planet with the offset in kilometers.\r\n * @param atmosphereRadius - The radius of the atmosphere in kilometers.\r\n * @param directionToLight - The direction to the light in world space.\r\n * @param originHeight - The height of the origin (distance from planet's surface) in kilometers.\r\n */\r\n public update(camera: Camera, planetRadius: number, planetRadiusWithOffset: number, atmosphereRadius: number, directionToLight: IVector3Like, originHeight: number): void {\r\n this._cameraNearPlane = camera.minZ;\r\n this._cameraForward.copyFrom(camera.getForwardRayToRef(TempRay, 1).direction);\r\n\r\n const engine = camera.getScene().getEngine();\r\n this._viewport.copyFromFloats(0.0, 0.0, engine.getRenderWidth(), engine.getRenderHeight());\r\n\r\n // Compute inverse view projection matrix, but remove the translational component to increase precision.\r\n const viewMatrix = camera.getViewMatrix();\r\n const projectionMatrix = camera.getProjectionMatrix();\r\n if (!this._lastViewMatrix.equals(viewMatrix) || !this._lastProjectionMatrix.equals(projectionMatrix)) {\r\n this._lastViewMatrix.copyFrom(viewMatrix);\r\n this._lastViewMatrix.setTranslation(Vector3.ZeroReadOnly);\r\n this._lastViewMatrix.invertToRef(this._inverseViewMatrixWithoutTranslation);\r\n\r\n this._lastProjectionMatrix.copyFrom(projectionMatrix);\r\n this._lastProjectionMatrix.invertToRef(this._inverseProjectionMatrix);\r\n this._inverseProjectionMatrix.multiplyToRef(this._inverseViewMatrixWithoutTranslation, this._inverseViewProjectionMatrixWithoutTranslation);\r\n }\r\n\r\n // Compute the global space position of the camera in kilometers.\r\n this._cameraPosition.copyFrom(camera.globalPosition);\r\n this._cameraPosition.scaleToRef(1.0 / 1000.0, this._cameraPositionGlobal);\r\n this._cameraPositionGlobal.y += planetRadius + originHeight;\r\n this._cameraHeight = this._cameraPositionGlobal.y - planetRadius;\r\n\r\n // Clamp the camera parameters.\r\n this._cameraRadius = this._cameraPositionGlobal.length();\r\n this._clampedCameraRadius = this._cameraRadius;\r\n this._cameraPositionGlobal.normalizeToRef(this._cameraGeocentricNormal);\r\n if (this._clampedCameraRadius < planetRadiusWithOffset) {\r\n this._clampedCameraRadius = planetRadiusWithOffset;\r\n this._cameraGeocentricNormal.scaleToRef(planetRadiusWithOffset, this._clampedCameraPositionGlobal);\r\n } else {\r\n this._clampedCameraPositionGlobal.copyFrom(this._cameraPositionGlobal);\r\n }\r\n\r\n this._cosCameraHorizonAngleFromZenith = ComputeCosHorizonAngleFromZenith(planetRadius, this._clampedCameraRadius);\r\n this._sinCameraAtmosphereHorizonAngleFromNadir = Math.min(1.0, atmosphereRadius / this._clampedCameraRadius);\r\n this._clampedCameraHeight = this._clampedCameraRadius - planetRadius;\r\n\r\n // Compute the direction to the light relative to the camera's geocentric normal.\r\n {\r\n this._cosAngleLightToZenith = Vector3Dot(directionToLight, this._cameraGeocentricNormal);\r\n const lightZenithSinAngle = Math.sqrt(Math.max(0.0, 1.0 - this._cosAngleLightToZenith * this._cosAngleLightToZenith));\r\n this._directionToLightRelativeToCameraGeocentricNormal.copyFromFloats(lightZenithSinAngle, this._cosAngleLightToZenith, 0.0);\r\n this._directionToLightRelativeToCameraGeocentricNormal.normalize();\r\n }\r\n }\r\n}\r\n\r\nconst ComputeCosHorizonAngleFromZenith = (planetRadius: number, radius: number): number => {\r\n const sinHorizonAngleFromNadir = Math.min(1, planetRadius / radius);\r\n const cosHorizonAngleFromNadir = Math.sqrt(1 - sinHorizonAngleFromNadir * sinHorizonAngleFromNadir);\r\n const cosHorizonAngleFromZenith = -cosHorizonAngleFromNadir;\r\n return cosHorizonAngleFromZenith;\r\n};\r\n","// Copyright (c) Microsoft Corporation.\r\n// MIT License\r\n\r\nimport type { IAtmospherePhysicalPropertiesOptions } from \"./atmospherePhysicalPropertiesOptions\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\n\r\nconst DefaultPlanetRadius = 6360.0;\r\nconst DefaultPlanetRadiusOffset = 0.01;\r\nconst DefaultAtmosphereThickness = 100.0;\r\n\r\n// The scattering and absorption values are per kilometer measured at sea level.\r\nconst DefaultPeakRayleighScattering = new Vector3(0.005802, 0.013558, 0.0331);\r\nconst DefaultPeakMieScattering = new Vector3(0.003996, 0.003996, 0.003996);\r\nconst DefaultPeakMieAbsorption = new Vector3(0.000444, 0.000444, 0.000444);\r\nconst DefaultPeakOzoneAbsorption = new Vector3(0.00065, 0.001881, 0.000085);\r\n\r\n/**\r\n * Describes the physical properties of the atmosphere. Assumes a spherical planet.\r\n * - \"radius\" values describe a distance from the planet's center.\r\n * - \"height\" values describe a distance from the planet's surface.\r\n * - Distances are in kilometers unless otherwise specified. Angles are in radians.\r\n */\r\nexport class AtmospherePhysicalProperties {\r\n /**\r\n * Notification for when properties of the {@link AtmospherePhysicalProperties} are changed.\r\n */\r\n public readonly onChangedObservable = new Observable<AtmospherePhysicalProperties>();\r\n\r\n private _planetRadius: number;\r\n private _planetRadiusOffset: number;\r\n private _atmosphereThickness: number;\r\n private _rayleighScatteringScale: number;\r\n private _peakRayleighScattering = new Vector3();\r\n private _mieScatteringScale: number;\r\n private _peakMieScattering = new Vector3();\r\n private _mieAbsorptionScale: number;\r\n private _peakMieAbsorption = new Vector3();\r\n private _ozoneAbsorptionScale: number;\r\n private _peakOzoneAbsorption = new Vector3();\r\n\r\n // Inferred values.\r\n private _planetRadiusWithOffset = 0;\r\n private _planetRadiusSquared = 0;\r\n private _atmosphereRadius = 0;\r\n private _atmosphereRadiusSquared = 0;\r\n private _horizonDistanceToAtmosphereEdge = 0;\r\n private _horizonDistanceToAtmosphereEdgeSquared = 0;\r\n private _rayleighScattering = new Vector3();\r\n private _mieScattering = new Vector3();\r\n private _mieAbsorption = new Vector3();\r\n private _mieExtinction = new Vector3();\r\n private _ozoneAbsorption = new Vector3();\r\n\r\n /**\r\n * The radius of the planet in kilometers.\r\n */\r\n public get planetRadius(): number {\r\n return this._planetRadius;\r\n }\r\n public set planetRadius(value: number) {\r\n if (this._planetRadius !== value) {\r\n this._planetRadius = value;\r\n this._recomputeDimensionalParameters();\r\n this.onChangedObservable.notifyObservers(this);\r\n }\r\n }\r\n\r\n /**\r\n * The squared radius of the planet in kilometers.\r\n */\r\n public get planetRadiusSquared(): number {\r\n return this._planetRadiusSquared;\r\n }\r\n\r\n /**\r\n * Offset applied to view points near the planet's surface. This should be greater than 0.\r\n * It prevents rendering issues close to the planet's surface.\r\n */\r\n public get planetRadiusOffset(): number {\r\n return this._planetRadiusOffset;\r\n }\r\n public set planetRadiusOffset(value: number) {\r\n if (this._planetRadiusOffset !== value) {\r\n this._planetRadiusOffset = value;\r\n this._recomputeDimensionalParameters();\r\n this.onChangedObservable.notifyObservers(this);\r\n }\r\n }\r\n\r\n /**\r\n * This is the {@link planetRadius} with the additional {@link planetRadiusOffset}, in kilometers.\r\n */\r\n public get planetRadiusWithOffset(): number {\r\n return this._planetRadiusWithOffset;\r\n }\r\n\r\n /**\r\n * The thickness of the atmosphere measured in kilometers.\r\n */\r\n public get atmosphereThickness(): number {\r\n return this._atmosphereThickness;\r\n }\r\n public set atmosphereThickness(value: number) {\r\n if (this._atmosphereThickness !== value) {\r\n this._atmosphereThickness = value;\r\n this._recomputeDimensionalParameters();\r\n this.onChangedObservable.notifyObservers(this);\r\n }\r\n }\r\n\r\n /**\r\n * The combined planet radius and atmosphere thickness in kilometers.\r\n */\r\n public get atmosphereRadius(): number {\r\n return this._atmosphereRadius;\r\n }\r\n\r\n /**\r\n * The atmosphere radius squared in kilometers.\r\n */\r\n public get atmosphereRadiusSquared(): number {\r\n return this._atmosphereRadiusSquared;\r\n }\r\n\r\n /**\r\n * Horizon distance from the planet's surface to the outer edge of the atmosphere in kilometers.\r\n */\r\n public get horizonDistanceToAtmosphereEdge(): number {\r\n return this._horizonDistanceToAtmosphereEdge;\r\n }\r\n\r\n /**\r\n * Horizon distance from the planet's surface to the outer edge of the atmosphere, squared, in kilometers.\r\n */\r\n public get horizonDistanceToAtmosphereEdgeSquared(): number {\r\n return this._horizonDistanceToAtmosphereEdgeSquared;\r\n }\r\n\r\n /**\r\n * The scale applied to {@link peakRayleighScattering}.\r\n */\r\n public get rayleighScatteringScale(): number {\r\n return this._rayleighScatteringScale;\r\n }\r\n public set rayleighScatteringScale(value: number) {\r\n if (this._rayleighScatteringScale !== value) {\r\n this._rayleighScatteringScale = value;\r\n this._recomputeRayleighScattering();\r\n this.onChangedObservable.notifyObservers(this);\r\n }\r\n }\r\n\r\n /**\r\n * The Rayleigh scattering per kilometer at sea level for red, green, and blue wavelengths.\r\n */\r\n public get peakRayleighScattering(): Vector3 {\r\n return this._peakRayleighScattering;\r\n }\r\n public set peakRayleighScattering(value: Vector3) {\r\n if (!this._peakRayleighScattering.equals(value)) {\r\n this._peakRayleighScattering.copyFrom(value);\r\n this._recomputeRayleighScattering();\r\n this.onChangedObservable.notifyObservers(this);\r\n }\r\n }\r\n\r\n /**\r\n * The Rayleigh scattering per kilometer at sea level for red, green, and blue wavelengths.\r\n * This value cannot be set directly. It is inferred by scaling {@link peakRayleighScattering} by {@link rayleighScatteringScale}.\r\n */\r\n public get rayleighScattering(): Vector3 {\r\n return this._rayleighScattering;\r\n }\r\n\r\n /**\r\n * The scale applied to {@link peakMieScattering}.\r\n */\r\n public get mieScatteringScale(): number {\r\n return this._mieScatteringScale;\r\n }\r\n public set mieScatteringScale(value: number) {\r\n if (this._mieScatteringScale !== value) {\r\n this._mieScatteringScale = value;\r\n this._recomputeMieScattering();\r\n this.onChangedObservable.notifyObservers(this);\r\n }\r\n }\r\n\r\n /**\r\n * The Mie scattering per kilometer at sea level for red, green, and blue wavelengths.\r\n */\r\n public get peakMieScattering(): Vector3 {\r\n return this._peakMieScattering;\r\n }\r\n public set peakMieScattering(value: Vector3) {\r\n if (!this._peakMieScattering.equals(value)) {\r\n this._peakMieScattering.copyFrom(value);\r\n this._recomputeMieScattering();\r\n this.onChangedObservable.notifyObservers(this);\r\n }\r\n }\r\n\r\n /**\r\n * The Mie scattering per kilometer at sea level for red, green, and blue wavelengths.\r\n * This value cannot be set directly. It is inferred by scaling {@link mieScatteringScale} by {@link peakMieScattering}.\r\n */\r\n public get mieScattering(): Vector3 {\r\n return this._mieScattering;\r\n }\r\n\r\n /**\r\n * The scale applied to {@link peakMieAbsorption}.\r\n */\r\n public get mieAbsorptionScale(): number {\r\n return this._mieAbsorptionScale;\r\n }\r\n public set mieAbsorptionScale(value: number) {\r\n if (this._mieAbsorptionScale !== value) {\r\n this._mieAbsorptionScale = value;\r\n this._recomputeMieAbsorption();\r\n this.onChangedObservable.notifyObservers(this);\r\n }\r\n }\r\n\r\n /**\r\n * The Mie absorption per kilometer at sea level for red, green, and blue wavelengths.\r\n */\r\n public get peakMieAbsorption(): Vector3 {\r\n return this._peakMieAbsorption;\r\n }\r\n public set peakMieAbsorption(value: Vector3) {\r\n if (!this._peakMieAbsorption.equals(value)) {\r\n this._peakMieAbsorption.copyFrom(value);\r\n this._recomputeMieAbsorption();\r\n this.onChangedObservable.notifyObservers(this);\r\n }\r\n }\r\n\r\n /**\r\n * The Mie absorption per kilometer at sea level for red, green, and blue wavelengths.\r\n * This value cannot be set directly. It is inferred by scaling {@link mieAbsorptionScale} by {@link peakMieAbsorption}.\r\n */\r\n public get mieAbsorption(): Vector3 {\r\n return this._mieAbsorption;\r\n }\r\n\r\n /**\r\n * The Mie extinction per kilometer at sea level for red, green, and blue wavelengths.\r\n * This value cannot be set directly. It is inferred by adding the {@link mieAbsorption} to the {@link mieScattering}.\r\n */\r\n public get mieExtinction(): Vector3 {\r\n return this._mieExtinction;\r\n }\r\n\r\n /**\r\n * The scale applied to {@link peakOzoneAbsorption}.\r\n */\r\n public get ozoneAbsorptionScale(): number {\r\n return this._ozoneAbsorptionScale;\r\n }\r\n public set ozoneAbsorptionScale(value: number) {\r\n if (this._ozoneAbsorptionScale !== value) {\r\n this._ozoneAbsorptionScale = value;\r\n this._recomputeOzoneAbsorption();\r\n this.onChangedObservable.notifyObservers(this);\r\n }\r\n }\r\n\r\n /**\r\n * The ozone absorption per kilometer measured at a height corresponding to it's peak concentration,\r\n * for red, green, and blue wavelengths.\r\n */\r\n public get peakOzoneAbsorption(): Vector3 {\r\n return this._peakOzoneAbsorption;\r\n }\r\n public set peakOzoneAbsorption(value: Vector3) {\r\n if (!this._peakOzoneAbsorption.equals(value)) {\r\n this._peakOzoneAbsorption.copyFrom(value);\r\n this._recomputeOzoneAbsorption();\r\n this.onChangedObservable.notifyObservers(this);\r\n }\r\n }\r\n\r\n /**\r\n * The ozone absorption per kilometer at sea level for red, green, and blue wavelengths.\r\n * This value cannot be set directly. It is inferred by scaling {@link peakOzoneAbsorption} by {@link ozoneAbsorptionScale}.\r\n */\r\n public get ozoneAbsorption(): Vector3 {\r\n return this._ozoneAbsorption;\r\n }\r\n\r\n /**\r\n * Constructs the {@link AtmospherePhysicalProperties}.\r\n * @param options - The options for the {@link AtmospherePhysicalProperties}.\r\n */\r\n constructor(options?: IAtmospherePhysicalPropertiesOptions) {\r\n this._planetRadius = options?.planetRadius ?? DefaultPlanetRadius;\r\n this._planetRadiusOffset = options?.planetRadiusOffset ?? DefaultPlanetRadiusOffset;\r\n this._atmosphereThickness = options?.atmosphereThickness ?? DefaultAtmosphereThickness;\r\n this._rayleighScatteringScale = options?.rayleighScatteringScale ?? 1.0;\r\n this._peakRayleighScattering.copyFrom(options?.peakRayleighScattering ?? DefaultPeakRayleighScattering);\r\n this._mieScatteringScale = options?.mieScatteringScale ?? 1.0;\r\n this._peakMieScattering.copyFrom(options?.peakMieScattering ?? DefaultPeakMieScattering);\r\n this._mieAbsorptionScale = options?.mieAbsorptionScale ?? 1.0;\r\n this._peakMieAbsorption.copyFrom(options?.peakMieAbsorption ?? DefaultPeakMieAbsorption);\r\n this._ozoneAbsorptionScale = options?.ozoneAbsorptionScale ?? 1.0;\r\n this._peakOzoneAbsorption.copyFrom(options?.peakOzoneAbsorption ?? DefaultPeakOzoneAbsorption);\r\n\r\n // Compute inferred values.\r\n this._recomputeDimensionalParameters();\r\n this._recomputeRayleighScattering();\r\n this._recomputeMieScattering();\r\n this._recomputeMieAbsorption();\r\n this._recomputeOzoneAbsorption();\r\n }\r\n\r\n private _recomputeDimensionalParameters(): void {\r\n this._planetRadiusWithOffset = this._planetRadius + this._planetRadiusOffset;\r\n this._planetRadiusSquared = this._planetRadius * this._planetRadius;\r\n this._atmosphereRadius = this._planetRadius + this._atmosphereThickness;\r\n this._atmosphereRadiusSquared = this._atmosphereRadius * this._atmosphereRadius;\r\n this._horizonDistanceToAtmosphereEdgeSquared = this._atmosphereRadiusSquared - this._planetRadiusSquared;\r\n this._horizonDistanceToAtmosphereEdge = Math.sqrt(this._horizonDistanceToAtmosphereEdgeSquared);\r\n }\r\n\r\n private _recomputeRayleighScattering(): void {\r\n this._peakRayleighScattering.scaleToRef(this._rayleighScatteringScale, this._rayleighScattering);\r\n }\r\n\r\n private _recomputeMieScattering(): void {\r\n this._peakMieScattering.scaleToRef(this._mieScatteringScale, this._mieScattering);\r\n this._recomputeMieExtinction();\r\n }\r\n\r\n private _recomputeMieAbsorption(): void {\r\n this._peakMieAbsorption.scaleToRef(this._mieAbsorptionScale, this._mieAbsorption);\r\n this._recomputeMieExtinction();\r\n }\r\n\r\n private _recomputeMieExtinction(): void {\r\n this._mieAbsorption.addToRef(this._mieScattering, this._mieExtinction);\r\n }\r\n\r\n private _recomputeOzoneAbsorption(): void {\r\n this._peakOzoneAbsorption.scaleToRef(this._ozoneAbsorptionScale, this._ozoneAbsorption);\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation.\r\n// MIT License\r\n\r\nimport { Clamp } from \"core/Maths/math.scalar.functions\";\r\nimport type { IColor4Like } from \"core/Maths/math.like\";\r\n\r\nconst MakeTempColor4Like = (): IColor4Like => {\r\n return {\r\n r: Number.NaN,\r\n g: Number.NaN,\r\n b: Number.NaN,\r\n a: Number.NaN,\r\n };\r\n};\r\n\r\nconst TmpColor1 = MakeTempColor4Like();\r\nconst TmpColor2 = MakeTempColor4Like();\r\nconst TmpColor3 = MakeTempColor4Like();\r\nconst TmpColor4 = MakeTempColor4Like();\r\n\r\n/**\r\n * Samples the texture data at the given uv coordinate using bilinear interpolation.\r\n * Note this will not match GPU sampling behavior exactly.\r\n * Currently assumes clamping behavior.\r\n * @param u - The u coordinate to sample.\r\n * @param v - The v coordinate to sample.\r\n * @param widthPx - The width of the texture in texels.\r\n * @param heightPx - The height of the texture in texels.\r\n * @param data - The texture data to sample.\r\n * @param result - The color to store the sample.\r\n * @param normalizeFunc - The function to normalize the texel values. Default is to divide by 255.\r\n * @returns The result color.\r\n */\r\nexport const Sample2DRgbaToRef = <T extends IColor4Like>(\r\n u: number,\r\n v: number,\r\n widthPx: number,\r\n heightPx: number,\r\n data: Uint8Array | Uint16Array | Float32Array,\r\n result: T,\r\n normalizeFunc = (value: number) => value / 255.0\r\n): T => {\r\n // Default to clamping behavior, but could support others.\r\n u = Clamp(u);\r\n v = Clamp(v);\r\n\r\n // Compute 4 nearest neighbor texels.\r\n const fractionalTexelX = Math.max(u * widthPx - 0.5, 0);\r\n const fractionalTexelY = Math.max(v * heightPx - 0.5, 0);\r\n const xLeft = Math.floor(fractionalTexelX);\r\n const xRight = Math.min(xLeft + 1, widthPx - 1);\r\n const yBottom = Math.floor(fractionalTexelY);\r\n const yTop = Math.min(yBottom + 1, heightPx - 1);\r\n\r\n // Sample nearest neighbor texels.\r\n const lowerLeftColor = TexelFetch2DRgbaToRef(xLeft, yBottom, widthPx, heightPx, data, TmpColor1, normalizeFunc);\r\n const upperLeftColor = TexelFetch2DRgbaToRef(xLeft, yTop, widthPx, heightPx, data, TmpColor2, normalizeFunc);\r\n const lowerRightColor = TexelFetch2DRgbaToRef(xRight, yBottom, widthPx, heightPx, data, TmpColor3, normalizeFunc);\r\n const upperRightColor = TexelFetch2DRgbaToRef(xRight, yTop, widthPx, heightPx, data, TmpColor4, normalizeFunc);\r\n\r\n // Compute weights.\r\n const tX = fractionalTexelX - xLeft;\r\n const tY = fractionalTexelY - yBottom;\r\n const oneMinusTX = 1.0 - tX;\r\n const oneMinusTY = 1.0 - tY;\r\n const w0 = oneMinusTX * oneMinusTY;\r\n const w1 = tX * oneMinusTY;\r\n const w2 = oneMinusTX * tY;\r\n const w3 = tX * tY;\r\n\r\n // Compute the result.\r\n result.r = lowerLeftColor.r * w0 + lowerRightColor.r * w1 + upperLeftColor.r * w2 + upperRightColor.r * w3;\r\n result.g = lowerLeftColor.g * w0 + lowerRightColor.g * w1 + upperLeftColor.g * w2 + upperRightColor.g * w3;\r\n result.b = lowerLeftColor.b * w0 + lowerRightColor.b * w1 + upperLeftColor.b * w2 + upperRightColor.b * w3;\r\n result.a = lowerLeftColor.a * w0 + lowerRightColor.a * w1 + upperLeftColor.a * w2 + upperRightColor.a * w3;\r\n return result;\r\n};\r\n\r\n/**\r\n * Fetches a texel from a 2D texture and stores the result in the given color.\r\n * @param x - The x coordinate in texels.\r\n * @param y - The y coordinate in texels.\r\n * @param width - The width of the texture in texels.\r\n * @param height - The height of the texture in texels.\r\n * @param data - The texture data to sample from.\r\n * @param result - The color to store the sampled color in.\r\n * @param normalizeFunc - The function to normalize the texel values. Default is to divide by 255.\r\n * @returns The result color.\r\n */\r\nconst TexelFetch2DRgbaToRef = <T extends IColor4Like>(\r\n x: number,\r\n y: number,\r\n width: number,\r\n height: number,\r\n data: Uint8Array | Uint16Array | Float32Array,\r\n result: T,\r\n normalizeFunc = (value: number) => value / 255.0\r\n): T => {\r\n const clampedTexelX = Clamp(x, 0, width - 1);\r\n const clampedTexelY = Clamp(y, 0, height - 1);\r\n const index = 4 * (clampedTexelY * width + clampedTexelX);\r\n result.r = normalizeFunc(data[index]);\r\n result.g = normalizeFunc(data[index + 1]);\r\n result.b = normalizeFunc(data[index + 2]);\r\n result.a = normalizeFunc(data[index + 3]);\r\n return result;\r\n};\r\n","// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\n\nconst name = \"atmosphereFragmentDeclaration\";\nconst shader = `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`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStore[name]) {\n ShaderStore.IncludesShadersStore[name] = shader;\n}\n/** @internal */\nexport const atmosphereFragmentDeclaration = { name, shader };\n","// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\n\nconst name = \"atmosphereUboDeclaration\";\nconst shader = `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`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStore[name]) {\n ShaderStore.IncludesShadersStore[name] = shader;\n}\n/** @internal */\nexport const atmosphereUboDeclaration = { name, shader };\n","// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\n\nconst name = \"depthFunctions\";\nconst shader = `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);}`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStore[name]) {\n ShaderStore.IncludesShadersStore[name] = shader;\n}\n/** @internal */\nexport const depthFunctions = { name, shader };\n","// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\nimport \"core/Shaders/ShadersInclude/intersectionFunctions\";\n\nconst name = \"atmosphereFunctions\";\nconst shader = `#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`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStore[name]) {\n ShaderStore.IncludesShadersStore[name] = shader;\n}\n/** @internal */\nexport const atmosphereFunctions = { name, shader };\n","// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\nimport \"../Shaders/ShadersInclude/atmosphereFragmentDeclaration\";\nimport \"../Shaders/ShadersInclude/atmosphereUboDeclaration\";\nimport \"core/Shaders/ShadersInclude/helperFunctions\";\nimport \"../Shaders/ShadersInclude/depthFunctions\";\nimport \"../Shaders/ShadersInclude/atmosphereFunctions\";\nimport \"core/Shaders/ShadersInclude/importanceSampling\";\nimport \"core/Shaders/ShadersInclude/pbrBRDFFunctions\";\nimport \"core/Shaders/ShadersInclude/hdrFilteringFunctions\";\n\nconst name = \"diffuseSkyIrradiancePixelShader\";\nconst shader = `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.);}`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const diffuseSkyIrradiancePixelShader = { name, shader };\n","// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\nimport \"../Shaders/ShadersInclude/atmosphereFragmentDeclaration\";\nimport \"../Shaders/ShadersInclude/atmosphereUboDeclaration\";\n\nconst name = \"fullscreenTriangleVertexShader\";\nconst shader = `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}`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const fullscreenTriangleVertexShader = { name, shader };\n","// Copyright (c) Microsoft Corporation.\r\n// MIT License\r\n\r\nimport type { Atmosphere } from \"./atmosphere\";\r\nimport type { AtmospherePhysicalProperties } from \"./atmospherePhysicalProperties\";\r\nimport { Clamp } from \"core/Maths/math.scalar.functions\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { EffectRenderer, EffectWrapper } from \"core/Materials/effectRenderer\";\r\nimport { FromHalfFloat } from \"core/Misc/textureTools\";\r\nimport type { IColor3Like, IColor4Like, IVector2Like, IVector3Like } from \"core/Maths/math.like\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { RenderTargetTexture } from \"core/Materials/Textures/renderTargetTexture\";\r\nimport { Sample2DRgbaToRef } from \"./sampling\";\r\nimport \"./Shaders/diffuseSkyIrradiance.fragment\";\r\nimport \"./Shaders/fullscreenTriangle.vertex\";\r\n\r\nconst RaySamples = 128;\r\nconst LutWidthPx = 64;\r\nconst LutHeightPx = 16;\r\nconst HalfTexelSize = { x: 0.5 / LutWidthPx, y: 0.5 / LutHeightPx };\r\nconst UnitToUVScale = { x: (LutWidthPx - 1.0) / LutWidthPx, y: (LutHeightPx - 1.0) / LutHeightPx };\r\nconst UvTemp = { x: Number.NaN, y: Number.NaN };\r\nconst Color4Temp = { r: Number.NaN, g: Number.NaN, b: Number.NaN, a: Number.NaN } as IColor4Like;\r\n\r\nconst ComputeLutUVToRef = (properties: AtmospherePhysicalProperties, radius: number, cosAngleLightToZenith: number, result: IVector2Like): void => {\r\n const unitX = Clamp(0.5 + 0.5 * cosAngleLightToZenith);\r\n const unitY = Clamp((radius - properties.planetRadius) / properties.atmosphereThickness);\r\n result.x = unitX * UnitToUVScale.x + HalfTexelSize.x;\r\n result.y = unitY * UnitToUVScale.y + HalfTexelSize.y;\r\n};\r\n\r\n/**\r\n * The diffuse sky irradiance LUT is used to query the diffuse irradiance at a specified position.\r\n */\r\nexport class DiffuseSkyIrradianceLut {\r\n private readonly _atmosphere: Atmosphere;\r\n private _renderTarget: Nullable<RenderTargetTexture> = null;\r\n private _effectWrapper: Nullable<EffectWrapper> = null;\r\n private _effectRenderer: Nullable<EffectRenderer> = null;\r\n private _isDirty = true;\r\n private _isDisposed = false;\r\n private _lutData: Uint8Array | Uint16Array = new Uint16Array(0);\r\n\r\n /**\r\n * True if the LUT needs to be rendered.\r\n */\r\n public get isDirty() {\r\n return this._isDirty;\r\n }\r\n\r\n /**\r\n * True if the LUT has been disposed.\r\n */\r\n public get isDisposed(): boolean {\r\n return this._isDisposed;\r\n }\r\n\r\n /**\r\n * The render target used for this LUT.\r\n * @throws if the LUT has been disposed.\r\n */\r\n public get renderTarget(): RenderTargetTexture {\r\n if (this._isDisposed || this._renderTarget === null) {\r\n throw new Error();\r\n }\r\n return this._renderTarget;\r\n }\r\n\r\n /**\r\n * True if the LUT data has been read back from the GPU.\r\n */\r\n public get hasLutData(): boolean {\r\n return this._lutData[0] !== undefined;\r\n }\r\n\r\n /**\r\n * Constructs the {@link DiffuseSkyIrradianceLut}.\r\n * @param atmosphere - The atmosphere to use.\r\n */\r\n constructor(atmosphere: Atmosphere) {\r\n this._atmosphere = atmosphere;\r\n const scene = atmosphere.scene;\r\n const engine = scene.getEngine();\r\n\r\n const name = \"atmo-diffuseSkyIrradiance\";\r\n const renderTarget = (this._renderTarget = new RenderTargetTexture(name, { width: LutWidthPx, height: LutHeightPx }, scene, {\r\n generateMipMaps: false,\r\n type: Constants.TEXTURETYPE_HALF_FLOAT,\r\n samplingMode: Constants.TEXTURE_BILINEAR_SAMPLINGMODE,\r\n generateDepthBuffer: false,\r\n gammaSpace: false,\r\n }));\r\n renderTarget.wrapU = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n renderTarget.wrapV = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n renderTarget.anisotropicFilteringLevel = 1;\r\n renderTarget.skipInitialClear = true;\r\n\r\n const useUbo = atmosphere.uniformBuffer.useUbo;\r\n\r\n this._effectWrapper = new EffectWrapper({\r\n engine,\r\n name,\r\n vertexShader: \"fullscreenTriangle\",\r\n fragmentShader: \"diffuseSkyIrradiance\",\r\n attributeNames: [\"position\"],\r\n uniformNames: [\"depth\", ...(useUbo ? [] : atmosphere.uniformBuffer.getUniformNames())],\r\n uniformBuffers: useUbo ? [atmosphere.uniformBuffer.name] : [],\r\n defines: [\r\n \"#define POSITION_VEC2\",\r\n `#define NUM_SAMPLES ${RaySamples}u`,\r\n \"#define CUSTOM_IRRADIANCE_FILTERING_INPUT /* empty */\", // empty, no input texture needed as the radiance is procedurally generated from ray marching.\r\n // The following ray marches the atmosphere to get the radiance.\r\n \"#define CUSTOM_IRRADIANCE_FILTERING_FUNCTION vec3 c = integrateForIrradiance(n, Ls, vec3(0., filteringInfo.x, 0.));\",\r\n ],\r\n samplers: [\"transmittanceLut\", \"multiScatteringLut\"],\r\n useShaderStore: true,\r\n });\r\n\r\n this._effectRenderer = new EffectRenderer(engine, {\r\n // Full screen triangle.\r\n indices: [0, 2, 1],\r\n positions: [-1, -1, -1, 3, 3, -1],\r\n });\r\n\r\n // The sky irradiance will also be used for the environment texture.\r\n scene.environmentTexture = renderTarget;\r\n scene.environmentTexture.irradianceTexture = renderTarget;\r\n scene.environmentIntensity = 1.0;\r\n\r\n // Prevent the irradiance LUT from being rendered redundantly at the beginning of the frame.\r\n scene.environmentTexture.isRenderTarget = false;\r\n }\r\n\r\n /**\r\n * Gets the diffuse sky irradiance for a surface oriented along the geocentric normal.\r\n * Resulting color is always in linear space.\r\n * @param directionToLight - The direction to the light in world space.\r\n * @param radius - The position's distance to the planet origin.\r\n * @param cameraGeocentricNormal - The geocentric normal of the camera.\r\n * @param lightIrradiance - The irradiance of the light.\r\n * @param result - The color to store the result in.\r\n * @returns The result color.\r\n */\r\n public getDiffuseSkyIrradianceToRef<T extends IColor3Like>(\r\n directionToLight: IVector3Like,\r\n radius: number,\r\n cameraGeocentricNormal: IVector3Like,\r\n lightIrradiance: number,\r\n result: T\r\n ): T {\r\n const atmosphere = this._atmosphere;\r\n const additionalDiffuseSkyIrradiance = atmosphere.additionalDiffuseSkyIrradiance;\r\n\r\n const properties = atmosphere.physicalProperties;\r\n if (this._lutData[0] === undefined || radius > properties.atmosphereRadius) {\r\n result.r = additionalDiffuseSkyIrradiance.r;\r\n result.g = additionalDiffuseSkyIrradiance.g;\r\n result.b = additionalDiffuseSkyIrradiance.b;\r\n return result;\r\n }\r\n\r\n const cosAngleLightToZenith = directionToLight.x * cameraGeocentricNormal.x + directionToLight.y * cameraGeocentricNormal.y + directionToLight.z * cameraGeocentricNormal.z;\r\n ComputeLutUVToRef(properties, radius, cosAngleLightToZenith, UvTemp);\r\n Sample2DRgbaToRef(UvTemp.x, UvTemp.y, LutWidthPx, LutHeightPx, this._lutData, Color4Temp, FromHalfFloat);\r\n\r\n const intensity = atmosphere.diffuseSkyIrradianceIntensity;\r\n result.r = intensity * (lightIrradiance * Color4Temp.r + additionalDiffuseSkyIrradiance.r);\r\n result.g = intensity * (lightIrradiance * Color4Temp.g + additionalDiffuseSkyIrradiance.g);\r\n result.b = intensity * (lightIrradiance * Color4Temp.b + additionalDiffuseSkyIrradiance.b);\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Renders the LUT.\r\n * @returns True if the LUT was rendered.\r\n */\r\n public render(): boolean {\r\n // Only need to render the LUT once.\r\n const effectWrapper = this._effectWrapper;\r\n if (!this._isDirty || !effectWrapper?.isReady() || !this._renderTarget?.isReady()) {\r\n return false;\r\n }\r\n\r\n const engine = this._atmosphere.scene.getEngine();\r\n\r\n engine.bindFramebuffer(this.renderTarget.renderTarget!, undefined, undefined, undefined, true);\r\n\r\n const effectRenderer = this._effectRenderer!;\r\n effectRenderer.applyEffectWrapper(effectWrapper);\r\n\r\n effectRenderer.saveStates();\r\n effectRenderer.setViewport();\r\n\r\n const effect = effectWrapper.effect;\r\n effectRenderer.bindBuffers(effect);\r\n\r\n effect.setTexture(\"transmittanceLut\", this._atmosphere.transmittanceLut!.renderTarget);\r\n effect.setTexture(\"multiScatteringLut\", this._atmosphere.multiScatteringLutRenderTarget);\r\n\r\n this._atmosphere.bindUniformBufferToEffect(effect);\r\n\r\n effect.setFloat(\"depth\", 0.0);\r\n\r\n effectRenderer.draw();\r\n\r\n effectRenderer.restoreStates();\r\n engine.restoreDefaultFramebuffer();\r\n\r\n this._isDirty = false;\r\n\r\n // eslint-disable-next-line github/no-then\r\n void this.renderTarget.readPixels(0, 0, undefined, undefined, true /* noDataConversion */)?.then((value: ArrayBufferView) => {\r\n if (this._isDisposed) {\r\n return;\r\n }\r\n this._lutData = value as Uint8Array | Uint16Array;\r\n });\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Marks the LUT as needing to be rendered.\r\n */\r\n public markDirty(): void {\r\n this._isDirty = true;\r\n }\r\n\r\n /**\r\n * Disposes the LUT.\r\n */\r\n public dispose() {\r\n if (this._renderTarget) {\r\n this._renderTarget.irradianceTexture = null;\r\n this._renderTarget.dispose();\r\n }\r\n this._renderTarget = null;\r\n this._effectWrapper?.dispose();\r\n this._effectWrapper = null;\r\n this._effectRenderer?.dispose();\r\n this._effectRenderer = null;\r\n this._isDisposed = true;\r\n }\r\n}\r\n","// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\nimport \"../Shaders/ShadersInclude/atmosphereFragmentDeclaration\";\nimport \"../Shaders/ShadersInclude/atmosphereUboDeclaration\";\nimport \"core/Shaders/ShadersInclude/helperFunctions\";\nimport \"../Shaders/ShadersInclude/atmosphereFunctions\";\n\nconst name = \"transmittancePixelShader\";\nconst shader = `#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);}`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const transmittancePixelShader = { name, shader };\n","// Copyright (c) Microsoft Corporation.\r\n// MIT License\r\n\r\nimport type { Atmosphere } from \"./atmosphere\";\r\nimport type { AtmospherePhysicalProperties } from \"./atmospherePhysicalProperties\";\r\nimport { Clamp, SmoothStep } from \"core/Maths/math.scalar.functions\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport type { DirectionalLight } from \"core/Lights/directionalLight\";\r\nimport { EffectRenderer, EffectWrapper } from \"core/Materials/effectRenderer\";\r\nimport { FromHalfFloat } from \"core/Misc/textureTools\";\r\nimport type { IColor3Like, IColor4Like, IVector2Like, IVector3Like } from \"core/Maths/math.like\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { RenderTargetTexture } from \"core/Materials/Textures/renderTargetTexture\";\r\nimport { Sample2DRgbaToRef } from \"./sampling\";\r\nimport \"./Shaders/fullscreenTriangle.vertex\";\r\nimport \"./Shaders/transmittance.fragment\";\r\n\r\nconst LutWidthPx = 256;\r\nconst LutHeightPx = 64;\r\nconst EffectiveDomainInUVSpace = { x: (LutWidthPx - 1.0) / LutWidthPx, y: (LutHeightPx - 1.0) / LutHeightPx };\r\nconst HalfTexelSize = { x: 0.5 / LutWidthPx, y: 0.5 / LutHeightPx };\r\nconst TransmittanceHorizonRange = 2.0 * HalfTexelSize.x;\r\nconst TransmittanceMaxUnoccludedU = 1.0 - 0.5 * TransmittanceHorizonRange;\r\n\r\nconst UseHalfFloat = false;\r\n\r\n// Temporary storage.\r\nconst Uv = { x: Number.NaN, y: Number.NaN } as IVector2Like;\r\nconst LightColorTemp = { r: Number.NaN, g: Number.NaN, b: Number.NaN } as IColor3Like;\r\nconst DirectionToLightTemp = { x: Number.NaN, y: Number.NaN, z: Number.NaN } as IVector3Like;\r\nconst Color4Temp = { r: Number.NaN, g: Number.NaN, b: Number.NaN, a: Number.NaN } as IColor4Like;\r\n\r\nconst ComputeLutUVToRef = (properties: AtmospherePhysicalProperties, radius: number, cosAngleLightToZenith: number, uv: IVector2Like): void => {\r\n const radiusSquared = radius * radius;\r\n const distanceToHorizon = Math.sqrt(Math.max(0.0, radiusSquared - properties.planetRadiusSquared));\r\n\r\n const cosAngleLightToZenithSq = cosAngleLightToZenith * cosAngleLightToZenith;\r\n const discriminant = radiusSquared * (cosAngleLightToZenithSq - 1.0) + properties.atmosphereRadiusSquared;\r\n const distanceToAtmosphereEdge = Math.max(0.0, -radius * cosAngleLightToZenith + Math.sqrt(Math.max(0.0, discriminant)));\r\n\r\n const minDistanceToAtmosphereEdge = Math.max(0.0, properties.atmosphereRadius - radius);\r\n const maxDistanceToAtmosphereEdge = distanceToHorizon + properties.horizonDistanceToAtmosphereEdge;\r\n const cosAngleLightToZenithCoordinate =\r\n (distanceToAtmosphereEdge - minDistanceToAtmosphereEdge) / Math.max(0.000001, maxDistanceToAtmosphereEdge - minDistanceToAtmosphereEdge);\r\n const distanceToHorizonCoordinate = distanceToHorizon / Math.max(0.000001, properties.horizonDistanceToAtmosphereEdge);\r\n\r\n // Unit to UV.\r\n uv.x = EffectiveDomainInUVSpace.x * cosAngleLightToZenithCoordinate + HalfTexelSize.x;\r\n uv.y = EffectiveDomainInUVSpace.y * distanceToHorizonCoordinate + HalfTexelSize.y;\r\n};\r\n\r\nconst SampleLutToRef = (\r\n properties: AtmospherePhysicalProperties,\r\n lutData: Uint8Array | Uint16Array,\r\n positionDistanceToOrigin: number,\r\n cosAngleLightToZenith: number,\r\n result: IColor4Like\r\n): void => {\r\n if (positionDistanceToOrigin > properties.atmosphereRadius) {\r\n result.r = result.g = result.b = result.a = 1.0;\r\n return;\r\n }\r\n\r\n ComputeLutUVToRef(properties, positionDistanceToOrigin, cosAngleLightToZenith, Uv);\r\n Sample2DRgbaToRef(Uv.x, Uv.y, LutWidthPx, LutHeightPx, lutData, result, UseHalfFloat ? FromHalfFloat : (value) => value / 255.0);\r\n\r\n const weight = Clamp(SmoothStep(1.0, 0.0, Clamp((Uv.x - TransmittanceMaxUnoccludedU) / TransmittanceHorizonRange)));\r\n result.r *= weight;\r\n result.g *= weight;\r\n result.b *= weight;\r\n result.a *= weight;\r\n};\r\n\r\n/**\r\n * The transmittance LUT can be used to get the radiance from an external light source arriving a given point, accounting for atmospheric scattering.\r\n */\r\nexport class TransmittanceLut {\r\n /**\r\n * Listen to this observer to know when the LUT data has been updated.\r\n * This is typically infrequent (once at startup), but also happens whenever the atmosphere's properties change.\r\n */\r\n public readonly onUpdatedObservable = new Observable<void>();\r\n\r\n private readonly _atmosphere: Atmosphere;\r\n private _lutData: Uint8Array | Uint16Array = new Uint8Array(0);\r\n private _renderTarget: Nullable<RenderTargetTexture>;\r\n private _effectWrapper: Nullable<EffectWrapper>;\r\n private _effectRenderer: Nullable<EffectRenderer>;\r\n private _isDirty = true;\r\n private _isDisposed = false;\r\n\r\n /**\r\n * True if the LUT has been rendered.\r\n */\r\n public get isDirty(): boolean {\r\n return this._isDirty;\r\n }\r\n\r\n /**\r\n * The render target that contains the transmittance LUT.\r\n * @throws if the LUT has been disposed.\r\n */\r\n public get renderTarget(): RenderTargetTexture {\r\n if (this._isDisposed || this._renderTarget === null) {\r\n throw new Error();\r\n }\r\n return this._renderTarget;\r\n }\r\n\r\n /**\r\n * Constructs the {@link TransmittanceLut}.\r\n * @param atmosphere - The atmosphere that owns this LUT.\r\n */\r\n constructor(atmosphere: Atmosphere) {\r\n this._atmosphere = atmosphere;\r\n\r\n const scene = this._atmosphere.scene;\r\n const engine = scene.getEngine();\r\n\r\n const name = \"atmo-transmittance\";\r\n const renderTarget = (this._renderTarget = new RenderTargetTexture(name, { width: LutWidthPx, height: LutHeightPx }, scene, {\r\n type: UseHalfFloat ? Constants.TEXTURETYPE_HALF_FLOAT : Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n samplingMode: Constants.TEXTURE_BILINEAR_SAMPLINGMODE,\r\n generateDepthBuffer: false,\r\n gammaSpace: false,\r\n }));\r\n renderTarget.wrapU = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n renderTarget.wrapV = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n renderTarget.anisotropicFilteringLevel = 1;\r\n renderTarget.skipInitialClear = true;\r\n\r\n const useUbo = this._atmosphere.uniformBuffer.useUbo;\r\n this._effectWrapper = new EffectWrapper({\r\n engine,\r\n name,\r\n vertexShader: \"fullscreenTriangle\",\r\n fragmentShader: \"transmittance\",\r\n attributeNames: [\"position\"],\r\n uniformNames: [\"depth\", ...(useUbo ? [] : this._atmosphere.uniformBuffer.getUniformNames())],\r\n uniformBuffers: useUbo ? [this._atmosphere.uniformBuffer.name] : [],\r\n defines: [\"#define POSITION_VEC2\"],\r\n useShaderStore: true,\r\n });\r\n\r\n this._effectRenderer = new EffectRenderer(engine, {\r\n // Full screen triangle.\r\n indices: [0, 2, 1],\r\n positions: [-1, -1, -1, 3, 3, -1],\r\n });\r\n }\r\n\r\n /**\r\n * Gets the transmittance of an external light through the atmosphere to a point specified by its distance to the planet center and its geocentric normal.\r\n * The result is always a linear space color.\r\n * @param directionToLight - The direction to the light source.\r\n * @param pointRadius - The distance from the origin to the point.\r\n * @param pointGeocentricNormal - The normal of the point.\r\n * @param result - The color to write the result to.\r\n * @returns The result color.\r\n */\r\n public getTransmittedColorToRef<T extends IColor3Like>(directionToLight: IVector3Like, pointRadius: number, pointGeocentricNormal: IVector3Like, result: T): T {\r\n if (this._lutData[0] !== undefined) {\r\n const cosAngleLightToZenith =\r\n directionToLight.x * pointGeocentricNormal.x + directionToLight.y * pointGeocentricNormal.y + directionToLight.z * pointGeocentricNormal.z;\r\n SampleLutToRef(this._atmosphere.physicalProperties, this._lutData, pointRadius, cosAngleLightToZenith, Color4Temp);\r\n result.r = Color4Temp.r;\r\n result.g = Color4Temp.g;\r\n result.b = Color4Temp.b;\r\n } else {\r\n // Fallback.\r\n result.r = result.g = result.b = 1.0;\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * Derives light color from the transmittance at a point specified by its distance to the planet center and its geocentric normal.\r\n * @param light - The light to update.\r\n * @param pointRadius - The distance from the origin to the point.\r\n * @param pointGeocentricNormal - The normal of the point.\r\n */\r\n public updateLightParameters(light: DirectionalLight, pointRadius: number, pointGeocentricNormal: IVector3Like): void {\r\n const lightDirection = light.direction;\r\n DirectionToLightTemp.x = -lightDirection.x;\r\n DirectionToLightTemp.y = -lightDirection.y;\r\n DirectionToLightTemp.z = -lightDirection.z;\r\n this.getTransmittedColorToRef(DirectionToLightTemp, pointRadius, pointGeocentricNormal, LightColorTemp);\r\n\r\n light.diffuse.copyFromFloats(LightColorTemp.r, LightColorTemp.g, LightColorTemp.b);\r\n light.specular.copyFromFloats(LightColorTemp.r, LightColorTemp.g, LightColorTemp.b);\r\n }\r\n\r\n /**\r\n * Renders the LUT if needed.\r\n * @returns true if the LUT was rendered.\r\n */\r\n public render(): boolean {\r\n // Only need to render the LUT once.\r\n const effectWrapper = this._effectWrapper;\r\n if (!this._isDirty || !effectWrapper?.isReady() || !this._renderTarget?.isReady()) {\r\n return false;\r\n }\r\n\r\n const engine = this._atmosphere.scene.getEngine();\r\n\r\n engine.bindFramebuffer(this.renderTarget.renderTarget!, undefined, undefined, undefined, true);\r\n\r\n const effectRenderer = this._effectRenderer!;\r\n effectRenderer.applyEffectWrapper(effectWrapper);\r\n\r\n effectRenderer.saveStates();\r\n effectRenderer.setViewport();\r\n\r\n const effect = effectWrapper.effect;\r\n effectRenderer.bindBuffers(effect);\r\n\r\n this._atmosphere.bindUniformBufferToEffect(effect);\r\n\r\n effect.setFloat(\"depth\", 0);\r\n\r\n effectRenderer.draw();\r\n\r\n effectRenderer.restoreStates();\r\n engine.restoreDefaultFramebuffer();\r\n\r\n this._isDirty = false;\r\n\r\n // eslint-disable-next-line github/no-then\r\n void this.renderTarget.readPixels(0, 0, undefined, undefined, UseHalfFloat /* noDataConversion */)?.then((value: ArrayBufferView) => {\r\n if (this._isDisposed) {\r\n return;\r\n }\r\n this._lutData = value as Uint8Array | Uint16Array;\r\n this.onUpdatedObservable.notifyObservers();\r\n });\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Marks the LUT as needing to be rendered.\r\n */\r\n public markDirty(): void {\r\n this._isDirty = true;\r\n }\r\n\r\n /**\r\n * Disposes the LUT and its resources.\r\n */\r\n public dispose(): void {\r\n this._renderTarget?.dispose();\r\n this._renderTarget = null;\r\n this._effectWrapper?.dispose();\r\n this._effectWrapper = null;\r\n this._effectRenderer?.dispose();\r\n this._effectRenderer = null;\r\n this._isDisposed = true;\r\n }\r\n}\r\n","// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\nimport \"../Shaders/ShadersInclude/atmosphereFragmentDeclaration\";\nimport \"../Shaders/ShadersInclude/atmosphereUboDeclaration\";\nimport \"core/Shaders/ShadersInclude/helperFunctions\";\nimport \"../Shaders/ShadersInclude/depthFunctions\";\nimport \"../Shaders/ShadersInclude/atmosphereFunctions\";\n\nconst name = \"compositeAerialPerspectivePixelShader\";\nconst shader = `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}`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const compositeAerialPerspectivePixelShader = { name, shader };\n","// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\nimport \"../Shaders/ShadersInclude/atmosphereFragmentDeclaration\";\nimport \"../Shaders/ShadersInclude/atmosphereUboDeclaration\";\nimport \"core/Shaders/ShadersInclude/helperFunctions\";\nimport \"../Shaders/ShadersInclude/depthFunctions\";\nimport \"../Shaders/ShadersInclude/atmosphereFunctions\";\n\nconst name = \"compositeSkyPixelShader\";\nconst shader = `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}`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const compositeSkyPixelShader = { name, shader };\n","// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\nimport \"../Shaders/ShadersInclude/atmosphereFragmentDeclaration\";\nimport \"../Shaders/ShadersInclude/atmosphereUboDeclaration\";\nimport \"core/Shaders/ShadersInclude/helperFunctions\";\nimport \"../Shaders/ShadersInclude/depthFunctions\";\nimport \"../Shaders/ShadersInclude/atmosphereFunctions\";\n\nconst name = \"compositeGlobeAtmospherePixelShader\";\nconst shader = `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}`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const compositeGlobeAtmospherePixelShader = { name, shader };\n","// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\nimport \"../Shaders/ShadersInclude/atmosphereFragmentDeclaration\";\nimport \"../Shaders/ShadersInclude/atmosphereUboDeclaration\";\nimport \"core/Shaders/ShadersInclude/helperFunctions\";\nimport \"../Shaders/ShadersInclude/atmosphereFunctions\";\n\nconst name = \"multiScatteringPixelShader\";\nconst shader = `#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);}`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const multiScatteringPixelShader = { name, shader };\n","// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\nimport \"../Shaders/ShadersInclude/atmosphereFragmentDeclaration\";\nimport \"../Shaders/ShadersInclude/atmosphereUboDeclaration\";\nimport \"core/Shaders/ShadersInclude/helperFunctions\";\nimport \"../Shaders/ShadersInclude/atmosphereFunctions\";\n\nconst name = \"skyViewPixelShader\";\nconst shader = `#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);}`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const skyViewPixelShader = { name, shader };\n","// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\nimport \"../Shaders/ShadersInclude/atmosphereFragmentDeclaration\";\nimport \"../Shaders/ShadersInclude/atmosphereUboDeclaration\";\nimport \"core/Shaders/ShadersInclude/helperFunctions\";\nimport \"../Shaders/ShadersInclude/atmosphereFunctions\";\n\nconst name = \"aerialPerspectivePixelShader\";\nconst shader = `#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);}`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const aerialPerspectivePixelShader = { name, shader };\n","// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\n\nconst name = \"atmosphereVertexDeclaration\";\nconst shader = `uniform mat4 inverseViewProjectionWithoutTranslation;\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStore[name]) {\n ShaderStore.IncludesShadersStore[name] = shader;\n}\n/** @internal */\nexport const atmosphereVertexDeclaration = { name, shader };\n","import type { IDisposable, Scene } from \"core/scene\";\r\nimport type { BMFontChar } from \"./sdf/bmFont\";\r\nimport type { SdfFont } from \"./sdf/font\";\r\nimport { Texture } from \"core/Materials/Textures/texture\";\r\n\r\nenum CharCode {\r\n SPACE = 32,\r\n TOFU = 0xfffc,\r\n}\r\n\r\n/**\r\n * Class representing a font asset for SDF (Signed Distance Field) rendering.\r\n */\r\nexport class FontAsset implements IDisposable {\r\n private readonly _chars = new Map<number, BMFontChar>();\r\n private readonly _charsRegex: RegExp;\r\n private readonly _kernings = new Map<number, Map<number, number>>();\r\n\r\n /** @internal */\r\n public readonly _font: SdfFont;\r\n\r\n /**\r\n * Gets the font scale value\r\n */\r\n public readonly scale: number;\r\n\r\n /**\r\n * Gets the list of used textures\r\n */\r\n public readonly textures: Texture[];\r\n\r\n /**\r\n * Creates a new FontAsset instance.\r\n * @param definitionData defines the font data in JSON format.\r\n * @param textureUrl defines the url of the texture to use for the font.\r\n * @param scene defines the hosting scene.\r\n */\r\n public constructor(definitionData: string, textureUrl: string, scene?: Scene) {\r\n this._font = JSON.parse(definitionData) as SdfFont;\r\n // So far we only consider one page\r\n this._font.pages = [textureUrl];\r\n\r\n this._font.chars.forEach((char) => this._chars.set(char.id, char));\r\n this._font.kernings.forEach((kerning) => {\r\n let submap = this._kernings.get(kerning.first);\r\n if (!submap) {\r\n submap = new Map();\r\n this._kernings.set(kerning.first, submap);\r\n }\r\n submap.set(kerning.second, kerning.amount);\r\n });\r\n this._charsRegex = new RegExp(`[${this._font.chars.map((c) => c.char.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, \"\\\\$&\")).join(\"\")}]`, \"g\");\r\n\r\n this._updateFallbacks();\r\n\r\n this.scale = 1 / this._font.info.size;\r\n this.textures = this._font.pages.map((page) => {\r\n const texture = new Texture(page, scene, { noMipmap: false, invertY: false });\r\n texture.anisotropicFilteringLevel = 16;\r\n return texture;\r\n });\r\n }\r\n\r\n dispose(): void {\r\n for (const texture of this.textures) {\r\n texture.dispose();\r\n }\r\n this.textures.length = 0;\r\n }\r\n\r\n private _updateFallbacks() {\r\n if (!this._chars.has(CharCode.SPACE)) {\r\n this._chars.set(CharCode.SPACE, {\r\n id: CharCode.SPACE,\r\n x: 0,\r\n y: 0,\r\n width: 0,\r\n height: 0,\r\n xoffset: 0,\r\n yoffset: 0,\r\n xadvance: this._font.info.size * 0.5,\r\n page: -1,\r\n chnl: -1,\r\n index: -1,\r\n char: \" \",\r\n });\r\n }\r\n\r\n if (!this._chars.has(CharCode.TOFU)) {\r\n this._chars.set(CharCode.TOFU, {\r\n id: CharCode.TOFU,\r\n x: 0,\r\n y: 0,\r\n width: this._font.info.size,\r\n height: this._font.info.size,\r\n xoffset: 0,\r\n yoffset: 0,\r\n xadvance: this._font.info.size * 0.5,\r\n page: -1,\r\n chnl: -1,\r\n index: -1,\r\n char: \"￿\",\r\n });\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _getChar(charCode: number) {\r\n return this._chars.get(charCode) || this._chars.get(CharCode.TOFU)!;\r\n }\r\n\r\n /** @internal */\r\n public _getKerning(first: number, second: number) {\r\n return this._kernings.get(first)?.get(second) || 0;\r\n }\r\n\r\n /** @internal */\r\n public _unsupportedChars(text: string) {\r\n return text.replace(this._charsRegex, \"\");\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation.\r\n// MIT License\r\n\r\nimport type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\nimport { AtmospherePBRMaterialPlugin } from \"./atmospherePBRMaterialPlugin\";\r\nimport { AtmospherePerCameraVariables } from \"./atmospherePerCameraVariables\";\r\nimport { AtmospherePhysicalProperties } from \"./atmospherePhysicalProperties\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport type { Camera } from \"core/Cameras/camera\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport type { DeepImmutable, Nullable } from \"core/types\";\r\nimport { DiffuseSkyIrradianceLut } from \"./diffuseSkyIrradianceLut\";\r\nimport type { DirectionalLight } from \"core/Lights/directionalLight\";\r\nimport type { Effect } from \"core/Materials/effect\";\r\nimport { EffectRenderer, EffectWrapper } from \"core/Materials/effectRenderer\";\r\nimport type { IAtmosphereOptions } from \"./atmosphereOptions\";\r\nimport type { IColor3Like, IVector3Like } from \"core/Maths/math.like\";\r\nimport type { IDisposable, Scene } from \"core/scene\";\r\nimport { Observable, type Observer } from \"core/Misc/observable\";\r\nimport { RegisterMaterialPlugin, UnregisterMaterialPlugin } from \"core/Materials/materialPluginManager\";\r\nimport type { RenderingGroupInfo } from \"core/Rendering/renderingManager\";\r\nimport { RenderTargetTexture, type RenderTargetTextureOptions } from \"core/Materials/Textures/renderTargetTexture\";\r\nimport type { RenderTargetWrapper } from \"core/Engines/renderTargetWrapper\";\r\nimport { TransmittanceLut } from \"./transmittanceLut\";\r\nimport { UniformBuffer } from \"core/Materials/uniformBuffer\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport \"./Shaders/compositeAerialPerspective.fragment\";\r\nimport \"./Shaders/compositeSky.fragment\";\r\nimport \"./Shaders/compositeGlobeAtmosphere.fragment\";\r\nimport \"./Shaders/fullscreenTriangle.vertex\";\r\nimport \"./Shaders/multiScattering.fragment\";\r\nimport \"./Shaders/skyView.fragment\";\r\nimport \"./Shaders/aerialPerspective.fragment\";\r\nimport \"./Shaders/ShadersInclude/atmosphereFragmentDeclaration\";\r\nimport \"./Shaders/ShadersInclude/atmosphereFunctions\";\r\nimport \"./Shaders/ShadersInclude/atmosphereUboDeclaration\";\r\nimport \"./Shaders/ShadersInclude/atmosphereVertexDeclaration\";\r\nimport \"./Shaders/ShadersInclude/depthFunctions\";\r\n\r\nconst MaterialPlugin = \"atmo-pbr\";\r\n\r\n/**\r\n * Renders a physically based atmosphere.\r\n * Use {@link IsSupported} to check if the atmosphere is supported before creating an instance.\r\n * @experimental\r\n */\r\nexport class Atmosphere implements IDisposable {\r\n private readonly _directionToLight = Vector3.Zero();\r\n private readonly _tempSceneAmbient = new Color3();\r\n private readonly _engine: AbstractEngine;\r\n private _physicalProperties: AtmospherePhysicalProperties;\r\n private _transmittanceLut: Nullable<TransmittanceLut>;\r\n private _diffuseSkyIrradianceLut: Nullable<DiffuseSkyIrradianceLut>;\r\n private _isSkyViewLutEnabled: boolean;\r\n private _isAerialPerspectiveLutEnabled: boolean;\r\n private _aerialPerspectiveTransmittanceScale: number;\r\n private _aerialPerspectiveSaturation: number;\r\n private _aerialPerspectiveIntensity: number;\r\n private _aerialPerspectiveRadianceBias: number;\r\n private _diffuseSkyIrradianceDesaturationFactor: number;\r\n private _additionalDiffuseSkyIrradianceIntensity: number;\r\n private _additionalDiffuseSkyIrradianceColor: Color3;\r\n private _additionalDiffuseSkyIrradiance = new Color3();\r\n private _diffuseSkyIrradianceIntensity: number;\r\n private _multiScatteringIntensity: number;\r\n private _groundAlbedo: Color3;\r\n private _minimumMultiScatteringColor: Color3;\r\n private _minimumMultiScatteringIntensity: number;\r\n private _lights: DirectionalLight[];\r\n private _atmosphereUbo: Nullable<UniformBuffer> = null;\r\n private _minimumMultiScattering = new Vector3();\r\n private _cameraAtmosphereVariables = new AtmospherePerCameraVariables();\r\n private _isLinearSpaceComposition: boolean;\r\n private _isLinearSpaceLight: boolean;\r\n private _lightRadianceAtCamera = new Vector3();\r\n private _linearLightColor = new Color3();\r\n private _originHeight: number;\r\n private _applyApproximateTransmittance: boolean;\r\n private _exposure: number;\r\n private _atmosphereUniformBufferAsArray: UniformBuffer[] = [];\r\n private _effectRenderer: Nullable<EffectRenderer> = null;\r\n private _skyRenderingGroup: number;\r\n private _aerialPerspectiveRenderingGroup: number;\r\n private _globeAtmosphereRenderingGroup: number;\r\n private _isEnabled = true;\r\n\r\n private _hasRenderedMultiScatteringLut = false;\r\n private _multiScatteringEffectWrapper: Nullable<EffectWrapper> = null;\r\n private _multiScatteringLutRenderTarget: Nullable<RenderTargetTexture> = null;\r\n\r\n private _aerialPerspectiveLutEffectWrapper: Nullable<EffectWrapper> = null;\r\n private _aerialPerspectiveLutEffectRenderer: Nullable<EffectRenderer> = null;\r\n private _aerialPerspectiveLutRenderTarget: Nullable<RenderTargetTexture> = null;\r\n\r\n private _skyViewLutEffectWrapper: Nullable<EffectWrapper> = null;\r\n private _skyViewLutEffectRenderer: Nullable<EffectRenderer> = null;\r\n private _skyViewLutRenderTarget: Nullable<RenderTargetTexture> = null;\r\n\r\n private _aerialPerspectiveCompositorEffectWrapper: Nullable<EffectWrapper> = null;\r\n private _skyCompositorEffectWrapper: Nullable<EffectWrapper> = null;\r\n private _globeAtmosphereCompositorEffectWrapper: Nullable<EffectWrapper> = null;\r\n\r\n private _onBeforeCameraRenderObserver: Nullable<Observer<Camera>> = null;\r\n private _onBeforeDrawPhaseObserver: Nullable<Observer<Scene>> = null;\r\n private _onAfterRenderingGroupObserver: Nullable<Observer<RenderingGroupInfo>> = null;\r\n\r\n /**\r\n * Checks if the {@link Atmosphere} is supported.\r\n * @param engine - The engine to check.\r\n * @returns True if the atmosphere is supported, false otherwise.\r\n */\r\n public static IsSupported(engine: AbstractEngine): boolean {\r\n return !engine._badOS && !engine.isWebGPU && engine.version >= 2;\r\n }\r\n\r\n /**\r\n * Called after the atmosphere variables have been updated for the specified camera.\r\n */\r\n public readonly onAfterUpdateVariablesForCameraObservable = new Observable<Camera>();\r\n\r\n /**\r\n * Called immediately before the light variables are finalized.\r\n */\r\n public readonly onBeforeLightVariablesUpdateObservable = new Observable<void>();\r\n\r\n /**\r\n * Called before the LUTs are rendered for this camera. This happens after the per-camera UBO update.\r\n */\r\n public readonly onBeforeRenderLutsForCameraObservable = new Observable<void>();\r\n\r\n /**\r\n * Called after the LUTs were rendered.\r\n */\r\n public readonly onAfterRenderLutsForCameraObservable = new Observable<void>();\r\n\r\n /**\r\n * If provided, this is the depth texture used for composition passes.\r\n * Expects an infinite far plane on the camera (camera.maxZ = 0) and the non-linear depth accessible in red channel.\r\n * @internal\r\n */\r\n public readonly depthTexture: Nullable<BaseTexture> = null;\r\n\r\n /**\r\n * Controls the overall brightness of the atmosphere rendering.\r\n */\r\n public get exposure(): number {\r\n return this._exposure;\r\n }\r\n\r\n public set exposure(value: number) {\r\n this._exposure = Math.max(0, value);\r\n }\r\n\r\n /**\r\n * Affects the overall intensity of the multiple scattering.\r\n */\r\n public get multiScatteringIntensity(): number {\r\n return this._multiScatteringIntensity;\r\n }\r\n\r\n public set multiScatteringIntensity(value: number) {\r\n const newValue = Math.max(0.0, value);\r\n if (newValue !== this._multiScatteringIntensity) {\r\n this._multiScatteringIntensity = value;\r\n this._diffuseSkyIrradianceLut?.markDirty();\r\n }\r\n }\r\n\r\n /**\r\n * Affects the multiply scattered light contribution in the atmosphere by describing the average light color reflected off the ground.\r\n */\r\n public get groundAlbedo(): DeepImmutable<IColor3Like> {\r\n return this._groundAlbedo;\r\n }\r\n\r\n public set groundAlbedo(value: DeepImmutable<IColor3Like>) {\r\n if (!this._groundAlbedo.equals(value)) {\r\n this._groundAlbedo.copyFrom(value);\r\n this._multiScatteringEffectWrapper?.dispose();\r\n this._multiScatteringEffectWrapper = null;\r\n this._hasRenderedMultiScatteringLut = false;\r\n }\r\n }\r\n\r\n /**\r\n * Can be used to clamp the multiple scattering to a minimum value.\r\n */\r\n public get minimumMultiScatteringColor(): DeepImmutable<IColor3Like> {\r\n return this._minimumMultiScatteringColor;\r\n }\r\n\r\n public set minimumMultiScatteringColor(value: DeepImmutable<IColor3Like>) {\r\n if (!this._minimumMultiScatteringColor.equals(value)) {\r\n const minimumScatteringColor = this._minimumMultiScatteringColor.copyFrom(value);\r\n this._minimumMultiScattering.x = minimumScatteringColor.r * this._minimumMultiScatteringIntensity;\r\n this._minimumMultiScattering.y = minimumScatteringColor.g * this._minimumMultiScatteringIntensity;\r\n this._minimumMultiScattering.z = minimumScatteringColor.b * this._minimumMultiScatteringIntensity;\r\n this._diffuseSkyIrradianceLut?.markDirty();\r\n }\r\n }\r\n\r\n /**\r\n * This is an additional scaling factor applied to the {@link minimumMultiScatteringColor}.\r\n */\r\n public get minimumMultiScatteringIntensity(): number {\r\n return this._minimumMultiScatteringIntensity;\r\n }\r\n\r\n public set minimumMultiScatteringIntensity(value: number) {\r\n const newValue = Math.max(0.0, value);\r\n if (newValue !== this._minimumMultiScatteringIntensity) {\r\n this._minimumMultiScatteringIntensity = value;\r\n this._minimumMultiScattering.x = this._minimumMultiScatteringColor.r * value;\r\n this._minimumMultiScattering.y = this._minimumMultiScatteringColor.g * value;\r\n this._minimumMultiScattering.z = this._minimumMultiScatteringColor.b * value;\r\n this._diffuseSkyIrradianceLut?.markDirty();\r\n }\r\n }\r\n\r\n /**\r\n * Can be used to force the diffuse irradiance towards a gray color.\r\n */\r\n public get diffuseSkyIrradianceDesaturationFactor(): number {\r\n return this._diffuseSkyIrradianceDesaturationFactor;\r\n }\r\n\r\n public set diffuseSkyIrradianceDesaturationFactor(value: number) {\r\n const newValue = Math.max(value, 0.0);\r\n if (newValue !== this._diffuseSkyIrradianceDesaturationFactor) {\r\n this._diffuseSkyIrradianceDesaturationFactor = newValue;\r\n this._diffuseSkyIrradianceLut?.markDirty();\r\n }\r\n }\r\n\r\n /**\r\n * This is an additional amount of irradiance added to the diffuse irradiance.\r\n */\r\n public get additionalDiffuseSkyIrradianceIntensity(): number {\r\n return this._additionalDiffuseSkyIrradianceIntensity;\r\n }\r\n\r\n public set additionalDiffuseSkyIrradianceIntensity(value: number) {\r\n value = Math.max(0.0, value);\r\n if (value !== this._additionalDiffuseSkyIrradianceIntensity) {\r\n this._additionalDiffuseSkyIrradianceIntensity = value;\r\n this._additionalDiffuseSkyIrradianceColor.scaleToRef(value, this._additionalDiffuseSkyIrradiance);\r\n }\r\n }\r\n\r\n /**\r\n * This is the color for the additional amount of irradiance added to the diffuse irradiance.\r\n */\r\n public get additionalDiffuseSkyIrradianceColor(): DeepImmutable<IColor3Like> {\r\n return this._additionalDiffuseSkyIrradianceColor;\r\n }\r\n\r\n public set additionalDiffuseSkyIrradianceColor(value: DeepImmutable<IColor3Like>) {\r\n if (!this._additionalDiffuseSkyIrradianceColor.equals(value)) {\r\n this._additionalDiffuseSkyIrradianceColor.copyFrom(value).scaleToRef(this._additionalDiffuseSkyIrradianceIntensity, this._additionalDiffuseSkyIrradiance);\r\n }\r\n }\r\n\r\n /**\r\n * The final additional diffuse irradiance, taking into account the intensity and color.\r\n */\r\n public get additionalDiffuseSkyIrradiance(): DeepImmutable<IColor3Like> {\r\n return this._additionalDiffuseSkyIrradiance;\r\n }\r\n\r\n /**\r\n * The intensity of the diffuse irradiance.\r\n */\r\n public get diffuseSkyIrradianceIntensity(): number {\r\n return this._diffuseSkyIrradianceIntensity;\r\n }\r\n\r\n public set diffuseSkyIrradianceIntensity(value: number) {\r\n this._diffuseSkyIrradianceIntensity = Math.max(value, 0.0);\r\n }\r\n\r\n /**\r\n * True if the sky view LUT should be used for compositing the sky instead of a per-pixel ray march.\r\n */\r\n public get isSkyViewLutEnabled(): boolean {\r\n return this._isSkyViewLutEnabled;\r\n }\r\n\r\n public set isSkyViewLutEnabled(value: boolean) {\r\n this._isSkyViewLutEnabled = value;\r\n this._disposeSkyCompositor();\r\n this._disposeGlobeAtmosphereCompositor();\r\n }\r\n\r\n /**\r\n * Gets the sky view LUT render target or null if not enabled.\r\n * @returns The render target.\r\n */\r\n public get skyViewLutRenderTarget(): Nullable<RenderTargetTexture> {\r\n if (!this._isSkyViewLutEnabled) {\r\n return null;\r\n }\r\n\r\n if (this._skyViewLutRenderTarget !== null) {\r\n return this._skyViewLutRenderTarget;\r\n }\r\n\r\n const renderTarget = (this._skyViewLutRenderTarget = CreateRenderTargetTexture(\"atmo-skyView\", { width: 128, height: 128 }, this.scene));\r\n renderTarget.coordinatesMode = Constants.TEXTURE_EQUIRECTANGULAR_MODE;\r\n\r\n this._skyViewLutEffectWrapper = CreateSkyViewEffectWrapper(this._engine, this.uniformBuffer);\r\n\r\n return renderTarget;\r\n }\r\n /**\r\n * True if the aerial perspective LUT should be used.\r\n * If false, full ray marching would be used instead.\r\n */\r\n public get isAerialPerspectiveLutEnabled(): boolean {\r\n return this._isAerialPerspectiveLutEnabled;\r\n }\r\n\r\n public set isAerialPerspectiveLutEnabled(value: boolean) {\r\n this._isAerialPerspectiveLutEnabled = value;\r\n this._disposeAerialPerspectiveCompositor();\r\n }\r\n\r\n /**\r\n * Gets the aerial perspective LUT render target or null if not enabled.\r\n * @returns The render target.\r\n */\r\n public get aerialPerspectiveLutRenderTarget(): Nullable<RenderTargetTexture> {\r\n if (!this._isAerialPerspectiveLutEnabled) {\r\n return null;\r\n }\r\n\r\n if (this._aerialPerspectiveLutRenderTarget !== null) {\r\n return this._aerialPerspectiveLutRenderTarget;\r\n }\r\n\r\n const scene = this.scene;\r\n const name = \"atmo-aerialPerspective\";\r\n const renderTarget = (this._aerialPerspectiveLutRenderTarget = CreateRenderTargetTexture(name, { width: 16, height: 64, layers: 32 }, scene, {}));\r\n this._aerialPerspectiveLutEffectWrapper = CreateAerialPerspectiveEffectWrapper(this._engine, this.uniformBuffer);\r\n\r\n return renderTarget;\r\n }\r\n\r\n /**\r\n * The intensity of the aerial perspective.\r\n */\r\n public get aerialPerspectiveIntensity(): number {\r\n return this._aerialPerspectiveIntensity;\r\n }\r\n\r\n public set aerialPerspectiveIntensity(value: number) {\r\n value = Math.max(0.001, value);\r\n if (value !== this._aerialPerspectiveIntensity) {\r\n // Define only needs to change if the value is changing between 1 and not 1.\r\n const hasDefineChanged = (value === 1) !== (this._aerialPerspectiveIntensity === 1);\r\n this._aerialPerspectiveIntensity = value;\r\n if (hasDefineChanged) {\r\n this._disposeAerialPerspectiveCompositor();\r\n this._disposeGlobeAtmosphereCompositor();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * The amount of light transmitted into aerial perspective.\r\n * A scale of 1 is physically correct.\r\n */\r\n public get aerialPerspectiveTransmittanceScale(): number {\r\n return this._aerialPerspectiveTransmittanceScale;\r\n }\r\n\r\n public set aerialPerspectiveTransmittanceScale(value: number) {\r\n value = Math.max(0, value);\r\n if (value !== this._aerialPerspectiveTransmittanceScale) {\r\n this._aerialPerspectiveTransmittanceScale = value;\r\n }\r\n }\r\n\r\n /**\r\n * The amount of saturation applied to the aerial perspective.\r\n * Reducing to zero desaturates the aerial perspective completely.\r\n * A value of 1 has no effect.\r\n */\r\n public get aerialPerspectiveSaturation(): number {\r\n return this._aerialPerspectiveSaturation;\r\n }\r\n\r\n public set aerialPerspectiveSaturation(value: number) {\r\n value = Math.max(0.0, value);\r\n if (value !== this._aerialPerspectiveSaturation) {\r\n this._aerialPerspectiveSaturation = value;\r\n }\r\n }\r\n\r\n /**\r\n * A radiance bias applied to aerial perspective.\r\n */\r\n public get aerialPerspectiveRadianceBias(): number {\r\n return this._aerialPerspectiveRadianceBias;\r\n }\r\n\r\n public set aerialPerspectiveRadianceBias(value: number) {\r\n if (value !== this._aerialPerspectiveRadianceBias) {\r\n // Define only needs to change if the value is changing between 0 and not 0.\r\n const hasDefineChanged = (value === 0) !== (this._aerialPerspectiveRadianceBias === 0);\r\n this._aerialPerspectiveRadianceBias = value;\r\n if (hasDefineChanged) {\r\n this._disposeAerialPerspectiveCompositor();\r\n this._disposeGlobeAtmosphereCompositor();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * True if the composition should be in linear space (e.g. for HDR rendering).\r\n * Typically linear space is expected when ImageProcessing is enabled via PostProcesses.\r\n * False for non-linear output.\r\n */\r\n public get isLinearSpaceComposition(): boolean {\r\n return this._isLinearSpaceComposition;\r\n }\r\n\r\n public set isLinearSpaceComposition(value: boolean) {\r\n if (value !== this._isLinearSpaceComposition) {\r\n this._isLinearSpaceComposition = value;\r\n // Note, LUTs will remain in linear space. Up to compositors to apply gamma if needed.\r\n this._disposeSkyCompositor();\r\n this._disposeAerialPerspectiveCompositor();\r\n this._disposeGlobeAtmosphereCompositor();\r\n }\r\n }\r\n\r\n /**\r\n * True if the {@link light} value should be specified in linear space.\r\n * If using PBRMaterials, light value is expected to be linear.\r\n */\r\n public get isLinearSpaceLight(): boolean {\r\n return this._isLinearSpaceLight;\r\n }\r\n\r\n public set isLinearSpaceLight(value: boolean) {\r\n this._isLinearSpaceLight = value;\r\n }\r\n\r\n /**\r\n * The lookup table for transmittance.\r\n */\r\n public get transmittanceLut(): Nullable<TransmittanceLut> {\r\n return this._transmittanceLut;\r\n }\r\n\r\n /**\r\n * Gets the multiple scattering LUT render target.\r\n * @returns The render target.\r\n */\r\n public get multiScatteringLutRenderTarget(): Nullable<RenderTargetTexture> {\r\n return this._multiScatteringLutRenderTarget;\r\n }\r\n\r\n /**\r\n * The lookup table for diffuse sky irradiance, or null if not enabled.\r\n */\r\n public get diffuseSkyIrradianceLut(): Nullable<DiffuseSkyIrradianceLut> {\r\n return this._diffuseSkyIrradianceLut;\r\n }\r\n\r\n /**\r\n * The properties used to describe the size and optical parameters of the atmosphere.\r\n */\r\n public get physicalProperties(): AtmospherePhysicalProperties {\r\n return this._physicalProperties;\r\n }\r\n\r\n /**\r\n * The height in kilometers of the scene's origin.\r\n */\r\n public get originHeight(): number {\r\n return this._originHeight;\r\n }\r\n\r\n public set originHeight(value: number) {\r\n this._originHeight = value;\r\n }\r\n\r\n /**\r\n * When atmospheric scattering is applied to surfaces, if this value is set to true,\r\n * a grayscale approximation of the transmittance is used to dim surfaces.\r\n *\r\n * When set to false, the atmospheric composition does not dim the surfaces behind it.\r\n * It is up to the client application to apply transmittance manually.\r\n */\r\n public get applyApproximateTransmittance(): boolean {\r\n return this._applyApproximateTransmittance;\r\n }\r\n\r\n public set applyApproximateTransmittance(value: boolean) {\r\n if (this._applyApproximateTransmittance !== value) {\r\n this._applyApproximateTransmittance = value;\r\n this._disposeSkyCompositor();\r\n this._disposeAerialPerspectiveCompositor();\r\n this._disposeGlobeAtmosphereCompositor();\r\n }\r\n }\r\n\r\n /**\r\n * The directional lights in the scene which represent the suns illuminating the atmosphere.\r\n * Each frame, the color and intensity of the lights are updated based on the camera position and the light's direction.\r\n */\r\n public get lights(): ReadonlyArray<DirectionalLight> {\r\n return this._lights;\r\n }\r\n\r\n /**\r\n * The rendering group ID for the sky compositor.\r\n * The sky will only be rendered for this group.\r\n */\r\n public get skyRenderingGroup(): number {\r\n return this._skyRenderingGroup;\r\n }\r\n\r\n public set skyRenderingGroup(value: number) {\r\n this._skyRenderingGroup = value;\r\n this.scene.renderingManager.getRenderingGroup(value);\r\n }\r\n\r\n /**\r\n * The rendering group ID for the aerial perspective compositor.\r\n * Aerial perspective will only be rendered for this group.\r\n */\r\n public get aerialPerspectiveRenderingGroup(): number {\r\n return this._aerialPerspectiveRenderingGroup;\r\n }\r\n\r\n public set aerialPerspectiveRenderingGroup(value: number) {\r\n this._aerialPerspectiveRenderingGroup = value;\r\n this.scene.renderingManager.getRenderingGroup(value);\r\n }\r\n\r\n /**\r\n * The rendering group ID for the globe atmosphere compositor.\r\n * The globe atmosphere will only be rendered for this group.\r\n */\r\n public get globeAtmosphereRenderingGroup(): number {\r\n return this._globeAtmosphereRenderingGroup;\r\n }\r\n\r\n public set globeAtmosphereRenderingGroup(value: number) {\r\n this._globeAtmosphereRenderingGroup = value;\r\n this.scene.renderingManager.getRenderingGroup(value);\r\n }\r\n\r\n /**\r\n * Gets the uniform buffer used to store the atmosphere's physical properties.\r\n */\r\n public get uniformBuffer(): UniformBuffer {\r\n if (this._atmosphereUbo === null) {\r\n const atmosphereUbo = (this._atmosphereUbo = new UniformBuffer(this._engine, undefined, true, \"Atmosphere\"));\r\n atmosphereUbo.addUniform(\"peakRayleighScattering\", 3);\r\n atmosphereUbo.addUniform(\"planetRadius\", 1);\r\n // 16-byte boundary\r\n atmosphereUbo.addUniform(\"peakMieScattering\", 3);\r\n atmosphereUbo.addUniform(\"atmosphereThickness\", 1);\r\n // 16-byte boundary\r\n atmosphereUbo.addUniform(\"peakMieAbsorption\", 3);\r\n atmosphereUbo.addUniform(\"planetRadiusSquared\", 1);\r\n // 16-byte boundary\r\n atmosphereUbo.addUniform(\"peakMieExtinction\", 3);\r\n atmosphereUbo.addUniform(\"atmosphereRadius\", 1);\r\n // 16-byte boundary\r\n atmosphereUbo.addUniform(\"peakOzoneAbsorption\", 3);\r\n atmosphereUbo.addUniform(\"atmosphereRadiusSquared\", 1);\r\n // 16-byte boundary\r\n atmosphereUbo.addUniform(\"horizonDistanceToAtmosphereEdge\", 1);\r\n atmosphereUbo.addUniform(\"horizonDistanceToAtmosphereEdgeSquared\", 1);\r\n atmosphereUbo.addUniform(\"planetRadiusWithOffset\", 1);\r\n atmosphereUbo.addUniform(\"planetRadiusOffset\", 1);\r\n // 16-byte boundary\r\n atmosphereUbo.addUniform(\"atmosphereExposure\", 1);\r\n atmosphereUbo.addUniform(\"aerialPerspectiveRadianceBias\", 1);\r\n atmosphereUbo.addUniform(\"inverseAtmosphereThickness\", 1);\r\n atmosphereUbo.addUniform(\"aerialPerspectiveTransmittanceScale\", 1);\r\n // 16-byte boundary\r\n atmosphereUbo.addUniform(\"inverseViewProjectionWithoutTranslation\", 16);\r\n // 16-byte boundary\r\n atmosphereUbo.addUniform(\"directionToLight\", 3);\r\n atmosphereUbo.addUniform(\"multiScatteringIntensity\", 1);\r\n // 16-byte boundary\r\n atmosphereUbo.addUniform(\"directionToLightRelativeToCameraGeocentricNormal\", 3);\r\n atmosphereUbo.addUniform(\"cameraRadius\", 1);\r\n // 16-byte boundary\r\n atmosphereUbo.addUniform(\"lightRadianceAtCamera\", 3);\r\n atmosphereUbo.addUniform(\"diffuseSkyIrradianceDesaturationFactor\", 1);\r\n // 16-byte boundary\r\n atmosphereUbo.addUniform(\"groundAlbedo\", 3);\r\n atmosphereUbo.addUniform(\"aerialPerspectiveSaturation\", 1);\r\n // 16-byte boundary\r\n atmosphereUbo.addUniform(\"minMultiScattering\", 3);\r\n atmosphereUbo.addUniform(\"diffuseSkyIrradianceIntensity\", 1);\r\n // 16-byte boundary\r\n atmosphereUbo.addUniform(\"cameraPositionGlobal\", 3);\r\n atmosphereUbo.addUniform(\"lightIntensity\", 1);\r\n // 16-byte boundary\r\n atmosphereUbo.addUniform(\"clampedCameraPositionGlobal\", 3);\r\n atmosphereUbo.addUniform(\"aerialPerspectiveIntensity\", 1);\r\n // 16-byte boundary\r\n atmosphereUbo.addUniform(\"cameraGeocentricNormal\", 3);\r\n atmosphereUbo.addUniform(\"clampedCameraRadius\", 1);\r\n // 16-byte boundary\r\n atmosphereUbo.addUniform(\"cameraForward\", 3);\r\n atmosphereUbo.addUniform(\"clampedCameraHeight\", 1);\r\n // 16-byte boundary\r\n atmosphereUbo.addUniform(\"cameraPosition\", 3);\r\n atmosphereUbo.addUniform(\"cosCameraHorizonAngleFromZenith\", 1);\r\n // 16-byte boundary\r\n atmosphereUbo.addUniform(\"viewport\", 4);\r\n // 16-byte boundary\r\n atmosphereUbo.addUniform(\"additionalDiffuseSkyIrradiance\", 3);\r\n atmosphereUbo.addUniform(\"cameraHeight\", 1);\r\n // 16-byte boundary\r\n atmosphereUbo.addUniform(\"cameraNearPlane\", 1);\r\n atmosphereUbo.addUniform(\"originHeight\", 1);\r\n atmosphereUbo.addUniform(\"sinCameraAtmosphereHorizonAngleFromNadir\", 1);\r\n atmosphereUbo.create();\r\n }\r\n return this._atmosphereUbo;\r\n }\r\n\r\n /**\r\n * Gets the camera-related variables for this atmosphere. Updated each frame.\r\n */\r\n public get cameraAtmosphereVariables(): AtmospherePerCameraVariables {\r\n return this._cameraAtmosphereVariables;\r\n }\r\n\r\n // These fields and properties are used to interop with the inspector and not meant to be part of the API.\r\n\r\n private _peakRayleighScatteringMmInternal = new Vector3();\r\n private _peakRayleighScatteringKm = new Vector3();\r\n private _peakMieScatteringMmInternal = new Vector3();\r\n private _peakMieScatteringKm = new Vector3();\r\n private _peakMieAbsorptionMmInternal = new Vector3();\r\n private _peakMieAbsorptionKm = new Vector3();\r\n private _peakOzoneAbsorptionMmInternal = new Vector3();\r\n private _peakOzoneAbsorptionKm = new Vector3();\r\n\r\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\r\n // @ts-ignore\r\n private get _planetRadius(): number {\r\n return this._physicalProperties.planetRadius;\r\n }\r\n private set _planetRadius(value: number) {\r\n this._physicalProperties.planetRadius = value;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\r\n // @ts-ignore\r\n private get _planetRadiusOffset(): number {\r\n return this._physicalProperties.planetRadiusOffset;\r\n }\r\n private set _planetRadiusOffset(value: number) {\r\n this._physicalProperties.planetRadiusOffset = value;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\r\n // @ts-ignore\r\n private get _atmosphereThickness(): number {\r\n return this._physicalProperties.atmosphereThickness;\r\n }\r\n private set _atmosphereThickness(value: number) {\r\n this._physicalProperties.atmosphereThickness = value;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\r\n // @ts-ignore\r\n private get _rayleighScatteringScale(): number {\r\n return this._physicalProperties.rayleighScatteringScale;\r\n }\r\n private set _rayleighScatteringScale(value: number) {\r\n this._physicalProperties.rayleighScatteringScale = value;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\r\n // @ts-ignore\r\n private get _peakRayleighScatteringMm(): Vector3 {\r\n this._physicalProperties.peakRayleighScattering.scaleToRef(1000.0, this._peakRayleighScatteringMmInternal);\r\n return this._peakRayleighScatteringMmInternal;\r\n }\r\n private set _peakRayleighScatteringMm(value: Vector3) {\r\n this._peakRayleighScatteringMmInternal.copyFrom(value);\r\n this._peakRayleighScatteringMmInternal.scaleToRef(0.001, this._peakRayleighScatteringKm);\r\n this._physicalProperties.peakRayleighScattering = this._peakRayleighScatteringKm;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\r\n // @ts-ignore\r\n private get _mieScatteringScale(): number {\r\n return this._physicalProperties.mieScatteringScale;\r\n }\r\n private set _mieScatteringScale(value: number) {\r\n this._physicalProperties.mieScatteringScale = value;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\r\n // @ts-ignore\r\n private get _peakMieScatteringMm(): Vector3 {\r\n this._physicalProperties.peakMieScattering.scaleToRef(1000.0, this._peakMieScatteringMmInternal);\r\n return this._peakMieScatteringMmInternal;\r\n }\r\n private set _peakMieScatteringMm(value: Vector3) {\r\n this._peakMieScatteringMmInternal.copyFrom(value);\r\n this._peakMieScatteringMmInternal.scaleToRef(0.001, this._peakMieScatteringKm);\r\n this._physicalProperties.peakMieScattering = this._peakMieScatteringKm;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\r\n // @ts-ignore\r\n private get _mieAbsorptionScale(): number {\r\n return this._physicalProperties.mieAbsorptionScale;\r\n }\r\n private set _mieAbsorptionScale(value: number) {\r\n this._physicalProperties.mieAbsorptionScale = value;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\r\n // @ts-ignore\r\n private get _peakMieAbsorptionMm(): Vector3 {\r\n this._physicalProperties.peakMieAbsorption.scaleToRef(1000.0, this._peakMieAbsorptionMmInternal);\r\n return this._peakMieAbsorptionMmInternal;\r\n }\r\n private set _peakMieAbsorptionMm(value: Vector3) {\r\n this._peakMieAbsorptionMmInternal.copyFrom(value);\r\n this._peakMieAbsorptionMmInternal.scaleToRef(0.001, this._peakMieAbsorptionKm);\r\n this._physicalProperties.peakMieAbsorption = this._peakMieAbsorptionKm;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\r\n // @ts-ignore\r\n private get _ozoneAbsorptionScale(): number {\r\n return this._physicalProperties.ozoneAbsorptionScale;\r\n }\r\n private set _ozoneAbsorptionScale(value: number) {\r\n this._physicalProperties.ozoneAbsorptionScale = value;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\r\n // @ts-ignore\r\n private get _peakOzoneAbsorptionMm(): Vector3 {\r\n this._physicalProperties.peakOzoneAbsorption.scaleToRef(1000.0, this._peakOzoneAbsorptionMmInternal);\r\n return this._peakOzoneAbsorptionMmInternal;\r\n }\r\n private set _peakOzoneAbsorptionMm(value: Vector3) {\r\n this._peakOzoneAbsorptionMmInternal.copyFrom(value);\r\n this._peakOzoneAbsorptionMmInternal.scaleToRef(0.001, this._peakOzoneAbsorptionKm);\r\n this._physicalProperties.peakOzoneAbsorption = this._peakOzoneAbsorptionKm;\r\n }\r\n\r\n /**\r\n * Constructs the {@link Atmosphere}.\r\n * @param name - The name of this instance.\r\n * @param scene - The scene to which the atmosphere will be added.\r\n * @param lights - The light sources that illuminate the atmosphere. Currently only supports one light, and that light should be the first light in the scene.\r\n * @param options - The options used to create the atmosphere.\r\n */\r\n public constructor(\r\n public readonly name: string,\r\n public readonly scene: Scene,\r\n lights: DirectionalLight[],\r\n options?: IAtmosphereOptions\r\n ) {\r\n const engine = (this._engine = scene.getEngine());\r\n if (engine.isWebGPU) {\r\n throw new Error(\"Atmosphere is not supported on WebGPU.\");\r\n }\r\n if (engine.version < 2) {\r\n throw new Error(`Atmosphere is not supported on WebGL ${engine.version}.`);\r\n }\r\n\r\n this._physicalProperties = options?.physicalProperties ?? new AtmospherePhysicalProperties();\r\n this._physicalProperties.onChangedObservable.add(() => {\r\n this._transmittanceLut?.markDirty();\r\n });\r\n\r\n if (lights.length !== 1) {\r\n throw new Error(\"Atmosphere only supports one light source currently.\");\r\n }\r\n this._lights = lights;\r\n\r\n this.depthTexture = options?.depthTexture ?? null;\r\n this._exposure = options?.exposure ?? 1.0;\r\n this._isLinearSpaceLight = options?.isLinearSpaceLight ?? false;\r\n this._isLinearSpaceComposition = options?.isLinearSpaceComposition ?? false;\r\n this._applyApproximateTransmittance = options?.applyApproximateTransmittance ?? true;\r\n this._aerialPerspectiveRadianceBias = options?.aerialPerspectiveRadianceBias ?? 0.0;\r\n this._aerialPerspectiveTransmittanceScale = options?.aerialPerspectiveTransmittanceScale ?? 1.0;\r\n this._aerialPerspectiveSaturation = options?.aerialPerspectiveSaturation ?? 1.0;\r\n this._aerialPerspectiveIntensity = options?.aerialPerspectiveIntensity ?? 1.0;\r\n this._diffuseSkyIrradianceDesaturationFactor = options?.diffuseSkyIrradianceDesaturationFactor ?? 0.5;\r\n this._diffuseSkyIrradianceIntensity = options?.diffuseSkyIrradianceIntensity ?? 1.0;\r\n this._additionalDiffuseSkyIrradianceIntensity = options?.additionalDiffuseSkyIrradianceIntensity ?? 0.01;\r\n this._multiScatteringIntensity = options?.multiScatteringIntensity ?? 1.0;\r\n this._minimumMultiScatteringIntensity = options?.minimumMultiScatteringIntensity ?? 0.000618;\r\n this._isSkyViewLutEnabled = options?.isSkyViewLutEnabled ?? true;\r\n this._isAerialPerspectiveLutEnabled = options?.isAerialPerspectiveLutEnabled ?? true;\r\n this._originHeight = options?.originHeight ?? 0;\r\n this._additionalDiffuseSkyIrradianceColor = options?.additionalDiffuseSkyIrradianceColor\r\n ? new Color3().copyFrom(options.additionalDiffuseSkyIrradianceColor)\r\n : new Color3(163 / 255.0, 199 / 255.0, 1.0);\r\n this._groundAlbedo = options?.groundAlbedo ? new Color3().copyFrom(options.groundAlbedo) : new Color3().set(124.0 / 255.0, 165.0 / 255.0, 1.0);\r\n const minimumMultiScatteringColor = (this._minimumMultiScatteringColor = options?.minimumMultiScatteringColor\r\n ? new Color3().copyFrom(options.minimumMultiScatteringColor)\r\n : new Color3(30.0 / 255.0, 40.0 / 255.0, 77.0 / 255.0));\r\n\r\n this._skyRenderingGroup = options?.skyRenderingGroup ?? 0;\r\n this._aerialPerspectiveRenderingGroup = options?.aerialPerspectiveRenderingGroup ?? 0;\r\n this._globeAtmosphereRenderingGroup = options?.globeAtmosphereRenderingGroup ?? 0;\r\n\r\n this._additionalDiffuseSkyIrradianceColor.scaleToRef(this._additionalDiffuseSkyIrradianceIntensity, this._additionalDiffuseSkyIrradiance);\r\n this._minimumMultiScattering.x = minimumMultiScatteringColor.r * this._minimumMultiScatteringIntensity;\r\n this._minimumMultiScattering.y = minimumMultiScatteringColor.g * this._minimumMultiScatteringIntensity;\r\n this._minimumMultiScattering.z = minimumMultiScatteringColor.b * this._minimumMultiScatteringIntensity;\r\n\r\n this._effectRenderer = new EffectRenderer(engine, {\r\n // Full screen triangle.\r\n indices: [0, 2, 1],\r\n positions: [-1, -1, -1, 3, 3, -1],\r\n });\r\n\r\n this._transmittanceLut = new TransmittanceLut(this);\r\n this._multiScatteringLutRenderTarget = CreateRenderTargetTexture(\"atmo-multiScattering\", { width: 32, height: 32 }, scene);\r\n if (options?.isDiffuseSkyIrradianceLutEnabled ?? true) {\r\n this._diffuseSkyIrradianceLut = new DiffuseSkyIrradianceLut(this);\r\n }\r\n if (this._isSkyViewLutEnabled) {\r\n this.skyViewLutRenderTarget!;\r\n }\r\n if (this._isAerialPerspectiveLutEnabled) {\r\n this.aerialPerspectiveLutRenderTarget!;\r\n }\r\n\r\n // Before rendering, make sure the per-camera variables have been updated.\r\n this._onBeforeCameraRenderObserver = scene.onBeforeCameraRenderObservable.add((x) => {\r\n this._updatePerCameraVariables(x);\r\n this._renderLutsForCamera();\r\n });\r\n\r\n {\r\n const renderingManager = scene.renderingManager;\r\n renderingManager.getRenderingGroup(this._skyRenderingGroup);\r\n renderingManager.getRenderingGroup(this._aerialPerspectiveRenderingGroup);\r\n renderingManager.getRenderingGroup(this._globeAtmosphereRenderingGroup);\r\n\r\n // Mark all rendering groups as being \"not empty\" before rendering the corresponding targets.\r\n // This ensures onAfterRenderTargetsRenderObservable is called for empty groups,\r\n // which allows the atmosphere to be rendered even when the groups are otherwise empty e.g.,\r\n // a scene with only the atmosphere in it, and no other Meshes.\r\n this._onBeforeDrawPhaseObserver = scene.onBeforeDrawPhaseObservable.add(() => {\r\n renderingManager.getRenderingGroup(this._skyRenderingGroup)._empty = false;\r\n renderingManager.getRenderingGroup(this._aerialPerspectiveRenderingGroup)._empty = false;\r\n renderingManager.getRenderingGroup(this._globeAtmosphereRenderingGroup)._empty = false;\r\n });\r\n\r\n // Draw compositors after the respective rendering group.\r\n this._onAfterRenderingGroupObserver = scene.onAfterRenderingGroupObservable.add((group) => {\r\n if (group.renderingManager !== scene.renderingManager) {\r\n return;\r\n }\r\n\r\n const groupId = group.renderingGroupId;\r\n\r\n if (this._skyRenderingGroup === groupId) {\r\n this._drawSkyCompositor();\r\n }\r\n\r\n if (this._aerialPerspectiveRenderingGroup === groupId) {\r\n this._drawAerialPerspectiveCompositor();\r\n }\r\n\r\n if (this._globeAtmosphereRenderingGroup === groupId) {\r\n this._drawGlobeAtmosphereCompositor();\r\n }\r\n });\r\n }\r\n\r\n // Ensure the atmosphere is disposed when the scene is disposed.\r\n scene.onDisposeObservable.addOnce(() => {\r\n this.dispose();\r\n });\r\n\r\n // Registers a material plugin which will allow common materials to sample the atmosphere environment maps e.g.,\r\n // sky view LUT for glossy reflections and diffuse sky illiminance LUT for irradiance.\r\n // It also handles aerial perspective application when Atmosphere is not provided with a depth texture.\r\n UnregisterMaterialPlugin(MaterialPlugin);\r\n RegisterMaterialPlugin(MaterialPlugin, (material) => {\r\n if (material.getClassName() === \"PBRMaterial\") {\r\n return new AtmospherePBRMaterialPlugin(material, this, this.depthTexture === null);\r\n }\r\n return null;\r\n });\r\n }\r\n\r\n /**\r\n * @override\r\n */\r\n public dispose(): void {\r\n this._onBeforeCameraRenderObserver?.remove();\r\n this._onBeforeCameraRenderObserver = null;\r\n this._onBeforeDrawPhaseObserver?.remove();\r\n this._onBeforeDrawPhaseObserver = null;\r\n this._onAfterRenderingGroupObserver?.remove();\r\n this._onAfterRenderingGroupObserver = null;\r\n this._globeAtmosphereCompositorEffectWrapper?.dispose();\r\n this._globeAtmosphereCompositorEffectWrapper = null;\r\n this._skyCompositorEffectWrapper?.dispose();\r\n this._skyCompositorEffectWrapper = null;\r\n this._aerialPerspectiveCompositorEffectWrapper?.dispose();\r\n this._aerialPerspectiveCompositorEffectWrapper = null;\r\n this._skyViewLutRenderTarget?.dispose();\r\n this._skyViewLutRenderTarget = null;\r\n this._skyViewLutEffectWrapper?.dispose();\r\n this._skyViewLutEffectWrapper = null;\r\n this._skyViewLutEffectRenderer?.dispose();\r\n this._skyViewLutEffectRenderer = null;\r\n this._aerialPerspectiveLutRenderTarget?.dispose();\r\n this._aerialPerspectiveLutRenderTarget = null;\r\n this._aerialPerspectiveLutEffectWrapper?.dispose();\r\n this._aerialPerspectiveLutEffectWrapper = null;\r\n this._aerialPerspectiveLutEffectRenderer?.dispose();\r\n this._aerialPerspectiveLutEffectRenderer = null;\r\n this._multiScatteringEffectWrapper?.dispose();\r\n this._multiScatteringEffectWrapper = null;\r\n this._multiScatteringLutRenderTarget?.dispose();\r\n this._multiScatteringLutRenderTarget = null;\r\n this._transmittanceLut?.dispose();\r\n this._transmittanceLut = null;\r\n this._diffuseSkyIrradianceLut?.dispose();\r\n this._diffuseSkyIrradianceLut = null;\r\n this._atmosphereUbo?.dispose();\r\n this._atmosphereUbo = null;\r\n this._effectRenderer?.dispose();\r\n this._effectRenderer = null;\r\n this._atmosphereUniformBufferAsArray.length = 0;\r\n\r\n UnregisterMaterialPlugin(MaterialPlugin);\r\n }\r\n\r\n /**\r\n * True if the atmosphere is enabled.\r\n * @returns - True if the atmosphere is enabled.\r\n */\r\n public isEnabled() {\r\n return this._isEnabled;\r\n }\r\n\r\n /**\r\n * Sets the enabled state of the atmosphere.\r\n * @param enabled - True to enable the atmosphere, false to disable it.\r\n */\r\n public setEnabled(enabled: boolean) {\r\n this._isEnabled = enabled;\r\n }\r\n\r\n /**\r\n * The class name of the {@link Atmosphere}.\r\n * @returns - The class name of the atmosphere.\r\n */\r\n public getClassName(): string {\r\n return \"Atmosphere\";\r\n }\r\n\r\n /**\r\n * Gets the color of a light after being transmitted through the atmosphere to a point specified by its distance to the planet center and its geocentric normal.\r\n * NOTE, the result is always a linear space color.\r\n * @param directionToLight - The direction of the light.\r\n * @param pointRadius - The distance from the planet center to the point in kilometers.\r\n * @param pointGeocentricNormal - The geocentric normal at the point i.e., normalize(point - planet center).\r\n * @param result - The color to store the result in.\r\n * @returns The result color.\r\n */\r\n public getTransmittedColorToRef = <T extends IColor3Like>(directionToLight: IVector3Like, pointRadius: number, pointGeocentricNormal: IVector3Like, result: T): T =>\r\n this._transmittanceLut!.getTransmittedColorToRef(directionToLight, pointRadius, pointGeocentricNormal, result);\r\n\r\n /**\r\n * Gets the diffuse sky irradiance. Result is always in linear space.\r\n * @param directionToLight - The direction of the point to the light.\r\n * @param pointRadius - The distance from the planet center to the point in kilometers.\r\n * @param pointGeocentricNormal - The geocentric normal at the point: normalize(point - planet center).\r\n * @param lightIrradiance - The irradiance of the light.\r\n * @param result - The color to store the result in.\r\n * @returns The result color.\r\n */\r\n public getDiffuseSkyIrradianceToRef = <T extends IColor3Like>(\r\n directionToLight: IVector3Like,\r\n pointRadius: number,\r\n pointGeocentricNormal: IVector3Like,\r\n lightIrradiance: number,\r\n result: T\r\n ): T =>\r\n this._diffuseSkyIrradianceLut?.getDiffuseSkyIrradianceToRef(directionToLight, pointRadius, pointGeocentricNormal, lightIrradiance, result) ??\r\n ((result.r = 0), (result.g = 0), (result.b = 0), result);\r\n\r\n /**\r\n * Creates a new {@link EffectWrapper} for the multiple scattering LUT\r\n * @returns The newly created {@link EffectWrapper}.\r\n */\r\n private _createMultiScatteringEffectWrapper(): EffectWrapper {\r\n const engine = this._engine;\r\n const name = \"atmo-multiScattering\";\r\n const ubo = this.uniformBuffer;\r\n const useUbo = ubo.useUbo;\r\n\r\n const defines: string[] = [\"#define POSITION_VEC2\"];\r\n if (!this._groundAlbedo.equals(Color3.BlackReadOnly)) {\r\n defines.push(\"#define USE_GROUND_ALBEDO\");\r\n }\r\n\r\n return new EffectWrapper({\r\n engine,\r\n name,\r\n vertexShader: \"fullscreenTriangle\",\r\n fragmentShader: \"multiScattering\",\r\n attributeNames: [\"position\"],\r\n uniformNames: [\"depth\", ...(useUbo ? [] : this.uniformBuffer.getUniformNames())],\r\n uniformBuffers: useUbo ? [this.uniformBuffer.name] : [],\r\n samplerNames: [\"transmittanceLut\"],\r\n defines,\r\n useShaderStore: true,\r\n });\r\n }\r\n\r\n /**\r\n * Draws the multiple scattering LUT using {@link EffectWrapper} and {@link EffectRenderer}.\r\n */\r\n private _drawMultiScatteringLut(): void {\r\n const transmittanceLut = this._transmittanceLut!.renderTarget;\r\n DrawEffect(\r\n this._engine,\r\n this._effectRenderer!,\r\n this._multiScatteringEffectWrapper,\r\n this._multiScatteringLutRenderTarget,\r\n (effectRenderer, renderTarget, effect, engine) => {\r\n this.bindUniformBufferToEffect(effect);\r\n engine.bindFramebuffer(renderTarget!, undefined, undefined, undefined, true);\r\n effectRenderer.bindBuffers(effect);\r\n effect.setTexture(\"transmittanceLut\", transmittanceLut);\r\n effectRenderer.draw();\r\n }\r\n );\r\n }\r\n\r\n /**\r\n * Draws the aerial perspective compositor using {@link EffectWrapper} and {@link EffectRenderer}.\r\n */\r\n private _drawAerialPerspectiveCompositor(): void {\r\n // Only works if we have a depth texture.\r\n if (this.depthTexture === null) {\r\n return;\r\n }\r\n\r\n const isEnabled = this.isEnabled();\r\n if (!isEnabled) {\r\n return;\r\n }\r\n\r\n // Aerial perspective compositor only renders when inside the atmosphere.\r\n const isOutsideAtmosphere = this._cameraAtmosphereVariables.clampedCameraRadius > this._physicalProperties.atmosphereRadius;\r\n if (isOutsideAtmosphere) {\r\n return;\r\n }\r\n\r\n const engine = this._engine;\r\n this._aerialPerspectiveCompositorEffectWrapper ??= CreateAerialPerspectiveCompositorEffectWrapper(\r\n engine,\r\n this.uniformBuffer,\r\n this._isAerialPerspectiveLutEnabled,\r\n this._isSkyViewLutEnabled,\r\n this._isLinearSpaceComposition,\r\n this._applyApproximateTransmittance,\r\n this._aerialPerspectiveIntensity,\r\n this._aerialPerspectiveRadianceBias\r\n );\r\n\r\n const skyViewLut = this._isSkyViewLutEnabled ? this.skyViewLutRenderTarget : null;\r\n const multiScatteringLut = this._multiScatteringLutRenderTarget!;\r\n const transmittanceLut = this._transmittanceLut!.renderTarget;\r\n const aerialPerspectiveLut = this._isAerialPerspectiveLutEnabled ? this.aerialPerspectiveLutRenderTarget : null;\r\n if (\r\n !this._aerialPerspectiveCompositorEffectWrapper.isReady() ||\r\n !(skyViewLut?.isReady() ?? true) ||\r\n !multiScatteringLut.isReady() ||\r\n !transmittanceLut.isReady() ||\r\n !(aerialPerspectiveLut?.isReady() ?? true) ||\r\n !this.depthTexture.isReady()\r\n ) {\r\n return;\r\n }\r\n\r\n DrawEffect(\r\n engine,\r\n this._effectRenderer!,\r\n this._aerialPerspectiveCompositorEffectWrapper,\r\n null, // No render target, it will render to the current buffer.\r\n (effectRenderer, _, effect) => {\r\n if (this.depthTexture === null) {\r\n throw new Error(\"Depth texture is required for aerial perspective compositor.\");\r\n }\r\n this.bindUniformBufferToEffect(effect);\r\n effectRenderer.bindBuffers(effect);\r\n effect.setTexture(\"transmittanceLut\", transmittanceLut);\r\n effect.setTexture(\"multiScatteringLut\", multiScatteringLut);\r\n if (this._isSkyViewLutEnabled) {\r\n effect.setTexture(\"skyViewLut\", skyViewLut);\r\n }\r\n if (this._isAerialPerspectiveLutEnabled) {\r\n effect.setTexture(\"aerialPerspectiveLut\", aerialPerspectiveLut);\r\n }\r\n effect.setTexture(\"depthTexture\", this.depthTexture);\r\n effectRenderer.draw();\r\n },\r\n 1, // depth to use in the compositor.\r\n this.applyApproximateTransmittance ? Constants.ALPHA_PREMULTIPLIED_PORTERDUFF : Constants.ALPHA_ONEONE,\r\n true, // depthTest\r\n false, // depthWrite\r\n Constants.ALWAYS, // depthFunction\r\n false // restoreDefaultFramebuffer\r\n );\r\n }\r\n\r\n /**\r\n * Draws the sky compositor using {@link EffectWrapper} and {@link EffectRenderer}.\r\n */\r\n private _drawSkyCompositor(): void {\r\n const isEnabled = this.isEnabled();\r\n if (!isEnabled) {\r\n return;\r\n }\r\n\r\n // The sky compositor only renders when inside the atmosphere.\r\n const isOutsideAtmosphere = this._cameraAtmosphereVariables.clampedCameraRadius > this._physicalProperties.atmosphereRadius;\r\n if (isOutsideAtmosphere) {\r\n return;\r\n }\r\n\r\n if (this.depthTexture !== null && !this.depthTexture.isReady()) {\r\n return;\r\n }\r\n\r\n const engine = this._engine;\r\n this._skyCompositorEffectWrapper ??= CreateSkyCompositorEffectWrapper(\r\n engine,\r\n this.uniformBuffer,\r\n this._isSkyViewLutEnabled,\r\n this._isLinearSpaceComposition,\r\n this._applyApproximateTransmittance\r\n );\r\n\r\n const skyViewLut = this._isSkyViewLutEnabled ? this.skyViewLutRenderTarget : null;\r\n const multiScatteringLut = this._multiScatteringLutRenderTarget!;\r\n const transmittanceLut = this._transmittanceLut!.renderTarget;\r\n if (!this._skyCompositorEffectWrapper.isReady() || !(skyViewLut?.isReady() ?? true) || !multiScatteringLut.isReady() || !transmittanceLut.isReady()) {\r\n return;\r\n }\r\n\r\n DrawEffect(\r\n engine,\r\n this._effectRenderer!,\r\n this._skyCompositorEffectWrapper,\r\n null, // No render target, it will render to the current buffer.\r\n (effectRenderer, _, effect) => {\r\n this.bindUniformBufferToEffect(effect);\r\n effectRenderer.bindBuffers(effect);\r\n effect.setTexture(\"multiScatteringLut\", multiScatteringLut);\r\n effect.setTexture(\"transmittanceLut\", transmittanceLut);\r\n if (this._isSkyViewLutEnabled) {\r\n effect.setTexture(\"skyViewLut\", skyViewLut);\r\n }\r\n effectRenderer.draw();\r\n },\r\n 1, // depth to use in the compositor.\r\n this._applyApproximateTransmittance ? Constants.ALPHA_PREMULTIPLIED_PORTERDUFF : Constants.ALPHA_ONEONE,\r\n true, // depthTest\r\n false, // depthWrite\r\n Constants.EQUAL, // depthFunction\r\n false // restoreDefaultFramebuffer\r\n );\r\n }\r\n\r\n /**\r\n * Draws the globe atmosphere compositor using {@link EffectWrapper} and {@link EffectRenderer}.\r\n */\r\n private _drawGlobeAtmosphereCompositor(): void {\r\n const isEnabled = this.isEnabled();\r\n if (!isEnabled) {\r\n return;\r\n }\r\n\r\n // Globe atmosphere compositor only renders when outside the atmosphere.\r\n const isOutsideAtmosphere = this._cameraAtmosphereVariables.clampedCameraRadius > this._physicalProperties.atmosphereRadius;\r\n if (!isOutsideAtmosphere) {\r\n return;\r\n }\r\n\r\n const engine = this._engine;\r\n this._globeAtmosphereCompositorEffectWrapper ??= CreateGlobeAtmosphereCompositorEffectWrapper(\r\n engine,\r\n this.uniformBuffer,\r\n this._isSkyViewLutEnabled,\r\n this._isLinearSpaceComposition,\r\n this._applyApproximateTransmittance,\r\n this._aerialPerspectiveIntensity,\r\n this._aerialPerspectiveRadianceBias,\r\n this.depthTexture !== null\r\n );\r\n\r\n const skyViewLut = this._isSkyViewLutEnabled ? this.skyViewLutRenderTarget : null;\r\n const multiScatteringLut = this._multiScatteringLutRenderTarget!;\r\n const transmittanceLut = this._transmittanceLut!.renderTarget;\r\n if (!this._globeAtmosphereCompositorEffectWrapper.isReady() || !(skyViewLut?.isReady() ?? true) || !multiScatteringLut.isReady() || !transmittanceLut.isReady()) {\r\n return;\r\n }\r\n\r\n if (this.depthTexture !== null && !this.depthTexture.isReady()) {\r\n return;\r\n }\r\n\r\n DrawEffect(\r\n engine,\r\n this._effectRenderer!,\r\n this._globeAtmosphereCompositorEffectWrapper,\r\n null, // No render target, it will render to the current buffer.\r\n (effectRenderer, _, effect) => {\r\n this.bindUniformBufferToEffect(effect);\r\n effectRenderer.bindBuffers(effect);\r\n effect.setTexture(\"transmittanceLut\", transmittanceLut);\r\n effect.setTexture(\"multiScatteringLut\", multiScatteringLut);\r\n if (this._isSkyViewLutEnabled) {\r\n effect.setTexture(\"skyViewLut\", skyViewLut);\r\n }\r\n if (this.depthTexture !== null) {\r\n effect.setTexture(\"depthTexture\", this.depthTexture);\r\n }\r\n effectRenderer.draw();\r\n },\r\n 1, // depth to use in the compositor.\r\n this._applyApproximateTransmittance ? Constants.ALPHA_PREMULTIPLIED_PORTERDUFF : Constants.ALPHA_ONEONE,\r\n true, // depthTest\r\n false, // depthWrite\r\n Constants.ALWAYS, // depthFunction\r\n false // restoreDefaultFramebuffer\r\n );\r\n }\r\n\r\n private _disposeSkyCompositor(): void {\r\n this._skyCompositorEffectWrapper?.dispose();\r\n this._skyCompositorEffectWrapper = null;\r\n }\r\n\r\n private _disposeAerialPerspectiveCompositor(): void {\r\n this._aerialPerspectiveCompositorEffectWrapper?.dispose();\r\n this._aerialPerspectiveCompositorEffectWrapper = null;\r\n }\r\n\r\n private _disposeGlobeAtmosphereCompositor(): void {\r\n this._globeAtmosphereCompositorEffectWrapper?.dispose();\r\n this._globeAtmosphereCompositorEffectWrapper = null;\r\n }\r\n\r\n /**\r\n * Updates the camera variables that are specific to the atmosphere.\r\n * @param camera - The camera to update the variables for.\r\n */\r\n private _updatePerCameraVariables(camera: Camera): void {\r\n const light = this._lights[0];\r\n this._directionToLight.copyFrom(light.direction);\r\n this._directionToLight.scaleInPlace(-1);\r\n\r\n const properties = this._physicalProperties;\r\n const cameraAtmosphereVariables = this._cameraAtmosphereVariables;\r\n cameraAtmosphereVariables.update(\r\n camera,\r\n properties.planetRadius,\r\n properties.planetRadiusWithOffset,\r\n properties.atmosphereRadius,\r\n this._directionToLight,\r\n this.originHeight\r\n );\r\n\r\n this._transmittanceLut!.updateLightParameters(light, cameraAtmosphereVariables.clampedCameraRadius, cameraAtmosphereVariables.cameraGeocentricNormal);\r\n this._linearLightColor.copyFrom(light.diffuse);\r\n\r\n this.getDiffuseSkyIrradianceToRef(this._directionToLight, 0, cameraAtmosphereVariables.cameraGeocentricNormal, this.lights[0].intensity, this._tempSceneAmbient);\r\n if (!this.isLinearSpaceLight) {\r\n this._tempSceneAmbient.toGammaSpaceToRef(this._tempSceneAmbient);\r\n }\r\n this.scene.ambientColor = this._tempSceneAmbient;\r\n\r\n this.onAfterUpdateVariablesForCameraObservable.notifyObservers(camera);\r\n }\r\n\r\n /**\r\n * Renders the lookup tables, some of which can vary per-camera.\r\n * It is expected that updatePerCameraVariables was previously called.\r\n */\r\n private _renderLutsForCamera(): void {\r\n {\r\n this.onBeforeLightVariablesUpdateObservable.notifyObservers();\r\n\r\n const light = this.lights[0];\r\n if (!this.isLinearSpaceLight) {\r\n light.diffuse = light.diffuse.toGammaSpaceToRef(light.diffuse);\r\n light.specular = light.specular.toGammaSpaceToRef(light.specular);\r\n }\r\n const intensity = light.intensity;\r\n this._lightRadianceAtCamera.set(intensity * this._linearLightColor.r, intensity * this._linearLightColor.g, intensity * this._linearLightColor.b);\r\n }\r\n\r\n if (this.uniformBuffer.useUbo) {\r\n this._updateUniformBuffer();\r\n }\r\n\r\n // Render the LUTs.\r\n const isEnabled = this.isEnabled();\r\n {\r\n this.onBeforeRenderLutsForCameraObservable.notifyObservers();\r\n\r\n // After UBO update we can render the global LUTs which use some of these values on the GPU.\r\n // TODO: Could break out update and UBOs to global vs. per-camera.\r\n this.renderGlobalLuts();\r\n\r\n // If atmosphere is enabled, render the per-camera LUTs (sky view and aerial perspective).\r\n if (isEnabled && !this._transmittanceLut!.isDirty && this._hasRenderedMultiScatteringLut) {\r\n if (this._isSkyViewLutEnabled) {\r\n this._drawSkyViewLut();\r\n }\r\n\r\n // Only need to render aerial perspective LUT when inside the atmosphere.\r\n if (this._isAerialPerspectiveLutEnabled && this._cameraAtmosphereVariables.clampedCameraRadius <= this._physicalProperties.atmosphereRadius) {\r\n this._drawAerialPerspectiveLut();\r\n }\r\n }\r\n\r\n this.onAfterRenderLutsForCameraObservable.notifyObservers();\r\n }\r\n }\r\n\r\n /**\r\n * Renders the lookup tables that do not depend on a camera position.\r\n */\r\n public renderGlobalLuts(): void {\r\n const hasNewTransmittanceLut = this._transmittanceLut!.render();\r\n if (hasNewTransmittanceLut) {\r\n this._hasRenderedMultiScatteringLut = false;\r\n this._diffuseSkyIrradianceLut?.markDirty();\r\n }\r\n\r\n if (!this._transmittanceLut!.isDirty && !this._hasRenderedMultiScatteringLut) {\r\n this._multiScatteringEffectWrapper ??= this._createMultiScatteringEffectWrapper();\r\n if (this._multiScatteringEffectWrapper?.isReady() && this._multiScatteringLutRenderTarget?.isReady()) {\r\n this._drawMultiScatteringLut();\r\n this._hasRenderedMultiScatteringLut = true;\r\n }\r\n }\r\n\r\n if (!this._transmittanceLut!.isDirty && this._hasRenderedMultiScatteringLut) {\r\n this._diffuseSkyIrradianceLut?.render(); // Will only render if needed.\r\n }\r\n }\r\n\r\n /**\r\n * Binds the atmosphere's uniform buffer to an {@link Effect}.\r\n * @param effect - The {@link Effect} to bind the uniform buffer to.\r\n */\r\n public bindUniformBufferToEffect(effect: Effect): void {\r\n const uniformBuffer = this.uniformBuffer;\r\n const name = uniformBuffer.name;\r\n uniformBuffer.bindToEffect(effect, name);\r\n if (uniformBuffer.useUbo) {\r\n const engine = this.scene.getEngine();\r\n engine.bindUniformBufferBase(uniformBuffer.getBuffer()!, effect._uniformBuffersNames[name], name);\r\n } else {\r\n this._updateUniformBuffer();\r\n }\r\n }\r\n\r\n /**\r\n * Updates the atmosphere's uniform buffer.\r\n */\r\n private _updateUniformBuffer(): void {\r\n const physicalProperties = this._physicalProperties;\r\n const cameraAtmosphereVariables = this._cameraAtmosphereVariables;\r\n const ubo = this.uniformBuffer;\r\n\r\n ubo.updateVector3(\"peakRayleighScattering\", physicalProperties.rayleighScattering);\r\n ubo.updateFloat(\"planetRadius\", physicalProperties.planetRadius);\r\n ubo.updateVector3(\"peakMieScattering\", physicalProperties.mieScattering);\r\n ubo.updateFloat(\"atmosphereThickness\", physicalProperties.atmosphereThickness);\r\n ubo.updateVector3(\"peakMieAbsorption\", physicalProperties.mieAbsorption);\r\n ubo.updateFloat(\"planetRadiusSquared\", physicalProperties.planetRadiusSquared);\r\n ubo.updateVector3(\"peakMieExtinction\", physicalProperties.mieExtinction);\r\n ubo.updateFloat(\"atmosphereRadius\", physicalProperties.atmosphereRadius);\r\n ubo.updateVector3(\"peakOzoneAbsorption\", physicalProperties.ozoneAbsorption);\r\n ubo.updateFloat(\"atmosphereRadiusSquared\", physicalProperties.atmosphereRadiusSquared);\r\n ubo.updateFloat(\"horizonDistanceToAtmosphereEdge\", physicalProperties.horizonDistanceToAtmosphereEdge);\r\n ubo.updateFloat(\"horizonDistanceToAtmosphereEdgeSquared\", physicalProperties.horizonDistanceToAtmosphereEdgeSquared);\r\n ubo.updateFloat(\"planetRadiusWithOffset\", physicalProperties.planetRadiusWithOffset);\r\n ubo.updateFloat(\"planetRadiusOffset\", physicalProperties.planetRadiusOffset);\r\n ubo.updateFloat(\"aerialPerspectiveRadianceBias\", this._aerialPerspectiveRadianceBias);\r\n ubo.updateFloat(\"inverseAtmosphereThickness\", 1 / physicalProperties.atmosphereThickness);\r\n ubo.updateFloat(\"aerialPerspectiveTransmittanceScale\", this._aerialPerspectiveTransmittanceScale);\r\n ubo.updateMatrix(\"inverseViewProjectionWithoutTranslation\", cameraAtmosphereVariables.inverseViewProjectionMatrixWithoutTranslation);\r\n ubo.updateVector3(\"directionToLight\", this._directionToLight);\r\n ubo.updateFloat(\"multiScatteringIntensity\", this.multiScatteringIntensity);\r\n ubo.updateVector3(\"directionToLightRelativeToCameraGeocentricNormal\", cameraAtmosphereVariables.directionToLightRelativeToCameraGeocentricNormal);\r\n ubo.updateFloat(\"cameraRadius\", cameraAtmosphereVariables.cameraRadius);\r\n ubo.updateVector3(\"lightRadianceAtCamera\", this._lightRadianceAtCamera);\r\n ubo.updateFloat(\"diffuseSkyIrradianceDesaturationFactor\", this._diffuseSkyIrradianceDesaturationFactor);\r\n ubo.updateColor3(\"groundAlbedo\", this._groundAlbedo);\r\n ubo.updateFloat(\"aerialPerspectiveSaturation\", this._aerialPerspectiveSaturation);\r\n ubo.updateVector3(\"minMultiScattering\", this._minimumMultiScattering);\r\n ubo.updateFloat(\"diffuseSkyIrradianceIntensity\", this._diffuseSkyIrradianceIntensity);\r\n ubo.updateVector3(\"cameraPositionGlobal\", cameraAtmosphereVariables.cameraPositionGlobal);\r\n ubo.updateFloat(\"lightIntensity\", this.lights[0].intensity);\r\n ubo.updateVector3(\"clampedCameraPositionGlobal\", cameraAtmosphereVariables.clampedCameraPositionGlobal);\r\n ubo.updateFloat(\"aerialPerspectiveIntensity\", this._aerialPerspectiveIntensity);\r\n ubo.updateVector3(\"cameraGeocentricNormal\", cameraAtmosphereVariables.cameraGeocentricNormal);\r\n ubo.updateFloat(\"clampedCameraRadius\", cameraAtmosphereVariables.clampedCameraRadius);\r\n ubo.updateVector3(\"cameraForward\", cameraAtmosphereVariables.cameraForward);\r\n ubo.updateFloat(\"clampedCameraHeight\", cameraAtmosphereVariables.clampedCameraHeight);\r\n ubo.updateVector3(\"cameraPosition\", cameraAtmosphereVariables.cameraPosition);\r\n ubo.updateFloat(\"cosCameraHorizonAngleFromZenith\", cameraAtmosphereVariables.cosCameraHorizonAngleFromZenith);\r\n ubo.updateVector4(\"viewport\", cameraAtmosphereVariables.viewport);\r\n ubo.updateColor3(\"additionalDiffuseSkyIrradiance\", this._additionalDiffuseSkyIrradiance);\r\n ubo.updateFloat(\"cameraHeight\", cameraAtmosphereVariables.cameraHeight);\r\n ubo.updateFloat(\"cameraNearPlane\", cameraAtmosphereVariables.cameraNearPlane);\r\n ubo.updateFloat(\"originHeight\", this._originHeight);\r\n ubo.updateFloat(\"sinCameraAtmosphereHorizonAngleFromNadir\", cameraAtmosphereVariables.sinCameraAtmosphereHorizonAngleFromNadir);\r\n ubo.updateFloat(\"atmosphereExposure\", this._exposure);\r\n ubo.update();\r\n }\r\n\r\n /**\r\n * Draws the aerial perspective LUT using {@link EffectWrapper} and {@link EffectRenderer}.\r\n */\r\n private _drawAerialPerspectiveLut(): void {\r\n const transmittanceLut = this._transmittanceLut!.renderTarget;\r\n const multiScatteringLut = this._multiScatteringLutRenderTarget;\r\n DrawEffect(\r\n this._engine,\r\n this._effectRenderer!,\r\n this._aerialPerspectiveLutEffectWrapper,\r\n this._aerialPerspectiveLutRenderTarget,\r\n (effectRenderer, renderTarget, effect, engine) => {\r\n this.bindUniformBufferToEffect(effect);\r\n const layers = 32;\r\n effect.setTexture(\"transmittanceLut\", transmittanceLut);\r\n effect.setTexture(\"multiScatteringLut\", multiScatteringLut);\r\n for (let layer = 0; layer < layers; layer++) {\r\n engine.bindFramebuffer(renderTarget!, undefined, undefined, undefined, true, undefined, layer);\r\n effectRenderer.bindBuffers(effect);\r\n effect.setFloat(\"layerIdx\", layer);\r\n effectRenderer.draw();\r\n }\r\n }\r\n );\r\n }\r\n\r\n /**\r\n * Draws the sky view LUT using {@link EffectWrapper} and {@link EffectRenderer}.\r\n */\r\n private _drawSkyViewLut(): void {\r\n const transmittanceLut = this._transmittanceLut!.renderTarget;\r\n const multiScatteringLut = this._multiScatteringLutRenderTarget!;\r\n DrawEffect(this._engine, this._effectRenderer!, this._skyViewLutEffectWrapper, this._skyViewLutRenderTarget, (effectRenderer, renderTarget, effect, engine) => {\r\n this.bindUniformBufferToEffect(effect);\r\n engine.bindFramebuffer(renderTarget!, undefined, undefined, undefined, true);\r\n effectRenderer.bindBuffers(effect);\r\n effect.setTexture(\"transmittanceLut\", transmittanceLut);\r\n effect.setTexture(\"multiScatteringLut\", multiScatteringLut);\r\n effectRenderer.draw();\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Creates an {@link EffectWrapper} with the given parameters.\r\n * @param engine - The engine to use.\r\n * @param name - The name of the effect wrapper.\r\n * @param fragmentShader - The fragment shader source.\r\n * @param uniformNames - The uniform names to use.\r\n * @param samplerNames - The sampler names to use.\r\n * @param uniformBuffers - The uniform buffers to use.\r\n * @param defineNames - Array of define names to prepend with \"#define \".\r\n * @returns The effect wrapper.\r\n */\r\nconst CreateEffectWrapper = (\r\n engine: AbstractEngine,\r\n name: string,\r\n fragmentShader: string,\r\n uniformNames?: string[],\r\n samplerNames?: string[],\r\n uniformBuffers?: string[],\r\n defineNames?: string[]\r\n): EffectWrapper => {\r\n const defines = defineNames?.map((defineName) => `#define ${defineName}`) ?? [];\r\n\r\n return new EffectWrapper({\r\n engine,\r\n name,\r\n vertexShader: \"fullscreenTriangle\",\r\n fragmentShader,\r\n attributeNames: [\"position\"],\r\n uniformNames,\r\n uniformBuffers,\r\n samplerNames,\r\n defines,\r\n useShaderStore: true,\r\n });\r\n};\r\n\r\nconst CreateRenderTargetTexture = (\r\n name: string,\r\n size: number | { width: number; height: number; layers?: number },\r\n scene: Scene,\r\n options?: RenderTargetTextureOptions\r\n): RenderTargetTexture => {\r\n const rtOptions: RenderTargetTextureOptions = {\r\n generateMipMaps: false,\r\n generateDepthBuffer: false,\r\n generateStencilBuffer: false,\r\n gammaSpace: false,\r\n samplingMode: Constants.TEXTURE_BILINEAR_SAMPLINGMODE,\r\n type: Constants.TEXTURETYPE_HALF_FLOAT,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n ...options,\r\n };\r\n const renderTarget = new RenderTargetTexture(name, size, scene, rtOptions);\r\n\r\n renderTarget.wrapU = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n renderTarget.wrapV = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n renderTarget.anisotropicFilteringLevel = 1;\r\n renderTarget.skipInitialClear = true;\r\n return renderTarget;\r\n};\r\n\r\n/**\r\n * Common setup and teardown for drawing LUTs or composition passes.\r\n * @param engine - The engine to use.\r\n * @param effectRenderer - The effect renderer to use.\r\n * @param effectWrapper - The effect wrapper to use.\r\n * @param renderTarget - The render target.\r\n * @param drawCallback - Callback function that performs the drawing.\r\n * @param depth - The depth value to set in the effect.\r\n * @param alphaMode - The alpha mode to set before drawing.\r\n * @param depthTest - Whether to enable depth testing.\r\n * @param depthWrite - Optional depth write state to set before drawing.\r\n * @param depthFunction - The depth function to set before drawing.\r\n * @param restoreDefaultFramebuffer - Whether to restore the default framebuffer after drawing.\r\n */\r\nconst DrawEffect = (\r\n engine: AbstractEngine,\r\n effectRenderer: EffectRenderer,\r\n effectWrapper: Nullable<EffectWrapper>,\r\n renderTarget: Nullable<RenderTargetTexture>,\r\n drawCallback: (effectRenderer: EffectRenderer, renderTarget: Nullable<RenderTargetWrapper>, effect: Effect, engine: AbstractEngine) => void,\r\n depth = 0,\r\n alphaMode = Constants.ALPHA_DISABLE,\r\n depthTest = true,\r\n depthWrite?: boolean,\r\n depthFunction = Constants.LEQUAL,\r\n restoreDefaultFramebuffer = true\r\n): void => {\r\n if ((renderTarget !== null && !renderTarget.isReady()) || !effectWrapper?.isReady()) {\r\n return;\r\n }\r\n\r\n // Set additional depth/stencil states before calling applyEffectWrapper.\r\n const currentDepthWrite = engine.getDepthWrite();\r\n if (depthWrite !== undefined) {\r\n engine.setDepthWrite(depthWrite);\r\n }\r\n const currentDepthFunction = engine.getDepthFunction();\r\n engine.setDepthFunction(depthFunction);\r\n\r\n // Likewise with the alpha mode, which can affect depth state too.\r\n const currentAlphaMode = engine.getAlphaMode();\r\n if (alphaMode !== Constants.ALPHA_DISABLE) {\r\n engine.setAlphaMode(alphaMode);\r\n }\r\n\r\n effectRenderer.saveStates();\r\n effectRenderer.setViewport();\r\n effectRenderer.applyEffectWrapper(effectWrapper, depthTest); // Note, stencil is false by default.\r\n\r\n const effect = effectWrapper.effect;\r\n\r\n effect.setFloat(\"depth\", depth);\r\n\r\n // Call the specific drawing logic.\r\n drawCallback(effectRenderer, renderTarget?.renderTarget!, effect, engine);\r\n\r\n // Restore state (order matters!)\r\n engine.setAlphaMode(currentAlphaMode);\r\n if (currentDepthWrite !== undefined) {\r\n engine.setDepthWrite(currentDepthWrite);\r\n }\r\n if (currentDepthFunction) {\r\n engine.setDepthFunction(currentDepthFunction);\r\n }\r\n effectRenderer.restoreStates();\r\n\r\n // And restore the default framebuffer.\r\n if (restoreDefaultFramebuffer) {\r\n engine.restoreDefaultFramebuffer();\r\n }\r\n};\r\n\r\n/**\r\n * Creates an EffectWrapper for the sky compositor.\r\n * @param engine - The engine to use.\r\n * @param uniformBuffer - The uniform buffer to use.\r\n * @param isSkyViewLutEnabled - Whether the sky view LUT is enabled.\r\n * @param isLinearSpaceComposition - Whether composition is in linear space.\r\n * @param applyApproximateTransmittance - Whether to apply approximate transmittance.\r\n * @returns The created EffectWrapper.\r\n */\r\nconst CreateSkyCompositorEffectWrapper = (\r\n engine: AbstractEngine,\r\n uniformBuffer: UniformBuffer,\r\n isSkyViewLutEnabled: boolean,\r\n isLinearSpaceComposition: boolean,\r\n applyApproximateTransmittance: boolean\r\n): EffectWrapper => {\r\n const useUbo = uniformBuffer.useUbo;\r\n const defines = [\"COMPUTE_WORLD_RAY\"];\r\n if (isSkyViewLutEnabled) {\r\n defines.push(\"USE_SKY_VIEW_LUT\");\r\n }\r\n if (!isLinearSpaceComposition) {\r\n defines.push(\"OUTPUT_TO_SRGB\");\r\n }\r\n if (applyApproximateTransmittance) {\r\n defines.push(\"APPLY_TRANSMITTANCE_BLENDING\");\r\n }\r\n const textures = isSkyViewLutEnabled ? [\"skyViewLut\"] : [\"transmittanceLut\", \"multiScatteringLut\"];\r\n return CreateEffectWrapper(\r\n engine,\r\n \"atmo-skyCompositor\",\r\n \"compositeSky\",\r\n [\"depth\", ...(useUbo ? [] : uniformBuffer.getUniformNames())],\r\n textures,\r\n useUbo ? [uniformBuffer.name] : [],\r\n defines\r\n );\r\n};\r\n\r\n/**\r\n * Creates an EffectWrapper for the aerial perspective LUT.\r\n * @param engine - The engine to use.\r\n * @param uniformBuffer - The uniform buffer to use.\r\n * @returns The created EffectWrapper.\r\n */\r\nconst CreateAerialPerspectiveEffectWrapper = (engine: AbstractEngine, uniformBuffer: UniformBuffer): EffectWrapper =>\r\n CreateEffectWrapper(\r\n engine,\r\n \"atmo-aerialPerspective\",\r\n \"aerialPerspective\",\r\n [\"layerIdx\", \"depth\", ...(uniformBuffer.useUbo ? [] : uniformBuffer.getUniformNames())],\r\n [\"transmittanceLut\", \"multiScatteringLut\"],\r\n uniformBuffer.useUbo ? [uniformBuffer.name] : [],\r\n [\"COMPUTE_WORLD_RAY\"]\r\n );\r\n\r\n/**\r\n * Creates an EffectWrapper for the aerial perspective compositor.\r\n * @param engine - The engine to use.\r\n * @param uniformBuffer - The uniform buffer.\r\n * @param isAerialPerspectiveLutEnabled - Whether the aerial perspective LUT is enabled.\r\n * @param isSkyViewLutEnabled - Whether the sky view LUT is enabled.\r\n * @param isLinearSpaceComposition - Whether composition is in linear space.\r\n * @param applyApproximateTransmittance - Whether to apply approximate transmittance.\r\n * @param aerialPerspectiveIntensity - The aerial perspective intensity.\r\n * @param aerialPerspectiveRadianceBias - The aerial perspective radiance bias.\r\n * @returns The created EffectWrapper.\r\n */\r\nconst CreateAerialPerspectiveCompositorEffectWrapper = (\r\n engine: AbstractEngine,\r\n uniformBuffer: UniformBuffer,\r\n isAerialPerspectiveLutEnabled: boolean,\r\n isSkyViewLutEnabled: boolean,\r\n isLinearSpaceComposition: boolean,\r\n applyApproximateTransmittance: boolean,\r\n aerialPerspectiveIntensity: number,\r\n aerialPerspectiveRadianceBias: number\r\n): EffectWrapper => {\r\n const useUbo = uniformBuffer.useUbo;\r\n const defines = [\"COMPUTE_WORLD_RAY\"];\r\n if (isAerialPerspectiveLutEnabled) {\r\n defines.push(\"USE_AERIAL_PERSPECTIVE_LUT\");\r\n }\r\n if (isSkyViewLutEnabled) {\r\n defines.push(\"USE_SKY_VIEW_LUT\");\r\n }\r\n if (aerialPerspectiveIntensity !== 1) {\r\n defines.push(\"APPLY_AERIAL_PERSPECTIVE_INTENSITY\");\r\n }\r\n if (!isLinearSpaceComposition) {\r\n defines.push(\"OUTPUT_TO_SRGB\");\r\n }\r\n if (applyApproximateTransmittance) {\r\n defines.push(\"APPLY_TRANSMITTANCE_BLENDING\");\r\n }\r\n if (aerialPerspectiveRadianceBias !== 0.0) {\r\n defines.push(\"APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS\");\r\n }\r\n\r\n const samplers = [\"transmittanceLut\", \"multiScatteringLut\", \"depthTexture\"];\r\n if (isSkyViewLutEnabled) {\r\n samplers.push(\"skyViewLut\");\r\n }\r\n if (isAerialPerspectiveLutEnabled) {\r\n samplers.push(\"aerialPerspectiveLut\");\r\n }\r\n\r\n return CreateEffectWrapper(\r\n engine,\r\n \"atmo-aerialPerspectiveCompositor\",\r\n \"compositeAerialPerspective\",\r\n [\"depth\", ...(useUbo ? [] : uniformBuffer.getUniformNames())],\r\n samplers,\r\n useUbo ? [uniformBuffer.name] : [],\r\n defines\r\n );\r\n};\r\n\r\n/**\r\n * Creates an EffectWrapper for the globe atmosphere compositor.\r\n * @param engine - The engine to use.\r\n * @param uniformBuffer - The uniform buffer to use.\r\n * @param isSkyViewLutEnabled - Whether the sky view LUT is enabled.\r\n * @param isLinearSpaceComposition - Whether composition is in linear space.\r\n * @param applyApproximateTransmittance - Whether to apply approximate transmittance.\r\n * @param aerialPerspectiveIntensity - The aerial perspective intensity.\r\n * @param aerialPerspectiveRadianceBias - The aerial perspective radiance bias.\r\n * @param hasDepthTexture - Whether a depth texture is available.\r\n * @returns The created EffectWrapper.\r\n */\r\nconst CreateGlobeAtmosphereCompositorEffectWrapper = (\r\n engine: AbstractEngine,\r\n uniformBuffer: UniformBuffer,\r\n isSkyViewLutEnabled: boolean,\r\n isLinearSpaceComposition: boolean,\r\n applyApproximateTransmittance: boolean,\r\n aerialPerspectiveIntensity: number,\r\n aerialPerspectiveRadianceBias: number,\r\n hasDepthTexture: boolean\r\n): EffectWrapper => {\r\n const useUbo = uniformBuffer.useUbo;\r\n const defines = [\"COMPUTE_WORLD_RAY\"];\r\n if (isSkyViewLutEnabled) {\r\n defines.push(\"USE_SKY_VIEW_LUT\");\r\n }\r\n if (aerialPerspectiveIntensity !== 1) {\r\n defines.push(\"APPLY_AERIAL_PERSPECTIVE_INTENSITY\");\r\n }\r\n if (!isLinearSpaceComposition) {\r\n defines.push(\"OUTPUT_TO_SRGB\");\r\n }\r\n if (hasDepthTexture) {\r\n defines.push(\"HAS_DEPTH_TEXTURE\");\r\n }\r\n if (applyApproximateTransmittance) {\r\n defines.push(\"APPLY_TRANSMITTANCE_BLENDING\");\r\n }\r\n if (aerialPerspectiveRadianceBias !== 0.0) {\r\n defines.push(\"APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS\");\r\n }\r\n\r\n const samplers = [\"transmittanceLut\", \"multiScatteringLut\"];\r\n if (isSkyViewLutEnabled) {\r\n samplers.push(\"skyViewLut\");\r\n }\r\n if (hasDepthTexture) {\r\n samplers.push(\"depthTexture\");\r\n }\r\n\r\n return CreateEffectWrapper(\r\n engine,\r\n \"atmo-globeAtmosphereCompositor\",\r\n \"compositeGlobeAtmosphere\",\r\n [\"depth\", ...(useUbo ? [] : uniformBuffer.getUniformNames())],\r\n samplers,\r\n useUbo ? [uniformBuffer.name] : [],\r\n defines\r\n );\r\n};\r\n\r\n/**\r\n * Creates an EffectWrapper for the sky view LUT.\r\n * @param engine - The engine to use.\r\n * @param uniformBuffer - The uniform buffer to use.\r\n * @returns The created EffectWrapper.\r\n */\r\nconst CreateSkyViewEffectWrapper = (engine: AbstractEngine, uniformBuffer: UniformBuffer): EffectWrapper =>\r\n CreateEffectWrapper(\r\n engine,\r\n \"atmo-skyView\",\r\n \"skyView\",\r\n [\"depth\", ...(uniformBuffer.useUbo ? [] : uniformBuffer.getUniformNames())],\r\n [\"transmittanceLut\", \"multiScatteringLut\"],\r\n uniformBuffer.useUbo ? [uniformBuffer.name] : []\r\n );\r\n","import type { Scene } from \"core/scene\";\r\nimport { Matrix, Quaternion, Vector3 } from \"core/Maths/math\";\r\n\r\nimport type { HtmlMesh } from \"./htmlMesh\";\r\nimport { Camera } from \"core/Cameras/camera\";\r\nimport type { SubMesh } from \"core/Meshes/subMesh\";\r\nimport { RenderingGroup } from \"core/Rendering/renderingGroup\";\r\n\r\nimport type { Observer } from \"core/Misc/observable\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport type { AbstractEngine } from \"core/Engines\";\r\nimport { TransformNode } from \"core/Meshes/transformNode\";\r\n\r\nconst PositionUpdateFailMessage = \"Failed to update html mesh renderer position due to failure to get canvas rect. HtmlMesh instances may not render correctly\";\r\nconst BabylonUnitsToPixels = 100;\r\n\r\n/**\r\n * A function that compares two submeshes and returns a number indicating which\r\n * should be rendered first.\r\n */\r\ntype RenderOrderFunction = (subMeshA: SubMesh, subMeshB: SubMesh) => number;\r\n\r\ntype RenderLayerElements = {\r\n container: HTMLElement;\r\n domElement: HTMLElement;\r\n cameraElement: HTMLElement;\r\n};\r\n\r\n// Returns a function that ensures that HtmlMeshes are rendered before all other meshes.\r\n// Note this will only be applied to group 0.\r\n// If neither mesh is an HtmlMesh, then the default render order is used\r\n// This prevents HtmlMeshes from appearing in front of other meshes when they are behind them\r\nconst RenderOrderFunc = (defaultRenderOrder: RenderOrderFunction): RenderOrderFunction => {\r\n return (subMeshA: SubMesh, subMeshB: SubMesh) => {\r\n const meshA = subMeshA.getMesh();\r\n const meshB = subMeshB.getMesh();\r\n\r\n // Use property check instead of instanceof since it is less expensive and\r\n // this will be called many times per frame\r\n const meshIsHtmlMeshA = (meshA as any)[\"isHtmlMesh\"];\r\n const meshIsHtmlMeshB = (meshB as any)[\"isHtmlMesh\"];\r\n if (meshIsHtmlMeshA) {\r\n return meshIsHtmlMeshB ? (meshA.absolutePosition.z <= meshB.absolutePosition.z ? 1 : -1) : -1;\r\n } else {\r\n return meshIsHtmlMeshB ? 1 : defaultRenderOrder(subMeshA, subMeshB);\r\n }\r\n };\r\n};\r\n\r\n/**\r\n * An instance of this is required to render HtmlMeshes in the scene.\r\n * if using HtmlMeshes, you must not set render order for group 0 using\r\n * scene.setRenderingOrder. You must instead pass the compare functions\r\n * to the HtmlMeshRenderer constructor. If you do not, then your render\r\n * order will be overwritten if the HtmlMeshRenderer is created after and\r\n * the HtmlMeshes will not render correctly (they will appear in front of\r\n * meshes that are actually in front of them) if the HtmlMeshRenderer is\r\n * created before.\r\n */\r\nexport class HtmlMeshRenderer {\r\n /**\r\n * Global scale factor applied to the homogeneous `w` component (m[15]) of the\r\n * transformation matrix when projecting 3D objects into pixel space.\r\n *\r\n * This value is used to balance Babylon units against screen pixels, ensuring\r\n * that HTML-mapped or screen-space objects appear with the correct relative\r\n * size. Adjust with care, as changing it affects the projection scale of all\r\n * transformed objects.\r\n *\r\n * The default value is `0.00001`, which works well when 1 Babylon unit\r\n * corresponds to 1 meter, and the typical screen resolution is around\r\n * 100 pixels per meter (i.e., 1 pixel per centimeter).\r\n */\r\n public static PROJECTION_SCALE_FACTOR = 0.00001;\r\n\r\n private _containerId?: string;\r\n private _inSceneElements?: RenderLayerElements | null;\r\n private _overlayElements?: RenderLayerElements | null;\r\n private _engine: AbstractEngine;\r\n\r\n private _cache = {\r\n cameraData: { fov: 0, position: new Vector3(), style: \"\" },\r\n htmlMeshData: new WeakMap<object, { style: string }>(),\r\n };\r\n private _width = 0;\r\n private _height = 0;\r\n private _heightHalf = 0;\r\n\r\n private _cameraWorldMatrix?: Matrix;\r\n\r\n // Create some refs to avoid creating new objects every frame\r\n private _temp = {\r\n scaleTransform: new Vector3(),\r\n rotationTransform: new Quaternion(),\r\n positionTransform: new Vector3(),\r\n objectMatrix: Matrix.Identity(),\r\n cameraWorldMatrix: Matrix.Identity(),\r\n cameraRotationMatrix: Matrix.Identity(),\r\n cameraWorldMatrixAsArray: new Array(16),\r\n };\r\n\r\n // Keep track of DPR so we can resize if DPR changes\r\n // Otherwise the DOM content will scale, but the mesh won't\r\n private _lastDevicePixelRatio = window.devicePixelRatio;\r\n\r\n // Keep track of camera matrix changes so we only update the\r\n // DOM element styles when necessary\r\n private _cameraMatrixUpdated = true;\r\n\r\n // Keep track of position changes so we only update the DOM element\r\n // styles when necessary\r\n private _previousCanvasDocumentPosition = {\r\n top: 0,\r\n left: 0,\r\n };\r\n\r\n private _renderObserver: Observer<Scene> | null = null;\r\n\r\n /**\r\n * Contruct an instance of HtmlMeshRenderer\r\n * @param scene\r\n * @param options object containing the following optional properties:\r\n * @returns\r\n */\r\n constructor(\r\n scene: Scene,\r\n {\r\n parentContainerId = null,\r\n _containerId = \"css-container\",\r\n enableOverlayRender = true,\r\n defaultOpaqueRenderOrder = RenderingGroup.PainterSortCompare,\r\n defaultAlphaTestRenderOrder = RenderingGroup.PainterSortCompare,\r\n defaultTransparentRenderOrder = RenderingGroup.defaultTransparentSortCompare,\r\n }: {\r\n parentContainerId?: string | null;\r\n _containerId?: string;\r\n defaultOpaqueRenderOrder?: RenderOrderFunction;\r\n defaultAlphaTestRenderOrder?: RenderOrderFunction;\r\n defaultTransparentRenderOrder?: RenderOrderFunction;\r\n enableOverlayRender?: boolean;\r\n } = {}\r\n ) {\r\n // Requires a browser to work. Only init if we are in a browser\r\n if (typeof document === \"undefined\") {\r\n return;\r\n }\r\n this._containerId = _containerId;\r\n this._init(scene, parentContainerId, enableOverlayRender, defaultOpaqueRenderOrder, defaultAlphaTestRenderOrder, defaultTransparentRenderOrder);\r\n }\r\n\r\n /**\r\n * Dispose of the HtmlMeshRenderer\r\n */\r\n public dispose() {\r\n if (this._renderObserver) {\r\n this._renderObserver.remove();\r\n this._renderObserver = null;\r\n }\r\n\r\n this._overlayElements?.container.remove();\r\n this._overlayElements = null;\r\n\r\n this._inSceneElements?.container.remove();\r\n this._inSceneElements = null;\r\n }\r\n\r\n protected _init(\r\n scene: Scene,\r\n parentContainerId: string | null,\r\n enableOverlayRender: boolean,\r\n defaultOpaqueRenderOrder: RenderOrderFunction,\r\n defaultAlphaTestRenderOrder: RenderOrderFunction,\r\n defaultTransparentRenderOrder: RenderOrderFunction\r\n ): void {\r\n // Requires a browser to work. Only init if we are in a browser\r\n if (typeof document === \"undefined\") {\r\n return;\r\n }\r\n\r\n // Create the DOM containers\r\n let parentContainer = parentContainerId ? document.getElementById(parentContainerId) : document.body;\r\n\r\n if (!parentContainer) {\r\n parentContainer = document.body;\r\n }\r\n\r\n // if the container already exists, then remove it\r\n const inSceneContainerId = `${this._containerId}_in_scene`;\r\n this._inSceneElements = this._createRenderLayerElements(inSceneContainerId);\r\n\r\n parentContainer.insertBefore(this._inSceneElements.container, parentContainer.firstChild);\r\n\r\n if (enableOverlayRender) {\r\n const overlayContainerId = `${this._containerId}_overlay`;\r\n this._overlayElements = this._createRenderLayerElements(overlayContainerId);\r\n const zIndex = +(scene.getEngine().getRenderingCanvas()!.style.zIndex ?? \"0\") + 1;\r\n this._overlayElements.container.style.zIndex = `${zIndex}`;\r\n this._overlayElements.container.style.pointerEvents = \"none\";\r\n parentContainer.insertBefore(this._overlayElements.container, parentContainer.firstChild);\r\n }\r\n this._engine = scene.getEngine();\r\n const clientRect = this._engine.getRenderingCanvasClientRect();\r\n if (!clientRect) {\r\n throw new Error(\"Failed to get client rect for rendering canvas\");\r\n }\r\n\r\n // Set the size and resize behavior\r\n this._setSize(clientRect.width, clientRect.height);\r\n\r\n this._engine.onResizeObservable.add(() => {\r\n const clientRect = this._engine.getRenderingCanvasClientRect();\r\n if (clientRect) {\r\n this._setSize(clientRect.width, clientRect.height);\r\n }\r\n });\r\n\r\n let projectionObs: Observer<Camera>;\r\n let matrixObs: Observer<Camera>;\r\n\r\n const observeCamera = () => {\r\n const camera = scene.activeCamera;\r\n if (camera) {\r\n projectionObs = camera.onProjectionMatrixChangedObservable.add(() => {\r\n this._onCameraMatrixChanged(camera);\r\n });\r\n matrixObs = camera.onViewMatrixChangedObservable.add(() => {\r\n this._onCameraMatrixChanged(camera);\r\n });\r\n }\r\n };\r\n\r\n observeCamera();\r\n\r\n scene.onActiveCameraChanged.add(() => {\r\n if (projectionObs) {\r\n scene.activeCamera?.onProjectionMatrixChangedObservable.remove(projectionObs);\r\n }\r\n if (matrixObs) {\r\n scene.activeCamera?.onViewMatrixChangedObservable.remove(matrixObs);\r\n }\r\n observeCamera();\r\n });\r\n\r\n // We need to make sure that HtmlMeshes are rendered before all other meshes\r\n // so that they don't appear in front of meshes that are actually in front of them\r\n // Updating the render order isn't ideal, but it is the only way to acheive this\r\n // The implication is that an app using the HtmlMeshRendered must set the scene render order\r\n // via the HtmlMeshRendered constructor\r\n const opaqueRenderOrder = RenderOrderFunc(defaultOpaqueRenderOrder);\r\n const alphaTestRenderOrder = RenderOrderFunc(defaultAlphaTestRenderOrder);\r\n const transparentRenderOrder = RenderOrderFunc(defaultTransparentRenderOrder);\r\n scene.setRenderingOrder(0, opaqueRenderOrder, alphaTestRenderOrder, transparentRenderOrder);\r\n\r\n this._renderObserver = scene.onBeforeRenderObservable.add(() => {\r\n this._render(scene, scene.activeCamera as Camera);\r\n });\r\n }\r\n\r\n private _createRenderLayerElements(containerId: string): RenderLayerElements {\r\n const existingContainer = document.getElementById(containerId);\r\n if (existingContainer) {\r\n existingContainer.remove();\r\n }\r\n const container = document.createElement(\"div\");\r\n container.id = containerId;\r\n container.style.position = \"absolute\";\r\n container.style.width = \"100%\";\r\n container.style.height = \"100%\";\r\n container.style.zIndex = \"-1\";\r\n\r\n const domElement = document.createElement(\"div\");\r\n domElement.style.overflow = \"hidden\";\r\n\r\n const cameraElement = document.createElement(\"div\");\r\n\r\n cameraElement.style.webkitTransformStyle = \"preserve-3d\";\r\n cameraElement.style.transformStyle = \"preserve-3d\";\r\n\r\n cameraElement.style.pointerEvents = \"none\";\r\n\r\n domElement.appendChild(cameraElement);\r\n container.appendChild(domElement);\r\n return {\r\n container,\r\n domElement,\r\n cameraElement,\r\n };\r\n }\r\n\r\n protected _getSize(): { width: number; height: number } {\r\n return {\r\n width: this._width,\r\n height: this._height,\r\n };\r\n }\r\n\r\n protected _setSize(width: number, height: number): void {\r\n this._width = width;\r\n this._height = height;\r\n this._heightHalf = this._height / 2;\r\n\r\n if (!this._inSceneElements || !this._overlayElements) {\r\n return;\r\n }\r\n\r\n const domElements = [this._inSceneElements.domElement, this._overlayElements.domElement, this._inSceneElements.cameraElement, this._overlayElements.cameraElement];\r\n for (const dom of domElements) {\r\n if (dom) {\r\n dom.style.width = `${width}px`;\r\n dom.style.height = `${height}px`;\r\n }\r\n }\r\n }\r\n\r\n // prettier-ignore\r\n protected _getCameraCssMatrix(matrix: Matrix): string {\r\n const elements = matrix.m;\r\n return `matrix3d(${\r\n this._epsilon( elements[0] )\r\n },${\r\n this._epsilon( - elements[1] )\r\n },${\r\n this._epsilon( elements[2] )\r\n },${\r\n this._epsilon( elements[3] )\r\n },${\r\n this._epsilon( elements[4] )\r\n },${\r\n this._epsilon( - elements[5] )\r\n },${\r\n this._epsilon( elements[6] )\r\n },${\r\n this._epsilon( elements[7] )\r\n },${\r\n this._epsilon( elements[8] )\r\n },${\r\n this._epsilon( - elements[9] )\r\n },${\r\n this._epsilon( elements[10] )\r\n },${\r\n this._epsilon( elements[11] )\r\n },${\r\n this._epsilon( elements[12] )\r\n },${\r\n this._epsilon( - elements[13] )\r\n },${\r\n this._epsilon( elements[14] )\r\n },${\r\n this._epsilon( elements[15] )\r\n })`;\r\n }\r\n\r\n // Convert a Babylon world matrix to a CSS matrix\r\n // This also handles conversion from BJS left handed coords\r\n // to CSS right handed coords\r\n // prettier-ignore\r\n protected _getHtmlContentCssMatrix(matrix: Matrix, useRightHandedSystem: boolean): string {\r\n const elements = matrix.m;\r\n // In a right handed coordinate system, the elements 11 to 14 have to change their direction\r\n const direction = useRightHandedSystem ? -1 : 1;\r\n const matrix3d = `matrix3d(${\r\n this._epsilon( elements[0] )\r\n },${\r\n this._epsilon( elements[1] )\r\n },${\r\n this._epsilon( elements[2] * -direction )\r\n },${\r\n this._epsilon( elements[3] )\r\n },${\r\n this._epsilon( - elements[4] )\r\n },${\r\n this._epsilon( - elements[5] )\r\n },${\r\n this._epsilon( elements[6] * direction )\r\n },${\r\n this._epsilon( - elements[7] )\r\n },${\r\n this._epsilon( elements[8] * -direction )\r\n },${\r\n this._epsilon( elements[9] * -direction )\r\n },${\r\n this._epsilon( elements[10] )\r\n },${\r\n this._epsilon( elements[11] * direction )\r\n },${\r\n this._epsilon( elements[12] * direction )\r\n },${\r\n this._epsilon( elements[13] * direction )\r\n },${\r\n this._epsilon( elements[14] * direction )\r\n },${\r\n this._epsilon( elements[15] )\r\n })`;\r\n return matrix3d;\r\n }\r\n\r\n protected _getTransformationMatrix(htmlMesh: HtmlMesh, useRightHandedSystem: boolean): Matrix {\r\n // Get the camera world matrix\r\n // Make sure the camera world matrix is up to date\r\n if (!this._cameraWorldMatrix) {\r\n this._cameraWorldMatrix = htmlMesh.getScene().activeCamera?.getWorldMatrix();\r\n }\r\n if (!this._cameraWorldMatrix) {\r\n return Matrix.Identity();\r\n }\r\n\r\n const objectWorldMatrix = htmlMesh.getWorldMatrix();\r\n\r\n // Scale the object matrix by the base scale factor for the mesh\r\n // which is the ratio of the mesh width/height to the renderer\r\n // width/height divided by the babylon units to pixels ratio\r\n let widthScaleFactor = 1;\r\n let heightScaleFactor = 1;\r\n if (htmlMesh.sourceWidth && htmlMesh.sourceHeight) {\r\n widthScaleFactor = htmlMesh.width! / (htmlMesh.sourceWidth / BabylonUnitsToPixels);\r\n heightScaleFactor = htmlMesh.height! / (htmlMesh.sourceHeight / BabylonUnitsToPixels);\r\n }\r\n\r\n // Apply the scale to the object's world matrix. Note we aren't scaling\r\n // the object, just getting a matrix as though it were scaled, so we can\r\n // scale the content\r\n const scaleTransform = this._temp.scaleTransform;\r\n const rotationTransform = this._temp.rotationTransform;\r\n const positionTransform = this._temp.positionTransform;\r\n const scaledAndTranslatedObjectMatrix = this._temp.objectMatrix;\r\n\r\n objectWorldMatrix.decompose(scaleTransform, rotationTransform, positionTransform);\r\n scaleTransform.x *= widthScaleFactor;\r\n scaleTransform.y *= heightScaleFactor;\r\n\r\n Matrix.ComposeToRef(scaleTransform, rotationTransform, positionTransform, scaledAndTranslatedObjectMatrix);\r\n\r\n // Adjust direction of 12 and 13 of the transformation matrix based on the handedness of the system\r\n const direction = useRightHandedSystem ? -1 : 1;\r\n // Adjust translation values to be from camera vs world origin\r\n // Note that we are also adjusting these values to be pixels vs Babylon units\r\n const position = htmlMesh.getAbsolutePosition();\r\n scaledAndTranslatedObjectMatrix.setRowFromFloats(\r\n 3,\r\n (-this._cameraWorldMatrix.m[12] + position.x) * BabylonUnitsToPixels * direction,\r\n (-this._cameraWorldMatrix.m[13] + position.y) * BabylonUnitsToPixels * direction,\r\n (this._cameraWorldMatrix.m[14] - position.z) * BabylonUnitsToPixels,\r\n this._cameraWorldMatrix.m[15] * HtmlMeshRenderer.PROJECTION_SCALE_FACTOR * BabylonUnitsToPixels\r\n );\r\n\r\n // Adjust other values to be pixels vs Babylon units\r\n scaledAndTranslatedObjectMatrix.multiplyAtIndex(3, BabylonUnitsToPixels);\r\n scaledAndTranslatedObjectMatrix.multiplyAtIndex(7, BabylonUnitsToPixels);\r\n scaledAndTranslatedObjectMatrix.multiplyAtIndex(11, BabylonUnitsToPixels);\r\n\r\n return scaledAndTranslatedObjectMatrix;\r\n }\r\n\r\n protected _renderHtmlMesh(htmlMesh: HtmlMesh, useRightHandedSystem: boolean) {\r\n if (!htmlMesh.element || !htmlMesh.element.firstElementChild) {\r\n // nothing to render, so bail\r\n return;\r\n }\r\n\r\n // We need to ensure html mesh data is initialized before\r\n // computing the base scale factor\r\n let htmlMeshData = this._cache.htmlMeshData.get(htmlMesh);\r\n if (!htmlMeshData) {\r\n htmlMeshData = { style: \"\" };\r\n this._cache.htmlMeshData.set(htmlMesh, htmlMeshData);\r\n }\r\n\r\n const cameraElement = htmlMesh._isCanvasOverlay ? this._overlayElements?.cameraElement : this._inSceneElements?.cameraElement;\r\n\r\n if (htmlMesh.element.parentNode !== cameraElement) {\r\n cameraElement!.appendChild(htmlMesh.element);\r\n }\r\n\r\n // If the htmlMesh content has changed, update the base scale factor\r\n if (htmlMesh.requiresUpdate) {\r\n this._updateBaseScaleFactor(htmlMesh);\r\n }\r\n\r\n // Get the transformation matrix for the html mesh\r\n const scaledAndTranslatedObjectMatrix = this._getTransformationMatrix(htmlMesh, useRightHandedSystem);\r\n\r\n let style = `translate(-50%, -50%) ${this._getHtmlContentCssMatrix(scaledAndTranslatedObjectMatrix, useRightHandedSystem)}`;\r\n // In a right handed system, screens are on the wrong side of the mesh, so we have to rotate by Math.PI which results in the matrix3d seen below\r\n // Also in RH + billboard mode, we cancel the handedness so we do not need to scale on x\r\n style += `${useRightHandedSystem ? `matrix3d(${htmlMesh.billboardMode !== TransformNode.BILLBOARDMODE_NONE ? 1 : -1}, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1)` : \"\"}`;\r\n\r\n if (htmlMeshData.style !== style) {\r\n htmlMesh.element.style.webkitTransform = style;\r\n htmlMesh.element.style.transform = style;\r\n }\r\n\r\n htmlMesh._markAsUpdated();\r\n }\r\n\r\n protected _render(scene: Scene, camera: Camera) {\r\n let needsUpdate = false;\r\n\r\n const useRightHandedSystem = scene.useRightHandedSystem;\r\n\r\n // Update the container position and size if necessary\r\n this._updateContainerPositionIfNeeded();\r\n\r\n // Check for a camera change\r\n if (this._cameraMatrixUpdated) {\r\n this._cameraMatrixUpdated = false;\r\n needsUpdate = true;\r\n }\r\n\r\n // If the camera position has changed, then we also need to update\r\n if (\r\n camera.position.x !== this._cache.cameraData.position.x ||\r\n camera.position.y !== this._cache.cameraData.position.y ||\r\n camera.position.z !== this._cache.cameraData.position.z\r\n ) {\r\n this._cache.cameraData.position.copyFrom(camera.position);\r\n needsUpdate = true;\r\n }\r\n\r\n // Check for a dpr change\r\n if (window.devicePixelRatio !== this._lastDevicePixelRatio) {\r\n this._lastDevicePixelRatio = window.devicePixelRatio;\r\n Logger.Log(\"In render - dpr changed: \", this._lastDevicePixelRatio);\r\n needsUpdate = true;\r\n }\r\n\r\n // Check if any meshes need to be updated\r\n const meshesNeedingUpdate = scene.meshes.filter((mesh) => (mesh as any)[\"isHtmlMesh\"] && (needsUpdate || (mesh as HtmlMesh).requiresUpdate));\r\n needsUpdate = needsUpdate || meshesNeedingUpdate.length > 0;\r\n\r\n if (!needsUpdate) {\r\n return;\r\n }\r\n\r\n // Get a projection matrix for the camera\r\n const projectionMatrix = camera.getProjectionMatrix();\r\n const fov = projectionMatrix.m[5] * this._heightHalf;\r\n\r\n if (this._cache.cameraData.fov !== fov) {\r\n const source = [this._overlayElements?.domElement, this._inSceneElements?.domElement];\r\n if (camera.mode == Camera.PERSPECTIVE_CAMERA) {\r\n for (const el of source) {\r\n if (el) {\r\n el.style.webkitPerspective = fov + \"px\";\r\n el.style.perspective = fov + \"px\";\r\n }\r\n }\r\n } else {\r\n for (const el of source) {\r\n if (el) {\r\n el.style.webkitPerspective = \"\";\r\n el.style.perspective = \"\";\r\n }\r\n }\r\n }\r\n this._cache.cameraData.fov = fov;\r\n }\r\n\r\n // Get the CSS matrix for the camera (which will include any camera rotation)\r\n if (camera.parent === null) {\r\n camera.computeWorldMatrix();\r\n }\r\n\r\n const cameraMatrixWorld = this._temp.cameraWorldMatrix;\r\n cameraMatrixWorld.copyFrom(camera.getWorldMatrix());\r\n const cameraRotationMatrix = this._temp.cameraRotationMatrix;\r\n cameraMatrixWorld.getRotationMatrix().transposeToRef(cameraRotationMatrix);\r\n\r\n const cameraMatrixWorldAsArray = this._temp.cameraWorldMatrixAsArray;\r\n cameraMatrixWorld.copyToArray(cameraMatrixWorldAsArray);\r\n\r\n // For a few values, we have to adjust the direction based on the handedness of the system\r\n const direction = useRightHandedSystem ? 1 : -1;\r\n\r\n cameraMatrixWorldAsArray[1] = cameraRotationMatrix.m[1];\r\n cameraMatrixWorldAsArray[2] = cameraRotationMatrix.m[2] * direction;\r\n cameraMatrixWorldAsArray[4] = cameraRotationMatrix.m[4] * direction;\r\n cameraMatrixWorldAsArray[6] = cameraRotationMatrix.m[6] * direction;\r\n cameraMatrixWorldAsArray[8] = cameraRotationMatrix.m[8] * direction;\r\n cameraMatrixWorldAsArray[9] = cameraRotationMatrix.m[9] * direction;\r\n\r\n Matrix.FromArrayToRef(cameraMatrixWorldAsArray, 0, cameraMatrixWorld);\r\n\r\n const cameraCSSMatrix = this._getCameraCssMatrix(cameraMatrixWorld);\r\n const style = cameraCSSMatrix;\r\n\r\n if (this._cache.cameraData.style !== style) {\r\n const source = [this._inSceneElements?.cameraElement, this._overlayElements?.cameraElement];\r\n for (const el of source) {\r\n if (el) {\r\n el.style.webkitTransform = style;\r\n el.style.transform = style;\r\n }\r\n }\r\n this._cache.cameraData.style = style;\r\n }\r\n\r\n // _Render objects if necessary\r\n for (const mesh of meshesNeedingUpdate) {\r\n this._renderHtmlMesh(mesh as HtmlMesh, useRightHandedSystem);\r\n }\r\n }\r\n\r\n protected _updateBaseScaleFactor(htmlMesh: HtmlMesh) {\r\n // Get screen width and height\r\n let screenWidth = this._width;\r\n let screenHeight = this._height;\r\n\r\n // Calculate aspect ratios\r\n const htmlMeshAspectRatio = (htmlMesh.width || 1) / (htmlMesh.height || 1);\r\n const screenAspectRatio = screenWidth / screenHeight;\r\n\r\n // Adjust screen dimensions based on aspect ratios\r\n if (htmlMeshAspectRatio > screenAspectRatio) {\r\n // If the HTML mesh is wider relative to its height than the screen, adjust the screen width\r\n screenWidth = screenHeight * htmlMeshAspectRatio;\r\n } else {\r\n // If the HTML mesh is taller relative to its width than the screen, adjust the screen height\r\n screenHeight = screenWidth / htmlMeshAspectRatio;\r\n }\r\n\r\n // Set content to fill screen so we get max resolution when it is shrunk to fit the mesh\r\n htmlMesh.setContentSizePx(screenWidth, screenHeight);\r\n }\r\n\r\n protected _updateContainerPositionIfNeeded() {\r\n // Determine if the canvas has moved on the screen\r\n const canvasRect = this._engine.getRenderingCanvasClientRect();\r\n\r\n // canvas rect may be null if layout not complete\r\n if (!canvasRect) {\r\n Logger.Warn(PositionUpdateFailMessage);\r\n return;\r\n }\r\n const scrollTop = window.scrollY;\r\n const scrollLeft = window.scrollX;\r\n const canvasDocumentTop = canvasRect.top + scrollTop;\r\n const canvasDocumentLeft = canvasRect.left + scrollLeft;\r\n\r\n if (this._previousCanvasDocumentPosition.top !== canvasDocumentTop || this._previousCanvasDocumentPosition.left !== canvasDocumentLeft) {\r\n this._previousCanvasDocumentPosition.top = canvasDocumentTop;\r\n this._previousCanvasDocumentPosition.left = canvasDocumentLeft;\r\n\r\n const source = [this._inSceneElements?.container, this._overlayElements?.container];\r\n for (const container of source) {\r\n if (!container) {\r\n continue;\r\n }\r\n // set the top and left of the css container to match the canvas\r\n const containerParent = container.offsetParent as HTMLElement;\r\n const parentRect = containerParent.getBoundingClientRect();\r\n const parentDocumentTop = parentRect.top + scrollTop;\r\n const parentDocumentLeft = parentRect.left + scrollLeft;\r\n\r\n const ancestorMarginsAndPadding = this._getAncestorMarginsAndPadding(containerParent);\r\n\r\n // Add the body margin\r\n const bodyStyle = window.getComputedStyle(document.body);\r\n const bodyMarginTop = parseInt(bodyStyle.marginTop, 10);\r\n const bodyMarginLeft = parseInt(bodyStyle.marginLeft, 10);\r\n\r\n container.style.top = `${canvasDocumentTop - parentDocumentTop - ancestorMarginsAndPadding.marginTop + ancestorMarginsAndPadding.paddingTop + bodyMarginTop}px`;\r\n container.style.left = `${\r\n canvasDocumentLeft - parentDocumentLeft - ancestorMarginsAndPadding.marginLeft + ancestorMarginsAndPadding.paddingLeft + bodyMarginLeft\r\n }px`;\r\n }\r\n }\r\n }\r\n\r\n protected _onCameraMatrixChanged = (camera: Camera) => {\r\n this._cameraWorldMatrix = camera.getWorldMatrix();\r\n this._cameraMatrixUpdated = true;\r\n };\r\n\r\n private _epsilon(value: number) {\r\n return Math.abs(value) < 1e-10 ? 0 : value;\r\n }\r\n\r\n // Get total margins and padding for an element, excluding the body and document margins\r\n private _getAncestorMarginsAndPadding(element: HTMLElement) {\r\n let marginTop = 0;\r\n let marginLeft = 0;\r\n let paddingTop = 0;\r\n let paddingLeft = 0;\r\n\r\n while (element && element !== document.body && element !== document.documentElement) {\r\n const style = window.getComputedStyle(element);\r\n marginTop += parseInt(style.marginTop, 10);\r\n marginLeft += parseInt(style.marginLeft, 10);\r\n paddingTop += parseInt(style.paddingTop, 10);\r\n paddingLeft += parseInt(style.paddingLeft, 10);\r\n element = element.offsetParent as HTMLElement;\r\n }\r\n\r\n return { marginTop, marginLeft, paddingTop, paddingLeft };\r\n }\r\n}\r\n","import { Tools } from \"core/Misc/tools\";\r\n\r\n// A capture management system to ensure that the correct object has the pointer\r\n// events by eliminating race conditions that can cause the pointer events to be\r\n// released by a different object after they are captured leaving no object\r\n// as the owner. It does this by queueing requests and only allowing\r\n// capture when the current capture owner releases pointer events.\r\n\r\ntype CaptureReleaseCallback = () => void;\r\n\r\ntype CaptureReleaseCallbacks = {\r\n capture: CaptureReleaseCallback;\r\n release: CaptureReleaseCallback;\r\n};\r\n\r\nlet CaptureRequestQueue: string[] = [];\r\n\r\n// Key is request id, value is object with capture and release callbacks\r\nconst PendingRequestCallbacks: Map<string, CaptureReleaseCallbacks> = new Map();\r\n\r\n// Keep track of release requests with no matching capture request\r\n// in case the release request arrived before the capture to avoid\r\n// the capture request never getting released.\r\nlet UnmatchedReleaseRequests: string[] = [];\r\n\r\nlet CurrentOwner: string | null = null; // Called on first capture or release request\r\n\r\n/**\r\n * Get the id of the object currently capturing pointer events\r\n * @returns The id of the object currently capturing pointer events\r\n * or null if no object is capturing pointer events\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const getCapturingId = () => {\r\n return CurrentOwner;\r\n};\r\n\r\n/**\r\n * Request that the object with the given id capture pointer events. If there is no current\r\n * owner, then the request is granted immediately. If there is a current owner, then the request\r\n * is queued until the current owner releases pointer events.\r\n * @param requestId An id to identify the request. This id will be used to match the capture\r\n * request with the release request.\r\n * @param captureCallback The callback to call when the request is granted and the object is capturing\r\n * @param releaseCallback The callback to call when the object is no longer capturing pointer events\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const requestCapture = (requestId: string, captureCallback: CaptureReleaseCallback, releaseCallback: CaptureReleaseCallback) => {\r\n DebugLog(`In pointerEventsCapture.requestCapture - Pointer events capture requested for ${requestId}`);\r\n\r\n // If there is a release for this request, then ignore the request\r\n if (RemoveUnmatchedRequest(requestId)) {\r\n DebugLog(`In pointerEventsCapture.requestCapture - Capture request matched previous release request ${requestId}. Cancelling capture request`);\r\n return;\r\n } else if (requestId !== CurrentOwner) {\r\n // if the request is not already in the queue, add it to the queue\r\n EnqueueCaptureRequest(requestId, captureCallback, releaseCallback);\r\n }\r\n\r\n if (!CurrentOwner) {\r\n // If there is no current owner, go ahead and grant the request\r\n TransferPointerEventsOwnership();\r\n }\r\n // If the request id is the current owner, do nothing\r\n};\r\n\r\n/**\r\n * Release pointer events from the object with the given id. If the object is the current owner\r\n * then pointer events are released immediately. If the object is not the current owner, then the\r\n * associated capture request is removed from the queue. If there is no matching capture request\r\n * in the queue, then the release request is added to a list of unmatched release requests and will\r\n * negate the next capture request with the same id. This is to guard against the possibility that\r\n * the release request arrived before the capture request.\r\n * @param requestId The id which should match the id of the capture request\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const requestRelease = (requestId: string | null) => {\r\n DebugLog(`In pointerEventsCapture.requestRelease - Pointer events release requested for ${requestId}`);\r\n\r\n // if the requestId is the current capture holder release it\r\n if (!requestId || requestId === CurrentOwner) {\r\n TransferPointerEventsOwnership();\r\n } else if (CancelRequest(requestId)) {\r\n // if the request is in the queue, but not the current capture holder, remove it and it's callbacks\r\n PendingRequestCallbacks.delete(requestId);\r\n } else {\r\n DebugLog(`In pointerEventsCapture.requestRelease - Received release request ${requestId} but no matching capture request was received`);\r\n // request was not current and not in queue, likely because we received a release\r\n // request before the capture. Add it to the unmatched list to guard against this possibility\r\n if (!UnmatchedReleaseRequests.includes(requestId)) {\r\n UnmatchedReleaseRequests.push(requestId);\r\n }\r\n }\r\n};\r\n\r\n/**\r\n * Release pointer events from the current owner\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const releaseCurrent = () => {\r\n requestRelease(CurrentOwner);\r\n};\r\n\r\nconst EnqueueCaptureRequest = (requestId: string, capture: CaptureReleaseCallback, release: CaptureReleaseCallback) => {\r\n DebugLog(`In pointerEventsCapture.enqueueCaptureRequest - Enqueueing capture request for ${requestId}`);\r\n if (!CaptureRequestQueue.includes(requestId)) {\r\n CaptureRequestQueue.push(requestId);\r\n PendingRequestCallbacks.set(requestId, { capture, release });\r\n }\r\n};\r\n\r\n// Removes the request from the queue if it exists. Returns true\r\n// if the request was found and removed, otherwise false\r\nconst CancelRequest = (requestId: string | null) => {\r\n let removed = false;\r\n CaptureRequestQueue = CaptureRequestQueue.filter((id) => {\r\n if (id !== requestId) {\r\n return true;\r\n } else {\r\n removed = true;\r\n DebugLog(`In pointerEventsCapture.cancelRequest - Canceling pointer events capture request ${requestId}`);\r\n return false;\r\n }\r\n });\r\n return removed;\r\n};\r\n\r\nconst RemoveUnmatchedRequest = (requestId: string) => {\r\n let removed = false;\r\n UnmatchedReleaseRequests = UnmatchedReleaseRequests.filter((id) => {\r\n if (id !== requestId) {\r\n return true;\r\n } else {\r\n removed = true;\r\n return false;\r\n }\r\n });\r\n return removed;\r\n};\r\n\r\nconst TransferPointerEventsOwnership = () => {\r\n const newOwnerId = NextCaptureRequest();\r\n DebugLog(`In pointerEventsCapture.transferPointerEventsOwnership - Transferrring pointer events from ${CurrentOwner} to ${newOwnerId}`);\r\n // Release the current owner\r\n DoRelease();\r\n if (newOwnerId) {\r\n DoCapture(newOwnerId);\r\n }\r\n};\r\n\r\nconst DoRelease = () => {\r\n DebugLog(`In pointerEventsCapture.doRelease - Releasing pointer events from ${CurrentOwner}`);\r\n if (CurrentOwner) {\r\n // call the release callback\r\n PendingRequestCallbacks.get(CurrentOwner)?.release();\r\n // And remove the callbacks\r\n PendingRequestCallbacks.delete(CurrentOwner);\r\n CurrentOwner = null;\r\n }\r\n};\r\n\r\nconst DoCapture = (newOwnerId: string) => {\r\n if (newOwnerId) {\r\n // call the capture callback\r\n PendingRequestCallbacks.get(newOwnerId)?.capture();\r\n }\r\n CurrentOwner = newOwnerId;\r\n DebugLog(`In pointerEventsCapture.doCapture - Pointer events now captured by ${newOwnerId}`);\r\n};\r\n\r\nconst NextCaptureRequest = () => {\r\n return CaptureRequestQueue.length > 0 ? CaptureRequestQueue.shift() : null;\r\n};\r\n\r\n// #region Debugging support\r\ndeclare global {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n interface Window {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n \"pointer-events-capture-debug\": boolean | null;\r\n }\r\n}\r\n\r\nconst DebugLog = (message: string) => {\r\n // If we are runnning in a test runner (in node, so window is not defined)\r\n // or if the debug flag is set, then log the message\r\n if (typeof window === \"undefined\" || window[\"pointer-events-capture-debug\"]) {\r\n Tools.Log(\r\n `${performance.now()} - game.scene.pointerEvents - ${message}\\ncurrentOwner: ${CurrentOwner}\\nqueue: ${CaptureRequestQueue}\\nunmatched: ${UnmatchedReleaseRequests}`\r\n );\r\n }\r\n};\r\n// #endregion Debugging support\r\n","import type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport type { Behavior } from \"core/Behaviors/behavior\";\r\nimport type { Scene } from \"core/scene\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { requestCapture, requestRelease, releaseCurrent, getCapturingId } from \"./pointerEventsCapture\";\r\n\r\n// Module level variable for holding the current scene\r\nlet LocalScene: Scene | null = null;\r\n\r\n// Module level variable to hold the count of behavior instances that are currently capturing pointer events\r\n// on entry. This is used to determine if we need to start or stop observing pointer movement.\r\nlet CaptureOnEnterCount = 0;\r\n\r\n// Map used to store instance of the PointerEventsCaptureBehavior for a mesh\r\n// We do this because this gets checked on pointer move and we don't want to\r\n// use getBehaviorByName() because that is a linear search\r\nconst MeshToBehaviorMap = new WeakMap<AbstractMesh, PointerEventsCaptureBehavior>();\r\n\r\nconst StartCaptureOnEnter = (scene: Scene) => {\r\n // If we are not in a browser, do nothing\r\n if (typeof document === \"undefined\") {\r\n return;\r\n }\r\n if (CaptureOnEnterCount === 0) {\r\n document.addEventListener(\"pointermove\", OnPointerMove);\r\n document.addEventListener(\"touchstart\", OnPointerMove);\r\n LocalScene = LocalScene ?? scene;\r\n Logger.Log(\"PointerEventsCaptureBehavior: Starting observation of pointer move events.\");\r\n LocalScene.onDisposeObservable.add(DoStopCaptureOnEnter);\r\n }\r\n CaptureOnEnterCount++;\r\n};\r\n\r\nconst DoStopCaptureOnEnter = () => {\r\n document.removeEventListener(\"pointermove\", OnPointerMove);\r\n document.removeEventListener(\"touchstart\", OnPointerMove);\r\n LocalScene = null;\r\n Logger.Log(\"PointerEventsCaptureBehavior: Stopping observation of pointer move events.\");\r\n CaptureOnEnterCount = 0;\r\n};\r\n\r\nconst StopCaptureOnEnter = () => {\r\n // If we are not in a browser, do nothing\r\n if (typeof document === \"undefined\") {\r\n return;\r\n }\r\n\r\n // If we are not observing pointer movement, do nothing\r\n if (!LocalScene) {\r\n return;\r\n }\r\n\r\n CaptureOnEnterCount--;\r\n if (CaptureOnEnterCount <= 0) {\r\n DoStopCaptureOnEnter();\r\n }\r\n};\r\n\r\n// Module level function used to determine if an entered mesh should capture pointer events\r\nconst OnPointerMove = (evt: PointerEvent | TouchEvent) => {\r\n if (!LocalScene) {\r\n return;\r\n }\r\n\r\n const canvasRect = LocalScene.getEngine().getRenderingCanvasClientRect();\r\n if (!canvasRect) {\r\n return;\r\n }\r\n\r\n // Get the object that contains the client X and Y from either the pointer event or from the\r\n // TouchEvent touch\r\n const { clientX, clientY } = \"touches\" in evt ? evt.touches[0] : evt;\r\n\r\n // get the picked mesh, if any\r\n const pointerScreenX = clientX - canvasRect.left;\r\n const pointerScreenY = clientY - canvasRect.top;\r\n\r\n let pointerCaptureBehavior: PointerEventsCaptureBehavior | undefined;\r\n const pickResult = LocalScene.pick(pointerScreenX, pointerScreenY, (mesh) => {\r\n // If the mesh has an instance of PointerEventsCaptureBehavior attached to it,\r\n // and capture on pointer enter is true, then we want to pick it\r\n const pointerCaptureBehavior = MeshToBehaviorMap.get(mesh);\r\n return mesh.isEnabled() && typeof pointerCaptureBehavior !== \"undefined\" && pointerCaptureBehavior._captureOnPointerEnter;\r\n });\r\n\r\n let pickedMesh: AbstractMesh | null;\r\n if (pickResult.hit) {\r\n pickedMesh = pickResult.pickedMesh;\r\n } else {\r\n pickedMesh = null;\r\n }\r\n\r\n const capturingIdAsInt = parseInt(getCapturingId() || \"\");\r\n\r\n // if the picked mesh is the current capturing mesh, do nothing\r\n if (pickedMesh && pickedMesh.uniqueId === capturingIdAsInt) {\r\n return;\r\n }\r\n\r\n // If there is a capturing mesh and it is not the current picked mesh, or no\r\n // mesh is picked, release the capturing mesh\r\n if (capturingIdAsInt && (!pickedMesh || pickedMesh.uniqueId !== capturingIdAsInt)) {\r\n releaseCurrent();\r\n }\r\n\r\n // If there is a picked mesh and it is not the current capturing mesh, capture\r\n // the pointer events. Note that the current capturing mesh has already been\r\n // released above\r\n if (pickedMesh) {\r\n pointerCaptureBehavior = MeshToBehaviorMap.get(pickedMesh);\r\n pointerCaptureBehavior!.capturePointerEvents();\r\n }\r\n};\r\n\r\n/**\r\n * Behavior for any content that can capture pointer events, i.e. bypass the Babylon pointer event handling\r\n * and receive pointer events directly. It will register the capture triggers and negotiate the capture and\r\n * release of pointer events. Curerntly this applies only to HtmlMesh\r\n */\r\nexport class PointerEventsCaptureBehavior implements Behavior<AbstractMesh> {\r\n /** gets or sets behavior's name */\r\n public name = \"PointerEventsCaptureBehavior\";\r\n\r\n private _attachedMesh: AbstractMesh | null;\r\n /** @internal */\r\n public _captureOnPointerEnter: boolean;\r\n\r\n /**\r\n * Gets or sets the mesh that the behavior is attached to\r\n */\r\n public get attachedMesh() {\r\n return this._attachedMesh;\r\n }\r\n\r\n public set attachedMesh(value: AbstractMesh | null) {\r\n this._attachedMesh = value;\r\n }\r\n\r\n constructor(\r\n private _captureCallback: () => void,\r\n private _releaseCallback: () => void,\r\n { captureOnPointerEnter = true } = {}\r\n ) {\r\n this._attachedMesh = null;\r\n this._captureOnPointerEnter = captureOnPointerEnter;\r\n\r\n // Warn if we are not in a browser\r\n if (typeof document === \"undefined\") {\r\n Logger.Warn(`Creating an instance of PointerEventsCaptureBehavior outside of a browser. The behavior will not work.`);\r\n }\r\n }\r\n\r\n /**\r\n * Set if the behavior should capture pointer events when the pointer enters the mesh\r\n */\r\n public set captureOnPointerEnter(captureOnPointerEnter: boolean) {\r\n if (this._captureOnPointerEnter === captureOnPointerEnter) {\r\n return;\r\n }\r\n this._captureOnPointerEnter = captureOnPointerEnter;\r\n if (this._attachedMesh) {\r\n if (this._captureOnPointerEnter) {\r\n StartCaptureOnEnter(this._attachedMesh.getScene());\r\n } else {\r\n StopCaptureOnEnter();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Function called when the behavior needs to be initialized (before attaching it to a target)\r\n */\r\n public init() {}\r\n\r\n /**\r\n * Called when the behavior is attached to a target\r\n * @param mesh defines the target where the behavior is attached to\r\n */\r\n public attach(mesh: AbstractMesh) {\r\n // Add a reference to this behavior on the mesh. We do this so we can get a\r\n // reference to the behavior in the onPointerMove function without relying on\r\n // getBehaviorByName(), which does a linear search of the behaviors array.\r\n this.attachedMesh = mesh;\r\n MeshToBehaviorMap.set(mesh, this);\r\n if (this._captureOnPointerEnter) {\r\n StartCaptureOnEnter(mesh.getScene());\r\n }\r\n }\r\n\r\n /**\r\n * Called when the behavior is detached from its target\r\n */\r\n public detach() {\r\n if (!this.attachedMesh) {\r\n return;\r\n }\r\n // Remove the reference to this behavior from the mesh\r\n MeshToBehaviorMap.delete(this.attachedMesh);\r\n if (this._captureOnPointerEnter) {\r\n StopCaptureOnEnter();\r\n }\r\n this.attachedMesh = null;\r\n }\r\n\r\n /**\r\n * Dispose the behavior\r\n */\r\n public dispose() {\r\n this.detach();\r\n }\r\n\r\n // Release pointer events\r\n public releasePointerEvents() {\r\n if (!this.attachedMesh) {\r\n return;\r\n }\r\n requestRelease(this.attachedMesh.uniqueId.toString());\r\n }\r\n\r\n // Capture pointer events\r\n public capturePointerEvents() {\r\n if (!this.attachedMesh) {\r\n return;\r\n }\r\n requestCapture(this.attachedMesh.uniqueId.toString(), this._captureCallback, this._releaseCallback);\r\n }\r\n}\r\n","export type FitStrategyType = {\r\n wrapElement(element: HTMLElement): HTMLElement;\r\n updateSize(sizingElement: HTMLElement, width: number, height: number): void;\r\n};\r\n\r\nconst FitStrategyContain: FitStrategyType = {\r\n wrapElement(element: HTMLElement): HTMLElement {\r\n const sizingElement = document.createElement(\"div\");\r\n sizingElement.style.display = \"flex\";\r\n sizingElement.style.justifyContent = \"center\";\r\n sizingElement.style.alignItems = \"center\";\r\n const scalingElement = document.createElement(\"div\");\r\n scalingElement.style.visibility = \"hidden\";\r\n scalingElement.appendChild(element);\r\n sizingElement.appendChild(scalingElement);\r\n return sizingElement;\r\n },\r\n updateSize(sizingElement: HTMLElement, width: number, height: number) {\r\n const scalingElement = sizingElement.firstElementChild! as HTMLElement;\r\n sizingElement.style.width = `${width}px`;\r\n sizingElement.style.height = `${height}px`;\r\n\r\n const [childWidth, childHeight] = [scalingElement.offsetWidth, scalingElement.offsetHeight];\r\n const scale = Math.min(width / childWidth, height / childHeight);\r\n scalingElement.style.transform = `scale(${scale})`;\r\n scalingElement.style.visibility = \"visible\";\r\n },\r\n};\r\n\r\nconst FitStrategyCover: FitStrategyType = {\r\n wrapElement(element: HTMLElement): HTMLElement {\r\n const sizingElement = document.createElement(\"div\");\r\n sizingElement.style.display = \"flex\";\r\n sizingElement.style.justifyContent = \"center\";\r\n sizingElement.style.alignItems = \"center\";\r\n sizingElement.style.overflow = \"hidden\";\r\n const scalingElement = document.createElement(\"div\");\r\n scalingElement.style.visibility = \"hidden\";\r\n scalingElement.appendChild(element);\r\n sizingElement.appendChild(scalingElement);\r\n return sizingElement;\r\n },\r\n updateSize(sizingElement: HTMLElement, width: number, height: number) {\r\n const scalingElement = sizingElement.firstElementChild! as HTMLElement;\r\n sizingElement.style.width = `${width}px`;\r\n sizingElement.style.height = `${height}px`;\r\n\r\n const [childWidth, childHeight] = [scalingElement.offsetWidth, scalingElement.offsetHeight];\r\n const scale = Math.max(width / childWidth, height / childHeight);\r\n scalingElement.style.transform = `scale(${scale})`;\r\n scalingElement.style.visibility = \"visible\";\r\n },\r\n};\r\n\r\nconst FitStrategyStretch: FitStrategyType = {\r\n wrapElement(element: HTMLElement): HTMLElement {\r\n const sizingElement = document.createElement(\"div\");\r\n sizingElement.style.display = \"flex\";\r\n sizingElement.style.justifyContent = \"center\";\r\n sizingElement.style.alignItems = \"center\";\r\n const scalingElement = document.createElement(\"div\");\r\n scalingElement.style.visibility = \"hidden\";\r\n scalingElement.appendChild(element);\r\n sizingElement.appendChild(scalingElement);\r\n return sizingElement;\r\n },\r\n updateSize(sizingElement: HTMLElement, width: number, height: number) {\r\n const scalingElement = sizingElement.firstElementChild! as HTMLElement;\r\n sizingElement.style.width = `${width}px`;\r\n sizingElement.style.height = `${height}px`;\r\n\r\n const [childWidth, childHeight] = [scalingElement.offsetWidth, scalingElement.offsetHeight];\r\n scalingElement.style.transform = `scale(${width / childWidth}, ${height / childHeight})`;\r\n scalingElement.style.visibility = \"visible\";\r\n },\r\n};\r\n\r\nconst FitStrategyNone: FitStrategyType = {\r\n wrapElement(element: HTMLElement): HTMLElement {\r\n return element;\r\n },\r\n updateSize(sizingElement: HTMLElement, width: number, height: number) {\r\n if (sizingElement) {\r\n sizingElement.style.width = `${width}px`;\r\n sizingElement.style.height = `${height}px`;\r\n }\r\n },\r\n};\r\n\r\nexport const FitStrategy = {\r\n CONTAIN: FitStrategyContain,\r\n COVER: FitStrategyCover,\r\n STRETCH: FitStrategyStretch,\r\n NONE: FitStrategyNone,\r\n};\r\n","import { Mesh } from \"core/Meshes/mesh\";\r\nimport { CreatePlaneVertexData } from \"core/Meshes/Builders/planeBuilder\";\r\nimport { StandardMaterial } from \"core/Materials/standardMaterial\";\r\nimport { Matrix } from \"core/Maths/math\";\r\nimport { PointerEventsCaptureBehavior } from \"./pointerEventsCaptureBehavior\";\r\nimport type { Scene } from \"core/scene\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport type { FitStrategyType } from \"./fitStrategy\";\r\nimport { FitStrategy } from \"./fitStrategy\";\r\n\r\n/**\r\n * This class represents HTML content that we want to render as though it is part of the scene. The HTML content is actually\r\n * rendered below the canvas, but a depth mask is created by this class that writes to the depth buffer but does not\r\n * write to the color buffer, effectively punching a hole in the canvas. CSS transforms are used to scale, translate, and rotate\r\n * the HTML content so that it matches the camera and mesh orientation. The class supports interactions in editable and non-editable mode.\r\n * In non-editable mode (the default), events are passed to the HTML content when the pointer is over the mask (and not occluded by other meshes\r\n * in the scene).\r\n * @see https://playground.babylonjs.com/#HVHYJC#5\r\n * @see https://playground.babylonjs.com/#B17TC7#112\r\n */\r\nexport class HtmlMesh extends Mesh {\r\n /**\r\n * Helps identifying a html mesh from a regular mesh\r\n */\r\n public get isHtmlMesh() {\r\n return true;\r\n }\r\n\r\n // Override the super class's _isEnabled property so we can control when the mesh\r\n // is enabled. I.e., we don't want to render the mesh until there is content to show.\r\n private _enabled = false;\r\n\r\n // The mesh is ready when content has been set and the content size has been set\r\n // The former is done by the user, the latter is done by the renderer.\r\n private _ready = false;\r\n\r\n /**\r\n * @internal\r\n */\r\n public _isCanvasOverlay = false;\r\n\r\n private _requiresUpdate = true;\r\n\r\n private _element?: HTMLElement;\r\n private _width?: number;\r\n private _height?: number;\r\n\r\n private _inverseScaleMatrix: Matrix | null = null;\r\n\r\n private _captureOnPointerEnter: boolean = true;\r\n private _pointerEventCaptureBehavior: PointerEventsCaptureBehavior | null = null;\r\n\r\n private _sourceWidth: number | null = null;\r\n private _sourceHeight: number | null = null;\r\n\r\n /**\r\n * Return the source width of the content in pixels\r\n */\r\n public get sourceWidth() {\r\n return this._sourceWidth;\r\n }\r\n\r\n /**\r\n * Return the source height of the content in pixels\r\n */\r\n public get sourceHeight() {\r\n return this._sourceHeight;\r\n }\r\n\r\n private _worldMatrixUpdateObserver: any;\r\n\r\n private _fitStrategy: FitStrategyType = FitStrategy.NONE;\r\n\r\n /**\r\n * Contruct an instance of HtmlMesh\r\n * @param scene\r\n * @param id The id of the mesh. Will be used as the id of the HTML element as well.\r\n * @param options object with optional parameters\r\n */\r\n constructor(scene: Scene, id: string, { captureOnPointerEnter = true, isCanvasOverlay = false, fitStrategy = FitStrategy.NONE } = {}) {\r\n super(id, scene);\r\n\r\n // Requires a browser to work. Bail if we aren't running in a browser\r\n if (typeof document === \"undefined\") {\r\n Logger.Warn(`Creating an instance of an HtmlMesh with id ${id} outside of a browser. The mesh will not be visible.`);\r\n return;\r\n }\r\n\r\n this._fitStrategy = fitStrategy;\r\n this._isCanvasOverlay = isCanvasOverlay;\r\n this._createMask();\r\n this._element = this._createElement();\r\n\r\n // Set enabled by default, so this will show as soon as it's ready\r\n this.setEnabled(true);\r\n\r\n this._captureOnPointerEnter = captureOnPointerEnter;\r\n\r\n // Create a behavior to capture pointer events\r\n this._pointerEventCaptureBehavior = new PointerEventsCaptureBehavior(this.capturePointerEvents.bind(this), this.releasePointerEvents.bind(this), {\r\n captureOnPointerEnter: this._captureOnPointerEnter,\r\n });\r\n this.addBehavior(this._pointerEventCaptureBehavior);\r\n }\r\n\r\n /**\r\n * The width of the content in pixels\r\n */\r\n public get width() {\r\n return this._width;\r\n }\r\n\r\n /**\r\n * The height of the content in pixels\r\n */\r\n public get height() {\r\n return this._height;\r\n }\r\n\r\n /**\r\n * The HTML element that is being rendered as a mesh\r\n */\r\n public get element() {\r\n return this._element;\r\n }\r\n\r\n /**\r\n * True if the mesh has been moved, rotated, or scaled since the last time this\r\n * property was read. This property is reset to false after reading.\r\n */\r\n public get requiresUpdate() {\r\n return this._requiresUpdate;\r\n }\r\n\r\n /**\r\n * Enable capture for the pointer when entering the mesh area\r\n */\r\n public set captureOnPointerEnter(captureOnPointerEnter: boolean) {\r\n this._captureOnPointerEnter = captureOnPointerEnter;\r\n if (this._pointerEventCaptureBehavior) {\r\n this._pointerEventCaptureBehavior.captureOnPointerEnter = captureOnPointerEnter;\r\n }\r\n }\r\n\r\n /**\r\n * Disposes of the mesh and the HTML element\r\n */\r\n public override dispose() {\r\n super.dispose();\r\n this._element?.remove();\r\n this._element = undefined;\r\n if (this._pointerEventCaptureBehavior) {\r\n this._pointerEventCaptureBehavior.dispose();\r\n this._pointerEventCaptureBehavior = null;\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _markAsUpdated() {\r\n this._requiresUpdate = false;\r\n }\r\n\r\n /**\r\n * Sets the content of the element to the specified content adjusting the mesh scale to match and making it visible.\r\n * If the the specified content is undefined, then it will make the mesh invisible. In either case it will clear the\r\n * element content first.\r\n * @param element The element to render as a mesh\r\n * @param width The width of the mesh in Babylon units\r\n * @param height The height of the mesh in Babylon units\r\n */\r\n setContent(element: HTMLElement, width: number, height: number) {\r\n // If content is changed, we are no longer ready\r\n this._setAsReady(false);\r\n\r\n // Also invalidate the source width and height\r\n this._sourceWidth = null;\r\n this._sourceHeight = null;\r\n\r\n if (!this._element) {\r\n return;\r\n }\r\n\r\n this._width = width;\r\n this._height = height;\r\n this._requiresUpdate = true;\r\n\r\n this.scaling.setAll(1);\r\n\r\n if (element) {\r\n this._element.appendChild(this._fitStrategy.wrapElement(element));\r\n\r\n this._updateScaleIfNecessary();\r\n }\r\n\r\n if (this.sourceWidth && this.sourceHeight) {\r\n this._setAsReady(true);\r\n }\r\n }\r\n\r\n // Overides BABYLON.Mesh.setEnabled\r\n public override setEnabled(enabled: boolean) {\r\n // Capture requested enabled state\r\n this._enabled = enabled;\r\n\r\n // If disabling or enabling and we are ready\r\n if (!enabled || this._ready) {\r\n this._doSetEnabled(enabled);\r\n }\r\n }\r\n\r\n /**\r\n * Sets the content size in pixels\r\n * @param width width of the source\r\n * @param height height of the source\r\n */\r\n public setContentSizePx(width: number, height: number) {\r\n this._sourceWidth = width;\r\n this._sourceHeight = height;\r\n\r\n if (!this._element || !this._element.firstElementChild) {\r\n return;\r\n }\r\n\r\n this._fitStrategy.updateSize(this._element.firstElementChild as HTMLElement, width, height);\r\n\r\n this._updateScaleIfNecessary();\r\n\r\n if (this.width && this.height) {\r\n this._setAsReady(true);\r\n }\r\n }\r\n\r\n protected _setAsReady(ready: boolean) {\r\n this._ready = ready;\r\n if (ready) {\r\n this._doSetEnabled(this._enabled);\r\n } else {\r\n this._doSetEnabled(false);\r\n }\r\n }\r\n\r\n protected _doSetEnabled(enabled: boolean) {\r\n if (!this._element) {\r\n return;\r\n }\r\n\r\n //if enabled, then start listening for changes to the\r\n // scaling, rotation, and position. otherwise stop listening\r\n if (enabled && !this._worldMatrixUpdateObserver) {\r\n this._worldMatrixUpdateObserver = this.onAfterWorldMatrixUpdateObservable.add(() => {\r\n this._requiresUpdate = true;\r\n });\r\n } else if (!enabled) {\r\n this._worldMatrixUpdateObserver?.remove();\r\n this._worldMatrixUpdateObserver = null;\r\n }\r\n\r\n // If enabled, then revert the content element display\r\n // otherwise hide it\r\n this._element.style.display = enabled ? \"\" : \"none\";\r\n // Capture the content z index\r\n this._setElementzIndex(this.position.z * -10000);\r\n super.setEnabled(enabled);\r\n }\r\n\r\n protected _updateScaleIfNecessary() {\r\n // If we have setContent before, the content scale is baked into the mesh. If we don't reset the vertices to\r\n // the original size, then we will multiply the scale when we bake the scale below. By applying the inverse, we back out\r\n // the scaling that has been done so we are starting from the same point.\r\n // First reset the scale to 1\r\n this.scaling.setAll(1);\r\n // Then back out the original vertices changes to match the content scale\r\n if (this._inverseScaleMatrix) {\r\n this.bakeTransformIntoVertices(this._inverseScaleMatrix);\r\n // Clear out the matrix so it doesn't get applied again unless we scale\r\n this._inverseScaleMatrix = null;\r\n }\r\n\r\n // Set scale to match content. Note we can't just scale the mesh, because that will scale the content as well\r\n // What we need to do is compute a scale matrix and then bake that into the mesh vertices. This will leave the\r\n // mesh scale at 1, so our content will stay it's original width and height until we scale the mesh.\r\n const scaleX = this._width || 1;\r\n const scaleY = this._height || 1;\r\n const scaleMatrix = Matrix.Scaling(scaleX, scaleY, 1);\r\n this.bakeTransformIntoVertices(scaleMatrix);\r\n\r\n // Get an inverse of the scale matrix that we can use to back out the scale changes we have made so\r\n // we don't multiply the scale.\r\n this._inverseScaleMatrix = new Matrix();\r\n scaleMatrix.invertToRef(this._inverseScaleMatrix);\r\n }\r\n\r\n protected _createMask() {\r\n const vertexData = CreatePlaneVertexData({ width: 1, height: 1 });\r\n vertexData.applyToMesh(this);\r\n\r\n const scene = this.getScene();\r\n this.checkCollisions = true;\r\n\r\n const depthMask = new StandardMaterial(`${this.id}-mat`, scene);\r\n if (!this._isCanvasOverlay) {\r\n depthMask.backFaceCulling = false;\r\n depthMask.disableColorWrite = true;\r\n depthMask.disableLighting = true;\r\n }\r\n\r\n this.material = depthMask;\r\n\r\n // Optimization - Freeze material since it never needs to change\r\n this.material.freeze();\r\n }\r\n\r\n protected _setElementzIndex(zIndex: number) {\r\n if (this._element) {\r\n this._element.style.zIndex = `${zIndex}`;\r\n }\r\n }\r\n\r\n /**\r\n * Callback used by the PointerEventsCaptureBehavior to capture pointer events\r\n */\r\n capturePointerEvents() {\r\n if (!this._element) {\r\n return;\r\n }\r\n\r\n // Enable dom content to capture pointer events\r\n this._element.style.pointerEvents = \"auto\";\r\n\r\n // Supress events outside of the dom content\r\n document.getElementsByTagName(\"body\")[0].style.pointerEvents = \"none\";\r\n }\r\n\r\n /**\r\n * Callback used by the PointerEventsCaptureBehavior to release pointer events\r\n */\r\n releasePointerEvents() {\r\n if (!this._element) {\r\n return;\r\n }\r\n\r\n // Enable pointer events on canvas\r\n document.getElementsByTagName(\"body\")[0].style.pointerEvents = \"auto\";\r\n\r\n // Disable pointer events on dom content\r\n this._element.style.pointerEvents = \"none\";\r\n }\r\n\r\n protected _createElement() {\r\n // Requires a browser to work. Bail if we aren't running in a browser\r\n if (typeof document === \"undefined\") {\r\n return;\r\n }\r\n const div = document.createElement(\"div\");\r\n div.id = this.id;\r\n div.style.backgroundColor = this._isCanvasOverlay ? \"transparent\" : \"#000\";\r\n div.style.zIndex = \"1\";\r\n div.style.position = \"absolute\";\r\n div.style.pointerEvents = \"none\";\r\n div.style.backfaceVisibility = \"hidden\";\r\n\r\n return div;\r\n }\r\n}\r\n","/* eslint-disable jsdoc/require-jsdoc */\r\n\r\nimport type { IVector2Like } from \"core/Maths/math.like\";\r\n\r\n/** @internal */\r\nexport type ParagraphOptions = {\r\n maxWidth: number;\r\n lineHeight: number;\r\n letterSpacing: number;\r\n tabSize: number;\r\n whiteSpace: /* 'normal' | 'nowrap' | 'pre' | 'pre-wrap' | */ \"pre-line\" /* | 'break-spaces'*/;\r\n textAlign: \"left\" | \"right\" | \"center\" /* | 'justify'*/;\r\n translate: IVector2Like | undefined;\r\n};\r\n\r\n/** @internal */\r\nexport const DefaultParagraphOptions: ParagraphOptions = {\r\n maxWidth: Infinity,\r\n lineHeight: 1,\r\n letterSpacing: 1,\r\n tabSize: 4,\r\n whiteSpace: \"pre-line\",\r\n textAlign: \"center\",\r\n translate: { x: -0.5, y: -0.5 },\r\n};\r\n","/* eslint-disable babylonjs/available */\r\n/* eslint-disable jsdoc/require-jsdoc */\r\nimport type { FontAsset } from \"../fontAsset\";\r\nimport { DefaultParagraphOptions, type ParagraphOptions } from \"../paragraphOptions\";\r\nimport type { BMFontChar } from \"./bmFont\";\r\nimport type { SdfGlyph } from \"./glyph\";\r\nimport type { SdfTextLine } from \"./line\";\r\n\r\n/** @internal */\r\nexport class SdfTextParagraph {\r\n public readonly options: ParagraphOptions;\r\n\r\n get lineHeight() {\r\n return this.fontAsset._font.common.lineHeight * this.options.lineHeight;\r\n }\r\n\r\n readonly paragraph;\r\n readonly lines;\r\n readonly width;\r\n readonly height;\r\n readonly glyphs;\r\n\r\n constructor(\r\n public readonly text: string,\r\n public readonly fontAsset: FontAsset,\r\n options?: Partial<ParagraphOptions>\r\n ) {\r\n this.options = { ...DefaultParagraphOptions, ...options };\r\n\r\n const { paragraph, lines, glyphs, width, height } = this._computeMetrics(text);\r\n\r\n this.paragraph = paragraph;\r\n this.lines = lines;\r\n this.glyphs = glyphs;\r\n this.width = width;\r\n this.height = height;\r\n }\r\n\r\n private _computeMetrics(text: string) {\r\n const collapsed = this._collapse(text);\r\n const breaked = this._breakLines(collapsed);\r\n const trimmed = breaked.map((line) => line.trim());\r\n\r\n const lines: SdfTextLine[] = [];\r\n for (const line of trimmed) {\r\n lines.push(...this._wrap(line, lines.length));\r\n }\r\n\r\n const width = Math.max(...lines.map((line) => line.width));\r\n const height = this.lineHeight * lines.length;\r\n\r\n if (this.options.textAlign !== \"left\" || this.options.translate) {\r\n lines.forEach((line) => {\r\n const anchor = (() => {\r\n switch (this.options.textAlign) {\r\n case \"right\":\r\n return width - line.width;\r\n case \"center\":\r\n return (width - line.width) / 2;\r\n case \"left\":\r\n default:\r\n return 0;\r\n }\r\n })();\r\n\r\n const x = this.options.translate ? this.options.translate.x * width : 0;\r\n const y = this.options.translate ? this.options.translate.y * height : 0;\r\n for (const glyph of line.glyphs) {\r\n glyph.x += anchor;\r\n glyph.x += x;\r\n glyph.y += y;\r\n }\r\n });\r\n }\r\n\r\n const glyphs = lines.flatMap((line) => line.glyphs);\r\n\r\n return {\r\n paragraph: trimmed.join(\"\\n\"),\r\n lines,\r\n glyphs,\r\n width,\r\n height,\r\n };\r\n }\r\n\r\n private _breakLines(text: string) {\r\n return text.split(\"\\n\");\r\n }\r\n\r\n private _collapse(text: string) {\r\n return text.replace(/\\t/g, \" \".repeat(this.options.tabSize)).replace(/ +/g, \" \");\r\n }\r\n\r\n private _wrap(text: string, lineOffset = 0) {\r\n const lines = new Array<SdfTextLine>();\r\n\r\n let currentLine = lineOffset;\r\n let currentGlyphs = new Array<SdfGlyph>();\r\n let currentCursor = 0;\r\n let currentWidth = 0;\r\n let lastChar: BMFontChar | undefined;\r\n let start = 0;\r\n let end = start;\r\n\r\n const pushCurrentLine = () => {\r\n lines.push({\r\n text: text.slice(start, end),\r\n glyphs: currentGlyphs,\r\n start: start,\r\n end: end,\r\n width: currentWidth,\r\n });\r\n };\r\n\r\n while (end < text.length) {\r\n const i = end;\r\n const charCode = text.charCodeAt(i);\r\n const char = this.fontAsset._getChar(charCode);\r\n const charWidth = char.width;\r\n const kerning = lastChar ? this.fontAsset._getKerning(lastChar.id, char.id) : 0;\r\n\r\n currentCursor += kerning;\r\n const newWidth = currentCursor + charWidth;\r\n const cursorProgress = char.xadvance + this.options.letterSpacing;\r\n const nextPosition = currentCursor + cursorProgress;\r\n\r\n const shouldBreak = nextPosition > this.options.maxWidth || newWidth > this.options.maxWidth;\r\n\r\n if (shouldBreak) {\r\n pushCurrentLine();\r\n\r\n currentLine++;\r\n lastChar = undefined;\r\n currentCursor = 0;\r\n currentWidth = 0;\r\n start = end;\r\n end = start + 1;\r\n currentGlyphs = [];\r\n }\r\n\r\n const x = currentCursor;\r\n const y = currentLine * this.lineHeight;\r\n\r\n currentGlyphs.push({\r\n char,\r\n line: currentLine,\r\n position: currentGlyphs.length,\r\n x: x,\r\n y: y,\r\n });\r\n\r\n if (!shouldBreak) {\r\n lastChar = char;\r\n currentCursor = nextPosition;\r\n currentWidth = newWidth;\r\n end++;\r\n } else {\r\n currentCursor = cursorProgress;\r\n }\r\n }\r\n\r\n if (currentGlyphs.length > 0) {\r\n if (lastChar) {\r\n // currentWidth += lastChar.xadvance;\r\n }\r\n pushCurrentLine();\r\n }\r\n\r\n return lines;\r\n }\r\n}\r\n","import type { VertexBuffer } from \"core/Buffers/buffer\";\r\nimport { Buffer } from \"core/Buffers/buffer\";\r\nimport type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport type { ThinEngine } from \"core/Engines/thinEngine\";\r\nimport { DrawWrapper } from \"core/Materials/drawWrapper\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\nimport type { IDisposable } from \"core/scene\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { SdfTextParagraph } from \"./sdf/paragraph\";\r\nimport type { FontAsset } from \"./fontAsset\";\r\nimport type { ParagraphOptions } from \"./paragraphOptions\";\r\nimport { ThinMatrix } from \"core/Maths/ThinMaths/thinMath.matrix\";\r\nimport {\r\n CopyMatrixToArray,\r\n CopyMatrixToRef,\r\n IdentityMatrixToRef,\r\n MultiplyMatricesToRef,\r\n ScalingMatrixToRef,\r\n TranslationMatrixToRef,\r\n} from \"core/Maths/ThinMaths/thinMath.matrix.functions\";\r\nimport type { IColor4Like, IMatrixLike } from \"core/Maths/math.like\";\r\n\r\n/**\r\n * Abstract Node class from Babylon.js\r\n */\r\nexport interface INodeLike {\r\n getWorldMatrix(): IMatrixLike;\r\n}\r\n\r\n/**\r\n * Class used to render text using MSDF (Multi-channel Signed Distance Field) technique\r\n * Thanks a lot to the work of Bhushan_Wagh and zb_sj for their amazing work on MSDF for Babylon.js\r\n * #6RLCWP#16\r\n * Star wars scroller: #6RLCWP#29\r\n * With metrics: #6RLCWP#35\r\n * Thickness: #IABMEZ#3\r\n * Solar system: #9YCDYC#9\r\n * Stroke: #6RLCWP#37\r\n */\r\nexport class TextRenderer implements IDisposable {\r\n private readonly _useVAO: boolean = false;\r\n private _engine: AbstractEngine;\r\n private _shaderLanguage: ShaderLanguage;\r\n private _vertexBuffers: { [key: string]: VertexBuffer } = {};\r\n private _spriteBuffer: Nullable<Buffer>;\r\n private _worldBuffer: Nullable<Buffer>;\r\n private _uvBuffer: Nullable<Buffer>;\r\n private _drawWrapperBase: DrawWrapper;\r\n private _vertexArrayObject: WebGLVertexArrayObject;\r\n private _font: FontAsset;\r\n private _charMatrices = new Array<number>();\r\n private _charUvs = new Array<number>();\r\n private _isDirty = true;\r\n private _baseLine = 0;\r\n\r\n // Cache\r\n private _scalingMatrix = new ThinMatrix();\r\n private _fontScaleMatrix = new ThinMatrix();\r\n private _offsetMatrix = new ThinMatrix();\r\n private _translationMatrix = new ThinMatrix();\r\n private _baseMatrix = new ThinMatrix();\r\n private _scaledMatrix = new ThinMatrix();\r\n private _localMatrix = new ThinMatrix();\r\n private _finalMatrix = new ThinMatrix();\r\n private _lineMatrix = new ThinMatrix();\r\n private _parentWorldMatrix = new ThinMatrix();\r\n\r\n /**\r\n * Gets or sets the color of the text\r\n */\r\n public color: IColor4Like = { r: 1.0, g: 1.0, b: 1.0, a: 1.0 };\r\n\r\n /**\r\n * Gets or sets the color of the stroke around the text\r\n */\r\n public strokeColor: IColor4Like = { r: 1.0, g: 1.0, b: 1.0, a: 1.0 };\r\n\r\n /**\r\n * Gets or sets the width of the stroke around the text (inset)\r\n */\r\n public strokeInsetWidth = 0;\r\n\r\n /**\r\n * Gets or sets the width of the stroke around the text (outset)\r\n */\r\n public strokeOutsetWidth = 0;\r\n\r\n /**\r\n * Gets or sets the thickness of the text (0 means as defined in the font)\r\n * Value must be between -0.5 and 0.5\r\n */\r\n public thicknessControl = 0;\r\n\r\n private _parent: Nullable<INodeLike> = null;\r\n\r\n /**\r\n * Gets or sets the parent of the text renderer\r\n */\r\n public get parent(): Nullable<INodeLike> {\r\n return this._parent;\r\n }\r\n\r\n public set parent(value: Nullable<INodeLike>) {\r\n this._parent = value;\r\n }\r\n\r\n private _transformMatrix: IMatrixLike = new ThinMatrix();\r\n\r\n /**\r\n * Gets or sets the transform matrix of the text renderer\r\n * It will be applied in that order:\r\n * parent x transform x paragraph world\r\n */\r\n public get transformMatrix(): IMatrixLike {\r\n return this._transformMatrix;\r\n }\r\n\r\n public set transformMatrix(value: IMatrixLike) {\r\n this._transformMatrix = value;\r\n }\r\n\r\n /**\r\n * Gets or sets if the text is billboarded\r\n */\r\n public isBillboard = false;\r\n\r\n /**\r\n * Gets or sets if the text is screen projected\r\n * This will work only if the text is billboarded\r\n */\r\n public isBillboardScreenProjected = false;\r\n\r\n /**\r\n * Gets the number of characters in the text renderer\r\n */\r\n public get characterCount(): number {\r\n return this._charMatrices.length / 16;\r\n }\r\n\r\n /**\r\n * Gets or sets if the text renderer should ignore the depth buffer\r\n * Default is false\r\n */\r\n public ignoreDepthBuffer = false;\r\n\r\n private constructor(engine: AbstractEngine, shaderLanguage: ShaderLanguage = ShaderLanguage.GLSL, font: FontAsset) {\r\n this._engine = engine;\r\n this._shaderLanguage = shaderLanguage;\r\n this._font = font;\r\n this._baseLine = font._font.common.lineHeight * font.scale;\r\n\r\n this._useVAO = engine.getCaps().vertexArrayObject && !engine.disableVertexArrayObjects;\r\n\r\n // Main vertex buffer\r\n const spriteData = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]);\r\n this._spriteBuffer = new Buffer(engine, spriteData, false, 2);\r\n this._vertexBuffers[\"offsets\"] = this._spriteBuffer.createVertexBuffer(\"offsets\", 0, 2);\r\n\r\n // Instances\r\n this._resizeBuffers(128);\r\n }\r\n\r\n private _resizeBuffers(capacity: number) {\r\n if (this._worldBuffer) {\r\n this._worldBuffer.dispose();\r\n this._worldBuffer = null;\r\n }\r\n\r\n if (this._uvBuffer) {\r\n this._uvBuffer.dispose();\r\n this._uvBuffer = null;\r\n }\r\n\r\n this._worldBuffer = new Buffer(this._engine, new Float32Array(capacity * 16), true, 16);\r\n this._vertexBuffers[\"world0\"] = this._worldBuffer.createVertexBuffer(\"world0\", 0, 4, 16, true);\r\n this._vertexBuffers[\"world1\"] = this._worldBuffer.createVertexBuffer(\"world1\", 4, 4, 16, true);\r\n this._vertexBuffers[\"world2\"] = this._worldBuffer.createVertexBuffer(\"world2\", 8, 4, 16, true);\r\n this._vertexBuffers[\"world3\"] = this._worldBuffer.createVertexBuffer(\"world3\", 12, 4, 16, true);\r\n\r\n this._uvBuffer = new Buffer(this._engine, new Float32Array(capacity * 4), true, 4);\r\n this._vertexBuffers[\"uvs\"] = this._uvBuffer.createVertexBuffer(\"uvs\", 0, 4, 4, true);\r\n }\r\n\r\n private _setShaders(vertex: string, fragment: string) {\r\n this._drawWrapperBase?.dispose();\r\n\r\n this._drawWrapperBase = new DrawWrapper(this._engine);\r\n\r\n if (this._drawWrapperBase.drawContext) {\r\n this._drawWrapperBase.drawContext.useInstancing = true;\r\n }\r\n\r\n const defines = \"\";\r\n\r\n this._drawWrapperBase.effect = this._engine.createEffect(\r\n {\r\n vertexSource: vertex,\r\n fragmentSource: fragment,\r\n },\r\n [\"offsets\", \"world0\", \"world1\", \"world2\", \"world3\", \"uvs\"],\r\n [\"parentWorld\", \"view\", \"projection\", \"uColor\", \"thickness\", \"uStrokeColor\", \"uStrokeInsetWidth\", \"uStrokeOutsetWidth\", \"mode\", \"transform\"],\r\n [\"fontAtlas\"],\r\n defines,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n this._shaderLanguage\r\n );\r\n\r\n this._drawWrapperBase.effect._refCount++;\r\n }\r\n\r\n /**\r\n * Add a paragraph of text to the renderer\r\n * @param text define the text to add\r\n * @param options define the options to use for the paragraph (optional)\r\n * @param worldMatrix define the world matrix to use for the paragraph (optional)\r\n */\r\n public addParagraph(text: string, options?: Partial<ParagraphOptions>, worldMatrix?: IMatrixLike) {\r\n const paragraph = new SdfTextParagraph(text, this._font, options);\r\n\r\n const fontScale = this._font.scale;\r\n\r\n const texWidth = this._font._font.common.scaleW;\r\n const texHeight = this._font._font.common.scaleH;\r\n const glyphs = paragraph.glyphs.filter((g) => g.char.page >= 0);\r\n\r\n let worldMatrixToUse = worldMatrix;\r\n\r\n if (!worldMatrixToUse) {\r\n const lineHeight = paragraph.lineHeight * fontScale;\r\n const lineOffset = (paragraph.lines.length * lineHeight) / 2;\r\n TranslationMatrixToRef(0, this._baseLine - lineOffset, 0, this._lineMatrix);\r\n worldMatrixToUse = this._lineMatrix;\r\n }\r\n\r\n ScalingMatrixToRef(fontScale, fontScale, 1.0, this._fontScaleMatrix);\r\n TranslationMatrixToRef(0.5, -0.5, 0, this._offsetMatrix);\r\n\r\n const charsUvsBase = this._charUvs.length;\r\n const matricesBase = this._charMatrices.length;\r\n glyphs.forEach((g, i) => {\r\n this._charUvs[charsUvsBase + i * 4 + 0] = g.char.x / texWidth;\r\n this._charUvs[charsUvsBase + i * 4 + 1] = g.char.y / texHeight;\r\n this._charUvs[charsUvsBase + i * 4 + 2] = g.char.width / texWidth;\r\n this._charUvs[charsUvsBase + i * 4 + 3] = g.char.height / texHeight;\r\n\r\n const x = g.x + g.char.xoffset;\r\n const y = 1.0 - (g.y + g.char.yoffset);\r\n\r\n ScalingMatrixToRef(g.char.width, g.char.height, 1.0, this._scalingMatrix);\r\n MultiplyMatricesToRef(this._offsetMatrix, this._scalingMatrix, this._baseMatrix);\r\n\r\n TranslationMatrixToRef(x * fontScale, y * fontScale, 0.0, this._translationMatrix);\r\n MultiplyMatricesToRef(this._baseMatrix, this._fontScaleMatrix, this._scaledMatrix);\r\n MultiplyMatricesToRef(this._scaledMatrix, this._translationMatrix, this._localMatrix);\r\n\r\n MultiplyMatricesToRef(this._localMatrix, worldMatrixToUse, this._finalMatrix);\r\n CopyMatrixToArray(this._finalMatrix, this._charMatrices, matricesBase + i * 16);\r\n });\r\n\r\n this._isDirty = true;\r\n\r\n this._baseLine -= paragraph.lineHeight * fontScale * paragraph.lines.length;\r\n }\r\n\r\n /**\r\n * Render the text using the provided view and projection matrices\r\n * @param viewMatrix define the view matrix to use\r\n * @param projectionMatrix define the projection matrix to use\r\n */\r\n public render(viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike): void {\r\n const drawWrapper = this._drawWrapperBase;\r\n\r\n const effect = drawWrapper.effect!;\r\n\r\n // Check\r\n if (!effect.isReady()) {\r\n return;\r\n }\r\n const engine = this._engine;\r\n\r\n engine.setState(false);\r\n engine.enableEffect(drawWrapper);\r\n\r\n if (this.ignoreDepthBuffer) {\r\n engine.setDepthBuffer(false);\r\n }\r\n\r\n if (this._parent) {\r\n CopyMatrixToRef(this._parent.getWorldMatrix(), this._parentWorldMatrix);\r\n } else {\r\n IdentityMatrixToRef(this._parentWorldMatrix);\r\n }\r\n\r\n effect.setInt(\"mode\", this.isBillboard ? (this.isBillboardScreenProjected ? 2 : 1) : 0);\r\n effect.setMatrix(\"parentWorld\", this._parentWorldMatrix);\r\n effect.setMatrix(\"view\", viewMatrix);\r\n effect.setMatrix(\"projection\", projectionMatrix);\r\n effect.setMatrix(\"transform\", this.transformMatrix);\r\n\r\n // Texture\r\n effect.setTexture(\"fontAtlas\", this._font.textures[0]);\r\n effect.setDirectColor4(\"uColor\", this.color);\r\n effect.setDirectColor4(\"uStrokeColor\", this.strokeColor);\r\n effect.setFloat(\"thickness\", this.thicknessControl * 0.9);\r\n effect.setFloat(\"uStrokeInsetWidth\", this.strokeInsetWidth);\r\n effect.setFloat(\"uStrokeOutsetWidth\", this.strokeOutsetWidth);\r\n\r\n const instanceCount = this._charMatrices.length / 16;\r\n\r\n // Need update?\r\n if (this._isDirty) {\r\n this._isDirty = false;\r\n\r\n if (this._worldBuffer!.getBuffer()!.capacity / 4 < instanceCount * 16) {\r\n this._resizeBuffers(instanceCount);\r\n }\r\n\r\n this._worldBuffer!.update(this._charMatrices);\r\n this._uvBuffer!.update(this._charUvs);\r\n }\r\n\r\n if (this._useVAO) {\r\n if (!this._vertexArrayObject) {\r\n this._vertexArrayObject = (engine as ThinEngine).recordVertexArrayObject(this._vertexBuffers, null, effect);\r\n }\r\n (engine as ThinEngine).bindVertexArrayObject(this._vertexArrayObject, null);\r\n } else {\r\n // VBOs\r\n engine.bindBuffers(this._vertexBuffers, null, effect);\r\n }\r\n\r\n engine.setAlphaMode(Constants.ALPHA_COMBINE);\r\n engine.drawArraysType(Constants.MATERIAL_TriangleStripDrawMode, 0, 4, instanceCount);\r\n engine.unbindInstanceAttributes();\r\n engine.setAlphaMode(Constants.ALPHA_DISABLE);\r\n\r\n if (this.ignoreDepthBuffer) {\r\n engine.setDepthBuffer(true);\r\n }\r\n }\r\n\r\n /**\r\n * Release associated resources\r\n */\r\n public dispose(): void {\r\n if (this._worldBuffer) {\r\n this._worldBuffer.dispose();\r\n this._worldBuffer = null;\r\n }\r\n\r\n if (this._uvBuffer) {\r\n this._uvBuffer.dispose();\r\n this._uvBuffer = null;\r\n }\r\n\r\n if (this._spriteBuffer) {\r\n this._spriteBuffer.dispose();\r\n this._spriteBuffer = null;\r\n }\r\n\r\n if (this._vertexArrayObject) {\r\n (this._engine as ThinEngine).releaseVertexArrayObject(this._vertexArrayObject);\r\n (<any>this._vertexArrayObject) = null;\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new TextRenderer instance asynchronously\r\n * @param font define the font asset to use\r\n * @param engine define the engine to use\r\n * @returns a promise that resolves to the created TextRenderer instance\r\n */\r\n public static async CreateTextRendererAsync(font: FontAsset, engine: AbstractEngine) {\r\n if (!engine.getCaps().instancedArrays || !engine._features.supportSpriteInstancing) {\r\n throw new Error(\"Instanced arrays are required for MSDF text rendering.\");\r\n }\r\n\r\n let shaderLanguage = ShaderLanguage.GLSL;\r\n let vertex: string = \"\";\r\n let fragment: string = \"\";\r\n if (engine.isWebGPU) {\r\n shaderLanguage = ShaderLanguage.WGSL;\r\n vertex = (await import(\"./shadersWGSL/msdf.vertex\")).msdfVertexShaderWGSL.shader;\r\n fragment = (await import(\"./shadersWGSL/msdf.fragment\")).msdfPixelShaderWGSL.shader;\r\n } else {\r\n vertex = (await import(\"./shaders/msdf.vertex\")).msdfVertexShader.shader;\r\n fragment = (await import(\"./shaders/msdf.fragment\")).msdfPixelShader.shader;\r\n }\r\n\r\n const textRenderer = new TextRenderer(engine, shaderLanguage, font);\r\n textRenderer._setShaders(vertex, fragment);\r\n\r\n return textRenderer;\r\n }\r\n}\r\n","import * as addons from \"addons/index\";\r\n\r\nexport { addons };\r\nexport default addons;\r\n"],"names":["root","factory","exports","module","require","define","amd","self","global","this","__WEBPACK_EXTERNAL_MODULE__597__","name","shader","ShaderStore","ShadersStore","msdfVertexShader","ShadersStoreWGSL","msdfPixelShaderWGSL","msdfPixelShader","msdfVertexShaderWGSL","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","n","getter","__esModule","d","a","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","extendStatics","b","setPrototypeOf","__proto__","Array","p","__extends","TypeError","String","__","constructor","create","__assign","assign","t","s","i","arguments","length","apply","__spreadArray","to","from","pack","ar","l","slice","concat","SuppressedError","UboArray","useAerialPerspectiveLut","APPLY_AERIAL_PERSPECTIVE_INTENSITY","APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS","USE_AERIAL_PERSPECTIVE_LUT","MaterialDefines","size","type","material","_atmosphere","_isAerialPerspectiveEnabled","USE_CUSTOM_REFLECTION","diffuseSkyIrradianceLut","CUSTOM_FRAGMENT_BEFORE_FOG","isAerialPerspectiveLutEnabled","aerialPerspectiveIntensity","aerialPerspectiveRadianceBias","doNotSerialize","_pluginManager","_addPlugin","getUniformBuffersNames","_ubos","uniformBuffer","useUbo","push","getUniforms","atmosphere","ubo","fragment","externalUniforms","getUniformNames","isReadyForSubMesh","isReady","aerialPerspectiveLutRenderTarget","transmittanceLutRenderTarget","transmittanceLut","renderTarget","getActiveTextures","_activeTextures","bindForSubMesh","engine","scene","getEngine","effect","currentEffect","bindUniformBufferToEffect","width","getRenderWidth","height","getRenderHeight","updateFloat2","setTexture","prepareDefines","defines","lastUseAerialPerspectiveLut","lastApplyAerialPerspectiveIntensity","lastApplyAerialPerspectiveRadianceBias","markAllAsDirty","getSamplers","samplers","getCustomCode","shaderType","directionToLightSnippet","supportsUniformBuffers","atmosphereImportSnippet","CUSTOM_FRAGMENT_DEFINITIONS","CUSTOM_LIGHT0_COLOR","CUSTOM_REFLECTION","MaterialPluginBase","TempRay","Ray","Vector3","Zero","_inverseViewProjectionMatrixWithoutTranslation","Matrix","Identity","_directionToLightRelativeToCameraGeocentricNormal","Up","_cosAngleLightToZenith","_cameraRadius","_clampedCameraRadius","_cameraHeight","_clampedCameraHeight","_cameraPositionGlobal","_clampedCameraPositionGlobal","_cosCameraHorizonAngleFromZenith","_sinCameraAtmosphereHorizonAngleFromNadir","_cameraGeocentricNormal","_cameraForward","Down","_cameraNearPlane","_cameraPosition","_viewport","Vector4","_lastViewMatrix","_lastProjectionMatrix","_inverseViewMatrixWithoutTranslation","_inverseProjectionMatrix","update","camera","planetRadius","planetRadiusWithOffset","atmosphereRadius","directionToLight","originHeight","minZ","copyFrom","getForwardRayToRef","direction","getScene","copyFromFloats","viewMatrix","getViewMatrix","projectionMatrix","getProjectionMatrix","equals","setTranslation","ZeroReadOnly","invertToRef","multiplyToRef","globalPosition","scaleToRef","y","normalizeToRef","ComputeCosHorizonAngleFromZenith","Math","min","Vector3Dot","lightZenithSinAngle","sqrt","max","normalize","radius","sinHorizonAngleFromNadir","DefaultPeakRayleighScattering","DefaultPeakMieScattering","DefaultPeakMieAbsorption","DefaultPeakOzoneAbsorption","options","onChangedObservable","Observable","_peakRayleighScattering","_peakMieScattering","_peakMieAbsorption","_peakOzoneAbsorption","_planetRadiusWithOffset","_planetRadiusSquared","_atmosphereRadius","_atmosphereRadiusSquared","_horizonDistanceToAtmosphereEdge","_horizonDistanceToAtmosphereEdgeSquared","_rayleighScattering","_mieScattering","_mieAbsorption","_mieExtinction","_ozoneAbsorption","_planetRadius","_planetRadiusOffset","planetRadiusOffset","_atmosphereThickness","atmosphereThickness","_rayleighScatteringScale","rayleighScatteringScale","peakRayleighScattering","_mieScatteringScale","mieScatteringScale","peakMieScattering","_mieAbsorptionScale","mieAbsorptionScale","peakMieAbsorption","_ozoneAbsorptionScale","ozoneAbsorptionScale","peakOzoneAbsorption","_recomputeDimensionalParameters","_recomputeRayleighScattering","_recomputeMieScattering","_recomputeMieAbsorption","_recomputeOzoneAbsorption","notifyObservers","_recomputeMieExtinction","addToRef","MakeTempColor4Like","Number","NaN","g","TmpColor1","TmpColor2","TmpColor3","TmpColor4","Sample2DRgbaToRef","u","v","widthPx","heightPx","data","result","normalizeFunc","Clamp","fractionalTexelX","fractionalTexelY","xLeft","floor","xRight","yBottom","yTop","lowerLeftColor","TexelFetch2DRgbaToRef","upperLeftColor","lowerRightColor","upperRightColor","tX","tY","oneMinusTX","oneMinusTY","w0","w1","w2","w3","x","clampedTexelX","index","IncludesShadersStore","UvTemp","Color4Temp","_renderTarget","_effectWrapper","_effectRenderer","_isDirty","_isDisposed","_lutData","Uint16Array","RenderTargetTexture","generateMipMaps","Constants","TEXTURETYPE_HALF_FLOAT","samplingMode","TEXTURE_BILINEAR_SAMPLINGMODE","generateDepthBuffer","gammaSpace","wrapU","TEXTURE_CLAMP_ADDRESSMODE","wrapV","anisotropicFilteringLevel","skipInitialClear","EffectWrapper","vertexShader","fragmentShader","attributeNames","uniformNames","uniformBuffers","useShaderStore","EffectRenderer","indices","positions","environmentTexture","irradianceTexture","environmentIntensity","isRenderTarget","Error","getDiffuseSkyIrradianceToRef","cameraGeocentricNormal","lightIrradiance","additionalDiffuseSkyIrradiance","properties","physicalProperties","cosAngleLightToZenith","unitX","unitY","ComputeLutUVToRef","z","FromHalfFloat","intensity","diffuseSkyIrradianceIntensity","render","effectWrapper","bindFramebuffer","effectRenderer","applyEffectWrapper","saveStates","setViewport","bindBuffers","multiScatteringLutRenderTarget","setFloat","draw","restoreStates","restoreDefaultFramebuffer","readPixels","then","markDirty","dispose","TransmittanceHorizonRange","Uv","LightColorTemp","DirectionToLightTemp","onUpdatedObservable","Uint8Array","TEXTURETYPE_UNSIGNED_BYTE","getTransmittedColorToRef","pointRadius","pointGeocentricNormal","lutData","positionDistanceToOrigin","uv","radiusSquared","distanceToHorizon","planetRadiusSquared","discriminant","atmosphereRadiusSquared","distanceToAtmosphereEdge","minDistanceToAtmosphereEdge","maxDistanceToAtmosphereEdge","horizonDistanceToAtmosphereEdge","cosAngleLightToZenithCoordinate","distanceToHorizonCoordinate","weight","SmoothStep","SampleLutToRef","updateLightParameters","light","lightDirection","diffuse","specular","CharCode","MaterialPlugin","lights","_directionToLight","_tempSceneAmbient","Color3","_additionalDiffuseSkyIrradiance","_atmosphereUbo","_minimumMultiScattering","_cameraAtmosphereVariables","AtmospherePerCameraVariables","_lightRadianceAtCamera","_linearLightColor","_atmosphereUniformBufferAsArray","_isEnabled","_hasRenderedMultiScatteringLut","_multiScatteringEffectWrapper","_multiScatteringLutRenderTarget","_aerialPerspectiveLutEffectWrapper","_aerialPerspectiveLutEffectRenderer","_aerialPerspectiveLutRenderTarget","_skyViewLutEffectWrapper","_skyViewLutEffectRenderer","_skyViewLutRenderTarget","_aerialPerspectiveCompositorEffectWrapper","_skyCompositorEffectWrapper","_globeAtmosphereCompositorEffectWrapper","_onBeforeCameraRenderObserver","_onBeforeDrawPhaseObserver","_onAfterRenderingGroupObserver","onAfterUpdateVariablesForCameraObservable","onBeforeLightVariablesUpdateObservable","onBeforeRenderLutsForCameraObservable","onAfterRenderLutsForCameraObservable","depthTexture","_peakRayleighScatteringMmInternal","_peakRayleighScatteringKm","_peakMieScatteringMmInternal","_peakMieScatteringKm","_peakMieAbsorptionMmInternal","_peakMieAbsorptionKm","_peakOzoneAbsorptionMmInternal","_peakOzoneAbsorptionKm","_transmittanceLut","_diffuseSkyIrradianceLut","_engine","isWebGPU","version","_physicalProperties","AtmospherePhysicalProperties","add","_lights","_exposure","exposure","_isLinearSpaceLight","isLinearSpaceLight","_isLinearSpaceComposition","isLinearSpaceComposition","_applyApproximateTransmittance","applyApproximateTransmittance","_aerialPerspectiveRadianceBias","_aerialPerspectiveTransmittanceScale","aerialPerspectiveTransmittanceScale","_aerialPerspectiveSaturation","aerialPerspectiveSaturation","_aerialPerspectiveIntensity","_diffuseSkyIrradianceDesaturationFactor","diffuseSkyIrradianceDesaturationFactor","_diffuseSkyIrradianceIntensity","_additionalDiffuseSkyIrradianceIntensity","additionalDiffuseSkyIrradianceIntensity","_multiScatteringIntensity","multiScatteringIntensity","_minimumMultiScatteringIntensity","minimumMultiScatteringIntensity","_isSkyViewLutEnabled","isSkyViewLutEnabled","_isAerialPerspectiveLutEnabled","_originHeight","_additionalDiffuseSkyIrradianceColor","additionalDiffuseSkyIrradianceColor","_groundAlbedo","groundAlbedo","set","minimumMultiScatteringColor","_minimumMultiScatteringColor","_skyRenderingGroup","skyRenderingGroup","_aerialPerspectiveRenderingGroup","aerialPerspectiveRenderingGroup","_globeAtmosphereRenderingGroup","globeAtmosphereRenderingGroup","TransmittanceLut","CreateRenderTargetTexture","isDiffuseSkyIrradianceLutEnabled","DiffuseSkyIrradianceLut","skyViewLutRenderTarget","onBeforeCameraRenderObservable","_updatePerCameraVariables","_renderLutsForCamera","renderingManager","getRenderingGroup","onBeforeDrawPhaseObservable","_empty","onAfterRenderingGroupObservable","group","groupId","renderingGroupId","_drawSkyCompositor","_drawAerialPerspectiveCompositor","_drawGlobeAtmosphereCompositor","onDisposeObservable","addOnce","UnregisterMaterialPlugin","RegisterMaterialPlugin","getClassName","AtmospherePBRMaterialPlugin","IsSupported","_badOS","minimumScatteringColor","newValue","_disposeSkyCompositor","_disposeGlobeAtmosphereCompositor","coordinatesMode","TEXTURE_EQUIRECTANGULAR_MODE","CreateSkyViewEffectWrapper","_disposeAerialPerspectiveCompositor","layers","CreateAerialPerspectiveEffectWrapper","hasDefineChanged","atmosphereUbo","UniformBuffer","addUniform","remove","isEnabled","setEnabled","enabled","_createMultiScatteringEffectWrapper","BlackReadOnly","samplerNames","_drawMultiScatteringLut","DrawEffect","clampedCameraRadius","CreateAerialPerspectiveCompositorEffectWrapper","skyViewLut","multiScatteringLut","aerialPerspectiveLut","_","ALPHA_PREMULTIPLIED_PORTERDUFF","ALPHA_ONEONE","ALWAYS","CreateSkyCompositorEffectWrapper","EQUAL","CreateGlobeAtmosphereCompositorEffectWrapper","scaleInPlace","cameraAtmosphereVariables","toGammaSpaceToRef","ambientColor","_updateUniformBuffer","renderGlobalLuts","isDirty","_drawSkyViewLut","_drawAerialPerspectiveLut","bindToEffect","bindUniformBufferBase","getBuffer","_uniformBuffersNames","updateVector3","rayleighScattering","updateFloat","mieScattering","mieAbsorption","mieExtinction","ozoneAbsorption","horizonDistanceToAtmosphereEdgeSquared","updateMatrix","inverseViewProjectionMatrixWithoutTranslation","directionToLightRelativeToCameraGeocentricNormal","cameraRadius","updateColor3","cameraPositionGlobal","clampedCameraPositionGlobal","cameraForward","clampedCameraHeight","cameraPosition","cosCameraHorizonAngleFromZenith","updateVector4","viewport","cameraHeight","cameraNearPlane","sinCameraAtmosphereHorizonAngleFromNadir","layer","CreateEffectWrapper","defineNames","map","defineName","rtOptions","generateStencilBuffer","format","TEXTUREFORMAT_RGBA","drawCallback","depth","alphaMode","depthTest","depthWrite","depthFunction","ALPHA_DISABLE","LEQUAL","currentDepthWrite","getDepthWrite","setDepthWrite","currentDepthFunction","getDepthFunction","setDepthFunction","currentAlphaMode","getAlphaMode","setAlphaMode","textures","hasDepthTexture","BabylonUnitsToPixels","RenderOrderFunc","defaultRenderOrder","subMeshA","subMeshB","meshA","getMesh","meshB","meshIsHtmlMeshA","meshIsHtmlMeshB","absolutePosition","parentContainerId","_containerId","enableOverlayRender","defaultOpaqueRenderOrder","RenderingGroup","PainterSortCompare","defaultAlphaTestRenderOrder","defaultTransparentRenderOrder","defaultTransparentSortCompare","_cache","cameraData","fov","position","style","htmlMeshData","WeakMap","_width","_height","_heightHalf","_temp","scaleTransform","rotationTransform","Quaternion","positionTransform","objectMatrix","cameraWorldMatrix","cameraRotationMatrix","cameraWorldMatrixAsArray","_lastDevicePixelRatio","window","devicePixelRatio","_cameraMatrixUpdated","_previousCanvasDocumentPosition","top","left","_renderObserver","_onCameraMatrixChanged","_cameraWorldMatrix","getWorldMatrix","document","_init","_overlayElements","container","_inSceneElements","parentContainer","getElementById","body","inSceneContainerId","_createRenderLayerElements","insertBefore","firstChild","overlayContainerId","zIndex","getRenderingCanvas","pointerEvents","projectionObs","matrixObs","clientRect","getRenderingCanvasClientRect","_setSize","onResizeObservable","observeCamera","activeCamera","onProjectionMatrixChangedObservable","onViewMatrixChangedObservable","onActiveCameraChanged","opaqueRenderOrder","alphaTestRenderOrder","transparentRenderOrder","setRenderingOrder","onBeforeRenderObservable","_render","containerId","existingContainer","createElement","id","domElement","overflow","cameraElement","webkitTransformStyle","transformStyle","appendChild","_getSize","dom","_getCameraCssMatrix","matrix","elements","m","_epsilon","_getHtmlContentCssMatrix","useRightHandedSystem","_getTransformationMatrix","htmlMesh","objectWorldMatrix","widthScaleFactor","heightScaleFactor","sourceWidth","sourceHeight","scaledAndTranslatedObjectMatrix","decompose","ComposeToRef","getAbsolutePosition","setRowFromFloats","HtmlMeshRenderer","PROJECTION_SCALE_FACTOR","multiplyAtIndex","_renderHtmlMesh","element","firstElementChild","_isCanvasOverlay","parentNode","requiresUpdate","_updateBaseScaleFactor","billboardMode","TransformNode","BILLBOARDMODE_NONE","webkitTransform","transform","_markAsUpdated","needsUpdate","_updateContainerPositionIfNeeded","Logger","Log","meshesNeedingUpdate","meshes","filter","mesh","source","mode","Camera","PERSPECTIVE_CAMERA","el","webkitPerspective","perspective","parent","computeWorldMatrix","cameraMatrixWorld","getRotationMatrix","transposeToRef","cameraMatrixWorldAsArray","copyToArray","FromArrayToRef","screenWidth","screenHeight","htmlMeshAspectRatio","setContentSizePx","canvasRect","scrollTop","scrollY","scrollLeft","scrollX","canvasDocumentTop","canvasDocumentLeft","containerParent","offsetParent","parentRect","getBoundingClientRect","parentDocumentTop","parentDocumentLeft","ancestorMarginsAndPadding","_getAncestorMarginsAndPadding","bodyStyle","getComputedStyle","bodyMarginTop","parseInt","marginTop","bodyMarginLeft","marginLeft","paddingTop","paddingLeft","Warn","abs","documentElement","CaptureRequestQueue","PendingRequestCallbacks","Map","UnmatchedReleaseRequests","CurrentOwner","requestRelease","requestId","DebugLog","CancelRequest","delete","includes","TransferPointerEventsOwnership","removed","newOwnerId","NextCaptureRequest","DoRelease","DoCapture","release","capture","shift","message","Tools","performance","now","LocalScene","CaptureOnEnterCount","MeshToBehaviorMap","StartCaptureOnEnter","addEventListener","OnPointerMove","DoStopCaptureOnEnter","removeEventListener","StopCaptureOnEnter","evt","pickedMesh","touches","clientX","clientY","pointerScreenX","pointerScreenY","pickResult","pick","pointerCaptureBehavior","_captureOnPointerEnter","hit","capturingIdAsInt","uniqueId","capturePointerEvents","_captureCallback","_releaseCallback","captureOnPointerEnter","_attachedMesh","init","attach","attachedMesh","detach","releasePointerEvents","toString","captureCallback","releaseCallback","RemoveUnmatchedRequest","EnqueueCaptureRequest","FitStrategy","CONTAIN","wrapElement","sizingElement","display","justifyContent","alignItems","scalingElement","visibility","updateSize","offsetWidth","offsetHeight","childWidth","childHeight","scale","COVER","STRETCH","NONE","isCanvasOverlay","fitStrategy","_enabled","_ready","_requiresUpdate","_inverseScaleMatrix","_pointerEventCaptureBehavior","_sourceWidth","_sourceHeight","_fitStrategy","_createMask","_element","_createElement","PointerEventsCaptureBehavior","bind","addBehavior","setContent","_setAsReady","scaling","setAll","_updateScaleIfNecessary","_doSetEnabled","ready","_worldMatrixUpdateObserver","onAfterWorldMatrixUpdateObservable","_setElementzIndex","bakeTransformIntoVertices","scaleX","scaleY","scaleMatrix","Scaling","CreatePlaneVertexData","applyToMesh","checkCollisions","depthMask","StandardMaterial","backFaceCulling","disableColorWrite","disableLighting","freeze","getElementsByTagName","div","backgroundColor","backfaceVisibility","Mesh","definitionData","textureUrl","_chars","_kernings","_font","JSON","parse","pages","chars","forEach","char","kernings","kerning","submap","first","second","amount","_charsRegex","RegExp","c","replace","join","_updateFallbacks","info","page","texture","Texture","noMipmap","invertY","has","SPACE","xoffset","yoffset","xadvance","chnl","TOFU","_getChar","charCode","_getKerning","_unsupportedChars","text","DefaultParagraphOptions","maxWidth","Infinity","lineHeight","letterSpacing","tabSize","whiteSpace","textAlign","translate","fontAsset","_computeMetrics","paragraph","lines","glyphs","common","collapsed","_collapse","trimmed","_breakLines","line","trim","_wrap","anchor","glyph","flatMap","split","repeat","lineOffset","lastChar","currentLine","currentGlyphs","currentCursor","currentWidth","start","end","pushCurrentLine","charCodeAt","charWidth","newWidth","cursorProgress","nextPosition","shouldBreak","shaderLanguage","font","_useVAO","_vertexBuffers","_charMatrices","_charUvs","_baseLine","_scalingMatrix","ThinMatrix","_fontScaleMatrix","_offsetMatrix","_translationMatrix","_baseMatrix","_scaledMatrix","_localMatrix","_finalMatrix","_lineMatrix","_parentWorldMatrix","color","strokeColor","strokeInsetWidth","strokeOutsetWidth","thicknessControl","_parent","_transformMatrix","isBillboard","isBillboardScreenProjected","ignoreDepthBuffer","_shaderLanguage","getCaps","vertexArrayObject","disableVertexArrayObjects","spriteData","Float32Array","_spriteBuffer","Buffer","createVertexBuffer","_resizeBuffers","capacity","_worldBuffer","_uvBuffer","_setShaders","vertex","_drawWrapperBase","DrawWrapper","drawContext","useInstancing","createEffect","vertexSource","fragmentSource","_refCount","addParagraph","worldMatrix","SdfTextParagraph","fontScale","texWidth","scaleW","texHeight","scaleH","worldMatrixToUse","TranslationMatrixToRef","ScalingMatrixToRef","charsUvsBase","matricesBase","MultiplyMatricesToRef","CopyMatrixToArray","drawWrapper","setState","enableEffect","setDepthBuffer","CopyMatrixToRef","IdentityMatrixToRef","setInt","setMatrix","transformMatrix","setDirectColor4","instanceCount","_vertexArrayObject","recordVertexArrayObject","bindVertexArrayObject","ALPHA_COMBINE","drawArraysType","MATERIAL_TriangleStripDrawMode","unbindInstanceAttributes","releaseVertexArrayObject","CreateTextRendererAsync","thisArg","_arguments","generator","f","label","sent","trys","ops","Iterator","next","verb","iterator","op","done","pop","e","step","instancedArrays","_features","supportSpriteInstancing","textRenderer","TextRenderer","P","Promise","resolve","reject","fulfilled","rejected"],"sourceRoot":""}