itowns 2.43.2-next.9 → 2.44.1-next.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.
Files changed (62) hide show
  1. package/CONTRIBUTORS.md +1 -0
  2. package/changelog.md +107 -0
  3. package/dist/455.js +2 -0
  4. package/dist/455.js.map +1 -0
  5. package/dist/debug.js +1 -1
  6. package/dist/debug.js.LICENSE.txt +2 -2
  7. package/dist/debug.js.map +1 -1
  8. package/dist/itowns.js +1 -1
  9. package/dist/itowns.js.LICENSE.txt +1 -22
  10. package/dist/itowns.js.map +1 -1
  11. package/dist/itowns_lasparser.js +2 -0
  12. package/dist/itowns_lasparser.js.map +1 -0
  13. package/dist/itowns_lasworker.js +2 -0
  14. package/dist/itowns_lasworker.js.map +1 -0
  15. package/dist/itowns_potree2worker.js +2 -0
  16. package/dist/itowns_potree2worker.js.map +1 -0
  17. package/dist/itowns_widgets.js +1 -1
  18. package/dist/itowns_widgets.js.map +1 -1
  19. package/examples/3dtiles_loader.html +150 -0
  20. package/examples/config.json +5 -0
  21. package/examples/jsm/.eslintrc.cjs +38 -0
  22. package/examples/jsm/OGC3DTilesHelper.js +105 -0
  23. package/examples/misc_instancing.html +2 -1
  24. package/examples/potree2_25d_map.html +127 -0
  25. package/lib/Core/3DTiles/C3DTFeature.js +6 -6
  26. package/lib/Core/Potree2Node.js +206 -0
  27. package/lib/Core/Potree2PointAttributes.js +139 -0
  28. package/lib/Core/Scheduler/Scheduler.js +1 -1
  29. package/lib/Core/Style.js +52 -49
  30. package/lib/Core/View.js +3 -0
  31. package/lib/Layer/C3DTilesLayer.js +6 -6
  32. package/lib/Layer/OGC3DTilesLayer.js +386 -0
  33. package/lib/Layer/PointCloudLayer.js +1 -1
  34. package/lib/Layer/Potree2Layer.js +165 -0
  35. package/lib/Layer/ReferencingLayerProperties.js +5 -0
  36. package/lib/Layer/TiledGeometryLayer.js +4 -1
  37. package/lib/Loader/Potree2BrotliLoader.js +261 -0
  38. package/lib/Loader/Potree2Loader.js +207 -0
  39. package/lib/Main.js +9 -2
  40. package/lib/Parser/B3dmParser.js +11 -22
  41. package/lib/Parser/LASParser.js +48 -16
  42. package/lib/Parser/Potree2BinParser.js +92 -0
  43. package/lib/Parser/ShapefileParser.js +2 -2
  44. package/lib/Parser/deprecated/LegacyGLTFLoader.js +25 -5
  45. package/lib/Parser/iGLTFLoader.js +169 -0
  46. package/lib/Process/3dTilesProcessing.js +2 -1
  47. package/lib/Provider/3dTilesProvider.js +6 -4
  48. package/lib/Renderer/PointsMaterial.js +128 -94
  49. package/lib/Source/FileSource.js +1 -1
  50. package/lib/Source/OGC3DTilesGoogleSource.js +32 -0
  51. package/lib/Source/OGC3DTilesIonSource.js +37 -0
  52. package/lib/Source/OGC3DTilesSource.js +24 -0
  53. package/lib/Source/Potree2Source.js +172 -0
  54. package/lib/ThreeExtended/loaders/DRACOLoader.js +5 -3
  55. package/lib/ThreeExtended/loaders/GLTFLoader.js +38 -2
  56. package/lib/ThreeExtended/loaders/KTX2Loader.js +17 -10
  57. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +32 -30
  58. package/lib/Worker/LASLoaderWorker.js +19 -0
  59. package/lib/Worker/Potree2Worker.js +21 -0
  60. package/package.json +33 -31
  61. package/lib/Parser/GLTFParser.js +0 -88
  62. /package/lib/{Parser → Loader}/LASLoader.js +0 -0
