ebeaufay / threedtiles

3DTiles viewer for three.js
MIT License
265 stars 32 forks source link

How can I bring the 3D Tiles inside the frustum? #26

Open alexaac opened 2 months ago

alexaac commented 2 months ago

First of all, thanks for sharing this helpful project with us. I'm hoping you can offer some clarity on this issue.

I'm trying to visualize 3D tiles using 'loadOutsideView: false' when the model is not near the origin.

I use OGC3DTile to load the data with 'centerModel: true', and the position of the model is '{ x: 0.0012816467933589593, y: -6377878.112330666, z: -0.00019524665549397469 }'. In order to bring the model into view I've either set the model position to 0, or made the camera and controls look at the initial model position. The tiles group seems to be in the frustum if I use this check: if (!frustum.containsPoint(ogc3DTile.position)) { console.log("Tiles Out of view"); } else { console.log("Tiles In view"); } But the model is not visible unless I use 'loadOutsideView: true'.

Screenshot from 2024-07-02 12-57-18 Screenshot from 2024-07-02 12-56-59

I've tried removing the 'transform' indications from the tileset.json, and it works the same.

Screenshot from 2024-07-02 13-04-34

Thanks

ebeaufay commented 2 months ago

Hi @alexaac ,

When you specify centerModel: true, it should bring the model's center to 0,0,0 so if the camera points to 0,0,0, the model should be in view and you shouldn't need to compensate for the tileset.json transforms manually.

However, I've changed this part of the code recently and haven't tested on "region" bounding volume tilesets. Probably, the code fails to apply one transform or the other on region bounding volumes.

Can you share a tileset with region bounding volume by any chance? I'd be glad to fix it.

alexaac commented 2 months ago

Hi @alexaac ,

When you specify centerModel: true, it should bring the model's center to 0,0,0 so if the camera points to 0,0,0, the model should be in view and you shouldn't need to compensate for the tileset.json transforms manually.

However, I've changed this part of the code recently and haven't tested on "region" bounding volume tilesets. Probably, the code fails to apply one transform or the other on region bounding volumes.

Can you share a tileset with region bounding volume by any chance? I'd be glad to fix it.

Sure. I'll prepare some sample data and send it to you. Thanks

alexaac commented 2 months ago

Hi @alexaac ,

When you specify centerModel: true, it should bring the model's center to 0,0,0 so if the camera points to 0,0,0, the model should be in view and you shouldn't need to compensate for the tileset.json transforms manually.

However, I've changed this part of the code recently and haven't tested on "region" bounding volume tilesets. Probably, the code fails to apply one transform or the other on region bounding volumes.

Can you share a tileset with region bounding volume by any chance? I'd be glad to fix it.

Here is the tileset: https://www.dropbox.com/scl/fi/dnpu126aozz6dghaea6w0/rotest.zip?rlkey=jqbf849porxjb7mz1r0lb9pgt&st=ukie5tzk&dl=0

ebeaufay commented 2 weeks ago

The latest version should fix the issue, tell me if you get the chance to test it out

alexaac commented 1 week ago

I'm still having this issue using the latest version, but it is most probably related to the data or some other setting. Here's a quick test using the tileset above: https://codepen.io/chrislx/pen/ExBRNMG?editors=1111

ebeaufay commented 1 week ago

Hi again,

I can see the tiles in the example: https://codepen.io/chrislx/pen/ExBRNMG?editors=1111 image

The loading is very slow. looking at the tiles, I see there's no actual LODing and the viewer is downloading over 2 gigabyte of data.

If you have access to the original mesh data, you can probably do a pre-processing pass to simplify geometry "losslessly" to maybe 2-3% of the size. There's way more geometry than necessary for the mesh. image

In case you're interested, I have a 3DTiles converter that can produce higher quality tiles with LODs. it's a commercial product but if you need this for a one-off, I'm open to converting it for you.

alexaac commented 1 week ago

Thanks for the answer. Can you see them when setting loadOutsideView to 'false'?

I don't need them converted for now, because I'm just testing, thank you.

Screenshot from 2024-08-29 16-19-42

.

ebeaufay commented 1 week ago

I guess not and I'll look into why, but for this tileset, it won't make any difference. The mesh is just split into tiles with no LOD. The system will download everything anyway.

When you have "loadOutsideView" true, it won't render tiles outside the frustum. It avoids refining the tree to higher LODs.

However, the system will always download the first LOD with data, which in this case is everything.

There is no point in using 3dtiles like this, it's counter-productive. If you want to get a feel of what 3dtiles can do, you need to get your hands on a proper tileset. There is no way to get anything good or even useable with this tileset I'm afraid. It's not a good test

alexaac commented 1 week ago

I understand. Alright, I will test other data. Thanks for the clarifications.