@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
52 lines (51 loc) • 1.81 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 { JsType } from "../../poly/registers/nodes/types/Js";
const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF;
class GetNodeJsParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param parameter to get */
this.Node = ParamConfig.NODE_PATH("", {
dependentOnFoundNode: false,
// nodeSelection: {
// context: NodeContext.SOP,
// },
computeOnDirty: false
});
}
}
const ParamsConfig = new GetNodeJsParamsConfig();
export class GetNodeJsNode extends TypedJsNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return JsType.GET_NODE;
}
initializeNode() {
this.io.outputs.setNamedOutputConnectionPoints([
new JsConnectionPoint(JsConnectionPointType.NODE, JsConnectionPointType.NODE, CONNECTION_OPTIONS)
]);
this.io.connection_points.spare_params.setInputlessParamNames([JsConnectionPointType.NODE]);
}
setNodePath(nodePath) {
this.p.Node.set(nodePath);
}
setLines(linesController) {
const out = this.jsVarName(JsConnectionPointType.NODE);
const node = this.params.get(JsConnectionPointType.NODE).value.node();
if (!node) {
return;
}
const func = Poly.namedFunctionsRegister.getFunction("getNode", this, linesController);
const bodyLine = func.asString(`'${node.path()}'`);
linesController.addBodyOrComputed(this, [
{ dataType: JsConnectionPointType.NODE, varName: out, value: bodyLine }
]);
}
}