bruce-cesium 6.9.7 → 6.9.9
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 +501 -39
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +499 -37
- package/dist/bruce-cesium.umd.js.map +1 -1
- package/dist/lib/bruce-cesium.js +1 -1
- package/dist/lib/internal/image-utils.js +35 -0
- package/dist/lib/internal/image-utils.js.map +1 -0
- package/dist/lib/internal/series-segment.js +3 -0
- package/dist/lib/internal/series-segment.js.map +1 -0
- package/dist/lib/rendering/entity-render-engine-polygon.js +146 -35
- package/dist/lib/rendering/entity-render-engine-polygon.js.map +1 -1
- package/dist/lib/rendering/entity-render-engine.js +1 -0
- package/dist/lib/rendering/entity-render-engine.js.map +1 -1
- package/dist/lib/rendering/menu-item-manager.js +46 -1
- package/dist/lib/rendering/menu-item-manager.js.map +1 -1
- package/dist/lib/rendering/render-managers/entities/entities-render-manager.js +3 -1
- package/dist/lib/rendering/render-managers/entities/entities-render-manager.js.map +1 -1
- package/dist/lib/rendering/texture-frame-series-animator.js +281 -0
- package/dist/lib/rendering/texture-frame-series-animator.js.map +1 -0
- package/dist/types/bruce-cesium.d.ts +1 -1
- package/dist/types/internal/image-utils.d.ts +10 -0
- package/dist/types/internal/series-segment.d.ts +10 -0
- package/dist/types/rendering/entity-render-engine-polygon.d.ts +4 -0
- package/dist/types/rendering/entity-render-engine.d.ts +2 -0
- package/dist/types/rendering/menu-item-manager.d.ts +19 -0
- package/dist/types/rendering/render-managers/entities/entities-render-manager.d.ts +3 -0
- package/dist/types/rendering/texture-frame-series-animator.d.ts +93 -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, DistanceDisplayCondition,
|
|
3
|
-
import { Cartes, Entity as Entity$1, ENVIRONMENT,
|
|
2
|
+
import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, DistanceDisplayCondition, Math as Math$1, Cartesian3, JulianDate, Quaternion, Transforms, HeadingPitchRoll, Matrix4, HeightReference, ColorBlendMode, ShadowMode, ClassificationType, Model, ArcType, CornerType, ConstantPositionProperty, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, HorizontalOrigin, VerticalOrigin, SceneTransforms, NearFarScalar, Cartesian2, Matrix3, Rectangle, KmlDataSource, GeoJsonDataSource, SceneMode, Cesium3DTileStyle, HeadingPitchRange, Ion, IonResource, Cesium3DTileColorBlendMode, Cesium3DTileset, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, OrthographicFrustum, EasingFunction, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, PolygonPipeline, CesiumInspector, ClockRange, BoundingSphere, GeometryInstance, ScreenSpaceEventHandler, ScreenSpaceEventType, Fullscreen, Intersect, CzmlDataSource } from 'cesium';
|
|
3
|
+
import { Cartes, Entity as Entity$1, ENVIRONMENT, Calculator, ClientFile, EntityLod, EntityTag, EntityType, LRUCache, ObjectUtils, Style, Carto, Geometry, MenuItem, ProjectView, ProjectViewBookmark, Tileset, ZoomControl, Bounds, Color as Color$1, Api, BruceEvent, EntityCoords, DataLab, DelayQueue, BruceApi, EntityRelation, EntityHistoricData, AccountConcept, RecordChangeFeed, ProgramKey, EntitySource, ProjectViewLegacyTile, ProjectViewTile, Camera, Session, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils, EntityRelationType } from 'bruce-models';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Ensures a number is returned from a given value.
|
|
@@ -9686,13 +9686,14 @@ var EntitiesRenderManager;
|
|
|
9686
9686
|
// Type IDs that we'll allow to be rendered when receiving Entities.
|
|
9687
9687
|
// This might be exactly the Menu Item Type ID because of local data sources.
|
|
9688
9688
|
this.allowedTypeIDs = [];
|
|
9689
|
-
const { viewer, apiGetter, monitor, item, register: visualsManager, sharedGetters } = params;
|
|
9689
|
+
const { viewer, apiGetter, monitor, item, register: visualsManager, sharedGetters, onSeriesDiscovered } = params;
|
|
9690
9690
|
this.viewer = viewer;
|
|
9691
9691
|
this.sharedGetters = sharedGetters;
|
|
9692
9692
|
this.monitor = monitor;
|
|
9693
9693
|
this.apiGetter = apiGetter;
|
|
9694
9694
|
this.item = item;
|
|
9695
9695
|
this.visualsManager = visualsManager;
|
|
9696
|
+
this.onSeriesDiscovered = onSeriesDiscovered;
|
|
9696
9697
|
this.useGeojson = item.renderAsGeojson == true;
|
|
9697
9698
|
if (item.enableClustering) {
|
|
9698
9699
|
this.clustering = new PointClustering(this.visualsManager, this.item.id);
|
|
@@ -10661,6 +10662,7 @@ var EntitiesRenderManager;
|
|
|
10661
10662
|
apiGetter: this.apiGetter,
|
|
10662
10663
|
entities: entities,
|
|
10663
10664
|
menuItemId: this.item.id,
|
|
10665
|
+
onSeriesDiscovered: this.onSeriesDiscovered,
|
|
10664
10666
|
visualRegister: this.visualsManager,
|
|
10665
10667
|
zoomControl: this.zoomControl,
|
|
10666
10668
|
entitiesHistoric: entitiesHistoric,
|
|
@@ -22270,6 +22272,46 @@ var MenuItemManager;
|
|
|
22270
22272
|
}
|
|
22271
22273
|
return this.onUpdate;
|
|
22272
22274
|
}
|
|
22275
|
+
get OnSeriesUpdated() {
|
|
22276
|
+
if (!this.onSeriesUpdated) {
|
|
22277
|
+
this.onSeriesUpdated = new BruceEvent();
|
|
22278
|
+
}
|
|
22279
|
+
return this.onSeriesUpdated;
|
|
22280
|
+
}
|
|
22281
|
+
/**
|
|
22282
|
+
* Currently known series segments for a menu item (empty array if none discovered yet).
|
|
22283
|
+
*/
|
|
22284
|
+
GetSeriesSegments(itemId) {
|
|
22285
|
+
return this.seriesSegments.get(itemId) || [];
|
|
22286
|
+
}
|
|
22287
|
+
/**
|
|
22288
|
+
* @param itemId
|
|
22289
|
+
* @param segment
|
|
22290
|
+
*/
|
|
22291
|
+
RecordSeriesSegment(itemId, segment) {
|
|
22292
|
+
const existing = this.seriesSegments.get(itemId) || [];
|
|
22293
|
+
const idx = existing.findIndex((s) => s.key === segment.key);
|
|
22294
|
+
if (idx !== -1) {
|
|
22295
|
+
const current = existing[idx];
|
|
22296
|
+
if (current.min.getTime() === segment.min.getTime() && current.max.getTime() === segment.max.getTime() && current.label === segment.label) {
|
|
22297
|
+
return; // No-op.
|
|
22298
|
+
}
|
|
22299
|
+
existing[idx] = segment;
|
|
22300
|
+
}
|
|
22301
|
+
else {
|
|
22302
|
+
existing.push(segment);
|
|
22303
|
+
}
|
|
22304
|
+
this.seriesSegments.set(itemId, existing);
|
|
22305
|
+
this.OnSeriesUpdated.Trigger({ itemId, segments: existing });
|
|
22306
|
+
}
|
|
22307
|
+
/**
|
|
22308
|
+
* Clears any series segments recorded for a menu item, eg when it's disabled/removed.
|
|
22309
|
+
*/
|
|
22310
|
+
ClearSeriesSegments(itemId) {
|
|
22311
|
+
if (this.seriesSegments.delete(itemId)) {
|
|
22312
|
+
this.OnSeriesUpdated.Trigger({ itemId, segments: [] });
|
|
22313
|
+
}
|
|
22314
|
+
}
|
|
22273
22315
|
get Monitor() {
|
|
22274
22316
|
return this.sharedMonitor;
|
|
22275
22317
|
}
|
|
@@ -22277,6 +22319,9 @@ var MenuItemManager;
|
|
|
22277
22319
|
this.items = [];
|
|
22278
22320
|
this.pendingHandoffPool = [];
|
|
22279
22321
|
this.onUpdate = null;
|
|
22322
|
+
// Segments discovered so far per menu item ID.
|
|
22323
|
+
this.seriesSegments = new Map();
|
|
22324
|
+
this.onSeriesUpdated = null;
|
|
22280
22325
|
let { viewer, visualsRegister, getters } = params;
|
|
22281
22326
|
this.viewer = viewer;
|
|
22282
22327
|
if (!getters) {
|
|
@@ -22502,7 +22547,8 @@ var MenuItemManager;
|
|
|
22502
22547
|
apiGetter: params.apiGetter,
|
|
22503
22548
|
monitor: this.sharedMonitor,
|
|
22504
22549
|
item: params.item,
|
|
22505
|
-
sharedGetters: this.sharedGetters
|
|
22550
|
+
sharedGetters: this.sharedGetters,
|
|
22551
|
+
onSeriesDiscovered: (segment) => this.RecordSeriesSegment(rItem.id, segment)
|
|
22506
22552
|
});
|
|
22507
22553
|
break;
|
|
22508
22554
|
case MenuItem.EType.EntitiesLoaded:
|
|
@@ -22728,6 +22774,7 @@ var MenuItemManager;
|
|
|
22728
22774
|
}
|
|
22729
22775
|
}
|
|
22730
22776
|
this.items = this.items.filter(x => x.id !== id);
|
|
22777
|
+
this.ClearSeriesSegments(item.id);
|
|
22731
22778
|
(_b = this.onUpdate) === null || _b === void 0 ? void 0 : _b.Trigger({ isEnabling: false, itemId: item.id });
|
|
22732
22779
|
}
|
|
22733
22780
|
}
|
|
@@ -36724,6 +36771,312 @@ function getHeightRef$2(style, defaultStyle) {
|
|
|
36724
36771
|
return heightRef;
|
|
36725
36772
|
}
|
|
36726
36773
|
|
|
36774
|
+
/**
|
|
36775
|
+
* Remaps a (assumed grayscale, server-rendered black-to-white) image's pixels into a gradient between minColor/maxColor,
|
|
36776
|
+
* preserving source alpha blended with the mask's own alpha.
|
|
36777
|
+
* @param imageData
|
|
36778
|
+
* @param minColor
|
|
36779
|
+
* @param maxColor
|
|
36780
|
+
*/
|
|
36781
|
+
function ApplyGrayscaleColorMask(imageData, minColor, maxColor) {
|
|
36782
|
+
const data = imageData.data;
|
|
36783
|
+
for (let i = 0; i < data.length; i += 4) {
|
|
36784
|
+
// The texture is rendered black-to-white server-side, so any channel carries the value.
|
|
36785
|
+
const t = data[i] / 255;
|
|
36786
|
+
data[i] = Math.round(minColor.red + (maxColor.red - minColor.red) * t);
|
|
36787
|
+
data[i + 1] = Math.round(minColor.green + (maxColor.green - minColor.green) * t);
|
|
36788
|
+
data[i + 2] = Math.round(minColor.blue + (maxColor.blue - minColor.blue) * t);
|
|
36789
|
+
// Preserve source transparency (eg unrasterized pixels) blended with the mask's own alpha.
|
|
36790
|
+
const srcAlpha = data[i + 3] / 255;
|
|
36791
|
+
const maskAlpha = minColor.alpha + (maxColor.alpha - minColor.alpha) * t;
|
|
36792
|
+
data[i + 3] = Math.round(srcAlpha * maskAlpha * 255);
|
|
36793
|
+
}
|
|
36794
|
+
}
|
|
36795
|
+
function loadImage(src) {
|
|
36796
|
+
return new Promise((res, rej) => {
|
|
36797
|
+
const image = new Image();
|
|
36798
|
+
image.onload = () => res(image);
|
|
36799
|
+
image.onerror = (e) => rej(e);
|
|
36800
|
+
image.src = src;
|
|
36801
|
+
});
|
|
36802
|
+
}
|
|
36803
|
+
|
|
36804
|
+
var TextureFrameSeriesAnimator;
|
|
36805
|
+
(function (TextureFrameSeriesAnimator) {
|
|
36806
|
+
/**
|
|
36807
|
+
* Detects whether a ClientFile's `Data.generation` metadata describes a frame archive rather than a single static image,
|
|
36808
|
+
* so a caller can decide whether to construct an Animator or fall back to the existing static-texture path.
|
|
36809
|
+
* @param data ClientFile.Data (the `IFile.Data` field), as returned by ClientFile.Get().
|
|
36810
|
+
*/
|
|
36811
|
+
function IsFrameArchiveMetadata(data) {
|
|
36812
|
+
return Boolean(data && data.generation && Array.isArray(data.generation.Frames) && data.generation.Frames.length > 0);
|
|
36813
|
+
}
|
|
36814
|
+
TextureFrameSeriesAnimator.IsFrameArchiveMetadata = IsFrameArchiveMetadata;
|
|
36815
|
+
const DEFAULT_CROSSFADE_MS = 900;
|
|
36816
|
+
const DEFAULT_LOW_COLOR = { red: 255, green: 255, blue: 255, alpha: 0.12 };
|
|
36817
|
+
const DEFAULT_HIGH_COLOR = { red: 21, green: 96, blue: 196, alpha: 0.92 };
|
|
36818
|
+
class Animator {
|
|
36819
|
+
constructor(options) {
|
|
36820
|
+
var _a;
|
|
36821
|
+
this.removeOnTick = null;
|
|
36822
|
+
this.removeCrossfadeTick = null;
|
|
36823
|
+
this.disposed = false;
|
|
36824
|
+
this.currentFrameIndex = -1;
|
|
36825
|
+
// Single-in-flight fetch queue: only one Range GET outstanding at a time, and the NEXT one
|
|
36826
|
+
// is chosen right before sending, this is what makes reprioritizing mid-scrub take effect
|
|
36827
|
+
// immediately instead of draining a backlog of stale requests first.
|
|
36828
|
+
this.inFlightIndex = -1;
|
|
36829
|
+
this.pendingIndex = -1;
|
|
36830
|
+
this.displayedPixels = null;
|
|
36831
|
+
this.fadeFromPixels = null;
|
|
36832
|
+
this.fadeToIndex = -1;
|
|
36833
|
+
this.fadeToDims = null;
|
|
36834
|
+
this.fadeStartMs = null;
|
|
36835
|
+
// Two-canvas pool: Cesium compares image references each frame, so alternating between
|
|
36836
|
+
// pool[0]/pool[1] gives a new object reference whenever we actually present a new frame,
|
|
36837
|
+
// forcing Cesium to re-upload the texture only when something changed.
|
|
36838
|
+
this.pool = [document.createElement("canvas"), document.createElement("canvas")];
|
|
36839
|
+
this.poolIdx = 0;
|
|
36840
|
+
if (!options.entity.polygon) {
|
|
36841
|
+
throw new Error("TextureFrameSeriesAnimator requires an entity with polygon graphics.");
|
|
36842
|
+
}
|
|
36843
|
+
if (!options.frames || options.frames.length === 0) {
|
|
36844
|
+
throw new Error("TextureFrameSeriesAnimator requires at least one frame.");
|
|
36845
|
+
}
|
|
36846
|
+
this.viewer = options.viewer;
|
|
36847
|
+
this.entity = options.entity;
|
|
36848
|
+
this.archiveUrl = options.archiveUrl;
|
|
36849
|
+
this.frames = options.frames;
|
|
36850
|
+
this.crossfadeMs = (_a = options.crossfadeMs) !== null && _a !== void 0 ? _a : DEFAULT_CROSSFADE_MS;
|
|
36851
|
+
const mask = options.textureColorMask;
|
|
36852
|
+
this.lowColor = (mask && Color$1.ColorFromStr(mask.minColor)) || DEFAULT_LOW_COLOR;
|
|
36853
|
+
this.highColor = (mask && Color$1.ColorFromStr(mask.maxColor)) || DEFAULT_HIGH_COLOR;
|
|
36854
|
+
this.frameDates = this.frames.map((f) => JulianDate.fromIso8601(f.Timestamp));
|
|
36855
|
+
this.frameCache = new Array(this.frames.length).fill(null);
|
|
36856
|
+
this.frameDims = new Array(this.frames.length).fill(null);
|
|
36857
|
+
this.originalMaterial = options.entity.polygon.material;
|
|
36858
|
+
this.imageProperty = new CallbackProperty(() => this.pool[this.poolIdx], false);
|
|
36859
|
+
options.entity.polygon.material = new ImageMaterialProperty({ image: this.imageProperty, transparent: true });
|
|
36860
|
+
this.removeCrossfadeTick = this.viewer.scene.postUpdate.addEventListener(() => this.tickCrossfade());
|
|
36861
|
+
this.removeOnTick = this.viewer.clock.onTick.addEventListener((clock) => this.onClockTick(clock.currentTime));
|
|
36862
|
+
this.onClockTick(this.viewer.clock.currentTime);
|
|
36863
|
+
}
|
|
36864
|
+
/**
|
|
36865
|
+
* Explicit teardown: stops driving the entity's material, abandons any in-flight/pending fetch (results are simply ignored when they land),
|
|
36866
|
+
* and restores whatever material the entity had before construction. Never called automatically.
|
|
36867
|
+
*/
|
|
36868
|
+
Dispose() {
|
|
36869
|
+
if (this.disposed) {
|
|
36870
|
+
return;
|
|
36871
|
+
}
|
|
36872
|
+
this.disposed = true;
|
|
36873
|
+
if (this.removeOnTick) {
|
|
36874
|
+
this.removeOnTick();
|
|
36875
|
+
this.removeOnTick = null;
|
|
36876
|
+
}
|
|
36877
|
+
if (this.removeCrossfadeTick) {
|
|
36878
|
+
this.removeCrossfadeTick();
|
|
36879
|
+
this.removeCrossfadeTick = null;
|
|
36880
|
+
}
|
|
36881
|
+
if (this.entity && this.entity.polygon) {
|
|
36882
|
+
this.entity.polygon.material = this.originalMaterial;
|
|
36883
|
+
}
|
|
36884
|
+
}
|
|
36885
|
+
IsDisposed() {
|
|
36886
|
+
return this.disposed;
|
|
36887
|
+
}
|
|
36888
|
+
/**
|
|
36889
|
+
* The archive URL this instance was constructed with,
|
|
36890
|
+
* lets a caller re-rendering the same entity tell whether an existing instance is already correct, without reaching into private state.
|
|
36891
|
+
*/
|
|
36892
|
+
GetArchiveUrl() {
|
|
36893
|
+
return this.archiveUrl;
|
|
36894
|
+
}
|
|
36895
|
+
onClockTick(currentTime) {
|
|
36896
|
+
if (this.disposed) {
|
|
36897
|
+
return;
|
|
36898
|
+
}
|
|
36899
|
+
this.swapToFrame(this.findFrameIndex(currentTime));
|
|
36900
|
+
}
|
|
36901
|
+
// Binary-search the frame whose timestamp is <= currentTime.
|
|
36902
|
+
findFrameIndex(currentTime) {
|
|
36903
|
+
const dates = this.frameDates;
|
|
36904
|
+
let lo = 0;
|
|
36905
|
+
let hi = dates.length - 1;
|
|
36906
|
+
if (JulianDate.lessThanOrEquals(currentTime, dates[0])) {
|
|
36907
|
+
return 0;
|
|
36908
|
+
}
|
|
36909
|
+
if (JulianDate.greaterThanOrEquals(currentTime, dates[hi])) {
|
|
36910
|
+
return hi;
|
|
36911
|
+
}
|
|
36912
|
+
while (lo < hi) {
|
|
36913
|
+
const mid = (lo + hi + 1) >> 1;
|
|
36914
|
+
if (JulianDate.lessThanOrEquals(dates[mid], currentTime)) {
|
|
36915
|
+
lo = mid;
|
|
36916
|
+
}
|
|
36917
|
+
else {
|
|
36918
|
+
hi = mid - 1;
|
|
36919
|
+
}
|
|
36920
|
+
}
|
|
36921
|
+
return lo;
|
|
36922
|
+
}
|
|
36923
|
+
// Called with the discrete target frame (never a fractional/interpolated index).
|
|
36924
|
+
// Scrubbing rapidly just retargets what's fetched next.
|
|
36925
|
+
swapToFrame(idx) {
|
|
36926
|
+
if (idx === this.currentFrameIndex) {
|
|
36927
|
+
return;
|
|
36928
|
+
}
|
|
36929
|
+
this.currentFrameIndex = idx;
|
|
36930
|
+
if (this.frameCache[idx]) {
|
|
36931
|
+
this.beginCrossfadeTo(idx);
|
|
36932
|
+
return;
|
|
36933
|
+
}
|
|
36934
|
+
this.ensureFrame(idx);
|
|
36935
|
+
}
|
|
36936
|
+
ensureFrame(idx) {
|
|
36937
|
+
if (this.frameCache[idx]) {
|
|
36938
|
+
return;
|
|
36939
|
+
}
|
|
36940
|
+
if (this.inFlightIndex === idx) {
|
|
36941
|
+
return;
|
|
36942
|
+
}
|
|
36943
|
+
this.pendingIndex = idx;
|
|
36944
|
+
this.pumpFetchQueue();
|
|
36945
|
+
}
|
|
36946
|
+
// Nearest still-uncached frame to wherever the viewer CURRENTLY is.
|
|
36947
|
+
nearestUncachedFrame() {
|
|
36948
|
+
const n = this.frameCache.length;
|
|
36949
|
+
if (this.currentFrameIndex < 0) {
|
|
36950
|
+
return this.frameCache[0] ? -1 : 0;
|
|
36951
|
+
}
|
|
36952
|
+
for (let d = 0; d < n; d++) {
|
|
36953
|
+
const forward = this.currentFrameIndex + d;
|
|
36954
|
+
if (forward < n && !this.frameCache[forward]) {
|
|
36955
|
+
return forward;
|
|
36956
|
+
}
|
|
36957
|
+
const backward = this.currentFrameIndex - d;
|
|
36958
|
+
if (backward >= 0 && !this.frameCache[backward]) {
|
|
36959
|
+
return backward;
|
|
36960
|
+
}
|
|
36961
|
+
}
|
|
36962
|
+
return -1;
|
|
36963
|
+
}
|
|
36964
|
+
pumpFetchQueue() {
|
|
36965
|
+
if (this.disposed || this.inFlightIndex !== -1) {
|
|
36966
|
+
return;
|
|
36967
|
+
}
|
|
36968
|
+
let next = -1;
|
|
36969
|
+
if (this.pendingIndex !== -1) {
|
|
36970
|
+
next = this.pendingIndex;
|
|
36971
|
+
this.pendingIndex = -1;
|
|
36972
|
+
}
|
|
36973
|
+
else {
|
|
36974
|
+
next = this.nearestUncachedFrame();
|
|
36975
|
+
}
|
|
36976
|
+
if (next === -1) {
|
|
36977
|
+
return;
|
|
36978
|
+
}
|
|
36979
|
+
this.inFlightIndex = next;
|
|
36980
|
+
this.fetchAndTint(next)
|
|
36981
|
+
.catch(() => {
|
|
36982
|
+
// Eating it.
|
|
36983
|
+
})
|
|
36984
|
+
.finally(() => {
|
|
36985
|
+
this.inFlightIndex = -1;
|
|
36986
|
+
if (!this.disposed) {
|
|
36987
|
+
this.pumpFetchQueue();
|
|
36988
|
+
}
|
|
36989
|
+
});
|
|
36990
|
+
}
|
|
36991
|
+
async fetchAndTint(idx) {
|
|
36992
|
+
const entry = this.frames[idx];
|
|
36993
|
+
const start = entry.ByteOffset;
|
|
36994
|
+
const end = entry.ByteOffset + entry.ByteLength - 1;
|
|
36995
|
+
const response = await fetch(this.archiveUrl, { headers: { Range: `bytes=${start}-${end}` } });
|
|
36996
|
+
const buffer = await response.arrayBuffer();
|
|
36997
|
+
if (this.disposed) {
|
|
36998
|
+
return;
|
|
36999
|
+
}
|
|
37000
|
+
const decoded = await this.decodeAndTint(buffer);
|
|
37001
|
+
if (this.disposed) {
|
|
37002
|
+
return;
|
|
37003
|
+
}
|
|
37004
|
+
this.frameCache[idx] = decoded.pixels;
|
|
37005
|
+
this.frameDims[idx] = { width: decoded.width, height: decoded.height };
|
|
37006
|
+
if (idx === this.currentFrameIndex) {
|
|
37007
|
+
this.beginCrossfadeTo(idx);
|
|
37008
|
+
}
|
|
37009
|
+
}
|
|
37010
|
+
/**
|
|
37011
|
+
* Decodes one frame's raw PNG bytes (as returned by a Range GET) and applies the grayscale color mask.
|
|
37012
|
+
*/
|
|
37013
|
+
async decodeAndTint(buffer) {
|
|
37014
|
+
const blob = new Blob([buffer], { type: "image/png" });
|
|
37015
|
+
const objectUrl = URL.createObjectURL(blob);
|
|
37016
|
+
let image;
|
|
37017
|
+
try {
|
|
37018
|
+
image = await loadImage(objectUrl);
|
|
37019
|
+
}
|
|
37020
|
+
finally {
|
|
37021
|
+
URL.revokeObjectURL(objectUrl);
|
|
37022
|
+
}
|
|
37023
|
+
const canvas = document.createElement("canvas");
|
|
37024
|
+
canvas.width = image.width;
|
|
37025
|
+
canvas.height = image.height;
|
|
37026
|
+
const ctx = canvas.getContext("2d");
|
|
37027
|
+
ctx.drawImage(image, 0, 0);
|
|
37028
|
+
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
|
37029
|
+
ApplyGrayscaleColorMask(imageData, this.lowColor, this.highColor);
|
|
37030
|
+
return { pixels: imageData.data, width: canvas.width, height: canvas.height };
|
|
37031
|
+
}
|
|
37032
|
+
beginCrossfadeTo(idx) {
|
|
37033
|
+
const to = this.frameCache[idx];
|
|
37034
|
+
this.fadeFromPixels = this.displayedPixels === null ? new Uint8ClampedArray(to.length) : this.displayedPixels;
|
|
37035
|
+
this.fadeToIndex = idx;
|
|
37036
|
+
this.fadeToDims = this.frameDims[idx];
|
|
37037
|
+
this.fadeStartMs = Now();
|
|
37038
|
+
}
|
|
37039
|
+
tickCrossfade() {
|
|
37040
|
+
if (this.disposed || this.fadeStartMs === null) {
|
|
37041
|
+
return;
|
|
37042
|
+
}
|
|
37043
|
+
const t = Math.min(1, (Now() - this.fadeStartMs) / this.crossfadeMs);
|
|
37044
|
+
const eased = easeInOutQuad(t);
|
|
37045
|
+
const from = this.fadeFromPixels;
|
|
37046
|
+
const to = this.frameCache[this.fadeToIndex];
|
|
37047
|
+
const n = Math.min(from.length, to.length);
|
|
37048
|
+
const blended = new Uint8ClampedArray(to.length);
|
|
37049
|
+
for (let i = 0; i < n; i++) {
|
|
37050
|
+
blended[i] = from[i] + (to[i] - from[i]) * eased;
|
|
37051
|
+
}
|
|
37052
|
+
this.presentPixels(blended, this.fadeToDims);
|
|
37053
|
+
if (t >= 1) {
|
|
37054
|
+
this.fadeStartMs = null;
|
|
37055
|
+
this.fadeFromPixels = null;
|
|
37056
|
+
}
|
|
37057
|
+
}
|
|
37058
|
+
presentPixels(pixels, dims) {
|
|
37059
|
+
this.poolIdx = 1 - this.poolIdx;
|
|
37060
|
+
const target = this.pool[this.poolIdx];
|
|
37061
|
+
target.width = dims.width;
|
|
37062
|
+
target.height = dims.height;
|
|
37063
|
+
const ctx = target.getContext("2d");
|
|
37064
|
+
const imgData = ctx.createImageData(dims.width, dims.height);
|
|
37065
|
+
imgData.data.set(pixels);
|
|
37066
|
+
ctx.putImageData(imgData, 0, 0);
|
|
37067
|
+
this.displayedPixels = pixels;
|
|
37068
|
+
}
|
|
37069
|
+
}
|
|
37070
|
+
TextureFrameSeriesAnimator.Animator = Animator;
|
|
37071
|
+
function easeInOutQuad(t) {
|
|
37072
|
+
return t < 0.5 ? 2 * t * t : 1 - Math.pow(-2 * t + 2, 2) / 2;
|
|
37073
|
+
}
|
|
37074
|
+
function Now() {
|
|
37075
|
+
return typeof performance !== "undefined" ? performance.now() : Date.now();
|
|
37076
|
+
}
|
|
37077
|
+
})(TextureFrameSeriesAnimator || (TextureFrameSeriesAnimator = {}));
|
|
37078
|
+
|
|
37079
|
+
const TEXTURE_FRAME_SERIES_ANIMATOR_KEY = "TextureFrameSeriesAnimator.Animator";
|
|
36727
37080
|
var EntityRenderEnginePolygon;
|
|
36728
37081
|
(function (EntityRenderEnginePolygon) {
|
|
36729
37082
|
async function Render(params) {
|
|
@@ -36743,6 +37096,7 @@ var EntityRenderEnginePolygon;
|
|
|
36743
37096
|
const cFillColor = bFillColor ? ColorToCColor(bFillColor) : Color.fromCssColorString("rgba(139, 195, 74, 0.8)");
|
|
36744
37097
|
let textureDataUri = null;
|
|
36745
37098
|
let textureTraceEffective = null;
|
|
37099
|
+
let frameArchive = null;
|
|
36746
37100
|
if (fillType === Style.EPolygonFillType.Texture) {
|
|
36747
37101
|
const resolved = await resolveTexturedFill({
|
|
36748
37102
|
api: params.api,
|
|
@@ -36752,11 +37106,16 @@ var EntityRenderEnginePolygon;
|
|
|
36752
37106
|
});
|
|
36753
37107
|
textureDataUri = resolved.dataUri;
|
|
36754
37108
|
textureTraceEffective = resolved.effective;
|
|
37109
|
+
frameArchive = resolved.frameArchive || null;
|
|
36755
37110
|
}
|
|
36756
|
-
const hasFill = fillType === Style.EPolygonFillType.Texture
|
|
37111
|
+
const hasFill = fillType === Style.EPolygonFillType.Texture
|
|
37112
|
+
? Boolean(textureDataUri || frameArchive || cFillColor.alpha > 0)
|
|
37113
|
+
: cFillColor.alpha > 0;
|
|
36757
37114
|
const fillMaterial = textureDataUri
|
|
36758
37115
|
? new ImageMaterialProperty({ image: textureDataUri, transparent: true })
|
|
36759
|
-
:
|
|
37116
|
+
: frameArchive
|
|
37117
|
+
? Color.WHITE.withAlpha(0)
|
|
37118
|
+
: cFillColor;
|
|
36760
37119
|
const lineColorTrace = style.lineColor ? Calculator.TraceGetColor(style.lineColor, entity, params.tags) : { value: null, effective: null };
|
|
36761
37120
|
const bLineColor = lineColorTrace.value;
|
|
36762
37121
|
const cLineColor = bLineColor ? ColorToCColor(bLineColor) : Color.fromCssColorString("rgba(80, 80, 80, 0.8)");
|
|
@@ -36926,6 +37285,13 @@ var EntityRenderEnginePolygon;
|
|
|
36926
37285
|
}
|
|
36927
37286
|
cEntity.show = true;
|
|
36928
37287
|
}
|
|
37288
|
+
syncTextureFrameArchive(cEntity, frameArchive, params.viewer, style.textureColorMask);
|
|
37289
|
+
if (frameArchive && params.onSeriesDiscovered) {
|
|
37290
|
+
const segment = frameArchiveToSeriesSegment(frameArchive, params.entity);
|
|
37291
|
+
if (segment) {
|
|
37292
|
+
params.onSeriesDiscovered(segment);
|
|
37293
|
+
}
|
|
37294
|
+
}
|
|
36929
37295
|
if (hasOutline) {
|
|
36930
37296
|
let borderHeight = undefined;
|
|
36931
37297
|
if (heightRef != HeightReference.CLAMP_TO_GROUND) {
|
|
@@ -37134,7 +37500,9 @@ var EntityRenderEnginePolygon;
|
|
|
37134
37500
|
// Temporarily disabling re-using graphics for polygons as they have some bugs, and
|
|
37135
37501
|
// they don't support any animation yet.
|
|
37136
37502
|
// rendered: null
|
|
37137
|
-
rendered: (_c = params.rendered) === null || _c === void 0 ? void 0 : _c.get(entity.Bruce.ID)
|
|
37503
|
+
rendered: (_c = params.rendered) === null || _c === void 0 ? void 0 : _c.get(entity.Bruce.ID),
|
|
37504
|
+
menuItemId: params.menuItemId,
|
|
37505
|
+
onSeriesDiscovered: params.onSeriesDiscovered
|
|
37138
37506
|
});
|
|
37139
37507
|
if (cEntity) {
|
|
37140
37508
|
const name = await getName$3(api, entity);
|
|
@@ -37250,11 +37618,86 @@ async function getStyle$4(api, entity, styleId) {
|
|
|
37250
37618
|
// same polygon (or multiple polygons sharing a texture) don't refetch/reprocess the same image.
|
|
37251
37619
|
const _textureCache = new LRUCache(50);
|
|
37252
37620
|
/**
|
|
37253
|
-
*
|
|
37621
|
+
* Reconciles cEntity's TextureFrameSeriesAnimator.Animator (if any) against this render's resolved texture.
|
|
37622
|
+
* Called once cEntity is fully created/updated and definitely has a `polygon` graphics.
|
|
37623
|
+
* @param cEntity
|
|
37624
|
+
* @param frameArchive
|
|
37625
|
+
* @param viewer
|
|
37626
|
+
* @param textureColorMask
|
|
37627
|
+
*/
|
|
37628
|
+
function syncTextureFrameArchive(cEntity, frameArchive, viewer, textureColorMask) {
|
|
37629
|
+
const existing = cEntity[TEXTURE_FRAME_SERIES_ANIMATOR_KEY];
|
|
37630
|
+
if (frameArchive && existing && !existing.IsDisposed() && existing.GetArchiveUrl() === frameArchive.url) {
|
|
37631
|
+
return;
|
|
37632
|
+
}
|
|
37633
|
+
if (existing && !existing.IsDisposed()) {
|
|
37634
|
+
existing.Dispose();
|
|
37635
|
+
cEntity[TEXTURE_FRAME_SERIES_ANIMATOR_KEY] = null;
|
|
37636
|
+
}
|
|
37637
|
+
if (frameArchive) {
|
|
37638
|
+
const animator = new TextureFrameSeriesAnimator.Animator({
|
|
37639
|
+
viewer,
|
|
37640
|
+
entity: cEntity,
|
|
37641
|
+
archiveUrl: frameArchive.url,
|
|
37642
|
+
frames: frameArchive.metadata.Frames,
|
|
37643
|
+
textureColorMask
|
|
37644
|
+
});
|
|
37645
|
+
cEntity[TEXTURE_FRAME_SERIES_ANIMATOR_KEY] = animator;
|
|
37646
|
+
}
|
|
37647
|
+
}
|
|
37648
|
+
/**
|
|
37649
|
+
* Derives a min/max/label time-range segment from a resolved frame archive's Frames metadata,
|
|
37650
|
+
* for reporting up to whoever owns the menu item this entity belongs to (see IParams.onSeriesDiscovered).
|
|
37651
|
+
* @param frameArchive
|
|
37652
|
+
* @param entity
|
|
37653
|
+
*/
|
|
37654
|
+
function frameArchiveToSeriesSegment(frameArchive, entity) {
|
|
37655
|
+
var _a;
|
|
37656
|
+
const timestamps = frameArchive.metadata.Frames
|
|
37657
|
+
.map((f) => new Date(f.Timestamp))
|
|
37658
|
+
.filter((d) => !isNaN(d.getTime()));
|
|
37659
|
+
if (!timestamps.length) {
|
|
37660
|
+
return null;
|
|
37661
|
+
}
|
|
37662
|
+
return {
|
|
37663
|
+
key: frameArchive.url,
|
|
37664
|
+
min: new Date(Math.min(...timestamps.map((d) => d.getTime()))),
|
|
37665
|
+
max: new Date(Math.max(...timestamps.map((d) => d.getTime()))),
|
|
37666
|
+
label: ((_a = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _a === void 0 ? void 0 : _a.Name) || undefined
|
|
37667
|
+
};
|
|
37668
|
+
}
|
|
37669
|
+
/**
|
|
37670
|
+
* Returns if a value looks like a URL rather than a bare client file ID.
|
|
37254
37671
|
* @param value
|
|
37255
37672
|
*/
|
|
37256
|
-
function
|
|
37257
|
-
return /^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(value) || value.startsWith("//")
|
|
37673
|
+
function looksLikeUrl(value) {
|
|
37674
|
+
return /^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(value) || value.startsWith("//");
|
|
37675
|
+
}
|
|
37676
|
+
/**
|
|
37677
|
+
* Extracts a client file ID from a resolved polygon "texture" value, which is either a bare
|
|
37678
|
+
* file ID or a URL. Follows the "/file/<id>" route path regardless of domain,
|
|
37679
|
+
* eg: "https://host/file/AGPWMAQR6F5ZVDJXZVRODGLCJE.png" or "https://host/RV:1/file/AGPWMAQR6F5ZVDJXZVRODGLCJE?cc=1".
|
|
37680
|
+
* @param raw
|
|
37681
|
+
*/
|
|
37682
|
+
function extractClientFileIdFromTextureValue(raw) {
|
|
37683
|
+
if (!raw || typeof raw !== "string") {
|
|
37684
|
+
return null;
|
|
37685
|
+
}
|
|
37686
|
+
if (!looksLikeUrl(raw)) {
|
|
37687
|
+
return raw;
|
|
37688
|
+
}
|
|
37689
|
+
try {
|
|
37690
|
+
const withoutQuery = raw.split("?")[0];
|
|
37691
|
+
const match = withoutQuery.match(/\/file\/([^\/]+)/);
|
|
37692
|
+
if (!match) {
|
|
37693
|
+
return null;
|
|
37694
|
+
}
|
|
37695
|
+
return match[1].split(".")[0];
|
|
37696
|
+
}
|
|
37697
|
+
catch (e) {
|
|
37698
|
+
console.warn("Failed to parse client file ID from texture URL:", e, raw);
|
|
37699
|
+
return null;
|
|
37700
|
+
}
|
|
37258
37701
|
}
|
|
37259
37702
|
/**
|
|
37260
37703
|
* Resolves a polygon style's texture field and if a color ask is needed it tints the resulting image.
|
|
@@ -37262,7 +37705,11 @@ function looksLikeTextureUrl(value) {
|
|
|
37262
37705
|
*/
|
|
37263
37706
|
async function resolveTexturedFill(params) {
|
|
37264
37707
|
const { api, style, entity, tags } = params;
|
|
37265
|
-
|
|
37708
|
+
const textureValue = style.texture;
|
|
37709
|
+
if (textureValue && !Array.isArray(textureValue)) {
|
|
37710
|
+
return resolveTextureCondition({ api, condition: textureValue });
|
|
37711
|
+
}
|
|
37712
|
+
let textureRows = Array.isArray(textureValue) ? textureValue : [];
|
|
37266
37713
|
textureRows.forEach((row) => {
|
|
37267
37714
|
if (row.type == Calculator.EValueType.Color) {
|
|
37268
37715
|
row.type = Calculator.EValueType.Input;
|
|
@@ -37274,13 +37721,21 @@ async function resolveTexturedFill(params) {
|
|
|
37274
37721
|
return { dataUri: null, effective: textureTrace.effective };
|
|
37275
37722
|
}
|
|
37276
37723
|
let url = raw;
|
|
37277
|
-
if (!
|
|
37278
|
-
|
|
37279
|
-
|
|
37280
|
-
api
|
|
37281
|
-
fileId:
|
|
37282
|
-
|
|
37283
|
-
|
|
37724
|
+
if (!raw.startsWith("data:")) {
|
|
37725
|
+
const clientFileId = extractClientFileIdFromTextureValue(raw);
|
|
37726
|
+
if (clientFileId) {
|
|
37727
|
+
await api.Loading;
|
|
37728
|
+
const { clientFile } = await ClientFile.Get({ api, fileId: clientFileId });
|
|
37729
|
+
url = clientFile.URL;
|
|
37730
|
+
const clientFileData = clientFile.Data;
|
|
37731
|
+
if (TextureFrameSeriesAnimator.IsFrameArchiveMetadata(clientFileData)) {
|
|
37732
|
+
return {
|
|
37733
|
+
dataUri: null,
|
|
37734
|
+
effective: textureTrace.effective,
|
|
37735
|
+
frameArchive: { url, metadata: clientFileData.generation }
|
|
37736
|
+
};
|
|
37737
|
+
}
|
|
37738
|
+
}
|
|
37284
37739
|
}
|
|
37285
37740
|
const mask = style.textureColorMask;
|
|
37286
37741
|
const cacheKey = "texture-" + url + "-" + (mask ? mask.type + "-" + mask.minColor + "-" + mask.maxColor : "none");
|
|
@@ -37291,6 +37746,31 @@ async function resolveTexturedFill(params) {
|
|
|
37291
37746
|
}
|
|
37292
37747
|
return { dataUri: await prom, effective: textureTrace.effective };
|
|
37293
37748
|
}
|
|
37749
|
+
async function resolveTextureCondition(params) {
|
|
37750
|
+
const { api, condition } = params;
|
|
37751
|
+
const entityTypeSourceId = condition === null || condition === void 0 ? void 0 : condition["EntityType.Source.ID"];
|
|
37752
|
+
const attribute = condition === null || condition === void 0 ? void 0 : condition.Attribute;
|
|
37753
|
+
if (!api || !entityTypeSourceId || !attribute) {
|
|
37754
|
+
return { dataUri: null, effective: null };
|
|
37755
|
+
}
|
|
37756
|
+
await api.Loading;
|
|
37757
|
+
const clientFile = await ClientFile.FindGeneratedTexture({ api, entityTypeSourceId, attribute });
|
|
37758
|
+
if (!clientFile) {
|
|
37759
|
+
return { dataUri: null, effective: null };
|
|
37760
|
+
}
|
|
37761
|
+
const url = clientFile.URL;
|
|
37762
|
+
const clientFileData = clientFile.Data;
|
|
37763
|
+
if (TextureFrameSeriesAnimator.IsFrameArchiveMetadata(clientFileData)) {
|
|
37764
|
+
return { dataUri: null, effective: null, frameArchive: { url, metadata: clientFileData.generation } };
|
|
37765
|
+
}
|
|
37766
|
+
const cacheKey = "texture-" + url + "-none";
|
|
37767
|
+
let prom = _textureCache.Get(cacheKey);
|
|
37768
|
+
if (!prom) {
|
|
37769
|
+
prom = buildTintedTextureDataUri(url).catch(() => null);
|
|
37770
|
+
_textureCache.Set(cacheKey, prom);
|
|
37771
|
+
}
|
|
37772
|
+
return { dataUri: await prom, effective: null };
|
|
37773
|
+
}
|
|
37294
37774
|
/**
|
|
37295
37775
|
* Fetches an image and, if a color mask is provided, remaps its (assumed grayscale) pixel values
|
|
37296
37776
|
* into a gradient between the mask's minColor/maxColor, preserving source alpha.
|
|
@@ -37317,30 +37797,11 @@ async function buildTintedTextureDataUri(url, mask) {
|
|
|
37317
37797
|
const minColor = Color$1.ColorFromStr(mask.minColor) || { red: 0, green: 0, blue: 0, alpha: 1 };
|
|
37318
37798
|
const maxColor = Color$1.ColorFromStr(mask.maxColor) || { red: 255, green: 255, blue: 255, alpha: 1 };
|
|
37319
37799
|
const imageData = context.getImageData(0, 0, canvas.width, canvas.height);
|
|
37320
|
-
|
|
37321
|
-
for (let i = 0; i < data.length; i += 4) {
|
|
37322
|
-
// The texture is rendered black-to-white server-side, so any channel carries the value.
|
|
37323
|
-
const t = data[i] / 255;
|
|
37324
|
-
data[i] = Math.round(minColor.red + (maxColor.red - minColor.red) * t);
|
|
37325
|
-
data[i + 1] = Math.round(minColor.green + (maxColor.green - minColor.green) * t);
|
|
37326
|
-
data[i + 2] = Math.round(minColor.blue + (maxColor.blue - minColor.blue) * t);
|
|
37327
|
-
// Preserve source transparency (eg unrasterized pixels) blended with the mask's own alpha.
|
|
37328
|
-
const srcAlpha = data[i + 3] / 255;
|
|
37329
|
-
const maskAlpha = minColor.alpha + (maxColor.alpha - minColor.alpha) * t;
|
|
37330
|
-
data[i + 3] = Math.round(srcAlpha * maskAlpha * 255);
|
|
37331
|
-
}
|
|
37800
|
+
ApplyGrayscaleColorMask(imageData, minColor, maxColor);
|
|
37332
37801
|
context.putImageData(imageData, 0, 0);
|
|
37333
37802
|
}
|
|
37334
37803
|
return canvas.toDataURL("image/png");
|
|
37335
37804
|
}
|
|
37336
|
-
function loadImage(src) {
|
|
37337
|
-
return new Promise((res, rej) => {
|
|
37338
|
-
const image = new Image();
|
|
37339
|
-
image.onload = () => res(image);
|
|
37340
|
-
image.onerror = (e) => rej(e);
|
|
37341
|
-
image.src = src;
|
|
37342
|
-
});
|
|
37343
|
-
}
|
|
37344
37805
|
/**
|
|
37345
37806
|
* Compares two color materials.
|
|
37346
37807
|
* Returns if they are equal.
|
|
@@ -37685,6 +38146,7 @@ var EntityRenderEngine;
|
|
|
37685
38146
|
entities: [],
|
|
37686
38147
|
zoomItems: {},
|
|
37687
38148
|
menuItemId: params.menuItemId,
|
|
38149
|
+
onSeriesDiscovered: params.onSeriesDiscovered,
|
|
37688
38150
|
visualRegister: params.visualRegister
|
|
37689
38151
|
};
|
|
37690
38152
|
const updated = new Map();
|
|
@@ -38650,7 +39112,7 @@ var StyleUtils;
|
|
|
38650
39112
|
StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
|
|
38651
39113
|
})(StyleUtils || (StyleUtils = {}));
|
|
38652
39114
|
|
|
38653
|
-
const VERSION = "6.9.
|
|
39115
|
+
const VERSION = "6.9.9";
|
|
38654
39116
|
/**
|
|
38655
39117
|
* Updates the environment instance used by bruce-cesium to one specified.
|
|
38656
39118
|
* This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.
|