Cesium-terrain-builder编译入坑详解

本以为编译cesium-terrian-tools编译应该没那么难,不想问题重重,不想后人重蹈覆辙,也记录下点点滴滴。

编译geo-data版本

链接编译,无法link GDALCreateOverviewDataset,gdal版本不对,可以暂行注释掉,应该是个扩展功能可以不管

复制代码
      //poSrcOvrDS = GDALCreateOverviewDataset( poSrcDS, iOvr, FALSE);
          poSrcOvrDS = nullptr;// GDALCreateOverviewDataset(poSrcDS, iOvr, FALSE, FALSE);
        }

ahuarte47 版本

  • git clone 后,记得要切换到最新代码,默认没有切换到最新代码,【坑】

  • gdal 307 或gdal204 使用时,可能出现部分重载函数声明不一致,需要改ctb源码即可解决

  • 网上其他设置:

    • 中文支持: GDALAllRegister后添加CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "NO");
  • cesium 发布地形,默认需要关闭gzip,才可以被cesium加载

  • 发布命令:

    cmd 复制代码
    ctb-tile.exe  --output-dir  H:/ctb_output   H:/shenzhen_dem/L15/shenzhen_dem.tif  -f Mesh
    • 生成layer
    cmd 复制代码
    ctb-tile.exe --gzip --output-dir  H:/ctb_output   H:/shenzhen_dem/L15/shenzhen_dem.tif  -f Mesh -l

上图为证:

Cesium-1.106版本加载terrian

cesium测试代码:

html 复制代码
<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        html,
        body,
        #cesiumContainer {
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
            overflow: hidden;
        }
    </style>
    <!-- Include the CesiumJS JavaScript and CSS files -->
    <script src="../Build/CesiumUnminified/Cesium.js"></script>
    <style>
        @import url(../Build/CesiumUnminified/Widgets/widgets.css);

        html,
        body,
        #cesiumContainer {
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
            overflow: hidden;
        }
    </style>
</head>
 
<body>
    <div id="cesiumContainer"></div>
    <script>
        Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI0NzkzYjFkNi1mODZhLTRkNjAtYWE1YS1jYzE5NzBjNjhkNjciLCJpZCI6MTQyMjI1LCJpYXQiOjE2ODYyMzUxODl9.l8y5SN0ALIwPZh9eM8Al14DBpfMjHdeG7uqb69tH6nU';
        <!-- const viewer = new Cesium.Viewer('cesiumContainer'); -->
		
		const viewer = new Cesium.Viewer('cesiumContainer', {
        terrainProvider: new Cesium.EllipsoidTerrainProvider({}),//移除自带地形
        baseLayerPicker:false,
        homeButton:false,
        infoBox:false,
        timeline:false,
        navigationHelpButton:false,
        geocoder:false,
        sceneModePicker:false,
        animation:false,
        fullscreenButton:false
      });

		 //viewer.imageryLayers.removeAll();
        var terrainProvider = new Cesium.CesiumTerrainProvider({
  
			url: './ctb_shenzhen_nogzip/'

        });

        viewer.scene.terrainProvider = terrainProvider;
        viewer.camera.flyTo({
            //destination: Cesium.Cartesian3.fromDegrees(121.8040466308, 29.9597, 2500)
			// 深圳
            destination: Cesium.Cartesian3.fromDegrees(114.1040466308, 22.5, 2500)
        });  
    </script>
</body>
 
</html>
## 参考:

[基于Docker使用CTB生成地形切片并加载 - 当时明月在曾照彩云归 - 博客园 (cnblogs.com)](https://www.cnblogs.com/jiujiubashiyi/p/17104115.html)

非压缩:[Cesium地形切片--CTB(cesium-terrain-builder)填坑指南 - 知乎 (zhihu.com)](
相关推荐
灵境(虚幻知音)5 小时前
Cesium动态轨迹性能瓶颈深度拆解:翼带与尾迹的底层优化实践
性能优化·cesium·3d引擎·afsim·翼带·尾迹·自定义着色器
fxshy2 天前
WebGIS 游戏化实践:基于 Cesium + Vue3 实现全球飞行模拟系统:从球体坐标、飞行动力学到地形碰撞实战
游戏·vue3·cesium·webgis·飞行模拟
用户83134859306983 天前
Cesium实现动态流动火烧云晚霞效果(可用slider调整火烧云浓度)
vue.js·webgl·cesium
CBX5 天前
Cesium 入门实战:GeoJSON 数据加载与地区边界可视化
cesium
毕安格 - BimAngle11 天前
国家电网 GIM 格式模型一键输出 3D Tiles (for Cesium) 和 glTF/glb 更新时间:2026-08-18
3d·gis·cesium·gltf·glb·3d tiles·gim
探索前端12 天前
3dtiles加载时被地形遮挡问题研究及处理思路
前端·3d·cesium
兔年鸿运Q小Q22 天前
cesium1.140以上版本加载地形
arcgis·cesium
用户831348593069823 天前
Vue3+Cesium实现阴天乌云+下雨天气特效
vue.js·webgl·cesium
REDcker1 个月前
Cesium三维WebGIS入门详解
前端·gis·web·cesium·webgis
用户83134859306981 个月前
Cesium 实现行政区内部遮罩
vue.js·webgl·cesium