{"ast":null,"code":"import { NodeMaterialBlock } from \"../../nodeMaterialBlock.js\";\nimport { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes.js\";\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets.js\";\nimport { RegisterClass } from \"../../../../Misc/typeStore.js\";\n/**\n * Block used for the particle ramp gradient section\n */\nexport class ParticleRampGradientBlock extends NodeMaterialBlock {\n /**\n * Create a new ParticleRampGradientBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name, NodeMaterialBlockTargets.Fragment);\n this._isUnique = true;\n this.registerInput(\"color\", NodeMaterialBlockConnectionPointTypes.Color4, false, NodeMaterialBlockTargets.Fragment);\n this.registerOutput(\"rampColor\", NodeMaterialBlockConnectionPointTypes.Color4, NodeMaterialBlockTargets.Fragment);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"ParticleRampGradientBlock\";\n }\n /**\n * Gets the color input component\n */\n get color() {\n return this._inputs[0];\n }\n /**\n * Gets the rampColor output component\n */\n get rampColor() {\n return this._outputs[0];\n }\n /**\n * Initialize the block and prepare the context for build\n * @param state defines the state that will be used for the build\n */\n initialize(state) {\n state._excludeVariableName(\"remapRanges\");\n state._excludeVariableName(\"rampSampler\");\n state._excludeVariableName(\"baseColor\");\n state._excludeVariableName(\"alpha\");\n state._excludeVariableName(\"remappedColorIndex\");\n state._excludeVariableName(\"rampColor\");\n }\n _buildBlock(state) {\n super._buildBlock(state);\n if (state.target === NodeMaterialBlockTargets.Vertex) {\n return;\n }\n state._emit2DSampler(\"rampSampler\", \"RAMPGRADIENT\");\n state._emitVaryingFromString(\"remapRanges\", NodeMaterialBlockConnectionPointTypes.Vector4, \"RAMPGRADIENT\");\n state.compilationString += `\n #ifdef RAMPGRADIENT\n ${state._declareLocalVar(\"baseColor\", NodeMaterialBlockConnectionPointTypes.Vector4)} = ${this.color.associatedVariableName};\n ${state._declareLocalVar(\"alpha\", NodeMaterialBlockConnectionPointTypes.Float)} = ${this.color.associatedVariableName}.a;\n\n ${state._declareLocalVar(\"remappedColorIndex\", NodeMaterialBlockConnectionPointTypes.Float)} = clamp((alpha - remapRanges.x) / remapRanges.y, 0.0, 1.0);\n\n ${state._declareLocalVar(\"rampColor\", NodeMaterialBlockConnectionPointTypes.Vector4)} = ${state._generateTextureSample(\"vec2(1.0 - remappedColorIndex, 0.)\", \"rampSampler\")};\n\n // Remapped alpha\n ${state._declareOutput(this.rampColor)} = vec4${state.fSuffix}(baseColor.rgb * rampColor.rgb, clamp((alpha * rampColor.a - remapRanges.z) / remapRanges.w, 0.0, 1.0));\n #else\n ${state._declareOutput(this.rampColor)} = ${this.color.associatedVariableName};\n #endif\n `;\n return this;\n }\n}\nRegisterClass(\"BABYLON.ParticleRampGradientBlock\", ParticleRampGradientBlock);","map":{"version":3,"names":["NodeMaterialBlock","NodeMaterialBlockConnectionPointTypes","NodeMaterialBlockTargets","RegisterClass","ParticleRampGradientBlock","constructor","name","Fragment","_isUnique","registerInput","Color4","registerOutput","getClassName","color","_inputs","rampColor","_outputs","initialize","state","_excludeVariableName","_buildBlock","target","Vertex","_emit2DSampler","_emitVaryingFromString","Vector4","compilationString","_declareLocalVar","associatedVariableName","Float","_generateTextureSample","_declareOutput","fSuffix"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Materials/Node/Blocks/Particle/particleRampGradientBlock.js"],"sourcesContent":["import { NodeMaterialBlock } from \"../../nodeMaterialBlock.js\";\nimport { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes.js\";\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets.js\";\nimport { RegisterClass } from \"../../../../Misc/typeStore.js\";\n/**\n * Block used for the particle ramp gradient section\n */\nexport class ParticleRampGradientBlock extends NodeMaterialBlock {\n /**\n * Create a new ParticleRampGradientBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name, NodeMaterialBlockTargets.Fragment);\n this._isUnique = true;\n this.registerInput(\"color\", NodeMaterialBlockConnectionPointTypes.Color4, false, NodeMaterialBlockTargets.Fragment);\n this.registerOutput(\"rampColor\", NodeMaterialBlockConnectionPointTypes.Color4, NodeMaterialBlockTargets.Fragment);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"ParticleRampGradientBlock\";\n }\n /**\n * Gets the color input component\n */\n get color() {\n return this._inputs[0];\n }\n /**\n * Gets the rampColor output component\n */\n get rampColor() {\n return this._outputs[0];\n }\n /**\n * Initialize the block and prepare the context for build\n * @param state defines the state that will be used for the build\n */\n initialize(state) {\n state._excludeVariableName(\"remapRanges\");\n state._excludeVariableName(\"rampSampler\");\n state._excludeVariableName(\"baseColor\");\n state._excludeVariableName(\"alpha\");\n state._excludeVariableName(\"remappedColorIndex\");\n state._excludeVariableName(\"rampColor\");\n }\n _buildBlock(state) {\n super._buildBlock(state);\n if (state.target === NodeMaterialBlockTargets.Vertex) {\n return;\n }\n state._emit2DSampler(\"rampSampler\", \"RAMPGRADIENT\");\n state._emitVaryingFromString(\"remapRanges\", NodeMaterialBlockConnectionPointTypes.Vector4, \"RAMPGRADIENT\");\n state.compilationString += `\r\n #ifdef RAMPGRADIENT\r\n ${state._declareLocalVar(\"baseColor\", NodeMaterialBlockConnectionPointTypes.Vector4)} = ${this.color.associatedVariableName};\r\n ${state._declareLocalVar(\"alpha\", NodeMaterialBlockConnectionPointTypes.Float)} = ${this.color.associatedVariableName}.a;\r\n\r\n ${state._declareLocalVar(\"remappedColorIndex\", NodeMaterialBlockConnectionPointTypes.Float)} = clamp((alpha - remapRanges.x) / remapRanges.y, 0.0, 1.0);\r\n\r\n ${state._declareLocalVar(\"rampColor\", NodeMaterialBlockConnectionPointTypes.Vector4)} = ${state._generateTextureSample(\"vec2(1.0 - remappedColorIndex, 0.)\", \"rampSampler\")};\r\n\r\n // Remapped alpha\r\n ${state._declareOutput(this.rampColor)} = vec4${state.fSuffix}(baseColor.rgb * rampColor.rgb, clamp((alpha * rampColor.a - remapRanges.z) / remapRanges.w, 0.0, 1.0));\r\n #else\r\n ${state._declareOutput(this.rampColor)} = ${this.color.associatedVariableName};\r\n #endif\r\n `;\n return this;\n }\n}\nRegisterClass(\"BABYLON.ParticleRampGradientBlock\", ParticleRampGradientBlock);\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,4BAA4B;AAC9D,SAASC,qCAAqC,QAAQ,sDAAsD;AAC5G,SAASC,wBAAwB,QAAQ,yCAAyC;AAClF,SAASC,aAAa,QAAQ,+BAA+B;AAC7D;AACA;AACA;AACA,OAAO,MAAMC,yBAAyB,SAASJ,iBAAiB,CAAC;EAC7D;AACJ;AACA;AACA;EACIK,WAAWA,CAACC,IAAI,EAAE;IACd,KAAK,CAACA,IAAI,EAAEJ,wBAAwB,CAACK,QAAQ,CAAC;IAC9C,IAAI,CAACC,SAAS,GAAG,IAAI;IACrB,IAAI,CAACC,aAAa,CAAC,OAAO,EAAER,qCAAqC,CAACS,MAAM,EAAE,KAAK,EAAER,wBAAwB,CAACK,QAAQ,CAAC;IACnH,IAAI,CAACI,cAAc,CAAC,WAAW,EAAEV,qCAAqC,CAACS,MAAM,EAAER,wBAAwB,CAACK,QAAQ,CAAC;EACrH;EACA;AACJ;AACA;AACA;EACIK,YAAYA,CAAA,EAAG;IACX,OAAO,2BAA2B;EACtC;EACA;AACJ;AACA;EACI,IAAIC,KAAKA,CAAA,EAAG;IACR,OAAO,IAAI,CAACC,OAAO,CAAC,CAAC,CAAC;EAC1B;EACA;AACJ;AACA;EACI,IAAIC,SAASA,CAAA,EAAG;IACZ,OAAO,IAAI,CAACC,QAAQ,CAAC,CAAC,CAAC;EAC3B;EACA;AACJ;AACA;AACA;EACIC,UAAUA,CAACC,KAAK,EAAE;IACdA,KAAK,CAACC,oBAAoB,CAAC,aAAa,CAAC;IACzCD,KAAK,CAACC,oBAAoB,CAAC,aAAa,CAAC;IACzCD,KAAK,CAACC,oBAAoB,CAAC,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