PermafrostDiscoveryGateway / viz-points

Python package for post-processing point-cloud data for 3D visualization
Apache License 2.0
0 stars 1 forks source link

Merged point cloud disappears when viewing from certain angles #9

Open iannesbitt opened 1 year ago

iannesbitt commented 1 year ago

Appeared after solution to #8, so perhaps related to force_universal_merger=True

iannesbitt commented 1 year ago

Interesting that this does not happen with test dataset (see image in #10)

iannesbitt commented 1 year ago

This looks like it may be similar to CesiumGS/cesium#5524 but it appears that the video describing the issue has been taken down.

The issue appears to occur when the camera enters the bounding box of a child tileset. As soon as the camera enters the bounding box, the tileset becomes invisible. Rotating the camera ~180º to look roughly south (dataset is in Nome, AK) and changing the viewing angle to more horizontal makes the tileset reappear and begin loading at the appropriate zoom level. So in effect, there is only a narrow slice of angles at which the tileset can be viewed up close, otherwise it must be viewed from far away.

Running the 3d-tiles-validator on the tilesets involved yields no errors:

% npx 3d-tiles-validator --tilesetsDirectory 3dtiles/
...
Validated 248 files
    0 files with errors
    0 files with warnings
    0 files with infos

Stranger still, this effect does not appear when pointing cesiumjs at the subdirectory tilesets (e.g. 3dtiles/Site7/tileset.json), only the merged root directory tileset (e.g. 3dtiles/tileset.json). Changing the root "refine": properties in the root tileset.json file does not alleviate the error. I suspect the issue is related to the merger process somehow, but have not yet been able to confirm.

Will be writing up an issue and/or forum post for Cesium and/or Oslandia soon.

iannesbitt commented 1 year ago

A temporary solution is to add tilesets individually rather than merge, then add and zoom to the master merged tileset with show: false like so:

  const sites = [
    "3dtiles/Site1/tileset.json",
    "3dtiles/Site3/tileset.json",
    "3dtiles/Site4/tileset.json",
    "3dtiles/Site5/tileset.json",
    "3dtiles/Site6/tileset.json",
    "3dtiles/Site7/tileset.json",
    "3dtiles/Site8/tileset.json",
    "3dtiles/Site8_2/tileset.json",
    "3dtiles/SiteV_1/tileset.json",
    "3dtiles/SiteV_2/tileset.json",
    "3dtiles/Site_9/tileset.json",
  ]; // could also be generated programatically
  try {
    for (const site of sites) {
      var tileset = new Cesium.Cesium3DTileset({
        url: site,
      });
      tileset.style = new Cesium.Cesium3DTileStyle({
          pointSize: 2,
          show: true,
          scaleByDistance: 'vec4(1.5e2, 2.0, 1.5e7, 0.5)',
        });
      scene.primitives.add(tileset);
    }
    var master = new Cesium.Cesium3DTileset({
      url: '3dtiles/tileset.json',
    });
    master.style = new Cesium.Cesium3DTileStyle({
        show: false,
      });
    scene.primitives.add(master);
    await viewer.zoomTo(master);
iannesbitt commented 1 year ago

I have a hunch (untested) that this has to do with erroneous values introduced in the tiling process that make Cesium think it should be loading/unloading certain things when it should not. Not sure how this might be resolved except to try to understand and modify the merge process.

iannesbitt commented 1 year ago

The reason for this hunch is best shown here: image

iannesbitt commented 11 months ago

Next step is to test the merge at https://github.com/PermafrostDiscoveryGateway/viz-3dtiles/blob/d9fb183c7487ff37b320dd97c85190a3921526ab/viz_3dtiles/TreeGenerator.py#L108 to see if that method works better.