@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
36 lines (35 loc) • 991 B
JavaScript
;
import { TypedPostNode, PostParamOptions } from "./_Base";
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
import { EffectPass, PixelationEffect } from "postprocessing";
class PixelPostParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param pixelSize */
this.pixelSize = ParamConfig.INTEGER(16, {
range: [1, 50],
rangeLocked: [true, false],
...PostParamOptions
});
}
}
const ParamsConfig = new PixelPostParamsConfig();
export class PixelPostNode extends TypedPostNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return "pixel";
}
createPass(context) {
const effect = new PixelationEffect(5);
const pass = new EffectPass(context.camera, effect);
this.updatePass(pass);
return pass;
}
updatePass(pass) {
const effect = pass.effects[0];
effect.granularity = this.pv.pixelSize;
}
}