Lens Scripting API

    This is a random number generator that allows you to set the seed used, for generating consistent random values between runs. It is implemented as a linear congruential generator, which is fast but not very random.

    NOTE: The seed you pass needs to be an Integer

    See: https://en.wikipedia.org/wiki/Linear_congruential_generator

    Index

    Constructors

    Properties

    seed: number

    Methods

    • Returns an Array of random numbers within a specified range (no duplicates).

      Parameters

      • rangeMin: number

        The minimum value of the range (inclusive).

      • rangeMax: number

        The maximum value of the range (exclusive).

      • numRandomNumbers: number

        The number of random numbers to generate.

      Returns number[]

      An Array of random numbers within the specified range.

      Will throw an error if rangeMin >= rangeMax.

      Will throw an error if numRandomNumbers > rangeMax - rangeMin.

    • Returns a random integer between 0 and 2^32

      Returns number

      A random integer between 0 and 2^32

    • Generate an integer in the given range.

      Parameters

      • start: number

        The lowest value in the range. If this is a decimal, the start of the range will be the floor of the value.

      • end: number

        The highest value in the range. If this is a decimal, the end of the range will be the floor of the value.

      Returns () => number

      A function that, when called, returns an integer within the given range.

    • Generates a random point within an Axis-Aligned Bounding Box (AABB). An AABB is a rectangular box specified by providing the minimum and maximum x, y, and z coordinates.

      Parameters

      • minPoint: vec3

        The minimum point of the AABB.

      • maxPoint: vec3

        The maximum point of the AABB.

      Returns vec3

      A randomly generated point within the specified AABB, where minPoint.x <= x <= maxPont.x etc.

      Will throw an error if any component of minPoint is greater than the corresponding component of maxPoint.

    • Generates a random quaternion. The resulting quaternion is of unit length and its components range between -1 and 1.

      Returns quat

      A randomly generated quaternion of unit length.

    • Generate a floating-point number in the given range

      Parameters

      • start: number

        The lowest value in the range.

      • end: number

        The highest value in the range.

      Returns () => number

      A function that, when called, returns a number within the given range.

    MMNEPVFCICPMFPCPTTAAATR