SFM cameras in cesium


Im trying to implement sfm cameras in cesium viewer like here which is implemented in potree (https://github.com/hokiespurs/potree-sfm). So created a plane and added image as texture. But got issues with rotations, orientations of sfm cameras. Could anyone suggest a solution.

Thank you.

Hey, that looks super cool! It would be neat to see that in CesiumJS. Are you developing this as open source?

You might look at that project to see how they compute the camera positions and orientations (or is this information already known to?) After that, you should be able to position and orient a plane either by creating it by defining a normal like in these examples:

Or by passing an orientation to the entity, which you can use this headingPitchRoll helper to compute. Let me know if this helps! If you’re stuck, feel free to post what you’ve got so far, maybe even a Sandcastle example you can share so I can run the code and see what’s going on.

Best of luck!


I got positions and orientations (roll, pitch ,yaw) from pix4d. And trying to do the same as you suggested by creating a plane as an entity and applying orientation. Plane is positioning properly but the orientation is different from what it should be.

If you can create a Sandcastle example (https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/) and share it (click “Share” in the top and paste the link here) I’d love to take a look and see if I can help.


Here is the example

I got positions and roll,pitch,yaw from pix4d. And after applying rotation in potree, I got correct results.
But if I apply same rotation in cesium, it is giving some random directions. The values I'm using in the above example are related to a circular flight viewing a building in middle.

Thanks for providing a Sandcastle! Initially I thought the issue might be an incorrect reference frame but that doesn’t seem to be a problem (you can verify this by removing the orientation, all the planes face the same way, and if you set them all to rotate 90 degrees, they all correctly rotate, so there’s nothing wrong there).

Can you post a screenshot of what it’s supposed to look like in Potree or Pix4d? Are they all just supposed to face away from the center?

I would make sure that the planes look right when no orientation is applied. So for example that the plane is supposed to be the XY plane:

plane : new Cesium.Plane(Cesium.Cartesian3.UNIT_Z, 0.0),


as opposed to the YZ plane:

plane : new Cesium.Plane(Cesium.Cartesian3.UNIT_X, 0.0),


When I change it to the above it looks a bit more correct but I have no way of knowing without seeing the original reference.


Thanks for the reply and sorry for delayed response. PFA to know how they should look like.

Thank you

I think it really is just a matter of a different coordinate system that pix4d uses. I was able to get the orientations below by just negating the Rx, Ry, Rz and using Cesium.Cartesian.UNIT_Y for the plane.

I would just construct some debug planes in pix4d that are oriented along each axis, and see which configuration of offset/plane in Cesium is the correct orientation, and that should then work for any input from Pix4d.