@loaders.gl/gltf 4.0.0-beta.4 → 4.0.0-beta.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.
package/dist/dist.dev.js CHANGED
@@ -56,8 +56,6 @@ var __exports__ = (() => {
56
56
  GLTFScenegraph: () => GLTFScenegraph,
57
57
  GLTFWriter: () => GLTFWriter,
58
58
  _getMemoryUsageGLTF: () => getMemoryUsageGLTF,
59
- getPropertyTableFromExtFeatureMetadata: () => getPropertyTableFromExtFeatureMetadata,
60
- getPropertyTableFromExtStructuralMetadata: () => getPropertyTableFromExtStructuralMetadata,
61
59
  postProcessGLTF: () => postProcessGLTF
62
60
  });
63
61
 
@@ -2709,7 +2707,6 @@ var __exports__ = (() => {
2709
2707
  var EXT_structural_metadata_exports = {};
2710
2708
  __export(EXT_structural_metadata_exports, {
2711
2709
  decode: () => decode2,
2712
- getPropertyTableFromExtStructuralMetadata: () => getPropertyTableFromExtStructuralMetadata,
2713
2710
  name: () => name2
2714
2711
  });
2715
2712
  var EXT_STRUCTURAL_METADATA_NAME = "EXT_structural_metadata";
@@ -2718,26 +2715,6 @@ var __exports__ = (() => {
2718
2715
  const scenegraph = new GLTFScenegraph(gltfData);
2719
2716
  decodeExtStructuralMetadata(scenegraph, options);
2720
2717
  }
2721
- function getPropertyTableFromExtStructuralMetadata(extension, metadataClass) {
2722
- if (extension.propertyTables) {
2723
- const firstPropertyTable = extension?.propertyTables[0];
2724
- const propertyTableWithData = {};
2725
- for (const propertyName in firstPropertyTable.properties) {
2726
- propertyTableWithData[propertyName] = firstPropertyTable.properties[propertyName].data;
2727
- }
2728
- return propertyTableWithData;
2729
- }
2730
- if (extension.propertyTextures) {
2731
- const firstPropertyTexture = extension?.propertyTextures[0];
2732
- const propertyTableWithData = {};
2733
- for (const propertyName in firstPropertyTexture.properties) {
2734
- propertyTableWithData[propertyName] = firstPropertyTexture.properties[propertyName].data;
2735
- }
2736
- return propertyTableWithData;
2737
- }
2738
- console.warn("Cannot get property table from EXT_structural_metadata extension. There is neither propertyTables, nor propertyTextures in the extension.");
2739
- return null;
2740
- }
2741
2718
  function decodeExtStructuralMetadata(scenegraph, options) {
2742
2719
  if (!options.gltf?.loadBuffers) {
2743
2720
  return;
@@ -3006,7 +2983,6 @@ var __exports__ = (() => {
3006
2983
  var EXT_feature_metadata_exports = {};
3007
2984
  __export(EXT_feature_metadata_exports, {
3008
2985
  decode: () => decode3,
3009
- getPropertyTableFromExtFeatureMetadata: () => getPropertyTableFromExtFeatureMetadata,
3010
2986
  name: () => name3
3011
2987
  });
3012
2988
  var EXT_FEATURE_METADATA_NAME = "EXT_feature_metadata";
@@ -3015,38 +2991,6 @@ var __exports__ = (() => {
3015
2991
  const scenegraph = new GLTFScenegraph(gltfData);
3016
2992
  decodeExtFeatureMetadata(scenegraph, options);
3017
2993
  }
3018
- function getPropertyTableFromExtFeatureMetadata(extension, metadataClass) {
3019
- if (extension.featureTables) {
3020
- const firstFeatureTableName = Object.keys(extension.featureTables)?.[0];
3021
- if (firstFeatureTableName) {
3022
- const featureTable = extension.featureTables[firstFeatureTableName];
3023
- const propertyTable = {};
3024
- for (const propertyName in featureTable.properties) {
3025
- propertyTable[propertyName] = featureTable.properties[propertyName].data;
3026
- }
3027
- return propertyTable;
3028
- }
3029
- }
3030
- if (extension.featureTextures) {
3031
- let featureTexture;
3032
- for (const textureKey in extension.featureTextures) {
3033
- const texture = extension.featureTextures[textureKey];
3034
- if (texture.class === metadataClass) {
3035
- featureTexture = textureKey;
3036
- }
3037
- }
3038
- if (typeof featureTexture === "string") {
3039
- const featureTable = extension.featureTextures[featureTexture];
3040
- const propertyTable = {};
3041
- for (const propertyName in featureTable.properties) {
3042
- propertyTable[propertyName] = featureTable.properties[propertyName].data;
3043
- }
3044
- return propertyTable;
3045
- }
3046
- }
3047
- console.warn("Cannot get property table from EXT_feature_metadata extension. There is neither featureTables, nor featureTextures in the extension.");
3048
- return null;
3049
- }
3050
2994
  function decodeExtFeatureMetadata(scenegraph, options) {
3051
2995
  if (!options.gltf?.loadBuffers) {
3052
2996
  return;
package/dist/index.cjs CHANGED
@@ -29,8 +29,6 @@ __export(src_exports, {
29
29
  GLTFScenegraph: () => GLTFScenegraph,
30
30
  GLTFWriter: () => GLTFWriter,
31
31
  _getMemoryUsageGLTF: () => getMemoryUsageGLTF,
32
- getPropertyTableFromExtFeatureMetadata: () => getPropertyTableFromExtFeatureMetadata,
33
- getPropertyTableFromExtStructuralMetadata: () => getPropertyTableFromExtStructuralMetadata,
34
32
  postProcessGLTF: () => postProcessGLTF
35
33
  });
36
34
  module.exports = __toCommonJS(src_exports);
@@ -975,7 +973,6 @@ function processMeshPrimitiveFeatures(scenegraph, primitive, options) {
975
973
  var EXT_structural_metadata_exports = {};
976
974
  __export(EXT_structural_metadata_exports, {
977
975
  decode: () => decode2,
978
- getPropertyTableFromExtStructuralMetadata: () => getPropertyTableFromExtStructuralMetadata,
979
976
  name: () => name2
980
977
  });
981
978
  var EXT_STRUCTURAL_METADATA_NAME = "EXT_structural_metadata";
@@ -984,28 +981,6 @@ async function decode2(gltfData, options) {
984
981
  const scenegraph = new GLTFScenegraph(gltfData);
985
982
  decodeExtStructuralMetadata(scenegraph, options);
986
983
  }
987
- function getPropertyTableFromExtStructuralMetadata(extension, metadataClass) {
988
- if (extension.propertyTables) {
989
- const firstPropertyTable = extension == null ? void 0 : extension.propertyTables[0];
990
- const propertyTableWithData = {};
991
- for (const propertyName in firstPropertyTable.properties) {
992
- propertyTableWithData[propertyName] = firstPropertyTable.properties[propertyName].data;
993
- }
994
- return propertyTableWithData;
995
- }
996
- if (extension.propertyTextures) {
997
- const firstPropertyTexture = extension == null ? void 0 : extension.propertyTextures[0];
998
- const propertyTableWithData = {};
999
- for (const propertyName in firstPropertyTexture.properties) {
1000
- propertyTableWithData[propertyName] = firstPropertyTexture.properties[propertyName].data;
1001
- }
1002
- return propertyTableWithData;
1003
- }
1004
- console.warn(
1005
- "Cannot get property table from EXT_structural_metadata extension. There is neither propertyTables, nor propertyTextures in the extension."
1006
- );
1007
- return null;
1008
- }
1009
984
  function decodeExtStructuralMetadata(scenegraph, options) {
1010
985
  var _a, _b;
1011
986
  if (!((_a = options.gltf) == null ? void 0 : _a.loadBuffers)) {
@@ -1348,7 +1323,6 @@ function getEnumByValue(enumEntry, value) {
1348
1323
  var EXT_feature_metadata_exports = {};
1349
1324
  __export(EXT_feature_metadata_exports, {
1350
1325
  decode: () => decode3,
1351
- getPropertyTableFromExtFeatureMetadata: () => getPropertyTableFromExtFeatureMetadata,
1352
1326
  name: () => name3
1353
1327
  });
1354
1328
  var EXT_FEATURE_METADATA_NAME = "EXT_feature_metadata";
@@ -1357,41 +1331,6 @@ async function decode3(gltfData, options) {
1357
1331
  const scenegraph = new GLTFScenegraph(gltfData);
1358
1332
  decodeExtFeatureMetadata(scenegraph, options);
1359
1333
  }
1360
- function getPropertyTableFromExtFeatureMetadata(extension, metadataClass) {
1361
- var _a;
1362
- if (extension.featureTables) {
1363
- const firstFeatureTableName = (_a = Object.keys(extension.featureTables)) == null ? void 0 : _a[0];
1364
- if (firstFeatureTableName) {
1365
- const featureTable = extension.featureTables[firstFeatureTableName];
1366
- const propertyTable = {};
1367
- for (const propertyName in featureTable.properties) {
1368
- propertyTable[propertyName] = featureTable.properties[propertyName].data;
1369
- }
1370
- return propertyTable;
1371
- }
1372
- }
1373
- if (extension.featureTextures) {
1374
- let featureTexture;
1375
- for (const textureKey in extension.featureTextures) {
1376
- const texture = extension.featureTextures[textureKey];
1377
- if (texture.class === metadataClass) {
1378
- featureTexture = textureKey;
1379
- }
1380
- }
1381
- if (typeof featureTexture === "string") {
1382
- const featureTable = extension.featureTextures[featureTexture];
1383
- const propertyTable = {};
1384
- for (const propertyName in featureTable.properties) {
1385
- propertyTable[propertyName] = featureTable.properties[propertyName].data;
1386
- }
1387
- return propertyTable;
1388
- }
1389
- }
1390
- console.warn(
1391
- "Cannot get property table from EXT_feature_metadata extension. There is neither featureTables, nor featureTextures in the extension."
1392
- );
1393
- return null;
1394
- }
1395
1334
  function decodeExtFeatureMetadata(scenegraph, options) {
1396
1335
  var _a, _b;
1397
1336
  if (!((_a = options.gltf) == null ? void 0 : _a.loadBuffers)) {
package/dist/index.d.ts CHANGED
@@ -1,13 +1,11 @@
1
1
  export type { GLB } from './lib/types/glb-types';
2
2
  export type { GLTF, GLTFAccessor, GLTFBuffer, GLTFBufferView, GLTFMeshPrimitive, GLTFMesh, GLTFNode, GLTFMaterial, GLTFSampler, GLTFScene, GLTFSkin, GLTFTexture, GLTFImage, GLTFObject, GLTF_KHR_binary_glTF, GLTF_KHR_draco_mesh_compression, GLTF_KHR_texture_basisu, GLTF_EXT_meshopt_compression, GLTF_EXT_texture_webp } from './lib/types/gltf-json-schema';
3
3
  export type { GLTF_EXT_feature_metadata_GLTF, GLTF_EXT_feature_metadata_Schema, GLTF_EXT_feature_metadata_Class, GLTF_EXT_feature_metadata_ClassProperty, GLTF_EXT_feature_metadata_Enum, GLTF_EXT_feature_metadata_EnumValue, GLTF_EXT_feature_metadata_FeatureTable, GLTF_EXT_feature_metadata_FeatureTableProperty, GLTF_EXT_feature_metadata_FeatureTexture, GLTF_EXT_feature_metadata_TextureAccessor, GLTF_EXT_feature_metadata_Statistics, GLTF_EXT_feature_metadata_StatisticsClass, GLTF_EXT_feature_metadata_StatisticsClassProperty, GLTF_EXT_feature_metadata_Primitive, GLTF_EXT_feature_metadata_FeatureIdAttribute, GLTF_EXT_feature_metadata_FeatureIdAttributeFeatureIds, GLTF_EXT_feature_metadata_FeatureIdTexture, GLTF_EXT_feature_metadata_FeatureIdTextureAccessor } from './lib/types/gltf-ext-feature-metadata-schema';
4
- export type { GLTF_EXT_structural_metadata_GLTF } from './lib/types/gltf-ext-structural-metadata-schema';
4
+ export type { GLTF_EXT_structural_metadata_GLTF, GLTF_EXT_structural_metadata_Schema, GLTF_EXT_structural_metadata_PropertyTable, GLTF_EXT_structural_metadata_PropertyTexture, GLTF_EXT_structural_metadata_Class, GLTF_EXT_structural_metadata_ClassProperty } from './lib/types/gltf-ext-structural-metadata-schema';
5
5
  export type { GLTF_EXT_mesh_features, GLTF_EXT_mesh_features_featureId } from './lib/types/gltf-ext-mesh-features-schema';
6
6
  export { name as EXT_MESH_FEATURES } from './lib/extensions/EXT_mesh_features';
7
7
  export { name as EXT_STRUCTURAL_METADATA } from './lib/extensions/EXT_structural_metadata';
8
8
  export { name as EXT_FEATURE_METADATA } from './lib/extensions/deprecated/EXT_feature_metadata';
9
- export { getPropertyTableFromExtFeatureMetadata } from './lib/extensions/deprecated/EXT_feature_metadata';
10
- export { getPropertyTableFromExtStructuralMetadata } from './lib/extensions/EXT_structural_metadata';
11
9
  export type { GLTFPostprocessed, GLTFAccessorPostprocessed, GLTFNodePostprocessed, GLTFMaterialPostprocessed, GLTFMeshPostprocessed, GLTFMeshPrimitivePostprocessed, GLTFImagePostprocessed, GLTFTexturePostprocessed } from './lib/types/gltf-postprocessed-schema';
12
10
  export type { GLTFWithBuffers, FeatureTableJson } from './lib/types/gltf-types';
13
11
  export { GLTFLoader } from './gltf-loader';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAC,GAAG,EAAC,MAAM,uBAAuB,CAAC;AAG/C,YAAY,EACV,IAAI,EACJ,YAAY,EACZ,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,SAAS,EACT,QAAQ,EACR,WAAW,EACX,SAAS,EACT,UAAU,EAEV,oBAAoB,EACpB,+BAA+B,EAC/B,uBAAuB,EACvB,4BAA4B,EAC5B,qBAAqB,EACtB,MAAM,8BAA8B,CAAC;AAGtC,YAAY,EACV,8BAA8B,EAC9B,gCAAgC,EAChC,+BAA+B,EAC/B,uCAAuC,EACvC,8BAA8B,EAC9B,mCAAmC,EACnC,sCAAsC,EACtC,8CAA8C,EAC9C,wCAAw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C;AAE/C,YAAY,EAAC,eAAe,EAAE,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AAG9E,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AACzC,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAGzC,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAGvC,OAAO,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,kBAAkB,IAAI,mBAAmB,EAAC,MAAM,6BAA6B,CAAC;AAEtF,kBAAkB;AAElB,kBAAkB;AAElB,kBAAkB"}
package/dist/index.js CHANGED
@@ -1,8 +1,6 @@
1
1
  export { name as EXT_MESH_FEATURES } from "./lib/extensions/EXT_mesh_features.js";
2
2
  export { name as EXT_STRUCTURAL_METADATA } from "./lib/extensions/EXT_structural_metadata.js";
3
3
  export { name as EXT_FEATURE_METADATA } from "./lib/extensions/deprecated/EXT_feature_metadata.js";
4
- export { getPropertyTableFromExtFeatureMetadata } from "./lib/extensions/deprecated/EXT_feature_metadata.js";
5
- export { getPropertyTableFromExtStructuralMetadata } from "./lib/extensions/EXT_structural_metadata.js";
6
4
  export { GLTFLoader } from "./gltf-loader.js";
7
5
  export { GLTFWriter } from "./gltf-writer.js";
8
6
  export { GLBLoader } from "./glb-loader.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["name","EXT_MESH_FEATURES","EXT_STRUCTURAL_METADATA","EXT_FEATURE_METADATA","getPropertyTableFromExtFeatureMetadata","getPropertyTableFromExtStructuralMetadata","GLTFLoader","GLTFWriter","GLBLoader","GLBWriter","GLTFScenegraph","postProcessGLTF","getMemoryUsageGLTF","_getMemoryUsageGLTF"],"sources":["../src/index.ts"],"sourcesContent":["/* eslint-disable camelcase, indent */\nexport type {GLB} from './lib/types/glb-types';\n\n// Raw GLTF Types (i.e. not post-processed)\nexport type {\n GLTF,\n GLTFAccessor,\n GLTFBuffer,\n GLTFBufferView,\n GLTFMeshPrimitive,\n GLTFMesh,\n GLTFNode,\n GLTFMaterial,\n GLTFSampler,\n GLTFScene,\n GLTFSkin,\n GLTFTexture,\n GLTFImage,\n GLTFObject,\n // The following extensions are handled by the GLTFLoader and removed from the parsed glTF (disable via options.gltf.excludeExtensions)\n GLTF_KHR_binary_glTF,\n GLTF_KHR_draco_mesh_compression,\n GLTF_KHR_texture_basisu,\n GLTF_EXT_meshopt_compression,\n GLTF_EXT_texture_webp\n} from './lib/types/gltf-json-schema';\n\n// 3DTiles extensions\nexport type {\n GLTF_EXT_feature_metadata_GLTF,\n GLTF_EXT_feature_metadata_Schema,\n GLTF_EXT_feature_metadata_Class,\n GLTF_EXT_feature_metadata_ClassProperty,\n GLTF_EXT_feature_metadata_Enum,\n GLTF_EXT_feature_metadata_EnumValue,\n GLTF_EXT_feature_metadata_FeatureTable,\n GLTF_EXT_feature_metadata_FeatureTableProperty,\n GLTF_EXT_feature_metadata_FeatureTexture,\n GLTF_EXT_feature_metadata_TextureAccessor,\n GLTF_EXT_feature_metadata_Statistics,\n GLTF_EXT_feature_metadata_StatisticsClass,\n GLTF_EXT_feature_metadata_StatisticsClassProperty,\n GLTF_EXT_feature_metadata_Primitive,\n GLTF_EXT_feature_metadata_FeatureIdAttribute,\n GLTF_EXT_feature_metadata_FeatureIdAttributeFeatureIds,\n GLTF_EXT_feature_metadata_FeatureIdTexture,\n GLTF_EXT_feature_metadata_FeatureIdTextureAccessor\n} from './lib/types/gltf-ext-feature-metadata-schema';\n\nexport type {GLTF_EXT_structural_metadata_GLTF} from './lib/types/gltf-ext-structural-metadata-schema';\n\nexport type {\n GLTF_EXT_mesh_features,\n GLTF_EXT_mesh_features_featureId\n} from './lib/types/gltf-ext-mesh-features-schema';\n\nexport {name as EXT_MESH_FEATURES} from './lib/extensions/EXT_mesh_features';\nexport {name as EXT_STRUCTURAL_METADATA} from './lib/extensions/EXT_structural_metadata';\nexport {name as EXT_FEATURE_METADATA} from './lib/extensions/deprecated/EXT_feature_metadata';\nexport {getPropertyTableFromExtFeatureMetadata} from './lib/extensions/deprecated/EXT_feature_metadata';\nexport {getPropertyTableFromExtStructuralMetadata} from './lib/extensions/EXT_structural_metadata';\n\n// Postprocessed types (modified GLTF types)\nexport type {\n GLTFPostprocessed,\n GLTFAccessorPostprocessed,\n GLTFNodePostprocessed,\n GLTFMaterialPostprocessed,\n GLTFMeshPostprocessed,\n GLTFMeshPrimitivePostprocessed,\n GLTFImagePostprocessed,\n GLTFTexturePostprocessed\n} from './lib/types/gltf-postprocessed-schema';\n\nexport type {GLTFWithBuffers, FeatureTableJson} from './lib/types/gltf-types';\n\n// glTF loader/writer definition objects\nexport {GLTFLoader} from './gltf-loader';\nexport {GLTFWriter} from './gltf-writer';\n\n// GLB Loader & Writer (for custom formats that want to leverage the GLB binary \"envelope\")\nexport {GLBLoader} from './glb-loader';\nexport {GLBWriter} from './glb-writer';\n\n// glTF Data Access Helper Class\nexport {GLTFScenegraph} from './lib/api/gltf-scenegraph';\nexport {postProcessGLTF} from './lib/api/post-process-gltf';\nexport {getMemoryUsageGLTF as _getMemoryUsageGLTF} from './lib/gltf-utils/gltf-utils';\n\n/** @deprecated */\n// export type {GLTFMesh as Mesh} from './lib/types/gltf-json-schema';\n/** @deprecated */\n// export type {GLTFNodePostprocessed as Node} from './lib/types/gltf-postprocessed-schema';\n/** @deprecated */\n// export type {GLTFAccessorPostprocessed as Accessor} from './lib/types/gltf-postprocessed-schema';\n// /** @deprecated */\n// export type {GLTFImagePostprocessed as Image} from './lib/types/gltf-postprocessed-schema';\n"],"mappings":"SAwDQA,IAAI,IAAIC,iBAAiB;AAAA,SACzBD,IAAI,IAAIE,uBAAuB;AAAA,SAC/BF,IAAI,IAAIG,oBAAoB;AAAA,SAC5BC,sCAAsC;AAAA,SACtCC,yCAAyC;AAAA,SAiBzCC,UAAU;AAAA,SACVC,UAAU;AAAA,SAGVC,SAAS;AAAA,SACTC,SAAS;AAAA,SAGTC,cAAc;AAAA,SACdC,eAAe;AAAA,SACfC,kBAAkB,IAAIC,mBAAmB"}
1
+ {"version":3,"file":"index.js","names":["name","EXT_MESH_FEATURES","EXT_STRUCTURAL_METADATA","EXT_FEATURE_METADATA","GLTFLoader","GLTFWriter","GLBLoader","GLBWriter","GLTFScenegraph","postProcessGLTF","getMemoryUsageGLTF","_getMemoryUsageGLTF"],"sources":["../src/index.ts"],"sourcesContent":["/* eslint-disable camelcase, indent */\nexport type {GLB} from './lib/types/glb-types';\n\n// Raw GLTF Types (i.e. not post-processed)\nexport type {\n GLTF,\n GLTFAccessor,\n GLTFBuffer,\n GLTFBufferView,\n GLTFMeshPrimitive,\n GLTFMesh,\n GLTFNode,\n GLTFMaterial,\n GLTFSampler,\n GLTFScene,\n GLTFSkin,\n GLTFTexture,\n GLTFImage,\n GLTFObject,\n // The following extensions are handled by the GLTFLoader and removed from the parsed glTF (disable via options.gltf.excludeExtensions)\n GLTF_KHR_binary_glTF,\n GLTF_KHR_draco_mesh_compression,\n GLTF_KHR_texture_basisu,\n GLTF_EXT_meshopt_compression,\n GLTF_EXT_texture_webp\n} from './lib/types/gltf-json-schema';\n\n// 3DTiles extensions\nexport type {\n GLTF_EXT_feature_metadata_GLTF,\n GLTF_EXT_feature_metadata_Schema,\n GLTF_EXT_feature_metadata_Class,\n GLTF_EXT_feature_metadata_ClassProperty,\n GLTF_EXT_feature_metadata_Enum,\n GLTF_EXT_feature_metadata_EnumValue,\n GLTF_EXT_feature_metadata_FeatureTable,\n GLTF_EXT_feature_metadata_FeatureTableProperty,\n GLTF_EXT_feature_metadata_FeatureTexture,\n GLTF_EXT_feature_metadata_TextureAccessor,\n GLTF_EXT_feature_metadata_Statistics,\n GLTF_EXT_feature_metadata_StatisticsClass,\n GLTF_EXT_feature_metadata_StatisticsClassProperty,\n GLTF_EXT_feature_metadata_Primitive,\n GLTF_EXT_feature_metadata_FeatureIdAttribute,\n GLTF_EXT_feature_metadata_FeatureIdAttributeFeatureIds,\n GLTF_EXT_feature_metadata_FeatureIdTexture,\n GLTF_EXT_feature_metadata_FeatureIdTextureAccessor\n} from './lib/types/gltf-ext-feature-metadata-schema';\n\nexport type {\n GLTF_EXT_structural_metadata_GLTF,\n GLTF_EXT_structural_metadata_Schema,\n GLTF_EXT_structural_metadata_PropertyTable,\n GLTF_EXT_structural_metadata_PropertyTexture,\n GLTF_EXT_structural_metadata_Class,\n GLTF_EXT_structural_metadata_ClassProperty\n} from './lib/types/gltf-ext-structural-metadata-schema';\n\nexport type {\n GLTF_EXT_mesh_features,\n GLTF_EXT_mesh_features_featureId\n} from './lib/types/gltf-ext-mesh-features-schema';\n\nexport {name as EXT_MESH_FEATURES} from './lib/extensions/EXT_mesh_features';\nexport {name as EXT_STRUCTURAL_METADATA} from './lib/extensions/EXT_structural_metadata';\nexport {name as EXT_FEATURE_METADATA} from './lib/extensions/deprecated/EXT_feature_metadata';\n\n// Postprocessed types (modified GLTF types)\nexport type {\n GLTFPostprocessed,\n GLTFAccessorPostprocessed,\n GLTFNodePostprocessed,\n GLTFMaterialPostprocessed,\n GLTFMeshPostprocessed,\n GLTFMeshPrimitivePostprocessed,\n GLTFImagePostprocessed,\n GLTFTexturePostprocessed\n} from './lib/types/gltf-postprocessed-schema';\n\nexport type {GLTFWithBuffers, FeatureTableJson} from './lib/types/gltf-types';\n\n// glTF loader/writer definition objects\nexport {GLTFLoader} from './gltf-loader';\nexport {GLTFWriter} from './gltf-writer';\n\n// GLB Loader & Writer (for custom formats that want to leverage the GLB binary \"envelope\")\nexport {GLBLoader} from './glb-loader';\nexport {GLBWriter} from './glb-writer';\n\n// glTF Data Access Helper Class\nexport {GLTFScenegraph} from './lib/api/gltf-scenegraph';\nexport {postProcessGLTF} from './lib/api/post-process-gltf';\nexport {getMemoryUsageGLTF as _getMemoryUsageGLTF} from './lib/gltf-utils/gltf-utils';\n\n/** @deprecated */\n// export type {GLTFMesh as Mesh} from './lib/types/gltf-json-schema';\n/** @deprecated */\n// export type {GLTFNodePostprocessed as Node} from './lib/types/gltf-postprocessed-schema';\n/** @deprecated */\n// export type {GLTFAccessorPostprocessed as Accessor} from './lib/types/gltf-postprocessed-schema';\n// /** @deprecated */\n// export type {GLTFImagePostprocessed as Image} from './lib/types/gltf-postprocessed-schema';\n"],"mappings":"SA+DQA,IAAI,IAAIC,iBAAiB;AAAA,SACzBD,IAAI,IAAIE,uBAAuB;AAAA,SAC/BF,IAAI,IAAIG,oBAAoB;AAAA,SAiB5BC,UAAU;AAAA,SACVC,UAAU;AAAA,SAGVC,SAAS;AAAA,SACTC,SAAS;AAAA,SAGTC,cAAc;AAAA,SACdC,eAAe;AAAA,SACfC,kBAAkB,IAAIC,mBAAmB"}
@@ -17,9 +17,7 @@ export declare class GLTFScenegraph {
17
17
  });
18
18
  get json(): GLTF;
19
19
  getApplicationData(key: string): unknown;
20
- getExtraData(key: string): {
21
- [key: string]: unknown;
22
- };
20
+ getExtraData(key: string): unknown;
23
21
  hasExtension(extensionName: string): boolean;
24
22
  getExtension<T = Extension>(extensionName: string): T | null;
25
23
  getRequiredExtension<T = Extension>(extensionName: string): T | null;
@@ -40,7 +38,7 @@ export declare class GLTFScenegraph {
40
38
  getImage(index: number): GLTFImage;
41
39
  getBufferView(index: number | object): GLTFBufferView;
42
40
  getBuffer(index: number): GLTFBuffer;
43
- getObject(array: string, index: number | object): object;
41
+ getObject(array: string, index: number | object): Record<string, unknown>;
44
42
  /**
45
43
  * Accepts buffer view index or buffer view object
46
44
  * @returns a `Uint8Array`
@@ -1 +1 @@
1
- {"version":3,"file":"gltf-scenegraph.d.ts","sourceRoot":"","sources":["../../../src/lib/api/gltf-scenegraph.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EACV,IAAI,EACJ,SAAS,EACT,QAAQ,EAC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AA,EAAE,IAAI,KAAA;;;;CAmChC"}
@@ -1 +1 @@
1
- {"version":3,"file":"gltf-scenegraph.js","names":["getBinaryImageMetadata","padToNBytes","copyToArray","assert","getAccessorTypeFromSize","getComponentTypeFromArray","getTypedArrayForAccessor","_getTypedArrayForAccessor","makeDefaultGLTFJson","asset","version","generator","buffers","extensions","extensionsRequired","extensionsUsed","GLTFScenegraph","constructor","gltf","sourceBuffers","byteLength","json","images","getApplicationData","key","data","getExtraData","extras","hasExtension","extensionName","isUsedExtension","getUsedExtensions","find","name","isRequiredExtension","getRequiredExtensions","getExtension","isExtension","getRequiredExtension","isRequired","getRemovedExtensions","extensionsRemoved","getObjectExtension","object","getScene","index","getObject","getNode","getSkin","getMesh","getMaterial","getAccessor","getTexture","getSampler","getImage","getBufferView","getBuffer","array","Error","getTypedArrayForBufferView","bufferView","bufferIndex","buffer","binChunk","byteOffset","Uint8Array","arrayBuffer","accessor","gltfAccessor","getTypedArrayForImageData","image","addApplicationData","addExtraData","addObjectExtension","registerUsedExtension","setObjectExtension","removeObjectExtension","includes","push","addExtension","extensionData","arguments","length","undefined","addRequiredExtension","registerRequiredExtension","ext","removeExtension","_this$json$extensions","_removeStringFromArray","setDefaultScene","sceneIndex","scene","addScene","nodeIndices","scenes","nodes","addNode","node","meshIndex","matrix","nodeData","mesh","addMesh","attributes","indices","material","mode","accessors","_addAttributes","glTFMesh","primitives","indicesAccessor","_addIndices","Number","isFinite","meshes","addPointCloud","accessorIndices","addImage","imageData","mimeTypeOpt","metadata","mimeType","bufferViewIndex","addBufferView","glTFImage","glTFBufferView","bufferViews","addAccessor","glTFAccessor","type","size","componentType","count","max","min","addBinaryBuffer","sourceBuffer","minMax","_getAccessorMinMax","accessorDefaults","Math","round","Object","assign","addTexture","texture","imageIndex","glTFTexture","source","textures","addMaterial","pbrMaterialInfo","materials","createBinaryChunk","_this$json","_this$json$buffers","totalByteLength","ArrayBuffer","targetArray","dstByteOffset","binary","string","found","indexOf","splice","result","attributeKey","attributeData","attrName","_getGltfAttributeName","value","attributeName","toLowerCase","initValues","subarray","componentIndex"],"sources":["../../../src/lib/api/gltf-scenegraph.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {GLTFWithBuffers} from '../types/gltf-types';\nimport type {\n GLTF,\n GLTFScene,\n GLTFNode,\n GLTFMesh,\n GLTFSkin,\n GLTFMaterial,\n GLTFAccessor,\n GLTFSampler,\n GLTFTexture,\n GLTFImage,\n GLTFBuffer,\n GLTFBufferView\n} from '../types/gltf-json-schema';\n\nimport {getBinaryImageMetadata} from '@loaders.gl/images';\nimport {padToNBytes, copyToArray} from '@loaders.gl/loader-utils';\nimport {assert} from '../utils/assert';\nimport {getAccessorTypeFromSize, getComponentTypeFromArray} from '../gltf-utils/gltf-utils';\n\nimport {getTypedArrayForAccessor as _getTypedArrayForAccessor} from '../gltf-utils/get-typed-array';\n\ntype Extension = {[key: string]: any};\n\nfunction makeDefaultGLTFJson(): GLTF {\n return {\n asset: {\n version: '2.0',\n generator: 'loaders.gl'\n },\n buffers: [],\n extensions: {},\n extensionsRequired: [],\n extensionsUsed: []\n };\n}\n\n/**\n * Class for structured access to GLTF data\n */\nexport class GLTFScenegraph {\n // internal\n gltf: GLTFWithBuffers;\n sourceBuffers: any[];\n byteLength: number;\n\n // TODO - why is this not GLTFWithBuffers - what happens to images?\n constructor(gltf?: {json: GLTF; buffers?: any[]; images?: any[]}) {\n // Declare locally so\n\n this.gltf = {\n json: gltf?.json || makeDefaultGLTFJson(),\n buffers: gltf?.buffers || [],\n images: gltf?.images || []\n };\n this.sourceBuffers = [];\n this.byteLength = 0;\n\n // Initialize buffers\n if (this.gltf.buffers && this.gltf.buffers[0]) {\n this.byteLength = this.gltf.buffers[0].byteLength;\n this.sourceBuffers = [this.gltf.buffers[0]];\n }\n }\n\n // Accessors\n\n get json(): GLTF {\n return this.gltf.json;\n }\n\n getApplicationData(key: string): unknown {\n // TODO - Data is already unpacked by GLBParser\n const data = this.json[key];\n return data;\n }\n\n getExtraData(key: string): {[key: string]: unknown} {\n // TODO - Data is already unpacked by GLBParser\n const extras = this.json.extras || {};\n return extras[key];\n }\n\n hasExtension(extensionName: string): boolean {\n const isUsedExtension = this.getUsedExtensions().find((name) => name === extensionName);\n const isRequiredExtension = this.getRequiredExtensions().find((name) => name === extensionName);\n return typeof isUsedExtension === 'string' || typeof isRequiredExtension === 'string';\n }\n\n getExtension<T = Extension>(extensionName: string): T | null {\n const isExtension = this.getUsedExtensions().find((name) => name === extensionName);\n const extensions = this.json.extensions || {};\n return isExtension ? (extensions[extensionName] as T) : null;\n }\n\n getRequiredExtension<T = Extension>(extensionName: string): T | null {\n const isRequired = this.getRequiredExtensions().find((name) => name === extensionName);\n return isRequired ? this.getExtension(extensionName) : null;\n }\n\n getRequiredExtensions(): string[] {\n return this.json.extensionsRequired || [];\n }\n\n getUsedExtensions(): string[] {\n return this.json.extensionsUsed || [];\n }\n\n getRemovedExtensions(): string[] {\n return (this.json.extensionsRemoved || []) as string[];\n }\n\n getObjectExtension<T = Extension>(object: {[key: string]: any}, extensionName: string): T | null {\n const extensions = object.extensions || {};\n return extensions[extensionName];\n }\n\n getScene(index: number): GLTFScene {\n return this.getObject('scenes', index) as GLTFScene;\n }\n\n getNode(index: number): GLTFNode {\n return this.getObject('nodes', index) as GLTFNode;\n }\n\n getSkin(index: number): GLTFSkin {\n return this.getObject('skins', index) as GLTFSkin;\n }\n\n getMesh(index: number): GLTFMesh {\n return this.getObject('meshes', index) as GLTFMesh;\n }\n\n getMaterial(index: number): GLTFMaterial {\n return this.getObject('materials', index) as GLTFMaterial;\n }\n\n getAccessor(index: number): GLTFAccessor {\n return this.getObject('accessors', index) as GLTFAccessor;\n }\n\n // getCamera(index: number): object | null {\n // return null; // TODO: fix thi: object as null;\n // }\n\n getTexture(index: number): GLTFTexture {\n return this.getObject('textures', index) as GLTFTexture;\n }\n\n getSampler(index: number): GLTFSampler {\n return this.getObject('samplers', index) as GLTFSampler;\n }\n\n getImage(index: number): GLTFImage {\n return this.getObject('images', index) as GLTFImage;\n }\n\n getBufferView(index: number | object): GLTFBufferView {\n return this.getObject('bufferViews', index) as GLTFBufferView;\n }\n\n getBuffer(index: number): GLTFBuffer {\n return this.getObject('buffers', index) as GLTFBuffer;\n }\n\n getObject(array: string, index: number | object): object {\n // check if already resolved\n if (typeof index === 'object') {\n return index;\n }\n const object = this.json[array] && (this.json[array] as {}[])[index];\n if (!object) {\n throw new Error(`glTF file error: Could not find ${array}[${index}]`); // eslint-disable-line\n }\n return object;\n }\n\n /**\n * Accepts buffer view index or buffer view object\n * @returns a `Uint8Array`\n */\n getTypedArrayForBufferView(bufferView: number | object): Uint8Array {\n bufferView = this.getBufferView(bufferView);\n // @ts-ignore\n const bufferIndex = bufferView.buffer;\n\n // Get hold of the arrayBuffer\n // const buffer = this.getBuffer(bufferIndex);\n const binChunk = this.gltf.buffers[bufferIndex];\n assert(binChunk);\n\n // @ts-ignore\n const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;\n // @ts-ignore\n return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);\n }\n\n /** Accepts accessor index or accessor object\n * @returns a typed array with type that matches the types\n */\n getTypedArrayForAccessor(accessor: number | object): any {\n // @ts-ignore\n const gltfAccessor = this.getAccessor(accessor);\n return _getTypedArrayForAccessor(this.gltf.json, this.gltf.buffers, gltfAccessor);\n }\n\n /** accepts accessor index or accessor object\n * returns a `Uint8Array`\n */\n getTypedArrayForImageData(image: number | object): Uint8Array {\n // @ts-ignore\n image = this.getAccessor(image);\n // @ts-ignore\n const bufferView = this.getBufferView(image.bufferView);\n const buffer = this.getBuffer(bufferView.buffer);\n // @ts-ignore\n const arrayBuffer = buffer.data;\n\n const byteOffset = bufferView.byteOffset || 0;\n return new Uint8Array(arrayBuffer, byteOffset, bufferView.byteLength);\n }\n\n // MODIFERS\n\n /**\n * Add an extra application-defined key to the top-level data structure\n */\n addApplicationData(key: string, data: object): GLTFScenegraph {\n this.json[key] = data;\n return this;\n }\n\n /**\n * `extras` - Standard GLTF field for storing application specific data\n */\n addExtraData(key: string, data: object): GLTFScenegraph {\n this.json.extras = this.json.extras || {};\n (this.json.extras as Record<string, unknown>)[key] = data;\n return this;\n }\n\n addObjectExtension(object: object, extensionName: string, data: object): GLTFScenegraph {\n // @ts-ignore\n object.extensions = object.extensions || {};\n // TODO - clobber or merge?\n // @ts-ignore\n object.extensions[extensionName] = data;\n this.registerUsedExtension(extensionName);\n return this;\n }\n\n setObjectExtension(object: any, extensionName: string, data: object): void {\n const extensions = object.extensions || {};\n extensions[extensionName] = data;\n // TODO - add to usedExtensions...\n }\n\n removeObjectExtension(object: any, extensionName: string): void {\n const extensions = object?.extensions || {};\n\n if (extensions[extensionName]) {\n this.json.extensionsRemoved = this.json.extensionsRemoved || [];\n const extensionsRemoved = this.json.extensionsRemoved as string[];\n if (!extensionsRemoved.includes(extensionName)) {\n extensionsRemoved.push(extensionName);\n }\n }\n\n delete extensions[extensionName];\n }\n\n /**\n * Add to standard GLTF top level extension object, mark as used\n */\n addExtension(extensionName: string, extensionData: object = {}): object {\n assert(extensionData);\n this.json.extensions = this.json.extensions || {};\n this.json.extensions[extensionName] = extensionData;\n this.registerUsedExtension(extensionName);\n return extensionData;\n }\n\n /**\n * Standard GLTF top level extension object, mark as used and required\n */\n addRequiredExtension(extensionName, extensionData: object = {}): object {\n assert(extensionData);\n this.addExtension(extensionName, extensionData);\n this.registerRequiredExtension(extensionName);\n return extensionData;\n }\n\n /**\n * Add extensionName to list of used extensions\n */\n registerUsedExtension(extensionName: string): void {\n this.json.extensionsUsed = this.json.extensionsUsed || [];\n if (!this.json.extensionsUsed.find((ext) => ext === extensionName)) {\n this.json.extensionsUsed.push(extensionName);\n }\n }\n\n /**\n * Add extensionName to list of required extensions\n */\n registerRequiredExtension(extensionName: string): void {\n this.registerUsedExtension(extensionName);\n this.json.extensionsRequired = this.json.extensionsRequired || [];\n if (!this.json.extensionsRequired.find((ext) => ext === extensionName)) {\n this.json.extensionsRequired.push(extensionName);\n }\n }\n\n /**\n * Removes an extension from the top-level list\n */\n removeExtension(extensionName: string): void {\n if (this.json.extensions?.[extensionName]) {\n this.json.extensionsRemoved = this.json.extensionsRemoved || [];\n const extensionsRemoved = this.json.extensionsRemoved as string[];\n if (!extensionsRemoved.includes(extensionName)) {\n extensionsRemoved.push(extensionName);\n }\n }\n if (this.json.extensions) {\n delete this.json.extensions[extensionName];\n }\n if (this.json.extensionsRequired) {\n this._removeStringFromArray(this.json.extensionsRequired, extensionName);\n }\n if (this.json.extensionsUsed) {\n this._removeStringFromArray(this.json.extensionsUsed, extensionName);\n }\n }\n\n /**\n * Set default scene which is to be displayed at load time\n */\n setDefaultScene(sceneIndex: number): void {\n this.json.scene = sceneIndex;\n }\n\n /**\n * @todo: add more properties for scene initialization:\n * name`, `extensions`, `extras`\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-scene\n */\n addScene(scene: {nodeIndices: number[]}): number {\n const {nodeIndices} = scene;\n this.json.scenes = this.json.scenes || [];\n this.json.scenes.push({nodes: nodeIndices});\n return this.json.scenes.length - 1;\n }\n\n /**\n * @todo: add more properties for node initialization:\n * `name`, `extensions`, `extras`, `camera`, `children`, `skin`, `rotation`, `scale`, `translation`, `weights`\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#node\n */\n addNode(node: {meshIndex: number; matrix?: number[]}): number {\n const {meshIndex, matrix} = node;\n this.json.nodes = this.json.nodes || [];\n const nodeData = {mesh: meshIndex};\n if (matrix) {\n // @ts-ignore\n nodeData.matrix = matrix;\n }\n this.json.nodes.push(nodeData);\n return this.json.nodes.length - 1;\n }\n\n /** Adds a mesh to the json part */\n addMesh(mesh: {attributes: object; indices?: object; material?: number; mode?: number}): number {\n const {attributes, indices, material, mode = 4} = mesh;\n const accessors = this._addAttributes(attributes);\n\n const glTFMesh = {\n primitives: [\n {\n attributes: accessors,\n mode\n }\n ]\n };\n\n if (indices) {\n const indicesAccessor = this._addIndices(indices);\n // @ts-ignore\n glTFMesh.primitives[0].indices = indicesAccessor;\n }\n\n if (Number.isFinite(material)) {\n // @ts-ignore\n glTFMesh.primitives[0].material = material;\n }\n\n this.json.meshes = this.json.meshes || [];\n this.json.meshes.push(glTFMesh);\n return this.json.meshes.length - 1;\n }\n\n addPointCloud(attributes: object): number {\n // @ts-ignore\n const accessorIndices = this._addAttributes(attributes);\n\n const glTFMesh = {\n primitives: [\n {\n attributes: accessorIndices,\n mode: 0 // GL.POINTS\n }\n ]\n };\n\n this.json.meshes = this.json.meshes || [];\n this.json.meshes.push(glTFMesh);\n return this.json.meshes.length - 1;\n }\n\n /**\n * Adds a binary image. Builds glTF \"JSON metadata\" and saves buffer reference\n * Buffer will be copied into BIN chunk during \"pack\"\n * Currently encodes as glTF image\n * @param imageData\n * @param mimeType\n */\n addImage(imageData: any, mimeTypeOpt?: string): number {\n // If image is referencing a bufferView instead of URI, mimeType must be defined:\n // https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#images\n // \"a reference to a bufferView; in that case mimeType must be defined.\"\n const metadata = getBinaryImageMetadata(imageData);\n const mimeType = mimeTypeOpt || metadata?.mimeType;\n\n const bufferViewIndex = this.addBufferView(imageData);\n\n const glTFImage = {\n bufferView: bufferViewIndex,\n mimeType\n };\n\n this.json.images = this.json.images || [];\n this.json.images.push(glTFImage);\n return this.json.images.length - 1;\n }\n\n /**\n * Add one untyped source buffer, create a matching glTF `bufferView`, and return its index\n * @param buffer\n */\n addBufferView(buffer: any, bufferIndex = 0, byteOffset = this.byteLength): number {\n const byteLength = buffer.byteLength;\n assert(Number.isFinite(byteLength));\n\n // Add this buffer to the list of buffers to be written to the body.\n this.sourceBuffers = this.sourceBuffers || [];\n this.sourceBuffers.push(buffer);\n\n const glTFBufferView = {\n buffer: bufferIndex,\n // Write offset from the start of the binary body\n byteOffset,\n byteLength\n };\n\n // We've now added the contents to the body, so update the total length\n // Every sub-chunk needs to be 4-byte align ed\n this.byteLength += padToNBytes(byteLength, 4);\n\n // Add a bufferView indicating start and length of this binary sub-chunk\n this.json.bufferViews = this.json.bufferViews || [];\n this.json.bufferViews.push(glTFBufferView);\n return this.json.bufferViews.length - 1;\n }\n\n /**\n * Adds an accessor to a bufferView\n * @param bufferViewIndex\n * @param accessor\n */\n addAccessor(bufferViewIndex: number, accessor: object): number {\n const glTFAccessor = {\n bufferView: bufferViewIndex,\n // @ts-ignore\n type: getAccessorTypeFromSize(accessor.size),\n // @ts-ignore\n componentType: accessor.componentType,\n // @ts-ignore\n count: accessor.count,\n // @ts-ignore\n max: accessor.max,\n // @ts-ignore\n min: accessor.min\n };\n\n this.json.accessors = this.json.accessors || [];\n this.json.accessors.push(glTFAccessor);\n return this.json.accessors.length - 1;\n }\n\n /**\n * Add a binary buffer. Builds glTF \"JSON metadata\" and saves buffer reference\n * Buffer will be copied into BIN chunk during \"pack\"\n * Currently encodes buffers as glTF accessors, but this could be optimized\n * @param sourceBuffer\n * @param accessor\n */\n addBinaryBuffer(sourceBuffer: any, accessor: object = {size: 3}): number {\n const bufferViewIndex = this.addBufferView(sourceBuffer);\n // @ts-ignore\n let minMax = {min: accessor.min, max: accessor.max};\n if (!minMax.min || !minMax.max) {\n // @ts-ignore\n minMax = this._getAccessorMinMax(sourceBuffer, accessor.size);\n }\n\n const accessorDefaults = {\n // @ts-ignore\n size: accessor.size,\n componentType: getComponentTypeFromArray(sourceBuffer),\n // @ts-ignore\n count: Math.round(sourceBuffer.length / accessor.size),\n min: minMax.min,\n max: minMax.max\n };\n\n return this.addAccessor(bufferViewIndex, Object.assign(accessorDefaults, accessor));\n }\n\n /**\n * Adds a texture to the json part\n * @todo: add more properties for texture initialization\n * `sampler`, `name`, `extensions`, `extras`\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#texture\n */\n addTexture(texture: {imageIndex: number}): number {\n const {imageIndex} = texture;\n const glTFTexture = {\n source: imageIndex\n };\n\n this.json.textures = this.json.textures || [];\n this.json.textures.push(glTFTexture);\n return this.json.textures.length - 1;\n }\n\n /** Adds a material to the json part */\n addMaterial(pbrMaterialInfo: Object): number {\n this.json.materials = this.json.materials || [];\n this.json.materials.push(pbrMaterialInfo);\n return this.json.materials.length - 1;\n }\n\n /** Pack the binary chunk */\n createBinaryChunk(): void {\n // Encoder expects this array undefined or empty\n this.gltf.buffers = [];\n\n // Allocate total array\n const totalByteLength = this.byteLength;\n const arrayBuffer = new ArrayBuffer(totalByteLength);\n const targetArray = new Uint8Array(arrayBuffer);\n\n // Copy each array into\n let dstByteOffset = 0;\n for (const sourceBuffer of this.sourceBuffers || []) {\n dstByteOffset = copyToArray(sourceBuffer, targetArray, dstByteOffset);\n }\n\n // Update the glTF BIN CHUNK byte length\n if (this.json?.buffers?.[0]) {\n this.json.buffers[0].byteLength = totalByteLength;\n } else {\n this.json.buffers = [{byteLength: totalByteLength}];\n }\n\n // Save generated arrayBuffer\n this.gltf.binary = arrayBuffer;\n\n // Put arrayBuffer to sourceBuffers for possible additional writing data in the chunk\n this.sourceBuffers = [arrayBuffer];\n }\n\n // PRIVATE\n\n _removeStringFromArray(array, string) {\n let found = true;\n while (found) {\n const index = array.indexOf(string);\n if (index > -1) {\n array.splice(index, 1);\n } else {\n found = false;\n }\n }\n }\n\n /**\n * Add attributes to buffers and create `attributes` object which is part of `mesh`\n */\n _addAttributes(attributes = {}) {\n const result = {};\n for (const attributeKey in attributes) {\n const attributeData = attributes[attributeKey];\n const attrName = this._getGltfAttributeName(attributeKey);\n const accessor = this.addBinaryBuffer(attributeData.value, attributeData);\n result[attrName] = accessor;\n }\n return result;\n }\n\n /**\n * Add indices to buffers\n */\n _addIndices(indices) {\n return this.addBinaryBuffer(indices, {size: 1});\n }\n\n /**\n * Deduce gltf specific attribue name from input attribute name\n */\n _getGltfAttributeName(attributeName) {\n switch (attributeName.toLowerCase()) {\n case 'position':\n case 'positions':\n case 'vertices':\n return 'POSITION';\n case 'normal':\n case 'normals':\n return 'NORMAL';\n case 'color':\n case 'colors':\n return 'COLOR_0';\n case 'texcoord':\n case 'texcoords':\n return 'TEXCOORD_0';\n default:\n return attributeName;\n }\n }\n\n /**\n * Calculate `min` and `max` arrays of accessor according to spec:\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-accessor\n */\n _getAccessorMinMax(buffer, size) {\n const result = {min: null, max: null};\n if (buffer.length < size) {\n return result;\n }\n // @ts-ignore\n result.min = [];\n // @ts-ignore\n result.max = [];\n const initValues = buffer.subarray(0, size);\n for (const value of initValues) {\n // @ts-ignore\n result.min.push(value);\n // @ts-ignore\n result.max.push(value);\n }\n\n for (let index = size; index < buffer.length; index += size) {\n for (let componentIndex = 0; componentIndex < size; componentIndex++) {\n // @ts-ignore\n result.min[0 + componentIndex] = Math.min(\n // @ts-ignore\n result.min[0 + componentIndex],\n buffer[index + componentIndex]\n );\n // @ts-ignore\n result.max[0 + componentIndex] = Math.max(\n // @ts-ignore\n result.max[0 + componentIndex],\n buffer[index + componentIndex]\n );\n }\n }\n return result;\n }\n}\n"],"mappings":"AAkBA,SAAQA,sBAAsB,QAAO,oBAAoB;AACzD,SAAQC,WAAW,EAAEC,WAAW,QAAO,0BAA0B;AAAC,SAC1DC,MAAM;AAAA,SACNC,uBAAuB,EAAEC,yBAAyB;AAAA,SAElDC,wBAAwB,IAAIC,yBAAyB;AAI7D,SAASC,mBAAmBA,CAAA,EAAS;EACnC,OAAO;IACLC,KAAK,EAAE;MACLC,OAAO,EAAE,KAAK;MACdC,SAAS,EAAE;IACb,CAAC;IACDC,OAAO,EAAE,EAAE;IACXC,UAAU,EAAE,CAAC,CAAC;IACdC,kBAAkB,EAAE,EAAE;IACtBC,cAAc,EAAE;EAClB,CAAC;AACH;AAKA,OAAO,MAAMC,cAAc,CAAC;EAO1BC,WAAWA,CAACC,IAAoD,EAAE;IAAA,KALlEA,IAAI;IAAA,KACJC,aAAa;IAAA,KACbC,UAAU;IAMR,IAAI,CAACF,IAAI,GAAG;MACVG,IAAI,EAAE,CAAAH,IAAI,aAAJA,IAAI,uBAAJA,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AM,CAACoB,MAAM,EAAErC,KAAK,IAAIuF,IAAI,EAAE;MAC3D,KAAK,IAAI6C,cAAc,GAAG,CAAC,EAAEA,cAAc,GAAG7C,IAAI,EAAE6C,cAAc,EAAE,EAAE;QAEpEV,MAAM,CAAC/B,GAAG,CAAC,CAAC,GAAGyC,cAAc,CAAC,GAAGnC,IAAI,CAACN,GAAG,CAEvC+B,MAAM,CAAC/B,GAAG,CAAC,CAAC,GAAGyC,cAAc,CAAC,EAC9BnH,MAAM,CAACjB,KAAK,GAAGoI,cAAc,CAC/B,CAAC;QAEDV,MAAM,CAAChC,GAAG,CAAC,CAAC,GAAG0C,cAAc,CAAC,GAAGnC,IAAI,CAACP,GAAG,CAEvCgC,MAAM,CAAChC,GAAG,CAAC,CAAC,GAAG0C,cAAc,CAAC,EAC9BnH,MAAM,CAACjB,KAAK,GAAGoI,cAAc,CAC/B,CAAC;MACH;IACF;IACA,OAAOV,MAAM;EACf;AACF"}
1
+ {"version":3,"file":"gltf-scenegraph.js","names":["getBinaryImageMetadata","padToNBytes","copyToArray","assert","getAccessorTypeFromSize","getComponentTypeFromArray","getTypedArrayForAccessor","_getTypedArrayForAccessor","makeDefaultGLTFJson","asset","version","generator","buffers","extensions","extensionsRequired","extensionsUsed","GLTFScenegraph","constructor","gltf","sourceBuffers","byteLength","json","images","getApplicationData","key","data","getExtraData","extras","hasExtension","extensionName","isUsedExtension","getUsedExtensions","find","name","isRequiredExtension","getRequiredExtensions","getExtension","isExtension","getRequiredExtension","isRequired","getRemovedExtensions","extensionsRemoved","getObjectExtension","object","getScene","index","getObject","getNode","getSkin","getMesh","getMaterial","getAccessor","getTexture","getSampler","getImage","getBufferView","getBuffer","array","Error","getTypedArrayForBufferView","bufferView","bufferIndex","buffer","binChunk","byteOffset","Uint8Array","arrayBuffer","accessor","gltfAccessor","getTypedArrayForImageData","image","addApplicationData","addExtraData","addObjectExtension","registerUsedExtension","setObjectExtension","removeObjectExtension","includes","push","addExtension","extensionData","arguments","length","undefined","addRequiredExtension","registerRequiredExtension","ext","removeExtension","_this$json$extensions","_removeStringFromArray","setDefaultScene","sceneIndex","scene","addScene","nodeIndices","scenes","nodes","addNode","node","meshIndex","matrix","nodeData","mesh","addMesh","attributes","indices","material","mode","accessors","_addAttributes","glTFMesh","primitives","indicesAccessor","_addIndices","Number","isFinite","meshes","addPointCloud","accessorIndices","addImage","imageData","mimeTypeOpt","metadata","mimeType","bufferViewIndex","addBufferView","glTFImage","glTFBufferView","bufferViews","addAccessor","glTFAccessor","type","size","componentType","count","max","min","addBinaryBuffer","sourceBuffer","minMax","_getAccessorMinMax","accessorDefaults","Math","round","Object","assign","addTexture","texture","imageIndex","glTFTexture","source","textures","addMaterial","pbrMaterialInfo","materials","createBinaryChunk","_this$json","_this$json$buffers","totalByteLength","ArrayBuffer","targetArray","dstByteOffset","binary","string","found","indexOf","splice","result","attributeKey","attributeData","attrName","_getGltfAttributeName","value","attributeName","toLowerCase","initValues","subarray","componentIndex"],"sources":["../../../src/lib/api/gltf-scenegraph.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {GLTFWithBuffers} from '../types/gltf-types';\nimport type {\n GLTF,\n GLTFScene,\n GLTFNode,\n GLTFMesh,\n GLTFSkin,\n GLTFMaterial,\n GLTFAccessor,\n GLTFSampler,\n GLTFTexture,\n GLTFImage,\n GLTFBuffer,\n GLTFBufferView\n} from '../types/gltf-json-schema';\n\nimport {getBinaryImageMetadata} from '@loaders.gl/images';\nimport {padToNBytes, copyToArray} from '@loaders.gl/loader-utils';\nimport {assert} from '../utils/assert';\nimport {getAccessorTypeFromSize, getComponentTypeFromArray} from '../gltf-utils/gltf-utils';\n\nimport {getTypedArrayForAccessor as _getTypedArrayForAccessor} from '../gltf-utils/get-typed-array';\n\ntype Extension = {[key: string]: any};\n\nfunction makeDefaultGLTFJson(): GLTF {\n return {\n asset: {\n version: '2.0',\n generator: 'loaders.gl'\n },\n buffers: [],\n extensions: {},\n extensionsRequired: [],\n extensionsUsed: []\n };\n}\n\n/**\n * Class for structured access to GLTF data\n */\nexport class GLTFScenegraph {\n // internal\n gltf: GLTFWithBuffers;\n sourceBuffers: any[];\n byteLength: number;\n\n // TODO - why is this not GLTFWithBuffers - what happens to images?\n constructor(gltf?: {json: GLTF; buffers?: any[]; images?: any[]}) {\n // Declare locally so\n\n this.gltf = {\n json: gltf?.json || makeDefaultGLTFJson(),\n buffers: gltf?.buffers || [],\n images: gltf?.images || []\n };\n this.sourceBuffers = [];\n this.byteLength = 0;\n\n // Initialize buffers\n if (this.gltf.buffers && this.gltf.buffers[0]) {\n this.byteLength = this.gltf.buffers[0].byteLength;\n this.sourceBuffers = [this.gltf.buffers[0]];\n }\n }\n\n // Accessors\n\n get json(): GLTF {\n return this.gltf.json;\n }\n\n getApplicationData(key: string): unknown {\n // TODO - Data is already unpacked by GLBParser\n const data = this.json[key];\n return data;\n }\n\n getExtraData(key: string): unknown {\n // TODO - Data is already unpacked by GLBParser\n const extras = (this.json.extras || {}) as Record<string, unknown>;\n return extras[key];\n }\n\n hasExtension(extensionName: string): boolean {\n const isUsedExtension = this.getUsedExtensions().find((name) => name === extensionName);\n const isRequiredExtension = this.getRequiredExtensions().find((name) => name === extensionName);\n return typeof isUsedExtension === 'string' || typeof isRequiredExtension === 'string';\n }\n\n getExtension<T = Extension>(extensionName: string): T | null {\n const isExtension = this.getUsedExtensions().find((name) => name === extensionName);\n const extensions = this.json.extensions || {};\n return isExtension ? (extensions[extensionName] as T) : null;\n }\n\n getRequiredExtension<T = Extension>(extensionName: string): T | null {\n const isRequired = this.getRequiredExtensions().find((name) => name === extensionName);\n return isRequired ? this.getExtension(extensionName) : null;\n }\n\n getRequiredExtensions(): string[] {\n return this.json.extensionsRequired || [];\n }\n\n getUsedExtensions(): string[] {\n return this.json.extensionsUsed || [];\n }\n\n getRemovedExtensions(): string[] {\n return (this.json.extensionsRemoved || []) as string[];\n }\n\n getObjectExtension<T = Extension>(object: {[key: string]: any}, extensionName: string): T | null {\n const extensions = object.extensions || {};\n return extensions[extensionName];\n }\n\n getScene(index: number): GLTFScene {\n return this.getObject('scenes', index) as GLTFScene;\n }\n\n getNode(index: number): GLTFNode {\n return this.getObject('nodes', index) as GLTFNode;\n }\n\n getSkin(index: number): GLTFSkin {\n return this.getObject('skins', index) as GLTFSkin;\n }\n\n getMesh(index: number): GLTFMesh {\n return this.getObject('meshes', index) as GLTFMesh;\n }\n\n getMaterial(index: number): GLTFMaterial {\n return this.getObject('materials', index) as GLTFMaterial;\n }\n\n getAccessor(index: number): GLTFAccessor {\n return this.getObject('accessors', index) as GLTFAccessor;\n }\n\n // getCamera(index: number): object | null {\n // return null; // TODO: fix thi: object as null;\n // }\n\n getTexture(index: number): GLTFTexture {\n return this.getObject('textures', index) as GLTFTexture;\n }\n\n getSampler(index: number): GLTFSampler {\n return this.getObject('samplers', index) as GLTFSampler;\n }\n\n getImage(index: number): GLTFImage {\n return this.getObject('images', index) as GLTFImage;\n }\n\n getBufferView(index: number | object): GLTFBufferView {\n return this.getObject('bufferViews', index) as GLTFBufferView;\n }\n\n getBuffer(index: number): GLTFBuffer {\n return this.getObject('buffers', index) as GLTFBuffer;\n }\n\n getObject(array: string, index: number | object): Record<string, unknown> {\n // check if already resolved\n if (typeof index === 'object') {\n return index as Record<string, unknown>;\n }\n const object = this.json[array] && (this.json[array] as {}[])[index];\n if (!object) {\n throw new Error(`glTF file error: Could not find ${array}[${index}]`); // eslint-disable-line\n }\n return object as Record<string, unknown>;\n }\n\n /**\n * Accepts buffer view index or buffer view object\n * @returns a `Uint8Array`\n */\n getTypedArrayForBufferView(bufferView: number | object): Uint8Array {\n bufferView = this.getBufferView(bufferView);\n // @ts-ignore\n const bufferIndex = bufferView.buffer;\n\n // Get hold of the arrayBuffer\n // const buffer = this.getBuffer(bufferIndex);\n const binChunk = this.gltf.buffers[bufferIndex];\n assert(binChunk);\n\n // @ts-ignore\n const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset;\n // @ts-ignore\n return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength);\n }\n\n /** Accepts accessor index or accessor object\n * @returns a typed array with type that matches the types\n */\n getTypedArrayForAccessor(accessor: number | object): any {\n // @ts-ignore\n const gltfAccessor = this.getAccessor(accessor);\n return _getTypedArrayForAccessor(this.gltf.json, this.gltf.buffers, gltfAccessor);\n }\n\n /** accepts accessor index or accessor object\n * returns a `Uint8Array`\n */\n getTypedArrayForImageData(image: number | object): Uint8Array {\n // @ts-ignore\n image = this.getAccessor(image);\n // @ts-ignore\n const bufferView = this.getBufferView(image.bufferView);\n const buffer = this.getBuffer(bufferView.buffer);\n // @ts-ignore\n const arrayBuffer = buffer.data;\n\n const byteOffset = bufferView.byteOffset || 0;\n return new Uint8Array(arrayBuffer, byteOffset, bufferView.byteLength);\n }\n\n // MODIFERS\n\n /**\n * Add an extra application-defined key to the top-level data structure\n */\n addApplicationData(key: string, data: object): GLTFScenegraph {\n this.json[key] = data;\n return this;\n }\n\n /**\n * `extras` - Standard GLTF field for storing application specific data\n */\n addExtraData(key: string, data: object): GLTFScenegraph {\n this.json.extras = this.json.extras || {};\n (this.json.extras as Record<string, unknown>)[key] = data;\n return this;\n }\n\n addObjectExtension(object: object, extensionName: string, data: object): GLTFScenegraph {\n // @ts-ignore\n object.extensions = object.extensions || {};\n // TODO - clobber or merge?\n // @ts-ignore\n object.extensions[extensionName] = data;\n this.registerUsedExtension(extensionName);\n return this;\n }\n\n setObjectExtension(object: any, extensionName: string, data: object): void {\n const extensions = object.extensions || {};\n extensions[extensionName] = data;\n // TODO - add to usedExtensions...\n }\n\n removeObjectExtension(object: any, extensionName: string): void {\n const extensions = object?.extensions || {};\n\n if (extensions[extensionName]) {\n this.json.extensionsRemoved = this.json.extensionsRemoved || [];\n const extensionsRemoved = this.json.extensionsRemoved as string[];\n if (!extensionsRemoved.includes(extensionName)) {\n extensionsRemoved.push(extensionName);\n }\n }\n\n delete extensions[extensionName];\n }\n\n /**\n * Add to standard GLTF top level extension object, mark as used\n */\n addExtension(extensionName: string, extensionData: object = {}): object {\n assert(extensionData);\n this.json.extensions = this.json.extensions || {};\n this.json.extensions[extensionName] = extensionData;\n this.registerUsedExtension(extensionName);\n return extensionData;\n }\n\n /**\n * Standard GLTF top level extension object, mark as used and required\n */\n addRequiredExtension(extensionName, extensionData: object = {}): object {\n assert(extensionData);\n this.addExtension(extensionName, extensionData);\n this.registerRequiredExtension(extensionName);\n return extensionData;\n }\n\n /**\n * Add extensionName to list of used extensions\n */\n registerUsedExtension(extensionName: string): void {\n this.json.extensionsUsed = this.json.extensionsUsed || [];\n if (!this.json.extensionsUsed.find((ext) => ext === extensionName)) {\n this.json.extensionsUsed.push(extensionName);\n }\n }\n\n /**\n * Add extensionName to list of required extensions\n */\n registerRequiredExtension(extensionName: string): void {\n this.registerUsedExtension(extensionName);\n this.json.extensionsRequired = this.json.extensionsRequired || [];\n if (!this.json.extensionsRequired.find((ext) => ext === extensionName)) {\n this.json.extensionsRequired.push(extensionName);\n }\n }\n\n /**\n * Removes an extension from the top-level list\n */\n removeExtension(extensionName: string): void {\n if (this.json.extensions?.[extensionName]) {\n this.json.extensionsRemoved = this.json.extensionsRemoved || [];\n const extensionsRemoved = this.json.extensionsRemoved as string[];\n if (!extensionsRemoved.includes(extensionName)) {\n extensionsRemoved.push(extensionName);\n }\n }\n if (this.json.extensions) {\n delete this.json.extensions[extensionName];\n }\n if (this.json.extensionsRequired) {\n this._removeStringFromArray(this.json.extensionsRequired, extensionName);\n }\n if (this.json.extensionsUsed) {\n this._removeStringFromArray(this.json.extensionsUsed, extensionName);\n }\n }\n\n /**\n * Set default scene which is to be displayed at load time\n */\n setDefaultScene(sceneIndex: number): void {\n this.json.scene = sceneIndex;\n }\n\n /**\n * @todo: add more properties for scene initialization:\n * name`, `extensions`, `extras`\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-scene\n */\n addScene(scene: {nodeIndices: number[]}): number {\n const {nodeIndices} = scene;\n this.json.scenes = this.json.scenes || [];\n this.json.scenes.push({nodes: nodeIndices});\n return this.json.scenes.length - 1;\n }\n\n /**\n * @todo: add more properties for node initialization:\n * `name`, `extensions`, `extras`, `camera`, `children`, `skin`, `rotation`, `scale`, `translation`, `weights`\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#node\n */\n addNode(node: {meshIndex: number; matrix?: number[]}): number {\n const {meshIndex, matrix} = node;\n this.json.nodes = this.json.nodes || [];\n const nodeData = {mesh: meshIndex};\n if (matrix) {\n // @ts-ignore\n nodeData.matrix = matrix;\n }\n this.json.nodes.push(nodeData);\n return this.json.nodes.length - 1;\n }\n\n /** Adds a mesh to the json part */\n addMesh(mesh: {attributes: object; indices?: object; material?: number; mode?: number}): number {\n const {attributes, indices, material, mode = 4} = mesh;\n const accessors = this._addAttributes(attributes);\n\n const glTFMesh = {\n primitives: [\n {\n attributes: accessors,\n mode\n }\n ]\n };\n\n if (indices) {\n const indicesAccessor = this._addIndices(indices);\n // @ts-ignore\n glTFMesh.primitives[0].indices = indicesAccessor;\n }\n\n if (Number.isFinite(material)) {\n // @ts-ignore\n glTFMesh.primitives[0].material = material;\n }\n\n this.json.meshes = this.json.meshes || [];\n this.json.meshes.push(glTFMesh);\n return this.json.meshes.length - 1;\n }\n\n addPointCloud(attributes: object): number {\n // @ts-ignore\n const accessorIndices = this._addAttributes(attributes);\n\n const glTFMesh = {\n primitives: [\n {\n attributes: accessorIndices,\n mode: 0 // GL.POINTS\n }\n ]\n };\n\n this.json.meshes = this.json.meshes || [];\n this.json.meshes.push(glTFMesh);\n return this.json.meshes.length - 1;\n }\n\n /**\n * Adds a binary image. Builds glTF \"JSON metadata\" and saves buffer reference\n * Buffer will be copied into BIN chunk during \"pack\"\n * Currently encodes as glTF image\n * @param imageData\n * @param mimeType\n */\n addImage(imageData: any, mimeTypeOpt?: string): number {\n // If image is referencing a bufferView instead of URI, mimeType must be defined:\n // https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#images\n // \"a reference to a bufferView; in that case mimeType must be defined.\"\n const metadata = getBinaryImageMetadata(imageData);\n const mimeType = mimeTypeOpt || metadata?.mimeType;\n\n const bufferViewIndex = this.addBufferView(imageData);\n\n const glTFImage = {\n bufferView: bufferViewIndex,\n mimeType\n };\n\n this.json.images = this.json.images || [];\n this.json.images.push(glTFImage);\n return this.json.images.length - 1;\n }\n\n /**\n * Add one untyped source buffer, create a matching glTF `bufferView`, and return its index\n * @param buffer\n */\n addBufferView(buffer: any, bufferIndex = 0, byteOffset = this.byteLength): number {\n const byteLength = buffer.byteLength;\n assert(Number.isFinite(byteLength));\n\n // Add this buffer to the list of buffers to be written to the body.\n this.sourceBuffers = this.sourceBuffers || [];\n this.sourceBuffers.push(buffer);\n\n const glTFBufferView = {\n buffer: bufferIndex,\n // Write offset from the start of the binary body\n byteOffset,\n byteLength\n };\n\n // We've now added the contents to the body, so update the total length\n // Every sub-chunk needs to be 4-byte align ed\n this.byteLength += padToNBytes(byteLength, 4);\n\n // Add a bufferView indicating start and length of this binary sub-chunk\n this.json.bufferViews = this.json.bufferViews || [];\n this.json.bufferViews.push(glTFBufferView);\n return this.json.bufferViews.length - 1;\n }\n\n /**\n * Adds an accessor to a bufferView\n * @param bufferViewIndex\n * @param accessor\n */\n addAccessor(bufferViewIndex: number, accessor: object): number {\n const glTFAccessor = {\n bufferView: bufferViewIndex,\n // @ts-ignore\n type: getAccessorTypeFromSize(accessor.size),\n // @ts-ignore\n componentType: accessor.componentType,\n // @ts-ignore\n count: accessor.count,\n // @ts-ignore\n max: accessor.max,\n // @ts-ignore\n min: accessor.min\n };\n\n this.json.accessors = this.json.accessors || [];\n this.json.accessors.push(glTFAccessor);\n return this.json.accessors.length - 1;\n }\n\n /**\n * Add a binary buffer. Builds glTF \"JSON metadata\" and saves buffer reference\n * Buffer will be copied into BIN chunk during \"pack\"\n * Currently encodes buffers as glTF accessors, but this could be optimized\n * @param sourceBuffer\n * @param accessor\n */\n addBinaryBuffer(sourceBuffer: any, accessor: object = {size: 3}): number {\n const bufferViewIndex = this.addBufferView(sourceBuffer);\n // @ts-ignore\n let minMax = {min: accessor.min, max: accessor.max};\n if (!minMax.min || !minMax.max) {\n // @ts-ignore\n minMax = this._getAccessorMinMax(sourceBuffer, accessor.size);\n }\n\n const accessorDefaults = {\n // @ts-ignore\n size: accessor.size,\n componentType: getComponentTypeFromArray(sourceBuffer),\n // @ts-ignore\n count: Math.round(sourceBuffer.length / accessor.size),\n min: minMax.min,\n max: minMax.max\n };\n\n return this.addAccessor(bufferViewIndex, Object.assign(accessorDefaults, accessor));\n }\n\n /**\n * Adds a texture to the json part\n * @todo: add more properties for texture initialization\n * `sampler`, `name`, `extensions`, `extras`\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#texture\n */\n addTexture(texture: {imageIndex: number}): number {\n const {imageIndex} = texture;\n const glTFTexture = {\n source: imageIndex\n };\n\n this.json.textures = this.json.textures || [];\n this.json.textures.push(glTFTexture);\n return this.json.textures.length - 1;\n }\n\n /** Adds a material to the json part */\n addMaterial(pbrMaterialInfo: Object): number {\n this.json.materials = this.json.materials || [];\n this.json.materials.push(pbrMaterialInfo);\n return this.json.materials.length - 1;\n }\n\n /** Pack the binary chunk */\n createBinaryChunk(): void {\n // Encoder expects this array undefined or empty\n this.gltf.buffers = [];\n\n // Allocate total array\n const totalByteLength = this.byteLength;\n const arrayBuffer = new ArrayBuffer(totalByteLength);\n const targetArray = new Uint8Array(arrayBuffer);\n\n // Copy each array into\n let dstByteOffset = 0;\n for (const sourceBuffer of this.sourceBuffers || []) {\n dstByteOffset = copyToArray(sourceBuffer, targetArray, dstByteOffset);\n }\n\n // Update the glTF BIN CHUNK byte length\n if (this.json?.buffers?.[0]) {\n this.json.buffers[0].byteLength = totalByteLength;\n } else {\n this.json.buffers = [{byteLength: totalByteLength}];\n }\n\n // Save generated arrayBuffer\n this.gltf.binary = arrayBuffer;\n\n // Put arrayBuffer to sourceBuffers for possible additional writing data in the chunk\n this.sourceBuffers = [arrayBuffer];\n }\n\n // PRIVATE\n\n _removeStringFromArray(array, string) {\n let found = true;\n while (found) {\n const index = array.indexOf(string);\n if (index > -1) {\n array.splice(index, 1);\n } else {\n found = false;\n }\n }\n }\n\n /**\n * Add attributes to buffers and create `attributes` object which is part of `mesh`\n */\n _addAttributes(attributes = {}) {\n const result = {};\n for (const attributeKey in attributes) {\n const attributeData = attributes[attributeKey];\n const attrName = this._getGltfAttributeName(attributeKey);\n const accessor = this.addBinaryBuffer(attributeData.value, attributeData);\n result[attrName] = accessor;\n }\n return result;\n }\n\n /**\n * Add indices to buffers\n */\n _addIndices(indices) {\n return this.addBinaryBuffer(indices, {size: 1});\n }\n\n /**\n * Deduce gltf specific attribue name from input attribute name\n */\n _getGltfAttributeName(attributeName) {\n switch (attributeName.toLowerCase()) {\n case 'position':\n case 'positions':\n case 'vertices':\n return 'POSITION';\n case 'normal':\n case 'normals':\n return 'NORMAL';\n case 'color':\n case 'colors':\n return 'COLOR_0';\n case 'texcoord':\n case 'texcoords':\n return 'TEXCOORD_0';\n default:\n return attributeName;\n }\n }\n\n /**\n * Calculate `min` and `max` arrays of accessor according to spec:\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-accessor\n */\n _getAccessorMinMax(buffer, size) {\n const result = {min: null, max: null};\n if (buffer.length < size) {\n return result;\n }\n // @ts-ignore\n result.min = [];\n // @ts-ignore\n result.max = [];\n const initValues = buffer.subarray(0, size);\n for (const value of initValues) {\n // @ts-ignore\n result.min.push(value);\n // @ts-ignore\n result.max.push(value);\n }\n\n for (let index = size; index < buffer.length; index += size) {\n for (let componentIndex = 0; componentIndex < size; componentIndex++) {\n // @ts-ignore\n result.min[0 + componentIndex] = Math.min(\n // @ts-ignore\n result.min[0 + componentIndex],\n buffer[index + componentIndex]\n );\n // @ts-ignore\n result.max[0 + componentIndex] = Math.max(\n // @ts-ignore\n result.max[0 + componentIndex],\n buffer[index + componentIndex]\n );\n }\n }\n return result;\n }\n}\n"],"mappings":"AAkBA,SAAQA,sBAAsB,QAAO,oB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';
2
- import type { GLTF_EXT_structural_metadata_GLTF } from '../types/gltf-ext-structural-metadata-schema';
3
2
  import type { GLTFLoaderOptions } from '../../gltf-loader';
4
- import type { FeatureTableJson } from '../types/gltf-types';
5
3
  export declare const name = "EXT_structural_metadata";
6
4
  export declare function decode(gltfData: {
7
5
  json: GLTF;
8
6
  }, options: GLTFLoaderOptions): Promise<void>;
9
- /**
10
- * Handles EXT_structural_metadata to get property table.
11
- * @param extension - Global level of EXT_STRUCTURAL_METADATA extension.
12
- * @param metadataClass - User selected feature metadata class name.
13
- * @returns {FeatureTableJson | null} Property table or null if the extension can't be handled properly.
14
- */
15
- export declare function getPropertyTableFromExtStructuralMetadata(extension: GLTF_EXT_structural_metadata_GLTF, metadataClass?: string): FeatureTableJson | null;
16
7
  //# sourceMappingURL=EXT_structural_metadata.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EXT_structural_metadata.d.ts","sourceRoot":"","sources":["../../../src/lib/extensions/EXT_structural_metadata.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,IAAI,EAA6C,MAAM,2BAA2B,CAAC;AAChG,OAAO,KAAK,EAMV,iCAAiC,EAIlC,MAAM,8CAA8C,CAAC;AACtD,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,qBAAqB,CAAC;AAgB1D,eAAO,MAAM,IAAI,4BAA+B,CAAC;AAEjD,wBAAsB,MAAM,CAAC,QAAQ,EAAE;IAAC,IAAI,EAAE,IAAI,CAAA;CAAC,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAG9F;AAED;;;;;GAKG;AACH,wBAAgB,yCAAyC,CACvD,SAAS,EAAE,iCAAiC,EAC5C,aAAa,CAAC,EAAE,MAAM,GACrB,gBAAgB,GAAG,IAAI,CAmCzB"}
1
+ {"version":3,"file":"EXT_structural_metadata.d.ts","sourceRoot":"","sources":["../../../src/lib/extensions/EXT_structural_metadata.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,IAAI,EAA6C,MAAM,2BAA2B,CAAC;AAYhG,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,mBAAmB,CAAC;AAgBzD,eAAO,MAAM,IAAI,4BAA+B,CAAC;AAEjD,wBAAsB,MAAM,CAAC,QAAQ,EAAE;IAAC,IAAI,EAAE,IAAI,CAAA;CAAC,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAG9F"}
@@ -6,26 +6,6 @@ export async function decode(gltfData, options) {
6
6
  const scenegraph = new GLTFScenegraph(gltfData);
7
7
  decodeExtStructuralMetadata(scenegraph, options);
8
8
  }
9
- export function getPropertyTableFromExtStructuralMetadata(extension, metadataClass) {
10
- if (extension.propertyTables) {
11
- const firstPropertyTable = extension === null || extension === void 0 ? void 0 : extension.propertyTables[0];
12
- const propertyTableWithData = {};
13
- for (const propertyName in firstPropertyTable.properties) {
14
- propertyTableWithData[propertyName] = firstPropertyTable.properties[propertyName].data;
15
- }
16
- return propertyTableWithData;
17
- }
18
- if (extension.propertyTextures) {
19
- const firstPropertyTexture = extension === null || extension === void 0 ? void 0 : extension.propertyTextures[0];
20
- const propertyTableWithData = {};
21
- for (const propertyName in firstPropertyTexture.properties) {
22
- propertyTableWithData[propertyName] = firstPropertyTexture.properties[propertyName].data;
23
- }
24
- return propertyTableWithData;
25
- }
26
- console.warn('Cannot get property table from EXT_structural_metadata extension. There is neither propertyTables, nor propertyTextures in the extension.');
27
- return null;
28
- }
29
9
  function decodeExtStructuralMetadata(scenegraph, options) {
30
10
  var _options$gltf, _options$gltf2;
31
11
  if (!((_options$gltf = options.gltf) !== null && _options$gltf !== void 0 && _options$gltf.loadBuffers)) {
@@ -1 +1 @@
1
- {"version":3,"file":"EXT_structural_metadata.js","names":["GLTFScenegraph","convertRawBufferToMetadataArray","getPrimitiveTextureData","primitivePropertyDataToAttributes","getArrayElementByteSize","getOffsetsForProperty","parseVariableLengthArrayNumeric","parseFixedLengthArrayNumeric","getPropertyDataString","EXT_STRUCTURAL_METADATA_NAME","name","decode","gltfData","options","scenegraph","decodeExtStructuralMetadata","getPropertyTableFromExtStructuralMetadata","extension","metadataClass","propertyTables","firstPropertyTable","propertyTableWithData","propertyName","properties","data","propertyTextures","firstPropertyTexture","console","warn","_options$gltf","_options$gltf2","gltf","loadBuffers","getExtension","loadImages","decodePropertyTextures","decodePropertyTables","json","meshes","mesh","primitive","primitives","processPrimitivePropertyTextures","schema","schemaClasses","classes","schemaName","propertyTable","findPropertyTableByClass","processPropertyTable","schemaClassName","class","_primitive$extensions","primitiveExtension","extensions","primitivePropertyTextureIndices","primitivePropertyTextureIndex","propertyTexture","processPrimitivePropertyTexture","dataAttributeNames","className","_propertyTexture$prop","attributeName","textureInfoTopLevel","featureTextureTable","propertyData","push","_schema$classes","schemaClass","Error","numberOfElements","count","_propertyTable$proper","classProperty","propertyTableProperty","getPropertyDataFromBinarySource","valuesBufferView","values","valuesDataBytes","getTypedArrayForBufferView","arrayOffsets","getArrayOffsetsForProperty","stringOffsets","getStringOffsetsForProperty","type","getPropertyDataNumeric","getPropertyDataENUM","array","arrayOffsetType","stringOffsetType","isArray","arrayCount","elementSize","componentType","elementCount","byteLength","valuesData","length","_schema$enums","enumType","enumEntry","enums","enumValueType","valueType","parseVariableLengthArrayENUM","valuesDataBytesLength","parseFixedLengthArrayENUM","getEnumsArray","params","attributeValueArray","index","arrayOffset","arrayByteSize","typedArrayOffset","elementOffset","offset","i","BigInt64Array","BigUint64Array","value","enumObject","getEnumByValue","enumValue"],"sources":["../../../src/lib/extensions/EXT_structural_metadata.ts"],"sourcesContent":["// GLTF EXTENSION: EXT_structural_metadata\n// https://github.com/CesiumGS/glTF/blob/3d-tiles-next/extensions/2.0/Vendor/EXT_structural_metadata\n/* eslint-disable camelcase */\nimport type {BigTypedArray, TypedArray} from '@loaders.gl/schema';\nimport type {GLTF, GLTFTextureInfoMetadata, GLTFMeshPrimitive} from '../types/gltf-json-schema';\nimport type {\n GLTF_EXT_structural_metadata_Schema,\n GLTF_EXT_structural_metadata_ClassProperty,\n GLTF_EXT_structural_metadata_Enum,\n GLTF_EXT_structural_metadata_EnumValue,\n GLTF_EXT_structural_metadata_PropertyTable,\n GLTF_EXT_structural_metadata_GLTF,\n GLTF_EXT_structural_metadata_PropertyTexture,\n GLTF_EXT_structural_metadata_PropertyTable_Property,\n GLTF_EXT_structural_metadata_Primitive\n} from '../types/gltf-ext-structural-metadata-schema';\nimport type {GLTFLoaderOptions} from '../../gltf-loader';\nimport type {FeatureTableJson} from '../types/gltf-types';\n\nimport {GLTFScenegraph} from '../api/gltf-scenegraph';\nimport {\n convertRawBufferToMetadataArray,\n getPrimitiveTextureData,\n primitivePropertyDataToAttributes,\n getArrayElementByteSize,\n NumericComponentType,\n getOffsetsForProperty,\n parseVariableLengthArrayNumeric,\n parseFixedLengthArrayNumeric,\n getPropertyDataString\n} from './utils/3d-tiles-utils';\n\nconst EXT_STRUCTURAL_METADATA_NAME = 'EXT_structural_metadata';\nexport const name = EXT_STRUCTURAL_METADATA_NAME;\n\nexport async function decode(gltfData: {json: GLTF}, options: GLTFLoaderOptions): Promise<void> {\n const scenegraph = new GLTFScenegraph(gltfData);\n decodeExtStructuralMetadata(scenegraph, options);\n}\n\n/**\n * Handles EXT_structural_metadata to get property table.\n * @param extension - Global level of EXT_STRUCTURAL_METADATA extension.\n * @param metadataClass - User selected feature metadata class name.\n * @returns {FeatureTableJson | null} Property table or null if the extension can't be handled properly.\n */\nexport function getPropertyTableFromExtStructuralMetadata(\n extension: GLTF_EXT_structural_metadata_GLTF,\n metadataClass?: string\n): FeatureTableJson | null {\n if (extension.propertyTables) {\n /**\n * Take only first feature table to generate attributes storage info object.\n * TODO: Think about getting data from all feature tables?\n * It can be tricky just because 3dTiles is able to have multiple featureId attributes and multiple feature tables.\n * In I3S we should decide which featureIds attribute will be passed to geometry data.\n */\n const firstPropertyTable = extension?.propertyTables[0];\n const propertyTableWithData = {};\n\n for (const propertyName in firstPropertyTable.properties) {\n propertyTableWithData[propertyName] = firstPropertyTable.properties[propertyName].data;\n }\n\n return propertyTableWithData;\n }\n\n if (extension.propertyTextures) {\n // TODO: Think about getting data from all property textures.\n const firstPropertyTexture = extension?.propertyTextures[0];\n const propertyTableWithData = {};\n\n for (const propertyName in firstPropertyTexture.properties) {\n propertyTableWithData[propertyName] = firstPropertyTexture.properties[propertyName].data;\n }\n\n return propertyTableWithData;\n }\n\n // eslint-disable-next-line no-console\n console.warn(\n 'Cannot get property table from EXT_structural_metadata extension. There is neither propertyTables, nor propertyTextures in the extension.'\n );\n return null;\n}\n\n/*\n// Example of the extension.\n// See more info at https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_structural_metadata\nconst extensions = {\n \"extensions\": {\n \"EXT_structural_metadata\": {\n \"schema\": {\n \"classes\": {\n \"tree\": {\n \"name\": \"Tree\",\n \"description\": \"Woody, perennial plant.\",\n \"properties\": {\n \"species\": {\n \"description\": \"Type of tree.\",\n \"type\": \"ENUM\",\n \"enumType\": \"speciesEnum\",\n \"required\": true\n },\n \"age\": {\n \"description\": \"The age of the tree, in years\",\n \"type\": \"SCALAR\",\n \"componentType\": \"UINT8\",\n \"required\": true\n }\n }\n }\n },\n \"enums\": {\n \"speciesEnum\": {\n \"name\": \"Species\",\n \"description\": \"An example enum for tree species.\",\n // valueType is not defined here. Default is \"UINT16\"\n \"values\": [\n { \"name\": \"Unspecified\", \"value\": 0 },\n { \"name\": \"Oak\", \"value\": 1 }\n ]\n }\n }\n },\n \"propertyTables\": [{\n \"name\": \"tree_survey_2021-09-29\",\n \"class\": \"tree\",\n \"count\": 10, // The number of elements in each property array (in `species`, in `age`).\n \"properties\": {\n \"species\": {\n \"values\": 0, // It's an index of the buffer view containing property values.\n },\n \"age\": {\n \"values\": 1\n }\n }\n }]\n }\n }\n}\n*/\n\n/**\n * Decodes feature metadata from extension.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param options - GLTFLoader options.\n */\nfunction decodeExtStructuralMetadata(scenegraph: GLTFScenegraph, options: GLTFLoaderOptions): void {\n // Decoding metadata involves buffers processing.\n // So, if buffers have not been loaded, there is no reason to process metadata.\n if (!options.gltf?.loadBuffers) {\n return;\n }\n const extension: GLTF_EXT_structural_metadata_GLTF | null = scenegraph.getExtension(\n EXT_STRUCTURAL_METADATA_NAME\n );\n if (!extension) {\n return;\n }\n\n if (options.gltf?.loadImages) {\n decodePropertyTextures(scenegraph, extension);\n }\n\n decodePropertyTables(scenegraph, extension);\n}\n\n/**\n * Processes the data stored in the textures\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param extension - Top-level extension.\n */\nfunction decodePropertyTextures(\n scenegraph: GLTFScenegraph,\n extension: GLTF_EXT_structural_metadata_GLTF\n): void {\n const propertyTextures = extension.propertyTextures;\n const json = scenegraph.gltf.json;\n if (propertyTextures && json.meshes) {\n // Iterate through all meshes/primitives.\n for (const mesh of json.meshes) {\n for (const primitive of mesh.primitives) {\n processPrimitivePropertyTextures(scenegraph, propertyTextures, primitive, extension);\n }\n }\n }\n}\n\n/**\n * Processes the data stored in the property tables.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param extension - Top-level extension.\n */\nfunction decodePropertyTables(\n scenegraph: GLTFScenegraph,\n extension: GLTF_EXT_structural_metadata_GLTF\n): void {\n const schema = extension.schema;\n if (!schema) {\n return;\n }\n const schemaClasses = schema.classes;\n const propertyTables = extension.propertyTables;\n if (schemaClasses && propertyTables) {\n for (const schemaName in schemaClasses) {\n const propertyTable = findPropertyTableByClass(propertyTables, schemaName);\n if (propertyTable) {\n processPropertyTable(scenegraph, schema, propertyTable);\n }\n }\n }\n}\n\n/**\n * Finds the property table by class name.\n * @param propertyTables - propertyTable definition taken from the top-level extension.\n * @param schemaClassName - class name in the extension schema.\n */\nfunction findPropertyTableByClass(\n propertyTables: GLTF_EXT_structural_metadata_PropertyTable[],\n schemaClassName: string\n): GLTF_EXT_structural_metadata_PropertyTable | null {\n for (const propertyTable of propertyTables) {\n if (propertyTable.class === schemaClassName) {\n return propertyTable;\n }\n }\n\n return null;\n}\n\n/**\n * Takes data from property textures reffered by the primitive.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param propertyTextures - propertyTexture definition taken from the top-level extention.\n * @param primitive - Primitive object.\n * @param extension - Top-level extension.\n */\nfunction processPrimitivePropertyTextures(\n scenegraph: GLTFScenegraph,\n propertyTextures: GLTF_EXT_structural_metadata_PropertyTexture[],\n primitive: GLTFMeshPrimitive,\n extension: GLTF_EXT_structural_metadata_GLTF\n): void {\n if (!propertyTextures) {\n return;\n }\n const primitiveExtension: GLTF_EXT_structural_metadata_Primitive = primitive.extensions?.[\n EXT_STRUCTURAL_METADATA_NAME\n ] as GLTF_EXT_structural_metadata_Primitive;\n const primitivePropertyTextureIndices = primitiveExtension?.propertyTextures;\n if (!primitivePropertyTextureIndices) {\n return;\n }\n\n for (const primitivePropertyTextureIndex of primitivePropertyTextureIndices) {\n const propertyTexture = propertyTextures[primitivePropertyTextureIndex];\n processPrimitivePropertyTexture(scenegraph, propertyTexture, primitive, extension);\n }\n}\n\n/**\n * Takes property data from the texture pointed by the primitive and appends them to `exension.data`.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param propertyTexture - propertyTexture definition taken from the top-level extension.\n * @param primitive - Primitive object.\n * @param extension - Top-level extension.\n */\nfunction processPrimitivePropertyTexture(\n scenegraph: GLTFScenegraph,\n propertyTexture: GLTF_EXT_structural_metadata_PropertyTexture,\n primitive: GLTFMeshPrimitive,\n extension: GLTF_EXT_structural_metadata_GLTF\n): void {\n if (!propertyTexture.properties) {\n return;\n }\n\n if (!extension.dataAttributeNames) {\n extension.dataAttributeNames = [];\n }\n\n /* Iterate through all properties defined in propertyTexture, e.g. \"speed\" and \"direction\":\n {\n \"class\": \"wind\",\n \"properties\": {\n \"speed\": {\n \"index\": 0,\n \"texCoord\": 0,\n \"channels\": [0]\n },\n \"direction\": {\n \"index\": 0,\n \"texCoord\": 0,\n \"channels\": [1, 2]\n }\n }\n }\n */\n const className = propertyTexture.class;\n for (const propertyName in propertyTexture.properties) {\n // propertyName has values like \"speed\", \"direction\"\n // Make attributeName as a combination of the class name and the propertyName like \"wind_speed\" or \"wind_direction\"\n const attributeName = `${className}_${propertyName}`;\n const textureInfoTopLevel: GLTFTextureInfoMetadata | undefined =\n propertyTexture.properties?.[propertyName];\n if (!textureInfoTopLevel) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n // The data taken from all meshes/primitives (the same property, e.g. \"speed\" or \"direction\") will be combined into one array and saved in textureInfoTopLevel.data\n // Initially textureInfoTopLevel.data will be initialized with an empty array.\n if (!textureInfoTopLevel.data) {\n textureInfoTopLevel.data = [];\n }\n const featureTextureTable: number[] = textureInfoTopLevel.data as number[];\n\n const propertyData: number[] | null = getPrimitiveTextureData(\n scenegraph,\n textureInfoTopLevel,\n primitive\n );\n if (propertyData === null) {\n // eslint-disable-next-line no-continue\n continue;\n }\n primitivePropertyDataToAttributes(\n scenegraph,\n attributeName,\n propertyData,\n featureTextureTable,\n primitive\n );\n textureInfoTopLevel.data = featureTextureTable;\n extension.dataAttributeNames.push(attributeName);\n }\n}\n\n/**\n * Navigates through all properies in the property table, gets properties data,\n * and put the data to `propertyTable.data` as an array.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param schema - schema object.\n * @param propertyTable - propertyTable definition taken from the top-level extension.\n */\nfunction processPropertyTable(\n scenegraph: GLTFScenegraph,\n schema: GLTF_EXT_structural_metadata_Schema,\n propertyTable: GLTF_EXT_structural_metadata_PropertyTable\n): void {\n const schemaClass = schema.classes?.[propertyTable.class];\n if (!schemaClass) {\n throw new Error(\n `Incorrect data in the EXT_structural_metadata extension: no schema class with name ${propertyTable.class}`\n );\n }\n\n const numberOfElements = propertyTable.count; // `propertyTable.count` is a number of elements in each property array.\n\n for (const propertyName in schemaClass.properties) {\n const classProperty = schemaClass.properties[propertyName];\n const propertyTableProperty: GLTF_EXT_structural_metadata_PropertyTable_Property | undefined =\n propertyTable.properties?.[propertyName];\n\n if (propertyTableProperty) {\n // Getting all elements (`numberOfElements`) of the array in the `propertyTableProperty`\n const data = getPropertyDataFromBinarySource(\n scenegraph,\n schema,\n classProperty,\n numberOfElements,\n propertyTableProperty\n );\n propertyTableProperty.data = data;\n }\n }\n}\n\n/**\n * Decodes a propertyTable column from binary source based on property type.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param schema - Schema object.\n * @param classProperty - class property object.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @param propertyTableProperty - propertyTable's property metadata.\n * @returns {string[] | number[] | string[][] | number[][]}\n */\nfunction getPropertyDataFromBinarySource(\n scenegraph: GLTFScenegraph,\n schema: GLTF_EXT_structural_metadata_Schema,\n classProperty: GLTF_EXT_structural_metadata_ClassProperty,\n numberOfElements: number,\n propertyTableProperty: GLTF_EXT_structural_metadata_PropertyTable_Property\n): string[] | BigTypedArray | string[][] | BigTypedArray[] {\n let data: string[] | BigTypedArray | string[][] | BigTypedArray[] = [];\n const valuesBufferView = propertyTableProperty.values;\n const valuesDataBytes: Uint8Array = scenegraph.getTypedArrayForBufferView(valuesBufferView);\n\n const arrayOffsets = getArrayOffsetsForProperty(\n scenegraph,\n classProperty,\n propertyTableProperty,\n numberOfElements\n );\n const stringOffsets = getStringOffsetsForProperty(\n scenegraph,\n propertyTableProperty,\n numberOfElements\n );\n\n switch (classProperty.type) {\n case 'SCALAR':\n case 'VEC2':\n case 'VEC3':\n case 'VEC4':\n case 'MAT2':\n case 'MAT3':\n case 'MAT4': {\n data = getPropertyDataNumeric(classProperty, numberOfElements, valuesDataBytes, arrayOffsets);\n break;\n }\n case 'BOOLEAN': {\n // TODO: implement it as soon as we have the corresponding tileset\n throw new Error(`Not implemented - classProperty.type=${classProperty.type}`);\n }\n case 'STRING': {\n data = getPropertyDataString(numberOfElements, valuesDataBytes, arrayOffsets, stringOffsets);\n break;\n }\n case 'ENUM': {\n data = getPropertyDataENUM(\n schema,\n classProperty,\n numberOfElements,\n valuesDataBytes,\n arrayOffsets\n );\n break;\n }\n default:\n throw new Error(`Unknown classProperty type ${classProperty.type}`);\n }\n\n return data;\n}\n\n/**\n * Parses propertyTable.property.arrayOffsets that are offsets of sub-arrays in a flatten array of values.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param classProperty - class property object.\n * @param propertyTableProperty - propertyTable's property metadata.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @returns Typed array with offset values.\n * @see https://github.com/CesiumGS/glTF/blob/2976f1183343a47a29e4059a70961371cd2fcee8/extensions/2.0/Vendor/EXT_structural_metadata/schema/propertyTable.property.schema.json#L21\n */\nfunction getArrayOffsetsForProperty(\n scenegraph: GLTFScenegraph,\n classProperty: GLTF_EXT_structural_metadata_ClassProperty,\n propertyTableProperty: GLTF_EXT_structural_metadata_PropertyTable_Property,\n numberOfElements: number\n): TypedArray | null {\n if (\n classProperty.array &&\n // `count` is a number of array elements. May only be defined when `array` is true.\n // If `count` is NOT defined, it's a VARIABLE-length array\n typeof classProperty.count === 'undefined' &&\n // `arrayOffsets` is an index of the buffer view containing offsets for variable-length arrays.\n typeof propertyTableProperty.arrayOffsets !== 'undefined'\n ) {\n // Data are in a VARIABLE-length array\n return getOffsetsForProperty(\n scenegraph,\n propertyTableProperty.arrayOffsets,\n propertyTableProperty.arrayOffsetType || 'UINT32',\n numberOfElements\n );\n }\n return null;\n}\n\n/**\n * Parses propertyTable.property.stringOffsets.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param propertyTableProperty - propertyTable's property metadata.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @returns Typed array with offset values.\n * @see https://github.com/CesiumGS/glTF/blob/2976f1183343a47a29e4059a70961371cd2fcee8/extensions/2.0/Vendor/EXT_structural_metadata/schema/propertyTable.property.schema.json#L29C10-L29C23\n */\nfunction getStringOffsetsForProperty(\n scenegraph: GLTFScenegraph,\n propertyTableProperty: GLTF_EXT_structural_metadata_PropertyTable_Property,\n numberOfElements: number\n): TypedArray | null {\n if (\n typeof propertyTableProperty.stringOffsets !== 'undefined' // `stringOffsets` is an index of the buffer view containing offsets for strings.\n ) {\n // Data are in a FIXED-length array\n return getOffsetsForProperty(\n scenegraph,\n propertyTableProperty.stringOffsets,\n propertyTableProperty.stringOffsetType || 'UINT32',\n numberOfElements\n );\n }\n return null;\n}\n\n/**\n * Decodes properties of SCALAR, VEC-N, MAT-N types from binary sourse.\n * @param classProperty - class property object.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @param valuesDataBytes - Data taken from values property of the property table property.\n * @param arrayOffsets - Offsets for variable-length arrays. It's null for fixed-length arrays or scalar types.\n * @returns Property values in a typed array or in an array of typed arrays.\n */\nfunction getPropertyDataNumeric(\n classProperty: GLTF_EXT_structural_metadata_ClassProperty,\n numberOfElements: number,\n valuesDataBytes: Uint8Array,\n arrayOffsets: TypedArray | null\n): BigTypedArray | BigTypedArray[] {\n const isArray = classProperty.array;\n const arrayCount = classProperty.count;\n\n const elementSize = getArrayElementByteSize(classProperty.type, classProperty.componentType);\n const elementCount = valuesDataBytes.byteLength / elementSize;\n\n let valuesData: BigTypedArray;\n if (classProperty.componentType) {\n valuesData = convertRawBufferToMetadataArray(\n valuesDataBytes,\n classProperty.type,\n // The datatype of the element's components. Only applicable to `SCALAR`, `VECN`, and `MATN` types.\n classProperty.componentType as NumericComponentType,\n elementCount\n );\n } else {\n // The spec doesn't provide any info what to do if componentType is not set.\n valuesData = valuesDataBytes;\n }\n\n if (isArray) {\n if (arrayOffsets) {\n // VARIABLE-length array\n return parseVariableLengthArrayNumeric(\n valuesData,\n numberOfElements,\n arrayOffsets,\n valuesDataBytes.length,\n elementSize\n );\n }\n if (arrayCount) {\n // FIXED-length array\n return parseFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount);\n }\n return [];\n }\n\n return valuesData;\n}\n\n/**\n * Decodes properties of enum type from binary source.\n * @param schema - Schema object.\n * @param classProperty - Class property object.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @param valuesDataBytes - Data taken from values property of the property table property.\n * @param arrayOffsets - Offsets for variable-length arrays. It's null for fixed-length arrays or scalar types.\n * @returns Strings array of nested strings array.\n */\nfunction getPropertyDataENUM(\n schema: GLTF_EXT_structural_metadata_Schema,\n classProperty: GLTF_EXT_structural_metadata_ClassProperty,\n numberOfElements: number,\n valuesDataBytes: Uint8Array,\n arrayOffsets: TypedArray | null\n): string[] | string[][] {\n const enumType = classProperty.enumType;\n // Enum ID as declared in the `enums` dictionary. Required when `type` is `ENUM`.\n if (!enumType) {\n throw new Error(\n 'Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM'\n );\n }\n\n const enumEntry: GLTF_EXT_structural_metadata_Enum | undefined = schema.enums?.[enumType];\n if (!enumEntry) {\n throw new Error(\n `Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${enumType}`\n );\n }\n\n const enumValueType = enumEntry.valueType || 'UINT16';\n const elementSize = getArrayElementByteSize(classProperty.type, enumValueType);\n const elementCount = valuesDataBytes.byteLength / elementSize;\n let valuesData: BigTypedArray | null = convertRawBufferToMetadataArray(\n valuesDataBytes,\n classProperty.type,\n enumValueType,\n elementCount\n );\n if (!valuesData) {\n valuesData = valuesDataBytes;\n }\n\n if (classProperty.array) {\n if (arrayOffsets) {\n // VARIABLE-length array\n return parseVariableLengthArrayENUM({\n valuesData,\n numberOfElements,\n arrayOffsets,\n valuesDataBytesLength: valuesDataBytes.length,\n elementSize,\n enumEntry\n });\n }\n\n const arrayCount = classProperty.count;\n if (arrayCount) {\n // FIXED-length array\n return parseFixedLengthArrayENUM(valuesData, numberOfElements, arrayCount, enumEntry);\n }\n return [];\n }\n\n // Single value (not an array)\n return getEnumsArray(valuesData, 0, numberOfElements, enumEntry);\n}\n\n/**\n * Parses variable length nested ENUM arrays.\n * @param params.valuesData - Values in a flat typed array.\n * @param params.numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @param params.arrayOffsets - Offsets for variable-length arrays. It's null for fixed-length arrays or scalar types.\n * @param params.valuesDataBytesLength - Byte length of values array.\n * @param params.elementSize - Single element byte size.\n * @param params.enumEntry - Enums dictionary.\n * @returns Nested strings array.\n */\nfunction parseVariableLengthArrayENUM(params: {\n valuesData: BigTypedArray;\n numberOfElements: number;\n arrayOffsets: TypedArray;\n valuesDataBytesLength: number;\n elementSize: number;\n enumEntry: GLTF_EXT_structural_metadata_Enum;\n}): string[][] {\n const {\n valuesData,\n numberOfElements,\n arrayOffsets,\n valuesDataBytesLength,\n elementSize,\n enumEntry\n } = params;\n const attributeValueArray: string[][] = [];\n for (let index = 0; index < numberOfElements; index++) {\n const arrayOffset = arrayOffsets[index];\n const arrayByteSize = arrayOffsets[index + 1] - arrayOffsets[index];\n if (arrayByteSize + arrayOffset > valuesDataBytesLength) {\n break;\n }\n\n const typedArrayOffset = arrayOffset / elementSize;\n const elementCount = arrayByteSize / elementSize;\n const array: string[] = getEnumsArray(valuesData, typedArrayOffset, elementCount, enumEntry);\n attributeValueArray.push(array);\n }\n return attributeValueArray;\n}\n\n/**\n * Parses fixed length ENUM arrays.\n * @param valuesData - Values in a flat typed array.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @param arrayCount - Nested arrays length.\n * @param enumEntry - Enums dictionary.\n * @returns Nested strings array.\n */\nfunction parseFixedLengthArrayENUM(\n valuesData: BigTypedArray,\n numberOfElements: number,\n arrayCount: number,\n enumEntry: GLTF_EXT_structural_metadata_Enum\n): string[][] {\n const attributeValueArray: string[][] = [];\n for (let index = 0; index < numberOfElements; index++) {\n const elementOffset = arrayCount * index;\n const array: string[] = getEnumsArray(valuesData, elementOffset, arrayCount, enumEntry);\n attributeValueArray.push(array);\n }\n return attributeValueArray;\n}\n\n/**\n * Parses ENUM values into a string array.\n * @param valuesData - Values in a flat typed array.\n * @param offset - Offset to start parse from.\n * @param count - Values length to parse.\n * @param enumEntry - Enums dictionary.\n * @returns Array of strings with parsed ENUM names.\n */\nfunction getEnumsArray(\n valuesData: BigTypedArray,\n offset: number,\n count: number,\n enumEntry: GLTF_EXT_structural_metadata_Enum\n): string[] {\n const array: string[] = [];\n for (let i = 0; i < count; i++) {\n // At the moment we don't support BigInt. It requires additional calculations logic\n // and might be an issue in Safari\n if (valuesData instanceof BigInt64Array || valuesData instanceof BigUint64Array) {\n array.push('');\n } else {\n const value = valuesData[offset + i];\n\n const enumObject = getEnumByValue(enumEntry, value);\n if (enumObject) {\n array.push(enumObject.name);\n } else {\n array.push('');\n }\n }\n }\n return array;\n}\n\n/**\n * Looks up ENUM whose `value` property matches the specified number in the parameter `value`.\n * @param {GLTF_EXT_structural_metadata_Enum} enumEntry - ENUM entry containing the array of possible enums.\n * @param {number} value - The value of the ENUM to locate.\n * @returns {GLTF_EXT_structural_metadata_EnumValue | null} ENUM matcihng the specified value or null of no ENUM object was found.\n */\nfunction getEnumByValue(\n enumEntry: GLTF_EXT_structural_metadata_Enum,\n value: number\n): GLTF_EXT_structural_metadata_EnumValue | null {\n for (const enumValue of enumEntry.values) {\n if (enumValue.value === value) {\n return enumValue;\n }\n }\n\n return null;\n}\n"],"mappings":"SAmBQA,cAAc;AAAA,SAEpBC,+BAA+B,EAC/BC,uBAAuB,EACvBC,iCAAiC,EACjCC,uBAAuB,EAEvBC,qBAAqB,EACrBC,+BAA+B,EAC/BC,4BAA4B,EAC5BC,qBAAqB;AAGvB,MAAMC,4BAA4B,GAAG,yBAAyB;AAC9D,OAAO,MAAMC,IAAI,GAAGD,4BAA4B;AAEhD,OAAO,eAAeE,MAAMA,CAACC,QAAsB,EAAEC,OAA0B,EAAiB;EAC9F,MAAMC,UAAU,GAAG,IAAId,cAAc,CAACY,QAA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ASkC,cAAcA,CACrBrB,SAA4C,EAC5CmB,KAAa,EACkC;EAC/C,KAAK,MAAMG,SAAS,IAAItB,SAAS,CAACvB,MAAM,EAAE;IACxC,IAAI6C,SAAS,CAACH,KAAK,KAAKA,KAAK,EAAE;MAC7B,OAAOG,SAAS;IAClB;EACF;EAEA,OAAO,IAAI;AACb"}
1
+ {"version":3,"file":"EXT_structural_metadata.js","names":["GLTFScenegraph","convertRawBufferToMetadataArray","getPrimitiveTextureData","primitivePropertyDataToAttributes","getArrayElementByteSize","getOffsetsForProperty","parseVariableLengthArrayNumeric","parseFixedLengthArrayNumeric","getPropertyDataString","EXT_STRUCTURAL_METADATA_NAME","name","decode","gltfData","options","scenegraph","decodeExtStructuralMetadata","_options$gltf","_options$gltf2","gltf","loadBuffers","extension","getExtension","loadImages","decodePropertyTextures","decodePropertyTables","propertyTextures","json","meshes","mesh","primitive","primitives","processPrimitivePropertyTextures","schema","schemaClasses","classes","propertyTables","schemaName","propertyTable","findPropertyTableByClass","processPropertyTable","schemaClassName","class","_primitive$extensions","primitiveExtension","extensions","primitivePropertyTextureIndices","primitivePropertyTextureIndex","propertyTexture","processPrimitivePropertyTexture","properties","dataAttributeNames","className","propertyName","_propertyTexture$prop","attributeName","textureInfoTopLevel","data","featureTextureTable","propertyData","push","_schema$classes","schemaClass","Error","numberOfElements","count","_propertyTable$proper","classProperty","propertyTableProperty","getPropertyDataFromBinarySource","valuesBufferView","values","valuesDataBytes","getTypedArrayForBufferView","arrayOffsets","getArrayOffsetsForProperty","stringOffsets","getStringOffsetsForProperty","type","getPropertyDataNumeric","getPropertyDataENUM","array","arrayOffsetType","stringOffsetType","isArray","arrayCount","elementSize","componentType","elementCount","byteLength","valuesData","length","_schema$enums","enumType","enumEntry","enums","enumValueType","valueType","parseVariableLengthArrayENUM","valuesDataBytesLength","parseFixedLengthArrayENUM","getEnumsArray","params","attributeValueArray","index","arrayOffset","arrayByteSize","typedArrayOffset","elementOffset","offset","i","BigInt64Array","BigUint64Array","value","enumObject","getEnumByValue","enumValue"],"sources":["../../../src/lib/extensions/EXT_structural_metadata.ts"],"sourcesContent":["// GLTF EXTENSION: EXT_structural_metadata\n// https://github.com/CesiumGS/glTF/blob/3d-tiles-next/extensions/2.0/Vendor/EXT_structural_metadata\n/* eslint-disable camelcase */\nimport type {BigTypedArray, TypedArray} from '@loaders.gl/schema';\nimport type {GLTF, GLTFTextureInfoMetadata, GLTFMeshPrimitive} from '../types/gltf-json-schema';\nimport type {\n GLTF_EXT_structural_metadata_Schema,\n GLTF_EXT_structural_metadata_ClassProperty,\n GLTF_EXT_structural_metadata_Enum,\n GLTF_EXT_structural_metadata_EnumValue,\n GLTF_EXT_structural_metadata_PropertyTable,\n GLTF_EXT_structural_metadata_GLTF,\n GLTF_EXT_structural_metadata_PropertyTexture,\n GLTF_EXT_structural_metadata_PropertyTable_Property,\n GLTF_EXT_structural_metadata_Primitive\n} from '../types/gltf-ext-structural-metadata-schema';\nimport type {GLTFLoaderOptions} from '../../gltf-loader';\n\nimport {GLTFScenegraph} from '../api/gltf-scenegraph';\nimport {\n convertRawBufferToMetadataArray,\n getPrimitiveTextureData,\n primitivePropertyDataToAttributes,\n getArrayElementByteSize,\n NumericComponentType,\n getOffsetsForProperty,\n parseVariableLengthArrayNumeric,\n parseFixedLengthArrayNumeric,\n getPropertyDataString\n} from './utils/3d-tiles-utils';\n\nconst EXT_STRUCTURAL_METADATA_NAME = 'EXT_structural_metadata';\nexport const name = EXT_STRUCTURAL_METADATA_NAME;\n\nexport async function decode(gltfData: {json: GLTF}, options: GLTFLoaderOptions): Promise<void> {\n const scenegraph = new GLTFScenegraph(gltfData);\n decodeExtStructuralMetadata(scenegraph, options);\n}\n\n/*\n// Example of the extension.\n// See more info at https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_structural_metadata\nconst extensions = {\n \"extensions\": {\n \"EXT_structural_metadata\": {\n \"schema\": {\n \"classes\": {\n \"tree\": {\n \"name\": \"Tree\",\n \"description\": \"Woody, perennial plant.\",\n \"properties\": {\n \"species\": {\n \"description\": \"Type of tree.\",\n \"type\": \"ENUM\",\n \"enumType\": \"speciesEnum\",\n \"required\": true\n },\n \"age\": {\n \"description\": \"The age of the tree, in years\",\n \"type\": \"SCALAR\",\n \"componentType\": \"UINT8\",\n \"required\": true\n }\n }\n }\n },\n \"enums\": {\n \"speciesEnum\": {\n \"name\": \"Species\",\n \"description\": \"An example enum for tree species.\",\n // valueType is not defined here. Default is \"UINT16\"\n \"values\": [\n { \"name\": \"Unspecified\", \"value\": 0 },\n { \"name\": \"Oak\", \"value\": 1 }\n ]\n }\n }\n },\n \"propertyTables\": [{\n \"name\": \"tree_survey_2021-09-29\",\n \"class\": \"tree\",\n \"count\": 10, // The number of elements in each property array (in `species`, in `age`).\n \"properties\": {\n \"species\": {\n \"values\": 0, // It's an index of the buffer view containing property values.\n },\n \"age\": {\n \"values\": 1\n }\n }\n }]\n }\n }\n}\n*/\n\n/**\n * Decodes feature metadata from extension.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param options - GLTFLoader options.\n */\nfunction decodeExtStructuralMetadata(scenegraph: GLTFScenegraph, options: GLTFLoaderOptions): void {\n // Decoding metadata involves buffers processing.\n // So, if buffers have not been loaded, there is no reason to process metadata.\n if (!options.gltf?.loadBuffers) {\n return;\n }\n const extension: GLTF_EXT_structural_metadata_GLTF | null = scenegraph.getExtension(\n EXT_STRUCTURAL_METADATA_NAME\n );\n if (!extension) {\n return;\n }\n\n if (options.gltf?.loadImages) {\n decodePropertyTextures(scenegraph, extension);\n }\n\n decodePropertyTables(scenegraph, extension);\n}\n\n/**\n * Processes the data stored in the textures\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param extension - Top-level extension.\n */\nfunction decodePropertyTextures(\n scenegraph: GLTFScenegraph,\n extension: GLTF_EXT_structural_metadata_GLTF\n): void {\n const propertyTextures = extension.propertyTextures;\n const json = scenegraph.gltf.json;\n if (propertyTextures && json.meshes) {\n // Iterate through all meshes/primitives.\n for (const mesh of json.meshes) {\n for (const primitive of mesh.primitives) {\n processPrimitivePropertyTextures(scenegraph, propertyTextures, primitive, extension);\n }\n }\n }\n}\n\n/**\n * Processes the data stored in the property tables.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param extension - Top-level extension.\n */\nfunction decodePropertyTables(\n scenegraph: GLTFScenegraph,\n extension: GLTF_EXT_structural_metadata_GLTF\n): void {\n const schema = extension.schema;\n if (!schema) {\n return;\n }\n const schemaClasses = schema.classes;\n const propertyTables = extension.propertyTables;\n if (schemaClasses && propertyTables) {\n for (const schemaName in schemaClasses) {\n const propertyTable = findPropertyTableByClass(propertyTables, schemaName);\n if (propertyTable) {\n processPropertyTable(scenegraph, schema, propertyTable);\n }\n }\n }\n}\n\n/**\n * Finds the property table by class name.\n * @param propertyTables - propertyTable definition taken from the top-level extension.\n * @param schemaClassName - class name in the extension schema.\n */\nfunction findPropertyTableByClass(\n propertyTables: GLTF_EXT_structural_metadata_PropertyTable[],\n schemaClassName: string\n): GLTF_EXT_structural_metadata_PropertyTable | null {\n for (const propertyTable of propertyTables) {\n if (propertyTable.class === schemaClassName) {\n return propertyTable;\n }\n }\n\n return null;\n}\n\n/**\n * Takes data from property textures reffered by the primitive.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param propertyTextures - propertyTexture definition taken from the top-level extention.\n * @param primitive - Primitive object.\n * @param extension - Top-level extension.\n */\nfunction processPrimitivePropertyTextures(\n scenegraph: GLTFScenegraph,\n propertyTextures: GLTF_EXT_structural_metadata_PropertyTexture[],\n primitive: GLTFMeshPrimitive,\n extension: GLTF_EXT_structural_metadata_GLTF\n): void {\n if (!propertyTextures) {\n return;\n }\n const primitiveExtension: GLTF_EXT_structural_metadata_Primitive = primitive.extensions?.[\n EXT_STRUCTURAL_METADATA_NAME\n ] as GLTF_EXT_structural_metadata_Primitive;\n const primitivePropertyTextureIndices = primitiveExtension?.propertyTextures;\n if (!primitivePropertyTextureIndices) {\n return;\n }\n\n for (const primitivePropertyTextureIndex of primitivePropertyTextureIndices) {\n const propertyTexture = propertyTextures[primitivePropertyTextureIndex];\n processPrimitivePropertyTexture(scenegraph, propertyTexture, primitive, extension);\n }\n}\n\n/**\n * Takes property data from the texture pointed by the primitive and appends them to `exension.data`.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param propertyTexture - propertyTexture definition taken from the top-level extension.\n * @param primitive - Primitive object.\n * @param extension - Top-level extension.\n */\nfunction processPrimitivePropertyTexture(\n scenegraph: GLTFScenegraph,\n propertyTexture: GLTF_EXT_structural_metadata_PropertyTexture,\n primitive: GLTFMeshPrimitive,\n extension: GLTF_EXT_structural_metadata_GLTF\n): void {\n if (!propertyTexture.properties) {\n return;\n }\n\n if (!extension.dataAttributeNames) {\n extension.dataAttributeNames = [];\n }\n\n /* Iterate through all properties defined in propertyTexture, e.g. \"speed\" and \"direction\":\n {\n \"class\": \"wind\",\n \"properties\": {\n \"speed\": {\n \"index\": 0,\n \"texCoord\": 0,\n \"channels\": [0]\n },\n \"direction\": {\n \"index\": 0,\n \"texCoord\": 0,\n \"channels\": [1, 2]\n }\n }\n }\n */\n const className = propertyTexture.class;\n for (const propertyName in propertyTexture.properties) {\n // propertyName has values like \"speed\", \"direction\"\n // Make attributeName as a combination of the class name and the propertyName like \"wind_speed\" or \"wind_direction\"\n const attributeName = `${className}_${propertyName}`;\n const textureInfoTopLevel: GLTFTextureInfoMetadata | undefined =\n propertyTexture.properties?.[propertyName];\n if (!textureInfoTopLevel) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n // The data taken from all meshes/primitives (the same property, e.g. \"speed\" or \"direction\") will be combined into one array and saved in textureInfoTopLevel.data\n // Initially textureInfoTopLevel.data will be initialized with an empty array.\n if (!textureInfoTopLevel.data) {\n textureInfoTopLevel.data = [];\n }\n const featureTextureTable: number[] = textureInfoTopLevel.data as number[];\n\n const propertyData: number[] | null = getPrimitiveTextureData(\n scenegraph,\n textureInfoTopLevel,\n primitive\n );\n if (propertyData === null) {\n // eslint-disable-next-line no-continue\n continue;\n }\n primitivePropertyDataToAttributes(\n scenegraph,\n attributeName,\n propertyData,\n featureTextureTable,\n primitive\n );\n textureInfoTopLevel.data = featureTextureTable;\n extension.dataAttributeNames.push(attributeName);\n }\n}\n\n/**\n * Navigates through all properies in the property table, gets properties data,\n * and put the data to `propertyTable.data` as an array.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param schema - schema object.\n * @param propertyTable - propertyTable definition taken from the top-level extension.\n */\nfunction processPropertyTable(\n scenegraph: GLTFScenegraph,\n schema: GLTF_EXT_structural_metadata_Schema,\n propertyTable: GLTF_EXT_structural_metadata_PropertyTable\n): void {\n const schemaClass = schema.classes?.[propertyTable.class];\n if (!schemaClass) {\n throw new Error(\n `Incorrect data in the EXT_structural_metadata extension: no schema class with name ${propertyTable.class}`\n );\n }\n\n const numberOfElements = propertyTable.count; // `propertyTable.count` is a number of elements in each property array.\n\n for (const propertyName in schemaClass.properties) {\n const classProperty = schemaClass.properties[propertyName];\n const propertyTableProperty: GLTF_EXT_structural_metadata_PropertyTable_Property | undefined =\n propertyTable.properties?.[propertyName];\n\n if (propertyTableProperty) {\n // Getting all elements (`numberOfElements`) of the array in the `propertyTableProperty`\n const data = getPropertyDataFromBinarySource(\n scenegraph,\n schema,\n classProperty,\n numberOfElements,\n propertyTableProperty\n );\n propertyTableProperty.data = data;\n }\n }\n}\n\n/**\n * Decodes a propertyTable column from binary source based on property type.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param schema - Schema object.\n * @param classProperty - class property object.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @param propertyTableProperty - propertyTable's property metadata.\n * @returns {string[] | number[] | string[][] | number[][]}\n */\nfunction getPropertyDataFromBinarySource(\n scenegraph: GLTFScenegraph,\n schema: GLTF_EXT_structural_metadata_Schema,\n classProperty: GLTF_EXT_structural_metadata_ClassProperty,\n numberOfElements: number,\n propertyTableProperty: GLTF_EXT_structural_metadata_PropertyTable_Property\n): string[] | BigTypedArray | string[][] | BigTypedArray[] {\n let data: string[] | BigTypedArray | string[][] | BigTypedArray[] = [];\n const valuesBufferView = propertyTableProperty.values;\n const valuesDataBytes: Uint8Array = scenegraph.getTypedArrayForBufferView(valuesBufferView);\n\n const arrayOffsets = getArrayOffsetsForProperty(\n scenegraph,\n classProperty,\n propertyTableProperty,\n numberOfElements\n );\n const stringOffsets = getStringOffsetsForProperty(\n scenegraph,\n propertyTableProperty,\n numberOfElements\n );\n\n switch (classProperty.type) {\n case 'SCALAR':\n case 'VEC2':\n case 'VEC3':\n case 'VEC4':\n case 'MAT2':\n case 'MAT3':\n case 'MAT4': {\n data = getPropertyDataNumeric(classProperty, numberOfElements, valuesDataBytes, arrayOffsets);\n break;\n }\n case 'BOOLEAN': {\n // TODO: implement it as soon as we have the corresponding tileset\n throw new Error(`Not implemented - classProperty.type=${classProperty.type}`);\n }\n case 'STRING': {\n data = getPropertyDataString(numberOfElements, valuesDataBytes, arrayOffsets, stringOffsets);\n break;\n }\n case 'ENUM': {\n data = getPropertyDataENUM(\n schema,\n classProperty,\n numberOfElements,\n valuesDataBytes,\n arrayOffsets\n );\n break;\n }\n default:\n throw new Error(`Unknown classProperty type ${classProperty.type}`);\n }\n\n return data;\n}\n\n/**\n * Parses propertyTable.property.arrayOffsets that are offsets of sub-arrays in a flatten array of values.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param classProperty - class property object.\n * @param propertyTableProperty - propertyTable's property metadata.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @returns Typed array with offset values.\n * @see https://github.com/CesiumGS/glTF/blob/2976f1183343a47a29e4059a70961371cd2fcee8/extensions/2.0/Vendor/EXT_structural_metadata/schema/propertyTable.property.schema.json#L21\n */\nfunction getArrayOffsetsForProperty(\n scenegraph: GLTFScenegraph,\n classProperty: GLTF_EXT_structural_metadata_ClassProperty,\n propertyTableProperty: GLTF_EXT_structural_metadata_PropertyTable_Property,\n numberOfElements: number\n): TypedArray | null {\n if (\n classProperty.array &&\n // `count` is a number of array elements. May only be defined when `array` is true.\n // If `count` is NOT defined, it's a VARIABLE-length array\n typeof classProperty.count === 'undefined' &&\n // `arrayOffsets` is an index of the buffer view containing offsets for variable-length arrays.\n typeof propertyTableProperty.arrayOffsets !== 'undefined'\n ) {\n // Data are in a VARIABLE-length array\n return getOffsetsForProperty(\n scenegraph,\n propertyTableProperty.arrayOffsets,\n propertyTableProperty.arrayOffsetType || 'UINT32',\n numberOfElements\n );\n }\n return null;\n}\n\n/**\n * Parses propertyTable.property.stringOffsets.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param propertyTableProperty - propertyTable's property metadata.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @returns Typed array with offset values.\n * @see https://github.com/CesiumGS/glTF/blob/2976f1183343a47a29e4059a70961371cd2fcee8/extensions/2.0/Vendor/EXT_structural_metadata/schema/propertyTable.property.schema.json#L29C10-L29C23\n */\nfunction getStringOffsetsForProperty(\n scenegraph: GLTFScenegraph,\n propertyTableProperty: GLTF_EXT_structural_metadata_PropertyTable_Property,\n numberOfElements: number\n): TypedArray | null {\n if (\n typeof propertyTableProperty.stringOffsets !== 'undefined' // `stringOffsets` is an index of the buffer view containing offsets for strings.\n ) {\n // Data are in a FIXED-length array\n return getOffsetsForProperty(\n scenegraph,\n propertyTableProperty.stringOffsets,\n propertyTableProperty.stringOffsetType || 'UINT32',\n numberOfElements\n );\n }\n return null;\n}\n\n/**\n * Decodes properties of SCALAR, VEC-N, MAT-N types from binary sourse.\n * @param classProperty - class property object.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @param valuesDataBytes - Data taken from values property of the property table property.\n * @param arrayOffsets - Offsets for variable-length arrays. It's null for fixed-length arrays or scalar types.\n * @returns Property values in a typed array or in an array of typed arrays.\n */\nfunction getPropertyDataNumeric(\n classProperty: GLTF_EXT_structural_metadata_ClassProperty,\n numberOfElements: number,\n valuesDataBytes: Uint8Array,\n arrayOffsets: TypedArray | null\n): BigTypedArray | BigTypedArray[] {\n const isArray = classProperty.array;\n const arrayCount = classProperty.count;\n\n const elementSize = getArrayElementByteSize(classProperty.type, classProperty.componentType);\n const elementCount = valuesDataBytes.byteLength / elementSize;\n\n let valuesData: BigTypedArray;\n if (classProperty.componentType) {\n valuesData = convertRawBufferToMetadataArray(\n valuesDataBytes,\n classProperty.type,\n // The datatype of the element's components. Only applicable to `SCALAR`, `VECN`, and `MATN` types.\n classProperty.componentType as NumericComponentType,\n elementCount\n );\n } else {\n // The spec doesn't provide any info what to do if componentType is not set.\n valuesData = valuesDataBytes;\n }\n\n if (isArray) {\n if (arrayOffsets) {\n // VARIABLE-length array\n return parseVariableLengthArrayNumeric(\n valuesData,\n numberOfElements,\n arrayOffsets,\n valuesDataBytes.length,\n elementSize\n );\n }\n if (arrayCount) {\n // FIXED-length array\n return parseFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount);\n }\n return [];\n }\n\n return valuesData;\n}\n\n/**\n * Decodes properties of enum type from binary source.\n * @param schema - Schema object.\n * @param classProperty - Class property object.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @param valuesDataBytes - Data taken from values property of the property table property.\n * @param arrayOffsets - Offsets for variable-length arrays. It's null for fixed-length arrays or scalar types.\n * @returns Strings array of nested strings array.\n */\nfunction getPropertyDataENUM(\n schema: GLTF_EXT_structural_metadata_Schema,\n classProperty: GLTF_EXT_structural_metadata_ClassProperty,\n numberOfElements: number,\n valuesDataBytes: Uint8Array,\n arrayOffsets: TypedArray | null\n): string[] | string[][] {\n const enumType = classProperty.enumType;\n // Enum ID as declared in the `enums` dictionary. Required when `type` is `ENUM`.\n if (!enumType) {\n throw new Error(\n 'Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM'\n );\n }\n\n const enumEntry: GLTF_EXT_structural_metadata_Enum | undefined = schema.enums?.[enumType];\n if (!enumEntry) {\n throw new Error(\n `Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${enumType}`\n );\n }\n\n const enumValueType = enumEntry.valueType || 'UINT16';\n const elementSize = getArrayElementByteSize(classProperty.type, enumValueType);\n const elementCount = valuesDataBytes.byteLength / elementSize;\n let valuesData: BigTypedArray | null = convertRawBufferToMetadataArray(\n valuesDataBytes,\n classProperty.type,\n enumValueType,\n elementCount\n );\n if (!valuesData) {\n valuesData = valuesDataBytes;\n }\n\n if (classProperty.array) {\n if (arrayOffsets) {\n // VARIABLE-length array\n return parseVariableLengthArrayENUM({\n valuesData,\n numberOfElements,\n arrayOffsets,\n valuesDataBytesLength: valuesDataBytes.length,\n elementSize,\n enumEntry\n });\n }\n\n const arrayCount = classProperty.count;\n if (arrayCount) {\n // FIXED-length array\n return parseFixedLengthArrayENUM(valuesData, numberOfElements, arrayCount, enumEntry);\n }\n return [];\n }\n\n // Single value (not an array)\n return getEnumsArray(valuesData, 0, numberOfElements, enumEntry);\n}\n\n/**\n * Parses variable length nested ENUM arrays.\n * @param params.valuesData - Values in a flat typed array.\n * @param params.numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @param params.arrayOffsets - Offsets for variable-length arrays. It's null for fixed-length arrays or scalar types.\n * @param params.valuesDataBytesLength - Byte length of values array.\n * @param params.elementSize - Single element byte size.\n * @param params.enumEntry - Enums dictionary.\n * @returns Nested strings array.\n */\nfunction parseVariableLengthArrayENUM(params: {\n valuesData: BigTypedArray;\n numberOfElements: number;\n arrayOffsets: TypedArray;\n valuesDataBytesLength: number;\n elementSize: number;\n enumEntry: GLTF_EXT_structural_metadata_Enum;\n}): string[][] {\n const {\n valuesData,\n numberOfElements,\n arrayOffsets,\n valuesDataBytesLength,\n elementSize,\n enumEntry\n } = params;\n const attributeValueArray: string[][] = [];\n for (let index = 0; index < numberOfElements; index++) {\n const arrayOffset = arrayOffsets[index];\n const arrayByteSize = arrayOffsets[index + 1] - arrayOffsets[index];\n if (arrayByteSize + arrayOffset > valuesDataBytesLength) {\n break;\n }\n\n const typedArrayOffset = arrayOffset / elementSize;\n const elementCount = arrayByteSize / elementSize;\n const array: string[] = getEnumsArray(valuesData, typedArrayOffset, elementCount, enumEntry);\n attributeValueArray.push(array);\n }\n return attributeValueArray;\n}\n\n/**\n * Parses fixed length ENUM arrays.\n * @param valuesData - Values in a flat typed array.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @param arrayCount - Nested arrays length.\n * @param enumEntry - Enums dictionary.\n * @returns Nested strings array.\n */\nfunction parseFixedLengthArrayENUM(\n valuesData: BigTypedArray,\n numberOfElements: number,\n arrayCount: number,\n enumEntry: GLTF_EXT_structural_metadata_Enum\n): string[][] {\n const attributeValueArray: string[][] = [];\n for (let index = 0; index < numberOfElements; index++) {\n const elementOffset = arrayCount * index;\n const array: string[] = getEnumsArray(valuesData, elementOffset, arrayCount, enumEntry);\n attributeValueArray.push(array);\n }\n return attributeValueArray;\n}\n\n/**\n * Parses ENUM values into a string array.\n * @param valuesData - Values in a flat typed array.\n * @param offset - Offset to start parse from.\n * @param count - Values length to parse.\n * @param enumEntry - Enums dictionary.\n * @returns Array of strings with parsed ENUM names.\n */\nfunction getEnumsArray(\n valuesData: BigTypedArray,\n offset: number,\n count: number,\n enumEntry: GLTF_EXT_structural_metadata_Enum\n): string[] {\n const array: string[] = [];\n for (let i = 0; i < count; i++) {\n // At the moment we don't support BigInt. It requires additional calculations logic\n // and might be an issue in Safari\n if (valuesData instanceof BigInt64Array || valuesData instanceof BigUint64Array) {\n array.push('');\n } else {\n const value = valuesData[offset + i];\n\n const enumObject = getEnumByValue(enumEntry, value);\n if (enumObject) {\n array.push(enumObject.name);\n } else {\n array.push('');\n }\n }\n }\n return array;\n}\n\n/**\n * Looks up ENUM whose `value` property matches the specified number in the parameter `value`.\n * @param {GLTF_EXT_structural_metadata_Enum} enumEntry - ENUM entry containing the array of possible enums.\n * @param {number} value - The value of the ENUM to locate.\n * @returns {GLTF_EXT_structural_metadata_EnumValue | null} ENUM matcihng the specified value or null of no ENUM object was found.\n */\nfunction getEnumByValue(\n enumEntry: GLTF_EXT_structural_metadata_Enum,\n value: number\n): GLTF_EXT_structural_metadata_EnumValue | null {\n for (const enumValue of enumEntry.values) {\n if (enumValue.value === value) {\n return enumValue;\n }\n }\n\n return null;\n}\n"],"mappings":"SAkBQA,cAAc;AAAA,SAEpBC,+BAA+B,EAC/BC,uBAAuB,EACvBC,iCAAiC,EACjCC,uBAAuB,EAEvBC,qBAAqB,EACrBC,+BAA+B,EAC/BC,4BAA4B,EAC5BC,qBAAqB;AAGvB,MAAMC,4BAA4B,GAAG,yBAAyB;AAC9D,OAAO,MAAMC,IAAI,GAAGD,4BAA4B;AAEhD,OAAO,eAAeE,MAAMA,CAACC,QAAsB,EAAEC,OAA0B,EAAiB;EAC9F,MAAMC,UAAU,GAAG,IAAId,cAAc,CAACY,QAAQ,CAAC;EAC/CG,2BAA2B,CAACD,UAAU,EAAED,OAAO,CAAC;AAClD;AAgEA,SAASE,2BAA2BA,CAACD,UAA0B,EAAED,OAA0B,EAAQ;EAAA,IAAAG,aAAA,EAAAC,cAAA;EAGjG,IAAI,GAAAD,aAAA,GAACH,OAAO,CAACK,IAAI,cAAAF,aAAA,eAAZA,aAAA,CAAcG,WAAW,GAAE;IAC9B;EACF;EACA,MAAMC,SAAmD,GAAGN,UAAU,CAACO,YAAY,CACjFZ,4BACF,CAAC;EACD,IAAI,CAACW,SAAS,EAAE;IACd;EACF;EAEA,KAAAH,cAAA,GAAIJ,OAAO,CAACK,IAAI,cAAAD,cAAA,eAAZA,cAAA,CAAcK,UAAU,EAAE;IAC5BC,sBAAsB,CAACT,UAAU,EAAEM,SAAS,CAAC;EAC/C;EAEAI,oBAAoB,CAACV,UAAU,EAAEM,SAAS,CAAC;AAC7C;AAOA,SAASG,sBAAsBA,CAC7BT,UAA0B,EAC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,EAAEwC,KAAK,EAAE,EAAE;IACrD,MAAMI,aAAa,GAAGvB,UAAU,GAAGmB,KAAK;IACxC,MAAMvB,KAAe,GAAGoB,aAAa,CAACX,UAAU,EAAEkB,aAAa,EAAEvB,UAAU,EAAES,SAAS,CAAC;IACvFS,mBAAmB,CAAC3C,IAAI,CAACqB,KAAK,CAAC;EACjC;EACA,OAAOsB,mBAAmB;AAC5B;AAUA,SAASF,aAAaA,CACpBX,UAAyB,EACzBmB,MAAc,EACd5C,KAAa,EACb6B,SAA4C,EAClC;EACV,MAAMb,KAAe,GAAG,EAAE;EAC1B,KAAK,IAAI6B,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAG7C,KAAK,EAAE6C,CAAC,EAAE,EAAE;IAG9B,IAAIpB,UAAU,YAAYqB,aAAa,IAAIrB,UAAU,YAAYsB,cAAc,EAAE;MAC/E/B,KAAK,CAACrB,IAAI,CAAC,EAAE,CAAC;IAChB,CAAC,MAAM;MACL,MAAMqD,KAAK,GAAGvB,UAAU,CAACmB,MAAM,GAAGC,CAAC,CAAC;MAEpC,MAAMI,UAAU,GAAGC,cAAc,CAACrB,SAAS,EAAEmB,KAAK,CAAC;MACnD,IAAIC,UAAU,EAAE;QACdjC,KAAK,CAACrB,IAAI,CAACsD,UAAU,CAACvG,IAAI,CAAC;MAC7B,CAAC,MAAM;QACLsE,KAAK,CAACrB,IAAI,CAAC,EAAE,CAAC;MAChB;IACF;EACF;EACA,OAAOqB,KAAK;AACd;AAQA,SAASkC,cAAcA,CACrBrB,SAA4C,EAC5CmB,KAAa,EACkC;EAC/C,KAAK,MAAMG,SAAS,IAAItB,SAAS,CAACvB,MAAM,EAAE;IACxC,IAAI6C,SAAS,CAACH,KAAK,KAAKA,KAAK,EAAE;MAC7B,OAAOG,SAAS;IAClB;EACF;EAEA,OAAO,IAAI;AACb"}
@@ -1,16 +1,7 @@
1
1
  import type { GLTF } from '../../types/gltf-json-schema';
2
- import type { GLTF_EXT_feature_metadata_GLTF } from '../../types/gltf-ext-feature-metadata-schema';
3
- import type { FeatureTableJson } from '../../types/gltf-types';
4
2
  import { GLTFLoaderOptions } from '../../../gltf-loader';
5
3
  export declare const name = "EXT_feature_metadata";
6
4
  export declare function decode(gltfData: {
7
5
  json: GLTF;
8
6
  }, options: GLTFLoaderOptions): Promise<void>;
9
- /**
10
- * Handles EXT_feature_metadata to get property table.
11
- * @param extension - Global level of EXT_FEATURE_METADATA extension.
12
- * @param metadataClass - User selected feature metadata class name.
13
- * @returns {FeatureTableJson | null} Property table or null if the extension can't be handled properly.
14
- */
15
- export declare function getPropertyTableFromExtFeatureMetadata(extension: GLTF_EXT_feature_metadata_GLTF, metadataClass?: string): FeatureTableJson | null;
16
7
  //# sourceMappingURL=EXT_feature_metadata.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EXT_feature_metadata.d.ts","sourceRoot":"","sources":["../../../../src/lib/extensions/deprecated/EXT_feature_metadata.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,IAAI,EAA0B,MAAM,8BAA8B,CAAC;AAChF,OAAO,KAAK,EAMV,8BAA8B,EAG/B,MAAM,8CAA8C,CAAC;AAEtD,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AAG7D,OAAO,EAAC,iBAAiB,EAAC,MAAM,sBAAsB,CAAC;AAevD,eAAO,MAAM,IAAI,yBAA4B,CAAC;AAE9C,wBAAsB,MAAM,CAAC,QAAQ,EAAE;IAAC,IAAI,EAAE,IAAI,CAAA;CAAC,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAG9F;AAED;;;;;GAKG;AACH,wBAAgB,sCAAsC,CACpD,SAAS,EAAE,8BAA8B,EACzC,aAAa,CAAC,EAAE,MAAM,GACrB,gBAAgB,GAAG,IAAI,CAgDzB"}
1
+ {"version":3,"file":"EXT_feature_metadata.d.ts","sourceRoot":"","sources":["../../../../src/lib/extensions/deprecated/EXT_feature_metadata.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,IAAI,EAA0B,MAAM,8BAA8B,CAAC;AAchF,OAAO,EAAC,iBAAiB,EAAC,MAAM,sBAAsB,CAAC;AAevD,eAAO,MAAM,IAAI,yBAA4B,CAAC;AAE9C,wBAAsB,MAAM,CAAC,QAAQ,EAAE;IAAC,IAAI,EAAE,IAAI,CAAA;CAAC,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAG9F"}
@@ -6,39 +6,6 @@ export async function decode(gltfData, options) {
6
6
  const scenegraph = new GLTFScenegraph(gltfData);
7
7
  decodeExtFeatureMetadata(scenegraph, options);
8
8
  }
9
- export function getPropertyTableFromExtFeatureMetadata(extension, metadataClass) {
10
- if (extension.featureTables) {
11
- var _Object$keys;
12
- const firstFeatureTableName = (_Object$keys = Object.keys(extension.featureTables)) === null || _Object$keys === void 0 ? void 0 : _Object$keys[0];
13
- if (firstFeatureTableName) {
14
- const featureTable = extension.featureTables[firstFeatureTableName];
15
- const propertyTable = {};
16
- for (const propertyName in featureTable.properties) {
17
- propertyTable[propertyName] = featureTable.properties[propertyName].data;
18
- }
19
- return propertyTable;
20
- }
21
- }
22
- if (extension.featureTextures) {
23
- let featureTexture;
24
- for (const textureKey in extension.featureTextures) {
25
- const texture = extension.featureTextures[textureKey];
26
- if (texture.class === metadataClass) {
27
- featureTexture = textureKey;
28
- }
29
- }
30
- if (typeof featureTexture === 'string') {
31
- const featureTable = extension.featureTextures[featureTexture];
32
- const propertyTable = {};
33
- for (const propertyName in featureTable.properties) {
34
- propertyTable[propertyName] = featureTable.properties[propertyName].data;
35
- }
36
- return propertyTable;
37
- }
38
- }
39
- console.warn('Cannot get property table from EXT_feature_metadata extension. There is neither featureTables, nor featureTextures in the extension.');
40
- return null;
41
- }
42
9
  function decodeExtFeatureMetadata(scenegraph, options) {
43
10
  var _options$gltf, _options$gltf2;
44
11
  if (!((_options$gltf = options.gltf) !== null && _options$gltf !== void 0 && _options$gltf.loadBuffers)) {
@@ -1 +1 @@
1
- {"version":3,"file":"EXT_feature_metadata.js","names":["GLTFScenegraph","convertRawBufferToMetadataArray","getPrimitiveTextureData","primitivePropertyDataToAttributes","getArrayElementByteSize","getOffsetsForProperty","parseVariableLengthArrayNumeric","parseFixedLengthArrayNumeric","getPropertyDataString","EXT_FEATURE_METADATA_NAME","name","decode","gltfData","options","scenegraph","decodeExtFeatureMetadata","getPropertyTableFromExtFeatureMetadata","extension","metadataClass","featureTables","_Object$keys","firstFeatureTableName","Object","keys","featureTable","propertyTable","propertyName","properties","data","featureTextures","featureTexture","textureKey","texture","class","console","warn","_options$gltf","_options$gltf2","gltf","loadBuffers","getExtension","loadImages","decodePropertyTextures","decodePropertyTables","schema","schemaClasses","classes","schemaName","schemaClass","findFeatureTextureByClass","handleFeatureTextureProperties","propertyTables","findPropertyTableByClass","processPropertyTable","schemaClassName","propertyTableName","featureTexturesName","_schema$classes","Error","numberOfElements","count","_propertyTable$proper","classProperty","propertyTableProperty","getPropertyDataFromBinarySource","attributeName","_featureTexture$prope","featureTextureProperty","getPropertyDataFromTexture","numberOfFeatures","featureTableProperty","bufferView","dataArray","getTypedArrayForBufferView","arrayOffsets","getArrayOffsetsForProperty","stringOffsets","getStringOffsetsForProperty","type","componentType","isNumericProperty","getPropertyDataNumeric","componentCount","arrayOffsetBufferView","offsetType","stringOffsetBufferView","schemaProperty","types","includes","valuesDataBytes","isArray","arrayCount","attributeType","elementSize","elementCount","byteLength","valuesData","length","json","meshes","featureTextureTable","mesh","primitive","primitives","processPrimitiveTextures","textureInfoTopLevel","channels","propertyData"],"sources":["../../../../src/lib/extensions/deprecated/EXT_feature_metadata.ts"],"sourcesContent":["/* eslint-disable camelcase */\nimport type {GLTF, GLTFTextureInfoMetadata} from '../../types/gltf-json-schema';\nimport type {\n GLTF_EXT_feature_metadata_Class,\n GLTF_EXT_feature_metadata_ClassProperty,\n GLTF_EXT_feature_metadata_FeatureTable,\n GLTF_EXT_feature_metadata_FeatureTableProperty,\n GLTF_EXT_feature_metadata_FeatureTexture,\n GLTF_EXT_feature_metadata_GLTF,\n GLTF_EXT_feature_metadata_TextureAccessor,\n GLTF_EXT_feature_metadata_Schema\n} from '../../types/gltf-ext-feature-metadata-schema';\nimport type {BigTypedArray, TypedArray} from '@loaders.gl/schema';\nimport type {FeatureTableJson} from '../../types/gltf-types';\nimport {GLTFScenegraph} from '../../api/gltf-scenegraph';\nimport {GLTFMeshPrimitive} from '../../types/gltf-json-schema';\nimport {GLTFLoaderOptions} from '../../../gltf-loader';\nimport {\n convertRawBufferToMetadataArray,\n getPrimitiveTextureData,\n primitivePropertyDataToAttributes,\n getArrayElementByteSize,\n NumericComponentType,\n getOffsetsForProperty,\n parseVariableLengthArrayNumeric,\n parseFixedLengthArrayNumeric,\n getPropertyDataString\n} from '../utils/3d-tiles-utils';\n\n/** Extension name */\nconst EXT_FEATURE_METADATA_NAME = 'EXT_feature_metadata';\nexport const name = EXT_FEATURE_METADATA_NAME;\n\nexport async function decode(gltfData: {json: GLTF}, options: GLTFLoaderOptions): Promise<void> {\n const scenegraph = new GLTFScenegraph(gltfData);\n decodeExtFeatureMetadata(scenegraph, options);\n}\n\n/**\n * Handles EXT_feature_metadata to get property table.\n * @param extension - Global level of EXT_FEATURE_METADATA extension.\n * @param metadataClass - User selected feature metadata class name.\n * @returns {FeatureTableJson | null} Property table or null if the extension can't be handled properly.\n */\nexport function getPropertyTableFromExtFeatureMetadata(\n extension: GLTF_EXT_feature_metadata_GLTF,\n metadataClass?: string\n): FeatureTableJson | null {\n if (extension.featureTables) {\n /**\n * Take only first feature table to generate attributes storage info object.\n * TODO: Think about getting data from all feature tables?\n * It can be tricky just because 3dTiles is able to have multiple featureId attributes and multiple feature tables.\n * In I3S we should decide which featureIds attribute will be passed to geometry data.\n */\n const firstFeatureTableName = Object.keys(extension.featureTables)?.[0];\n\n if (firstFeatureTableName) {\n const featureTable = extension.featureTables[firstFeatureTableName];\n const propertyTable = {};\n\n for (const propertyName in featureTable.properties) {\n propertyTable[propertyName] = featureTable.properties[propertyName].data;\n }\n\n return propertyTable;\n }\n }\n\n if (extension.featureTextures) {\n let featureTexture: string | undefined;\n for (const textureKey in extension.featureTextures) {\n const texture = extension.featureTextures[textureKey];\n if (texture.class === metadataClass) {\n featureTexture = textureKey;\n }\n }\n\n if (typeof featureTexture === 'string') {\n const featureTable = extension.featureTextures[featureTexture];\n const propertyTable = {};\n\n for (const propertyName in featureTable.properties) {\n propertyTable[propertyName] = featureTable.properties[propertyName].data;\n }\n\n return propertyTable;\n }\n }\n\n // eslint-disable-next-line no-console\n console.warn(\n 'Cannot get property table from EXT_feature_metadata extension. There is neither featureTables, nor featureTextures in the extension.'\n );\n return null;\n}\n\n/**\n * Decodes feature metadata from extension.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param options - GLTFLoader options.\n */\nfunction decodeExtFeatureMetadata(scenegraph: GLTFScenegraph, options: GLTFLoaderOptions): void {\n // Decoding metadata involves buffers processing.\n // So, if buffers have not been loaded, there is no reason to process metadata.\n if (!options.gltf?.loadBuffers) {\n return;\n }\n const extension: GLTF_EXT_feature_metadata_GLTF | null =\n scenegraph.getExtension(EXT_FEATURE_METADATA_NAME);\n if (!extension) {\n return;\n }\n\n if (options.gltf?.loadImages) {\n decodePropertyTextures(scenegraph, extension);\n }\n\n decodePropertyTables(scenegraph, extension);\n}\n\n/**\n * Processes the data stored in the textures\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param extension - Top-level extension.\n */\nfunction decodePropertyTextures(\n scenegraph: GLTFScenegraph,\n extension: GLTF_EXT_feature_metadata_GLTF\n): void {\n const schema = extension.schema;\n if (!schema) {\n return;\n }\n const schemaClasses = schema.classes;\n\n const {featureTextures} = extension;\n if (schemaClasses && featureTextures) {\n for (const schemaName in schemaClasses) {\n const schemaClass = schemaClasses[schemaName];\n const featureTexture = findFeatureTextureByClass(featureTextures, schemaName);\n\n if (featureTexture) {\n handleFeatureTextureProperties(scenegraph, featureTexture, schemaClass);\n }\n }\n }\n}\n\n/**\n * Processes the data stored in the property tables.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param extension - Top-level extension.\n */\nfunction decodePropertyTables(\n scenegraph: GLTFScenegraph,\n extension: GLTF_EXT_feature_metadata_GLTF\n): void {\n const schema = extension.schema;\n if (!schema) {\n return;\n }\n const schemaClasses = schema.classes;\n const propertyTables = extension.featureTables;\n if (schemaClasses && propertyTables) {\n for (const schemaName in schemaClasses) {\n const propertyTable = findPropertyTableByClass(propertyTables, schemaName);\n if (propertyTable) {\n processPropertyTable(scenegraph, schema, propertyTable);\n }\n }\n }\n}\n\n/**\n * Finds the property table by class name.\n * @param propertyTables - propertyTable definition taken from the top-level extension.\n * @param schemaClassName - class name in the extension schema.\n */\nfunction findPropertyTableByClass(\n propertyTables: {[key: string]: GLTF_EXT_feature_metadata_FeatureTable},\n schemaClassName: string\n): GLTF_EXT_feature_metadata_FeatureTable | null {\n for (const propertyTableName in propertyTables) {\n const propertyTable = propertyTables[propertyTableName];\n if (propertyTable.class === schemaClassName) {\n return propertyTable;\n }\n }\n\n return null;\n}\n\nfunction findFeatureTextureByClass(\n featureTextures: {[key: string]: GLTF_EXT_feature_metadata_FeatureTexture},\n schemaClassName: string\n): GLTF_EXT_feature_metadata_FeatureTexture | null {\n for (const featureTexturesName in featureTextures) {\n const featureTable = featureTextures[featureTexturesName];\n\n if (featureTable.class === schemaClassName) {\n return featureTable;\n }\n }\n\n return null;\n}\n\n/**\n * Navigates through all properies in the property table, gets properties data,\n * and put the data to `propertyTable.data` as an array.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param schema - schema object.\n * @param propertyTable - propertyTable definition taken from the top-level extension.\n */\nfunction processPropertyTable(\n scenegraph: GLTFScenegraph,\n schema: GLTF_EXT_feature_metadata_Schema,\n propertyTable: GLTF_EXT_feature_metadata_FeatureTable\n): void {\n // Though 'class' is not required by spec, it doesn't make any scence when it's not provided.\n // So, bale out here.\n if (!propertyTable.class) {\n return;\n }\n\n const schemaClass = schema.classes?.[propertyTable.class];\n if (!schemaClass) {\n throw new Error(\n `Incorrect data in the EXT_structural_metadata extension: no schema class with name ${propertyTable.class}`\n );\n }\n\n const numberOfElements = propertyTable.count; // `propertyTable.count` is a number of elements in each property array.\n\n for (const propertyName in schemaClass.properties) {\n const classProperty = schemaClass.properties[propertyName];\n const propertyTableProperty: GLTF_EXT_feature_metadata_FeatureTableProperty | undefined =\n propertyTable.properties?.[propertyName];\n\n if (propertyTableProperty) {\n // Getting all elements (`numberOfElements`) of the array in the `propertyTableProperty`\n const data = getPropertyDataFromBinarySource(\n scenegraph,\n schema,\n classProperty,\n numberOfElements,\n propertyTableProperty\n );\n propertyTableProperty.data = data;\n }\n }\n}\n\n/**\n * Navigates through all properies in feature texture and gets properties data.\n * Data will be stored in featureTexture.properties[propertyName].data.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param featureTexture\n * @param schemaClass\n */\nfunction handleFeatureTextureProperties(\n scenegraph: GLTFScenegraph,\n featureTexture: GLTF_EXT_feature_metadata_FeatureTexture,\n schemaClass: GLTF_EXT_feature_metadata_Class\n): void {\n const attributeName = featureTexture.class;\n\n for (const propertyName in schemaClass.properties) {\n const featureTextureProperty = featureTexture?.properties?.[propertyName];\n\n if (featureTextureProperty) {\n const data = getPropertyDataFromTexture(scenegraph, featureTextureProperty, attributeName);\n featureTextureProperty.data = data;\n }\n }\n}\n\n/**\n * Decodes properties from binary sourse based on property type.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param schemaProperty\n * @param numberOfFeatures\n * @param featureTableProperty\n */\nfunction getPropertyDataFromBinarySource(\n scenegraph: GLTFScenegraph,\n schema: GLTF_EXT_feature_metadata_Schema,\n classProperty: GLTF_EXT_feature_metadata_ClassProperty,\n numberOfFeatures: number,\n featureTableProperty: GLTF_EXT_feature_metadata_FeatureTableProperty\n): string[] | BigTypedArray | string[][] | BigTypedArray[] {\n let data: string[] | BigTypedArray | string[][] | BigTypedArray[] = [];\n const bufferView = featureTableProperty.bufferView;\n const dataArray: Uint8Array = scenegraph.getTypedArrayForBufferView(bufferView);\n\n const arrayOffsets = getArrayOffsetsForProperty(\n scenegraph,\n classProperty,\n featureTableProperty,\n numberOfFeatures\n );\n const stringOffsets = getStringOffsetsForProperty(\n scenegraph,\n classProperty,\n featureTableProperty,\n numberOfFeatures\n );\n\n if (classProperty.type === 'STRING' || classProperty.componentType === 'STRING') {\n data = getPropertyDataString(numberOfFeatures, dataArray, arrayOffsets, stringOffsets);\n } else if (isNumericProperty(classProperty)) {\n data = getPropertyDataNumeric(classProperty, numberOfFeatures, dataArray, arrayOffsets);\n }\n\n return data;\n}\n\n/**\n * Parses propertyTable.property.arrayOffsets that are offsets of sub-arrays in a flatten array of values.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param classProperty - class property object.\n * @param propertyTableProperty - propertyTable's property metadata.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @returns Typed array with offset values.\n * @see https://github.com/CesiumGS/glTF/blob/2976f1183343a47a29e4059a70961371cd2fcee8/extensions/2.0/Vendor/EXT_structural_metadata/schema/propertyTable.property.schema.json#L21\n */\nfunction getArrayOffsetsForProperty(\n scenegraph: GLTFScenegraph,\n classProperty: GLTF_EXT_feature_metadata_ClassProperty,\n propertyTableProperty: GLTF_EXT_feature_metadata_FeatureTableProperty,\n numberOfElements: number\n): TypedArray | null {\n /*\n If ARRAY is used, then componentType must also be specified.\n ARRAY is a fixed-length array when componentCount is defined, and variable-length otherwise.\n*/\n if (\n classProperty.type === 'ARRAY' &&\n // `componentCount` is a number of fixed-length array elements.\n // If `componentCount` is NOT defined, it's a VARIABLE-length array\n typeof classProperty.componentCount === 'undefined' &&\n // `arrayOffsetBufferView` is an index of the buffer view containing offsets for variable-length arrays.\n typeof propertyTableProperty.arrayOffsetBufferView !== 'undefined'\n ) {\n // Data are in a VARIABLE-length array\n return getOffsetsForProperty(\n scenegraph,\n propertyTableProperty.arrayOffsetBufferView,\n propertyTableProperty.offsetType || 'UINT32', // offsetType is used both for stringOffsetBufferView and arrayOffsetBufferView\n numberOfElements\n );\n }\n return null;\n}\n\n/**\n * Parses featureTable.property.stringOffsetBufferView.\n * String offsets is an array of offsets of strings in the united array of characters.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param propertyTableProperty - propertyTable's property metadata.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @returns Typed array of offset values. The number of offsets in the array is equal to `numberOfElements` plus one.\n * @see https://github.com/CesiumGS/glTF/blob/c38f7f37e894004353c15cd0481bc5b7381ce841/extensions/2.0/Vendor/EXT_feature_metadata/schema/featureTable.property.schema.json#L50C10-L50C32\n */\nfunction getStringOffsetsForProperty(\n scenegraph: GLTFScenegraph,\n classProperty: GLTF_EXT_feature_metadata_ClassProperty,\n propertyTableProperty: GLTF_EXT_feature_metadata_FeatureTableProperty,\n numberOfElements: number\n): TypedArray | null {\n if (\n typeof propertyTableProperty.stringOffsetBufferView !== 'undefined' // `stringOffsetBufferView` is an index of the buffer view containing offsets for strings.\n ) {\n // Data are in a FIXED-length array\n return getOffsetsForProperty(\n scenegraph,\n propertyTableProperty.stringOffsetBufferView,\n propertyTableProperty.offsetType || 'UINT32', // offsetType is used both for stringOffsetBufferView and arrayOffsetBufferView\n numberOfElements\n );\n }\n return null;\n}\n\n/**\n * Checks if the feature table property is of numeric type.\n * @param schemaPropertyType - feature table property\n * @returns true if property is numeric, else - false\n */\nfunction isNumericProperty(schemaProperty: GLTF_EXT_feature_metadata_ClassProperty): boolean {\n const types = [\n 'UINT8',\n 'INT16',\n 'UINT16',\n 'INT32',\n 'UINT32',\n 'INT64',\n 'UINT64',\n 'FLOAT32',\n 'FLOAT64'\n ];\n return (\n types.includes(schemaProperty.type) ||\n (typeof schemaProperty.componentType !== 'undefined' &&\n types.includes(schemaProperty.componentType))\n );\n}\n\n/**\n * Decodes properties of numeric types from binary sourse.\n * @param classProperty - class property object.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @param valuesDataBytes - Data taken from values property of the property table property.\n * @param arrayOffsets - Offsets for variable-length arrays. It's null for fixed-length arrays or scalar types.\n * @returns Property values in a typed array or in an array of typed arrays.\n */\nfunction getPropertyDataNumeric(\n classProperty: GLTF_EXT_feature_metadata_ClassProperty,\n numberOfElements: number,\n valuesDataBytes: Uint8Array,\n arrayOffsets: TypedArray | null\n): BigTypedArray | BigTypedArray[] {\n const isArray = classProperty.type === 'ARRAY';\n const arrayCount = classProperty.componentCount;\n\n /*\n We are getting Numeric data. So,\n the component type can be one of NumericComponentType,\n the attribute type should be 'SCALAR'\n */\n const attributeType = 'SCALAR';\n const componentType = classProperty.componentType || classProperty.type;\n const elementSize = getArrayElementByteSize(attributeType, componentType);\n const elementCount = valuesDataBytes.byteLength / elementSize;\n\n const valuesData: BigTypedArray = convertRawBufferToMetadataArray(\n valuesDataBytes,\n attributeType,\n componentType as NumericComponentType,\n elementCount\n );\n\n if (isArray) {\n if (arrayOffsets) {\n // VARIABLE-length array\n return parseVariableLengthArrayNumeric(\n valuesData,\n numberOfElements,\n arrayOffsets,\n valuesDataBytes.length,\n elementSize\n );\n }\n if (arrayCount) {\n // FIXED-length array\n return parseFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount);\n }\n return [];\n }\n\n return valuesData;\n}\n\n/**\n * Gets properties from texture associated with all mesh primitives.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param featureTextureProperty\n * @param attributeName\n * @returns Feature texture data\n */\nfunction getPropertyDataFromTexture(\n scenegraph: GLTFScenegraph,\n featureTextureProperty: GLTF_EXT_feature_metadata_TextureAccessor,\n attributeName: string\n): number[] {\n const json = scenegraph.gltf.json;\n if (!json.meshes) {\n return [];\n }\n const featureTextureTable: number[] = [];\n for (const mesh of json.meshes) {\n for (const primitive of mesh.primitives) {\n processPrimitiveTextures(\n scenegraph,\n attributeName,\n featureTextureProperty,\n featureTextureTable,\n primitive\n );\n }\n }\n return featureTextureTable;\n}\n\n/**\n * Processes data encoded in the texture associated with the primitive. This data will be accessible through the attributes.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param attributeName\n * @param featureTextureProperty\n * @param featureTextureTable\n * @param primitive\n */\nfunction processPrimitiveTextures(\n scenegraph: GLTFScenegraph,\n attributeName: string,\n featureTextureProperty: GLTF_EXT_feature_metadata_TextureAccessor,\n featureTextureTable: number[],\n primitive: GLTFMeshPrimitive\n): void {\n const textureInfoTopLevel: GLTFTextureInfoMetadata = {\n channels: featureTextureProperty.channels,\n ...featureTextureProperty.texture\n };\n const propertyData: number[] | null = getPrimitiveTextureData(\n scenegraph,\n textureInfoTopLevel,\n primitive\n );\n if (!propertyData) {\n return;\n }\n primitivePropertyDataToAttributes(\n scenegraph,\n attributeName,\n propertyData,\n featureTextureTable,\n primitive\n );\n}\n"],"mappings":"SAcQA,cAAc;AAAA,SAIpBC,+BAA+B,EAC/BC,uBAAuB,EACvBC,iCAAiC,EACjCC,uBAAuB,EAEvBC,qBAAqB,EACrBC,+BAA+B,EAC/BC,4BAA4B,EAC5BC,qBAAqB;AAIvB,MAAMC,yBAAyB,GAAG,sBAAsB;AACxD,OAAO,MAAMC,IAAI,GAAGD,yBAAyB;AAE7C,OAAO,eAAeE,MAAMA,CAACC,QAAsB,EAAEC,OAA0B,EAAiB;EAC9F,MAAMC,UAAU,GAAG,IAAId,cAAc,CAACY,QAAQ,CAAC;EAC/CG,wBAAwB,CAACD,UAAU,EAAED,OAAO,CAAC;AAC/C;AAQA,OAAO,SAASG,sCAAsCA,CACpDC,SAAyC,EACzCC,aAAsB,EACG;EACzB,IAAID,SAAS,CAACE,aAAa,EAAE;IAAA,IAAAC,YAAA;IAO3B,MAAMC,qBAAqB,IAAAD,YAAA,GAAGE,MAAM,CAACC,IAAI,CAACN,SAAS,CAACE,aAAa,CAAC,cAAAC,YAAA,uBAApCA,YAAA,CAAuC,CAAC,CAAC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,CAAC4D,IAAI;EACjC,IAAI,CAACA,IAAI,CAACC,MAAM,EAAE;IAChB,OAAO,EAAE;EACX;EACA,MAAMC,mBAA6B,GAAG,EAAE;EACxC,KAAK,MAAMC,IAAI,IAAIH,IAAI,CAACC,MAAM,EAAE;IAC9B,KAAK,MAAMG,SAAS,IAAID,IAAI,CAACE,UAAU,EAAE;MACvCC,wBAAwB,CACtB1F,UAAU,EACVmD,aAAa,EACbE,sBAAsB,EACtBiC,mBAAmB,EACnBE,SACF,CAAC;IACH;EACF;EACA,OAAOF,mBAAmB;AAC5B;AAUA,SAASI,wBAAwBA,CAC/B1F,UAA0B,EAC1BmD,aAAqB,EACrBE,sBAAiE,EACjEiC,mBAA6B,EAC7BE,SAA4B,EACtB;EACN,MAAMG,mBAA4C,GAAG;IACnDC,QAAQ,EAAEvC,sBAAsB,CAACuC,QAAQ;IACzC,GAAGvC,sBAAsB,CAACnC;EAC5B,CAAC;EACD,MAAM2E,YAA6B,GAAGzG,uBAAuB,CAC3DY,UAAU,EACV2F,mBAAmB,EACnBH,SACF,CAAC;EACD,IAAI,CAACK,YAAY,EAAE;IACjB;EACF;EACAxG,iCAAiC,CAC/BW,UAAU,EACVmD,aAAa,EACb0C,YAAY,EACZP,mBAAmB,EACnBE,SACF,CAAC;AACH"}
1
+ {"version":3,"file":"EXT_feature_metadata.js","names":["GLTFScenegraph","convertRawBufferToMetadataArray","getPrimitiveTextureData","primitivePropertyDataToAttributes","getArrayElementByteSize","getOffsetsForProperty","parseVariableLengthArrayNumeric","parseFixedLengthArrayNumeric","getPropertyDataString","EXT_FEATURE_METADATA_NAME","name","decode","gltfData","options","scenegraph","decodeExtFeatureMetadata","_options$gltf","_options$gltf2","gltf","loadBuffers","extension","getExtension","loadImages","decodePropertyTextures","decodePropertyTables","schema","schemaClasses","classes","featureTextures","schemaName","schemaClass","featureTexture","findFeatureTextureByClass","handleFeatureTextureProperties","propertyTables","featureTables","propertyTable","findPropertyTableByClass","processPropertyTable","schemaClassName","propertyTableName","class","featureTexturesName","featureTable","_schema$classes","Error","numberOfElements","count","propertyName","properties","_propertyTable$proper","classProperty","propertyTableProperty","data","getPropertyDataFromBinarySource","attributeName","_featureTexture$prope","featureTextureProperty","getPropertyDataFromTexture","numberOfFeatures","featureTableProperty","bufferView","dataArray","getTypedArrayForBufferView","arrayOffsets","getArrayOffsetsForProperty","stringOffsets","getStringOffsetsForProperty","type","componentType","isNumericProperty","getPropertyDataNumeric","componentCount","arrayOffsetBufferView","offsetType","stringOffsetBufferView","schemaProperty","types","includes","valuesDataBytes","isArray","arrayCount","attributeType","elementSize","elementCount","byteLength","valuesData","length","json","meshes","featureTextureTable","mesh","primitive","primitives","processPrimitiveTextures","textureInfoTopLevel","channels","texture","propertyData"],"sources":["../../../../src/lib/extensions/deprecated/EXT_feature_metadata.ts"],"sourcesContent":["/* eslint-disable camelcase */\nimport type {GLTF, GLTFTextureInfoMetadata} from '../../types/gltf-json-schema';\nimport type {\n GLTF_EXT_feature_metadata_Class,\n GLTF_EXT_feature_metadata_ClassProperty,\n GLTF_EXT_feature_metadata_FeatureTable,\n GLTF_EXT_feature_metadata_FeatureTableProperty,\n GLTF_EXT_feature_metadata_FeatureTexture,\n GLTF_EXT_feature_metadata_GLTF,\n GLTF_EXT_feature_metadata_TextureAccessor,\n GLTF_EXT_feature_metadata_Schema\n} from '../../types/gltf-ext-feature-metadata-schema';\nimport type {BigTypedArray, TypedArray} from '@loaders.gl/schema';\nimport {GLTFScenegraph} from '../../api/gltf-scenegraph';\nimport {GLTFMeshPrimitive} from '../../types/gltf-json-schema';\nimport {GLTFLoaderOptions} from '../../../gltf-loader';\nimport {\n convertRawBufferToMetadataArray,\n getPrimitiveTextureData,\n primitivePropertyDataToAttributes,\n getArrayElementByteSize,\n NumericComponentType,\n getOffsetsForProperty,\n parseVariableLengthArrayNumeric,\n parseFixedLengthArrayNumeric,\n getPropertyDataString\n} from '../utils/3d-tiles-utils';\n\n/** Extension name */\nconst EXT_FEATURE_METADATA_NAME = 'EXT_feature_metadata';\nexport const name = EXT_FEATURE_METADATA_NAME;\n\nexport async function decode(gltfData: {json: GLTF}, options: GLTFLoaderOptions): Promise<void> {\n const scenegraph = new GLTFScenegraph(gltfData);\n decodeExtFeatureMetadata(scenegraph, options);\n}\n\n/**\n * Decodes feature metadata from extension.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param options - GLTFLoader options.\n */\nfunction decodeExtFeatureMetadata(scenegraph: GLTFScenegraph, options: GLTFLoaderOptions): void {\n // Decoding metadata involves buffers processing.\n // So, if buffers have not been loaded, there is no reason to process metadata.\n if (!options.gltf?.loadBuffers) {\n return;\n }\n const extension: GLTF_EXT_feature_metadata_GLTF | null =\n scenegraph.getExtension(EXT_FEATURE_METADATA_NAME);\n if (!extension) {\n return;\n }\n\n if (options.gltf?.loadImages) {\n decodePropertyTextures(scenegraph, extension);\n }\n\n decodePropertyTables(scenegraph, extension);\n}\n\n/**\n * Processes the data stored in the textures\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param extension - Top-level extension.\n */\nfunction decodePropertyTextures(\n scenegraph: GLTFScenegraph,\n extension: GLTF_EXT_feature_metadata_GLTF\n): void {\n const schema = extension.schema;\n if (!schema) {\n return;\n }\n const schemaClasses = schema.classes;\n\n const {featureTextures} = extension;\n if (schemaClasses && featureTextures) {\n for (const schemaName in schemaClasses) {\n const schemaClass = schemaClasses[schemaName];\n const featureTexture = findFeatureTextureByClass(featureTextures, schemaName);\n\n if (featureTexture) {\n handleFeatureTextureProperties(scenegraph, featureTexture, schemaClass);\n }\n }\n }\n}\n\n/**\n * Processes the data stored in the property tables.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param extension - Top-level extension.\n */\nfunction decodePropertyTables(\n scenegraph: GLTFScenegraph,\n extension: GLTF_EXT_feature_metadata_GLTF\n): void {\n const schema = extension.schema;\n if (!schema) {\n return;\n }\n const schemaClasses = schema.classes;\n const propertyTables = extension.featureTables;\n if (schemaClasses && propertyTables) {\n for (const schemaName in schemaClasses) {\n const propertyTable = findPropertyTableByClass(propertyTables, schemaName);\n if (propertyTable) {\n processPropertyTable(scenegraph, schema, propertyTable);\n }\n }\n }\n}\n\n/**\n * Finds the property table by class name.\n * @param propertyTables - propertyTable definition taken from the top-level extension.\n * @param schemaClassName - class name in the extension schema.\n */\nfunction findPropertyTableByClass(\n propertyTables: {[key: string]: GLTF_EXT_feature_metadata_FeatureTable},\n schemaClassName: string\n): GLTF_EXT_feature_metadata_FeatureTable | null {\n for (const propertyTableName in propertyTables) {\n const propertyTable = propertyTables[propertyTableName];\n if (propertyTable.class === schemaClassName) {\n return propertyTable;\n }\n }\n\n return null;\n}\n\nfunction findFeatureTextureByClass(\n featureTextures: {[key: string]: GLTF_EXT_feature_metadata_FeatureTexture},\n schemaClassName: string\n): GLTF_EXT_feature_metadata_FeatureTexture | null {\n for (const featureTexturesName in featureTextures) {\n const featureTable = featureTextures[featureTexturesName];\n\n if (featureTable.class === schemaClassName) {\n return featureTable;\n }\n }\n\n return null;\n}\n\n/**\n * Navigates through all properies in the property table, gets properties data,\n * and put the data to `propertyTable.data` as an array.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param schema - schema object.\n * @param propertyTable - propertyTable definition taken from the top-level extension.\n */\nfunction processPropertyTable(\n scenegraph: GLTFScenegraph,\n schema: GLTF_EXT_feature_metadata_Schema,\n propertyTable: GLTF_EXT_feature_metadata_FeatureTable\n): void {\n // Though 'class' is not required by spec, it doesn't make any scence when it's not provided.\n // So, bale out here.\n if (!propertyTable.class) {\n return;\n }\n\n const schemaClass = schema.classes?.[propertyTable.class];\n if (!schemaClass) {\n throw new Error(\n `Incorrect data in the EXT_structural_metadata extension: no schema class with name ${propertyTable.class}`\n );\n }\n\n const numberOfElements = propertyTable.count; // `propertyTable.count` is a number of elements in each property array.\n\n for (const propertyName in schemaClass.properties) {\n const classProperty = schemaClass.properties[propertyName];\n const propertyTableProperty: GLTF_EXT_feature_metadata_FeatureTableProperty | undefined =\n propertyTable.properties?.[propertyName];\n\n if (propertyTableProperty) {\n // Getting all elements (`numberOfElements`) of the array in the `propertyTableProperty`\n const data = getPropertyDataFromBinarySource(\n scenegraph,\n schema,\n classProperty,\n numberOfElements,\n propertyTableProperty\n );\n propertyTableProperty.data = data;\n }\n }\n}\n\n/**\n * Navigates through all properies in feature texture and gets properties data.\n * Data will be stored in featureTexture.properties[propertyName].data.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param featureTexture\n * @param schemaClass\n */\nfunction handleFeatureTextureProperties(\n scenegraph: GLTFScenegraph,\n featureTexture: GLTF_EXT_feature_metadata_FeatureTexture,\n schemaClass: GLTF_EXT_feature_metadata_Class\n): void {\n const attributeName = featureTexture.class;\n\n for (const propertyName in schemaClass.properties) {\n const featureTextureProperty = featureTexture?.properties?.[propertyName];\n\n if (featureTextureProperty) {\n const data = getPropertyDataFromTexture(scenegraph, featureTextureProperty, attributeName);\n featureTextureProperty.data = data;\n }\n }\n}\n\n/**\n * Decodes properties from binary sourse based on property type.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param schemaProperty\n * @param numberOfFeatures\n * @param featureTableProperty\n */\nfunction getPropertyDataFromBinarySource(\n scenegraph: GLTFScenegraph,\n schema: GLTF_EXT_feature_metadata_Schema,\n classProperty: GLTF_EXT_feature_metadata_ClassProperty,\n numberOfFeatures: number,\n featureTableProperty: GLTF_EXT_feature_metadata_FeatureTableProperty\n): string[] | BigTypedArray | string[][] | BigTypedArray[] {\n let data: string[] | BigTypedArray | string[][] | BigTypedArray[] = [];\n const bufferView = featureTableProperty.bufferView;\n const dataArray: Uint8Array = scenegraph.getTypedArrayForBufferView(bufferView);\n\n const arrayOffsets = getArrayOffsetsForProperty(\n scenegraph,\n classProperty,\n featureTableProperty,\n numberOfFeatures\n );\n const stringOffsets = getStringOffsetsForProperty(\n scenegraph,\n classProperty,\n featureTableProperty,\n numberOfFeatures\n );\n\n if (classProperty.type === 'STRING' || classProperty.componentType === 'STRING') {\n data = getPropertyDataString(numberOfFeatures, dataArray, arrayOffsets, stringOffsets);\n } else if (isNumericProperty(classProperty)) {\n data = getPropertyDataNumeric(classProperty, numberOfFeatures, dataArray, arrayOffsets);\n }\n\n return data;\n}\n\n/**\n * Parses propertyTable.property.arrayOffsets that are offsets of sub-arrays in a flatten array of values.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param classProperty - class property object.\n * @param propertyTableProperty - propertyTable's property metadata.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @returns Typed array with offset values.\n * @see https://github.com/CesiumGS/glTF/blob/2976f1183343a47a29e4059a70961371cd2fcee8/extensions/2.0/Vendor/EXT_structural_metadata/schema/propertyTable.property.schema.json#L21\n */\nfunction getArrayOffsetsForProperty(\n scenegraph: GLTFScenegraph,\n classProperty: GLTF_EXT_feature_metadata_ClassProperty,\n propertyTableProperty: GLTF_EXT_feature_metadata_FeatureTableProperty,\n numberOfElements: number\n): TypedArray | null {\n /*\n If ARRAY is used, then componentType must also be specified.\n ARRAY is a fixed-length array when componentCount is defined, and variable-length otherwise.\n*/\n if (\n classProperty.type === 'ARRAY' &&\n // `componentCount` is a number of fixed-length array elements.\n // If `componentCount` is NOT defined, it's a VARIABLE-length array\n typeof classProperty.componentCount === 'undefined' &&\n // `arrayOffsetBufferView` is an index of the buffer view containing offsets for variable-length arrays.\n typeof propertyTableProperty.arrayOffsetBufferView !== 'undefined'\n ) {\n // Data are in a VARIABLE-length array\n return getOffsetsForProperty(\n scenegraph,\n propertyTableProperty.arrayOffsetBufferView,\n propertyTableProperty.offsetType || 'UINT32', // offsetType is used both for stringOffsetBufferView and arrayOffsetBufferView\n numberOfElements\n );\n }\n return null;\n}\n\n/**\n * Parses featureTable.property.stringOffsetBufferView.\n * String offsets is an array of offsets of strings in the united array of characters.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param propertyTableProperty - propertyTable's property metadata.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @returns Typed array of offset values. The number of offsets in the array is equal to `numberOfElements` plus one.\n * @see https://github.com/CesiumGS/glTF/blob/c38f7f37e894004353c15cd0481bc5b7381ce841/extensions/2.0/Vendor/EXT_feature_metadata/schema/featureTable.property.schema.json#L50C10-L50C32\n */\nfunction getStringOffsetsForProperty(\n scenegraph: GLTFScenegraph,\n classProperty: GLTF_EXT_feature_metadata_ClassProperty,\n propertyTableProperty: GLTF_EXT_feature_metadata_FeatureTableProperty,\n numberOfElements: number\n): TypedArray | null {\n if (\n typeof propertyTableProperty.stringOffsetBufferView !== 'undefined' // `stringOffsetBufferView` is an index of the buffer view containing offsets for strings.\n ) {\n // Data are in a FIXED-length array\n return getOffsetsForProperty(\n scenegraph,\n propertyTableProperty.stringOffsetBufferView,\n propertyTableProperty.offsetType || 'UINT32', // offsetType is used both for stringOffsetBufferView and arrayOffsetBufferView\n numberOfElements\n );\n }\n return null;\n}\n\n/**\n * Checks if the feature table property is of numeric type.\n * @param schemaPropertyType - feature table property\n * @returns true if property is numeric, else - false\n */\nfunction isNumericProperty(schemaProperty: GLTF_EXT_feature_metadata_ClassProperty): boolean {\n const types = [\n 'UINT8',\n 'INT16',\n 'UINT16',\n 'INT32',\n 'UINT32',\n 'INT64',\n 'UINT64',\n 'FLOAT32',\n 'FLOAT64'\n ];\n return (\n types.includes(schemaProperty.type) ||\n (typeof schemaProperty.componentType !== 'undefined' &&\n types.includes(schemaProperty.componentType))\n );\n}\n\n/**\n * Decodes properties of numeric types from binary sourse.\n * @param classProperty - class property object.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @param valuesDataBytes - Data taken from values property of the property table property.\n * @param arrayOffsets - Offsets for variable-length arrays. It's null for fixed-length arrays or scalar types.\n * @returns Property values in a typed array or in an array of typed arrays.\n */\nfunction getPropertyDataNumeric(\n classProperty: GLTF_EXT_feature_metadata_ClassProperty,\n numberOfElements: number,\n valuesDataBytes: Uint8Array,\n arrayOffsets: TypedArray | null\n): BigTypedArray | BigTypedArray[] {\n const isArray = classProperty.type === 'ARRAY';\n const arrayCount = classProperty.componentCount;\n\n /*\n We are getting Numeric data. So,\n the component type can be one of NumericComponentType,\n the attribute type should be 'SCALAR'\n */\n const attributeType = 'SCALAR';\n const componentType = classProperty.componentType || classProperty.type;\n const elementSize = getArrayElementByteSize(attributeType, componentType);\n const elementCount = valuesDataBytes.byteLength / elementSize;\n\n const valuesData: BigTypedArray = convertRawBufferToMetadataArray(\n valuesDataBytes,\n attributeType,\n componentType as NumericComponentType,\n elementCount\n );\n\n if (isArray) {\n if (arrayOffsets) {\n // VARIABLE-length array\n return parseVariableLengthArrayNumeric(\n valuesData,\n numberOfElements,\n arrayOffsets,\n valuesDataBytes.length,\n elementSize\n );\n }\n if (arrayCount) {\n // FIXED-length array\n return parseFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount);\n }\n return [];\n }\n\n return valuesData;\n}\n\n/**\n * Gets properties from texture associated with all mesh primitives.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param featureTextureProperty\n * @param attributeName\n * @returns Feature texture data\n */\nfunction getPropertyDataFromTexture(\n scenegraph: GLTFScenegraph,\n featureTextureProperty: GLTF_EXT_feature_metadata_TextureAccessor,\n attributeName: string\n): number[] {\n const json = scenegraph.gltf.json;\n if (!json.meshes) {\n return [];\n }\n const featureTextureTable: number[] = [];\n for (const mesh of json.meshes) {\n for (const primitive of mesh.primitives) {\n processPrimitiveTextures(\n scenegraph,\n attributeName,\n featureTextureProperty,\n featureTextureTable,\n primitive\n );\n }\n }\n return featureTextureTable;\n}\n\n/**\n * Processes data encoded in the texture associated with the primitive. This data will be accessible through the attributes.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param attributeName\n * @param featureTextureProperty\n * @param featureTextureTable\n * @param primitive\n */\nfunction processPrimitiveTextures(\n scenegraph: GLTFScenegraph,\n attributeName: string,\n featureTextureProperty: GLTF_EXT_feature_metadata_TextureAccessor,\n featureTextureTable: number[],\n primitive: GLTFMeshPrimitive\n): void {\n const textureInfoTopLevel: GLTFTextureInfoMetadata = {\n channels: featureTextureProperty.channels,\n ...featureTextureProperty.texture\n };\n const propertyData: number[] | null = getPrimitiveTextureData(\n scenegraph,\n textureInfoTopLevel,\n primitive\n );\n if (!propertyData) {\n return;\n }\n primitivePropertyDataToAttributes(\n scenegraph,\n attributeName,\n propertyData,\n featureTextureTable,\n primitive\n );\n}\n"],"mappings":"SAaQA,cAAc;AAAA,SAIpBC,+BAA+B,EAC/BC,uBAAuB,EACvBC,iCAAiC,EACjCC,uBAAuB,EAEvBC,qBAAqB,EACrBC,+BAA+B,EAC/BC,4BAA4B,EAC5BC,qBAAqB;AAIvB,MAAMC,yBAAyB,GAAG,sBAAsB;AACxD,OAAO,MAAMC,IAAI,GAAGD,yBAAyB;AAE7C,OAAO,eAAeE,MAAMA,CAACC,QAAsB,EAAEC,OAA0B,EAAiB;EAC9F,MAAMC,UAAU,GAAG,IAAId,cAAc,CAACY,QAAQ,CAAC;EAC/CG,wBAAwB,CAACD,UAAU,EAAED,OAAO,CAAC;AAC/C;AAOA,SAASE,wBAAwBA,CAACD,UAA0B,EAAED,OAA0B,EAAQ;EAAA,IAAAG,aAAA,EAAAC,cAAA;EAG9F,IAAI,GAAAD,aAAA,GAACH,OAAO,CAACK,IAAI,cAAAF,aAAA,eAAZA,aAAA,CAAcG,WAAW,GAAE;IAC9B;EACF;EACA,MAAMC,SAAgD,GACpDN,UAAU,CAACO,YAAY,CAACZ,yBAAyB,CAAC;EACpD,IAAI,CAACW,SAAS,EAAE;IACd;EACF;EAEA,KAAAH,cAAA,GAAIJ,OAAO,CAACK,IAAI,cAAAD,cAAA,eAAZA,cAAA,CAAcK,UAAU,EAAE;IAC5BC,sBAAsB,CAACT,UAAU,EAAEM,SAAS,CAAC;EAC/C;EAEAI,oBAAoB,CAACV,UAAU,EAAEM,SAAS,CAAC;AAC7C;AAOA,SAASG,sBAAsBA,CAC7B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/BhF,UAA0B,EAC1ByC,aAAqB,EACrBE,sBAAiE,EACjEiC,mBAA6B,EAC7BE,SAA4B,EACtB;EACN,MAAMG,mBAA4C,GAAG;IACnDC,QAAQ,EAAEvC,sBAAsB,CAACuC,QAAQ;IACzC,GAAGvC,sBAAsB,CAACwC;EAC5B,CAAC;EACD,MAAMC,YAA6B,GAAGhG,uBAAuB,CAC3DY,UAAU,EACViF,mBAAmB,EACnBH,SACF,CAAC;EACD,IAAI,CAACM,YAAY,EAAE;IACjB;EACF;EACA/F,iCAAiC,CAC/BW,UAAU,EACVyC,aAAa,EACb2C,YAAY,EACZR,mBAAmB,EACnBE,SACF,CAAC;AACH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/gltf",
3
- "version": "4.0.0-beta.4",
3
+ "version": "4.0.0-beta.5",
4
4
  "description": "Framework-independent loader for the glTF format",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -42,11 +42,11 @@
42
42
  "build-bundle": "ocular-bundle ./src/index.ts"
43
43
  },
44
44
  "dependencies": {
45
- "@loaders.gl/draco": "4.0.0-beta.4",
46
- "@loaders.gl/images": "4.0.0-beta.4",
47
- "@loaders.gl/loader-utils": "4.0.0-beta.4",
48
- "@loaders.gl/textures": "4.0.0-beta.4",
45
+ "@loaders.gl/draco": "4.0.0-beta.5",
46
+ "@loaders.gl/images": "4.0.0-beta.5",
47
+ "@loaders.gl/loader-utils": "4.0.0-beta.5",
48
+ "@loaders.gl/textures": "4.0.0-beta.5",
49
49
  "@math.gl/core": "^4.0.0"
50
50
  },
51
- "gitHead": "848c20b474532d301f2c3f8d4e1fb9bf262b86d4"
51
+ "gitHead": "a6f5a0d1a316cc22396e5a4d480c14329d1ef146"
52
52
  }
package/src/index.ts CHANGED
@@ -47,7 +47,14 @@ export type {
47
47
  GLTF_EXT_feature_metadata_FeatureIdTextureAccessor
48
48
  } from './lib/types/gltf-ext-feature-metadata-schema';
49
49
 
50
- export type {GLTF_EXT_structural_metadata_GLTF} from './lib/types/gltf-ext-structural-metadata-schema';
50
+ export type {
51
+ GLTF_EXT_structural_metadata_GLTF,
52
+ GLTF_EXT_structural_metadata_Schema,
53
+ GLTF_EXT_structural_metadata_PropertyTable,
54
+ GLTF_EXT_structural_metadata_PropertyTexture,
55
+ GLTF_EXT_structural_metadata_Class,
56
+ GLTF_EXT_structural_metadata_ClassProperty
57
+ } from './lib/types/gltf-ext-structural-metadata-schema';
51
58
 
52
59
  export type {
53
60
  GLTF_EXT_mesh_features,
@@ -57,8 +64,6 @@ export type {
57
64
  export {name as EXT_MESH_FEATURES} from './lib/extensions/EXT_mesh_features';
58
65
  export {name as EXT_STRUCTURAL_METADATA} from './lib/extensions/EXT_structural_metadata';
59
66
  export {name as EXT_FEATURE_METADATA} from './lib/extensions/deprecated/EXT_feature_metadata';
60
- export {getPropertyTableFromExtFeatureMetadata} from './lib/extensions/deprecated/EXT_feature_metadata';
61
- export {getPropertyTableFromExtStructuralMetadata} from './lib/extensions/EXT_structural_metadata';
62
67
 
63
68
  // Postprocessed types (modified GLTF types)
64
69
  export type {
@@ -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.