import {BaseController as BaseController2} from "./_BaseController";
import {TypedMatNode} from "../_Base";
import {Material as Material2} from "three/src/materials/Material";
import {NodeParamsConfig, ParamConfig} from "../../utils/params/ParamsConfig";
var LineCapType;
(function(LineCapType2) {
  LineCapType2["ROUND"] = "round";
  LineCapType2["BUTT"] = "butt";
  LineCapType2["SQUARE"] = "square";
})(LineCapType || (LineCapType = {}));
const LINE_CAP_TYPES = [LineCapType.ROUND, LineCapType.BUTT, LineCapType.SQUARE];
var LineJoinType;
(function(LineJoinType2) {
  LineJoinType2["ROUND"] = "round";
  LineJoinType2["BEVEL"] = "bevel";
  LineJoinType2["MITER"] = "miter";
})(LineJoinType || (LineJoinType = {}));
const LINE_JOIN_TYPES = [LineJoinType.ROUND, LineJoinType.BEVEL, LineJoinType.MITER];
export function WireframeParamConfig(Base2) {
  return class Mixin extends Base2 {
    constructor() {
      super(...arguments);
      this.wireframe = ParamConfig.BOOLEAN(0);
      this.wireframeLinecap = ParamConfig.INTEGER(0, {
        menu: {
          entries: LINE_CAP_TYPES.map((name, value) => {
            return {name, value};
          })
        },
        visibleIf: {wireframe: 1}
      });
      this.wireframeLinejoin = ParamConfig.INTEGER(0, {
        menu: {
          entries: LINE_JOIN_TYPES.map((name, value) => {
            return {name, value};
          })
        },
        visibleIf: {wireframe: 1}
      });
    }
  };
}
class WireframedMaterial extends Material2 {
}
class WireframeParamsConfig extends WireframeParamConfig(NodeParamsConfig) {
}
class WireframedMatNode extends TypedMatNode {
  create_material() {
    return new WireframedMaterial();
  }
}
export class WireframeController extends BaseController2 {
  constructor(node) {
    super(node);
    this.node = node;
  }
  static update(node) {
    const material = node.material;
    const pv = node.pv;
    material.wireframe = pv.wireframe;
    material.wireframeLinecap = LINE_CAP_TYPES[pv.wireframeLinecap];
    material.wireframeLinejoin = LINE_JOIN_TYPES[pv.wireframeLinejoin];
    material.needsUpdate = true;
  }
}
