itowns 2.43.2-next.10 → 2.43.2-next.12
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/itowns.js +1 -1
- package/dist/itowns.js.map +1 -1
- package/dist/itowns_potree2worker.js +2 -0
- package/dist/itowns_potree2worker.js.map +1 -0
- package/examples/config.json +1 -0
- package/examples/potree2_25d_map.html +127 -0
- package/lib/Core/Potree2Node.js +201 -0
- package/lib/Core/Potree2PointAttributes.js +139 -0
- package/lib/Core/Scheduler/Scheduler.js +1 -1
- package/lib/Layer/Potree2Layer.js +165 -0
- package/lib/Loader/Potree2BrotliLoader.js +261 -0
- package/lib/Loader/Potree2Loader.js +207 -0
- package/lib/Main.js +2 -0
- package/lib/Parser/LASParser.js +1 -1
- package/lib/Parser/Potree2BinParser.js +92 -0
- package/lib/Renderer/PointsMaterial.js +1 -1
- package/lib/Source/FileSource.js +1 -1
- package/lib/Source/Potree2Source.js +172 -0
- package/lib/Worker/Potree2Worker.js +21 -0
- package/package.json +4 -2
- /package/lib/{Parser → Loader}/LASLoader.js +0 -0
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
/*
|
|
2
|
+
============
|
|
3
|
+
== POTREE ==
|
|
4
|
+
============
|
|
5
|
+
|
|
6
|
+
http://potree.org
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2011-2020, Markus Schütz
|
|
9
|
+
All rights reserved.
|
|
10
|
+
|
|
11
|
+
Redistribution and use in source and binary forms, with or without
|
|
12
|
+
modification, are permitted provided that the following conditions are met:
|
|
13
|
+
|
|
14
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
15
|
+
list of conditions and the following disclaimer.
|
|
16
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
17
|
+
this list of conditions and the following disclaimer in the documentation
|
|
18
|
+
and/or other materials provided with the distribution.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
21
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
22
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
24
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
25
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
26
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
27
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
28
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
29
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
30
|
+
|
|
31
|
+
The views and conclusions contained in the software and documentation are those
|
|
32
|
+
of the authors and should not be interpreted as representing official policies,
|
|
33
|
+
either expressed or implied, of the FreeBSD Project.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
import { PointAttribute, PointAttributeTypes } from "../Core/Potree2PointAttributes.js";
|
|
37
|
+
import { decompress } from 'brotli-compress/js.mjs';
|
|
38
|
+
const typedArrayMapping = {
|
|
39
|
+
int8: Int8Array,
|
|
40
|
+
int16: Int16Array,
|
|
41
|
+
int32: Int32Array,
|
|
42
|
+
int64: Float64Array,
|
|
43
|
+
uint8: Uint8Array,
|
|
44
|
+
uint16: Uint16Array,
|
|
45
|
+
uint32: Uint32Array,
|
|
46
|
+
uint64: Float64Array,
|
|
47
|
+
float: Float32Array,
|
|
48
|
+
double: Float64Array
|
|
49
|
+
};
|
|
50
|
+
function dealign24b(mortoncode) {
|
|
51
|
+
// see https://stackoverflow.com/questions/45694690/how-i-can-remove-all-odds-bits-in-c
|
|
52
|
+
|
|
53
|
+
// input alignment of desired bits
|
|
54
|
+
// ..a..b..c..d..e..f..g..h..i..j..k..l..m..n..o..p
|
|
55
|
+
let x = mortoncode;
|
|
56
|
+
|
|
57
|
+
// ..a..b..c..d..e..f..g..h..i..j..k..l..m..n..o..p ..a..b..c..d..e..f..g..h..i..j..k..l..m..n..o..p
|
|
58
|
+
// ..a.....c.....e.....g.....i.....k.....m.....o... .....b.....d.....f.....h.....j.....l.....n.....p
|
|
59
|
+
// ....a.....c.....e.....g.....i.....k.....m.....o. .....b.....d.....f.....h.....j.....l.....n.....p
|
|
60
|
+
x = (x & 0b001000001000001000001000) >> 2 | (x & 0b000001000001000001000001) >> 0;
|
|
61
|
+
// ....ab....cd....ef....gh....ij....kl....mn....op ....ab....cd....ef....gh....ij....kl....mn....op
|
|
62
|
+
// ....ab..........ef..........ij..........mn...... ..........cd..........gh..........kl..........op
|
|
63
|
+
// ........ab..........ef..........ij..........mn.. ..........cd..........gh..........kl..........op
|
|
64
|
+
x = (x & 0b000011000000000011000000) >> 4 | (x & 0b000000000011000000000011) >> 0;
|
|
65
|
+
// ........abcd........efgh........ijkl........mnop ........abcd........efgh........ijkl........mnop
|
|
66
|
+
// ........abcd....................ijkl............ ....................efgh....................mnop
|
|
67
|
+
// ................abcd....................ijkl.... ....................efgh....................mnop
|
|
68
|
+
x = (x & 0b000000001111000000000000) >> 8 | (x & 0b000000000000000000001111) >> 0;
|
|
69
|
+
// ................abcdefgh................ijklmnop ................abcdefgh................ijklmnop
|
|
70
|
+
// ................abcdefgh........................ ........................................ijklmnop
|
|
71
|
+
// ................................abcdefgh........ ........................................ijklmnop
|
|
72
|
+
x = (x & 0b000000000000000000000000) >> 16 | (x & 0b000000000000000011111111) >> 0;
|
|
73
|
+
|
|
74
|
+
// sucessfully realigned!
|
|
75
|
+
// ................................abcdefghijklmnop
|
|
76
|
+
|
|
77
|
+
return x;
|
|
78
|
+
}
|
|
79
|
+
export default async function load(buffer, options) {
|
|
80
|
+
const {
|
|
81
|
+
pointAttributes,
|
|
82
|
+
scale,
|
|
83
|
+
min,
|
|
84
|
+
size,
|
|
85
|
+
offset,
|
|
86
|
+
numPoints
|
|
87
|
+
} = options;
|
|
88
|
+
let bytes;
|
|
89
|
+
if (numPoints === 0) {
|
|
90
|
+
bytes = {
|
|
91
|
+
buffer: new ArrayBuffer(0)
|
|
92
|
+
};
|
|
93
|
+
} else {
|
|
94
|
+
try {
|
|
95
|
+
bytes = await decompress(new Int8Array(buffer));
|
|
96
|
+
} catch (e) {
|
|
97
|
+
bytes = {
|
|
98
|
+
buffer: new ArrayBuffer(numPoints * (pointAttributes.byteSize + 12))
|
|
99
|
+
};
|
|
100
|
+
console.error(`problem with node ${name}: `, e);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const view = new DataView(bytes.buffer);
|
|
104
|
+
const attributeBuffers = {};
|
|
105
|
+
const gridSize = 32;
|
|
106
|
+
const grid = new Uint32Array(gridSize ** 3);
|
|
107
|
+
const toIndex = (x, y, z) => {
|
|
108
|
+
// min is already subtracted
|
|
109
|
+
const dx = gridSize * x / size.x;
|
|
110
|
+
const dy = gridSize * y / size.y;
|
|
111
|
+
const dz = gridSize * z / size.z;
|
|
112
|
+
const ix = Math.min(parseInt(dx, 10), gridSize - 1);
|
|
113
|
+
const iy = Math.min(parseInt(dy, 10), gridSize - 1);
|
|
114
|
+
const iz = Math.min(parseInt(dz, 10), gridSize - 1);
|
|
115
|
+
return ix + iy * gridSize + iz * gridSize * gridSize;
|
|
116
|
+
};
|
|
117
|
+
let numOccupiedCells = 0;
|
|
118
|
+
let byteOffset = 0;
|
|
119
|
+
for (const pointAttribute of pointAttributes.attributes) {
|
|
120
|
+
if (['POSITION_CARTESIAN', 'position'].includes(pointAttribute.name)) {
|
|
121
|
+
const buff = new ArrayBuffer(numPoints * 4 * 3);
|
|
122
|
+
const positions = new Float32Array(buff);
|
|
123
|
+
for (let j = 0; j < numPoints; j++) {
|
|
124
|
+
const mc_0 = view.getUint32(byteOffset + 4, true);
|
|
125
|
+
const mc_1 = view.getUint32(byteOffset + 0, true);
|
|
126
|
+
const mc_2 = view.getUint32(byteOffset + 12, true);
|
|
127
|
+
const mc_3 = view.getUint32(byteOffset + 8, true);
|
|
128
|
+
byteOffset += 16;
|
|
129
|
+
let X = dealign24b((mc_3 & 0x00FFFFFF) >>> 0) | dealign24b((mc_3 >>> 24 | mc_2 << 8) >>> 0) << 8;
|
|
130
|
+
let Y = dealign24b((mc_3 & 0x00FFFFFF) >>> 1) | dealign24b((mc_3 >>> 24 | mc_2 << 8) >>> 1) << 8;
|
|
131
|
+
let Z = dealign24b((mc_3 & 0x00FFFFFF) >>> 2) | dealign24b((mc_3 >>> 24 | mc_2 << 8) >>> 2) << 8;
|
|
132
|
+
if (mc_1 != 0 || mc_2 != 0) {
|
|
133
|
+
X = X | dealign24b((mc_1 & 0x00FFFFFF) >>> 0) << 16 | dealign24b((mc_1 >>> 24 | mc_0 << 8) >>> 0) << 24;
|
|
134
|
+
Y = Y | dealign24b((mc_1 & 0x00FFFFFF) >>> 1) << 16 | dealign24b((mc_1 >>> 24 | mc_0 << 8) >>> 1) << 24;
|
|
135
|
+
Z = Z | dealign24b((mc_1 & 0x00FFFFFF) >>> 2) << 16 | dealign24b((mc_1 >>> 24 | mc_0 << 8) >>> 2) << 24;
|
|
136
|
+
}
|
|
137
|
+
const x = parseInt(X, 10) * scale[0] + offset[0] - min.x;
|
|
138
|
+
const y = parseInt(Y, 10) * scale[1] + offset[1] - min.y;
|
|
139
|
+
const z = parseInt(Z, 10) * scale[2] + offset[2] - min.z;
|
|
140
|
+
const index = toIndex(x, y, z);
|
|
141
|
+
const count = grid[index]++;
|
|
142
|
+
if (count === 0) {
|
|
143
|
+
numOccupiedCells++;
|
|
144
|
+
}
|
|
145
|
+
positions[3 * j + 0] = x;
|
|
146
|
+
positions[3 * j + 1] = y;
|
|
147
|
+
positions[3 * j + 2] = z;
|
|
148
|
+
}
|
|
149
|
+
attributeBuffers[pointAttribute.name] = {
|
|
150
|
+
buffer: buff,
|
|
151
|
+
attribute: pointAttribute
|
|
152
|
+
};
|
|
153
|
+
} else if (['RGBA', 'rgba'].includes(pointAttribute.name)) {
|
|
154
|
+
const buff = new ArrayBuffer(numPoints * 4);
|
|
155
|
+
const colors = new Uint8Array(buff);
|
|
156
|
+
for (let j = 0; j < numPoints; j++) {
|
|
157
|
+
const mc_0 = view.getUint32(byteOffset + 4, true);
|
|
158
|
+
const mc_1 = view.getUint32(byteOffset + 0, true);
|
|
159
|
+
byteOffset += 8;
|
|
160
|
+
const r = dealign24b((mc_1 & 0x00FFFFFF) >>> 0) | dealign24b((mc_1 >>> 24 | mc_0 << 8) >>> 0) << 8;
|
|
161
|
+
const g = dealign24b((mc_1 & 0x00FFFFFF) >>> 1) | dealign24b((mc_1 >>> 24 | mc_0 << 8) >>> 1) << 8;
|
|
162
|
+
const b = dealign24b((mc_1 & 0x00FFFFFF) >>> 2) | dealign24b((mc_1 >>> 24 | mc_0 << 8) >>> 2) << 8;
|
|
163
|
+
colors[4 * j + 0] = r > 255 ? r / 256 : r;
|
|
164
|
+
colors[4 * j + 1] = g > 255 ? g / 256 : g;
|
|
165
|
+
colors[4 * j + 2] = b > 255 ? b / 256 : b;
|
|
166
|
+
}
|
|
167
|
+
attributeBuffers[pointAttribute.name] = {
|
|
168
|
+
buffer: buff,
|
|
169
|
+
attribute: pointAttribute
|
|
170
|
+
};
|
|
171
|
+
} else {
|
|
172
|
+
const buff = new ArrayBuffer(numPoints * 4);
|
|
173
|
+
const f32 = new Float32Array(buff);
|
|
174
|
+
const TypedArray = typedArrayMapping[pointAttribute.type.name];
|
|
175
|
+
const preciseBuffer = new TypedArray(numPoints);
|
|
176
|
+
let [offset, scale] = [0, 1];
|
|
177
|
+
const getterMap = {
|
|
178
|
+
int8: view.getInt8,
|
|
179
|
+
int16: view.getInt16,
|
|
180
|
+
int32: view.getInt32,
|
|
181
|
+
uint8: view.getUint8,
|
|
182
|
+
uint16: view.getUint16,
|
|
183
|
+
uint32: view.getUint32,
|
|
184
|
+
float: view.getFloat32,
|
|
185
|
+
double: view.getFloat64
|
|
186
|
+
};
|
|
187
|
+
const getter = getterMap[pointAttribute.type.name].bind(view);
|
|
188
|
+
|
|
189
|
+
// compute offset and scale to pack larger types into 32 bit floats
|
|
190
|
+
if (pointAttribute.type.size > 4) {
|
|
191
|
+
const [amin, amax] = pointAttribute.range;
|
|
192
|
+
offset = amin;
|
|
193
|
+
scale = 1 / (amax - amin);
|
|
194
|
+
}
|
|
195
|
+
for (let j = 0; j < numPoints; j++) {
|
|
196
|
+
const value = getter(byteOffset, true);
|
|
197
|
+
byteOffset += pointAttribute.byteSize;
|
|
198
|
+
f32[j] = (value - offset) * scale;
|
|
199
|
+
preciseBuffer[j] = value;
|
|
200
|
+
}
|
|
201
|
+
attributeBuffers[pointAttribute.name] = {
|
|
202
|
+
buffer: buff,
|
|
203
|
+
preciseBuffer,
|
|
204
|
+
attribute: pointAttribute,
|
|
205
|
+
offset,
|
|
206
|
+
scale
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
const occupancy = parseInt(numPoints / numOccupiedCells, 10);
|
|
211
|
+
{
|
|
212
|
+
// add indices
|
|
213
|
+
const buff = new ArrayBuffer(numPoints * 4);
|
|
214
|
+
const indices = new Uint32Array(buff);
|
|
215
|
+
for (let i = 0; i < numPoints; i++) {
|
|
216
|
+
indices[i] = i;
|
|
217
|
+
}
|
|
218
|
+
attributeBuffers.INDICES = {
|
|
219
|
+
buffer: buff,
|
|
220
|
+
attribute: PointAttribute.INDICES
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
{
|
|
224
|
+
// handle attribute vectors
|
|
225
|
+
const vectors = pointAttributes.vectors;
|
|
226
|
+
for (const vector of vectors) {
|
|
227
|
+
const {
|
|
228
|
+
name,
|
|
229
|
+
attributes
|
|
230
|
+
} = vector;
|
|
231
|
+
const numVectorElements = attributes.length;
|
|
232
|
+
const buffer = new ArrayBuffer(numVectorElements * numPoints * 4);
|
|
233
|
+
const f32 = new Float32Array(buffer);
|
|
234
|
+
let iElement = 0;
|
|
235
|
+
for (const sourceName of attributes) {
|
|
236
|
+
const sourceBuffer = attributeBuffers[sourceName];
|
|
237
|
+
const {
|
|
238
|
+
offset,
|
|
239
|
+
scale
|
|
240
|
+
} = sourceBuffer;
|
|
241
|
+
const view = new DataView(sourceBuffer.buffer);
|
|
242
|
+
const getter = view.getFloat32.bind(view);
|
|
243
|
+
for (let j = 0; j < numPoints; j++) {
|
|
244
|
+
const value = getter(j * 4, true);
|
|
245
|
+
f32[j * numVectorElements + iElement] = value / scale + offset;
|
|
246
|
+
}
|
|
247
|
+
iElement++;
|
|
248
|
+
}
|
|
249
|
+
const vecAttribute = new PointAttribute(name, PointAttributeTypes.DATA_TYPE_FLOAT, 3);
|
|
250
|
+
attributeBuffers[name] = {
|
|
251
|
+
buffer,
|
|
252
|
+
attribute: vecAttribute
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return {
|
|
257
|
+
buffer,
|
|
258
|
+
attributeBuffers,
|
|
259
|
+
density: occupancy
|
|
260
|
+
};
|
|
261
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/*
|
|
2
|
+
============
|
|
3
|
+
== POTREE ==
|
|
4
|
+
============
|
|
5
|
+
|
|
6
|
+
http://potree.org
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2011-2020, Markus Schütz
|
|
9
|
+
All rights reserved.
|
|
10
|
+
|
|
11
|
+
Redistribution and use in source and binary forms, with or without
|
|
12
|
+
modification, are permitted provided that the following conditions are met:
|
|
13
|
+
|
|
14
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
15
|
+
list of conditions and the following disclaimer.
|
|
16
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
17
|
+
this list of conditions and the following disclaimer in the documentation
|
|
18
|
+
and/or other materials provided with the distribution.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
21
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
22
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
24
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
25
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
26
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
27
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
28
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
29
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
30
|
+
|
|
31
|
+
The views and conclusions contained in the software and documentation are those
|
|
32
|
+
of the authors and should not be interpreted as representing official policies,
|
|
33
|
+
either expressed or implied, of the FreeBSD Project.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
import { PointAttribute, PointAttributeTypes } from "../Core/Potree2PointAttributes.js";
|
|
37
|
+
const typedArrayMapping = {
|
|
38
|
+
int8: Int8Array,
|
|
39
|
+
int16: Int16Array,
|
|
40
|
+
int32: Int32Array,
|
|
41
|
+
int64: Float64Array,
|
|
42
|
+
uint8: Uint8Array,
|
|
43
|
+
uint16: Uint16Array,
|
|
44
|
+
uint32: Uint32Array,
|
|
45
|
+
uint64: Float64Array,
|
|
46
|
+
float: Float32Array,
|
|
47
|
+
double: Float64Array
|
|
48
|
+
};
|
|
49
|
+
export default function load(buffer, options) {
|
|
50
|
+
const {
|
|
51
|
+
pointAttributes,
|
|
52
|
+
scale,
|
|
53
|
+
min,
|
|
54
|
+
size,
|
|
55
|
+
offset,
|
|
56
|
+
numPoints
|
|
57
|
+
} = options;
|
|
58
|
+
const view = new DataView(buffer);
|
|
59
|
+
const attributeBuffers = {};
|
|
60
|
+
let attributeOffset = 0;
|
|
61
|
+
let bytesPerPoint = 0;
|
|
62
|
+
for (const pointAttribute of pointAttributes.attributes) {
|
|
63
|
+
bytesPerPoint += pointAttribute.byteSize;
|
|
64
|
+
}
|
|
65
|
+
const gridSize = 32;
|
|
66
|
+
const grid = new Uint32Array(gridSize ** 3);
|
|
67
|
+
const toIndex = (x, y, z) => {
|
|
68
|
+
// min is already subtracted
|
|
69
|
+
const dx = gridSize * x / size.x;
|
|
70
|
+
const dy = gridSize * y / size.y;
|
|
71
|
+
const dz = gridSize * z / size.z;
|
|
72
|
+
const ix = Math.min(parseInt(dx, 10), gridSize - 1);
|
|
73
|
+
const iy = Math.min(parseInt(dy, 10), gridSize - 1);
|
|
74
|
+
const iz = Math.min(parseInt(dz, 10), gridSize - 1);
|
|
75
|
+
return ix + iy * gridSize + iz * gridSize * gridSize;
|
|
76
|
+
};
|
|
77
|
+
let numOccupiedCells = 0;
|
|
78
|
+
for (const pointAttribute of pointAttributes.attributes) {
|
|
79
|
+
if (['POSITION_CARTESIAN', 'position'].includes(pointAttribute.name)) {
|
|
80
|
+
const buff = new ArrayBuffer(numPoints * 4 * 3);
|
|
81
|
+
const positions = new Float32Array(buff);
|
|
82
|
+
for (let j = 0; j < numPoints; j++) {
|
|
83
|
+
const pointOffset = j * bytesPerPoint;
|
|
84
|
+
const x = view.getInt32(pointOffset + attributeOffset + 0, true) * scale[0] + offset[0] - min.x;
|
|
85
|
+
const y = view.getInt32(pointOffset + attributeOffset + 4, true) * scale[1] + offset[1] - min.y;
|
|
86
|
+
const z = view.getInt32(pointOffset + attributeOffset + 8, true) * scale[2] + offset[2] - min.z;
|
|
87
|
+
const index = toIndex(x, y, z);
|
|
88
|
+
const count = grid[index]++;
|
|
89
|
+
if (count === 0) {
|
|
90
|
+
numOccupiedCells++;
|
|
91
|
+
}
|
|
92
|
+
positions[3 * j + 0] = x;
|
|
93
|
+
positions[3 * j + 1] = y;
|
|
94
|
+
positions[3 * j + 2] = z;
|
|
95
|
+
}
|
|
96
|
+
attributeBuffers[pointAttribute.name] = {
|
|
97
|
+
buffer: buff,
|
|
98
|
+
attribute: pointAttribute
|
|
99
|
+
};
|
|
100
|
+
} else if (['RGBA', 'rgba'].includes(pointAttribute.name)) {
|
|
101
|
+
const buff = new ArrayBuffer(numPoints * 4);
|
|
102
|
+
const colors = new Uint8Array(buff);
|
|
103
|
+
for (let j = 0; j < numPoints; j++) {
|
|
104
|
+
const pointOffset = j * bytesPerPoint;
|
|
105
|
+
const r = view.getUint16(pointOffset + attributeOffset + 0, true);
|
|
106
|
+
const g = view.getUint16(pointOffset + attributeOffset + 2, true);
|
|
107
|
+
const b = view.getUint16(pointOffset + attributeOffset + 4, true);
|
|
108
|
+
colors[4 * j + 0] = r > 255 ? r / 256 : r;
|
|
109
|
+
colors[4 * j + 1] = g > 255 ? g / 256 : g;
|
|
110
|
+
colors[4 * j + 2] = b > 255 ? b / 256 : b;
|
|
111
|
+
}
|
|
112
|
+
attributeBuffers[pointAttribute.name] = {
|
|
113
|
+
buffer: buff,
|
|
114
|
+
attribute: pointAttribute
|
|
115
|
+
};
|
|
116
|
+
} else {
|
|
117
|
+
const buff = new ArrayBuffer(numPoints * 4);
|
|
118
|
+
const f32 = new Float32Array(buff);
|
|
119
|
+
const TypedArray = typedArrayMapping[pointAttribute.type.name];
|
|
120
|
+
const preciseBuffer = new TypedArray(numPoints);
|
|
121
|
+
let [offset, scale] = [0, 1];
|
|
122
|
+
const getterMap = {
|
|
123
|
+
int8: view.getInt8,
|
|
124
|
+
int16: view.getInt16,
|
|
125
|
+
int32: view.getInt32,
|
|
126
|
+
uint8: view.getUint8,
|
|
127
|
+
uint16: view.getUint16,
|
|
128
|
+
uint32: view.getUint32,
|
|
129
|
+
float: view.getFloat32,
|
|
130
|
+
double: view.getFloat64
|
|
131
|
+
};
|
|
132
|
+
const getter = getterMap[pointAttribute.type.name].bind(view);
|
|
133
|
+
|
|
134
|
+
// compute offset and scale to pack larger types into 32 bit floats
|
|
135
|
+
if (pointAttribute.type.size > 4) {
|
|
136
|
+
const [amin, amax] = pointAttribute.range;
|
|
137
|
+
offset = amin;
|
|
138
|
+
scale = 1 / (amax - amin);
|
|
139
|
+
}
|
|
140
|
+
for (let j = 0; j < numPoints; j++) {
|
|
141
|
+
const pointOffset = j * bytesPerPoint;
|
|
142
|
+
const value = getter(pointOffset + attributeOffset, true);
|
|
143
|
+
f32[j] = (value - offset) * scale;
|
|
144
|
+
preciseBuffer[j] = value;
|
|
145
|
+
}
|
|
146
|
+
attributeBuffers[pointAttribute.name] = {
|
|
147
|
+
buffer: buff,
|
|
148
|
+
preciseBuffer,
|
|
149
|
+
attribute: pointAttribute,
|
|
150
|
+
offset,
|
|
151
|
+
scale
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
attributeOffset += pointAttribute.byteSize;
|
|
155
|
+
}
|
|
156
|
+
const occupancy = parseInt(numPoints / numOccupiedCells, 10);
|
|
157
|
+
{
|
|
158
|
+
// add indices
|
|
159
|
+
const buff = new ArrayBuffer(numPoints * 4);
|
|
160
|
+
const indices = new Uint32Array(buff);
|
|
161
|
+
for (let i = 0; i < numPoints; i++) {
|
|
162
|
+
indices[i] = i;
|
|
163
|
+
}
|
|
164
|
+
attributeBuffers.INDICES = {
|
|
165
|
+
buffer: buff,
|
|
166
|
+
attribute: PointAttribute.INDICES
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
{
|
|
170
|
+
// handle attribute vectors
|
|
171
|
+
const vectors = pointAttributes.vectors;
|
|
172
|
+
for (const vector of vectors) {
|
|
173
|
+
const {
|
|
174
|
+
name,
|
|
175
|
+
attributes
|
|
176
|
+
} = vector;
|
|
177
|
+
const numVectorElements = attributes.length;
|
|
178
|
+
const buffer = new ArrayBuffer(numVectorElements * numPoints * 4);
|
|
179
|
+
const f32 = new Float32Array(buffer);
|
|
180
|
+
let iElement = 0;
|
|
181
|
+
for (const sourceName of attributes) {
|
|
182
|
+
const sourceBuffer = attributeBuffers[sourceName];
|
|
183
|
+
const {
|
|
184
|
+
offset,
|
|
185
|
+
scale
|
|
186
|
+
} = sourceBuffer;
|
|
187
|
+
const view = new DataView(sourceBuffer.buffer);
|
|
188
|
+
const getter = view.getFloat32.bind(view);
|
|
189
|
+
for (let j = 0; j < numPoints; j++) {
|
|
190
|
+
const value = getter(j * 4, true);
|
|
191
|
+
f32[j * numVectorElements + iElement] = value / scale + offset;
|
|
192
|
+
}
|
|
193
|
+
iElement++;
|
|
194
|
+
}
|
|
195
|
+
const vecAttribute = new PointAttribute(name, PointAttributeTypes.DATA_TYPE_FLOAT, 3);
|
|
196
|
+
attributeBuffers[name] = {
|
|
197
|
+
buffer,
|
|
198
|
+
attribute: vecAttribute
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return {
|
|
203
|
+
buffer,
|
|
204
|
+
attributeBuffers,
|
|
205
|
+
density: occupancy
|
|
206
|
+
};
|
|
207
|
+
}
|
package/lib/Main.js
CHANGED
|
@@ -51,6 +51,7 @@ export { default as GeometryLayer } from "./Layer/GeometryLayer.js";
|
|
|
51
51
|
export { default as FeatureGeometryLayer } from "./Layer/FeatureGeometryLayer.js";
|
|
52
52
|
export { default as PointCloudLayer } from "./Layer/PointCloudLayer.js";
|
|
53
53
|
export { default as PotreeLayer } from "./Layer/PotreeLayer.js";
|
|
54
|
+
export { default as Potree2Layer } from "./Layer/Potree2Layer.js";
|
|
54
55
|
export { default as C3DTilesLayer, C3DTILES_LAYER_EVENTS } from "./Layer/C3DTilesLayer.js";
|
|
55
56
|
export { default as TiledGeometryLayer } from "./Layer/TiledGeometryLayer.js";
|
|
56
57
|
export { default as OrientedImageLayer } from "./Layer/OrientedImageLayer.js";
|
|
@@ -75,6 +76,7 @@ export { default as WMTSSource } from "./Source/WMTSSource.js";
|
|
|
75
76
|
export { default as VectorTilesSource } from "./Source/VectorTilesSource.js";
|
|
76
77
|
export { default as OrientedImageSource } from "./Source/OrientedImageSource.js";
|
|
77
78
|
export { default as PotreeSource } from "./Source/PotreeSource.js";
|
|
79
|
+
export { default as Potree2Source } from "./Source/Potree2Source.js";
|
|
78
80
|
export { default as C3DTilesSource } from "./Source/C3DTilesSource.js";
|
|
79
81
|
export { default as C3DTilesIonSource } from "./Source/C3DTilesIonSource.js";
|
|
80
82
|
export { default as C3DTilesGoogleSource } from "./Source/C3DTilesGoogleSource.js";
|
package/lib/Parser/LASParser.js
CHANGED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { spawn, Thread, Transfer } from 'threads';
|
|
3
|
+
let _thread;
|
|
4
|
+
function workerInstance() {
|
|
5
|
+
return new Worker( /* webpackChunkName: "itowns_potree2worker" */
|
|
6
|
+
new URL('../Worker/Potree2Worker.js', import.meta.url), {
|
|
7
|
+
type: 'module'
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
async function loader() {
|
|
11
|
+
if (_thread) {
|
|
12
|
+
return _thread;
|
|
13
|
+
}
|
|
14
|
+
_thread = await spawn(workerInstance());
|
|
15
|
+
return _thread;
|
|
16
|
+
}
|
|
17
|
+
function decoder(w, metadata) {
|
|
18
|
+
return metadata.encoding === 'BROTLI' ? w.parseBrotli : w.parse;
|
|
19
|
+
}
|
|
20
|
+
export default {
|
|
21
|
+
/**
|
|
22
|
+
* @return {Promise<void>}
|
|
23
|
+
*/
|
|
24
|
+
terminate() {
|
|
25
|
+
const currentThread = _thread;
|
|
26
|
+
_thread = undefined;
|
|
27
|
+
return Thread.terminate(currentThread);
|
|
28
|
+
},
|
|
29
|
+
/** @module Potree2BinParser */
|
|
30
|
+
/** Parse .bin PotreeConverter 2.0 format and convert to a THREE.BufferGeometry
|
|
31
|
+
* @function parse
|
|
32
|
+
* @param {ArrayBuffer} buffer - the bin buffer.
|
|
33
|
+
* @param {Object} options
|
|
34
|
+
* @param {string[]} options.in.pointAttributes - the point attributes information contained in metadata.js
|
|
35
|
+
* @return {Promise} - a promise that resolves with a THREE.BufferGeometry.
|
|
36
|
+
*
|
|
37
|
+
*/
|
|
38
|
+
parse: async function (buffer, options) {
|
|
39
|
+
const metadata = options.in.source.metadata;
|
|
40
|
+
const layer = options.out;
|
|
41
|
+
const pointAttributes = layer.pointAttributes;
|
|
42
|
+
const scale = metadata.scale;
|
|
43
|
+
const box = options.in.bbox;
|
|
44
|
+
const min = box.min;
|
|
45
|
+
const size = box.max.clone().sub(box.min);
|
|
46
|
+
const max = box.max;
|
|
47
|
+
const offset = metadata.offset;
|
|
48
|
+
const numPoints = options.in.numPoints;
|
|
49
|
+
const potreeLoader = await loader();
|
|
50
|
+
const decode = decoder(potreeLoader, metadata);
|
|
51
|
+
const data = await decode(Transfer(buffer), {
|
|
52
|
+
pointAttributes,
|
|
53
|
+
scale,
|
|
54
|
+
min,
|
|
55
|
+
max,
|
|
56
|
+
size,
|
|
57
|
+
offset,
|
|
58
|
+
numPoints
|
|
59
|
+
});
|
|
60
|
+
const buffers = data.attributeBuffers;
|
|
61
|
+
const geometry = new THREE.BufferGeometry();
|
|
62
|
+
Object.keys(buffers).forEach(property => {
|
|
63
|
+
const buffer = buffers[property].buffer;
|
|
64
|
+
if (property === 'position') {
|
|
65
|
+
geometry.setAttribute('position', new THREE.BufferAttribute(new Float32Array(buffer), 3));
|
|
66
|
+
} else if (property === 'rgba') {
|
|
67
|
+
geometry.setAttribute('color', new THREE.BufferAttribute(new Uint8Array(buffer), 4, true));
|
|
68
|
+
} else if (property === 'NORMAL') {
|
|
69
|
+
geometry.setAttribute('normal', new THREE.BufferAttribute(new Float32Array(buffer), 3));
|
|
70
|
+
} else if (property === 'INDICES') {
|
|
71
|
+
const bufferAttribute = new THREE.BufferAttribute(new Uint8Array(buffer), 4);
|
|
72
|
+
bufferAttribute.normalized = true;
|
|
73
|
+
geometry.setAttribute('indices', bufferAttribute);
|
|
74
|
+
} else {
|
|
75
|
+
const bufferAttribute = new THREE.BufferAttribute(new Float32Array(buffer), 1);
|
|
76
|
+
const batchAttribute = buffers[property].attribute;
|
|
77
|
+
bufferAttribute.potree = {
|
|
78
|
+
offset: buffers[property].offset,
|
|
79
|
+
scale: buffers[property].scale,
|
|
80
|
+
preciseBuffer: buffers[property].preciseBuffer,
|
|
81
|
+
range: batchAttribute.range
|
|
82
|
+
};
|
|
83
|
+
geometry.setAttribute(property, bufferAttribute);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
geometry.computeBoundingBox();
|
|
87
|
+
return {
|
|
88
|
+
geometry,
|
|
89
|
+
density: data.density
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
/* babel-plugin-inline-import './Shader/PointsVS.glsl' */
|
|
3
|
-
const PointsVS = "#include <itowns/precision_qualifier>\n#if defined(USE_TEXTURES_PROJECTIVE)\n#include <itowns/projective_texturing_pars_vertex>\n#endif\n#include <common>\n#include <logdepthbuf_pars_vertex>\n\n#define NB_CLASS 8.\n\nuniform float size;\nuniform float scale;\n\nuniform bool picking;\nuniform int mode;\nuniform float opacity;\nuniform vec4 overlayColor;\n\nuniform vec2 elevationRange;\nuniform vec2 intensityRange;\nuniform vec2 angleRange;\n\nuniform sampler2D classificationTexture;\nuniform sampler2D discreteTexture;\nuniform sampler2D gradientTexture;\nuniform int sizeMode;\nuniform float minAttenuatedSize;\nuniform float maxAttenuatedSize;\n\nattribute vec3 color;\nattribute vec2 range;\nattribute vec4 unique_id;\nattribute float intensity;\nattribute float classification;\nattribute float pointSourceID;\n\nattribute float returnNumber;\nattribute float numberOfReturns;\nattribute float scanAngle;\n\n#if defined(NORMAL_OCT16)\nattribute vec2 oct16Normal;\n#elif defined(NORMAL_SPHEREMAPPED)\nattribute vec2 sphereMappedNormal;\n#endif\n\nvarying vec4 vColor;\n\n// see https://web.archive.org/web/20150303053317/http://lgdv.cs.fau.de/get/1602\n// and implementation in PotreeConverter (BINPointReader.cpp) and potree (BinaryDecoderWorker.js)\n#if defined(NORMAL_OCT16)\nvec3 decodeOct16Normal(vec2 encodedNormal) {\n vec2 nNorm = 2. * (encodedNormal / 255.) - 1.;\n vec3 n;\n n.z = 1. - abs(nNorm.x) - abs(nNorm.y);\n if (n.z >= 0.) {\n n.x = nNorm.x;\n n.y = nNorm.y;\n } else {\n n.x = sign(nNorm.x) - sign(nNorm.x) * sign(nNorm.y) * nNorm.y;\n n.y = sign(nNorm.y) - sign(nNorm.y) * sign(nNorm.x) * nNorm.x;\n }\n return normalize(n);\n}\n#elif defined(NORMAL_SPHEREMAPPED)\n// see http://aras-p.info/texts/CompactNormalStorage.html method #4\n// or see potree's implementation in BINPointReader.cpp\nvec3 decodeSphereMappedNormal(vec2 encodedNormal) {\n vec2 fenc = 2. * encodedNormal / 255. - 1.;\n float f = dot(fenc,fenc);\n float g = 2. * sqrt(1. - f);\n vec3 n;\n n.xy = fenc * g;\n n.z = 1. - 2. * f;\n return n;\n}\n#endif\n\nvoid main() {\n\n#if defined(NORMAL_OCT16)\n vec3 normal = decodeOct16Normal(oct16Normal);\n#elif defined(NORMAL_SPHEREMAPPED)\n vec3 normal = decodeSphereMappedNormal(sphereMappedNormal);\n#elif defined(NORMAL)\n // nothing to do\n#else\n // default to color\n vec3 normal = color;\n#endif\n\n if (picking) {\n vColor = unique_id;\n } else {\n vColor.a = 1.0;\n if (mode == PNTS_MODE_CLASSIFICATION) {\n vec2 uv = vec2(classification/255., 0.5);\n vColor = texture2D(classificationTexture, uv);\n } else if (mode == PNTS_MODE_NORMAL) {\n vColor.rgb = abs(normal);\n } else if (mode == PNTS_MODE_COLOR) {\n // default to color mode\n vColor.rgb = mix(color, overlayColor.rgb, overlayColor.a);\n } else if (mode == PNTS_MODE_RETURN_NUMBER) {\n vec2 uv = vec2(returnNumber/255., 0.5);\n vColor = texture2D(discreteTexture, uv);\n } else if (mode == PNTS_MODE_RETURN_TYPE) {\n float returnType;\n if (returnNumber > numberOfReturns) {\n returnType = 4.;\n } else if (returnNumber == 1.) {\n if (numberOfReturns == 1.) {\n // single\n returnType = 0.;\n } else {\n // first\n returnType = 1.;\n }\n } else {\n if (returnNumber == numberOfReturns) {\n // last\n returnType = 3.;\n } else {\n // intermediate\n returnType = 2.;\n }\n }\n vec2 uv = vec2(returnType/255., 0.5);\n vColor = texture2D(discreteTexture, uv);\n } else if (mode == PNTS_MODE_RETURN_COUNT) {\n vec2 uv = vec2(numberOfReturns/255., 0.5);\n vColor = texture2D(discreteTexture, uv);\n } else if (mode == PNTS_MODE_POINT_SOURCE_ID) {\n vec2 uv = vec2(mod(pointSourceID, NB_CLASS)/255., 0.5);\n vColor = texture2D(discreteTexture, uv);\n } else if (mode == PNTS_MODE_SCAN_ANGLE) {\n float i = (scanAngle - angleRange.x) / (angleRange.y - angleRange.x);\n vec2 uv = vec2(i, (1. - i));\n vColor = texture2D(gradientTexture, uv);\n } else if (mode == PNTS_MODE_INTENSITY) {\n float i = (intensity - intensityRange.x) / (intensityRange.y - intensityRange.x);\n vec2 uv = vec2(i, (1. - i));\n vColor = texture2D(gradientTexture, uv);\n } else if (mode == PNTS_MODE_ELEVATION) {\n float
|
|
3
|
+
const PointsVS = "#include <itowns/precision_qualifier>\n#if defined(USE_TEXTURES_PROJECTIVE)\n#include <itowns/projective_texturing_pars_vertex>\n#endif\n#include <common>\n#include <logdepthbuf_pars_vertex>\n\n#define NB_CLASS 8.\n\nuniform float size;\nuniform float scale;\n\nuniform bool picking;\nuniform int mode;\nuniform float opacity;\nuniform vec4 overlayColor;\n\nuniform vec2 elevationRange;\nuniform vec2 intensityRange;\nuniform vec2 angleRange;\n\nuniform sampler2D classificationTexture;\nuniform sampler2D discreteTexture;\nuniform sampler2D gradientTexture;\nuniform int sizeMode;\nuniform float minAttenuatedSize;\nuniform float maxAttenuatedSize;\n\nattribute vec3 color;\nattribute vec2 range;\nattribute vec4 unique_id;\nattribute float intensity;\nattribute float classification;\nattribute float pointSourceID;\n\nattribute float returnNumber;\nattribute float numberOfReturns;\nattribute float scanAngle;\n\n#if defined(NORMAL_OCT16)\nattribute vec2 oct16Normal;\n#elif defined(NORMAL_SPHEREMAPPED)\nattribute vec2 sphereMappedNormal;\n#endif\n\nvarying vec4 vColor;\n\n// see https://web.archive.org/web/20150303053317/http://lgdv.cs.fau.de/get/1602\n// and implementation in PotreeConverter (BINPointReader.cpp) and potree (BinaryDecoderWorker.js)\n#if defined(NORMAL_OCT16)\nvec3 decodeOct16Normal(vec2 encodedNormal) {\n vec2 nNorm = 2. * (encodedNormal / 255.) - 1.;\n vec3 n;\n n.z = 1. - abs(nNorm.x) - abs(nNorm.y);\n if (n.z >= 0.) {\n n.x = nNorm.x;\n n.y = nNorm.y;\n } else {\n n.x = sign(nNorm.x) - sign(nNorm.x) * sign(nNorm.y) * nNorm.y;\n n.y = sign(nNorm.y) - sign(nNorm.y) * sign(nNorm.x) * nNorm.x;\n }\n return normalize(n);\n}\n#elif defined(NORMAL_SPHEREMAPPED)\n// see http://aras-p.info/texts/CompactNormalStorage.html method #4\n// or see potree's implementation in BINPointReader.cpp\nvec3 decodeSphereMappedNormal(vec2 encodedNormal) {\n vec2 fenc = 2. * encodedNormal / 255. - 1.;\n float f = dot(fenc,fenc);\n float g = 2. * sqrt(1. - f);\n vec3 n;\n n.xy = fenc * g;\n n.z = 1. - 2. * f;\n return n;\n}\n#endif\n\nvoid main() {\n\n#if defined(NORMAL_OCT16)\n vec3 normal = decodeOct16Normal(oct16Normal);\n#elif defined(NORMAL_SPHEREMAPPED)\n vec3 normal = decodeSphereMappedNormal(sphereMappedNormal);\n#elif defined(NORMAL)\n // nothing to do\n#else\n // default to color\n vec3 normal = color;\n#endif\n\n if (picking) {\n vColor = unique_id;\n } else {\n vColor.a = 1.0;\n if (mode == PNTS_MODE_CLASSIFICATION) {\n vec2 uv = vec2(classification/255., 0.5);\n vColor = texture2D(classificationTexture, uv);\n } else if (mode == PNTS_MODE_NORMAL) {\n vColor.rgb = abs(normal);\n } else if (mode == PNTS_MODE_COLOR) {\n // default to color mode\n vColor.rgb = mix(color, overlayColor.rgb, overlayColor.a);\n } else if (mode == PNTS_MODE_RETURN_NUMBER) {\n vec2 uv = vec2(returnNumber/255., 0.5);\n vColor = texture2D(discreteTexture, uv);\n } else if (mode == PNTS_MODE_RETURN_TYPE) {\n float returnType;\n if (returnNumber > numberOfReturns) {\n returnType = 4.;\n } else if (returnNumber == 1.) {\n if (numberOfReturns == 1.) {\n // single\n returnType = 0.;\n } else {\n // first\n returnType = 1.;\n }\n } else {\n if (returnNumber == numberOfReturns) {\n // last\n returnType = 3.;\n } else {\n // intermediate\n returnType = 2.;\n }\n }\n vec2 uv = vec2(returnType/255., 0.5);\n vColor = texture2D(discreteTexture, uv);\n } else if (mode == PNTS_MODE_RETURN_COUNT) {\n vec2 uv = vec2(numberOfReturns/255., 0.5);\n vColor = texture2D(discreteTexture, uv);\n } else if (mode == PNTS_MODE_POINT_SOURCE_ID) {\n vec2 uv = vec2(mod(pointSourceID, NB_CLASS)/255., 0.5);\n vColor = texture2D(discreteTexture, uv);\n } else if (mode == PNTS_MODE_SCAN_ANGLE) {\n float i = (scanAngle - angleRange.x) / (angleRange.y - angleRange.x);\n vec2 uv = vec2(i, (1. - i));\n vColor = texture2D(gradientTexture, uv);\n } else if (mode == PNTS_MODE_INTENSITY) {\n float i = (intensity - intensityRange.x) / (intensityRange.y - intensityRange.x);\n vec2 uv = vec2(i, (1. - i));\n vColor = texture2D(gradientTexture, uv);\n } else if (mode == PNTS_MODE_ELEVATION) {\n float z = (modelMatrix * vec4(position, 1.0)).z;\n float i = (z - elevationRange.x) / (elevationRange.y - elevationRange.x);\n vec2 uv = vec2(i, (1. - i));\n vColor = texture2D(gradientTexture, uv);\n }\n\n vColor.a *= opacity;\n }\n\n #include <begin_vertex>\n #include <project_vertex>\n\n gl_PointSize = size;\n\n if (sizeMode == PNTS_SIZE_MODE_ATTENUATED) {\n bool isPerspective = isPerspectiveMatrix(projectionMatrix);\n\n if (isPerspective) {\n gl_PointSize *= scale / -mvPosition.z;\n gl_PointSize = clamp(gl_PointSize, minAttenuatedSize, maxAttenuatedSize);\n }\n }\n\n#if defined(USE_TEXTURES_PROJECTIVE)\n #include <itowns/projective_texturing_vertex>\n#endif\n #include <logdepthbuf_vertex>\n}\n";
|
|
4
4
|
/* babel-plugin-inline-import './Shader/PointsFS.glsl' */
|
|
5
5
|
const PointsFS = "#include <itowns/precision_qualifier>\n#include <logdepthbuf_pars_fragment>\n#if defined(USE_TEXTURES_PROJECTIVE)\n#include <itowns/projective_texturing_pars_fragment>\n#endif\n\nvarying vec4 vColor;\nuniform bool picking;\nuniform int shape;\n\nvoid main() {\n #include <logdepthbuf_fragment>\n //square shape does not require any change.\n if (shape == PNTS_SHAPE_CIRCLE) {\n //circular rendering in glsl\n if ((length(gl_PointCoord - 0.5) > 0.5) || (vColor.a == 0.0)) {\n discard;\n }\n }\n\n#if defined(USE_TEXTURES_PROJECTIVE)\n vec4 color = vColor;\n if (!picking) {\n #pragma unroll_loop\n for (int i = 0; i < ORIENTED_IMAGES_COUNT; i++) {\n color = projectiveTextureColor(projectiveTextureCoords[ ORIENTED_IMAGES_COUNT - 1 - i ], projectiveTextureDistortion[ ORIENTED_IMAGES_COUNT - 1 - i ], projectiveTexture[ ORIENTED_IMAGES_COUNT - 1 - i ], mask[ORIENTED_IMAGES_COUNT - 1 - i], color);\n }\n gl_FragColor = vec4(color.rgb, color.a * opacity);\n } else {\n gl_FragColor = color;\n }\n#else\n gl_FragColor = vColor;\n#endif\n}\n";
|
|
6
6
|
import ShaderUtils from "./Shader/ShaderUtils.js";
|
package/lib/Source/FileSource.js
CHANGED
|
@@ -130,7 +130,7 @@ class FileSource extends Source {
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
// the fake url is for when we use the fetchedData or features mode
|
|
133
|
-
source.url = source.url || '
|
|
133
|
+
source.url = source.url || 'none';
|
|
134
134
|
super(source);
|
|
135
135
|
this.isFileSource = true;
|
|
136
136
|
this.fetchedData = source.fetchedData;
|