BB.Vector2

Defined in: src/BB.Vector2.js:13

A vector in 2 dimensional space. A direct copy of Three.js's THREE.Vector2 class.

Constructor

BB.Vector2
(
  • x
  • y
)

Parameters:

  • x Number

    Represents the x value of the vector

  • y Number

    Represents the y value of the vector

Properties

x Unknown

This vector's x value

y Unknown

This vector's y value

There are no properties that match your current filter settings. You can change your filter settings in the index section on this page. index

Methods

add
(
  • v
)
BB.Vector2 chainable

Adds vector v to this vector.

Parameters:

Returns: BB.Vector2

this vector.

addScalar
(
  • s
)
BB.Vector2 chainable

Add the scalar value s to this vector's x and y values.

Parameters:

  • s Number

    Scalar to add vector with.

Returns: BB.Vector2

this vector.

addVectors
(
  • a
  • b
)
BB.Vector2 chainable

Sets this vector to a + b.

Parameters:

Returns: BB.Vector2

This vector.

ceil () BB.Vector2 chainable

The components of the vector are rounded upwards (towards positive infinity) to an integer value.

Returns: BB.Vector2

This vector.

clamp
(
  • min
  • max
)
BB.Vector2 chainable

If this vector's x or y value is greater than the max vector's x or y value, it is replaced by the corresponding value. If this vector's x or y value is less than the min vector's x or y value, it is replace by the corresponding value. Note: This function assumes min < max, if this assumption isn't true it will not operate correctly

Parameters:

  • min BB.Vector2

    The vector containing the min x and y values in the desired range.

  • max BB.Vector2

    The vector containing the max x and y values in the desired range.

Returns: BB.Vector2

This vector.

clampScalar
(
  • min
  • max
)
BB.Vector2 chainable

If this vector's x or y values are greater than the max value, they are replaced by the max value. If this vector's x or y values are less than the min value, they are replace by the min value.

Parameters:

  • min Number

    the minimum value the components will be clamped to.

  • max Number

    the minimum value the components will be clamped to.

Returns: BB.Vector2

This vector.

clone () BB.Vector2

Clones this vector.

Returns: BB.Vector2

A new vector with this vectors x and y values.

copy
(
  • v
)
BB.Vector2 chainable

Copies value of v to this vector. Note: Does not return a copy of this vector.

Parameters:

Returns: BB.Vector2

This vector.

distanceTo
(
  • v
)
Number

Computes distance of this vector to v.

Parameters:

Returns: Number

Distance from this vector to v.

distanceToSquared
(
  • v
)
Number

Computes squared distance of this vector to v.

Parameters:

Returns: Number

Squared distance from this vector to v.

divide
(
  • v
)
BB.Vector2 chainable

Divides this vector by v.

Parameters:

  • v BB.Vector2

    The vector to subtract from this vector

Returns: BB.Vector2

this vector.

divideScalar
(
  • s
)
BB.Vector2

Divides this vector by scalar s.

Parameters:

  • s Number

    The scalar to divide this vector by.

Returns: BB.Vector2

This vector.

dot
(
  • v
)
Number

Computes dot product of this vector and v.

Parameters:

Returns: Number

The dot product of this vector and v.

equals
(
  • v
)
Boolean

Checks for strict equality of this vector and v.

Parameters:

  • v BB.Vector2

    The vector to check equality against.

Returns: Boolean

Boolean:

floor () BB.Vector2 chainable

The components of the vector are rounded downwards (towards negative infinity) to an integer value.

Returns: BB.Vector2

This vector.

fromArray
(
  • array
)
BB.Vector2 chainable

Sets this vector's x value to be array[0] and y value to be array[1].

Parameters:

  • array type

    Array of length 2.

Returns: BB.Vector2

This vector.

getComponent
(
  • index
)
Number

Get this vector's x and y values by index (0 and 1 respectively). If index equals 0 method returns vector's x value. If index equals 1 method returns vector's y value.

Parameters:

  • index type

    0 or 1

Returns: Number

Vector's x or y dependent on index

length () Number

Computes the length of this vector.

Returns: Number

The length of this vector.

lengthSq () Number

Computes squared length of this vector.

Returns: Number

