Open jailln opened 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
.
Thank you for the clarifications! With these information and by having a deeper look in the code, it seems that:
tileIndex
is an Object containing a flattened tileset (in the 3D Tiles spec, a tileset is a set of nested tiles organized according to a tree; each tile referencing a content being e.g a b3dm file).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 ?
THREEjs
): When a b3dm tile content is loaded (by the b3dmParser
and gltfParser
), it is converted to a THREE.Object3D
and added as a child to the object3d
attribute of the layer. The structure of each b3dm tile content is as follow: it has one children (of type THREE.Scene
), which also has one children (of type THREE.Mesh
) which has a property geometry
(of type THREE.BufferGeometry
) which has a property attributes
which has 3 properties of type THREE.BufferAttribute
: _BATCHID
, normal
, position
. cf. this structure in the 3dtiles_hierarchy
example: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 )
Thank you for your analysis of the 3Dtiles code.
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
.
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
.
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:
examples/3dtiles_temporal.html
and src/Provider/TemporalExtension.js
src/Provider/3dTilesClasses.js
in which I added a Tileset
class (holding the tileIndex
) a BoundingVolume
class and a BatchTable
class. This file also holds the code needed for extensions management.$3dTilesCulling
, fillHTMLWithPickingInfo
). Example: BatchTableHierarchy and Temporal extensions are defined in the layer. $3dTilesCulling does its work and then calls the culling method of both these extensions. BatchTableHierarchyExtension.culling() does nothing and TemporalExtension.culling hides some of the tiles based on the attributes stored in the temporalExtension of the boundingVolume.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 ?
Great :) Could you elaborate what are the roles of 3DTilesLayer and of 3DTilesSource please ? (e.g. in comparison with Provider and Processing)
3DTilesLayer
have data structure and processing.3DTilesSource
defines the parameters (base url, network option
) and conditions (extent
) to obtain the data.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
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 ?
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).
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