bruce-cesium 2.8.4 → 2.8.6
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 +212 -94
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +211 -93
- package/dist/bruce-cesium.umd.js.map +1 -1
- package/dist/lib/bruce-cesium.js +1 -1
- package/dist/lib/rendering/render-managers/common/entity-label.js +212 -92
- package/dist/lib/rendering/render-managers/common/entity-label.js.map +1 -1
- package/dist/types/bruce-cesium.d.ts +1 -1
- package/dist/types/rendering/render-managers/common/entity-label.d.ts +12 -5
- package/package.json +1 -1
package/dist/bruce-cesium.es5.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BruceEvent, Cartes, Carto, Entity as Entity$1, Geometry, Tileset, MathUtils, LRUCache, ZoomControl, Style, EntityTag, Calculator, EntityLod, EntityType, ClientFile, ObjectUtils, Bounds, EntityRelationType, DelayQueue, BatchedDataGetter, EntityCoords, EntityFilterGetter, EntitySource, MenuItem, EntityRelation, ENVIRONMENT, ProjectView, ProjectViewBookmark, ProjectViewTile, ProjectViewLegacyTile, ProgramKey, Camera, AbstractApi, EntityAttachment, EntityAttachmentType, EntityAttribute } from 'bruce-models';
|
|
2
2
|
import * as Cesium from 'cesium';
|
|
3
|
-
import { Cartographic, Cartesian2, CallbackProperty, Cartesian3, Color, Rectangle, Math as Math$1,
|
|
3
|
+
import { Cartographic, Cartesian2, CallbackProperty, Cartesian3, Color, Rectangle, Math as Math$1, HeightReference, DistanceDisplayCondition, NearFarScalar, Entity, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, JulianDate, SceneMode, Primitive, Cesium3DTileFeature, Cesium3DTileColorBlendMode, HeadingPitchRange, createOsmBuildings, Cesium3DTileStyle, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, createWorldTerrain, EllipsoidTerrainProvider, CesiumTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, CesiumInspector, defined, EllipsoidGeodesic, sampleTerrainMostDetailed, Cesium3DTileset, Model, Matrix4, Matrix3, IonResource, Ion, PolygonPipeline, ColorMaterialProperty, GeometryInstance, ScreenSpaceEventHandler, ScreenSpaceEventType, BoundingSphere } from 'cesium';
|
|
4
4
|
|
|
5
5
|
var TIME_LAG = 300;
|
|
6
6
|
var POSITION_CHECK_TIMER = 950;
|
|
@@ -3739,28 +3739,27 @@ var EntityLabel;
|
|
|
3739
3739
|
EntityLabel.ATTACH_KEY = "nextspace-navigator-entity-label";
|
|
3740
3740
|
var Label = /** @class */ (function () {
|
|
3741
3741
|
function Label(params) {
|
|
3742
|
-
var
|
|
3742
|
+
var _a;
|
|
3743
|
+
// Counter to help differentiate between createLabel calls.
|
|
3744
|
+
this.counter = 0;
|
|
3743
3745
|
// The label element itself.
|
|
3744
3746
|
this.label = null;
|
|
3745
3747
|
// Callback to kill render listener.
|
|
3746
3748
|
this.renderRemoval = null;
|
|
3749
|
+
// Callback to kill terrain listener.
|
|
3750
|
+
this.terrChangedRemoval = null;
|
|
3747
3751
|
// Indicates the label was disposed and any actions will be ignored.
|
|
3748
3752
|
this.disposed = false;
|
|
3749
|
-
this.creating = false;
|
|
3750
3753
|
// Calculated pos3d for the label.
|
|
3751
3754
|
// Override to make it draw at a different position.
|
|
3752
|
-
this.
|
|
3755
|
+
this._pos3d = null;
|
|
3756
|
+
this.prePositioned = false;
|
|
3753
3757
|
this.rego = params.rego;
|
|
3754
3758
|
this.viewer = params.viewer;
|
|
3755
3759
|
this.api = params.api;
|
|
3756
3760
|
this.visualRegister = params.visualRegister;
|
|
3757
|
-
this.
|
|
3758
|
-
this.
|
|
3759
|
-
_this.creating = false;
|
|
3760
|
-
}).catch(function (e) {
|
|
3761
|
-
console.error("Failed to create label", e);
|
|
3762
|
-
_this.creating = false;
|
|
3763
|
-
});
|
|
3761
|
+
this.prePositioned = !isNaN((_a = params.pos3d) === null || _a === void 0 ? void 0 : _a.x);
|
|
3762
|
+
this.createLabel(params.pos3d);
|
|
3764
3763
|
}
|
|
3765
3764
|
Object.defineProperty(Label.prototype, "Rego", {
|
|
3766
3765
|
get: function () {
|
|
@@ -3776,9 +3775,14 @@ var EntityLabel;
|
|
|
3776
3775
|
enumerable: false,
|
|
3777
3776
|
configurable: true
|
|
3778
3777
|
});
|
|
3779
|
-
Object.defineProperty(Label.prototype, "
|
|
3778
|
+
Object.defineProperty(Label.prototype, "pos3d", {
|
|
3780
3779
|
get: function () {
|
|
3781
|
-
return this.
|
|
3780
|
+
return this._pos3d;
|
|
3781
|
+
},
|
|
3782
|
+
set: function (val) {
|
|
3783
|
+
this._pos3d = val;
|
|
3784
|
+
this.prePositioned = !isNaN(val === null || val === void 0 ? void 0 : val.x);
|
|
3785
|
+
this.createLabel(val);
|
|
3782
3786
|
},
|
|
3783
3787
|
enumerable: false,
|
|
3784
3788
|
configurable: true
|
|
@@ -3792,49 +3796,107 @@ var EntityLabel;
|
|
|
3792
3796
|
return;
|
|
3793
3797
|
}
|
|
3794
3798
|
this.disposed = true;
|
|
3795
|
-
|
|
3796
|
-
this.label.parentElement) {
|
|
3797
|
-
this.label.parentElement.removeChild(this.label);
|
|
3798
|
-
this.label = null;
|
|
3799
|
-
}
|
|
3800
|
-
if (this.renderRemoval) {
|
|
3801
|
-
this.renderRemoval();
|
|
3802
|
-
this.renderRemoval = null;
|
|
3803
|
-
}
|
|
3799
|
+
this.removeLabel();
|
|
3804
3800
|
};
|
|
3805
3801
|
/**
|
|
3806
3802
|
* Creates cesium entity for the label if one does not exist.
|
|
3807
|
-
* @param
|
|
3803
|
+
* @param starterPos3d optional position to create label at. Ignored for billboard labels.
|
|
3808
3804
|
*/
|
|
3809
|
-
Label.prototype.
|
|
3810
|
-
var _a, _b, _c, _d, _e, _f;
|
|
3805
|
+
Label.prototype.createLabel = function (starterPos3d) {
|
|
3806
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
3811
3807
|
return __awaiter(this, void 0, void 0, function () {
|
|
3812
|
-
var
|
|
3808
|
+
var pos3d, counter, sizeInM, heightRef, pixelOffset, visual, hierarchy, posses, centerIndex, pos1, pos2, pos3, posses, isClamped, centerIndex, size, height, scale, posses, centerIndex, text, type, e_1, ele, _lastDistance, _lastCameraPos, getDistance, MAX_DISTANCE, updateLabel, terrTimeout;
|
|
3813
3809
|
var _this = this;
|
|
3814
|
-
return __generator(this, function (
|
|
3815
|
-
switch (
|
|
3810
|
+
return __generator(this, function (_l) {
|
|
3811
|
+
switch (_l.label) {
|
|
3816
3812
|
case 0:
|
|
3817
|
-
|
|
3813
|
+
pos3d = starterPos3d ? starterPos3d.clone() : null;
|
|
3814
|
+
counter = ++this.counter;
|
|
3815
|
+
if (this.disposed) {
|
|
3818
3816
|
return [2 /*return*/];
|
|
3819
3817
|
}
|
|
3818
|
+
this.removeLabel();
|
|
3819
|
+
sizeInM = 0;
|
|
3820
3820
|
heightRef = null;
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3821
|
+
pixelOffset = new Cartesian2(0, -5);
|
|
3822
|
+
if (!isNaN(pos3d === null || pos3d === void 0 ? void 0 : pos3d.x)) {
|
|
3823
|
+
heightRef = HeightReference.NONE;
|
|
3824
|
+
pixelOffset.y = -15;
|
|
3825
|
+
}
|
|
3824
3826
|
visual = (_a = this.rego) === null || _a === void 0 ? void 0 : _a.visual;
|
|
3827
|
+
// If pos3d is already set we'll run through the visuals to figure out the entity's size.
|
|
3828
|
+
// If unset then we'll use the entity's position to draw the label.
|
|
3825
3829
|
if (visual && visual instanceof Entity) {
|
|
3826
|
-
if (visual.polygon) {
|
|
3827
|
-
|
|
3830
|
+
if (!this.prePositioned && visual.polygon) {
|
|
3831
|
+
hierarchy = getValue$1(this.viewer, visual.polygon.hierarchy);
|
|
3832
|
+
if ((_b = hierarchy === null || hierarchy === void 0 ? void 0 : hierarchy.positions) === null || _b === void 0 ? void 0 : _b.length) {
|
|
3833
|
+
posses = [].concat(hierarchy.positions);
|
|
3834
|
+
try {
|
|
3835
|
+
sizeInM = (_c = MeasureUtils.MeasurePolygon({
|
|
3836
|
+
posses: posses,
|
|
3837
|
+
})) === null || _c === void 0 ? void 0 : _c.area;
|
|
3838
|
+
if (isNaN(sizeInM)) {
|
|
3839
|
+
sizeInM = 0;
|
|
3840
|
+
}
|
|
3841
|
+
}
|
|
3842
|
+
catch (e) {
|
|
3843
|
+
console.error("Failed to measure polygon", e);
|
|
3844
|
+
}
|
|
3845
|
+
if (isNaN(pos3d === null || pos3d === void 0 ? void 0 : pos3d.x)) {
|
|
3846
|
+
heightRef = getValue$1(this.viewer, visual.polygon.heightReference);
|
|
3847
|
+
if (Cartes.IsRing3Closed(posses)) {
|
|
3848
|
+
posses.pop();
|
|
3849
|
+
}
|
|
3850
|
+
centerIndex = Math.floor(posses.length / 2);
|
|
3851
|
+
if (posses.length >= 3) {
|
|
3852
|
+
pos1 = posses[centerIndex];
|
|
3853
|
+
pos2 = posses[0];
|
|
3854
|
+
pos3 = posses[posses.length - 1];
|
|
3855
|
+
if (pos1 && pos2 && pos3) {
|
|
3856
|
+
pos3d = Cartesian3.midpoint(pos1, pos2, new Cartesian3());
|
|
3857
|
+
pos3d = Cartesian3.midpoint(pos3d, pos3, new Cartesian3());
|
|
3858
|
+
}
|
|
3859
|
+
}
|
|
3860
|
+
if (isNaN(pos3d === null || pos3d === void 0 ? void 0 : pos3d.x)) {
|
|
3861
|
+
pos3d = posses[centerIndex];
|
|
3862
|
+
}
|
|
3863
|
+
}
|
|
3864
|
+
}
|
|
3828
3865
|
}
|
|
3829
|
-
else if (visual.polyline) {
|
|
3830
|
-
|
|
3831
|
-
|
|
3866
|
+
else if (!this.prePositioned && visual.polyline) {
|
|
3867
|
+
posses = getValue$1(this.viewer, visual.polyline.positions);
|
|
3868
|
+
if (posses === null || posses === void 0 ? void 0 : posses.length) {
|
|
3869
|
+
if (isNaN(pos3d === null || pos3d === void 0 ? void 0 : pos3d.x)) {
|
|
3870
|
+
isClamped = getValue$1(this.viewer, visual.polyline.clampToGround);
|
|
3871
|
+
heightRef = isClamped == false ? HeightReference.NONE : HeightReference.CLAMP_TO_GROUND;
|
|
3872
|
+
centerIndex = Math.floor(posses.length / 2);
|
|
3873
|
+
pos3d = posses[centerIndex];
|
|
3874
|
+
}
|
|
3875
|
+
try {
|
|
3876
|
+
sizeInM = (_d = MeasureUtils.MeasurePolyline({
|
|
3877
|
+
posses: posses,
|
|
3878
|
+
})) === null || _d === void 0 ? void 0 : _d.totalLength;
|
|
3879
|
+
if (isNaN(sizeInM)) {
|
|
3880
|
+
sizeInM = 0;
|
|
3881
|
+
}
|
|
3882
|
+
}
|
|
3883
|
+
catch (e) {
|
|
3884
|
+
console.error("Failed to measure polyline", e);
|
|
3885
|
+
}
|
|
3886
|
+
}
|
|
3832
3887
|
}
|
|
3833
3888
|
else if (visual.model) {
|
|
3834
|
-
|
|
3889
|
+
if (isNaN(pos3d === null || pos3d === void 0 ? void 0 : pos3d.x)) {
|
|
3890
|
+
heightRef = getValue$1(this.viewer, visual.model.heightReference);
|
|
3891
|
+
}
|
|
3835
3892
|
}
|
|
3836
3893
|
else if (visual.point) {
|
|
3837
3894
|
heightRef = getValue$1(this.viewer, visual.point.heightReference);
|
|
3895
|
+
size = getValue$1(this.viewer, visual.point.pixelSize);
|
|
3896
|
+
if (size) {
|
|
3897
|
+
pixelOffset.y = -(size / 2);
|
|
3898
|
+
pixelOffset.y -= 5;
|
|
3899
|
+
}
|
|
3838
3900
|
}
|
|
3839
3901
|
else if (visual.billboard) {
|
|
3840
3902
|
heightRef = getValue$1(this.viewer, visual.billboard.heightReference);
|
|
@@ -3842,63 +3904,57 @@ var EntityLabel;
|
|
|
3842
3904
|
if (height) {
|
|
3843
3905
|
scale = EnsureNumber(getValue$1(this.viewer, visual.billboard.scale), 1);
|
|
3844
3906
|
pixelOffset.y = -(height * scale);
|
|
3907
|
+
pixelOffset.y -= 5;
|
|
3845
3908
|
}
|
|
3846
|
-
// Flat padding.
|
|
3847
|
-
pixelOffset.y -= 5;
|
|
3848
|
-
heightOffset = 0;
|
|
3849
3909
|
}
|
|
3850
|
-
else if (visual.corridor) {
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
}
|
|
3858
|
-
else if (visual instanceof Cesium3DTileFeature) {
|
|
3859
|
-
featureAny = visual;
|
|
3860
|
-
propertyNames = featureAny.getPropertyNames ? featureAny.getPropertyNames() : (_b = featureAny.getPropertyIds) === null || _b === void 0 ? void 0 : _b.call(featureAny);
|
|
3861
|
-
if (propertyNames === null || propertyNames === void 0 ? void 0 : propertyNames.length) {
|
|
3862
|
-
latProp = propertyNames.find(function (x) { return x.toLowerCase().includes("lat"); });
|
|
3863
|
-
lonProp = propertyNames.find(function (x) { return x.toLowerCase().includes("lon"); });
|
|
3864
|
-
lat = latProp ? featureAny.getProperty(latProp) : null;
|
|
3865
|
-
lon = lonProp ? featureAny.getProperty(lonProp) : null;
|
|
3866
|
-
if (lat && lon) {
|
|
3867
|
-
latIsRad = typeof lat == "number" && lat > -Math.PI && lat < Math.PI;
|
|
3868
|
-
lonIsRad = typeof lon == "number" && lon > -Math.PI && lon < Math.PI;
|
|
3869
|
-
latIsDeg = typeof lat == "number" && lat > -180 && lat < 180;
|
|
3870
|
-
lonIsDeg = typeof lon == "number" && lon > -180 && lon < 180;
|
|
3871
|
-
if (latIsRad && lonIsRad) {
|
|
3872
|
-
pos3d = Cartographic.toCartesian(Cartographic.fromRadians(lon, lat, 0));
|
|
3910
|
+
else if (!this.prePositioned && visual.corridor) {
|
|
3911
|
+
posses = getValue$1(this.viewer, visual.corridor.positions);
|
|
3912
|
+
if (posses === null || posses === void 0 ? void 0 : posses.length) {
|
|
3913
|
+
if (isNaN(pos3d === null || pos3d === void 0 ? void 0 : pos3d.x)) {
|
|
3914
|
+
heightRef = getValue$1(this.viewer, visual.corridor.heightReference);
|
|
3915
|
+
centerIndex = Math.floor(posses.length / 2);
|
|
3916
|
+
pos3d = posses[centerIndex];
|
|
3873
3917
|
}
|
|
3874
|
-
|
|
3875
|
-
|
|
3918
|
+
try {
|
|
3919
|
+
sizeInM = (_e = MeasureUtils.MeasurePolyline({
|
|
3920
|
+
posses: posses,
|
|
3921
|
+
})) === null || _e === void 0 ? void 0 : _e.totalLength;
|
|
3922
|
+
if (isNaN(sizeInM)) {
|
|
3923
|
+
sizeInM = 0;
|
|
3924
|
+
}
|
|
3925
|
+
}
|
|
3926
|
+
catch (e) {
|
|
3927
|
+
console.error("Failed to measure polyline", e);
|
|
3876
3928
|
}
|
|
3877
|
-
heightRef = HeightReference.CLAMP_TO_GROUND;
|
|
3878
3929
|
}
|
|
3879
3930
|
}
|
|
3931
|
+
else if (visual.ellipse) {
|
|
3932
|
+
if (isNaN(pos3d === null || pos3d === void 0 ? void 0 : pos3d.x)) {
|
|
3933
|
+
heightRef = getValue$1(this.viewer, visual.ellipse.heightReference);
|
|
3934
|
+
}
|
|
3935
|
+
}
|
|
3936
|
+
if (visual.billboard || visual.point || isNaN(pos3d === null || pos3d === void 0 ? void 0 : pos3d.x)) {
|
|
3937
|
+
pos3d = getValue$1(this.viewer, visual.position);
|
|
3938
|
+
}
|
|
3880
3939
|
}
|
|
3881
3940
|
if (!isNaN(pos3d === null || pos3d === void 0 ? void 0 : pos3d.x)) return [3 /*break*/, 2];
|
|
3882
3941
|
return [4 /*yield*/, EntityUtils.GetPosAsync({
|
|
3883
3942
|
viewer: this.viewer,
|
|
3884
3943
|
api: this.api,
|
|
3885
|
-
entityId: (
|
|
3944
|
+
entityId: (_f = this.rego) === null || _f === void 0 ? void 0 : _f.entityId,
|
|
3886
3945
|
returnHeightRef: HeightReference.NONE,
|
|
3887
|
-
|
|
3946
|
+
recordHeightRef: heightRef == null || isNaN(heightRef) ? HeightReference.NONE : heightRef,
|
|
3947
|
+
tilesetId: (_g = this.rego) === null || _g === void 0 ? void 0 : _g.tilesetId,
|
|
3888
3948
|
visualRegister: this.visualRegister
|
|
3889
3949
|
})];
|
|
3890
3950
|
case 1:
|
|
3891
|
-
pos3d =
|
|
3951
|
+
pos3d = _l.sent();
|
|
3892
3952
|
heightRef = HeightReference.NONE;
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
heightOffset = 0;
|
|
3899
|
-
pixelOffset.y = -15;
|
|
3900
|
-
_g.label = 4;
|
|
3901
|
-
case 4:
|
|
3953
|
+
if (this.counter != counter) {
|
|
3954
|
+
return [2 /*return*/];
|
|
3955
|
+
}
|
|
3956
|
+
_l.label = 2;
|
|
3957
|
+
case 2:
|
|
3902
3958
|
if (isNaN(pos3d === null || pos3d === void 0 ? void 0 : pos3d.x)) {
|
|
3903
3959
|
return [2 /*return*/];
|
|
3904
3960
|
}
|
|
@@ -3911,18 +3967,42 @@ var EntityLabel;
|
|
|
3911
3967
|
if (isNaN(pos3d === null || pos3d === void 0 ? void 0 : pos3d.x)) {
|
|
3912
3968
|
return [2 /*return*/];
|
|
3913
3969
|
}
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3970
|
+
this._pos3d = pos3d;
|
|
3971
|
+
text = "Unknown Entity";
|
|
3972
|
+
if (!((_h = this.rego) === null || _h === void 0 ? void 0 : _h.relation)) return [3 /*break*/, 7];
|
|
3973
|
+
type = this.rego.relation.RelationType;
|
|
3974
|
+
if (!(!type && this.rego.relation["Related.Entity.ID"])) return [3 /*break*/, 6];
|
|
3975
|
+
_l.label = 3;
|
|
3976
|
+
case 3:
|
|
3977
|
+
_l.trys.push([3, 5, , 6]);
|
|
3978
|
+
return [4 /*yield*/, EntityRelationType.Get({
|
|
3979
|
+
api: this.api,
|
|
3980
|
+
relationTypeId: this.rego.relation["Related.Entity.ID"]
|
|
3981
|
+
})];
|
|
3982
|
+
case 4:
|
|
3983
|
+
type = (_j = (_l.sent())) === null || _j === void 0 ? void 0 : _j.relationType;
|
|
3984
|
+
return [3 /*break*/, 6];
|
|
3985
|
+
case 5:
|
|
3986
|
+
e_1 = _l.sent();
|
|
3987
|
+
console.error(e_1);
|
|
3988
|
+
return [3 /*break*/, 6];
|
|
3989
|
+
case 6:
|
|
3990
|
+
if (type) {
|
|
3991
|
+
text = type.Name ? type.Name : (type.ForwardName + "/" + type.ReverseName);
|
|
3992
|
+
}
|
|
3993
|
+
return [3 /*break*/, 8];
|
|
3994
|
+
case 7:
|
|
3995
|
+
if ((_k = this.rego) === null || _k === void 0 ? void 0 : _k.name) {
|
|
3996
|
+
text = this.rego.name;
|
|
3920
3997
|
}
|
|
3921
|
-
|
|
3922
|
-
|
|
3998
|
+
else {
|
|
3999
|
+
text = "Unnamed Entity";
|
|
4000
|
+
}
|
|
4001
|
+
_l.label = 8;
|
|
4002
|
+
case 8:
|
|
3923
4003
|
ele = document.createElement("div");
|
|
3924
4004
|
ele.innerHTML = text;
|
|
3925
|
-
ele.setAttribute("style", "\n position: absolute;\n z-index:
|
|
4005
|
+
ele.setAttribute("style", "\n position: absolute;\n z-index: 0;\n display: none;\n pointer-events: none;\n padding: 6px 8px;\n border-radius: 6px;\n font-family: Arial;\n font-size: 12px;\n -webkit-backdrop-filter: blur(20px);\n backdrop-filter: blur(20px);\n background: rgba(33,39,42,.8);\n border-radius: 9px;\n box-shadow: 0 0 1px rgba(18,22,25,.36),0 18px 36px -4px rgba(18,22,25,.36);\n color: #ffffff;\n }");
|
|
3926
4006
|
this.label = ele;
|
|
3927
4007
|
this.viewer.container.appendChild(ele);
|
|
3928
4008
|
_lastDistance = null;
|
|
@@ -3972,23 +4052,30 @@ var EntityLabel;
|
|
|
3972
4052
|
// }
|
|
3973
4053
|
// }
|
|
3974
4054
|
// }
|
|
3975
|
-
var distance = Cartesian3.distance(cameraPos, _this.
|
|
4055
|
+
var distance = Cartesian3.distance(cameraPos, _this._pos3d);
|
|
3976
4056
|
_lastDistance = distance;
|
|
3977
4057
|
_lastCameraPos = cameraPos.clone();
|
|
3978
4058
|
return distance;
|
|
3979
4059
|
};
|
|
3980
4060
|
MAX_DISTANCE = 5000;
|
|
4061
|
+
if (sizeInM > 30) {
|
|
4062
|
+
MAX_DISTANCE = Math.max(MAX_DISTANCE, sizeInM / 2);
|
|
4063
|
+
}
|
|
3981
4064
|
updateLabel = function () {
|
|
3982
4065
|
var _a;
|
|
3983
|
-
if (_this.disposed || isNaN((_a = _this.
|
|
4066
|
+
if (_this.disposed || isNaN((_a = _this._pos3d) === null || _a === void 0 ? void 0 : _a.x)) {
|
|
4067
|
+
return;
|
|
4068
|
+
}
|
|
4069
|
+
if (!_this.viewer || _this.viewer.isDestroyed()) {
|
|
4070
|
+
_this.Dispose();
|
|
3984
4071
|
return;
|
|
3985
4072
|
}
|
|
3986
4073
|
var distance = getDistance();
|
|
3987
|
-
if (isNaN(distance) || distance >= MAX_DISTANCE) {
|
|
4074
|
+
if (isNaN(distance) || (!_this.prePositioned && distance >= MAX_DISTANCE)) {
|
|
3988
4075
|
ele.style.display = "none";
|
|
3989
4076
|
return;
|
|
3990
4077
|
}
|
|
3991
|
-
var pos2d = SceneTransforms.wgs84ToWindowCoordinates(_this.viewer.scene, _this.
|
|
4078
|
+
var pos2d = SceneTransforms.wgs84ToWindowCoordinates(_this.viewer.scene, _this._pos3d);
|
|
3992
4079
|
if (isNaN(pos2d === null || pos2d === void 0 ? void 0 : pos2d.x)) {
|
|
3993
4080
|
ele.style.display = "none";
|
|
3994
4081
|
return;
|
|
@@ -4002,7 +4089,7 @@ var EntityLabel;
|
|
|
4002
4089
|
ele.style.display = "block";
|
|
4003
4090
|
// Check scale to apply based on distance between camera and pos3d.
|
|
4004
4091
|
// We'll make the label smaller and less transparent when further away.
|
|
4005
|
-
var scale = 1 - (distance / MAX_DISTANCE);
|
|
4092
|
+
var scale = _this.prePositioned ? 1 : 1 - (distance / MAX_DISTANCE);
|
|
4006
4093
|
if (scale && scale > 0.15) {
|
|
4007
4094
|
ele.style.transform = "scale(".concat(scale, ")");
|
|
4008
4095
|
ele.style.opacity = "".concat(scale);
|
|
@@ -4018,11 +4105,42 @@ var EntityLabel;
|
|
|
4018
4105
|
};
|
|
4019
4106
|
this.renderRemoval = this.viewer.scene.postUpdate.addEventListener(updateLabel);
|
|
4020
4107
|
updateLabel();
|
|
4108
|
+
terrTimeout = null;
|
|
4109
|
+
this.terrChangedRemoval = this.viewer.scene.terrainProviderChanged.addEventListener(function () {
|
|
4110
|
+
if (_this.disposed) {
|
|
4111
|
+
return;
|
|
4112
|
+
}
|
|
4113
|
+
clearTimeout(terrTimeout);
|
|
4114
|
+
terrTimeout = setTimeout(function () {
|
|
4115
|
+
if (counter != _this.counter) {
|
|
4116
|
+
return;
|
|
4117
|
+
}
|
|
4118
|
+
_this.createLabel(starterPos3d);
|
|
4119
|
+
}, 2500);
|
|
4120
|
+
});
|
|
4021
4121
|
return [2 /*return*/];
|
|
4022
4122
|
}
|
|
4023
4123
|
});
|
|
4024
4124
|
});
|
|
4025
4125
|
};
|
|
4126
|
+
/**
|
|
4127
|
+
* Removes label from the viewer and unsubscribes from events.
|
|
4128
|
+
*/
|
|
4129
|
+
Label.prototype.removeLabel = function () {
|
|
4130
|
+
if (this.label &&
|
|
4131
|
+
this.label.parentElement) {
|
|
4132
|
+
this.label.parentElement.removeChild(this.label);
|
|
4133
|
+
this.label = null;
|
|
4134
|
+
}
|
|
4135
|
+
if (this.renderRemoval) {
|
|
4136
|
+
this.renderRemoval();
|
|
4137
|
+
this.renderRemoval = null;
|
|
4138
|
+
}
|
|
4139
|
+
if (this.terrChangedRemoval) {
|
|
4140
|
+
this.terrChangedRemoval();
|
|
4141
|
+
this.terrChangedRemoval = null;
|
|
4142
|
+
}
|
|
4143
|
+
};
|
|
4026
4144
|
return Label;
|
|
4027
4145
|
}());
|
|
4028
4146
|
EntityLabel.Label = Label;
|
|
@@ -16008,7 +16126,7 @@ var ViewerUtils;
|
|
|
16008
16126
|
ViewerUtils.CreateWidgets = CreateWidgets;
|
|
16009
16127
|
})(ViewerUtils || (ViewerUtils = {}));
|
|
16010
16128
|
|
|
16011
|
-
var VERSION$1 = "2.8.
|
|
16129
|
+
var VERSION$1 = "2.8.6";
|
|
16012
16130
|
|
|
16013
16131
|
export { VERSION$1 as VERSION, CesiumViewMonitor, ViewerUtils, MenuItemManager, EntityRenderEngine, MenuItemCreator, VisualsRegister, RenderManager, EntitiesIdsRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, TilesetCadRenderManager, TilesetArbRenderManager, TilesetEntitiesRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TilesetGooglePhotosRenderManager, DataSourceStaticKmlManager, RelationsRenderManager, SharedGetters, CesiumParabola, EntityLabel, ViewRenderEngine, TileRenderEngine, TilesetRenderEngine, CESIUM_INSPECTOR_KEY, ViewUtils, DrawingUtils, MeasureUtils, EntityUtils, Draw3dPolygon, Draw3dPolyline };
|
|
16014
16132
|
//# sourceMappingURL=bruce-cesium.es5.js.map
|