bruce-cesium 1.6.1 → 1.6.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 +226 -80
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +224 -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 +152 -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, SceneMode,
|
|
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, SceneMode, createOsmBuildings, Cesium3DTileStyle, Rectangle, Cesium3DTileColorBlendMode, HeadingPitchRange, KmlDataSource, CallbackProperty, OrthographicFrustum, JulianDate, createWorldTerrain, CesiumTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, Cesium3DTileset, Matrix4, IonResource, EllipsoidGeodesic, sampleTerrainMostDetailed, ColorMaterialProperty, Matrix3, EasingFunction, GeometryInstance, PolygonPipeline } from 'cesium';
|
|
3
3
|
|
|
4
4
|
var TIME_LAG = 300;
|
|
5
5
|
var POSITION_CHECK_TIMER = 950;
|
|
@@ -836,6 +836,122 @@ 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, e_1, pos3d, 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
|
+
if (!!entity) return [3 /*break*/, 5];
|
|
854
|
+
_g.label = 1;
|
|
855
|
+
case 1:
|
|
856
|
+
_g.trys.push([1, 3, , 5]);
|
|
857
|
+
return [4 /*yield*/, Entity$1.Get({
|
|
858
|
+
api: api,
|
|
859
|
+
entityId: entityId,
|
|
860
|
+
expandLocation: true
|
|
861
|
+
})];
|
|
862
|
+
case 2:
|
|
863
|
+
entity = (_g.sent()).entity;
|
|
864
|
+
return [3 /*break*/, 5];
|
|
865
|
+
case 3:
|
|
866
|
+
e_1 = _g.sent();
|
|
867
|
+
console.warn(e_1);
|
|
868
|
+
return [4 /*yield*/, Entity$1.Get({
|
|
869
|
+
api: api,
|
|
870
|
+
entityId: entityId,
|
|
871
|
+
expandLocation: false
|
|
872
|
+
})];
|
|
873
|
+
case 4:
|
|
874
|
+
entity = (_g.sent()).entity;
|
|
875
|
+
return [3 /*break*/, 5];
|
|
876
|
+
case 5:
|
|
877
|
+
if (!entity) {
|
|
878
|
+
return [2 /*return*/, null];
|
|
879
|
+
}
|
|
880
|
+
pos3d = GetPos({
|
|
881
|
+
viewer: viewer,
|
|
882
|
+
entity: entity,
|
|
883
|
+
visualRegister: visualRegister,
|
|
884
|
+
returnHeightRef: returnHeightRef,
|
|
885
|
+
recordHeightRef: recordHeightRef
|
|
886
|
+
});
|
|
887
|
+
if (Cartes.ValidateCartes3(pos3d)) {
|
|
888
|
+
return [2 /*return*/, pos3d];
|
|
889
|
+
}
|
|
890
|
+
if (!!tileset) return [3 /*break*/, 7];
|
|
891
|
+
if (!tilesetId) {
|
|
892
|
+
tilesetId = ((_a = entity.tilesetID) === null || _a === void 0 ? void 0 : _a.length) ? entity.tilesetID[0] : tilesetId;
|
|
893
|
+
}
|
|
894
|
+
if (!tilesetId) return [3 /*break*/, 7];
|
|
895
|
+
return [4 /*yield*/, Tileset.Get({
|
|
896
|
+
api: api,
|
|
897
|
+
tilesetId: tilesetId
|
|
898
|
+
})];
|
|
899
|
+
case 6:
|
|
900
|
+
tileset = (_g.sent()).tileset;
|
|
901
|
+
_g.label = 7;
|
|
902
|
+
case 7:
|
|
903
|
+
tSettings = tileset === null || tileset === void 0 ? void 0 : tileset.settings;
|
|
904
|
+
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)) {
|
|
905
|
+
ALT_INCREASE = 30;
|
|
906
|
+
if ((_d = entity === null || entity === void 0 ? void 0 : entity.location) === null || _d === void 0 ? void 0 : _d.longitude) {
|
|
907
|
+
alt = +entity.location.altitude;
|
|
908
|
+
if (isNaN(alt)) {
|
|
909
|
+
alt = 0;
|
|
910
|
+
}
|
|
911
|
+
alt += ALT_INCREASE;
|
|
912
|
+
pos3d = Cartesian3.fromDegrees(+entity.location.longitude, +entity.location.latitude, alt);
|
|
913
|
+
}
|
|
914
|
+
else {
|
|
915
|
+
alt = +tSettings.location.altitude;
|
|
916
|
+
if (isNaN(alt)) {
|
|
917
|
+
alt = 0;
|
|
918
|
+
}
|
|
919
|
+
alt += ALT_INCREASE;
|
|
920
|
+
pos3d = Cartesian3.fromDegrees(+tSettings.location.longitude, +tSettings.location.latitude, alt);
|
|
921
|
+
}
|
|
922
|
+
// World position = we got lat/lon/alt from the tileset, now we need to apply relative movement.
|
|
923
|
+
if (entity === null || entity === void 0 ? void 0 : entity.worldPosition) {
|
|
924
|
+
heading = 0;
|
|
925
|
+
if ((_e = entity === null || entity === void 0 ? void 0 : entity.transform) === null || _e === void 0 ? void 0 : _e.heading) {
|
|
926
|
+
heading = entity.transform.heading;
|
|
927
|
+
}
|
|
928
|
+
else if ((_f = tSettings === null || tSettings === void 0 ? void 0 : tSettings.transform) === null || _f === void 0 ? void 0 : _f.heading) {
|
|
929
|
+
heading = tSettings.transform.heading;
|
|
930
|
+
}
|
|
931
|
+
heading = +heading;
|
|
932
|
+
if (isNaN(heading)) {
|
|
933
|
+
heading = 0;
|
|
934
|
+
}
|
|
935
|
+
matrix4 = entity.worldPosition;
|
|
936
|
+
offset = new Cartesian3(matrix4[0][3], matrix4[1][3], matrix4[2][3]);
|
|
937
|
+
m1 = Transforms.eastNorthUpToFixedFrame(pos3d);
|
|
938
|
+
hpr = HeadingPitchRoll.fromDegrees(heading, 0, 0, new HeadingPitchRoll());
|
|
939
|
+
transform = Matrix3.fromHeadingPitchRoll(hpr);
|
|
940
|
+
transformedOffset = Matrix3.multiplyByVector(transform, offset, new Cartesian3());
|
|
941
|
+
pos3d = Matrix4.multiplyByPoint(m1, transformedOffset, new Cartesian3());
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
return [2 /*return*/, DrawingUtils.EnsurePosHeight({
|
|
945
|
+
desiredHeightRef: params.returnHeightRef,
|
|
946
|
+
heightRef: params.recordHeightRef,
|
|
947
|
+
pos3d: pos3d,
|
|
948
|
+
viewer: viewer
|
|
949
|
+
})];
|
|
950
|
+
}
|
|
951
|
+
});
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
EntityUtils.GetPosAsync = GetPosAsync;
|
|
839
955
|
/**
|
|
840
956
|
* Returns entity and any associated parent/sibling entities as a flat array.
|
|
841
957
|
* @param entity
|
|
@@ -3029,7 +3145,7 @@ var RelationRenderEngine;
|
|
|
3029
3145
|
i = 0;
|
|
3030
3146
|
_d.label = 1;
|
|
3031
3147
|
case 1:
|
|
3032
|
-
if (!(i < relations.length)) return [3 /*break*/,
|
|
3148
|
+
if (!(i < relations.length)) return [3 /*break*/, 17];
|
|
3033
3149
|
relation = relations[i];
|
|
3034
3150
|
return [4 /*yield*/, Entity$1.Get({
|
|
3035
3151
|
api: api,
|
|
@@ -3094,22 +3210,25 @@ var RelationRenderEngine;
|
|
|
3094
3210
|
_d.label = 14;
|
|
3095
3211
|
case 14:
|
|
3096
3212
|
style = _c;
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3213
|
+
return [4 /*yield*/, Parabola.Render({
|
|
3214
|
+
dataEntity: dataEntity,
|
|
3215
|
+
fromEntity: fromEntity,
|
|
3216
|
+
relation: relation,
|
|
3217
|
+
style: style,
|
|
3218
|
+
toEntity: toEntity,
|
|
3219
|
+
viewer: viewer,
|
|
3220
|
+
visualRegister: visualRegister,
|
|
3221
|
+
apiGetter: apiGetter
|
|
3222
|
+
})];
|
|
3223
|
+
case 15:
|
|
3224
|
+
cEntity = _d.sent();
|
|
3106
3225
|
cEntity._renderGroup = GetRenderGroupId(relation);
|
|
3107
3226
|
rendered[GetRenderGroupId(relation)] = cEntity;
|
|
3108
|
-
_d.label =
|
|
3109
|
-
case
|
|
3227
|
+
_d.label = 16;
|
|
3228
|
+
case 16:
|
|
3110
3229
|
i++;
|
|
3111
3230
|
return [3 /*break*/, 1];
|
|
3112
|
-
case
|
|
3231
|
+
case 17: return [2 /*return*/, rendered];
|
|
3113
3232
|
}
|
|
3114
3233
|
});
|
|
3115
3234
|
});
|
|
@@ -3119,74 +3238,101 @@ var RelationRenderEngine;
|
|
|
3119
3238
|
(function (Parabola) {
|
|
3120
3239
|
function Render(params) {
|
|
3121
3240
|
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
|
-
|
|
3241
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3242
|
+
var style, entity, bColor, cColor, width, duration, hDistanceRatio, fromPos, toPos, updatingPosses, updatePosses, parabola, cEntities, cEntity, i, sibling, updateInterval;
|
|
3243
|
+
var _this = this;
|
|
3244
|
+
return __generator(this, function (_b) {
|
|
3245
|
+
style = (_a = params.style) === null || _a === void 0 ? void 0 : _a.Settings;
|
|
3246
|
+
entity = params.dataEntity;
|
|
3247
|
+
bColor = (style === null || style === void 0 ? void 0 : style.lineColor) ? Calculator.GetColor(style === null || style === void 0 ? void 0 : style.lineColor, entity, []) : null;
|
|
3248
|
+
cColor = bColor ? colorToCColor$1(bColor) : Color.WHITE;
|
|
3249
|
+
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);
|
|
3250
|
+
if (width < 1) {
|
|
3251
|
+
width = 1;
|
|
3252
|
+
}
|
|
3253
|
+
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);
|
|
3254
|
+
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);
|
|
3255
|
+
fromPos = null;
|
|
3256
|
+
toPos = null;
|
|
3257
|
+
updatingPosses = false;
|
|
3258
|
+
updatePosses = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3259
|
+
var e_1;
|
|
3260
|
+
return __generator(this, function (_a) {
|
|
3261
|
+
switch (_a.label) {
|
|
3262
|
+
case 0:
|
|
3263
|
+
if (updatingPosses) {
|
|
3264
|
+
return [2 /*return*/];
|
|
3265
|
+
}
|
|
3266
|
+
updatingPosses = true;
|
|
3267
|
+
_a.label = 1;
|
|
3268
|
+
case 1:
|
|
3269
|
+
_a.trys.push([1, 4, , 5]);
|
|
3270
|
+
return [4 /*yield*/, EntityUtils.GetPosAsync({
|
|
3271
|
+
// Not passing it so it requests entity with expanded tileset information instead.
|
|
3272
|
+
//entity: params.fromEntity,
|
|
3273
|
+
viewer: params.viewer,
|
|
3274
|
+
visualRegister: params.visualRegister,
|
|
3275
|
+
returnHeightRef: HeightReference.NONE,
|
|
3276
|
+
recordHeightRef: HeightReference.CLAMP_TO_GROUND,
|
|
3277
|
+
api: params.apiGetter.getApi(),
|
|
3278
|
+
entityId: params.fromEntity.Bruce.ID
|
|
3279
|
+
})];
|
|
3280
|
+
case 2:
|
|
3281
|
+
fromPos = _a.sent();
|
|
3282
|
+
return [4 /*yield*/, EntityUtils.GetPosAsync({
|
|
3283
|
+
// Not passing it so it requests entity with expanded tileset information instead.
|
|
3284
|
+
//entity: params.toEntity,
|
|
3285
|
+
viewer: params.viewer,
|
|
3286
|
+
visualRegister: params.visualRegister,
|
|
3287
|
+
returnHeightRef: HeightReference.NONE,
|
|
3288
|
+
recordHeightRef: HeightReference.CLAMP_TO_GROUND,
|
|
3289
|
+
api: params.apiGetter.getApi(),
|
|
3290
|
+
entityId: params.toEntity.Bruce.ID
|
|
3291
|
+
})];
|
|
3292
|
+
case 3:
|
|
3293
|
+
toPos = _a.sent();
|
|
3294
|
+
return [3 /*break*/, 5];
|
|
3295
|
+
case 4:
|
|
3296
|
+
e_1 = _a.sent();
|
|
3297
|
+
console.error(e_1);
|
|
3298
|
+
return [3 /*break*/, 5];
|
|
3299
|
+
case 5:
|
|
3300
|
+
updatingPosses = false;
|
|
3301
|
+
return [2 /*return*/];
|
|
3302
|
+
}
|
|
3303
|
+
});
|
|
3304
|
+
}); };
|
|
3305
|
+
updatePosses();
|
|
3306
|
+
parabola = new CesiumParabola({
|
|
3150
3307
|
viewer: params.viewer,
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3308
|
+
pos1: function () { return fromPos; },
|
|
3309
|
+
pos2: function () { return toPos; },
|
|
3310
|
+
color: cColor.toCssColorString(),
|
|
3311
|
+
width: width,
|
|
3312
|
+
duration: duration,
|
|
3313
|
+
heightDistanceRatio: hDistanceRatio
|
|
3154
3314
|
});
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3315
|
+
cEntities = parabola.Animate();
|
|
3316
|
+
cEntity = cEntities.parabola;
|
|
3317
|
+
cEntity._siblingGraphics = [];
|
|
3318
|
+
for (i = 0; i < cEntities.siblings.length; i++) {
|
|
3319
|
+
sibling = cEntities.siblings[i];
|
|
3320
|
+
cEntity._siblingGraphics.push(sibling);
|
|
3321
|
+
}
|
|
3322
|
+
updateInterval = setInterval(function () {
|
|
3323
|
+
var _a;
|
|
3324
|
+
if (!((_a = params.viewer) === null || _a === void 0 ? void 0 : _a.scene) ||
|
|
3325
|
+
params.viewer.isDestroyed() ||
|
|
3326
|
+
!params.viewer.entities.contains(cEntity)) {
|
|
3327
|
+
clearInterval(updateInterval);
|
|
3328
|
+
parabola.Dispose();
|
|
3329
|
+
return;
|
|
3330
|
+
}
|
|
3331
|
+
updatePosses();
|
|
3332
|
+
}, 1000);
|
|
3333
|
+
return [2 /*return*/, cEntity];
|
|
3334
|
+
});
|
|
3170
3335
|
});
|
|
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
3336
|
}
|
|
3191
3337
|
Parabola.Render = Render;
|
|
3192
3338
|
})(Parabola = RelationRenderEngine.Parabola || (RelationRenderEngine.Parabola = {}));
|