MCPcopy
hub / github.com/CesiumGS/cesium / createGetEntity

Function createGetEntity

packages/engine/Source/DataSources/EntityCluster.js:634–688  ·  view source on GitHub ↗
(
  collectionProperty,
  CollectionConstructor,
  unusedIndicesProperty,
  entityIndexProperty,
)

Source from the content-addressed store, hash-verified

632});
633
634function 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
690function removeEntityIndicesIfUnused(entityCluster, entityId) {
691 const indices = entityCluster._collectionIndicesByEntity[entityId];

Callers 1

EntityCluster.jsFile · 0.85

Calls 3

definedFunction · 0.50
getMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…