@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,245 +1,304 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
5
- const loader_utils_1 = require("@loaders.gl/loader-utils");
6
- const tile_3d_accessor_utils_1 = require("./helpers/tile-3d-accessor-utils");
7
- const tile_3d_batch_table_hierarchy_1 = require("./tile-3d-batch-table-hierarchy");
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import { assert } from '@loaders.gl/loader-utils';
3
+ import { createTypedArrayFromAccessor } from './helpers/tile-3d-accessor-utils';
4
+ import { initializeHierarchy, traverseHierarchy } from './tile-3d-batch-table-hierarchy';
5
+
8
6
  function defined(x) {
9
- return x !== undefined && x !== null;
7
+ return x !== undefined && x !== null;
10
8
  }
9
+
11
10
  const clone = (x, y) => x;
12
- // These top level fields in the batch table json are not properties
11
+
13
12
  const IGNORED_PROPERTY_FIELDS = {
14
- HIERARCHY: true,
15
- extensions: true,
16
- extras: true
13
+ HIERARCHY: true,
14
+ extensions: true,
15
+ extras: true
17
16
  };
18
- // The size of this array equals the maximum instance count among all loaded tiles, which has the potential to be large.
19
- class Tile3DBatchTableParser {
20
- constructor(json, binary, featureCount, options = {}) {
21
- (0, loader_utils_1.assert)(featureCount >= 0);
22
- this.json = json || {};
23
- this.binary = binary;
24
- this.featureCount = featureCount;
25
- this._extensions = this.json?.extensions || {};
26
- // Copy all top-level property fields from the json object, ignoring special fields
27
- this._properties = {};
28
- for (const propertyName in this.json) {
29
- if (!IGNORED_PROPERTY_FIELDS[propertyName]) {
30
- this._properties[propertyName] = this.json[propertyName];
31
- }
32
- }
33
- this._binaryProperties = this._initializeBinaryProperties();
34
- // TODO: hierarchy support is only partially implemented and not tested
35
- if (options['3DTILES_batch_table_hierarchy']) {
36
- this._hierarchy = (0, tile_3d_batch_table_hierarchy_1.initializeHierarchy)(this, this.json, this.binary);
37
- }
17
+ export default class Tile3DBatchTableParser {
18
+ constructor(json, binary, featureCount, options = {}) {
19
+ var _this$json;
20
+
21
+ _defineProperty(this, "json", void 0);
22
+
23
+ _defineProperty(this, "binary", void 0);
24
+
25
+ _defineProperty(this, "featureCount", void 0);
26
+
27
+ _defineProperty(this, "_extensions", void 0);
28
+
29
+ _defineProperty(this, "_properties", void 0);
30
+
31
+ _defineProperty(this, "_binaryProperties", void 0);
32
+
33
+ _defineProperty(this, "_hierarchy", void 0);
34
+
35
+ assert(featureCount >= 0);
36
+ this.json = json || {};
37
+ this.binary = binary;
38
+ this.featureCount = featureCount;
39
+ this._extensions = ((_this$json = this.json) === null || _this$json === void 0 ? void 0 : _this$json.extensions) || {};
40
+ this._properties = {};
41
+
42
+ for (const propertyName in this.json) {
43
+ if (!IGNORED_PROPERTY_FIELDS[propertyName]) {
44
+ this._properties[propertyName] = this.json[propertyName];
45
+ }
38
46
  }
39
- getExtension(extensionName) {
40
- return this.json && this.json.extensions && this.json.extensions[extensionName];
47
+
48
+ this._binaryProperties = this._initializeBinaryProperties();
49
+
50
+ if (options['3DTILES_batch_table_hierarchy']) {
51
+ this._hierarchy = initializeHierarchy(this, this.json, this.binary);
41
52
  }
42
- memorySizeInBytes() {
43
- return 0;
53
+ }
54
+
55
+ getExtension(extensionName) {
56
+ return this.json && this.json.extensions && this.json.extensions[extensionName];
57
+ }
58
+
59
+ memorySizeInBytes() {
60
+ return 0;
61
+ }
62
+
63
+ isClass(batchId, className) {
64
+ this._checkBatchId(batchId);
65
+
66
+ assert(typeof className === 'string', className);
67
+
68
+ if (this._hierarchy) {
69
+ const result = traverseHierarchy(this._hierarchy, batchId, (hierarchy, instanceIndex) => {
70
+ const classId = hierarchy.classIds[instanceIndex];
71
+ const instanceClass = hierarchy.classes[classId];
72
+ return instanceClass.name === className;
73
+ });
74
+ return defined(result);
44
75
  }
45
- isClass(batchId, className) {
46
- this._checkBatchId(batchId);
47
- (0, loader_utils_1.assert)(typeof className === 'string', className);
48
- // extension: 3DTILES_batch_table_hierarchy
49
- if (this._hierarchy) {
50
- // PERFORMANCE_IDEA : cache results in the ancestor classes
51
- // to speed up this check if this area becomes a hotspot
52
- // PERFORMANCE_IDEA : treat class names as integers for faster comparisons
53
- const result = (0, tile_3d_batch_table_hierarchy_1.traverseHierarchy)(this._hierarchy, batchId, (hierarchy, instanceIndex) => {
54
- const classId = hierarchy.classIds[instanceIndex];
55
- const instanceClass = hierarchy.classes[classId];
56
- return instanceClass.name === className;
57
- });
58
- return defined(result);
59
- }
60
- return false;
76
+
77
+ return false;
78
+ }
79
+
80
+ isExactClass(batchId, className) {
81
+ assert(typeof className === 'string', className);
82
+ return this.getExactClassName(batchId) === className;
83
+ }
84
+
85
+ getExactClassName(batchId) {
86
+ this._checkBatchId(batchId);
87
+
88
+ if (this._hierarchy) {
89
+ const classId = this._hierarchy.classIds[batchId];
90
+ const instanceClass = this._hierarchy.classes[classId];
91
+ return instanceClass.name;
61
92
  }
62
- isExactClass(batchId, className) {
63
- (0, loader_utils_1.assert)(typeof className === 'string', className);
64
- return this.getExactClassName(batchId) === className;
93
+
94
+ return undefined;
95
+ }
96
+
97
+ hasProperty(batchId, name) {
98
+ this._checkBatchId(batchId);
99
+
100
+ assert(typeof name === 'string', name);
101
+ return defined(this._properties[name]) || this._hasPropertyInHierarchy(batchId, name);
102
+ }
103
+
104
+ getPropertyNames(batchId, results) {
105
+ this._checkBatchId(batchId);
106
+
107
+ results = defined(results) ? results : [];
108
+ results.length = 0;
109
+ const propertyNames = Object.keys(this._properties);
110
+ results.push(...propertyNames);
111
+
112
+ if (this._hierarchy) {
113
+ this._getPropertyNamesInHierarchy(batchId, results);
65
114
  }
66
- getExactClassName(batchId) {
67
- this._checkBatchId(batchId);
68
- // extension: 3DTILES_batch_table_hierarchy
69
- if (this._hierarchy) {
70
- const classId = this._hierarchy.classIds[batchId];
71
- const instanceClass = this._hierarchy.classes[classId];
72
- return instanceClass.name;
73
- }
74
- return undefined;
115
+
116
+ return results;
117
+ }
118
+
119
+ getProperty(batchId, name) {
120
+ this._checkBatchId(batchId);
121
+
122
+ assert(typeof name === 'string', name);
123
+
124
+ if (this._binaryProperties) {
125
+ const binaryProperty = this._binaryProperties[name];
126
+
127
+ if (defined(binaryProperty)) {
128
+ return this._getBinaryProperty(binaryProperty, batchId);
129
+ }
75
130
  }
76
- hasProperty(batchId, name) {
77
- this._checkBatchId(batchId);
78
- (0, loader_utils_1.assert)(typeof name === 'string', name);
79
- return defined(this._properties[name]) || this._hasPropertyInHierarchy(batchId, name);
131
+
132
+ const propertyValues = this._properties[name];
133
+
134
+ if (defined(propertyValues)) {
135
+ return clone(propertyValues[batchId], true);
80
136
  }
81
- getPropertyNames(batchId, results) {
82
- this._checkBatchId(batchId);
83
- results = defined(results) ? results : [];
84
- results.length = 0;
85
- const propertyNames = Object.keys(this._properties);
86
- results.push(...propertyNames);
87
- if (this._hierarchy) {
88
- this._getPropertyNamesInHierarchy(batchId, results);
89
- }
90
- return results;
137
+
138
+ if (this._hierarchy) {
139
+ const hierarchyProperty = this._getHierarchyProperty(batchId, name);
140
+
141
+ if (defined(hierarchyProperty)) {
142
+ return hierarchyProperty;
143
+ }
91
144
  }
92
- getProperty(batchId, name) {
93
- this._checkBatchId(batchId);
94
- (0, loader_utils_1.assert)(typeof name === 'string', name);
95
- if (this._binaryProperties) {
96
- const binaryProperty = this._binaryProperties[name];
97
- if (defined(binaryProperty)) {
98
- return this._getBinaryProperty(binaryProperty, batchId);
99
- }
100
- }
101
- const propertyValues = this._properties[name];
102
- if (defined(propertyValues)) {
103
- return clone(propertyValues[batchId], true);
104
- }
105
- // EXTENSION: 3DTILES_batch_table_hierarchy
106
- if (this._hierarchy) {
107
- const hierarchyProperty = this._getHierarchyProperty(batchId, name);
108
- if (defined(hierarchyProperty)) {
109
- return hierarchyProperty;
110
- }
111
- }
112
- return undefined;
145
+
146
+ return undefined;
147
+ }
148
+
149
+ setProperty(batchId, name, value) {
150
+ const featureCount = this.featureCount;
151
+
152
+ this._checkBatchId(batchId);
153
+
154
+ assert(typeof name === 'string', name);
155
+
156
+ if (this._binaryProperties) {
157
+ const binaryProperty = this._binaryProperties[name];
158
+
159
+ if (binaryProperty) {
160
+ this._setBinaryProperty(binaryProperty, batchId, value);
161
+
162
+ return;
163
+ }
113
164
  }
114
- setProperty(batchId, name, value) {
115
- const featureCount = this.featureCount;
116
- this._checkBatchId(batchId);
117
- (0, loader_utils_1.assert)(typeof name === 'string', name);
118
- if (this._binaryProperties) {
119
- const binaryProperty = this._binaryProperties[name];
120
- if (binaryProperty) {
121
- this._setBinaryProperty(binaryProperty, batchId, value);
122
- return;
123
- }
124
- }
125
- // EXTENSION: 3DTILES_batch_table_hierarchy
126
- if (this._hierarchy) {
127
- if (this._setHierarchyProperty(this, batchId, name, value)) {
128
- return;
129
- }
130
- }
131
- let propertyValues = this._properties[name];
132
- if (!defined(propertyValues)) {
133
- // Property does not exist. Create it.
134
- this._properties[name] = new Array(featureCount);
135
- propertyValues = this._properties[name];
136
- }
137
- propertyValues[batchId] = clone(value, true);
165
+
166
+ if (this._hierarchy) {
167
+ if (this._setHierarchyProperty(this, batchId, name, value)) {
168
+ return;
169
+ }
138
170
  }
139
- // PRIVATE METHODS
140
- _checkBatchId(batchId) {
141
- const valid = batchId >= 0 && batchId < this.featureCount;
142
- if (!valid) {
143
- throw new Error('batchId not in range [0, featureCount - 1].');
144
- }
171
+
172
+ let propertyValues = this._properties[name];
173
+
174
+ if (!defined(propertyValues)) {
175
+ this._properties[name] = new Array(featureCount);
176
+ propertyValues = this._properties[name];
145
177
  }
146
- _getBinaryProperty(binaryProperty, index) {
147
- return binaryProperty.unpack(binaryProperty.typedArray, index);
178
+
179
+ propertyValues[batchId] = clone(value, true);
180
+ }
181
+
182
+ _checkBatchId(batchId) {
183
+ const valid = batchId >= 0 && batchId < this.featureCount;
184
+
185
+ if (!valid) {
186
+ throw new Error('batchId not in range [0, featureCount - 1].');
148
187
  }
149
- _setBinaryProperty(binaryProperty, index, value) {
150
- binaryProperty.pack(value, binaryProperty.typedArray, index);
188
+ }
189
+
190
+ _getBinaryProperty(binaryProperty, index) {
191
+ return binaryProperty.unpack(binaryProperty.typedArray, index);
192
+ }
193
+
194
+ _setBinaryProperty(binaryProperty, index, value) {
195
+ binaryProperty.pack(value, binaryProperty.typedArray, index);
196
+ }
197
+
198
+ _initializeBinaryProperties() {
199
+ let binaryProperties = null;
200
+
201
+ for (const name in this._properties) {
202
+ const property = this._properties[name];
203
+
204
+ const binaryProperty = this._initializeBinaryProperty(name, property);
205
+
206
+ if (binaryProperty) {
207
+ binaryProperties = binaryProperties || {};
208
+ binaryProperties[name] = binaryProperty;
209
+ }
151
210
  }
152
- _initializeBinaryProperties() {
153
- let binaryProperties = null;
154
- for (const name in this._properties) {
155
- const property = this._properties[name];
156
- const binaryProperty = this._initializeBinaryProperty(name, property);
157
- // Store any information needed to access the binary data, including the typed array,
158
- // componentCount (e.g. a VEC4 would be 4), and the type used to pack and unpack (e.g. Cartesian4).
159
- if (binaryProperty) {
160
- binaryProperties = binaryProperties || {};
161
- binaryProperties[name] = binaryProperty;
162
- }
163
- }
164
- return binaryProperties;
211
+
212
+ return binaryProperties;
213
+ }
214
+
215
+ _initializeBinaryProperty(name, property) {
216
+ if ('byteOffset' in property) {
217
+ const tile3DAccessor = property;
218
+ assert(this.binary, "Property ".concat(name, " requires a batch table binary."));
219
+ assert(tile3DAccessor.type, "Property ".concat(name, " requires a type."));
220
+ const accessor = createTypedArrayFromAccessor(tile3DAccessor, this.binary.buffer, this.binary.byteOffset | 0, this.featureCount);
221
+ return {
222
+ typedArray: accessor.values,
223
+ componentCount: accessor.size,
224
+ unpack: accessor.unpacker,
225
+ pack: accessor.packer
226
+ };
165
227
  }
166
- _initializeBinaryProperty(name, property) {
167
- if ('byteOffset' in property) {
168
- // This is a binary property
169
- const tile3DAccessor = property;
170
- (0, loader_utils_1.assert)(this.binary, `Property ${name} requires a batch table binary.`);
171
- (0, loader_utils_1.assert)(tile3DAccessor.type, `Property ${name} requires a type.`);
172
- const accessor = (0, tile_3d_accessor_utils_1.createTypedArrayFromAccessor)(tile3DAccessor, this.binary.buffer, this.binary.byteOffset | 0, this.featureCount);
173
- // Store any information needed to access the binary data, including the typed array,
174
- // componentCount (e.g. a VEC4 would be 4), and the type used to pack and unpack (e.g. Cartesian4).
175
- return {
176
- typedArray: accessor.values,
177
- componentCount: accessor.size,
178
- unpack: accessor.unpacker,
179
- pack: accessor.packer
180
- };
181
- }
182
- return null;
228
+
229
+ return null;
230
+ }
231
+
232
+ _hasPropertyInHierarchy(batchId, name) {
233
+ if (!this._hierarchy) {
234
+ return false;
183
235
  }
184
- // EXTENSION SUPPORT: 3DTILES_batch_table_hierarchy
185
- _hasPropertyInHierarchy(batchId, name) {
186
- if (!this._hierarchy) {
187
- return false;
236
+
237
+ const result = traverseHierarchy(this._hierarchy, batchId, (hierarchy, instanceIndex) => {
238
+ const classId = hierarchy.classIds[instanceIndex];
239
+ const instances = hierarchy.classes[classId].instances;
240
+ return defined(instances[name]);
241
+ });
242
+ return defined(result);
243
+ }
244
+
245
+ _getPropertyNamesInHierarchy(batchId, results) {
246
+ traverseHierarchy(this._hierarchy, batchId, (hierarchy, instanceIndex) => {
247
+ const classId = hierarchy.classIds[instanceIndex];
248
+ const instances = hierarchy.classes[classId].instances;
249
+
250
+ for (const name in instances) {
251
+ if (instances.hasOwnProperty(name)) {
252
+ if (results.indexOf(name) === -1) {
253
+ results.push(name);
254
+ }
188
255
  }
189
- const result = (0, tile_3d_batch_table_hierarchy_1.traverseHierarchy)(this._hierarchy, batchId, (hierarchy, instanceIndex) => {
190
- const classId = hierarchy.classIds[instanceIndex];
191
- const instances = hierarchy.classes[classId].instances;
192
- return defined(instances[name]);
193
- });
194
- return defined(result);
195
- }
196
- _getPropertyNamesInHierarchy(batchId, results) {
197
- (0, tile_3d_batch_table_hierarchy_1.traverseHierarchy)(this._hierarchy, batchId, (hierarchy, instanceIndex) => {
198
- const classId = hierarchy.classIds[instanceIndex];
199
- const instances = hierarchy.classes[classId].instances;
200
- for (const name in instances) {
201
- if (instances.hasOwnProperty(name)) {
202
- if (results.indexOf(name) === -1) {
203
- results.push(name);
204
- }
205
- }
206
- }
207
- });
208
- }
209
- _getHierarchyProperty(batchId, name) {
210
- return (0, tile_3d_batch_table_hierarchy_1.traverseHierarchy)(this._hierarchy, batchId, (hierarchy, instanceIndex) => {
211
- const classId = hierarchy.classIds[instanceIndex];
212
- const instanceClass = hierarchy.classes[classId];
213
- const indexInClass = hierarchy.classIndexes[instanceIndex];
214
- const propertyValues = instanceClass.instances[name];
215
- if (defined(propertyValues)) {
216
- if (defined(propertyValues.typedArray)) {
217
- return this._getBinaryProperty(propertyValues, indexInClass);
218
- }
219
- return clone(propertyValues[indexInClass], true);
220
- }
221
- return null;
222
- });
223
- }
224
- _setHierarchyProperty(batchTable, batchId, name, value) {
225
- const result = (0, tile_3d_batch_table_hierarchy_1.traverseHierarchy)(this._hierarchy, batchId, (hierarchy, instanceIndex) => {
226
- const classId = hierarchy.classIds[instanceIndex];
227
- const instanceClass = hierarchy.classes[classId];
228
- const indexInClass = hierarchy.classIndexes[instanceIndex];
229
- const propertyValues = instanceClass.instances[name];
230
- if (defined(propertyValues)) {
231
- (0, loader_utils_1.assert)(instanceIndex === batchId, `Inherited property "${name}" is read-only.`);
232
- if (defined(propertyValues.typedArray)) {
233
- this._setBinaryProperty(propertyValues, indexInClass, value);
234
- }
235
- else {
236
- propertyValues[indexInClass] = clone(value, true);
237
- }
238
- return true;
239
- }
240
- return false;
241
- });
242
- return defined(result);
243
- }
256
+ }
257
+ });
258
+ }
259
+
260
+ _getHierarchyProperty(batchId, name) {
261
+ return traverseHierarchy(this._hierarchy, batchId, (hierarchy, instanceIndex) => {
262
+ const classId = hierarchy.classIds[instanceIndex];
263
+ const instanceClass = hierarchy.classes[classId];
264
+ const indexInClass = hierarchy.classIndexes[instanceIndex];
265
+ const propertyValues = instanceClass.instances[name];
266
+
267
+ if (defined(propertyValues)) {
268
+ if (defined(propertyValues.typedArray)) {
269
+ return this._getBinaryProperty(propertyValues, indexInClass);
270
+ }
271
+
272
+ return clone(propertyValues[indexInClass], true);
273
+ }
274
+
275
+ return null;
276
+ });
277
+ }
278
+
279
+ _setHierarchyProperty(batchTable, batchId, name, value) {
280
+ const result = traverseHierarchy(this._hierarchy, batchId, (hierarchy, instanceIndex) => {
281
+ const classId = hierarchy.classIds[instanceIndex];
282
+ const instanceClass = hierarchy.classes[classId];
283
+ const indexInClass = hierarchy.classIndexes[instanceIndex];
284
+ const propertyValues = instanceClass.instances[name];
285
+
286
+ if (defined(propertyValues)) {
287
+ assert(instanceIndex === batchId, "Inherited property \"".concat(name, "\" is read-only."));
288
+
289
+ if (defined(propertyValues.typedArray)) {
290
+ this._setBinaryProperty(propertyValues, indexInClass, value);
291
+ } else {
292
+ propertyValues[indexInClass] = clone(value, true);
293
+ }
294
+
295
+ return true;
296
+ }
297
+
298
+ return false;
299
+ });
300
+ return defined(result);
301
+ }
302
+
244
303
  }
245
- exports.default = Tile3DBatchTableParser;
304
+ //# sourceMappingURL=tile-3d-batch-table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/lib/classes/tile-3d-batch-table.ts"],"names":["assert","createTypedArrayFromAccessor","initializeHierarchy","traverseHierarchy","defined","x","undefined","clone","y","IGNORED_PROPERTY_FIELDS","HIERARCHY","extensions","extras","Tile3DBatchTableParser","constructor","json","binary","featureCount","options","_extensions","_properties","propertyName","_binaryProperties","_initializeBinaryProperties","_hierarchy","getExtension","extensionName","memorySizeInBytes","isClass","batchId","className","_checkBatchId","result","hierarchy","instanceIndex","classId","classIds","instanceClass","classes","name","isExactClass","getExactClassName","hasProperty","_hasPropertyInHierarchy","getPropertyNames","results","length","propertyNames","Object","keys","push","_getPropertyNamesInHierarchy","getProperty","binaryProperty","_getBinaryProperty","propertyValues","hierarchyProperty","_getHierarchyProperty","setProperty","value","_setBinaryProperty","_setHierarchyProperty","Array","valid","Error","index","unpack","typedArray","pack","binaryProperties","property","_initializeBinaryProperty","tile3DAccessor","type","accessor","buffer","byteOffset","values","componentCount","size","unpacker","packer","instances","hasOwnProperty","indexOf","indexInClass","classIndexes","batchTable"],"mappings":";AAGA,SAAQA,MAAR,QAAqB,0BAArB;AAEA,SAAQC,4BAAR,QAA2C,kCAA3C;AACA,SAAQC,mBAAR,EAA6BC,iBAA7B,QAAqD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ACtD,UAAM3B,MAAM,GAAG7B,iBAAiB,CAAC,KAAKqB,UAAN,EAAkBK,OAAlB,EAA2B,CAACI,SAAD,EAAYC,aAAZ,KAA8B;AACvF,YAAMC,OAAO,GAAGF,SAAS,CAACG,QAAV,CAAmBF,aAAnB,CAAhB;AACA,YAAMG,aAAa,GAAGJ,SAAS,CAACK,OAAV,CAAkBH,OAAlB,CAAtB;AACA,YAAMkD,YAAY,GAAGpD,SAAS,CAACqD,YAAV,CAAuBpD,aAAvB,CAArB;AACA,YAAMqB,cAAc,GAAGlB,aAAa,CAAC6C,SAAd,CAAwB3C,IAAxB,CAAvB;;AACA,UAAInC,OAAO,CAACmD,cAAD,CAAX,EAA6B;AAC3BvD,QAAAA,MAAM,CAACkC,aAAa,KAAKL,OAAnB,iCAAmDU,IAAnD,sBAAN;;AACA,YAAInC,OAAO,CAACmD,cAAc,CAACY,UAAhB,CAAX,EAAwC;AACtC,eAAKP,kBAAL,CAAwBL,cAAxB,EAAwC8B,YAAxC,EAAsD1B,KAAtD;AACD,SAFD,MAEO;AACLJ,UAAAA,cAAc,CAAC8B,YAAD,CAAd,GAA+B9E,KAAK,CAACoD,KAAD,EAAQ,IAAR,CAApC;AACD;;AACD,eAAO,IAAP;AACD;;AACD,aAAO,KAAP;AACD,KAf+B,CAAhC;AAgBA,WAAOvD,OAAO,CAAC4B,MAAD,CAAd;AACD;;AA/RyC","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 {assert} from '@loaders.gl/loader-utils';\n\nimport {createTypedArrayFromAccessor} from './helpers/tile-3d-accessor-utils';\nimport {initializeHierarchy, traverseHierarchy} from './tile-3d-batch-table-hierarchy';\n\nfunction defined(x) {\n return x !== undefined && x !== null;\n}\n\nconst clone = (x, y) => x;\n\n// These top level fields in the batch table json are not properties\nconst IGNORED_PROPERTY_FIELDS = {\n HIERARCHY: true, // Deprecated HIERARCHY property\n extensions: true,\n extras: true\n};\n\n// The size of this array equals the maximum instance count among all loaded tiles, which has the potential to be large.\nexport default class Tile3DBatchTableParser {\n json;\n binary;\n featureCount;\n _extensions;\n // Copy all top-level property fields from the json object, ignoring special fields\n _properties;\n _binaryProperties;\n // TODO: hierarchy support is only partially implemented and not tested\n _hierarchy;\n\n constructor(json, binary, featureCount, options = {}) {\n assert(featureCount >= 0);\n this.json = json || {};\n this.binary = binary;\n this.featureCount = featureCount;\n\n this._extensions = this.json?.extensions || {};\n\n // Copy all top-level property fields from the json object, ignoring special fields\n this._properties = {};\n for (const propertyName in this.json) {\n if (!IGNORED_PROPERTY_FIELDS[propertyName]) {\n this._properties[propertyName] = this.json[propertyName];\n }\n }\n\n this._binaryProperties = this._initializeBinaryProperties();\n\n // TODO: hierarchy support is only partially implemented and not tested\n if (options['3DTILES_batch_table_hierarchy']) {\n this._hierarchy = initializeHierarchy(this, this.json, this.binary);\n }\n }\n\n getExtension(extensionName) {\n return this.json && this.json.extensions && this.json.extensions[extensionName];\n }\n\n memorySizeInBytes(): number {\n return 0;\n }\n\n isClass(batchId, className: string): boolean {\n this._checkBatchId(batchId);\n assert(typeof className === 'string', className);\n\n // extension: 3DTILES_batch_table_hierarchy\n if (this._hierarchy) {\n // PERFORMANCE_IDEA : cache results in the ancestor classes\n // to speed up this check if this area becomes a hotspot\n // PERFORMANCE_IDEA : treat class names as integers for faster comparisons\n const result = traverseHierarchy(this._hierarchy, batchId, (hierarchy, instanceIndex) => {\n const classId = hierarchy.classIds[instanceIndex];\n const instanceClass = hierarchy.classes[classId];\n return instanceClass.name === className;\n });\n return defined(result);\n }\n\n return false;\n }\n\n isExactClass(batchId, className) {\n assert(typeof className === 'string', className);\n\n return this.getExactClassName(batchId) === className;\n }\n\n getExactClassName(batchId) {\n this._checkBatchId(batchId);\n\n // extension: 3DTILES_batch_table_hierarchy\n if (this._hierarchy) {\n const classId = this._hierarchy.classIds[batchId];\n const instanceClass = this._hierarchy.classes[classId];\n return instanceClass.name;\n }\n\n return undefined;\n }\n\n hasProperty(batchId, name) {\n this._checkBatchId(batchId);\n assert(typeof name === 'string', name);\n\n return defined(this._properties[name]) || this._hasPropertyInHierarchy(batchId, name);\n }\n\n getPropertyNames(batchId, results) {\n this._checkBatchId(batchId);\n\n results = defined(results) ? results : [];\n results.length = 0;\n\n const propertyNames = Object.keys(this._properties);\n results.push(...propertyNames);\n\n if (this._hierarchy) {\n this._getPropertyNamesInHierarchy(batchId, results);\n }\n\n return results;\n }\n\n getProperty(batchId, name) {\n this._checkBatchId(batchId);\n assert(typeof name === 'string', name);\n\n if (this._binaryProperties) {\n const binaryProperty = this._binaryProperties[name];\n if (defined(binaryProperty)) {\n return this._getBinaryProperty(binaryProperty, batchId);\n }\n }\n\n const propertyValues = this._properties[name];\n if (defined(propertyValues)) {\n return clone(propertyValues[batchId], true);\n }\n\n // EXTENSION: 3DTILES_batch_table_hierarchy\n if (this._hierarchy) {\n const hierarchyProperty = this._getHierarchyProperty(batchId, name);\n if (defined(hierarchyProperty)) {\n return hierarchyProperty;\n }\n }\n\n return undefined;\n }\n\n setProperty(batchId, name, value) {\n const featureCount = this.featureCount;\n\n this._checkBatchId(batchId);\n assert(typeof name === 'string', name);\n\n if (this._binaryProperties) {\n const binaryProperty = this._binaryProperties[name];\n if (binaryProperty) {\n this._setBinaryProperty(binaryProperty, batchId, value);\n return;\n }\n }\n\n // EXTENSION: 3DTILES_batch_table_hierarchy\n if (this._hierarchy) {\n if (this._setHierarchyProperty(this, batchId, name, value)) {\n return;\n }\n }\n\n let propertyValues = this._properties[name];\n if (!defined(propertyValues)) {\n // Property does not exist. Create it.\n this._properties[name] = new Array(featureCount);\n propertyValues = this._properties[name];\n }\n\n propertyValues[batchId] = clone(value, true);\n }\n\n // PRIVATE METHODS\n\n _checkBatchId(batchId) {\n const valid = batchId >= 0 && batchId < this.featureCount;\n if (!valid) {\n throw new Error('batchId not in range [0, featureCount - 1].');\n }\n }\n\n _getBinaryProperty(binaryProperty, index) {\n return binaryProperty.unpack(binaryProperty.typedArray, index);\n }\n\n _setBinaryProperty(binaryProperty, index, value) {\n binaryProperty.pack(value, binaryProperty.typedArray, index);\n }\n\n _initializeBinaryProperties() {\n let binaryProperties: Record<string, any> | null = null;\n for (const name in this._properties) {\n const property = this._properties[name];\n const binaryProperty = this._initializeBinaryProperty(name, property);\n // Store any information needed to access the binary data, including the typed array,\n // componentCount (e.g. a VEC4 would be 4), and the type used to pack and unpack (e.g. Cartesian4).\n if (binaryProperty) {\n binaryProperties = binaryProperties || {};\n binaryProperties[name] = binaryProperty;\n }\n }\n return binaryProperties;\n }\n\n _initializeBinaryProperty(name, property) {\n if ('byteOffset' in property) {\n // This is a binary property\n const tile3DAccessor = property;\n\n assert(this.binary, `Property ${name} requires a batch table binary.`);\n assert(tile3DAccessor.type, `Property ${name} requires a type.`);\n\n const accessor = createTypedArrayFromAccessor(\n tile3DAccessor,\n this.binary.buffer,\n this.binary.byteOffset | 0,\n this.featureCount\n );\n\n // Store any information needed to access the binary data, including the typed array,\n // componentCount (e.g. a VEC4 would be 4), and the type used to pack and unpack (e.g. Cartesian4).\n return {\n typedArray: accessor.values,\n componentCount: accessor.size,\n unpack: accessor.unpacker,\n pack: accessor.packer\n };\n }\n\n return null;\n }\n\n // EXTENSION SUPPORT: 3DTILES_batch_table_hierarchy\n\n _hasPropertyInHierarchy(batchId, name) {\n if (!this._hierarchy) {\n return false;\n }\n\n const result = traverseHierarchy(this._hierarchy, batchId, (hierarchy, instanceIndex) => {\n const classId = hierarchy.classIds[instanceIndex];\n const instances = hierarchy.classes[classId].instances;\n return defined(instances[name]);\n });\n\n return defined(result);\n }\n\n _getPropertyNamesInHierarchy(batchId, results) {\n traverseHierarchy(this._hierarchy, batchId, (hierarchy, instanceIndex) => {\n const classId = hierarchy.classIds[instanceIndex];\n const instances = hierarchy.classes[classId].instances;\n for (const name in instances) {\n if (instances.hasOwnProperty(name)) {\n if (results.indexOf(name) === -1) {\n results.push(name);\n }\n }\n }\n });\n }\n\n _getHierarchyProperty(batchId, name) {\n return traverseHierarchy(this._hierarchy, batchId, (hierarchy, instanceIndex) => {\n const classId = hierarchy.classIds[instanceIndex];\n const instanceClass = hierarchy.classes[classId];\n const indexInClass = hierarchy.classIndexes[instanceIndex];\n const propertyValues = instanceClass.instances[name];\n if (defined(propertyValues)) {\n if (defined(propertyValues.typedArray)) {\n return this._getBinaryProperty(propertyValues, indexInClass);\n }\n return clone(propertyValues[indexInClass], true);\n }\n return null;\n });\n }\n\n _setHierarchyProperty(batchTable, batchId, name, value) {\n const result = traverseHierarchy(this._hierarchy, batchId, (hierarchy, instanceIndex) => {\n const classId = hierarchy.classIds[instanceIndex];\n const instanceClass = hierarchy.classes[classId];\n const indexInClass = hierarchy.classIndexes[instanceIndex];\n const propertyValues = instanceClass.instances[name];\n if (defined(propertyValues)) {\n assert(instanceIndex === batchId, `Inherited property \"${name}\" is read-only.`);\n if (defined(propertyValues.typedArray)) {\n this._setBinaryProperty(propertyValues, indexInClass, value);\n } else {\n propertyValues[indexInClass] = clone(value, true);\n }\n return true;\n }\n return false;\n });\n return defined(result);\n }\n}\n"],"file":"tile-3d-batch-table.js"}