@loaders.gl/tile-converter 3.4.6 → 4.0.0-alpha.10

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 (179) hide show
  1. package/bin/converter.js +1 -1
  2. package/dist/3d-tiles-attributes-worker.js +2 -2
  3. package/dist/3d-tiles-attributes-worker.js.map +3 -3
  4. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
  5. package/dist/3d-tiles-converter/3d-tiles-converter.js +4 -3
  6. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +0 -8
  7. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
  8. package/dist/3d-tiles-converter/helpers/b3dm-converter.js +2 -15
  9. package/dist/converter.min.js +75 -76
  10. package/dist/deps-installer/deps-installer.js +4 -4
  11. package/dist/dist.min.js +2101 -2120
  12. package/dist/es5/3d-tiles-attributes-worker.js +1 -1
  13. package/dist/es5/3d-tiles-attributes-worker.js.map +1 -1
  14. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +0 -3
  15. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  16. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +2 -10
  17. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  18. package/dist/es5/deps-installer/deps-installer.js +4 -4
  19. package/dist/es5/deps-installer/deps-installer.js.map +1 -1
  20. package/dist/es5/i3s-attributes-worker.js +1 -1
  21. package/dist/es5/i3s-attributes-worker.js.map +1 -1
  22. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +4 -4
  23. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  24. package/dist/es5/i3s-converter/helpers/coordinate-converter.js +6 -7
  25. package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  26. package/dist/es5/i3s-converter/helpers/geometry-converter.js +49 -30
  27. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  28. package/dist/es5/i3s-converter/helpers/gltf-attributes.js +46 -16
  29. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  30. package/dist/es5/i3s-converter/helpers/load-3d-tiles.js +82 -0
  31. package/dist/es5/i3s-converter/helpers/load-3d-tiles.js.map +1 -0
  32. package/dist/es5/i3s-converter/helpers/node-index-document.js +74 -45
  33. package/dist/es5/i3s-converter/helpers/node-index-document.js.map +1 -1
  34. package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js +111 -0
  35. package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -0
  36. package/dist/es5/i3s-converter/helpers/tileset-traversal.js +82 -0
  37. package/dist/es5/i3s-converter/helpers/tileset-traversal.js.map +1 -0
  38. package/dist/es5/i3s-converter/i3s-converter.js +545 -523
  39. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  40. package/dist/es5/i3s-converter/types.js +16 -0
  41. package/dist/es5/i3s-converter/types.js.map +1 -1
  42. package/dist/es5/i3s-server/README.md +19 -0
  43. package/dist/es5/i3s-server/app.js +10 -1
  44. package/dist/es5/i3s-server/app.js.map +1 -1
  45. package/dist/es5/i3s-server/controllers/slpk-controller.js +84 -0
  46. package/dist/es5/i3s-server/controllers/slpk-controller.js.map +1 -0
  47. package/dist/es5/i3s-server/routes/slpk-router.js +71 -0
  48. package/dist/es5/i3s-server/routes/slpk-router.js.map +1 -0
  49. package/dist/es5/i3s-server/utils/create-scene-server.js +17 -0
  50. package/dist/es5/i3s-server/utils/create-scene-server.js.map +1 -0
  51. package/dist/es5/lib/utils/file-utils.js +1 -1
  52. package/dist/es5/lib/utils/file-utils.js.map +1 -1
  53. package/dist/es5/lib/utils/geometry-utils.js +15 -0
  54. package/dist/es5/lib/utils/geometry-utils.js.map +1 -0
  55. package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
  56. package/dist/es5/pgm-loader.js +1 -1
  57. package/dist/es5/pgm-loader.js.map +1 -1
  58. package/dist/esm/3d-tiles-attributes-worker.js +1 -1
  59. package/dist/esm/3d-tiles-attributes-worker.js.map +1 -1
  60. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +0 -3
  61. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  62. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +2 -8
  63. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  64. package/dist/esm/deps-installer/deps-installer.js +4 -4
  65. package/dist/esm/deps-installer/deps-installer.js.map +1 -1
  66. package/dist/esm/i3s-attributes-worker.js +1 -1
  67. package/dist/esm/i3s-attributes-worker.js.map +1 -1
  68. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +4 -4
  69. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  70. package/dist/esm/i3s-converter/helpers/coordinate-converter.js +6 -7
  71. package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  72. package/dist/esm/i3s-converter/helpers/geometry-converter.js +37 -18
  73. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  74. package/dist/esm/i3s-converter/helpers/gltf-attributes.js +50 -16
  75. package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  76. package/dist/esm/i3s-converter/helpers/load-3d-tiles.js +35 -0
  77. package/dist/esm/i3s-converter/helpers/load-3d-tiles.js.map +1 -0
  78. package/dist/esm/i3s-converter/helpers/node-index-document.js +14 -1
  79. package/dist/esm/i3s-converter/helpers/node-index-document.js.map +1 -1
  80. package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js +48 -0
  81. package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -0
  82. package/dist/esm/i3s-converter/helpers/tileset-traversal.js +14 -0
  83. package/dist/esm/i3s-converter/helpers/tileset-traversal.js.map +1 -0
  84. package/dist/esm/i3s-converter/i3s-converter.js +134 -127
  85. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  86. package/dist/esm/i3s-converter/types.js +10 -1
  87. package/dist/esm/i3s-converter/types.js.map +1 -1
  88. package/dist/esm/i3s-server/README.md +19 -0
  89. package/dist/esm/i3s-server/app.js +11 -1
  90. package/dist/esm/i3s-server/app.js.map +1 -1
  91. package/dist/esm/i3s-server/controllers/slpk-controller.js +36 -0
  92. package/dist/esm/i3s-server/controllers/slpk-controller.js.map +1 -0
  93. package/dist/esm/i3s-server/routes/slpk-router.js +33 -0
  94. package/dist/esm/i3s-server/routes/slpk-router.js.map +1 -0
  95. package/dist/esm/i3s-server/utils/create-scene-server.js +16 -0
  96. package/dist/esm/i3s-server/utils/create-scene-server.js.map +1 -0
  97. package/dist/esm/lib/utils/file-utils.js +1 -1
  98. package/dist/esm/lib/utils/file-utils.js.map +1 -1
  99. package/dist/esm/lib/utils/geometry-utils.js +8 -0
  100. package/dist/esm/lib/utils/geometry-utils.js.map +1 -0
  101. package/dist/esm/lib/utils/lod-conversion-utils.js.map +1 -1
  102. package/dist/esm/pgm-loader.js +1 -1
  103. package/dist/esm/pgm-loader.js.map +1 -1
  104. package/dist/i3s-attributes-worker.d.ts +10 -2
  105. package/dist/i3s-attributes-worker.d.ts.map +1 -1
  106. package/dist/i3s-attributes-worker.js +2 -2
  107. package/dist/i3s-attributes-worker.js.map +3 -3
  108. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +4 -2
  109. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
  110. package/dist/i3s-converter/helpers/batch-ids-extensions.js +4 -7
  111. package/dist/i3s-converter/helpers/coordinate-converter.d.ts +3 -4
  112. package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -1
  113. package/dist/i3s-converter/helpers/coordinate-converter.js +8 -9
  114. package/dist/i3s-converter/helpers/geometry-converter.d.ts +9 -4
  115. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  116. package/dist/i3s-converter/helpers/geometry-converter.js +84 -54
  117. package/dist/i3s-converter/helpers/gltf-attributes.d.ts +22 -3
  118. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
  119. package/dist/i3s-converter/helpers/gltf-attributes.js +62 -22
  120. package/dist/i3s-converter/helpers/load-3d-tiles.d.ts +18 -0
  121. package/dist/i3s-converter/helpers/load-3d-tiles.d.ts.map +1 -0
  122. package/dist/i3s-converter/helpers/load-3d-tiles.js +53 -0
  123. package/dist/i3s-converter/helpers/node-index-document.d.ts +8 -0
  124. package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -1
  125. package/dist/i3s-converter/helpers/node-index-document.js +20 -2
  126. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +23 -0
  127. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +1 -0
  128. package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +76 -0
  129. package/dist/i3s-converter/helpers/tileset-traversal.d.ts +25 -0
  130. package/dist/i3s-converter/helpers/tileset-traversal.d.ts.map +1 -0
  131. package/dist/i3s-converter/helpers/tileset-traversal.js +29 -0
  132. package/dist/i3s-converter/i3s-converter.d.ts +40 -40
  133. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  134. package/dist/i3s-converter/i3s-converter.js +150 -125
  135. package/dist/i3s-converter/types.d.ts +18 -0
  136. package/dist/i3s-converter/types.d.ts.map +1 -1
  137. package/dist/i3s-converter/types.js +15 -0
  138. package/dist/i3s-server/app.d.ts.map +1 -1
  139. package/dist/i3s-server/app.js +9 -1
  140. package/dist/i3s-server/controllers/slpk-controller.d.ts +3 -0
  141. package/dist/i3s-server/controllers/slpk-controller.d.ts.map +1 -0
  142. package/dist/i3s-server/controllers/slpk-controller.js +32 -0
  143. package/dist/i3s-server/routes/slpk-router.d.ts +3 -0
  144. package/dist/i3s-server/routes/slpk-router.d.ts.map +1 -0
  145. package/dist/i3s-server/routes/slpk-router.js +33 -0
  146. package/dist/i3s-server/utils/create-scene-server.d.ts +11 -0
  147. package/dist/i3s-server/utils/create-scene-server.d.ts.map +1 -0
  148. package/dist/i3s-server/utils/create-scene-server.js +14 -0
  149. package/dist/lib/utils/file-utils.d.ts.map +1 -1
  150. package/dist/lib/utils/file-utils.js +2 -1
  151. package/dist/lib/utils/geometry-utils.d.ts +9 -0
  152. package/dist/lib/utils/geometry-utils.d.ts.map +1 -0
  153. package/dist/lib/utils/geometry-utils.js +18 -0
  154. package/dist/lib/utils/lod-conversion-utils.d.ts +3 -2
  155. package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -1
  156. package/dist/lib/utils/lod-conversion-utils.js +1 -1
  157. package/package.json +15 -16
  158. package/src/3d-tiles-converter/3d-tiles-converter.ts +9 -8
  159. package/src/3d-tiles-converter/helpers/b3dm-converter.ts +2 -16
  160. package/src/deps-installer/deps-installer.ts +4 -4
  161. package/src/i3s-attributes-worker.ts +11 -2
  162. package/src/i3s-converter/helpers/batch-ids-extensions.ts +15 -19
  163. package/src/i3s-converter/helpers/coordinate-converter.ts +11 -10
  164. package/src/i3s-converter/helpers/geometry-converter.ts +154 -95
  165. package/src/i3s-converter/helpers/gltf-attributes.ts +85 -25
  166. package/src/i3s-converter/helpers/load-3d-tiles.ts +68 -0
  167. package/src/i3s-converter/helpers/node-index-document.ts +22 -2
  168. package/src/i3s-converter/helpers/preprocess-3d-tiles.ts +81 -0
  169. package/src/i3s-converter/helpers/tileset-traversal.ts +51 -0
  170. package/src/i3s-converter/i3s-converter.ts +229 -178
  171. package/src/i3s-converter/types.ts +20 -0
  172. package/src/i3s-server/README.md +19 -0
  173. package/src/i3s-server/app.js +8 -1
  174. package/src/i3s-server/controllers/slpk-controller.js +38 -0
  175. package/src/i3s-server/routes/slpk-router.js +33 -0
  176. package/src/i3s-server/utils/create-scene-server.js +15 -0
  177. package/src/lib/utils/file-utils.ts +2 -1
  178. package/src/lib/utils/geometry-utils.ts +14 -0
  179. package/src/lib/utils/lod-conversion-utils.ts +6 -2
