加载模型代码:
let tileModelTool={
longitude: 118.57323,
latitude: 32.59386,
height: 218.30516,
rx: 38.621906,
ry: 5.2172027,
rz: 144.28116,
}
let earthPosition = Cesium.Cartesian3.fromDegrees(
tileModelTool.longitude,
tileModelTool.latitude,
tileModelTool.height
);
var hpRoll = new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(tileModelTool.rz), Cesium.Math.toRadians(tileModelTool.ry), Cesium.Math.toRadians(tileModelTool.rx));
var fixedFrameTransform = Cesium.Transforms.localFrameToFixedFrameGenerator('north', 'west');
var m1 = Cesium.Transforms.headingPitchRollToFixedFrame(earthPosition, hpRoll, Cesium.Ellipsoid.WGS84, fixedFrameTransform);
m1=Cesium.Matrix4.fromArray([1,0,0,0,0,1,0,0,0,0,1,0,-2572703.3915971606,4723922.014731573,3416214.8218105813,1]);
console.log(m1);
var models = scene.primitives.add(
Cesium.Model.fromGltf({
url: "/data/fengche.gltf",
modelMatrix: m1,
scale: 0.005,
})
);
//显示模型坐标系
_viewer.extend(Cesium.viewerCesiumInspectorMixin);
模型动画显示
viewer的shouldAnimate参数需要设置为true
model.readyPromise.then(function(model) {
model.activeAnimations.addAll({
loop : Cesium.ModelAnimationLoop.REPEAT,
speedup : 2, //速度
reverse : true //false顺时针 true逆时针
});