当前位置:网站首页>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 ).
边栏推荐
- Code generator - single table query crud - generator
- Simple solution of small up main lottery in station B
- How does win7 solve the problem that telnet is not an internal or external command
- Kubesphere - build MySQL master-slave replication structure
- Zhiniu stock project -- 04
- phpstudy设置项目可以由局域网的其他电脑可以访问
- Tabbar settings
- 技术管理进阶——你了解成长的全貌吗?
- Bernoulli distribution, binomial distribution and Poisson distribution, and the relationship between maximum likelihood (incomplete)
- Kubernetes notes (VI) kubernetes storage
猜你喜欢

Project summary --01 (addition, deletion, modification and query of interfaces; use of multithreading)

QT read write excel -- qxlsx insert chart 5

Kubernetes notes (IV) kubernetes network
![[teacher Zhao Yuqiang] use Oracle's tracking file](/img/0e/698478876d0dbfb37904d7b9ff9aca.jpg)
[teacher Zhao Yuqiang] use Oracle's tracking file

有意思的鼠标指针交互探究

Maximum likelihood estimation, divergence, cross entropy

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

卷积神经网络CNN中的卷积操作详解

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

多线程与高并发(7)——从ReentrantLock到AQS源码(两万字大章,一篇理解AQS)
随机推荐
The programmer shell with a monthly salary of more than 10000 becomes a grammar skill for secondary school. Do you often use it!!!
Ext4 vs XFS -- which file system should you use
There is no one of the necessary magic skills PXE for old drivers to install!!!
Analysis of Clickhouse mergetree principle
Zhiniu stock -- 03
1. Somme des deux nombres
Synthetic keyword and NBAC mechanism
Kubesphere - Multi tenant management
Simple solution of small up main lottery in station B
Apple submitted the new MAC model to the regulatory database before the spring conference
[teacher Zhao Yuqiang] MySQL flashback
Complete set of C language file operation functions (super detailed)
Why should there be a firewall? This time xiaowai has something to say!!!
Tabbar settings
Pytorch dataloader implements minibatch (incomplete)
QT read write excel -- qxlsx insert chart 5
pytorch 搭建神经网络最简版
Kubesphere - set up redis cluster
智牛股项目--05
Disruptor learning notes: basic use, core concepts and principles