bruce-cesium 2.8.8 → 2.9.0

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.
@@ -1937,6 +1937,34 @@
1937
1937
  }
1938
1938
  return length;
1939
1939
  }
1940
+ var _billboardCache = new bruceModels.LRUCache(100);
1941
+ var POINT_BILLBOARD_PADDING = 1;
1942
+ var createCircleBillboard = function (size, colorCss) {
1943
+ var key = size + "-" + colorCss;
1944
+ var cacheData = _billboardCache.Get(key);
1945
+ if ((cacheData === null || cacheData === void 0 ? void 0 : cacheData.canvas) instanceof HTMLCanvasElement) {
1946
+ return cacheData;
1947
+ }
1948
+ // Slight padding to avoid corners clipping.
1949
+ var canvasSize = size + (POINT_BILLBOARD_PADDING * 4);
1950
+ var canvas = document.createElement("canvas");
1951
+ canvas.width = canvasSize;
1952
+ canvas.height = canvasSize;
1953
+ var context = canvas.getContext("2d");
1954
+ context.beginPath();
1955
+ context.arc(canvasSize / 2, canvasSize / 2, size / 2, 0, 2 * Math.PI, false);
1956
+ context.fillStyle = colorCss;
1957
+ context.fill();
1958
+ var data = {
1959
+ canvas: canvas,
1960
+ colorCss: colorCss,
1961
+ size: size,
1962
+ height: canvasSize,
1963
+ width: canvasSize
1964
+ };
1965
+ _billboardCache.Set(key, data);
1966
+ return data;
1967
+ };
1940
1968
  (function (EntityRenderEngine) {
1941
1969
  function Render(params) {
1942
1970
  var _a, _b, _c, _d, _e, _f, _g, _h;
@@ -2196,7 +2224,7 @@
2196
2224
  (function (Point) {
2197
2225
  function Render(params) {
2198
2226
  return __awaiter(this, void 0, void 0, function () {
2199
- var entity, style, type, cEntity, siblings, iconUrlRows, icon, iconUrl_1, res, blob_1, e_4, e_5, iconScale, disableDepthTest, heightRef, radius, bFill, cFill, outline, cOutline, outlineWidth, bOutline, heightRef, pos3d, extrusion, outlineExtrusion, bColor, cColor, size, heightRef;
2227
+ var entity, style, type, cEntity, siblings, iconUrlRows, icon, iconUrl_1, res, blob_1, e_4, e_5, iconScale, disableDepthTest, heightRef, radius, bFill, cFill, outline, cOutline, outlineWidth, bOutline, heightRef, pos3d, extrusion, outlineExtrusion, bColor, cColor, size, heightRef, circleBillboard;
2200
2228
  return __generator(this, function (_a) {
2201
2229
  switch (_a.label) {
2202
2230
  case 0:
@@ -2294,8 +2322,7 @@
2294
2322
  heightReference: getHeightRef(style),
2295
2323
  scale: iconScale,
2296
2324
  disableDepthTestDistance: disableDepthTest ? Number.POSITIVE_INFINITY : undefined,
2297
- distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance),
2298
- height: _fileHeightCache[iconUrl_1]
2325
+ distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance)
2299
2326
  // Would be great once we have a setting for this.
2300
2327
  // translucencyByDistance: getTranslucencyByDistance(params.minDistance, params.maxDistance),
2301
2328
  },
@@ -2307,6 +2334,7 @@
2307
2334
  }),
2308
2335
  show: true
2309
2336
  });
2337
+ cEntity.billboard._billboardSize = _fileHeightCache[iconUrl_1];
2310
2338
  }
2311
2339
  }
2312
2340
  _a.label = 12;
@@ -2386,11 +2414,22 @@
2386
2414
  return [2 /*return*/, null];
2387
2415
  }
2388
2416
  heightRef = getHeightRef(style);
2417
+ circleBillboard = createCircleBillboard(size, cColor.toCssColorString());
2389
2418
  cEntity = new Cesium.Entity({
2390
- point: {
2391
- pixelSize: size,
2392
- color: cColor,
2393
- heightReference: getHeightRef(style),
2419
+ // point: {
2420
+ // pixelSize: size,
2421
+ // color: cColor,
2422
+ // heightReference: getHeightRef(style),
2423
+ // distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance)
2424
+ // },
2425
+ // We are generating a billboard instead of using the point.
2426
+ // This is because points were behaving strangely where they would appear oblong shapes.
2427
+ // This occurred consistently when rendering many icons and points at the same time.
2428
+ billboard: {
2429
+ height: circleBillboard.height,
2430
+ width: circleBillboard.width,
2431
+ image: circleBillboard.canvas,
2432
+ heightReference: heightRef,
2394
2433
  distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance)
2395
2434
  },
2396
2435
  position: exports.EntityUtils.GetPos({
@@ -2401,6 +2440,7 @@
2401
2440
  }),
2402
2441
  show: true
2403
2442
  });
2443
+ cEntity.billboard._billboardSize = Math.ceil(circleBillboard.height / 2);
2404
2444
  }
