import {BaseSopOperation} from "./_Base";
import {ASSETS_ROOT} from "../../loader/AssetsUtils";
import {CoreSVGLoader} from "../../loader/SVG";
const DEFAULT_URL = `${ASSETS_ROOT}/models/svg/tiger.svg`;
export class SvgSopOperation extends BaseSopOperation {
  static type() {
    return "svg";
  }
  cook(input_contents, params) {
    const loader = new CoreSVGLoader(params.url, this.scene);
    return new Promise(async (resolve) => {
      const group = await loader.load(params);
      for (let child of group.children) {
        this._ensure_geometry_has_index(child);
      }
      resolve(this.create_core_group_from_objects(group.children));
    });
  }
  _ensure_geometry_has_index(object) {
    const mesh = object;
    const geometry = mesh.geometry;
    if (geometry) {
      this.create_index_if_none(geometry);
    }
  }
}
SvgSopOperation.DEFAULT_PARAMS = {
  url: DEFAULT_URL,
  drawFillShapes: true,
  fillShapesWireframe: false,
  drawStrokes: true,
  strokesWireframe: false
};
