浏览代码

Fix codeNaming issue (nme)

David Catuhe 5 年之前
父节点
当前提交
209c6c2f98
共有 2 个文件被更改,包括 13 次插入11 次删除
  1. 12 10
      src/Materials/Node/Blocks/Input/inputBlock.ts
  2. 1 1
      src/Materials/Node/nodeMaterialBlock.ts

+ 12 - 10
src/Materials/Node/Blocks/Input/inputBlock.ts

@@ -541,22 +541,24 @@ export class InputBlock extends NodeMaterialBlock {
     }
 
     protected _dumpPropertiesCode() {
+        let variableName = this._codeVariableName;
+
         if (this.isAttribute) {
-            return `${this._codeVariableName}.setAsAttribute("${this.name}");\r\n`;
+            return `${variableName}.setAsAttribute("${this.name}");\r\n`;
         }
         if (this.isSystemValue) {
-            return `${this._codeVariableName}.setAsSystemValue(BABYLON.NodeMaterialSystemValues.${NodeMaterialSystemValues[this._systemValue!]});\r\n`;
+            return `${variableName}.setAsSystemValue(BABYLON.NodeMaterialSystemValues.${NodeMaterialSystemValues[this._systemValue!]});\r\n`;
         }
         if (this.isUniform) {
             let valueString = "";
             switch (this.type) {
                 case NodeMaterialBlockConnectionPointTypes.Float:
-                    let returnValue = `${this._codeVariableName}.value = ${this.value};\r\n`;
+                    let returnValue = `${variableName}.value = ${this.value};\r\n`;
 
-                    returnValue += `${this._codeVariableName}.min = ${this.min};\r\n`;
-                    returnValue += `${this._codeVariableName}.max = ${this.max};\r\n`;
-                    returnValue += `${this._codeVariableName}.matrixMode = ${this.matrixMode};\r\n`;
-                    returnValue += `${this._codeVariableName}.animationType  = BABYLON.AnimatedInputBlockTypes.${AnimatedInputBlockTypes[this.animationType]};\r\n`;
+                    returnValue += `${variableName}.min = ${this.min};\r\n`;
+                    returnValue += `${variableName}.max = ${this.max};\r\n`;
+                    returnValue += `${variableName}.matrixMode = ${this.matrixMode};\r\n`;
+                    returnValue += `${variableName}.animationType  = BABYLON.AnimatedInputBlockTypes.${AnimatedInputBlockTypes[this.animationType]};\r\n`;
 
                     return returnValue;
                 case NodeMaterialBlockConnectionPointTypes.Vector2:
@@ -575,9 +577,9 @@ export class InputBlock extends NodeMaterialBlock {
                     valueString = `new BABYLON.Color4(${this.value.r}, ${this.value.g}, ${this.value.b}, ${this.value.a})`;
                     break;
             }
-            let finalOutput = `${this._codeVariableName}.value = ${valueString};\r\n`;
-            finalOutput += `${this._codeVariableName}.isConstant = ${this.isConstant ? "true" : "false"};\r\n`;
-            finalOutput += `${this._codeVariableName}.visibleInInspector = ${this.visibleInInspector ? "true" : "false"};\r\n`;
+            let finalOutput = `${variableName}.value = ${valueString};\r\n`;
+            finalOutput += `${variableName}.isConstant = ${this.isConstant ? "true" : "false"};\r\n`;
+            finalOutput += `${variableName}.visibleInInspector = ${this.visibleInInspector ? "true" : "false"};\r\n`;
 
             return finalOutput;
         }

+ 1 - 1
src/Materials/Node/nodeMaterialBlock.ts

@@ -541,7 +541,7 @@ export class NodeMaterialBlock {
 
         // Get unique name
         let nameAsVariableName = this.name.replace(/[^A-Za-z_]+/g, "");
-        this._codeVariableName = nameAsVariableName;
+        this._codeVariableName = nameAsVariableName || `${this.getClassName()}_${this.uniqueId}`;
 
         if (uniqueNames.indexOf(this._codeVariableName) !== -1) {
             let index = 0;