@@ -2240,13 +2240,7 @@ function updateZoomTarget(viewer) {
2240
2240
const camera = scene . camera ;
2241
2241
const zoomOptions = defaultValue ( viewer . _zoomOptions , { } ) ;
2242
2242
let options ;
2243
-
2244
- if (
2245
- target instanceof Cesium3DTileset ||
2246
- target instanceof VoxelPrimitive ||
2247
- target instanceof TimeDynamicPointCloud
2248
- ) {
2249
- const boundingSphere = target . boundingSphere ;
2243
+ function zoomToBoundingSphere ( boundingSphere ) {
2250
2244
// If offset was originally undefined then give it base value instead of empty object
2251
2245
if ( ! defined ( zoomOptions . offset ) ) {
2252
2246
zoomOptions . offset = new HeadingPitchRange (
@@ -2281,6 +2275,27 @@ function updateZoomTarget(viewer) {
2281
2275
clearZoom ( viewer ) ;
2282
2276
}
2283
2277
2278
+ if ( target instanceof TimeDynamicPointCloud ) {
2279
+ if ( defined ( target . boundingSphere ) ) {
2280
+ zoomToBoundingSphere ( target . boundingSphere ) ;
2281
+ return ;
2282
+ }
2283
+
2284
+ // Otherwise, the first "frame" needs to have been rendered
2285
+ const removeEventListener = target . frameChanged . addEventListener ( function (
2286
+ timeDynamicPointCloud
2287
+ ) {
2288
+ zoomToBoundingSphere ( timeDynamicPointCloud . boundingSphere ) ;
2289
+ removeEventListener ( ) ;
2290
+ } ) ;
2291
+ return ;
2292
+ }
2293
+
2294
+ if ( target instanceof Cesium3DTileset || target instanceof VoxelPrimitive ) {
2295
+ zoomToBoundingSphere ( target . boundingSphere ) ;
2296
+ return ;
2297
+ }
2298
+
2284
2299
// If zoomTarget was an ImageryLayer
2285
2300
if ( target instanceof Cartographic ) {
2286
2301
options = {
@@ -2329,7 +2344,7 @@ function updateZoomTarget(viewer) {
2329
2344
return ;
2330
2345
}
2331
2346
2332
- //Stop tracking the current entity.
2347
+ // Stop tracking the current entity.
2333
2348
viewer . trackedEntity = undefined ;
2334
2349
2335
2350
const boundingSphere = BoundingSphere . fromBoundingSpheres ( boundingSpheres ) ;
0 commit comments