Skip to content

Commit

Permalink
fix(test): PointCloud unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ftoromanoff committed Feb 10, 2025
1 parent fd0d69c commit bd215e4
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 18 deletions.
4 changes: 4 additions & 0 deletions src/Source/Potree2Source.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ class Potree2Source extends Source {
if (!source.file) {
throw new Error('New Potree2Source: file is required');
}
if (!source.crs) {
// with better data and the spec this might be removed
throw new Error('New PotreeSource: crs is required');
}

super(source);
this.file = source.file;
Expand Down
4 changes: 4 additions & 0 deletions src/Source/PotreeSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ class PotreeSource extends Source {
if (!source.file) {
throw new Error('New PotreeSource: file is required');
}
if (!source.crs) {
// with better data and the spec this might be removed
throw new Error('New PotreeSource: crs is required');
}

super(source);
this.file = source.file;
Expand Down
17 changes: 9 additions & 8 deletions test/unit/entwine.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import assert from 'assert';
import { Vector3 } from 'three';
import View from 'Core/View';
import GlobeView from 'Core/Prefab/GlobeView';
import Coordinates from 'Core/Geographic/Coordinates';
import EntwinePointTileSource from 'Source/EntwinePointTileSource';
import EntwinePointTileLayer from 'Layer/EntwinePointTileLayer';
import EntwinePointTileNode from 'Core/EntwinePointTileNode';
import LASParser from 'Parser/LASParser';
import sinon from 'sinon';
import Fetcher from 'Provider/Fetcher';
import LASParser from 'Parser/LASParser';
import Renderer from './bootstrap';

import eptFile from '../data/entwine/ept.json';
Expand Down Expand Up @@ -78,18 +79,16 @@ describe('Entwine Point Tile', function () {
});
});