@@ -0,0 +1,38 @@
1
+ module.exports = {
2
+ extends: [
3
+ 'eslint-config-airbnb-base',
4
+ 'eslint-config-airbnb-base/rules/strict',
5
+ '../.eslintrc.cjs',
6
+ ],
7
+ parserOptions: {
8
+ ecmaVersion: 13,
9
+ sourceType: 'module',
10
+ ecmaFeatures: {
11
+ impliedStrict: true,
12
+ },
13
+ },
14
+ env: {
15
+ browser: true,
16
+ es6: true,
17
+ amd: true,
18
+ commonjs: true,
19
+ },
20
+ globals: {
21
+ itowns: true,
22
+ },
23
+ rules: {
24
+ 'prefer-arrow-callback': 'off',
25
+ 'object-shorthand': 'off',
26
+ 'no-param-reassign': ['error', { props: false }],
27
+ 'no-mixed-operators': ['error', { allowSamePrecedence: true }],
28
+ 'prefer-template': 'off',
29
+ 'prefer-rest-params': 'off',
30
+ 'arrow-parens': ['error', 'as-needed', { requireForBlockBody: true }],
31
+
32
+ // deactivated rules for `examples/`
33
+ 'no-console': 'off',
34
+ // TODO reactivate all the following rules
35
+ 'no-underscore-dangle': 'off',
36
+
37
+ },
38
+ };
@@ -0,0 +1,105 @@
1
+ import { MathUtils, Vector3 } from 'three';
2
+
3
+ const { Coordinates, Extent, CameraUtils } = itowns;
4
+
5
+ /**
6
+ * Function allowing picking on a given 3D tiles layer and filling an html div
7
+ * with information on the picked feature.
8
+ * @param {MouseEvent} event
9
+ * @param {Object} pickingArg
10
+ * @param {HTMLDivElement} pickingArg.htmlDiv - div element which contains the
11
+ * picked information
12
+ * @param {GlobeView} picking.view - iTowns view where the picking must be done
13
+ * @param {OGC3DTilesLayer} pickingArg.layer - the layer on which the picking
14
+ * must be done
15
+ */
16
+ export function fillHTMLWithPickingInfo(event, pickingArg) {
17
+ const { htmlDiv, view, layer } = pickingArg;
18
+
19
+ // Remove content already in html div
20
+ while (htmlDiv.firstChild) {
21
+ htmlDiv.removeChild(htmlDiv.firstChild);
22
+ }
23
+
24
+ // Get intersected objects
25
+ const intersects = view.pickObjectsAt(event, 5, layer);
26
+
27
+ // Get information from intersected objects (from the batch table and
28
+ // eventually the 3D Tiles extensions
29
+ const closestC3DTileFeature =
30
+ layer.getC3DTileFeatureFromIntersectsArray(intersects);
31
+
32
+ if (closestC3DTileFeature) {
33
+ // eslint-disable-next-line
34
+ htmlDiv.appendChild(createHTMLListFromObject(closestC3DTileFeature));
35
+ }
36
+ }
37
+
38
+ function zoomToSphere(view, tile, sphere) {
39
+ const transform = tile.cached.transform;
40
+
41
+ const center = new Vector3().fromArray(sphere).applyMatrix4(transform);
42
+ const radius = sphere[3] * transform.getMaxScaleOnAxis();
43
+
44
+ // Get the distance to sphere where the diameter cover the whole screen
45
+ // This is similar to SSE computation where sse = screen height.
46
+ const fov = view.camera3D.fov * MathUtils.DEG2RAD;
47
+ const distance = radius * Math.tan(fov * 2);
48
+
49
+ return {
50
+ coord: new Coordinates('EPSG:4978', center),
51
+ range: distance + radius,
52
+ };
53
+ }
54
+
55
+ function zoomToBox(view, tile, box) {
56
+ const radius = Math.max(
57
+ new Vector3().fromArray(box, 3).length(),
58
+ new Vector3().fromArray(box, 6).length(),
59
+ new Vector3().fromArray(box, 9).length(),
60
+ );
61
+
62
+ // Approximate zoomToBox with sphere
63
+ const sphere = [box[0], box[1], box[2], radius];
64
+ return zoomToSphere(view, tile, sphere);
65
+ }
66
+
67
+ function zoomToRegion(view, region) {
68
+ const extent = new Extent('EPSG:4326',
69
+ region[0] * MathUtils.RAD2DEG, // west
70
+ region[2] * MathUtils.RAD2DEG, // east
71
+ region[1] * MathUtils.RAD2DEG, // south
72
+ region[3] * MathUtils.RAD2DEG, // north
73
+ );
74
+
75
+ return CameraUtils.getCameraTransformOptionsFromExtent(
76
+ view,
77
+ view.camera3D,
78
+ extent,
79
+ );
80
+ }
81
+
82
+ function zoomToTile(view, tile) {
83
+ const { region, box, sphere } = tile.boundingVolume;
84
+
85
+ let cameraTransform;
86
+ if (region) {
87
+ cameraTransform = zoomToRegion(view, region);
88
+ } else if (box) {
89
+ cameraTransform = zoomToBox(view, tile, box);
90
+ } else {
91
+ cameraTransform = zoomToSphere(view, tile, sphere);
92
+ }
93
+
94
+ view.controls.lookAtCoordinate({
95
+ coord: cameraTransform.coord,
96
+ range: 1.25 * cameraTransform.range, // zoom out a little bit
97
+ tilt: 60,
98
+ });
99
+ }
100
+
101
+ export function zoomToLayer(view, layer) {
102
+ const root = layer.tilesRenderer.root;
103
+
104
+ zoomToTile(view, root);
105
+ }
@@ -145,7 +145,8 @@
145
145
  });
