Options
All
  • Public
  • Public/Protected
  • All
Menu

Class representing a vector containing 2 coordinates Example Playground - Overview - https://playground.babylonjs.com/#QYBWV4#9

Hierarchy

Index

Constructors

  • new Vector2(x?: number, y?: number): Vector2
  • Creates a new Vector2 from the given x and y coordinates

    Parameters

    • Optional x: number

      defines the first coordinate

    • Optional y: number

      defines the second coordinate

    Returns Vector2

Properties

x: number

defines the first coordinate

y: number

defines the second coordinate

Accessors

Methods

  • Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates Example Playground https://playground.babylonjs.com/#QYBWV4#14

    Parameters

    • otherVector: Vector3

      defines the other vector

    Returns Vector2

    a new Vector2

  • asArray(): number[]
  • copyFromFloats(x: number, y: number): Vector2
  • Sets the Vector2 coordinates with the given floats Example Playground https://playground.babylonjs.com/#QYBWV4#25

    Parameters

    • x: number

      defines the first coordinate

    • y: number

      defines the second coordinate

    Returns Vector2

    the current updated Vector2

  • Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates Example Playground https://playground.babylonjs.com/#QYBWV4#27

    Parameters

    • otherVector: Vector2

      defines the other vector

    Returns Vector2

    a new Vector2

  • Gets a boolean if two vectors are equals (using an epsilon value) Example Playground https://playground.babylonjs.com/#QYBWV4#32

    Parameters

    • otherVector: DeepImmutableObject<Vector2>

      defines the other vector

    • Optional epsilon: number

      defines the minimal distance to consider equality

    Returns boolean

    true if the given vector coordinates are close to the current ones by a distance of epsilon.

  • Update the current vector from an array Example Playground https://playground.babylonjs.com/#QYBWV4#39

    Parameters

    • array: FloatArray

      defines the destination array

    • Optional index: number

      defines the offset in the destination array

    Returns Vector2

    the current Vector2

  • getClassName(): string
  • Gets class name

    Returns string

    the string "Vector2"

  • getHashCode(): number
  • Gets current vector hash code

    Returns number

    the Vector2 hash code as a number

  • length(): number
  • Gets the length of the vector

    Returns number

    the vector length (float)

  • lengthSquared(): number
  • Gets the vector squared length

    Returns number

    the vector squared length (float)

  • multiplyByFloats(x: number, y: number): Vector2
  • Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats Example Playground https://playground.babylonjs.com/#QYBWV4#89

    Parameters

    • x: number

      defines the first coordinate

    • y: number

      defines the second coordinate

    Returns Vector2

    a new Vector2

  • Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates Example Playground https://playground.babylonjs.com/#QYBWV4#44

    Type Parameters

    Parameters

    Returns T

    result input

  • negateToRef<T>(result: T): T
  • Negate the current Vector2 and stores the result in the given vector "result" coordinates Example Playground https://playground.babylonjs.com/#QYBWV4#41

    Type Parameters

    Parameters

    • result: T

      defines the Vector3 object where to store the result

    Returns T

    the result

  • rotateToRef<T>(angle: number, result: T): T
  • Rotate the current vector into a given result vector Example Playground https://playground.babylonjs.com/#QYBWV4#49

    Type Parameters

    Parameters

    • angle: number

      defines the rotation angle

    • result: T

      defines the result vector where to store the rotated vector

    Returns T

    result input

  • Returns a new Vector2 scaled by "scale" from the current Vector2 Example Playground https://playground.babylonjs.com/#QYBWV4#52

    Parameters

    • scale: number

      defines the scaling factor

    Returns Vector2

    a new Vector2

  • scaleAndAddToRef<T>(scale: number, result: T): T
  • Scale the current Vector2 values by a factor and add the result to a given Vector2 Example Playground https://playground.babylonjs.com/#QYBWV4#58

    Type Parameters

    Parameters

    • scale: number

      defines the scale factor

    • result: T

      defines the Vector2 object where to store the result

    Returns T

    result input

  • scaleInPlace(scale: number): Vector2
  • scaleToRef<T>(scale: number, result: T): T
  • Scale the current Vector2 values by a factor to a given Vector2 Example Playground https://playground.babylonjs.com/#QYBWV4#57

    Type Parameters

    Parameters

    • scale: number

      defines the scale factor

    • result: T

      defines the Vector2 object where to store the result

    Returns T

    result input

  • Sets the Vector2 coordinates with the given floats Example Playground https://playground.babylonjs.com/#QYBWV4#62

    Parameters

    • x: number

      defines the first coordinate

    • y: number

      defines the second coordinate

    Returns Vector2

    the current updated Vector2

  • Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2 Example Playground https://playground.babylonjs.com/#QYBWV4#61

    Parameters

    • otherVector: Vector2

      defines the other vector

    Returns Vector2

    a new Vector2

  • Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates. Example Playground https://playground.babylonjs.com/#QYBWV4#63

    Type Parameters

    Parameters

    Returns T

    result input

  • Sets the Vector2 coordinates in the given array or Float32Array from the given index. Example Playground https://playground.babylonjs.com/#QYBWV4#15

    Parameters

    • array: FloatArray

      defines the source array

    • Optional index: number

      defines the offset in source array

    Returns Vector2

    the current Vector2

  • toString(): string
  • Gets a string with the Vector2 coordinates

    Returns string

    a string with the Vector2 coordinates

  • Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max". If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate. If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate Example Playground https://playground.babylonjs.com/#QYBWV4#76

    Type Parameters

    Parameters

    Returns T

    a new Vector2

  • Gets a new Vector2 set from the given index element of the given array Example Playground https://playground.babylonjs.com/#QYBWV4#79

    Parameters

    • array: DeepImmutableObject<ArrayLike<number>>

      defines the data source

    • Optional offset: number

      defines the offset in the data source

    Returns Vector2

    a new Vector2

  • Sets "result" from the given index element of the given array Example Playground https://playground.babylonjs.com/#QYBWV4#80

    Type Parameters

    Parameters

    • array: DeepImmutableObject<ArrayLike<number>>

      defines the data source

    • offset: number

      defines the offset in the data source

    • result: T

      defines the target vector

    Returns T

    result input

  • Gets a new Vector2(1, 1)

    Returns Vector2

    a new Vector2

  • Random(min?: number, max?: number): Vector2
  • Returns a new Vector2 with random values between min and max

    Parameters

    • Optional min: number

      the minimum random value

    • Optional max: number

      the maximum random value

    Returns Vector2

    a Vector2 with random values between min and max

  • Gets a new Vector2(0, 0)

    Returns Vector2

    a new Vector2

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Method
  • Static method

Settings

Theme