minorua / Qgis2threejs

3D map visualization and web export plugin for QGIS
http://minorua.github.io/Qgis2threejs/docs/
495 stars 91 forks source link

Setting camera via Python seems to be broken #256

Closed kannes closed 2 years ago

kannes commented 2 years ago

Following https://qgis2threejs.readthedocs.io/en/docs/ExportProgrammaticallyUsingPython.html I set up a scene and saved it as image.

Then I changed the CAMERA dictionary to

CAMERA = {"position": {"x": 123, "y": 234, "z": 345},
          "target": {"x": 0, "y": 0, "z": 0}}

and ran the script again. The resulting image is the same. The camera is not positioned somewhere else.

I also edit the target:

CAMERA = {"position": {"x": 0, "y": 0, "z": 0},
          "target": {"x": 123, "y": 234, "z": 345}}

and ran the script again. The resulting image is the same. The camera is not pointing somewhere else.

Trying to find the issue I added two prints to https://github.com/minorua/Qgis2threejs/blob/d3edab611e667390164c99248208fb58623fd030/q3dview.py#L227, callling self.cameraState(). One at the beginning of the function, one at the end. They both print the same camera parameters:

{'lookAt': {'x': 0.0, 'y': 0.0, 'z': 0.0}, 'pos': {'x': 0.0, 'y': -99.99999999999994, 'z': 99.99999999999997}}
{'lookAt': {'x': 0.0, 'y': 0.0, 'z': 0.0}, 'pos': {'x': 0.0, 'y': -99.99999999999994, 'z': 99.99999999999997}}

So I assume the setCameraState function either in Python or JS is broken.

kannes commented 2 years ago

Sweet, thank you!

minorua commented 2 years ago

Thanks!