threeMap.vue 4.23 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;
            scene.lightSource.ambientLightColor = new Cesium.Color(0.65, 0.65, 0.65, 1);

            this.$parent.draw = new createDraw(viewer);
            // this.$parent.viewer = viewer;
            objectManage.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' });
            promise[3] = scene.addS3MTilesLayerByScp(URL_CONFIG.SCP_CBD_LAKE, { name: 'lake' });
            // promise[4] = scene.addS3MTilesLayerByScp(URL_CONFIG.SCP_CBD_ROAD, { name: 'road' });
            // promise[5] = scene.addS3MTilesLayerByScp(URL_CONFIG.SCP_CBD_BRIDGE, {name: 'bridge'});
            promise[4] = scene.addS3MTilesLayerByScp(URL_CONFIG.SCP_CBD_TREE, { name : 'tree'});
            // promise[5] = scene.addS3MTilesLayerByScp(
            //     'http://localhost:8090/iserver/services/3D-scene/rest/realspace/datas/dcdata@dataSource/config', 
            //     { name : 'dcdata'}
            // );
            // promise[6] = scene.addS3MTilesLayerByScp(
            //     'http://localhost:8090/iserver/services/3D-scene/rest/realspace/datas/dcdata1@dataSource/config', 
            //     { name : 'dcdata1'}
            // );

            Cesium.when.all(promise, layers => {
                layers[0].shadowType = 2;
                layers[1].shadowType = 2;
                layers[2].shadowType = 2;
                layers[0].selectEnabled = false;
                layers[1].selectEnabled = false;
                layers[2].selectEnabled = false;
                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>