3D tiles move from their correct position while rotating

Hi all!

I am very new to Cesium and I am having some issues with the correct positioning of my 3D tileset on 3D Terrain. The tile model is b3dm. When I try to rotate the tileset on the map; it moves from its correct position. When I deactivate the 3D Terrain, the 3D tileset remains in the correct position while moving and rotating. I am trying to implement the possible solutions provided by Cesium Community that are 3D Tiles. Model moves when camera tilts and this example.

I try to use the code from the example but I obtain some errors:

The tile.boundingVolume does not have a minimumHeight property, so I manually find and define the minimum height of the tileset. Additionally model.rtcCenter is undefined.

I have changed the code a little bit in order to bypass the problems, so I’ve used model._modelMatrix that returns:

Matrix4 {0: 1, 1: 0, 2: 0, 3: 0, 4: 0, 5: 1, 6: 0, 7: 0, 8: 0, 9: 0, 10: 1, 11: 0, 12: 4557159.9855588935, 13: 913199.2611898157, 14: 4353386.520720135, 15: 1}

And then I’ve extracted the 12th, 13th and 14th column. The code I am using is here:

    tileset.tileVisible.addEventListener(function(tile) {
    tileset.readyPromise.then(function(tileset) {
        var children = tileset.root.children;
        var length = children.length;
        for (var i = 0; i < length; ++i) {
            var boundingVolume = tile.boundingVolume;
            if (Cesium.defined(tile.contentBoundingVolume)) {
    	    boundingVolume = tile.contentBoundingVolume;
           var content = tile.content;
           var model = content._model;
           var center = model._modelMatrix;
           var rtcCenterEye = new Cartesian3();
           rtcCenterEye.x = center[12];  
           rtcCenterEye.y = center[13];
          rtcCenterEye.z = center[14];
          var normal = scene.globe.ellipsoid.geodeticSurfaceNormal(rtcCenterEye, new Cartesian3());
          var height = -10.0;
          var offset = Cartesian3.multiplyByScalar(normal, height, new Cartesian3());
          var carto = Cesium.Cartographic.fromCartesian(rtcCenterEye);
          var promise = Cesium.sampleTerrainMostDetailed(scene.terrainProvider, [carto]);
          Cesium.when(promise, function(result) {
              result = Cesium.Cartographic.toCartesian(carto);
              var position = Cartesian3.subtract(result, offset, new Cartesian3());
	  model.rtcCenterEye = Cartesian3.clone(position, model.rtcCenterEye);

As nothing has changed after this operation, I tried to use a tile transform to reach the rtcCenter value as mentioned here but the tile content does not have a Feature Table but a Batch Table. Isn’t the Feature Table automatically generated when the 3D tileset is generated? I couldn’t find which kind of value model.rtcCenter returns.

I am a bit confused and not even sure if these solutions are the correct approaches. The tileset and the terrain are generated with the open-source tools. I am adding the JSON file. Hopefully, someone will help me, thank you very much in advance!

tileset.json: tileset.json.zip (944 Bytes)

The 3D Tileset that is in the correct position:

When rotating: