itowns 2.45.1-next.0 → 2.45.1-next.1

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.
Files changed (185) hide show
  1. package/dist/455.js +2 -0
  2. package/dist/455.js.map +1 -0
  3. package/dist/debug.js +3 -0
  4. package/dist/debug.js.LICENSE.txt +13 -0
  5. package/dist/debug.js.map +1 -0
  6. package/dist/itowns.js +3 -0
  7. package/dist/itowns.js.LICENSE.txt +5 -0
  8. package/dist/itowns.js.map +1 -0
  9. package/dist/itowns_lasparser.js +2 -0
  10. package/dist/itowns_lasparser.js.map +1 -0
  11. package/dist/itowns_lasworker.js +2 -0
  12. package/dist/itowns_lasworker.js.map +1 -0
  13. package/dist/itowns_potree2worker.js +2 -0
  14. package/dist/itowns_potree2worker.js.map +1 -0
  15. package/dist/itowns_widgets.js +2 -0
  16. package/dist/itowns_widgets.js.map +1 -0
  17. package/lib/Controls/FirstPersonControls.js +308 -0
  18. package/lib/Controls/FlyControls.js +175 -0
  19. package/lib/Controls/GlobeControls.js +1178 -0
  20. package/lib/Controls/PlanarControls.js +1025 -0
  21. package/lib/Controls/StateControl.js +432 -0
  22. package/lib/Controls/StreetControls.js +392 -0
  23. package/lib/Converter/Feature2Mesh.js +612 -0
  24. package/lib/Converter/Feature2Texture.js +174 -0
  25. package/lib/Converter/convertToTile.js +70 -0
  26. package/lib/Converter/textureConverter.js +43 -0
  27. package/lib/Core/3DTiles/C3DTBatchTable.js +131 -0
  28. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +96 -0
  29. package/lib/Core/3DTiles/C3DTBoundingVolume.js +156 -0
  30. package/lib/Core/3DTiles/C3DTExtensions.js +97 -0
  31. package/lib/Core/3DTiles/C3DTFeature.js +110 -0
  32. package/lib/Core/3DTiles/C3DTilesEnums.js +20 -0
  33. package/lib/Core/3DTiles/C3DTileset.js +99 -0
  34. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +100 -0
  35. package/lib/Core/AnimationPlayer.js +142 -0
  36. package/lib/Core/CopcNode.js +174 -0
  37. package/lib/Core/Deprecated/Undeprecator.js +74 -0
  38. package/lib/Core/EntwinePointTileNode.js +126 -0
  39. package/lib/Core/Feature.js +488 -0
  40. package/lib/Core/Geographic/GeoidGrid.js +108 -0
  41. package/lib/Core/Label.js +222 -0
  42. package/lib/Core/MainLoop.js +209 -0
  43. package/lib/Core/Picking.js +255 -0
  44. package/lib/Core/PointCloudNode.js +42 -0
  45. package/lib/Core/Potree2Node.js +206 -0
  46. package/lib/Core/Potree2PointAttributes.js +139 -0
  47. package/lib/Core/PotreeNode.js +101 -0
  48. package/lib/Core/Prefab/Globe/Atmosphere.js +293 -0
  49. package/lib/Core/Prefab/Globe/GlobeLayer.js +152 -0
  50. package/lib/Core/Prefab/Globe/GlobeTileBuilder.js +110 -0
  51. package/lib/Core/Prefab/Globe/SkyShader.js +78 -0
  52. package/lib/Core/Prefab/GlobeView.js +155 -0
  53. package/lib/Core/Prefab/Planar/PlanarLayer.js +59 -0
  54. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +71 -0
  55. package/lib/Core/Prefab/PlanarView.js +62 -0
  56. package/lib/Core/Prefab/TileBuilder.js +82 -0
  57. package/lib/Core/Prefab/computeBufferTileGeometry.js +248 -0
  58. package/lib/Core/Scheduler/Cache.js +17 -0
  59. package/lib/Core/Scheduler/CancelledCommandException.js +15 -0
  60. package/lib/Core/Scheduler/Scheduler.js +294 -0
  61. package/lib/Core/Style.js +660 -0
  62. package/lib/Core/StyleOptions.js +486 -0
  63. package/lib/Core/System/Capabilities.js +63 -0
  64. package/lib/Core/Tile/Tile.js +205 -0
  65. package/lib/Core/Tile/TileGrid.js +49 -0
  66. package/lib/Core/TileGeometry.js +124 -0
  67. package/lib/Core/TileMesh.js +108 -0
  68. package/lib/Core/View.js +1115 -0
  69. package/lib/Layer/C3DTilesLayer.js +459 -0
  70. package/lib/Layer/ColorLayer.js +154 -0
  71. package/lib/Layer/CopcLayer.js +63 -0
  72. package/lib/Layer/ElevationLayer.js +139 -0
  73. package/lib/Layer/EntwinePointTileLayer.js +71 -0
  74. package/lib/Layer/FeatureGeometryLayer.js +77 -0
  75. package/lib/Layer/GeoidLayer.js +80 -0
  76. package/lib/Layer/GeometryLayer.js +233 -0
  77. package/lib/Layer/InfoLayer.js +64 -0
  78. package/lib/Layer/LabelLayer.js +469 -0
  79. package/lib/Layer/Layer.js +335 -0
  80. package/lib/Layer/LayerUpdateState.js +89 -0
  81. package/lib/Layer/LayerUpdateStrategy.js +80 -0
  82. package/lib/Layer/OGC3DTilesLayer.js +543 -0
  83. package/lib/Layer/OrientedImageLayer.js +227 -0
  84. package/lib/Layer/PointCloudLayer.js +405 -0
  85. package/lib/Layer/Potree2Layer.js +171 -0
  86. package/lib/Layer/PotreeLayer.js +72 -0
  87. package/lib/Layer/RasterLayer.js +37 -0
  88. package/lib/Layer/ReferencingLayerProperties.js +62 -0
  89. package/lib/Layer/TiledGeometryLayer.js +459 -0
  90. package/lib/Loader/LASLoader.js +193 -0
  91. package/lib/Loader/Potree2BrotliLoader.js +261 -0
  92. package/lib/Loader/Potree2Loader.js +207 -0
  93. package/lib/Main.js +113 -0
  94. package/lib/MainBundle.js +4 -0
  95. package/lib/Parser/B3dmParser.js +174 -0
  96. package/lib/Parser/CameraCalibrationParser.js +94 -0
  97. package/lib/Parser/GDFParser.js +72 -0
  98. package/lib/Parser/GTXParser.js +75 -0
  99. package/lib/Parser/GeoJsonParser.js +212 -0
  100. package/lib/Parser/GpxParser.js +25 -0
  101. package/lib/Parser/ISGParser.js +71 -0
  102. package/lib/Parser/KMLParser.js +25 -0
  103. package/lib/Parser/LASParser.js +137 -0
  104. package/lib/Parser/MapBoxUrlParser.js +83 -0
  105. package/lib/Parser/PntsParser.js +131 -0
  106. package/lib/Parser/Potree2BinParser.js +92 -0
  107. package/lib/Parser/PotreeBinParser.js +106 -0
  108. package/lib/Parser/PotreeCinParser.js +29 -0
  109. package/lib/Parser/ShapefileParser.js +78 -0
  110. package/lib/Parser/VectorTileParser.js +215 -0
  111. package/lib/Parser/XbilParser.js +120 -0
  112. package/lib/Parser/deprecated/LegacyGLTFLoader.js +1386 -0
  113. package/lib/Parser/iGLTFLoader.js +168 -0
  114. package/lib/Process/3dTilesProcessing.js +304 -0
  115. package/lib/Process/FeatureProcessing.js +76 -0
  116. package/lib/Process/LayeredMaterialNodeProcessing.js +229 -0
  117. package/lib/Process/ObjectRemovalHelper.js +97 -0
  118. package/lib/Process/handlerNodeError.js +23 -0
  119. package/lib/Provider/3dTilesProvider.js +149 -0
  120. package/lib/Provider/DataSourceProvider.js +24 -0
  121. package/lib/Provider/Fetcher.js +233 -0
  122. package/lib/Provider/PointCloudProvider.js +45 -0
  123. package/lib/Provider/TileProvider.js +16 -0
  124. package/lib/Provider/URLBuilder.js +116 -0
  125. package/lib/Renderer/Camera.js +281 -0
  126. package/lib/Renderer/Color.js +56 -0
  127. package/lib/Renderer/ColorLayersOrdering.js +115 -0
  128. package/lib/Renderer/CommonMaterial.js +31 -0
  129. package/lib/Renderer/Label2DRenderer.js +192 -0
  130. package/lib/Renderer/LayeredMaterial.js +243 -0
  131. package/lib/Renderer/OBB.js +150 -0
  132. package/lib/Renderer/OrientedImageCamera.js +118 -0
  133. package/lib/Renderer/OrientedImageMaterial.js +167 -0
  134. package/lib/Renderer/PointsMaterial.js +485 -0
  135. package/lib/Renderer/RasterTile.js +243 -0
  136. package/lib/Renderer/RenderMode.js +31 -0
  137. package/lib/Renderer/Shader/ShaderChunk.js +160 -0
  138. package/lib/Renderer/Shader/ShaderUtils.js +47 -0
  139. package/lib/Renderer/SphereHelper.js +17 -0
  140. package/lib/Renderer/WebXR.js +51 -0
  141. package/lib/Renderer/c3DEngine.js +214 -0
  142. package/lib/Source/C3DTilesGoogleSource.js +74 -0
  143. package/lib/Source/C3DTilesIonSource.js +54 -0
  144. package/lib/Source/C3DTilesSource.js +30 -0
  145. package/lib/Source/CopcSource.js +126 -0
  146. package/lib/Source/EntwinePointTileSource.js +72 -0
  147. package/lib/Source/FileSource.js +188 -0
  148. package/lib/Source/OGC3DTilesGoogleSource.js +29 -0
  149. package/lib/Source/OGC3DTilesIonSource.js +34 -0
  150. package/lib/Source/OGC3DTilesSource.js +21 -0
  151. package/lib/Source/OrientedImageSource.js +59 -0
  152. package/lib/Source/Potree2Source.js +167 -0
  153. package/lib/Source/PotreeSource.js +82 -0
  154. package/lib/Source/Source.js +202 -0
  155. package/lib/Source/TMSSource.js +144 -0
  156. package/lib/Source/VectorTilesSource.js +182 -0
  157. package/lib/Source/WFSSource.js +170 -0
  158. package/lib/Source/WMSSource.js +167 -0
  159. package/lib/Source/WMTSSource.js +92 -0
  160. package/lib/ThreeExtended/capabilities/WebGL.js +69 -0
  161. package/lib/ThreeExtended/libs/ktx-parse.module.js +506 -0
  162. package/lib/ThreeExtended/libs/zstddec.module.js +29 -0
  163. package/lib/ThreeExtended/loaders/DDSLoader.js +200 -0
  164. package/lib/ThreeExtended/loaders/DRACOLoader.js +400 -0
  165. package/lib/ThreeExtended/loaders/GLTFLoader.js +2879 -0
  166. package/lib/ThreeExtended/loaders/KTX2Loader.js +709 -0
  167. package/lib/ThreeExtended/math/ColorSpaces.js +59 -0
  168. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +846 -0
  169. package/lib/ThreeExtended/utils/WorkerPool.js +70 -0
  170. package/lib/Utils/CameraUtils.js +554 -0
  171. package/lib/Utils/DEMUtils.js +350 -0
  172. package/lib/Utils/FeaturesUtils.js +156 -0
  173. package/lib/Utils/Gradients.js +16 -0
  174. package/lib/Utils/ThreeUtils.js +115 -0
  175. package/lib/Utils/gui/C3DTilesStyle.js +218 -0
  176. package/lib/Utils/gui/Main.js +7 -0
  177. package/lib/Utils/gui/Minimap.js +152 -0
  178. package/lib/Utils/gui/Navigation.js +245 -0
  179. package/lib/Utils/gui/Scale.js +104 -0
  180. package/lib/Utils/gui/Searchbar.js +234 -0
  181. package/lib/Utils/gui/Widget.js +80 -0
  182. package/lib/Utils/placeObjectOnGround.js +136 -0
  183. package/lib/Worker/LASLoaderWorker.js +19 -0
  184. package/lib/Worker/Potree2Worker.js +21 -0
  185. package/package.json +2 -2
@@ -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 ADDED
@@ -0,0 +1,113 @@
1
+ const conf = {
2
+ version: '2.45.0'
3
+ };
4
+ export const REVISION = conf.version;
5
+
6
+ // Geographic tools
7
+ export { Coordinates, Extent, CRS, Ellipsoid, ellipsoidSizes, OrientationUtils } from '@itowns/geographic';
8
+ export { default as GeoidGrid } from "./Core/Geographic/GeoidGrid.js";
9
+ export { default as GlobeView, GLOBE_VIEW_EVENTS } from "./Core/Prefab/GlobeView.js";
10
+ export { default as PlanarView } from "./Core/Prefab/PlanarView.js";
11
+ export { default as Fetcher } from "./Provider/Fetcher.js";
12
+ export { MAIN_LOOP_EVENTS } from "./Core/MainLoop.js";
13
+ export { default as View } from "./Core/View.js";
14
+ export { VIEW_EVENTS } from "./Core/View.js";
15
+ export { default as FeatureProcessing } from "./Process/FeatureProcessing.js";
16
+ export { default as ObjectRemovalHelper } from "./Process/ObjectRemovalHelper.js";
17
+ export { updateLayeredMaterialNodeImagery, updateLayeredMaterialNodeElevation } from "./Process/LayeredMaterialNodeProcessing.js";
18
+ export { default as OrientedImageCamera } from "./Renderer/OrientedImageCamera.js";
19
+ export { default as PointsMaterial, PNTS_MODE, PNTS_SHAPE, PNTS_SIZE_MODE, ClassificationScheme } from "./Renderer/PointsMaterial.js";
20
+ export { default as GlobeControls } from "./Controls/GlobeControls.js";
21
+ export { default as FlyControls } from "./Controls/FlyControls.js";
22
+ export { default as FirstPersonControls } from "./Controls/FirstPersonControls.js";
23
+ export { default as StreetControls } from "./Controls/StreetControls.js";
24
+ export { default as PlanarControls } from "./Controls/PlanarControls.js";
25
+ export { CONTROL_EVENTS } from "./Controls/GlobeControls.js";
26
+ export { PLANAR_CONTROL_EVENT } from "./Controls/PlanarControls.js";
27
+ export { default as Feature2Mesh } from "./Converter/Feature2Mesh.js";
28
+ export { default as FeaturesUtils } from "./Utils/FeaturesUtils.js";
29
+ export { default as DEMUtils } from "./Utils/DEMUtils.js";
30
+ export { default as CameraUtils } from "./Utils/CameraUtils.js";
31
+ export { default as ShaderChunk } from "./Renderer/Shader/ShaderChunk.js";
32
+ export { getMaxColorSamplerUnitsCount, colorLayerEffects } from "./Renderer/LayeredMaterial.js";
33
+ export { default as Capabilities } from "./Core/System/Capabilities.js";
34
+ export { CAMERA_TYPE } from "./Renderer/Camera.js";
35
+ export { default as OBB } from "./Renderer/OBB.js";
36
+
37
+ // Internal itowns format
38
+ export { default as Feature, FeatureCollection, FeatureGeometry, FEATURE_TYPES } from "./Core/Feature.js";
39
+ export { default as Style } from "./Core/Style.js";
40
+ export { default as Label } from "./Core/Label.js";
41
+
42
+ // Layers provided by default in iTowns
43
+ // A custom layer should at least implements Layer
44
+ // See http://www.itowns-project.org/itowns/docs/#api/Layer/Layer
45
+ export { default as Layer, ImageryLayers } from "./Layer/Layer.js";
46
+ export { default as ColorLayer } from "./Layer/ColorLayer.js";
47
+ export { default as ElevationLayer } from "./Layer/ElevationLayer.js";
48
+ export { default as GeometryLayer } from "./Layer/GeometryLayer.js";
49
+ export { default as FeatureGeometryLayer } from "./Layer/FeatureGeometryLayer.js";
50
+ export { default as PointCloudLayer } from "./Layer/PointCloudLayer.js";
51
+ export { default as PotreeLayer } from "./Layer/PotreeLayer.js";
52
+ export { default as Potree2Layer } from "./Layer/Potree2Layer.js";
53
+ export { default as C3DTilesLayer, C3DTILES_LAYER_EVENTS } from "./Layer/C3DTilesLayer.js";
54
+ export { default as OGC3DTilesLayer, OGC3DTILES_LAYER_EVENTS, enableDracoLoader, enableKtx2Loader, enableMeshoptDecoder } from "./Layer/OGC3DTilesLayer.js";
55
+ export { default as TiledGeometryLayer } from "./Layer/TiledGeometryLayer.js";
56
+ export { default as OrientedImageLayer } from "./Layer/OrientedImageLayer.js";
57
+ export { STRATEGY_MIN_NETWORK_TRAFFIC, STRATEGY_GROUP, STRATEGY_PROGRESSIVE, STRATEGY_DICHOTOMY } from "./Layer/LayerUpdateStrategy.js";
58
+ export { default as ColorLayersOrdering } from "./Renderer/ColorLayersOrdering.js";
59
+ export { default as GlobeLayer } from "./Core/Prefab/Globe/GlobeLayer.js";
60
+ export { default as PlanarLayer } from "./Core/Prefab/Planar/PlanarLayer.js";
61
+ export { default as LabelLayer } from "./Layer/LabelLayer.js";
62
+ export { default as EntwinePointTileLayer } from "./Layer/EntwinePointTileLayer.js";
63
+ export { default as CopcLayer } from "./Layer/CopcLayer.js";
64
+ export { default as GeoidLayer } from "./Layer/GeoidLayer.js";
65
+
66
+ // Sources provided by default in iTowns
67
+ // A custom source should at least implements Source
68
+ // See http://www.itowns-project.org/itowns/docs/#api/Source/Source
69
+ export { default as Source } from "./Source/Source.js";
70
+ export { default as FileSource } from "./Source/FileSource.js";
71
+ export { default as TMSSource } from "./Source/TMSSource.js";
72
+ export { default as WFSSource } from "./Source/WFSSource.js";
73
+ export { default as WMSSource } from "./Source/WMSSource.js";
74
+ export { default as WMTSSource } from "./Source/WMTSSource.js";
75
+ export { default as VectorTilesSource } from "./Source/VectorTilesSource.js";
76
+ export { default as OrientedImageSource } from "./Source/OrientedImageSource.js";
77
+ export { default as PotreeSource } from "./Source/PotreeSource.js";
78
+ export { default as Potree2Source } from "./Source/Potree2Source.js";
79
+ export { default as C3DTilesSource } from "./Source/C3DTilesSource.js";
80
+ export { default as C3DTilesIonSource } from "./Source/C3DTilesIonSource.js";
81
+ export { default as C3DTilesGoogleSource } from "./Source/C3DTilesGoogleSource.js";
82
+ export { default as OGC3DTilesSource } from "./Source/OGC3DTilesSource.js";
83
+ export { default as OGC3DTilesIonSource } from "./Source/OGC3DTilesIonSource.js";
84
+ export { default as OGC3DTilesGoogleSource } from "./Source/OGC3DTilesGoogleSource.js";
85
+ export { default as EntwinePointTileSource } from "./Source/EntwinePointTileSource.js";
86
+ export { default as CopcSource } from "./Source/CopcSource.js";
87
+
88
+ // Parsers provided by default in iTowns
89
+ // Custom parser can be implemented as wanted, as long as the main function
90
+ // takes the data as the first argument and options as the second.
91
+ export { default as GpxParser } from "./Parser/GpxParser.js";
92
+ export { default as GeoJsonParser } from "./Parser/GeoJsonParser.js";
93
+ export { default as KMLParser } from "./Parser/KMLParser.js";
94
+ export { default as CameraCalibrationParser } from "./Parser/CameraCalibrationParser.js";
95
+ export { default as ShapefileParser } from "./Parser/ShapefileParser.js";
96
+ export { default as LASParser } from "./Parser/LASParser.js";
97
+ export { default as ISGParser } from "./Parser/ISGParser.js";
98
+ export { default as GDFParser } from "./Parser/GDFParser.js";
99
+ export { default as GTXParser } from "./Parser/GTXParser.js";
100
+ export { default as B3dmParser } from "./Parser/B3dmParser.js";
101
+ export { default as iGLTFLoader } from "./Parser/iGLTFLoader.js";
102
+
103
+ // 3D Tiles classes and extensions
104
+ // Exported to allow one to implement its own 3D Tiles extension which needs to
105
+ // know the classes it extends
106
+ export { default as C3DTFeature } from "./Core/3DTiles/C3DTFeature.js";
107
+ export { default as C3DTileset } from "./Core/3DTiles/C3DTileset.js";
108
+ export { default as C3DTBoundingVolume } from "./Core/3DTiles/C3DTBoundingVolume.js";
109
+ export { default as C3DTBatchTable } from "./Core/3DTiles/C3DTBatchTable.js";
110
+ export { default as C3DTExtensions } from "./Core/3DTiles/C3DTExtensions.js";
111
+ export { C3DTilesTypes, C3DTilesBoundingVolumeTypes } from "./Core/3DTiles/C3DTilesEnums.js";
112
+ export { default as C3DTBatchTableHierarchyExtension } from "./Core/3DTiles/C3DTBatchTableHierarchyExtension.js";
113
+ export { process3dTilesNode, $3dTilesCulling, $3dTilesSubdivisionControl } from "./Process/3dTilesProcessing.js";
@@ -0,0 +1,4 @@
1
+ import * as THREE from 'three';
2
+ export { THREE };
3
+ export { default as proj4 } from 'proj4';
4
+ export * from "./Main.js";