UNPKG

@polygonjs/polygonjs

Version:

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

59 lines (58 loc) 2.05 kB
"use strict"; import { Poly } from "../../Poly"; import { JsConnectionPointType, JsConnectionPointTypeFromArrayTypeMap } from "../utils/io/connections/Js"; import { MathFunctionArg3OperationFactory, DEFAULT_ALLOWED_TYPES } from "./_Math_Arg1Operation"; export var SmootherstepInput = /* @__PURE__ */ ((SmootherstepInput2) => { SmootherstepInput2["X"] = "x"; SmootherstepInput2["EDGE0"] = "edge0"; SmootherstepInput2["EDGE1"] = "edge1"; return SmootherstepInput2; })(SmootherstepInput || {}); const DefaultValues = { ["x" /* X */]: 0, ["edge0" /* EDGE0 */]: 0, ["edge1" /* EDGE1 */]: 1 }; const FUNCTION_NAME = "smootherstep"; export class SmootherstepJsNode extends MathFunctionArg3OperationFactory("smootherstep", { inputPrefix: "in", out: "smootherstep" }) { _coreFunction(shadersCollectionController) { const mainArg = "x"; const _min = this.variableForInput(shadersCollectionController, "edge0" /* EDGE0 */); const _max = this.variableForInput(shadersCollectionController, "edge1" /* EDGE1 */); Poly.namedFunctionsRegister.getFunction(FUNCTION_NAME, this, shadersCollectionController).asString(mainArg, _min, _max); return FUNCTION_NAME; } paramDefaultValue(name) { return DefaultValues[name]; } _expectedInputName(index) { return ["x" /* X */, "edge0" /* EDGE0 */, "edge1" /* EDGE1 */][index]; } _expectedInputTypes() { let first_input_type = this.io.connection_points.first_input_connection_type(); const inputConnectionPoints = this.io.inputs.namedInputConnectionPoints(); if (!inputConnectionPoints) { return []; } if (first_input_type) { if (!DEFAULT_ALLOWED_TYPES.includes(first_input_type)) { const first_connection = inputConnectionPoints[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]; } }