UltimateZoneBuilder/Build/UDBScript/Scripts/Examples/Geometry/triangulatesectors.js
biwa 5b2b149b40
UDBScript version 5 (#819)
Improved UDBScript to version 5:

- Added Plane class
- Added BlockMap, BlockEntry, and BlackMapQueryResult classes
- Sector class
  - Added getLabelPositions method to get the position of sector labels (where tags, effects etc. are displayed)
- Added support for JavaScript BigInt for UDMF fields. This means it's not necessary anymore to use UniValue to assign integers to new UDMF fields. Instead it can be done like this: sector.fields.my_int_field = 1n;
- Added type information file (udbscript.d.ts)
2022-11-13 01:15:17 +01:00

13 lines
No EOL
604 B
JavaScript

/// <reference path="../../../udbscript.d.ts" />
`#version 4`;
`#name Triangulate Sectors`;
`#description Triangulates the selected or highlighted sectors into new sectors. Note that the triangulation will not "be beautiful", and that the sectors with islands may cause problems.`;
let sectors = UDB.Map.getSelectedOrHighlightedSectors();
if(sectors.length == 0)
UDB.die('No sectors selected or highlighted');
// Draw all triangles. Remember to add the first point at the end so that the drawing will be closed
sectors.forEach(s => s.getTriangles().forEach(t => UDB.Map.drawLines([...t, t[0]])));