0.2.9 • Published 2 years ago

@pnext/three-loader v0.2.9

Weekly downloads
1,094
License
MIT
Repository
github
Last release
2 years ago

README

This project is based on the core/loading parts of Potree, converted to Typescript for usage directly in ThreeJS-based third-party applications.

This project focuses solely on the loading of point clouds into ThreeJS applications and doesn't try to provide other things which are available in Potree: earth controls, measurement tools, elevation profiles, etc.

If you have a need for such auxiliary components/tools, we would most definitely welcome contributions, potentially as part of another project under the PNext organization.

And of course, suggestions for better/easier APIs or new features, as well as PRs, are very welcome too!

Usage

import { Scene } from 'three';
import { PointCloudOctree, Potree } from '@pnext/three-loader';

const scene = new Scene();
// Manages the necessary state for loading/updating one or more point clouds.
const potree = new Potree();
// Show at most 2 million points.
potree.pointBudget = 2_000_000;
// List of point clouds which we loaded and need to update.
const pointClouds: PointCloudOctree[] = [];

potree
  .loadPointCloud(
    // The name of the point cloud which is to be loaded.
    'cloud.js',
    // Given the relative URL of a file, should return a full URL (e.g. signed).
    relativeUrl => `${baseUrl}${relativeUrl}`,
  )
  .then(pco => {
    pointClouds.push(pco);
    scene.add(pco); // Add the loaded point cloud to your ThreeJS scene.

    // The point cloud comes with a material which can be customized directly.
    // Here we just set the size of the points.
    pco.material.size = 1.0;
  });

function update() {
  // This is where most of the potree magic happens. It updates the visiblily of the octree nodes
  // based on the camera frustum and it triggers any loads/unloads which are necessary to keep the
  // number of visible points in check.
  potree.updatePointClouds(pointClouds, camera, renderer);

  // Render your scene as normal
  renderer.clear();
  renderer.render(scene, camera);
}

You can play with a live example here: https://codesandbox.io/s/yw2p3446j9?autoresize=1&view=preview

Local Development

To develop and contribute to the project, you need to start by cloning the repositry and then install all the dependencies with yarn:

> yarn

Once that is done you can start a development server by running:

> yarn start

You can also start the example application (/example) by running:

> yarn start:example

To create a production-ready build of the library which can be published to NPM, you can run the following command:

> yarn build

Thank You!

Thank you to Markus Schütz for his work on Potree, on which this project is based.

Contributors

Pix4D

We use this as part of our online 3D model viewer (http://cloud.pix4d.com).

Georepublic

0.2.9

2 years ago

0.2.8

2 years ago

0.2.7

2 years ago

0.2.6-beta.1

3 years ago

0.2.5

3 years ago

0.2.3

3 years ago

0.2.4

3 years ago

0.2.3-beta.1

3 years ago

0.2.3-beta.2

3 years ago

0.2.2

3 years ago

0.2.1-beta.1

4 years ago

0.2.1

4 years ago

0.2.1-beta.0

4 years ago

0.2.0-beta.2

4 years ago

0.2.0-beta.3

4 years ago

0.2.0

4 years ago

0.2.0-beta.1

4 years ago

0.2.0-beta.0

4 years ago

0.2.0-veta.0

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.19

5 years ago

0.0.18

5 years ago

0.0.17

5 years ago

0.0.16

5 years ago

0.0.15

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago