@loaders.gl/tile-converter 4.0.0-alpha.22 → 4.0.0-alpha.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/3d-tiles-converter/helpers/load-i3s.d.ts.map +1 -1
- package/dist/constants.d.ts +0 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/converter.min.js +106 -106
- package/dist/dist.min.js +1883 -1241
- package/dist/es5/3d-tiles-converter/helpers/load-i3s.js.map +1 -1
- package/dist/es5/constants.js +1 -5
- package/dist/es5/constants.js.map +1 -1
- package/dist/es5/deps-installer/deps-installer.js +1 -1
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +26 -11
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/feature-attributes.js +7 -17
- package/dist/es5/i3s-converter/helpers/feature-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js +83 -44
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-converter.js +70 -17
- package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/node-index-document.js +3 -2
- package/dist/es5/i3s-converter/helpers/node-index-document.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js +1 -2
- package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
- package/dist/es5/i3s-converter/i3s-converter.js +36 -26
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/es5/i3s-converter/types.js.map +1 -1
- package/dist/es5/i3s-server/controllers/slpk-controller.js +2 -2
- package/dist/es5/i3s-server/controllers/slpk-controller.js.map +1 -1
- package/dist/es5/pgm-loader.js +11 -3
- package/dist/es5/pgm-loader.js.map +1 -1
- package/dist/es5/slpk-extractor/slpk-extractor.js +1 -1
- package/dist/es5/slpk-extractor/slpk-extractor.js.map +1 -1
- package/dist/esm/3d-tiles-converter/helpers/load-i3s.js.map +1 -1
- package/dist/esm/constants.js +0 -2
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/deps-installer/deps-installer.js +1 -1
- package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +21 -6
- package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/feature-attributes.js +9 -7
- package/dist/esm/i3s-converter/helpers/feature-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js +76 -34
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-converter.js +66 -13
- package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/node-index-document.js +2 -1
- package/dist/esm/i3s-converter/helpers/node-index-document.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js +1 -1
- package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
- package/dist/esm/i3s-converter/i3s-converter.js +20 -17
- package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/esm/i3s-converter/types.js.map +1 -1
- package/dist/esm/i3s-server/bin/i3s-server.min.js +71 -71
- package/dist/esm/i3s-server/controllers/slpk-controller.js +1 -1
- package/dist/esm/i3s-server/controllers/slpk-controller.js.map +1 -1
- package/dist/esm/pgm-loader.js +7 -4
- package/dist/esm/pgm-loader.js.map +1 -1
- package/dist/esm/slpk-extractor/slpk-extractor.js +2 -1
- package/dist/esm/slpk-extractor/slpk-extractor.js.map +1 -1
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/feature-attributes.d.ts +6 -6
- package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +2 -2
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.d.ts +1 -1
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/types.d.ts +7 -4
- package/dist/i3s-converter/types.d.ts.map +1 -1
- package/dist/pgm-loader.d.ts +9 -2
- package/dist/pgm-loader.d.ts.map +1 -1
- package/dist/slpk-extractor/slpk-extractor.d.ts.map +1 -1
- package/dist/slpk-extractor.min.js +38 -38
- package/package.json +14 -14
- package/src/3d-tiles-converter/helpers/load-i3s.ts +1 -0
- package/src/constants.ts +0 -3
- package/src/i3s-converter/helpers/batch-ids-extensions.ts +53 -14
- package/src/i3s-converter/helpers/feature-attributes.ts +20 -15
- package/src/i3s-converter/helpers/geometry-attributes.ts +80 -50
- package/src/i3s-converter/helpers/geometry-converter.ts +153 -21
- package/src/i3s-converter/helpers/node-index-document.ts +5 -1
- package/src/i3s-converter/helpers/preprocess-3d-tiles.ts +1 -1
- package/src/i3s-converter/i3s-converter.ts +42 -17
- package/src/i3s-converter/types.ts +8 -4
- package/src/i3s-server/controllers/slpk-controller.ts +1 -1
- package/src/pgm-loader.ts +15 -7
- package/src/slpk-extractor/slpk-extractor.ts +2 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.js +0 -279
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js +0 -271
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +0 -23
- package/dist/3d-tiles-converter/helpers/load-i3s.js +0 -42
- package/dist/3d-tiles-converter/helpers/texture-atlas.js +0 -54
- package/dist/3d-tiles-converter/json-templates/tileset.js +0 -43
- package/dist/bundle.js +0 -5
- package/dist/constants.js +0 -6
- package/dist/converter-cli.js +0 -222
- package/dist/deps-installer/deps-installer.js +0 -89
- package/dist/i3s-converter/helpers/batch-ids-extensions.js +0 -158
- package/dist/i3s-converter/helpers/coordinate-converter.js +0 -122
- package/dist/i3s-converter/helpers/create-scene-server-path.js +0 -28
- package/dist/i3s-converter/helpers/feature-attributes.js +0 -216
- package/dist/i3s-converter/helpers/geometry-attributes.js +0 -203
- package/dist/i3s-converter/helpers/geometry-converter.js +0 -1240
- package/dist/i3s-converter/helpers/gltf-attributes.js +0 -129
- package/dist/i3s-converter/helpers/load-3d-tiles.js +0 -99
- package/dist/i3s-converter/helpers/node-debug.js +0 -120
- package/dist/i3s-converter/helpers/node-index-document.js +0 -268
- package/dist/i3s-converter/helpers/node-pages.js +0 -316
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +0 -100
- package/dist/i3s-converter/helpers/tileset-traversal.js +0 -29
- package/dist/i3s-converter/i3s-converter.js +0 -945
- package/dist/i3s-converter/json-templates/geometry-definitions.js +0 -87
- package/dist/i3s-converter/json-templates/layers.js +0 -139
- package/dist/i3s-converter/json-templates/metadata.js +0 -25
- package/dist/i3s-converter/json-templates/node.js +0 -89
- package/dist/i3s-converter/json-templates/scene-server.js +0 -31
- package/dist/i3s-converter/json-templates/shared-resources.js +0 -129
- package/dist/i3s-converter/json-templates/store.js +0 -103
- package/dist/i3s-converter/types.js +0 -17
- package/dist/i3s-server/app.js +0 -29
- package/dist/i3s-server/bin/www.js +0 -37
- package/dist/i3s-server/controllers/index-controller.js +0 -31
- package/dist/i3s-server/controllers/slpk-controller.js +0 -33
- package/dist/i3s-server/routes/index.js +0 -20
- package/dist/i3s-server/routes/slpk-router.js +0 -34
- package/dist/i3s-server/utils/create-scene-server.js +0 -22
- package/dist/i3s-server/utils/server-utils.js +0 -66
- package/dist/index.js +0 -10
- package/dist/lib/utils/cli-utils.js +0 -82
- package/dist/lib/utils/compress-util.js +0 -257
- package/dist/lib/utils/file-utils.js +0 -139
- package/dist/lib/utils/geometry-utils.js +0 -18
- package/dist/lib/utils/lod-conversion-utils.js +0 -76
- package/dist/lib/utils/queue.js +0 -18
- package/dist/lib/utils/statistic-utills.js +0 -64
- package/dist/lib/utils/write-queue.js +0 -80
- package/dist/pgm-loader.js +0 -24
- package/dist/slpk-extractor/slpk-extractor.js +0 -74
- package/dist/slpk-extractor-cli.js +0 -102
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry-attributes.js","names":["concatenateTypedArrays","VALUES_PER_VERTEX","POSITIONS_AND_NORMALS_PER_TRIANGLE","generateAttributes","attributes","positions","normals","texCoords","colors","uvRegions","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","uvRegionsList","Uint16Array","startIndex","endIndex","positionsCount","getSliceAttributeCount","normalsCount","colorsCount","uvRegionsCount","texCoordsCount","featureId","sort","first","second","attributeName","itemsPerVertex4","texCoordsPerVertex","trianglesCount","vertexCount","sortedData","uniqueObjects","currentObject","existingObject","find","obj","unifiedObjects","firstAttributeObject","range","objIndex","sum","currentAttributesObject","groupedObject"],"sources":["../../../../src/i3s-converter/helpers/geometry-attributes.ts"],"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, uvRegions, 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 uvRegions\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 uvRegions,\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 let uvRegionsList = new Uint16Array(uvRegions);\n\n for (let index = 0; index < featureIds.length; index++) {\n const startIndex = faceRange[index * 2];\n const endIndex = faceRange[index * 2 + 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 uvRegionsCount = getSliceAttributeCount('uvRegions', 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 uvRegions: uvRegionsList.slice(0, uvRegionsCount),\n texCoords: texCoordsList.slice(0, texCoordsCount)\n });\n\n positionsList = positionsList.slice(positionsCount);\n normalsList = normalsList.slice(normalsCount);\n colorsList = colorsList.slice(colorsCount);\n uvRegionsList = uvRegionsList.slice(uvRegionsCount);\n texCoordsList = texCoordsList.slice(texCoordsCount);\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 itemsPerVertex4 = 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 case 'uvRegions':\n return vertexCount * itemsPerVertex4;\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 existingObject = uniqueObjects.find((obj) => obj.featureId === currentObject.featureId);\n\n if (existingObject) {\n existingObject.positions = concatenateTypedArrays(\n existingObject.positions,\n currentObject.positions\n );\n existingObject.normals = concatenateTypedArrays(\n existingObject.normals,\n currentObject.normals\n );\n existingObject.colors = concatenateTypedArrays(existingObject.colors, currentObject.colors);\n existingObject.texCoords = concatenateTypedArrays(\n existingObject.texCoords,\n currentObject.texCoords\n );\n existingObject.uvRegions = concatenateTypedArrays(\n existingObject.uvRegions,\n currentObject.uvRegions\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 uvRegions = new Uint16Array(firstAttributeObject.uvRegions);\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 uvRegions = concatenateTypedArrays(uvRegions, currentAttributesObject.uvRegions);\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, uvRegions, texCoords, featureCount};\n}\n"],"mappings":"AACA,SAAQA,sBAAsB,QAAO,0BAA0B;AAE/D,MAAMC,iBAAiB,GAAG,CAAC;AAC3B,MAAMC,kCAAkC,GAAG,CAAC;AAO5C,OAAO,SAASC,kBAAkBA,CAACC,UAA+B,EAAsB;EACtF,MAAM;IAACC,SAAS;IAAEC,OAAO;IAAEC,SAAS;IAAEC,MAAM;IAAEC,SAAS;IAAEC;EAAc,CAAC,GAA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AAS,GAAGP,sBAAsB,CAACO,SAAS,EAAEuE,uBAAuB,CAACvE,SAAS,CAAC;IAEhF,MAAMwE,aAAa,GAAGN,cAAc,CAACG,QAAQ,CAAC;IAC9CD,KAAK,CAACxC,IAAI,CAAC4C,aAAa,CAAC1E,SAAS,CAACO,MAAM,GAAGV,kCAAkC,GAAG,CAAC,GAAG2E,GAAG,CAAC;IACzFF,KAAK,CAACxC,IAAI,CAAC4C,aAAa,CAAC1E,SAAS,CAACO,MAAM,GAAGV,kCAAkC,GAAG2E,GAAG,CAAC;IAErFA,GAAG,IAAIE,aAAa,CAAC1E,SAAS,CAACO,MAAM,GAAGV,kCAAkC;IAC1E0E,QAAQ,IAAI,CAAC;EACf;EAEAD,KAAK,CAACxC,IAAI,CAAC9B,SAAS,CAACO,MAAM,GAAGV,kCAAkC,GAAG,CAAC,CAAC;EAErE,MAAMW,SAAS,GAAG,IAAIC,WAAW,CAAC6D,KAAK,CAAC;EACxC,OAAO;IAAC9D,SAAS;IAAEE,UAAU;IAAEV,SAAS;IAAEC,OAAO;IAAEE,MAAM;IAAEC,SAAS;IAAEF,SAAS;IAAES;EAAY,CAAC;AAChG"}
|
|
1
|
+
{"version":3,"file":"geometry-attributes.js","names":["concatenateTypedArrays","VALUES_PER_VERTEX","POSITIONS_AND_NORMALS_PER_TRIANGLE","generateAttributes","attributes","positions","normals","texCoords","colors","uvRegions","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","uvRegionsList","Uint16Array","positionsOffset","normalsOffset","colorsOffset","uvRegionsOffset","texCoordsOffset","startIndex","endIndex","positionsCount","getSliceAttributeCount","normalsCount","colorsCount","uvRegionsCount","texCoordsCount","featureId","subarray","attributeName","itemsPerVertex4","texCoordsPerVertex","trianglesCount","vertexCount","sortedData","groupedMetadata","existingObject","find","obj","uniqueObjects","metatada","concatenateAttributes","unifiedObjects","firstAttributeObject","range","objIndex","sum","currentAttributesObject","groupedObject","positionGroups","_ref","normalGroups","_ref2","colorGroups","_ref3","texCoordGroups","_ref4","uvRegionGroups","_ref5"],"sources":["../../../../src/i3s-converter/helpers/geometry-attributes.ts"],"sourcesContent":["import type {\n GeometryAttributes,\n ConvertedAttributes,\n GroupedByFeatureIdAttributes,\n GroupedAttributes\n} 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, uvRegions, 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 uvRegions\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 uvRegions,\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 let uvRegionsList = new Uint16Array(uvRegions);\n let positionsOffset = 0;\n let normalsOffset = 0;\n let colorsOffset = 0;\n let uvRegionsOffset = 0;\n let texCoordsOffset = 0;\n\n for (let index = 0; index < featureIds.length; index++) {\n const startIndex = faceRange[index * 2];\n const endIndex = faceRange[index * 2 + 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 uvRegionsCount = getSliceAttributeCount('uvRegions', startIndex, endIndex);\n const texCoordsCount = getSliceAttributeCount('texCoords', startIndex, endIndex);\n\n groupedData.push({\n featureId: featureIds[index],\n positions: positionsList.subarray(positionsOffset, positionsOffset + positionsCount),\n normals: normalsList.subarray(normalsOffset, normalsOffset + normalsCount),\n colors: colorsList.subarray(colorsOffset, colorsOffset + colorsCount),\n uvRegions: uvRegionsList.subarray(uvRegionsOffset, uvRegionsOffset + uvRegionsCount),\n texCoords: texCoordsList.subarray(texCoordsOffset, texCoordsOffset + texCoordsCount)\n });\n\n positionsOffset += positionsCount;\n normalsOffset += normalsCount;\n colorsOffset += colorsCount;\n uvRegionsOffset += uvRegionsCount;\n texCoordsOffset += texCoordsCount;\n }\n\n return groupedData;\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 itemsPerVertex4 = 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 case 'uvRegions':\n return vertexCount * itemsPerVertex4;\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 groupedMetadata: {\n featureId: number;\n attributes: GroupedByFeatureIdAttributes[];\n }[] = [];\n for (const data of sortedData) {\n const existingObject = groupedMetadata.find((obj) => obj.featureId === data.featureId);\n if (existingObject) {\n existingObject.attributes.push(data);\n } else {\n groupedMetadata.push({\n featureId: data.featureId,\n attributes: [data]\n });\n }\n }\n\n const uniqueObjects: GroupedByFeatureIdAttributes[] = [];\n for (const metatada of groupedMetadata) {\n const attributes = concatenateAttributes(metatada.attributes);\n\n uniqueObjects.push({\n featureId: metatada.featureId,\n ...attributes\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 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 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 const attributes = concatenateAttributes(unifiedObjects);\n\n range.push(attributes.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1);\n\n const faceRange = new Uint32Array(range);\n return {faceRange, featureIds, featureCount, ...attributes};\n}\n\n/**\n * Concatenate attributes typed arrays\n * @param attributes - grouped by featureId typed arrays\n * @returns - concatenated typed array list\n */\nfunction concatenateAttributes(attributes: GroupedByFeatureIdAttributes[]): GroupedAttributes {\n const positionGroups = attributes.map(({positions}) => positions);\n const positions =\n positionGroups.length > 1 ? concatenateTypedArrays(...positionGroups) : positionGroups[0];\n\n const normalGroups = attributes.map(({normals}) => normals);\n const normals =\n normalGroups.length > 1 ? concatenateTypedArrays(...normalGroups) : normalGroups[0];\n\n const colorGroups = attributes.map(({colors}) => colors);\n const colors = colorGroups.length > 1 ? concatenateTypedArrays(...colorGroups) : colorGroups[0];\n\n const texCoordGroups = attributes.map(({texCoords}) => texCoords);\n const texCoords =\n texCoordGroups.length > 1 ? concatenateTypedArrays(...texCoordGroups) : texCoordGroups[0];\n\n const uvRegionGroups = attributes.map(({uvRegions}) => uvRegions);\n const uvRegions =\n uvRegionGroups.length > 1 ? concatenateTypedArrays(...uvRegionGroups) : uvRegionGroups[0];\n return {\n positions,\n normals,\n colors,\n texCoords,\n uvRegions\n };\n}\n"],"mappings":"AAMA,SAAQA,sBAAsB,QAAO,0BAA0B;AAE/D,MAAMC,iBAAiB,GAAG,CAAC;AAC3B,MAAMC,kCAAkC,GAAG,CAAC;AAO5C,OAAO,SAASC,kBAAkBA,CAACC,UAA+B,EAAsB;EACtF,MAAM;IAACC,SAAS;IAAEC,OAAO;IAAEC,SAAS;IAAEC,MAAM;IAAEC,SAAS;IAAEC;EAAc,CAAC,GAAGN,UAAU;EACrF,MAAMO,aAAa,GAAGN,SAAS,CAACO,MAAM,GAAGV,kCAAkC;EAE3E,IAAI,CAACQ,cAAc,CAACE,MAAM,EAAE;IAC1B,OAAO;MACLC,SAAS,EAAE,IAAIC,WAAW,CAAC,CAAC,CAAC,EAAE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iF,YAAY,CAAC3E,MAAM,GAAG,CAAC,GAAGZ,sBAAsB,CAAC,GAAGuF,YAAY,CAAC,GAAGA,YAAY,CAAC,CAAC,CAAC;EAErF,MAAME,WAAW,GAAGrF,UAAU,CAACiC,GAAG,CAACqD,KAAA;IAAA,IAAC;MAAClF;IAAM,CAAC,GAAAkF,KAAA;IAAA,OAAKlF,MAAM;EAAA,EAAC;EACxD,MAAMA,MAAM,GAAGiF,WAAW,CAAC7E,MAAM,GAAG,CAAC,GAAGZ,sBAAsB,CAAC,GAAGyF,WAAW,CAAC,GAAGA,WAAW,CAAC,CAAC,CAAC;EAE/F,MAAME,cAAc,GAAGvF,UAAU,CAACiC,GAAG,CAACuD,KAAA;IAAA,IAAC;MAACrF;IAAS,CAAC,GAAAqF,KAAA;IAAA,OAAKrF,SAAS;EAAA,EAAC;EACjE,MAAMA,SAAS,GACboF,cAAc,CAAC/E,MAAM,GAAG,CAAC,GAAGZ,sBAAsB,CAAC,GAAG2F,cAAc,CAAC,GAAGA,cAAc,CAAC,CAAC,CAAC;EAE3F,MAAME,cAAc,GAAGzF,UAAU,CAACiC,GAAG,CAACyD,KAAA;IAAA,IAAC;MAACrF;IAAS,CAAC,GAAAqF,KAAA;IAAA,OAAKrF,SAAS;EAAA,EAAC;EACjE,MAAMA,SAAS,GACboF,cAAc,CAACjF,MAAM,GAAG,CAAC,GAAGZ,sBAAsB,CAAC,GAAG6F,cAAc,CAAC,GAAGA,cAAc,CAAC,CAAC,CAAC;EAC3F,OAAO;IACLxF,SAAS;IACTC,OAAO;IACPE,MAAM;IACND,SAAS;IACTE;EACF,CAAC;AACH"}
|
|
@@ -12,7 +12,7 @@ import { getTextureByMetadataClass, handleBatchIdsExtensions } from './batch-ids
|
|
|
12
12
|
import { checkPropertiesLength, flattenPropertyTableByFeatureIds } from './feature-attributes';
|
|
13
13
|
import { GL } from '@loaders.gl/math';
|
|
14
14
|
import { generateSyntheticIndices } from '../../lib/utils/geometry-utils';
|
|
15
|
-
import { EXT_FEATURE_METADATA,
|
|
15
|
+
import { EXT_MESH_FEATURES, EXT_FEATURE_METADATA, EXT_STRUCTURAL_METADATA } from '@loaders.gl/gltf';
|
|
16
16
|
const DEFAULT_ROUGHNESS_FACTOR = 1;
|
|
17
17
|
const DEFAULT_METALLIC_FACTOR = 1;
|
|
18
18
|
const VALUES_PER_VERTEX = 3;
|
|
@@ -107,8 +107,9 @@ async function _makeNodeResources(_ref) {
|
|
|
107
107
|
texCoords,
|
|
108
108
|
featureCount
|
|
109
109
|
} = generateAttributes(convertedAttributes);
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
let featureIdsMap = {};
|
|
111
|
+
if (propertyTable) {
|
|
112
|
+
featureIdsMap = makeFeatureIdsUnique(featureIds, convertedAttributes.featureIndices, featuresHashArray, propertyTable);
|
|
112
113
|
}
|
|
113
114
|
const header = new Uint32Array(2);
|
|
114
115
|
const typedFeatureIds = generateBigUint64Array(featureIds);
|
|
@@ -125,7 +126,7 @@ async function _makeNodeResources(_ref) {
|
|
|
125
126
|
}, libraries) : null;
|
|
126
127
|
let attributes = [];
|
|
127
128
|
if (attributeStorageInfo && propertyTable) {
|
|
128
|
-
attributes = convertPropertyTableToAttributeBuffers(featureIds, propertyTable, attributeStorageInfo);
|
|
129
|
+
attributes = convertPropertyTableToAttributeBuffers(featureIds, featureIdsMap, propertyTable, attributeStorageInfo);
|
|
129
130
|
}
|
|
130
131
|
return {
|
|
131
132
|
nodeId,
|
|
@@ -663,6 +664,7 @@ function makeFeatureIdsUnique(featureIds, featureIndices, featuresHashArray, bat
|
|
|
663
664
|
const replaceMap = getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray);
|
|
664
665
|
replaceIndicesByUnique(featureIndices, replaceMap);
|
|
665
666
|
replaceIndicesByUnique(featureIds, replaceMap);
|
|
667
|
+
return replaceMap;
|
|
666
668
|
}
|
|
667
669
|
function getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray) {
|
|
668
670
|
const featureMap = {};
|
|
@@ -693,19 +695,21 @@ function replaceIndicesByUnique(indicesArray, featureMap) {
|
|
|
693
695
|
indicesArray[index] = featureMap[indicesArray[index]];
|
|
694
696
|
}
|
|
695
697
|
}
|
|
696
|
-
function convertPropertyTableToAttributeBuffers(featureIds, propertyTable, attributeStorageInfo) {
|
|
698
|
+
function convertPropertyTableToAttributeBuffers(featureIds, featureIdsMap, propertyTable, attributeStorageInfo) {
|
|
697
699
|
const attributeBuffers = [];
|
|
698
700
|
const needFlattenPropertyTable = checkPropertiesLength(featureIds, propertyTable);
|
|
699
|
-
const properties = needFlattenPropertyTable ? flattenPropertyTableByFeatureIds(
|
|
701
|
+
const properties = needFlattenPropertyTable ? flattenPropertyTableByFeatureIds(featureIdsMap, propertyTable) : propertyTable;
|
|
700
702
|
const propertyTableWithObjectIds = {
|
|
701
703
|
OBJECTID: featureIds,
|
|
702
704
|
...properties
|
|
703
705
|
};
|
|
704
706
|
for (const propertyName in propertyTableWithObjectIds) {
|
|
705
707
|
const type = getAttributeType(propertyName, attributeStorageInfo);
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
708
|
+
if (type) {
|
|
709
|
+
const value = propertyTableWithObjectIds[propertyName];
|
|
710
|
+
const attributeBuffer = generateAttributeBuffer(type, value);
|
|
711
|
+
attributeBuffers.push(attributeBuffer);
|
|
712
|
+
}
|
|
709
713
|
}
|
|
710
714
|
return attributeBuffers;
|
|
711
715
|
}
|
|
@@ -729,6 +733,14 @@ function generateAttributeBuffer(type, value) {
|
|
|
729
733
|
}
|
|
730
734
|
function getAttributeType(key, attributeStorageInfo) {
|
|
731
735
|
const attribute = attributeStorageInfo.find(attr => attr.name === key);
|
|
736
|
+
if (!attribute) {
|
|
737
|
+
console.error("attribute is null, key=".concat(key, ", attributeStorageInfo=").concat(JSON.stringify(attributeStorageInfo, null, 2)));
|
|
738
|
+
return '';
|
|
739
|
+
}
|
|
740
|
+
if (!attribute.attributeValues) {
|
|
741
|
+
console.error("attributeValues is null, attribute=".concat(attribute));
|
|
742
|
+
return '';
|
|
743
|
+
}
|
|
732
744
|
return attribute.attributeValues.valueType;
|
|
733
745
|
}
|
|
734
746
|
function generateShortIntegerAttributeBuffer(featureIds) {
|
|
@@ -836,6 +848,7 @@ export function getPropertyTable(tileContent, metadataClass) {
|
|
|
836
848
|
if (!tileContent) {
|
|
837
849
|
return null;
|
|
838
850
|
}
|
|
851
|
+
let propertyTable;
|
|
839
852
|
const batchTableJson = tileContent === null || tileContent === void 0 ? void 0 : tileContent.batchTableJson;
|
|
840
853
|
if (batchTableJson) {
|
|
841
854
|
return batchTableJson;
|
|
@@ -847,12 +860,18 @@ export function getPropertyTable(tileContent, metadataClass) {
|
|
|
847
860
|
switch (extensionName) {
|
|
848
861
|
case EXT_MESH_FEATURES:
|
|
849
862
|
{
|
|
850
|
-
|
|
851
|
-
return
|
|
863
|
+
propertyTable = getPropertyTableFromExtMeshFeatures(extension, metadataClass);
|
|
864
|
+
return propertyTable;
|
|
865
|
+
}
|
|
866
|
+
case EXT_STRUCTURAL_METADATA:
|
|
867
|
+
{
|
|
868
|
+
propertyTable = getPropertyTableFromExtStructuralMetadata(extension, metadataClass);
|
|
869
|
+
return propertyTable;
|
|
852
870
|
}
|
|
853
871
|
case EXT_FEATURE_METADATA:
|
|
854
872
|
{
|
|
855
|
-
|
|
873
|
+
propertyTable = getPropertyTableFromExtFeatureMetadata(extension, metadataClass);
|
|
874
|
+
return propertyTable;
|
|
856
875
|
}
|
|
857
876
|
default:
|
|
858
877
|
return null;
|
|
@@ -860,7 +879,7 @@ export function getPropertyTable(tileContent, metadataClass) {
|
|
|
860
879
|
}
|
|
861
880
|
function getPropertyTableExtension(tileContent) {
|
|
862
881
|
var _tileContent$gltf3, _tileContent$gltf5, _tileContent$gltf5$ex;
|
|
863
|
-
const extensionsWithPropertyTables = [EXT_FEATURE_METADATA, EXT_MESH_FEATURES];
|
|
882
|
+
const extensionsWithPropertyTables = [EXT_FEATURE_METADATA, EXT_STRUCTURAL_METADATA, EXT_MESH_FEATURES];
|
|
864
883
|
const extensionsUsed = tileContent === null || tileContent === void 0 ? void 0 : (_tileContent$gltf3 = tileContent.gltf) === null || _tileContent$gltf3 === void 0 ? void 0 : _tileContent$gltf3.extensionsUsed;
|
|
865
884
|
if (!extensionsUsed) {
|
|
866
885
|
return {
|
|
@@ -921,4 +940,38 @@ function getPropertyTableFromExtFeatureMetadata(extension, metadataClass) {
|
|
|
921
940
|
console.warn("The I3S converter couldn't handle EXT_feature_metadata extension: There is neither featureTables, no featureTextures in the extension.");
|
|
922
941
|
return null;
|
|
923
942
|
}
|
|
943
|
+
function getPropertyTableFromExtStructuralMetadata(extension, metadataClass) {
|
|
944
|
+
if (extension !== null && extension !== void 0 && extension.propertyTables) {
|
|
945
|
+
const firstPropertyTable = extension === null || extension === void 0 ? void 0 : extension.propertyTables[0];
|
|
946
|
+
const propertyTableWithData = {};
|
|
947
|
+
for (const propertyName in firstPropertyTable.properties) {
|
|
948
|
+
propertyTableWithData[propertyName] = firstPropertyTable.properties[propertyName].data;
|
|
949
|
+
}
|
|
950
|
+
return propertyTableWithData;
|
|
951
|
+
}
|
|
952
|
+
if (extension !== null && extension !== void 0 && extension.propertyTextures) {
|
|
953
|
+
if (extension !== null && extension !== void 0 && extension.propertyTextures) {
|
|
954
|
+
const firstPropertyTexture = extension === null || extension === void 0 ? void 0 : extension.propertyTextures[0];
|
|
955
|
+
const propertyTableWithData = {};
|
|
956
|
+
for (const propertyName in firstPropertyTexture.properties) {
|
|
957
|
+
propertyTableWithData[propertyName] = firstPropertyTexture.properties[propertyName].data;
|
|
958
|
+
}
|
|
959
|
+
return propertyTableWithData;
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
console.warn("The I3S converter couldn't handle EXT_structural_metadata extension: There is neither propertyTables, no propertyTextures in the extension.");
|
|
963
|
+
return null;
|
|
964
|
+
}
|
|
965
|
+
function getPropertyTableFromExtMeshFeatures(extension, metadataClass) {
|
|
966
|
+
if (extension !== null && extension !== void 0 && extension.featureIds) {
|
|
967
|
+
const firstFeatureId = extension === null || extension === void 0 ? void 0 : extension.featureIds[0];
|
|
968
|
+
const propertyTableWithData = {};
|
|
969
|
+
if (!firstFeatureId.propertyTable) {
|
|
970
|
+
console.warn('Should be implemented as we have the tileset with Ext_mesh_features not linked with EXT_structural_metadata extension');
|
|
971
|
+
}
|
|
972
|
+
return propertyTableWithData;
|
|
973
|
+
}
|
|
974
|
+
console.warn("The I3S converter couldn't handle EXT_mesh_features extension: There is no featureIds in the extension.");
|
|
975
|
+
return null;
|
|
976
|
+
}
|
|
924
977
|
//# sourceMappingURL=geometry-converter.js.map
|