1 |
- {"ast":null,"code":"import { __decorate } from \"../../../../tslib.es6.js\";\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes.js\";\nimport { NodeGeometryBlock } from \"../../nodeGeometryBlock.js\";\nimport { GeometryInputBlock } from \"../geometryInputBlock.js\";\nimport { RegisterClass } from \"../../../../Misc/typeStore.js\";\nimport { Matrix } from \"../../../../Maths/math.vector.js\";\nimport { editableInPropertyPage } from \"../../../../Decorators/nodeDecorator.js\";\nimport { CreateGroundVertexData } from \"../../../Builders/groundBuilder.js\";\n/**\n * Defines a block used to generate plane geometry data\n */\nexport class PlaneBlock extends NodeGeometryBlock {\n /**\n * Create a new PlaneBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name);\n this._rotationMatrix = new Matrix();\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 = false;\n this.registerInput(\"size\", NodeGeometryBlockConnectionPointTypes.Float, true, 1);\n this.registerInput(\"width\", NodeGeometryBlockConnectionPointTypes.Float, true, 0);\n this.registerInput(\"height\", NodeGeometryBlockConnectionPointTypes.Float, true, 0);\n this.registerInput(\"subdivisions\", NodeGeometryBlockConnectionPointTypes.Int, true, 1);\n this.registerInput(\"subdivisionsX\", NodeGeometryBlockConnectionPointTypes.Int, true, 0);\n this.registerInput(\"subdivisionsY\", NodeGeometryBlockConnectionPointTypes.Int, true, 0);\n this.registerOutput(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"PlaneBlock\";\n }\n /**\n * Gets the size input component\n */\n get size() {\n return this._inputs[0];\n }\n /**\n * Gets the width input component\n */\n get width() {\n return this._inputs[1];\n }\n /**\n * Gets the height input component\n */\n get height() {\n return this._inputs[2];\n }\n /**\n * Gets the subdivisions input component\n */\n get subdivisions() {\n return this._inputs[3];\n }\n /**\n * Gets the subdivisionsX input component\n */\n get subdivisionsX() {\n return this._inputs[4];\n }\n /**\n * Gets the subdivisionsY input component\n */\n get subdivisionsY() {\n return this._inputs[5];\n }\n /**\n * Gets the geometry output component\n */\n get geometry() {\n return this._outputs[0];\n }\n autoConfigure() {\n if (this.size.isConnected) {\n return;\n }\n if (!this.width.isConnected && !this.height.isConnected) {\n const sizeInput = new GeometryInputBlock(\"Size\");\n sizeInput.value = 1;\n sizeInput.output.connectTo(this.size);\n return;\n }\n if (!this.width.isConnected) {\n const widthInput = new GeometryInputBlock(\"Width\");\n widthInput.value = 1;\n widthInput.output.connectTo(this.width);\n }\n if (!this.height.isConnected) {\n const heightInput = new GeometryInputBlock(\"Height\");\n heightInput.value = 1;\n heightInput.output.connectTo(this.height);\n }\n }\n _buildBlock(state) {\n const options = {};\n const func = state => {\n options.size = this.size.getConnectedValue(state);\n options.width = this.width.getConnectedValue(state);\n options.height = this.height.getConnectedValue(state);\n const subdivisions = this.subdivisions.getConnectedValue(state);\n const subdivisionsX = this.subdivisionsX.getConnectedValue(state);\n const subdivisionsY = this.subdivisionsY.getConnectedValue(state);\n if (subdivisions) {\n options.subdivisions = subdivisions;\n }\n if (subdivisionsX) {\n options.subdivisionsX = subdivisionsX;\n }\n if (subdivisionsY) {\n options.subdivisionsY = subdivisionsY;\n }\n // Append vertex data from the ground builder (to get access to subdivisions)\n const vertexData = CreateGroundVertexData(options);\n Matrix.RotationYawPitchRollToRef(-Math.PI / 2, 0, Math.PI / 2, this._rotationMatrix);\n vertexData.transform(this._rotationMatrix);\n return vertexData;\n };\n if (this.evaluateContext) {\n this.geometry._storedFunction = func;\n } else {\n const value = func(state);\n this.geometry._storedFunction = () => {\n this.geometry._executionCount = 1;\n return value.clone();\n };\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 this.evaluateContext = serializationObject.evaluateContext;\n }\n}\n__decorate([editableInPropertyPage(\"Evaluate context\", 0 /* PropertyTypeForEdition.Boolean */, \"ADVANCED\", {\n embedded: true,\n notifiers: {\n rebuild: true\n }\n})], PlaneBlock.prototype, \"evaluateContext\", void 0);\nRegisterClass(\"BABYLON.PlaneBlock\", PlaneBlock);","map":{"version":3,"names":["__decorate","NodeGeometryBlockConnectionPointTypes","NodeGeometryBlock","GeometryInputBlock","RegisterClass","Matrix","editableInPropertyPage","CreateGroundVertexData","PlaneBlock","constructor","name","_rotationMatrix","evaluateContext","registerInput","Float","Int","registerOutput","Geometry","getClassName","size","_inputs","width","height","subdivisions","subdivisionsX","subdivisionsY","geometry","_outputs","autoConfigure","isConnected","sizeInput","value","output","connectTo","widthInput","heightInput","_buildBlock","state","options","func","getConnectedValue","vertexData","RotationYawPitchRollToRef","Math","PI","transform","_storedFunction","_executionCount","clone","_dumpPropertiesCode","codeString","_codeVariableName","serialize","serializationObject","_deserialize","embedded","notifiers","rebuild","prototype"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Meshes/Node/Blocks/Sources/planeBlock.js"],"sourcesContent":["import { __decorate } from \"../../../../tslib.es6.js\";\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes.js\";\nimport { NodeGeometryBlock } from \"../../nodeGeometryBlock.js\";\nimport { GeometryInputBlock } from \"../geometryInputBlock.js\";\nimport { RegisterClass } from \"../../../../Misc/typeStore.js\";\nimport { Matrix } from \"../../../../Maths/math.vector.js\";\nimport { editableInPropertyPage } from \"../../../../Decorators/nodeDecorator.js\";\nimport { CreateGroundVertexData } from \"../../../Builders/groundBuilder.js\";\n/**\n * Defines a block used to generate plane geometry data\n */\nexport class PlaneBlock extends NodeGeometryBlock {\n /**\n * Create a new PlaneBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name);\n this._rotationMatrix = new Matrix();\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 = false;\n this.registerInput(\"size\", NodeGeometryBlockConnectionPointTypes.Float, true, 1);\n this.registerInput(\"width\", NodeGeometryBlockConnectionPointTypes.Float, true, 0);\n this.registerInput(\"height\", NodeGeometryBlockConnectionPointTypes.Float, true, 0);\n this.registerInput(\"subdivisions\", NodeGeometryBlockConnectionPointTypes.Int, true, 1);\n this.registerInput(\"subdivisionsX\", NodeGeometryBlockConnectionPointTypes.Int, true, 0);\n this.registerInput(\"subdivisionsY\", NodeGeometryBlockConnectionPointTypes.Int, true, 0);\n this.registerOutput(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"PlaneBlock\";\n }\n /**\n * Gets the size input component\n */\n get size() {\n return this._inputs[0];\n }\n /**\n * Gets the width input component\n */\n get width() {\n return this._inputs[1];\n }\n /**\n * Gets the height input component\n */\n get height() {\n return this._inputs[2];\n }\n /**\n * Gets the subdivisions input component\n */\n get subdivisions() {\n return this._inputs[3];\n }\n /**\n * Gets the subdivisionsX input component\n */\n get subdivisionsX() {\n return this._inputs[4];\n }\n /**\n * Gets the subdivisionsY input component\n */\n get subdivisionsY() {\n return this._inputs[5];\n }\n /**\n * Gets the geometry output component\n */\n get geometry() {\n return this._outputs[0];\n }\n autoConfigure() {\n if (this.size.isConnected) {\n return;\n }\n if (!this.width.isConnected && !this.height.isConnected) {\n const sizeInput = new GeometryInputBlock(\"Size\");\n sizeInput.value = 1;\n sizeInput.output.connectTo(this.size);\n return;\n }\n if (!this.width.isConnected) {\n const widthInput = new GeometryInputBlock(\"Width\");\n widthInput.value = 1;\n widthInput.output.connectTo(this.width);\n }\n if (!this.height.isConnected) {\n const heightInput = new GeometryInputBlock(\"Height\");\n heightInput.value = 1;\n heightInput.output.connectTo(this.height);\n }\n }\n _buildBlock(state) {\n const options = {};\n const func = (state) => {\n options.size = this.size.getConnectedValue(state);\n options.width = this.width.getConnectedValue(state);\n options.height = this.height.getConnectedValue(state);\n const subdivisions = this.subdivisions.getConnectedValue(state);\n const subdivisionsX = this.subdivisionsX.getConnectedValue(state);\n const subdivisionsY = this.subdivisionsY.getConnectedValue(state);\n if (subdivisions) {\n options.subdivisions = subdivisions;\n }\n if (subdivisionsX) {\n options.subdivisionsX = subdivisionsX;\n }\n if (subdivisionsY) {\n options.subdivisionsY = subdivisionsY;\n }\n // Append vertex data from the ground builder (to get access to subdivisions)\n const vertexData = CreateGroundVertexData(options);\n Matrix.RotationYawPitchRollToRef(-Math.PI / 2, 0, Math.PI / 2, this._rotationMatrix);\n vertexData.transform(this._rotationMatrix);\n return vertexData;\n };\n if (this.evaluateContext) {\n this.geometry._storedFunction = func;\n }\n else {\n const value = func(state);\n this.geometry._storedFunction = () => {\n this.geometry._executionCount = 1;\n return value.clone();\n };\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 this.evaluateContext = serializationObject.evaluateContext;\n }\n}\n__decorate([\n editableInPropertyPage(\"Evaluate context\", 0 /* PropertyTypeForEdition.Boolean */, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\n], PlaneBlock.prototype, \"evaluateContext\", void 0);\nRegisterClass(\"BABYLON.PlaneBlock\", PlaneBlock);\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,0BAA0B;AACrD,SAASC,qCAAqC,QAAQ,iDAAiD;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