This commit is contained in:
ann 2023-02-28 17:03:40 +08:00
parent ceeeaacbd4
commit a6aec7b36d
8 changed files with 151 additions and 27337 deletions

39
package-lock.json generated
View File

@ -33,6 +33,7 @@
"normalize.css": "7.0.0", "normalize.css": "7.0.0",
"nprogress": "0.2.0", "nprogress": "0.2.0",
"path-to-regexp": "2.4.0", "path-to-regexp": "2.4.0",
"proj4": "^2.8.1",
"randomstring": "^1.2.1", "randomstring": "^1.2.1",
"screenfull": "4.2.0", "screenfull": "4.2.0",
"script-loader": "0.7.2", "script-loader": "0.7.2",
@ -14967,6 +14968,11 @@
"node": ">= 0.6" "node": ">= 0.6"
} }
}, },
"node_modules/mgrs": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/mgrs/-/mgrs-1.0.0.tgz",
"integrity": "sha512-awNbTOqCxK1DBGjalK3xqWIstBZgN6fxsMSiXLs9/spqWkF2pAhb2rrYCFSsr1/tT7PhcDGjZndG8SWYn0byYA=="
},
"node_modules/microargs": { "node_modules/microargs": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/microargs/-/microargs-1.1.0.tgz", "resolved": "https://registry.npmjs.org/microargs/-/microargs-1.1.0.tgz",
@ -18067,6 +18073,15 @@
"node": ">=0.4.0" "node": ">=0.4.0"
} }
}, },
"node_modules/proj4": {
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/proj4/-/proj4-2.8.1.tgz",
"integrity": "sha512-KK/bgM6oIwxdpeCaJ/JK3V1D8LMQCKKKzndab4/pYQNd+NVKTcddUNtds053Q110GxTALXVjx98L9f5q8xPVXQ==",
"dependencies": {
"mgrs": "1.0.0",
"wkt-parser": "^1.3.1"
}
},
"node_modules/promise-inflight": { "node_modules/promise-inflight": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz", "resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz",
@ -23519,6 +23534,11 @@
"integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=",
"dev": true "dev": true
}, },
"node_modules/wkt-parser": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/wkt-parser/-/wkt-parser-1.3.2.tgz",
"integrity": "sha512-A26BOOo7sHAagyxG7iuRhnKMO7Q3mEOiOT4oGUmohtN/Li5wameeU4S6f8vWw6NADTVKljBs8bzA8JPQgSEMVQ=="
},
"node_modules/word-wrap": { "node_modules/word-wrap": {
"version": "1.2.3", "version": "1.2.3",
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",
@ -35709,6 +35729,11 @@
"integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=", "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=",
"dev": true "dev": true
}, },
"mgrs": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/mgrs/-/mgrs-1.0.0.tgz",
"integrity": "sha512-awNbTOqCxK1DBGjalK3xqWIstBZgN6fxsMSiXLs9/spqWkF2pAhb2rrYCFSsr1/tT7PhcDGjZndG8SWYn0byYA=="
},
"microargs": { "microargs": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/microargs/-/microargs-1.1.0.tgz", "resolved": "https://registry.npmjs.org/microargs/-/microargs-1.1.0.tgz",
@ -38253,6 +38278,15 @@
"integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==",
"dev": true "dev": true
}, },
"proj4": {
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/proj4/-/proj4-2.8.1.tgz",
"integrity": "sha512-KK/bgM6oIwxdpeCaJ/JK3V1D8LMQCKKKzndab4/pYQNd+NVKTcddUNtds053Q110GxTALXVjx98L9f5q8xPVXQ==",
"requires": {
"mgrs": "1.0.0",
"wkt-parser": "^1.3.1"
}
},
"promise-inflight": { "promise-inflight": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz", "resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz",
@ -42660,6 +42694,11 @@
"integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=",
"dev": true "dev": true
}, },
"wkt-parser": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/wkt-parser/-/wkt-parser-1.3.2.tgz",
"integrity": "sha512-A26BOOo7sHAagyxG7iuRhnKMO7Q3mEOiOT4oGUmohtN/Li5wameeU4S6f8vWw6NADTVKljBs8bzA8JPQgSEMVQ=="
},
"word-wrap": { "word-wrap": {
"version": "1.2.3", "version": "1.2.3",
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",

View File

@ -39,6 +39,7 @@
"normalize.css": "7.0.0", "normalize.css": "7.0.0",
"nprogress": "0.2.0", "nprogress": "0.2.0",
"path-to-regexp": "2.4.0", "path-to-regexp": "2.4.0",
"proj4": "^2.8.1",
"randomstring": "^1.2.1", "randomstring": "^1.2.1",
"screenfull": "4.2.0", "screenfull": "4.2.0",
"script-loader": "0.7.2", "script-loader": "0.7.2",

BIN
public/cloud.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 596 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 298 KiB

After

Width:  |  Height:  |  Size: 1.2 MiB

File diff suppressed because one or more lines are too long

View File

@ -6,6 +6,7 @@
</template> </template>
<script> <script>
import * as Three from 'three' import * as Three from 'three'
import proj4 from 'proj4'
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls' import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls'
import { getEarthRegion, getEarthDetails } from '@/api/top-menu/TotalNum' import { getEarthRegion, getEarthDetails } from '@/api/top-menu/TotalNum'
import chinaJson from './chinaProvince.json' import chinaJson from './chinaProvince.json'
@ -47,7 +48,6 @@ export default {
getEarthRegion().then(res => { getEarthRegion().then(res => {
const demo = res.data const demo = res.data
const that = this const that = this
// console.log(demo)
for (let i = 0; i < demo.length; i++) { for (let i = 0; i < demo.length; i++) {
const modelItem = [] const modelItem = []
const value = [] const value = []
@ -58,7 +58,6 @@ export default {
modelItem['value'] = value modelItem['value'] = value
that.mapMarks[i] = modelItem that.mapMarks[i] = modelItem
} }
// console.log(that.mapMarks)
}) })
getEarthDetails('杭州').then(res => { getEarthDetails('杭州').then(res => {
const demo = res.data const demo = res.data
@ -132,11 +131,19 @@ export default {
var material = new Three.MeshLambertMaterial({ var material = new Three.MeshLambertMaterial({
// color: 0x0000ff, // color: 0x0000ff,
transparent: true, transparent: true,
opacity: 0.99, opacity: 0.96,
map: texture map: texture
}) })
var material2 = new Three.MeshLambertMaterial({
transparent: true,
opacity: 0.2,
// blending: Three.AdditiveBlending,
map: textureLoader.load(process.env.VUE_APP_PUBLIC_SOURCE_API + '/earth_cloud.png')
})
this.mesh = new Three.Mesh(geometry, material) // Mesh this.mesh = new Three.Mesh(geometry, material) // Mesh
this.mesh2 = new Three.Mesh(geometry, material2)
this.scene.add(this.mesh) // this.scene.add(this.mesh) //
this.scene.add(this.mesh2)
this.setMark(this.mapMarks) // this.setMark(this.mapMarks) //
this.setAreaMark(this.area) this.setAreaMark(this.area)
// //
@ -162,7 +169,6 @@ export default {
// this.renderer.setClearColor(0x03060f, 1) // // this.renderer.setClearColor(0x03060f, 1) //
const earth = document.getElementById('earth') const earth = document.getElementById('earth')
earth.appendChild(this.renderer.domElement) earth.appendChild(this.renderer.domElement)
// this.setSatellitesAnimate()
this.animate() this.animate()
}) })
}, },
@ -205,28 +211,31 @@ export default {
const coordinates = elem.geometry.coordinates const coordinates = elem.geometry.coordinates
coordinates.forEach(multiPolygon => { coordinates.forEach(multiPolygon => {
if (elem.geometry.type === 'MultiPolygon') { if (elem.geometry.type === 'MultiPolygon') {
// multiPolygon.forEach(polygon => { multiPolygon.forEach(polygon => {
// const lineMaterial = new Three.LineBasicMaterial({ color: 0x3BFA9E }) // 0x3BFA9E const lineMaterial = new Three.LineBasicMaterial({ color: 0x0d4178b5 }) // 0x3BFA9E
// const positions = [] const positions = []
// const linGeometry = new Three.BufferGeometry() const linGeometry = new Three.BufferGeometry()
// for (let i = 0; i < polygon.length; i++) { for (let i = 0; i < polygon.length; i++) {
// var pos = this.getPosition(polygon[i][0] + 90, polygon[i][1], 100) const LL = this.transformToLatLon(polygon[i], continentsJson['hc-transform'].default)
// if (pos.x) { var pos = this.getPosition(LL.x + 90, LL.y, 100)
// positions.push(pos.x, pos.y, pos.z) if (pos.x) {
// } else { positions.push(pos.x, pos.y, pos.z)
// console.log(polygon[i]) } else {
// } console.log(multiPolygon[i])
// } }
// linGeometry.setAttribute('position', new Three.Float32BufferAttribute(positions, 3)) }
// const line = new Three.Line(linGeometry, lineMaterial) linGeometry.setAttribute('position', new Three.Float32BufferAttribute(positions, 3))
// continents.add(line) const line = new Three.Line(linGeometry, lineMaterial)
// }) continents.add(line)
})
} else { } else {
const lineMaterial = new Three.LineBasicMaterial({ color: 0x3BFA9E }) // 0x3BFA9E const lineMaterial = new Three.LineBasicMaterial({ color: 0x0d4178b5 }) // 0x3BFA9E
const positions = [] const positions = []
const linGeometry = new Three.BufferGeometry() const linGeometry = new Three.BufferGeometry()
for (let i = 0; i < multiPolygon.length; i++) { for (let i = 0; i < multiPolygon.length; i++) {
var pos = this.getPosition(multiPolygon[i][0] + 90, multiPolygon[i][1], 100) // var pos = this.getPosition(multiPolygon[i][0] + 90, multiPolygon[i][1], 100)
const LL = this.transformToLatLon(multiPolygon[i], continentsJson['hc-transform'].default)
var pos = this.getPosition(LL.x + 90, LL.y, 100)
if (pos.x) { if (pos.x) {
positions.push(pos.x, pos.y, pos.z) positions.push(pos.x, pos.y, pos.z)
} else { } else {
@ -242,6 +251,45 @@ export default {
}) })
this.scene.add(map1) this.scene.add(map1)
}, },
transformToLatLon(a, b) {
var d = b.jsonmarginX
var f = b.jsonmarginY
var e = b.jsonres
e = void 0 === e ? 1 : e
var n = b.scale
n = void 0 === n ? 1 : n
var t = b.xoffset
var r = b.xpan
var m = b.yoffset
var h = b.ypan
a = {
x: ((a[0] - (void 0 === d ? 0 : d)) / e - (void 0 === r ? 0 : r)) / n + (void 0 === t ? 0 : t),
y: ((a[1] - (void 0 === f ? 0 : f)) / e + (void 0 === h ? 0 : h)) / n + (void 0 === m ? 0 : m)
}
d = b.cosAngle || b.rotation && Math.cos(b.rotation)
f = b.sinAngle || b.rotation && Math.sin(b.rotation)
b = proj4(b.crs, 'WGS84', b.rotation ? {
x: a.x * d + a.y * -f,
y: a.x * f + a.y * d
} : a)
return {
y: b.y,
x: b.x
}
},
// getPosition(_longitude, _latitude, _radius) {
// var lg = Three.Math.degToRad(_longitude)
// var lt = Three.Math.degToRad(_latitude)
// var temp = _radius * Math.cos(lt)
// var x = temp * Math.sin(lg)
// var y = _radius * Math.sin(lt)
// var z = temp * Math.cos(lg)
// return {
// x: x,
// y: y,
// z: z
// }
// },
init() { init() {
this.initRender() this.initRender()
this.initScene() this.initScene()
@ -262,29 +310,6 @@ export default {
} }
document.addEventListener('mousedown', this.onDocumentMouseDown, false) document.addEventListener('mousedown', this.onDocumentMouseDown, false)
}, },
setSatellitesAnimate() {
//
if (this.scene.children[3].children.length) {
this.scene.children[3].children.forEach((mesh) => {
this.mshs += 0.005
mesh.scale.set(this.mshs, this.mshs, 3 * this.mshs)
if (this.mshs <= 1.5) {
// mesh._s=1=0 mesh._s=1.5=1
mesh.material.opacity = (this.mshs - 1) * 2
} else if (this.mshs > 1.5 && this.mshs <= 2) {
// mesh._s=1.5=1 mesh._s=2=0
mesh.material.opacity = 1 - (this.mshs - 1.5) * 2
} else {
this.mshs = 1.0
}
})
}
//
for (let i = 0; i < this.satellitesArr.length; i++) {
this.satellitesArr[i].satellite.rotation.z -= this.satellitesArr[i].speed
}
this.saaniId = requestAnimationFrame(this.setSatellitesAnimate)
},
onDocumentMouseDown(event) { onDocumentMouseDown(event) {
// x y (-1 to +1) // x y (-1 to +1)
console.log('fk') console.log('fk')
@ -477,6 +502,26 @@ export default {
this.scene.rotation.y += 0.005 this.scene.rotation.y += 0.005
this.clock = new Three.Clock()// this.clock = new Three.Clock()//
// const delta = this.clock.getDelta() // const delta = this.clock.getDelta()
//
if (this.scene.children[6].children.length) {
this.scene.children[6].children.forEach((mesh) => {
this.mshs += 0.005
mesh.scale.set(this.mshs, this.mshs, 3 * this.mshs)
if (this.mshs <= 1.5) {
// mesh._s=1=0 mesh._s=1.5=1
mesh.material.opacity = (this.mshs - 1) * 2
} else if (this.mshs > 1.5 && this.mshs <= 2) {
// mesh._s=1.5=1 mesh._s=2=0
mesh.material.opacity = 1 - (this.mshs - 1.5) * 2
} else {
this.mshs = 1.0
}
})
}
//
for (let i = 0; i < this.satellitesArr.length; i++) {
this.satellitesArr[i].satellite.rotation.z -= this.satellitesArr[i].speed
}
this.render() this.render()
this.orbitControls.update() this.orbitControls.update()
this.aniId = requestAnimationFrame(this.animate) this.aniId = requestAnimationFrame(this.animate)

File diff suppressed because one or more lines are too long

View File

@ -8388,6 +8388,11 @@
"resolved" "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz" "resolved" "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz"
"version" "1.1.2" "version" "1.1.2"
"mgrs@1.0.0":
"integrity" "sha512-awNbTOqCxK1DBGjalK3xqWIstBZgN6fxsMSiXLs9/spqWkF2pAhb2rrYCFSsr1/tT7PhcDGjZndG8SWYn0byYA=="
"resolved" "https://registry.npmjs.org/mgrs/-/mgrs-1.0.0.tgz"
"version" "1.0.0"
"microargs@1.1.0": "microargs@1.1.0":
"integrity" "sha1-XsPNi9dzf1fUhVlBMZM+qUMJ+1k=" "integrity" "sha1-XsPNi9dzf1fUhVlBMZM+qUMJ+1k="
"resolved" "https://registry.npmjs.org/microargs/-/microargs-1.1.0.tgz" "resolved" "https://registry.npmjs.org/microargs/-/microargs-1.1.0.tgz"
@ -10195,6 +10200,14 @@
"resolved" "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz" "resolved" "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz"
"version" "2.0.3" "version" "2.0.3"
"proj4@^2.8.1":
"integrity" "sha512-KK/bgM6oIwxdpeCaJ/JK3V1D8LMQCKKKzndab4/pYQNd+NVKTcddUNtds053Q110GxTALXVjx98L9f5q8xPVXQ=="
"resolved" "https://registry.npmjs.org/proj4/-/proj4-2.8.1.tgz"
"version" "2.8.1"
dependencies:
"mgrs" "1.0.0"
"wkt-parser" "^1.3.1"
"promise-inflight@^1.0.1": "promise-inflight@^1.0.1":
"integrity" "sha1-mEcocL8igTL8vdhoEputEsPAKeM=" "integrity" "sha1-mEcocL8igTL8vdhoEputEsPAKeM="
"resolved" "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz" "resolved" "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz"
@ -13080,6 +13093,11 @@
dependencies: dependencies:
"isexe" "^2.0.0" "isexe" "^2.0.0"
"wkt-parser@^1.3.1":
"integrity" "sha512-A26BOOo7sHAagyxG7iuRhnKMO7Q3mEOiOT4oGUmohtN/Li5wameeU4S6f8vWw6NADTVKljBs8bzA8JPQgSEMVQ=="
"resolved" "https://registry.npmjs.org/wkt-parser/-/wkt-parser-1.3.2.tgz"
"version" "1.3.2"
"word-wrap@~1.2.3": "word-wrap@~1.2.3":
"integrity" "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==" "integrity" "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ=="
"resolved" "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz" "resolved" "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz"