babylonjs-addons 8.8.0 → 8.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/babylonjs.addons.js +12 -12
- package/babylonjs.addons.min.js +1 -1
- package/babylonjs.addons.min.js.map +1 -1
- package/package.json +2 -2
package/babylonjs.addons.min.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-addons",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-addons"]=t(require("babylonjs")):e.ADDONS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(e=>(()=>{"use strict";var t,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)return;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.asArray());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.CopyMatrixToArray)(this._parent.getWorldMatrix(),this._parentWorldMatrix.asArray()):(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,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.asArray());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.CopyMatrixToArray)(this._parent.getWorldMatrix(),this._parentWorldMatrix.asArray()):(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})()));
|
2
2
|
//# sourceMappingURL=babylonjs.addons.min.js.map
|