@loaders.gl/gltf 4.0.0-beta.4 → 4.0.0-beta.6

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.
@@ -78,9 +78,9 @@ export class GLTFScenegraph {
78
78
  return data;
79
79
  }
80
80
 
81
- getExtraData(key: string): {[key: string]: unknown} {
81
+ getExtraData(key: string): unknown {
82
82
  // TODO - Data is already unpacked by GLBParser
83
- const extras = this.json.extras || {};
83
+ const extras = (this.json.extras || {}) as Record<string, unknown>;
84
84
  return extras[key];
85
85
  }
86
86
 
@@ -166,16 +166,16 @@ export class GLTFScenegraph {
166
166
  return this.getObject('buffers', index) as GLTFBuffer;
167
167
  }
168
168
 
169
- getObject(array: string, index: number | object): object {
169
+ getObject(array: string, index: number | object): Record<string, unknown> {
170
170
  // check if already resolved
171
171
  if (typeof index === 'object') {
172
- return index;
172
+ return index as Record<string, unknown>;
173
173
  }
174
174
  const object = this.json[array] && (this.json[array] as {}[])[index];
175
175
  if (!object) {
176
176
  throw new Error(`glTF file error: Could not find ${array}[${index}]`); // eslint-disable-line
177
177
  }
178
- return object;
178
+ return object as Record<string, unknown>;
179
179
  }
180
180
 
181
181
  /**
@@ -15,7 +15,6 @@ import type {
15
15
  GLTF_EXT_structural_metadata_Primitive
16
16
  } from '../types/gltf-ext-structural-metadata-schema';
17
17
  import type {GLTFLoaderOptions} from '../../gltf-loader';
18
- import type {FeatureTableJson} from '../types/gltf-types';
19
18
 
20
19
  import {GLTFScenegraph} from '../api/gltf-scenegraph';
21
20
  import {
@@ -38,52 +37,6 @@ export async function decode(gltfData: {json: GLTF}, options: GLTFLoaderOptions)
38
37
  decodeExtStructuralMetadata(scenegraph, options);
39
38
  }
40
39
 
41
- /**
42
- * Handles EXT_structural_metadata to get property table.
43
- * @param extension - Global level of EXT_STRUCTURAL_METADATA extension.
44
- * @param metadataClass - User selected feature metadata class name.
45
- * @returns {FeatureTableJson | null} Property table or null if the extension can't be handled properly.
46
- */
47
- export function getPropertyTableFromExtStructuralMetadata(
48
- extension: GLTF_EXT_structural_metadata_GLTF,
49
- metadataClass?: string
50
- ): FeatureTableJson | null {
51
- if (extension.propertyTables) {
52
- /**
53
- * Take only first feature table to generate attributes storage info object.
54
- * TODO: Think about getting data from all feature tables?
55
- * It can be tricky just because 3dTiles is able to have multiple featureId attributes and multiple feature tables.
56
- * In I3S we should decide which featureIds attribute will be passed to geometry data.
57
- */
58
- const firstPropertyTable = extension?.propertyTables[0];
59
- const propertyTableWithData = {};
60
-
61
- for (const propertyName in firstPropertyTable.properties) {
62
- propertyTableWithData[propertyName] = firstPropertyTable.properties[propertyName].data;
63
- }
64
-
65
- return propertyTableWithData;
66
- }
67
-
68
- if (extension.propertyTextures) {
69
- // TODO: Think about getting data from all property textures.
70
- const firstPropertyTexture = extension?.propertyTextures[0];
71
- const propertyTableWithData = {};
72
-
73
- for (const propertyName in firstPropertyTexture.properties) {
74
- propertyTableWithData[propertyName] = firstPropertyTexture.properties[propertyName].data;
75
- }
76
-
77
- return propertyTableWithData;
78
- }
79
-
80
- // eslint-disable-next-line no-console
81
- console.warn(
82
- 'Cannot get property table from EXT_structural_metadata extension. There is neither propertyTables, nor propertyTextures in the extension.'
83
- );
84
- return null;
85
- }
86
-
87
40
  /*
88
41
  // Example of the extension.
89
42
  // See more info at https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_structural_metadata
@@ -11,7 +11,6 @@ import type {
11
11
  GLTF_EXT_feature_metadata_Schema
12
12
  } from '../../types/gltf-ext-feature-metadata-schema';
13
13
  import type {BigTypedArray, TypedArray} from '@loaders.gl/schema';
14
- import type {FeatureTableJson} from '../../types/gltf-types';
15
14
  import {GLTFScenegraph} from '../../api/gltf-scenegraph';
16
15
  import {GLTFMeshPrimitive} from '../../types/gltf-json-schema';
17
16
  import {GLTFLoaderOptions} from '../../../gltf-loader';
@@ -36,65 +35,6 @@ export async function decode(gltfData: {json: GLTF}, options: GLTFLoaderOptions)
36
35
  decodeExtFeatureMetadata(scenegraph, options);
37
36
  }
38
37
 
39
- /**
40
- * Handles EXT_feature_metadata to get property table.
41
- * @param extension - Global level of EXT_FEATURE_METADATA extension.
42
- * @param metadataClass - User selected feature metadata class name.
43
- * @returns {FeatureTableJson | null} Property table or null if the extension can't be handled properly.
44
- */
45
- export function getPropertyTableFromExtFeatureMetadata(
46
- extension: GLTF_EXT_feature_metadata_GLTF,
47
- metadataClass?: string
48
- ): FeatureTableJson | null {
49
- if (extension.featureTables) {
50
- /**
51
- * Take only first feature table to generate attributes storage info object.
52
- * TODO: Think about getting data from all feature tables?
53
- * It can be tricky just because 3dTiles is able to have multiple featureId attributes and multiple feature tables.
54
- * In I3S we should decide which featureIds attribute will be passed to geometry data.
55
- */
56
- const firstFeatureTableName = Object.keys(extension.featureTables)?.[0];
57
-
58
- if (firstFeatureTableName) {
59
- const featureTable = extension.featureTables[firstFeatureTableName];
60
- const propertyTable = {};
61
-
62
- for (const propertyName in featureTable.properties) {
63
- propertyTable[propertyName] = featureTable.properties[propertyName].data;
64
- }
65
-
66
- return propertyTable;
67
- }
68
- }
69
-
70
- if (extension.featureTextures) {
71
- let featureTexture: string | undefined;
72
- for (const textureKey in extension.featureTextures) {
73
- const texture = extension.featureTextures[textureKey];
74
- if (texture.class === metadataClass) {
75
- featureTexture = textureKey;
76
- }
77
- }
78
-
79
- if (typeof featureTexture === 'string') {
80
- const featureTable = extension.featureTextures[featureTexture];
81
- const propertyTable = {};
82
-
83
- for (const propertyName in featureTable.properties) {
84
- propertyTable[propertyName] = featureTable.properties[propertyName].data;
85
- }
86
-
87
- return propertyTable;
88
- }
89
- }
90
-
91
- // eslint-disable-next-line no-console
92
- console.warn(
93
- 'Cannot get property table from EXT_feature_metadata extension. There is neither featureTables, nor featureTextures in the extension.'
94
- );
95
- return null;
96
- }
97
-
98
38
  /**
99
39
  * Decodes feature metadata from extension.
100
40
  * @param scenegraph - Instance of the class for structured access to GLTF data.
@@ -24,9 +24,8 @@ export type ParseGLTFOptions = ParseGLBOptions & {
24
24
  loadBuffers?: boolean;
25
25
  decompressMeshes?: boolean;
26
26
  excludeExtensions?: string[];
27
-
28
27
  /** @deprecated not supported in v4. `postProcessGLTF()` must be called by the application */
29
- postProcess?: false;
28
+ postProcess?: never;
30
29
  };
31
30
 
32
31
  /** Check if an array buffer appears to contain GLTF data */