Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,4 @@ node_modules/
.idea/
dist/

package-lock.json



docs/
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,46 @@ loop();
### To Do
- Supports logarithmic depth buffer (just by enabling it on the threejs renderer), useful for large scale visualization.
- Point clouds are automatically updated, frustum culling is used to avoid unnecessary updates (better update performance for multiple point clouds).


### fastlabel 対応の拡張履歴

#### 反映方法

```
npm run build
npm pack
```


生成された fastlabel-potree-core-2.0.11-fastlabel.0.0.x.tgz を fastlabel-application へ移動

古いバージョンを削除して、新規をインポート

```
yarn remove @fastlabel/potree-core
file:./lib/fastlabel-potree-core-2.0.11-fastlabel.0.0.X.tgz
```


#### アノテーションの色付けの繁栄保存

##### change RequestManager

urlのパターンがRequestManagerだと、ファイル名しか変更できないため、拡張して各コンテンツごとにURLを解決できるようにする

##### support NodeDecorator

Potreeのデータは静的な巨大なファイルを、byteのrange指定で取得するので、アノテーションの情報は、識別キーと一緒に同一粒度(node)単位で、保存しているためその繁栄のために、NodeDecoratorを差し込めるようにする

###### rgba BufferAttribute の色をアノテーションの色で塗り替える

###### BufferAttribute追加 anno_idx アノテーションを区別する為に追加

##### add bk_rgba

色のクリア時に、戻しやすくするために bk_rgba を追加する

##### NodeLoader load に完了時のcallbackを追加

load の Promiseは、ワーカーにPOSTするまでになっているため、完了時のタイミングとれないため、追加
109 changes: 54 additions & 55 deletions example/main.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { AmbientLight, BoxGeometry, Euler, Mesh, MeshBasicMaterial, PerspectiveCamera, Raycaster, Scene, SphereGeometry, Vector2, Vector3, WebGLRenderer } from 'three';
import { AmbientLight, BoxGeometry, Euler, Mesh, MeshBasicMaterial, PerspectiveCamera, Raycaster, Scene, SphereGeometry, Vector2, Vector3, WebGLRenderer } from 'three';
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
import { PointCloudOctree, Potree } from '../source';

document.body.onload = function()
{
document.body.onload = function () {
const potree = new Potree();
let pointClouds: PointCloudOctree[] = [];

Expand Down Expand Up @@ -32,7 +31,7 @@ document.body.onload = function()
});

const geometry = new BoxGeometry(25, 1, 25);
const material = new MeshBasicMaterial({color: 0x44AA44});
const material = new MeshBasicMaterial({ color: 0x44AA44 });
const cube = new Mesh(geometry, material);
cube.position.y = -2;
scene.add(cube);
Expand All @@ -47,8 +46,7 @@ document.body.onload = function()
raycaster.params.Points.threshold = 1e-2;
const normalized = new Vector2();

