All files / src/views/threejs/cad buildScene.ts

22.22% Statements 2/9
100% Branches 0/0
0% Functions 0/2
22.22% Lines 2/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21        1x     1x                          
/*!
 * Copyright 2020 Cognite AS
 */
 
import { SectorNode } from './SectorNode';
import { SectorMetadata } from '../../../models/cad/types';
 
export function buildScene(sector: SectorMetadata, root: SectorNode, sectorNodeMap: Map<number, SectorNode>) {
  return buildSceneRecurse(sector, root, sectorNodeMap);
}
 
function buildSceneRecurse(sector: SectorMetadata, parent: SectorNode, sectorNodeMap: Map<number, SectorNode>) {
  const sectorGroup = new SectorNode(sector.id, sector.path);
  sectorGroup.name = `Sector ${sector.id}`;
  parent.add(sectorGroup);
  sectorNodeMap.set(sector.id, sectorGroup);
  for (const child of sector.children) {
    buildSceneRecurse(child, sectorGroup, sectorNodeMap);
  }
}