146
146
 
147
147
  // Load a glTF resource
148
- itowns.glTFLoader.load(
148
+ var gltfLoader = new itowns.iGLTFLoader();
149
+ gltfLoader.load(
149
150
  // resource URL
150
151
  "https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/models/lampadaire/scene.gltf",
151
152
 
@@ -0,0 +1,127 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Point Cloud Viewer</title>
5
+
6
+ <style type="text/css">
7
+ #info {
8
+ color: #7ad7ff;
9
+ font-family: 'Open Sans', sans-serif;
10
+ position: absolute;
11
+ top: 0;
12
+ left: 0;
13
+ padding: 0.3rem;
14
+ background-color: #404040;
15
+ z-index: 1;
16
+ }
17
+ @media (max-width: 600px) {
18
+ #info,
19
+ .dg {
20
+ display: none;
21
+ }
22
+ }
23
+ </style>
24
+
25
+ <meta charset="UTF-8">
26
+ <link rel="stylesheet" type="text/css" href="css/example.css">
27
+ <link rel="stylesheet" type="text/css" href="css/LoadingScreen.css">
28
+
29
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
30
+ </head>
31
+ <body>
32
+ <div id="viewerDiv">
33
+ <div id="info"></div>
34
+ </div>
35
+
36
+ <div>
37
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.6/dat.gui.min.js"></script>
38
+ <script src="../dist/itowns.js"></script>
39
+ <script src="js/GUI/LoadingScreen.js"></script>
40
+ <script src="../dist/debug.js"></script>
41
+ <script type="text/javascript">
42
+ var potreeLayer;
43
+ var oldPostUpdate;
44
+ var viewerDiv;
45
+ var debugGui;
46
+ var view;
47
+ var controls;
48
+
49
+ // Define crs projection that we will use (taken from https://epsg.io/3946, Proj4js section)
50
+ itowns.proj4.defs('EPSG:3946', '+proj=lcc +lat_1=45.25 +lat_2=46.75 +lat_0=46 +lon_0=3 +x_0=1700000 +y_0=5200000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs');
51
+
52
+ viewerDiv = document.getElementById('viewerDiv');
53
+ viewerDiv.style.display = 'block';
54
+
55
+ debugGui = new dat.GUI();
56
+
57
+ // TODO: do we really need to disable logarithmicDepthBuffer ?
58
+ view = new itowns.View('EPSG:3946', viewerDiv);
59
+ setupLoadingScreen(viewerDiv, view);
60
+ view.mainLoop.gfxEngine.renderer.setClearColor(0xcccccc);
61
+
62
+ // Configure Point Cloud layer
63
+ potreeLayer = new itowns.Potree2Layer('Lion', {
64
+ source: new itowns.Potree2Source({
65
+ file: 'metadata.json',
66
+ url: 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/pointclouds/potree2.0/lion',
67
+ crs: view.referenceCrs,
68
+ }),
69
+ });
70
+
71
+ // point selection on double-click
72
+ function dblClickHandler(event) {
73
+ var pick = view.pickObjectsAt(event, 5, potreeLayer);
74
+
75
+ for (const p of pick) {
76
+ console.info('Selected point #' + p.index + ' in position (' +
77
+ p.object.position.x + ', ' +
78
+ p.object.position.y + ', ' +
79
+ p.object.position.z +
80
+ ') in Points ' + p.object.layer.id);
81
+ }
82
+ }
83
+ view.domElement.addEventListener('dblclick', dblClickHandler);
84
+
85
+ function placeCamera(position, lookAt) {
86
+ view.camera.camera3D.position.copy(position);
87
+ view.camera.camera3D.lookAt(lookAt);
88
+ // create controls
89
+ controls = new itowns.FirstPersonControls(view, { focusOnClick: true });
90
+ debugGui.add(controls.options, 'moveSpeed', 1, 100).name('Movement speed');
91
+
92
+ view.notifyChange(view.camera.camera3D);
93
+ }
94
+
95
+ // add potreeLayer to scene
96
+ function onLayerReady() {
97
+ var ratio;
98
+ var position;
99
+ var lookAt = new itowns.THREE.Vector3();
100
+ var size = new itowns.THREE.Vector3();
101
+
102
+ potreeLayer.root.bbox.getSize(size);
103
+ potreeLayer.root.bbox.getCenter(lookAt);
104
+
105
+ debug.PointCloudDebug.initTools(view, potreeLayer, debugGui);
106
+
107
+ view.camera.camera3D.far = 2.0 * size.length();
108
+
109
+ ratio = size.x / size.z;
110
+ position = potreeLayer.root.bbox.min.clone().add(
111
+ size.multiply({ x: 0, y: 0, z: ratio * 0.5 }));
112
+ lookAt.z = potreeLayer.root.bbox.min.z;
113
+ placeCamera(position, lookAt);
114
+ controls.moveSpeed = size.length() / 3;
115
+
116
+ // update stats window
117
+ var info = document.getElementById('info');
118
+ view.addFrameRequester(itowns.MAIN_LOOP_EVENTS.AFTER_RENDER, () => {
119
+ info.textContent = potreeLayer.displayedCount.toLocaleString() + ' points';
120
+ });
121
+ }
122
+ window.view = view;
123
+ view.addLayer(potreeLayer).then(onLayerReady);
124
+ </script>
125
+ </body>
126
+ </html>
127
+
@@ -72,12 +72,12 @@ class C3DTFeature {
72
72
  target.min.y = Infinity;
73
73
  target.min.z = Infinity;
74
74
  this.groups.forEach(group => {
75
- const positionIndexStart = group.start * 3;
76
- const positionIndexCount = (group.start + group.count) * 3;
77
- for (let index = positionIndexStart; index < positionIndexCount; index += 3) {
78
- const x = this.object3d.geometry.attributes.position.array[index];
79
- const y = this.object3d.geometry.attributes.position.array[index + 1];
80
- const z = this.object3d.geometry.attributes.position.array[index + 2];
75
+ const positionIndexStart = group.start * this.object3d.geometry.attributes.position.itemSize;
76
+ const positionIndexCount = (group.start + group.count) * this.object3d.geometry.attributes.position.itemSize;
77
+ for (let index = positionIndexStart; index < positionIndexCount; index++) {
78
+ const x = this.object3d.geometry.attributes.position.getX(index);
79
+ const y = this.object3d.geometry.attributes.position.getY(index);
80
+ const z = this.object3d.geometry.attributes.position.getZ(index);
81
81
  target.max.x = Math.max(x, target.max.x);
82
82
  target.max.y = Math.max(y, target.max.y);
83
83
  target.max.z = Math.max(z, target.max.z);
@@ -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
+ }
@@ -140,7 +140,7 @@ Scheduler.prototype.execute = function (command) {
140
140
 
141
141
  // parse host
142
142
  const layer = command.layer;
143
- const host = layer.source && layer.source.url ? new URL(URLBuilder.subDomains(layer.source.url), document.location).host : undefined;
143
+ const host = layer.source && layer.source.url && layer.source.url !== 'none' ? new URL(URLBuilder.subDomains(layer.source.url), document.location).host : undefined;
144
144
  command.promise = new Promise((resolve, reject) => {
145
145
  command.resolve = resolve;
146
146
  command.reject = reject;