This commit is contained in:
2026-03-11 11:56:46 +08:00
parent ae59fbe68b
commit 7fdbf19951
9 changed files with 613 additions and 12 deletions

View File

@ -149,4 +149,29 @@ export class AppModel extends Monobehiver {
this.skeletonMerged = false;
}
/**
* 销毁指定模型
* @param modelName 模型名称
*/
destroyModel(modelName: string): void {
// 遍历模型字典,查找匹配的模型
const keys = this.modelDic.Keys();
for (const key of keys) {
if (key.includes(modelName)) {
const meshes = this.modelDic.Get(key);
if (meshes) {
// 销毁所有网格
meshes.forEach(mesh => mesh?.dispose());
// 从字典中移除
this.modelDic.Remove(key);
// 从加载的网格列表中移除
this.loadedMeshes = this.loadedMeshes.filter(mesh => !meshes.includes(mesh));
console.log(`Model destroyed: ${modelName}`);
return;
}
}
}
console.warn(`Model not found: ${modelName}`);
}
}