potree-core

Potree Core 2.0

npm version GitHub version

Demo

Example

const scene = new Scene();
const camera = new PerspectiveCamera(60, 1, 0.1, 10000);

const canvas = document.getElementById("canvas");

const renderer = new WebGLRenderer({canvas:canvas});

const geometry = new BoxGeometry(1, 1, 1);
const material = new MeshBasicMaterial({color: 0x00ff00});
const cube = new Mesh(geometry, material);
scene.add(cube);

const controls = new OrbitControls(camera, canvas);
camera.position.z = 10;

const pointClouds = [];

const baseUrl = "data/test/";
const potree = new Potree();
potree.loadPointCloud("cloud.js", baseUrl).then(function(pco) {
   scene.add(pco);
	pointClouds.push(pco);
});

function loop()
{
   potree.updatePointClouds(pointClouds, camera, renderer);

	controls.update();
	renderer.render(scene, camera);

	requestAnimationFrame(loop);
};
loop();

Closed point surfaces

PointShape.CLOSED reconstructs small gaps between points with screen-space binary closing. Use PotreeRenderer to run its multiple passes:

import { PointShape, PotreeRenderer } from 'potree-core';

pco.material.shape = PointShape.CLOSED;
const pointRenderer = new PotreeRenderer({
	closed: { radius: 2, depthThreshold: 0.02 },
	edl: { enabled: false },
});

// Each animation frame:
pointRenderer.updateAndRender(potree, pointClouds, camera, renderer, scene);

// Change settings at runtime:
pointRenderer.setClosed({ radius: 3 });

// When finished (clouds and the three.js renderer remain caller-owned):
pointRenderer.dispose();

Select Closed in the demo’s Points → Shape control. Closing Radius (px) and Closing Depth Tolerance adjust reconstruction.

Run npm run build followed by node tests/run-browser-checks.mjs for the Chromium GPU regression checks. Set BROWSER_PATH if Chromium is installed outside the detected paths. The checks compare the GPU mask against a binary morphology reference, exercise interpolation, depth, clipping and renderer state, and load both bundled cloud formats. Preview images and results are written to build/browser-checks/. To also exercise the demo, first run npm run build:example, then set CHECK_DEMO=1 when running the checks.

Clip Boxes

import { ClipMode, createClipBox } from 'potree-core';
import { Vector3 } from 'three';

pco.material.clipMode = ClipMode.CLIP_OUTSIDE; // global fallback for undefined volume modes

const includeA = createClipBox(new Vector3(10, 10, 10), new Vector3(0, 0, 0), 'include');
const excludeB = createClipBox(new Vector3(4, 4, 4), new Vector3(0, 0, 0), 'exclude');
const inheritedD = createClipBox(new Vector3(3, 3, 3), new Vector3(-3, 0, 0)); // inherits CLIP_OUTSIDE

pco.material.setClipBoxes([includeA, excludeB, inheritedD]);

Clip Spheres

Clip Planes

import { ClipMode, createClipSphere } from 'potree-core';
import { Vector3 } from 'three';

pco.material.clipMode = ClipMode.HIGHLIGHT_INSIDE;

const sphereA = createClipSphere(new Vector3(0, 1, 0), 3, 'exclude');
const sphereB = createClipSphere(new Vector3(5, 1, 0), 2); // inherits HIGHLIGHT_INSIDE

pco.material.setClipSpheres([sphereA, sphereB]);

Custom Request Manager

   class CustomRequestManager implements RequestManager 
   {
      fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {
         throw new Error("Method not implemented.")
      }

      async getUrl(url: string): Promise<string> {
         return url;
      }
   }

Notes

Potree Converter

TXT2LAS

### To Do