zoukankan      html  css  js  c++  java
  • Cesium高度解析

    var viewer = new Cesium.Viewer('cesiumContainer', {
        shadows : true
    });
    //为true时,球体会有高程遮挡效果(在没有地形时候也会有高程遮挡效果)
    viewer.scene.globe.depthTestAgainstTerrain = true;
    
    var viewModel = {
        height: 0
    };
    
    Cesium.knockout.track(viewModel);
    //获取左上角的toolbar
    var toolbar = document.getElementById('toolbar');
    Cesium.knockout.applyBindings(viewModel, toolbar);
    //添加 3D Tiles,url是路径
    var tileset = new Cesium.Cesium3DTileset({ url: Cesium.IonResource.fromAssetId(3883) });
    //tileset的根已经准备就绪
    tileset.readyPromise.then(function(tileset) {
        //在场景添加tileset
        viewer.scene.primitives.add(tileset);
        //zoomTo (target,offset)目标和偏移
        viewer.zoomTo(tileset, new Cesium.HeadingPitchRange(0.0, -0.5, tileset.boundingSphere.radius * 2.0));
    }).otherwise(function(error) {
        //若没有加载成功,提示错误
        console.log(error);
    });
    
    Cesium.knockout.getObservable(viewModel, 'height').subscribe(function(height) {
        height = Number(height);
        if (isNaN(height)) {
            return;
            }
    //地理位置
        var cartographic = Cesium.Cartographic.fromCartesian(tileset.boundingSphere.center);
        var surface = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, 0.0);
        var offset = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, height);
        var translation = Cesium.Cartesian3.subtract(offset, surface, new Cesium.Cartesian3());
        tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
    });

  • 相关阅读:
    WPF中ListBoxItem绑定一个UserControl的学习
    Server.Transfer和Response.Redirect的区别
    4个程序员的一天
    (转)让ADO.NET Entity Framework支持Oracle数据库
    IIS操作类
    HttpHandler与HttpModule区别
    网站性能优化的34条黄金法则
    oracle9i/10g/11g各种下载
    WCF简要介绍
    软件系统的稳定性
  • 原文地址:https://www.cnblogs.com/Yimi/p/8963869.html
Copyright © 2011-2022 走看看