bruce-cesium 1.6.1 → 1.6.2
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 +223 -80
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +221 -78
- package/dist/bruce-cesium.umd.js.map +1 -1
- package/dist/lib/rendering/relation-render-engine.js +108 -78
- package/dist/lib/rendering/relation-render-engine.js.map +1 -1
- package/dist/lib/utils/entity-utils.js +149 -0
- package/dist/lib/utils/entity-utils.js.map +1 -1
- package/dist/types/rendering/relation-render-engine.d.ts +2 -1
- package/dist/types/utils/entity-utils.d.ts +18 -1
- package/package.json +2 -2
package/dist/bruce-cesium.es5.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BruceEvent, Cartes, Carto, Geometry, ZoomControl, Style, EntityTag, Calculator, EntityLod, EntityType, ClientFile, ObjectUtils, DelayQueue,
|
|
2
|
-
import { Cartesian2, Cartographic, Math as Math$1, Color, HeightReference, Cartesian3, EllipsoidTerrainProvider, Entity, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, PolygonHierarchy, ShadowMode, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, Primitive, Cesium3DTileFeature,
|
|
1
|
+
import { BruceEvent, Cartes, Carto, Entity as Entity$1, Geometry, Tileset, ZoomControl, Style, EntityTag, Calculator, EntityLod, EntityType, ClientFile, ObjectUtils, DelayQueue, BatchedDataGetter, EntityRelationType, EntityCoords, EntityFilterGetter, EntitySource, MenuItem, EntityRelation, ProjectView, ProjectViewBookmark, ProjectViewTile, ProjectViewLegacyTile, ProgramKey, Camera } from 'bruce-models';
|
|
2
|
+
import { Cartesian2, Cartographic, Math as Math$1, Color, HeightReference, Cartesian3, EllipsoidTerrainProvider, Entity, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, PolygonHierarchy, ShadowMode, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, Primitive, Cesium3DTileFeature, Cesium3DTileColorBlendMode, HeadingPitchRange, createOsmBuildings, Cesium3DTileStyle, Rectangle, SceneMode, OrthographicFrustum, JulianDate, CallbackProperty, KmlDataSource, EllipsoidGeodesic, sampleTerrainMostDetailed, PolygonPipeline, ColorMaterialProperty, Matrix3, Matrix4, EasingFunction, GeometryInstance, Cesium3DTileset, IonResource, createWorldTerrain, CesiumTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider } from 'cesium';
|
|
3
3
|
|
|
4
4
|
var TIME_LAG = 300;
|
|
5
5
|
var POSITION_CHECK_TIMER = 950;
|
|
@@ -836,6 +836,119 @@ var EntityUtils;
|
|
|
836
836
|
});
|
|
837
837
|
}
|
|
838
838
|
EntityUtils.GetPos = GetPos;
|
|
839
|
+
/**
|
|
840
|
+
* Returns the position of the entity.
|
|
841
|
+
* This is an async variant that checks for related tilesets.
|
|
842
|
+
* @param params
|
|
843
|
+
* @returns
|
|
844
|
+
*/
|
|
845
|
+
function GetPosAsync(params) {
|
|
846
|
+
var _a, _b, _c, _d, _e, _f;
|
|
847
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
848
|
+
var viewer, entityId, entity, tileset, tilesetId, visualRegister, returnHeightRef, recordHeightRef, api, pos3d, e_1, tSettings, ALT_INCREASE, alt, alt, heading, matrix4, offset, m1, hpr, transform, transformedOffset;
|
|
849
|
+
return __generator(this, function (_g) {
|
|
850
|
+
switch (_g.label) {
|
|
851
|
+
case 0:
|
|
852
|
+
viewer = params.viewer, entityId = params.entityId, entity = params.entity, tileset = params.tileset, tilesetId = params.tilesetId, visualRegister = params.visualRegister, returnHeightRef = params.returnHeightRef, recordHeightRef = params.recordHeightRef, api = params.api;
|
|
853
|
+
pos3d = GetPos({
|
|
854
|
+
viewer: viewer,
|
|
855
|
+
entity: entity,
|
|
856
|
+
visualRegister: visualRegister,
|
|
857
|
+
returnHeightRef: returnHeightRef,
|
|
858
|
+
recordHeightRef: recordHeightRef
|
|
859
|
+
});
|
|
860
|
+
if (Cartes.ValidateCartes3(pos3d)) {
|
|
861
|
+
return [2 /*return*/, pos3d];
|
|
862
|
+
}
|
|
863
|
+
if (!!entity) return [3 /*break*/, 5];
|
|
864
|
+
_g.label = 1;
|
|
865
|
+
case 1:
|
|
866
|
+
_g.trys.push([1, 3, , 5]);
|
|
867
|
+
return [4 /*yield*/, Entity$1.Get({
|
|
868
|
+
api: api,
|
|
869
|
+
entityId: entityId,
|
|
870
|
+
expandLocation: true
|
|
871
|
+
})];
|
|
872
|
+
case 2:
|
|
873
|
+
entity = (_g.sent()).entity;
|
|
874
|
+
return [3 /*break*/, 5];
|
|
875
|
+
case 3:
|
|
876
|
+
e_1 = _g.sent();
|
|
877
|
+
console.warn(e_1);
|
|
878
|
+
return [4 /*yield*/, Entity$1.Get({
|
|
879
|
+
api: api,
|
|
880
|
+
entityId: entityId,
|
|
881
|
+
expandLocation: false
|
|
882
|
+
})];
|
|
883
|
+
case 4:
|
|
884
|
+
entity = (_g.sent()).entity;
|
|
885
|
+
return [3 /*break*/, 5];
|
|
886
|
+
case 5:
|
|
887
|
+
if (!!tileset) return [3 /*break*/, 7];
|
|
888
|
+
if (!tilesetId) {
|
|
889
|
+
tilesetId = ((_a = entity.tilesetID) === null || _a === void 0 ? void 0 : _a.length) ? entity.tilesetID[0] : tilesetId;
|
|
890
|
+
}
|
|
891
|
+
if (!tilesetId) return [3 /*break*/, 7];
|
|
892
|
+
return [4 /*yield*/, Tileset.Get({
|
|
893
|
+
api: api,
|
|
894
|
+
tilesetId: tilesetId
|
|
895
|
+
})];
|
|
896
|
+
case 6:
|
|
897
|
+
tileset = (_g.sent()).tileset;
|
|
898
|
+
_g.label = 7;
|
|
899
|
+
case 7:
|
|
900
|
+
tSettings = tileset === null || tileset === void 0 ? void 0 : tileset.settings;
|
|
901
|
+
if (((_b = entity.location) === null || _b === void 0 ? void 0 : _b.longitude) || ((_c = tSettings === null || tSettings === void 0 ? void 0 : tSettings.location) === null || _c === void 0 ? void 0 : _c.longitude)) {
|
|
902
|
+
ALT_INCREASE = 30;
|
|
903
|
+
if ((_d = entity === null || entity === void 0 ? void 0 : entity.location) === null || _d === void 0 ? void 0 : _d.longitude) {
|
|
904
|
+
alt = +entity.location.altitude;
|
|
905
|
+
if (isNaN(alt)) {
|
|
906
|
+
alt = 0;
|
|
907
|
+
}
|
|
908
|
+
alt += ALT_INCREASE;
|
|
909
|
+
pos3d = Cartesian3.fromDegrees(+entity.location.longitude, +entity.location.latitude, alt);
|
|
910
|
+
}
|
|
911
|
+
else {
|
|
912
|
+
alt = +tSettings.location.altitude;
|
|
913
|
+
if (isNaN(alt)) {
|
|
914
|
+
alt = 0;
|
|
915
|
+
}
|
|
916
|
+
alt += ALT_INCREASE;
|
|
917
|
+
pos3d = Cartesian3.fromDegrees(+tSettings.location.longitude, +tSettings.location.latitude, alt);
|
|
918
|
+
}
|
|
919
|
+
// World position = we got lat/lon/alt from the tileset, now we need to apply relative movement.
|
|
920
|
+
if (entity === null || entity === void 0 ? void 0 : entity.worldPosition) {
|
|
921
|
+
heading = 0;
|
|
922
|
+
if ((_e = entity === null || entity === void 0 ? void 0 : entity.transform) === null || _e === void 0 ? void 0 : _e.heading) {
|
|
923
|
+
heading = entity.transform.heading;
|
|
924
|
+
}
|
|
925
|
+
else if ((_f = tSettings === null || tSettings === void 0 ? void 0 : tSettings.transform) === null || _f === void 0 ? void 0 : _f.heading) {
|
|
926
|
+
heading = tSettings.transform.heading;
|
|
927
|
+
}
|
|
928
|
+
heading = +heading;
|
|
929
|
+
if (isNaN(heading)) {
|
|
930
|
+
heading = 0;
|
|
931
|
+
}
|
|
932
|
+
matrix4 = entity.worldPosition;
|
|
933
|
+
offset = new Cartesian3(matrix4[0][3], matrix4[1][3], matrix4[2][3]);
|
|
934
|
+
m1 = Transforms.eastNorthUpToFixedFrame(pos3d);
|
|
935
|
+
hpr = HeadingPitchRoll.fromDegrees(heading, 0, 0, new HeadingPitchRoll());
|
|
936
|
+
transform = Matrix3.fromHeadingPitchRoll(hpr);
|
|
937
|
+
transformedOffset = Matrix3.multiplyByVector(transform, offset, new Cartesian3());
|
|
938
|
+
pos3d = Matrix4.multiplyByPoint(m1, transformedOffset, new Cartesian3());
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
return [2 /*return*/, DrawingUtils.EnsurePosHeight({
|
|
942
|
+
desiredHeightRef: params.returnHeightRef,
|
|
943
|
+
heightRef: params.recordHeightRef,
|
|
944
|
+
pos3d: pos3d,
|
|
945
|
+
viewer: viewer
|
|
946
|
+
})];
|
|
947
|
+
}
|
|
948
|
+
});
|
|
949
|
+
});
|
|
950
|
+
}
|
|
951
|
+
EntityUtils.GetPosAsync = GetPosAsync;
|
|
839
952
|
/**
|
|
840
953
|
* Returns entity and any associated parent/sibling entities as a flat array.
|
|
841
954
|
* @param entity
|
|
@@ -3029,7 +3142,7 @@ var RelationRenderEngine;
|
|
|
3029
3142
|
i = 0;
|
|
3030
3143
|
_d.label = 1;
|
|
3031
3144
|
case 1:
|
|
3032
|
-
if (!(i < relations.length)) return [3 /*break*/,
|
|
3145
|
+
if (!(i < relations.length)) return [3 /*break*/, 17];
|
|
3033
3146
|
relation = relations[i];
|
|
3034
3147
|
return [4 /*yield*/, Entity$1.Get({
|
|
3035
3148
|
api: api,
|
|
@@ -3094,22 +3207,25 @@ var RelationRenderEngine;
|
|
|
3094
3207
|
_d.label = 14;
|
|
3095
3208
|
case 14:
|
|
3096
3209
|
style = _c;
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3210
|
+
return [4 /*yield*/, Parabola.Render({
|
|
3211
|
+
dataEntity: dataEntity,
|
|
3212
|
+
fromEntity: fromEntity,
|
|
3213
|
+
relation: relation,
|
|
3214
|
+
style: style,
|
|
3215
|
+
toEntity: toEntity,
|
|
3216
|
+
viewer: viewer,
|
|
3217
|
+
visualRegister: visualRegister,
|
|
3218
|
+
apiGetter: apiGetter
|
|
3219
|
+
})];
|
|
3220
|
+
case 15:
|
|
3221
|
+
cEntity = _d.sent();
|
|
3106
3222
|
cEntity._renderGroup = GetRenderGroupId(relation);
|
|
3107
3223
|
rendered[GetRenderGroupId(relation)] = cEntity;
|
|
3108
|
-
_d.label =
|
|
3109
|
-
case
|
|
3224
|
+
_d.label = 16;
|
|
3225
|
+
case 16:
|
|
3110
3226
|
i++;
|
|
3111
3227
|
return [3 /*break*/, 1];
|
|
3112
|
-
case
|
|
3228
|
+
case 17: return [2 /*return*/, rendered];
|
|
3113
3229
|
}
|
|
3114
3230
|
});
|
|
3115
3231
|
});
|
|
@@ -3119,74 +3235,101 @@ var RelationRenderEngine;
|
|
|
3119
3235
|
(function (Parabola) {
|
|
3120
3236
|
function Render(params) {
|
|
3121
3237
|
var _a;
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3238
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3239
|
+
var style, entity, bColor, cColor, width, duration, hDistanceRatio, fromPos, toPos, updatingPosses, updatePosses, parabola, cEntities, cEntity, i, sibling, updateInterval;
|
|
3240
|
+
var _this = this;
|
|
3241
|
+
return __generator(this, function (_b) {
|
|
3242
|
+
style = (_a = params.style) === null || _a === void 0 ? void 0 : _a.Settings;
|
|
3243
|
+
entity = params.dataEntity;
|
|
3244
|
+
bColor = (style === null || style === void 0 ? void 0 : style.lineColor) ? Calculator.GetColor(style === null || style === void 0 ? void 0 : style.lineColor, entity, []) : null;
|
|
3245
|
+
cColor = bColor ? colorToCColor$1(bColor) : Color.WHITE;
|
|
3246
|
+
width = EnsureNumber((style === null || style === void 0 ? void 0 : style.lineWidth) ? Calculator.GetNumber(style === null || style === void 0 ? void 0 : style.lineWidth, entity, []) : 4, 4);
|
|
3247
|
+
if (width < 1) {
|
|
3248
|
+
width = 1;
|
|
3249
|
+
}
|
|
3250
|
+
duration = EnsureNumber((style === null || style === void 0 ? void 0 : style.duration) ? Calculator.GetNumber(style === null || style === void 0 ? void 0 : style.duration, entity, []) : 2, 2);
|
|
3251
|
+
hDistanceRatio = EnsureNumber((style === null || style === void 0 ? void 0 : style.heightDistanceRatio) ? Calculator.GetNumber(style === null || style === void 0 ? void 0 : style.heightDistanceRatio, entity, []) : 0.25, 0.25);
|
|
3252
|
+
fromPos = null;
|
|
3253
|
+
toPos = null;
|
|
3254
|
+
updatingPosses = false;
|
|
3255
|
+
updatePosses = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3256
|
+
var e_1;
|
|
3257
|
+
return __generator(this, function (_a) {
|
|
3258
|
+
switch (_a.label) {
|
|
3259
|
+
case 0:
|
|
3260
|
+
if (updatingPosses) {
|
|
3261
|
+
return [2 /*return*/];
|
|
3262
|
+
}
|
|
3263
|
+
updatingPosses = true;
|
|
3264
|
+
_a.label = 1;
|
|
3265
|
+
case 1:
|
|
3266
|
+
_a.trys.push([1, 4, , 5]);
|
|
3267
|
+
return [4 /*yield*/, EntityUtils.GetPosAsync({
|
|
3268
|
+
// Not passing it so it requests entity with expanded tileset information instead.
|
|
3269
|
+
//entity: params.fromEntity,
|
|
3270
|
+
viewer: params.viewer,
|
|
3271
|
+
visualRegister: params.visualRegister,
|
|
3272
|
+
returnHeightRef: HeightReference.NONE,
|
|
3273
|
+
recordHeightRef: HeightReference.CLAMP_TO_GROUND,
|
|
3274
|
+
api: params.apiGetter.getApi(),
|
|
3275
|
+
entityId: params.fromEntity.Bruce.ID
|
|
3276
|
+
})];
|
|
3277
|
+
case 2:
|
|
3278
|
+
fromPos = _a.sent();
|
|
3279
|
+
return [4 /*yield*/, EntityUtils.GetPosAsync({
|
|
3280
|
+
// Not passing it so it requests entity with expanded tileset information instead.
|
|
3281
|
+
//entity: params.toEntity,
|
|
3282
|
+
viewer: params.viewer,
|
|
3283
|
+
visualRegister: params.visualRegister,
|
|
3284
|
+
returnHeightRef: HeightReference.NONE,
|
|
3285
|
+
recordHeightRef: HeightReference.CLAMP_TO_GROUND,
|
|
3286
|
+
api: params.apiGetter.getApi(),
|
|
3287
|
+
entityId: params.toEntity.Bruce.ID
|
|
3288
|
+
})];
|
|
3289
|
+
case 3:
|
|
3290
|
+
toPos = _a.sent();
|
|
3291
|
+
return [3 /*break*/, 5];
|
|
3292
|
+
case 4:
|
|
3293
|
+
e_1 = _a.sent();
|
|
3294
|
+
console.error(e_1);
|
|
3295
|
+
return [3 /*break*/, 5];
|
|
3296
|
+
case 5:
|
|
3297
|
+
updatingPosses = false;
|
|
3298
|
+
return [2 /*return*/];
|
|
3299
|
+
}
|
|
3300
|
+
});
|
|
3301
|
+
}); };
|
|
3302
|
+
updatePosses();
|
|
3303
|
+
parabola = new CesiumParabola({
|
|
3150
3304
|
viewer: params.viewer,
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3305
|
+
pos1: function () { return fromPos; },
|
|
3306
|
+
pos2: function () { return toPos; },
|
|
3307
|
+
color: cColor.toCssColorString(),
|
|
3308
|
+
width: width,
|
|
3309
|
+
duration: duration,
|
|
3310
|
+
heightDistanceRatio: hDistanceRatio
|
|
3154
3311
|
});
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3312
|
+
cEntities = parabola.Animate();
|
|
3313
|
+
cEntity = cEntities.parabola;
|
|
3314
|
+
cEntity._siblingGraphics = [];
|
|
3315
|
+
for (i = 0; i < cEntities.siblings.length; i++) {
|
|
3316
|
+
sibling = cEntities.siblings[i];
|
|
3317
|
+
cEntity._siblingGraphics.push(sibling);
|
|
3318
|
+
}
|
|
3319
|
+
updateInterval = setInterval(function () {
|
|
3320
|
+
var _a;
|
|
3321
|
+
if (!((_a = params.viewer) === null || _a === void 0 ? void 0 : _a.scene) ||
|
|
3322
|
+
params.viewer.isDestroyed() ||
|
|
3323
|
+
!params.viewer.entities.contains(cEntity)) {
|
|
3324
|
+
clearInterval(updateInterval);
|
|
3325
|
+
parabola.Dispose();
|
|
3326
|
+
return;
|
|
3327
|
+
}
|
|
3328
|
+
updatePosses();
|
|
3329
|
+
}, 1000);
|
|
3330
|
+
return [2 /*return*/, cEntity];
|
|
3331
|
+
});
|
|
3170
3332
|
});
|
|
3171
|
-
var cEntities = parabola.Animate();
|
|
3172
|
-
var cEntity = cEntities.parabola;
|
|
3173
|
-
cEntity._siblingGraphics = [];
|
|
3174
|
-
for (var i = 0; i < cEntities.siblings.length; i++) {
|
|
3175
|
-
var sibling = cEntities.siblings[i];
|
|
3176
|
-
cEntity._siblingGraphics.push(sibling);
|
|
3177
|
-
}
|
|
3178
|
-
var updateInterval = setInterval(function () {
|
|
3179
|
-
var _a;
|
|
3180
|
-
if (!((_a = params.viewer) === null || _a === void 0 ? void 0 : _a.scene) ||
|
|
3181
|
-
params.viewer.isDestroyed() ||
|
|
3182
|
-
!params.viewer.entities.contains(cEntity)) {
|
|
3183
|
-
clearInterval(updateInterval);
|
|
3184
|
-
parabola.Dispose();
|
|
3185
|
-
return;
|
|
3186
|
-
}
|
|
3187
|
-
updatePosses();
|
|
3188
|
-
}, 1000);
|
|
3189
|
-
return cEntity;
|
|
3190
3333
|
}
|
|
3191
3334
|
Parabola.Render = Render;
|
|
3192
3335
|
})(Parabola = RelationRenderEngine.Parabola || (RelationRenderEngine.Parabola = {}));
|