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.
- package/dist/455.js +2 -0
- package/dist/455.js.map +1 -0
- package/dist/debug.js +3 -0
- package/dist/debug.js.LICENSE.txt +13 -0
- package/dist/debug.js.map +1 -0
- package/dist/itowns.js +3 -0
- package/dist/itowns.js.LICENSE.txt +5 -0
- package/dist/itowns.js.map +1 -0
- 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/dist/itowns_potree2worker.js +2 -0
- package/dist/itowns_potree2worker.js.map +1 -0
- package/dist/itowns_widgets.js +2 -0
- package/dist/itowns_widgets.js.map +1 -0
- package/lib/Controls/FirstPersonControls.js +308 -0
- package/lib/Controls/FlyControls.js +175 -0
- package/lib/Controls/GlobeControls.js +1178 -0
- package/lib/Controls/PlanarControls.js +1025 -0
- package/lib/Controls/StateControl.js +432 -0
- package/lib/Controls/StreetControls.js +392 -0
- package/lib/Converter/Feature2Mesh.js +612 -0
- package/lib/Converter/Feature2Texture.js +174 -0
- package/lib/Converter/convertToTile.js +70 -0
- package/lib/Converter/textureConverter.js +43 -0
- package/lib/Core/3DTiles/C3DTBatchTable.js +131 -0
- package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +96 -0
- package/lib/Core/3DTiles/C3DTBoundingVolume.js +156 -0
- package/lib/Core/3DTiles/C3DTExtensions.js +97 -0
- package/lib/Core/3DTiles/C3DTFeature.js +110 -0
- package/lib/Core/3DTiles/C3DTilesEnums.js +20 -0
- package/lib/Core/3DTiles/C3DTileset.js +99 -0
- package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +100 -0
- package/lib/Core/AnimationPlayer.js +142 -0
- package/lib/Core/CopcNode.js +174 -0
- package/lib/Core/Deprecated/Undeprecator.js +74 -0
- package/lib/Core/EntwinePointTileNode.js +126 -0
- package/lib/Core/Feature.js +488 -0
- package/lib/Core/Geographic/GeoidGrid.js +108 -0
- package/lib/Core/Label.js +222 -0
- package/lib/Core/MainLoop.js +209 -0
- package/lib/Core/Picking.js +255 -0
- package/lib/Core/PointCloudNode.js +42 -0
- package/lib/Core/Potree2Node.js +206 -0
- package/lib/Core/Potree2PointAttributes.js +139 -0
- package/lib/Core/PotreeNode.js +101 -0
- package/lib/Core/Prefab/Globe/Atmosphere.js +293 -0
- package/lib/Core/Prefab/Globe/GlobeLayer.js +152 -0
- package/lib/Core/Prefab/Globe/GlobeTileBuilder.js +110 -0
- package/lib/Core/Prefab/Globe/SkyShader.js +78 -0
- package/lib/Core/Prefab/GlobeView.js +155 -0
- package/lib/Core/Prefab/Planar/PlanarLayer.js +59 -0
- package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +71 -0
- package/lib/Core/Prefab/PlanarView.js +62 -0
- package/lib/Core/Prefab/TileBuilder.js +82 -0
- package/lib/Core/Prefab/computeBufferTileGeometry.js +248 -0
- package/lib/Core/Scheduler/Cache.js +17 -0
- package/lib/Core/Scheduler/CancelledCommandException.js +15 -0
- package/lib/Core/Scheduler/Scheduler.js +294 -0
- package/lib/Core/Style.js +660 -0
- package/lib/Core/StyleOptions.js +486 -0
- package/lib/Core/System/Capabilities.js +63 -0
- package/lib/Core/Tile/Tile.js +205 -0
- package/lib/Core/Tile/TileGrid.js +49 -0
- package/lib/Core/TileGeometry.js +124 -0
- package/lib/Core/TileMesh.js +108 -0
- package/lib/Core/View.js +1115 -0
- package/lib/Layer/C3DTilesLayer.js +459 -0
- package/lib/Layer/ColorLayer.js +154 -0
- package/lib/Layer/CopcLayer.js +63 -0
- package/lib/Layer/ElevationLayer.js +139 -0
- package/lib/Layer/EntwinePointTileLayer.js +71 -0
- package/lib/Layer/FeatureGeometryLayer.js +77 -0
- package/lib/Layer/GeoidLayer.js +80 -0
- package/lib/Layer/GeometryLayer.js +233 -0
- package/lib/Layer/InfoLayer.js +64 -0
- package/lib/Layer/LabelLayer.js +469 -0
- package/lib/Layer/Layer.js +335 -0
- package/lib/Layer/LayerUpdateState.js +89 -0
- package/lib/Layer/LayerUpdateStrategy.js +80 -0
- package/lib/Layer/OGC3DTilesLayer.js +543 -0
- package/lib/Layer/OrientedImageLayer.js +227 -0
- package/lib/Layer/PointCloudLayer.js +405 -0
- package/lib/Layer/Potree2Layer.js +171 -0
- package/lib/Layer/PotreeLayer.js +72 -0
- package/lib/Layer/RasterLayer.js +37 -0
- package/lib/Layer/ReferencingLayerProperties.js +62 -0
- package/lib/Layer/TiledGeometryLayer.js +459 -0
- package/lib/Loader/LASLoader.js +193 -0
- package/lib/Loader/Potree2BrotliLoader.js +261 -0
- package/lib/Loader/Potree2Loader.js +207 -0
- package/lib/Main.js +113 -0
- package/lib/MainBundle.js +4 -0
- package/lib/Parser/B3dmParser.js +174 -0
- package/lib/Parser/CameraCalibrationParser.js +94 -0
- package/lib/Parser/GDFParser.js +72 -0
- package/lib/Parser/GTXParser.js +75 -0
- package/lib/Parser/GeoJsonParser.js +212 -0
- package/lib/Parser/GpxParser.js +25 -0
- package/lib/Parser/ISGParser.js +71 -0
- package/lib/Parser/KMLParser.js +25 -0
- package/lib/Parser/LASParser.js +137 -0
- package/lib/Parser/MapBoxUrlParser.js +83 -0
- package/lib/Parser/PntsParser.js +131 -0
- package/lib/Parser/Potree2BinParser.js +92 -0
- package/lib/Parser/PotreeBinParser.js +106 -0
- package/lib/Parser/PotreeCinParser.js +29 -0
- package/lib/Parser/ShapefileParser.js +78 -0
- package/lib/Parser/VectorTileParser.js +215 -0
- package/lib/Parser/XbilParser.js +120 -0
- package/lib/Parser/deprecated/LegacyGLTFLoader.js +1386 -0
- package/lib/Parser/iGLTFLoader.js +168 -0
- package/lib/Process/3dTilesProcessing.js +304 -0
- package/lib/Process/FeatureProcessing.js +76 -0
- package/lib/Process/LayeredMaterialNodeProcessing.js +229 -0
- package/lib/Process/ObjectRemovalHelper.js +97 -0
- package/lib/Process/handlerNodeError.js +23 -0
- package/lib/Provider/3dTilesProvider.js +149 -0
- package/lib/Provider/DataSourceProvider.js +24 -0
- package/lib/Provider/Fetcher.js +233 -0
- package/lib/Provider/PointCloudProvider.js +45 -0
- package/lib/Provider/TileProvider.js +16 -0
- package/lib/Provider/URLBuilder.js +116 -0
- package/lib/Renderer/Camera.js +281 -0
- package/lib/Renderer/Color.js +56 -0
- package/lib/Renderer/ColorLayersOrdering.js +115 -0
- package/lib/Renderer/CommonMaterial.js +31 -0
- package/lib/Renderer/Label2DRenderer.js +192 -0
- package/lib/Renderer/LayeredMaterial.js +243 -0
- package/lib/Renderer/OBB.js +150 -0
- package/lib/Renderer/OrientedImageCamera.js +118 -0
- package/lib/Renderer/OrientedImageMaterial.js +167 -0
- package/lib/Renderer/PointsMaterial.js +485 -0
- package/lib/Renderer/RasterTile.js +243 -0
- package/lib/Renderer/RenderMode.js +31 -0
- package/lib/Renderer/Shader/ShaderChunk.js +160 -0
- package/lib/Renderer/Shader/ShaderUtils.js +47 -0
- package/lib/Renderer/SphereHelper.js +17 -0
- package/lib/Renderer/WebXR.js +51 -0
- package/lib/Renderer/c3DEngine.js +214 -0
- package/lib/Source/C3DTilesGoogleSource.js +74 -0
- package/lib/Source/C3DTilesIonSource.js +54 -0
- package/lib/Source/C3DTilesSource.js +30 -0
- package/lib/Source/CopcSource.js +126 -0
- package/lib/Source/EntwinePointTileSource.js +72 -0
- package/lib/Source/FileSource.js +188 -0
- package/lib/Source/OGC3DTilesGoogleSource.js +29 -0
- package/lib/Source/OGC3DTilesIonSource.js +34 -0
- package/lib/Source/OGC3DTilesSource.js +21 -0
- package/lib/Source/OrientedImageSource.js +59 -0
- package/lib/Source/Potree2Source.js +167 -0
- package/lib/Source/PotreeSource.js +82 -0
- package/lib/Source/Source.js +202 -0
- package/lib/Source/TMSSource.js +144 -0
- package/lib/Source/VectorTilesSource.js +182 -0
- package/lib/Source/WFSSource.js +170 -0
- package/lib/Source/WMSSource.js +167 -0
- package/lib/Source/WMTSSource.js +92 -0
- package/lib/ThreeExtended/capabilities/WebGL.js +69 -0
- package/lib/ThreeExtended/libs/ktx-parse.module.js +506 -0
- package/lib/ThreeExtended/libs/zstddec.module.js +29 -0
- package/lib/ThreeExtended/loaders/DDSLoader.js +200 -0
- package/lib/ThreeExtended/loaders/DRACOLoader.js +400 -0
- package/lib/ThreeExtended/loaders/GLTFLoader.js +2879 -0
- package/lib/ThreeExtended/loaders/KTX2Loader.js +709 -0
- package/lib/ThreeExtended/math/ColorSpaces.js +59 -0
- package/lib/ThreeExtended/utils/BufferGeometryUtils.js +846 -0
- package/lib/ThreeExtended/utils/WorkerPool.js +70 -0
- package/lib/Utils/CameraUtils.js +554 -0
- package/lib/Utils/DEMUtils.js +350 -0
- package/lib/Utils/FeaturesUtils.js +156 -0
- package/lib/Utils/Gradients.js +16 -0
- package/lib/Utils/ThreeUtils.js +115 -0
- package/lib/Utils/gui/C3DTilesStyle.js +218 -0
- package/lib/Utils/gui/Main.js +7 -0
- package/lib/Utils/gui/Minimap.js +152 -0
- package/lib/Utils/gui/Navigation.js +245 -0
- package/lib/Utils/gui/Scale.js +104 -0
- package/lib/Utils/gui/Searchbar.js +234 -0
- package/lib/Utils/gui/Widget.js +80 -0
- package/lib/Utils/placeObjectOnGround.js +136 -0
- package/lib/Worker/LASLoaderWorker.js +19 -0
- package/lib/Worker/Potree2Worker.js +21 -0
- package/package.json +2 -2
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
class PointCloudNode extends THREE.EventDispatcher {
|
|
3
|
+
constructor() {
|
|
4
|
+
let numPoints = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
5
|
+
let layer = arguments.length > 1 ? arguments[1] : undefined;
|
|
6
|
+
super();
|
|
7
|
+
this.numPoints = numPoints;
|
|
8
|
+
this.layer = layer;
|
|
9
|
+
this.children = [];
|
|
10
|
+
this.bbox = new THREE.Box3();
|
|
11
|
+
this.sse = -1;
|
|
12
|
+
}
|
|
13
|
+
add(node, indexChild) {
|
|
14
|
+
this.children.push(node);
|
|
15
|
+
node.parent = this;
|
|
16
|
+
this.createChildAABB(node, indexChild);
|
|
17
|
+
}
|
|
18
|
+
load() {
|
|
19
|
+
// Query octree/HRC if we don't have children potreeNode yet.
|
|
20
|
+
if (!this.octreeIsLoaded) {
|
|
21
|
+
this.loadOctree();
|
|
22
|
+
}
|
|
23
|
+
return this.layer.source.fetcher(this.url, this.layer.source.networkOptions).then(file => this.layer.source.parse(file, {
|
|
24
|
+
out: this.layer,
|
|
25
|
+
in: this.layer.source
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
findCommonAncestor(node) {
|
|
29
|
+
if (node.depth == this.depth) {
|
|
30
|
+
if (node.id == this.id) {
|
|
31
|
+
return node;
|
|
32
|
+
} else if (node.depth != 0) {
|
|
33
|
+
return this.parent.findCommonAncestor(node.parent);
|
|
34
|
+
}
|
|
35
|
+
} else if (node.depth < this.depth) {
|
|
36
|
+
return this.parent.findCommonAncestor(node);
|
|
37
|
+
} else {
|
|
38
|
+
return this.findCommonAncestor(node.parent);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export default PointCloudNode;
|
|
@@ -0,0 +1,206 @@
|
|
|
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 * as THREE from 'three';
|
|
37
|
+
import PointCloudNode from "./PointCloudNode.js";
|
|
38
|
+
|
|
39
|
+
// Create an A(xis)A(ligned)B(ounding)B(ox) for the child `childIndex` of one aabb.
|
|
40
|
+
// (PotreeConverter protocol builds implicit octree hierarchy by applying the same
|
|
41
|
+
// subdivision algo recursively)
|
|
42
|
+
const dHalfLength = new THREE.Vector3();
|
|
43
|
+
const NODE_TYPE = {
|
|
44
|
+
NORMAL: 0,
|
|
45
|
+
LEAF: 1,
|
|
46
|
+
PROXY: 2
|
|
47
|
+
};
|
|
48
|
+
class Potree2Node extends PointCloudNode {
|
|
49
|
+
constructor() {
|
|
50
|
+
let numPoints = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
51
|
+
let childrenBitField = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
52
|
+
let layer = arguments.length > 2 ? arguments[2] : undefined;
|
|
53
|
+
super(numPoints, layer);
|
|
54
|
+
this.childrenBitField = childrenBitField;
|
|
55
|
+
this.id = '';
|
|
56
|
+
this.depth = 0;
|
|
57
|
+
this.baseurl = layer.source.baseurl;
|
|
58
|
+
}
|
|
59
|
+
add(node, indexChild) {
|
|
60
|
+
super.add(node, indexChild);
|
|
61
|
+
node.id = this.id + indexChild;
|
|
62
|
+
node.depth = this.depth + 1;
|
|
63
|
+
}
|
|
64
|
+
createChildAABB(node, childIndex) {
|
|
65
|
+
// Code inspired from potree
|
|
66
|
+
node.bbox.copy(this.bbox);
|
|
67
|
+
this.bbox.getCenter(node.bbox.max);
|
|
68
|
+
dHalfLength.copy(node.bbox.max).sub(this.bbox.min);
|
|
69
|
+
if (childIndex === 1) {
|
|
70
|
+
node.bbox.min.z += dHalfLength.z;
|
|
71
|
+
node.bbox.max.z += dHalfLength.z;
|
|
72
|
+
} else if (childIndex === 3) {
|
|
73
|
+
node.bbox.min.z += dHalfLength.z;
|
|
74
|
+
node.bbox.max.z += dHalfLength.z;
|
|
75
|
+
node.bbox.min.y += dHalfLength.y;
|
|
76
|
+
node.bbox.max.y += dHalfLength.y;
|
|
77
|
+
} else if (childIndex === 0) {
|
|
78
|
+
//
|
|
79
|
+
} else if (childIndex === 2) {
|
|
80
|
+
node.bbox.min.y += dHalfLength.y;
|
|
81
|
+
node.bbox.max.y += dHalfLength.y;
|
|
82
|
+
} else if (childIndex === 5) {
|
|
83
|
+
node.bbox.min.z += dHalfLength.z;
|
|
84
|
+
node.bbox.max.z += dHalfLength.z;
|
|
85
|
+
node.bbox.min.x += dHalfLength.x;
|
|
86
|
+
node.bbox.max.x += dHalfLength.x;
|
|
87
|
+
} else if (childIndex === 7) {
|
|
88
|
+
node.bbox.min.add(dHalfLength);
|
|
89
|
+
node.bbox.max.add(dHalfLength);
|
|
90
|
+
} else if (childIndex === 4) {
|
|
91
|
+
node.bbox.min.x += dHalfLength.x;
|
|
92
|
+
node.bbox.max.x += dHalfLength.x;
|
|
93
|
+
} else if (childIndex === 6) {
|
|
94
|
+
node.bbox.min.y += dHalfLength.y;
|
|
95
|
+
node.bbox.max.y += dHalfLength.y;
|
|
96
|
+
node.bbox.min.x += dHalfLength.x;
|
|
97
|
+
node.bbox.max.x += dHalfLength.x;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
get octreeIsLoaded() {
|
|
101
|
+
return !(this.childrenBitField && this.children.length === 0);
|
|
102
|
+
}
|
|
103
|
+
get url() {
|
|
104
|
+
return `${this.baseurl}/octree.bin`;
|
|
105
|
+
}
|
|
106
|
+
networkOptions(byteOffset, byteSize) {
|
|
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)
|
|
111
|
+
const networkOptions = {
|
|
112
|
+
...this.layer.source.networkOptions,
|
|
113
|
+
headers: {
|
|
114
|
+
...this.layer.source.networkOptions.headers,
|
|
115
|
+
...(this.url.startsWith('https://raw.githubusercontent.com') ? {} : {
|
|
116
|
+
'content-type': 'multipart/byteranges'
|
|
117
|
+
}),
|
|
118
|
+
Range: `bytes=${first}-${first + byteSize - 1n}`
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
return networkOptions;
|
|
122
|
+
}
|
|
123
|
+
async load() {
|
|
124
|
+
// Query octree if we don't have children potreeNode yet.
|
|
125
|
+
if (!this.octreeIsLoaded) {
|
|
126
|
+
await this.loadOctree();
|
|
127
|
+
}
|
|
128
|
+
return this.layer.source.fetcher(this.url, this.networkOptions(this.byteOffset, this.byteSize)).then(file => this.layer.source.parser(file, {
|
|
129
|
+
in: {
|
|
130
|
+
source: this.layer.source,
|
|
131
|
+
bbox: this.bbox,
|
|
132
|
+
numPoints: this.numPoints
|
|
133
|
+
},
|
|
134
|
+
out: this.layer
|
|
135
|
+
})).then(data => {
|
|
136
|
+
this.loaded = true;
|
|
137
|
+
this.loading = false;
|
|
138
|
+
return data.geometry;
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
async loadOctree() {
|
|
142
|
+
if (this.loaded || this.loading) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
this.loading = true;
|
|
146
|
+
return this.nodeType === NODE_TYPE.PROXY ? this.loadHierarchy() : Promise.resolve();
|
|
147
|
+
}
|
|
148
|
+
async loadHierarchy() {
|
|
149
|
+
const hierarchyPath = `${this.baseurl}/hierarchy.bin`;
|
|
150
|
+
const buffer = await this.layer.source.fetcher(hierarchyPath, this.networkOptions(this.hierarchyByteOffset, this.hierarchyByteSize));
|
|
151
|
+
this.parseHierarchy(buffer);
|
|
152
|
+
}
|
|
153
|
+
parseHierarchy(buffer) {
|
|
154
|
+
const view = new DataView(buffer);
|
|
155
|
+
const bytesPerNode = 22;
|
|
156
|
+
const numNodes = buffer.byteLength / bytesPerNode;
|
|
157
|
+
const stack = [];
|
|
158
|
+
stack.push(this);
|
|
159
|
+
for (let indexNode = 0; indexNode < numNodes; indexNode++) {
|
|
160
|
+
const current = stack.shift();
|
|
161
|
+
const offset = indexNode * bytesPerNode;
|
|
162
|
+
const type = view.getUint8(offset + 0);
|
|
163
|
+
const childMask = view.getUint8(offset + 1);
|
|
164
|
+
const numPoints = view.getUint32(offset + 2, true);
|
|
165
|
+
const byteOffset = view.getBigInt64(offset + 6, true);
|
|
166
|
+
const byteSize = view.getBigInt64(offset + 14, true);
|
|
167
|
+
if (current.nodeType === NODE_TYPE.PROXY) {
|
|
168
|
+
// replace proxy with real node
|
|
169
|
+
current.byteOffset = byteOffset;
|
|
170
|
+
current.byteSize = byteSize;
|
|
171
|
+
current.numPoints = numPoints;
|
|
172
|
+
} else if (type === NODE_TYPE.PROXY) {
|
|
173
|
+
// load proxy
|
|
174
|
+
current.hierarchyByteOffset = byteOffset;
|
|
175
|
+
current.hierarchyByteSize = byteSize;
|
|
176
|
+
current.numPoints = numPoints;
|
|
177
|
+
} else {
|
|
178
|
+
// load real node
|
|
179
|
+
current.byteOffset = byteOffset;
|
|
180
|
+
current.byteSize = byteSize;
|
|
181
|
+
current.numPoints = numPoints;
|
|
182
|
+
}
|
|
183
|
+
if (current.byteSize === 0n) {
|
|
184
|
+
// workaround for issue potree/potree#1125
|
|
185
|
+
// some inner nodes erroneously report >0 points even though have 0 points
|
|
186
|
+
// however, they still report a byteSize of 0, so based on that we now set node.numPoints to 0
|
|
187
|
+
current.numPoints = 0;
|
|
188
|
+
}
|
|
189
|
+
current.nodeType = type;
|
|
190
|
+
if (current.nodeType === NODE_TYPE.PROXY) {
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
for (let childIndex = 0; childIndex < 8; childIndex++) {
|
|
194
|
+
const childExists = (1 << childIndex & childMask) !== 0;
|
|
195
|
+
if (!childExists) {
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
const child = new Potree2Node(numPoints, childMask, this.layer);
|
|
199
|
+
child.spacing = current.spacing / 2;
|
|
200
|
+
current.add(child, childIndex);
|
|
201
|
+
stack.push(child);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
export default Potree2Node;
|
|
@@ -0,0 +1,139 @@
|
|
|
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
|
+
/**
|
|
37
|
+
* Some types of possible point attribute data formats
|
|
38
|
+
*
|
|
39
|
+
* @class
|
|
40
|
+
*/
|
|
41
|
+
const PointAttributeTypes = {
|
|
42
|
+
DATA_TYPE_DOUBLE: {
|
|
43
|
+
name: 'double',
|
|
44
|
+
size: 8
|
|
45
|
+
},
|
|
46
|
+
DATA_TYPE_FLOAT: {
|
|
47
|
+
name: 'float',
|
|
48
|
+
size: 4
|
|
49
|
+
},
|
|
50
|
+
DATA_TYPE_INT8: {
|
|
51
|
+
name: 'int8',
|
|
52
|
+
size: 1
|
|
53
|
+
},
|
|
54
|
+
DATA_TYPE_UINT8: {
|
|
55
|
+
name: 'uint8',
|
|
56
|
+
size: 1
|
|
57
|
+
},
|
|
58
|
+
DATA_TYPE_INT16: {
|
|
59
|
+
name: 'int16',
|
|
60
|
+
size: 2
|
|
61
|
+
},
|
|
62
|
+
DATA_TYPE_UINT16: {
|
|
63
|
+
name: 'uint16',
|
|
64
|
+
size: 2
|
|
65
|
+
},
|
|
66
|
+
DATA_TYPE_INT32: {
|
|
67
|
+
name: 'int32',
|
|
68
|
+
size: 4
|
|
69
|
+
},
|
|
70
|
+
DATA_TYPE_UINT32: {
|
|
71
|
+
name: 'uint32',
|
|
72
|
+
size: 4
|
|
73
|
+
},
|
|
74
|
+
DATA_TYPE_INT64: {
|
|
75
|
+
name: 'int64',
|
|
76
|
+
size: 8
|
|
77
|
+
},
|
|
78
|
+
DATA_TYPE_UINT64: {
|
|
79
|
+
name: 'uint64',
|
|
80
|
+
size: 8
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
Object.keys(PointAttributeTypes).forEach((type, index) => {
|
|
84
|
+
PointAttributeTypes[index] = PointAttributeTypes[type];
|
|
85
|
+
});
|
|
86
|
+
export { PointAttributeTypes };
|
|
87
|
+
class PointAttribute {
|
|
88
|
+
constructor(name, type, numElements) {
|
|
89
|
+
this.name = name;
|
|
90
|
+
this.type = type;
|
|
91
|
+
this.numElements = numElements;
|
|
92
|
+
this.byteSize = this.numElements * this.type.size;
|
|
93
|
+
this.description = '';
|
|
94
|
+
this.range = [Infinity, -Infinity];
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
PointAttribute.POSITION_CARTESIAN = new PointAttribute('POSITION_CARTESIAN', PointAttributeTypes.DATA_TYPE_FLOAT, 3);
|
|
98
|
+
PointAttribute.RGBA_PACKED = new PointAttribute('COLOR_PACKED', PointAttributeTypes.DATA_TYPE_INT8, 4);
|
|
99
|
+
PointAttribute.COLOR_PACKED = PointAttribute.RGBA_PACKED;
|
|
100
|
+
PointAttribute.RGB_PACKED = new PointAttribute('COLOR_PACKED', PointAttributeTypes.DATA_TYPE_INT8, 3);
|
|
101
|
+
PointAttribute.NORMAL_FLOATS = new PointAttribute('NORMAL_FLOATS', PointAttributeTypes.DATA_TYPE_FLOAT, 3);
|
|
102
|
+
PointAttribute.INTENSITY = new PointAttribute('INTENSITY', PointAttributeTypes.DATA_TYPE_UINT16, 1);
|
|
103
|
+
PointAttribute.CLASSIFICATION = new PointAttribute('CLASSIFICATION', PointAttributeTypes.DATA_TYPE_UINT8, 1);
|
|
104
|
+
PointAttribute.NORMAL_SPHEREMAPPED = new PointAttribute('NORMAL_SPHEREMAPPED', PointAttributeTypes.DATA_TYPE_UINT8, 2);
|
|
105
|
+
PointAttribute.NORMAL_OCT16 = new PointAttribute('NORMAL_OCT16', PointAttributeTypes.DATA_TYPE_UINT8, 2);
|
|
106
|
+
PointAttribute.NORMAL = new PointAttribute('NORMAL', PointAttributeTypes.DATA_TYPE_FLOAT, 3);
|
|
107
|
+
PointAttribute.RETURN_NUMBER = new PointAttribute('RETURN_NUMBER', PointAttributeTypes.DATA_TYPE_UINT8, 1);
|
|
108
|
+
PointAttribute.NUMBER_OF_RETURNS = new PointAttribute('NUMBER_OF_RETURNS', PointAttributeTypes.DATA_TYPE_UINT8, 1);
|
|
109
|
+
PointAttribute.SOURCE_ID = new PointAttribute('SOURCE_ID', PointAttributeTypes.DATA_TYPE_UINT16, 1);
|
|
110
|
+
PointAttribute.INDICES = new PointAttribute('INDICES', PointAttributeTypes.DATA_TYPE_UINT32, 1);
|
|
111
|
+
PointAttribute.SPACING = new PointAttribute('SPACING', PointAttributeTypes.DATA_TYPE_FLOAT, 1);
|
|
112
|
+
PointAttribute.GPS_TIME = new PointAttribute('GPS_TIME', PointAttributeTypes.DATA_TYPE_DOUBLE, 1);
|
|
113
|
+
export { PointAttribute };
|
|
114
|
+
export class Potree2PointAttributes {
|
|
115
|
+
constructor() {
|
|
116
|
+
this.attributes = [];
|
|
117
|
+
this.byteSize = 0;
|
|
118
|
+
this.size = 0;
|
|
119
|
+
this.vectors = [];
|
|
120
|
+
}
|
|
121
|
+
add(pointAttribute) {
|
|
122
|
+
this.attributes.push(pointAttribute);
|
|
123
|
+
this.byteSize += pointAttribute.byteSize;
|
|
124
|
+
this.size++;
|
|
125
|
+
}
|
|
126
|
+
addVector(vector) {
|
|
127
|
+
this.vectors.push(vector);
|
|
128
|
+
}
|
|
129
|
+
hasNormals() {
|
|
130
|
+
for (let index = 0; index < this.attributes.length; index++) {
|
|
131
|
+
const name = this.attributes[index];
|
|
132
|
+
const pointAttribute = this.attributes[name];
|
|
133
|
+
if (pointAttribute === PointAttribute.NORMAL_SPHEREMAPPED || pointAttribute === PointAttribute.NORMAL_FLOATS || pointAttribute === PointAttribute.NORMAL || pointAttribute === PointAttribute.NORMAL_OCT16) {
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import PointCloudNode from "./PointCloudNode.js";
|
|
3
|
+
|
|
4
|
+
// Create an A(xis)A(ligned)B(ounding)B(ox) for the child `childIndex` of one aabb.
|
|
5
|
+
// (PotreeConverter protocol builds implicit octree hierarchy by applying the same
|
|
6
|
+
// subdivision algo recursively)
|
|
7
|
+
const dHalfLength = new THREE.Vector3();
|
|
8
|
+
class PotreeNode extends PointCloudNode {
|
|
9
|
+
constructor() {
|
|
10
|
+
let numPoints = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
11
|
+
let childrenBitField = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
12
|
+
let layer = arguments.length > 2 ? arguments[2] : undefined;
|
|
13
|
+
super(numPoints, layer);
|
|
14
|
+
this.childrenBitField = childrenBitField;
|
|
15
|
+
this.id = '';
|
|
16
|
+
this.depth = 0;
|
|
17
|
+
this.baseurl = layer.source.baseurl;
|
|
18
|
+
}
|
|
19
|
+
add(node, indexChild, root) {
|
|
20
|
+
super.add(node, indexChild);
|
|
21
|
+
node.id = this.id + indexChild;
|
|
22
|
+
node.depth = node.id.length;
|
|
23
|
+
if (node.id.length % this.layer.hierarchyStepSize == 0) {
|
|
24
|
+
node.baseurl = `${root.baseurl}/${node.id.substr(root.id.length)}`;
|
|
25
|
+
} else {
|
|
26
|
+
node.baseurl = root.baseurl;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
createChildAABB(node, childIndex) {
|
|
30
|
+
// Code inspired from potree
|
|
31
|
+
node.bbox.copy(this.bbox);
|
|
32
|
+
this.bbox.getCenter(node.bbox.max);
|
|
33
|
+
dHalfLength.copy(node.bbox.max).sub(this.bbox.min);
|
|
34
|
+
if (childIndex === 1) {
|
|
35
|
+
node.bbox.min.z += dHalfLength.z;
|
|
36
|
+
node.bbox.max.z += dHalfLength.z;
|
|
37
|
+
} else if (childIndex === 3) {
|
|
38
|
+
node.bbox.min.z += dHalfLength.z;
|
|
39
|
+
node.bbox.max.z += dHalfLength.z;
|
|
40
|
+
node.bbox.min.y += dHalfLength.y;
|
|
41
|
+
node.bbox.max.y += dHalfLength.y;
|
|
42
|
+
} else if (childIndex === 0) {
|
|
43
|
+
//
|
|
44
|
+
} else if (childIndex === 2) {
|
|
45
|
+
node.bbox.min.y += dHalfLength.y;
|
|
46
|
+
node.bbox.max.y += dHalfLength.y;
|
|
47
|
+
} else if (childIndex === 5) {
|
|
48
|
+
node.bbox.min.z += dHalfLength.z;
|
|
49
|
+
node.bbox.max.z += dHalfLength.z;
|
|
50
|
+
node.bbox.min.x += dHalfLength.x;
|
|
51
|
+
node.bbox.max.x += dHalfLength.x;
|
|
52
|
+
} else if (childIndex === 7) {
|
|
53
|
+
node.bbox.min.add(dHalfLength);
|
|
54
|
+
node.bbox.max.add(dHalfLength);
|
|
55
|
+
} else if (childIndex === 4) {
|
|
56
|
+
node.bbox.min.x += dHalfLength.x;
|
|
57
|
+
node.bbox.max.x += dHalfLength.x;
|
|
58
|
+
} else if (childIndex === 6) {
|
|
59
|
+
node.bbox.min.y += dHalfLength.y;
|
|
60
|
+
node.bbox.max.y += dHalfLength.y;
|
|
61
|
+
node.bbox.min.x += dHalfLength.x;
|
|
62
|
+
node.bbox.max.x += dHalfLength.x;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
get octreeIsLoaded() {
|
|
66
|
+
return !(this.childrenBitField && this.children.length === 0);
|
|
67
|
+
}
|
|
68
|
+
get url() {
|
|
69
|
+
return `${this.baseurl}/r${this.id}.${this.layer.source.extension}`;
|
|
70
|
+
}
|
|
71
|
+
loadOctree() {
|
|
72
|
+
const octreeUrl = `${this.baseurl}/r${this.id}.${this.layer.source.extensionOctree}`;
|
|
73
|
+
return this.layer.source.fetcher(octreeUrl, this.layer.source.networkOptions).then(blob => {
|
|
74
|
+
const view = new DataView(blob);
|
|
75
|
+
const stack = [];
|
|
76
|
+
let offset = 0;
|
|
77
|
+
this.childrenBitField = view.getUint8(0);
|
|
78
|
+
offset += 1;
|
|
79
|
+
this.numPoints = view.getUint32(1, true);
|
|
80
|
+
offset += 4;
|
|
81
|
+
stack.push(this);
|
|
82
|
+
while (stack.length && offset < blob.byteLength) {
|
|
83
|
+
const snode = stack.shift();
|
|
84
|
+
// look up 8 children
|
|
85
|
+
for (let indexChild = 0; indexChild < 8; indexChild++) {
|
|
86
|
+
// does snode have a #indexChild child ?
|
|
87
|
+
if (snode.childrenBitField & 1 << indexChild && offset + 5 <= blob.byteLength) {
|
|
88
|
+
const childrenBitField = view.getUint8(offset);
|
|
89
|
+
offset += 1;
|
|
90
|
+
const numPoints = view.getUint32(offset, true) || this.numPoints;
|
|
91
|
+
offset += 4;
|
|
92
|
+
const item = new PotreeNode(numPoints, childrenBitField, this.layer);
|
|
93
|
+
snode.add(item, indexChild, this);
|
|
94
|
+
stack.push(item);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export default PotreeNode;
|