| | |
| | | function initViewer () { |
| | | global.viewer = new DC.Viewer('viewer-container') |
| | | |
| | | // 天地图 影像 |
| | | global.viewer.imageryLayers.addImageryProvider( |
| | | new global.DC.Namespace.Cesium.UrlTemplateImageryProvider({ |
| | | url: 'https://t{s}.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=789e558be762ff832392a0393fd8a4f1', |
| | | subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'], |
| | | format: 'image/jpeg', |
| | | show: true, |
| | | maximumLevel: 18 |
| | | }) |
| | | ) |
| | | |
| | | // 去除水印 |
| | | const primitiveArr = global.viewer.scene.primitives._primitives |
| | | global.viewer.scene.primitives.remove(primitiveArr[0]) |
| | | |
| | | global.viewer.camera.setView({ |
| | | // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州 |
| | | // fromDegrees()方法,将经纬度和高程转换为世界坐标 |
| | | destination: global.DC.Namespace.Cesium.Cartesian3.fromDegrees( |
| | | 116.027429, 28.681978, 800 |
| | | ), |
| | | orientation: { |
| | | // 指向 |
| | | heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0), |
| | | // 视角 |
| | | pitch: global.DC.Namespace.Cesium.Math.toRadians(-90), |
| | | roll: 0.0 |
| | | |
| | | global.viewer.setOptions({ |
| | | globe:{ |
| | | baseColor:DC.Color.BLACK |
| | | } |
| | | }) |
| | | // that.addBaseLayer() |
| | | let layer_build = new DC.TilesetLayer('layer_build').addTo(global.viewer) |
| | | let build = new DC.Tileset( |
| | | '//resource.dvgis.cn/data/3dtiles/ljz/tileset.json', |
| | | {skipLevels:true} |
| | | ) |
| | | let fs = ` |
| | | varying vec3 v_positionEC; |
| | | void main(void){ |
| | | vec4 position = czm_inverseModelView * vec4(v_positionEC,1); // 位置 |
| | | float glowRange = 100.0; // 光环的移动范围(高度) |
| | | gl_FragColor = vec4(0.2, 0.5, 1.0, 1.0); // 颜色 |
| | | gl_FragColor *= vec4(vec3(position.z / 100.0), 1.0); // 渐变 |
| | | // 动态光环 |
| | | float time = fract(czm_frameNumber / 360.0); |
| | | time = abs(time - 0.5) * 2.0; |
| | | float diff = step(0.005, abs( clamp(position.z / glowRange, 0.0, 1.0) - time)); |
| | | gl_FragColor.rgb += gl_FragColor.rgb * (1.0 - diff); |
| | | } |
| | | ` |
| | | build.setCustomShader(fs) |
| | | layer_build.addOverlay(build) |
| | | let layer = new DC.PrimitiveLayer('layer').addTo(global.viewer) |
| | | let positions = generatePosition(50,true) |
| | | positions = positions.concat(generatePosition(50,)) |
| | | positions.forEach(item=>{ |
| | | let position = DC.Position.fromObject(item) |
| | | let end = position.copy() |
| | | end.alt = 5000 * Math.random() |
| | | let line = new DC.FlowLinePrimitive([position,end],0.5) |
| | | line.setStyle({ |
| | | speed: 6 * Math.random(), |
| | | color: DC.Color.fromCssColorString("rgb(141,172,172)"), |
| | | percent:0.1, |
| | | gradient:0.01 |
| | | }) |
| | | layer.addOverlay(line) |
| | | }) |
| | | global.viewer.flyToPosition("121.4941629,31.2091462,1859.56,0,-28.71") |
| | | |
| | | global.viewer.use(new global.DC.Measure()) |
| | | // // 天地图 影像 |
| | | // global.viewer.imageryLayers.addImageryProvider( |
| | | // new global.DC.Namespace.Cesium.UrlTemplateImageryProvider({ |
| | | // url: 'https://t{s}.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=789e558be762ff832392a0393fd8a4f1', |
| | | // subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'], |
| | | // format: 'image/jpeg', |
| | | // show: true, |
| | | // maximumLevel: 18 |
| | | // }) |
| | | // ) |
| | | |
| | | // global.viewer.camera.setView({ |
| | | // // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州 |
| | | // // fromDegrees()方法,将经纬度和高程转换为世界坐标 |
| | | // destination: global.DC.Namespace.Cesium.Cartesian3.fromDegrees( |
| | | // 116.027429, 28.681978, 800 |
| | | // ), |
| | | // orientation: { |
| | | // // 指向 |
| | | // heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0), |
| | | // // 视角 |
| | | // pitch: global.DC.Namespace.Cesium.Math.toRadians(-90), |
| | | // roll: 0.0 |
| | | // } |
| | | // }) |
| | | // // that.addBaseLayer() |
| | | |
| | | // that.addMxTileset()//师大需要使用 |
| | | // global.viewer.use(new global.DC.Measure()) |
| | | |
| | | // // that.addMxTileset()//师大需要使用 |
| | | } |
| | | |
| | | global.DC.ready(initViewer) |