( collectionProperty, CollectionConstructor, unusedIndicesProperty, entityIndexProperty, )
| 632 | }); |
| 633 | |
| 634 | function createGetEntity( |
| 635 | collectionProperty, |
| 636 | CollectionConstructor, |
| 637 | unusedIndicesProperty, |
| 638 | entityIndexProperty, |
| 639 | ) { |
| 640 | return function (entity) { |
| 641 | let collection = this[collectionProperty]; |
| 642 | |
| 643 | if (!defined(this._collectionIndicesByEntity)) { |
| 644 | this._collectionIndicesByEntity = {}; |
| 645 | } |
| 646 | |
| 647 | let entityIndices = this._collectionIndicesByEntity[entity.id]; |
| 648 | |
| 649 | if (!defined(entityIndices)) { |
| 650 | entityIndices = this._collectionIndicesByEntity[entity.id] = { |
| 651 | billboardIndex: undefined, |
| 652 | labelIndex: undefined, |
| 653 | pointIndex: undefined, |
| 654 | }; |
| 655 | } |
| 656 | |
| 657 | if (defined(collection) && defined(entityIndices[entityIndexProperty])) { |
| 658 | return collection.get(entityIndices[entityIndexProperty]); |
| 659 | } |
| 660 | |
| 661 | if (!defined(collection)) { |
| 662 | collection = this[collectionProperty] = new CollectionConstructor({ |
| 663 | scene: this._scene, |
| 664 | }); |
| 665 | } |
| 666 | |
| 667 | let index; |
| 668 | let entityItem; |
| 669 | |
| 670 | const unusedIndices = this[unusedIndicesProperty]; |
| 671 | if (unusedIndices.length > 0) { |
| 672 | index = unusedIndices.shift(); |
| 673 | entityItem = collection.get(index); |
| 674 | } else { |
| 675 | entityItem = collection.add(); |
| 676 | index = collection.length - 1; |
| 677 | } |
| 678 | |
| 679 | entityIndices[entityIndexProperty] = index; |
| 680 | |
| 681 | const that = this; |
| 682 | Promise.resolve().then(function () { |
| 683 | that._clusterDirty = true; |
| 684 | }); |
| 685 | |
| 686 | return entityItem; |
| 687 | }; |
| 688 | } |
| 689 | |
| 690 | function removeEntityIndicesIfUnused(entityCluster, entityId) { |
| 691 | const indices = entityCluster._collectionIndicesByEntity[entityId]; |
no test coverage detected
searching dependent graphs…