This commit is contained in:
2026-04-24 12:18:24 +08:00
parent 09359a1647
commit 6c94559383
7 changed files with 70 additions and 49 deletions

View File

@ -275,19 +275,19 @@
<div class="option-group">
<div class="option-checkbox">
<input type="checkbox" id="louver-1" data-option="louver-1">
<label for="louver-1">百叶A</label>
<label for="louver-1">百叶1</label>
</div>
<div class="option-checkbox">
<input type="checkbox" id="louver-2" data-option="louver-2">
<label for="louver-2">百叶B</label>
<label for="louver-2">百叶2</label>
</div>
<div class="option-checkbox">
<input type="checkbox" id="louver-3" data-option="louver-3">
<label for="louver-3">百叶C</label>
<label for="louver-3">百叶3</label>
</div>
<div class="option-checkbox">
<input type="checkbox" id="louver-4" data-option="louver-4">
<label for="louver-4">百叶D</label>
<label for="louver-4">百叶4</label>
</div>
</div>
</div>
@ -365,10 +365,11 @@
// 多选复选框逻辑
document.querySelectorAll('.option-checkbox input[type="checkbox"]').forEach(checkbox => {
checkbox.addEventListener('change', function () {
checkbox.addEventListener('change', async function () {
const category = this.closest('.config-category');
const categoryName = category.querySelector('.category-header').dataset.category;
const optionGroup = this.closest('.option-group');
const checked = this.checked;
// 获取当前组所有选中的值
const selectedValues = Array.from(
@ -395,17 +396,26 @@
checked: this.checked,
currentValue: this.dataset.option
});
if (category === "louver") {
selectedValues.forEach(element => {
if (checked) {
kernel.model.add(element.text,`https://sdk.zguiy.com/resurces/model/${element.text}.glb`);
} else {
kernel.model.destroy(element.text);
}
});
}
// kernel.model.add('https://sdk.zguiy.com/resurces/model/百叶1.glb');
// 百叶模型加载/卸载逻辑
if (categoryName === "louver") {
const currentText = this.nextElementSibling.textContent;
const modelUrl = `https://sdk.zguiy.com/resurces/model/${currentText}.glb`;
console.log(modelUrl);
if (checked) {
// 加载模型
try {
await kernel.model.add(currentText, modelUrl);
console.log(`模型 ${currentText} 加载成功`);
} catch (error) {
console.error(`模型 ${currentText} 加载失败:`, error);
}
} else {
// 卸载模型
kernel.model.remove(currentText);
console.log(`模型 ${currentText} 已卸载`);
}
}
});
});