njam / citygml-to-3dtiles

Convert from CityGML to Cesium 3D Tiles.
Apache License 2.0
160 stars 41 forks source link

3DModel in Cesium on wrong position #43

Closed ghschier closed 10 months ago

ghschier commented 10 months ago

I'm trying to show this CityGML-File in Cesium: https://data.geobasis-bb.de/geobasis/daten/3d_gebaeude/lod2_gml/lod2_33250-5889.zip

I convert it with the following code:

let converter = new Converter({
  srsProjections: {
    'urn:adv:crs:ETRS89_UTM33*DE_DHHN2016_NH': '+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs'
  }
});
converter.convertFiles('./lod2_33250-5889_geb.gml', './out/');

The tileset.json looks like this:

{
  "asset": {
    "version": "0.0"
  },
  "properties": {},
  "geometricError": 99,
  "root": {
    "refine": "ADD",
    "boundingVolume": {
      "region": [
        0.2378663445769732,
        0.9163309264592866,
        0.23854127001963296,
        0.9168317354679856,
        -4652.384408036445,
        5271.9993159265605
      ]
    },
    "geometricError": 0,
    "content": {
      "url": "full.b3dm"
    }
  }
}

Then I try to show the buildings in Cesium Sandcastle (https://sandcastle.cesium.com/):

const viewer = new Cesium.Viewer("cesiumContainer");

const tileset = viewer.scene.primitives.add(
  await Cesium.Cesium3DTileset.fromUrl(
    "http://localhost/test/tileset.json", {
    debugShowBoundingVolume: true
  })
);

const transform = Cesium.Transforms.eastNorthUpToFixedFrame(
  Cesium.Cartesian3.fromDegrees(13.6248, 52.4816, 0)
);
tileset.modelMatrix = transform;

viewer.zoomTo(tileset);

The viewer shows the bounding volume somewhere in outer space... I don't know if it's a issue with the converter or with cesium. Do you have an explanation? Is it a problem with the elevation, the heights look strange in the tileset.json. Thank you.

ghschier commented 10 months ago

I found out that without the transformation the buildings are displayed (hanging in the air, but at the correct position). So this works as expected:

const tileset = viewer.scene.primitives.add(
  await Cesium.Cesium3DTileset.fromUrl("http://localhost/test/tileset.json")
);
viewer.zoomTo(tileset);