|
@@ -195,14 +195,16 @@ const updatePixelPosition = () => {
|
|
}
|
|
}
|
|
|
|
|
|
const initPixelPosition = () => {
|
|
const initPixelPosition = () => {
|
|
- const { x, y, width, length } = props.item
|
|
|
|
|
|
+ const { x, y, width: itemLength, length: itemWidth } = props.item
|
|
|
|
+ // ⚠️ width: itemLength, length: itemWidth 回显时需要转换一下,不然家具会有偏移
|
|
|
|
+
|
|
// === 1️⃣ 将房间坐标转换为画布坐标 ===
|
|
// === 1️⃣ 将房间坐标转换为画布坐标 ===
|
|
const itemConvert = convert_furniture_r2c(
|
|
const itemConvert = convert_furniture_r2c(
|
|
{
|
|
{
|
|
x: x,
|
|
x: x,
|
|
y: y,
|
|
y: y,
|
|
- width: width,
|
|
|
|
- height: length,
|
|
|
|
|
|
+ width: itemWidth,
|
|
|
|
+ height: itemLength,
|
|
},
|
|
},
|
|
{
|
|
{
|
|
x_radar: 250,
|
|
x_radar: 250,
|
|
@@ -215,26 +217,18 @@ const initPixelPosition = () => {
|
|
{
|
|
{
|
|
left: itemConvert.left,
|
|
left: itemConvert.left,
|
|
top: itemConvert.top,
|
|
top: itemConvert.top,
|
|
- width: width,
|
|
|
|
- height: length,
|
|
|
|
|
|
+ width: itemConvert.width,
|
|
|
|
+ height: itemConvert.height,
|
|
},
|
|
},
|
|
{ x: 250, y: 250 },
|
|
{ x: 250, y: 250 },
|
|
props.angle
|
|
props.angle
|
|
)
|
|
)
|
|
|
|
|
|
- console.log('🌸🌸🌸回显的家具数据AAAA', props.angle, props.item, itemConvert, rotatedRect)
|
|
|
|
-
|
|
|
|
// === 3️⃣ 应用最终位置 ===
|
|
// === 3️⃣ 应用最终位置 ===
|
|
- /* 90度和270度需要特殊处理,因为旋转后家具的中心位置会改变 */
|
|
|
|
- // pixelPosition.left = props.angle === 90 ? rotatedRect.left + length / 2 : rotatedRect.left
|
|
|
|
- // pixelPosition.top = props.angle === 270 ? rotatedRect.top - length / 2 : rotatedRect.top
|
|
|
|
-
|
|
|
|
pixelPosition.left = rotatedRect.left
|
|
pixelPosition.left = rotatedRect.left
|
|
pixelPosition.top = rotatedRect.top
|
|
pixelPosition.top = rotatedRect.top
|
|
|
|
|
|
// 同步像素位置到 localItem(方便 emit)
|
|
// 同步像素位置到 localItem(方便 emit)
|
|
- // localItem.left = rotatedRect.left
|
|
|
|
- // localItem.top = rotatedRect.top
|
|
|
|
localItem.left = pixelPosition.left
|
|
localItem.left = pixelPosition.left
|
|
localItem.top = pixelPosition.top
|
|
localItem.top = pixelPosition.top
|
|
|
|
|