babylonjs-addons 8.14.1 → 8.14.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,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-addons",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-addons"]=t(require("babylonjs")):e.ADDONS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(e=>(()=>{"use strict";var t={36:(e,t,r)=>{r.r(t),r.d(t,{msdfVertexShader:()=>s});var i=r(597),n="msdfVertexShader",o="#define BILLBOARD 1\n#define BILLBOARDSCREENPROJECTED 2\nattribute vec2 offsets;attribute vec4 world0;attribute vec4 world1;attribute vec4 world2;attribute vec4 world3;attribute vec4 uvs;uniform mat4 transform;uniform mat4 parentWorld;uniform mat4 view;uniform mat4 projection;uniform vec3 center;uniform int mode;varying vec2 atlasUV;void main(void) {mat4 world=mat4(world0,world1,world2,world3);vec4 worldPos=transform*(world*vec4(offsets.xy-vec2(0.5,0.5),0.,1.0));if (mode>=BILLBOARD) {vec3 viewPos=(view*parentWorld*vec4(0.,0.,0.,1.0)).xyz; \nif (mode==BILLBOARDSCREENPROJECTED) {viewPos.x/=viewPos.z;viewPos.y/=viewPos.z;viewPos.z=1.0;}\ngl_Position=projection*vec4(viewPos+worldPos.xyz,1.0); } else {vec3 viewPos=(view*parentWorld*worldPos).xyz; \ngl_Position=projection*vec4(viewPos,1.0); }\natlasUV=vec2(uvs.x+offsets.x*uvs.z,uvs.y+(1.0-offsets.y)*uvs.w);}";i.ShaderStore.ShadersStore[n]||(i.ShaderStore.ShadersStore[n]=o);var s={name:n,shader:o}},115:(e,t,r)=>{r.r(t),r.d(t,{msdfPixelShaderWGSL:()=>s});var i=r(597),n="msdfPixelShader",o="var fontAtlas: texture_2d<f32>;var fontAtlasSampler: sampler;uniform uColor: vec4f;uniform thickness: f32;uniform uStrokeColor: vec4f;uniform uStrokeInsetWidth: f32;uniform uStrokeOutsetWidth: f32;varying atlasUV: vec2f;fn median(msdf: vec3<f32>)->f32 {let a=min(msdf.r,msdf.g);let b=max(msdf.r,msdf.g);return max(a,min(b,msdf.b));}\n@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {let s=textureSample(fontAtlas,fontAtlasSampler,input.atlasUV).rgb;let sigDist=median(s)-0.5+uniforms.thickness;let afwidth=length(vec2<f32>(dpdx(sigDist),dpdy(sigDist)));let alpha=clamp(sigDist/afwidth+0.5,0.0,1.0);let sigDistOutset=sigDist+uniforms.uStrokeOutsetWidth*0.5;let sigDistInset=sigDist-uniforms.uStrokeInsetWidth*0.5;let afwidthOutset=length(vec2<f32>(dpdx(sigDistOutset),dpdy(sigDistOutset)));let afwidthInset=length(vec2<f32>(dpdx(sigDistInset),dpdy(sigDistInset)));let outset=clamp(sigDistOutset/afwidthOutset+0.5,0.0,1.0);let inset=1.0-clamp(sigDistInset/afwidthInset+0.5,0.0,1.0);let border=outset*inset;let filledFragColor=vec4<f32>(uniforms.uColor.rgb,alpha*uniforms.uColor.a);let strokedFragColor=vec4<f32>(uniforms.uStrokeColor.rgb,border*uniforms.uStrokeColor.a);fragmentOutputs.color=mix(filledFragColor,strokedFragColor,border);}";i.ShaderStore.ShadersStoreWGSL[n]||(i.ShaderStore.ShadersStoreWGSL[n]=o);var s={name:n,shader:o}},370:(e,t,r)=>{r.r(t),r.d(t,{msdfPixelShader:()=>s});var i=r(597),n="msdfPixelShader",o="#extension GL_OES_standard_derivatives : enable\nprecision highp float;uniform sampler2D fontAtlas;uniform vec4 uColor;uniform vec4 uStrokeColor;uniform float uStrokeInsetWidth;uniform float uStrokeOutsetWidth;uniform float thickness;varying vec2 atlasUV;float median(vec3 msdf) {return max(min(msdf.r,msdf.g),min(max(msdf.r,msdf.g),msdf.b));}\nvoid main(void)\n{vec3 s=texture2D(fontAtlas,atlasUV).rgb;float sigDist=median(s)-0.5+thickness;float alpha=clamp(sigDist/fwidth(sigDist)+0.5,0.0,1.0);float sigDistOutset=sigDist+uStrokeOutsetWidth*0.5;float sigDistInset=sigDist-uStrokeInsetWidth*0.5;float outset=clamp(sigDistOutset/fwidth(sigDistOutset)+0.5,0.0,1.0);float inset=1.0-clamp(sigDistInset/fwidth(sigDistInset)+0.5,0.0,1.0);float border=outset*inset;vec4 filledFragColor=vec4(uColor.rgb,alpha*uColor.a);vec4 strokedFragColor=vec4(uStrokeColor.rgb,border*uStrokeColor.a);gl_FragColor=mix(filledFragColor,strokedFragColor,border);}";i.ShaderStore.ShadersStore[n]||(i.ShaderStore.ShadersStore[n]=o);var s={name:n,shader:o}},597:t=>{t.exports=e},681:(e,t,r)=>{r.r(t),r.d(t,{msdfVertexShaderWGSL:()=>s});var i=r(597),n="msdfVertexShader",o="#define BILLBOARD 1\n#define BILLBOARDSCREENPROJECTED 2\nattribute offsets: vec2f;attribute world0: vec4f;attribute world1: vec4f;attribute world2: vec4f;attribute world3: vec4f;attribute uvs: vec4f;uniform transform: mat4x4f;uniform parentWorld: mat4x4f;uniform view: mat4x4f;uniform projection: mat4x4f;uniform mode: u32;varying atlasUV: vec2f;@vertex\nfn main(input: VertexInputs)->FragmentInputs {let world=mat4x4<f32>(input.world0,input.world1,input.world2,input.world3);let localOffset=vec4<f32>(input.offsets-vec2<f32>(0.5,0.5),0.0,1.0);let worldPos=uniforms.transform*world*localOffset;if (uniforms.mode>=BILLBOARD) { \nvar viewPos=(uniforms.view*uniforms.parentWorld*vec4f(0.,0.,0.,1.0)).xyz;if (uniforms.mode==BILLBOARDSCREENPROJECTED) {viewPos=vec3f(viewPos.x/viewPos.z,viewPos.y/viewPos.z,1.0);} \nvertexOutputs.position=uniforms.projection*vec4<f32>(viewPos+worldPos.xyz,1.0);} else { \nlet viewPos=(uniforms.view*uniforms.parentWorld*worldPos).xyz;vertexOutputs.position=uniforms.projection*vec4<f32>(viewPos,1.0);}\nvertexOutputs.atlasUV=vec2<f32>(\ninput.uvs.x+input.offsets.x*input.uvs.z,\ninput.uvs.y+(1.0-input.offsets.y)*input.uvs.w\n);}";i.ShaderStore.ShadersStoreWGSL[n]||(i.ShaderStore.ShadersStoreWGSL[n]=o);var s={name:n,shader:o}}},r={};function i(e){var n=r[e];if(void 0!==n)return n.exports;var o=r[e]={exports:{}};return t[e](o,o.exports,i),o.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};i.d(n,{default:()=>F});var o={};i.r(o),i.d(o,{DefaultParagraphOptions:()=>D,FitStrategy:()=>R,FontAsset:()=>T,HtmlMesh:()=>W,HtmlMeshRenderer:()=>c,PointerEventsCaptureBehavior:()=>I,SdfTextParagraph:()=>k,TextRenderer:()=>L,msdfPixelShader:()=>z.msdfPixelShader,msdfPixelShaderWGSL:()=>U.msdfPixelShaderWGSL,msdfVertexShader:()=>j.msdfVertexShader,msdfVertexShaderWGSL:()=>V.msdfVertexShaderWGSL});var s=i(597),a=100,l=function(e){return function(t,r){var i=t.getMesh(),n=r.getMesh(),o=i.isHtmlMesh,s=n.isHtmlMesh;return o?s&&i.absolutePosition.z<=n.absolutePosition.z?1:-1:s?1:e(t,r)}},c=function(){function e(e,t){var r=void 0===t?{}:t,i=r.parentContainerId,n=void 0===i?null:i,o=r._containerId,a=void 0===o?"css-container":o,l=r.enableOverlayRender,c=void 0===l||l,h=r.defaultOpaqueRenderOrder,d=void 0===h?s.RenderingGroup.PainterSortCompare:h,u=r.defaultAlphaTestRenderOrder,f=void 0===u?s.RenderingGroup.PainterSortCompare:u,p=r.defaultTransparentRenderOrder,v=void 0===p?s.RenderingGroup.defaultTransparentSortCompare:p,m=this;this._cache={cameraData:{fov:0,position:new s.Vector3,style:""},htmlMeshData:new WeakMap},this._width=0,this._height=0,this._heightHalf=0,this._temp={scaleTransform:new s.Vector3,rotationTransform:new s.Quaternion,positionTransform:new s.Vector3,objectMatrix:s.Matrix.Identity(),cameraWorldMatrix:s.Matrix.Identity(),cameraRotationMatrix:s.Matrix.Identity(),cameraWorldMatrixAsArray:new Array(16)},this._lastDevicePixelRatio=window.devicePixelRatio,this._cameraMatrixUpdated=!0,this._previousCanvasDocumentPosition={top:0,left:0},this._renderObserver=null,this._onCameraMatrixChanged=function(e){m._cameraWorldMatrix=e.getWorldMatrix(),m._cameraMatrixUpdated=!0},"undefined"!=typeof document&&(this._containerId=a,this._init(e,n,c,d,f,v))}return e.prototype.dispose=function(){var e,t;this._renderObserver&&(this._renderObserver.remove(),this._renderObserver=null),null===(e=this._overlayElements)||void 0===e||e.container.remove(),this._overlayElements=null,null===(t=this._inSceneElements)||void 0===t||t.container.remove(),this._inSceneElements=null},e.prototype._init=function(e,t,r,i,n,o){var s,a=this;if("undefined"!=typeof document){var c=t?document.getElementById(t):document.body;c||(c=document.body);var h="".concat(this._containerId,"_in_scene");if(this._inSceneElements=this._createRenderLayerElements(h),c.insertBefore(this._inSceneElements.container,c.firstChild),r){var d="".concat(this._containerId,"_overlay");this._overlayElements=this._createRenderLayerElements(d);var u=+(null!==(s=e.getEngine().getRenderingCanvas().style.zIndex)&&void 0!==s?s:"0")+1;this._overlayElements.container.style.zIndex="".concat(u),this._overlayElements.container.style.pointerEvents="none",c.insertBefore(this._overlayElements.container,c.firstChild)}this._engine=e.getEngine();var f,p,v=this._engine.getRenderingCanvasClientRect();if(!v)throw new Error("Failed to get client rect for rendering canvas");this._setSize(v.width,v.height),this._engine.onResizeObservable.add((function(){var e=a._engine.getRenderingCanvasClientRect();e&&a._setSize(e.width,e.height)}));var m=function(){var t=e.activeCamera;t&&(f=t.onProjectionMatrixChangedObservable.add((function(){a._onCameraMatrixChanged(t)})),p=t.onViewMatrixChangedObservable.add((function(){a._onCameraMatrixChanged(t)})))};m(),e.onActiveCameraChanged.add((function(){var t,r;f&&(null===(t=e.activeCamera)||void 0===t||t.onProjectionMatrixChangedObservable.remove(f)),p&&(null===(r=e.activeCamera)||void 0===r||r.onViewMatrixChangedObservable.remove(p)),m()}));var _=l(i),g=l(n),y=l(o);e.setRenderingOrder(0,_,g,y),this._renderObserver=e.onBeforeRenderObservable.add((function(){a._render(e,e.activeCamera)}))}},e.prototype._createRenderLayerElements=function(e){var t=document.getElementById(e);t&&t.remove();var r=document.createElement("div");r.id=e,r.style.position="absolute",r.style.width="100%",r.style.height="100%",r.style.zIndex="-1";var i=document.createElement("div");i.style.overflow="hidden";var n=document.createElement("div");return n.style.webkitTransformStyle="preserve-3d",n.style.transformStyle="preserve-3d",n.style.pointerEvents="none",i.appendChild(n),r.appendChild(i),{container:r,domElement:i,cameraElement:n}},e.prototype._getSize=function(){return{width:this._width,height:this._height}},e.prototype._setSize=function(e,t){if(this._width=e,this._height=t,this._heightHalf=this._height/2,this._inSceneElements&&this._overlayElements)for(var r=0,i=[this._inSceneElements.domElement,this._overlayElements.domElement,this._inSceneElements.cameraElement,this._overlayElements.cameraElement];r<i.length;r++){var n=i[r];n&&(n.style.width="".concat(e,"px"),n.style.height="".concat(t,"px"))}},e.prototype._getCameraCssMatrix=function(e){var t=e.m;return"matrix3d(".concat(this._epsilon(t[0]),",").concat(this._epsilon(-t[1]),",").concat(this._epsilon(t[2]),",").concat(this._epsilon(t[3]),",").concat(this._epsilon(t[4]),",").concat(this._epsilon(-t[5]),",").concat(this._epsilon(t[6]),",").concat(this._epsilon(t[7]),",").concat(this._epsilon(t[8]),",").concat(this._epsilon(-t[9]),",").concat(this._epsilon(t[10]),",").concat(this._epsilon(t[11]),",").concat(this._epsilon(t[12]),",").concat(this._epsilon(-t[13]),",").concat(this._epsilon(t[14]),",").concat(this._epsilon(t[15]),")")},e.prototype._getHtmlContentCssMatrix=function(e,t){var r=e.m,i=t?-1:1;return"matrix3d(".concat(this._epsilon(r[0]),",").concat(this._epsilon(r[1]),",").concat(this._epsilon(r[2]*-i),",").concat(this._epsilon(r[3]),",").concat(this._epsilon(-r[4]),",").concat(this._epsilon(-r[5]),",").concat(this._epsilon(r[6]*i),",").concat(this._epsilon(-r[7]),",").concat(this._epsilon(r[8]*-i),",").concat(this._epsilon(r[9]*-i),",").concat(this._epsilon(r[10]),",").concat(this._epsilon(r[11]*i),",").concat(this._epsilon(r[12]*i),",").concat(this._epsilon(r[13]*i),",").concat(this._epsilon(r[14]*i),",").concat(this._epsilon(r[15]),")")},e.prototype._getTransformationMatrix=function(e,t){var r;if(this._cameraWorldMatrix||(this._cameraWorldMatrix=null===(r=e.getScene().activeCamera)||void 0===r?void 0:r.getWorldMatrix()),!this._cameraWorldMatrix)return s.Matrix.Identity();var i=e.getWorldMatrix(),n=1,o=1;e.sourceWidth&&e.sourceHeight&&(n=e.width/(e.sourceWidth/a),o=e.height/(e.sourceHeight/a));var l=this._temp.scaleTransform,c=this._temp.rotationTransform,h=this._temp.positionTransform,d=this._temp.objectMatrix;i.decompose(l,c,h),l.x*=n,l.y*=o,s.Matrix.ComposeToRef(l,c,h,d);var u=t?-1:1,f=e.getAbsolutePosition();return d.setRowFromFloats(3,(-this._cameraWorldMatrix.m[12]+f.x)*a*u,(-this._cameraWorldMatrix.m[13]+f.y)*a*u,(this._cameraWorldMatrix.m[14]-f.z)*a,1e-5*this._cameraWorldMatrix.m[15]*a),d.multiplyAtIndex(3,a),d.multiplyAtIndex(7,a),d.multiplyAtIndex(11,a),d},e.prototype._renderHtmlMesh=function(e,t){var r,i;if(e.element&&e.element.firstElementChild){var n=this._cache.htmlMeshData.get(e);n||(n={style:""},this._cache.htmlMeshData.set(e,n));var o=e._isCanvasOverlay?null===(r=this._overlayElements)||void 0===r?void 0:r.cameraElement:null===(i=this._inSceneElements)||void 0===i?void 0:i.cameraElement;e.element.parentNode!==o&&o.appendChild(e.element),e.requiresUpdate&&this._updateBaseScaleFactor(e);var s=this._getTransformationMatrix(e,t),a="translate(-50%, -50%) ".concat(this._getHtmlContentCssMatrix(s,t));a+="".concat(t?"matrix3d(-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1)":""),n.style!==a&&(e.element.style.webkitTransform=a,e.element.style.transform=a),e._markAsUpdated()}},e.prototype._render=function(e,t){var r,i,n,o,a=!1,l=e.useRightHandedSystem;this._updateContainerPositionIfNeeded(),this._cameraMatrixUpdated&&(this._cameraMatrixUpdated=!1,a=!0),t.position.x===this._cache.cameraData.position.x&&t.position.y===this._cache.cameraData.position.y&&t.position.z===this._cache.cameraData.position.z||(this._cache.cameraData.position.copyFrom(t.position),a=!0),window.devicePixelRatio!==this._lastDevicePixelRatio&&(this._lastDevicePixelRatio=window.devicePixelRatio,s.Logger.Log("In render - dpr changed: ",this._lastDevicePixelRatio),a=!0);var c=e.meshes.filter((function(e){return e.isHtmlMesh&&(a||e.requiresUpdate)}));if(a=a||c.length>0){var h=t.getProjectionMatrix().m[5]*this._heightHalf;if(this._cache.cameraData.fov!==h){var d=[null===(r=this._overlayElements)||void 0===r?void 0:r.domElement,null===(i=this._inSceneElements)||void 0===i?void 0:i.domElement];if(t.mode==s.Camera.PERSPECTIVE_CAMERA)for(var u=0,f=d;u<f.length;u++)(M=f[u])&&(M.style.webkitPerspective=h+"px",M.style.perspective=h+"px");else for(var p=0,v=d;p<v.length;p++)(M=v[p])&&(M.style.webkitPerspective="",M.style.perspective="");this._cache.cameraData.fov=h}null===t.parent&&t.computeWorldMatrix();var m=this._temp.cameraWorldMatrix;m.copyFrom(t.getWorldMatrix());var _=this._temp.cameraRotationMatrix;m.getRotationMatrix().transposeToRef(_);var g=this._temp.cameraWorldMatrixAsArray;m.copyToArray(g);var y=l?1:-1;g[1]=_.m[1],g[2]=_.m[2]*y,g[4]=_.m[4]*y,g[6]=_.m[6]*y,g[8]=_.m[8]*y,g[9]=_.m[9]*y,s.Matrix.FromArrayToRef(g,0,m);var x=this._getCameraCssMatrix(m);if(this._cache.cameraData.style!==x){for(var b=0,w=d=[null===(n=this._inSceneElements)||void 0===n?void 0:n.cameraElement,null===(o=this._overlayElements)||void 0===o?void 0:o.cameraElement];b<w.length;b++){var M;(M=w[b])&&(M.style.webkitTransform=x,M.style.transform=x)}this._cache.cameraData.style=x}for(var S=0,C=c;S<C.length;S++){var E=C[S];this._renderHtmlMesh(E,l)}}},e.prototype._updateBaseScaleFactor=function(e){var t=this._width,r=this._height,i=(e.width||1)/(e.height||1);i>t/r?t=r*i:r=t/i,e.setContentSizePx(t,r)},e.prototype._updateContainerPositionIfNeeded=function(){var e,t,r=this._engine.getRenderingCanvasClientRect();if(r){var i=window.scrollY,n=window.scrollX,o=r.top+i,a=r.left+n;if(this._previousCanvasDocumentPosition.top!==o||this._previousCanvasDocumentPosition.left!==a){this._previousCanvasDocumentPosition.top=o,this._previousCanvasDocumentPosition.left=a;for(var l=0,c=[null===(e=this._inSceneElements)||void 0===e?void 0:e.container,null===(t=this._overlayElements)||void 0===t?void 0:t.container];l<c.length;l++){var h=c[l];if(h){var d=h.offsetParent,u=d.getBoundingClientRect(),f=u.top+i,p=u.left+n,v=this._getAncestorMarginsAndPadding(d),m=window.getComputedStyle(document.body),_=parseInt(m.marginTop,10),g=parseInt(m.marginLeft,10);h.style.top="".concat(o-f-v.marginTop+v.paddingTop+_,"px"),h.style.left="".concat(a-p-v.marginLeft+v.paddingLeft+g,"px")}}}}else s.Logger.Warn("Failed to update html mesh renderer position due to failure to get canvas rect. HtmlMesh instances may not render correctly")},e.prototype._epsilon=function(e){return Math.abs(e)<1e-10?0:e},e.prototype._getAncestorMarginsAndPadding=function(e){for(var t=0,r=0,i=0,n=0;e&&e!==document.body&&e!==document.documentElement;){var o=window.getComputedStyle(e);t+=parseInt(o.marginTop,10),r+=parseInt(o.marginLeft,10),i+=parseInt(o.paddingTop,10),n+=parseInt(o.paddingLeft,10),e=e.offsetParent}return{marginTop:t,marginLeft:r,paddingTop:i,paddingLeft:n}},e}(),h=function(e,t){return h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},h(e,t)};var d=function(){return d=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},d.apply(this,arguments)};Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var u,f=[],p=new Map,v=[],m=null,_=function(e){M("In pointerEventsCapture.requestRelease - Pointer events release requested for ".concat(e)),e&&e!==m?g(e)?p.delete(e):(M("In pointerEventsCapture.requestRelease - Received release request ".concat(e," but no matching capture request was received")),v.includes(e)||v.push(e)):y()},g=function(e){var t=!1;return f=f.filter((function(r){return r!==e||(t=!0,M("In pointerEventsCapture.cancelRequest - Canceling pointer events capture request ".concat(e)),!1)})),t},y=function(){var e=w();M("In pointerEventsCapture.transferPointerEventsOwnership - Transferrring pointer events from ".concat(m," to ").concat(e)),x(),e&&b(e)},x=function(){var e;M("In pointerEventsCapture.doRelease - Releasing pointer events from ".concat(m)),m&&(null===(e=p.get(m))||void 0===e||e.release(),p.delete(m),m=null)},b=function(e){var t;e&&(null===(t=p.get(e))||void 0===t||t.capture()),m=e,M("In pointerEventsCapture.doCapture - Pointer events now captured by ".concat(e))},w=function(){return f.length>0?f.shift():null},M=function(e){("undefined"==typeof window||window["pointer-events-capture-debug"])&&s.Tools.Log("".concat(performance.now()," - game.scene.pointerEvents - ").concat(e,"\ncurrentOwner: ").concat(m,"\nqueue: ").concat(f,"\nunmatched: ").concat(v))},S=null,C=0,E=new WeakMap,O=function(e){"undefined"!=typeof document&&(0===C&&(document.addEventListener("pointermove",A),document.addEventListener("touchstart",A),S=null!=S?S:e,s.Logger.Log("PointerEventsCaptureBehavior: Starting observation of pointer move events."),S.onDisposeObservable.add(P)),C++)},P=function(){document.removeEventListener("pointermove",A),document.removeEventListener("touchstart",A),S=null,s.Logger.Log("PointerEventsCaptureBehavior: Stopping observation of pointer move events."),C=0},B=function(){"undefined"!=typeof document&&S&&--C<=0&&P()},A=function(e){if(S){var t=S.getEngine().getRenderingCanvasClientRect();if(t){var r,i="touches"in e?e.touches[0]:e,n=i.clientX,o=i.clientY,s=n-t.left,a=o-t.top,l=S.pick(s,a,(function(e){var t=E.get(e);return e.isEnabled()&&void 0!==t&&t._captureOnPointerEnter}));r=l.hit?l.pickedMesh:null;var c=parseInt(m||"");r&&r.uniqueId===c||(!c||r&&r.uniqueId===c||_(m),r&&E.get(r).capturePointerEvents())}}},I=function(){function e(e,t,r){var i=(void 0===r?{}:r).captureOnPointerEnter,n=void 0===i||i;this._captureCallback=e,this._releaseCallback=t,this.name="PointerEventsCaptureBehavior",this._attachedMesh=null,this._captureOnPointerEnter=n,"undefined"==typeof document&&s.Logger.Warn("Creating an instance of PointerEventsCaptureBehavior outside of a browser. The behavior will not work.")}return Object.defineProperty(e.prototype,"attachedMesh",{get:function(){return this._attachedMesh},set:function(e){this._attachedMesh=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"captureOnPointerEnter",{set:function(e){this._captureOnPointerEnter!==e&&(this._captureOnPointerEnter=e,this._attachedMesh&&(this._captureOnPointerEnter?O(this._attachedMesh.getScene()):B()))},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){this.attachedMesh=e,E.set(e,this),this._captureOnPointerEnter&&O(e.getScene())},e.prototype.detach=function(){this.attachedMesh&&(E.delete(this.attachedMesh),this._captureOnPointerEnter&&B(),this.attachedMesh=null)},e.prototype.dispose=function(){this.detach()},e.prototype.releasePointerEvents=function(){this.attachedMesh&&_(this.attachedMesh.uniqueId.toString())},e.prototype.capturePointerEvents=function(){var e,t,r;this.attachedMesh&&(e=this.attachedMesh.uniqueId.toString(),t=this._captureCallback,r=this._releaseCallback,M("In pointerEventsCapture.requestCapture - Pointer events capture requested for ".concat(e)),function(e){var t=!1;return v=v.filter((function(r){return r!==e||(t=!0,!1)})),t}(e)?M("In pointerEventsCapture.requestCapture - Capture request matched previous release request ".concat(e,". Cancelling capture request")):(e!==m&&function(e,t,r){M("In pointerEventsCapture.enqueueCaptureRequest - Enqueueing capture request for ".concat(e)),f.includes(e)||(f.push(e),p.set(e,{capture:t,release:r}))}(e,t,r),m||y()))},e}(),R={CONTAIN:{wrapElement:function(e){var t=document.createElement("div");t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center";var r=document.createElement("div");return r.style.visibility="hidden",r.appendChild(e),t.appendChild(r),t},updateSize:function(e,t,r){var i=e.firstElementChild;e.style.width="".concat(t,"px"),e.style.height="".concat(r,"px");var n=[i.offsetWidth,i.offsetHeight],o=n[0],s=n[1],a=Math.min(t/o,r/s);i.style.transform="scale(".concat(a,")"),i.style.visibility="visible"}},COVER:{wrapElement:function(e){var t=document.createElement("div");t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center",t.style.overflow="hidden";var r=document.createElement("div");return r.style.visibility="hidden",r.appendChild(e),t.appendChild(r),t},updateSize:function(e,t,r){var i=e.firstElementChild;e.style.width="".concat(t,"px"),e.style.height="".concat(r,"px");var n=[i.offsetWidth,i.offsetHeight],o=n[0],s=n[1],a=Math.max(t/o,r/s);i.style.transform="scale(".concat(a,")"),i.style.visibility="visible"}},STRETCH:{wrapElement:function(e){var t=document.createElement("div");t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center";var r=document.createElement("div");return r.style.visibility="hidden",r.appendChild(e),t.appendChild(r),t},updateSize:function(e,t,r){var i=e.firstElementChild;e.style.width="".concat(t,"px"),e.style.height="".concat(r,"px");var n=[i.offsetWidth,i.offsetHeight],o=n[0],s=n[1];i.style.transform="scale(".concat(t/o,", ").concat(r/s,")"),i.style.visibility="visible"}},NONE:{wrapElement:function(e){return e},updateSize:function(e,t,r){e&&(e.style.width="".concat(t,"px"),e.style.height="".concat(r,"px"))}}},W=function(e){function t(t,r,i){var n=void 0===i?{}:i,o=n.captureOnPointerEnter,a=void 0===o||o,l=n.isCanvasOverlay,c=void 0!==l&&l,h=n.fitStrategy,d=void 0===h?R.NONE:h,u=e.call(this,r,t)||this;return u._enabled=!1,u._ready=!1,u._isCanvasOverlay=!1,u._requiresUpdate=!0,u._inverseScaleMatrix=null,u._captureOnPointerEnter=!0,u._pointerEventCaptureBehavior=null,u._sourceWidth=null,u._sourceHeight=null,u._fitStrategy=R.NONE,"undefined"==typeof document?(s.Logger.Warn("Creating an instance of an HtmlMesh with id ".concat(r," outside of a browser. The mesh will not be visible.")),u):(u._fitStrategy=d,u._isCanvasOverlay=c,u._createMask(),u._element=u._createElement(),u.setEnabled(!0),u._captureOnPointerEnter=a,u._pointerEventCaptureBehavior=new I(u.capturePointerEvents.bind(u),u.releasePointerEvents.bind(u),{captureOnPointerEnter:u._captureOnPointerEnter}),u.addBehavior(u._pointerEventCaptureBehavior),u)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}h(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(t,e),Object.defineProperty(t.prototype,"isHtmlMesh",{get:function(){return!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sourceWidth",{get:function(){return this._sourceWidth},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sourceHeight",{get:function(){return this._sourceHeight},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return this._width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this._height},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"element",{get:function(){return this._element},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"requiresUpdate",{get:function(){return this._requiresUpdate},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"captureOnPointerEnter",{set:function(e){this._captureOnPointerEnter=e,this._pointerEventCaptureBehavior&&(this._pointerEventCaptureBehavior.captureOnPointerEnter=e)},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){var t;e.prototype.dispose.call(this),null===(t=this._element)||void 0===t||t.remove(),this._element=void 0,this._pointerEventCaptureBehavior&&(this._pointerEventCaptureBehavior.dispose(),this._pointerEventCaptureBehavior=null)},t.prototype._markAsUpdated=function(){this._requiresUpdate=!1},t.prototype.setContent=function(e,t,r){this._setAsReady(!1),this._sourceWidth=null,this._sourceHeight=null,this._element&&(this._width=t,this._height=r,this._requiresUpdate=!0,this.scaling.setAll(1),e&&(this._element.appendChild(this._fitStrategy.wrapElement(e)),this._updateScaleIfNecessary()),this.sourceWidth&&this.sourceHeight&&this._setAsReady(!0))},t.prototype.setEnabled=function(e){this._enabled=e,e&&!this._ready||this._doSetEnabled(e)},t.prototype.setContentSizePx=function(e,t){this._sourceWidth=e,this._sourceHeight=t,this._element&&this._element.firstElementChild&&(this._fitStrategy.updateSize(this._element.firstElementChild,e,t),this._updateScaleIfNecessary(),this.width&&this.height&&this._setAsReady(!0))},t.prototype._setAsReady=function(e){this._ready=e,e?this._doSetEnabled(this._enabled):this._doSetEnabled(!1)},t.prototype._doSetEnabled=function(t){var r,i=this;this._element&&(t&&!this._worldMatrixUpdateObserver?this._worldMatrixUpdateObserver=this.onAfterWorldMatrixUpdateObservable.add((function(){i._requiresUpdate=!0})):t||(null===(r=this._worldMatrixUpdateObserver)||void 0===r||r.remove(),this._worldMatrixUpdateObserver=null),this._element.style.display=t?"":"none",this._setElementzIndex(-1e4*this.position.z),e.prototype.setEnabled.call(this,t))},t.prototype._updateScaleIfNecessary=function(){this.scaling.setAll(1),this._inverseScaleMatrix&&(this.bakeTransformIntoVertices(this._inverseScaleMatrix),this._inverseScaleMatrix=null);var e=this._width||1,t=this._height||1,r=s.Matrix.Scaling(e,t,1);this.bakeTransformIntoVertices(r),this._inverseScaleMatrix=new s.Matrix,r.invertToRef(this._inverseScaleMatrix)},t.prototype._createMask=function(){(0,s.CreatePlaneVertexData)({width:1,height:1}).applyToMesh(this);var e=this.getScene();this.checkCollisions=!0;var t=new s.StandardMaterial("".concat(this.id,"-mat"),e);this._isCanvasOverlay||(t.backFaceCulling=!1,t.disableColorWrite=!0,t.disableLighting=!0),this.material=t,this.material.freeze()},t.prototype._setElementzIndex=function(e){this._element&&(this._element.style.zIndex="".concat(e))},t.prototype.capturePointerEvents=function(){this._element&&(this._element.style.pointerEvents="auto",document.getElementsByTagName("body")[0].style.pointerEvents="none")},t.prototype.releasePointerEvents=function(){this._element&&(document.getElementsByTagName("body")[0].style.pointerEvents="auto",this._element.style.pointerEvents="none")},t.prototype._createElement=function(){if("undefined"!=typeof document){var e=document.createElement("div");return e.id=this.id,e.style.backgroundColor=this._isCanvasOverlay?"transparent":"#000",e.style.zIndex="1",e.style.position="absolute",e.style.pointerEvents="none",e.style.backfaceVisibility="hidden",e}},t}(s.Mesh);!function(e){e[e.SPACE=32]="SPACE",e[e.TOFU=65532]="TOFU"}(u||(u={}));var T=function(){function e(e,t,r){var i=this;this._chars=new Map,this._kernings=new Map,this._font=JSON.parse(e),this._font.pages=[t],this._font.chars.forEach((function(e){return i._chars.set(e.id,e)})),this._font.kernings.forEach((function(e){var t=i._kernings.get(e.first);t||(t=new Map,i._kernings.set(e.first,t)),t.set(e.second,e.amount)})),this._charsRegex=new RegExp("[".concat(this._font.chars.map((function(e){return e.char.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")})).join(""),"]"),"g"),this._updateFallbacks(),this.scale=1/this._font.info.size,this.textures=this._font.pages.map((function(e){var t=new s.Texture(e,r,{noMipmap:!1,invertY:!1});return t.anisotropicFilteringLevel=16,t}))}return e.prototype.dispose=function(){for(var e=0,t=this.textures;e<t.length;e++)t[e].dispose();this.textures.length=0},e.prototype._updateFallbacks=function(){this._chars.has(u.SPACE)||this._chars.set(u.SPACE,{id:u.SPACE,x:0,y:0,width:0,height:0,xoffset:0,yoffset:0,xadvance:.5*this._font.info.size,page:-1,chnl:-1,index:-1,char:" "}),this._chars.has(u.TOFU)||this._chars.set(u.TOFU,{id:u.TOFU,x:0,y:0,width:this._font.info.size,height:this._font.info.size,xoffset:0,yoffset:0,xadvance:.5*this._font.info.size,page:-1,chnl:-1,index:-1,char:"￿"})},e.prototype._getChar=function(e){return this._chars.get(e)||this._chars.get(u.TOFU)},e.prototype._getKerning=function(e,t){var r;return(null===(r=this._kernings.get(e))||void 0===r?void 0:r.get(t))||0},e.prototype._unsupportedChars=function(e){return e.replace(this._charsRegex,"")},e}(),D={maxWidth:1/0,lineHeight:1,letterSpacing:1,tabSize:4,whiteSpace:"pre-line",textAlign:"center",translate:{x:-.5,y:-.5}},k=function(){function e(e,t,r){this.text=e,this.fontAsset=t,this.options=d(d({},D),r);var i=this._computeMetrics(e),n=i.paragraph,o=i.lines,s=i.glyphs,a=i.width,l=i.height;this.paragraph=n,this.lines=o,this.glyphs=s,this.width=a,this.height=l}return Object.defineProperty(e.prototype,"lineHeight",{get:function(){return this.fontAsset._font.common.lineHeight*this.options.lineHeight},enumerable:!1,configurable:!0}),e.prototype._computeMetrics=function(e){for(var t=this,r=this._collapse(e),i=this._breakLines(r).map((function(e){return e.trim()})),n=[],o=0,s=i;o<s.length;o++){var a=s[o];n.push.apply(n,this._wrap(a,n.length))}var l=Math.max.apply(Math,n.map((function(e){return e.width}))),c=this.lineHeight*n.length;("left"!==this.options.textAlign||this.options.translate)&&n.forEach((function(e){for(var r=function(){switch(t.options.textAlign){case"right":return l-e.width;case"center":return(l-e.width)/2;default:return 0}}(),i=t.options.translate?t.options.translate.x*l:0,n=t.options.translate?t.options.translate.y*c:0,o=0,s=e.glyphs;o<s.length;o++){var a=s[o];a.x+=r,a.x+=i,a.y+=n}}));var h=n.flatMap((function(e){return e.glyphs}));return{paragraph:i.join("\n"),lines:n,glyphs:h,width:l,height:c}},e.prototype._breakLines=function(e){return e.split("\n")},e.prototype._collapse=function(e){return e.replace(/\t/g," ".repeat(this.options.tabSize)).replace(/ +/g," ")},e.prototype._wrap=function(e,t){void 0===t&&(t=0);for(var r,i=new Array,n=t,o=new Array,s=0,a=0,l=0,c=l,h=function(){i.push({text:e.slice(l,c),glyphs:o,start:l,end:c,width:a})};c<e.length;){var d=c,u=e.charCodeAt(d),f=this.fontAsset._getChar(u),p=f.width,v=(s+=r?this.fontAsset._getKerning(r.id,f.id):0)+p,m=f.xadvance+this.options.letterSpacing,_=s+m,g=_>this.options.maxWidth||v>this.options.maxWidth;g&&(h(),n++,r=void 0,s=0,a=0,c=(l=c)+1,o=[]);var y=s,x=n*this.lineHeight;o.push({char:f,line:n,position:o.length,x:y,y:x}),g?s=m:(r=f,s=_,a=v,c++)}return o.length>0&&h(),i},e}(),L=function(){function e(e,t,r){void 0===t&&(t=0),this._useVAO=!1,this._vertexBuffers={},this._charMatrices=new Array,this._charUvs=new Array,this._isDirty=!0,this._baseLine=0,this._scalingMatrix=new s.ThinMatrix,this._fontScaleMatrix=new s.ThinMatrix,this._offsetMatrix=new s.ThinMatrix,this._translationMatrix=new s.ThinMatrix,this._baseMatrix=new s.ThinMatrix,this._scaledMatrix=new s.ThinMatrix,this._localMatrix=new s.ThinMatrix,this._finalMatrix=new s.ThinMatrix,this._lineMatrix=new s.ThinMatrix,this._parentWorldMatrix=new s.ThinMatrix,this.color={r:1,g:1,b:1,a:1},this.strokeColor={r:1,g:1,b:1,a:1},this.strokeInsetWidth=0,this.strokeOutsetWidth=0,this.thicknessControl=0,this._parent=null,this._transformMatrix=new s.ThinMatrix,this.isBillboard=!1,this.isBillboardScreenProjected=!1,this.ignoreDepthBuffer=!1,this._engine=e,this._shaderLanguage=t,this._font=r,this._baseLine=r._font.common.lineHeight*r.scale,this._useVAO=e.getCaps().vertexArrayObject&&!e.disableVertexArrayObjects;var i=new Float32Array([0,0,1,0,0,1,1,1]);this._spriteBuffer=new s.Buffer(e,i,!1,2),this._vertexBuffers.offsets=this._spriteBuffer.createVertexBuffer("offsets",0,2),this._resizeBuffers(128)}return Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},set:function(e){this._parent=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transformMatrix",{get:function(){return this._transformMatrix},set:function(e){this._transformMatrix=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"characterCount",{get:function(){return this._charMatrices.length/16},enumerable:!1,configurable:!0}),e.prototype._resizeBuffers=function(e){this._worldBuffer&&(this._worldBuffer.dispose(),this._worldBuffer=null),this._uvBuffer&&(this._uvBuffer.dispose(),this._uvBuffer=null),this._worldBuffer=new s.Buffer(this._engine,new Float32Array(16*e),!0,16),this._vertexBuffers.world0=this._worldBuffer.createVertexBuffer("world0",0,4,16,!0),this._vertexBuffers.world1=this._worldBuffer.createVertexBuffer("world1",4,4,16,!0),this._vertexBuffers.world2=this._worldBuffer.createVertexBuffer("world2",8,4,16,!0),this._vertexBuffers.world3=this._worldBuffer.createVertexBuffer("world3",12,4,16,!0),this._uvBuffer=new s.Buffer(this._engine,new Float32Array(4*e),!0,4),this._vertexBuffers.uvs=this._uvBuffer.createVertexBuffer("uvs",0,4,4,!0)},e.prototype._setShaders=function(e,t){var r;null===(r=this._drawWrapperBase)||void 0===r||r.dispose(),this._drawWrapperBase=new s.DrawWrapper(this._engine),this._drawWrapperBase.drawContext&&(this._drawWrapperBase.drawContext.useInstancing=!0),this._drawWrapperBase.effect=this._engine.createEffect({vertexSource:e,fragmentSource:t},["offsets","world0","world1","world2","world3","uvs"],["parentWorld","view","projection","uColor","thickness","uStrokeColor","uStrokeInsetWidth","uStrokeOutsetWidth","mode","transform"],["fontAtlas"],"",void 0,void 0,void 0,void 0,this._shaderLanguage),this._drawWrapperBase.effect._refCount++},e.prototype.addParagraph=function(e,t,r){var i=this,n=new k(e,this._font,t),o=this._font.scale,a=this._font._font.common.scaleW,l=this._font._font.common.scaleH,c=n.glyphs.filter((function(e){return e.char.page>=0})),h=r;if(!h){var d=n.lineHeight*o,u=n.lines.length*d/2;(0,s.TranslationMatrixToRef)(0,this._baseLine-u,0,this._lineMatrix),h=this._lineMatrix}(0,s.ScalingMatrixToRef)(o,o,1,this._fontScaleMatrix),(0,s.TranslationMatrixToRef)(.5,-.5,0,this._offsetMatrix);var f=this._charUvs.length,p=this._charMatrices.length;c.forEach((function(e,t){i._charUvs[f+4*t+0]=e.char.x/a,i._charUvs[f+4*t+1]=e.char.y/l,i._charUvs[f+4*t+2]=e.char.width/a,i._charUvs[f+4*t+3]=e.char.height/l;var r=e.x+e.char.xoffset,n=1-(e.y+e.char.yoffset);(0,s.ScalingMatrixToRef)(e.char.width,e.char.height,1,i._scalingMatrix),(0,s.MultiplyMatricesToRef)(i._offsetMatrix,i._scalingMatrix,i._baseMatrix),(0,s.TranslationMatrixToRef)(r*o,n*o,0,i._translationMatrix),(0,s.MultiplyMatricesToRef)(i._baseMatrix,i._fontScaleMatrix,i._scaledMatrix),(0,s.MultiplyMatricesToRef)(i._scaledMatrix,i._translationMatrix,i._localMatrix),(0,s.MultiplyMatricesToRef)(i._localMatrix,h,i._finalMatrix),(0,s.CopyMatrixToArray)(i._finalMatrix,i._charMatrices,p+16*t)})),this._isDirty=!0,this._baseLine-=n.lineHeight*o*n.lines.length},e.prototype.render=function(e,t){var r=this._drawWrapperBase,i=r.effect;if(i.isReady()){var n=this._engine;n.setState(!1),n.enableEffect(r),this.ignoreDepthBuffer&&n.setDepthBuffer(!1),this._parent?(0,s.CopyMatrixToRef)(this._parent.getWorldMatrix(),this._parentWorldMatrix):(0,s.IdentityMatrixToRef)(this._parentWorldMatrix),i.setInt("mode",this.isBillboard?this.isBillboardScreenProjected?2:1:0),i.setMatrix("parentWorld",this._parentWorldMatrix),i.setMatrix("view",e),i.setMatrix("projection",t),i.setMatrix("transform",this.transformMatrix),i.setTexture("fontAtlas",this._font.textures[0]),i.setDirectColor4("uColor",this.color),i.setDirectColor4("uStrokeColor",this.strokeColor),i.setFloat("thickness",.9*this.thicknessControl),i.setFloat("uStrokeInsetWidth",this.strokeInsetWidth),i.setFloat("uStrokeOutsetWidth",this.strokeOutsetWidth);var o=this._charMatrices.length/16;this._isDirty&&(this._isDirty=!1,this._worldBuffer.getBuffer().capacity/4<16*o&&this._resizeBuffers(o),this._worldBuffer.update(this._charMatrices),this._uvBuffer.update(this._charUvs)),this._useVAO?(this._vertexArrayObject||(this._vertexArrayObject=n.recordVertexArrayObject(this._vertexBuffers,null,i)),n.bindVertexArrayObject(this._vertexArrayObject,null)):n.bindBuffers(this._vertexBuffers,null,i),n.setAlphaMode(s.Constants.ALPHA_COMBINE),n.drawArraysType(s.Constants.MATERIAL_TriangleStripDrawMode,0,4,o),n.unbindInstanceAttributes(),n.setAlphaMode(s.Constants.ALPHA_DISABLE),this.ignoreDepthBuffer&&n.setDepthBuffer(!0)}},e.prototype.dispose=function(){this._worldBuffer&&(this._worldBuffer.dispose(),this._worldBuffer=null),this._uvBuffer&&(this._uvBuffer.dispose(),this._uvBuffer=null),this._spriteBuffer&&(this._spriteBuffer.dispose(),this._spriteBuffer=null),this._vertexArrayObject&&(this._engine.releaseVertexArrayObject(this._vertexArrayObject),this._vertexArrayObject=null)},e.CreateTextRendererAsync=function(t,r){return n=this,o=void 0,a=function(){var n,o,s,a;return function(e,t){var r,i,n,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(l){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(r=1,i&&(n=2&a[0]?i.return:a[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,a[1])).done)return n;switch(i=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,i=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((n=(n=o.trys).length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){o.label=a[1];break}if(6===a[0]&&o.label<n[1]){o.label=n[1],n=a;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(a);break}n[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],i=0}finally{r=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,l])}}}(this,(function(l){switch(l.label){case 0:if(!r.getCaps().instancedArrays||!r._features.supportSpriteInstancing)throw new Error("Instanced arrays are required for MSDF text rendering.");return n=0,o="",s="",r.isWebGPU?(n=1,[4,Promise.resolve().then(i.bind(i,681))]):[3,3];case 1:return o=l.sent().msdfVertexShaderWGSL.shader,[4,Promise.resolve().then(i.bind(i,115))];case 2:return s=l.sent().msdfPixelShaderWGSL.shader,[3,6];case 3:return[4,Promise.resolve().then(i.bind(i,36))];case 4:return o=l.sent().msdfVertexShader.shader,[4,Promise.resolve().then(i.bind(i,370))];case 5:s=l.sent().msdfPixelShader.shader,l.label=6;case 6:return(a=new e(r,n,t))._setShaders(o,s),[2,a]}}))},new((s=void 0)||(s=Promise))((function(e,t){function r(e){try{l(a.next(e))}catch(e){t(e)}}function i(e){try{l(a.throw(e))}catch(e){t(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof s?n:new s((function(e){e(n)}))).then(r,i)}l((a=a.apply(n,o||[])).next())}));var n,o,s,a},e}(),j=i(36),z=i(370),V=i(681),U=i(115);const F=o;return n.default})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-addons",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-addons"]=t(require("babylonjs")):e.ADDONS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(e=>(()=>{"use strict";var t={36:(e,t,r)=>{r.r(t),r.d(t,{msdfVertexShader:()=>s});var i=r(597),n="msdfVertexShader",o="#define BILLBOARD 1\n#define BILLBOARDSCREENPROJECTED 2\nattribute vec2 offsets;attribute vec4 world0;attribute vec4 world1;attribute vec4 world2;attribute vec4 world3;attribute vec4 uvs;uniform mat4 transform;uniform mat4 parentWorld;uniform mat4 view;uniform mat4 projection;uniform vec3 center;uniform int mode;varying vec2 atlasUV;void main(void) {mat4 world=mat4(world0,world1,world2,world3);vec4 worldPos=transform*(world*vec4(offsets.xy-vec2(0.5,0.5),0.,1.0));if (mode>=BILLBOARD) {vec3 viewPos=(view*parentWorld*vec4(0.,0.,0.,1.0)).xyz; \nif (mode==BILLBOARDSCREENPROJECTED) {viewPos.x/=viewPos.z;viewPos.y/=viewPos.z;viewPos.z=1.0;}\ngl_Position=projection*vec4(viewPos+worldPos.xyz,1.0); } else {vec3 viewPos=(view*parentWorld*worldPos).xyz; \ngl_Position=projection*vec4(viewPos,1.0); }\natlasUV=vec2(uvs.x+offsets.x*uvs.z,uvs.y+(1.0-offsets.y)*uvs.w);}";i.ShaderStore.ShadersStore[n]||(i.ShaderStore.ShadersStore[n]=o);var s={name:n,shader:o}},115:(e,t,r)=>{r.r(t),r.d(t,{msdfPixelShaderWGSL:()=>s});var i=r(597),n="msdfPixelShader",o="var fontAtlas: texture_2d<f32>;var fontAtlasSampler: sampler;uniform uColor: vec4f;uniform thickness: f32;uniform uStrokeColor: vec4f;uniform uStrokeInsetWidth: f32;uniform uStrokeOutsetWidth: f32;varying atlasUV: vec2f;fn median(msdf: vec3<f32>)->f32 {let a=min(msdf.r,msdf.g);let b=max(msdf.r,msdf.g);return max(a,min(b,msdf.b));}\n@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {let s=textureSample(fontAtlas,fontAtlasSampler,input.atlasUV).rgb;let sigDist=median(s)-0.5+uniforms.thickness;let afwidth=length(vec2<f32>(dpdx(sigDist),dpdy(sigDist)));let alpha=clamp(sigDist/afwidth+0.5,0.0,1.0);let sigDistOutset=sigDist+uniforms.uStrokeOutsetWidth*0.5;let sigDistInset=sigDist-uniforms.uStrokeInsetWidth*0.5;let afwidthOutset=length(vec2<f32>(dpdx(sigDistOutset),dpdy(sigDistOutset)));let afwidthInset=length(vec2<f32>(dpdx(sigDistInset),dpdy(sigDistInset)));let outset=clamp(sigDistOutset/afwidthOutset+0.5,0.0,1.0);let inset=1.0-clamp(sigDistInset/afwidthInset+0.5,0.0,1.0);let border=outset*inset;let filledFragColor=vec4<f32>(uniforms.uColor.rgb,alpha*uniforms.uColor.a);let strokedFragColor=vec4<f32>(uniforms.uStrokeColor.rgb,border*uniforms.uStrokeColor.a);fragmentOutputs.color=mix(filledFragColor,strokedFragColor,border);}";i.ShaderStore.ShadersStoreWGSL[n]||(i.ShaderStore.ShadersStoreWGSL[n]=o);var s={name:n,shader:o}},370:(e,t,r)=>{r.r(t),r.d(t,{msdfPixelShader:()=>s});var i=r(597),n="msdfPixelShader",o="#extension GL_OES_standard_derivatives : enable\nprecision highp float;uniform sampler2D fontAtlas;uniform vec4 uColor;uniform vec4 uStrokeColor;uniform float uStrokeInsetWidth;uniform float uStrokeOutsetWidth;uniform float thickness;varying vec2 atlasUV;float median(vec3 msdf) {return max(min(msdf.r,msdf.g),min(max(msdf.r,msdf.g),msdf.b));}\nvoid main(void)\n{vec3 s=texture2D(fontAtlas,atlasUV).rgb;float sigDist=median(s)-0.5+thickness;float alpha=clamp(sigDist/fwidth(sigDist)+0.5,0.0,1.0);float sigDistOutset=sigDist+uStrokeOutsetWidth*0.5;float sigDistInset=sigDist-uStrokeInsetWidth*0.5;float outset=clamp(sigDistOutset/fwidth(sigDistOutset)+0.5,0.0,1.0);float inset=1.0-clamp(sigDistInset/fwidth(sigDistInset)+0.5,0.0,1.0);float border=outset*inset;vec4 filledFragColor=vec4(uColor.rgb,alpha*uColor.a);vec4 strokedFragColor=vec4(uStrokeColor.rgb,border*uStrokeColor.a);gl_FragColor=mix(filledFragColor,strokedFragColor,border);}";i.ShaderStore.ShadersStore[n]||(i.ShaderStore.ShadersStore[n]=o);var s={name:n,shader:o}},597:t=>{t.exports=e},681:(e,t,r)=>{r.r(t),r.d(t,{msdfVertexShaderWGSL:()=>s});var i=r(597),n="msdfVertexShader",o="#define BILLBOARD 1\n#define BILLBOARDSCREENPROJECTED 2\nattribute offsets: vec2f;attribute world0: vec4f;attribute world1: vec4f;attribute world2: vec4f;attribute world3: vec4f;attribute uvs: vec4f;uniform transform: mat4x4f;uniform parentWorld: mat4x4f;uniform view: mat4x4f;uniform projection: mat4x4f;uniform mode: u32;varying atlasUV: vec2f;@vertex\nfn main(input: VertexInputs)->FragmentInputs {let world=mat4x4<f32>(input.world0,input.world1,input.world2,input.world3);let localOffset=vec4<f32>(input.offsets-vec2<f32>(0.5,0.5),0.0,1.0);let worldPos=uniforms.transform*world*localOffset;if (uniforms.mode>=BILLBOARD) { \nvar viewPos=(uniforms.view*uniforms.parentWorld*vec4f(0.,0.,0.,1.0)).xyz;if (uniforms.mode==BILLBOARDSCREENPROJECTED) {viewPos=vec3f(viewPos.x/viewPos.z,viewPos.y/viewPos.z,1.0);} \nvertexOutputs.position=uniforms.projection*vec4<f32>(viewPos+worldPos.xyz,1.0);} else { \nlet viewPos=(uniforms.view*uniforms.parentWorld*worldPos).xyz;vertexOutputs.position=uniforms.projection*vec4<f32>(viewPos,1.0);}\nvertexOutputs.atlasUV=vec2<f32>(\ninput.uvs.x+input.offsets.x*input.uvs.z,\ninput.uvs.y+(1.0-input.offsets.y)*input.uvs.w\n);}";i.ShaderStore.ShadersStoreWGSL[n]||(i.ShaderStore.ShadersStoreWGSL[n]=o);var s={name:n,shader:o}}},r={};function i(e){var n=r[e];if(void 0!==n)return n.exports;var o=r[e]={exports:{}};return t[e](o,o.exports,i),o.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};i.d(n,{default:()=>F});var o={};i.r(o),i.d(o,{DefaultParagraphOptions:()=>D,FitStrategy:()=>R,FontAsset:()=>T,HtmlMesh:()=>W,HtmlMeshRenderer:()=>c,PointerEventsCaptureBehavior:()=>I,SdfTextParagraph:()=>k,TextRenderer:()=>L,msdfPixelShader:()=>z.msdfPixelShader,msdfPixelShaderWGSL:()=>U.msdfPixelShaderWGSL,msdfVertexShader:()=>j.msdfVertexShader,msdfVertexShaderWGSL:()=>V.msdfVertexShaderWGSL});var s=i(597),a=100,l=function(e){return function(t,r){var i=t.getMesh(),n=r.getMesh(),o=i.isHtmlMesh,s=n.isHtmlMesh;return o?s&&i.absolutePosition.z<=n.absolutePosition.z?1:-1:s?1:e(t,r)}},c=function(){function e(e,t){var r=void 0===t?{}:t,i=r.parentContainerId,n=void 0===i?null:i,o=r._containerId,a=void 0===o?"css-container":o,l=r.enableOverlayRender,c=void 0===l||l,h=r.defaultOpaqueRenderOrder,d=void 0===h?s.RenderingGroup.PainterSortCompare:h,u=r.defaultAlphaTestRenderOrder,f=void 0===u?s.RenderingGroup.PainterSortCompare:u,p=r.defaultTransparentRenderOrder,v=void 0===p?s.RenderingGroup.defaultTransparentSortCompare:p,m=this;this._cache={cameraData:{fov:0,position:new s.Vector3,style:""},htmlMeshData:new WeakMap},this._width=0,this._height=0,this._heightHalf=0,this._temp={scaleTransform:new s.Vector3,rotationTransform:new s.Quaternion,positionTransform:new s.Vector3,objectMatrix:s.Matrix.Identity(),cameraWorldMatrix:s.Matrix.Identity(),cameraRotationMatrix:s.Matrix.Identity(),cameraWorldMatrixAsArray:new Array(16)},this._lastDevicePixelRatio=window.devicePixelRatio,this._cameraMatrixUpdated=!0,this._previousCanvasDocumentPosition={top:0,left:0},this._renderObserver=null,this._onCameraMatrixChanged=function(e){m._cameraWorldMatrix=e.getWorldMatrix(),m._cameraMatrixUpdated=!0},"undefined"!=typeof document&&(this._containerId=a,this._init(e,n,c,d,f,v))}return e.prototype.dispose=function(){var e,t;this._renderObserver&&(this._renderObserver.remove(),this._renderObserver=null),null===(e=this._overlayElements)||void 0===e||e.container.remove(),this._overlayElements=null,null===(t=this._inSceneElements)||void 0===t||t.container.remove(),this._inSceneElements=null},e.prototype._init=function(e,t,r,i,n,o){var s,a=this;if("undefined"!=typeof document){var c=t?document.getElementById(t):document.body;c||(c=document.body);var h="".concat(this._containerId,"_in_scene");if(this._inSceneElements=this._createRenderLayerElements(h),c.insertBefore(this._inSceneElements.container,c.firstChild),r){var d="".concat(this._containerId,"_overlay");this._overlayElements=this._createRenderLayerElements(d);var u=+(null!==(s=e.getEngine().getRenderingCanvas().style.zIndex)&&void 0!==s?s:"0")+1;this._overlayElements.container.style.zIndex="".concat(u),this._overlayElements.container.style.pointerEvents="none",c.insertBefore(this._overlayElements.container,c.firstChild)}this._engine=e.getEngine();var f,p,v=this._engine.getRenderingCanvasClientRect();if(!v)throw new Error("Failed to get client rect for rendering canvas");this._setSize(v.width,v.height),this._engine.onResizeObservable.add((function(){var e=a._engine.getRenderingCanvasClientRect();e&&a._setSize(e.width,e.height)}));var m=function(){var t=e.activeCamera;t&&(f=t.onProjectionMatrixChangedObservable.add((function(){a._onCameraMatrixChanged(t)})),p=t.onViewMatrixChangedObservable.add((function(){a._onCameraMatrixChanged(t)})))};m(),e.onActiveCameraChanged.add((function(){var t,r;f&&(null===(t=e.activeCamera)||void 0===t||t.onProjectionMatrixChangedObservable.remove(f)),p&&(null===(r=e.activeCamera)||void 0===r||r.onViewMatrixChangedObservable.remove(p)),m()}));var _=l(i),g=l(n),y=l(o);e.setRenderingOrder(0,_,g,y),this._renderObserver=e.onBeforeRenderObservable.add((function(){a._render(e,e.activeCamera)}))}},e.prototype._createRenderLayerElements=function(e){var t=document.getElementById(e);t&&t.remove();var r=document.createElement("div");r.id=e,r.style.position="absolute",r.style.width="100%",r.style.height="100%",r.style.zIndex="-1";var i=document.createElement("div");i.style.overflow="hidden";var n=document.createElement("div");return n.style.webkitTransformStyle="preserve-3d",n.style.transformStyle="preserve-3d",n.style.pointerEvents="none",i.appendChild(n),r.appendChild(i),{container:r,domElement:i,cameraElement:n}},e.prototype._getSize=function(){return{width:this._width,height:this._height}},e.prototype._setSize=function(e,t){if(this._width=e,this._height=t,this._heightHalf=this._height/2,this._inSceneElements&&this._overlayElements)for(var r=0,i=[this._inSceneElements.domElement,this._overlayElements.domElement,this._inSceneElements.cameraElement,this._overlayElements.cameraElement];r<i.length;r++){var n=i[r];n&&(n.style.width="".concat(e,"px"),n.style.height="".concat(t,"px"))}},e.prototype._getCameraCssMatrix=function(e){var t=e.m;return"matrix3d(".concat(this._epsilon(t[0]),",").concat(this._epsilon(-t[1]),",").concat(this._epsilon(t[2]),",").concat(this._epsilon(t[3]),",").concat(this._epsilon(t[4]),",").concat(this._epsilon(-t[5]),",").concat(this._epsilon(t[6]),",").concat(this._epsilon(t[7]),",").concat(this._epsilon(t[8]),",").concat(this._epsilon(-t[9]),",").concat(this._epsilon(t[10]),",").concat(this._epsilon(t[11]),",").concat(this._epsilon(t[12]),",").concat(this._epsilon(-t[13]),",").concat(this._epsilon(t[14]),",").concat(this._epsilon(t[15]),")")},e.prototype._getHtmlContentCssMatrix=function(e,t){var r=e.m,i=t?-1:1;return"matrix3d(".concat(this._epsilon(r[0]),",").concat(this._epsilon(r[1]),",").concat(this._epsilon(r[2]*-i),",").concat(this._epsilon(r[3]),",").concat(this._epsilon(-r[4]),",").concat(this._epsilon(-r[5]),",").concat(this._epsilon(r[6]*i),",").concat(this._epsilon(-r[7]),",").concat(this._epsilon(r[8]*-i),",").concat(this._epsilon(r[9]*-i),",").concat(this._epsilon(r[10]),",").concat(this._epsilon(r[11]*i),",").concat(this._epsilon(r[12]*i),",").concat(this._epsilon(r[13]*i),",").concat(this._epsilon(r[14]*i),",").concat(this._epsilon(r[15]),")")},e.prototype._getTransformationMatrix=function(e,t){var r;if(this._cameraWorldMatrix||(this._cameraWorldMatrix=null===(r=e.getScene().activeCamera)||void 0===r?void 0:r.getWorldMatrix()),!this._cameraWorldMatrix)return s.Matrix.Identity();var i=e.getWorldMatrix(),n=1,o=1;e.sourceWidth&&e.sourceHeight&&(n=e.width/(e.sourceWidth/a),o=e.height/(e.sourceHeight/a));var l=this._temp.scaleTransform,c=this._temp.rotationTransform,h=this._temp.positionTransform,d=this._temp.objectMatrix;i.decompose(l,c,h),l.x*=n,l.y*=o,s.Matrix.ComposeToRef(l,c,h,d);var u=t?-1:1,f=e.getAbsolutePosition();return d.setRowFromFloats(3,(-this._cameraWorldMatrix.m[12]+f.x)*a*u,(-this._cameraWorldMatrix.m[13]+f.y)*a*u,(this._cameraWorldMatrix.m[14]-f.z)*a,1e-5*this._cameraWorldMatrix.m[15]*a),d.multiplyAtIndex(3,a),d.multiplyAtIndex(7,a),d.multiplyAtIndex(11,a),d},e.prototype._renderHtmlMesh=function(e,t){var r,i;if(e.element&&e.element.firstElementChild){var n=this._cache.htmlMeshData.get(e);n||(n={style:""},this._cache.htmlMeshData.set(e,n));var o=e._isCanvasOverlay?null===(r=this._overlayElements)||void 0===r?void 0:r.cameraElement:null===(i=this._inSceneElements)||void 0===i?void 0:i.cameraElement;e.element.parentNode!==o&&o.appendChild(e.element),e.requiresUpdate&&this._updateBaseScaleFactor(e);var a=this._getTransformationMatrix(e,t),l="translate(-50%, -50%) ".concat(this._getHtmlContentCssMatrix(a,t));l+="".concat(t?"matrix3d(".concat(e.billboardMode!==s.TransformNode.BILLBOARDMODE_NONE?1:-1,", 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1)"):""),n.style!==l&&(e.element.style.webkitTransform=l,e.element.style.transform=l),e._markAsUpdated()}},e.prototype._render=function(e,t){var r,i,n,o,a=!1,l=e.useRightHandedSystem;this._updateContainerPositionIfNeeded(),this._cameraMatrixUpdated&&(this._cameraMatrixUpdated=!1,a=!0),t.position.x===this._cache.cameraData.position.x&&t.position.y===this._cache.cameraData.position.y&&t.position.z===this._cache.cameraData.position.z||(this._cache.cameraData.position.copyFrom(t.position),a=!0),window.devicePixelRatio!==this._lastDevicePixelRatio&&(this._lastDevicePixelRatio=window.devicePixelRatio,s.Logger.Log("In render - dpr changed: ",this._lastDevicePixelRatio),a=!0);var c=e.meshes.filter((function(e){return e.isHtmlMesh&&(a||e.requiresUpdate)}));if(a=a||c.length>0){var h=t.getProjectionMatrix().m[5]*this._heightHalf;if(this._cache.cameraData.fov!==h){var d=[null===(r=this._overlayElements)||void 0===r?void 0:r.domElement,null===(i=this._inSceneElements)||void 0===i?void 0:i.domElement];if(t.mode==s.Camera.PERSPECTIVE_CAMERA)for(var u=0,f=d;u<f.length;u++)(M=f[u])&&(M.style.webkitPerspective=h+"px",M.style.perspective=h+"px");else for(var p=0,v=d;p<v.length;p++)(M=v[p])&&(M.style.webkitPerspective="",M.style.perspective="");this._cache.cameraData.fov=h}null===t.parent&&t.computeWorldMatrix();var m=this._temp.cameraWorldMatrix;m.copyFrom(t.getWorldMatrix());var _=this._temp.cameraRotationMatrix;m.getRotationMatrix().transposeToRef(_);var g=this._temp.cameraWorldMatrixAsArray;m.copyToArray(g);var y=l?1:-1;g[1]=_.m[1],g[2]=_.m[2]*y,g[4]=_.m[4]*y,g[6]=_.m[6]*y,g[8]=_.m[8]*y,g[9]=_.m[9]*y,s.Matrix.FromArrayToRef(g,0,m);var x=this._getCameraCssMatrix(m);if(this._cache.cameraData.style!==x){for(var b=0,w=d=[null===(n=this._inSceneElements)||void 0===n?void 0:n.cameraElement,null===(o=this._overlayElements)||void 0===o?void 0:o.cameraElement];b<w.length;b++){var M;(M=w[b])&&(M.style.webkitTransform=x,M.style.transform=x)}this._cache.cameraData.style=x}for(var S=0,E=c;S<E.length;S++){var C=E[S];this._renderHtmlMesh(C,l)}}},e.prototype._updateBaseScaleFactor=function(e){var t=this._width,r=this._height,i=(e.width||1)/(e.height||1);i>t/r?t=r*i:r=t/i,e.setContentSizePx(t,r)},e.prototype._updateContainerPositionIfNeeded=function(){var e,t,r=this._engine.getRenderingCanvasClientRect();if(r){var i=window.scrollY,n=window.scrollX,o=r.top+i,a=r.left+n;if(this._previousCanvasDocumentPosition.top!==o||this._previousCanvasDocumentPosition.left!==a){this._previousCanvasDocumentPosition.top=o,this._previousCanvasDocumentPosition.left=a;for(var l=0,c=[null===(e=this._inSceneElements)||void 0===e?void 0:e.container,null===(t=this._overlayElements)||void 0===t?void 0:t.container];l<c.length;l++){var h=c[l];if(h){var d=h.offsetParent,u=d.getBoundingClientRect(),f=u.top+i,p=u.left+n,v=this._getAncestorMarginsAndPadding(d),m=window.getComputedStyle(document.body),_=parseInt(m.marginTop,10),g=parseInt(m.marginLeft,10);h.style.top="".concat(o-f-v.marginTop+v.paddingTop+_,"px"),h.style.left="".concat(a-p-v.marginLeft+v.paddingLeft+g,"px")}}}}else s.Logger.Warn("Failed to update html mesh renderer position due to failure to get canvas rect. HtmlMesh instances may not render correctly")},e.prototype._epsilon=function(e){return Math.abs(e)<1e-10?0:e},e.prototype._getAncestorMarginsAndPadding=function(e){for(var t=0,r=0,i=0,n=0;e&&e!==document.body&&e!==document.documentElement;){var o=window.getComputedStyle(e);t+=parseInt(o.marginTop,10),r+=parseInt(o.marginLeft,10),i+=parseInt(o.paddingTop,10),n+=parseInt(o.paddingLeft,10),e=e.offsetParent}return{marginTop:t,marginLeft:r,paddingTop:i,paddingLeft:n}},e}(),h=function(e,t){return h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},h(e,t)};var d=function(){return d=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},d.apply(this,arguments)};Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var u,f=[],p=new Map,v=[],m=null,_=function(e){M("In pointerEventsCapture.requestRelease - Pointer events release requested for ".concat(e)),e&&e!==m?g(e)?p.delete(e):(M("In pointerEventsCapture.requestRelease - Received release request ".concat(e," but no matching capture request was received")),v.includes(e)||v.push(e)):y()},g=function(e){var t=!1;return f=f.filter((function(r){return r!==e||(t=!0,M("In pointerEventsCapture.cancelRequest - Canceling pointer events capture request ".concat(e)),!1)})),t},y=function(){var e=w();M("In pointerEventsCapture.transferPointerEventsOwnership - Transferrring pointer events from ".concat(m," to ").concat(e)),x(),e&&b(e)},x=function(){var e;M("In pointerEventsCapture.doRelease - Releasing pointer events from ".concat(m)),m&&(null===(e=p.get(m))||void 0===e||e.release(),p.delete(m),m=null)},b=function(e){var t;e&&(null===(t=p.get(e))||void 0===t||t.capture()),m=e,M("In pointerEventsCapture.doCapture - Pointer events now captured by ".concat(e))},w=function(){return f.length>0?f.shift():null},M=function(e){("undefined"==typeof window||window["pointer-events-capture-debug"])&&s.Tools.Log("".concat(performance.now()," - game.scene.pointerEvents - ").concat(e,"\ncurrentOwner: ").concat(m,"\nqueue: ").concat(f,"\nunmatched: ").concat(v))},S=null,E=0,C=new WeakMap,O=function(e){"undefined"!=typeof document&&(0===E&&(document.addEventListener("pointermove",A),document.addEventListener("touchstart",A),S=null!=S?S:e,s.Logger.Log("PointerEventsCaptureBehavior: Starting observation of pointer move events."),S.onDisposeObservable.add(P)),E++)},P=function(){document.removeEventListener("pointermove",A),document.removeEventListener("touchstart",A),S=null,s.Logger.Log("PointerEventsCaptureBehavior: Stopping observation of pointer move events."),E=0},B=function(){"undefined"!=typeof document&&S&&--E<=0&&P()},A=function(e){if(S){var t=S.getEngine().getRenderingCanvasClientRect();if(t){var r,i="touches"in e?e.touches[0]:e,n=i.clientX,o=i.clientY,s=n-t.left,a=o-t.top,l=S.pick(s,a,(function(e){var t=C.get(e);return e.isEnabled()&&void 0!==t&&t._captureOnPointerEnter}));r=l.hit?l.pickedMesh:null;var c=parseInt(m||"");r&&r.uniqueId===c||(!c||r&&r.uniqueId===c||_(m),r&&C.get(r).capturePointerEvents())}}},I=function(){function e(e,t,r){var i=(void 0===r?{}:r).captureOnPointerEnter,n=void 0===i||i;this._captureCallback=e,this._releaseCallback=t,this.name="PointerEventsCaptureBehavior",this._attachedMesh=null,this._captureOnPointerEnter=n,"undefined"==typeof document&&s.Logger.Warn("Creating an instance of PointerEventsCaptureBehavior outside of a browser. The behavior will not work.")}return Object.defineProperty(e.prototype,"attachedMesh",{get:function(){return this._attachedMesh},set:function(e){this._attachedMesh=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"captureOnPointerEnter",{set:function(e){this._captureOnPointerEnter!==e&&(this._captureOnPointerEnter=e,this._attachedMesh&&(this._captureOnPointerEnter?O(this._attachedMesh.getScene()):B()))},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){this.attachedMesh=e,C.set(e,this),this._captureOnPointerEnter&&O(e.getScene())},e.prototype.detach=function(){this.attachedMesh&&(C.delete(this.attachedMesh),this._captureOnPointerEnter&&B(),this.attachedMesh=null)},e.prototype.dispose=function(){this.detach()},e.prototype.releasePointerEvents=function(){this.attachedMesh&&_(this.attachedMesh.uniqueId.toString())},e.prototype.capturePointerEvents=function(){var e,t,r;this.attachedMesh&&(e=this.attachedMesh.uniqueId.toString(),t=this._captureCallback,r=this._releaseCallback,M("In pointerEventsCapture.requestCapture - Pointer events capture requested for ".concat(e)),function(e){var t=!1;return v=v.filter((function(r){return r!==e||(t=!0,!1)})),t}(e)?M("In pointerEventsCapture.requestCapture - Capture request matched previous release request ".concat(e,". Cancelling capture request")):(e!==m&&function(e,t,r){M("In pointerEventsCapture.enqueueCaptureRequest - Enqueueing capture request for ".concat(e)),f.includes(e)||(f.push(e),p.set(e,{capture:t,release:r}))}(e,t,r),m||y()))},e}(),R={CONTAIN:{wrapElement:function(e){var t=document.createElement("div");t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center";var r=document.createElement("div");return r.style.visibility="hidden",r.appendChild(e),t.appendChild(r),t},updateSize:function(e,t,r){var i=e.firstElementChild;e.style.width="".concat(t,"px"),e.style.height="".concat(r,"px");var n=[i.offsetWidth,i.offsetHeight],o=n[0],s=n[1],a=Math.min(t/o,r/s);i.style.transform="scale(".concat(a,")"),i.style.visibility="visible"}},COVER:{wrapElement:function(e){var t=document.createElement("div");t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center",t.style.overflow="hidden";var r=document.createElement("div");return r.style.visibility="hidden",r.appendChild(e),t.appendChild(r),t},updateSize:function(e,t,r){var i=e.firstElementChild;e.style.width="".concat(t,"px"),e.style.height="".concat(r,"px");var n=[i.offsetWidth,i.offsetHeight],o=n[0],s=n[1],a=Math.max(t/o,r/s);i.style.transform="scale(".concat(a,")"),i.style.visibility="visible"}},STRETCH:{wrapElement:function(e){var t=document.createElement("div");t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center";var r=document.createElement("div");return r.style.visibility="hidden",r.appendChild(e),t.appendChild(r),t},updateSize:function(e,t,r){var i=e.firstElementChild;e.style.width="".concat(t,"px"),e.style.height="".concat(r,"px");var n=[i.offsetWidth,i.offsetHeight],o=n[0],s=n[1];i.style.transform="scale(".concat(t/o,", ").concat(r/s,")"),i.style.visibility="visible"}},NONE:{wrapElement:function(e){return e},updateSize:function(e,t,r){e&&(e.style.width="".concat(t,"px"),e.style.height="".concat(r,"px"))}}},W=function(e){function t(t,r,i){var n=void 0===i?{}:i,o=n.captureOnPointerEnter,a=void 0===o||o,l=n.isCanvasOverlay,c=void 0!==l&&l,h=n.fitStrategy,d=void 0===h?R.NONE:h,u=e.call(this,r,t)||this;return u._enabled=!1,u._ready=!1,u._isCanvasOverlay=!1,u._requiresUpdate=!0,u._inverseScaleMatrix=null,u._captureOnPointerEnter=!0,u._pointerEventCaptureBehavior=null,u._sourceWidth=null,u._sourceHeight=null,u._fitStrategy=R.NONE,"undefined"==typeof document?(s.Logger.Warn("Creating an instance of an HtmlMesh with id ".concat(r," outside of a browser. The mesh will not be visible.")),u):(u._fitStrategy=d,u._isCanvasOverlay=c,u._createMask(),u._element=u._createElement(),u.setEnabled(!0),u._captureOnPointerEnter=a,u._pointerEventCaptureBehavior=new I(u.capturePointerEvents.bind(u),u.releasePointerEvents.bind(u),{captureOnPointerEnter:u._captureOnPointerEnter}),u.addBehavior(u._pointerEventCaptureBehavior),u)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}h(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(t,e),Object.defineProperty(t.prototype,"isHtmlMesh",{get:function(){return!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sourceWidth",{get:function(){return this._sourceWidth},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sourceHeight",{get:function(){return this._sourceHeight},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return this._width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this._height},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"element",{get:function(){return this._element},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"requiresUpdate",{get:function(){return this._requiresUpdate},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"captureOnPointerEnter",{set:function(e){this._captureOnPointerEnter=e,this._pointerEventCaptureBehavior&&(this._pointerEventCaptureBehavior.captureOnPointerEnter=e)},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){var t;e.prototype.dispose.call(this),null===(t=this._element)||void 0===t||t.remove(),this._element=void 0,this._pointerEventCaptureBehavior&&(this._pointerEventCaptureBehavior.dispose(),this._pointerEventCaptureBehavior=null)},t.prototype._markAsUpdated=function(){this._requiresUpdate=!1},t.prototype.setContent=function(e,t,r){this._setAsReady(!1),this._sourceWidth=null,this._sourceHeight=null,this._element&&(this._width=t,this._height=r,this._requiresUpdate=!0,this.scaling.setAll(1),e&&(this._element.appendChild(this._fitStrategy.wrapElement(e)),this._updateScaleIfNecessary()),this.sourceWidth&&this.sourceHeight&&this._setAsReady(!0))},t.prototype.setEnabled=function(e){this._enabled=e,e&&!this._ready||this._doSetEnabled(e)},t.prototype.setContentSizePx=function(e,t){this._sourceWidth=e,this._sourceHeight=t,this._element&&this._element.firstElementChild&&(this._fitStrategy.updateSize(this._element.firstElementChild,e,t),this._updateScaleIfNecessary(),this.width&&this.height&&this._setAsReady(!0))},t.prototype._setAsReady=function(e){this._ready=e,e?this._doSetEnabled(this._enabled):this._doSetEnabled(!1)},t.prototype._doSetEnabled=function(t){var r,i=this;this._element&&(t&&!this._worldMatrixUpdateObserver?this._worldMatrixUpdateObserver=this.onAfterWorldMatrixUpdateObservable.add((function(){i._requiresUpdate=!0})):t||(null===(r=this._worldMatrixUpdateObserver)||void 0===r||r.remove(),this._worldMatrixUpdateObserver=null),this._element.style.display=t?"":"none",this._setElementzIndex(-1e4*this.position.z),e.prototype.setEnabled.call(this,t))},t.prototype._updateScaleIfNecessary=function(){this.scaling.setAll(1),this._inverseScaleMatrix&&(this.bakeTransformIntoVertices(this._inverseScaleMatrix),this._inverseScaleMatrix=null);var e=this._width||1,t=this._height||1,r=s.Matrix.Scaling(e,t,1);this.bakeTransformIntoVertices(r),this._inverseScaleMatrix=new s.Matrix,r.invertToRef(this._inverseScaleMatrix)},t.prototype._createMask=function(){(0,s.CreatePlaneVertexData)({width:1,height:1}).applyToMesh(this);var e=this.getScene();this.checkCollisions=!0;var t=new s.StandardMaterial("".concat(this.id,"-mat"),e);this._isCanvasOverlay||(t.backFaceCulling=!1,t.disableColorWrite=!0,t.disableLighting=!0),this.material=t,this.material.freeze()},t.prototype._setElementzIndex=function(e){this._element&&(this._element.style.zIndex="".concat(e))},t.prototype.capturePointerEvents=function(){this._element&&(this._element.style.pointerEvents="auto",document.getElementsByTagName("body")[0].style.pointerEvents="none")},t.prototype.releasePointerEvents=function(){this._element&&(document.getElementsByTagName("body")[0].style.pointerEvents="auto",this._element.style.pointerEvents="none")},t.prototype._createElement=function(){if("undefined"!=typeof document){var e=document.createElement("div");return e.id=this.id,e.style.backgroundColor=this._isCanvasOverlay?"transparent":"#000",e.style.zIndex="1",e.style.position="absolute",e.style.pointerEvents="none",e.style.backfaceVisibility="hidden",e}},t}(s.Mesh);!function(e){e[e.SPACE=32]="SPACE",e[e.TOFU=65532]="TOFU"}(u||(u={}));var T=function(){function e(e,t,r){var i=this;this._chars=new Map,this._kernings=new Map,this._font=JSON.parse(e),this._font.pages=[t],this._font.chars.forEach((function(e){return i._chars.set(e.id,e)})),this._font.kernings.forEach((function(e){var t=i._kernings.get(e.first);t||(t=new Map,i._kernings.set(e.first,t)),t.set(e.second,e.amount)})),this._charsRegex=new RegExp("[".concat(this._font.chars.map((function(e){return e.char.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")})).join(""),"]"),"g"),this._updateFallbacks(),this.scale=1/this._font.info.size,this.textures=this._font.pages.map((function(e){var t=new s.Texture(e,r,{noMipmap:!1,invertY:!1});return t.anisotropicFilteringLevel=16,t}))}return e.prototype.dispose=function(){for(var e=0,t=this.textures;e<t.length;e++)t[e].dispose();this.textures.length=0},e.prototype._updateFallbacks=function(){this._chars.has(u.SPACE)||this._chars.set(u.SPACE,{id:u.SPACE,x:0,y:0,width:0,height:0,xoffset:0,yoffset:0,xadvance:.5*this._font.info.size,page:-1,chnl:-1,index:-1,char:" "}),this._chars.has(u.TOFU)||this._chars.set(u.TOFU,{id:u.TOFU,x:0,y:0,width:this._font.info.size,height:this._font.info.size,xoffset:0,yoffset:0,xadvance:.5*this._font.info.size,page:-1,chnl:-1,index:-1,char:"￿"})},e.prototype._getChar=function(e){return this._chars.get(e)||this._chars.get(u.TOFU)},e.prototype._getKerning=function(e,t){var r;return(null===(r=this._kernings.get(e))||void 0===r?void 0:r.get(t))||0},e.prototype._unsupportedChars=function(e){return e.replace(this._charsRegex,"")},e}(),D={maxWidth:1/0,lineHeight:1,letterSpacing:1,tabSize:4,whiteSpace:"pre-line",textAlign:"center",translate:{x:-.5,y:-.5}},k=function(){function e(e,t,r){this.text=e,this.fontAsset=t,this.options=d(d({},D),r);var i=this._computeMetrics(e),n=i.paragraph,o=i.lines,s=i.glyphs,a=i.width,l=i.height;this.paragraph=n,this.lines=o,this.glyphs=s,this.width=a,this.height=l}return Object.defineProperty(e.prototype,"lineHeight",{get:function(){return this.fontAsset._font.common.lineHeight*this.options.lineHeight},enumerable:!1,configurable:!0}),e.prototype._computeMetrics=function(e){for(var t=this,r=this._collapse(e),i=this._breakLines(r).map((function(e){return e.trim()})),n=[],o=0,s=i;o<s.length;o++){var a=s[o];n.push.apply(n,this._wrap(a,n.length))}var l=Math.max.apply(Math,n.map((function(e){return e.width}))),c=this.lineHeight*n.length;("left"!==this.options.textAlign||this.options.translate)&&n.forEach((function(e){for(var r=function(){switch(t.options.textAlign){case"right":return l-e.width;case"center":return(l-e.width)/2;default:return 0}}(),i=t.options.translate?t.options.translate.x*l:0,n=t.options.translate?t.options.translate.y*c:0,o=0,s=e.glyphs;o<s.length;o++){var a=s[o];a.x+=r,a.x+=i,a.y+=n}}));var h=n.flatMap((function(e){return e.glyphs}));return{paragraph:i.join("\n"),lines:n,glyphs:h,width:l,height:c}},e.prototype._breakLines=function(e){return e.split("\n")},e.prototype._collapse=function(e){return e.replace(/\t/g," ".repeat(this.options.tabSize)).replace(/ +/g," ")},e.prototype._wrap=function(e,t){void 0===t&&(t=0);for(var r,i=new Array,n=t,o=new Array,s=0,a=0,l=0,c=l,h=function(){i.push({text:e.slice(l,c),glyphs:o,start:l,end:c,width:a})};c<e.length;){var d=c,u=e.charCodeAt(d),f=this.fontAsset._getChar(u),p=f.width,v=(s+=r?this.fontAsset._getKerning(r.id,f.id):0)+p,m=f.xadvance+this.options.letterSpacing,_=s+m,g=_>this.options.maxWidth||v>this.options.maxWidth;g&&(h(),n++,r=void 0,s=0,a=0,c=(l=c)+1,o=[]);var y=s,x=n*this.lineHeight;o.push({char:f,line:n,position:o.length,x:y,y:x}),g?s=m:(r=f,s=_,a=v,c++)}return o.length>0&&h(),i},e}(),L=function(){function e(e,t,r){void 0===t&&(t=0),this._useVAO=!1,this._vertexBuffers={},this._charMatrices=new Array,this._charUvs=new Array,this._isDirty=!0,this._baseLine=0,this._scalingMatrix=new s.ThinMatrix,this._fontScaleMatrix=new s.ThinMatrix,this._offsetMatrix=new s.ThinMatrix,this._translationMatrix=new s.ThinMatrix,this._baseMatrix=new s.ThinMatrix,this._scaledMatrix=new s.ThinMatrix,this._localMatrix=new s.ThinMatrix,this._finalMatrix=new s.ThinMatrix,this._lineMatrix=new s.ThinMatrix,this._parentWorldMatrix=new s.ThinMatrix,this.color={r:1,g:1,b:1,a:1},this.strokeColor={r:1,g:1,b:1,a:1},this.strokeInsetWidth=0,this.strokeOutsetWidth=0,this.thicknessControl=0,this._parent=null,this._transformMatrix=new s.ThinMatrix,this.isBillboard=!1,this.isBillboardScreenProjected=!1,this.ignoreDepthBuffer=!1,this._engine=e,this._shaderLanguage=t,this._font=r,this._baseLine=r._font.common.lineHeight*r.scale,this._useVAO=e.getCaps().vertexArrayObject&&!e.disableVertexArrayObjects;var i=new Float32Array([0,0,1,0,0,1,1,1]);this._spriteBuffer=new s.Buffer(e,i,!1,2),this._vertexBuffers.offsets=this._spriteBuffer.createVertexBuffer("offsets",0,2),this._resizeBuffers(128)}return Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},set:function(e){this._parent=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transformMatrix",{get:function(){return this._transformMatrix},set:function(e){this._transformMatrix=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"characterCount",{get:function(){return this._charMatrices.length/16},enumerable:!1,configurable:!0}),e.prototype._resizeBuffers=function(e){this._worldBuffer&&(this._worldBuffer.dispose(),this._worldBuffer=null),this._uvBuffer&&(this._uvBuffer.dispose(),this._uvBuffer=null),this._worldBuffer=new s.Buffer(this._engine,new Float32Array(16*e),!0,16),this._vertexBuffers.world0=this._worldBuffer.createVertexBuffer("world0",0,4,16,!0),this._vertexBuffers.world1=this._worldBuffer.createVertexBuffer("world1",4,4,16,!0),this._vertexBuffers.world2=this._worldBuffer.createVertexBuffer("world2",8,4,16,!0),this._vertexBuffers.world3=this._worldBuffer.createVertexBuffer("world3",12,4,16,!0),this._uvBuffer=new s.Buffer(this._engine,new Float32Array(4*e),!0,4),this._vertexBuffers.uvs=this._uvBuffer.createVertexBuffer("uvs",0,4,4,!0)},e.prototype._setShaders=function(e,t){var r;null===(r=this._drawWrapperBase)||void 0===r||r.dispose(),this._drawWrapperBase=new s.DrawWrapper(this._engine),this._drawWrapperBase.drawContext&&(this._drawWrapperBase.drawContext.useInstancing=!0),this._drawWrapperBase.effect=this._engine.createEffect({vertexSource:e,fragmentSource:t},["offsets","world0","world1","world2","world3","uvs"],["parentWorld","view","projection","uColor","thickness","uStrokeColor","uStrokeInsetWidth","uStrokeOutsetWidth","mode","transform"],["fontAtlas"],"",void 0,void 0,void 0,void 0,this._shaderLanguage),this._drawWrapperBase.effect._refCount++},e.prototype.addParagraph=function(e,t,r){var i=this,n=new k(e,this._font,t),o=this._font.scale,a=this._font._font.common.scaleW,l=this._font._font.common.scaleH,c=n.glyphs.filter((function(e){return e.char.page>=0})),h=r;if(!h){var d=n.lineHeight*o,u=n.lines.length*d/2;(0,s.TranslationMatrixToRef)(0,this._baseLine-u,0,this._lineMatrix),h=this._lineMatrix}(0,s.ScalingMatrixToRef)(o,o,1,this._fontScaleMatrix),(0,s.TranslationMatrixToRef)(.5,-.5,0,this._offsetMatrix);var f=this._charUvs.length,p=this._charMatrices.length;c.forEach((function(e,t){i._charUvs[f+4*t+0]=e.char.x/a,i._charUvs[f+4*t+1]=e.char.y/l,i._charUvs[f+4*t+2]=e.char.width/a,i._charUvs[f+4*t+3]=e.char.height/l;var r=e.x+e.char.xoffset,n=1-(e.y+e.char.yoffset);(0,s.ScalingMatrixToRef)(e.char.width,e.char.height,1,i._scalingMatrix),(0,s.MultiplyMatricesToRef)(i._offsetMatrix,i._scalingMatrix,i._baseMatrix),(0,s.TranslationMatrixToRef)(r*o,n*o,0,i._translationMatrix),(0,s.MultiplyMatricesToRef)(i._baseMatrix,i._fontScaleMatrix,i._scaledMatrix),(0,s.MultiplyMatricesToRef)(i._scaledMatrix,i._translationMatrix,i._localMatrix),(0,s.MultiplyMatricesToRef)(i._localMatrix,h,i._finalMatrix),(0,s.CopyMatrixToArray)(i._finalMatrix,i._charMatrices,p+16*t)})),this._isDirty=!0,this._baseLine-=n.lineHeight*o*n.lines.length},e.prototype.render=function(e,t){var r=this._drawWrapperBase,i=r.effect;if(i.isReady()){var n=this._engine;n.setState(!1),n.enableEffect(r),this.ignoreDepthBuffer&&n.setDepthBuffer(!1),this._parent?(0,s.CopyMatrixToRef)(this._parent.getWorldMatrix(),this._parentWorldMatrix):(0,s.IdentityMatrixToRef)(this._parentWorldMatrix),i.setInt("mode",this.isBillboard?this.isBillboardScreenProjected?2:1:0),i.setMatrix("parentWorld",this._parentWorldMatrix),i.setMatrix("view",e),i.setMatrix("projection",t),i.setMatrix("transform",this.transformMatrix),i.setTexture("fontAtlas",this._font.textures[0]),i.setDirectColor4("uColor",this.color),i.setDirectColor4("uStrokeColor",this.strokeColor),i.setFloat("thickness",.9*this.thicknessControl),i.setFloat("uStrokeInsetWidth",this.strokeInsetWidth),i.setFloat("uStrokeOutsetWidth",this.strokeOutsetWidth);var o=this._charMatrices.length/16;this._isDirty&&(this._isDirty=!1,this._worldBuffer.getBuffer().capacity/4<16*o&&this._resizeBuffers(o),this._worldBuffer.update(this._charMatrices),this._uvBuffer.update(this._charUvs)),this._useVAO?(this._vertexArrayObject||(this._vertexArrayObject=n.recordVertexArrayObject(this._vertexBuffers,null,i)),n.bindVertexArrayObject(this._vertexArrayObject,null)):n.bindBuffers(this._vertexBuffers,null,i),n.setAlphaMode(s.Constants.ALPHA_COMBINE),n.drawArraysType(s.Constants.MATERIAL_TriangleStripDrawMode,0,4,o),n.unbindInstanceAttributes(),n.setAlphaMode(s.Constants.ALPHA_DISABLE),this.ignoreDepthBuffer&&n.setDepthBuffer(!0)}},e.prototype.dispose=function(){this._worldBuffer&&(this._worldBuffer.dispose(),this._worldBuffer=null),this._uvBuffer&&(this._uvBuffer.dispose(),this._uvBuffer=null),this._spriteBuffer&&(this._spriteBuffer.dispose(),this._spriteBuffer=null),this._vertexArrayObject&&(this._engine.releaseVertexArrayObject(this._vertexArrayObject),this._vertexArrayObject=null)},e.CreateTextRendererAsync=function(t,r){return n=this,o=void 0,a=function(){var n,o,s,a;return function(e,t){var r,i,n,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(l){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(r=1,i&&(n=2&a[0]?i.return:a[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,a[1])).done)return n;switch(i=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,i=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((n=(n=o.trys).length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){o.label=a[1];break}if(6===a[0]&&o.label<n[1]){o.label=n[1],n=a;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(a);break}n[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],i=0}finally{r=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,l])}}}(this,(function(l){switch(l.label){case 0:if(!r.getCaps().instancedArrays||!r._features.supportSpriteInstancing)throw new Error("Instanced arrays are required for MSDF text rendering.");return n=0,o="",s="",r.isWebGPU?(n=1,[4,Promise.resolve().then(i.bind(i,681))]):[3,3];case 1:return o=l.sent().msdfVertexShaderWGSL.shader,[4,Promise.resolve().then(i.bind(i,115))];case 2:return s=l.sent().msdfPixelShaderWGSL.shader,[3,6];case 3:return[4,Promise.resolve().then(i.bind(i,36))];case 4:return o=l.sent().msdfVertexShader.shader,[4,Promise.resolve().then(i.bind(i,370))];case 5:s=l.sent().msdfPixelShader.shader,l.label=6;case 6:return(a=new e(r,n,t))._setShaders(o,s),[2,a]}}))},new((s=void 0)||(s=Promise))((function(e,t){function r(e){try{l(a.next(e))}catch(e){t(e)}}function i(e){try{l(a.throw(e))}catch(e){t(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof s?n:new s((function(e){e(n)}))).then(r,i)}l((a=a.apply(n,o||[])).next())}));var n,o,s,a},e}(),j=i(36),z=i(370),V=i(681),U=i(115);const F=o;return n.default})()));
2
2
  //# sourceMappingURL=babylonjs.addons.min.js.map
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-addons",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-addons"]=t(require("babylonjs")):e.ADDONS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(e=>(()=>{"use strict";var t={36:(e,t,r)=>{r.r(t),r.d(t,{msdfVertexShader:()=>s});var i=r(597),n="msdfVertexShader",o="#define BILLBOARD 1\n#define BILLBOARDSCREENPROJECTED 2\nattribute vec2 offsets;attribute vec4 world0;attribute vec4 world1;attribute vec4 world2;attribute vec4 world3;attribute vec4 uvs;uniform mat4 transform;uniform mat4 parentWorld;uniform mat4 view;uniform mat4 projection;uniform vec3 center;uniform int mode;varying vec2 atlasUV;void main(void) {mat4 world=mat4(world0,world1,world2,world3);vec4 worldPos=transform*(world*vec4(offsets.xy-vec2(0.5,0.5),0.,1.0));if (mode>=BILLBOARD) {vec3 viewPos=(view*parentWorld*vec4(0.,0.,0.,1.0)).xyz; \nif (mode==BILLBOARDSCREENPROJECTED) {viewPos.x/=viewPos.z;viewPos.y/=viewPos.z;viewPos.z=1.0;}\ngl_Position=projection*vec4(viewPos+worldPos.xyz,1.0); } else {vec3 viewPos=(view*parentWorld*worldPos).xyz; \ngl_Position=projection*vec4(viewPos,1.0); }\natlasUV=vec2(uvs.x+offsets.x*uvs.z,uvs.y+(1.0-offsets.y)*uvs.w);}";i.ShaderStore.ShadersStore[n]||(i.ShaderStore.ShadersStore[n]=o);var s={name:n,shader:o}},115:(e,t,r)=>{r.r(t),r.d(t,{msdfPixelShaderWGSL:()=>s});var i=r(597),n="msdfPixelShader",o="var fontAtlas: texture_2d<f32>;var fontAtlasSampler: sampler;uniform uColor: vec4f;uniform thickness: f32;uniform uStrokeColor: vec4f;uniform uStrokeInsetWidth: f32;uniform uStrokeOutsetWidth: f32;varying atlasUV: vec2f;fn median(msdf: vec3<f32>)->f32 {let a=min(msdf.r,msdf.g);let b=max(msdf.r,msdf.g);return max(a,min(b,msdf.b));}\n@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {let s=textureSample(fontAtlas,fontAtlasSampler,input.atlasUV).rgb;let sigDist=median(s)-0.5+uniforms.thickness;let afwidth=length(vec2<f32>(dpdx(sigDist),dpdy(sigDist)));let alpha=clamp(sigDist/afwidth+0.5,0.0,1.0);let sigDistOutset=sigDist+uniforms.uStrokeOutsetWidth*0.5;let sigDistInset=sigDist-uniforms.uStrokeInsetWidth*0.5;let afwidthOutset=length(vec2<f32>(dpdx(sigDistOutset),dpdy(sigDistOutset)));let afwidthInset=length(vec2<f32>(dpdx(sigDistInset),dpdy(sigDistInset)));let outset=clamp(sigDistOutset/afwidthOutset+0.5,0.0,1.0);let inset=1.0-clamp(sigDistInset/afwidthInset+0.5,0.0,1.0);let border=outset*inset;let filledFragColor=vec4<f32>(uniforms.uColor.rgb,alpha*uniforms.uColor.a);let strokedFragColor=vec4<f32>(uniforms.uStrokeColor.rgb,border*uniforms.uStrokeColor.a);fragmentOutputs.color=mix(filledFragColor,strokedFragColor,border);}";i.ShaderStore.ShadersStoreWGSL[n]||(i.ShaderStore.ShadersStoreWGSL[n]=o);var s={name:n,shader:o}},370:(e,t,r)=>{r.r(t),r.d(t,{msdfPixelShader:()=>s});var i=r(597),n="msdfPixelShader",o="#extension GL_OES_standard_derivatives : enable\nprecision highp float;uniform sampler2D fontAtlas;uniform vec4 uColor;uniform vec4 uStrokeColor;uniform float uStrokeInsetWidth;uniform float uStrokeOutsetWidth;uniform float thickness;varying vec2 atlasUV;float median(vec3 msdf) {return max(min(msdf.r,msdf.g),min(max(msdf.r,msdf.g),msdf.b));}\nvoid main(void)\n{vec3 s=texture2D(fontAtlas,atlasUV).rgb;float sigDist=median(s)-0.5+thickness;float alpha=clamp(sigDist/fwidth(sigDist)+0.5,0.0,1.0);float sigDistOutset=sigDist+uStrokeOutsetWidth*0.5;float sigDistInset=sigDist-uStrokeInsetWidth*0.5;float outset=clamp(sigDistOutset/fwidth(sigDistOutset)+0.5,0.0,1.0);float inset=1.0-clamp(sigDistInset/fwidth(sigDistInset)+0.5,0.0,1.0);float border=outset*inset;vec4 filledFragColor=vec4(uColor.rgb,alpha*uColor.a);vec4 strokedFragColor=vec4(uStrokeColor.rgb,border*uStrokeColor.a);gl_FragColor=mix(filledFragColor,strokedFragColor,border);}";i.ShaderStore.ShadersStore[n]||(i.ShaderStore.ShadersStore[n]=o);var s={name:n,shader:o}},597:t=>{t.exports=e},681:(e,t,r)=>{r.r(t),r.d(t,{msdfVertexShaderWGSL:()=>s});var i=r(597),n="msdfVertexShader",o="#define BILLBOARD 1\n#define BILLBOARDSCREENPROJECTED 2\nattribute offsets: vec2f;attribute world0: vec4f;attribute world1: vec4f;attribute world2: vec4f;attribute world3: vec4f;attribute uvs: vec4f;uniform transform: mat4x4f;uniform parentWorld: mat4x4f;uniform view: mat4x4f;uniform projection: mat4x4f;uniform mode: u32;varying atlasUV: vec2f;@vertex\nfn main(input: VertexInputs)->FragmentInputs {let world=mat4x4<f32>(input.world0,input.world1,input.world2,input.world3);let localOffset=vec4<f32>(input.offsets-vec2<f32>(0.5,0.5),0.0,1.0);let worldPos=uniforms.transform*world*localOffset;if (uniforms.mode>=BILLBOARD) { \nvar viewPos=(uniforms.view*uniforms.parentWorld*vec4f(0.,0.,0.,1.0)).xyz;if (uniforms.mode==BILLBOARDSCREENPROJECTED) {viewPos=vec3f(viewPos.x/viewPos.z,viewPos.y/viewPos.z,1.0);} \nvertexOutputs.position=uniforms.projection*vec4<f32>(viewPos+worldPos.xyz,1.0);} else { \nlet viewPos=(uniforms.view*uniforms.parentWorld*worldPos).xyz;vertexOutputs.position=uniforms.projection*vec4<f32>(viewPos,1.0);}\nvertexOutputs.atlasUV=vec2<f32>(\ninput.uvs.x+input.offsets.x*input.uvs.z,\ninput.uvs.y+(1.0-input.offsets.y)*input.uvs.w\n);}";i.ShaderStore.ShadersStoreWGSL[n]||(i.ShaderStore.ShadersStoreWGSL[n]=o);var s={name:n,shader:o}}},r={};function i(e){var n=r[e];if(void 0!==n)return n.exports;var o=r[e]={exports:{}};return t[e](o,o.exports,i),o.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};i.d(n,{default:()=>F});var o={};i.r(o),i.d(o,{DefaultParagraphOptions:()=>D,FitStrategy:()=>R,FontAsset:()=>T,HtmlMesh:()=>W,HtmlMeshRenderer:()=>c,PointerEventsCaptureBehavior:()=>I,SdfTextParagraph:()=>k,TextRenderer:()=>L,msdfPixelShader:()=>z.msdfPixelShader,msdfPixelShaderWGSL:()=>U.msdfPixelShaderWGSL,msdfVertexShader:()=>j.msdfVertexShader,msdfVertexShaderWGSL:()=>V.msdfVertexShaderWGSL});var s=i(597),a=100,l=function(e){return function(t,r){var i=t.getMesh(),n=r.getMesh(),o=i.isHtmlMesh,s=n.isHtmlMesh;return o?s&&i.absolutePosition.z<=n.absolutePosition.z?1:-1:s?1:e(t,r)}},c=function(){function e(e,t){var r=void 0===t?{}:t,i=r.parentContainerId,n=void 0===i?null:i,o=r._containerId,a=void 0===o?"css-container":o,l=r.enableOverlayRender,c=void 0===l||l,h=r.defaultOpaqueRenderOrder,d=void 0===h?s.RenderingGroup.PainterSortCompare:h,u=r.defaultAlphaTestRenderOrder,f=void 0===u?s.RenderingGroup.PainterSortCompare:u,p=r.defaultTransparentRenderOrder,v=void 0===p?s.RenderingGroup.defaultTransparentSortCompare:p,m=this;this._cache={cameraData:{fov:0,position:new s.Vector3,style:""},htmlMeshData:new WeakMap},this._width=0,this._height=0,this._heightHalf=0,this._temp={scaleTransform:new s.Vector3,rotationTransform:new s.Quaternion,positionTransform:new s.Vector3,objectMatrix:s.Matrix.Identity(),cameraWorldMatrix:s.Matrix.Identity(),cameraRotationMatrix:s.Matrix.Identity(),cameraWorldMatrixAsArray:new Array(16)},this._lastDevicePixelRatio=window.devicePixelRatio,this._cameraMatrixUpdated=!0,this._previousCanvasDocumentPosition={top:0,left:0},this._renderObserver=null,this._onCameraMatrixChanged=function(e){m._cameraWorldMatrix=e.getWorldMatrix(),m._cameraMatrixUpdated=!0},"undefined"!=typeof document&&(this._containerId=a,this._init(e,n,c,d,f,v))}return e.prototype.dispose=function(){var e,t;this._renderObserver&&(this._renderObserver.remove(),this._renderObserver=null),null===(e=this._overlayElements)||void 0===e||e.container.remove(),this._overlayElements=null,null===(t=this._inSceneElements)||void 0===t||t.container.remove(),this._inSceneElements=null},e.prototype._init=function(e,t,r,i,n,o){var s,a=this;if("undefined"!=typeof document){var c=t?document.getElementById(t):document.body;c||(c=document.body);var h="".concat(this._containerId,"_in_scene");if(this._inSceneElements=this._createRenderLayerElements(h),c.insertBefore(this._inSceneElements.container,c.firstChild),r){var d="".concat(this._containerId,"_overlay");this._overlayElements=this._createRenderLayerElements(d);var u=+(null!==(s=e.getEngine().getRenderingCanvas().style.zIndex)&&void 0!==s?s:"0")+1;this._overlayElements.container.style.zIndex="".concat(u),this._overlayElements.container.style.pointerEvents="none",c.insertBefore(this._overlayElements.container,c.firstChild)}this._engine=e.getEngine();var f,p,v=this._engine.getRenderingCanvasClientRect();if(!v)throw new Error("Failed to get client rect for rendering canvas");this._setSize(v.width,v.height),this._engine.onResizeObservable.add((function(){var e=a._engine.getRenderingCanvasClientRect();e&&a._setSize(e.width,e.height)}));var m=function(){var t=e.activeCamera;t&&(f=t.onProjectionMatrixChangedObservable.add((function(){a._onCameraMatrixChanged(t)})),p=t.onViewMatrixChangedObservable.add((function(){a._onCameraMatrixChanged(t)})))};m(),e.onActiveCameraChanged.add((function(){var t,r;f&&(null===(t=e.activeCamera)||void 0===t||t.onProjectionMatrixChangedObservable.remove(f)),p&&(null===(r=e.activeCamera)||void 0===r||r.onViewMatrixChangedObservable.remove(p)),m()}));var _=l(i),g=l(n),y=l(o);e.setRenderingOrder(0,_,g,y),this._renderObserver=e.onBeforeRenderObservable.add((function(){a._render(e,e.activeCamera)}))}},e.prototype._createRenderLayerElements=function(e){var t=document.getElementById(e);t&&t.remove();var r=document.createElement("div");r.id=e,r.style.position="absolute",r.style.width="100%",r.style.height="100%",r.style.zIndex="-1";var i=document.createElement("div");i.style.overflow="hidden";var n=document.createElement("div");return n.style.webkitTransformStyle="preserve-3d",n.style.transformStyle="preserve-3d",n.style.pointerEvents="none",i.appendChild(n),r.appendChild(i),{container:r,domElement:i,cameraElement:n}},e.prototype._getSize=function(){return{width:this._width,height:this._height}},e.prototype._setSize=function(e,t){if(this._width=e,this._height=t,this._heightHalf=this._height/2,this._inSceneElements&&this._overlayElements)for(var r=0,i=[this._inSceneElements.domElement,this._overlayElements.domElement,this._inSceneElements.cameraElement,this._overlayElements.cameraElement];r<i.length;r++){var n=i[r];n&&(n.style.width="".concat(e,"px"),n.style.height="".concat(t,"px"))}},e.prototype._getCameraCssMatrix=function(e){var t=e.m;return"matrix3d(".concat(this._epsilon(t[0]),",").concat(this._epsilon(-t[1]),",").concat(this._epsilon(t[2]),",").concat(this._epsilon(t[3]),",").concat(this._epsilon(t[4]),",").concat(this._epsilon(-t[5]),",").concat(this._epsilon(t[6]),",").concat(this._epsilon(t[7]),",").concat(this._epsilon(t[8]),",").concat(this._epsilon(-t[9]),",").concat(this._epsilon(t[10]),",").concat(this._epsilon(t[11]),",").concat(this._epsilon(t[12]),",").concat(this._epsilon(-t[13]),",").concat(this._epsilon(t[14]),",").concat(this._epsilon(t[15]),")")},e.prototype._getHtmlContentCssMatrix=function(e,t){var r=e.m,i=t?-1:1;return"matrix3d(".concat(this._epsilon(r[0]),",").concat(this._epsilon(r[1]),",").concat(this._epsilon(r[2]*-i),",").concat(this._epsilon(r[3]),",").concat(this._epsilon(-r[4]),",").concat(this._epsilon(-r[5]),",").concat(this._epsilon(r[6]*i),",").concat(this._epsilon(-r[7]),",").concat(this._epsilon(r[8]*-i),",").concat(this._epsilon(r[9]*-i),",").concat(this._epsilon(r[10]),",").concat(this._epsilon(r[11]*i),",").concat(this._epsilon(r[12]*i),",").concat(this._epsilon(r[13]*i),",").concat(this._epsilon(r[14]*i),",").concat(this._epsilon(r[15]),")")},e.prototype._getTransformationMatrix=function(e,t){var r;if(this._cameraWorldMatrix||(this._cameraWorldMatrix=null===(r=e.getScene().activeCamera)||void 0===r?void 0:r.getWorldMatrix()),!this._cameraWorldMatrix)return s.Matrix.Identity();var i=e.getWorldMatrix(),n=1,o=1;e.sourceWidth&&e.sourceHeight&&(n=e.width/(e.sourceWidth/a),o=e.height/(e.sourceHeight/a));var l=this._temp.scaleTransform,c=this._temp.rotationTransform,h=this._temp.positionTransform,d=this._temp.objectMatrix;i.decompose(l,c,h),l.x*=n,l.y*=o,s.Matrix.ComposeToRef(l,c,h,d);var u=t?-1:1,f=e.getAbsolutePosition();return d.setRowFromFloats(3,(-this._cameraWorldMatrix.m[12]+f.x)*a*u,(-this._cameraWorldMatrix.m[13]+f.y)*a*u,(this._cameraWorldMatrix.m[14]-f.z)*a,1e-5*this._cameraWorldMatrix.m[15]*a),d.multiplyAtIndex(3,a),d.multiplyAtIndex(7,a),d.multiplyAtIndex(11,a),d},e.prototype._renderHtmlMesh=function(e,t){var r,i;if(e.element&&e.element.firstElementChild){var n=this._cache.htmlMeshData.get(e);n||(n={style:""},this._cache.htmlMeshData.set(e,n));var o=e._isCanvasOverlay?null===(r=this._overlayElements)||void 0===r?void 0:r.cameraElement:null===(i=this._inSceneElements)||void 0===i?void 0:i.cameraElement;e.element.parentNode!==o&&o.appendChild(e.element),e.requiresUpdate&&this._updateBaseScaleFactor(e);var s=this._getTransformationMatrix(e,t),a="translate(-50%, -50%) ".concat(this._getHtmlContentCssMatrix(s,t));a+="".concat(t?"matrix3d(-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1)":""),n.style!==a&&(e.element.style.webkitTransform=a,e.element.style.transform=a),e._markAsUpdated()}},e.prototype._render=function(e,t){var r,i,n,o,a=!1,l=e.useRightHandedSystem;this._updateContainerPositionIfNeeded(),this._cameraMatrixUpdated&&(this._cameraMatrixUpdated=!1,a=!0),t.position.x===this._cache.cameraData.position.x&&t.position.y===this._cache.cameraData.position.y&&t.position.z===this._cache.cameraData.position.z||(this._cache.cameraData.position.copyFrom(t.position),a=!0),window.devicePixelRatio!==this._lastDevicePixelRatio&&(this._lastDevicePixelRatio=window.devicePixelRatio,s.Logger.Log("In render - dpr changed: ",this._lastDevicePixelRatio),a=!0);var c=e.meshes.filter((function(e){return e.isHtmlMesh&&(a||e.requiresUpdate)}));if(a=a||c.length>0){var h=t.getProjectionMatrix().m[5]*this._heightHalf;if(this._cache.cameraData.fov!==h){var d=[null===(r=this._overlayElements)||void 0===r?void 0:r.domElement,null===(i=this._inSceneElements)||void 0===i?void 0:i.domElement];if(t.mode==s.Camera.PERSPECTIVE_CAMERA)for(var u=0,f=d;u<f.length;u++)(M=f[u])&&(M.style.webkitPerspective=h+"px",M.style.perspective=h+"px");else for(var p=0,v=d;p<v.length;p++)(M=v[p])&&(M.style.webkitPerspective="",M.style.perspective="");this._cache.cameraData.fov=h}null===t.parent&&t.computeWorldMatrix();var m=this._temp.cameraWorldMatrix;m.copyFrom(t.getWorldMatrix());var _=this._temp.cameraRotationMatrix;m.getRotationMatrix().transposeToRef(_);var g=this._temp.cameraWorldMatrixAsArray;m.copyToArray(g);var y=l?1:-1;g[1]=_.m[1],g[2]=_.m[2]*y,g[4]=_.m[4]*y,g[6]=_.m[6]*y,g[8]=_.m[8]*y,g[9]=_.m[9]*y,s.Matrix.FromArrayToRef(g,0,m);var x=this._getCameraCssMatrix(m);if(this._cache.cameraData.style!==x){for(var b=0,w=d=[null===(n=this._inSceneElements)||void 0===n?void 0:n.cameraElement,null===(o=this._overlayElements)||void 0===o?void 0:o.cameraElement];b<w.length;b++){var M;(M=w[b])&&(M.style.webkitTransform=x,M.style.transform=x)}this._cache.cameraData.style=x}for(var S=0,C=c;S<C.length;S++){var E=C[S];this._renderHtmlMesh(E,l)}}},e.prototype._updateBaseScaleFactor=function(e){var t=this._width,r=this._height,i=(e.width||1)/(e.height||1);i>t/r?t=r*i:r=t/i,e.setContentSizePx(t,r)},e.prototype._updateContainerPositionIfNeeded=function(){var e,t,r=this._engine.getRenderingCanvasClientRect();if(r){var i=window.scrollY,n=window.scrollX,o=r.top+i,a=r.left+n;if(this._previousCanvasDocumentPosition.top!==o||this._previousCanvasDocumentPosition.left!==a){this._previousCanvasDocumentPosition.top=o,this._previousCanvasDocumentPosition.left=a;for(var l=0,c=[null===(e=this._inSceneElements)||void 0===e?void 0:e.container,null===(t=this._overlayElements)||void 0===t?void 0:t.container];l<c.length;l++){var h=c[l];if(h){var d=h.offsetParent,u=d.getBoundingClientRect(),f=u.top+i,p=u.left+n,v=this._getAncestorMarginsAndPadding(d),m=window.getComputedStyle(document.body),_=parseInt(m.marginTop,10),g=parseInt(m.marginLeft,10);h.style.top="".concat(o-f-v.marginTop+v.paddingTop+_,"px"),h.style.left="".concat(a-p-v.marginLeft+v.paddingLeft+g,"px")}}}}else s.Logger.Warn("Failed to update html mesh renderer position due to failure to get canvas rect. HtmlMesh instances may not render correctly")},e.prototype._epsilon=function(e){return Math.abs(e)<1e-10?0:e},e.prototype._getAncestorMarginsAndPadding=function(e){for(var t=0,r=0,i=0,n=0;e&&e!==document.body&&e!==document.documentElement;){var o=window.getComputedStyle(e);t+=parseInt(o.marginTop,10),r+=parseInt(o.marginLeft,10),i+=parseInt(o.paddingTop,10),n+=parseInt(o.paddingLeft,10),e=e.offsetParent}return{marginTop:t,marginLeft:r,paddingTop:i,paddingLeft:n}},e}(),h=function(e,t){return h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},h(e,t)};var d=function(){return d=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},d.apply(this,arguments)};Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var u,f=[],p=new Map,v=[],m=null,_=function(e){M("In pointerEventsCapture.requestRelease - Pointer events release requested for ".concat(e)),e&&e!==m?g(e)?p.delete(e):(M("In pointerEventsCapture.requestRelease - Received release request ".concat(e," but no matching capture request was received")),v.includes(e)||v.push(e)):y()},g=function(e){var t=!1;return f=f.filter((function(r){return r!==e||(t=!0,M("In pointerEventsCapture.cancelRequest - Canceling pointer events capture request ".concat(e)),!1)})),t},y=function(){var e=w();M("In pointerEventsCapture.transferPointerEventsOwnership - Transferrring pointer events from ".concat(m," to ").concat(e)),x(),e&&b(e)},x=function(){var e;M("In pointerEventsCapture.doRelease - Releasing pointer events from ".concat(m)),m&&(null===(e=p.get(m))||void 0===e||e.release(),p.delete(m),m=null)},b=function(e){var t;e&&(null===(t=p.get(e))||void 0===t||t.capture()),m=e,M("In pointerEventsCapture.doCapture - Pointer events now captured by ".concat(e))},w=function(){return f.length>0?f.shift():null},M=function(e){("undefined"==typeof window||window["pointer-events-capture-debug"])&&s.Tools.Log("".concat(performance.now()," - game.scene.pointerEvents - ").concat(e,"\ncurrentOwner: ").concat(m,"\nqueue: ").concat(f,"\nunmatched: ").concat(v))},S=null,C=0,E=new WeakMap,O=function(e){"undefined"!=typeof document&&(0===C&&(document.addEventListener("pointermove",A),document.addEventListener("touchstart",A),S=null!=S?S:e,s.Logger.Log("PointerEventsCaptureBehavior: Starting observation of pointer move events."),S.onDisposeObservable.add(P)),C++)},P=function(){document.removeEventListener("pointermove",A),document.removeEventListener("touchstart",A),S=null,s.Logger.Log("PointerEventsCaptureBehavior: Stopping observation of pointer move events."),C=0},B=function(){"undefined"!=typeof document&&S&&--C<=0&&P()},A=function(e){if(S){var t=S.getEngine().getRenderingCanvasClientRect();if(t){var r,i="touches"in e?e.touches[0]:e,n=i.clientX,o=i.clientY,s=n-t.left,a=o-t.top,l=S.pick(s,a,(function(e){var t=E.get(e);return e.isEnabled()&&void 0!==t&&t._captureOnPointerEnter}));r=l.hit?l.pickedMesh:null;var c=parseInt(m||"");r&&r.uniqueId===c||(!c||r&&r.uniqueId===c||_(m),r&&E.get(r).capturePointerEvents())}}},I=function(){function e(e,t,r){var i=(void 0===r?{}:r).captureOnPointerEnter,n=void 0===i||i;this._captureCallback=e,this._releaseCallback=t,this.name="PointerEventsCaptureBehavior",this._attachedMesh=null,this._captureOnPointerEnter=n,"undefined"==typeof document&&s.Logger.Warn("Creating an instance of PointerEventsCaptureBehavior outside of a browser. The behavior will not work.")}return Object.defineProperty(e.prototype,"attachedMesh",{get:function(){return this._attachedMesh},set:function(e){this._attachedMesh=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"captureOnPointerEnter",{set:function(e){this._captureOnPointerEnter!==e&&(this._captureOnPointerEnter=e,this._attachedMesh&&(this._captureOnPointerEnter?O(this._attachedMesh.getScene()):B()))},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){this.attachedMesh=e,E.set(e,this),this._captureOnPointerEnter&&O(e.getScene())},e.prototype.detach=function(){this.attachedMesh&&(E.delete(this.attachedMesh),this._captureOnPointerEnter&&B(),this.attachedMesh=null)},e.prototype.dispose=function(){this.detach()},e.prototype.releasePointerEvents=function(){this.attachedMesh&&_(this.attachedMesh.uniqueId.toString())},e.prototype.capturePointerEvents=function(){var e,t,r;this.attachedMesh&&(e=this.attachedMesh.uniqueId.toString(),t=this._captureCallback,r=this._releaseCallback,M("In pointerEventsCapture.requestCapture - Pointer events capture requested for ".concat(e)),function(e){var t=!1;return v=v.filter((function(r){return r!==e||(t=!0,!1)})),t}(e)?M("In pointerEventsCapture.requestCapture - Capture request matched previous release request ".concat(e,". Cancelling capture request")):(e!==m&&function(e,t,r){M("In pointerEventsCapture.enqueueCaptureRequest - Enqueueing capture request for ".concat(e)),f.includes(e)||(f.push(e),p.set(e,{capture:t,release:r}))}(e,t,r),m||y()))},e}(),R={CONTAIN:{wrapElement:function(e){var t=document.createElement("div");t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center";var r=document.createElement("div");return r.style.visibility="hidden",r.appendChild(e),t.appendChild(r),t},updateSize:function(e,t,r){var i=e.firstElementChild;e.style.width="".concat(t,"px"),e.style.height="".concat(r,"px");var n=[i.offsetWidth,i.offsetHeight],o=n[0],s=n[1],a=Math.min(t/o,r/s);i.style.transform="scale(".concat(a,")"),i.style.visibility="visible"}},COVER:{wrapElement:function(e){var t=document.createElement("div");t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center",t.style.overflow="hidden";var r=document.createElement("div");return r.style.visibility="hidden",r.appendChild(e),t.appendChild(r),t},updateSize:function(e,t,r){var i=e.firstElementChild;e.style.width="".concat(t,"px"),e.style.height="".concat(r,"px");var n=[i.offsetWidth,i.offsetHeight],o=n[0],s=n[1],a=Math.max(t/o,r/s);i.style.transform="scale(".concat(a,")"),i.style.visibility="visible"}},STRETCH:{wrapElement:function(e){var t=document.createElement("div");t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center";var r=document.createElement("div");return r.style.visibility="hidden",r.appendChild(e),t.appendChild(r),t},updateSize:function(e,t,r){var i=e.firstElementChild;e.style.width="".concat(t,"px"),e.style.height="".concat(r,"px");var n=[i.offsetWidth,i.offsetHeight],o=n[0],s=n[1];i.style.transform="scale(".concat(t/o,", ").concat(r/s,")"),i.style.visibility="visible"}},NONE:{wrapElement:function(e){return e},updateSize:function(e,t,r){e&&(e.style.width="".concat(t,"px"),e.style.height="".concat(r,"px"))}}},W=function(e){function t(t,r,i){var n=void 0===i?{}:i,o=n.captureOnPointerEnter,a=void 0===o||o,l=n.isCanvasOverlay,c=void 0!==l&&l,h=n.fitStrategy,d=void 0===h?R.NONE:h,u=e.call(this,r,t)||this;return u._enabled=!1,u._ready=!1,u._isCanvasOverlay=!1,u._requiresUpdate=!0,u._inverseScaleMatrix=null,u._captureOnPointerEnter=!0,u._pointerEventCaptureBehavior=null,u._sourceWidth=null,u._sourceHeight=null,u._fitStrategy=R.NONE,"undefined"==typeof document?(s.Logger.Warn("Creating an instance of an HtmlMesh with id ".concat(r," outside of a browser. The mesh will not be visible.")),u):(u._fitStrategy=d,u._isCanvasOverlay=c,u._createMask(),u._element=u._createElement(),u.setEnabled(!0),u._captureOnPointerEnter=a,u._pointerEventCaptureBehavior=new I(u.capturePointerEvents.bind(u),u.releasePointerEvents.bind(u),{captureOnPointerEnter:u._captureOnPointerEnter}),u.addBehavior(u._pointerEventCaptureBehavior),u)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}h(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(t,e),Object.defineProperty(t.prototype,"isHtmlMesh",{get:function(){return!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sourceWidth",{get:function(){return this._sourceWidth},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sourceHeight",{get:function(){return this._sourceHeight},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return this._width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this._height},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"element",{get:function(){return this._element},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"requiresUpdate",{get:function(){return this._requiresUpdate},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"captureOnPointerEnter",{set:function(e){this._captureOnPointerEnter=e,this._pointerEventCaptureBehavior&&(this._pointerEventCaptureBehavior.captureOnPointerEnter=e)},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){var t;e.prototype.dispose.call(this),null===(t=this._element)||void 0===t||t.remove(),this._element=void 0,this._pointerEventCaptureBehavior&&(this._pointerEventCaptureBehavior.dispose(),this._pointerEventCaptureBehavior=null)},t.prototype._markAsUpdated=function(){this._requiresUpdate=!1},t.prototype.setContent=function(e,t,r){this._setAsReady(!1),this._sourceWidth=null,this._sourceHeight=null,this._element&&(this._width=t,this._height=r,this._requiresUpdate=!0,this.scaling.setAll(1),e&&(this._element.appendChild(this._fitStrategy.wrapElement(e)),this._updateScaleIfNecessary()),this.sourceWidth&&this.sourceHeight&&this._setAsReady(!0))},t.prototype.setEnabled=function(e){this._enabled=e,e&&!this._ready||this._doSetEnabled(e)},t.prototype.setContentSizePx=function(e,t){this._sourceWidth=e,this._sourceHeight=t,this._element&&this._element.firstElementChild&&(this._fitStrategy.updateSize(this._element.firstElementChild,e,t),this._updateScaleIfNecessary(),this.width&&this.height&&this._setAsReady(!0))},t.prototype._setAsReady=function(e){this._ready=e,e?this._doSetEnabled(this._enabled):this._doSetEnabled(!1)},t.prototype._doSetEnabled=function(t){var r,i=this;this._element&&(t&&!this._worldMatrixUpdateObserver?this._worldMatrixUpdateObserver=this.onAfterWorldMatrixUpdateObservable.add((function(){i._requiresUpdate=!0})):t||(null===(r=this._worldMatrixUpdateObserver)||void 0===r||r.remove(),this._worldMatrixUpdateObserver=null),this._element.style.display=t?"":"none",this._setElementzIndex(-1e4*this.position.z),e.prototype.setEnabled.call(this,t))},t.prototype._updateScaleIfNecessary=function(){this.scaling.setAll(1),this._inverseScaleMatrix&&(this.bakeTransformIntoVertices(this._inverseScaleMatrix),this._inverseScaleMatrix=null);var e=this._width||1,t=this._height||1,r=s.Matrix.Scaling(e,t,1);this.bakeTransformIntoVertices(r),this._inverseScaleMatrix=new s.Matrix,r.invertToRef(this._inverseScaleMatrix)},t.prototype._createMask=function(){(0,s.CreatePlaneVertexData)({width:1,height:1}).applyToMesh(this);var e=this.getScene();this.checkCollisions=!0;var t=new s.StandardMaterial("".concat(this.id,"-mat"),e);this._isCanvasOverlay||(t.backFaceCulling=!1,t.disableColorWrite=!0,t.disableLighting=!0),this.material=t,this.material.freeze()},t.prototype._setElementzIndex=function(e){this._element&&(this._element.style.zIndex="".concat(e))},t.prototype.capturePointerEvents=function(){this._element&&(this._element.style.pointerEvents="auto",document.getElementsByTagName("body")[0].style.pointerEvents="none")},t.prototype.releasePointerEvents=function(){this._element&&(document.getElementsByTagName("body")[0].style.pointerEvents="auto",this._element.style.pointerEvents="none")},t.prototype._createElement=function(){if("undefined"!=typeof document){var e=document.createElement("div");return e.id=this.id,e.style.backgroundColor=this._isCanvasOverlay?"transparent":"#000",e.style.zIndex="1",e.style.position="absolute",e.style.pointerEvents="none",e.style.backfaceVisibility="hidden",e}},t}(s.Mesh);!function(e){e[e.SPACE=32]="SPACE",e[e.TOFU=65532]="TOFU"}(u||(u={}));var T=function(){function e(e,t,r){var i=this;this._chars=new Map,this._kernings=new Map,this._font=JSON.parse(e),this._font.pages=[t],this._font.chars.forEach((function(e){return i._chars.set(e.id,e)})),this._font.kernings.forEach((function(e){var t=i._kernings.get(e.first);t||(t=new Map,i._kernings.set(e.first,t)),t.set(e.second,e.amount)})),this._charsRegex=new RegExp("[".concat(this._font.chars.map((function(e){return e.char.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")})).join(""),"]"),"g"),this._updateFallbacks(),this.scale=1/this._font.info.size,this.textures=this._font.pages.map((function(e){var t=new s.Texture(e,r,{noMipmap:!1,invertY:!1});return t.anisotropicFilteringLevel=16,t}))}return e.prototype.dispose=function(){for(var e=0,t=this.textures;e<t.length;e++)t[e].dispose();this.textures.length=0},e.prototype._updateFallbacks=function(){this._chars.has(u.SPACE)||this._chars.set(u.SPACE,{id:u.SPACE,x:0,y:0,width:0,height:0,xoffset:0,yoffset:0,xadvance:.5*this._font.info.size,page:-1,chnl:-1,index:-1,char:" "}),this._chars.has(u.TOFU)||this._chars.set(u.TOFU,{id:u.TOFU,x:0,y:0,width:this._font.info.size,height:this._font.info.size,xoffset:0,yoffset:0,xadvance:.5*this._font.info.size,page:-1,chnl:-1,index:-1,char:"￿"})},e.prototype._getChar=function(e){return this._chars.get(e)||this._chars.get(u.TOFU)},e.prototype._getKerning=function(e,t){var r;return(null===(r=this._kernings.get(e))||void 0===r?void 0:r.get(t))||0},e.prototype._unsupportedChars=function(e){return e.replace(this._charsRegex,"")},e}(),D={maxWidth:1/0,lineHeight:1,letterSpacing:1,tabSize:4,whiteSpace:"pre-line",textAlign:"center",translate:{x:-.5,y:-.5}},k=function(){function e(e,t,r){this.text=e,this.fontAsset=t,this.options=d(d({},D),r);var i=this._computeMetrics(e),n=i.paragraph,o=i.lines,s=i.glyphs,a=i.width,l=i.height;this.paragraph=n,this.lines=o,this.glyphs=s,this.width=a,this.height=l}return Object.defineProperty(e.prototype,"lineHeight",{get:function(){return this.fontAsset._font.common.lineHeight*this.options.lineHeight},enumerable:!1,configurable:!0}),e.prototype._computeMetrics=function(e){for(var t=this,r=this._collapse(e),i=this._breakLines(r).map((function(e){return e.trim()})),n=[],o=0,s=i;o<s.length;o++){var a=s[o];n.push.apply(n,this._wrap(a,n.length))}var l=Math.max.apply(Math,n.map((function(e){return e.width}))),c=this.lineHeight*n.length;("left"!==this.options.textAlign||this.options.translate)&&n.forEach((function(e){for(var r=function(){switch(t.options.textAlign){case"right":return l-e.width;case"center":return(l-e.width)/2;default:return 0}}(),i=t.options.translate?t.options.translate.x*l:0,n=t.options.translate?t.options.translate.y*c:0,o=0,s=e.glyphs;o<s.length;o++){var a=s[o];a.x+=r,a.x+=i,a.y+=n}}));var h=n.flatMap((function(e){return e.glyphs}));return{paragraph:i.join("\n"),lines:n,glyphs:h,width:l,height:c}},e.prototype._breakLines=function(e){return e.split("\n")},e.prototype._collapse=function(e){return e.replace(/\t/g," ".repeat(this.options.tabSize)).replace(/ +/g," ")},e.prototype._wrap=function(e,t){void 0===t&&(t=0);for(var r,i=new Array,n=t,o=new Array,s=0,a=0,l=0,c=l,h=function(){i.push({text:e.slice(l,c),glyphs:o,start:l,end:c,width:a})};c<e.length;){var d=c,u=e.charCodeAt(d),f=this.fontAsset._getChar(u),p=f.width,v=(s+=r?this.fontAsset._getKerning(r.id,f.id):0)+p,m=f.xadvance+this.options.letterSpacing,_=s+m,g=_>this.options.maxWidth||v>this.options.maxWidth;g&&(h(),n++,r=void 0,s=0,a=0,c=(l=c)+1,o=[]);var y=s,x=n*this.lineHeight;o.push({char:f,line:n,position:o.length,x:y,y:x}),g?s=m:(r=f,s=_,a=v,c++)}return o.length>0&&h(),i},e}(),L=function(){function e(e,t,r){void 0===t&&(t=0),this._useVAO=!1,this._vertexBuffers={},this._charMatrices=new Array,this._charUvs=new Array,this._isDirty=!0,this._baseLine=0,this._scalingMatrix=new s.ThinMatrix,this._fontScaleMatrix=new s.ThinMatrix,this._offsetMatrix=new s.ThinMatrix,this._translationMatrix=new s.ThinMatrix,this._baseMatrix=new s.ThinMatrix,this._scaledMatrix=new s.ThinMatrix,this._localMatrix=new s.ThinMatrix,this._finalMatrix=new s.ThinMatrix,this._lineMatrix=new s.ThinMatrix,this._parentWorldMatrix=new s.ThinMatrix,this.color={r:1,g:1,b:1,a:1},this.strokeColor={r:1,g:1,b:1,a:1},this.strokeInsetWidth=0,this.strokeOutsetWidth=0,this.thicknessControl=0,this._parent=null,this._transformMatrix=new s.ThinMatrix,this.isBillboard=!1,this.isBillboardScreenProjected=!1,this.ignoreDepthBuffer=!1,this._engine=e,this._shaderLanguage=t,this._font=r,this._baseLine=r._font.common.lineHeight*r.scale,this._useVAO=e.getCaps().vertexArrayObject&&!e.disableVertexArrayObjects;var i=new Float32Array([0,0,1,0,0,1,1,1]);this._spriteBuffer=new s.Buffer(e,i,!1,2),this._vertexBuffers.offsets=this._spriteBuffer.createVertexBuffer("offsets",0,2),this._resizeBuffers(128)}return Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},set:function(e){this._parent=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transformMatrix",{get:function(){return this._transformMatrix},set:function(e){this._transformMatrix=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"characterCount",{get:function(){return this._charMatrices.length/16},enumerable:!1,configurable:!0}),e.prototype._resizeBuffers=function(e){this._worldBuffer&&(this._worldBuffer.dispose(),this._worldBuffer=null),this._uvBuffer&&(this._uvBuffer.dispose(),this._uvBuffer=null),this._worldBuffer=new s.Buffer(this._engine,new Float32Array(16*e),!0,16),this._vertexBuffers.world0=this._worldBuffer.createVertexBuffer("world0",0,4,16,!0),this._vertexBuffers.world1=this._worldBuffer.createVertexBuffer("world1",4,4,16,!0),this._vertexBuffers.world2=this._worldBuffer.createVertexBuffer("world2",8,4,16,!0),this._vertexBuffers.world3=this._worldBuffer.createVertexBuffer("world3",12,4,16,!0),this._uvBuffer=new s.Buffer(this._engine,new Float32Array(4*e),!0,4),this._vertexBuffers.uvs=this._uvBuffer.createVertexBuffer("uvs",0,4,4,!0)},e.prototype._setShaders=function(e,t){var r;null===(r=this._drawWrapperBase)||void 0===r||r.dispose(),this._drawWrapperBase=new s.DrawWrapper(this._engine),this._drawWrapperBase.drawContext&&(this._drawWrapperBase.drawContext.useInstancing=!0),this._drawWrapperBase.effect=this._engine.createEffect({vertexSource:e,fragmentSource:t},["offsets","world0","world1","world2","world3","uvs"],["parentWorld","view","projection","uColor","thickness","uStrokeColor","uStrokeInsetWidth","uStrokeOutsetWidth","mode","transform"],["fontAtlas"],"",void 0,void 0,void 0,void 0,this._shaderLanguage),this._drawWrapperBase.effect._refCount++},e.prototype.addParagraph=function(e,t,r){var i=this,n=new k(e,this._font,t),o=this._font.scale,a=this._font._font.common.scaleW,l=this._font._font.common.scaleH,c=n.glyphs.filter((function(e){return e.char.page>=0})),h=r;if(!h){var d=n.lineHeight*o,u=n.lines.length*d/2;(0,s.TranslationMatrixToRef)(0,this._baseLine-u,0,this._lineMatrix),h=this._lineMatrix}(0,s.ScalingMatrixToRef)(o,o,1,this._fontScaleMatrix),(0,s.TranslationMatrixToRef)(.5,-.5,0,this._offsetMatrix);var f=this._charUvs.length,p=this._charMatrices.length;c.forEach((function(e,t){i._charUvs[f+4*t+0]=e.char.x/a,i._charUvs[f+4*t+1]=e.char.y/l,i._charUvs[f+4*t+2]=e.char.width/a,i._charUvs[f+4*t+3]=e.char.height/l;var r=e.x+e.char.xoffset,n=1-(e.y+e.char.yoffset);(0,s.ScalingMatrixToRef)(e.char.width,e.char.height,1,i._scalingMatrix),(0,s.MultiplyMatricesToRef)(i._offsetMatrix,i._scalingMatrix,i._baseMatrix),(0,s.TranslationMatrixToRef)(r*o,n*o,0,i._translationMatrix),(0,s.MultiplyMatricesToRef)(i._baseMatrix,i._fontScaleMatrix,i._scaledMatrix),(0,s.MultiplyMatricesToRef)(i._scaledMatrix,i._translationMatrix,i._localMatrix),(0,s.MultiplyMatricesToRef)(i._localMatrix,h,i._finalMatrix),(0,s.CopyMatrixToArray)(i._finalMatrix,i._charMatrices,p+16*t)})),this._isDirty=!0,this._baseLine-=n.lineHeight*o*n.lines.length},e.prototype.render=function(e,t){var r=this._drawWrapperBase,i=r.effect;if(i.isReady()){var n=this._engine;n.setState(!1),n.enableEffect(r),this.ignoreDepthBuffer&&n.setDepthBuffer(!1),this._parent?(0,s.CopyMatrixToRef)(this._parent.getWorldMatrix(),this._parentWorldMatrix):(0,s.IdentityMatrixToRef)(this._parentWorldMatrix),i.setInt("mode",this.isBillboard?this.isBillboardScreenProjected?2:1:0),i.setMatrix("parentWorld",this._parentWorldMatrix),i.setMatrix("view",e),i.setMatrix("projection",t),i.setMatrix("transform",this.transformMatrix),i.setTexture("fontAtlas",this._font.textures[0]),i.setDirectColor4("uColor",this.color),i.setDirectColor4("uStrokeColor",this.strokeColor),i.setFloat("thickness",.9*this.thicknessControl),i.setFloat("uStrokeInsetWidth",this.strokeInsetWidth),i.setFloat("uStrokeOutsetWidth",this.strokeOutsetWidth);var o=this._charMatrices.length/16;this._isDirty&&(this._isDirty=!1,this._worldBuffer.getBuffer().capacity/4<16*o&&this._resizeBuffers(o),this._worldBuffer.update(this._charMatrices),this._uvBuffer.update(this._charUvs)),this._useVAO?(this._vertexArrayObject||(this._vertexArrayObject=n.recordVertexArrayObject(this._vertexBuffers,null,i)),n.bindVertexArrayObject(this._vertexArrayObject,null)):n.bindBuffers(this._vertexBuffers,null,i),n.setAlphaMode(s.Constants.ALPHA_COMBINE),n.drawArraysType(s.Constants.MATERIAL_TriangleStripDrawMode,0,4,o),n.unbindInstanceAttributes(),n.setAlphaMode(s.Constants.ALPHA_DISABLE),this.ignoreDepthBuffer&&n.setDepthBuffer(!0)}},e.prototype.dispose=function(){this._worldBuffer&&(this._worldBuffer.dispose(),this._worldBuffer=null),this._uvBuffer&&(this._uvBuffer.dispose(),this._uvBuffer=null),this._spriteBuffer&&(this._spriteBuffer.dispose(),this._spriteBuffer=null),this._vertexArrayObject&&(this._engine.releaseVertexArrayObject(this._vertexArrayObject),this._vertexArrayObject=null)},e.CreateTextRendererAsync=function(t,r){return n=this,o=void 0,a=function(){var n,o,s,a;return function(e,t){var r,i,n,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(l){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(r=1,i&&(n=2&a[0]?i.return:a[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,a[1])).done)return n;switch(i=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,i=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((n=(n=o.trys).length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){o.label=a[1];break}if(6===a[0]&&o.label<n[1]){o.label=n[1],n=a;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(a);break}n[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],i=0}finally{r=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,l])}}}(this,(function(l){switch(l.label){case 0:if(!r.getCaps().instancedArrays||!r._features.supportSpriteInstancing)throw new Error("Instanced arrays are required for MSDF text rendering.");return n=0,o="",s="",r.isWebGPU?(n=1,[4,Promise.resolve().then(i.bind(i,681))]):[3,3];case 1:return o=l.sent().msdfVertexShaderWGSL.shader,[4,Promise.resolve().then(i.bind(i,115))];case 2:return s=l.sent().msdfPixelShaderWGSL.shader,[3,6];case 3:return[4,Promise.resolve().then(i.bind(i,36))];case 4:return o=l.sent().msdfVertexShader.shader,[4,Promise.resolve().then(i.bind(i,370))];case 5:s=l.sent().msdfPixelShader.shader,l.label=6;case 6:return(a=new e(r,n,t))._setShaders(o,s),[2,a]}}))},new((s=void 0)||(s=Promise))((function(e,t){function r(e){try{l(a.next(e))}catch(e){t(e)}}function i(e){try{l(a.throw(e))}catch(e){t(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof s?n:new s((function(e){e(n)}))).then(r,i)}l((a=a.apply(n,o||[])).next())}));var n,o,s,a},e}(),j=i(36),z=i(370),V=i(681),U=i(115);const F=o;return n.default})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-addons",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-addons"]=t(require("babylonjs")):e.ADDONS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(e=>(()=>{"use strict";var t={36:(e,t,r)=>{r.r(t),r.d(t,{msdfVertexShader:()=>s});var i=r(597),n="msdfVertexShader",o="#define BILLBOARD 1\n#define BILLBOARDSCREENPROJECTED 2\nattribute vec2 offsets;attribute vec4 world0;attribute vec4 world1;attribute vec4 world2;attribute vec4 world3;attribute vec4 uvs;uniform mat4 transform;uniform mat4 parentWorld;uniform mat4 view;uniform mat4 projection;uniform vec3 center;uniform int mode;varying vec2 atlasUV;void main(void) {mat4 world=mat4(world0,world1,world2,world3);vec4 worldPos=transform*(world*vec4(offsets.xy-vec2(0.5,0.5),0.,1.0));if (mode>=BILLBOARD) {vec3 viewPos=(view*parentWorld*vec4(0.,0.,0.,1.0)).xyz; \nif (mode==BILLBOARDSCREENPROJECTED) {viewPos.x/=viewPos.z;viewPos.y/=viewPos.z;viewPos.z=1.0;}\ngl_Position=projection*vec4(viewPos+worldPos.xyz,1.0); } else {vec3 viewPos=(view*parentWorld*worldPos).xyz; \ngl_Position=projection*vec4(viewPos,1.0); }\natlasUV=vec2(uvs.x+offsets.x*uvs.z,uvs.y+(1.0-offsets.y)*uvs.w);}";i.ShaderStore.ShadersStore[n]||(i.ShaderStore.ShadersStore[n]=o);var s={name:n,shader:o}},115:(e,t,r)=>{r.r(t),r.d(t,{msdfPixelShaderWGSL:()=>s});var i=r(597),n="msdfPixelShader",o="var fontAtlas: texture_2d<f32>;var fontAtlasSampler: sampler;uniform uColor: vec4f;uniform thickness: f32;uniform uStrokeColor: vec4f;uniform uStrokeInsetWidth: f32;uniform uStrokeOutsetWidth: f32;varying atlasUV: vec2f;fn median(msdf: vec3<f32>)->f32 {let a=min(msdf.r,msdf.g);let b=max(msdf.r,msdf.g);return max(a,min(b,msdf.b));}\n@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {let s=textureSample(fontAtlas,fontAtlasSampler,input.atlasUV).rgb;let sigDist=median(s)-0.5+uniforms.thickness;let afwidth=length(vec2<f32>(dpdx(sigDist),dpdy(sigDist)));let alpha=clamp(sigDist/afwidth+0.5,0.0,1.0);let sigDistOutset=sigDist+uniforms.uStrokeOutsetWidth*0.5;let sigDistInset=sigDist-uniforms.uStrokeInsetWidth*0.5;let afwidthOutset=length(vec2<f32>(dpdx(sigDistOutset),dpdy(sigDistOutset)));let afwidthInset=length(vec2<f32>(dpdx(sigDistInset),dpdy(sigDistInset)));let outset=clamp(sigDistOutset/afwidthOutset+0.5,0.0,1.0);let inset=1.0-clamp(sigDistInset/afwidthInset+0.5,0.0,1.0);let border=outset*inset;let filledFragColor=vec4<f32>(uniforms.uColor.rgb,alpha*uniforms.uColor.a);let strokedFragColor=vec4<f32>(uniforms.uStrokeColor.rgb,border*uniforms.uStrokeColor.a);fragmentOutputs.color=mix(filledFragColor,strokedFragColor,border);}";i.ShaderStore.ShadersStoreWGSL[n]||(i.ShaderStore.ShadersStoreWGSL[n]=o);var s={name:n,shader:o}},370:(e,t,r)=>{r.r(t),r.d(t,{msdfPixelShader:()=>s});var i=r(597),n="msdfPixelShader",o="#extension GL_OES_standard_derivatives : enable\nprecision highp float;uniform sampler2D fontAtlas;uniform vec4 uColor;uniform vec4 uStrokeColor;uniform float uStrokeInsetWidth;uniform float uStrokeOutsetWidth;uniform float thickness;varying vec2 atlasUV;float median(vec3 msdf) {return max(min(msdf.r,msdf.g),min(max(msdf.r,msdf.g),msdf.b));}\nvoid main(void)\n{vec3 s=texture2D(fontAtlas,atlasUV).rgb;float sigDist=median(s)-0.5+thickness;float alpha=clamp(sigDist/fwidth(sigDist)+0.5,0.0,1.0);float sigDistOutset=sigDist+uStrokeOutsetWidth*0.5;float sigDistInset=sigDist-uStrokeInsetWidth*0.5;float outset=clamp(sigDistOutset/fwidth(sigDistOutset)+0.5,0.0,1.0);float inset=1.0-clamp(sigDistInset/fwidth(sigDistInset)+0.5,0.0,1.0);float border=outset*inset;vec4 filledFragColor=vec4(uColor.rgb,alpha*uColor.a);vec4 strokedFragColor=vec4(uStrokeColor.rgb,border*uStrokeColor.a);gl_FragColor=mix(filledFragColor,strokedFragColor,border);}";i.ShaderStore.ShadersStore[n]||(i.ShaderStore.ShadersStore[n]=o);var s={name:n,shader:o}},597:t=>{t.exports=e},681:(e,t,r)=>{r.r(t),r.d(t,{msdfVertexShaderWGSL:()=>s});var i=r(597),n="msdfVertexShader",o="#define BILLBOARD 1\n#define BILLBOARDSCREENPROJECTED 2\nattribute offsets: vec2f;attribute world0: vec4f;attribute world1: vec4f;attribute world2: vec4f;attribute world3: vec4f;attribute uvs: vec4f;uniform transform: mat4x4f;uniform parentWorld: mat4x4f;uniform view: mat4x4f;uniform projection: mat4x4f;uniform mode: u32;varying atlasUV: vec2f;@vertex\nfn main(input: VertexInputs)->FragmentInputs {let world=mat4x4<f32>(input.world0,input.world1,input.world2,input.world3);let localOffset=vec4<f32>(input.offsets-vec2<f32>(0.5,0.5),0.0,1.0);let worldPos=uniforms.transform*world*localOffset;if (uniforms.mode>=BILLBOARD) { \nvar viewPos=(uniforms.view*uniforms.parentWorld*vec4f(0.,0.,0.,1.0)).xyz;if (uniforms.mode==BILLBOARDSCREENPROJECTED) {viewPos=vec3f(viewPos.x/viewPos.z,viewPos.y/viewPos.z,1.0);} \nvertexOutputs.position=uniforms.projection*vec4<f32>(viewPos+worldPos.xyz,1.0);} else { \nlet viewPos=(uniforms.view*uniforms.parentWorld*worldPos).xyz;vertexOutputs.position=uniforms.projection*vec4<f32>(viewPos,1.0);}\nvertexOutputs.atlasUV=vec2<f32>(\ninput.uvs.x+input.offsets.x*input.uvs.z,\ninput.uvs.y+(1.0-input.offsets.y)*input.uvs.w\n);}";i.ShaderStore.ShadersStoreWGSL[n]||(i.ShaderStore.ShadersStoreWGSL[n]=o);var s={name:n,shader:o}}},r={};function i(e){var n=r[e];if(void 0!==n)return n.exports;var o=r[e]={exports:{}};return t[e](o,o.exports,i),o.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};i.d(n,{default:()=>F});var o={};i.r(o),i.d(o,{DefaultParagraphOptions:()=>D,FitStrategy:()=>R,FontAsset:()=>T,HtmlMesh:()=>W,HtmlMeshRenderer:()=>c,PointerEventsCaptureBehavior:()=>I,SdfTextParagraph:()=>k,TextRenderer:()=>L,msdfPixelShader:()=>z.msdfPixelShader,msdfPixelShaderWGSL:()=>U.msdfPixelShaderWGSL,msdfVertexShader:()=>j.msdfVertexShader,msdfVertexShaderWGSL:()=>V.msdfVertexShaderWGSL});var s=i(597),a=100,l=function(e){return function(t,r){var i=t.getMesh(),n=r.getMesh(),o=i.isHtmlMesh,s=n.isHtmlMesh;return o?s&&i.absolutePosition.z<=n.absolutePosition.z?1:-1:s?1:e(t,r)}},c=function(){function e(e,t){var r=void 0===t?{}:t,i=r.parentContainerId,n=void 0===i?null:i,o=r._containerId,a=void 0===o?"css-container":o,l=r.enableOverlayRender,c=void 0===l||l,h=r.defaultOpaqueRenderOrder,d=void 0===h?s.RenderingGroup.PainterSortCompare:h,u=r.defaultAlphaTestRenderOrder,f=void 0===u?s.RenderingGroup.PainterSortCompare:u,p=r.defaultTransparentRenderOrder,v=void 0===p?s.RenderingGroup.defaultTransparentSortCompare:p,m=this;this._cache={cameraData:{fov:0,position:new s.Vector3,style:""},htmlMeshData:new WeakMap},this._width=0,this._height=0,this._heightHalf=0,this._temp={scaleTransform:new s.Vector3,rotationTransform:new s.Quaternion,positionTransform:new s.Vector3,objectMatrix:s.Matrix.Identity(),cameraWorldMatrix:s.Matrix.Identity(),cameraRotationMatrix:s.Matrix.Identity(),cameraWorldMatrixAsArray:new Array(16)},this._lastDevicePixelRatio=window.devicePixelRatio,this._cameraMatrixUpdated=!0,this._previousCanvasDocumentPosition={top:0,left:0},this._renderObserver=null,this._onCameraMatrixChanged=function(e){m._cameraWorldMatrix=e.getWorldMatrix(),m._cameraMatrixUpdated=!0},"undefined"!=typeof document&&(this._containerId=a,this._init(e,n,c,d,f,v))}return e.prototype.dispose=function(){var e,t;this._renderObserver&&(this._renderObserver.remove(),this._renderObserver=null),null===(e=this._overlayElements)||void 0===e||e.container.remove(),this._overlayElements=null,null===(t=this._inSceneElements)||void 0===t||t.container.remove(),this._inSceneElements=null},e.prototype._init=function(e,t,r,i,n,o){var s,a=this;if("undefined"!=typeof document){var c=t?document.getElementById(t):document.body;c||(c=document.body);var h="".concat(this._containerId,"_in_scene");if(this._inSceneElements=this._createRenderLayerElements(h),c.insertBefore(this._inSceneElements.container,c.firstChild),r){var d="".concat(this._containerId,"_overlay");this._overlayElements=this._createRenderLayerElements(d);var u=+(null!==(s=e.getEngine().getRenderingCanvas().style.zIndex)&&void 0!==s?s:"0")+1;this._overlayElements.container.style.zIndex="".concat(u),this._overlayElements.container.style.pointerEvents="none",c.insertBefore(this._overlayElements.container,c.firstChild)}this._engine=e.getEngine();var f,p,v=this._engine.getRenderingCanvasClientRect();if(!v)throw new Error("Failed to get client rect for rendering canvas");this._setSize(v.width,v.height),this._engine.onResizeObservable.add((function(){var e=a._engine.getRenderingCanvasClientRect();e&&a._setSize(e.width,e.height)}));var m=function(){var t=e.activeCamera;t&&(f=t.onProjectionMatrixChangedObservable.add((function(){a._onCameraMatrixChanged(t)})),p=t.onViewMatrixChangedObservable.add((function(){a._onCameraMatrixChanged(t)})))};m(),e.onActiveCameraChanged.add((function(){var t,r;f&&(null===(t=e.activeCamera)||void 0===t||t.onProjectionMatrixChangedObservable.remove(f)),p&&(null===(r=e.activeCamera)||void 0===r||r.onViewMatrixChangedObservable.remove(p)),m()}));var _=l(i),g=l(n),y=l(o);e.setRenderingOrder(0,_,g,y),this._renderObserver=e.onBeforeRenderObservable.add((function(){a._render(e,e.activeCamera)}))}},e.prototype._createRenderLayerElements=function(e){var t=document.getElementById(e);t&&t.remove();var r=document.createElement("div");r.id=e,r.style.position="absolute",r.style.width="100%",r.style.height="100%",r.style.zIndex="-1";var i=document.createElement("div");i.style.overflow="hidden";var n=document.createElement("div");return n.style.webkitTransformStyle="preserve-3d",n.style.transformStyle="preserve-3d",n.style.pointerEvents="none",i.appendChild(n),r.appendChild(i),{container:r,domElement:i,cameraElement:n}},e.prototype._getSize=function(){return{width:this._width,height:this._height}},e.prototype._setSize=function(e,t){if(this._width=e,this._height=t,this._heightHalf=this._height/2,this._inSceneElements&&this._overlayElements)for(var r=0,i=[this._inSceneElements.domElement,this._overlayElements.domElement,this._inSceneElements.cameraElement,this._overlayElements.cameraElement];r<i.length;r++){var n=i[r];n&&(n.style.width="".concat(e,"px"),n.style.height="".concat(t,"px"))}},e.prototype._getCameraCssMatrix=function(e){var t=e.m;return"matrix3d(".concat(this._epsilon(t[0]),",").concat(this._epsilon(-t[1]),",").concat(this._epsilon(t[2]),",").concat(this._epsilon(t[3]),",").concat(this._epsilon(t[4]),",").concat(this._epsilon(-t[5]),",").concat(this._epsilon(t[6]),",").concat(this._epsilon(t[7]),",").concat(this._epsilon(t[8]),",").concat(this._epsilon(-t[9]),",").concat(this._epsilon(t[10]),",").concat(this._epsilon(t[11]),",").concat(this._epsilon(t[12]),",").concat(this._epsilon(-t[13]),",").concat(this._epsilon(t[14]),",").concat(this._epsilon(t[15]),")")},e.prototype._getHtmlContentCssMatrix=function(e,t){var r=e.m,i=t?-1:1;return"matrix3d(".concat(this._epsilon(r[0]),",").concat(this._epsilon(r[1]),",").concat(this._epsilon(r[2]*-i),",").concat(this._epsilon(r[3]),",").concat(this._epsilon(-r[4]),",").concat(this._epsilon(-r[5]),",").concat(this._epsilon(r[6]*i),",").concat(this._epsilon(-r[7]),",").concat(this._epsilon(r[8]*-i),",").concat(this._epsilon(r[9]*-i),",").concat(this._epsilon(r[10]),",").concat(this._epsilon(r[11]*i),",").concat(this._epsilon(r[12]*i),",").concat(this._epsilon(r[13]*i),",").concat(this._epsilon(r[14]*i),",").concat(this._epsilon(r[15]),")")},e.prototype._getTransformationMatrix=function(e,t){var r;if(this._cameraWorldMatrix||(this._cameraWorldMatrix=null===(r=e.getScene().activeCamera)||void 0===r?void 0:r.getWorldMatrix()),!this._cameraWorldMatrix)return s.Matrix.Identity();var i=e.getWorldMatrix(),n=1,o=1;e.sourceWidth&&e.sourceHeight&&(n=e.width/(e.sourceWidth/a),o=e.height/(e.sourceHeight/a));var l=this._temp.scaleTransform,c=this._temp.rotationTransform,h=this._temp.positionTransform,d=this._temp.objectMatrix;i.decompose(l,c,h),l.x*=n,l.y*=o,s.Matrix.ComposeToRef(l,c,h,d);var u=t?-1:1,f=e.getAbsolutePosition();return d.setRowFromFloats(3,(-this._cameraWorldMatrix.m[12]+f.x)*a*u,(-this._cameraWorldMatrix.m[13]+f.y)*a*u,(this._cameraWorldMatrix.m[14]-f.z)*a,1e-5*this._cameraWorldMatrix.m[15]*a),d.multiplyAtIndex(3,a),d.multiplyAtIndex(7,a),d.multiplyAtIndex(11,a),d},e.prototype._renderHtmlMesh=function(e,t){var r,i;if(e.element&&e.element.firstElementChild){var n=this._cache.htmlMeshData.get(e);n||(n={style:""},this._cache.htmlMeshData.set(e,n));var o=e._isCanvasOverlay?null===(r=this._overlayElements)||void 0===r?void 0:r.cameraElement:null===(i=this._inSceneElements)||void 0===i?void 0:i.cameraElement;e.element.parentNode!==o&&o.appendChild(e.element),e.requiresUpdate&&this._updateBaseScaleFactor(e);var a=this._getTransformationMatrix(e,t),l="translate(-50%, -50%) ".concat(this._getHtmlContentCssMatrix(a,t));l+="".concat(t?"matrix3d(".concat(e.billboardMode!==s.TransformNode.BILLBOARDMODE_NONE?1:-1,", 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1)"):""),n.style!==l&&(e.element.style.webkitTransform=l,e.element.style.transform=l),e._markAsUpdated()}},e.prototype._render=function(e,t){var r,i,n,o,a=!1,l=e.useRightHandedSystem;this._updateContainerPositionIfNeeded(),this._cameraMatrixUpdated&&(this._cameraMatrixUpdated=!1,a=!0),t.position.x===this._cache.cameraData.position.x&&t.position.y===this._cache.cameraData.position.y&&t.position.z===this._cache.cameraData.position.z||(this._cache.cameraData.position.copyFrom(t.position),a=!0),window.devicePixelRatio!==this._lastDevicePixelRatio&&(this._lastDevicePixelRatio=window.devicePixelRatio,s.Logger.Log("In render - dpr changed: ",this._lastDevicePixelRatio),a=!0);var c=e.meshes.filter((function(e){return e.isHtmlMesh&&(a||e.requiresUpdate)}));if(a=a||c.length>0){var h=t.getProjectionMatrix().m[5]*this._heightHalf;if(this._cache.cameraData.fov!==h){var d=[null===(r=this._overlayElements)||void 0===r?void 0:r.domElement,null===(i=this._inSceneElements)||void 0===i?void 0:i.domElement];if(t.mode==s.Camera.PERSPECTIVE_CAMERA)for(var u=0,f=d;u<f.length;u++)(M=f[u])&&(M.style.webkitPerspective=h+"px",M.style.perspective=h+"px");else for(var p=0,v=d;p<v.length;p++)(M=v[p])&&(M.style.webkitPerspective="",M.style.perspective="");this._cache.cameraData.fov=h}null===t.parent&&t.computeWorldMatrix();var m=this._temp.cameraWorldMatrix;m.copyFrom(t.getWorldMatrix());var _=this._temp.cameraRotationMatrix;m.getRotationMatrix().transposeToRef(_);var g=this._temp.cameraWorldMatrixAsArray;m.copyToArray(g);var y=l?1:-1;g[1]=_.m[1],g[2]=_.m[2]*y,g[4]=_.m[4]*y,g[6]=_.m[6]*y,g[8]=_.m[8]*y,g[9]=_.m[9]*y,s.Matrix.FromArrayToRef(g,0,m);var x=this._getCameraCssMatrix(m);if(this._cache.cameraData.style!==x){for(var b=0,w=d=[null===(n=this._inSceneElements)||void 0===n?void 0:n.cameraElement,null===(o=this._overlayElements)||void 0===o?void 0:o.cameraElement];b<w.length;b++){var M;(M=w[b])&&(M.style.webkitTransform=x,M.style.transform=x)}this._cache.cameraData.style=x}for(var S=0,E=c;S<E.length;S++){var C=E[S];this._renderHtmlMesh(C,l)}}},e.prototype._updateBaseScaleFactor=function(e){var t=this._width,r=this._height,i=(e.width||1)/(e.height||1);i>t/r?t=r*i:r=t/i,e.setContentSizePx(t,r)},e.prototype._updateContainerPositionIfNeeded=function(){var e,t,r=this._engine.getRenderingCanvasClientRect();if(r){var i=window.scrollY,n=window.scrollX,o=r.top+i,a=r.left+n;if(this._previousCanvasDocumentPosition.top!==o||this._previousCanvasDocumentPosition.left!==a){this._previousCanvasDocumentPosition.top=o,this._previousCanvasDocumentPosition.left=a;for(var l=0,c=[null===(e=this._inSceneElements)||void 0===e?void 0:e.container,null===(t=this._overlayElements)||void 0===t?void 0:t.container];l<c.length;l++){var h=c[l];if(h){var d=h.offsetParent,u=d.getBoundingClientRect(),f=u.top+i,p=u.left+n,v=this._getAncestorMarginsAndPadding(d),m=window.getComputedStyle(document.body),_=parseInt(m.marginTop,10),g=parseInt(m.marginLeft,10);h.style.top="".concat(o-f-v.marginTop+v.paddingTop+_,"px"),h.style.left="".concat(a-p-v.marginLeft+v.paddingLeft+g,"px")}}}}else s.Logger.Warn("Failed to update html mesh renderer position due to failure to get canvas rect. HtmlMesh instances may not render correctly")},e.prototype._epsilon=function(e){return Math.abs(e)<1e-10?0:e},e.prototype._getAncestorMarginsAndPadding=function(e){for(var t=0,r=0,i=0,n=0;e&&e!==document.body&&e!==document.documentElement;){var o=window.getComputedStyle(e);t+=parseInt(o.marginTop,10),r+=parseInt(o.marginLeft,10),i+=parseInt(o.paddingTop,10),n+=parseInt(o.paddingLeft,10),e=e.offsetParent}return{marginTop:t,marginLeft:r,paddingTop:i,paddingLeft:n}},e}(),h=function(e,t){return h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},h(e,t)};var d=function(){return d=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},d.apply(this,arguments)};Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var u,f=[],p=new Map,v=[],m=null,_=function(e){M("In pointerEventsCapture.requestRelease - Pointer events release requested for ".concat(e)),e&&e!==m?g(e)?p.delete(e):(M("In pointerEventsCapture.requestRelease - Received release request ".concat(e," but no matching capture request was received")),v.includes(e)||v.push(e)):y()},g=function(e){var t=!1;return f=f.filter((function(r){return r!==e||(t=!0,M("In pointerEventsCapture.cancelRequest - Canceling pointer events capture request ".concat(e)),!1)})),t},y=function(){var e=w();M("In pointerEventsCapture.transferPointerEventsOwnership - Transferrring pointer events from ".concat(m," to ").concat(e)),x(),e&&b(e)},x=function(){var e;M("In pointerEventsCapture.doRelease - Releasing pointer events from ".concat(m)),m&&(null===(e=p.get(m))||void 0===e||e.release(),p.delete(m),m=null)},b=function(e){var t;e&&(null===(t=p.get(e))||void 0===t||t.capture()),m=e,M("In pointerEventsCapture.doCapture - Pointer events now captured by ".concat(e))},w=function(){return f.length>0?f.shift():null},M=function(e){("undefined"==typeof window||window["pointer-events-capture-debug"])&&s.Tools.Log("".concat(performance.now()," - game.scene.pointerEvents - ").concat(e,"\ncurrentOwner: ").concat(m,"\nqueue: ").concat(f,"\nunmatched: ").concat(v))},S=null,E=0,C=new WeakMap,O=function(e){"undefined"!=typeof document&&(0===E&&(document.addEventListener("pointermove",A),document.addEventListener("touchstart",A),S=null!=S?S:e,s.Logger.Log("PointerEventsCaptureBehavior: Starting observation of pointer move events."),S.onDisposeObservable.add(P)),E++)},P=function(){document.removeEventListener("pointermove",A),document.removeEventListener("touchstart",A),S=null,s.Logger.Log("PointerEventsCaptureBehavior: Stopping observation of pointer move events."),E=0},B=function(){"undefined"!=typeof document&&S&&--E<=0&&P()},A=function(e){if(S){var t=S.getEngine().getRenderingCanvasClientRect();if(t){var r,i="touches"in e?e.touches[0]:e,n=i.clientX,o=i.clientY,s=n-t.left,a=o-t.top,l=S.pick(s,a,(function(e){var t=C.get(e);return e.isEnabled()&&void 0!==t&&t._captureOnPointerEnter}));r=l.hit?l.pickedMesh:null;var c=parseInt(m||"");r&&r.uniqueId===c||(!c||r&&r.uniqueId===c||_(m),r&&C.get(r).capturePointerEvents())}}},I=function(){function e(e,t,r){var i=(void 0===r?{}:r).captureOnPointerEnter,n=void 0===i||i;this._captureCallback=e,this._releaseCallback=t,this.name="PointerEventsCaptureBehavior",this._attachedMesh=null,this._captureOnPointerEnter=n,"undefined"==typeof document&&s.Logger.Warn("Creating an instance of PointerEventsCaptureBehavior outside of a browser. The behavior will not work.")}return Object.defineProperty(e.prototype,"attachedMesh",{get:function(){return this._attachedMesh},set:function(e){this._attachedMesh=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"captureOnPointerEnter",{set:function(e){this._captureOnPointerEnter!==e&&(this._captureOnPointerEnter=e,this._attachedMesh&&(this._captureOnPointerEnter?O(this._attachedMesh.getScene()):B()))},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){this.attachedMesh=e,C.set(e,this),this._captureOnPointerEnter&&O(e.getScene())},e.prototype.detach=function(){this.attachedMesh&&(C.delete(this.attachedMesh),this._captureOnPointerEnter&&B(),this.attachedMesh=null)},e.prototype.dispose=function(){this.detach()},e.prototype.releasePointerEvents=function(){this.attachedMesh&&_(this.attachedMesh.uniqueId.toString())},e.prototype.capturePointerEvents=function(){var e,t,r;this.attachedMesh&&(e=this.attachedMesh.uniqueId.toString(),t=this._captureCallback,r=this._releaseCallback,M("In pointerEventsCapture.requestCapture - Pointer events capture requested for ".concat(e)),function(e){var t=!1;return v=v.filter((function(r){return r!==e||(t=!0,!1)})),t}(e)?M("In pointerEventsCapture.requestCapture - Capture request matched previous release request ".concat(e,". Cancelling capture request")):(e!==m&&function(e,t,r){M("In pointerEventsCapture.enqueueCaptureRequest - Enqueueing capture request for ".concat(e)),f.includes(e)||(f.push(e),p.set(e,{capture:t,release:r}))}(e,t,r),m||y()))},e}(),R={CONTAIN:{wrapElement:function(e){var t=document.createElement("div");t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center";var r=document.createElement("div");return r.style.visibility="hidden",r.appendChild(e),t.appendChild(r),t},updateSize:function(e,t,r){var i=e.firstElementChild;e.style.width="".concat(t,"px"),e.style.height="".concat(r,"px");var n=[i.offsetWidth,i.offsetHeight],o=n[0],s=n[1],a=Math.min(t/o,r/s);i.style.transform="scale(".concat(a,")"),i.style.visibility="visible"}},COVER:{wrapElement:function(e){var t=document.createElement("div");t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center",t.style.overflow="hidden";var r=document.createElement("div");return r.style.visibility="hidden",r.appendChild(e),t.appendChild(r),t},updateSize:function(e,t,r){var i=e.firstElementChild;e.style.width="".concat(t,"px"),e.style.height="".concat(r,"px");var n=[i.offsetWidth,i.offsetHeight],o=n[0],s=n[1],a=Math.max(t/o,r/s);i.style.transform="scale(".concat(a,")"),i.style.visibility="visible"}},STRETCH:{wrapElement:function(e){var t=document.createElement("div");t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center";var r=document.createElement("div");return r.style.visibility="hidden",r.appendChild(e),t.appendChild(r),t},updateSize:function(e,t,r){var i=e.firstElementChild;e.style.width="".concat(t,"px"),e.style.height="".concat(r,"px");var n=[i.offsetWidth,i.offsetHeight],o=n[0],s=n[1];i.style.transform="scale(".concat(t/o,", ").concat(r/s,")"),i.style.visibility="visible"}},NONE:{wrapElement:function(e){return e},updateSize:function(e,t,r){e&&(e.style.width="".concat(t,"px"),e.style.height="".concat(r,"px"))}}},W=function(e){function t(t,r,i){var n=void 0===i?{}:i,o=n.captureOnPointerEnter,a=void 0===o||o,l=n.isCanvasOverlay,c=void 0!==l&&l,h=n.fitStrategy,d=void 0===h?R.NONE:h,u=e.call(this,r,t)||this;return u._enabled=!1,u._ready=!1,u._isCanvasOverlay=!1,u._requiresUpdate=!0,u._inverseScaleMatrix=null,u._captureOnPointerEnter=!0,u._pointerEventCaptureBehavior=null,u._sourceWidth=null,u._sourceHeight=null,u._fitStrategy=R.NONE,"undefined"==typeof document?(s.Logger.Warn("Creating an instance of an HtmlMesh with id ".concat(r," outside of a browser. The mesh will not be visible.")),u):(u._fitStrategy=d,u._isCanvasOverlay=c,u._createMask(),u._element=u._createElement(),u.setEnabled(!0),u._captureOnPointerEnter=a,u._pointerEventCaptureBehavior=new I(u.capturePointerEvents.bind(u),u.releasePointerEvents.bind(u),{captureOnPointerEnter:u._captureOnPointerEnter}),u.addBehavior(u._pointerEventCaptureBehavior),u)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}h(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(t,e),Object.defineProperty(t.prototype,"isHtmlMesh",{get:function(){return!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sourceWidth",{get:function(){return this._sourceWidth},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sourceHeight",{get:function(){return this._sourceHeight},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return this._width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this._height},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"element",{get:function(){return this._element},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"requiresUpdate",{get:function(){return this._requiresUpdate},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"captureOnPointerEnter",{set:function(e){this._captureOnPointerEnter=e,this._pointerEventCaptureBehavior&&(this._pointerEventCaptureBehavior.captureOnPointerEnter=e)},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){var t;e.prototype.dispose.call(this),null===(t=this._element)||void 0===t||t.remove(),this._element=void 0,this._pointerEventCaptureBehavior&&(this._pointerEventCaptureBehavior.dispose(),this._pointerEventCaptureBehavior=null)},t.prototype._markAsUpdated=function(){this._requiresUpdate=!1},t.prototype.setContent=function(e,t,r){this._setAsReady(!1),this._sourceWidth=null,this._sourceHeight=null,this._element&&(this._width=t,this._height=r,this._requiresUpdate=!0,this.scaling.setAll(1),e&&(this._element.appendChild(this._fitStrategy.wrapElement(e)),this._updateScaleIfNecessary()),this.sourceWidth&&this.sourceHeight&&this._setAsReady(!0))},t.prototype.setEnabled=function(e){this._enabled=e,e&&!this._ready||this._doSetEnabled(e)},t.prototype.setContentSizePx=function(e,t){this._sourceWidth=e,this._sourceHeight=t,this._element&&this._element.firstElementChild&&(this._fitStrategy.updateSize(this._element.firstElementChild,e,t),this._updateScaleIfNecessary(),this.width&&this.height&&this._setAsReady(!0))},t.prototype._setAsReady=function(e){this._ready=e,e?this._doSetEnabled(this._enabled):this._doSetEnabled(!1)},t.prototype._doSetEnabled=function(t){var r,i=this;this._element&&(t&&!this._worldMatrixUpdateObserver?this._worldMatrixUpdateObserver=this.onAfterWorldMatrixUpdateObservable.add((function(){i._requiresUpdate=!0})):t||(null===(r=this._worldMatrixUpdateObserver)||void 0===r||r.remove(),this._worldMatrixUpdateObserver=null),this._element.style.display=t?"":"none",this._setElementzIndex(-1e4*this.position.z),e.prototype.setEnabled.call(this,t))},t.prototype._updateScaleIfNecessary=function(){this.scaling.setAll(1),this._inverseScaleMatrix&&(this.bakeTransformIntoVertices(this._inverseScaleMatrix),this._inverseScaleMatrix=null);var e=this._width||1,t=this._height||1,r=s.Matrix.Scaling(e,t,1);this.bakeTransformIntoVertices(r),this._inverseScaleMatrix=new s.Matrix,r.invertToRef(this._inverseScaleMatrix)},t.prototype._createMask=function(){(0,s.CreatePlaneVertexData)({width:1,height:1}).applyToMesh(this);var e=this.getScene();this.checkCollisions=!0;var t=new s.StandardMaterial("".concat(this.id,"-mat"),e);this._isCanvasOverlay||(t.backFaceCulling=!1,t.disableColorWrite=!0,t.disableLighting=!0),this.material=t,this.material.freeze()},t.prototype._setElementzIndex=function(e){this._element&&(this._element.style.zIndex="".concat(e))},t.prototype.capturePointerEvents=function(){this._element&&(this._element.style.pointerEvents="auto",document.getElementsByTagName("body")[0].style.pointerEvents="none")},t.prototype.releasePointerEvents=function(){this._element&&(document.getElementsByTagName("body")[0].style.pointerEvents="auto",this._element.style.pointerEvents="none")},t.prototype._createElement=function(){if("undefined"!=typeof document){var e=document.createElement("div");return e.id=this.id,e.style.backgroundColor=this._isCanvasOverlay?"transparent":"#000",e.style.zIndex="1",e.style.position="absolute",e.style.pointerEvents="none",e.style.backfaceVisibility="hidden",e}},t}(s.Mesh);!function(e){e[e.SPACE=32]="SPACE",e[e.TOFU=65532]="TOFU"}(u||(u={}));var T=function(){function e(e,t,r){var i=this;this._chars=new Map,this._kernings=new Map,this._font=JSON.parse(e),this._font.pages=[t],this._font.chars.forEach((function(e){return i._chars.set(e.id,e)})),this._font.kernings.forEach((function(e){var t=i._kernings.get(e.first);t||(t=new Map,i._kernings.set(e.first,t)),t.set(e.second,e.amount)})),this._charsRegex=new RegExp("[".concat(this._font.chars.map((function(e){return e.char.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")})).join(""),"]"),"g"),this._updateFallbacks(),this.scale=1/this._font.info.size,this.textures=this._font.pages.map((function(e){var t=new s.Texture(e,r,{noMipmap:!1,invertY:!1});return t.anisotropicFilteringLevel=16,t}))}return e.prototype.dispose=function(){for(var e=0,t=this.textures;e<t.length;e++)t[e].dispose();this.textures.length=0},e.prototype._updateFallbacks=function(){this._chars.has(u.SPACE)||this._chars.set(u.SPACE,{id:u.SPACE,x:0,y:0,width:0,height:0,xoffset:0,yoffset:0,xadvance:.5*this._font.info.size,page:-1,chnl:-1,index:-1,char:" "}),this._chars.has(u.TOFU)||this._chars.set(u.TOFU,{id:u.TOFU,x:0,y:0,width:this._font.info.size,height:this._font.info.size,xoffset:0,yoffset:0,xadvance:.5*this._font.info.size,page:-1,chnl:-1,index:-1,char:"￿"})},e.prototype._getChar=function(e){return this._chars.get(e)||this._chars.get(u.TOFU)},e.prototype._getKerning=function(e,t){var r;return(null===(r=this._kernings.get(e))||void 0===r?void 0:r.get(t))||0},e.prototype._unsupportedChars=function(e){return e.replace(this._charsRegex,"")},e}(),D={maxWidth:1/0,lineHeight:1,letterSpacing:1,tabSize:4,whiteSpace:"pre-line",textAlign:"center",translate:{x:-.5,y:-.5}},k=function(){function e(e,t,r){this.text=e,this.fontAsset=t,this.options=d(d({},D),r);var i=this._computeMetrics(e),n=i.paragraph,o=i.lines,s=i.glyphs,a=i.width,l=i.height;this.paragraph=n,this.lines=o,this.glyphs=s,this.width=a,this.height=l}return Object.defineProperty(e.prototype,"lineHeight",{get:function(){return this.fontAsset._font.common.lineHeight*this.options.lineHeight},enumerable:!1,configurable:!0}),e.prototype._computeMetrics=function(e){for(var t=this,r=this._collapse(e),i=this._breakLines(r).map((function(e){return e.trim()})),n=[],o=0,s=i;o<s.length;o++){var a=s[o];n.push.apply(n,this._wrap(a,n.length))}var l=Math.max.apply(Math,n.map((function(e){return e.width}))),c=this.lineHeight*n.length;("left"!==this.options.textAlign||this.options.translate)&&n.forEach((function(e){for(var r=function(){switch(t.options.textAlign){case"right":return l-e.width;case"center":return(l-e.width)/2;default:return 0}}(),i=t.options.translate?t.options.translate.x*l:0,n=t.options.translate?t.options.translate.y*c:0,o=0,s=e.glyphs;o<s.length;o++){var a=s[o];a.x+=r,a.x+=i,a.y+=n}}));var h=n.flatMap((function(e){return e.glyphs}));return{paragraph:i.join("\n"),lines:n,glyphs:h,width:l,height:c}},e.prototype._breakLines=function(e){return e.split("\n")},e.prototype._collapse=function(e){return e.replace(/\t/g," ".repeat(this.options.tabSize)).replace(/ +/g," ")},e.prototype._wrap=function(e,t){void 0===t&&(t=0);for(var r,i=new Array,n=t,o=new Array,s=0,a=0,l=0,c=l,h=function(){i.push({text:e.slice(l,c),glyphs:o,start:l,end:c,width:a})};c<e.length;){var d=c,u=e.charCodeAt(d),f=this.fontAsset._getChar(u),p=f.width,v=(s+=r?this.fontAsset._getKerning(r.id,f.id):0)+p,m=f.xadvance+this.options.letterSpacing,_=s+m,g=_>this.options.maxWidth||v>this.options.maxWidth;g&&(h(),n++,r=void 0,s=0,a=0,c=(l=c)+1,o=[]);var y=s,x=n*this.lineHeight;o.push({char:f,line:n,position:o.length,x:y,y:x}),g?s=m:(r=f,s=_,a=v,c++)}return o.length>0&&h(),i},e}(),L=function(){function e(e,t,r){void 0===t&&(t=0),this._useVAO=!1,this._vertexBuffers={},this._charMatrices=new Array,this._charUvs=new Array,this._isDirty=!0,this._baseLine=0,this._scalingMatrix=new s.ThinMatrix,this._fontScaleMatrix=new s.ThinMatrix,this._offsetMatrix=new s.ThinMatrix,this._translationMatrix=new s.ThinMatrix,this._baseMatrix=new s.ThinMatrix,this._scaledMatrix=new s.ThinMatrix,this._localMatrix=new s.ThinMatrix,this._finalMatrix=new s.ThinMatrix,this._lineMatrix=new s.ThinMatrix,this._parentWorldMatrix=new s.ThinMatrix,this.color={r:1,g:1,b:1,a:1},this.strokeColor={r:1,g:1,b:1,a:1},this.strokeInsetWidth=0,this.strokeOutsetWidth=0,this.thicknessControl=0,this._parent=null,this._transformMatrix=new s.ThinMatrix,this.isBillboard=!1,this.isBillboardScreenProjected=!1,this.ignoreDepthBuffer=!1,this._engine=e,this._shaderLanguage=t,this._font=r,this._baseLine=r._font.common.lineHeight*r.scale,this._useVAO=e.getCaps().vertexArrayObject&&!e.disableVertexArrayObjects;var i=new Float32Array([0,0,1,0,0,1,1,1]);this._spriteBuffer=new s.Buffer(e,i,!1,2),this._vertexBuffers.offsets=this._spriteBuffer.createVertexBuffer("offsets",0,2),this._resizeBuffers(128)}return Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},set:function(e){this._parent=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transformMatrix",{get:function(){return this._transformMatrix},set:function(e){this._transformMatrix=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"characterCount",{get:function(){return this._charMatrices.length/16},enumerable:!1,configurable:!0}),e.prototype._resizeBuffers=function(e){this._worldBuffer&&(this._worldBuffer.dispose(),this._worldBuffer=null),this._uvBuffer&&(this._uvBuffer.dispose(),this._uvBuffer=null),this._worldBuffer=new s.Buffer(this._engine,new Float32Array(16*e),!0,16),this._vertexBuffers.world0=this._worldBuffer.createVertexBuffer("world0",0,4,16,!0),this._vertexBuffers.world1=this._worldBuffer.createVertexBuffer("world1",4,4,16,!0),this._vertexBuffers.world2=this._worldBuffer.createVertexBuffer("world2",8,4,16,!0),this._vertexBuffers.world3=this._worldBuffer.createVertexBuffer("world3",12,4,16,!0),this._uvBuffer=new s.Buffer(this._engine,new Float32Array(4*e),!0,4),this._vertexBuffers.uvs=this._uvBuffer.createVertexBuffer("uvs",0,4,4,!0)},e.prototype._setShaders=function(e,t){var r;null===(r=this._drawWrapperBase)||void 0===r||r.dispose(),this._drawWrapperBase=new s.DrawWrapper(this._engine),this._drawWrapperBase.drawContext&&(this._drawWrapperBase.drawContext.useInstancing=!0),this._drawWrapperBase.effect=this._engine.createEffect({vertexSource:e,fragmentSource:t},["offsets","world0","world1","world2","world3","uvs"],["parentWorld","view","projection","uColor","thickness","uStrokeColor","uStrokeInsetWidth","uStrokeOutsetWidth","mode","transform"],["fontAtlas"],"",void 0,void 0,void 0,void 0,this._shaderLanguage),this._drawWrapperBase.effect._refCount++},e.prototype.addParagraph=function(e,t,r){var i=this,n=new k(e,this._font,t),o=this._font.scale,a=this._font._font.common.scaleW,l=this._font._font.common.scaleH,c=n.glyphs.filter((function(e){return e.char.page>=0})),h=r;if(!h){var d=n.lineHeight*o,u=n.lines.length*d/2;(0,s.TranslationMatrixToRef)(0,this._baseLine-u,0,this._lineMatrix),h=this._lineMatrix}(0,s.ScalingMatrixToRef)(o,o,1,this._fontScaleMatrix),(0,s.TranslationMatrixToRef)(.5,-.5,0,this._offsetMatrix);var f=this._charUvs.length,p=this._charMatrices.length;c.forEach((function(e,t){i._charUvs[f+4*t+0]=e.char.x/a,i._charUvs[f+4*t+1]=e.char.y/l,i._charUvs[f+4*t+2]=e.char.width/a,i._charUvs[f+4*t+3]=e.char.height/l;var r=e.x+e.char.xoffset,n=1-(e.y+e.char.yoffset);(0,s.ScalingMatrixToRef)(e.char.width,e.char.height,1,i._scalingMatrix),(0,s.MultiplyMatricesToRef)(i._offsetMatrix,i._scalingMatrix,i._baseMatrix),(0,s.TranslationMatrixToRef)(r*o,n*o,0,i._translationMatrix),(0,s.MultiplyMatricesToRef)(i._baseMatrix,i._fontScaleMatrix,i._scaledMatrix),(0,s.MultiplyMatricesToRef)(i._scaledMatrix,i._translationMatrix,i._localMatrix),(0,s.MultiplyMatricesToRef)(i._localMatrix,h,i._finalMatrix),(0,s.CopyMatrixToArray)(i._finalMatrix,i._charMatrices,p+16*t)})),this._isDirty=!0,this._baseLine-=n.lineHeight*o*n.lines.length},e.prototype.render=function(e,t){var r=this._drawWrapperBase,i=r.effect;if(i.isReady()){var n=this._engine;n.setState(!1),n.enableEffect(r),this.ignoreDepthBuffer&&n.setDepthBuffer(!1),this._parent?(0,s.CopyMatrixToRef)(this._parent.getWorldMatrix(),this._parentWorldMatrix):(0,s.IdentityMatrixToRef)(this._parentWorldMatrix),i.setInt("mode",this.isBillboard?this.isBillboardScreenProjected?2:1:0),i.setMatrix("parentWorld",this._parentWorldMatrix),i.setMatrix("view",e),i.setMatrix("projection",t),i.setMatrix("transform",this.transformMatrix),i.setTexture("fontAtlas",this._font.textures[0]),i.setDirectColor4("uColor",this.color),i.setDirectColor4("uStrokeColor",this.strokeColor),i.setFloat("thickness",.9*this.thicknessControl),i.setFloat("uStrokeInsetWidth",this.strokeInsetWidth),i.setFloat("uStrokeOutsetWidth",this.strokeOutsetWidth);var o=this._charMatrices.length/16;this._isDirty&&(this._isDirty=!1,this._worldBuffer.getBuffer().capacity/4<16*o&&this._resizeBuffers(o),this._worldBuffer.update(this._charMatrices),this._uvBuffer.update(this._charUvs)),this._useVAO?(this._vertexArrayObject||(this._vertexArrayObject=n.recordVertexArrayObject(this._vertexBuffers,null,i)),n.bindVertexArrayObject(this._vertexArrayObject,null)):n.bindBuffers(this._vertexBuffers,null,i),n.setAlphaMode(s.Constants.ALPHA_COMBINE),n.drawArraysType(s.Constants.MATERIAL_TriangleStripDrawMode,0,4,o),n.unbindInstanceAttributes(),n.setAlphaMode(s.Constants.ALPHA_DISABLE),this.ignoreDepthBuffer&&n.setDepthBuffer(!0)}},e.prototype.dispose=function(){this._worldBuffer&&(this._worldBuffer.dispose(),this._worldBuffer=null),this._uvBuffer&&(this._uvBuffer.dispose(),this._uvBuffer=null),this._spriteBuffer&&(this._spriteBuffer.dispose(),this._spriteBuffer=null),this._vertexArrayObject&&(this._engine.releaseVertexArrayObject(this._vertexArrayObject),this._vertexArrayObject=null)},e.CreateTextRendererAsync=function(t,r){return n=this,o=void 0,a=function(){var n,o,s,a;return function(e,t){var r,i,n,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(l){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(r=1,i&&(n=2&a[0]?i.return:a[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,a[1])).done)return n;switch(i=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,i=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((n=(n=o.trys).length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){o.label=a[1];break}if(6===a[0]&&o.label<n[1]){o.label=n[1],n=a;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(a);break}n[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],i=0}finally{r=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,l])}}}(this,(function(l){switch(l.label){case 0:if(!r.getCaps().instancedArrays||!r._features.supportSpriteInstancing)throw new Error("Instanced arrays are required for MSDF text rendering.");return n=0,o="",s="",r.isWebGPU?(n=1,[4,Promise.resolve().then(i.bind(i,681))]):[3,3];case 1:return o=l.sent().msdfVertexShaderWGSL.shader,[4,Promise.resolve().then(i.bind(i,115))];case 2:return s=l.sent().msdfPixelShaderWGSL.shader,[3,6];case 3:return[4,Promise.resolve().then(i.bind(i,36))];case 4:return o=l.sent().msdfVertexShader.shader,[4,Promise.resolve().then(i.bind(i,370))];case 5:s=l.sent().msdfPixelShader.shader,l.label=6;case 6:return(a=new e(r,n,t))._setShaders(o,s),[2,a]}}))},new((s=void 0)||(s=Promise))((function(e,t){function r(e){try{l(a.next(e))}catch(e){t(e)}}function i(e){try{l(a.throw(e))}catch(e){t(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof s?n:new s((function(e){e(n)}))).then(r,i)}l((a=a.apply(n,o||[])).next())}));var n,o,s,a},e}(),j=i(36),z=i(370),V=i(681),U=i(115);const F=o;return n.default})()));
2
2
  //# sourceMappingURL=babylonjs.addons.min.js.map