点云修改

This commit is contained in:
2026-01-27 16:34:30 +08:00
parent ece75ff87a
commit 4dd2a44842
3 changed files with 47 additions and 12 deletions

View File

@@ -217,6 +217,9 @@ export default {
this.initPathSystem(); // 初始化路径系统 this.initPathSystem(); // 初始化路径系统
this.setupEventListeners(); this.setupEventListeners();
this.animate(); this.animate();
this.updateCarPosition(this.carPosition)
this.addPathPoint(this.carPosition)
}, },
createPointCloud() { createPointCloud() {
this.pointGeometry = new THREE.BufferGeometry(); this.pointGeometry = new THREE.BufferGeometry();
@@ -255,6 +258,10 @@ export default {
this.carMesh.position.set(this.carPosition.x, this.carPosition.y, 5); this.carMesh.position.set(this.carPosition.x, this.carPosition.y, 5);
this.carMesh.rotation.z = this.carPosition.angle; this.carMesh.rotation.z = this.carPosition.angle;
this.scene.add(this.carMesh); this.scene.add(this.carMesh);
if (this.yellowDotSprite) {
this.yellowDotSprite.scale.set(carScale * 1.5, carScale * 1.5, 1);
}
}); });
}, },
createYellowDot(initialX, initialY) { createYellowDot(initialX, initialY) {
@@ -282,18 +289,36 @@ export default {
}); });
this.yellowDotSprite = new THREE.Sprite(dotMaterial); this.yellowDotSprite = new THREE.Sprite(dotMaterial);
// 设置圆点大小(根据场景比例调整)
const actualRangeY = this.pointCloudRange.maxY - this.pointCloudRange.minY; let dotScale
const carScale = actualRangeY / 5; if (this.carMesh) {
this.yellowDotSprite.scale.set(carScale * 1.5, carScale * 1.5, 1); dotScale = this.carMesh.scale.x;
} else {
const actualRangeY = this.pointCloudRange.maxY - this.pointCloudRange.minY;
dotScale = actualRangeY / 5 * 1.5;
}
this.yellowDotSprite.scale.set(dotScale, dotScale, 1);
// 固定在小车初始位置 // 固定在小车初始位置
this.yellowDotSprite.position.set(initialX, initialY, 5); // z轴4在点云之上、小车之下 this.yellowDotSprite.position.set(initialX, initialY, 4);
this.scene.add(this.yellowDotSprite); this.scene.add(this.yellowDotSprite);
if (this.renderer && this.scene && this.camera) { if (this.renderer && this.scene && this.camera) {
this.renderer.render(this.scene, this.camera); this.renderer.render(this.scene, this.camera);
} }
}, },
updateAllSpritesScale() {
const actualRangeY = this.pointCloudRange.maxY - this.pointCloudRange.minY;
const newScale = actualRangeY / 5 * 1.5;
if (this.carMesh) {
this.carMesh.scale.set(newScale, newScale, 1);
}
if (this.yellowDotSprite) {
this.yellowDotSprite.scale.set(newScale, newScale, 1);
}
},
updatePointCloud(points) { updatePointCloud(points) {
if (!points || !Array.isArray(points) || points.length === 0) return; if (!points || !Array.isArray(points) || points.length === 0) return;
@@ -383,6 +408,11 @@ export default {
this.pointCloudRange.maxY = newRange.maxY; this.pointCloudRange.maxY = newRange.maxY;
expanded = true; expanded = true;
} }
if (expanded) {
this.updateAllSpritesScale();
this.adjustCameraToNewRange();
}
return expanded; return expanded;
}, },
@@ -661,6 +691,7 @@ export default {
// this.isLoading = false; // this.isLoading = false;
// const pointData = points.data // const pointData = points.data
// this.updatePointCloud(pointData); // this.updatePointCloud(pointData);
// this.createYellowDot(this.carPosition.x, this.carPosition.y)
// setTimeout(() => { // setTimeout(() => {
// const arr = points1.data // const arr = points1.data
// this.updatePointCloud(arr); // this.updatePointCloud(arr);

View File

@@ -504,13 +504,17 @@ export default {
let res = await teachingStartingPointRelocate() let res = await teachingStartingPointRelocate()
this.$message({ this.$message({
type: 'success', type: 'success',
message: res.message, message: res.message
duration: 0
}) })
this.needsConfirmation = false this.needsConfirmation = false
this.$router.push('/index/home') this.$router.push('/index/home')
} catch (e) { } catch (e) {
console.log(e) this.$message({
type: 'success',
message: e
})
this.needsConfirmation = false
this.$router.push('/index/home')
} }
}, },
closeCloud () { closeCloud () {

View File

@@ -221,16 +221,16 @@ export default {
this.websocket.onmessage = (event) => { this.websocket.onmessage = (event) => {
try { try {
const res = JSON.parse(event.data) const res = JSON.parse(event.data)
if (!res.data.rcsConnected && !res.data.vehicleConnected) { if (!res.rcsConnected && !res.vehicleConnected) {
this.showConnectionError(this.$t('Dispatchvehiclenotconnected')) this.showConnectionError(this.$t('Dispatchvehiclenotconnected'))
} else if (!res.data.rcsConnected && res.data.vehicleConnected) { } else if (!res.rcsConnected && res.vehicleConnected) {
this.showConnectionError(this.$t('Dispatchnotconnected')) this.showConnectionError(this.$t('Dispatchnotconnected'))
} else if (!res.data.vehicleConnected && res.data.rcsConnected) { } else if (!res.vehicleConnected && res.rcsConnected) {
this.showConnectionError(this.$t('Vehiclenotconnected')) this.showConnectionError(this.$t('Vehiclenotconnected'))
} else { } else {
this.hideConnectionError() this.hideConnectionError()
} }
if (res.data.rcsConnected && res.data.vehicleConnected) { if (res.rcsConnected && res.vehicleConnected) {
this.loading.close() this.loading.close()
this.hideConnectionError() this.hideConnectionError()
} }