This commit is contained in:
2026-05-25 10:43:25 +08:00
parent 84c8752e0b
commit 44925388af
5 changed files with 320 additions and 15 deletions

View File

@ -453,7 +453,7 @@
<div class="category-content expanded">
<div class="option-group">
<button class="option-btn" data-option="color-1">SPFPDS13FTW</button>
<button class="option-btn" data-option="color-2">SPFPDS13FTC</button>
<button class="option-btn" data-option="color-2">SPFSW13FTC</button>
</div>
</div>
</div>
@ -911,23 +911,62 @@
// 生成放置区域按钮事件
let dropZoneVisible = false;
document.getElementById('dropzone-btn').addEventListener('click', () => {
if (!dropZoneVisible) {
document.getElementById('dropzone-btn').addEventListener('click', async () => {
const { wallName, index } = dropzone_data;
// 先正常放置模型
await window.AppLogic.getEvent(dropzone_data, sku);
// 更新按钮文字
document.getElementById('dropzone-btn').textContent = '隐藏放置区域';
console.log('已生成并显示放置区域');
} else {
// 隐藏放置区域
kernel.dropZone.hideAll();
dropZoneVisible = false;
// 检查该墙面是否已满
const zones = kernel.dropZone.getPlacementZones();
const wallZones = zones.filter(z => z.wallName === wallName);
// 更新按钮文字
document.getElementById('dropzone-btn').textContent = '生成放置区域';
console.log('已隐藏放置区域');
// 获取该墙面已放置的模型
const placedModels = kernel.dropZone.getPlacedModels(wallName);
// 如果该墙面所有区域都已占用
if (placedModels.length === wallZones.length) {
console.log(`${wallName} 墙面已满,自动排列模型`);
// 按区域索引排序
const sortedZones = wallZones.sort((a, b) => a.index - b.index);
// 重新排列模型到对应区域
placedModels.forEach((model, idx) => {
const targetZone = sortedZones[idx];
const { position, rotation } = targetZone.transform;
// 移动模型到目标位置
kernel.transform.position({
modelId: model.modelId,
vector3: position
});
kernel.transform.rotation({
modelId: model.modelId,
vector3: rotation
});
// 禁用该模型的拖拽
kernel.model.setDragEnabled(model.modelId, false);
});
console.log('模型已自动排列并禁用拖拽');
}
// if (!dropZoneVisible) {
// // 更新按钮文字
// document.getElementById('dropzone-btn').textContent = '隐藏放置区域';
// console.log('已生成并显示放置区域');
// } else {
// // 隐藏放置区域
// kernel.dropZone.hideAll();
// dropZoneVisible = false;
// // 更新按钮文字
// document.getElementById('dropzone-btn').textContent = '生成放置区域';
// console.log('已隐藏放置区域');
// }
});
// 初始化放置区域配置数据(只需设置一次)