当前位置:网站首页>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 ).
边栏推荐
- Svn branch management
- Migrate data from Amazon aurora to tidb
- Alibaba cloud Alipay sandbox payment
- 卷积神经网络CNN中的卷积操作详解
- Beandefinitionregistrypostprocessor
- Kubernetes notes (VII) kuberetes scheduling
- Oauth2.0 - use database to store client information and authorization code
- BeanDefinitionRegistryPostProcessor
- Yum is too slow to bear? That's because you didn't do it
- Oauth2.0 - using JWT to replace token and JWT content enhancement
猜你喜欢
多线程与高并发(7)——从ReentrantLock到AQS源码(两万字大章,一篇理解AQS)
Detailed explanation of contextclassloader
理解 YOLOV1 第一篇 预测阶段
Zhiniu stock project -- 04
Cesium 点击获三维坐标(经纬度高程)
pytorch DataLoader实现miniBatch(未完成)
Kubernetes notes (III) controller
最大似然估计,散度,交叉熵
Exception when introducing redistemplate: noclassdeffounderror: com/fasterxml/jackson/core/jsonprocessingexception
QT read write excel -- qxlsx insert chart 5
随机推荐
智牛股--03
[teacher Zhao Yuqiang] kubernetes' probe
Deep learning, thinking from one dimensional input to multi-dimensional feature input
Kubesphere - build Nacos cluster
Apple submitted the new MAC model to the regulatory database before the spring conference
Download the corresponding version of chromedriver
MySQL 5.7.32-winx64 installation tutorial (support installing multiple MySQL services on one host)
ThreadLocal的简单理解
Kubernetes notes (VI) kubernetes storage
深入解析kubernetes controller-runtime
BeanDefinitionRegistryPostProcessor
1. 兩數之和
[teacher Zhao Yuqiang] RDB persistence of redis
Leetcode solution - 02 Add Two Numbers
理解 期望(均值/估计值)和方差
Solve the problem of automatic disconnection of SecureCRT timeout connection
The server data is all gone! Thinking caused by a RAID5 crash
1. Sum of two numbers
Kubernetes notes (V) configuration management
When PHP uses env to obtain file parameters, it gets strings