forked from BabylonJS/Website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbabylon.canvas2d.min.js
12 lines (12 loc) · 370 KB
/
babylon.canvas2d.min.js
1
2
3
4
5
6
7
8
9
10
11
12
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 (index<ms) {\nborderOffset=vec2(1.0-(borderThickness*2.0/w),1.0-(borderThickness*2.0/h));\n}\nelse {\nsegi-=ms;\n}\nfloat angle=TWOPI*segi/ms;\npos2.x=(cos(angle)/2.0)+0.5;\npos2.y=(sin(angle)/2.0)+0.5;\npos2.x=((pos2.x-0.5)*borderOffset.x)+0.5;\npos2.y=((pos2.y-0.5)*borderOffset.y)+0.5;\n#else\nif (index == 0.0) {\npos2=vec2(0.5,0.5);\n}\nelse {\nfloat ms=properties.z;\nfloat angle=TWOPI*(index-1.0)/ms;\npos2.x=(cos(angle)/2.0)+0.5;\npos2.y=(sin(angle)/2.0)+0.5;\n}\n#endif\n#ifdef FillSolid\nvColor=fillSolidColor;\n#endif\n#ifdef BorderSolid\nvColor=borderSolidColor;\n#endif\n#ifdef FillGradient\nfloat v=dot(vec4(pos2.xy,1,1),fillGradientTY);\nvColor=mix(fillGradientColor2,fillGradientColor1,v); \n#endif\n#ifdef BorderGradient\nfloat v=dot(vec4(pos2.xy,1,1),borderGradientTY);\nvColor=mix(borderGradientColor2,borderGradientColor1,v); \n#endif\nvColor.a*=opacity;\nvec4 pos;\npos.xy=pos2.xy*properties.xy;\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)+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}",BABYLON.Effect.ShadersStore.lines2dPixelShader="varying vec4 vColor;\nvoid main(void) {\ngl_FragColor=vColor;\n}",BABYLON.Effect.ShadersStore.lines2dVertexShader="\n#ifdef Instanced\n#define att attribute\n#else\n#define att uniform\n#endif\nattribute vec2 position;\natt vec2 zBias;\natt vec4 transformX;\natt vec4 transformY;\natt vec3 renderingInfo;\natt float opacity;\n#ifdef FillSolid\natt vec4 fillSolidColor;\n#endif\n#ifdef BorderSolid\natt vec4 borderSolidColor;\n#endif\n#ifdef FillGradient\natt vec2 boundingMin;\natt vec2 boundingMax;\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#define TWOPI 6.28318530\n\nvarying vec2 vUV;\nvarying vec4 vColor;\nvoid main(void) {\n#ifdef FillSolid\nvColor=fillSolidColor;\n#endif\n#ifdef BorderSolid\nvColor=borderSolidColor;\n#endif\n#ifdef FillGradient\nfloat v=dot(vec4((position.xy-boundingMin)/(boundingMax-boundingMin),1,1),fillGradientTY);\nvColor=mix(fillGradientColor2,fillGradientColor1,v); \n#endif\n#ifdef BorderGradient\nfloat v=dot(vec4((position.xy-boundingMin)/(boundingMax-boundingMin),1,1),borderGradientTY);\nvColor=mix(borderGradientColor2,borderGradientColor1,v); \n#endif\nvColor.a*=opacity;\nvec4 pos;\npos.xy=position.xy;\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)+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}",BABYLON.Effect.ShadersStore.rect2dPixelShader="varying vec4 vColor;\nvoid main(void) {\ngl_FragColor=vColor;\n}",BABYLON.Effect.ShadersStore.rect2dVertexShader="\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\n#define rsub0 17.0\n#define rsub1 33.0\n#define rsub2 49.0\n#define rsub3 65.0\n#define rsub 64.0\n#define TWOPI 6.28318530\n\nvarying vec2 vUV;\nvarying vec4 vColor;\nvoid main(void) {\nvec2 pos2;\n\nif (properties.z == 0.0) {\n#ifdef Border\nfloat w=properties.x;\nfloat h=properties.y;\nvec2 borderOffset=vec2(1.0,1.0);\nfloat segi=index;\nif (index<4.0) {\nborderOffset=vec2(1.0-(borderThickness*2.0/w),1.0-(borderThickness*2.0/h));\n}\nelse {\nsegi-=4.0;\n}\nif (segi == 0.0) {\npos2=vec2(1.0,1.0);\n} \nelse if (segi == 1.0) {\npos2=vec2(1.0,0.0);\n}\nelse if (segi == 2.0) {\npos2=vec2(0.0,0.0);\n} \nelse {\npos2=vec2(0.0,1.0);\n}\npos2.x=((pos2.x-0.5)*borderOffset.x)+0.5;\npos2.y=((pos2.y-0.5)*borderOffset.y)+0.5;\n#else\nif (index == 0.0) {\npos2=vec2(0.5,0.5);\n}\nelse if (index == 1.0) {\npos2=vec2(1.0,1.0);\n}\nelse if (index == 2.0) {\npos2=vec2(1.0,0.0);\n}\nelse if (index == 3.0) {\npos2=vec2(0.0,0.0);\n}\nelse {\npos2=vec2(0.0,1.0);\n}\n#endif\n}\nelse\n{\n#ifdef Border\nfloat w=properties.x;\nfloat h=properties.y;\nfloat r=properties.z;\nfloat nru=r/w;\nfloat nrv=r/h;\nvec2 borderOffset=vec2(1.0,1.0);\nfloat segi=index;\nif (index<rsub) {\nborderOffset=vec2(1.0-(borderThickness*2.0/w),1.0-(borderThickness*2.0/h));\n}\nelse {\nsegi-=rsub;\n}\n\nif (segi<rsub0) {\npos2=vec2(1.0-nru,nrv);\n}\n\nelse if (segi<rsub1) {\npos2=vec2(nru,nrv);\n}\n\nelse if (segi<rsub2) {\npos2=vec2(nru,1.0-nrv);\n}\n\nelse {\npos2=vec2(1.0-nru,1.0-nrv);\n}\nfloat angle=TWOPI-((index-1.0)*TWOPI/(rsub-0.5));\npos2.x+=cos(angle)*nru;\npos2.y+=sin(angle)*nrv;\npos2.x=((pos2.x-0.5)*borderOffset.x)+0.5;\npos2.y=((pos2.y-0.5)*borderOffset.y)+0.5;\n#else\nif (index == 0.0) {\npos2=vec2(0.5,0.5);\n}\nelse {\nfloat w=properties.x;\nfloat h=properties.y;\nfloat r=properties.z;\nfloat nru=r/w;\nfloat nrv=r/h;\n\nif (index<rsub0) {\npos2=vec2(1.0-nru,nrv);\n}\n\nelse if (index<rsub1) {\npos2=vec2(nru,nrv);\n}\n\nelse if (index<rsub2) {\npos2=vec2(nru,1.0-nrv);\n}\n\nelse {\npos2=vec2(1.0-nru,1.0-nrv);\n}\nfloat angle=TWOPI-((index-1.0)*TWOPI/(rsub-0.5));\npos2.x+=cos(angle)*nru;\npos2.y+=sin(angle)*nrv;\n}\n#endif\n}\n#ifdef FillSolid\nvColor=fillSolidColor;\n#endif\n#ifdef BorderSolid\nvColor=borderSolidColor;\n#endif\n#ifdef FillGradient\nfloat v=dot(vec4(pos2.xy,1,1),fillGradientTY);\nvColor=mix(fillGradientColor2,fillGradientColor1,v); \n#endif\n#ifdef BorderGradient\nfloat v=dot(vec4(pos2.xy,1,1),borderGradientTY);\nvColor=mix(borderGradientColor2,borderGradientColor1,v); \n#endif\nvColor.a*=opacity;\nvec4 pos;\npos.xy=pos2.xy*properties.xy;\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)+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}",BABYLON.Effect.ShadersStore.sprite2dPixelShader="varying vec2 vUV;\nvarying float vOpacity;\n#ifdef Scale9\nvarying vec2 vTopLeftUV;\nvarying vec2 vBottomRightUV;\nvarying vec4 vScale9;\nvarying vec2 vScaleFactor;\n#endif\nuniform bool alphaTest;\nuniform sampler2D diffuseSampler;\nvoid main(void) {\nvec2 uv=vUV;\n#ifdef Scale9\nvec2 sizeUV=vBottomRightUV-vTopLeftUV;\n\nfloat leftPartUV=vTopLeftUV.x+(vScale9.x/vScaleFactor.x);\nfloat rightPartUV=vTopLeftUV.x+sizeUV.x-((sizeUV.x-vScale9.z)/vScaleFactor.x);\nif (vUV.x<leftPartUV) {\nuv.x=vTopLeftUV.x+((vUV.x- vTopLeftUV.x)*vScaleFactor.x);\n}\nelse if (vUV.x>rightPartUV) {\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.y<topPartUV) {\nuv.y=vTopLeftUV.y+((vUV.y-vTopLeftUV.y)*vScaleFactor.y);\n}\nelse if (vUV.y>bottomPartUV) {\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)+0.5)*irw)+irw/2.0)+0.5*irw;\ny=((floor((y/irh)+0.5)*irh)+irh/2.0)+0.5*irh;\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<e.Epsilon*e.Epsilon)throw new Error("Can't invert matrix, near null determinant");var u=1/l,c=i*s-o*a,h=n*a-r*s;t.m[0]=o*u,t.m[1]=-n*u,t.m[2]=-i*u,t.m[3]=r*u,t.m[4]=c*u,t.m[5]=h*u},t.prototype.multiplyToThis=function(e){this.multiplyToRef(e,this)},t.prototype.multiply=function(e){var r=new t;return this.multiplyToRef(e,r),r},t.prototype.multiplyToRef=function(e,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=e.m[0],u=e.m[1],c=e.m[2],h=e.m[3],d=e.m[4],p=e.m[5];t.m[0]=r*l+n*c,t.m[1]=r*u+n*h,t.m[2]=i*l+o*c,t.m[3]=i*u+o*h,t.m[4]=a*l+s*c+d,t.m[5]=a*u+s*h+p},t.prototype.transformFloats=function(t,r){var n=e.Vector2.Zero();return this.transformFloatsToRef(t,r,n),n},t.prototype.transformFloatsToRef=function(e,t,r){r.x=e*this.m[0]+t*this.m[2]+this.m[4],r.y=e*this.m[1]+t*this.m[3]+this.m[5]},t.prototype.transformPoint=function(t){var r=e.Vector2.Zero();return this.transformFloatsToRef(t.x,t.y,r),r},t.prototype.transformPointToRef=function(e,t){this.transformFloatsToRef(e.x,e.y,t)},t.prototype.decompose=function(e,t){return t.x=this.m[4],t.y=this.m[5],e.x=Math.sqrt(this.m[0]*this.m[0]+this.m[1]*this.m[1]),e.y=Math.sqrt(this.m[2]*this.m[2]+this.m[3]*this.m[3]),0===e.x||0===e.y?null:Math.atan2(-this.m[2]/e.y,this.m[0]/e.x)},t})();t._decomp=new t,e.Matrix2D=t;var r=(function(){function t(t,r,n){return null===t&&null===r&&null===n?(this.a=e.Vector2.Zero(),this.b=e.Vector2.Zero(),this.c=e.Vector2.Zero(),this.center=e.Vector2.Zero(),void(this.radius=0)):(this.a=t.clone(),this.b=r.clone(),this.c=n.clone(),void this._updateCenterRadius())}return t.Zero=function(){return new t(null,null,null)},t.prototype.set=function(e,t,r){this.a.copyFrom(e),this.b.copyFrom(t),this.c.copyFrom(r),this._updateCenterRadius()},t.prototype.transformInPlace=function(e){e.transformPointToRef(this.a,this.a),e.transformPointToRef(this.b,this.b),e.transformPointToRef(this.c,this.c),this._updateCenterRadius()},t.prototype.doesContain=function(t){return e.Vector2.PointInTriangle(t,this.a,this.b,this.c)},t.prototype._updateCenterRadius=function(){this.center.x=(this.a.x+this.b.x+this.c.x)/3,this.center.y=(this.a.y+this.b.y+this.c.y)/3;var t=e.Vector2.DistanceSquared(this.a,this.center),r=e.Vector2.DistanceSquared(this.b,this.center),n=e.Vector2.DistanceSquared(this.c,this.center),i=Math.max(Math.max(t,r),n);this.radius=Math.sqrt(i)},t})();e.Tri2DInfo=r;var n=(function(){function t(e){this._count=e,this._array=new Float32Array(9*e)}return t.prototype.clear=function(e){this._count!==e&&(this._count=e,this._array=new Float32Array(9*e))},t.prototype.storeTriangle=function(t,r,n,i){var o=new e.Vector2((r.x+n.x+i.x)/3,(r.y+n.y+i.y)/3),a=e.Vector2.DistanceSquared(r,o),s=e.Vector2.DistanceSquared(n,o),l=e.Vector2.DistanceSquared(i,o),u=Math.max(Math.max(a,s),l),c=Math.sqrt(u),h=9*t;this._array[h+0]=r.x,this._array[h+1]=r.y,this._array[h+2]=n.x,this._array[h+3]=n.y,this._array[h+4]=i.x,this._array[h+5]=i.y,this._array[h+6]=o.x,this._array[h+7]=o.y,this._array[h+8]=c},t.prototype.storeToTri2DInfo=function(e,t){if(e>=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;n<this.count;n++)if(this.storeToTri2DInfo(n,r),r.doesContain(e))return!0;return!1},t.doesIntersect=function(e,r,n){t._checkInitStatics();for(var o=t.tempT[0],a=t.tempT[1],s=t.tempV[0],l=0;l<r.count;l++){r.transformAndStoreToTri2DInfo(l,a,n);for(var u=0;u<e.count;u++)if(e.storeToTri2DInfo(u,o),s.x=o.center.x-a.center.x,s.y=o.center.y-a.center.y,!(s.lengthSquared()>o.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<arguments.length;s++)o[s-0]=arguments[s];if(n.snooze)return l.apply(this,o);var u=o.map((function(e){return i.getFormattedValue(e)+", "})).join();u=u.slice(0,u.length-2);var c=i.computeIndent(),h=this.id||"";null!==t&&""!==t&&console.log(t);var d=this instanceof e.SmartPropertyPrim,p=d?this._flags:0,f=i.callDepth;r||console.log(c+" ["+h+"] ("+f+") ==> 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;r<arguments.length;r++)e[r]=arguments[r];var n=this._array.length,i=(a=this._array).push.apply(a,e);this._watchObjectsPropertyChange&&this._addWatchedElement.apply(this,e),this.onPropertyChanged("length",n,this._array.length);var o=this.getArrayChangedObject();return o&&(o.action=t.newItemsAction,o.newStartingIndex=n,this.feedNotifArray.apply(this,[o.newItems,n].concat(e)),this.callArrayChanged(o)),i;var a},i.prototype.pop=function(){var e=this._array.length-1,r=this._array.pop();if(r&&this._watchObjectsPropertyChange&&this._removeWatchedElement(r),e!==-1){this.onPropertyChanged("length",this._array.length+1,this._array.length);var n=this.getArrayChangedObject();n&&(n.action=t.removedItemsAction,n.removedStartingIndex=e,this.feedNotifArray(n.removedItems,e,r))}return r},i.prototype.concat=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return new i(this._watchObjectsPropertyChange,(r=this._array).concat.apply(r,e));var r},i.prototype.join=function(e){return this._array.join(e)},i.prototype.reverse=function(){var e=this._array.reverse(),r=this.getArrayChangedObject();return r.action=t.replacedArrayAction,e},i.prototype.shift=function(){var e=this._array.length,r=this._array.shift();if(this._watchedObjectChanged&&null!=r&&this._removeWatchedElement(r),0!==e){this.onPropertyChanged("length",e,this._array.length);var n=this.getArrayChangedObject();n&&(n.action=t.replacedArrayAction,n.removedItems.splice(0,n.removedItems.length,{index:0,value:r}),n.newItems.splice(0),n.changedItems.splice(0),n.removedStartingIndex=0,this.callArrayChanged(n))}return r},i.prototype.slice=function(e,t){return new i(this._watchObjectsPropertyChange,this._array.slice(e,t))},i.prototype.sort=function(e){var r=this._array.length;if(this._array.sort(e),0!==r){var n=this.getArrayChangedObject();n&&(n.clear(),n.action=t.replacedArrayAction,this.callArrayChanged(n))}},i.prototype.splice=function(e,r){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];var o=this._array.length;if(this._watchObjectsPropertyChange)for(var a=e;a<e+r;a++){var s=this._array[a];this._watchObjectsPropertyChange&&null!=s&&this._removeWatchedElement(s)}var l=(c=this._array).splice.apply(c,[e,r].concat(n));this._watchObjectsPropertyChange&&this._addWatchedElement.apply(this,n),o!==this._array.length&&this.onPropertyChanged("length",o,this._array.length);var u=this.getArrayChangedObject();return u&&(u.clear(),u.action=t.replacedArrayAction,this.callArrayChanged(u)),l;var c},i.prototype.unshift=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var n=this._array.length,i=(a=this._array).unshift.apply(a,e);this._watchObjectsPropertyChange&&this._addWatchedElement.apply(this,e),this.onPropertyChanged("length",n,this._array.length);var o=this.getArrayChangedObject();return o&&(o.clear(),o.action=t.replacedArrayAction,o.newStartingIndex=0,this.feedNotifArray.apply(this,[o.newItems,0].concat(e)),this.callArrayChanged(o)),i;var a},i.prototype.indexOf=function(e,t){return this._array.indexOf(e,t)},i.prototype.lastIndexOf=function(e,t){return this._array.lastIndexOf(e,t)},i.prototype.every=function(e,t){
return this._array.every(e,t)},i.prototype.some=function(e,t){return this._array.some(e,t)},i.prototype.forEach=function(e,t){return this._array.forEach(e,t)},i.prototype.map=function(e,t){return this._array.map(e,t)},i.prototype.filter=function(e,t){return this._array.filter(e,t)},i.prototype.reduce=function(e,t){return this._array.reduce(e)},i.prototype.reduceRight=function(e,t){return this._array.reduceRight(e)},Object.defineProperty(i.prototype,"arrayChanged",{get:function(){return this._arrayChanged||(this._arrayChanged=new e.Observable),this._arrayChanged},enumerable:!0,configurable:!0}),i.prototype.getArrayChangedObject=function(){if(this._arrayChanged&&this._arrayChanged.hasObservers()){var e=this._callingArrayChanged?new t:this.dci;return e}return null},i.prototype.feedNotifArray=function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];e.splice(0);for(var i=0;i<r.length;i++){var o=this._array[i+t];void 0!==o&&e.push({index:i+t,value:o})}},i.prototype.callArrayChanged=function(e){try{this._callingArrayChanged=!0,this.arrayChanged.notifyObservers(e,e.action)}finally{this._callingArrayChanged=!1}},Object.defineProperty(i.prototype,"watchedObjectChanged",{get:function(){return this._watchedObjectChanged||(this._watchedObjectChanged=new e.Observable),this._watchedObjectChanged},enumerable:!0,configurable:!0}),i.prototype._addWatchedElement=function(){for(var t=this,r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];for(var i=function(r){if(r.propertyChanged){var n=r.__ObsArrayObjID__;n||(n=e.Tools.RandomId(),r.__ObsArrayObjID__=n),o._watchedObjectList.add(n,r.propertyChanged.add((function(e,i){t.onWatchedObjectChanged(n,r,e)})))}},o=this,a=0,s=r;a<s.length;a++){var l=s[a];i(l)}},i.prototype._removeWatchedElement=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var r=0,n=e;r<n.length;r++){var i=n[r],o=i.__ObsArrayObjID__;if(null!=o){var a=this._watchedObjectList.getAndRemove(o);i.propertyChanged.remove(a)}}},i.prototype.onWatchedObjectChanged=function(e,t,n){if(this._watchedObjectChanged&&this._watchedObjectChanged.hasObservers()){var i=this._callingWatchedObjectChanged?new r:this._woci;i.object=t,i.propertyChanged=n;try{this._callingWatchedObjectChanged=!0,this.watchedObjectChanged.notifyObservers(i)}finally{this._callingWatchedObjectChanged=!1}}},i})(e.PropertyChangedBase);e.ObservableArray=n})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){}return Object.defineProperty(e,"clearAction",{get:function(){return e._clearAction},enumerable:!0,configurable:!0}),Object.defineProperty(e,"newItemAction",{get:function(){return e._newItemAction},enumerable:!0,configurable:!0}),Object.defineProperty(e,"removedItemAction",{get:function(){return e._removedItemAction},enumerable:!0,configurable:!0}),Object.defineProperty(e,"itemValueChangedAction",{get:function(){return e._itemValueChangedAction},enumerable:!0,configurable:!0}),Object.defineProperty(e,"replacedAction",{get:function(){return e._replacedAction},enumerable:!0,configurable:!0}),e})();t._clearAction=1,t._newItemAction=2,t._removedItemAction=4,t._itemValueChangedAction=8,t._replacedAction=16,e.DictionaryChanged=t;var r=(function(){function e(){}return e})();e.OSDWatchedObjectChangedInfo=r;var n=(function(n){function i(i){var o=n.call(this)||this;return o._propertyChanged=null,o._dictionaryChanged=null,o.dci=new t,o._callingDicChanged=!1,o._watchedObjectChanged=null,o._callingWatchedObjectChanged=!1,o._woci=new r,o._watchObjectsPropertyChange=i,o._watchedObjectList=o._watchObjectsPropertyChange?new e.StringDictionary:null,o}return __extends(i,n),i.prototype.copyFrom=function(e){var r=this,i=this.count;n.prototype.clear.call(this),e.forEach((function(e,t){return r._add(e,t,!1,r._watchObjectsPropertyChange)})),this.onDictionaryChanged(t.replacedAction,null,null,null),this.onPropertyChanged("count",i,this.count)},i.prototype.getOrAddWithFactory=function(e,t){var r=this,i=n.prototype.getOrAddWithFactory.call(this,e,(function(n){var i=t(e);return r._add(e,i,!0,r._watchObjectsPropertyChange),i}));return i},i.prototype.add=function(e,t){return this._add(e,t,!0,this._watchObjectsPropertyChange)},i.prototype.getAndRemove=function(e){var t=n.prototype.get.call(this,e);return this._remove(e,!0,t),t},i.prototype._add=function(e,r,i,o){return!!n.prototype.add.call(this,e,r)&&(i&&(this.onDictionaryChanged(t.newItemAction,{key:e,value:r},null,null),this.onPropertyChanged("count",this.count-1,this.count)),o&&this._addWatchedElement(e,r),!0)},i.prototype._addWatchedElement=function(e,t){var r=this;t.propertyChanged&&this._watchedObjectList.add(e,t.propertyChanged.add((function(n,i){r.onWatchedObjectChanged(e,t,n)})))},i.prototype._removeWatchedElement=function(e,t){var r=this._watchedObjectList.getAndRemove(e);t.propertyChanged&&t.propertyChanged.remove(r)},i.prototype.set=function(e,r){var i=this.get(e);return this._watchObjectsPropertyChange&&this._removeWatchedElement(e,i),!!n.prototype.set.call(this,e,r)&&(this.onDictionaryChanged(t.itemValueChangedAction,null,null,{key:e,oldValue:i,newValue:r}),this._addWatchedElement(e,r),!0)},i.prototype.remove=function(e){return this._remove(e,!0)},i.prototype._remove=function(e,r,i){return i||(i=this.get(e)),!!i&&(void 0!==n.prototype.remove.call(this,e)&&(this.onDictionaryChanged(t.removedItemAction,null,e,null),this.onPropertyChanged("count",this.count+1,this.count),this._watchObjectsPropertyChange&&this._removeWatchedElement(e,i),!0))},i.prototype.clear=function(){var e=this;this._watchedObjectList&&(this._watchedObjectList.forEach((function(t,r){var n=e.get(t);e._removeWatchedElement(t,n)})),this._watchedObjectList.clear());var r=this.count;n.prototype.clear.call(this),this.onDictionaryChanged(t.clearAction,null,null,null),this.onPropertyChanged("count",r,0)},Object.defineProperty(i.prototype,"propertyChanged",{get:function(){return this._propertyChanged||(this._propertyChanged=new e.Observable),this._propertyChanged},enumerable:!0,configurable:!0}),i.prototype.onPropertyChanged=function(t,r,n,o){if(this._propertyChanged&&this._propertyChanged.hasObservers()){var a=i.callingPropChanged?new e.PropertyChangedInfo:i.pci;a.oldValue=r,a.newValue=n,a.propertyName=t;try{i.callingPropChanged=!0,this.propertyChanged.notifyObservers(a,o)}finally{i.callingPropChanged=!1}}},Object.defineProperty(i.prototype,"dictionaryChanged",{get:function(){return this._dictionaryChanged||(this._dictionaryChanged=new e.Observable),this._dictionaryChanged},enumerable:!0,configurable:!0}),i.prototype.onDictionaryChanged=function(e,r,n,i){if(this._dictionaryChanged&&this._dictionaryChanged.hasObservers()){var o=this._callingDicChanged?new t:this.dci;o.action=e,o.newItem=r,o.removedKey=n,o.changedItem=i;try{this._callingDicChanged=!0,this.dictionaryChanged.notifyObservers(o,e)}finally{this._callingDicChanged=!1}}},Object.defineProperty(i.prototype,"watchedObjectChanged",{get:function(){return this._watchedObjectChanged||(this._watchedObjectChanged=new e.Observable),this._watchedObjectChanged},enumerable:!0,configurable:!0}),i.prototype.onWatchedObjectChanged=function(e,t,n){if(this._watchedObjectChanged&&this._watchedObjectChanged.hasObservers()){var i=this._callingWatchedObjectChanged?new r:this._woci;i.key=e,i.object=t,i.propertyChanged=n;try{this._callingWatchedObjectChanged=!0,this.watchedObjectChanged.notifyObservers(i)}finally{this._callingWatchedObjectChanged=!1}}},i})(e.StringDictionary);n.pci=new e.PropertyChangedInfo,n.callingPropChanged=!1,e.ObservableStringDictionary=n})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){function t(e,t){return function(){o.addLoader(e,t)}}var r=(function(){function e(){}return e})();e.CharInfo=r;var n=(function(t){function r(r,n,i,o,a,s){void 0===i&&(i=!1),void 0===o&&(o=!0),void 0===a&&(a=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===s&&(s=!1);var l=t.call(this,r,n,i,o,a)||this;return l._cachedFontId=null,l._charInfos=new e.StringDictionary,l._isPremultipliedAlpha=s,l}return __extends(r,t),Object.defineProperty(r.prototype,"isSuperSampled",{get:function(){return this._superSample},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isSignedDistanceField",{get:function(){return this._signedDistanceField},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isPremultipliedAlpha",{get:function(){return this._isPremultipliedAlpha},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"spaceWidth",{get:function(){return this._spaceWidth},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"lineHeight",{get:function(){return this._lineHeight},enumerable:!0,configurable:!0}),r.prototype.measureText=function(t,r){for(var n=0,i=0,o=1,a=0,s=0,l=t;s<l.length;s++){var u=l[s];if("\n"!==u)if("\t"!==u){if(!(u<" ")){var c=this.getChar(u);if(!c)throw new Error("Character "+u+" is not supported by FontTexture "+this.name);i+=c.charWidth,++a}}else{var h=a+r;h-=h%r,i+=(h-a)*this.spaceWidth,a=h}else n=Math.max(n,i),a=0,i=0,++o}return n=Math.max(n,i),new e.Size(n,o*this.lineHeight)},r})(e.Texture);e.BaseFontTexture=n;var i=(function(){function t(){this.kerningDic=new e.StringDictionary,this.charDic=new e.StringDictionary}return t})();e.BitmapFontInfo=i;var o=(function(t){function r(n,i,o,a,s,l,u,c,h){void 0===o&&(o=null),void 0===a&&(a=!1),void 0===s&&(s=!0),void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===u&&(u=!1),void 0===c&&(c=null),void 0===h&&(h=null);var d=t.call(this,null,n,a,s,l,u)||this;d._usedCounter=1;var p=new XMLHttpRequest;return p.onreadystatechange=function(){if(p.readyState===XMLHttpRequest.DONE)if(200===p.status){var e=i.split(".").pop().split(/\#|\?/)[0],t=r.plugins.get(e.toLocaleLowerCase());if(!t)return void(h&&h("couldn't find a plugin for this file extension",-1));for(var u=function(e){var t=e.loadFont(p.response,n,s);if(t){var r=t.bfi;if(null!=o)r.textureUrl=o;else{var u=i.substr(0,i.lastIndexOf("/")+1);r.textureUrl=u+r.textureFile}d._texture=n.getEngine().createTexture(r.textureUrl,a,s,n,l,(function(){t.bfi&&c&&c()})),d._lineHeight=r.lineHeight,d._charInfos.copyFrom(r.charDic);var f=d.getChar(" ");return f?d._spaceWidth=f.charWidth:d._charInfos.first((function(e,t){return d._spaceWidth=t.charWidth})),!t.bfi&&h&&h(t.errorMsg,t.errorCode),{value:void 0}}},f=0,g=t;f<g.length;f++){var _=g[f],y=u(_);if("object"==typeof y)return y.value}h&&h("No plugin to load this BMFont file format",-1)}else h&&h("Couldn't load file through HTTP Request, HTTP Status "+p.status,p.status)},p.open("GET",i,!0),p.send(),d}return __extends(r,t),r.GetCachedFontTexture=function(t,r){var n=t.getOrAddExternalDataWithFactory("BitmapFontTextureCache",(function(){return new e.StringDictionary})),i=n.get(r.uid);return i?(++i._usedCounter,i):(n.add(r.uid,r),i)},r.ReleaseCachedFontTexture=function(e,t){var r=e.getExternalData("BitmapFontTextureCache");if(r){var n=r.get(t.uid);0===--n._usedCounter&&(r.remove(t.uid),n.dispose())}},Object.defineProperty(r.prototype,"isDynamicFontTexture",{get:function(){return!1},enumerable:!0,configurable:!0}),r.prototype.update=function(){},r.prototype.getChar=function(e){return this._charInfos.get(e)},r.prototype.incCachedFontTextureCounter=function(){++this._usedCounter},r.prototype.decCachedFontTextureCounter=function(){var e=this.getScene().getExternalData("BitmapFontTextureCache");e&&0===--this._usedCounter&&(e.remove(this._cachedFontId),this.dispose())},r.addLoader=function(e,t){var n=r.plugins.getOrAddWithFactory(e.toLocaleLowerCase(),(function(){return new Array}));n.push(t)},r})(n);o.plugins=new e.StringDictionary,e.BitmapFontTexture=o;var a=(function(t){function n(r,n,i,o,a,s,l){void 0===o&&(o=200),void 0===a&&(a=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===s&&(s=!1),void 0===l&&(l=!1);var u=t.call(this,null,i,!0,!1,a)||this;if(u._curCharCount=0,u._lastUpdateCharCount=-1,u._usedCounter=1,u.name=r,u.debugMode=!1,u.wrapU=e.Texture.CLAMP_ADDRESSMODE,u.wrapV=e.Texture.CLAMP_ADDRESSMODE,u._sdfScale=8,u._signedDistanceField=l,u._superSample=!1,u._isPremultipliedAlpha=!l,u.name="FontTexture "+n,s||l){var c=u.getSuperSampleFont(n);c&&(u._superSample=!0,n=c)}u._canvas=document.createElement("canvas"),u._context=u._canvas.getContext("2d"),u._context.font=n,u._context.fillStyle="white",u._context.textBaseline="top";var h=u.getFontHeight(n,"j$|");u._lineHeightSuper=h.height,u._lineHeight=u._superSample?Math.ceil(u._lineHeightSuper/2):u._lineHeightSuper,u._offset=h.offset,h=u.getFontHeight(n,"f"),u._baseLine=h.height+h.offset-u._offset;var d=Math.max(u._context.measureText("W").width,u._context.measureText("_").width);u._spaceWidthSuper=u._context.measureText(" ").width,u._spaceWidth=u._superSample?u._spaceWidthSuper/2:u._spaceWidthSuper,u._xMargin=Math.ceil(d/32),u._yMargin=u._xMargin;var p=(Math.ceil(u._lineHeightSuper)+2*u._yMargin)*(Math.ceil(d)+2*u._xMargin)*o,f=Math.sqrt(p),g=Math.pow(2,Math.ceil(Math.log(f)/Math.log(2)));u._texture=i.getEngine().createDynamicTexture(g,g,!1,a);var _=u.getSize();if(u.hasAlpha=u._signedDistanceField===!1,u._canvas=document.createElement("canvas"),u._canvas.width=_.width,u._canvas.height=_.height,u._context=u._canvas.getContext("2d"),u._context.textBaseline="top",u._context.font=n,u._context.fillStyle="white",u._context.imageSmoothingEnabled=!1,u._context.clearRect(0,0,_.width,_.height),u._signedDistanceField){var y=document.createElement("canvas"),m=u._sdfScale;y.width=(Math.ceil(d)+2*u._xMargin)*m,y.height=(Math.ceil(u._lineHeightSuper)+2*u._yMargin)*m;var v=y.getContext("2d");v.scale(m,m),v.textBaseline="top",v.font=n,v.fillStyle="white",v.imageSmoothingEnabled=!1,u._sdfCanvas=y,u._sdfContext=v}u._currentFreePosition=e.Vector2.Zero();for(var b=32;b<127;b++){var P=String.fromCharCode(b);u.getChar(P)}return u.update(),u}return __extends(n,t),Object.defineProperty(n.prototype,"isDynamicFontTexture",{get:function(){return!0},enumerable:!0,configurable:!0}),n.GetCachedFontTexture=function(t,r,i,o,a){void 0===i&&(i=!1),void 0===o&&(o=!1),void 0===a&&(a=!1);var s=t.getOrAddExternalDataWithFactory("FontTextureCache",(function(){return new e.StringDictionary})),l=r.toLocaleLowerCase()+(i?"_+SS":"_-SS")+(o?"_+SDF":"_-SDF")+(a?"_+BF":"_-BF"),u=s.get(l);return u?(++u._usedCounter,u):(u=new n(null,r,t,i?100:200,o||a?e.Texture.BILINEAR_SAMPLINGMODE:e.Texture.NEAREST_SAMPLINGMODE,i,o),u._cachedFontId=l,s.add(l,u),u)},n.ReleaseCachedFontTexture=function(e,t,r,n,i){void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===i&&(i=!1);var o=e.getExternalData("FontTextureCache");if(o){var a=t.toLocaleLowerCase()+(r?"_+SS":"_-SS")+(n?"_+SDF":"_-SDF")+(i?"_+BF":"_-BF"),s=o.get(a);0===--s._usedCounter&&(o.remove(a),s.dispose())}},n.prototype._saveToImage=function(e){var t=this._canvas.toDataURL("image/png");if("download"in document.createElement("a")){var r=window.document.createElement("a");r.href=t;var n=new Date,i=(n.getFullYear()+"-"+(n.getMonth()+1)).slice(-2)+"-"+n.getDate()+"_"+n.getHours()+"-"+("0"+n.getMinutes()).slice(-2);r.setAttribute("download","screenshot_"+i+".png"),window.document.body.appendChild(r),r.addEventListener("click",(function(){r.parentElement.removeChild(r)})),r.click()}else{var o=window.open(""),a=o.document.createElement("img");a.src=t,o.document.body.appendChild(a)}},n.prototype.getChar=function(t){var n=this;if(1!==t.length)return null;var i=this._charInfos.get(t);if(i)return i;i=new r;var o=this._context.measureText(t),a=this.getSize(),s=Math.ceil(o.width+.5);if(this._currentFreePosition.x+s+this._xMargin>a.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;p<o;p++)for(var f=0;f<i;f++){var g=c(f,p,0,0,!0),_=h(f,p,g);0===_&&(_=l*l*2),d[p*i+f]=g?_:-_}for(var y=this._context.createImageData(i,o),m=i*o,v=0;v<m;v++){var _=d[v],b=_<0?-1:1;_=Math.sqrt(Math.abs(_))*b,_*=127.5/l,_+=127.5,_<0?_=0:_>255&&(_=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;o<r.length;o++)null!=r[o]&&(i+=r[o]+" ");return i},n.prototype.getFontHeight=function(e,t){var r=document.createElement("canvas");r.width=600,r.height=600;var n=r.getContext("2d");n.fillRect(0,0,r.width,r.height),n.textBaseline="top",n.fillStyle="white",n.font=e,n.fillText(t,0,0);for(var i=n.getImageData(0,0,r.width,r.height).data,o=-1,a=-1,s=0;s<r.height;s++)for(var l=0;l<r.width;l++){var u=4*(s*r.width+l),c=i[u];if(0!==c){o===-1&&(o=s);break}if(l===r.width-1&&o!==-1){a=s,s=r.height;break}}return{height:a-o+1,offset:o}},Object.defineProperty(n.prototype,"canRescale",{get:function(){return!1},enumerable:!0,configurable:!0}),n.prototype.getContext=function(){return this._context},n.prototype.update=function(){this._lastUpdateCharCount<this._curCharCount&&(this.getScene().getEngine().updateDynamicTexture(this._texture,this._canvas,!1,!0),this._lastUpdateCharCount=this._curCharCount)},n.prototype.clone=function(){return null},n.prototype.incCachedFontTextureCounter=function(){++this._usedCounter},n.prototype.decCachedFontTextureCounter=function(){var e=this.getScene().getExternalData("FontTextureCache");e&&0===--this._usedCounter&&(e.remove(this._cachedFontId),this.dispose())},n})(n);e.FontTexture=a;var s=l=(function(){function t(){}return t.prototype._parseStrToObj=function(e){var t=e.match(l.ITEM_EXP);if(!t)return null;for(var r={},n=0,i=t.length;n<i;n++){var o=t[n],a=o.indexOf("="),s=o.substring(0,a),u=o.substring(a+1);u.match(l.INT_EXP)?u=parseInt(u):'"'===u[0]&&(u=u.substring(1,u.length-1)),r[s]=u}return r},t.prototype._buildCharInfo=function(t,n,i,o,a,s){var l=null,u=null,c=null,h=null,d=null,p=0,f=0,g=0,_=new r;for(var y in i){var m=i[y];switch(y){case"id":l=String.fromCharCode(m);break;case"x":u=m;break;case"y":c=m;break;case"width":h=m;break;case"height":d=m;break;case"xadvance":g=m;break;case"xoffset":p=m;break;case"yoffset":f=m}}null!=u&&null!=c&&null!=h&&null!=d&&null!=l?(_.xAdvance=g,_.xOffset=p,_.yOffset=t.lineHeight-d-f,a?(_.topLeftUV=new e.Vector2(1-u/o.width,1-c/o.height),_.bottomRightUV=new e.Vector2(1-(u+h)/o.width,1-(c+d)/o.height)):(_.topLeftUV=new e.Vector2(u/o.width,c/o.height),_.bottomRightUV=new e.Vector2((u+h)/o.width,(c+d)/o.height)),_.charWidth=h,s.add(l,_)):console.log("Error while parsing line "+n)},t.prototype.loadFont=function(t,r,n){var o=t,a=new i,s=0,u="OK",c=o.match(l.INFO_EXP),h=this._parseStrToObj(c[0]);if(!h)return null;var d=h.padding.split(",");a.padding=new e.Vector4(parseInt(d[0]),parseInt(d[1]),parseInt(d[2]),parseInt(d[3]));var p=this._parseStrToObj(o.match(l.COMMON_EXP)[0]);a.lineHeight=p.lineHeight,a.baseLine=p.base,a.textureSize=new e.Size(p.scaleW,p.scaleH);var f=r.getEngine()._gl.getParameter(3379);if(p.scaleW>f.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<m;y++){var v=this._parseStrToObj(_[y]);this._buildCharInfo(a,_[y],v,a.textureSize,n,a.charDic)}var b=o.match(l.KERNING_EXP);if(b)for(var y=0,m=b.length;y<m;y++){var P=this._parseStrToObj(b[y]);a.kerningDic.add((P.first<<16|65535&P.second).toString(),P.amount)}}}return{bfi:a,errorCode:s,errorMsg:u}},t})();s.INFO_EXP=/info [^\r\n]*(\r\n|$)/gi,s.COMMON_EXP=/common [^\n]*(\n|$)/gi,s.PAGE_EXP=/page [^\n]*(\n|$)/gi,s.CHAR_EXP=/char [^\n]*(\n|$)/gi,s.KERNING_EXP=/kerning [^\n]*(\n|$)/gi,s.ITEM_EXP=/\w+=[^ \r\n]+/gi,s.INT_EXP=/^[\-]?\d+$/,s=l=__decorate([t("fnt",new l)],s),e.BitmapFontLoaderPlugin=t;var l})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this.radius=0,this.center=e.Vector2.Zero(),this.extent=e.Vector2.Zero(),this._worldAABBDirty=!1,this._worldAABBDirtyObservable=null,this._worldAABB=e.Vector4.Zero()}return t.CreateFromSize=function(e){var r=new t;return t.CreateFromSizeToRef(e,r),r},t.CreateFromRadius=function(e){var r=new t;return t.CreateFromRadiusToRef(e,r),r},t.CreateFromPoints=function(e){var r=new t;return t.CreateFromPointsToRef(e,r),r},t.CreateFromSizeToRef=function(t,r){t||(t=e.Size.Zero()),r.center.x=+t.width/2,r.center.y=+t.height/2,r.extent.x=r.center.x,r.extent.y=r.center.y,r.radius=r.extent.length(),r._worldAABBDirty=!0},t.CreateFromRadiusToRef=function(e,t){t.center.x=t.center.y=0;var r=+e;t.extent.x=r,t.extent.y=r,t.radius=r,t._worldAABBDirty=!0},t.CreateFromPointsToRef=function(e,r){for(var n=Number.MAX_VALUE,i=Number.MAX_VALUE,o=Number.MIN_VALUE,a=Number.MIN_VALUE,s=0,l=e;s<l.length;s++){var u=l[s];n=Math.min(u.x,n),o=Math.max(u.x,o),i=Math.min(u.y,i),a=Math.max(u.y,a)}t.CreateFromMinMaxToRef(n,o,i,a,r)},t.CreateFromMinMaxToRef=function(t,r,n,i,o){var a=r-t,s=i-n;o.center=new e.Vector2(t+a/2,n+s/2),o.extent=new e.Vector2(r-o.center.x,i-o.center.y),o.radius=o.extent.length(),o._worldAABBDirty=!0},t.prototype.toString=function(){return"Center: "+this.center+", Extent: "+this.extent+", Radius: "+this.radius},t.prototype.clone=function(){var e=new t;return e.center=this.center.clone(),e.radius=this.radius,e.extent=this.extent.clone(),e},t.prototype.clear=function(){this.center.copyFromFloats(0,0),this.radius=0,this.extent.copyFromFloats(0,0),this._worldAABBDirty=!0},t.prototype.copyFrom=function(e){this.center.copyFrom(e.center),this.radius=e.radius,this.extent.copyFrom(e.extent),this._worldAABBDirty=!0},t.prototype.equals=function(e){return!!e&&(e.center.equals(this.center)&&e.extent.equals(this.extent))},t.prototype.max=function(){var t=e.Vector2.Zero();return this.maxToRef(t),t},t.prototype.minMax=function(){var t=e.Vector4.Zero();return this.minMaxToRef(t),t},t.prototype.maxToRef=function(e){e.x=this.center.x+this.extent.x,e.y=this.center.y+this.extent.y},t.prototype.minMaxToRef=function(e){e.x=this.center.x-this.extent.x,e.y=this.center.y-this.extent.y,e.z=this.center.x+this.extent.x,e.w=this.center.y+this.extent.y},t.prototype.size=function(){var t=e.Size.Zero();return this.sizeToRef(t),t},t.prototype.sizeToRef=function(e){e.width=2*this.extent.x,e.height=2*this.extent.y},t.prototype.inflate=function(e){this.extent.addInPlace(e),this.radius=this.extent.length()},t.prototype.transform=function(e){var r=new t;return this.transformToRef(e,r),r},t.prototype.union=function(e){var r=new t;return this.unionToRef(e,r),r},t.prototype.worldAABBIntersectionTest=function(e){var t=this.worldAABB,r=e.worldAABB;return r.z>=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._clusterSize.height;r++)for(var n=0;n<this._clusterSize.width;n++)this._freeClusterInfo(this._clusters[r][n]);this._clusterSize.copyFromFloats(e,t),this._clusters=[];for(var r=0;r<this._clusterSize.height;r++){this._clusters[r]=[];for(var n=0;n<this._clusterSize.width;n++){var i=this._allocClusterInfo();this._clusters[r][n]=i}}this._clusterStep.copyFromFloats(this._owner.actualWidth/e,this._owner.actualHeight/t),this._maxActorByCluster=0,this._lastClusterResizeCounter=0,this._clusterDirty=!1},r.prototype._rebuildAllActors=function(){var e=this;this._actors.forEach((function(t,r){e._processActor(r)}))},r.prototype._rebuildDirtyActors=function(){var e=this;this._dirtyActors.forEach((function(t,r){e._processActor(r)}))},r.prototype._processActor=function(e){var t=this;if(!e.isEnabled||e.isRemoved)return e.presentInClusters.forEach((function(t,r){r.actors.remove(e.prim.uid)})),void e.presentInClusters.clear();var n=e.worldAABB,i=r.WAABBCorners;i[0].copyFromFloats(n.x,n.y),i[1].copyFromFloats(n.z,n.y),i[2].copyFromFloats(n.z,n.w),i[3].copyFromFloats(n.x,n.w);for(var o=this._clusterStep,a=r.WAABBCornersCluster,s=0;s<4;s++){var l=i[s],u=(l.x-l.x%o.x)/o.x,c=(l.y-l.y%o.y)/o.y;a[s].copyFromFloats(Math.floor(u),Math.floor(c))}var h=0,d=0,p=new Array,f=Math.max(0,a[0].x),g=Math.max(0,a[0].y),_=Math.min(this._clusterSize.width-1,a[2].x),y=Math.min(this._clusterSize.height-1,a[2].y);this._enableBorder&&(i[0].x<0?this._borderIntersecteddActors[0].add(e.prim.uid,e.prim):this._borderIntersecteddActors[0].remove(e.prim.uid),i[0].y<0?this._borderIntersecteddActors[1].add(e.prim.uid,e.prim):this._borderIntersecteddActors[1].remove(e.prim.uid),i[2].x>=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<S.length;C++){var D=S[C];e.presentInClusters.remove(D)}}},r.prototype._collisionDetection=function(){var e=this,t=r.CandidatesActors,n=r.PreviousIntersections,i=0;this._dirtyActors.forEach((function(r,o){++i,t.clear(),o.presentInClusters.forEach((function(e,r){++i,r.actors.forEach((function(e,r){return t.add(e,r)}))}));var a=o.worldAABB;n.clear(),n.copyFrom(o.intersectWith),o.intersectWith.clear(),t.forEach((function(t,n){if(++i,r!==t){var s=n.worldAABB;s.z>=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),r<t?e._intersectedActors.add(r+";"+t,{a:o.prim,b:n.prim}):e._intersectedActors.add(t+";"+r,{a:n.prim,b:o.prim}))}})),n.forEach((function(t,n){o.intersectWith.contains(t)||(++i,e._intersectedActors.remove((t<r?t:r)+";"+(t<r?r:t)))}))})),this._debugUpdateOpCount.fetchNewFrame(),this._debugUpdateOpCount.addCount(i,!0)},r.prototype._getCluster=function(e,t){return this._clusters[e][t]},r.prototype._updateDebugStats=function(){var t=function(e){return(Math.round(100*e)/100).toString()},r="Primitive Collision Stats\n"+(" - PCM Execution Time: "+t(this._debugUpdateTime.lastSecAverage)+"ms\n")+(" - Operation Count: "+t(this._debugUpdateOpCount.current)+", (avg:"+t(this._debugUpdateOpCount.lastSecAverage)+", t:"+t(this._debugUpdateOpCount.total)+")\n")+(" - Max Actor per Cluster: "+this._maxActorByCluster+"\n")+(" - Intersections count: "+this.intersectedActors.count);if(this._debugTextBackground){this._debugTextBackground.levelVisible=!0;var n=this._debugTextBackground.children[0];n.text=r}else this._debugTextBackground=new e.Rectangle2D({id:"###DEBUG PMC STATS###",parent:this._owner,marginAlignment:"h: left, v: top",fill:"#C0404080",padding:"10",margin:"10",roundRadius:10,children:[new e.Text2D(r,{id:"###DEBUG PMC TEXT###",fontName:"12pt Lucida Console"})]})},r.prototype._updateAABBDisplay=function(){var t=new e.WireFrameGroup2D("main",new e.Color4(.5,.8,1,1)),r=e.Vector2.Zero();this._actors.forEach((function(e,n){if(n.isEnabled){var i=n.worldAABB;r.x=i.x,r.y=i.y,t.startLineStrip(r),r.x=i.z,t.pushVertex(r),r.y=i.w,t.pushVertex(r),r.x=i.x,t.pushVertex(r),r.y=i.y,t.endLineStrip(r)}})),this._AABBRenderPrim?(this._AABBRenderPrim.wireFrameGroups.set("main",t),this._AABBRenderPrim.wireFrameGroupsDirty()):this._AABBRenderPrim=new e.WireFrame2D([t],{parent:this._owner,alignToPixel:!0,id:"###DEBUG PCM AABB###"}),this._debugRenderAABBDirty=!1},r.prototype._updateClusterDisplay=function(t,r){var n=new e.WireFrameGroup2D("main",new e.Color4(.8,.1,.5,1)),i=e.Vector2.Zero(),o=e.Vector2.Zero(),a=(this._owner.actualWidth-1)/t;i.y=0,o.y=this._owner.actualHeight;for(var s=0;s<=t;s++)n.pushVertex(i),n.pushVertex(o),i.x+=a,o.x+=a;a=(this._owner.actualHeight-1)/r,i.x=i.y=o.y=0,o.x=this._owner.actualWidth;for(var l=0;l<=r;l++)n.pushVertex(i),n.pushVertex(o),i.y+=a,o.y+=a;this._ClusterRenderPrim?(this._ClusterRenderPrim.wireFrameGroups.set("main",n),this._ClusterRenderPrim.wireFrameGroupsDirty()):this._ClusterRenderPrim=new e.WireFrame2D([n],{parent:this._owner,alignToPixel:!0,id:"###DEBUG PCM Clusters###"})},r.prototype._allocClusterInfo=function(){if(0===this._freeClusters.length)for(var e=0;e<8;e++)this._freeClusters.push(new i);return this._freeClusters.pop()},r.prototype._freeClusterInfo=function(e){e.clear(),this._freeClusters.push(e)},r})(t);o.WAABBCorners=null,o.WAABBCornersCluster=null,o.CandidatesActors=new e.StringDictionary,o.PreviousIntersections=new e.StringDictionary})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this.layoutDirtyOnPropertyChangedMask=0}return e.prototype.updateLayout=function(e){},Object.defineProperty(e.prototype,"isChildPositionAllowed",{get:function(){return!1},enumerable:!0,configurable:!0}),e.prototype.isLocked=function(){return this._isLocked},e.prototype.lock=function(){return!this._isLocked&&(this._isLocked=!0,!0)},e})();t=__decorate([e.className("LayoutEngineBase","BABYLON")],t),e.LayoutEngineBase=t;var r=u=(function(t){function r(){var r=t.call(this)||this;return r.layoutDirtyOnPropertyChangedMask=e.Prim2DBase.sizeProperty.flagId|e.Prim2DBase.actualSizeProperty.flagId,r}return __extends(r,t),Object.defineProperty(r,"Singleton",{get:function(){return u._singleton||(u._singleton=new u),u._singleton},enumerable:!0,configurable:!0}),r.prototype.updateLayout=function(t){if(t._isFlagSet(e.SmartPropertyPrim.flagLayoutDirty)){t._clearFlags(e.SmartPropertyPrim.flagLayoutDirty);for(var r=0,n=t.children;r<n.length;r++){var i=n[r];this._doUpdate(i)}}},r.prototype._doUpdate=function(t){if(t instanceof e.Canvas2D)t.layoutArea=t.actualSize;else if(t.parent instanceof e.Canvas2D)t.layoutArea=t.owner.actualSize;else{var r=t.parent.contentArea;r&&(t.layoutArea=r)}},Object.defineProperty(r.prototype,"isChildPositionAllowed",{get:function(){return!0},enumerable:!0,configurable:!0}),r})(t);r._singleton=null,__decorate([e.logMethod()],r.prototype,"updateLayout",null),__decorate([e.logMethod()],r.prototype,"_doUpdate",null),r=u=__decorate([e.className("CanvasLayoutEngine","BABYLON")],r),e.CanvasLayoutEngine=r;var n=c=(function(t){function r(){var r=t.call(this)||this;return r._isHorizontal=!0,r.layoutDirtyOnPropertyChangedMask=e.Prim2DBase.sizeProperty.flagId|e.Prim2DBase.actualSizeProperty.flagId,r}return __extends(r,t),Object.defineProperty(r,"Horizontal",{get:function(){return c._horizontal||(c._horizontal=new c,c._horizontal.isHorizontal=!0,c._horizontal.lock()),c._horizontal},enumerable:!0,configurable:!0}),Object.defineProperty(r,"Vertical",{get:function(){return c._vertical||(c._vertical=new c,c._vertical.isHorizontal=!1,c._vertical.lock()),c._vertical},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isHorizontal",{get:function(){return this._isHorizontal},set:function(e){this.isLocked()||(this._isHorizontal=e)},enumerable:!0,configurable:!0}),r.prototype.updateLayout=function(t){if(t._isFlagSet(e.SmartPropertyPrim.flagLayoutDirty)){var r=t.layoutArea,n=t.isSizeAuto;if(!r&&!n)return;var i=0,o=0,a=this.isHorizontal,s=0,l=c.stackPanelLayoutArea;a?t.isVerticalSizeAuto?(s=0,l.height=0):(s=t.layoutArea.height,l.height=t.layoutArea.height,l.width=0):t.isHorizontalSizeAuto?(s=0,l.width=0):(s=t.layoutArea.width,l.width=t.layoutArea.width,l.height=0);for(var u=0,h=t.children;u<h.length;u++){var d=h[u];d._isFlagSet(e.SmartPropertyPrim.flagNoPartOfLayout)||(d._hasMargin?(d.margin.computeWithAlignment(l,d.actualSize,d.marginAlignment,d.actualScale,c.dstOffset,c.dstArea,!0),d.layoutArea=c.dstArea):(d.margin.computeArea(d.actualSize,d.actualScale,c.dstArea),d.layoutArea=c.dstArea),s=Math.max(s,a?c.dstArea.height:c.dstArea.width))}for(var p=0,f=t.children;p<f.length;p++){var d=f[p];if(!d._isFlagSet(e.SmartPropertyPrim.flagNoPartOfLayout)){var g=d.layoutArea;a?(d.layoutAreaPos=new e.Vector2(i,0),i+=g.width,d.layoutArea=new e.Size(g.width,s)):(d.layoutAreaPos=new e.Vector2(0,o),o+=g.height,d.layoutArea=new e.Size(s,g.height))}}t._clearFlags(e.SmartPropertyPrim.flagLayoutDirty)}},Object.defineProperty(r.prototype,"isChildPositionAllowed",{get:function(){return!1},enumerable:!0,configurable:!0}),r})(t);n._horizontal=null,n._vertical=null,n.stackPanelLayoutArea=e.Size.Zero(),n.dstOffset=e.Vector4.Zero(),n.dstArea=e.Size.Zero(),n.computeCounter=0,n=c=__decorate([e.className("StackPanelLayoutEngine","BABYLON")],n),e.StackPanelLayoutEngine=n;var i=(function(){function e(e,t,r,n){this.row=e,this.column=t,this.rowSpan=null==r?1:r,this.columnSpan=null==n?1:n}return e})();e.GridData=i;var o=(function(){function e(){}return e.prototype._parse=function(t,r){var n=t.toLocaleLowerCase().trim();if(0===n.indexOf("auto"))r(null,null,e.Auto);else if(n.indexOf("*")!==-1){var i=n.indexOf("*"),o=1;i>0&&(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 null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t})(o),s=(function(e){function t(){return null!==e&&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;l<u.length;l++){var c=u[l];i(c)}if(r.columns)for(var h=function(e){var t=new s;t._parse(e.width,(function(e,r,n){t.width=e,t.widthPixels=r,t.widthType=n})),d._columns.push(t)},d=this,p=0,f=r.columns;p<f.length;p++){var g=f[p];h(g)}return n}return __extends(r,t),r.prototype.updateLayout=function(t){if(t._isFlagSet(e.SmartPropertyPrim.flagLayoutDirty)){if(!t.layoutArea)return;for(var r=0,n=t.children;r<n.length;r++){var i=n[r];i._isFlagSet(e.SmartPropertyPrim.flagNoPartOfLayout)||(i._hasMargin?i.margin.computeWithAlignment(t.layoutArea,i.actualSize,i.marginAlignment,i.actualScale,h.dstOffset,h.dstArea,!0):i.margin.computeArea(i.actualSize,i.actualScale,h.dstArea),i.layoutArea=h.dstArea)}this._updateGrid(t);for(var o=this._children,a=this._rows.length,s=this._columns.length,l=h.dstArea,u=h.dstAreaPos,c=0;c<o.length;c++){var d=o[c];if(d)for(var p=this._rowBottoms[c],f=this._rowHeights[c],g=p,_=f,y=0;y<d.length;y++){var m=this._columnLefts[y],v=this._columnWidths[y],i=d[y];if(i){var b=i.layoutData;if(b.columnSpan>1)for(var P=y+1;P<b.columnSpan+y&&P<s;P++)v+=this._columnWidths[P];if(b.rowSpan>1)for(var P=c+1;P<b.rowSpan+c&&P<a;P++)f+=this._rowHeights[P],p=this._rowBottoms[P];l.width=v,l.height=f,i.layoutArea=l,u.x=m,u.y=p,i.layoutAreaPos=u,p=g,f=_}}}t._clearFlags(e.SmartPropertyPrim.flagLayoutDirty)}},Object.defineProperty(r.prototype,"isChildPositionAllowed",{get:function(){return!1},enumerable:!0,configurable:!0}),r.prototype._getMaxChildHeightInRow=function(e){var t=this._rows,r=this._columns.length,n=(this._rows.length,this._children),i=(t[e],0);if(n&&n[e])for(var o=0;o<r;o++){var a=n[e][o];if(a){var s=a.layoutData.rowSpan;i<a.layoutArea.height/s&&(i=a.layoutArea.height/s)}}return i},r.prototype._getMaxChildWidthInColumn=function(e){var t=this._columns,r=(this._columns.length,this._rows.length),n=this._children,i=(t[e],0);if(n)for(var o=0;o<r;o++)if(n[o]){var a=n[o][e];if(a){var s=a.layoutData.columnSpan;i<a.layoutArea.width/s&&(i=a.layoutArea.width/s)}}return i},r.prototype._updateGrid=function(e){for(var t=this._children,r=0;r<t.length;r++){var n=t[r];n&&(n.length=0)}for(var i,a=0,s=e.children;a<s.length;a++){var l=s[a];if(l.layoutData){var u=l.layoutData;if(t[u.row]||(t[u.row]=[]),1==u.columnSpan&&1==u.rowSpan)t[u.row][u.column]=l;else{i||(i=[]),i.push(l);for(var c=u.row;c<u.row+u.rowSpan;c++)for(var h=u.column;h<u.column+u.columnSpan;h++)t[c][h]=l}}}for(var d=(this._rows,this._columns,this._rows.length),p=this._columns.length,f=[],g=0,_=0,y=0,m=0;m<d;m++){var v=this._rows[m];if(v.heightType==o.Auto)this._rowHeights[m]=this._getMaxChildHeightInRow(m),_+=this._rowHeights[m];else if(v.heightType==o.Pixels){var b=this._getMaxChildHeightInRow(m);this._rowHeights[m]=Math.max(v.heightPixels,b),_+=this._rowHeights[m]}else v.heightType==o.Stars&&(f.push(m),g+=v.height)}if(f.length>0)for(var P=e.contentArea.height-_,C=0;C<f.length;C++){var S=f[C],D=this._rows[S].height/g*P,b=this._getMaxChildHeightInRow(C);this._rowHeights[S]=Math.max(D,b)}f.length=0,g=0;for(var x=0;x<p;x++){var A=this._columns[x];if(A.widthType==o.Auto)this._columnWidths[x]=this._getMaxChildWidthInColumn(x),y+=this._columnWidths[x];else if(A.widthType==o.Pixels){var O=this._getMaxChildWidthInColumn(x);this._columnWidths[x]=Math.max(A.widthPixels,O),y+=this._columnWidths[x]}else A.widthType==o.Stars&&(f.push(x),g+=A.width)}if(f.length>0)for(var I=e.contentArea.width-y,T=0;T<f.length;T++){var w=f[T],B=this._columns[w].width/g*I,O=this._getMaxChildWidthInColumn(T);this._columnWidths[w]=Math.max(B,O)}var R=0;this._rowBottoms[d-1]=R;for(var E=d-2;E>=0;E--)R+=this._rowHeights[E+1],this._rowBottoms[E]=R;var L=0;this._columnLefts[0]=L;for(var F=1;F<p;F++)L+=this._columnWidths[F-1],this._columnLefts[F]=L;if(i)for(var M=0;M<i.length;M++)for(var l=i[M],u=l.layoutData,V=u.row;V<u.row+u.rowSpan;V++)for(var h=u.column;h<u.column+u.columnSpan;h++)V==u.row&&h==u.column||t[V][h]==l&&(t[V][h]=null)},r})(t);l.dstOffset=e.Vector4.Zero(),l.dstArea=e.Size.Zero(),l.dstAreaPos=e.Vector2.Zero(),l=h=__decorate([e.className("GridPanelLayoutEngine","BABYLON")],l),e.GridPanelLayoutEngine=l;var u,c,h})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){}return e.prototype.isLocked=function(){return this._isLocked},e.prototype.lock=function(){return!!this._isLocked||(this.onLock(),this._isLocked=!0,!1)},e.prototype.onLock=function(){},e})();e.LockableBase=t;var r=(function(e){function t(t,r){void 0===r&&(r=!1);var n=e.call(this)||this;return n._color=t,r&&n.lock(),n}return __extends(t,e),t.prototype.isTransparent=function(){return this._color&&this._color.a<1},Object.defineProperty(t.prototype,"color",{get:function(){return this._color},set:function(e){this.isLocked()||(this._color=e)},enumerable:!0,configurable:!0}),t.prototype.toString=function(){return this._color.toHexString()},t})(t);r=__decorate([e.className("SolidColorBrush2D","BABYLON")],r),e.SolidColorBrush2D=r;var n=(function(t){function r(r,n,i,o,a,s){void 0===i&&(i=e.Vector2.Zero()),void 0===o&&(o=0),void 0===a&&(a=1),void 0===s&&(s=!1);var l=t.call(this)||this;return l._color1=r,l._color2=n,l._translation=i,l._rotation=o,l._scale=a,s&&l.lock(),l}return __extends(r,t),r.prototype.isTransparent=function(){return this._color1&&this._color1.a<1||this._color2&&this._color2.a<1},Object.defineProperty(r.prototype,"color1",{get:function(){return this._color1},set:function(e){this.isLocked()||(this._color1=e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"color2",{get:function(){return this._color2},set:function(e){this.isLocked()||(this._color2=e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"translation",{get:function(){return this._translation},set:function(e){this.isLocked()||(this._translation=e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"rotation",{get:function(){return this._rotation},set:function(e){this.isLocked()||(this._rotation=e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"scale",{get:function(){return this._scale},set:function(e){this.isLocked()||(this._scale=e)},enumerable:!0,configurable:!0}),r.prototype.toString=function(){return"C1:"+this._color1+";C2:"+this._color2+";T:"+this._translation.toString()+";R:"+this._rotation+";S:"+this._scale+";"},r.BuildKey=function(e,t,r,n,i){return"C1:"+e+";C2:"+t+";T:"+r.toString()+";R:"+n+";S:"+i+";"},r})(t);n=__decorate([e.className("GradientColorBrush2D","BABYLON")],n),e.GradientColorBrush2D=n})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){function t(e,t,r,n){return void 0===r&&(r=l.MODE_TWOWAY),void 0===n&&(n=l.UPDATESOURCETRIGGER_PROPERTYCHANGED),u._hookProperty(e,t,a.PROPKIND_DYNAMIC,{bindingMode:r,bindingUpdateSourceTrigger:n})}function r(e,t,r,n,i){return void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===i&&(i=!1),u._hookProperty(e,t,a.PROPKIND_MODEL,{typeLevelCompare:r,dirtyBoundingInfo:n,dirtyParentBoundingBox:i})}function n(e,t,r,n,i){return void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===i&&(i=!1),u._hookProperty(e,t,a.PROPKIND_INSTANCE,{typeLevelCompare:r,dirtyBoundingInfo:n,dirtyParentBoundingBox:i})}function i(e,t,r,n,i){return void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===i&&(i=!1),u._hookProperty(e,t,a.PROPKIND_DYNAMIC,{typeLevelCompare:r,dirtyBoundingInfo:n,dirtyParentBoundingBox:i})}var o=(function(){function e(){}return e})();e.Prim2DClassInfo=o;var a=(function(){function e(){}return e})();a.PROPKIND_MODEL=1,a.PROPKIND_INSTANCE=2,a.PROPKIND_DYNAMIC=3,e.Prim2DPropInfo=a;var s=(function(){function t(t,r,n){this._baseClass=t,this._type=r,this._subClasses=new Array,this._levelContent=new e.StringDictionary,this._classContentFactory=n}return Object.defineProperty(t.prototype,"classContent",{get:function(){return this._classContent||(this._classContent=this._classContentFactory(this._baseClass?this._baseClass.classContent:null)),this._classContent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"type",{get:function(){return this._type},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"levelContent",{get:function(){return this._levelContent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fullContent",{get:function(){if(!this._fullContent){for(var t=new e.StringDictionary,r=this;r;)r.levelContent.forEach((function(e,r){return t.add(e,r)})),r=r._baseClass;this._fullContent=t}return this._fullContent},enumerable:!0,configurable:!0}),t.prototype.getLevelOf=function(e){if(e===this._type)return this;var t=Object.getPrototypeOf(e),r=this.getOrAddType(Object.getPrototypeOf(t),t);return r||this.getLevelOf(t),this.getOrAddType(t,e)},t.prototype.getOrAddType=function(e,r){if(e===this._type){for(var n=0,i=this._subClasses;n<i.length;n++){var o=i[n];if(o.type===r)return o.node}var a=new t(this,r,this._classContentFactory),s={type:r,node:a};return this._subClasses.push(s),s.node}for(var l=0,u=this._subClasses;l<u.length;l++){var o=u[l],s=o.node.getOrAddType(e,r);if(s)return s}return null},t.get=function(e){var t=e.__classTreeInfo;return t?t.getLevelOf(e):null},t.getOrRegister=function(e,r){var n=e.__classTreeInfo;return n||(n=new t(null,e,r),e.__classTreeInfo=n),n},t})();e.ClassTreeInfo=s;var l=f=(function(){function e(){this._converter=null,this._mode=f.MODE_DEFAULT,this._uiElementId=null,this._dataSource=null,this._currentDataSource=null,this._propertyPathName=null,this._stringFormat=null,this._updateSourceTrigger=f.UPDATESOURCETRIGGER_PROPERTYCHANGED,this._boundTo=null,this._owner=null,this._updateCounter=0}return Object.defineProperty(e.prototype,"converter",{get:function(){return this._converter},set:function(e){this._converter!==e&&(this._converter=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"mode",{get:function(){return this._mode===f.MODE_DEFAULT?this._boundTo.bindingMode:this._mode},set:function(e){this._mode!==e&&(this._mode=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"uiElementId",{get:function(){return this._uiElementId},set:function(e){this._uiElementId!==e&&(this._uiElementId=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dataSource",{get:function(){return this._dataSource},set:function(e){this._dataSource!==e&&(this._dataSource=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"propertyPathName",{get:function(){return this._propertyPathName},set:function(e){this._propertyPathName!==e&&(this._owner,this._propertyPathName=e,this._owner)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"stringFormat",{get:function(){return this._stringFormat},set:function(e){this._stringFormat!==e&&(this._stringFormat=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"updateSourceTrigger",{get:function(){return this._updateSourceTrigger},set:function(e){this._updateSourceTrigger!==e&&(this._updateSourceTrigger=e)},enumerable:!0,configurable:!0}),e.prototype.canUpdateTarget=function(e){e&&(this._updateCounter=0);var t=this.mode;return t===f.MODE_ONETIME?0===this._updateCounter:t!==f.MODE_ONEWAYTOSOURCE},e.prototype.updateTarget=function(){for(var e=this._getActualDataSource(),t=this.propertyPathName.split("."),r=0,n=t;r<n.length;r++){var i=n[r];e=e[i]}this._storeBoundValue(this._owner,e)},e.prototype._storeBoundValue=function(e,t){if(!(++this._updateCounter>1&&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.length;r++){var i=n[r];null!=i&&i._registerDataSource(!0)}this.onPropertyChanged("dataSource",t,e)}},enumerable:!0,configurable:!0}),r.prototype._getDataSource=function(){return this._dataSource},r.prototype.createSimpleDataBinding=function(e,t,r){void 0===r&&(r=l.MODE_DEFAULT);var n=new l;return n.propertyPathName=t,n.mode=r,this.createDataBinding(e,n)},r.prototype.createDataBinding=function(e,t){if(this._bindings||(this._bindings=new Array),!t||null!=t._owner)throw Error("A valid/unused Binding must be passed.");return this.removeDataBinding(e),t._owner=this,t._boundTo=e,this._bindings[e.id]=t,this._hasBinding|=e.flagId,t._registerDataSource(!0),t},r.prototype.removeDataBinding=function(e){if(0===(this._hasBinding&e.flagId))return!1;var t=this._bindings[e.id];return t._unregisterDataSource(),this._bindings[e.id]=null,this._hasBinding&=~e.flagId,!0},r.prototype.updateFromDataSource=function(){for(var e=0,t=this._bindings;e<t.length;e++){t[e]}},r})(e.PropertyChangedBase);u.propChangedInfo=new e.PropertyChangedInfo,u.propChangeGuarding=!1,__decorate([e.logProp()],u.prototype,"_triggerPropertyChanged",null),u=g=__decorate([e.className("SmartPropertyBase","BABYLON")],u),e.SmartPropertyBase=u;var c=(function(){function e(e,t,r){this.binding=e,this.level=t,this.isLast=r}return e})(),h=(function(){function t(t){var r=this;this.monitoredObject=t,this.monitoredIntermediateProperties=new e.StringDictionary,this.observer=this.monitoredObject.propertyChanged.add((function(e,t){r.propertyChangedHandler(e.propertyName,e.oldValue,e.newValue)})),this.boundProperties=new e.StringDictionary,this.monitoredIntermediateMask=0,this.boundPropertiesMask=0}return t.prototype.propertyChangedHandler=function(e,t,r){var n=d._getPropertyID(this.monitoredObject,e),i=n.toString();if(0!==(this.boundPropertiesMask&n))for(var o=this.boundProperties.get(i),a=0,s=o;a<s.length;a++){var l=s[a];l.isLast||(d.unregisterDataSource(this.monitoredObject,l.binding,l.level),d.registerDataSource(l.binding._currentDataSource,l.binding)),l.binding.canUpdateTarget(!1)&&l.binding.updateTarget()}},t})(),d=(function(){function t(){}return t.registerDataSource=function(r,n){for(var i=n.propertyPathName.split("."),o=null,a=0,s=r,l=function(r){var l=i[r],u=t._getPropertyID(s,l),h=u.toString(),d=void 0;if(o){var p=o,f=s,g=a;d=o.monitoredIntermediateProperties.getOrAddWithFactory(g.toString(),(function(e){return p.monitoredIntermediateMask|=g,t._getMonitoredObjectData(f)}))}else d=t._getMonitoredObjectData(s);var _=d,y=d.boundProperties.getOrAddWithFactory(h,(function(e){return _.boundPropertiesMask|=u,new Array})),m=e.Tools.first(y,(function(e){return e.binding===n}));m||y.push(new c(n,r,r+1===i.length)),o=d,a=u,s=s[l]},u=0;u<i.length;u++)l(u)},t.unregisterDataSource=function(e,r,n){for(var i=r.propertyPathName.split("."),o=e,a=t._getMonitoredObjectData(o),s=0;s<i.length;s++){
var l=i[s],u=t._getPropertyID(o,l),c=u.toString();a=s>=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<<n.count}));return i},t})();d._propertiesID=new e.StringDictionary,d._monitoredObjects=new e.StringDictionary;var p=_=(function(t){function r(){var r=t.call(this)||this;return r._flags=0,r._uid=null,r._modelKey=null,r._levelBoundingInfo=new e.BoundingInfo2D,r._boundingInfo=new e.BoundingInfo2D,r.animations=new Array,r}return __extends(r,t),r.prototype.dispose=function(){return!this.isDisposed&&(t.prototype.dispose.call(this),this.animations.splice(0),!0)},Object.defineProperty(r.prototype,"uid",{get:function(){return this._uid||(this._uid=e.Tools.RandomId()),this._uid},enumerable:!0,configurable:!0}),r.prototype.getAnimatables=function(){return new Array},Object.defineProperty(r.prototype,"modelKey",{get:function(){var t=this;if(!this._isFlagSet(_.flagModelDirty)&&this._modelKey)return this._modelKey;var r="Class:"+e.Tools.getClassName(this)+";",n=this.propDic;return n.forEach((function(n,i){if(i.kind===a.PROPKIND_MODEL){var o=t[i.name];if(o&&o.constructor===Array){var s=o[0];o=s?e.Tools.hashCodeFromStream(e.Tools.arrayOrStringFeeder(o)):0}var l="[null]";null!=o&&(l=i.typeLevelCompare?e.Tools.getClassName(o):o instanceof e.StringDictionary?e.Tools.RandomId():o instanceof e.BaseTexture?o.uid:o.toString()),r+=i.name+":"+l+";"}})),this._clearFlags(_.flagModelDirty),this._modelKey=r,r},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isDirty",{get:function(){return 0!==this._instanceDirtyFlags||this._areSomeFlagsSet(_.flagModelDirty|_.flagModelUpdate|_.flagPositioningDirty|_.flagLayoutDirty)},enumerable:!0,configurable:!0}),r.prototype._boundingBoxDirty=function(){if(this._setFlags(_.flagLevelBoundingInfoDirty|_.flagLayoutBoundingInfoDirty),this instanceof e.Prim2DBase)for(var t=this;t&&(t._setFlags(_.flagBoundingInfoDirty|_.flagLayoutBoundingInfoDirty),t.isSizeAuto&&(t.onPrimitivePropertyDirty(e.Prim2DBase.sizeProperty.flagId),t._isFlagSet(_.flagUsePositioning)&&t._setFlags(_.flagPositioningDirty)),!(t instanceof e.Group2D&&t.isRenderableGroup));)t=t.parent},r.prototype._handlePropChanged=function(r,n,i,o,s){if(t.prototype._handlePropChanged.call(this,r,n,i,o,s),o.dirtyBoundingInfo)this._boundingBoxDirty();else if(o.dirtyParentBoundingInfo){var l=this._parent;null!=l&&l._boundingBoxDirty()}if(this instanceof e.Group2D&&this._renderableData&&this.handleGroupChanged(o),this instanceof e.Prim2DBase){var l=this._parent;null!=l&&l.layoutEngine&&0!==(l.layoutEngine.layoutDirtyOnPropertyChangedMask&o.flagId)&&l._setLayoutDirty();var u=this;u.layoutEngine&&0!==(u.layoutEngine.layoutDirtyOnPropertyChangedMask&o.flagId)&&this._setLayoutDirty()}var c=!1;if(s&&null!=r&&null!=n){var h=r.__proto__,d=n.__proto__;c=h===d}if(c||o.kind!==a.PROPKIND_MODEL){if(c||o.kind===a.PROPKIND_INSTANCE||o.kind===a.PROPKIND_DYNAMIC){var p=o.flagId;this.onPrimitivePropertyDirty(p)}}else this.isDirty||(this.onPrimBecomesDirty(),this._setFlags(_.flagModelDirty))},r.prototype.onPrimitivePropertyDirty=function(e){this.onPrimBecomesDirty(),this._instanceDirtyFlags|=e},r.prototype.handleGroupChanged=function(e){},r.prototype._resetPropertiesDirty=function(){t.prototype._resetPropertiesDirty.call(this),this._clearFlags(_.flagPrimInDirtyList|_.flagNeedRefresh)},Object.defineProperty(r.prototype,"levelBoundingInfo",{get:function(){return this._isFlagSet(_.flagLevelBoundingInfoDirty)&&(this.updateLevelBoundingInfo()?(this._boundingInfo.dirtyWorldAABB(),this._clearFlags(_.flagLevelBoundingInfoDirty)):this._levelBoundingInfo.clear()),this._levelBoundingInfo},enumerable:!0,configurable:!0}),r.prototype.updateLevelBoundingInfo=function(){return!1},r.prototype.onPrimBecomesDirty=function(){},r.prototype._isFlagSet=function(e){return 0!==(this._flags&e)},r.prototype._areAllFlagsSet=function(e){return(this._flags&e)===e},r.prototype._areSomeFlagsSet=function(e){return 0!==(this._flags&e)},r.prototype._clearFlags=function(e){this._flags&=~e},r.prototype._setFlags=function(e){var t=this._flags;return this._flags|=e,t},r.prototype._changeFlags=function(e,t){t?this._flags|=e:this._flags&=~e},r.prototype._getFlagsDebug=function(e){var t="";return e&_.flagNoPartOfLayout&&(t+="NoPartOfLayout, "),e&_.flagLevelBoundingInfoDirty&&(t+="LevelBoundingInfoDirty, "),e&_.flagModelDirty&&(t+="ModelDirty, "),e&_.flagLayoutDirty&&(t+="LayoutDirty, "),e&_.flagLevelVisible&&(t+="LevelVisible, "),e&_.flagBoundingInfoDirty&&(t+="BoundingInfoDirty, "),e&_.flagIsPickable&&(t+="IsPickable, "),e&_.flagIsVisible&&(t+="IsVisible, "),e&_.flagVisibilityChanged&&(t+="VisibilityChanged, "),e&_.flagPositioningDirty&&(t+="PositioningDirty, "),e&_.flagTrackedGroup&&(t+="TrackedGroup, "),e&_.flagWorldCacheChanged&&(t+="WorldCacheChanged, "),e&_.flagChildrenFlatZOrder&&(t+="ChildrenFlatZOrder, "),e&_.flagZOrderDirty&&(t+="ZOrderDirty, "),e&_.flagActualOpacityDirty&&(t+="ActualOpacityDirty, "),e&_.flagPrimInDirtyList&&(t+="PrimInDirtyList, "),e&_.flagIsContainer&&(t+="IsContainer, "),e&_.flagNeedRefresh&&(t+="NeedRefresh, "),e&_.flagActualScaleDirty&&(t+="ActualScaleDirty, "),e&_.flagDontInheritParentScale&&(t+="DontInheritParentScale, "),e&_.flagGlobalTransformDirty&&(t+="GlobalTransformDirty, "),e&_.flagLayoutBoundingInfoDirty&&(t+="LayoutBoundingInfoDirty, "),e&_.flagCollisionActor&&(t+="CollisionActor, "),e&_.flagModelUpdate&&(t+="ModelUpdate, "),e&_.flagLocalTransformDirty&&(t+="LocalTransformDirty, "),e&_.flagUsePositioning&&(t+="UsePositioning, "),e&_.flagComputingPositioning&&(t+="ComputingPositioning, "),t.slice(0,t.length-2)},r})(u);p.SMARTPROPERTYPRIM_PROPCOUNT=0,p.flagNoPartOfLayout=1,p.flagLevelBoundingInfoDirty=2,p.flagModelDirty=4,p.flagLayoutDirty=8,p.flagLevelVisible=16,p.flagBoundingInfoDirty=32,p.flagIsPickable=64,p.flagIsVisible=128,p.flagVisibilityChanged=256,p.flagPositioningDirty=512,p.flagTrackedGroup=1024,p.flagWorldCacheChanged=2048,p.flagChildrenFlatZOrder=4096,p.flagZOrderDirty=8192,p.flagActualOpacityDirty=16384,p.flagPrimInDirtyList=32768,p.flagIsContainer=65536,p.flagNeedRefresh=131072,p.flagActualScaleDirty=262144,p.flagDontInheritParentScale=524288,p.flagGlobalTransformDirty=1048576,p.flagLayoutBoundingInfoDirty=2097152,p.flagCollisionActor=4194304,p.flagModelUpdate=8388608,p.flagLocalTransformDirty=16777216,p.flagUsePositioning=33554432,p.flagComputingPositioning=67108864,p.flagAlignPrimitive=134217728,__decorate([e.logProp()],p.prototype,"levelBoundingInfo",null),p=_=__decorate([e.className("SmartPropertyPrim","BABYLON")],p),e.SmartPropertyPrim=p,e.dependencyProperty=t,e.modelLevelProperty=r,e.instanceLevelProperty=n,e.dynamicLevelProperty=i;var f,g,_})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this.forceRefreshPrimitive=!1}return e})();e.PrepareRender2DContext=t;var r=(function(){function e(e){this._renderMode=e,this.useInstancing=!1,this.groupInfoPartData=null,this.partDataStartIndex=this.partDataEndIndex=null,this.instancedBuffers=null}return Object.defineProperty(e.prototype,"renderMode",{get:function(){return this._renderMode},enumerable:!0,configurable:!0}),Object.defineProperty(e,"RenderModeOpaque",{get:function(){return e._renderModeOpaque},enumerable:!0,configurable:!0}),Object.defineProperty(e,"RenderModeAlphaTest",{get:function(){return e._renderModeAlphaTest},enumerable:!0,configurable:!0}),Object.defineProperty(e,"RenderModeTransparent",{get:function(){return e._renderModeTransparent},enumerable:!0,configurable:!0}),e})();r._renderModeOpaque=1,r._renderModeAlphaTest=2,r._renderModeTransparent=3,e.Render2DContext=r;var n=(function(){function t(){this.primitivePointerPos=e.Vector2.Zero(),this.tilt=e.Vector2.Zero(),this.cancelBubble=!1}return Object.defineProperty(t,"PointerOver",{get:function(){return t._pointerOver},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PointerEnter",{get:function(){return t._pointerEnter},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PointerDown",{get:function(){return t._pointerDown},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PointerMouseWheel",{get:function(){return t._pointerMouseWheel},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PointerMove",{get:function(){return t._pointerMove},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PointerUp",{get:function(){return t._pointerUp},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PointerOut",{get:function(){return t._pointerOut},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PointerLeave",{get:function(){return t._pointerLeave},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PointerGotCapture",{get:function(){return t._pointerGotCapture},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PointerLostCapture",{get:function(){return t._pointerLostCapture},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MouseWheelPrecision",{get:function(){return t._mouseWheelPrecision},enumerable:!0,configurable:!0}),t.prototype.updateRelatedTarget=function(e,t){this.relatedTarget=e,this.relatedTargetPointerPos=t},t.getEventTypeName=function(e){switch(e){case t.PointerOver:return"PointerOver";case t.PointerEnter:return"PointerEnter";case t.PointerDown:return"PointerDown";case t.PointerMouseWheel:return"PointerMouseWheel";case t.PointerMove:return"PointerMove";case t.PointerUp:return"PointerUp";case t.PointerOut:return"PointerOut";case t.PointerLeave:return"PointerLeave";case t.PointerGotCapture:return"PointerGotCapture";case t.PointerLostCapture:return"PointerLostCapture"}},t})();n._pointerOver=1,n._pointerEnter=2,n._pointerDown=4,n._pointerMouseWheel=8,n._pointerMove=16,n._pointerUp=32,n._pointerOut=64,n._pointerLeave=128,n._pointerGotCapture=256,n._pointerLostCapture=512,n._mouseWheelPrecision=3,e.PrimitivePointerInfo=n;var i=u=(function(){function e(e){this._changedCallback=e,this._horizontal=u.AlignLeft,this._vertical=u.AlignBottom}return Object.defineProperty(e,"AlignLeft",{get:function(){return u._AlignLeft},enumerable:!0,configurable:!0}),Object.defineProperty(e,"AlignTop",{get:function(){return u._AlignTop},enumerable:!0,configurable:!0}),Object.defineProperty(e,"AlignRight",{get:function(){return u._AlignRight},enumerable:!0,configurable:!0}),Object.defineProperty(e,"AlignBottom",{get:function(){return u._AlignBottom},enumerable:!0,configurable:!0}),Object.defineProperty(e,"AlignCenter",{get:function(){return u._AlignCenter},enumerable:!0,configurable:!0}),Object.defineProperty(e,"AlignStretch",{get:function(){return u._AlignStretch},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"horizontal",{get:function(){return this._horizontal},set:function(e){this._horizontal!==e&&(this._horizontal=e,this.onChangeCallback())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"vertical",{get:function(){return this._vertical},set:function(e){this._vertical!==e&&(this._vertical=e,this.onChangeCallback())},enumerable:!0,configurable:!0}),e.prototype.onChangeCallback=function(){this._changedCallback&&this._changedCallback()},e.prototype.setHorizontal=function(e){var t=e.trim().toLocaleLowerCase();switch(t){case"left":return void(this.horizontal=u.AlignLeft);case"right":return void(this.horizontal=u.AlignRight);case"center":return void(this.horizontal=u.AlignCenter);case"stretch":return void(this.horizontal=u.AlignStretch)}},e.prototype.setVertical=function(e){var t=e.trim().toLocaleLowerCase();switch(t){case"top":return void(this.vertical=u.AlignTop);case"bottom":return void(this.vertical=u.AlignBottom);case"center":return void(this.vertical=u.AlignCenter);case"stretch":return void(this.vertical=u.AlignStretch)}},e.prototype.fromString=function(e){var t=e.trim().split(",");if(1===t.length)this.setHorizontal(t[0]),this.setVertical(t[0]);else for(var r=0,n=t;r<n.length;r++){var i=n[r];i=i.toLocaleLowerCase().trim();var o=i.indexOf("h:");o===-1&&(o=i.indexOf("horizontal:")),o===-1?(o=i.indexOf("v:"),o===-1&&(o=i.indexOf("vertical:")),o===-1||(i=i.substr(i.indexOf(":")+1),this.setVertical(i))):(i=i.substr(i.indexOf(":")+1),this.setHorizontal(i))}},e.prototype.copyFrom=function(e){this._horizontal=e._horizontal,this._vertical=e._vertical,this.onChangeCallback()},e.prototype.clone=function(){var e=new u;return e._horizontal=this._horizontal,e._vertical=this._vertical,e},Object.defineProperty(e.prototype,"isDefault",{get:function(){return this.horizontal===u.AlignLeft&&this.vertical===u.AlignBottom},enumerable:!0,configurable:!0}),e})();i._AlignLeft=1,i._AlignTop=1,i._AlignRight=2,i._AlignBottom=2,i._AlignCenter=3,i._AlignStretch=4,i=u=__decorate([e.className("PrimitiveAlignment","BABYLON")],i),e.PrimitiveAlignment=i;var o=(function(){function e(e,t){this.prim=e,this.intersectionLocation=t}return e})();e.PrimitiveIntersectedInfo=o;var a=c=(function(){function e(e,t){this._parentAccess=e,this._changedCallback=t,this._pixels=new Array(4),this._percentages=new Array(4),this._setType(0,c.Auto),this._setType(1,c.Auto),this._setType(2,c.Auto),this._setType(3,c.Auto),this._pixels[0]=0,this._pixels[1]=0,this._pixels[2]=0,this._pixels[3]=0}return e.prototype.fromString=function(e){this._clear();var t=e.trim().split(",");if(1===t.length&&e.indexOf(":")===-1)return this._setStringValue(t[0],0,!1),this._setStringValue(t[0],1,!1),this._setStringValue(t[0],2,!1),this._setStringValue(t[0],3,!1),void this.onChangeCallback();for(var r=!1,n=0,i=t;n<i.length;n++){var o=i[n];r=this._extractString(o,!1)||r}if(!r)throw new Error("Can't parse the string to create a PrimitiveMargin object, format must be: 'top: <value>, left:<value>, right:<value>, bottom:<value>");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-b*_)/2;o.x=I+(A-O),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-P*y)/2;o.y=I+(T-w),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;t<r.length;t++){var n=r[t];if(n.prim===e)return n.intersectionLocation}return null},t.prototype._exit=function(e){e&&(this._globalPickPosition=null)},t})();e.IntersectInfo2D=s;var l=h=(function(t){function r(r){var n=this;null==r&&(r={}),n=t.call(this)||this;var i,o;if(h._isCanvasInit)i=n,o=null,n._canvasPreInit(r);else if(null!=r.parent){if(o=r.parent,i=r.parent.owner,!i)throw new Error("Parent "+o.id+" of "+r.id+" doesn't have a valid owner!");if(!(n instanceof e.Group2D||n instanceof e.Sprite2D&&null!=r.id&&0===r.id.indexOf("__cachedSpriteOfGroup__")||i.cachingStrategy!==e.Canvas2D.CACHESTRATEGY_TOPLEVELGROUPS||o!==i))throw new Error("Can't create a primitive with the canvas as direct parent when the caching strategy is TOPLEVELGROUPS. You need to create a Group below the canvas and use it as the parent for the primitive")}n._layoutEngine=e.CanvasLayoutEngine.Singleton,n._size=null,n._scale=new e.Vector2(1,1),n._postScale=new e.Vector2(1,1),n._actualSize=null,n._internalSize=e.Size.Zero(),n._layoutArea=null,n._layoutAreaPos=null,n._layoutBoundingInfo=null,n._marginOffset=e.Vector4.Zero(),n._paddingOffset=e.Vector4.Zero(),n._parentPaddingOffset=e.Vector2.Zero(),n._parentContentArea=e.Size.Zero(),n._lastAutoSizeArea=e.Size.Zero(),n._contentArea=e.Size.Zero(),n._pointerEventObservable=new e.Observable,n._owner=i,n._parent=null,n._margin=null,n._padding=null,n._marginAlignment=null,n._id=r.id,n._children=new Array,n._localTransform=new e.Matrix2D,n._localLayoutTransform=new e.Matrix2D,n._globalTransform=null,n._invGlobalTransform=null,n._globalTransformProcessStep=0,n._globalTransformStep=0,n._prepareProcessStep=0,n._updateCachesProcessStep=0,n._renderGroup=null,n._primLinearPosition=0,n._manualZOrder=null,n._zOrder=0,n._zMax=0,n._firstZDirtyIndex=h._bigInt,n._actualOpacity=0,n._actualScale=e.Vector2.Zero(),n._displayDebugAreas=!1,n._debugAreaGroup=null,n._primTriArray=null,n._primTriArrayDirty=!0,i&&n.onSetOwner(),n._levelBoundingInfo.worldMatrixAccess=function(){return n.globalTransform},n._boundingInfo.worldMatrixAccess=function(){return n.globalTransform};var a=!0,s=!0;if(void 0!==r.isPickable&&(a=r.isPickable),void 0!==r.isContainer&&(s=r.isContainer),r.dontInheritParentScale&&n._setFlags(e.SmartPropertyPrim.flagDontInheritParentScale),r.alignToPixel&&(n.alignToPixel=!0),n._setFlags((a?e.SmartPropertyPrim.flagIsPickable:0)|e.SmartPropertyPrim.flagBoundingInfoDirty|e.SmartPropertyPrim.flagActualOpacityDirty|(s?e.SmartPropertyPrim.flagIsContainer:0)|e.SmartPropertyPrim.flagActualScaleDirty|e.SmartPropertyPrim.flagLayoutBoundingInfoDirty),null!=r.opacity?n._opacity=r.opacity:n._opacity=1,n._updateRenderMode(),r.childrenFlatZOrder&&n._setFlags(e.SmartPropertyPrim.flagChildrenFlatZOrder),null!=o&&(o.addChild(n),n._hierarchyDepth=o._hierarchyDepth+1,n._patchHierarchy(o.owner)),n.owner&&n instanceof e.Group2D){var l=n;l.detectGroupStates()}if(null!=r.children)for(var u=0,c=r.children;u<c.length;u++){var d=c[u];n.addChild(d),null!=n.owner&&null!=n._hierarchyDepth&&d._patchHierarchy(n.owner)}if(null!=r.zOrder&&(n.zOrder=r.zOrder),null!=r.position?n.position=r.position:null!=r.x||null!=r.y?n.position=new e.Vector2(r.x||0,r.y||0):n._position=null,n.rotation=null==r.rotation?0:r.rotation,null!=r.scale?n.scale=r.scale:(null!=r.scaleX&&(n.scaleX=r.scaleX),null!=r.scaleY&&(n.scaleY=r.scaleY)),n.levelVisible=null==r.isVisible||r.isVisible,n.origin=r.origin||new e.Vector2(.5,.5),null!=r.layoutEngine)if("string"==typeof r.layoutEngine){var p=r.layoutEngine.toLocaleLowerCase().trim();"canvas"===p||"canvaslayoutengine"===p?n.layoutEngine=e.CanvasLayoutEngine.Singleton:0===p.indexOf("stackpanel")||0===p.indexOf("horizontalstackpanel")?n.layoutEngine=e.StackPanelLayoutEngine.Horizontal:0===p.indexOf("verticalstackpanel")&&(n.layoutEngine=e.StackPanelLayoutEngine.Vertical)}else r.layoutEngine instanceof e.LayoutEngineBase&&(n.layoutEngine=r.layoutEngine);return r.marginTop&&n.margin.setTop(r.marginTop),r.marginLeft&&n.margin.setLeft(r.marginLeft),r.marginRight&&n.margin.setRight(r.marginRight),r.marginBottom&&n.margin.setBottom(r.marginBottom),r.margin&&("string"==typeof r.margin?n.margin.fromString(r.margin):n.margin.fromUniformPixels(r.margin)),r.marginHAlignment&&(n.marginAlignment.horizontal=r.marginHAlignment),r.marginVAlignment&&(n.marginAlignment.vertical=r.marginVAlignment),r.marginAlignment&&n.marginAlignment.fromString(r.marginAlignment),r.paddingTop&&n.padding.setTop(r.paddingTop),r.paddingLeft&&n.padding.setLeft(r.paddingLeft),r.paddingRight&&n.padding.setRight(r.paddingRight),r.paddingBottom&&n.padding.setBottom(r.paddingBottom),r.padding&&("string"==typeof r.padding?n.padding.fromString(r.padding):n.padding.fromUniformPixels(r.padding)),r.layoutData&&(n.layoutData=r.layoutData),n._updatePositioningState(),n._parentLayoutDirty(),n._positioningDirty(),r.levelCollision||r.deepCollision?(n._actorInfo=n.owner._primitiveCollisionManager._addActor(n,r.deepCollision===!0),n._setFlags(e.SmartPropertyPrim.flagCollisionActor)):n._actorInfo=null,n}return __extends(r,t),Object.defineProperty(r.prototype,"intersectWithObservable",{get:function(){return this._actorInfo?this._actorInfo.intersectWith.dictionaryChanged:null},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"intersectWith",{get:function(){return this._actorInfo?this._actorInfo.intersectWith:null},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"actionManager",{get:function(){return this._actionManager||(this._actionManager=new e.ActionManager(this.owner.scene)),this._actionManager},enumerable:!0,configurable:!0}),r.prototype.traverseUp=function(e){for(var t=this;null!=t;){if(e(t))return t;t=t._parent}return null},Object.defineProperty(r.prototype,"owner",{get:function(){return this._owner},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"children",{get:function(){return this._children},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"id",{get:function(){return this._id},set:function(e){if(this._id!==e){var t=this._id;this.onPropertyChanged("id",t,this._id)}},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"actualPosition",{get:function(){return this._isFlagSet(e.SmartPropertyPrim.flagUsePositioning)?null!=this._actualPosition?this._actualPosition:(this._updatePositioning(),this._actualPosition):this.position;
},set:function(e){this._actualPosition?this._actualPosition.copyFrom(e):this._actualPosition=e.clone()},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"actualX",{get:function(){return this.actualPosition.x},set:function(e){this._actualPosition.x=e,this._triggerPropertyChanged(h.actualPositionProperty,this._actualPosition)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"actualY",{get:function(){return this.actualPosition.y},set:function(e){this._actualPosition.y=e,this._triggerPropertyChanged(h.actualPositionProperty,this._actualPosition)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"position",{get:function(){return this._position||(this._position=e.Vector2.Zero()),this._position},set:function(e){if(this._checkUseMargin()){switch(this.marginAlignment.horizontal){case i.AlignLeft:case i.AlignStretch:case i.AlignCenter:this.margin.leftPixels=e.x;break;case i.AlignRight:this.margin.rightPixels=e.x}switch(this.marginAlignment.vertical){case i.AlignBottom:case i.AlignStretch:case i.AlignCenter:this.margin.bottomPixels=e.y;break;case i.AlignTop:this.margin.topPixels=e.y}}else e?this._position?this._position.copyFrom(e):this._position=e.clone():this._position=null,this._actualPosition=null,this._triggerPropertyChanged(h.actualPositionProperty,e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"x",{get:function(){return this._position?this._position.x:null},set:function(t){if(null==t)throw new Error("Can't set a null x in primitive "+this.id+", only the position can be turned to null");if(this._checkUseMargin())switch(this.marginAlignment.horizontal){case i.AlignLeft:case i.AlignStretch:case i.AlignCenter:this.margin.leftPixels=t;break;case i.AlignRight:this.margin.rightPixels=t}else this._position||(this._position=e.Vector2.Zero()),this._position.x!==t&&(this._position.x=t,this._actualPosition=null,this._triggerPropertyChanged(h.positionProperty,t),this._triggerPropertyChanged(h.actualPositionProperty,t))},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"y",{get:function(){return this._position?this._position.y:null},set:function(t){if(null==t)throw new Error("Can't set a null y in primitive "+this.id+", only the position can be turned to null");if(this._checkUseMargin())switch(this.marginAlignment.vertical){case i.AlignBottom:case i.AlignStretch:case i.AlignCenter:this.margin.bottomPixels=t;break;case i.AlignTop:this.margin.topPixels=t}else this._position||(this._position=e.Vector2.Zero()),this._position.y!==t&&(this._position.y=t,this._actualPosition=null,this._triggerPropertyChanged(h.positionProperty,t),this._triggerPropertyChanged(h.actualPositionProperty,t))},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"size",{get:function(){return this.internalGetSize()},set:function(e){this.internalSetSize(e)},enumerable:!0,configurable:!0}),r.prototype.internalGetSize=function(){if(!this._size||null==this._size.width||null==this._size.height){var t=h.boundinbBoxReentrency;if(t!==-1&&t<=(this.hierarchyDepth||0))return e.C2DLogging.setPostMessage((function(){return"re entrancy detected"})),h.nullSize;if(!this._isFlagSet(e.SmartPropertyPrim.flagLayoutBoundingInfoDirty))return e.C2DLogging.setPostMessage((function(){return"cache hit"})),this._internalSize;e.C2DLogging.setPostMessage((function(){return"cache miss"})),h.boundinbBoxReentrency=this.hierarchyDepth||0;var r=this.boundingInfo;return h.boundinbBoxReentrency=-1,h._size.copyFrom(this._internalSize),r.sizeToRef(this._internalSize),this._internalSize.equals(h._size)||(this._triggerPropertyChanged(h.sizeProperty,this._internalSize),this._positioningDirty()),this._internalSize||h._nullSize}return e.C2DLogging.setPostMessage((function(){return"user set size"})),this._size||h._nullSize},r.prototype.internalSetSize=function(e){e?this._size?this._size.copyFrom(e):this._size=e.clone():this._size=null,this._actualSize=null,this._updatePositioningState(),this._positioningDirty()},Object.defineProperty(r.prototype,"width",{get:function(){return this.size?this.size.width:null},set:function(t){this.size&&this.size.width===t||(this.size?this.size.width=t:this.size=new e.Size(t,0),this._actualSize=null,this._triggerPropertyChanged(h.sizeProperty,t),this._positioningDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"height",{get:function(){return this.size?this.size.height:null},set:function(t){this.size&&this.size.height===t||(this.size?this.size.height=t:this.size=new e.Size(0,t),this._actualSize=null,this._triggerPropertyChanged(h.sizeProperty,t),this._positioningDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"rotation",{get:function(){return this._rotation},set:function(e){this._rotation=e,this._hasMargin&&this._positioningDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"scale",{get:function(){return this._scale.x},set:function(t){if(t<=0)throw new Error("You can't set the scale to less or equal to 0");this._scale.x=this._scale.y=t,this._setFlags(e.SmartPropertyPrim.flagActualScaleDirty),this._spreadActualScaleDirty(),this._positioningDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"actualSize",{get:function(){return this._isFlagSet(e.SmartPropertyPrim.flagUsePositioning)?this._actualSize?this._actualSize:(this._updatePositioning(),this._actualSize):this.size},set:function(e){this._actualSize&&this._actualSize.equals(e)||(this._actualSize?this._actualSize.copyFrom(e):this._actualSize=e.clone())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"actualWidth",{get:function(){return this.actualSize.width},set:function(e){this._actualSize.width=e,this._triggerPropertyChanged(h.actualSizeProperty,this._actualSize)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"actualHeight",{get:function(){return this.actualSize.height},set:function(e){this._actualSize.height=e,this._triggerPropertyChanged(h.actualPositionProperty,this._actualSize)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"actualZOffset",{get:function(){return null!=this._manualZOrder?this._manualZOrder:(this._isFlagSet(e.SmartPropertyPrim.flagZOrderDirty)&&this._updateZOrder(),1-this._zOrder)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"minSize",{get:function(){return this._minSize},set:function(e){this._minSize&&e&&this._minSize.equals(e)||(this._minSize?this._minSize.copyFrom(e):this._minSize=e.clone(),this._parentLayoutDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"maxSize",{get:function(){return this._maxSize},set:function(e){this._maxSize&&e&&this._maxSize.equals(e)||(this._maxSize?this._maxSize.copyFrom(e):this._maxSize=e.clone(),this._parentLayoutDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"origin",{get:function(){return this._origin},set:function(e){this._origin?this._origin.copyFrom(e):this._origin=e.clone()},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"levelVisible",{get:function(){return this._isFlagSet(e.SmartPropertyPrim.flagLevelVisible)},set:function(t){this._changeFlags(e.SmartPropertyPrim.flagLevelVisible,t)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isVisible",{get:function(){return this._isFlagSet(e.SmartPropertyPrim.flagIsVisible)},set:function(t){this._changeFlags(e.SmartPropertyPrim.flagIsVisible,t)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"zOrder",{get:function(){return this._manualZOrder},set:function(e){this._manualZOrder!==e&&(this._manualZOrder=e,this.onZOrderChanged(),this._actualZOrderChangedObservable&&this._actualZOrderChangedObservable.hasObservers()&&this._actualZOrderChangedObservable.notifyObservers(e))},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isManualZOrder",{get:function(){return null!=this._manualZOrder},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"margin",{get:function(){var e=this;return this._margin||(this._margin=new a(function(){return e.parent?e.parent.margin:null},function(){return e._positioningDirty()}),this._updatePositioningState()),this._margin},set:function(e){e?this.margin.copyFrom(e):this._margin=null,this._updatePositioningState()},enumerable:!0,configurable:!0}),r.prototype.setMargin=function(e){this.margin.fromString(e),this._updatePositioningState()},Object.defineProperty(r.prototype,"_hasMargin",{get:function(){return null!==this._margin&&!this._margin.isDefault||null!==this._marginAlignment&&!this._marginAlignment.isDefault},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"padding",{get:function(){var e=this;return this._padding||(this._padding=new a(function(){return e.parent?e.parent.padding:null},function(){return e._positioningDirty()}),this._updatePositioningState()),this._padding},set:function(e){e?this.padding.copyFrom(e):this._padding=null,this._updatePositioningState()},enumerable:!0,configurable:!0}),r.prototype.setPadding=function(e){this.padding.fromString(e),this._updatePositioningState()},Object.defineProperty(r.prototype,"_hasPadding",{get:function(){return null!==this._padding&&!this._padding.isDefault},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"marginAlignment",{get:function(){var e=this;return this._marginAlignment||(this._marginAlignment=new i(function(){return e._positioningDirty()}),this._updatePositioningState()),this._marginAlignment},set:function(e){e?this.marginAlignment.copyFrom(e):this._marginAlignment=null,this._updatePositioningState()},enumerable:!0,configurable:!0}),r.prototype.setMarginalignment=function(e){this.marginAlignment.fromString(e),this._updatePositioningState()},Object.defineProperty(r.prototype,"_hasMarginAlignment",{get:function(){return null!==this._marginAlignment&&!this._marginAlignment.isDefault},enumerable:!0,configurable:!0}),r.prototype._updatePositioningState=function(){var t=this._hasMargin||this._hasPadding||this.isSizeAuto;this._changeFlags(e.SmartPropertyPrim.flagUsePositioning,t)},Object.defineProperty(r.prototype,"opacity",{get:function(){return this._opacity},set:function(t){t<0?t=0:t>1&&(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;t<r.length;t++){var n=r[t];n._setFlags(e.SmartPropertyPrim.flagActualScaleDirty),n._spreadActualScaleDirty()}},Object.defineProperty(r.prototype,"actualScale",{get:function(){if(this._isFlagSet(e.SmartPropertyPrim.flagActualScaleDirty)){for(var t=this._isFlagSet(e.SmartPropertyPrim.flagDontInheritParentScale)?null:this.parent,r=this.scaleX,n=this.scaleY;t;)r*=t.scaleX,n*=t.scaleY,t=t._isFlagSet(e.SmartPropertyPrim.flagDontInheritParentScale)?null:t.parent;this._actualScale.copyFromFloats(r,n),this._clearFlags(e.SmartPropertyPrim.flagActualScaleDirty)}return this._actualScale},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"actualScaleX",{get:function(){return this.actualScale.x},enumerable:!0,configurable:!0}),r.prototype.getActualGlobalScaleToRef=function(e){var t=this.actualScale,r=this.owner._canvasLevelScale||h._iv2;e.x=t.x*r.x,e.y=t.y*r.y},Object.defineProperty(r.prototype,"actualScaleY",{get:function(){return this.actualScale.y},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"actualOpacity",{get:function(){if(this._isFlagSet(e.SmartPropertyPrim.flagActualOpacityDirty)){for(var t=this.parent,r=this.opacity;t;)r*=t.opacity,t=t.parent;this._actualOpacity=r,this._clearFlags(e.SmartPropertyPrim.flagActualOpacityDirty)}return this._actualOpacity},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"layoutEngine",{get:function(){return this._layoutEngine||(this._layoutEngine=e.CanvasLayoutEngine.Singleton),this._layoutEngine},set:function(e){this._layoutEngine!==e&&this._changeLayoutEngine(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"layoutArea",{get:function(){return this._layoutArea},set:function(t){this._layoutArea&&this._layoutArea.equals(t)||(this._positioningDirty(),this._setFlags(e.SmartPropertyPrim.flagLayoutBoundingInfoDirty),this.parent&&this.parent._setFlags(e.SmartPropertyPrim.flagLayoutBoundingInfoDirty|e.SmartPropertyPrim.flagGlobalTransformDirty),this._layoutArea?this._layoutArea.copyFrom(t):this._layoutArea=t.clone())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"layoutAreaPos",{get:function(){return this._layoutAreaPos},set:function(t){this._layoutAreaPos&&this._layoutAreaPos.equals(t)||(this.parent&&this.parent._setFlags(e.SmartPropertyPrim.flagLayoutBoundingInfoDirty|e.SmartPropertyPrim.flagGlobalTransformDirty),this._positioningDirty(),this._layoutAreaPos?this._layoutAreaPos.copyFrom(t):this._layoutAreaPos=t.clone(),this._setFlags(e.SmartPropertyPrim.flagLocalTransformDirty))},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isPickable",{get:function(){return this._isFlagSet(e.SmartPropertyPrim.flagIsPickable)},set:function(t){this._changeFlags(e.SmartPropertyPrim.flagIsPickable,t)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isContainer",{get:function(){return this._isFlagSet(e.SmartPropertyPrim.flagIsContainer)},set:function(t){this._changeFlags(e.SmartPropertyPrim.flagIsContainer,t)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"hierarchyDepth",{get:function(){return this._hierarchyDepth},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"renderGroup",{get:function(){return this._renderGroup},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"globalTransform",{get:function(){return this._globalTransform&&this._globalTransformProcessStep===this.owner._globalTransformProcessStep||this.updateCachedStates(!1),this._globalTransform},enumerable:!0,configurable:!0}),r.prototype.getGlobalPosition=function(){var t=new e.Vector2(0,0);return this.getGlobalPositionByRef(t),t},r.prototype.getGlobalPositionByRef=function(e){e.x=this.globalTransform.m[4],e.y=this.globalTransform.m[5]},Object.defineProperty(r.prototype,"invGlobalTransform",{get:function(){return this._updateLocalTransform(),this._invGlobalTransform},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"localTransform",{get:function(){return this._updateLocalTransform(),this._localTransform},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"localLayoutTransform",{get:function(){return this._updateLocalTransform(),this._localLayoutTransform},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"alignToPixel",{get:function(){return this._isFlagSet(e.SmartPropertyPrim.flagAlignPrimitive)},set:function(t){this._changeFlags(e.SmartPropertyPrim.flagAlignPrimitive,t)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"boundingInfo",{get:function(){if(this._isFlagSet(e.SmartPropertyPrim.flagBoundingInfoDirty)){this.owner&&this.owner.boundingInfoRecomputeCounter.addCount(1,!1),e.C2DLogging.setPostMessage((function(){return"cache miss"}));var t=this.isSizedByContent;if(t?this._boundingInfo.clear():this._boundingInfo.copyFrom(this.levelBoundingInfo),this._children.length>0){for(var r=new e.BoundingInfo2D,n=h._tpsBB2,i=0,o=this._children;i<o.length;i++){var a=o[i];if(!a._isFlagSet(e.SmartPropertyPrim.flagNoPartOfLayout)){var s=a.layoutBoundingInfo;s.transformToRef(a.localLayoutTransform,n),r.unionToRef(n,r)}}if(this._hasPadding){var l=this.padding,u=h._bMinMax;r.minMaxToRef(u),this._paddingOffset.copyFromFloats(l.leftPixels,l.bottomPixels,l.rightPixels,l.topPixels);var c=h._size2;r.sizeToRef(c),this._getActualSizeFromContentToRef(c,this._paddingOffset,c),u.z+=this._paddingOffset.z+this._paddingOffset.x,u.w+=this._paddingOffset.w+this._paddingOffset.y,e.BoundingInfo2D.CreateFromMinMaxToRef(u.x,u.z,u.y,u.w,r)}else this._paddingOffset.copyFromFloats(0,0,0,0);this._boundingInfo.unionToRef(r,this._boundingInfo)}!t&&this._isFlagSet(e.SmartPropertyPrim.flagLevelBoundingInfoDirty)||this._clearFlags(e.SmartPropertyPrim.flagBoundingInfoDirty)}else e.C2DLogging.setPostMessage((function(){return"cache hit"}));return this._boundingInfo},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"layoutBoundingInfo",{get:function(){var t=this._isFlagSet(e.SmartPropertyPrim.flagUsePositioning);if(this._isFlagSet(e.SmartPropertyPrim.flagLayoutBoundingInfoDirty)){if(e.C2DLogging.setPostMessage((function(){return"cache miss"})),this._owner&&this._owner.addLayoutBoundingInfoUpdateCounter(1),this._isFlagSet(e.SmartPropertyPrim.flagLayoutDirty)&&(this._owner&&this._owner.addUpdateLayoutCounter(1),this._layoutEngine.updateLayout(this),this._clearFlags(e.SmartPropertyPrim.flagLayoutDirty)),t){if(this._isFlagSet(e.SmartPropertyPrim.flagPositioningDirty)&&this._updatePositioning(),!this._layoutBoundingInfo)return e.C2DLogging.setPostMessage((function(){return"re entrance detected, boundingInfo returned"})),this.boundingInfo;if(this._isFlagSet(e.SmartPropertyPrim.flagPositioningDirty))return e.C2DLogging.setPostMessage((function(){return"couldn't compute positioning, boundingInfo returned"})),this.boundingInfo}if(!t){var r=this.boundingInfo;return this._isFlagSet(e.SmartPropertyPrim.flagBoundingInfoDirty)||this._clearFlags(e.SmartPropertyPrim.flagLayoutBoundingInfoDirty),r}this._clearFlags(e.SmartPropertyPrim.flagLayoutBoundingInfoDirty)}else e.C2DLogging.setPostMessage((function(){return"cache hit"}));return t?this._layoutBoundingInfo:this.boundingInfo},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isSizeAuto",{get:function(){var e=this._size;return null==e||null==e.width&&null==e.height},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isHorizontalSizeAuto",{get:function(){var e=this._size;return null==e||null==e.width},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isVerticalSizeAuto",{get:function(){var e=this._size;return null==e||null==e.height},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isSizedByContent",{get:function(){return null==this._size&&this._children.length>0},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;t<r.length;t++){var n=r[t],i=n.findById(e);if(null!=i)return i}},r.prototype.onZOrderChanged=function(){},r.prototype.levelIntersect=function(e){return!1},r.prototype.setPointerEventCapture=function(e){return this.owner._setPointerCapture(e,this)},r.prototype.releasePointerEventsCapture=function(e){return this.owner._releasePointerCapture(e,this)},r.prototype.intersect=function(t){if(!t)return!1;var r=!t._globalPickPosition;if(r&&(t._globalPickPosition=e.Vector2.Zero(),this.globalTransform.transformPointToRef(t.pickPosition,t._globalPickPosition),t._localPickPosition=t.pickPosition.clone(),t.intersectedPrimitives=new Array,t.topMostIntersectedPrimitive=null),!h._bypassGroup2DExclusion&&this instanceof e.Group2D&&this.isCachedGroup&&!this.isRenderableGroup)return t._exit(r),!1;if(!t.intersectHidden&&!this.isVisible)return t._exit(r),!1;var n=this.id;if(null!=n&&0===n.indexOf("__cachedSpriteOfGroup__"))try{h._bypassGroup2DExclusion=!0;var i=this.getExternalData("__cachedGroup__");return!!i&&i.intersect(t)}finally{h._bypassGroup2DExclusion=!1}var a=!1;if(this instanceof e.Group2D){var s=this;a=s.isCachedGroup}if(a&&!this.levelBoundingInfo.doesIntersect(t._localPickPosition))return t._exit(r),!1;var l=!0;if(this.isPickable&&!this.boundingInfo.doesIntersect(t._localPickPosition)){if(this.isContainer)return t._exit(r),!1;l=!1}var u=!1;if(this.isPickable&&(u=l&&this.levelIntersect(t))){var c=new o(this,t._localPickPosition.clone());if(t.intersectedPrimitives.push(c),(!t.topMostIntersectedPrimitive||t.topMostIntersectedPrimitive.prim.actualZOffset>c.prim.actualZOffset)&&(t.topMostIntersectedPrimitive=c),t.findFirstOnly)return t._exit(r),!0}if(!u||!t.findFirstOnly)for(var d=0,p=this._children;d<p.length;d++){var f=p[d];if((f.isPickable||!f.isContainer)&&(t.intersectHidden||f.isVisible)&&(f.invGlobalTransform.transformPointToRef(t._globalPickPosition,t._localPickPosition),f.intersect(t)&&t.findFirstOnly))return t._exit(r),!0}return t._exit(r),t.isIntersected},r.prototype.intersectOtherPrim=function(t){var r=this.triList,n=t.triList;return e.Tri2DArray.doesIntersect(r,n,t.globalTransform.multiply(this.globalTransform.clone().invert()))},Object.defineProperty(r.prototype,"triList",{get:function(){return this._primTriArrayDirty&&(this.updateTriArray(),this._primTriArrayDirty=!1),this._primTriArray},enumerable:!0,configurable:!0}),r.prototype.updateTriArray=function(){null==this._primTriArray?this._primTriArray=new e.Tri2DArray(2):this._primTriArray.clear(2);var t=this.actualSize,r=new e.Vector2(0,0),n=new e.Vector2(t.width,t.height),i=new e.Vector2(0,t.height),o=new e.Vector2(t.width,0);this._primTriArray.storeTriangle(0,r,i,n),this._primTriArray.storeTriangle(1,r,n,o)},r.prototype.moveChild=function(t,r){if(t.parent!==this)return!1;var n=this._children.indexOf(t),i=r?this._children.indexOf(r):-1;return this._isFlagSet(e.SmartPropertyPrim.flagChildrenFlatZOrder)||(this._setFlags(e.SmartPropertyPrim.flagZOrderDirty),this._firstZDirtyIndex=Math.min(this._firstZDirtyIndex,i+1)),this._children.splice(i+1,0,this._children.splice(n,1)[0]),!0},r.prototype.moveChildToTop=function(e){return this.moveChild(e,this._children[this._children.length-1])},r.prototype.moveChildToBottom=function(e){return this.moveChild(e,null)},r.prototype.moveToTop=function(){return null!=this.parent&&this.parent.moveChildToTop(this)},r.prototype.moveToBottom=function(){return null!=this.parent&&this.parent.moveChildToBottom(this)},r.prototype.addChild=function(t){t._parent=this,this._boundingBoxDirty();var r=this._isFlagSet(e.SmartPropertyPrim.flagChildrenFlatZOrder);r?(t._setFlags(e.SmartPropertyPrim.flagChildrenFlatZOrder),t._setZOrder(this._zOrder,!0),t._zMax=this._zOrder):this._setFlags(e.SmartPropertyPrim.flagZOrderDirty);var n=this._children.push(t);this._firstZDirtyIndex=Math.min(this._firstZDirtyIndex,n-1)},r.prototype.dispose=function(){if(!t.prototype.dispose.call(this))return!1;if(this._isFlagSet(e.SmartPropertyPrim.flagCollisionActor)&&(this.owner._primitiveCollisionManager._removeActor(this),this._actorInfo=null),this._pointerEventObservable&&(this._pointerEventObservable.clear(),this._pointerEventObservable=null),this._actionManager&&(this._actionManager.dispose(),this._actionManager=null),this.owner.scene.stopAnimation(this),this._parent){if(this instanceof e.Group2D){var r=this;if(r.isRenderableGroup){var n=this.parent.traverseUp((function(t){return t instanceof e.Group2D&&t.isRenderableGroup}));if(null!=n){var i=n._renderableData._childrenRenderableGroups,o=i.indexOf(r);o!==-1&&i.splice(o,1)}}}var a=this._parent._children.indexOf(this);void 0!==a&&this._parent._children.splice(a,1),this._parent=null}if(this._children)for(;this._children.length>0;)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._prepareProcessStep<t&&(this._prepareRenderPre(e),this._prepareRenderPost(e),this._prepareProcessStep=t)},r.prototype._prepareRenderPre=function(e){},r.prototype._prepareRenderPost=function(t){if(this instanceof e.Group2D){var r=this;if(r.isRenderableGroup)return}this._children.length>0&&(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<n.length;r++){var i=n[r];i.updateCachedStates(t)}},r.prototype._parentLayoutDirty=function(){this._parent&&!this._parent.isDisposed&&this._parent._setLayoutDirty()},r.prototype._setLayoutDirty=function(){this.onPrimBecomesDirty(),this._setFlags(e.SmartPropertyPrim.flagLayoutDirty)},r.prototype._checkUseMargin=function(){return!(this instanceof e.Group2D&&null!=this.trackedNode)&&this._isFlagSet(e.SmartPropertyPrim.flagUsePositioning)},r.prototype._positioningDirty=function(){this._isFlagSet(e.SmartPropertyPrim.flagUsePositioning)&&(this.onPrimBecomesDirty(),this._setFlags(e.SmartPropertyPrim.flagPositioningDirty))},r.prototype._spreadActualOpacityChanged=function(){for(var t=0,r=this._children;t<r.length;t++){var n=r[t];n._setFlags(e.SmartPropertyPrim.flagActualOpacityDirty),n._updateRenderMode(),n.onPrimBecomesDirty(),n._spreadActualOpacityChanged()}},r.prototype._changeLayoutEngine=function(e){this._layoutEngine=e},r.prototype._updateLocalTransform=function(){var t=h.actualPositionProperty.flagId|h.rotationProperty.flagId|h.scaleProperty.flagId|h.scaleXProperty.flagId|h.scaleYProperty.flagId|h.originProperty.flagId;if(this.checkPropertiesDirty(t)||this._areSomeFlagsSet(e.SmartPropertyPrim.flagLocalTransformDirty|e.SmartPropertyPrim.flagPositioningDirty)){this.owner&&this.owner.addupdateLocalTransformCounter(1),
this._isFlagSet(e.SmartPropertyPrim.flagPositioningDirty)&&this._updatePositioning();var r,n=this._rotation,i=this._position?this.position:this.layoutAreaPos||h._v0,o=this._postScale,a=h._iv2,s=this._scale.multiplyByFloats(a.x,a.y);if(0===this._origin.x&&0===this._origin.y||this._hasMargin)r=e.Matrix2D.Compose(s,n,new e.Vector2(i.x+this._marginOffset.x,i.y+this._marginOffset.y)),this._localTransform=r,this._localLayoutTransform=e.Matrix2D.Compose(s,n,new e.Vector2(i.x,i.y));else{var l=h._t0,u=h._t1,c=h._t2,d=h._ts0;d.copyFrom(this.actualSize),e.Matrix2D.TranslationToRef(-d.width*this._origin.x,-d.height*this._origin.y,l),e.Matrix2D.RotationToRef(n,u),l.multiplyToRef(u,c),e.Matrix2D.ScalingToRef(this._scale.x,this._scale.y,l),c.multiplyToRef(l,u),e.Matrix2D.TranslationToRef(d.width*this._origin.x,d.height*this._origin.y,c),u.multiplyToRef(c,l),e.Matrix2D.ScalingToRef(o.x,o.y,u),l.multiplyToRef(u,c),e.Matrix2D.TranslationToRef(i.x+this._marginOffset.x,i.y+this._marginOffset.y,l),c.multiplyToRef(l,this._localTransform),this._localLayoutTransform=e.Matrix2D.Compose(s,n,i)}return this.clearPropertiesDirty(t),this._setFlags(e.SmartPropertyPrim.flagGlobalTransformDirty),this._clearFlags(e.SmartPropertyPrim.flagLocalTransformDirty),!0}return!1},r.prototype.updateCachedStates=function(t){if(this.isDisposed)return void e.C2DLogging.setPostMessage((function(){return"disposed"}));var r=this.owner._globalTransformProcessStep;if(this._updateCachesProcessStep!==r){this._updateCachesProcessStep=r,this.owner.addUpdateCachedStateCounter(1),this._parent&&(this._parent._globalTransformProcessStep!==this.owner._globalTransformProcessStep||this._parent._areSomeFlagsSet(e.SmartPropertyPrim.flagLayoutDirty|e.SmartPropertyPrim.flagPositioningDirty|e.SmartPropertyPrim.flagZOrderDirty))&&this._parent.updateCachedStates(!1),this._isFlagSet(e.SmartPropertyPrim.flagZOrderDirty)&&this._updateZOrder();var n=this.checkPropertiesDirty(h.sizeProperty.flagId);if(!this._isFlagSet(e.SmartPropertyPrim.flagLayoutDirty)&&!this._isFlagSet(e.SmartPropertyPrim.flagPositioningDirty)&&n){var i=this.size;this.onPropertyChanged("actualSize",i,i,h.actualSizeProperty.flagId),this.clearPropertiesDirty(h.sizeProperty.flagId)}var o=this._isFlagSet(e.SmartPropertyPrim.flagPositioningDirty),a=o&&!this._isFlagSet(e.SmartPropertyPrim.flagPositioningDirty);this._isFlagSet(e.SmartPropertyPrim.flagLayoutDirty)&&(this.owner.addUpdateLayoutCounter(1),this._layoutEngine.updateLayout(this),this._clearFlags(e.SmartPropertyPrim.flagLayoutDirty));var s=!1;if(this.isSizeAuto&&(s=this._lastAutoSizeArea?!this._lastAutoSizeArea.equals(this.actualSize):null!==this.actualSize),!a&&(s||n||this._isFlagSet(e.SmartPropertyPrim.flagPositioningDirty)||this._parent&&!this._parent.contentArea.equals(this._parentContentArea))&&(this._updatePositioning(),n&&this.clearPropertiesDirty(h.sizeProperty.flagId),a=!0),a&&this._parent&&this._parentContentArea.copyFrom(this._parent.contentArea),!this._globalTransform||this._globalTransformProcessStep!==this.owner._globalTransformProcessStep||this._areSomeFlagsSet(e.SmartPropertyPrim.flagGlobalTransformDirty)){this.owner.addUpdateGlobalTransformCounter(1);var l=this.isVisible;this.isVisible=(!this._parent||this._parent.isVisible)&&this.levelVisible,this._changeFlags(e.SmartPropertyPrim.flagVisibilityChanged,l!==this.isVisible);var u=this._updateLocalTransform(),c=!1,d=h._v0;this._parent&&(d=new e.Vector2(this._parent._paddingOffset.x,this._parent._paddingOffset.y),c=!d.equals(this._parentPaddingOffset));var p=null!=this._parent&&this._parent._globalTransformStep!==this._parentTransformStep;if(!this._globalTransform||u||p||c||this._areSomeFlagsSet(e.SmartPropertyPrim.flagGlobalTransformDirty)){var f=this._parent?this._parent._globalTransform:null,g=void 0;h._transMtx.copyFrom(this._localTransform),h._transMtx.m[4]+=d.x,h._transMtx.m[5]+=d.y,g=h._transMtx,this._globalTransform=this._parent?g.multiply(f):g.clone(),this._invGlobalTransform=e.Matrix2D.Invert(this._globalTransform),this._levelBoundingInfo.dirtyWorldAABB(),this._boundingInfo.dirtyWorldAABB(),this._globalTransformStep=this.owner._globalTransformProcessStep+1,this._parentTransformStep=this._parent?this._parent._globalTransformStep:0,this._clearFlags(e.SmartPropertyPrim.flagGlobalTransformDirty)}this._globalTransformProcessStep=this.owner._globalTransformProcessStep}if(t)for(var _=0,y=this._children;_<y.length;_++){var m=y[_];m.updateCachedStates(!(m instanceof e.Group2D&&m.isRenderableGroup))}}},r.prototype._updatePositioning=function(){if(!this._isFlagSet(e.SmartPropertyPrim.flagUsePositioning))return e.C2DLogging.setPostMessage((function(){return"Not using positioning engine"})),void this._clearFlags(e.SmartPropertyPrim.flagPositioningDirty);var t=!0;if(this._isFlagSet(e.SmartPropertyPrim.flagComputingPositioning))return this._actualSize||(this._actualSize=this.size.clone()||e.Size.Zero(),this._contentArea.copyFrom(this._actualSize)),this._actualPosition||(this._actualPosition=e.Vector2.Zero()),void e.C2DLogging.setPostMessage((function(){return"Re entrance detected"}));this.owner&&this.owner.addUpdatePositioningCounter(1),this._setFlags(e.SmartPropertyPrim.flagComputingPositioning);try{var r=this.isSizeAuto,n=this.isVerticalSizeAuto,o=this.isHorizontalSizeAuto,s=this._marginAlignment?this._marginAlignment.clone():new i,l=this._scale,u=this.size;!this._hasMarginAlignment&&r&&(u===h.nullSize||u===this._internalSize&&0===u.width&&0===u.height)&&((r||null==this.actualSize.width)&&(s.horizontal=i.AlignStretch),(r||null==this.actualSize.height)&&(s.vertical=i.AlignStretch));var c=h._size3,d=h._size4,p=this.boundingInfo;this._isFlagSet(e.SmartPropertyPrim.flagBoundingInfoDirty)&&(t=!1);var f=h._tbi;p.transformToRef(e.Matrix2D.Rotation(this.rotation),f),f.sizeToRef(c),p.sizeToRef(d),p.extent.subtractToRef(p.center,h._pv1),f.center.subtractToRef(f.extent,h._pv2);var g=h._pv2.add(h._pv1),_=!1,y=null!==this._margin&&!this._margin.isDefault||null!==s&&!s.isDefault,m=h._size,v=!1,b=!1,P=!1,C=this._hasPadding;if(y){var S=this.layoutArea;S&&s.horizontal===i.AlignStretch&&(this.margin.computeWithAlignment(S,u,s,l,this._marginOffset,m,!1,a.ComputeH),v=!0,_=!0),S&&s.vertical===i.AlignStretch&&(this.margin.computeWithAlignment(S,u,s,l,this._marginOffset,m,!1,a.ComputeV),b=!0,_=!0)}if(v||(o?(m.width=d.width,_=!0):m.width=u.width),b||(n?(m.height=d.height,_=!0):m.height=u.height),!n||!o){if(h._curContentArea.copyFrom(this._contentArea),C){var D=h._icArea,x=h._icZone;this._getInitialContentAreaToRef(m,x,D),D.width=Math.max(0,D.width),D.height=Math.max(0,D.height),this.padding.compute(D,this._paddingOffset,h._size2),o||(this._paddingOffset.x+=x.x,this._paddingOffset.z-=x.z,this._contentArea.width=h._size2.width),n||(this._paddingOffset.y+=x.y,this._paddingOffset.w-=x.w,this._contentArea.height=h._size2.height)}else this._contentArea.copyFrom(m);h._curContentArea.equals(this._contentArea)||this._setLayoutDirty(),P=!0}if(y){var S=this.layoutArea,A=this._marginOffset,O=this.margin;S&&S.width>=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;o<a.length;o++){var s=a[o];s._hierarchyDepth=this._hierarchyDepth+1,s._patchHierarchy(t)}}},r.prototype.onSetOwner=function(){},r.prototype._updateZOrder=function(){var t=this._primLinearPosition,r=0,n=this._zOrder,i=this._children.length;if(this._firstZDirtyIndex>0&&this._firstZDirtyIndex-1<i){var o=this._children[this._firstZDirtyIndex-1];t=o._primLinearPosition,r=this._firstZDirtyIndex-1,n=o._zOrder}var a=t;h._totalCount=0;for(var s=r;s<i;s++){var l=this._children[s];t=l._updatePrimitiveLinearPosition(t)}var u=(this._zMax-n)/(h._totalCount*(h._zRebuildReentrency?1:1.2));if(u<e.Canvas2D._zMinDelta){if(h._zRebuildReentrency){var c=this._parent;return null==c?(console.log("Can't compute Z-Order for "+this.id+"'s children, zDelta is too small, Z-Order is now in an unstable state"),void(h._zRebuildReentrency=!1)):(c._firstZDirtyIndex=0,c._updateZOrder())}h._zRebuildReentrency=!0,this._firstZDirtyIndex=0,this._updateZOrder(),h._zRebuildReentrency=!1}for(var s=r;s<i;s++){var l=this._children[s];l._updatePrimitiveZOrder(a,n,u)}for(var d=0,p=h._zOrderChangedNotifList;d<p.length;d++){var c=p[d];c._actualZOrderChangedObservable.notifyObservers(c.actualZOffset)}h._zOrderChangedNotifList.splice(0),this._firstZDirtyIndex=h._bigInt,this._clearFlags(e.SmartPropertyPrim.flagZOrderDirty)},r.prototype._updatePrimitiveLinearPosition=function(t){if(this.isManualZOrder)return t;if(this._primLinearPosition=++t,h._totalCount++,!this._isFlagSet(e.SmartPropertyPrim.flagChildrenFlatZOrder))for(var r=0,n=this._children;r<n.length;r++){var i=n[r];t=i._updatePrimitiveLinearPosition(t)}return t},r.prototype._updatePrimitiveZOrder=function(t,r,n){if(this.isManualZOrder)return null;var i=r+(this._primLinearPosition-t)*n,o=this._isFlagSet(e.SmartPropertyPrim.flagChildrenFlatZOrder);this._setZOrder(i,!1),this._isFlagSet(e.SmartPropertyPrim.flagZOrderDirty)&&(this._firstZDirtyIndex=h._bigInt,this._clearFlags(e.SmartPropertyPrim.flagZOrderDirty));var a=i;if(o){if(this._children.length>0)for(var s=0,l=this._children;s<l.length;s++){var u=l[s];u._updatePrimitiveFlatZOrder(this._zOrder)}}else for(var c=0,d=this._children;c<d.length;c++){var u=d[c],p=u._updatePrimitiveZOrder(t,r,n);null!=p&&(a=p)}return this._zMax=o?i:a+n,a},r.prototype._updatePrimitiveFlatZOrder=function(t){if(!this.isManualZOrder){this._setZOrder(t,!1),this._zMax=t,this._isFlagSet(e.SmartPropertyPrim.flagZOrderDirty)&&(this._firstZDirtyIndex=h._bigInt,this._clearFlags(e.SmartPropertyPrim.flagZOrderDirty));for(var r=0,n=this._children;r<n.length;r++){var i=n[r];i._updatePrimitiveFlatZOrder(t)}}},r.prototype._setZOrder=function(e,t){e!==this._zOrder&&(this._zOrder=e,this.onPrimBecomesDirty(),this.onZOrderChanged(),this._actualZOrderChangedObservable&&this._actualZOrderChangedObservable.hasObservers()&&(t?this._actualZOrderChangedObservable.notifyObservers(e):h._zOrderChangedNotifList.push(this)))},r.prototype._updateRenderMode=function(){},r.prototype._getInitialContentAreaToRef=function(e,t,r){r.copyFrom(e),t.x=t.y=t.z=t.w=0},r.prototype._getActualSizeFromContentToRef=function(e,t,r){r.copyFrom(e)},Object.defineProperty(r.prototype,"layoutData",{get:function(){return this._layoutData},set:function(e){this._layoutData!==e&&(this._layoutData=e)},enumerable:!0,configurable:!0}),r})(e.SmartPropertyPrim);l.PRIM2DBASE_PROPCOUNT=25,l._bigInt=Math.pow(2,30),l._nullPosition=e.Vector2.Zero(),l._nullSize=e.Size.Zero(),l.boundinbBoxReentrency=-1,l.nullSize=e.Size.Zero(),l._bMinMax=e.Vector4.Zero(),l._bMax=e.Vector2.Zero(),l._bSize=e.Size.Zero(),l._tpsBB=new e.BoundingInfo2D,l._tpsBB2=new e.BoundingInfo2D,l._updatingDebugArea=!1,l._bypassGroup2DExclusion=!1,l._isCanvasInit=!1,l._t0=new e.Matrix2D,l._t1=new e.Matrix2D,l._t2=new e.Matrix2D,l._v0=e.Vector2.Zero(),l._v30=e.Vector3.Zero(),l._iv2=new e.Vector2(1,1),l._ts0=e.Size.Zero(),l._transMtx=e.Matrix2D.Zero(),l._icPos=e.Vector2.Zero(),l._icZone=e.Vector4.Zero(),l._icArea=e.Size.Zero(),l._size=e.Size.Zero(),l._size2=e.Size.Zero(),l._size3=e.Size.Zero(),l._size4=e.Size.Zero(),l._pv0=e.Vector2.Zero(),l._curContentArea=e.Size.Zero(),l._piv=new e.Vector2(1,1),l._tbi=new e.BoundingInfo2D,l._pv1=e.Vector2.Zero(),l._pv2=e.Vector2.Zero(),l._zOrderChangedNotifList=new Array,l._zRebuildReentrency=!1,l._totalCount=0,__decorate([e.logProp(null,!1,!1,!1),e.instanceLevelProperty(1,(function(e){return h.actualPositionProperty=e}),!1,!1,!0)],l.prototype,"actualPosition",null),__decorate([e.instanceLevelProperty(e.SmartPropertyPrim.SMARTPROPERTYPRIM_PROPCOUNT+1,(function(e){return h.actualXProperty=e}),!1,!1,!0)],l.prototype,"actualX",null),__decorate([e.instanceLevelProperty(e.SmartPropertyPrim.SMARTPROPERTYPRIM_PROPCOUNT+2,(function(e){return h.actualYProperty=e}),!1,!1,!0)],l.prototype,"actualY",null),__decorate([e.dynamicLevelProperty(e.SmartPropertyPrim.SMARTPROPERTYPRIM_PROPCOUNT+3,(function(e){return h.positionProperty=e}),!1,!1,!0)],l.prototype,"position",null),__decorate([e.dynamicLevelProperty(e.SmartPropertyPrim.SMARTPROPERTYPRIM_PROPCOUNT+4,(function(e){return h.xProperty=e}),!1,!1,!0)],l.prototype,"x",null),__decorate([e.dynamicLevelProperty(e.SmartPropertyPrim.SMARTPROPERTYPRIM_PROPCOUNT+5,(function(e){return h.yProperty=e}),!1,!1,!0)],l.prototype,"y",null),__decorate([e.logProp(),e.dynamicLevelProperty(e.SmartPropertyPrim.SMARTPROPERTYPRIM_PROPCOUNT+6,(function(e){return h.sizeProperty=e}),!1,!0)],l.prototype,"size",null),__decorate([e.logMethod()],l.prototype,"internalGetSize",null),__decorate([e.logMethod()],l.prototype,"internalSetSize",null),__decorate([e.logProp(),e.dynamicLevelProperty(e.SmartPropertyPrim.SMARTPROPERTYPRIM_PROPCOUNT+7,(function(e){return h.widthProperty=e}),!1,!0)],l.prototype,"width",null),__decorate([e.logProp(),e.dynamicLevelProperty(e.SmartPropertyPrim.SMARTPROPERTYPRIM_PROPCOUNT+8,(function(e){return h.heightProperty=e}),!1,!0)],l.prototype,"height",null),__decorate([e.logProp(),e.instanceLevelProperty(e.SmartPropertyPrim.SMARTPROPERTYPRIM_PROPCOUNT+9,(function(e){return h.rotationProperty=e}),!1,!0)],l.prototype,"rotation",null),__decorate([e.logProp(),e.instanceLevelProperty(e.SmartPropertyPrim.SMARTPROPERTYPRIM_PROPCOUNT+10,(function(e){return h.scaleProperty=e}),!1,!0)],l.prototype,"scale",null),__decorate([e.logProp(),e.dynamicLevelProperty(e.SmartPropertyPrim.SMARTPROPERTYPRIM_PROPCOUNT+11,(function(e){return h.actualSizeProperty=e}),!1,!0)],l.prototype,"actualSize",null),__decorate([e.dynamicLevelProperty(e.SmartPropertyPrim.SMARTPROPERTYPRIM_PROPCOUNT+12,(function(e){return h.actualWidthProperty=e}),!1,!0)],l.prototype,"actualWidth",null),__decorate([e.dynamicLevelProperty(e.SmartPropertyPrim.SMARTPROPERTYPRIM_PROPCOUNT+13,(function(e){return h.actualHeightProperty=e}),!1,!0)],l.prototype,"actualHeight",null),__decorate([e.dynamicLevelProperty(e.SmartPropertyPrim.SMARTPROPERTYPRIM_PROPCOUNT+14,(function(e){return h.originProperty=e}),!1,!0)],l.prototype,"origin",null),__decorate([e.dynamicLevelProperty(e.SmartPropertyPrim.SMARTPROPERTYPRIM_PROPCOUNT+15,(function(e){return h.levelVisibleProperty=e}))],l.prototype,"levelVisible",null),__decorate([e.instanceLevelProperty(e.SmartPropertyPrim.SMARTPROPERTYPRIM_PROPCOUNT+16,(function(e){return h.isVisibleProperty=e}))],l.prototype,"isVisible",null),__decorate([e.instanceLevelProperty(e.SmartPropertyPrim.SMARTPROPERTYPRIM_PROPCOUNT+17,(function(e){return h.zOrderProperty=e}))],l.prototype,"zOrder",null),__decorate([e.dynamicLevelProperty(e.SmartPropertyPrim.SMARTPROPERTYPRIM_PROPCOUNT+18,(function(e){return h.marginProperty=e}))],l.prototype,"margin",null),__decorate([e.dynamicLevelProperty(e.SmartPropertyPrim.SMARTPROPERTYPRIM_PROPCOUNT+19,(function(e){return h.paddingProperty=e}))],l.prototype,"padding",null),__decorate([e.dynamicLevelProperty(e.SmartPropertyPrim.SMARTPROPERTYPRIM_PROPCOUNT+20,(function(e){return h.marginAlignmentProperty=e}))],l.prototype,"marginAlignment",null),__decorate([e.instanceLevelProperty(e.SmartPropertyPrim.SMARTPROPERTYPRIM_PROPCOUNT+21,(function(e){return h.opacityProperty=e}))],l.prototype,"opacity",null),__decorate([e.instanceLevelProperty(e.SmartPropertyPrim.SMARTPROPERTYPRIM_PROPCOUNT+22,(function(e){return h.scaleXProperty=e}),!1,!0)],l.prototype,"scaleX",null),__decorate([e.instanceLevelProperty(e.SmartPropertyPrim.SMARTPROPERTYPRIM_PROPCOUNT+23,(function(e){return h.scaleYProperty=e}),!1,!0)],l.prototype,"scaleY",null),__decorate([e.instanceLevelProperty(e.SmartPropertyPrim.SMARTPROPERTYPRIM_PROPCOUNT+24,(function(e){return h.actualScaleProperty=e}),!1,!0)],l.prototype,"actualScale",null),__decorate([e.logProp("",!0)],l.prototype,"boundingInfo",null),__decorate([e.logProp("",!0)],l.prototype,"layoutBoundingInfo",null),__decorate([e.logMethod("",!0)],l.prototype,"_setLayoutDirty",null),__decorate([e.logMethod("",!0)],l.prototype,"_positioningDirty",null),__decorate([e.logMethod()],l.prototype,"updateCachedStates",null),__decorate([e.logMethod()],l.prototype,"_updatePositioning",null),l=h=__decorate([e.className("Prim2DBase","BABYLON")],l),e.Prim2DBase=l;var u,c,h})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,r,n){this._partCount=n,this._primCount=0,this.owner=t,this.modelRenderCache=r,this.modelRenderCache.addRef(),this.partIndexFromId=new e.StringDictionary,this._usedShaderCategories=new Array(n),this._strides=new Array(n),this._opaqueData=null,this._alphaTestData=null,this._transparentData=null,this.opaqueDirty=this.alphaTestDirty=this.transparentDirty=this.transparentOrderDirty=!1}return t.prototype.incPrimCount=function(){++this._primCount},t.prototype.dispose=function(){if(this._isDisposed)return!1;if(--this._primCount,this._primCount>0)return!1;this.owner._renderableData._renderGroupInstancesInfo.remove(this.modelRenderCache.modelKey),this.modelRenderCache&&(this.modelRenderCache.dispose(),this.modelRenderCache=null);var e=this.owner.owner.engine;return this._opaqueData&&(this._opaqueData.forEach((function(t){return t.dispose(e)})),this._opaqueData=null),this._alphaTestData&&(this._alphaTestData.forEach((function(t){return t.dispose(e)})),this._alphaTestData=null),this._transparentData&&(this._transparentData.forEach((function(t){return t.dispose(e)})),this._transparentData=null),this.partIndexFromId=null,this._isDisposed=!0,!0},Object.defineProperty(t.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasOpaqueData",{get:function(){return null!=this._opaqueData},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasAlphaTestData",{get:function(){return null!=this._alphaTestData},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasTransparentData",{get:function(){return null!=this._transparentData},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"opaqueData",{get:function(){if(!this._opaqueData){this._opaqueData=new Array(this._partCount);for(var e=0;e<this._partCount;e++)this._opaqueData[e]=new n(this._strides[e])}return this._opaqueData},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"alphaTestData",{get:function(){if(!this._alphaTestData){this._alphaTestData=new Array(this._partCount);for(var e=0;e<this._partCount;e++)this._alphaTestData[e]=new n(this._strides[e])}return this._alphaTestData},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"transparentData",{get:function(){if(!this._transparentData){this._transparentData=new Array(this._partCount);for(var e=0;e<this._partCount;e++){var t=this.modelRenderCache._partData[e]._zBiasOffset;this._transparentData[e]=new i(this._strides[e],t)}}return this._transparentData},enumerable:!0,configurable:!0}),t.prototype.sortTransparentData=function(){if(this.transparentOrderDirty){for(var e=0;e<this._transparentData.length;e++){var t=this._transparentData[e];t._partData.sort()}this.transparentOrderDirty=!1}},Object.defineProperty(t.prototype,"usedShaderCategories",{get:function(){return this._usedShaderCategories},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"strides",{get:function(){return this._strides},enumerable:!0,configurable:!0}),t})();e.GroupInstanceInfo=t;var r=(function(){function t(){this.groupInsanceInfo=null,this.startZ=0,this.endZ=0,this.startDataIndex=e.Prim2DBase._bigInt,this.endDataIndex=0,this.partBuffers=null}return t.prototype.dispose=function(e){this.partBuffers&&(this.partBuffers.forEach((function(t){return e._releaseBuffer(t)})),this.partBuffers.splice(0),this.partBuffers=null)},t})();e.TransparentSegment=r;var n=(function(){function t(t){this._partData=null,this._partBuffer=null,this._partBufferSize=0,this._partData=new e.DynamicFloatArray(t/4,50),this._isDisposed=!1}return t.prototype.dispose=function(e){return!this._isDisposed&&(this._partBuffer&&(e._releaseBuffer(this._partBuffer),this._partBuffer=null),this._partData=null,void(this._isDisposed=!0))},t})();e.GroupInfoPartData=n;var i=(function(e){function t(t,r){var n=e.call(this,t)||this;return n._partData.compareValueOffset=r,n._partData.sortingAscending=!1,n}return __extends(t,e),t})(n);e.TransparentGroupInfoPartData=i;var o=(function(){function e(e,t){this._engine=e,this._modelKey=t,this._nextKey=1,this._refCounter=1,this._partData=null}return e.prototype.dispose=function(){if(0!==--this._refCounter)return!1;var e=this._engine.getExternalData("__BJSCANVAS2D__");return e&&e.DisposeModelRenderCache(this),!0},Object.defineProperty(e.prototype,"isDisposed",{get:function(){return this._refCounter<=0},enumerable:!0,configurable:!0}),e.prototype.addRef=function(){return++this._refCounter},Object.defineProperty(e.prototype,"modelKey",{get:function(){return this._modelKey},enumerable:!0,configurable:!0}),e.prototype.updateModelRenderCache=function(e){return!1},e.prototype.render=function(e,t){return!0},e.prototype.getPartIndexFromId=function(e){for(var t=0;t<this._partData.length;t++)if(this._partData[t]._partId===e)return t;return null},e.prototype.loadInstancingAttributes=function(e,t){var r=this.getPartIndexFromId(e);if(null===r)return null;var n=this._partsClassInfo[r],i=this._partData[r]._partUsedCategories,o=n.classContent.getInstancingAttributeInfos(t,i);return o},e.prototype.setupUniforms=function(t,r,n,i){var o=this._partData[r],a=o._partDataStride/4*i,s=this._partsClassInfo[r];s.fullContent.forEach((function(r,i){if(!i.category||o._partUsedCategories.indexOf(i.category)!==-1)switch(i.dataType){case 3:var s=i.instanceOffset.get(o._partJoinedUsedCategories);t.setFloat(i.attributeName,n.buffer[a+s]);break;case 0:var s=i.instanceOffset.get(o._partJoinedUsedCategories);e.v2.x=n.buffer[a+s+0],e.v2.y=n.buffer[a+s+1],t.setVector2(i.attributeName,e.v2);break;case 4:case 1:var s=i.instanceOffset.get(o._partJoinedUsedCategories);e.v3.x=n.buffer[a+s+0],e.v3.y=n.buffer[a+s+1],e.v3.z=n.buffer[a+s+2],t.setVector3(i.attributeName,e.v3);break;case 5:case 2:var s=i.instanceOffset.get(o._partJoinedUsedCategories);e.v4.x=n.buffer[a+s+0],e.v4.y=n.buffer[a+s+1],e.v4.z=n.buffer[a+s+2],e.v4.w=n.buffer[a+s+3],t.setVector4(i.attributeName,e.v4)}}))},e})();o.v2=e.Vector2.Zero(),o.v3=e.Vector3.Zero(),o.v4=e.Vector4.Zero(),e.ModelRenderCache=o;var a=(function(){function e(){}return e})();e.ModelRenderCachePartData=a})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){function t(t,i){return function(o,a,s){var l=e.ClassTreeInfo.getOrRegister(o,(function(e){return new r(e)})),u=l.getLevelOf(o),c=a;i=i||c;var h=u.levelContent.get(c);if(h)throw new Error("The ID "+c+" is already taken by another instance data");h=new n,h.attributeName=i,h.category=t||null,h.category&&(h.delimitedCategory=";"+h.category+";"),u.levelContent.add(c,h),s.get=function(){return null},s.set=function(e){if(!h.category||r._CurCategories.indexOf(h.delimitedCategory)!==-1){var t;h.curCategory===r._CurCategories?t=h.curCategoryOffset:(h.size?h.instanceOffset.contains(r._CurCategories)||u.classContent.mapProperty(h,!1):(h.setSize(e),u.classContent.mapProperty(h,!0)),t=h.instanceOffset.get(r._CurCategories),h.curCategory=r._CurCategories,h.curCategoryOffset=t);var n=this;if(n.dataBuffer&&n.dataElements){var i=n.dataElements[n.curElement].offset+t;h.writeData(n.dataBuffer.buffer,i,e)}}}}}var r=(function(){function t(t){this._baseInfo=t,this._nextOffset=new e.StringDictionary,this._attributes=new Array}return t.prototype.mapProperty=function(e,r){var n=this._nextOffset.getOrAdd(t._CurCategories,0);e.instanceOffset.add(t._CurCategories,this._getBaseOffset(t._CurCategories)+n),this._nextOffset.set(t._CurCategories,n+e.size/4),r&&this._attributes.push(e)},t.prototype.getInstancingAttributeInfos=function(t,r){for(var n=";"+r.join(";")+";",i=new Array,o=this;o;){for(var a=0,s=o._attributes;a<s.length;a++){var l=s[a];if(!l.category||r.indexOf(l.category)!==-1){var u=t.getAttributeLocationByName(l.attributeName);if(u===-1)throw new Error("Attribute "+l.attributeName+" was not found in Effect: "+t.name+". It's certainly no longer used in the Effect's Shaders");var c=new e.InstancingAttributeInfo;c.index=u,c.attributeSize=l.size/4,c.offset=4*l.instanceOffset.get(n),c.attributeName=l.attributeName,i.push(c)}}o=o._baseInfo}return i},t.prototype.getShaderAttributes=function(e){for(var t=new Array,r=this;r;){for(var n=0,i=r._attributes;n<i.length;n++){var o=i[n];o.category&&e.indexOf(o.category)===-1||t.push(o.attributeName)}r=r._baseInfo}return t},t.prototype._getBaseOffset=function(e){for(var t=0,r=this._baseInfo;r;)t+=r._nextOffset.getOrAdd(e,0),r=r._baseInfo;return t},t})();e.InstanceClassInfo=r;var n=(function(){function t(){this.attributeName=null,this.category=null,this.size=null,this.instanceOffset=new e.StringDictionary,this.dataType=0,this.curCategory="",this.curCategoryOffset=0}return t.prototype.setSize=function(t){if(t instanceof e.Vector2)return this.size=8,void(this.dataType=0);if(t instanceof e.Vector3)return this.size=12,void(this.dataType=1);if(t instanceof e.Vector4)return this.size=16,void(this.dataType=2);if(t instanceof e.Matrix2D)throw new Error("Matrix2D type is not supported by WebGL Instance Buffer, you have to use four Vector4 properties instead");return"number"==typeof t?(this.size=4,void(this.dataType=3)):t instanceof e.Color3?(this.size=12,void(this.dataType=4)):t instanceof e.Color4?(this.size=16,void(this.dataType=5)):t instanceof e.Size?(this.size=8,void(this.dataType=6)):void 0},t.prototype.writeData=function(e,t,r){switch(this.dataType){case 0:var n=r;e[t+0]=n.x,e[t+1]=n.y;break;case 1:var n=r;e[t+0]=n.x,e[t+1]=n.y,e[t+2]=n.z;break;case 2:var n=r;e[t+0]=n.x,e[t+1]=n.y,e[t+2]=n.z,e[t+3]=n.w;break;case 4:var n=r;e[t+0]=n.r,e[t+1]=n.g,e[t+2]=n.b;break;case 5:var n=r;e[t+0]=n.r,e[t+1]=n.g,e[t+2]=n.b,e[t+3]=n.a;break;case 3:var n=r;e[t]=n;break;case 6:var i=r;e[t+0]=i.width,e[t+1]=i.height}},t})();e.InstancePropInfo=n,e.instanceData=t;var i=(function(){function t(e,t){this.id=e,this.curElement=0,this._dataElementCount=t,this.renderMode=0,this.arrayLengthChanged=!1}return Object.defineProperty(t.prototype,"zBias",{get:function(){return null},set:function(e){},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"transformX",{get:function(){return null},set:function(e){},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"transformY",{get:function(){return null},set:function(e){},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"renderingInfo",{get:function(){return null},set:function(e){},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"opacity",{get:function(){return null},set:function(e){},enumerable:!0,configurable:!0}),t.prototype.getClassTreeInfo=function(){return this.typeInfo||(this.typeInfo=e.ClassTreeInfo.get(Object.getPrototypeOf(this))),this.typeInfo},t.prototype.allocElements=function(){if(this.dataBuffer&&!this.dataElements){for(var e=new Array(this.dataElementCount),t=0;t<this.dataElementCount;t++)e[t]=this.dataBuffer.allocElement();this.dataElements=e}},t.prototype.freeElements=function(){if(this.dataElements){for(var e=0,t=this.dataElements;e<t.length;e++){var r=t[e];this.dataBuffer.freeElement(r)}this.dataElements=null}},Object.defineProperty(t.prototype,"dataElementCount",{get:function(){return this._dataElementCount},set:function(e){e!==this._dataElementCount&&(this.arrayLengthChanged=!0,this.freeElements(),this._dataElementCount=e,this.allocElements())},enumerable:!0,configurable:!0}),t})();__decorate([t()],i.prototype,"zBias",null),__decorate([t()],i.prototype,"transformX",null),__decorate([t()],i.prototype,"transformY",null),__decorate([t()],i.prototype,"renderingInfo",null),__decorate([t()],i.prototype,"opacity",null),e.InstanceDataBase=i;var o=a=(function(t){function n(e){var r=t.call(this,e)||this;return r._transparentPrimitiveInfo=null,r}return __extends(n,t),Object.defineProperty(n.prototype,"isAlphaTest",{get:function(){return this._useTextureAlpha()||this._isPrimAlphaTest()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isTransparent",{get:function(){return this.actualOpacity<1||this._shouldUseAlphaFromTexture()||this._isPrimTransparent()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"renderMode",{get:function(){return this._renderMode},enumerable:!0,configurable:!0}),n.prototype.dispose=function(){return!!t.prototype.dispose.call(this)&&(this.renderGroup&&this.renderGroup._setCacheGroupDirty(),this._transparentPrimitiveInfo&&(this.renderGroup._renderableData.removeTransparentPrimitiveInfo(this._transparentPrimitiveInfo),this._transparentPrimitiveInfo=null),this._instanceDataParts&&this._cleanupInstanceDataParts(),this._modelRenderCache&&(this._modelRenderCache.dispose(),this._modelRenderCache=null),this._instanceDataParts&&(this._instanceDataParts.forEach((function(e){e.freeElements()})),this._instanceDataParts=null),!0)},n.prototype._cleanupInstanceDataParts=function(){for(var e=null,t=0,r=this._instanceDataParts;t<r.length;t++){var n=r[t];n.freeElements(),e=n.groupInstanceInfo,n.groupInstanceInfo=null}e&&(e.hasOpaqueData&&(e.opaqueDirty=!0),e.hasAlphaTestData&&(e.alphaTestDirty=!0),e.hasTransparentData&&(e.transparentDirty=!0),e.dispose(),this._modelRenderCache&&(this._modelRenderCache.dispose(),this._modelRenderCache=null)),this._instanceDataParts=null},n.prototype._prepareRenderPre=function(r){t.prototype._prepareRenderPre.call(this,r),this._isFlagSet(e.SmartPropertyPrim.flagModelDirty)&&this._instanceDataParts&&this._cleanupInstanceDataParts();var n=!1;this._modelRenderCache&&!this._isFlagSet(e.SmartPropertyPrim.flagModelDirty)||(n=this._createModelRenderCache());var i=null,o=!1;this._instanceDataParts||(o=!0,i=this._createModelDataParts()),n&&this.setupModelRenderCache(this._modelRenderCache),this._isFlagSet(e.SmartPropertyPrim.flagModelUpdate)&&this._modelRenderCache.updateModelRenderCache(this)&&this._clearFlags(e.SmartPropertyPrim.flagModelUpdate),(this._areSomeFlagsSet(e.SmartPropertyPrim.flagVisibilityChanged|e.SmartPropertyPrim.flagNeedRefresh)||r.forceRefreshPrimitive||o||0!==this._instanceDirtyFlags||this._globalTransformProcessStep!==this._globalTransformStep||this._mustUpdateInstance())&&this._updateInstanceDataParts(i);
},n.prototype._createModelRenderCache=function(){var t=this,r=!1;return this._modelRenderCache&&this._modelRenderCache.dispose(),this._modelRenderCache=this.owner._engineData.GetOrAddModelCache(this.modelKey,(function(e){var n=t.createModelRenderCache(e);return r=!0,n})),this._clearFlags(e.SmartPropertyPrim.flagModelDirty),r||this._modelRenderCache.addRef(),r},n.prototype._createModelDataParts=function(){var t=this,r=this.createInstanceDataParts();this._instanceDataParts=r,this._modelRenderCache._partData||this._setupModelRenderCache(r);var n=this.renderGroup._renderableData._renderGroupInstancesInfo.getOrAddWithFactory(this.modelKey,(function(r){for(var n=new e.GroupInstanceInfo(t.renderGroup,t._modelRenderCache,t._modelRenderCache._partData.length),i=0;i<t._modelRenderCache._partData.length;i++){var o=t._instanceDataParts[i];n.partIndexFromId.add(o.id.toString(),i),n.usedShaderCategories[i]=";"+t.getUsedShaderCategories(o).join(";")+";",n.strides[i]=t._modelRenderCache._partData[i]._partDataStride}return n})),i=0,o=null;this.isTransparent?(o=n.transparentData,i=e.Render2DContext.RenderModeTransparent):this.isAlphaTest?(o=n.alphaTestData,i=e.Render2DContext.RenderModeAlphaTest):(o=n.opaqueData,i=e.Render2DContext.RenderModeOpaque);for(var a=0;a<r.length;a++){var s=r[a];s.dataBuffer=o[a]._partData,s.allocElements(),s.renderMode=i,s.groupInstanceInfo=n}return n.incPrimCount(),n},n.prototype._setupModelRenderCache=function(t){var n=new Array;this._modelRenderCache._partData=new Array;for(var i=0,o=t;i<o.length;i++){var a=o[i],s=new e.ModelRenderCachePartData;this._modelRenderCache._partData.push(s);var l=this.getUsedShaderCategories(a),u=a.getClassTreeInfo(),c=this.isVisible;this.isVisible=!0;var h=";"+l.join(";")+";";s._partJoinedUsedCategories=h,r._CurCategories=h;var d=this.beforeRefreshForLayoutConstruction(a);this.refreshInstanceDataPart(a)||console.log("Layout construction for "+e.Tools.getClassName(this._instanceDataParts[0])+" failed because refresh returned false"),this.afterRefreshForLayoutConstruction(a,d),this.isVisible=c;var p=0;u.fullContent.forEach((function(t,r){r.category&&l.indexOf(r.category)===-1||("zBias"===r.attributeName&&(s._zBiasOffset=r.instanceOffset.get(h)),r.size?p+=r.size:console.log("ERROR: Couldn't detect the size of the Property "+r.attributeName+" from type "+e.Tools.getClassName(u.type)+". Property is ignored."))})),s._partDataStride=p,s._partUsedCategories=l,s._partId=a.id,n.push(u)}this._modelRenderCache._partsClassInfo=n},n.prototype.onZOrderChanged=function(){if(this.isTransparent&&this._transparentPrimitiveInfo){this.renderGroup._renderableData.transparentPrimitiveZChanged(this._transparentPrimitiveInfo);var e=this.renderGroup._renderableData._renderGroupInstancesInfo.get(this.modelKey);e.transparentOrderDirty=!0}},n.prototype._mustUpdateInstance=function(){return!1},n.prototype._useTextureAlpha=function(){return!1},n.prototype._shouldUseAlphaFromTexture=function(){return!1},n.prototype._isPrimAlphaTest=function(){return!1},n.prototype._isPrimTransparent=function(){return!1},n.prototype._updateInstanceDataParts=function(t){var n=this.renderGroup._renderableData;if(t||(t=n._renderGroupInstancesInfo.get(this.modelKey)),!t.isDisposed){var i=this.isTransparent,o=this.isAlphaTest,a=!1,s=!1;if(this._instanceDataParts.length>0){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;d<this._instanceDataParts.length;d++){var p=this._instanceDataParts[d];p.freeElements(),p.dataBuffer=h[d]._partData,p.renderMode=c}}}var f=this._isFlagSet(e.SmartPropertyPrim.flagVisibilityChanged);(i||a)&&(f||s)&&(this.isVisible&&!a?this._transparentPrimitiveInfo||(this._transparentPrimitiveInfo=n.addNewTransparentPrimitiveInfo(this,t)):this._transparentPrimitiveInfo&&(n.removeTransparentPrimitiveInfo(this._transparentPrimitiveInfo),this._transparentPrimitiveInfo=null),t.transparentOrderDirty=!0);for(var g=!1,_=0,y=this._instanceDataParts;_<y.length;_++){var p=y[_],m=!1;!p.dataElements&&(f||s||this.isVisible)&&(p.allocElements(),m=!0),r._CurCategories=t.usedShaderCategories[t.partIndexFromId.get(p.id.toString())],p.arrayLengthChanged=!1,this.refreshInstanceDataPart(p)||(p.dataElements&&p.freeElements(),this.isVisible&&n._primNewDirtyList.push(this)),g=g||p.arrayLengthChanged||m}this._instanceDirtyFlags=0,i?(t.transparentDirty=!0,g&&(n._transparentListChanged=!0)):o?t.alphaTestDirty=!0:t.opaqueDirty=!0,this._clearFlags(e.SmartPropertyPrim.flagVisibilityChanged)}},n.prototype._updateTransparentSegmentIndices=function(t){for(var r=e.Prim2DBase._bigInt,n=0,i=0,o=this._instanceDataParts;i<o.length;i++){var a=o[i];if(a&&a.dataElements){a.dataBuffer.pack();for(var s=0,l=a.dataElements;s<l.length;s++){var u=l[s];r=Math.min(r,u.offset),n=Math.max(n,u.offset)}t.startDataIndex=Math.min(t.startDataIndex,r/a.dataBuffer.stride),t.endDataIndex=Math.max(t.endDataIndex,n/a.dataBuffer.stride+1)}}},n.prototype._getNextPrimZOrder=function(){for(var e=this._instanceDataParts.length,t=0;t<e;t++){var r=this._instanceDataParts[t];if(r){var n=r.dataBuffer.stride,i=r.dataElements[r.dataElements.length-1].offset;return r.dataBuffer.totalElementCount*n<=i?null:r.dataBuffer[i+n+this.modelRenderCache._partData[t]._zBiasOffset]}}return null},n.prototype._getPrevPrimZOrder=function(){for(var e=this._instanceDataParts.length,t=0;t<e;t++){var r=this._instanceDataParts[t];if(r){var n=r.dataBuffer.stride,i=r.dataElements[0].offset;return 0===i?null:r.dataBuffer[i-n+this.modelRenderCache._partData[t]._zBiasOffset]}}return null},n.prototype.getDataPartEffectInfo=function(t,r,n,i){void 0===n&&(n=null),void 0===i&&(i=null);var o=e.Tools.first(this._instanceDataParts,(function(e){return e.id===t}));if(!o)return null;var a=this.owner.supportInstancedArray;if(null!=i){if(i&&a===!1)return null;a=i}var s=o.getClassTreeInfo(),l=this.getUsedShaderCategories(o),u=s.classContent.getShaderAttributes(l),c="";return l.forEach((function(e){c+="#define "+e+"\n"})),a&&(c+="#define Instanced\n"),{attributes:a?r.concat(u):r,uniforms:a?null!=n?n:[]:null!=n?u.concat(n):null!=u?u:[],defines:c}},Object.defineProperty(n.prototype,"modelRenderCache",{get:function(){return this._modelRenderCache},enumerable:!0,configurable:!0}),n.prototype.createModelRenderCache=function(e){return null},n.prototype.setupModelRenderCache=function(e){},n.prototype.createInstanceDataParts=function(){return null},n.prototype.getUsedShaderCategories=function(e){return[]},n.prototype.beforeRefreshForLayoutConstruction=function(e){},n.prototype.afterRefreshForLayoutConstruction=function(e,t){},n.prototype.applyActualScaleOnTransform=function(){return!0},n.prototype.refreshInstanceDataPart=function(e){return!!this.isVisible&&(e.isVisible=this.isVisible,1===e.dataElementCount&&(e.curElement=0,this.updateInstanceDataPart(e)),!0)},n.prototype.updateInstanceDataPart=function(t,r){void 0===r&&(r=null);var n=this._globalTransform.multiply(this.renderGroup.invGlobalTransform),i=a._s,o=a._t,s=n.decompose(i,o),l=this.actualScale,u=this.owner._canvasLevelScale;i.x=l.x*u.x*this._postScale.x,i.y=l.y*u.y*this._postScale.y,o.multiplyInPlace(u),n=e.Matrix2D.Compose(this.applyActualScaleOnTransform()?i:a._iV2,s,o);var c=this.renderGroup.viewportSize,h=this.actualZOffset,d=0,p=0;r&&(d=r.x*n.m[0]+r.y*n.m[2],p=r.x*n.m[1]+r.y*n.m[3]);var f=c.width,g=c.height,_=1/h,y=new e.Vector4(2*n.m[0]/f,2*n.m[2]/f,0,2*(n.m[4]+d)/f-1),m=new e.Vector4(2*n.m[1]/g,2*n.m[3]/g,0,2*(n.m[5]+p)/g-1);t.renderingInfo=new e.Vector3(f,g,this.alignToPixel?1:0),t.transformX=y,t.transformY=m,t.opacity=this.actualOpacity,t.zBias=new e.Vector2(h,_)},n.prototype._updateRenderMode=function(){this.isTransparent?this._renderMode=e.Render2DContext.RenderModeTransparent:this.isAlphaTest?this._renderMode=e.Render2DContext.RenderModeAlphaTest:this._renderMode=e.Render2DContext.RenderModeOpaque},n})(e.Prim2DBase);o.RENDERABLEPRIM2D_PROPCOUNT=e.Prim2DBase.PRIM2DBASE_PROPCOUNT+5,o._toz=e.Size.Zero(),o._uV=new e.Vector2(1,1),o._s=e.Vector2.Zero(),o._r=e.Quaternion.Identity(),o._t=e.Vector2.Zero(),o._iV2=new e.Vector2(1,1),__decorate([e.dynamicLevelProperty(e.Prim2DBase.PRIM2DBASE_PROPCOUNT+0,(function(e){return a.isAlphaTestProperty=e}))],o.prototype,"isAlphaTest",null),__decorate([e.dynamicLevelProperty(e.Prim2DBase.PRIM2DBASE_PROPCOUNT+1,(function(e){return a.isTransparentProperty=e}))],o.prototype,"isTransparent",null),o=a=__decorate([e.className("RenderablePrim2D","BABYLON")],o),e.RenderablePrim2D=o;var a})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=n=(function(t){function r(r){var n=t.call(this,r)||this;r||(r={});var i=null;r.border&&(i="string"==typeof r.border?e.Canvas2D.GetBrushFromString(r.border):r.border);var o=null;return r.fill&&(o="string"==typeof r.fill?e.Canvas2D.GetBrushFromString(r.fill):r.fill),n._isTransparent=!1,n._oldTransparent=!1,n.border=i,n.fill=o,n._updateTransparencyStatus(),n.borderThickness=r.borderThickness,n}return __extends(r,t),Object.defineProperty(r.prototype,"border",{get:function(){return this._border},set:function(e){this._border=e,this._updateTransparencyStatus()},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"fill",{get:function(){return this._fill},set:function(e){this._fill=e,this._updateTransparencyStatus()},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"borderThickness",{get:function(){return this._borderThickness},set:function(e){this._borderThickness=e},enumerable:!0,configurable:!0}),r.prototype.getUsedShaderCategories=function(r){var i=t.prototype.getUsedShaderCategories.call(this,r);if(r.id===n.SHAPE2D_FILLPARTID){var o=this.fill;o instanceof e.SolidColorBrush2D&&i.push(n.SHAPE2D_CATEGORY_FILLSOLID),o instanceof e.GradientColorBrush2D&&i.push(n.SHAPE2D_CATEGORY_FILLGRADIENT)}if(r.id===n.SHAPE2D_BORDERPARTID){i.push(n.SHAPE2D_CATEGORY_BORDER);var a=this.border;a instanceof e.SolidColorBrush2D&&i.push(n.SHAPE2D_CATEGORY_BORDERSOLID),a instanceof e.GradientColorBrush2D&&i.push(n.SHAPE2D_CATEGORY_BORDERGRADIENT)}return i},r.prototype.refreshInstanceDataPart=function(r){if(!t.prototype.refreshInstanceDataPart.call(this,r))return!1;if(r.id===n.SHAPE2D_FILLPARTID){var i=r;if(this.fill){var o=this.fill;if(o instanceof e.SolidColorBrush2D)i.fillSolidColor=o.color;else if(o instanceof e.GradientColorBrush2D){i.fillGradientColor1=o.color1,i.fillGradientColor2=o.color2;var a=e.Matrix2D.Compose(new e.Vector2(o.scale,o.scale),o.rotation,new e.Vector2(o.translation.x,o.translation.y)),s=new e.Vector4(a.m[1],a.m[3],0,a.m[5]);i.fillGradientTY=s}}}else if(r.id===n.SHAPE2D_BORDERPARTID){var i=r;if(this.border){i.borderThickness=this.borderThickness;var l=this.border;if(l instanceof e.SolidColorBrush2D)i.borderSolidColor=l.color;else if(l instanceof e.GradientColorBrush2D){i.borderGradientColor1=l.color1,i.borderGradientColor2=l.color2;var a=e.Matrix2D.Compose(new e.Vector2(l.scale,l.scale),l.rotation,new e.Vector2(l.translation.x,l.translation.y)),s=new e.Vector4(a.m[1],a.m[3],0,a.m[5]);i.borderGradientTY=s}}}return!0},r.prototype._updateTransparencyStatus=function(){this._isTransparent=this._border&&this._border.isTransparent()||this._fill&&this._fill.isTransparent()||this.actualOpacity<1,this._isTransparent!==this._oldTransparent&&(this._oldTransparent=this._isTransparent,this._updateRenderMode())},r.prototype._mustUpdateInstance=function(){var e=this._oldTransparent!==this._isTransparent;return e&&(this._updateRenderMode(),this._oldTransparent=this._isTransparent),e},r.prototype._isPrimTransparent=function(){return this._isTransparent},r})(e.RenderablePrim2D);t.SHAPE2D_BORDERPARTID=1,t.SHAPE2D_FILLPARTID=2,t.SHAPE2D_CATEGORY_BORDER="Border",t.SHAPE2D_CATEGORY_BORDERSOLID="BorderSolid",t.SHAPE2D_CATEGORY_BORDERGRADIENT="BorderGradient",t.SHAPE2D_CATEGORY_FILLSOLID="FillSolid",t.SHAPE2D_CATEGORY_FILLGRADIENT="FillGradient",t.SHAPE2D_PROPCOUNT=e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+5,__decorate([e.modelLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+1,(function(e){return n.borderProperty=e}),!0)],t.prototype,"border",null),__decorate([e.modelLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+2,(function(e){return n.fillProperty=e}),!0)],t.prototype,"fill",null),__decorate([e.instanceLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+3,(function(e){return n.borderThicknessProperty=e}))],t.prototype,"borderThickness",null),t=n=__decorate([e.className("Shape2D","BABYLON")],t),e.Shape2D=t;var r=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),Object.defineProperty(t.prototype,"fillSolidColor",{get:function(){return null},set:function(e){},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fillGradientColor1",{get:function(){return null},set:function(e){},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fillGradientColor2",{get:function(){return null},set:function(e){},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fillGradientTY",{get:function(){return null},set:function(e){},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"borderThickness",{get:function(){return null},set:function(e){},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"borderSolidColor",{get:function(){return null},set:function(e){},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"borderGradientColor1",{get:function(){return null},set:function(e){},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"borderGradientColor2",{get:function(){return null},set:function(e){},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"borderGradientTY",{get:function(){return null},set:function(e){},enumerable:!0,configurable:!0}),t})(e.InstanceDataBase);__decorate([e.instanceData(t.SHAPE2D_CATEGORY_FILLSOLID)],r.prototype,"fillSolidColor",null),__decorate([e.instanceData(t.SHAPE2D_CATEGORY_FILLGRADIENT)],r.prototype,"fillGradientColor1",null),__decorate([e.instanceData(t.SHAPE2D_CATEGORY_FILLGRADIENT)],r.prototype,"fillGradientColor2",null),__decorate([e.instanceData(t.SHAPE2D_CATEGORY_FILLGRADIENT)],r.prototype,"fillGradientTY",null),__decorate([e.instanceData(t.SHAPE2D_CATEGORY_BORDER)],r.prototype,"borderThickness",null),__decorate([e.instanceData(t.SHAPE2D_CATEGORY_BORDERSOLID)],r.prototype,"borderSolidColor",null),__decorate([e.instanceData(t.SHAPE2D_CATEGORY_BORDERGRADIENT)],r.prototype,"borderGradientColor1",null),__decorate([e.instanceData(t.SHAPE2D_CATEGORY_BORDERGRADIENT)],r.prototype,"borderGradientColor2",null),__decorate([e.instanceData(t.SHAPE2D_CATEGORY_BORDERGRADIENT)],r.prototype,"borderGradientTY",null),e.Shape2DInstanceData=r;var n})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=i=(function(t){function n(r){var n=this;null==r&&(r={}),null==r.origin&&(r.origin=new e.Vector2(0,0)),n=t.call(this,r)||this;var o=r.size||r.width||r.height?r.size||new e.Size(r.width||0,r.height||0):null;n instanceof e.WorldSpaceCanvas2D||(n._trackedNode=null==r.trackNode?null:r.trackNode,n._trackedNodeOffset=null==r.trackNodeOffset?null:r.trackNodeOffset,n._trackedNode&&n.owner&&n.owner._registerTrackedNode(n)),n._cacheBehavior=null==r.cacheBehavior?i.GROUPCACHEBEHAVIOR_FOLLOWCACHESTRATEGY:r.cacheBehavior;var a=n._renderableData;return a&&(a._noResizeOnScale=0!==(n.cacheBehavior&i.GROUPCACHEBEHAVIOR_NORESIZEONSCALE)),n.size=o,n._viewportPosition=e.Vector2.Zero(),n._viewportSize=e.Size.Zero(),n}return __extends(n,t),n._createCachedCanvasGroup=function(t){var r=new i({parent:t,id:"__cachedCanvasGroup__",position:e.Vector2.Zero(),origin:e.Vector2.Zero(),size:null,isVisible:!0,isPickable:!1,dontInheritParentScale:!0});return r},n.prototype.applyCachedTexture=function(t,r){if(this._bindCacheTarget(),t)for(var n=t.uvs,i=this._renderableData._cacheNodeUVs,o=0;o<4;o++)n[2*o+0]=i[o].x,n[2*o+1]=i[o].y;r&&(r.diffuseTexture=this._renderableData._cacheTexture,r.emissiveColor=new e.Color3(1,1,1)),this._renderableData._cacheTexture.hasAlpha=!0,this._unbindCacheTarget()},Object.defineProperty(n.prototype,"cachedRect",{get:function(){return this._renderableData?this._renderableData._cacheNode:null},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"cachedUVs",{get:function(){return this._renderableData?this._renderableData._cacheNodeUVs:null},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"cachedUVsChanged",{get:function(){return this._renderableData?(this._renderableData._cacheNodeUVsChangedObservable||(this._renderableData._cacheNodeUVsChangedObservable=new e.Observable),this._renderableData._cacheNodeUVsChangedObservable):null},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"cacheTexture",{get:function(){return this._renderableData?this._renderableData._cacheTexture:null},enumerable:!0,configurable:!0}),n.prototype.dispose=function(){return!!t.prototype.dispose.call(this)&&(null!=this._trackedNode&&(this.owner._unregisterTrackedNode(this),this._trackedNode=null),this._renderableData&&(this._renderableData.dispose(this.owner),this._renderableData=null),!0)},Object.defineProperty(n.prototype,"isRenderableGroup",{get:function(){return this._isRenderableGroup},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isCachedGroup",{get:function(){return this._isCachedGroup},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"size",{get:function(){return this.internalGetSize()},set:function(e){this.internalSetSize(e)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"viewportSize",{get:function(){return this._viewportSize},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"cacheBehavior",{get:function(){return this._cacheBehavior},enumerable:!0,configurable:!0}),n.prototype._addPrimToDirtyList=function(e){this._renderableData._primDirtyList.push(e)},n.prototype._renderCachedCanvas=function(){this.owner._addGroupRenderCount(1),this.updateCachedStates(!0);var t=new e.PrepareRender2DContext;this._prepareGroupRender(t),this._groupRender()},Object.defineProperty(n.prototype,"trackedNode",{get:function(){return this._trackedNode},set:function(t){null!=t?(this._isFlagSet(e.SmartPropertyPrim.flagTrackedGroup)||this.owner._registerTrackedNode(this),this._trackedNode=t):(this._isFlagSet(e.SmartPropertyPrim.flagTrackedGroup)&&this.owner._unregisterTrackedNode(this),this._trackedNode=null)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"trackedNodeOffset",{get:function(){return this._trackedNodeOffset},set:function(e){this._trackedNodeOffset?this._trackedNodeOffset.copyFrom(e):this._trackedNodeOffset=e.clone()},enumerable:!0,configurable:!0}),n.prototype.levelIntersect=function(e){return!0},n.prototype.updateLevelBoundingInfo=function(){var t;return t=this.size?this.size:new e.Size(0,0),e.BoundingInfo2D.CreateFromSizeToRef(t,this._levelBoundingInfo),!0},n.prototype._prepareGroupRender=function(t){var r=null,n=this._renderableData;(n._primDirtyList.length>0||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;f<g.length;f++){var _=g[f];_.isDisposed||_._prepareRender(t)}else r||(r=n._primDirtyList.sort((function(e,t){return e.hierarchyDepth-t.hierarchyDepth}))),r.forEach((function(e){!e.isDisposed&&e._needPrepare()&&e._prepareRender(t)}));n._primDirtyList.forEach((function(t){n._primNewDirtyList.indexOf(t)===-1?t._resetPropertiesDirty():t._setFlags(e.SmartPropertyPrim.flagNeedRefresh)})),n._primDirtyList.splice(0),n._primDirtyList=n._primDirtyList.concat(n._primNewDirtyList)}n._childrenRenderableGroups.forEach((function(e){e._prepareGroupRender(t)}))},n.prototype._groupRender=function(){for(var t=this,r=this.owner.engine,n=0,i=0,o=this._renderableData._childrenRenderableGroups;i<o.length;i++){var a=o[i];a._groupRender()}if(!this.isCachedGroup||this._cacheGroupDirty){if(this.owner._addGroupRenderCount(1),this.isCachedGroup)this._bindCacheTarget();else var s=r.setDirectViewport(this._viewportPosition.x,this._viewportPosition.y,this._viewportSize.width,this._viewportSize.height);var l=r.getAlphaTesting()===!0,u=r.getDepthWrite()===!0;r.setAlphaTesting(!1),r.setDepthWrite(!0);var c=new e.Render2DContext(e.Render2DContext.RenderModeOpaque);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(!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<i.length;n++){var o=i[n];o.dispose(this.owner.engine)}t._transparentSegments.splice(0);for(var a=null,s=0;s<t._transparentPrimitives.length;s++){var l=t._transparentPrimitives[s];if(l._groupInstanceInfo.transparentOrderDirty&&l._groupInstanceInfo.sortTransparentData(),l._transparentSegment=null,a&&r(a,s),!l._transparentSegment){var o=new e.TransparentSegment;o.groupInsanceInfo=l._groupInstanceInfo;var u=l._primitive;o.startZ=u.actualZOffset,u._updateTransparentSegmentIndices(o),o.endZ=o.startZ,l._transparentSegment=o,t._transparentSegments.push(o)}a=l._transparentSegment}t._transparentListChanged=!1},n.prototype._renderTransparentData=function(){for(var t=0,r=new e.Render2DContext(e.Render2DContext.RenderModeTransparent),n=this._renderableData,i=this.owner.supportInstancedArray,o=n._transparentSegments.length,a=0;a<o;a++){r.instancedBuffers=null;var s=n._transparentSegments[a],l=s.groupInsanceInfo,u=l.modelRenderCache,c=this.owner.engine,h=s.endDataIndex-s.startDataIndex;if(i&&h>=this.owner.minPartCountToUseInstancedArray){if(s.partBuffers){if(l.transparentDirty)for(var d=0;d<l.transparentData.length;d++){var p=l.transparentData[d],f=p._partData,g=f.pack(),_=f.stride,y=s.partBuffers[d],m=g.subarray(s.startDataIndex*_,s.endDataIndex*_);c.bindArrayBuffer(y),c.updateArrayBuffer(m)}}else{for(var v=new Array,d=0;d<l.transparentData.length;d++){var p=l.transparentData[d],f=p._partData,g=f.pack(),_=f.stride,b=h*_*4,y=c.createInstancesBuffer(b),m=g.subarray(s.startDataIndex*_,s.endDataIndex*_);c.updateArrayBuffer(m),v.push(y)}s.partBuffers=v}r.useInstancing=!0,r.instancesCount=h,r.instancedBuffers=s.partBuffers,r.groupInfoPartData=l.transparentData;var P=!u.render(l,r);t+=P?1:0}else{r.useInstancing=!1,r.partDataStartIndex=s.startDataIndex,r.partDataEndIndex=s.endDataIndex,r.groupInfoPartData=l.transparentData;var P=!u.render(l,r);t+=P?1:0}}return t},n.prototype._prepareContext=function(t,r,n){var i,o,a=null;switch(r.renderMode){case e.Render2DContext.RenderModeOpaque:if(!n.hasOpaqueData)return null;i=function(e){n.opaqueDirty=e},o=function(){return n.opaqueDirty},r.groupInfoPartData=n.opaqueData,a=n.opaqueData;break;case e.Render2DContext.RenderModeAlphaTest:if(!n.hasAlphaTestData)return null;i=function(e){n.alphaTestDirty=e},o=function(){return n.alphaTestDirty},r.groupInfoPartData=n.alphaTestData,a=n.alphaTestData;break;default:throw new Error("_prepareContext is only for opaque or alphaTest")}var s=0;if(this.owner.supportInstancedArray){r.useInstancing=!0;for(var l=0;l<a.length;l++){var u=a[l],c=u._partData,h=c.pack();s+=c.usedElementCount;var d=c.usedElementCount*c.stride*4;!u._partBuffer||u._partBufferSize<d?(u._partBuffer&&t.deleteInstancesBuffer(u._partBuffer),u._partBuffer=t.createInstancesBuffer(d),u._partBufferSize=d,i(!1),t.updateArrayBuffer(h)):o()&&(t.bindArrayBuffer(u._partBuffer),t.updateArrayBuffer(h))}i(!1)}else if(r.partDataStartIndex=0,r.groupInfoPartData.length>0){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._s.width||h.height<i._s.height){var d=this.owner.isScreenSpace?1.07:1;t=Math.floor(i._s.width*d),r=Math.floor(i._s.height*d),o._cacheTexture.freeRect(o._cacheNode),o._cacheNode=null}}if(o._cacheNode){if(c){var p=o._cacheRenderSprite;p&&(p.size=u,p.spriteSize=new e.Size(u.width*n.x*a,u.height*n.y*a))}}else{var f=this.owner._allocateGroupCache(this,this.parent&&this.parent.renderGroup,t?new e.Size(t,r):null,o._useMipMap,o._anisotropicLevel);o._cacheNode=f.node,o._cacheTexture=f.texture,o._cacheRenderSprite&&o._cacheRenderSprite.dispose(),o._cacheRenderSprite=f.sprite,c=!0}c&&(o._cacheSize.copyFrom(i._s),o._cacheNodeUVs=o._cacheNode.getUVsForCustomSize(o._cacheSize),o._cacheNodeUVsChangedObservable&&o._cacheNodeUVsChangedObservable.hasObservers()&&o._cacheNodeUVsChangedObservable.notifyObservers(o._cacheNodeUVs),this._setFlags(e.SmartPropertyPrim.flagWorldCacheChanged));var g=i._v1;o._cacheNode.getInnerPosToRef(g),o._cacheTexture.bindTextureForPosSize(g,i._s,!0)},n.prototype._unbindCacheTarget=function(){this._renderableData._cacheTexture&&this._renderableData._cacheTexture.unbindTexture()},n.prototype._spreadActualScaleDirty=function(){this._renderableData&&this._renderableData._cacheRenderSprite&&this.handleGroupChanged(e.Prim2DBase.actualScaleProperty),t.prototype._spreadActualScaleDirty.call(this)},n.prototype.handleGroupChanged=function(t){var r=this._renderableData;if(r){var n=r._cacheRenderSprite;if(this.isCachedGroup&&n)switch(t.id){case e.Prim2DBase.actualPositionProperty.id:n.actualPosition=this.actualPosition.clone(),null!=n.position&&(n.position=n.actualPosition.clone());break;case e.Prim2DBase.rotationProperty.id:n.rotation=this.rotation;break;case e.Prim2DBase.scaleProperty.id:n.scale=this.scale;break;case e.Prim2DBase.originProperty.id:n.origin=this.origin.clone();break;case i.actualSizeProperty.id:n.size=this.actualSize.clone();break;case i.xProperty.id:n.x=this.x;break;case i.yProperty.id:n.y=this.y}}},n.prototype.detectGroupStates=function(){var t=this instanceof e.Canvas2D,n=this.owner.cachingStrategy;if(n===e.Canvas2D.CACHESTRATEGY_DONTCACHE)this._isRenderableGroup=t,this._isCachedGroup=!1;else if(n===e.Canvas2D.CACHESTRATEGY_CANVAS)t?(this._isRenderableGroup=!0,this._isCachedGroup=!0):(this._isRenderableGroup="__cachedCanvasGroup__"===this.id,this._isCachedGroup=!1);else if(n===e.Canvas2D.CACHESTRATEGY_TOPLEVELGROUPS)t?(this._isRenderableGroup=!0,this._isCachedGroup=!1):1===this.hierarchyDepth?(this._isRenderableGroup=!0,this._isCachedGroup=!0):(this._isRenderableGroup=!1,this._isCachedGroup=!1);else if(n===e.Canvas2D.CACHESTRATEGY_ALLGROUPS)if(t)this._isRenderableGroup=!0,this._isCachedGroup=!1;else{var o=this.cacheBehavior&i.GROUPCACHEBEHAVIOR_OPTIONMASK;o!==i.GROUPCACHEBEHAVIOR_DONTCACHEOVERRIDE&&o!==i.GROUPCACHEBEHAVIOR_CACHEINPARENTGROUP||(this._isRenderableGroup=o===i.GROUPCACHEBEHAVIOR_DONTCACHEOVERRIDE,this._isCachedGroup=!1),o===i.GROUPCACHEBEHAVIOR_FOLLOWCACHESTRATEGY&&(this._isRenderableGroup=!0,this._isCachedGroup=!0)}if(this._isRenderableGroup&&(this._renderableData||(this._renderableData=new r)),this._isCachedGroup){this._renderableData._noResizeOnScale=0!==(this.cacheBehavior&i.GROUPCACHEBEHAVIOR_NORESIZEONSCALE);for(var a=this.parent;a;){if(a instanceof i&&a._isRenderableGroup){a._renderableData._childrenRenderableGroups.indexOf(this)===-1&&a._renderableData._childrenRenderableGroups.push(this);break}a=a.parent}}},Object.defineProperty(n.prototype,"_cachedTexture",{get:function(){return this._renderableData?this._renderableData._cacheTexture:null},enumerable:!0,configurable:!0}),n})(e.Prim2DBase);t.GROUP2D_PROPCOUNT=e.Prim2DBase.PRIM2DBASE_PROPCOUNT+5,t.GROUPCACHEBEHAVIOR_FOLLOWCACHESTRATEGY=0,t.GROUPCACHEBEHAVIOR_DONTCACHEOVERRIDE=1,t.GROUPCACHEBEHAVIOR_CACHEINPARENTGROUP=2,t.GROUPCACHEBEHAVIOR_NORESIZEONSCALE=256,t.GROUPCACHEBEHAVIOR_OPTIONMASK=255,t._uV=new e.Vector2(1,1),t._s=e.Size.Zero(),t._v1=e.Vector2.Zero(),t._s2=e.Size.Zero(),t._unS=new e.Vector2(1,1),__decorate([e.instanceLevelProperty(e.Prim2DBase.PRIM2DBASE_PROPCOUNT+1,(function(e){return i.sizeProperty=e}),!1,!0)],t.prototype,"size",null),t=i=__decorate([e.className("Group2D","BABYLON")],t),e.Group2D=t;var r=(function(){function t(){this._primDirtyList=new Array,this._primNewDirtyList=new Array,this._childrenRenderableGroups=new Array,this._renderGroupInstancesInfo=new e.StringDictionary,this._transparentPrimitives=new Array,this._transparentSegments=new Array,this._transparentListChanged=!1,this._cacheNode=null,this._cacheTexture=null,this._cacheRenderSprite=null,this._renderingScale=1,this._cacheNodeUVs=null,this._cacheNodeUVsChangedObservable=null,this._cacheSize=e.Size.Zero(),this._useMipMap=!1,this._anisotropicLevel=1,this._noResizeOnScale=!1}return t.prototype.dispose=function(e){var t=e.engine;if(this._cacheRenderSprite&&(this._cacheRenderSprite.dispose(),this._cacheRenderSprite=null),this._cacheTexture&&this._cacheNode&&(this._cacheTexture.freeRect(this._cacheNode),this._cacheTexture=null,this._cacheNode=null),this._primDirtyList&&(this._primDirtyList.splice(0),this._primDirtyList=null),this._renderGroupInstancesInfo&&(this._renderGroupInstancesInfo.forEach((function(e,t){t.dispose()})),this._renderGroupInstancesInfo=null),this._cacheNodeUVsChangedObservable&&(this._cacheNodeUVsChangedObservable.clear(),this._cacheNodeUVsChangedObservable=null),this._transparentSegments){for(var r=0,n=this._transparentSegments;r<n.length;r++){
var i=n[r];i.dispose(t)}this._transparentSegments.splice(0),this._transparentSegments=null}},t.prototype.addNewTransparentPrimitiveInfo=function(e,t){var r=new n;return r._primitive=e,r._groupInstanceInfo=t,r._transparentSegment=null,this._transparentPrimitives.push(r),this._transparentListChanged=!0,r},t.prototype.removeTransparentPrimitiveInfo=function(e){var t=this._transparentPrimitives.indexOf(e);t!==-1&&(this._transparentPrimitives.splice(t,1),this._transparentListChanged=!0)},t.prototype.transparentPrimitiveZChanged=function(e){this._transparentListChanged=!0},t})();e.RenderableGroupData=r;var n=(function(){function e(){}return e})();e.TransparentPrimitiveInfo=n;var i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e.effectsReady=!1,e.vb=null,e.vtxCount=0,e.instancingAttributes=null,e.effect=null,e.effectInstanced=null,e}return __extends(r,t),r.prototype.render=function(t,r){if(!this.effectsReady){if(this.effect&&(!this.effect.isReady()||this.effectInstanced&&!this.effectInstanced.isReady()))return!1;this.effectsReady=!0}var n=t.owner.owner,o=n.engine,a=o.getAlphaMode(),s=r.useInstancing?this.effectInstanced:this.effect;o.enableEffect(s),o.bindBuffersDirectly(this.vb,null,[2,4],24,s),r.renderMode!==e.Render2DContext.RenderModeOpaque&&o.setAlphaMode(e.Engine.ALPHA_COMBINE,!0);var l=r.groupInfoPartData[0];if(r.useInstancing){this.instancingAttributes||(this.instancingAttributes=this.loadInstancingAttributes(i.WIREFRAME2D_MAINPARTID,s));var u=r.instancedBuffers?r.instancedBuffers[0]:l._partBuffer,c=r.instancedBuffers?r.instancesCount:l._partData.usedElementCount;n._addDrawCallCount(1,r.renderMode),o.updateAndBindInstancesBuffer(u,null,this.instancingAttributes),o.drawUnIndexed(!1,0,this.vtxCount,c),o.unbindInstanceAttributes()}else{n._addDrawCallCount(r.partDataEndIndex-r.partDataStartIndex,r.renderMode);for(var h=r.partDataStartIndex;h<r.partDataEndIndex;h++)this.setupUniforms(s,0,l._partData,h),o.drawUnIndexed(!1,0,this.vtxCount)}return o.setAlphaMode(a,!0),!0},r.prototype.updateModelRenderCache=function(e){var t=e;return t._updateVertexBuffer(this),!0},r.prototype.dispose=function(){return!!t.prototype.dispose.call(this)&&(this.vb&&(this._engine._releaseBuffer(this.vb),this.vb=null),this.effect=null,this.effectInstanced=null,!0)},r})(e.ModelRenderCache);e.WireFrame2DRenderCache=t;var r=(function(){function e(e,t){void 0===t&&(t=null),this.fromVector2(e),null!=t?this.fromColor4(t):this.r=this.g=this.b=this.a=1}return e.prototype.fromVector2=function(e){this.x=e.x,this.y=e.y},e.prototype.fromColor3=function(e){this.r=e.r,this.g=e.g,this.b=e.b,this.a=1},e.prototype.fromColor4=function(e){this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a},e})();r=__decorate([e.className("WireFrameVertex2D","BABYLON")],r),e.WireFrameVertex2D=r;var n=(function(){function t(t,r){void 0===t&&(t=null),void 0===r&&(r=null),this._id=null==t?e.Tools.RandomId():t,this._uid=e.Tools.RandomId(),this._defaultColor=null==r?new e.Color4(1,1,1,1):r,this._buildingStrip=!1,this._vertices=new Array}return Object.defineProperty(t.prototype,"uid",{get:function(){return this._uid},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"id",{get:function(){return this._id},enumerable:!0,configurable:!0}),t.prototype.pushVertex=function(e,t){void 0===t&&(t=null);var n=new r(e,null==t?this._defaultColor:t);if(this._vertices.push(n),this._buildingStrip){var i=new r(e,null==t?this._defaultColor:t);this._vertices.push(i)}},t.prototype.startLineStrip=function(e,t){void 0===t&&(t=null),this.pushVertex(e,null==t?this._defaultColor:t),this._buildingStrip=!0},t.prototype.endLineStrip=function(e,t){void 0===t&&(t=null),this._buildingStrip=!1,this.pushVertex(e,null==t?this._defaultColor:t)},Object.defineProperty(t.prototype,"vertices",{get:function(){return this._vertices},enumerable:!0,configurable:!0}),t})();n=__decorate([e.className("WireFrameGroup2D","BABYLON")],n),e.WireFrameGroup2D=n;var i=a=(function(r){function n(t,n){var i=this;n||(n={}),i=r.call(this,n)||this,i._wireFrameGroups=new e.StringDictionary;for(var o=0,a=t;o<a.length;o++){var s=a[o];i._wireFrameGroups.add(s.id,s)}return i._vtxTransparent=!1,null!=n.size&&(i.size=n.size),i.alignToPixel=null==n.alignToPixel||n.alignToPixel,i}return __extends(n,r),Object.defineProperty(n.prototype,"wireFrameGroups",{get:function(){return this._wireFrameGroups},enumerable:!0,configurable:!0}),n.prototype.wireFrameGroupsDirty=function(){this._setFlags(e.SmartPropertyPrim.flagModelUpdate),this.onPrimBecomesDirty()},Object.defineProperty(n.prototype,"size",{get:function(){return null==this._size&&this._computeMinMaxTrans(),this._size},set:function(e){this.internalSetSize(e)},enumerable:!0,configurable:!0}),n.prototype.updateLevelBoundingInfo=function(){var t=this._computeMinMaxTrans();return e.BoundingInfo2D.CreateFromMinMaxToRef(t.x,t.z,t.y,t.w,this._levelBoundingInfo),!0},n.prototype.levelIntersect=function(e){return!0},Object.defineProperty(n.prototype,"alignToPixel",{get:function(){return this._alignToPixel},set:function(e){this._alignToPixel=e},enumerable:!0,configurable:!0}),n.prototype.createModelRenderCache=function(e){var r=new t(this.owner.engine,e);return r},n.prototype.setupModelRenderCache=function(e){var t=e,r=this.owner.engine;this._updateVertexBuffer(t);var n=this.getDataPartEffectInfo(a.WIREFRAME2D_MAINPARTID,["pos","col"],[],!0);return n&&(t.effectInstanced=r.createEffect("wireframe2d",n.attributes,n.uniforms,[],n.defines,null)),n=this.getDataPartEffectInfo(a.WIREFRAME2D_MAINPARTID,["pos","col"],[],!1),t.effect=r.createEffect("wireframe2d",n.attributes,n.uniforms,[],n.defines,null),t},n.prototype._updateVertexBuffer=function(e){var t=this.owner.engine;null!=e.vb&&t._releaseBuffer(e.vb);var r=0;this._wireFrameGroups.forEach((function(e,t){return r+=t.vertices.length}));var n=new Float32Array(6*r),i=0;this._wireFrameGroups.forEach((function(e,t){for(var r=0,o=t.vertices;r<o.length;r++){var a=o[r];n[i++]=a.x,n[i++]=a.y,n[i++]=a.r,n[i++]=a.g,n[i++]=a.b,n[i++]=a.a}})),e.vb=t.createVertexBuffer(n),e.vtxCount=r},n.prototype.refreshInstanceDataPart=function(e){return!!r.prototype.refreshInstanceDataPart.call(this,e)},n.prototype._computeMinMaxTrans=function(){var t=Number.MAX_VALUE,r=Number.MIN_VALUE,n=Number.MAX_VALUE,i=Number.MIN_VALUE,o=!1;return this._wireFrameGroups.forEach((function(e,a){for(var s=0,l=a.vertices;s<l.length;s++){var u=l[s];t=Math.min(t,u.x),r=Math.max(r,u.x),n=Math.min(n,u.y),i=Math.max(i,u.y),u.a<1&&(o=!0)}})),this._vtxTransparent=o,this._size=new e.Size(r-t,i-n),new e.Vector4(t,n,r,i)},n.prototype.createInstanceDataParts=function(){return[new o(a.WIREFRAME2D_MAINPARTID)]},n})(e.RenderablePrim2D);i.WIREFRAME2D_MAINPARTID=1,__decorate([e.modelLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+1,(function(e){return a.wireFrameGroupsProperty=e}))],i.prototype,"wireFrameGroups",null),i=a=__decorate([e.className("WireFrame2D","BABYLON")],i),e.WireFrame2D=i;var o=(function(e){function t(t){return e.call(this,t,1)||this}return __extends(t,e),t})(e.InstanceDataBase);e.WireFrame2DInstanceData=o;var a})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(e,r){var n=t.call(this,e,r)||this;return n.effectsReady=!1,n.fillVB=null,n.fillIB=null,n.fillIndicesCount=0,n.instancingFillAttributes=null,n.effectFill=null,n.effectFillInstanced=null,n.borderVB=null,n.borderIB=null,n.borderIndicesCount=0,n.instancingBorderAttributes=null,n.effectBorder=null,n.effectBorderInstanced=null,n}return __extends(r,t),r.prototype.render=function(t,r){if(!this.effectsReady){if(this.effectFill&&(!this.effectFill.isReady()||this.effectFillInstanced&&!this.effectFillInstanced.isReady())||this.effectBorder&&(!this.effectBorder.isReady()||this.effectBorderInstanced&&!this.effectBorderInstanced.isReady()))return!1;this.effectsReady=!0}var n=t.owner.owner,i=n.engine,o=0;this.effectFill&&this.effectBorder&&(o=i.getDepthFunction(),i.setDepthFunctionToLessOrEqual());var a=i.getAlphaMode();if(this.effectFill){var s=t.partIndexFromId.get(e.Shape2D.SHAPE2D_FILLPARTID.toString()),l=r.groupInfoPartData[s];r.renderMode!==e.Render2DContext.RenderModeOpaque&&i.setAlphaMode(e.Engine.ALPHA_COMBINE,!0);var u=r.useInstancing?this.effectFillInstanced:this.effectFill;if(i.enableEffect(u),i.bindBuffersDirectly(this.fillVB,this.fillIB,[1],4,u),r.useInstancing){this.instancingFillAttributes||(this.instancingFillAttributes=this.loadInstancingAttributes(e.Shape2D.SHAPE2D_FILLPARTID,u));var c=r.instancedBuffers?r.instancedBuffers[s]:l._partBuffer,h=r.instancedBuffers?r.instancesCount:l._partData.usedElementCount;n._addDrawCallCount(1,r.renderMode),i.updateAndBindInstancesBuffer(c,null,this.instancingFillAttributes),i.draw(!0,0,this.fillIndicesCount,h),i.unbindInstanceAttributes()}else{n._addDrawCallCount(r.partDataEndIndex-r.partDataStartIndex,r.renderMode);for(var d=r.partDataStartIndex;d<r.partDataEndIndex;d++)this.setupUniforms(u,s,l._partData,d),i.draw(!0,0,this.fillIndicesCount)}}if(this.effectBorder){var s=t.partIndexFromId.get(e.Shape2D.SHAPE2D_BORDERPARTID.toString()),l=r.groupInfoPartData[s];r.renderMode!==e.Render2DContext.RenderModeOpaque&&i.setAlphaMode(e.Engine.ALPHA_COMBINE,!0);var u=r.useInstancing?this.effectBorderInstanced:this.effectBorder;if(i.enableEffect(u),i.bindBuffersDirectly(this.borderVB,this.borderIB,[1],4,u),r.useInstancing){this.instancingBorderAttributes||(this.instancingBorderAttributes=this.loadInstancingAttributes(e.Shape2D.SHAPE2D_BORDERPARTID,u));var c=r.instancedBuffers?r.instancedBuffers[s]:l._partBuffer,h=r.instancedBuffers?r.instancesCount:l._partData.usedElementCount;n._addDrawCallCount(1,r.renderMode),i.updateAndBindInstancesBuffer(c,null,this.instancingBorderAttributes),i.draw(!0,0,this.borderIndicesCount,h),i.unbindInstanceAttributes()}else{n._addDrawCallCount(r.partDataEndIndex-r.partDataStartIndex,r.renderMode);for(var d=r.partDataStartIndex;d<r.partDataEndIndex;d++)this.setupUniforms(u,s,l._partData,d),i.draw(!0,0,this.borderIndicesCount)}}return i.setAlphaMode(a,!0),this.effectFill&&this.effectBorder&&i.setDepthFunction(o),!0},r.prototype.dispose=function(){return!!t.prototype.dispose.call(this)&&(this.fillVB&&(this._engine._releaseBuffer(this.fillVB),this.fillVB=null),this.fillIB&&(this._engine._releaseBuffer(this.fillIB),this.fillIB=null),this.effectFill=null,this.effectFillInstanced=null,this.effectBorder=null,this.effectBorderInstanced=null,this.borderVB&&(this._engine._releaseBuffer(this.borderVB),this.borderVB=null),this.borderIB&&(this._engine._releaseBuffer(this.borderIB),this.borderIB=null),!0)},r})(e.ModelRenderCache);e.Rectangle2DRenderCache=t;var r=(function(e){function t(t){return e.call(this,t,1)||this}return __extends(t,e),Object.defineProperty(t.prototype,"properties",{get:function(){return null},set:function(e){},enumerable:!0,configurable:!0}),t})(e.Shape2DInstanceData);__decorate([e.instanceData()],r.prototype,"properties",null),e.Rectangle2DInstanceData=r;var n=i=(function(n){function o(t){var r=this;if(null==t&&(t={}),r=n.call(this,t)||this,null!=t.size)r.size=t.size;else if(t.width||t.height){var i=new e.Size(t.width,t.height);r.size=i}var o=null==t.roundRadius?0:t.roundRadius,a=null==t.borderThickness?1:t.borderThickness;return r.roundRadius=o,r.borderThickness=a,r}return __extends(o,n),Object.defineProperty(o.prototype,"notRounded",{get:function(){return this._notRounded},set:function(e){this._notRounded=e},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"roundRadius",{get:function(){return this._roundRadius},set:function(e){this._roundRadius=e,this.notRounded=0===e,this._positioningDirty()},enumerable:!0,configurable:!0}),o.prototype.levelIntersect=function(e){if(this.notRounded)return!0;var t=this.size;i._i0.x=e._localPickPosition.x,i._i0.y=e._localPickPosition.y;var r=this.roundRadius,n=r*r;return i._i1.x=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):(i._i1.x=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=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){e<l?(r.x=1-p,r.y=f):e<u?(r.x=p,r.y=f):e<c?(r.x=p,r.y=1-f):(r.x=1-p,r.y=1-f);var n=d-e*d/(t-.5);r.x+=Math.cos(n)*p,r.y+=Math.sin(n)*f,r.x*=o,r.y*=a};console.log("Genetre TriList for "+this.id);var _=e.Vector2.Zero(),y=e.Vector2.Zero();g(0,_);for(var m=_.clone(),v=1;v<t;v++)g(v,y),this._primTriArray.storeTriangle(v-1,h,m,y),console.log(v-1+", "+h+", "+m+", "+y),m.copyFrom(y);this._primTriArray.storeTriangle(t-1,h,_,m),console.log(t-1+", "+h+", "+m+", "+_)},o.prototype.setupModelRenderCache=function(t){var r=t,n=this.owner.engine;if(this.fill){for(var o=4*(this.notRounded?1:i.roundSubdivisions)+1,a=new Float32Array(o),s=0;s<o;s++)a[s]=s;r.fillVB=n.createVertexBuffer(a);for(var l=o-1,u=new Float32Array(3*l),s=0;s<l;s++)u[3*s+0]=0,u[3*s+2]=s+1,u[3*s+1]=s+2;u[3*l-2]=1,r.fillIB=n.createIndexBuffer(u),r.fillIndicesCount=3*l;var c=this.getDataPartEffectInfo(e.Shape2D.SHAPE2D_FILLPARTID,["index"],null,!0);c&&(r.effectFillInstanced=n.createEffect("rect2d",c.attributes,c.uniforms,[],c.defines,null)),c=this.getDataPartEffectInfo(e.Shape2D.SHAPE2D_FILLPARTID,["index"],null,!1),r.effectFill=n.createEffect("rect2d",c.attributes,c.uniforms,[],c.defines,null)}if(this.border){for(var o=4*(this.notRounded?1:i.roundSubdivisions)*2,a=new Float32Array(o),s=0;s<o;s++)a[s]=s;r.borderVB=n.createVertexBuffer(a);for(var l=o,h=l/2,u=new Float32Array(3*l),s=0;s<h;s++){var d=s,p=(s+1)%h;u[6*s+0]=h+p,u[6*s+1]=h+d,u[6*s+2]=d,u[6*s+3]=p,u[6*s+4]=h+p,u[6*s+5]=d}r.borderIB=n.createIndexBuffer(u),r.borderIndicesCount=3*l;var c=this.getDataPartEffectInfo(e.Shape2D.SHAPE2D_BORDERPARTID,["index"],null,!0);c&&(r.effectBorderInstanced=n.createEffect("rect2d",c.attributes,c.uniforms,[],c.defines,null)),c=this.getDataPartEffectInfo(e.Shape2D.SHAPE2D_BORDERPARTID,["index"],null,!1),r.effectBorder=n.createEffect("rect2d",c.attributes,c.uniforms,[],c.defines,null)}return r},o.prototype._getInitialContentAreaToRef=function(e,t,r){if(this._notRounded)n.prototype._getInitialContentAreaToRef.call(this,e,t,r);else{var i=Math.round(1.3*(this.roundRadius-this.roundRadius/Math.sqrt(2)));t.x=t.y=i,r.width=Math.max(0,e.width-2*i),r.height=Math.max(0,e.height-2*i),t.z=e.width-(t.x+r.width),t.w=e.height-(t.y+r.height)}},o.prototype._getActualSizeFromContentToRef=function(e,t,r){if(this._notRounded)n.prototype._getActualSizeFromContentToRef.call(this,e,t,r);else{var i=Math.round(1.3*(this.roundRadius-this.roundRadius/Math.sqrt(2)));r.copyFrom(e),r.width+=2*i,r.height+=2*i,t.x+=i,t.y+=i,t.z+=i,t.w+=i}},o.prototype.createInstanceDataParts=function(){var t=new Array;return this.border&&t.push(new r(e.Shape2D.SHAPE2D_BORDERPARTID)),this.fill&&t.push(new r(e.Shape2D.SHAPE2D_FILLPARTID)),t},o.prototype.refreshInstanceDataPart=function(t){if(!n.prototype.refreshInstanceDataPart.call(this,t))return!1;if(t.id===e.Shape2D.SHAPE2D_BORDERPARTID){var r=t,i=this.actualSize;r.properties=new e.Vector3(i.width,i.height,this.roundRadius||0)}else if(t.id===e.Shape2D.SHAPE2D_FILLPARTID){var r=t,i=this.actualSize;r.properties=new e.Vector3(i.width,i.height,this.roundRadius||0)}return!0},o})(e.Shape2D);n._i0=e.Vector2.Zero(),n._i1=e.Vector2.Zero(),n._i2=e.Vector2.Zero(),n.roundSubdivisions=16,n._riv0=new e.Vector2(0,0),__decorate([e.modelLevelProperty(e.Shape2D.SHAPE2D_PROPCOUNT+2,(function(e){return i.notRoundedProperty=e}))],n.prototype,"notRounded",null),__decorate([e.instanceLevelProperty(e.Shape2D.SHAPE2D_PROPCOUNT+3,(function(e){return i.roundRadiusProperty=e}))],n.prototype,"roundRadius",null),n=i=__decorate([e.className("Rectangle2D","BABYLON")],n),e.Rectangle2D=n;var i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(e,r){var n=t.call(this,e,r)||this;return n.effectsReady=!1,n.fillVB=null,n.fillIB=null,n.fillIndicesCount=0,n.instancingFillAttributes=null,n.effectFillInstanced=null,n.effectFill=null,n.borderVB=null,n.borderIB=null,n.borderIndicesCount=0,n.instancingBorderAttributes=null,n.effectBorderInstanced=null,n.effectBorder=null,n}return __extends(r,t),r.prototype.render=function(t,r){if(!this.effectsReady){if(this.effectFill&&(!this.effectFill.isReady()||this.effectFillInstanced&&!this.effectFillInstanced.isReady())||this.effectBorder&&(!this.effectBorder.isReady()||this.effectBorderInstanced&&!this.effectBorderInstanced.isReady()))return!1;this.effectsReady=!0}var n=t.owner.owner,i=n.engine,o=0;this.effectFill&&this.effectBorder&&(o=i.getDepthFunction(),i.setDepthFunctionToLessOrEqual());var a=i.getAlphaMode();if(this.effectFill){var s=t.partIndexFromId.get(e.Shape2D.SHAPE2D_FILLPARTID.toString()),l=r.groupInfoPartData[s];r.renderMode!==e.Render2DContext.RenderModeOpaque&&i.setAlphaMode(e.Engine.ALPHA_COMBINE,!0);var u=r.useInstancing?this.effectFillInstanced:this.effectFill;if(i.enableEffect(u),i.bindBuffersDirectly(this.fillVB,this.fillIB,[1],4,u),r.useInstancing){this.instancingFillAttributes||(this.instancingFillAttributes=this.loadInstancingAttributes(e.Shape2D.SHAPE2D_FILLPARTID,u));var c=r.instancedBuffers?r.instancedBuffers[s]:l._partBuffer,h=r.instancedBuffers?r.instancesCount:l._partData.usedElementCount;n._addDrawCallCount(1,r.renderMode),i.updateAndBindInstancesBuffer(c,null,this.instancingFillAttributes),i.draw(!0,0,this.fillIndicesCount,h),i.unbindInstanceAttributes()}else{n._addDrawCallCount(r.partDataEndIndex-r.partDataStartIndex,r.renderMode);for(var d=r.partDataStartIndex;d<r.partDataEndIndex;d++)this.setupUniforms(u,s,l._partData,d),i.draw(!0,0,this.fillIndicesCount)}}if(this.effectBorder){var s=t.partIndexFromId.get(e.Shape2D.SHAPE2D_BORDERPARTID.toString()),l=r.groupInfoPartData[s];r.renderMode!==e.Render2DContext.RenderModeOpaque&&i.setAlphaMode(e.Engine.ALPHA_COMBINE,!0);var u=r.useInstancing?this.effectBorderInstanced:this.effectBorder;if(i.enableEffect(u),i.bindBuffersDirectly(this.borderVB,this.borderIB,[1],4,u),r.useInstancing){this.instancingBorderAttributes||(this.instancingBorderAttributes=this.loadInstancingAttributes(e.Shape2D.SHAPE2D_BORDERPARTID,u));var c=r.instancedBuffers?r.instancedBuffers[s]:l._partBuffer,h=r.instancedBuffers?r.instancesCount:l._partData.usedElementCount;n._addDrawCallCount(1,r.renderMode),i.updateAndBindInstancesBuffer(c,null,this.instancingBorderAttributes),i.draw(!0,0,this.borderIndicesCount,h),i.unbindInstanceAttributes()}else{n._addDrawCallCount(r.partDataEndIndex-r.partDataStartIndex,r.renderMode);for(var d=r.partDataStartIndex;d<r.partDataEndIndex;d++)this.setupUniforms(u,s,l._partData,d),i.draw(!0,0,this.borderIndicesCount)}}return i.setAlphaMode(a,!0),this.effectFill&&this.effectBorder&&i.setDepthFunction(o),!0},r.prototype.dispose=function(){return!!t.prototype.dispose.call(this)&&(this.fillVB&&(this._engine._releaseBuffer(this.fillVB),this.fillVB=null),this.fillIB&&(this._engine._releaseBuffer(this.fillIB),this.fillIB=null),this.effectFill=null,this.effectFillInstanced=null,this.effectBorder=null,this.effectBorderInstanced=null,this.borderVB&&(this._engine._releaseBuffer(this.borderVB),this.borderVB=null),this.borderIB&&(this._engine._releaseBuffer(this.borderIB),this.borderIB=null),!0)},r})(e.ModelRenderCache);e.Ellipse2DRenderCache=t;var r=(function(e){function t(t){return e.call(this,t,1)||this}return __extends(t,e),Object.defineProperty(t.prototype,"properties",{get:function(){return null},set:function(e){},enumerable:!0,configurable:!0}),t})(e.Shape2DInstanceData);__decorate([e.instanceData()],r.prototype,"properties",null),e.Ellipse2DInstanceData=r;var n=i=(function(n){function i(t){var r=this;if(null==t&&(t={}),r=n.call(this,t)||this,null!=t.size)r.size=t.size;else if(t.width||t.height){var i=new e.Size(t.width,t.height);r.size=i}var o=null==t.subdivisions?64:t.subdivisions;return r.subdivisions=o,r}return __extends(i,n),Object.defineProperty(i.prototype,"subdivisions",{get:function(){return this._subdivisions},set:function(e){this._subdivisions=e},enumerable:!0,configurable:!0}),i.prototype.levelIntersect=function(e){var t=this.size.width/2,r=this.size.height/2,n=e._localPickPosition.x-t,i=e._localPickPosition.y-r;return n*n/(t*t)+i*i/(r*r)<=1},i.prototype.updateLevelBoundingInfo=function(){return e.BoundingInfo2D.CreateFromSizeToRef(this.actualSize,this._levelBoundingInfo),!0},i.prototype.updateTriArray=function(){var t=this._subdivisions;null==this._primTriArray?this._primTriArray=new e.Tri2DArray(t):this._primTriArray.clear(t);for(var r=this.actualSize,n=new e.Vector2(.5*r.width,.5*r.height),i=e.Vector2.Zero(),o=e.Vector2.Zero(),a=0;a<t;a++){var s=2*Math.PI*(a-1)/t,l=2*Math.PI*a/t;i.x=(Math.cos(s)/2+.5)*r.width,i.y=(Math.sin(s)/2+.5)*r.height,o.x=(Math.cos(l)/2+.5)*r.width,o.y=(Math.sin(l)/2+.5)*r.height,this._primTriArray.storeTriangle(a,n,i,o)}},i.prototype.createModelRenderCache=function(e){var r=new t(this.owner.engine,e);return r},i.prototype.setupModelRenderCache=function(t){var r=t,n=this.owner.engine;if(this.fill){for(var i=this.subdivisions+1,o=new Float32Array(i),a=0;a<i;a++)o[a]=a;r.fillVB=n.createVertexBuffer(o);for(var s=i-1,l=new Float32Array(3*s),a=0;a<s;a++)l[3*a+0]=0,l[3*a+2]=a+2,l[3*a+1]=a+1;l[3*s-1]=1,r.fillIB=n.createIndexBuffer(l),r.fillIndicesCount=3*s;var u=this.getDataPartEffectInfo(e.Shape2D.SHAPE2D_FILLPARTID,["index"],null,!0);u&&(r.effectFillInstanced=n.createEffect({vertex:"ellipse2d",fragment:"ellipse2d"},u.attributes,u.uniforms,[],u.defines,null)),u=this.getDataPartEffectInfo(e.Shape2D.SHAPE2D_FILLPARTID,["index"],null,!1),r.effectFill=n.createEffect({vertex:"ellipse2d",fragment:"ellipse2d"},u.attributes,u.uniforms,[],u.defines,null)}if(this.border){for(var i=2*this.subdivisions,o=new Float32Array(i),a=0;a<i;a++)o[a]=a;r.borderVB=n.createVertexBuffer(o);for(var s=i,c=s/2,l=new Float32Array(3*s),a=0;a<c;a++){var h=a,d=(a+1)%c;l[6*a+0]=c+d,l[6*a+1]=c+h,l[6*a+2]=h,l[6*a+3]=d,l[6*a+4]=c+d,l[6*a+5]=h}r.borderIB=n.createIndexBuffer(l),r.borderIndicesCount=3*s;var u=this.getDataPartEffectInfo(e.Shape2D.SHAPE2D_BORDERPARTID,["index"],null,!0);u&&(r.effectBorderInstanced=n.createEffect("ellipse2d",u.attributes,u.uniforms,[],u.defines,null)),u=this.getDataPartEffectInfo(e.Shape2D.SHAPE2D_BORDERPARTID,["index"],null,!1),r.effectBorder=n.createEffect("ellipse2d",u.attributes,u.uniforms,[],u.defines,null)}return r},i.prototype.createInstanceDataParts=function(){var t=new Array;return this.border&&t.push(new r(e.Shape2D.SHAPE2D_BORDERPARTID)),this.fill&&t.push(new r(e.Shape2D.SHAPE2D_FILLPARTID)),t},i.prototype.refreshInstanceDataPart=function(t){if(!n.prototype.refreshInstanceDataPart.call(this,t))return!1;if(t.id===e.Shape2D.SHAPE2D_BORDERPARTID){var r=t,i=this.actualSize;r.properties=new e.Vector3(i.width,i.height,this.subdivisions)}else if(t.id===e.Shape2D.SHAPE2D_FILLPARTID){var r=t,i=this.actualSize;r.properties=new e.Vector3(i.width,i.height,this.subdivisions)}return!0},i})(e.Shape2D);n._riv0=new e.Vector2(0,0),__decorate([e.modelLevelProperty(e.Shape2D.SHAPE2D_PROPCOUNT+2,(function(e){return i.subdivisionsProperty=e}))],n.prototype,"subdivisions",null),n=i=__decorate([e.className("Ellipse2D","BABYLON")],n),e.Ellipse2D=n;var i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.effectsReady=!1,e.vb=null,e.ib=null,e.instancingAttributes=null,e.texture=null,e.effect=null,e.effectInstanced=null,e}return __extends(n,t),n.prototype.render=function(t,n){if(!this.effectsReady){if(this.effect&&(!this.effect.isReady()||this.effectInstanced&&!this.effectInstanced.isReady()))return!1;this.effectsReady=!0}var i=t.owner.owner,o=i.engine,a=o.getAlphaMode(),s=n.useInstancing?this.effectInstanced:this.effect;o.enableEffect(s),s.setTexture("diffuseSampler",this.texture),o.bindBuffersDirectly(this.vb,this.ib,[1],4,s),n.renderMode!==e.Render2DContext.RenderModeOpaque&&o.setAlphaMode(e.Engine.ALPHA_COMBINE,!0),s.setBool("alphaTest",n.renderMode===e.Render2DContext.RenderModeAlphaTest);var l=n.groupInfoPartData[0];if(n.useInstancing){this.instancingAttributes||(this.instancingAttributes=this.loadInstancingAttributes(r.SPRITE2D_MAINPARTID,s));var u=n.instancedBuffers?n.instancedBuffers[0]:l._partBuffer,c=n.instancedBuffers?n.instancesCount:l._partData.usedElementCount;i._addDrawCallCount(1,n.renderMode),o.updateAndBindInstancesBuffer(u,null,this.instancingAttributes),o.draw(!0,0,6,c),o.unbindInstanceAttributes()}else{i._addDrawCallCount(n.partDataEndIndex-n.partDataStartIndex,n.renderMode);for(var h=n.partDataStartIndex;h<n.partDataEndIndex;h++)this.setupUniforms(s,0,l._partData,h),o.draw(!0,0,6)}return o.setAlphaMode(a,!0),!0},n.prototype.dispose=function(){return!!t.prototype.dispose.call(this)&&(this.vb&&(this._engine._releaseBuffer(this.vb),this.vb=null),this.ib&&(this._engine._releaseBuffer(this.ib),this.ib=null),this.effect=null,this.effectInstanced=null,!0)},n})(e.ModelRenderCache);e.Sprite2DRenderCache=t;var r=i=(function(r){function o(t,n){var o=this;if(n||(n={}),o=r.call(this,n)||this,o.texture=t,o._useSize=!1,o._spriteSize=null!=n.spriteSize?n.spriteSize.clone():null,o._spriteLocation=null!=n.spriteLocation?n.spriteLocation.clone():new e.Vector2(0,0),null!=n.size&&(o.size=n.size),o._updatePositioningState(),o.spriteFrame=0,o.invertY=null!=n.invertY&&n.invertY,o.alignToPixel=null==n.alignToPixel||n.alignToPixel,o.useAlphaFromTexture=!0,o._scale9=null!=n.scale9?n.scale9.clone():null,null==n.spriteSize&&(o.spriteSize=new e.Size(10,10)),null==n.spriteSize||!t.isReady())if(t.isReady()){var a=t.getBaseSize();o.spriteSize=new e.Size(a.width,a.height),o._updateSpriteScaleFactor()}else t.onLoadObservable.add((function(){if(null==n.spriteSize){var r=t.getBaseSize();o.spriteSize=new e.Size(r.width,r.height)}o._updateSpriteScaleFactor(),o._positioningDirty(),o._setLayoutDirty(),o._instanceDirtyFlags|=e.Prim2DBase.originProperty.flagId|i.textureProperty.flagId}));return o}return __extends(o,r),Object.defineProperty(o.prototype,"texture",{get:function(){return this._texture},set:function(e){this._texture=e,this._oldTextureHasAlpha=this._texture&&this.texture.hasAlpha},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"useAlphaFromTexture",{get:function(){return this._useAlphaFromTexture},set:function(e){this._useAlphaFromTexture!==e&&(this._useAlphaFromTexture=e,this._updateRenderMode())},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"size",{get:function(){return null==this._size?this.spriteSize:this.internalGetSize()},set:function(e){this._useSize=null!=e,this.internalSetSize(e),this._updateSpriteScaleFactor()},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"spriteSize",{get:function(){return this._spriteSize},set:function(e){this._spriteSize?this._spriteSize.copyFrom(e):this._spriteSize=e.clone(),this._updateSpriteScaleFactor()},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"spriteLocation",{get:function(){return this._spriteLocation},set:function(e){this._spriteLocation?this._spriteLocation.copyFrom(e):this._spriteLocation=e.clone()},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"spriteFrame",{get:function(){return this._spriteFrame},set:function(e){this._spriteFrame=e},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"invertY",{get:function(){return this._invertY},set:function(e){this._invertY=e},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"isScale9",{get:function(){return null!==this._scale9},enumerable:!0,configurable:!0}),o.prototype.updateLevelBoundingInfo=function(){return e.BoundingInfo2D.CreateFromSizeToRef(this.size,this._levelBoundingInfo),!0},o.prototype.getAnimatables=function(){var e=new Array;return this.texture&&this.texture.animations&&this.texture.animations.length>0&&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;l<u.length;l++){var c=u[l],h=c.loadFile(e);if(h)return void(h.api?(h.api.texture=r,i&&i(h.api)):o&&o(h.errorMsg,h.errorCode))}o&&o("No plugin to load this Atlas Data file format",-1)}),null,null,null,(function(){o&&o("Couldn't load file",-1)})),null},t})();i.plugins=new e.StringDictionary,e.AtlasPictureInfoFactory=i;var o=a=(function(){function t(){}return t.prototype.loadFile=function(t){var i=null,o=0,a=null,s=null;try{var l,u=void 0;try{if(a=JSON.parse(t),l=a.frames,u=a.meta,!l||!u)throw Error("Not a JSON Array file format")}catch(e){return null}s=new n,s.atlasSize=new e.Size(u.size.w,u.size.h),s.subPictures=new e.StringDictionary;for(var c=0,h=l;c<h.length;c++){var d=h[c],p=new r;p.name=d.filename,p.location=new e.Vector2(d.frame.x,s.atlasSize.height-(d.frame.y+d.frame.h)),p.size=new e.Size(d.frame.w,d.frame.h),s.subPictures.add(p.name,p)}}catch(e){i="Unknown Exception: "+e,o=-2}return{api:s,errorMsg:i,errorCode:o}},t})();o=a=__decorate([t("json",new a)],o),e.AtlasLoaderPlugin=t;var a})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e.effectsReady=!1,e.vb=null,e.ib=null,e.instancingAttributes=null,e.fontTexture=null,e.effect=null,e.effectInstanced=null,e.fontPremulAlpha=!1,e}return __extends(r,t),r.prototype.render=function(t,r){if(!this.effectsReady){if(this.effect&&(!this.effect.isReady()||this.effectInstanced&&!this.effectInstanced.isReady()))return!1;this.effectsReady=!0}var i=t.owner.owner,o=i.engine;this.fontTexture.update();var a=r.useInstancing?this.effectInstanced:this.effect;o.enableEffect(a),a.setTexture("diffuseSampler",this.fontTexture),o.bindBuffersDirectly(this.vb,this.ib,[1],4,a);var s,l=this.fontTexture.isSignedDistanceField;l||(s=o.getAlphaMode(),o.setAlphaMode(this.fontPremulAlpha?e.Engine.ALPHA_PREMULTIPLIED:e.Engine.ALPHA_COMBINE,!0));var u=r.groupInfoPartData[0];if(r.useInstancing){this.instancingAttributes||(this.instancingAttributes=this.loadInstancingAttributes(n.TEXT2D_MAINPARTID,a));var c=r.instancedBuffers?r.instancedBuffers[0]:u._partBuffer,h=r.instancedBuffers?r.instancesCount:u._partData.usedElementCount;i._addDrawCallCount(1,r.renderMode),o.updateAndBindInstancesBuffer(c,null,this.instancingAttributes),o.draw(!0,0,6,h),o.unbindInstanceAttributes()}else{i._addDrawCallCount(r.partDataEndIndex-r.partDataStartIndex,r.renderMode);for(var d=r.partDataStartIndex;d<r.partDataEndIndex;d++)this.setupUniforms(a,0,u._partData,d),o.draw(!0,0,6)}return l||o.setAlphaMode(s,!0),!0},r.prototype.dispose=function(){return!!t.prototype.dispose.call(this)&&(this.vb&&(this._engine._releaseBuffer(this.vb),this.vb=null),this.ib&&(this._engine._releaseBuffer(this.ib),this.ib=null),this.fontTexture&&(this.fontTexture.decCachedFontTextureCounter(),this.fontTexture=null),this.effect=null,this.effectInstanced=null,!0)},r})(e.ModelRenderCache);e.Text2DRenderCache=t;var r=(function(e){function t(t,r){return e.call(this,t,r)||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,"textureSize",{get:function(){return null},set:function(e){},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"color",{get:function(){return null},set:function(e){},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"superSampleFactor",{get:function(){return null},set:function(e){},enumerable:!0,configurable:!0}),t})(e.InstanceDataBase);__decorate([e.instanceData()],r.prototype,"topLeftUV",null),__decorate([e.instanceData()],r.prototype,"sizeUV",null),__decorate([e.instanceData()],r.prototype,"textureSize",null),__decorate([e.instanceData()],r.prototype,"color",null),__decorate([e.instanceData()],r.prototype,"superSampleFactor",null),e.Text2DInstanceData=r;var n=i=(function(n){function o(t,r){var o=this;if(r||(r={}),o=n.call(this,r)||this,null!=r.bitmapFontTexture){o._fontTexture=r.bitmapFontTexture,o._fontName=null,o._fontSuperSample=!1,o._fontSDF=!1,o._textureIsPremulAlpha=o._fontTexture.isPremultipliedAlpha;var a=o._fontTexture;null==a||a.isReady()||a.onLoadObservable.add((function(){o._positioningDirty(),o._setLayoutDirty(),o._instanceDirtyFlags|=e.Prim2DBase.originProperty.flagId}))}else o._fontName=null==r.fontName?"12pt Arial":r.fontName,o._fontSuperSample=null!=r.fontSuperSample&&r.fontSuperSample,o._fontSDF=null!=r.fontSignedDistanceField&&r.fontSignedDistanceField;return o._defaultFontColor=null==r.defaultFontColor?new e.Color4(1,1,1,1):r.defaultFontColor.clone(),o._tabulationSize=null==r.tabulationSize?4:r.tabulationSize,o._textureIsPremulAlpha=!0,o._textSize=null,o.text=t,null!=r.size?(o.size=r.size,o._sizeSetByUser=!0):o.size=null,o._useBilinearFiltering=null!=r.useBilinearFiltering?r.useBilinearFiltering:null,o._fontBilinearFiltering=!1,o.alignToPixel=!0,o.textAlignmentH=null==r.textAlignmentH?i.AlignLeft:r.textAlignmentH,o.textAlignmentV=null==r.textAlignmentV?i.AlignTop:r.textAlignmentV,o.textAlignment=null==r.textAlignment?"":r.textAlignment,o._wordWrap=null!=r.wordWrap&&r.wordWrap,o._updateRenderMode(),o}return __extends(o,n),Object.defineProperty(o,"AlignLeft",{get:function(){return i._AlignLeft},enumerable:!0,configurable:!0}),Object.defineProperty(o,"AlignTop",{get:function(){return i._AlignTop},enumerable:!0,configurable:!0}),Object.defineProperty(o,"AlignRight",{get:function(){return i._AlignRight},enumerable:!0,configurable:!0}),Object.defineProperty(o,"AlignBottom",{get:function(){return i._AlignBottom},enumerable:!0,configurable:!0}),Object.defineProperty(o,"AlignCenter",{get:function(){return i._AlignCenter},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"fontName",{get:function(){return this._fontName},set:function(e){if(this._fontName)throw new Error("Font Name change is not supported right now.");this._fontName=e},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"defaultFontColor",{get:function(){return this._defaultFontColor},set:function(e){this._defaultFontColor?this._defaultFontColor.copyFrom(e):this._defaultFontColor=e.clone()},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"text",{get:function(){return this._text},set:function(e){e||(e=""),this._text=e,this._textSize=null,this._sizeSetByUser||(this._size=null,this._actualSize=null),this._updateCharCount();this.textSize},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"size",{get:function(){return null!=this._size?this._size:this.textSize},set:function(e){this.internalSetSize(e)},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"fontSuperSample",{get:function(){return this._fontTexture&&this._fontTexture.isSuperSampled},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"fontSignedDistanceField",{get:function(){return this._fontTexture&&this._fontTexture.isSignedDistanceField},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"textureIsPremulAlpha",{get:function(){return this._textureIsPremulAlpha},set:function(e){this._textureIsPremulAlpha=e},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"isSizeAuto",{get:function(){return!1},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"isVerticalSizeAuto",{get:function(){return!1},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"isHorizontalSizeAuto",{get:function(){return!1},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"textSize",{get:function(){if(!this._textSize){if(!this.owner||!this._text)return i.nullSize;var t=this.fontTexture;if(null==t)return i.nullSize;var r=t.measureText(this._text,this._tabulationSize);r.equals(this._textSize)||(this.onPrimitivePropertyDirty(e.Prim2DBase.sizeProperty.flagId),this._positioningDirty()),this._textSize=r}return this._textSize},enumerable:!0,configurable:!0}),o.prototype.onSetOwner=function(){this._textSize||(this.onPrimitivePropertyDirty(e.Prim2DBase.sizeProperty.flagId),this._setLayoutDirty(),this._positioningDirty(),this._actualSize=null,this._setFlags(e.SmartPropertyPrim.flagLevelBoundingInfoDirty|e.SmartPropertyPrim.flagBoundingInfoDirty))},Object.defineProperty(o.prototype,"fontTexture",{get:function(){return this._fontTexture?this._fontTexture:null==this.fontName||null==this.owner||null==this.owner.scene?null:(this._fontBilinearFiltering=null===this._useBilinearFiltering?this.owner instanceof e.WorldSpaceCanvas2D:this._useBilinearFiltering,this._fontTexture=e.FontTexture.GetCachedFontTexture(this.owner.scene,this.fontName,this._fontSuperSample,this._fontSDF,this._fontBilinearFiltering),this._textureIsPremulAlpha=this._fontTexture.isPremultipliedAlpha,this._fontTexture)},enumerable:!0,configurable:!0}),o.prototype.dispose=function(){return!!n.prototype.dispose.call(this)&&(this._fontTexture&&(e.FontTexture.ReleaseCachedFontTexture(this.owner.scene,this.fontName,this._fontSuperSample,this._fontSDF,this._fontBilinearFiltering),this._fontTexture=null),!0)},o.prototype.updateLevelBoundingInfo=function(){if(!this.owner||!this._text)return!1;var t=this.actualSize;return(0!==t.width||0!==t.height)&&(e.BoundingInfo2D.CreateFromSizeToRef(this.actualSize,this._levelBoundingInfo),!0)},Object.defineProperty(o.prototype,"textAlignment",{get:function(){return this._textAlignment},set:function(e){this._textAlignment=e,this._setTextAlignmentfromString(e)},enumerable:!0,configurable:!0}),o.prototype.levelIntersect=function(e){return!0},o.prototype.createModelRenderCache=function(e){var r=new t(this.owner.engine,e);return r},o.prototype.setupModelRenderCache=function(e){var t=e,r=this.owner.engine;t.fontTexture=this.fontTexture,t.fontTexture.incCachedFontTextureCounter(),t.fontPremulAlpha=this.textureIsPremulAlpha;for(var 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);var s=this.getDataPartEffectInfo(i.TEXT2D_MAINPARTID,["index"],null,!0);return s&&(t.effectInstanced=r.createEffect("text2d",s.attributes,s.uniforms,["diffuseSampler"],s.defines,null)),s=this.getDataPartEffectInfo(i.TEXT2D_MAINPARTID,["index"],null,!1),t.effect=r.createEffect("text2d",s.attributes,s.uniforms,["diffuseSampler"],s.defines,null),t},o.prototype.createInstanceDataParts=function(){return[new r(i.TEXT2D_MAINPARTID,this._charCount)]},o.prototype.beforeRefreshForLayoutConstruction=function(e){if(!this._charCount){var t=this._text;return this.text="A",t}},o.prototype.afterRefreshForLayoutConstruction=function(e,t){void 0!==t&&(this.text=t)},o.prototype.getUsedShaderCategories=function(t){var r=n.prototype.getUsedShaderCategories.call(this,t);return this._fontSDF&&r.push(i.TEXT2D_CATEGORY_SDF),this._fontTexture instanceof e.FontTexture&&r.push(i.TEXT2D_CATEGORY_FONTTEXTURE),r},o.prototype.refreshInstanceDataPart=function(t){if(!n.prototype.refreshInstanceDataPart.call(this,t))return!1;if(t.id===i.TEXT2D_MAINPARTID){var r=t,o=this.fontTexture,a=o;if(!a)return!1;var s=a.isSuperSampled?.5:1,l=a.getSize(),u=e.Vector2.Zero(),c=o.lineHeight;r.dataElementCount=this._charCount,r.curElement=0;for(var h=[],d=[],p=[],f=0,g=this.contentArea.width,_=this.contentArea.height,y=0,m=0,v=0,b=this.text,P=this._tabulationSize*a.spaceWidth,C=0;C<b.length;C++){var S=b[C];if(f++,d[C]=0,this._isWhiteSpaceCharVert(S))h.push(u.x),p.push(f-1),f=1,u.x=0,m>0&&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;E<h.length;E++)h[E]>w&&(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;V<h.length;V++){var z=p[V],N=h[V];B==i.AlignRight?u.x+=w-N:B==i.AlignCenter&&(u.x+=.5*(w-N));for(var A=0;A<z;A++){var S=b[T],x=d[T];if("\t"!==S&&!this._isWhiteSpaceCharVert(S)){var D=a.getChar(S),U=new e.Vector2(Math.floor(u.x+D.xOffset),Math.floor(u.y+D.yOffset));this.updateInstanceDataPart(r,U),r.topLeftUV=D.topLeftUV;var G=D.bottomRightUV.subtract(D.topLeftUV);r.sizeUV=G,r.textureSize=new e.Vector2(l.width,l.height),r.color=this.defaultFontColor,r.superSampleFactor=s,++r.curElement}u.x+=Math.floor(x),T++}u.x=F,u.y-=M}}return!0},o.prototype._isWhiteSpaceCharHoriz=function(e){if(" "===e||"\t"===e)return!0},o.prototype._isWhiteSpaceCharVert=function(e){if("\n"===e||"\r"===e)return!0},o.prototype._updateCharCount=function(){for(var e=0,t=0,r=this._text;t<r.length;t++){var n=r[t];"\r"===n||"\n"===n||"\t"===n||n<" "||++e}this._charCount=e},o.prototype._setTextAlignmentfromString=function(e){for(var t=e.trim().split(","),r=0,n=t;r<n.length;r++){var i=n[r];i=i.toLocaleLowerCase().trim();var o=i.indexOf("h:");o===-1&&(o=i.indexOf("horizontal:")),o===-1?(o=i.indexOf("v:"),o===-1&&(o=i.indexOf("vertical:")),o===-1||(i=i.substr(i.indexOf(":")+1),this._setTextAlignmentVertical(i))):(i=i.substr(i.indexOf(":")+1),this._setTextAlignmentHorizontal(i))}},o.prototype._setTextAlignmentHorizontal=function(e){var t=e.trim().toLocaleLowerCase();switch(t){case"left":return void(this.textAlignmentH=i.AlignLeft);case"right":return void(this.textAlignmentH=i.AlignRight);case"center":return void(this.textAlignmentH=i.AlignCenter)}},o.prototype._setTextAlignmentVertical=function(e){var t=e.trim().toLocaleLowerCase();switch(t){case"top":return void(this.textAlignmentV=i.AlignTop);case"bottom":return void(this.textAlignmentV=i.AlignBottom);case"center":return void(this.textAlignmentV=i.AlignCenter)}},o.prototype._useTextureAlpha=function(){return this._fontSDF},o.prototype._shouldUseAlphaFromTexture=function(){return!this._fontSDF},o})(e.RenderablePrim2D);n.TEXT2D_MAINPARTID=1,n.TEXT2D_CATEGORY_SDF="SignedDistanceField",n.TEXT2D_CATEGORY_FONTTEXTURE="FontTexture",n._AlignLeft=1,n._AlignTop=1,n._AlignRight=2,n._AlignBottom=2,n._AlignCenter=3,__decorate([e.modelLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+1,(function(e){return i.fontProperty=e}),!1,!0)],n.prototype,"fontName",null),__decorate([e.dynamicLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+2,(function(e){return i.defaultFontColorProperty=e}))],n.prototype,"defaultFontColor",null),__decorate([e.instanceLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+3,(function(e){return i.textProperty=e}),!1,!0)],n.prototype,"text",null),__decorate([e.instanceLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+4,(function(e){return i.sizeProperty=e}))],n.prototype,"size",null),__decorate([e.modelLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+5,(function(e){return i.fontSuperSampleProperty=e}),!1,!1)],n.prototype,"fontSuperSample",null),__decorate([e.modelLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+6,(function(e){return i.fontSignedDistanceFieldProperty=e}),!1,!1)],n.prototype,"fontSignedDistanceField",null),__decorate([e.instanceLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+7,(function(e){return i.textureIsPremulAlphaProperty=e}))],n.prototype,"textureIsPremulAlpha",null),__decorate([e.modelLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+8,(function(e){return i.fontTextureProperty=e}))],n.prototype,"fontTexture",null),n=i=__decorate([e.className("Text2D","BABYLON")],n),e.Text2D=n;var i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(e,r){var n=t.call(this,e,r)||this;return n.effectsReady=!1,n.fillVB=null,n.fillIB=null,n.fillIndicesCount=0,n.instancingFillAttributes=null,n.effectFill=null,n.effectFillInstanced=null,n.borderVB=null,n.borderIB=null,n.borderIndicesCount=0,n.instancingBorderAttributes=null,n.effectBorder=null,n.effectBorderInstanced=null,n}return __extends(r,t),r.prototype.render=function(t,r){if(!this.effectsReady){if(this.effectFill&&(!this.effectFill.isReady()||this.effectFillInstanced&&!this.effectFillInstanced.isReady())||this.effectBorder&&(!this.effectBorder.isReady()||this.effectBorderInstanced&&!this.effectBorderInstanced.isReady()))return!1;this.effectsReady=!0}var n=t.owner.owner,i=n.engine;i.setState(!1,void 0,!0);var o=0;this.effectFill&&this.effectBorder&&(o=i.getDepthFunction(),i.setDepthFunctionToLessOrEqual());var a=i.getAlphaMode();if(this.effectFill){var s=t.partIndexFromId.get(e.Shape2D.SHAPE2D_FILLPARTID.toString()),l=r.groupInfoPartData[s];r.renderMode!==e.Render2DContext.RenderModeOpaque&&i.setAlphaMode(e.Engine.ALPHA_COMBINE,!0);var u=r.useInstancing?this.effectFillInstanced:this.effectFill;if(i.enableEffect(u),i.bindBuffersDirectly(this.fillVB,this.fillIB,[2],8,u),r.useInstancing){this.instancingFillAttributes||(this.instancingFillAttributes=this.loadInstancingAttributes(e.Shape2D.SHAPE2D_FILLPARTID,u));var c=r.instancedBuffers?r.instancedBuffers[s]:l._partBuffer,h=r.instancedBuffers?r.instancesCount:l._partData.usedElementCount;n._addDrawCallCount(1,r.renderMode),i.updateAndBindInstancesBuffer(c,null,this.instancingFillAttributes),i.draw(!0,0,this.fillIndicesCount,h),i.unbindInstanceAttributes()}else{n._addDrawCallCount(r.partDataEndIndex-r.partDataStartIndex,r.renderMode);for(var d=r.partDataStartIndex;d<r.partDataEndIndex;d++)this.setupUniforms(u,s,l._partData,d),i.draw(!0,0,this.fillIndicesCount)}}if(this.effectBorder){var s=t.partIndexFromId.get(e.Shape2D.SHAPE2D_BORDERPARTID.toString()),l=r.groupInfoPartData[s];r.renderMode!==e.Render2DContext.RenderModeOpaque&&i.setAlphaMode(e.Engine.ALPHA_COMBINE,!0);var u=r.useInstancing?this.effectBorderInstanced:this.effectBorder;if(i.enableEffect(u),i.bindBuffersDirectly(this.borderVB,this.borderIB,[2],8,u),r.useInstancing){this.instancingBorderAttributes||(this.instancingBorderAttributes=this.loadInstancingAttributes(e.Shape2D.SHAPE2D_BORDERPARTID,u));var c=r.instancedBuffers?r.instancedBuffers[s]:l._partBuffer,h=r.instancedBuffers?r.instancesCount:l._partData.usedElementCount;n._addDrawCallCount(1,r.renderMode),i.updateAndBindInstancesBuffer(c,null,this.instancingBorderAttributes),i.draw(!0,0,this.borderIndicesCount,h),i.unbindInstanceAttributes()}else{n._addDrawCallCount(r.partDataEndIndex-r.partDataStartIndex,r.renderMode);for(var d=r.partDataStartIndex;d<r.partDataEndIndex;d++)this.setupUniforms(u,s,l._partData,d),i.draw(!0,0,this.borderIndicesCount)}}return i.setAlphaMode(a,!0),this.effectFill&&this.effectBorder&&i.setDepthFunction(o),!0},r.prototype.dispose=function(){return!!t.prototype.dispose.call(this)&&(this.fillVB&&(this._engine._releaseBuffer(this.fillVB),this.fillVB=null),this.fillIB&&(this._engine._releaseBuffer(this.fillIB),this.fillIB=null),this.effectFill=null,this.effectFillInstanced=null,this.effectBorder=null,this.effectBorderInstanced=null,this.borderVB&&(this._engine._releaseBuffer(this.borderVB),this.borderVB=null),this.borderIB&&(this._engine._releaseBuffer(this.borderIB),this.borderIB=null),!0)},r})(e.ModelRenderCache);e.Lines2DRenderCache=t;var r=(function(e){function t(t){return e.call(this,t,1)||this}return __extends(t,e),Object.defineProperty(t.prototype,"boundingMin",{get:function(){return null},set:function(e){},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"boundingMax",{get:function(){return null},set:function(e){},enumerable:!0,configurable:!0}),t})(e.Shape2DInstanceData);__decorate([e.instanceData(e.Shape2D.SHAPE2D_CATEGORY_FILLGRADIENT)],r.prototype,"boundingMin",null),__decorate([e.instanceData(e.Shape2D.SHAPE2D_CATEGORY_FILLGRADIENT)],r.prototype,"boundingMax",null),e.Lines2DInstanceData=r;var n=i=(function(n){function o(e,t){var r=this;t||(t={}),r=n.call(this,t)||this,r._fillVB=null,r._fillIB=null,r._borderVB=null,r._borderIB=null,r._boundingMin=null,r._boundingMax=null;var i=null==t.fillThickness?1:t.fillThickness,o=null==t.startCap?0:t.startCap,a=null==t.endCap?0:t.endCap,s=null!=t.closed&&t.closed;return r.points=e,r.fillThickness=i,r.startCap=o,r.endCap=a,r.closed=s,r}return __extends(o,n),Object.defineProperty(o,"NoCap",{get:function(){return i._noCap},enumerable:!0,configurable:!0}),Object.defineProperty(o,"RoundCap",{get:function(){return i._roundCap},enumerable:!0,configurable:!0}),Object.defineProperty(o,"TriangleCap",{get:function(){return i._triangleCap},enumerable:!0,configurable:!0}),Object.defineProperty(o,"SquareAnchorCap",{get:function(){return i._squareAnchorCap},enumerable:!0,configurable:!0}),Object.defineProperty(o,"RoundAnchorCap",{get:function(){return i._roundAnchorCap},enumerable:!0,configurable:!0}),Object.defineProperty(o,"DiamondAnchorCap",{get:function(){return i._diamondAnchorCap},enumerable:!0,configurable:!0}),Object.defineProperty(o,"ArrowCap",{get:function(){return i._arrowCap},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"points",{get:function(){return this._points},set:function(e){this._points=e,this._primTriArrayDirty=!0,this._boundingBoxDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"fillThickness",{get:function(){return this._fillThickness},set:function(e){this._fillThickness=e},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"closed",{get:function(){return this._closed},set:function(e){this._closed=e},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"startCap",{get:function(){return this._startCap},set:function(e){this._startCap=e},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"endCap",{get:function(){return this._endCap},set:function(e){this._endCap=e},enumerable:!0,configurable:!0}),o.prototype.levelIntersect=function(e){var t=e._localPickPosition;return this.updateTriArray(),this._primTriArray.doesContain(t)},Object.defineProperty(o.prototype,"boundingMin",{get:function(){return this._boundingMin||this._computeLines2D(),this._boundingMin},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"boundingMax",{get:function(){return this._boundingMax||this._computeLines2D(),this._boundingMax},enumerable:!0,configurable:!0}),o.prototype.getUsedShaderCategories=function(t){var r=n.prototype.getUsedShaderCategories.call(this,t),i=r.indexOf(e.Shape2D.SHAPE2D_CATEGORY_BORDER);return i!==-1&&r.splice(i,1),r},o.prototype.updateLevelBoundingInfo=function(){return this._boundingMin||this._computeLines2D(),e.BoundingInfo2D.CreateFromMinMaxToRef(this._boundingMin.x,this._boundingMax.x,this._boundingMin.y,this._boundingMax.y,this._levelBoundingInfo),!0},o.prototype.createModelRenderCache=function(e){var r=new t(this.owner.engine,e);return r},o.prototype._perp=function(e,t){t.x=e.y,t.y=-e.x},o.prototype._direction=function(e,t,r){e.subtractToRef(t,r),r.normalize()},o.prototype._computeMiter=function(t,r,n,o){return n.addToRef(o,t),t.normalize(),r.x=-t.y,r.y=t.x,i._miterTps.x=-n.y,i._miterTps.y=n.x,1/e.Vector2.Dot(r,i._miterTps)},o.prototype._intersect=function(e,t,r,n,i,o,a,s){var l=(e-r)*(o-s)-(t-n)*(i-a);if(0===l)return!1;var u=((i-a)*(e*n-t*r)-(e-r)*(i*s-o*a))/l;return!(u<Math.min(e,r)||u>Math.max(e,r))&&!(u<Math.min(i,a)||u>Math.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;V<d/2;V++){var P=this._storeVertex(t,r,2*V+0,a,f,new e.Vector2(Math.cos(F)*g,Math.sin(F)*g),null),C=this._storeVertex(t,r,2*V+1,a,f,new e.Vector2(Math.cos(F)*(g+m),Math.sin(F)*(g+m)),h);V>0&&(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;V<d/2;V++){var C=this._storeVertex(t,r,V+1,a,f,new e.Vector2(Math.cos(F)*g,Math.sin(F)*g),h);this._storeIndex(n,o,3*V+0,z),this._storeIndex(n,o,3*V+1,C-1),this._storeIndex(n,o,3*V+2,C),F+=M}}break;case i.SquareAnchorCap:var v=0,z=y?null:h,P=this._storeVertex(t,r,v++,a,f,new e.Vector2(0,_),z),C=this._storeVertex(t,r,v++,a,f,new e.Vector2(2*_,_),z),S=this._storeVertex(t,r,v++,a,f,new e.Vector2(2*_,-_),z),D=this._storeVertex(t,r,v++,a,f,new e.Vector2(0,-_),z);
if(y){var A=this._storeVertex(t,r,v++,a,f,new e.Vector2(0,g+m),null),O=this._storeVertex(t,r,v++,a,f,new e.Vector2(-m,g+m),h),R=this._storeVertex(t,r,v++,a,f,new e.Vector2(-m,_+m),h),E=this._storeVertex(t,r,v++,a,f,new e.Vector2(2*_+m,_+m),h),L=this._storeVertex(t,r,v++,a,f,new e.Vector2(2*_+m,-(_+m)),h),T=this._storeVertex(t,r,v++,a,f,new e.Vector2(-m,-(_+m)),h),B=this._storeVertex(t,r,v++,a,f,new e.Vector2(-m,-(g+m)),h),w=this._storeVertex(t,r,v++,a,f,new e.Vector2(0,-(g+m)),null),b=0;this._storeIndex(n,o,b++,O),this._storeIndex(n,o,b++,P),this._storeIndex(n,o,b++,A),this._storeIndex(n,o,b++,O),this._storeIndex(n,o,b++,R),this._storeIndex(n,o,b++,P),this._storeIndex(n,o,b++,P),this._storeIndex(n,o,b++,R),this._storeIndex(n,o,b++,E),this._storeIndex(n,o,b++,P),this._storeIndex(n,o,b++,E),this._storeIndex(n,o,b++,C),this._storeIndex(n,o,b++,C),this._storeIndex(n,o,b++,E),this._storeIndex(n,o,b++,L),this._storeIndex(n,o,b++,C),this._storeIndex(n,o,b++,L),this._storeIndex(n,o,b++,S),this._storeIndex(n,o,b++,S),this._storeIndex(n,o,b++,L),this._storeIndex(n,o,b++,T),this._storeIndex(n,o,b++,S),this._storeIndex(n,o,b++,T),this._storeIndex(n,o,b++,D),this._storeIndex(n,o,b++,T),this._storeIndex(n,o,b++,B),this._storeIndex(n,o,b++,D),this._storeIndex(n,o,b++,B),this._storeIndex(n,o,b++,w),this._storeIndex(n,o,b++,D)}else this._storeIndex(n,o,0,P),this._storeIndex(n,o,1,C),this._storeIndex(n,o,2,S),this._storeIndex(n,o,3,P),this._storeIndex(n,o,4,S),this._storeIndex(n,o,5,D);break;case i.RoundAnchorCap:var N=Math.sqrt(_*_-g*g),U=new e.Vector2(N,0),F=e.Tools.ToRadians(-150),M=e.Tools.ToRadians(300)/(d-1);if(y)for(var b=0,V=0;V<d;V++){var P=this._storeVertex(t,r,2*V+0,a,f,new e.Vector2(N+Math.cos(F)*_,Math.sin(F)*_),null),C=this._storeVertex(t,r,2*V+1,a,f,new e.Vector2(N+Math.cos(F)*(_+m),Math.sin(F)*(_+m)),h);V>0&&(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;V<d;V++){var C=this._storeVertex(t,r,V+1,a,f,new e.Vector2(N+Math.cos(F)*_,Math.sin(F)*_),h);this._storeIndex(n,o,3*V+0,z),this._storeIndex(n,o,3*V+1,C-1),this._storeIndex(n,o,3*V+2,C),F+=M}this._storeIndex(n,o,3*d+0,z),this._storeIndex(n,o,3*d+1,z+1),this._storeIndex(n,o,3*d+2,z+d)}break;case i.DiamondAnchorCap:var v=0,z=y?null:h,P=this._storeVertex(t,r,v++,a,f,new e.Vector2(0,g),z),C=this._storeVertex(t,r,v++,a,f,new e.Vector2(g,_),z),S=this._storeVertex(t,r,v++,a,f,new e.Vector2(3*g,0),z),D=this._storeVertex(t,r,v++,a,f,new e.Vector2(g,-_),z),A=this._storeVertex(t,r,v++,a,f,new e.Vector2(0,-g),z);if(y){var x=Math.sqrt(m*m*2),O=this._storeVertex(t,r,v++,a,f,new e.Vector2(-x,g),h),R=this._storeVertex(t,r,v++,a,f,new e.Vector2(g,_+x),h),E=this._storeVertex(t,r,v++,a,f,new e.Vector2(3*g+x,0),h),L=this._storeVertex(t,r,v++,a,f,new e.Vector2(g,-(_+x)),h),T=this._storeVertex(t,r,v++,a,f,new e.Vector2(-x,-g),h),b=0;this._storeIndex(n,o,b++,O),this._storeIndex(n,o,b++,R),this._storeIndex(n,o,b++,P),this._storeIndex(n,o,b++,P),this._storeIndex(n,o,b++,R),this._storeIndex(n,o,b++,C),this._storeIndex(n,o,b++,C),this._storeIndex(n,o,b++,R),this._storeIndex(n,o,b++,E),this._storeIndex(n,o,b++,C),this._storeIndex(n,o,b++,E),this._storeIndex(n,o,b++,S),this._storeIndex(n,o,b++,S),this._storeIndex(n,o,b++,E),this._storeIndex(n,o,b++,L),this._storeIndex(n,o,b++,S),this._storeIndex(n,o,b++,L),this._storeIndex(n,o,b++,D),this._storeIndex(n,o,b++,D),this._storeIndex(n,o,b++,L),this._storeIndex(n,o,b++,T),this._storeIndex(n,o,b++,D),this._storeIndex(n,o,b++,T),this._storeIndex(n,o,b++,A)}else this._storeIndex(n,o,0,P),this._storeIndex(n,o,1,C),this._storeIndex(n,o,2,S),this._storeIndex(n,o,3,P),this._storeIndex(n,o,4,S),this._storeIndex(n,o,5,A),this._storeIndex(n,o,6,A),this._storeIndex(n,o,7,S),this._storeIndex(n,o,8,D)}return null},o.prototype._buildLine=function(t,r,n,i){var o=e.Vector2.Zero(),a=e.Vector2.Zero(),s=e.Vector2.Zero(),l=e.Vector2.Zero(),u=null;this.closed&&this.points.push(this.points[0]);for(var c=this.points.length,h=1;h<c;h++){var d=this.points[h-1],p=this.points[h],f=h<this.points.length-1?this.points[h+1]:null;if(this._direction(p,d,o),u||(u=e.Vector2.Zero(),this._perp(o,u)),1===h&&this._store(t,r,0,c,this.points[0],u,n,i),f){this._direction(f,p,a);var g=this._computeMiter(s,l,o,a);this._store(t,r,h,c,this.points[h],l,g*n,g*i,h-1)}else this._perp(o,u),this._store(t,r,h,c,this.points[h],u,n,i,h-1)}if(this.points.length>2&&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;g<p;g+=2)f[3*g+0]=g+0,f[3*g+1]=g+1,f[3*g+2]=(g+2)%d,f[3*g+3]=g+1,f[3*g+4]=(g+3)%d,f[3*g+5]=(g+2)%d;this._buildCap(u,2*s*2,f,3*p,this.points[0],this.fillThickness,null,this.startCap,i._startDir,this.border?null:r),this._buildCap(u,2*s*2+o.vbsize,f,3*p+o.ibsize,this.points[h-1],this.fillThickness,null,this.endCap,i._endDir,this.border?null:r)}if(this.border){var o=this._getCapSize(this.startCap,!0),a=this._getCapSize(this.endCap,!0),s=this.points.length,l=2*s*2*2+o.vbsize+a.vbsize;this._borderVB=new Float32Array(l);var u=this._borderVB,c=this.fillThickness/2,_=this.borderThickness,h=this.points.length;this._buildLine(u,t,c,_);var d=2*h*2,p=2*(s-(this.closed?0:1))*2;this._borderIB=new Float32Array(3*p+o.ibsize+a.ibsize);for(var f=this._borderIB,g=0;g<p;g+=4)f[3*g+0]=g+0,f[3*g+1]=g+2,f[3*g+2]=(g+6)%d,f[3*g+3]=g+0,f[3*g+4]=(g+6)%d,f[3*g+5]=(g+4)%d,f[3*g+6]=g+3,f[3*g+7]=g+1,f[3*g+8]=(g+5)%d,f[3*g+9]=g+3,f[3*g+10]=(g+5)%d,f[3*g+11]=(g+7)%d;this._buildCap(u,2*s*2*2,f,3*p,this.points[0],this.fillThickness,this.borderThickness,this.startCap,i._startDir,r),this._buildCap(u,2*s*2*2+o.vbsize,f,3*p+o.ibsize,this.points[h-1],this.fillThickness,this.borderThickness,this.endCap,i._endDir,n)}var y;r.length>0&&(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;g<P;g++)i._curA.copyFrom(t[g%v*2+0]),i._curB.copyFrom(t[g%v*2+1]),b.storeTriangle(C++,i._prevA,i._prevB,i._curA),b.storeTriangle(C++,i._curA,i._prevB,i._curB),i._prevA.x=i._curA.x,i._prevA.y=i._curA.y,i._prevB.x=i._curB.x,i._prevB.y=i._curB.y;var S=function(e,t){for(var r=e.length,n=0;n<r;n+=3)i._curA.x=t[2*e[n+0]+0],i._curA.y=t[2*e[n+0]+1],i._curB.copyFrom(i._curA),i._curA.x=t[2*e[n+1]+0],i._curA.y=t[2*e[n+1]+1],i._prevA.copyFrom(i._curA),i._curA.x=t[2*e[n+2]+0],i._curA.y=t[2*e[n+2]+1],i._prevB.copyFrom(i._curA),b.storeTriangle(C++,i._prevA,i._prevB,i._curB);return!1};y&&(y&&S(y,r),m&&S(m,n)),this._primTriArrayDirty=!1;var D=this._boundingMax.subtract(this._boundingMin);this._size||(this._size=new e.Size(D.x,D.y),this._updatePositioningState()),this._size.width=D.x,this._size.height=D.y,this._actualSize=null},Object.defineProperty(o.prototype,"size",{get:function(){return null==this._size&&this._computeLines2D(),this._size},enumerable:!0,configurable:!0}),o.prototype.createInstanceDataParts=function(){var t=new Array;return this.border&&t.push(new r(e.Shape2D.SHAPE2D_BORDERPARTID)),this.fill&&t.push(new r(e.Shape2D.SHAPE2D_FILLPARTID)),t},o.prototype.applyActualScaleOnTransform=function(){return!0},o.prototype.refreshInstanceDataPart=function(t){if(!n.prototype.refreshInstanceDataPart.call(this,t))return!1;if(t.id===e.Shape2D.SHAPE2D_BORDERPARTID){var r=t;this.border instanceof e.GradientColorBrush2D&&(r.boundingMin=this.boundingMin,r.boundingMax=this.boundingMax)}else if(t.id===e.Shape2D.SHAPE2D_FILLPARTID){var r=t;this.fill instanceof e.GradientColorBrush2D&&(r.boundingMin=this.boundingMin,r.boundingMax=this.boundingMax)}return!0},o})(e.Shape2D);n._prevA=e.Vector2.Zero(),n._prevB=e.Vector2.Zero(),n._curA=e.Vector2.Zero(),n._curB=e.Vector2.Zero(),n._miterTps=e.Vector2.Zero(),n._startDir=e.Vector2.Zero(),n._endDir=e.Vector2.Zero(),n._tpsV=e.Vector2.Zero(),n._noCap=0,n._roundCap=1,n._triangleCap=2,n._squareAnchorCap=3,n._roundAnchorCap=4,n._diamondAnchorCap=5,n._arrowCap=6,n._roundCapSubDiv=36,__decorate([e.modelLevelProperty(e.Shape2D.SHAPE2D_PROPCOUNT+1,(function(e){return i.pointsProperty=e}))],n.prototype,"points",null),__decorate([e.modelLevelProperty(e.Shape2D.SHAPE2D_PROPCOUNT+2,(function(e){return i.fillThicknessProperty=e}))],n.prototype,"fillThickness",null),__decorate([e.modelLevelProperty(e.Shape2D.SHAPE2D_PROPCOUNT+3,(function(e){return i.closedProperty=e}))],n.prototype,"closed",null),__decorate([e.modelLevelProperty(e.Shape2D.SHAPE2D_PROPCOUNT+4,(function(e){return i.startCapProperty=e}))],n.prototype,"startCap",null),__decorate([e.modelLevelProperty(e.Shape2D.SHAPE2D_PROPCOUNT+5,(function(e){return i.endCapProperty=e}))],n.prototype,"endCap",null),n=i=__decorate([e.className("Lines2D","BABYLON")],n),e.Lines2D=n;var i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._modelCache=new e.StringDictionary}return t.prototype.GetOrAddModelCache=function(e,t){return this._modelCache.getOrAddWithFactory(e,t)},t.prototype.DisposeModelRenderCache=function(e){return!!e.isDisposed&&(this._modelCache.remove(e.modelKey),!0)},t})();e.Canvas2DEngineBoundData=t;var r=o=(function(r){function n(n,i){var a=r.call(this,i)||this;a.worldSpaceToNodeLocal=function(t){var r=a._worldSpaceNode;if(r){var n=r.getWorldMatrix().clone();n.invert();var i=a.unitScaleFactor,o=e.Vector3.TransformCoordinates(t,n),s=new e.Vector2(o.x,o.y),l=a.actualSize;return s.x+=l.width/i*.5,s.y+=l.height/i*.5,s.x*=i,s.y*=i,s}},a.worldSpaceCacheChanged=function(){var t=a.worldSpaceCanvasNode,r=e.VertexData.ExtractFromMesh(t);r.uvs=new Float32Array(8);var n=t.material,i=a._renderableData._cacheTexture;n.diffuseTexture!==i&&(n.diffuseTexture=i,i.hasAlpha=!0);for(var o=a._renderableData._cacheNodeUVs,s=0;s<4;s++)r.uvs[2*s+0]=o[s].x,r.uvs[2*s+1]=o[s].y;r.applyToMesh(t)},a._notifDebugMode=!1,a.minPartCountToUseInstancedArray=5,a._mapCounter=0,a._cachedCanvasGroup=null,a._renderingGroupObserver=null,a._beforeRenderObserver=null,a._afterRenderObserver=null,a._profileInfoText=null,e.Prim2DBase._isCanvasInit=!1,i||(i={}),a._cachingStrategy!==o.CACHESTRATEGY_TOPLEVELGROUPS&&(a._background=new e.Rectangle2D({parent:a,id:"###CANVAS BACKGROUND###",size:i.size}),a._background.zOrder=1,a._background.isPickable=!1,a._background.origin=e.Vector2.Zero(),a._background.levelVisible=!1,null!=i.backgroundRoundRadius&&(a.backgroundRoundRadius=i.backgroundRoundRadius),null!=i.backgroundBorder&&("string"==typeof i.backgroundBorder?a.backgroundBorder=o.GetBrushFromString(i.backgroundBorder):a.backgroundBorder=i.backgroundBorder),null!=i.backgroundBorderThickNess&&(a.backgroundBorderThickness=i.backgroundBorderThickNess),null!=i.backgroundFill&&("string"==typeof i.backgroundFill?a.backgroundFill=o.GetBrushFromString(i.backgroundFill):a.backgroundFill=i.backgroundFill),a.propertyChanged.add((function(e,t){"size"===e.propertyName&&(a._background.size=a.size)}),e.Group2D.sizeProperty.flagId),a._background._patchHierarchy(a));var s=n.getEngine();a.__engineData=s.getOrAddExternalDataWithFactory("__BJSCANVAS2D__",(function(e){return new t})),a._primPointerInfo=new e.PrimitivePointerInfo,a._capturedPointers=new e.StringDictionary,a._pickStartingPosition=e.Vector2.Zero(),a._hierarchyLevelMaxSiblingCount=50,a._hierarchyDepth=0,a._zOrder=0,a._zMax=1,a._scene=n,a._engine=s,a._renderingSize=new e.Size(0,0),a._curHWScale=0,a._canvasLevelScale=new e.Vector2(1,1),a._designSize=i.designSize||null,a._designUseHorizAxis=i.designUseHorizAxis===!0,a._trackedGroups||(a._trackedGroups=new Array),a._maxAdaptiveWorldSpaceCanvasSize=null,a._groupCacheMaps=new e.StringDictionary,a._patchHierarchy(a);var l=null==i.enableInteraction||i.enableInteraction;if(a._fitRenderingDevice=!i.size,i.size||(i.size=new e.Size(s.getRenderWidth(),s.getRenderHeight())),n.onDisposeObservable.add((function(e,t){a.dispose()})),a._isScreenSpace)if(i.renderingPhase){if(!i.renderingPhase.camera||null==i.renderingPhase.renderingGroupID)throw Error("You have to specify a valid camera and renderingGroup");a._renderingGroupObserver=a._scene.onRenderingGroupObservable.add((function(t,r){a._scene.activeCamera===i.renderingPhase.camera&&t.renderStage===e.RenderingGroupInfo.STAGE_POSTTRANSPARENT&&(a._engine.clear(null,!1,!0,!0),e.C2DLogging._startFrameRender(),a._render(),e.C2DLogging._endFrameRender())}),Math.pow(2,i.renderingPhase.renderingGroupID))}else a._afterRenderObserver=a._scene.onAfterRenderObservable.add((function(t,r){a._engine.clear(null,!1,!0,!0),e.C2DLogging._startFrameRender(),a._render(),e.C2DLogging._endFrameRender()}));else a._beforeRenderObserver=a._scene.onBeforeRenderObservable.add((function(t,r){e.C2DLogging._startFrameRender(),a._render(),e.C2DLogging._endFrameRender()}));if(a._supprtInstancedArray=null!==a._engine.getCaps().instancedArrays,a._setupInteraction(l),i.enableCollisionManager){var u=i.collisionManagerUseBorders;a._primitiveCollisionManager=null==i.customCollisionManager?e.PrimitiveCollisionManagerBase.allocBasicPCM(a,u):i.customCollisionManager(a,u)}return o._INSTANCES.push(a),a}return __extends(n,r),Object.defineProperty(n.prototype,"drawCallsOpaqueCounter",{get:function(){return this._drawCallsOpaqueCounter||(this._drawCallsOpaqueCounter=new e.PerfCounter),this._drawCallsOpaqueCounter},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"drawCallsAlphaTestCounter",{get:function(){return this._drawCallsAlphaTestCounter||(this._drawCallsAlphaTestCounter=new e.PerfCounter),this._drawCallsAlphaTestCounter},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"drawCallsTransparentCounter",{get:function(){return this._drawCallsTransparentCounter||(this._drawCallsTransparentCounter=new e.PerfCounter),this._drawCallsTransparentCounter},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"groupRenderCounter",{get:function(){return this._groupRenderCounter||(this._groupRenderCounter=new e.PerfCounter),this._groupRenderCounter},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"updateTransparentDataCounter",{get:function(){return this._updateTransparentDataCounter||(this._updateTransparentDataCounter=new e.PerfCounter),this._updateTransparentDataCounter},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"updateCachedStateCounter",{get:function(){return this._updateCachedStateCounter||(this._updateCachedStateCounter=new e.PerfCounter),this._updateCachedStateCounter},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"updateLayoutCounter",{get:function(){return this._updateLayoutCounter||(this._updateLayoutCounter=new e.PerfCounter),this._updateLayoutCounter},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"updatePositioningCounter",{get:function(){return this._updatePositioningCounter||(this._updatePositioningCounter=new e.PerfCounter),this._updatePositioningCounter},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"updateLocalTransformCounter",{get:function(){return this._updateLocalTransformCounter||(this._updateLocalTransformCounter=new e.PerfCounter),this._updateLocalTransformCounter},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"updateGlobalTransformCounter",{get:function(){return this._updateGlobalTransformCounter||(this._updateGlobalTransformCounter=new e.PerfCounter),this._updateGlobalTransformCounter},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"boundingInfoRecomputeCounter",{get:function(){return this._boundingInfoRecomputeCounter||(this._boundingInfoRecomputeCounter=new e.PerfCounter),this._boundingInfoRecomputeCounter},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"layoutBoundingInfoUpdateCounter",{get:function(){return this._layoutBoundingInfoUpdateCounter||(this._layoutBoundingInfoUpdateCounter=new e.PerfCounter),this._layoutBoundingInfoUpdateCounter},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"canvasRenderTimeCounter",{get:function(){return this._canvasRenderTimeCounter||(this._canvasRenderTimeCounter=new e.PerfCounter),this._canvasRenderTimeCounter},enumerable:!0,configurable:!0}),Object.defineProperty(n,"instances",{get:function(){return o._INSTANCES},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"primitiveCollisionManager",{get:function(){return this._primitiveCollisionManager},enumerable:!0,configurable:!0}),n.prototype._canvasPreInit=function(e){var t=null==e.cachingStrategy?o.CACHESTRATEGY_DONTCACHE:e.cachingStrategy;this._cachingStrategy=t,this._isScreenSpace=null==e.isScreenSpace||e.isScreenSpace,this._hierarchyDepth=0},n.prototype._setupInteraction=function(e){var t=this;if(e!==this._interactionEnabled)if(this._interactionEnabled=e,this._isScreenSpace){if(!e)return void(this._scenePrePointerObserver&&(this.scene.onPrePointerObservable.remove(this._scenePrePointerObserver),this._scenePrePointerObserver=null));this._scenePrePointerObserver=this.scene.onPrePointerObservable.add((function(e,r){t.isVisible!==!1&&t._handlePointerEventForInteraction(e,e.localPosition,r)}))}else{var r=this.scene;e?(r.constantlyUpdateMeshUnderPointer=!0,this._scenePointerObserver=r.onPointerObservable.add((function(e,r){if(t.isVisible!==!1)if(e.pickInfo.hit&&e.pickInfo.pickedMesh===t._worldSpaceNode&&t.worldSpaceToNodeLocal){var n=t.worldSpaceToNodeLocal(e.pickInfo.pickedPoint);t._handlePointerEventForInteraction(e,n,r)}else t._actualIntersectionList&&t._actualIntersectionList.length>0&&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;s<l.length;s++){var u=l[s];o(u)}for(var c=function(t){e.Tools.first(h._previousIntersectionList,(function(e){return e.prim===t.prim}))||(h._primPointerInfo.updateRelatedTarget(t.prim,t.intersectionLocation),h._bubbleNotifyPrimPointerObserver(t.prim,e.PrimitivePointerInfo.PointerOver,null))},h=this,d=0,p=this._actualIntersectionList;d<p.length;d++){var f=p[d];c(f)}}}this._hoverStatusRenderId=this.scene.getRenderId()}},n.prototype._updatePrimPointerPos=function(e){if(this._primPointerInfo.isCaptured)this._primPointerInfo.primitivePointerPos=this._primPointerInfo.relatedTargetPointerPos;else for(var t=0,r=this._actualIntersectionList;t<r.length;t++){var n=r[t];if(n.prim===e)return void(this._primPointerInfo.primitivePointerPos=n.intersectionLocation)}},n.prototype._debugExecObserver=function(t,r){if(this._notifDebugMode){for(var n="",i=0;i<t.hierarchyDepth;i++)n+=" ";var o=this._primPointerInfo;n+="[RID:"+this.scene.getRenderId()+"] ["+t.hierarchyDepth+"] event:"+e.PrimitivePointerInfo.getEventTypeName(r)+", id: "+t.id+" ("+e.Tools.getClassName(t)+"), primPos: "+o.primitivePointerPos.toString()+", canvasPos: "+o.canvasPointerPos.toString()+", relatedTarget: "+o.relatedTarget.id,console.log(n)}},n.prototype._bubbleNotifyPrimPointerObserver=function(t,r,n){for(var i=this._primPointerInfo,o=n?n.event:null,a=t;a&&!a.isDisposed;){if(this._updatePrimPointerPos(a),a===t&&(r===e.PrimitivePointerInfo.PointerOver?(this._debugExecObserver(t,e.PrimitivePointerInfo.PointerEnter),t._pointerEventObservable.notifyObservers(i,e.PrimitivePointerInfo.PointerEnter)):r===e.PrimitivePointerInfo.PointerOut&&(this._debugExecObserver(t,e.PrimitivePointerInfo.PointerLeave),t._pointerEventObservable.notifyObservers(i,e.PrimitivePointerInfo.PointerLeave))),this._debugExecObserver(a,r),!a._pointerEventObservable.notifyObservers(i,r)&&n instanceof e.PointerInfoPre)return n.skipOnPointerObservable=!0,!1;if(this._triggerActionManager(a,i,r,o),i.cancelBubble)return!1;a=a.parent}return!0},n.prototype._triggerActionManager=function(t,r,n,i){var o=this;if(this._globalTransform||this.updateCachedStates(!0),0!==(n&e.PrimitivePointerInfo.PointerDown)){if(this._pickStartingPosition=r.primitivePointerPos.clone(),this._pickStartingTime=(new Date).getTime(),this._pickedDownPrim=null,t.actionManager){if(this._pickedDownPrim=t,t.actionManager.hasPickTriggers){var a=e.ActionEvent.CreateNewFromPrimitive(t,r.primitivePointerPos,i);switch(i.button){case 0:t.actionManager.processTrigger(e.ActionManager.OnLeftPickTrigger,a);break;case 1:t.actionManager.processTrigger(e.ActionManager.OnCenterPickTrigger,a);break;case 2:t.actionManager.processTrigger(e.ActionManager.OnRightPickTrigger,a)}t.actionManager.processTrigger(e.ActionManager.OnPickDownTrigger,a)}t.actionManager.hasSpecificTrigger(e.ActionManager.OnLongPressTrigger)&&window.setTimeout((function(){var r=o._primPointerInfo,n=o.getCapturedPrimitive(r.pointerId);o._updateIntersectionList(r.canvasPointerPos,null!==n,!0),o._updateOverStatus(!1);var a=new e.IntersectInfo2D;a.pickPosition=r.canvasPointerPos.clone(),a.findFirstOnly=!1,o.intersect(a),null!==a.isPrimIntersected(t)&&t.actionManager&&0!==o._pickStartingTime&&(new Date).getTime()-o._pickStartingTime>e.Scene.LongPressDelay&&Math.abs(o._pickStartingPosition.x-a.pickPosition.x)<e.Scene.DragMovementThreshold&&Math.abs(o._pickStartingPosition.y-a.pickPosition.y)<e.Scene.DragMovementThreshold&&(o._pickStartingTime=0,t.actionManager.processTrigger(e.ActionManager.OnLongPressTrigger,e.ActionEvent.CreateNewFromPrimitive(t,r.primitivePointerPos,i)))}),e.Scene.LongPressDelay)}}else if(0!==(n&e.PrimitivePointerInfo.PointerUp)){this._pickStartingTime=0;var a=e.ActionEvent.CreateNewFromPrimitive(t,r.primitivePointerPos,i);t.actionManager&&(t.actionManager.processTrigger(e.ActionManager.OnPickUpTrigger,a),Math.abs(this._pickStartingPosition.x-r.canvasPointerPos.x)<e.Scene.DragMovementThreshold&&Math.abs(this._pickStartingPosition.y-r.canvasPointerPos.y)<e.Scene.DragMovementThreshold&&t.actionManager.processTrigger(e.ActionManager.OnPickTrigger,a)),this._pickedDownPrim&&this._pickedDownPrim.actionManager&&this._pickedDownPrim!==t&&this._pickedDownPrim.actionManager.processTrigger(e.ActionManager.OnPickOutTrigger,a)}else if(0!==(n&e.PrimitivePointerInfo.PointerOver)){if(t.actionManager){var a=e.ActionEvent.CreateNewFromPrimitive(t,r.primitivePointerPos,i);t.actionManager.processTrigger(e.ActionManager.OnPointerOverTrigger,a)}}else if(0!==(n&e.PrimitivePointerInfo.PointerOut)&&t.actionManager){var a=e.ActionEvent.CreateNewFromPrimitive(t,r.primitivePointerPos,i);t.actionManager.processTrigger(e.ActionManager.OnPointerOutTrigger,a)}},n.prototype.dispose=function(){if(!r.prototype.dispose.call(this))return!1;this._profilingCanvas&&(this._profilingCanvas.dispose(),this._profilingCanvas=null),this.interactionEnabled&&this._setupInteraction(!1),this._renderingGroupObserver&&(this._scene.onRenderingGroupObservable.remove(this._renderingGroupObserver),this._renderingGroupObserver=null),this._beforeRenderObserver&&(this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver),this._beforeRenderObserver=null),this._afterRenderObserver&&(this._scene.onAfterRenderObservable.remove(this._afterRenderObserver),this._afterRenderObserver=null),this._groupCacheMaps&&(this._groupCacheMaps.forEach((function(e,t){return t.forEach((function(e){return e.dispose()}))})),this._groupCacheMaps=null);var e=o._INSTANCES.indexOf(this);return e>-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<l.length;s++){var u=l[s];if(!u.isDisposed){var c=u.trackedNode,h=c.getWorldMatrix();u.trackedNodeOffset&&(e.Vector3.TransformCoordinatesToRef(u.trackedNodeOffset,h,i),a.copyFrom(h),h=a,h.setTranslation(i));var d=e.Vector3.Project(o._v,h,o._m,n);u.levelVisible=d.z>=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;c<h.length;c++){var d=h[c];d._setFlags(e.SmartPropertyPrim.flagLocalTransformDirty|e.SmartPropertyPrim.flagGlobalTransformDirty)}this._setLayoutDirty()}n&&this._fitRenderingDevice&&(this.size=this._renderingSize.clone(),this._background&&(this._background.size=this.size),this._setLayoutDirty());var p=new e.PrepareRender2DContext;++this._globalTransformProcessStep,this._setFlags(e.SmartPropertyPrim.flagLocalTransformDirty|e.SmartPropertyPrim.flagGlobalTransformDirty),this.updateCachedStates(!1),this._prepareGroupRender(p),this._updateRenderId=this.scene.getRenderId()}},n.prototype._render=function(){this._initPerfMetrics(),this._renderObservable&&this._renderObservable.hasObservers()&&this._renderObservable.notifyObservers(this,o.RENDEROBSERVABLE_PRE),this._updateCanvasState(!1),this._updateTrackedNodes(),this.isVisible!==!1&&(this._isScreenSpace||this._updateAdaptiveSizeWorldCanvas(),this._updateCanvasState(!1),this._primitiveCollisionManager&&this._primitiveCollisionManager._update(),this._primPointerInfo.canvasPointerPos&&(this._updateIntersectionList(this._primPointerInfo.canvasPointerPos,!1,!1),this._updateOverStatus(!1)),this.engine.setState(!1,void 0,!0),this._groupRender(),this._isScreenSpace||this._isFlagSet(e.SmartPropertyPrim.flagWorldCacheChanged)&&(this.worldSpaceCacheChanged(),this._clearFlags(e.SmartPropertyPrim.flagWorldCacheChanged)),this._cachingStrategy===o.CACHESTRATEGY_CANVAS&&this._cachedCanvasGroup&&this._cachedCanvasGroup._renderCachedCanvas(),this._fetchPerfMetrics(),this._updateProfileCanvas(),this._renderObservable&&this._renderObservable.hasObservers()&&this._renderObservable.notifyObservers(this,o.RENDEROBSERVABLE_POST))},n.prototype._allocateGroupCache=function(t,r,n,i,a){void 0===i&&(i=!1),void 0===a&&(a=1);var s,l=(i?"MipMap":"NoMipMap")+"_"+a,u=t._renderableData,c=u._noResizeOnScale,h=null==r;s=c?h?o._unS:t.parent.actualScale.multiply(this._canvasLevelScale):t.actualScale.multiply(this._canvasLevelScale);var d=t.actualSize,p=new e.Size(d.width*s.x,d.height*s.y),f=new e.Size(Math.ceil(p.width),Math.ceil(p.height)),g=p.clone();n&&(f.width=Math.max(n.width,f.width),f.height=Math.max(n.height,f.height));for(var _,y=this._groupCacheMaps.getOrAddWithFactory(l,(function(){return new Array})),m=null,v=0,b=y;v<b.length;v++){var P=b[v];_=P;var C=_.allocateRect(f);if(C){m={node:C,texture:_};break}}if(!m){var S=new e.Size(o._groupTextureCacheSize,o._groupTextureCacheSize);(f.width>S.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=this;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=this;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;r<n.length;r++){var i=n[r],o=i.findById(e);if(null!=o)return o}},Object.defineProperty(r.prototype,"ownerWindow",{get:function(){return this._ownerWindow},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"style",{get:function(){return this.style?this._style.name:o.DefaultStyleName},set:function(t){if(!this._style||this._style.name!==t){var r=null;if(t&&(r=o.getStyle(e.Tools.getFullClassName(this),t),!r))throw Error("Couldn't find Style "+t+" for UIElement "+e.Tools.getFullClassName(this));this._style&&this._style.removeStyle(this),r&&r.applyStyle(this),this._style=r}},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"id",{get:function(){return this._id},set:function(e){this._id!==e&&(this._id=e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"uid",{get:function(){return this._uid||(this._uid=e.Tools.RandomId()),this._uid},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"hierarchyDepth",{get:function(){return this._hierarchyDepth},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"parent",{get:function(){return this._parent},set:function(e){this._parent=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"width",{get:function(){return this._width},set:function(e){this._width=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"height",{get:function(){return this._height},set:function(e){this._height=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"minWidth",{get:function(){return this._minWidth},set:function(e){this._minWidth=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"minHheight",{get:function(){return this._minHeight},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"minHeight",{set:function(e){this._minHeight=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"maxWidth",{get:function(){return this._maxWidth},set:function(e){this._maxWidth=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"maxHeight",{get:function(){return this._maxHeight},set:function(e){this._maxHeight=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"actualWidth",{get:function(){return this._actualWidth},set:function(e){this._actualWidth=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"actualHeight",{get:function(){return this._actualHeight},set:function(e){this._actualHeight=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"margin",{get:function(){var t=this;return this._margin||(this._margin=new e.PrimitiveThickness(function(){return t.parent?t.parent.margin:null})),this._margin},set:function(e){this.margin.copyFrom(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"_hasMargin",{get:function(){return null!==this._margin&&!this._margin.isDefault||null!==this._marginAlignment&&!this._marginAlignment.isDefault},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"padding",{get:function(){var t=this;return this._padding||(this._padding=new e.PrimitiveThickness(function(){return t.parent?t.parent.padding:null})),this._padding},set:function(e){this.padding.copyFrom(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"_hasPadding",{get:function(){return null!==this._padding&&!this._padding.isDefault},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"marginAlignment",{get:function(){return this._marginAlignment||(this._marginAlignment=new e.PrimitiveAlignment),this._marginAlignment},set:function(e){this.marginAlignment.copyFrom(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"_hasMarginAlignment",{get:function(){return null!==this._marginAlignment&&!this._marginAlignment.isDefault},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"paddingAlignment",{get:function(){return this._paddingAlignment||(this._paddingAlignment=new e.PrimitiveAlignment),this._paddingAlignment},set:function(e){this.paddingAlignment.copyFrom(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"_hasPaddingAlignment",{get:function(){return null!==this._paddingAlignment&&!this._paddingAlignment.isDefault},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isVisible",{get:function(){return this._isFlagSet(r.flagIsVisible)},set:function(e){this.isVisible!==e&&(this._visualPlaceholder.levelVisible=e,this._changeFlags(r.flagIsVisible,e))},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isEnabled",{get:function(){return this._isFlagSet(r.flagIsEnabled)},set:function(e){this._changeFlags(r.flagIsEnabled,e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isFocused",{get:function(){return this._isFlagSet(r.flagIsFocus)},set:function(e){if(!this.isFocusable){var t=this.parent;if(!t)return;t.isFocused=e}e&&this.ownerWindow.focusManager.setFocusOn(this,this.getFocusScope()),this._changeFlags(r.flagIsFocus,e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isMouseOver",{get:function(){return this._isFlagSet(r.flagIsMouseOver)},set:function(e){this._changeFlags(r.flagIsMouseOver,e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isFocusScope",{get:function(){return this._isFlagSet(r.flagIsFocusScope)},set:function(e){this._changeFlags(r.flagIsFocusScope,e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isFocusable",{get:function(){return this._isFlagSet(r.flagIsFocusable)},set:function(e){this._changeFlags(r.flagIsFocusable,e)},enumerable:!0,configurable:!0}),r.prototype.getFocusScope=function(){if(this.isFocusScope)return this;var e=this.parent;return e?e.getFocusScope():null},r.prototype._isFlagSet=function(e){return 0!==(this._flags&e)},r.prototype._areAllFlagsSet=function(e){return(this._flags&e)===e},r.prototype._areSomeFlagsSet=function(e){return 0!==(this._flags&e)},r.prototype._clearFlags=function(e){this._flags&=~e},r.prototype._setFlags=function(e){var t=this._flags;return this._flags|=e,t},r.prototype._changeFlags=function(e,t){t?this._flags|=e:this._flags&=~e},r.prototype._assignTemplate=function(t){t||(t=o.DefaultTemplateName);var r=e.Tools.getFullClassName(this);if(!r)throw Error("Couldn't access class name of this UIElement, you have to decorate the type with the className decorator");var n=o.getRenderingTemplate(r,t);if(!n)throw Error("Couldn't get the renderingTemplate "+t+" of class "+r);this._renderingTemplateName=t,this._renderingTemplate=n(),this._renderingTemplate.attach(this)},r.prototype._createVisualTree=function(){var t=this.ownerWindow.canvas;this.parent&&(t=this.parent.visualChildrenPlaceholder),this._renderingTemplate||this._assignTemplate(this._renderingTemplateName),this._visualPlaceholder=new e.Group2D({parent:t,id:"GUI "+e.Tools.getClassName(this)+" RootGroup of "+this.id});var r=this._visualPlaceholder;r.addExternalData("_GUIOwnerElement_",this),r.dataSource=this,
r.createSimpleDataBinding(e.Prim2DBase.widthProperty,"width",e.DataBinding.MODE_ONEWAY),r.createSimpleDataBinding(e.Prim2DBase.heightProperty,"height",e.DataBinding.MODE_ONEWAY),r.createSimpleDataBinding(e.Prim2DBase.actualWidthProperty,"actualWidth",e.DataBinding.MODE_ONEWAYTOSOURCE),r.createSimpleDataBinding(e.Prim2DBase.actualHeightProperty,"actualHeight",e.DataBinding.MODE_ONEWAYTOSOURCE),r.createSimpleDataBinding(e.Prim2DBase.marginProperty,"margin",e.DataBinding.MODE_ONEWAY),r.createSimpleDataBinding(e.Prim2DBase.marginAlignmentProperty,"marginAlignment",e.DataBinding.MODE_ONEWAY),this.createVisualTree()},r.prototype._patchUIElement=function(e,t){e&&(this._ownerWindow||e._registerVisualToBuild(this),this._ownerWindow=e),this._parent=t,t&&(this._hierarchyDepth=t.hierarchyDepth+1);var r=this._getChildren();if(r)for(var n=0,i=r;n<i.length;n++){var o=i[n];o._patchUIElement(e,this)}},r.prototype._getDataSource=function(){var e=t.prototype._getDataSource.call(this);if(null!=e)return e;var r=this.parent;return null!=r?r.dataSource:null},r.prototype.createVisualTree=function(){var e=this._renderingTemplate.createVisualTree(this,this._visualPlaceholder);this._visualTemplateRoot=e.root,this._visualChildrenPlaceholder=e.contentPlaceholder},Object.defineProperty(r.prototype,"visualPlaceholder",{get:function(){return this._visualPlaceholder},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"visualTemplateRoot",{get:function(){return this._visualTemplateRoot},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"visualChildrenPlaceholder",{get:function(){return this._visualChildrenPlaceholder},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"_position",{get:function(){return null},enumerable:!0,configurable:!0}),r})(e.SmartPropertyBase);n.UIELEMENT_PROPCOUNT=16,n.flagVisualToBuild=1,n.flagIsVisible=2,n.flagIsFocus=4,n.flagIsFocusScope=8,n.flagIsFocusable=16,n.flagIsEnabled=32,n.flagIsMouseOver=64,n._enableState="Enabled",n._disabledState="Disabled",n._mouseOverState="MouseOver",__decorate([e.dependencyProperty(0,(function(e){return n.parentProperty=e}))],n.prototype,"parent",null),__decorate([e.dependencyProperty(1,(function(e){return n.widthProperty=e}))],n.prototype,"width",null),__decorate([e.dependencyProperty(2,(function(e){return n.heightProperty=e}))],n.prototype,"height",null),__decorate([e.dependencyProperty(3,(function(e){return n.minWidthProperty=e}))],n.prototype,"minWidth",null),__decorate([e.dependencyProperty(4,(function(e){return n.minHeightProperty=e}))],n.prototype,"minHheight",null),__decorate([e.dependencyProperty(5,(function(e){return n.maxWidthProperty=e}))],n.prototype,"maxWidth",null),__decorate([e.dependencyProperty(6,(function(e){return n.maxHeightProperty=e}))],n.prototype,"maxHeight",null),__decorate([e.dependencyProperty(7,(function(e){return n.actualWidthProperty=e}))],n.prototype,"actualWidth",null),__decorate([e.dependencyProperty(8,(function(e){return n.actualHeightProperty=e}))],n.prototype,"actualHeight",null),__decorate([e.dynamicLevelProperty(9,(function(e){return n.marginProperty=e}))],n.prototype,"margin",null),__decorate([e.dynamicLevelProperty(10,(function(e){return n.paddingProperty=e}))],n.prototype,"padding",null),__decorate([e.dynamicLevelProperty(11,(function(e){return n.marginAlignmentProperty=e}))],n.prototype,"marginAlignment",null),__decorate([e.dynamicLevelProperty(12,(function(e){return n.paddingAlignmentProperty=e}))],n.prototype,"paddingAlignment",null),__decorate([e.dynamicLevelProperty(13,(function(e){return n.isEnabledProperty=e}))],n.prototype,"isEnabled",null),__decorate([e.dynamicLevelProperty(14,(function(e){return n.isFocusedProperty=e}))],n.prototype,"isFocused",null),__decorate([e.dynamicLevelProperty(15,(function(e){return n.isMouseOverProperty=e}))],n.prototype,"isMouseOver",null),e.UIElement=n;var i=(function(){function e(){}return Object.defineProperty(e.prototype,"name",{get:function(){return null},enumerable:!0,configurable:!0}),e})();e.UIElementStyle=i;var o=(function(){function t(){}return t.registerDataTemplate=function(e,t){},t.getStyle=function(e,r){var n=t.stylesByUIElement.get(e);if(!n)throw Error("The type "+e+" is unknown, no style were registered for it.");var i=n.get(r);if(!i)throw Error("Couldn't find Template "+r+" of UIElement type "+e);return i},t.registerStyle=function(r,n,i){var o=t.stylesByUIElement.getOrAddWithFactory(r,(function(){return new e.StringDictionary}));o.contains(n)?o[n]=i:o.add(n,i)},Object.defineProperty(t,"DefaultStyleName",{get:function(){return t._defaultStyleName},set:function(e){t._defaultStyleName=e},enumerable:!0,configurable:!0}),t.getRenderingTemplate=function(e,r){var n=t.renderingTemplatesByUIElement.get(e);if(!n)throw Error("The type "+e+" is unknown, no Rendering Template were registered for it.");var i=n.get(r);if(!i)throw Error("Couldn't find Template "+r+" of UI Element type "+e);return i},t.registerRenderingTemplate=function(r,n,i){var o=t.renderingTemplatesByUIElement.getOrAddWithFactory(r,(function(){return new e.StringDictionary}));o.contains(n)?o[n]=i:o.add(n,i)},Object.defineProperty(t,"DefaultTemplateName",{get:function(){return t._defaultTemplateName},set:function(e){t._defaultTemplateName=e},enumerable:!0,configurable:!0}),t})();o.stylesByUIElement=new e.StringDictionary,o.renderingTemplatesByUIElement=new e.StringDictionary,o._defaultTemplateName="Default",o._defaultStyleName="Default",e.GUIManager=o;var a=(function(){function e(){}return e.prototype.attach=function(e){this._owner=e},e.prototype.detach=function(){},Object.defineProperty(e.prototype,"owner",{get:function(){return this._owner},enumerable:!0,configurable:!0}),e})();e.UIElementRenderingTemplateBase=a,e.registerWindowRenderingTemplate=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=n=(function(t){function r(e){var r=this;if(e||(e={}),r=t.call(this,e)||this,r.isOrientationHorizontal=null==e.isOrientationHorizontal||e.isOrientationHorizontal,r._children=new Array,null!=e.children)for(var n=0,i=e.children;n<i.length;n++){var o=i[n];r._children.push(o)}return r}return __extends(r,t),Object.defineProperty(r.prototype,"isOrientationHorizontal",{get:function(){return this._isOrientationHorizontal},set:function(e){this._isOrientationHorizontal=e},enumerable:!0,configurable:!0}),r.prototype.createVisualTree=function(){t.prototype.createVisualTree.call(this),this._childrenPlaceholder=new e.Group2D({parent:this._visualPlaceholder,id:"StackPanel Children Placeholder of "+this.id});var r=this._childrenPlaceholder;r.layoutEngine=this.isOrientationHorizontal?e.StackPanelLayoutEngine.Horizontal:e.StackPanelLayoutEngine.Vertical,r.dataSource=this,r.createSimpleDataBinding(e.Prim2DBase.marginProperty,"padding",e.DataBinding.MODE_ONEWAY),r.createSimpleDataBinding(e.Prim2DBase.marginAlignmentProperty,"paddingAlignment",e.DataBinding.MODE_ONEWAY),this._visualChildrenPlaceholder=this._childrenPlaceholder},Object.defineProperty(r.prototype,"children",{get:function(){return this._children},enumerable:!0,configurable:!0}),r.prototype._getChildren=function(){return this.children},r})(e.UIElement);t.STACKPANEL_PROPCOUNT=e.UIElement.UIELEMENT_PROPCOUNT+3,__decorate([e.dependencyProperty(n.STACKPANEL_PROPCOUNT+0,(function(e){return n.orientationHorizontalProperty=e}))],t.prototype,"isOrientationHorizontal",null),t=n=__decorate([e.className("StackPanel","BABYLON")],t),e.StackPanel=t;var r=i=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.createVisualTree=function(e,t){return{root:t,contentPlaceholder:t}},t.prototype.attach=function(t){e.prototype.attach.call(this,t)},t})(e.UIElementRenderingTemplateBase);r=i=__decorate([e.registerWindowRenderingTemplate("BABYLON.StackPanel","Default",(function(){return new i}))],r),e.DefaultStackPanelRenderingTemplate=r;var n,i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=r=(function(t){function r(e){return t.call(this,e)||this}return __extends(r,t),Object.defineProperty(r.prototype,"background",{get:function(){return this._background||(this._background=new e.ObservableStringDictionary(!1)),this._background},set:function(e){this.background.copyFrom(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"border",{get:function(){return this._border},set:function(e){this._border=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"borderThickness",{get:function(){return this._borderThickness},set:function(e){this._borderThickness=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"fontName",{get:function(){return this._fontName},set:function(e){this._fontName=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"foreground",{get:function(){return this._foreground},set:function(e){this._foreground=e},enumerable:!0,configurable:!0}),r})(e.UIElement);t.CONTROL_PROPCOUNT=e.UIElement.UIELEMENT_PROPCOUNT+5,__decorate([e.dependencyProperty(e.UIElement.UIELEMENT_PROPCOUNT+0,(function(e){return r.backgroundProperty=e}))],t.prototype,"background",null),__decorate([e.dependencyProperty(e.UIElement.UIELEMENT_PROPCOUNT+1,(function(e){return r.borderProperty=e}))],t.prototype,"border",null),__decorate([e.dependencyProperty(e.UIElement.UIELEMENT_PROPCOUNT+2,(function(e){return r.borderThicknessProperty=e}))],t.prototype,"borderThickness",null),__decorate([e.dependencyProperty(e.UIElement.UIELEMENT_PROPCOUNT+3,(function(e){return r.fontNameProperty=e}))],t.prototype,"fontName",null),__decorate([e.dependencyProperty(e.UIElement.UIELEMENT_PROPCOUNT+4,(function(e){return r.foregroundProperty=e}))],t.prototype,"foreground",null),t=r=__decorate([e.className("Control","BABYLON")],t),e.Control=t;var r})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=r=(function(t){function r(e){var r=this;return e||(e={}),r=t.call(this,e)||this,null!=e.content&&(r._content=e.content),r}return __extends(r,t),r.prototype.dispose=function(){return!this.isDisposed&&(this.content&&this.content.dispose&&(this.content.dispose(),this.content=null),this.__contentUIElement&&(this.__contentUIElement.dispose(),this.__contentUIElement=null),t.prototype.dispose.call(this),!0)},Object.defineProperty(r.prototype,"content",{get:function(){return this._content},set:function(e){this._content=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"_contentUIElement",{get:function(){return this.__contentUIElement||this._buildContentUIElement(),this.__contentUIElement},enumerable:!0,configurable:!0}),r.prototype._createVisualTree=function(){t.prototype._createVisualTree.call(this),this._contentPlaceholder=new e.Group2D({parent:this._visualPlaceholder,id:"ContentControl Content Placeholder of "+this.id});var r=this._contentPlaceholder;r.dataSource=this,r.createSimpleDataBinding(e.Prim2DBase.marginProperty,"padding",e.DataBinding.MODE_ONEWAY),r.createSimpleDataBinding(e.Prim2DBase.marginAlignmentProperty,"paddingAlignment",e.DataBinding.MODE_ONEWAY),this._visualChildrenPlaceholder=this._contentPlaceholder},r.prototype._buildContentUIElement=function(){var t=this._content;if(this.__contentUIElement=null,t instanceof e.UIElement)this.__contentUIElement=t;else if("string"==typeof t||"boolean"==typeof t||"number"==typeof t){var r=new e.Label({parent:this,id:"Content of "+this.id}),n=new e.DataBinding;n.propertyPathName="content",n.stringFormat=function(e){return""+e},n.dataSource=this,r.createDataBinding(e.Label.textProperty,n),this.__contentUIElement=r}this.__contentUIElement&&this.__contentUIElement._patchUIElement(this.ownerWindow,this)},r.prototype._getChildren=function(){var e=new Array;return this.content&&e.push(this._contentUIElement),e},r})(e.Control);t.CONTENTCONTROL_PROPCOUNT=e.Control.CONTROL_PROPCOUNT+2,__decorate([e.dependencyProperty(e.Control.CONTROL_PROPCOUNT+0,(function(e){return r.contentProperty=e}))],t.prototype,"content",null),t=r=__decorate([e.className("ContentControl","BABYLON")],t),e.ContentControl=t;var r})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(e){this.focusScope=e,this.focusedElement=null}return e})(),r=(function(){function r(){this._focusScopes=new e.StringDictionary,this._rootScope=new t(null),this._activeScope=null}return r.prototype.setFocusOn=function(e,r){var n=null!=r?this._focusScopes.getOrAddWithFactory(r.uid,(function(e){return new t(r)})):this._rootScope;n.focusedElement!==e&&(n.focusedElement&&(n.focusedElement.isFocused=!1),n.focusedElement=e),this._activeScope!==n&&(this._activeScope=n)},r})();e.FocusManager=r;var n=(function(){function t(t){this.scene=t,this.screenSpaceCanvas=new e.ScreenSpaceCanvas2D(t,{id:"GUI Canvas",cachingStrategy:e.Canvas2D.CACHESTRATEGY_DONTCACHE}),this.focusManager=new r}return t})(),i=a=(function(t){function r(r,n){var i=this;if(n||(n={}),i=t.call(this,n)||this,i.isFocusScope=!0,i.isActive=!1,i._UIElementVisualToBuildList||(i._UIElementVisualToBuildList=new Array),i._patchUIElement(i,null),n.worldPosition||n.worldRotation){var o=null==n.width?100:n.width,s=null==n.height?100:n.height,l=null==n.worldPosition?e.Vector3.Zero():n.worldPosition,u=null==n.worldRotation?e.Quaternion.Identity():n.worldRotation;i._canvas=new e.WorldSpaceCanvas2D(r,new e.Size(o,s),{id:"GUI Canvas",cachingStrategy:e.Canvas2D.CACHESTRATEGY_DONTCACHE,worldPosition:l,worldRotation:u}),i._isWorldSpaceCanvas=!0}else i._sceneData=a.getSceneData(r),i._canvas=i._sceneData.screenSpaceCanvas,i._isWorldSpaceCanvas=!1,i._left=null!=n.left?n.left:0,i._bottom=null!=n.bottom?n.bottom:0;return i._renderObserver=i._canvas.renderObservable.add((function(e,t){return i._canvasPreRender()}),e.Canvas2D.RENDEROBSERVABLE_PRE),i._disposeObserver=i._canvas.disposeObservable.add((function(e,t){return i._canvasDisposed()})),i._canvas.propertyChanged.add((function(e,t){"overPrim"===e.propertyName&&i._overPrimChanged(e.oldValue,e.newValue)})),i._mouseOverUIElement=null,i}return __extends(r,t),Object.defineProperty(r.prototype,"canvas",{get:function(){return this._canvas},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"left",{get:function(){return this._left},set:function(t){var r=new e.Vector2(this._left,this._bottom);this._left=t,this.onPropertyChanged("_position",r,this._position)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"bottom",{get:function(){return this._bottom},set:function(t){var r=new e.Vector2(this._left,this._bottom);this._bottom=t,this.onPropertyChanged("_position",r,this._position)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"position",{get:function(){return this._position},set:function(e){this._left=e.x,this._bottom=e.y},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isActive",{get:function(){return this._isActive},set:function(e){this._isActive=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"focusManager",{get:function(){return this._sceneData.focusManager},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"_position",{get:function(){return new e.Vector2(this.left,this.bottom)},enumerable:!0,configurable:!0}),r.prototype.createVisualTree=function(){t.prototype.createVisualTree.call(this);var r=this._visualPlaceholder;r.createSimpleDataBinding(e.Group2D.positionProperty,"position")},r.prototype._registerVisualToBuild=function(t){t._isFlagSet(e.UIElement.flagVisualToBuild)||(this._UIElementVisualToBuildList||(this._UIElementVisualToBuildList=new Array),this._UIElementVisualToBuildList.push(t),t._setFlags(e.UIElement.flagVisualToBuild))},r.prototype._overPrimChanged=function(t,r){for(var n=this._mouseOverUIElement,i=null,o=r?r.traverseUp((function(t){return t instanceof e.Group2D})):null;o;){var a=o.getExternalData("_GUIOwnerElement_");if(a){i=a;break}o=o.parent?o.parent.traverseUp((function(t){return t instanceof e.Group2D})):null}n!==i&&(n&&(n.isMouseOver=!1),i&&(i.isMouseOver=!0),this._mouseOverUIElement=i)},r.prototype._canvasPreRender=function(){if(this._UIElementVisualToBuildList.length>0){for(var e=this._UIElementVisualToBuildList.sort((function(e,t){return e.hierarchyDepth-t.hierarchyDepth})),t=0,r=e;t<r.length;t++){var n=r[t];n._createVisualTree()}this._UIElementVisualToBuildList.splice(0)}},r.prototype._canvasDisposed=function(){this._canvas.disposeObservable.remove(this._disposeObserver),this._canvas.renderObservable.remove(this._renderObserver)},r.getSceneData=function(e){return a._sceneData.getOrAddWithFactory(e.uid,(function(t){return new n(e)}))},r})(e.ContentControl);i.WINDOW_PROPCOUNT=e.ContentControl.CONTENTCONTROL_PROPCOUNT+4,i._sceneData=new e.StringDictionary,__decorate([e.dependencyProperty(e.ContentControl.CONTENTCONTROL_PROPCOUNT+0,(function(e){return a.leftProperty=e}))],i.prototype,"left",null),__decorate([e.dependencyProperty(e.ContentControl.CONTENTCONTROL_PROPCOUNT+1,(function(e){return a.bottomProperty=e}))],i.prototype,"bottom",null),__decorate([e.dependencyProperty(e.ContentControl.CONTENTCONTROL_PROPCOUNT+2,(function(e){return a.positionProperty=e}))],i.prototype,"position",null),__decorate([e.dependencyProperty(e.ContentControl.CONTENTCONTROL_PROPCOUNT+3,(function(e){return a.isActiveProperty=e}))],i.prototype,"isActive",null),i=a=__decorate([e.className("Window","BABYLON")],i),e.Window=i;var o=s=(function(t){function r(){return null!==t&&t.apply(this,arguments)||this}return __extends(r,t),r.prototype.createVisualTree=function(t,r){var n=new e.Rectangle2D({parent:r,fill:"#808080FF"});return{root:n,contentPlaceholder:n}},r})(e.UIElementRenderingTemplateBase);o=s=__decorate([e.registerWindowRenderingTemplate("BABYLON.Window","Default",(function(){return new s}))],o),e.DefaultWindowRenderingTemplate=o;var a,s})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=n=(function(t){function r(e){var r=this;return e||(e={}),r=t.call(this,e)||this,null!=e.text&&(r.text=e.text),r}return __extends(r,t),Object.defineProperty(r.prototype,"_position",{get:function(){return e.Vector2.Zero()},enumerable:!0,configurable:!0}),r.prototype._getChildren=function(){return n._emptyArray},r.prototype.createVisualTree=function(){t.prototype.createVisualTree.call(this);this._visualChildrenPlaceholder},Object.defineProperty(r.prototype,"text",{get:function(){return this._text},set:function(e){this._text=e},enumerable:!0,configurable:!0}),r})(e.Control);t._emptyArray=new Array,__decorate([e.dependencyProperty(e.Control.CONTROL_PROPCOUNT+0,(function(e){return n.textProperty=e}))],t.prototype,"text",null),t=n=__decorate([e.className("Label","BABYLON")],t),e.Label=t;var r=i=(function(t){function r(){return null!==t&&t.apply(this,arguments)||this}return __extends(r,t),r.prototype.createVisualTree=function(t,r){var n=new e.Text2D("",{parent:r});return n.createSimpleDataBinding(e.Text2D.textProperty,"text"),n.dataSource=t,{root:n,contentPlaceholder:n}},r})(e.UIElementRenderingTemplateBase);r=i=__decorate([e.registerWindowRenderingTemplate("BABYLON.Label","Default",(function(){return new i}))],r),e.DefaultLabelRenderingTemplate=r;var n,i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=n=(function(t){function r(r){var i=this;return r||(r={}),i=t.call(this,r)||this,null==r.paddingAlignment&&(i.paddingAlignment.horizontal=e.PrimitiveAlignment.AlignCenter,i.paddingAlignment.vertical=e.PrimitiveAlignment.AlignCenter),i._normalStateBackground=new e.ObservableStringDictionary(!1),i._normalStateBorder=new e.ObservableStringDictionary(!1),i._defaultStateBackground=new e.ObservableStringDictionary(!1),i._defaultStateBorder=new e.ObservableStringDictionary(!1),i._normalStateBackground.add(e.UIElement.enabledState,e.Canvas2D.GetSolidColorBrushFromHex("#337AB7FF")),i._normalStateBackground.add(e.UIElement.disabledState,e.Canvas2D.GetSolidColorBrushFromHex("#7BA9D0FF")),i._normalStateBackground.add(e.UIElement.mouseOverState,e.Canvas2D.GetSolidColorBrushFromHex("#286090FF")),i._normalStateBackground.add(n.pushedState,e.Canvas2D.GetSolidColorBrushFromHex("#1E496EFF")),i._normalStateBorder.add(e.UIElement.enabledState,e.Canvas2D.GetSolidColorBrushFromHex("#2E6DA4FF")),i._normalStateBorder.add(e.UIElement.disabledState,e.Canvas2D.GetSolidColorBrushFromHex("#77A0C4FF")),i._normalStateBorder.add(e.UIElement.mouseOverState,e.Canvas2D.GetSolidColorBrushFromHex("#204D74FF")),i._normalStateBorder.add(n.pushedState,e.Canvas2D.GetSolidColorBrushFromHex("#2E5D9EFF")),i._defaultStateBackground.add(e.UIElement.enabledState,e.Canvas2D.GetSolidColorBrushFromHex("#FFFFFFFF")),i._defaultStateBackground.add(e.UIElement.disabledState,e.Canvas2D.GetSolidColorBrushFromHex("#FFFFFFFF")),i._defaultStateBackground.add(e.UIElement.mouseOverState,e.Canvas2D.GetSolidColorBrushFromHex("#E6E6E6FF")),i._defaultStateBackground.add(n.pushedState,e.Canvas2D.GetSolidColorBrushFromHex("#D4D4D4FF")),i._defaultStateBorder.add(e.UIElement.enabledState,e.Canvas2D.GetSolidColorBrushFromHex("#CCCCCCFF")),i._defaultStateBorder.add(e.UIElement.disabledState,e.Canvas2D.GetSolidColorBrushFromHex("#DEDEDEFF")),i._defaultStateBorder.add(e.UIElement.mouseOverState,e.Canvas2D.GetSolidColorBrushFromHex("#ADADADFF")),i._defaultStateBorder.add(n.pushedState,e.Canvas2D.GetSolidColorBrushFromHex("#6C8EC5FF")),i}return __extends(r,t),Object.defineProperty(r,"pushedState",{get:function(){return n._pushedState},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isPushed",{get:function(){return this._isPushed},set:function(e){this._isPushed=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isDefault",{get:function(){return this._isDefault},set:function(e){this._isDefault=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isOutline",{get:function(){return this._isOutline},set:function(e){this._isOutline=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"clickObservable",{get:function(){return this._clickObservable||(this._clickObservable=new e.Observable),this._clickObservable},enumerable:!0,configurable:!0}),r.prototype._raiseClick=function(){this._clickObservable&&this._clickObservable.hasObservers()&&this._clickObservable.notifyObservers(this)},r.prototype.createVisualTree=function(){var r=this;t.prototype.createVisualTree.call(this);var n=this._visualPlaceholder;n.pointerEventObservable.add((function(t,n){r.isVisible&&r.isEnabled&&t.relatedTarget!==r._visualPlaceholder&&(n.mask===e.PrimitivePointerInfo.PointerUp?(r._raiseClick(),r.isPushed=!1):n.mask===e.PrimitivePointerInfo.PointerDown&&(r.isPushed=!0,r.isFocused=!0))}),e.PrimitivePointerInfo.PointerUp|e.PrimitivePointerInfo.PointerDown)},Object.defineProperty(r.prototype,"normalStateBackground",{get:function(){return this._normalStateBackground},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"defaultStateBackground",{get:function(){return this._defaultStateBackground},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"normalStateBorder",{get:function(){return this._normalStateBorder},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"defaultStateBorder",{get:function(){return this._defaultStateBorder},enumerable:!0,configurable:!0}),r})(e.ContentControl);t.BUTTON_PROPCOUNT=e.ContentControl.CONTENTCONTROL_PROPCOUNT+3,t._pushedState="Pushed",__decorate([e.dependencyProperty(e.ContentControl.CONTROL_PROPCOUNT+0,(function(e){return n.isPushedProperty=e}))],t.prototype,"isPushed",null),__decorate([e.dependencyProperty(e.ContentControl.CONTROL_PROPCOUNT+1,(function(e){return n.isDefaultProperty=e}))],t.prototype,"isDefault",null),__decorate([e.dependencyProperty(e.ContentControl.CONTROL_PROPCOUNT+2,(function(e){return n.isOutlineProperty=e}))],t.prototype,"isOutline",null),t=n=__decorate([e.className("Button","BABYLON")],t),e.Button=t;var r=i=(function(r){function n(){return null!==r&&r.apply(this,arguments)||this}return __extends(n,r),n.prototype.createVisualTree=function(t,r){return this._rect=new e.Rectangle2D({parent:r,fill:"#FF8080FF",border:"#FF8080FF",roundRadius:10,borderThickness:2}),this.stateChange(),{root:this._rect,contentPlaceholder:this._rect}},n.prototype.attach=function(n){var i=this;r.prototype.attach.call(this,n),this.owner.propertyChanged.add((function(e,t){return i.stateChange()}),e.UIElement.isEnabledProperty.flagId|e.UIElement.isFocusedProperty.flagId|e.UIElement.isMouseOverProperty.flagId|t.isDefaultProperty.flagId|t.isOutlineProperty.flagId|t.isPushedProperty.flagId);var o=n;o.normalStateBackground.dictionaryChanged.add((function(e,t){return i.stateChange()})),o.normalStateBorder.dictionaryChanged.add((function(e,t){return i.stateChange()})),o.defaultStateBackground.dictionaryChanged.add((function(e,t){return i.stateChange()})),o.defaultStateBorder.dictionaryChanged.add((function(e,t){return i.stateChange()}))},n.prototype.stateChange=function(){var r=this.owner,n=e.UIElement.enabledState,i=r.isDefault?r.defaultStateBackground.get(n):r.normalStateBackground.get(n),o=r.isDefault?r.defaultStateBorder.get(n):r.normalStateBorder.get(n);r.isPushed?(n=t.pushedState,r.isDefault?(i=r.defaultStateBackground.get(n),o=r.defaultStateBorder.get(n)):(i=r.normalStateBackground.get(n),o=r.normalStateBorder.get(n))):r.isMouseOver?(n=e.UIElement.mouseOverState,r.isDefault?(i=r.defaultStateBackground.get(n),o=r.defaultStateBorder.get(n)):(i=r.normalStateBackground.get(n),o=r.normalStateBorder.get(n))):r.isEnabled||(n=e.UIElement.disabledState,r.isDefault?(i=r.defaultStateBackground.get(n),o=r.defaultStateBorder.get(n)):(i=r.normalStateBackground.get(n),o=r.normalStateBorder.get(n))),this._rect.fill=i,this._rect.border=o},n})(e.UIElementRenderingTemplateBase);r=i=__decorate([e.registerWindowRenderingTemplate("BABYLON.Button","Default",(function(){return new i}))],r),e.DefaultButtonRenderingTemplate=r;var n,i})(BABYLON||(BABYLON={}));