@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
42 lines (41 loc) • 1.82 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 { defaultPrimitiveGraph } from "./_BaseObject3D";
const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF;
class PrimitiveNeighboursCountJsParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param entity index */
this.index = ParamConfig.INTEGER(0);
/** @param require a shared edge */
this.sharedEdgeOnly = ParamConfig.BOOLEAN(0);
}
}
const ParamsConfig = new PrimitiveNeighboursCountJsParamsConfig();
export class PrimitiveNeighboursCountJsNode extends TypedJsNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return "primitiveNeighboursCount";
}
initializeNode() {
super.initializeNode();
this.io.outputs.setNamedOutputConnectionPoints([
new JsConnectionPoint(JsConnectionPointType.INT, JsConnectionPointType.INT, CONNECTION_OPTIONS)
]);
}
setLines(linesController) {
const primitiveGraph = defaultPrimitiveGraph(linesController);
const index = this.variableForInputParam(linesController, this.p.index);
const sharedEdgeOnly = this.variableForInputParam(linesController, this.p.sharedEdgeOnly);
const out = this.jsVarName(JsConnectionPointType.INT);
const func = Poly.namedFunctionsRegister.getFunction("primitiveNeighboursCount", this, linesController);
const bodyLine = func.asString(primitiveGraph, index, sharedEdgeOnly);
linesController.addBodyOrComputed(this, [{ dataType: JsConnectionPointType.INT, varName: out, value: bodyLine }]);
}
}