@loaders.gl/3d-tiles 3.0.9 → 3.0.13

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 (88) hide show
  1. package/dist/dist.es5.min.js +1 -1
  2. package/dist/dist.es5.min.js.map +1 -1
  3. package/dist/dist.min.js +1 -1
  4. package/dist/dist.min.js.map +1 -1
  5. package/dist/es5/bundle.js +2 -2
  6. package/dist/es5/bundle.js.map +1 -1
  7. package/dist/es5/cesium-ion-loader.js +23 -78
  8. package/dist/es5/cesium-ion-loader.js.map +1 -1
  9. package/dist/es5/index.js +7 -7
  10. package/dist/es5/lib/classes/helpers/tile-3d-accessor-utils.js +30 -42
  11. package/dist/es5/lib/classes/helpers/tile-3d-accessor-utils.js.map +1 -1
  12. package/dist/es5/lib/classes/tile-3d-batch-table-hierarchy.js +57 -59
  13. package/dist/es5/lib/classes/tile-3d-batch-table-hierarchy.js.map +1 -1
  14. package/dist/es5/lib/classes/tile-3d-batch-table.js +201 -240
  15. package/dist/es5/lib/classes/tile-3d-batch-table.js.map +1 -1
  16. package/dist/es5/lib/classes/tile-3d-feature-table.js +62 -80
  17. package/dist/es5/lib/classes/tile-3d-feature-table.js.map +1 -1
  18. package/dist/es5/lib/constants.js +4 -4
  19. package/dist/es5/lib/constants.js.map +1 -1
  20. package/dist/es5/lib/encoders/encode-3d-tile-batched-model.js +15 -22
  21. package/dist/es5/lib/encoders/encode-3d-tile-batched-model.js.map +1 -1
  22. package/dist/es5/lib/encoders/encode-3d-tile-composite.js +6 -13
  23. package/dist/es5/lib/encoders/encode-3d-tile-composite.js.map +1 -1
  24. package/dist/es5/lib/encoders/encode-3d-tile-instanced-model.js +14 -23
  25. package/dist/es5/lib/encoders/encode-3d-tile-instanced-model.js.map +1 -1
  26. package/dist/es5/lib/encoders/encode-3d-tile-point-cloud.js +15 -22
  27. package/dist/es5/lib/encoders/encode-3d-tile-point-cloud.js.map +1 -1
  28. package/dist/es5/lib/encoders/encode-3d-tile.js +3 -3
  29. package/dist/es5/lib/encoders/encode-3d-tile.js.map +1 -1
  30. package/dist/es5/lib/encoders/helpers/encode-3d-tile-header.js +6 -6
  31. package/dist/es5/lib/encoders/helpers/encode-3d-tile-header.js.map +1 -1
  32. package/dist/es5/lib/ion/ion.js +69 -197
  33. package/dist/es5/lib/ion/ion.js.map +1 -1
  34. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-colors.js +17 -18
  35. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-colors.js.map +1 -1
  36. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-normals.js +3 -3
  37. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-normals.js.map +1 -1
  38. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-positions.js +3 -3
  39. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-positions.js.map +1 -1
  40. package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js +26 -66
  41. package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
  42. package/dist/es5/lib/parsers/helpers/parse-3d-tile-header.js +3 -4
  43. package/dist/es5/lib/parsers/helpers/parse-3d-tile-header.js.map +1 -1
  44. package/dist/es5/lib/parsers/helpers/parse-3d-tile-tables.js +19 -17
  45. package/dist/es5/lib/parsers/helpers/parse-3d-tile-tables.js.map +1 -1
  46. package/dist/es5/lib/parsers/helpers/parse-utils.js +7 -8
  47. package/dist/es5/lib/parsers/helpers/parse-utils.js.map +1 -1
  48. package/dist/es5/lib/parsers/parse-3d-tile-batched-model.js +10 -36
  49. package/dist/es5/lib/parsers/parse-3d-tile-batched-model.js.map +1 -1
  50. package/dist/es5/lib/parsers/parse-3d-tile-composite.js +12 -48
  51. package/dist/es5/lib/parsers/parse-3d-tile-composite.js.map +1 -1
  52. package/dist/es5/lib/parsers/parse-3d-tile-header.js +14 -30
  53. package/dist/es5/lib/parsers/parse-3d-tile-header.js.map +1 -1
  54. package/dist/es5/lib/parsers/parse-3d-tile-instanced-model.js +38 -63
  55. package/dist/es5/lib/parsers/parse-3d-tile-instanced-model.js.map +1 -1
  56. package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js +117 -198
  57. package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
  58. package/dist/es5/lib/parsers/parse-3d-tile.js +15 -65
  59. package/dist/es5/lib/parsers/parse-3d-tile.js.map +1 -1
  60. package/dist/es5/lib/utils/version.js +1 -1
  61. package/dist/es5/lib/utils/version.js.map +1 -1
  62. package/dist/es5/tile-3d-writer.js +5 -5
  63. package/dist/es5/tile-3d-writer.js.map +1 -1
  64. package/dist/es5/tiles-3d-loader.js +35 -115
  65. package/dist/es5/tiles-3d-loader.js.map +1 -1
  66. package/dist/esm/lib/classes/tile-3d-batch-table-hierarchy.js +1 -1
  67. package/dist/esm/lib/classes/tile-3d-batch-table-hierarchy.js.map +1 -1
  68. package/dist/esm/lib/classes/tile-3d-batch-table.js +4 -4
  69. package/dist/esm/lib/classes/tile-3d-batch-table.js.map +1 -1
  70. package/dist/esm/lib/ion/ion.js +6 -6
  71. package/dist/esm/lib/ion/ion.js.map +1 -1
  72. package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js +2 -2
  73. package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
  74. package/dist/esm/lib/parsers/helpers/parse-3d-tile-header.js +1 -1
  75. package/dist/esm/lib/parsers/helpers/parse-3d-tile-header.js.map +1 -1
  76. package/dist/esm/lib/parsers/helpers/parse-3d-tile-tables.js +1 -1
  77. package/dist/esm/lib/parsers/helpers/parse-3d-tile-tables.js.map +1 -1
  78. package/dist/esm/lib/parsers/helpers/parse-utils.js +1 -5
  79. package/dist/esm/lib/parsers/helpers/parse-utils.js.map +1 -1
  80. package/dist/esm/lib/parsers/parse-3d-tile-header.js +1 -1
  81. package/dist/esm/lib/parsers/parse-3d-tile-header.js.map +1 -1
  82. package/dist/esm/lib/parsers/parse-3d-tile-instanced-model.js +1 -1
  83. package/dist/esm/lib/parsers/parse-3d-tile-instanced-model.js.map +1 -1
  84. package/dist/esm/lib/parsers/parse-3d-tile.js +1 -1
  85. package/dist/esm/lib/parsers/parse-3d-tile.js.map +1 -1
  86. package/dist/esm/lib/utils/version.js +1 -1
  87. package/dist/esm/lib/utils/version.js.map +1 -1
  88. package/package.json +8 -8
@@ -8,12 +8,6 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.parsePointCloud3DTile = parsePointCloud3DTile;
9
9
  exports.loadDraco = loadDraco;
10
10
 
11
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
12
-
13
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
-
15
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
16
-
17
11
  var _draco = require("@loaders.gl/draco");
18
12
 
19
13
  var _math = require("@loaders.gl/math");
@@ -34,44 +28,20 @@ var _normalize3dTileNormals = require("./helpers/normalize-3d-tile-normals");
34
28
 
35
29
  var _normalize3dTilePositions = require("./helpers/normalize-3d-tile-positions");
36
30
 
37
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
38
-
39
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
40
-
41
- function parsePointCloud3DTile(_x, _x2, _x3, _x4, _x5) {
42
- return _parsePointCloud3DTile.apply(this, arguments);
43
- }
44
-
45
- function _parsePointCloud3DTile() {
46
- _parsePointCloud3DTile = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(tile, arrayBuffer, byteOffset, options, context) {
47
- var _parsePointCloudTable, featureTable, batchTable;
48
-
49
- return _regenerator.default.wrap(function _callee$(_context) {
50
- while (1) {
51
- switch (_context.prev = _context.next) {
52
- case 0:
53
- byteOffset = (0, _parse3dTileHeader.parse3DTileHeaderSync)(tile, arrayBuffer, byteOffset);
54
- byteOffset = (0, _parse3dTileTables.parse3DTileTablesHeaderSync)(tile, arrayBuffer, byteOffset);
55
- byteOffset = (0, _parse3dTileTables.parse3DTileTablesSync)(tile, arrayBuffer, byteOffset, options);
56
- initializeTile(tile);
57
- _parsePointCloudTable = parsePointCloudTables(tile), featureTable = _parsePointCloudTable.featureTable, batchTable = _parsePointCloudTable.batchTable;
58
- _context.next = 7;
59
- return parseDraco(tile, featureTable, batchTable, options, context);
60
-
61
- case 7:
62
- parsePositions(tile, featureTable, options);
63
- parseColors(tile, featureTable, batchTable);
64
- parseNormals(tile, featureTable);
65
- return _context.abrupt("return", byteOffset);
66
-
67
- case 11:
68
- case "end":
69
- return _context.stop();
70
- }
71
- }
72
- }, _callee);
73
- }));
74
- return _parsePointCloud3DTile.apply(this, arguments);
31
+ async function parsePointCloud3DTile(tile, arrayBuffer, byteOffset, options, context) {
32
+ byteOffset = (0, _parse3dTileHeader.parse3DTileHeaderSync)(tile, arrayBuffer, byteOffset);
33
+ byteOffset = (0, _parse3dTileTables.parse3DTileTablesHeaderSync)(tile, arrayBuffer, byteOffset);
34
+ byteOffset = (0, _parse3dTileTables.parse3DTileTablesSync)(tile, arrayBuffer, byteOffset, options);
35
+ initializeTile(tile);
36
+ const {
37
+ featureTable,
38
+ batchTable
39
+ } = parsePointCloudTables(tile);
40
+ await parseDraco(tile, featureTable, batchTable, options, context);
41
+ parsePositions(tile, featureTable, options);
42
+ parseColors(tile, featureTable, batchTable);
43
+ parseNormals(tile, featureTable);
44
+ return byteOffset;
75
45
  }
