1 |
- {"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 to desaturate a color\n */\nexport class DesaturateBlock extends NodeMaterialBlock {\n /**\n * Creates a new DesaturateBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name, NodeMaterialBlockTargets.Neutral);\n this.registerInput(\"color\", NodeMaterialBlockConnectionPointTypes.Color3);\n this.registerInput(\"level\", NodeMaterialBlockConnectionPointTypes.Float);\n this.registerOutput(\"output\", NodeMaterialBlockConnectionPointTypes.Color3);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"DesaturateBlock\";\n }\n /**\n * Gets the color operand input component\n */\n get color() {\n return this._inputs[0];\n }\n /**\n * Gets the level operand input component\n */\n get level() {\n return this._inputs[1];\n }\n /**\n * Gets the output component\n */\n get output() {\n return this._outputs[0];\n }\n _buildBlock(state) {\n super._buildBlock(state);\n const output = this._outputs[0];\n const color = this.color;\n const colorName = color.associatedVariableName;\n const tempMin = state._getFreeVariableName(\"colorMin\");\n const tempMax = state._getFreeVariableName(\"colorMax\");\n const tempMerge = state._getFreeVariableName(\"colorMerge\");\n state.compilationString += `${state._declareLocalVar(tempMin, NodeMaterialBlockConnectionPointTypes.Float)} = min(min(${colorName}.x, ${colorName}.y), ${colorName}.z);\\n`;\n state.compilationString += `${state._declareLocalVar(tempMax, NodeMaterialBlockConnectionPointTypes.Float)} = max(max(${colorName}.x, ${colorName}.y), ${colorName}.z);\\n`;\n state.compilationString += `${state._declareLocalVar(tempMerge, NodeMaterialBlockConnectionPointTypes.Float)} = 0.5 * (${tempMin} + ${tempMax});\\n`;\n state.compilationString += state._declareOutput(output) + ` = mix(${colorName}, ${state._getShaderType(NodeMaterialBlockConnectionPointTypes.Vector3)}(${tempMerge}, ${tempMerge}, ${tempMerge}), ${this.level.associatedVariableName});\\n`;\n return this;\n }\n}\nRegisterClass(\"BABYLON.DesaturateBlock\", DesaturateBlock);","map":{"version":3,"names":["NodeMaterialBlock","NodeMaterialBlockConnectionPointTypes","NodeMaterialBlockTargets","RegisterClass","DesaturateBlock","constructor","name","Neutral","registerInput","Color3","Float","registerOutput","getClassName","color","_inputs","level","output","_outputs","_buildBlock","state","colorName","associatedVariableName","tempMin","_getFreeVariableName","tempMax","tempMerge","compilationString","_declareLocalVar","_declareOutput","_getShaderType","Vector3"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Materials/Node/Blocks/desaturateBlock.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 to desaturate a color\n */\nexport class DesaturateBlock extends NodeMaterialBlock {\n /**\n * Creates a new DesaturateBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name, NodeMaterialBlockTargets.Neutral);\n this.registerInput(\"color\", NodeMaterialBlockConnectionPointTypes.Color3);\n this.registerInput(\"level\", NodeMaterialBlockConnectionPointTypes.Float);\n this.registerOutput(\"output\", NodeMaterialBlockConnectionPointTypes.Color3);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"DesaturateBlock\";\n }\n /**\n * Gets the color operand input component\n */\n get color() {\n return this._inputs[0];\n }\n /**\n * Gets the level operand input component\n */\n get level() {\n return this._inputs[1];\n }\n /**\n * Gets the output component\n */\n get output() {\n return this._outputs[0];\n }\n _buildBlock(state) {\n super._buildBlock(state);\n const output = this._outputs[0];\n const color = this.color;\n const colorName = color.associatedVariableName;\n const tempMin = state._getFreeVariableName(\"colorMin\");\n const tempMax = state._getFreeVariableName(\"colorMax\");\n const tempMerge = state._getFreeVariableName(\"colorMerge\");\n state.compilationString += `${state._declareLocalVar(tempMin, NodeMaterialBlockConnectionPointTypes.Float)} = min(min(${colorName}.x, ${colorName}.y), ${colorName}.z);\\n`;\n state.compilationString += `${state._declareLocalVar(tempMax, NodeMaterialBlockConnectionPointTypes.Float)} = max(max(${colorName}.x, ${colorName}.y), ${colorName}.z);\\n`;\n state.compilationString += `${state._declareLocalVar(tempMerge, NodeMaterialBlockConnectionPointTypes.Float)} = 0.5 * (${tempMin} + ${tempMax});\\n`;\n state.compilationString +=\n state._declareOutput(output) +\n ` = mix(${colorName}, ${state._getShaderType(NodeMaterialBlockConnectionPointTypes.Vector3)}(${tempMerge}, ${tempMerge}, ${tempMerge}), ${this.level.associatedVariableName});\\n`;\n return this;\n }\n}\nRegisterClass(\"BABYLON.DesaturateBlock\", DesaturateBlock);\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,yBAAyB;AAC3D,SAASC,qCAAqC,QAAQ,mDAAmD;AACzG,SAASC,wBAAwB,QAAQ,sCAAsC;AAC/E,SAASC,aAAa,QAAQ,4BAA4B;AAC1D;AACA;AACA;AACA,OAAO,MAAMC,eAAe,SAASJ,iBAAiB,CAAC;EACnD;AACJ;AACA;AACA;EACIK,WAAWA,CAACC,IAAI,EAAE;IACd,KAAK,CAACA,IAAI,EAAEJ,wBAAwB,CAACK,OAAO,CAAC;IAC7C,IAAI,CAACC,aAAa,CAAC,OAAO,EAAEP,qCAAqC,CAACQ,MAAM,CAAC;IACzE,IAAI,CAACD,aAAa,CAAC,OAAO,EAAEP,qCAAqC,CAACS,KAAK,CAAC;IACxE,IAAI,CAACC,cAAc,CAAC,QAAQ,EAAEV,qCAAqC,CAACQ,MAAM,CAAC;EAC/E;EACA;AACJ;AACA;AACA;EACIG,YAAYA,CAAA,EAAG;IACX,OAAO,iBAAiB;EAC5B;EACA;AACJ;AACA;EACI,IAAIC,KAAK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