Skip to main content

ParticleRng

Struct ParticleRng 

Source
pub struct ParticleRng { /* private fields */ }
Expand description

A deterministic xorshift64* pseudo-random generator used by particle emitters.

The engine intentionally avoids both the rand crate (dependency weight for a wasm target) and js_sys::Math::random (non-deterministic, and unusable outside a JS runtime, which would make host-side unit tests impossible). A seeded generator keeps emitter behavior reproducible.

Implementations§

Source§

impl ParticleRng

Implements deterministic pseudo-random number generation for ParticleRng.

Source

pub fn with_seed(seed: u64) -> ParticleRng

Creates a generator from the given seed. A zero seed is replaced with the default seed, since xorshift degenerates at zero.

§Arguments
  • u64 - The seed value.
§Returns
  • ParticleRng - The seeded generator.
Source

pub fn next_u64(&mut self) -> u64

Advances the generator and returns the next 64-bit value.

§Returns
  • u64 - The next pseudo-random value.
Source

pub fn next_f64(&mut self) -> f64

Returns the next pseudo-random value uniformly distributed in [0.0, 1.0).

§Returns
  • f64 - The next value in the unit interval.
Source

pub fn range(&mut self, min: f64, max: f64) -> f64

Returns the next pseudo-random value uniformly distributed in [min, max).

§Arguments
  • f64 - The inclusive lower bound.
  • f64 - The exclusive upper bound.
§Returns
  • f64 - The next value in the given range.
Source§

impl ParticleRng

Source

pub fn new(state: u64) -> Self

Trait Implementations§

Source§

impl Clone for ParticleRng

Source§

fn clone(&self) -> ParticleRng

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ParticleRng

Source§

impl Debug for ParticleRng

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ParticleRng

Implements Default for ParticleRng using the default seed.

Source§

fn default() -> ParticleRng

Returns the “default value” for a type. Read more
Source§

impl PartialEq for ParticleRng

Source§

fn eq(&self, other: &ParticleRng) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for ParticleRng

Source§

fn partial_cmp(&self, other: &ParticleRng) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for ParticleRng

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more