@loaders.gl/gltf 4.0.0-alpha.21 → 4.0.0-alpha.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/dist/dist.min.js +3587 -3026
  2. package/dist/es5/index.js +21 -0
  3. package/dist/es5/index.js.map +1 -1
  4. package/dist/es5/lib/api/gltf-extensions.js +3 -1
  5. package/dist/es5/lib/api/gltf-extensions.js.map +1 -1
  6. package/dist/es5/lib/extensions/EXT_mesh_features.js +111 -0
  7. package/dist/es5/lib/extensions/EXT_mesh_features.js.map +1 -0
  8. package/dist/es5/lib/extensions/EXT_structural_metadata.js +386 -0
  9. package/dist/es5/lib/extensions/EXT_structural_metadata.js.map +1 -0
  10. package/dist/es5/lib/extensions/KHR_draco_mesh_compression.js +6 -7
  11. package/dist/es5/lib/extensions/KHR_draco_mesh_compression.js.map +1 -1
  12. package/dist/es5/lib/extensions/data-processing.js +181 -0
  13. package/dist/es5/lib/extensions/data-processing.js.map +1 -0
  14. package/dist/es5/lib/extensions/deprecated/EXT_feature_metadata.js +6 -9
  15. package/dist/es5/lib/extensions/deprecated/EXT_feature_metadata.js.map +1 -1
  16. package/dist/es5/lib/parsers/parse-gltf.js +3 -3
  17. package/dist/es5/lib/parsers/parse-gltf.js.map +1 -1
  18. package/dist/es5/lib/types/gltf-ext-mesh-features-schema.js +2 -0
  19. package/dist/es5/lib/types/gltf-ext-mesh-features-schema.js.map +1 -0
  20. package/dist/es5/lib/types/gltf-ext-structural-metadata-schema.js +2 -0
  21. package/dist/es5/lib/types/gltf-ext-structural-metadata-schema.js.map +1 -0
  22. package/dist/es5/lib/types/gltf-json-schema.js.map +1 -1
  23. package/dist/es5/lib/utils/version.js +1 -1
  24. package/dist/esm/index.js +3 -0
  25. package/dist/esm/index.js.map +1 -1
  26. package/dist/esm/lib/api/gltf-extensions.js +3 -1
  27. package/dist/esm/lib/api/gltf-extensions.js.map +1 -1
  28. package/dist/esm/lib/extensions/EXT_mesh_features.js +55 -0
  29. package/dist/esm/lib/extensions/EXT_mesh_features.js.map +1 -0
  30. package/dist/esm/lib/extensions/EXT_structural_metadata.js +320 -0
  31. package/dist/esm/lib/extensions/EXT_structural_metadata.js.map +1 -0
  32. package/dist/esm/lib/extensions/KHR_draco_mesh_compression.js +2 -5
  33. package/dist/esm/lib/extensions/KHR_draco_mesh_compression.js.map +1 -1
  34. package/dist/esm/lib/extensions/data-processing.js +146 -0
  35. package/dist/esm/lib/extensions/data-processing.js.map +1 -0
  36. package/dist/esm/lib/extensions/deprecated/EXT_feature_metadata.js +4 -7
  37. package/dist/esm/lib/extensions/deprecated/EXT_feature_metadata.js.map +1 -1
  38. package/dist/esm/lib/parsers/parse-gltf.js +5 -6
  39. package/dist/esm/lib/parsers/parse-gltf.js.map +1 -1
  40. package/dist/esm/lib/types/gltf-ext-mesh-features-schema.js +2 -0
  41. package/dist/esm/lib/types/gltf-ext-mesh-features-schema.js.map +1 -0
  42. package/dist/esm/lib/types/gltf-ext-structural-metadata-schema.js +2 -0
  43. package/dist/esm/lib/types/gltf-ext-structural-metadata-schema.js.map +1 -0
  44. package/dist/esm/lib/types/gltf-json-schema.js.map +1 -1
  45. package/dist/esm/lib/utils/version.js +1 -1
  46. package/dist/index.d.ts +6 -1
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +7 -1
  49. package/dist/lib/api/gltf-extensions.d.ts.map +1 -1
  50. package/dist/lib/api/gltf-extensions.js +5 -0
  51. package/dist/lib/extensions/EXT_mesh_features.d.ts +7 -0
  52. package/dist/lib/extensions/EXT_mesh_features.d.ts.map +1 -0
  53. package/dist/lib/extensions/EXT_mesh_features.js +89 -0
  54. package/dist/lib/extensions/EXT_structural_metadata.d.ts +17 -0
  55. package/dist/lib/extensions/EXT_structural_metadata.d.ts.map +1 -0
  56. package/dist/lib/extensions/EXT_structural_metadata.js +504 -0
  57. package/dist/lib/extensions/KHR_draco_mesh_compression.d.ts +1 -1
  58. package/dist/lib/extensions/KHR_draco_mesh_compression.d.ts.map +1 -1
  59. package/dist/lib/extensions/KHR_draco_mesh_compression.js +2 -3
  60. package/dist/lib/extensions/data-processing.d.ts +34 -0
  61. package/dist/lib/extensions/data-processing.d.ts.map +1 -0
  62. package/dist/lib/extensions/data-processing.js +212 -0
  63. package/dist/lib/extensions/deprecated/EXT_feature_metadata.d.ts.map +1 -1
  64. package/dist/lib/extensions/deprecated/EXT_feature_metadata.js +8 -17
  65. package/dist/lib/parsers/parse-gltf.d.ts.map +1 -1
  66. package/dist/lib/parsers/parse-gltf.js +5 -3
  67. package/dist/lib/types/gltf-ext-mesh-features-schema.d.ts +45 -0
  68. package/dist/lib/types/gltf-ext-mesh-features-schema.d.ts.map +1 -0
  69. package/dist/lib/types/gltf-ext-mesh-features-schema.js +2 -0
  70. package/dist/lib/types/gltf-ext-structural-metadata-schema.d.ts +310 -0
  71. package/dist/lib/types/gltf-ext-structural-metadata-schema.d.ts.map +1 -0
  72. package/dist/lib/types/gltf-ext-structural-metadata-schema.js +2 -0
  73. package/dist/lib/types/gltf-json-schema.d.ts +11 -57
  74. package/dist/lib/types/gltf-json-schema.d.ts.map +1 -1
  75. package/package.json +6 -6
  76. package/src/index.ts +11 -3
  77. package/src/lib/api/gltf-extensions.ts +6 -2
  78. package/src/lib/extensions/EXT_mesh_features.ts +117 -0
  79. package/src/lib/extensions/EXT_structural_metadata.ts +730 -0
  80. package/src/lib/extensions/KHR_draco_mesh_compression.ts +7 -7
  81. package/src/lib/extensions/data-processing.ts +264 -0
  82. package/src/lib/extensions/deprecated/EXT_feature_metadata.ts +6 -17
  83. package/src/lib/parsers/parse-gltf.ts +9 -5
  84. package/src/lib/types/gltf-ext-mesh-features-schema.ts +48 -0
  85. package/src/lib/types/gltf-ext-structural-metadata-schema.ts +357 -0
  86. package/src/lib/types/gltf-json-schema.ts +12 -60
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-processing.js","names":["getComponentTypeFromArray","getImageData","emod","ATTRIBUTE_TYPE_TO_COMPONENTS","SCALAR","VEC2","VEC3","VEC4","MAT2","MAT3","MAT4","BOOLEAN","STRING","ENUM","ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY","INT8","Int8Array","UINT8","Uint8Array","INT16","Int16Array","UINT16","Uint16Array","INT32","Int32Array","UINT32","Uint32Array","INT64","BigInt64Array","UINT64","BigUint64Array","FLOAT32","Float32Array","FLOAT64","Float64Array","ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE","getArrayElementByteSize","attributeType","componentType","convertRawBufferToMetadataArray","typedArray","elementCount","arguments","length","undefined","numberOfComponents","ArrayType","size","offset","byteOffset","Math","ceil","buffer","getPrimitiveTextureData","scenegraph","textureInfo","primitive","_json$textures","_json$textures$textur","json","gltf","texCoordAccessorKey","concat","texCoord","texCoordAccessorIndex","attributes","texCoordBufferView","getBufferView","texCoordArray","getTypedArrayForBufferView","textureCoordinates","textureIndex","index","imageIndex","textures","source","_json$images","_json$images$imageInd","_scenegraph$gltf$imag","mimeType","images","parsedImage","width","textureData","value","getImageValueByCoordinates","channels","push","primitivePropertyDataToAttributes","attributeName","propertyData","featureTable","featureIndices","texelData","findIndex","item","bufferIndex","buffers","arrayBuffer","byteLength","bufferViewIndex","addBufferView","accessorIndex","addAccessor","count","CHANNELS_MAP","shift","u","v","components","indexOf","coordinatesToOffset","c","map","imageOffset","imageData","data","Error","imageValue","componentsCount","w","iX","indX","round","h","height","iY","indY"],"sources":["../../../../src/lib/extensions/data-processing.ts"],"sourcesContent":["import type {GLTFTextureInfoMetadata, GLTFMeshPrimitive} from '../types/gltf-json-schema';\nimport type {TypedArray} from '@loaders.gl/schema';\nimport type {ImageType} from '@loaders.gl/images';\n\nimport {GLTFScenegraph} from '../api/gltf-scenegraph';\nimport {getComponentTypeFromArray} from '../gltf-utils/gltf-utils';\nimport {getImageData} from '@loaders.gl/images';\nimport {emod} from '@loaders.gl/math';\n\nconst ATTRIBUTE_TYPE_TO_COMPONENTS = {\n SCALAR: 1,\n VEC2: 2,\n VEC3: 3,\n VEC4: 4,\n MAT2: 4,\n MAT3: 9,\n MAT4: 16,\n BOOLEAN: 1,\n STRING: 1,\n ENUM: 1\n};\n\nconst ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY = {\n INT8: Int8Array,\n UINT8: Uint8Array,\n INT16: Int16Array,\n UINT16: Uint16Array,\n INT32: Int32Array,\n UINT32: Uint32Array,\n INT64: BigInt64Array,\n UINT64: BigUint64Array,\n FLOAT32: Float32Array,\n FLOAT64: Float64Array\n};\n\nconst ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE = {\n INT8: 1,\n UINT8: 1,\n INT16: 2,\n UINT16: 2,\n INT32: 4,\n UINT32: 4,\n INT64: 8,\n UINT64: 8,\n FLOAT32: 4,\n FLOAT64: 8\n};\n\nexport function getArrayElementByteSize(attributeType, componentType): number {\n return (\n ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE[componentType] *\n ATTRIBUTE_TYPE_TO_COMPONENTS[attributeType]\n );\n}\n\n/**\n * Converts raw bytes that are in the buffer to an array of the type defined by the schema.\n * @param {Uint8Array} typedArray - raw bytes in the buffer\n * @param {string} attributeType - SCALAR, VECN, MATN\n * @param {string} componentType - type of the component in elements, e.g. 'UINT8' or 'FLOAT32'\n * @param {number} elementCount - number of elements in the array. Default value is 1.\n * @returns {TypedArray} Data array\n */\nexport function convertRawBufferToMetadataArray(\n typedArray: Uint8Array,\n attributeType: string,\n componentType: string,\n elementCount: number = 1\n): TypedArray {\n const numberOfComponents = ATTRIBUTE_TYPE_TO_COMPONENTS[attributeType];\n const ArrayType = ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY[componentType];\n const length = elementCount * numberOfComponents;\n const size = ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE[componentType];\n // the buffer view `byteOffset` must be aligned to a multiple of the `componentType` size.\n const offset =\n typedArray.byteOffset % size\n ? Math.ceil(typedArray.byteOffset / size) * size\n : typedArray.byteOffset;\n return new ArrayType(typedArray.buffer, offset, length);\n}\n\n/**\n * Processes data encoded in the texture associated with the primitive.\n * If Ext_mesh_featues is combined with the Ext_structural_metadata, propertyTable will also be processed.\n * @param {GLTFScenegraph} scenegraph - Instance of the class for structured access to GLTF data.\n * @param {GLTFTextureInfoMetadata} textureInfo - reference to the texture where extension data are stored.\n * @param {GLTFMeshPrimitive} primitive - primitive object in the mesh\n * @returns {number[] | null} Array of data taken. Null if data can't be taken from the texture.\n */\nexport function getPrimitiveTextureData(\n scenegraph: GLTFScenegraph,\n textureInfo: GLTFTextureInfoMetadata,\n primitive: GLTFMeshPrimitive\n): number[] | null {\n /*\n texture.index is an index for the \"textures\" array.\n The texture object referenced by this index looks like this:\n {\n \"sampler\": 0,\n \"source\": 0\n }\n \"sampler\" is an index for the \"samplers\" array\n \"source\" is an index for the \"images\" array that contains data. These data are stored in rgba channels of the image.\n\n texture.texCoord is a number-suffix (like 1) for an attribute like \"TEXCOORD_1\" in meshes.primitives\n The value of \"TEXCOORD_1\" is an accessor that is used to get coordinates. These coordinates are being used to get data from the image.\n */\n const json = scenegraph.gltf.json;\n\n const texCoordAccessorKey = `TEXCOORD_${textureInfo.texCoord || 0}`;\n const texCoordAccessorIndex = primitive.attributes[texCoordAccessorKey];\n const texCoordBufferView = scenegraph.getBufferView(texCoordAccessorIndex);\n const texCoordArray: Uint8Array = scenegraph.getTypedArrayForBufferView(texCoordBufferView);\n\n // textureCoordinates array contains UV coordinates of the actual data stored in the texture\n const textureCoordinates: Float32Array = new Float32Array(\n texCoordArray.buffer,\n texCoordArray.byteOffset,\n texCoordArray.length / 4\n );\n\n const textureIndex: number = textureInfo.index;\n const imageIndex = json.textures?.[textureIndex]?.source;\n if (typeof imageIndex !== 'undefined') {\n const mimeType = json.images?.[imageIndex]?.mimeType;\n const parsedImage = scenegraph.gltf.images?.[imageIndex];\n // Checking for width is to prevent handling Un-processed images (e.g. [analyze] stage, where loadImages option is set to false)\n if (parsedImage && typeof parsedImage.width !== 'undefined') {\n const textureData: number[] = [];\n for (let index = 0; index < textureCoordinates.length; index += 2) {\n const value = getImageValueByCoordinates(\n parsedImage,\n mimeType,\n textureCoordinates,\n index,\n textureInfo.channels\n );\n textureData.push(value);\n }\n return textureData;\n }\n }\n return null;\n}\n\n/**\n * Puts property data to attributes.\n * It creates corresponding buffer, bufferView and accessor\n * so the data can be accessed like regular data stored in buffers.\n * @param {GLTFScenegraph} scenegraph - scenegraph object\n * @param {string} attributeName - name of the attribute\n * @param {number[]} propertyData - property data to store\n * @param {number[]} featureTable - an array where unique data from the property data are being stored\n * @param {GLTFMeshPrimitive} primitive - primitive object\n */\nexport function primitivePropertyDataToAttributes(\n scenegraph: GLTFScenegraph,\n attributeName: string,\n propertyData: number[],\n featureTable: number[],\n primitive: GLTFMeshPrimitive\n): void {\n if (propertyData === null) return;\n /*\n featureTable will contain unique values, e.g.\n propertyData = [24, 35, 28, 24]\n featureTable = [24, 35, 28]\n featureIndices will contain indices that refer featureTextureTable, e.g.\n featureIndices = [0, 1, 2, 0]\n */\n const featureIndices: number[] = [];\n for (const texelData of propertyData) {\n let index = featureTable.findIndex((item) => item === texelData);\n if (index === -1) {\n index = featureTable.push(texelData) - 1;\n }\n featureIndices.push(index);\n }\n const typedArray = new Uint32Array(featureIndices);\n const bufferIndex =\n scenegraph.gltf.buffers.push({\n arrayBuffer: typedArray.buffer,\n byteOffset: typedArray.byteOffset,\n byteLength: typedArray.byteLength\n }) - 1;\n const bufferViewIndex = scenegraph.addBufferView(typedArray, bufferIndex, 0);\n const accessorIndex = scenegraph.addAccessor(bufferViewIndex, {\n size: 1,\n componentType: getComponentTypeFromArray(typedArray),\n count: typedArray.length\n });\n primitive.attributes[attributeName] = accessorIndex;\n}\n\n/**\n * Gets the value from the texture by coordinates provided.\n * @param {ImageType} parsedImage - image where the data are stored.\n * @param {string | undefined} mimeType - MIME type\n * @param {Float32Array} textureCoordinates - uv coordinates to access data in the image.\n * @param {number} index - index of uv coordinates in the array textureCoordinates\n * @param {channels} channels - image channels where data are stored. Channels of an RGBA texture are numbered 0..3 respectively.\n * @returns {number} Value taken from the image.\n */\nfunction getImageValueByCoordinates(\n parsedImage: ImageType,\n mimeType: string | undefined,\n textureCoordinates: Float32Array,\n index: number,\n channels: number[] = [0]\n) {\n const CHANNELS_MAP = [\n {offset: 0, shift: 0},\n {offset: 1, shift: 8},\n {offset: 2, shift: 16},\n {offset: 3, shift: 24}\n ];\n\n const u = textureCoordinates[index];\n const v = textureCoordinates[index + 1];\n\n let components = 1;\n if (mimeType && (mimeType.indexOf('image/jpeg') !== -1 || mimeType.indexOf('image/png') !== -1))\n components = 4;\n const offset = coordinatesToOffset(u, v, parsedImage, components);\n let value: number = 0;\n for (const c of channels) {\n const map = CHANNELS_MAP[c];\n const imageOffset = offset + map.offset;\n const imageData = getImageData(parsedImage);\n if (imageData.data.length <= imageOffset) {\n throw new Error(`${imageData.data.length} <= ${imageOffset}`);\n }\n const imageValue = imageData.data[imageOffset];\n value |= imageValue << map.shift;\n }\n return value;\n}\n\n/**\n * Retrieves the offset in the image where the data are stored\n * @param u - u-coordinate\n * @param v - v-coordinate\n * @param parsedImage - image where the data are stored\n * @param componentsCount - number of components the data consists of.\n * @returns offset in the image where the data are stored\n */\nfunction coordinatesToOffset(\n u: number,\n v: number,\n parsedImage: any,\n componentsCount: number = 1\n): number {\n const w = parsedImage.width;\n const iX = emod(u) * (w - 1);\n const indX = Math.round(iX);\n\n const h = parsedImage.height;\n const iY = emod(v) * (h - 1);\n const indY = Math.round(iY);\n const components = parsedImage.components ? parsedImage.components : componentsCount;\n // components is a number of channels in the image\n const offset = (indY * w + indX) * components;\n return offset;\n}\n"],"mappings":"AAKA,SAAQA,yBAAyB,QAAO,0BAA0B;AAClE,SAAQC,YAAY,QAAO,oBAAoB;AAC/C,SAAQC,IAAI,QAAO,kBAAkB;AAErC,MAAMC,4BAA4B,GAAG;EACnCC,MAAM,EAAE,CAAC;EACTC,IAAI,EAAE,CAAC;EACPC,IAA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,IAAI,CAACyE,KAAK,CAACF,EAAE,CAAC;EAE3B,MAAMG,CAAC,GAAG3C,WAAW,CAAC4C,MAAM;EAC5B,MAAMC,EAAE,GAAG5H,IAAI,CAAC0G,CAAC,CAAC,IAAIgB,CAAC,GAAG,CAAC,CAAC;EAC5B,MAAMG,IAAI,GAAG7E,IAAI,CAACyE,KAAK,CAACG,EAAE,CAAC;EAC3B,MAAMjB,UAAU,GAAG5B,WAAW,CAAC4B,UAAU,GAAG5B,WAAW,CAAC4B,UAAU,GAAGU,eAAe;EAEpF,MAAMvE,MAAM,GAAG,CAAC+E,IAAI,GAAGP,CAAC,GAAGE,IAAI,IAAIb,UAAU;EAC7C,OAAO7D,MAAM;AACf"}
@@ -1,15 +1,16 @@
1
1
  import { GLTFScenegraph } from '../../api/gltf-scenegraph';
2
2
  import { getImageData } from '@loaders.gl/images';
3
3
  import { getComponentTypeFromArray } from '../../gltf-utils/gltf-utils';
4
- const EXT_FEATURE_METADATA = 'EXT_feature_metadata';
5
- export const name = EXT_FEATURE_METADATA;
4
+ import { emod } from '@loaders.gl/math';
5
+ const EXT_FEATURE_METADATA_NAME = 'EXT_feature_metadata';
6
+ export const name = EXT_FEATURE_METADATA_NAME;
6
7
  export async function decode(gltfData, options) {
7
8
  const scenegraph = new GLTFScenegraph(gltfData);
8
9
  decodeExtFeatureMetadata(scenegraph, options);
9
10
  }
10
11
  function decodeExtFeatureMetadata(scenegraph, options) {
11
12
  var _extension$schema, _options$gltf;
12
- const extension = scenegraph.getExtension(EXT_FEATURE_METADATA);
13
+ const extension = scenegraph.getExtension(EXT_FEATURE_METADATA_NAME);
13
14
  if (!extension) return;
14
15
  const schemaClasses = (_extension$schema = extension.schema) === null || _extension$schema === void 0 ? void 0 : _extension$schema.classes;
15
16
  const {
@@ -184,10 +185,6 @@ function coordinatesToOffset(u, v, parsedImage) {
184
185
  const offset = (indY * w + indX) * components;
185
186
  return offset;
186
187
  }
187
- function emod(n) {
188
- const a = (n % 1 + 1) % 1;
189
- return a;
190
- }
191
188
  function findFeatureTableByName(featureTables, schemaClassName) {
192
189
  for (const featureTableName in featureTables) {
193
190
  const featureTable = featureTables[featureTableName];
@@ -1 +1 @@
1
- {"version":3,"file":"EXT_feature_metadata.js","names":["GLTFScenegraph","getImageData","getComponentTypeFromArray","EXT_FEATURE_METADATA","name","decode","gltfData","options","scenegraph","decodeExtFeatureMetadata","_extension$schema","_options$gltf","extension","getExtension","schemaClasses","schema","classes","featureTables","schemaName","schemaClass","featureTable","findFeatureTableByName","handleFeatureTableProperties","featureTextures","gltf","loadImages","featureTexture","findFeatureTextureByName","handleFeatureTextureProperties","propertyName","properties","_featureTable$propert","schemaProperty","featureTableProperty","numberOfFeatures","count","data","getPropertyDataFromBinarySource","attributeName","class","_featureTexture$prope","featureTextureProperty","getPropertyDataFromTexture","bufferView","dataArray","getTypedArrayForBufferView","type","stringOffsetBufferView","offsetsData","getStringAttributes","json","meshes","featureTextureTable","mesh","primitive","primitives","processPrimitiveTextures","_json$textures","textureData","texCoordAccessorKey","concat","texture","texCoord","texCoordAccessorIndex","attributes","texCoordBufferView","getBufferView","texCoordArray","textureCoordinates","Float32Array","buffer","byteOffset","length","textureIndex","index","textures","imageIndex","source","_json$images","_scenegraph$gltf$imag","image","images","mimeType","parsedImage","value","getImageValueByCoordinates","channels","push","featureIndices","texelData","findIndex","item","typedArray","Uint32Array","bufferIndex","buffers","arrayBuffer","byteLength","bufferViewIndex","addBufferView","accessorIndex","addAccessor","size","componentType","CHANNELS_MAP","r","offset","shift","g","b","a","u","v","components","indexOf","coordinatesToOffset","c","map","val","getVal","imageData","Error","componentsCount","arguments","undefined","w","width","iX","emod","indX","Math","round","h","height","iY","indY","n","schemaClassName","featureTableName","featureTexturesName","stringsCount","stringsArray","textDecoder","TextDecoder","stringOffset","bytesPerStringSize","stringByteSize","stringData","subarray","stringAttribute"],"sources":["../../../../../src/lib/extensions/deprecated/EXT_feature_metadata.ts"],"sourcesContent":["/* eslint-disable camelcase */\nimport type {\n GLTF,\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} from '../../types/gltf-json-schema';\nimport {GLTFScenegraph} from '../../api/gltf-scenegraph';\nimport {getImageData} from '@loaders.gl/images';\nimport {GLTFMeshPrimitive} from '../../types/gltf-json-schema';\nimport {getComponentTypeFromArray} from '../../gltf-utils/gltf-utils';\nimport {GLTFLoaderOptions} from '../../../gltf-loader';\n\n/** Extension name */\nconst EXT_FEATURE_METADATA = 'EXT_feature_metadata';\n\nexport const name = EXT_FEATURE_METADATA;\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\n */\nfunction decodeExtFeatureMetadata(scenegraph: GLTFScenegraph, options: GLTFLoaderOptions): void {\n const extension: GLTF_EXT_feature_metadata_GLTF | null =\n scenegraph.getExtension(EXT_FEATURE_METADATA);\n if (!extension) return;\n\n const schemaClasses = extension.schema?.classes;\n\n const {featureTables} = extension;\n if (schemaClasses && featureTables) {\n for (const schemaName in schemaClasses) {\n const schemaClass = schemaClasses[schemaName];\n const featureTable = findFeatureTableByName(featureTables, schemaName);\n\n if (featureTable) {\n handleFeatureTableProperties(scenegraph, featureTable, schemaClass);\n }\n }\n }\n\n const {featureTextures} = extension;\n if (schemaClasses && featureTextures && options.gltf?.loadImages) {\n for (const schemaName in schemaClasses) {\n const schemaClass = schemaClasses[schemaName];\n const featureTexture = findFeatureTextureByName(featureTextures, schemaName);\n\n if (featureTexture) {\n handleFeatureTextureProperties(scenegraph, featureTexture, schemaClass);\n }\n }\n }\n}\n\n/**\n * Navigate throw all properies in feature table and gets properties data.\n * @param scenegraph\n * @param featureTable\n * @param schemaClass\n */\nfunction handleFeatureTableProperties(\n scenegraph: GLTFScenegraph,\n featureTable: GLTF_EXT_feature_metadata_FeatureTable,\n schemaClass: GLTF_EXT_feature_metadata_Class\n): void {\n for (const propertyName in schemaClass.properties) {\n const schemaProperty = schemaClass.properties[propertyName];\n const featureTableProperty = featureTable?.properties?.[propertyName];\n const numberOfFeatures = featureTable.count;\n\n if (featureTableProperty) {\n const data = getPropertyDataFromBinarySource(\n scenegraph,\n schemaProperty,\n numberOfFeatures,\n featureTableProperty\n );\n featureTableProperty.data = data;\n }\n }\n}\n\n/**\n * Navigate throw all properies in feature texture and gets properties data.\n * Data will be stored in featureTexture.properties[propertyName].data\n * @param scenegraph\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 * Decode properties from binary sourse based on property type.\n * @param scenegraph\n * @param schemaProperty\n * @param numberOfFeatures\n * @param featureTableProperty\n */\nfunction getPropertyDataFromBinarySource(\n scenegraph: GLTFScenegraph,\n schemaProperty: GLTF_EXT_feature_metadata_ClassProperty,\n numberOfFeatures: number,\n featureTableProperty: GLTF_EXT_feature_metadata_FeatureTableProperty\n): Uint8Array | string[] {\n const bufferView = featureTableProperty.bufferView;\n // TODO think maybe we shouldn't get data only in Uint8Array format.\n const dataArray: Uint8Array = scenegraph.getTypedArrayForBufferView(bufferView);\n\n switch (schemaProperty.type) {\n case 'STRING': {\n // stringOffsetBufferView should be available for string type.\n const stringOffsetBufferView = featureTableProperty.stringOffsetBufferView!;\n const offsetsData = scenegraph.getTypedArrayForBufferView(stringOffsetBufferView);\n return getStringAttributes(dataArray, offsetsData, numberOfFeatures);\n }\n default:\n }\n\n return dataArray;\n}\n\n/**\n * Get properties from texture associated with all mesh primitives.\n * @param scenegraph\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// eslint-disable-next-line max-statements\n/**\n * Processes data encoded in the texture associated with the primitive. This data will be accessible through the attributes.\n * @param scenegraph\n * @param attributeName\n * @param featureTextureProperty\n * @param featureTextureTable\n * @param primitive\n */\n// eslint-disable-next-line max-statements\nfunction processPrimitiveTextures(\n scenegraph: GLTFScenegraph,\n attributeName: string,\n featureTextureProperty: GLTF_EXT_feature_metadata_TextureAccessor,\n featureTextureTable: number[],\n primitive: GLTFMeshPrimitive\n): void {\n /*\n texture.index is an index for the \"textures\" array.\n The texture object referenced by this index looks like this:\n {\n \"sampler\": 0,\n \"source\": 0\n }\n \"sampler\" is an index for the \"samplers\" array\n \"source\" is an index for the \"images\" array that contains data. These data are stored in rgba channels of the image.\n\n texture.texCoord is a number-suffix (like 1) for an attribute like \"TEXCOORD_1\" in meshes.primitives\n The value of \"TEXCOORD_1\" is an accessor that is used to get coordinates. These coordinates ared used to get data from the image.\n */\n const json = scenegraph.gltf.json;\n const textureData: number[] = [];\n const texCoordAccessorKey = `TEXCOORD_${featureTextureProperty.texture.texCoord}`;\n const texCoordAccessorIndex = primitive.attributes[texCoordAccessorKey];\n const texCoordBufferView = scenegraph.getBufferView(texCoordAccessorIndex);\n const texCoordArray: Uint8Array = scenegraph.getTypedArrayForBufferView(texCoordBufferView);\n\n const textureCoordinates: Float32Array = new Float32Array(\n texCoordArray.buffer,\n texCoordArray.byteOffset,\n texCoordArray.length / 4\n );\n // textureCoordinates contains UV coordinates of the actual data stored in the texture\n // accessor.count is a number of UV pairs (they are stored as VEC2)\n\n const textureIndex = featureTextureProperty.texture.index;\n const texture = json.textures?.[textureIndex];\n const imageIndex = texture?.source;\n if (typeof imageIndex !== 'undefined') {\n const image = json.images?.[imageIndex];\n const mimeType = image?.mimeType;\n const parsedImage = scenegraph.gltf.images?.[imageIndex];\n if (parsedImage) {\n for (let index = 0; index < textureCoordinates.length; index += 2) {\n const value = getImageValueByCoordinates(\n parsedImage,\n mimeType,\n textureCoordinates,\n index,\n featureTextureProperty.channels\n );\n textureData.push(value);\n }\n }\n }\n /*\n featureTextureTable will contain unique values, e.g.\n textureData = [24, 35, 28, 24]\n featureTextureTable = [24, 35, 28]\n featureIndices will contain indices hat refer featureTextureTable, e.g.\n featureIndices = [0, 1, 2, 0]\n */\n const featureIndices: number[] = [];\n for (const texelData of textureData) {\n let index = featureTextureTable.findIndex((item) => item === texelData);\n if (index === -1) {\n index = featureTextureTable.push(texelData) - 1;\n }\n featureIndices.push(index);\n }\n const typedArray = new Uint32Array(featureIndices);\n const bufferIndex =\n scenegraph.gltf.buffers.push({\n arrayBuffer: typedArray.buffer,\n byteOffset: 0,\n byteLength: typedArray.byteLength\n }) - 1;\n const bufferViewIndex = scenegraph.addBufferView(typedArray, bufferIndex, 0);\n const accessorIndex = scenegraph.addAccessor(bufferViewIndex, {\n size: 1,\n componentType: getComponentTypeFromArray(typedArray),\n count: typedArray.length\n });\n primitive.attributes[attributeName] = accessorIndex;\n}\n\nfunction getImageValueByCoordinates(\n parsedImage: any,\n mimeType: string | undefined,\n textureCoordinates: Float32Array,\n index: number,\n channels: string\n) {\n const CHANNELS_MAP = {\n r: {offset: 0, shift: 0},\n g: {offset: 1, shift: 8},\n b: {offset: 2, shift: 16},\n a: {offset: 3, shift: 24}\n };\n\n const u = textureCoordinates[index];\n const v = textureCoordinates[index + 1];\n\n let components = 1;\n if (mimeType && (mimeType.indexOf('image/jpeg') !== -1 || mimeType.indexOf('image/png') !== -1))\n components = 4;\n const offset = coordinatesToOffset(u, v, parsedImage, components);\n let value = 0;\n for (const c of channels) {\n const map = CHANNELS_MAP[c];\n const val = getVal(parsedImage, offset + map.offset);\n value |= val << map.shift;\n }\n return value;\n}\n\nfunction getVal(parsedImage: any, offset: number): number {\n const imageData = getImageData(parsedImage);\n if (imageData.data.length <= offset) {\n throw new Error(`${imageData.data.length} <= ${offset}`);\n }\n return imageData.data[offset];\n}\n\nfunction coordinatesToOffset(\n u: number,\n v: number,\n parsedImage: any,\n componentsCount: number = 1\n): number {\n const w = parsedImage.width;\n const iX = emod(u) * (w - 1);\n const indX = Math.round(iX);\n\n const h = parsedImage.height;\n const iY = emod(v) * (h - 1);\n const indY = Math.round(iY);\n const components = parsedImage.components ? parsedImage.components : componentsCount;\n // components is a number of channels in the image\n const offset = (indY * w + indX) * components;\n return offset;\n}\n\n// The following is taken from tile-converter\\src\\i3s-converter\\helpers\\batch-ids-extensions.ts\n/**\n * Handle UVs if they are out of range [0,1].\n * @param n\n * @param m\n */\nfunction emod(n: number): number {\n const a = ((n % 1) + 1) % 1;\n return a;\n}\n\n/**\n * Find the feature table by class name.\n * @param featureTables\n * @param schemaClassName\n */\nfunction findFeatureTableByName(\n featureTables: {[key: string]: GLTF_EXT_feature_metadata_FeatureTable},\n schemaClassName: string\n): GLTF_EXT_feature_metadata_FeatureTable | null {\n for (const featureTableName in featureTables) {\n const featureTable = featureTables[featureTableName];\n\n if (featureTable.class === schemaClassName) {\n return featureTable;\n }\n }\n\n return null;\n}\n\nfunction findFeatureTextureByName(\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 * Getting string attributes from binary data.\n * Spec - https://github.com/CesiumGS/3d-tiles/tree/main/specification/Metadata#strings\n * @param data\n * @param offsetsData\n * @param stringsCount\n */\nfunction getStringAttributes(\n data: Uint8Array,\n offsetsData: Uint8Array,\n stringsCount: number\n): string[] {\n const stringsArray: string[] = [];\n const textDecoder = new TextDecoder('utf8');\n\n let stringOffset = 0;\n const bytesPerStringSize = 4;\n\n for (let index = 0; index < stringsCount; index++) {\n // TODO check if it is multiplication on bytesPerStringSize is valid operation?\n const stringByteSize =\n offsetsData[(index + 1) * bytesPerStringSize] - offsetsData[index * bytesPerStringSize];\n const stringData = data.subarray(stringOffset, stringByteSize + stringOffset);\n const stringAttribute = textDecoder.decode(stringData);\n\n stringsArray.push(stringAttribute);\n stringOffset += stringByteSize;\n }\n\n return stringsArray;\n}\n"],"mappings":"AAWA,SAAQA,cAAc,QAAO,2BAA2B;AACxD,SAAQC,YAAY,QAAO,oBAAoB;AAE/C,SAAQC,yBAAyB,QAAO,6BAA6B;AAIrE,MAAMC,oBAAoB,GAAG,sBAAsB;AAEnD,OAAO,MAAMC,IAAI,GAAGD,oBAAoB;AAExC,OAAO,eAAeE,MAAMA,CAACC,QAAsB,EAAEC,OAA0B,EAAiB;EAC9F,MAAMC,UAAU,GAAG,IAAIR,cAAc,CAACM,QAAQ,CAAC;EAC/CG,wBAAwB,CAACD,UAAU,EAAED,OAAO,CAAC;AAC/C;AAMA,SAASE,wBAAwBA,CAACD,UAA0B,EAAED,OAA0B,EAAQ;EAAA,IAAAG,iBAAA,EAAAC,aAAA;EAC9F,MAAMC,SAAgD,GACpDJ,UAAU,CAACK,YAAY,CAACV,oBAAoB,CAAC;EAC/C,IAAI,CAACS,SAAS,EAAE;EAEhB,MAAME,aAAa,IAAAJ,iBAAA,GAAGE,SA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AC,MAAM,CAAC;EAE3C,IAAIC,YAAY,GAAG,CAAC;EACpB,MAAMC,kBAAkB,GAAG,CAAC;EAE5B,KAAK,IAAIvE,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGkE,YAAY,EAAElE,KAAK,EAAE,EAAE;IAEjD,MAAMwE,cAAc,GAClBlG,WAAW,CAAC,CAAC0B,KAAK,GAAG,CAAC,IAAIuE,kBAAkB,CAAC,GAAGjG,WAAW,CAAC0B,KAAK,GAAGuE,kBAAkB,CAAC;IACzF,MAAME,UAAU,GAAG/G,IAAI,CAACgH,QAAQ,CAACJ,YAAY,EAAEE,cAAc,GAAGF,YAAY,CAAC;IAC7E,MAAMK,eAAe,GAAGP,WAAW,CAACzI,MAAM,CAAC8I,UAAU,CAAC;IAEtDN,YAAY,CAACtD,IAAI,CAAC8D,eAAe,CAAC;IAClCL,YAAY,IAAIE,cAAc;EAChC;EAEA,OAAOL,YAAY;AACrB"}
1
+ {"version":3,"file":"EXT_feature_metadata.js","names":["GLTFScenegraph","getImageData","getComponentTypeFromArray","emod","EXT_FEATURE_METADATA_NAME","name","decode","gltfData","options","scenegraph","decodeExtFeatureMetadata","_extension$schema","_options$gltf","extension","getExtension","schemaClasses","schema","classes","featureTables","schemaName","schemaClass","featureTable","findFeatureTableByName","handleFeatureTableProperties","featureTextures","gltf","loadImages","featureTexture","findFeatureTextureByName","handleFeatureTextureProperties","propertyName","properties","_featureTable$propert","schemaProperty","featureTableProperty","numberOfFeatures","count","data","getPropertyDataFromBinarySource","attributeName","class","_featureTexture$prope","featureTextureProperty","getPropertyDataFromTexture","bufferView","dataArray","getTypedArrayForBufferView","type","stringOffsetBufferView","offsetsData","getStringAttributes","json","meshes","featureTextureTable","mesh","primitive","primitives","processPrimitiveTextures","_json$textures","textureData","texCoordAccessorKey","concat","texture","texCoord","texCoordAccessorIndex","attributes","texCoordBufferView","getBufferView","texCoordArray","textureCoordinates","Float32Array","buffer","byteOffset","length","textureIndex","index","textures","imageIndex","source","_json$images","_scenegraph$gltf$imag","image","images","mimeType","parsedImage","value","getImageValueByCoordinates","channels","push","featureIndices","texelData","findIndex","item","typedArray","Uint32Array","bufferIndex","buffers","arrayBuffer","byteLength","bufferViewIndex","addBufferView","accessorIndex","addAccessor","size","componentType","CHANNELS_MAP","r","offset","shift","g","b","a","u","v","components","indexOf","coordinatesToOffset","c","map","val","getVal","imageData","Error","componentsCount","arguments","undefined","w","width","iX","indX","Math","round","h","height","iY","indY","schemaClassName","featureTableName","featureTexturesName","stringsCount","stringsArray","textDecoder","TextDecoder","stringOffset","bytesPerStringSize","stringByteSize","stringData","subarray","stringAttribute"],"sources":["../../../../../src/lib/extensions/deprecated/EXT_feature_metadata.ts"],"sourcesContent":["/* eslint-disable camelcase */\nimport type {\n GLTF,\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} from '../../types/gltf-json-schema';\nimport {GLTFScenegraph} from '../../api/gltf-scenegraph';\nimport {getImageData} from '@loaders.gl/images';\nimport {GLTFMeshPrimitive} from '../../types/gltf-json-schema';\nimport {getComponentTypeFromArray} from '../../gltf-utils/gltf-utils';\nimport {GLTFLoaderOptions} from '../../../gltf-loader';\nimport {emod} from '@loaders.gl/math';\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\n */\nfunction decodeExtFeatureMetadata(scenegraph: GLTFScenegraph, options: GLTFLoaderOptions): void {\n const extension: GLTF_EXT_feature_metadata_GLTF | null =\n scenegraph.getExtension(EXT_FEATURE_METADATA_NAME);\n if (!extension) return;\n\n const schemaClasses = extension.schema?.classes;\n\n const {featureTables} = extension;\n if (schemaClasses && featureTables) {\n for (const schemaName in schemaClasses) {\n const schemaClass = schemaClasses[schemaName];\n const featureTable = findFeatureTableByName(featureTables, schemaName);\n\n if (featureTable) {\n handleFeatureTableProperties(scenegraph, featureTable, schemaClass);\n }\n }\n }\n\n const {featureTextures} = extension;\n if (schemaClasses && featureTextures && options.gltf?.loadImages) {\n for (const schemaName in schemaClasses) {\n const schemaClass = schemaClasses[schemaName];\n const featureTexture = findFeatureTextureByName(featureTextures, schemaName);\n\n if (featureTexture) {\n handleFeatureTextureProperties(scenegraph, featureTexture, schemaClass);\n }\n }\n }\n}\n\n/**\n * Navigates through all properies in feature table and gets properties data.\n * @param scenegraph\n * @param featureTable\n * @param schemaClass\n */\nfunction handleFeatureTableProperties(\n scenegraph: GLTFScenegraph,\n featureTable: GLTF_EXT_feature_metadata_FeatureTable,\n schemaClass: GLTF_EXT_feature_metadata_Class\n): void {\n for (const propertyName in schemaClass.properties) {\n const schemaProperty = schemaClass.properties[propertyName];\n const featureTableProperty = featureTable?.properties?.[propertyName];\n const numberOfFeatures = featureTable.count;\n\n if (featureTableProperty) {\n const data = getPropertyDataFromBinarySource(\n scenegraph,\n schemaProperty,\n numberOfFeatures,\n featureTableProperty\n );\n featureTableProperty.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\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 * Decode properties from binary sourse based on property type.\n * @param scenegraph\n * @param schemaProperty\n * @param numberOfFeatures\n * @param featureTableProperty\n */\nfunction getPropertyDataFromBinarySource(\n scenegraph: GLTFScenegraph,\n schemaProperty: GLTF_EXT_feature_metadata_ClassProperty,\n numberOfFeatures: number,\n featureTableProperty: GLTF_EXT_feature_metadata_FeatureTableProperty\n): Uint8Array | string[] {\n const bufferView = featureTableProperty.bufferView;\n // TODO think maybe we shouldn't get data only in Uint8Array format.\n const dataArray: Uint8Array = scenegraph.getTypedArrayForBufferView(bufferView);\n\n switch (schemaProperty.type) {\n case 'STRING': {\n // stringOffsetBufferView should be available for string type.\n const stringOffsetBufferView = featureTableProperty.stringOffsetBufferView!;\n const offsetsData = scenegraph.getTypedArrayForBufferView(stringOffsetBufferView);\n return getStringAttributes(dataArray, offsetsData, numberOfFeatures);\n }\n default:\n }\n\n return dataArray;\n}\n\n/**\n * Get properties from texture associated with all mesh primitives.\n * @param scenegraph\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// eslint-disable-next-line max-statements\n/**\n * Processes data encoded in the texture associated with the primitive. This data will be accessible through the attributes.\n * @param scenegraph\n * @param attributeName\n * @param featureTextureProperty\n * @param featureTextureTable\n * @param primitive\n */\n// eslint-disable-next-line max-statements\nfunction processPrimitiveTextures(\n scenegraph: GLTFScenegraph,\n attributeName: string,\n featureTextureProperty: GLTF_EXT_feature_metadata_TextureAccessor,\n featureTextureTable: number[],\n primitive: GLTFMeshPrimitive\n): void {\n /*\n texture.index is an index for the \"textures\" array.\n The texture object referenced by this index looks like this:\n {\n \"sampler\": 0,\n \"source\": 0\n }\n \"sampler\" is an index for the \"samplers\" array\n \"source\" is an index for the \"images\" array that contains data. These data are stored in rgba channels of the image.\n\n texture.texCoord is a number-suffix (like 1) for an attribute like \"TEXCOORD_1\" in meshes.primitives\n The value of \"TEXCOORD_1\" is an accessor that is used to get coordinates. These coordinates ared used to get data from the image.\n */\n const json = scenegraph.gltf.json;\n const textureData: number[] = [];\n const texCoordAccessorKey = `TEXCOORD_${featureTextureProperty.texture.texCoord}`;\n const texCoordAccessorIndex = primitive.attributes[texCoordAccessorKey];\n const texCoordBufferView = scenegraph.getBufferView(texCoordAccessorIndex);\n const texCoordArray: Uint8Array = scenegraph.getTypedArrayForBufferView(texCoordBufferView);\n\n const textureCoordinates: Float32Array = new Float32Array(\n texCoordArray.buffer,\n texCoordArray.byteOffset,\n texCoordArray.length / 4\n );\n // textureCoordinates contains UV coordinates of the actual data stored in the texture\n // accessor.count is a number of UV pairs (they are stored as VEC2)\n\n const textureIndex = featureTextureProperty.texture.index;\n const texture = json.textures?.[textureIndex];\n const imageIndex = texture?.source;\n if (typeof imageIndex !== 'undefined') {\n const image = json.images?.[imageIndex];\n const mimeType = image?.mimeType;\n const parsedImage = scenegraph.gltf.images?.[imageIndex];\n if (parsedImage) {\n for (let index = 0; index < textureCoordinates.length; index += 2) {\n const value = getImageValueByCoordinates(\n parsedImage,\n mimeType,\n textureCoordinates,\n index,\n featureTextureProperty.channels\n );\n textureData.push(value);\n }\n }\n }\n /*\n featureTextureTable will contain unique values, e.g.\n textureData = [24, 35, 28, 24]\n featureTextureTable = [24, 35, 28]\n featureIndices will contain indices hat refer featureTextureTable, e.g.\n featureIndices = [0, 1, 2, 0]\n */\n const featureIndices: number[] = [];\n for (const texelData of textureData) {\n let index = featureTextureTable.findIndex((item) => item === texelData);\n if (index === -1) {\n index = featureTextureTable.push(texelData) - 1;\n }\n featureIndices.push(index);\n }\n const typedArray = new Uint32Array(featureIndices);\n const bufferIndex =\n scenegraph.gltf.buffers.push({\n arrayBuffer: typedArray.buffer,\n byteOffset: 0,\n byteLength: typedArray.byteLength\n }) - 1;\n const bufferViewIndex = scenegraph.addBufferView(typedArray, bufferIndex, 0);\n const accessorIndex = scenegraph.addAccessor(bufferViewIndex, {\n size: 1,\n componentType: getComponentTypeFromArray(typedArray),\n count: typedArray.length\n });\n primitive.attributes[attributeName] = accessorIndex;\n}\n\nfunction getImageValueByCoordinates(\n parsedImage: any,\n mimeType: string | undefined,\n textureCoordinates: Float32Array,\n index: number,\n channels: string\n) {\n const CHANNELS_MAP = {\n r: {offset: 0, shift: 0},\n g: {offset: 1, shift: 8},\n b: {offset: 2, shift: 16},\n a: {offset: 3, shift: 24}\n };\n\n const u = textureCoordinates[index];\n const v = textureCoordinates[index + 1];\n\n let components = 1;\n if (mimeType && (mimeType.indexOf('image/jpeg') !== -1 || mimeType.indexOf('image/png') !== -1))\n components = 4;\n const offset = coordinatesToOffset(u, v, parsedImage, components);\n let value = 0;\n for (const c of channels) {\n const map = CHANNELS_MAP[c];\n const val = getVal(parsedImage, offset + map.offset);\n value |= val << map.shift;\n }\n return value;\n}\n\nfunction getVal(parsedImage: any, offset: number): number {\n const imageData = getImageData(parsedImage);\n if (imageData.data.length <= offset) {\n throw new Error(`${imageData.data.length} <= ${offset}`);\n }\n return imageData.data[offset];\n}\n\nfunction coordinatesToOffset(\n u: number,\n v: number,\n parsedImage: any,\n componentsCount: number = 1\n): number {\n const w = parsedImage.width;\n const iX = emod(u) * (w - 1);\n const indX = Math.round(iX);\n\n const h = parsedImage.height;\n const iY = emod(v) * (h - 1);\n const indY = Math.round(iY);\n const components = parsedImage.components ? parsedImage.components : componentsCount;\n // components is a number of channels in the image\n const offset = (indY * w + indX) * components;\n return offset;\n}\n\n/**\n * Find the feature table by class name.\n * @param featureTables\n * @param schemaClassName\n */\nfunction findFeatureTableByName(\n featureTables: {[key: string]: GLTF_EXT_feature_metadata_FeatureTable},\n schemaClassName: string\n): GLTF_EXT_feature_metadata_FeatureTable | null {\n for (const featureTableName in featureTables) {\n const featureTable = featureTables[featureTableName];\n\n if (featureTable.class === schemaClassName) {\n return featureTable;\n }\n }\n\n return null;\n}\n\nfunction findFeatureTextureByName(\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 * Getting string attributes from binary data.\n * Spec - https://github.com/CesiumGS/3d-tiles/tree/main/specification/Metadata#strings\n * @param data\n * @param offsetsData\n * @param stringsCount\n */\nfunction getStringAttributes(\n data: Uint8Array,\n offsetsData: Uint8Array,\n stringsCount: number\n): string[] {\n const stringsArray: string[] = [];\n const textDecoder = new TextDecoder('utf8');\n\n let stringOffset = 0;\n const bytesPerStringSize = 4;\n\n for (let index = 0; index < stringsCount; index++) {\n // TODO check if it is multiplication on bytesPerStringSize is valid operation?\n const stringByteSize =\n offsetsData[(index + 1) * bytesPerStringSize] - offsetsData[index * bytesPerStringSize];\n const stringData = data.subarray(stringOffset, stringByteSize + stringOffset);\n const stringAttribute = textDecoder.decode(stringData);\n\n stringsArray.push(stringAttribute);\n stringOffset += stringByteSize;\n }\n\n return stringsArray;\n}\n"],"mappings":"AAWA,SAAQA,cAAc,QAAO,2BAA2B;AACxD,SAAQC,YAAY,QAAO,oBAAoB;AAE/C,SAAQC,yBAAyB,QAAO,6BAA6B;AAErE,SAAQC,IAAI,QAAO,kBAAkB;AAGrC,MAAMC,yBAAyB,GAAG,sBAAsB;AACxD,OAAO,MAAMC,IAAI,GAAGD,yBAAyB;AAE7C,OAAO,eAAeE,MAAM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YAAY,CAACmB,KAAK,KAAKgG,eAAe,EAAE;MAC1C,OAAOnH,YAAY;IACrB;EACF;EAEA,OAAO,IAAI;AACb;AASA,SAAS6B,mBAAmBA,CAC1Bb,IAAgB,EAChBY,WAAuB,EACvB0F,YAAoB,EACV;EACV,MAAMC,YAAsB,GAAG,EAAE;EACjC,MAAMC,WAAW,GAAG,IAAIC,WAAW,CAAC,MAAM,CAAC;EAE3C,IAAIC,YAAY,GAAG,CAAC;EACpB,MAAMC,kBAAkB,GAAG,CAAC;EAE5B,KAAK,IAAIrE,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGgE,YAAY,EAAEhE,KAAK,EAAE,EAAE;IAEjD,MAAMsE,cAAc,GAClBhG,WAAW,CAAC,CAAC0B,KAAK,GAAG,CAAC,IAAIqE,kBAAkB,CAAC,GAAG/F,WAAW,CAAC0B,KAAK,GAAGqE,kBAAkB,CAAC;IACzF,MAAME,UAAU,GAAG7G,IAAI,CAAC8G,QAAQ,CAACJ,YAAY,EAAEE,cAAc,GAAGF,YAAY,CAAC;IAC7E,MAAMK,eAAe,GAAGP,WAAW,CAACvI,MAAM,CAAC4I,UAAU,CAAC;IAEtDN,YAAY,CAACpD,IAAI,CAAC4D,eAAe,CAAC;IAClCL,YAAY,IAAIE,cAAc;EAChC;EAEA,OAAOL,YAAY;AACrB"}
@@ -1,4 +1,4 @@
1
- import { parseJSON, sliceArrayBuffer } from '@loaders.gl/loader-utils';
1
+ import { parseJSON, sliceArrayBuffer, parseFromContext } from '@loaders.gl/loader-utils';
2
2
  import { ImageLoader } from '@loaders.gl/images';
3
3
  import { BasisLoader, selectSupportedBasisFormat } from '@loaders.gl/textures';
4
4
  import { assert } from '../utils/assert';
@@ -112,13 +112,12 @@ function getReferencesImageIndices(gltf) {
112
112
  return Array.from(imageIndices).sort();
113
113
  }
114
114
  async function loadImage(gltf, image, index, options, context) {
115
- const {
116
- fetch,
117
- parse
118
- } = context;
119
115
  let arrayBuffer;
120
116
  if (image.uri && !image.hasOwnProperty('bufferView')) {
121
117
  const uri = resolveUrl(image.uri, options);
118
+ const {
119
+ fetch
120
+ } = context;
122
121
  const response = await fetch(uri);
123
122
  arrayBuffer = await response.arrayBuffer();
124
123
  image.bufferView = {
@@ -130,7 +129,7 @@ async function loadImage(gltf, image, index, options, context) {
130
129
  arrayBuffer = sliceArrayBuffer(array.buffer, array.byteOffset, array.byteLength);
131
130
  }
132
131
  assert(arrayBuffer, 'glTF image has no data');
133
- let parsedImage = await parse(arrayBuffer, [ImageLoader, BasisLoader], {
132
+ let parsedImage = await parseFromContext(arrayBuffer, [ImageLoader, BasisLoader], {
134
133
  ...options,
135
134
  mimeType: image.mimeType,
136
135
  basis: options.basis || {
@@ -1 +1 @@
1
- {"version":3,"file":"parse-gltf.js","names":["parseJSON","sliceArrayBuffer","ImageLoader","BasisLoader","selectSupportedBasisFormat","assert","isGLB","parseGLBSync","resolveUrl","getTypedArrayForBufferView","preprocessExtensions","decodeExtensions","normalizeGLTFV1","isGLTF","arrayBuffer","options","byteOffset","parseGLTF","gltf","arrayBufferOrString","_options$gltf","_options$gltf2","_options$gltf3","arguments","length","undefined","context","parseGLTFContainerSync","normalize","loadBuffers","json","buffers","loadImages","data","uri","baseUri","ArrayBuffer","textDecoder","TextDecoder","decode","glb","type","concat","_glb","Array","fill","header","hasBinChunk","binChunks","byteLength","images","i","buffer","_context$fetch","_response$arrayBuffer","fetch","response","call","imageIndices","getReferencesImageIndices","promises","imageIndex","push","loadImage","Promise","all","Set","textures","texture","source","add","from","sort","image","index","parse","hasOwnProperty","bufferView","Number","isFinite","array","parsedImage","mimeType","basis","format","compressed","mipmaps","width","height"],"sources":["../../../../src/lib/parsers/parse-gltf.ts"],"sourcesContent":["/* eslint-disable camelcase, max-statements, no-restricted-globals */\nimport type {LoaderContext} from '@loaders.gl/loader-utils';\nimport type {GLTFLoaderOptions} from '../../gltf-loader';\nimport type {GLTFWithBuffers} from '../types/gltf-types';\nimport type {GLB} from '../types/glb-types';\nimport type {ParseGLBOptions} from './parse-glb';\n\nimport {parseJSON, sliceArrayBuffer} from '@loaders.gl/loader-utils';\nimport {ImageLoader} from '@loaders.gl/images';\nimport {BasisLoader, selectSupportedBasisFormat} from '@loaders.gl/textures';\n\nimport {assert} from '../utils/assert';\nimport {isGLB, parseGLBSync} from './parse-glb';\nimport {resolveUrl} from '../gltf-utils/resolve-url';\nimport {getTypedArrayForBufferView} from '../gltf-utils/get-typed-array';\nimport {preprocessExtensions, decodeExtensions} from '../api/gltf-extensions';\nimport {normalizeGLTFV1} from '../api/normalize-gltf-v1';\n\n/** */\nexport type ParseGLTFOptions = ParseGLBOptions & {\n normalize?: boolean;\n loadImages?: boolean;\n loadBuffers?: boolean;\n decompressMeshes?: boolean;\n excludeExtensions?: string[];\n\n /** @deprecated not supported in v4. `postProcessGLTF()` must be called by the application */\n postProcess?: false;\n};\n\n/** Check if an array buffer appears to contain GLTF data */\nexport function isGLTF(arrayBuffer: ArrayBuffer, options?: ParseGLTFOptions): boolean {\n const byteOffset = 0;\n return isGLB(arrayBuffer, byteOffset, options);\n}\n\nexport async function parseGLTF(\n gltf: GLTFWithBuffers,\n arrayBufferOrString,\n byteOffset = 0,\n options: GLTFLoaderOptions,\n context: LoaderContext\n): Promise<GLTFWithBuffers> {\n parseGLTFContainerSync(gltf, arrayBufferOrString, byteOffset, options);\n\n normalizeGLTFV1(gltf, {normalize: options?.gltf?.normalize});\n\n preprocessExtensions(gltf, options, context);\n\n // Load linked buffers asynchronously and decodes base64 buffers in parallel\n if (options?.gltf?.loadBuffers && gltf.json.buffers) {\n await loadBuffers(gltf, options, context);\n }\n\n // loadImages and decodeExtensions should not be running in parallel, because\n // decodeExtensions uses data from images taken during the loadImages call.\n if (options?.gltf?.loadImages) {\n await loadImages(gltf, options, context);\n }\n\n await decodeExtensions(gltf, options, context);\n\n return gltf;\n}\n\n/**\n *\n * @param gltf\n * @param data - can be ArrayBuffer (GLB), ArrayBuffer (Binary JSON), String (JSON), or Object (parsed JSON)\n * @param byteOffset\n * @param options\n */\nfunction parseGLTFContainerSync(gltf, data, byteOffset, options) {\n // Initialize gltf container\n if (options.uri) {\n gltf.baseUri = options.uri;\n }\n\n // If data is binary and starting with magic bytes, assume binary JSON text, convert to string\n if (data instanceof ArrayBuffer && !isGLB(data, byteOffset, options)) {\n const textDecoder = new TextDecoder();\n data = textDecoder.decode(data);\n }\n\n if (typeof data === 'string') {\n // If string, try to parse as JSON\n gltf.json = parseJSON(data);\n } else if (data instanceof ArrayBuffer) {\n // If still ArrayBuffer, parse as GLB container\n const glb: GLB = {} as GLB;\n byteOffset = parseGLBSync(glb, data, byteOffset, options.glb);\n\n assert(glb.type === 'glTF', `Invalid GLB magic string ${glb.type}`);\n\n gltf._glb = glb;\n gltf.json = glb.json;\n } else {\n assert(false, 'GLTF: must be ArrayBuffer or string');\n }\n\n // Populate buffers\n // Create an external buffers array to hold binary data\n const buffers = gltf.json.buffers || [];\n gltf.buffers = new Array(buffers.length).fill(null);\n\n // Populates JSON and some bin chunk info\n if (gltf._glb && gltf._glb.header.hasBinChunk) {\n const {binChunks} = gltf._glb;\n gltf.buffers[0] = {\n arrayBuffer: binChunks[0].arrayBuffer,\n byteOffset: binChunks[0].byteOffset,\n byteLength: binChunks[0].byteLength\n };\n\n // TODO - this modifies JSON and is a post processing thing\n // gltf.json.buffers[0].data = gltf.buffers[0].arrayBuffer;\n // gltf.json.buffers[0].byteOffset = gltf.buffers[0].byteOffset;\n }\n\n // Populate images\n const images = gltf.json.images || [];\n gltf.images = new Array(images.length).fill({});\n}\n\n/** Asynchronously fetch and parse buffers, store in buffers array outside of json\n * TODO - traverse gltf and determine which buffers are actually needed\n */\nasync function loadBuffers(gltf: GLTFWithBuffers, options, context: LoaderContext) {\n // TODO\n const buffers = gltf.json.buffers || [];\n for (let i = 0; i < buffers.length; ++i) {\n const buffer = buffers[i];\n if (buffer.uri) {\n const {fetch} = context;\n assert(fetch);\n\n const uri = resolveUrl(buffer.uri, options);\n const response = await context?.fetch?.(uri);\n const arrayBuffer = await response?.arrayBuffer?.();\n\n gltf.buffers[i] = {\n arrayBuffer,\n byteOffset: 0,\n byteLength: arrayBuffer.byteLength\n };\n\n delete buffer.uri;\n } else if (gltf.buffers[i] === null) {\n gltf.buffers[i] = {\n arrayBuffer: new ArrayBuffer(buffer.byteLength),\n byteOffset: 0,\n byteLength: buffer.byteLength\n };\n }\n }\n}\n\n/**\n * Loads all images\n * TODO - traverse gltf and determine which images are actually needed\n * @param gltf\n * @param options\n * @param context\n * @returns\n */\nasync function loadImages(gltf: GLTFWithBuffers, options, context: LoaderContext) {\n const imageIndices = getReferencesImageIndices(gltf);\n\n const images = gltf.json.images || [];\n\n const promises: Promise<any>[] = [];\n for (const imageIndex of imageIndices) {\n promises.push(loadImage(gltf, images[imageIndex], imageIndex, options, context));\n }\n\n return await Promise.all(promises);\n}\n\n/** Make sure we only load images that are actually referenced by textures */\nfunction getReferencesImageIndices(gltf: GLTFWithBuffers): number[] {\n const imageIndices = new Set<number>();\n\n const textures = gltf.json.textures || [];\n for (const texture of textures) {\n if (texture.source !== undefined) {\n imageIndices.add(texture.source);\n }\n }\n\n return Array.from(imageIndices).sort();\n}\n\n/** Asynchronously fetches and parses one image, store in images array outside of json */\nasync function loadImage(\n gltf: GLTFWithBuffers,\n image,\n index: number,\n options,\n context: LoaderContext\n) {\n const {fetch, parse} = context;\n\n let arrayBuffer;\n\n if (image.uri && !image.hasOwnProperty('bufferView')) {\n const uri = resolveUrl(image.uri, options);\n const response = await fetch(uri);\n arrayBuffer = await response.arrayBuffer();\n image.bufferView = {\n data: arrayBuffer\n };\n }\n\n if (Number.isFinite(image.bufferView)) {\n const array = getTypedArrayForBufferView(gltf.json, gltf.buffers, image.bufferView);\n arrayBuffer = sliceArrayBuffer(array.buffer, array.byteOffset, array.byteLength);\n }\n\n assert(arrayBuffer, 'glTF image has no data');\n\n // Call `parse`\n let parsedImage = await parse(\n arrayBuffer,\n [ImageLoader, BasisLoader],\n {\n ...options,\n mimeType: image.mimeType,\n basis: options.basis || {format: selectSupportedBasisFormat()}\n },\n context\n );\n\n if (parsedImage && parsedImage[0]) {\n parsedImage = {\n compressed: true,\n mipmaps: false,\n width: parsedImage[0].width,\n height: parsedImage[0].height,\n data: parsedImage[0]\n };\n }\n // TODO making sure ImageLoader is overridable by using array of loaders\n // const parsedImage = await parse(arrayBuffer, [ImageLoader]);\n\n // Store the loaded image\n gltf.images = gltf.images || [];\n gltf.images[index] = parsedImage;\n}\n"],"mappings":"AAOA,SAAQA,SAAS,EAAEC,gBAAgB,QAAO,0BAA0B;AACpE,SAAQC,WAAW,QAAO,oBAAoB;AAC9C,SAAQC,WAAW,EAAEC,0BAA0B,QAAO,sBAAsB;AAE5E,SAAQC,MAAM,QAAO,iBAAiB;AACtC,SAAQC,KAAK,EAAEC,YAAY,QAAO,aAAa;AAC/C,SAAQC,UAAU,QAAO,2BAA2B;AACpD,SAAQC,0BAA0B,QAAO,+BAA+B;AACxE,SAAQC,oBAAoB,EAAEC,gBAAgB,QAAO,wBAAwB;AAC7E,SAAQC,eAAe,QAAO,0BAA0B;AAexD,OAAO,SAASC,MAAMA,CAACC,WAAwB,EAAEC,OAA0B,EAAW;EACpF,MAAMC,UAAU,GAAG,CAAC;EACpB,OAAOV,KAAK,CAACQ,WAAW,EAAEE,UAAU,EAAED,OAAO,CAAC;AAChD;AAEA,OAAO,eAAeE,SAASA,CAC7BC,IAAqB,EACrBC,mBAAmB,EAIO;EAAA,IAAAC,aAAA,EAAAC,cAAA,EAAAC,cAAA;EAAA,IAH1BN,UAAU,GAAAO,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;EAAA,IACdR,OAA0B,GAAAQ,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAAA,IAC1BC,OAAsB,GAAAH,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAEtBE,sBAAsB,CAACT,IAAI,EAAEC,m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D,IAAI,EAAEgD,WAAW,CAAC,CAAC;IACrB,CAAC;EACH;EAKA/D,IAAI,CAACgC,MAAM,GAAGhC,IAAI,CAACgC,MAAM,IAAI,EAAE;EAC/BhC,IAAI,CAACgC,MAAM,CAACwB,KAAK,CAAC,GAAGO,WAAW;AAClC"}
1
+ {"version":3,"file":"parse-gltf.js","names":["parseJSON","sliceArrayBuffer","parseFromContext","ImageLoader","BasisLoader","selectSupportedBasisFormat","assert","isGLB","parseGLBSync","resolveUrl","getTypedArrayForBufferView","preprocessExtensions","decodeExtensions","normalizeGLTFV1","isGLTF","arrayBuffer","options","byteOffset","parseGLTF","gltf","arrayBufferOrString","_options$gltf","_options$gltf2","_options$gltf3","arguments","length","undefined","context","parseGLTFContainerSync","normalize","loadBuffers","json","buffers","loadImages","data","uri","baseUri","ArrayBuffer","textDecoder","TextDecoder","decode","glb","type","concat","_glb","Array","fill","header","hasBinChunk","binChunks","byteLength","images","i","buffer","_context$fetch","_response$arrayBuffer","fetch","response","call","imageIndices","getReferencesImageIndices","promises","imageIndex","push","loadImage","Promise","all","Set","textures","texture","source","add","from","sort","image","index","hasOwnProperty","bufferView","Number","isFinite","array","parsedImage","mimeType","basis","format","compressed","mipmaps","width","height"],"sources":["../../../../src/lib/parsers/parse-gltf.ts"],"sourcesContent":["/* eslint-disable camelcase, max-statements, no-restricted-globals */\nimport type {LoaderContext} from '@loaders.gl/loader-utils';\nimport type {GLTFLoaderOptions} from '../../gltf-loader';\nimport type {GLTFWithBuffers} from '../types/gltf-types';\nimport type {GLB} from '../types/glb-types';\nimport type {ParseGLBOptions} from './parse-glb';\n\nimport type {ImageType, TextureLevel} from '@loaders.gl/schema';\nimport {parseJSON, sliceArrayBuffer, parseFromContext} from '@loaders.gl/loader-utils';\nimport {ImageLoader} from '@loaders.gl/images';\nimport {BasisLoader, selectSupportedBasisFormat} from '@loaders.gl/textures';\n\nimport {assert} from '../utils/assert';\nimport {isGLB, parseGLBSync} from './parse-glb';\nimport {resolveUrl} from '../gltf-utils/resolve-url';\nimport {getTypedArrayForBufferView} from '../gltf-utils/get-typed-array';\nimport {preprocessExtensions, decodeExtensions} from '../api/gltf-extensions';\nimport {normalizeGLTFV1} from '../api/normalize-gltf-v1';\n\n/** */\nexport type ParseGLTFOptions = ParseGLBOptions & {\n normalize?: boolean;\n loadImages?: boolean;\n loadBuffers?: boolean;\n decompressMeshes?: boolean;\n excludeExtensions?: string[];\n\n /** @deprecated not supported in v4. `postProcessGLTF()` must be called by the application */\n postProcess?: false;\n};\n\n/** Check if an array buffer appears to contain GLTF data */\nexport function isGLTF(arrayBuffer: ArrayBuffer, options?: ParseGLTFOptions): boolean {\n const byteOffset = 0;\n return isGLB(arrayBuffer, byteOffset, options);\n}\n\nexport async function parseGLTF(\n gltf: GLTFWithBuffers,\n arrayBufferOrString,\n byteOffset = 0,\n options: GLTFLoaderOptions,\n context: LoaderContext\n): Promise<GLTFWithBuffers> {\n parseGLTFContainerSync(gltf, arrayBufferOrString, byteOffset, options);\n\n normalizeGLTFV1(gltf, {normalize: options?.gltf?.normalize});\n\n preprocessExtensions(gltf, options, context);\n\n // Load linked buffers asynchronously and decodes base64 buffers in parallel\n if (options?.gltf?.loadBuffers && gltf.json.buffers) {\n await loadBuffers(gltf, options, context);\n }\n\n // loadImages and decodeExtensions should not be running in parallel, because\n // decodeExtensions uses data from images taken during the loadImages call.\n if (options?.gltf?.loadImages) {\n await loadImages(gltf, options, context);\n }\n\n await decodeExtensions(gltf, options, context);\n\n return gltf;\n}\n\n/**\n *\n * @param gltf\n * @param data - can be ArrayBuffer (GLB), ArrayBuffer (Binary JSON), String (JSON), or Object (parsed JSON)\n * @param byteOffset\n * @param options\n */\nfunction parseGLTFContainerSync(gltf, data, byteOffset, options) {\n // Initialize gltf container\n if (options.uri) {\n gltf.baseUri = options.uri;\n }\n\n // If data is binary and starting with magic bytes, assume binary JSON text, convert to string\n if (data instanceof ArrayBuffer && !isGLB(data, byteOffset, options)) {\n const textDecoder = new TextDecoder();\n data = textDecoder.decode(data);\n }\n\n if (typeof data === 'string') {\n // If string, try to parse as JSON\n gltf.json = parseJSON(data);\n } else if (data instanceof ArrayBuffer) {\n // If still ArrayBuffer, parse as GLB container\n const glb: GLB = {} as GLB;\n byteOffset = parseGLBSync(glb, data, byteOffset, options.glb);\n\n assert(glb.type === 'glTF', `Invalid GLB magic string ${glb.type}`);\n\n gltf._glb = glb;\n gltf.json = glb.json;\n } else {\n assert(false, 'GLTF: must be ArrayBuffer or string');\n }\n\n // Populate buffers\n // Create an external buffers array to hold binary data\n const buffers = gltf.json.buffers || [];\n gltf.buffers = new Array(buffers.length).fill(null);\n\n // Populates JSON and some bin chunk info\n if (gltf._glb && gltf._glb.header.hasBinChunk) {\n const {binChunks} = gltf._glb;\n gltf.buffers[0] = {\n arrayBuffer: binChunks[0].arrayBuffer,\n byteOffset: binChunks[0].byteOffset,\n byteLength: binChunks[0].byteLength\n };\n\n // TODO - this modifies JSON and is a post processing thing\n // gltf.json.buffers[0].data = gltf.buffers[0].arrayBuffer;\n // gltf.json.buffers[0].byteOffset = gltf.buffers[0].byteOffset;\n }\n\n // Populate images\n const images = gltf.json.images || [];\n gltf.images = new Array(images.length).fill({});\n}\n\n/** Asynchronously fetch and parse buffers, store in buffers array outside of json\n * TODO - traverse gltf and determine which buffers are actually needed\n */\nasync function loadBuffers(gltf: GLTFWithBuffers, options, context: LoaderContext) {\n // TODO\n const buffers = gltf.json.buffers || [];\n for (let i = 0; i < buffers.length; ++i) {\n const buffer = buffers[i];\n if (buffer.uri) {\n const {fetch} = context;\n assert(fetch);\n\n const uri = resolveUrl(buffer.uri, options);\n const response = await context?.fetch?.(uri);\n const arrayBuffer = await response?.arrayBuffer?.();\n\n gltf.buffers[i] = {\n arrayBuffer,\n byteOffset: 0,\n byteLength: arrayBuffer.byteLength\n };\n\n delete buffer.uri;\n } else if (gltf.buffers[i] === null) {\n gltf.buffers[i] = {\n arrayBuffer: new ArrayBuffer(buffer.byteLength),\n byteOffset: 0,\n byteLength: buffer.byteLength\n };\n }\n }\n}\n\n/**\n * Loads all images\n * TODO - traverse gltf and determine which images are actually needed\n * @param gltf\n * @param options\n * @param context\n * @returns\n */\nasync function loadImages(gltf: GLTFWithBuffers, options, context: LoaderContext) {\n const imageIndices = getReferencesImageIndices(gltf);\n\n const images = gltf.json.images || [];\n\n const promises: Promise<any>[] = [];\n for (const imageIndex of imageIndices) {\n promises.push(loadImage(gltf, images[imageIndex], imageIndex, options, context));\n }\n\n return await Promise.all(promises);\n}\n\n/** Make sure we only load images that are actually referenced by textures */\nfunction getReferencesImageIndices(gltf: GLTFWithBuffers): number[] {\n const imageIndices = new Set<number>();\n\n const textures = gltf.json.textures || [];\n for (const texture of textures) {\n if (texture.source !== undefined) {\n imageIndices.add(texture.source);\n }\n }\n\n return Array.from(imageIndices).sort();\n}\n\n/** Asynchronously fetches and parses one image, store in images array outside of json */\nasync function loadImage(\n gltf: GLTFWithBuffers,\n image,\n index: number,\n options,\n context: LoaderContext\n) {\n let arrayBuffer;\n\n if (image.uri && !image.hasOwnProperty('bufferView')) {\n const uri = resolveUrl(image.uri, options);\n\n const {fetch} = context;\n const response = await fetch(uri);\n\n arrayBuffer = await response.arrayBuffer();\n image.bufferView = {\n data: arrayBuffer\n };\n }\n\n if (Number.isFinite(image.bufferView)) {\n const array = getTypedArrayForBufferView(gltf.json, gltf.buffers, image.bufferView);\n arrayBuffer = sliceArrayBuffer(array.buffer, array.byteOffset, array.byteLength);\n }\n\n assert(arrayBuffer, 'glTF image has no data');\n\n // Call `parse`\n let parsedImage = (await parseFromContext(\n arrayBuffer,\n [ImageLoader, BasisLoader],\n {\n ...options,\n mimeType: image.mimeType,\n basis: options.basis || {format: selectSupportedBasisFormat()}\n },\n context\n )) as ImageType | TextureLevel[][];\n\n if (parsedImage && parsedImage[0]) {\n parsedImage = {\n compressed: true,\n // @ts-expect-error\n mipmaps: false,\n width: parsedImage[0].width,\n height: parsedImage[0].height,\n data: parsedImage[0]\n };\n }\n // TODO making sure ImageLoader is overridable by using array of loaders\n // const parsedImage = await parse(arrayBuffer, [ImageLoader]);\n\n // Store the loaded image\n gltf.images = gltf.images || [];\n // @ts-expect-error TODO - sort out image typing asap\n gltf.images[index] = parsedImage;\n}\n"],"mappings":"AAQA,SAAQA,SAAS,EAAEC,gBAAgB,EAAEC,gBAAgB,QAAO,0BAA0B;AACtF,SAAQC,WAAW,QAAO,oBAAoB;AAC9C,SAAQC,WAAW,EAAEC,0BAA0B,QAAO,sBAAsB;AAE5E,SAAQC,MAAM,QAAO,iBAAiB;AACtC,SAAQC,KAAK,EAAEC,YAAY,QAAO,aAAa;AAC/C,SAAQC,UAAU,QAAO,2BAA2B;AACpD,SAAQC,0BAA0B,QAAO,+BAA+B;AACxE,SAAQC,oBAAoB,EAAEC,gBAAgB,QAAO,wBAAwB;AAC7E,SAAQC,eAAe,QAAO,0BAA0B;AAexD,OAAO,SAASC,MAAMA,CAACC,WAAwB,EAAEC,OAA0B,EAAW;EACpF,MAAMC,UAAU,GAAG,CAAC;EACpB,OAAOV,KAAK,CAACQ,WAAW,EAAEE,UAAU,EAAED,OAAO,CAAC;AAChD;AAEA,OAAO,eAAeE,SAASA,CAC7BC,IAAqB,EACrBC,mBAAmB,EAIO;EAAA,IAAAC,aAAA,EAAAC,cAAA,EAAAC,cAAA;EAAA,IAH1BN,UAAU,GAAAO,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;EAAA,IACdR,OAA0B,GAAAQ,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAAA,IAC1BC,OAAsB,GAAAH,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAEtBE,sBAAsB,CAACT,IAAI,EAAEC,mBAAmB,EAAEH,UAAU,EAAED,OAAO,CAAC;EAEtEH,eAAe,CAACM,IAAI,EAAE;IAACU,SAAS,EAAEb,OAAO,aAAPA,OAAO,wBAAAK,aAAA,GAAPL,OA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,MAAM,CAACwB,KAAK,CAAC,GAAGM,WAAW;AAClC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=gltf-ext-mesh-features-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gltf-ext-mesh-features-schema.js","names":[],"sources":["../../../../src/lib/types/gltf-ext-mesh-features-schema.ts"],"sourcesContent":["import {GLTFTextureInfoMetadata} from './gltf-json-schema';\n/* eslint-disable camelcase */\n\n/**\n * EXT_mesh_features extension types\n * This is a primitive-level extension\n * @see https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_mesh_features\n * or https://github.com/CesiumGS/glTF/blob/c38f7f37e894004353c15cd0481bc5b7381ce841/extensions/2.0/Vendor/EXT_mesh_features/schema/mesh.primitive.EXT_mesh_features.schema.json\n * An object describing feature IDs for a mesh primitive.\n */\nexport type GLTF_EXT_mesh_features = {\n /** An array of feature ID sets. */\n featureIds: GLTF_EXT_mesh_features_featureId[];\n extensions?: Record<string, unknown>;\n extras?: unknown;\n /** For internal usage */\n dataAttributeNames?: string[];\n};\n\n/**\n * @see https://github.com/CesiumGS/glTF/blob/c38f7f37e894004353c15cd0481bc5b7381ce841/extensions/2.0/Vendor/EXT_mesh_features/schema/featureId.schema.json\n * Feature IDs stored in an attribute or texture.\n */\nexport type GLTF_EXT_mesh_features_featureId = {\n /** The number of unique features in the attribute or texture. */\n featureCount: number;\n /** A value that indicates that no feature is associated with this vertex or texel. */\n nullFeatureId?: number;\n /** A label assigned to this feature ID set. Labels must be alphanumeric identifiers matching the regular expression `^[a-zA-Z_][a-zA-Z0-9_]*$`. */\n label?: string;\n /**\n * An attribute containing feature IDs.\n * When `attribute` and `texture` are omitted the feature IDs are assigned to vertices by their index.\n * @see https://github.com/CesiumGS/glTF/blob/3d-tiles-next/extensions/2.0/Vendor/EXT_mesh_features/schema/featureIdAttribute.schema.json\n * An integer value used to construct a string in the format `_FEATURE_ID_<set index>` which is a reference to a key in `mesh.primitives.attributes`\n * (e.g. a value of `0` corresponds to `_FEATURE_ID_0`).\n */\n attribute?: number;\n /** A texture containing feature IDs. */\n texture?: GLTFTextureInfoMetadata;\n /** The index of the property table containing per-feature property values. Only applicable when using the `EXT_structural_metadata` extension. */\n propertyTable?: number;\n extensions?: Record<string, unknown>;\n extras?: unknown;\n\n /** For internal usage */\n data?: unknown;\n};\n"],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=gltf-ext-structural-metadata-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gltf-ext-structural-metadata-schema.js","names":[],"sources":["../../../../src/lib/types/gltf-ext-structural-metadata-schema.ts"],"sourcesContent":["import {GLTFTextureInfoMetadata} from './gltf-json-schema';\n\n/* eslint-disable camelcase */\n\n/**\n * @see https://github.com/CesiumGS/glTF/blob/3d-tiles-next/extensions/2.0/Vendor/EXT_structural_metadata/schema/glTF.EXT_structural_metadata.schema.json\n */\nexport type GLTF_EXT_structural_metadata = {\n /** An object defining classes and enums. */\n schema?: GLTF_EXT_structural_metadata_Schema;\n /** A uri to an external schema file. */\n schemaUri?: string;\n /** An array of property table definitions, which may be referenced by index. */\n propertyTables?: GLTF_EXT_structural_metadata_PropertyTable[];\n /** An array of property texture definitions, which may be referenced by index. */\n propertyTextures?: GLTF_EXT_structural_metadata_PropertyTexture[];\n /** \"An array of property attribute definitions, which may be referenced by index. */\n propertyAttributes?: GLTF_EXT_structural_metadata_PropertyAttribute[];\n /** For internal usage */\n dataAttributeNames?: string[];\n};\n\n/**\n * @see https://github.com/CesiumGS/glTF/blob/3d-tiles-next/extensions/2.0/Vendor/EXT_structural_metadata/schema/schema.schema.json\n */\nexport type GLTF_EXT_structural_metadata_Schema = {\n /** Unique identifier for the schema. Schema IDs must be alphanumeric identifiers matching the regular expression `^[a-zA-Z_][a-zA-Z0-9_]*$`. */\n id: string;\n /** The name of the schema. */\n name?: string;\n /** The description of the schema. */\n description?: string;\n /** Application-specific version of the schema. */\n version?: string;\n /** A dictionary, where each key is a class ID and each value is an object defining the class. */\n classes?: {\n [key: string]: GLTF_EXT_structural_metadata_Class;\n };\n /** A dictionary, where each key is an enum ID and each value is an object defining the values for the enum. */\n enums?: {\n [key: string]: GLTF_EXT_structural_metadata_Enum;\n };\n extensions?: Record<string, any>;\n extras?: any;\n};\n\n/**\n * An object defining the values of an enum.\n * @see https://github.com/CesiumGS/glTF/blob/3d-tiles-next/extensions/2.0/Vendor/EXT_structural_metadata/schema/enum.schema.json\n */\nexport type GLTF_EXT_structural_metadata_Enum = {\n /** The name of the enum, e.g. for display purposes. */\n name?: string;\n /** The description of the enum. */\n description?: string;\n /** The type of the integer enum value. */\n valueType?: 'INT8' | 'UINT8' | 'INT16' | 'UINT16' | 'INT32' | 'UINT32' | 'INT64' | 'UINT64'; // default: \"UINT16\"\n /** An array of enum values. Duplicate names or duplicate integer values are not allowed. */\n values: GLTF_EXT_structural_metadata_EnumValue[];\n extensions?: Record<string, any>;\n extras?: any;\n};\n\n/**\n * @see https://github.com/CesiumGS/glTF/blob/3d-tiles-next/extensions/2.0/Vendor/EXT_structural_metadata/schema/enum.value.schema.json\n */\nexport type GLTF_EXT_structural_metadata_EnumValue = {\n /** The name of the enum value. */\n name: string;\n /** The description of the enum value. */\n description?: string;\n /** The integer enum value. */\n value: number;\n extensions?: Record<string, any>;\n extras?: any;\n};\n\n/**\n * @see https://github.com/CesiumGS/glTF/blob/3d-tiles-next/extensions/2.0/Vendor/EXT_structural_metadata/schema/class.schema.json\n */\nexport type GLTF_EXT_structural_metadata_Class = {\n /** The name of the class, e.g. for display purposes. */\n name?: string;\n /** The description of the class. */\n description?: string;\n /**\n * A dictionary, where each key is a property ID and each value is an object defining the property.\n * Property IDs must be alphanumeric identifiers matching the regular expression `^[a-zA-Z_][a-zA-Z0-9_]*$`.\n */\n properties: {\n [key: string]: GLTF_EXT_structural_metadata_ClassProperty;\n };\n extensions?: Record<string, any>;\n extras?: any;\n};\n\n/**\n * @see https://github.com/CesiumGS/glTF/blob/3d-tiles-next/extensions/2.0/Vendor/EXT_structural_metadata/schema/class.property.schema.json\n */\nexport type GLTF_EXT_structural_metadata_ClassProperty = {\n /** The name of the property, e.g. for display purposes. */\n name?: string;\n\n /** The description of the property. */\n description?: string;\n\n /** The element type. */\n type:\n | 'SCALAR'\n | 'VEC2'\n | 'VEC3'\n | 'VEC4'\n | 'MAT2'\n | 'MAT3'\n | 'MAT4'\n | 'BOOLEAN'\n | 'STRING'\n | 'ENUM';\n\n /** The datatype of the element's components. Only applicable to `SCALAR`, `VECN`, and `MATN` types. */\n componentType?:\n | 'INT8'\n | 'UINT8'\n | 'INT16'\n | 'UINT16'\n | 'INT32'\n | 'UINT32'\n | 'INT64'\n | 'UINT64'\n | 'FLOAT32'\n | 'FLOAT64';\n\n /** Enum ID as declared in the `enums` dictionary. Required when `type` is `ENUM`. */\n enumType?: string;\n\n /**\n * Whether the property is an array.\n * When `count` is defined the property is a fixed-length array. Otherwise the property is a variable-length array.\n */\n array?: boolean;\n\n /** The number of array elements. May only be defined when `array` is true. */\n count?: number;\n\n /**\n * Specifies whether integer values are normalized.\n * Only applicable to `SCALAR`, `VECN`, and `MATN` types with integer component types.\n * For unsigned integer component types, values are normalized between `[0.0, 1.0]`.\n * For signed integer component types, values are normalized between `[-1.0, 1.0]`.\n * For all other component types, this property must be false.\n */\n normalized?: boolean;\n\n /**\n * An offset to apply to property values.\n * Only applicable to `SCALAR`, `VECN`, and `MATN` types when the component type is `FLOAT32` or `FLOAT64`, or when the property is `normalized`.\n */\n offset?: number | number[];\n\n /**\n * A scale to apply to property values.\n * Only applicable to `SCALAR`, `VECN`, and `MATN` types when the component type is `FLOAT32` or `FLOAT64`, or when the property is `normalized`.\n */\n scale?: number | number[];\n\n /**\n * Maximum allowed value for the property.\n * Only applicable to `SCALAR`, `VECN`, and `MATN` types.\n * This is the maximum of all property values, after the transforms based on the `normalized`, `offset`, and `scale` properties have been applied.\n */\n max?: number | number[];\n\n /**\n * Minimum allowed value for the property.\n * Only applicable to `SCALAR`, `VECN`, and `MATN` types.\n * This is the minimum of all property values, after the transforms based on the `normalized`, `offset`, and `scale` properties have been applied.\n */\n min?: number | number[];\n\n default?: boolean | number | string | number[];\n /**\n * If required, the property must be present in every entity conforming to the class.\n * If not required, individual entities may include `noData` values, or the entire property may be omitted.\n * As a result, `noData` has no effect on a required property.\n * Client implementations may use required properties to make performance optimizations.\n */\n required?: boolean; // default false;\n\n /**\n * A `noData` value represents missing data — also known as a sentinel value — wherever it appears.\n * `BOOLEAN` properties may not specify `noData` values.\n * This is given as the plain property value, without the transforms from the `normalized`, `offset`, and `scale` properties.\n * Must not be defined if `required` is true.\n */\n noData?: number | string | number[] | string[];\n\n /**\n * An identifier that describes how this property should be interpreted.\n * The semantic cannot be used by other properties in the class.\n */\n semantic?: string;\n extensions?: Record<string, any>;\n extras?: any;\n};\n\nexport type GLTF_EXT_structural_metadata_PropertyTable = {\n /** The name of the property table, e.g. for display purposes. */\n name?: string;\n /** The class that property values conform to. The value must be a class ID declared in the `classes` dictionary. */\n class: string;\n /** The number of elements in each property array. */\n count: number;\n /**\n * A dictionary, where each key corresponds to a property ID in the class' `properties` dictionary\n * and each value is an object describing where property values are stored.\n * Required properties must be included in this dictionary.\n */\n properties?: {\n [key: string]: GLTF_EXT_structural_metadata_PropertyTable_Property;\n };\n extensions?: Record<string, any>;\n extras?: any;\n};\n\n/**\n * @see https://github.com/CesiumGS/glTF/blob/3d-tiles-next/extensions/2.0/Vendor/EXT_structural_metadata/schema/propertyTable.property.schema.json\n */\nexport type GLTF_EXT_structural_metadata_PropertyTable_Property = {\n /**\n * The index of the buffer view containing property values.\n * The data type of property values is determined by the property definition:\n * When `type` is `BOOLEAN` values are packed into a bitstream.\n * When `type` is `STRING` values are stored as byte sequences and decoded as UTF-8 strings.\n * When `type` is `SCALAR`, `VECN`, or `MATN` the values are stored as the provided `componentType`\n * and the buffer view `byteOffset` must be aligned to a multiple of the `componentType` size.\n * When `type` is `ENUM` values are stored as the enum's `valueType`\n * and the buffer view `byteOffset` must be aligned to a multiple of the `valueType` size.\n * Each enum value in the array must match one of the allowed values in the enum definition.\n * `arrayOffsets` is required for variable-length arrays and `stringOffsets` is required for strings (for variable-length arrays of strings, both are required).\n */\n values: number;\n /**\n * The index of the buffer view containing offsets for variable-length arrays.\n * The number of offsets is equal to the property table `count` plus one.\n * The offsets represent the start positions of each array, with the last offset representing the position after the last array.\n * The array length is computed using the difference between the subsequent offset and the current offset.\n * If `type` is `STRING` the offsets index into the string offsets array (stored in `stringOffsets`), otherwise they index into the property array (stored in `values`).\n * The data type of these offsets is determined by `arrayOffsetType`.\n * The buffer view `byteOffset` must be aligned to a multiple of the `arrayOffsetType` size.\n */\n arrayOffsets?: number;\n /**\n * The index of the buffer view containing offsets for strings.\n * The number of offsets is equal to the number of string elements plus one.\n * The offsets represent the byte offsets of each string in the property array (stored in `values`), with the last offset representing the byte offset after the last string.\n * The string byte length is computed using the difference between the subsequent offset and the current offset.\n * The data type of these offsets is determined by `stringOffsetType`.\n * The buffer view `byteOffset` must be aligned to a multiple of the `stringOffsetType` size.\n */\n stringOffsets?: number;\n /**\n * The type of values in `arrayOffsets`.\n */\n arrayOffsetType?: 'UINT8' | 'UINT16' | 'UINT32' | 'UINT64';\n\n /**\n * The type of values in `stringOffsets`.\n */\n stringOffsetType?: 'UINT8' | 'UINT16' | 'UINT32' | 'UINT64';\n /**\n * An offset to apply to property values.\n * Only applicable when the component type is `FLOAT32` or `FLOAT64`, or when the property is `normalized`.\n * Overrides the class property's `offset` if both are defined.\n */\n offset?: number | number[];\n /**\n * A scale to apply to property values.\n * Only applicable when the component type is `FLOAT32` or `FLOAT64`, or when the property is `normalized`.\n * Overrides the class property's `scale` if both are defined.\n */\n scale?: number | number[];\n /**\n * Maximum value present in the property values.\n * Only applicable to `SCALAR`, `VECN`, and `MATN` types.\n * This is the maximum of all property values, after the transforms based on the `normalized`, `offset`, and `scale` properties have been applied.\n */\n max?: number | number[];\n /**\n * Minimum value present in the property values.\n * Only applicable to `SCALAR`, `VECN`, and `MATN` types.\n * This is the minimum of all property values, after the transforms based on the `normalized`, `offset`, and `scale` properties have been applied.\n */\n min?: number | number[];\n extensions?: Record<string, any>;\n extras?: any;\n /** For internal usage */\n data?: unknown;\n};\n\n/**\n * @see https://github.com/CesiumGS/glTF/blob/3d-tiles-next/extensions/2.0/Vendor/EXT_structural_metadata/schema/propertyTexture.schema.json\n */\nexport type GLTF_EXT_structural_metadata_PropertyTexture = {\n /** The name of the property texture, e.g. for display purposes. */\n name?: string;\n /** The class that property values conform to. The value must be a class ID declared in the `classes` dictionary. */\n class: string;\n /**\n * A dictionary, where each key corresponds to a property ID in the class' `properties` dictionary\n * and each value is an object describing where property values are stored.\n * Required properties must be included in this dictionary.\n *\n * https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_structural_metadata\n * Each property that is defined in the propertyTexture object extends the glTF textureInfo object.\n * The texCoord specifies a texture coordinate set in the referring primitive.\n * The index is the index of the glTF texture object that stores the actual data. Additionally,\n * each property specifies an array of channels, which are the indices of the texture channels providing data for the respective property.\n * Channels of an RGBA texture are numbered 0..3 respectively.\n */\n properties?: {\n [key: string]: GLTFTextureInfoMetadata;\n };\n extensions?: Record<string, any>;\n extras?: any;\n};\n\n/**\n * @see https://github.com/CesiumGS/glTF/blob/3d-tiles-next/extensions/2.0/Vendor/EXT_structural_metadata/schema/propertyAttribute.schema.json\n */\nexport type GLTF_EXT_structural_metadata_PropertyAttribute = {\n /** The name of the property attribute, e.g. for display purposes. */\n name?: string;\n /** The class that property values conform to. The value must be a class ID declared in the `classes` dictionary. */\n class: string;\n /**\n * \"A dictionary, where each key corresponds to a property ID in the class' `properties` dictionary\n * and each value is an object describing where property values are stored.\n * Required properties must be included in this dictionary.\n */\n properties?: {\n [key: string]: any;\n };\n extensions?: Record<string, any>;\n extras?: any;\n};\n\n/**\n * @see https://github.com/CesiumGS/glTF/blob/3d-tiles-next/extensions/2.0/Vendor/EXT_structural_metadata/schema/mesh.primitive.EXT_structural_metadata.schema.json\n */\nexport type GLTF_EXT_structural_metadata_Primitive = {\n /** An array of indexes of property textures in the root `EXT_structural_metadata` object. */\n propertyTextures?: number[];\n /** An array of indexes of property attributes in the root `EXT_structural_metadata` object. */\n propertyAttributes?: number[];\n extensions?: Record<string, any>;\n extras?: any;\n};\n"],"mappings":""}