itowns 2.45.2-next.0 → 2.45.2-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,7 +34,7 @@
34
34
  </div>
35
35
 
36
36
  <div>
37
- <script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.6/dat.gui.min.js"></script>
37
+ <script src="https://cdn.jsdelivr.net/npm/lil-gui@0.19"></script>
38
38
  <script src="../dist/itowns.js"></script>
39
39
  <script src="js/GUI/LoadingScreen.js"></script>
40
40
  <script src="../dist/debug.js"></script>
@@ -52,7 +52,7 @@
52
52
  viewerDiv = document.getElementById('viewerDiv');
53
53
  viewerDiv.style.display = 'block';
54
54
 
55
- debugGui = new dat.GUI();
55
+ debugGui = new lil.GUI();
56
56
 
57
57
  // TODO: do we really need to disable logarithmicDepthBuffer ?
58
58
  view = new itowns.View('EPSG:3946', viewerDiv);
@@ -34,7 +34,7 @@
34
34
  </div>
35
35
 
36
36
  <div>
37
- <script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.6/dat.gui.min.js"></script>
37
+ <script src="https://cdn.jsdelivr.net/npm/lil-gui@0.19"></script>
38
38
  <script src="../dist/itowns.js"></script>
39
39
  <script src="js/GUI/LoadingScreen.js"></script>
40
40
  <script src="../dist/debug.js"></script>
@@ -52,7 +52,7 @@
52
52
  viewerDiv = document.getElementById('viewerDiv');
53
53
  viewerDiv.style.display = 'block';
54
54
 
55
- debugGui = new dat.GUI();
55
+ debugGui = new lil.GUI();
56
56
 
57
57
  // TODO: do we really need to disable logarithmicDepthBuffer ?
58
58
  view = new itowns.View('EPSG:3946', viewerDiv);
@@ -32,7 +32,7 @@
32
32
  <body>
33
33
  <div id="viewerDiv"></div>
34
34
  <div id="info"></div>
35
- <script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.6/dat.gui.min.js"></script>
35
+ <script src="https://cdn.jsdelivr.net/npm/lil-gui@0.19"></script>
36
36
  <script src="../dist/itowns.js"></script>
37
37
  <script src="js/GUI/LoadingScreen.js"></script>
38
38
  <script src="../dist/debug.js"></script>
@@ -46,7 +46,7 @@
46
46
  viewerDiv = document.getElementById('viewerDiv');
47
47
  viewerDiv.style.display = 'block';
48
48
 
49
- debugGui = new dat.GUI();
49
+ debugGui = new lil.GUI();
50
50
 
