当前位置:网站首页>cesium鼠标拾取要素,并判断要素类别
cesium鼠标拾取要素,并判断要素类别
2022-04-22 07:42:00 【Gisleung】
函数功能: 输入拾取位置的屏幕坐标,返回拾取结果,并判断结果类别。
支持: Entity、Cesium3DTileset、Billboard Primitive、Primitive、Model。
/** * 拾取屏幕像素位置的cesium要素,并判断是什么类型 * @param x 像素横坐标 * @param y 像素纵坐标 * @returns {*} */
pickFeatureFromScreen(x, y){
// 存放拾取结果
let resp = {
pickResult: null,
}
// 从像素坐标拾取对象
let pickCartesian2 = new Cesium.Cartesian2(x, y)
let feature = viewer.scene.pick(pickCartesian2);
// 判断拾取结果
if (Cesium.defined(feature)) {
// feature.primitive.constructor.name 也可以获取类型
resp.pickResult = feature // 拾取结果
if (feature.hasOwnProperty('id') && feature.id instanceof Cesium.Entity) {
// 是entity: {collection, id, primitive}
resp.type = 'Entity'
resp.detailType = feature.primitive.constructor.name
resp.entity = feature.id
} else if (feature.primitive instanceof Cesium.Cesium3DTileset) {
// 是3DTile: {content, primitive}
resp.type = 'Cesium3DTileset'
} else if (feature.primitive instanceof Cesium.Billboard) {
// 是primitive-billboard: {collection, id, primitive}
resp.type = 'Billboard'
resp.id = feature.id
resp.billboardCollection = feature.collection
resp.billboard = feature.primitive
} else if (feature.primitive instanceof Cesium.Primitive) {
// 是primitive: { primitive}
resp.type = 'Primitive'
resp.primitive = feature.primitive
} else if (feature.primitive instanceof Cesium.Model) {
// 是mode
resp.type = 'Primitive'
resp.detailType = 'Model'
resp.primitive = feature.primitive
}
}
return resp
},
版权声明
本文为[Gisleung]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_27816785/article/details/120841393
边栏推荐
- 技术选型分类(2022)
- Asnotracking for efcore optimization
- Efcore global query filter
- 原来PID是在老王头和老斯基的斗争中诞生的
- 58 Technology Salon issue 28 - anjuke quality assurance system Salon
- Introduction to smarttablayout
- shell脚本学习笔记——shell对文件的操作sed
- 【无极低码】低代码平台开发日记,低代码平台之sql编程
- shell脚本学习——实战案例
- One question per day: improve the mold assembly on the 15th day of sprint in the big factory
猜你喜欢

vscode的插件

qt designer 跳转,布局,样式

Click, walk and move of characters in 3D sandbox game

SQL requirements processing - count the number of Mondays to Sundays in a given year

7-34 delete duplicate characters (set usage) & 7-35 count the number of characters (unordered_map)

Airtest installation and introduction

PWM output of STM32 to steering gear sg90

Experiment 1: introduction to data science -- data science cognition

Nacos Foundation (3): open API configuration management test and close Nacos service

Anhydrous glucose CAS: 50-99-7 D (+) - glucose molecular weight: 180.156 molecular formula: C6H12O6 density and boiling point value
随机推荐
oh-my-notepro
kubernetes学习笔记
The collection palette in LabVIEW 2012 is imported into LabVIEW 2013
Nacos Foundation (4): configure the external database of Nacos
BLDC双闭环(速度PI+电流PI)simulink仿真模型
CAS: 36530-06-0 boron chloride phthalocyanine | phthalocyanine | boron chloride phthalocyanine | dichloroboron phthalocyanine dye | boron chloride phthalocyanine | boronsubphalocyaninichloride
The industrialization of SCRM has accelerated, and the manufacturing industry has begun to play with private traffic
CPU的基本工作流程
pyqt5使用内置数据库sqllite
Is NFT just a beautiful foam?
vscode的插件
PWM output of STM32 to steering gear sg90
3-1 比较大小
ViewPager用法详细解析
Redis非关系型数据库—Redis高可用、持久化及性能管理
微服务(分布式架构)
手把手教你实现RecyclerView的下拉刷新和上拉加载更多
Variante rapide: trouver le nombre maximum de K premiers
Click, walk and move of characters in 3D sandbox game
js再学习