import {TypedPostProcessNode, PostParamOptions} from "./_Base";
import {FilmPass as FilmPass2} from "../../../modules/three/examples/jsm/postprocessing/FilmPass";
import {NodeParamsConfig, ParamConfig} from "../utils/params/ParamsConfig";
class FilmPostParamsConfig extends NodeParamsConfig {
  constructor() {
    super(...arguments);
    this.noiseIntensity = ParamConfig.FLOAT(0.5, {
      range: [0, 1],
      rangeLocked: [false, false],
      ...PostParamOptions
    });
    this.scanlinesIntensity = ParamConfig.FLOAT(0.05, {
      range: [0, 1],
      rangeLocked: [true, false],
      ...PostParamOptions
    });
    this.scanlinesCount = ParamConfig.FLOAT(4096, {
      range: [0, 4096],
      rangeLocked: [true, false],
      ...PostParamOptions
    });
    this.grayscale = ParamConfig.BOOLEAN(1, {
      ...PostParamOptions
    });
  }
}
const ParamsConfig2 = new FilmPostParamsConfig();
export class FilmPostNode extends TypedPostProcessNode {
  constructor() {
    super(...arguments);
    this.params_config = ParamsConfig2;
  }
  static type() {
    return "film";
  }
  _create_pass(context) {
    const pass = new FilmPass2(this.pv.noiseIntensity, this.pv.scanlinesIntensity, this.pv.scanlinesCount, this.pv.grayscale ? 1 : 0);
    this.update_pass(pass);
    return pass;
  }
  update_pass(pass) {
    pass.uniforms.nIntensity.value = this.pv.noiseIntensity;
    pass.uniforms.sIntensity.value = this.pv.scanlinesIntensity;
    pass.uniforms.sCount.value = this.pv.scanlinesCount;
    pass.uniforms.grayscale.value = this.pv.grayscale ? 1 : 0;
  }
}
