Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PoincLoudLayer and Multisource #2392

Draft
wants to merge 22 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
f6f172e
fix(geometryLayer): fix opacity magic number
ftoromanoff Jul 18, 2024
49f0069
fix(crs): add support for non EPSG projection and fix proj4 unit 'met…
ftoromanoff Apr 30, 2024
00f7cb9
refactor(EntwinePointTile): move this.spacing from EntwinePointItleSo…
ftoromanoff Apr 30, 2024
69302ab
refactor(EntwinePointTileLayer): proj boundsConforming in view crs
ftoromanoff Apr 30, 2024
7e5e6fb
refactor(LASLoader): reproj data during parsing and add elevation att…
ftoromanoff Jul 12, 2024
43363f1
refactor(test): entwine.js
ftoromanoff Apr 30, 2024
4a256b1
refactor(examples): entwine examples -> change linked to reproj
ftoromanoff Apr 30, 2024
37351e1
refactor(exemple): add GrandLyon on entwine_3d_loader
ftoromanoff Jul 15, 2024
b296635
feat(EntwineData): add obb for reprojection in View crs
ftoromanoff Jul 17, 2024
8a4a33e
refactor: potree1&2Node, copcNode -> add node.createChildOBB()
ftoromanoff Apr 30, 2024
2fd2703
refactor(CopcData): add obb
ftoromanoff Jul 17, 2024
44ec007
refactor(test): obb
ftoromanoff May 3, 2024
9694295
refactor(PointCloud): supp instanciation of bboxMesh that is not used
ftoromanoff May 3, 2024
2a59134
refactor(AllPointCloudLayer): supp this.extent
ftoromanoff Jul 17, 2024
8649479
refactor(CopcSource): use wkt to get source.crs
ftoromanoff Jul 18, 2024
81a1fb5
refactor(example): add copc 3d loader
ftoromanoff Jul 18, 2024
10a61e4
example(copc_simpls_loader): change to addapt view crs from layer crs
ftoromanoff Jul 19, 2024
4e0ea06
refactor(COPCexample): change title
ftoromanoff Sep 2, 2024
09c87b0
refactor(multiSource): 1st try -> add Source/Multisource.js
ftoromanoff Sep 5, 2024
e4d7ca1
refactor(Copc): Multisource -> add isMultiple in Source
ftoromanoff Sep 5, 2024
4aa157e
refactor(EntwinePointCloud): Multisource
ftoromanoff Sep 6, 2024
07a6df8
refactor(potree1and2): change linked with multisource
ftoromanoff Sep 6, 2024
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
3 changes: 2 additions & 1 deletion config/threeExamples.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default {
'./utils/WorkerPool.js',
'./capabilities/WebGL.js',
'./libs/ktx-parse.module.js',
'./libs/zstddec.module.js'
'./libs/zstddec.module.js',
'./math/OBB.js',
],
};
152 changes: 152 additions & 0 deletions examples/copc_3d_loader.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
<html>
<head>
<title>Itowns - COPC 3D loader</title>

<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="css/example.css">
<link rel="stylesheet" type="text/css" href="css/LoadingScreen.css">

<style type="text/css">
#description {
z-index: 2;
left: 10px;
}
</style>

<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.6/dat.gui.min.js"></script>
</head>
<body>
<div id="description">Specify the URL of a COPC file to load:
<input type="text" id="copc_url" />
<button onclick="readCopcURL()">Load</button>
<button onclick="loadLidarHD()">Load LiDAR HD dataset</button>
<div id="share"></div>
</div>
<div id="viewerDiv">
</div>

<script src="../dist/itowns.js"></script>
<script src="js/GUI/LoadingScreen.js"></script>
<script src="../dist/debug.js"></script>
<script type="text/javascript">
var debugGui = new dat.GUI();
var viewerDiv = document.getElementById('viewerDiv');

var view = new itowns.GlobeView(viewerDiv);

// Add one imagery layer to the scene and the miniView
// This layer is defined in a json file but it could be defined as a plain js
// object. See Layer* for more info.
itowns.Fetcher.json('./layers/JSONLayers/Ortho.json').then(function _(config) {
config.source = new itowns.WMTSSource(config.source);
var layer = new itowns.ColorLayer('Ortho', config);
view.addLayer(layer);
});
// Add two elevation layers.
// These will deform iTowns globe geometry to represent terrain elevation.
function addElevationLayerFromConfig(config) {
config.source = new itowns.WMTSSource(config.source);
var layer = new itowns.ElevationLayer(config.id, config);
view.addLayer(layer);
}
itowns.Fetcher.json('./layers/JSONLayers/IGN_MNT_HIGHRES.json').then(addElevationLayerFromConfig);
itowns.Fetcher.json('./layers/JSONLayers/WORLD_DTM.json').then(addElevationLayerFromConfig);

var layer;

