Browse Source

Add a position2d attribute

Popov72 5 years ago
parent
commit
c150e043de

+ 3 - 1
nodeEditor/src/diagram/display/inputDisplayManager.ts

@@ -64,7 +64,9 @@ export class InputDisplayManager implements IDisplayManager {
         let inputBlock = block as InputBlock;
 
         if (inputBlock.isAttribute) {
-            value = "mesh." + inputBlock.name;
+            const attrVal = inputBlock.name === 'position2d' ? 'position' : inputBlock.name;
+            const attrName = inputBlock.name === 'position2d' ? 'postprocess' : 'mesh';
+            value = attrName + "." + attrVal;
         } else if (inputBlock.isSystemValue) {
             switch (inputBlock.systemValue) {
                 case NodeMaterialSystemValues.World:

+ 2 - 1
src/Materials/Node/Blocks/Input/inputBlock.ts

@@ -95,6 +95,7 @@ export class InputBlock extends NodeMaterialBlock {
                         return this._type;
                     case "uv":
                     case "uv2":
+                    case "position2d":
                         this._type = NodeMaterialBlockConnectionPointTypes.Vector2;
                         return this._type;
                     case "matricesIndices":
@@ -443,7 +444,7 @@ export class InputBlock extends NodeMaterialBlock {
 
         // Attribute
         if (this.isAttribute) {
-            this.associatedVariableName = this.name;
+            this.associatedVariableName = this.name === 'position2d' ? 'position' : this.name;
 
             if (this.target === NodeMaterialBlockTargets.Vertex && state._vertexState) { // Attribute for fragment need to be carried over by varyings
                 this._emit(state._vertexState, define);