This commit is contained in:
2026-05-16 14:18:06 +08:00
parent b41c3e80bf
commit 25c193b35a
4 changed files with 75 additions and 66 deletions

View File

@ -507,12 +507,13 @@
const response = await fetch(`http://localhost:3001/api/product-configs/by-sku/${currentText}`);
const result = await response.json();
if (result.code === 200) {
const { divisions, enable_placement_zone } = result.data;
console.log(result.data);
sku = currentText;
const { placement_zone, enable_placement_zone } = result.data;
// const {position_x, position_y, position_z} = data;
if (enable_placement_zone) {
sku = currentText;
await placementWall(divisions);
//await initPlacementZoneConfig(divisions);
if (enable_placement_zone && placement_zone != undefined) {
// await initPlacementZoneConfig(placement_zone);
await placementWall();
}
}
@ -795,8 +796,8 @@
});
// 初始化放置区域配置数据(只需设置一次)
const initPlacementZoneConfig = (divisions) => {
const initPlacementZoneConfig = (placement_zone) => {
const { alpha, border_color, color, show_border, thickness, walls } = placement_zone
// 只清除旧的放置区域网格,不清除模型
kernel.dropZone.clearZones();
// 调整 baseY 来控制整体高度(正数向上,负数向下)
@ -807,64 +808,32 @@
const wallOffset = -0.07; // 修改这个值来调整墙面偏移
kernel.dropZone.setData({
walls: [
{
name: 'front',
startPoint: [-1.82, baseY, -1.37],
endPoint: [1.87, baseY, -1.37],
height: height,
divisions: divisions,
offset: wallOffset // 向外或向内偏移
},
{
name: 'back',
startPoint: [1.87, baseY, 1.4],
endPoint: [-1.82, baseY, 1.4],
height: height,
divisions: divisions,
offset: wallOffset
},
{
name: 'left',
startPoint: [-1.82, baseY, 1.4],
endPoint: [-1.82, baseY, -1.37],
height: height,
divisions: divisions,
offset: wallOffset
},
{
name: 'right',
startPoint: [1.82, baseY, -1.37],
endPoint: [1.82, baseY, 1.4],
height: height,
divisions: divisions,
offset: wallOffset
}
],
color: "#21c7ff",
alpha: 0.3,
thickness: 2,
showBorder: true,
borderColor: "#ffffff"
color: color,
alpha: +alpha,
thickness: thickness,
showBorder: !show_border,
borderColor: border_color,
walls: walls
});
kernel.dropZone.generateDropZones(divisions);
kernel.dropZone.generateDropZones();
// 显示放置区域
kernel.dropZone.show();
dropZoneVisible = true;
};
const placementWall = (divisions) => {
const placementWall = () => {
// 只清除旧的放置区域网格,不清除模型
kernel.dropZone.clearZones();
// 如果传入了 divisions使用统一分割数否则使用每个墙面自己的分割数
if (divisions !== undefined) {
kernel.dropZone.generateDropZones(divisions);
} else {
kernel.dropZone.generateDropZones();
}
kernel.dropZone.updateDivisions({
"前": 4,
"后": 1,
"左": 1,
"右": 1
});
// 显示放置区域
kernel.dropZone.show();