记一次开发中的cesium加载模型
createModel (url, location, height, scale = 2, radians = 135) {
const position = Cesium.Cartesian3.fromDegrees(location[0], location[1], height)
const heading = Cesium.Math.toRadians(radians) // 模型旋转角度
const pitch = Cesium.Math.toRadians(0.0)
const roll = 0
const hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll)
const orientation = Cesium.Transforms.headingPitchRollQuaternion(
position,
hpr,
)
let entity = window.viewer.entities.add({
name: url,
position: position,
orientation: orientation,
model: {
uri: url,
scale: scale,
// maximumScale: 1.1
position: position,
orientation: orientation,
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND, // 是否贴地显示
color: Cesium.Color.WHITE // 将模型颜色和设置的颜色进行融合
}
})
},