目前有倾斜摄影测量数据和美工制作的3dsMax模型数据,需要对这两种数据进行处理,以便于在cesium上进行展示,模型处理方法如下:
1.倾斜摄影测量模型生产
倾斜摄影测量数据是通过无人机搭载的五镜头相机拍摄的某区域的照片,照片数据共有800张,每张照片均有经纬度坐标,通过ContextCapture软件进行空三计算后,即可进行三维重建,ContextCapture软件的使用较简单,其中需要注意的就是生产的三维模型数据格式选择cesium b3dm,数据坐标系选择WGS84,模型生产完成后,通过如下代码即可加载到cesium上
//加载3d tileset
var tileset = new Cesium.Cesium3DTileset({
url: "/data/Production_1_4326/Scene/Production_1_4326.json"
});
// earthView.terrainProvider = Cesium.createWorldTerrain();
//倾斜模型与CESIUM DEM高程误差,需手动调整
var height = -1080;
// var height = -25;
let thisView = earthView;
tileset.readyPromise
.then(tileset => {
this.droneModalPrimitive = thisView.scene.primitives.add(tileset);
thisView.zoomTo(
tileset,
new Cesium.HeadingPitchRange(
0.0,
-0.5,
tileset.boundingSphere.radius * 2.0
)
);
//贴地显示
var cartographic = Cesium.Cartographic.fromCartesian(
tileset.boundingSphere.center
);
var surface = Cesium.Cartesian3.fromRadians(
cartographic.longitude,
cartographic.latitude,
0.0
);
var offset = Cesium.Cartesian3.fromRadians(
cartographic.longitude,
cartographic.latitude,
height
);
var translation = Cesium.Cartesian3.subtract(
offset,
surface,
new Cesium.Cartesian3()
);
tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
})
.otherwise(function(error) {
console.log(error);
});
2. 3dsMax模型导入
2.1插件安装
首先对美工使用的3dsMax软件添加一个DAE数据导出插件,插件下载地址见https://github.com/KhronosGroup/OpenCOLLADA/releases,下载指定版本的插件,然后解压dle文件到3dsMax的plugins目录,重启3dsMax,即可完成插件的安装。
2.2模型导出
将模型导出为DAE格式,通过安装的插件,能够保证模型材质不丢失
2.3模型切片
下载cesiumlab,cesiumlab是一款免费的cesium数据处理工具,使用手机号注册后即可使用,打开软件登陆后进入数据处理——人工模型切片工具
微信截图_20191211092554.png
2.3.1输入模型地理坐标
美工制作好的模型是不具有地理坐标的,点击人工模型切片工具的右侧的添加按钮,将DAE模型添加到工具中,然后点击位置按钮,输入模型的经纬度坐标数据
微信截图_20191211092832.png
确定了模型的地理坐标后,即可点击确定进行模型切片,cesiumlab会将DAE模型文件转换为b3dm切片数据
2.3模型加载
切片完成后的模型已经转换成为3dTiles数据格式,加载代码如下
var tileset = earthView.scene.primitives.add(
new Cesium.Cesium3DTileset({
url: modelUrl,
modelMatrix: Cesium.Matrix4.fromArray([
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1
])
})
);
earthView.flyTo(tileset);