import {RectAreaLight as RectAreaLight2} from "three/src/lights/RectAreaLight";
import {RectAreaLightUniformsLib as RectAreaLightUniformsLib2} from "../../../modules/three/examples/jsm/lights/RectAreaLightUniformsLib";
import {BaseLightTransformedObjNode} from "./_BaseLightTransformed";
import {TransformedParamConfig} from "./utils/TransformController";
import {NodeParamsConfig, ParamConfig} from "../utils/params/ParamsConfig";
import {ColorConversion} from "../../../core/Color";
import {HelperController as HelperController2} from "./utils/HelperController";
import {RectAreaLightObjNodeHelper} from "./utils/helpers/AreaLightHelper";
export function AreaLightParamConfig(Base) {
  return class Mixin extends Base {
    constructor() {
      super(...arguments);
      this.light = ParamConfig.FOLDER();
      this.color = ParamConfig.COLOR([1, 1, 1], {
        conversion: ColorConversion.SRGB_TO_LINEAR
      });
      this.intensity = ParamConfig.FLOAT(1, {range: [0, 10]});
      this.width = ParamConfig.FLOAT(1, {range: [0, 10]});
      this.height = ParamConfig.FLOAT(1, {range: [0, 10]});
      this.showHelper = ParamConfig.BOOLEAN(0);
    }
  };
}
class AreaLightObjParamsConfig extends AreaLightParamConfig(TransformedParamConfig(NodeParamsConfig)) {
}
const ParamsConfig2 = new AreaLightObjParamsConfig();
export class AreaLightObjNode extends BaseLightTransformedObjNode {
  constructor() {
    super(...arguments);
    this.params_config = ParamsConfig2;
    this._helper_controller = new HelperController2(this, RectAreaLightObjNodeHelper, "RectAreaLightObjNodeHelper");
  }
  static type() {
    return "areaLight";
  }
  initializeNode() {
    this._helper_controller.initializeNode();
  }
  create_light() {
    const light = new RectAreaLight2(16777215, 1, 1, 1);
    light.matrixAutoUpdate = false;
    if (!RectAreaLightUniformsLib2.initialized) {
      RectAreaLightUniformsLib2.init();
      RectAreaLightUniformsLib2.initialized = true;
    }
    return light;
  }
  update_light_params() {
    this.light.color = this.pv.color;
    this.light.intensity = this.pv.intensity;
    this.light.width = this.pv.width;
    this.light.height = this.pv.height;
    this._helper_controller.update();
  }
}
