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/bruce-cesium.umd.js
CHANGED
|
@@ -28173,14 +28173,12 @@
|
|
|
28173
28173
|
var _a, _b;
|
|
28174
28174
|
// Array index is the LOD level, ie: index 0 = LOD 0.
|
|
28175
28175
|
const lods = obj.getLodInfos();
|
|
28176
|
-
|
|
28177
|
-
|
|
28178
|
-
const
|
|
28179
|
-
|
|
28180
|
-
|
|
28181
|
-
|
|
28182
|
-
console.warn("Reduced splat quality due to the number of splats being too large. Was: \"" + maxSplats + "\", now is: \"" + HARD_MAX + "\".");
|
|
28183
|
-
}
|
|
28176
|
+
const maxSplats = 6000000;
|
|
28177
|
+
// LCC 0.5.4 fixes the LOD when the budget exceeds LOD 1, leaving distant splats sparse.
|
|
28178
|
+
const lodBudget = (lods === null || lods === void 0 ? void 0 : lods[0]) > maxSplats && (lods === null || lods === void 0 ? void 0 : lods[1]) > 0
|
|
28179
|
+
? Math.min(maxSplats, lods[1])
|
|
28180
|
+
: maxSplats;
|
|
28181
|
+
obj.setMaxSplats(lodBudget);
|
|
28184
28182
|
// Auto fly to.
|
|
28185
28183
|
if (params.flyTo) {
|
|
28186
28184
|
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;
|
|
@@ -28201,6 +28199,15 @@
|
|
|
28201
28199
|
}
|
|
28202
28200
|
}
|
|
28203
28201
|
});
|
|
28202
|
+
if (typeof (obj === null || obj === void 0 ? void 0 : obj.setRenderState) === "function") {
|
|
28203
|
+
// Splats must respect nearer meshes already drawn in the same Cesium pass.
|
|
28204
|
+
obj.setRenderState({
|
|
28205
|
+
depthTest: {
|
|
28206
|
+
enabled: true,
|
|
28207
|
+
func: Cesium.WebGLConstants.LEQUAL
|
|
28208
|
+
}
|
|
28209
|
+
});
|
|
28210
|
+
}
|
|
28204
28211
|
if (typeof (obj === null || obj === void 0 ? void 0 : obj.setVisible) === "function") {
|
|
28205
28212
|
obj.setVisible(true);
|
|
28206
28213
|
}
|
|
@@ -45481,6 +45488,45 @@
|
|
|
45481
45488
|
const hpr = Cesium.HeadingPitchRoll.fromDegrees(EnsureNumber(transform.heading), EnsureNumber(transform.pitch), EnsureNumber(transform.roll));
|
|
45482
45489
|
return Cesium.Matrix4.multiply(frame, Cesium.Matrix4.fromRotation(Cesium.Matrix3.fromHeadingPitchRoll(hpr)), frame);
|
|
45483
45490
|
}
|
|
45491
|
+
// Assembly parts are always drawn at the heights their records hold.
|
|
45492
|
+
const ASSEMBLY_HEIGHT_REFS = {
|
|
45493
|
+
point: Cesium.HeightReference.NONE,
|
|
45494
|
+
polyline: Cesium.HeightReference.NONE,
|
|
45495
|
+
polygon: Cesium.HeightReference.NONE
|
|
45496
|
+
};
|
|
45497
|
+
/*
|
|
45498
|
+
* Reads how an Entity Type's default Style draws its records, or null when the type cannot be read.
|
|
45499
|
+
*/
|
|
45500
|
+
async function getStyledHeightRefs(api, entityTypeId) {
|
|
45501
|
+
var _a, _b;
|
|
45502
|
+
let styleId;
|
|
45503
|
+
try {
|
|
45504
|
+
const { entityType } = await BModels.EntityType.Get({ api, entityTypeId });
|
|
45505
|
+
if (!entityType) {
|
|
45506
|
+
return null;
|
|
45507
|
+
}
|
|
45508
|
+
styleId = entityType["DisplaySetting.ID"];
|
|
45509
|
+
}
|
|
45510
|
+
catch (e) {
|
|
45511
|
+
console.error(e);
|
|
45512
|
+
return null;
|
|
45513
|
+
}
|
|
45514
|
+
let settings = {};
|
|
45515
|
+
if (styleId && styleId > 0) {
|
|
45516
|
+
try {
|
|
45517
|
+
settings = ((_b = (_a = (await BModels.Style.Get({ api, styleId })).style) === null || _a === void 0 ? void 0 : _a.Settings) !== null && _b !== void 0 ? _b : {});
|
|
45518
|
+
}
|
|
45519
|
+
catch (e) {
|
|
45520
|
+
// A deleted Style leaves the records drawn with the defaults, as the render engines do.
|
|
45521
|
+
console.error(e);
|
|
45522
|
+
}
|
|
45523
|
+
}
|
|
45524
|
+
return {
|
|
45525
|
+
point: exports.EntityRenderEngine.GetHeightRef(settings.pointStyle),
|
|
45526
|
+
polyline: exports.EntityRenderEngine.GetHeightRefPolyline(exports.EntityRenderEngine.GetHeightRef(settings.polylineStyle)),
|
|
45527
|
+
polygon: exports.EntityRenderEngine.GetHeightRef(settings.polygonStyle)
|
|
45528
|
+
};
|
|
45529
|
+
}
|
|
45484
45530
|
// Records created within about this long ago are the ones the oversized GeometryRadius bug could have written.
|
|
45485
45531
|
const GEOMETRY_RADIUS_SUSPECT_AGE_MS = 1000 * 60 * 60 * 24 * 183;
|
|
45486
45532
|
// Above this a recent record's radius is treated as that bug rather than a real size.
|
|
@@ -45916,6 +45962,44 @@
|
|
|
45916
45962
|
}
|
|
45917
45963
|
return [];
|
|
45918
45964
|
};
|
|
45965
|
+
// Entity Type ID -> how its default Style draws each kind of geometry, read once per call.
|
|
45966
|
+
const styledRefs = new Map();
|
|
45967
|
+
/*
|
|
45968
|
+
* How the scene would draw an undrawn record's geometry, or null to fall back to the sample's heightRef.
|
|
45969
|
+
*/
|
|
45970
|
+
const getStyledRefs = (entity) => {
|
|
45971
|
+
var _a, _b, _c;
|
|
45972
|
+
// Assembly parts are drawn at absolute heights whatever their type's Style says, read with a root or not.
|
|
45973
|
+
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)) {
|
|
45974
|
+
return Promise.resolve(ASSEMBLY_HEIGHT_REFS);
|
|
45975
|
+
}
|
|
45976
|
+
const typeId = (_c = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _c === void 0 ? void 0 : _c["EntityType.ID"];
|
|
45977
|
+
if (!api || !typeId) {
|
|
45978
|
+
return Promise.resolve(null);
|
|
45979
|
+
}
|
|
45980
|
+
if (!styledRefs.has(typeId)) {
|
|
45981
|
+
styledRefs.set(typeId, getStyledHeightRefs(api, typeId));
|
|
45982
|
+
}
|
|
45983
|
+
return styledRefs.get(typeId);
|
|
45984
|
+
};
|
|
45985
|
+
/*
|
|
45986
|
+
* Makes a record's positions absolute as a Style draws them, sampling terrain as none may be loaded there.
|
|
45987
|
+
*/
|
|
45988
|
+
const placeStyled = async (posses, heightRef, sample) => {
|
|
45989
|
+
if (heightRef != Cesium.HeightReference.NONE) {
|
|
45990
|
+
for (let i = 0; i < posses.length; i++) {
|
|
45991
|
+
const carto = Cesium.Cartographic.fromCartesian(posses[i]);
|
|
45992
|
+
if (!carto) {
|
|
45993
|
+
continue;
|
|
45994
|
+
}
|
|
45995
|
+
const { height: terrainHeight } = await exports.DrawingUtils.GetTerrainHeight({ pos3d: posses[i], viewer });
|
|
45996
|
+
const ground = EnsureNumber(terrainHeight, 0);
|
|
45997
|
+
carto.height = heightRef == Cesium.HeightReference.CLAMP_TO_GROUND ? ground : carto.height + ground;
|
|
45998
|
+
posses[i] = Cesium.Cartographic.toCartesian(carto);
|
|
45999
|
+
}
|
|
46000
|
+
}
|
|
46001
|
+
await ensureHeightRefs(posses, { ...sample, heightRef: Cesium.HeightReference.NONE });
|
|
46002
|
+
};
|
|
45919
46003
|
/**
|
|
45920
46004
|
* Returns an array of positions for a given sampled entity.
|
|
45921
46005
|
* This will include the location, and geometry positions.
|
|
@@ -45930,6 +46014,9 @@
|
|
|
45930
46014
|
*/
|
|
45931
46015
|
const evaluateRecord = async () => {
|
|
45932
46016
|
let posses = [];
|
|
46017
|
+
const refs = await getStyledRefs(entity);
|
|
46018
|
+
// The record's own point, kept apart so a Style can say what its altitude means.
|
|
46019
|
+
const pointPosses = [];
|
|
45933
46020
|
const location = BModels.Entity.GetValue({
|
|
45934
46021
|
entity: entity,
|
|
45935
46022
|
path: ["Bruce", "Location"]
|
|
@@ -45940,7 +46027,7 @@
|
|
|
45940
46027
|
// Disallowing 0.
|
|
45941
46028
|
if (latitude && longitude) {
|
|
45942
46029
|
const pos3d = Cesium.Cartesian3.fromDegrees(longitude, latitude, EnsureNumber(location.altitude));
|
|
45943
|
-
|
|
46030
|
+
pointPosses.push(pos3d);
|
|
45944
46031
|
}
|
|
45945
46032
|
}
|
|
45946
46033
|
const geometry = BModels.Entity.GetValue({
|
|
@@ -45956,7 +46043,7 @@
|
|
|
45956
46043
|
const point = points.length > 0 ? points[0] : null;
|
|
45957
46044
|
if (point && BModels.Carto.ValidateCarto(point)) {
|
|
45958
46045
|
const pos3d = Cesium.Cartesian3.fromDegrees(EnsureNumber(point.longitude), EnsureNumber(point.latitude), EnsureNumber(point.altitude));
|
|
45959
|
-
|
|
46046
|
+
pointPosses.push(pos3d);
|
|
45960
46047
|
}
|
|
45961
46048
|
}
|
|
45962
46049
|
const lineStr = geometry.LineString;
|
|
@@ -45964,7 +46051,12 @@
|
|
|
45964
46051
|
const points = BModels.Geometry.ParsePoints(lineStr);
|
|
45965
46052
|
if (points.length > 0) {
|
|
45966
46053
|
const pPosses = points.map(x => Cesium.Cartesian3.fromDegrees(EnsureNumber(x.longitude), EnsureNumber(x.latitude), EnsureNumber(x.altitude)));
|
|
45967
|
-
|
|
46054
|
+
if (refs) {
|
|
46055
|
+
await placeStyled(pPosses, refs.polyline, sample);
|
|
46056
|
+
}
|
|
46057
|
+
else {
|
|
46058
|
+
await ensureHeightRefs(pPosses, sample);
|
|
46059
|
+
}
|
|
45968
46060
|
posses = posses.concat(pPosses);
|
|
45969
46061
|
}
|
|
45970
46062
|
}
|
|
@@ -45974,7 +46066,12 @@
|
|
|
45974
46066
|
if (boundary === null || boundary === void 0 ? void 0 : boundary.LinearRing) {
|
|
45975
46067
|
const points = BModels.Geometry.ParsePoints(boundary.LinearRing);
|
|
45976
46068
|
const pPosses = points.map(x => Cesium.Cartesian3.fromDegrees(EnsureNumber(x.longitude), EnsureNumber(x.latitude), EnsureNumber(x.altitude)));
|
|
45977
|
-
|
|
46069
|
+
if (refs) {
|
|
46070
|
+
await placeStyled(pPosses, refs.polygon, sample);
|
|
46071
|
+
}
|
|
46072
|
+
else {
|
|
46073
|
+
await ensureHeightRefs(pPosses, sample);
|
|
46074
|
+
}
|
|
45978
46075
|
posses = posses.concat(pPosses);
|
|
45979
46076
|
}
|
|
45980
46077
|
}
|
|
@@ -45995,11 +46092,22 @@
|
|
|
45995
46092
|
Cesium.Cartesian3.fromDegrees(EnsureNumber(boundaries.minLongitude), EnsureNumber(boundaries.minLatitude), EnsureNumber(boundaries.minAltitude)),
|
|
45996
46093
|
Cesium.Cartesian3.fromDegrees(EnsureNumber(boundaries.maxLongitude), EnsureNumber(boundaries.maxLatitude), EnsureNumber(boundaries.maxAltitude))
|
|
45997
46094
|
];
|
|
45998
|
-
|
|
46095
|
+
if (refs) {
|
|
46096
|
+
// The bounds span the record's main geometry, so they are drawn the way it is.
|
|
46097
|
+
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;
|
|
46098
|
+
await placeStyled(bPosses, boundsRef, sample);
|
|
46099
|
+
}
|
|
46100
|
+
else {
|
|
46101
|
+
await ensureHeightRefs(bPosses, sample);
|
|
46102
|
+
}
|
|
45999
46103
|
posses = posses.concat(bPosses);
|
|
46000
46104
|
}
|
|
46001
46105
|
}
|
|
46002
|
-
|
|
46106
|
+
if (refs) {
|
|
46107
|
+
await placeStyled(pointPosses, refs.point, sample);
|
|
46108
|
+
}
|
|
46109
|
+
// Points first, since a lone record is placed by its first position.
|
|
46110
|
+
return pointPosses.concat(posses);
|
|
46003
46111
|
};
|
|
46004
46112
|
if (isAssemblyEntity) {
|
|
46005
46113
|
// See if we have tileset coords to use.
|
|
@@ -46158,6 +46266,8 @@
|
|
|
46158
46266
|
sample.entity = (_e = simulation === null || simulation === void 0 ? void 0 : simulation.GetEntity(sample.entityId)) !== null && _e !== void 0 ? _e : sample.entity;
|
|
46159
46267
|
}
|
|
46160
46268
|
}
|
|
46269
|
+
// Read here at the scene's time with their location; records a caller supplied may be of another time.
|
|
46270
|
+
const readHere = new Set();
|
|
46161
46271
|
// Bulk requesting Entity records.
|
|
46162
46272
|
try {
|
|
46163
46273
|
const toSearchIds = recordSamples.filter(x => !x.entity && x.entityId).map(x => x.entityId);
|
|
@@ -46179,6 +46289,9 @@
|
|
|
46179
46289
|
const sample = recordSamples[i];
|
|
46180
46290
|
if (!sample.entity && sample.entityId) {
|
|
46181
46291
|
const read = entitiesMap.get(sample.entityId);
|
|
46292
|
+
if (read) {
|
|
46293
|
+
readHere.add(sample.entityId);
|
|
46294
|
+
}
|
|
46182
46295
|
sample.entity = read && simulation ? simulation.Overlay(read) : read;
|
|
46183
46296
|
}
|
|
46184
46297
|
}
|
|
@@ -46189,10 +46302,10 @@
|
|
|
46189
46302
|
catch (e) {
|
|
46190
46303
|
console.error(e);
|
|
46191
46304
|
}
|
|
46192
|
-
//
|
|
46193
|
-
//
|
|
46305
|
+
// Assembly parts not read above with a location expand still need one, and the ones off the scene are dropped
|
|
46306
|
+
// when others are in it, since category nodes without geometry would otherwise pull the result elsewhere.
|
|
46194
46307
|
try {
|
|
46195
|
-
const
|
|
46308
|
+
const assemblySamples = recordSamples.filter(x => {
|
|
46196
46309
|
var _a;
|
|
46197
46310
|
// Expanding reads the API's record, which would replace the stand-in or undo the patch.
|
|
46198
46311
|
if (simulation === null || simulation === void 0 ? void 0 : simulation.HasBlob((_a = x.entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID)) {
|
|
@@ -46202,36 +46315,30 @@
|
|
|
46202
46315
|
entity: x.entity,
|
|
46203
46316
|
path: ["Bruce", "AssemblyPosition"]
|
|
46204
46317
|
});
|
|
46205
|
-
|
|
46206
|
-
return false;
|
|
46207
|
-
}
|
|
46208
|
-
const rootPos = BModels.Entity.GetValue({
|
|
46209
|
-
entity: x.entity,
|
|
46210
|
-
path: ["Bruce", "AssemblyRootPosition"]
|
|
46211
|
-
});
|
|
46212
|
-
return !rootPos;
|
|
46318
|
+
return !!assemblyPos;
|
|
46213
46319
|
});
|
|
46320
|
+
const isInScene = (sample) => {
|
|
46321
|
+
var _a;
|
|
46322
|
+
return !!(visualRegister && visualRegister.GetRego({
|
|
46323
|
+
entityId: (_a = sample.entityId) !== null && _a !== void 0 ? _a : sample.entity.Bruce.ID,
|
|
46324
|
+
menuItemId: sample.menuItemId
|
|
46325
|
+
}));
|
|
46326
|
+
};
|
|
46327
|
+
const sceneSamples = assemblySamples.filter(isInScene);
|
|
46328
|
+
const offSceneSamples = sceneSamples.length ? assemblySamples.filter(x => !isInScene(x)) : [];
|
|
46329
|
+
if (offSceneSamples.length) {
|
|
46330
|
+
const offSceneIds = new Set(offSceneSamples.map(x => x.entity.Bruce.ID));
|
|
46331
|
+
recordSamples = recordSamples.filter(x => !offSceneIds.has(x.entity.Bruce.ID));
|
|
46332
|
+
}
|
|
46333
|
+
const keptSamples = sceneSamples.length ? sceneSamples : assemblySamples;
|
|
46334
|
+
const needsExpansion = keptSamples.filter(x => !readHere.has(x.entity.Bruce.ID) || !BModels.Entity.GetValue({
|
|
46335
|
+
entity: x.entity,
|
|
46336
|
+
path: ["Bruce", "AssemblyRootLocation"]
|
|
46337
|
+
}));
|
|
46214
46338
|
if (needsExpansion.length) {
|
|
46215
46339
|
const EXPAND_BATCH_SIZE = 30;
|
|
46216
46340
|
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)));
|
|
46341
|
+
const uniqueIds = Array.from(new Set(needsExpansion.map(x => x.entity.Bruce.ID)));
|
|
46235
46342
|
const expandIds = uniqueIds.slice(0, EXPAND_MAX_IDS);
|
|
46236
46343
|
// Anything we didn't expand will taint the overall result so we have to filter them out.
|
|
46237
46344
|
const droppedIds = new Set(uniqueIds.slice(EXPAND_MAX_IDS));
|
|
@@ -46260,8 +46367,8 @@
|
|
|
46260
46367
|
expandedMap.set(entities[i].Bruce.ID, entities[i]);
|
|
46261
46368
|
}
|
|
46262
46369
|
}
|
|
46263
|
-
for (let i = 0; i <
|
|
46264
|
-
const sample =
|
|
46370
|
+
for (let i = 0; i < needsExpansion.length; i++) {
|
|
46371
|
+
const sample = needsExpansion[i];
|
|
46265
46372
|
const expanded = expandedMap.get(sample.entity.Bruce.ID);
|
|
46266
46373
|
if (expanded) {
|
|
46267
46374
|
sample.entity = expanded;
|
|
@@ -57015,7 +57122,7 @@ void main() {
|
|
|
57015
57122
|
StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
|
|
57016
57123
|
})(exports.StyleUtils || (exports.StyleUtils = {}));
|
|
57017
57124
|
|
|
57018
|
-
const VERSION = "7.7.
|
|
57125
|
+
const VERSION = "7.7.4";
|
|
57019
57126
|
/**
|
|
57020
57127
|
* Updates the environment instance used by bruce-cesium to one specified.
|
|
57021
57128
|
* This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.
|