Skip to main content

Vector2

Vector2

Kind: global class

new Vector2([x], [y])

ParamTypeDefault
[x]number0
[y]number0

vector2.x : number

Kind: instance property of Vector2

vector2.y : number

Kind: instance property of Vector2

vector2.isVector2 : boolean

Kind: instance property of Vector2
Read only: true

vector2.writeToArray

Deprecated

Kind: instance property of Vector2

vector2.readFromArray

Deprecated

Kind: instance property of Vector2

vector2.fromArray(array, offset)

Kind: instance method of Vector2

ParamTypeDefault
arrayArray.<number> | Float32Array
offsetnumber0

vector2.toArray(array, offset)

Kind: instance method of Vector2

ParamTypeDefault
arrayArray.<number> | Float32Array
offsetnumber0

vector2.set(x, y) ⇒ Vector2

Kind: instance method of Vector2

ParamType
xnumber
ynumber

vector2.setSilent(x, y)

Kind: instance method of Vector2

ParamType
xnumber
ynumber

vector2.setX(x) ⇒ Vector2

Kind: instance method of Vector2

ParamType
xnumber

vector2.setY(y) ⇒ Vector2

Kind: instance method of Vector2

ParamType
ynumber

vector2._sub(x, y) ⇒ Vector2

Kind: instance method of Vector2

ParamType
xnumber
ynumber

vector2.sub(other) ⇒ Vector2

Kind: instance method of Vector2

ParamType
otherVector2

vector2.subVectors(a, b)

Kind: instance method of Vector2

ParamType
aVector2
bVector2

vector2.floor() ⇒ Vector2

performs Math.floor operation on x and y

Kind: instance method of Vector2

vector2.ceil() ⇒ Vector2

performs Math.ceil operation on x and y

Kind: instance method of Vector2

vector2.round()

Round both components to nearest integer

Kind: instance method of Vector2

vector2.abs() ⇒ Vector2

performs Math.abs operation on x and y

Kind: instance method of Vector2

vector2._mod(x, y) ⇒ Vector2

Kind: instance method of Vector2

ParamType
xnumber
ynumber

vector2.mod(other) ⇒ Vector2

Kind: instance method of Vector2

ParamType
otherVector2

vector2.divide(other) ⇒ Vector2

Kind: instance method of Vector2

ParamType
otherVector2

vector2.multiply(other) ⇒ Vector2

Kind: instance method of Vector2

ParamType
otherVector2

vector2._multiply(x, y) ⇒ Vector2

Kind: instance method of Vector2

ParamType
xnumber
ynumber

vector2.max(other) ⇒ Vector2

Kind: instance method of Vector2

ParamType
otherVector2

vector2.dot(other) ⇒ number

Kind: instance method of Vector2

ParamType
otherVector2

vector2.copy(other) ⇒ Vector2

Kind: instance method of Vector2

ParamType
otherVector2

vector2.clone() ⇒ Vector2

Kind: instance method of Vector2

vector2.negate() ⇒ Vector2

Kind: instance method of Vector2

vector2._add(x, y) ⇒ Vector2

Kind: instance method of Vector2

ParamType
xnumber
ynumber

vector2.add(other) ⇒ Vector2

Kind: instance method of Vector2

ParamType
otherVector2

vector2.addScalar(val)

Kind: instance method of Vector2

ParamType
valNumber

vector2.setScalar(val)

Kind: instance method of Vector2

ParamType
valnumber

vector2.divideScalar(val)

Kind: instance method of Vector2

ParamType
valnumber

vector2.multiplyScalar(val) ⇒ Vector2

Kind: instance method of Vector2

ParamType
valNumber

vector2.toBinaryBuffer(buffer)

Kind: instance method of Vector2

ParamType
bufferBinaryBuffer

vector2.fromBinaryBuffer(buffer)

Kind: instance method of Vector2

ParamType
bufferBinaryBuffer

vector2.toBinaryBufferFloat32(buffer)

Kind: instance method of Vector2

ParamType
bufferBinaryBuffer

vector2.fromBinaryBufferFloat32(buffer)

Kind: instance method of Vector2

ParamType
bufferBinaryBuffer

vector2.isZero() ⇒ boolean

Kind: instance method of Vector2

vector2.clamp(minX, minY, maxX, maxY)

Kind: instance method of Vector2

ParamType
minXNumber
minYNumber
maxXNumber
maxYNumber

vector2.clampLow(lowX, lowY)

Kind: instance method of Vector2

ParamType
lowXNumber
lowYNumber

vector2.clampHigh(highX, highY)

Kind: instance method of Vector2

ParamType
highXNumber
highYNumber

vector2.distanceSqrTo(other) ⇒ number

Kind: instance method of Vector2

ParamType
otherVector2

vector2._distanceSqrTo(x, y) ⇒ number

Kind: instance method of Vector2

ParamType
xnumber
ynumber

vector2.lerpVectors(a, b, fraction)

Kind: instance method of Vector2

ParamType
aVector2
bVector2
fractionnumber

vector2.applyMatrix3(matrix3)

Kind: instance method of Vector2

ParamType
matrix3Array.<number>

vector2.distanceTo(other) ⇒ number

Kind: instance method of Vector2

ParamType
otherVector2

vector2._distanceTo(x, y) ⇒ number

Kind: instance method of Vector2

ParamType
xnumber
ynumber

vector2.manhattanDistanceTo(other) ⇒ number

Kind: instance method of Vector2

ParamType
otherVector2

vector2.length() ⇒ number

Kind: instance method of Vector2

vector2.normalize()

Normalizes the vector, preserving its direction, but making magnitude equal to 1

Kind: instance method of Vector2

vector2.hash() ⇒ number

Kind: instance method of Vector2

vector2.rotate(angle)

Rotation is counter-clockwise

Kind: instance method of Vector2

ParamTypeDescription
anglenumberin radians

vector2.process(processor, [thisArg]) ⇒ Vector2

Kind: instance method of Vector2

ParamType
processorfunction
[thisArg]*

vector2.equals(other) ⇒ boolean

Kind: instance method of Vector2

ParamType
otherVector2

vector2.roughlyEquals(other, [tolerance]) ⇒ boolean

Kind: instance method of Vector2

ParamType
otherVector2
[tolerance]number

vector2._roughlyEquals(x, y, [tolerance]) ⇒ boolean

Kind: instance method of Vector2

ParamTypeDescription
xnumber
ynumber
[tolerance]numberacceptable deviation

Vector2.up : Vector2

Kind: static property of Vector2
Read only: true

Vector2.down : Vector2

Kind: static property of Vector2
Read only: true

Vector2.left : Vector2

Kind: static property of Vector2
Read only: true

Vector2.right : Vector2

Kind: static property of Vector2
Read only: true

Vector2.zero : Vector2

Kind: static property of Vector2
Read only: true

Vector2.one : Vector2

Kind: static property of Vector2
Read only: true