@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
41 lines (40 loc) • 1.68 kB
JavaScript
;
import { TRIGGER_CONNECTION_NAME, TypedJsNode } from "./_Base";
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
import { JsConnectionPoint, JsConnectionPointType, JS_CONNECTION_POINT_IN_NODE_DEF } from "../utils/io/connections/Js";
import { Poly } from "../../Poly";
const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF;
class SetViewerJsParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param sets the class of the viewer */
this.className = ParamConfig.STRING("active");
/** @param set or unset */
this.set = ParamConfig.BOOLEAN(1);
}
}
const ParamsConfig = new SetViewerJsParamsConfig();
export class SetViewerJsNode extends TypedJsNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return "setViewer";
}
initializeNode() {
this.io.inputs.setNamedInputConnectionPoints([
new JsConnectionPoint(TRIGGER_CONNECTION_NAME, JsConnectionPointType.TRIGGER, CONNECTION_OPTIONS)
]);
this.io.outputs.setNamedOutputConnectionPoints([
new JsConnectionPoint(TRIGGER_CONNECTION_NAME, JsConnectionPointType.TRIGGER)
]);
}
setTriggerableLines(shadersCollectionController) {
const className = this.variableForInputParam(shadersCollectionController, this.p.className);
const set = this.variableForInputParam(shadersCollectionController, this.p.set);
const func = Poly.namedFunctionsRegister.getFunction("setViewer", this, shadersCollectionController);
const bodyLine = func.asString(className, set);
shadersCollectionController.addTriggerableLines(this, [bodyLine]);
}
}