@@ -1 +1 @@
1
- {"version":3,"file":"coordinate-converter.js","names":["_core","require","_geospatial","_culling","createBoundingVolumes","tile","geoidHeightModel","radius","halfSize","quaternion","boundingVolume","cartographicCenter","Ellipsoid","WGS84","cartesianToCartographic","center","Vector3","getHeight","OrientedBoundingBox","len","Quaternion","fromMatrix3","Matrix3","normalize","mbs","obb","createBoundingVolumesFromGeometry","cartesianPositions","positionVectors","convertPositionsToVectors","geometryObb","makeOrientedBoundingBoxFromPoints","geometryMbs","makeBoundingSphereFromPoints","mbsCenter","obbCenter","positions","result","i","length","positionVector","push","convertBoundingVolumeToI3SFullExtent","sphere","BoundingSphere","getBoundingSphere","vertexMax","vertexMin","xmin","Math","min","xmax","max","ymin","ymax","zmin","zmax","createObbFromMbs","halfAxex"],"sources":["../../../../src/i3s-converter/helpers/coordinate-converter.ts"],"sourcesContent":["import type {BoundingVolumes, FullExtent, Mbs, Obb} from '@loaders.gl/i3s';\n\nimport {Matrix3, Quaternion, Vector3} from '@math.gl/core';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {\n OrientedBoundingBox,\n makeOrientedBoundingBoxFromPoints,\n makeBoundingSphereFromPoints,\n BoundingSphere\n} from '@math.gl/culling';\nimport {Tile3D} from '@loaders.gl/tiles';\nimport {Geoid} from '@math.gl/geoid';\n\n/**\n * Create bounding volumes object from tile and geoid height model.\n * @param tile\n * @param geoidHeightModel\n * @returns - Bounding volumes object\n */\nexport function createBoundingVolumes(tile: Tile3D, geoidHeightModel: Geoid): BoundingVolumes {\n let radius;\n let halfSize;\n let quaternion;\n\n const boundingVolume = tile.boundingVolume;\n const cartographicCenter = Ellipsoid.WGS84.cartesianToCartographic(\n boundingVolume.center,\n new Vector3()\n );\n cartographicCenter[2] =\n cartographicCenter[2] -\n geoidHeightModel.getHeight(cartographicCenter[1], cartographicCenter[0]);\n if (boundingVolume instanceof OrientedBoundingBox) {\n halfSize = boundingVolume.halfSize;\n radius = new Vector3(halfSize[0], halfSize[1], halfSize[2]).len();\n quaternion = boundingVolume.quaternion;\n } else {\n radius = tile.boundingVolume.radius;\n halfSize = [radius, radius, radius];\n quaternion = new Quaternion()\n .fromMatrix3(new Matrix3([halfSize[0], 0, 0, 0, halfSize[1], 0, 0, 0, halfSize[2]]))\n .normalize();\n }\n\n return {\n mbs: [cartographicCenter[0], cartographicCenter[1], cartographicCenter[2], radius],\n obb: {\n center: [cartographicCenter[0], cartographicCenter[1], cartographicCenter[2]],\n halfSize,\n quaternion\n }\n };\n}\n\n/**\n * Generates bounding volumes from geometry positions\n * @param cartesianPositions\n * @param geoidHeightModel\n */\nexport function createBoundingVolumesFromGeometry(\n cartesianPositions: Float32Array,\n geoidHeightModel: Geoid\n): {mbs: Mbs; obb: Obb} {\n const positionVectors = convertPositionsToVectors(cartesianPositions);\n\n const geometryObb = makeOrientedBoundingBoxFromPoints(positionVectors);\n const geometryMbs = makeBoundingSphereFromPoints(positionVectors);\n\n let mbsCenter = Ellipsoid.WGS84.cartesianToCartographic(geometryMbs.center, new Vector3());\n let obbCenter = Ellipsoid.WGS84.cartesianToCartographic(geometryObb.center, new Vector3());\n\n mbsCenter[2] = mbsCenter[2] - geoidHeightModel.getHeight(mbsCenter[1], mbsCenter[0]);\n obbCenter[2] = obbCenter[2] - geoidHeightModel.getHeight(obbCenter[1], obbCenter[0]);\n\n return {\n mbs: [mbsCenter[0], mbsCenter[1], mbsCenter[2], geometryMbs.radius],\n obb: {\n center: obbCenter,\n halfSize: geometryObb.halfSize,\n quaternion: geometryObb.quaternion\n }\n };\n}\n\n/**\n * Create array of posisitons where each vertex is vector\n * @param {array} positions\n * @returns {Vector3[]}\n */\nexport function convertPositionsToVectors(positions: Float32Array): Vector3[] {\n const result: Vector3[] = [];\n\n for (let i = 0; i < positions.length; i += 3) {\n // TODO: (perf) new Vector3 is not optimal but required in `makeOrientedBoundingBoxFromPoints`.\n // modify `makeOrientedBoundingBoxFromPoints` to use scratch vectors\n const positionVector = new Vector3([positions[i], positions[i + 1], positions[i + 2]]);\n result.push(positionVector);\n }\n\n return result;\n}\n\n/**\n * Convert common coordinate to fullExtent https://github.com/Esri/i3s-spec/blob/master/docs/1.8/fullExtent.cmn.md\n * @param\n * @param boundingVolume\n * @returns - fullExtent object\n */\nexport function convertBoundingVolumeToI3SFullExtent(\n boundingVolume: OrientedBoundingBox | BoundingSphere\n): FullExtent {\n let sphere: BoundingSphere;\n if (boundingVolume instanceof BoundingSphere) {\n sphere = boundingVolume;\n } else {\n sphere = boundingVolume.getBoundingSphere();\n }\n const center: Vector3 = sphere.center;\n const radius: number = sphere.radius;\n const vertexMax = Ellipsoid.WGS84.cartesianToCartographic(\n new Vector3(center[0] + radius, center[1] + radius, center[2] + radius),\n new Vector3()\n );\n const vertexMin = Ellipsoid.WGS84.cartesianToCartographic(\n new Vector3(center[0] - radius, center[1] - radius, center[2] - radius),\n new Vector3()\n );\n\n // Converter sometimes returns min values that are bigger then max,\n // so we should check and take bigger value from max and smaller for nim\n return {\n xmin: Math.min(vertexMin[0], vertexMax[0]),\n xmax: Math.max(vertexMin[0], vertexMax[0]),\n ymin: Math.min(vertexMin[1], vertexMax[1]),\n ymax: Math.max(vertexMin[1], vertexMax[1]),\n zmin: Math.min(vertexMin[2], vertexMax[2]),\n zmax: Math.max(vertexMin[2], vertexMax[2])\n };\n}\n\n/**\n * Creates oriented boundinb box from mbs.\n * @param mbs - Minimum Bounding Sphere\n * @returns - Oriented BOunding Box\n */\nexport function createObbFromMbs(mbs: Mbs): Obb {\n const radius = mbs[3];\n const center = new Vector3(mbs[0], mbs[1], mbs[2]);\n const halfAxex = new Matrix3([radius, 0, 0, 0, radius, 0, 0, 0, radius]);\n return new OrientedBoundingBox(center, halfAxex);\n}\n"],"mappings":";;;;;;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAeO,SAASG,qBAAqBA,CAACC,IAAY,EAAEC,gBAAuB,EAAmB;EAC5F,IAAIC,MAAM;EACV,IAAIC,QAAQ;EACZ,IAAIC,UAA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D"}
1
+ {"version":3,"file":"coordinate-converter.js","names":["_core","require","_geospatial","_culling","createBoundingVolumes","sourceBoundingVolume","geoidHeightModel","radius","halfSize","quaternion","cartographicCenter","Ellipsoid","WGS84","cartesianToCartographic","center","Vector3","getHeight","OrientedBoundingBox","len","Quaternion","fromMatrix3","Matrix3","normalize","mbs","obb","createBoundingVolumesFromGeometry","cartesianPositions","positionVectors","convertPositionsToVectors","geometryObb","makeOrientedBoundingBoxFromPoints","geometryMbs","makeBoundingSphereFromPoints","mbsCenter","obbCenter","positions","result","i","length","positionVector","push","convertBoundingVolumeToI3SFullExtent","boundingVolume","sphere","BoundingSphere","getBoundingSphere","vertexMax","vertexMin","xmin","Math","min","xmax","max","ymin","ymax","zmin","zmax","createObbFromMbs","halfAxex"],"sources":["../../../../src/i3s-converter/helpers/coordinate-converter.ts"],"sourcesContent":["import type {BoundingVolumes, FullExtent, Mbs, Obb} from '@loaders.gl/i3s';\n\nimport {Matrix3, Quaternion, Vector3} from '@math.gl/core';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {\n OrientedBoundingBox,\n makeOrientedBoundingBoxFromPoints,\n makeBoundingSphereFromPoints,\n BoundingSphere\n} from '@math.gl/culling';\nimport {Geoid} from '@math.gl/geoid';\n\n/**\n * Create bounding volumes object from tile and geoid height model.\n * @param sourceBoundingVolume - initialized bounding volume of the source tile\n * @param geoidHeightModel - instance of Geoid class that converts elevation from geoidal to ellipsoidal and back\n * @returns - Bounding volumes object\n */\nexport function createBoundingVolumes(\n sourceBoundingVolume: OrientedBoundingBox | BoundingSphere,\n geoidHeightModel: Geoid\n): BoundingVolumes {\n let radius;\n let halfSize;\n let quaternion;\n\n const cartographicCenter = Ellipsoid.WGS84.cartesianToCartographic(\n sourceBoundingVolume.center,\n new Vector3()\n );\n cartographicCenter[2] =\n cartographicCenter[2] -\n geoidHeightModel.getHeight(cartographicCenter[1], cartographicCenter[0]);\n if (sourceBoundingVolume instanceof OrientedBoundingBox) {\n halfSize = sourceBoundingVolume.halfSize;\n radius = new Vector3(halfSize[0], halfSize[1], halfSize[2]).len();\n quaternion = sourceBoundingVolume.quaternion;\n } else {\n radius = sourceBoundingVolume.radius;\n halfSize = [radius, radius, radius];\n quaternion = new Quaternion()\n .fromMatrix3(new Matrix3([halfSize[0], 0, 0, 0, halfSize[1], 0, 0, 0, halfSize[2]]))\n .normalize();\n }\n\n return {\n mbs: [cartographicCenter[0], cartographicCenter[1], cartographicCenter[2], radius],\n obb: {\n center: [cartographicCenter[0], cartographicCenter[1], cartographicCenter[2]],\n halfSize,\n quaternion\n }\n };\n}\n\n/**\n * Generates bounding volumes from geometry positions\n * @param cartesianPositions\n * @param geoidHeightModel\n */\nexport function createBoundingVolumesFromGeometry(\n cartesianPositions: Float32Array,\n geoidHeightModel: Geoid\n): {mbs: Mbs; obb: Obb} {\n const positionVectors = convertPositionsToVectors(cartesianPositions);\n\n const geometryObb = makeOrientedBoundingBoxFromPoints(positionVectors);\n const geometryMbs = makeBoundingSphereFromPoints(positionVectors);\n\n let mbsCenter = Ellipsoid.WGS84.cartesianToCartographic(geometryMbs.center, new Vector3());\n let obbCenter = Ellipsoid.WGS84.cartesianToCartographic(geometryObb.center, new Vector3());\n\n mbsCenter[2] = mbsCenter[2] - geoidHeightModel.getHeight(mbsCenter[1], mbsCenter[0]);\n obbCenter[2] = obbCenter[2] - geoidHeightModel.getHeight(obbCenter[1], obbCenter[0]);\n\n return {\n mbs: [mbsCenter[0], mbsCenter[1], mbsCenter[2], geometryMbs.radius],\n obb: {\n center: obbCenter,\n halfSize: geometryObb.halfSize,\n quaternion: geometryObb.quaternion\n }\n };\n}\n\n/**\n * Create array of posisitons where each vertex is vector\n * @param {array} positions\n * @returns {Vector3[]}\n */\nexport function convertPositionsToVectors(positions: Float32Array): Vector3[] {\n const result: Vector3[] = [];\n\n for (let i = 0; i < positions.length; i += 3) {\n // TODO: (perf) new Vector3 is not optimal but required in `makeOrientedBoundingBoxFromPoints`.\n // modify `makeOrientedBoundingBoxFromPoints` to use scratch vectors\n const positionVector = new Vector3([positions[i], positions[i + 1], positions[i + 2]]);\n result.push(positionVector);\n }\n\n return result;\n}\n\n/**\n * Convert common coordinate to fullExtent https://github.com/Esri/i3s-spec/blob/master/docs/1.8/fullExtent.cmn.md\n * @param\n * @param boundingVolume\n * @returns - fullExtent object\n */\nexport function convertBoundingVolumeToI3SFullExtent(\n boundingVolume: OrientedBoundingBox | BoundingSphere\n): FullExtent {\n let sphere: BoundingSphere;\n if (boundingVolume instanceof BoundingSphere) {\n sphere = boundingVolume;\n } else {\n sphere = boundingVolume.getBoundingSphere();\n }\n const center: Vector3 = sphere.center;\n const radius: number = sphere.radius;\n const vertexMax = Ellipsoid.WGS84.cartesianToCartographic(\n new Vector3(center[0] + radius, center[1] + radius, center[2] + radius),\n new Vector3()\n );\n const vertexMin = Ellipsoid.WGS84.cartesianToCartographic(\n new Vector3(center[0] - radius, center[1] - radius, center[2] - radius),\n new Vector3()\n );\n\n // Converter sometimes returns min values that are bigger then max,\n // so we should check and take bigger value from max and smaller for nim\n return {\n xmin: Math.min(vertexMin[0], vertexMax[0]),\n xmax: Math.max(vertexMin[0], vertexMax[0]),\n ymin: Math.min(vertexMin[1], vertexMax[1]),\n ymax: Math.max(vertexMin[1], vertexMax[1]),\n zmin: Math.min(vertexMin[2], vertexMax[2]),\n zmax: Math.max(vertexMin[2], vertexMax[2])\n };\n}\n\n/**\n * Creates oriented boundinb box from mbs.\n * @param mbs - Minimum Bounding Sphere\n * @returns - Oriented BOunding Box\n */\nexport function createObbFromMbs(mbs: Mbs): Obb {\n const radius = mbs[3];\n const center = new Vector3(mbs[0], mbs[1], mbs[2]);\n const halfAxex = new Matrix3([radius, 0, 0, 0, radius, 0, 0, 0, radius]);\n return new OrientedBoundingBox(center, halfAxex);\n}\n"],"mappings":";;;;;;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;A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O,IAAIU,4BAAmB,CAACH,MAAM,EAAE4C,QAAQ,CAAC;AAClD"}
@@ -24,6 +24,7 @@ var _gltfAttributes = require("./gltf-attributes");
24
24
  var _batchIdsExtensions = require("./batch-ids-extensions");
