• Returns an expression that limits an operand to a range. The type of the bounds should be the same.

      var _ = ExpressionFactory;
    //Evaluates to 47.
    var number = _.clamp(_.number(42), _.number(47), _.number(83));
    //Evaluates to a point with values clamped between 47 and 83.
    var clamped = _.clamp(_.point(p1), _.number(47), _.number(83));
    //Evaluates to a point with values of p1 clamped between p2 and p3.
    var elementsIndividuallyClamped = _.clamp(_.point(p1), _.point(p2), _.point(p3));

    Type Parameters

    • T extends string | number | Vector3

    Parameters

    • operand: Expression<T>

      The operand to evaluate. Should result in a number, point or color.

    • lowerBound: Expression<number | T>

      The lowerBound to evaluate. Should result in the same type as operand or a number.

    • upperBound: Expression<number | T>

      The upperBound to evaluate. Should result in the same type as lowerBound.

    Returns Expression<T>

    An expression that limits a value to the given range. Results in a number, point or color depending on the type of the operands. When a number is used with an other type, the operation is applied to the individual element values and the result is of the other type.