potree-core 2.0.10 → 2.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,29 +6,99 @@ import { PickParams } from './point-cloud-octree-picker';
6
6
  import { PointCloudTree } from './point-cloud-tree';
7
7
  import { IPointCloudTreeNode, IPotree, PickPoint, PCOGeometry } from './types';
8
8
  export declare class PointCloudOctree extends PointCloudTree {
9
+ /**
10
+ * The name of the point cloud octree.
11
+ */
9
12
  potree: IPotree;
13
+ /**
14
+ * Indicates whether the point cloud octree has been disposed.
15
+ *
16
+ * This is set to true when the octree is disposed, and can be used to check if the octree is still valid.
17
+ */
10
18
  disposed: boolean;
19
+ /**
20
+ * The geometry of the point cloud octree.
21
+ *
22
+ * This contains the root node and other properties related to the point cloud geometry.
23
+ */
11
24
  pcoGeometry: PCOGeometry;
25
+ /**
26
+ * The bounding box of the point cloud octree.
27
+ *
28
+ * This is used to define the spatial extent of the point cloud.
29
+ */
12
30
  boundingBox: Box3;
31
+ /**
32
+ * The bounding sphere of the point cloud octree.
33
+ *
34
+ * This is used for spatial queries and to determine visibility.
35
+ */
13
36
  boundingSphere: Sphere;
14
- material: PointCloudMaterial;
37
+ /**
38
+ * The position of the point cloud octree in the 3D space.
39
+ *
40
+ * This is used to position the octree in the scene.
41
+ */
15
42
  level: number;
43
+ /**
44
+ * The maximum level of detail for the point cloud octree.
45
+ *
46
+ * This is used to limit the depth of the octree when rendering or processing.
47
+ */
16
48
  maxLevel: number;
17
49
  /**
18
- * The minimum radius of a node's bounding sphere on the screen in order to be displayed.
19
- */
50
+ * The minimum radius of a node's bounding sphere on the screen in order to be displayed.
51
+ */
20
52
  minNodePixelSize: number;
53
+ /**
54
+ * The root node of the point cloud octree.
55
+ */
21
56
  root: IPointCloudTreeNode | null;
57
+ /**
58
+ * Bounding box nodes for visualization.
59
+ */
22
60
  boundingBoxNodes: Object3D[];
61
+ /**
62
+ * An array of visible nodes in the point cloud octree.
63
+ *
64
+ * These nodes are currently visible in the scene and can be rendered.
65
+ */
23
66
  visibleNodes: PointCloudOctreeNode[];
67
+ /**
68
+ * An array of visible geometry nodes in the point cloud octree.
69
+ *
70
+ * These nodes contain the geometry data for rendering and are currently visible.
71
+ */
24
72
  visibleGeometry: PointCloudOctreeGeometryNode[];
73
+ /**
74
+ * The number of visible points in the point cloud octree.
75
+ *
76
+ * This is used to keep track of how many points are currently visible in the scene.
77
+ */
25
78
  numVisiblePoints: number;
79
+ /**
80
+ * Indicates whether the bounding box should be shown in the scene.
81
+ *
82
+ * This can be toggled to visualize the spatial extent of the point cloud octree.
83
+ */
26
84
  showBoundingBox: boolean;
85
+ private _material;
86
+ /**
87
+ * The bounds of the visible area in the point cloud octree.
88
+ *
89
+ * This is used to determine which nodes are currently visible based on the camera's frustum.
90
+ */
27
91
  private visibleBounds;
92
+ /**
93
+ * The picker used for picking points in the point cloud octree.
94
+ *
95
+ * This is used to interact with the point cloud, such as selecting points or querying information.
96
+ */
28
97
  private picker;
29
98
  constructor(potree: IPotree, pcoGeometry: PCOGeometry, material?: PointCloudMaterial);
30
- private initMaterial;
31
99
  dispose(): void;
100
+ get material(): PointCloudMaterial;
101
+ set material(material: PointCloudMaterial);
32
102
  get pointSizeType(): PointSizeType;
33
103
  set pointSizeType(value: PointSizeType);
34
104
  toTreeNode(geometryNode: PointCloudOctreeGeometryNode, parent?: PointCloudOctreeNode | null): PointCloudOctreeNode;
@@ -1,6 +1,17 @@
1
1
  import { Object3D } from 'three';
2
2
  import { IPointCloudTreeNode } from './types';
3
+ /**
4
+ * Represents a point cloud tree structure.
5
+ */
3
6
  export declare class PointCloudTree extends Object3D {
7
+ /**
8
+ * The root node of the point cloud tree.
9
+ */
4
10
  root: IPointCloudTreeNode | null;
11
+ /**
12
+ * Checks if the point cloud tree has been initialized.
13
+ *
14
+ * @returns Returns true if the tree has been initialized (i.e., root is not null), false otherwise.
15
+ */
5
16
  initialized(): boolean;
6
17
  }
package/dist/potree.d.ts CHANGED
@@ -1,20 +1,34 @@
1
- import { Camera, Ray, WebGLRenderer } from 'three';
2
- import { GetUrlFn } from './loading';
1
+ import { RequestManager } from './loading2/RequestManager';
2
+ import { Camera, Frustum, Ray, Vector2, Vector3, WebGLRenderer } from 'three';
3
3
  import { PointCloudOctree } from './point-cloud-octree';
4
- import { PickParams } from './point-cloud-octree-picker';
4
+ import { PickParams, PointCloudOctreePicker } from './point-cloud-octree-picker';
5
5
  import { IPointCloudTreeNode, IPotree, IVisibilityUpdateResult, PickPoint } from './types';
6
+ import { BinaryHeap } from './utils/binary-heap';
6
7
  import { LRU } from './utils/lru';
8
+ /**
9
+ * Represents an item in a processing queue for point cloud operations.
10
+ *
11
+ * This class is typically used to manage nodes within a point cloud structure, associating each node with a specific weight and its parent node if applicable.
12
+ */
7
13
  export declare class QueueItem {
8
14
  pointCloudIndex: number;
9
15
  weight: number;
10
16
  node: IPointCloudTreeNode;
11
17
  parent?: IPointCloudTreeNode | null;
18
+ /**
19
+ * Creates a new QueueItem instance.
20
+ *
21
+ * @param pointCloudIndex - The index of the point cloud this item belongs to.
22
+ * @param weight - The weight or priority associated with this queue item.
23
+ * @param node - The point cloud tree node represented by this queue item.
24
+ * @param parent - (Optional) The parent node of the current node, or null if it has no parent.
25
+ */
12
26
  constructor(pointCloudIndex: number, weight: number, node: IPointCloudTreeNode, parent?: IPointCloudTreeNode | null);
13
27
  }
14
28
  export declare class Potree implements IPotree {
15
- private static picker;
16
- private _pointBudget;
17
- private _rendererSize;
29
+ static picker: PointCloudOctreePicker | undefined;
30
+ _pointBudget: number;
31
+ _rendererSize: Vector2;
18
32
  maxNumNodesLoading: number;
19
33
  get features(): {
20
34
  SHADER_INTERPOLATION: boolean;
@@ -23,7 +37,8 @@ export declare class Potree implements IPotree {
23
37
  precision: string;
24
38
  };
25
39
  lru: LRU;
26
- loadPointCloud(url: string, getUrl: GetUrlFn, xhrRequest?: (input: RequestInfo, init?: RequestInit) => Promise<Response>): Promise<PointCloudOctree>;
40
+ loadPointCloud(url: string, baseUrl: string): Promise<PointCloudOctree>;
41
+ loadPointCloud(url: string, requestManager: RequestManager): Promise<PointCloudOctree>;
27
42
  updatePointClouds(pointClouds: PointCloudOctree[], camera: Camera, renderer: WebGLRenderer): IVisibilityUpdateResult;
28
43
  static pick(pointClouds: PointCloudOctree[], renderer: WebGLRenderer, camera: Camera, ray: Ray, params?: Partial<PickParams>): PickPoint | null;
29
44
  get pointBudget(): number;
@@ -33,5 +48,9 @@ export declare class Potree implements IPotree {
33
48
  private updateChildVisibility;
34
49
  private updateBoundingBoxVisibility;
35
50
  private shouldClip;
36
- private updateVisibilityStructures;
51
+ updateVisibilityStructures: (pointClouds: PointCloudOctree[], camera: Camera) => {
52
+ frustums: Frustum[];
53
+ cameraPositions: Vector3[];
54
+ priorityQueue: BinaryHeap<QueueItem>;
55
+ };
37
56
  }
@@ -0,0 +1,25 @@
1
+ import { Camera, Object3D, WebGLRenderer } from 'three';
2
+ import { PointCloudOctree } from '../point-cloud-octree';
3
+ export type EDLPassParams = {
4
+ renderer: WebGLRenderer;
5
+ scene: Object3D;
6
+ camera: Camera;
7
+ pointClouds?: PointCloudOctree[];
8
+ pointCloudLayer?: number;
9
+ };
10
+ export declare class EDLPass {
11
+ edlStrength: number;
12
+ radius: number;
13
+ opacity: number;
14
+ neighbourCount: number;
15
+ private rtEDL;
16
+ private rtTypeChecked;
17
+ private edlMaterial;
18
+ private screenPass;
19
+ private size;
20
+ constructor();
21
+ private ensureRenderTargetType;
22
+ dispose(): void;
23
+ private resizeToRenderer;
24
+ render(params: EDLPassParams): void;
25
+ }
@@ -0,0 +1,83 @@
1
+ import { Camera, Object3D, WebGLRenderer } from 'three';
2
+ import { PointCloudOctree } from '../point-cloud-octree';
3
+ import { Potree } from '../potree';
4
+ import { IVisibilityUpdateResult } from '../types';
5
+ /**
6
+ * Configuration for Eye-Dome Lighting (EDL) rendering.
7
+ *
8
+ * Note: EDL is a multi-pass / post-process effect (render default layer 0 (non-pointcloud), render point clouds to an offscreen target,
9
+ * then composite). Therefore it cannot be expressed as a single `renderer.render(scene, camera)` call.
10
+ */
11
+ export type PotreeRendererEDLOptions = {
12
+ enabled: boolean;
13
+ /** Defaults to 1 so layer 0 can remain reserved for non-pointcloud content in the first pass. */
14
+ pointCloudLayer?: number;
15
+ strength?: number;
16
+ radius?: number;
17
+ opacity?: number;
18
+ neighbourCount?: number;
19
+ };
20
+ /**
21
+ * Options for {@link PotreeRenderer}.
22
+ *
23
+ * This is intentionally additive and does not change existing Potree APIs.
24
+ */
25
+ export type PotreeRendererOptions = {
26
+ edl?: PotreeRendererEDLOptions;
27
+ };
28
+ /**
29
+ * Parameters required to render a frame.
30
+ */
31
+ export type PotreeRendererRenderParams = {
32
+ renderer: WebGLRenderer;
33
+ scene: Object3D;
34
+ camera: Camera;
35
+ pointClouds?: PointCloudOctree[];
36
+ };
37
+ /**
38
+ * Thin helper that renders Potree point clouds.
39
+ *
40
+ * Why this exists:
41
+ * - Without EDL, users typically do: `potree.updatePointClouds(...)` then `renderer.render(scene, camera)`.
42
+ * - With EDL enabled, users previously had to manually:
43
+ * 1) keep point-cloud objects on a dedicated layer, and
44
+ * 2) run `EDLPass.render(...)` instead of `renderer.render(...)`.
45
+ *
46
+ * `PotreeRenderer` keeps that wiring in one place while preserving backward compatibility.
47
+ */
48
+ export declare class PotreeRenderer {
49
+ private edlPass;
50
+ private edlOptions;
51
+ private lastPointClouds;
52
+ private overriddenMaterials;
53
+ private overriddenLayerMasks;
54
+ constructor(options?: PotreeRendererOptions);
55
+ /** Releases internally owned GPU resources (render targets). */
56
+ dispose(): void;
57
+ /**
58
+ * Enables/disables EDL and updates EDL parameters.
59
+ *
60
+ * This method is safe to call at runtime (e.g. toggling EDL on/off).
61
+ */
62
+ setEDL(options: PotreeRendererEDLOptions): void;
63
+ private setLayerMaskRecursive;
64
+ /**
65
+ * Ensures all point-cloud objects (including newly created child nodes) are on the provided layer.
66
+ * Side effect: overwrites `Object3D.layers` for the point cloud subtree.
67
+ *
68
+ * When EDL is enabled, layer separation is required so we can render:
69
+ * - non-pointcloud content first (layer 0), then
70
+ * - point clouds on a dedicated layer into an offscreen target.
71
+ */
72
+ syncPointCloudLayers(pointClouds: PointCloudOctree[], layer: number): void;
73
+ private applyEDLState;
74
+ /**
75
+ * Renders a frame.
76
+ *
77
+ * - EDL disabled: calls `renderer.render(scene, camera)`.
78
+ * - EDL enabled: runs the EDL multi-pass pipeline via {@link EDLPass}.
79
+ */
80
+ render(params: PotreeRendererRenderParams): void;
81
+ /** Convenience helper: `updatePointClouds()` followed by {@link render}. */
82
+ updateAndRender(potree: Potree, pointClouds: PointCloudOctree[], camera: Camera, renderer: WebGLRenderer, scene: Object3D): IVisibilityUpdateResult;
83
+ }
@@ -0,0 +1,11 @@
1
+ import { RawShaderMaterial, WebGLRenderer, WebGLRenderTarget } from 'three';
2
+ export declare class ScreenPass {
3
+ private scene;
4
+ private camera;
5
+ private quad;
6
+ private geometry;
7
+ private placeholderMaterial;
8
+ constructor();
9
+ dispose(): void;
10
+ render(renderer: WebGLRenderer, material: RawShaderMaterial, target?: WebGLRenderTarget | null): void;
11
+ }
@@ -1,3 +1,15 @@
1
1
  import { PointCloudOctreeGeometryNode } from './point-cloud-octree-geometry-node';
2
+ /**
3
+ * Checks if the given node is a geometry node.
4
+ *
5
+ * @param node - Node to check.
6
+ * @returns True if the node is a geometry node, false otherwise.
7
+ */
2
8
  export declare function isGeometryNode(node?: any): node is PointCloudOctreeGeometryNode;
9
+ /**
10
+ * Checks if the given node is a tree node.
11
+ *
12
+ * @param node - Node to check.
13
+ * @returns True if the node is a tree node, false otherwise.
14
+ */
3
15
  export declare function isTreeNode(node?: any): any;
package/dist/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
+ import { RequestManager } from './loading2/RequestManager';
1
2
  import { OctreeGeometry } from './loading2/OctreeGeometry';
2
3
  import { PointCloudOctreeGeometry } from './point-cloud-octree-geometry';
3
4
  import { Box3, Camera, Sphere, Vector3, WebGLRenderer } from 'three';
4
- import { GetUrlFn, XhrRequest } from './loading/types';
5
5
  import { PointCloudOctree } from './point-cloud-octree';
6
6
  import { LRU } from './utils/lru';
7
7
  export interface IPointCloudTreeNode {
@@ -24,6 +24,7 @@ export interface IVisibilityUpdateResult {
24
24
  numVisiblePoints: number;
25
25
  /**
26
26
  * True when a node has been loaded but was not added to the scene yet.
27
+ *
27
28
  * Make sure to call updatePointClouds() again on the next frame.
28
29
  */
29
30
  exceededMaxLoadsToGPU: boolean;
@@ -40,7 +41,8 @@ export interface IPotree {
40
41
  pointBudget: number;
41
42
  maxNumNodesLoading: number;
42
43
  lru: LRU;
43
- loadPointCloud(url: string, getUrl: GetUrlFn, xhrRequest?: XhrRequest): Promise<PointCloudOctree>;
44
+ loadPointCloud(url: string, baseUrl: string): Promise<PointCloudOctree>;
45
+ loadPointCloud(url: string, requestManager: RequestManager): Promise<PointCloudOctree>;
44
46
  updatePointClouds(pointClouds: PointCloudOctree[], camera: Camera, renderer: WebGLRenderer): IVisibilityUpdateResult;
45
47
  }
46
48
  export interface PickPoint {
@@ -0,0 +1,16 @@
1
+ export class BinaryHeap<T>
2
+ {
3
+ constructor(scoreFunction: (node: T)=> number);
4
+
5
+ push(node: T): void;
6
+
7
+ pop(): T | undefined;
8
+
9
+ remove(node: T): void;
10
+
11
+ size(): number;
12
+
13
+ bubbleUp(n: number): void;
14
+
15
+ sinkDown(n: number): void;
16
+ }
@@ -1,6 +1,17 @@
1
1
  import { Box3, Matrix4 } from 'three';
2
2
  /**
3
- * adapted from mhluska at https://github.com/mrdoob/three.js/issues/1561
3
+ * Computes the transformed bounding box of a given Box3 using a transformation matrix.
4
+ *
5
+ * @param box - The original bounding box to transform.
6
+ * @param transform - The transformation matrix to apply.
7
+ * @returns A new Box3 that represents the transformed bounding box.
4
8
  */
5
9
  export declare function computeTransformedBoundingBox(box: Box3, transform: Matrix4): Box3;
10
+ /**
11
+ * Creates a child AABB (Axis-Aligned Bounding Box) from a parent AABB based on the specified index.
12
+ *
13
+ * @param aabb - The parent AABB from which to create the child AABB.
14
+ * @param index - The index that determines how to split the parent AABB into a child AABB.
15
+ * @returns New Box3 representing the child AABB.
16
+ */
6
17
  export declare function createChildAABB(aabb: Box3, index: number): Box3;
@@ -1,12 +1,8 @@
1
1
  import { Box3, Color, LineSegments } from 'three';
2
2
  /**
3
+ * Helper class to visualize a Box3 bounding box in 3D space.
3
4
  *
4
- * code adapted from three.js BoxHelper.js
5
- * https://github.com/mrdoob/three.js/blob/dev/src/helpers/BoxHelper.js
6
- *
7
- * @author mrdoob / http://mrdoob.com/
8
- * @author Mugen87 / http://github.com/Mugen87
9
- * @author mschuetz / http://potree.org
5
+ * Code adapted from three.js BoxHelper.js
10
6
  */
11
7
  export declare class Box3Helper extends LineSegments {
12
8
  constructor(box: Box3, color?: Color);
@@ -11,22 +11,76 @@ export declare class LRUItem {
11
11
  */
12
12
  export declare class LRU {
13
13
  pointBudget: number;
14
+ /**
15
+ * The least recently used item.
16
+ */
14
17
  first: LRUItem | null;
18
+ /**
19
+ * The most recently used item
20
+ */
15
21
  last: LRUItem | null;
22
+ /**
23
+ * The total number of points in the LRU cache.
24
+ */
16
25
  numPoints: number;
26
+ /**
27
+ * Items in the LRU cache, indexed by node ID.
28
+ */
17
29
  private items;
30
+ /**
31
+ * Creates a new LRU cache with a specified point budget.
32
+ *
33
+ * @param pointBudget The maximum number of points that can be stored in the LRU cache.
34
+ */
18
35
  constructor(pointBudget?: number);
19
36
  get size(): number;
37
+ /**
38
+ * Checks if the LRU cache contains the specified node.
39
+ *
40
+ * @param node - The node to check for in the LRU cache.
41
+ * @returns Returns true if the node is in the cache, false otherwise.
42
+ */
20
43
  has(node: Node): boolean;
21
44
  /**
22
- * Makes the specified the most recently used item. if the list does not contain node, it will
23
- * be added.
24
- */
45
+ * Makes the specified the most recently used item. if the list does not contain node, it will be added.
46
+ *
47
+ * @param node - The node to touch, making it the most recently used item in the LRU cache.
48
+ */
25
49
  touch(node: Node): void;
50
+ /**
51
+ * Adds a new node to the LRU cache, making it the most recently used item.
52
+ *
53
+ * @param node - The node to add to the LRU cache.
54
+ */
26
55
  private addNew;
56
+ /**
57
+ * Touches an existing item in the LRU cache, moving it to the end of the list (most recently used).
58
+ *
59
+ * @param item - The LRUItem to touch, making it the most recently used item in the cache.
60
+ */
27
61
  private touchExisting;
62
+ /**
63
+ * Removes a node from the LRU cache.
64
+ *
65
+ * @param node - The node to remove from the LRU cache.
66
+ */
28
67
  remove(node: Node): void;
68
+ /**
69
+ * Gets the least recently used item from the LRU cache.
70
+ *
71
+ * @returns Returns the least recently used node, or undefined if the cache is empty.
72
+ */
29
73
  getLRUItem(): Node | undefined;
74
+ /**
75
+ * Frees up memory by removing the least recently used items until the number of points is below the point budget.
76
+ *
77
+ * @returns - Returns nothing.
78
+ */
30
79
  freeMemory(): void;
80
+ /**
81
+ * Disposes of a subtree starting from the specified node and removes it from the LRU cache.
82
+ *
83
+ * @param node - The root node of the subtree to dispose of.
84
+ */
31
85
  disposeSubtree(node: Node): void;
32
86
  }
@@ -1 +1,9 @@
1
+ /**
2
+ * Clamps a number between a minimum and maximum value.
3
+ *
4
+ * @param value - The number to clamp.
5
+ * @param min - The minimum value the number can be.
6
+ * @param max - The maximum value the number can be.
7
+ * @returns Clamped value between min and max.
8
+ */
1
9
  export declare function clamp(value: number, min: number, max: number): number;
package/dist/version.d.ts CHANGED
@@ -3,7 +3,25 @@ export declare class Version {
3
3
  versionMajor: number;
4
4
  versionMinor: number;
5
5
  constructor(version: string);
6
+ /**
7
+ * Checks if this version is newer than the given version.
8
+ *
9
+ * @param version - The version to compare against.
10
+ * @returns True if this version is newer than the given version, false otherwise.
11
+ */
6
12
  newerThan(version: string): boolean;
13
+ /**
14
+ * Checks if this version is equal or higher than the given version.
15
+ *
16
+ * @param version - The version to compare against.
17
+ * @returns True if this version is equal or higher than the given version, false otherwise.
18
+ */
7
19
  equalOrHigher(version: string): boolean;
20
+ /**
21
+ * Checks if this version is equal or lower than the given version.
22
+ *
23
+ * @param version - The version to compare against.
24
+ * @returns True if this version is equal or lower than the given version, false otherwise.
25
+ */
8
26
  upTo(version: string): boolean;
9
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "potree-core",
3
- "version": "2.0.10",
3
+ "version": "2.0.12",
4
4
  "description": "Potree wrapper for three.js applications",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,10 +15,10 @@
15
15
  "dev": "webpack --mode development --watch --progress --stats-children",
16
16
  "build": "webpack --mode production --config webpack.prod.js",
17
17
  "start": "npm run build && webpack-dev-server --config webpack.example.js --mode development --progress --port 5200",
18
- "docs": "jsdoc -d docs source",
19
- "pub": "npm run build && npm publish --access public .",
20
- "lint": "eslint source",
21
- "lint-fix": "eslint --fix source"
18
+ "docs": "typedoc source/** --out docs --tsconfig tsconfig.json --theme default --excludeExternals --excludeNotDocumented",
19
+ "pub": "npm run build && npm run docs && npm publish --access public .",
20
+ "lint": "eslint ./source",
21
+ "lint-fix": "eslint --fix ./source"
22
22
  },
23
23
  "keywords": [
24
24
  "three",
@@ -32,7 +32,6 @@
32
32
  "three": ">0.125.0"
33
33
  },
34
34
  "dependencies": {
35
- "three": "^0.154.0",
36
35
  "brotli": "1.3.3"
37
36
  },
38
37
  "devDependencies": {
@@ -48,12 +47,14 @@
48
47
  "html-webpack-plugin": "5.5.0",
49
48
  "raw-loader": "4.0.2",
50
49
  "style-loader": "3.3.1",
50
+ "three": "^0.154.0",
51
51
  "ts-loader": "9.5.1",
52
+ "typedoc": "0.28.5",
52
53
  "typescript": "5.5.4",
53
54
  "webpack": "5.94.0",
54
55
  "webpack-bundle-analyzer": "4.10.2",
55
56
  "webpack-cli": "5.1.4",
56
- "webpack-dev-server": "5.0.4",
57
+ "webpack-dev-server": "5.2.1",
57
58
  "worker-loader": "3.0.8"
58
59
  }
59
60
  }