getConst method

dynamic getConst(
  1. dynamic type,
  2. dynamic value
)

Implementation

getConst(type, value) {
  if (type == 'float') return value + (value % 1 ? '' : '.0');
  if (type == 'vec2')
    return "${this.getType('vec2')}( ${value.x}, ${value.y} )";
  if (type == 'vec3')
    return "${this.getType('vec3')}( ${value.x}, ${value.y}, ${value.z} )";
  if (type == 'vec4')
    return "${this.getType('vec4')}( ${value.x}, ${value.y}, ${value.z}, ${value.w} )";
  if (type == 'color')
    return "${this.getType('vec3')}( ${value.r}, ${value.g}, ${value.b} )";

  throw ("NodeBuilder: Type '${type}' not found in generate constant attempt.");
}