* Select or unselects the given faces. * @param active Whether to select or unselect. * @param ids List of faces IDs to select or unselect. If not * defined, all faces will be selected or deselected. * @param allItems all the existing items.
(active: boolean, ids: Iterable<number>, allItems: number[])
| 9 | * @param allItems all the existing items. |
| 10 | */ |
| 11 | select(active: boolean, ids: Iterable<number>, allItems: number[]) { |
| 12 | const all = new Set<number>(allItems); |
| 13 | const idsToUpdate: number[] = []; |
| 14 | for (const id of ids) { |
| 15 | const exists = all.has(id); |
| 16 | if (!exists) continue; |
| 17 | |
| 18 | const isAlreadySelected = this.data.has(id); |
| 19 | if (active) { |
| 20 | if (isAlreadySelected) continue; |
| 21 | this.data.add(id); |
| 22 | idsToUpdate.push(id); |
| 23 | } else { |
| 24 | if (!isAlreadySelected) continue; |
| 25 | this.data.delete(id); |
| 26 | idsToUpdate.push(id); |
| 27 | } |
| 28 | } |
| 29 | return idsToUpdate; |
| 30 | } |
| 31 | |
| 32 | getUnselected(ids: number[]) { |
| 33 | const notSelectedIDs: number[] = []; |