I am a Python developer and I am currently facing a difficult problem. I need to use PyQGIS to implement the latest 3D data feature introduced in QGIS version 3.34.
I have spent 7 days trying to find possible APIs, such as QgsTiledSceneLayer for loading 3D data and Qgs3DMapCanvas related to 3D canvas, which I found in the source code of the C++ version of QGIS version 3.36. QGIS version 3.34 is the latest stable version, while version 3.36 is not yet stable. However, in order to implement the function of displaying 3D data on the 3D canvas, I have to take a risk and choose the QGIS package version 3.36 to solve the problem.
Here’s an example code that I experimented with in QGIS 3.36, which allows loading 3D model data onto the canvas.
`if name ==”main“:
app = QgsApplication([],True)
address = r”D:app1python_workspacereal_workthree_mode_datamars3d-max-shihua-3dtiles-master/tileset.json”
testLayer = QgsTiledSceneLayer(uri=address,baseName=’111′,provider=’cesiumtiles’)
print(“本地三维加载是否有效%s” % (testLayer.isValid()))
sys.exit(app.exec_())`
The functionality I pursued is displayed as follows in QGIS:
I am currently looking for some advice or, even better, a complete code example of how to add 3D data to a 3D canvas. I am not good at C++ and actually dislike it quite a bit… I hope someone can help me with this. Additionally, I find the new Qgs3DMapCanvas in QGIS less user-friendly compared to the QgsMapCanvas. This is my current feeling.