itowns 2.44.3-next.8 → 2.45.0
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/README.md +3 -129
- package/examples/3dtiles_loader.html +123 -48
- package/examples/config.json +3 -10
- package/examples/copc_simple_loader.html +15 -5
- package/examples/effects_stereo.html +2 -2
- package/examples/entwine_3d_loader.html +3 -1
- package/examples/entwine_simple_loader.html +1 -1
- package/examples/images/itowns_logo.svg +123 -0
- package/examples/js/plugins/COGParser.js +1 -1
- package/examples/jsm/OGC3DTilesHelper.js +6 -1
- package/examples/layers/JSONLayers/GeoidMNT.json +3 -1
- package/examples/misc_collada.html +2 -2
- package/examples/source_file_geojson_3d.html +0 -1
- package/examples/source_file_kml_raster_usgs.html +0 -1
- package/examples/source_stream_wfs_raster.html +0 -7
- package/examples/vector_tile_mapbox_raster.html +91 -0
- package/examples/view_3d_map_webxr.html +3 -1
- package/examples/view_multi_25d.html +2 -2
- package/package.json +21 -75
- package/CODING.md +0 -120
- package/CONTRIBUTING.md +0 -150
- package/CONTRIBUTORS.md +0 -55
- package/LICENSE.md +0 -44
- package/changelog.md +0 -1361
- package/dist/455.js +0 -2
- package/dist/455.js.map +0 -1
- package/dist/debug.js +0 -3
- package/dist/debug.js.LICENSE.txt +0 -13
- package/dist/debug.js.map +0 -1
- package/dist/itowns.js +0 -3
- package/dist/itowns.js.LICENSE.txt +0 -7
- package/dist/itowns.js.map +0 -1
- package/dist/itowns_lasparser.js +0 -2
- package/dist/itowns_lasparser.js.map +0 -1
- package/dist/itowns_lasworker.js +0 -2
- package/dist/itowns_lasworker.js.map +0 -1
- package/dist/itowns_potree2worker.js +0 -2
- package/dist/itowns_potree2worker.js.map +0 -1
- package/dist/itowns_widgets.js +0 -2
- package/dist/itowns_widgets.js.map +0 -1
- package/examples/.eslintrc.cjs +0 -35
- package/examples/3dtiles_25d.html +0 -120
- package/examples/3dtiles_basic.html +0 -94
- package/examples/3dtiles_batch_table.html +0 -86
- package/examples/3dtiles_ion.html +0 -126
- package/examples/3dtiles_pointcloud.html +0 -95
- package/examples/jsm/.eslintrc.cjs +0 -38
- package/lib/Controls/FirstPersonControls.js +0 -308
- package/lib/Controls/FlyControls.js +0 -175
- package/lib/Controls/GlobeControls.js +0 -1162
- package/lib/Controls/PlanarControls.js +0 -1025
- package/lib/Controls/StateControl.js +0 -429
- package/lib/Controls/StreetControls.js +0 -392
- package/lib/Converter/Feature2Mesh.js +0 -615
- package/lib/Converter/Feature2Texture.js +0 -170
- package/lib/Converter/convertToTile.js +0 -75
- package/lib/Converter/textureConverter.js +0 -44
- package/lib/Core/3DTiles/C3DTBatchTable.js +0 -131
- package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +0 -96
- package/lib/Core/3DTiles/C3DTBoundingVolume.js +0 -157
- package/lib/Core/3DTiles/C3DTExtensions.js +0 -97
- package/lib/Core/3DTiles/C3DTFeature.js +0 -110
- package/lib/Core/3DTiles/C3DTilesEnums.js +0 -20
- package/lib/Core/3DTiles/C3DTileset.js +0 -99
- package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +0 -100
- package/lib/Core/AnimationPlayer.js +0 -142
- package/lib/Core/CopcNode.js +0 -174
- package/lib/Core/Deprecated/Undeprecator.js +0 -75
- package/lib/Core/EntwinePointTileNode.js +0 -126
- package/lib/Core/Feature.js +0 -490
- package/lib/Core/Geographic/CoordStars.js +0 -80
- package/lib/Core/Geographic/Coordinates.js +0 -320
- package/lib/Core/Geographic/Crs.js +0 -175
- package/lib/Core/Geographic/Extent.js +0 -534
- package/lib/Core/Geographic/GeoidGrid.js +0 -109
- package/lib/Core/Label.js +0 -222
- package/lib/Core/MainLoop.js +0 -211
- package/lib/Core/Math/Ellipsoid.js +0 -144
- package/lib/Core/Picking.js +0 -255
- package/lib/Core/PointCloudNode.js +0 -42
- package/lib/Core/Potree2Node.js +0 -206
- package/lib/Core/Potree2PointAttributes.js +0 -139
- package/lib/Core/PotreeNode.js +0 -101
- package/lib/Core/Prefab/Globe/Atmosphere.js +0 -299
- package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +0 -110
- package/lib/Core/Prefab/Globe/GlobeLayer.js +0 -145
- package/lib/Core/Prefab/Globe/SkyShader.js +0 -78
- package/lib/Core/Prefab/GlobeView.js +0 -161
- package/lib/Core/Prefab/Planar/PlanarLayer.js +0 -53
- package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +0 -72
- package/lib/Core/Prefab/PlanarView.js +0 -62
- package/lib/Core/Prefab/TileBuilder.js +0 -80
- package/lib/Core/Prefab/computeBufferTileGeometry.js +0 -183
- package/lib/Core/Scheduler/Cache.js +0 -256
- package/lib/Core/Scheduler/CancelledCommandException.js +0 -15
- package/lib/Core/Scheduler/Scheduler.js +0 -294
- package/lib/Core/Style.js +0 -1121
- package/lib/Core/System/Capabilities.js +0 -63
- package/lib/Core/Tile/Tile.js +0 -219
- package/lib/Core/Tile/TileGrid.js +0 -46
- package/lib/Core/TileGeometry.js +0 -40
- package/lib/Core/TileMesh.js +0 -109
- package/lib/Core/View.js +0 -1109
- package/lib/Layer/C3DTilesLayer.js +0 -455
- package/lib/Layer/ColorLayer.js +0 -128
- package/lib/Layer/CopcLayer.js +0 -58
- package/lib/Layer/ElevationLayer.js +0 -107
- package/lib/Layer/EntwinePointTileLayer.js +0 -64
- package/lib/Layer/FeatureGeometryLayer.js +0 -63
- package/lib/Layer/GeoidLayer.js +0 -80
- package/lib/Layer/GeometryLayer.js +0 -202
- package/lib/Layer/InfoLayer.js +0 -64
- package/lib/Layer/LabelLayer.js +0 -456
- package/lib/Layer/Layer.js +0 -304
- package/lib/Layer/LayerUpdateState.js +0 -89
- package/lib/Layer/LayerUpdateStrategy.js +0 -80
- package/lib/Layer/OGC3DTilesLayer.js +0 -387
- package/lib/Layer/OrientedImageLayer.js +0 -222
- package/lib/Layer/PointCloudLayer.js +0 -359
- package/lib/Layer/Potree2Layer.js +0 -164
- package/lib/Layer/PotreeLayer.js +0 -65
- package/lib/Layer/RasterLayer.js +0 -27
- package/lib/Layer/ReferencingLayerProperties.js +0 -62
- package/lib/Layer/TiledGeometryLayer.js +0 -403
- package/lib/Loader/LASLoader.js +0 -193
- package/lib/Loader/Potree2BrotliLoader.js +0 -261
- package/lib/Loader/Potree2Loader.js +0 -207
- package/lib/Main.js +0 -115
- package/lib/MainBundle.js +0 -4
- package/lib/Parser/B3dmParser.js +0 -174
- package/lib/Parser/CameraCalibrationParser.js +0 -94
- package/lib/Parser/GDFParser.js +0 -72
- package/lib/Parser/GTXParser.js +0 -75
- package/lib/Parser/GeoJsonParser.js +0 -212
- package/lib/Parser/GpxParser.js +0 -25
- package/lib/Parser/ISGParser.js +0 -71
- package/lib/Parser/KMLParser.js +0 -25
- package/lib/Parser/LASParser.js +0 -137
- package/lib/Parser/MapBoxUrlParser.js +0 -83
- package/lib/Parser/PntsParser.js +0 -131
- package/lib/Parser/Potree2BinParser.js +0 -92
- package/lib/Parser/PotreeBinParser.js +0 -106
- package/lib/Parser/PotreeCinParser.js +0 -29
- package/lib/Parser/ShapefileParser.js +0 -78
- package/lib/Parser/VectorTileParser.js +0 -202
- package/lib/Parser/XbilParser.js +0 -119
- package/lib/Parser/deprecated/LegacyGLTFLoader.js +0 -1386
- package/lib/Parser/iGLTFLoader.js +0 -168
- package/lib/Process/3dTilesProcessing.js +0 -304
- package/lib/Process/FeatureProcessing.js +0 -76
- package/lib/Process/LayeredMaterialNodeProcessing.js +0 -221
- package/lib/Process/ObjectRemovalHelper.js +0 -97
- package/lib/Process/handlerNodeError.js +0 -23
- package/lib/Provider/3dTilesProvider.js +0 -149
- package/lib/Provider/DataSourceProvider.js +0 -8
- package/lib/Provider/Fetcher.js +0 -229
- package/lib/Provider/PointCloudProvider.js +0 -45
- package/lib/Provider/TileProvider.js +0 -16
- package/lib/Provider/URLBuilder.js +0 -116
- package/lib/Renderer/Camera.js +0 -281
- package/lib/Renderer/Color.js +0 -56
- package/lib/Renderer/ColorLayersOrdering.js +0 -115
- package/lib/Renderer/CommonMaterial.js +0 -31
- package/lib/Renderer/Label2DRenderer.js +0 -190
- package/lib/Renderer/LayeredMaterial.js +0 -243
- package/lib/Renderer/OBB.js +0 -153
- package/lib/Renderer/OrientedImageCamera.js +0 -118
- package/lib/Renderer/OrientedImageMaterial.js +0 -167
- package/lib/Renderer/PointsMaterial.js +0 -485
- package/lib/Renderer/RasterTile.js +0 -209
- package/lib/Renderer/RenderMode.js +0 -31
- package/lib/Renderer/Shader/ShaderChunk.js +0 -160
- package/lib/Renderer/Shader/ShaderUtils.js +0 -47
- package/lib/Renderer/SphereHelper.js +0 -23
- package/lib/Renderer/WebXR.js +0 -51
- package/lib/Renderer/c3DEngine.js +0 -214
- package/lib/Source/C3DTilesGoogleSource.js +0 -74
- package/lib/Source/C3DTilesIonSource.js +0 -54
- package/lib/Source/C3DTilesSource.js +0 -30
- package/lib/Source/CopcSource.js +0 -115
- package/lib/Source/EntwinePointTileSource.js +0 -62
- package/lib/Source/FileSource.js +0 -189
- package/lib/Source/OGC3DTilesGoogleSource.js +0 -29
- package/lib/Source/OGC3DTilesIonSource.js +0 -34
- package/lib/Source/OGC3DTilesSource.js +0 -21
- package/lib/Source/OrientedImageSource.js +0 -59
- package/lib/Source/Potree2Source.js +0 -167
- package/lib/Source/PotreeSource.js +0 -82
- package/lib/Source/Source.js +0 -223
- package/lib/Source/TMSSource.js +0 -145
- package/lib/Source/VectorTilesSource.js +0 -178
- package/lib/Source/WFSSource.js +0 -168
- package/lib/Source/WMSSource.js +0 -133
- package/lib/Source/WMTSSource.js +0 -86
- package/lib/ThreeExtended/capabilities/WebGL.js +0 -69
- package/lib/ThreeExtended/libs/ktx-parse.module.js +0 -470
- package/lib/ThreeExtended/libs/zstddec.module.js +0 -29
- package/lib/ThreeExtended/loaders/DDSLoader.js +0 -200
- package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -399
- package/lib/ThreeExtended/loaders/GLTFLoader.js +0 -2876
- package/lib/ThreeExtended/loaders/KTX2Loader.js +0 -625
- package/lib/ThreeExtended/utils/BufferGeometryUtils.js +0 -846
- package/lib/ThreeExtended/utils/WorkerPool.js +0 -70
- package/lib/Utils/CameraUtils.js +0 -555
- package/lib/Utils/DEMUtils.js +0 -350
- package/lib/Utils/FeaturesUtils.js +0 -156
- package/lib/Utils/Gradients.js +0 -16
- package/lib/Utils/OrientationUtils.js +0 -457
- package/lib/Utils/ThreeUtils.js +0 -115
- package/lib/Utils/gui/C3DTilesStyle.js +0 -215
- package/lib/Utils/gui/Main.js +0 -7
- package/lib/Utils/gui/Minimap.js +0 -154
- package/lib/Utils/gui/Navigation.js +0 -245
- package/lib/Utils/gui/Scale.js +0 -107
- package/lib/Utils/gui/Searchbar.js +0 -234
- package/lib/Utils/gui/Widget.js +0 -80
- package/lib/Utils/placeObjectOnGround.js +0 -137
- package/lib/Worker/LASLoaderWorker.js +0 -19
- package/lib/Worker/Potree2Worker.js +0 -21
package/lib/Core/Picking.js
DELETED
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
import RenderMode from "../Renderer/RenderMode.js";
|
|
3
|
-
import { unpack1K } from "../Renderer/LayeredMaterial.js";
|
|
4
|
-
import Coordinates from "./Geographic/Coordinates.js";
|
|
5
|
-
const depthRGBA = new THREE.Vector4();
|
|
6
|
-
// TileMesh picking support function
|
|
7
|
-
function screenCoordsToNodeId(view, tileLayer, viewCoords) {
|
|
8
|
-
let radius = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
9
|
-
const dim = view.mainLoop.gfxEngine.getWindowSize();
|
|
10
|
-
viewCoords = viewCoords || new THREE.Vector2(Math.floor(dim.x / 2), Math.floor(dim.y / 2));
|
|
11
|
-
const restore = tileLayer.level0Nodes.map(n => RenderMode.push(n, RenderMode.MODES.ID));
|
|
12
|
-
const buffer = view.mainLoop.gfxEngine.renderViewToBuffer({
|
|
13
|
-
camera: view.camera,
|
|
14
|
-
scene: tileLayer.object3d
|
|
15
|
-
}, {
|
|
16
|
-
x: viewCoords.x - radius,
|
|
17
|
-
y: viewCoords.y - radius,
|
|
18
|
-
width: 1 + radius * 2,
|
|
19
|
-
height: 1 + radius * 2
|
|
20
|
-
});
|
|
21
|
-
restore.forEach(r => r());
|
|
22
|
-
const ids = [];
|
|
23
|
-
traversePickingCircle(radius, (x, y) => {
|
|
24
|
-
const idx = (y * 2 * radius + x) * 4;
|
|
25
|
-
const data = buffer.slice(idx, idx + 4 || undefined);
|
|
26
|
-
depthRGBA.fromArray(data).divideScalar(255.0);
|
|
27
|
-
const unpack = unpack1K(depthRGBA, 256 ** 3);
|
|
28
|
-
const _id = Math.round(unpack);
|
|
29
|
-
if (!ids.includes(_id)) {
|
|
30
|
-
ids.push(_id);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
return ids;
|
|
34
|
-
}
|
|
35
|
-
function traversePickingCircle(radius, callback) {
|
|
36
|
-
// iterate on radius so we get closer to the mouse
|
|
37
|
-
// results first.
|
|
38
|
-
// Result traversal order for radius=2
|
|
39
|
-
// --3--
|
|
40
|
-
// -323-
|
|
41
|
-
// 32123
|
|
42
|
-
// -323
|
|
43
|
-
// --3--
|
|
44
|
-
let prevSq;
|
|
45
|
-
for (let r = 0; r <= radius; r++) {
|
|
46
|
-
const sq = r * r;
|
|
47
|
-
for (let x = -r; x <= r; x++) {
|
|
48
|
-
const sqx = x * x;
|
|
49
|
-
for (let y = -r; y <= r; y++) {
|
|
50
|
-
const dist = sqx + y * y;
|
|
51
|
-
// skip if too far
|
|
52
|
-
if (dist > sq) {
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
// skip if belongs to previous
|
|
56
|
-
if (dist <= prevSq) {
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
if (callback(x, y) === false) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
prevSq = sq;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
function findLayerInParent(obj) {
|
|
68
|
-
if (obj.layer) {
|
|
69
|
-
return obj.layer;
|
|
70
|
-
}
|
|
71
|
-
if (obj.parent) {
|
|
72
|
-
return findLayerInParent(obj.parent);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
const raycaster = new THREE.Raycaster();
|
|
76
|
-
const normalized = new THREE.Vector2();
|
|
77
|
-
const pointPos = new THREE.Vector3();
|
|
78
|
-
const pointPosCoord = new Coordinates('EPSG:4978'); // default crs, will be set to view crs when used
|
|
79
|
-
const cameraPos = new THREE.Vector3();
|
|
80
|
-
const cameraPosCoord = new Coordinates('EPSG:4978'); // default crs, will be set to view crs when used
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* @module Picking
|
|
84
|
-
*
|
|
85
|
-
* Implement various picking methods for geometry layers.
|
|
86
|
-
* These methods are not meant to be used directly, see View.pickObjectsAt
|
|
87
|
-
* instead.
|
|
88
|
-
*
|
|
89
|
-
* All the methods here takes the same parameters:
|
|
90
|
-
* - the View instance
|
|
91
|
-
* - view coordinates (in pixels) where picking should be done
|
|
92
|
-
* - radius (in pixels) of the picking circle
|
|
93
|
-
* - layer: the geometry layer used for picking
|
|
94
|
-
*/
|
|
95
|
-
export default {
|
|
96
|
-
pickTilesAt(view, viewCoords, radius, layer) {
|
|
97
|
-
let results = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
98
|
-
const _ids = screenCoordsToNodeId(view, layer, viewCoords, radius);
|
|
99
|
-
const extractResult = node => {
|
|
100
|
-
if (_ids.includes(node.id) && node.isTileMesh) {
|
|
101
|
-
results.push({
|
|
102
|
-
object: node,
|
|
103
|
-
layer
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
for (const n of layer.level0Nodes) {
|
|
108
|
-
n.traverse(extractResult);
|
|
109
|
-
}
|
|
110
|
-
return results;
|
|
111
|
-
},
|
|
112
|
-
pickPointsAt(view, viewCoords, radius, layer) {
|
|
113
|
-
let result = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
114
|
-
if (!layer.root) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// enable picking mode for points material
|
|
119
|
-
layer.object3d.traverse(o => {
|
|
120
|
-
if (o.isPoints && o.baseId) {
|
|
121
|
-
o.material.enablePicking(true);
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
// render 1 pixel
|
|
126
|
-
// TODO: support more than 1 pixel selection
|
|
127
|
-
const buffer = view.mainLoop.gfxEngine.renderViewToBuffer({
|
|
128
|
-
camera: view.camera,
|
|
129
|
-
scene: layer.object3d
|
|
130
|
-
}, {
|
|
131
|
-
x: viewCoords.x - radius,
|
|
132
|
-
y: viewCoords.y - radius,
|
|
133
|
-
width: 1 + radius * 2,
|
|
134
|
-
height: 1 + radius * 2
|
|
135
|
-
});
|
|
136
|
-
const candidates = [];
|
|
137
|
-
traversePickingCircle(radius, (x, y) => {
|
|
138
|
-
const idx = (y * 2 * radius + x) * 4;
|
|
139
|
-
const data = buffer.slice(idx, idx + 4);
|
|
140
|
-
|
|
141
|
-
// see PotreeProvider and the construction of unique_id
|
|
142
|
-
const objId = data[0] << 8 | data[1];
|
|
143
|
-
const index = data[2] << 8 | data[3];
|
|
144
|
-
const r = {
|
|
145
|
-
objId,
|
|
146
|
-
index
|
|
147
|
-
};
|
|
148
|
-
for (let i = 0; i < candidates.length; i++) {
|
|
149
|
-
if (candidates[i].objId == r.objId && candidates[i].index == r.index) {
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
candidates.push(r);
|
|
154
|
-
});
|
|
155
|
-
layer.object3d.traverse(o => {
|
|
156
|
-
if (o.isPoints && o.baseId) {
|
|
157
|
-
// disable picking mode
|
|
158
|
-
o.material.enablePicking(false);
|
|
159
|
-
|
|
160
|
-
// if baseId matches objId, the clicked point belongs to `o`
|
|
161
|
-
for (let i = 0; i < candidates.length; i++) {
|
|
162
|
-
if (candidates[i].objId == o.baseId) {
|
|
163
|
-
// Get point position: get the picked point from the buffer geometry and apply local to world
|
|
164
|
-
// transform of the picked object
|
|
165
|
-
pointPos.fromBufferAttribute(o.geometry.attributes.position, candidates[i].index);
|
|
166
|
-
o.localToWorld(pointPos);
|
|
167
|
-
// Compute distance to the camera
|
|
168
|
-
pointPosCoord.setCrs(view.referenceCrs);
|
|
169
|
-
pointPosCoord.setFromVector3(pointPos);
|
|
170
|
-
view.camera3D.getWorldPosition(cameraPos);
|
|
171
|
-
cameraPosCoord.setCrs(view.referenceCrs);
|
|
172
|
-
cameraPosCoord.setFromVector3(cameraPos);
|
|
173
|
-
const dist = pointPosCoord.spatialEuclideanDistanceTo(cameraPosCoord);
|
|
174
|
-
result.push({
|
|
175
|
-
object: o,
|
|
176
|
-
point: pointPos.clone(),
|
|
177
|
-
// the position of the point in the 3D view. Same name and value than what's returned by pickObjectsAt
|
|
178
|
-
index: candidates[i].index,
|
|
179
|
-
distance: dist,
|
|
180
|
-
layer
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
return result;
|
|
187
|
-
},
|
|
188
|
-
/*
|
|
189
|
-
* Default picking method. Uses THREE.Raycaster
|
|
190
|
-
*/
|
|
191
|
-
pickObjectsAt(view, viewCoords, radius, object) {
|
|
192
|
-
let target = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
193
|
-
// Raycaster use NDC coordinate
|
|
194
|
-
view.viewToNormalizedCoords(viewCoords, normalized);
|
|
195
|
-
if (radius < 0) {
|
|
196
|
-
raycaster.setFromCamera(normalized, view.camera3D);
|
|
197
|
-
const intersects = raycaster.intersectObject(object, true);
|
|
198
|
-
for (const inter of intersects) {
|
|
199
|
-
inter.layer = findLayerInParent(inter.object);
|
|
200
|
-
target.push(inter);
|
|
201
|
-
}
|
|
202
|
-
return target;
|
|
203
|
-
}
|
|
204
|
-
// Instead of doing N raycast (1 per x,y returned by traversePickingCircle),
|
|
205
|
-
// we force render the zone of interest.
|
|
206
|
-
// Then we'll only do raycasting for the pixels where something was drawn.
|
|
207
|
-
const zone = {
|
|
208
|
-
x: viewCoords.x - radius,
|
|
209
|
-
y: viewCoords.y - radius,
|
|
210
|
-
width: 1 + radius * 2,
|
|
211
|
-
height: 1 + radius * 2
|
|
212
|
-
};
|
|
213
|
-
const pixels = view.mainLoop.gfxEngine.renderViewToBuffer({
|
|
214
|
-
scene: object,
|
|
215
|
-
camera: view.camera
|
|
216
|
-
}, zone);
|
|
217
|
-
const clearColor = new THREE.Color();
|
|
218
|
-
view.mainLoop.gfxEngine.renderer.getClearColor(clearColor);
|
|
219
|
-
const clearR = Math.round(255 * clearColor.r);
|
|
220
|
-
const clearG = Math.round(255 * clearColor.g);
|
|
221
|
-
const clearB = Math.round(255 * clearColor.b);
|
|
222
|
-
|
|
223
|
-
// Raycaster use NDC coordinate
|
|
224
|
-
const tmp = normalized.clone();
|
|
225
|
-
traversePickingCircle(radius, (x, y) => {
|
|
226
|
-
// x, y are offset from the center of the picking circle,
|
|
227
|
-
// and pixels is a square where 0, 0 is the top-left corner.
|
|
228
|
-
// So we need to shift x,y by radius.
|
|
229
|
-
|
|
230
|
-
const offset = ((y + radius) * (radius * 2 + 1) + (x + radius)) * 4;
|
|
231
|
-
const r = pixels[offset];
|
|
232
|
-
const g = pixels[offset + 1];
|
|
233
|
-
const b = pixels[offset + 2];
|
|
234
|
-
// Use approx. test to avoid rounding error or to behave
|
|
235
|
-
// differently depending on hardware rounding mode.
|
|
236
|
-
if (Math.abs(clearR - r) <= 1 && Math.abs(clearG - g) <= 1 && Math.abs(clearB - b) <= 1) {
|
|
237
|
-
// skip because nothing has been rendered here
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
// Perform raycasting
|
|
242
|
-
tmp.setX(normalized.x + x / view.camera.width).setY(normalized.y + y / view.camera.height);
|
|
243
|
-
raycaster.setFromCamera(tmp, view.camera3D);
|
|
244
|
-
const intersects = raycaster.intersectObject(object, true);
|
|
245
|
-
for (const inter of intersects) {
|
|
246
|
-
inter.layer = findLayerInParent(inter.object);
|
|
247
|
-
target.push(inter);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// Stop at first hit
|
|
251
|
-
return target.length == 0;
|
|
252
|
-
});
|
|
253
|
-
return target;
|
|
254
|
-
}
|
|
255
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
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;
|
package/lib/Core/Potree2Node.js
DELETED
|
@@ -1,206 +0,0 @@
|
|
|
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;
|
|
@@ -1,139 +0,0 @@
|
|
|
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
|
-
}
|