/** * 加载管理器 */ export class LoadTool { static s_loadingData: Map = new Map(); static s_loadingNum: number = 0; static readonly c_tag_preloadMark = "preloadMark";//预加载标绘物模型(不阻断) static readonly c_tag_createMark = "createMark";//创建标绘物(不阻断) static readonly c_tag_facilityPrefab = "facilityPrefab";//设备预制体 /** * 新增加载数据 * @param data * @param tag */ static add(data: any, tag?: string) { switch (tag) { case LoadTool.c_tag_preloadMark: case LoadTool.c_tag_createMark: return; } let oldNum = LoadTool.s_loadingNum; LoadTool.s_loadingData.set(data, tag); LoadTool.s_loadingNum = LoadTool.s_loadingData.size; if (oldNum == 0 && LoadTool.s_loadingNum == 1) { LoadTool.onStart(); } } /** * 加载完成,移除记录 * @param data */ static remove(data: any) { let oldNum = LoadTool.s_loadingNum; if (LoadTool.s_loadingData.has(data)) { LoadTool.s_loadingData.delete(data); } LoadTool.s_loadingNum = LoadTool.s_loadingData.size; if (oldNum > 0 && LoadTool.s_loadingNum == 0) { LoadTool.onEnd(); } } /** * 开始加载 */ static onStart() { console.log("开始加载"); //ThreeDimensionalHomeComponent.instance.maskLayerService.sendMessage(true) } /** * 全部加载结束 */ static onEnd() { console.log("结束加载"); //ThreeDimensionalHomeComponent.instance.maskLayerService.sendMessage(false) } }