import {TypedPostProcessNode, PostParamOptions} from "./_Base";
import {AdaptiveToneMappingPass as AdaptiveToneMappingPass2} from "../../../modules/three/examples/jsm/postprocessing/AdaptiveToneMappingPass";
import {NodeParamsConfig, ParamConfig} from "../utils/params/ParamsConfig";
class AdaptiveToneMappingPostParamsConfig extends NodeParamsConfig {
  constructor() {
    super(...arguments);
    this.adaptive = ParamConfig.BOOLEAN(1, {
      ...PostParamOptions
    });
    this.averageLuminance = ParamConfig.FLOAT(0.7, {
      ...PostParamOptions
    });
    this.midGrey = ParamConfig.FLOAT(0.04, {
      ...PostParamOptions
    });
    this.maxLuminance = ParamConfig.FLOAT(16, {
      range: [0, 20],
      ...PostParamOptions
    });
    this.adaptiveRange = ParamConfig.FLOAT(2, {
      range: [0, 10],
      ...PostParamOptions
    });
  }
}
const ParamsConfig2 = new AdaptiveToneMappingPostParamsConfig();
export class AdaptiveToneMappingPostNode extends TypedPostProcessNode {
  constructor() {
    super(...arguments);
    this.params_config = ParamsConfig2;
  }
  static type() {
    return "adaptiveToneMapping";
  }
  _create_pass(context) {
    const pass = new AdaptiveToneMappingPass2(this.pv.adaptive, context.resolution.x);
    this.update_pass(pass);
    return pass;
  }
  update_pass(pass) {
    pass.setMaxLuminance(this.pv.maxLuminance);
    pass.setMiddleGrey(this.pv.midGrey);
    pass.setAverageLuminance(this.pv.averageLuminance);
  }
}
