getVarFromNode method

dynamic getVarFromNode(
  1. dynamic node,
  2. dynamic type, [
  3. dynamic shaderStage
])

Implementation

getVarFromNode(node, type, [shaderStage]) {
  shaderStage ??= this.shaderStage;

  Map nodeData = this.getDataFromNode(node, shaderStage);

  var nodeVar = nodeData["variable"];

  if (nodeVar == undefined) {
    var vars = this.vars[shaderStage];
    var index = vars.length;

    nodeVar = new NodeVar('nodeVar${index}', type);

    vars.add(nodeVar);

    nodeData["variable"] = nodeVar;
  }

  return nodeVar;
}