All files / datasources/local/pointcloud createLocalPointCloudModel.ts

90.91% Statements 10/11
50% Branches 1/2
100% Functions 2/2
90.91% Lines 10/11

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        1x     1x 1x     1x   1x 1x 1x         1x         1x     1x    
/*!
 * Copyright 2020 Cognite AS
 */
 
import { mat4 } from 'gl-matrix';
import { FetchPointCloudDelegate } from '../../../models/pointclouds/delegates';
import { SectorModelTransformation } from '../../../models/cad/types';
import { PointCloudLoader } from '../../../utils/potree/PointCloudLoader';
import { EptLoader } from '../../../utils/potree/EptLoader';
import { PointCloudModel } from '../../../models/pointclouds/PointCloudModel';
 
const identity = mat4.identity(mat4.create());
 
export function createLocalPointCloudModel(url: string): PointCloudModel {
  const fetchPointCloud: FetchPointCloudDelegate = async () => {
    const transform: SectorModelTransformation = {
      modelMatrix: identity,
      inverseModelMatrix: identity
    };
 
    Iif (url.endsWith('ept.json')) {
      // Entwine format
      return [await EptLoader.load(url), transform];
    } else {
      // Potree format
      return [await PointCloudLoader.load(url), transform];
    }
  };
  return [fetchPointCloud];
}