How to load many GLTf files

Hi,

I'm using the last version of Cesium and i'm not able to load correctly several GLTF files at the same time.
The thing is i have many GLTf files, each one of them representing a 3D building, and i want to load all of them together at the same time,
but the result i get is a mesh of overlapping structures.

Any help would be appreciated.

Thanks,

David

Do you have information about where each building should be positioned, for example longitude and latitude? It sounds like the models themselves don’t have positional information and so they all render at the same spot.

Hi Sean,

Thanks for answering. As far as i know, yes the gltf files have positional information. I used the 3Dcity-importer-exporter to transform de data from a cityGML file (which has location information) to the GLTF files. These new files have the property POSITION referencing an accessor, which is for instance like this;

"accessor_12": {
            "bufferView": "bufferView_15",
            "byteOffset": 0,
            "byteStride": 12,
            "componentType": 5126,
            "count": 854,
            "max": [
                15.083,
                1.504,
                25.24
            ],
            "min": [
                -56.259,
                -59.658,
                0
            ],
            "type": "VEC3"
        }

Where "bufferView_15" is also included in the file, with the data in an uri.

David

What do some of the other gltfs look like? Are the min/max in the same sort of range? It seems like the vertex positions might be just for the building alone and not positioned relative to other buildings. If you send over some files I could help check.

Hi Sean,

Here you can download a .zip file (25 mb; 100mb when unzziped) which contains around 6000~7000 gltf files.

Thanks!

https://wetransfer.com/downloads/c9943176dd39ebb1ee47a3cdd81190a920180302131457/93f30a

From those files it does look like each model has roughly the same origin (0, 0, 0) which will cause them to all render on top of each other. Does 3Dcity-importer-exporter save any other information during the conversion, such as where model is positioned relative to the city as a whole? You’ll need information like that in order to place the glTFs in their correct locations.

Hi Sean,

The 3Dcity-importer-exporter also creates one .kml file which seems to be like a "master" file with references to each one of the gltf files, but if i load the KML file i only obtain the border of the city, perhaps the references are not correct?

The .kml file is something like this;

<kml xmlns:xal="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:gx="http://www.google.com/kml/ext/2.2">
  <Document>
    <name>noTiles_Tile_0_0_collada</name>
    <open>false</open>
    <Placemark>
      <name>Tile border</name>
      <LineString>
        <tessellate>true</tessellate>
        <coordinates>-2.6882315813700774,42.832737463758754 -2.645598461482068,42.832737463758754 -2.645598461482068,42.854820236527694 -2.6882315813700774,42.854820236527694 -2.6882315813700774,42.832737463758754</coordinates>
      </LineString>
    </Placemark>
    <Placemark id="COLLADA__104">
      <name>_104</name>
      <Model>
        <altitudeMode>absolute</altitudeMode>
        <Location>
          <longitude>-2.6846207</longitude>
          <latitude>42.8548064</latitude>
          <altitude>0.0</altitude>
        </Location>
        <Orientation>
          <heading>0.2173963</heading>
        </Orientation>
        <Link>
          <href>3076/_104.gltf</href>
        </Link>
      </Model>
    </Placemark>
    <Placemark id="COLLADA__176">
      <name>_176</name>
      <Model>
        <altitudeMode>absolute</altitudeMode>
        <Location>
          <longitude>-2.6793701</longitude>
          <latitude>42.8547503</latitude>
          <altitude>0.0</altitude>
        </Location>
        <Orientation>
          <heading>0.2160434</heading>
        </Orientation>
        <Link>
          <href>3112/_176.gltf</href>
        </Link>
      </Model>

..... and so on.

Thanks in advise!

Ah yeah the KML is the missing piece. Unfortunately I don’t think our KML implementation loads models.

However if you are able to parse the KML yourself and get the longitude/latitude for each model you should be able to position the models.

As a side note, KML + Collada (or glTF) is a common format that we are able to convert to 3D Tiles. This type of conversion will ultimately be available with Cesium ion - https://cesium.com/blog/2018/03/01/hello-cesium-ion/

I used X2JS to turn the kml into JavaScript objects and then there really isn’t any parsing. Here’s the way you access the placemarks.

https://github.com/x2js/x2js

var x2js = new X2JS();

var kmlFile = x2js.xml2json( kmlFilePath );

var placeMarks = kmlFile.kml.Folder.Placemark;

Scott

Great! Thanks both!

David

Ah good idea Scott.