{"size": 2323, "ext": "js", "max_stars_repo_path": "geedataextract/node_modules/@luma.gl/shadertools/dist/es6/utils/shader-utils.js", "max_stars_repo_name": "ehurme/geedataextract", "max_stars_repo_stars_event_min_datetime": "2019-10-17T02:19:14.000Z", "max_stars_repo_stars_event_max_datetime": "2020-02-25T07:00:01.000Z", "max_issues_repo_path": "geedataextract/node_modules/@luma.gl/shadertools/dist/es6/utils/shader-utils.js", "max_issues_repo_name": "ehurme/geedataextract", "max_issues_repo_issues_event_min_datetime": "2019-11-05T06:42:42.000Z", "max_issues_repo_issues_event_max_datetime": "2019-11-05T07:42:20.000Z", "max_forks_repo_path": "Pydeck/node_modules/@luma.gl/shadertools/dist/es6/utils/shader-utils.js", "max_forks_repo_name": "mincloud1501/Python", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 5, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 22.7745098039, "max_line_length": 231, "alphanum_fraction": 0.5858803272}
import { assert } from '../utils';
const FS100 = "void main() {gl_FragColor = vec4(0);}";
const FS_GLES = "out vec4 transform_output;\nvoid main() {\n  transform_output = vec4(0);\n}";
const FS300 = "#version 300 es\n".concat(FS_GLES);
export function getQualifierDetails(line, qualifiers) {
  qualifiers = Array.isArray(qualifiers) ? qualifiers : [qualifiers];
  const words = line.replace(/^\s+/, '').split(/\s+/);
  const [qualifier, type, definition] = words;

  if (!qualifiers.includes(qualifier) || !type || !definition) {
    return null;
  }

  const name = definition.split(';')[0];
  return {
    qualifier,
    type,
    name
  };
}
export function getPassthroughFS({
  version = 100,
  input,
  inputType,
  output
} = {}) {
  if (!input) {
    if (version === 300) {
      return FS300;
    } else if (version > 300) {
      return "#version ".concat(version, "\n").concat(FS_GLES);
    }

    return FS100;
  }

  const outputValue = convertToVec4(input, inputType);

  if (version >= 300) {
    return "#version ".concat(version, " ").concat(version === 300 ? 'es' : '', "\nin ").concat(inputType, " ").concat(input, ";\nout vec4 ").concat(output, ";\nvoid main() {\n  ").concat(output, " = ").concat(outputValue, ";\n}");
  }

  return "varying ".concat(inputType, " ").concat(input, ";\nvoid main() {\n  gl_FragColor = ").concat(outputValue, ";\n}");
}
export function typeToChannelSuffix(type) {
  switch (type) {
    case 'float':
      return 'x';

    case 'vec2':
      return 'xy';

    case 'vec3':
      return 'xyz';

    case 'vec4':
      return 'xyzw';

    default:
      assert(false);
      return null;
  }
}
export function typeToChannelCount(type) {
  switch (type) {
    case 'float':
      return 1;

    case 'vec2':
      return 2;

    case 'vec3':
      return 3;

    case 'vec4':
      return 4;

    default:
      assert(false);
      return null;
  }
}
export function convertToVec4(variable, type) {
  switch (type) {
    case 'float':
      return "vec4(".concat(variable, ", 0.0, 0.0, 1.0)");

    case 'vec2':
      return "vec4(".concat(variable, ", 0.0, 1.0)");

    case 'vec3':
      return "vec4(".concat(variable, ", 1.0)");

    case 'vec4':
      return variable;

    default:
      assert(false);
      return null;
  }
}
//# sourceMappingURL=shader-utils.js.map