@loaders.gl/3d-tiles 4.0.0-alpha.7 → 4.0.0-alpha.8

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 (114) hide show
  1. package/dist/dist.min.js +317 -146
  2. package/dist/es5/index.js.map +1 -1
  3. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-colors.js +4 -3
  4. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-colors.js.map +1 -1
  5. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-normals.js +2 -2
  6. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-normals.js.map +1 -1
  7. package/dist/es5/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +1 -1
  8. package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js +30 -18
  9. package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
  10. package/dist/es5/lib/parsers/helpers/parse-3d-tile-header.js.map +1 -1
  11. package/dist/es5/lib/parsers/helpers/parse-3d-tile-tables.js +12 -12
  12. package/dist/es5/lib/parsers/helpers/parse-3d-tile-tables.js.map +1 -1
  13. package/dist/es5/lib/parsers/parse-3d-tile-batched-model.js.map +1 -1
  14. package/dist/es5/lib/parsers/parse-3d-tile-composite.js +1 -1
  15. package/dist/es5/lib/parsers/parse-3d-tile-composite.js.map +1 -1
  16. package/dist/es5/lib/parsers/parse-3d-tile-gltf.js +19 -4
  17. package/dist/es5/lib/parsers/parse-3d-tile-gltf.js.map +1 -1
  18. package/dist/es5/lib/parsers/parse-3d-tile-header.js +98 -80
  19. package/dist/es5/lib/parsers/parse-3d-tile-header.js.map +1 -1
  20. package/dist/es5/lib/parsers/parse-3d-tile-instanced-model.js +12 -21
  21. package/dist/es5/lib/parsers/parse-3d-tile-instanced-model.js.map +1 -1
  22. package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js +29 -5
  23. package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
  24. package/dist/es5/lib/parsers/parse-3d-tile.js.map +1 -1
  25. package/dist/es5/lib/utils/version.js +1 -1
  26. package/dist/es5/tiles-3d-loader.js +26 -31
  27. package/dist/es5/tiles-3d-loader.js.map +1 -1
  28. package/dist/es5/types.js.map +1 -1
  29. package/dist/esm/index.js.map +1 -1
  30. package/dist/esm/lib/parsers/helpers/normalize-3d-tile-colors.js +3 -3
  31. package/dist/esm/lib/parsers/helpers/normalize-3d-tile-colors.js.map +1 -1
  32. package/dist/esm/lib/parsers/helpers/normalize-3d-tile-normals.js +2 -2
  33. package/dist/esm/lib/parsers/helpers/normalize-3d-tile-normals.js.map +1 -1
  34. package/dist/esm/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +1 -1
  35. package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js +15 -9
  36. package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
  37. package/dist/esm/lib/parsers/helpers/parse-3d-tile-header.js.map +1 -1
  38. package/dist/esm/lib/parsers/helpers/parse-3d-tile-tables.js +7 -7
  39. package/dist/esm/lib/parsers/helpers/parse-3d-tile-tables.js.map +1 -1
  40. package/dist/esm/lib/parsers/parse-3d-tile-batched-model.js.map +1 -1
  41. package/dist/esm/lib/parsers/parse-3d-tile-composite.js +1 -1
  42. package/dist/esm/lib/parsers/parse-3d-tile-composite.js.map +1 -1
  43. package/dist/esm/lib/parsers/parse-3d-tile-gltf.js +15 -7
  44. package/dist/esm/lib/parsers/parse-3d-tile-gltf.js.map +1 -1
  45. package/dist/esm/lib/parsers/parse-3d-tile-header.js +62 -45
  46. package/dist/esm/lib/parsers/parse-3d-tile-header.js.map +1 -1
  47. package/dist/esm/lib/parsers/parse-3d-tile-instanced-model.js +12 -21
  48. package/dist/esm/lib/parsers/parse-3d-tile-instanced-model.js.map +1 -1
  49. package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js +23 -2
  50. package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
  51. package/dist/esm/lib/parsers/parse-3d-tile.js.map +1 -1
  52. package/dist/esm/lib/utils/version.js +1 -1
  53. package/dist/esm/tiles-3d-loader.js +18 -12
  54. package/dist/esm/tiles-3d-loader.js.map +1 -1
  55. package/dist/esm/types.js.map +1 -1
  56. package/dist/index.d.ts +2 -1
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/lib/parsers/helpers/normalize-3d-tile-colors.d.ts +4 -2
  59. package/dist/lib/parsers/helpers/normalize-3d-tile-colors.d.ts.map +1 -1
  60. package/dist/lib/parsers/helpers/normalize-3d-tile-colors.js +3 -3
  61. package/dist/lib/parsers/helpers/normalize-3d-tile-normals.d.ts +3 -2
  62. package/dist/lib/parsers/helpers/normalize-3d-tile-normals.d.ts.map +1 -1
  63. package/dist/lib/parsers/helpers/normalize-3d-tile-normals.js +2 -2
  64. package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.d.ts.map +1 -1
  65. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.d.ts +5 -2
  66. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.d.ts.map +1 -1
  67. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js +15 -9
  68. package/dist/lib/parsers/helpers/parse-3d-tile-header.d.ts +2 -1
  69. package/dist/lib/parsers/helpers/parse-3d-tile-header.d.ts.map +1 -1
  70. package/dist/lib/parsers/helpers/parse-3d-tile-tables.d.ts +4 -2
  71. package/dist/lib/parsers/helpers/parse-3d-tile-tables.d.ts.map +1 -1
  72. package/dist/lib/parsers/helpers/parse-3d-tile-tables.js +7 -7
  73. package/dist/lib/parsers/parse-3d-tile-batched-model.d.ts +4 -1
  74. package/dist/lib/parsers/parse-3d-tile-batched-model.d.ts.map +1 -1
  75. package/dist/lib/parsers/parse-3d-tile-batched-model.js +1 -1
  76. package/dist/lib/parsers/parse-3d-tile-composite.d.ts +3 -2
  77. package/dist/lib/parsers/parse-3d-tile-composite.d.ts.map +1 -1
  78. package/dist/lib/parsers/parse-3d-tile-composite.js +1 -1
  79. package/dist/lib/parsers/parse-3d-tile-gltf.d.ts +2 -1
  80. package/dist/lib/parsers/parse-3d-tile-gltf.d.ts.map +1 -1
  81. package/dist/lib/parsers/parse-3d-tile-gltf.js +13 -5
  82. package/dist/lib/parsers/parse-3d-tile-header.d.ts +5 -6
  83. package/dist/lib/parsers/parse-3d-tile-header.d.ts.map +1 -1
  84. package/dist/lib/parsers/parse-3d-tile-header.js +57 -42
  85. package/dist/lib/parsers/parse-3d-tile-instanced-model.d.ts +2 -1
  86. package/dist/lib/parsers/parse-3d-tile-instanced-model.d.ts.map +1 -1
  87. package/dist/lib/parsers/parse-3d-tile-instanced-model.js +11 -25
  88. package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts +3 -2
  89. package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts.map +1 -1
  90. package/dist/lib/parsers/parse-3d-tile-point-cloud.js +23 -2
  91. package/dist/lib/parsers/parse-3d-tile.d.ts +4 -1
  92. package/dist/lib/parsers/parse-3d-tile.d.ts.map +1 -1
  93. package/dist/lib/parsers/parse-3d-tile.js +0 -4
  94. package/dist/tiles-3d-loader.d.ts.map +1 -1
  95. package/dist/tiles-3d-loader.js +18 -17
  96. package/dist/types.d.ts +257 -15
  97. package/dist/types.d.ts.map +1 -1
  98. package/package.json +7 -7
  99. package/src/index.ts +12 -1
  100. package/src/lib/parsers/helpers/normalize-3d-tile-colors.ts +10 -4
  101. package/src/lib/parsers/helpers/normalize-3d-tile-normals.ts +7 -3
  102. package/src/lib/parsers/helpers/parse-3d-implicit-tiles.ts +4 -4
  103. package/src/lib/parsers/helpers/parse-3d-tile-gltf-view.ts +35 -13
  104. package/src/lib/parsers/helpers/parse-3d-tile-header.ts +7 -1
  105. package/src/lib/parsers/helpers/parse-3d-tile-tables.ts +32 -11
  106. package/src/lib/parsers/parse-3d-tile-batched-model.ts +18 -3
  107. package/src/lib/parsers/parse-3d-tile-composite.ts +7 -6
  108. package/src/lib/parsers/parse-3d-tile-gltf.ts +16 -8
  109. package/src/lib/parsers/parse-3d-tile-header.ts +84 -52
  110. package/src/lib/parsers/parse-3d-tile-instanced-model.ts +24 -33
  111. package/src/lib/parsers/parse-3d-tile-point-cloud.ts +51 -19
  112. package/src/lib/parsers/parse-3d-tile.ts +10 -5
  113. package/src/tiles-3d-loader.ts +21 -23
  114. package/src/types.ts +269 -15
