I have a 3D building model, which contains many components such as doors, beds, and windows.
Now I read a json file to get all the components of this model and display them on the page as a tree menu. Click the door in the tree menu to set the transparency of the door in the model, thus highlighting the target component .
In addition, I also hope that the camera can focus on the component, how to achieve such a function?
Welcome to the Cesium community @zww !
What file format is your 3D building model in? What software did you use to create/export this JSON file? Can you share a sample of what this file looks like?
Hello omar, the format of the model is 3dtiles, there is a tileset.json file and the model component tree file scenetree.json, the file attachment is as followsdata.rar (3.9 MB)
I want to realize that when the tree menu is clicked, the camera automatically “flyto” the component (door, window…)
Because the position of the 3D model on the Cesium map is incorrect, I then developed a widget to adjust the position of the model and the angle of rotation，A new transform is generated and replaced with the root transform in the original tileset.json file. Then set the transparency of the corresponding component of the model through Cesium3DTileStyle and the component ID in the clicked component tree
Because only the transform in tileset.json is modified, and the sphere of the component in scenetree.json is not modified, after clicking the tree menu, camera is positioned to the position of the original model (I hope the camera can be positioned after the modification) On the corresponding components of the model (doors, windows…))
At this point I thought of two solutions
Record the changes from the original model position to the new model position, such as longitude adjustment 0.1, latitude adjustment 0.2, elevation adjustment 12, x, y, z rotation angle, when you click the tree menu, get the position of the corresponding component in the original model, and Automatically complete translation and rotation operations to obtain a new position, the new position of the camera flyto.
In this way, I only realized the restoration of the translation operation, but did not realize the rotation. Can you give me a sample Or you can look at the second solution
After the adjustment, the model can be correctly displayed on the map, and now I hope to be able to click the door or window in the tree menu to fly the camera into the components of the model.
The solution is to get the component id in the tree menu that was clicked, and use it as a query condition to traverse all the sub-components of the model until the matching id is found, thereby obtaining the position of the corresponding component and flyto.
The solution is to obtain the position of the sub-component through the model that has been displayed in the correct position.But I did not find the relevant API for this solution
Can you tell me how this was generated? Was the source model an OBJ, or FBX, or something else?
A lot of times the source format has metadata and geographic information so it might be possible to just upload the pre-tiled version to Cesium ion (https://cesium.com/ion) and it will show up in the correct place.