# JSVec3Array

> Create a new Module.JSVec3Array API.

```javascript
var vec_array = new Module.JSVec3Array();
```

### clear()

> Initializes the vector list.

```javascript
var vectorList = new Module.JSVec3Array();
vectorList.clear();
```

### count() → number

> Returns the number of data in the array.

{% tabs %}
{% tab title="Information" %}

* Return
  * number: The number of vectors in the list.
    {% endtab %}

{% tab title="Template" %}

```javascript
var vectorList = new Module.JSVec3Array();
// ...
vectorList.count();
```

{% endtab %}
{% endtabs %}

### get(index) → [JSVector3D](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/core/jsvector3d)

> Returns the vector object corresponding to the index.

{% tabs %}
{% tab title="Information" %}

| Name  | Type   | Description                                             |
| ----- | ------ | ------------------------------------------------------- |
| index | number | The index of the data to return (sorted from 0 onwards) |

* Return
  * A valid vector object ([JSVector3D](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/core/jsvector3d)): Successfully returns the vector at the specified index.
  * An initialized object ([JSVector3D](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/core/jsvector3d)): If the index exceeds the size of the vector list.
    {% endtab %}

{% tab title="Template" %}

```javascript
var vectorList = new Module.JSVec3Array();
//...
var vector = vectorList.get(2);
```

{% endtab %}
{% endtabs %}

### pop() → [JSVector3D](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/core/jsvector3d)

> Returns the last vector in the vector list.
>
> After returning, the last vector is deleted from the vector list.

{% tabs %}
{% tab title="Information" %}

* Return
  * A valid vector object ([JSVector3D](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/core/jsvector3d)): Successfully returns the last vector.
  * An initialized object ([JSVector3D](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/core/jsvector3d)): If the vector list is empty.
    {% endtab %}

{% tab title="Template" %}

```javascript
var vectorList = new Module.JSVec3Array();
//...
var lastVector = vectorList.pop();
```

{% endtab %}
{% endtabs %}

### push(element) → number

> Add a new vector ([JSVector3D](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/core/jsvector3d)).

{% tabs %}
{% tab title="Information" %}

| Name    | Type                                                                                        | Description |
| ------- | ------------------------------------------------------------------------------------------- | ----------- |
| element | [JSVector3D](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/core/jsvector3d) | 3D vector.  |

* Return
  * number: The number of vectors in the list after adding the new vector.
    {% endtab %}

{% tab title="Template" %}

```javascript
var vectorList = new Module.JSVec3Array();
var newVector = new Module.JSVector3D(100.0, 150.0, 15.0);
vectorList.push(newVector);
```

{% endtab %}
{% endtabs %}

### pushLonLatAlt(lon, lat, alt) → number

> Adds a new vector.

{% tabs %}
{% tab title="Information" %}

| Name | Type   | Description                     |
| ---- | ------ | ------------------------------- |
| lon  | number | longitude location coordinates. |
| lat  | number | latitude location coordinates.  |
| alt  | number | altitude location coordinates.  |

* Return
  * number: The number of vectors in the list after adding the new vector.
    {% endtab %}

{% tab title="Template" %}

```javascript
var vectorList = new Module.JSVec3Array();
vectorList.pushLonLatAlt(100.0, 120.0, 15.0);
```

{% endtab %}
{% endtabs %}

### set(index, vec)

> Resets the value of the vector at the specified index.

{% tabs %}
{% tab title="Information" %}

| Name         | Type                                                                                        | Description                     |
| ------------ | ------------------------------------------------------------------------------------------- | ------------------------------- |
| index        | number                                                                                      | The index of the vector to set. |
| vec          | [JSVector3D](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/core/jsvector3d) | The vector object to set.       |
| {% endtab %} |                                                                                             |                                 |

{% tab title="Template" %}

```javascript
var vectorList = new Module.JSVec3Array();
//...
var newVector = new Module.JSVector3D(130.22, 149.3, 15.0);
vectorList.set(5, newVector);
```

{% endtab %}
{% endtabs %}

### setLonLatAlt(index, lon, lat, alt)

> Resets the value of the vector at the specified index.

{% tabs %}
{% tab title="Information" %}

| Name         | Type   | Description                     |
| ------------ | ------ | ------------------------------- |
| index        | number | The index of the vector to set. |
| lon          | number | longitude location coordinates. |
| lat          | number | latitude location coordinates.  |
| alt          | number | altitude location coordinates.  |
| {% endtab %} |        |                                 |

{% tab title="Template" %}

```javascript
var vectorList = new Module.JSVec3Array();
//...
vectorList.setLonLatAlt(5, 130.22, 149.3, 15.0);
```

{% endtab %}
{% endtabs %}

### shift()

> Returns the first vector in the vector list and moves the order of the remaining vectors one position forward.

{% tabs %}
{% tab title="Information" %}

* Return
  * A valid vector object ([JSVector3D](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/core/jsvector3d)): Successfully returns the first vector.
  * An initialized object ([JSVector3D](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/core/jsvector3d)): If the vector list is empty.
    {% endtab %}

{% tab title="Template" %}

```javascript
var vectorList = new Module.JSVec3Array();
//...
var lastVector = vectorList.shift();
```

{% endtab %}
{% endtabs %}
