import {TypedNode} from "../_Base";
import {Material as Material2} from "three/src/materials/Material";
import {NodeContext as NodeContext2} from "../../poly/NodeContext";
export class TypedMatNode extends TypedNode {
  constructor() {
    super(...arguments);
    this._cook_main_without_inputs_when_dirty_bound = this._cook_main_without_inputs_when_dirty.bind(this);
  }
  static nodeContext() {
    return NodeContext2.MAT;
  }
  initializeBaseNode() {
    super.initializeBaseNode();
    this.nameController.add_post_set_fullPath_hook(this.set_material_name.bind(this));
    this.addPostDirtyHook("_cook_main_without_inputs_when_dirty", () => {
      setTimeout(this._cook_main_without_inputs_when_dirty_bound, 0);
    });
  }
  async _cook_main_without_inputs_when_dirty() {
    await this.cookController.cook_main_without_inputs();
  }
  set_material_name() {
    if (this._material) {
      this._material.name = this.fullPath();
    }
  }
  get material() {
    return this._material = this._material || this.create_material();
  }
  set_material(material) {
    this.setContainer(material);
  }
}
export class BaseMatNodeClass extends TypedMatNode {
  create_material() {
    return new Material2();
  }
}
