diff --git a/index.html b/index.html index 9c27841..5614f4b 100644 --- a/index.html +++ b/index.html @@ -338,6 +338,7 @@ + diff --git a/index.js b/index.js index a897874..5ea4668 100644 --- a/index.js +++ b/index.js @@ -214,13 +214,14 @@ export const executeEvent2 = async (result) => { console.log(`检查模型 ${name + '_' + category} 是否存在:`, modelAlreadyExists); } } - kernel.dropZone.clearZones(); + // 只有在需要更换模型且模型不存在时才清除 if (hasModelChange && !modelAlreadyExists) { console.log('模型不存在,执行清除操作'); kernel.model.removeAll(); } else if (modelAlreadyExists) { + kernel.dropZone.hide(); console.log('模型已存在,跳过清除操作,仅更新材质'); } diff --git a/src/babylonjs/AppDropZone.ts b/src/babylonjs/AppDropZone.ts index 52f0e47..0a642b3 100644 --- a/src/babylonjs/AppDropZone.ts +++ b/src/babylonjs/AppDropZone.ts @@ -31,6 +31,8 @@ export class AppDropZone { // 存储放置区域配置数据 private dropZoneConfig: DropZoneConfig | null = null; + // 存储原始墙面配置(用于 updateDivisions 时恢复完整墙面列表) + private originalWalls: WallConfig[] = []; constructor(scene: Scene) { this.scene = scene; @@ -50,6 +52,8 @@ export class AppDropZone { */ setData(config: DropZoneConfig): void { this.dropZoneConfig = config; + // 保存原始墙面配置的深拷贝 + this.originalWalls = config.walls.map(wall => ({ ...wall })); } /** @@ -145,8 +149,8 @@ export class AppDropZone { return null; }; - // 更新配置中的墙面分割数,只保留后端配置的墙面 - this.dropZoneConfig.walls = this.dropZoneConfig.walls + // 更新配置中的墙面分割数,从原始配置中恢复墙面列表 + this.dropZoneConfig.walls = this.originalWalls .map(wall => { const newDivisions = matchWallName(wall.name);