上面是效果图...
// gltf
var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(
Cesium.Cartesian3.fromDegrees(beijin[0], beijin[1], 0)
)
var scene = viewer.scene
// gltf数据加载位置
let model = scene.primitives.add(
Cesium.Model.fromGltf({
url: './tiananmen.gltf', // 本地文件
show: true, //确定是否将显示模型基元。
modelMatrix: modelMatrix,
scale: 0.05 // 放大倍数
})
)
/** 模型旋转角度 */
model.readyPromise.then(function () {
var position = Cesium.Cartesian3.fromDegrees(beijin[0], beijin[1], 0);
var mat = Cesium.Transforms.eastNorthUpToFixedFrame(position);
var rotationX = Cesium.Matrix4.fromRotationTranslation(Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(-90)));
Cesium.Matrix4.multiply(mat, rotationX, mat);
model.modelMatrix = mat;
})
viewer.camera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(beijin[0], 39.860187, 5000.0), //相机飞入点
orientation: {
// heading: 0.6,
pitch: Cesium.Math.toRadians(-52.0), //绕纬度线旋转
// roll: Cesium.Math.toRadians() //绕经度线旋转
}
})
注意:需要注意的是坐标问题....,不进行转换会发生偏移,阅读后面文档进行安装,点击查看坐标转换。
let coordtransform = require('coordtransform');
let beijin = coordtransform.gcj02towgs84(116.397451, 39.909187);