Skip to content

Commit

Permalink
Add potree 2.0 loader
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin ETOURNEAU committed Jul 11, 2023
1 parent 08dbd3d commit cece657
Show file tree
Hide file tree
Showing 23 changed files with 3,791 additions and 4 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = {
},
},
env: {
es2020: true,
browser: true,
es6: true,
amd: true,
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ potree
coverage
.nyc_output/
/src/ThreeExtended/
.DS_Store
.idea
1 change: 1 addition & 0 deletions docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"FileSource",
"OrientedImageSource",
"PotreeSource",
"Potree2Source",
"VectorTilesSource",
"EntwinePointTileSource"
],
Expand Down
1 change: 1 addition & 0 deletions examples/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

"Pointcloud": {
"potree_25d_map": "Potree 2.5D map",
"potree2_25d_map": "Potree 2.5D map 2.0 format",
"potree_3d_map": "Potree 3D map",
"laz_dragndrop": "LAS/LAZ viewer",
"entwine_simple_loader": "Entwine loader",
Expand Down
129 changes: 129 additions & 0 deletions examples/potree2_25d_map.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<!DOCTYPE html>
<html>
<head>
<title>Point Cloud Viewer</title>

<style type="text/css">
#info {
color: #7ad7ff;
font-family: 'Open Sans', sans-serif;
position: absolute;
top: 0;
left: 0;
padding: 0.3rem;
background-color: #404040;
z-index: 1;
}
@media (max-width: 600px) {
#info,
.dg {
display: none;
}
}
</style>

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

<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div id="viewerDiv">
<div id="info"></div>
</div>

<div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.6/dat.gui.min.js"></script>
<script src="../dist/itowns.js"></script>
<script src="js/GUI/LoadingScreen.js"></script>
<script src="../dist/debug.js"></script>
<script type="text/javascript">
var potreeLayer;
var oldPostUpdate;
var viewerDiv;
var debugGui;
var view;
var controls;

// Define crs projection that we will use (taken from https://epsg.io/3946, Proj4js section)
itowns.proj4.defs('EPSG:3946', '+proj=lcc +lat_1=45.25 +lat_2=46.75 +lat_0=46 +lon_0=3 +x_0=1700000 +y_0=5200000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs');

viewerDiv = document.getElementById('viewerDiv');
viewerDiv.style.display = 'block';

debugGui = new dat.GUI();

// TODO: do we really need to disable logarithmicDepthBuffer ?
view = new itowns.View('EPSG:3946', viewerDiv);
setupLoadingScreen(viewerDiv, view);
view.mainLoop.gfxEngine.renderer.setClearColor(0xcccccc);

// Configure Point Cloud layer
potreeLayer = new itowns.Potree2Layer('Lion', {
source: new itowns.Potree2Source({
file: 'metadata.json',
url: 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/pointclouds/potree2.0/lion',
crs: view.referenceCrs,
}),
});

// point selection on double-click
function dblClickHandler(event) {
var pick = view.pickObjectsAt(event, 5, potreeLayer);

for (const p of pick) {
console.info('Selected point #' + p.index + ' in position (' +
p.object.position.x + ', ' +
p.object.position.y + ', ' +
p.object.position.z +
') in Points ' + p.object.layer.id);
}
}
view.domElement.addEventListener('dblclick', dblClickHandler);

function placeCamera(position, lookAt) {
view.camera.camera3D.position.copy(position);
view.camera.camera3D.lookAt(lookAt);
// create controls
controls = new itowns.FirstPersonControls(view, { focusOnClick: true });
debugGui.add(controls.options, 'moveSpeed', 1, 100).name('Movement speed');

view.notifyChange(view.camera.camera3D);
}

// add potreeLayer to scene
function onLayerReady() {
var ratio;
var position;
var lookAt = new itowns.THREE.Vector3();
var size = new itowns.THREE.Vector3();

potreeLayer.root.bbox.getSize(size);
potreeLayer.root.bbox.getCenter(lookAt);

debug.PotreeDebug.initTools(view, potreeLayer, debugGui);

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

ratio = size.x / size.z;
position = potreeLayer.root.bbox.min.clone().add(
size.multiply({ x: 0, y: 0, z: ratio * 0.5 }));
lookAt.z = potreeLayer.root.bbox.min.z;
placeCamera(position, lookAt);
controls.moveSpeed = size.length() / 3;

// update stats window
var info = document.getElementById('info');
view.addFrameRequester(itowns.MAIN_LOOP_EVENTS.AFTER_RENDER, () => {
info.textContent = potreeLayer.displayedCount.toLocaleString() + ' points';
});

// console.log(view.scene);
}
window.view = view;
view.addLayer(potreeLayer).then(onLayerReady);
</script>
</body>
</html>

43 changes: 43 additions & 0 deletions libs/brotli/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package(
default_visibility = ["//visibility:public"],
)

licenses(["notice"]) # MIT

load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library")

# Not a real polyfill. Do NOT use for anything, but tests.
closure_js_library(
name = "polyfill",
srcs = ["polyfill.js"],
suppress = [
"JSC_INVALID_OPERAND_TYPE",
"JSC_MISSING_JSDOC",
"JSC_STRICT_INEXISTENT_PROPERTY",
"JSC_TYPE_MISMATCH",
"JSC_UNKNOWN_EXPR_TYPE",
],
)

# Do NOT use this artifact; it is for test purposes only.
closure_js_library(
name = "decode",
srcs = ["decode.js"],
suppress = [
"JSC_DUP_VAR_DECLARATION",
"JSC_USELESS_BLOCK",
],
deps = [":polyfill"],
)

load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_test")

closure_js_test(
name = "all_tests",
srcs = ["decode_test.js"],
deps = [
":decode",
":polyfill",
"@io_bazel_rules_closure//closure/library:testing",
],
)
19 changes: 19 additions & 0 deletions libs/brotli/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2009, 2010, 2013-2016 by the Brotli Authors.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
12 changes: 12 additions & 0 deletions libs/brotli/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
workspace(name = "org_brotli_js")

load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

git_repository(
name = "io_bazel_rules_closure",
commit = "29ec97e7c85d607ba9e41cab3993fbb13f812c4b",
remote = "https://github.com/bazelbuild/rules_closure.git",
)

load("@io_bazel_rules_closure//closure:defs.bzl", "closure_repositories")
closure_repositories()
Loading

0 comments on commit cece657

Please sign in to comment.