UNPKG

@polygonjs/polygonjs

Version:

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

60 lines (59 loc) 2.55 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 GetPlanePropertyJsNodeInputName = /* @__PURE__ */ ((GetPlanePropertyJsNodeInputName2) => { GetPlanePropertyJsNodeInputName2["normal"] = "normal"; GetPlanePropertyJsNodeInputName2["constant"] = "constant"; return GetPlanePropertyJsNodeInputName2; })(GetPlanePropertyJsNodeInputName || {}); export class GetPlanePropertyJsNode extends ParamlessTypedJsNode { static type() { return "getPlaneProperty"; } initializeNode() { this.io.inputs.setNamedInputConnectionPoints([ new JsConnectionPoint(JsConnectionPointType.PLANE, JsConnectionPointType.PLANE, CONNECTION_OPTIONS) ]); this.io.outputs.setNamedOutputConnectionPoints([ new JsConnectionPoint("normal" /* normal */, JsConnectionPointType.VECTOR3), new JsConnectionPoint("constant" /* constant */, JsConnectionPointType.FLOAT) ]); } setLines(shadersCollectionController) { const usedOutputNames = this.io.outputs.used_output_names(); const plane = this.variableForInput(shadersCollectionController, JsConnectionPointType.PLANE); const _v3 = (propertyName, functionName, type) => { if (!usedOutputNames.includes(propertyName)) { return; } const varName = this.jsVarName(propertyName); const tmpVarName = shadersCollectionController.addVariable(this, new Vector3()); const func = Poly.namedFunctionsRegister.getFunction(functionName, this, shadersCollectionController); shadersCollectionController.addBodyOrComputed(this, [ { dataType: type, varName, value: func.asString(plane, tmpVarName) } ]); }; const _f = (propertyName, functionName, type) => { if (!usedOutputNames.includes(propertyName)) { return; } const func = Poly.namedFunctionsRegister.getFunction(functionName, this, shadersCollectionController); shadersCollectionController.addBodyOrComputed(this, [ { dataType: type, varName: this.jsVarName(propertyName), value: func.asString(plane) } ]); }; _v3("normal" /* normal */, "getPlaneNormal", JsConnectionPointType.VECTOR3); _f("constant" /* constant */, "getPlaneConstant", JsConnectionPointType.FLOAT); } }