78ce5982c254b8bae5906a1f1743d6f3861ee7e211f6b2b9a982c6feb0696dea.json 18 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 set texture coordinates for a geometry\n */\nexport class SetUVsBlock extends NodeGeometryBlock {\n /**\n * Create a new SetUVsBlock\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 /**\n * Gets or sets a value indicating which UV to set\n */\n this.textureCoordinateIndex = 0;\n this.registerInput(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\n this.registerInput(\"uvs\", NodeGeometryBlockConnectionPointTypes.Vector2);\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\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 \"SetUVsBlock\";\n }\n /**\n * Gets the geometry input component\n */\n get geometry() {\n return this._inputs[0];\n }\n /**\n * Gets the uvs input component\n */\n get uvs() {\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.uvs.isConnected) {\n state.restoreGeometryContext();\n state.restoreExecutionContext();\n this.output._storedValue = this._vertexData;\n return;\n }\n const uvs = [];\n // Processing\n const vertexCount = this._vertexData.positions.length / 3;\n for (this._currentIndex = 0; this._currentIndex < vertexCount; this._currentIndex++) {\n const tempVector2 = this.uvs.getConnectedValue(state);\n if (tempVector2) {\n tempVector2.toArray(uvs, this._currentIndex * 2);\n }\n }\n switch (this.textureCoordinateIndex) {\n case 0:\n this._vertexData.uvs = uvs;\n break;\n case 1:\n this._vertexData.uvs2 = uvs;\n break;\n case 2:\n this._vertexData.uvs3 = uvs;\n break;\n case 3:\n this._vertexData.uvs4 = uvs;\n break;\n case 4:\n this._vertexData.uvs5 = uvs;\n break;\n case 5:\n this._vertexData.uvs6 = uvs;\n break;\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 let codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.textureCoordinateIndex};\\n`;\n codeString += `${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 serializationObject.textureCoordinateIndex = this.textureCoordinateIndex;\n return serializationObject;\n }\n _deserialize(serializationObject) {\n super._deserialize(serializationObject);\n this.textureCoordinateIndex = serializationObject.textureCoordinateIndex;\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})], SetUVsBlock.prototype, \"evaluateContext\", void 0);\n__decorate([editableInPropertyPage(\"Texture coordinates index\", 4 /* PropertyTypeForEdition.List */, \"ADVANCED\", {\n notifiers: {\n update: true\n },\n embedded: true,\n options: [{\n label: \"UV1\",\n value: 0\n }, {\n label: \"UV2\",\n value: 1\n }, {\n label: \"UV3\",\n value: 2\n }, {\n label: \"UV4\",\n value: 3\n }, {\n label: \"UV5\",\n value: 4\n }, {\n label: \"UV6\",\n value: 5\n }]\n})], SetUVsBlock.prototype, \"textureCoordinateIndex\", void 0);\nRegisterClass(\"BABYLON.SetUVsBlock\", SetUVsBlock);","map":{"version":3,"names":["__decorate","NodeGeometryBlock","RegisterClass","NodeGeometryBlockConnectionPointTypes","editableInPropertyPage","SetUVsBlock","constructor","name","evaluateContext","textureCoordinateIndex","registerInput","Geometry","Vector2","registerOutput","getExecutionIndex","_currentIndex","getExecutionLoopIndex","getExecutionFaceIndex","getClassName","geometry","_inputs","uvs","output","_outputs","_buildBlock","state","func","pushExecutionContext","_vertexData","getConnectedValue","clone","pushGeometryContext","positions","restoreGeometryContext","restoreExecutionContext","_storedValue","isConnected","vertexCount","length","tempVector2","toArray","uvs2","uvs3","uvs4","uvs5","uvs6","_storedFunction","_dumpPropertiesCode","codeString","_codeVariableName","serialize","serializationObject","_deserialize","undefined","embedded","notifiers","rebuild","prototype","update","options","label","value"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Meshes/Node/Blocks/Set/setUVsBlock.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 texture coordinates for a geometry\n */\nexport class SetUVsBlock extends NodeGeometryBlock {\n /**\n * Create a new SetUVsBlock\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 /**\n * Gets or sets a value indicating which UV to set\n */\n this.textureCoordinateIndex = 0;\n this.registerInput(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\n this.registerInput(\"uvs\", NodeGeometryBlockConnectionPointTypes.Vector2);\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\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 \"SetUVsBlock\";\n }\n /**\n * Gets the geometry input component\n */\n get geometry() {\n return this._inputs[0];\n }\n /**\n * Gets the uvs input component\n */\n get uvs() {\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.uvs.isConnected) {\n state.restoreGeometryContext();\n state.restoreExecutionContext();\n this.output._storedValue = this._vertexData;\n return;\n }\n const uvs = [];\n // Processing\n const vertexCount = this._vertexData.positions.length / 3;\n for (this._currentIndex = 0; this._currentIndex < vertexCount; this._currentIndex++) {\n const tempVector2 = this.uvs.getConnectedValue(state);\n if (tempVector2) {\n tempVector2.toArray(uvs, this._currentIndex * 2);\n }\n }\n switch (this.textureCoordinateIndex) {\n case 0:\n this._vertexData.uvs = uvs;\n break;\n case 1:\n this._vertexData.uvs2 = uvs;\n break;\n case 2:\n this._vertexData.uvs3 = uvs;\n break;\n case 3:\n this._vertexData.uvs4 = uvs;\n break;\n case 4:\n this._vertexData.uvs5 = uvs;\n break;\n case 5:\n this._vertexData.uvs6 = uvs;\n break;\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 let codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.textureCoordinateIndex};\\n`;\n codeString += `${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 serializationObject.textureCoordinateIndex = this.textureCoordinateIndex;\n return serializationObject;\n }\n _deserialize(serializationObject) {\n super._deserialize(serializationObject);\n this.textureCoordinateIndex = serializationObject.textureCoordinateIndex;\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], SetUVsBlock.prototype, \"evaluateContext\", void 0);\n__decorate([\n editableInPropertyPage(\"Texture coordinates index\", 4 /* PropertyTypeForEdition.List */, \"ADVANCED\", {\n notifiers: { update: true },\n embedded: true,\n options: [\n { label: \"UV1\", value: 0 },\n { label: \"UV2\", value: 1 },\n { label: \"UV3\", value: 2 },\n { label: \"UV4\", value: 3 },\n { label: \"UV5\", value: 4 },\n { label: \"UV6\", value: 5 },\n ],\n })\n], SetUVsBlock.prototype, \"textureCoordinateIndex\", void 0);\nRegisterClass(\"BABYLON.SetUVsBlock\", SetUVsBlock);\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,0BAA0B;AACrD,SAASC,iBAAiB,QAAQ,4BAA4B;AAC9D,SAASC,aAAa,QAAQ,+BAA+B;AAC7D,SAASC,qCAAqC,QAAQ,iDAAiD;AACvG,SAASC,sBAAsB,QAAQ,yCAAyC;AAChF;AACA;AACA;AACA,OAAO,MAAMC,WAAW,SAASJ,iBAAiB,CAAC;EAC/C;AACJ;AACA;AACA;EACIK,WAAWA,CAACC,IAAI,EAAE;IACd,KAAK,CAACA,IAAI,CAAC;IACX;AACR;AACA;AACA;IACQ,IAAI,CAACC,eAAe,GAAG,IAAI;IAC3B;AACR;AACA;IACQ,IAAI,CAACC,sBAAsB,GAAG,CAAC;IAC/B,IAAI,CAACC,aAAa,CAAC,UAAU,EAAEP,qCAAqC,CAACQ,QAAQ,CAAC;IAC9E,IAAI,CAACD,aAAa,CAAC,KAAK,EAAEP,qCAAqC,CAACS,OAAO,CAAC;IACxE,IAAI,CAACC,cAAc,CAAC,QAAQ,EAAEV,qCAAqC,CAACQ,QAAQ,CAAC;EACjF;EACA;AACJ;AACA;AACA;EACIG,iBAAiBA,CAAA,EAAG;IAChB,OAAO,IAAI,CAACC,aAAa;EAC7B;EACA;AACJ;AACA;AACA;EACIC,qBAAqBA,CAAA,EAAG;IACpB,OAAO,IAAI,CAACD,aAAa;EAC7B;EACA;AACJ;AACA;AACA;EACIE,qBAAqBA,CAAA,EAAG;IACpB,OAAO,CAAC;EACZ;EACA;AACJ;AACA;AACA;EACIC,YAAYA,CAAA,EAAG;IACX,OAAO,aAAa;EACxB;EACA;AACJ;AACA;EACI,IAAIC,QAAQA,CAAA,EAAG;IACX,OAAO,IAAI,C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