-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClassificationErftShowcase.html
304 lines (238 loc) · 12.3 KB
/
ClassificationErftShowcase.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="author" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<!-- The "viewport" meta tag specifies the initial
scale and dimensions of the webpage's viewport. This is important for optimizing
the page's display on different devices, such as desktops and mobile devices. -->
<title>Potree Viewer</title>
<!--The following five lines define links to various stylesheets used by the webpage.
Each <link> element specifies the type of resource (stylesheet in this case), the path to the resource,
and the stylesheet's type. The stylesheet paths are relative to the location of the current webpage.
(./ = look in the current folder ./ = look in the folder before)
These stylesheets are used to define the appearance and behavior of various UI components used by the webpage.-->
<link rel="stylesheet" type="text/css" href="../libs/potree/potree.css">
<link rel="stylesheet" type="text/css" href="../libs/jquery-ui/jquery-ui.min.css">
<link rel="stylesheet" type="text/css" href="../libs/openlayers3/ol.css">
<link rel="stylesheet" type="text/css" href="../libs/spectrum/spectrum.css">
<link rel="stylesheet" type="text/css" href="../libs/jstree/themes/mixed/style.css">
<link rel="stylesheet" type="text/css" href="../libs/Cesium/Widgets/CesiumWidget/CesiumWidget.css">
</head>
<body>
<!-- This code in the body of an HTML document contains several <script> tags that reference external
JavaScript files. The src attribute of each <script> tag specifies the path to the JavaScript
file that should be loaded and executed in the browser. -->
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
<script src="../libs/spectrum/spectrum.js"></script>
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
<script src="../libs/other/BinaryHeap.js"></script>
<script src="../libs/tween/tween.min.js"></script>
<script src="../libs/d3/d3.js"></script>
<script src="../libs/proj4/proj4.js"></script>
<script src="../libs/openlayers3/ol.js"></script>
<script src="../libs/i18next/i18next.js"></script>
<script src="../libs/jstree/jstree.js"></script>
<script src="../libs/potree/potree.js"></script>
<script src="../libs/plasio/js/laslaz.js"></script>
<script src="../libs/shapefile/shapefile.js"></script>
<script src="../libs/Cesium/Cesium.js"></script>
<!-- Cesium is a JavaScript library for creating 3D globes and maps in the browser, and it provides
a range of features for visualizing and interacting with geospatial data. By importing the library using this script tag,
the Cesium library becomes available for use in the rest of the HTML document, and the functions and classes provided by the
library can be called and used in the JavaScript code. -->
<!-- INCLUDE ADDITIONAL DEPENDENCIES HERE -->
<!-- INCLUDE SETTINGS HERE -->
<!-- This code creates an HTML container element with three child elements that are used to display and control a Potree viewer. -->
<div class="potree_container" style="position: absolute; width: 100%; height: 100%; left: 0px; top: 0px; ">
<!-- This line creates a new div element with the class attribute set to potree_container. The style attribute
sets the position, width, height, left and top CSS properties to position this element as a full-screen container. -->
<div id="potree_render_area" style="background-image: url('../build/potree/resources/images/background.jpg');">
<div id="cesiumContainer" style="position: absolute; width: 100%; height: 100%; background-color:green"></div>
<!-- Another div with an id "cesiumContainer" is also included inside the "potree_render_area" div. This div is
used to hold the CesiumJS 3D globe. It is positioned absolutely with a width and height of 100% and has a
green background color. -->
<span style="position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); z-index: 10000">
<!-- <input type="button" value="Default Scheme" onclick="setDefaultScheme()"/> -->
<input type="button" value="Custom Scheme" onclick="setCustomScheme()"/>
<input type="button" value="Random Scheme" onclick="setRandomScheme()"/>
</span>
</div>
<!-- This line creates a child div element with the id attribute set to potree_render_area. This is the main rendering
area where the point cloud data is displayed. The style attribute sets the background image of the div element to a
background.jpg -->
<div id="potree_sidebar_container"> </div>
<!-- This line creates a child div element with the id attribute set to potree_sidebar_container. This is the sidebar container
where the user interface controls are displayed, including the various menus and options of the Potree viewer. -->
</div>
<!--The <script> tag in HTML is used to define a section of JavaScript code that can be executed by the browser.
It is an element that allows developers to embed scripts in HTML pages, and is typically placed in the <head> or
<body> section of an HTML document.-->
<script type="module">
// This is a JavaScript code block with the type="module" attribute, indicating that it contains ECMAScript modules.
import * as THREE from "../libs/three.js/build/three.module.js";
window.cesiumViewer = new Cesium.Viewer('cesiumContainer', {
useDefaultRenderLoop: false,
animation: false,
baseLayerPicker : false,
fullscreenButton: false,
geocoder: false,
homeButton: false,
infoBox: false,
sceneModePicker: false,
selectionIndicator: false,
timeline: false,
navigationHelpButton: false,
imageryProvider : Cesium.createOpenStreetMapImageryProvider({url : 'https://a.tile.openstreetmap.org/'}),
terrainShadows: Cesium.ShadowMode.DISABLED,
});
let cp = new Cesium.Cartesian3(4303414.154026048, 552161.235598733, 4660771.704035539);
cesiumViewer.camera.setView({
destination : cp,
orientation: {
heading : 10,
pitch : -Cesium.Math.PI_OVER_TWO * 0.5,
roll : 0.0
}
});
window.potreeViewer = new Potree.Viewer(document.getElementById("potree_render_area"), {
useDefaultRenderLoop: false
});
potreeViewer.setEDLEnabled(true);
potreeViewer.setFOV(60);
potreeViewer.setPointBudget(3_000_000);
potreeViewer.loadSettingsFromURL();
potreeViewer.setMinNodeSize(50);
potreeViewer.loadSettingsFromURL();
potreeViewer.setBackground(null);
potreeViewer.useHQ = true;
potreeViewer.setDescription(`Erft Neuss-Gnadental, Point cloud courtesy of <a href="https://www.zumbroich.com/de/home">Planungsbüro Zumbroich</a> and Dr. Georg Lamberty.`);
potreeViewer.loadGUI(() => {
potreeViewer.setLanguage('en');
$("#menu_appearance").next().show();
$("#menu_tools").next().show();
$("#menu_scene").next().show();
potreeViewer.toggleSidebar();
//I got this navigation aid section from the (https://sitn.ne.ch/lidar/) (Third Party Showcases)
let section = $(`
<h3 id="menu_meta" class="accordion-header ui-widget"><span>Navigation aid</span></h3>
<div class="accordion-content ui-widget"></div>
`);
let content = section.last();
content.html(`
<img src="../resources/images/mouse.png" alt="mouse" width="100%">
`);
section.first().click(() => content.slideToggle());
section.insertBefore($('#menu_about'));
});
Potree.loadPointCloud("../pointclouds/SommerFlightClassified/metadata.json", "SommerFlight", async e => {
// Potree.loadPointCloud("../pointclouds/SommerFlight_Potree/metadata.json", "SommerFlight", async e => {
let pointcloud = e.pointcloud;
let scene = potreeViewer.scene;
let material = pointcloud.material;
// scene configuration
scene.addPointCloud(pointcloud);
// // pointcloud configuration
pointcloud.position.setZ(0);
// pointcloud.rotation.set(0, 0, -0.035);
// material configuration
material.pointSizeType = Potree.PointSizeType.ADAPTIVE;
material.size = 0.8;
material.elevationRange = [0, 70];
material.weightRGB = 1.0;
material.weightElevation = 1.0;
material.activeAttributeName = "classification";
// // scene configuration again (Lets see if I can put it back up)
// scene.view.position.set(570975.577, 5398630.521, 1659.311);
// scene.view.lookAt(570115.285, 5400866.092, 30.009);
// I took this coordenates from the viewer
potreeViewer.scene.view.setView(
[341187.858, 5671969.144, 994.758],
[341187.858, 5671969.144, -61.967],
);
// for the hierarchy example the projection is obtained from here
let pointcloudProjection = "+proj=utm +zone=32N +ellps=WGS84 +datum=WGS84 +units=m +no_defs";
// In the Retz example the projection is directly assigned, how do I find out my projection?
let mapProjection = proj4.defs("WGS84");
window.toMap = proj4(pointcloudProjection, mapProjection);
window.toScene = proj4(mapProjection, pointcloudProjection);
{
let bb = potreeViewer.getBoundingBox();
let minWGS84 = proj4(pointcloudProjection, mapProjection, bb.min.toArray());
let maxWGS84 = proj4(pointcloudProjection, mapProjection, bb.max.toArray());
}
});
function loop(timestamp){
requestAnimationFrame(loop);
potreeViewer.update(potreeViewer.clock.getDelta(), timestamp);
potreeViewer.render();
if(window.toMap !== undefined){
{
let camera = potreeViewer.scene.getActiveCamera();
let pPos = new THREE.Vector3(0, 0, 0).applyMatrix4(camera.matrixWorld);
let pRight = new THREE.Vector3(600, 0, 0).applyMatrix4(camera.matrixWorld);
let pUp = new THREE.Vector3(0, 600, 0).applyMatrix4(camera.matrixWorld);
let pTarget = potreeViewer.scene.view.getPivot();
let toCes = (pos) => {
let xy = [pos.x, pos.y];
let height = pos.z;
let deg = toMap.forward(xy);
let cPos = Cesium.Cartesian3.fromDegrees(...deg, height);
return cPos;
};
let cPos = toCes(pPos);
let cUpTarget = toCes(pUp);
let cTarget = toCes(pTarget);
let cDir = Cesium.Cartesian3.subtract(cTarget, cPos, new Cesium.Cartesian3());
let cUp = Cesium.Cartesian3.subtract(cUpTarget, cPos, new Cesium.Cartesian3());
cDir = Cesium.Cartesian3.normalize(cDir, new Cesium.Cartesian3());
cUp = Cesium.Cartesian3.normalize(cUp, new Cesium.Cartesian3());
cesiumViewer.camera.setView({
destination : cPos,
orientation : {
direction : cDir,
up : cUp
}
});
}
let aspect = potreeViewer.scene.getActiveCamera().aspect;
if(aspect < 1){
let fovy = Math.PI * (potreeViewer.scene.getActiveCamera().fov / 180);
cesiumViewer.camera.frustum.fov = fovy;
}else{
let fovy = Math.PI * (potreeViewer.scene.getActiveCamera().fov / 180);
let fovx = Math.atan(Math.tan(0.5 * fovy) * aspect) * 2
cesiumViewer.camera.frustum.fov = fovx;
}
}
cesiumViewer.render();
}
requestAnimationFrame(loop);
</script>
<!-- How to change the classification -->
<script type="module">
import * as THREE from "../libs/three.js/build/three.module.js";
window.setCustomScheme = function(){
potreeViewer.setClassifications({
0: { visible: true, name: 'unclassified' , color: [0.46, 0.39, 0.39, 1.0] },
1: { visible: true, name: 'Road' , color: [0.19, 0.25, 0.35, 1.0] },
2: { visible: true, name: 'River' , color: [0.39, 69, 19, 1] },
3: { visible: true, name: 'Structures' , color: [0.45, 0.06, 0.06, 1.0] },
4: { visible: true, name: 'Dike' , color: [1, 0.39, 69, 19] },
5: { visible: true, name: 'Agricultural Field' , color: [1.0, 1.0, 0.0, 1.0] },
6: { visible: true, name: 'Diverse Vegetation' , color: [0.0, 1.0, 0.0, 1.0] },
DEFAULT: { visible: false, name: 'other' , color: [0.0, 0.0, 0.0, 1.0] },
});
}
window.setRandomScheme = function(){
const scheme = {};
for(let i = 0; i < 32; i++){
scheme[i] = { visible: true, name: `random:_${i}`, color: [Math.random(), Math.random(), Math.random(), 1.0] };
}
potreeViewer.setClassifications(scheme);
}
</script>
</body>
</html>