10f68a8a67a69fe30ed2f97ce8a214e9d0f4d2b4dbd88d33f00b63f7f7a4e33d.json 9.3 KB

1
  1. {"ast":null,"code":"import { NodeMaterialBlock } from \"../nodeMaterialBlock.js\";\nimport { NodeMaterialBlockTargets } from \"../Enums/nodeMaterialBlockTargets.js\";\nimport { NodeMaterialBlockConnectionPointTypes } from \"../Enums/nodeMaterialBlockConnectionPointTypes.js\";\nimport { RegisterClass } from \"../../../Misc/typeStore.js\";\nimport { InputBlock } from \"./Input/inputBlock.js\";\nimport \"../../../Shaders/ShadersInclude/fresnelFunction.js\";\nimport { ViewDirectionBlock } from \"./viewDirectionBlock.js\";\n/**\n * Block used to compute fresnel value\n */\nexport class FresnelBlock extends NodeMaterialBlock {\n /**\n * Create a new FresnelBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name, NodeMaterialBlockTargets.Neutral);\n this.registerInput(\"worldNormal\", NodeMaterialBlockConnectionPointTypes.Vector4);\n this.registerInput(\"viewDirection\", NodeMaterialBlockConnectionPointTypes.Vector3);\n this.registerInput(\"bias\", NodeMaterialBlockConnectionPointTypes.Float);\n this.registerInput(\"power\", NodeMaterialBlockConnectionPointTypes.Float);\n this.registerOutput(\"fresnel\", NodeMaterialBlockConnectionPointTypes.Float);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"FresnelBlock\";\n }\n /**\n * Gets the world normal input component\n */\n get worldNormal() {\n return this._inputs[0];\n }\n /**\n * Gets the view direction input component\n */\n get viewDirection() {\n return this._inputs[1];\n }\n /**\n * Gets the bias input component\n */\n get bias() {\n return this._inputs[2];\n }\n /**\n * Gets the camera (or eye) position component\n */\n get power() {\n return this._inputs[3];\n }\n /**\n * Gets the fresnel output component\n */\n get fresnel() {\n return this._outputs[0];\n }\n autoConfigure(material) {\n if (!this.viewDirection.isConnected) {\n const viewDirectionInput = new ViewDirectionBlock(\"View direction\");\n viewDirectionInput.output.connectTo(this.viewDirection);\n viewDirectionInput.autoConfigure(material);\n }\n if (!this.bias.isConnected) {\n const biasInput = new InputBlock(\"bias\");\n biasInput.value = 0;\n biasInput.output.connectTo(this.bias);\n }\n if (!this.power.isConnected) {\n const powerInput = new InputBlock(\"power\");\n powerInput.value = 1;\n powerInput.output.connectTo(this.power);\n }\n }\n _buildBlock(state) {\n super._buildBlock(state);\n const comments = `//${this.name}`;\n state._emitFunctionFromInclude(\"fresnelFunction\", comments, {\n removeIfDef: true\n });\n state.compilationString += state._declareOutput(this.fresnel) + ` = computeFresnelTerm(${this.viewDirection.associatedVariableName}.xyz, ${this.worldNormal.associatedVariableName}.xyz, ${this.bias.associatedVariableName}, ${this.power.associatedVariableName});\\n`;\n return this;\n }\n}\nRegisterClass(\"BABYLON.FresnelBlock\", FresnelBlock);","map":{"version":3,"names":["NodeMaterialBlock","NodeMaterialBlockTargets","NodeMaterialBlockConnectionPointTypes","RegisterClass","InputBlock","ViewDirectionBlock","FresnelBlock","constructor","name","Neutral","registerInput","Vector4","Vector3","Float","registerOutput","getClassName","worldNormal","_inputs","viewDirection","bias","power","fresnel","_outputs","autoConfigure","material","isConnected","viewDirectionInput","output","connectTo","biasInput","value","powerInput","_buildBlock","state","comments","_emitFunctionFromInclude","removeIfDef","compilationString","_declareOutput","associatedVariableName"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Materials/Node/Blocks/fresnelBlock.js"],"sourcesContent":["import { NodeMaterialBlock } from \"../nodeMaterialBlock.js\";\nimport { NodeMaterialBlockTargets } from \"../Enums/nodeMaterialBlockTargets.js\";\nimport { NodeMaterialBlockConnectionPointTypes } from \"../Enums/nodeMaterialBlockConnectionPointTypes.js\";\nimport { RegisterClass } from \"../../../Misc/typeStore.js\";\nimport { InputBlock } from \"./Input/inputBlock.js\";\nimport \"../../../Shaders/ShadersInclude/fresnelFunction.js\";\nimport { ViewDirectionBlock } from \"./viewDirectionBlock.js\";\n/**\n * Block used to compute fresnel value\n */\nexport class FresnelBlock extends NodeMaterialBlock {\n /**\n * Create a new FresnelBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name, NodeMaterialBlockTargets.Neutral);\n this.registerInput(\"worldNormal\", NodeMaterialBlockConnectionPointTypes.Vector4);\n this.registerInput(\"viewDirection\", NodeMaterialBlockConnectionPointTypes.Vector3);\n this.registerInput(\"bias\", NodeMaterialBlockConnectionPointTypes.Float);\n this.registerInput(\"power\", NodeMaterialBlockConnectionPointTypes.Float);\n this.registerOutput(\"fresnel\", NodeMaterialBlockConnectionPointTypes.Float);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"FresnelBlock\";\n }\n /**\n * Gets the world normal input component\n */\n get worldNormal() {\n return this._inputs[0];\n }\n /**\n * Gets the view direction input component\n */\n get viewDirection() {\n return this._inputs[1];\n }\n /**\n * Gets the bias input component\n */\n get bias() {\n return this._inputs[2];\n }\n /**\n * Gets the camera (or eye) position component\n */\n get power() {\n return this._inputs[3];\n }\n /**\n * Gets the fresnel output component\n */\n get fresnel() {\n return this._outputs[0];\n }\n autoConfigure(material) {\n if (!this.viewDirection.isConnected) {\n const viewDirectionInput = new ViewDirectionBlock(\"View direction\");\n viewDirectionInput.output.connectTo(this.viewDirection);\n viewDirectionInput.autoConfigure(material);\n }\n if (!this.bias.isConnected) {\n const biasInput = new InputBlock(\"bias\");\n biasInput.value = 0;\n biasInput.output.connectTo(this.bias);\n }\n if (!this.power.isConnected) {\n const powerInput = new InputBlock(\"power\");\n powerInput.value = 1;\n powerInput.output.connectTo(this.power);\n }\n }\n _buildBlock(state) {\n super._buildBlock(state);\n const comments = `//${this.name}`;\n state._emitFunctionFromInclude(\"fresnelFunction\", comments, { removeIfDef: true });\n state.compilationString +=\n state._declareOutput(this.fresnel) +\n ` = computeFresnelTerm(${this.viewDirection.associatedVariableName}.xyz, ${this.worldNormal.associatedVariableName}.xyz, ${this.bias.associatedVariableName}, ${this.power.associatedVariableName});\\n`;\n return this;\n }\n}\nRegisterClass(\"BABYLON.FresnelBlock\", FresnelBlock);\n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