1
This commit is contained in:
@ -29,6 +29,9 @@ export class AppDropZone {
|
||||
// 墙面 -> 该墙面模型对应的分割数(用于检测分割数变化)
|
||||
private wallModelDivisionsMap: Map<string, number> = new Map();
|
||||
|
||||
// 存储放置区域配置数据
|
||||
private dropZoneConfig: DropZoneConfig | null = null;
|
||||
|
||||
constructor(scene: Scene) {
|
||||
this.scene = scene;
|
||||
this.placementWall = new AppPlacementWall(scene);
|
||||
@ -42,16 +45,41 @@ export class AppDropZone {
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成放置区域
|
||||
* 设置放置区域数据
|
||||
* @param config 配置参数
|
||||
*/
|
||||
generateDropZones(config: DropZoneConfig): PlacementZoneInfo[] {
|
||||
setData(config: DropZoneConfig): void {
|
||||
this.dropZoneConfig = config;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成放置区域
|
||||
* @param divisions 分割数量(必传)
|
||||
* @param config 配置参数(可选,如果不传则使用 setData 设置的数据)
|
||||
*/
|
||||
generateDropZones(divisions: number, config?: DropZoneConfig): PlacementZoneInfo[] {
|
||||
const finalConfig = config || this.dropZoneConfig;
|
||||
|
||||
if (!finalConfig) {
|
||||
console.error('未设置放置区域配置数据,请先调用 setData 或传入 config 参数');
|
||||
return [];
|
||||
}
|
||||
|
||||
// 为所有墙面设置分割数,同时保留其他配置属性
|
||||
const configWithDivisions: DropZoneConfig = {
|
||||
...finalConfig, // 保留所有配置属性(color, alpha, thickness, showBorder, borderColor)
|
||||
walls: finalConfig.walls.map(wall => ({
|
||||
...wall,
|
||||
divisions: divisions
|
||||
}))
|
||||
};
|
||||
|
||||
// 只记录分割数,不自动卸载模型
|
||||
config.walls.forEach(wall => {
|
||||
configWithDivisions.walls.forEach(wall => {
|
||||
this.wallDivisionsMap.set(wall.name, wall.divisions);
|
||||
});
|
||||
|
||||
return this.placementWall.generatePlacementAreas(config);
|
||||
return this.placementWall.generatePlacementAreas(configWithDivisions);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user