@loaders.gl/3d-tiles 4.0.0-alpha.9 → 4.0.0-beta.2

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 (170) hide show
  1. package/dist/3d-tiles-archive/3d-tiles-archive-archive.d.ts +30 -0
  2. package/dist/3d-tiles-archive/3d-tiles-archive-archive.d.ts.map +1 -0
  3. package/dist/3d-tiles-archive/3d-tiles-archive-parser.d.ts +10 -0
  4. package/dist/3d-tiles-archive/3d-tiles-archive-parser.d.ts.map +1 -0
  5. package/dist/3d-tiles-archive-loader.d.ts +13 -0
  6. package/dist/3d-tiles-archive-loader.d.ts.map +1 -0
  7. package/dist/cesium-ion-loader.d.ts +2 -2
  8. package/dist/cesium-ion-loader.d.ts.map +1 -1
  9. package/dist/dist.min.js +10981 -4462
  10. package/dist/es5/3d-tiles-archive/3d-tiles-archive-archive.js +126 -0
  11. package/dist/es5/3d-tiles-archive/3d-tiles-archive-archive.js.map +1 -0
  12. package/dist/es5/3d-tiles-archive/3d-tiles-archive-parser.js +69 -0
  13. package/dist/es5/3d-tiles-archive/3d-tiles-archive-parser.js.map +1 -0
  14. package/dist/es5/3d-tiles-archive-loader.js +50 -0
  15. package/dist/es5/3d-tiles-archive-loader.js.map +1 -0
  16. package/dist/es5/cesium-ion-loader.js.map +1 -1
  17. package/dist/es5/index.js +14 -0
  18. package/dist/es5/index.js.map +1 -1
  19. package/dist/es5/lib/filesystems/tiles-3d-archive-file-system.js +151 -0
  20. package/dist/es5/lib/filesystems/tiles-3d-archive-file-system.js.map +1 -0
  21. package/dist/es5/lib/ion/ion.js +3 -9
  22. package/dist/es5/lib/ion/ion.js.map +1 -1
  23. package/dist/es5/lib/parsers/helpers/parse-3d-implicit-tiles.js +63 -38
  24. package/dist/es5/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +1 -1
  25. package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js +3 -3
  26. package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
  27. package/dist/es5/lib/parsers/helpers/parse-3d-tile-subtree.js +70 -55
  28. package/dist/es5/lib/parsers/helpers/parse-3d-tile-subtree.js.map +1 -1
  29. package/dist/es5/lib/parsers/parse-3d-tile-composite.js +3 -1
  30. package/dist/es5/lib/parsers/parse-3d-tile-composite.js.map +1 -1
  31. package/dist/es5/lib/parsers/parse-3d-tile-gltf.js +14 -12
  32. package/dist/es5/lib/parsers/parse-3d-tile-gltf.js.map +1 -1
  33. package/dist/es5/lib/parsers/parse-3d-tile-header.js +14 -12
  34. package/dist/es5/lib/parsers/parse-3d-tile-header.js.map +1 -1
  35. package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js +6 -6
  36. package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
  37. package/dist/es5/lib/parsers/parse-3d-tile.js +3 -1
  38. package/dist/es5/lib/parsers/parse-3d-tile.js.map +1 -1
  39. package/dist/es5/lib/utils/version.js +1 -1
  40. package/dist/es5/lib/utils/version.js.map +1 -1
  41. package/dist/es5/tile-3d-subtree-loader.js.map +1 -1
  42. package/dist/es5/tile-3d-writer.js.map +1 -1
  43. package/dist/es5/tiles-3d-loader.js +2 -0
  44. package/dist/es5/tiles-3d-loader.js.map +1 -1
  45. package/dist/es5/types.js.map +1 -1
  46. package/dist/esm/3d-tiles-archive/3d-tiles-archive-archive.js +46 -0
  47. package/dist/esm/3d-tiles-archive/3d-tiles-archive-archive.js.map +1 -0
  48. package/dist/esm/3d-tiles-archive/3d-tiles-archive-parser.js +23 -0
  49. package/dist/esm/3d-tiles-archive/3d-tiles-archive-parser.js.map +1 -0
  50. package/dist/esm/3d-tiles-archive-loader.js +20 -0
  51. package/dist/esm/3d-tiles-archive-loader.js.map +1 -0
  52. package/dist/esm/cesium-ion-loader.js.map +1 -1
  53. package/dist/esm/index.js +2 -0
  54. package/dist/esm/index.js.map +1 -1
  55. package/dist/esm/lib/filesystems/tiles-3d-archive-file-system.js +49 -0
  56. package/dist/esm/lib/filesystems/tiles-3d-archive-file-system.js.map +1 -0
  57. package/dist/esm/lib/ion/ion.js +3 -9
  58. package/dist/esm/lib/ion/ion.js.map +1 -1
  59. package/dist/esm/lib/parsers/helpers/parse-3d-implicit-tiles.js +45 -23
  60. package/dist/esm/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +1 -1
  61. package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js +5 -6
  62. package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
  63. package/dist/esm/lib/parsers/helpers/parse-3d-tile-subtree.js +18 -24
  64. package/dist/esm/lib/parsers/helpers/parse-3d-tile-subtree.js.map +1 -1
  65. package/dist/esm/lib/parsers/parse-3d-tile-composite.js +3 -1
  66. package/dist/esm/lib/parsers/parse-3d-tile-composite.js.map +1 -1
  67. package/dist/esm/lib/parsers/parse-3d-tile-gltf.js +7 -8
  68. package/dist/esm/lib/parsers/parse-3d-tile-gltf.js.map +1 -1
  69. package/dist/esm/lib/parsers/parse-3d-tile-header.js +8 -5
  70. package/dist/esm/lib/parsers/parse-3d-tile-header.js.map +1 -1
  71. package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js +2 -4
  72. package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
  73. package/dist/esm/lib/parsers/parse-3d-tile.js +3 -1
  74. package/dist/esm/lib/parsers/parse-3d-tile.js.map +1 -1
  75. package/dist/esm/lib/utils/version.js +1 -1
  76. package/dist/esm/lib/utils/version.js.map +1 -1
  77. package/dist/esm/tile-3d-subtree-loader.js.map +1 -1
  78. package/dist/esm/tile-3d-writer.js.map +1 -1
  79. package/dist/esm/tiles-3d-loader.js +2 -0
  80. package/dist/esm/tiles-3d-loader.js.map +1 -1
  81. package/dist/esm/types.js.map +1 -1
  82. package/dist/index.d.ts +3 -0
  83. package/dist/index.d.ts.map +1 -1
  84. package/dist/lib/filesystems/tiles-3d-archive-file-system.d.ts +32 -0
  85. package/dist/lib/filesystems/tiles-3d-archive-file-system.d.ts.map +1 -0
  86. package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.d.ts +4 -1
  87. package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.d.ts.map +1 -1
  88. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.d.ts.map +1 -1
  89. package/dist/lib/parsers/helpers/parse-3d-tile-subtree.d.ts.map +1 -1
  90. package/dist/lib/parsers/parse-3d-tile-gltf.d.ts +2 -2
  91. package/dist/lib/parsers/parse-3d-tile-gltf.d.ts.map +1 -1
  92. package/dist/lib/parsers/parse-3d-tile-header.d.ts +30 -2
  93. package/dist/lib/parsers/parse-3d-tile-header.d.ts.map +1 -1
  94. package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts +1 -1
  95. package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts.map +1 -1
  96. package/dist/lib/parsers/parse-3d-tile.d.ts +1 -1
  97. package/dist/lib/parsers/parse-3d-tile.d.ts.map +1 -1
  98. package/dist/tile-3d-subtree-loader.d.ts +3 -3
  99. package/dist/tile-3d-subtree-loader.d.ts.map +1 -1
  100. package/dist/tile-3d-writer.d.ts +2 -2
  101. package/dist/tile-3d-writer.d.ts.map +1 -1
  102. package/dist/tiles-3d-loader.d.ts +2 -1
  103. package/dist/tiles-3d-loader.d.ts.map +1 -1
  104. package/dist/types.d.ts +49 -8
  105. package/dist/types.d.ts.map +1 -1
  106. package/package.json +9 -7
  107. package/src/3d-tiles-archive/3d-tiles-archive-archive.ts +85 -0
  108. package/src/3d-tiles-archive/3d-tiles-archive-parser.ts +52 -0
  109. package/src/3d-tiles-archive-loader.ts +47 -0
  110. package/src/cesium-ion-loader.ts +2 -3
  111. package/src/index.ts +3 -0
  112. package/src/lib/filesystems/tiles-3d-archive-file-system.ts +97 -0
  113. package/src/lib/ion/ion.ts +3 -3
  114. package/src/lib/parsers/helpers/parse-3d-implicit-tiles.ts +76 -32
  115. package/src/lib/parsers/helpers/parse-3d-tile-gltf-view.ts +8 -3
  116. package/src/lib/parsers/helpers/parse-3d-tile-subtree.ts +44 -62
  117. package/src/lib/parsers/parse-3d-tile-composite.ts +1 -1
  118. package/src/lib/parsers/parse-3d-tile-gltf.ts +11 -10
  119. package/src/lib/parsers/parse-3d-tile-header.ts +39 -6
  120. package/src/lib/parsers/parse-3d-tile-point-cloud.ts +10 -3
  121. package/src/lib/parsers/parse-3d-tile.ts +2 -2
  122. package/src/tile-3d-subtree-loader.ts +3 -3
  123. package/src/tile-3d-writer.ts +2 -2
  124. package/src/tiles-3d-loader.ts +16 -4
  125. package/src/types.ts +52 -9
  126. package/dist/bundle.js +0 -5
  127. package/dist/cesium-ion-loader.js +0 -41
  128. package/dist/index.js +0 -26
  129. package/dist/lib/classes/helpers/tile-3d-accessor-utils.js +0 -113
  130. package/dist/lib/classes/tile-3d-batch-table-hierarchy.js +0 -197
  131. package/dist/lib/classes/tile-3d-batch-table.js +0 -245
  132. package/dist/lib/classes/tile-3d-feature-table.js +0 -72
  133. package/dist/lib/constants.js +0 -26
  134. package/dist/lib/encoders/encode-3d-tile-batched-model.js +0 -46
  135. package/dist/lib/encoders/encode-3d-tile-composite.js +0 -24
  136. package/dist/lib/encoders/encode-3d-tile-instanced-model.js +0 -38
  137. package/dist/lib/encoders/encode-3d-tile-point-cloud.js +0 -39
  138. package/dist/lib/encoders/encode-3d-tile.js +0 -33
  139. package/dist/lib/encoders/helpers/encode-3d-tile-header.js +0 -30
  140. package/dist/lib/ion/ion.js +0 -68
  141. package/dist/lib/parsers/helpers/normalize-3d-tile-colors.js +0 -65
  142. package/dist/lib/parsers/helpers/normalize-3d-tile-normals.js +0 -30
  143. package/dist/lib/parsers/helpers/normalize-3d-tile-positions.js +0 -42
  144. package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.js +0 -266
  145. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js +0 -96
  146. package/dist/lib/parsers/helpers/parse-3d-tile-header.js +0 -28
  147. package/dist/lib/parsers/helpers/parse-3d-tile-subtree.js +0 -104
  148. package/dist/lib/parsers/helpers/parse-3d-tile-tables.js +0 -93
  149. package/dist/lib/parsers/helpers/parse-utils.js +0 -32
  150. package/dist/lib/parsers/parse-3d-tile-batched-model.js +0 -33
  151. package/dist/lib/parsers/parse-3d-tile-composite.js +0 -24
  152. package/dist/lib/parsers/parse-3d-tile-gltf.js +0 -28
  153. package/dist/lib/parsers/parse-3d-tile-header.js +0 -192
  154. package/dist/lib/parsers/parse-3d-tile-instanced-model.js +0 -172
  155. package/dist/lib/parsers/parse-3d-tile-point-cloud.js +0 -433
  156. package/dist/lib/parsers/parse-3d-tile.js +0 -33
  157. package/dist/lib/utils/obb/s2-corners-to-obb.js +0 -37
  158. package/dist/lib/utils/s2/converters/s2-to-boundary.js +0 -61
  159. package/dist/lib/utils/s2/converters/s2-to-obb-points.js +0 -36
  160. package/dist/lib/utils/s2/converters/s2-to-region.js +0 -59
  161. package/dist/lib/utils/s2/index.js +0 -23
  162. package/dist/lib/utils/s2/s2-geometry-functions.js +0 -29
  163. package/dist/lib/utils/s2/s2-token-functions.js +0 -68
  164. package/dist/lib/utils/s2/s2geometry/s2-cell-utils.js +0 -32
  165. package/dist/lib/utils/s2/s2geometry/s2-geometry.js +0 -260
  166. package/dist/lib/utils/version.js +0 -7
  167. package/dist/tile-3d-subtree-loader.js +0 -23
  168. package/dist/tile-3d-writer.js +0 -27
  169. package/dist/tiles-3d-loader.js +0 -76
  170. package/dist/types.js +0 -2
