当前位置:网站首页>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一同使用)。
边栏推荐
- Clickhouse learning notes (I): Clickhouse installation, data type, table engine, SQL operation
- [teacher Zhao Yuqiang] kubernetes' probe
- 项目总结--04
- 最大似然估计,散度,交叉熵
- [teacher Zhao Yuqiang] calculate aggregation using MapReduce in mongodb
- MySQL startup error: several solutions to the server quit without updating PID file
- 70 shell script interview questions and answers
- [written examination question analysis] | | get [sizeof and strlen] [pointer and array] graphic explanation + code analysis
- Txt document download save as solution
- Apache+php+mysql environment construction is super detailed!!!
猜你喜欢

Simple handwritten ORM framework

Redhat7 system root user password cracking

PHP notes are super detailed!!!

Capacity expansion mechanism of map

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

深度学习,从一维特性输入到多维特征输入引发的思考

Kubernetes notes (IV) kubernetes network

项目总结--2(Jsoup的基本使用)
![[teacher Zhao Yuqiang] use Oracle's tracking file](/img/0e/698478876d0dbfb37904d7b9ff9aca.jpg)
[teacher Zhao Yuqiang] use Oracle's tracking file

Solve the 1251 client does not support authentication protocol error of Navicat for MySQL connection MySQL 8.0.11
随机推荐
Redhat7系统root用户密码破解
深度学习,从一维特性输入到多维特征输入引发的思考
Jackson: what if there is a lack of property- Jackson: What happens if a property is missing?
The server data is all gone! Thinking caused by a RAID5 crash
Alibaba cloud OOS file upload
Niuke JS separator
Final review Day8
Why should there be a firewall? This time xiaowai has something to say!!!
Virtual memory technology sharing
Solve the problem that Anaconda environment cannot be accessed in PowerShell
Loss function in pytorch multi classification
[trivia of two-dimensional array application] | [simple version] [detailed steps + code]
[teacher Zhao Yuqiang] RDB persistence of redis
Kubernetes notes (I) kubernetes cluster architecture
Disruptor learning notes: basic use, core concepts and principles
The most responsible command line beautification tutorial
Apache+php+mysql environment construction is super detailed!!!
Kubernetes notes (II) pod usage notes
Kubernetes notes (VI) kubernetes storage
Leetcode solution - 02 Add Two Numbers