BABYLON.Effect.ShadersStore.ellipse2dPixelShader="varying vec4 vColor;\nvoid main(void) {\ngl_FragColor=vColor;\n}",BABYLON.Effect.ShadersStore.ellipse2dVertexShader="\n#ifdef Instanced\n#define att attribute\n#else\n#define att uniform\n#endif\nattribute float index;\natt vec2 zBias;\natt vec4 transformX;\natt vec4 transformY;\natt vec3 renderingInfo;\natt float opacity;\n#ifdef Border\natt float borderThickness;\n#endif\n#ifdef FillSolid\natt vec4 fillSolidColor;\n#endif\n#ifdef BorderSolid\natt vec4 borderSolidColor;\n#endif\n#ifdef FillGradient\natt vec4 fillGradientColor1;\natt vec4 fillGradientColor2;\natt vec4 fillGradientTY;\n#endif\n#ifdef BorderGradient\natt vec4 borderGradientColor1;\natt vec4 borderGradientColor2;\natt vec4 borderGradientTY;\n#endif\n\natt vec3 properties;\n#define TWOPI 6.28318530\n\nvarying vec2 vUV;\nvarying vec4 vColor;\nvoid main(void) {\nvec2 pos2;\n#ifdef Border\nfloat w=properties.x;\nfloat h=properties.y;\nfloat ms=properties.z;\nvec2 borderOffset=vec2(1.0,1.0);\nfloat segi=index;\nif (indexrightPartUV) {\nuv.x=vTopLeftUV.x+vScale9.z+((vUV.x-rightPartUV)*vScaleFactor.x);\n}\nelse {\nfloat r=(vUV.x-leftPartUV)/(rightPartUV-leftPartUV);\nuv.x=vTopLeftUV.x+vScale9.x+((vScale9.z-vScale9.x)*r);\n}\n\nfloat topPartUV=(vTopLeftUV.y+(vScale9.y/vScaleFactor.y));\nfloat bottomPartUV=(vTopLeftUV.y+sizeUV.y-((sizeUV.y-vScale9.w)/vScaleFactor.y));\nif (vUV.ybottomPartUV) {\nuv.y=vTopLeftUV.y+vScale9.w+((vUV.y-bottomPartUV)*vScaleFactor.y);\n}\nelse {\nfloat r=(vUV.y-topPartUV)/(bottomPartUV-topPartUV);\nuv.y=vTopLeftUV.y+vScale9.y+((vScale9.w-vScale9.y)*r);\n}\n#endif\nvec4 color=texture2D(diffuseSampler,uv);\nif (alphaTest)\n{\nif (color.a<0.95) {\ndiscard;\n}\n}\ncolor.a*=vOpacity;\ngl_FragColor=color;\n}",BABYLON.Effect.ShadersStore.sprite2dVertexShader="\n#ifdef Instanced\n#define att attribute\n#else\n#define att uniform\n#endif\n\nattribute float index;\natt vec2 topLeftUV;\natt vec2 sizeUV;\n#ifdef Scale9\natt vec2 scaleFactor;\n#endif\natt vec2 textureSize;\n\natt vec3 properties;\n#ifdef Scale9\natt vec4 scale9;\n#endif\natt vec2 zBias;\natt vec4 transformX;\natt vec4 transformY;\natt vec3 renderingInfo;\natt float opacity;\n\n\nvarying vec2 vUV;\nvarying float vOpacity;\n#ifdef Scale9\nvarying vec2 vTopLeftUV;\nvarying vec2 vBottomRightUV;\nvarying vec4 vScale9;\nvarying vec2 vScaleFactor;\n#endif\nvoid main(void) {\nvec2 pos2;\nfloat frame=properties.x;\nfloat invertY=properties.y;\nfloat alignToPixel=properties.z;\n\nif (index == 0.0) {\npos2=vec2(0.0,0.0);\nvUV=vec2(topLeftUV.x+(frame*sizeUV.x),topLeftUV.y);\n}\n\nelse if (index == 1.0) {\npos2=vec2(0.0,1.0);\nvUV=vec2(topLeftUV.x+(frame*sizeUV.x),(topLeftUV.y+sizeUV.y));\n}\n\nelse if (index == 2.0) {\npos2=vec2( 1.0,1.0);\nvUV=vec2(topLeftUV.x+sizeUV.x+(frame*sizeUV.x),(topLeftUV.y+sizeUV.y));\n}\n\nelse if (index == 3.0) {\npos2=vec2( 1.0,0.0);\nvUV=vec2(topLeftUV.x+sizeUV.x+(frame*sizeUV.x),topLeftUV.y);\n}\nif (invertY == 1.0) {\nvUV.y=1.0-vUV.y;\n}\n\nvec4 pos;\n\n\n\n\npos.xy=pos2.xy*sizeUV*textureSize;\n\n#ifdef Scale9\nif (invertY == 1.0) {\nvTopLeftUV=vec2(topLeftUV.x,1.0-(topLeftUV.y+sizeUV.y));\nvBottomRightUV=vec2(topLeftUV.x+sizeUV.x,1.0-topLeftUV.y);\nvScale9=vec4(scale9.x,sizeUV.y-scale9.w,scale9.z,sizeUV.y-scale9.y);\n}\nelse {\nvTopLeftUV=topLeftUV;\nvBottomRightUV=vec2(topLeftUV.x+sizeUV.x,topLeftUV.y+sizeUV.y);\nvScale9=scale9;\n}\nvScaleFactor=scaleFactor;\n#endif\nvOpacity=opacity;\npos.z=1.0;\npos.w=1.0;\nfloat x=dot(pos,transformX);\nfloat y=dot(pos,transformY);\nif (renderingInfo.z == 1.0) {\nfloat rw=renderingInfo.x;\nfloat rh=renderingInfo.y;\nfloat irw=2.0/rw;\nfloat irh=2.0/rh;\nx=(floor((x/irw))*irw)+irw/2.0;\ny=(floor((y/irh))*irh)+irh/2.0;\n}\ngl_Position=vec4(x,y,zBias.x,1.0);\n} ",BABYLON.Effect.ShadersStore.text2dPixelShader="\nvarying vec4 vColor;\nvarying vec2 vUV;\n\nuniform sampler2D diffuseSampler;\nvoid main(void) {\n#ifdef SignedDistanceField\nfloat dist=texture2D(diffuseSampler,vUV).r;\nif (dist<0.5) {\ndiscard;\n}\n\n\n\n\n\ngl_FragColor=vec4(vColor.xyz*dist,vColor.a);\n#else\nvec4 color=texture2D(diffuseSampler,vUV);\nif (color.a == 0.0) {\ndiscard;\n}\n#ifdef FontTexture\ngl_FragColor=vec4(color.xxxx)*vColor;\n#else\ngl_FragColor=color*vColor;\n#endif\n#endif\n}",BABYLON.Effect.ShadersStore.text2dVertexShader="\n#ifdef Instanced\n#define att attribute\n#else\n#define att uniform\n#endif\n\nattribute float index;\natt vec2 zBias;\natt vec4 transformX;\natt vec4 transformY;\natt vec3 renderingInfo;\natt float opacity;\natt vec2 topLeftUV;\natt vec2 sizeUV;\natt vec2 textureSize;\natt vec4 color;\natt float superSampleFactor;\n\nvarying vec2 vUV;\nvarying vec4 vColor;\nvoid main(void) {\nvec2 pos2;\n\nif (index == 0.0) {\npos2=vec2(0.0,0.0);\nvUV=vec2(topLeftUV.x,topLeftUV.y+sizeUV.y);\n}\n\nelse if (index == 1.0) {\npos2=vec2(0.0,1.0);\nvUV=vec2(topLeftUV.x,topLeftUV.y);\n}\n\nelse if (index == 2.0) {\npos2=vec2(1.0,1.0);\nvUV=vec2(topLeftUV.x+sizeUV.x,topLeftUV.y);\n}\n\nelse if (index == 3.0) {\npos2=vec2(1.0,0.0);\nvUV=vec2(topLeftUV.x+sizeUV.x,topLeftUV.y+sizeUV.y);\n}\n\n\n\nvColor=color;\nvColor.a*=opacity;\nvec4 pos;\npos.xy=pos2.xy*superSampleFactor*sizeUV*textureSize;\npos.z=1.0;\npos.w=1.0;\nfloat x=dot(pos,transformX);\nfloat y=dot(pos,transformY);\nif (renderingInfo.z == 1.0) {\nfloat rw=renderingInfo.x;\nfloat rh=renderingInfo.y;\nfloat irw=2.0/rw;\nfloat irh=2.0/rh;\nx=(floor((x/irw))*irw)+irw/2.0;\ny=(floor((y/irh))*irh)+irh/2.0;\n}\ngl_Position=vec4(x,y,zBias.x,1.0);\n}",BABYLON.Effect.ShadersStore.wireframe2dPixelShader="varying vec4 vColor;\nvoid main(void) {\ngl_FragColor=vColor;\n}",BABYLON.Effect.ShadersStore.wireframe2dVertexShader="\n#ifdef Instanced\n#define att attribute\n#else\n#define att uniform\n#endif\n\nattribute vec2 pos;\nattribute vec4 col;\n\n\n\n\natt vec3 properties;\natt vec2 zBias;\natt vec4 transformX;\natt vec4 transformY;\natt vec3 renderingInfo;\natt float opacity;\n\n\nvarying vec4 vColor;\nvoid main(void) {\nvec4 p=vec4(pos.xy,1.0,1.0);\nvColor=vec4(col.xyz,col.w*opacity);\nfloat x=dot(p,transformX);\nfloat y=dot(p,transformY);\nif (renderingInfo.z == 1.0) {\nfloat rw=renderingInfo.x;\nfloat rh=renderingInfo.y;\nfloat irw=2.0/rw;\nfloat irh=2.0/rh;\nx=(floor((x/irw)+0.5)*irw)+irw/2.0;\ny=(floor((y/irh)+0.5)*irh)+irh/2.0;\n}\ngl_Position=vec4(x,y,zBias.x,1);\n}";var BABYLON;!(function(e){var t=(function(){function t(){this.m=new Float32Array(6)}return t.Zero=function(){return new t},t.FromValuesToRef=function(e,t,r,n,i,o,a){a.m[0]=e,a.m[1]=t,a.m[2]=r,a.m[3]=n,a.m[4]=i,a.m[5]=o},t.FromMatrix=function(e){var r=new t;return t.FromMatrixToRef(e,r),r},t.FromMatrixToRef=function(e,t){t.m[0]=e.m[0],t.m[1]=e.m[1],t.m[2]=e.m[4],t.m[3]=e.m[5],t.m[4]=e.m[8],t.m[5]=e.m[9]},t.Rotation=function(e){var r=new t;return t.RotationToRef(e,r),r},t.RotationToRef=function(e,t){var r=Math.sin(e),n=Math.cos(e);t.m[0]=n,t.m[1]=r,t.m[2]=-r,t.m[3]=n,t.m[4]=0,t.m[5]=0},t.Translation=function(e,r){var n=new t;return t.TranslationToRef(e,r,n),n},t.TranslationToRef=function(e,t,r){r.m[0]=1,r.m[1]=0,r.m[2]=0,r.m[3]=1,r.m[4]=e,r.m[5]=t},t.Scaling=function(e,r){var n=new t;return t.ScalingToRef(e,r,n),n},t.ScalingToRef=function(e,t,r){r.m[0]=e,r.m[1]=0,r.m[2]=0,r.m[3]=t,r.m[4]=0,r.m[5]=0},t.Identity=function(){var e=new t;return t.IdentityToRef(e),e},t.IdentityToRef=function(e){e.m[1]=e.m[2]=e.m[4]=e[5]=0,e.m[0]=e.m[3]=1},t.FromQuaternion=function(e){var r=new t;return t.FromQuaternionToRef(e,r),r},t.FromQuaternionToRef=function(e,t){var r=e.x*e.x,n=e.y*e.y,i=e.z*e.z,o=e.x*e.y,a=e.z*e.w;t.m[0]=1-2*(n+i),t.m[1]=2*(o+a),t.m[2]=2*(o-a),t.m[3]=1-2*(i+r)},t.Compose=function(e,r,n){var i=t.Scaling(e.x,e.y),o=t.Rotation(r);return i=i.multiply(o),i.setTranslation(n),i},t.Invert=function(e){var r=new t;return e.invertToRef(r),r},t.prototype.clone=function(){var e=new t;return e.copyFrom(this),e},t.prototype.copyFrom=function(e){for(var t=0;t<6;t++)this.m[t]=e.m[t]},t.prototype.getTranslation=function(){return new e.Vector2(this.m[4],this.m[5])},t.prototype.setTranslation=function(e){this.m[4]=e.x,this.m[5]=e.y},t.prototype.determinant=function(){return this.m[0]*this.m[3]-this.m[1]*this.m[2]},t.prototype.invertToThis=function(){this.invertToRef(this)},t.prototype.invert=function(){var e=new t;return this.invertToRef(e),e},t.prototype.invertToRef=function(t){var r=this.m[0],n=this.m[1],i=this.m[2],o=this.m[3],a=this.m[4],s=this.m[5],l=this.determinant();if(l=this._count)throw new Error("Can't fetch the triangle at index "+e+", max index is "+(this._count-1));var r=9*e;t.a.x=this._array[r+0],t.a.y=this._array[r+1],t.b.x=this._array[r+2],t.b.y=this._array[r+3],t.c.x=this._array[r+4],t.c.y=this._array[r+5],t.center.x=this._array[r+6],t.center.y=this._array[r+7],t.radius=this._array[r+8]},t.prototype.transformAndStoreToTri2DInfo=function(e,t,r){if(e>=this._count)throw new Error("Can't fetch the triangle at index "+e+", max index is "+(this._count-1));var n=9*e;t.a.x=this._array[n+0],t.a.y=this._array[n+1],t.b.x=this._array[n+2],t.b.y=this._array[n+3],t.c.x=this._array[n+4],t.c.y=this._array[n+5],t.transformInPlace(r)},Object.defineProperty(t.prototype,"count",{get:function(){return this._count},enumerable:!0,configurable:!0}),t.prototype.doesContain=function(e){t._checkInitStatics();for(var r=t.tempT[0],n=0;no.radius*o.radius+a.radius*a.radius)&&i.TriangleTriangleDosIntersect(o.a,o.b,o.c,a.a,a.b,a.c))return!0}return!1},t._checkInitStatics=function(){if(null===t.tempT){t.tempT=new Array(2),t.tempT[0]=new r(null,null,null),t.tempT[1]=new r(null,null,null),t.tempV=new Array(6);for(var n=0;n<6;n++)t.tempV[n]=e.Vector2.Zero()}},t})();n.tempV=null,n.tempT=null,e.Tri2DArray=n;var i=(function(){function t(){}return t.Dot=function(e,t){return e.x*t.x+e.y*t.y},t.LineLineDoesIntersect=function(e,t,r,n){var i=t.x-e.x,o=t.y-e.y,a=n.x-r.x,s=n.y-r.y,l=(-o*(e.x-r.x)+i*(e.y-r.y))/(-a*o+i*s),u=(a*(e.y-r.y)-s*(e.x-r.x))/(-a*o+i*s);return l>=0&&l<=1&&u>=0&&u<=1},t.LineLineIntersection=function(e,t,r,n){var i=t.x-e.x,o=t.y-e.y,a=n.x-r.x,s=n.y-r.y,l=(-o*(e.x-r.x)+i*(e.y-r.y))/(-a*o+i*s),u=(a*(e.y-r.y)-s*(e.x-r.x))/(-a*o+i*s);return l>=0&&l<=1&&u>=0&&u<=1?{res:!0,xr:e.x+u*i,yr:e.y+u*o}:{res:!1,xr:0,yr:0}},t.TriangleTriangleDosIntersect=function(r,n,i,o,a,s){return!!t.LineLineDoesIntersect(r,n,o,a)||(!!t.LineLineDoesIntersect(r,n,o,s)||(!!t.LineLineDoesIntersect(r,n,a,s)||(!!t.LineLineDoesIntersect(r,i,o,a)||(!!t.LineLineDoesIntersect(r,i,o,s)||(!!t.LineLineDoesIntersect(r,i,a,s)||(!!t.LineLineDoesIntersect(n,i,o,a)||(!!t.LineLineDoesIntersect(n,i,o,s)||(!!t.LineLineDoesIntersect(n,i,a,s)||(!!(e.Vector2.PointInTriangle(o,r,n,i)&&e.Vector2.PointInTriangle(a,r,n,i)&&e.Vector2.PointInTriangle(s,r,n,i))||!!(e.Vector2.PointInTriangle(r,o,a,s)&&e.Vector2.PointInTriangle(n,o,a,s)&&e.Vector2.PointInTriangle(i,o,a,s)))))))))))},t})();i.v0=e.Vector2.Zero(),i.v1=e.Vector2.Zero(),i.v2=e.Vector2.Zero()})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){}return e})();e.PropertyChangedInfo=t;var r=(function(){function r(){this._propertyChanged=null}return r.prototype.onPropertyChanged=function(e,n,i,o){if(this.propertyChanged.hasObservers()){var a=r.calling?new t:r.pci;a.oldValue=n,a.newValue=i,a.propertyName=e;try{r.calling=!0,this.propertyChanged.notifyObservers(a,o)}finally{r.calling=!1}}},Object.defineProperty(r.prototype,"propertyChanged",{get:function(){return this._propertyChanged||(this._propertyChanged=new e.Observable),this._propertyChanged},enumerable:!0,configurable:!0}),r})();r.pci=new t,r.calling=!1,e.PropertyChangedBase=r})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){function t(t,r,o,a){return void 0===t&&(t=""),void 0===r&&(r=!1),void 0===o&&(o=!1),void 0===a&&(a=!1),function(s,l,u){if(!i.enableLog)return u;var c=u.get,h=u.set;return c&&r&&(u.get=function(){if(n.snooze)return c.call(this);var r=i.computeIndent(),o=this.id||"";null!==t&&""!==t&&console.log(t);var s=this instanceof e.SmartPropertyPrim,u=s?this._flags:0,h=i.callDepth;a||console.log(r+" ["+o+"] ("+h+") ==> get "+l+" property"),++i.callDepth,n.setPostMessage((function(){return"[no msg]"}));var d=c.call(this);--i.callDepth;var p="";if(s){var f=this._flags,g=this._getFlagsDebug(f&u^f),_=this._getFlagsDebug(f&u^u);p="",""!==g&&(p=" +++["+g+"]"),""!==_&&(""!==p&&(p+=","),p+=" ---["+_+"]")}return console.log(r+" ["+o+"] ("+h+")"+(a?"":" <==")+" get "+l+" property => "+i.getFormattedValue(d)+p+", "+i.postMessages[i.callDepth]),d}),h&&(u.set=function(r){if(n.snooze)h.call(this,r);else{var a=i.computeIndent(),s=this.id||"";null!==t&&""!==t&&console.log(t);var u=this instanceof e.SmartPropertyPrim,c=u?this._flags:0,d=i.callDepth;o||console.log(a+" ["+s+"] ("+d+") ==> set "+l+" property with "+i.getFormattedValue(r)),++i.callDepth,n.setPostMessage((function(){return"[no msg]"})),h.call(this,r),--i.callDepth;var p="";if(u){var f=this._flags,g=this._getFlagsDebug(f&c^f),_=this._getFlagsDebug(f&c^c);p="",""!==g&&(p=" +++["+g+"]"),""!==_&&(""!==p&&(p+=","),p+=" ---["+_+"]")}console.log(a+" ["+s+"] ("+d+")"+(o?"":" <==")+" set "+l+" property, "+i.postMessages[i.callDepth]+p)}}),u}}function r(t,r){return void 0===t&&(t=""),void 0===r&&(r=!1),function(o,a,s){if(!i.enableLog)return s;void 0===s&&(s=Object.getOwnPropertyDescriptor(o,a));var l=s.value;return s.value=function(){for(var o=[],s=0;s call: "+a+" ("+u+")"),++i.callDepth,n.setPostMessage((function(){return"[no msg]"}));var g=l.apply(this,o);--i.callDepth;var _="";if(d){var y=this._flags,m=this._getFlagsDebug(y&p^y),v=this._getFlagsDebug(y&p^p);_="",""!==m&&(_=" +++["+m+"]"),""!==v&&(""!==_&&(_+=","),_+=" ---["+v+"]")}return console.log(c+" ["+h+"] ("+f+")"+(r?"":" <==")+" call: "+a+" ("+u+") Res: "+i.getFormattedValue(g)+", "+i.postMessages[i.callDepth]+_),g},s}}var n=(function(){function e(){}return e.logFrameRender=function(t){e.snooze=!0,e._logFramesCount=t},e.setPostMessage=function(e){i.enableLog&&(i.postMessages[i.callDepth-1]=e())},e._startFrameRender=function(){0!==e._logFramesCount&&(e.snooze=!1)},e._endFrameRender=function(){0!==e._logFramesCount&&(e.snooze=!0,--e._logFramesCount)},e})();n.snooze=!0,n._logFramesCount=0,e.C2DLogging=n;var i=(function(){function t(){}return t.computeIndent=function(){var e=null;if(t.callDepth<20)e=t.depths[t.callDepth];else{e="|";for(var r=0;r<=t.callDepth;r++)e+="-"}return e},t.getFormattedValue=function(t){return t instanceof e.Prim2DBase?t.id:null==t?"[null]":t.toString()},t})();i.enableLog=!1,i.callDepth=0,i.depths=["|-","|--","|---","|----","|-----","|------","|-------","|--------","|---------","|----------","|-----------","|------------","|-------------","|--------------","|---------------","|----------------","|-----------------","|------------------","|-------------------","|--------------------"],i.postMessages=[],e.logProp=t,e.logMethod=r})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this.action=0,this.newItems=new Array,this.removedItems=new Array,this.changedItems=new Array,this.newStartingIndex=-1,this.removedStartingIndex=-1}return Object.defineProperty(e,"clearAction",{get:function(){return e._clearAction},enumerable:!0,configurable:!0}),Object.defineProperty(e,"newItemsAction",{get:function(){return e._newItemsAction},enumerable:!0,configurable:!0}),Object.defineProperty(e,"removedItemsAction",{get:function(){return e._removedItemsAction},enumerable:!0,configurable:!0}),Object.defineProperty(e,"changedItemAction",{get:function(){return e._changedItemAction},enumerable:!0,configurable:!0}),Object.defineProperty(e,"replacedArrayAction",{get:function(){return e._replacedArrayAction},enumerable:!0,configurable:!0}),Object.defineProperty(e,"lengthChangedAction",{get:function(){return e._lengthChangedAction},enumerable:!0,configurable:!0}),e.prototype.clear=function(){this.action=0,this.newItems.splice(0),this.removedItems.splice(0),this.changedItems.splice(0),this.removedStartingIndex=this.removedStartingIndex=this.changedStartingIndex=0},e})();t._clearAction=1,t._newItemsAction=2,t._removedItemsAction=4,t._replacedArrayAction=8,t._lengthChangedAction=16,t._changedItemAction=32,e.ArrayChanged=t;var r=(function(){function e(){}return e})();e.OAWatchedObjectChangedInfo=r;var n=(function(n){function i(i,o){var a=n.call(this)||this;return a.dci=new t,a._callingArrayChanged=!1,a._array=null!=o?o:new Array,a.dci=new t,a._callingArrayChanged=!1,a._arrayChanged=null,a._callingWatchedObjectChanged=!1,a._watchObjectsPropertyChange=i,a._watchedObjectList=a._watchObjectsPropertyChange?new e.StringDictionary:null,a._woci=new r,a}return __extends(i,n),Object.defineProperty(i.prototype,"length",{get:function(){return this._array.length},set:function(e){if(e!==this._array.length){var t=this._array.length;this._array.length=e,this.onPropertyChanged("length",t,this._array.length)}},enumerable:!0,configurable:!0}),i.prototype.getAt=function(e){return this._array[e]},i.prototype.setAt=function(e,r){if(e<0)return!1;var n=e>=this._array.length||void 0===this._array[e],i=0;n?i=this._array.length:this._watchObjectsPropertyChange&&this._removeWatchedElement(this._array[e]),this._array[e]=r,this._watchObjectsPropertyChange&&this._addWatchedElement(r),n&&this.onPropertyChanged("length",i,this._array.length);var o=this.getArrayChangedObject();o&&(o.action=n?t.newItemsAction:t.changedItemAction,n?(o.newItems.splice(0,o.newItems.length,{index:e,value:r}),o.newStartingIndex=e,o.changedItems.splice(0)):(o.newItems.splice(0),o.changedStartingIndex=e,o.changedItems.splice(0,o.changedItems.length,{index:e,value:r})),o.removedItems.splice(0),o.removedStartingIndex=-1,this.callArrayChanged(o))},i.prototype.toString=function(){return this._array.toString()},i.prototype.toLocaleString=function(){return this._array.toLocaleString()},i.prototype.push=function(){for(var e=[],r=0;ra.width&&(this._currentFreePosition.x=0,this._currentFreePosition.y+=Math.ceil(this._lineHeightSuper+2*this._yMargin),this._currentFreePosition.y>a.height))return this.getChar("!");var l=this._currentFreePosition.x+.5,u=this._currentFreePosition.y+.5,c=l+this._xMargin,h=u+this._yMargin,d=function(e){e.strokeStyle="green",e.beginPath(),e.rect(c,h,s,n._lineHeightSuper),e.closePath(),e.stroke(),e.strokeStyle="blue",e.beginPath(),e.moveTo(c,h+Math.round(n._baseLine)),e.lineTo(c+s,h+Math.round(n._baseLine)),e.closePath(),e.stroke()};if(this._signedDistanceField){var p=this._sdfScale;this._sdfContext.clearRect(0,0,this._sdfCanvas.width,this._sdfCanvas.height),this._sdfContext.fillText(t,this._xMargin+.5,this._yMargin+.5-this._offset);var f=this._sdfContext.getImageData(0,0,(s+2*this._xMargin)*p,this._sdfCanvas.height),g=this._computeSDFChar(f);this._context.putImageData(g,l,u),this.debugMode&&d(this._context)}else{this.debugMode&&d(this._context),this._context.fillText(t,c,h-this._offset);for(var _=this._context.getImageData(c,h,s,this._lineHeightSuper),y=0;y<_.data.length;y+=4){var m=_.data[y+3];m>0&&m<255&&(_.data[y+0]=m,_.data[y+1]=m,_.data[y+2]=m,_.data[y+3]=m)}this._context.putImageData(_,c,h)}if(i.topLeftUV=new e.Vector2((c-.5)/a.width,(this._currentFreePosition.y-.5+this._yMargin)/a.height),i.bottomRightUV=new e.Vector2((c-.5+s)/a.width,i.topLeftUV.y+this._lineHeightSuper/a.height),i.yOffset=i.xOffset=0,this._signedDistanceField){var v=1/a.width;i.topLeftUV.addInPlace(new e.Vector2(v,v)),i.bottomRightUV.addInPlace(new e.Vector2(v,v))}return i.charWidth=this._superSample?s/2:s,i.xAdvance=i.charWidth,this._charInfos.add(t,i),this._curCharCount++,this._currentFreePosition.x+=Math.ceil(s+2*this._xMargin),i},n.prototype._computeSDFChar=function(e){for(var t=this._sdfScale,r=e.width,n=e.height,i=r/t,o=n/t,a=0,s=0,l=t,u=l-1,c=function(i,o,l,u,c){var h=i*t,d=o*t;if(h+l<0||h+l>=r||d+u<0||d+u>=n)return!0;var p=e.data[4*((d+u)*r+(h+l))],f=p>0===c;return f||(a=l,s=u),f},h=function(e,t,r){if(c(e,t,0,u,r)&&c(e,t,0,-u,r)&&c(e,t,-u,0,r)&&c(e,t,u,0,r))return 0;for(var n=1;n<=l;n++){if(!(c(e,t,0,n,r)&&c(e,t,0,-n,r)&&c(e,t,-n,0,r)&&c(e,t,n,0,r)))return n*n;for(var i=1;i<=n;i++)if(!(c(e,t,-i,n,r)&&c(e,t,i,n,r)&&c(e,t,n,-i,r)&&c(e,t,n,i,r)&&c(e,t,-i,-n,r)&&c(e,t,i,-n,r)&&c(e,t,-n,-i,r)&&c(e,t,-n,i,r))){var o=n*n+i*i,h=1;return c(e,t,a-1,s,r)||(o+=(a-1)*(a-1)+s*s,++h),c(e,t,a+1,s,r)||(o+=(a+1)*(a+1)+s*s,++h),c(e,t,a,s-1,r)||(o+=a*a+(s-1)*(s-1),++h),c(e,t,a,s+1,r)||(o+=a*a+(s+1)*(s+1),++h),c(e,t,a-1,s-1,r)||(o+=(a-1)*(a-1)+(s-1)*(s-1),++h),c(e,t,a+1,s+1,r)||(o+=(a+1)*(a+1)+(s+1)*(s+1),++h),c(e,t,a+1,s-1,r)||(o+=(a+1)*(a+1)+(s-1)*(s-1),++h),c(e,t,a-1,s+1,r)||(o+=(a-1)*(a-1)+(s+1)*(s+1),++h),o/h}}return 0},d=new Array(i*o),p=0;p255&&(_=255),_+=.5,y.data[4*v+0]=_,y.data[4*v+1]=_,y.data[4*v+2]=_,y.data[4*v+3]=255}return y},n.prototype.getSuperSampleFont=function(e){var t=/^\s*(?=(?:(?:[-a-z]+\s*){0,2}(italic|oblique))?)(?=(?:(?:[-a-z]+\s*){0,2}(small-caps))?)(?=(?:(?:[-a-z]+\s*){0,2}(bold(?:er)?|lighter|[1-9]00))?)(?:(?:normal|\1|\2|\3)\s*){0,3}((?:xx?-)?(?:small|large)|medium|smaller|larger|[.\d]+(?:\%|in|[cem]m|ex|p[ctx]))(?:\s*\/\s*(normal|[.\d]+(?:\%|in|[cem]m|ex|p[ctx])))?\s*([-,\"\sa-z]+?)\s*$/,r=e.toLocaleLowerCase().match(t);if(null==r)return null;var n=parseInt(r[4]);r[4]=(2*n).toString()+(r[4].match(/\D+/)||[]).pop();for(var i="",o=1;of.width||p.scaleH>f.height)u="FontMap texture's size is bigger than what WebGL supports",s=-1;else if(1!==p.pages)u="FontMap must contain one page only.",s=-1;else{var g=this._parseStrToObj(o.match(l.PAGE_EXP)[0]);if(0!==g.id)u="Only one page of ID 0 is supported",s=-1;else{a.textureFile=g.file;for(var _=o.match(l.CHAR_EXP),y=0,m=_.length;y=t.x&&r.x<=t.z&&r.w>=t.y&&r.y<=t.w},t.prototype.transformToRef=function(e,r){var n=t._transform;n[0].x=this.center.x+this.extent.x,n[0].y=this.center.y+this.extent.y,n[1].x=this.center.x+this.extent.x,n[1].y=this.center.y-this.extent.y,n[2].x=this.center.x-this.extent.x,n[2].y=this.center.y-this.extent.y,n[3].x=this.center.x-this.extent.x,n[3].y=this.center.y+this.extent.y;for(var i=0;i<4;i++)e.transformPointToRef(n[i],n[i]);t.CreateFromPointsToRef(n,r)},t.prototype._updateWorldAABB=function(e){var r=t._transform;r[0].x=this.center.x+this.extent.x,r[0].y=this.center.y+this.extent.y,r[1].x=this.center.x+this.extent.x,r[1].y=this.center.y-this.extent.y,r[2].x=this.center.x-this.extent.x,r[2].y=this.center.y-this.extent.y,r[3].x=this.center.x-this.extent.x,r[3].y=this.center.y+this.extent.y;for(var n=0;n<4;n++)e.transformPointToRef(r[n],r[n]);this._worldAABB.x=Math.min(Math.min(r[0].x,r[1].x),Math.min(r[2].x,r[3].x)),this._worldAABB.y=Math.min(Math.min(r[0].y,r[1].y),Math.min(r[2].y,r[3].y)),this._worldAABB.z=Math.max(Math.max(r[0].x,r[1].x),Math.max(r[2].x,r[3].x)),this._worldAABB.w=Math.max(Math.max(r[0].y,r[1].y),Math.max(r[2].y,r[3].y))},Object.defineProperty(t.prototype,"worldAABBDirtyObservable",{get:function(){return this._worldAABBDirtyObservable||(this._worldAABBDirtyObservable=new e.Observable),this._worldAABBDirtyObservable},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isWorldAABBDirty",{get:function(){return this._worldAABBDirty},enumerable:!0,configurable:!0}),t.prototype.dirtyWorldAABB=function(){this._worldAABBDirty||(this._worldAABBDirty=!0,this._worldAABBDirtyObservable&&this._worldAABBDirtyObservable.hasObservers()&&this._worldAABBDirtyObservable.notifyObservers(this))},Object.defineProperty(t.prototype,"worldAABB",{get:function(){if(this._worldAABBDirty){if(!this.worldMatrixAccess)throw new Error("you must set the worldMatrixAccess function first");this._updateWorldAABB(this.worldMatrixAccess()),this._worldAABBDirty=!1}return this._worldAABB},enumerable:!0,configurable:!0}),t.prototype.unionToRef=function(e,r){var n=Math.max(this.center.x+this.extent.x,e.center.x+e.extent.x),i=Math.max(this.center.y+this.extent.y,e.center.y+e.extent.y),o=Math.min(this.center.x-this.extent.x,e.center.x-e.extent.x),a=Math.min(this.center.y-this.extent.y,e.center.y-e.extent.y);t.CreateFromMinMaxToRef(o,n,a,i,r)},t.prototype.doesIntersect=function(e){var t=e.subtract(this.center);return t.lengthSquared()<=this.radius*this.radius&&(Math.abs(t.x)<=this.extent.x&&Math.abs(t.y)<=this.extent.y)},t})();t._transform=new Array(e.Vector2.Zero(),e.Vector2.Zero(),e.Vector2.Zero(),e.Vector2.Zero()),e.BoundingInfo2D=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(e){this._owner=e}return e.allocBasicPCM=function(e,t){return new o(e,t)},e})();e.PrimitiveCollisionManagerBase=t;var r=(function(){function e(){}return e})();e.ActorInfoBase=r;var n=(function(t){function r(n,i,o){var a=t.call(this)||this;a.owner=n,a.prim=i,a.flags=0,a.presentInClusters=new e.StringDictionary,a.intersectWith=new e.ObservableStringDictionary(!1),a.setFlags((o?r.flagDeep:0)|r.flagDirty);var s=o?i.boundingInfo:i.levelBoundingInfo;return s.worldAABBDirtyObservable.add((function(e,t){a.owner.actorDirty(a)})),i.propertyChanged.add((function(e,t){t.mask!==-1&&(a.setFlagsValue(r.flagEnabled,e.newValue===!0),a.owner.actorDirty(a))}),e.Prim2DBase.isVisibleProperty.flagId),a}return __extends(r,t),r.prototype.setFlags=function(e){this.flags|=e},r.prototype.clearFlags=function(e){this.flags&=~e},r.prototype.isAllFlagsSet=function(e){return(this.flags&e)===e},r.prototype.isSomeFlagsSet=function(e){return 0!==(this.flags&e)},r.prototype.setFlagsValue=function(e,t){t?this.flags|=e:this.flags&=~e},Object.defineProperty(r.prototype,"worldAABB",{get:function(){return(this.isSomeFlagsSet(r.flagDeep)?this.prim.boundingInfo:this.prim.levelBoundingInfo).worldAABB},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isEnabled",{get:function(){return this.isSomeFlagsSet(r.flagEnabled)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isDeep",{get:function(){return this.isSomeFlagsSet(r.flagDeep)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isDirty",{get:function(){return this.isSomeFlagsSet(r.flagDirty)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isRemoved",{get:function(){return this.isSomeFlagsSet(r.flagRemoved)},enumerable:!0,configurable:!0}),r})(r);n.flagDeep=1,n.flagEnabled=2,n.flagDirty=4,n.flagRemoved=8;var i=(function(){function t(){this.actors=new e.StringDictionary}return t.prototype.clear=function(){this.actors.clear()},t})(),o=(function(t){function r(n,i){var o=t.call(this,n)||this;o._actors=new e.StringDictionary,o._dirtyActors=new e.StringDictionary,o._clusters=null,o._maxActorByCluster=0,o._AABBRenderPrim=null,o._canvasSize=e.Size.Zero(),o._ClusterRenderPrim=null,o._debugTextBackground=null,o._clusterDirty=!0,o._clusterSize=new e.Size(2,2),o._clusterStep=e.Vector2.Zero(),o._lastClusterResizeCounter=0,o._freeClusters=new Array,o._enableBorder=i,o._debugUpdateOpCount=new e.PerfCounter,o._debugUpdateTime=new e.PerfCounter,o._intersectedActors=new e.ObservableStringDictionary(!1),o._borderIntersecteddActors=new Array(4);for(var a=0;a<4;a++)o._borderIntersecteddActors[a]=new e.ObservableStringDictionary(!1);var s=e.Canvas2D.actualSizeProperty.flagId;if(!r.WAABBCorners){r.WAABBCorners=new Array(4);for(var l=0;l<4;l++)r.WAABBCorners[l]=e.Vector2.Zero();r.WAABBCornersCluster=new Array(4);for(var l=0;l<4;l++)r.WAABBCornersCluster[l]=e.Vector2.Zero()}return n.propertyChanged.add((function(e,t){t.mask!==-1&&(o._clusterDirty=!0,console.log("canvas size changed"))}),s),o.debugRenderAABB=!1,o.debugRenderClusters=!1,o.debugStats=!1,o}return __extends(r,t),r.prototype._addActor=function(e,t){var r=this;return this._actors.getOrAddWithFactory(e.uid,(function(){var i=new n(r,e,t);return r.actorDirty(i),i}))},r.prototype._removeActor=function(e){var t=this._actors.getAndRemove(e.uid);t.setFlags(n.flagRemoved),this.actorDirty(t)},r.prototype.actorDirty=function(e){e.setFlags(n.flagDirty),this._dirtyActors.add(e.prim.uid,e)},r.prototype._update=function(){this._canvasSize.copyFrom(this._owner.actualSize),this.debugRenderAABB&&(this._dirtyActors.count>0||this._debugRenderAABBDirty)&&this._updateAABBDisplay(),this._AABBRenderPrim&&(this._AABBRenderPrim.levelVisible=this.debugRenderAABB);var e=this._clusterSize.width,t=this._clusterSize.height;(this._clusterSize.width<16&&this._clusterSize.height<16&&this._maxActorByCluster>=10||this._clusterSize.width>2&&this._clusterSize.height>2&&this._maxActorByCluster<=7)&&this._lastClusterResizeCounter>100&&(this._maxActorByCluster>=10?(++e, ++t):(--e,--t),console.log("Change cluster size to "+e+":"+t+", max actor "+this._maxActorByCluster),this._clusterDirty=!0),this.debugRenderClusters&&this._clusterDirty&&this._updateClusterDisplay(e,t),this._ClusterRenderPrim&&(this._ClusterRenderPrim.levelVisible=this.debugRenderClusters);var r=this.debugStats&&(this._dirtyActors.count>0||this._clusterDirty);this._debugUpdateTime.beginMonitoring(),this._clusterDirty?(this._initializeCluster(e,t),this._rebuildAllActors()):(this._rebuildDirtyActors(),++this._lastClusterResizeCounter),this._collisionDetection(),this._debugUpdateTime.endMonitoring(),r&&this._updateDebugStats(),this._debugTextBackground&&(this._debugTextBackground.levelVisible=r),this._dirtyActors.clear()},Object.defineProperty(r.prototype,"debugRenderAABB",{get:function(){return this._debugRenderAABB},set:function(e){this._debugRenderAABB!==e&&(this._debugRenderAABB=e,this._debugRenderAABBDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"intersectedActors",{get:function(){return this._intersectedActors},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"leftBorderIntersectedActors",{get:function(){return this._borderIntersecteddActors[0]},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"bottomBorderIntersectedActors",{get:function(){return this._borderIntersecteddActors[1]},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"rightBorderIntersectedActors",{get:function(){return this._borderIntersecteddActors[2]},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"topBorderIntersectedActors",{get:function(){return this._borderIntersecteddActors[3]},enumerable:!0,configurable:!0}),r.prototype._initializeCluster=function(e,t){if(this._clusters)for(var r=0;r=this._canvasSize.width?this._borderIntersecteddActors[2].add(e.prim.uid,e.prim):this._borderIntersecteddActors[2].remove(e.prim.uid),i[2].y>=this._canvasSize.height?this._borderIntersecteddActors[3].add(e.prim.uid,e.prim):this._borderIntersecteddActors[3].remove(e.prim.uid));for(var m=g;m<=y;m++)for(var v=function(r){var n=r+":"+m,i=r,o=m,a=e.presentInClusters.getOrAddWithFactory(n,(function(r){var n=t._getCluster(i,o);return n.actors.add(e.prim.uid,e),t._maxActorByCluster=Math.max(t._maxActorByCluster,n.actors.count),++h,++d,n}));p.push(a)},b=f;b<=_;b++)v(b);if(0!==h||e.presentInClusters.count!==d){var P=new Array;e.presentInClusters.forEach((function(t,r){p.indexOf(r)===-1&&(P.push(t),r.actors.remove(e.prim.uid))}));for(var C=0,S=P;C=a.x&&s.x<=a.z&&s.w>=a.y&&s.y<=a.w&&o.prim.intersectOtherPrim(n.prim)&&(++i,o.intersectWith.add(t,n),r0&&(o=parseFloat(n.substr(0,i))),r(o,null,e.Stars)}else{var o=parseFloat(n);r(o,o,e.Pixels)}},e})();o.Pixels=1,o.Stars=2,o.Auto=3;var a=(function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t})(o),s=(function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t})(o),l=h=(function(t){function r(r){var n=t.call(this)||this;if(n._children=[],n._rowBottoms=[],n._columnLefts=[],n._rowHeights=[],n._columnWidths=[],n.layoutDirtyOnPropertyChangedMask=e.Prim2DBase.sizeProperty.flagId|e.Prim2DBase.actualSizeProperty.flagId,n._rows=new Array,n._columns=new Array,r.rows)for(var i=function(e){var t=new a;t._parse(e.height,(function(e,r,n){t.height=e,t.heightPixels=r,t.heightType=n})),o._rows.push(t)},o=this,l=0,u=r.rows;l1)for(var P=y+1;P1)for(var P=c+1;P0)for(var P=e.contentArea.height-_,C=0;C0)for(var I=e.contentArea.width-y,T=0;T=0;E--)R+=this._rowHeights[E+1],this._rowBottoms[E]=R;var L=0;this._columnLefts[0]=L;for(var F=1;F1&&this.mode===f.MODE_ONETIME)){var r=t;this._converter&&(r=this._converter(t)),this._stringFormat&&(r=this._stringFormat(r)),e[this._boundTo.name]=r}},e.prototype._getActualDataSource=function(){return this.dataSource?this.dataSource:this.uiElementId?null:this._owner.dataSource},e.prototype._registerDataSource=function(e){var t=this._getActualDataSource();t!==this._currentDataSource&&(this._currentDataSource&&d.unregisterDataSource(this._currentDataSource,this,0),t&&(d.registerDataSource(t,this),e&&this.canUpdateTarget(!0)&&this.updateTarget()),this._currentDataSource=t)},e.prototype._unregisterDataSource=function(){var e=this._getActualDataSource();e&&d.unregisterDataSource(e,this,0)},e})();l.MODE_DEFAULT=1,l.MODE_ONETIME=2,l.MODE_ONEWAY=3,l.MODE_ONEWAYTOSOURCE=4,l.MODE_TWOWAY=5,l.UPDATESOURCETRIGGER_DEFAULT=1,l.UPDATESOURCETRIGGER_PROPERTYCHANGED=2,l.UPDATESOURCETRIGGER_LOSTFOCUS=3,l.UPDATESOURCETRIGGER_EXPLICIT=4,l=f=__decorate([e.className("DataBinding","BABYLON")],l),e.DataBinding=l;var u=g=(function(t){function r(){var e=t.call(this)||this;return e._dataSource=null,e._dataSourceObserver=null,e._instanceDirtyFlags=0,e._isDisposed=!1,e._bindings=null,e._hasBinding=0,e._bindingSourceChanged=0,e._disposeObservable=null,e}return __extends(r,t),Object.defineProperty(r.prototype,"disposeObservable",{get:function(){return this._disposeObservable||(this._disposeObservable=new e.Observable),this._disposeObservable},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!0,configurable:!0}),r.prototype.dispose=function(){return!this.isDisposed&&(this._disposeObservable&&this._disposeObservable.hasObservers()&&this._disposeObservable.notifyObservers(this),this._isDisposed=!0,!0)},r.prototype.checkPropertiesDirty=function(e){return 0!==(this._instanceDirtyFlags&e)},r.prototype.clearPropertiesDirty=function(e){return this._instanceDirtyFlags&=~e,this._instanceDirtyFlags},r.prototype._resetPropertiesDirty=function(){this._instanceDirtyFlags=0},r.prototype.addExternalData=function(t,r){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.add(t,r)},r.prototype.getExternalData=function(e){return this._externalData?this._externalData.get(e):null},r.prototype.getOrAddExternalDataWithFactory=function(t,r){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.getOrAddWithFactory(t,r)},r.prototype.removeExternalData=function(e){return!!this._externalData&&this._externalData.remove(e)},r._hookProperty=function(t,r,n,i){return function(o,a,s){i||(i={});var l=g._createPropInfo(o,a,t,n,i);r&&r(l);var u=s.get,c=s.set,h=void 0!==i.typeLevelCompare&&i.typeLevelCompare;s.set=function(t){if(!c)throw Error("Property '"+l.name+"' of type '"+e.Tools.getFullClassName(this)+"' has no setter defined but was invoked as if it had one.");if(!this.isDisposed){var r=u.call(this);if(!g._checkUnchanged(r,t)){var n=this;c.call(this,t),n._handlePropChanged(r,t,a,l,h)}}}}},r._createPropInfo=function(e,t,r,n,i){var u=s.getOrRegister(e,(function(){return new o})),c=u.getLevelOf(e),h=c.levelContent.get(r.toString());if(h)throw new Error("The ID "+r+" is already taken by another property declaration named: "+h.name);return h=new a,h.id=r,h.flagId=Math.pow(2,r),h.kind=n,h.name=t,h.bindingMode=void 0!==i.bindingMode?i.bindingMode:l.MODE_TWOWAY,h.bindingUpdateSourceTrigger=void 0!==i.bindingUpdateSourceTrigger?i.bindingUpdateSourceTrigger:l.UPDATESOURCETRIGGER_PROPERTYCHANGED,h.dirtyBoundingInfo=void 0!==i.dirtyBoundingInfo&&i.dirtyBoundingInfo,h.dirtyParentBoundingInfo=void 0!==i.dirtyParentBoundingBox&&i.dirtyParentBoundingBox,h.typeLevelCompare=void 0!==i.typeLevelCompare&&i.typeLevelCompare,c.levelContent.add(t,h),h},Object.defineProperty(r.prototype,"propDic",{get:function(){if(!this._propInfo){var e=s.get(Object.getPrototypeOf(this));if(!e)throw new Error("Can't access the propDic member in class definition, is this class SmartPropertyPrim based?");this._propInfo=e.fullContent}return this._propInfo},enumerable:!0,configurable:!0}),r._checkUnchanged=function(e,t){if(null===e&&null===t||void 0===e&&void 0===t)return!0;if(null!=e&&null!=t)if("function"==typeof e.equals){if(e.equals(t))return!0}else if(e===t)return!0;return!1},r.prototype._handlePropChanged=function(t,r,n,i,o){var a=g.propChangeGuarding?new e.PropertyChangedInfo:p.propChangedInfo;a.oldValue=t,a.newValue=r,a.propertyName=n;var s=i?i.flagId:-1;try{g.propChangeGuarding=!0,this.propertyChanged.notifyObservers(a,s)}finally{g.propChangeGuarding=!1}},r.prototype._triggerPropertyChanged=function(e,t){this.isDisposed||e&&this._handlePropChanged(void 0,t,e.name,e,e.typeLevelCompare)},Object.defineProperty(r.prototype,"dataSource",{get:function(){return this._getDataSource()},set:function(e){if(this._dataSource!==e){var t=this._dataSource;if(this._dataSource=e,this._bindings&&null!=e)for(var r=0,n=this._bindings;r=n?t._unregisterBinding(a,u,r):a.monitoredIntermediateProperties.get(c),o=o[l]}},t._unregisterBinding=function(r,n,i){var o=n.toString(),a=null;if(0!==(r.monitoredIntermediateMask&n)&&(a=r.monitoredIntermediateProperties.get(o), r.monitoredIntermediateProperties.remove(o),r.monitoredIntermediateMask&=~n),0!==(r.boundPropertiesMask&n)){var s=r.boundProperties.get(o),l=e.Tools.first(s,(function(e){return e.binding===i}));if(l){var u=s.indexOf(l);s.splice(u,1)}0===s.length&&(r.boundPropertiesMask&=~n)}if(0===r.boundPropertiesMask&&0===r.monitoredIntermediateMask){r.monitoredObject.propertyChanged.remove(r.observer);var c=t._getObjectId(r.monitoredObject);t._monitoredObjects.remove(c)}return a},t._getMonitoredObjectData=function(e){var r=t._getObjectId(e),n=t._monitoredObjects.getOrAddWithFactory(r,(function(t){return new h(e)}));return n},t._getObjectId=function(t){var r=t.__bindingHelperObjectId__;return null==r?(r=e.Tools.RandomId(),t.__bindingHelperObjectId__=r,r):r},t._getObjectTypePropertyIDs=function(r){var n=e.Tools.getFullClassName(r);if(!n)throw Error("Types involved in Data Binding must be decorated with the @className decorator");var i=t._propertiesID.getOrAddWithFactory(n,(function(){return new e.StringDictionary}));return i},t._getPropertyID=function(e,r){var n=t._getObjectTypePropertyIDs(e),i=n.getOrAddWithFactory(r,(function(e){return 1<, left:, right:, bottom:");0===(15&this._flags)&&(this._flags|=c.Pixel<<0),0===(240&this._flags)&&(this._flags|=c.Pixel<<4),0===(3840&this._flags)&&(this._flags|=c.Pixel<<8),0===(61440&this._flags)&&(this._flags|=c.Pixel<<12),this.onChangeCallback()},e.prototype.fromStrings=function(e,t,r,n){return this._clear(),this._setStringValue(e,0,!1),this._setStringValue(t,1,!1),this._setStringValue(r,2,!1),this._setStringValue(n,3,!1),this.onChangeCallback(),this},e.prototype.fromPixels=function(e,t,r,n){return this._clear(),this._pixels[0]=e,this._pixels[1]=t,this._pixels[2]=r,this._pixels[3]=n,this.onChangeCallback(),this},e.prototype.fromUniformPixels=function(e){return this._clear(),this._pixels[0]=e,this._pixels[1]=e,this._pixels[2]=e,this._pixels[3]=e,this.onChangeCallback(),this},e.prototype.copyFrom=function(e){this._clear();for(var t=0;t<4;t++)this._pixels[t]=e._pixels[t],this._percentages[t]=e._percentages[t];this._flags=e._flags,this.onChangeCallback()},e.prototype.auto=function(){return this._clear(),this._flags=c.Auto<<0|c.Auto<<4|c.Auto<<8|c.Auto<<12,this._pixels[0]=0,this._pixels[1]=0,this._pixels[2]=0,this._pixels[3]=0,this.onChangeCallback(),this},e.prototype._clear=function(){this._flags=0,this._pixels[0]=0,this._pixels[1]=0,this._pixels[2]=0,this._pixels[3]=0,this._percentages[0]=null,this._percentages[1]=null,this._percentages[2]=null,this._percentages[3]=null},e.prototype._extractString=function(e,t){var r=e.trim().toLocaleLowerCase();return 0===r.indexOf("top:")?(r=r.substr(4).trim(),this._setStringValue(r,0,t)):0===r.indexOf("left:")?(r=r.substr(5).trim(),this._setStringValue(r,1,t)):0===r.indexOf("right:")?(r=r.substr(6).trim(),this._setStringValue(r,2,t)):0===r.indexOf("bottom:")&&(r=r.substr(7).trim(),this._setStringValue(r,3,t))},e.prototype._setStringValue=function(e,t,r){var n=e.trim().toLocaleLowerCase();if("auto"===n){if(this._isType(t,c.Auto))return!0;this._setType(t,c.Auto),this._pixels[t]=0,r&&this.onChangeCallback()}else{if("inherit"!==n){var i=n.indexOf("%");if(i!==-1){var o=n.substr(0,i),a=Math.round(Number(o))/100;return!(!this._isType(t,c.Percentage)||this._percentages[t]!==a)||(this._setType(t,c.Percentage),!isNaN(a)&&(this._percentages[t]=a,r&&this.onChangeCallback(),!0))}var s=void 0;i=n.indexOf("px"),s=i!==-1?n.substr(0,i).trim():n;var l=Number(s);return!(!this._isType(t,c.Pixel)||this._pixels[t]!==l)||!isNaN(l)&&(this._pixels[t]=l,this._setType(t,c.Pixel),r&&this.onChangeCallback(),!0)}if(this._isType(t,c.Inherit))return!0;this._setType(t,c.Inherit),this._pixels[t]=null,r&&this.onChangeCallback()}},e.prototype._setPixels=function(e,t,r){e=Math.round(e),this._isType(t,c.Pixel)&&this._pixels[t]===e||(this._setType(t,c.Pixel),this._pixels[t]=e,r&&this.onChangeCallback())},e.prototype._setPercentage=function(e,t,r){e=Math.min(1,e),e=Math.max(0,e),e=Math.round(100*e)/100,this._isType(t,c.Percentage)&&this._percentages[t]===e||(this._setType(t,c.Percentage),this._percentages[t]=e,r&&this.onChangeCallback())},e.prototype._getStringValue=function(e){var t=this._flags>>4*e&15;switch(t){case c.Auto:return"auto";case c.Pixel:return this._pixels[e]+"px";case c.Percentage:return 100*this._percentages[e]+"%";case c.Inherit:return"inherit"}return""},e.prototype._isType=function(e,t){var r=this._flags>>4*e&15;return r===t},e.prototype._getType=function(e,t){var r=this._flags>>4*e&15;if(t&&r===c.Inherit){var n=this._parentAccess();return n?n._getType(e,!0):c.Auto}return r},e.prototype._setType=function(e,t){this._flags&=~(15<<4*e),this._flags|=t<<4*e},e.prototype.setTop=function(e){"string"==typeof e?this._setStringValue(e,0,!0):this.topPixels=e},e.prototype.setLeft=function(e){"string"==typeof e?this._setStringValue(e,1,!0):this.leftPixels=e},e.prototype.setRight=function(e){"string"==typeof e?this._setStringValue(e,2,!0):this.rightPixels=e},e.prototype.setBottom=function(e){"string"==typeof e?this._setStringValue(e,3,!0):this.bottomPixels=e},Object.defineProperty(e.prototype,"top",{get:function(){return this._getStringValue(0)},set:function(e){this._setStringValue(e,0,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"left",{get:function(){return this._getStringValue(1)},set:function(e){this._setStringValue(e,1,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"right",{get:function(){return this._getStringValue(2)},set:function(e){this._setStringValue(e,2,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bottom",{get:function(){return this._getStringValue(3)},set:function(e){this._setStringValue(e,3,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"topPixels",{get:function(){return this._pixels[0]},set:function(e){this._setPixels(e,0,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"leftPixels",{get:function(){return this._pixels[1]},set:function(e){this._setPixels(e,1,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightPixels",{get:function(){return this._pixels[2]},set:function(e){this._setPixels(e,2,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bottomPixels",{get:function(){return this._pixels[3]},set:function(e){this._setPixels(e,3,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"topPercentage",{get:function(){return this._percentages[0]},set:function(e){this._setPercentage(e,0,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"leftPercentage",{get:function(){return this._percentages[1]},set:function(e){this._setPercentage(e,1,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightPercentage",{get:function(){return this._percentages[2]},set:function(e){this._setPercentage(e,2,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bottomPercentage",{get:function(){return this._percentages[3]},set:function(e){this._setPercentage(e,3,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"topMode",{get:function(){return this._getType(0,!1)},set:function(e){this._setType(0,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"leftMode",{get:function(){return this._getType(1,!1)},set:function(e){this._setType(1,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightMode",{get:function(){return this._getType(2,!1)},set:function(e){this._setType(2,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bottomMode",{get:function(){return this._getType(3,!1)},set:function(e){this._setType(3,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isDefault",{get:function(){return 4369===this._flags},enumerable:!0,configurable:!0}),e.prototype._computePixels=function(e,t,r){var n=this._getType(e,!1);if(n===c.Inherit)return void this._parentAccess()._computePixels(e,t,r);if(n===c.Percentage){var i=(0===e||3===e?t.height:t.width)*this._percentages[e];this._pixels[e]=i,r&&this.onChangeCallback()}},e.prototype.onChangeCallback=function(){this._changedCallback&&this._changedCallback()},e.prototype.computeWithAlignment=function(e,t,r,n,o,a,s,l){void 0===s&&(s=!1),void 0===l&&(l=c.ComputeAll);var u=this._getType(0,!0),h=this._getType(1,!0),d=this._getType(2,!0),p=this._getType(3,!0),f=t&&null!=t.width,g=t&&null!=t.height,_=n.x,y=n.y,m=1/_,v=1/y,b=f?t.width:0,P=g?t.height:0,C=u===c.Auto,S=h===c.Auto,D=d===c.Auto,x=p===c.Auto;if(l&c.ComputeH)switch(r.horizontal){case i.AlignLeft:var A=0;if(S||(this._computePixels(1,e,!0),A=this.leftPixels),o.x=A,a.width=b*m,o.z=e.width-(b*_+A),s){var O=0;D||(this._computePixels(2,e,!0),O=this.rightPixels),a.width+=(A+O)*m}break;case i.AlignRight:var O=0;if(D||(this._computePixels(2,e,!0),O=this.rightPixels),o.x=e.width-(b*_+O),a.width=b*m,o.z=O,s){var A=0;S||(this._computePixels(1,e,!0),A=this.leftPixels),a.width+=(A+O)*m}break;case i.AlignStretch:S?o.x=0:(this._computePixels(1,e,!0),o.x=this.leftPixels);var O=0;D||(this._computePixels(2,e,!0),O=this.rightPixels),s?a.width=e.width*m:a.width=e.width*m-(o.x+O)*m,o.z=this.rightPixels;break;case i.AlignCenter:var A=0;S||(this._computePixels(1,e,!0),A=this.leftPixels);var O=0;D||(this._computePixels(2,e,!0),O=this.rightPixels);var I=(e.width-(A+O)-b*_)/2;o.x=A+I,s?a.width=b*m+(this.leftPixels+this.rightPixels)*m:a.width=b*m,o.z=O+I}if(l&c.ComputeV)switch(r.vertical){case i.AlignBottom:var T=0;if(x||(this._computePixels(3,e,!0),T=this.bottomPixels),o.y=T,a.height=P*v,o.w=e.height-(P*y+T),s){var w=0;C||(this._computePixels(0,e,!0),w=this.topPixels),a.height+=(T+w)*v}break;case i.AlignTop:var w=0;if(C||(this._computePixels(0,e,!0),w=this.topPixels),o.y=e.height-(P*y+w),a.height=P*v,o.w=w,s){var T=0;x||(this._computePixels(3,e,!0),T=this.bottomPixels),a.height+=(T+w)*v}break;case i.AlignStretch:var B=0;x||(this._computePixels(3,e,!0),B=this.bottomPixels),o.y=B;var R=0;C||(this._computePixels(0,e,!0),R=this.topPixels),o.w=R,s?a.height=e.height*v:a.height=e.height*v-(R+B)*v;break;case i.AlignCenter:var T=0;x||(this._computePixels(3,e,!0),T=this.bottomPixels);var w=0;C||(this._computePixels(0,e,!0),w=this.topPixels);var I=(e.height-(T+w)-P*y)/2;o.y=T+I,s?a.height=P*v+(T+w)*v:a.height=P*v,o.w=w+I}},e.prototype.compute=function(e,t,r,n){void 0===n&&(n=!1),this._computePixels(0,e,!0),this._computePixels(1,e,!0),this._computePixels(2,e,!0),this._computePixels(3,e,!0),t.x=this.leftPixels,n?r.width=e.width+(t.x+this.rightPixels):r.width=e.width-(t.x+this.rightPixels),t.y=this.bottomPixels,n?r.height=e.height+(t.y+this.topPixels):r.height=e.height-(t.y+this.topPixels),t.z=this.rightPixels,t.w=this.topPixels},e.prototype.computeArea=function(e,t,r){this._computePixels(0,e,!0),this._computePixels(1,e,!0),this._computePixels(2,e,!0),this._computePixels(3,e,!0),r.width=this.leftPixels+e.width*t.x+this.rightPixels,r.height=this.bottomPixels+e.height*t.y+this.topPixels},e.prototype.enlarge=function(e,t,r,n){this._computePixels(0,e,!0),this._computePixels(1,e,!0),this._computePixels(2,e,!0),this._computePixels(3,e,!0),r.x=this.leftPixels,n.width=e.width*t.x+(r.x+this.rightPixels),r.y=this.bottomPixels,n.height=e.height*t.y+(r.y+this.topPixels),r.z=this.rightPixels,r.w=this.topPixels},e})();a.Auto=1,a.Inherit=2,a.Percentage=4,a.Pixel=8,a.ComputeH=1,a.ComputeV=2,a.ComputeAll=3,a=c=__decorate([e.className("PrimitiveThickness","BABYLON")],a),e.PrimitiveThickness=a;var s=(function(){function t(){this.findFirstOnly=!1,this.intersectHidden=!1,this.pickPosition=e.Vector2.Zero()}return Object.defineProperty(t.prototype,"isIntersected",{get:function(){return this.intersectedPrimitives&&this.intersectedPrimitives.length>0},enumerable:!0,configurable:!0}),t.prototype.isPrimIntersected=function(e){for(var t=0,r=this.intersectedPrimitives;t1&&(t=1),this._opacity!==t&&(this._opacity=t,this._setFlags(e.SmartPropertyPrim.flagActualOpacityDirty),this._spreadActualOpacityChanged(),this._updateRenderMode())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"scaleX",{get:function(){return this._scale.x},set:function(t){if(t<=0)throw new Error("You can't set the scaleX to less or equal to 0");this._scale.x=t,this._setFlags(e.SmartPropertyPrim.flagActualScaleDirty),this._spreadActualScaleDirty(),this._positioningDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"scaleY",{get:function(){return this._scale.y},set:function(t){if(t<=0)throw new Error("You can't set the scaleY to less or equal to 0");this._scale.y=t,this._setFlags(e.SmartPropertyPrim.flagActualScaleDirty),this._spreadActualScaleDirty(),this._positioningDirty()},enumerable:!0,configurable:!0}),r.prototype._spreadActualScaleDirty=function(){for(var t=0,r=this._children;t0){for(var r=new e.BoundingInfo2D,n=h._tpsBB2,i=0,o=this._children;i0},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isPositionAuto",{get:function(){return null==this._position},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"pointerEventObservable",{get:function(){return this._pointerEventObservable},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"zActualOrderChangedObservable",{get:function(){return this._actualZOrderChangedObservable||(this._actualZOrderChangedObservable=new e.Observable),this._actualZOrderChangedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"displayDebugAreas",{get:function(){return this._displayDebugAreas},set:function(t){if(this._displayDebugAreas!==t){if(t===!1)this._debugAreaGroup.dispose(),this._debugAreaGroup=null;else{var r="#F0808040",n="#F08080FF",i="#F0F04040",o="#F0F040FF",a="#F040F040",s="#F040F0FF",l="#40F0F040",u="#40F0F0FF",c=new e.Size(10,10),h=e.Vector2.Zero();this._debugAreaGroup=new e.Group2D({parent:null!=this.parent?this.parent:this,id:"###DEBUG AREA GROUP###",children:[new e.Group2D({id:"###Layout Area###",position:h,size:c,children:[new e.Rectangle2D({id:"###Layout Frame###",position:e.Vector2.Zero(),size:c,fill:null,border:n}),new e.Rectangle2D({id:"###Layout Top###",position:e.Vector2.Zero(),size:c,fill:r}),new e.Rectangle2D({id:"###Layout Left###",position:e.Vector2.Zero(),size:c,fill:r}),new e.Rectangle2D({id:"###Layout Right###",position:e.Vector2.Zero(),size:c,fill:r}),new e.Rectangle2D({id:"###Layout Bottom###",position:e.Vector2.Zero(),size:c,fill:r})]}),new e.Group2D({id:"###Margin Area###",position:h,size:c,children:[new e.Rectangle2D({id:"###Margin Frame###",position:e.Vector2.Zero(),size:c,fill:null,border:o}),new e.Rectangle2D({id:"###Margin Top###",position:e.Vector2.Zero(),size:c,fill:i}),new e.Rectangle2D({id:"###Margin Left###",position:e.Vector2.Zero(),size:c,fill:i}),new e.Rectangle2D({id:"###Margin Right###",position:e.Vector2.Zero(),size:c,fill:i}),new e.Rectangle2D({id:"###Margin Bottom###",position:e.Vector2.Zero(),size:c,fill:i})]}),new e.Group2D({id:"###Padding Area###",position:h,size:c,children:[new e.Rectangle2D({id:"###Padding Frame###",position:e.Vector2.Zero(),size:c,fill:null,border:s}),new e.Rectangle2D({id:"###Padding Top###",position:e.Vector2.Zero(),size:c,fill:a}),new e.Rectangle2D({id:"###Padding Left###",position:e.Vector2.Zero(),size:c,fill:a}),new e.Rectangle2D({id:"###Padding Right###",position:e.Vector2.Zero(),size:c,fill:a}),new e.Rectangle2D({id:"###Padding Bottom###",position:e.Vector2.Zero(),size:c,fill:a})]}),new e.Group2D({id:"###Content Area###",position:h,size:c,children:[new e.Rectangle2D({id:"###Content Frame###",position:e.Vector2.Zero(),size:c,fill:null,border:u}),new e.Rectangle2D({id:"###Content Top###",position:e.Vector2.Zero(),size:c,fill:l}),new e.Rectangle2D({id:"###Content Left###",position:e.Vector2.Zero(),size:c,fill:l}),new e.Rectangle2D({id:"###Content Right###",position:e.Vector2.Zero(),size:c,fill:l}),new e.Rectangle2D({id:"###Content Bottom###",position:e.Vector2.Zero(),size:c,fill:l})]})]}),this._debugAreaGroup._setFlags(e.SmartPropertyPrim.flagNoPartOfLayout),this._updateDebugArea()}this._displayDebugAreas=t}},enumerable:!0,configurable:!0}),r.prototype._updateDebugArea=function(){if(h._updatingDebugArea!==!0){h._updatingDebugArea=!0;for(var t=["Layout","Margin","Padding","Content"],r=["Area","Frame","Top","Left","Right","Bottom"],n=new Array(4),i=0;i<4;i++){n[i]=new Array(6);for(var o=0;o<6;o++)n[i][o]=this._debugAreaGroup.findById("###"+t[i]+" "+r[o]+"###"),o>1&&(n[i][o].levelVisible=!1)}var a=null!=this._layoutAreaPos,s=0!==this.actualPosition.x||0!==this.actualPosition.y,l=this._hasMargin,u=this._hasPadding;n[0][0].levelVisible=a,n[1][0].levelVisible=l,n[2][0].levelVisible=u,n[3][0].levelVisible=!0;var c=e.Vector2.Zero(),d=0,p=new Array(4),f=function(e,t){var r=e.clone(),n=e.clone();t.width>0&&(n.x+=t.width),t.height>0&&(n.y+=t.height),p[d++]={off:e,size:t,min:r,max:n}},g=this instanceof e.Canvas2D,_=this._marginOffset.x+this._marginOffset.z,y=this._marginOffset.y+this._marginOffset.w,m=this.actualSize.multiplyByFloats(g?1:this.scaleX,g?1:this.scaleY),v=a?this.layoutAreaPos.x+this.layoutArea.width:_+m.width,b=a?this.layoutAreaPos.y+this.layoutArea.height:y+m.height,P=a||l||u||!s?e.Vector2.Zero():this.actualPosition;if(f(P,new e.Size(v,b)),a){var C=this.layoutAreaPos.clone();f(C,l||u?this.layoutArea.clone():m.clone()),c=C.clone()}if(l){var S=c.clone();S.x+=this._marginOffset.x,S.y+=this._marginOffset.y;var D=m;f(S,D),c=S.clone()}if(u){var x=c.clone();x.x+=this._paddingOffset.x,x.y+=this._paddingOffset.y;var A=this.contentArea;f(x,A),c=c.add(x)}var O=function(e,t,r,i){n[e][t].position=r,n[e][t].size=i},I=function(e,t,r){var i=n[e];i[2].levelVisible=!0,i[3].levelVisible=!1,i[4].levelVisible=!1,i[5].levelVisible=!1,O(e,1,t,r),O(e,2,t,r)},T=function(t,r){var i=n[t];i[2].levelVisible=!0,i[3].levelVisible=!0,i[4].levelVisible=!0,i[5].levelVisible=!0;var o=p[r],a=p[r+1],s=new e.Vector2(o.min.x,a.max.y),l=new e.Size(o.size.width,o.max.y-s.y),u=new e.Vector2(o.min.x,a.min.y),c=new e.Size(a.min.x-o.min.x,a.max.y-a.min.y),h=new e.Vector2(a.max.x,a.min.y),d=new e.Size(o.max.x-a.max.x,a.max.y-a.min.y),f=new e.Vector2(o.min.x,o.min.y),g=new e.Size(o.size.width,a.min.y-o.min.y);i[1].position=o.off,i[1].size=o.size,i[2].position=s,i[2].size=l,i[3].position=u,i[3].size=c,i[4].position=h,i[4].size=d,i[5].position=f,i[5].size=g};d=0;for(var w=[!1,a,l,u,!0],B=1;B<5;B++)if(w[B]){var R=p[d];O(B-1,0,e.Vector2.Zero(),R.size),4===B?I(B-1,R.off,R.size):T(B-1,d),++d}h._updatingDebugArea=!1}},r.prototype.findById=function(e){if(this._id===e)return this;for(var t=0,r=this._children;tc.prim.actualZOffset)&&(t.topMostIntersectedPrimitive=c),t.findFirstOnly)return t._exit(r),!0}if(!u||!t.findFirstOnly)for(var d=0,p=this._children;d0;)this._children[this._children.length-1].dispose();return!0},r.prototype.onPrimBecomesDirty=function(){this._renderGroup&&!this._isFlagSet(e.SmartPropertyPrim.flagPrimInDirtyList)&&(this._renderGroup._addPrimToDirtyList(this),this._setFlags(e.SmartPropertyPrim.flagPrimInDirtyList))},r.prototype._needPrepare=function(){return this._areSomeFlagsSet(e.SmartPropertyPrim.flagVisibilityChanged|e.SmartPropertyPrim.flagModelDirty|e.SmartPropertyPrim.flagModelUpdate|e.SmartPropertyPrim.flagNeedRefresh)||0!==this._instanceDirtyFlags||this._globalTransformProcessStep!==this._globalTransformStep},r.prototype._prepareRender=function(e){var t=this.owner._globalTransformStep;this._prepareProcessStep0&&(this._globalTransformProcessStep!==this._globalTransformStep||this.checkPropertiesDirty(h.isVisibleProperty.flagId))&&this._children.forEach((function(r){r instanceof e.Group2D&&r.isRenderableGroup||r._prepareRender(t)})),this._clearFlags(e.SmartPropertyPrim.flagModelDirty),this._instanceDirtyFlags=0},r.prototype._canvasPreInit=function(e){},r.CheckParent=function(e){},r.prototype.updateCachedStatesOf=function(e,t){for(var r=0,n=e;r=c.width&&S.height>=c.height?O.computeWithAlignment(S,c,s,l,A,h._size2):A.copyFromFloats(0,0,0,0);var I=h._tpsBB;I.copyFrom(p);var T=h._bMinMax;I.minMaxToRef(T),T.z+=O.leftPixels+O.rightPixels,T.w+=O.topPixels+O.bottomPixels,e.BoundingInfo2D.CreateFromMinMaxToRef(T.x,T.z,T.y,T.w,I);var w=!1;if(this._layoutBoundingInfo?this._layoutBoundingInfo.equals(I)||(this._layoutBoundingInfo.copyFrom(I),w=!0):(this._layoutBoundingInfo=I.clone(),w=!0),w){for(var B=this._parent;B&&B.isSizedByContent;)B._setFlags(e.SmartPropertyPrim.flagLayoutBoundingInfoDirty),B.onPrimitivePropertyDirty(h.actualSizeProperty.flagId),B=B._parent;this.onPrimitivePropertyDirty(h.actualSizeProperty.flagId)}}var R=this.layoutAreaPos;this._marginOffset.x-=g.x*l.x,this._marginOffset.y-=g.y*l.y,this.actualPosition=new e.Vector2(this._marginOffset.x+(R?R.x:0),this._marginOffset.y+(R?R.y:0)),this.actualSize=m.clone(),this._setFlags(e.SmartPropertyPrim.flagLocalTransformDirty),r&&(this._lastAutoSizeArea=this.actualSize),this.displayDebugAreas&&this._updateDebugArea()}finally{e.C2DLogging.setPostMessage((function(){return"Succeeded"})),this._clearFlags(e.SmartPropertyPrim.flagComputingPositioning),t&&this._clearFlags(e.SmartPropertyPrim.flagPositioningDirty)}},Object.defineProperty(r.prototype,"contentArea",{get:function(){return this._isFlagSet(e.SmartPropertyPrim.flagUsePositioning)?(this._isFlagSet(e.SmartPropertyPrim.flagPositioningDirty)&&this._updatePositioning(),this._contentArea):this.size},enumerable:!0,configurable:!0}),r.prototype._patchHierarchy=function(t){if(null==this._owner&&(this._owner=t,this.onSetOwner(),this._setFlags(e.SmartPropertyPrim.flagLayoutBoundingInfoDirty)),null==this._renderGroup){if(this instanceof e.Group2D){var r=this;r.detectGroupStates(),r._trackedNode&&!r._isFlagSet(e.SmartPropertyPrim.flagTrackedGroup)&&r.owner._registerTrackedNode(this)}if(this._renderGroup=this.traverseUp((function(t){return t instanceof e.Group2D&&t.isRenderableGroup})),this._parent&&this._parentLayoutDirty(),this._renderGroup&&this.isDirty){var n=this._renderGroup._renderableData._primDirtyList,i=n.indexOf(this);i===-1&&(this._setFlags(e.SmartPropertyPrim.flagPrimInDirtyList),n.push(this))}for(var o=0,a=this._children;o0&&this._firstZDirtyIndex-10)for(var s=0,l=this._children;s0){var l=this._instanceDataParts[0],u=l.renderMode,c=this.renderMode;if(u!==c){a=u===e.Render2DContext.RenderModeTransparent,s=!0;var h=void 0;switch(c){case e.Render2DContext.RenderModeTransparent:h=t.transparentData;break;case e.Render2DContext.RenderModeAlphaTest:h=t.alphaTestData;break;default:h=t.opaqueData}for(var d=0;d0||t.forceRefreshPrimitive)&&(r=n._primDirtyList.sort((function(e,t){return e.hierarchyDepth-t.hierarchyDepth})),this.updateCachedStatesOf(r,!0));var i=this.actualSize,o=this.actualScale,a=this.owner._canvasLevelScale,s=1/this.owner.engine.getHardwareScalingLevel(),l=i.width*o.x*a.x,u=i.height*o.y*a.y;if((this instanceof e.Canvas2D||"__cachedCanvasGroup__"===this.id)&&null!=this.owner.designSize&&(l=this.owner.engine.getRenderWidth(),u=this.owner.engine.getRenderHeight()),!this._isCachedGroup){var c=this._globalTransform.getTranslation(),h=this.owner._renderingSize.multiplyByFloats(s,s);u=Math.min(u,h.height-c.y),l=Math.min(l,h.width-c.x);var d=c.x,p=c.y;this._viewportPosition.x=d,this._viewportPosition.y=p}if(this._viewportSize.width===l&&this._viewportSize.height===u||(t.forceRefreshPrimitive=!0,this._viewportSize.width=l,this._viewportSize.height=u),n._primDirtyList.length>0||t.forceRefreshPrimitive){if(this._cacheGroupDirty=this._isCachedGroup,n._primNewDirtyList.splice(0),t.forceRefreshPrimitive)for(var f=0,g=this._children;f0)){var a=!i.modelRenderCache.render(i,c);i.opaqueDirty=a,n+=a?1:0}})),r.setAlphaTesting(!0),r.setDepthWrite(!0),c=new e.Render2DContext(e.Render2DContext.RenderModeAlphaTest),this._renderableData._renderGroupInstancesInfo.forEach((function(e,i){var o=t._prepareContext(r,c,i);if(null!==o&&(!t.owner.supportInstancedArray||o>0)){var a=!i.modelRenderCache.render(i,c);i.opaqueDirty=a,n+=a?1:0}})),r.setAlphaTesting(!0),r.setDepthWrite(!1),this._renderableData._transparentListChanged&&this._updateTransparentData(),n+=this._renderTransparentData(),this._cacheGroupDirty=0!==n,this.isCachedGroup?this._unbindCacheTarget():s&&r.setViewport(s),r.setAlphaTesting(l),r.setDepthWrite(u)}},n.prototype._setCacheGroupDirty=function(){this._cacheGroupDirty=!0},n.prototype._updateTransparentData=function(){this.owner._addUpdateTransparentDataCount(1);var t=this._renderableData;t._transparentPrimitives.sort((function(e,t){return t._primitive.actualZOffset-e._primitive.actualZOffset}));for(var r=function(e,r){var n=t._transparentPrimitives[r];return e.groupInsanceInfo===n._groupInstanceInfo&&(n._transparentSegment=e,n._primitive._updateTransparentSegmentIndices(e),!0)},n=0,i=t._transparentSegments;n=this.owner.minPartCountToUseInstancedArray){if(s.partBuffers){if(l.transparentDirty)for(var d=0;d0){for(var l=0;!r.groupInfoPartData[l];)l++;r.partDataEndIndex=r.groupInfoPartData[l]._partData.usedElementCount}return s},n.prototype._setRenderingScale=function(e){this._renderableData._renderingScale!==e&&(this._renderableData._renderingScale=e)},n.prototype._bindCacheTarget=function(){var t,r,n,o=this._renderableData,a=o._renderingScale,s=o._noResizeOnScale,l=null==this.parent;n=s?l?i._uV:this.parent.actualScale.multiply(this.owner._canvasLevelScale):this.actualScale.multiply(this.owner._canvasLevelScale);var u=this.actualSize;l&&this.owner.cachingStrategy===e.Canvas2D.CACHESTRATEGY_CANVAS&&this.owner.isScreenSpace?this.owner.designSize||this.owner.fitRenderingDevice?(i._s.width=this.owner.engine.getRenderWidth(),i._s.height=this.owner.engine.getRenderHeight()):i._s.copyFrom(this.owner.size):(i._s.width=Math.ceil(u.width*n.x*a),i._s.height=Math.ceil(u.height*n.y*a));var c=!i._s.equals(o._cacheSize);if(o._cacheNode){var h=i._s;if(o._cacheNode.getInnerSizeToRef(h),h.width=i._i1.y?(i._i2.x=i._i0.x-i._i1.x,i._i2.y=i._i0.y-i._i1.y,i._i2.lengthSquared()<=n):(i._i1.x=t.width-r,i._i1.y=t.height-r,i._i0.x>=i._i1.x&&i._i0.y>=i._i1.y?(i._i2.x=i._i0.x-i._i1.x,i._i2.y=i._i0.y-i._i1.y,i._i2.lengthSquared()<=n):(i._i1.x=t.width-r,i._i1.y=r,!(i._i0.x>=i._i1.x&&i._i0.y<=i._i1.y)||(i._i2.x=i._i0.x-i._i1.x,i._i2.y=i._i0.y-i._i1.y,i._i2.lengthSquared()<=n))))},o.prototype.updateLevelBoundingInfo=function(){return e.BoundingInfo2D.CreateFromSizeToRef(this.actualSize,this._levelBoundingInfo),!0},o.prototype.createModelRenderCache=function(e){var r=new t(this.owner.engine,e);return r},o.prototype.updateTriArray=function(){if(this.notRounded)return void n.prototype.updateTriArray.call(this);var t=4*i.roundSubdivisions;null==this._primTriArray?this._primTriArray=new e.Tri2DArray(t):this._primTriArray.clear(t);var r=this.actualSize,o=r.width,a=r.height,s=this.roundRadius,l=.25*t,u=.5*t,c=.75*t,h=new e.Vector2(.5*r.width,.5*r.height),d=2*Math.PI,p=s/o,f=s/a,g=function(e,r){e0&&e.push(this.texture),e},o.prototype.levelIntersect=function(e){return!0},Object.defineProperty(o.prototype,"isSizeAuto",{get:function(){return null==this.size},enumerable:!0,configurable:!0}),o.prototype.createModelRenderCache=function(e){var r=new t(this.owner.engine,e);return r},o.prototype.setupModelRenderCache=function(e){for(var t=e,r=this.owner.engine,n=new Float32Array(4),o=0;o<4;o++)n[o]=o;t.vb=r.createVertexBuffer(n);var a=new Float32Array(6);a[0]=0,a[1]=2,a[2]=1,a[3]=0,a[4]=3,a[5]=2,t.ib=r.createIndexBuffer(a),t.texture=this.texture;var s=this.getDataPartEffectInfo(i.SPRITE2D_MAINPARTID,["index"],["alphaTest"],!0);return s&&(t.effectInstanced=r.createEffect("sprite2d",s.attributes,s.uniforms,["diffuseSampler"],s.defines,null)),s=this.getDataPartEffectInfo(i.SPRITE2D_MAINPARTID,["index"],["alphaTest"],!1),t.effect=r.createEffect("sprite2d",s.attributes,s.uniforms,["diffuseSampler"],s.defines,null),t},o.prototype.getUsedShaderCategories=function(e){var t=r.prototype.getUsedShaderCategories.call(this,e);if(e.id===i.SPRITE2D_MAINPARTID){var n=null!=this._scale9;n&&t.push(i.SHAPE2D_CATEGORY_SCALE9)}return t},o.prototype.createInstanceDataParts=function(){return[new n(i.SPRITE2D_MAINPARTID)]},o.prototype.beforeRefreshForLayoutConstruction=function(e){i.layoutConstructMode=!0},o.prototype.afterRefreshForLayoutConstruction=function(e,t){i.layoutConstructMode=!1},o.prototype.refreshInstanceDataPart=function(t){if(!r.prototype.refreshInstanceDataPart.call(this,t))return!1;if(!this.texture.isReady()&&!i.layoutConstructMode)return!1;if(t.id===i.SPRITE2D_MAINPARTID){var n=this._instanceDataParts[0];if(i.layoutConstructMode)n.topLeftUV=e.Vector2.Zero(),n.sizeUV=e.Vector2.Zero(),n.properties=e.Vector3.Zero(),n.textureSize=e.Vector2.Zero(),n.scaleFactor=e.Vector2.Zero(),this.isScale9&&(n.scale9=e.Vector4.Zero());else{var o=this.texture.getBaseSize(),a=this.spriteSize,s=this.spriteLocation,l=this.actualScale;n.topLeftUV=new e.Vector2(s.x/o.width,s.y/o.height);var u=new e.Vector2(a.width/o.width,a.height/o.height);n.sizeUV=u,n.scaleFactor=l,i._prop.x=this.spriteFrame,i._prop.y=this.invertY?1:0,i._prop.z=this.alignToPixel?1:0,n.properties=i._prop,n.textureSize=new e.Vector2(o.width,o.height);var c=this._scale9;if(null!=c){var h=new e.Vector4(c.x*u.x/a.width,c.y*u.y/a.height,c.z*u.x/a.width,c.w*u.y/a.height);n.scale9=h}}}return!0},o.prototype._mustUpdateInstance=function(){var e=this._oldTextureHasAlpha!==(null!=this.texture&&this.texture.hasAlpha);return this._oldTextureHasAlpha=null!=this.texture&&this.texture.hasAlpha,e&&this._updateRenderMode(),e},o.prototype._useTextureAlpha=function(){return null!=this.texture&&this.texture.hasAlpha},o.prototype._shouldUseAlphaFromTexture=function(){return null!=this.texture&&this.texture.hasAlpha&&this.useAlphaFromTexture},o.prototype._updateSpriteScaleFactor=function(){if(this._useSize){var e=this.spriteSize,t=this.size;null!=t&&null!=e&&(this._postScale.x=t.width/e.width,this._postScale.y=t.height/e.height)}},o})(e.RenderablePrim2D);r.SPRITE2D_MAINPARTID=1,r.SHAPE2D_CATEGORY_SCALE9="Scale9",r._prop=e.Vector3.Zero(),r.layoutConstructMode=!1,__decorate([e.modelLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+1,(function(e){return i.textureProperty=e}))],r.prototype,"texture",null),__decorate([e.dynamicLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+2,(function(e){ return i.useAlphaFromTextureProperty=e}))],r.prototype,"useAlphaFromTexture",null),__decorate([e.instanceLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+4,(function(e){return i.spriteSizeProperty=e}),!1,!0)],r.prototype,"spriteSize",null),__decorate([e.instanceLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+5,(function(e){return i.spriteLocationProperty=e}))],r.prototype,"spriteLocation",null),__decorate([e.instanceLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+6,(function(e){return i.spriteFrameProperty=e}))],r.prototype,"spriteFrame",null),__decorate([e.instanceLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+7,(function(e){return i.invertYProperty=e}))],r.prototype,"invertY",null),__decorate([e.modelLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+8,(function(e){return i.spriteScale9Property=e}))],r.prototype,"isScale9",null),r=i=__decorate([e.className("Sprite2D","BABYLON")],r),e.Sprite2D=r;var n=(function(e){function t(t){return e.call(this,t,1)||this}return __extends(t,e),Object.defineProperty(t.prototype,"topLeftUV",{get:function(){return null},set:function(e){},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"sizeUV",{get:function(){return null},set:function(e){},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scaleFactor",{get:function(){return null},set:function(e){},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"textureSize",{get:function(){return null},set:function(e){},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"properties",{get:function(){return null},set:function(e){},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scale9",{get:function(){return null},set:function(e){},enumerable:!0,configurable:!0}),t})(e.InstanceDataBase);__decorate([e.instanceData()],n.prototype,"topLeftUV",null),__decorate([e.instanceData()],n.prototype,"sizeUV",null),__decorate([e.instanceData(r.SHAPE2D_CATEGORY_SCALE9)],n.prototype,"scaleFactor",null),__decorate([e.instanceData()],n.prototype,"textureSize",null),__decorate([e.instanceData()],n.prototype,"properties",null),__decorate([e.instanceData(r.SHAPE2D_CATEGORY_SCALE9)],n.prototype,"scale9",null),e.Sprite2DInstanceData=n;var i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){function t(e,t){return function(){i.addLoader(e,t)}}var r=(function(){function e(){}return e})();e.AtlasSubPictureInfo=r;var n=(function(){function t(){}return t.prototype.createSprites=function(e,t){var r=this,n=new Array,i=0;return this.subPictures.forEach((function(o,a){if(!e||e(i++,o,a,t)){var s=r.createSprite(o,t);s&&n.push(s)}})),n},t.prototype.createSprite=function(t,r){var n=this.subPictures.get(t);if(!n)return null;r||(r={});var i=r;i.id=t,i.spriteLocation=n.location,i.spriteSize=n.size;var o=new e.Sprite2D(this.texture,r);return o},t})();e.AtlasPictureInfo=n;var i=(function(){function t(){}return t.addLoader=function(e,r){var n=t.plugins.getOrAddWithFactory(e.toLocaleLowerCase(),(function(){return new Array}));n.push(r)},t.loadFromUrl=function(r,n,i,o){return void 0===o&&(o=null),e.Tools.LoadFile(n,(function(e){var a=n.split(".").pop().split(/\#|\?/)[0],s=t.plugins.get(a.toLocaleLowerCase());if(!s)return void(o&&o("couldn't find a plugin for this file extension",-1));for(var l=0,u=s;l0&&v++,v=0,y=0,m=0;else{var D=a.getChar(S),x=0;if(x="\t"===S?P:D.xAdvance,u.x+=x,d[C]=x,this._isWhiteSpaceCharHoriz(S)?(m>0&&v++,y=0,m=0):(m+=D.xAdvance,y++),this._wordWrap&&v>0&&u.x>g){h.push(u.x-m),f-=y;for(var A=C-y;this._isWhiteSpaceCharHoriz(b[A]);)h[h.length-1]-=d[A],A--;if(p.push(f),this._isWhiteSpaceCharHoriz(b[C])){for(var O=0;this._isWhiteSpaceCharHoriz(b[C+O]);)O++,d[C+O]=0;C+=O-1,u.x=0,f=O-1}else f=y,u.x=m;v=0}}}h.push(u.x),p.push(f);for(var I=b.length-1;this._isWhiteSpaceCharHoriz(b[I]);)h[h.length-1]-=d[I],I--;var T=0,w=0,B=this.textAlignmentH,R=this.textAlignmentV;if(u.x=0,B==i.AlignRight||B==i.AlignCenter)for(var E=0;Ew&&(w=h[E]);var L=h.length*c,F=this.padding.leftPixels;B==i.AlignRight?F+=g-w:B==i.AlignCenter&&(F+=.5*(g-w)),u.x+=Math.floor(F),u.y+=_+L-c,u.y+=this.padding.bottomPixels,R==i.AlignBottom?u.y-=_:R==i.AlignCenter?u.y-=.5*(_-L)+h.length*c:u.y-=h.length*c;for(var M=a.lineHeight,V=0;VMath.max(e,r))&&!(uMath.max(i,a))},o.prototype._updateMinMax=function(e,t){t>=e.length||(this._boundingMin.x=Math.min(this._boundingMin.x,e[t]),this._boundingMax.x=Math.max(this._boundingMax.x,e[t]),this._boundingMin.y=Math.min(this._boundingMin.y,e[t+1]),this._boundingMax.y=Math.max(this._boundingMax.y,e[t+1]))},o.prototype._store=function(t,r,n,o,a,s,l,u,c){var h=null!=u&&!isNaN(u),d=n*(h?8:4);if(!(d>=t.length)){0===n?this._perp(s,i._startDir):n===o-1&&(this._perp(s,i._endDir),i._endDir.x*=-1,i._endDir.y*=-1);var p=!1;if(t[d+0]=a.x+s.x*l,t[d+1]=a.y+s.y*l,t[d+2]=a.x+s.x*-l,t[d+3]=a.y+s.y*-l,this._updateMinMax(t,d),this._updateMinMax(t,d+2),0!=c){var f=c*(h?8:4);if(this._intersect(t[d+0],t[d+1],t[f+0],t[f+1],t[d+2],t[d+3],t[f+2],t[f+3])){p=!0;var g=t[d+0];t[d+0]=t[d+2],t[d+2]=g,g=t[d+1],t[d+1]=t[d+3],t[d+3]=g}}if(h){var _=l+u;t[d+4]=a.x+s.x*(p?-_:_),t[d+5]=a.y+s.y*(p?-_:_),t[d+6]=a.x+s.x*(p?_:-_),t[d+7]=a.y+s.y*(p?_:-_),this._updateMinMax(t,d+4),this._updateMinMax(t,d+6)}r&&(d+=h?4:0,r.push(new e.Vector2(t[d+0],t[d+1])),r.push(new e.Vector2(t[d+2],t[d+3])))}},o.prototype._getCapSize=function(e,t){void 0===t&&(t=!1);var r=i._roundCapSubDiv,n=0,o=0;switch(e){case i.NoCap:!this.closed&&t?(n=4,o=6):n=o=0;break;case i.RoundCap:t?(n=r,o=3*(r-2)):(n=r/2+1,o=r/2*3);break;case i.ArrowCap:t?(n=12,o=24):(n=3,o=3);break;case i.TriangleCap:t?(n=6,o=12):(n=3,o=3);break;case i.DiamondAnchorCap:t?(n=10,o=24):(n=5,o=9);break;case i.SquareAnchorCap:t?(n=12,o=30):(n=4,o=6);break;case i.RoundAnchorCap:t?(n=2*r,o=6*(r-1)):(n=r+1,o=3*(r+1))}return{vbsize:2*n,ibsize:o}},o.prototype._storeVertex=function(e,t,r,n,o,a,s){var l=Math.cos(o),u=Math.sin(o);i._tpsV.x=l*a.x+-u*a.y+n.x,i._tpsV.y=u*a.x+l*a.y+n.y;var c=t+2*r;return e[c+0]=i._tpsV.x,e[c+1]=i._tpsV.y,s&&(s.push(i._tpsV.x),s.push(i._tpsV.y)),this._updateMinMax(e,c),(t+2*r)/2},o.prototype._storeIndex=function(e,t,r,n){e[t+r]=n},o.prototype._buildCap=function(t,r,n,o,a,s,l,u,c,h){var d=i._roundCapSubDiv,p=new e.Vector2(1,0),f=Math.atan2(c.y,c.x)-Math.atan2(p.y,p.x),g=s/2,_=s,y=null!=l,m=l;switch(u){case i.NoCap:if(y&&!this.closed){var v=0,b=0,P=this._storeVertex(t,r,v++,a,f,new e.Vector2(0,g+m),h),C=this._storeVertex(t,r,v++,a,f,new e.Vector2(m,g+m),h),S=this._storeVertex(t,r,v++,a,f,new e.Vector2(m,-(g+m)),h),D=this._storeVertex(t,r,v++,a,f,new e.Vector2(0,-(g+m)),h);this._storeIndex(n,o,b++,P),this._storeIndex(n,o,b++,C),this._storeIndex(n,o,b++,S),this._storeIndex(n,o,b++,P),this._storeIndex(n,o,b++,S),this._storeIndex(n,o,b++,D)}break;case i.ArrowCap:g*=2;case i.TriangleCap:if(y){var x=u===i.TriangleCap?m:Math.sqrt(m*m*2),P=this._storeVertex(t,r,0,a,f,new e.Vector2(0,g),null),C=this._storeVertex(t,r,1,a,f,new e.Vector2(g,0),null),S=this._storeVertex(t,r,2,a,f,new e.Vector2(0,-g),null),D=this._storeVertex(t,r,3,a,f,new e.Vector2(0,g+x),h),A=this._storeVertex(t,r,4,a,f,new e.Vector2(g+x,0),h),O=this._storeVertex(t,r,5,a,f,new e.Vector2(0,-(g+x)),h),b=0;if(this._storeIndex(n,o,b++,P),this._storeIndex(n,o,b++,D),this._storeIndex(n,o,b++,A),this._storeIndex(n,o,b++,P),this._storeIndex(n,o,b++,A),this._storeIndex(n,o,b++,C),this._storeIndex(n,o,b++,O),this._storeIndex(n,o,b++,S),this._storeIndex(n,o,b++,C),this._storeIndex(n,o,b++,O),this._storeIndex(n,o,b++,C),this._storeIndex(n,o,b++,A),u===i.ArrowCap){var I=s/2,T=this._storeVertex(t,r,9,a,f,new e.Vector2(0,-(I+m)),null),w=this._storeVertex(t,r,11,a,f,new e.Vector2(-m,-(g+x)),h),B=this._storeVertex(t,r,10,a,f,new e.Vector2(-m,-(I+m)),h),R=this._storeVertex(t,r,6,a,f,new e.Vector2(0,I+m),null),E=this._storeVertex(t,r,7,a,f,new e.Vector2(-m,I+m),h),L=this._storeVertex(t,r,8,a,f,new e.Vector2(-m,g+x),h);this._storeIndex(n,o,b++,R),this._storeIndex(n,o,b++,E),this._storeIndex(n,o,b++,L),this._storeIndex(n,o,b++,R),this._storeIndex(n,o,b++,L),this._storeIndex(n,o,b++,D),this._storeIndex(n,o,b++,T),this._storeIndex(n,o,b++,w),this._storeIndex(n,o,b++,B),this._storeIndex(n,o,b++,T),this._storeIndex(n,o,b++,O),this._storeIndex(n,o,b++,w)}}else{var P=this._storeVertex(t,r,0,a,f,new e.Vector2(0,g),h),C=this._storeVertex(t,r,1,a,f,new e.Vector2(g,0),h),S=this._storeVertex(t,r,2,a,f,new e.Vector2(0,-g),h);this._storeIndex(n,o,0,P),this._storeIndex(n,o,1,C),this._storeIndex(n,o,2,S)}break;case i.RoundCap:if(y)for(var F=-Math.PI/2,M=Math.PI/(d/2-1),b=0,V=0;V0&&(this._storeIndex(n,o,b++,P-2),this._storeIndex(n,o,b++,C-2),this._storeIndex(n,o,b++,C),this._storeIndex(n,o,b++,P-2),this._storeIndex(n,o,b++,C),this._storeIndex(n,o,b++,P)),F+=M}else{var z=this._storeVertex(t,r,0,a,f,new e.Vector2(0,0),null),F=-Math.PI/2,M=Math.PI/(d/2-1);this._storeVertex(t,r,1,a,f,new e.Vector2(Math.cos(F)*g,Math.sin(F)*g),null),F+=M;for(var V=1;V0&&(this._storeIndex(n,o,b++,P-2),this._storeIndex(n,o,b++,C-2),this._storeIndex(n,o,b++,C),this._storeIndex(n,o,b++,P-2),this._storeIndex(n,o,b++,C),this._storeIndex(n,o,b++,P)),F+=M}else{var z=this._storeVertex(t,r,0,a,f,U,null);this._storeVertex(t,r,1,a,f,new e.Vector2(N+Math.cos(F)*_,Math.sin(F)*_),null),F+=M;for(var V=1;V2&&this.closed){var _=this.points[c-2],y=this.points[0],m=this.points[1];this._direction(y,_,o),this._direction(m,y,a),this._perp(o,u);var v=this._computeMiter(s,l,o,a);if(this._store(t,null,0,c,this.points[0],l,v*n,v*i,1),r){var b=null==i?0:4;r[0].x=t[b+0],r[0].y=t[b+1],r[1].x=t[b+2],r[1].y=t[b+3]}}this.closed&&this.points.splice(c-1)},o.prototype.setupModelRenderCache=function(t){var r=t,n=this.owner.engine;if(null===this._fillVB&&this._computeLines2D(),this.fill){r.fillVB=n.createVertexBuffer(this._fillVB),r.fillIB=n.createIndexBuffer(this._fillIB),r.fillIndicesCount=this._fillIB.length;var i=this.getDataPartEffectInfo(e.Shape2D.SHAPE2D_FILLPARTID,["position"],null,!0);i&&(r.effectFillInstanced=n.createEffect("lines2d",i.attributes,i.uniforms,[],i.defines,null)),i=this.getDataPartEffectInfo(e.Shape2D.SHAPE2D_FILLPARTID,["position"],null,!1),r.effectFill=n.createEffect("lines2d",i.attributes,i.uniforms,[],i.defines,null)}if(this.border){r.borderVB=n.createVertexBuffer(this._borderVB),r.borderIB=n.createIndexBuffer(this._borderIB),r.borderIndicesCount=this._borderIB.length;var i=this.getDataPartEffectInfo(e.Shape2D.SHAPE2D_BORDERPARTID,["position"],null,!0);i&&(r.effectBorderInstanced=n.createEffect({vertex:"lines2d",fragment:"lines2d"},i.attributes,i.uniforms,[],i.defines,null)),i=this.getDataPartEffectInfo(e.Shape2D.SHAPE2D_BORDERPARTID,["position"],null,!1),r.effectBorder=n.createEffect({vertex:"lines2d",fragment:"lines2d"},i.attributes,i.uniforms,[],i.defines,null)}return this._fillVB=null,this._fillIB=null,this._borderVB=null,this._borderIB=null,r},o.prototype.updateTriArray=function(){this._primTriArrayDirty&&this._computeLines2D()},o.prototype._computeLines2D=function(){this._boundingMin=new e.Vector2(Number.MAX_VALUE,Number.MAX_VALUE),this._boundingMax=new e.Vector2(Number.MIN_VALUE,Number.MIN_VALUE);var t=new Array,r=new Array,n=new Array;if(this.fill){var o=this._getCapSize(this.startCap),a=this._getCapSize(this.endCap),s=this.points.length,l=2*s*2+o.vbsize+a.vbsize;this._fillVB=new Float32Array(l);var u=this._fillVB,c=this.fillThickness/2,h=this.points.length;this._buildLine(u,this.border?null:t,c);var d=2*h,p=2*(s-(this.closed?0:1));this._fillIB=new Float32Array(3*p+o.ibsize+a.ibsize);for(var f=this._fillIB,g=0;g0&&(y=Earcut.earcut(r,null,2));var m;n.length>0&&(m=Earcut.earcut(n,null,2));var v=this.points.length,s=2*(this.closed?v:v-1)+(null!=y?(y.length+m.length)/3:0);this._primTriArray?this._primTriArray.clear(s):this._primTriArray=new e.Tri2DArray(s);var b=this._primTriArray,P=this.closed?v+1:v;i._prevA.copyFrom(t[0]),i._prevB.copyFrom(t[1]);for(var C=0,g=1;g0&&t._handlePointerEventForInteraction(e,null,r)}))):this._scenePointerObserver&&(this.scene.onPointerObservable.remove(this._scenePointerObserver),this._scenePointerObserver=null)}},n.prototype._setPointerCapture=function(t,r){if(this.isPointerCaptured(t))return!1;try{this.engine.getRenderingCanvas().setPointerCapture(t)}catch(e){}return this._primPointerInfo.updateRelatedTarget(r,e.Vector2.Zero()),this._bubbleNotifyPrimPointerObserver(r,e.PrimitivePointerInfo.PointerGotCapture,null),this._capturedPointers.add(t.toString(),r),!0},n.prototype._releasePointerCapture=function(t,r){if(this._capturedPointers.get(t.toString())!==r)return!1;try{this.engine.getRenderingCanvas().releasePointerCapture(t)}catch(e){}return this._primPointerInfo.updateRelatedTarget(r,e.Vector2.Zero()),this._bubbleNotifyPrimPointerObserver(r,e.PrimitivePointerInfo.PointerLostCapture,null),this._capturedPointers.remove(t.toString()),!0},n.prototype.isPointerCaptured=function(e){return this._capturedPointers.contains(e.toString())},n.prototype.getCapturedPrimitive=function(e){return 0===this._capturedPointers.count?null:this._capturedPointers.get(e.toString())},n.prototype._handlePointerEventForInteraction=function(t,r,n){if(!this.isDisposed){if(r){if(!this._updatePointerInfo(t,r))return}else this._primPointerInfo.canvasPointerPos=null;var i=this.getCapturedPrimitive(this._primPointerInfo.pointerId);if(this._updateIntersectionList(r?this._primPointerInfo.canvasPointerPos:null,null!==i,!0),this._updateOverStatus(!0),this._actualOverPrimitive||i){var o=i||this._actualOverPrimitive.prim,a=i?this._primPointerInfo.canvasPointerPos.subtract(new e.Vector2(o.globalTransform.m[4],o.globalTransform.m[5])):this._actualOverPrimitive.intersectionLocation;this._primPointerInfo.updateRelatedTarget(o,a);var s=!1;t.type===e.PointerEventTypes.POINTERWHEEL?s=!this._bubbleNotifyPrimPointerObserver(o,e.PrimitivePointerInfo.PointerMouseWheel,t):t.type===e.PointerEventTypes.POINTERMOVE?s=!this._bubbleNotifyPrimPointerObserver(o,e.PrimitivePointerInfo.PointerMove,t):t.type===e.PointerEventTypes.POINTERDOWN?s=!this._bubbleNotifyPrimPointerObserver(o,e.PrimitivePointerInfo.PointerDown,t):t.type===e.PointerEventTypes.POINTERUP&&(s=!this._bubbleNotifyPrimPointerObserver(o,e.PrimitivePointerInfo.PointerUp,t)),n.skipNextObservers=s}}},n.prototype._updatePointerInfo=function(t,r){var n=this._canvasLevelScale.multiplyByFloats(this.scaleX,this.scaleY),i=this._primPointerInfo;i.cancelBubble=!1,i.canvasPointerPos||(i.canvasPointerPos=e.Vector2.Zero());var o=this._scene.cameraToUseForPointers||this._scene.activeCamera;if(!o||!o.viewport)return!1;var a=this._scene.getEngine();if(this._isScreenSpace){var s=o.viewport,l=a.getRenderWidth(),u=a.getRenderHeight(),c=s.toGlobal(l,u),h=r.x-c.x,d=r.y-c.y;i.canvasPointerPos.x=(h-this.actualPosition.x)/n.x,i.canvasPointerPos.y=(u-d-this.actualPosition.y)/n.y}else i.canvasPointerPos.x=r.x/n.x,i.canvasPointerPos.y=r.y/n.x;if(i.mouseWheelDelta=0,t.type===e.PointerEventTypes.POINTERWHEEL){var p=t.event;p.wheelDelta?i.mouseWheelDelta=p.wheelDelta/(40*e.PrimitivePointerInfo.MouseWheelPrecision):p.detail&&(i.mouseWheelDelta=-p.detail/e.PrimitivePointerInfo.MouseWheelPrecision)}else{var f=t.event;i.ctrlKey=f.ctrlKey,i.altKey=f.altKey,i.shiftKey=f.shiftKey,i.metaKey=f.metaKey,i.button=f.button,i.buttons=f.buttons,i.pointerId=f.pointerId,i.width=f.width,i.height=f.height,i.presssure=f.pressure,i.tilt.x=f.tiltX,i.tilt.y=f.tiltY,i.isCaptured=null!==this.getCapturedPrimitive(f.pointerId)}return!0},n.prototype._updateIntersectionList=function(e,t,r){if(r||this.scene.getRenderId()!==this._intersectionRenderId){var n=o._interInfo,i=null==e;i||(this._globalTransform||this.updateCachedStates(!0),n.pickPosition.x=e.x,n.pickPosition.y=e.y,n.findFirstOnly=!1,t||this.levelBoundingInfo.doesIntersect(n.pickPosition)?(this.intersect(n),n.intersectedPrimitives=n.intersectedPrimitives.sort((function(e,t){return e.prim.actualZOffset-t.prim.actualZOffset}))):(n.intersectedPrimitives=new Array,n.topMostIntersectedPrimitive=null)),this._previousIntersectionList=this._actualIntersectionList,this._actualIntersectionList=i?new Array:n.intersectedPrimitives,this._previousOverPrimitive=this._actualOverPrimitive,this._actualOverPrimitive=i?null:n.topMostIntersectedPrimitive;var a=null!=this._previousOverPrimitive?this._previousOverPrimitive.prim:null,s=null!=this._actualOverPrimitive?this._actualOverPrimitive.prim:null;a!==s&&this.onPropertyChanged("overPrim",this._previousOverPrimitive?this._previousOverPrimitive.prim:null,this._actualOverPrimitive?this._actualOverPrimitive.prim:null),this._intersectionRenderId=this.scene.getRenderId()}},n.prototype._updateOverStatus=function(t){if((t||this.scene.getRenderId()!==this._hoverStatusRenderId)&&this._actualIntersectionList){null==this._previousIntersectionList&&(this._previousIntersectionList=[]);var r=this._previousOverPrimitive?this._previousOverPrimitive.prim:null,n=this._actualOverPrimitive?this._actualOverPrimitive.prim:null;if(r!==n){var i=this.getCapturedPrimitive(this._primPointerInfo.pointerId);if(i)i===r?(this._primPointerInfo.updateRelatedTarget(r,this._previousOverPrimitive.intersectionLocation),this._bubbleNotifyPrimPointerObserver(r,e.PrimitivePointerInfo.PointerOut,null)):i===n&&(this._primPointerInfo.updateRelatedTarget(n,this._actualOverPrimitive.intersectionLocation),this._bubbleNotifyPrimPointerObserver(n,e.PrimitivePointerInfo.PointerOver,null));else{for(var o=function(t){e.Tools.first(a._actualIntersectionList,(function(e){return e.prim===t.prim}))||(a._primPointerInfo.updateRelatedTarget(t.prim,t.intersectionLocation),a._bubbleNotifyPrimPointerObserver(t.prim,e.PrimitivePointerInfo.PointerOut,null))},a=this,s=0,l=this._previousIntersectionList;se.Scene.LongPressDelay&&Math.abs(o._pickStartingPosition.x-a.pickPosition.x)-1&&o._INSTANCES.splice(e,1),!0},Object.defineProperty(n.prototype,"scene",{get:function(){return this._scene},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"engine",{get:function(){return this._engine},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"renderObservable",{get:function(){return this._renderObservable||(this._renderObservable=new e.Observable),this._renderObservable},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"cachingStrategy",{get:function(){return this._cachingStrategy},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isScreenSpace",{get:function(){return this._isScreenSpace},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"worldSpaceCanvasNode",{get:function(){return this._worldSpaceNode},set:function(e){this._worldSpaceNode=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"supportInstancedArray",{get:function(){return this._supprtInstancedArray},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"backgroundFill",{get:function(){return this._background&&this._background.isVisible?this._background.fill:null},set:function(e){this.checkBackgroundAvailability(),e!==this._background.fill&&(this._background.fill=e,this._background.levelVisible=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"backgroundBorder",{ get:function(){return this._background&&this._background.isVisible?this._background.border:null},set:function(e){this.checkBackgroundAvailability(),e!==this._background.border&&(this._background.border=e,this._background.levelVisible=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"backgroundBorderThickness",{get:function(){return this._background&&this._background.isVisible?this._background.borderThickness:null},set:function(e){this.checkBackgroundAvailability(),e!==this._background.borderThickness&&(this._background.borderThickness=e)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"backgroundRoundRadius",{get:function(){return this._background&&this._background.isVisible?this._background.roundRadius:null},set:function(e){this.checkBackgroundAvailability(),e!==this._background.roundRadius&&(this._background.roundRadius=e,this._background.levelVisible=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"interactionEnabled",{get:function(){return this._interactionEnabled},set:function(e){this._setupInteraction(e)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"fitRenderingDevice",{get:function(){return this._fitRenderingDevice},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"designSize",{get:function(){return this._designSize},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"designSizeUseHorizAxis",{get:function(){return this._designUseHorizAxis},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"designSizeUseHorizeAxis",{set:function(e){this._designUseHorizAxis=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"overPrim",{get:function(){return this._actualIntersectionList&&this._actualIntersectionList.length>0?this._actualIntersectionList[0].prim:null},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"_engineData",{get:function(){return this.__engineData},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"unitScaleFactor",{get:function(){return this._unitScaleFactor},enumerable:!0,configurable:!0}),n.prototype.createCanvasProfileInfoCanvas=function(){if(this._profilingCanvas)return this._profilingCanvas;var t=new i(this.scene,{id:"ProfileInfoCanvas",cachingStrategy:o.CACHESTRATEGY_DONTCACHE,children:[new e.Rectangle2D({id:"ProfileBorder",border:"#FFFFFFFF",borderThickness:2,roundRadius:5,fill:"#C04040C0",marginAlignment:"h: left, v: top",margin:"10",padding:"10",children:[new e.Text2D("Stats",{id:"ProfileInfoText",marginAlignment:"h: left, v: top",fontName:"12pt Lucida Console",fontSignedDistanceField:!0})]})]});return this._profileInfoText=t.findById("ProfileInfoText"),this._profilingCanvas=t,t},n.prototype.checkBackgroundAvailability=function(){if(this._cachingStrategy===o.CACHESTRATEGY_TOPLEVELGROUPS)throw Error("Can't use Canvas Background with the caching strategy TOPLEVELGROUPS")},n.prototype._initPerfMetrics=function(){this.drawCallsOpaqueCounter.fetchNewFrame(),this.drawCallsAlphaTestCounter.fetchNewFrame(),this.drawCallsTransparentCounter.fetchNewFrame(),this.groupRenderCounter.fetchNewFrame(),this.updateTransparentDataCounter.fetchNewFrame(),this.updateCachedStateCounter.fetchNewFrame(),this.updateLayoutCounter.fetchNewFrame(),this.updatePositioningCounter.fetchNewFrame(),this.updateLocalTransformCounter.fetchNewFrame(),this.updateGlobalTransformCounter.fetchNewFrame(),this.boundingInfoRecomputeCounter.fetchNewFrame(),this.layoutBoundingInfoUpdateCounter.fetchNewFrame(),this.canvasRenderTimeCounter.beginMonitoring()},n.prototype._fetchPerfMetrics=function(){this.drawCallsOpaqueCounter.addCount(0,!0),this.drawCallsAlphaTestCounter.addCount(0,!0),this.drawCallsTransparentCounter.addCount(0,!0),this.groupRenderCounter.addCount(0,!0),this.updateTransparentDataCounter.addCount(0,!0),this.updateCachedStateCounter.addCount(0,!0),this.updateLayoutCounter.addCount(0,!0),this.updatePositioningCounter.addCount(0,!0),this.updateLocalTransformCounter.addCount(0,!0),this.updateGlobalTransformCounter.addCount(0,!0),this.boundingInfoRecomputeCounter.addCount(0,!0),this.layoutBoundingInfoUpdateCounter.addCount(0,!0),this.canvasRenderTimeCounter.endMonitoring(!0)},n.prototype._updateProfileCanvas=function(){if(null!=this._profileInfoText){var e=function(e){return(Math.round(100*e)/100).toString()},t="Render Time: avg:"+e(this.canvasRenderTimeCounter.lastSecAverage)+"ms "+e(this.canvasRenderTimeCounter.current)+"ms\nDraw Calls:\n"+(" - Opaque: "+e(this.drawCallsOpaqueCounter.current)+", (avg:"+e(this.drawCallsOpaqueCounter.lastSecAverage)+", t:"+e(this.drawCallsOpaqueCounter.total)+")\n")+(" - AlphaTest: "+e(this.drawCallsAlphaTestCounter.current)+", (avg:"+e(this.drawCallsAlphaTestCounter.lastSecAverage)+", t:"+e(this.drawCallsAlphaTestCounter.total)+")\n")+(" - Transparent: "+e(this.drawCallsTransparentCounter.current)+", (avg:"+e(this.drawCallsTransparentCounter.lastSecAverage)+", t:"+e(this.drawCallsTransparentCounter.total)+")\n")+("Group Render: "+this.groupRenderCounter.current+", (avg:"+e(this.groupRenderCounter.lastSecAverage)+", t:"+e(this.groupRenderCounter.total)+")\n")+("Update Transparent Data: "+this.updateTransparentDataCounter.current+", (avg:"+e(this.updateTransparentDataCounter.lastSecAverage)+", t:"+e(this.updateTransparentDataCounter.total)+")\n")+("Update Cached States: "+this.updateCachedStateCounter.current+", (avg:"+e(this.updateCachedStateCounter.lastSecAverage)+", t:"+e(this.updateCachedStateCounter.total)+")\n")+(" - Update Layout: "+this.updateLayoutCounter.current+", (avg:"+e(this.updateLayoutCounter.lastSecAverage)+", t:"+e(this.updateLayoutCounter.total)+")\n")+(" - Update Positioning: "+this.updatePositioningCounter.current+", (avg:"+e(this.updatePositioningCounter.lastSecAverage)+", t:"+e(this.updatePositioningCounter.total)+")\n")+(" - Update Local Trans: "+this.updateLocalTransformCounter.current+", (avg:"+e(this.updateLocalTransformCounter.lastSecAverage)+", t:"+e(this.updateLocalTransformCounter.total)+")\n")+(" - Update Global Trans: "+this.updateGlobalTransformCounter.current+", (avg:"+e(this.updateGlobalTransformCounter.lastSecAverage)+", t:"+e(this.updateGlobalTransformCounter.total)+")\n")+(" - BoundingInfo Recompute: "+this.boundingInfoRecomputeCounter.current+", (avg:"+e(this.boundingInfoRecomputeCounter.lastSecAverage)+", t:"+e(this.boundingInfoRecomputeCounter.total)+")\n")+(" - LayoutBoundingInfo Recompute: "+this.layoutBoundingInfoUpdateCounter.current+", (avg:"+e(this.layoutBoundingInfoUpdateCounter.lastSecAverage)+", t:"+e(this.layoutBoundingInfoUpdateCounter.total)+")");this._profileInfoText.text=t}},n.prototype._addDrawCallCount=function(t,r){switch(r){case e.Render2DContext.RenderModeOpaque:return void this._drawCallsOpaqueCounter.addCount(t,!1);case e.Render2DContext.RenderModeAlphaTest:return void this._drawCallsAlphaTestCounter.addCount(t,!1);case e.Render2DContext.RenderModeTransparent:return void this._drawCallsTransparentCounter.addCount(t,!1)}},n.prototype._addGroupRenderCount=function(e){this._groupRenderCounter&&this._groupRenderCounter.addCount(e,!1)},n.prototype._addUpdateTransparentDataCount=function(e){this._updateTransparentDataCounter&&this._updateTransparentDataCounter.addCount(e,!1)},n.prototype.addUpdateCachedStateCounter=function(e){this._updateCachedStateCounter&&this._updateCachedStateCounter.addCount(e,!1)},n.prototype.addUpdateLayoutCounter=function(e){this._updateLayoutCounter&&this._updateLayoutCounter.addCount(e,!1)},n.prototype.addUpdatePositioningCounter=function(e){this._updatePositioningCounter&&this._updatePositioningCounter.addCount(e,!1)},n.prototype.addupdateLocalTransformCounter=function(e){this._updateLocalTransformCounter&&this._updateLocalTransformCounter.addCount(e,!1)},n.prototype.addUpdateGlobalTransformCounter=function(e){this._updateGlobalTransformCounter&&this._updateGlobalTransformCounter.addCount(e,!1)},n.prototype.addLayoutBoundingInfoUpdateCounter=function(e){this._layoutBoundingInfoUpdateCounter&&this._layoutBoundingInfoUpdateCounter.addCount(e,!1)},n.prototype._updateTrackedNodes=function(){var t=this.scene.cameraToUseForPointers||this.scene.activeCamera;t.getViewMatrix().multiplyToRef(t.getProjectionMatrix(),o._m);for(var r=this.engine.getRenderHeight(),n=t.viewport.toGlobal(this.engine.getRenderWidth(),r),i=o._tmpVec3,a=o._tmpMtx,s=0,l=this._trackedGroups;s=0&&d.z<1;var p=this.scale;u.x=Math.round(d.x/p),u.y=Math.round((r-d.y)/p)}}if(this._trackNode){var f=null,g=null,_=this._trackNode.getWorldMatrix(),y=_.getTranslation().add(this._trackNodeOffset),m=this,v=m.worldSpaceCanvasNode;if(this._trackNodeBillboard){var b=t.getViewMatrix().clone().invert();b.decompose(o.tS,o.tR,o.tT),f=o.tR.clone()}_.decompose(o.tS,o.tR,o.tT);var P=e.Matrix.Compose(o.tS,o.tR,e.Vector3.Zero());if(y=_.getTranslation().add(e.Vector3.TransformCoordinates(this._trackNodeOffset,P)),1!==o.tS.lengthSquared()&&(g=o.tS.clone()),this._trackNodeBillboard||(f=o.tR.clone()),!(v instanceof e.AbstractMesh))throw new Error("Can't Track another Scene Node Type than AbstractMesh right now, call me lazy!");v.position=y,v.rotationQuaternion=f,g&&(v.scaling=g)}},n.prototype.updateCanvasLayout=function(e){this._updateCanvasState(e)},n.prototype._updateAdaptiveSizeWorldCanvas=function(){if(!(this._globalTransformStep<2)){var t=this.worldSpaceCanvasNode,r=t.getBoundingInfo().boundingBox,n=r.vectorsWorld,i=this.scene.cameraToUseForPointers||this.scene.activeCamera;i.getViewMatrix().multiplyToRef(i.getProjectionMatrix(),o._m);for(var a=i.viewport.toGlobal(this.engine.getRenderWidth(),this.engine.getRenderHeight()),s=new Array(4),l=0;l<4;l++)s[l]=e.Vector3.Project(n[l],o._mI,o._m,a);var u=s[3].subtract(s[0]).length(),c=s[3].subtract(s[1]).length(),h=s[1].subtract(s[2]).length(),d=s[2].subtract(s[0]).length(),p=Math.round(Math.max(c,d)),f=Math.round(Math.max(h,u)),g=p>f,_=Math.max(p,f);_=_<256?256:Math.pow(2,Math.ceil(Math.log(_)/Math.log(2))),_=Math.min(_,this._maxAdaptiveWorldSpaceCanvasSize);var y=_/(g?this.size.width:this.size.height);if(y!==this.scale){var m=y;this._setRenderingScale(m)}}},n.prototype._updateCanvasState=function(t){if(t||this.scene.getRenderId()!==this._updateRenderId){var r=this.engine.getHardwareScalingLevel();this._curHWScale=r;var n=!1,i=this.engine.getRenderWidth()*r;i!==this._renderingSize.width&&(n=!0),this._renderingSize.width=i;var a=this.engine.getRenderHeight()*r;a!==this._renderingSize.height&&(n=!0),this._renderingSize.height=a;var s=o._pCLS;if(s.copyFrom(this._canvasLevelScale),this._designSize){var l=void 0;l=this._designUseHorizAxis?this._renderingSize.width/(this._designSize.width*r):this._renderingSize.height/(this._designSize.height*r),this.size=this._designSize.clone(),this._canvasLevelScale.copyFromFloats(l,l)}else{var u=1/this._curHWScale;this._canvasLevelScale.copyFromFloats(u,u)}if(!s.equals(this._canvasLevelScale)){for(var c=0,h=this.children;cS.width||f.height>S.height)&&(S.width=Math.pow(2,Math.ceil(Math.log(f.width)/Math.log(2))),S.height=Math.pow(2,Math.ceil(Math.log(f.height)/Math.log(2))));var D="groupsMapChache"+this._mapCounter++ +"forCanvas"+this.id;_=new e.MapTexture(D,this._scene,S,i?e.Texture.TRILINEAR_SAMPLINGMODE:e.Texture.BILINEAR_SAMPLINGMODE,i,2),_.hasAlpha=!0,_.anisotropicFilteringLevel=4,y.splice(0,0,_);var C=_.allocateRect(f);m={node:C,texture:_}}if(t!==this||this._isScreenSpace){var C=m.node,x=o._cv1;C.getInnerPosToRef(x);var A=void 0;if(this._cachingStrategy===o.CACHESTRATEGY_CANVAS?(this._cachedCanvasGroup&&this._cachedCanvasGroup.dispose(),this._cachedCanvasGroup=e.Group2D._createCachedCanvasGroup(this),A=new e.Sprite2D(_,{parent:this._cachedCanvasGroup,id:"__cachedCanvasSprite__",spriteSize:g,size:d,alignToPixel:!0,spriteLocation:x}),A.zOrder=1,A.origin=e.Vector2.Zero()):(A=new e.Sprite2D(_,{parent:r,id:"__cachedSpriteOfGroup__"+t.id,x:t.x,y:t.y,spriteSize:g,size:d,spriteLocation:x,alignToPixel:!0,dontInheritParentScale:!0}),A.origin=t.origin.clone(),A.addExternalData("__cachedGroup__",t),A.pointerEventObservable.add((function(e,r){null!==t.pointerEventObservable&&t.pointerEventObservable.notifyObservers(e,r.mask)})),m.sprite=A),A&&c){var O=h?t.actualScale:t.actualScale.divide(t.parent.actualScale);A.scaleX=O.x,A.scaleY=O.y}}return m},n.prototype._registerTrackedNode=function(t){t._isFlagSet(e.SmartPropertyPrim.flagTrackedGroup)||(this._trackedGroups||(this._trackedGroups=new Array),this._trackedGroups.push(t),t._setFlags(e.SmartPropertyPrim.flagTrackedGroup))},n.prototype._unregisterTrackedNode=function(t){if(t._isFlagSet(e.SmartPropertyPrim.flagTrackedGroup)){var r=this._trackedGroups.indexOf(t);r!==-1&&this._trackedGroups.splice(r,1),t._clearFlags(e.SmartPropertyPrim.flagTrackedGroup)}},n.GetSolidColorBrush=function(t){return o._solidColorBrushes.getOrAddWithFactory(t.toHexString(),(function(){return new e.SolidColorBrush2D(t.clone(),!0)}))},n.GetSolidColorBrushFromHex=function(t){return o._solidColorBrushes.getOrAddWithFactory(t,(function(){return new e.SolidColorBrush2D(e.Color4.FromHexString(t),!0)}))},n.GetGradientColorBrush=function(t,r,n,i,a){return void 0===n&&(n=e.Vector2.Zero()),void 0===i&&(i=0),void 0===a&&(a=1),o._gradientColorBrushes.getOrAddWithFactory(e.GradientColorBrush2D.BuildKey(t,r,n,i,a),(function(){return new e.GradientColorBrush2D(t,r,n,i,a,!0)}))},n.GetBrushFromString=function(t){t=t.trim();var r=t.split(",");if(1===r.length){var n=null;if(0===t.indexOf("solid:"))n=t.substr(6).trim();else{if(0!==t.indexOf("#"))return null;n=t}return o.GetSolidColorBrushFromHex(n)}0===r[0].indexOf("gradient:")&&(r[0]=r[0].substr(9).trim());try{var i=e.Color4.FromHexString(r[0].trim()),a=e.Color4.FromHexString(r[1].trim()),s=e.Vector2.Zero();if(r.length>2){var l=r[2].trim();if("["!==l.charAt(0)||"]"!==l.charAt(l.length-1))return null;var u=l.indexOf(":"),c=parseFloat(l.substr(1,u)),h=parseFloat(l.substr(u+1,l.length-(u+1)));s=new e.Vector2(c,h)}var d=0;r.length>3&&(d=e.Tools.ToRadians(parseFloat(r[3].trim())));var p=1;return r.length>4&&(p=parseFloat(r[4].trim())),o.GetGradientColorBrush(i,a,s,d,p)}catch(e){return null}},n})(e.Group2D);r.CACHESTRATEGY_TOPLEVELGROUPS=1,r.CACHESTRATEGY_ALLGROUPS=2,r.CACHESTRATEGY_CANVAS=3,r.CACHESTRATEGY_DONTCACHE=4,r.RENDEROBSERVABLE_PRE=1,r.RENDEROBSERVABLE_POST=2,r._INSTANCES=[],r._zMinDelta=1/(Math.pow(2,24)-1),r._interInfo=new e.IntersectInfo2D,r._v=e.Vector3.Zero(),r._cv1=e.Vector2.Zero(),r._m=e.Matrix.Identity(),r._mI=e.Matrix.Identity(),r.tS=e.Vector3.Zero(),r.tT=e.Vector3.Zero(),r.tR=e.Quaternion.Identity(),r._tmpMtx=e.Matrix.Identity(),r._tmpVec3=e.Vector3.Zero(),r._pCLS=e.Vector2.Zero(),r._groupTextureCacheSize=1024,r._solidColorBrushes=new e.StringDictionary,r._gradientColorBrushes=new e.StringDictionary,__decorate([e.logMethod("==========CANVAS RENDER===============")],r.prototype,"_render",null),r=o=__decorate([e.className("Canvas2D","BABYLON")],r),e.Canvas2D=r;var n=(function(t){function n(n,i,o){var a;e.Prim2DBase._isCanvasInit=!0;var s=o;if(s.isScreenSpace=!1,null!=o.unitScaleFactor?s.size=i.multiplyByFloats(o.unitScaleFactor,o.unitScaleFactor):s.size=i.clone(),o.cachingStrategy=null==o.cachingStrategy?r.CACHESTRATEGY_CANVAS:o.cachingStrategy,o.cachingStrategy!==r.CACHESTRATEGY_CANVAS)throw new Error("Right now only the CACHESTRATEGY_CANVAS cache Strategy is supported for WorldSpace Canvas. More will come soon!");a=t.call(this,n,o)||this,e.Prim2DBase._isCanvasInit=!1,a._unitScaleFactor=null!=o.unitScaleFactor?o.unitScaleFactor:1,a._renderableData._useMipMap=!0,a._renderableData._anisotropicLevel=8,a._trackNode=null!=o.trackNode?o.trackNode:null,a._trackNodeOffset=null!=o.trackNodeOffset?o.trackNodeOffset:e.Vector3.Zero(),a._trackNodeBillboard=null==o.trackNodeBillboard||o.trackNodeBillboard;var l=!o||null==o.customWorldSpaceNode;a._customWorldSpaceNode=!l;var u=o?o.id||null:null,c=a.engine.getCaps().maxRenderTextureSize,h=Math.min(c,1024);if(null==o.maxAdaptiveCanvasSize?a._maxAdaptiveWorldSpaceCanvasSize=h:a._maxAdaptiveWorldSpaceCanvasSize=Math.min(o.maxAdaptiveCanvasSize,c),l){var d=new e.WorldSpaceCanvas2DNode(u,n,a),p=e.VertexData.CreatePlane({width:i.width,height:i.height,sideOrientation:o&&o.sideOrientation||e.Mesh.DEFAULTSIDE}),f=new e.StandardMaterial(u+"_Material",n);a.applyCachedTexture(p,f),p.applyToMesh(d,!0),f.specularColor=new e.Color3(0,0,0),f.disableLighting=!0,f.useAlphaFromDiffuseTexture=!0,o&&o.sideOrientation&&(f.backFaceCulling=o.sideOrientation===e.Mesh.DEFAULTSIDE||o.sideOrientation===e.Mesh.FRONTSIDE),d.position=o&&o.worldPosition||e.Vector3.Zero(),d.rotationQuaternion=o&&o.worldRotation||e.Quaternion.Identity(),d.material=f,a._worldSpaceNode=d}else a._worldSpaceNode=o.customWorldSpaceNode,a.applyCachedTexture(null,null);return a.propertyChanged.add((function(e,t){if("isVisible"===e.propertyName){var r=a._worldSpaceNode;r&&(r.isVisible=e.newValue)}}),e.Prim2DBase.isVisibleProperty.flagId),a}return __extends(n,t),n.prototype.dispose=function(){return!!t.prototype.dispose.call(this)&&void(!this._customWorldSpaceNode&&this._worldSpaceNode&&(this._worldSpaceNode.dispose(),this._worldSpaceNode=null))},Object.defineProperty(n.prototype,"trackNode",{get:function(){return this._trackNode},set:function(e){this._trackNode!==e&&(this._trackNode=e)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"trackNodeOffset",{get:function(){return this._trackNodeOffset},set:function(e){this._trackNodeOffset?this._trackNodeOffset.copyFrom(e):this._trackNodeOffset=e.clone()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"trackNodeBillboard",{get:function(){return this._trackNodeBillboard},set:function(e){this._trackNodeBillboard=e},enumerable:!0,configurable:!0}),n})(r);n=__decorate([e.className("WorldSpaceCanvas2D","BABYLON")],n),e.WorldSpaceCanvas2D=n;var i=(function(t){function r(r,n){var i;return e.Prim2DBase._isCanvasInit=!0,i=t.call(this,r,n)||this}return __extends(r,t),r})(r);i=__decorate([e.className("ScreenSpaceCanvas2D","BABYLON")],i),e.ScreenSpaceCanvas2D=i;var o})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,r,n){var i=e.call(this,t,r)||this;return i._canvas=n,i}return __extends(t,e),t.prototype.dispose=function(){e.prototype.dispose.call(this),this._canvas&&(this._canvas.dispose(),this._canvas=null)},t})(e.Mesh);e.WorldSpaceCanvas2DNode=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){function t(e,t,r){return function(){o.registerRenderingTemplate(e,t,r)}}var r=(function(){function t(e,t){if(!e)throw Error("At least an execute lambda must be given at Command creation time");this._canExecuteChanged=null,this._lastCanExecuteResult=null,this.execute=e,this.canExecute=t}return t.prototype.canExecute=function(e){var t=!0;return this._canExecute&&(t=this._canExecute(e)),t!==this._lastCanExecuteResult&&(this._canExecuteChanged&&this._canExecuteChanged.hasObservers()&&this._canExecuteChanged.notifyObservers(null),this._lastCanExecuteResult=t),t},t.prototype.execute=function(e){this._execute(e)},Object.defineProperty(t.prototype,"canExecuteChanged",{get:function(){return this._canExecuteChanged||(this._canExecuteChanged=new e.Observable),this._canExecuteChanged},enumerable:!0,configurable:!0}),t})();e.Command=r;var n=(function(t){function r(n){var i=t.call(this)||this;if(!n)throw Error("A settings object must be passed with at least either a parent or owner parameter");var a=e.Tools.getFullClassName(i);return i._ownerWindow=null,i._parent=null,i._visualPlaceholder=null,i._visualTemplateRoot=null,i._visualChildrenPlaceholder=null,i._hierarchyDepth=0,i._renderingTemplateName=null!=n.templateName?n.templateName:o.DefaultTemplateName,i._style=null!=n.styleName?o.getStyle(a,n.styleName):null,i._flags=0,i._id=null!=n.id?n.id:null,i._uid=null,i._width=null!=n.width?n.width:null,i._height=null!=n.height?n.height:null,i._minWidth=null!=n.minWidth?n.minWidth:0,i._minHeight=null!=n.minHeight?n.minHeight:0,i._maxWidth=null!=n.maxWidth?n.maxWidth:Number.MAX_VALUE,i._maxHeight=null!=n.maxHeight?n.maxHeight:Number.MAX_VALUE,i._margin=null,i._padding=null,i._marginAlignment=null,i._setFlags(r.flagIsVisible|r.flagIsEnabled),n.marginTop&&i.margin.setTop(n.marginTop),n.marginLeft&&i.margin.setLeft(n.marginLeft),n.marginRight&&i.margin.setRight(n.marginRight),n.marginBottom&&i.margin.setBottom(n.marginBottom),n.margin&&("string"==typeof n.margin?i.margin.fromString(n.margin):i.margin.fromUniformPixels(n.margin)),n.marginHAlignment&&(i.marginAlignment.horizontal=n.marginHAlignment),n.marginVAlignment&&(i.marginAlignment.vertical=n.marginVAlignment),n.marginAlignment&&i.marginAlignment.fromString(n.marginAlignment),n.paddingTop&&i.padding.setTop(n.paddingTop),n.paddingLeft&&i.padding.setLeft(n.paddingLeft),n.paddingRight&&i.padding.setRight(n.paddingRight),n.paddingBottom&&i.padding.setBottom(n.paddingBottom),n.padding&&i.padding.fromString(n.padding),n.paddingHAlignment&&(i.paddingAlignment.horizontal=n.paddingHAlignment),n.paddingVAlignment&&(i.paddingAlignment.vertical=n.paddingVAlignment),n.paddingAlignment&&i.paddingAlignment.fromString(n.paddingAlignment),null!=n.parent&&(i._parent=n.parent,i._hierarchyDepth=i._parent._hierarchyDepth+1),i}return __extends(r,t),Object.defineProperty(r,"enabledState",{get:function(){return r._enableState},enumerable:!0,configurable:!0}),Object.defineProperty(r,"disabledState",{get:function(){return r._disabledState},enumerable:!0,configurable:!0}),Object.defineProperty(r,"mouseOverState",{get:function(){return r._mouseOverState},enumerable:!0,configurable:!0}),r.prototype.dispose=function(){return!this.isDisposed&&(this._renderingTemplate&&(this._renderingTemplate.detach(),this._renderingTemplate=null),t.prototype.dispose.call(this),this.animations.splice(0),!0)},r.prototype.getAnimatables=function(){return new Array},r.prototype.findById=function(e){if(this._id===e)return this;for(var t=this._getChildren(),r=0,n=t;r0){for(var e=this._UIElementVisualToBuildList.sort((function(e,t){return e.hierarchyDepth-t.hierarchyDepth})),t=0,r=e;t