a8636104821c5e7d3723ca5866dfeb7b80ca3421ff538397d0715f9641bc84db.json 13 KB

1
  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\";\nimport { NodeMaterialSystemValues } from \"../../Enums/nodeMaterialSystemValues.js\";\nimport { InputBlock } from \"../Input/inputBlock.js\";\n/**\n * Block used to transform a vector3 or a vector4 into screen space\n */\nexport class ScreenSpaceBlock extends NodeMaterialBlock {\n /**\n * Creates a new ScreenSpaceBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name, NodeMaterialBlockTargets.Fragment);\n this.registerInput(\"vector\", NodeMaterialBlockConnectionPointTypes.AutoDetect);\n this.registerInput(\"worldViewProjection\", NodeMaterialBlockConnectionPointTypes.Matrix);\n this.registerOutput(\"output\", NodeMaterialBlockConnectionPointTypes.Vector2);\n this.registerOutput(\"x\", NodeMaterialBlockConnectionPointTypes.Float);\n this.registerOutput(\"y\", NodeMaterialBlockConnectionPointTypes.Float);\n this.inputs[0].addExcludedConnectionPointFromAllowedTypes(NodeMaterialBlockConnectionPointTypes.Color3 | NodeMaterialBlockConnectionPointTypes.Vector3 | NodeMaterialBlockConnectionPointTypes.Vector4);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"ScreenSpaceBlock\";\n }\n /**\n * Gets the vector input\n */\n get vector() {\n return this._inputs[0];\n }\n /**\n * Gets the worldViewProjection transform input\n */\n get worldViewProjection() {\n return this._inputs[1];\n }\n /**\n * Gets the output component\n */\n get output() {\n return this._outputs[0];\n }\n /**\n * Gets the x output component\n */\n get x() {\n return this._outputs[1];\n }\n /**\n * Gets the y output component\n */\n get y() {\n return this._outputs[2];\n }\n autoConfigure(material, additionalFilteringInfo = () => true) {\n if (!this.worldViewProjection.isConnected) {\n let worldViewProjectionInput = material.getInputBlockByPredicate(b => b.systemValue === NodeMaterialSystemValues.WorldViewProjection && additionalFilteringInfo(b));\n if (!worldViewProjectionInput) {\n worldViewProjectionInput = new InputBlock(\"worldViewProjection\");\n worldViewProjectionInput.setAsSystemValue(NodeMaterialSystemValues.WorldViewProjection);\n }\n worldViewProjectionInput.output.connectTo(this.worldViewProjection);\n }\n }\n _buildBlock(state) {\n super._buildBlock(state);\n const vector = this.vector;\n const worldViewProjection = this.worldViewProjection;\n if (!vector.connectedPoint) {\n return;\n }\n const worldViewProjectionName = worldViewProjection.associatedVariableName;\n const tempVariableName = state._getFreeVariableName(\"screenSpaceTemp\");\n switch (vector.connectedPoint.type) {\n case NodeMaterialBlockConnectionPointTypes.Vector3:\n state.compilationString += `${state._declareLocalVar(tempVariableName, NodeMaterialBlockConnectionPointTypes.Vector4)} = ${worldViewProjectionName} * vec4${state.fSuffix}(${vector.associatedVariableName}, 1.0);\\n`;\n break;\n case NodeMaterialBlockConnectionPointTypes.Vector4:\n state.compilationString += `${state._declareLocalVar(tempVariableName, NodeMaterialBlockConnectionPointTypes.Vector4)} = ${worldViewProjectionName} * ${vector.associatedVariableName};\\n`;\n break;\n }\n state.compilationString += `${tempVariableName} = vec4${state.fSuffix}(${tempVariableName}.xy / ${tempVariableName}.w, ${tempVariableName}.zw);`;\n state.compilationString += `${tempVariableName} = vec4${state.fSuffix}(${tempVariableName}.xy * 0.5 + vec2${state.fSuffix}(0.5, 0.5), ${tempVariableName}.zw);`;\n if (this.output.hasEndpoints) {\n state.compilationString += state._declareOutput(this.output) + ` = ${tempVariableName}.xy;\\n`;\n }\n if (this.x.hasEndpoints) {\n state.compilationString += state._declareOutput(this.x) + ` = ${tempVariableName}.x;\\n`;\n }\n if (this.y.hasEndpoints) {\n state.compilationString += state._declareOutput(this.y) + ` = ${tempVariableName}.y;\\n`;\n }\n return this;\n }\n}\nRegisterClass(\"BABYLON.ScreenSpaceBlock\", ScreenSpaceBlock);","map":{"version":3,"names":["NodeMaterialBlock","NodeMaterialBlockConnectionPointTypes","NodeMaterialBlockTargets","RegisterClass","NodeMaterialSystemValues","InputBlock","ScreenSpaceBlock","constructor","name","Fragment","registerInput","AutoDetect","Matrix","registerOutput","Vector2","Float","inputs","addExcludedConnectionPointFromAllowedTypes","Color3","Vector3","Vector4","getClassName","vector","_inputs","worldViewProjection","output","_outputs","x","y","autoConfigure","material","additionalFilteringInfo","isConnected","worldViewProjectionInput","getInputBlockByPredicate","b","systemValue","WorldViewProjection","setAsSystemValue","connectTo","_buildBlock","state","connectedPoint","worldViewProjectionName","associatedVariableName","tempVariableName","_getFreeVariableName","type","compilationString","_declareLocalVar","fSuffix","hasEndpoints","_declareOutput"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Materials/Node/Blocks/Fragment/screenSpaceBlock.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\";\nimport { NodeMaterialSystemValues } from \"../../Enums/nodeMaterialSystemValues.js\";\nimport { InputBlock } from \"../Input/inputBlock.js\";\n/**\n * Block used to transform a vector3 or a vector4 into screen space\n */\nexport class ScreenSpaceBlock extends NodeMaterialBlock {\n /**\n * Creates a new ScreenSpaceBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name, NodeMaterialBlockTargets.Fragment);\n this.registerInput(\"vector\", NodeMaterialBlockConnectionPointTypes.AutoDetect);\n this.registerInput(\"worldViewProjection\", NodeMaterialBlockConnectionPointTypes.Matrix);\n this.registerOutput(\"output\", NodeMaterialBlockConnectionPointTypes.Vector2);\n this.registerOutput(\"x\", NodeMaterialBlockConnectionPointTypes.Float);\n this.registerOutput(\"y\", NodeMaterialBlockConnectionPointTypes.Float);\n this.inputs[0].addExcludedConnectionPointFromAllowedTypes(NodeMaterialBlockConnectionPointTypes.Color3 | NodeMaterialBlockConnectionPointTypes.Vector3 | NodeMaterialBlockConnectionPointTypes.Vector4);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"ScreenSpaceBlock\";\n }\n /**\n * Gets the vector input\n */\n get vector() {\n return this._inputs[0];\n }\n /**\n * Gets the worldViewProjection transform input\n */\n get worldViewProjection() {\n return this._inputs[1];\n }\n /**\n * Gets the output component\n */\n get output() {\n return this._outputs[0];\n }\n /**\n * Gets the x output component\n */\n get x() {\n return this._outputs[1];\n }\n /**\n * Gets the y output component\n */\n get y() {\n return this._outputs[2];\n }\n autoConfigure(material, additionalFilteringInfo = () => true) {\n if (!this.worldViewProjection.isConnected) {\n let worldViewProjectionInput = material.getInputBlockByPredicate((b) => b.systemValue === NodeMaterialSystemValues.WorldViewProjection && additionalFilteringInfo(b));\n if (!worldViewProjectionInput) {\n worldViewProjectionInput = new InputBlock(\"worldViewProjection\");\n worldViewProjectionInput.setAsSystemValue(NodeMaterialSystemValues.WorldViewProjection);\n }\n worldViewProjectionInput.output.connectTo(this.worldViewProjection);\n }\n }\n _buildBlock(state) {\n super._buildBlock(state);\n const vector = this.vector;\n const worldViewProjection = this.worldViewProjection;\n if (!vector.connectedPoint) {\n return;\n }\n const worldViewProjectionName = worldViewProjection.associatedVariableName;\n const tempVariableName = state._getFreeVariableName(\"screenSpaceTemp\");\n switch (vector.connectedPoint.type) {\n case NodeMaterialBlockConnectionPointTypes.Vector3:\n state.compilationString += `${state._declareLocalVar(tempVariableName, NodeMaterialBlockConnectionPointTypes.Vector4)} = ${worldViewProjectionName} * vec4${state.fSuffix}(${vector.associatedVariableName}, 1.0);\\n`;\n break;\n case NodeMaterialBlockConnectionPointTypes.Vector4:\n state.compilationString += `${state._declareLocalVar(tempVariableName, NodeMaterialBlockConnectionPointTypes.Vector4)} = ${worldViewProjectionName} * ${vector.associatedVariableName};\\n`;\n break;\n }\n state.compilationString += `${tempVariableName} = vec4${state.fSuffix}(${tempVariableName}.xy / ${tempVariableName}.w, ${tempVariableName}.zw);`;\n state.compilationString += `${tempVariableName} = vec4${state.fSuffix}(${tempVariableName}.xy * 0.5 + vec2${state.fSuffix}(0.5, 0.5), ${tempVariableName}.zw);`;\n if (this.output.hasEndpoints) {\n state.compilationString += state._declareOutput(this.output) + ` = ${tempVariableName}.xy;\\n`;\n }\n if (this.x.hasEndpoints) {\n state.compilationString += state._declareOutput(this.x) + ` = ${tempVariableName}.x;\\n`;\n }\n if (this.y.hasEndpoints) {\n state.compilationString += state._declareOutput(this.y) + ` = ${tempVariableName}.y;\\n`;\n }\n return this;\n }\n}\nRegisterClass(\"BABYLON.ScreenSpaceBlock\", ScreenSpaceBlock);\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,4BAA4B;AAC9D,SAASC,qCAAqC,QAAQ,sDAAsD;AAC5G,SAASC,wBAAwB,QAAQ,yCAAyC;AAClF,SAASC,aAAa,QAAQ,+BAA+B;AAC7D,SAASC,wBAAwB,QAAQ,yCAAyC;AAClF,SAASC,UAAU,QAAQ,wBAAwB;AACnD;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,SAASN,iBAAiB,CAAC;EACpD;AACJ;AACA;AACA;EACIO,WAAWA,CAACC,IAAI,EAAE;IACd,KAAK,CAACA,IAAI,EAAEN,wBAAwB,CAACO,QAAQ,CAAC;IAC9C,IAAI,CAACC,aAAa,CAAC,QAAQ,EAAET,qCAAqC,CAACU,UAAU,CAAC;IAC9E,IAAI,CAACD,aAAa,CAAC,qBAAqB,EAAET,qCAAqC,CAACW,MAAM,CAAC;IACvF,IAAI,CAACC,cAAc,CAAC,QAAQ,EAAEZ,qCAAqC,CAACa,OAAO,CAAC;IAC5E,IAAI,CAACD,cAAc,CAAC,GAAG,EAAEZ,qCAAqC,CAACc,KAAK,CAAC;IACrE,IAAI,CAACF,cAAc,CAAC,GAAG,EA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