@loaders.gl/tile-converter 4.0.0-alpha.12 → 4.0.0-alpha.14

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 (85) hide show
  1. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +0 -1
  2. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
  3. package/dist/3d-tiles-converter/3d-tiles-converter.js +8 -19
  4. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +4 -1
  5. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
  6. package/dist/converter.min.js +66 -66
  7. package/dist/dist.min.js +1381 -331
  8. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +34 -67
  9. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  10. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  11. package/dist/es5/deps-installer/deps-installer.js +1 -1
  12. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  13. package/dist/es5/i3s-converter/helpers/geometry-converter.js +6 -0
  14. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  15. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  16. package/dist/es5/i3s-converter/i3s-converter.js +10 -21
  17. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  18. package/dist/es5/i3s-converter/types.js.map +1 -1
  19. package/dist/es5/pgm-loader.js +1 -1
  20. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +8 -18
  21. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  22. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  23. package/dist/esm/deps-installer/deps-installer.js +1 -1
  24. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  25. package/dist/esm/i3s-converter/helpers/geometry-converter.js +6 -0
  26. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  27. package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  28. package/dist/esm/i3s-converter/i3s-converter.js +0 -7
  29. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  30. package/dist/esm/i3s-converter/types.js.map +1 -1
  31. package/dist/esm/pgm-loader.js +1 -1
  32. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +1 -1
  33. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
  34. package/dist/i3s-converter/helpers/geometry-converter.d.ts +2 -3
  35. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  36. package/dist/i3s-converter/helpers/geometry-converter.js +3 -0
  37. package/dist/i3s-converter/helpers/gltf-attributes.d.ts +2 -2
  38. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
  39. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  40. package/dist/i3s-converter/i3s-converter.js +0 -5
  41. package/dist/i3s-converter/types.d.ts +32 -1
  42. package/dist/i3s-converter/types.d.ts.map +1 -1
  43. package/dist/i3s-converter/types.js +1 -1
  44. package/package.json +16 -18
  45. package/src/3d-tiles-converter/3d-tiles-converter.ts +10 -28
  46. package/src/3d-tiles-converter/helpers/b3dm-converter.ts +5 -2
  47. package/src/i3s-converter/helpers/batch-ids-extensions.ts +6 -6
  48. package/src/i3s-converter/helpers/geometry-converter.ts +17 -17
  49. package/src/i3s-converter/helpers/gltf-attributes.ts +2 -2
  50. package/src/i3s-converter/i3s-converter.ts +0 -5
  51. package/src/i3s-converter/types.ts +32 -1
  52. package/dist/3d-tiles-attributes-worker.d.ts +0 -28
  53. package/dist/3d-tiles-attributes-worker.d.ts.map +0 -1
  54. package/dist/3d-tiles-attributes-worker.js +0 -3
  55. package/dist/3d-tiles-attributes-worker.js.map +0 -7
  56. package/dist/es5/3d-tiles-attributes-worker.js +0 -25
  57. package/dist/es5/3d-tiles-attributes-worker.js.map +0 -1
  58. package/dist/es5/i3s-attributes-worker.js +0 -25
  59. package/dist/es5/i3s-attributes-worker.js.map +0 -1
  60. package/dist/es5/workers/3d-tiles-attributes-worker.js +0 -28
  61. package/dist/es5/workers/3d-tiles-attributes-worker.js.map +0 -1
  62. package/dist/es5/workers/i3s-attributes-worker.js +0 -30
  63. package/dist/es5/workers/i3s-attributes-worker.js.map +0 -1
  64. package/dist/esm/3d-tiles-attributes-worker.js +0 -16
  65. package/dist/esm/3d-tiles-attributes-worker.js.map +0 -1
  66. package/dist/esm/i3s-attributes-worker.js +0 -16
  67. package/dist/esm/i3s-attributes-worker.js.map +0 -1
  68. package/dist/esm/workers/3d-tiles-attributes-worker.js +0 -8
  69. package/dist/esm/workers/3d-tiles-attributes-worker.js.map +0 -1
  70. package/dist/esm/workers/i3s-attributes-worker.js +0 -7
  71. package/dist/esm/workers/i3s-attributes-worker.js.map +0 -1
  72. package/dist/i3s-attributes-worker.d.ts +0 -45
  73. package/dist/i3s-attributes-worker.d.ts.map +0 -1
  74. package/dist/i3s-attributes-worker.js +0 -9
  75. package/dist/i3s-attributes-worker.js.map +0 -7
  76. package/dist/workers/3d-tiles-attributes-worker.d.ts +0 -2
  77. package/dist/workers/3d-tiles-attributes-worker.d.ts.map +0 -1
  78. package/dist/workers/3d-tiles-attributes-worker.js +0 -9
  79. package/dist/workers/i3s-attributes-worker.d.ts +0 -2
  80. package/dist/workers/i3s-attributes-worker.d.ts.map +0 -1
  81. package/dist/workers/i3s-attributes-worker.js +0 -5
  82. package/src/3d-tiles-attributes-worker.ts +0 -43
  83. package/src/i3s-attributes-worker.ts +0 -59
  84. package/src/workers/3d-tiles-attributes-worker.ts +0 -6
  85. package/src/workers/i3s-attributes-worker.ts +0 -7