51
51
  var placement = {
52
52
  coord: new itowns.Coordinates('EPSG:4326', 4.631512, 43.675626),
@@ -13,7 +13,7 @@ export default CopcNode;
13
13
  * @property {number} x - X position within the octree
14
14
  * @property {number} y - Y position within the octree
15
15
  * @property {number} z - Z position within the octree
16
- * @property {string} id - The id of the node, constituted of the four
16
+ * @property {string} voxelKey - The id of the node, constituted of the four
17
17
  * components: `depth-x-y-z`.
18
18
  */
19
19
  declare class CopcNode extends PointCloudNode {
@@ -38,8 +38,9 @@ declare class CopcNode extends PointCloudNode {
38
38
  x: number;
39
39
  y: number;
40
40
  z: number;
41
- id: string;
41
+ voxelKey: string;
42
42
  get octreeIsLoaded(): boolean;
43
+ get id(): string;
43
44
  /**
44
45
  * @param {number} offset
45
46
  * @param {number} size
@@ -1,6 +1,6 @@
1
1
  import { Hierarchy } from 'copc';
2
2
  import PointCloudNode from "./PointCloudNode.js";
3
- function buildId(depth, x, y, z) {
3
+ function buildVoxelKey(depth, x, y, z) {
4
4
  return `${depth}-${x}-${y}-${z}`;
5
5
  }
6
6
 
@@ -18,7 +18,7 @@ function buildId(depth, x, y, z) {
18
18
  * @property {number} x - X position within the octree
19
19
  * @property {number} y - Y position within the octree
20
20
  * @property {number} z - Z position within the octree
21
- * @property {string} id - The id of the node, constituted of the four
21
+ * @property {string} voxelKey - The id of the node, constituted of the four
22
22
  * components: `depth-x-y-z`.
23
23
  */
24
24
  class CopcNode extends PointCloudNode {
@@ -41,16 +41,18 @@ class CopcNode extends PointCloudNode {
41
41
  this.isCopcNode = true;
42
42
  this.entryOffset = entryOffset;
43
43
  this.entryLength = entryLength;
44
- this.layer = layer;
45
44
  this.depth = depth;
46
45
  this.x = x;
47
46
  this.y = y;
48
47
  this.z = z;
49
- this.id = buildId(depth, x, y, z);
48
+ this.voxelKey = buildVoxelKey(depth, x, y, z);
50
49
  }
51
50
  get octreeIsLoaded() {
52
51
  return this.numPoints >= 0;
53
52
  }
53
+ get id() {
54
+ return `${this.depth}${this.x}${this.y}${this.z}`;
55
+ }
54
56
 
55
57
  /**
56
58
  * @param {number} offset
@@ -71,7 +73,7 @@ class CopcNode extends PointCloudNode {
71
73
  const hierarchy = await Hierarchy.parse(new Uint8Array(buffer));
72
74
 
73
75
  // Update current node entry from loaded subtree
74
- const node = hierarchy.nodes[this.id];
76
+ const node = hierarchy.nodes[this.voxelKey];
75
77
  if (!node) {
76
78
  return Promise.reject('[CopcNode]: Ill-formed data, entry not found in hierarchy.');
77
79
  }
@@ -110,17 +112,17 @@ class CopcNode extends PointCloudNode {
110
112
  * @param {CopcNode[]} stack - Stack of node candidates for traversal
111
113
  */
112
114
  findAndCreateChild(depth, x, y, z, hierarchy, stack) {
113
- const id = buildId(depth, x, y, z);
115
+ const voxelKey = buildVoxelKey(depth, x, y, z);
114
116
  let pointCount;
115
117
  let offset;
116
118
  let byteSize;
117
- const node = hierarchy.nodes[id];
119
+ const node = hierarchy.nodes[voxelKey];
118
120
  if (node) {
119
121
  pointCount = node.pointCount;
120
122
  offset = node.pointDataOffset;
121
123
  byteSize = node.pointDataLength;
122
124
  } else {
123
- const page = hierarchy.pages[id];
125
+ const page = hierarchy.pages[voxelKey];
124
126
  if (!page) {
125
127
  return;
126
128
  }
@@ -17,7 +17,7 @@ export default EntwinePointTileNode;
17
17
  * @property {number} z - The z coordinate of the node in the tree - see the
18
18
  * [Entwine
19
19
  * documentation](https://entwine.io/entwine-point-tile.html#ept-data)
20
- * @property {string} id - The id of the node, constituted of the four
20
+ * @property {string} voxelKey - The id of the node, constituted of the four
21
21
  * components: `depth-x-y-z`.
22
22
  */
23
23
  declare class EntwinePointTileNode extends PointCloudNode {
@@ -49,9 +49,10 @@ declare class EntwinePointTileNode extends PointCloudNode {
49
49
  x: number;
50
50
  y: number;
51
51
  z: number;
52
- id: string;
52
+ voxelKey: string;
53
53
  url: string;
54
54
  get octreeIsLoaded(): boolean;
55
+ get id(): string;
55
56
  loadOctree(): Promise<void>;
56
57
  findAndCreateChild(depth: any, x: any, y: any, z: any, hierarchy: any, stack: any): void;
57
58
  }
@@ -1,6 +1,6 @@
1
1
  import Fetcher from "../Provider/Fetcher.js";
2
2
  import PointCloudNode from "./PointCloudNode.js";
3
- function buildId(depth, x, y, z) {
3
+ function buildVoxelKey(depth, x, y, z) {
4
4
  return `${depth}-${x}-${y}-${z}`;
5
5
  }
6
6
 
@@ -22,7 +22,7 @@ function buildId(depth, x, y, z) {
22
22
  * @property {number} z - The z coordinate of the node in the tree - see the
23
23
  * [Entwine
24
24
  * documentation](https://entwine.io/entwine-point-tile.html#ept-data)
25
- * @property {string} id - The id of the node, constituted of the four
25
+ * @property {string} voxelKey - The id of the node, constituted of the four
26
26
  * components: `depth-x-y-z`.
27
27
  */
28
28
  class EntwinePointTileNode extends PointCloudNode {
@@ -56,16 +56,19 @@ class EntwinePointTileNode extends PointCloudNode {
56
56
  this.x = x;
57
57
  this.y = y;
58
58
  this.z = z;
59
- this.id = buildId(depth, x, y, z);
60
- this.url = `${this.layer.source.url}/ept-data/${this.id}.${this.layer.source.extension}`;
59
+ this.voxelKey = buildVoxelKey(depth, x, y, z);
60
+ this.url = `${this.layer.source.url}/ept-data/${this.voxelKey}.${this.layer.source.extension}`;
61
61
  }
62
62
  get octreeIsLoaded() {
63
63
  return this.numPoints >= 0;
64
64
  }
65
+ get id() {
66
+ return `${this.depth}${this.x}${this.y}${this.z}`;
67
+ }
65
68
  loadOctree() {
66
- const hierarchyUrl = `${this.layer.source.url}/ept-hierarchy/${this.id}.json`;
69
+ const hierarchyUrl = `${this.layer.source.url}/ept-hierarchy/${this.voxelKey}.json`;
67
70
  return Fetcher.json(hierarchyUrl, this.layer.source.networkOptions).then(hierarchy => {
68
- this.numPoints = hierarchy[this.id];
71
+ this.numPoints = hierarchy[this.voxelKey];
69
72
  const stack = [];
70
73
  stack.push(this);
71
74
  while (stack.length) {
@@ -86,8 +89,8 @@ class EntwinePointTileNode extends PointCloudNode {
86
89
  });
87
90
  }
88
91
  findAndCreateChild(depth, x, y, z, hierarchy, stack) {
89
- const id = buildId(depth, x, y, z);
90
- const numPoints = hierarchy[id];
92
+ const voxelKey = buildVoxelKey(depth, x, y, z);
93
+ const numPoints = hierarchy[voxelKey];
91
94
  if (typeof numPoints == 'number') {
92
95
  const child = new EntwinePointTileNode(depth, x, y, z, this.layer, numPoints);
93
96
  this.add(child);
@@ -6,6 +6,8 @@ declare class PointCloudNode extends THREE.EventDispatcher<any> {
6
6
  children: any[];
7
7
  bbox: THREE.Box3;
8
8
  sse: number;
9
+ get pointSpacing(): number;
10
+ get id(): void;
9
11
  add(node: any, indexChild: any): void;
10
12
  createChildAABB(node: any): void;
11
13
  load(): any;
@@ -13,6 +13,12 @@ class PointCloudNode extends THREE.EventDispatcher {
13
13
  this.bbox = new THREE.Box3();
14
14
  this.sse = -1;
15
15
  }
16
+ get pointSpacing() {
17
+ return this.layer.spacing / 2 ** this.depth;
18
+ }
19
+ get id() {
20
+ throw new Error('In extended PointCloudNode, you have to implement the getter id!');
21
+ }
16
22
  add(node, indexChild) {
17
23
  this.children.push(node);
18
24
  node.parent = this;
@@ -44,10 +50,6 @@ class PointCloudNode extends THREE.EventDispatcher {
44
50
  node.bbox.max.copy(node.bbox.min).add(size);
45
51
  }
46
52
  load() {
47
- // Query octree/HRC if we don't have children potreeNode yet.
48
- if (!this.octreeIsLoaded) {
49
- this.loadOctree();
50
- }
51
53
  return this.layer.source.fetcher(this.url, this.layer.source.networkOptions).then(file => this.layer.source.parse(file, {
52
54
  out: this.layer,
53
55
  in: this.layer.source
@@ -92,8 +92,8 @@ class Potree2Node extends PotreeNode {
92
92
  return this.nodeType === NODE_TYPE.PROXY ? this.loadHierarchy() : Promise.resolve();
93
93
  }
94
94
  async loadHierarchy() {
95
- const hierarchyPath = `${this.baseurl}/hierarchy.bin`;
96
- const buffer = await this.layer.source.fetcher(hierarchyPath, this.networkOptions(this.hierarchyByteOffset, this.hierarchyByteSize));
95
+ const hierarchyUrl = `${this.baseurl}/hierarchy.bin`;
96
+ const buffer = await this.layer.source.fetcher(hierarchyUrl, this.networkOptions(this.hierarchyByteOffset, this.hierarchyByteSize));
97
97
  this.parseHierarchy(buffer);
98
98
  }
99
99
  parseHierarchy(buffer) {
@@ -142,7 +142,6 @@ class Potree2Node extends PotreeNode {
142
142
  continue;
143
143
  }
144
144
  const child = new Potree2Node(numPoints, childMask, this.layer);
145
- child.spacing = current.spacing / 2;
146
145
  current.add(child, childIndex);
147
146
  stack.push(child);
148
147
  }
@@ -2,11 +2,12 @@ export default PotreeNode;
2
2
  declare class PotreeNode extends PointCloudNode {
3
3
  constructor(numPoints: number | undefined, childrenBitField: number | undefined, layer: any);
4
4
  childrenBitField: number;
5
- id: string;
6
5
  depth: number;
6
+ hierarchyKey: string;
7
7
  baseurl: any;
8
8
  get octreeIsLoaded(): boolean;
9
9
  get url(): string;
10
+ get id(): string;
10
11
  createChildAABB(node: any, childIndex: any): void;
11
12
  loadOctree(): any;
12
13
  }
@@ -12,18 +12,21 @@ class PotreeNode extends PointCloudNode {
12
12
  let layer = arguments.length > 2 ? arguments[2] : undefined;
13
13
  super(numPoints, layer);
14
14
  this.childrenBitField = childrenBitField;
15
- this.id = '';
16
15
  this.depth = 0;
16
+ this.hierarchyKey = 'r';
17
17
  this.baseurl = layer.source.baseurl;
18
18
  }
19
19
  get octreeIsLoaded() {
20
20
  return !(this.childrenBitField && this.children.length === 0);
21
21
  }
22
22
  get url() {
23
- return `${this.baseurl}/r${this.id}.${this.layer.source.extension}`;
23
+ return `${this.baseurl}/${this.hierarchyKey}.${this.layer.source.extension}`;
24
+ }
25
+ get id() {
26
+ return this.hierarchyKey;
24
27
  }
25
28
  add(node, indexChild) {
26
- node.id = this.id + indexChild;
29
+ node.hierarchyKey = this.hierarchyKey + indexChild;
27
30
  node.depth = this.depth + 1;
28
31
  super.add(node, indexChild);
29
32
  }
@@ -63,8 +66,15 @@ class PotreeNode extends PointCloudNode {
63
66
  node.bbox.max.x += dHalfLength.x;
64
67
  }
65
68
  }
69
+ load() {
70
+ // Query octree/HRC if we don't have children potreeNode yet.
71
+ if (!this.octreeIsLoaded) {
72
+ this.loadOctree();
73
+ }
74
+ return super.load();
75
+ }
66
76
  loadOctree() {
67
- const octreeUrl = `${this.baseurl}/r${this.id}.${this.layer.source.extensionOctree}`;
77
+ const octreeUrl = `${this.baseurl}/${this.hierarchyKey}.${this.layer.source.extensionOctree}`;
68
78
  return this.layer.source.fetcher(octreeUrl, this.layer.source.networkOptions).then(blob => {
69
79
  const view = new DataView(blob);
70
80
  const stack = [];
@@ -26,11 +26,10 @@ function initBoundingBox(elt, layer) {
26
26
  elt.obj.boxHelper.updateMatrix();
27
27
  elt.obj.boxHelper.updateMatrixWorld();
28
28
  }
29
- function computeSSEPerspective(context, pointSize, spacing, elt, distance) {
29
+ function computeSSEPerspective(context, pointSize, pointSpacing, distance) {
30
30
  if (distance <= 0) {
31
31
  return Infinity;
32
32
  }
33
- const pointSpacing = spacing / 2 ** elt.depth;
34
33
  // Estimate the onscreen distance between 2 points
35
34
  const onScreenSpacing = context.camera.preSSE * pointSpacing / distance;
36
35
  // [ P1 ]--------------[ P2 ]
@@ -39,9 +38,7 @@ function computeSSEPerspective(context, pointSize, spacing, elt, distance) {
39
38
  // <------> = pointSize (in pixels)
40
39
  return Math.max(0.0, onScreenSpacing - pointSize);
41
40
  }
42
- function computeSSEOrthographic(context, pointSize, spacing, elt) {
43
- const pointSpacing = spacing / 2 ** elt.depth;
44
-
41
+ function computeSSEOrthographic(context, pointSize, pointSpacing) {
45
42
  // Given an identity view matrix, project pointSpacing from world space to
46
43
  // clip space. v' = vVP = vP
47
44
  const v = new THREE.Vector4(pointSpacing);
@@ -53,11 +50,11 @@ function computeSSEOrthographic(context, pointSize, spacing, elt) {
53
50
  const distance = Math.sqrt(dx * dx + dy * dy);
54
51
  return Math.max(0.0, distance - pointSize);
55
52
  }
56
- function computeScreenSpaceError(context, pointSize, spacing, elt, distance) {
53
+ function computeScreenSpaceError(context, pointSize, pointSpacing, distance) {
57
54
  if (context.camera.camera3D.isOrthographicCamera) {
58
- return computeSSEOrthographic(context, pointSize, spacing, elt);
55
+ return computeSSEOrthographic(context, pointSize, pointSpacing);
59
56
  }
60
- return computeSSEPerspective(context, pointSize, spacing, elt, distance);
57
+ return computeSSEPerspective(context, pointSize, pointSpacing, distance);
61
58
  }
62
59
  function markForDeletion(elt) {
63
60
  if (elt.obj) {
@@ -284,7 +281,7 @@ class PointCloudLayer extends GeometryLayer {
284
281
  } else if (!elt.promise) {
285
282
  const distance = Math.max(0.001, bbox.distanceToPoint(point));
286
283
  // Increase priority of nearest node
287
- const priority = computeScreenSpaceError(context, layer.pointSize, layer.spacing, elt, distance) / distance;
284
+ const priority = computeScreenSpaceError(context, layer.pointSize, elt.pointSpacing, distance) / distance;
288
285
  elt.promise = context.scheduler.execute({
289
286
  layer,
290
287
  requester: elt,
@@ -312,7 +309,7 @@ class PointCloudLayer extends GeometryLayer {
312
309
  }
313
310
  if (elt.children && elt.children.length) {
314
311
  const distance = bbox.distanceToPoint(point);
315
- elt.sse = computeScreenSpaceError(context, layer.pointSize, layer.spacing, elt, distance) / this.sseThreshold;
312
+ elt.sse = computeScreenSpaceError(context, layer.pointSize, elt.pointSpacing, distance) / this.sseThreshold;
316
313
  if (elt.sse >= 1) {
317
314
  return elt.children;
318
315
  } else {
@@ -156,8 +156,6 @@ class Potree2Layer extends PointCloudLayer {
156
156
  root.boundingSphere = boundingBox.getBoundingSphere(new THREE.Sphere());
157
157
  this.minElevationRange = this.minElevationRange ?? metadata.boundingBox.min[2];
158
158
  this.maxElevationRange = this.maxElevationRange ?? metadata.boundingBox.max[2];
159
- root.id = 'r';
160
- root.depth = 0;
161
159
  root.nodeType = 2;
162
160
  root.hierarchyByteOffset = 0n;
163
161
  root.hierarchyByteSize = BigInt(metadata.hierarchy.firstChunkSize);
package/lib/Main.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const conf = {
2
- version: '2.45.2-next.0'
2
+ version: '2.45.2-next.1'
3
3
  };
4
4
  export const REVISION = conf.version;
5
5
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "itowns",
3
- "version": "2.45.2-next.0",
3
+ "version": "2.45.2-next.1",
4
4
  "description": "A JS/WebGL framework for 3D geospatial data visualization",
5
5
  "type": "module",
6
6
  "main": "lib/Main.js",
@@ -51,7 +51,7 @@
51
51
  "url": "https://github.com/iTowns/itowns/issues"
52
52
  },
53
53
  "dependencies": {
54
- "@itowns/geographic": "^2.45.2-next.0",
54
+ "@itowns/geographic": "^2.45.2-next.1",
55
55
  "@mapbox/vector-tile": "^2.0.3",
56
56
  "@maplibre/maplibre-gl-style-spec": "^23.1.0",
57
57
  "@tmcw/togeojson": "^7.0.0",