Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Vector2

Implements

Index

Constructors

constructor

Properties

Protected _values

_values: Float32Array = ...

Accessors

x

  • get x(): number
  • set x(value: number): void

xy

  • get xy(): XY
  • set xy(values: XY): void
  • Returns XY

    • An array containing the x-component and y-component of the vector
  • Parameters

    • values: XY

      An array containing the new x-component and y-component of the vector

    Returns void

    • An array containing the x-component and y-component of the vector

y

  • get y(): number
  • set y(value: number): void

Static zero

Methods

abs

add

at

  • at(index: number): number

copyFrom

copyTo

  • copyTo<T>(p: T): T
  • Copies the x and y components from the source to the destination. The source and destination must be of the same type.

    Type parameters

    • T: IPointData

      The type of your source, can also be a Vector2.

    Parameters

    • p: T

      The source point.

    Returns T

deepClone

  • Returns a deep clone this Vector. If no dest vector is specified, the operation is performed in-place.

    Parameters

    • Optional dest: Vector2

      An optional destination Vector2.

    Returns Vector2

    • The resulting deep clone.

divide

equals

  • equals(other: Vector2, threshold?: number): boolean

greaterThan

  • greaterThan(other: Vector2): boolean

length

  • length(): number

multiply

negate

  • Multiplies both the x- and y-components of a vector by -1. If no dest vector is specified, the operation is performed in-place.

    Parameters

    • Optional dest: Vector2

      An optional destination Vector2.

    Returns Vector2

normalize

reset

  • reset(): void

scale

  • Scales a vector by a scalar parameter. If no dest vector is specified, the operation is performed in-place.

    Parameters

    • value: number
    • Optional dest: Vector2

      An optional destination Vector2.

    Returns Vector2

set

squaredLength

  • squaredLength(): number

subtract

toJSON

  • toJSON(): { x: number; y: number }

toObservable

  • Convert this Vector to an ObservableVector2.

    Type parameters

    • T = any

    Parameters

    • callback: () => any

      Callback of the observableVector2.

        • (): any
        • Returns any

    • scope: T

      Scope of the ObservableVector2.

    Returns ObservableVector2<T>

    • An ObservableVector2.

toString

  • toString(): string

Static difference

Static direction

  • Calculates a normalized vector representing the direction from one vector to another. If no dest vector is specified, a new vector is instantiated.

    Parameters

    Returns Vector2

Static distance

Static dot

Static lerp

Static max

Static min

Static product

Static quotient

Static squaredDistance

Static sum

Generated using TypeDoc