1
This commit is contained in:
@ -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}`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user