UNPKG

@polygonjs/polygonjs

Version:

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

58 lines (57 loc) 2.02 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 SmoothstepInput = /* @__PURE__ */ ((SmoothstepInput2) => { SmoothstepInput2["X"] = "x"; SmoothstepInput2["EDGE0"] = "edge0"; SmoothstepInput2["EDGE1"] = "edge1"; return SmoothstepInput2; })(SmoothstepInput || {}); const DefaultValues = { ["x" /* X */]: 0, ["edge0" /* EDGE0 */]: 0, ["edge1" /* EDGE1 */]: 1 }; const FUNCTION_NAME = "smoothstep"; export class SmoothstepJsNode extends MathFunctionArg3OperationFactory("smoothstep", { inputPrefix: "in", out: "smoothstep" }) { _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(); if (first_input_type) { if (!DEFAULT_ALLOWED_TYPES.includes(first_input_type)) { const connectionPoints = this.io.inputs.namedInputConnectionPoints(); if (connectionPoints) { 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]; } }