The squared length of this vector.

lerp
(
  • v
  • alpha
)
BB.Vector2 chainable

Linear interpolation between this vector and v, where alpha is the percent along the line.

Parameters:

  • v BB.Vector2

    The vector to lerp this vector with.

  • alpha Number

    Percentage along the line (0 - 1).

Returns: BB.Vector2

This vector.

lerpVectors
(
  • v1
  • v2
  • alpha
)
BB.Vector2 chainable

Sets this vector to be the vector linearly interpolated between v1 and v2 with alpha factor.

Parameters:

  • v1 BB.Vector2

    The first vector.

  • v2 BB.Vector2

    The second vector.

  • alpha Number

    Percentage along the line (0 - 1).

Returns: BB.Vector2

This vector.

max
(
  • v
)
BB.Vector2 chainable

If this vector's x or y value is less than v's x or y value, replace that value with the corresponding min value.

Parameters:

  • v BB.Vector2

    The vector to check and assign max values from

Returns: BB.Vector2

This vector.

min
(
  • v
)
BB.Vector2 chainable

If this vector's x or y value is less than v's x or y value, replace that value with the corresponding min value.

Parameters:

  • v BB.Vector2

    The vector to check and assign min values from

Returns: BB.Vector2

This vector.

multiply
(
  • v
)
BB.Vector2 chainable

Multiplies this vector by v.

Parameters:

  • v BB.Vector2

    The vector to subtract from this vector

Returns: BB.Vector2

this vector.

mutliplyScalar
(
  • s
)
BB.Vector2

Multiplies this vector by scalar s.

Parameters:

  • s Number

    The scalar to multiply this vector by.

Returns: BB.Vector2

This vector.

negate () BB.Vector2 chainable

Inverts this vector.

Returns: BB.Vector2

this vector.

normalize () BB.Vector2 chainable

Normalizes this vector.

Returns: BB.Vector2

This vector.

round () BB.Vector2 chainable

The components of the vector are rounded towards the nearest integer value.

Returns: BB.Vector2

This vector.

roundToZero () BB.Vector2 chainable

The components of the vector are rounded towards zero (up if negative, down if positive) to an integer value.

Returns: BB.Vector2

This vector.

set
(
  • x
  • y
)
BB.Vector2 chainable

Sets value of this vector.

Parameters:

  • x Number

    Represents the x value of the vector

  • y Number

    Represents the y value of the vector

Returns: BB.Vector2

this vector.

setComponent
(
  • index
  • value
)

Sets this vector's x and y values by index (0 and 1 respectively). If index equals 0 method replaces this.x with value. If index equals 1 method replaces this.y with value.

Parameters:

  • index Number

    0 or 1

  • value Number

    Value to be assigned to corresponding index

setLength
(
  • l
)
BB.Vector2 chainable

Normalizes this vector and multiplies it by l.

Parameters:

  • l Number

    The new length of the vector.

Returns: BB.Vector2

This vector.

setX
(
  • x
)
BB.Vector2 chainable

Replace this vector's x value with x.

Parameters:

  • x Number

    Represents the x value of the vector.

Returns: BB.Vector2

this vector.

setY
(
  • y
)
BB.Vector2 chainable

Replace this vector's y value with y.

Parameters:

  • y Number

    Represents the y value of the vector.

Returns: BB.Vector2

this vector.

sub
(
  • v
)
BB.Vector2 chainable

Subtracts vector v from this vector.

Parameters:

  • v BB.Vector2

    The vector to subtract from this vector

Returns: BB.Vector2

this vector.

subScalar
(
  • s
)
BB.Vector2 chainable

Subtracts the scalar value s from this vector's x and y values.

Parameters:

  • s Number

    Scalar to subract vector by.

Returns: BB.Vector2

this vector.

subVectors
(
  • a
  • b
)
BB.Vector2 chainable

Sets this vector to a - b.

Parameters:

Returns: BB.Vector2

This vector.

toArray
(
  • [array]
)
Array

Returns an array [x, y].

Parameters:

  • [array] Array optional

    Optional array that will be filled if provided.

Returns: Array

Array [x, y].

There are no methods that match your current filter settings. You can change your filter settings in the index section on this page. index