---
description: API for creating and modifying water flow effect polygon objects.
---

# JSFlowPolygon

> Create a API with Module.createFlowPolygon.

```javascript
let flowPolygon = Module.createFlowPolygon("ID");
```

## Properties

| Name             | Type                               | Description                                                                                                                                                                                                                   |
| ---------------- | ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| opacity          | number                             | Opacity.                                                                                                                                                                                                                      |
| fluid\_activity  | number                             | Degree of fluid fluctuation.                                                                                                                                                                                                  |
| flow\_speed      | number                             | Flow speed.                                                                                                                                                                                                                   |
| image\_type      | number                             | <p>Surface image display type.<br>0: Display with specified image.<br>1: Display wind flow direction legend as color.<br>3: Display with terrain texture buffer.<br>Otherwise, display with the color specified by color.</p> |
| position\_offset | [JSVector3D](../core/jsvector3d)   | Additional position offset.                                                                                                                                                                                                   |
| color            | [JSColor](../core/jscolor)         | Color setting when in legend color display mode.                                                                                                                                                                              |
| coordinates      | [JSVec3Array](../core/jsvec3array) | Position of the object (get only).                                                                                                                                                                                            |

## Function

### createGrid(options) → object

> Creates a grid object.

{% tabs %}
{% tab title="Information" %}
| Name    | Type                                                          | Description                |
| ------- | ------------------------------------------------------------- | -------------------------- |
| options | [JSFlowPolygon.GridDataOption](#jsflowpolygon.griddataoption) | Grid information settings. |

* Return
  * Object with "result" attribute: Object creation successful.
  * Object with "error" attribute: Object creation failed.
  * Failure conditions.
    * If the "vertex" attribute is missing in options.
    * If the "index" attribute is missing in options.
    * If the "normaltexture" attribute is missing or the texture image is not valid.
    * If grid object creation failed.
    * If setting the "waterlevel" attribute failed.
{% endtab %}

{% tab title="Template" %}
```javascript
```
{% endtab %}
{% endtabs %}

### createWall(options) → object

> Creates a vertical wall polygon object.
>
> Object is set with options variable.

{% tabs %}
{% tab title="Information" %}
| Name    | Type                                                          | Description                |
| ------- | ------------------------------------------------------------- | -------------------------- |
| options | [JSFlowPolygon.WallDataOption](#jsflowpolygon.walldataoption) | Wall information settings. |

* Return
  * Object with "result" attribute: Object creation successful.
  * Object with "error" attribute: Object creation failed.
  * Failure conditions.
    * If the "vertex" attribute is missing in options.
    * If the "normaltexture" attribute is missing or the texture image is not valid.
{% endtab %}

{% tab title="Template" %}
```javascript
```
{% endtab %}
{% endtabs %}

### setCullMode(type) → boolean

> Sets the culling option for the vertical wall polygon.
>
> The culling option based on the input value of type is 0(both sides), 1(both sides), 2(CW), 3(CCW).
>
> The initial culling option setting is 3.

{% tabs %}
{% tab title="Information" %}
| Name | Type   | Description           |
| ---- | ------ | --------------------- |
| type | number | Polygon culling mode. |

* Return
  * true: Object option setting successful.
  * false: Object option setting failed.
{% endtab %}

{% tab title="Template" %}
```javascript
polygon.setCullMode(3);
```
{% endtab %}
{% endtabs %}

### Type Definitions

#### JSFlowPolygon.GridDataOption

> Grid information parameters.

| Name           | Type                                                          | Attributes | Default         | Description                                 |
| -------------- | ------------------------------------------------------------- | ---------- | --------------- | ------------------------------------------- |
| vertex         | array([JSVector3D](../core/jsvector3d))                       |            |                 | List of coordinates forming the grid.       |
| index          | array(number)                                                 |            |                 | List of index coordinates forming the grid. |
| normaltexture  | [JSIcon](jsicon)                                              |            |                 | Material normal texture.                    |
| flowtexture    | [JSIcon](jsicon)                                              | optional   |                 | Direct flow map texture.                    |
| flowpath       | array([JSVector2D](../core/jsvector2d))                       | optional   |                 | Flow map path.                              |
| imagetexture   | [JSIcon](jsicon)                                              | optional   |                 | Surface image texture.                      |
| waterlevel     | number                                                        | optional   | 0.0             | Water level.                                |
| positionoffset | [JSFlowPolygon.positionOffset](#jsflowpolygon.positionoffset) | optional   | (0.0, 0.0, 0.0) | Position offset.                            |

#### JSFlowPolygon.WallDataOption

> Wall information parameters.

| Name           | Type                                                          | Attributes | Default         | Description                           |
| -------------- | ------------------------------------------------------------- | ---------- | --------------- | ------------------------------------- |
| vertex         | array([JSVector3D](../core/jsvector3d))                       |            |                 | List of coordinates forming the wall. |
| normaltexture  | [JSIcon](jsicon)                                              |            |                 | Material normal texture.              |
| imagetexture   | [JSIcon](jsicon)                                              | optional   |                 | Surface image texture.                |
| height         | number                                                        | optional   | 10.0            | Wall height.                          |
| positionoffset | [JSFlowPolygon.positionOffset](#jsflowpolygon.positionoffset) | optional   | (0.0, 0.0, 0.0) | Position offset.                      |

#### JSFlowPolygon.positionOffset

| Name      | Type   | Default | Description |
| --------- | ------ | ------- | ----------- |
| longitude | number | 0.0     | Longitude.  |
| latitude  | number | 0.0     | Latitude.   |
| altitude  | number | 0.0     | Altitude.   |
