1 |
- {"ast":null,"code":"import { __decorate } from \"../../../../tslib.es6.js\";\nimport { NodeGeometryBlock } from \"../../nodeGeometryBlock.js\";\nimport { RegisterClass } from \"../../../../Misc/typeStore.js\";\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes.js\";\nimport { editableInPropertyPage } from \"../../../../Decorators/nodeDecorator.js\";\n/**\n * Block used to set colors for a geometry\n */\nexport class SetColorsBlock extends NodeGeometryBlock {\n /**\n * Create a new SetColorsBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name);\n /**\n * Gets or sets a boolean indicating that this block can evaluate context\n * Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change\n */\n this.evaluateContext = true;\n this.registerInput(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\n this.registerInput(\"colors\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Int);\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Vector2);\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Texture);\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Texture);\n }\n /**\n * Gets the current index in the current flow\n * @returns the current index\n */\n getExecutionIndex() {\n return this._currentIndex;\n }\n /**\n * Gets the current loop index in the current flow\n * @returns the current loop index\n */\n getExecutionLoopIndex() {\n return this._currentIndex;\n }\n /**\n * Gets the current face index in the current flow\n * @returns the current face index\n */\n getExecutionFaceIndex() {\n return 0;\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"SetColorsBlock\";\n }\n /**\n * Gets the geometry input component\n */\n get geometry() {\n return this._inputs[0];\n }\n /**\n * Gets the colors input component\n */\n get colors() {\n return this._inputs[1];\n }\n /**\n * Gets the geometry output component\n */\n get output() {\n return this._outputs[0];\n }\n _buildBlock(state) {\n const func = state => {\n state.pushExecutionContext(this);\n this._vertexData = this.geometry.getConnectedValue(state);\n if (this._vertexData) {\n this._vertexData = this._vertexData.clone(); // Preserve source data\n }\n state.pushGeometryContext(this._vertexData);\n if (!this._vertexData || !this._vertexData.positions) {\n state.restoreGeometryContext();\n state.restoreExecutionContext();\n this.output._storedValue = null;\n return;\n }\n if (!this.colors.isConnected) {\n state.restoreGeometryContext();\n state.restoreExecutionContext();\n this.output._storedValue = this._vertexData;\n return;\n }\n if (!this._vertexData.colors) {\n this._vertexData.colors = [];\n }\n // Processing\n const vertexCount = this._vertexData.positions.length / 3;\n for (this._currentIndex = 0; this._currentIndex < vertexCount; this._currentIndex++) {\n var _this$colors$connecte;\n if (((_this$colors$connecte = this.colors.connectedPoint) === null || _this$colors$connecte === void 0 ? void 0 : _this$colors$connecte.type) === NodeGeometryBlockConnectionPointTypes.Vector3) {\n const tempVector3 = this.colors.getConnectedValue(state);\n if (tempVector3) {\n tempVector3.toArray(this._vertexData.colors, this._currentIndex * 4);\n this._vertexData.colors[this._currentIndex * 4 + 3] = 1; // Alpha\n this._vertexData.hasVertexAlpha = false;\n }\n } else {\n const tempVector4 = this.colors.getConnectedValue(state);\n if (tempVector4) {\n tempVector4.toArray(this._vertexData.colors, this._currentIndex * 4);\n this._vertexData.hasVertexAlpha = true;\n }\n }\n }\n // Storage\n state.restoreGeometryContext();\n state.restoreExecutionContext();\n return this._vertexData;\n };\n if (this.evaluateContext) {\n this.output._storedFunction = func;\n } else {\n this.output._storedFunction = null;\n this.output._storedValue = func(state);\n }\n }\n _dumpPropertiesCode() {\n const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? \"true\" : \"false\"};\\n`;\n return codeString;\n }\n /**\n * Serializes this block in a JSON representation\n * @returns the serialized block object\n */\n serialize() {\n const serializationObject = super.serialize();\n serializationObject.evaluateContext = this.evaluateContext;\n return serializationObject;\n }\n _deserialize(serializationObject) {\n super._deserialize(serializationObject);\n if (serializationObject.evaluateContext !== undefined) {\n this.evaluateContext = serializationObject.evaluateContext;\n }\n }\n}\n__decorate([editableInPropertyPage(\"Evaluate context\", 0 /* PropertyTypeForEdition.Boolean */, \"ADVANCED\", {\n embedded: true,\n notifiers: {\n rebuild: true\n }\n})], SetColorsBlock.prototype, \"evaluateContext\", void 0);\nRegisterClass(\"BABYLON.SetColorsBlock\", SetColorsBlock);","map":{"version":3,"names":["__decorate","NodeGeometryBlock","RegisterClass","NodeGeometryBlockConnectionPointTypes","editableInPropertyPage","SetColorsBlock","constructor","name","evaluateContext","registerInput","Geometry","AutoDetect","registerOutput","_inputs","excludedConnectionPointTypes","push","Int","Float","Vector2","Texture","getExecutionIndex","_currentIndex","getExecutionLoopIndex","getExecutionFaceIndex","getClassName","geometry","colors","output","_outputs","_buildBlock","state","func","pushExecutionContext","_vertexData","getConnectedValue","clone","pushGeometryContext","positions","restoreGeometryContext","restoreExecutionContext","_storedValue","isConnected","vertexCount","length","_this$colors$connecte","connectedPoint","type","Vector3","tempVector3","toArray","hasVertexAlpha","tempVector4","_storedFunction","_dumpPropertiesCode","codeString","_codeVariableName","serialize","serializationObject","_deserialize","undefined","embedded","notifiers","rebuild","prototype"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Meshes/Node/Blocks/Set/setColorsBlock.js"],"sourcesContent":["import { __decorate } from \"../../../../tslib.es6.js\";\nimport { NodeGeometryBlock } from \"../../nodeGeometryBlock.js\";\nimport { RegisterClass } from \"../../../../Misc/typeStore.js\";\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes.js\";\nimport { editableInPropertyPage } from \"../../../../Decorators/nodeDecorator.js\";\n/**\n * Block used to set colors for a geometry\n */\nexport class SetColorsBlock extends NodeGeometryBlock {\n /**\n * Create a new SetColorsBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name);\n /**\n * Gets or sets a boolean indicating that this block can evaluate context\n * Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change\n */\n this.evaluateContext = true;\n this.registerInput(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\n this.registerInput(\"colors\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Int);\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Vector2);\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Texture);\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Texture);\n }\n /**\n * Gets the current index in the current flow\n * @returns the current index\n */\n getExecutionIndex() {\n return this._currentIndex;\n }\n /**\n * Gets the current loop index in the current flow\n * @returns the current loop index\n */\n getExecutionLoopIndex() {\n return this._currentIndex;\n }\n /**\n * Gets the current face index in the current flow\n * @returns the current face index\n */\n getExecutionFaceIndex() {\n return 0;\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"SetColorsBlock\";\n }\n /**\n * Gets the geometry input component\n */\n get geometry() {\n return this._inputs[0];\n }\n /**\n * Gets the colors input component\n */\n get colors() {\n return this._inputs[1];\n }\n /**\n * Gets the geometry output component\n */\n get output() {\n return this._outputs[0];\n }\n _buildBlock(state) {\n const func = (state) => {\n state.pushExecutionContext(this);\n this._vertexData = this.geometry.getConnectedValue(state);\n if (this._vertexData) {\n this._vertexData = this._vertexData.clone(); // Preserve source data\n }\n state.pushGeometryContext(this._vertexData);\n if (!this._vertexData || !this._vertexData.positions) {\n state.restoreGeometryContext();\n state.restoreExecutionContext();\n this.output._storedValue = null;\n return;\n }\n if (!this.colors.isConnected) {\n state.restoreGeometryContext();\n state.restoreExecutionContext();\n this.output._storedValue = this._vertexData;\n return;\n }\n if (!this._vertexData.colors) {\n this._vertexData.colors = [];\n }\n // Processing\n const vertexCount = this._vertexData.positions.length / 3;\n for (this._currentIndex = 0; this._currentIndex < vertexCount; this._currentIndex++) {\n if (this.colors.connectedPoint?.type === NodeGeometryBlockConnectionPointTypes.Vector3) {\n const tempVector3 = this.colors.getConnectedValue(state);\n if (tempVector3) {\n tempVector3.toArray(this._vertexData.colors, this._currentIndex * 4);\n this._vertexData.colors[this._currentIndex * 4 + 3] = 1; // Alpha\n this._vertexData.hasVertexAlpha = false;\n }\n }\n else {\n const tempVector4 = this.colors.getConnectedValue(state);\n if (tempVector4) {\n tempVector4.toArray(this._vertexData.colors, this._currentIndex * 4);\n this._vertexData.hasVertexAlpha = true;\n }\n }\n }\n // Storage\n state.restoreGeometryContext();\n state.restoreExecutionContext();\n return this._vertexData;\n };\n if (this.evaluateContext) {\n this.output._storedFunction = func;\n }\n else {\n this.output._storedFunction = null;\n this.output._storedValue = func(state);\n }\n }\n _dumpPropertiesCode() {\n const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? \"true\" : \"false\"};\\n`;\n return codeString;\n }\n /**\n * Serializes this block in a JSON representation\n * @returns the serialized block object\n */\n serialize() {\n const serializationObject = super.serialize();\n serializationObject.evaluateContext = this.evaluateContext;\n return serializationObject;\n }\n _deserialize(serializationObject) {\n super._deserialize(serializationObject);\n if (serializationObject.evaluateContext !== undefined) {\n this.evaluateContext = serializationObject.evaluateContext;\n }\n }\n}\n__decorate([\n editableInPropertyPage(\"Evaluate context\", 0 /* PropertyTypeForEdition.Boolean */, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\n], SetColorsBlock.prototype, \"evaluateContext\", void 0);\nRegisterClass(\"BABYLON.SetColorsBlock\", SetColorsBlock);\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,0BA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