threeMap.vue 3.15 KB
<template>
    <div>

        <div id="cesiumContainer" ref="cesium">
            <div id="vertical-slider" style="display: none;"></div>
            <div id="horizontal-slider" style="display: none;"></div>
        </div>

    </div>
</template>
<script>

    import objectManage from '../assets/js/map/maputils';
    import createDraw from '../assets/js/map/createDraw';
    import URL_CONFIG from "./../config/urlConfig.vue";
    const Cesium = window.Cesium;
    

    export default {
        components: {

        },
        data() {
            return {}
        },
        mounted() {
            let viewer = new Cesium.Viewer('cesiumContainer', {shadows : true});
            viewer.imageryLayers.addImageryProvider(new Cesium.TiandituImageryProvider({
                credit : new Cesium.Credit('天地图全球影像服务'),
                token: URL_CONFIG.TOKEN_TIANDITU
            }));
            let scene = viewer.scene
            scene.shadowMap.darkness = 1; //设置第二重烘焙纹理的效果(明暗程度)
            scene.skyAtmosphere.brightnessShift=0.4;
            scene.debugShowFramesPerSecond = true;
            scene.hdrEnabled = false;
            scene.sun.show = true;
            this.$parent.draw = new createDraw(viewer);
            this.$parent.viewer = viewer;

            var promise = [];
            promise[0] = scene.addS3MTilesLayerByScp(URL_CONFIG.SCP_CBD_BUILD, {
                name: 'build1'
            });
            promise[1] = scene.addS3MTilesLayerByScp(URL_CONFIG.SCP_CBD_BUILD, {
                name: 'build2'
            });
            promise[2] = scene.addS3MTilesLayerByScp(URL_CONFIG.SCP_CBD_GROUND1, {
                name: 'ground'
            });

            Cesium.when.all(promise, layers => {
                layers[1].shadowType = 2;
                layers[2].shadowType = 2;
                scene.camera.setView({
                    destination : Cesium.Cartesian3.fromDegrees(116.44621857300415, 39.899281526734555, 216.7793905027196),
                    orientation : {
                        heading : 0.41348036210986194,
                        pitch : -0.13636490404291735,
                        roll : 6.283185307179563
                    }
                });
            }, function(e){
                if (widget._showRenderLoopErrors) {
                    var title = '加载SCP失败,请检查网络连接状态或者url地址是否正确?';
                    widget.showErrorPanel(title, undefined, e);
                }
            });

        },
        methods: {
   
        }
    }
</script>

<style>
    html, body, #cesiumContainer {
        height: 100%;
        padding: 0;
        margin: 0;
    }

    .slider {
        position: absolute;
        left: 50%;
        top: 0px;
        background-color: #d3d3d3;
        width: 5px;
        height: 100%;
        z-index: 9999;
    }

    .slider:hover {
        cursor: ew-resize;
    }

    .home {
        position: relative;
        width: 100%;
        height: 100%;
    }
    .top {
        position: absolute;
        z-index: 1000;
        color: red;
        width: 100%;
        /* height: 86.5px; */
        height: 124.5px;
    }
</style>