function onLayerReady() {
var lookAt = new itowns.THREE.Vector3();

const bboxes = layer.root.map(root => root.bbox);

let bbox = bboxes[0];
for (let i = 1; i < bboxes.length; i++) {
bbox = bbox.union(bboxes[i]);
}

bbox.getCenter(lookAt);
var coordLookAt = new itowns.Coordinates(view.referenceCrs, lookAt);

var size = new itowns.THREE.Vector3();
bbox.getSize(size);

view.controls.lookAtCoordinate({
coord: coordLookAt,
range: 2 * size.length(),
}, false);
}

function readCopcURL() {
const urlParams = new URL(location.href).searchParams
var url = document.getElementById('copc_url').value || urlParams.get('copc');

if (url) {
const options = {};
urlParams.keys().forEach(key => {
if (key !== 'copc') {
if (key.includes('.')) {
params = key.split('.');
let object = options;
params.forEach((subKey, index) => {
if (!object[subKey]) { object[subKey] = {}; }
if (index === params.length - 1) {
object[subKey] = parseFloat(urlParams.get(key));
}
object = object[subKey];
})
} else {
options[key] = parseFloat(urlParams.get(key));
}

}
});
loadCopc(url, options);

document.getElementById('share').innerHTML = '<a href="' +
location.href.replace(location.search, '?copc=' + url) +
'" target="_blank">Link to share this view</a>';
document.getElementById('copc_url').value = url;
}
}

function loadCopc(url, options) {
const source = new itowns.CopcSource({ url });

if (layer) {
debugGui.removeFolder(layer.debugUI);
view.removeLayer('COPC');
view.notifyChange();
layer.delete();
}

const config = {
source,
crs: view.referenceCrs,
sseThreshold: 2,
pointBudget: 3000000,
...options,
}

layer = new itowns.CopcLayer('COPC', config);

itowns.View.prototype.addLayer.call(view, layer).then(onLayerReady);

layer.whenReady
.then(() => debug.PointCloudDebug.initTools(view, layer, debugGui));
}

function loadLidarHD() {
// const url ="https://storage.sbg.cloud.ovh.net/v1/AUTH_63234f509d6048bca3c9fd7928720ca1/ppk-lidar/ML/LHD_FXX_0746_6509_PTS_C_LAMB93_IGN69.copc.laz"
const url ="https://dl-lidar.ign.fr/ppk-lidar/ML/LHD_FXX_0746_6509_PTS_C_LAMB93_IGN69.copc.laz" //fixed with proxy
const options = {
material: {mode: 2},
opacity: 0.5,
}
loadCopc(url, options);
}

readCopcURL();
</script>
</body>
</html>
51 changes: 30 additions & 21 deletions examples/copc_simple_loader.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<head>
<meta charset="UTF-8">

<title>Itowns - COPC loader</title>
<title>Itowns - COPC simple loader</title>

<link rel="stylesheet" type="text/css" href="css/example.css">
<link rel="stylesheet" type="text/css" href="css/LoadingScreen.css">
Expand Down Expand Up @@ -35,30 +35,39 @@
<script src="../dist/debug.js"></script>
<script type="text/javascript">
let layer; // COPCLayer
let view;
let control;

const uri = new URL(location);

const gui = new dat.GUI();
const crs = {
'autzen-classified': 'EPSG:2992',
sofi: 'EPSG:32611',
millsite: 'EPSG:6341',
}

const viewerDiv = document.getElementById('viewerDiv');
const view = new itowns.View('EPSG:4326', viewerDiv);
const controls = new itowns.PlanarControls(view);
view.mainLoop.gfxEngine.renderer.setClearColor(0xdddddd);
gui = new dat.GUI();

setUrl(uri.searchParams.get('copc'));
const uri = new URL(location);
setView(uri.searchParams.get('copc'));

