bruce-cesium 7.7.2 → 7.7.3
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 +140 -40
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +138 -38
- package/dist/bruce-cesium.umd.js.map +1 -1
- package/dist/lib/bruce-cesium.js +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 +1 -1
package/dist/bruce-cesium.umd.js
CHANGED
|
@@ -45481,6 +45481,45 @@
|
|
|
45481
45481
|
const hpr = Cesium.HeadingPitchRoll.fromDegrees(EnsureNumber(transform.heading), EnsureNumber(transform.pitch), EnsureNumber(transform.roll));
|
|
45482
45482
|
return Cesium.Matrix4.multiply(frame, Cesium.Matrix4.fromRotation(Cesium.Matrix3.fromHeadingPitchRoll(hpr)), frame);
|
|
45483
45483
|
}
|
|
45484
|
+
// Assembly parts are always drawn at the heights their records hold.
|
|
45485
|
+
const ASSEMBLY_HEIGHT_REFS = {
|
|
45486
|
+
point: Cesium.HeightReference.NONE,
|
|
45487
|
+
polyline: Cesium.HeightReference.NONE,
|
|
45488
|
+
polygon: Cesium.HeightReference.NONE
|
|
45489
|
+
};
|
|
45490
|
+
/*
|
|
45491
|
+
* Reads how an Entity Type's default Style draws its records, or null when the type cannot be read.
|
|
45492
|
+
*/
|
|
45493
|
+
async function getStyledHeightRefs(api, entityTypeId) {
|
|
45494
|
+
var _a, _b;
|
|
45495
|
+
let styleId;
|
|
45496
|
+
try {
|
|
45497
|
+
const { entityType } = await BModels.EntityType.Get({ api, entityTypeId });
|
|
45498
|
+
if (!entityType) {
|
|
45499
|
+
return null;
|
|
45500
|
+
}
|
|
45501
|
+
styleId = entityType["DisplaySetting.ID"];
|
|
45502
|
+
}
|
|
45503
|
+
catch (e) {
|
|
45504
|
+
console.error(e);
|
|
45505
|
+
return null;
|
|
45506
|
+
}
|
|
45507
|
+
let settings = {};
|
|
45508
|
+
if (styleId && styleId > 0) {
|
|
45509
|
+
try {
|
|
45510
|
+
settings = ((_b = (_a = (await BModels.Style.Get({ api, styleId })).style) === null || _a === void 0 ? void 0 : _a.Settings) !== null && _b !== void 0 ? _b : {});
|
|
45511
|
+
}
|
|
45512
|
+
catch (e) {
|
|
45513
|
+
// A deleted Style leaves the records drawn with the defaults, as the render engines do.
|
|
45514
|
+
console.error(e);
|
|
45515
|
+
}
|
|
45516
|
+
}
|
|
45517
|
+
return {
|
|
45518
|
+
point: exports.EntityRenderEngine.GetHeightRef(settings.pointStyle),
|
|
45519
|
+
polyline: exports.EntityRenderEngine.GetHeightRefPolyline(exports.EntityRenderEngine.GetHeightRef(settings.polylineStyle)),
|
|
45520
|
+
polygon: exports.EntityRenderEngine.GetHeightRef(settings.polygonStyle)
|
|
45521
|
+
};
|
|
45522
|
+
}
|
|
45484
45523
|
// Records created within about this long ago are the ones the oversized GeometryRadius bug could have written.
|
|
45485
45524
|
const GEOMETRY_RADIUS_SUSPECT_AGE_MS = 1000 * 60 * 60 * 24 * 183;
|
|
45486
45525
|
// Above this a recent record's radius is treated as that bug rather than a real size.
|
|
@@ -45916,6 +45955,44 @@
|
|
|
45916
45955
|
}
|
|
45917
45956
|
return [];
|
|
45918
45957
|
};
|
|
45958
|
+
// Entity Type ID -> how its default Style draws each kind of geometry, read once per call.
|
|
45959
|
+
const styledRefs = new Map();
|
|
45960
|
+
/*
|
|
45961
|
+
* How the scene would draw an undrawn record's geometry, or null to fall back to the sample's heightRef.
|
|
45962
|
+
*/
|
|
45963
|
+
const getStyledRefs = (entity) => {
|
|
45964
|
+
var _a, _b, _c;
|
|
45965
|
+
// Assembly parts are drawn at absolute heights whatever their type's Style says, read with a root or not.
|
|
45966
|
+
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)) {
|
|
45967
|
+
return Promise.resolve(ASSEMBLY_HEIGHT_REFS);
|
|
45968
|
+
}
|
|
45969
|
+
const typeId = (_c = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _c === void 0 ? void 0 : _c["EntityType.ID"];
|
|
45970
|
+
if (!api || !typeId) {
|
|
45971
|
+
return Promise.resolve(null);
|
|
45972
|
+
}
|
|
45973
|
+
if (!styledRefs.has(typeId)) {
|
|
45974
|
+
styledRefs.set(typeId, getStyledHeightRefs(api, typeId));
|
|
45975
|
+
}
|
|
45976
|
+
return styledRefs.get(typeId);
|
|
45977
|
+
};
|
|
45978
|
+
/*
|
|
45979
|
+
* Makes a record's positions absolute as a Style draws them, sampling terrain as none may be loaded there.
|
|
45980
|
+
*/
|
|
45981
|
+
const placeStyled = async (posses, heightRef, sample) => {
|
|
45982
|
+
if (heightRef != Cesium.HeightReference.NONE) {
|
|
45983
|
+
for (let i = 0; i < posses.length; i++) {
|
|
45984
|
+
const carto = Cesium.Cartographic.fromCartesian(posses[i]);
|
|
45985
|
+
if (!carto) {
|
|
45986
|
+
continue;
|
|
45987
|
+
}
|
|
45988
|
+
const { height: terrainHeight } = await exports.DrawingUtils.GetTerrainHeight({ pos3d: posses[i], viewer });
|
|
45989
|
+
const ground = EnsureNumber(terrainHeight, 0);
|
|
45990
|
+
carto.height = heightRef == Cesium.HeightReference.CLAMP_TO_GROUND ? ground : carto.height + ground;
|
|
45991
|
+
posses[i] = Cesium.Cartographic.toCartesian(carto);
|
|
45992
|
+
}
|
|
45993
|
+
}
|
|
45994
|
+
await ensureHeightRefs(posses, { ...sample, heightRef: Cesium.HeightReference.NONE });
|
|
45995
|
+
};
|
|
45919
45996
|
/**
|
|
45920
45997
|
* Returns an array of positions for a given sampled entity.
|
|
45921
45998
|
* This will include the location, and geometry positions.
|
|
@@ -45930,6 +46007,9 @@
|
|
|
45930
46007
|
*/
|
|
45931
46008
|
const evaluateRecord = async () => {
|
|
45932
46009
|
let posses = [];
|
|
46010
|
+
const refs = await getStyledRefs(entity);
|
|
46011
|
+
// The record's own point, kept apart so a Style can say what its altitude means.
|
|
46012
|
+
const pointPosses = [];
|
|
45933
46013
|
const location = BModels.Entity.GetValue({
|
|
45934
46014
|
entity: entity,
|
|
45935
46015
|
path: ["Bruce", "Location"]
|
|
@@ -45940,7 +46020,7 @@
|
|
|
45940
46020
|
// Disallowing 0.
|
|
45941
46021
|
if (latitude && longitude) {
|
|
45942
46022
|
const pos3d = Cesium.Cartesian3.fromDegrees(longitude, latitude, EnsureNumber(location.altitude));
|
|
45943
|
-
|
|
46023
|
+
pointPosses.push(pos3d);
|
|
45944
46024
|
}
|
|
45945
46025
|
}
|
|
45946
46026
|
const geometry = BModels.Entity.GetValue({
|
|
@@ -45956,7 +46036,7 @@
|
|
|
45956
46036
|
const point = points.length > 0 ? points[0] : null;
|
|
45957
46037
|
if (point && BModels.Carto.ValidateCarto(point)) {
|
|
45958
46038
|
const pos3d = Cesium.Cartesian3.fromDegrees(EnsureNumber(point.longitude), EnsureNumber(point.latitude), EnsureNumber(point.altitude));
|
|
45959
|
-
|
|
46039
|
+
pointPosses.push(pos3d);
|
|
45960
46040
|
}
|
|
45961
46041
|
}
|
|
45962
46042
|
const lineStr = geometry.LineString;
|
|
@@ -45964,7 +46044,12 @@
|
|
|
45964
46044
|
const points = BModels.Geometry.ParsePoints(lineStr);
|
|
45965
46045
|
if (points.length > 0) {
|
|
45966
46046
|
const pPosses = points.map(x => Cesium.Cartesian3.fromDegrees(EnsureNumber(x.longitude), EnsureNumber(x.latitude), EnsureNumber(x.altitude)));
|
|
45967
|
-
|
|
46047
|
+
if (refs) {
|
|
46048
|
+
await placeStyled(pPosses, refs.polyline, sample);
|
|
46049
|
+
}
|
|
46050
|
+
else {
|
|
46051
|
+
await ensureHeightRefs(pPosses, sample);
|
|
46052
|
+
}
|
|
45968
46053
|
posses = posses.concat(pPosses);
|
|
45969
46054
|
}
|
|
45970
46055
|
}
|
|
@@ -45974,7 +46059,12 @@
|
|
|
45974
46059
|
if (boundary === null || boundary === void 0 ? void 0 : boundary.LinearRing) {
|
|
45975
46060
|
const points = BModels.Geometry.ParsePoints(boundary.LinearRing);
|
|
45976
46061
|
const pPosses = points.map(x => Cesium.Cartesian3.fromDegrees(EnsureNumber(x.longitude), EnsureNumber(x.latitude), EnsureNumber(x.altitude)));
|
|
45977
|
-
|
|
46062
|
+
if (refs) {
|
|
46063
|
+
await placeStyled(pPosses, refs.polygon, sample);
|
|
46064
|
+
}
|
|
46065
|
+
else {
|
|
46066
|
+
await ensureHeightRefs(pPosses, sample);
|
|
46067
|
+
}
|
|
45978
46068
|
posses = posses.concat(pPosses);
|
|
45979
46069
|
}
|
|
45980
46070
|
}
|
|
@@ -45995,11 +46085,22 @@
|
|
|
45995
46085
|
Cesium.Cartesian3.fromDegrees(EnsureNumber(boundaries.minLongitude), EnsureNumber(boundaries.minLatitude), EnsureNumber(boundaries.minAltitude)),
|
|
45996
46086
|
Cesium.Cartesian3.fromDegrees(EnsureNumber(boundaries.maxLongitude), EnsureNumber(boundaries.maxLatitude), EnsureNumber(boundaries.maxAltitude))
|
|
45997
46087
|
];
|
|
45998
|
-
|
|
46088
|
+
if (refs) {
|
|
46089
|
+
// The bounds span the record's main geometry, so they are drawn the way it is.
|
|
46090
|
+
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;
|
|
46091
|
+
await placeStyled(bPosses, boundsRef, sample);
|
|
46092
|
+
}
|
|
46093
|
+
else {
|
|
46094
|
+
await ensureHeightRefs(bPosses, sample);
|
|
46095
|
+
}
|
|
45999
46096
|
posses = posses.concat(bPosses);
|
|
46000
46097
|
}
|
|
46001
46098
|
}
|
|
46002
|
-
|
|
46099
|
+
if (refs) {
|
|
46100
|
+
await placeStyled(pointPosses, refs.point, sample);
|
|
46101
|
+
}
|
|
46102
|
+
// Points first, since a lone record is placed by its first position.
|
|
46103
|
+
return pointPosses.concat(posses);
|
|
46003
46104
|
};
|
|
46004
46105
|
if (isAssemblyEntity) {
|
|
46005
46106
|
// See if we have tileset coords to use.
|
|
@@ -46158,6 +46259,8 @@
|
|
|
46158
46259
|
sample.entity = (_e = simulation === null || simulation === void 0 ? void 0 : simulation.GetEntity(sample.entityId)) !== null && _e !== void 0 ? _e : sample.entity;
|
|
46159
46260
|
}
|
|
46160
46261
|
}
|
|
46262
|
+
// Read here at the scene's time with their location; records a caller supplied may be of another time.
|
|
46263
|
+
const readHere = new Set();
|
|
46161
46264
|
// Bulk requesting Entity records.
|
|
46162
46265
|
try {
|
|
46163
46266
|
const toSearchIds = recordSamples.filter(x => !x.entity && x.entityId).map(x => x.entityId);
|
|
@@ -46179,6 +46282,9 @@
|
|
|
46179
46282
|
const sample = recordSamples[i];
|
|
46180
46283
|
if (!sample.entity && sample.entityId) {
|
|
46181
46284
|
const read = entitiesMap.get(sample.entityId);
|
|
46285
|
+
if (read) {
|
|
46286
|
+
readHere.add(sample.entityId);
|
|
46287
|
+
}
|
|
46182
46288
|
sample.entity = read && simulation ? simulation.Overlay(read) : read;
|
|
46183
46289
|
}
|
|
46184
46290
|
}
|
|
@@ -46189,10 +46295,10 @@
|
|
|
46189
46295
|
catch (e) {
|
|
46190
46296
|
console.error(e);
|
|
46191
46297
|
}
|
|
46192
|
-
//
|
|
46193
|
-
//
|
|
46298
|
+
// Assembly parts not read above with a location expand still need one, and the ones off the scene are dropped
|
|
46299
|
+
// when others are in it, since category nodes without geometry would otherwise pull the result elsewhere.
|
|
46194
46300
|
try {
|
|
46195
|
-
const
|
|
46301
|
+
const assemblySamples = recordSamples.filter(x => {
|
|
46196
46302
|
var _a;
|
|
46197
46303
|
// Expanding reads the API's record, which would replace the stand-in or undo the patch.
|
|
46198
46304
|
if (simulation === null || simulation === void 0 ? void 0 : simulation.HasBlob((_a = x.entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID)) {
|
|
@@ -46202,36 +46308,30 @@
|
|
|
46202
46308
|
entity: x.entity,
|
|
46203
46309
|
path: ["Bruce", "AssemblyPosition"]
|
|
46204
46310
|
});
|
|
46205
|
-
|
|
46206
|
-
return false;
|
|
46207
|
-
}
|
|
46208
|
-
const rootPos = BModels.Entity.GetValue({
|
|
46209
|
-
entity: x.entity,
|
|
46210
|
-
path: ["Bruce", "AssemblyRootPosition"]
|
|
46211
|
-
});
|
|
46212
|
-
return !rootPos;
|
|
46311
|
+
return !!assemblyPos;
|
|
46213
46312
|
});
|
|
46313
|
+
const isInScene = (sample) => {
|
|
46314
|
+
var _a;
|
|
46315
|
+
return !!(visualRegister && visualRegister.GetRego({
|
|
46316
|
+
entityId: (_a = sample.entityId) !== null && _a !== void 0 ? _a : sample.entity.Bruce.ID,
|
|
46317
|
+
menuItemId: sample.menuItemId
|
|
46318
|
+
}));
|
|
46319
|
+
};
|
|
46320
|
+
const sceneSamples = assemblySamples.filter(isInScene);
|
|
46321
|
+
const offSceneSamples = sceneSamples.length ? assemblySamples.filter(x => !isInScene(x)) : [];
|
|
46322
|
+
if (offSceneSamples.length) {
|
|
46323
|
+
const offSceneIds = new Set(offSceneSamples.map(x => x.entity.Bruce.ID));
|
|
46324
|
+
recordSamples = recordSamples.filter(x => !offSceneIds.has(x.entity.Bruce.ID));
|
|
46325
|
+
}
|
|
46326
|
+
const keptSamples = sceneSamples.length ? sceneSamples : assemblySamples;
|
|
46327
|
+
const needsExpansion = keptSamples.filter(x => !readHere.has(x.entity.Bruce.ID) || !BModels.Entity.GetValue({
|
|
46328
|
+
entity: x.entity,
|
|
46329
|
+
path: ["Bruce", "AssemblyRootLocation"]
|
|
46330
|
+
}));
|
|
46214
46331
|
if (needsExpansion.length) {
|
|
46215
46332
|
const EXPAND_BATCH_SIZE = 30;
|
|
46216
46333
|
const EXPAND_MAX_IDS = 200;
|
|
46217
|
-
|
|
46218
|
-
// Helps us sort leaf-nodes away from category nodes thta don't have geometry.
|
|
46219
|
-
const isInScene = (sample) => {
|
|
46220
|
-
var _a;
|
|
46221
|
-
return !!(visualRegister && visualRegister.GetRego({
|
|
46222
|
-
entityId: (_a = sample.entityId) !== null && _a !== void 0 ? _a : sample.entity.Bruce.ID,
|
|
46223
|
-
menuItemId: sample.menuItemId
|
|
46224
|
-
}));
|
|
46225
|
-
};
|
|
46226
|
-
// Trim to max 200 with a preference to those in the scene.
|
|
46227
|
-
const sceneSamples = needsExpansion.filter(isInScene);
|
|
46228
|
-
const offSceneSamples = sceneSamples.length ? needsExpansion.filter(x => !isInScene(x)) : [];
|
|
46229
|
-
if (offSceneSamples.length) {
|
|
46230
|
-
const offSceneIds = new Set(offSceneSamples.map(x => x.entity.Bruce.ID));
|
|
46231
|
-
recordSamples = recordSamples.filter(x => !offSceneIds.has(x.entity.Bruce.ID));
|
|
46232
|
-
}
|
|
46233
|
-
const effectiveSamples = sceneSamples.length ? sceneSamples : needsExpansion;
|
|
46234
|
-
const uniqueIds = Array.from(new Set(effectiveSamples.map(x => x.entity.Bruce.ID)));
|
|
46334
|
+
const uniqueIds = Array.from(new Set(needsExpansion.map(x => x.entity.Bruce.ID)));
|
|
46235
46335
|
const expandIds = uniqueIds.slice(0, EXPAND_MAX_IDS);
|
|
46236
46336
|
// Anything we didn't expand will taint the overall result so we have to filter them out.
|
|
46237
46337
|
const droppedIds = new Set(uniqueIds.slice(EXPAND_MAX_IDS));
|
|
@@ -46260,8 +46360,8 @@
|
|
|
46260
46360
|
expandedMap.set(entities[i].Bruce.ID, entities[i]);
|
|
46261
46361
|
}
|
|
46262
46362
|
}
|
|
46263
|
-
for (let i = 0; i <
|
|
46264
|
-
const sample =
|
|
46363
|
+
for (let i = 0; i < needsExpansion.length; i++) {
|
|
46364
|
+
const sample = needsExpansion[i];
|
|
46265
46365
|
const expanded = expandedMap.get(sample.entity.Bruce.ID);
|
|
46266
46366
|
if (expanded) {
|
|
46267
46367
|
sample.entity = expanded;
|
|
@@ -57015,7 +57115,7 @@ void main() {
|
|
|
57015
57115
|
StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
|
|
57016
57116
|
})(exports.StyleUtils || (exports.StyleUtils = {}));
|
|
57017
57117
|
|
|
57018
|
-
const VERSION = "7.7.
|
|
57118
|
+
const VERSION = "7.7.3";
|
|
57019
57119
|
/**
|
|
57020
57120
|
* Updates the environment instance used by bruce-cesium to one specified.
|
|
57021
57121
|
* This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.
|