当前位置:网站首页>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 ).
边栏推荐
- What's the difference between using the Service Worker Cache API and regular browser cache?
- Zhiniu stock project -- 04
- CKA certification notes - CKA certification experience post
- Solve the problem of automatic disconnection of SecureCRT timeout connection
- Kubesphere - build MySQL master-slave replication structure
- Pytorch dataloader implements minibatch (incomplete)
- Multithreading and high concurrency (7) -- from reentrantlock to AQS source code (20000 words, one understanding AQS)
- Cesium 点击获取模型表面经纬度高程坐标(三维坐标)
- [Zhao Yuqiang] deploy kubernetes cluster with binary package
- Using the ethtool command by example
猜你喜欢

Core principles and source code analysis of disruptor

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

Project summary --04

Zhiniu stock project -- 05

Fluentd facile à utiliser avec le marché des plug - ins rainbond pour une collecte de journaux plus rapide

Oauth2.0 - use database to store client information and authorization code
![[Zhao Yuqiang] deploy kubernetes cluster with binary package](/img/cc/5509b62756dddc6e5d4facbc6a7c5f.jpg)
[Zhao Yuqiang] deploy kubernetes cluster with binary package

Kubernetes notes (IV) kubernetes network
![[teacher Zhao Yuqiang] MySQL flashback](/img/93/75998e28fd309880661ea723dc8de6.jpg)
[teacher Zhao Yuqiang] MySQL flashback

Convolution operation in convolution neural network CNN
随机推荐
[teacher Zhao Yuqiang] the most detailed introduction to PostgreSQL architecture in history
Beandefinitionregistrypostprocessor
JS implements the problem of closing the current child window and refreshing the parent window
PMP笔记记录
Alibaba cloud OOS file upload
When PHP uses env to obtain file parameters, it gets strings
Project summary --01 (addition, deletion, modification and query of interfaces; use of multithreading)
PMP notes
Life is a process of continuous learning
Installation of CAD plug-ins and automatic loading of DLL and ARX
Zhiniu stock project -- 05
88. Merge two ordered arrays
Deep learning, thinking from one dimensional input to multi-dimensional feature input
Kubesphere - Multi tenant management
Using the ethtool command by example
1. Sum of two numbers
Virtual memory technology sharing
智牛股--03
arcgis创建postgre企业级数据库
Cesium 点击获取模型表面经纬度高程坐标(三维坐标)