function onLayerReady(layer) {
const camera = view.camera.camera3D;

const lookAt = new itowns.THREE.Vector3();
const size = new itowns.THREE.Vector3();
layer.root.bbox.getSize(size);
layer.root.bbox.getCenter(lookAt);

const bboxes = layer.root.map(root => root.bbox);
let bbox = bboxes[0];
for (let i = 1; i < bboxes.length; i++) {
bbox = bbox.union(bboxes[i]);
}
bbox.getSize(size);
bbox.getCenter(lookAt);

camera.far = 2.0 * size.length();

controls.groundLevel = layer.root.bbox.min.z;
const position = layer.root.bbox.min.clone().add(
controls.groundLevel = bbox.min.z;
const position = bbox.min.clone().add(
size.multiply({ x: 1, y: 1, z: size.x / size.z }),
);

Expand All @@ -69,7 +78,6 @@
view.notifyChange(camera);
}


function readURL() {
const url = document.getElementById('url').value;

Expand All @@ -88,20 +96,21 @@
history.replaceState(null, null, `?${uri.searchParams.toString()}`);

input_url.value = url;
load(url);
location.reload()
}

function setView(url) {
const copcId = url.split('/').pop().split('.').shift();

view = new itowns.View(crs[copcId], viewerDiv);
controls = new itowns.PlanarControls(view);
view.mainLoop.gfxEngine.renderer.setClearColor(0xdddddd);
load(url);
}

function load(url) {
const source = new itowns.CopcSource({ url });

if (layer) {
gui.removeFolder(layer.debugUI);
view.removeLayer('COPC');
view.notifyChange();
layer.delete();
}

layer = new itowns.CopcLayer('COPC', {
source,
crs: view.referenceCrs,
Expand Down
29 changes: 22 additions & 7 deletions examples/entwine_3d_loader.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
<div id="description">Specify the URL of a Entwine Point Tree to load:
<input type="text" id="ept_url" />
<button onclick="readEPTURL()">Load</button>
<p>If your dataset is not displaying at the right location,
check that it has been converted in <code>EPSG:4978</code>.</p>
<button onclick="loadGrandLyon()">Load the Grand Lyon
dataset</button>
<div id="share"></div>
</div>
<div id="viewerDiv">
Expand Down Expand Up @@ -58,11 +58,17 @@

function onLayerReady() {
var lookAt = new itowns.THREE.Vector3();
eptLayer.root.bbox.getCenter(lookAt);

const bboxes = eptLayer.root.map(root => root.bbox);
let bbox = bboxes[0];
for (let i = 1; i < bboxes.length; i++) {
bbox = bbox.union(bboxes[i]);
}
bbox.getCenter(lookAt);
var coordLookAt = new itowns.Coordinates(view.referenceCrs, lookAt);

var size = new itowns.THREE.Vector3();
eptLayer.root.bbox.getSize(size);
bbox.getSize(size);

view.controls.lookAtCoordinate({
coord: coordLookAt,
Expand All @@ -71,7 +77,8 @@
}

function readEPTURL() {
var url = document.getElementById('ept_url').value || new URL(location.href).searchParams.get('ept');
const urlParams = new URL(location.href).searchParams
var url = document.getElementById('ept_url').value || urlParams.get('ept');

if (url) {
loadEPT(url);
Expand All @@ -87,8 +94,10 @@
eptSource = new itowns.EntwinePointTileSource({ url });

if (eptLayer) {
view.removeLayer('ept');
debugGui.removeFolder(eptLayer.debugUI);
view.removeLayer('Entwine Point Tile');
view.notifyChange();
eptLayer.delete();
}

eptLayer = new itowns.EntwinePointTileLayer('Entwine Point Tile', {
Expand All @@ -98,7 +107,13 @@

itowns.View.prototype.addLayer.call(view, eptLayer).then(onLayerReady);

debug.PointCloudDebug.initTools(view, eptLayer, debugGui);
eptLayer.whenReady
.then(() => debug.PointCloudDebug.initTools(view, eptLayer, debugGui));
}

function loadGrandLyon() {
document.getElementById('ept_url').value = 'https://download.data.grandlyon.com/files/grandlyon/imagerie/mnt2018/lidar/ept/';
readEPTURL();
}

readEPTURL();
Expand Down
21 changes: 13 additions & 8 deletions examples/entwine_simple_loader.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@
<script src="js/GUI/LoadingScreen.js"></script>
<script src="../dist/debug.js"></script>
<script type="text/javascript">
itowns.proj4.defs('EPSG:3946', '+proj=lcc +lat_0=46 +lon_0=3 +lat_1=45.25 +lat_2=46.75 +x_0=1700000 +y_0=5200000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs');

var debugGui = new dat.GUI();
var viewerDiv = document.getElementById('viewerDiv');
viewerDiv.style.display = 'block';
var view = new itowns.View('EPSG:3946', viewerDiv);

var view = new itowns.View('EPSG:3857', viewerDiv);
view.mainLoop.gfxEngine.renderer.setClearColor(0xcccccc);

const controls = new itowns.PlanarControls(view);
Expand All @@ -46,13 +45,19 @@
function onLayerReady() {
var lookAt = new itowns.THREE.Vector3();
var size = new itowns.THREE.Vector3();
eptLayer.root.bbox.getSize(size);
eptLayer.root.bbox.getCenter(lookAt);

const bboxes = eptLayer.root.map(root => root.bbox);
let bbox = bboxes[0];
for (let i = 1; i < bboxes.length; i++) {
bbox = bbox.union(bboxes[i]);
}
bbox.getSize(size);
bbox.getCenter(lookAt);

view.camera3D.far = 2.0 * size.length();

controls.groundLevel = eptLayer.root.bbox.min.z;
var position = eptLayer.root.bbox.min.clone().add(
controls.groundLevel = bbox.min.z;
var position = bbox.max.clone().add(
size.multiply({ x: 0, y: 0, z: size.x / size.z })
);

Expand Down Expand Up @@ -88,7 +93,7 @@
eptSource = new itowns.EntwinePointTileSource({ url });

if (eptLayer) {
debugGUI.removeFolder(eptLayer.debugUI);
debugGui.removeFolder(eptLayer.debugUI);
view.removeLayer('Entwine Point Tile');
view.notifyChange();
eptLayer.delete();
Expand Down
Loading
Loading