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 | 1x 1x 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 3x 2x | /*!
* Copyright 2020 Cognite AS
*/
// @ts-ignore
import * as Potree from '@cognite/potree-core';
import * as THREE from 'three';
import { PotreeNodeWrapper } from './PotreeNodeWrapper';
/**
* Wrapper around Potree.Group with type information and
* basic functionality.
*/
export class PotreeGroupWrapper extends THREE.Object3D {
get needsRedraw(): boolean {
return (
Potree.Global.numNodesLoading !== this.numNodesLoadingAfterLastRedraw ||
this.numChildrenAfterLastRedraw !== this.potreeGroup.children.length
);
}
private readonly potreeGroup: Potree.Group;
private numNodesLoadingAfterLastRedraw = 0;
private numChildrenAfterLastRedraw = 0;
constructor() {
super();
this.potreeGroup = new Potree.Group();
this.potreeGroup.name = 'PotreeGroup';
this.name = 'Potree point cloud wrapper';
this.add(this.potreeGroup);
const onAfterRenderTrigger = new THREE.Mesh(new THREE.Geometry());
onAfterRenderTrigger.onAfterRender = () => this.resetNeedsRedraw();
this.add(onAfterRenderTrigger);
}
addPointCloud(node: PotreeNodeWrapper): void {
this.potreeGroup.add(node.octtree);
}
*pointClouds(): Generator<PotreeNodeWrapper> {
for (const child of this.potreeGroup.children) {
yield new PotreeNodeWrapper(child as Potree.PointCloudOcttree);
}
}
private resetNeedsRedraw() {
this.numNodesLoadingAfterLastRedraw = Potree.Global.numNodesLoading;
this.numChildrenAfterLastRedraw = this.potreeGroup.children.length;
}
}
|