UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

50 lines (49 loc) 1.78 kB
"use strict"; 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 { JsType } from "../../poly/registers/nodes/types/Js"; const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF; class GetParamJsParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param parameter to get */ this.Param = ParamConfig.PARAM_PATH("", { dependentOnFoundParam: false, paramSelection: true, computeOnDirty: false }); } } const ParamsConfig = new GetParamJsParamsConfig(); export class GetParamJsNode extends TypedJsNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return JsType.GET_PARAM; } initializeNode() { this.io.outputs.setNamedOutputConnectionPoints([ new JsConnectionPoint(JsConnectionPointType.PARAM, JsConnectionPointType.PARAM, CONNECTION_OPTIONS) ]); this.io.connection_points.spare_params.setInputlessParamNames([JsConnectionPointType.PARAM]); } setParamPath(paramPath) { this.p.Param.set(paramPath); } setLines(linesController) { const out = this.jsVarName(JsConnectionPointType.PARAM); const param = this.params.get(JsConnectionPointType.PARAM).value.param(); if (!param) { return; } const func = Poly.namedFunctionsRegister.getFunction("getParam", this, linesController); const bodyLine = func.asString(`'${param.path()}'`); linesController.addBodyOrComputed(this, [ { dataType: JsConnectionPointType.PARAM, varName: out, value: bodyLine } ]); } }