I want to modify the Heading/Pitch/Roll of a Cesium3DTileset in real time once its loaded. The functionality I want is pretty much identical to what the Cesium Ion’s asset editor offers.
My problem is that whenever I change the tileset rotation using the Cesium3DTileset.modelMatrix it drastically changes the tileset position sending it somewhere way above the Earth.
I am fairly new to working with CesiumJS and graphics so my understanding is very limited when it comes to the related math. I would appreciate it someone can point me in the right direction or show how this can be implemented.
The reason for the observed behavior is explained in 3DTileset rotation - #2 by Marco13 , including a Sandcastle showing how to solve this. That approach, applied to your Sandcastle, is shown here:
Note that some details here depend on where and how “the location” of the tileset is represented. The solution here assumes that it is represented with the transform of the root tile.
Hey Marco,
Thank you for your insightful answer, it was really helpful!
I have one more question, How do I obtain a tileset’s original HeadingPitchRoll? I want to preserve the original HeadingPitchRoll just in case it needs to be reverted back.
I have to emphasize: The approach that is shown here (or in that linked thread) may not work for some tilesets!
The position and orientation of the geometry data can be represented in different ways. There might be tilesets where the transform is not stored in the root tile, but … somewhere else. (In fact, it is even difficult to determine where and how the position and orientation are represented…)
That being said, coming back to your question:
How do I obtain a tileset’s original HeadingPitchRoll?
The position and orientation of a tileset is not stored as a HeadingPitchRoll object. From a user perspective, you can see that in the sandcastle. It “does not matter” what the user selects in the Heading/Pitch/Roll sliders: When the sliders are all set back to 0, then the tileset will have its original orientation again.
In the sandcastle, you can see that it stores the initialRootTransform (and resets the root transform to be the identity matrix). And one could consider this initialRootTransform as the “original orientation”, in some way. But again: This is only one way of representing the orientation. You might have to very precisely define your goal in order to find a robust solution that works in as many cases as possible.