# JSTraceTarget

> Create a API with Module.createTraceTarget.

```javascript
let trace = Module.createTraceTarget("ID");
```

## Function

### move(front, right, terrain)

> Moves the object in the specified direction.

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

| Name         | Type    | Description                                                                                                                                                                        |
| ------------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| front        | number  | Forward and backward movement values (in meters).                                                                                                                                  |
| right        | number  | Left and right movement values (in meters).                                                                                                                                        |
| terrain      | boolean | <p>Set whether or not to refer to the terrain altitude of an object when moving.<br>true: See real-time terrain elevation values.<br>flase: fix object default altitude value.</p> |
| {% endtab %} |         |                                                                                                                                                                                    |

{% tab title="Template" %}

```javascript
// Omission of traceTarget creation and connection process.
traceTarget.move(1.0, 1.0, true);
```

{% endtab %}
{% endtabs %}

### moveTarget(options)

> Moves the object in the specified direction.
>
> Unlike move(), it passes movement in 6 directions (forward/backward/left/right/up/down) as parameters.

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

| Name         | Type                                                        | Description           |
| ------------ | ----------------------------------------------------------- | --------------------- |
| parameter    | [JSTraceTarget.moveParameter](#jstracetarget.moveparameter) | Movement information. |
| {% endtab %} |                                                             |                       |

{% tab title="Template" %}

```javascript
var move_front = 0.0;
var move_back = 0.0;
var move_left = 0.0;
var move_right = 0.0;
var move_up = 0.0;
var move_down = 0.0;

if (GLOBAL["KEY_PRESS_w"]) {
    move_front = 1.0;
} else if (GLOBAL["KEY_PRESS_s"]) {
    move_back = 1.0;
} else;

if (GLOBAL["KEY_PRESS_a"]) {
    move_left = 1.0;
} else if (GLOBAL["KEY_PRESS_d"]) {
    move_right = 1.0;
} else;

if (GLOBAL["KEY_PRESS_q"]) {
    move_down = 1.0;
} else if (GLOBAL["KEY_PRESS_e"]) {
    move_up = 1.0;
} else;

GLOBAL.TRACE_TARGET.moveTarget({
    front: move_front,
    back: move_back,
    left: move_left,
    right: move_right,
    down: move_down,
    up: move_up,
});
```

{% endtab %}
{% endtabs %}

### ReleaseObject() → boolean

> Unregisters a registered object.

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

* Return
  * true: Disconnection successful.
  * false: Disconnection failed.
    {% endtab %}

{% tab title="Template" %}

```javascript
// Omission of traceTarget creation and connection process.
traceTarget.ReleaseObject();
```

{% endtab %}
{% endtabs %}

### set(options)

> Create a movement path function using object and movement information.
>
> The object supports only [JSGhostSymbol](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/object/jsghostsymbol) and [JSPoint](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/object/jspoint).

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

| Name         | Type                                                                                      | Description    |
| ------------ | ----------------------------------------------------------------------------------------- | -------------- |
| object       | [JSObject](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/object/jsobject) | Target object. |
| tilt         | number                                                                                    | Tilt.          |
| direction    | number                                                                                    | Direction.     |
| distance     | number                                                                                    | Distance.      |
| {% endtab %} |                                                                                           |                |

{% tab title="Template" %}

```javascript
```

{% endtab %}
{% endtabs %}

### unionTargetToTerrain()

> The object moves by referencing the terrain altitude during movement.

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

{% endtab %}

{% tab title="Template" %}

```javascript
// Omission of traceTarget creation and connection process.
traceTarget.unionTargetToTerrain();
```

{% endtab %}
{% endtabs %}

## Getter / Setter

### getObject(), setObject(object) → [JSObject](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/object/jsobject)

> Changes the currently connected target object.
>
> The object supports only [JSGhostSymbol](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/object/jsghostsymbol) and [JSPoint](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/object/jspoint).
>
> Does not operate if the object is null.

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

| Name   | Type                                                                                      | Description                |
| ------ | ----------------------------------------------------------------------------------------- | -------------------------- |
| object | [JSObject](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/object/jsobject) | Target object information. |

* Return
  * [JSObject](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/object/jsobject): returned successfully.
  * null : returned failed.
    {% endtab %}

{% tab title="Template" %}

```javascript
// Omission of traceTarget creation and connection process.
traceTarget.getObject();
// ... or ...
// Omission of traceTarget creation and connection process.
traceTarget.setObject(object);
```

{% endtab %}
{% endtabs %}

### Type Definitions

#### JSTraceTarget.moveParameter

| Name  | Type   | Attributes | Default | Description                            |
| ----- | ------ | ---------- | ------- | -------------------------------------- |
| front | number | optional   | 0.0     | Forward movement values (in meters).   |
| back  | number | optional   | 0.0     | backward movement values (in meters).  |
| left  | number | optional   | 0.0     | leftward movement values (in meters).  |
| right | number | optional   | 0.0     | rightward movement values (in meters). |
| up    | number | optional   | 0.0     | upward movement values (in meters).    |
| down  | number | optional   | 0.0     | downward movement values (in meters).  |
