@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
42 lines (41 loc) • 1.2 kB
JavaScript
;
import { TypedPostNode, PostParamOptions } from "./_Base";
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
import { KawaseBlurPass, KernelSize } from "postprocessing";
import { KERNEL_SIZES, KERNEL_SIZE_MENU_OPTIONS } from "../../../core/post/KernelSize";
class BlurPostParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param amount */
this.amount = ParamConfig.FLOAT(1, {
range: [0, 2],
rangeLocked: [true, false],
step: 0.01,
...PostParamOptions
});
/** @param kernel size */
this.kernelSize = ParamConfig.INTEGER(KernelSize.LARGE, {
...PostParamOptions,
...KERNEL_SIZE_MENU_OPTIONS
});
}
}
const ParamsConfig = new BlurPostParamsConfig();
export class BlurPostNode extends TypedPostNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return "blur";
}
createPass(context) {
const pass = new KawaseBlurPass();
this.updatePass(pass);
return pass;
}
updatePass(pass) {
pass.scale = this.pv.amount;
pass.blurMaterial.kernelSize = KERNEL_SIZES[this.pv.kernelSize];
}
}