@loaders.gl/3d-tiles 3.1.3 → 4.0.0-alpha.5

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 (224) hide show
  1. package/dist/bundle.js +2 -2
  2. package/dist/bundle.js.map +1 -0
  3. package/dist/cesium-ion-loader.js +32 -36
  4. package/dist/cesium-ion-loader.js.map +1 -0
  5. package/dist/dist.min.js +88 -40
  6. package/dist/index.js +9 -26
  7. package/dist/index.js.map +1 -0
  8. package/dist/lib/classes/helpers/tile-3d-accessor-utils.js +89 -106
  9. package/dist/lib/classes/helpers/tile-3d-accessor-utils.js.map +1 -0
  10. package/dist/lib/classes/tile-3d-batch-table-hierarchy.js +202 -184
  11. package/dist/lib/classes/tile-3d-batch-table-hierarchy.js.map +1 -0
  12. package/dist/lib/classes/tile-3d-batch-table.js +282 -223
  13. package/dist/lib/classes/tile-3d-batch-table.js.map +1 -0
  14. package/dist/lib/classes/tile-3d-feature-table.js +86 -64
  15. package/dist/lib/classes/tile-3d-feature-table.js.map +1 -0
  16. package/dist/lib/constants.js +19 -23
  17. package/dist/lib/constants.js.map +1 -0
  18. package/dist/lib/encoders/encode-3d-tile-batched-model.js +45 -45
  19. package/dist/lib/encoders/encode-3d-tile-batched-model.js.map +1 -0
  20. package/dist/lib/encoders/encode-3d-tile-composite.js +24 -23
  21. package/dist/lib/encoders/encode-3d-tile-composite.js.map +1 -0
  22. package/dist/lib/encoders/encode-3d-tile-instanced-model.js +37 -37
  23. package/dist/lib/encoders/encode-3d-tile-instanced-model.js.map +1 -0
  24. package/dist/lib/encoders/encode-3d-tile-point-cloud.js +38 -36
  25. package/dist/lib/encoders/encode-3d-tile-point-cloud.js.map +1 -0
  26. package/dist/lib/encoders/encode-3d-tile.js +32 -30
  27. package/dist/lib/encoders/encode-3d-tile.js.map +1 -0
  28. package/dist/lib/encoders/helpers/encode-3d-tile-header.js +29 -28
  29. package/dist/lib/encoders/helpers/encode-3d-tile-header.js.map +1 -0
  30. package/dist/lib/ion/ion.js +69 -60
  31. package/dist/lib/ion/ion.js.map +1 -0
  32. package/dist/lib/parsers/helpers/normalize-3d-tile-colors.js +62 -60
  33. package/dist/lib/parsers/helpers/normalize-3d-tile-colors.js.map +1 -0
  34. package/dist/lib/parsers/helpers/normalize-3d-tile-normals.js +26 -26
  35. package/dist/lib/parsers/helpers/normalize-3d-tile-normals.js.map +1 -0
  36. package/dist/lib/parsers/helpers/normalize-3d-tile-positions.js +28 -39
  37. package/dist/lib/parsers/helpers/normalize-3d-tile-positions.js.map +1 -0
  38. package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.d.ts +18 -11
  39. package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.d.ts.map +1 -1
  40. package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.js +203 -170
  41. package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +1 -0
  42. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js +63 -82
  43. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -0
  44. package/dist/lib/parsers/helpers/parse-3d-tile-header.js +15 -26
  45. package/dist/lib/parsers/helpers/parse-3d-tile-header.js.map +1 -0
  46. package/dist/lib/parsers/helpers/parse-3d-tile-subtree.js +57 -68
  47. package/dist/lib/parsers/helpers/parse-3d-tile-subtree.js.map +1 -0
  48. package/dist/lib/parsers/helpers/parse-3d-tile-tables.js +80 -84
  49. package/dist/lib/parsers/helpers/parse-3d-tile-tables.js.map +1 -0
  50. package/dist/lib/parsers/helpers/parse-utils.js +16 -29
  51. package/dist/lib/parsers/helpers/parse-utils.js.map +1 -0
  52. package/dist/lib/parsers/parse-3d-tile-batched-model.js +26 -30
  53. package/dist/lib/parsers/parse-3d-tile-batched-model.js.map +1 -0
  54. package/dist/lib/parsers/parse-3d-tile-composite.js +16 -25
  55. package/dist/lib/parsers/parse-3d-tile-composite.js.map +1 -0
  56. package/dist/lib/parsers/parse-3d-tile-gltf.js +9 -17
  57. package/dist/lib/parsers/parse-3d-tile-gltf.js.map +1 -0
  58. package/dist/lib/parsers/parse-3d-tile-header.d.ts.map +1 -1
  59. package/dist/lib/parsers/parse-3d-tile-header.js +139 -122
  60. package/dist/lib/parsers/parse-3d-tile-header.js.map +1 -0
  61. package/dist/lib/parsers/parse-3d-tile-instanced-model.js +170 -179
  62. package/dist/{es5/lib → lib}/parsers/parse-3d-tile-instanced-model.js.map +1 -1
  63. package/dist/lib/parsers/parse-3d-tile-point-cloud.js +184 -350
  64. package/dist/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -0
  65. package/dist/lib/parsers/parse-3d-tile.js +31 -36
  66. package/dist/lib/parsers/parse-3d-tile.js.map +1 -0
  67. package/dist/lib/utils/version.js +2 -7
  68. package/dist/lib/utils/version.js.map +1 -0
  69. package/dist/tile-3d-subtree-loader.js +13 -22
  70. package/dist/tile-3d-subtree-loader.js.map +1 -0
  71. package/dist/tile-3d-writer.js +17 -24
  72. package/dist/tile-3d-writer.js.map +1 -0
  73. package/dist/tiles-3d-loader.js +66 -67
  74. package/dist/tiles-3d-loader.js.map +1 -0
  75. package/dist/types.d.ts +2 -1
  76. package/dist/types.d.ts.map +1 -1
  77. package/dist/types.js +2 -2
  78. package/dist/{es5/types.js.map → types.js.map} +0 -0
  79. package/package.json +10 -10
  80. package/src/lib/parsers/helpers/parse-3d-implicit-tiles.ts +95 -31
  81. package/src/lib/parsers/parse-3d-tile-header.ts +3 -1
  82. package/src/types.ts +2 -1
  83. package/dist/es5/bundle.js +0 -7
  84. package/dist/es5/bundle.js.map +0 -1
  85. package/dist/es5/cesium-ion-loader.js +0 -100
  86. package/dist/es5/cesium-ion-loader.js.map +0 -1
  87. package/dist/es5/index.js +0 -72
  88. package/dist/es5/index.js.map +0 -1
  89. package/dist/es5/lib/classes/helpers/tile-3d-accessor-utils.js +0 -120
  90. package/dist/es5/lib/classes/helpers/tile-3d-accessor-utils.js.map +0 -1
  91. package/dist/es5/lib/classes/tile-3d-batch-table-hierarchy.js +0 -225
  92. package/dist/es5/lib/classes/tile-3d-batch-table-hierarchy.js.map +0 -1
  93. package/dist/es5/lib/classes/tile-3d-batch-table.js +0 -349
  94. package/dist/es5/lib/classes/tile-3d-batch-table.js.map +0 -1
  95. package/dist/es5/lib/classes/tile-3d-feature-table.js +0 -119
  96. package/dist/es5/lib/classes/tile-3d-feature-table.js.map +0 -1
  97. package/dist/es5/lib/constants.js +0 -32
  98. package/dist/es5/lib/constants.js.map +0 -1
  99. package/dist/es5/lib/encoders/encode-3d-tile-batched-model.js +0 -63
  100. package/dist/es5/lib/encoders/encode-3d-tile-batched-model.js.map +0 -1
  101. package/dist/es5/lib/encoders/encode-3d-tile-composite.js +0 -41
  102. package/dist/es5/lib/encoders/encode-3d-tile-composite.js.map +0 -1
  103. package/dist/es5/lib/encoders/encode-3d-tile-instanced-model.js +0 -57
  104. package/dist/es5/lib/encoders/encode-3d-tile-instanced-model.js.map +0 -1
  105. package/dist/es5/lib/encoders/encode-3d-tile-point-cloud.js +0 -59
  106. package/dist/es5/lib/encoders/encode-3d-tile-point-cloud.js.map +0 -1
  107. package/dist/es5/lib/encoders/encode-3d-tile.js +0 -48
  108. package/dist/es5/lib/encoders/encode-3d-tile.js.map +0 -1
  109. package/dist/es5/lib/encoders/helpers/encode-3d-tile-header.js +0 -41
  110. package/dist/es5/lib/encoders/helpers/encode-3d-tile-header.js.map +0 -1
  111. package/dist/es5/lib/ion/ion.js +0 -219
  112. package/dist/es5/lib/ion/ion.js.map +0 -1
  113. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-colors.js +0 -76
  114. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-colors.js.map +0 -1
  115. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-normals.js +0 -40
  116. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-normals.js.map +0 -1
  117. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-positions.js +0 -40
  118. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-positions.js.map +0 -1
  119. package/dist/es5/lib/parsers/helpers/parse-3d-implicit-tiles.js +0 -270
  120. package/dist/es5/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +0 -1
  121. package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js +0 -123
  122. package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +0 -1
  123. package/dist/es5/lib/parsers/helpers/parse-3d-tile-header.js +0 -25
  124. package/dist/es5/lib/parsers/helpers/parse-3d-tile-header.js.map +0 -1
  125. package/dist/es5/lib/parsers/helpers/parse-3d-tile-subtree.js +0 -161
  126. package/dist/es5/lib/parsers/helpers/parse-3d-tile-subtree.js.map +0 -1
  127. package/dist/es5/lib/parsers/helpers/parse-3d-tile-tables.js +0 -98
  128. package/dist/es5/lib/parsers/helpers/parse-3d-tile-tables.js.map +0 -1
  129. package/dist/es5/lib/parsers/helpers/parse-utils.js +0 -32
  130. package/dist/es5/lib/parsers/helpers/parse-utils.js.map +0 -1
  131. package/dist/es5/lib/parsers/parse-3d-tile-batched-model.js +0 -69
  132. package/dist/es5/lib/parsers/parse-3d-tile-batched-model.js.map +0 -1
  133. package/dist/es5/lib/parsers/parse-3d-tile-composite.js +0 -61
  134. package/dist/es5/lib/parsers/parse-3d-tile-composite.js.map +0 -1
  135. package/dist/es5/lib/parsers/parse-3d-tile-gltf.js +0 -45
  136. package/dist/es5/lib/parsers/parse-3d-tile-gltf.js.map +0 -1
  137. package/dist/es5/lib/parsers/parse-3d-tile-header.js +0 -233
  138. package/dist/es5/lib/parsers/parse-3d-tile-header.js.map +0 -1
  139. package/dist/es5/lib/parsers/parse-3d-tile-instanced-model.js +0 -220
  140. package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js +0 -346
  141. package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js.map +0 -1
  142. package/dist/es5/lib/parsers/parse-3d-tile.js +0 -100
  143. package/dist/es5/lib/parsers/parse-3d-tile.js.map +0 -1
  144. package/dist/es5/lib/utils/version.js +0 -9
  145. package/dist/es5/lib/utils/version.js.map +0 -1
  146. package/dist/es5/tile-3d-subtree-loader.js +0 -26
  147. package/dist/es5/tile-3d-subtree-loader.js.map +0 -1
  148. package/dist/es5/tile-3d-writer.js +0 -32
  149. package/dist/es5/tile-3d-writer.js.map +0 -1
  150. package/dist/es5/tiles-3d-loader.js +0 -190
  151. package/dist/es5/tiles-3d-loader.js.map +0 -1
  152. package/dist/es5/types.js +0 -2
  153. package/dist/esm/bundle.js +0 -5
  154. package/dist/esm/bundle.js.map +0 -1
  155. package/dist/esm/cesium-ion-loader.js +0 -36
  156. package/dist/esm/cesium-ion-loader.js.map +0 -1
  157. package/dist/esm/index.js +0 -9
  158. package/dist/esm/index.js.map +0 -1
  159. package/dist/esm/lib/classes/helpers/tile-3d-accessor-utils.js +0 -96
  160. package/dist/esm/lib/classes/helpers/tile-3d-accessor-utils.js.map +0 -1
  161. package/dist/esm/lib/classes/tile-3d-batch-table-hierarchy.js +0 -215
  162. package/dist/esm/lib/classes/tile-3d-batch-table-hierarchy.js.map +0 -1
  163. package/dist/esm/lib/classes/tile-3d-batch-table.js +0 -304
  164. package/dist/esm/lib/classes/tile-3d-batch-table.js.map +0 -1
  165. package/dist/esm/lib/classes/tile-3d-feature-table.js +0 -94
  166. package/dist/esm/lib/classes/tile-3d-feature-table.js.map +0 -1
  167. package/dist/esm/lib/constants.js +0 -22
  168. package/dist/esm/lib/constants.js.map +0 -1
  169. package/dist/esm/lib/encoders/encode-3d-tile-batched-model.js +0 -46
  170. package/dist/esm/lib/encoders/encode-3d-tile-batched-model.js.map +0 -1
  171. package/dist/esm/lib/encoders/encode-3d-tile-composite.js +0 -25
  172. package/dist/esm/lib/encoders/encode-3d-tile-composite.js.map +0 -1
  173. package/dist/esm/lib/encoders/encode-3d-tile-instanced-model.js +0 -38
  174. package/dist/esm/lib/encoders/encode-3d-tile-instanced-model.js.map +0 -1
  175. package/dist/esm/lib/encoders/encode-3d-tile-point-cloud.js +0 -41
  176. package/dist/esm/lib/encoders/encode-3d-tile-point-cloud.js.map +0 -1
  177. package/dist/esm/lib/encoders/encode-3d-tile.js +0 -35
  178. package/dist/esm/lib/encoders/encode-3d-tile.js.map +0 -1
  179. package/dist/esm/lib/encoders/helpers/encode-3d-tile-header.js +0 -31
  180. package/dist/esm/lib/encoders/helpers/encode-3d-tile-header.js.map +0 -1
  181. package/dist/esm/lib/ion/ion.js +0 -77
  182. package/dist/esm/lib/ion/ion.js.map +0 -1
  183. package/dist/esm/lib/parsers/helpers/normalize-3d-tile-colors.js +0 -67
  184. package/dist/esm/lib/parsers/helpers/normalize-3d-tile-colors.js.map +0 -1
  185. package/dist/esm/lib/parsers/helpers/normalize-3d-tile-normals.js +0 -30
  186. package/dist/esm/lib/parsers/helpers/normalize-3d-tile-normals.js.map +0 -1
  187. package/dist/esm/lib/parsers/helpers/normalize-3d-tile-positions.js +0 -31
  188. package/dist/esm/lib/parsers/helpers/normalize-3d-tile-positions.js.map +0 -1
  189. package/dist/esm/lib/parsers/helpers/parse-3d-implicit-tiles.js +0 -173
  190. package/dist/esm/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +0 -1
  191. package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js +0 -69
  192. package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +0 -1
  193. package/dist/esm/lib/parsers/helpers/parse-3d-tile-header.js +0 -17
  194. package/dist/esm/lib/parsers/helpers/parse-3d-tile-header.js.map +0 -1
  195. package/dist/esm/lib/parsers/helpers/parse-3d-tile-subtree.js +0 -64
  196. package/dist/esm/lib/parsers/helpers/parse-3d-tile-subtree.js.map +0 -1
  197. package/dist/esm/lib/parsers/helpers/parse-3d-tile-tables.js +0 -89
  198. package/dist/esm/lib/parsers/helpers/parse-3d-tile-tables.js.map +0 -1
  199. package/dist/esm/lib/parsers/helpers/parse-utils.js +0 -19
  200. package/dist/esm/lib/parsers/helpers/parse-utils.js.map +0 -1
  201. package/dist/esm/lib/parsers/parse-3d-tile-batched-model.js +0 -29
  202. package/dist/esm/lib/parsers/parse-3d-tile-batched-model.js.map +0 -1
  203. package/dist/esm/lib/parsers/parse-3d-tile-composite.js +0 -17
  204. package/dist/esm/lib/parsers/parse-3d-tile-composite.js.map +0 -1
  205. package/dist/esm/lib/parsers/parse-3d-tile-gltf.js +0 -10
  206. package/dist/esm/lib/parsers/parse-3d-tile-gltf.js.map +0 -1
  207. package/dist/esm/lib/parsers/parse-3d-tile-header.js +0 -144
  208. package/dist/esm/lib/parsers/parse-3d-tile-header.js.map +0 -1
  209. package/dist/esm/lib/parsers/parse-3d-tile-instanced-model.js +0 -177
  210. package/dist/esm/lib/parsers/parse-3d-tile-instanced-model.js.map +0 -1
  211. package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js +0 -245
  212. package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js.map +0 -1
  213. package/dist/esm/lib/parsers/parse-3d-tile.js +0 -32
  214. package/dist/esm/lib/parsers/parse-3d-tile.js.map +0 -1
  215. package/dist/esm/lib/utils/version.js +0 -2
  216. package/dist/esm/lib/utils/version.js.map +0 -1
  217. package/dist/esm/tile-3d-subtree-loader.js +0 -14
  218. package/dist/esm/tile-3d-subtree-loader.js.map +0 -1
  219. package/dist/esm/tile-3d-writer.js +0 -20
  220. package/dist/esm/tile-3d-writer.js.map +0 -1
  221. package/dist/esm/tiles-3d-loader.js +0 -79
  222. package/dist/esm/tiles-3d-loader.js.map +0 -1
  223. package/dist/esm/types.js +0 -2
  224. package/dist/esm/types.js.map +0 -1