2405
2445
  if (cEntity) {
2406
2446
  cEntity._siblingGraphics = siblings;
@@ -3893,7 +3933,7 @@
3893
3933
  }
3894
3934
  else if (visual.billboard) {
3895
3935
  heightRef = getValue$1(this.viewer, visual.billboard.heightReference);
3896
- height = getValue$1(this.viewer, visual.billboard.height);
3936
+ height = visual.billboard._billboardSize;
3897
3937
  if (height) {
3898
3938
  scale = EnsureNumber(getValue$1(this.viewer, visual.billboard.scale), 1);
3899
3939
  pixelOffset.y = -(height * scale);
@@ -9926,11 +9966,8 @@
9926
9966
  * @param relation
9927
9967
  */
9928
9968
  Manager.prototype.shouldRenderRelation = function (relation) {
9929
- var _a, _b, _c;
9930
- if (((_a = this.item.relationTypeIds) === null || _a === void 0 ? void 0 : _a.length) && !this.item.relationTypeIds.includes(relation["Relation.Type.ID"])) {
9931
- return false;
9932
- }
9933
- var renderedIds = (_c = (_b = this.item) === null || _b === void 0 ? void 0 : _b.BruceEntity) === null || _c === void 0 ? void 0 : _c.EntityIds;
9969
+ var _a, _b;
9970
+ var renderedIds = (_b = (_a = this.item) === null || _a === void 0 ? void 0 : _a.BruceEntity) === null || _b === void 0 ? void 0 : _b.EntityIds;
9934
9971
  if (!renderedIds) {
9935
9972
  return false;
9936
9973
  }
@@ -15948,9 +15985,13 @@
15948
15985
  // We check in case something else is also requesting renders.
15949
15986
  var lastRenderTime = viewer.scene.lastRenderTime;
15950
15987
  if (!lastRenderTime || Cesium.JulianDate.secondsDifference(Cesium.JulianDate.now(), lastRenderTime) > 3) {
15951
- viewer.scene.requestRender();
15988
+ // Check if window is active/in focus.
15989
+ // TODO: Should render the moment it is in focus as well.
15990
+ if (document.hasFocus()) {
15991
+ viewer.scene.requestRender();
15992
+ }
15952
15993
  }
15953
- }, 3500);
15994
+ }, 1500);
15954
15995
  }
15955
15996
  (function (ViewerUtils) {
15956
15997
  /**
@@ -16103,7 +16144,7 @@
16103
16144
  ViewerUtils.CreateWidgets = CreateWidgets;
16104
16145
  })(exports.ViewerUtils || (exports.ViewerUtils = {}));
16105
16146
 
16106
- var VERSION$1 = "2.8.8";
16147
+ var VERSION$1 = "2.9.0";
16107
16148
 
16108
16149
  exports.VERSION = VERSION$1;
16109
16150
  exports.CesiumViewMonitor = CesiumViewMonitor;