UNPKG

@polygonjs/polygonjs

Version:

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

59 lines (58 loc) 2.5 kB
"use strict"; import { TypedJsNode } from "./_Base"; import { NodeParamsConfig } from "../utils/params/ParamsConfig"; import { JS_CONNECTION_POINT_IN_NODE_DEF, JsConnectionPoint, JsConnectionPointType } from "../utils/io/connections/Js"; import { inputObject3D, setObject3DOutputLine } from "./_BaseObject3D"; import { Poly } from "../../Poly"; import { VectorArray } from "./code/assemblers/_BaseJsPersistedConfigUtils"; import { Vector3 } from "three"; const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF; export const GetGeometryPositionsInputName = { [JsConnectionPointType.OBJECT_3D]: JsConnectionPointType.OBJECT_3D }; var GetGeometryPositionsOutputName = /* @__PURE__ */ ((GetGeometryPositionsOutputName2) => { GetGeometryPositionsOutputName2["P"] = "positions"; return GetGeometryPositionsOutputName2; })(GetGeometryPositionsOutputName || {}); class GetGeometryPositionsJsParamsConfig extends NodeParamsConfig { } const ParamsConfig = new GetGeometryPositionsJsParamsConfig(); export class GetGeometryPositionsJsNode extends TypedJsNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return "getGeometryPositions"; } initializeNode() { this.io.inputs.setNamedInputConnectionPoints([ new JsConnectionPoint(JsConnectionPointType.OBJECT_3D, JsConnectionPointType.OBJECT_3D, CONNECTION_OPTIONS) ]); this.io.outputs.setNamedOutputConnectionPoints([ new JsConnectionPoint(JsConnectionPointType.OBJECT_3D, JsConnectionPointType.OBJECT_3D), new JsConnectionPoint("positions" /* P */, JsConnectionPointType.VECTOR3_ARRAY) ]); } setLines(linesController) { setObject3DOutputLine(this, linesController); const usedOutputNames = this.io.outputs.used_output_names(); const object3D = inputObject3D(this, linesController); const _v3 = (propertyName, functionName, type) => { if (!usedOutputNames.includes(propertyName)) { return; } const varName = this.jsVarName(propertyName); const tmpVarName = linesController.addVariable(this, new VectorArray([new Vector3()])); const func = Poly.namedFunctionsRegister.getFunction(functionName, this, linesController); linesController.addBodyOrComputed(this, [ { dataType: type, varName, value: func.asString(object3D, tmpVarName) } ]); }; _v3("positions" /* P */, "getGeometryPositions", JsConnectionPointType.VECTOR3_ARRAY); } }