From 62e9a2662a7eee53391a5fec28b4acbda15c4f3a Mon Sep 17 00:00:00 2001
From: Kubbo <390378816@qq.com>
Date: Tue, 9 Jul 2024 02:02:18 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E7=89=88=E6=9C=AC=E5=9C=B0=E5=9B=BE?=
=?UTF-8?q?=E5=B0=9D=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/App3DMap.vue | 58 +++++++++++++++++++
src/views/AppThreeMap.vue | 119 ++++++++++----------------------------
2 files changed, 88 insertions(+), 89 deletions(-)
create mode 100644 src/views/App3DMap.vue
diff --git a/src/views/App3DMap.vue b/src/views/App3DMap.vue
new file mode 100644
index 0000000..093cace
--- /dev/null
+++ b/src/views/App3DMap.vue
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
diff --git a/src/views/AppThreeMap.vue b/src/views/AppThreeMap.vue
index 99999bc..ca73ce2 100644
--- a/src/views/AppThreeMap.vue
+++ b/src/views/AppThreeMap.vue
@@ -16,7 +16,9 @@ export default {
const {$waitFor, THREE, $loadScript} = window
return $waitFor(THREE).then(() => Promise.all([
`http://10.0.97.209/presource/datascreen/js/three/js/controls/OrbitControls.js`,
- // `http://10.0.97.209/presource/datascreen/js/renderers/CSS3DRenderer.js`,
+ `http://10.0.97.209/presource/datascreen/js/three/js/renderers/CSS3DRenderer.js`,
+ `http://10.0.97.209/presource/datascreen/js/three/js/renderers/CSS2DRenderer.js`,
+ `http://10.0.97.209/presource/datascreen/js/three/js/objects/Reflector.js`,
].map(e => $loadScript('js', e))))
},
initMap() {
@@ -34,10 +36,8 @@ export default {
this.renderer = null; // 渲染器
this.controls = null; // 控制器
this.mapGroup = []; // 组
- this.meshList = []; // 接受鼠标事件对象
this.selectedObject = null; // 当前选中对象
this.loopIndex = 0; // 循环标记
- this.cameraPath = null; // 相机运动轨迹
this.mouse = new THREE.Vector2();
}
@@ -47,7 +47,6 @@ export default {
init() {
this.setScene();
this.setCamera();
- // this.setLight();
// this.setAxes();
this.setRenderer();
this.setControl();
@@ -61,11 +60,8 @@ export default {
/**
* @desc 动画循环
* */
-
animat() {
requestAnimationFrame(this.animat.bind(this));
- this.lightWave();
- // this.moveCamera();
TWEEN.update();
this.controls.update();
this.renderer.render(this.scene, this.camera);
@@ -74,7 +70,6 @@ export default {
/**
* @desc 获取地图
* */
-
getMap(url) {
const that = this;
axios.get(url).then(function (res) {
@@ -86,20 +81,6 @@ export default {
})
}
- /**
- * @desc 添加基础灯光
- * */
-
- setLight() {
- const pointLight = new THREE.PointLight(0xffffff, 1, 0);
- pointLight.position.set(0, 0, 5);
- this.scene.add(pointLight);
-
- const sphereSize = 1;
- const pointLightHelper = new THREE.PointLightHelper(pointLight, sphereSize);
- this.scene.add(pointLightHelper);
- }
-
/**
* @desc 绘制地图
* @params geojson
@@ -217,7 +198,6 @@ export default {
side: THREE.DoubleSide,
blending: THREE.AdditiveBlending,
color: bakeStockAmt > 0 ? "#66FFFF" : "#FFD15C",
- // color: "#66FFFF",
depthTest: false,
transparent: true,
opacity: 1
@@ -228,6 +208,7 @@ export default {
// marker.scale.set(scale, scale, 1)
marker.data = item
marker.position.set(v3.x * scale, v3.y * scale, 0.201 * scale)
+ console.log(marker)
return marker
}
@@ -240,32 +221,6 @@ export default {
})
}
- /**
- * @desc 移动相机
- * */
- moveCamera() {
- // 第一次绘制相机路径
- if (this.cameraPath === null) {
- this.cameraPath = new THREE.Path();
- this.cameraPath.moveTo(150, 0);
- this.cameraPath.lineTo(70, 0);
- let geometry = new THREE.BufferGeometry().setFromPoints(this.cameraPath.getPoints());
- let material = new THREE.LineBasicMaterial({color: 0xff0000});
- let line = new THREE.Line(geometry, material);
- line.position.z = 100;
- this.scene.add(line);
- this.progress = 0;
- } else {
- if (this.progress < 1) {
- this.progress += 0.01; // 增量 也就是说将该线端,按照1/500的比例进行分割。也就是说有500个坐标点
- let point = this.cameraPath.getPointAt(this.progress); // 从路径中拿取坐标点点
- if (point) {
- this.camera.position.set(point.x, point.y, 100);
- }
- }
- }
- }
-
/**
* @desc 坐标转换
* @param lnglat [x,y]
@@ -322,8 +277,8 @@ export default {
* @desc 创建控制器
* */
setControl() {
- this.controls = new THREE.OrbitControls(this.camera,rootEl);
- this.controls.enableRotate = false
+ this.controls = new THREE.OrbitControls(this.camera, rootEl);
+ // this.controls.enableRotate = false
this.camera.position.set(this.cameraPosition.x, this.cameraPosition.y, this.cameraPosition.z);
}
@@ -338,7 +293,6 @@ export default {
/**
* @desc 鼠标 hover 事件
* */
-
bindMouseEvent() {
const that = this, _this = this;
const raycaster = new THREE.Raycaster();
@@ -439,12 +393,26 @@ export default {
this.scene.add(ground);
ground.receiveShadow = true;
ground.castShadow = true;
+ const div = document.createElement("div");
+ div.style.color = "#fff";
+ div.style.width = "40px";
+ div.style.height = "25px";
+ div.style.borderWidth = "1px";
+ div.style.borderStyle = "solid";
+ div.style.borderColor = "#00ffc4";
+ div.style.borderRadius = "5px";
+ div.style.fontSize = "14px";
+ div.style.fontWeight = 600;
+ div.style.textShadow = "1px 1px 6px #fff";
+ div.style.textAlign = "center";
+ div.style.lineHeight = "25px";
+ div.textContent = `我操你大爷`;
+ const tip = new THREE.CSS2DObject(div);
+ tip.scale.set(0.01, 0.01, 0.01);
+ tip.position.set(0, 0, 1);
+ this.scene.add(tip);
}
- /**
- * @desc 地区名称 采用sprite
- * */
-
tipsSprite(areaData) {
let canvas = document.createElement("canvas");
canvas.width = 500;
@@ -472,39 +440,6 @@ export default {
return textSprite
}
-
- /**
- * @desc 光柱波纹动画
- * */
-
- lightWave() {
- if (this.mapGroup.children) {
- let that = this;
- if (this.loopIndex >= 1) {
- this.loopIndex = 0;
- } else {
- this.loopIndex += 0.02;
- }
- this.mapGroup.children.forEach(function (item) {
- if (item.name === 'area') {
- item.children.forEach(function (g) {
- if (g.name === 'lightTipGroup') {
- g.children.forEach(function (c) {
- if (c.name === 'circleMesh') {
- c.scale = {
- x: 4 * Math.asin(that.loopIndex) + 1,
- y: 4 * Math.asin(that.loopIndex) + 1,
- z: 4 * Math.asin(that.loopIndex) + 1
- };
- c.material.opacity = 0.3 * Math.acos(that.loopIndex) - 0.1
- }
- })
- }
- })
- }
- })
- }
- }
}
return new GeoMap()
@@ -541,3 +476,9 @@ export default {
+