修改点云和地图

This commit is contained in:
2025-08-25 15:24:04 +08:00
parent 15a57034ac
commit 6a1cac2d13
9 changed files with 4872 additions and 377 deletions

View File

@@ -123,6 +123,34 @@ export default {
if (this.scale > 0.02) {
this.zoom(-8) // 每次缩小8%
}
},
centerToCar() {
// 1. 基础数据校验(避免报错)
if (!this.mapData || !this.carPosition?.x || !this.carPosition?.y || !this.canvas) {
this.$message.warning('无法定位:地图或小车位置数据缺失');
return;
}
// 2. 步骤1计算小车在「原始画布」的坐标未缩放
const rawCarX = (this.carPosition.x - this.mapData.x) / this.mapData.resolution;
const rawCarY = this.mapData.height - (this.carPosition.y - this.mapData.y) / this.mapData.resolution;
// 3. 步骤2计算小车在「缩放后画布」的坐标
const scaledCarX = rawCarX * this.scale;
const scaledCarY = rawCarY * this.scale;
// 4. 步骤3计算可视区域中心坐标画布容器的中心
const viewCenterX = this.canvas.offsetWidth * this.scale / 2;
const viewCenterY = this.canvas.offsetHeight * this.scale / 2;
// 5. 步骤4计算目标偏移量核心修正
let targetOffsetX = viewCenterX - scaledCarX;
let targetOffsetY = viewCenterY - scaledCarY;
// 7. 应用最终偏移量并刷新画布
this.offsetX = targetOffsetX;
this.offsetY = targetOffsetY;
this.applyTransform(); // 立即更新CSS变换
}
}
}

4804
src/config/point2.js Normal file

File diff suppressed because it is too large Load Diff