canvas.onmousemove = function(event)
{
canvas.onmousemove = function (event) {
normalized.set(event.clientX / canvas.width * 2 - 1, -(event.clientY / canvas.height) * 2 + 1);
raycaster.setFromCamera(normalized, camera);

Expand All @@ -58,64 +56,67 @@ document.body.onload = function()
console.log('Potree.pick :>> ', I?.position, performance.now() - start1);

const start2 = performance.now();
const intesects = raycaster.intersectObject(scene, true);
if (intesects.length > 0) {
console.log('iraycaster.intersectObject :>> ', intesects[0].point, performance.now() - start2);
const intesects = raycaster.intersectObject(scene, true);
if (intesects.length > 0) {
console.log('iraycaster.intersectObject :>> ', intesects[0].point, performance.now() - start2);
}
};

canvas.ondblclick = function()
{
canvas.ondblclick = function () {
const intesects = raycaster.intersectObject(scene, true);


if (intesects.length > 0)
{
if (intesects.length > 0) {
const geometry = new SphereGeometry(0.2, 32, 32);
const material = new MeshBasicMaterial({color: Math.random() * 0xAA4444});
const material = new MeshBasicMaterial({ color: Math.random() * 0xAA4444 });
const sphere = new Mesh(geometry, material);
sphere.position.copy(intesects[0].point);
scene.add(sphere);
}
};

loadPointCloud('/data/lion_takanawa/', 'cloud.js', new Vector3(-4, -2, 5), new Euler(-Math.PI / 2, 0, 0));
loadPointCloud('/data/pump/', 'metadata.json', new Vector3(0, -1.5, 3), new Euler(-Math.PI / 2, 0, 0), new Vector3(2, 2, 2));

function loadPointCloud(baseUrl: string, url: string, position?: Vector3, rotation?: Euler, scale?: Vector3)
{
potree.loadPointCloud(url, baseUrl).then(function(pco: PointCloudOctree)
{
pco.material.size = 1.0;
pco.material.shape = 2;
pco.material.inputColorEncoding = 1;
pco.material.outputColorEncoding = 1;

if (position){pco.position.copy(position);}
if (rotation){pco.rotation.copy(rotation);}
if (scale){pco.scale.copy(scale);}

console.log('Pointcloud file loaded', pco);
pco.showBoundingBox = false;

const box = pco.pcoGeometry.boundingBox;
const size = box.getSize(new Vector3());

const geometry = new BoxGeometry(size.x, size.y, size.z);
const material = new MeshBasicMaterial({color:0xFF0000, wireframe: true});
const mesh = new Mesh(geometry, material);
mesh.position.copy(pco.position);
mesh.scale.copy(pco.scale);
mesh.rotation.copy(pco.rotation);
mesh.raycast = () => false;

size.multiplyScalar(0.5);
mesh.position.add(new Vector3(size.x, size.y, -size.z));

scene.add(mesh);

add(pco);
});

function loadPointCloud(baseUrl: string, url: string, position?: Vector3, rotation?: Euler, scale?: Vector3) {
potree.loadPointCloud({
fetch: (target, init) => {
return fetch(`${baseUrl}/${target}`, init);
},
getUrl: async (target) => {
return `${baseUrl}/${target}`;
}
}).then(function (pco: PointCloudOctree) {
pco.material.size = 1.0;
pco.material.shape = 2;
pco.material.inputColorEncoding = 1;
pco.material.outputColorEncoding = 1;

if (position) { pco.position.copy(position); }
if (rotation) { pco.rotation.copy(rotation); }
if (scale) { pco.scale.copy(scale); }

console.log('Pointcloud file loaded', pco);
pco.showBoundingBox = false;

const box = pco.pcoGeometry.boundingBox;
const size = box.getSize(new Vector3());

const geometry = new BoxGeometry(size.x, size.y, size.z);
const material = new MeshBasicMaterial({ color: 0xFF0000, wireframe: true });
const mesh = new Mesh(geometry, material);
mesh.position.copy(pco.position);
mesh.scale.copy(pco.scale);
mesh.rotation.copy(pco.rotation);
mesh.raycast = () => false;

size.multiplyScalar(0.5);
mesh.position.add(new Vector3(size.x, size.y, -size.z));

scene.add(mesh);

add(pco);
});
}

function add(pco: PointCloudOctree): void {
Expand All @@ -132,8 +133,7 @@ document.body.onload = function()
pointClouds = [];
}

function loop()
{
function loop() {
cube.rotation.y += 0.01;

potree.updatePointClouds(pointClouds, camera, renderer);
Expand All @@ -146,16 +146,15 @@ document.body.onload = function()

loop();

document.body.onresize = function()
{
document.body.onresize = function () {
const width = window.innerWidth;
const height = window.innerHeight;

renderer.setSize(width, height);
camera.aspect = width / height;
camera.updateProjectionMatrix();
};

// @ts-ignore
document.body.onresize();
};
Loading