aac6165906d25c2ca6aeb531e406f57276306767fcbce327996633029aa45bb9.json 13 KB

1
  1. {"ast":null,"code":"import { __decorate } from \"../../../tslib.es6.js\";\nimport { NodeMaterialBlock } from \"../nodeMaterialBlock.js\";\nimport { NodeMaterialBlockConnectionPointTypes } from \"../Enums/nodeMaterialBlockConnectionPointTypes.js\";\nimport { NodeMaterialBlockTargets } from \"../Enums/nodeMaterialBlockTargets.js\";\nimport { RegisterClass } from \"../../../Misc/typeStore.js\";\nimport { editableInPropertyPage } from \"../../../Decorators/nodeDecorator.js\";\nimport { NodeMaterialConnectionPointCustomObject } from \"../nodeMaterialConnectionPointCustomObject.js\";\n/**\n * Block used to repeat code\n */\nexport class LoopBlock extends NodeMaterialBlock {\n /**\n * Creates a new LoopBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name, NodeMaterialBlockTargets.Neutral);\n /**\n * Gets or sets number of iterations\n * Will be ignored if the iterations input is connected\n */\n this.iterations = 4;\n this.registerInput(\"input\", NodeMaterialBlockConnectionPointTypes.AutoDetect);\n this.registerInput(\"iterations\", NodeMaterialBlockConnectionPointTypes.Float, true);\n this.registerOutput(\"output\", NodeMaterialBlockConnectionPointTypes.BasedOnInput);\n this.registerOutput(\"index\", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment);\n this.registerOutput(\"loopID\", NodeMaterialBlockConnectionPointTypes.Object, undefined, new NodeMaterialConnectionPointCustomObject(\"loopID\", this, 1 /* NodeMaterialConnectionPointDirection.Output */, LoopBlock, \"LoopBlock\"));\n this._outputs[0]._typeConnectionSource = this._inputs[0];\n this._outputs[0]._forPostBuild = true;\n this._outputs[2]._redirectedSource = this._inputs[0];\n this._outputs[1]._preventBubbleUp = true;\n this._outputs[2]._preventBubbleUp = true;\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"LoopBlock\";\n }\n /**\n * Gets the main input component\n */\n get input() {\n return this._inputs[0];\n }\n /**\n * Gets the iterations input component\n */\n get iterationsInput() {\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 index component which will be incremented at each iteration\n */\n get index() {\n return this._outputs[1];\n }\n /**\n * Gets the loop ID component\n */\n get loopID() {\n return this._outputs[2];\n }\n _buildBlock(state) {\n super._buildBlock(state);\n const output = this._outputs[0];\n const index = this._outputs[1];\n const indexName = state._getFreeVariableName(\"index\");\n const decl = state.shaderLanguage === 1 /* ShaderLanguage.WGSL */ ? \"var\" : \"int\";\n const castFloat = state.shaderLanguage === 1 /* ShaderLanguage.WGSL */ ? \"f32\" : \"float\";\n const castInt = state.shaderLanguage === 1 /* ShaderLanguage.WGSL */ ? \"i32\" : \"int\";\n // Declare storage variable and store initial value\n state.compilationString += state._declareOutput(output) + ` = ${this.input.associatedVariableName};\\n`;\n // Iterations\n const iterations = this.iterationsInput.isConnected ? `${castInt}(${this.iterationsInput.associatedVariableName})` : this.iterations;\n // Loop\n state.compilationString += `for (${decl} ${indexName} = 0; ${indexName} < ${iterations}; ${indexName}++){\\n`;\n state.compilationString += `${state._declareOutput(index)} = ${castFloat}(${indexName});\\n`;\n return this;\n }\n _postBuildBlock(state) {\n super._postBuildBlock(state);\n state.compilationString += `}\\n`;\n return this;\n }\n _dumpPropertiesCode() {\n return super._dumpPropertiesCode() + `${this._codeVariableName}.iterations = ${this.iterations};\\n`;\n }\n serialize() {\n const serializationObject = super.serialize();\n serializationObject.iterations = this.iterations;\n return serializationObject;\n }\n _deserialize(serializationObject, scene, rootUrl) {\n super._deserialize(serializationObject, scene, rootUrl);\n this.iterations = serializationObject.iterations;\n }\n}\n__decorate([editableInPropertyPage(\"Iterations\", 2 /* PropertyTypeForEdition.Int */, undefined, {\n embedded: true\n})], LoopBlock.prototype, \"iterations\", void 0);\nRegisterClass(\"BABYLON.LoopBlock\", LoopBlock);","map":{"version":3,"names":["__decorate","NodeMaterialBlock","NodeMaterialBlockConnectionPointTypes","NodeMaterialBlockTargets","RegisterClass","editableInPropertyPage","NodeMaterialConnectionPointCustomObject","LoopBlock","constructor","name","Neutral","iterations","registerInput","AutoDetect","Float","registerOutput","BasedOnInput","Fragment","Object","undefined","_outputs","_typeConnectionSource","_inputs","_forPostBuild","_redirectedSource","_preventBubbleUp","getClassName","input","iterationsInput","output","index","loopID","_buildBlock","state","indexName","_getFreeVariableName","decl","shaderLanguage","castFloat","castInt","compilationString","_declareOutput","associatedVariableName","isConnected","_postBuildBlock","_dumpPropertiesCode","_codeVariableName","serialize","serializationObject","_deserialize","scene","rootUrl","embedded","prototype"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Materials/Node/Blocks/loopBlock.js"],"sourcesContent":["import { __decorate } from \"../../../tslib.es6.js\";\nimport { NodeMaterialBlock } from \"../nodeMaterialBlock.js\";\nimport { NodeMaterialBlockConnectionPointTypes } from \"../Enums/nodeMaterialBlockConnectionPointTypes.js\";\nimport { NodeMaterialBlockTargets } from \"../Enums/nodeMaterialBlockTargets.js\";\nimport { RegisterClass } from \"../../../Misc/typeStore.js\";\nimport { editableInPropertyPage } from \"../../../Decorators/nodeDecorator.js\";\nimport { NodeMaterialConnectionPointCustomObject } from \"../nodeMaterialConnectionPointCustomObject.js\";\n/**\n * Block used to repeat code\n */\nexport class LoopBlock extends NodeMaterialBlock {\n /**\n * Creates a new LoopBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name, NodeMaterialBlockTargets.Neutral);\n /**\n * Gets or sets number of iterations\n * Will be ignored if the iterations input is connected\n */\n this.iterations = 4;\n this.registerInput(\"input\", NodeMaterialBlockConnectionPointTypes.AutoDetect);\n this.registerInput(\"iterations\", NodeMaterialBlockConnectionPointTypes.Float, true);\n this.registerOutput(\"output\", NodeMaterialBlockConnectionPointTypes.BasedOnInput);\n this.registerOutput(\"index\", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment);\n this.registerOutput(\"loopID\", NodeMaterialBlockConnectionPointTypes.Object, undefined, new NodeMaterialConnectionPointCustomObject(\"loopID\", this, 1 /* NodeMaterialConnectionPointDirection.Output */, LoopBlock, \"LoopBlock\"));\n this._outputs[0]._typeConnectionSource = this._inputs[0];\n this._outputs[0]._forPostBuild = true;\n this._outputs[2]._redirectedSource = this._inputs[0];\n this._outputs[1]._preventBubbleUp = true;\n this._outputs[2]._preventBubbleUp = true;\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"LoopBlock\";\n }\n /**\n * Gets the main input component\n */\n get input() {\n return this._inputs[0];\n }\n /**\n * Gets the iterations input component\n */\n get iterationsInput() {\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 index component which will be incremented at each iteration\n */\n get index() {\n return this._outputs[1];\n }\n /**\n * Gets the loop ID component\n */\n get loopID() {\n return this._outputs[2];\n }\n _buildBlock(state) {\n super._buildBlock(state);\n const output = this._outputs[0];\n const index = this._outputs[1];\n const indexName = state._getFreeVariableName(\"index\");\n const decl = state.shaderLanguage === 1 /* ShaderLanguage.WGSL */ ? \"var\" : \"int\";\n const castFloat = state.shaderLanguage === 1 /* ShaderLanguage.WGSL */ ? \"f32\" : \"float\";\n const castInt = state.shaderLanguage === 1 /* ShaderLanguage.WGSL */ ? \"i32\" : \"int\";\n // Declare storage variable and store initial value\n state.compilationString += state._declareOutput(output) + ` = ${this.input.associatedVariableName};\\n`;\n // Iterations\n const iterations = this.iterationsInput.isConnected ? `${castInt}(${this.iterationsInput.associatedVariableName})` : this.iterations;\n // Loop\n state.compilationString += `for (${decl} ${indexName} = 0; ${indexName} < ${iterations}; ${indexName}++){\\n`;\n state.compilationString += `${state._declareOutput(index)} = ${castFloat}(${indexName});\\n`;\n return this;\n }\n _postBuildBlock(state) {\n super._postBuildBlock(state);\n state.compilationString += `}\\n`;\n return this;\n }\n _dumpPropertiesCode() {\n return super._dumpPropertiesCode() + `${this._codeVariableName}.iterations = ${this.iterations};\\n`;\n }\n serialize() {\n const serializationObject = super.serialize();\n serializationObject.iterations = this.iterations;\n return serializationObject;\n }\n _deserialize(serializationObject, scene, rootUrl) {\n super._deserialize(serializationObject, scene, rootUrl);\n this.iterations = serializationObject.iterations;\n }\n}\n__decorate([\n editableInPropertyPage(\"Iterations\", 2 /* PropertyTypeForEdition.Int */, undefined, { embedded: true })\n], LoopBlock.prototype, \"iterations\", void 0);\nRegisterClass(\"BABYLON.LoopBlock\", LoopBlock);\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,uBAAuB;AAClD,SAASC,iBAAiB,QAAQ,yBAAyB;AAC3D,SAASC,qCAAqC,QAAQ,mDAAmD;AACzG,SAASC,wBAAwB,QAAQ,sCAAsC;AAC/E,SAASC,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,sBAAsB,QAAQ,sCAAsC;AAC7E,SAASC,uCAAuC,QAAQ,+CAA+C;AACvG;AACA;AACA;AACA,OAAO,MAAMC,SAAS,SAASN,iBAAiB,CAAC;EAC7C;AACJ;AACA;AACA;EACIO,WAAWA,CAACC,IAAI,EAAE;IACd,KAAK,CAACA,IAAI,EAAEN,wBAAwB,CAACO,OAAO,CAAC;IAC7C;AACR;AACA;AACA;IACQ,IAAI,CAACC,UAAU,GAAG,CAAC;IACnB,IAAI,CAACC,aAAa,CAAC,OAAO,EAAEV,qCAAqC,CAACW,UAAU,CAAC;IAC7E,IAAI,CAACD,aAAa,CAAC,YAAY,EAAEV,qCAAqC,CAACY,KAAK,EAAE,IAAI,CAAC;IACnF,IAAI,CAACC,cAAc,CAAC,QAAQ,EAAEb,qCAAqC,CAACc,YAAY,CAAC;IACjF,IAAI,CAACD,cAAc,CAAC,OAAO,EAAEb,qCAAqC,CAACY,KAAK,EAAEX,wBAAwB,CAACc,QAAQ,CAAC;IAC5G,IAAI,CAACF,cAAc,CAAC,QAAQ,EAAEb,qCAAqC,CAACgB,MAAM,EAAEC,SAAS,EAAE,IAAIb,uCAAuC,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,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