[gs-longan](../README.md) / Vector3

# Class: Vector3

## Implements

- `IVector3Like`

## Table of contents

### Constructors

- [constructor](Vector3.md#constructor)

### Properties

- [\_data](Vector3.md#_data)

### Accessors

- [data](Vector3.md#data)
- [x](Vector3.md#x)
- [y](Vector3.md#y)
- [z](Vector3.md#z)

### Methods

- [add](Vector3.md#add)
- [clone](Vector3.md#clone)
- [cross](Vector3.md#cross)
- [crossFrom](Vector3.md#crossfrom)
- [divide](Vector3.md#divide)
- [divideFrom](Vector3.md#dividefrom)
- [dot](Vector3.md#dot)
- [equals](Vector3.md#equals)
- [length](Vector3.md#length)
- [lengthSquared](Vector3.md#lengthsquared)
- [multiply](Vector3.md#multiply)
- [multiplyTo](Vector3.md#multiplyto)
- [normalize](Vector3.md#normalize)
- [rotationFromAxis](Vector3.md#rotationfromaxis)
- [scale](Vector3.md#scale)
- [scaleAndAdd](Vector3.md#scaleandadd)
- [scaleAndAddTo](Vector3.md#scaleandaddto)
- [scaleFrom](Vector3.md#scalefrom)
- [set](Vector3.md#set)
- [setAll](Vector3.md#setall)
- [subtract](Vector3.md#subtract)
- [subtractFrom](Vector3.md#subtractfrom)
- [transform](Vector3.md#transform)
- [transformCoordinates](Vector3.md#transformcoordinates)
- [Backward](Vector3.md#backward)
- [CatmullRom](Vector3.md#catmullrom)
- [Distance](Vector3.md#distance)
- [DistanceSquared](Vector3.md#distancesquared)
- [Down](Vector3.md#down)
- [Forward](Vector3.md#forward)
- [FromArray](Vector3.md#fromarray)
- [Hermite](Vector3.md#hermite)
- [Left](Vector3.md#left)
- [Lerp](Vector3.md#lerp)
- [LerpTo](Vector3.md#lerpto)
- [One](Vector3.md#one)
- [Right](Vector3.md#right)
- [Up](Vector3.md#up)
- [Zero](Vector3.md#zero)

## Constructors

### constructor

• **new Vector3**(`x?`, `y?`, `z?`): [`Vector3`](Vector3.md)

#### Parameters

| Name | Type |
| :------ | :------ |
| `x?` | `number` |
| `y?` | `number` |
| `z?` | `number` |

#### Returns

[`Vector3`](Vector3.md)

## Properties

### \_data

• **\_data**: `number`[]

## Accessors

### data

• `get` **data**(): `number`[]

#### Returns

`number`[]

#### Implementation of

IVector3Like.data

___

### x

• `get` **x**(): `number`

#### Returns

`number`

#### Implementation of

IVector3Like.x

• `set` **x**(`value`): `void`

#### Parameters

| Name | Type |
| :------ | :------ |
| `value` | `number` |

#### Returns

`void`

#### Implementation of

IVector3Like.x

___

### y

• `get` **y**(): `number`

#### Returns

`number`

#### Implementation of

IVector3Like.y

• `set` **y**(`value`): `void`

#### Parameters

| Name | Type |
| :------ | :------ |
| `value` | `number` |

#### Returns

`void`

#### Implementation of

IVector3Like.y

___

### z

• `get` **z**(): `number`

#### Returns

`number`

#### Implementation of

IVector3Like.z

• `set` **z**(`value`): `void`

#### Parameters

| Name | Type |
| :------ | :------ |
| `value` | `number` |

#### Returns

`void`

#### Implementation of

IVector3Like.z

## Methods

### add

▸ **add**(`vector`): [`Vector3`](Vector3.md)

Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.

#### Parameters

| Name | Type |
| :------ | :------ |
| `vector` | `IVector3Like` |

#### Returns

[`Vector3`](Vector3.md)

the resulting vector

___

### clone

▸ **clone**(): [`Vector3`](Vector3.md)

#### Returns

[`Vector3`](Vector3.md)

___

### cross

▸ **cross**(`vector`): [`Vector3`](Vector3.md)

#### Parameters

| Name | Type |
| :------ | :------ |
| `vector` | [`Vector3`](Vector3.md) |

#### Returns

[`Vector3`](Vector3.md)

___

### crossFrom

▸ **crossFrom**(`vector`): `void`

#### Parameters

| Name | Type |
| :------ | :------ |
| `vector` | [`Vector3`](Vector3.md) |

#### Returns

`void`

___

### divide

▸ **divide**(`vector`): [`Vector3`](Vector3.md)

#### Parameters

| Name | Type |
| :------ | :------ |
| `vector` | [`Vector3`](Vector3.md) |

#### Returns

[`Vector3`](Vector3.md)

___

### divideFrom

▸ **divideFrom**(`vector`): `this`

#### Parameters

| Name | Type |
| :------ | :------ |
| `vector` | [`Vector3`](Vector3.md) |

#### Returns

`this`

___

### dot

▸ **dot**(`vector`): `number`

Gets the dot product of the current vector and the vector "vector"

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `vector` | `IVector3Like` | defines second vector |

#### Returns

`number`

the dot product (float)

___

### equals

▸ **equals**(`otherVector`): `boolean`

#### Parameters

| Name | Type |
| :------ | :------ |
| `otherVector` | [`Vector3`](Vector3.md) |

#### Returns

`boolean`

___

### length

▸ **length**(): `number`

Gets the length of the Vector3
Example Playground https://playground.babylonjs.com/#R1F8YU#25

#### Returns

`number`

the length of the Vector3

___

### lengthSquared

▸ **lengthSquared**(): `number`

Gets the squared length of the Vector3
Example Playground https://playground.babylonjs.com/#R1F8YU#26

#### Returns

`number`

squared length of the Vector3

___

### multiply

▸ **multiply**(`vector`): [`Vector3`](Vector3.md)

#### Parameters

| Name | Type |
| :------ | :------ |
| `vector` | [`Vector3`](Vector3.md) |

#### Returns

[`Vector3`](Vector3.md)

___

### multiplyTo

▸ **multiplyTo**(`vector`, `result`): [`Vector3`](Vector3.md)

#### Parameters

| Name | Type |
| :------ | :------ |
| `vector` | [`Vector3`](Vector3.md) |
| `result` | [`Vector3`](Vector3.md) |

#### Returns

[`Vector3`](Vector3.md)

___

### normalize

▸ **normalize**(): `this`

#### Returns

`this`

___

### rotationFromAxis

▸ **rotationFromAxis**(`xAxis`, `yAxis`): [`Vector3`](Vector3.md)

#### Parameters

| Name | Type |
| :------ | :------ |
| `xAxis` | [`Vector3`](Vector3.md) |
| `yAxis` | [`Vector3`](Vector3.md) |

#### Returns

[`Vector3`](Vector3.md)

___

### scale

▸ **scale**(`scale`): [`Vector3`](Vector3.md)

#### Parameters

| Name | Type |
| :------ | :------ |
| `scale` | `number` |

#### Returns

[`Vector3`](Vector3.md)

___

### scaleAndAdd

▸ **scaleAndAdd**(`scale`): [`Vector3`](Vector3.md)

#### Parameters

| Name | Type |
| :------ | :------ |
| `scale` | `number` |

#### Returns

[`Vector3`](Vector3.md)

___

### scaleAndAddTo

▸ **scaleAndAddTo**(`scale`, `result`): [`Vector3`](Vector3.md)

#### Parameters

| Name | Type |
| :------ | :------ |
| `scale` | `number` |
| `result` | [`Vector3`](Vector3.md) |

#### Returns

[`Vector3`](Vector3.md)

___

### scaleFrom

▸ **scaleFrom**(`scale`): `this`

#### Parameters

| Name | Type |
| :------ | :------ |
| `scale` | `number` |

#### Returns

`this`

___

### set

▸ **set**(`x`, `y`, `z`): `void`

#### Parameters

| Name | Type |
| :------ | :------ |
| `x` | `number` |
| `y` | `number` |
| `z` | `number` |

#### Returns

`void`

___

### setAll

▸ **setAll**(`v`): `this`

#### Parameters

| Name | Type |
| :------ | :------ |
| `v` | `number` |

#### Returns

`this`

___

### subtract

▸ **subtract**(`vector`): [`Vector3`](Vector3.md)

#### Parameters

| Name | Type |
| :------ | :------ |
| `vector` | [`Vector3`](Vector3.md) |

#### Returns

[`Vector3`](Vector3.md)

___

### subtractFrom

▸ **subtractFrom**(`vector`): `this`

#### Parameters

| Name | Type |
| :------ | :------ |
| `vector` | `IVector3Like` |

#### Returns

`this`

___

### transform

▸ **transform**(`transform`): [`Vector3`](Vector3.md)

#### Parameters

| Name | Type |
| :------ | :------ |
| `transform` | `Matrix4` |

#### Returns

[`Vector3`](Vector3.md)

___

### transformCoordinates

▸ **transformCoordinates**(`transform`): [`Vector3`](Vector3.md)

#### Parameters

| Name | Type |
| :------ | :------ |
| `transform` | `Matrix4` |

#### Returns

[`Vector3`](Vector3.md)

___

### Backward

▸ **Backward**(`rightHandedSystem?`): [`Vector3`](Vector3.md)

Returns a new Vector3 set to (0.0, 0.0, -1.0)
Example Playground https://playground.babylonjs.com/#R1F8YU#71

#### Parameters

| Name | Type | Default value | Description |
| :------ | :------ | :------ | :------ |
| `rightHandedSystem` | `boolean` | `true` | is the scene right-handed (negative-z) |

#### Returns

[`Vector3`](Vector3.md)

a new Backward Vector3

___

### CatmullRom

▸ **CatmullRom**(`value1`, `value2`, `value3`, `value4`, `amount`): [`Vector3`](Vector3.md)

Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
Example Playground https://playground.babylonjs.com/#R1F8YU#69

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `value1` | [`Vector3`](Vector3.md) | defines the first control point |
| `value2` | [`Vector3`](Vector3.md) | defines the second control point |
| `value3` | [`Vector3`](Vector3.md) | defines the third control point |
| `value4` | [`Vector3`](Vector3.md) | defines the fourth control point |
| `amount` | `number` | defines the amount on the spline to use |

#### Returns

[`Vector3`](Vector3.md)

the new Vector3

___

### Distance

▸ **Distance**(`value1`, `value2`): `number`

Returns the distance between the vectors "value1" and "value2"
Example Playground https://playground.babylonjs.com/#R1F8YU#81

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `value1` | [`Vector3`](Vector3.md) | defines the first operand |
| `value2` | [`Vector3`](Vector3.md) | defines the second operand |

#### Returns

`number`

the distance

___

### DistanceSquared

▸ **DistanceSquared**(`value1`, `value2`): `number`

Returns the squared distance between the vectors "value1" and "value2"
Example Playground https://playground.babylonjs.com/#R1F8YU#80

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `value1` | [`Vector3`](Vector3.md) | defines the first operand |
| `value2` | [`Vector3`](Vector3.md) | defines the second operand |

#### Returns

`number`

the squared distance

___

### Down

▸ **Down**(): [`Vector3`](Vector3.md)

Returns a new Vector3 set to (0.0, -1.0, 0.0)
Example Playground https://playground.babylonjs.com/#R1F8YU#71

#### Returns

[`Vector3`](Vector3.md)

a new down Vector3

___

### Forward

▸ **Forward**(`rightHandedSystem?`): [`Vector3`](Vector3.md)

Returns a new Vector3 set to (0.0, 0.0, 1.0)
Example Playground https://playground.babylonjs.com/#R1F8YU#71

#### Parameters

| Name | Type | Default value | Description |
| :------ | :------ | :------ | :------ |
| `rightHandedSystem` | `boolean` | `true` | is the scene right-handed (negative z) |

#### Returns

[`Vector3`](Vector3.md)

a new forward Vector3

___

### FromArray

▸ **FromArray**(`array`, `offset?`): [`Vector3`](Vector3.md)

#### Parameters

| Name | Type | Default value |
| :------ | :------ | :------ |
| `array` | `ArrayLike`\<`number`\> | `undefined` |
| `offset` | `number` | `0` |

#### Returns

[`Vector3`](Vector3.md)

___

### Hermite

▸ **Hermite**(`value1`, `tangent1`, `value2`, `tangent2`, `amount`): [`Vector3`](Vector3.md)

Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
Example Playground https://playground.babylonjs.com/#R1F8YU#89

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `value1` | [`Vector3`](Vector3.md) | defines the first control point |
| `tangent1` | [`Vector3`](Vector3.md) | defines the first tangent vector |
| `value2` | [`Vector3`](Vector3.md) | defines the second control point |
| `tangent2` | [`Vector3`](Vector3.md) | defines the second tangent vector |
| `amount` | `number` | defines the amount on the interpolation spline (between 0 and 1) |

#### Returns

[`Vector3`](Vector3.md)

the new Vector3

___

### Left

▸ **Left**(): [`Vector3`](Vector3.md)

Returns a new Vector3 set to (-1.0, 0.0, 0.0)
Example Playground https://playground.babylonjs.com/#R1F8YU#71

#### Returns

[`Vector3`](Vector3.md)

a new left Vector3

___

### Lerp

▸ **Lerp**(`start`, `end`, `amount`): [`Vector3`](Vector3.md)

#### Parameters

| Name | Type |
| :------ | :------ |
| `start` | [`Vector3`](Vector3.md) |
| `end` | [`Vector3`](Vector3.md) |
| `amount` | `number` |

#### Returns

[`Vector3`](Vector3.md)

___

### LerpTo

▸ **LerpTo**(`start`, `end`, `amount`, `result`): [`Vector3`](Vector3.md)

#### Parameters

| Name | Type |
| :------ | :------ |
| `start` | [`Vector3`](Vector3.md) |
| `end` | [`Vector3`](Vector3.md) |
| `amount` | `number` |
| `result` | [`Vector3`](Vector3.md) |

#### Returns

[`Vector3`](Vector3.md)

___

### One

▸ **One**(): [`Vector3`](Vector3.md)

Returns a new Vector3 set to (1.0, 1.0, 1.0)

#### Returns

[`Vector3`](Vector3.md)

a new Vector3

___

### Right

▸ **Right**(): [`Vector3`](Vector3.md)

Returns a new Vector3 set to (1.0, 0.0, 0.0)
Example Playground https://playground.babylonjs.com/#R1F8YU#71

#### Returns

[`Vector3`](Vector3.md)

a new right Vector3

___

### Up

▸ **Up**(): [`Vector3`](Vector3.md)

Returns a new Vector3 set to (0.0, 1.0, 0.0)
Example Playground https://playground.babylonjs.com/#R1F8YU#71

#### Returns

[`Vector3`](Vector3.md)

a new up Vector3

___

### Zero

▸ **Zero**(): [`Vector3`](Vector3.md)

Returns a new Vector3 set to (0.0, 0.0, 0.0)

#### Returns

[`Vector3`](Vector3.md)

a new empty Vector3
