{"size": 995, "ext": "js", "max_stars_repo_path": "src/renderer/loaders/md5-loader.js", "max_stars_repo_name": "maierfelix/rokon", "max_stars_repo_stars_event_min_datetime": "2018-06-05T14:21:31.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-23T05:02:19.000Z", "max_issues_repo_path": "src/renderer/loaders/md5-loader.js", "max_issues_repo_name": "Ali8668/rokon", "max_issues_repo_issues_event_min_datetime": "2018-07-09T00:48:15.000Z", "max_issues_repo_issues_event_max_datetime": "2018-07-09T00:48:15.000Z", "max_forks_repo_path": "src/renderer/loaders/md5-loader.js", "max_forks_repo_name": "Ali8668/rokon", "max_forks_repo_forks_event_min_datetime": "2018-06-05T15:01:49.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-20T07:48:37.000Z"}
{"max_stars_count": 210, "max_issues_count": 1, "max_forks_count": 14, "avg_line_length": 21.170212766, "max_line_length": 76, "alphanum_fraction": 0.6020100503}
import {
  uid,
  loadText
} from "../../utils";

import MD5Object from "../objects/md5-object";

import MD5 from "../md5";

/**
 * A md5 file loader
 * @class MD5FileLoader
 */
export default class MD5FileLoader {
  /**
   * @param {Object} opts
   * @constructor
   */
  constructor(opts = {}) {
    this.uid = uid();
    this.gl = opts.gl;
    this.renderer = opts.renderer;
    this.path = opts.path;
    this.loaded = false;
  }
};

MD5FileLoader.prototype.fromPath = function(path) {
  this.path = path;
  this.loaded = false;
  return new Promise(resolve => {
    let model = new MD5.Md5Mesh();
    model.load(gl, path, () => {
      let mesh = {
        vertices: model.vertArray
      };
      let object = this.renderer.createObject(MD5Object, { useMesh: mesh });
      console.log(object);
      object.buffers.vertices = model.vertBuffer;
      object.buffers.indices = model.indexBuffer;
      this.loaded = true;
      object.model = model;
      resolve(object);
    });
  });
};
