@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
49 lines (48 loc) • 1.87 kB
JavaScript
;
import { Poly } from "../../Poly";
import { JsConnectionPointType, JsConnectionPointTypeFromArrayTypeMap } from "../utils/io/connections/Js";
import { MathFunctionArg4OperationFactory, DEFAULT_ALLOWED_TYPES } from "./_Math_Arg1Operation";
export var MultAddInput = /* @__PURE__ */ ((MultAddInput2) => {
MultAddInput2["VALUE"] = "value";
MultAddInput2["PRE_ADD"] = "preAdd";
MultAddInput2["MULT"] = "mult";
MultAddInput2["POST_ADD"] = "postAdd";
return MultAddInput2;
})(MultAddInput || {});
const DefaultValues = {
["value" /* VALUE */]: 0,
["preAdd" /* PRE_ADD */]: 0,
["mult" /* MULT */]: 1,
["postAdd" /* POST_ADD */]: 0
};
const FUNCTION_NAME = "multAdd";
export class MultAddJsNode extends MathFunctionArg4OperationFactory("multAdd", {
inputPrefix: "in",
out: "val"
}) {
_coreFunction(shadersCollectionController) {
Poly.namedFunctionsRegister.getFunction(FUNCTION_NAME, this, shadersCollectionController).asString("", "", "", "");
return FUNCTION_NAME;
}
paramDefaultValue(name) {
return DefaultValues[name];
}
_expectedInputName(index) {
return ["value" /* VALUE */, "preAdd" /* PRE_ADD */, "mult" /* MULT */, "postAdd" /* POST_ADD */][index];
}
_expectedInputTypes() {
let first_input_type = this.io.connection_points.first_input_connection_type();
const connectionPoints = this.io.inputs.namedInputConnectionPoints();
if (first_input_type && connectionPoints) {
if (!DEFAULT_ALLOWED_TYPES.includes(first_input_type)) {
const first_connection = connectionPoints[0];
if (first_connection) {
first_input_type = first_connection.type();
}
}
}
const type = first_input_type || JsConnectionPointType.FLOAT;
const boundType = JsConnectionPointTypeFromArrayTypeMap[type];
return [type, boundType, boundType, boundType];
}
}