@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
50 lines (49 loc) • 1.78 kB
JavaScript
;
import { 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";
import { inputParam } from "./_BaseObject3D";
import { ParamType } from "../../poly/ParamType";
const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF;
class PressButtonParamJsParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param the parameter to update */
this.Param = ParamConfig.PARAM_PATH("", {
dependentOnFoundParam: false,
paramSelection: ParamType.BUTTON,
computeOnDirty: true
});
}
}
const ParamsConfig = new PressButtonParamJsParamsConfig();
export class PressButtonParamJsNode extends TypedJsNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return "pressButtonParam";
}
initializeNode() {
this.io.inputs.setNamedInputConnectionPoints([
new JsConnectionPoint(JsConnectionPointType.TRIGGER, JsConnectionPointType.TRIGGER, CONNECTION_OPTIONS)
]);
this.io.outputs.setNamedOutputConnectionPoints([
new JsConnectionPoint(JsConnectionPointType.TRIGGER, JsConnectionPointType.TRIGGER)
]);
}
setParamPath(paramPath) {
this.p.Param.set(paramPath);
}
setParamParam(param) {
this.p.Param.setParam(param);
}
setTriggerableLines(linesController) {
const param = inputParam(this, linesController);
const func = Poly.namedFunctionsRegister.getFunction("pressButtonParam", this, linesController);
const bodyLine = func.asString(param);
linesController.addTriggerableLines(this, [bodyLine]);
}
}