cdc9be8aafbae2a6afa8ae64081fb50504a9fbe7321770e82c2ae97bfdbe84bf.json 7.3 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 get the view direction\n */\nexport class ViewDirectionBlock extends NodeMaterialBlock {\n /**\n * Creates a new ViewDirectionBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name, NodeMaterialBlockTargets.Neutral);\n this.registerInput(\"worldPosition\", NodeMaterialBlockConnectionPointTypes.Vector4);\n this.registerInput(\"cameraPosition\", NodeMaterialBlockConnectionPointTypes.Vector3);\n this.registerOutput(\"output\", NodeMaterialBlockConnectionPointTypes.Vector3);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"ViewDirectionBlock\";\n }\n /**\n * Gets the world position component\n */\n get worldPosition() {\n return this._inputs[0];\n }\n /**\n * Gets the camera position component\n */\n get cameraPosition() {\n return this._inputs[1];\n }\n /**\n * Gets the output component\n */\n get output() {\n return this._outputs[0];\n }\n autoConfigure(material, additionalFilteringInfo = () => true) {\n if (!this.cameraPosition.isConnected) {\n let cameraPositionInput = material.getInputBlockByPredicate(b => b.systemValue === NodeMaterialSystemValues.CameraPosition && additionalFilteringInfo(b));\n if (!cameraPositionInput) {\n cameraPositionInput = new InputBlock(\"cameraPosition\");\n cameraPositionInput.setAsSystemValue(NodeMaterialSystemValues.CameraPosition);\n }\n cameraPositionInput.output.connectTo(this.cameraPosition);\n }\n }\n _buildBlock(state) {\n super._buildBlock(state);\n const output = this._outputs[0];\n state.compilationString += state._declareOutput(output) + ` = normalize(${this.cameraPosition.associatedVariableName} - ${this.worldPosition.associatedVariableName}.xyz);\\n`;\n return this;\n }\n}\nRegisterClass(\"BABYLON.ViewDirectionBlock\", ViewDirectionBlock);","map":{"version":3,"names":["NodeMaterialBlock","NodeMaterialBlockConnectionPointTypes","NodeMaterialBlockTargets","RegisterClass","NodeMaterialSystemValues","InputBlock","ViewDirectionBlock","constructor","name","Neutral","registerInput","Vector4","Vector3","registerOutput","getClassName","worldPosition","_inputs","cameraPosition","output","_outputs","autoConfigure","material","additionalFilteringInfo","isConnected","cameraPositionInput","getInputBlockByPredicate","b","systemValue","CameraPosition","setAsSystemValue","connectTo","_buildBlock","state","compilationString","_declareOutput","associatedVariableName"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Materials/Node/Blocks/viewDirectionBlock.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 get the view direction\n */\nexport class ViewDirectionBlock extends NodeMaterialBlock {\n /**\n * Creates a new ViewDirectionBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name, NodeMaterialBlockTargets.Neutral);\n this.registerInput(\"worldPosition\", NodeMaterialBlockConnectionPointTypes.Vector4);\n this.registerInput(\"cameraPosition\", NodeMaterialBlockConnectionPointTypes.Vector3);\n this.registerOutput(\"output\", NodeMaterialBlockConnectionPointTypes.Vector3);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"ViewDirectionBlock\";\n }\n /**\n * Gets the world position component\n */\n get worldPosition() {\n return this._inputs[0];\n }\n /**\n * Gets the camera position component\n */\n get cameraPosition() {\n return this._inputs[1];\n }\n /**\n * Gets the output component\n */\n get output() {\n return this._outputs[0];\n }\n autoConfigure(material, additionalFilteringInfo = () => true) {\n if (!this.cameraPosition.isConnected) {\n let cameraPositionInput = material.getInputBlockByPredicate((b) => b.systemValue === NodeMaterialSystemValues.CameraPosition && additionalFilteringInfo(b));\n if (!cameraPositionInput) {\n cameraPositionInput = new InputBlock(\"cameraPosition\");\n cameraPositionInput.setAsSystemValue(NodeMaterialSystemValues.CameraPosition);\n }\n cameraPositionInput.output.connectTo(this.cameraPosition);\n }\n }\n _buildBlock(state) {\n super._buildBlock(state);\n const output = this._outputs[0];\n state.compilationString +=\n state._declareOutput(output) + ` = normalize(${this.cameraPosition.associatedVariableName} - ${this.worldPosition.associatedVariableName}.xyz);\\n`;\n return this;\n }\n}\nRegisterClass(\"BABYLON.ViewDirectionBlock\", ViewDirectionBlock);\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,yBAAyB;AAC3D,SAASC,qCAAqC,QAAQ,mDAAmD;AACzG,SAASC,wBAAwB,QAAQ,sCAAsC;AAC/E,SAASC,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,wBAAwB,QAAQ,sCAAsC;AAC/E,SAASC,UAAU,QAAQ,uBAAuB;AAClD;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,SAASN,iBAAiB,CAAC;EACtD;AACJ;AACA;AACA;EACIO,WAAWA,CAACC,IAAI,EAAE;IACd,KAAK,CAACA,IAAI,EAAEN,wBAAwB,CAACO,OAAO,CAAC;IAC7C,IAAI,CAACC,aAAa,CAAC,eAAe,EAAET,qCAAqC,CAACU,OAAO,CAAC;IAClF,IAAI,CAACD,aAAa,CAAC,gBAAgB,EAAET,qCAAqC,CAACW,OAAO,CAAC;IACnF,IAAI,CAACC,cAAc,CAAC,QAAQ,EAAEZ,qCAAqC,CAACW,OAAO,CAAC;EAChF;EACA;AACJ;AACA;AACA;EACIE,YAAYA,CAAA,EAAG;IACX,OAAO,oBAAo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