@loaders.gl/tile-converter 3.2.7 → 3.3.0-alpha.3

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 (77) hide show
  1. package/dist/3d-tiles-attributes-worker.js +3 -3
  2. package/dist/3d-tiles-attributes-worker.js.map +1 -1
  3. package/dist/converter-cli.js +30 -7
  4. package/dist/converter.min.js +1 -1
  5. package/dist/dist.min.js +1105 -621
  6. package/dist/es5/3d-tiles-attributes-worker.js +1 -1
  7. package/dist/es5/3d-tiles-attributes-worker.js.map +1 -1
  8. package/dist/es5/converter-cli.js +42 -12
  9. package/dist/es5/converter-cli.js.map +1 -1
  10. package/dist/es5/i3s-attributes-worker.js +1 -1
  11. package/dist/es5/i3s-attributes-worker.js.map +1 -1
  12. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +146 -0
  13. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -0
  14. package/dist/es5/i3s-converter/helpers/feature-attributes.js +60 -0
  15. package/dist/es5/i3s-converter/helpers/feature-attributes.js.map +1 -0
  16. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +39 -7
  17. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  18. package/dist/es5/i3s-converter/helpers/geometry-converter.js +177 -59
  19. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  20. package/dist/es5/i3s-converter/helpers/gltf-attributes.js +15 -1
  21. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  22. package/dist/es5/i3s-converter/i3s-converter.js +50 -51
  23. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  24. package/dist/es5/lib/utils/write-queue.js +3 -5
  25. package/dist/es5/lib/utils/write-queue.js.map +1 -1
  26. package/dist/es5/pgm-loader.js +1 -1
  27. package/dist/es5/pgm-loader.js.map +1 -1
  28. package/dist/esm/3d-tiles-attributes-worker.js +1 -1
  29. package/dist/esm/3d-tiles-attributes-worker.js.map +1 -1
  30. package/dist/esm/converter-cli.js +37 -7
  31. package/dist/esm/converter-cli.js.map +1 -1
  32. package/dist/esm/i3s-attributes-worker.js +1 -1
  33. package/dist/esm/i3s-attributes-worker.js.map +1 -1
  34. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +128 -0
  35. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -0
  36. package/dist/esm/i3s-converter/helpers/feature-attributes.js +34 -0
  37. package/dist/esm/i3s-converter/helpers/feature-attributes.js.map +1 -0
  38. package/dist/esm/i3s-converter/helpers/geometry-attributes.js +23 -7
  39. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  40. package/dist/esm/i3s-converter/helpers/geometry-converter.js +145 -38
  41. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  42. package/dist/esm/i3s-converter/helpers/gltf-attributes.js +15 -1
  43. package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  44. package/dist/esm/i3s-converter/i3s-converter.js +21 -27
  45. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  46. package/dist/esm/lib/utils/write-queue.js +3 -5
  47. package/dist/esm/lib/utils/write-queue.js.map +1 -1
  48. package/dist/esm/pgm-loader.js +1 -1
  49. package/dist/esm/pgm-loader.js.map +1 -1
  50. package/dist/i3s-attributes-worker.js +3 -3
  51. package/dist/i3s-attributes-worker.js.map +3 -3
  52. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +12 -0
  53. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -0
  54. package/dist/i3s-converter/helpers/batch-ids-extensions.js +138 -0
  55. package/dist/i3s-converter/helpers/feature-attributes.d.ts +24 -0
  56. package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +1 -0
  57. package/dist/i3s-converter/helpers/feature-attributes.js +55 -0
  58. package/dist/i3s-converter/helpers/geometry-attributes.js +26 -7
  59. package/dist/i3s-converter/helpers/geometry-converter.d.ts +9 -2
  60. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  61. package/dist/i3s-converter/helpers/geometry-converter.js +140 -44
  62. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
  63. package/dist/i3s-converter/helpers/gltf-attributes.js +13 -0
  64. package/dist/i3s-converter/i3s-converter.d.ts +7 -14
  65. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  66. package/dist/i3s-converter/i3s-converter.js +44 -35
  67. package/dist/lib/utils/write-queue.d.ts.map +1 -1
  68. package/dist/lib/utils/write-queue.js +3 -4
  69. package/package.json +15 -15
  70. package/src/converter-cli.ts +33 -7
  71. package/src/i3s-converter/helpers/batch-ids-extensions.ts +199 -0
  72. package/src/i3s-converter/helpers/feature-attributes.ts +65 -0
  73. package/src/i3s-converter/helpers/geometry-attributes.ts +30 -7
  74. package/src/i3s-converter/helpers/geometry-converter.ts +187 -48
  75. package/src/i3s-converter/helpers/gltf-attributes.ts +15 -0
  76. package/src/i3s-converter/i3s-converter.ts +38 -41
  77. package/src/lib/utils/write-queue.ts +7 -5
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/i3s-converter/helpers/geometry-attributes.ts"],"names":["VALUES_PER_VERTEX","POSITIONS_AND_NORMALS_PER_TRIANGLE","generateAttributes","attributes","positions","normals","texCoords","colors","featureIndices","triangleCount","length","faceRange","Uint32Array","featureIds","featureCount","data","calculateFaceRangesAndFeaturesCount","attributeObjects","makeAttributeObjects","unifiedAttributeObjectsByFeatureIds","unifyObjectsByFeatureId","groupedAttributes","groupAttributesAndRangesByFeatureId","rangeIndex","featureIndex","currentFeatureId","faceRangeList","uniqueFeatureIds","index","includes","push","groupedData","positionsList","Float32Array","normalsList","colorsList","Uint8Array","texCoordsList","faceRangeIndex","startIndex","endIndex","positionsCount","getSliceAttributeCount","normalsCount","colorsCount","texCoordsCount","featureId","slice","sort","first","second","attributeName","colorsPerVertex","texCoordsPerVertex","trianglesCount","vertexCount","sortedData","uniqueObjects","currentObject","existedObject","find","obj","unifiedObjects","firstAttributeObject","range","objIndex","sum","currentAttributesObject","groupedObject"],"mappings":";;;;;;;;;;;AACA;;;;;;AAEA,IAAMA,iBAAiB,GAAG,CAA1B;AACA,IAAMC,kCAAkC,GAAG,CAA3C;;AAOO,SAASC,kBAAT,CAA4BC,UAA5B,EAAiF;AACtF,MAAOC,SAAP,GAAgED,UAAhE,CAAOC,SAAP;AAAA,MAAkBC,OAAlB,GAAgEF,UAAhE,CAAkBE,OAAlB;AAAA,MAA2BC,SAA3B,GAAgEH,UAAhE,CAA2BG,SAA3B;AAAA,MAAsCC,MAAtC,GAAgEJ,UAAhE,CAAsCI,MAAtC;AAAA,MAA8CC,cAA9C,GAAgEL,UAAhE,CAA8CK,cAA9C;AACA,MAAMC,aAAa,GAAGL,SAAS,CAACM,MAAV,GAAmBT,kCAAzC;;AAEA,MAAI,CAACO,cAAc,CAACE,MAApB,EAA4B;AAC1B,WAAO;AACLC,MAAAA,SAAS,EAAE,IAAIC,WAAJ,CAAgB,CAAC,CAAD,EAAIH,aAAa,GAAG,CAApB,CAAhB,CADN;AAELI,MAAAA,UAAU,EAAE,CAAC,CAAD,CAFP;AAGLC,MAAAA,YAAY,EAAE,CAHT;AAILV,MAAAA,SAAS,EAATA,SAJK;AAKLC,MAAAA,OAAO,EAAPA,OALK;AAMLC,MAAAA,SAAS,EAATA,SANK;AAOLC,MAAAA,MAAM,EAANA;AAPK,KAAP;AASD;;AAED,MAAMQ,IAAI,GAAGC,mCAAmC,CAACR,cAAD,CAAhD;AACA,MAAMS,gBAAgB,GAAGC,oBAAoB,iCAAKH,IAAL,GAAcZ,UAAd,EAA7C;AACA,MAAMgB,mCAAmC,GAAGC,uBAAuB,CAACH,gBAAD,CAAnE;AACA,MAAMI,iBAAiB,GAAGC,mCAAmC,CAC3DH,mCAD2D,EAE3DJ,IAAI,CAACD,YAFsD,CAA7D;AAIA,SAAOO,iBAAP;AACD;;AAOD,SAASL,mCAAT,CAA6CR,cA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BA,SAAvB,EAAkC6D,uBAAuB,CAAC7D,SAA1D,CAAZ;AAEA,QAAM8D,aAAa,GAAGN,cAAc,CAACG,QAAD,CAApC;AACAD,IAAAA,KAAK,CAAClC,IAAN,CAAWsC,aAAa,CAAChE,SAAd,CAAwBM,MAAxB,GAAiCT,kCAAjC,GAAsE,CAAtE,GAA0EiE,GAArF;AACAF,IAAAA,KAAK,CAAClC,IAAN,CAAWsC,aAAa,CAAChE,SAAd,CAAwBM,MAAxB,GAAiCT,kCAAjC,GAAsEiE,GAAjF;AAEAA,IAAAA,GAAG,IAAIE,aAAa,CAAChE,SAAd,CAAwBM,MAAxB,GAAiCT,kCAAxC;AACAgE,IAAAA,QAAQ,IAAI,CAAZ;AACD;;AAEDD,EAAAA,KAAK,CAAClC,IAAN,CAAW1B,SAAS,CAACM,MAAV,GAAmBT,kCAAnB,GAAwD,CAAnE;AAEA,MAAMU,SAAS,GAAG,IAAIC,WAAJ,CAAgBoD,KAAhB,CAAlB;AACA,SAAO;AAACrD,IAAAA,SAAS,EAATA,SAAD;AAAYE,IAAAA,UAAU,EAAVA,UAAZ;AAAwBT,IAAAA,SAAS,EAATA,SAAxB;AAAmCC,IAAAA,OAAO,EAAPA,OAAnC;AAA4CE,IAAAA,MAAM,EAANA,MAA5C;AAAoDD,IAAAA,SAAS,EAATA,SAApD;AAA+DQ,IAAAA,YAAY,EAAZA;AAA/D,GAAP;AACD","sourcesContent":["import type {GeometryAttributes, ConvertedAttributes, GroupedByFeatureIdAttributes} from '../types';\nimport {concatenateTypedArrays} from '@loaders.gl/loader-utils';\n\nconst VALUES_PER_VERTEX = 3;\nconst POSITIONS_AND_NORMALS_PER_TRIANGLE = 9;\n\n/**\n * Generate geometry attributes with faceRange and featureCount\n * @param attributes\n * @returns attirbutes with featureCount, featureIds and changed faceRange.\n */\nexport function generateAttributes(attributes: ConvertedAttributes): GeometryAttributes {\n const {positions, normals, texCoords, colors, featureIndices} = attributes;\n const triangleCount = positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;\n\n if (!featureIndices.length) {\n return {\n faceRange: new Uint32Array([0, triangleCount - 1]),\n featureIds: [0],\n featureCount: 1,\n positions,\n normals,\n texCoords,\n colors\n };\n }\n\n const data = calculateFaceRangesAndFeaturesCount(featureIndices);\n const attributeObjects = makeAttributeObjects({...data, ...attributes});\n const unifiedAttributeObjectsByFeatureIds = unifyObjectsByFeatureId(attributeObjects);\n const groupedAttributes = groupAttributesAndRangesByFeatureId(\n unifiedAttributeObjectsByFeatureIds,\n data.featureCount\n );\n return groupedAttributes;\n}\n\n/**\n * Calculates face Ranges and feature count based on featureIndices.\n * @param featureIndices\n * @returns Object with featureCount, reordered attributes and changed faceRange.\n */\nfunction calculateFaceRangesAndFeaturesCount(featureIndices: number[]): {\n faceRange: Uint32Array;\n featureCount: number;\n featureIds: number[];\n} {\n let rangeIndex = 1;\n let featureIndex = 1;\n let currentFeatureId = featureIndices[0];\n const faceRangeList: any[] = [];\n const featureIds: any[] = [];\n const uniqueFeatureIds = [currentFeatureId];\n\n faceRangeList[0] = 0;\n featureIds[0] = currentFeatureId;\n\n for (let index = 1; index < featureIndices.length; index++) {\n if (currentFeatureId !== featureIndices[index]) {\n faceRangeList[rangeIndex] = index / VALUES_PER_VERTEX - 1;\n faceRangeList[rangeIndex + 1] = index / VALUES_PER_VERTEX;\n featureIds[featureIndex] = featureIndices[index];\n\n if (!uniqueFeatureIds.includes(featureIndices[index])) {\n uniqueFeatureIds.push(featureIndices[index]);\n }\n\n rangeIndex += 2;\n featureIndex += 1;\n }\n currentFeatureId = featureIndices[index];\n }\n\n faceRangeList[rangeIndex] = featureIndices.length / VALUES_PER_VERTEX - 1;\n\n const faceRange = new Uint32Array(faceRangeList);\n const featureCount = uniqueFeatureIds.length;\n\n return {faceRange, featureCount, featureIds};\n}\n\n/**\n * Generate list of attribute object grouped by feature ids.\n * @param attributes\n * @returns sorted list of attribute objects.\n */\nfunction makeAttributeObjects(attributes: GeometryAttributes): GroupedByFeatureIdAttributes[] {\n const {\n featureIds,\n positions,\n normals,\n colors,\n texCoords,\n faceRange = new Uint32Array(0)\n } = attributes;\n const groupedData: GroupedByFeatureIdAttributes[] = [];\n\n let positionsList = new Float32Array(positions);\n let normalsList = new Float32Array(normals);\n let colorsList = new Uint8Array(colors);\n let texCoordsList = new Float32Array(texCoords);\n\n let faceRangeIndex = 0;\n\n for (let index = 0; index < featureIds.length; index++) {\n const startIndex = faceRange[index + faceRangeIndex];\n const endIndex = faceRange[index + faceRangeIndex + 1];\n\n const positionsCount = getSliceAttributeCount('positions', startIndex, endIndex);\n const normalsCount = getSliceAttributeCount('normals', startIndex, endIndex);\n const colorsCount = getSliceAttributeCount('colors', startIndex, endIndex);\n const texCoordsCount = getSliceAttributeCount('texCoords', startIndex, endIndex);\n\n groupedData.push({\n featureId: featureIds[index],\n positions: positionsList.slice(0, positionsCount),\n normals: normalsList.slice(0, normalsCount),\n colors: colorsList.slice(0, colorsCount),\n texCoords: texCoordsList.slice(0, texCoordsCount)\n });\n\n positionsList = positionsList.slice(positionsCount);\n normalsList = normalsList.slice(normalsCount);\n colorsList = colorsList.slice(colorsCount);\n texCoordsList = texCoordsList.slice(texCoordsCount);\n\n faceRangeIndex += 1;\n }\n\n return groupedData.sort((first, second) => first.featureId - second.featureId);\n}\n\n/**\n * Generate sliced count for generating attribute objects depends on attribute name and range.\n * @param attributeName\n * @param startIndex\n * @param endIndex\n * @returns sliced count\n */\nfunction getSliceAttributeCount(\n attributeName: string,\n startIndex: number,\n endIndex: number\n): number {\n const colorsPerVertex = 4;\n const texCoordsPerVertex = 2;\n\n const trianglesCount = endIndex - startIndex + 1;\n const vertexCount = trianglesCount * 3;\n\n switch (attributeName) {\n case 'positions':\n case 'normals':\n return trianglesCount * POSITIONS_AND_NORMALS_PER_TRIANGLE;\n case 'colors':\n return vertexCount * colorsPerVertex;\n case 'texCoords':\n return vertexCount * texCoordsPerVertex;\n default:\n return 0;\n }\n}\n\n/**\n * Generates unique object list depends on feature ids and concantenate their attributes.\n * @param sortedData\n * @returns unique list of objects\n */\nfunction unifyObjectsByFeatureId(\n sortedData: GroupedByFeatureIdAttributes[]\n): GroupedByFeatureIdAttributes[] {\n const uniqueObjects: GroupedByFeatureIdAttributes[] = [];\n\n for (let index = 0; index < sortedData.length; index++) {\n const currentObject = sortedData[index];\n const existedObject = uniqueObjects.find((obj) => obj.featureId === currentObject.featureId);\n\n if (existedObject) {\n existedObject.positions = concatenateTypedArrays(\n existedObject.positions,\n currentObject.positions\n );\n existedObject.normals = concatenateTypedArrays(existedObject.normals, currentObject.normals);\n existedObject.colors = concatenateTypedArrays(existedObject.colors, currentObject.colors);\n existedObject.texCoords = concatenateTypedArrays(\n existedObject.texCoords,\n currentObject.texCoords\n );\n } else {\n uniqueObjects.push(currentObject);\n }\n }\n\n return uniqueObjects;\n}\n\n/**\n * Generates attribute objects with new faceRange and reordered attributes.\n * @param unifiedObjects\n * @returns generated attributes with new faceRange.\n */\nfunction groupAttributesAndRangesByFeatureId(\n unifiedObjects: GroupedByFeatureIdAttributes[],\n featureCount: number\n): GeometryAttributes {\n const firstAttributeObject = unifiedObjects[0];\n const featureIds = [firstAttributeObject.featureId || 0];\n\n let positions = new Float32Array(firstAttributeObject.positions);\n let normals = new Float32Array(firstAttributeObject.normals);\n let colors = new Uint8Array(firstAttributeObject.colors);\n let texCoords = new Float32Array(firstAttributeObject.texCoords);\n const range = [0];\n\n let objIndex = 0;\n let sum = 0;\n\n for (let index = 1; index < unifiedObjects.length; index++) {\n const currentAttributesObject = unifiedObjects[index];\n featureIds.push(currentAttributesObject.featureId || 0);\n\n positions = concatenateTypedArrays(positions, currentAttributesObject.positions);\n normals = concatenateTypedArrays(normals, currentAttributesObject.normals);\n colors = concatenateTypedArrays(colors, currentAttributesObject.colors);\n texCoords = concatenateTypedArrays(texCoords, currentAttributesObject.texCoords);\n\n const groupedObject = unifiedObjects[objIndex];\n range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1 + sum);\n range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE + sum);\n\n sum += groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;\n objIndex += 1;\n }\n\n range.push(positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1);\n\n const faceRange = new Uint32Array(range);\n return {faceRange, featureIds, positions, normals, colors, texCoords, featureCount};\n}\n"],"file":"geometry-attributes.js"}
1
+ {"version":3,"sources":["../../../../src/i3s-converter/helpers/geometry-attributes.ts"],"names":["VALUES_PER_VERTEX","POSITIONS_AND_NORMALS_PER_TRIANGLE","generateAttributes","attributes","positions","normals","texCoords","colors","featureIndices","triangleCount","length","faceRange","Uint32Array","featureIds","featureCount","data","calculateFaceRangesAndFeaturesCount","attributeObjects","makeAttributeObjects","unifiedAttributeObjectsByFeatureIds","unifyObjectsByFeatureId","groupedAttributes","groupAttributesAndRangesByFeatureId","rangeIndex","featureIndex","currentFeatureId","getFrequentValue","slice","faceRangeList","uniqueFeatureIds","index","newFeatureId","includes","push","values","map","mostFrequentValue","maxCount","value","groupedData","positionsList","Float32Array","normalsList","colorsList","Uint8Array","texCoordsList","faceRangeIndex","startIndex","endIndex","positionsCount","getSliceAttributeCount","normalsCount","colorsCount","texCoordsCount","featureId","sort","first","second","attributeName","colorsPerVertex","texCoordsPerVertex","trianglesCount","vertexCount","sortedData","uniqueObjects","currentObject","existedObject","find","obj","unifiedObjects","firstAttributeObject","range","objIndex","sum","currentAttributesObject","groupedObject"],"mappings":";;;;;;;;;;;AACA;;;;;;;;;;;;AAEA,IAAMA,iBAAiB,GAAG,CAA1B;AACA,IAAMC,kCAAkC,GAAG,CAA3C;;AAOO,SAASC,kBAAT,CAA4BC,UAA5B,EAAiF;AACtF,MAAOC,SAAP,GAAgED,UAAhE,CAAOC,SAAP;AAAA,MAAkBC,OAAlB,GAAgEF,UAAhE,CAAkBE,OAAlB;AAAA,MAA2BC,SAA3B,GAAgEH,UAAhE,CAA2BG,SA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;AAA/D,GAAP;AACD","sourcesContent":["import type {GeometryAttributes, ConvertedAttributes, GroupedByFeatureIdAttributes} from '../types';\nimport {concatenateTypedArrays} from '@loaders.gl/loader-utils';\n\nconst VALUES_PER_VERTEX = 3;\nconst POSITIONS_AND_NORMALS_PER_TRIANGLE = 9;\n\n/**\n * Generate geometry attributes with faceRange and featureCount\n * @param attributes\n * @returns attirbutes with featureCount, featureIds and changed faceRange.\n */\nexport function generateAttributes(attributes: ConvertedAttributes): GeometryAttributes {\n const {positions, normals, texCoords, colors, featureIndices} = attributes;\n const triangleCount = positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;\n\n if (!featureIndices.length) {\n return {\n faceRange: new Uint32Array([0, triangleCount - 1]),\n featureIds: [0],\n featureCount: 1,\n positions,\n normals,\n texCoords,\n colors\n };\n }\n\n const data = calculateFaceRangesAndFeaturesCount(featureIndices);\n const attributeObjects = makeAttributeObjects({...data, ...attributes});\n const unifiedAttributeObjectsByFeatureIds = unifyObjectsByFeatureId(attributeObjects);\n const groupedAttributes = groupAttributesAndRangesByFeatureId(\n unifiedAttributeObjectsByFeatureIds,\n data.featureCount\n );\n return groupedAttributes;\n}\n\n/**\n * Calculates face Ranges and feature count based on featureIndices.\n * @param featureIndices\n * @returns Object with featureCount, reordered attributes and changed faceRange.\n */\nfunction calculateFaceRangesAndFeaturesCount(featureIndices: number[]): {\n faceRange: Uint32Array;\n featureCount: number;\n featureIds: number[];\n} {\n let rangeIndex = 1;\n let featureIndex = 1;\n let currentFeatureId = getFrequentValue(featureIndices.slice(0, VALUES_PER_VERTEX));\n const faceRangeList: any[] = [];\n const featureIds: any[] = [];\n const uniqueFeatureIds = [currentFeatureId];\n\n faceRangeList[0] = 0;\n featureIds[0] = currentFeatureId;\n\n for (let index = VALUES_PER_VERTEX; index < featureIndices.length; index += VALUES_PER_VERTEX) {\n const newFeatureId = getFrequentValue(featureIndices.slice(index, index + VALUES_PER_VERTEX));\n if (currentFeatureId !== newFeatureId) {\n faceRangeList[rangeIndex] = index / VALUES_PER_VERTEX - 1;\n faceRangeList[rangeIndex + 1] = index / VALUES_PER_VERTEX;\n featureIds[featureIndex] = newFeatureId;\n\n if (!uniqueFeatureIds.includes(newFeatureId)) {\n uniqueFeatureIds.push(newFeatureId);\n }\n\n rangeIndex += 2;\n featureIndex += 1;\n }\n currentFeatureId = newFeatureId;\n }\n\n faceRangeList[rangeIndex] = featureIndices.length / VALUES_PER_VERTEX - 1;\n\n const faceRange = new Uint32Array(faceRangeList);\n const featureCount = uniqueFeatureIds.length;\n\n return {faceRange, featureCount, featureIds};\n}\n\n/**\n * Find most frequent value to avoid situation where one vertex can be part of multiple features (objects).\n * @param values\n */\nfunction getFrequentValue(values: number[]): number {\n const map: {[key: number]: number} = {};\n\n let mostFrequentValue = values[0];\n let maxCount = 1;\n\n for (const value of values) {\n // Save item and it's frequency count to the map.\n map[value] = (map[value] || 0) + 1;\n // Find max count of frequency.\n maxCount = maxCount > map[value] ? maxCount : map[value];\n // Find the most frequent value.\n mostFrequentValue = maxCount > map[value] ? mostFrequentValue : value;\n }\n\n return mostFrequentValue;\n}\n\n/**\n * Generate list of attribute object grouped by feature ids.\n * @param attributes\n * @returns sorted list of attribute objects.\n */\nfunction makeAttributeObjects(attributes: GeometryAttributes): GroupedByFeatureIdAttributes[] {\n const {\n featureIds,\n positions,\n normals,\n colors,\n texCoords,\n faceRange = new Uint32Array(0)\n } = attributes;\n const groupedData: GroupedByFeatureIdAttributes[] = [];\n\n let positionsList = new Float32Array(positions);\n let normalsList = new Float32Array(normals);\n let colorsList = new Uint8Array(colors);\n let texCoordsList = new Float32Array(texCoords);\n\n let faceRangeIndex = 0;\n\n for (let index = 0; index < featureIds.length; index++) {\n const startIndex = faceRange[index + faceRangeIndex];\n const endIndex = faceRange[index + faceRangeIndex + 1];\n\n const positionsCount = getSliceAttributeCount('positions', startIndex, endIndex);\n const normalsCount = getSliceAttributeCount('normals', startIndex, endIndex);\n const colorsCount = getSliceAttributeCount('colors', startIndex, endIndex);\n const texCoordsCount = getSliceAttributeCount('texCoords', startIndex, endIndex);\n\n groupedData.push({\n featureId: featureIds[index],\n positions: positionsList.slice(0, positionsCount),\n normals: normalsList.slice(0, normalsCount),\n colors: colorsList.slice(0, colorsCount),\n texCoords: texCoordsList.slice(0, texCoordsCount)\n });\n\n positionsList = positionsList.slice(positionsCount);\n normalsList = normalsList.slice(normalsCount);\n colorsList = colorsList.slice(colorsCount);\n texCoordsList = texCoordsList.slice(texCoordsCount);\n\n faceRangeIndex += 1;\n }\n\n return groupedData.sort((first, second) => first.featureId - second.featureId);\n}\n\n/**\n * Generate sliced count for generating attribute objects depends on attribute name and range.\n * @param attributeName\n * @param startIndex\n * @param endIndex\n * @returns sliced count\n */\nfunction getSliceAttributeCount(\n attributeName: string,\n startIndex: number,\n endIndex: number\n): number {\n const colorsPerVertex = 4;\n const texCoordsPerVertex = 2;\n\n const trianglesCount = endIndex - startIndex + 1;\n const vertexCount = trianglesCount * 3;\n\n switch (attributeName) {\n case 'positions':\n case 'normals':\n return trianglesCount * POSITIONS_AND_NORMALS_PER_TRIANGLE;\n case 'colors':\n return vertexCount * colorsPerVertex;\n case 'texCoords':\n return vertexCount * texCoordsPerVertex;\n default:\n return 0;\n }\n}\n\n/**\n * Generates unique object list depends on feature ids and concantenate their attributes.\n * @param sortedData\n * @returns unique list of objects\n */\nfunction unifyObjectsByFeatureId(\n sortedData: GroupedByFeatureIdAttributes[]\n): GroupedByFeatureIdAttributes[] {\n const uniqueObjects: GroupedByFeatureIdAttributes[] = [];\n\n for (let index = 0; index < sortedData.length; index++) {\n const currentObject = sortedData[index];\n const existedObject = uniqueObjects.find((obj) => obj.featureId === currentObject.featureId);\n\n if (existedObject) {\n existedObject.positions = concatenateTypedArrays(\n existedObject.positions,\n currentObject.positions\n );\n existedObject.normals = concatenateTypedArrays(existedObject.normals, currentObject.normals);\n existedObject.colors = concatenateTypedArrays(existedObject.colors, currentObject.colors);\n existedObject.texCoords = concatenateTypedArrays(\n existedObject.texCoords,\n currentObject.texCoords\n );\n } else {\n uniqueObjects.push(currentObject);\n }\n }\n\n return uniqueObjects;\n}\n\n/**\n * Generates attribute objects with new faceRange and reordered attributes.\n * @param unifiedObjects\n * @returns generated attributes with new faceRange.\n */\nfunction groupAttributesAndRangesByFeatureId(\n unifiedObjects: GroupedByFeatureIdAttributes[],\n featureCount: number\n): GeometryAttributes {\n const firstAttributeObject = unifiedObjects[0];\n const featureIds = [firstAttributeObject.featureId || 0];\n\n let positions = new Float32Array(firstAttributeObject.positions);\n let normals = new Float32Array(firstAttributeObject.normals);\n let colors = new Uint8Array(firstAttributeObject.colors);\n let texCoords = new Float32Array(firstAttributeObject.texCoords);\n const range = [0];\n\n let objIndex = 0;\n let sum = 0;\n\n for (let index = 1; index < unifiedObjects.length; index++) {\n const currentAttributesObject = unifiedObjects[index];\n featureIds.push(currentAttributesObject.featureId || 0);\n\n positions = concatenateTypedArrays(positions, currentAttributesObject.positions);\n normals = concatenateTypedArrays(normals, currentAttributesObject.normals);\n colors = concatenateTypedArrays(colors, currentAttributesObject.colors);\n texCoords = concatenateTypedArrays(texCoords, currentAttributesObject.texCoords);\n\n const groupedObject = unifiedObjects[objIndex];\n range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1 + sum);\n range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE + sum);\n\n sum += groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;\n objIndex += 1;\n }\n\n range.push(positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1);\n\n const faceRange = new Uint32Array(range);\n return {faceRange, featureIds, positions, normals, colors, texCoords, featureCount};\n}\n"],"file":"geometry-attributes.js"}
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = convertB3dmToI3sGeometry;
9
9
  exports.convertAttributes = convertAttributes;
