* Constructs a new selection. * * @param {Iterable } [iterable] - A collection of objects that should be added to this selection. * @param {Number} [layer] - A dedicated render layer for selected objects. Range is `[2, 31]`. Starts at 2 if omitted.
(iterable, layer = idManager.getNextId())
| 18 | */ |
| 19 | |
| 20 | constructor(iterable, layer = idManager.getNextId()) { |
| 21 | |
| 22 | super(); |
| 23 | |
| 24 | /** |
| 25 | * Controls whether objects that are added to this selection should be removed from all other layers. |
| 26 | */ |
| 27 | |
| 28 | this.exclusive = false; |
| 29 | |
| 30 | /** |
| 31 | * The current render layer for selected objects. |
| 32 | * |
| 33 | * @type {Number} |
| 34 | * @private |
| 35 | */ |
| 36 | |
| 37 | this._layer = layer; |
| 38 | |
| 39 | if(this._layer < 1 || this._layer > 31) { |
| 40 | |
| 41 | console.warn("Layer out of range, resetting to 2"); |
| 42 | idManager.reset(2); |
| 43 | this._layer = idManager.getNextId(); |
| 44 | |
| 45 | } |
| 46 | |
| 47 | if(iterable !== undefined) { |
| 48 | |
| 49 | this.set(iterable); |
| 50 | |
| 51 | } |
| 52 | |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * The render layer for selected objects. |