Version:

<static> BuildFromPolygon(data, [holes], [scaleX], [scaleY], [out])

Takes an array of vertex coordinates, and optionally an array of hole indices, then returns an array of Triangle instances, where the given vertices have been decomposed into a series of triangles.

name | type | arguments | Default | description |
---|---|---|---|---|

data | array |
A flat array of vertex coordinates like [x0,y0, x1,y1, x2,y2, ...] |
||

holes | array | <optional> | null |
An array of hole indices if any (e.g. [5, 8] for a 12-vertex input would mean one hole with vertices 5–7 and another with 8–11). |

scaleX | number | <optional> | 1 |
Horizontal scale factor to multiply the resulting points by. |

scaleY | number | <optional> | 1 |
Vertical scale factor to multiply the resulting points by. |

out | array | Array.<Phaser.Geom.Triangle> | <optional> |
An array to store the resulting Triangle instances in. If not provided, a new array is created. |

An array of Triangle instances, where each triangle is based on the decomposed vertices data.

- array
- Array.<Phaser.Geom.Triangle>

Since: 3.0.0

Possible examples