MCPcopy Create free account
hub / github.com/esengine/esengine / buildNode

Function buildNode

packages/editor-app/src/components/SceneHierarchy.tsx:252–277  ·  view source on GitHub ↗
(entity: Entity, depth: number)

Source from the content-addressed store, hash-verified

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 }, []);

Callers 1

SceneHierarchyFunction · 0.70

Calls 5

isFolderFunction · 0.85
pushMethod · 0.65
getComponentMethod · 0.45
findEntityByIdMethod · 0.45

Tested by

no test coverage detected