parent
2ae334a056
commit
3746494c32
BIN
src/assets/map/zhejiang_top_surface.jpg
Normal file
BIN
src/assets/map/zhejiang_top_surface.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 705 KiB |
@ -1,6 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted } from 'vue'
|
import { onMounted } from 'vue'
|
||||||
import { setScene } from './script'
|
// @ts-ignore
|
||||||
|
import { setScene } from './script.js'
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
setScene(document.querySelector('.three-js-scene'))
|
setScene(document.querySelector('.three-js-scene'))
|
||||||
|
@ -90,18 +90,17 @@ function animateTexture() {
|
|||||||
requestAnimationFrame(animateTexture)
|
requestAnimationFrame(animateTexture)
|
||||||
}
|
}
|
||||||
animateTexture()
|
animateTexture()
|
||||||
|
|
||||||
function createGeo(geoJson) {
|
function createGeo(geoJson) {
|
||||||
|
|
||||||
const group = new THREE.Group()
|
const group = new THREE.Group()
|
||||||
group.info = geoJson
|
group.info = geoJson
|
||||||
|
|
||||||
// 材质
|
// 材质
|
||||||
|
|
||||||
const materials = [
|
const materials = [
|
||||||
new THREE.MeshStandardMaterial({ color: Math.random() * 0xffffff, transparent: true, metalness: 0.5, roughness: 0.5 }),
|
new THREE.MeshStandardMaterial({ color: Math.random() * 0xffffff, transparent: true, metalness: 0.5, roughness: 0.5 }),
|
||||||
new THREE.MeshBasicMaterial({ map: texture, color: 0xffffff * Math.random() }),
|
new THREE.MeshBasicMaterial({ map: texture, color: 0xffffff * Math.random() }),
|
||||||
]
|
]
|
||||||
|
|
||||||
// 遍历添加各个地块
|
// 遍历添加各个地块
|
||||||
geoJson.features.forEach((info) => {
|
geoJson.features.forEach((info) => {
|
||||||
|
|
||||||
@ -111,6 +110,8 @@ function createGeo(geoJson) {
|
|||||||
|
|
||||||
// 行政区块组
|
// 行政区块组
|
||||||
const areaGroup = new THREE.Group()
|
const areaGroup = new THREE.Group()
|
||||||
|
console.log(info.properties.adcode);
|
||||||
|
|
||||||
areaGroup.info = info
|
areaGroup.info = info
|
||||||
areaGroup.name = info.properties?.name
|
areaGroup.name = info.properties?.name
|
||||||
group.add(areaGroup)
|
group.add(areaGroup)
|
||||||
@ -142,12 +143,12 @@ function createGeo(geoJson) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 坐标转换
|
// 坐标转换
|
||||||
function coordToVector(coord, type = 2, slace = 10000) {
|
function coordToVector(coord, type = 2, scale = 10000) {
|
||||||
const [lng, lat] = coord
|
const [lng, lat] = coord
|
||||||
const x = lng * 20037508.34 / 180
|
const x = lng * 20037508.34 / 180
|
||||||
let y = Math.log(Math.tan((90 + lat) * Math.PI / 360)) / (Math.PI / 180)
|
let y = Math.log(Math.tan((90 + lat) * Math.PI / 360)) / (Math.PI / 180)
|
||||||
y = y * 20037508.34 / 180
|
y = y * 20037508.34 / 180
|
||||||
return type === 2 ? new THREE.Vector2(x / slace, y / slace) : new THREE.Vector3(x / slace, y / slace, 0)
|
return type === 2 ? new THREE.Vector2(x / scale, y / scale) : new THREE.Vector3(x / scale, y / scale, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user