iTowns / itowns

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

[Architecture] inconsistent role of `C3DTilesBatchTable` #2261

Open mgermerie opened 5 months ago

mgermerie commented 5 months ago

Your Environment

Context

When parsing B3DM 3d-tiles with B3dmParser and if needed, we instantiate a C3DTilesBatchTable at those lines. The arguments given for C3DTilesBatchTable instantiation are an ArrayBuffer containing raw batch table data, and lengths of the table as well as its json and binary parts. Then, in C3DTilesBatchTable constructor, the ArrayBuffer is parsed : the json part and the eventual binary attribute values are decoded and the resulting JS Object is stored in a C3DTilesBatchTable property.

I believe this is an error in terms of architecture. A C3DTilesBatchTable should only store data from a given batch table and grant method to access, edit or eventually delete this data. It should not be also responsible for parsing raw data from a B3DM file.

Possible Cause/Fix/Solution

The parsing of the batch table from a B3DM file should be done directly in the B3dmParser, and C3DTilesBatchTable should take an already parsed batch table as constructor argument.