椎体模型如下图
思路:不断改变椎体的偏航角(Y轴),从而实现选择
代码:
//获取锥体的坐标
var position = Cesium.Cartesian3.fromDegrees(108.95813233063066,34.22065543077288,30);
var heading = 0;//偏航角(Y轴)
var pitch = 0; //俯仰角(X轴)
var roll = 0;//翻滚角(Z轴)
//封装改变偏航角的方法
function diaoyong() {
heading = heading + Cesium.Math.toRadians(10);
var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
var orientation=Cesium.Transforms.headingPitchRollQuaternion(position, hpr);
return orientation;
}
//添加到椎体模型
var zhui = viewer.entities.add({
id:'zhui',
name: '旋转锥',
position: position,//椎体位置
//通过CallbackProperty延迟回调函数一直调用封装的偏航角方法
//false,返回的值如果改变则一直调用自身,diaoyong()返回的值是orientation,而orientation会根据每次heading 的不同而发生改变
orientation: new Cesium.CallbackProperty(diaoyong, false),
model: {
show: true,
uri: "./img/zhui.glb",
scale: 1,
minimumPixelSize: 60,
maximumScale: 10,
},
});