当前位置:网站首页>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 ).
边栏推荐
- BeanDefinitionRegistryPostProcessor
- [teacher Zhao Yuqiang] Flink's dataset operator
- What's the difference between using the Service Worker Cache API and regular browser cache?
- Fluentd facile à utiliser avec le marché des plug - ins rainbond pour une collecte de journaux plus rapide
- [teacher Zhao Yuqiang] MySQL high availability architecture: MHA
- 卷积神经网络CNN中的卷积操作详解
- 88. Merge two ordered arrays
- Installation du plug - in CAD et chargement automatique DLL, Arx
- Detailed explanation of contextclassloader
- When PHP uses env to obtain file parameters, it gets strings
猜你喜欢

Oauth2.0 - Introduction and use and explanation of authorization code mode

Tabbar settings

Kubernetes notes (IV) kubernetes network

Exception when introducing redistemplate: noclassdeffounderror: com/fasterxml/jackson/core/jsonprocessingexception

Kubernetes notes (VI) kubernetes storage

Zhiniu stock project -- 04

有意思的鼠标指针交互探究
![[video of Teacher Zhao Yuqiang's speech on wot] redis high performance cache and persistence](/img/a7/2140744ebad9f1dc0a609254cc618e.jpg)
[video of Teacher Zhao Yuqiang's speech on wot] redis high performance cache and persistence

MySQL 5.7.32-winx64 installation tutorial (support installing multiple MySQL services on one host)

Clickhouse learning notes (I): Clickhouse installation, data type, table engine, SQL operation
随机推荐
Why should there be a firewall? This time xiaowai has something to say!!!
Fluentd is easy to use. Combined with the rainbow plug-in market, log collection is faster
轻松上手Fluentd,结合 Rainbond 插件市场,日志收集更快捷
Mysql database table export and import with binary
GPS坐标转百度地图坐标的方法
Detailed explanation of iptables (1): iptables concept
理解 YOLOV1 第一篇 预测阶段
BeanDefinitionRegistryPostProcessor
Jedis source code analysis (II): jediscluster module source code analysis
Deep learning, thinking from one dimensional input to multi-dimensional feature input
Detailed explanation of findloadedclass
How does win7 solve the problem that telnet is not an internal or external command
Btrfs and ext4 - features, strengths and weaknesses
[teacher Zhao Yuqiang] index in mongodb (Part 1)
@Import annotation: four ways to import configuration classes & source code analysis
Cesium 点击获取模型表面经纬度高程坐标(三维坐标)
[teacher Zhao Yuqiang] Flink's dataset operator
Skywalking8.7 source code analysis (II): Custom agent, service loading, witness component version identification, transform workflow
BeanDefinitionRegistryPostProcessor
智牛股--03