describe('Layer', function () {
describe('Entwine Point Tile Layer', function () {
let renderer;
let placement;
let view;
let layer;
let context;

before(function (done) {
renderer = new Renderer();
placement = { coord: new Coordinates('EPSG:4326', 0, 0), range: 250 };
view = new GlobeView(renderer.domElement, placement, { renderer });
layer = new EntwinePointTileLayer('test', { source }, view);
view = new GlobeView(renderer.domElement, {}, { renderer });
layer = new EntwinePointTileLayer('test', { source });

context = {
camera: view.camera,
Expand Down Expand Up @@ -117,8 +116,10 @@ describe('Entwine Point Tile', function () {
});

it('tries to update on the root and succeeds', function (done) {
const lookAt = new Vector3();
const coord = new Coordinates(view.referenceCrs).setFromVector3(layer.root.bbox.getCenter(lookAt));
view.controls.lookAtCoordinate({
coord: source.center,
coord,
range: 250,
}, false)
.then(() => {
Expand All @@ -135,7 +136,7 @@ describe('Entwine Point Tile', function () {
});
});

describe('Node', function () {
describe('Entwine Point Tile Node', function () {
let root;
before(function () {
const layer = { source: { url: 'http://server.geo', extension: 'laz' } };
Expand Down
1 change: 1 addition & 0 deletions test/unit/potree.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ describe('Potree', function () {
const source = new PotreeSource({
file: fileName,
url: baseurl,
crs: 'EPSG:4978',
});

// Configure Point Cloud layer
Expand Down
14 changes: 8 additions & 6 deletions test/unit/potree2.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@ describe('Potree2', function () {

before(function () {
renderer = new Renderer();
viewer = new View('EPSG:3946', renderer.domElement, { renderer });
viewer = new View('EPSG:4978', renderer.domElement, { renderer });
viewer.camera.camera3D.position.copy(new Vector3(0, 0, 10));

// Configure Point Cloud layer
const source = new Potree2Source({
file: 'metadata.json',
url: 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/pointclouds/potree2.0/lion',
networkOptions: process.env.HTTPS_PROXY ? { agent: new HttpsProxyAgent(process.env.HTTPS_PROXY) } : {},
crs: 'EPSG:4978',
});
potreeLayer = new Potree2Layer('lion', {
source: new Potree2Source({
file: 'metadata.json',
url: 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/pointclouds/potree2.0/lion',
networkOptions: process.env.HTTPS_PROXY ? { agent: new HttpsProxyAgent(process.env.HTTPS_PROXY) } : {},
}),
source,
crs: viewer.referenceCrs,
});

Expand Down
4 changes: 4 additions & 0 deletions test/unit/potree2layerparsing.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ describe('Potree2 Provider', function () {
file: 'metadata.json',
url: 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/pointclouds/potree2.0/lion',
networkOptions: process.env.HTTPS_PROXY ? { agent: new HttpsProxyAgent(process.env.HTTPS_PROXY) } : {},
crs: 'EPSG:4978',
metadata,
});

Expand All @@ -65,6 +66,7 @@ describe('Potree2 Provider', function () {
file: 'metadata.json',
url: 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/pointclouds/potree2.0/lion',
networkOptions: process.env.HTTPS_PROXY ? { agent: new HttpsProxyAgent(process.env.HTTPS_PROXY) } : {},
crs: 'EPSG:4978',
metadata: {
version: '2.0',
name: 'lion',
Expand Down Expand Up @@ -132,6 +134,7 @@ describe('Potree2 Provider', function () {
file: 'metadata.json',
url: 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/pointclouds/potree2.0/lion',
networkOptions: process.env.HTTPS_PROXY ? { agent: new HttpsProxyAgent(process.env.HTTPS_PROXY) } : {},
crs: 'EPSG:4978',
metadata: {
version: '2.0',
name: 'lion',
Expand Down Expand Up @@ -199,6 +202,7 @@ describe('Potree2 Provider', function () {
file: 'metadata.json',
url: 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/pointclouds/potree2.0/lion',
networkOptions: process.env.HTTPS_PROXY ? { agent: new HttpsProxyAgent(process.env.HTTPS_PROXY) } : {},
crs: 'EPSG:4978',
metadata: {
version: '2.0',
name: 'lion',
Expand Down
16 changes: 12 additions & 4 deletions test/unit/potreelayerparsing.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ describe('Potree Provider', function () {
it('cloud with no normal information', function _it(done) {
// No normals
const cloud = {
boundingBox: { lx: 0, ly: 1, ux: 2, uy: 3 },
boundingBox: { lx: 10, ly: 20, ux: 30, uy: 40 },
tightBoundingBox: { lx: 1, ly: 2, ux: 3, uy: 4 },
scale: 1.0,
pointAttributes: ['POSITION', 'RGB'],
octreeDir: 'data',
Expand All @@ -51,6 +52,7 @@ describe('Potree Provider', function () {
const source = new PotreeSource({
file: fileName,
url: baseurl,
crs: 'EPSG:4978',
cloud,
});

Expand All @@ -66,7 +68,8 @@ describe('Potree Provider', function () {
it('cloud with normals as vector', function _it(done) {
// // // // normals as vector
const cloud = {
boundingBox: { lx: 0, ly: 1, ux: 2, uy: 3 },
boundingBox: { lx: 10, ly: 20, ux: 30, uy: 40 },
tightBoundingBox: { lx: 1, ly: 2, ux: 3, uy: 4 },
scale: 1.0,
pointAttributes: ['POSITION', 'NORMAL', 'CLASSIFICATION'],
octreeDir: 'data',
Expand All @@ -75,6 +78,7 @@ describe('Potree Provider', function () {
const source = new PotreeSource({
file: fileName,
url: baseurl,
crs: 'EPSG:4978',
cloud,
});

Expand All @@ -91,14 +95,16 @@ describe('Potree Provider', function () {
it('cloud with spheremapped normals', function _it(done) {
// // spheremapped normals
const cloud = {
boundingBox: { lx: 0, ly: 1, ux: 2, uy: 3 },
boundingBox: { lx: 10, ly: 20, ux: 30, uy: 40 },
tightBoundingBox: { lx: 1, ly: 2, ux: 3, uy: 4 },
scale: 1.0,
pointAttributes: ['POSITION', 'COLOR_PACKED', 'NORMAL_SPHEREMAPPED'],
octreeDir: 'data',
};
const source = new PotreeSource({
file: fileName,
url: baseurl,
crs: 'EPSG:4978',
cloud,
});
const layer = new PotreeLayer('pointsCloud3', { source, crs: view.referenceCrs });
Expand All @@ -115,7 +121,8 @@ describe('Potree Provider', function () {
it('cloud with oct16 normals', function _it(done) {
// // // oct16 normals
const cloud = {
boundingBox: { lx: 0, ly: 1, ux: 2, uy: 3 },
boundingBox: { lx: 10, ly: 20, ux: 30, uy: 40 },
tightBoundingBox: { lx: 1, ly: 2, ux: 3, uy: 4 },
scale: 1.0,
pointAttributes: ['POSITION', 'COLOR_PACKED', 'CLASSIFICATION', 'NORMAL_OCT16'],
octreeDir: 'data',
Expand All @@ -124,6 +131,7 @@ describe('Potree Provider', function () {
file: fileName,
url: baseurl,
cloud,
crs: 'EPSG:4978',
});
const layer = new PotreeLayer('pointsCloud4', { source, crs: view.referenceCrs });
View.prototype.addLayer.call(view, layer);
Expand Down

0 comments on commit bd215e4

Please sign in to comment.