bruce-cesium 3.1.5 → 3.1.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 +66 -42
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +65 -41
- package/dist/bruce-cesium.umd.js.map +1 -1
- package/dist/lib/bruce-cesium.js +1 -1
- package/dist/lib/rendering/visual-register-culler.js +81 -49
- package/dist/lib/rendering/visual-register-culler.js.map +1 -1
- package/dist/types/bruce-cesium.d.ts +1 -1
- package/package.json +1 -1
package/dist/bruce-cesium.es5.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Cartes, ProjectViewTile, Carto, Entity as Entity$1, Geometry, Tileset, MathUtils, LRUCache, DelayQueue, ZoomControl, Style, EntityTag, Calculator, EntityLod, EntityType, ClientFile, ObjectUtils, Bounds, EntityRelationType, BruceEvent, EntityCoords, Api, EntitySource, MenuItem, EntityRelation, ENVIRONMENT, AbstractApi, ProjectViewBookmark, EntityAttachment, EntityAttachmentType, EntityAttribute, ProjectView, ProjectViewLegacyTile, ProgramKey, Camera } from 'bruce-models';
|
|
2
2
|
import * as Cesium from 'cesium';
|
|
3
|
-
import { Cartographic, Color, HeightReference,
|
|
3
|
+
import { Cartographic, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, DistanceDisplayCondition, NearFarScalar, Entity, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, Model, JulianDate, Primitive, Cesium3DTileFeature, SceneMode, Cesium3DTileColorBlendMode, HeadingPitchRange, createOsmBuildings, Cesium3DTileStyle, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, createWorldTerrain, EllipsoidTerrainProvider, CesiumTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, Cesium3DTileset, Matrix4, Matrix3, IonResource, Ion, PolygonPipeline, CesiumInspector, ColorMaterialProperty, BoundingSphere, GeometryInstance, ScreenSpaceEventHandler, ScreenSpaceEventType, Intersect } from 'cesium';
|
|
4
4
|
|
|
5
5
|
/*! *****************************************************************************
|
|
6
6
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2101,7 +2101,19 @@ var TERRAIN_HEIGHT_TOLERANCE = 400;
|
|
|
2101
2101
|
// Tolerance to use when number of entities is lower than x in the scene.
|
|
2102
2102
|
var TERRAIN_HEIGHT_TOLERANCE_LOW_COUNT = 30;
|
|
2103
2103
|
var TERRAIN_HEIGHT_TOLERANCE_LOW_ENTITY_THRESHOLD = 100;
|
|
2104
|
+
/**
|
|
2105
|
+
* Returns the terrain height for a given position.
|
|
2106
|
+
* This will not sample most-detailed and instead the current state of the terrain.
|
|
2107
|
+
* TODO: If something is VERY far from the camera, we should just return 0.
|
|
2108
|
+
* @param viewer
|
|
2109
|
+
* @param pos3d
|
|
2110
|
+
* @returns
|
|
2111
|
+
*/
|
|
2104
2112
|
var getTerrainOffset = function (viewer, pos3d) {
|
|
2113
|
+
var _a;
|
|
2114
|
+
if (!((_a = viewer.terrainProvider) === null || _a === void 0 ? void 0 : _a.ready)) {
|
|
2115
|
+
return null;
|
|
2116
|
+
}
|
|
2105
2117
|
var terrain = ViewUtils.GatherTerrainTile({
|
|
2106
2118
|
viewer: viewer
|
|
2107
2119
|
}).terrain;
|
|
@@ -2113,8 +2125,8 @@ var getTerrainOffset = function (viewer, pos3d) {
|
|
|
2113
2125
|
var keys = Array.from(_terrainCache.Entries());
|
|
2114
2126
|
var tolerance = viewer.entities.values.length > TERRAIN_HEIGHT_TOLERANCE_LOW_ENTITY_THRESHOLD ? TERRAIN_HEIGHT_TOLERANCE : TERRAIN_HEIGHT_TOLERANCE_LOW_COUNT;
|
|
2115
2127
|
for (var i = 0; i < keys.length; i++) {
|
|
2116
|
-
var
|
|
2117
|
-
var
|
|
2128
|
+
var _b = keys[i], key_1 = _b[0], offset_1 = _b[1];
|
|
2129
|
+
var _c = key_1.split("_"), terrainId2 = _c[0], x = _c[1], y = _c[2], z = _c[3];
|
|
2118
2130
|
if (terrainId2 != terrainId) {
|
|
2119
2131
|
continue;
|
|
2120
2132
|
}
|
|
@@ -2170,12 +2182,6 @@ var adjustPos3d = function (viewer, heightRef, pos3d) {
|
|
|
2170
2182
|
}
|
|
2171
2183
|
return newPos3d;
|
|
2172
2184
|
};
|
|
2173
|
-
function getValue(viewer, obj) {
|
|
2174
|
-
if (obj === null || obj === void 0 ? void 0 : obj.getValue) {
|
|
2175
|
-
return obj.getValue(viewer.scene.lastRenderTime);
|
|
2176
|
-
}
|
|
2177
|
-
return obj;
|
|
2178
|
-
}
|
|
2179
2185
|
function isFlatTerrain(viewer) {
|
|
2180
2186
|
var _a;
|
|
2181
2187
|
if (!viewer) {
|
|
@@ -2185,6 +2191,12 @@ function isFlatTerrain(viewer) {
|
|
|
2185
2191
|
viewer: viewer
|
|
2186
2192
|
}).terrain) === null || _a === void 0 ? void 0 : _a.tilesetId) == ProjectViewTile.EDefaultTerrain.FlatTerrain;
|
|
2187
2193
|
}
|
|
2194
|
+
function getValue(viewer, obj) {
|
|
2195
|
+
if (obj === null || obj === void 0 ? void 0 : obj.getValue) {
|
|
2196
|
+
return obj.getValue(viewer.scene.lastRenderTime);
|
|
2197
|
+
}
|
|
2198
|
+
return obj;
|
|
2199
|
+
}
|
|
2188
2200
|
var boundingSphereCache = new LRUCache(100000);
|
|
2189
2201
|
function getPositionsFromEntity(viewer, entity) {
|
|
2190
2202
|
var positions = [];
|
|
@@ -2195,7 +2207,6 @@ function getPositionsFromEntity(viewer, entity) {
|
|
|
2195
2207
|
return null;
|
|
2196
2208
|
}
|
|
2197
2209
|
heightRef = getValue(viewer, entity.billboard.heightReference);
|
|
2198
|
-
pos3d = adjustPos3d(viewer, heightRef, pos3d);
|
|
2199
2210
|
positions.push(pos3d);
|
|
2200
2211
|
}
|
|
2201
2212
|
else if (entity.polyline) {
|
|
@@ -2213,8 +2224,7 @@ function getPositionsFromEntity(viewer, entity) {
|
|
|
2213
2224
|
}
|
|
2214
2225
|
heightRef = getValue(viewer, entity.polyline.clampToGround) == false ? HeightReference.NONE : HeightReference.CLAMP_TO_GROUND;
|
|
2215
2226
|
for (var i = 0; i < posses.length; i++) {
|
|
2216
|
-
|
|
2217
|
-
positions.push(pos3d);
|
|
2227
|
+
positions.push(posses[i]);
|
|
2218
2228
|
}
|
|
2219
2229
|
}
|
|
2220
2230
|
else if (entity.polygon) {
|
|
@@ -2233,8 +2243,7 @@ function getPositionsFromEntity(viewer, entity) {
|
|
|
2233
2243
|
}
|
|
2234
2244
|
heightRef = getValue(viewer, entity.polygon.heightReference);
|
|
2235
2245
|
for (var i = 0; i < posses.length; i++) {
|
|
2236
|
-
|
|
2237
|
-
positions.push(pos3d);
|
|
2246
|
+
positions.push(posses[i]);
|
|
2238
2247
|
}
|
|
2239
2248
|
}
|
|
2240
2249
|
else if (entity.corridor) {
|
|
@@ -2252,8 +2261,7 @@ function getPositionsFromEntity(viewer, entity) {
|
|
|
2252
2261
|
}
|
|
2253
2262
|
heightRef = getValue(viewer, entity.corridor.heightReference);
|
|
2254
2263
|
for (var i = 0; i < posses.length; i++) {
|
|
2255
|
-
|
|
2256
|
-
positions.push(pos3d);
|
|
2264
|
+
positions.push(posses[i]);
|
|
2257
2265
|
}
|
|
2258
2266
|
}
|
|
2259
2267
|
else if (entity.ellipse) {
|
|
@@ -2262,7 +2270,6 @@ function getPositionsFromEntity(viewer, entity) {
|
|
|
2262
2270
|
return null;
|
|
2263
2271
|
}
|
|
2264
2272
|
heightRef = getValue(viewer, entity.ellipse.heightReference);
|
|
2265
|
-
pos3d = adjustPos3d(viewer, heightRef, pos3d);
|
|
2266
2273
|
positions.push(pos3d);
|
|
2267
2274
|
}
|
|
2268
2275
|
else if (entity.model) {
|
|
@@ -2271,7 +2278,6 @@ function getPositionsFromEntity(viewer, entity) {
|
|
|
2271
2278
|
return null;
|
|
2272
2279
|
}
|
|
2273
2280
|
heightRef = getValue(viewer, entity.model.heightReference);
|
|
2274
|
-
pos3d = adjustPos3d(viewer, heightRef, pos3d);
|
|
2275
2281
|
positions.push(pos3d);
|
|
2276
2282
|
}
|
|
2277
2283
|
else if (entity.point) {
|
|
@@ -2280,7 +2286,6 @@ function getPositionsFromEntity(viewer, entity) {
|
|
|
2280
2286
|
return null;
|
|
2281
2287
|
}
|
|
2282
2288
|
heightRef = getValue(viewer, entity.point.heightReference);
|
|
2283
|
-
pos3d = adjustPos3d(viewer, heightRef, pos3d);
|
|
2284
2289
|
positions.push(pos3d);
|
|
2285
2290
|
}
|
|
2286
2291
|
if (!(positions === null || positions === void 0 ? void 0 : positions.length)) {
|
|
@@ -2295,19 +2300,21 @@ function getPositionsFromEntity(viewer, entity) {
|
|
|
2295
2300
|
positions[i] = Cartographic.toCartesian(carto);
|
|
2296
2301
|
}
|
|
2297
2302
|
}
|
|
2298
|
-
return
|
|
2303
|
+
return {
|
|
2304
|
+
positions: positions,
|
|
2305
|
+
heightRef: heightRef
|
|
2306
|
+
};
|
|
2299
2307
|
}
|
|
2300
2308
|
function computeBoundingSphereFromPositions(positions) {
|
|
2301
2309
|
return BoundingSphere.fromPoints(positions);
|
|
2302
2310
|
}
|
|
2303
2311
|
function shouldCullEntity(viewer, cEntity) {
|
|
2304
|
-
var _a, _b;
|
|
2312
|
+
var _a, _b, _c;
|
|
2305
2313
|
var camera = viewer.scene.camera;
|
|
2306
2314
|
var boundingSphere;
|
|
2307
2315
|
var terrainId = (_b = (_a = ViewUtils.GatherTerrainTile({
|
|
2308
2316
|
viewer: viewer
|
|
2309
2317
|
}).terrain) === null || _a === void 0 ? void 0 : _a.tilesetId) !== null && _b !== void 0 ? _b : ProjectViewTile.EDefaultTerrain.FlatTerrain;
|
|
2310
|
-
var cullSphere;
|
|
2311
2318
|
var cacheKey = terrainId + cEntity.id;
|
|
2312
2319
|
var cacheData = boundingSphereCache.Get(cacheKey);
|
|
2313
2320
|
if (cacheData) {
|
|
@@ -2315,17 +2322,20 @@ function shouldCullEntity(viewer, cEntity) {
|
|
|
2315
2322
|
}
|
|
2316
2323
|
else {
|
|
2317
2324
|
var positions = getPositionsFromEntity(viewer, cEntity);
|
|
2318
|
-
if (positions) {
|
|
2319
|
-
|
|
2325
|
+
if ((_c = positions === null || positions === void 0 ? void 0 : positions.positions) === null || _c === void 0 ? void 0 : _c.length) {
|
|
2326
|
+
// Sphere calculated from entity positions.
|
|
2327
|
+
// We will evaluate the visual now to see if the sphere should be counted, for example 3D models might not be loaded yet.
|
|
2328
|
+
var sphere = computeBoundingSphereFromPositions(positions.positions);
|
|
2329
|
+
// If a 3D model is not loaded, we'll avoid caching the sphere data.
|
|
2320
2330
|
var doNotCache = false;
|
|
2321
2331
|
if (cEntity.model) {
|
|
2322
2332
|
var model = cEntity.model;
|
|
2323
2333
|
if (model._radius && !isNaN(model._radius)) {
|
|
2324
|
-
|
|
2334
|
+
sphere.radius = Math.max(model._radius, MODEL_MIN_RADIUS);
|
|
2325
2335
|
}
|
|
2326
2336
|
else {
|
|
2327
2337
|
// Unknown size. Ignoring.
|
|
2328
|
-
|
|
2338
|
+
sphere = null;
|
|
2329
2339
|
doNotCache = !model._radiusLoaded;
|
|
2330
2340
|
}
|
|
2331
2341
|
}
|
|
@@ -2342,24 +2352,28 @@ function shouldCullEntity(viewer, cEntity) {
|
|
|
2342
2352
|
}
|
|
2343
2353
|
}
|
|
2344
2354
|
if (radius && !isNaN(radius)) {
|
|
2345
|
-
|
|
2355
|
+
sphere.radius = radius;
|
|
2346
2356
|
}
|
|
2347
2357
|
}
|
|
2348
2358
|
// Check for extrusion.
|
|
2349
2359
|
else if (cEntity.polygon) {
|
|
2350
2360
|
var extrusion = getValue(viewer, cEntity.polygon.extrudedHeight);
|
|
2351
2361
|
if (extrusion && !isNaN(extrusion)) {
|
|
2352
|
-
if (!
|
|
2353
|
-
|
|
2362
|
+
if (!sphere.radius) {
|
|
2363
|
+
sphere.radius = extrusion;
|
|
2354
2364
|
}
|
|
2355
|
-
else if (extrusion >
|
|
2356
|
-
|
|
2365
|
+
else if (extrusion > sphere.radius / 2) {
|
|
2366
|
+
sphere.radius = extrusion;
|
|
2357
2367
|
}
|
|
2358
2368
|
}
|
|
2359
2369
|
}
|
|
2360
2370
|
else if (cEntity.point || cEntity.billboard) {
|
|
2361
|
-
|
|
2371
|
+
sphere.radius = Math.max(sphere.radius, POINT_MIN_RADIUS);
|
|
2362
2372
|
}
|
|
2373
|
+
boundingSphere = {
|
|
2374
|
+
heightRef: positions.heightRef,
|
|
2375
|
+
sphere: sphere
|
|
2376
|
+
};
|
|
2363
2377
|
if (!doNotCache) {
|
|
2364
2378
|
boundingSphereCache.Set(cacheKey, boundingSphere);
|
|
2365
2379
|
}
|
|
@@ -2368,18 +2382,13 @@ function shouldCullEntity(viewer, cEntity) {
|
|
|
2368
2382
|
boundingSphereCache.Set(cacheKey, -1);
|
|
2369
2383
|
}
|
|
2370
2384
|
}
|
|
2371
|
-
if (!boundingSphere || boundingSphere == -1) {
|
|
2385
|
+
if (!boundingSphere || boundingSphere == -1 || !boundingSphere.sphere) {
|
|
2372
2386
|
return false;
|
|
2373
2387
|
}
|
|
2388
|
+
var adjustedSphere = boundingSphere.sphere.clone();
|
|
2389
|
+
adjustedSphere.center = adjustPos3d(viewer, boundingSphere.heightRef, adjustedSphere.center);
|
|
2374
2390
|
var cullingVolume = camera.frustum.computeCullingVolume(camera.position, camera.direction, camera.up);
|
|
2375
|
-
var visibility = cullingVolume.computeVisibility(
|
|
2376
|
-
if (cullSphere) {
|
|
2377
|
-
cullSphere.ellipsoid.material =
|
|
2378
|
-
(visibility == Intersect.INSIDE ||
|
|
2379
|
-
visibility == Intersect.INTERSECTING) ? Color.GREEN.withAlpha(0.1) :
|
|
2380
|
-
Color.RED.withAlpha(0.1);
|
|
2381
|
-
viewer.scene.requestRender();
|
|
2382
|
-
}
|
|
2391
|
+
var visibility = cullingVolume.computeVisibility(adjustedSphere);
|
|
2383
2392
|
return visibility !== Intersect.INSIDE && visibility !== Intersect.INTERSECTING;
|
|
2384
2393
|
}
|
|
2385
2394
|
// Amount of entities to check per interval.
|
|
@@ -2445,6 +2454,8 @@ function runCullChecker(register) {
|
|
|
2445
2454
|
}
|
|
2446
2455
|
var viewer = register.Viewer;
|
|
2447
2456
|
var entityIds = register.GetEntityIds();
|
|
2457
|
+
// We'll use the terrain cache per culler cycle.
|
|
2458
|
+
_terrainCache.Clear();
|
|
2448
2459
|
checkInterval = setInterval(function () {
|
|
2449
2460
|
if (viewer.isDestroyed() || !viewer.scene) {
|
|
2450
2461
|
clearInterval(checkInterval);
|
|
@@ -2529,6 +2540,15 @@ var VisualRegisterCuller;
|
|
|
2529
2540
|
(_a = checkQueue.Call) === null || _a === void 0 ? void 0 : _a.call(checkQueue);
|
|
2530
2541
|
}
|
|
2531
2542
|
});
|
|
2543
|
+
var terrChangeTimeout = null;
|
|
2544
|
+
var terrChangeRemoval = register.Viewer.scene.terrainProviderChanged.addEventListener(function () {
|
|
2545
|
+
clearTimeout(terrChangeTimeout);
|
|
2546
|
+
terrChangeTimeout = setTimeout(function () {
|
|
2547
|
+
var _a;
|
|
2548
|
+
MarkShouldRecheck(register.Viewer);
|
|
2549
|
+
(_a = checkQueue.Call) === null || _a === void 0 ? void 0 : _a.call(checkQueue);
|
|
2550
|
+
}, 2500);
|
|
2551
|
+
});
|
|
2532
2552
|
checkQueue.Call();
|
|
2533
2553
|
return function (params) {
|
|
2534
2554
|
var uncull = (params || {}).uncull;
|
|
@@ -2538,6 +2558,10 @@ var VisualRegisterCuller;
|
|
|
2538
2558
|
moveEndRemoval = null;
|
|
2539
2559
|
updateRemoval === null || updateRemoval === void 0 ? void 0 : updateRemoval();
|
|
2540
2560
|
updateRemoval = null;
|
|
2561
|
+
terrChangeRemoval === null || terrChangeRemoval === void 0 ? void 0 : terrChangeRemoval();
|
|
2562
|
+
terrChangeRemoval = null;
|
|
2563
|
+
clearTimeout(terrChangeTimeout);
|
|
2564
|
+
terrChangeTimeout = null;
|
|
2541
2565
|
checkInterval === null || checkInterval === void 0 ? void 0 : checkInterval();
|
|
2542
2566
|
checkInterval = null;
|
|
2543
2567
|
checkWaiting = false;
|
|
@@ -18728,7 +18752,7 @@ var CesiumViewMonitor;
|
|
|
18728
18752
|
CesiumViewMonitor$$1.Monitor = Monitor;
|
|
18729
18753
|
})(CesiumViewMonitor || (CesiumViewMonitor = {}));
|
|
18730
18754
|
|
|
18731
|
-
var VERSION$1 = "3.1.
|
|
18755
|
+
var VERSION$1 = "3.1.7";
|
|
18732
18756
|
|
|
18733
18757
|
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 };
|
|
18734
18758
|
//# sourceMappingURL=bruce-cesium.es5.js.map
|