iTowns / itowns

A Three.js-based framework written in Javascript/WebGL for visualizing 3D geospatial data
http://www.itowns-project.org
Other
1.09k stars 296 forks source link

[3D Tiles] What is tileIndex ? #1039

Open jailln opened 5 years ago

jailln commented 5 years ago

Context

I'm currently working on improving 3D Tiles extension management introduced in #1022 to give the possibility to have extensions defined in multiple 3D Tiles objects (i.e. not only in batch table as it is currently the case).

To this end, I need to start refactoring the 3D Tiles Provider (which I think is planned later this year in your roadmap). I'll come up with propositions in the next days maybe as an 'in progress' PR. I still have questions about the provider and the structure resulting from the parsing of the tileset and its tiles though.

Questions

gchoqueux commented 5 years ago

Thank you for this refactoring proposal.

What is tileIndex ? From what I understand, it seems to be a list of tiles (i.e. a flattened tileset). However, the tiles still have children attributes (and hence the hierarchy between tiles is still present but not stored as originally in the tileset tree)

I don't know the code of 3DTiles yet. I still don't clearly understand tileIndex. It seems to be the structure of tiles that allows the process to perform culling, replacement and fecthing of tiles.

There is also the meshs structure of the tiles in the LayerGeometry.object3d. It must be possible to unify these two structures.

What is the purpose of the extendTileset method ?

This method is used when loading a new tile. It just adds this new tile to the tileIndex.

Otherwise, an important thing in the refactoring will be to do 3DTilesLayer and 3DTilesSource and remove 3DTileProvider and 3DTileProcessing.

jailln commented 5 years ago

Thank you for the clarifications! With these information and by having a deeper look in the code, it seems that:

Otherwise, an important thing in the refactoring will be to do 3DTilesLayer and 3DTilesSource and remove 3DTileProvider and 3DTileProcessing.

It would indeed be great to have a 3DTilesLayer and 3DTilesSource. I don’t think I will go this far but I will go in this direction. I also think the implementation should match as much as possible the spec and its classes (i.e. it might be interesting to have Tileset, Tile, BoundingVolume, etc. classes in iTowns) so it is easier for developers and users to understand the data structure in iTowns and also it facilitates maintainability. WDYT ?

image

My usecase is to switch objects visibility based on their batchID and on user inputs. To achieve that, it would be great to have one THREE.Mesh object per batch (i.e. all the geometries corresponding to batchId = 0 in one mesh, all the ones with batchId = 1 in another mesh, etc.). I think this would also be interesting for styling features based on their batch id and without having to define new shaders. WDYT ?

I’m currently trying to implement this mesh subdivision in the B3dmParser but it’s not as easy as expected… Does anyone has inputs on how to achieve this ?

More generally, how do you modify styling properties of geographic features based on their batch id ? (ping @mbredif )

gchoqueux commented 5 years ago

Thank you for your analysis of the 3Dtiles code.

iTowns internal structure and tileSet

In summary, in itowns, the data structure of 3d Tiles consists of the tileSet and the object3Ds tree. It should have only the one structure of object3Ds.

3DTilesLayer and 3DTilesSource.

On our side, we could, in parallel of your development, develop the 3DTilesLayer and 3DTilesSource.

One mesh by batchID

My usecase is to switch objects visibility based on their batchID and on user inputs. To achieve that, it would be great to have one THREE.Mesh object per batch .

Warning, in the past, we generated one mesh for each buildings (with the Wfs source and feature2Mesh). But the problem, the performance decreases strongly because the count of webGL draw calls increases. Moreover, there's not interest to have a batchId buffer, in Three.Geometry, if it isn't used in the shader. It must be possible to use THREE's chunks shaders to build a style-supporting material based on the batchId.

jailln commented 5 years ago

iTowns internal structure and tileSet

Yes, we could merge these two structures (just a precision: the data structure consists of tileIndex and the object3Ds)

3DTilesLayer and 3DTilesSource

Great :) Could you elaborate what are the roles of 3DTilesLayer and of 3DTilesSource please ? (e.g. in comparison with Provider and Processing)

My current work is here. It is still a bit messy (especially in the commits) but you can see the changes here. The main ideas are:

One mesh by batchID

Good point. You mean by using Layer.OverrideMaterial with a custom material and custom shaders based on shaders and materials of iTowns ?

gchoqueux commented 5 years ago

Great :) Could you elaborate what are the roles of 3DTilesLayer and of 3DTilesSource please ? (e.g. in comparison with Provider and Processing)

Tileset class (holding the tileIndex) a BoundingVolume class and a BatchTable class

Developing these classes is a good idea. Could you give url to link this files?

Tileset class is a leaf of tree structure?

It will be necessary to be careful because there are already objects similar to BoundingVolume: like OBB and THREE.Box3.

I changed a bit the mechanism of extensions:

it should be discussed on https://gitter.im/iTowns

OverrideMaterial with a custom material and custom shaders based on shaders and materials of iTowns ?

Yes, but there would be a little development

jailln commented 5 years ago

Thanks for the clarification. The 3D Tiles classes I mentionned are here. For now they are in a 3dTilesClasses.js file but based on your response they should be in 3DTilesLayer.

Tileset class is an implementation of the tileset from the 3D Tiles spec, i.e. the tree structure. Same for BoundingVolume and BatchTable.

Regarding the extensions management I will open a discussion with an implementation example (maybe as a PR/issue instead of gitter so there is a trace of the design choices?) once I'm sure my proposition works.

Regarding the custom materials/shaders, is there an existing implementation of this (e.g. in another project) at your knowledge ?

mgermerie commented 1 year ago

The complete 3d-tiles support is planned in the short term road map. We are currently studying possibilities in terms of libraries to enhance support (as mentioned in https://github.com/iTowns/itowns/discussions/1917).