3Dtiles models bounding volumes doesn’t match the tile's actual position

Hi All,

I’m struggling to change modelMatrix . My tileset is local coordinate system ,i want to transforms from the tile’s local coordinate system to the WGS84, my code as follow:

var cesiumViewer = new Cesium.Viewer(‘cesiumContainer’);

cesiumViewer.scene.globe.depthTestAgainstTerrain = true;

var scene = cesiumViewer.scene;

// Configure tilesets

var rtcCenter = new Cesium.Cartesian3.fromDegrees(-4.8728231291920547, 36.5093837495992);

var posMat = Cesium.Transforms.eastNorthUpToFixedFrame(rtcCenter);

var tileset = scene.primitives.add(new Cesium.Cesium3DTileset({

url: './tileset.json',

modelMatrix: posMat,

debugShowBoundingVolume: true,

debugShowContentBoundingVolume: true

}));

// Move camera to tileset bounding volume

tileset.readyPromise.then(function (tileset) {

cesiumViewer.camera.viewBoundingSphere(tileset.boundingSphere, new Cesium.HeadingPitchRange(0, -0.5, 0));

cesiumViewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);

});

the problem is 3Dtiles model bounding volumes doesn’t match the tile’s actual position as below: is something wrong?

It’s hard to tell what the problem is exactly, but my guess is that the model’s vertices are not centered about (0,0,0). You may need to either adjust the model or adjust the sphere bounding volume. If you send over the tileset I could take a closer look.

Sean Lilley,thank you for your replay,my test data is upload,thank you for your help!
在 2017年9月29日星期五 UTC+8上午7:43:47,Sean Lilley写道:

testData.zip (158 KB)

I think the problem has to do with the modelMatrix offsetting the bounding sphere differently than the model.

I noticed the bounding sphere and model CESIUM_RTC use the same value ( -9.97391280580907, 4.1, 44.8553492029579) - so it seems like it would be correct. But what’s happening is the modelMatrix acts as a matrix multiply against the bounding’ sphere center, which causes it to rotate a bit. Meanwhile the modelMatrix is multiplied against the model’s origin (which is implicitly (0,0,0)), and THEN the CESIUM_RTC value is added. So the CESIUM_RTC is not affected by the rotational component of the modelMatrix. This slight difference is what causes the bounding sphere and model to be not aligned.

There are a couple approaches to fixing this:

  • Get rid of CESIUM_RTC and change the bounding sphere’s center to (0, 0, 0). In the tileset.json add a transform to the tile that has a translation of ( -9.97391280580907, 4.1, 44.8553492029579). This transform will be applied to both the bounding sphere and model and they will be aligned correctly. You can still set the tileset’s modelMatrix with this approach. I think this is the best approach to use in your case. https://github.com/AnalyticalGraphicsInc/3d-tiles#tile-transform

  • Bake the modelMatrix into both the bounding sphere and model’s geometry and CESIUM_RTC, and don’t use the modelMatrix in the code

  • Use a different center for the bounding sphere. I think this will require some matrix math to get right and will be dependent on the modelMatrix used.

Let me know if this makes sense…