All files / views/threejs/cad consumeSectorDetailed.ts

94.12% Statements 16/17
100% Branches 0/0
100% Functions 1/1
94.12% Lines 16/17

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 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38        2x     2x 2x 2x 2x     2x             4x 4x 4x     4x     4x 4x 1x   4x 4x 1x      
/*!
 * Copyright 2020 Cognite AS
 */
 
import * as THREE from 'three';
import { Sector, SectorMetadata } from '../../../models/cad/types';
import { SectorNode } from './SectorNode';
import { toThreeJsBox3 } from '../utilities';
import { createPrimitives } from './primitives';
import { createTriangleMeshes } from './triangleMeshes';
import { createInstancedMeshes } from './instancedMeshes';
import { Materials } from './materials';
 
export function consumeSectorDetailed(
  sectorId: number,
  sector: Sector,
  metadata: SectorMetadata,
  sectorNode: SectorNode,
  materials: Materials
) {
  const bounds = toThreeJsBox3(new THREE.Box3(), metadata.bounds);
  const boundsRenderer = new THREE.Box3Helper(bounds);
  boundsRenderer.name = `Bounding box ${sectorId}`;
  // group.add(boundsRenderer);
 
  for (const primtiveRoot of createPrimitives(sector, materials)) {
    sectorNode.add(primtiveRoot);
  }
  const triangleMeshes = createTriangleMeshes(sector.triangleMeshes, bounds, materials.triangleMesh);
  for (const triangleMesh of triangleMeshes) {
    sectorNode.add(triangleMesh);
  }
  const instanceMeshes = createInstancedMeshes(sector.instanceMeshes, bounds, materials.instancedMesh);
  for (const instanceMesh of instanceMeshes) {
    sectorNode.add(instanceMesh);
  }
}