bruce-cesium 0.5.5 → 0.5.7
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 +189 -304
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +187 -303
- package/dist/bruce-cesium.umd.js.map +1 -1
- package/dist/lib/bruce-cesium.js +0 -2
- package/dist/lib/bruce-cesium.js.map +1 -1
- package/dist/lib/rendering/visuals-register.js +148 -99
- package/dist/lib/rendering/visuals-register.js.map +1 -1
- package/dist/lib/utils/entity-utils.js +39 -26
- package/dist/lib/utils/entity-utils.js.map +1 -1
- package/dist/types/bruce-cesium.d.ts +0 -2
- package/dist/types/rendering/visuals-register.d.ts +13 -6
- package/dist/types/utils/entity-utils.d.ts +1 -1
- package/package.json +1 -1
- package/dist/lib/rendering/render-addons/measure-addon.js +0 -187
- package/dist/lib/rendering/render-addons/measure-addon.js.map +0 -1
- package/dist/lib/rendering/render-addons/render-addon.js +0 -3
- package/dist/lib/rendering/render-addons/render-addon.js.map +0 -1
- package/dist/types/rendering/render-addons/measure-addon.d.ts +0 -21
- package/dist/types/rendering/render-addons/render-addon.d.ts +0 -7
package/dist/bruce-cesium.es5.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BruceEvent, Cartes, Carto, Geometry, ZoomControl, Style, EntityTag, Calculator, EntityLod, EntityType, ClientFile, DelayQueue, Entity as Entity$1, BatchedDataGetter, ObjectUtils, Tileset, EntityCoords, EntityFilterGetter, EntitySource, MenuItem, ProjectView, ProjectViewBookmark, ProjectViewTile, ProjectViewLegacyTile, TilesetExtMapTiles, ProgramKey, Camera
|
|
1
|
+
import { BruceEvent, Cartes, Carto, Geometry, ZoomControl, Style, EntityTag, Calculator, EntityLod, EntityType, ClientFile, DelayQueue, Entity as Entity$1, BatchedDataGetter, ObjectUtils, Tileset, EntityCoords, EntityFilterGetter, EntitySource, MenuItem, ProjectView, ProjectViewBookmark, ProjectViewTile, ProjectViewLegacyTile, TilesetExtMapTiles, ProgramKey, Camera } from 'bruce-models';
|
|
2
2
|
import { Cartesian2, Cartographic, Math as Math$1, Color, HeightReference, Cartesian3, Entity, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, PolygonHierarchy, ShadowMode, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, Primitive, Cesium3DTileFeature, HeadingPitchRange, OrthographicFrustum, createWorldTerrain, EllipsoidTerrainProvider, CesiumTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, Matrix4, Cesium3DTileset, EllipsoidGeodesic, ColorMaterialProperty, Rectangle, Matrix3, EasingFunction, GeometryInstance, JulianDate, createOsmBuildings, Cesium3DTileStyle } from 'cesium';
|
|
3
3
|
|
|
4
4
|
var TIME_LAG = 300;
|
|
@@ -438,16 +438,25 @@ function traverseEntity(cEntity, arr) {
|
|
|
438
438
|
var ORG_OPACITY_KEY = "_org_opacity_";
|
|
439
439
|
var NEW_OPACITY_KEY = "_new_opacity_";
|
|
440
440
|
function getColor(viewer, material) {
|
|
441
|
-
var _a;
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
441
|
+
var _a, _b;
|
|
442
|
+
function findColor() {
|
|
443
|
+
var _a;
|
|
444
|
+
if (!material) {
|
|
445
|
+
return Color.WHITE;
|
|
446
|
+
}
|
|
447
|
+
if (material.getValue) {
|
|
448
|
+
material = material.getValue(viewer.scene.lastRenderTime);
|
|
449
|
+
}
|
|
450
|
+
if (material instanceof Color) {
|
|
451
|
+
return material;
|
|
452
|
+
}
|
|
453
|
+
var tmp = (_a = material) === null || _a === void 0 ? void 0 : _a.color;
|
|
454
|
+
if (tmp === null || tmp === void 0 ? void 0 : tmp.getValue) {
|
|
455
|
+
tmp = tmp.getValue(viewer.scene.lastRenderTime);
|
|
456
|
+
}
|
|
457
|
+
return tmp ? tmp : Color.WHITE;
|
|
449
458
|
}
|
|
450
|
-
return
|
|
459
|
+
return (_b = (_a = findColor()) === null || _a === void 0 ? void 0 : _a.clone) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
451
460
|
}
|
|
452
461
|
function applyOpacityToColor(viewer, opacity, material) {
|
|
453
462
|
var color = getColor(viewer, material);
|
|
@@ -456,29 +465,30 @@ function applyOpacityToColor(viewer, opacity, material) {
|
|
|
456
465
|
}
|
|
457
466
|
return color;
|
|
458
467
|
}
|
|
459
|
-
function applyOpacityToGraphic(viewer, entity, graphicKey, opacity) {
|
|
460
|
-
var color = applyOpacityToColor(viewer, opacity, entity[graphicKey]
|
|
468
|
+
function applyOpacityToGraphic(viewer, entity, graphicKey, materialKey, opacity) {
|
|
469
|
+
var color = applyOpacityToColor(viewer, opacity, entity[graphicKey][materialKey]);
|
|
461
470
|
if (color) {
|
|
462
|
-
entity[graphicKey]
|
|
471
|
+
entity[graphicKey][materialKey] = materialKey == "material" ? new ColorMaterialProperty(color) : color;
|
|
463
472
|
}
|
|
464
473
|
}
|
|
465
474
|
function revertAppliedEntityOpacity(viewer, entity) {
|
|
466
475
|
entity[NEW_OPACITY_KEY] = null;
|
|
467
476
|
if (entity instanceof Entity) {
|
|
468
|
-
var processKey = function (graphicKey) {
|
|
477
|
+
var processKey = function (graphicKey, materialKey) {
|
|
478
|
+
if (materialKey === void 0) { materialKey = "material"; }
|
|
469
479
|
if (entity[graphicKey]) {
|
|
470
480
|
var orgOpacity = entity[graphicKey][ORG_OPACITY_KEY];
|
|
471
481
|
if (orgOpacity != null) {
|
|
472
|
-
applyOpacityToGraphic(viewer, entity, graphicKey, orgOpacity);
|
|
482
|
+
applyOpacityToGraphic(viewer, entity, graphicKey, materialKey, orgOpacity);
|
|
473
483
|
}
|
|
474
484
|
entity[graphicKey][ORG_OPACITY_KEY] = null;
|
|
475
485
|
}
|
|
476
486
|
};
|
|
477
487
|
processKey("polygon");
|
|
478
488
|
processKey("polyline");
|
|
479
|
-
processKey("point");
|
|
489
|
+
processKey("point", "color");
|
|
480
490
|
processKey("ellipse");
|
|
481
|
-
processKey("model");
|
|
491
|
+
processKey("model", "color");
|
|
482
492
|
}
|
|
483
493
|
else if (entity instanceof Cesium3DTileFeature) {
|
|
484
494
|
var orgOpacity = entity[ORG_OPACITY_KEY];
|
|
@@ -493,24 +503,25 @@ function revertAppliedEntityOpacity(viewer, entity) {
|
|
|
493
503
|
function applyOpacityToEntity(viewer, opacity, entity) {
|
|
494
504
|
entity[NEW_OPACITY_KEY] = opacity;
|
|
495
505
|
if (entity instanceof Entity) {
|
|
496
|
-
var processKey = function (graphicKey) {
|
|
506
|
+
var processKey = function (graphicKey, materialKey) {
|
|
497
507
|
var _a;
|
|
508
|
+
if (materialKey === void 0) { materialKey = "material"; }
|
|
498
509
|
if (entity[graphicKey]) {
|
|
499
510
|
var orgOpacity = entity[graphicKey][ORG_OPACITY_KEY];
|
|
500
511
|
if (orgOpacity == null) {
|
|
501
|
-
entity[graphicKey][ORG_OPACITY_KEY] = (_a = getColor(viewer, entity[graphicKey]
|
|
512
|
+
entity[graphicKey][ORG_OPACITY_KEY] = (_a = getColor(viewer, entity[graphicKey][materialKey])) === null || _a === void 0 ? void 0 : _a.alpha;
|
|
502
513
|
}
|
|
503
514
|
if (orgOpacity == null) {
|
|
504
515
|
orgOpacity = 1;
|
|
505
516
|
}
|
|
506
|
-
applyOpacityToGraphic(viewer, entity, graphicKey, opacity * orgOpacity);
|
|
517
|
+
applyOpacityToGraphic(viewer, entity, graphicKey, materialKey, opacity * orgOpacity);
|
|
507
518
|
}
|
|
508
519
|
};
|
|
509
520
|
processKey("polygon");
|
|
510
521
|
processKey("polyline");
|
|
511
|
-
processKey("point");
|
|
522
|
+
processKey("point", "color");
|
|
512
523
|
processKey("ellipse");
|
|
513
|
-
processKey("model");
|
|
524
|
+
processKey("model", "color");
|
|
514
525
|
}
|
|
515
526
|
else if (entity instanceof Cesium3DTileFeature) {
|
|
516
527
|
var orgOpacity = entity[ORG_OPACITY_KEY];
|
|
@@ -521,13 +532,15 @@ function applyOpacityToEntity(viewer, opacity, entity) {
|
|
|
521
532
|
orgOpacity = 1;
|
|
522
533
|
}
|
|
523
534
|
var color = entity.color ? entity.color.clone() : new Color();
|
|
524
|
-
|
|
535
|
+
color.alpha = opacity * orgOpacity;
|
|
536
|
+
if (color.equals(Color.WHITE)) {
|
|
537
|
+
color.blue = 0.0001;
|
|
538
|
+
}
|
|
525
539
|
entity.color = color;
|
|
526
540
|
}
|
|
527
541
|
}
|
|
528
542
|
function findOpacity(entity) {
|
|
529
|
-
|
|
530
|
-
return (_a = entity[NEW_OPACITY_KEY]) !== null && _a !== void 0 ? _a : 1;
|
|
543
|
+
return entity[NEW_OPACITY_KEY];
|
|
531
544
|
}
|
|
532
545
|
var EntityUtils;
|
|
533
546
|
(function (EntityUtils) {
|
|
@@ -727,10 +740,10 @@ var EntityUtils;
|
|
|
727
740
|
* @param viewer
|
|
728
741
|
* @param entity
|
|
729
742
|
*/
|
|
730
|
-
function
|
|
743
|
+
function GetOpacity(entity) {
|
|
731
744
|
return findOpacity(entity);
|
|
732
745
|
}
|
|
733
|
-
EntityUtils.
|
|
746
|
+
EntityUtils.GetOpacity = GetOpacity;
|
|
734
747
|
})(EntityUtils || (EntityUtils = {}));
|
|
735
748
|
|
|
736
749
|
var RenderManager;
|
|
@@ -1926,25 +1939,31 @@ function updateEntityShow(viewer, visual, show) {
|
|
|
1926
1939
|
}
|
|
1927
1940
|
}
|
|
1928
1941
|
}
|
|
1929
|
-
function updateEntity(viewer,
|
|
1942
|
+
function updateEntity(viewer, entityId, register) {
|
|
1943
|
+
var isolatedIds = register.GetIsolated();
|
|
1944
|
+
var isIsolated = isolatedIds.includes(entityId);
|
|
1945
|
+
var isHidden = register.IsHidden(entityId);
|
|
1946
|
+
var regos = register.GetRegos(entityId);
|
|
1930
1947
|
var highestPriority = null;
|
|
1931
|
-
for (var i = 0; i <
|
|
1932
|
-
var rego =
|
|
1948
|
+
for (var i = 0; i < regos.length; i++) {
|
|
1949
|
+
var rego = regos[i];
|
|
1933
1950
|
if (highestPriority === null || rego.priority > highestPriority.priority) {
|
|
1934
1951
|
highestPriority = rego;
|
|
1935
1952
|
}
|
|
1936
1953
|
}
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
if (addons) {
|
|
1944
|
-
for (var j = 0; j < addons.length; j++) {
|
|
1945
|
-
var addon = addons[j];
|
|
1946
|
-
addon.Render(entityRegos.map(function (x) { return x.visual; }));
|
|
1954
|
+
function getShowState(rego) {
|
|
1955
|
+
if (isHidden) {
|
|
1956
|
+
return false;
|
|
1957
|
+
}
|
|
1958
|
+
if (!isIsolated && isolatedIds.length > 0) {
|
|
1959
|
+
return false;
|
|
1947
1960
|
}
|
|
1961
|
+
return rego === highestPriority;
|
|
1962
|
+
}
|
|
1963
|
+
for (var i = 0; i < regos.length; i++) {
|
|
1964
|
+
var rego = regos[i];
|
|
1965
|
+
rego.best = rego === highestPriority;
|
|
1966
|
+
updateEntityShow(viewer, rego.visual, getShowState(rego));
|
|
1948
1967
|
}
|
|
1949
1968
|
}
|
|
1950
1969
|
function markEntity(register, rego, visual) {
|
|
@@ -1978,67 +1997,89 @@ function unmarkEntity(visual) {
|
|
|
1978
1997
|
}
|
|
1979
1998
|
}
|
|
1980
1999
|
}
|
|
1981
|
-
|
|
2000
|
+
var ORG_COLOR_KEY = "_org_color_";
|
|
2001
|
+
function select(viewer, visual) {
|
|
2002
|
+
var _a;
|
|
1982
2003
|
var color = Color.fromAlpha(Color.YELLOW, 0.5);
|
|
1983
2004
|
if (visual instanceof Entity) {
|
|
1984
2005
|
var entities = EntityUtils.GatherEntity(visual);
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
cEntity.billboard.color = color.clone();
|
|
2006
|
+
var keyMapping = {
|
|
2007
|
+
"point": "color",
|
|
2008
|
+
"polygon": "material",
|
|
2009
|
+
"polyline": "material",
|
|
2010
|
+
"model": "color",
|
|
2011
|
+
"billboard": "color"
|
|
2012
|
+
};
|
|
2013
|
+
var _loop_1 = function (i) {
|
|
2014
|
+
var entity = entities[i];
|
|
2015
|
+
var processGraphic = function (graphicKey, materialKey) {
|
|
2016
|
+
if (entity[graphicKey]) {
|
|
2017
|
+
if (entity[graphicKey][ORG_COLOR_KEY] == null) {
|
|
2018
|
+
entity[graphicKey][ORG_COLOR_KEY] = entity[graphicKey][materialKey];
|
|
2019
|
+
}
|
|
2020
|
+
entity[graphicKey][materialKey] = color.clone();
|
|
2021
|
+
}
|
|
2022
|
+
};
|
|
2023
|
+
for (var key in keyMapping) {
|
|
2024
|
+
var map = keyMapping[key];
|
|
2025
|
+
processGraphic(key, map);
|
|
2006
2026
|
}
|
|
2027
|
+
};
|
|
2028
|
+
for (var i = 0; i < entities.length; i++) {
|
|
2029
|
+
_loop_1(i);
|
|
2007
2030
|
}
|
|
2008
2031
|
}
|
|
2009
2032
|
else if (visual instanceof Primitive) ;
|
|
2010
2033
|
else if (visual instanceof Cesium3DTileFeature) {
|
|
2011
|
-
var
|
|
2012
|
-
|
|
2013
|
-
|
|
2034
|
+
var orgColor = visual[ORG_COLOR_KEY];
|
|
2035
|
+
if (orgColor == null) {
|
|
2036
|
+
orgColor = visual.color;
|
|
2037
|
+
visual[ORG_COLOR_KEY] = (_a = orgColor === null || orgColor === void 0 ? void 0 : orgColor.clone) === null || _a === void 0 ? void 0 : _a.call(orgColor);
|
|
2038
|
+
}
|
|
2039
|
+
visual.color = color.clone();
|
|
2040
|
+
}
|
|
2041
|
+
var opacity = EntityUtils.GetOpacity(visual);
|
|
2042
|
+
if (opacity != null) {
|
|
2043
|
+
EntityUtils.SetOpacity(viewer, visual, opacity);
|
|
2014
2044
|
}
|
|
2015
2045
|
}
|
|
2016
|
-
function deselect(visual) {
|
|
2046
|
+
function deselect(viewer, visual) {
|
|
2017
2047
|
if (visual instanceof Entity) {
|
|
2018
2048
|
var entities = EntityUtils.GatherEntity(visual);
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2049
|
+
var keyMapping = {
|
|
2050
|
+
"point": "color",
|
|
2051
|
+
"polygon": "material",
|
|
2052
|
+
"polyline": "material",
|
|
2053
|
+
"model": "color",
|
|
2054
|
+
"billboard": "color"
|
|
2055
|
+
};
|
|
2056
|
+
var _loop_2 = function (i) {
|
|
2057
|
+
var entity = entities[i];
|
|
2058
|
+
var processGraphic = function (graphicKey, materialKey) {
|
|
2059
|
+
var _a;
|
|
2060
|
+
if ((_a = entity[graphicKey]) === null || _a === void 0 ? void 0 : _a[ORG_COLOR_KEY]) {
|
|
2061
|
+
entity[graphicKey][materialKey] = entity[graphicKey][ORG_COLOR_KEY];
|
|
2062
|
+
}
|
|
2063
|
+
};
|
|
2064
|
+
for (var key in keyMapping) {
|
|
2065
|
+
var map = keyMapping[key];
|
|
2066
|
+
processGraphic(key, map);
|
|
2035
2067
|
}
|
|
2068
|
+
};
|
|
2069
|
+
for (var i = 0; i < entities.length; i++) {
|
|
2070
|
+
_loop_2(i);
|
|
2036
2071
|
}
|
|
2037
2072
|
}
|
|
2038
2073
|
else if (visual instanceof Primitive) ;
|
|
2039
2074
|
else if (visual instanceof Cesium3DTileFeature) {
|
|
2040
|
-
var
|
|
2041
|
-
|
|
2075
|
+
var orgColor = visual[ORG_COLOR_KEY];
|
|
2076
|
+
if (orgColor != null) {
|
|
2077
|
+
visual.color = orgColor;
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
var opacity = EntityUtils.GetOpacity(visual);
|
|
2081
|
+
if (opacity != null) {
|
|
2082
|
+
EntityUtils.SetOpacity(viewer, visual, opacity);
|
|
2042
2083
|
}
|
|
2043
2084
|
}
|
|
2044
2085
|
/**
|
|
@@ -2053,7 +2094,8 @@ var VisualsRegister;
|
|
|
2053
2094
|
this.rego = {};
|
|
2054
2095
|
this.onUpdate = null;
|
|
2055
2096
|
this.selectedIds = [];
|
|
2056
|
-
this.
|
|
2097
|
+
this.isolatedIds = [];
|
|
2098
|
+
this.hiddenIds = [];
|
|
2057
2099
|
this.viewer = viewer;
|
|
2058
2100
|
}
|
|
2059
2101
|
Object.defineProperty(Register.prototype, "Id", {
|
|
@@ -2073,40 +2115,6 @@ var VisualsRegister;
|
|
|
2073
2115
|
enumerable: false,
|
|
2074
2116
|
configurable: true
|
|
2075
2117
|
});
|
|
2076
|
-
Register.prototype.AddAddon = function (entityId, addon) {
|
|
2077
|
-
if (!this.addons[entityId]) {
|
|
2078
|
-
this.addons[entityId] = [];
|
|
2079
|
-
}
|
|
2080
|
-
this.addons[entityId].push(addon);
|
|
2081
|
-
var regos = this.rego[entityId];
|
|
2082
|
-
if (regos) {
|
|
2083
|
-
addon.Render(regos.map(function (x) { return x.visual; }));
|
|
2084
|
-
}
|
|
2085
|
-
};
|
|
2086
|
-
Register.prototype.GetAddons = function (entityId) {
|
|
2087
|
-
return this.addons[entityId] || [];
|
|
2088
|
-
};
|
|
2089
|
-
Register.prototype.RemoveAddon = function (entityId, addonId) {
|
|
2090
|
-
var addons = this.addons[entityId];
|
|
2091
|
-
if (addons) {
|
|
2092
|
-
for (var i = 0; i < addons.length; i++) {
|
|
2093
|
-
if (addons[i].Id === addonId) {
|
|
2094
|
-
addons[i].Dispose();
|
|
2095
|
-
addons.splice(i, 1);
|
|
2096
|
-
break;
|
|
2097
|
-
}
|
|
2098
|
-
}
|
|
2099
|
-
}
|
|
2100
|
-
};
|
|
2101
|
-
Register.prototype.RemoveAddons = function (entityId) {
|
|
2102
|
-
var addons = this.addons[entityId];
|
|
2103
|
-
if (addons) {
|
|
2104
|
-
for (var i = 0; i < addons.length; i++) {
|
|
2105
|
-
addons[i].Dispose();
|
|
2106
|
-
}
|
|
2107
|
-
}
|
|
2108
|
-
this.addons[entityId] = [];
|
|
2109
|
-
};
|
|
2110
2118
|
Register.prototype.Select = function (id, refreshIfSelected) {
|
|
2111
2119
|
if (refreshIfSelected === void 0) { refreshIfSelected = false; }
|
|
2112
2120
|
var doSelect = refreshIfSelected;
|
|
@@ -2119,7 +2127,7 @@ var VisualsRegister;
|
|
|
2119
2127
|
if (regos) {
|
|
2120
2128
|
for (var i = 0; i < regos.length; i++) {
|
|
2121
2129
|
var rego = regos[i];
|
|
2122
|
-
select(rego.visual);
|
|
2130
|
+
select(this.viewer, rego.visual);
|
|
2123
2131
|
}
|
|
2124
2132
|
}
|
|
2125
2133
|
}
|
|
@@ -2132,7 +2140,7 @@ var VisualsRegister;
|
|
|
2132
2140
|
if (regos) {
|
|
2133
2141
|
for (var i = 0; i < regos.length; i++) {
|
|
2134
2142
|
var rego = regos[i];
|
|
2135
|
-
deselect(rego.visual);
|
|
2143
|
+
deselect(this.viewer, rego.visual);
|
|
2136
2144
|
}
|
|
2137
2145
|
}
|
|
2138
2146
|
}
|
|
@@ -2147,12 +2155,58 @@ var VisualsRegister;
|
|
|
2147
2155
|
if (regos) {
|
|
2148
2156
|
for (var i_1 = 0; i_1 < regos.length; i_1++) {
|
|
2149
2157
|
var rego = regos[i_1];
|
|
2150
|
-
deselect(rego.visual);
|
|
2158
|
+
deselect(this.viewer, rego.visual);
|
|
2151
2159
|
}
|
|
2152
2160
|
}
|
|
2153
2161
|
}
|
|
2154
2162
|
this.selectedIds = [];
|
|
2155
2163
|
};
|
|
2164
|
+
Register.prototype.Isolate = function (id) {
|
|
2165
|
+
if (this.isolatedIds.indexOf(id) === -1) {
|
|
2166
|
+
this.isolatedIds.push(id);
|
|
2167
|
+
}
|
|
2168
|
+
this.updateAllEntities();
|
|
2169
|
+
};
|
|
2170
|
+
Register.prototype.Deisolate = function (id) {
|
|
2171
|
+
var index = this.isolatedIds.indexOf(id);
|
|
2172
|
+
if (index !== -1) {
|
|
2173
|
+
this.isolatedIds.splice(index, 1);
|
|
2174
|
+
}
|
|
2175
|
+
this.updateAllEntities();
|
|
2176
|
+
};
|
|
2177
|
+
Register.prototype.IsIsolated = function (id) {
|
|
2178
|
+
return this.isolatedIds.indexOf(id) !== -1;
|
|
2179
|
+
};
|
|
2180
|
+
Register.prototype.GetIsolated = function () {
|
|
2181
|
+
return this.isolatedIds;
|
|
2182
|
+
};
|
|
2183
|
+
Register.prototype.ClearIsolated = function () {
|
|
2184
|
+
this.isolatedIds = [];
|
|
2185
|
+
this.updateAllEntities();
|
|
2186
|
+
};
|
|
2187
|
+
Register.prototype.Hide = function (id) {
|
|
2188
|
+
if (this.hiddenIds.indexOf(id) === -1) {
|
|
2189
|
+
this.hiddenIds.push(id);
|
|
2190
|
+
}
|
|
2191
|
+
updateEntity(this.viewer, id, this);
|
|
2192
|
+
};
|
|
2193
|
+
Register.prototype.Show = function (id) {
|
|
2194
|
+
var index = this.hiddenIds.indexOf(id);
|
|
2195
|
+
if (index !== -1) {
|
|
2196
|
+
this.hiddenIds.splice(index, 1);
|
|
2197
|
+
}
|
|
2198
|
+
updateEntity(this.viewer, id, this);
|
|
2199
|
+
};
|
|
2200
|
+
Register.prototype.IsHidden = function (id) {
|
|
2201
|
+
return this.hiddenIds.indexOf(id) !== -1;
|
|
2202
|
+
};
|
|
2203
|
+
Register.prototype.GetHidden = function () {
|
|
2204
|
+
return this.hiddenIds;
|
|
2205
|
+
};
|
|
2206
|
+
Register.prototype.ClearHidden = function () {
|
|
2207
|
+
this.hiddenIds = [];
|
|
2208
|
+
this.updateAllEntities();
|
|
2209
|
+
};
|
|
2156
2210
|
Register.prototype.Add = function (rego) {
|
|
2157
2211
|
var _a, _b;
|
|
2158
2212
|
this.Remove(rego.entityId, rego.menuItemId, false);
|
|
@@ -2161,9 +2215,9 @@ var VisualsRegister;
|
|
|
2161
2215
|
entityRegos.push(rego);
|
|
2162
2216
|
this.rego[entityId] = entityRegos;
|
|
2163
2217
|
markEntity(this, rego, rego.visual);
|
|
2164
|
-
updateEntity(this.viewer,
|
|
2218
|
+
updateEntity(this.viewer, entityId, this);
|
|
2165
2219
|
if (this.selectedIds.includes(entityId)) {
|
|
2166
|
-
select(rego.visual);
|
|
2220
|
+
select(this.viewer, rego.visual);
|
|
2167
2221
|
}
|
|
2168
2222
|
(_b = this.onUpdate) === null || _b === void 0 ? void 0 : _b.Trigger({ rego: rego, isAdding: true });
|
|
2169
2223
|
};
|
|
@@ -2232,7 +2286,7 @@ var VisualsRegister;
|
|
|
2232
2286
|
var doesInclude = this.rego[entityId].find(function (r) { return r.menuItemId === id; });
|
|
2233
2287
|
if (doesInclude) {
|
|
2234
2288
|
this.rego[entityId] = entityRegos.filter(function (r) { return r.menuItemId !== id; });
|
|
2235
|
-
updateEntity(this.viewer,
|
|
2289
|
+
updateEntity(this.viewer, entityId, this);
|
|
2236
2290
|
}
|
|
2237
2291
|
}
|
|
2238
2292
|
}
|
|
@@ -2252,7 +2306,7 @@ var VisualsRegister;
|
|
|
2252
2306
|
removeEntity(this.viewer, rego.visual);
|
|
2253
2307
|
this.rego[entityId] = entityRegos.filter(function (r) { return r.menuItemId !== menuItemId; });
|
|
2254
2308
|
if (_doUpdate) {
|
|
2255
|
-
updateEntity(this.viewer,
|
|
2309
|
+
updateEntity(this.viewer, entityId, this);
|
|
2256
2310
|
}
|
|
2257
2311
|
};
|
|
2258
2312
|
/**
|
|
@@ -2275,6 +2329,14 @@ var VisualsRegister;
|
|
|
2275
2329
|
}
|
|
2276
2330
|
return found;
|
|
2277
2331
|
};
|
|
2332
|
+
Register.prototype.updateAllEntities = function () {
|
|
2333
|
+
for (var entityId in this.rego) {
|
|
2334
|
+
var regos = this.rego[entityId];
|
|
2335
|
+
if (regos && regos.length) {
|
|
2336
|
+
updateEntity(this.viewer, entityId, this);
|
|
2337
|
+
}
|
|
2338
|
+
}
|
|
2339
|
+
};
|
|
2278
2340
|
return Register;
|
|
2279
2341
|
}());
|
|
2280
2342
|
VisualsRegister.Register = Register;
|
|
@@ -5149,183 +5211,6 @@ var ViewRenderEngine;
|
|
|
5149
5211
|
ViewRenderEngine.Render = Render;
|
|
5150
5212
|
})(ViewRenderEngine || (ViewRenderEngine = {}));
|
|
5151
5213
|
|
|
5152
|
-
function createContainer(viewer) {
|
|
5153
|
-
if (!viewer.canvas.parentElement) {
|
|
5154
|
-
return null;
|
|
5155
|
-
}
|
|
5156
|
-
var container = document.createElement("div");
|
|
5157
|
-
container.setAttribute("style", "\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n pointer-events: none;\n z-index: 1;\n ");
|
|
5158
|
-
viewer.canvas.parentElement.appendChild(container);
|
|
5159
|
-
return container;
|
|
5160
|
-
}
|
|
5161
|
-
function destroyContainer(container) {
|
|
5162
|
-
if ((container === null || container === void 0 ? void 0 : container.parentElement) && container.parentElement.contains(container)) {
|
|
5163
|
-
container.parentElement.removeChild(container);
|
|
5164
|
-
}
|
|
5165
|
-
}
|
|
5166
|
-
var MPolyline;
|
|
5167
|
-
(function (MPolyline) {
|
|
5168
|
-
function Render(container, viewer, entity) {
|
|
5169
|
-
var _a;
|
|
5170
|
-
var items = [];
|
|
5171
|
-
if ((_a = entity.polyline) === null || _a === void 0 ? void 0 : _a.positions) {
|
|
5172
|
-
var pointsUnk = entity.polyline.positions;
|
|
5173
|
-
if (pointsUnk.getValue) {
|
|
5174
|
-
pointsUnk = pointsUnk.getValue(viewer.scene.lastRenderTime);
|
|
5175
|
-
}
|
|
5176
|
-
var points = pointsUnk;
|
|
5177
|
-
if (points && points.length) {
|
|
5178
|
-
var totalLength = 0;
|
|
5179
|
-
for (var i = 0; i < points.length; i++) {
|
|
5180
|
-
var p1 = points[i];
|
|
5181
|
-
var p2 = points[i + 1];
|
|
5182
|
-
if (p1 && p2) {
|
|
5183
|
-
totalLength += Cartesian3.distance(p1, p2);
|
|
5184
|
-
}
|
|
5185
|
-
}
|
|
5186
|
-
if (totalLength <= 0) {
|
|
5187
|
-
return items;
|
|
5188
|
-
}
|
|
5189
|
-
var center = DrawingUtils.PointAcrossPolyline(viewer, points, totalLength / 2);
|
|
5190
|
-
var screenPos = viewer.scene.cartesianToCanvasCoordinates(center);
|
|
5191
|
-
if (screenPos) {
|
|
5192
|
-
var element = document.createElement("div");
|
|
5193
|
-
element.setAttribute("style", "\n position: absolute;\n top: " + screenPos.y + "px;\n left: " + screenPos.x + "px;\n color: white;\n font-size: 14px;\n z-index: 1;\n padding: 4px 6px;\n border-radius: 3px;\n background-color: black;\n color: white;\n ");
|
|
5194
|
-
var text = MathUtils.Round(totalLength, 3) + "m";
|
|
5195
|
-
element.innerText = text;
|
|
5196
|
-
var bounds = element.getBoundingClientRect();
|
|
5197
|
-
element.style.marginLeft = (-bounds.width / 2) + "px";
|
|
5198
|
-
element.style.marginTop = (-bounds.height - 10) + "px";
|
|
5199
|
-
container.appendChild(element);
|
|
5200
|
-
items.push({ element: element, text: text });
|
|
5201
|
-
}
|
|
5202
|
-
}
|
|
5203
|
-
}
|
|
5204
|
-
return items;
|
|
5205
|
-
}
|
|
5206
|
-
MPolyline.Render = Render;
|
|
5207
|
-
})(MPolyline || (MPolyline = {}));
|
|
5208
|
-
var MPoint;
|
|
5209
|
-
(function (MPoint) {
|
|
5210
|
-
function Render(container, viewer, entity) {
|
|
5211
|
-
var items = [];
|
|
5212
|
-
if (entity === null || entity === void 0 ? void 0 : entity.position) {
|
|
5213
|
-
var posUnk = entity.position;
|
|
5214
|
-
if (posUnk.getValue) {
|
|
5215
|
-
posUnk = posUnk.getValue(viewer.scene.lastRenderTime);
|
|
5216
|
-
}
|
|
5217
|
-
var pos = posUnk;
|
|
5218
|
-
if (!(pos === null || pos === void 0 ? void 0 : pos.x)) {
|
|
5219
|
-
return items;
|
|
5220
|
-
}
|
|
5221
|
-
var screenPos = viewer.scene.cartesianToCanvasCoordinates(pos);
|
|
5222
|
-
if (screenPos) {
|
|
5223
|
-
var element = document.createElement("div");
|
|
5224
|
-
element.setAttribute("style", "\n position: absolute;\n top: " + screenPos.y + "px;\n left: " + screenPos.x + "px;\n color: white;\n font-size: 14px;\n z-index: 1;\n padding: 4px 6px;\n border-radius: 3px;\n background-color: black;\n color: white;\n ");
|
|
5225
|
-
var point = Cartographic.fromCartesian(pos);
|
|
5226
|
-
var lat = MathUtils.Round(Math$1.toDegrees(point.latitude), 4);
|
|
5227
|
-
var lon = MathUtils.Round(Math$1.toDegrees(point.longitude), 4);
|
|
5228
|
-
var alt = MathUtils.Round(Math$1.toDegrees(point.height), 3);
|
|
5229
|
-
var text = lat + ", " + lon + ", " + alt;
|
|
5230
|
-
element.innerText = text;
|
|
5231
|
-
var bounds = element.getBoundingClientRect();
|
|
5232
|
-
// TODO: Account for billboard image size.
|
|
5233
|
-
element.style.marginLeft = (-bounds.width / 2) + "px";
|
|
5234
|
-
element.style.marginTop = (-bounds.height - 30) + "px";
|
|
5235
|
-
container.appendChild(element);
|
|
5236
|
-
items.push({ element: element, text: text });
|
|
5237
|
-
}
|
|
5238
|
-
}
|
|
5239
|
-
return items;
|
|
5240
|
-
}
|
|
5241
|
-
MPoint.Render = Render;
|
|
5242
|
-
})(MPoint || (MPoint = {}));
|
|
5243
|
-
function findVisual(visuals) {
|
|
5244
|
-
visuals.sort(function (a, b) {
|
|
5245
|
-
if (a.show && !b.show) {
|
|
5246
|
-
return -1;
|
|
5247
|
-
}
|
|
5248
|
-
if (!a.show && b.show) {
|
|
5249
|
-
return 1;
|
|
5250
|
-
}
|
|
5251
|
-
return 0;
|
|
5252
|
-
});
|
|
5253
|
-
for (var i = 0; i < visuals.length; i++) {
|
|
5254
|
-
var visual = visuals[i];
|
|
5255
|
-
if (visual instanceof Entity) {
|
|
5256
|
-
return visual;
|
|
5257
|
-
}
|
|
5258
|
-
}
|
|
5259
|
-
return null;
|
|
5260
|
-
}
|
|
5261
|
-
/**
|
|
5262
|
-
* Measure addon will render measurement details on the position of the 3d object.
|
|
5263
|
-
* For example it will add lengths to the line segments of a polyline.
|
|
5264
|
-
*/
|
|
5265
|
-
var MeasureAddon = /** @class */ (function () {
|
|
5266
|
-
function MeasureAddon(viewer) {
|
|
5267
|
-
var _this = this;
|
|
5268
|
-
this.Id = ObjectUtils.UId();
|
|
5269
|
-
this.visual = null;
|
|
5270
|
-
this.items = [];
|
|
5271
|
-
this.container = null;
|
|
5272
|
-
this.viewer = viewer;
|
|
5273
|
-
this.cRenderListener = this.viewer.scene.postRender.addEventListener(function () {
|
|
5274
|
-
_this.updateQueue.Call();
|
|
5275
|
-
});
|
|
5276
|
-
this.updateQueue = new DelayQueue(function () {
|
|
5277
|
-
_this.doUpdate();
|
|
5278
|
-
}, 1000 / 60);
|
|
5279
|
-
}
|
|
5280
|
-
MeasureAddon.prototype.doUpdate = function () {
|
|
5281
|
-
if (!this.container) {
|
|
5282
|
-
this.container = createContainer(this.viewer);
|
|
5283
|
-
}
|
|
5284
|
-
this.Remove();
|
|
5285
|
-
if (!this.container) {
|
|
5286
|
-
return;
|
|
5287
|
-
}
|
|
5288
|
-
var visual = this.visual;
|
|
5289
|
-
if (visual instanceof Entity) {
|
|
5290
|
-
var entity = visual;
|
|
5291
|
-
if (entity.polyline) {
|
|
5292
|
-
this.items = MPolyline.Render(this.container, this.viewer, entity);
|
|
5293
|
-
}
|
|
5294
|
-
else if (entity.point || entity.billboard) {
|
|
5295
|
-
this.items = MPoint.Render(this.container, this.viewer, entity);
|
|
5296
|
-
}
|
|
5297
|
-
// TODO:
|
|
5298
|
-
// - Polygon measurement.
|
|
5299
|
-
// - Polygon that is an angle measurement?
|
|
5300
|
-
// We'll need params for the addon that dictate what measurements we want to see.
|
|
5301
|
-
// Eg: I care about "length", "area" but not "angle" measurements in polygons.
|
|
5302
|
-
}
|
|
5303
|
-
};
|
|
5304
|
-
MeasureAddon.prototype.Render = function (visuals) {
|
|
5305
|
-
var newVisual = findVisual(visuals);
|
|
5306
|
-
if (newVisual != this.visual) {
|
|
5307
|
-
this.Remove();
|
|
5308
|
-
}
|
|
5309
|
-
this.visual = newVisual;
|
|
5310
|
-
this.updateQueue.Call(true);
|
|
5311
|
-
};
|
|
5312
|
-
MeasureAddon.prototype.Remove = function () {
|
|
5313
|
-
var _a;
|
|
5314
|
-
for (var i = 0; i < this.items.length; i++) {
|
|
5315
|
-
var item = this.items[i];
|
|
5316
|
-
if (((_a = item.element) === null || _a === void 0 ? void 0 : _a.parentElement) && item.element.parentElement.contains(item.element)) {
|
|
5317
|
-
item.element.parentElement.removeChild(item.element);
|
|
5318
|
-
}
|
|
5319
|
-
}
|
|
5320
|
-
this.items = [];
|
|
5321
|
-
};
|
|
5322
|
-
MeasureAddon.prototype.Dispose = function () {
|
|
5323
|
-
this.cRenderListener();
|
|
5324
|
-
destroyContainer(this.container);
|
|
5325
|
-
};
|
|
5326
|
-
return MeasureAddon;
|
|
5327
|
-
}());
|
|
5328
|
-
|
|
5329
5214
|
var ViewUtils;
|
|
5330
5215
|
(function (ViewUtils) {
|
|
5331
5216
|
function GatherLegacyMapTiles(viewer) {
|
|
@@ -5396,5 +5281,5 @@ var ViewUtils;
|
|
|
5396
5281
|
ViewUtils.GatherTerrainTile = GatherTerrainTile;
|
|
5397
5282
|
})(ViewUtils || (ViewUtils = {}));
|
|
5398
5283
|
|
|
5399
|
-
export { CesiumViewMonitor, ViewerUtils, MenuItemManager, EntityRenderEngine, RenderHelper, VisualsRegister, RenderManager, EntitiesIdsRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, TilesetCadRenderManager, ViewRenderEngine, TileRenderEngine, TilesetRenderEngine,
|
|
5284
|
+
export { CesiumViewMonitor, ViewerUtils, MenuItemManager, EntityRenderEngine, RenderHelper, VisualsRegister, RenderManager, EntitiesIdsRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, TilesetCadRenderManager, ViewRenderEngine, TileRenderEngine, TilesetRenderEngine, SharedGetters, ViewUtils, DrawingUtils, MeasureUtils, EntityUtils };
|
|
5400
5285
|
//# sourceMappingURL=bruce-cesium.es5.js.map
|