polygonjs-engine
Version:
node-based webgl 3D engine https://polygonjs.com
69 lines (68 loc) • 2.25 kB
JavaScript
import {Vector2 as Vector22} from "three/src/math/Vector2";
import {TypedPostProcessNode, PostParamOptions} from "./_Base";
import {OutlinePass as OutlinePass2} from "../../../modules/three/examples/jsm/postprocessing/OutlinePass";
import {NodeParamsConfig, ParamConfig} from "../utils/params/ParamsConfig";
class OutlinePostParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
this.objectsMask = ParamConfig.STRING("*outlined*", {
...PostParamOptions
});
this.refreshObjects = ParamConfig.BUTTON(null, {
...PostParamOptions
});
this.edgeStrength = ParamConfig.FLOAT(3, {
range: [0, 10],
rangeLocked: [true, false],
...PostParamOptions
});
this.edgeThickness = ParamConfig.FLOAT(0, {
range: [0, 4],
rangeLocked: [true, false],
...PostParamOptions
});
this.edgeGlow = ParamConfig.FLOAT(0, {
range: [0, 1],
rangeLocked: [true, false],
...PostParamOptions
});
this.pulsePeriod = ParamConfig.FLOAT(0, {
range: [0, 5],
rangeLocked: [true, false],
...PostParamOptions
});
this.visibleEdgeColor = ParamConfig.COLOR([1, 1, 1], {
...PostParamOptions
});
this.hiddenEdgeColor = ParamConfig.COLOR([0, 0, 0], {
...PostParamOptions
});
}
}
const ParamsConfig2 = new OutlinePostParamsConfig();
export class OutlinePostNode extends TypedPostProcessNode {
constructor() {
super(...arguments);
this.params_config = ParamsConfig2;
}
static type() {
return "outline";
}
_create_pass(context) {
const pass = new OutlinePass2(new Vector22(context.resolution.x, context.resolution.y), context.scene, context.camera, context.scene.children);
this.update_pass(pass);
return pass;
}
update_pass(pass) {
pass.edgeStrength = this.pv.edgeStrength;
pass.edgeThickness = this.pv.edgeThickness;
pass.edgeGlow = this.pv.edgeGlow;
pass.pulsePeriod = this.pv.pulsePeriod;
pass.visibleEdgeColor = this.pv.visibleEdgeColor;
pass.hiddenEdgeColor = this.pv.hiddenEdgeColor;
this._set_selected_objects(pass);
}
_set_selected_objects(pass) {
pass.selectedObjects = this.scene().objectsByMask(this.pv.objectsMask);
}
}