@loaders.gl/3d-tiles 3.4.10 → 3.4.12

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 (48) hide show
  1. package/dist/es5/lib/utils/version.js +1 -1
  2. package/dist/esm/lib/utils/version.js +1 -1
  3. package/package.json +7 -7
  4. package/dist/bundle.js +0 -5
  5. package/dist/cesium-ion-loader.js +0 -41
  6. package/dist/index.js +0 -26
  7. package/dist/lib/classes/helpers/tile-3d-accessor-utils.js +0 -113
  8. package/dist/lib/classes/tile-3d-batch-table-hierarchy.js +0 -197
  9. package/dist/lib/classes/tile-3d-batch-table.js +0 -245
  10. package/dist/lib/classes/tile-3d-feature-table.js +0 -72
  11. package/dist/lib/constants.js +0 -26
  12. package/dist/lib/encoders/encode-3d-tile-batched-model.js +0 -46
  13. package/dist/lib/encoders/encode-3d-tile-composite.js +0 -24
  14. package/dist/lib/encoders/encode-3d-tile-instanced-model.js +0 -38
  15. package/dist/lib/encoders/encode-3d-tile-point-cloud.js +0 -39
  16. package/dist/lib/encoders/encode-3d-tile.js +0 -33
  17. package/dist/lib/encoders/helpers/encode-3d-tile-header.js +0 -30
  18. package/dist/lib/ion/ion.js +0 -68
  19. package/dist/lib/parsers/helpers/normalize-3d-tile-colors.js +0 -65
  20. package/dist/lib/parsers/helpers/normalize-3d-tile-normals.js +0 -30
  21. package/dist/lib/parsers/helpers/normalize-3d-tile-positions.js +0 -42
  22. package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.js +0 -266
  23. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js +0 -89
  24. package/dist/lib/parsers/helpers/parse-3d-tile-header.js +0 -28
  25. package/dist/lib/parsers/helpers/parse-3d-tile-subtree.js +0 -104
  26. package/dist/lib/parsers/helpers/parse-3d-tile-tables.js +0 -93
  27. package/dist/lib/parsers/helpers/parse-utils.js +0 -32
  28. package/dist/lib/parsers/parse-3d-tile-batched-model.js +0 -33
  29. package/dist/lib/parsers/parse-3d-tile-composite.js +0 -26
  30. package/dist/lib/parsers/parse-3d-tile-gltf.js +0 -19
  31. package/dist/lib/parsers/parse-3d-tile-header.js +0 -177
  32. package/dist/lib/parsers/parse-3d-tile-instanced-model.js +0 -186
  33. package/dist/lib/parsers/parse-3d-tile-point-cloud.js +0 -411
  34. package/dist/lib/parsers/parse-3d-tile.js +0 -37
  35. package/dist/lib/utils/obb/s2-corners-to-obb.js +0 -37
  36. package/dist/lib/utils/s2/converters/s2-to-boundary.js +0 -61
  37. package/dist/lib/utils/s2/converters/s2-to-obb-points.js +0 -36
  38. package/dist/lib/utils/s2/converters/s2-to-region.js +0 -59
  39. package/dist/lib/utils/s2/index.js +0 -23
  40. package/dist/lib/utils/s2/s2-geometry-functions.js +0 -29
  41. package/dist/lib/utils/s2/s2-token-functions.js +0 -68
  42. package/dist/lib/utils/s2/s2geometry/s2-cell-utils.js +0 -32
  43. package/dist/lib/utils/s2/s2geometry/s2-geometry.js +0 -260
  44. package/dist/lib/utils/version.js +0 -7
  45. package/dist/tile-3d-subtree-loader.js +0 -23
  46. package/dist/tile-3d-writer.js +0 -27
  47. package/dist/tiles-3d-loader.js +0 -74
  48. package/dist/types.js +0 -2
@@ -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
- }
@@ -1,74 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Tiles3DLoader = void 0;
4
- const loader_utils_1 = require("@loaders.gl/loader-utils");
5
- const tiles_1 = require("@loaders.gl/tiles");
6
- const version_1 = require("./lib/utils/version");
7
- const parse_3d_tile_1 = require("./lib/parsers/parse-3d-tile");
8
- const parse_3d_tile_header_1 = require("./lib/parsers/parse-3d-tile-header");
9
- /**
10
- * Loader for 3D Tiles
11
- */
12
- exports.Tiles3DLoader = {
13
- id: '3d-tiles',
14
- name: '3D Tiles',
15
- module: '3d-tiles',
16
- version: version_1.VERSION,
17
- extensions: ['cmpt', 'pnts', 'b3dm', 'i3dm'],
18
- mimeTypes: ['application/octet-stream'],
19
- tests: ['cmpt', 'pnts', 'b3dm', 'i3dm'],
20
- parse,
21
- options: {
22
- '3d-tiles': {
23
- loadGLTF: true,
24
- decodeQuantizedPositions: false,
25
- isTileset: 'auto',
26
- assetGltfUpAxis: null
27
- }
28
- }
29
- };
30
- function getBaseUri(tileset) {
31
- return loader_utils_1.path.dirname(tileset.url);
32
- }
33
- async function parseTile(arrayBuffer, options, context) {
34
- const tile = {
35
- content: {
36
- featureIds: null
37
- }
38
- };
39
- const byteOffset = 0;
40
- await (0, parse_3d_tile_1.parse3DTile)(arrayBuffer, byteOffset, options, context, tile.content);
41
- return tile.content;
42
- }
43
- async function parseTileset(data, options, context) {
44
- const tilesetJson = JSON.parse(new TextDecoder().decode(data));
45
- // eslint-disable-next-line no-use-before-define
46
- tilesetJson.loader = options.loader || exports.Tiles3DLoader;
47
- tilesetJson.url = context.url;
48
- tilesetJson.queryString = context.queryString;
49
- // base path that non-absolute paths in tileset are relative to.
50
- tilesetJson.basePath = getBaseUri(tilesetJson);
51
- tilesetJson.root = await (0, parse_3d_tile_header_1.normalizeTileHeaders)(tilesetJson, options);
52
- tilesetJson.type = tiles_1.TILESET_TYPE.TILES3D;
53
- tilesetJson.lodMetricType = tiles_1.LOD_METRIC_TYPE.GEOMETRIC_ERROR;
54
- tilesetJson.lodMetricValue = tilesetJson.root?.lodMetricValue || 0;
55
- return tilesetJson;
56
- }
57
- async function parse(data, options, context) {
58
- // auto detect file type
59
- const loaderOptions = options['3d-tiles'] || {};
60
- let isTileset;
61
- if (loaderOptions.isTileset === 'auto') {
62
- isTileset = context.url && context.url.indexOf('.json') !== -1;
63
- }
64
- else {
65
- isTileset = loaderOptions.isTileset;
66
- }
67
- if (isTileset) {
68
- data = await parseTileset(data, options, context);
69
- }
70
- else {
71
- data = await parseTile(data, options, context);
72
- }
73
- return data;
74
- }
package/dist/types.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });