random

These deterministic random utils made available in the scene cope are primed with the seed value set in the retrace editor. Thus, using the same seed while using these functions will produce the same "random" result. Perfect for generative work as you can easily recreate a generated result. An instance of simplex-noise.js, primed with the scene seed, is also available. See example below
Properties:
Name Type Description
simplex Object The simplex js object
Source:
Example
simplex.noise3D(4, 6, 1); // 0.10787818930041222

Methods

(static) maybe(cb, p)

Maybe run a function given a probability value. Determinstic based on the scenes random seed.
Parameters:
Name Type Description
cb function The callback to run
p number Probability that the function will be run (0 - 1).
Source:

(static) pluckRandom(arr) → {any}

Pluck a value from a given array, randomly. Determinstic based on the scenes random seed.
Parameters:
Name Type Description
arr array The array
Source:

(static) random(…limit) → {number}

Return a random float value within a given range. Determinstic based on the scenes random seed.
Parameters:
Name Type Attributes Description
limit number <repeatable>
One argument for a random value in the range [0, limit], two arguments for the range [limit1, limit2].
Source:
Example
random(10); // 2.749887186359643
random(5, 10); // 9.724547372363647

(static) randomBool() → {bool}

Return true or false, randomly. Determinstic based on the scenes random seed.
Source:

(static) randomInt(…limit) → {number}

Return a random integer value within a given range. Determinstic based on the scenes random seed.
Parameters:
Name Type Attributes Description
limit number <repeatable>
One argument for a random value in the range [0, limit], two arguments for the range [limit1, limit2].
Source:
Example
random(10); // 2
random(5, 10); // 9

(static) randomSign() → {integer}

Return 1 or -1, randomly. Determinstic based on the scenes random seed.
Source:

(static) takeRandom(arr, n) → {any}

Pluck n values from a given array, randomly. Determinstic based on the scenes random seed.
Parameters:
Name Type Description
arr array The array
n number Number of elements
Source: