bruce-cesium 7.5.3 → 7.5.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 +124 -37
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +122 -35
- package/dist/bruce-cesium.umd.js.map +1 -1
- package/dist/lib/bruce-cesium.js +1 -1
- package/dist/lib/rendering/entity-gatherer.js +3 -0
- package/dist/lib/rendering/entity-gatherer.js.map +1 -1
- package/dist/lib/rendering/tileset-styler.js +120 -35
- package/dist/lib/rendering/tileset-styler.js.map +1 -1
- package/dist/types/bruce-cesium.d.ts +1 -1
- package/dist/types/rendering/entity-gatherer.d.ts +1 -0
- package/dist/types/rendering/tileset-styler.d.ts +48 -0
- package/package.json +2 -2
package/dist/bruce-cesium.es5.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Cesium from 'cesium';
|
|
2
|
-
import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature,
|
|
3
|
-
import { Cartes, LRUCache, ProjectViewTile, ENVIRONMENT, Calculator, ClientFile, Entity as Entity$1, EntityLod, EntityTag, EntityType, ObjectUtils, Style, Carto, Geometry as Geometry$1, Api, ClientFileValueMap, Color as Color$1,
|
|
2
|
+
import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, HeightReference, ColorBlendMode, HeadingPitchRoll, Math as Math$1, Transforms, ShadowMode, Cartesian3, ClassificationType, Model, ShaderSource, Ellipsoid, Matrix4, Geometry, GeometryAttribute, ComponentDatatype, PrimitiveType, BoundingSphere, GeometryPipeline, Cartesian2, Cartesian4, sampleTerrain, Texture, PixelFormat, Sampler, TextureWrap, TextureMinificationFilter, TextureMagnificationFilter, VertexArray, BufferUsage, ShaderProgram, RenderState, BlendingState, DrawCommand, Pass, JulianDate, Quaternion, ArcType, CornerType, ConstantPositionProperty, DistanceDisplayCondition, HorizontalOrigin, VerticalOrigin, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, Rectangle, SceneTransforms, NearFarScalar, Matrix3, KmlDataSource, FeatureDetection, SceneMode, GeoJsonDataSource, Cesium3DTileStyle, HeadingPitchRange, Cesium3DTileColorBlendMode, Ion, IonResource, Cesium3DTileset, OrthographicFrustum, EasingFunction, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, Intersect, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, PolygonPipeline, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, CustomDataSource, CesiumInspector, ClockRange, DynamicEnvironmentMapManager, ScreenSpaceEventHandler, ScreenSpaceEventType, GeometryInstance, Fullscreen, CzmlDataSource } from 'cesium';
|
|
3
|
+
import { Cartes, LRUCache, ProjectViewTile, ENVIRONMENT, Calculator, ClientFile, Entity as Entity$1, EntityLod, EntityTag, EntityType, ObjectUtils, Style, Carto, Geometry as Geometry$1, Api, ClientFileValueMap, Color as Color$1, BruceEvent, EntityCoords, MenuItem, Tileset, ProjectView, ProjectViewBookmark, ZoomControl, Bounds, DataLab, DelayQueue, AccountConcept, BruceApi, EntityRelation, RecordChangeFeed, EntitySource, Camera, ProgramKey, ProjectViewLegacyTile, Account, AccountLimits, Session, UrlUtils, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils, ProjectViewBookmarkGroup, EntityRelationType, EntityHistoricData } from 'bruce-models';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Ensures a number is returned from a given value.
|
|
@@ -17297,6 +17297,9 @@ class EntityGatherer {
|
|
|
17297
17297
|
}
|
|
17298
17298
|
};
|
|
17299
17299
|
}
|
|
17300
|
+
HasEntityDataOverride(eId) {
|
|
17301
|
+
return this.entityDataOverrides.has(eId);
|
|
17302
|
+
}
|
|
17300
17303
|
SetEntityDataOverride(eId, entity) {
|
|
17301
17304
|
if (this.disposed) {
|
|
17302
17305
|
return;
|
|
@@ -17993,6 +17996,24 @@ function correctStyle(style) {
|
|
|
17993
17996
|
}
|
|
17994
17997
|
return style;
|
|
17995
17998
|
}
|
|
17999
|
+
/**
|
|
18000
|
+
* Reads the baked attribute declaration from a loaded tileset, keyed by path.
|
|
18001
|
+
* @param cTileset
|
|
18002
|
+
*/
|
|
18003
|
+
function getBakedAttributes(cTileset) {
|
|
18004
|
+
var _a, _b;
|
|
18005
|
+
const result = new Map();
|
|
18006
|
+
const declared = (_b = (_a = cTileset === null || cTileset === void 0 ? void 0 : cTileset.extras) === null || _a === void 0 ? void 0 : _a.bruce) === null || _b === void 0 ? void 0 : _b.bakedAttributes;
|
|
18007
|
+
if (!Array.isArray(declared)) {
|
|
18008
|
+
return result;
|
|
18009
|
+
}
|
|
18010
|
+
for (const baked of declared) {
|
|
18011
|
+
if (Array.isArray(baked === null || baked === void 0 ? void 0 : baked.path) && baked.path.length && typeof baked.property == "string") {
|
|
18012
|
+
result.set(JSON.stringify(baked.path), baked);
|
|
18013
|
+
}
|
|
18014
|
+
}
|
|
18015
|
+
return result;
|
|
18016
|
+
}
|
|
17996
18017
|
function colorToCColor$3(color) {
|
|
17997
18018
|
return new Color(color.red ? color.red / 255 : 0, color.green ? color.green / 255 : 0, color.blue ? color.blue / 255 : 0, color.alpha);
|
|
17998
18019
|
}
|
|
@@ -18063,6 +18084,10 @@ class TilesetStyler {
|
|
|
18063
18084
|
// When false the Entity data is still gathered and the regos still updated, but no colour is
|
|
18064
18085
|
// applied. A historic item that did not ask for styling needs the first without the second.
|
|
18065
18086
|
this.applyStyles = true;
|
|
18087
|
+
// Attribute values the tiles carry per feature, keyed by JSON path. Empty for a tileset without them.
|
|
18088
|
+
this.bakedAttributes = new Map();
|
|
18089
|
+
// Entities changed since the tileset was generated, so their baked values can no longer be trusted.
|
|
18090
|
+
this.bakedStaleIds = new Set();
|
|
18066
18091
|
this.reRenderState = new EntityReRenderMaintainState();
|
|
18067
18092
|
// More expensive process.
|
|
18068
18093
|
// When an Entity is styled, the rego is reviewed and updated if needed.
|
|
@@ -18104,6 +18129,7 @@ class TilesetStyler {
|
|
|
18104
18129
|
this.viewer = viewer;
|
|
18105
18130
|
this.api = api;
|
|
18106
18131
|
this.cTileset = cTileset;
|
|
18132
|
+
this.bakedAttributes = getBakedAttributes(cTileset);
|
|
18107
18133
|
this.register = register;
|
|
18108
18134
|
this.menuItemId = menuItemId;
|
|
18109
18135
|
this.historic = Boolean(historic);
|
|
@@ -18182,6 +18208,7 @@ class TilesetStyler {
|
|
|
18182
18208
|
for (const [internalId, entityId] of this.styledByInternalId) {
|
|
18183
18209
|
if (RecordChangeFeed.isEntityInternalIdInRangeString(rangeStr, internalId)) {
|
|
18184
18210
|
this.feedPendingRestyleIds.add(entityId);
|
|
18211
|
+
this.bakedStaleIds.add(entityId);
|
|
18185
18212
|
}
|
|
18186
18213
|
}
|
|
18187
18214
|
if (this.feedPendingRestyleIds.size && !this.feedRestyleThrottleTimer) {
|
|
@@ -18502,17 +18529,7 @@ class TilesetStyler {
|
|
|
18502
18529
|
for (const key of pendingKeys) {
|
|
18503
18530
|
const relatedIds = this.stylePendingEntityIds.get(key);
|
|
18504
18531
|
if (relatedIds) {
|
|
18505
|
-
|
|
18506
|
-
this.entityGatherer.Queue(Array.from(relatedIds));
|
|
18507
|
-
}
|
|
18508
|
-
else {
|
|
18509
|
-
relatedIds.forEach(id => {
|
|
18510
|
-
const rego = this.getEntityRego(id);
|
|
18511
|
-
if (rego) {
|
|
18512
|
-
this.styleTilesetFeature(rego);
|
|
18513
|
-
}
|
|
18514
|
-
});
|
|
18515
|
-
}
|
|
18532
|
+
this.styleOrGatherIds(key, relatedIds);
|
|
18516
18533
|
}
|
|
18517
18534
|
}
|
|
18518
18535
|
this.stylePendingEntityIds.clear();
|
|
@@ -18527,17 +18544,7 @@ class TilesetStyler {
|
|
|
18527
18544
|
if (!relatedIds) {
|
|
18528
18545
|
return;
|
|
18529
18546
|
}
|
|
18530
|
-
|
|
18531
|
-
this.entityGatherer.Queue(Array.from(relatedIds));
|
|
18532
|
-
}
|
|
18533
|
-
else {
|
|
18534
|
-
relatedIds.forEach(id => {
|
|
18535
|
-
const rego = this.getEntityRego(id);
|
|
18536
|
-
if (rego) {
|
|
18537
|
-
this.styleTilesetFeature(rego);
|
|
18538
|
-
}
|
|
18539
|
-
});
|
|
18540
|
-
}
|
|
18547
|
+
this.styleOrGatherIds(entityTypeId, relatedIds);
|
|
18541
18548
|
this.stylePendingEntityIds.delete(entityTypeId);
|
|
18542
18549
|
}
|
|
18543
18550
|
hasMappingRow(entityTypeId) {
|
|
@@ -18622,20 +18629,10 @@ class TilesetStyler {
|
|
|
18622
18629
|
this.loadEntityTypeDefaultStyle(typeId);
|
|
18623
18630
|
}
|
|
18624
18631
|
if (this.styleMappingsLoaded.get(typeId) || (this.styleMappingLoaded && !this.hasMappingRow(typeId))) {
|
|
18625
|
-
|
|
18626
|
-
needsDataIds.push(rego.entityId);
|
|
18627
|
-
}
|
|
18628
|
-
else {
|
|
18629
|
-
this.styleTilesetFeature(rego);
|
|
18630
|
-
}
|
|
18632
|
+
this.styleOrCollect(rego, typeId, needsDataIds);
|
|
18631
18633
|
}
|
|
18632
18634
|
else if (!this.styleMappingsLoaded.has(typeId) && this.styleFallbackLoaded) {
|
|
18633
|
-
|
|
18634
|
-
needsDataIds.push(rego.entityId);
|
|
18635
|
-
}
|
|
18636
|
-
else {
|
|
18637
|
-
this.styleTilesetFeature(rego);
|
|
18638
|
-
}
|
|
18635
|
+
this.styleOrCollect(rego, typeId, needsDataIds);
|
|
18639
18636
|
}
|
|
18640
18637
|
else {
|
|
18641
18638
|
if (!this.stylePendingEntityIds.has(typeId)) {
|
|
@@ -18648,6 +18645,96 @@ class TilesetStyler {
|
|
|
18648
18645
|
this.entityGatherer.Queue(needsDataIds, highPriority);
|
|
18649
18646
|
}
|
|
18650
18647
|
}
|
|
18648
|
+
/**
|
|
18649
|
+
* Styles each Entity waiting on a type's style, gathering the records of those that need one.
|
|
18650
|
+
* @param entityTypeId
|
|
18651
|
+
* @param entityIds
|
|
18652
|
+
*/
|
|
18653
|
+
styleOrGatherIds(entityTypeId, entityIds) {
|
|
18654
|
+
const gatherIds = [];
|
|
18655
|
+
for (const id of entityIds) {
|
|
18656
|
+
const rego = this.getEntityRego(id);
|
|
18657
|
+
if (rego) {
|
|
18658
|
+
this.styleOrCollect(rego, entityTypeId, gatherIds);
|
|
18659
|
+
}
|
|
18660
|
+
}
|
|
18661
|
+
if (gatherIds.length) {
|
|
18662
|
+
this.entityGatherer.Queue(gatherIds);
|
|
18663
|
+
}
|
|
18664
|
+
}
|
|
18665
|
+
/**
|
|
18666
|
+
* Styles a feature now when its style reads no record, or reads only values its tile carries, and otherwise collects it for gathering.
|
|
18667
|
+
* @param rego
|
|
18668
|
+
* @param entityTypeId
|
|
18669
|
+
* @param gatherIds Receives the Entity ID when its record is needed.
|
|
18670
|
+
*/
|
|
18671
|
+
styleOrCollect(rego, entityTypeId, gatherIds) {
|
|
18672
|
+
if (!this.getTilesetFeatureNeedsFullData(entityTypeId)) {
|
|
18673
|
+
this.styleTilesetFeature(rego);
|
|
18674
|
+
return;
|
|
18675
|
+
}
|
|
18676
|
+
const record = this.canStyleFromBaked(rego.entityId, entityTypeId) ? this.readBakedRecord(rego.visual) : null;
|
|
18677
|
+
if (!record) {
|
|
18678
|
+
gatherIds.push(rego.entityId);
|
|
18679
|
+
return;
|
|
18680
|
+
}
|
|
18681
|
+
this.styleTilesetFeatureFullData(rego, record, []);
|
|
18682
|
+
// A later edit has to reach the record path, and the change feed finds Entities by Internal ID.
|
|
18683
|
+
if (rego.internalId != null) {
|
|
18684
|
+
this.styledByInternalId.set(rego.internalId, rego.entityId);
|
|
18685
|
+
}
|
|
18686
|
+
}
|
|
18687
|
+
/**
|
|
18688
|
+
* Returns if the tile's baked values hold everything this Entity's style would read from its record.
|
|
18689
|
+
* @param entityId
|
|
18690
|
+
* @param entityTypeId
|
|
18691
|
+
*/
|
|
18692
|
+
canStyleFromBaked(entityId, entityTypeId) {
|
|
18693
|
+
var _a, _b, _c;
|
|
18694
|
+
// Baked values are the base record at generation time, which a scenario, a point in time or merged sources all differ from.
|
|
18695
|
+
if (!this.bakedAttributes.size || this.historic || !!this.scenario || this.expandSources) {
|
|
18696
|
+
return false;
|
|
18697
|
+
}
|
|
18698
|
+
if (this.bakedStaleIds.has(entityId) || ((_a = this.entityGatherer) === null || _a === void 0 ? void 0 : _a.HasEntityDataOverride(entityId))) {
|
|
18699
|
+
return false;
|
|
18700
|
+
}
|
|
18701
|
+
const paths = Calculator.GetFieldPaths((_c = (_b = this.getTilesetFeatureStyle(entityTypeId)) === null || _b === void 0 ? void 0 : _b.modelStyle) === null || _c === void 0 ? void 0 : _c.fillColor);
|
|
18702
|
+
return paths != null && paths.every(path => this.bakedAttributes.has(JSON.stringify(path)));
|
|
18703
|
+
}
|
|
18704
|
+
/**
|
|
18705
|
+
* Builds a stand-in record from a feature's baked values, holding only the attributes that have one.
|
|
18706
|
+
* Returns null when the feature's tile lacks a declared column, so the record is gathered instead.
|
|
18707
|
+
* @param visual
|
|
18708
|
+
*/
|
|
18709
|
+
readBakedRecord(visual) {
|
|
18710
|
+
if (!(visual instanceof Cesium3DTileFeature)) {
|
|
18711
|
+
return null;
|
|
18712
|
+
}
|
|
18713
|
+
const record = {};
|
|
18714
|
+
for (const baked of this.bakedAttributes.values()) {
|
|
18715
|
+
if (!visual.hasProperty(baked.property)) {
|
|
18716
|
+
return null;
|
|
18717
|
+
}
|
|
18718
|
+
let value = visual.getProperty(baked.property);
|
|
18719
|
+
if (value == null) {
|
|
18720
|
+
continue;
|
|
18721
|
+
}
|
|
18722
|
+
// Booleans travel as 0/1 because a boolean column has no way to say "no value".
|
|
18723
|
+
if (baked.type == "BOOLEAN") {
|
|
18724
|
+
value = value != 0;
|
|
18725
|
+
}
|
|
18726
|
+
let target = record;
|
|
18727
|
+
for (let i = 0; i < baked.path.length - 1; i++) {
|
|
18728
|
+
const segment = baked.path[i];
|
|
18729
|
+
if (target[segment] == null || typeof target[segment] != "object") {
|
|
18730
|
+
target[segment] = {};
|
|
18731
|
+
}
|
|
18732
|
+
target = target[segment];
|
|
18733
|
+
}
|
|
18734
|
+
target[baked.path[baked.path.length - 1]] = value;
|
|
18735
|
+
}
|
|
18736
|
+
return record;
|
|
18737
|
+
}
|
|
18651
18738
|
styleTilesetFeature(rego) {
|
|
18652
18739
|
this.styleTilesetFeatureFullData(rego, null, []);
|
|
18653
18740
|
}
|
|
@@ -51223,7 +51310,7 @@ var StyleUtils;
|
|
|
51223
51310
|
StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
|
|
51224
51311
|
})(StyleUtils || (StyleUtils = {}));
|
|
51225
51312
|
|
|
51226
|
-
const VERSION = "7.5.
|
|
51313
|
+
const VERSION = "7.5.4";
|
|
51227
51314
|
/**
|
|
51228
51315
|
* Updates the environment instance used by bruce-cesium to one specified.
|
|
51229
51316
|
* This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.
|