-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathextra_materials_trimble_sitn.html
379 lines (282 loc) · 10.8 KB
/
extra_materials_trimble_sitn.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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
<html>
<head>
<meta http-equiv="origin-trial" content="ApM2LRrizp8n6n1p9IaYNL9tbGYTRob0jgm5wOr1jPQeXXyKTqNbaZKaC2LgVTyizCde6tC6XL0ZeH28L/z3EAEAAABdeyJvcmlnaW4iOiJodHRwczovL3BvdHJlZS5vcmc6NDQzIiwiZmVhdHVyZSI6IldlYkdQVSIsImV4cGlyeSI6MTY0MzE1NTE5OSwiaXNTdWJkb21haW4iOnRydWV9">
<style>
td{
padding: 2px 10px 0px 0px;
}
#big_message{
position: absolute;
left: calc(50%);
bottom: 10px;
color: white;
text-shadow: 4px 4px 4px black;
font-size: 4em;
font-weight: bold;
font-family: "Consolas";
/* from https://stackoverflow.com/a/14249403/913630 */
text-shadow: 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black;
}
#msg_dbg{
position: absolute;
left: 10px;
bottom: 10px;
color: white;
text-shadow: 4px 4px 4px black;
font-size: 1em;
font-weight: bold;
font-family: "Consolas";
/* from https://stackoverflow.com/a/14249403/913630 */
text-shadow: 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black, 0 0 4px black;
}
canvas{
image-rendering: pixelated;
display: flex;
position: absolute;
height: 100%;
}
</style>
</head>
<body style="padding: 0; margin: 0">
<div id="potree" style="width: 100%; height: 100%; position: fixed;">
<span style="position: relative">
<canvas id="canvas" width="800" height="600" style="width: 100%; height: 100%;"></canvas>
</span>
</div>
<span id="big_message"></span>
<span id="msg_dbg"></span>
<script type="importmap">
{
"imports": {
"potree": "./src/Potree.js",
"lazperf": "./libs/laz-perf/laz-perf.js",
"toolbar": "./src/modules/toolbar/toolbar.js",
"sidebar": "./src/modules/sidebar/sidebar.js",
"dat.gui": "./libs/dat.gui/dat.gui.module.js",
"stats": "./libs/stats.js/stats.module.js",
"BinaryHeap": "./libs/BinaryHeap/BinaryHeap.js",
"tween": "./libs/tween/tween.esm.js",
"range-select": "./libs/range-select/RangeSelect.js"
}
}
</script>
<script type="module">
import {Potree} from "potree";
import {Vector3, Mesh, Geometry, geometries, Points, PointLight} from "potree";
import {WireframeMaterial, TriangleColorMaterial} from "potree";
import {initGUI} from "./src/modules/gui_dat/gui.js";
import "range-select";
import {proj4} from "./libs/proj4js/proj4-src.js";
import {load as loadGLB} from "./src/misc/GLBLoader.js";
// import {GlbVoxelLoader} from "./src/misc/glbvoxels/GlbVoxelLoader.js";
console.log(proj4.version);
// import {installToolbar} from "toolbar";
import {installSidebar} from "sidebar";
let canvas = document.getElementById("canvas");
let elPotree = document.getElementById("potree");
let potree = await Potree.init(canvas);
let {scene, controls} = potree;
// installToolbar(potree.renderer.canvas, potree);
// window.Potree = {
// version: "abc",
// };
window.sidebar = installSidebar(elPotree, potree);
window.Potree = Potree;
window.potree = potree;
window.Vector3 = Vector3;
Potree.settings.edlEnabled = true;
Potree.settings.dilateEnabled = false;
Potree.settings.hqsEnabled = true;
// default, if not overriden later on
controls.set({
position: [-19.0, 13.6, 12.2],
pivot: [-0.0, 2.2, 3.9],
});
import {CopcLoader, Image360, Images360, SplatType} from "potree";
Potree.settings.pointBudget = 4_000_000;
// Potree.settings.pointBudget = 30_000;
// Potree.settings.attribute = "classification";
Potree.settings.attribute = "rgba";
Potree.settings.pointSize = 3;
Potree.settings.splatType = SplatType.POINTS;
// Potree.settings.pointBudget = 30085;
// // CopcLoader.load("./sofi.copc.laz").then(pointcloud => {
// CopcLoader.load("./autzen-classified.copc.laz").then(pointcloud => {
// window.pointcloud = pointcloud;
// pointcloud.name = "Autzen Stadium";
// let min = new Vector3(...pointcloud.loader.header.min);
// let max = new Vector3(...pointcloud.loader.header.max);
// let center = min.add(max).multiplyScalar(0.5);
// let size = min.distanceTo(max);
// controls.set({
// yaw: -0.2,
// pitch: 0.8,
// radius: 1.5 * size,
// pivot: center,
// });
// scene.add(scene.root, pointcloud);
// });
// Potree.load("./resources/pointclouds/heidentor/metadata.json", {name: "CA13"}).then(pointcloud => {
// pointcloud.name = "Heidentor";
// scene.root.children.push(pointcloud);
// });
loadGLB("./resources/models/australia_gas.glb", {
onStart: (node) => {
node.rotation.makeIdentity();
node.rotation.rotate(1.2, {x: 1, y: 0, z: 0});
node.rotation.rotate(-0.1, {x: 0, y: 1, z: 0});
node.scale.set(2, 2, 2);
node.position.set(-25, -10, 10);
node.name = "australia_gas";
scene.root.children.push(node);
}, onNode: (mesh) => {
console.log(mesh);
}
});
// Potree.load("./resources/models/ruins.glb").then(model => {
// console.log(model);
// // scene.root.children.push(model);
// });
Potree.load("./resources/pointclouds/heidentor/metadata.json").then(pointcloud => {
scene.root.children.push(pointcloud);
controls.set({
position: [20, 20, 20],
pivot: [0, 0, 0]
});
});
// Potree.load("./resources/pointclouds/CA13/metadata.json").then(pointcloud => {
Potree.load("./resources/pointclouds/las14_extra_attributes/metadata.json").then(pointcloud => {
window.pointcloud = pointcloud;
pointcloud.name = "sitn extra attributes";
// controls.set({
// position: [2561569.7, 1204855.7, 818.0],
// pivot: [2561737.6, 1205229.8, 439.5]
// // position: [2561582.3, 1205181.5, 524.3],
// // pivot: [2561594.6, 1205221.8, 480.1]
// });
let material = pointcloud.material;
console.log(material.attributes);
// register a new "runtime attribute"
material.registerAttribute("animated elevation");
material.registerMapping({
name: "animated elevation",
condition: (attribute) => (attribute.name === "animated elevation"),
wgsl: `
fn map_animated_elevation(vertex : VertexInput, attrib : AttributeDescriptor, node : Node, position : vec4<f32>) -> vec4<f32> {
var u = position.x / 500.0;
var v = position.y / 500.0;
var d = length(vec2<f32>(u - 0.5, v - 0.5));
var value = (uniforms.world * position).z;
var w = (value - 430.0) / (570.0 - 430.0);
var uv : vec2<f32> = vec2<f32>(w, 0.0);
var color = textureSampleLevel(gradientTexture, sampler_clamp, uv, 0.0);
if(cos(30.0 * d - 2.0 * uniforms.time) < -0.7){
color.w = 0.0;
}
return color;
}
`,
});
// register an attribute->color mapping that automatically applies
// to attributes that fullfill a given condition
material.registerMapping({
name: "normal (trimble 2-15-15)",
condition: (attribute) => (attribute.description === "Normal vector 2+15+15 bits"),
wgsl: `
fn map_normal_trimble_2_15_15(vertex : VertexInput, attrib : AttributeDescriptor, node : Node, position : vec4<f32>) -> vec4<f32> {
var PI = 3.1415;
var HML = (2.0 * PI) / 32767.0;
var VML = PI / 32767.0;
var offset = node.numPoints * attrib.offset + 4u * vertex.vertexID;
var value = readU32(offset);
var mask_15b = (1u << 15u) - 1u;
var dim = value & 3u;
var horzAngle = f32((value >> 2u) & mask_15b);
var vertAngle = f32((value >> 17u) & mask_15b);
var ang = (VML * vertAngle) - 0.5 * PI;
var zvl = sin(ang);
var xml = sqrt( 1.0 - (zvl * zvl));
var normal : vec3<f32>;
normal.x = xml * cos(HML * horzAngle);
normal.y = xml * sin(HML * horzAngle);
normal.z = zvl;
var color = vec4<f32>(normal, 1.0);
color = vec4<f32>(
1.0 * normal.x,
1.0 * normal.y,
1.0 * normal.z,
1.0,
);
return color;
}
`,
});
material.registerMapping({
name: "group",
condition: (attribute) => (attribute.name === "Group"),
wgsl: `
fn map_terrascan_group(vertex : VertexInput, attrib : AttributeDescriptor, node : Node, position : vec4<f32>) -> vec4<f32> {
var offset = node.numPoints * attrib.offset + 4u * vertex.vertexID;
var value = readU32(offset);
var w = f32(value) / 1234.0;
w = f32(value % 10u) / 10.0;
var uv = vec2<f32>(w, 0.0);
var color = textureSampleLevel(gradientTexture, sampler_repeat, uv, 0.0);
return color;
}
`,
});
material.registerMapping({
name: "distance",
condition: (attribute) => (attribute.name === "Distance"),
wgsl: `
fn map_terrascan_distance(vertex : VertexInput, attrib : AttributeDescriptor, node : Node, position : vec4<f32>) -> vec4<f32> {
var offset = node.numPoints * attrib.offset + 4u * vertex.vertexID;
var value = readI32(offset);
// assuming distance in meters
var distance = f32(value) / 1000.0;
var w = distance / 30.0;
var uv = vec2<f32>(w, 0.0);
var color = textureSampleLevel(gradientTexture, sampler_clamp, uv, 0.0);
return color;
}
`,
});
// Potree.settings.attribute = "Normal";
scene.root.children.push(pointcloud);
});
// Potree.load("./resources/pointclouds/aerial_lidar2019_2524_1197_laz14_dip/metadata.json").then(pointcloud => {
// window.pointcloud = pointcloud;
// pointcloud.name = "sitn dip";
// controls.set({
// position: [2524961.6, 1198245.8, 1646.2],
// pivot: [2524503.6, 1197488.7, 1098.6]
// });
// scene.root.children.push(pointcloud);
// });
// Potree.load("./nocommit/F_pointclouds/CA13_morro_bay/morro_bay.las_converted/metadata.json").then(pointcloud => {
// window.pointcloud = pointcloud;
// pointcloud.name = "CA13";
// controls.set({
// position: [694616.5, 3916084.9, 216.0],
// pivot: [694733.8, 3916401.9, 19.8]
// });
// scene.root.children.push(pointcloud);
// });
let origin = new Vector3(0, 0, 0);
let X = new Vector3(10, 0, 0);
let Y = new Vector3(0, 10, 0);
let Z = new Vector3(0, 0, 10);
let red = new Vector3(255, 0, 0);
let green = new Vector3(0, 255, 0);
let blue = new Vector3(0, 0, 255);
import {sphere} from "./src/modules/geometries/sphere.js";
potree.onUpdate( () => {
// potree.renderer.drawLine(origin, X, red);
// potree.renderer.drawLine(origin, Y, green);
// potree.renderer.drawLine(origin, Z, blue);
// potree.renderer.drawSphere(origin, 2);
});
</script>
</body>
</html>