25
25
  var _featureAttributes = require("./feature-attributes");
26
26
  var _math = require("@loaders.gl/math");
27
+ var _geometryUtils = require("../../lib/utils/geometry-utils");
27
28
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
28
29
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
29
30
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
@@ -44,11 +45,11 @@ var BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES = ['CUSTOM_ATTRIBUTE_2', '_BATCHID', 'BA
44
45
  var EXT_FEATURE_METADATA = 'EXT_feature_metadata';
45
46
  var EXT_MESH_FEATURES = 'EXT_mesh_features';
46
47
  var scratchVector = new _core.Vector3();
47
- function convertB3dmToI3sGeometry(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8, _x9, _x10) {
48
+ function convertB3dmToI3sGeometry(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8, _x9, _x10, _x11, _x12) {
48
49
  return _convertB3dmToI3sGeometry.apply(this, arguments);
49
50
  }
50
51
  function _convertB3dmToI3sGeometry() {
51
- _convertB3dmToI3sGeometry = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(tileContent, addNodeToNodePage, propertyTable, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, shouldMergeMaterials, geoidHeightModel, workerSource) {
52
+ _convertB3dmToI3sGeometry = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(tileContent, tileTransform, tileBoundingVolume, addNodeToNodePage, propertyTable, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, shouldMergeMaterials, geoidHeightModel, workerSource) {
52
53
  var _tileContent$gltf4;
53
54
  var useCartesianPositions, materialAndTextureList, dataForAttributesConversion, convertedAttributesMap, result, _iterator6, _step6, materialAndTexture, originarMaterialId, convertedAttributes, material, texture, nodeId;
54
55
  return _regenerator.default.wrap(function _callee$(_context) {
@@ -59,7 +60,7 @@ function _convertB3dmToI3sGeometry() {
59
60
  return convertMaterials((_tileContent$gltf4 = tileContent.gltf) === null || _tileContent$gltf4 === void 0 ? void 0 : _tileContent$gltf4.materials, shouldMergeMaterials);
60
61
  case 3:
61
62
  materialAndTextureList = _context.sent;
62
- dataForAttributesConversion = (0, _gltfAttributes.prepareDataForAttributesConversion)(tileContent);
63
+ dataForAttributesConversion = (0, _gltfAttributes.prepareDataForAttributesConversion)(tileContent, tileTransform, tileBoundingVolume);
63
64
  _context.next = 7;
64
65
  return convertAttributes(dataForAttributesConversion, materialAndTextureList, useCartesianPositions);
65
66
  case 7:
@@ -166,7 +167,7 @@ function _generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeigh
166
167
  _iterator.f();
167
168
  }
168
169
  }
169
- function _makeNodeResources(_x11) {
170
+ function _makeNodeResources(_x13) {
170
171
  return _makeNodeResources2.apply(this, arguments);
171
172
  }
172
173
  function _makeNodeResources2() {
@@ -221,7 +222,7 @@ function _makeNodeResources2() {
221
222
  }));
222
223
  return _makeNodeResources2.apply(this, arguments);
223
224
  }
224
- function convertAttributes(_x12, _x13, _x14) {
225
+ function convertAttributes(_x14, _x15, _x16) {
225
226
  return _convertAttributes.apply(this, arguments);
226
227
  }
227
228
  function _convertAttributes() {
@@ -376,21 +377,22 @@ function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, att
376
377
  var materialUvRegion;
377
378
  if (primitive.material) {
378
379
  var _outputAttributes, _outputAttributes$mer;
379
- outputAttributes = attributesMap.get(primitive.material.uniqueId);
380
+ outputAttributes = attributesMap.get(primitive.material.id);
380
381
  materialUvRegion = (_outputAttributes = outputAttributes) === null || _outputAttributes === void 0 ? void 0 : (_outputAttributes$mer = _outputAttributes.mergedMaterials.find(function (_ref2) {
381
382
  var _primitive$material;
382
383
  var originalMaterialId = _ref2.originalMaterialId;
383
- return originalMaterialId === ((_primitive$material = primitive.material) === null || _primitive$material === void 0 ? void 0 : _primitive$material.uniqueId);
384
+ return originalMaterialId === ((_primitive$material = primitive.material) === null || _primitive$material === void 0 ? void 0 : _primitive$material.id);
384
385
  })) === null || _outputAttributes$mer === void 0 ? void 0 : _outputAttributes$mer.uvRegion;
385
386
  } else if (attributesMap.has('default')) {
386
387
  outputAttributes = attributesMap.get('default');
387
388
  }
388
389
  (0, _core2.assert)(outputAttributes !== null, 'Primitive - material mapping failed');
390
+ (0, _core2.assert)(primitive.mode === undefined || primitive.mode === _math.GL.TRIANGLES || primitive.mode === _math.GL.TRIANGLE_STRIP, "Primitive - unsupported mode ".concat(primitive.mode));
389
391
  var attributes = primitive.attributes;
390
392
  if (!outputAttributes) {
391
393
  return "continue";
392
394
  }
393
- var indices = getIndices(primitive);
395
+ var indices = normalizeIndices(primitive);
394
396
  outputAttributes.positions = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.positions, transformVertexArray({
395
397
  vertices: attributes.POSITION.value,
396
398
  cartographicOrigin: cartographicOrigin,
@@ -427,9 +429,13 @@ function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, att
427
429
  _iterator3.f();
428
430
  }
429
431
  }
430
- function getIndices(primitive) {
432
+ function normalizeIndices(primitive) {
431
433
  var _primitive$indices;
432
434
  var indices = (_primitive$indices = primitive.indices) === null || _primitive$indices === void 0 ? void 0 : _primitive$indices.value;
435
+ if (!indices) {
436
+ var positions = primitive.attributes.POSITION.value;
437
+ return (0, _geometryUtils.generateSyntheticIndices)(positions.length / VALUES_PER_VERTEX);
438
+ }
433
439
  if (indices && primitive.mode === _math.GL.TRIANGLE_STRIP) {
434
440
  var TypedArrayConstructor = indices.constructor;
435
441
  var newIndices = new TypedArrayConstructor((indices.length - 2) * 3);
@@ -604,7 +610,7 @@ function _convertMaterials() {
604
610
  }));
605
611
  return _convertMaterials.apply(this, arguments);
606
612
  }
607
- function mergeAllMaterials(_x15) {
613
+ function mergeAllMaterials(_x17) {
608
614
  return _mergeAllMaterials.apply(this, arguments);
609
615
  }
610
616
  function _mergeAllMaterials() {
@@ -643,12 +649,12 @@ function _mergeAllMaterials() {
643
649
  break;
644
650
  case 15:
645
651
  if (newMaterial.texture && mergedIndices.length) {
646
- newWidth = (_newMaterial$mergedMa = newMaterial.mergedMaterials) === null || _newMaterial$mergedMa === void 0 ? void 0 : _newMaterial$mergedMa.reduce(function (accum, _ref4) {
647
- var textureSize = _ref4.textureSize;
652
+ newWidth = (_newMaterial$mergedMa = newMaterial.mergedMaterials) === null || _newMaterial$mergedMa === void 0 ? void 0 : _newMaterial$mergedMa.reduce(function (accum, _ref5) {
653
+ var textureSize = _ref5.textureSize;
648
654
  return accum + ((textureSize === null || textureSize === void 0 ? void 0 : textureSize.width) || 0);
649
655
  }, 0);
650
- newHeight = (_newMaterial$mergedMa2 = newMaterial.mergedMaterials) === null || _newMaterial$mergedMa2 === void 0 ? void 0 : _newMaterial$mergedMa2.reduce(function (accum, _ref5) {
651
- var textureSize = _ref5.textureSize;
656
+ newHeight = (_newMaterial$mergedMa2 = newMaterial.mergedMaterials) === null || _newMaterial$mergedMa2 === void 0 ? void 0 : _newMaterial$mergedMa2.reduce(function (accum, _ref6) {
657
+ var textureSize = _ref6.textureSize;
652
658
  return Math.max(accum, (textureSize === null || textureSize === void 0 ? void 0 : textureSize.height) || 0);
653
659
  }, 0);
654
660
  currentX = -1;
@@ -702,7 +708,7 @@ function _mergeAllMaterials() {
702
708
  }));
703
709
  return _mergeAllMaterials.apply(this, arguments);
704
710
  }
705
- function mergeMaterials(_x16, _x17) {
711
+ function mergeMaterials(_x18, _x19) {
706
712
  return _mergeMaterials.apply(this, arguments);
707
713
  }
708
714
  function _mergeMaterials() {
@@ -781,10 +787,9 @@ function convertMaterial(sourceMaterial) {
781
787
  textureSetDefinitionId: 0
782
788
  };
783
789
  }
784
- var uniqueId = (0, _uuid.v4)();
785
- sourceMaterial.uniqueId = uniqueId;
790
+ sourceMaterial.id = Number.isFinite(sourceMaterial.id) ? sourceMaterial.id : (0, _uuid.v4)();
786
791
  var mergedMaterials = [{
787
- originalMaterialId: uniqueId
792
+ originalMaterialId: sourceMaterial.id
788
793
  }];
789
794
  if (!texture) {
790
795
  var _sourceMaterial$pbrMe4;
@@ -892,21 +897,24 @@ function extractSharedResourcesMaterialInfo(baseColorFactor) {
892
897
  };
893
898
  }
894
899
  function extractSharedResourcesTextureInfo(texture, nodeId) {
895
- var _texture$source, _texture$source2, _texture$source3;
900
+ var _texture$source, _texture$source2, _texture$source3, _texture$source4;
896
901
  return {
897
902
  encoding: texture !== null && texture !== void 0 && (_texture$source = texture.source) !== null && _texture$source !== void 0 && _texture$source.mimeType ? [texture.source.mimeType] : undefined,
898
903
  images: [{
899
904
  id: generateImageId(texture, nodeId),
900
905
  size: (_texture$source2 = texture.source) === null || _texture$source2 === void 0 ? void 0 : _texture$source2.image.width,
901
- length: [(_texture$source3 = texture.source) === null || _texture$source3 === void 0 ? void 0 : _texture$source3.image.data.length]
906
+ length: (_texture$source3 = texture.source) !== null && _texture$source3 !== void 0 && _texture$source3.image.data.length ? [(_texture$source4 = texture.source) === null || _texture$source4 === void 0 ? void 0 : _texture$source4.image.data.length] : undefined
902
907
  }]
903
908
  };
904
909
  }
905
910
  function generateImageId(texture, nodeId) {
906
- var _texture$source4;
907
- var _texture$source$image = (_texture$source4 = texture.source) === null || _texture$source4 === void 0 ? void 0 : _texture$source4.image,
908
- width = _texture$source$image.width,
909
- height = _texture$source$image.height;
911
+ var _texture$source5;
912
+ var _ref4 = ((_texture$source5 = texture.source) === null || _texture$source5 === void 0 ? void 0 : _texture$source5.image) || {},
913
+ width = _ref4.width,
914
+ height = _ref4.height;
915
+ if (!width || !height) {
916
+ return '';
917
+ }
910
918
  var levelCountOfTexture = 1;
911
919
  var indexOfLevel = 0;
912
920
  var indexOfTextureInStore = nodeId + 1;
@@ -1027,7 +1035,7 @@ function generateBigUint64Array(featureIds) {
1027
1035
  }
1028
1036
  return typedFeatureIds;
1029
1037
  }
1030
- function generateCompressedGeometry(_x18, _x19, _x20, _x21) {
1038
+ function generateCompressedGeometry(_x20, _x21, _x22, _x23) {
1031
1039
  return _generateCompressedGeometry.apply(this, arguments);
1032
1040
  }
1033
1041
  function _generateCompressedGeometry() {
@@ -1097,6 +1105,9 @@ function generateFeatureIndexAttribute(featureIndex, faceRange) {
1097
1105
  return orderedFeatureIndices;
1098
1106
  }
1099
1107
  function getPropertyTable(tileContent) {
1108
+ if (!tileContent) {
1109
+ return null;
1110
+ }
1100
1111
  var batchTableJson = tileContent === null || tileContent === void 0 ? void 0 : tileContent.batchTableJson;
1101
1112
  if (batchTableJson) {
1102
1113
  return batchTableJson;
@@ -1151,10 +1162,6 @@ function getPropertyTableExtension(tileContent) {
1151
1162
  };
1152
1163
  }
1153
1164
  function getPropertyTableFromExtFeatureMetadata(extension) {
1154
- if (extension !== null && extension !== void 0 && extension.featureTextures) {
1155
- console.warn('The I3S converter does not yet support the EXT_feature_metadata feature textures');
1156
- return null;
1157
- }
1158
1165
  if (extension !== null && extension !== void 0 && extension.featureTables) {
1159
1166
  var _Object$keys;
1160
1167
  var firstFeatureTableName = (_Object$keys = Object.keys(extension.featureTables)) === null || _Object$keys === void 0 ? void 0 : _Object$keys[0];
@@ -1167,7 +1174,19 @@ function getPropertyTableFromExtFeatureMetadata(extension) {
1167
1174
  return propertyTable;
1168
1175
  }
1169
1176
  }
1170
- console.warn("The I3S converter couldn't handle EXT_feature_metadata extension");
1177
+ if (extension !== null && extension !== void 0 && extension.featureTextures) {
1178
+ var _Object$keys2;
1179
+ var firstTextureName = (_Object$keys2 = Object.keys(extension.featureTextures)) === null || _Object$keys2 === void 0 ? void 0 : _Object$keys2[0];
1180
+ if (firstTextureName) {
1181
+ var _featureTable = extension === null || extension === void 0 ? void 0 : extension.featureTextures[firstTextureName];
1182
+ var _propertyTable = {};
1183
+ for (var _propertyName in _featureTable.properties) {
1184
+ _propertyTable[_propertyName] = _featureTable.properties[_propertyName].data;
1185
+ }
1186
+ return _propertyTable;
1187
+ }
1188
+ }
1189
+ console.warn("The I3S converter couldn't handle EXT_feature_metadata extension: There is neither featureTables, no featureTextures in the extension.");
1171
1190
  return null;
1172
1191
  }
1173
1192
  //# sourceMappingURL=geometry-converter.js.map