itowns 2.43.2-next.14 → 2.43.2-next.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/558.js +2 -0
- package/dist/558.js.map +1 -0
- package/dist/itowns.js +1 -1
- package/dist/itowns.js.map +1 -1
- package/dist/itowns_lasparser.js +2 -0
- package/dist/itowns_lasparser.js.map +1 -0
- package/dist/itowns_lasworker.js +2 -0
- package/dist/itowns_lasworker.js.map +1 -0
- package/examples/potree2_25d_map.html +1 -1
- package/lib/Core/Potree2Node.js +6 -1
- package/lib/Parser/LASParser.js +48 -16
- package/lib/Worker/LASLoaderWorker.js +19 -0
- package/package.json +1 -1
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
potreeLayer = new itowns.Potree2Layer('Lion', {
|
|
64
64
|
source: new itowns.Potree2Source({
|
|
65
65
|
file: 'metadata.json',
|
|
66
|
-
url: 'https://
|
|
66
|
+
url: 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/pointclouds/potree2.0/lion',
|
|
67
67
|
crs: view.referenceCrs,
|
|
68
68
|
}),
|
|
69
69
|
});
|
package/lib/Core/Potree2Node.js
CHANGED
|
@@ -105,11 +105,16 @@ class Potree2Node extends PointCloudNode {
|
|
|
105
105
|
}
|
|
106
106
|
networkOptions(byteOffset, byteSize) {
|
|
107
107
|
const first = byteOffset;
|
|
108
|
+
// When we specify 'multipart/byteranges' on headers request it trigger a preflight request
|
|
109
|
+
// Actually github doesn't support it https://github.com/orgs/community/discussions/24659
|
|
110
|
+
// But if we omit header parameter, github seems to know it's a 'multipart/byteranges' request (thanks to 'Range' parameter)
|
|
108
111
|
const networkOptions = {
|
|
109
112
|
...this.layer.source.networkOptions,
|
|
110
113
|
headers: {
|
|
111
114
|
...this.layer.source.networkOptions.headers,
|
|
112
|
-
'
|
|
115
|
+
...(this.url.startsWith('https://raw.githubusercontent.com') ? {} : {
|
|
116
|
+
'content-type': 'multipart/byteranges'
|
|
117
|
+
}),
|
|
113
118
|
Range: `bytes=${first}-${first + byteSize - 1n}`
|
|
114
119
|
}
|
|
115
120
|
};
|
package/lib/Parser/LASParser.js
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import { spawn, Thread, Transfer } from 'threads';
|
|
3
|
+
let _lazPerf;
|
|
4
|
+
let _thread;
|
|
5
|
+
function workerInstance() {
|
|
6
|
+
return new Worker( /* webpackChunkName: "itowns_lasparser" */
|
|
7
|
+
new URL('../Worker/LASLoaderWorker.js', import.meta.url), {
|
|
8
|
+
type: 'module'
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
async function loader() {
|
|
12
|
+
if (_thread) {
|
|
13
|
+
return _thread;
|
|
14
|
+
}
|
|
15
|
+
_thread = await spawn(workerInstance());
|
|
16
|
+
if (_lazPerf) {
|
|
17
|
+
_thread.lazPerf(_lazPerf);
|
|
18
|
+
}
|
|
19
|
+
return _thread;
|
|
20
|
+
}
|
|
4
21
|
function buildBufferGeometry(attributes) {
|
|
5
22
|
const geometry = new THREE.BufferGeometry();
|
|
6
23
|
const positionBuffer = new THREE.BufferAttribute(attributes.position, 3);
|
|
@@ -42,7 +59,16 @@ export default {
|
|
|
42
59
|
if (!path) {
|
|
43
60
|
throw new Error('Path to laz-perf is mandatory');
|
|
44
61
|
}
|
|
45
|
-
|
|
62
|
+
_lazPerf = path;
|
|
63
|
+
},
|
|
64
|
+
/**
|
|
65
|
+
* Terminate all worker instances.
|
|
66
|
+
* @returns {Promise<void>}
|
|
67
|
+
*/
|
|
68
|
+
terminate() {
|
|
69
|
+
const currentThread = _thread;
|
|
70
|
+
_thread = undefined;
|
|
71
|
+
return Thread.terminate(currentThread);
|
|
46
72
|
},
|
|
47
73
|
/**
|
|
48
74
|
* Parses a chunk of a LAS or LAZ (LASZip) and returns the corresponding
|
|
@@ -66,13 +92,18 @@ export default {
|
|
|
66
92
|
* @return {Promise<THREE.BufferGeometry>} A promise resolving with a
|
|
67
93
|
* `THREE.BufferGeometry`.
|
|
68
94
|
*/
|
|
69
|
-
parseChunk(data) {
|
|
95
|
+
async parseChunk(data) {
|
|
70
96
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
97
|
+
const lasLoader = await loader();
|
|
98
|
+
const parsedData = await lasLoader.parseChunk(Transfer(data), {
|
|
99
|
+
pointCount: options.in.pointCount,
|
|
100
|
+
header: options.in.header,
|
|
101
|
+
eb: options.eb,
|
|
102
|
+
colorDepth: options.in.colorDepth
|
|
75
103
|
});
|
|
104
|
+
const geometry = buildBufferGeometry(parsedData.attributes);
|
|
105
|
+
geometry.computeBoundingBox();
|
|
106
|
+
return geometry;
|
|
76
107
|
},
|
|
77
108
|
/**
|
|
78
109
|
* Parses a LAS file or a LAZ (LASZip) file and return the corresponding
|
|
@@ -88,18 +119,19 @@ export default {
|
|
|
88
119
|
* @return {Promise} A promise resolving with a `THREE.BufferGeometry`. The
|
|
89
120
|
* header of the file is contained in `userData`.
|
|
90
121
|
*/
|
|
91
|
-
parse(data) {
|
|
122
|
+
async parse(data) {
|
|
92
123
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
93
124
|
if (options.out?.skip) {
|
|
94
125
|
console.warn("Warning: options 'skip' not supported anymore");
|
|
95
126
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
geometry.userData.header = parsedData.header;
|
|
101
|
-
geometry.computeBoundingBox();
|
|
102
|
-
return geometry;
|
|
127
|
+
const input = options.in;
|
|
128
|
+
const lasLoader = await loader();
|
|
129
|
+
const parsedData = await lasLoader.parseFile(Transfer(data), {
|
|
130
|
+
colorDepth: input?.colorDepth
|
|
103
131
|
});
|
|
132
|
+
const geometry = buildBufferGeometry(parsedData.attributes);
|
|
133
|
+
geometry.userData.header = parsedData.header;
|
|
134
|
+
geometry.computeBoundingBox();
|
|
135
|
+
return geometry;
|
|
104
136
|
}
|
|
105
137
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { expose, Transfer } from 'threads/worker';
|
|
2
|
+
import LASLoader from "../Loader/LASLoader.js";
|
|
3
|
+
const loader = new LASLoader();
|
|
4
|
+
function transferable(attributes) {
|
|
5
|
+
return Object.values(attributes).filter(ArrayBuffer.isView).map(a => a.buffer);
|
|
6
|
+
}
|
|
7
|
+
expose({
|
|
8
|
+
lazPerf(path) {
|
|
9
|
+
loader.lazPerf = path;
|
|
10
|
+
},
|
|
11
|
+
async parseChunk(data, options) {
|
|
12
|
+
const result = await loader.parseChunk(data, options);
|
|
13
|
+
return Transfer(result, transferable(result.attributes));
|
|
14
|
+
},
|
|
15
|
+
async parseFile(data, options) {
|
|
16
|
+
const result = await loader.parseFile(data, options);
|
|
17
|
+
return Transfer(result, transferable(result.attributes));
|
|
18
|
+
}
|
|
19
|
+
});
|