其他分享
首页 > 其他分享> > Supermap IClient3D 加载3DTiles倾斜摄影数据

Supermap IClient3D 加载3DTiles倾斜摄影数据

作者:互联网

由于倾斜摄影数据默认的地理坐标系与超图的坐标系不一样。

  var obj = [6378137.0, 6378137.0, 6356752.3142451793];
  Cesium.Ellipsoid.WGS84 = Object.freeze(new Cesium.Ellipsoid(obj[0], obj[1], obj[2]));
var viewer, url;
   viewer = new Cesium.Viewer('cesiumContainer');
   var scene = viewer.scene;
//模型地址 url = "http://172.23.50.51:8090/iserver/services/3D-CeShi2/rest/realspace"; var promise = scene.open(url); Cesium.when(promise, function (layer) { //设置相机位置、视角,便于观察场景 scene.camera.setView({ destination: new Cesium.Cartesian3.fromDegrees(cameraPosition.longitude, cameraPosition.latitude, cameraPosition.altitude), orientation: { heading: cameraPosition.heading, pitch: tilt, roll: 0 } }); if (!scene.pickPositionSupported) { alert('不支持深度纹理,无法拾取位置!'); } }, function (e) { if (widget._showRenderLoopErrors) { var title = '加载SCP失败,请检查网络连接状态或者url地址是否正确?'; widget.showErrorPanel(title, undefined, e); } });

3DTiles倾斜摄影模型

   try {
        var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({ url: 'https://localhost:5001/cl/tileset.json' }));
        // 修复偏移量
        tileset.readyPromise.then(function (tileset) {
            viewer.scene.primitives.add(tileset);

            var heightOffset = -220;  //高度
            var boundingSphere = tileset.boundingSphere;
            var cartographic = Cesium.Cartographic.fromCartesian(boundingSphere.center);
            var surface = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, 0.0);
            var offset = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, heightOffset);
            var translation = Cesium.Cartesian3.subtract(offset, surface, new Cesium.Cartesian3());
          //  tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
            viewer.zoomTo(tileset);
        }).otherwise(function (e) {
            throw e
        });

    } catch (e) {
        console.log(e);
    }

 

标签:Supermap,tileset,viewer,scene,IClient3D,Cesium,3DTiles,var,new
来源: https://www.cnblogs.com/w2011/p/14954277.html