@@ -1,61 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getS2BoundaryFlatFromS2Cell = void 0;
4
- const s2_geometry_1 = require("../s2geometry/s2-geometry");
5
- const MAX_RESOLUTION = 100;
6
- /**
7
- * Get a polygon with corner coordinates for an S2 cell
8
- * @param s2cell {S2Cell} S2 cell
9
- * @return {Float64Array} - a simple polygon in flat array format: [lng0, lat0, lng1, lat1, ...]
10
- * - the polygon is closed, i.e. last coordinate is a copy of the first coordinate
11
- */
12
- // eslint-disable-next-line max-statements
13
- function getS2BoundaryFlatFromS2Cell(s2cell) {
14
- const { face, ij, level } = s2cell;
15
- const offsets = [
16
- [0, 0],
17
- [0, 1],
18
- [1, 1],
19
- [1, 0],
20
- [0, 0]
21
- ];
22
- // The S2 cell edge is curved: http://s2geometry.io/
23
- // This is more prominent at lower levels
24
- // resolution is the number of segments to generate per edge.
25
- // We exponentially reduce resolution as level increases so it doesn't affect perf
26
- // when there are a large number of cells
27
- const resolution = Math.max(1, Math.ceil(MAX_RESOLUTION * Math.pow(2, -level)));
28
- const result = new Float64Array(4 * resolution * 2 + 2);
29
- let ptIndex = 0;
30
- let prevLng = 0;
31
- for (let i = 0; i < 4; i++) {
32
- const offset = offsets[i].slice(0);
33
- const nextOffset = offsets[i + 1];
34
- const stepI = (nextOffset[0] - offset[0]) / resolution;
35
- const stepJ = (nextOffset[1] - offset[1]) / resolution;
36
- for (let j = 0; j < resolution; j++) {
37
- offset[0] += stepI;
38
- offset[1] += stepJ;
39
- // Cell can be represented by coordinates IJ, ST, UV, XYZ
40
- // http://s2geometry.io/devguide/s2cell_hierarchy#coordinate-systems
41
- const st = (0, s2_geometry_1.IJToST)(ij, level, offset);
42
- const uv = (0, s2_geometry_1.STToUV)(st);
43
- const xyz = (0, s2_geometry_1.FaceUVToXYZ)(face, uv);
44
- const lngLat = (0, s2_geometry_1.XYZToLngLat)(xyz);
45
- // Adjust longitude for Web Mercator projection
46
- if (Math.abs(lngLat[1]) > 89.999) {
47
- lngLat[0] = prevLng;
48
- }
49
- const deltaLng = lngLat[0] - prevLng;
50
- lngLat[0] += deltaLng > 180 ? -360 : deltaLng < -180 ? 360 : 0;
51
- result[ptIndex++] = lngLat[0];
52
- result[ptIndex++] = lngLat[1];
53
- prevLng = lngLat[0];
54
- }
55
- }
56
- // close the loop
57
- result[ptIndex++] = result[0];
58
- result[ptIndex++] = result[1];
59
- return result;
60
- }
61
- exports.getS2BoundaryFlatFromS2Cell = getS2BoundaryFlatFromS2Cell;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getS2OrientedBoundingBoxCornerPoints = void 0;
4
- const s2_cell_utils_1 = require("../s2geometry/s2-cell-utils");
5
- const s2_to_region_1 = require("./s2-to-region");
6
- const core_1 = require("@math.gl/core");
7
- /**
8
- * Converts S2HeightInfo to corner points of an oriented bounding box
9
- * Can be used to constuct an OrientedBoundingBox instance
10
- * @param tokenOrKey {string} A string that is the cell's hex token or the Hilbert quad key (containing /)
11
- * @param heightInfo {S2HeightInfo} min and max height of the box
12
- * @returns corner points of the oriented bounding box
13
- */
14
- function getS2OrientedBoundingBoxCornerPoints(tokenOrKey, // This can be an S2 key or token
15
- heightInfo) {
16
- const min = heightInfo?.minimumHeight || 0;
17
- const max = heightInfo?.maximumHeight || 0;
18
- const s2cell = (0, s2_cell_utils_1.getS2Cell)(tokenOrKey);
19
- const region = (0, s2_to_region_1.getS2Region)(s2cell);
20
- // region lng/lat are in degrees
21
- const W = region.west;
22
- const S = region.south;
23
- const E = region.east;
24
- const N = region.north;
25
- const points = [];
26
- points.push(new core_1.Vector3(W, N, min));
27
- points.push(new core_1.Vector3(E, N, min));
28
- points.push(new core_1.Vector3(E, S, min));
29
- points.push(new core_1.Vector3(W, S, min));
30
- points.push(new core_1.Vector3(W, N, max));
31
- points.push(new core_1.Vector3(E, N, max));
32
- points.push(new core_1.Vector3(E, S, max));
33
- points.push(new core_1.Vector3(W, S, max));
34
- return points;
35
- }
36
- exports.getS2OrientedBoundingBoxCornerPoints = getS2OrientedBoundingBoxCornerPoints;
@@ -1,59 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getS2Region = void 0;
4
- const s2_to_boundary_1 = require("./s2-to-boundary");
5
- const s2_cell_utils_1 = require("../s2geometry/s2-cell-utils");
6
- /**
7
- * Converts S2 cell to the 2D region
8
- * @param s2cell {S2Cell} S2 cell to convert to 2D region
9
- * @returns 2D region as an object containing: west, north, east, south in degrees
10
- */
11
- function getS2Region(s2cell) {
12
- let region;
13
- if (s2cell.face === 2 || s2cell.face === 5) {
14
- // let corners: Float64Array;
15
- let corners = null;
16
- let len = 0;
17
- for (let i = 0; i < 4; i++) {
18
- const key = `${s2cell.face}/${i}`;
19
- const cell = (0, s2_cell_utils_1.getS2Cell)(key);
20
- const corns = (0, s2_to_boundary_1.getS2BoundaryFlatFromS2Cell)(cell);
21
- if (typeof corners === 'undefined' || corners === null)
22
- corners = new Float64Array(4 * corns.length);
23
- corners.set(corns, len);
24
- len += corns.length;
25
- }
26
- region = get2DRegionFromS2Corners(corners);
27
- }
28
- else {
29
- const corners = (0, s2_to_boundary_1.getS2BoundaryFlatFromS2Cell)(s2cell);
30
- region = get2DRegionFromS2Corners(corners);
31
- }
32
- return region;
33
- }
34
- exports.getS2Region = getS2Region;
35
- /**
36
- * Converts the S2 cell defined by its corners to the 2D region
37
- * @param corners {Float64Array} - a simple polygon in flat array format: [lng0, lat0, lng1, lat1, ...]
38
- * @returns 2D region as an object containing: west, north, east, south in degrees
39
- */
40
- function get2DRegionFromS2Corners(corners) {
41
- if (corners.length % 2 !== 0) {
42
- throw new Error('Invalid corners');
43
- }
44
- const longitudes = [];
45
- const latitudes = [];
46
- for (let i = 0; i < corners.length; i += 2) {
47
- longitudes.push(corners[i]);
48
- latitudes.push(corners[i + 1]);
49
- }
50
- longitudes.sort((a, b) => a - b);
51
- latitudes.sort((a, b) => a - b);
52
- // Return the region in degrees
53
- return {
54
- west: longitudes[0],
55
- east: longitudes[longitudes.length - 1],
56
- north: latitudes[latitudes.length - 1],
57
- south: latitudes[0]
58
- };
59
- }
@@ -1,23 +0,0 @@
1
- "use strict";
2
- // math.gl MIT license
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.getS2OrientedBoundingBoxCornerPoints = exports.getS2Region = exports.getS2LngLatFromS2Cell = exports.getS2CellIdFromQuadkey = exports.getS2CellFromQuadKey = exports.getS2QuadkeyFromCellId = exports.getS2QuadKey = exports.getS2Cell = exports.getS2LngLat = exports.getS2BoundaryFlat = exports.getS2ChildCellId = exports.getS2TokenFromCellId = exports.getS2CellIdFromToken = void 0;
5
- var s2_token_functions_1 = require("./s2-token-functions");
6
- Object.defineProperty(exports, "getS2CellIdFromToken", { enumerable: true, get: function () { return s2_token_functions_1.getS2CellIdFromToken; } });
7
- Object.defineProperty(exports, "getS2TokenFromCellId", { enumerable: true, get: function () { return s2_token_functions_1.getS2TokenFromCellId; } });
8
- Object.defineProperty(exports, "getS2ChildCellId", { enumerable: true, get: function () { return s2_token_functions_1.getS2ChildCellId; } });
9
- var s2_geometry_functions_1 = require("./s2-geometry-functions");
10
- Object.defineProperty(exports, "getS2BoundaryFlat", { enumerable: true, get: function () { return s2_geometry_functions_1.getS2BoundaryFlat; } });
11
- Object.defineProperty(exports, "getS2LngLat", { enumerable: true, get: function () { return s2_geometry_functions_1.getS2LngLat; } });
12
- var s2_cell_utils_1 = require("./s2geometry/s2-cell-utils");
13
- Object.defineProperty(exports, "getS2Cell", { enumerable: true, get: function () { return s2_cell_utils_1.getS2Cell; } });
14
- Object.defineProperty(exports, "getS2QuadKey", { enumerable: true, get: function () { return s2_cell_utils_1.getS2QuadKey; } });
15
- var s2_geometry_1 = require("./s2geometry/s2-geometry");
16
- Object.defineProperty(exports, "getS2QuadkeyFromCellId", { enumerable: true, get: function () { return s2_geometry_1.getS2QuadkeyFromCellId; } });
17
- Object.defineProperty(exports, "getS2CellFromQuadKey", { enumerable: true, get: function () { return s2_geometry_1.getS2CellFromQuadKey; } });
18
- Object.defineProperty(exports, "getS2CellIdFromQuadkey", { enumerable: true, get: function () { return s2_geometry_1.getS2CellIdFromQuadkey; } });
19
- Object.defineProperty(exports, "getS2LngLatFromS2Cell", { enumerable: true, get: function () { return s2_geometry_1.getS2LngLatFromS2Cell; } });
20
- var s2_to_region_1 = require("./converters/s2-to-region");
21
- Object.defineProperty(exports, "getS2Region", { enumerable: true, get: function () { return s2_to_region_1.getS2Region; } });
22
- var s2_to_obb_points_1 = require("./converters/s2-to-obb-points");
23
- Object.defineProperty(exports, "getS2OrientedBoundingBoxCornerPoints", { enumerable: true, get: function () { return s2_to_obb_points_1.getS2OrientedBoundingBoxCornerPoints; } });
@@ -1,29 +0,0 @@
1
- "use strict";
2
- // math.gl, MIT license
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.getS2BoundaryFlat = exports.getS2LngLat = void 0;
5
- const s2_to_boundary_1 = require("./converters/s2-to-boundary");
6
- const s2_geometry_1 = require("./s2geometry/s2-geometry");
7
- const s2_cell_utils_1 = require("./s2geometry/s2-cell-utils");
8
- // GEOMETRY
9
- /**
10
- * Retrieve S2 geometry center
11
- * @param s2Token {string} A string that is the cell's hex token
12
- * @returns {[number, number]} Longitude and Latitude coordinates of the S2 cell's center
13
- */
14
- function getS2LngLat(s2Token) {
15
- const s2cell = (0, s2_cell_utils_1.getS2Cell)(s2Token);
16
- return (0, s2_geometry_1.getS2LngLatFromS2Cell)(s2cell);
17
- }
18
- exports.getS2LngLat = getS2LngLat;
19
- /**
20
- * Get a polygon with corner coordinates for an s2 cell
21
- * @param tokenOrKey {string} A string that is the cell's hex token or the Hilbert quad key (containing /)
22
- * @return {Float64Array} - a simple polygon in flat array format: [lng0, lat0, lng1, lat1, ...]
23
- * - the polygon is closed, i.e. last coordinate is a copy of the first coordinate
24
- */
25
- function getS2BoundaryFlat(tokenOrKey) {
26
- const s2cell = (0, s2_cell_utils_1.getS2Cell)(tokenOrKey);
27
- return (0, s2_to_boundary_1.getS2BoundaryFlatFromS2Cell)(s2cell);
28
- }
29
- exports.getS2BoundaryFlat = getS2BoundaryFlat;
@@ -1,68 +0,0 @@
1
- "use strict";
2
- // loaders.gl, MIT license
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.getS2ChildCellId = exports.getS2TokenFromCellId = exports.getS2CellIdFromToken = void 0;
8
- const long_1 = __importDefault(require("long"));
9
- const MAXIMUM_TOKEN_LENGTH = 16;
10
- /**
11
- * Convert the S2 token to the S2 cell ID
12
- * @param token {string} A string that is the cell's hex token. Zero cell ID is represented as 'X'.
13
- * @returns {Long} Cell id that is a 64-bit encoding of a face and a Hilbert curve parameter on that face.
14
- * See {@link https://github.com/google/s2-geometry-library-java/blob/c04b68bf3197a9c34082327eeb3aec7ab7c85da1/src/com/google/common/geometry/S2CellId.java#L439} for more information
15
- */
16
- function getS2CellIdFromToken(token) {
17
- if (token === 'X') {
18
- token = '';
19
- }
20
- // pad token with zeros to make the length 16 that is defined in MAXIMUM_TOKEN_LENGTH
21
- const paddedToken = token.padEnd(MAXIMUM_TOKEN_LENGTH, '0');
22
- return long_1.default.fromString(paddedToken, true, 16); // Hex base
23
- }
24
- exports.getS2CellIdFromToken = getS2CellIdFromToken;
25
- /**
26
- * Convert the S2 cell ID to the S2 token
27
- * @param cellId {Long} A 64-bit encoding of a face and a Hilbert curve parameter on that face.
28
- * @returns {string} A string that is the cell's hex token. Zero cell ID is represented as 'X'.
29
- */
30
- function getS2TokenFromCellId(cellId) {
31
- if (cellId.isZero()) {
32
- return 'X';
33
- }
34
- let numZeroDigits = cellId.countTrailingZeros();
35
- const remainder = numZeroDigits % 4;
36
- numZeroDigits = (numZeroDigits - remainder) / 4;
37
- const trailingZeroHexChars = numZeroDigits;
38
- numZeroDigits *= 4;
39
- const x = cellId.shiftRightUnsigned(numZeroDigits);
40
- const hexString = x.toString(16).replace(/0+$/, '');
41
- const zeroString = Array(17 - trailingZeroHexChars - hexString.length).join('0');
42
- return zeroString + hexString;
43
- }
44
- exports.getS2TokenFromCellId = getS2TokenFromCellId;
45
- /**
46
- * Get one of four S2 cell's children.
47
- * @param cellId {Long} A 64-bit encoding of a face and a Hilbert curve parameter on that face.
48
- * The cell must NOT be a leaf one. So, the cell's level is in the range [0-29].
49
- * @param index {number} Child index defines one of four S2 cell's children. Must be in the range [0-3].
50
- * @returns The ID of the cell's child.
51
- */
52
- function getS2ChildCellId(cellId, index) {
53
- // Shift sentinel bit 2 positions to the right.
54
- const newLsb = lsb(cellId).shiftRightUnsigned(2);
55
- // Insert child index before the sentinel bit.
56
- const childCellId = cellId.add(long_1.default.fromNumber(2 * index + 1 - 4).multiply(newLsb));
57
- return childCellId;
58
- }
59
- exports.getS2ChildCellId = getS2ChildCellId;
60
- /**
61
- * Return the lowest-numbered bit that is on for this cell id.
62
- * @private
63
- * @param cellId {Long} Cell id.
64
- * @returns {Long} The lowest-numbered bit that is on for this cell id.
65
- */
66
- function lsb(cellId) {
67
- return cellId.and(cellId.not().add(1)); // eslint-disable-line
68
- }
@@ -1,32 +0,0 @@
1
- "use strict";
2
- // math.gl, MIT license
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.getS2QuadKey = exports.getS2Cell = void 0;
5
- const s2_geometry_1 = require("./s2-geometry");
6
- const s2_token_functions_1 = require("../s2-token-functions");
7
- /**
8
- * Return the S2Cell from the cell's hex token or the Hilbert quad key
9
- * @param tokenOrKey {string} A string that is the cell's hex token or the Hilbert quad key (containing /)
10
- * @returns {@link S2Cell}
11
- */
12
- function getS2Cell(tokenOrKey) {
13
- const key = getS2QuadKey(tokenOrKey);
14
- const s2cell = (0, s2_geometry_1.getS2CellFromQuadKey)(key);
15
- return s2cell;
16
- }
17
- exports.getS2Cell = getS2Cell;
18
- /**
19
- * Get the underlying Hilbert quad key
20
- * @param tokenOrKey {string} A string that is the cell's hex token or the Hilbert quad key (containing /)
21
- * @returns Hilbert quad key
22
- */
23
- function getS2QuadKey(tokenOrKey) {
24
- if (tokenOrKey.indexOf('/') > 0) {
25
- // is Hilbert quad key
26
- return tokenOrKey;
27
- }
28
- // is S2 cell's hex token
29
- const id = (0, s2_token_functions_1.getS2CellIdFromToken)(tokenOrKey);
30
- return (0, s2_geometry_1.getS2QuadkeyFromCellId)(id);
31
- }
32
- exports.getS2QuadKey = getS2QuadKey;
@@ -1,260 +0,0 @@
1
- "use strict";
2
- // math.gl, MIT license
3
- /*
4
- Adapted from s2-geometry under ISC License (ISC)
5
- Copyright (c) 2012-2016, Jon Atkins <github@jonatkins.com>
6
- Copyright (c) 2016, AJ ONeal <aj@daplie.com>
7
- Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
8
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
9
- */
10
- var __importDefault = (this && this.__importDefault) || function (mod) {
11
- return (mod && mod.__esModule) ? mod : { "default": mod };
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.getCornerLngLats = exports.getS2LngLatFromS2Cell = exports.XYZToLngLat = exports.FaceUVToXYZ = exports.STToUV = exports.IJToST = exports.getS2CellIdFromQuadkey = exports.getS2QuadkeyFromCellId = exports.getS2CellFromQuadKey = void 0;
15
- const long_1 = __importDefault(require("long"));
16
- //
17
- // Functional Style
18
- //
19
- const FACE_BITS = 3;
20
- const MAX_LEVEL = 30;
21
- const POS_BITS = 2 * MAX_LEVEL + 1; // 61 (60 bits of data, 1 bit lsb marker)
22
- const RADIAN_TO_DEGREE = 180 / Math.PI;
23
- /**
24
- * Return the S2Cell
25
- * @param hilbertQuadkey {string} A string that is the Hilbert quad key (containing /)
26
- * @returns {@link S2Cell}
27
- */
28
- // eslint-disable-next-line max-statements
29
- function getS2CellFromQuadKey(hilbertQuadkey) {
30
- if (hilbertQuadkey.length === 0) {
31
- throw new Error(`Invalid Hilbert quad key ${hilbertQuadkey}`);
32
- }
33
- const parts = hilbertQuadkey.split('/');
34
- const face = parseInt(parts[0], 10); // face is in the range [0..5]
35
- const position = parts[1]; // position is in the range [0..4**30-1]
36
- const maxLevel = position.length;
37
- let level = 0;
38
- const point = [0, 0];
39
- for (let i = maxLevel - 1; i >= 0; i--) {
40
- level = maxLevel - i;
41
- const bit = position[i];
42
- let rx = 0;
43
- let ry = 0;
44
- if (bit === '1') {
45
- ry = 1;
46
- }
47
- else if (bit === '2') {
48
- rx = 1;
49
- ry = 1;
50
- }
51
- else if (bit === '3') {
52
- rx = 1;
53
- }
54
- const val = Math.pow(2, level - 1);
55
- rotateAndFlipQuadrant(val, point, rx, ry);
56
- point[0] += val * rx;
57
- point[1] += val * ry;
58
- }
59
- if (face % 2 === 1) {
60
- const t = point[0];
61
- point[0] = point[1];
62
- point[1] = t;
63
- }
64
- return { face, ij: point, level };
65
- }
66
- exports.getS2CellFromQuadKey = getS2CellFromQuadKey;
67
- /**
68
- * Convets S2 cell ID to the Hilbert quad key
69
- * @param cellId {Long} Cell id that is a 64-bit encoding of a face and a Hilbert curve parameter on that face
70
- * @returns {string} the Hilbert quad key (containing /) as a string in the format 'face/pos', where
71
- * - face is a 10-base representation of the face number
72
- * - pos is a 4-base representation of the position along the Hilbert curve. For example,
73
- * pos == '13' means the following:
74
- * The face is divided two times. After the first time the child cell with position 1 will be selected.
75
- * Then, this cell will be divided the second time, and the child cell with position 3 will be selected.
76
- */
77
- function getS2QuadkeyFromCellId(cellId) {
78
- if (cellId.isZero()) {
79
- // Invalid token
80
- return '';
81
- }
82
- let bin = cellId.toString(2);
83
- while (bin.length < FACE_BITS + POS_BITS) {
84
- // eslint-disable-next-line prefer-template
85
- bin = '0' + bin;
86
- }
87
- // MUST come AFTER binstr has been left-padded with '0's
88
- const lsbIndex = bin.lastIndexOf('1');
89
- // substring(start, end) // includes start, does not include end
90
- const faceB = bin.substring(0, 3);
91
- // posB will always be a multiple of 2 (or it's invalid)
92
- const posB = bin.substring(3, lsbIndex);
93
- const levelN = posB.length / 2;
94
- const faceS = long_1.default.fromString(faceB, true, 2).toString(10);
95
- /*
96
- Here is a fix for the case when posB is an empty string that causes an exception in Long.fromString
97
- */
98
- let posS = '';
99
- if (levelN !== 0) {
100
- // posB is not an empty string, because levelN !== 0
101
- posS = long_1.default.fromString(posB, true, 2).toString(4);
102
- while (posS.length < levelN) {
103
- // eslint-disable-next-line prefer-template
104
- posS = '0' + posS;
105
- }
106
- }
107
- // Note, posS will be "" for the level==0, which corresponds to the full face.
108
- // Example: Full face 0 (No subdivision, so level==0): Returns "0/"
109
- // TODO: Is it ok?
110
- return `${faceS}/${posS}`;
111
- }
112
- exports.getS2QuadkeyFromCellId = getS2QuadkeyFromCellId;
113
- /**
114
- * Convets S2 the Hilbert quad key to cell ID.
115
- * @param quadkey {string} The Hilbert quad key (containing /) as a string in the format 'face/pos'
116
- * @returns {Long} Cell id that is a 64-bit encoding of a face and a Hilbert curve parameter on that face
117
- */
118
- /* eslint complexity: ["error", { "max": 14 }] */
119
- function getS2CellIdFromQuadkey(hilbertQuadkey) {
120
- if (hilbertQuadkey.length === 0 || hilbertQuadkey.indexOf('/') !== 1) {
121
- throw new Error(`Invalid Hilbert quad key ${hilbertQuadkey}`);
122
- }
123
- let idS = '';
124
- const faceS = hilbertQuadkey[0];
125
- switch (faceS) {
126
- case '0':
127
- idS += '000';
128
- break;
129
- case '1':
130
- idS += '001';
131
- break;
132
- case '2':
133
- idS += '010';
134
- break;
135
- case '3':
136
- idS += '011';
137
- break;
138
- case '4':
139
- idS += '100';
140
- break;
141
- case '5':
142
- idS += '101';
143
- break;
144
- default:
145
- throw new Error(`Invalid Hilbert quad key ${hilbertQuadkey}`);
146
- }
147
- const maxLevel = hilbertQuadkey.length;
148
- // Don't convert position to Long, because it can contain leading zeros, which makes you handle it later.
149
- for (let i = 2; i < maxLevel; i++) {
150
- // The first char is a face, the second char is '/'
151
- const p = hilbertQuadkey[i];
152
- switch (p) {
153
- case '0':
154
- idS += '00';
155
- break;
156
- case '1':
157
- idS += '01';
158
- break;
159
- case '2':
160
- idS += '10';
161
- break;
162
- case '3':
163
- idS += '11';
164
- break;
165
- default:
166
- throw new Error(`Invalid Hilbert quad key ${hilbertQuadkey}`);
167
- }
168
- }
169
- // Append the sentinel bit
170
- idS += '1';
171
- const paddedId = idS.padEnd(64, '0');
172
- const id = long_1.default.fromString(paddedId, true, 2);
173
- return id;
174
- }
175
- exports.getS2CellIdFromQuadkey = getS2CellIdFromQuadkey;
176
- function IJToST(ij, level, offsets) {
177
- const maxSize = 1 << level;
178
- return [(ij[0] + offsets[0]) / maxSize, (ij[1] + offsets[1]) / maxSize];
179
- }
180
- exports.IJToST = IJToST;
181
- function singleSTtoUV(st) {
182
- if (st >= 0.5) {
183
- return (1 / 3.0) * (4 * st * st - 1);
184
- }
185
- return (1 / 3.0) * (1 - 4 * (1 - st) * (1 - st));
186
- }
187
- function STToUV(st) {
188
- return [singleSTtoUV(st[0]), singleSTtoUV(st[1])];
189
- }
190
- exports.STToUV = STToUV;
191
- function FaceUVToXYZ(face, [u, v]) {
192
- switch (face) {
193
- case 0:
194
- return [1, u, v];
195
- case 1:
196
- return [-u, 1, v];
197
- case 2:
198
- return [-u, -v, 1];
199
- case 3:
200
- return [-1, -v, -u];
201
- case 4:
202
- return [v, -1, -u];
203
- case 5:
204
- return [v, u, -1];
205
- default:
206
- throw new Error('Invalid face');
207
- }
208
- }
209
- exports.FaceUVToXYZ = FaceUVToXYZ;
210
- function XYZToLngLat([x, y, z]) {
211
- const lat = Math.atan2(z, Math.sqrt(x * x + y * y));
212
- const lng = Math.atan2(y, x);
213
- return [lng * RADIAN_TO_DEGREE, lat * RADIAN_TO_DEGREE];
214
- }
215
- exports.XYZToLngLat = XYZToLngLat;
216
- function rotateAndFlipQuadrant(n, point, rx, ry) {
217
- if (ry === 0) {
218
- if (rx === 1) {
219
- point[0] = n - 1 - point[0];
220
- point[1] = n - 1 - point[1];
221
- }
222
- const x = point[0];
223
- point[0] = point[1];
224
- point[1] = x;
225
- }
226
- }
227
- /**
228
- * Retrieve S2 geometry center
229
- * @param s2cell {S2Cell} S2 cell
230
- * @returns {[number, number]} Longitude and Latitude coordinates of the S2 cell's center
231
- */
232
- function getS2LngLatFromS2Cell(s2Cell) {
233
- const st = IJToST(s2Cell.ij, s2Cell.level, [0.5, 0.5]);
234
- const uv = STToUV(st);
235
- const xyz = FaceUVToXYZ(s2Cell.face, uv);
236
- return XYZToLngLat(xyz);
237
- }
238
- exports.getS2LngLatFromS2Cell = getS2LngLatFromS2Cell;
239
- /**
240
- * Return longitude and latitude of four corners of the cell.
241
- * @param s2Cell {S2Cell} S2 cell
242
- * @returns {Array<[number, number]>} Array of longitude and latitude pairs (in degrees) for four corners of the cell.
243
- */
244
- function getCornerLngLats(s2Cell) {
245
- const result = [];
246
- const offsets = [
247
- [0.0, 0.0],
248
- [0.0, 1.0],
249
- [1.0, 1.0],
250
- [1.0, 0.0]
251
- ];
252
- for (let i = 0; i < 4; i++) {
253
- const st = IJToST(s2Cell.ij, s2Cell.level, offsets[i]);
254
- const uv = STToUV(st);
255
- const xyz = FaceUVToXYZ(s2Cell.face, uv);
256
- result.push(XYZToLngLat(xyz));
257
- }
258
- return result;
259
- }
260
- exports.getCornerLngLats = getCornerLngLats;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VERSION = void 0;
4
- // Version constant cannot be imported, it needs to correspond to the build version of **this** module.
5
- // __VERSION__ is injected by babel-plugin-version-inline
6
- // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
- exports.VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
@@ -1,23 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Tile3DSubtreeLoader = void 0;
7
- const parse_3d_tile_subtree_1 = __importDefault(require("./lib/parsers/helpers/parse-3d-tile-subtree"));
8
- const version_1 = require("./lib/utils/version");
9
- /**
10
- * Loader for 3D Tiles Subtree
11
- *
12
- */
13
- exports.Tile3DSubtreeLoader = {
14
- id: '3d-tiles-subtree',
15
- name: '3D Tiles Subtree',
16
- module: '3d-tiles',
17
- version: version_1.VERSION,
18
- extensions: ['subtree'],
19
- mimeTypes: ['application/octet-stream'],
20
- tests: ['subtree'],
21
- parse: parse_3d_tile_subtree_1.default,
22
- options: {}
23
- };
@@ -1,27 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Tile3DWriter = void 0;
7
- const version_1 = require("./lib/utils/version");
8
- const encode_3d_tile_1 = __importDefault(require("./lib/encoders/encode-3d-tile"));
9
- /**
10
- * Exporter for 3D Tiles
11
- */
12
- exports.Tile3DWriter = {
13
- name: '3D Tile',
14
- id: '3d-tiles',
15
- module: '3d-tiles',
16
- version: version_1.VERSION,
17
- extensions: ['cmpt', 'pnts', 'b3dm', 'i3dm'],
18
- mimeTypes: ['application/octet-stream'],
19
- encodeSync,
20
- binary: true,
21
- options: {
22
- ['3d-tiles']: {}
23
- }
24
- };
25
- function encodeSync(tile, options) {
26
- return (0, encode_3d_tile_1.default)(tile, options);
27
- }