Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does Cesium adjust the height of 3dtile

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "how Cesium adjusts the height of 3dtile". In daily operation, I believe many people have doubts about how to adjust the height of Cesium. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubt of "how to adjust the height of Cesium"! Next, please follow the editor to study!

In the process of making 3dtile, if the elevation of the model data exists in the original data, and the elevation information will also exist in the generated 3dtile, it is necessary to have the elevation of the base map data in the system in order to match with the 3dtile. However, the Cesium development document also provides a way to dynamically adjust the height of the 3dtile after the data is loaded, and there is a certain restriction that the height of the 3dtile as a whole can be adjusted. That is to change the overall elevation difference of the 3dtile.

API documentation reference: https://cesiumjs.org/Cesium/Build/Documentation/Cesium3DTileset.html

The specific implementation code is as follows:

/ / define viewer

Var viewer = new Cesium.Viewer ('cesiumContainer')

Var tileset = new Cesium.Cesium3DTileset ({

Url: '3dtile online address'

Show: true

});

/ / load 3dtile

Viewer.scene.primitives.add (tileset)

/ / execute after 3dtile loading is completed

Tileset.readyPromise.then (function (tileset) {

/ / locate to the location of 3dtiles

Viewer.camera.viewBoundingSphere (tileset.boundingSphere, new Cesium.HeadingPitchRange (0,-20,0))

/ / height deviation, positive up and negative down

Var heightOffset =-1063.0

/ / calculate the binding range of tileset

Var boundingSphere = tileset.boundingSphere

/ / calculate the location of the center point

Var cartographic = Cesium.Cartographic.fromCartesian (boundingSphere.center)

/ / calculate the surface coordinates of the central point

Var surface = Cesium.Cartesian3.fromRadians (cartographic.longitude, cartographic.latitude, 0.0)

/ / coordinates after offset

Var offset = Cesium.Cartesian3.fromRadians (cartographic.longitude, cartographic.latitude, heightOffset)

Var translation = Cesium.Cartesian3.subtract (offset, surface, new Cesium.Cartesian3 ())

/ / tileset.modelMatrix conversion

Tileset.modelMatrix = Cesium.Matrix4.fromTranslation (translation)

});

The effect is tested according to the real data, and the height has changed after the conversion, but if it is pulled too close, the model will not be displayed. You can test the effect according to the actual situation, or it is recommended to complete the height adjustment in the process of 3dtile generation. Without the conversion process, it can also improve the performance of the system.

At this point, the study on "how Cesium adjusts the height of 3dtile" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report