1
This commit is contained in:
@ -498,6 +498,28 @@ export class AppModel extends Monobehiver {
|
||||
console.log(`Model removed: ${modelName}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除所有已添加的模型并释放内存
|
||||
* 主要用于切换尺寸后清除不适用的配件
|
||||
*/
|
||||
removeAll(): void {
|
||||
const modelNames = this.modelDic.Keys();
|
||||
console.log(`开始清除所有模型,共 ${modelNames.length} 个模型`);
|
||||
|
||||
modelNames.forEach(modelName => {
|
||||
const meshes = this.modelDic.Get(modelName);
|
||||
if (meshes?.length) {
|
||||
this.getModelTransformTargets(meshes).forEach(mesh => mesh.dispose(false, true));
|
||||
}
|
||||
});
|
||||
|
||||
this.modelDic.Clear();
|
||||
this.modelMetadataDic.Clear();
|
||||
this.mainApp.gameManager?.updateDictionaries();
|
||||
|
||||
console.log('所有模型已清除,内存已释放');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取模型元数据
|
||||
* @param modelName 模型名称
|
||||
|
||||
Reference in New Issue
Block a user