其他分享
首页 > 其他分享> > 首次使用Cesium加载3D数据成功

首次使用Cesium加载3D数据成功

作者:互联网

接此;

https://blog.csdn.net/bcbobo21cn/article/details/111305160

`代码同前文;加载不同的数据,都不能加载出来;

var palaceTileset = new Cesium.Cesium3DTileset({
//url: './SampleData/Cesium3DTiles/Classification/Photogrammetry/tileset.json'
//url: './SampleData/Cesium3DTiles/Batched/BatchedColors/tileset.json'
//url: './SampleData/Cesium3DTiles/PointCloud/PointCloudConstantColor/tileset.json'
url: './SampleData/Cesium3DTiles/Tilesets/Tileset/tileset.json'
//url: './SampleData/Cesium3DTiles/Tilesets/Tileset/parent.b3dm'
//或者url: 'http://ip:port/www/DAEPalace/tileset.json'
});

然后更改代码为如下;

<script>
      

var viewer = new Cesium.Viewer("cesiumContainer");
 
var tileset = window.viewer.scene.primitives.add(
      new Cesium.Cesium3DTileset({
         //url: './SampleData/Cesium3DTiles/Classification/Photogrammetry/tileset.json'
         //url: './SampleData/Cesium3DTiles/Batched/BatchedColors/tileset.json'
         //url: './SampleData/Cesium3DTiles/PointCloud/PointCloudConstantColor/tileset.json'
         url: './SampleData/Cesium3DTiles/Tilesets/Tileset/tileset.json'
       })
     )
     tileset.readyPromise
      .then(function() {
         var boundingSphere = tileset.boundingSphere
         window.viewer.camera.viewBoundingSphere(boundingSphere, new Cesium.HeadingPitchRange(0.0, -0.5, 

boundingSphere.radius))
       window.viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY)
      })
      .otherwise(function(error) {
        throw error
      })
 
</script>

然后3D Tiles数据加载出来了;下面是不同的3D Tiles数据;

不同的3D Tiles数据;

都能加载;只有点云的那个不显示;

把自己的3D数据转换为它的3D Tiles数据,应该就能加载了;网上查转换工具;

标签:tileset,url,Cesium3DTiles,SampleData,json,Cesium,3D,加载
来源: https://blog.csdn.net/bcbobo21cn/article/details/112464630