当前位置:网站首页>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一同使用)。
边栏推荐
- 伯努利分布,二项分布和泊松分布以及最大似然之间的关系(未完成)
- [teacher Zhao Yuqiang] MySQL flashback
- Introduction to redis using Lua script
- [function explanation (Part 1)] | | knowledge sorting + code analysis + graphic interpretation
- Bernoulli distribution, binomial distribution and Poisson distribution, and the relationship between maximum likelihood (incomplete)
- Solve the problem that Anaconda environment cannot be accessed in PowerShell
- Niuke JS separator
- Strategy pattern: encapsulate changes and respond flexibly to changes in requirements
- Core principles and source code analysis of disruptor
- CKA certification notes - CKA certification experience post
猜你喜欢

Kubernetes resource object introduction and common commands (V) - (configmap)

Analysis of Clickhouse mergetree principle

Kubernetes notes (VI) kubernetes storage

Configure DTD of XML file

Solve the 1251 client does not support authentication protocol error of Navicat for MySQL connection MySQL 8.0.11

Understand one-way hash function

Personal outlook | looking forward to the future from Xiaobai's self analysis and future planning

Maximum likelihood estimation, divergence, cross entropy

Kubernetes notes (VII) kuberetes scheduling
![[teacher Zhao Yuqiang] index in mongodb (Part 1)](/img/2d/277ec737f2a7065831a19d036e61e1.jpg)
[teacher Zhao Yuqiang] index in mongodb (Part 1)
随机推荐
Leetcode solution - 01 Two Sum
[minesweeping of two-dimensional array application] | [simple version] [detailed steps + code]
Intel's new GPU patent shows that its graphics card products will use MCM Packaging Technology
理解 YOLOV1 第一篇 预测阶段
Clickhouse learning notes (I): Clickhouse installation, data type, table engine, SQL operation
The server data is all gone! Thinking caused by a RAID5 crash
[teacher Zhao Yuqiang] Alibaba cloud big data ACP certified Alibaba big data product system
[teacher Zhao Yuqiang] the most detailed introduction to PostgreSQL architecture in history
Kubernetes notes (II) pod usage notes
Btrfs and ext4 - features, strengths and weaknesses
Redhat7系统root用户密码破解
Solve the problem of automatic disconnection of SecureCRT timeout connection
深度学习,从一维特性输入到多维特征输入引发的思考
Troubleshooting of 32GB Jetson Orin SOM failure to brush
项目总结--04
JDBC connection database steps
从小数据量 MySQL 迁移数据到 TiDB
[teacher Zhao Yuqiang] index in mongodb (Part 1)
Sorry, this user does not exist!
Final review (Day5)