10
+ exports.getPropertyTable = getPropertyTable;
10
11
 
11
12
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
12
13
 
@@ -32,6 +33,10 @@ var _coordinateConverter = require("./coordinate-converter");
32
33
 
33
34
  var _gltfAttributes = require("./gltf-attributes");
34
35
 
36
+ var _batchIdsExtensions = require("./batch-ids-extensions");
37
+
38
+ var _featureAttributes = require("./feature-attributes");
39
+
35
40
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
36
41
 
37
42
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
@@ -52,14 +57,16 @@ var SHORT_INT_TYPE = 'Int32';
52
57
  var DOUBLE_TYPE = 'Float64';
53
58
  var OBJECT_ID_TYPE = 'Oid32';
54
59
  var BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES = ['CUSTOM_ATTRIBUTE_2', '_BATCHID', 'BATCHID'];
60
+ var EXT_FEATURE_METADATA = 'EXT_feature_metadata';
61
+ var EXT_MESH_FEATURES = 'EXT_mesh_features';
55
62
  var scratchVector = new _core.Vector3();
56
63
 
57
- function convertB3dmToI3sGeometry(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8) {
64
+ function convertB3dmToI3sGeometry(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8, _x9) {
58
65
  return _convertB3dmToI3sGeometry.apply(this, arguments);
59
66
  }
60
67
 
61
68
  function _convertB3dmToI3sGeometry() {
62
- _convertB3dmToI3sGeometry = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(tileContent, nodeId, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, geoidHeightModel, workerSource) {
69
+ _convertB3dmToI3sGeometry = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(tileContent, nodeId, propertyTable, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, geoidHeightModel, workerSource) {
63
70
  var _tileContent$gltf;
64
71
 
65
72
  var useCartesianPositions, materialAndTextureList, dataForAttributesConversion, convertedAttributesMap, result, nodesCounter, _ref3, _ref3$materials, materials, i, sourceMaterial, convertedAttributes, _materialAndTextureLi, material, texture;
@@ -137,6 +144,7 @@ function _convertB3dmToI3sGeometry() {
137
144
  tileContent: tileContent,
138
145
  nodeId: nodesCounter,
139
146
  featuresHashArray: featuresHashArray,
147
+ propertyTable: propertyTable,
140
148
  attributeStorageInfo: attributeStorageInfo,
141
149
  draco: draco,
142
150
  workerSource: workerSource
@@ -203,7 +211,7 @@ function _generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeigh
203
211
  }
204
212
  }
205
213
 
206
- function _makeNodeResources(_x9) {
214
+ function _makeNodeResources(_x10) {
207
215
  return _makeNodeResources2.apply(this, arguments);
208
216
  }
209
217
 
@@ -211,13 +219,13 @@ function _makeNodeResources2() {
211
219
  _makeNodeResources2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(_ref) {
212
220
  var _tileContent$gltf2;
213
221
 
214
- var convertedAttributes, material, texture, tileContent, nodeId, featuresHashArray, attributeStorageInfo, draco, workerSource, boundingVolumes, vertexCount, _generateAttributes, faceRange, featureIds, positions, normals, colors, texCoords, featureCount, header, typedFeatureIds, fileBuffer, compressedGeometry, attributes;
222
+ var convertedAttributes, material, texture, tileContent, nodeId, featuresHashArray, propertyTable, attributeStorageInfo, draco, workerSource, boundingVolumes, vertexCount, _generateAttributes, faceRange, featureIds, positions, normals, colors, texCoords, featureCount, header, typedFeatureIds, fileBuffer, compressedGeometry, attributes;
215
223
 
216
224
  return _regenerator.default.wrap(function _callee2$(_context2) {
217
225
  while (1) {
218
226
  switch (_context2.prev = _context2.next) {
219
227
  case 0:
220
- convertedAttributes = _ref.convertedAttributes, material = _ref.material, texture = _ref.texture, tileContent = _ref.tileContent, nodeId = _ref.nodeId, featuresHashArray = _ref.featuresHashArray, attributeStorageInfo = _ref.attributeStorageInfo, draco = _ref.draco, workerSource = _ref.workerSource;
228
+ convertedAttributes = _ref.convertedAttributes, material = _ref.material, texture = _ref.texture, tileContent = _ref.tileContent, nodeId = _ref.nodeId, featuresHashArray = _ref.featuresHashArray, propertyTable = _ref.propertyTable, attributeStorageInfo = _ref.attributeStorageInfo, draco = _ref.draco, workerSource = _ref.workerSource;
221
229
  boundingVolumes = convertedAttributes.boundingVolumes;
222
230
  vertexCount = convertedAttributes.positions.length / VALUES_PER_VERTEX;
223
231
  _generateAttributes = (0, _geometryAttributes.generateAttributes)(convertedAttributes), faceRange = _generateAttributes.faceRange, featureIds = _generateAttributes.featureIds, positions = _generateAttributes.positions, normals = _generateAttributes.normals, colors = _generateAttributes.colors, texCoords = _generateAttributes.texCoords, featureCount = _generateAttributes.featureCount;
@@ -238,7 +246,12 @@ function _makeNodeResources2() {
238
246
  featureIds: featureIds,
239
247
  faceRange: faceRange
240
248
  }, workerSource.draco) : null;
241
- attributes = convertBatchTableToAttributeBuffers(tileContent.batchTableJson, featureIds, attributeStorageInfo);
249
+ attributes = [];
250
+
251
+ if (attributeStorageInfo && propertyTable) {
252
+ attributes = convertPropertyTableToAttributeBuffers(featureIds, propertyTable, attributeStorageInfo);
253
+ }
254
+
242
255
  return _context2.abrupt("return", {
243
256
  geometry: fileBuffer,
244
257
  compressedGeometry: compressedGeometry,
@@ -251,7 +264,7 @@ function _makeNodeResources2() {
251
264
  boundingVolumes: boundingVolumes
252
265
  });
253
266
 
254
- case 12:
267
+ case 13:
255
268
  case "end":
256
269
  return _context2.stop();
257
270
  }
@@ -261,13 +274,13 @@ function _makeNodeResources2() {
261
274
  return _makeNodeResources2.apply(this, arguments);
262
275
  }
263
276
 
264
- function convertAttributes(_x10, _x11) {
277
+ function convertAttributes(_x11, _x12) {
265
278
  return _convertAttributes.apply(this, arguments);
266
279
  }
267
280
 
268
281
  function _convertAttributes() {
269
282
  _convertAttributes = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee3(attributesData, useCartesianPositions) {
270
- var gltfMaterials, nodes, cartographicOrigin, cartesianModelMatrix, attributesMap, _iterator6, _step6, material, _iterator7, _step7, attrKey, attributes;
283
+ var gltfMaterials, nodes, cartographicOrigin, cartesianModelMatrix, attributesMap, _iterator7, _step7, material, _iterator8, _step8, attrKey, attributes;
271
284
 
272
285
  return _regenerator.default.wrap(function _callee3$(_context3) {
273
286
  while (1) {
@@ -275,13 +288,13 @@ function _convertAttributes() {
275
288
  case 0:
276
289
  gltfMaterials = attributesData.gltfMaterials, nodes = attributesData.nodes, cartographicOrigin = attributesData.cartographicOrigin, cartesianModelMatrix = attributesData.cartesianModelMatrix;
277
290
  attributesMap = new Map();
278
- _iterator6 = _createForOfIteratorHelper(gltfMaterials || [{
291
+ _iterator7 = _createForOfIteratorHelper(gltfMaterials || [{
279
292
  id: 'default'
280
293
  }]);
281
294
 
282
295
  try {
283
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
284
- material = _step6.value;
296
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
297
+ material = _step7.value;
285
298
  attributesMap.set(material.id, {
286
299
  positions: new Float32Array(0),
287
300
  normals: new Float32Array(0),
@@ -293,24 +306,24 @@ function _convertAttributes() {
293
306
  });
294
307
  }
295
308
  } catch (err) {
296
- _iterator6.e(err);
309
+ _iterator7.e(err);
297
310
  } finally {
298
- _iterator6.f();
311
+ _iterator7.f();
299
312
  }
300
313
 
301
314
  convertNodes(nodes, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions);
302
- _iterator7 = _createForOfIteratorHelper(attributesMap.keys());
315
+ _iterator8 = _createForOfIteratorHelper(attributesMap.keys());
303
316
  _context3.prev = 6;
304
317
 
305
- _iterator7.s();
318
+ _iterator8.s();
306
319
 
307
320
  case 8:
308
- if ((_step7 = _iterator7.n()).done) {
321
+ if ((_step8 = _iterator8.n()).done) {
309
322
  _context3.next = 19;
310
323
  break;
311
324
  }
312
325
 
313
- attrKey = _step7.value;
326
+ attrKey = _step8.value;
314
327
  attributes = attributesMap.get(attrKey);
315
328
 
316
329
  if (attributes) {
@@ -349,12 +362,12 @@ function _convertAttributes() {
349
362
  _context3.prev = 21;
350
363
  _context3.t0 = _context3["catch"](6);
351
364
 
352
- _iterator7.e(_context3.t0);
365
+ _iterator8.e(_context3.t0);
353
366
 
354
367
  case 24:
355
368
  _context3.prev = 24;
356
369
 
357
- _iterator7.f();
370
+ _iterator8.f();
358
371
 
359
372
  return _context3.finish(24);
360
373
 
@@ -421,17 +434,18 @@ function convertNode(node, cartographicOrigin, cartesianModelMatrix, attributesM
421
434
  var matrix = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
422
435
  var transformationMatrix = getCompositeTransformationMatrix(node, matrix);
423
436
  var mesh = node.mesh;
437
+ var images = node.images;
424
438
 
425
439
  if (mesh) {
426
- convertMesh(mesh, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix);
440
+ convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix);
427
441
  }
428
442
 
429
443
  convertNodes(node.children || [], cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix);
430
444
  }
431
445
 
432
- function convertMesh(mesh, cartographicOrigin, cartesianModelMatrix, attributesMap) {
433
- var useCartesianPositions = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
434
- var matrix = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
446
+ function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap) {
447
+ var useCartesianPositions = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
448
+ var matrix = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
435
449
 
436
450
  var _iterator3 = _createForOfIteratorHelper(mesh.primitives),
437
451
  _step3;
@@ -477,7 +491,7 @@ function convertMesh(mesh, cartographicOrigin, cartesianModelMatrix, attributesM
477
491
  outputAttributes.texCoords = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.texCoords, flattenTexCoords(attributes.TEXCOORD_0 && attributes.TEXCOORD_0.value, (_primitive$indices3 = primitive.indices) === null || _primitive$indices3 === void 0 ? void 0 : _primitive$indices3.value));
478
492
  outputAttributes.colors = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.colors, flattenColors(attributes.COLOR_0, (_primitive$indices4 = primitive.indices) === null || _primitive$indices4 === void 0 ? void 0 : _primitive$indices4.value));
479
493
  outputAttributes.featureIndicesGroups = outputAttributes.featureIndicesGroups || [];
480
- outputAttributes.featureIndicesGroups.push(flattenBatchIds(getBatchIdsByAttributeName(attributes), (_primitive$indices5 = primitive.indices) === null || _primitive$indices5 === void 0 ? void 0 : _primitive$indices5.value));
494
+ outputAttributes.featureIndicesGroups.push(flattenBatchIds(getBatchIds(attributes, primitive, images), (_primitive$indices5 = primitive.indices) === null || _primitive$indices5 === void 0 ? void 0 : _primitive$indices5.value));
481
495
  }
482
496
  } catch (err) {
483
497
  _iterator3.e(err);
@@ -602,19 +616,22 @@ function flattenBatchIds(batchedIds, indices) {
602
616
  return newBatchIds;
603
617
  }
604
618
 
605
- function getBatchIdsByAttributeName(attributes) {
606
- var batchIds = [];
619
+ function getBatchIds(attributes, primitive, images) {
620
+ var batchIds = (0, _batchIdsExtensions.handleBatchIdsExtensions)(attributes, primitive, images);
621
+
622
+ if (batchIds.length) {
623
+ return batchIds;
624
+ }
607
625
 
608
626
  for (var index = 0; index < BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES.length; index++) {
609
627
  var possibleBatchIdAttributeName = BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES[index];
610
628
 
611
629
  if (attributes[possibleBatchIdAttributeName] && attributes[possibleBatchIdAttributeName].value) {
612
- batchIds = attributes[possibleBatchIdAttributeName].value;
613
- break;
630
+ return attributes[possibleBatchIdAttributeName].value;
614
631
  }
615
632
  }
616
633
 
617
- return batchIds;
634
+ return [];
618
635
  }
619
636
 
620
637
  function convertMaterials() {
@@ -869,43 +886,47 @@ function replaceIndicesByUnique(indicesArray, featureMap) {
869
886
  }
870
887
  }
871
888
 
872
- function convertBatchTableToAttributeBuffers(batchTable, featureIds, attributeStorageInfo) {
889
+ function convertPropertyTableToAttributeBuffers(featureIds, propertyTable, attributeStorageInfo) {
873
890
  var attributeBuffers = [];
891
+ var needFlattenPropertyTable = (0, _featureAttributes.checkPropertiesLength)(featureIds, propertyTable);
892
+ var properties = needFlattenPropertyTable ? (0, _featureAttributes.flattenPropertyTableByFeatureIds)(featureIds, propertyTable) : propertyTable;
893
+
894
+ var propertyTableWithObjectIds = _objectSpread({
895
+ OBJECTID: featureIds
896
+ }, properties);
897
+
898
+ for (var propertyName in propertyTableWithObjectIds) {
899
+ var type = getAttributeType(propertyName, attributeStorageInfo);
900
+ var value = propertyTableWithObjectIds[propertyName];
901
+ var attributeBuffer = generateAttributeBuffer(type, value);
902
+ attributeBuffers.push(attributeBuffer);
903
+ }
874
904
 
875
- if (batchTable) {
876
- var batchTableWithFeatureIds = _objectSpread({
877
- OBJECTID: featureIds
878
- }, batchTable);
879
-
880
- for (var _key2 in batchTableWithFeatureIds) {
881
- var type = getAttributeType(_key2, attributeStorageInfo);
882
- var attributeBuffer = null;
905
+ return attributeBuffers;
906
+ }
883
907
 
884
- switch (type) {
885
- case OBJECT_ID_TYPE:
886
- case SHORT_INT_TYPE:
887
- attributeBuffer = generateShortIntegerAttributeBuffer(batchTableWithFeatureIds[_key2]);
888
- break;
908
+ function generateAttributeBuffer(type, value) {
909
+ var attributeBuffer;
889
910
 
890
- case DOUBLE_TYPE:
891
- attributeBuffer = generateDoubleAttributeBuffer(batchTableWithFeatureIds[_key2]);
892
- break;
911
+ switch (type) {
912
+ case OBJECT_ID_TYPE:
913
+ case SHORT_INT_TYPE:
914
+ attributeBuffer = generateShortIntegerAttributeBuffer(value);
915
+ break;
893
916
 
894
- case STRING_TYPE:
895
- attributeBuffer = generateStringAttributeBuffer(batchTableWithFeatureIds[_key2]);
896
- break;
917
+ case DOUBLE_TYPE:
918
+ attributeBuffer = generateDoubleAttributeBuffer(value);
919
+ break;
897
920
 
898
- default:
899
- attributeBuffer = generateStringAttributeBuffer(batchTableWithFeatureIds[_key2]);
900
- }
921
+ case STRING_TYPE:
922
+ attributeBuffer = generateStringAttributeBuffer(value);
923
+ break;
901
924
 
902
- if (attributeBuffer) {
903
- attributeBuffers.push(attributeBuffer);
904
- }
905
- }
925
+ default:
926
+ attributeBuffer = generateStringAttributeBuffer(value);
906
927
  }
907
928
 
908
- return attributeBuffers;
929
+ return attributeBuffer;
909
930
  }
910
931
 
911
932
  function getAttributeType(key, attributeStorageInfo) {
@@ -957,7 +978,7 @@ function generateBigUint64Array(featureIds) {
957
978
  return typedFeatureIds;
958
979
  }
959
980
 
960
- function generateCompressedGeometry(_x12, _x13, _x14, _x15) {
981
+ function generateCompressedGeometry(_x13, _x14, _x15, _x16) {
961
982
  return _generateCompressedGeometry.apply(this, arguments);
962
983
  }
963
984
 
@@ -1031,4 +1052,101 @@ function generateFeatureIndexAttribute(featureIndex, faceRange) {
1031
1052
 
1032
1053
  return orderedFeatureIndices;
1033
1054
  }
1055
+
1056
+ function getPropertyTable(sourceTile) {
1057
+ var _sourceTile$content;
1058
+
1059
+ var batchTableJson = sourceTile === null || sourceTile === void 0 ? void 0 : (_sourceTile$content = sourceTile.content) === null || _sourceTile$content === void 0 ? void 0 : _sourceTile$content.batchTableJson;
1060
+
1061
+ if (batchTableJson) {
1062
+ return batchTableJson;
1063
+ }
1064
+
1065
+ var _getPropertyTableExte = getPropertyTableExtension(sourceTile),
1066
+ extensionName = _getPropertyTableExte.extensionName,
1067
+ extension = _getPropertyTableExte.extension;
1068
+
1069
+ switch (extensionName) {
1070
+ case EXT_MESH_FEATURES:
1071
+ {
1072
+ console.warn('The I3S converter does not yet support the EXT_mesh_features extension');
1073
+ return null;
1074
+ }
1075
+
1076
+ case EXT_FEATURE_METADATA:
1077
+ {
1078
+ return getPropertyTableFromExtFeatureMetadata(extension);
1079
+ }
1080
+
1081
+ default:
1082
+ return null;
1083
+ }
1084
+ }
1085
+
1086
+ function getPropertyTableExtension(sourceTile) {
1087
+ var _sourceTile$content2, _sourceTile$content2$, _sourceTile$content3, _sourceTile$content3$, _sourceTile$content3$2, _sourceTile$content4, _sourceTile$content4$;
1088
+
1089
+ var extensionsWithPropertyTables = [EXT_FEATURE_METADATA, EXT_MESH_FEATURES];
1090
+ var extensionsUsed = sourceTile === null || sourceTile === void 0 ? void 0 : (_sourceTile$content2 = sourceTile.content) === null || _sourceTile$content2 === void 0 ? void 0 : (_sourceTile$content2$ = _sourceTile$content2.gltf) === null || _sourceTile$content2$ === void 0 ? void 0 : _sourceTile$content2$.extensionsUsed;
1091
+
1092
+ if (!extensionsUsed) {
1093
+ return {
1094
+ extensionName: null,
1095
+ extension: null
1096
+ };
1097
+ }
1098
+
1099
+ var extensionName = '';
1100
+
1101
+ var _iterator6 = _createForOfIteratorHelper(sourceTile === null || sourceTile === void 0 ? void 0 : (_sourceTile$content4 = sourceTile.content) === null || _sourceTile$content4 === void 0 ? void 0 : (_sourceTile$content4$ = _sourceTile$content4.gltf) === null || _sourceTile$content4$ === void 0 ? void 0 : _sourceTile$content4$.extensionsUsed),
1102
+ _step6;
1103
+
1104
+ try {
1105
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
1106
+ var extensionItem = _step6.value;
1107
+
1108
+ if (extensionsWithPropertyTables.includes(extensionItem)) {
1109
+ extensionName = extensionItem;
1110
+ break;
1111
+ }
1112
+ }
1113
+ } catch (err) {
1114
+ _iterator6.e(err);
1115
+ } finally {
1116
+ _iterator6.f();
1117
+ }
1118
+
1119
+ var extension = sourceTile === null || sourceTile === void 0 ? void 0 : (_sourceTile$content3 = sourceTile.content) === null || _sourceTile$content3 === void 0 ? void 0 : (_sourceTile$content3$ = _sourceTile$content3.gltf) === null || _sourceTile$content3$ === void 0 ? void 0 : (_sourceTile$content3$2 = _sourceTile$content3$.extensions) === null || _sourceTile$content3$2 === void 0 ? void 0 : _sourceTile$content3$2[extensionName];
1120
+ return {
1121
+ extensionName: extensionName,
1122
+ extension: extension
1123
+ };
1124
+ }
1125
+
1126
+ function getPropertyTableFromExtFeatureMetadata(extension) {
1127
+ if (extension !== null && extension !== void 0 && extension.featureTextures) {
1128
+ console.warn('The I3S converter does not yet support the EXT_feature_metadata feature textures');
1129
+ return null;
1130
+ }
1131
+
1132
+ if (extension !== null && extension !== void 0 && extension.featureTables) {
1133
+ var _Object$keys;
1134
+
1135
+ var firstFeatureTableName = (_Object$keys = Object.keys(extension.featureTables)) === null || _Object$keys === void 0 ? void 0 : _Object$keys[0];
1136
+
1137
+ if (firstFeatureTableName) {
1138
+ var featureTable = extension === null || extension === void 0 ? void 0 : extension.featureTables[firstFeatureTableName];
1139
+ var propertyTable = {};
1140
+
1141
+ for (var propertyName in featureTable.properties) {
1142
+ propertyTable[propertyName] = featureTable.properties[propertyName].data;
1143
+ }
1144
+
1145
+ return propertyTable;
1146
+ }
1147
+ }
1148
+
1149
+ console.warn("The I3S converter couldn't handle EXT_feature_metadata extension");
1150
+ return null;
1151
+ }
1034
1152
  //# sourceMappingURL=geometry-converter.js.map