This commit is contained in:
2026-05-19 15:08:02 +08:00
parent 50b8ea355b
commit 127100d27b
3 changed files with 36 additions and 32 deletions

View File

@ -352,10 +352,15 @@
</div>
<div class="category-content">
<div class="option-group">
<button class="option-btn" data-option="color-1">SPF111S1010C</button>
<button class="option-btn" data-option="color-2">SPF111S1010W</button>
13
<button class="option-btn" data-option="color-1">SPF111S1013W</button>
<button class="option-btn" data-option="color-2">SPF111S1013C</button>
<button class="option-btn" data-option="color-3">SPF111S1013TA</button>
10
<button class="option-btn" data-option="color-1">SPF111S1010W</button>
<button class="option-btn" data-option="color-2">SPF111S1010C</button>
<button class="option-btn" data-option="color-3">SPF111S1010TA</button>
<button class="option-btn" data-option="color-4">木色</button>
</div>
</div>
</div>
@ -749,9 +754,13 @@
// 移除按钮事件
document.getElementById('remove-model-btn').addEventListener('click', () => {
const pickedMesh = window.getCurrentPickedMesh();
console.log(pickedMesh);
if (pickedMesh) {
const meshName = pickedMesh.name;
const modelName = kernel.model.findModelNameByMesh(pickedMesh);
console.log(modelName);
const success = kernel.model.removeByName(modelName);
if (success) {
console.log('模型已移除');

View File

@ -436,11 +436,6 @@ export class AppModel extends Monobehiver {
const keys = this.modelDic.Keys();
for (const key of keys) {
const meshes = this.modelDic.Get(key);
meshes.forEach(mesh => {
console.log(mesh.uniqueId);
console.log(mesh.name);
});
if (meshes?.some(m => m === mesh || m.uniqueId === mesh.uniqueId)) {
return key;
@ -501,18 +496,18 @@ export class AppModel extends Monobehiver {
* 销毁指定模型
* @param modelName 模型名称
*/
removeByName(modelName: string): void {
removeByName(modelName: string): boolean {
const meshes = this.modelDic.Get(modelName);
if (!meshes?.length) {
console.warn(`Model not found: ${modelName}`);
return;
return false;
}
this.getModelTransformTargets(meshes).forEach(mesh => mesh.dispose(false, true));
this.modelDic.Remove(modelName);
this.modelMetadataDic.Remove(modelName);
this.mainApp.gameManager?.updateDictionaries();
return true;
}

View File

@ -34,8 +34,8 @@ export class KernelAdapter {
* 销毁指定模型
* @param modelName 模型名称
*/
removeByName: (modelName: string): void => {
this.mainApp.appModel.removeByName(modelName);
removeByName: (modelName: string): boolean => {
return this.mainApp.appModel.removeByName(modelName);
},
/**
* 根据网格移除所属的整个模型