最近遇到倾斜摄影模型和BIM模型叠加在一起之后,高度不太对,因为Revit中的BIM模型是有高度的,但是无人机扫描出来的倾斜摄影模型加载到Cesium之后是平的,没有高度,为了将两者的高度近似一致,只能对倾斜摄影的模型做适当的旋转来匹配BIM模型.
var longitude = 120.28530000000003;
var latitude = 31.683809999999976;
var height = 45;
var heading = -0;
var tileset = new Cesium.Cesium3DTileset({
url:'http://localhost:9002/api/folder/4cb722afbd2a4380956ac32fb45f9eab/tileset.json'
});
viewer.scene.primitives.add(tileset);
tileset.readyPromise.then(function(argument) {
var position = Cesium.Cartesian3.fromDegrees(longitude, latitude, height);
var mat = Cesium.Transforms.eastNorthUpToFixedFrame(position);
var rotationX = Cesium.Matrix4.fromRotationTranslation(Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(heading)));
Cesium.Matrix4.multiply(mat, rotationX, mat);
tileset._root.transform = mat;
viewer.camera.flyTo({destination: Cesium.Cartesian3.fromDegrees(longitude, latitude, height + 1000)});
});
Cesium. Matrix3.formRotationX
Cesium. Matrix3.formRotationY
Cesium. Matrix3.formRotationZ
分别对应不用轴的旋转,需要用到那个轴的旋转,根据实际决定.