All files / src/utils/potree EptLoader.ts

23.08% Statements 3/13
100% Branches 0/0
100% Functions 1/1
23.08% Lines 3/13

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          2x   2x   1x                          
/*!
 * Copyright 2020 Cognite AS
 */
 
// @ts-ignore
import * as Potree from '@cognite/potree-core';
 
export class EptLoader {
  static async load(eptJsonUrl: string): Promise<Potree.PointCloudOctreeGeometry> {
    const response = await Potree.XHRFactory.fetch(eptJsonUrl);
    const json = await response.json();
    const baseUrl = eptJsonUrl.substr(0, eptJsonUrl.lastIndexOf('ept.json'));
    const geometry = new Potree.PointCloudEptGeometry(baseUrl, json);
    const x = geometry.offset.x;
    const y = geometry.offset.y;
    const z = geometry.offset.z;
    const root = new Potree.PointCloudEptGeometryNode(geometry, geometry.boundingBox, 0, x, y, z);
    geometry.root = root;
    geometry.root.load();
    return geometry;
  }
}