> For the complete documentation index, see [llms.txt](https://scripting.breeze.rip/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://scripting.breeze.rip/newgen/api/net/minecraft/world/phys/vec3.md).

# Vec3

An immutable point or direction in 3D space.

### Constructors

#### Constructor

> **new Vec3**(`x`, `y`, `z`): `Vec3`

Creates a new Vec3.

**Parameters**

**x**

`number`

The X coordinate.

**y**

`number`

The Y coordinate.

**z**

`number`

The Z coordinate.

**Returns**

`Vec3`

### Properties

#### x

> `readonly` **x**: `number`

The X coordinate.

***

#### y

> `readonly` **y**: `number`

The Y coordinate.

***

#### z

> `readonly` **z**: `number`

The Z coordinate.

### Methods

#### add()

> **add**(`x`, `y`, `z`): `Vec3`

Adds the given offsets.

**Parameters**

**x**

`number`

X offset.

**y**

`number`

Y offset.

**z**

`number`

Z offset.

**Returns**

`Vec3`

***

#### closerThan()

> **closerThan**(`other`, `distanceXZ`, `distanceY`): `boolean`

Whether another point is within a horizontal and a vertical distance.

**Parameters**

**other**

`Vec3`

The other point.

**distanceXZ**

`number`

The maximum horizontal distance.

**distanceY**

`number`

The maximum vertical distance.

**Returns**

`boolean`

***

#### cross()

> **cross**(`other`): `Vec3`

The cross product with another vector.

**Parameters**

**other**

`Vec3`

The other vector.

**Returns**

`Vec3`

***

#### distanceTo()

> **distanceTo**(`other`): `number`

The distance to another point.

**Parameters**

**other**

`Vec3`

The other point.

**Returns**

`number`

***

#### distanceToSqr()

> **distanceToSqr**(`other`): `number`

The squared distance to another point.

**Parameters**

**other**

`Vec3`

The other point.

**Returns**

`number`

***

#### dot()

> **dot**(`other`): `number`

The dot product with another vector.

**Parameters**

**other**

`Vec3`

The other vector.

**Returns**

`number`

***

#### horizontal()

> **horizontal**(): `Vec3`

This vector with Y set to 0.

**Returns**

`Vec3`

***

#### horizontalDistance()

> **horizontalDistance**(): `number`

The length of this vector ignoring Y.

**Returns**

`number`

***

#### horizontalDistanceSqr()

> **horizontalDistanceSqr**(): `number`

The squared length of this vector ignoring Y.

**Returns**

`number`

***

#### isFinite()

> **isFinite**(): `boolean`

Whether no component is NaN or infinite.

**Returns**

`boolean`

***

#### length()

> **length**(): `number`

The length of this vector.

**Returns**

`number`

***

#### lengthSqr()

> **lengthSqr**(): `number`

The squared length of this vector.

**Returns**

`number`

***

#### lerp()

> **lerp**(`other`, `delta`): `Vec3`

Interpolates towards another point.

**Parameters**

**other**

`Vec3`

The other point.

**delta**

`number`

0 is this point, 1 the other.

**Returns**

`Vec3`

***

#### minus()

> **minus**(`other`): `Vec3`

Subtracts another vector.

**Parameters**

**other**

`Vec3`

The vector to subtract.

**Returns**

`Vec3`

***

#### multiply()

> **multiply**(`x`, `y`, `z`): `Vec3`

Multiplies each component by its own factor.

**Parameters**

**x**

`number`

X factor.

**y**

`number`

Y factor.

**z**

`number`

Z factor.

**Returns**

`Vec3`

***

#### normalize()

> **normalize**(): `Vec3`

This vector with a length of 1, or zero if it has none.

**Returns**

`Vec3`

***

#### plus()

> **plus**(`other`): `Vec3`

Adds another vector.

**Parameters**

**other**

`Vec3`

The vector to add.

**Returns**

`Vec3`

***

#### projectedOn()

> **projectedOn**(`onto`): `Vec3`

This vector projected onto another.

**Parameters**

**onto**

`Vec3`

The vector to project onto.

**Returns**

`Vec3`

***

#### relative()

> **relative**(`direction`, `distance`): `Vec3`

This point moved along a direction.

**Parameters**

**direction**

[`Direction`](/newgen/api/enum_types/direction.md)

The direction.

**distance**

`number`

The distance in blocks.

**Returns**

`Vec3`

***

#### reverse()

> **reverse**(): `Vec3`

This vector pointing the opposite way.

**Returns**

`Vec3`

***

#### scale()

> **scale**(`factor`): `Vec3`

Multiplies every component.

**Parameters**

**factor**

`number`

The factor.

**Returns**

`Vec3`

***

#### subtract()

> **subtract**(`x`, `y`, `z`): `Vec3`

Subtracts the given offsets.

**Parameters**

**x**

`number`

X offset.

**y**

`number`

Y offset.

**z**

`number`

Z offset.

**Returns**

`Vec3`

***

#### toBlockPos()

> **toBlockPos**(): [`BlockPos`](/newgen/api/net/minecraft/core/blockpos.md)

The block position containing this point.

**Returns**

[`BlockPos`](/newgen/api/net/minecraft/core/blockpos.md)

***

#### vectorTo()

> **vectorTo**(`other`): `Vec3`

The vector from this point to another.

**Parameters**

**other**

`Vec3`

The other point.

**Returns**

`Vec3`

***

#### xRot()

> **xRot**(`radians`): `Vec3`

This vector rotated around the X axis.

**Parameters**

**radians**

`number`

The angle in radians.

**Returns**

`Vec3`

***

#### yRot()

> **yRot**(`radians`): `Vec3`

This vector rotated around the Y axis.

**Parameters**

**radians**

`number`

The angle in radians.

**Returns**

`Vec3`

***

#### zRot()

> **zRot**(`radians`): `Vec3`

This vector rotated around the Z axis.

**Parameters**

**radians**

`number`

The angle in radians.

**Returns**

`Vec3`
