babylonjs-addons 8.8.5 → 8.9.0

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