babylonjs-addons 8.3.1 → 8.4.1

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={597:t=>{t.exports=e}},n={};function i(e){var r=n[e];if(void 0!==r)return r.exports;var o=n[e]={exports:{}};return t[e](o,o.exports,i),o.exports}i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};i.d(r,{default:()=>j});var o={};i.r(o),i.d(o,{FitStrategy:()=>I,HtmlMesh:()=>T,HtmlMeshRenderer:()=>l,PointerEventsCaptureBehavior:()=>R});var a=i(597),s=100,c=function(e){return function(t,n){var i=t.getMesh(),r=n.getMesh(),o=i.isHtmlMesh,a=r.isHtmlMesh;return o?a&&i.absolutePosition.z<=r.absolutePosition.z?1:-1:a?1:e(t,n)}},l=function(){function e(e,t){var n=void 0===t?{}:t,i=n.parentContainerId,r=void 0===i?null:i,o=n._containerId,s=void 0===o?"css-container":o,c=n.enableOverlayRender,l=void 0===c||c,d=n.defaultOpaqueRenderOrder,h=void 0===d?a.RenderingGroup.PainterSortCompare:d,p=n.defaultAlphaTestRenderOrder,u=void 0===p?a.RenderingGroup.PainterSortCompare:p,v=n.defaultTransparentRenderOrder,m=void 0===v?a.RenderingGroup.defaultTransparentSortCompare:v,f=this;this._cache={cameraData:{fov:0,position:new a.Vector3,style:""},htmlMeshData:new WeakMap},this._width=0,this._height=0,this._heightHalf=0,this._temp={scaleTransform:new a.Vector3,rotationTransform:new a.Quaternion,positionTransform:new a.Vector3,objectMatrix:a.Matrix.Identity(),cameraWorldMatrix:a.Matrix.Identity(),cameraRotationMatrix:a.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){f._cameraWorldMatrix=e.getWorldMatrix(),f._cameraMatrixUpdated=!0},"undefined"!=typeof document&&(this._containerId=s,this._init(e,r,l,h,u,m))}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,i,r,o){var a,s=this;if("undefined"!=typeof document){var l=t?document.getElementById(t):document.body;l||(l=document.body);var d="".concat(this._containerId,"_in_scene");if(this._inSceneElements=this._createRenderLayerElements(d),l.insertBefore(this._inSceneElements.container,l.firstChild),n){var h="".concat(this._containerId,"_overlay");this._overlayElements=this._createRenderLayerElements(h);var p=+(null!==(a=e.getEngine().getRenderingCanvas().style.zIndex)&&void 0!==a?a:"0")+1;this._overlayElements.container.style.zIndex="".concat(p),this._overlayElements.container.style.pointerEvents="none",l.insertBefore(this._overlayElements.container,l.firstChild)}this._engine=e.getEngine();var u,v,m=this._engine.getRenderingCanvasClientRect();if(!m)throw new Error("Failed to get client rect for rendering canvas");this._setSize(m.width,m.height),this._engine.onResizeObservable.add((function(){var e=s._engine.getRenderingCanvasClientRect();e&&s._setSize(e.width,e.height)}));var f=function(){var t=e.activeCamera;t&&(u=t.onProjectionMatrixChangedObservable.add((function(){s._onCameraMatrixChanged(t)})),v=t.onViewMatrixChangedObservable.add((function(){s._onCameraMatrixChanged(t)})))};f(),e.onActiveCameraChanged.add((function(){var t,n;u&&(null===(t=e.activeCamera)||void 0===t||t.onProjectionMatrixChangedObservable.remove(u)),v&&(null===(n=e.activeCamera)||void 0===n||n.onViewMatrixChangedObservable.remove(v)),f()}));var _=c(i),y=c(r),g=c(o);e.setRenderingOrder(0,_,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 n=document.createElement("div");n.id=e,n.style.position="absolute",n.style.width="100%",n.style.height="100%",n.style.zIndex="-1";var i=document.createElement("div");i.style.overflow="hidden";var r=document.createElement("div");return r.style.webkitTransformStyle="preserve-3d",r.style.transformStyle="preserve-3d",r.style.pointerEvents="none",i.appendChild(r),n.appendChild(i),{container:n,domElement:i,cameraElement:r}},e.prototype._getSize=function(){return{width:this._width,height:this._height}},e.prototype._setSize=function(e,t){this._width=e,this._height=t,this._heightHalf=this._height/2,this._inSceneElements&&this._overlayElements&&[this._inSceneElements.domElement,this._overlayElements.domElement,this._inSceneElements.cameraElement,this._overlayElements.cameraElement].forEach((function(n){n&&(n.style.width="".concat(e,"px"),n.style.height="".concat(t,"px"))}))},e.prototype._getCameraCSSMatrix=function(e){var t=e.m;return"matrix3d(".concat(this._epsilon(t[0]),",").concat(this._epsilon(-t[1]),",").concat(this._epsilon(t[2]),",").concat(this._epsilon(t[3]),",").concat(this._epsilon(t[4]),",").concat(this._epsilon(-t[5]),",").concat(this._epsilon(t[6]),",").concat(this._epsilon(t[7]),",").concat(this._epsilon(t[8]),",").concat(this._epsilon(-t[9]),",").concat(this._epsilon(t[10]),",").concat(this._epsilon(t[11]),",").concat(this._epsilon(t[12]),",").concat(this._epsilon(-t[13]),",").concat(this._epsilon(t[14]),",").concat(this._epsilon(t[15]),")")},e.prototype._getHtmlContentCSSMatrix=function(e,t){var n=e.m,i=t?-1:1;return"matrix3d(".concat(this._epsilon(n[0]),",").concat(this._epsilon(n[1]),",").concat(this._epsilon(n[2]*-i),",").concat(this._epsilon(n[3]),",").concat(this._epsilon(-n[4]),",").concat(this._epsilon(-n[5]),",").concat(this._epsilon(n[6]*i),",").concat(this._epsilon(-n[7]),",").concat(this._epsilon(n[8]*-i),",").concat(this._epsilon(n[9]*-i),",").concat(this._epsilon(n[10]),",").concat(this._epsilon(n[11]*i),",").concat(this._epsilon(n[12]*i),",").concat(this._epsilon(n[13]*i),",").concat(this._epsilon(n[14]*i),",").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 a.Matrix.Identity();var i=e.getWorldMatrix(),r=1,o=1;e.sourceWidth&&e.sourceHeight&&(r=e.width/(e.sourceWidth/s),o=e.height/(e.sourceHeight/s));var c=this._temp.scaleTransform,l=this._temp.rotationTransform,d=this._temp.positionTransform,h=this._temp.objectMatrix;i.decompose(c,l,d),c.x*=r,c.y*=o,a.Matrix.ComposeToRef(c,l,d,h);var p=t?-1:1,u=e.getAbsolutePosition();return h.setRowFromFloats(3,(-this._cameraWorldMatrix.m[12]+u.x)*s*p,(-this._cameraWorldMatrix.m[13]+u.y)*s*p,(this._cameraWorldMatrix.m[14]-u.z)*s,1e-5*this._cameraWorldMatrix.m[15]*s),h.multiplyAtIndex(3,s),h.multiplyAtIndex(7,s),h.multiplyAtIndex(11,s),h},e.prototype._renderHtmlMesh=function(e,t){var n,i;if(e.element&&e.element.firstElementChild){var r=this._cache.htmlMeshData.get(e);r||(r={style:""},this._cache.htmlMeshData.set(e,r));var o=e._isCanvasOverlay?null===(n=this._overlayElements)||void 0===n?void 0:n.cameraElement:null===(i=this._inSceneElements)||void 0===i?void 0:i.cameraElement;e.element.parentNode!==o&&o.appendChild(e.element),e.requiresUpdate&&this._updateBaseScaleFactor(e);var a=this._getTransformationMatrix(e,t),s="translate(-50%, -50%) ".concat(this._getHtmlContentCSSMatrix(a,t));s+="".concat(t?"matrix3d(-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1)":""),r.style!==s&&(e.element.style.webkitTransform=s,e.element.style.transform=s),e._markAsUpdated()}},e.prototype._render=function(e,t){var n,i,r,o,s,c,l=this,d=!1,h=e.useRightHandedSystem;this._updateContainerPositionIfNeeded(),this._cameraMatrixUpdated&&(this._cameraMatrixUpdated=!1,d=!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),d=!0),window.devicePixelRatio!==this._lastDevicePixelRatio&&(this._lastDevicePixelRatio=window.devicePixelRatio,a.Logger.Log("In render - dpr changed: ",this._lastDevicePixelRatio),d=!0);var p=e.meshes.filter((function(e){return e.isHtmlMesh&&(d||e.requiresUpdate)}));if(d=d||p.length>0){var u=t.getProjectionMatrix().m[5]*this._heightHalf;this._cache.cameraData.fov!==u&&(t.mode==a.Camera.PERSPECTIVE_CAMERA?[null===(n=this._overlayElements)||void 0===n?void 0:n.domElement,null===(i=this._inSceneElements)||void 0===i?void 0:i.domElement].forEach((function(e){e&&(e.style.webkitPerspective=u+"px",e.style.perspective=u+"px")})):[null===(r=this._overlayElements)||void 0===r?void 0:r.domElement,null===(o=this._inSceneElements)||void 0===o?void 0:o.domElement].forEach((function(e){e&&(e.style.webkitPerspective="",e.style.perspective="")})),this._cache.cameraData.fov=u),null===t.parent&&t.computeWorldMatrix();var v=this._temp.cameraWorldMatrix;v.copyFrom(t.getWorldMatrix());var m=this._temp.cameraRotationMatrix;v.getRotationMatrix().transposeToRef(m);var f=this._temp.cameraWorldMatrixAsArray;v.copyToArray(f);var _=h?1:-1;f[1]=m.m[1],f[2]=m.m[2]*_,f[4]=m.m[4]*_,f[6]=m.m[6]*_,f[8]=m.m[8]*_,f[9]=m.m[9]*_,a.Matrix.FromArrayToRef(f,0,v);var y=this._getCameraCSSMatrix(v);this._cache.cameraData.style!==y&&([null===(s=this._inSceneElements)||void 0===s?void 0:s.cameraElement,null===(c=this._overlayElements)||void 0===c?void 0:c.cameraElement].forEach((function(e){e&&(e.style.webkitTransform=y,e.style.transform=y)})),this._cache.cameraData.style=y),p.forEach((function(e){l._renderHtmlMesh(e,h)}))}},e.prototype._updateBaseScaleFactor=function(e){var t=this._width,n=this._height,i=(e.width||1)/(e.height||1);i>t/n?t=n*i:n=t/i,e.setContentSizePx(t,n)},e.prototype._updateContainerPositionIfNeeded=function(){var e,t,n=this,i=this._engine.getRenderingCanvasClientRect();if(i){var r=window.scrollY,o=window.scrollX,s=i.top+r,c=i.left+o;this._previousCanvasDocumentPosition.top===s&&this._previousCanvasDocumentPosition.left===c||(this._previousCanvasDocumentPosition.top=s,this._previousCanvasDocumentPosition.left=c,[null===(e=this._inSceneElements)||void 0===e?void 0:e.container,null===(t=this._overlayElements)||void 0===t?void 0:t.container].forEach((function(e){if(e){var t=e.offsetParent,i=t.getBoundingClientRect(),a=i.top+r,l=i.left+o,d=n._getAncestorMarginsAndPadding(t),h=window.getComputedStyle(document.body),p=parseInt(h.marginTop,10),u=parseInt(h.marginLeft,10);e.style.top="".concat(s-a-d.marginTop+d.paddingTop+p,"px"),e.style.left="".concat(c-l-d.marginLeft+d.paddingLeft+u,"px")}})))}else a.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,i=0,r=0;e&&e!==document.body&&e!==document.documentElement;){var o=window.getComputedStyle(e);t+=parseInt(o.marginTop,10),n+=parseInt(o.marginLeft,10),i+=parseInt(o.paddingTop,10),r+=parseInt(o.paddingLeft,10),e=e.offsetParent}return{marginTop:t,marginLeft:n,paddingTop:i,paddingLeft:r}},e}(),d=function(e,t){return d=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])},d(e,t)};Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var h=[],p=new Map,u=[],v=null,m=function(e){b("In pointerEventsCapture.requestRelease - Pointer events release requested for ".concat(e)),e&&e!==v?f(e)?p.delete(e):(b("In pointerEventsCapture.requestRelease - Received release request ".concat(e," but no matching capture request was received")),u.includes(e)||u.push(e)):_()},f=function(e){var t=!1;return h=h.filter((function(n){return n!==e||(t=!0,b("In pointerEventsCapture.cancelRequest - Canceling pointer events capture request ".concat(e)),!1)})),t},_=function(){var e=E();b("In pointerEventsCapture.transferPointerEventsOwnership - Transferrring pointer events from ".concat(v," to ").concat(e)),y(),e&&g(e)},y=function(){var e;b("In pointerEventsCapture.doRelease - Releasing pointer events from ".concat(v)),v&&(null===(e=p.get(v))||void 0===e||e.release(),p.delete(v),v=null)},g=function(e){var t;e&&(null===(t=p.get(e))||void 0===t||t.capture()),v=e,b("In pointerEventsCapture.doCapture - Pointer events now captured by ".concat(e))},E=function(){return h.length>0?h.shift():null},b=function(e){("undefined"==typeof window||window["pointer-events-capture-debug"])&&a.Tools.Log("".concat(performance.now()," - game.scene.pointerEvents - ").concat(e,"\ncurrentOwner: ").concat(v,"\nqueue: ").concat(h,"\nunmatched: ").concat(u))},C=null,x=0,M=new WeakMap,w=function(e){"undefined"!=typeof document&&(0===x&&(document.addEventListener("pointermove",O),document.addEventListener("touchstart",O),C=null!=C?C:e,a.Logger.Log("PointerEventsCaptureBehavior: Starting observation of pointer move events."),C.onDisposeObservable.add(P)),x++)},P=function(){document.removeEventListener("pointermove",O),document.removeEventListener("touchstart",O),C=null,a.Logger.Log("PointerEventsCaptureBehavior: Stopping observation of pointer move events."),x=0},S=function(){"undefined"!=typeof document&&C&&--x<=0&&P()},O=function(e){if(C){var t=C.getEngine().getRenderingCanvasClientRect();if(t){var n,i="touches"in e?e.touches[0]:e,r=i.clientX,o=i.clientY,a=r-t.left,s=o-t.top,c=C.pick(a,s,(function(e){var t=M.get(e);return e.isEnabled()&&void 0!==t&&t._captureOnPointerEnter}));n=c.hit?c.pickedMesh:null;var l=parseInt(v||"");n&&n.uniqueId===l||(!l||n&&n.uniqueId===l||m(v),n&&M.get(n).capturePointerEvents())}}},R=function(){function e(e,t,n){var i=(void 0===n?{}:n).captureOnPointerEnter,r=void 0===i||i;this._captureCallback=e,this._releaseCallback=t,this.name="PointerEventsCaptureBehavior",this._attachedMesh=null,this._captureOnPointerEnter=r,"undefined"==typeof document&&a.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?w(this._attachedMesh.getScene()):S()))},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){this.attachedMesh=e,M.set(e,this),this._captureOnPointerEnter&&w(e.getScene())},e.prototype.detach=function(){this.attachedMesh&&(M.delete(this.attachedMesh),this._captureOnPointerEnter&&S(),this.attachedMesh=null)},e.prototype.dispose=function(){this.detach()},e.prototype.releasePointerEvents=function(){this.attachedMesh&&m(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,b("In pointerEventsCapture.requestCapture - Pointer events capture requested for ".concat(e)),function(e){var t=!1;return u=u.filter((function(n){return n!==e||(t=!0,!1)})),t}(e)?b("In pointerEventsCapture.requestCapture - Capture request matched previous release request ".concat(e,". Cancelling capture request")):(e!==v&&function(e,t,n){b("In pointerEventsCapture.enqueueCaptureRequest - Enqueueing capture request for ".concat(e)),h.includes(e)||(h.push(e),p.set(e,{capture:t,release:n}))}(e,t,n),v||_()))},e}(),I={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 i=e.firstElementChild;e.style.width="".concat(t,"px"),e.style.height="".concat(n,"px");var r=[i.offsetWidth,i.offsetHeight],o=r[0],a=r[1],s=Math.min(t/o,n/a);i.style.transform="scale(".concat(s,")"),i.style.visibility="visible"}},COVER:{wrapElement:function(e){var t=document.createElement("div");t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center",t.style.overflow="hidden";var n=document.createElement("div");return n.style.visibility="hidden",n.appendChild(e),t.appendChild(n),t},updateSize:function(e,t,n){var i=e.firstElementChild;e.style.width="".concat(t,"px"),e.style.height="".concat(n,"px");var r=[i.offsetWidth,i.offsetHeight],o=r[0],a=r[1],s=Math.max(t/o,n/a);i.style.transform="scale(".concat(s,")"),i.style.visibility="visible"}},STRETCH:{wrapElement:function(e){var t=document.createElement("div");t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center";var n=document.createElement("div");return n.style.visibility="hidden",n.appendChild(e),t.appendChild(n),t},updateSize:function(e,t,n){var i=e.firstElementChild;e.style.width="".concat(t,"px"),e.style.height="".concat(n,"px");var r=[i.offsetWidth,i.offsetHeight],o=r[0],a=r[1];i.style.transform="scale(".concat(t/o,", ").concat(n/a,")"),i.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,i){var r=void 0===i?{}:i,o=r.captureOnPointerEnter,s=void 0===o||o,c=r.isCanvasOverlay,l=void 0!==c&&c,d=r.fitStrategy,h=void 0===d?I.NONE:d,p=e.call(this,n,t)||this;return p._enabled=!1,p._ready=!1,p._isCanvasOverlay=!1,p._requiresUpdate=!0,p._inverseScaleMatrix=null,p._captureOnPointerEnter=!0,p._pointerEventCaptureBehavior=null,p._sourceWidth=null,p._sourceHeight=null,p._fitStrategy=I.NONE,"undefined"==typeof document?(a.Logger.Warn("Creating an instance of an HtmlMesh with id ".concat(n," outside of a browser. The mesh will not be visible.")),p):(p._fitStrategy=h,p._isCanvasOverlay=l,p._createMask(),p._element=p._createElement(),p.setEnabled(!0),p._captureOnPointerEnter=s,p._pointerEventCaptureBehavior=new R(p.capturePointerEvents.bind(p),p.releasePointerEvents.bind(p),{captureOnPointerEnter:p._captureOnPointerEnter}),p.addBehavior(p._pointerEventCaptureBehavior),p)}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}d(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,i=this;this._element&&(t&&!this._worldMatrixUpdateObserver?this._worldMatrixUpdateObserver=this.onAfterWorldMatrixUpdateObservable.add((function(){i._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=a.Matrix.Scaling(e,t,1);this.bakeTransformIntoVertices(n),this._inverseScaleMatrix=new a.Matrix,n.invertToRef(this._inverseScaleMatrix)},t.prototype._createMask=function(){(0,a.CreatePlaneVertexData)({width:1,height:1}).applyToMesh(this);var e=this.getScene();this.checkCollisions=!0;var t=new a.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}(a.Mesh);const j=o;return r.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={597:t=>{t.exports=e}},n={};function i(e){var r=n[e];if(void 0!==r)return r.exports;var o=n[e]={exports:{}};return t[e](o,o.exports,i),o.exports}i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};i.d(r,{default:()=>j});var o={};i.r(o),i.d(o,{FitStrategy:()=>I,HtmlMesh:()=>T,HtmlMeshRenderer:()=>l,PointerEventsCaptureBehavior:()=>R});var a=i(597),s=100,c=function(e){return function(t,n){var i=t.getMesh(),r=n.getMesh(),o=i.isHtmlMesh,a=r.isHtmlMesh;return o?a&&i.absolutePosition.z<=r.absolutePosition.z?1:-1:a?1:e(t,n)}},l=function(){function e(e,t){var n=void 0===t?{}:t,i=n.parentContainerId,r=void 0===i?null:i,o=n._containerId,s=void 0===o?"css-container":o,c=n.enableOverlayRender,l=void 0===c||c,d=n.defaultOpaqueRenderOrder,h=void 0===d?a.RenderingGroup.PainterSortCompare:d,p=n.defaultAlphaTestRenderOrder,u=void 0===p?a.RenderingGroup.PainterSortCompare:p,v=n.defaultTransparentRenderOrder,m=void 0===v?a.RenderingGroup.defaultTransparentSortCompare:v,f=this;this._cache={cameraData:{fov:0,position:new a.Vector3,style:""},htmlMeshData:new WeakMap},this._width=0,this._height=0,this._heightHalf=0,this._temp={scaleTransform:new a.Vector3,rotationTransform:new a.Quaternion,positionTransform:new a.Vector3,objectMatrix:a.Matrix.Identity(),cameraWorldMatrix:a.Matrix.Identity(),cameraRotationMatrix:a.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){f._cameraWorldMatrix=e.getWorldMatrix(),f._cameraMatrixUpdated=!0},"undefined"!=typeof document&&(this._containerId=s,this._init(e,r,l,h,u,m))}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,i,r,o){var a,s=this;if("undefined"!=typeof document){var l=t?document.getElementById(t):document.body;l||(l=document.body);var d="".concat(this._containerId,"_in_scene");if(this._inSceneElements=this._createRenderLayerElements(d),l.insertBefore(this._inSceneElements.container,l.firstChild),n){var h="".concat(this._containerId,"_overlay");this._overlayElements=this._createRenderLayerElements(h);var p=+(null!==(a=e.getEngine().getRenderingCanvas().style.zIndex)&&void 0!==a?a:"0")+1;this._overlayElements.container.style.zIndex="".concat(p),this._overlayElements.container.style.pointerEvents="none",l.insertBefore(this._overlayElements.container,l.firstChild)}this._engine=e.getEngine();var u,v,m=this._engine.getRenderingCanvasClientRect();if(!m)throw new Error("Failed to get client rect for rendering canvas");this._setSize(m.width,m.height),this._engine.onResizeObservable.add((function(){var e=s._engine.getRenderingCanvasClientRect();e&&s._setSize(e.width,e.height)}));var f=function(){var t=e.activeCamera;t&&(u=t.onProjectionMatrixChangedObservable.add((function(){s._onCameraMatrixChanged(t)})),v=t.onViewMatrixChangedObservable.add((function(){s._onCameraMatrixChanged(t)})))};f(),e.onActiveCameraChanged.add((function(){var t,n;u&&(null===(t=e.activeCamera)||void 0===t||t.onProjectionMatrixChangedObservable.remove(u)),v&&(null===(n=e.activeCamera)||void 0===n||n.onViewMatrixChangedObservable.remove(v)),f()}));var _=c(i),y=c(r),g=c(o);e.setRenderingOrder(0,_,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 n=document.createElement("div");n.id=e,n.style.position="absolute",n.style.width="100%",n.style.height="100%",n.style.zIndex="-1";var i=document.createElement("div");i.style.overflow="hidden";var r=document.createElement("div");return r.style.webkitTransformStyle="preserve-3d",r.style.transformStyle="preserve-3d",r.style.pointerEvents="none",i.appendChild(r),n.appendChild(i),{container:n,domElement:i,cameraElement:r}},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,i=[this._inSceneElements.domElement,this._overlayElements.domElement,this._inSceneElements.cameraElement,this._overlayElements.cameraElement];n<i.length;n++){var r=i[n];r&&(r.style.width="".concat(e,"px"),r.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,i=t?-1:1;return"matrix3d(".concat(this._epsilon(n[0]),",").concat(this._epsilon(n[1]),",").concat(this._epsilon(n[2]*-i),",").concat(this._epsilon(n[3]),",").concat(this._epsilon(-n[4]),",").concat(this._epsilon(-n[5]),",").concat(this._epsilon(n[6]*i),",").concat(this._epsilon(-n[7]),",").concat(this._epsilon(n[8]*-i),",").concat(this._epsilon(n[9]*-i),",").concat(this._epsilon(n[10]),",").concat(this._epsilon(n[11]*i),",").concat(this._epsilon(n[12]*i),",").concat(this._epsilon(n[13]*i),",").concat(this._epsilon(n[14]*i),",").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 a.Matrix.Identity();var i=e.getWorldMatrix(),r=1,o=1;e.sourceWidth&&e.sourceHeight&&(r=e.width/(e.sourceWidth/s),o=e.height/(e.sourceHeight/s));var c=this._temp.scaleTransform,l=this._temp.rotationTransform,d=this._temp.positionTransform,h=this._temp.objectMatrix;i.decompose(c,l,d),c.x*=r,c.y*=o,a.Matrix.ComposeToRef(c,l,d,h);var p=t?-1:1,u=e.getAbsolutePosition();return h.setRowFromFloats(3,(-this._cameraWorldMatrix.m[12]+u.x)*s*p,(-this._cameraWorldMatrix.m[13]+u.y)*s*p,(this._cameraWorldMatrix.m[14]-u.z)*s,1e-5*this._cameraWorldMatrix.m[15]*s),h.multiplyAtIndex(3,s),h.multiplyAtIndex(7,s),h.multiplyAtIndex(11,s),h},e.prototype._renderHtmlMesh=function(e,t){var n,i;if(e.element&&e.element.firstElementChild){var r=this._cache.htmlMeshData.get(e);r||(r={style:""},this._cache.htmlMeshData.set(e,r));var o=e._isCanvasOverlay?null===(n=this._overlayElements)||void 0===n?void 0:n.cameraElement:null===(i=this._inSceneElements)||void 0===i?void 0:i.cameraElement;e.element.parentNode!==o&&o.appendChild(e.element),e.requiresUpdate&&this._updateBaseScaleFactor(e);var a=this._getTransformationMatrix(e,t),s="translate(-50%, -50%) ".concat(this._getHtmlContentCSSMatrix(a,t));s+="".concat(t?"matrix3d(-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1)":""),r.style!==s&&(e.element.style.webkitTransform=s,e.element.style.transform=s),e._markAsUpdated()}},e.prototype._render=function(e,t){var n,i,r,o,s=!1,c=e.useRightHandedSystem;this._updateContainerPositionIfNeeded(),this._cameraMatrixUpdated&&(this._cameraMatrixUpdated=!1,s=!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),s=!0),window.devicePixelRatio!==this._lastDevicePixelRatio&&(this._lastDevicePixelRatio=window.devicePixelRatio,a.Logger.Log("In render - dpr changed: ",this._lastDevicePixelRatio),s=!0);var l=e.meshes.filter((function(e){return e.isHtmlMesh&&(s||e.requiresUpdate)}));if(s=s||l.length>0){var d=t.getProjectionMatrix().m[5]*this._heightHalf;if(this._cache.cameraData.fov!==d){var h=[null===(n=this._overlayElements)||void 0===n?void 0:n.domElement,null===(i=this._inSceneElements)||void 0===i?void 0:i.domElement];if(t.mode==a.Camera.PERSPECTIVE_CAMERA)for(var p=0,u=h;p<u.length;p++)(x=u[p])&&(x.style.webkitPerspective=d+"px",x.style.perspective=d+"px");else for(var v=0,m=h;v<m.length;v++)(x=m[v])&&(x.style.webkitPerspective="",x.style.perspective="");this._cache.cameraData.fov=d}null===t.parent&&t.computeWorldMatrix();var f=this._temp.cameraWorldMatrix;f.copyFrom(t.getWorldMatrix());var _=this._temp.cameraRotationMatrix;f.getRotationMatrix().transposeToRef(_);var y=this._temp.cameraWorldMatrixAsArray;f.copyToArray(y);var g=c?1:-1;y[1]=_.m[1],y[2]=_.m[2]*g,y[4]=_.m[4]*g,y[6]=_.m[6]*g,y[8]=_.m[8]*g,y[9]=_.m[9]*g,a.Matrix.FromArrayToRef(y,0,f);var E=this._getCameraCSSMatrix(f);if(this._cache.cameraData.style!==E){for(var b=0,C=h=[null===(r=this._inSceneElements)||void 0===r?void 0:r.cameraElement,null===(o=this._overlayElements)||void 0===o?void 0:o.cameraElement];b<C.length;b++){var x;(x=C[b])&&(x.style.webkitTransform=E,x.style.transform=E)}this._cache.cameraData.style=E}for(var M=0,w=l;M<w.length;M++){var P=w[M];this._renderHtmlMesh(P,c)}}},e.prototype._updateBaseScaleFactor=function(e){var t=this._width,n=this._height,i=(e.width||1)/(e.height||1);i>t/n?t=n*i:n=t/i,e.setContentSizePx(t,n)},e.prototype._updateContainerPositionIfNeeded=function(){var e,t,n=this._engine.getRenderingCanvasClientRect();if(n){var i=window.scrollY,r=window.scrollX,o=n.top+i,s=n.left+r;if(this._previousCanvasDocumentPosition.top!==o||this._previousCanvasDocumentPosition.left!==s){this._previousCanvasDocumentPosition.top=o,this._previousCanvasDocumentPosition.left=s;for(var c=0,l=[null===(e=this._inSceneElements)||void 0===e?void 0:e.container,null===(t=this._overlayElements)||void 0===t?void 0:t.container];c<l.length;c++){var d=l[c];if(!d)return;var h=d.offsetParent,p=h.getBoundingClientRect(),u=p.top+i,v=p.left+r,m=this._getAncestorMarginsAndPadding(h),f=window.getComputedStyle(document.body),_=parseInt(f.marginTop,10),y=parseInt(f.marginLeft,10);d.style.top="".concat(o-u-m.marginTop+m.paddingTop+_,"px"),d.style.left="".concat(s-v-m.marginLeft+m.paddingLeft+y,"px")}}}else a.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,i=0,r=0;e&&e!==document.body&&e!==document.documentElement;){var o=window.getComputedStyle(e);t+=parseInt(o.marginTop,10),n+=parseInt(o.marginLeft,10),i+=parseInt(o.paddingTop,10),r+=parseInt(o.paddingLeft,10),e=e.offsetParent}return{marginTop:t,marginLeft:n,paddingTop:i,paddingLeft:r}},e}(),d=function(e,t){return d=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])},d(e,t)};Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var h=[],p=new Map,u=[],v=null,m=function(e){b("In pointerEventsCapture.requestRelease - Pointer events release requested for ".concat(e)),e&&e!==v?f(e)?p.delete(e):(b("In pointerEventsCapture.requestRelease - Received release request ".concat(e," but no matching capture request was received")),u.includes(e)||u.push(e)):_()},f=function(e){var t=!1;return h=h.filter((function(n){return n!==e||(t=!0,b("In pointerEventsCapture.cancelRequest - Canceling pointer events capture request ".concat(e)),!1)})),t},_=function(){var e=E();b("In pointerEventsCapture.transferPointerEventsOwnership - Transferrring pointer events from ".concat(v," to ").concat(e)),y(),e&&g(e)},y=function(){var e;b("In pointerEventsCapture.doRelease - Releasing pointer events from ".concat(v)),v&&(null===(e=p.get(v))||void 0===e||e.release(),p.delete(v),v=null)},g=function(e){var t;e&&(null===(t=p.get(e))||void 0===t||t.capture()),v=e,b("In pointerEventsCapture.doCapture - Pointer events now captured by ".concat(e))},E=function(){return h.length>0?h.shift():null},b=function(e){("undefined"==typeof window||window["pointer-events-capture-debug"])&&a.Tools.Log("".concat(performance.now()," - game.scene.pointerEvents - ").concat(e,"\ncurrentOwner: ").concat(v,"\nqueue: ").concat(h,"\nunmatched: ").concat(u))},C=null,x=0,M=new WeakMap,w=function(e){"undefined"!=typeof document&&(0===x&&(document.addEventListener("pointermove",O),document.addEventListener("touchstart",O),C=null!=C?C:e,a.Logger.Log("PointerEventsCaptureBehavior: Starting observation of pointer move events."),C.onDisposeObservable.add(P)),x++)},P=function(){document.removeEventListener("pointermove",O),document.removeEventListener("touchstart",O),C=null,a.Logger.Log("PointerEventsCaptureBehavior: Stopping observation of pointer move events."),x=0},S=function(){"undefined"!=typeof document&&C&&--x<=0&&P()},O=function(e){if(C){var t=C.getEngine().getRenderingCanvasClientRect();if(t){var n,i="touches"in e?e.touches[0]:e,r=i.clientX,o=i.clientY,a=r-t.left,s=o-t.top,c=C.pick(a,s,(function(e){var t=M.get(e);return e.isEnabled()&&void 0!==t&&t._captureOnPointerEnter}));n=c.hit?c.pickedMesh:null;var l=parseInt(v||"");n&&n.uniqueId===l||(!l||n&&n.uniqueId===l||m(v),n&&M.get(n).capturePointerEvents())}}},R=function(){function e(e,t,n){var i=(void 0===n?{}:n).captureOnPointerEnter,r=void 0===i||i;this._captureCallback=e,this._releaseCallback=t,this.name="PointerEventsCaptureBehavior",this._attachedMesh=null,this._captureOnPointerEnter=r,"undefined"==typeof document&&a.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?w(this._attachedMesh.getScene()):S()))},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){this.attachedMesh=e,M.set(e,this),this._captureOnPointerEnter&&w(e.getScene())},e.prototype.detach=function(){this.attachedMesh&&(M.delete(this.attachedMesh),this._captureOnPointerEnter&&S(),this.attachedMesh=null)},e.prototype.dispose=function(){this.detach()},e.prototype.releasePointerEvents=function(){this.attachedMesh&&m(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,b("In pointerEventsCapture.requestCapture - Pointer events capture requested for ".concat(e)),function(e){var t=!1;return u=u.filter((function(n){return n!==e||(t=!0,!1)})),t}(e)?b("In pointerEventsCapture.requestCapture - Capture request matched previous release request ".concat(e,". Cancelling capture request")):(e!==v&&function(e,t,n){b("In pointerEventsCapture.enqueueCaptureRequest - Enqueueing capture request for ".concat(e)),h.includes(e)||(h.push(e),p.set(e,{capture:t,release:n}))}(e,t,n),v||_()))},e}(),I={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 i=e.firstElementChild;e.style.width="".concat(t,"px"),e.style.height="".concat(n,"px");var r=[i.offsetWidth,i.offsetHeight],o=r[0],a=r[1],s=Math.min(t/o,n/a);i.style.transform="scale(".concat(s,")"),i.style.visibility="visible"}},COVER:{wrapElement:function(e){var t=document.createElement("div");t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center",t.style.overflow="hidden";var n=document.createElement("div");return n.style.visibility="hidden",n.appendChild(e),t.appendChild(n),t},updateSize:function(e,t,n){var i=e.firstElementChild;e.style.width="".concat(t,"px"),e.style.height="".concat(n,"px");var r=[i.offsetWidth,i.offsetHeight],o=r[0],a=r[1],s=Math.max(t/o,n/a);i.style.transform="scale(".concat(s,")"),i.style.visibility="visible"}},STRETCH:{wrapElement:function(e){var t=document.createElement("div");t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center";var n=document.createElement("div");return n.style.visibility="hidden",n.appendChild(e),t.appendChild(n),t},updateSize:function(e,t,n){var i=e.firstElementChild;e.style.width="".concat(t,"px"),e.style.height="".concat(n,"px");var r=[i.offsetWidth,i.offsetHeight],o=r[0],a=r[1];i.style.transform="scale(".concat(t/o,", ").concat(n/a,")"),i.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,i){var r=void 0===i?{}:i,o=r.captureOnPointerEnter,s=void 0===o||o,c=r.isCanvasOverlay,l=void 0!==c&&c,d=r.fitStrategy,h=void 0===d?I.NONE:d,p=e.call(this,n,t)||this;return p._enabled=!1,p._ready=!1,p._isCanvasOverlay=!1,p._requiresUpdate=!0,p._inverseScaleMatrix=null,p._captureOnPointerEnter=!0,p._pointerEventCaptureBehavior=null,p._sourceWidth=null,p._sourceHeight=null,p._fitStrategy=I.NONE,"undefined"==typeof document?(a.Logger.Warn("Creating an instance of an HtmlMesh with id ".concat(n," outside of a browser. The mesh will not be visible.")),p):(p._fitStrategy=h,p._isCanvasOverlay=l,p._createMask(),p._element=p._createElement(),p.setEnabled(!0),p._captureOnPointerEnter=s,p._pointerEventCaptureBehavior=new R(p.capturePointerEvents.bind(p),p.releasePointerEvents.bind(p),{captureOnPointerEnter:p._captureOnPointerEnter}),p.addBehavior(p._pointerEventCaptureBehavior),p)}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}d(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,i=this;this._element&&(t&&!this._worldMatrixUpdateObserver?this._worldMatrixUpdateObserver=this.onAfterWorldMatrixUpdateObservable.add((function(){i._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=a.Matrix.Scaling(e,t,1);this.bakeTransformIntoVertices(n),this._inverseScaleMatrix=new a.Matrix,n.invertToRef(this._inverseScaleMatrix)},t.prototype._createMask=function(){(0,a.CreatePlaneVertexData)({width:1,height:1}).applyToMesh(this);var e=this.getScene();this.checkCollisions=!0;var t=new a.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}(a.Mesh);const j=o;return r.default})()));
2
2
  //# sourceMappingURL=babylonjs.addons.min.js.map