CesiumGS / 3d-tiles

Specification for streaming massive heterogeneous 3D geospatial datasets :earth_americas:
2.14k stars 469 forks source link

Update and extend the implicit tiling examples #512

Closed javagl closed 3 years ago

javagl commented 3 years ago

There are currently three examples for implicit tiling data sets. One of them is https://github.com/CesiumGS/3d-tiles/tree/3d-tiles-next/extensions/3DTILES_implicit_tiling/examples/sparseOctree

The tileset JSON says "subtreeLevels": 2.

The section https://github.com/CesiumGS/3d-tiles/tree/3d-tiles-next/extensions/3DTILES_implicit_tiling#availability-bitstream-lengths says that the length of the tile availability bitstream is

(N^subtreeLevels - 1)/(N - 1)

For N=8 and subtreeLevels=2, this should yield 9.

The section also says that

lengthBytes = ceil(lengthBits / 8), which would be 2, in this case.

But the tileAvailability of the JSON of subtree 0/0/0/0.subtree refers to bufferView: 0, which is said to have "byteLength": 1:

{
  "buffers" : [ {
    "byteLength" : 9
  } ],
  "bufferViews" : [ {
    "buffer" : 0,
    "byteOffset" : 0,
    "byteLength" : 1
  }, {
    "buffer" : 0,
    "byteOffset" : 1,
    "byteLength" : 8
  } ],
  "tileAvailability" : {
    "bufferView" : 0
  },
  "childSubtreeAvailability" : {
    "bufferView" : 1
  },
  "contentAvailability" : {
    "bufferView" : 0
  }
}

The same applies to the basicExample.


The examples should be updated to be valid, and extended to show different configurations, like sparse- and dense quadtrees and octrees with different heights and subtree-heights.

Preferably, the examples should be documented extensively, including information that can otherwise only be derived from actually reading the subtree files and interpreting the data correctly. This means that the JSON part that is contained in the subtree files should be part of the documentation, and the binary parts (i.e. the availability info) should be documented in a form that might say, for example,

The availability bytes are 0xCAFEBEEF, which is the bit pattern 01101010111101...

so that implementors can easily verify that their interpretation of the data is correct.


(Rumours say that such examples could go into https://github.com/CesiumGS/3d-tiles-samples at some point, but making sure that the ones that are currently here are valid would be the first step, if these new examples are not created with a completely new mechanism...)

ptrgags commented 3 years ago

Note that there are more tilesets used for unit testing in CesiumJS: https://github.com/CesiumGS/cesium/tree/main/Specs/Data/Cesium3DTiles/Implicit

We'll have to check through them to see if any of them need updating.

ptrgags commented 3 years ago

For lack of a better place to put this, here's another implicit tiling example that would be good to make into a real tileset and put in 3d-tiles-samples -- this is an example of making a double-headed quadtree for global-scale tilesets.

{
  "asset": {
    "version": "1.0"
  },
  "geometricError": 8000,
  "extensionsUsed": [
    "3DTILES_implicit_tiling"
  ],
  "extensionsRequired": [
    "3DTILES_implicit_tiling"
  ],
  "root": {
    "boundingVolume": {
      "region": [-3.14159265359, -1.57079632679, 3.14159265359, 1.57079632679, 0, 1000]
    },
    "refine": "REPLACE",
    "geometricError": 4000,
    "children": [
      {
        "boundingVolume": {
          "region": [-3.14159265359, -1.57079632679, 0, 1.57079632679, 0, 1000]
        },
        "content": {
          "uri": "content/western-hemisphere/{level}/{x}/{y}.b3dm"
        },
        "geometricError": 2000,
        "extensions": {
          "3DTILES_implicit_tiling": {
            "subdivisionScheme": "QUADTREE",
            "maximumLevel": 20,
            "subtrees": {
              "uri": "subtrees/eastern-hemisphere/{level}/{x}/{y}.subtree"
            },
            "subtreeLevels": 7
          }
        }
      },
      {
        "boundingVolume": {
          "region": [0, -1.57079632679, 3.14159265359, 1.57079632679, 0, 1000]
        },
        "content": {
          "uri": "content/eastern-hemisphere/{level}/{x}/{y}.b3dm"
        },
        "geometricError": 2000,
        "extensions": {
          "3DTILES_implicit_tiling": {
            "subdivisionScheme": "QUADTREE",
            "maximumLevel": 20,
            "subtrees": {
              "uri": "subtrees/eastern-hemisphere/{level}/{x}/{y}.subtree"
            },
            "subtreeLevels": 7
          }
        }
      }
    ]
  }
}
ptrgags commented 3 years ago

This has been mostly addressed in https://github.com/CesiumGS/3d-tiles-samples, and #562 has any further details.