在三维场景中绘制一个贴倾斜模型的面,点击面周围以外的地方(图片中红色框附近),仍然能选中该面
点击事件写法如下
function addleftclick(){
let hbhandler = new Cesium.ScreenSpaceEventHandler(
viewer.scene.canvas
);
hbhandler.setInputAction(function (event) {
console.log(event)
let position = viewer.scene.pickPosition(event.position);
clickPosition = position;
if (!position) {
return;
}
var pickedFeature = viewer.scene.pick(event.position,0,0);
var pickedFeatures = viewer.scene.drillPick(event.position,5,1,1);
var pickfeat = viewer.scene.pick(position,0,0);
var pickfeats = viewer.scene.drillPick(position,5,1,1);
console.log(pickedFeature,11)
console.log(pickedFeatures,22);
console.log(pickfeat,33)
console.log(pickfeats,44)
console.log(pickedFeature.id.layerName,55);
if (Cesium.defined(position)) {
let cartographic = Cesium.Cartographic.fromCartesian(position); //根据笛卡尔坐标获取到弧度
let lat = Cesium.Math.toDegrees(cartographic.latitude);
let lng = Cesium.Math.toDegrees(cartographic.longitude);
let height = cartographic.height;
}
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
}