itowns 2.43.2-next.2 → 2.43.2-next.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/558.js +2 -0
- package/dist/558.js.map +1 -0
- package/dist/debug.js +1 -1
- package/dist/debug.js.map +1 -1
- package/dist/itowns.js +1 -1
- package/dist/itowns.js.map +1 -1
- package/dist/itowns_lasparser.js +2 -0
- package/dist/itowns_lasparser.js.map +1 -0
- package/dist/itowns_lasworker.js +2 -0
- package/dist/itowns_lasworker.js.map +1 -0
- package/dist/itowns_potree2worker.js +2 -0
- package/dist/itowns_potree2worker.js.map +1 -0
- package/dist/itowns_widgets.js +1 -1
- package/dist/itowns_widgets.js.map +1 -1
- package/examples/3dtiles_25d.html +1 -1
- package/examples/3dtiles_basic.html +2 -2
- package/examples/3dtiles_batch_table.html +1 -3
- package/examples/3dtiles_pointcloud.html +9 -15
- package/examples/config.json +1 -0
- package/examples/copc_simple_loader.html +1 -1
- package/examples/entwine_3d_loader.html +1 -1
- package/examples/entwine_simple_loader.html +1 -1
- package/examples/js/plugins/COGParser.js +84 -50
- package/examples/js/plugins/COGSource.js +7 -4
- package/examples/layers/JSONLayers/OPENSM.json +1 -1
- package/examples/potree2_25d_map.html +127 -0
- package/examples/potree_25d_map.html +1 -1
- package/examples/potree_3d_map.html +1 -1
- package/examples/source_file_cog.html +22 -5
- package/lib/Controls/FirstPersonControls.js +0 -1
- package/lib/Controls/FlyControls.js +0 -1
- package/lib/Converter/Feature2Mesh.js +2 -4
- package/lib/Converter/textureConverter.js +1 -1
- package/lib/Core/3DTiles/C3DTBatchTable.js +1 -1
- package/lib/Core/3DTiles/C3DTFeature.js +6 -7
- package/lib/Core/Feature.js +1 -2
- package/lib/Core/Geographic/CoordStars.js +0 -1
- package/lib/Core/Label.js +0 -1
- package/lib/Core/MainLoop.js +0 -1
- package/lib/Core/Potree2Node.js +206 -0
- package/lib/Core/Potree2PointAttributes.js +139 -0
- package/lib/Core/Prefab/Globe/Atmosphere.js +0 -4
- package/lib/Core/Prefab/Globe/GlobeLayer.js +3 -3
- package/lib/Core/Scheduler/Scheduler.js +1 -1
- package/lib/Core/Style.js +54 -53
- package/lib/Core/View.js +2 -4
- package/lib/Layer/C3DTilesLayer.js +8 -6
- package/lib/Layer/ElevationLayer.js +2 -3
- package/lib/Layer/GeoidLayer.js +1 -2
- package/lib/Layer/LabelLayer.js +8 -17
- package/lib/Layer/Layer.js +4 -2
- package/lib/Layer/PointCloudLayer.js +5 -8
- package/lib/Layer/Potree2Layer.js +165 -0
- package/lib/Layer/ReferencingLayerProperties.js +8 -3
- package/lib/Layer/TiledGeometryLayer.js +6 -4
- package/lib/Loader/Potree2BrotliLoader.js +261 -0
- package/lib/Loader/Potree2Loader.js +207 -0
- package/lib/Main.js +2 -0
- package/lib/Parser/GeoJsonParser.js +2 -3
- package/lib/Parser/LASParser.js +49 -18
- package/lib/Parser/Potree2BinParser.js +92 -0
- package/lib/Parser/deprecated/LegacyGLTFLoader.js +1 -2
- package/lib/Process/3dTilesProcessing.js +2 -1
- package/lib/Process/FeatureProcessing.js +1 -2
- package/lib/Process/LayeredMaterialNodeProcessing.js +3 -9
- package/lib/Process/ObjectRemovalHelper.js +1 -2
- package/lib/Provider/3dTilesProvider.js +3 -2
- package/lib/Renderer/ColorLayersOrdering.js +1 -2
- package/lib/Renderer/Label2DRenderer.js +1 -4
- package/lib/Renderer/PointsMaterial.js +135 -100
- package/lib/Renderer/RenderMode.js +0 -1
- package/lib/Source/FileSource.js +1 -1
- package/lib/Source/Potree2Source.js +172 -0
- package/lib/ThreeExtended/loaders/DDSLoader.js +11 -1
- package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -1
- package/lib/ThreeExtended/loaders/GLTFLoader.js +1 -0
- package/lib/Utils/DEMUtils.js +2 -2
- package/lib/Utils/OrientationUtils.js +0 -1
- package/lib/Utils/gui/Searchbar.js +1 -2
- package/lib/Worker/LASLoaderWorker.js +19 -0
- package/lib/Worker/Potree2Worker.js +21 -0
- package/package.json +11 -8
- /package/lib/{Parser → Loader}/LASLoader.js +0 -0
package/lib/Layer/LabelLayer.js
CHANGED
|
@@ -195,11 +195,9 @@ class LabelLayer extends GeometryLayer {
|
|
|
195
195
|
set visible(value) {
|
|
196
196
|
super.visible = value;
|
|
197
197
|
if (value) {
|
|
198
|
-
|
|
199
|
-
(_this$domElement = this.domElement) === null || _this$domElement === void 0 ? void 0 : _this$domElement.show();
|
|
198
|
+
this.domElement?.show();
|
|
200
199
|
} else {
|
|
201
|
-
|
|
202
|
-
(_this$domElement2 = this.domElement) === null || _this$domElement2 === void 0 ? void 0 : _this$domElement2.hide();
|
|
200
|
+
this.domElement?.hide();
|
|
203
201
|
}
|
|
204
202
|
}
|
|
205
203
|
get submittedLabelNodes() {
|
|
@@ -231,16 +229,15 @@ class LabelLayer extends GeometryLayer {
|
|
|
231
229
|
coord.crs = data.crs;
|
|
232
230
|
context.setZoom(extent.zoom);
|
|
233
231
|
data.features.forEach(f => {
|
|
234
|
-
var _f$style, _f$style$text, _f$style2, _f$style2$point;
|
|
235
232
|
// TODO: add support for LINE and POLYGON
|
|
236
233
|
if (f.type !== FEATURE_TYPES.POINT) {
|
|
237
234
|
return;
|
|
238
235
|
}
|
|
239
236
|
context.setFeature(f);
|
|
240
|
-
const featureField =
|
|
237
|
+
const featureField = f.style?.text?.field;
|
|
241
238
|
|
|
242
239
|
// determine if altitude style is specified by the user
|
|
243
|
-
const altitudeStyle =
|
|
240
|
+
const altitudeStyle = f.style?.point?.base_altitude;
|
|
244
241
|
const isDefaultElevationStyle = altitudeStyle instanceof Function && altitudeStyle.name == 'baseAltitudeDefault';
|
|
245
242
|
|
|
246
243
|
// determine if the altitude needs update with ElevationLayer
|
|
@@ -292,19 +289,14 @@ class LabelLayer extends GeometryLayer {
|
|
|
292
289
|
this.toHide.add(labelsNode);
|
|
293
290
|
}
|
|
294
291
|
#findClosestDomElement(node) {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
var _node$parent$link$thi;
|
|
298
|
-
return ((_node$parent$link$thi = node.parent.link[this.id]) === null || _node$parent$link$thi === void 0 ? void 0 : _node$parent$link$thi.domElements) || this.#findClosestDomElement(node.parent);
|
|
292
|
+
if (node.parent?.isTileMesh) {
|
|
293
|
+
return node.parent.link[this.id]?.domElements || this.#findClosestDomElement(node.parent);
|
|
299
294
|
} else {
|
|
300
295
|
return this.domElement;
|
|
301
296
|
}
|
|
302
297
|
}
|
|
303
298
|
#hasLabelChildren(object) {
|
|
304
|
-
return object.children.every(c =>
|
|
305
|
-
var _c$layerUpdateState$t;
|
|
306
|
-
return c.layerUpdateState && ((_c$layerUpdateState$t = c.layerUpdateState[this.id]) === null || _c$layerUpdateState$t === void 0 ? void 0 : _c$layerUpdateState$t.hasFinished());
|
|
307
|
-
});
|
|
299
|
+
return object.children.every(c => c.layerUpdateState && c.layerUpdateState[this.id]?.hasFinished());
|
|
308
300
|
}
|
|
309
301
|
|
|
310
302
|
// Remove all labels invisible with pre-culling with screen grid
|
|
@@ -439,8 +431,7 @@ class LabelLayer extends GeometryLayer {
|
|
|
439
431
|
this.removeNodeDomElement(node);
|
|
440
432
|
}
|
|
441
433
|
removeNodeDomElement(node) {
|
|
442
|
-
|
|
443
|
-
if ((_node$link$this$id = node.link[this.id]) !== null && _node$link$this$id !== void 0 && _node$link$this$id.domElements) {
|
|
434
|
+
if (node.link[this.id]?.domElements) {
|
|
444
435
|
const child = node.link[this.id].domElements.dom;
|
|
445
436
|
child.parentElement.removeChild(child);
|
|
446
437
|
delete node.link[this.id].domElements;
|
package/lib/Layer/Layer.js
CHANGED
|
@@ -66,6 +66,7 @@ class Layer extends THREE.EventDispatcher {
|
|
|
66
66
|
* @param {boolean} [config.addLabelLayer.performance=false] - In case label layer adding, so remove labels that have no chance of being visible.
|
|
67
67
|
* Indeed, even in the best case, labels will never be displayed. By example, if there's many labels.
|
|
68
68
|
* @param {boolean} [config.addLabelLayer.forceClampToTerrain=false] - use elevation layer to clamp label on terrain.
|
|
69
|
+
* @param {number} [config.subdivisionThreshold=256] - set the texture size and, if applied to the globe, affects the tile subdivision.
|
|
69
70
|
*
|
|
70
71
|
* @example
|
|
71
72
|
* // Add and create a new Layer
|
|
@@ -100,8 +101,7 @@ class Layer extends THREE.EventDispatcher {
|
|
|
100
101
|
super();
|
|
101
102
|
this.isLayer = true;
|
|
102
103
|
if (config.style && !(config.style instanceof Style)) {
|
|
103
|
-
|
|
104
|
-
if (typeof ((_config$style$fill = config.style.fill) === null || _config$style$fill === void 0 ? void 0 : _config$style$fill.pattern) === 'string') {
|
|
104
|
+
if (typeof config.style.fill?.pattern === 'string') {
|
|
105
105
|
console.warn('Using style.fill.pattern = { source: Img|url } is adviced');
|
|
106
106
|
config.style.fill.pattern = {
|
|
107
107
|
source: config.style.fill.pattern
|
|
@@ -110,6 +110,8 @@ class Layer extends THREE.EventDispatcher {
|
|
|
110
110
|
config.style = new Style(config.style);
|
|
111
111
|
}
|
|
112
112
|
this.style = config.style || new Style();
|
|
113
|
+
this.subdivisionThreshold = config.subdivisionThreshold || 256;
|
|
114
|
+
this.sizeDiagonalTexture = (2 * (this.subdivisionThreshold * this.subdivisionThreshold)) ** 0.5;
|
|
113
115
|
Object.assign(this, config);
|
|
114
116
|
Object.defineProperty(this, 'id', {
|
|
115
117
|
value: id,
|
|
@@ -73,16 +73,13 @@ function markForDeletion(elt) {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
function changeIntensityRange(layer) {
|
|
76
|
-
|
|
77
|
-
(_layer$material$inten = layer.material.intensityRange) === null || _layer$material$inten === void 0 ? void 0 : _layer$material$inten.set(layer.minIntensityRange, layer.maxIntensityRange);
|
|
76
|
+
layer.material.intensityRange?.set(layer.minIntensityRange, layer.maxIntensityRange);
|
|
78
77
|
}
|
|
79
78
|
function changeElevationRange(layer) {
|
|
80
|
-
|
|
81
|
-
(_layer$material$eleva = layer.material.elevationRange) === null || _layer$material$eleva === void 0 ? void 0 : _layer$material$eleva.set(layer.minElevationRange, layer.maxElevationRange);
|
|
79
|
+
layer.material.elevationRange?.set(layer.minElevationRange, layer.maxElevationRange);
|
|
82
80
|
}
|
|
83
81
|
function changeAngleRange(layer) {
|
|
84
|
-
|
|
85
|
-
(_layer$material$angle = layer.material.angleRange) === null || _layer$material$angle === void 0 ? void 0 : _layer$material$angle.set(layer.minAngleRange, layer.maxAngleRange);
|
|
82
|
+
layer.material.angleRange?.set(layer.minAngleRange, layer.maxAngleRange);
|
|
86
83
|
}
|
|
87
84
|
|
|
88
85
|
/**
|
|
@@ -137,7 +134,7 @@ class PointCloudLayer extends GeometryLayer {
|
|
|
137
134
|
*/
|
|
138
135
|
constructor(id) {
|
|
139
136
|
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
140
|
-
super(id, new THREE.Group(), config);
|
|
137
|
+
super(id, config.object3d || new THREE.Group(), config);
|
|
141
138
|
this.isPointCloudLayer = true;
|
|
142
139
|
this.protocol = 'pointcloud';
|
|
143
140
|
this.group = config.group || new THREE.Group();
|
|
@@ -176,7 +173,7 @@ class PointCloudLayer extends GeometryLayer {
|
|
|
176
173
|
if (this.material) {
|
|
177
174
|
this.material.visible = this.visible;
|
|
178
175
|
this.material.opacity = this.opacity;
|
|
179
|
-
this.material.transparent = this.opacity < 1;
|
|
176
|
+
this.material.transparent = this.opacity < 1 || this.material.userData.needTransparency[this.material.mode];
|
|
180
177
|
this.material.size = this.pointSize;
|
|
181
178
|
this.material.scale = context.camera.preSSE;
|
|
182
179
|
if (this.material.updateUniforms) {
|
|
@@ -0,0 +1,165 @@
|
|
|
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 PointCloudLayer from "./PointCloudLayer.js";
|
|
38
|
+
import Potree2Node from "../Core/Potree2Node.js";
|
|
39
|
+
import Extent from "../Core/Geographic/Extent.js";
|
|
40
|
+
import { PointAttribute, Potree2PointAttributes, PointAttributeTypes } from "../Core/Potree2PointAttributes.js";
|
|
41
|
+
const bboxMesh = new THREE.Mesh();
|
|
42
|
+
const box3 = new THREE.Box3();
|
|
43
|
+
bboxMesh.geometry.boundingBox = box3;
|
|
44
|
+
const typeNameAttributeMap = {
|
|
45
|
+
double: PointAttributeTypes.DATA_TYPE_DOUBLE,
|
|
46
|
+
float: PointAttributeTypes.DATA_TYPE_FLOAT,
|
|
47
|
+
int8: PointAttributeTypes.DATA_TYPE_INT8,
|
|
48
|
+
uint8: PointAttributeTypes.DATA_TYPE_UINT8,
|
|
49
|
+
int16: PointAttributeTypes.DATA_TYPE_INT16,
|
|
50
|
+
uint16: PointAttributeTypes.DATA_TYPE_UINT16,
|
|
51
|
+
int32: PointAttributeTypes.DATA_TYPE_INT32,
|
|
52
|
+
uint32: PointAttributeTypes.DATA_TYPE_UINT32,
|
|
53
|
+
int64: PointAttributeTypes.DATA_TYPE_INT64,
|
|
54
|
+
uint64: PointAttributeTypes.DATA_TYPE_UINT64
|
|
55
|
+
};
|
|
56
|
+
function parseAttributes(jsonAttributes) {
|
|
57
|
+
const attributes = new Potree2PointAttributes();
|
|
58
|
+
const replacements = {
|
|
59
|
+
rgb: 'rgba'
|
|
60
|
+
};
|
|
61
|
+
for (const jsonAttribute of jsonAttributes) {
|
|
62
|
+
const {
|
|
63
|
+
name,
|
|
64
|
+
numElements,
|
|
65
|
+
min,
|
|
66
|
+
max
|
|
67
|
+
} = jsonAttribute;
|
|
68
|
+
const type = typeNameAttributeMap[jsonAttribute.type];
|
|
69
|
+
const potreeAttributeName = replacements[name] ? replacements[name] : name;
|
|
70
|
+
const attribute = new PointAttribute(potreeAttributeName, type, numElements);
|
|
71
|
+
if (numElements === 1) {
|
|
72
|
+
attribute.range = [min[0], max[0]];
|
|
73
|
+
} else {
|
|
74
|
+
attribute.range = [min, max];
|
|
75
|
+
}
|
|
76
|
+
if (name === 'gps-time') {
|
|
77
|
+
// HACK: Guard against bad gpsTime range in metadata, see potree/potree#909
|
|
78
|
+
if (attribute.range[0] === attribute.range[1]) {
|
|
79
|
+
attribute.range[1] += 1;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
attribute.initialRange = attribute.range;
|
|
83
|
+
attributes.add(attribute);
|
|
84
|
+
}
|
|
85
|
+
{
|
|
86
|
+
// check if it has normals
|
|
87
|
+
const hasNormals = attributes.attributes.find(a => a.name === 'NormalX') !== undefined && attributes.attributes.find(a => a.name === 'NormalY') !== undefined && attributes.attributes.find(a => a.name === 'NormalZ') !== undefined;
|
|
88
|
+
if (hasNormals) {
|
|
89
|
+
attributes.addVector({
|
|
90
|
+
name: 'NORMAL',
|
|
91
|
+
attributes: ['NormalX', 'NormalY', 'NormalZ']
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return attributes;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @property {boolean} isPotreeLayer - Used to checkout whether this layer
|
|
100
|
+
* is a Potree2Layer. Default is `true`. You should not change this, as it is
|
|
101
|
+
* used internally for optimisation.
|
|
102
|
+
*/
|
|
103
|
+
class Potree2Layer extends PointCloudLayer {
|
|
104
|
+
/**
|
|
105
|
+
* Constructs a new instance of Potree2 layer.
|
|
106
|
+
*
|
|
107
|
+
* @constructor
|
|
108
|
+
* @extends PointCloudLayer
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* // Create a new point cloud layer
|
|
112
|
+
* const points = new Potree2Layer('points',
|
|
113
|
+
* {
|
|
114
|
+
* source: new Potree2Source({
|
|
115
|
+
* url: 'https://pointsClouds/',
|
|
116
|
+
* file: 'metadata.json',
|
|
117
|
+
* }
|
|
118
|
+
* });
|
|
119
|
+
*
|
|
120
|
+
* View.prototype.addLayer.call(view, points);
|
|
121
|
+
*
|
|
122
|
+
* @param {string} id - The id of the layer, that should be unique. It is
|
|
123
|
+
* not mandatory, but an error will be emitted if this layer is added a
|
|
124
|
+
* {@link View} that already has a layer going by that id.
|
|
125
|
+
* @param {Object} config - Configuration, all elements in it
|
|
126
|
+
* will be merged as is in the layer. For example, if the configuration
|
|
127
|
+
* contains three elements `name, protocol, extent`, these elements will be
|
|
128
|
+
* available using `layer.name` or something else depending on the property
|
|
129
|
+
* name. See the list of properties to know which one can be specified.
|
|
130
|
+
* @param {string} [config.crs=ESPG:4326] - The CRS of the {@link View} this
|
|
131
|
+
* layer will be attached to. This is used to determine the extent of this
|
|
132
|
+
* layer. Default to `EPSG:4326`.
|
|
133
|
+
*/
|
|
134
|
+
constructor(id, config) {
|
|
135
|
+
super(id, config);
|
|
136
|
+
this.isPotreeLayer = true;
|
|
137
|
+
const resolve = this.addInitializationStep();
|
|
138
|
+
this.source.whenReady.then(metadata => {
|
|
139
|
+
this.scale = new THREE.Vector3(1, 1, 1);
|
|
140
|
+
this.metadata = metadata;
|
|
141
|
+
this.pointAttributes = parseAttributes(metadata.attributes);
|
|
142
|
+
this.spacing = metadata.spacing;
|
|
143
|
+
const normal = Array.isArray(this.pointAttributes.attributes) && this.pointAttributes.attributes.find(elem => elem.name.startsWith('NORMAL'));
|
|
144
|
+
if (normal) {
|
|
145
|
+
this.material.defines[normal.name] = 1;
|
|
146
|
+
}
|
|
147
|
+
const min = new THREE.Vector3(...metadata.boundingBox.min);
|
|
148
|
+
const max = new THREE.Vector3(...metadata.boundingBox.max);
|
|
149
|
+
const boundingBox = new THREE.Box3(min, max);
|
|
150
|
+
const root = new Potree2Node(0, 0, this);
|
|
151
|
+
root.bbox = boundingBox;
|
|
152
|
+
root.boundingSphere = boundingBox.getBoundingSphere(new THREE.Sphere());
|
|
153
|
+
root.id = 'r';
|
|
154
|
+
root.depth = 0;
|
|
155
|
+
root.nodeType = 2;
|
|
156
|
+
root.hierarchyByteOffset = 0n;
|
|
157
|
+
root.hierarchyByteSize = BigInt(metadata.hierarchy.firstChunkSize);
|
|
158
|
+
root.byteOffset = 0;
|
|
159
|
+
this.root = root;
|
|
160
|
+
this.extent = Extent.fromBox3(this.source.crs || 'EPSG:4326', boundingBox);
|
|
161
|
+
return this.root.loadOctree().then(resolve);
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
export default Potree2Layer;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// next step is move these properties to Style class
|
|
2
2
|
// and hide transparent mechanism
|
|
3
|
-
|
|
4
3
|
function ReferLayerProperties(material, layer) {
|
|
5
4
|
if (layer && layer.isGeometryLayer) {
|
|
6
5
|
let transparent = material.transparent;
|
|
@@ -39,14 +38,20 @@ function ReferLayerProperties(material, layer) {
|
|
|
39
38
|
get: () => material.layer.pntsMaxAttenuatedSize
|
|
40
39
|
});
|
|
41
40
|
}
|
|
41
|
+
if (material.uniforms && material.uniforms.scale != undefined) {
|
|
42
|
+
Object.defineProperty(material.uniforms.scale, 'value', {
|
|
43
|
+
get: () => material.layer.scale
|
|
44
|
+
});
|
|
45
|
+
}
|
|
42
46
|
Object.defineProperty(material, 'wireframe', {
|
|
43
47
|
get: () => material.layer.wireframe
|
|
44
48
|
});
|
|
45
49
|
Object.defineProperty(material, 'transparent', {
|
|
46
50
|
get: () => {
|
|
47
|
-
|
|
51
|
+
const needTransparency = material.userData.needTransparency?.[material.mode] || material.layer.opacity < 1.0;
|
|
52
|
+
if (transparent != needTransparency) {
|
|
48
53
|
material.needsUpdate = true;
|
|
49
|
-
transparent =
|
|
54
|
+
transparent = needTransparency;
|
|
50
55
|
}
|
|
51
56
|
return transparent;
|
|
52
57
|
}
|
|
@@ -4,7 +4,6 @@ import { InfoTiledGeometryLayer } from "./InfoLayer.js";
|
|
|
4
4
|
import Picking from "../Core/Picking.js";
|
|
5
5
|
import convertToTile from "../Converter/convertToTile.js";
|
|
6
6
|
import ObjectRemovalHelper from "../Process/ObjectRemovalHelper.js";
|
|
7
|
-
import { SIZE_DIAGONAL_TEXTURE } from "../Process/LayeredMaterialNodeProcessing.js";
|
|
8
7
|
import { ImageryLayers } from "./Layer.js";
|
|
9
8
|
import { CACHE_POLICIES } from "../Core/Scheduler/Cache.js";
|
|
10
9
|
const subdivisionVector = new THREE.Vector3();
|
|
@@ -68,7 +67,7 @@ class TiledGeometryLayer extends GeometryLayer {
|
|
|
68
67
|
// TODO : this should be add in a preprocess method specific to GeoidLayer.
|
|
69
68
|
this.object3d.geoidHeight = 0;
|
|
70
69
|
this.protocol = 'tile';
|
|
71
|
-
this._hideSkirt =
|
|
70
|
+
this._hideSkirt = !!config.hideSkirt;
|
|
72
71
|
this.sseSubdivisionThreshold = this.sseSubdivisionThreshold || 1.0;
|
|
73
72
|
this.schemeTile = schemeTile;
|
|
74
73
|
this.builder = builder;
|
|
@@ -89,12 +88,15 @@ class TiledGeometryLayer extends GeometryLayer {
|
|
|
89
88
|
this.object3d.add(...level0s);
|
|
90
89
|
this.object3d.updateMatrixWorld();
|
|
91
90
|
}));
|
|
92
|
-
this.maxScreenSizeNode = this.sseSubdivisionThreshold * (
|
|
91
|
+
this.maxScreenSizeNode = this.sseSubdivisionThreshold * (this.sizeDiagonalTexture * 2);
|
|
93
92
|
}
|
|
94
93
|
get hideSkirt() {
|
|
95
94
|
return this._hideSkirt;
|
|
96
95
|
}
|
|
97
96
|
set hideSkirt(value) {
|
|
97
|
+
if (!this.level0Nodes) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
98
100
|
this._hideSkirt = value;
|
|
99
101
|
for (const node of this.level0Nodes) {
|
|
100
102
|
node.traverse(obj => {
|
|
@@ -408,7 +410,7 @@ class TiledGeometryLayer extends GeometryLayer {
|
|
|
408
410
|
|
|
409
411
|
// The screen space error is calculated to have a correct texture display.
|
|
410
412
|
// For the projection of a texture's texel to be less than or equal to one pixel
|
|
411
|
-
const sse = node.screenSize / (
|
|
413
|
+
const sse = node.screenSize / (this.sizeDiagonalTexture * 2);
|
|
412
414
|
return this.sseSubdivisionThreshold < sse;
|
|
413
415
|
}
|
|
414
416
|
}
|
|
@@ -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
|
+
}
|