rhodonite
    Preparing search index...

    Class Scalar

    Immutable scalar class using 32-bit floating-point precision. Represents a single floating-point value with various utility methods for mathematical operations and format conversions.

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    _v: TypedArray = ...

    Internal typed array storage for vector components

    Accessors

    • get bytesPerComponent(): number

      Gets the number of bytes per component in the underlying typed array.

      Returns number

      The number of bytes per element

    • get glslStrAsFloat(): string

      Gets the scalar value as a GLSL-compatible float string.

      Returns string

      The scalar value formatted as a GLSL float literal

    • get glslStrAsInt(): string

      Gets the scalar value as a GLSL-compatible integer string.

      Returns string

      The scalar value formatted as a GLSL integer literal

    • get glslStrAsUint(): string

      Gets the scalar value as a GLSL-compatible unsigned integer string.

      Returns string

      The scalar value formatted as a GLSL unsigned integer literal with 'u' suffix

    • get wgslStrAsFloat(): string

      Gets the scalar value as a WGSL-compatible float string.

      Returns string

      The scalar value formatted as a WGSL float literal

    • get wgslStrAsInt(): string

      Gets the scalar value as a WGSL-compatible integer string.

      Returns string

      The scalar value formatted as a WGSL integer literal

    • get wgslStrAsUint(): string

      Gets the scalar value as a WGSL-compatible unsigned integer string.

      Returns string

      The scalar value formatted as a WGSL unsigned integer literal with 'u' suffix

    • get x(): number

      Gets the scalar value (alias for x component).

      Returns number

      The scalar value

    Methods

    • Gets the component value at the specified index.

      Parameters

      • i: number

        The index of the component to retrieve

      Returns number

      The component value at the given index

    • Performs approximate equality comparison with another scalar within a tolerance.

      Parameters

      • scalar: Scalar_<Float32ArrayConstructor>

        The scalar to compare with

      • delta: number = Number.EPSILON

        The tolerance for comparison (default: Number.EPSILON)

      Returns boolean

      True if the scalars are equal within the specified tolerance

    • Performs strict equality comparison with another scalar. Uses exact floating-point comparison without tolerance.

      Parameters

      • scalar: Scalar_<Float32ArrayConstructor>

        The scalar to compare with

      Returns boolean

      True if the scalars are exactly equal, false otherwise

    • Checks if the internal storage shares the same ArrayBuffer as the provided one. Useful for determining if vectors share underlying memory.

      Parameters

      • arrayBuffer: ArrayBuffer

        The ArrayBuffer to compare against

      Returns boolean

      True if the same ArrayBuffer is used, false otherwise

    • Gets the component value at the specified index. Alias for the at() method for convenience.

      Parameters

      • i: number

        The index of the component to retrieve

      Returns number

      The component value at the given index

    • Creates a new scalar from a numeric value.

      Parameters

      • value: number

        The numeric value to create the scalar from

      Returns Scalar

      A new Scalar instance