generate method

dynamic generate([
  1. dynamic builder,
  2. dynamic output
])
override

Implementation

generate([builder, output]) {
  var material = builder.context["material"];
  var scope = this.scope;

  var node = null;

  print(" ============ this ${this} generate scope: ${scope}  ");

  if (scope == MaterialNode.ALPHA_TEST) {
    node = new MaterialReferenceNode('alphaTest', 'float');
  } else if (scope == MaterialNode.COLOR) {
    var colorNode = new MaterialReferenceNode('color', 'color');

    if (material.map != null &&
        material.map != undefined &&
        material.map.isTexture == true) {
      node = new OperatorNode(
          '*', colorNode, new MaterialReferenceNode('map', 'texture'));
    } else {
      node = colorNode;
    }
  } else if (scope == MaterialNode.OPACITY) {
    var opacityNode = new MaterialReferenceNode('opacity', 'float');

    if (material.alphaMap != null &&
        material.alphaMap != undefined &&
        material.alphaMap.isTexture == true) {
      node = new OperatorNode(
          '*', opacityNode, new MaterialReferenceNode('alphaMap', 'texture'));
    } else {
      node = opacityNode;
    }
  } else if (scope == MaterialNode.SPECULAR) {
    var specularColorNode =
        new MaterialReferenceNode('specularColor', 'color');

    if (material.specularColorMap != null &&
        material.specularColorMap != undefined &&
        material.specularColorMap.isTexture == true) {
      node = new OperatorNode('*', specularColorNode,
          new MaterialReferenceNode('specularColorMap', 'texture'));
    } else {
      node = specularColorNode;
    }
  } else {
    var outputType = this.getNodeType(builder);

    node = new MaterialReferenceNode(scope, outputType);
  }

  return node.build(builder, output);
}