@@ -1,411 +1,245 @@
1
- "use strict";
2
- // This file is derived from the Cesium code base under Apache 2 license
3
- // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
4
- var __importDefault = (this && this.__importDefault) || function (mod) {
5
- return (mod && mod.__esModule) ? mod : { "default": mod };
6
- };
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.loadDraco = exports.parsePointCloud3DTile = void 0;
9
- const draco_1 = require("@loaders.gl/draco");
10
- const math_1 = require("@loaders.gl/math");
11
- const core_1 = require("@math.gl/core");
12
- const tile_3d_feature_table_1 = __importDefault(require("../classes/tile-3d-feature-table"));
13
- const tile_3d_batch_table_1 = __importDefault(require("../classes/tile-3d-batch-table"));
14
- const parse_3d_tile_header_1 = require("./helpers/parse-3d-tile-header");
15
- const parse_3d_tile_tables_1 = require("./helpers/parse-3d-tile-tables");
16
- const normalize_3d_tile_colors_1 = require("./helpers/normalize-3d-tile-colors");
17
- const normalize_3d_tile_normals_1 = require("./helpers/normalize-3d-tile-normals");
18
- const normalize_3d_tile_positions_1 = require("./helpers/normalize-3d-tile-positions");
19
- async function parsePointCloud3DTile(tile, arrayBuffer, byteOffset, options, context) {
20
- byteOffset = (0, parse_3d_tile_header_1.parse3DTileHeaderSync)(tile, arrayBuffer, byteOffset);
21
- byteOffset = (0, parse_3d_tile_tables_1.parse3DTileTablesHeaderSync)(tile, arrayBuffer, byteOffset);
22
- byteOffset = (0, parse_3d_tile_tables_1.parse3DTileTablesSync)(tile, arrayBuffer, byteOffset, options);
23
- initializeTile(tile);
24
- const { featureTable, batchTable } = parsePointCloudTables(tile);
25
- await parseDraco(tile, featureTable, batchTable, options, context);
26
- parsePositions(tile, featureTable, options);
27
- parseColors(tile, featureTable, batchTable);
28
- parseNormals(tile, featureTable);
29
- return byteOffset;
1
+ import { DracoLoader } from '@loaders.gl/draco';
2
+ import { GL } from '@loaders.gl/math';
3
+ import { Vector3 } from '@math.gl/core';
4
+ import Tile3DFeatureTable from '../classes/tile-3d-feature-table';
5
+ import Tile3DBatchTable from '../classes/tile-3d-batch-table';
6
+ import { parse3DTileHeaderSync } from './helpers/parse-3d-tile-header';
7
+ import { parse3DTileTablesHeaderSync, parse3DTileTablesSync } from './helpers/parse-3d-tile-tables';
8
+ import { normalize3DTileColorAttribute } from './helpers/normalize-3d-tile-colors';
9
+ import { normalize3DTileNormalAttribute } from './helpers/normalize-3d-tile-normals';
10
+ import { normalize3DTilePositionAttribute } from './helpers/normalize-3d-tile-positions';
11
+ export async function parsePointCloud3DTile(tile, arrayBuffer, byteOffset, options, context) {
12
+ byteOffset = parse3DTileHeaderSync(tile, arrayBuffer, byteOffset);
13
+ byteOffset = parse3DTileTablesHeaderSync(tile, arrayBuffer, byteOffset);
14
+ byteOffset = parse3DTileTablesSync(tile, arrayBuffer, byteOffset, options);
15
+ initializeTile(tile);
16
+ const {
17
+ featureTable,
18
+ batchTable
19
+ } = parsePointCloudTables(tile);
20
+ await parseDraco(tile, featureTable, batchTable, options, context);
21
+ parsePositions(tile, featureTable, options);
22
+ parseColors(tile, featureTable, batchTable);
23
+ parseNormals(tile, featureTable);
24
+ return byteOffset;
30
25
  }
31
- exports.parsePointCloud3DTile = parsePointCloud3DTile;
26
+
32
27
  function initializeTile(tile) {
33
- // Initialize point cloud tile defaults
34
- tile.attributes = {
35
- positions: null,
36
- colors: null,
37
- normals: null,
38
- batchIds: null
39
- };
40
- tile.isQuantized = false;
41
- tile.isTranslucent = false;
42
- tile.isRGB565 = false;
43
- tile.isOctEncoded16P = false;
44
- }
45
- function parsePointCloudTables(tile) {
46
- const featureTable = new tile_3d_feature_table_1.default(tile.featureTableJson, tile.featureTableBinary);
47
- const pointsLength = featureTable.getGlobalProperty('POINTS_LENGTH');
48
- if (!Number.isFinite(pointsLength)) {
49
- throw new Error('POINTS_LENGTH must be defined');
50
- }
51
- featureTable.featuresLength = pointsLength;
52
- tile.featuresLength = pointsLength;
53
- tile.pointsLength = pointsLength;
54
- tile.pointCount = pointsLength;
55
- tile.rtcCenter = featureTable.getGlobalProperty('RTC_CENTER', math_1.GL.FLOAT, 3);
56
- const batchTable = parseBatchIds(tile, featureTable);
57
- return { featureTable, batchTable };
58
- }
59
- function parsePositions(tile, featureTable, options) {
60
- if (!tile.attributes.positions) {
61
- if (featureTable.hasProperty('POSITION')) {
62
- tile.attributes.positions = featureTable.getPropertyArray('POSITION', math_1.GL.FLOAT, 3);
63
- }
64
- else if (featureTable.hasProperty('POSITION_QUANTIZED')) {
65
- const positions = featureTable.getPropertyArray('POSITION_QUANTIZED', math_1.GL.UNSIGNED_SHORT, 3);
66
- tile.isQuantized = true;
67
- tile.quantizedRange = (1 << 16) - 1;
68
- tile.quantizedVolumeScale = featureTable.getGlobalProperty('QUANTIZED_VOLUME_SCALE', math_1.GL.FLOAT, 3);
69
- if (!tile.quantizedVolumeScale) {
70
- throw new Error('QUANTIZED_VOLUME_SCALE must be defined for quantized positions.');
71
- }
72
- tile.quantizedVolumeOffset = featureTable.getGlobalProperty('QUANTIZED_VOLUME_OFFSET', math_1.GL.FLOAT, 3);
73
- if (!tile.quantizedVolumeOffset) {
74
- throw new Error('QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.');
75
- }
76
- tile.attributes.positions = (0, normalize_3d_tile_positions_1.normalize3DTilePositionAttribute)(tile, positions, options);
77
- }
78
- }
79
- if (!tile.attributes.positions) {
80
- throw new Error('Either POSITION or POSITION_QUANTIZED must be defined.');
81
- }
28
+ tile.attributes = {
29
+ positions: null,
30
+ colors: null,
31
+ normals: null,
32
+ batchIds: null
33
+ };
34
+ tile.isQuantized = false;
35
+ tile.isTranslucent = false;
36
+ tile.isRGB565 = false;
37
+ tile.isOctEncoded16P = false;
82
38
  }
83
- function parseColors(tile, featureTable, batchTable) {
84
- if (!tile.attributes.colors) {
85
- let colors = null;
86
- if (featureTable.hasProperty('RGBA')) {
87
- colors = featureTable.getPropertyArray('RGBA', math_1.GL.UNSIGNED_BYTE, 4);
88
- tile.isTranslucent = true;
89
- }
90
- else if (featureTable.hasProperty('RGB')) {
91
- colors = featureTable.getPropertyArray('RGB', math_1.GL.UNSIGNED_BYTE, 3);
92
- }
93
- else if (featureTable.hasProperty('RGB565')) {
94
- colors = featureTable.getPropertyArray('RGB565', math_1.GL.UNSIGNED_SHORT, 1);
95
- tile.isRGB565 = true;
96
- }
97
- tile.attributes.colors = (0, normalize_3d_tile_colors_1.normalize3DTileColorAttribute)(tile, colors, batchTable);
98
- }
99
- if (featureTable.hasProperty('CONSTANT_RGBA')) {
100
- tile.constantRGBA = featureTable.getGlobalProperty('CONSTANT_RGBA', math_1.GL.UNSIGNED_BYTE, 4);
101
- }
102
- }
103
- function parseNormals(tile, featureTable) {
104
- if (!tile.attributes.normals) {
105
- let normals = null;
106
- if (featureTable.hasProperty('NORMAL')) {
107
- normals = featureTable.getPropertyArray('NORMAL', math_1.GL.FLOAT, 3);
108
- }
109
- else if (featureTable.hasProperty('NORMAL_OCT16P')) {
110
- normals = featureTable.getPropertyArray('NORMAL_OCT16P', math_1.GL.UNSIGNED_BYTE, 2);
111
- tile.isOctEncoded16P = true;
112
- }
113
- tile.attributes.normals = (0, normalize_3d_tile_normals_1.normalize3DTileNormalAttribute)(tile, normals);
114
- }
115
- }
116
- function parseBatchIds(tile, featureTable) {
117
- let batchTable = null;
118
- if (!tile.batchIds && featureTable.hasProperty('BATCH_ID')) {
119
- tile.batchIds = featureTable.getPropertyArray('BATCH_ID', math_1.GL.UNSIGNED_SHORT, 1);
120
- if (tile.batchIds) {
121
- const batchFeatureLength = featureTable.getGlobalProperty('BATCH_LENGTH');
122
- if (!batchFeatureLength) {
123
- throw new Error('Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.');
124
- }
125
- const { batchTableJson, batchTableBinary } = tile;
126
- batchTable = new tile_3d_batch_table_1.default(batchTableJson, batchTableBinary, batchFeatureLength);
127
- }
128
- }
129
- return batchTable;
130
- }
131
- // eslint-disable-next-line complexity
132
- async function parseDraco(tile, featureTable, batchTable, options, context) {
133
- let dracoBuffer;
134
- let dracoFeatureTableProperties;
135
- let dracoBatchTableProperties;
136
- const batchTableDraco = tile.batchTableJson &&
137
- tile.batchTableJson.extensions &&
138
- tile.batchTableJson.extensions['3DTILES_draco_point_compression'];
139
- if (batchTableDraco) {
140
- dracoBatchTableProperties = batchTableDraco.properties;
141
- }
142
- const featureTableDraco = featureTable.getExtension('3DTILES_draco_point_compression');
143
- if (featureTableDraco) {
144
- dracoFeatureTableProperties = featureTableDraco.properties;
145
- const dracoByteOffset = featureTableDraco.byteOffset;
146
- const dracoByteLength = featureTableDraco.byteLength;
147
- if (!dracoFeatureTableProperties || !Number.isFinite(dracoByteOffset) || !dracoByteLength) {
148
- throw new Error('Draco properties, byteOffset, and byteLength must be defined');
149
- }
150
- dracoBuffer = tile.featureTableBinary.slice(dracoByteOffset, dracoByteOffset + dracoByteLength);
151
- tile.hasPositions = Number.isFinite(dracoFeatureTableProperties.POSITION);
152
- tile.hasColors =
153
- Number.isFinite(dracoFeatureTableProperties.RGB) ||
154
- Number.isFinite(dracoFeatureTableProperties.RGBA);
155
- tile.hasNormals = Number.isFinite(dracoFeatureTableProperties.NORMAL);
156
- tile.hasBatchIds = Number.isFinite(dracoFeatureTableProperties.BATCH_ID);
157
- tile.isTranslucent = Number.isFinite(dracoFeatureTableProperties.RGBA);
158
- }
159
- if (!dracoBuffer) {
160
- return true;
161
- }
162
- const dracoData = {
163
- buffer: dracoBuffer,
164
- properties: { ...dracoFeatureTableProperties, ...dracoBatchTableProperties },
165
- featureTableProperties: dracoFeatureTableProperties,
166
- batchTableProperties: dracoBatchTableProperties,
167
- dequantizeInShader: false
168
- };
169
- return await loadDraco(tile, dracoData, options, context);
170
- }
171
- // eslint-disable-next-line complexity, max-statements
172
- async function loadDraco(tile, dracoData, options, context) {
173
- const { parse } = context;
174
- const dracoOptions = {
175
- ...options,
176
- draco: {
177
- ...options.draco,
178
- extraAttributes: dracoData.batchTableProperties || {}
179
- }
180
- };
181
- // The entire tileset might be included, too expensive to serialize
182
- delete dracoOptions['3d-tiles'];
183
- const data = await parse(dracoData.buffer, draco_1.DracoLoader, dracoOptions);
184
- const decodedPositions = data.attributes.POSITION && data.attributes.POSITION.value;
185
- const decodedColors = data.attributes.COLOR_0 && data.attributes.COLOR_0.value;
186
- const decodedNormals = data.attributes.NORMAL && data.attributes.NORMAL.value;
187
- const decodedBatchIds = data.attributes.BATCH_ID && data.attributes.BATCH_ID.value;
188
- const isQuantizedDraco = decodedPositions && data.attributes.POSITION.value.quantization;
189
- const isOctEncodedDraco = decodedNormals && data.attributes.NORMAL.value.quantization;
190
- if (isQuantizedDraco) {
191
- // Draco quantization range == quantized volume scale - size in meters of the quantized volume
192
- // Internal quantized range is the range of values of the quantized data, e.g. 255 for 8-bit, 1023 for 10-bit, etc
193
- const quantization = data.POSITION.data.quantization;
194
- const range = quantization.range;
195
- tile.quantizedVolumeScale = new core_1.Vector3(range, range, range);
196
- tile.quantizedVolumeOffset = new core_1.Vector3(quantization.minValues);
197
- tile.quantizedRange = (1 << quantization.quantizationBits) - 1.0;
198
- tile.isQuantizedDraco = true;
199
- }
200
- if (isOctEncodedDraco) {
201
- tile.octEncodedRange = (1 << data.NORMAL.data.quantization.quantizationBits) - 1.0;
202
- tile.isOctEncodedDraco = true;
203
- }
204
- // Extra batch table attributes
205
- const batchTableAttributes = {};
206
- if (dracoData.batchTableProperties) {
207
- for (const attributeName of Object.keys(dracoData.batchTableProperties)) {
208
- if (data.attributes[attributeName] && data.attributes[attributeName].value) {
209
- batchTableAttributes[attributeName.toLowerCase()] = data.attributes[attributeName].value;
210
- }
211
- }
212
- }
213
- tile.attributes = {
214
- positions: decodedPositions,
215
- colors: (0, normalize_3d_tile_colors_1.normalize3DTileColorAttribute)(tile, decodedColors, undefined),
216
- normals: decodedNormals,
217
- batchIds: decodedBatchIds,
218
- ...batchTableAttributes
219
- };
220
- }
221
- exports.loadDraco = loadDraco;
222
- // TODO - this is the remaining code from Cesium's parser
223
- /*
224
- const batchTable = new Tile3DBatchTable(tile);
225
39
 
226
- // parseDracoBuffer(tile, featureTable, batchTable);
40
+ function parsePointCloudTables(tile) {
41
+ const featureTable = new Tile3DFeatureTable(tile.featureTableJson, tile.featureTableBinary);
42
+ const pointsLength = featureTable.getGlobalProperty('POINTS_LENGTH');
227
43
 
228
- if (!tile.attributes.positions) {
229
- throw new Error('Either POSITION or POSITION_QUANTIZED must be defined.');
44
+ if (!Number.isFinite(pointsLength)) {
45
+ throw new Error('POINTS_LENGTH must be defined');
230
46
  }
47
+
48
+ featureTable.featuresLength = pointsLength;
49
+ tile.featuresLength = pointsLength;
50
+ tile.pointsLength = pointsLength;
51
+ tile.pointCount = pointsLength;
52
+ tile.rtcCenter = featureTable.getGlobalProperty('RTC_CENTER', GL.FLOAT, 3);
53
+ const batchTable = parseBatchIds(tile, featureTable);
54
+ return {
55
+ featureTable,
56
+ batchTable
57
+ };
231
58
  }
232
- /*
233
59
 
60
+ function parsePositions(tile, featureTable, options) {
234
61
  if (!tile.attributes.positions) {
235
62
  if (featureTable.hasProperty('POSITION')) {
236
63
  tile.attributes.positions = featureTable.getPropertyArray('POSITION', GL.FLOAT, 3);
237
64
  } else if (featureTable.hasProperty('POSITION_QUANTIZED')) {
238
- tile.attributes.positions = featureTable.getPropertyArray('POSITION_QUANTIZED', GL.UNSIGNED_SHORT, 3);
65
+ const positions = featureTable.getPropertyArray('POSITION_QUANTIZED', GL.UNSIGNED_SHORT, 3);
66
+ tile.isQuantized = true;
67
+ tile.quantizedRange = (1 << 16) - 1;
68
+ tile.quantizedVolumeScale = featureTable.getGlobalProperty('QUANTIZED_VOLUME_SCALE', GL.FLOAT, 3);
69
+
70
+ if (!tile.quantizedVolumeScale) {
71
+ throw new Error('QUANTIZED_VOLUME_SCALE must be defined for quantized positions.');
72
+ }
73
+
74
+ tile.quantizedVolumeOffset = featureTable.getGlobalProperty('QUANTIZED_VOLUME_OFFSET', GL.FLOAT, 3);
75
+
76
+ if (!tile.quantizedVolumeOffset) {
77
+ throw new Error('QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.');
78
+ }
79
+
80
+ tile.attributes.positions = normalize3DTilePositionAttribute(tile, positions, options);
81
+ }
82
+ }
83
+
84
+ if (!tile.attributes.positions) {
85
+ throw new Error('Either POSITION or POSITION_QUANTIZED must be defined.');
86
+ }
87
+ }
239
88
 
89
+ function parseColors(tile, featureTable, batchTable) {
90
+ if (!tile.attributes.colors) {
91
+ let colors = null;
240
92
 
241
- if (!tile.colors) {
242
93
  if (featureTable.hasProperty('RGBA')) {
243
- tile.colors = featureTable.getPropertyArray('RGBA', GL.UNSIGNED_BYTE, 4);
94
+ colors = featureTable.getPropertyArray('RGBA', GL.UNSIGNED_BYTE, 4);
244
95
  tile.isTranslucent = true;
245
96
  } else if (featureTable.hasProperty('RGB')) {
246
- tile.colors = featureTable.getPropertyArray('RGB', GL.UNSIGNED_BYTE, 3);
247
- } else if (featureTable.hasPropertry('RGB565')) {
248
- tile.colors = featureTable.getPropertyArray('RGB565', GL.UNSIGNED_SHORT, 1);
97
+ colors = featureTable.getPropertyArray('RGB', GL.UNSIGNED_BYTE, 3);
98
+ } else if (featureTable.hasProperty('RGB565')) {
99
+ colors = featureTable.getPropertyArray('RGB565', GL.UNSIGNED_SHORT, 1);
249
100
  tile.isRGB565 = true;
250
101
  }
102
+
103
+ tile.attributes.colors = normalize3DTileColorAttribute(tile, colors, batchTable);
251
104
  }
252
105
 
106
+ if (featureTable.hasProperty('CONSTANT_RGBA')) {
107
+ tile.constantRGBA = featureTable.getGlobalProperty('CONSTANT_RGBA', GL.UNSIGNED_BYTE, 4);
108
+ }
109
+ }
110
+
111
+ function parseNormals(tile, featureTable) {
253
112
  if (!tile.attributes.normals) {
254
- if (featureTable.getPropertry('NORMAL')) {
255
- tile.attributes.normals = featureTable.getPropertyArray('NORMAL', GL.FLOAT, 3);
256
- } else if (featureTable.getProperty('NORMAL_OCT16P')) {
257
- tile.attributes.normals = featureTable.getPropertyArray('NORMAL_OCT16P', GL.UNSIGNED_BYTE, 2);
113
+ let normals = null;
114
+
115
+ if (featureTable.hasProperty('NORMAL')) {
116
+ normals = featureTable.getPropertyArray('NORMAL', GL.FLOAT, 3);
117
+ } else if (featureTable.hasProperty('NORMAL_OCT16P')) {
118
+ normals = featureTable.getPropertyArray('NORMAL_OCT16P', GL.UNSIGNED_BYTE, 2);
258
119
  tile.isOctEncoded16P = true;
259
120
  }
260
- }
261
121
 
262
- if (!tile.batchIds) {
263
- if (featureTable.hasProperty('BATCH_ID')) {
264
- tile.batchIds = featureTable.getPropertyArray('BATCH_ID', GL.UNSIGNED_SHORT, 1);
265
- }
122
+ tile.attributes.normals = normalize3DTileNormalAttribute(tile, normals);
266
123
  }
124
+ }
267
125
 
268
- if (!tile.attributes.positions) {
269
- throw new Error('Either POSITION or POSITION_QUANTIZED must be defined.');
270
- }
126
+ function parseBatchIds(tile, featureTable) {
127
+ let batchTable = null;
271
128
 
272
- if (featureTable.getPropertry('CONSTANT_RGBA')) {
273
- tile.constantRGBA = featureTable.getGlobalProperty('CONSTANT_RGBA', GL.UNSIGNED_BYTE, 4);
274
- }
129
+ if (!tile.batchIds && featureTable.hasProperty('BATCH_ID')) {
130
+ tile.batchIds = featureTable.getPropertyArray('BATCH_ID', GL.UNSIGNED_SHORT, 1);
275
131
 
276
- if (tile.batchIds) {
277
- const batchLength = featureTable.getGlobalProperty('BATCH_LENGTH');
278
- if (!defined(batchLength)) {
279
- throw new Error('Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.');
280
- }
132
+ if (tile.batchIds) {
133
+ const batchFeatureLength = featureTable.getGlobalProperty('BATCH_LENGTH');
281
134
 
282
- if (defined(batchTableBinary)) {
283
- // Copy the batchTableBinary section and let the underlying ArrayBuffer be freed
284
- batchTableBinary = new Uint8Array(batchTableBinary);
285
- }
135
+ if (!batchFeatureLength) {
136
+ throw new Error('Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.');
137
+ }
286
138
 
287
- if (defined(pointCloud._batchTableLoaded)) {
288
- pointCloud._batchTableLoaded(batchLength, batchTableJson, batchTableBinary);
139
+ const {
140
+ batchTableJson,
141
+ batchTableBinary
142
+ } = tile;
143
+ batchTable = new Tile3DBatchTable(batchTableJson, batchTableBinary, batchFeatureLength);
289
144
  }
290
145
  }
291
146
 
292
- // If points are not batched and there are per-point properties, use these properties for styling purposes
293
- var styleableProperties;
294
- if (!hasBatchIds && defined(batchTableBinary)) {
295
- tile.styleableProperties = Cesium3DTileBatchTable.getBinaryProperties(
296
- pointsLength,
297
- batchTableJson,
298
- batchTableBinary
299
- );
300
- }
301
-
302
- tile.draco = draco;
147
+ return batchTable;
303
148
  }
304
149
 
305
- // Separate parsing and decoding of Draco
306
- export function parseDracoBuffer(tile, featureTable, batchTable) {
150
+ async function parseDraco(tile, featureTable, batchTable, options, context) {
307
151
  let dracoBuffer;
308
152
  let dracoFeatureTableProperties;
309
153
  let dracoBatchTableProperties;
154
+ const batchTableDraco = tile.batchTableJson && tile.batchTableJson.extensions && tile.batchTableJson.extensions['3DTILES_draco_point_compression'];
310
155
 
311
- const batchTableDraco = batchTable.getExtension('3DTILES_draco_point_compression');
312
156
  if (batchTableDraco) {
313
157
  dracoBatchTableProperties = batchTableDraco.properties;
314
158
  }
315
159
 
316
160
  const featureTableDraco = featureTable.getExtension('3DTILES_draco_point_compression');
161
+
317
162
  if (featureTableDraco) {
318
163
  dracoFeatureTableProperties = featureTableDraco.properties;
319
164
  const dracoByteOffset = featureTableDraco.byteOffset;
320
165
  const dracoByteLength = featureTableDraco.byteLength;
321
- if (!dracoFeatureTableProperties || !dracoByteOffset || !dracoByteLength) {
166
+
167
+ if (!dracoFeatureTableProperties || !Number.isFinite(dracoByteOffset) || !dracoByteLength) {
322
168
  throw new Error('Draco properties, byteOffset, and byteLength must be defined');
323
169
  }
324
170
 
325
- dracoBuffer = arraySlice(
326
- featureTableBinary,
327
- dracoByteOffset,
328
- dracoByteOffset + dracoByteLength
329
- );
330
- tile.hasPositions = dracoFeatureTableProperties.POSITION;
331
- tile.hasColors = dracoFeatureTableProperties.RGB || dracoFeatureTableProperties.RGBA;
332
- tile.hasNormals = dracoFeatureTableProperties.NORMAL;
333
- tile.hasBatchIds = dracoFeatureTableProperties.BATCH_ID;
334
- tile.isTranslucent = dracoFeatureTableProperties.RGBA;
171
+ dracoBuffer = tile.featureTableBinary.slice(dracoByteOffset, dracoByteOffset + dracoByteLength);
172
+ tile.hasPositions = Number.isFinite(dracoFeatureTableProperties.POSITION);
173
+ tile.hasColors = Number.isFinite(dracoFeatureTableProperties.RGB) || Number.isFinite(dracoFeatureTableProperties.RGBA);
174
+ tile.hasNormals = Number.isFinite(dracoFeatureTableProperties.NORMAL);
175
+ tile.hasBatchIds = Number.isFinite(dracoFeatureTableProperties.BATCH_ID);
176
+ tile.isTranslucent = Number.isFinite(dracoFeatureTableProperties.RGBA);
335
177
  }
336
178
 
337
- if (dracoBuffer) {
338
- tile.draco = {
339
- buffer: dracoBuffer,
340
- properties: {...dracoFeatureTableProperties, ...dracoBatchTableProperties},
341
- featureTableProperties: dracoFeatureTableProperties,
342
- batchTableProperties: dracoBatchTableProperties,
343
- dequantizeInShader: false
344
- };
345
-
346
- tile.decodingState = DECODING_STATE.NEEDS_DECODE;
179
+ if (!dracoBuffer) {
180
+ return true;
347
181
  }
182
+
183
+ const dracoData = {
184
+ buffer: dracoBuffer,
185
+ properties: { ...dracoFeatureTableProperties,
186
+ ...dracoBatchTableProperties
187
+ },
188
+ featureTableProperties: dracoFeatureTableProperties,
189
+ batchTableProperties: dracoBatchTableProperties,
190
+ dequantizeInShader: false
191
+ };
192
+ return await loadDraco(tile, dracoData, options, context);
348
193
  }
349
194
 
350
- /*
351
- function decodeDraco(tile, context) {
352
- if (tile.decodingState === DECODING_STATE.READY) {
353
- return false;
195
+ export async function loadDraco(tile, dracoData, options, context) {
196
+ const {
197
+ parse
198
+ } = context;
199
+ const dracoOptions = { ...options,
200
+ draco: { ...options.draco,
201
+ extraAttributes: dracoData.batchTableProperties || {}
202
+ }
203
+ };
204
+ delete dracoOptions['3d-tiles'];
205
+ const data = await parse(dracoData.buffer, DracoLoader, dracoOptions);
206
+ const decodedPositions = data.attributes.POSITION && data.attributes.POSITION.value;
207
+ const decodedColors = data.attributes.COLOR_0 && data.attributes.COLOR_0.value;
208
+ const decodedNormals = data.attributes.NORMAL && data.attributes.NORMAL.value;
209
+ const decodedBatchIds = data.attributes.BATCH_ID && data.attributes.BATCH_ID.value;
210
+ const isQuantizedDraco = decodedPositions && data.attributes.POSITION.value.quantization;
211
+ const isOctEncodedDraco = decodedNormals && data.attributes.NORMAL.value.quantization;
212
+
213
+ if (isQuantizedDraco) {
214
+ const quantization = data.POSITION.data.quantization;
215
+ const range = quantization.range;
216
+ tile.quantizedVolumeScale = new Vector3(range, range, range);
217
+ tile.quantizedVolumeOffset = new Vector3(quantization.minValues);
218
+ tile.quantizedRange = (1 << quantization.quantizationBits) - 1.0;
219
+ tile.isQuantizedDraco = true;
354
220
  }
355
- if (tile.decodingState === DECODING_STATE.NEEDS_DECODE) {
356
- var parsedContent = tile._parsedContent;
357
- var draco = parsedContent.draco;
358
- var decodePromise = DracoLoader.decodePointCloud(draco, context);
359
- if (defined(decodePromise)) {
360
- tile.decodingState = DECODING_STATE.DECODING;
361
- decodePromise.then(function(result) {
362
- tile.decodingState = DECODING_STATE.READY;
363
- var decodedPositions = defined(result.POSITION) ? result.POSITION.array : undefined;
364
- var decodedRgb = defined(result.RGB) ? result.RGB.array : undefined;
365
- var decodedRgba = defined(result.RGBA) ? result.RGBA.array : undefined;
366
- var decodedNormals = defined(result.NORMAL) ? result.NORMAL.array : undefined;
367
- var decodedBatchIds = defined(result.BATCH_ID) ? result.BATCH_ID.array : undefined;
368
- var isQuantizedDraco = defined(decodedPositions) && defined(result.POSITION.data.quantization);
369
- var isOctEncodedDraco = defined(decodedNormals) && defined(result.NORMAL.data.quantization);
370
- if (isQuantizedDraco) {
371
- // Draco quantization range == quantized volume scale - size in meters of the quantized volume
372
- // Internal quantized range is the range of values of the quantized data, e.g. 255 for 8-bit, 1023 for 10-bit, etc
373
- var quantization = result.POSITION.data.quantization;
374
- var range = quantization.range;
375
- tile._quantizedVolumeScale = Cartesian3.fromElements(range, range, range);
376
- tile._quantizedVolumeOffset = Cartesian3.unpack(quantization.minValues);
377
- tile._quantizedRange = (1 << quantization.quantizationBits) - 1.0;
378
- tile._isQuantizedDraco = true;
379
- }
380
- if (isOctEncodedDraco) {
381
- tile._octEncodedRange = (1 << result.NORMAL.data.quantization.quantizationBits) - 1.0;
382
- tile._isOctEncodedDraco = true;
383
- }
384
- var styleableProperties = parsedContent.styleableProperties;
385
- var batchTableProperties = draco.batchTableProperties;
386
- for (var name in batchTableProperties) {
387
- if (batchTableProperties.hasOwnProperty(name)) {
388
- var property = result[name];
389
- if (!defined(styleableProperties)) {
390
- styleableProperties = {};
391
- }
392
- styleableProperties[name] = {
393
- typedArray : property.array,
394
- componentCount : property.data.componentsPerAttribute
395
- };
396
- }
397
- }
398
- parsedContent.positions = defaultValue(decodedPositions, parsedContent.positions);
399
- parsedContent.colors = defaultValue(defaultValue(decodedRgba, decodedRgb), parsedContent.colors);
400
- parsedContent.normals = defaultValue(decodedNormals, parsedContent.normals);
401
- parsedContent.batchIds = defaultValue(decodedBatchIds, parsedContent.batchIds);
402
- parsedContent.styleableProperties = styleableProperties;
403
- }).otherwise(function(error) {
404
- tile.decodingState = DECODING_STATE.FAILED;
405
- tile._readyPromise.reject(error);
406
- });
221
+
222
+ if (isOctEncodedDraco) {
223
+ tile.octEncodedRange = (1 << data.NORMAL.data.quantization.quantizationBits) - 1.0;
224
+ tile.isOctEncodedDraco = true;
225
+ }
226
+
227
+ const batchTableAttributes = {};
228
+
229
+ if (dracoData.batchTableProperties) {
230
+ for (const attributeName of Object.keys(dracoData.batchTableProperties)) {
231
+ if (data.attributes[attributeName] && data.attributes[attributeName].value) {
232
+ batchTableAttributes[attributeName.toLowerCase()] = data.attributes[attributeName].value;
233
+ }
407
234
  }
408
235
  }
409
- return true;
236
+
237
+ tile.attributes = {
238
+ positions: decodedPositions,
239
+ colors: normalize3DTileColorAttribute(tile, decodedColors, undefined),
240
+ normals: decodedNormals,
241
+ batchIds: decodedBatchIds,
242
+ ...batchTableAttributes
243
+ };
410
244
  }
411
- */
245
+ //# sourceMappingURL=parse-3d-tile-point-cloud.js.map