forked from potree/potree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTEMPLATE_v03.html
185 lines (146 loc) · 6.08 KB
/
TEMPLATE_v03.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
<!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">
<title>Potree Viewer</title>
<link rel="stylesheet" type="text/css" href="../../build/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">
</head>
<body>
<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="../../build/potree/potree.js"></script>
<script src="../../libs/plasio/js/laslaz.js"></script>
<div class="potree_container" style="position: absolute; width: 100%; height: 100%; left: 0px; top: 0px; ">
<div id="potree_render_area" style="background-image: url('../../build/potree/resources/images/background.jpg');">
</div>
<div id="potree_sidebar_container"> </div>
</div>
<script type="module">
import * as THREE from "../libs/three.js/build/three.module.js";
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
viewer.setEDLEnabled(true);
viewer.setFOV(60);
viewer.setPointBudget(2_000_000);
viewer.loadSettingsFromURL();
viewer.setDescription(`Geobotica Pointcloud Web Viewer (v03)`);
viewer.loadGUI(() => {
viewer.setLanguage('en');
$("#menu_scene").next().show();
viewer.toggleSidebar();
});
// Load and add pointcloud to scene
Potree.loadPointCloud("https://ugmapping.s3.amazonaws.com/test/INSERT_FOLDER_TIMESTAMP/potree/metadata.json", "cloud", e => {
let scene = viewer.scene;
let pointcloud = e.pointcloud;
let material = pointcloud.material;
material.size = 0.5;
material.minSize = 2.0;
material.pointSizeType = Potree.PointSizeType.ADAPTIVE;
material.shape = Potree.PointShape.SQUARE;
material.activeAttributeName = "intensity gradient";
scene.addPointCloud(pointcloud);
viewer.scene.view.setView(
[30, 30, 30],
[0, 0, 0],
);
run();
});
// Add video annotations to the scene
fetch("https://ugmapping.s3.amazonaws.com/test/INSERT_FOLDER_TIMESTAMP/arducam/videos/coordinates.txt")
.then((response) => response.text())
.then((text) => {
// Split the content by newlines to get each coordinate pair
const lines = text.split('\n');
// Initialize an array to hold the coordinates
const annotations = [];
// Loop through each line and parse the coordinates
lines.forEach(line => {
// Remove any leading/trailing spaces and check if the line is empty
const trimmedLine = line.trim();
if (trimmedLine) {
// Split each line into its x and y values (assuming the coordinates are separated by a comma)
const parts = trimmedLine.split('\t');
// Parse the x and y values as floats and push to the array
const x = parseFloat(parts[2]);
const y = parseFloat(parts[3]);
const z = parseFloat(parts[4]);
const fname = parts[0].substring(3, parts[0].length - 1);
// TODO: Figure out a way to change this
const dir = "https://ugmapping.s3.amazonaws.com/test/INSERT_FOLDER_TIMESTAMP/arducam/videos/"
const vid_link = dir.concat(fname);
if (!isNaN(x) && !isNaN(y) && !isNaN(z)) {
let vidTitle = $(`
<span>
${fname}
<img src="https://ugmapping.s3.amazonaws.com/resources/icons/goto.svg"
name="action_set_scene"
class="annotation-action-icon"
style="filter: invert(1);" />
</span>
`);
vidTitle.find("img[name=action_set_scene]").click( (event) => {
window.open(vid_link, "_blank");
});
vidTitle.toString = () => fname;
let video = new Potree.Annotation({
// NOTE: These parameters will need to be changed, they're just like this for the test dataset
position: [x, y, z],
"cameraPosition": [x + 1000, y + 1000, z + 1000],
"cameraTarget": [x, y, z],
"title": vidTitle
// "description": `<a href="https://www.google.com">Video Playback</a>`
// NOTE: We have 3 options: can have this link above, can have the icon to click or can possibly have a link as the title
});
viewer.scene.annotations.add(video);
annotations.push(video);
}
}
});
});
function updateAnnotations() {
let cameraPos = viewer.scene.getActiveCamera().position;
console.log("Camera Position:", cameraPos); // Log camera position
let annotations = viewer.scene.getAnnotations();
annotations.children.forEach(anno => {
if (anno.position) {
let distance = cameraPos.distanceTo(anno.position);
console.log(`Annotation at ${anno.position} has distance: ${distance}`);
anno.visible = distance <= 30000;
} else {
console.warn("Annotation does not have a position:", anno);
}
});
}
document.addEventListener("mousedown", () => {
console.log("Mouse button clicked, triggering updateAnnotations.");
updateAnnotations();
});
document.addEventListener("wheel", () => {
console.log("Mouse wheel used, triggering updateAnnotations.");
updateAnnotations();
});
async function run() {
// Add image spheres to the scene
Potree.Images360Loader.load("https://ugmapping.s3.amazonaws.com/test/INSERT_FOLDER_TIMESTAMP/imgs", viewer).then( images => {
viewer.scene.add360Images(images);
});
viewer.mapView.showSources(false);
}
</script>
</body>
</html>