text: var __extends=this&&this.__extends||(function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var n in i)i.hasOwnProperty(n)&&(e[n]=i[n])};return function(i,n){function t(){this.constructor=i}e(i,n),i.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t)}})(),__decorate=this&&this.__decorate||function(e,i,n,t){var r,o=arguments.length,s=o<3?i:null===t?t=Object.getOwnPropertyDescriptor(i,n):t;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,i,n,t);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(s=(o<3?r(s):o>3?r(i,n,s):r(i,n))||s);return o>3&&s&&Object.defineProperty(i,n,s),s},BABYLON;!(function(e){var i=(function(e){function i(){var i=e.call(this)||this;return i.DIFFUSE=!1,i.CLIPPLANE=!1,i.ALPHATEST=!1,i.POINTSIZE=!1,i.FOG=!1,i.NORMAL=!1,i.UV1=!1,i.UV2=!1,i.VERTEXCOLOR=!1,i.VERTEXALPHA=!1,i.NUM_BONE_INFLUENCERS=0,i.BonesPerMesh=0,i.INSTANCES=!1,i.NDOTL=!0,i.CUSTOMUSERLIGHTING=!0,i.CELLBASIC=!0,i.DEPTHPREPASS=!1,i.rebuild(),i}return __extends(i,e),i})(e.MaterialDefines),n=(function(n){function t(i,t){var r=n.call(this,i,t)||this;return r.diffuseColor=new e.Color3(1,1,1),r._computeHighLevel=!1,r._disableLighting=!1,r._maxSimultaneousLights=4,r}return __extends(t,n),t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.isReadyForSubMesh=function(n,t,r){if(this.isFrozen&&this._wasPreviouslyReady&&t.effect)return!0;t._materialDefines||(t._materialDefines=new i);var o=t._materialDefines,s=this.getScene();if(!this.checkReadyOnEveryCall&&t.effect&&this._renderId===s.getRenderId())return!0;var a=s.getEngine();if(o._areTexturesDirty&&(o._needUVs=!1,s.texturesEnabled&&this._diffuseTexture&&e.StandardMaterial.DiffuseTextureEnabled)){if(!this._diffuseTexture.isReady())return!1;o._needUVs=!0,o.DIFFUSE=!0}if(o.CELLBASIC=!this.computeHighLevel,e.MaterialHelper.PrepareDefinesForMisc(n,s,!1,this.pointsCloud,this.fogEnabled,o),o._needNormals=e.MaterialHelper.PrepareDefinesForLights(s,n,o,!1,this._maxSimultaneousLights,this._disableLighting),e.MaterialHelper.PrepareDefinesForFrameBoundValues(s,a,o,r),e.MaterialHelper.PrepareDefinesForAttributes(n,o,!0,!0),o.isDirty){o.markAsProcessed(),s.resetCachedMaterial();var f=new e.EffectFallbacks;o.FOG&&f.addFallback(1,"FOG"),e.MaterialHelper.HandleFallbacksForShadows(o,f,this.maxSimultaneousLights),o.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,n);var l=[e.VertexBuffer.PositionKind];o.NORMAL&&l.push(e.VertexBuffer.NormalKind),o.UV1&&l.push(e.VertexBuffer.UVKind),o.UV2&&l.push(e.VertexBuffer.UV2Kind),o.VERTEXCOLOR&&l.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(l,n,o,f),e.MaterialHelper.PrepareAttributesForInstances(l,o);var u=o.toString(),d=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","vClipPlane","diffuseMatrix"],c=["diffuseSampler"],h=new Array;e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:d,uniformBuffersNames:h,samplers:c,defines:o,maxSimultaneousLights:this.maxSimultaneousLights}),t.setEffect(s.getEngine().createEffect("cell",{attributes:l,uniformsNames:d,uniformBuffersNames:h,samplers:c,defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights-1}},a),o)}return!!t.effect.isReady()&&(this._renderId=s.getRenderId(),this._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(i,n,t){var r=this.getScene(),o=t._materialDefines;if(o){var s=t.effect;this._activeEffect=s,this.bindOnlyWorldMatrix(i),this._activeEffect.setMatrix("viewProjection",r.getTransformMatrix()),e.MaterialHelper.BindBonesParameters(n,this._activeEffect),this._mustRebind(r,s)&&(this._diffuseTexture&&e.StandardMaterial.DiffuseTextureEnabled&&(this._activeEffect.setTexture("diffuseSampler",this._diffuseTexture),this._activeEffect.setFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),this._activeEffect.setMatrix("diffuseMatrix",this._diffuseTexture.getTextureMatrix())),e.MaterialHelper.BindClipPlane(this._activeEffect,r),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),this._activeEffect.setVector3("vEyePosition",r._mirroredCameraPosition?r._mirroredCameraPosition:r.activeCamera.position)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*n.visibility),r.lightsEnabled&&!this.disableLighting&&e.MaterialHelper.BindLights(r,n,this._activeEffect,o,this._maxSimultaneousLights),r.fogEnabled&&n.applyFog&&r.fogMode!==e.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",r.getViewMatrix()),e.MaterialHelper.BindFogParameters(r,n,this._activeEffect),this._afterBind(n,this._activeEffect)}},t.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),e},t.prototype.getActiveTextures=function(){var e=n.prototype.getActiveTextures.call(this);return this._diffuseTexture&&e.push(this._diffuseTexture),e},t.prototype.hasTexture=function(e){return!!n.prototype.hasTexture.call(this,e)||this._diffuseTexture===e},t.prototype.dispose=function(e){this._diffuseTexture&&this._diffuseTexture.dispose(),n.prototype.dispose.call(this,e)},t.prototype.getClassName=function(){return"CellMaterial"},t.prototype.clone=function(i){var n=this;return e.SerializationHelper.Clone((function(){return new t(i,n.getScene())}),this)},t.prototype.serialize=function(){var i=e.SerializationHelper.Serialize(this);return i.customType="BABYLON.CellMaterial",i},t.Parse=function(i,n,r){return e.SerializationHelper.Parse((function(){return new t(i.name,n)}),i,n,r)},__decorate([e.serializeAsTexture("diffuseTexture")],t.prototype,"_diffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsColor3("diffuseColor")],t.prototype,"diffuseColor",void 0),__decorate([e.serialize("computeHighLevel")],t.prototype,"_computeHighLevel",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"computeHighLevel",void 0),__decorate([e.serialize("disableLighting")],t.prototype,"_disableLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),__decorate([e.serialize("maxSimultaneousLights")],t.prototype,"_maxSimultaneousLights",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),t})(e.PushMaterial);e.CellMaterial=n})(BABYLON||(BABYLON={})),BABYLON.Effect.ShadersStore.cellVertexShader="precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n",BABYLON.Effect.ShadersStore.cellPixelShader="precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\n\nvec3 computeCustomDiffuseLighting(lightingInfo info,vec3 diffuseBase,float shadow)\n{\ndiffuseBase=info.diffuse*shadow;\n#ifdef CELLBASIC\nfloat level=1.0;\nif (info.ndl<0.5)\nlevel=0.5;\ndiffuseBase.rgb*vec3(level,level,level);\n#else\nfloat ToonThresholds[4];\nToonThresholds[0]=0.95;\nToonThresholds[1]=0.5;\nToonThresholds[2]=0.2;\nToonThresholds[3]=0.03;\nfloat ToonBrightnessLevels[5];\nToonBrightnessLevels[0]=1.0;\nToonBrightnessLevels[1]=0.8;\nToonBrightnessLevels[2]=0.6;\nToonBrightnessLevels[3]=0.35;\nToonBrightnessLevels[4]=0.2;\nif (info.ndl>ToonThresholds[0])\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[0];\n}\nelse if (info.ndl>ToonThresholds[1])\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[1];\n}\nelse if (info.ndl>ToonThresholds[2])\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[2];\n}\nelse if (info.ndl>ToonThresholds[3])\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[3];\n}\nelse\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[4];\n}\n#endif\nreturn max(diffuseBase,vec3(0.2));\n}\nvoid main(void)\n{\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n\nlightingInfo info;\nvec3 diffuseBase=vec3(0.,0.,0.);\nfloat shadow=1.;\nfloat glossiness=0.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif \n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;;\n\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n}";