修复BUG
This commit is contained in:
24
src/views/AppMarketBoard.vue
Normal file
24
src/views/AppMarketBoard.vue
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<script>
|
||||||
|
import AppMarketBoardFilter from "@/views/AppMarketBoardFilter.vue";
|
||||||
|
import AppThreeMap from "@/views/AppThreeMap.vue";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "AppMarketBoard",
|
||||||
|
label: "市场看板",
|
||||||
|
components: {AppMarketBoardFilter, AppThreeMap}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<section class="AppMarketBoard">
|
||||||
|
<app-market-board-filter/>
|
||||||
|
<app-three-map/>
|
||||||
|
</section>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.AppMarketBoard {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -68,15 +68,17 @@ export default {
|
|||||||
animation() {
|
animation() {
|
||||||
requestAnimationFrame(this.animation.bind(this));
|
requestAnimationFrame(this.animation.bind(this));
|
||||||
this.loop = (this.loop * 100 + 2) % 100 * 0.01
|
this.loop = (this.loop * 100 + 2) % 100 * 0.01
|
||||||
this.markers.children.forEach(e => {
|
if (this.markers) {
|
||||||
if (e.data.bakeStockAmt <= 0) {
|
this.markers.children.forEach(e => {
|
||||||
e.scale = {
|
if (e.data.bakeStockAmt <= 0) {
|
||||||
x: Math.asin(this.loop) + 1,
|
e.scale = {
|
||||||
y: Math.asin(this.loop) + 1,
|
x: Math.asin(this.loop) + 1,
|
||||||
z: Math.asin(this.loop) + 1
|
y: Math.asin(this.loop) + 1,
|
||||||
};
|
z: Math.asin(this.loop) + 1
|
||||||
}
|
};
|
||||||
})
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
TWEEN.update();
|
TWEEN.update();
|
||||||
this.controls.update();
|
this.controls.update();
|
||||||
this.renderer.render(this.scene, this.camera);
|
this.renderer.render(this.scene, this.camera);
|
||||||
@@ -197,11 +199,11 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addMarkers() {
|
addMarkers() {
|
||||||
|
this.markers.clear()
|
||||||
root.layers.map(layer => {
|
root.layers.map(layer => {
|
||||||
const marker = this.transLayer(layer)
|
const marker = this.transLayer(layer)
|
||||||
this.markers.add(marker)
|
this.markers.add(marker)
|
||||||
})
|
})
|
||||||
this.mapGroup.add(this.markers)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lnglatToVector3(lnglat = []) {
|
lnglatToVector3(lnglat = []) {
|
||||||
@@ -218,6 +220,7 @@ export default {
|
|||||||
* */
|
* */
|
||||||
setScene() {
|
setScene() {
|
||||||
this.scene = new THREE.Scene();
|
this.scene = new THREE.Scene();
|
||||||
|
this.mapGroup.add(this.markers)
|
||||||
this.mapGroup.scale.set(scale, scale, scale)
|
this.mapGroup.scale.set(scale, scale, scale)
|
||||||
this.mapGroup.position.set(0, 0, 0)
|
this.mapGroup.position.set(0, 0, 0)
|
||||||
this.scene.add(this.mapGroup);
|
this.scene.add(this.mapGroup);
|
||||||
@@ -315,13 +318,13 @@ export default {
|
|||||||
|
|
||||||
bindMouseEvent() {
|
bindMouseEvent() {
|
||||||
const raycaster = new THREE.Raycaster();
|
const raycaster = new THREE.Raycaster();
|
||||||
|
const targets = this.markers?.children || []
|
||||||
const onPointerMove = (event) => {
|
const onPointerMove = (event) => {
|
||||||
const {offsetWidth: width, offsetHeight: height} = rootEl, {left, top} = rootEl.getBoundingClientRect();
|
const {offsetWidth: width, offsetHeight: height} = rootEl, {left, top} = rootEl.getBoundingClientRect();
|
||||||
this.mouse.x = ((event.clientX - left) / width) * 2 - 1; //标准设备横坐标
|
this.mouse.x = ((event.clientX - left) / width) * 2 - 1; //标准设备横坐标
|
||||||
this.mouse.y = -((event.clientY - top) / height) * 2 + 1; //标准设备纵坐标
|
this.mouse.y = -((event.clientY - top) / height) * 2 + 1; //标准设备纵坐标
|
||||||
raycaster.setFromCamera(this.mouse, this.camera);
|
raycaster.setFromCamera(this.mouse, this.camera);
|
||||||
const intersects = raycaster.intersectObjects(this.markers.children)
|
const intersects = raycaster.intersectObjects(targets)
|
||||||
intersects.forEach(e => {
|
intersects.forEach(e => {
|
||||||
if (e.object?.data) {
|
if (e.object?.data) {
|
||||||
this.showHoverPanel(e.object)
|
this.showHoverPanel(e.object)
|
||||||
@@ -339,7 +342,7 @@ export default {
|
|||||||
// const ray = worldVector.sub(this.camera.position).normalize();
|
// const ray = worldVector.sub(this.camera.position).normalize();
|
||||||
// 创建一个射线投射器
|
// 创建一个射线投射器
|
||||||
raycaster.setFromCamera(this.mouse, this.camera);
|
raycaster.setFromCamera(this.mouse, this.camera);
|
||||||
const intersects = raycaster.intersectObjects(this.markers.children)
|
const intersects = raycaster.intersectObjects(targets)
|
||||||
intersects.forEach(e => {
|
intersects.forEach(e => {
|
||||||
if (e.object?.data) {
|
if (e.object?.data) {
|
||||||
const marker = e.object?.data
|
const marker = e.object?.data
|
||||||
@@ -412,8 +415,8 @@ export default {
|
|||||||
</template>
|
</template>
|
||||||
<style>
|
<style>
|
||||||
.AppThreeMap {
|
.AppThreeMap {
|
||||||
width: 900px;
|
width: 100%;
|
||||||
height: 500px;
|
height: 100%;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user