当前位置:网站首页>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 ).
边栏推荐
- 使用 Abp.Zero 搭建第三方登录模块(一):原理篇
- Characteristics and isolation level of database
- 理解 YOLOV1 第一篇 预测阶段
- [teacher Zhao Yuqiang] RDB persistence of redis
- Oauth2.0 - use database to store client information and authorization code
- Apple submitted the new MAC model to the regulatory database before the spring conference
- Tabbar settings
- Crontab command usage
- [teacher Zhao Yuqiang] Flink's dataset operator
- ThreadLocal的简单理解
猜你喜欢

Understand expectations (mean / estimate) and variances

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

Life is a process of continuous learning

Solve the problem of automatic disconnection of SecureCRT timeout connection

Simple solution of small up main lottery in station B

Clickhouse learning notes (I): Clickhouse installation, data type, table engine, SQL operation

Why is the website slow to open?

Kubernetes notes (10) kubernetes Monitoring & debugging

为什么网站打开速度慢?

Method of converting GPS coordinates to Baidu map coordinates
随机推荐
使用 Abp.Zero 搭建第三方登录模块(一):原理篇
卷积神经网络CNN中的卷积操作详解
1. Somme des deux nombres
为什么网站打开速度慢?
QT read write excel -- qxlsx insert chart 5
70 shell script interview questions and answers
Redhat7 system root user password cracking
輕松上手Fluentd,結合 Rainbond 插件市場,日志收集更快捷
Kubernetes notes (VIII) kubernetes security
[teacher Zhao Yuqiang] Cassandra foundation of NoSQL database
Maximum likelihood estimation, divergence, cross entropy
Understand the first prediction stage of yolov1
Oauth2.0 - explanation of simplified mode, password mode and client mode
The server data is all gone! Thinking caused by a RAID5 crash
理解 YOLOV1 第一篇 预测阶段
[Zhao Yuqiang] deploy kubernetes cluster with binary package
How does win7 solve the problem that telnet is not an internal or external command
Kubernetes notes (II) pod usage notes
[teacher Zhao Yuqiang] use the catalog database of Oracle
Beandefinitionregistrypostprocessor