Skip to content

Commit 482d4f3

Browse files
committed
improvement based on feedback
1 parent 4be807d commit 482d4f3

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

src/scene/materials/shader-graph-node.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -91,31 +91,32 @@ Object.assign(ShaderGraphNode.prototype, {
9191
var i;
9292
if (this.graphData.ioPorts && this.graphData.ioPorts.length > 0 && (this.graphData.customFuncGlsl || ( this.graphData.subGraphs && this.graphData.subGraphs.length > 0 && this.graphData.connections))) {
9393
for (i = 0; i < this.graphData.ioPorts.length; i++) {
94-
if (this.graphData.ioPorts[i] && this.graphData.ioPorts[i].name && this.graphData.ioPorts[i].type) {
95-
if (this.graphData.ioPorts[i].type === 'sampler2D' && !this.graphData.ioPorts[i].name.startsWith('OUT_') ) {
96-
if (!(this.graphData.ioPorts[i].valueTex && this.graphData.ioPorts[i].valueTex instanceof Texture)) {
94+
var ioPort = this.graphData.ioPorts[i];
95+
if (ioPort && ioPort.name && ioPort.type) {
96+
if (ioPort.type === 'sampler2D' && !ioPort.name.startsWith('OUT_') ) {
97+
if (!(ioPort.valueTex && ioPort.valueTex instanceof Texture)) {
9798
return false;
9899
}
99-
} else if (this.graphData.ioPorts[i].type === 'float' && !this.graphData.ioPorts[i].name.startsWith('OUT_') ) {
100-
if (!(this.graphData.ioPorts[i].valueX != undefined && typeof(this.graphData.ioPorts[i].valueX) === 'number')) {
100+
} else if (ioPort.type === 'float' && !ioPort.name.startsWith('OUT_') ) {
101+
if (!(ioPort.valueX != undefined && typeof(ioPort.valueX) === 'number')) {
101102
return false;
102103
}
103-
} else if (this.graphData.ioPorts[i].type === 'vec2' && !this.graphData.ioPorts[i].name.startsWith('OUT_') ) {
104-
if (!(this.graphData.ioPorts[i].valueX != undefined && typeof(this.graphData.ioPorts[i].valueX) === 'number' &&
105-
this.graphData.ioPorts[i].valueY != undefined && typeof(this.graphData.ioPorts[i].valueY) === 'number' )) {
104+
} else if (ioPort.type === 'vec2' && !ioPort.name.startsWith('OUT_') ) {
105+
if (!(ioPort.valueX != undefined && typeof(ioPort.valueX) === 'number' &&
106+
ioPort.valueY != undefined && typeof(ioPort.valueY) === 'number' )) {
106107
return false;
107108
}
108-
} else if (this.graphData.ioPorts[i].type === 'vec3' && !this.graphData.ioPorts[i].name.startsWith('OUT_') ) {
109-
if (!(this.graphData.ioPorts[i].valueX != undefined && typeof(this.graphData.ioPorts[i].valueX) === 'number' &&
110-
this.graphData.ioPorts[i].valueY != undefined && typeof(this.graphData.ioPorts[i].valueY) === 'number' &&
111-
this.graphData.ioPorts[i].valueZ != undefined && typeof(this.graphData.ioPorts[i].valueZ) === 'number' )) {
109+
} else if (ioPort.type === 'vec3' && !ioPort.name.startsWith('OUT_') ) {
110+
if (!(ioPort.valueX != undefined && typeof(ioPort.valueX) === 'number' &&
111+
ioPort.valueY != undefined && typeof(ioPort.valueY) === 'number' &&
112+
ioPort.valueZ != undefined && typeof(ioPort.valueZ) === 'number' )) {
112113
return false;
113114
}
114-
} else if (this.graphData.ioPorts[i].type === 'vec4' && !this.graphData.ioPorts[i].name.startsWith('OUT_') ) {
115-
if (!(this.graphData.ioPorts[i].valueX != undefined && typeof(this.graphData.ioPorts[i].valueX) === 'number' &&
116-
this.graphData.ioPorts[i].valueY != undefined && typeof(this.graphData.ioPorts[i].valueY) === 'number' &&
117-
this.graphData.ioPorts[i].valueZ != undefined && typeof(this.graphData.ioPorts[i].valueZ) === 'number' &&
118-
this.graphData.ioPorts[i].valueW != undefined && typeof(this.graphData.ioPorts[i].valueW) === 'number' )) {
115+
} else if (ioPort.type === 'vec4' && !ioPort.name.startsWith('OUT_') ) {
116+
if (!(ioPort.valueX != undefined && typeof(ioPort.valueX) === 'number' &&
117+
ioPort.valueY != undefined && typeof(ioPort.valueY) === 'number' &&
118+
ioPort.valueZ != undefined && typeof(ioPort.valueZ) === 'number' &&
119+
ioPort.valueW != undefined && typeof(ioPort.valueW) === 'number' )) {
119120
return false;
120121
}
121122
}

0 commit comments

Comments
 (0)