76
46
 
77
47
  function initializeTile(tile) {
@@ -88,8 +58,8 @@ function initializeTile(tile) {
88
58
  }
89
59
 
90
60
  function parsePointCloudTables(tile) {
91
- var featureTable = new _tile3dFeatureTable.default(tile.featureTableJson, tile.featureTableBinary);
92
- var pointsLength = featureTable.getGlobalProperty('POINTS_LENGTH');
61
+ const featureTable = new _tile3dFeatureTable.default(tile.featureTableJson, tile.featureTableBinary);
62
+ const pointsLength = featureTable.getGlobalProperty('POINTS_LENGTH');
93
63
 
94
64
  if (!Number.isFinite(pointsLength)) {
95
65
  throw new Error('POINTS_LENGTH must be defined');
@@ -100,10 +70,10 @@ function parsePointCloudTables(tile) {
100
70
  tile.pointsLength = pointsLength;
101
71
  tile.pointCount = pointsLength;
102
72
  tile.rtcCenter = featureTable.getGlobalProperty('RTC_CENTER', _math.GL.FLOAT, 3);
103
- var batchTable = parseBatchIds(tile, featureTable);
73
+ const batchTable = parseBatchIds(tile, featureTable);
104
74
  return {
105
- featureTable: featureTable,
106
- batchTable: batchTable
75
+ featureTable,
76
+ batchTable
107
77
  };
108
78
  }
109
79
 
@@ -112,7 +82,7 @@ function parsePositions(tile, featureTable, options) {
112
82
  if (featureTable.hasProperty('POSITION')) {
113
83
  tile.attributes.positions = featureTable.getPropertyArray('POSITION', _math.GL.FLOAT, 3);
114
84
  } else if (featureTable.hasProperty('POSITION_QUANTIZED')) {
115
- var positions = featureTable.getPropertyArray('POSITION_QUANTIZED', _math.GL.UNSIGNED_SHORT, 3);
85
+ const positions = featureTable.getPropertyArray('POSITION_QUANTIZED', _math.GL.UNSIGNED_SHORT, 3);
116
86
  tile.isQuantized = true;
117
87
  tile.quantizedRange = (1 << 16) - 1;
118
88
  tile.quantizedVolumeScale = featureTable.getGlobalProperty('QUANTIZED_VOLUME_SCALE', _math.GL.FLOAT, 3);
@@ -138,7 +108,7 @@ function parsePositions(tile, featureTable, options) {
138
108
 
139
109
  function parseColors(tile, featureTable, batchTable) {
140
110
  if (!tile.attributes.colors) {
141
- var colors = null;
111
+ let colors = null;
142
112
 
143
113
  if (featureTable.hasProperty('RGBA')) {
144
114
  colors = featureTable.getPropertyArray('RGBA', _math.GL.UNSIGNED_BYTE, 4);
@@ -160,7 +130,7 @@ function parseColors(tile, featureTable, batchTable) {
160
130
 
161
131
  function parseNormals(tile, featureTable) {
162
132
  if (!tile.attributes.normals) {
163
- var normals = null;
133
+ let normals = null;
164
134
 
165
135
  if (featureTable.hasProperty('NORMAL')) {
166
136
  normals = featureTable.getPropertyArray('NORMAL', _math.GL.FLOAT, 3);
@@ -174,20 +144,22 @@ function parseNormals(tile, featureTable) {
174
144
  }
175
145
 
176
146
  function parseBatchIds(tile, featureTable) {
177
- var batchTable = null;
147
+ let batchTable = null;
178
148
 
179
149
  if (!tile.batchIds && featureTable.hasProperty('BATCH_ID')) {
180
150
  tile.batchIds = featureTable.getPropertyArray('BATCH_ID', _math.GL.UNSIGNED_SHORT, 1);
181
151
 
182
152
  if (tile.batchIds) {
183
- var batchFeatureLength = featureTable.getGlobalProperty('BATCH_LENGTH');
153
+ const batchFeatureLength = featureTable.getGlobalProperty('BATCH_LENGTH');
184
154
 
185
155
  if (!batchFeatureLength) {
186
156
  throw new Error('Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.');
187
157
  }
188
158
 
189
- var batchTableJson = tile.batchTableJson,
190
- batchTableBinary = tile.batchTableBinary;
159
+ const {
160
+ batchTableJson,
161
+ batchTableBinary
162
+ } = tile;
191
163
  batchTable = new _tile3dBatchTable.default(batchTableJson, batchTableBinary, batchFeatureLength);
192
164
  }
193
165
  }
@@ -195,152 +167,99 @@ function parseBatchIds(tile, featureTable) {
195
167
  return batchTable;
196
168
  }
197
169
 
198
- function parseDraco(_x6, _x7, _x8, _x9, _x10) {
199
- return _parseDraco.apply(this, arguments);
200
- }
170
+ async function parseDraco(tile, featureTable, batchTable, options, context) {
171
+ let dracoBuffer;
172
+ let dracoFeatureTableProperties;
173
+ let dracoBatchTableProperties;
174
+ const batchTableDraco = tile.batchTableJson && tile.batchTableJson.extensions && tile.batchTableJson.extensions['3DTILES_draco_point_compression'];
201
175
 
202
- function _parseDraco() {
203
- _parseDraco = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(tile, featureTable, batchTable, options, context) {
204
- var dracoBuffer, dracoFeatureTableProperties, dracoBatchTableProperties, batchTableDraco, featureTableDraco, dracoByteOffset, dracoByteLength, dracoData;
205
- return _regenerator.default.wrap(function _callee2$(_context2) {
206
- while (1) {
207
- switch (_context2.prev = _context2.next) {
208
- case 0:
209
- batchTableDraco = tile.batchTableJson && tile.batchTableJson.extensions && tile.batchTableJson.extensions['3DTILES_draco_point_compression'];
210
-
211
- if (batchTableDraco) {
212
- dracoBatchTableProperties = batchTableDraco.properties;
213
- }
214
-
215
- featureTableDraco = featureTable.getExtension('3DTILES_draco_point_compression');
216
-
217
- if (!featureTableDraco) {
218
- _context2.next = 15;
219
- break;
220
- }
221
-
222
- dracoFeatureTableProperties = featureTableDraco.properties;
223
- dracoByteOffset = featureTableDraco.byteOffset;
224
- dracoByteLength = featureTableDraco.byteLength;
225
-
226
- if (!(!dracoFeatureTableProperties || !Number.isFinite(dracoByteOffset) || !dracoByteLength)) {
227
- _context2.next = 9;
228
- break;
229
- }
230
-
231
- throw new Error('Draco properties, byteOffset, and byteLength must be defined');
232
-
233
- case 9:
234
- dracoBuffer = tile.featureTableBinary.slice(dracoByteOffset, dracoByteOffset + dracoByteLength);
235
- tile.hasPositions = Number.isFinite(dracoFeatureTableProperties.POSITION);
236
- tile.hasColors = Number.isFinite(dracoFeatureTableProperties.RGB) || Number.isFinite(dracoFeatureTableProperties.RGBA);
237
- tile.hasNormals = Number.isFinite(dracoFeatureTableProperties.NORMAL);
238
- tile.hasBatchIds = Number.isFinite(dracoFeatureTableProperties.BATCH_ID);
239
- tile.isTranslucent = Number.isFinite(dracoFeatureTableProperties.RGBA);
240
-
241
- case 15:
242
- if (dracoBuffer) {
243
- _context2.next = 17;
244
- break;
245
- }
246
-
247
- return _context2.abrupt("return", true);
248
-
249
- case 17:
250
- dracoData = {
251
- buffer: dracoBuffer,
252
- properties: _objectSpread(_objectSpread({}, dracoFeatureTableProperties), dracoBatchTableProperties),
253
- featureTableProperties: dracoFeatureTableProperties,
254
- batchTableProperties: dracoBatchTableProperties,
255
- dequantizeInShader: false
256
- };
257
- _context2.next = 20;
258
- return loadDraco(tile, dracoData, options, context);
259
-
260
- case 20:
261
- return _context2.abrupt("return", _context2.sent);
262
-
263
- case 21:
264
- case "end":
265
- return _context2.stop();
266
- }
267
- }
268
- }, _callee2);
269
- }));
270
- return _parseDraco.apply(this, arguments);
271
- }
176
+ if (batchTableDraco) {
177
+ dracoBatchTableProperties = batchTableDraco.properties;
178
+ }
179
+
180
+ const featureTableDraco = featureTable.getExtension('3DTILES_draco_point_compression');
272
181
 
273
- function loadDraco(_x11, _x12, _x13, _x14) {
274
- return _loadDraco.apply(this, arguments);
182
+ if (featureTableDraco) {
183
+ dracoFeatureTableProperties = featureTableDraco.properties;
184
+ const dracoByteOffset = featureTableDraco.byteOffset;
185
+ const dracoByteLength = featureTableDraco.byteLength;
186
+
187
+ if (!dracoFeatureTableProperties || !Number.isFinite(dracoByteOffset) || !dracoByteLength) {
188
+ throw new Error('Draco properties, byteOffset, and byteLength must be defined');
189
+ }
190
+
191
+ dracoBuffer = tile.featureTableBinary.slice(dracoByteOffset, dracoByteOffset + dracoByteLength);
192
+ tile.hasPositions = Number.isFinite(dracoFeatureTableProperties.POSITION);
193
+ tile.hasColors = Number.isFinite(dracoFeatureTableProperties.RGB) || Number.isFinite(dracoFeatureTableProperties.RGBA);
194
+ tile.hasNormals = Number.isFinite(dracoFeatureTableProperties.NORMAL);
195
+ tile.hasBatchIds = Number.isFinite(dracoFeatureTableProperties.BATCH_ID);
196
+ tile.isTranslucent = Number.isFinite(dracoFeatureTableProperties.RGBA);
197
+ }
198
+
199
+ if (!dracoBuffer) {
200
+ return true;
201
+ }
202
+
203
+ const dracoData = {
204
+ buffer: dracoBuffer,
205
+ properties: { ...dracoFeatureTableProperties,
206
+ ...dracoBatchTableProperties
207
+ },
208
+ featureTableProperties: dracoFeatureTableProperties,
209
+ batchTableProperties: dracoBatchTableProperties,
210
+ dequantizeInShader: false
211
+ };
212
+ return await loadDraco(tile, dracoData, options, context);
275
213
  }
276
214
 
277
- function _loadDraco() {
278
- _loadDraco = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee3(tile, dracoData, options, context) {
279
- var parse, dracoOptions, data, decodedPositions, decodedColors, decodedNormals, decodedBatchIds, isQuantizedDraco, isOctEncodedDraco, quantization, range, batchTableAttributes, _i, _Object$keys, attributeName;
280
-
281
- return _regenerator.default.wrap(function _callee3$(_context3) {
282
- while (1) {
283
- switch (_context3.prev = _context3.next) {
284
- case 0:
285
- parse = context.parse;
286
- dracoOptions = _objectSpread(_objectSpread({}, options), {}, {
287
- draco: _objectSpread(_objectSpread({}, options.draco), {}, {
288
- extraAttributes: dracoData.batchTableProperties || {}
289
- })
290
- });
291
- delete dracoOptions['3d-tiles'];
292
- _context3.next = 5;
293
- return parse(dracoData.buffer, _draco.DracoLoader, dracoOptions);
294
-
295
- case 5:
296
- data = _context3.sent;
297
- decodedPositions = data.attributes.POSITION && data.attributes.POSITION.value;
298
- decodedColors = data.attributes.COLOR_0 && data.attributes.COLOR_0.value;
299
- decodedNormals = data.attributes.NORMAL && data.attributes.NORMAL.value;
300
- decodedBatchIds = data.attributes.BATCH_ID && data.attributes.BATCH_ID.value;
301
- isQuantizedDraco = decodedPositions && data.attributes.POSITION.value.quantization;
302
- isOctEncodedDraco = decodedNormals && data.attributes.NORMAL.value.quantization;
303
-
304
- if (isQuantizedDraco) {
305
- quantization = data.POSITION.data.quantization;
306
- range = quantization.range;
307
- tile.quantizedVolumeScale = new _core.Vector3(range, range, range);
308
- tile.quantizedVolumeOffset = new _core.Vector3(quantization.minValues);
309
- tile.quantizedRange = (1 << quantization.quantizationBits) - 1.0;
310
- tile.isQuantizedDraco = true;
311
- }
312
-
313
- if (isOctEncodedDraco) {
314
- tile.octEncodedRange = (1 << data.NORMAL.data.quantization.quantizationBits) - 1.0;
315
- tile.isOctEncodedDraco = true;
316
- }
317
-
318
- batchTableAttributes = {};
319
-
320
- if (dracoData.batchTableProperties) {
321
- for (_i = 0, _Object$keys = Object.keys(dracoData.batchTableProperties); _i < _Object$keys.length; _i++) {
322
- attributeName = _Object$keys[_i];
323
-
324
- if (data.attributes[attributeName] && data.attributes[attributeName].value) {
325
- batchTableAttributes[attributeName.toLowerCase()] = data.attributes[attributeName].value;
326
- }
327
- }
328
- }
329
-
330
- tile.attributes = _objectSpread({
331
- positions: decodedPositions,
332
- colors: (0, _normalize3dTileColors.normalize3DTileColorAttribute)(tile, decodedColors),
333
- normals: decodedNormals,
334
- batchIds: decodedBatchIds
335
- }, batchTableAttributes);
336
-
337
- case 17:
338
- case "end":
339
- return _context3.stop();
340
- }
215
+ async function loadDraco(tile, dracoData, options, context) {
216
+ const {
217
+ parse
218
+ } = context;
219
+ const dracoOptions = { ...options,
220
+ draco: { ...options.draco,
221
+ extraAttributes: dracoData.batchTableProperties || {}
222
+ }
223
+ };
224
+ delete dracoOptions['3d-tiles'];
225
+ const data = await parse(dracoData.buffer, _draco.DracoLoader, dracoOptions);
226
+ const decodedPositions = data.attributes.POSITION && data.attributes.POSITION.value;
227
+ const decodedColors = data.attributes.COLOR_0 && data.attributes.COLOR_0.value;
228
+ const decodedNormals = data.attributes.NORMAL && data.attributes.NORMAL.value;
229
+ const decodedBatchIds = data.attributes.BATCH_ID && data.attributes.BATCH_ID.value;
230
+ const isQuantizedDraco = decodedPositions && data.attributes.POSITION.value.quantization;
231
+ const isOctEncodedDraco = decodedNormals && data.attributes.NORMAL.value.quantization;
232
+
233
+ if (isQuantizedDraco) {
234
+ const quantization = data.POSITION.data.quantization;
235
+ const range = quantization.range;
236
+ tile.quantizedVolumeScale = new _core.Vector3(range, range, range);
237
+ tile.quantizedVolumeOffset = new _core.Vector3(quantization.minValues);
238
+ tile.quantizedRange = (1 << quantization.quantizationBits) - 1.0;
239
+ tile.isQuantizedDraco = true;
240
+ }
241
+
242
+ if (isOctEncodedDraco) {
243
+ tile.octEncodedRange = (1 << data.NORMAL.data.quantization.quantizationBits) - 1.0;
244
+ tile.isOctEncodedDraco = true;
245
+ }
246
+
247
+ const batchTableAttributes = {};
248
+
249
+ if (dracoData.batchTableProperties) {
250
+ for (const attributeName of Object.keys(dracoData.batchTableProperties)) {
251
+ if (data.attributes[attributeName] && data.attributes[attributeName].value) {
252
+ batchTableAttributes[attributeName.toLowerCase()] = data.attributes[attributeName].value;
341
253
  }
342
- }, _callee3);
343
- }));
344
- return _loadDraco.apply(this, arguments);
254
+ }
255
+ }
256
+
257
+ tile.attributes = {
258
+ positions: decodedPositions,
259
+ colors: (0, _normalize3dTileColors.normalize3DTileColorAttribute)(tile, decodedColors),
260
+ normals: decodedNormals,
261
+ batchIds: decodedBatchIds,
262
+ ...batchTableAttributes
263
+ };
345
264
  }
346
265
  //# sourceMappingURL=parse-3d-tile-point-cloud.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/parsers/parse-3d-tile-point-cloud.js"],"names":["parsePointCloud3DTile","tile","arrayBuffer","byteOffset","options","context","initializeTile","parsePointCloudTables","featureTable","batchTable","parseDraco","parsePositions","parseColors","parseNormals","attributes","positions","colors","normals","batchIds","isQuantized","isTranslucent","isRGB565","isOctEncoded16P","Tile3DFeatureTable","featureTableJson","featureTableBinary","pointsLength","getGlobalProperty","Number","isFinite","Error","featuresLength","pointCount","rtcCenter","GL","FLOAT","parseBatchIds","hasProperty","getPropertyArray","UNSIGNED_SHORT","quantizedRange","quantizedVolumeScale","quantizedVolumeOffset","UNSIGNED_BYTE","constantRGBA","batchFeatureLength","batchTableJson","batchTableBinary","Tile3DBatchTable","batchTableDraco","extensions","dracoBatchTableProperties","properties","featureTableDraco","getExtension","dracoFeatureTableProperties","dracoByteOffset","dracoByteLength","byteLength","dracoBuffer","slice","hasPositions","POSITION","hasColors","RGB","RGBA","hasNormals","NORMAL","hasBatchIds","BATCH_ID","dracoData","buffer","featureTableProperties","batchTableProperties","dequantizeInShader","loadDraco","parse","dracoOptions","draco","extraAttributes","DracoLoader","data","decodedPositions","value","decodedColors","COLOR_0","decodedNormals","decodedBatchIds","isQuantizedDraco","quantization","isOctEncodedDraco","range","Vector3","minValues","quantizationBits","octEncodedRange","batchTableAttributes","Object","keys","attributeName","toLowerCase"],"mappings":";;;;;;;;;;;;;;;;AAGA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;SAEsBA,qB;;;;;qFAAf,iBAAqCC,IAArC,EAA2CC,WAA3C,EAAwDC,UAAxD,EAAoEC,OAApE,EAA6EC,OAA7E;AAAA;;AAAA;AAAA;AAAA;AAAA;AACLF,YAAAA,UAAU,GAAG,8CAAsBF,IAAtB,EAA4BC,WAA5B,EAAyCC,UAAzC,CAAb;AACAA,YAAAA,UAAU,GAAG,oDAA4BF,IAA5B,EAAkCC,WAAlC,EAA+CC,UAA/C,CAAb;AACAA,YAAAA,UAAU,GAAG,8CAAsBF,IAAtB,EAA4BC,WAA5B,EAAyCC,UAAzC,EAAqDC,OAArD,CAAb;AACAE,YAAAA,cAAc,CAACL,IAAD,CAAd;AAJK,oCAM8BM,qBAAqB,CAACN,IAAD,CANnD,EAMEO,YANF,yBAMEA,YANF,EAMgBC,UANhB,yBAMgBA,UANhB;AAAA;AAAA,mBAQCC,UAAU,CAACT,IAAD,EAAOO,YAAP,EAAqBC,UAArB,EAAiCL,OAAjC,EAA0CC,OAA1C,CARX;;AAAA;AAULM,YAAAA,cAAc,CAACV,IAAD,EAAOO,YAAP,EAAqBJ,OAArB,CAAd;AACAQ,YAAAA,WAAW,CAACX,IAAD,EAAOO,YAAP,EAAqBC,UAArB,CAAX;AACAI,YAAAA,YAAY,CAACZ,IAAD,EAAOO,YAAP,C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G","sourcesContent":["// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\nimport {DracoLoader} from '@loaders.gl/draco';\nimport {GL} from '@loaders.gl/math';\nimport {Vector3} from '@math.gl/core';\n\nimport Tile3DFeatureTable from '../classes/tile-3d-feature-table';\nimport Tile3DBatchTable from '../classes/tile-3d-batch-table';\nimport {parse3DTileHeaderSync} from './helpers/parse-3d-tile-header';\nimport {parse3DTileTablesHeaderSync, parse3DTileTablesSync} from './helpers/parse-3d-tile-tables';\nimport {normalize3DTileColorAttribute} from './helpers/normalize-3d-tile-colors';\nimport {normalize3DTileNormalAttribute} from './helpers/normalize-3d-tile-normals';\nimport {normalize3DTilePositionAttribute} from './helpers/normalize-3d-tile-positions';\n\nexport async function parsePointCloud3DTile(tile, arrayBuffer, byteOffset, options, context) {\n byteOffset = parse3DTileHeaderSync(tile, arrayBuffer, byteOffset);\n byteOffset = parse3DTileTablesHeaderSync(tile, arrayBuffer, byteOffset);\n byteOffset = parse3DTileTablesSync(tile, arrayBuffer, byteOffset, options);\n initializeTile(tile);\n\n const {featureTable, batchTable} = parsePointCloudTables(tile);\n\n await parseDraco(tile, featureTable, batchTable, options, context);\n\n parsePositions(tile, featureTable, options);\n parseColors(tile, featureTable, batchTable);\n parseNormals(tile, featureTable);\n\n return byteOffset;\n}\n\nfunction initializeTile(tile) {\n // Initialize point cloud tile defaults\n tile.attributes = {\n positions: null,\n colors: null,\n normals: null,\n batchIds: null\n };\n tile.isQuantized = false;\n tile.isTranslucent = false;\n tile.isRGB565 = false;\n tile.isOctEncoded16P = false;\n}\n\nfunction parsePointCloudTables(tile) {\n const featureTable = new Tile3DFeatureTable(tile.featureTableJson, tile.featureTableBinary);\n\n const pointsLength = featureTable.getGlobalProperty('POINTS_LENGTH');\n if (!Number.isFinite(pointsLength)) {\n throw new Error('POINTS_LENGTH must be defined');\n }\n featureTable.featuresLength = pointsLength;\n\n tile.featuresLength = pointsLength;\n tile.pointsLength = pointsLength;\n tile.pointCount = pointsLength;\n\n tile.rtcCenter = featureTable.getGlobalProperty('RTC_CENTER', GL.FLOAT, 3);\n\n const batchTable = parseBatchIds(tile, featureTable);\n\n return {featureTable, batchTable};\n}\n\nfunction parsePositions(tile, featureTable, options) {\n if (!tile.attributes.positions) {\n if (featureTable.hasProperty('POSITION')) {\n tile.attributes.positions = featureTable.getPropertyArray('POSITION', GL.FLOAT, 3);\n } else if (featureTable.hasProperty('POSITION_QUANTIZED')) {\n const positions = featureTable.getPropertyArray('POSITION_QUANTIZED', GL.UNSIGNED_SHORT, 3);\n\n tile.isQuantized = true;\n tile.quantizedRange = (1 << 16) - 1;\n\n tile.quantizedVolumeScale = featureTable.getGlobalProperty(\n 'QUANTIZED_VOLUME_SCALE',\n GL.FLOAT,\n 3\n );\n if (!tile.quantizedVolumeScale) {\n throw new Error('QUANTIZED_VOLUME_SCALE must be defined for quantized positions.');\n }\n\n tile.quantizedVolumeOffset = featureTable.getGlobalProperty(\n 'QUANTIZED_VOLUME_OFFSET',\n GL.FLOAT,\n 3\n );\n if (!tile.quantizedVolumeOffset) {\n throw new Error('QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.');\n }\n\n tile.attributes.positions = normalize3DTilePositionAttribute(tile, positions, options);\n }\n }\n\n if (!tile.attributes.positions) {\n throw new Error('Either POSITION or POSITION_QUANTIZED must be defined.');\n }\n}\n\nfunction parseColors(tile, featureTable, batchTable) {\n if (!tile.attributes.colors) {\n let colors = null;\n if (featureTable.hasProperty('RGBA')) {\n colors = featureTable.getPropertyArray('RGBA', GL.UNSIGNED_BYTE, 4);\n tile.isTranslucent = true;\n } else if (featureTable.hasProperty('RGB')) {\n colors = featureTable.getPropertyArray('RGB', GL.UNSIGNED_BYTE, 3);\n } else if (featureTable.hasProperty('RGB565')) {\n colors = featureTable.getPropertyArray('RGB565', GL.UNSIGNED_SHORT, 1);\n tile.isRGB565 = true;\n }\n\n tile.attributes.colors = normalize3DTileColorAttribute(tile, colors, batchTable);\n }\n\n if (featureTable.hasProperty('CONSTANT_RGBA')) {\n tile.constantRGBA = featureTable.getGlobalProperty('CONSTANT_RGBA', GL.UNSIGNED_BYTE, 4);\n }\n}\n\nfunction parseNormals(tile, featureTable) {\n if (!tile.attributes.normals) {\n let normals = null;\n if (featureTable.hasProperty('NORMAL')) {\n normals = featureTable.getPropertyArray('NORMAL', GL.FLOAT, 3);\n } else if (featureTable.hasProperty('NORMAL_OCT16P')) {\n normals = featureTable.getPropertyArray('NORMAL_OCT16P', GL.UNSIGNED_BYTE, 2);\n tile.isOctEncoded16P = true;\n }\n\n tile.attributes.normals = normalize3DTileNormalAttribute(tile, normals);\n }\n}\n\nfunction parseBatchIds(tile, featureTable) {\n let batchTable = null;\n if (!tile.batchIds && featureTable.hasProperty('BATCH_ID')) {\n tile.batchIds = featureTable.getPropertyArray('BATCH_ID', GL.UNSIGNED_SHORT, 1);\n\n if (tile.batchIds) {\n const batchFeatureLength = featureTable.getGlobalProperty('BATCH_LENGTH');\n if (!batchFeatureLength) {\n throw new Error('Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.');\n }\n const {batchTableJson, batchTableBinary} = tile;\n batchTable = new Tile3DBatchTable(batchTableJson, batchTableBinary, batchFeatureLength);\n }\n }\n return batchTable;\n}\n\n// eslint-disable-next-line complexity\nasync function parseDraco(tile, featureTable, batchTable, options, context) {\n let dracoBuffer;\n let dracoFeatureTableProperties;\n let dracoBatchTableProperties;\n const batchTableDraco =\n tile.batchTableJson &&\n tile.batchTableJson.extensions &&\n tile.batchTableJson.extensions['3DTILES_draco_point_compression'];\n if (batchTableDraco) {\n dracoBatchTableProperties = batchTableDraco.properties;\n }\n\n const featureTableDraco = featureTable.getExtension('3DTILES_draco_point_compression');\n if (featureTableDraco) {\n dracoFeatureTableProperties = featureTableDraco.properties;\n const dracoByteOffset = featureTableDraco.byteOffset;\n const dracoByteLength = featureTableDraco.byteLength;\n if (!dracoFeatureTableProperties || !Number.isFinite(dracoByteOffset) || !dracoByteLength) {\n throw new Error('Draco properties, byteOffset, and byteLength must be defined');\n }\n\n dracoBuffer = tile.featureTableBinary.slice(dracoByteOffset, dracoByteOffset + dracoByteLength);\n\n tile.hasPositions = Number.isFinite(dracoFeatureTableProperties.POSITION);\n tile.hasColors =\n Number.isFinite(dracoFeatureTableProperties.RGB) ||\n Number.isFinite(dracoFeatureTableProperties.RGBA);\n tile.hasNormals = Number.isFinite(dracoFeatureTableProperties.NORMAL);\n tile.hasBatchIds = Number.isFinite(dracoFeatureTableProperties.BATCH_ID);\n tile.isTranslucent = Number.isFinite(dracoFeatureTableProperties.RGBA);\n }\n\n if (!dracoBuffer) {\n return true;\n }\n\n const dracoData = {\n buffer: dracoBuffer,\n properties: {...dracoFeatureTableProperties, ...dracoBatchTableProperties},\n featureTableProperties: dracoFeatureTableProperties,\n batchTableProperties: dracoBatchTableProperties,\n dequantizeInShader: false\n };\n\n return await loadDraco(tile, dracoData, options, context);\n}\n\n// eslint-disable-next-line complexity, max-statements\nexport async function loadDraco(tile, dracoData, options, context) {\n const {parse} = context;\n const dracoOptions = {\n ...options,\n draco: {\n ...options.draco,\n extraAttributes: dracoData.batchTableProperties || {}\n }\n };\n\n // The entire tileset might be included, too expensive to serialize\n delete dracoOptions['3d-tiles'];\n\n const data = await parse(dracoData.buffer, DracoLoader, dracoOptions);\n\n const decodedPositions = data.attributes.POSITION && data.attributes.POSITION.value;\n const decodedColors = data.attributes.COLOR_0 && data.attributes.COLOR_0.value;\n const decodedNormals = data.attributes.NORMAL && data.attributes.NORMAL.value;\n const decodedBatchIds = data.attributes.BATCH_ID && data.attributes.BATCH_ID.value;\n const isQuantizedDraco = decodedPositions && data.attributes.POSITION.value.quantization;\n const isOctEncodedDraco = decodedNormals && data.attributes.NORMAL.value.quantization;\n if (isQuantizedDraco) {\n // Draco quantization range == quantized volume scale - size in meters of the quantized volume\n // Internal quantized range is the range of values of the quantized data, e.g. 255 for 8-bit, 1023 for 10-bit, etc\n const quantization = data.POSITION.data.quantization;\n const range = quantization.range;\n tile.quantizedVolumeScale = new Vector3(range, range, range);\n tile.quantizedVolumeOffset = new Vector3(quantization.minValues);\n tile.quantizedRange = (1 << quantization.quantizationBits) - 1.0;\n tile.isQuantizedDraco = true;\n }\n if (isOctEncodedDraco) {\n tile.octEncodedRange = (1 << data.NORMAL.data.quantization.quantizationBits) - 1.0;\n tile.isOctEncodedDraco = true;\n }\n\n // Extra batch table attributes\n const batchTableAttributes = {};\n if (dracoData.batchTableProperties) {\n for (const attributeName of Object.keys(dracoData.batchTableProperties)) {\n if (data.attributes[attributeName] && data.attributes[attributeName].value) {\n batchTableAttributes[attributeName.toLowerCase()] = data.attributes[attributeName].value;\n }\n }\n }\n\n tile.attributes = {\n positions: decodedPositions,\n colors: normalize3DTileColorAttribute(tile, decodedColors),\n normals: decodedNormals,\n batchIds: decodedBatchIds,\n ...batchTableAttributes\n };\n}\n\n// TODO - this is the remaining code from Cesium's parser\n/*\n const batchTable = new Tile3DBatchTable(tile);\n\n // parseDracoBuffer(tile, featureTable, batchTable);\n\n if (!tile.attributes.positions) {\n throw new Error('Either POSITION or POSITION_QUANTIZED must be defined.');\n }\n}\n/*\n\n if (!tile.attributes.positions) {\n if (featureTable.hasProperty('POSITION')) {\n tile.attributes.positions = featureTable.getPropertyArray('POSITION', GL.FLOAT, 3);\n } else if (featureTable.hasProperty('POSITION_QUANTIZED')) {\n tile.attributes.positions = featureTable.getPropertyArray('POSITION_QUANTIZED', GL.UNSIGNED_SHORT, 3);\n\n\n if (!tile.colors) {\n if (featureTable.hasProperty('RGBA')) {\n tile.colors = featureTable.getPropertyArray('RGBA', GL.UNSIGNED_BYTE, 4);\n tile.isTranslucent = true;\n } else if (featureTable.hasProperty('RGB')) {\n tile.colors = featureTable.getPropertyArray('RGB', GL.UNSIGNED_BYTE, 3);\n } else if (featureTable.hasPropertry('RGB565')) {\n tile.colors = featureTable.getPropertyArray('RGB565', GL.UNSIGNED_SHORT, 1);\n tile.isRGB565 = true;\n }\n }\n\n if (!tile.attributes.normals) {\n if (featureTable.getPropertry('NORMAL')) {\n tile.attributes.normals = featureTable.getPropertyArray('NORMAL', GL.FLOAT, 3);\n } else if (featureTable.getProperty('NORMAL_OCT16P')) {\n tile.attributes.normals = featureTable.getPropertyArray('NORMAL_OCT16P', GL.UNSIGNED_BYTE, 2);\n tile.isOctEncoded16P = true;\n }\n }\n\n if (!tile.batchIds) {\n if (featureTable.hasProperty('BATCH_ID')) {\n tile.batchIds = featureTable.getPropertyArray('BATCH_ID', GL.UNSIGNED_SHORT, 1);\n }\n }\n\n if (!tile.attributes.positions) {\n throw new Error('Either POSITION or POSITION_QUANTIZED must be defined.');\n }\n\n if (featureTable.getPropertry('CONSTANT_RGBA')) {\n tile.constantRGBA = featureTable.getGlobalProperty('CONSTANT_RGBA', GL.UNSIGNED_BYTE, 4);\n }\n\n if (tile.batchIds) {\n const batchLength = featureTable.getGlobalProperty('BATCH_LENGTH');\n if (!defined(batchLength)) {\n throw new Error('Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.');\n }\n\n if (defined(batchTableBinary)) {\n // Copy the batchTableBinary section and let the underlying ArrayBuffer be freed\n batchTableBinary = new Uint8Array(batchTableBinary);\n }\n\n if (defined(pointCloud._batchTableLoaded)) {\n pointCloud._batchTableLoaded(batchLength, batchTableJson, batchTableBinary);\n }\n }\n\n // If points are not batched and there are per-point properties, use these properties for styling purposes\n var styleableProperties;\n if (!hasBatchIds && defined(batchTableBinary)) {\n tile.styleableProperties = Cesium3DTileBatchTable.getBinaryProperties(\n pointsLength,\n batchTableJson,\n batchTableBinary\n );\n }\n\n tile.draco = draco;\n}\n\n// Separate parsing and decoding of Draco\nexport function parseDracoBuffer(tile, featureTable, batchTable) {\n let dracoBuffer;\n let dracoFeatureTableProperties;\n let dracoBatchTableProperties;\n\n const batchTableDraco = batchTable.getExtension('3DTILES_draco_point_compression');\n if (batchTableDraco) {\n dracoBatchTableProperties = batchTableDraco.properties;\n }\n\n const featureTableDraco = featureTable.getExtension('3DTILES_draco_point_compression');\n if (featureTableDraco) {\n dracoFeatureTableProperties = featureTableDraco.properties;\n const dracoByteOffset = featureTableDraco.byteOffset;\n const dracoByteLength = featureTableDraco.byteLength;\n if (!dracoFeatureTableProperties || !dracoByteOffset || !dracoByteLength) {\n throw new Error('Draco properties, byteOffset, and byteLength must be defined');\n }\n\n dracoBuffer = arraySlice(\n featureTableBinary,\n dracoByteOffset,\n dracoByteOffset + dracoByteLength\n );\n tile.hasPositions = dracoFeatureTableProperties.POSITION;\n tile.hasColors = dracoFeatureTableProperties.RGB || dracoFeatureTableProperties.RGBA;\n tile.hasNormals = dracoFeatureTableProperties.NORMAL;\n tile.hasBatchIds = dracoFeatureTableProperties.BATCH_ID;\n tile.isTranslucent = dracoFeatureTableProperties.RGBA;\n }\n\n if (dracoBuffer) {\n tile.draco = {\n buffer: dracoBuffer,\n properties: {...dracoFeatureTableProperties, ...dracoBatchTableProperties},\n featureTableProperties: dracoFeatureTableProperties,\n batchTableProperties: dracoBatchTableProperties,\n dequantizeInShader: false\n };\n\n tile.decodingState = DECODING_STATE.NEEDS_DECODE;\n }\n}\n\n/*\nfunction decodeDraco(tile, context) {\n if (tile.decodingState === DECODING_STATE.READY) {\n return false;\n }\n if (tile.decodingState === DECODING_STATE.NEEDS_DECODE) {\n var parsedContent = tile._parsedContent;\n var draco = parsedContent.draco;\n var decodePromise = DracoLoader.decodePointCloud(draco, context);\n if (defined(decodePromise)) {\n tile.decodingState = DECODING_STATE.DECODING;\n decodePromise.then(function(result) {\n tile.decodingState = DECODING_STATE.READY;\n var decodedPositions = defined(result.POSITION) ? result.POSITION.array : undefined;\n var decodedRgb = defined(result.RGB) ? result.RGB.array : undefined;\n var decodedRgba = defined(result.RGBA) ? result.RGBA.array : undefined;\n var decodedNormals = defined(result.NORMAL) ? result.NORMAL.array : undefined;\n var decodedBatchIds = defined(result.BATCH_ID) ? result.BATCH_ID.array : undefined;\n var isQuantizedDraco = defined(decodedPositions) && defined(result.POSITION.data.quantization);\n var isOctEncodedDraco = defined(decodedNormals) && defined(result.NORMAL.data.quantization);\n if (isQuantizedDraco) {\n // Draco quantization range == quantized volume scale - size in meters of the quantized volume\n // Internal quantized range is the range of values of the quantized data, e.g. 255 for 8-bit, 1023 for 10-bit, etc\n var quantization = result.POSITION.data.quantization;\n var range = quantization.range;\n tile._quantizedVolumeScale = Cartesian3.fromElements(range, range, range);\n tile._quantizedVolumeOffset = Cartesian3.unpack(quantization.minValues);\n tile._quantizedRange = (1 << quantization.quantizationBits) - 1.0;\n tile._isQuantizedDraco = true;\n }\n if (isOctEncodedDraco) {\n tile._octEncodedRange = (1 << result.NORMAL.data.quantization.quantizationBits) - 1.0;\n tile._isOctEncodedDraco = true;\n }\n var styleableProperties = parsedContent.styleableProperties;\n var batchTableProperties = draco.batchTableProperties;\n for (var name in batchTableProperties) {\n if (batchTableProperties.hasOwnProperty(name)) {\n var property = result[name];\n if (!defined(styleableProperties)) {\n styleableProperties = {};\n }\n styleableProperties[name] = {\n typedArray : property.array,\n componentCount : property.data.componentsPerAttribute\n };\n }\n }\n parsedContent.positions = defaultValue(decodedPositions, parsedContent.positions);\n parsedContent.colors = defaultValue(defaultValue(decodedRgba, decodedRgb), parsedContent.colors);\n parsedContent.normals = defaultValue(decodedNormals, parsedContent.normals);\n parsedContent.batchIds = defaultValue(decodedBatchIds, parsedContent.batchIds);\n parsedContent.styleableProperties = styleableProperties;\n }).otherwise(function(error) {\n tile.decodingState = DECODING_STATE.FAILED;\n tile._readyPromise.reject(error);\n });\n }\n }\n return true;\n}\n*/\n"],"file":"parse-3d-tile-point-cloud.js"}
1
+ {"version":3,"sources":["../../../../src/lib/parsers/parse-3d-tile-point-cloud.js"],"names":["parsePointCloud3DTile","tile","arrayBuffer","byteOffset","options","context","initializeTile","featureTable","batchTable","parsePointCloudTables","parseDraco","parsePositions","parseColors","parseNormals","attributes","positions","colors","normals","batchIds","isQuantized","isTranslucent","isRGB565","isOctEncoded16P","Tile3DFeatureTable","featureTableJson","featureTableBinary","pointsLength","getGlobalProperty","Number","isFinite","Error","featuresLength","pointCount","rtcCenter","GL","FLOAT","parseBatchIds","hasProperty","getPropertyArray","UNSIGNED_SHORT","quantizedRange","quantizedVolumeScale","quantizedVolumeOffset","UNSIGNED_BYTE","constantRGBA","batchFeatureLength","batchTableJson","batchTableBinary","Tile3DBatchTable","dracoBuffer","dracoFeatureTableProperties","dracoBatchTableProperties","batchTableDraco","extensions","properties","featureTableDraco","getExtension","dracoByteOffset","dracoByteLength","byteLength","slice","hasPositions","POSITION","hasColors","RGB","RGBA","hasNormals","NORMAL","hasBatchIds","BATCH_ID","dracoData","buffer","featureTableProperties","batchTableProperties","dequantizeInShader","loadDraco","parse","dracoOptions","draco","extraAttributes","data","DracoLoader","decodedPositions","value","decodedColors","COLOR_0","decodedNormals","decodedBatchIds","isQuantizedDraco","quantization","isOctEncodedDraco","range","Vector3","minValues","quantizationBits","octEncodedRange","batchTableAttributes","attributeName","Object","keys","toLowerCase"],"mappings":";;;;;;;;;;AAGA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEO,eAAeA,qBAAf,CAAqCC,IAArC,EAA2CC,WAA3C,EAAwDC,UAAxD,EAAoEC,OAApE,EAA6EC,OAA7E,EAAsF;AAC3FF,EAAAA,UAAU,GAAG,8CAAsBF,IAAtB,EAA4BC,WAA5B,EAAyCC,UAAzC,CAAb;AACAA,EAAAA,UAAU,GAAG,oDAA4BF,IAA5B,EAAkCC,WAAlC,EAA+CC,UAA/C,CAAb;AACAA,EAAAA,UAAU,GAAG,8CAAsBF,IAAtB,EAA4BC,WAA5B,EAAyCC,UAAzC,EAAqDC,OAArD,CAAb;AACAE,EAAAA,cAAc,CAACL,IAAD,CAAd;AAEA,QAAM;AAACM,IAAAA,YAAD;AAAeC,IAAAA;AAAf,MAA6BC,qBAAqB,CAACR,IAAD,CAAxD;AAEA,QAAMS,UAAU,CAACT,IA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md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\nimport {DracoLoader} from '@loaders.gl/draco';\nimport {GL} from '@loaders.gl/math';\nimport {Vector3} from '@math.gl/core';\n\nimport Tile3DFeatureTable from '../classes/tile-3d-feature-table';\nimport Tile3DBatchTable from '../classes/tile-3d-batch-table';\nimport {parse3DTileHeaderSync} from './helpers/parse-3d-tile-header';\nimport {parse3DTileTablesHeaderSync, parse3DTileTablesSync} from './helpers/parse-3d-tile-tables';\nimport {normalize3DTileColorAttribute} from './helpers/normalize-3d-tile-colors';\nimport {normalize3DTileNormalAttribute} from './helpers/normalize-3d-tile-normals';\nimport {normalize3DTilePositionAttribute} from './helpers/normalize-3d-tile-positions';\n\nexport async function parsePointCloud3DTile(tile, arrayBuffer, byteOffset, options, context) {\n byteOffset = parse3DTileHeaderSync(tile, arrayBuffer, byteOffset);\n byteOffset = parse3DTileTablesHeaderSync(tile, arrayBuffer, byteOffset);\n byteOffset = parse3DTileTablesSync(tile, arrayBuffer, byteOffset, options);\n initializeTile(tile);\n\n const {featureTable, batchTable} = parsePointCloudTables(tile);\n\n await parseDraco(tile, featureTable, batchTable, options, context);\n\n parsePositions(tile, featureTable, options);\n parseColors(tile, featureTable, batchTable);\n parseNormals(tile, featureTable);\n\n return byteOffset;\n}\n\nfunction initializeTile(tile) {\n // Initialize point cloud tile defaults\n tile.attributes = {\n positions: null,\n colors: null,\n normals: null,\n batchIds: null\n };\n tile.isQuantized = false;\n tile.isTranslucent = false;\n tile.isRGB565 = false;\n tile.isOctEncoded16P = false;\n}\n\nfunction parsePointCloudTables(tile) {\n const featureTable = new Tile3DFeatureTable(tile.featureTableJson, tile.featureTableBinary);\n\n const pointsLength = featureTable.getGlobalProperty('POINTS_LENGTH');\n if (!Number.isFinite(pointsLength)) {\n throw new Error('POINTS_LENGTH must be defined');\n }\n featureTable.featuresLength = pointsLength;\n\n tile.featuresLength = pointsLength;\n tile.pointsLength = pointsLength;\n tile.pointCount = pointsLength;\n\n tile.rtcCenter = featureTable.getGlobalProperty('RTC_CENTER', GL.FLOAT, 3);\n\n const batchTable = parseBatchIds(tile, featureTable);\n\n return {featureTable, batchTable};\n}\n\nfunction parsePositions(tile, featureTable, options) {\n if (!tile.attributes.positions) {\n if (featureTable.hasProperty('POSITION')) {\n tile.attributes.positions = featureTable.getPropertyArray('POSITION', GL.FLOAT, 3);\n } else if (featureTable.hasProperty('POSITION_QUANTIZED')) {\n const positions = featureTable.getPropertyArray('POSITION_QUANTIZED', GL.UNSIGNED_SHORT, 3);\n\n tile.isQuantized = true;\n tile.quantizedRange = (1 << 16) - 1;\n\n tile.quantizedVolumeScale = featureTable.getGlobalProperty(\n 'QUANTIZED_VOLUME_SCALE',\n GL.FLOAT,\n 3\n );\n if (!tile.quantizedVolumeScale) {\n throw new Error('QUANTIZED_VOLUME_SCALE must be defined for quantized positions.');\n }\n\n tile.quantizedVolumeOffset = featureTable.getGlobalProperty(\n 'QUANTIZED_VOLUME_OFFSET',\n GL.FLOAT,\n 3\n );\n if (!tile.quantizedVolumeOffset) {\n throw new Error('QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.');\n }\n\n tile.attributes.positions = normalize3DTilePositionAttribute(tile, positions, options);\n }\n }\n\n if (!tile.attributes.positions) {\n throw new Error('Either POSITION or POSITION_QUANTIZED must be defined.');\n }\n}\n\nfunction parseColors(tile, featureTable, batchTable) {\n if (!tile.attributes.colors) {\n let colors = null;\n if (featureTable.hasProperty('RGBA')) {\n colors = featureTable.getPropertyArray('RGBA', GL.UNSIGNED_BYTE, 4);\n tile.isTranslucent = true;\n } else if (featureTable.hasProperty('RGB')) {\n colors = featureTable.getPropertyArray('RGB', GL.UNSIGNED_BYTE, 3);\n } else if (featureTable.hasProperty('RGB565')) {\n colors = featureTable.getPropertyArray('RGB565', GL.UNSIGNED_SHORT, 1);\n tile.isRGB565 = true;\n }\n\n tile.attributes.colors = normalize3DTileColorAttribute(tile, colors, batchTable);\n }\n\n if (featureTable.hasProperty('CONSTANT_RGBA')) {\n tile.constantRGBA = featureTable.getGlobalProperty('CONSTANT_RGBA', GL.UNSIGNED_BYTE, 4);\n }\n}\n\nfunction parseNormals(tile, featureTable) {\n if (!tile.attributes.normals) {\n let normals = null;\n if (featureTable.hasProperty('NORMAL')) {\n normals = featureTable.getPropertyArray('NORMAL', GL.FLOAT, 3);\n } else if (featureTable.hasProperty('NORMAL_OCT16P')) {\n normals = featureTable.getPropertyArray('NORMAL_OCT16P', GL.UNSIGNED_BYTE, 2);\n tile.isOctEncoded16P = true;\n }\n\n tile.attributes.normals = normalize3DTileNormalAttribute(tile, normals);\n }\n}\n\nfunction parseBatchIds(tile, featureTable) {\n let batchTable = null;\n if (!tile.batchIds && featureTable.hasProperty('BATCH_ID')) {\n tile.batchIds = featureTable.getPropertyArray('BATCH_ID', GL.UNSIGNED_SHORT, 1);\n\n if (tile.batchIds) {\n const batchFeatureLength = featureTable.getGlobalProperty('BATCH_LENGTH');\n if (!batchFeatureLength) {\n throw new Error('Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.');\n }\n const {batchTableJson, batchTableBinary} = tile;\n batchTable = new Tile3DBatchTable(batchTableJson, batchTableBinary, batchFeatureLength);\n }\n }\n return batchTable;\n}\n\n// eslint-disable-next-line complexity\nasync function parseDraco(tile, featureTable, batchTable, options, context) {\n let dracoBuffer;\n let dracoFeatureTableProperties;\n let dracoBatchTableProperties;\n const batchTableDraco =\n tile.batchTableJson &&\n tile.batchTableJson.extensions &&\n tile.batchTableJson.extensions['3DTILES_draco_point_compression'];\n if (batchTableDraco) {\n dracoBatchTableProperties = batchTableDraco.properties;\n }\n\n const featureTableDraco = featureTable.getExtension('3DTILES_draco_point_compression');\n if (featureTableDraco) {\n dracoFeatureTableProperties = featureTableDraco.properties;\n const dracoByteOffset = featureTableDraco.byteOffset;\n const dracoByteLength = featureTableDraco.byteLength;\n if (!dracoFeatureTableProperties || !Number.isFinite(dracoByteOffset) || !dracoByteLength) {\n throw new Error('Draco properties, byteOffset, and byteLength must be defined');\n }\n\n dracoBuffer = tile.featureTableBinary.slice(dracoByteOffset, dracoByteOffset + dracoByteLength);\n\n tile.hasPositions = Number.isFinite(dracoFeatureTableProperties.POSITION);\n tile.hasColors =\n Number.isFinite(dracoFeatureTableProperties.RGB) ||\n Number.isFinite(dracoFeatureTableProperties.RGBA);\n tile.hasNormals = Number.isFinite(dracoFeatureTableProperties.NORMAL);\n tile.hasBatchIds = Number.isFinite(dracoFeatureTableProperties.BATCH_ID);\n tile.isTranslucent = Number.isFinite(dracoFeatureTableProperties.RGBA);\n }\n\n if (!dracoBuffer) {\n return true;\n }\n\n const dracoData = {\n buffer: dracoBuffer,\n properties: {...dracoFeatureTableProperties, ...dracoBatchTableProperties},\n featureTableProperties: dracoFeatureTableProperties,\n batchTableProperties: dracoBatchTableProperties,\n dequantizeInShader: false\n };\n\n return await loadDraco(tile, dracoData, options, context);\n}\n\n// eslint-disable-next-line complexity, max-statements\nexport async function loadDraco(tile, dracoData, options, context) {\n const {parse} = context;\n const dracoOptions = {\n ...options,\n draco: {\n ...options.draco,\n extraAttributes: dracoData.batchTableProperties || {}\n }\n };\n\n // The entire tileset might be included, too expensive to serialize\n delete dracoOptions['3d-tiles'];\n\n const data = await parse(dracoData.buffer, DracoLoader, dracoOptions);\n\n const decodedPositions = data.attributes.POSITION && data.attributes.POSITION.value;\n const decodedColors = data.attributes.COLOR_0 && data.attributes.COLOR_0.value;\n const decodedNormals = data.attributes.NORMAL && data.attributes.NORMAL.value;\n const decodedBatchIds = data.attributes.BATCH_ID && data.attributes.BATCH_ID.value;\n const isQuantizedDraco = decodedPositions && data.attributes.POSITION.value.quantization;\n const isOctEncodedDraco = decodedNormals && data.attributes.NORMAL.value.quantization;\n if (isQuantizedDraco) {\n // Draco quantization range == quantized volume scale - size in meters of the quantized volume\n // Internal quantized range is the range of values of the quantized data, e.g. 255 for 8-bit, 1023 for 10-bit, etc\n const quantization = data.POSITION.data.quantization;\n const range = quantization.range;\n tile.quantizedVolumeScale = new Vector3(range, range, range);\n tile.quantizedVolumeOffset = new Vector3(quantization.minValues);\n tile.quantizedRange = (1 << quantization.quantizationBits) - 1.0;\n tile.isQuantizedDraco = true;\n }\n if (isOctEncodedDraco) {\n tile.octEncodedRange = (1 << data.NORMAL.data.quantization.quantizationBits) - 1.0;\n tile.isOctEncodedDraco = true;\n }\n\n // Extra batch table attributes\n const batchTableAttributes = {};\n if (dracoData.batchTableProperties) {\n for (const attributeName of Object.keys(dracoData.batchTableProperties)) {\n if (data.attributes[attributeName] && data.attributes[attributeName].value) {\n batchTableAttributes[attributeName.toLowerCase()] = data.attributes[attributeName].value;\n }\n }\n }\n\n tile.attributes = {\n positions: decodedPositions,\n colors: normalize3DTileColorAttribute(tile, decodedColors),\n normals: decodedNormals,\n batchIds: decodedBatchIds,\n ...batchTableAttributes\n };\n}\n\n// TODO - this is the remaining code from Cesium's parser\n/*\n const batchTable = new Tile3DBatchTable(tile);\n\n // parseDracoBuffer(tile, featureTable, batchTable);\n\n if (!tile.attributes.positions) {\n throw new Error('Either POSITION or POSITION_QUANTIZED must be defined.');\n }\n}\n/*\n\n if (!tile.attributes.positions) {\n if (featureTable.hasProperty('POSITION')) {\n tile.attributes.positions = featureTable.getPropertyArray('POSITION', GL.FLOAT, 3);\n } else if (featureTable.hasProperty('POSITION_QUANTIZED')) {\n tile.attributes.positions = featureTable.getPropertyArray('POSITION_QUANTIZED', GL.UNSIGNED_SHORT, 3);\n\n\n if (!tile.colors) {\n if (featureTable.hasProperty('RGBA')) {\n tile.colors = featureTable.getPropertyArray('RGBA', GL.UNSIGNED_BYTE, 4);\n tile.isTranslucent = true;\n } else if (featureTable.hasProperty('RGB')) {\n tile.colors = featureTable.getPropertyArray('RGB', GL.UNSIGNED_BYTE, 3);\n } else if (featureTable.hasPropertry('RGB565')) {\n tile.colors = featureTable.getPropertyArray('RGB565', GL.UNSIGNED_SHORT, 1);\n tile.isRGB565 = true;\n }\n }\n\n if (!tile.attributes.normals) {\n if (featureTable.getPropertry('NORMAL')) {\n tile.attributes.normals = featureTable.getPropertyArray('NORMAL', GL.FLOAT, 3);\n } else if (featureTable.getProperty('NORMAL_OCT16P')) {\n tile.attributes.normals = featureTable.getPropertyArray('NORMAL_OCT16P', GL.UNSIGNED_BYTE, 2);\n tile.isOctEncoded16P = true;\n }\n }\n\n if (!tile.batchIds) {\n if (featureTable.hasProperty('BATCH_ID')) {\n tile.batchIds = featureTable.getPropertyArray('BATCH_ID', GL.UNSIGNED_SHORT, 1);\n }\n }\n\n if (!tile.attributes.positions) {\n throw new Error('Either POSITION or POSITION_QUANTIZED must be defined.');\n }\n\n if (featureTable.getPropertry('CONSTANT_RGBA')) {\n tile.constantRGBA = featureTable.getGlobalProperty('CONSTANT_RGBA', GL.UNSIGNED_BYTE, 4);\n }\n\n if (tile.batchIds) {\n const batchLength = featureTable.getGlobalProperty('BATCH_LENGTH');\n if (!defined(batchLength)) {\n throw new Error('Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.');\n }\n\n if (defined(batchTableBinary)) {\n // Copy the batchTableBinary section and let the underlying ArrayBuffer be freed\n batchTableBinary = new Uint8Array(batchTableBinary);\n }\n\n if (defined(pointCloud._batchTableLoaded)) {\n pointCloud._batchTableLoaded(batchLength, batchTableJson, batchTableBinary);\n }\n }\n\n // If points are not batched and there are per-point properties, use these properties for styling purposes\n var styleableProperties;\n if (!hasBatchIds && defined(batchTableBinary)) {\n tile.styleableProperties = Cesium3DTileBatchTable.getBinaryProperties(\n pointsLength,\n batchTableJson,\n batchTableBinary\n );\n }\n\n tile.draco = draco;\n}\n\n// Separate parsing and decoding of Draco\nexport function parseDracoBuffer(tile, featureTable, batchTable) {\n let dracoBuffer;\n let dracoFeatureTableProperties;\n let dracoBatchTableProperties;\n\n const batchTableDraco = batchTable.getExtension('3DTILES_draco_point_compression');\n if (batchTableDraco) {\n dracoBatchTableProperties = batchTableDraco.properties;\n }\n\n const featureTableDraco = featureTable.getExtension('3DTILES_draco_point_compression');\n if (featureTableDraco) {\n dracoFeatureTableProperties = featureTableDraco.properties;\n const dracoByteOffset = featureTableDraco.byteOffset;\n const dracoByteLength = featureTableDraco.byteLength;\n if (!dracoFeatureTableProperties || !dracoByteOffset || !dracoByteLength) {\n throw new Error('Draco properties, byteOffset, and byteLength must be defined');\n }\n\n dracoBuffer = arraySlice(\n featureTableBinary,\n dracoByteOffset,\n dracoByteOffset + dracoByteLength\n );\n tile.hasPositions = dracoFeatureTableProperties.POSITION;\n tile.hasColors = dracoFeatureTableProperties.RGB || dracoFeatureTableProperties.RGBA;\n tile.hasNormals = dracoFeatureTableProperties.NORMAL;\n tile.hasBatchIds = dracoFeatureTableProperties.BATCH_ID;\n tile.isTranslucent = dracoFeatureTableProperties.RGBA;\n }\n\n if (dracoBuffer) {\n tile.draco = {\n buffer: dracoBuffer,\n properties: {...dracoFeatureTableProperties, ...dracoBatchTableProperties},\n featureTableProperties: dracoFeatureTableProperties,\n batchTableProperties: dracoBatchTableProperties,\n dequantizeInShader: false\n };\n\n tile.decodingState = DECODING_STATE.NEEDS_DECODE;\n }\n}\n\n/*\nfunction decodeDraco(tile, context) {\n if (tile.decodingState === DECODING_STATE.READY) {\n return false;\n }\n if (tile.decodingState === DECODING_STATE.NEEDS_DECODE) {\n var parsedContent = tile._parsedContent;\n var draco = parsedContent.draco;\n var decodePromise = DracoLoader.decodePointCloud(draco, context);\n if (defined(decodePromise)) {\n tile.decodingState = DECODING_STATE.DECODING;\n decodePromise.then(function(result) {\n tile.decodingState = DECODING_STATE.READY;\n var decodedPositions = defined(result.POSITION) ? result.POSITION.array : undefined;\n var decodedRgb = defined(result.RGB) ? result.RGB.array : undefined;\n var decodedRgba = defined(result.RGBA) ? result.RGBA.array : undefined;\n var decodedNormals = defined(result.NORMAL) ? result.NORMAL.array : undefined;\n var decodedBatchIds = defined(result.BATCH_ID) ? result.BATCH_ID.array : undefined;\n var isQuantizedDraco = defined(decodedPositions) && defined(result.POSITION.data.quantization);\n var isOctEncodedDraco = defined(decodedNormals) && defined(result.NORMAL.data.quantization);\n if (isQuantizedDraco) {\n // Draco quantization range == quantized volume scale - size in meters of the quantized volume\n // Internal quantized range is the range of values of the quantized data, e.g. 255 for 8-bit, 1023 for 10-bit, etc\n var quantization = result.POSITION.data.quantization;\n var range = quantization.range;\n tile._quantizedVolumeScale = Cartesian3.fromElements(range, range, range);\n tile._quantizedVolumeOffset = Cartesian3.unpack(quantization.minValues);\n tile._quantizedRange = (1 << quantization.quantizationBits) - 1.0;\n tile._isQuantizedDraco = true;\n }\n if (isOctEncodedDraco) {\n tile._octEncodedRange = (1 << result.NORMAL.data.quantization.quantizationBits) - 1.0;\n tile._isOctEncodedDraco = true;\n }\n var styleableProperties = parsedContent.styleableProperties;\n var batchTableProperties = draco.batchTableProperties;\n for (var name in batchTableProperties) {\n if (batchTableProperties.hasOwnProperty(name)) {\n var property = result[name];\n if (!defined(styleableProperties)) {\n styleableProperties = {};\n }\n styleableProperties[name] = {\n typedArray : property.array,\n componentCount : property.data.componentsPerAttribute\n };\n }\n }\n parsedContent.positions = defaultValue(decodedPositions, parsedContent.positions);\n parsedContent.colors = defaultValue(defaultValue(decodedRgba, decodedRgb), parsedContent.colors);\n parsedContent.normals = defaultValue(decodedNormals, parsedContent.normals);\n parsedContent.batchIds = defaultValue(decodedBatchIds, parsedContent.batchIds);\n parsedContent.styleableProperties = styleableProperties;\n }).otherwise(function(error) {\n tile.decodingState = DECODING_STATE.FAILED;\n tile._readyPromise.reject(error);\n });\n }\n }\n return true;\n}\n*/\n"],"file":"parse-3d-tile-point-cloud.js"}
@@ -1,16 +1,10 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.parse3DTile = parse3DTile;
9
7
 
10
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
-
14
8
  var _constants = require("../constants");
15
9
 
16
10
  var _parseUtils = require("./helpers/parse-utils");
@@ -23,69 +17,25 @@ var _parse3dTileInstancedModel = require("./parse-3d-tile-instanced-model");
23
17
 
24
18
  var _parse3dTileComposite = require("./parse-3d-tile-composite");
25
19
 
26
- function parse3DTile(_x) {
27
- return _parse3DTile.apply(this, arguments);
28
- }
29
-
30
- function _parse3DTile() {
31
- _parse3DTile = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(arrayBuffer) {
32
- var byteOffset,
33
- options,
34
- context,
35
- tile,
36
- _args = arguments;
37
- return _regenerator.default.wrap(function _callee$(_context) {
38
- while (1) {
39
- switch (_context.prev = _context.next) {
40
- case 0:
41
- byteOffset = _args.length > 1 && _args[1] !== undefined ? _args[1] : 0;
42
- options = _args.length > 2 ? _args[2] : undefined;
43
- context = _args.length > 3 ? _args[3] : undefined;
44
- tile = _args.length > 4 && _args[4] !== undefined ? _args[4] : {};
45
- tile.byteOffset = byteOffset;
46
- tile.type = (0, _parseUtils.getMagicString)(arrayBuffer, byteOffset);
47
- _context.t0 = tile.type;
48
- _context.next = _context.t0 === _constants.TILE3D_TYPE.COMPOSITE ? 9 : _context.t0 === _constants.TILE3D_TYPE.BATCHED_3D_MODEL ? 12 : _context.t0 === _constants.TILE3D_TYPE.INSTANCED_3D_MODEL ? 15 : _context.t0 === _constants.TILE3D_TYPE.POINT_CLOUD ? 18 : 21;
49
- break;
50
-
51
- case 9:
52
- _context.next = 11;
53
- return (0, _parse3dTileComposite.parseComposite3DTile)(tile, arrayBuffer, byteOffset, options, context, parse3DTile);
54
-
55
- case 11:
56
- return _context.abrupt("return", _context.sent);
57
-
58
- case 12:
59
- _context.next = 14;
60
- return (0, _parse3dTileBatchedModel.parseBatchedModel3DTile)(tile, arrayBuffer, byteOffset, options, context);
61
-
62
- case 14:
63
- return _context.abrupt("return", _context.sent);
64
-
65
- case 15:
66
- _context.next = 17;
67
- return (0, _parse3dTileInstancedModel.parseInstancedModel3DTile)(tile, arrayBuffer, byteOffset, options, context);
20
+ async function parse3DTile(arrayBuffer, byteOffset = 0, options, context, tile = {}) {
21
+ tile.byteOffset = byteOffset;
22
+ tile.type = (0, _parseUtils.getMagicString)(arrayBuffer, byteOffset);
68
23
 
69
- case 17:
70
- return _context.abrupt("return", _context.sent);
24
+ switch (tile.type) {
25
+ case _constants.TILE3D_TYPE.COMPOSITE:
26
+ return await (0, _parse3dTileComposite.parseComposite3DTile)(tile, arrayBuffer, byteOffset, options, context, parse3DTile);
71
27
 
72
- case 18:
73
- _context.next = 20;
74
- return (0, _parse3dTilePointCloud.parsePointCloud3DTile)(tile, arrayBuffer, byteOffset, options, context);
28
+ case _constants.TILE3D_TYPE.BATCHED_3D_MODEL:
29
+ return await (0, _parse3dTileBatchedModel.parseBatchedModel3DTile)(tile, arrayBuffer, byteOffset, options, context);
75
30
 
76
- case 20:
77
- return _context.abrupt("return", _context.sent);
31
+ case _constants.TILE3D_TYPE.INSTANCED_3D_MODEL:
32
+ return await (0, _parse3dTileInstancedModel.parseInstancedModel3DTile)(tile, arrayBuffer, byteOffset, options, context);
78
33
 
79
- case 21:
80
- throw new Error("3DTileLoader: unknown type ".concat(tile.type));
34
+ case _constants.TILE3D_TYPE.POINT_CLOUD:
35
+ return await (0, _parse3dTilePointCloud.parsePointCloud3DTile)(tile, arrayBuffer, byteOffset, options, context);
81
36
 
82
- case 22:
83
- case "end":
84
- return _context.stop();
85
- }
86
- }
87
- }, _callee);
88
- }));
89
- return _parse3DTile.apply(this, arguments);
37
+ default:
38
+ throw new Error("3DTileLoader: unknown type ".concat(tile.type));
39
+ }
90
40
  }
91
41
  //# sourceMappingURL=parse-3d-tile.js.map