1
This commit is contained in:
@ -54,10 +54,9 @@ export class AppDropZone {
|
||||
|
||||
/**
|
||||
* 生成放置区域
|
||||
* @param divisions 可选的统一分割数量,如果不传则使用每个墙面自己的 divisions
|
||||
* @param config 配置参数(可选,如果不传则使用 setData 设置的数据)
|
||||
*/
|
||||
generateDropZones(divisions?: number, config?: DropZoneConfig): PlacementZoneInfo[] {
|
||||
generateDropZones(config?: DropZoneConfig): PlacementZoneInfo[] {
|
||||
const finalConfig = config || this.dropZoneConfig;
|
||||
|
||||
if (!finalConfig) {
|
||||
@ -65,13 +64,12 @@ export class AppDropZone {
|
||||
return [];
|
||||
}
|
||||
|
||||
// 为墙面设置分割数
|
||||
// 为墙面设置分割数(使用每个墙面自己的 divisions,默认为 1)
|
||||
const configWithDivisions: DropZoneConfig = {
|
||||
...finalConfig, // 保留所有配置属性(color, alpha, thickness, showBorder, borderColor)
|
||||
walls: finalConfig.walls.map(wall => ({
|
||||
...wall,
|
||||
// 如果传入了统一的 divisions,使用它;否则使用墙面自己的 divisions;都没有则默认为 1
|
||||
divisions: divisions !== undefined ? divisions : (wall.divisions || 1)
|
||||
divisions: wall.divisions || 1
|
||||
}))
|
||||
};
|
||||
|
||||
@ -83,6 +81,34 @@ export class AppDropZone {
|
||||
return this.placementWall.generatePlacementAreas(configWithDivisions);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新墙面分割数并重新生成放置区域
|
||||
* @param divisions 分割数对象,key 为墙面名称,value 为分割数,例如 { "前": 4, "后": 1, "左": 1, "右": 1 }
|
||||
*/
|
||||
updateDivisions(divisions: Record<string, number>): PlacementZoneInfo[] {
|
||||
if (!this.dropZoneConfig) {
|
||||
console.error('未设置放置区域配置数据,请先调用 setData');
|
||||
return [];
|
||||
}
|
||||
|
||||
// 更新配置中的墙面分割数
|
||||
this.dropZoneConfig.walls = this.dropZoneConfig.walls.map(wall => ({
|
||||
...wall,
|
||||
divisions: divisions[wall.name] !== undefined ? divisions[wall.name] : wall.divisions || 1
|
||||
}));
|
||||
|
||||
// 清除旧的放置区域网格(不清除模型)
|
||||
this.clearZones();
|
||||
|
||||
// 重新生成放置区域
|
||||
const zones = this.generateDropZones();
|
||||
|
||||
// 显示放置区域
|
||||
this.show();
|
||||
|
||||
return zones;
|
||||
}
|
||||
|
||||
/**
|
||||
* 卸载指定墙面的所有模型(内部方法)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user