先提交一部分
This commit is contained in:
@@ -205,7 +205,8 @@ export default {
|
|||||||
that.scene.add(that.mapGroup);
|
that.scene.add(that.mapGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
transLayer({bakeStockAmt, longitude, latitude} = {}) {
|
transLayer(item = {}) {
|
||||||
|
let {bakeStockAmt, longitude, latitude} = item
|
||||||
longitude = Number(longitude || 0).toFixed(6);
|
longitude = Number(longitude || 0).toFixed(6);
|
||||||
latitude = Number(latitude || 0).toFixed(6);
|
latitude = Number(latitude || 0).toFixed(6);
|
||||||
const markerGeometry = new THREE.CircleBufferGeometry(0.1, 32);
|
const markerGeometry = new THREE.CircleBufferGeometry(0.1, 32);
|
||||||
@@ -219,17 +220,21 @@ export default {
|
|||||||
opacity: 1
|
opacity: 1
|
||||||
});
|
});
|
||||||
const marker = new THREE.Mesh(markerGeometry, markerMaterial);
|
const marker = new THREE.Mesh(markerGeometry, markerMaterial);
|
||||||
// const [x, y, z] = this.lnglatToVector3([longitude, latitude])
|
|
||||||
|
|
||||||
const lnglat = this.lnglatToVector3([longitude, latitude]);
|
const lnglat = this.lnglatToVector3([longitude, latitude]);
|
||||||
const v3 = new THREE.Vector3(lnglat[0], lnglat[1], lnglat[2]).multiplyScalar(1.2);
|
const v3 = new THREE.Vector3(lnglat[0], lnglat[1], lnglat[2]).multiplyScalar(1.2);
|
||||||
// marker.scale.set(scale, scale, 1)
|
// marker.scale.set(scale, scale, 1)
|
||||||
|
marker.data = item
|
||||||
marker.position.set(v3.x * scale, v3.y * scale, 0.201 * scale)
|
marker.position.set(v3.x * scale, v3.y * scale, 0.201 * scale)
|
||||||
return marker
|
return marker
|
||||||
}
|
}
|
||||||
|
|
||||||
addMarkers() {
|
addMarkers() {
|
||||||
root.layers.map(layer => this.scene.add(this.transLayer(layer)))
|
this.markers = [];
|
||||||
|
root.layers.map(layer => {
|
||||||
|
const marker = this.transLayer(layer)
|
||||||
|
this.markers.push(marker)
|
||||||
|
this.scene.add(marker)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -378,7 +383,21 @@ export default {
|
|||||||
new TWEEN.Tween(o).to(n, t).start();
|
new TWEEN.Tween(o).to(n, t).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
// window.addEventListener('mousemove', onMouseMove, false);
|
const onClick = evt => {
|
||||||
|
// 计算鼠标位置
|
||||||
|
const mouseX = (evt.clientX / window.innerWidth) * 2 - 1;
|
||||||
|
const mouseY = -(evt.clientY / window.innerHeight) * 2 + 1;
|
||||||
|
|
||||||
|
// 创建一个射线投射器
|
||||||
|
const raycaster = new THREE.Raycaster();
|
||||||
|
raycaster.setFromCamera(new THREE.Vector2(mouseX, mouseY), this.camera);
|
||||||
|
const marker = this.markers.find(e => raycaster.intersectObject(e).length > 0)
|
||||||
|
const {$glob} = window
|
||||||
|
this.$storeBoard.search.storeCode = marker.data?.storeCode
|
||||||
|
$glob.group = '9f299712-5549-413b-a93b-7c3e3b5bfadb'
|
||||||
|
}
|
||||||
|
window.addEventListener('mousemove', onMouseMove, false);
|
||||||
|
window.addEventListener('click', onClick, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
makeGround() {
|
makeGround() {
|
||||||
@@ -497,8 +516,3 @@ export default {
|
|||||||
<template>
|
<template>
|
||||||
<section class="AppThreeMap"/>
|
<section class="AppThreeMap"/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style>
|
|
||||||
.AppThreeMap {
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user