Skip to content

Commit 9ceb960

Browse files
committed
Fix zoom to time dynamic point cloud
1 parent 1637861 commit 9ceb960

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

packages/widgets/Source/Viewer/Viewer.js

+23-8
Original file line numberDiff line numberDiff line change
@@ -2240,13 +2240,7 @@ function updateZoomTarget(viewer) {
22402240
const camera = scene.camera;
22412241
const zoomOptions = defaultValue(viewer._zoomOptions, {});
22422242
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) {
22502244
// If offset was originally undefined then give it base value instead of empty object
22512245
if (!defined(zoomOptions.offset)) {
22522246
zoomOptions.offset = new HeadingPitchRange(
@@ -2281,6 +2275,27 @@ function updateZoomTarget(viewer) {
22812275
clearZoom(viewer);
22822276
}
22832277

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+
22842299
// If zoomTarget was an ImageryLayer
22852300
if (target instanceof Cartographic) {
22862301
options = {
@@ -2329,7 +2344,7 @@ function updateZoomTarget(viewer) {
23292344
return;
23302345
}
23312346

2332-
//Stop tracking the current entity.
2347+
// Stop tracking the current entity.
23332348
viewer.trackedEntity = undefined;
23342349

23352350
const boundingSphere = BoundingSphere.fromBoundingSpheres(boundingSpheres);

0 commit comments

Comments
 (0)