UNPKG

@polygonjs/polygonjs

Version:

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

50 lines (49 loc) 2.25 kB
"use strict"; import { ParamlessTypedJsNode } from "./_Base"; import { JsConnectionPoint, JsConnectionPointType, JS_CONNECTION_POINT_IN_NODE_DEF } from "../utils/io/connections/Js"; import { Vector3 } from "three"; import { Poly } from "../../Poly"; const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF; var GetBox3PropertyJsNodeInputName = /* @__PURE__ */ ((GetBox3PropertyJsNodeInputName2) => { GetBox3PropertyJsNodeInputName2["min"] = "min"; GetBox3PropertyJsNodeInputName2["max"] = "max"; GetBox3PropertyJsNodeInputName2["center"] = "center"; return GetBox3PropertyJsNodeInputName2; })(GetBox3PropertyJsNodeInputName || {}); export class GetBox3PropertyJsNode extends ParamlessTypedJsNode { static type() { return "getBox3Property"; } initializeNode() { this.io.inputs.setNamedInputConnectionPoints([ new JsConnectionPoint(JsConnectionPointType.BOX3, JsConnectionPointType.BOX3, CONNECTION_OPTIONS) ]); this.io.outputs.setNamedOutputConnectionPoints([ new JsConnectionPoint("min" /* min */, JsConnectionPointType.VECTOR3), new JsConnectionPoint("max" /* max */, JsConnectionPointType.VECTOR3), new JsConnectionPoint("center" /* center */, JsConnectionPointType.VECTOR3) ]); } setLines(shadersCollectionController) { const usedOutputNames = this.io.outputs.used_output_names(); const box3 = this.variableForInput(shadersCollectionController, JsConnectionPointType.BOX3); const _f = (propertyName, functionName, type) => { if (!usedOutputNames.includes(propertyName)) { return; } const out = this.jsVarName(propertyName); const tmpVarName = shadersCollectionController.addVariable(this, new Vector3()); const func = Poly.namedFunctionsRegister.getFunction(functionName, this, shadersCollectionController); shadersCollectionController.addBodyOrComputed(this, [ { dataType: type, varName: out, value: func.asString(box3, tmpVarName) } ]); }; _f("min" /* min */, "getBox3Min", JsConnectionPointType.VECTOR3); _f("max" /* max */, "getBox3Max", JsConnectionPointType.VECTOR3); _f("center" /* center */, "getBox3Center", JsConnectionPointType.VECTOR3); } }