1b4a745b59cbcfe0e76d7e9432da42217a98607289df3f049bd219c51f2c2634.json 17 KB

1
  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 randomly pick a geometry from a collection\n */\nexport class GeometryCollectionBlock extends NodeGeometryBlock {\n /**\n * Create a new GeometryCollectionBlock\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(\"geometry0\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\n this.registerInput(\"geometry1\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\n this.registerInput(\"geometry2\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\n this.registerInput(\"geometry3\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\n this.registerInput(\"geometry4\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\n this.registerInput(\"geometry5\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\n this.registerInput(\"geometry6\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\n this.registerInput(\"geometry7\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\n this.registerInput(\"geometry8\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\n this.registerInput(\"geometry9\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\n this._outputs[0]._typeConnectionSource = this._inputs[0];\n this._linkConnectionTypes(0, 1);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"GeometryCollectionBlock\";\n }\n /**\n * Gets the geometry0 input component\n */\n get geometry0() {\n return this._inputs[0];\n }\n /**\n * Gets the geometry1 input component\n */\n get geometry1() {\n return this._inputs[1];\n }\n /**\n * Gets the geometry2 input component\n */\n get geometry2() {\n return this._inputs[2];\n }\n /**\n * Gets the geometry3 input component\n */\n get geometry3() {\n return this._inputs[3];\n }\n /**\n * Gets the geometry4 input component\n */\n get geometry4() {\n return this._inputs[4];\n }\n /**\n * Gets the geometry5 input component\n */\n get geometry5() {\n return this._inputs[5];\n }\n /**\n * Gets the geometry6 input component\n */\n get geometry6() {\n return this._inputs[6];\n }\n /**\n * Gets the geometry7 input component\n */\n get geometry7() {\n return this._inputs[7];\n }\n /**\n * Gets the geometry8 input component\n */\n get geometry8() {\n return this._inputs[8];\n }\n /**\n * Gets the geometry9 input component\n */\n get geometry9() {\n return this._inputs[9];\n }\n /**\n * Gets the geometry output component\n */\n get output() {\n return this._outputs[0];\n }\n _storeGeometry(input, state, index, availables) {\n if (input.isConnected) {\n const vertexData = input.getConnectedValue(state);\n if (!vertexData) {\n return;\n }\n vertexData.metadata = vertexData.metadata || {};\n vertexData.metadata.collectionId = index;\n availables.push(vertexData);\n }\n }\n _buildBlock(state) {\n const func = state => {\n const availables = [];\n this._storeGeometry(this.geometry0, state, 0, availables);\n this._storeGeometry(this.geometry1, state, 1, availables);\n this._storeGeometry(this.geometry2, state, 2, availables);\n this._storeGeometry(this.geometry3, state, 3, availables);\n this._storeGeometry(this.geometry4, state, 4, availables);\n this._storeGeometry(this.geometry5, state, 5, availables);\n this._storeGeometry(this.geometry6, state, 6, availables);\n this._storeGeometry(this.geometry7, state, 7, availables);\n this._storeGeometry(this.geometry8, state, 8, availables);\n this._storeGeometry(this.geometry9, state, 9, availables);\n if (!availables.length) {\n return null;\n }\n return availables[Math.round(Math.random() * (availables.length - 1))];\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 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})], GeometryCollectionBlock.prototype, \"evaluateContext\", void 0);\nRegisterClass(\"BABYLON.GeometryCollectionBlock\", GeometryCollectionBlock);","map":{"version":3,"names":["__decorate","NodeGeometryBlock","RegisterClass","NodeGeometryBlockConnectionPointTypes","editableInPropertyPage","GeometryCollectionBlock","constructor","name","evaluateContext","registerInput","Geometry","registerOutput","_outputs","_typeConnectionSource","_inputs","_linkConnectionTypes","getClassName","geometry0","geometry1","geometry2","geometry3","geometry4","geometry5","geometry6","geometry7","geometry8","geometry9","output","_storeGeometry","input","state","index","availables","isConnected","vertexData","getConnectedValue","metadata","collectionId","push","_buildBlock","func","length","Math","round","random","_storedFunction","_storedValue","_dumpPropertiesCode","codeString","_codeVariableName","serialize","serializationObject","_deserialize","embedded","notifiers","rebuild","prototype"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Meshes/Node/Blocks/geometryCollectionBlock.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 randomly pick a geometry from a collection\n */\nexport class GeometryCollectionBlock extends NodeGeometryBlock {\n /**\n * Create a new GeometryCollectionBlock\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(\"geometry0\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\n this.registerInput(\"geometry1\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\n this.registerInput(\"geometry2\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\n this.registerInput(\"geometry3\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\n this.registerInput(\"geometry4\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\n this.registerInput(\"geometry5\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\n this.registerInput(\"geometry6\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\n this.registerInput(\"geometry7\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\n this.registerInput(\"geometry8\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\n this.registerInput(\"geometry9\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\n this._outputs[0]._typeConnectionSource = this._inputs[0];\n this._linkConnectionTypes(0, 1);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"GeometryCollectionBlock\";\n }\n /**\n * Gets the geometry0 input component\n */\n get geometry0() {\n return this._inputs[0];\n }\n /**\n * Gets the geometry1 input component\n */\n get geometry1() {\n return this._inputs[1];\n }\n /**\n * Gets the geometry2 input component\n */\n get geometry2() {\n return this._inputs[2];\n }\n /**\n * Gets the geometry3 input component\n */\n get geometry3() {\n return this._inputs[3];\n }\n /**\n * Gets the geometry4 input component\n */\n get geometry4() {\n return this._inputs[4];\n }\n /**\n * Gets the geometry5 input component\n */\n get geometry5() {\n return this._inputs[5];\n }\n /**\n * Gets the geometry6 input component\n */\n get geometry6() {\n return this._inputs[6];\n }\n /**\n * Gets the geometry7 input component\n */\n get geometry7() {\n return this._inputs[7];\n }\n /**\n * Gets the geometry8 input component\n */\n get geometry8() {\n return this._inputs[8];\n }\n /**\n * Gets the geometry9 input component\n */\n get geometry9() {\n return this._inputs[9];\n }\n /**\n * Gets the geometry output component\n */\n get output() {\n return this._outputs[0];\n }\n _storeGeometry(input, state, index, availables) {\n if (input.isConnected) {\n const vertexData = input.getConnectedValue(state);\n if (!vertexData) {\n return;\n }\n vertexData.metadata = vertexData.metadata || {};\n vertexData.metadata.collectionId = index;\n availables.push(vertexData);\n }\n }\n _buildBlock(state) {\n const func = (state) => {\n const availables = [];\n this._storeGeometry(this.geometry0, state, 0, availables);\n this._storeGeometry(this.geometry1, state, 1, availables);\n this._storeGeometry(this.geometry2, state, 2, availables);\n this._storeGeometry(this.geometry3, state, 3, availables);\n this._storeGeometry(this.geometry4, state, 4, availables);\n this._storeGeometry(this.geometry5, state, 5, availables);\n this._storeGeometry(this.geometry6, state, 6, availables);\n this._storeGeometry(this.geometry7, state, 7, availables);\n this._storeGeometry(this.geometry8, state, 8, availables);\n this._storeGeometry(this.geometry9, state, 9, availables);\n if (!availables.length) {\n return null;\n }\n return availables[Math.round(Math.random() * (availables.length - 1))];\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 this.evaluateContext = serializationObject.evaluateContext;\n }\n}\n__decorate([\n editableInPropertyPage(\"Evaluate context\", 0 /* PropertyTypeForEdition.Boolean */, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\n], GeometryCollectionBlock.prototype, \"evaluateContext\", void 0);\nRegisterClass(\"BABYLON.GeometryCollectionBlock\", GeometryCollectionBlock);\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,uBAAuB;AAClD,SAASC,iBAAiB,QAAQ,yBAAyB;AAC3D,SAASC,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,qCAAqC,QAAQ,8CAA8C;AACpG,SAASC,sBAAsB,QAAQ,sCAAsC;AAC7E;AACA;AACA;AACA,OAAO,MAAMC,uBAAuB,SAASJ,iBAAiB,CAAC;EAC3D;AACJ;AACA;AACA;EACIK,WAAWA,CAACC,IAAI,EAAE;IACd,KAAK,CAACA,IAAI,CAAC;IACX;AACR;AACA;AACA;IACQ,IAAI,CAACC,eAAe,GAAG,IAAI;IAC3B,IAAI,CAACC,aAAa,CAAC,WAAW,EAAEN,qCAAqC,CAACO,QAAQ,EAAE,IAAI,CAAC;IACrF,IAAI,CAACD,aAAa,CAAC,WAAW,EAAEN,qCAAqC,CAACO,QAAQ,EAAE,IAAI,CAAC;IACrF,IAAI,CAACD,aAAa,CAAC,WAAW,EAAEN,qCAAqC,CAACO,QAAQ,EAAE,IAAI,CAAC;IACrF,IAAI,CAACD,aAAa,CAAC,WAAW,EAAEN,qCAAqC,CAACO,QAAQ,EAAE,IAAI,CAAC;IACrF,IAAI,CAACD,aAAa,CAAC,WAAW,EAAEN,qCAAqC,CAACO,QAAQ,EAAE,IAAI,CAAC;IACrF,IAAI,CAACD,aAAa,CAAC,WAAW,EAAEN,qCAAqC,CAACO,QAAQ,EAAE,IAAI,CAAC;IACrF,IAAI,CAACD,aAAa,CAAC,WAAW,EAAEN,qCAAqC,CAACO,QAAQ,EAAE,IAAI,CAAC;IACrF,IAAI,CAACD,aAAa,CAAC,WAAW,EAAEN,qCAAqC,CAACO,QAAQ,EAAE,IAAI,CAAC;IACrF,IAAI,CAACD,aAAa,CAAC,WAAW,EAAEN,qCAAqC,CAACO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