@@ -1 +1 @@
1
- {"version":3,"file":"gltf-attributes.js","names":["_core","require","_geospatial","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","prepareDataForAttributesConversion","tileContent","tileTransform","boundingVolume","_tileContent$gltf","_tileContent$gltf$sce","_tileContent$gltf2","_tileContent$gltf2$sc","_tileContent$gltf2$sc2","_tileContent$gltf3","_tileContent$gltf4","_tileContent$gltf4$im","nodes","gltf","scene","scenes","images","map","imageObject","_imageObject$image","image","compressed","_imageObject$image2","data","dataCopy","Uint8Array","set","height","width","components","mimeType","prepareNodes","_calculateTransformPr","calculateTransformProps","cartographicOrigin","cartesianModelMatrix","modelMatrix","getB3DMAttributesWithoutBufferView","attributes","attributesWithoutBufferView","attributeName","value","rtcCenter","gltfUpAxis","center","Matrix4","translate","rotationY","rotateX","Math","PI","multiplyRight","rotationX","rotateY","cartesianOrigin","Vector3","Ellipsoid","WGS84","cartesianToCartographic","index","node","mesh","_node$mesh","primitives","primitive","_primitive$indices","_primitive$material","_primitive$material2","indices","material","id","uniqueId","children"],"sources":["../../../../src/i3s-converter/helpers/gltf-attributes.ts"],"sourcesContent":["import type {Tiles3DTileContent} from '@loaders.gl/3d-tiles';\nimport type {GLTFAccessorPostprocessed, GLTFNodePostprocessed} from '@loaders.gl/gltf';\nimport type {B3DMAttributesData} from '../../i3s-attributes-worker';\nimport {Matrix4, TypedArray, Vector3} from '@math.gl/core';\nimport {BoundingSphere, OrientedBoundingBox} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\n\n/**\n * Prepare attributes for conversion to avoid binary data breaking in worker thread.\n * @param tileContent - 3DTiles tile content\n * @param tileTransform - transformation matrix of the tile, calculated recursively multiplying\n * transform of all parent tiles and transform of the current tile\n * @param boundingVolume - initialized bounding volume of the source tile\n * @returns 3DTiles content data, prepared for conversion\n */\nexport function prepareDataForAttributesConversion(\n tileContent: Tiles3DTileContent,\n tileTransform: Matrix4,\n boundingVolume: OrientedBoundingBox | BoundingSphere\n): B3DMAttributesData {\n let nodes =\n tileContent.gltf?.scene?.nodes ||\n tileContent.gltf?.scenes?.[0]?.nodes ||\n tileContent.gltf?.nodes ||\n [];\n\n const images =\n tileContent.gltf?.images?.map((imageObject) => {\n // Need data only for uncompressed images because we can't get batchIds from compressed textures.\n if (imageObject?.image?.compressed) {\n return null;\n } else {\n const data = imageObject?.image?.data;\n const dataCopy = new Uint8Array(data.length);\n dataCopy.set(data);\n return {\n data: dataCopy,\n compressed: false,\n height: imageObject.image.height,\n width: imageObject.image.width,\n components: imageObject.image.components,\n mimeType: imageObject.mimeType\n };\n }\n }) || [];\n\n prepareNodes(nodes);\n\n const {cartographicOrigin, modelMatrix: cartesianModelMatrix} = calculateTransformProps(\n tileContent,\n tileTransform,\n boundingVolume\n );\n\n return {\n nodes,\n images,\n cartographicOrigin,\n cartesianModelMatrix\n };\n}\n\n/**\n * Keep only values for glTF attributes to pass data to worker thread.\n * @param attributes - geometry attributes\n * @returns attributes with only `value` item\n */\nfunction getB3DMAttributesWithoutBufferView(\n attributes: Record<string, GLTFAccessorPostprocessed>\n): Record<string, {value: TypedArray}> {\n const attributesWithoutBufferView: Record<string, {value: TypedArray}> = {};\n\n for (const attributeName in attributes) {\n attributesWithoutBufferView[attributeName] = {\n value: attributes[attributeName].value\n };\n }\n\n return attributesWithoutBufferView;\n}\n\n/**\n * Calculate transformation properties to transform vertex attributes (POSITION, NORMAL, etc.)\n * from METER_OFFSET coorditantes to LNGLAT_OFFSET coordinates\n * @param tileContent - 3DTiles tile content\n * @param tileTransform - transformation matrix of the tile, calculated recursively multiplying\n * transform of all parent tiles and transform of the current tile\n * @param boundingVolume - initialized bounding volume of the source tile\n * @returns modelMatrix - transformation matrix to transform coordinates to cartographic coordinates\n * cartographicOrigin - tile origin coordinates to calculate offsets\n */\nexport function calculateTransformProps(\n tileContent: Tiles3DTileContent,\n tileTransform: Matrix4,\n boundingVolume: OrientedBoundingBox | BoundingSphere\n): {modelMatrix: Matrix4; cartographicOrigin: Vector3} {\n const {rtcCenter, gltfUpAxis} = tileContent;\n const {center} = boundingVolume;\n\n let modelMatrix = new Matrix4(tileTransform);\n\n // Translate if appropriate\n if (rtcCenter) {\n modelMatrix.translate(rtcCenter);\n }\n\n // glTF models need to be rotated from Y to Z up\n // https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification#y-up-to-z-up\n switch (gltfUpAxis) {\n case 'Z':\n break;\n case 'Y':\n const rotationY = new Matrix4().rotateX(Math.PI / 2);\n modelMatrix = modelMatrix.multiplyRight(rotationY);\n break;\n case 'X':\n const rotationX = new Matrix4().rotateY(-Math.PI / 2);\n modelMatrix = modelMatrix.multiplyRight(rotationX);\n break;\n default:\n break;\n }\n\n const cartesianOrigin = new Vector3(center);\n const cartographicOrigin = Ellipsoid.WGS84.cartesianToCartographic(\n cartesianOrigin,\n new Vector3()\n );\n return {modelMatrix, cartographicOrigin};\n}\n\n/**\n * Traverse all nodes to replace all sensible data with copy to avoid data corruption in worker.\n * @param nodes\n */\nfunction prepareNodes(nodes: GLTFNodePostprocessed[]): void {\n for (let index = 0; index < nodes.length; index++) {\n const node = nodes[index] as any;\n\n if (node.mesh) {\n nodes[index] = {\n ...node,\n mesh: {\n ...node.mesh,\n primitives: node.mesh?.primitives.map((primitive) => ({\n ...primitive,\n indices: {value: primitive?.indices?.value},\n attributes: getB3DMAttributesWithoutBufferView(primitive.attributes),\n material: {\n id: primitive?.material?.id,\n uniqueId: primitive?.material?.uniqueId\n }\n }))\n }\n };\n }\n\n if (node.children) {\n prepareNodes(node.children);\n }\n }\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AAA8C,SAAAE,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAA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AEN,SAAS,aAATA,SAAS,wBAAAE,mBAAA,GAATF,SAAS,CAAEK,QAAQ,cAAAH,mBAAA,uBAAnBA,mBAAA,CAAqBI,EAAE;gBAC3BC,QAAQ,EAAEP,SAAS,aAATA,SAAS,wBAAAG,oBAAA,GAATH,SAAS,CAAEK,QAAQ,cAAAF,oBAAA,uBAAnBA,oBAAA,CAAqBI;cACjC;YAAC;UAAA,CACD;QAAC;MACJ,EACF;IACH;IAEA,IAAIX,IAAI,CAACY,QAAQ,EAAE;MACjBzC,YAAY,CAAC6B,IAAI,CAACY,QAAQ,CAAC;IAC7B;EACF;AACF"}
1
+ {"version":3,"file":"gltf-attributes.js","names":["_core","require","_geospatial","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","prepareDataForAttributesConversion","tileContent","tileTransform","boundingVolume","_tileContent$gltf","_tileContent$gltf$sce","_tileContent$gltf2","_tileContent$gltf2$sc","_tileContent$gltf2$sc2","_tileContent$gltf3","_tileContent$gltf4","_tileContent$gltf4$im","nodes","gltf","scene","scenes","images","map","imageObject","_imageObject$image","image","compressed","_imageObject$image2","data","dataCopy","Uint8Array","set","height","width","components","mimeType","prepareNodes","_calculateTransformPr","calculateTransformProps","cartographicOrigin","cartesianModelMatrix","modelMatrix","getB3DMAttributesWithoutBufferView","attributes","attributesWithoutBufferView","attributeName","value","rtcCenter","gltfUpAxis","center","Matrix4","translate","rotationY","rotateX","Math","PI","multiplyRight","rotationX","rotateY","cartesianOrigin","Vector3","Ellipsoid","WGS84","cartesianToCartographic","index","node","mesh","_node$mesh","primitives","primitive","_primitive$indices","_primitive$material","_primitive$material2","indices","material","id","uniqueId","children"],"sources":["../../../../src/i3s-converter/helpers/gltf-attributes.ts"],"sourcesContent":["import type {Tiles3DTileContent} from '@loaders.gl/3d-tiles';\nimport type {GLTFAccessorPostprocessed, GLTFNodePostprocessed} from '@loaders.gl/gltf';\nimport {Matrix4, TypedArray, Vector3} from '@math.gl/core';\nimport {BoundingSphere, OrientedBoundingBox} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {GLTFAttributesData} from '../types';\n\n/**\n * Prepare attributes for conversion to avoid binary data breaking in worker thread.\n * @param tileContent - 3DTiles tile content\n * @param tileTransform - transformation matrix of the tile, calculated recursively multiplying\n * transform of all parent tiles and transform of the current tile\n * @param boundingVolume - initialized bounding volume of the source tile\n * @returns 3DTiles content data, prepared for conversion\n */\nexport function prepareDataForAttributesConversion(\n tileContent: Tiles3DTileContent,\n tileTransform: Matrix4,\n boundingVolume: OrientedBoundingBox | BoundingSphere\n): GLTFAttributesData {\n let nodes =\n tileContent.gltf?.scene?.nodes ||\n tileContent.gltf?.scenes?.[0]?.nodes ||\n tileContent.gltf?.nodes ||\n [];\n\n const images =\n tileContent.gltf?.images?.map((imageObject) => {\n // Need data only for uncompressed images because we can't get batchIds from compressed textures.\n if (imageObject?.image?.compressed) {\n return null;\n } else {\n const data = imageObject?.image?.data;\n const dataCopy = new Uint8Array(data.length);\n dataCopy.set(data);\n return {\n data: dataCopy,\n compressed: false,\n height: imageObject.image.height,\n width: imageObject.image.width,\n components: imageObject.image.components,\n mimeType: imageObject.mimeType\n };\n }\n }) || [];\n\n prepareNodes(nodes);\n\n const {cartographicOrigin, modelMatrix: cartesianModelMatrix} = calculateTransformProps(\n tileContent,\n tileTransform,\n boundingVolume\n );\n\n return {\n nodes,\n images,\n cartographicOrigin,\n cartesianModelMatrix\n };\n}\n\n/**\n * Keep only values for glTF attributes to pass data to worker thread.\n * @param attributes - geometry attributes\n * @returns attributes with only `value` item\n */\nfunction getB3DMAttributesWithoutBufferView(\n attributes: Record<string, GLTFAccessorPostprocessed>\n): Record<string, {value: TypedArray}> {\n const attributesWithoutBufferView: Record<string, {value: TypedArray}> = {};\n\n for (const attributeName in attributes) {\n attributesWithoutBufferView[attributeName] = {\n value: attributes[attributeName].value\n };\n }\n\n return attributesWithoutBufferView;\n}\n\n/**\n * Calculate transformation properties to transform vertex attributes (POSITION, NORMAL, etc.)\n * from METER_OFFSET coorditantes to LNGLAT_OFFSET coordinates\n * @param tileContent - 3DTiles tile content\n * @param tileTransform - transformation matrix of the tile, calculated recursively multiplying\n * transform of all parent tiles and transform of the current tile\n * @param boundingVolume - initialized bounding volume of the source tile\n * @returns modelMatrix - transformation matrix to transform coordinates to cartographic coordinates\n * cartographicOrigin - tile origin coordinates to calculate offsets\n */\nexport function calculateTransformProps(\n tileContent: Tiles3DTileContent,\n tileTransform: Matrix4,\n boundingVolume: OrientedBoundingBox | BoundingSphere\n): {modelMatrix: Matrix4; cartographicOrigin: Vector3} {\n const {rtcCenter, gltfUpAxis} = tileContent;\n const {center} = boundingVolume;\n\n let modelMatrix = new Matrix4(tileTransform);\n\n // Translate if appropriate\n if (rtcCenter) {\n modelMatrix.translate(rtcCenter);\n }\n\n // glTF models need to be rotated from Y to Z up\n // https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification#y-up-to-z-up\n switch (gltfUpAxis) {\n case 'Z':\n break;\n case 'Y':\n const rotationY = new Matrix4().rotateX(Math.PI / 2);\n modelMatrix = modelMatrix.multiplyRight(rotationY);\n break;\n case 'X':\n const rotationX = new Matrix4().rotateY(-Math.PI / 2);\n modelMatrix = modelMatrix.multiplyRight(rotationX);\n break;\n default:\n break;\n }\n\n const cartesianOrigin = new Vector3(center);\n const cartographicOrigin = Ellipsoid.WGS84.cartesianToCartographic(\n cartesianOrigin,\n new Vector3()\n );\n return {modelMatrix, cartographicOrigin};\n}\n\n/**\n * Traverse all nodes to replace all sensible data with copy to avoid data corruption in worker.\n * @param nodes\n */\nfunction prepareNodes(nodes: GLTFNodePostprocessed[]): void {\n for (let index = 0; index < nodes.length; index++) {\n const node = nodes[index] as any;\n\n if (node.mesh) {\n nodes[index] = {\n ...node,\n mesh: {\n ...node.mesh,\n primitives: node.mesh?.primitives.map((primitive) => ({\n ...primitive,\n indices: {value: primitive?.indices?.value},\n attributes: getB3DMAttributesWithoutBufferView(primitive.attributes),\n material: {\n id: primitive?.material?.id,\n uniqueId: primitive?.material?.uniqueId\n }\n }))\n }\n };\n }\n\n if (node.children) {\n prepareNodes(node.children);\n }\n }\n}\n"],"mappings":";;;;;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AAA8C,SAAAE,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,WAAAJ,MAAA,CAAAK,wBAAA,CAAAR,MAAA,EAAAO,GAAA,EAAAE,UAAA,OAAAP,IAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,IAAA,EAAAG,OAAA,YAAAH,IAAA;AAAA,SAAAU,cAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAF,CAAA,UAAAG,MAAA,WAAAF,SAAA,CAAAD,CAAA,IAAAC,SAAA,CAAAD,CAAA,QAAAA,CAAA,OAAAf,OAAA,CAAAI,MAAA,CAAAc,MAAA,OAAAC,OAAA,WAAAC,GAAA,QAAAC,gBAAA,CAAAC,OAAA,EAAAR,MAAA,EAAAM,GAAA,EAAAF,MAAA,CAAAE,GAAA,SAAAhB,MAAA,CAAAmB,yBAAA,GAAAnB,MAAA,CAAAoB,gBAAA,CAAAV,MAAA,EAAAV,MAAA,CAAAmB,yBAAA,CAAAL,MAAA,KAAAlB,OAAA,CAAAI,MAAA,CAAAc,MAAA,GAAAC,OAAA,WAAAC,GAAA,IAAAhB,MAAA,CAAAqB,cAAA,CAAAX,MAAA,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aAAA,CAAAA,aAAA,KACCyE,IAAI,CAACC,IAAI;UACZE,UAAU,GAAAD,UAAA,GAAEF,IAAI,CAACC,IAAI,cAAAC,UAAA,uBAATA,UAAA,CAAWC,UAAU,CAAC9C,GAAG,CAAC,UAAC+C,SAAS;YAAA,IAAAC,kBAAA,EAAAC,mBAAA,EAAAC,oBAAA;YAAA,OAAAhF,aAAA,CAAAA,aAAA,KAC3C6E,SAAS;cACZI,OAAO,EAAE;gBAAC3B,KAAK,EAAEuB,SAAS,aAATA,SAAS,wBAAAC,kBAAA,GAATD,SAAS,CAAEI,OAAO,cAAAH,kBAAA,uBAAlBA,kBAAA,CAAoBxB;cAAK,CAAC;cAC3CH,UAAU,EAAED,kCAAkC,CAAC2B,SAAS,CAAC1B,UAAU,CAAC;cACpE+B,QAAQ,EAAE;gBACRC,EAAE,EAAEN,SAAS,aAATA,SAAS,wBAAAE,mBAAA,GAATF,SAAS,CAAEK,QAAQ,cAAAH,mBAAA,uBAAnBA,mBAAA,CAAqBI,EAAE;gBAC3BC,QAAQ,EAAEP,SAAS,aAATA,SAAS,wBAAAG,oBAAA,GAATH,SAAS,CAAEK,QAAQ,cAAAF,oBAAA,uBAAnBA,oBAAA,CAAqBI;cACjC;YAAC;UAAA,CACD;QAAC;MACJ,EACF;IACH;IAEA,IAAIX,IAAI,CAACY,QAAQ,EAAE;MACjBzC,YAAY,CAAC6B,IAAI,CAACY,QAAQ,CAAC;IAC7B;EACF;AACF"}
@@ -38,7 +38,6 @@ var _types = require("./types");
38
38
  var _workerUtils = require("@loaders.gl/worker-utils");
39
39
  var _draco = require("@loaders.gl/draco");
40
40
  var _writeQueue = _interopRequireDefault(require("../lib/utils/write-queue"));
41
- var _i3sAttributesWorker = require("../i3s-attributes-worker");
42
41
  var _constants = require("../constants");
43
42
  var _featureAttributes = require("./helpers/feature-attributes");
44
43
  var _nodeIndexDocument = require("./helpers/node-index-document");
@@ -1498,7 +1497,7 @@ var I3SConverter = function () {
1498
1497
  key: "loadWorkers",
1499
1498
  value: function () {
1500
1499
  var _loadWorkers = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee22() {
1501
- var url, _sourceResponse, _source, _url, _sourceResponse2, _source2, i3sAttributesWorkerUrl, sourceResponse, source;
1500
+ var url, sourceResponse, source, _url, _sourceResponse, _source;
1502
1501
  return _regenerator.default.wrap(function _callee22$(_context23) {
1503
1502
  while (1) switch (_context23.prev = _context23.next) {
1504
1503
  case 0:
@@ -1511,12 +1510,12 @@ var I3SConverter = function () {
1511
1510
  _context23.next = 5;
1512
1511
  return (0, _core.fetchFile)(url);
1513
1512
  case 5:
1514
- _sourceResponse = _context23.sent;
1513
+ sourceResponse = _context23.sent;
1515
1514
  _context23.next = 8;
1516
- return _sourceResponse.text();
1515
+ return sourceResponse.text();
1517
1516
  case 8:
1518
- _source = _context23.sent;
1519
- this.workerSource.draco = _source;
1517
+ source = _context23.sent;
1518
+ this.workerSource.draco = source;
1520
1519
  case 10:
1521
1520
  if (!this.generateTextures) {
1522
1521
  _context23.next = 19;
@@ -1526,25 +1525,15 @@ var I3SConverter = function () {
1526
1525
  _context23.next = 14;
1527
1526
  return (0, _core.fetchFile)(_url);
1528
1527
  case 14:
1529
- _sourceResponse2 = _context23.sent;
1528
+ _sourceResponse = _context23.sent;
1530
1529
  _context23.next = 17;
1531
- return _sourceResponse2.text();
1530
+ return _sourceResponse.text();
1532
1531
  case 17:
1533
- _source2 = _context23.sent;
1534
- this.workerSource.ktx2 = _source2;
1532
+ _source = _context23.sent;
1533
+ this.workerSource.ktx2 = _source;
1535
1534
  case 19:
1536
- i3sAttributesWorkerUrl = (0, _workerUtils.getWorkerURL)(_i3sAttributesWorker.I3SAttributesWorker, _objectSpread({}, (0, _core.getLoaderOptions)()));
1537
- _context23.next = 22;
1538
- return (0, _core.fetchFile)(i3sAttributesWorkerUrl);
1539
- case 22:
1540
- sourceResponse = _context23.sent;
1541
- _context23.next = 25;
1542
- return sourceResponse.text();
1543
- case 25:
1544
- source = _context23.sent;
1545
- this.workerSource.I3SAttributes = source;
1546
1535
  console.log("Loading workers source completed!");
1547
- case 28:
1536
+ case 20:
1548
1537
  case "end":
1549
1538
  return _context23.stop();
1550
1539
  }