1 |
- {"ast":null,"code":"import { Vector3 } from \"../../../Maths/math.vector.js\";\nimport { RegisterClass } from \"../../../Misc/typeStore.js\";\nimport { NodeGeometryBlockConnectionPointTypes } from \"../Enums/nodeGeometryConnectionPointTypes.js\";\nimport { NodeGeometryBlock } from \"../nodeGeometryBlock.js\";\n/**\n * Block used to desaturate a color\n */\nexport class GeometryDesaturateBlock extends NodeGeometryBlock {\n /**\n * Creates a new GeometryDesaturateBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name);\n this.registerInput(\"color\", NodeGeometryBlockConnectionPointTypes.Vector3);\n this.registerInput(\"level\", NodeGeometryBlockConnectionPointTypes.Float, true, 0);\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Vector3);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"GeometryDesaturateBlock\";\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() {\n if (!this.color.isConnected) {\n this.output._storedFunction = null;\n this.output._storedValue = null;\n return;\n }\n this.output._storedFunction = state => {\n const color = this.color.getConnectedValue(state);\n const level = this.level.getConnectedValue(state);\n const tempMin = Math.min(color.x, color.y, color.z);\n const tempMax = Math.max(color.x, color.y, color.z);\n const tempMerge = 0.5 * (tempMin + tempMax);\n return new Vector3(color.x * (1 - level) + tempMerge * level, color.y * (1 - level) + tempMerge * level, color.z * (1 - level) + tempMerge * level);\n };\n return this;\n }\n}\nRegisterClass(\"BABYLON.GeometryDesaturateBlock\", GeometryDesaturateBlock);","map":{"version":3,"names":["Vector3","RegisterClass","NodeGeometryBlockConnectionPointTypes","NodeGeometryBlock","GeometryDesaturateBlock","constructor","name","registerInput","Float","registerOutput","getClassName","color","_inputs","level","output","_outputs","_buildBlock","isConnected","_storedFunction","_storedValue","state","getConnectedValue","tempMin","Math","min","x","y","z","tempMax","max","tempMerge"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Meshes/Node/Blocks/geometryDesaturateBlock.js"],"sourcesContent":["import { Vector3 } from \"../../../Maths/math.vector.js\";\nimport { RegisterClass } from \"../../../Misc/typeStore.js\";\nimport { NodeGeometryBlockConnectionPointTypes } from \"../Enums/nodeGeometryConnectionPointTypes.js\";\nimport { NodeGeometryBlock } from \"../nodeGeometryBlock.js\";\n/**\n * Block used to desaturate a color\n */\nexport class GeometryDesaturateBlock extends NodeGeometryBlock {\n /**\n * Creates a new GeometryDesaturateBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name);\n this.registerInput(\"color\", NodeGeometryBlockConnectionPointTypes.Vector3);\n this.registerInput(\"level\", NodeGeometryBlockConnectionPointTypes.Float, true, 0);\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Vector3);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"GeometryDesaturateBlock\";\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() {\n if (!this.color.isConnected) {\n this.output._storedFunction = null;\n this.output._storedValue = null;\n return;\n }\n this.output._storedFunction = (state) => {\n const color = this.color.getConnectedValue(state);\n const level = this.level.getConnectedValue(state);\n const tempMin = Math.min(color.x, color.y, color.z);\n const tempMax = Math.max(color.x, color.y, color.z);\n const tempMerge = 0.5 * (tempMin + tempMax);\n return new Vector3(color.x * (1 - level) + tempMerge * level, color.y * (1 - level) + tempMerge * level, color.z * (1 - level) + tempMerge * level);\n };\n return this;\n }\n}\nRegisterClass(\"BABYLON.GeometryDesaturateBlock\", GeometryDesaturateBlock);\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,+BAA+B;AACvD,SAASC,aAAa,QAAQ,4BAA4B;AAC1D,SAAS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