Skip to content

Commit

Permalink
Fix zoom to time dynamic point cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
ggetz committed Jul 3, 2023
1 parent 1637861 commit 9ceb960
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions packages/widgets/Source/Viewer/Viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2240,13 +2240,7 @@ function updateZoomTarget(viewer) {
const camera = scene.camera;
const zoomOptions = defaultValue(viewer._zoomOptions, {});
let options;

if (
target instanceof Cesium3DTileset ||
target instanceof VoxelPrimitive ||
target instanceof TimeDynamicPointCloud
) {
const boundingSphere = target.boundingSphere;
function zoomToBoundingSphere(boundingSphere) {
// If offset was originally undefined then give it base value instead of empty object
if (!defined(zoomOptions.offset)) {
zoomOptions.offset = new HeadingPitchRange(
Expand Down Expand Up @@ -2281,6 +2275,27 @@ function updateZoomTarget(viewer) {
clearZoom(viewer);
}

if (target instanceof TimeDynamicPointCloud) {
if (defined(target.boundingSphere)) {
zoomToBoundingSphere(target.boundingSphere);
return;
}

// Otherwise, the first "frame" needs to have been rendered
const removeEventListener = target.frameChanged.addEventListener(function (
timeDynamicPointCloud
) {
zoomToBoundingSphere(timeDynamicPointCloud.boundingSphere);
removeEventListener();
});
return;
}

if (target instanceof Cesium3DTileset || target instanceof VoxelPrimitive) {
zoomToBoundingSphere(target.boundingSphere);
return;
}

// If zoomTarget was an ImageryLayer
if (target instanceof Cartographic) {
options = {
Expand Down Expand Up @@ -2329,7 +2344,7 @@ function updateZoomTarget(viewer) {
return;
}

//Stop tracking the current entity.
// Stop tracking the current entity.
viewer.trackedEntity = undefined;

const boundingSphere = BoundingSphere.fromBoundingSpheres(boundingSpheres);
Expand Down

0 comments on commit 9ceb960

Please sign in to comment.