UNPKG

@polygonjs/polygonjs

Version:

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

56 lines (55 loc) 2.03 kB
"use strict"; import { Poly } from "../../Poly"; import { _vectorFunctionName_3vvf } from "../../functions/_MathGeneric"; import { JsConnectionPointType, JsConnectionPointTypeFromArrayTypeMap } from "../utils/io/connections/Js"; import { MathFunctionArg3OperationFactory, DEFAULT_ALLOWED_TYPES } from "./_Math_Arg1Operation"; var MixInput = /* @__PURE__ */ ((MixInput2) => { MixInput2["value0"] = "value0"; MixInput2["value1"] = "value1"; MixInput2["blend"] = "blend"; return MixInput2; })(MixInput || {}); const DefaultValues = { ["value0" /* value0 */]: 0, ["value1" /* value1 */]: 1, ["blend" /* blend */]: 0.5 }; const FUNCTION_NAME = "mix"; export class MixJsNode extends MathFunctionArg3OperationFactory("mix", { inputPrefix: "in", out: "mix" }) { _coreFunction(shadersCollectionController) { Poly.namedFunctionsRegister.getFunction(FUNCTION_NAME, this, shadersCollectionController).asString("", "", ""); return FUNCTION_NAME; } _functionData() { return { vectorFunctionNameFunction: _vectorFunctionName_3vvf, mathFloat: "mathFloat_3", mathPrimArray: "mathPrimArray_3", mathVectorArray: "mathVectorArray_3" }; } paramDefaultValue(name) { return DefaultValues[name]; } _expectedInputName(index) { return ["value0" /* value0 */, "value1" /* value1 */, "blend" /* blend */][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, JsConnectionPointType.FLOAT]; } }