From bf58722dfd03ea1513f3acc7331d4d4403fca76e Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Fri, 18 Mar 2022 11:48:37 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.0.105:10010/r/school-web
---
src/components/map/components/dimension.vue | 204 +++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 164 insertions(+), 40 deletions(-)
diff --git a/src/components/map/components/dimension.vue b/src/components/map/components/dimension.vue
index 6a39dd1..9b9f8dd 100644
--- a/src/components/map/components/dimension.vue
+++ b/src/components/map/components/dimension.vue
@@ -1,5 +1,21 @@
<template>
<div class="dimension-cut">
+ <el-button
+ v-show="btnGroupShow"
+ size="mini"
+ class="three-stm"
+ type="primary"
+ @click="locationSTM"
+ >s3m</el-button>
+
+ <el-button
+ v-show="btnGroupShow"
+ size="mini"
+ class="sat-stm"
+ type="primary"
+ @click="locationSAT"
+ >科技</el-button>
+
<el-radio-group v-model="dimensionValue" size="medium" @change="dimensionChange">
<el-radio-button label="三 维"></el-radio-button>
<el-radio-button label="真三维"></el-radio-button>
@@ -26,12 +42,18 @@
let select = null
+let streenMlayer = null
+
+let layerSat = null
+let layerSATtwo = null
+
const wallLayer = null
export default {
name: 'dimension',
data () {
return {
+ btnGroupShow: false,
dimensionValue: '三 维',
// 建筑2.5D地图
// 建筑2.5D面数据
@@ -248,7 +270,7 @@
})
// 最小
- global.viewer.scene.screenSpaceCameraController.minimumZoomDistance = 220
+ global.viewer.scene.screenSpaceCameraController.minimumZoomDistance = 100
// 最大
global.viewer.scene.screenSpaceCameraController.maximumZoomDistance = 400
@@ -401,13 +423,13 @@
global.viewer.camera.positionCartographic.height
)
- if (height <= 250) {
+ if (height < 150) {
global.viewer.camera.setView({
destination:
global.DC.Namespace.Cesium.Cartesian3.fromRadians(
global.viewer.camera.positionCartographic.longitude,
global.viewer.camera.positionCartographic.latitude,
- 280
+ 200
),
orientation: {
// 指向
@@ -417,15 +439,17 @@
roll: 0.0
}
})
+
+ return
}
- if (height > 250 && height <= 310) {
+ if (height < 250) {
global.viewer.camera.setView({
destination:
global.DC.Namespace.Cesium.Cartesian3.fromRadians(
global.viewer.camera.positionCartographic.longitude,
global.viewer.camera.positionCartographic.latitude,
- 340
+ 300
),
orientation: {
// 指向
@@ -435,9 +459,11 @@
roll: 0.0
}
})
+
+ return
}
- if (height > 310 && height < 370) {
+ if (height < 350) {
global.viewer.camera.setView({
destination:
global.DC.Namespace.Cesium.Cartesian3.fromRadians(
@@ -467,33 +493,13 @@
global.viewer.camera.positionCartographic.height
)
- if (height > 370) {
+ if (height > 350) {
global.viewer.camera.setView({
destination:
global.DC.Namespace.Cesium.Cartesian3.fromRadians(
global.viewer.camera.positionCartographic.longitude,
global.viewer.camera.positionCartographic.latitude,
- 340
- ),
- orientation: {
- // 指向
- heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
- // 视角
- pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
- roll: 0.0
- }
- })
-
- return
- }
-
- if (height > 310) {
- global.viewer.camera.setView({
- destination:
- global.DC.Namespace.Cesium.Cartesian3.fromRadians(
- global.viewer.camera.positionCartographic.longitude,
- global.viewer.camera.positionCartographic.latitude,
- 280
+ 300
),
orientation: {
// 指向
@@ -513,7 +519,27 @@
global.DC.Namespace.Cesium.Cartesian3.fromRadians(
global.viewer.camera.positionCartographic.longitude,
global.viewer.camera.positionCartographic.latitude,
- 220
+ 200
+ ),
+ orientation: {
+ // 指向
+ heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
+ // 视角
+ pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
+ roll: 0.0
+ }
+ })
+
+ return
+ }
+
+ if (height > 150) {
+ global.viewer.camera.setView({
+ destination:
+ global.DC.Namespace.Cesium.Cartesian3.fromRadians(
+ global.viewer.camera.positionCartographic.longitude,
+ global.viewer.camera.positionCartographic.latitude,
+ 100
),
orientation: {
// 指向
@@ -533,6 +559,10 @@
}
},
methods: {
+ locationSTM () {
+ global.viewer.flyToPosition('116.45793269658417,39.92711385557482,617.5967826044838,181.95219395269424,-21.286437065473546')
+ },
+
mouseMoveEvent (e) {
var that = this
@@ -603,12 +633,12 @@
}
})
- if (height <= 250) {
+ if (height < 150) {
global.viewer.camera.setView({
destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
global.viewer.camera.positionCartographic.longitude,
global.viewer.camera.positionCartographic.latitude,
- 220
+ 100
),
orientation: {
// 指向
@@ -620,12 +650,12 @@
})
}
- if (height > 250 && height <= 310) {
+ if (height > 150 && height <= 250) {
global.viewer.camera.setView({
destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
global.viewer.camera.positionCartographic.longitude,
global.viewer.camera.positionCartographic.latitude,
- 280
+ 200
),
orientation: {
// 指向
@@ -637,12 +667,12 @@
})
}
- if (height > 310 && height <= 370) {
+ if (height > 250 && height <= 350) {
global.viewer.camera.setView({
destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
global.viewer.camera.positionCartographic.longitude,
global.viewer.camera.positionCartographic.latitude,
- 340
+ 300
),
orientation: {
// 指向
@@ -654,7 +684,7 @@
})
}
- if (height > 370) {
+ if (height > 350) {
global.viewer.camera.setView({
destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
global.viewer.camera.positionCartographic.longitude,
@@ -797,12 +827,82 @@
}
},
+ locationSAT () {
+ global.viewer.flyToPosition('121.4941629,31.2091462,1859.56,0,-28.71')
+ },
+
+ // 科技感删除
+ removeSAT () {
+ global.viewer.remove(layerSat)
+ global.viewer.remove(layerSATtwo)
+ },
+
+ // 科技感添加
+ createSAT () {
+ function generatePosition (num, isAdd) {
+ const list = []
+ for (let i = 0; i < num; i++) {
+ const lng = 121.49536592256028 + Math.random() * 0.04 * (isAdd ? 1 : -1)
+ const lat = 31.241616722278213 + Math.random() * 0.04 * (isAdd ? 1 : -1)
+ list.push({ lng, lat })
+ }
+ return list
+ }
+
+ layerSat = new global.DC.TilesetLayer('layerSat').addTo(global.viewer)
+
+ const build = new global.DC.Tileset(
+ 'http://resource.dvgis.cn/data/3dtiles/ljz/tileset.json',
+ { skipLevels: true }
+ )
+
+ const 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)
+
+ layerSat.addOverlay(build)
+
+ layerSATtwo = new global.DC.PrimitiveLayer('layer').addTo(global.viewer)
+
+ let positions = generatePosition(50, true)
+
+ positions = positions.concat(generatePosition(50))
+
+ positions.forEach(item => {
+ const position = global.DC.Position.fromObject(item)
+ const end = position.copy()
+ end.alt = 5000 * Math.random()
+ const line = new global.DC.FlowLinePrimitive([position, end], 0.5)
+ line.setStyle({
+ speed: 6 * Math.random(),
+ color: global.DC.Color.fromCssColorString('rgb(141,172,172)'),
+ percent: 0.1,
+ gradient: 0.01
+ })
+ layerSATtwo.addOverlay(line)
+ })
+ },
+
dimensionChange () {
var that = this
that.$store.commit('SET_TWOORTHREE', that.dimensionValue)
if (that.dimensionValue == '真三维') {
+ that.btnGroupShow = true
+ that.createSAT()
global.viewer.off(global.DC.MouseEventType.MOUSE_MOVE, that.mouseMoveEvent)
global.viewer.off(global.DC.SceneEventType.CAMERA_CHANGED, that.mapCameraEvent)
that.removeLayers()
@@ -814,12 +914,18 @@
tilesetLayer = new global.DC.TilesetLayer('tilesetLayer')
global.viewer.addLayer(tilesetLayer)
tileset = new global.DC.Tileset('/mx/tileset.json', {
- luminanceAtZenith: 0.3,
+ luminanceAtZenith: 0.4,
+ // cullWithChildrenBounds: false,
+ // cullRequestsWhileMoving: false,
+ // skipLevelOfDetail: false,
shadows: global.DC.Namespace.Cesium.ShadowMode.DISABLED
})
tilesetLayer.addOverlay(tileset)
tileset.on(global.DC.MouseEventType.CLICK, that.tilesetClick)
tilesetLayer.show = true
+
+ streenMlayer = new global.DC.S3MLayer('streenMlayer', 'http://resource.dvgis.cn/data/3dtiles/CBD/cbd.scp')
+ global.viewer.addLayer(streenMlayer)
// 最小
global.viewer.scene.screenSpaceCameraController.minimumZoomDistance = 1.0
// 最大
@@ -845,14 +951,18 @@
}
})
} else {
+ that.btnGroupShow = false
+ that.removeSAT()
global.viewer.on(global.DC.MouseEventType.MOUSE_MOVE, that.mouseMoveEvent)
global.viewer.on(global.DC.SceneEventType.CAMERA_CHANGED, that.mapCameraEvent)
tileset.off(global.DC.MouseEventType.CLICK, that.tilesetClick)
tilesetLayer.removeOverlay(tileset)
- global.viewer.remove(tilesetLayer)
+ tilesetLayer.show = false
+ global.viewer.removeLayer(tilesetLayer)
tileset = null
tilesetLayer = null
- tilesetLayer.show = false
+ global.viewer.removeLayer(streenMlayer)
+ streenMlayer = null
that.createdLayers()
baseMapLayer = global.viewer.imageryLayers.addImageryProvider(new global.DC.Namespace.Cesium.UrlTemplateImageryProvider({
@@ -877,7 +987,7 @@
}
})
// 最小
- global.viewer.scene.screenSpaceCameraController.minimumZoomDistance = 220
+ global.viewer.scene.screenSpaceCameraController.minimumZoomDistance = 100
// 最大
global.viewer.scene.screenSpaceCameraController.maximumZoomDistance = 400
// 视角旋转
@@ -897,4 +1007,18 @@
// height: 40px;
z-index: 1;
}
+
+.three-stm {
+ position: fixed;
+ top: 66px;
+ right: 10px;
+ z-index: 99;
+}
+
+.sat-stm {
+ position: fixed;
+ top: 66px;
+ right: 75px;
+ z-index: 99;
+}
</style>
--
Gitblit v1.9.3