UNPKG

@vrspace/babylonjs

Version:

vrspace.org babylonjs client

1 lines 198 kB
!function(e,i){"object"==typeof exports&&"object"==typeof module?module.exports=i(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-materials",["babylonjs"],i):"object"==typeof exports?exports["babylonjs-materials"]=i(require("babylonjs")):e.MATERIALS=i(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(e=>(()=>{"use strict";var i={597:i=>{i.exports=e}},t={};function n(e){var r=t[e];if(void 0!==r)return r.exports;var o=t[e]={exports:{}};return i[e](o,o.exports,n),o.exports}n.d=(e,i)=>{for(var t in i)n.o(i,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:i[t]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,i)=>Object.prototype.hasOwnProperty.call(e,i),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{n.d(r,{default:()=>X});var e={};n.r(e),n.d(e,{CellMaterial:()=>l,CustomMaterial:()=>c,CustomShaderStructure:()=>u,FireMaterial:()=>g,FurMaterial:()=>_,GradientMaterial:()=>S,GridMaterial:()=>C,LavaMaterial:()=>y,MixMaterial:()=>I,NormalMaterial:()=>M,PBRCustomMaterial:()=>m,ShaderAlbedoParts:()=>h,ShaderAlebdoParts:()=>p,ShaderSpecialParts:()=>d,ShadowOnlyMaterial:()=>b,SimpleMaterial:()=>D,SkyMaterial:()=>R,TerrainMaterial:()=>V,TriPlanarMaterial:()=>B,WaterMaterial:()=>G});var i={};n.r(i),n.d(i,{CellMaterial:()=>l,CustomMaterial:()=>c,CustomShaderStructure:()=>u,FireMaterial:()=>g,FurMaterial:()=>_,GradientMaterial:()=>S,GridMaterial:()=>C,LavaMaterial:()=>y,MixMaterial:()=>I,NormalMaterial:()=>M,PBRCustomMaterial:()=>m,ShaderAlbedoParts:()=>h,ShaderAlebdoParts:()=>p,ShaderSpecialParts:()=>d,ShadowOnlyMaterial:()=>b,SimpleMaterial:()=>D,SkyMaterial:()=>R,TerrainMaterial:()=>V,TriPlanarMaterial:()=>B,WaterMaterial:()=>G});var t=function(e,i){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var t in i)Object.prototype.hasOwnProperty.call(i,t)&&(e[t]=i[t])},t(e,i)};function o(e,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}function s(e,i,t,n){var r,o=arguments.length,s=o<3?i:null===n?n=Object.getOwnPropertyDescriptor(i,t):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,i,t,n);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(s=(o<3?r(s):o>3?r(i,t,s):r(i,t))||s);return o>3&&s&&Object.defineProperty(i,t,s),s}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var a=n(597);a.ShaderStore.ShadersStore.cellPixelShader="precision highp float;uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;varying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<helperFunctions>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;uniform sampler2D diffuseSampler;uniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\nvec3 computeCustomDiffuseLighting(lightingInfo info,vec3 diffuseBase,float shadow)\n{diffuseBase=info.diffuse*shadow;\n#ifdef CELLBASIC\nfloat level=1.0;if (info.ndl<0.5)\nlevel=0.5;diffuseBase.rgb*vec3(level,level,level);\n#else\nfloat ToonThresholds[4];ToonThresholds[0]=0.95;ToonThresholds[1]=0.5;ToonThresholds[2]=0.2;ToonThresholds[3]=0.03;float ToonBrightnessLevels[5];ToonBrightnessLevels[0]=1.0;ToonBrightnessLevels[1]=0.8;ToonBrightnessLevels[2]=0.6;ToonBrightnessLevels[3]=0.35;ToonBrightnessLevels[4]=0.2;if (info.ndl>ToonThresholds[0])\n{diffuseBase.rgb*=ToonBrightnessLevels[0];}\nelse if (info.ndl>ToonThresholds[1])\n{diffuseBase.rgb*=ToonBrightnessLevels[1];}\nelse if (info.ndl>ToonThresholds[2])\n{diffuseBase.rgb*=ToonBrightnessLevels[2];}\nelse if (info.ndl>ToonThresholds[3])\n{diffuseBase.rgb*=ToonBrightnessLevels[3];}\nelse\n{diffuseBase.rgb*=ToonBrightnessLevels[4];}\n#endif\nreturn max(diffuseBase,vec3(0.2));}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=vec4(1.,1.,1.,1.);vec3 diffuseColor=vDiffuseColor.rgb;float 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#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\nlightingInfo info;vec3 diffuseBase=vec3(0.,0.,0.);float shadow=1.;float glossiness=0.;float aggShadow=0.;float numLights=0.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif \n#include<lightFragment>[0..maxSimultaneousLights]\n#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;vec4 color=vec4(finalDiffuse,alpha);\n#include<logDepthFragment>\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}";a.ShaderStore.ShadersStore.cellVertexShader="precision highp float;attribute 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#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\nuniform mat4 view;uniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;uniform mat4 diffuseMatrix;uniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<logDepthDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(position,1.0);gl_Position=viewProjection*worldPos;vPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\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{vDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));}\nelse\n{vDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));}\n#endif\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#include<vertexColorMixing>\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#include<logDepthVertex>\n#define CUSTOM_VERTEX_MAIN_END\n}\n";var f=function(e){function i(){var i=e.call(this)||this;return i.DIFFUSE=!1,i.CLIPPLANE=!1,i.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!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.INSTANCESCOLOR=!1,i.NDOTL=!0,i.CUSTOMUSERLIGHTING=!0,i.CELLBASIC=!0,i.DEPTHPREPASS=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.LOGARITHMICDEPTH=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),l=function(e){function i(i,t){var n=e.call(this,i,t)||this;return n.diffuseColor=new a.Color3(1,1,1),n._computeHighLevel=!1,n._disableLighting=!1,n._maxSimultaneousLights=4,n}return o(i,e),i.prototype.needAlphaBlending=function(){return this.alpha<1},i.prototype.needAlphaTesting=function(){return!1},i.prototype.getAlphaTestTexture=function(){return null},i.prototype.isReadyForSubMesh=function(e,i,t){var n=i._drawWrapper;if(this.isFrozen&&n.effect&&n._wasPreviouslyReady&&n._wasPreviouslyUsingInstances===t)return!0;i.materialDefines||(i.materialDefines=new f);var r=i.materialDefines,o=this.getScene();if(this._isReadyForSubMesh(i))return!0;var s=o.getEngine();if(r._areTexturesDirty&&(r._needUVs=!1,o.texturesEnabled&&this._diffuseTexture&&a.MaterialFlags.DiffuseTextureEnabled)){if(!this._diffuseTexture.isReady())return!1;r._needUVs=!0,r.DIFFUSE=!0}if(r.CELLBASIC=!this.computeHighLevel,(0,a.PrepareDefinesForMisc)(e,o,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),r),r._needNormals=(0,a.PrepareDefinesForLights)(o,e,r,!1,this._maxSimultaneousLights,this._disableLighting),(0,a.PrepareDefinesForFrameBoundValues)(o,s,this,r,!!t),(0,a.PrepareDefinesForAttributes)(e,r,!0,!0),r.isDirty){r.markAsProcessed(),o.resetCachedMaterial();var l=new a.EffectFallbacks;r.FOG&&l.addFallback(1,"FOG"),(0,a.HandleFallbacksForShadows)(r,l,this.maxSimultaneousLights),r.NUM_BONE_INFLUENCERS>0&&l.addCPUSkinningFallback(0,e),r.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var u=[a.VertexBuffer.PositionKind];r.NORMAL&&u.push(a.VertexBuffer.NormalKind),r.UV1&&u.push(a.VertexBuffer.UVKind),r.UV2&&u.push(a.VertexBuffer.UV2Kind),r.VERTEXCOLOR&&u.push(a.VertexBuffer.ColorKind),(0,a.PrepareAttributesForBones)(u,e,r,l),(0,a.PrepareAttributesForInstances)(u,r);var d=r.toString(),c=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","diffuseMatrix","logarithmicDepthConstant"],h=["diffuseSampler"],p=[];(0,a.addClipPlaneUniforms)(c),(0,a.PrepareUniformsAndSamplersList)({uniformsNames:c,uniformBuffersNames:p,samplers:h,defines:r,maxSimultaneousLights:this.maxSimultaneousLights}),i.setEffect(o.getEngine().createEffect("cell",{attributes:u,uniformsNames:c,uniformBuffersNames:p,samplers:h,defines:d,fallbacks:l,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights-1}},s),r,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(r._renderId=o.getRenderId(),n._wasPreviouslyReady=!0,n._wasPreviouslyUsingInstances=!!t,0))},i.prototype.bindForSubMesh=function(e,i,t){var n=this.getScene(),r=t.materialDefines;if(r){var o=t.effect;o&&(this._activeEffect=o,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),(0,a.BindBonesParameters)(i,this._activeEffect),this._mustRebind(n,o,t)&&(this._diffuseTexture&&a.MaterialFlags.DiffuseTextureEnabled&&(this._activeEffect.setTexture("diffuseSampler",this._diffuseTexture),this._activeEffect.setFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),this._activeEffect.setMatrix("diffuseMatrix",this._diffuseTexture.getTextureMatrix())),(0,a.bindClipPlane)(this._activeEffect,this,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),this._useLogarithmicDepth&&(0,a.BindLogDepth)(r,o,n),n.bindEyePosition(o)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility),n.lightsEnabled&&!this.disableLighting&&(0,a.BindLights)(n,i,this._activeEffect,r,this._maxSimultaneousLights),n.fogEnabled&&i.applyFog&&n.fogMode!==a.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",n.getViewMatrix()),(0,a.BindFogParameters)(n,i,this._activeEffect),this._afterBind(i,this._activeEffect,t))}},i.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),e},i.prototype.getActiveTextures=function(){var i=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&i.push(this._diffuseTexture),i},i.prototype.hasTexture=function(i){return!!e.prototype.hasTexture.call(this,i)||this._diffuseTexture===i},i.prototype.dispose=function(i){this._diffuseTexture&&this._diffuseTexture.dispose(),e.prototype.dispose.call(this,i)},i.prototype.getClassName=function(){return"CellMaterial"},i.prototype.clone=function(e){var t=this;return a.SerializationHelper.Clone((function(){return new i(e,t.getScene())}),this)},i.prototype.serialize=function(){var i=e.prototype.serialize.call(this);return i.customType="BABYLON.CellMaterial",i},i.Parse=function(e,t,n){return a.SerializationHelper.Parse((function(){return new i(e.name,t)}),e,t,n)},s([(0,a.serializeAsTexture)("diffuseTexture")],i.prototype,"_diffuseTexture",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture",void 0),s([(0,a.serializeAsColor3)("diffuse")],i.prototype,"diffuseColor",void 0),s([(0,a.serialize)("computeHighLevel")],i.prototype,"_computeHighLevel",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"computeHighLevel",void 0),s([(0,a.serialize)("disableLighting")],i.prototype,"_disableLighting",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),s([(0,a.serialize)("maxSimultaneousLights")],i.prototype,"_maxSimultaneousLights",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),i}(a.PushMaterial);(0,a.RegisterClass)("BABYLON.CellMaterial",l);var u=function(){},d=function(){},c=function(e){function i(t,n){var r=e.call(this,t,n)||this;return r.CustomParts=new d,r.customShaderNameResolve=r.Builder,r.FragmentShader=a.Effect.ShadersStore.defaultPixelShader,r.VertexShader=a.Effect.ShadersStore.defaultVertexShader,i.ShaderIndexer++,r._createdShaderName="custom_"+i.ShaderIndexer,r}return o(i,e),i.prototype.AttachAfterBind=function(e,i){if(this._newUniformInstances)for(var t in this._newUniformInstances)"vec2"==(n=t.toString().split("-"))[0]?i.setVector2(n[1],this._newUniformInstances[t]):"vec3"==n[0]?this._newUniformInstances[t]instanceof a.Color3?i.setColor3(n[1],this._newUniformInstances[t]):i.setVector3(n[1],this._newUniformInstances[t]):"vec4"==n[0]?(this._newUniformInstances[t]instanceof a.Color4?i.setDirectColor4(n[1],this._newUniformInstances[t]):i.setVector4(n[1],this._newUniformInstances[t]),i.setVector4(n[1],this._newUniformInstances[t])):"mat4"==n[0]?i.setMatrix(n[1],this._newUniformInstances[t]):"float"==n[0]&&i.setFloat(n[1],this._newUniformInstances[t]);if(this._newSamplerInstances)for(var t in this._newSamplerInstances){var n;"sampler2D"==(n=t.toString().split("-"))[0]&&this._newSamplerInstances[t].isReady&&this._newSamplerInstances[t].isReady()&&i.setTexture(n[1],this._newSamplerInstances[t])}},i.prototype.ReviewUniform=function(e,i){if("uniform"==e&&this._newUniforms)for(var t=0;t<this._newUniforms.length;t++)-1==this._customUniform[t].indexOf("sampler")&&i.push(this._newUniforms[t].replace(/\[\d*\]/g,""));if("sampler"==e&&this._newUniforms)for(t=0;t<this._newUniforms.length;t++)-1!=this._customUniform[t].indexOf("sampler")&&i.push(this._newUniforms[t].replace(/\[\d*\]/g,""));return i},i.prototype.Builder=function(e,i,t,n,r,o){o&&this._customAttributes&&this._customAttributes.length>0&&o.push.apply(o,this._customAttributes),this.ReviewUniform("uniform",i),this.ReviewUniform("sampler",n);var s=this._createdShaderName;return a.Effect.ShadersStore[s+"VertexShader"]&&a.Effect.ShadersStore[s+"PixelShader"]||(a.Effect.ShadersStore[s+"VertexShader"]=this._injectCustomCode(this.VertexShader,"vertex"),a.Effect.ShadersStore[s+"PixelShader"]=this._injectCustomCode(this.FragmentShader,"fragment")),s},i.prototype._injectCustomCode=function(e,i){var t=this._getCustomCode(i);for(var n in t){var r=t[n];if(r&&r.length>0){var o="#define "+n;e=e.replace(o,"\n"+r+"\n"+o)}}return e},i.prototype._getCustomCode=function(e){var i,t;return"vertex"===e?{CUSTOM_VERTEX_BEGIN:this.CustomParts.Vertex_Begin,CUSTOM_VERTEX_DEFINITIONS:((null===(i=this._customUniform)||void 0===i?void 0:i.join("\n"))||"")+(this.CustomParts.Vertex_Definitions||""),CUSTOM_VERTEX_MAIN_BEGIN:this.CustomParts.Vertex_MainBegin,CUSTOM_VERTEX_UPDATE_POSITION:this.CustomParts.Vertex_Before_PositionUpdated,CUSTOM_VERTEX_UPDATE_NORMAL:this.CustomParts.Vertex_Before_NormalUpdated,CUSTOM_VERTEX_MAIN_END:this.CustomParts.Vertex_MainEnd,CUSTOM_VERTEX_UPDATE_WORLDPOS:this.CustomParts.Vertex_After_WorldPosComputed}:{CUSTOM_FRAGMENT_BEGIN:this.CustomParts.Fragment_Begin,CUSTOM_FRAGMENT_DEFINITIONS:((null===(t=this._customUniform)||void 0===t?void 0:t.join("\n"))||"")+(this.CustomParts.Fragment_Definitions||""),CUSTOM_FRAGMENT_MAIN_BEGIN:this.CustomParts.Fragment_MainBegin,CUSTOM_FRAGMENT_UPDATE_DIFFUSE:this.CustomParts.Fragment_Custom_Diffuse,CUSTOM_FRAGMENT_UPDATE_ALPHA:this.CustomParts.Fragment_Custom_Alpha,CUSTOM_FRAGMENT_BEFORE_LIGHTS:this.CustomParts.Fragment_Before_Lights,CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR:this.CustomParts.Fragment_Before_FragColor,CUSTOM_FRAGMENT_MAIN_END:this.CustomParts.Fragment_MainEnd,CUSTOM_FRAGMENT_BEFORE_FOG:this.CustomParts.Fragment_Before_Fog}},i.prototype._afterBind=function(i,t,n){if(void 0===t&&(t=null),t){this.AttachAfterBind(i,t);try{e.prototype._afterBind.call(this,i,t,n)}catch(e){}}},i.prototype.AddUniform=function(e,i,t){return this._customUniform||(this._customUniform=new Array,this._newUniforms=new Array,this._newSamplerInstances={},this._newUniformInstances={}),t&&(-1!=i.indexOf("sampler")?this._newSamplerInstances[i+"-"+e]=t:this._newUniformInstances[i+"-"+e]=t),this._customUniform.push("uniform "+i+" "+e+";"),this._newUniforms.push(e),this},i.prototype.AddAttribute=function(e){return this._customAttributes||(this._customAttributes=[]),this._customAttributes.push(e),this},i.prototype.Fragment_Begin=function(e){return this.CustomParts.Fragment_Begin=e,this},i.prototype.Fragment_Definitions=function(e){return this.CustomParts.Fragment_Definitions=e,this},i.prototype.Fragment_MainBegin=function(e){return this.CustomParts.Fragment_MainBegin=e,this},i.prototype.Fragment_MainEnd=function(e){return this.CustomParts.Fragment_MainEnd=e,this},i.prototype.Fragment_Custom_Diffuse=function(e){return this.CustomParts.Fragment_Custom_Diffuse=e.replace("result","diffuseColor"),this},i.prototype.Fragment_Custom_Alpha=function(e){return this.CustomParts.Fragment_Custom_Alpha=e.replace("result","alpha"),this},i.prototype.Fragment_Before_Lights=function(e){return this.CustomParts.Fragment_Before_Lights=e,this},i.prototype.Fragment_Before_Fog=function(e){return this.CustomParts.Fragment_Before_Fog=e,this},i.prototype.Fragment_Before_FragColor=function(e){return this.CustomParts.Fragment_Before_FragColor=e.replace("result","color"),this},i.prototype.Vertex_Begin=function(e){return this.CustomParts.Vertex_Begin=e,this},i.prototype.Vertex_Definitions=function(e){return this.CustomParts.Vertex_Definitions=e,this},i.prototype.Vertex_MainBegin=function(e){return this.CustomParts.Vertex_MainBegin=e,this},i.prototype.Vertex_Before_PositionUpdated=function(e){return this.CustomParts.Vertex_Before_PositionUpdated=e.replace("result","positionUpdated"),this},i.prototype.Vertex_Before_NormalUpdated=function(e){return this.CustomParts.Vertex_Before_NormalUpdated=e.replace("result","normalUpdated"),this},i.prototype.Vertex_After_WorldPosComputed=function(e){return this.CustomParts.Vertex_After_WorldPosComputed=e,this},i.prototype.Vertex_MainEnd=function(e){return this.CustomParts.Vertex_MainEnd=e,this},i.ShaderIndexer=1,i}(a.StandardMaterial);(0,a.RegisterClass)("BABYLON.CustomMaterial",c);var h=function(){},p=h,m=function(e){function i(t,n){var r=e.call(this,t,n)||this;return r.CustomParts=new h,r.customShaderNameResolve=r.Builder,r.FragmentShader=a.Effect.ShadersStore.pbrPixelShader,r.VertexShader=a.Effect.ShadersStore.pbrVertexShader,r.FragmentShader=r.FragmentShader.replace(/#include<pbrBlockAlbedoOpacity>/g,a.Effect.IncludesShadersStore.pbrBlockAlbedoOpacity),r.FragmentShader=r.FragmentShader.replace(/#include<pbrBlockReflectivity>/g,a.Effect.IncludesShadersStore.pbrBlockReflectivity),r.FragmentShader=r.FragmentShader.replace(/#include<pbrBlockFinalColorComposition>/g,a.Effect.IncludesShadersStore.pbrBlockFinalColorComposition),i.ShaderIndexer++,r._createdShaderName="custompbr_"+i.ShaderIndexer,r}return o(i,e),i.prototype.AttachAfterBind=function(e,i){if(this._newUniformInstances)for(var t in this._newUniformInstances)"vec2"==(n=t.toString().split("-"))[0]?i.setVector2(n[1],this._newUniformInstances[t]):"vec3"==n[0]?this._newUniformInstances[t]instanceof a.Color3?i.setColor3(n[1],this._newUniformInstances[t]):i.setVector3(n[1],this._newUniformInstances[t]):"vec4"==n[0]?(this._newUniformInstances[t]instanceof a.Color4?i.setDirectColor4(n[1],this._newUniformInstances[t]):i.setVector4(n[1],this._newUniformInstances[t]),i.setVector4(n[1],this._newUniformInstances[t])):"mat4"==n[0]?i.setMatrix(n[1],this._newUniformInstances[t]):"float"==n[0]&&i.setFloat(n[1],this._newUniformInstances[t]);if(this._newSamplerInstances)for(var t in this._newSamplerInstances){var n;"sampler2D"==(n=t.toString().split("-"))[0]&&this._newSamplerInstances[t].isReady&&this._newSamplerInstances[t].isReady()&&i.setTexture(n[1],this._newSamplerInstances[t])}},i.prototype.ReviewUniform=function(e,i){if("uniform"==e&&this._newUniforms)for(var t=0;t<this._newUniforms.length;t++)-1==this._customUniform[t].indexOf("sampler")&&i.push(this._newUniforms[t].replace(/\[\d*\]/g,""));if("sampler"==e&&this._newUniforms)for(t=0;t<this._newUniforms.length;t++)-1!=this._customUniform[t].indexOf("sampler")&&i.push(this._newUniforms[t].replace(/\[\d*\]/g,""));return i},i.prototype.Builder=function(e,i,t,n,r,o,s){if(s){var f=s.processFinalCode;s.processFinalCode=function(e,i){if("vertex"===e)return f?f(e,i):i;var t=new a.ShaderCodeInliner(i);return t.inlineToken="#define pbr_inline",t.processCode(),f?f(e,t.code):t.code}}o&&this._customAttributes&&this._customAttributes.length>0&&o.push.apply(o,this._customAttributes),this.ReviewUniform("uniform",i),this.ReviewUniform("sampler",n);var l=this._createdShaderName;return a.Effect.ShadersStore[l+"VertexShader"]&&a.Effect.ShadersStore[l+"PixelShader"]||(a.Effect.ShadersStore[l+"VertexShader"]=this._injectCustomCode(this.VertexShader,"vertex"),a.Effect.ShadersStore[l+"PixelShader"]=this._injectCustomCode(this.FragmentShader,"fragment")),l},i.prototype._injectCustomCode=function(e,i){var t=this._getCustomCode(i);for(var n in t){var r=t[n];if(r&&r.length>0){var o="#define "+n;e=e.replace(o,"\n"+r+"\n"+o)}}return e},i.prototype._getCustomCode=function(e){var i,t;return"vertex"===e?{CUSTOM_VERTEX_BEGIN:this.CustomParts.Vertex_Begin,CUSTOM_VERTEX_DEFINITIONS:((null===(i=this._customUniform)||void 0===i?void 0:i.join("\n"))||"")+(this.CustomParts.Vertex_Definitions||""),CUSTOM_VERTEX_MAIN_BEGIN:this.CustomParts.Vertex_MainBegin,CUSTOM_VERTEX_UPDATE_POSITION:this.CustomParts.Vertex_Before_PositionUpdated,CUSTOM_VERTEX_UPDATE_NORMAL:this.CustomParts.Vertex_Before_NormalUpdated,CUSTOM_VERTEX_MAIN_END:this.CustomParts.Vertex_MainEnd,CUSTOM_VERTEX_UPDATE_WORLDPOS:this.CustomParts.Vertex_After_WorldPosComputed}:{CUSTOM_FRAGMENT_BEGIN:this.CustomParts.Fragment_Begin,CUSTOM_FRAGMENT_MAIN_BEGIN:this.CustomParts.Fragment_MainBegin,CUSTOM_FRAGMENT_DEFINITIONS:((null===(t=this._customUniform)||void 0===t?void 0:t.join("\n"))||"")+(this.CustomParts.Fragment_Definitions||""),CUSTOM_FRAGMENT_UPDATE_ALBEDO:this.CustomParts.Fragment_Custom_Albedo,CUSTOM_FRAGMENT_UPDATE_ALPHA:this.CustomParts.Fragment_Custom_Alpha,CUSTOM_FRAGMENT_BEFORE_LIGHTS:this.CustomParts.Fragment_Before_Lights,CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS:this.CustomParts.Fragment_Custom_MetallicRoughness,CUSTOM_FRAGMENT_UPDATE_MICROSURFACE:this.CustomParts.Fragment_Custom_MicroSurface,CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION:this.CustomParts.Fragment_Before_FinalColorComposition,CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR:this.CustomParts.Fragment_Before_FragColor,CUSTOM_FRAGMENT_MAIN_END:this.CustomParts.Fragment_MainEnd,CUSTOM_FRAGMENT_BEFORE_FOG:this.CustomParts.Fragment_Before_Fog}},i.prototype._afterBind=function(i,t,n){if(void 0===t&&(t=null),t){this.AttachAfterBind(i,t);try{e.prototype._afterBind.call(this,i,t,n)}catch(e){}}},i.prototype.AddUniform=function(e,i,t){return this._customUniform||(this._customUniform=new Array,this._newUniforms=new Array,this._newSamplerInstances={},this._newUniformInstances={}),t&&(-1!=i.indexOf("sampler")?this._newSamplerInstances[i+"-"+e]=t:this._newUniformInstances[i+"-"+e]=t),this._customUniform.push("uniform "+i+" "+e+";"),this._newUniforms.push(e),this},i.prototype.AddAttribute=function(e){return this._customAttributes||(this._customAttributes=[]),this._customAttributes.push(e),this},i.prototype.Fragment_Begin=function(e){return this.CustomParts.Fragment_Begin=e,this},i.prototype.Fragment_Definitions=function(e){return this.CustomParts.Fragment_Definitions=e,this},i.prototype.Fragment_MainBegin=function(e){return this.CustomParts.Fragment_MainBegin=e,this},i.prototype.Fragment_Custom_Albedo=function(e){return this.CustomParts.Fragment_Custom_Albedo=e.replace("result","surfaceAlbedo"),this},i.prototype.Fragment_Custom_Alpha=function(e){return this.CustomParts.Fragment_Custom_Alpha=e.replace("result","alpha"),this},i.prototype.Fragment_Before_Lights=function(e){return this.CustomParts.Fragment_Before_Lights=e,this},i.prototype.Fragment_Custom_MetallicRoughness=function(e){return this.CustomParts.Fragment_Custom_MetallicRoughness=e,this},i.prototype.Fragment_Custom_MicroSurface=function(e){return this.CustomParts.Fragment_Custom_MicroSurface=e,this},i.prototype.Fragment_Before_Fog=function(e){return this.CustomParts.Fragment_Before_Fog=e,this},i.prototype.Fragment_Before_FinalColorComposition=function(e){return this.CustomParts.Fragment_Before_FinalColorComposition=e,this},i.prototype.Fragment_Before_FragColor=function(e){return this.CustomParts.Fragment_Before_FragColor=e.replace("result","color"),this},i.prototype.Fragment_MainEnd=function(e){return this.CustomParts.Fragment_MainEnd=e,this},i.prototype.Vertex_Begin=function(e){return this.CustomParts.Vertex_Begin=e,this},i.prototype.Vertex_Definitions=function(e){return this.CustomParts.Vertex_Definitions=e,this},i.prototype.Vertex_MainBegin=function(e){return this.CustomParts.Vertex_MainBegin=e,this},i.prototype.Vertex_Before_PositionUpdated=function(e){return this.CustomParts.Vertex_Before_PositionUpdated=e.replace("result","positionUpdated"),this},i.prototype.Vertex_Before_NormalUpdated=function(e){return this.CustomParts.Vertex_Before_NormalUpdated=e.replace("result","normalUpdated"),this},i.prototype.Vertex_After_WorldPosComputed=function(e){return this.CustomParts.Vertex_After_WorldPosComputed=e,this},i.prototype.Vertex_MainEnd=function(e){return this.CustomParts.Vertex_MainEnd=e,this},i.ShaderIndexer=1,i}(a.PBRMaterial);(0,a.RegisterClass)("BABYLON.PBRCustomMaterial",m);a.ShaderStore.ShadersStore.firePixelShader="precision highp float;uniform vec4 vEyePosition;varying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;uniform sampler2D diffuseSampler;uniform vec2 vDiffuseInfos;\n#endif\nuniform sampler2D distortionSampler;uniform sampler2D opacitySampler;\n#ifdef DIFFUSE\nvarying vec2 vDistortionCoords1;varying vec2 vDistortionCoords2;varying vec2 vDistortionCoords3;\n#endif\n#include<clipPlaneFragmentDeclaration>\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\nvec4 bx2(vec4 x)\n{return vec4(2.0)*x-vec4(1.0);}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=vec4(1.,1.,1.,1.);float alpha=1.0;\n#ifdef DIFFUSE\nconst float distortionAmount0 =0.092;const float distortionAmount1 =0.092;const float distortionAmount2 =0.092;vec2 heightAttenuation=vec2(0.3,0.39);vec4 noise0=texture2D(distortionSampler,vDistortionCoords1);vec4 noise1=texture2D(distortionSampler,vDistortionCoords2);vec4 noise2=texture2D(distortionSampler,vDistortionCoords3);vec4 noiseSum=bx2(noise0)*distortionAmount0+bx2(noise1)*distortionAmount1+bx2(noise2)*distortionAmount2;vec4 perturbedBaseCoords=vec4(vDiffuseUV,0.0,1.0)+noiseSum*(vDiffuseUV.y*heightAttenuation.x+heightAttenuation.y);vec4 opacityColor=texture2D(opacitySampler,perturbedBaseCoords.xy);\n#ifdef ALPHATEST\nif (opacityColor.r<0.1)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor=texture2D(diffuseSampler,perturbedBaseCoords.xy)*2.0;baseColor*=opacityColor;baseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\nvec3 diffuseBase=vec3(1.0,1.0,1.0);\n#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nalpha*=vColor.a;\n#endif\nvec4 color=vec4(baseColor.rgb,alpha);\n#include<logDepthFragment>\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}";a.ShaderStore.ShadersStore.fireVertexShader="precision highp float;attribute vec3 position;\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#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\nuniform mat4 view;uniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<logDepthDeclaration>\n#include<fogVertexDeclaration>\nuniform float time;uniform float speed;\n#ifdef DIFFUSE\nvarying vec2 vDistortionCoords1;varying vec2 vDistortionCoords2;varying vec2 vDistortionCoords3;\n#endif\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(position,1.0);gl_Position=viewProjection*worldPos;vPositionW=vec3(worldPos);\n#ifdef DIFFUSE\nvDiffuseUV=uv;vDiffuseUV.y-=0.2;\n#endif\n#include<clipPlaneVertex>\n#include<logDepthVertex>\n#include<fogVertex>\n#include<vertexColorMixing>\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#ifdef DIFFUSE\nvec3 layerSpeed=vec3(-0.2,-0.52,-0.1)*speed;vDistortionCoords1.x=uv.x;vDistortionCoords1.y=uv.y+layerSpeed.x*time/1000.0;vDistortionCoords2.x=uv.x;vDistortionCoords2.y=uv.y+layerSpeed.y*time/1000.0;vDistortionCoords3.x=uv.x;vDistortionCoords3.y=uv.y+layerSpeed.z*time/1000.0;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n";var v=function(e){function i(){var i=e.call(this)||this;return i.DIFFUSE=!1,i.CLIPPLANE=!1,i.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!1,i.ALPHATEST=!1,i.DEPTHPREPASS=!1,i.POINTSIZE=!1,i.FOG=!1,i.UV1=!1,i.VERTEXCOLOR=!1,i.VERTEXALPHA=!1,i.BonesPerMesh=0,i.NUM_BONE_INFLUENCERS=0,i.INSTANCES=!1,i.INSTANCESCOLOR=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.LOGARITHMICDEPTH=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),g=function(e){function i(i,t){var n=e.call(this,i,t)||this;return n.diffuseColor=new a.Color3(1,1,1),n.speed=1,n._scaledDiffuse=new a.Color3,n._lastTime=0,n}return o(i,e),i.prototype.needAlphaBlending=function(){return!1},i.prototype.needAlphaTesting=function(){return!0},i.prototype.getAlphaTestTexture=function(){return null},i.prototype.isReadyForSubMesh=function(e,i,t){var n=i._drawWrapper;if(this.isFrozen&&n._wasPreviouslyReady&&n._wasPreviouslyUsingInstances===t)return!0;i.materialDefines||(i.materialDefines=new v);var r=i.materialDefines,o=this.getScene();if(this._isReadyForSubMesh(i))return!0;var s=o.getEngine();if(r._areTexturesDirty&&(r._needUVs=!1,this._diffuseTexture&&a.MaterialFlags.DiffuseTextureEnabled)){if(!this._diffuseTexture.isReady())return!1;r._needUVs=!0,r.DIFFUSE=!0}if(r.ALPHATEST=!!this._opacityTexture,r._areMiscDirty&&(r.POINTSIZE=this.pointsCloud||o.forcePointsCloud,r.FOG=o.fogEnabled&&e.applyFog&&o.fogMode!==a.Scene.FOGMODE_NONE&&this.fogEnabled,r.LOGARITHMICDEPTH=this._useLogarithmicDepth),(0,a.PrepareDefinesForFrameBoundValues)(o,s,this,r,!!t),(0,a.PrepareDefinesForAttributes)(e,r,!1,!0),r.isDirty){r.markAsProcessed(),o.resetCachedMaterial();var f=new a.EffectFallbacks;r.FOG&&f.addFallback(1,"FOG"),r.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,e),r.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var l=[a.VertexBuffer.PositionKind];r.UV1&&l.push(a.VertexBuffer.UVKind),r.VERTEXCOLOR&&l.push(a.VertexBuffer.ColorKind),(0,a.PrepareAttributesForBones)(l,e,r,f),(0,a.PrepareAttributesForInstances)(l,r);var u=["world","view","viewProjection","vEyePosition","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","diffuseMatrix","logarithmicDepthConstant","time","speed"];(0,a.addClipPlaneUniforms)(u);var d=r.toString();i.setEffect(o.getEngine().createEffect("fire",{attributes:l,uniformsNames:u,uniformBuffersNames:[],samplers:["diffuseSampler","distortionSampler","opacitySampler"],defines:d,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:null,maxSimultaneousLights:4,transformFeedbackVaryings:null},s),r,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(r._renderId=o.getRenderId(),n._wasPreviouslyReady=!0,n._wasPreviouslyUsingInstances=!!t,0))},i.prototype.bindForSubMesh=function(e,i,t){var n=this.getScene(),r=t.materialDefines;if(r){var o=t.effect;o&&(this._activeEffect=o,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),(0,a.BindBonesParameters)(i,this._activeEffect),this._mustRebind(n,o,t)&&(this._diffuseTexture&&a.MaterialFlags.DiffuseTextureEnabled&&(this._activeEffect.setTexture("diffuseSampler",this._diffuseTexture),this._activeEffect.setFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),this._activeEffect.setMatrix("diffuseMatrix",this._diffuseTexture.getTextureMatrix()),this._activeEffect.setTexture("distortionSampler",this._distortionTexture),this._activeEffect.setTexture("opacitySampler",this._opacityTexture)),(0,a.bindClipPlane)(this._activeEffect,this,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),this._useLogarithmicDepth&&(0,a.BindLogDepth)(r,o,n),n.bindEyePosition(o)),this._activeEffect.setColor4("vDiffuseColor",this._scaledDiffuse,this.alpha*i.visibility),n.fogEnabled&&i.applyFog&&n.fogMode!==a.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",n.getViewMatrix()),(0,a.BindFogParameters)(n,i,this._activeEffect),this._lastTime+=n.getEngine().getDeltaTime(),this._activeEffect.setFloat("time",this._lastTime),this._activeEffect.setFloat("speed",this.speed),this._afterBind(i,this._activeEffect,t))}},i.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),this._distortionTexture&&this._distortionTexture.animations&&this._distortionTexture.animations.length>0&&e.push(this._distortionTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),e},i.prototype.getActiveTextures=function(){var i=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&i.push(this._diffuseTexture),this._distortionTexture&&i.push(this._distortionTexture),this._opacityTexture&&i.push(this._opacityTexture),i},i.prototype.hasTexture=function(i){return!!e.prototype.hasTexture.call(this,i)||this._diffuseTexture===i||this._distortionTexture===i||this._opacityTexture===i},i.prototype.getClassName=function(){return"FireMaterial"},i.prototype.dispose=function(i){this._diffuseTexture&&this._diffuseTexture.dispose(),this._distortionTexture&&this._distortionTexture.dispose(),e.prototype.dispose.call(this,i)},i.prototype.clone=function(e){var t=this;return a.SerializationHelper.Clone((function(){return new i(e,t.getScene())}),this)},i.prototype.serialize=function(){var i=e.prototype.serialize.call(this);return i.customType="BABYLON.FireMaterial",i.diffuseColor=this.diffuseColor.asArray(),i.speed=this.speed,this._diffuseTexture&&(i._diffuseTexture=this._diffuseTexture.serialize()),this._distortionTexture&&(i._distortionTexture=this._distortionTexture.serialize()),this._opacityTexture&&(i._opacityTexture=this._opacityTexture.serialize()),i},i.Parse=function(e,t,n){var r=new i(e.name,t);return r.diffuseColor=a.Color3.FromArray(e.diffuseColor),r.speed=e.speed,r.alpha=e.alpha,r.id=e.id,a.Tags.AddTagsTo(r,e.tags),r.backFaceCulling=e.backFaceCulling,r.wireframe=e.wireframe,e._diffuseTexture&&(r._diffuseTexture=a.Texture.Parse(e._diffuseTexture,t,n)),e._distortionTexture&&(r._distortionTexture=a.Texture.Parse(e._distortionTexture,t,n)),e._opacityTexture&&(r._opacityTexture=a.Texture.Parse(e._opacityTexture,t,n)),r},s([(0,a.serializeAsTexture)("diffuseTexture")],i.prototype,"_diffuseTexture",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture",void 0),s([(0,a.serializeAsTexture)("distortionTexture")],i.prototype,"_distortionTexture",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"distortionTexture",void 0),s([(0,a.serializeAsTexture)("opacityTexture")],i.prototype,"_opacityTexture",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"opacityTexture",void 0),s([(0,a.serializeAsColor3)("diffuse")],i.prototype,"diffuseColor",void 0),s([(0,a.serialize)()],i.prototype,"speed",void 0),i}(a.PushMaterial);(0,a.RegisterClass)("BABYLON.FireMaterial",g);a.ShaderStore.ShadersStore.furPixelShader="precision highp float;uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;uniform vec4 furColor;uniform float furLength;varying vec3 vPositionW;varying float vfur_length;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<helperFunctions>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;uniform sampler2D diffuseSampler;uniform vec2 vDiffuseInfos;\n#endif\n#ifdef HIGHLEVEL\nuniform float furOffset;uniform float furOcclusion;uniform sampler2D furTexture;varying vec2 vFurUV;\n#endif\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n#include<logDepthDeclaration>\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<fogFragmentDeclaration>\n#include<clipPlaneFragmentDeclaration>\nfloat Rand(vec3 rv) {float x=dot(rv,vec3(12.9898,78.233,24.65487));return fract(sin(x)*43758.5453);}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=furColor;vec3 diffuseColor=vDiffuseColor.rgb;float 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#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#ifdef HIGHLEVEL\nvec4 furTextureColor=texture2D(furTexture,vec2(vFurUV.x,vFurUV.y));if (furTextureColor.a<=0.0 || furTextureColor.g<furOffset) {discard;}\nfloat occlusion=mix(0.0,furTextureColor.b*1.2,furOffset);baseColor=vec4(baseColor.xyz*max(occlusion,furOcclusion),1.1-furOffset);\n#endif\nvec3 diffuseBase=vec3(0.,0.,0.);lightingInfo info;float shadow=1.;float glossiness=0.;float aggShadow=0.;float numLights=0.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase.rgb*baseColor.rgb,0.0,1.0);\n#ifdef HIGHLEVEL\nvec4 color=vec4(finalDiffuse,alpha);\n#else\nfloat r=vfur_length/furLength*0.5;vec4 color=vec4(finalDiffuse*(0.5+r),alpha);\n#endif\n#include<logDepthFragment>\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}";a.ShaderStore.ShadersStore.furVertexShader="precision highp float;attribute vec3 position;attribute vec3 normal;\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#include<bakedVertexAnimationDeclaration>\nuniform float furLength;uniform float furAngle;\n#ifdef HIGHLEVEL\nuniform float furOffset;uniform vec3 furGravity;uniform float furTime;uniform float furSpacing;uniform float furDensity;\n#endif\n#ifdef HEIGHTMAP\nuniform sampler2D heightTexture;\n#endif\n#ifdef HIGHLEVEL\nvarying vec2 vFurUV;\n#endif\n#include<instancesDeclaration>\nuniform mat4 view;uniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;uniform mat4 diffuseMatrix;uniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\nvarying float vfur_length;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<logDepthDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nfloat Rand(vec3 rv) {float x=dot(rv,vec3(12.9898,78.233,24.65487));return fract(sin(x)*43758.5453);}\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nfloat r=Rand(position);\n#ifdef HEIGHTMAP\n#if __VERSION__>100\nvfur_length=furLength*texture(heightTexture,uv).x;\n#else\nvfur_length=furLength*texture2D(heightTexture,uv).r;\n#endif\n#else \nvfur_length=(furLength*r);\n#endif\nvec3 tangent1=vec3(normal.y,-normal.x,0);vec3 tangent2=vec3(-normal.z,0,normal.x);r=Rand(tangent1*r);float J=(2.0+4.0*r);r=Rand(tangent2*r);float K=(2.0+2.0*r);tangent1=tangent1*J+tangent2*K;tangent1=normalize(tangent1);vec3 newPosition=position+normal*vfur_length*cos(furAngle)+tangent1*vfur_length*sin(furAngle);\n#ifdef HIGHLEVEL\nvec3 forceDirection=vec3(0.0,0.0,0.0);forceDirection.x=sin(furTime+position.x*0.05)*0.2;forceDirection.y=cos(furTime*0.7+position.y*0.04)*0.2;forceDirection.z=sin(furTime*0.7+position.z*0.04)*0.2;vec3 displacement=vec3(0.0,0.0,0.0);displacement=furGravity+forceDirection;float displacementFactor=pow(furOffset,3.0);vec3 aNormal=normal;aNormal.xyz+=displacement*displacementFactor;newPosition=vec3(newPosition.x,newPosition.y,newPosition.z)+(normalize(aNormal)*furOffset*furSpacing);\n#endif\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\ngl_Position=viewProjection*finalWorld*vec4(newPosition,1.0);vec4 worldPos=finalWorld*vec4(newPosition,1.0);vPositionW=vec3(worldPos);\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{vDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));}\nelse\n{vDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));}\n#ifdef HIGHLEVEL\nvFurUV=vDiffuseUV*furDensity;\n#endif\n#else\n#ifdef HIGHLEVEL\nvFurUV=uv*furDensity;\n#endif\n#endif\n#include<clipPlaneVertex>\n#include<logDepthVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#include<vertexColorMixing>\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n";var T=function(e){function i(){var i=e.call(this)||this;return i.DIFFUSE=!1,i.HEIGHTMAP=!1,i.CLIPPLANE=!1,i.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!1,i.ALPHATEST=!1,i.DEPTHPREPASS=!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.INSTANCESCOLOR=!1,i.HIGHLEVEL=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.LOGARITHMICDEPTH=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),_=function(e){function i(i,t){var n=e.call(this,i,t)||this;return n.diffuseColor=new a.Color3(1,1,1),n.furLength=1,n.furAngle=0,n.furColor=new a.Color3(.44,.21,.02),n.furOffset=0,n.furSpacing=12,n.furGravity=new a.Vector3(0,0,0),n.furSpeed=100,n.furDensity=20,n.furOcclusion=0,n._disableLighting=!1,n._maxSimultaneousLights=4,n.highLevelFur=!0,n._furTime=0,n}return o(i,e),Object.defineProperty(i.prototype,"furTime",{get:function(){return this._furTime},set:function(e){this._furTime=e},enumerable:!1,configurable:!0}),i.prototype.needAlphaBlending=function(){return this.alpha<1},i.prototype.needAlphaTesting=function(){return!1},i.prototype.getAlphaTestTexture=function(){return null},i.prototype.updateFur=function(){for(var e=1;e<this._meshes.length;e++){var i=this._meshes[e].material;i.furLength=this.furLength,i.furAngle=this.furAngle,i.furGravity=this.furGravity,i.furSpacing=this.furSpacing,i.furSpeed=this.furSpeed,i.furColor=this.furColor,i.diffuseTexture=this.diffuseTexture,i.furTexture=this.furTexture,i.highLevelFur=this.highLevelFur,i.furTime=this.furTime,i.furDensity=this.furDensity}},i.prototype.isReadyForSubMesh=function(e,i,t){var n=i._drawWrapper;if(this.isFrozen&&n.effect&&n._wasPreviouslyReady&&n._wasPreviouslyUsingInstances===t)return!0;i.materialDefines||(i.materialDefines=new T);var r=i.materialDefines,o=this.getScene();if(this._isReadyForSubMesh(i))return!0;var s=o.getEngine();if(r._areTexturesDirty&&o.texturesEnabled){if(this.diffuseTexture&&a.MaterialFlags.DiffuseTextureEnabled){if(!this.diffuseTexture.isReady())return!1;r._needUVs=!0,r.DIFFUSE=!0}if(this.heightTexture&&s.getCaps().maxVertexTextureImageUnits){if(!this.heightTexture.isReady())return!1;r._needUVs=!0,r.HEIGHTMAP=!0}}if(this.highLevelFur!==r.HIGHLEVEL&&(r.HIGHLEVEL=!0,r.markAsUnprocessed()),(0,a.PrepareDefinesForMisc)(e,o,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),r),r._needNormals=(0,a.PrepareDefinesForLights)(o,e,r,!1,this._maxSimultaneousLights,this._disableLighting),(0,a.PrepareDefinesForFrameBoundValues)(o,s,this,r,!!t),(0,a.PrepareDefinesForAttributes)(e,r,!0,!0),r.isDirty){r.markAsProcessed(),o.resetCachedMaterial();var f=new a.EffectFallbacks;r.FOG&&f.addFallback(1,"FOG"),(0,a.HandleFallbacksForShadows)(r,f,this.maxSimultaneousLights),r.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,e),r.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var l=[a.VertexBuffer.PositionKind];r.NORMAL&&l.push(a.VertexBuffer.NormalKind),r.UV1&&l.push(a.VertexBuffer.UVKind),r.UV2&&l.push(a.VertexBuffer.UV2Kind),r.VERTEXCOLOR&&l.push(a.VertexBuffer.ColorKind),(0,a.PrepareAttributesForBones)(l,e,r,f),(0,a.PrepareAttributesForInstances)(l,r);var u=r.toString(),d=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","diffuseMatrix","logarithmicDepthConstant","furLength","furAngle","furColor","furOffset","furGravity","furTime","furSpacing","furDensity","furOcclusion"];(0,a.addClipPlaneUniforms)(d);var c=["diffuseSampler","heightTexture","furTexture"],h=[];(0,a.PrepareUniformsAndSamplersList)({uniformsNames:d,uniformBuffersNames:h,samplers:c,defines:r,maxSimultaneousLights:this.maxSimultaneousLights}),i.setEffect(o.getEngine().createEffect("fur",{attributes:l,uniformsNames:d,uniformBuffersNames:h,samplers:c,defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights}},s),r,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(r._renderId=o.getRenderId(),n._wasPreviouslyReady=!0,n._wasPreviouslyUsingInstances=!!t,0))},i.prototype.bindForSubMesh=function(e,i,t){var n=this.getScene(),r=t.materialDefines;if(r){var o=t.effect;o&&(this._activeEffect=o,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),(0,a.BindBonesParameters)(i,this._activeEffect),this._mustRebind(n,o,t)&&(this._diffuseTexture&&a.MaterialFlags.DiffuseTextureEnabled&&(this._activeEffect.setTexture("diffuseSampler",this._diffuseTexture),this._activeEffect.setFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),this._activeEffect.setMatrix("diffuseMatrix",this._diffuseTexture.getTextureMatrix())),this._heightTexture&&this._activeEffect.setTexture("heightTexture",this._heightTexture),(0,a.bindClipPlane)(this._activeEffect,this,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),this._useLogarithmicDepth&&(0,a.BindLogDepth)(r,o,n),n.bindEyePosition(o)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility),n.lightsEnabled&&!this.disableLighting&&(0,a.BindLights)(n,i,this._activeEffect,r,this.maxSimultaneousLights),n.fogEnabled&&i.applyFog&&n.fogMode!==a.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",n.getViewMatrix()),(0,a.BindFogParameters)(n,i,this._activeEffect),this._activeEffect.setFloat("furLength",this.furLength),this._activeEffect.setFloat("furAngle",this.furAngle),this._activeEffect.setColor4("furColor",this.furColor,1),this.highLevelFur&&(this._activeEffect.setVector3("furGravity",this.furGravity),this._activeEffect.setFloat("furOffset",this.furOffset),this._activeEffect.setFloat("furSpacing",this.furSpacing),this._activeEffect.setFloat("furDensity",this.furDensity),this._activeEffect.setFloat("furOcclusion",this.furOcclusion),this._furTime+=this.getScene().getEngine().getDel