@immugio/three-math-extensions / Exports / Vec2
Vec2 represents a 2D vector. It extends Vector2
from the threejs
library.
-
Vector2
↳
Vec2
- addX
- addY
- in3DSpace
- isNear
- moveTowards
- parallelTo
- roundIfCloseToInteger
- signedAngle
- fromPoint
- fromPoints
• new Vec2(x?
, y?
): Vec2
Name | Type |
---|---|
x? |
number |
y? |
number |
Vector2.constructor
node_modules/@types/three/src/math/Vector2.d.ts:140
▸ addX(x
): Vec2
Adds x amount to this Vec3 instance and return this
Name | Type |
---|---|
x |
number |
▸ addY(y
): Vec2
Adds y amount to this Vec3 instance and return this
Name | Type |
---|---|
y |
number |
▸ in3DSpace(y?
): Vec3
Projects this Vec2 instance to a Vec3 instance in 3D space. Vec2.y becomes Vec3.z. and Vec3.y is provided as an argument.
Name | Type | Default value | Description |
---|---|---|---|
y |
number |
0 |
The y value of the new Vec3 instance. |
A new Vec3 instance.
▸ isNear(v
, maxDistance?
): boolean
Determines if this Vec2 instance is near the target Vec2.
maxDistance is the maximum distance between the two vectors within which they are considered near
.
Name | Type | Default value |
---|---|---|
v |
Vector2 |
undefined |
maxDistance |
number |
undefined |
boolean
▸ moveTowards(target
, amount
): Vec2
Moves this Vec2 instance towards the target Vec2 by the given amount.
Name | Type | Description |
---|---|---|
target |
Vector2 |
The target Vec2. |
amount |
number |
The distance to move. |
This Vec2 instance.
▸ parallelTo(other
, toleranceRadians?
): boolean
check if the angle between the two vectors is close enough to 0 or 180 degrees (same or opposite direction) within the given tolerance
Name | Type | Default value | Description |
---|---|---|---|
other |
Vector2 |
undefined |
Vector2 |
toleranceRadians |
number |
0 |
number angle tolerance in radians |
boolean
▸ roundIfCloseToInteger(max?
): Vec2
Rounds the x and y values of this Vec2 instance if they are close to an integer value.
Name | Type | Default value | Description |
---|---|---|---|
max |
number |
0.000000000001 |
The maximum difference between the value and the nearest integer. |
This Vec2 instance.
▸ signedAngle(): number
Returns the angle between this vector and positive x-axis, the return value is between 0 and 2PI
number
▸ fromPoint(point
): Vec2
Creates a new Vec2 instance from an {x, y} object.
Name | Type | Description |
---|---|---|
point |
Point2 |
The {x, y} instance. |
A new Vec2 instance.
▸ fromPoints(...points
): Vec2
[]
Creates a new Vec2[] array from arguments of {x, y} objects. *
Name | Type | Description |
---|---|---|
...points |
Point2 [] |
The ...{x, y} instances. |
Vec2
[]