bruce-cesium 7.7.2 → 7.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bruce-cesium.es5.js +155 -48
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +153 -46
- package/dist/bruce-cesium.umd.js.map +1 -1
- package/dist/lib/bruce-cesium.js +1 -1
- package/dist/lib/rendering/xgrids-render-engine.js +15 -8
- package/dist/lib/rendering/xgrids-render-engine.js.map +1 -1
- package/dist/lib/utils/entity-utils.js +138 -37
- package/dist/lib/utils/entity-utils.js.map +1 -1
- package/dist/types/bruce-cesium.d.ts +1 -1
- package/package.json +2 -2
package/dist/lib/bruce-cesium.js
CHANGED
|
@@ -92,7 +92,7 @@ __exportStar(require("./widgets/widget-info-view"), exports);
|
|
|
92
92
|
__exportStar(require("./widgets/widget-left-panel"), exports);
|
|
93
93
|
__exportStar(require("./widgets/widget-nav-compass"), exports);
|
|
94
94
|
__exportStar(require("./widgets/widget-view-bar"), exports);
|
|
95
|
-
exports.VERSION = "7.7.
|
|
95
|
+
exports.VERSION = "7.7.4";
|
|
96
96
|
/**
|
|
97
97
|
* Updates the environment instance used by bruce-cesium to one specified.
|
|
98
98
|
* This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.
|
|
@@ -74,14 +74,12 @@ var XGridsRenderEngine;
|
|
|
74
74
|
var _a, _b;
|
|
75
75
|
// Array index is the LOD level, ie: index 0 = LOD 0.
|
|
76
76
|
const lods = obj.getLodInfos();
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
console.warn("Reduced splat quality due to the number of splats being too large. Was: \"" + maxSplats + "\", now is: \"" + HARD_MAX + "\".");
|
|
84
|
-
}
|
|
77
|
+
const maxSplats = 6000000;
|
|
78
|
+
// LCC 0.5.4 fixes the LOD when the budget exceeds LOD 1, leaving distant splats sparse.
|
|
79
|
+
const lodBudget = (lods === null || lods === void 0 ? void 0 : lods[0]) > maxSplats && (lods === null || lods === void 0 ? void 0 : lods[1]) > 0
|
|
80
|
+
? Math.min(maxSplats, lods[1])
|
|
81
|
+
: maxSplats;
|
|
82
|
+
obj.setMaxSplats(lodBudget);
|
|
85
83
|
// Auto fly to.
|
|
86
84
|
if (params.flyTo) {
|
|
87
85
|
const pos3d = (_b = (_a = obj === null || obj === void 0 ? void 0 : obj.getBounds) === null || _a === void 0 ? void 0 : _a.call(obj)) === null || _b === void 0 ? void 0 : _b.origin;
|
|
@@ -102,6 +100,15 @@ var XGridsRenderEngine;
|
|
|
102
100
|
}
|
|
103
101
|
}
|
|
104
102
|
});
|
|
103
|
+
if (typeof (obj === null || obj === void 0 ? void 0 : obj.setRenderState) === "function") {
|
|
104
|
+
// Splats must respect nearer meshes already drawn in the same Cesium pass.
|
|
105
|
+
obj.setRenderState({
|
|
106
|
+
depthTest: {
|
|
107
|
+
enabled: true,
|
|
108
|
+
func: Cesium.WebGLConstants.LEQUAL
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
105
112
|
if (typeof (obj === null || obj === void 0 ? void 0 : obj.setVisible) === "function") {
|
|
106
113
|
obj.setVisible(true);
|
|
107
114
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xgrids-render-engine.js","sourceRoot":"","sources":["../../../src/rendering/xgrids-render-engine.ts"],"names":[],"mappings":";;;AAAA,+CAAyD;AACzD,iCAAiC;AACjC,mDAAoD;AACpD,0DAAsD;AACtD,mEAA8D;AAK9D;;GAEG;AACH,IAAiB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"xgrids-render-engine.js","sourceRoot":"","sources":["../../../src/rendering/xgrids-render-engine.ts"],"names":[],"mappings":";;;AAAA,+CAAyD;AACzD,iCAAiC;AACjC,mDAAoD;AACpD,0DAAsD;AACtD,mEAA8D;AAK9D;;GAEG;AACH,IAAiB,kBAAkB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IACL,CAAC;IAvCe,gCAAa,gBAuC5B,CAAA;AACL,CAAC,EArMgB,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAqMlC"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.EntityUtils = void 0;
|
|
4
4
|
const bruce_models_1 = require("bruce-models");
|
|
5
5
|
const Cesium = require("cesium");
|
|
6
|
+
const entity_render_engine_1 = require("../rendering/entity-render-engine");
|
|
6
7
|
const drawing_utils_1 = require("./drawing-utils");
|
|
7
8
|
const measure_utils_1 = require("./measure-utils");
|
|
8
9
|
const js_utils_1 = require("../internal/js-utils");
|
|
@@ -167,6 +168,45 @@ function calcAssemblyRootFrame(entity, modelSpace) {
|
|
|
167
168
|
const hpr = Cesium.HeadingPitchRoll.fromDegrees((0, js_utils_1.EnsureNumber)(transform.heading), (0, js_utils_1.EnsureNumber)(transform.pitch), (0, js_utils_1.EnsureNumber)(transform.roll));
|
|
168
169
|
return Cesium.Matrix4.multiply(frame, Cesium.Matrix4.fromRotation(Cesium.Matrix3.fromHeadingPitchRoll(hpr)), frame);
|
|
169
170
|
}
|
|
171
|
+
// Assembly parts are always drawn at the heights their records hold.
|
|
172
|
+
const ASSEMBLY_HEIGHT_REFS = {
|
|
173
|
+
point: Cesium.HeightReference.NONE,
|
|
174
|
+
polyline: Cesium.HeightReference.NONE,
|
|
175
|
+
polygon: Cesium.HeightReference.NONE
|
|
176
|
+
};
|
|
177
|
+
/*
|
|
178
|
+
* Reads how an Entity Type's default Style draws its records, or null when the type cannot be read.
|
|
179
|
+
*/
|
|
180
|
+
async function getStyledHeightRefs(api, entityTypeId) {
|
|
181
|
+
var _a, _b;
|
|
182
|
+
let styleId;
|
|
183
|
+
try {
|
|
184
|
+
const { entityType } = await bruce_models_1.EntityType.Get({ api, entityTypeId });
|
|
185
|
+
if (!entityType) {
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
styleId = entityType["DisplaySetting.ID"];
|
|
189
|
+
}
|
|
190
|
+
catch (e) {
|
|
191
|
+
console.error(e);
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
let settings = {};
|
|
195
|
+
if (styleId && styleId > 0) {
|
|
196
|
+
try {
|
|
197
|
+
settings = ((_b = (_a = (await bruce_models_1.Style.Get({ api, styleId })).style) === null || _a === void 0 ? void 0 : _a.Settings) !== null && _b !== void 0 ? _b : {});
|
|
198
|
+
}
|
|
199
|
+
catch (e) {
|
|
200
|
+
// A deleted Style leaves the records drawn with the defaults, as the render engines do.
|
|
201
|
+
console.error(e);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return {
|
|
205
|
+
point: entity_render_engine_1.EntityRenderEngine.GetHeightRef(settings.pointStyle),
|
|
206
|
+
polyline: entity_render_engine_1.EntityRenderEngine.GetHeightRefPolyline(entity_render_engine_1.EntityRenderEngine.GetHeightRef(settings.polylineStyle)),
|
|
207
|
+
polygon: entity_render_engine_1.EntityRenderEngine.GetHeightRef(settings.polygonStyle)
|
|
208
|
+
};
|
|
209
|
+
}
|
|
170
210
|
// Records created within about this long ago are the ones the oversized GeometryRadius bug could have written.
|
|
171
211
|
const GEOMETRY_RADIUS_SUSPECT_AGE_MS = 1000 * 60 * 60 * 24 * 183;
|
|
172
212
|
// Above this a recent record's radius is treated as that bug rather than a real size.
|
|
@@ -603,6 +643,44 @@ var EntityUtils;
|
|
|
603
643
|
}
|
|
604
644
|
return [];
|
|
605
645
|
};
|
|
646
|
+
// Entity Type ID -> how its default Style draws each kind of geometry, read once per call.
|
|
647
|
+
const styledRefs = new Map();
|
|
648
|
+
/*
|
|
649
|
+
* How the scene would draw an undrawn record's geometry, or null to fall back to the sample's heightRef.
|
|
650
|
+
*/
|
|
651
|
+
const getStyledRefs = (entity) => {
|
|
652
|
+
var _a, _b, _c;
|
|
653
|
+
// Assembly parts are drawn at absolute heights whatever their type's Style says, read with a root or not.
|
|
654
|
+
if (((_a = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _a === void 0 ? void 0 : _a.AssemblyPosition) || ((_b = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _b === void 0 ? void 0 : _b.AssemblyRootLocation)) {
|
|
655
|
+
return Promise.resolve(ASSEMBLY_HEIGHT_REFS);
|
|
656
|
+
}
|
|
657
|
+
const typeId = (_c = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _c === void 0 ? void 0 : _c["EntityType.ID"];
|
|
658
|
+
if (!api || !typeId) {
|
|
659
|
+
return Promise.resolve(null);
|
|
660
|
+
}
|
|
661
|
+
if (!styledRefs.has(typeId)) {
|
|
662
|
+
styledRefs.set(typeId, getStyledHeightRefs(api, typeId));
|
|
663
|
+
}
|
|
664
|
+
return styledRefs.get(typeId);
|
|
665
|
+
};
|
|
666
|
+
/*
|
|
667
|
+
* Makes a record's positions absolute as a Style draws them, sampling terrain as none may be loaded there.
|
|
668
|
+
*/
|
|
669
|
+
const placeStyled = async (posses, heightRef, sample) => {
|
|
670
|
+
if (heightRef != Cesium.HeightReference.NONE) {
|
|
671
|
+
for (let i = 0; i < posses.length; i++) {
|
|
672
|
+
const carto = Cesium.Cartographic.fromCartesian(posses[i]);
|
|
673
|
+
if (!carto) {
|
|
674
|
+
continue;
|
|
675
|
+
}
|
|
676
|
+
const { height: terrainHeight } = await drawing_utils_1.DrawingUtils.GetTerrainHeight({ pos3d: posses[i], viewer });
|
|
677
|
+
const ground = (0, js_utils_1.EnsureNumber)(terrainHeight, 0);
|
|
678
|
+
carto.height = heightRef == Cesium.HeightReference.CLAMP_TO_GROUND ? ground : carto.height + ground;
|
|
679
|
+
posses[i] = Cesium.Cartographic.toCartesian(carto);
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
await ensureHeightRefs(posses, { ...sample, heightRef: Cesium.HeightReference.NONE });
|
|
683
|
+
};
|
|
606
684
|
/**
|
|
607
685
|
* Returns an array of positions for a given sampled entity.
|
|
608
686
|
* This will include the location, and geometry positions.
|
|
@@ -617,6 +695,9 @@ var EntityUtils;
|
|
|
617
695
|
*/
|
|
618
696
|
const evaluateRecord = async () => {
|
|
619
697
|
let posses = [];
|
|
698
|
+
const refs = await getStyledRefs(entity);
|
|
699
|
+
// The record's own point, kept apart so a Style can say what its altitude means.
|
|
700
|
+
const pointPosses = [];
|
|
620
701
|
const location = bruce_models_1.Entity.GetValue({
|
|
621
702
|
entity: entity,
|
|
622
703
|
path: ["Bruce", "Location"]
|
|
@@ -627,7 +708,7 @@ var EntityUtils;
|
|
|
627
708
|
// Disallowing 0.
|
|
628
709
|
if (latitude && longitude) {
|
|
629
710
|
const pos3d = Cesium.Cartesian3.fromDegrees(longitude, latitude, (0, js_utils_1.EnsureNumber)(location.altitude));
|
|
630
|
-
|
|
711
|
+
pointPosses.push(pos3d);
|
|
631
712
|
}
|
|
632
713
|
}
|
|
633
714
|
const geometry = bruce_models_1.Entity.GetValue({
|
|
@@ -643,7 +724,7 @@ var EntityUtils;
|
|
|
643
724
|
const point = points.length > 0 ? points[0] : null;
|
|
644
725
|
if (point && bruce_models_1.Carto.ValidateCarto(point)) {
|
|
645
726
|
const pos3d = Cesium.Cartesian3.fromDegrees((0, js_utils_1.EnsureNumber)(point.longitude), (0, js_utils_1.EnsureNumber)(point.latitude), (0, js_utils_1.EnsureNumber)(point.altitude));
|
|
646
|
-
|
|
727
|
+
pointPosses.push(pos3d);
|
|
647
728
|
}
|
|
648
729
|
}
|
|
649
730
|
const lineStr = geometry.LineString;
|
|
@@ -651,7 +732,12 @@ var EntityUtils;
|
|
|
651
732
|
const points = bruce_models_1.Geometry.ParsePoints(lineStr);
|
|
652
733
|
if (points.length > 0) {
|
|
653
734
|
const pPosses = points.map(x => Cesium.Cartesian3.fromDegrees((0, js_utils_1.EnsureNumber)(x.longitude), (0, js_utils_1.EnsureNumber)(x.latitude), (0, js_utils_1.EnsureNumber)(x.altitude)));
|
|
654
|
-
|
|
735
|
+
if (refs) {
|
|
736
|
+
await placeStyled(pPosses, refs.polyline, sample);
|
|
737
|
+
}
|
|
738
|
+
else {
|
|
739
|
+
await ensureHeightRefs(pPosses, sample);
|
|
740
|
+
}
|
|
655
741
|
posses = posses.concat(pPosses);
|
|
656
742
|
}
|
|
657
743
|
}
|
|
@@ -661,7 +747,12 @@ var EntityUtils;
|
|
|
661
747
|
if (boundary === null || boundary === void 0 ? void 0 : boundary.LinearRing) {
|
|
662
748
|
const points = bruce_models_1.Geometry.ParsePoints(boundary.LinearRing);
|
|
663
749
|
const pPosses = points.map(x => Cesium.Cartesian3.fromDegrees((0, js_utils_1.EnsureNumber)(x.longitude), (0, js_utils_1.EnsureNumber)(x.latitude), (0, js_utils_1.EnsureNumber)(x.altitude)));
|
|
664
|
-
|
|
750
|
+
if (refs) {
|
|
751
|
+
await placeStyled(pPosses, refs.polygon, sample);
|
|
752
|
+
}
|
|
753
|
+
else {
|
|
754
|
+
await ensureHeightRefs(pPosses, sample);
|
|
755
|
+
}
|
|
665
756
|
posses = posses.concat(pPosses);
|
|
666
757
|
}
|
|
667
758
|
}
|
|
@@ -682,11 +773,22 @@ var EntityUtils;
|
|
|
682
773
|
Cesium.Cartesian3.fromDegrees((0, js_utils_1.EnsureNumber)(boundaries.minLongitude), (0, js_utils_1.EnsureNumber)(boundaries.minLatitude), (0, js_utils_1.EnsureNumber)(boundaries.minAltitude)),
|
|
683
774
|
Cesium.Cartesian3.fromDegrees((0, js_utils_1.EnsureNumber)(boundaries.maxLongitude), (0, js_utils_1.EnsureNumber)(boundaries.maxLatitude), (0, js_utils_1.EnsureNumber)(boundaries.maxAltitude))
|
|
684
775
|
];
|
|
685
|
-
|
|
776
|
+
if (refs) {
|
|
777
|
+
// The bounds span the record's main geometry, so they are drawn the way it is.
|
|
778
|
+
const boundsRef = (geometry === null || geometry === void 0 ? void 0 : geometry.Polygon) ? refs.polygon : (geometry === null || geometry === void 0 ? void 0 : geometry.LineString) ? refs.polyline : refs.point;
|
|
779
|
+
await placeStyled(bPosses, boundsRef, sample);
|
|
780
|
+
}
|
|
781
|
+
else {
|
|
782
|
+
await ensureHeightRefs(bPosses, sample);
|
|
783
|
+
}
|
|
686
784
|
posses = posses.concat(bPosses);
|
|
687
785
|
}
|
|
688
786
|
}
|
|
689
|
-
|
|
787
|
+
if (refs) {
|
|
788
|
+
await placeStyled(pointPosses, refs.point, sample);
|
|
789
|
+
}
|
|
790
|
+
// Points first, since a lone record is placed by its first position.
|
|
791
|
+
return pointPosses.concat(posses);
|
|
690
792
|
};
|
|
691
793
|
if (isAssemblyEntity) {
|
|
692
794
|
// See if we have tileset coords to use.
|
|
@@ -845,6 +947,8 @@ var EntityUtils;
|
|
|
845
947
|
sample.entity = (_e = simulation === null || simulation === void 0 ? void 0 : simulation.GetEntity(sample.entityId)) !== null && _e !== void 0 ? _e : sample.entity;
|
|
846
948
|
}
|
|
847
949
|
}
|
|
950
|
+
// Read here at the scene's time with their location; records a caller supplied may be of another time.
|
|
951
|
+
const readHere = new Set();
|
|
848
952
|
// Bulk requesting Entity records.
|
|
849
953
|
try {
|
|
850
954
|
const toSearchIds = recordSamples.filter(x => !x.entity && x.entityId).map(x => x.entityId);
|
|
@@ -866,6 +970,9 @@ var EntityUtils;
|
|
|
866
970
|
const sample = recordSamples[i];
|
|
867
971
|
if (!sample.entity && sample.entityId) {
|
|
868
972
|
const read = entitiesMap.get(sample.entityId);
|
|
973
|
+
if (read) {
|
|
974
|
+
readHere.add(sample.entityId);
|
|
975
|
+
}
|
|
869
976
|
sample.entity = read && simulation ? simulation.Overlay(read) : read;
|
|
870
977
|
}
|
|
871
978
|
}
|
|
@@ -876,10 +983,10 @@ var EntityUtils;
|
|
|
876
983
|
catch (e) {
|
|
877
984
|
console.error(e);
|
|
878
985
|
}
|
|
879
|
-
//
|
|
880
|
-
//
|
|
986
|
+
// Assembly parts not read above with a location expand still need one, and the ones off the scene are dropped
|
|
987
|
+
// when others are in it, since category nodes without geometry would otherwise pull the result elsewhere.
|
|
881
988
|
try {
|
|
882
|
-
const
|
|
989
|
+
const assemblySamples = recordSamples.filter(x => {
|
|
883
990
|
var _a;
|
|
884
991
|
// Expanding reads the API's record, which would replace the stand-in or undo the patch.
|
|
885
992
|
if (simulation === null || simulation === void 0 ? void 0 : simulation.HasBlob((_a = x.entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID)) {
|
|
@@ -889,36 +996,30 @@ var EntityUtils;
|
|
|
889
996
|
entity: x.entity,
|
|
890
997
|
path: ["Bruce", "AssemblyPosition"]
|
|
891
998
|
});
|
|
892
|
-
|
|
893
|
-
return false;
|
|
894
|
-
}
|
|
895
|
-
const rootPos = bruce_models_1.Entity.GetValue({
|
|
896
|
-
entity: x.entity,
|
|
897
|
-
path: ["Bruce", "AssemblyRootPosition"]
|
|
898
|
-
});
|
|
899
|
-
return !rootPos;
|
|
999
|
+
return !!assemblyPos;
|
|
900
1000
|
});
|
|
1001
|
+
const isInScene = (sample) => {
|
|
1002
|
+
var _a;
|
|
1003
|
+
return !!(visualRegister && visualRegister.GetRego({
|
|
1004
|
+
entityId: (_a = sample.entityId) !== null && _a !== void 0 ? _a : sample.entity.Bruce.ID,
|
|
1005
|
+
menuItemId: sample.menuItemId
|
|
1006
|
+
}));
|
|
1007
|
+
};
|
|
1008
|
+
const sceneSamples = assemblySamples.filter(isInScene);
|
|
1009
|
+
const offSceneSamples = sceneSamples.length ? assemblySamples.filter(x => !isInScene(x)) : [];
|
|
1010
|
+
if (offSceneSamples.length) {
|
|
1011
|
+
const offSceneIds = new Set(offSceneSamples.map(x => x.entity.Bruce.ID));
|
|
1012
|
+
recordSamples = recordSamples.filter(x => !offSceneIds.has(x.entity.Bruce.ID));
|
|
1013
|
+
}
|
|
1014
|
+
const keptSamples = sceneSamples.length ? sceneSamples : assemblySamples;
|
|
1015
|
+
const needsExpansion = keptSamples.filter(x => !readHere.has(x.entity.Bruce.ID) || !bruce_models_1.Entity.GetValue({
|
|
1016
|
+
entity: x.entity,
|
|
1017
|
+
path: ["Bruce", "AssemblyRootLocation"]
|
|
1018
|
+
}));
|
|
901
1019
|
if (needsExpansion.length) {
|
|
902
1020
|
const EXPAND_BATCH_SIZE = 30;
|
|
903
1021
|
const EXPAND_MAX_IDS = 200;
|
|
904
|
-
|
|
905
|
-
// Helps us sort leaf-nodes away from category nodes thta don't have geometry.
|
|
906
|
-
const isInScene = (sample) => {
|
|
907
|
-
var _a;
|
|
908
|
-
return !!(visualRegister && visualRegister.GetRego({
|
|
909
|
-
entityId: (_a = sample.entityId) !== null && _a !== void 0 ? _a : sample.entity.Bruce.ID,
|
|
910
|
-
menuItemId: sample.menuItemId
|
|
911
|
-
}));
|
|
912
|
-
};
|
|
913
|
-
// Trim to max 200 with a preference to those in the scene.
|
|
914
|
-
const sceneSamples = needsExpansion.filter(isInScene);
|
|
915
|
-
const offSceneSamples = sceneSamples.length ? needsExpansion.filter(x => !isInScene(x)) : [];
|
|
916
|
-
if (offSceneSamples.length) {
|
|
917
|
-
const offSceneIds = new Set(offSceneSamples.map(x => x.entity.Bruce.ID));
|
|
918
|
-
recordSamples = recordSamples.filter(x => !offSceneIds.has(x.entity.Bruce.ID));
|
|
919
|
-
}
|
|
920
|
-
const effectiveSamples = sceneSamples.length ? sceneSamples : needsExpansion;
|
|
921
|
-
const uniqueIds = Array.from(new Set(effectiveSamples.map(x => x.entity.Bruce.ID)));
|
|
1022
|
+
const uniqueIds = Array.from(new Set(needsExpansion.map(x => x.entity.Bruce.ID)));
|
|
922
1023
|
const expandIds = uniqueIds.slice(0, EXPAND_MAX_IDS);
|
|
923
1024
|
// Anything we didn't expand will taint the overall result so we have to filter them out.
|
|
924
1025
|
const droppedIds = new Set(uniqueIds.slice(EXPAND_MAX_IDS));
|
|
@@ -947,8 +1048,8 @@ var EntityUtils;
|
|
|
947
1048
|
expandedMap.set(entities[i].Bruce.ID, entities[i]);
|
|
948
1049
|
}
|
|
949
1050
|
}
|
|
950
|
-
for (let i = 0; i <
|
|
951
|
-
const sample =
|
|
1051
|
+
for (let i = 0; i < needsExpansion.length; i++) {
|
|
1052
|
+
const sample = needsExpansion[i];
|
|
952
1053
|
const expanded = expandedMap.get(sample.entity.Bruce.ID);
|
|
953
1054
|
if (expanded) {
|
|
954
1055
|
sample.entity = expanded;
|