@@ -14,13 +14,14 @@ import {normalize3DTileNormalAttribute} from './helpers/normalize-3d-tile-normal
14
14
  import {normalize3DTilePositionAttribute} from './helpers/normalize-3d-tile-positions';
15
15
  import {Tiles3DLoaderOptions} from '../../tiles-3d-loader';
16
16
  import {LoaderContext} from '@loaders.gl/loader-utils';
17
+ import {Tiles3DTileContent} from '../../types';
17
18
 
18
19
  export async function parsePointCloud3DTile(
19
- tile,
20
+ tile: Tiles3DTileContent,
20
21
  arrayBuffer: ArrayBuffer,
21
22
  byteOffset: number,
22
- options: Tiles3DLoaderOptions,
23
- context: LoaderContext
23
+ options?: Tiles3DLoaderOptions,
24
+ context?: LoaderContext
24
25
  ): Promise<number> {
25
26
  byteOffset = parse3DTileHeaderSync(tile, arrayBuffer, byteOffset);
26
27
  byteOffset = parse3DTileTablesHeaderSync(tile, arrayBuffer, byteOffset);
@@ -39,7 +40,7 @@ export async function parsePointCloud3DTile(
39
40
  return byteOffset;
40
41
  }
41
42
 
42
- function initializeTile(tile): void {
43
+ function initializeTile(tile: Tiles3DTileContent): void {
43
44
  // Initialize point cloud tile defaults
44
45
  tile.attributes = {
45
46
  positions: null,
@@ -53,7 +54,7 @@ function initializeTile(tile): void {
53
54
  tile.isOctEncoded16P = false;
54
55
  }
55
56
 
56
- function parsePointCloudTables(tile): {
57
+ function parsePointCloudTables(tile: Tiles3DTileContent): {
57
58
  featureTable: Tile3DFeatureTable;
58
59
  batchTable: Tile3DBatchTable | null;
59
60
  } {
@@ -77,10 +78,16 @@ function parsePointCloudTables(tile): {
77
78
  }
78
79
 
79
80
  function parsePositions(
80
- tile,
81
+ tile: Tiles3DTileContent,
81
82
  featureTable: Tile3DFeatureTable,
82
- options: Tiles3DLoaderOptions
83
+ options: Tiles3DLoaderOptions | undefined
83
84
  ): void {
85
+ tile.attributes = tile.attributes || {
86
+ positions: null,
87
+ colors: null,
88
+ normals: null,
89
+ batchIds: null
90
+ };
84
91
  if (!tile.attributes.positions) {
85
92
  if (featureTable.hasProperty('POSITION')) {
86
93
  tile.attributes.positions = featureTable.getPropertyArray('POSITION', GL.FLOAT, 3);
@@ -117,7 +124,17 @@ function parsePositions(
117
124
  }
118
125
  }
119
126
 
120
- function parseColors(tile, featureTable: Tile3DFeatureTable, batchTable: Tile3DBatchTable): void {
127
+ function parseColors(
128
+ tile: Tiles3DTileContent,
129
+ featureTable: Tile3DFeatureTable,
130
+ batchTable: Tile3DBatchTable
131
+ ): void {
132
+ tile.attributes = tile.attributes || {
133
+ positions: null,
134
+ colors: null,
135
+ normals: null,
136
+ batchIds: null
137
+ };
121
138
  if (!tile.attributes.colors) {
122
139
  let colors = null;
123
140
  if (featureTable.hasProperty('RGBA')) {
@@ -138,7 +155,13 @@ function parseColors(tile, featureTable: Tile3DFeatureTable, batchTable: Tile3DB
138
155
  }
139
156
  }
140
157
 
141
- function parseNormals(tile, featureTable: Tile3DFeatureTable): void {
158
+ function parseNormals(tile: Tiles3DTileContent, featureTable: Tile3DFeatureTable): void {
159
+ tile.attributes = tile.attributes || {
160
+ positions: null,
161
+ colors: null,
162
+ normals: null,
163
+ batchIds: null
164
+ };
142
165
  if (!tile.attributes.normals) {
143
166
  let normals = null;
144
167
  if (featureTable.hasProperty('NORMAL')) {
@@ -152,7 +175,10 @@ function parseNormals(tile, featureTable: Tile3DFeatureTable): void {
152
175
  }
153
176
  }
154
177
 
155
- function parseBatchIds(tile, featureTable: Tile3DFeatureTable): Tile3DBatchTable | null {
178
+ function parseBatchIds(
179
+ tile: Tiles3DTileContent,
180
+ featureTable: Tile3DFeatureTable
181
+ ): Tile3DBatchTable | null {
156
182
  let batchTable: Tile3DBatchTable | null = null;
157
183
  if (!tile.batchIds && featureTable.hasProperty('BATCH_ID')) {
158
184
  tile.batchIds = featureTable.getPropertyArray('BATCH_ID', GL.UNSIGNED_SHORT, 1);
@@ -171,11 +197,11 @@ function parseBatchIds(tile, featureTable: Tile3DFeatureTable): Tile3DBatchTable
171
197
 
172
198
  // eslint-disable-next-line complexity
173
199
  async function parseDraco(
174
- tile,
200
+ tile: Tiles3DTileContent,
175
201
  featureTable: Tile3DFeatureTable,
176
202
  batchTable,
177
- options: Tiles3DLoaderOptions,
178
- context: LoaderContext
203
+ options?: Tiles3DLoaderOptions,
204
+ context?: LoaderContext
179
205
  ) {
180
206
  let dracoBuffer;
181
207
  let dracoFeatureTableProperties;
@@ -197,7 +223,10 @@ async function parseDraco(
197
223
  throw new Error('Draco properties, byteOffset, and byteLength must be defined');
198
224
  }
199
225
 
200
- dracoBuffer = tile.featureTableBinary.slice(dracoByteOffset, dracoByteOffset + dracoByteLength);
226
+ dracoBuffer = (tile.featureTableBinary || []).slice(
227
+ dracoByteOffset,
228
+ dracoByteOffset + dracoByteLength
229
+ );
201
230
 
202
231
  tile.hasPositions = Number.isFinite(dracoFeatureTableProperties.POSITION);
203
232
  tile.hasColors =
@@ -225,16 +254,19 @@ async function parseDraco(
225
254
 
226
255
  // eslint-disable-next-line complexity, max-statements
227
256
  export async function loadDraco(
228
- tile,
257
+ tile: Tiles3DTileContent,
229
258
  dracoData,
230
- options: Tiles3DLoaderOptions,
231
- context: LoaderContext
232
- ) {
259
+ options?: Tiles3DLoaderOptions,
260
+ context?: LoaderContext
261
+ ): Promise<void> {
262
+ if (!context) {
263
+ return;
264
+ }
233
265
  const {parse} = context;
234
266
  const dracoOptions = {
235
267
  ...options,
236
268
  draco: {
237
- ...options.draco,
269
+ ...options?.draco,
238
270
  extraAttributes: dracoData.batchTableProperties || {}
239
271
  }
240
272
  };
@@ -9,15 +9,21 @@ import {parseBatchedModel3DTile} from './parse-3d-tile-batched-model';
9
9
  import {parseInstancedModel3DTile} from './parse-3d-tile-instanced-model';
10
10
  import {parseComposite3DTile} from './parse-3d-tile-composite';
11
11
  import {parseGltf3DTile} from './parse-3d-tile-gltf';
12
+ import {LoaderContext} from '@loaders.gl/loader-utils';
13
+ import {Tiles3DLoaderOptions} from '../../tiles-3d-loader';
14
+ import {Tiles3DTileContent} from '../../types';
12
15
 
13
16
  // Extracts
14
- export async function parse3DTile(arrayBuffer, byteOffset = 0, options, context, tile = {}) {
15
- // @ts-expect-error
17
+ export async function parse3DTile(
18
+ arrayBuffer: ArrayBuffer,
19
+ byteOffset = 0,
20
+ options: Tiles3DLoaderOptions | undefined,
21
+ context: LoaderContext | undefined,
22
+ tile: Tiles3DTileContent = {}
23
+ ) {
16
24
  tile.byteOffset = byteOffset;
17
- // @ts-expect-error
18
25
  tile.type = getMagicString(arrayBuffer, byteOffset);
19
26
 
20
- // @ts-expect-error
21
27
  switch (tile.type) {
22
28
  case TILE3D_TYPE.COMPOSITE:
23
29
  // Note: We pass this function as argument so that embedded tiles can be parsed recursively
@@ -43,7 +49,6 @@ export async function parse3DTile(arrayBuffer, byteOffset = 0, options, context,
43
49
  return await parsePointCloud3DTile(tile, arrayBuffer, byteOffset, options, context);
44
50
 
45
51
  default:
46
- // @ts-expect-error
47
52
  throw new Error(`3DTileLoader: unknown type ${tile.type}`); // eslint-disable-line
48
53
  }
49
54
  }
@@ -8,6 +8,7 @@ import {TILESET_TYPE, LOD_METRIC_TYPE} from '@loaders.gl/tiles';
8
8
  import {VERSION} from './lib/utils/version';
9
9
  import {parse3DTile} from './lib/parsers/parse-3d-tile';
10
10
  import {normalizeTileHeaders} from './lib/parsers/parse-3d-tile-header';
11
+ import {Tiles3DTilesetJSON, Tiles3DTilesetJSONPostprocessed} from './types';
11
12
 
12
13
  export type Tiles3DLoaderOptions = LoaderOptions &
13
14
  // GLTFLoaderOptions & - TODO not yet exported
@@ -58,9 +59,7 @@ async function parse(data, options: Tiles3DLoaderOptions = {}, context?: LoaderC
58
59
  isTileset = loaderOptions.isTileset;
59
60
  }
60
61
 
61
- return (await isTileset)
62
- ? parseTileset(data, options, context)
63
- : parseTile(data, options, context);
62
+ return isTileset ? parseTileset(data, options, context) : parseTile(data, options, context);
64
63
  }
65
64
 
66
65
  /** Parse a tileset */
@@ -68,25 +67,24 @@ async function parseTileset(
68
67
  data: ArrayBuffer,
69
68
  options?: Tiles3DLoaderOptions,
70
69
  context?: LoaderContext
71
- ) {
72
- const tilesetJson = JSON.parse(new TextDecoder().decode(data));
73
-
74
- // eslint-disable-next-line no-use-before-define
75
- tilesetJson.loader = options?.loader || Tiles3DLoader;
76
- tilesetJson.url = context?.url || '';
77
- tilesetJson.queryString = context?.queryString || '';
78
-
79
- // base path that non-absolute paths in tileset are relative to.
80
- tilesetJson.basePath = getBaseUri(tilesetJson);
81
- // TODO - check option types in normalizeTileHeaders
82
- tilesetJson.root = await normalizeTileHeaders(tilesetJson, options || {});
70
+ ): Promise<Tiles3DTilesetJSONPostprocessed> {
71
+ const tilesetJson: Tiles3DTilesetJSON = JSON.parse(new TextDecoder().decode(data));
83
72
 
84
- tilesetJson.type = TILESET_TYPE.TILES3D;
85
-
86
- tilesetJson.lodMetricType = LOD_METRIC_TYPE.GEOMETRIC_ERROR;
87
- tilesetJson.lodMetricValue = tilesetJson.root?.lodMetricValue || 0;
88
-
89
- return tilesetJson;
73
+ const tilesetUrl = context?.url || '';
74
+ const basePath = getBaseUri(tilesetUrl);
75
+ const normalizedRoot = await normalizeTileHeaders(tilesetJson, basePath, options || {});
76
+ const tilesetJsonPostprocessed: Tiles3DTilesetJSONPostprocessed = {
77
+ ...tilesetJson,
78
+ loader: Tiles3DLoader,
79
+ url: tilesetUrl,
80
+ queryString: context?.queryString || '',
81
+ basePath,
82
+ root: normalizedRoot || tilesetJson.root,
83
+ type: TILESET_TYPE.TILES3D,
84
+ lodMetricType: LOD_METRIC_TYPE.GEOMETRIC_ERROR,
85
+ lodMetricValue: tilesetJson.root?.geometricError || 0
86
+ };
87
+ return tilesetJsonPostprocessed;
90
88
  }
91
89
 
92
90
  /** Parse a tile */
@@ -106,6 +104,6 @@ async function parseTile(
106
104
  }
107
105
 
108
106
  /** Get base name */
109
- function getBaseUri(tileset) {
110
- return path.dirname(tileset.url);
107
+ function getBaseUri(tilesetUrl: string): string {
108
+ return path.dirname(tilesetUrl);
111
109
  }
package/src/types.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import type {GLTFPostprocessed} from '@loaders.gl/gltf';
2
+ import {LoaderWithParser} from '@loaders.gl/loader-utils';
2
3
  import {Matrix4, Vector3} from '@math.gl/core';
4
+ import {TILESET_TYPE, LOD_METRIC_TYPE, TILE_TYPE, TILE_REFINEMENT} from '@loaders.gl/tiles';
3
5
 
4
6
  export type FeatureTableJson = {
5
7
  [key: string]: any[];
@@ -35,20 +37,259 @@ export type GLTFHeader = {
35
37
  featureTableJsonByteLength: number;
36
38
  };
37
39
 
38
- export type Node3D = {
39
- boundingVolume: BoundingVolume;
40
- children: any;
41
- geometricError: number;
42
- content?: {
43
- uri: string;
44
- boundingVolume: BoundingVolume;
40
+ /**
41
+ * A 3D Tiles tileset JSON
42
+ * https://github.com/CesiumGS/3d-tiles/tree/main/specification#property-reference
43
+ */
44
+ export type Tiles3DTilesetJSON = {
45
+ /** Metadata about the entire tileset.
46
+ * https://github.com/CesiumGS/3d-tiles/tree/main/specification#asset
47
+ */
48
+ asset: {
49
+ /** The 3D Tiles version. The version defines the JSON schema for the tileset JSON and the base set of tile formats. */
50
+ version: string;
51
+ /** Application-specific version of this tileset, e.g., for when an existing tileset is updated. */
52
+ tilesetVersion?: string;
53
+ /** Dictionary object with extension-specific objects. */
54
+ extensions?: object;
55
+ /** Application-specific data. */
56
+ extras?: any;
57
+ /** Not mentioned in 1.0 spec but some tilesets contain this option */
58
+ gltfUpAxis?: string;
45
59
  };
60
+ /** A dictionary object of metadata about per-feature properties. */
61
+ properties?: Record<string, TilesetProperty>;
62
+ /** The error, in meters, introduced if this tileset is not rendered. At runtime, the geometric error is used to compute screen space error (SSE), i.e., the error measured in pixels. */
63
+ geometricError: number;
64
+ /** A tile in a 3D Tiles tileset. */
65
+ root: Tiles3DTileJSON;
66
+ /** Names of 3D Tiles extensions used somewhere in this tileset. */
67
+ extensionsUsed?: string[];
68
+ /** Names of 3D Tiles extensions required to properly load this tileset. */
69
+ extensionsRequired?: string[];
70
+ /** Dictionary object with extension-specific objects. */
71
+ extensions?: object;
72
+ /** Application-specific data. */
73
+ extras?: any;
74
+ };
75
+
76
+ /** TilesetJSON postprocessed by Tiles3DLoader */
77
+ export type Tiles3DTilesetJSONPostprocessed = Omit<Tiles3DTilesetJSON, 'root'> & {
78
+ /**
79
+ * Loader used
80
+ * @deprecated
81
+ */
82
+ loader: LoaderWithParser;
83
+ /** URL used to load a tileset resource */
84
+ url: string;
85
+ /** HTTP request query string */
86
+ queryString: string;
87
+ /** base path that non-absolute paths in tileset are relative to. */
88
+ basePath: string;
89
+ /** tileset type */
90
+ type: TILESET_TYPE.TILES3D;
91
+ /** LOD metric type */
92
+ lodMetricType: LOD_METRIC_TYPE.GEOMETRIC_ERROR;
93
+ /** LOD metric value */
94
+ lodMetricValue: number;
95
+ /** Postprocessed root */
96
+ root: Tiles3DTileJSONPostprocessed;
46
97
  };
47
98
 
48
- export type BoundingVolume = {
99
+ /**
100
+ * A tile in a 3D Tiles tileset.
101
+ * https://github.com/CesiumGS/3d-tiles/tree/main/specification#tile
102
+ */
103
+ export type Tiles3DTileJSON = {
104
+ /** A bounding volume that encloses a tile or its content. */
105
+ boundingVolume: Tile3DBoundingVolume;
106
+ /** A bounding volume that encloses a tile or its content. */
107
+ viewerRequestVolume?: object;
108
+ /** The error, in meters, introduced if this tile is rendered and its children are not. At runtime, the geometric error is used to compute screen space error (SSE), i.e., the error measured in pixels. */
109
+ geometricError: number;
110
+ /**
111
+ * Specifies if additive or replacement refinement is used when traversing the tileset for rendering. This property is required for the root tile of a tileset; it is optional for all other tiles.
112
+ * The default is to inherit from the parent tile.
113
+ */
114
+ refine?: string;
115
+ /** A floating-point 4x4 affine transformation matrix, stored in column-major order, that transforms the tile's content */
116
+ transform?: number[];
117
+ /** Metadata about the tile's content and a link to the content. */
118
+ content?: Tiles3DTileContentJSON;
119
+ /** An array of objects that define child tiles. */
120
+ children: Tiles3DTileJSON[];
121
+ /** Dictionary object with extension-specific objects. */
122
+ extensions?: object;
123
+ /** Application-specific data. */
124
+ extras?: any;
125
+
126
+ /** 3DTiles v1.1 properties
127
+ * https://github.com/CesiumGS/3d-tiles/blob/draft-1.1/specification/schema/tile.schema.json
128
+ */
129
+ /** This object allows a tile to be implicitly subdivided. Tile and content availability and metadata is stored in subtrees which are referenced externally. */
130
+ implicitTiling?: ImplicitTilingData;
131
+ };
132
+
133
+ export type Tiles3DTileJSONPostprocessed = Omit<Tiles3DTileJSON, 'refine' | 'children'> & {
134
+ /** Unique ID */
135
+ id?: string;
136
+ /** Content full URL */
137
+ contentUrl?: string;
138
+ /** LOD metric type */
139
+ lodMetricType?: LOD_METRIC_TYPE.GEOMETRIC_ERROR;
140
+ /** LOD metric value */
141
+ lodMetricValue?: number;
142
+ /** Duplicate of transform */
143
+ transformMatrix?: number[];
144
+ /** Type of tile */
145
+ type?: TILE_TYPE | string;
146
+ /**
147
+ * Specifies if additive or replacement refinement is used when traversing the tileset for rendering. This property is required for the root tile of a tileset; it is optional for all other tiles.
148
+ * The default is to inherit from the parent tile.
149
+ */
150
+ refine?: TILE_REFINEMENT | string;
151
+ /** An array of objects that define child tiles. */
152
+ children: Tiles3DTileJSONPostprocessed[];
153
+ };
154
+
155
+ /** Metadata about the tile's content and a link to the content. */
156
+ export type Tiles3DTileContentJSON = {
157
+ /** A uri that points to the tile's content. When the uri is relative, it is relative to the referring tileset JSON file. */
158
+ uri: string;
159
+ /** url doesn't allign the spec but we support it same way as uri */
160
+ url?: string;
161
+ /** A bounding volume that encloses a tile or its content. At least one bounding volume property is required. Bounding volumes include box, region, or sphere. */
162
+ boundingVolume?: Tile3DBoundingVolume;
163
+ /** Dictionary object with extension-specific objects. */
164
+ extensions?: object;
165
+ /** Application-specific data. */
166
+ extras?: any;
167
+ };
168
+
169
+ /** A bounding volume that encloses a tile or its content.
170
+ * https://github.com/CesiumGS/3d-tiles/tree/main/specification#bounding-volume
171
+ */
172
+ export type Tile3DBoundingVolume = {
173
+ /** An array of 12 numbers that define an oriented bounding box. The first three elements define the x, y, and z values for the center of the box.
174
+ * The next three elements (with indices 3, 4, and 5) define the x axis direction and half-length. The next three elements (indices 6, 7, and 8) define
175
+ * the y axis direction and half-length. The last three elements (indices 9, 10, and 11) define the z axis direction and half-length. */
49
176
  box?: number[];
177
+ /** An array of four numbers that define a bounding sphere. The first three elements define the x, y, and z values for the center of the sphere.
178
+ * The last element (with index 3) defines the radius in meters. */
50
179
  sphere?: number[];
180
+ /** An array of six numbers that define a bounding geographic region in EPSG:4979 coordinates with the order [west, south, east, north, minimum height, maximum height].
181
+ * Longitudes and latitudes are in radians, and heights are in meters above (or below) the WGS84 ellipsoid. */
51
182
  region?: number[];
183
+ /** Dictionary object with extension-specific objects. */
184
+ extensions?: object;
185
+ /** Application-specific data. */
186
+ extras?: any;
187
+ };
188
+
189
+ /**
190
+ * A dictionary object of metadata about per-feature properties.
191
+ * https://github.com/CesiumGS/3d-tiles/tree/main/specification#properties
192
+ */
193
+ export type TilesetProperty = {
194
+ /** The maximum value of this property of all the features in the tileset. */
195
+ maximum: number;
196
+ /** The minimum value of this property of all the features in the tileset. */
197
+ minimum: number;
198
+ /** Dictionary object with extension-specific objects. */
199
+ extensions?: object;
200
+ /** Application-specific data. */
201
+ extras?: any;
202
+ };
203
+
204
+ export type Tiles3DTileContent = {
205
+ /** Common properties */
206
+ byteOffset?: number;
207
+ type?: string;
208
+ featureIds?: null;
209
+
210
+ /** 3DTile header */
211
+ magic?: number;
212
+ version?: number;
213
+ byteLength?: number;
214
+
215
+ /** 3DTile tables header */
216
+ header?: {
217
+ featureTableJsonByteLength?: number;
218
+ featureTableBinaryByteLength?: number;
219
+ batchTableJsonByteLength?: number;
220
+ batchTableBinaryByteLength?: number;
221
+ batchLength?: number;
222
+ };
223
+
224
+ /** 3DTile tables */
225
+ featureTableJson?:
226
+ | {
227
+ BATCH_LENGTH?: number;
228
+ }
229
+ | Record<string, any>;
230
+ featureTableBinary?: Uint8Array;
231
+ batchTableJson?: Record<string, (string | number)[]>;
232
+ batchTableBinary?: Uint8Array;
233
+ rtcCenter?: number[];
234
+
235
+ /** 3DTile glTF */
236
+ gltfArrayBuffer?: ArrayBuffer;
237
+ gltfByteOffset?: number;
238
+ gltfByteLength?: number;
239
+ rotateYtoZ?: boolean;
240
+ gltfUpAxis?: 'x' | 'X' | 'y' | 'Y' | 'z' | 'Z';
241
+ gltfUrl?: string;
242
+ gpuMemoryUsageInBytes?: number;
243
+ gltf?: GLTFPostprocessed;
244
+
245
+ /** For Composite tiles */
246
+ tilesLength?: number;
247
+ tiles?: Tiles3DTileContent[];
248
+
249
+ /** For Instances model and Pointcloud tiles */
250
+ featuresLength?: number;
251
+
252
+ /** For Instanced model tiles */
253
+ gltfFormat?: number;
254
+ eastNorthUp?: boolean;
255
+ normalUp?: number[];
256
+ normalRight?: number[];
257
+ hasCustomOrientation?: boolean;
258
+ octNormalUp?: number[];
259
+ octNormalRight?: number[];
260
+ instances?: {
261
+ modelMatrix: Matrix4;
262
+ batchId: number;
263
+ }[];
264
+
265
+ /** For Pointcloud tiles */
266
+ attributes?: {
267
+ positions: null | number[];
268
+ colors:
269
+ | null
270
+ | number[]
271
+ | {type: number; value: Uint8ClampedArray; size: number; normalized: boolean};
272
+ normals: null | number[] | {type: number; size: number; value: Float32Array};
273
+ batchIds: null | number[];
274
+ };
275
+ constantRGBA?: number[];
276
+ isQuantized?: boolean;
277
+ isTranslucent?: boolean;
278
+ isRGB565?: boolean;
279
+ isOctEncoded16P?: boolean;
280
+ pointsLength?: number;
281
+ pointCount?: number;
282
+ batchIds?: number[];
283
+ hasPositions?: boolean;
284
+ hasColors?: boolean;
285
+ hasNormals?: boolean;
286
+ hasBatchIds?: boolean;
287
+ quantizedVolumeScale?: Vector3;
288
+ quantizedVolumeOffset?: Vector3;
289
+ quantizedRange?: number;
290
+ isQuantizedDraco?: boolean;
291
+ octEncodedRange?: number;
292
+ isOctEncodedDraco?: boolean;
52
293
  };
53
294
 
54
295
  /**
@@ -92,14 +333,27 @@ type BufferView = {
92
333
  /**
93
334
  * Spec - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling
94
335
  */
95
- export type ImplicitTilingExtension = {
96
- subdivisionScheme: 'QUADTREE' | 'OCTREE';
336
+ export type ImplicitTilingExensionData = ImplicitTilingData & {
97
337
  maximumLevel?: number;
98
- availableLevels: number;
99
- subtreeLevels: number;
100
- subtrees: SubtreeUri;
101
338
  };
102
339
 
103
- type SubtreeUri = {
104
- uri: string;
340
+ /** 3DTiles v1.1 types */
341
+
342
+ /**
343
+ * This object allows a tile to be implicitly subdivided. Tile and content availability and metadata is stored in subtrees which are referenced externally.
344
+ * https://github.com/CesiumGS/3d-tiles/blob/draft-1.1/specification/schema/tile.implicitTiling.schema.json
345
+ * */
346
+ type ImplicitTilingData = {
347
+ /** A string describing the subdivision scheme used within the tileset. */
348
+ subdivisionScheme: 'QUADTREE' | 'OCTREE' | string;
349
+ /** The number of distinct levels in each subtree. For example, a quadtree with `subtreeLevels = 2` will have subtrees with 5 nodes (one root and 4 children). */
350
+ subtreeLevels: number;
351
+ /** The numbers of the levels in the tree with available tiles. */
352
+ availableLevels: number;
353
+ /** An object describing the location of subtree files. */
354
+ subtrees: {
355
+ /** A template URI pointing to subtree files. A subtree is a fixed-depth (defined by `subtreeLevels`) portion of the tree to keep memory use bounded.
356
+ * The URI of each file is substituted with the subtree root's global level, x, and y. For subdivision scheme `OCTREE`, z shall also be given. Relative paths are relative to the tileset JSON. */
357
+ uri: string;
358
+ };
105
359
  };