加载车辆模型
export function addModel(viewer: Cesium.Viewer) {
const model = new Cesium.Entity({
id: "model",
name: "小车模型",
show: true,
position: Cesium.Cartesian3.fromDegrees(118, 30, 5000),
model: {
uri: "../../../src/assets/model/car.glb",
minimumPixelSize: 600,
maximumScale: 1000,
scale: 10,
},
});
viewer.entities.add(model);
return model;
}
const model=addModel(viewer);
修改车辆摆放角度
const degree = 90;
const heading = Cesium.Math.toRadians(degree);
const pitch = 0;
const roll = 0;
const hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
model.orientation=new Cesium.ConstantProperty(Cesium.Transforms.headingPitchRollQuaternion(Cesium.
Cartesian3.fromDegrees(118, 30, 5000), hpr));