*.flyTo() where show=false?

Hi there,

I believe there’s a check on any of the flyTo()/zoomTo() functions to see if the entity is showing on the map, and does nothing if show=false. Is there a way to fly to non-showing entitiy, or to pull out all the camera position/view/angles that flyTo() normally does?

I’ve currently got a wall showing a boundery of an area, and users can turn the visibility of it on and off, however they can also flyTo() that wall through interaction. But when the wall isn’t showing, the flyTo() doesn’t work.

Thoughts?

Cheers,

Alex

I can see a couple of solutions here:

  • Instead of doing flyTo(entity), store the entity’s position, and fly to that with some fixed heading/pitch/range offset.
  • Create a sphere entity that has a completely transparent material and fly to that instead, so you can visually see what the camera is flying to when you set it up
  • Extract the bounding parameters the camera would normally use to fly to the wall entity and call that directly. This isn’t exposed through the public API, but the entry point for this code is in DataSourceDisplay.js: https://github.com/CesiumGS/cesium/blob/master/Source/DataSources/DataSourceDisplay.js#L346.

Hi Omar,

Thanks for your reply.

Yeah, I tried your option 1, however flyTo() does a good job of doing all the size, bounding and camera stuff, I don’t really want to replicate all of that. I tried turning the entity on, wait, flyTo(), wait and off again, but the async /timing stuff was hard to get right.

Right now I’m turning the opacity down to 0.01, which works, but just feels like a kludge. It’s kinda like your option 2, however I do a lot of picking on the scene, and these invisible entities does create some confusion and issues.

Thanks for the reference in point 3. Do you have a reference also to where the final camera values happens? I can take any bounding area, assess its size, create a set of distance/heading/pitch parameters based on, umm, something. :slight_smile:

Cheers,

Alex

Does turning the opacity to 0 not allow you to fly there? I would expect that to work since that’s different from show = false.

If you’re able to extract the bounding sphere, there’s a camera method to fly to that: https://cesium.com/docs/cesiumjs-ref-doc/Camera.html?classFilter=camera#flyToBoundingSphere, which I think is what happens internally when you do viewer.flyTo(entity).

How the bounding sphere is computed is different for each type of entity, but digging in further, you can see the bounding sphere for wall geometry is just created directly from its vertices that are passed in: https://github.com/CesiumGS/cesium/blob/master/Source/Core/WallGeometry.js#L621.

If this is a common enough use case perhaps there’s a case to be made to expose the DataSourceDisplay.getBoundingSphere(entity) method in the public API so it just works regardless of the type of entity you’re working with.