当前位置:网站首页>Cesium 点击获取模型表面经纬度高程坐标(三维坐标)
Cesium 点击获取模型表面经纬度高程坐标(三维坐标)
2022-07-03 06:03:00 【最凶残的小海豹】
下面代码适用于 模型表面 三维坐标。
注意:
- 下面代码只适用于模型、倾斜摄影等表面坐标获取(地形三维坐标情况我其他文章)
- 需要开启深度检测
depthTestAgainstTerrain = true。
// 开启深度检测
viewer.scene.globe.depthTestAgainstTerrain = true
var handler = new Cesium.ScreenSpaceEventHandler(gvEarth.scene.canvas);
handler.setInputAction(function (evt) {
var scene = gvEarth.scene;
// 判断场景的模式,不能是 变形模式
if (scene.mode !== Cesium.SceneMode.MORPHING) {
// scene.pick: 返回scene中指定位置的顶端的primitive属性的一个对象
let pickedObject = scene.pick(evt.position);
// 判断是否拾取到模型
if (scene.pickPositionSupported && Cesium.defined(pickedObject) && pickedObject.node) {
let cartesian = gvEarth.scene.pickPosition(evt.position);
// 是否获取到空间坐标
if (Cesium.defined(cartesian)) {
// // 空间坐标转世界坐标(弧度)
let cartographic = Cesium.Cartographic.fromCartesian(cartesian);
// 弧度转为角度(经纬度)
let lon = Cesium.Math.toDegrees(cartographic.longitude);
let lat = Cesium.Math.toDegrees(cartographic.latitude);
//模型高度
let height = cartographic.height;
console.log('模型表面的经纬度高程是:', {
x: lon, y: lat, height: height })
}
}
}
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);

说明一下:
viewer.scene.pickPosition(e.position)在没有3dTile模型下的笛卡尔坐标不准问题,可以通过开启深度检测解决 viewer.scene.globe.depthTestAgainstTerrain = true
viewer.scene.pick: 返回scene中指定位置的顶端的primitive属性的一个对象。适用于选取3dTile,改变3dTile的属性(例如颜色)。
viewer.scene.pickPosition: 返回一个被屏幕坐标和深度缓存指定的点。适用于模型表面位置的选取,通俗的说就是camera看过去第一个被挡住的模型(如entity)上的坐标,通常结合其他的选取方式一块用于选取模型和球上的点(结合viewer.scene.pick一同使用)。
边栏推荐
- Jetson AgX Orin platform porting ar0233 gw5200 max9295 camera driver
- [teacher Zhao Yuqiang] index in mongodb (Part 1)
- 项目总结--2(Jsoup的基本使用)
- Kubernetes notes (I) kubernetes cluster architecture
- If function of MySQL
- [set theory] relational closure (reflexive closure | symmetric closure | transitive closure)
- Leetcode solution - 01 Two Sum
- 多线程与高并发(7)——从ReentrantLock到AQS源码(两万字大章,一篇理解AQS)
- 1. 两数之和
- Why should there be a firewall? This time xiaowai has something to say!!!
猜你喜欢

Redhat7 system root user password cracking

Error 1045 (28000) occurs when Linux logs in MySQL: access denied for user 'root' @ 'localhost' (using password: yes)

Kubernetes notes (VI) kubernetes storage
![[explain in depth the creation and destruction of function stack frames] | detailed analysis + graphic analysis](/img/df/884313a69fb1e613aec3497800f7ba.jpg)
[explain in depth the creation and destruction of function stack frames] | detailed analysis + graphic analysis

Kubernetes notes (IV) kubernetes network

从小数据量 MySQL 迁移数据到 TiDB

Clickhouse learning notes (I): Clickhouse installation, data type, table engine, SQL operation
![[trivia of two-dimensional array application] | [simple version] [detailed steps + code]](/img/84/98c1220d0f7bc3a948125ead6ff3d9.jpg)
[trivia of two-dimensional array application] | [simple version] [detailed steps + code]

多线程与高并发(7)——从ReentrantLock到AQS源码(两万字大章,一篇理解AQS)

Pytorch dataloader implements minibatch (incomplete)
随机推荐
JDBC connection database steps
[set theory] relational closure (reflexive closure | symmetric closure | transitive closure)
Detailed explanation of iptables (1): iptables concept
Configure DTD of XML file
Understand expectations (mean / estimate) and variances
最大似然估计,散度,交叉熵
JS implements the problem of closing the current child window and refreshing the parent window
Loss function in pytorch multi classification
[teacher Zhao Yuqiang] index in mongodb (Part 1)
Kubernetes notes (I) kubernetes cluster architecture
[teacher Zhao Yuqiang] the most detailed introduction to PostgreSQL architecture in history
Ansible firewall firewalld setting
If function of MySQL
Apple submitted the new MAC model to the regulatory database before the spring conference
[untitled]
MySQL startup error: several solutions to the server quit without updating PID file
pytorch 搭建神经网络最简版
1. Sum of two numbers
Multithreading and high concurrency (7) -- from reentrantlock to AQS source code (20000 words, one understanding AQS)
[teacher Zhao Yuqiang] use the catalog database of Oracle