Oslandia / py3dtiles

:warning: Project migrated to : https://gitlab.com/py3dtiles/py3dtiles :warning:
https://py3dtiles.org
Other
213 stars 77 forks source link

Boxes tilted over x-axes #44

Closed tomvantilburg closed 4 years ago

tomvantilburg commented 5 years ago

I noticed that the bounding boxes created by py3dtiles are showing up in Cesium (debugShowBoundingVolume: true) as if they are tilted over the x-axis (One might also assume that it is just the earth surface that is tilted and the boxes perfectly aligned to the cartesian grid)

image (North is to the right of the image, latitude if roughly 51.84 degrees)

Here is a snippet of the tileset.json created by py3dtiles:

{"asset": {"version": "1.0", "gltfUpAxis": "Z"}, "geometricError": 500, "root": {"boundingVolume": {"box": [0.0, 0.0, 0.0, 1736.569, 0, 0, 0, 3140.645, 0, 0, 0, 1281.764]}, "geometricError": 500, "children": [...]
...
"refine": "add", "content": {"url": "tiles/1580.b3dm"}}], "refine": "add", "transform": [1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 3927692.935, 403020.138, 4992459.055, 1.0]}}

I am not sure how this is caused or what the consequences are. I am not used with working with the box as a boundingvolume and always used region up till now so it may even be normal behaviour or have nothing to do with the way py3dtiles works. I am seeing however unexpected disappearance of some tiles when I rotate the view around the Z-axis (perpend. to earth surface) that may have to do with how the boundingvolumes are defined.

Questions are: 1) Is this normal or to be expected behaviour of a box as boundingVolume? 2) Could it explain the unexpected disappearance from rendering of boxes when rotated to certain angles?

If needed I can provide a sample dataset and viewer.

Jeremy-Gaillard commented 5 years ago

A bit of context first: py3dtiles was originally designed to hanlde objects in a projected space (typically LCCs), where the region type of bounding volumes can't be used. Instead, we used boxes, which were well suited for this use case. The method used in py3dtiles to generate the tileset still works with globe coordinates, but is sub-optimal (we expect geometries to have the Z axis as their up axis), resulting in these weird bounding boxes.

Regarding the disappearance of tiles, the use of boxes instead of regions should not have any significant impact. I think the disappearance problem might come from the computing of the screen space error: depending on the angle you view the bounding box (and how much space the box takes on your screen), the SSE will vary and can cause some tiles not to be refined (and thus, unload their children tiles). Having these weirdly-shaped boxes can worsen this phenomenon. To test if this is the problem you're encountering, you can change the SSE refinement threshold of Cesium and see if the disappearing tiles reappear.

The proper way of fixing this issue would be to implement a better way of building tilesets for geometries on a globe. Unfortunately, I don't have the time to work on these types of tasks at the moment. A quick fix to your problem would be to find the transform that rotates your data set in a Z-up coordinate system, apply it to your geometries, generate the tileset as usual, and then apply the inverse transform to the root tile of the tileset.

HuyQuoc commented 5 years ago

Hi Jeremy,

I got this error when i tried to convert a big LAS file (1GB). Can u explain for me about this and how can i fix it or is this affected to converted 3dtiles ?

/DockerShared/py3dtiles/venv/lib/python3.5/site-packages/py3dtiles-1.1.0-py3.5.egg/py3dtiles/convert.py:336: RuntimeWarning: invalid value encountered in subtract x_axis = br - bl /DockerShared/py3dtiles/venv/lib/python3.5/site-packages/py3dtiles-1.1.0-py3.5.egg/py3dtiles/convert.py:338: RuntimeWarning: invalid value encountered in subtract bl = bl - avg_min /DockerShared/py3dtiles/venv/lib/python3.5/site-packages/py3dtiles-1.1.0-py3.5.egg/py3dtiles/convert.py:339: RuntimeWarning: invalid value encountered in subtract tr = tr - avg_min /DockerShared/py3dtiles/venv/lib/python3.5/site-packages/py3dtiles-1.1.0-py3.5.egg/py3dtiles/convert.py:83: RuntimeWarning: invalid value encountered in true_divide v0 = z1 / np.linalg.norm(z1) /DockerShared/py3dtiles/venv/lib/python3.5/site-packages/py3dtiles-1.1.0-py3.5.egg/py3dtiles/convert.py:354: RuntimeWarning: invalid value encountered in minimum np.minimum(bl, tr), /DockerShared/py3dtiles/venv/lib/python3.5/site-packages/py3dtiles-1.1.0-py3.5.egg/py3dtiles/convert.py:355: RuntimeWarning: invalid value encountered in maximum np.maximum(bl, tr) 0.0 % in 0 sec [est. time left: 14151 sec]/DockerShared/py3dtiles/venv/lib/python3.5/site-packages/py3dtiles-1.1.0-py3.5.egg/py3dtiles/points/node.py:132: RuntimeWarning: invalid value encountered in greater_equal indices = xyz_to_child_index(pending_xyz_arr, self.aabb_center) 1.19 % in 2 sec [est. time left: 169 sec]/DockerShared/py3dtiles/venv/lib/python3.5/site-packages/py3dtiles-1.1.0-py3.5.egg/py3dtiles/points/node.py:132: RuntimeWarning: invalid value encountered in greater_equal indices = xyz_to_child_index(pending_xyz_arr, self.aabb_center) 7.85 % in 18 sec [est. time left: 211 sec]/DockerShared/py3dtiles/venv/lib/python3.5/site-packages/py3dtiles-1.1.0-py3.5.egg/py3dtiles/points/task/las_reader.py:118: RuntimeWarning: invalid value encountered in add x = (x + offset_scale[0][0]) offset_scale[1][0] /DockerShared/py3dtiles/venv/lib/python3.5/site-packages/py3dtiles-1.1.0-py3.5.egg/py3dtiles/points/task/las_reader.py:119: RuntimeWarning: invalid value encountered in add y = (y + offset_scale[0][1]) offset_scale[1][1] 17.78 % in 41 sec [est. time left: 192 sec]/DockerShared/py3dtiles/venv/lib/python3.5/site-packages/py3dtiles-1.1.0-py3.5.egg/py3dtiles/points/task/las_reader.py:118: RuntimeWarning: invalid value encountered in add x = (x + offset_scale[0][0]) offset_scale[1][0] /DockerShared/py3dtiles/venv/lib/python3.5/site-packages/py3dtiles-1.1.0-py3.5.egg/py3dtiles/points/task/las_reader.py:119: RuntimeWarning: invalid value encountered in add y = (y + offset_scale[0][1]) offset_scale[1][1]

Thanks. Regards.

Jeremy-Gaillard commented 5 years ago

Your error is not related to this issue, please create a new issue to describe your problem.

HuyQuoc commented 5 years ago

Your error is not related to this issue, please create a new issue to describe your problem.

Ok. I created new issue. thanks.

delhomer commented 4 years ago

https://gitlab.com/Oslandia/py3dtiles/-/issues/44