添加显示隐藏状态控制

This commit is contained in:
wzy-warehouse
2026-04-14 08:59:05 +08:00
parent 61725b8b1e
commit 2a3256fa17
14 changed files with 267 additions and 59 deletions
+28
View File
@@ -246,6 +246,34 @@ export class CesiumUtils {
return this.#primitiveManager!.getPrimitiveIds(clearType);
}
/**
* 批量切换Primitives可见性
* @param ids - Primitive ID 数组
* @param visible - 是否可见
*/
batchTogglePrimitives(ids: string[], visible: boolean): void {
this.#checkManager(this.#primitiveManager, 'PrimitiveManager');
this.#primitiveManager!.batchTogglePrimitives(ids, visible);
}
/**
* 批量显示Primitives
* @param ids - Primitive ID 数组
*/
batchShowPrimitives(ids: string[]): void {
this.#checkManager(this.#primitiveManager, 'PrimitiveManager');
this.#primitiveManager!.batchShowPrimitives(ids);
}
/**
* 批量隐藏Primitives
* @param ids - Primitive ID 数组
*/
batchHidePrimitives(ids: string[]): void {
this.#checkManager(this.#primitiveManager, 'PrimitiveManager');
this.#primitiveManager!.batchHidePrimitives(ids);
}
// ===================== 图层管理 =====================
/**
+38
View File
@@ -122,6 +122,44 @@ export class PrimitiveManager {
return this.#getTargetIdsByType(clearType);
}
/**
* 批量显示或隐藏Primitive
* @param ids - Primitive ID 数组
* @param visible - 是否显示
*/
batchTogglePrimitives(ids: string[], visible: boolean): void {
const uniquePrimitives = new Set<Primitive | BillboardCollection>();
for (const id of ids) {
const primitive = this.getPrimitiveById(id);
if (primitive) {
uniquePrimitives.add(primitive);
} else {
console.warn(`Primitive ID "${id}" 不存在,无法设置显示`);
}
}
for (const primitive of uniquePrimitives) {
primitive.show = visible;
}
}
/**
* 批量显示Primitive
* @param ids - Primitive ID 数组
*/
batchShowPrimitives(ids: string[]): void {
this.batchTogglePrimitives(ids, true);
}
/**
* 批量隐藏Primitive
* @param ids - Primitive ID 数组
*/
batchHidePrimitives(ids: string[]): void {
this.batchTogglePrimitives(ids, false);
}
// ===================== 私有方法 =====================
#groupPrimitivesByType(primitives: PrimitiveOptions[]) {