当前位置:网站首页>Cesium Click to obtain the longitude and latitude elevation coordinates (3D coordinates) of the model surface
Cesium Click to obtain the longitude and latitude elevation coordinates (3D coordinates) of the model surface
2022-07-03 06:08:00 【The most ferocious little seal】
The following code applies to Model surface Three dimensional coordinates .
Be careful :
- The following code only applies to models 、 Acquisition of surface coordinates such as tilt photography ( Terrain three-dimensional coordinates of my other articles )
- Depth detection needs to be turned on
depthTestAgainstTerrain = true
.
// Open depth detection
viewer.scene.globe.depthTestAgainstTerrain = true
var handler = new Cesium.ScreenSpaceEventHandler(gvEarth.scene.canvas);
handler.setInputAction(function (evt) {
var scene = gvEarth.scene;
// Judge the mode of the scene , It can't be Deformation mode
if (scene.mode !== Cesium.SceneMode.MORPHING) {
// scene.pick: return scene At the top of the specified position in primitive An object of property
let pickedObject = scene.pick(evt.position);
// Determine if the model is picked up
if (scene.pickPositionSupported && Cesium.defined(pickedObject) && pickedObject.node) {
let cartesian = gvEarth.scene.pickPosition(evt.position);
// Whether spatial coordinates are obtained
if (Cesium.defined(cartesian)) {
// // Space coordinates to world coordinates ( radian )
let cartographic = Cesium.Cartographic.fromCartesian(cartesian);
// Radian to angle ( Longitude and latitude )
let lon = Cesium.Math.toDegrees(cartographic.longitude);
let lat = Cesium.Math.toDegrees(cartographic.latitude);
// Model height
let height = cartographic.height;
console.log(' The longitude and latitude elevation of the model surface is :', {
x: lon, y: lat, height: height })
}
}
}
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
Explain :
viewer.scene.pickPosition(e.position) In the absence of 3dTile The problem of Cartesian coordinates inaccuracy under the model , It can be solved by opening depth detection viewer.scene.globe.depthTestAgainstTerrain = true
viewer.scene.pick: return scene
At the top of the specified position in primitive An object of property . Applicable to selection 3dTile, change 3dTile Properties of ( Such as color ).
viewer.scene.pickPosition: Returns a point specified by the screen coordinates and depth cache . It is applicable to the selection of model surface position , Generally speaking, it means camera Look at the first blocked model ( Such as entity) The coordinates on , Usually combined with other selection methods, it is used to select the points on the model and ball ( combination viewer.scene.pick Use together ).
边栏推荐
- 从小数据量 MySQL 迁移数据到 TiDB
- [teacher Zhao Yuqiang] index in mongodb (Part 2)
- Cesium 点击获三维坐标(经纬度高程)
- Fluentd is easy to use. Combined with the rainbow plug-in market, log collection is faster
- 1. Somme des deux nombres
- It is said that the operation and maintenance of shell scripts are paid tens of thousands of yuan a month!!!
- 1. Sum of two numbers
- phpstudy设置项目可以由局域网的其他电脑可以访问
- BeanDefinitionRegistryPostProcessor
- Leetcode solution - 01 Two Sum
猜你喜欢
Convolution operation in convolution neural network CNN
Es remote cluster configuration and cross cluster search
Kubernetes notes (I) kubernetes cluster architecture
.NET程序配置文件操作(ini,cfg,config)
Analysis of Clickhouse mergetree principle
【系统设计】邻近服务
Synthetic keyword and NBAC mechanism
Zhiniu stock project -- 05
Loss function in pytorch multi classification
Method of converting GPS coordinates to Baidu map coordinates
随机推荐
Installation du plug - in CAD et chargement automatique DLL, Arx
Project summary --2 (basic use of jsup)
@Import annotation: four ways to import configuration classes & source code analysis
Installation of CAD plug-ins and automatic loading of DLL and ARX
项目总结--01(接口的增删改查;多线程的使用)
Apt update and apt upgrade commands - what is the difference?
【系统设计】邻近服务
Solve the 1251 client does not support authentication protocol error of Navicat for MySQL connection MySQL 8.0.11
PHP用ENV获取文件参数的时候拿到的是字符串
Core principles and source code analysis of disruptor
Detailed explanation of findloadedclass
CAD插件的安裝和自動加載dll、arx
项目总结--04
Why should there be a firewall? This time xiaowai has something to say!!!
[teacher Zhao Yuqiang] index in mongodb (Part 2)
GPS坐标转百度地图坐标的方法
有意思的鼠标指针交互探究
Method of converting GPS coordinates to Baidu map coordinates
[Zhao Yuqiang] deploy kubernetes cluster with binary package
Disruptor learning notes: basic use, core concepts and principles