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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | 1x 1x 1x 1x 1x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x | /*!
* Copyright 2020 Cognite AS
*/
// @ts-ignore
import * as Potree from '@cognite/potree-core';
import { PotreePointSizeType, PotreePointColorType, PotreePointShape } from './enums';
import { fromThreeJsBox3 } from '../utilities';
import { Box3 } from '../../../utils/Box3';
import { vec3 } from 'gl-matrix';
/**
* Wrapper around `Potree.PointCloudOctree` with some convinence functions.
*/
export class PotreeNodeWrapper {
readonly octtree: Potree.PointCloudOctreeNode;
constructor(octtree: Potree.PointCloudOctreeNode) {
this.octtree = octtree;
this.pointSize = 2;
this.pointSizeType = PotreePointSizeType.Adaptive;
this.pointColorType = PotreePointColorType.Rgb;
this.pointShape = PotreePointShape.Circle;
this.pointBudget = 2_000_000;
}
get pointSize(): number {
return this.octtree.material.size;
}
set pointSize(size: number) {
this.octtree.material.size = size;
}
get pointSizeType(): PotreePointSizeType {
return this.octtree.material.pointSizeType;
}
set pointSizeType(type: PotreePointSizeType) {
this.octtree.material.pointSizeType = type;
}
get pointBudget(): number {
return this.octtree.pointBudget;
}
set pointBudget(count: number) {
this.octtree.pointBudget = count;
}
get visiblePointCount(): number {
return this.octtree.numVisiblePoints || 0;
}
get boundingBox(): Box3 {
const bbox: THREE.Box3 = this.octtree.root.tightBoundingBox;
const box = fromThreeJsBox3(bbox);
// Apply transformation to switch axes
const min = vec3.fromValues(box.min[0], box.min[2], -box.min[1]);
const max = vec3.fromValues(box.max[0], box.max[2], -box.max[1]);
return new Box3([min, max]);
}
get pointColorType(): PotreePointColorType {
return this.octtree.material.pointColorType;
}
set pointColorType(type: PotreePointColorType) {
this.octtree.material.pointColorType = type;
}
get pointShape(): PotreePointShape {
return this.octtree.material.shape;
}
set pointShape(shape: PotreePointShape) {
this.octtree.material.shape = shape;
}
}
|