UNPKG

@polygonjs/polygonjs

Version:

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

45 lines (44 loc) 2.01 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 { defaultPrimitiveGraph } from "./_BaseObject3D"; const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF; class PrimitiveNeighbourIndexJsParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param entity index */ this.index = ParamConfig.INTEGER(0); /** @param neighbour index */ this.neighbourIndex = ParamConfig.INTEGER(0); /** @param require a shared edge */ this.sharedEdgeOnly = ParamConfig.BOOLEAN(0); } } const ParamsConfig = new PrimitiveNeighbourIndexJsParamsConfig(); export class PrimitiveNeighbourIndexJsNode extends TypedJsNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return "primitiveNeighbourIndex"; } 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 neighbourIndex = this.variableForInputParam(linesController, this.p.neighbourIndex); const sharedEdgeOnly = this.variableForInputParam(linesController, this.p.sharedEdgeOnly); const out = this.jsVarName(JsConnectionPointType.INT); const func = Poly.namedFunctionsRegister.getFunction("primitiveNeighbourIndex", this, linesController); const bodyLine = func.asString(primitiveGraph, index, neighbourIndex, sharedEdgeOnly); linesController.addBodyOrComputed(this, [{ dataType: JsConnectionPointType.INT, varName: out, value: bodyLine }]); } }