Documentation
    Preparing search index...

    Function truncate

    • Clamps vector to at most maxLength, in place, and returns it.

      Shorter vectors are left bit-identical and unwritten (no round-trip through a normalize, no change hook), so truncate is a no-op exactly when it should be. A non-positive maxLength zeroes the vector: 0 because that is the limit, and negative because scaling by a negative limit would reverse the direction, which is never what a caller means.

      The common case costs one squared-length comparison and no square root.

      This is the public form of the clamp every behaviour applies. The behaviours do not call it: they clamp the scalars they are about to write, which keeps out to a single write (see the module note on allocation), and writeTruncated is that shared scalar form.

      Parameters

      Returns Vector3