(entity: Entity, depth: number)
| 250 | if (!scene) return []; |
| 251 | |
| 252 | const buildNode = (entity: Entity, depth: number): EntityNode => { |
| 253 | const hierarchy = entity.getComponent(HierarchyComponent); |
| 254 | const childIds = hierarchy?.childIds ?? []; |
| 255 | const bIsEntityFolder = isFolder(entity.tag); |
| 256 | |
| 257 | const children: EntityNode[] = []; |
| 258 | for (const childId of childIds) { |
| 259 | const childEntity = scene.findEntityById(childId); |
| 260 | if (childEntity) { |
| 261 | children.push(buildNode(childEntity, depth + 1)); |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | // Collect virtual nodes from components |
| 266 | // 从组件收集虚拟节点 |
| 267 | const virtualNodes = VirtualNodeRegistry.getAllVirtualNodesForEntity(entity); |
| 268 | |
| 269 | return { |
| 270 | entity, |
| 271 | children, |
| 272 | depth, |
| 273 | bIsFolder: bIsEntityFolder, |
| 274 | hasChildren: children.length > 0 || virtualNodes.length > 0, |
| 275 | virtualNodes: virtualNodes.length > 0 ? virtualNodes : undefined |
| 276 | }; |
| 277 | }; |
| 278 | |
| 279 | return rootEntities.map((entity) => buildNode(entity, 1)); |
| 280 | }, []); |
no test coverage detected