Hi all
I’ve checked the model coordinates by manually plotting billboards on some of the model coordinates directly into the globe and they aligned perfectly. Example code
cartesian = new Cesium.Cartesian3.fromDegrees(-4.8979284420470881, 36.490237894893575, 0.1); // model vertex coordinate transformed into WGS84
viewer.entities.add({
id: “building-coordinate-max”,
position: cartesian,
box: {
dimensions: new Cesium.Cartesian3(1,1,0),
outline: true,
outlineColor: Cesium.Color.WHITE,
outlineWidth: 2,
material: Cesium.Color.fromAlpha(Cesium.Color.YELLOW, 0.2)
},
label: {
text: ‘MAX’,
font: ‘14pt monospace’,
style: Cesium.LabelStyle.FILL_AND_OUTLINE,
outlineWidth: 2,
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
pixelOffset: new Cesium.Cartesian2(0,-9)
}
But when the same model was loaded by a tileset with the appropriate eastNorthUpToFixedFrame transform, it never algined. I’ve also discovered that the model would be closer to it’s ideal position the closer it was to the RTC center. It also looked like it was a rotation rather than translation issue.
Then I’ve tried to manually rotate the tileset by multiplying a rotation transform to the eastNorthUpToFixedFrame transform and applying it directly to the tileset on runtime. Thus I’ve managed to improve dramatically the alignment of the models in my extent (south Spain) by adding a rotation of 1.117 degrees to the tileset modelMatrix. Even models as far as 1000+ m from the RTC appear to be correctly aligned.
This is the code I’ve used to configure the tileset with the appropriate rotation:
var rotation = Cesium.Matrix3.fromRotationZ(1.117* RADIANS_PER_DEGREE);
var rotMat = Cesium.Matrix4.fromRotationTranslation(rotation);
var rtcCenter = new Cesium.Cartesian3.fromDegrees(-4.8728231291920547, 36.5093837495992);
var posMat = Cesium.Transforms.eastNorthUpToFixedFrame(rtcCenter);
var modelMatrix = new Cesium.Matrix4();
Cesium.Matrix4.multiply(posMat, rotMat, modelMatrix);
//modelMatrix = posMat;
var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
url: ‘http://cesium.local/tileset.json’,
modelMatrix: modelMatrix,
debugShowBoundingVolume: true,
debugShowContentBoundingVolume: true
}));
Is there any reason for this behavior?
Thanks in advance
Álvaro

tileset.json (422 Bytes)