bruce-cesium 0.0.2 → 0.0.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 +335 -199
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +310 -203
- package/dist/bruce-cesium.umd.js.map +1 -1
- package/dist/lib/rendering/entity-render-engine.js.map +1 -1
- package/dist/lib/rendering/menu-item-manager.js +26 -0
- package/dist/lib/rendering/menu-item-manager.js.map +1 -1
- package/dist/lib/rendering/render-helper.js +3 -0
- package/dist/lib/rendering/render-helper.js.map +1 -1
- package/dist/lib/rendering/render-managers/entities/entities-ids-render-manager.js +5 -1
- package/dist/lib/rendering/render-managers/entities/entities-ids-render-manager.js.map +1 -1
- package/dist/lib/rendering/render-managers/entities/entities-loaded-render-manager.js +6 -1
- package/dist/lib/rendering/render-managers/entities/entities-loaded-render-manager.js.map +1 -1
- package/dist/lib/rendering/render-managers/entities/entities-render-manager.js +5 -1
- package/dist/lib/rendering/render-managers/entities/entities-render-manager.js.map +1 -1
- package/dist/lib/rendering/render-managers/entities/entity-render-manager.js +4 -1
- package/dist/lib/rendering/render-managers/entities/entity-render-manager.js.map +1 -1
- package/dist/lib/rendering/render-managers/tilesets/tileset-cad-render-manager.js +5 -4
- package/dist/lib/rendering/render-managers/tilesets/tileset-cad-render-manager.js.map +1 -1
- package/dist/lib/rendering/tileset-render-engine.js +1 -1
- package/dist/lib/rendering/tileset-render-engine.js.map +1 -1
- package/dist/lib/rendering/visuals-register.js +166 -139
- package/dist/lib/rendering/visuals-register.js.map +1 -1
- package/dist/lib/utils/drawing-utils.js +8 -0
- package/dist/lib/utils/drawing-utils.js.map +1 -1
- package/dist/lib/utils/entity-utils.js +33 -0
- package/dist/lib/utils/entity-utils.js.map +1 -1
- package/dist/lib/utils/measure-utils.js +6 -0
- package/dist/lib/utils/measure-utils.js.map +1 -1
- package/dist/lib/viewer/cesium-view-monitor.js +3 -0
- package/dist/lib/viewer/cesium-view-monitor.js.map +1 -1
- package/dist/lib/viewer/viewer-utils.js +10 -0
- package/dist/lib/viewer/viewer-utils.js.map +1 -1
- package/dist/types/rendering/entity-render-engine.d.ts +5 -5
- package/dist/types/rendering/menu-item-manager.d.ts +17 -1
- package/dist/types/rendering/render-helper.d.ts +3 -0
- package/dist/types/rendering/render-managers/entities/entities-ids-render-manager.d.ts +5 -1
- package/dist/types/rendering/render-managers/entities/entities-loaded-render-manager.d.ts +6 -1
- package/dist/types/rendering/render-managers/entities/entities-render-manager.d.ts +5 -1
- package/dist/types/rendering/render-managers/entities/entity-render-manager.d.ts +4 -1
- package/dist/types/rendering/render-managers/tilesets/tileset-cad-render-manager.d.ts +5 -1
- package/dist/types/rendering/tileset-render-engine.d.ts +2 -2
- package/dist/types/rendering/visuals-register.d.ts +38 -20
- package/dist/types/utils/drawing-utils.d.ts +8 -0
- package/dist/types/utils/entity-utils.d.ts +12 -0
- package/dist/types/utils/measure-utils.d.ts +6 -0
- package/dist/types/viewer/cesium-view-monitor.d.ts +3 -0
- package/dist/types/viewer/viewer-utils.d.ts +10 -0
- package/package.json +1 -1
package/dist/bruce-cesium.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '
|
|
4
|
-
(factory((global.bruceCesium = {}),global.
|
|
5
|
-
}(this, (function (exports,bruceModels
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('cesium'), require('bruce-models')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'cesium', 'bruce-models'], factory) :
|
|
4
|
+
(factory((global.bruceCesium = {}),global.Cesium,global.bruceModels));
|
|
5
|
+
}(this, (function (exports,Cesium,bruceModels) { 'use strict';
|
|
6
6
|
|
|
7
7
|
var TIME_LAG = 300;
|
|
8
8
|
var POSITION_CHECK_TIMER = 950;
|
|
@@ -75,6 +75,9 @@
|
|
|
75
75
|
function arePosEqual(a, b) {
|
|
76
76
|
return a.latitude == b.latitude && a.longitude == b.longitude;
|
|
77
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Monitors and emits events when the Cesium view changes.
|
|
80
|
+
*/
|
|
78
81
|
var CesiumViewMonitor = /** @class */ (function () {
|
|
79
82
|
function CesiumViewMonitor(viewer) {
|
|
80
83
|
var _this = this;
|
|
@@ -221,6 +224,12 @@
|
|
|
221
224
|
}());
|
|
222
225
|
|
|
223
226
|
(function (ViewerUtils) {
|
|
227
|
+
/**
|
|
228
|
+
* Creates a Cesium viewer in a given HTML container and returns it.
|
|
229
|
+
* This will kill all widgets in the process.
|
|
230
|
+
* @param container
|
|
231
|
+
* @returns
|
|
232
|
+
*/
|
|
224
233
|
function InitViewer(container) {
|
|
225
234
|
if (container._cViewer) {
|
|
226
235
|
throw new Error("Container already has a viewer.");
|
|
@@ -254,6 +263,10 @@
|
|
|
254
263
|
}
|
|
255
264
|
}
|
|
256
265
|
ViewerUtils.DestroyWidget = DestroyWidget;
|
|
266
|
+
/**
|
|
267
|
+
* Hides all unnecessary elements from the Cesium viewer container.
|
|
268
|
+
* @param viewer
|
|
269
|
+
*/
|
|
257
270
|
function StyleContainer(viewer) {
|
|
258
271
|
var _a;
|
|
259
272
|
var container = viewer.container;
|
|
@@ -356,6 +369,14 @@
|
|
|
356
369
|
|
|
357
370
|
var DrawingUtils;
|
|
358
371
|
(function (DrawingUtils) {
|
|
372
|
+
/**
|
|
373
|
+
* Returns the point across a polyline at a given distance.
|
|
374
|
+
* If the distance exceeds the length of the line, the point will be placed at the end of the line.
|
|
375
|
+
* @param viewer
|
|
376
|
+
* @param positions
|
|
377
|
+
* @param distance
|
|
378
|
+
* @returns
|
|
379
|
+
*/
|
|
359
380
|
function PointAcrossPolyline(viewer, positions, distance) {
|
|
360
381
|
if (positions.length > 1) {
|
|
361
382
|
var currentDistance = 0;
|
|
@@ -387,6 +408,12 @@
|
|
|
387
408
|
|
|
388
409
|
var MeasureUtils;
|
|
389
410
|
(function (MeasureUtils) {
|
|
411
|
+
/**
|
|
412
|
+
* Returns the total distance in meters between an array of points.
|
|
413
|
+
* This distance is NOT following the terrain.
|
|
414
|
+
* @param posses
|
|
415
|
+
* @returns
|
|
416
|
+
*/
|
|
390
417
|
function MeasurePolyline(posses) {
|
|
391
418
|
if (posses.length < 2) {
|
|
392
419
|
return 0;
|
|
@@ -410,8 +437,27 @@
|
|
|
410
437
|
MeasureUtils.MeasurePolyline = MeasurePolyline;
|
|
411
438
|
})(MeasureUtils || (MeasureUtils = {}));
|
|
412
439
|
|
|
440
|
+
function traverseEntity(cEntity, arr) {
|
|
441
|
+
if (cEntity._parentEntity) {
|
|
442
|
+
traverseEntity(cEntity._parentEntity, arr);
|
|
443
|
+
}
|
|
444
|
+
if (cEntity._siblingGraphics) {
|
|
445
|
+
for (var i = 0; i < cEntity._siblingGraphics.length; i++) {
|
|
446
|
+
var sibling = cEntity._siblingGraphics[i];
|
|
447
|
+
traverseEntity(sibling, arr);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
arr.push(cEntity);
|
|
451
|
+
}
|
|
413
452
|
var EntityUtils;
|
|
414
453
|
(function (EntityUtils) {
|
|
454
|
+
/**
|
|
455
|
+
* Returns an entity's position.
|
|
456
|
+
* This will attempt to calculate it from multiple sources of data.
|
|
457
|
+
* @param viewer
|
|
458
|
+
* @param entity
|
|
459
|
+
* @returns
|
|
460
|
+
*/
|
|
415
461
|
function GetPos(viewer, entity) {
|
|
416
462
|
if (entity.location && bruceModels.Carto.ValidateCarto(entity.location)) {
|
|
417
463
|
var location_1 = entity.location;
|
|
@@ -468,6 +514,20 @@
|
|
|
468
514
|
return null;
|
|
469
515
|
}
|
|
470
516
|
EntityUtils.GetPos = GetPos;
|
|
517
|
+
/**
|
|
518
|
+
* Returns entity and any associated parent/sibling entities as a flat array.
|
|
519
|
+
* @param entity
|
|
520
|
+
*/
|
|
521
|
+
function GatherEntity(entity) {
|
|
522
|
+
if (entity instanceof Cesium.Entity) {
|
|
523
|
+
var cEntity = entity;
|
|
524
|
+
var items = [];
|
|
525
|
+
traverseEntity(cEntity, items);
|
|
526
|
+
return items;
|
|
527
|
+
}
|
|
528
|
+
return [entity];
|
|
529
|
+
}
|
|
530
|
+
EntityUtils.GatherEntity = GatherEntity;
|
|
471
531
|
})(EntityUtils || (EntityUtils = {}));
|
|
472
532
|
|
|
473
533
|
(function (RenderManager) {
|
|
@@ -1394,7 +1454,7 @@
|
|
|
1394
1454
|
this.visualsManager.Add({
|
|
1395
1455
|
entityId: id,
|
|
1396
1456
|
menuItemId: this.item.id,
|
|
1397
|
-
|
|
1457
|
+
visual: cEntity,
|
|
1398
1458
|
priority: 0
|
|
1399
1459
|
});
|
|
1400
1460
|
}
|
|
@@ -1486,7 +1546,7 @@
|
|
|
1486
1546
|
this.visualsManager.Add({
|
|
1487
1547
|
entityId: id,
|
|
1488
1548
|
menuItemId: this.item.id,
|
|
1489
|
-
|
|
1549
|
+
visual: cEntity,
|
|
1490
1550
|
priority: 0
|
|
1491
1551
|
});
|
|
1492
1552
|
}
|
|
@@ -1505,6 +1565,221 @@
|
|
|
1505
1565
|
EntitiesLoadedRenderManager.Manager = Manager;
|
|
1506
1566
|
})(exports.EntitiesLoadedRenderManager || (exports.EntitiesLoadedRenderManager = {}));
|
|
1507
1567
|
|
|
1568
|
+
function removeEntity(viewer, visual) {
|
|
1569
|
+
unmarkEntity(visual);
|
|
1570
|
+
if (visual instanceof Cesium.Entity) {
|
|
1571
|
+
exports.EntityRenderEngine.Remove(viewer, visual);
|
|
1572
|
+
}
|
|
1573
|
+
else if (visual instanceof Cesium.Primitive) {
|
|
1574
|
+
if (viewer.scene.primitives.contains(visual)) {
|
|
1575
|
+
viewer.scene.primitives.remove(visual);
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
else if (visual instanceof Cesium.Cesium3DTileFeature) {
|
|
1579
|
+
// No way to tell if changing show will crash it!
|
|
1580
|
+
try {
|
|
1581
|
+
visual.show = false;
|
|
1582
|
+
}
|
|
1583
|
+
catch (e) {
|
|
1584
|
+
console.error(e);
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
function updateCEntityShow(viewer, visual, show) {
|
|
1589
|
+
if (visual._parentEntity) {
|
|
1590
|
+
updateCEntityShow(viewer, visual._parentEntity, show);
|
|
1591
|
+
}
|
|
1592
|
+
if (visual._siblingGraphics) {
|
|
1593
|
+
for (var i = 0; i < visual._siblingGraphics.length; i++) {
|
|
1594
|
+
var sibling = visual._siblingGraphics[i];
|
|
1595
|
+
updateCEntityShow(viewer, sibling, show);
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
if (viewer.entities.contains(visual)) {
|
|
1599
|
+
visual.show = show;
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
function updateEntityShow(viewer, visual, show) {
|
|
1603
|
+
if (visual instanceof Cesium.Entity) {
|
|
1604
|
+
updateCEntityShow(viewer, visual, show);
|
|
1605
|
+
}
|
|
1606
|
+
else if (visual instanceof Cesium.Primitive) {
|
|
1607
|
+
if (viewer.scene.primitives.contains(visual)) {
|
|
1608
|
+
visual.show = show;
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
else if (visual instanceof Cesium.Cesium3DTileFeature) {
|
|
1612
|
+
// No way to tell if changing show will crash it!
|
|
1613
|
+
try {
|
|
1614
|
+
visual.show = show;
|
|
1615
|
+
}
|
|
1616
|
+
catch (e) {
|
|
1617
|
+
console.error(e);
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
function updateEntity(viewer, entityRegos) {
|
|
1622
|
+
var highestPriority = null;
|
|
1623
|
+
for (var i = 0; i < entityRegos.length; i++) {
|
|
1624
|
+
var rego = entityRegos[i];
|
|
1625
|
+
if (highestPriority === null || rego.priority > highestPriority.priority) {
|
|
1626
|
+
highestPriority = rego;
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
for (var i = 0; i < entityRegos.length; i++) {
|
|
1630
|
+
var rego = entityRegos[i];
|
|
1631
|
+
updateEntityShow(viewer, rego.visual, rego === highestPriority);
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
function markEntity(register, rego, visual) {
|
|
1635
|
+
var vis = visual;
|
|
1636
|
+
vis._register = register;
|
|
1637
|
+
vis._rego = rego;
|
|
1638
|
+
if (visual instanceof Cesium.Entity) {
|
|
1639
|
+
var visEnt = visual;
|
|
1640
|
+
if (visEnt._parentEntity) {
|
|
1641
|
+
markEntity(register, rego, visEnt._parentEntity);
|
|
1642
|
+
}
|
|
1643
|
+
if (visEnt._siblingGraphics) {
|
|
1644
|
+
for (var i = 0; i < visEnt._siblingGraphics.length; i++) {
|
|
1645
|
+
markEntity(register, rego, visEnt._siblingGraphics[i]);
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
function unmarkEntity(visual) {
|
|
1651
|
+
var vis = visual;
|
|
1652
|
+
vis._register = null;
|
|
1653
|
+
if (visual instanceof Cesium.Entity) {
|
|
1654
|
+
var visEnt = visual;
|
|
1655
|
+
if (visEnt._parentEntity) {
|
|
1656
|
+
unmarkEntity(visEnt._parentEntity);
|
|
1657
|
+
}
|
|
1658
|
+
if (visEnt._siblingGraphics) {
|
|
1659
|
+
for (var i = 0; i < visEnt._siblingGraphics.length; i++) {
|
|
1660
|
+
unmarkEntity(visEnt._siblingGraphics[i]);
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
(function (VisualsRegister) {
|
|
1666
|
+
var Register = /** @class */ (function () {
|
|
1667
|
+
function Register(viewer) {
|
|
1668
|
+
this.id = bruceModels.ObjectUtils.UId();
|
|
1669
|
+
this.rego = {};
|
|
1670
|
+
this.onUpdate = null;
|
|
1671
|
+
this.viewer = viewer;
|
|
1672
|
+
}
|
|
1673
|
+
Object.defineProperty(Register.prototype, "Id", {
|
|
1674
|
+
get: function () {
|
|
1675
|
+
return this.id;
|
|
1676
|
+
},
|
|
1677
|
+
enumerable: false,
|
|
1678
|
+
configurable: true
|
|
1679
|
+
});
|
|
1680
|
+
Object.defineProperty(Register.prototype, "OnUpdate", {
|
|
1681
|
+
get: function () {
|
|
1682
|
+
return this.onUpdate;
|
|
1683
|
+
},
|
|
1684
|
+
enumerable: false,
|
|
1685
|
+
configurable: true
|
|
1686
|
+
});
|
|
1687
|
+
Register.prototype.Add = function (rego) {
|
|
1688
|
+
var _a, _b;
|
|
1689
|
+
this.Remove(rego.entityId, rego.menuItemId, false);
|
|
1690
|
+
var entityId = rego.entityId;
|
|
1691
|
+
var entityRegos = (_a = this.rego[entityId]) !== null && _a !== void 0 ? _a : [];
|
|
1692
|
+
entityRegos.push(rego);
|
|
1693
|
+
this.rego[entityId] = entityRegos;
|
|
1694
|
+
markEntity(this, rego, rego.visual);
|
|
1695
|
+
updateEntity(this.viewer, this.rego[entityId]);
|
|
1696
|
+
(_b = this.onUpdate) === null || _b === void 0 ? void 0 : _b.Trigger({ rego: rego, isAdding: true });
|
|
1697
|
+
};
|
|
1698
|
+
Register.prototype.GetVisuals = function (entityId, menuItemId) {
|
|
1699
|
+
var _a;
|
|
1700
|
+
var entityRegos = this.rego[entityId];
|
|
1701
|
+
if (!entityRegos) {
|
|
1702
|
+
return [];
|
|
1703
|
+
}
|
|
1704
|
+
var visuals = (_a = entityRegos.find(function (r) { return r.menuItemId === menuItemId; })) === null || _a === void 0 ? void 0 : _a.visual;
|
|
1705
|
+
return visuals !== null && visuals !== void 0 ? visuals : [];
|
|
1706
|
+
};
|
|
1707
|
+
Register.prototype.RemoveByEntityId = function (id) {
|
|
1708
|
+
var _a;
|
|
1709
|
+
var entityRegos = this.rego[id];
|
|
1710
|
+
if (!entityRegos) {
|
|
1711
|
+
return;
|
|
1712
|
+
}
|
|
1713
|
+
for (var i = 0; i < entityRegos.length; i++) {
|
|
1714
|
+
var rego = entityRegos[i];
|
|
1715
|
+
(_a = this.onUpdate) === null || _a === void 0 ? void 0 : _a.Trigger({ rego: rego, isAdding: false });
|
|
1716
|
+
removeEntity(this.viewer, rego.visual);
|
|
1717
|
+
}
|
|
1718
|
+
this.rego[id] = [];
|
|
1719
|
+
delete this.rego[id];
|
|
1720
|
+
};
|
|
1721
|
+
Register.prototype.RemoveByMenuItemId = function (id) {
|
|
1722
|
+
var _a;
|
|
1723
|
+
for (var entityId in this.rego) {
|
|
1724
|
+
var entityRegos = this.rego[entityId];
|
|
1725
|
+
if (entityRegos) {
|
|
1726
|
+
var rego = entityRegos.find(function (r) { return r.menuItemId === id; });
|
|
1727
|
+
if (!rego) {
|
|
1728
|
+
continue;
|
|
1729
|
+
}
|
|
1730
|
+
(_a = this.onUpdate) === null || _a === void 0 ? void 0 : _a.Trigger({ rego: rego, isAdding: false });
|
|
1731
|
+
removeEntity(this.viewer, rego.visual);
|
|
1732
|
+
var doesInclude = this.rego[entityId].find(function (r) { return r.menuItemId === id; });
|
|
1733
|
+
if (doesInclude) {
|
|
1734
|
+
this.rego[entityId] = entityRegos.filter(function (r) { return r.menuItemId !== id; });
|
|
1735
|
+
updateEntity(this.viewer, this.rego[entityId]);
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
};
|
|
1740
|
+
Register.prototype.Remove = function (entityId, menuItemId, _doUpdate) {
|
|
1741
|
+
var _a;
|
|
1742
|
+
if (_doUpdate === void 0) { _doUpdate = true; }
|
|
1743
|
+
var entityRegos = this.rego[entityId];
|
|
1744
|
+
if (!entityRegos) {
|
|
1745
|
+
return;
|
|
1746
|
+
}
|
|
1747
|
+
var rego = entityRegos.find(function (r) { return r.menuItemId === menuItemId; });
|
|
1748
|
+
if (!rego) {
|
|
1749
|
+
return;
|
|
1750
|
+
}
|
|
1751
|
+
(_a = this.onUpdate) === null || _a === void 0 ? void 0 : _a.Trigger({ rego: rego, isAdding: false });
|
|
1752
|
+
removeEntity(this.viewer, rego.visual);
|
|
1753
|
+
this.rego[entityId] = entityRegos.filter(function (r) { return r.menuItemId !== menuItemId; });
|
|
1754
|
+
if (_doUpdate) {
|
|
1755
|
+
updateEntity(this.viewer, this.rego[entityId]);
|
|
1756
|
+
}
|
|
1757
|
+
};
|
|
1758
|
+
/**
|
|
1759
|
+
* Returns an array of drilled visuals associated with this register.
|
|
1760
|
+
* The top array item is the first found.
|
|
1761
|
+
* @param cursor
|
|
1762
|
+
* @returns
|
|
1763
|
+
*/
|
|
1764
|
+
Register.prototype.GetFromCursor = function (cursor) {
|
|
1765
|
+
var _a;
|
|
1766
|
+
var found = [];
|
|
1767
|
+
var picked = this.viewer.scene.drillPick(new Cesium.Cartesian2(cursor.x, cursor.y), 5);
|
|
1768
|
+
for (var i = 0; i < picked.length; i++) {
|
|
1769
|
+
var object = picked[i];
|
|
1770
|
+
var entity = (object && object.id && object.id instanceof Cesium.Entity ? object.id : object);
|
|
1771
|
+
var visual = entity;
|
|
1772
|
+
if (((_a = visual === null || visual === void 0 ? void 0 : visual._register) === null || _a === void 0 ? void 0 : _a.Id) == this.id) {
|
|
1773
|
+
found.push(visual._rego);
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
return found;
|
|
1777
|
+
};
|
|
1778
|
+
return Register;
|
|
1779
|
+
}());
|
|
1780
|
+
VisualsRegister.Register = Register;
|
|
1781
|
+
})(exports.VisualsRegister || (exports.VisualsRegister = {}));
|
|
1782
|
+
|
|
1508
1783
|
(function (EntitiesIdsRenderManager) {
|
|
1509
1784
|
var Manager = /** @class */ (function () {
|
|
1510
1785
|
function Manager(viewer, visualsManager, api, item) {
|
|
@@ -1581,7 +1856,7 @@
|
|
|
1581
1856
|
this.visualsManager.Add({
|
|
1582
1857
|
entityId: id,
|
|
1583
1858
|
menuItemId: this.item.id,
|
|
1584
|
-
|
|
1859
|
+
visual: cEntity,
|
|
1585
1860
|
priority: 0
|
|
1586
1861
|
});
|
|
1587
1862
|
}
|
|
@@ -1672,7 +1947,7 @@
|
|
|
1672
1947
|
this.visualsManager.Add({
|
|
1673
1948
|
entityId: entity.Bruce.ID,
|
|
1674
1949
|
menuItemId: this.item.id,
|
|
1675
|
-
|
|
1950
|
+
visual: cEntity,
|
|
1676
1951
|
priority: 0
|
|
1677
1952
|
});
|
|
1678
1953
|
}
|
|
@@ -2080,7 +2355,7 @@
|
|
|
2080
2355
|
var bColor = (((_a = style.modelStyle) === null || _a === void 0 ? void 0 : _a.fillColor) ? bruceModels.Calculator.GetValue(style.modelStyle.fillColor, data, []) : null);
|
|
2081
2356
|
if (bColor != null) {
|
|
2082
2357
|
var cColor = colorToCColor$1(bColor);
|
|
2083
|
-
var visual = entity.
|
|
2358
|
+
var visual = entity.visual;
|
|
2084
2359
|
if (visual && visual instanceof Cesium.Cesium3DTileFeature) {
|
|
2085
2360
|
visual.color = cColor;
|
|
2086
2361
|
}
|
|
@@ -2203,7 +2478,7 @@
|
|
|
2203
2478
|
entityTypeId: null,
|
|
2204
2479
|
menuItemId: this.item.id,
|
|
2205
2480
|
priority: 0,
|
|
2206
|
-
|
|
2481
|
+
visual: feature
|
|
2207
2482
|
};
|
|
2208
2483
|
if (version == 1) {
|
|
2209
2484
|
var pathStr = feature.getProperty("BrucePath");
|
|
@@ -2304,12 +2579,32 @@
|
|
|
2304
2579
|
TilesetCadRenderManager.Manager = Manager;
|
|
2305
2580
|
})(exports.TilesetCadRenderManager || (exports.TilesetCadRenderManager = {}));
|
|
2306
2581
|
|
|
2582
|
+
/**
|
|
2583
|
+
* Utility to keep track of enabled menu items within a Cesium viewer.
|
|
2584
|
+
*/
|
|
2307
2585
|
var MenuItemManager = /** @class */ (function () {
|
|
2308
2586
|
function MenuItemManager(viewer, visualsRegister) {
|
|
2309
2587
|
this.items = [];
|
|
2310
2588
|
this.viewer = viewer;
|
|
2589
|
+
if (!visualsRegister) {
|
|
2590
|
+
visualsRegister = new exports.VisualsRegister.Register(viewer);
|
|
2591
|
+
}
|
|
2311
2592
|
this.visualsRegister = visualsRegister;
|
|
2312
2593
|
}
|
|
2594
|
+
Object.defineProperty(MenuItemManager.prototype, "VisualsRegister", {
|
|
2595
|
+
get: function () {
|
|
2596
|
+
return this.visualsRegister;
|
|
2597
|
+
},
|
|
2598
|
+
enumerable: false,
|
|
2599
|
+
configurable: true
|
|
2600
|
+
});
|
|
2601
|
+
/**
|
|
2602
|
+
* Renders a given menu item and all ids children.
|
|
2603
|
+
* Will return the enabled item id.
|
|
2604
|
+
* @param api
|
|
2605
|
+
* @param item
|
|
2606
|
+
* @returns
|
|
2607
|
+
*/
|
|
2313
2608
|
MenuItemManager.prototype.RenderItem = function (api, item) {
|
|
2314
2609
|
var _a;
|
|
2315
2610
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -2384,6 +2679,11 @@
|
|
|
2384
2679
|
});
|
|
2385
2680
|
});
|
|
2386
2681
|
};
|
|
2682
|
+
/**
|
|
2683
|
+
* Disables a menu item by ids id.
|
|
2684
|
+
* This will disable all children as well.
|
|
2685
|
+
* @param id
|
|
2686
|
+
*/
|
|
2387
2687
|
MenuItemManager.prototype.RemoveItemById = function (id) {
|
|
2388
2688
|
return __awaiter(this, void 0, void 0, function () {
|
|
2389
2689
|
var item, _loop_1, this_1, i;
|
|
@@ -2564,201 +2864,8 @@
|
|
|
2564
2864
|
RenderHelper.RenderTileset = RenderTileset;
|
|
2565
2865
|
})(exports.RenderHelper || (exports.RenderHelper = {}));
|
|
2566
2866
|
|
|
2567
|
-
function removeEntity(viewer, visuals) {
|
|
2568
|
-
unmarkEntity(visuals);
|
|
2569
|
-
for (var i = 0; i < visuals.length; i++) {
|
|
2570
|
-
var visual = visuals[i];
|
|
2571
|
-
if (visual instanceof Cesium.Entity) {
|
|
2572
|
-
exports.EntityRenderEngine.Remove(viewer, visual);
|
|
2573
|
-
}
|
|
2574
|
-
else if (visual instanceof Cesium.Primitive) {
|
|
2575
|
-
viewer.scene.primitives.remove(visual);
|
|
2576
|
-
}
|
|
2577
|
-
else if (visual instanceof Cesium.Cesium3DTileFeature) {
|
|
2578
|
-
visual.show = false;
|
|
2579
|
-
}
|
|
2580
|
-
}
|
|
2581
|
-
}
|
|
2582
|
-
function updateCEntityShow(viewer, visual, show) {
|
|
2583
|
-
if (visual._parentEntity) {
|
|
2584
|
-
updateCEntityShow(viewer, visual._parentEntity, show);
|
|
2585
|
-
}
|
|
2586
|
-
if (visual._siblingGraphics) {
|
|
2587
|
-
for (var i = 0; i < visual._siblingGraphics.length; i++) {
|
|
2588
|
-
var sibling = visual._siblingGraphics[i];
|
|
2589
|
-
updateCEntityShow(viewer, sibling, show);
|
|
2590
|
-
}
|
|
2591
|
-
}
|
|
2592
|
-
visual.show = show;
|
|
2593
|
-
}
|
|
2594
|
-
function updateEntityShow(viewer, visual, show) {
|
|
2595
|
-
if (visual instanceof Cesium.Entity) {
|
|
2596
|
-
updateCEntityShow(viewer, visual, show);
|
|
2597
|
-
}
|
|
2598
|
-
else if (visual instanceof Cesium.Primitive) {
|
|
2599
|
-
visual.show = show;
|
|
2600
|
-
}
|
|
2601
|
-
else if (visual instanceof Cesium.Cesium3DTileFeature) {
|
|
2602
|
-
visual.show = show;
|
|
2603
|
-
}
|
|
2604
|
-
}
|
|
2605
|
-
function updateEntity(viewer, entityRegos) {
|
|
2606
|
-
var highestPriority = null;
|
|
2607
|
-
for (var i = 0; i < entityRegos.length; i++) {
|
|
2608
|
-
var rego = entityRegos[i];
|
|
2609
|
-
if (highestPriority === null || rego.priority > highestPriority.priority) {
|
|
2610
|
-
highestPriority = rego;
|
|
2611
|
-
}
|
|
2612
|
-
}
|
|
2613
|
-
for (var i = 0; i < entityRegos.length; i++) {
|
|
2614
|
-
var rego = entityRegos[i];
|
|
2615
|
-
for (var j = 0; j < rego.visuals.length; j++) {
|
|
2616
|
-
var visual = rego.visuals[j];
|
|
2617
|
-
updateEntityShow(viewer, visual, rego === highestPriority);
|
|
2618
|
-
}
|
|
2619
|
-
}
|
|
2620
|
-
}
|
|
2621
|
-
function markEntity(register, rego, visuals) {
|
|
2622
|
-
for (var i = 0; i < visuals.length; i++) {
|
|
2623
|
-
var visual = visuals[i];
|
|
2624
|
-
var vis = visual;
|
|
2625
|
-
vis._register = register;
|
|
2626
|
-
vis._rego = rego;
|
|
2627
|
-
if (visual instanceof Cesium.Entity) {
|
|
2628
|
-
var visEnt = visual;
|
|
2629
|
-
if (visEnt._parentEntity) {
|
|
2630
|
-
markEntity(register, rego, [visEnt._parentEntity]);
|
|
2631
|
-
}
|
|
2632
|
-
if (visEnt._siblingGraphics) {
|
|
2633
|
-
markEntity(register, rego, visEnt._siblingGraphics);
|
|
2634
|
-
}
|
|
2635
|
-
}
|
|
2636
|
-
}
|
|
2637
|
-
}
|
|
2638
|
-
function unmarkEntity(visuals) {
|
|
2639
|
-
for (var i = 0; i < visuals.length; i++) {
|
|
2640
|
-
var visual = visuals[i];
|
|
2641
|
-
var vis = visual;
|
|
2642
|
-
vis._register = null;
|
|
2643
|
-
if (visual instanceof Cesium.Entity) {
|
|
2644
|
-
var visEnt = visual;
|
|
2645
|
-
if (visEnt._parentEntity) {
|
|
2646
|
-
unmarkEntity([visEnt._parentEntity]);
|
|
2647
|
-
}
|
|
2648
|
-
if (visEnt._siblingGraphics) {
|
|
2649
|
-
unmarkEntity(visEnt._siblingGraphics);
|
|
2650
|
-
}
|
|
2651
|
-
}
|
|
2652
|
-
}
|
|
2653
|
-
}
|
|
2654
|
-
var VisualsRegister = /** @class */ (function () {
|
|
2655
|
-
function VisualsRegister(viewer) {
|
|
2656
|
-
this.id = bruceModels.ObjectUtils.UId();
|
|
2657
|
-
this.rego = {};
|
|
2658
|
-
this.viewer = viewer;
|
|
2659
|
-
}
|
|
2660
|
-
Object.defineProperty(VisualsRegister.prototype, "Id", {
|
|
2661
|
-
get: function () {
|
|
2662
|
-
return this.id;
|
|
2663
|
-
},
|
|
2664
|
-
enumerable: false,
|
|
2665
|
-
configurable: true
|
|
2666
|
-
});
|
|
2667
|
-
VisualsRegister.prototype.Add = function (rego) {
|
|
2668
|
-
var _a;
|
|
2669
|
-
this.Remove(rego.entityId, rego.menuItemId, false);
|
|
2670
|
-
var entityId = rego.entityId;
|
|
2671
|
-
var entityRegos = (_a = this.rego[entityId]) !== null && _a !== void 0 ? _a : [];
|
|
2672
|
-
entityRegos.push(rego);
|
|
2673
|
-
this.rego[entityId] = entityRegos;
|
|
2674
|
-
markEntity(this, rego, rego.visuals);
|
|
2675
|
-
updateEntity(this.viewer, this.rego[entityId]);
|
|
2676
|
-
};
|
|
2677
|
-
VisualsRegister.prototype.GetVisuals = function (entityId, menuItemId) {
|
|
2678
|
-
var _a;
|
|
2679
|
-
var entityRegos = this.rego[entityId];
|
|
2680
|
-
if (!entityRegos) {
|
|
2681
|
-
return [];
|
|
2682
|
-
}
|
|
2683
|
-
var visuals = (_a = entityRegos.find(function (r) { return r.menuItemId === menuItemId; })) === null || _a === void 0 ? void 0 : _a.visuals;
|
|
2684
|
-
return visuals !== null && visuals !== void 0 ? visuals : [];
|
|
2685
|
-
};
|
|
2686
|
-
VisualsRegister.prototype.RemoveByEntityId = function (id) {
|
|
2687
|
-
var entityRegos = this.rego[id];
|
|
2688
|
-
if (!entityRegos) {
|
|
2689
|
-
return;
|
|
2690
|
-
}
|
|
2691
|
-
for (var i = 0; i < entityRegos.length; i++) {
|
|
2692
|
-
var rego = entityRegos[i];
|
|
2693
|
-
removeEntity(this.viewer, rego.visuals);
|
|
2694
|
-
}
|
|
2695
|
-
this.rego[id] = [];
|
|
2696
|
-
delete this.rego[id];
|
|
2697
|
-
};
|
|
2698
|
-
VisualsRegister.prototype.RemoveByMenuItemId = function (id) {
|
|
2699
|
-
for (var entityId in this.rego) {
|
|
2700
|
-
var entityRegos = this.rego[entityId];
|
|
2701
|
-
if (entityRegos) {
|
|
2702
|
-
var rego = entityRegos.find(function (r) { return r.menuItemId === id; });
|
|
2703
|
-
if (!rego) {
|
|
2704
|
-
continue;
|
|
2705
|
-
}
|
|
2706
|
-
removeEntity(this.viewer, rego.visuals);
|
|
2707
|
-
var doesInclude = this.rego[entityId].find(function (r) { return r.menuItemId === id; });
|
|
2708
|
-
if (doesInclude) {
|
|
2709
|
-
this.rego[entityId] = entityRegos.filter(function (r) { return r.menuItemId !== id; });
|
|
2710
|
-
updateEntity(this.viewer, this.rego[entityId]);
|
|
2711
|
-
}
|
|
2712
|
-
}
|
|
2713
|
-
}
|
|
2714
|
-
};
|
|
2715
|
-
VisualsRegister.prototype.Remove = function (entityId, menuItemId, _doUpdate) {
|
|
2716
|
-
if (_doUpdate === void 0) { _doUpdate = true; }
|
|
2717
|
-
var entityRegos = this.rego[entityId];
|
|
2718
|
-
if (!entityRegos) {
|
|
2719
|
-
return;
|
|
2720
|
-
}
|
|
2721
|
-
var rego = entityRegos.find(function (r) { return r.menuItemId === menuItemId; });
|
|
2722
|
-
if (!rego) {
|
|
2723
|
-
return;
|
|
2724
|
-
}
|
|
2725
|
-
for (var i = 0; i < rego.visuals.length; i++) {
|
|
2726
|
-
var visual = rego.visuals[i];
|
|
2727
|
-
if (visual instanceof Cesium.Entity) {
|
|
2728
|
-
this.viewer.entities.remove(visual);
|
|
2729
|
-
}
|
|
2730
|
-
else if (visual instanceof Cesium.Primitive) {
|
|
2731
|
-
this.viewer.scene.primitives.remove(visual);
|
|
2732
|
-
}
|
|
2733
|
-
else if (visual instanceof Cesium.Cesium3DTileFeature) {
|
|
2734
|
-
visual.show = false;
|
|
2735
|
-
}
|
|
2736
|
-
}
|
|
2737
|
-
this.rego[entityId] = entityRegos.filter(function (r) { return r.menuItemId !== menuItemId; });
|
|
2738
|
-
if (_doUpdate) {
|
|
2739
|
-
updateEntity(this.viewer, this.rego[entityId]);
|
|
2740
|
-
}
|
|
2741
|
-
};
|
|
2742
|
-
VisualsRegister.prototype.GetFromCursor = function (cursor) {
|
|
2743
|
-
var _a;
|
|
2744
|
-
var found = [];
|
|
2745
|
-
var picked = this.viewer.scene.drillPick(new Cesium.Cartesian2(cursor.x, cursor.y), 5);
|
|
2746
|
-
for (var i = 0; i < picked.length; i++) {
|
|
2747
|
-
var object = picked[i];
|
|
2748
|
-
var entity = (object && object.id && object.id instanceof Cesium.Entity ? object.id : object);
|
|
2749
|
-
var visual = entity;
|
|
2750
|
-
if (((_a = visual === null || visual === void 0 ? void 0 : visual._register) === null || _a === void 0 ? void 0 : _a.Id) == this.id) {
|
|
2751
|
-
found.push(visual._rego);
|
|
2752
|
-
}
|
|
2753
|
-
}
|
|
2754
|
-
return found;
|
|
2755
|
-
};
|
|
2756
|
-
return VisualsRegister;
|
|
2757
|
-
}());
|
|
2758
|
-
|
|
2759
2867
|
exports.CesiumViewMonitor = CesiumViewMonitor;
|
|
2760
2868
|
exports.MenuItemManager = MenuItemManager;
|
|
2761
|
-
exports.VisualsRegister = VisualsRegister;
|
|
2762
2869
|
|
|
2763
2870
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2764
2871
|
|