Limit User Camera Movement

Hi,

I am currently working on a project, where the user should not be able to move the camera too far from the original starting point.
i read the following post:

In the post, the solution stated is:
you can set the maximumZoomFactor to clamp the camera position so that the user can’t zoom too far from the country of interest.
This does not solve the problem at hand, it just makes it more time consuming to move the camera. I want to be able to set boundries in which the camera is able to move. Is this possible?

Thanks in advance,
Alex

bump

Hi,

This is a running feature request in CesiumJS - Camera boundry · Issue #4802 · CesiumGS/cesium · GitHub. I’ll add this request to that thread.

It’s possible with the existing camera API now, but will require implementing your own boundary behavior.

I managed to get a working JS Class for limiting cesium camera to a bbox (minx,maxy,miny,maxy,maxz) or to a distance from an entity (position). Contact me if you’re interested.

I am very interested by your solution Romain.

Romain could you host your code for me to see somewhere ?

I can’t post the code publicly as It is used by one of my client, paying for it.
Some hints if you want to do it yourself: use viewer.scene.postRender event to test camera position and apply effect.

If you are interested by the whole thing, ready to use, you can contact me to purchase the module.

I’m working on releasing a final version.

You can sponsor me on github: Sponsor @romain974 on GitHub Sponsors · GitHub

My target is 200$ to push the code open source.

Trying to put a demo soon online

See the demo here: https://vimeo.com/1033903810?share=copy#t=0

If you want to help me release this open source: Sponsor @romain974 on GitHub Sponsors · GitHub

Thanks @romain97437 for sharing your work.

We do not pay or sponsor code contributions into Cesium’s open source software. While we strongly believe that every contributors’ time and effort are valuable, we want to facilitate a community of shared value and growth, where the software helps us create value for everyone together. In that spirit, we encourage you to open a pull request as it would help the Cesium community.

If you are interested, we have other programs like the Cesium Certified Developer and Ecosystem Grants which facilitate developer advancement that you can to apply to.

Please let us know if you have any questions.

Hi,

You can find the source code in my open-source repository here: https://github.com/romain974/cesiumCameraLimiter.

Feel free to let me know if you encounter any bugs or have suggestions for improvements.

If you find the project useful, I’d greatly appreciate it if you could support it through my GitHub Sponsors page. Your contributions help me continue improving the project.

Best regards,