@loaders.gl/tile-converter 3.3.0-alpha.7 → 3.3.0

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 (136) hide show
  1. package/dist/3d-tiles-attributes-worker.d.ts +2 -2
  2. package/dist/3d-tiles-attributes-worker.d.ts.map +1 -1
  3. package/dist/3d-tiles-attributes-worker.js +2 -2
  4. package/dist/3d-tiles-attributes-worker.js.map +3 -3
  5. package/dist/converter-cli.js +14 -2
  6. package/dist/converter.min.js +22 -22
  7. package/dist/deps-installer/deps-installer.d.ts.map +1 -1
  8. package/dist/deps-installer/deps-installer.js +8 -0
  9. package/dist/dist.min.js +1407 -1242
  10. package/dist/es5/3d-tiles-attributes-worker.js +1 -1
  11. package/dist/es5/3d-tiles-attributes-worker.js.map +1 -1
  12. package/dist/es5/converter-cli.js +14 -2
  13. package/dist/es5/converter-cli.js.map +1 -1
  14. package/dist/es5/deps-installer/deps-installer.js +13 -2
  15. package/dist/es5/deps-installer/deps-installer.js.map +1 -1
  16. package/dist/es5/i3s-attributes-worker.js +1 -1
  17. package/dist/es5/i3s-attributes-worker.js.map +1 -1
  18. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  19. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +16 -7
  20. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  21. package/dist/es5/i3s-converter/helpers/geometry-converter.js +363 -113
  22. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  23. package/dist/es5/i3s-converter/helpers/gltf-attributes.js +6 -11
  24. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  25. package/dist/es5/i3s-converter/helpers/node-index-document.js +517 -0
  26. package/dist/es5/i3s-converter/helpers/node-index-document.js.map +1 -0
  27. package/dist/es5/i3s-converter/helpers/node-pages.js +455 -173
  28. package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
  29. package/dist/es5/i3s-converter/i3s-converter.js +549 -618
  30. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  31. package/dist/es5/i3s-converter/json-templates/geometry-definitions.js +107 -0
  32. package/dist/es5/i3s-converter/json-templates/geometry-definitions.js.map +1 -0
  33. package/dist/es5/i3s-converter/json-templates/layers.js +2 -93
  34. package/dist/es5/i3s-converter/json-templates/layers.js.map +1 -1
  35. package/dist/es5/i3s-converter/json-templates/shared-resources.js +3 -3
  36. package/dist/es5/i3s-converter/json-templates/shared-resources.js.map +1 -1
  37. package/dist/es5/i3s-converter/types.js.map +1 -1
  38. package/dist/es5/lib/utils/file-utils.js +93 -9
  39. package/dist/es5/lib/utils/file-utils.js.map +1 -1
  40. package/dist/es5/lib/utils/write-queue.js +38 -25
  41. package/dist/es5/lib/utils/write-queue.js.map +1 -1
  42. package/dist/es5/pgm-loader.js +1 -1
  43. package/dist/es5/pgm-loader.js.map +1 -1
  44. package/dist/es5/workers/i3s-attributes-worker.js +1 -1
  45. package/dist/es5/workers/i3s-attributes-worker.js.map +1 -1
  46. package/dist/esm/3d-tiles-attributes-worker.js +1 -1
  47. package/dist/esm/3d-tiles-attributes-worker.js.map +1 -1
  48. package/dist/esm/converter-cli.js +14 -2
  49. package/dist/esm/converter-cli.js.map +1 -1
  50. package/dist/esm/deps-installer/deps-installer.js +9 -1
  51. package/dist/esm/deps-installer/deps-installer.js.map +1 -1
  52. package/dist/esm/i3s-attributes-worker.js +1 -1
  53. package/dist/esm/i3s-attributes-worker.js.map +1 -1
  54. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  55. package/dist/esm/i3s-converter/helpers/geometry-attributes.js +16 -7
  56. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  57. package/dist/esm/i3s-converter/helpers/geometry-converter.js +150 -40
  58. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  59. package/dist/esm/i3s-converter/helpers/gltf-attributes.js +6 -9
  60. package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  61. package/dist/esm/i3s-converter/helpers/node-index-document.js +202 -0
  62. package/dist/esm/i3s-converter/helpers/node-index-document.js.map +1 -0
  63. package/dist/esm/i3s-converter/helpers/node-pages.js +162 -76
  64. package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
  65. package/dist/esm/i3s-converter/i3s-converter.js +115 -220
  66. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  67. package/dist/esm/i3s-converter/json-templates/geometry-definitions.js +89 -0
  68. package/dist/esm/i3s-converter/json-templates/geometry-definitions.js.map +1 -0
  69. package/dist/esm/i3s-converter/json-templates/layers.js +2 -85
  70. package/dist/esm/i3s-converter/json-templates/layers.js.map +1 -1
  71. package/dist/esm/i3s-converter/json-templates/shared-resources.js +3 -3
  72. package/dist/esm/i3s-converter/json-templates/shared-resources.js.map +1 -1
  73. package/dist/esm/i3s-converter/types.js.map +1 -1
  74. package/dist/esm/lib/utils/file-utils.js +44 -3
  75. package/dist/esm/lib/utils/file-utils.js.map +1 -1
  76. package/dist/esm/lib/utils/write-queue.js +19 -10
  77. package/dist/esm/lib/utils/write-queue.js.map +1 -1
  78. package/dist/esm/pgm-loader.js +1 -1
  79. package/dist/esm/pgm-loader.js.map +1 -1
  80. package/dist/esm/workers/i3s-attributes-worker.js +1 -1
  81. package/dist/esm/workers/i3s-attributes-worker.js.map +1 -1
  82. package/dist/i3s-attributes-worker.d.ts +2 -2
  83. package/dist/i3s-attributes-worker.d.ts.map +1 -1
  84. package/dist/i3s-attributes-worker.js +2 -2
  85. package/dist/i3s-attributes-worker.js.map +2 -2
  86. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +3 -3
  87. package/dist/i3s-converter/helpers/batch-ids-extensions.js +3 -3
  88. package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -1
  89. package/dist/i3s-converter/helpers/geometry-attributes.js +16 -10
  90. package/dist/i3s-converter/helpers/geometry-converter.d.ts +8 -4
  91. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  92. package/dist/i3s-converter/helpers/geometry-converter.js +200 -44
  93. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
  94. package/dist/i3s-converter/helpers/gltf-attributes.js +2 -3
  95. package/dist/i3s-converter/helpers/node-index-document.d.ts +95 -0
  96. package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -0
  97. package/dist/i3s-converter/helpers/node-index-document.js +250 -0
  98. package/dist/i3s-converter/helpers/node-pages.d.ts +78 -43
  99. package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
  100. package/dist/i3s-converter/helpers/node-pages.js +195 -94
  101. package/dist/i3s-converter/i3s-converter.d.ts +33 -58
  102. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  103. package/dist/i3s-converter/i3s-converter.js +122 -233
  104. package/dist/i3s-converter/json-templates/geometry-definitions.d.ts +7 -0
  105. package/dist/i3s-converter/json-templates/geometry-definitions.d.ts.map +1 -0
  106. package/dist/i3s-converter/json-templates/geometry-definitions.js +87 -0
  107. package/dist/i3s-converter/json-templates/layers.d.ts +1 -30
  108. package/dist/i3s-converter/json-templates/layers.d.ts.map +1 -1
  109. package/dist/i3s-converter/json-templates/layers.js +2 -86
  110. package/dist/i3s-converter/json-templates/shared-resources.js +3 -3
  111. package/dist/i3s-converter/types.d.ts +34 -8
  112. package/dist/i3s-converter/types.d.ts.map +1 -1
  113. package/dist/lib/utils/file-utils.d.ts +17 -1
  114. package/dist/lib/utils/file-utils.d.ts.map +1 -1
  115. package/dist/lib/utils/file-utils.js +64 -7
  116. package/dist/lib/utils/write-queue.d.ts +19 -3
  117. package/dist/lib/utils/write-queue.d.ts.map +1 -1
  118. package/dist/lib/utils/write-queue.js +18 -12
  119. package/dist/workers/i3s-attributes-worker.js +1 -1
  120. package/package.json +25 -20
  121. package/src/converter-cli.ts +22 -2
  122. package/src/deps-installer/deps-installer.ts +9 -0
  123. package/src/i3s-converter/helpers/batch-ids-extensions.ts +3 -3
  124. package/src/i3s-converter/helpers/geometry-attributes.ts +16 -11
  125. package/src/i3s-converter/helpers/geometry-converter.ts +217 -48
  126. package/src/i3s-converter/helpers/gltf-attributes.ts +2 -3
  127. package/src/i3s-converter/helpers/node-index-document.ts +315 -0
  128. package/src/i3s-converter/helpers/node-pages.ts +215 -110
  129. package/src/i3s-converter/i3s-converter.ts +170 -312
  130. package/src/i3s-converter/json-templates/geometry-definitions.ts +83 -0
  131. package/src/i3s-converter/json-templates/layers.ts +2 -91
  132. package/src/i3s-converter/json-templates/shared-resources.ts +3 -3
  133. package/src/i3s-converter/types.ts +29 -2
  134. package/src/lib/utils/file-utils.ts +62 -7
  135. package/src/lib/utils/write-queue.ts +36 -15
  136. package/src/workers/i3s-attributes-worker.ts +2 -1
@@ -14,15 +14,15 @@ const MATERIAL_DEFINITION_INFO_PARAMS = () => ({
14
14
  },
15
15
  ambient: {
16
16
  path: 'ambient',
17
- default: [1, 1, 1, 1]
17
+ default: [1, 1, 1]
18
18
  },
19
19
  diffuse: {
20
20
  path: 'diffuse',
21
- default: [1, 1, 1, 1]
21
+ default: [1, 1, 1]
22
22
  },
23
23
  specular: {
24
24
  path: 'specular',
25
- default: [0, 0, 0, 0]
25
+ default: [0, 0, 0]
26
26
  },
27
27
  useVertexColorAlpha: {
28
28
  path: 'useVertexColorAlpha',
@@ -1 +1 @@
1
- {"version":3,"file":"shared-resources.js","names":["transform","MATERIAL_DEFINITION_INFO_PARAMS","renderMode","path","default","shininess","reflectivity","ambient","diffuse","specular","useVertexColorAlpha","vertexRegions","vertexColors","MATERIAL_DEFINITION_INFO","name","type","params","val","thisObject","originalObject","TEXTURE_DEFINITION_IMAGE","id","size","href","length","TEXTURE_DEFINITION_INFO","encoding","wrap","atlas","uvSet","channels","images","map","image","SHARED_RESOURCES","materialDefinitions","transfromMaterialDefinitions","textureDefinitions","transfromTextureDefinitions","materialDefinitionInfos","result","index","materialDefinitionInfo","entries","nodePath","textureDefinitionInfos","textureDefinitionInfo","imageIndex"],"sources":["../../../../src/i3s-converter/json-templates/shared-resources.ts"],"sourcesContent":["import transform from 'json-map-transform';\n\nconst MATERIAL_DEFINITION_INFO_PARAMS = () => ({\n renderMode: {\n path: 'renderMode',\n default: 'solid'\n },\n shininess: {\n path: 'shininess',\n default: 1\n },\n reflectivity: {\n path: 'reflectivity',\n default: 0\n },\n ambient: {\n path: 'ambient',\n default: [1, 1, 1, 1]\n },\n diffuse: {\n path: 'diffuse',\n default: [1, 1, 1, 1]\n },\n specular: {\n path: 'specular',\n default: [0, 0, 0, 0]\n },\n useVertexColorAlpha: {\n path: 'useVertexColorAlpha',\n default: false\n },\n vertexRegions: {\n path: 'vertexRegions',\n default: false\n },\n vertexColors: {\n path: 'vertexColors',\n default: true\n }\n});\n\nconst MATERIAL_DEFINITION_INFO = () => ({\n name: {\n path: 'name',\n default: 'standard'\n },\n type: {\n path: 'type',\n default: 'standard'\n },\n params: {\n path: 'params',\n transform: (val, thisObject, originalObject) =>\n transform(originalObject, MATERIAL_DEFINITION_INFO_PARAMS())\n }\n});\n\nconst TEXTURE_DEFINITION_IMAGE = () => ({\n id: {\n path: 'id'\n },\n size: {\n path: 'size'\n },\n href: {\n path: 'href',\n default: ['../textures/0']\n },\n length: {\n path: 'length'\n }\n});\n\nconst TEXTURE_DEFINITION_INFO = () => ({\n encoding: {\n path: 'encoding'\n },\n wrap: {\n path: 'wrap',\n default: ['none']\n },\n atlas: {\n path: 'atlas',\n default: false\n },\n uvSet: {\n path: 'uvSet',\n default: 'uv0'\n },\n channels: {\n path: 'channels',\n default: 'rgb'\n },\n images: {\n path: 'images',\n transform: (val, thisObject, originalObject) =>\n val.map((image) => transform(image, TEXTURE_DEFINITION_IMAGE()))\n }\n});\n\nexport const SHARED_RESOURCES = () => ({\n materialDefinitions: {\n path: 'materialDefinitionInfos',\n transform: transfromMaterialDefinitions\n },\n textureDefinitions: {\n path: 'textureDefinitionInfos',\n transform: transfromTextureDefinitions\n }\n});\n\nfunction transfromMaterialDefinitions(materialDefinitionInfos, thisObject, originalObject) {\n const result = {};\n for (const [index, materialDefinitionInfo] of materialDefinitionInfos.entries()) {\n result[`Mat${originalObject.nodePath}${index}`] = transform(\n materialDefinitionInfo,\n MATERIAL_DEFINITION_INFO()\n );\n }\n return result;\n}\n\nfunction transfromTextureDefinitions(textureDefinitionInfos, thisObject, originalObject) {\n if (!textureDefinitionInfos) {\n return null;\n }\n const result = {};\n for (const [index, textureDefinitionInfo] of textureDefinitionInfos.entries()) {\n const imageIndex = `${originalObject.nodePath}${index}`;\n textureDefinitionInfo.imageIndex = imageIndex;\n result[imageIndex] = transform(textureDefinitionInfo, TEXTURE_DEFINITION_INFO());\n }\n return result;\n}\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,oBAAoB;AAE1C,MAAMC,+BAA+B,GAAG,OAAO;EAC7CC,UAAU,EAAE;IACVC,IAAI,EAAE,YAAY;IAClBC,OAAO,EAAE;EACX,CAAC;EACDC,SAAS,EAAE;IACTF,IAAI,EAAE,WAAW;IACjBC,OAAO,EAAE;EACX,CAAC;EACDE,YAAY,EAAE;IACZH,IAAI,EAAE,cAAc;IACpBC,OAAO,EAAE;EACX,CAAC;EACDG,OAAO,EAAE;IACPJ,IAAI,EAAE,SAAS;IACfC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;EACtB,CAAC;EACDI,OAAO,EAAE;IACPL,IAAI,EAAE,SAAS;IACfC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;EACtB,CAAC;EACDK,QAAQ,EAAE;IACRN,IAAI,EAAE,UAAU;IAChBC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;EACtB,CAAC;EACDM,mBAAmB,EAAE;IACnBP,IAAI,EAAE,qBAAqB;IAC3BC,OAAO,EAAE;EACX,CAAC;EACDO,aAAa,EAAE;IACbR,IAAI,EAAE,eAAe;IACrBC,OA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AMS","renderMode","path","default","shininess","reflectivity","ambient","diffuse","specular","useVertexColorAlpha","vertexRegions","vertexColors","MATERIAL_DEFINITION_INFO","name","type","params","val","thisObject","originalObject","TEXTURE_DEFINITION_IMAGE","id","size","href","length","TEXTURE_DEFINITION_INFO","encoding","wrap","atlas","uvSet","channels","images","map","image","SHARED_RESOURCES","materialDefinitions","transfromMaterialDefinitions","textureDefinitions","transfromTextureDefinitions","materialDefinitionInfos","result","index","materialDefinitionInfo","entries","nodePath","textureDefinitionInfos","textureDefinitionInfo","imageIndex"],"sources":["../../../../src/i3s-converter/json-templates/shared-resources.ts"],"sourcesContent":["import transform from 'json-map-transform';\n\nconst MATERIAL_DEFINITION_INFO_PARAMS = () => ({\n renderMode: {\n path: 'renderMode',\n default: 'solid'\n },\n shininess: {\n path: 'shininess',\n default: 1\n },\n reflectivity: {\n path: 'reflectivity',\n default: 0\n },\n ambient: {\n path: 'ambient',\n default: [1, 1, 1]\n },\n diffuse: {\n path: 'diffuse',\n default: [1, 1, 1]\n },\n specular: {\n path: 'specular',\n default: [0, 0, 0]\n },\n useVertexColorAlpha: {\n path: 'useVertexColorAlpha',\n default: false\n },\n vertexRegions: {\n path: 'vertexRegions',\n default: false\n },\n vertexColors: {\n path: 'vertexColors',\n default: true\n }\n});\n\nconst MATERIAL_DEFINITION_INFO = () => ({\n name: {\n path: 'name',\n default: 'standard'\n },\n type: {\n path: 'type',\n default: 'standard'\n },\n params: {\n path: 'params',\n transform: (val, thisObject, originalObject) =>\n transform(originalObject, MATERIAL_DEFINITION_INFO_PARAMS())\n }\n});\n\nconst TEXTURE_DEFINITION_IMAGE = () => ({\n id: {\n path: 'id'\n },\n size: {\n path: 'size'\n },\n href: {\n path: 'href',\n default: ['../textures/0']\n },\n length: {\n path: 'length'\n }\n});\n\nconst TEXTURE_DEFINITION_INFO = () => ({\n encoding: {\n path: 'encoding'\n },\n wrap: {\n path: 'wrap',\n default: ['none']\n },\n atlas: {\n path: 'atlas',\n default: false\n },\n uvSet: {\n path: 'uvSet',\n default: 'uv0'\n },\n channels: {\n path: 'channels',\n default: 'rgb'\n },\n images: {\n path: 'images',\n transform: (val, thisObject, originalObject) =>\n val.map((image) => transform(image, TEXTURE_DEFINITION_IMAGE()))\n }\n});\n\nexport const SHARED_RESOURCES = () => ({\n materialDefinitions: {\n path: 'materialDefinitionInfos',\n transform: transfromMaterialDefinitions\n },\n textureDefinitions: {\n path: 'textureDefinitionInfos',\n transform: transfromTextureDefinitions\n }\n});\n\nfunction transfromMaterialDefinitions(materialDefinitionInfos, thisObject, originalObject) {\n const result = {};\n for (const [index, materialDefinitionInfo] of materialDefinitionInfos.entries()) {\n result[`Mat${originalObject.nodePath}${index}`] = transform(\n materialDefinitionInfo,\n MATERIAL_DEFINITION_INFO()\n );\n }\n return result;\n}\n\nfunction transfromTextureDefinitions(textureDefinitionInfos, thisObject, originalObject) {\n if (!textureDefinitionInfos) {\n return null;\n }\n const result = {};\n for (const [index, textureDefinitionInfo] of textureDefinitionInfos.entries()) {\n const imageIndex = `${originalObject.nodePath}${index}`;\n textureDefinitionInfo.imageIndex = imageIndex;\n result[imageIndex] = transform(textureDefinitionInfo, TEXTURE_DEFINITION_INFO());\n }\n return result;\n}\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,oBAAoB;AAE1C,MAAMC,+BAA+B,GAAG,OAAO;EAC7CC,UAAU,EAAE;IACVC,IAAI,EAAE,YAAY;IAClBC,OAAO,EAAE;EACX,CAAC;EACDC,SAAS,EAAE;IACTF,IAAI,EAAE,WAAW;IACjBC,OAAO,EAAE;EACX,CAAC;EACDE,YAAY,EAAE;IACZH,IAAI,EAAE,cAAc;IACpBC,OAAO,EAAE;EACX,CAAC;EACDG,OAAO,EAAE;IACPJ,IAAI,EAAE,SAAS;IACfC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;EACnB,CAAC;EACDI,OAAO,EAAE;IACPL,IAAI,EAAE,SAAS;IACfC,OAAO,EAAE,CAAC,CAA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AMI,UAAU,aAAM5B,cAAc,CAACyB,QAAQ,SAAGH,KAAK,CAAE;IACvDK,qBAAqB,CAACC,UAAU,GAAGA,UAAU;IAC7CP,MAAM,CAACO,UAAU,CAAC,GAAG/C,SAAS,CAAC8C,qBAAqB,EAAErB,uBAAuB,EAAE,CAAC;EAClF;EACA,OAAOe,MAAM;AACf"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../src/i3s-converter/types.ts"],"sourcesContent":["import {\n BoundingVolumes,\n I3SMaterialDefinition,\n MaterialDefinitionInfo,\n TextureDefinitionInfo\n} from '@loaders.gl/i3s';\nimport {ImageDataType} from '@loaders.gl/images';\n\n/** Converted resources for specific node */\nexport type I3SConvertedResources = {\n /**\n * Node id\n */\n nodeId?: number;\n /** Non-compressed geometry buffer that have structure met\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.8/defaultGeometrySchema.cmn.md\n * (Geometry buffer)\n */\n geometry: ArrayBuffer | null;\n /**\n * Draco compressed geometry\n */\n compressedGeometry?: Promise<ArrayBuffer> | null;\n /**\n * Texture image content\n */\n texture: any | null;\n /**\n * Shared resources built from GLTF material\n */\n sharedResources: SharedResourcesArrays | null;\n /**\n * Material definition of the node\n */\n meshMaterial?: I3SMaterialDefinition | null;\n /**\n * Number of vertices in the node\n */\n vertexCount: number | null;\n /**\n * Feature attributes contents\n */\n attributes: ArrayBuffer[] | null;\n /**\n * Number of features in the node\n */\n featureCount: number | null;\n /**\n * MBS and/or OBB bounding volumes of the node\n */\n boundingVolumes: BoundingVolumes | null;\n};\n\n/**\n * Geometry and feature attributes converted from GLTF primitives\n */\nexport type ConvertedAttributes = {\n /** POSITION attribute value */\n positions: Float32Array;\n /** NORMAL attribute value */\n normals: Float32Array;\n /** TEXCOORD_0 attribute value */\n texCoords: Float32Array;\n /** COLOR_0 attribute value */\n colors: Uint8Array;\n /** Feature indices grouped by ...\n * converted from \"batch ids\" of GLTF\n */\n featureIndicesGroups?: number[][];\n /** Feature indices converted from \"batch ids\" */\n featureIndices: number[];\n /**\n * MBS and/or OBB bounding volumes of the node\n */\n boundingVolumes: null | BoundingVolumes;\n};\n\n/** Postprocessed geometry and feature attributes\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.8/defaultGeometrySchema.cmn.md\n */\nexport type GeometryAttributes = {\n /** POSITION attribute value */\n positions: Float32Array;\n /** NORMAL attribute value */\n normals: Float32Array;\n /** TEXCOORD_0 attribute value */\n texCoords: Float32Array;\n /** COLOR_0 attribute value */\n colors: Uint8Array;\n /** faceRanges attribute value */\n faceRange: Uint32Array;\n /** feature Ids attribute value */\n featureIds: number[];\n /** number of features in the node */\n featureCount: number;\n};\n\n/** Geometry attributes specific for the particular feature */\nexport type GroupedByFeatureIdAttributes = {\n /** Feature Id */\n featureId: number;\n /** POSITION attribute value */\n positions: Float32Array;\n /** NORMAL attribute value */\n normals: Float32Array;\n /** COLOR_0 attribute value */\n colors: Uint8Array;\n /** TEXCOORD_0 attribute value */\n texCoords: Float32Array;\n};\n\n/** Shared resources made from GLTF material */\nexport type SharedResourcesArrays = {\n /** material definitions list https://github.com/Esri/i3s-spec/blob/master/docs/1.8/materialDefinitionInfo.cmn.md */\n materialDefinitionInfos?: MaterialDefinitionInfo[];\n /** texture definitions list https://github.com/Esri/i3s-spec/blob/master/docs/1.8/textureDefinitionInfo.cmn.md*/\n textureDefinitionInfos?: TextureDefinitionInfo[];\n /** node id to make unique SharedResource ids */\n nodePath?: string;\n};\n\n/** I3S material definition and texture content taken from GLTF material */\nexport type I3SMaterialWithTexture = {\n /** Material definition https://github.com/Esri/i3s-spec/blob/master/docs/1.8/materialDefinitions.cmn.md */\n material: I3SMaterialDefinition;\n /** Texture content (image) */\n texture?: ImageDataType;\n};\n"],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../src/i3s-converter/types.ts"],"sourcesContent":["import {GLTFImagePostprocessed} from '@loaders.gl/gltf';\nimport {\n BoundingVolumes,\n I3SMaterialDefinition,\n MaterialDefinitionInfo,\n TextureDefinitionInfo\n} from '@loaders.gl/i3s';\n\n/** Converted resources for specific node */\nexport type I3SConvertedResources = {\n /**\n * Node id\n */\n nodeId?: number;\n /** Non-compressed geometry buffer that have structure met\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.8/defaultGeometrySchema.cmn.md\n * (Geometry buffer)\n */\n geometry: ArrayBuffer | null;\n /**\n * Draco compressed geometry\n */\n compressedGeometry?: Promise<ArrayBuffer> | null;\n /**\n * Texture image content\n */\n texture: any | null;\n /**\n * If the resource has uvRegions geometry attribute\n */\n hasUvRegions: boolean;\n /**\n * Shared resources built from GLTF material\n */\n sharedResources: SharedResourcesArrays | null;\n /**\n * Material definition of the node\n */\n meshMaterial?: I3SMaterialDefinition | null;\n /**\n * Number of vertices in the node\n */\n vertexCount: number | null;\n /**\n * Feature attributes contents\n */\n attributes: ArrayBuffer[] | null;\n /**\n * Number of features in the node\n */\n featureCount: number | null;\n /**\n * MBS and/or OBB bounding volumes of the node\n */\n boundingVolumes: BoundingVolumes | null;\n};\n\n/**\n * Geometry and feature attributes converted from GLTF primitives\n */\nexport type ConvertedAttributes = {\n /** POSITION attribute value */\n positions: Float32Array;\n /** NORMAL attribute value */\n normals: Float32Array;\n /** TEXCOORD_0 attribute value */\n texCoords: Float32Array;\n /** COLOR_0 attribute value */\n colors: Uint8Array;\n /** uvRegion attribute for a texture atlas */\n uvRegions: Uint16Array;\n /** Feature indices grouped by ...\n * converted from \"batch ids\" of GLTF\n */\n featureIndicesGroups?: number[][];\n /** Feature indices converted from \"batch ids\" */\n featureIndices: number[];\n /**\n * MBS and/or OBB bounding volumes of the node\n */\n boundingVolumes: null | BoundingVolumes;\n /** merged materials data */\n mergedMaterials: MergedMaterial[];\n};\n\n/** Postprocessed geometry and feature attributes\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.8/defaultGeometrySchema.cmn.md\n */\nexport type GeometryAttributes = {\n /** POSITION attribute value */\n positions: Float32Array;\n /** NORMAL attribute value */\n normals: Float32Array;\n /** TEXCOORD_0 attribute value */\n texCoords: Float32Array;\n /** COLOR_0 attribute value */\n colors: Uint8Array;\n /** uvRegion attribute for a texture atlas */\n uvRegions: Uint16Array;\n /** faceRanges attribute value */\n faceRange: Uint32Array;\n /** feature Ids attribute value */\n featureIds: number[];\n /** number of features in the node */\n featureCount: number;\n};\n\n/** Geometry attributes specific for the particular feature */\nexport type GroupedByFeatureIdAttributes = {\n /** Feature Id */\n featureId: number;\n /** POSITION attribute value */\n positions: Float32Array;\n /** NORMAL attribute value */\n normals: Float32Array;\n /** COLOR_0 attribute value */\n colors: Uint8Array;\n /** uvRegion attribute for a texture atlas */\n uvRegions: Uint16Array;\n /** TEXCOORD_0 attribute value */\n texCoords: Float32Array;\n};\n\n/** Shared resources made from GLTF material */\nexport type SharedResourcesArrays = {\n /** material definitions list https://github.com/Esri/i3s-spec/blob/master/docs/1.8/materialDefinitionInfo.cmn.md */\n materialDefinitionInfos?: MaterialDefinitionInfo[];\n /** texture definitions list https://github.com/Esri/i3s-spec/blob/master/docs/1.8/textureDefinitionInfo.cmn.md*/\n textureDefinitionInfos?: TextureDefinitionInfo[];\n /** node id to make unique SharedResource ids */\n nodePath?: string;\n};\n\n/** I3S material definition and texture content taken from GLTF material */\nexport type I3SMaterialWithTexture = {\n /** Material definition https://github.com/Esri/i3s-spec/blob/master/docs/1.8/materialDefinitions.cmn.md */\n material: I3SMaterialDefinition;\n /** Texture content (image) */\n texture?: GLTFImagePostprocessed;\n /** Metadata of all merged materials */\n mergedMaterials: MergedMaterial[];\n};\n\n/** Metadata of some original texture */\nexport type MergedMaterial = {\n /** Gltf material Id */\n originalMaterialId: string;\n /** Original texture size */\n textureSize?: {\n width: number;\n height: number;\n };\n /** Uint16Array of 4 elements https://github.com/Esri/i3s-spec/blob/master/docs/1.7/geometryUVRegion.cmn.md */\n uvRegion?: Uint16Array;\n};\n"],"mappings":""}
@@ -1,3 +1,5 @@
1
+ import { load } from '@loaders.gl/core';
2
+ import { JSONLoader } from '@loaders.gl/loader-utils';
1
3
  import { promises as fs } from 'fs';
2
4
  import { isAbsolute, join } from 'path';
3
5
  import { compressFileWithGzip } from './compress-util';
@@ -28,15 +30,54 @@ export async function writeFile(path, data) {
28
30
  export async function writeFileForSlpk(path, data) {
29
31
  let fileName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'index.json';
30
32
  let compress = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
33
+ let compressList = arguments.length > 4 ? arguments[4] : undefined;
31
34
  const pathFile = await writeFile(path, data, fileName);
32
35
  if (compress) {
33
- const pathGzFile = await compressFileWithGzip(pathFile);
34
- await removeFile(pathFile);
35
- return pathGzFile;
36
+ if (compressList) {
37
+ if (!compressList.includes(pathFile)) {
38
+ compressList.push(pathFile);
39
+ return "".concat(pathFile, ".gz");
40
+ } else {
41
+ return null;
42
+ }
43
+ } else {
44
+ const pathGzFile = await compressFileWithGzip(pathFile);
45
+ await removeFile(pathFile);
46
+ return pathGzFile;
47
+ }
36
48
  }
37
49
  return pathFile;
38
50
  }
39
51
 
52
+ export async function openJson(path, fileName) {
53
+ return new Promise((resolve, reject) => {
54
+ let count = 0;
55
+ console.log("load ".concat(path, "/").concat(fileName, "."));
56
+ const intervalId = setInterval(() => {
57
+ const pathFile = join(path, fileName);
58
+ load(pathFile, JSONLoader).then(result => {
59
+ clearInterval(intervalId);
60
+ resolve(result);
61
+ }).catch(() => {
62
+ count++;
63
+ if (count > 100) {
64
+ clearInterval(intervalId);
65
+ reject(new Error("Cannon load ".concat(path, "/").concat(fileName, ".")));
66
+ }
67
+ });
68
+ }, 200);
69
+ });
70
+ }
71
+
72
+ export async function isFileExists(fileName) {
73
+ try {
74
+ await fs.stat(fileName);
75
+ return true;
76
+ } catch {
77
+ return false;
78
+ }
79
+ }
80
+
40
81
  export function removeDir(path) {
41
82
  return fs.rmdir(path, {
42
83
  recursive: true
@@ -1 +1 @@
1
- {"version":3,"file":"file-utils.js","names":["promises","fs","isAbsolute","join","compressFileWithGzip","writeFile","path","data","fileName","toWriteData","Promise","Uint8Array","ArrayBuffer","mkdir","recursive","pathFile","err","console","log","writeFileForSlpk","compress","pathGzFile","removeFile","removeDir","rmdir","unlink","getAbsoluteFilePath","filePath","process","cwd"],"sources":["../../../../src/lib/utils/file-utils.ts"],"sourcesContent":["import {promises as fs} from 'fs';\nimport {isAbsolute, join} from 'path';\nimport {compressFileWithGzip} from './compress-util';\n\n/**\n * Write a file with data and name fileName to path\n *\n * @param path - output path\n * @param data - file content\n * @param fileName - name of output file (default: index.json)\n */\nexport async function writeFile(\n path: string,\n data: string | Uint8Array | ArrayBuffer | Promise<ArrayBuffer>,\n fileName: string = 'index.json'\n): Promise<string> {\n let toWriteData: string | Uint8Array;\n if (data instanceof Promise) {\n toWriteData = new Uint8Array(await data);\n } else if (data instanceof ArrayBuffer) {\n toWriteData = new Uint8Array(data as ArrayBuffer);\n } else {\n toWriteData = data;\n }\n await fs.mkdir(path, {recursive: true});\n const pathFile = join(path, fileName);\n try {\n await fs.writeFile(pathFile, toWriteData);\n } catch (err) {\n throw err;\n }\n console.log(`${pathFile} saved.`); // eslint-disable-line\n return pathFile;\n}\n\n/**\n * Write a file with data and name fileName to path - specific one for further packaging into slpk\n *\n * @param path - output path\n * @param data - file content\n * @param fileName - name of output file (default: index.json)\n * @param compress - if need to compress file with gzip (default: true)\n */\nexport async function writeFileForSlpk(\n path: string,\n data: string | Uint8Array | ArrayBuffer | Promise<ArrayBuffer>,\n fileName: string = 'index.json',\n compress: boolean = true\n): Promise<string> {\n const pathFile = await writeFile(path, data, fileName);\n if (compress) {\n const pathGzFile = await compressFileWithGzip(pathFile);\n // After compression, we don't need an uncompressed file\n await removeFile(pathFile);\n return pathGzFile;\n }\n return pathFile;\n}\n\n/**\n * Remove dir with path\n *\n * @param path\n */\nexport function removeDir(path: string) {\n return fs.rmdir(path, {recursive: true});\n}\n\n/**\n * Remove file with path\n *\n * @param path\n */\nexport function removeFile(path: string) {\n return fs.unlink(path);\n}\n\n/**\n * Generates absolute file path\n * @param filePath\n */\nexport function getAbsoluteFilePath(filePath: string) {\n return isAbsolute(filePath) ? filePath : join(process.cwd(), filePath); // eslint-disable-line no-undef\n}\n"],"mappings":"AAAA,SAAQA,QAAQ,IAAIC,EAAE,QAAO,IAAI;AACjC,SAAQC,UAAU,EAAEC,IAAI,QAAO,MAAM;AACrC,SAAQC,oBAAoB,QAAO,iBAAiB;;AASpD,OAAO,eAAeC,SAAS,CAC7BC,IAAY,EACZC,IAA8D,EAE7C;EAAA,IADjBC,QAAgB,uEAAG,YAAY;EAE/B,IAAIC,WAAgC;EACpC,IAAIF,IAAI,YAAYG,OAAO,EAAE;IAC3BD,WAAW,GAAG,IAAIE,UAAU,CAAC,MAAMJ,IAAI,CAAC;EAC1C,CAAC,MAAM,IAAIA,IAAI,YAAYK,WAAW,EAAE;IACtCH,WAAW,GAAG,IAAIE,UAAU,CAACJ,IAAI,CAAgB;EACnD,CAAC,MAAM;IACLE,WAAW,GAAGF,IAAI;EACpB;EACA,MAAMN,EAAE,CAACY,KAAK,CAACP,IAAI,EAAE;IAACQ,SAAS,EAAE;EAAI,CAAC,CAAC;EACvC,MAAMC,QAAQ,GAAGZ,IAAI,CAACG,IAAI,EAAEE,QAAQ,CAAC;EACrC,IAAI;IACF,MAAMP,EAAE,CAACI,SAAS,CAACU,QAAQ,EAAEN,WAAW,CAAC;EAC3C,CAAC,CAAC,OAAOO,GAAG,EAAE;IACZ,MAAMA,GAAG;EACX;EACAC,OAAO,CAACC,GAAG,WAAIH,QAAQ,aAAU;EACjC,OAAOA,QAAQ;AACjB;;AAUA,OAAO,eAAeI,gBAAgB,CACpCb,IAAY,EACZC,IAA8D,EAG7C;EAAA,IAFjBC,QAAgB,uEAAG,YAAY;EAAA,IAC/BY,QAAiB,uEAAG,IAAI;EAExB,MAAML,QAAQ,GAAG,MAAMV,SAAS,CAACC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,CAAC;EACtD,IAAIY,QAAQ,EAAE;IACZ,MAAMC,UAAU,GAAG,MAAMjB,oBAAoB,CAACW,QAAQ,CAAC;IAEvD,MAAMO,UAAU,CAACP,QAAQ,CAAC;IAC1B,OAAOM,UAAU;EACnB;EACA,OAAON,QAAQ;AACjB;;AAOA,OAAO,SAASQ,SAAS,CAACjB,IAAY,EAAE;EACtC,OAAOL,EAAE,CAACuB,KAAK,CAAClB,IAAI,EAAE;IAACQ,SAAS,EAAE;EAAI,CAAC,CAAC;AAC1C;;AAOA,OAAO,SAASQ,UAAU,CAAChB,IAAY,EAAE;EACvC,OAAOL,EAAE,CAACwB,MAAM,CAACnB,IAAI,CAAC;AACxB;;AAMA,OAAO,SAASoB,mBAAmB,CAACC,QAAgB,EAAE;EACpD,OAAOzB,UAAU,CAACyB,QAAQ,CAAC,GAAGA,QAAQ,GAAGxB,IAAI,CAACyB,OAAO,CAACC,GAAG,EAAE,EAAEF,QAAQ,CAAC;AACxE"}
1
+ {"version":3,"file":"file-utils.js","names":["load","JSONLoader","promises","fs","isAbsolute","join","compressFileWithGzip","writeFile","path","data","fileName","toWriteData","Promise","Uint8Array","ArrayBuffer","mkdir","recursive","pathFile","err","console","log","writeFileForSlpk","compress","compressList","includes","push","pathGzFile","removeFile","openJson","resolve","reject","count","intervalId","setInterval","then","result","clearInterval","catch","Error","isFileExists","stat","removeDir","rmdir","unlink","getAbsoluteFilePath","filePath","process","cwd"],"sources":["../../../../src/lib/utils/file-utils.ts"],"sourcesContent":["import {load} from '@loaders.gl/core';\nimport {JSONLoader} from '@loaders.gl/loader-utils';\nimport {promises as fs} from 'fs';\nimport {isAbsolute, join} from 'path';\nimport {compressFileWithGzip} from './compress-util';\n\n/**\n * Write a file with data and name fileName to path\n *\n * @param path - output path\n * @param data - file content\n * @param fileName - name of output file (default: index.json)\n */\nexport async function writeFile(\n path: string,\n data: string | Uint8Array | ArrayBuffer | Promise<ArrayBuffer>,\n fileName: string = 'index.json'\n): Promise<string> {\n let toWriteData: string | Uint8Array;\n if (data instanceof Promise) {\n toWriteData = new Uint8Array(await data);\n } else if (data instanceof ArrayBuffer) {\n toWriteData = new Uint8Array(data as ArrayBuffer);\n } else {\n toWriteData = data;\n }\n await fs.mkdir(path, {recursive: true});\n const pathFile = join(path, fileName);\n try {\n await fs.writeFile(pathFile, toWriteData);\n } catch (err) {\n throw err;\n }\n console.log(`${pathFile} saved.`); // eslint-disable-line\n return pathFile;\n}\n\n/**\n * Write a file with data and name fileName to path - specific one for further packaging into slpk\n *\n * @param path - output path\n * @param data - file content\n * @param fileName - name of output file (default: index.json)\n * @param compress - if need to compress file with gzip (default: true)\n * @param compressList - if set - the file should be added to this list and compressed in the end of conversion\n */\nexport async function writeFileForSlpk(\n path: string,\n data: string | Uint8Array | ArrayBuffer | Promise<ArrayBuffer>,\n fileName: string = 'index.json',\n compress: boolean = true,\n compressList?: string[] | null\n): Promise<string | null> {\n const pathFile = await writeFile(path, data, fileName);\n if (compress) {\n if (compressList) {\n if (!compressList.includes(pathFile)) {\n compressList.push(pathFile);\n return `${pathFile}.gz`;\n } else {\n return null;\n }\n } else {\n const pathGzFile = await compressFileWithGzip(pathFile);\n // After compression, we don't need an uncompressed file\n await removeFile(pathFile);\n return pathGzFile;\n }\n }\n return pathFile;\n}\n\n/**\n * Open json file\n * @param path - path to the file\n * @param fileName - file name\n * @returns object\n */\nexport async function openJson(path: string, fileName: string): Promise<{[key: string]: any}> {\n return new Promise((resolve, reject) => {\n let count = 0;\n console.log(`load ${path}/${fileName}.`); // eslint-disable-line\n const intervalId = setInterval(() => {\n const pathFile = join(path, fileName);\n load(pathFile, JSONLoader)\n .then((result) => {\n clearInterval(intervalId);\n resolve(result);\n })\n .catch(() => {\n count++;\n if (count > 100) {\n clearInterval(intervalId);\n reject(new Error(`Cannon load ${path}/${fileName}.`));\n }\n });\n }, 200);\n });\n}\n\n/**\n * Check if the file exists\n * @param fileName - full name of file\n * @returns true if file exists, otherwise - false\n */\nexport async function isFileExists(fileName: string): Promise<boolean> {\n try {\n await fs.stat(fileName);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Remove dir with path\n *\n * @param path\n */\nexport function removeDir(path: string) {\n return fs.rmdir(path, {recursive: true});\n}\n\n/**\n * Remove file with path\n *\n * @param path\n */\nexport function removeFile(path: string) {\n return fs.unlink(path);\n}\n\n/**\n * Generates absolute file path\n * @param filePath\n */\nexport function getAbsoluteFilePath(filePath: string) {\n return isAbsolute(filePath) ? filePath : join(process.cwd(), filePath);\n}\n"],"mappings":"AAAA,SAAQA,IAAI,QAAO,kBAAkB;AACrC,SAAQC,UAAU,QAAO,0BAA0B;AACnD,SAAQC,QAAQ,IAAIC,EAAE,QAAO,IAAI;AACjC,SAAQC,UAAU,EAAEC,IAAI,QAAO,MAAM;AACrC,SAAQC,oBAAoB,QAAO,iBAAiB;;AASpD,OAAO,eAAeC,SAAS,CAC7BC,IAAY,EACZC,IAA8D,EAE7C;EAAA,IADjBC,QAAgB,uEAAG,YAAY;EAE/B,IAAIC,WAAgC;EACpC,IAAIF,IAAI,YAAYG,OAAO,EAAE;IAC3BD,WAAW,GAAG,IAAIE,UAAU,CAAC,MAAMJ,IAAI,CAAC;EAC1C,CAAC,MAAM,IAAIA,IAAI,YAAYK,WAAW,EAAE;IACtCH,WAAW,GAAG,IAAIE,UAAU,CAACJ,IAAI,CAAgB;EACnD,CAAC,MAAM;IACLE,WAAW,GAAGF,IAAI;EACpB;EACA,MAAMN,EAAE,CAACY,KAAK,CAACP,IAAI,EAAE;IAACQ,SAAS,EAAE;EAAI,CAAC,CAAC;EACvC,MAAMC,QAAQ,GAAGZ,IAAI,CAACG,IAAI,EAAEE,QAAQ,CAAC;EACrC,IAAI;IACF,MAAMP,EAAE,CAACI,SAAS,CAACU,QAAQ,EAAEN,WAAW,CAAC;EAC3C,CAAC,CAAC,OAAOO,GAAG,EAAE;IACZ,MAAMA,GAAG;EACX;EACAC,OAAO,CAACC,GAAG,WAAIH,QAAQ,aAAU;EACjC,OAAOA,QAAQ;AACjB;;AA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AC;UACzBF,MAAM,CAAC,IAAIQ,KAAK,uBAAgB9B,IAAI,cAAIE,QAAQ,OAAI,CAAC;QACvD;MACF,CAAC,CAAC;IACN,CAAC,EAAE,GAAG,CAAC;EACT,CAAC,CAAC;AACJ;;AAOA,OAAO,eAAe6B,YAAY,CAAC7B,QAAgB,EAAoB;EACrE,IAAI;IACF,MAAMP,EAAE,CAACqC,IAAI,CAAC9B,QAAQ,CAAC;IACvB,OAAO,IAAI;EACb,CAAC,CAAC,MAAM;IACN,OAAO,KAAK;EACd;AACF;;AAOA,OAAO,SAAS+B,SAAS,CAACjC,IAAY,EAAE;EACtC,OAAOL,EAAE,CAACuC,KAAK,CAAClC,IAAI,EAAE;IAACQ,SAAS,EAAE;EAAI,CAAC,CAAC;AAC1C;;AAOA,OAAO,SAASW,UAAU,CAACnB,IAAY,EAAE;EACvC,OAAOL,EAAE,CAACwC,MAAM,CAACnC,IAAI,CAAC;AACxB;;AAMA,OAAO,SAASoC,mBAAmB,CAACC,QAAgB,EAAE;EACpD,OAAOzC,UAAU,CAACyC,QAAQ,CAAC,GAAGA,QAAQ,GAAGxC,IAAI,CAACyC,OAAO,CAACC,GAAG,EAAE,EAAEF,QAAQ,CAAC;AACxE"}
@@ -18,9 +18,21 @@ export default class WriteQueue extends Queue {
18
18
  this.writeConcurrency = writeConcurrency;
19
19
  }
20
20
  async enqueue(val) {
21
- super.enqueue(val);
22
- if (process.memoryUsage().rss > MEMORY_LIMIT) {
23
- await this.startWrite();
21
+ let writeImmediately = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
22
+ if (writeImmediately) {
23
+ const {
24
+ archiveKey,
25
+ writePromise
26
+ } = val;
27
+ const result = await writePromise();
28
+ if (archiveKey && result) {
29
+ this.fileMap[archiveKey] = result;
30
+ }
31
+ } else {
32
+ super.enqueue(val);
33
+ if (process.memoryUsage().rss > MEMORY_LIMIT) {
34
+ await this.startWrite();
35
+ }
24
36
  }
25
37
  }
26
38
  startListening() {
@@ -32,12 +44,9 @@ export default class WriteQueue extends Queue {
32
44
  }
33
45
  }
34
46
  async startWrite() {
35
- if (this.writePromise) {
36
- await this.writePromise;
37
- this.writePromise = null;
38
- return;
47
+ if (!this.writePromise) {
48
+ this.writePromise = this.doWrite();
39
49
  }
40
- this.writePromise = this.doWrite();
41
50
  await this.writePromise;
42
51
  this.writePromise = null;
43
52
  }
@@ -59,12 +68,12 @@ export default class WriteQueue extends Queue {
59
68
  writePromise
60
69
  } = item;
61
70
  archiveKeys.push(archiveKey);
62
- promises.push(writePromise);
71
+ const promise = writePromise();
72
+ promises.push(promise);
63
73
  }
64
74
  const writeResults = await Promise.allSettled(promises);
65
75
  this.updateFileMap(archiveKeys, writeResults);
66
76
  }
67
- this.writePromise = null;
68
77
  }
69
78
  updateFileMap(archiveKeys, writeResults) {
70
79
  for (let i = 0; i < archiveKeys.length; i++) {
@@ -1 +1 @@
1
- {"version":3,"file":"write-queue.js","names":["Queue","process","MEMORY_LIMIT","WriteQueue","constructor","listeningInterval","writeConcurrency","enqueue","val","memoryUsage","rss","startWrite","startListening","intervalId","setInterval","bind","stopListening","clearInterval","writePromise","doWrite","finalize","length","promises","archiveKeys","i","item","dequeue","archiveKey","push","writeResults","Promise","allSettled","updateFileMap","fileMap","value"],"sources":["../../../../src/lib/utils/write-queue.ts"],"sourcesContent":["import {Queue} from './queue';\nimport process from 'process';\n\n/** Memory limit size is based on testing */\nconst MEMORY_LIMIT = 4 * 1024 * 1024 * 1024; // 4GB\n\nexport type WriteQueueItem = {\n archiveKey?: string;\n writePromise: Promise<string>;\n};\n\nexport default class WriteQueue<T extends WriteQueueItem> extends Queue<T> {\n private intervalId?: NodeJS.Timeout;\n public writePromise: Promise<void> | null = null;\n public fileMap: {[key: string]: string} = {};\n public listeningInterval: number;\n public writeConcurrency: number;\n\n constructor(listeningInterval: number = 2000, writeConcurrency: number = 400) {\n super();\n this.listeningInterval = listeningInterval;\n this.writeConcurrency = writeConcurrency;\n }\n\n async enqueue(val: T) {\n super.enqueue(val);\n /** https://nodejs.org/docs/latest-v14.x/api/process.html#process_process_memoryusage */\n if (process.memoryUsage().rss > MEMORY_LIMIT) {\n await this.startWrite();\n }\n }\n\n startListening() {\n this.intervalId = setInterval(this.startWrite.bind(this), this.listeningInterval);\n }\n\n stopListening() {\n if (this.intervalId) {\n clearInterval(this.intervalId);\n }\n }\n\n async startWrite(): Promise<void> {\n if (this.writePromise) {\n await this.writePromise;\n this.writePromise = null;\n return;\n }\n this.writePromise = this.doWrite();\n await this.writePromise;\n this.writePromise = null;\n }\n\n async finalize(): Promise<void> {\n this.stopListening();\n await this.startWrite();\n }\n\n private async doWrite(): Promise<void> {\n while (this.length) {\n const promises: Promise<string>[] = [];\n const archiveKeys: (string | undefined)[] = [];\n for (let i = 0; i < this.writeConcurrency; i++) {\n const item = this.dequeue();\n if (!item) {\n break;\n }\n const {archiveKey, writePromise} = item as WriteQueueItem;\n archiveKeys.push(archiveKey);\n promises.push(writePromise);\n }\n const writeResults = await Promise.allSettled(promises);\n this.updateFileMap(archiveKeys, writeResults);\n }\n this.writePromise = null;\n }\n\n private updateFileMap(\n archiveKeys: (string | undefined)[],\n writeResults: PromiseSettledResult<string>[]\n ) {\n for (let i = 0; i < archiveKeys.length; i++) {\n const archiveKey = archiveKeys[i];\n if (archiveKey && 'value' in writeResults[i]) {\n this.fileMap[archiveKey] = (writeResults[i] as PromiseFulfilledResult<string>).value;\n }\n }\n }\n}\n"],"mappings":";AAAA,SAAQA,KAAK,QAAO,SAAS;AAC7B,OAAOC,OAAO,MAAM,SAAS;;AAG7B,MAAMC,YAAY,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI;;AAO3C,eAAe,MAAMC,UAAU,SAAmCH,KAAK,CAAI;EAOzEI,WAAW,GAAmE;IAAA,IAAlEC,iBAAyB,uEAAG,IAAI;IAAA,IAAEC,gBAAwB,uEAAG,GAAG;IAC1E,KAAK,EAAE;IAAC;IAAA,sCANkC,IAAI;IAAA,iCACN,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IAAI,CAACD,IAAI,EAAE;UACT;QACF;QACA,MAAM;UAACE,UAAU;UAAET;QAAY,CAAC,GAAGO,IAAsB;QACzDF,WAAW,CAACK,IAAI,CAACD,UAAU,CAAC;QAC5BL,QAAQ,CAACM,IAAI,CAACV,YAAY,CAAC;MAC7B;MACA,MAAMW,YAAY,GAAG,MAAMC,OAAO,CAACC,UAAU,CAACT,QAAQ,CAAC;MACvD,IAAI,CAACU,aAAa,CAACT,WAAW,EAAEM,YAAY,CAAC;IAC/C;IACA,IAAI,CAACX,YAAY,GAAG,IAAI;EAC1B;EAEQc,aAAa,CACnBT,WAAmC,EACnCM,YAA4C,EAC5C;IACA,KAAK,IAAIL,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGD,WAAW,CAACF,MAAM,EAAEG,CAAC,EAAE,EAAE;MAC3C,MAAMG,UAAU,GAAGJ,WAAW,CAACC,CAAC,CAAC;MACjC,IAAIG,UAAU,IAAI,OAAO,IAAIE,YAAY,CAACL,CAAC,CAAC,EAAE;QAC5C,IAAI,CAACS,OAAO,CAACN,UAAU,CAAC,GAAIE,YAAY,CAACL,CAAC,CAAC,CAAoCU,KAAK;MACtF;IACF;EACF;AACF"}
1
+ {"version":3,"file":"write-queue.js","names":["Queue","process","MEMORY_LIMIT","WriteQueue","constructor","listeningInterval","writeConcurrency","enqueue","val","writeImmediately","archiveKey","writePromise","result","fileMap","memoryUsage","rss","startWrite","startListening","intervalId","setInterval","bind","stopListening","clearInterval","doWrite","finalize","length","promises","archiveKeys","i","item","dequeue","push","promise","writeResults","Promise","allSettled","updateFileMap","value"],"sources":["../../../../src/lib/utils/write-queue.ts"],"sourcesContent":["import {Queue} from './queue';\nimport process from 'process';\n\n/** Memory limit size is based on testing */\nconst MEMORY_LIMIT = 4 * 1024 * 1024 * 1024; // 4GB\n\nexport type WriteQueueItem = {\n archiveKey?: string;\n /**\n * writePromise() returns a Promise that will be awaited in Promise.allSettled(promises);\n * Arguments for this call are specified in writeQueue.enqueue call like this:\n * await writeQueue.enqueue({\n * archiveKey: `nodePages/xxx.json.gz`,\n * writePromise: () => writeFileForSlpk(slpkPath, data, `xxx.json`)\n * });\n * Note, a function like writeFileForSlpk should NOT be called when initializing the object for enqueue().\n * If he function is called, the promise will be created\n * and the function will allocate resources (file descriptors) for file writing.\n * It will be done for ALL items in the queue, which is not supposed to happen.\n * That's why the function should be passed as\n * writePromise: () => writeFileForSlpk(slpkPath, content, `xxx.json`)\n * instead of\n * writePromise: writeFileForSlpk(slpkPath, content, `xxx.json`) // INCORRECT !\n */\n writePromise: () => Promise<string | null>;\n};\n\nexport default class WriteQueue<T extends WriteQueueItem> extends Queue<T> {\n private intervalId?: NodeJS.Timeout;\n public writePromise: Promise<void> | null = null;\n public fileMap: {[key: string]: string} = {};\n public listeningInterval: number;\n public writeConcurrency: number;\n\n constructor(listeningInterval: number = 2000, writeConcurrency: number = 400) {\n super();\n this.listeningInterval = listeningInterval;\n this.writeConcurrency = writeConcurrency;\n }\n\n async enqueue(val: T, writeImmediately: boolean = false) {\n if (writeImmediately) {\n const {archiveKey, writePromise} = val as WriteQueueItem;\n const result = await writePromise();\n if (archiveKey && result) {\n this.fileMap[archiveKey] = result;\n }\n } else {\n super.enqueue(val);\n /** https://nodejs.org/docs/latest-v14.x/api/process.html#process_process_memoryusage */\n if (process.memoryUsage().rss > MEMORY_LIMIT) {\n await this.startWrite();\n }\n }\n }\n\n startListening() {\n this.intervalId = setInterval(this.startWrite.bind(this), this.listeningInterval);\n }\n\n stopListening() {\n if (this.intervalId) {\n clearInterval(this.intervalId);\n }\n }\n\n async startWrite(): Promise<void> {\n if (!this.writePromise) {\n this.writePromise = this.doWrite();\n }\n await this.writePromise;\n this.writePromise = null;\n }\n\n async finalize(): Promise<void> {\n this.stopListening();\n await this.startWrite();\n }\n\n private async doWrite(): Promise<void> {\n while (this.length) {\n const promises: Promise<string | null>[] = [];\n const archiveKeys: (string | undefined)[] = [];\n for (let i = 0; i < this.writeConcurrency; i++) {\n const item = this.dequeue();\n if (!item) {\n break;\n }\n const {archiveKey, writePromise} = item as WriteQueueItem;\n archiveKeys.push(archiveKey);\n const promise = writePromise();\n promises.push(promise);\n }\n const writeResults = await Promise.allSettled(promises);\n this.updateFileMap(archiveKeys, writeResults);\n }\n }\n\n private updateFileMap(\n archiveKeys: (string | undefined)[],\n writeResults: PromiseSettledResult<string | null>[]\n ) {\n for (let i = 0; i < archiveKeys.length; i++) {\n const archiveKey = archiveKeys[i];\n if (archiveKey && 'value' in writeResults[i]) {\n this.fileMap[archiveKey] = (writeResults[i] as PromiseFulfilledResult<string>).value;\n }\n }\n }\n}\n"],"mappings":";AAAA,SAAQA,KAAK,QAAO,SAAS;AAC7B,OAAOC,OAAO,MAAM,SAAS;;AAG7B,MAAMC,YAAY,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI;;AAuB3C,eAAe,MAAMC,UAAU,SAAmCH,KAAK,CAAI;EAOzEI,WAAW,GAAmE;IAAA,IAAlEC,iBAAyB,uEAAG,IAAI;IAAA,IAAEC,gBAAwB,uEAAG,GAAG;IAC1E,KAAK,EAAE;IAAC;IAAA,sCANkC,IAAI;IAAA,iCACN,CAAC,CAAC;IAAA;IAAA;IAM1C,IAAI,CAACD,iBAAiB,GAAGA,iBAAiB;IAC1C,IAAI,CAACC,gBAAgB,GAAGA,gBAAgB;EAC1C;EAEA,MAAMC,OAAO,CAACC,GAAM,EAAqC;IAAA,IAAnCC,gBAAyB,uEAAG,KAAK;IACrD,IAAIA,gBAAgB,EAAE;MACpB,MAAM;QAACC,UAAU;QAAEC;MAAY,CAAC,GAAGH,GAAqB;MACxD,MAAMI,MAAM,GAAG,MAAMD,YAAY,EAAE;MACnC,IAAID,UAAU,IAAIE,MAAM,EAAE;QACxB,IAAI,CAACC,OAAO,CAACH,UAAU,CAAC,GAAGE,MAAM;MACnC;IACF,CAAC,MAAM;MACL,KAAK,CAACL,OAAO,CAACC,GAAG,CAAC;MAElB,IAAIP,OAAO,CAACa,WA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T,QAAQ,CAAC;MACvD,IAAI,CAACU,aAAa,CAACT,WAAW,EAAEM,YAAY,CAAC;IAC/C;EACF;EAEQG,aAAa,CACnBT,WAAmC,EACnCM,YAAmD,EACnD;IACA,KAAK,IAAIL,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGD,WAAW,CAACF,MAAM,EAAEG,CAAC,EAAE,EAAE;MAC3C,MAAMlB,UAAU,GAAGiB,WAAW,CAACC,CAAC,CAAC;MACjC,IAAIlB,UAAU,IAAI,OAAO,IAAIuB,YAAY,CAACL,CAAC,CAAC,EAAE;QAC5C,IAAI,CAACf,OAAO,CAACH,UAAU,CAAC,GAAIuB,YAAY,CAACL,CAAC,CAAC,CAAoCS,KAAK;MACtF;IACF;EACF;AACF"}
@@ -1,6 +1,6 @@
1
1
  import { parsePGM } from '@math.gl/geoid';
2
2
 
3
- const VERSION = typeof "3.3.0-alpha.7" !== 'undefined' ? "3.3.0-alpha.7" : 'latest';
3
+ const VERSION = typeof "3.3.0" !== 'undefined' ? "3.3.0" : 'latest';
4
4
 
5
5
  export const PGMLoader = {
6
6
  name: 'PGM - Netpbm grayscale image format',
@@ -1 +1 @@
1
- {"version":3,"file":"pgm-loader.js","names":["parsePGM","VERSION","PGMLoader","name","id","module","version","mimeTypes","parse","arrayBuffer","options","Uint8Array","extensions","cubic"],"sources":["../../src/pgm-loader.ts"],"sourcesContent":["import type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {parsePGM} from '@math.gl/geoid';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\n/**\n * Loader for PGM - Netpbm grayscale image format\n */\nexport const PGMLoader: LoaderWithParser = {\n name: 'PGM - Netpbm grayscale image format',\n id: 'pgm',\n module: 'tile-converter',\n version: VERSION,\n mimeTypes: ['image/x-portable-graymap'],\n // @ts-expect-error LoaderOptions does not have cubic parameter\n parse: async (arrayBuffer, options) => parsePGM(new Uint8Array(arrayBuffer), options),\n extensions: ['pgm'],\n options: {\n // TODO - use pgm namespace\n cubic: false\n }\n};\n"],"mappings":"AACA,SAAQA,QAAQ,QAAO,gBAAgB;;AAIvC,MAAMC,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiB,QAAQ;;AAK3E,OAAO,MAAMC,SAA2B,GAAG;EACzCC,IAAI,EAAE,qCAAqC;EAC3CC,EAAE,EAAE,KAAK;EACTC,MAAM,EAAE,gBAAgB;EACxBC,OAAO,EAAEL,OAAO;EAChBM,SAAS,EAAE,CAAC,0BAA0B,CAAC;EAEvCC,KAAK,EAAE,OAAOC,WAAW,EAAEC,OAAO,KAAKV,QAAQ,CAAC,IAAIW,UAAU,CAACF,WAAW,CAAC,EAAEC,OAAO,CAAC;EACrFE,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBF,OAAO,EAAE;IAEPG,KAAK,EAAE;EACT;AACF,CAAC"}
1
+ {"version":3,"file":"pgm-loader.js","names":["parsePGM","VERSION","PGMLoader","name","id","module","version","mimeTypes","parse","arrayBuffer","options","Uint8Array","extensions","cubic"],"sources":["../../src/pgm-loader.ts"],"sourcesContent":["import type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {parsePGM} from '@math.gl/geoid';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\n/**\n * Loader for PGM - Netpbm grayscale image format\n */\nexport const PGMLoader: LoaderWithParser = {\n name: 'PGM - Netpbm grayscale image format',\n id: 'pgm',\n module: 'tile-converter',\n version: VERSION,\n mimeTypes: ['image/x-portable-graymap'],\n // @ts-expect-error LoaderOptions does not have cubic parameter\n parse: async (arrayBuffer, options) => parsePGM(new Uint8Array(arrayBuffer), options),\n extensions: ['pgm'],\n options: {\n // TODO - use pgm namespace\n cubic: false\n }\n};\n"],"mappings":"AACA,SAAQA,QAAQ,QAAO,gBAAgB;;AAIvC,MAAMC,OAAO,GAAG,cAAkB,KAAK,WAAW,aAAiB,QAAQ;;AAK3E,OAAO,MAAMC,SAA2B,GAAG;EACzCC,IAAI,EAAE,qCAAqC;EAC3CC,EAAE,EAAE,KAAK;EACTC,MAAM,EAAE,gBAAgB;EACxBC,OAAO,EAAEL,OAAO;EAChBM,SAAS,EAAE,CAAC,0BAA0B,CAAC;EAEvCC,KAAK,EAAE,OAAOC,WAAW,EAAEC,OAAO,KAAKV,QAAQ,CAAC,IAAIW,UAAU,CAACF,WAAW,CAAC,EAAEC,OAAO,CAAC;EACrFE,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBF,OAAO,EAAE;IAEPG,KAAK,EAAE;EACT;AACF,CAAC"}
@@ -2,6 +2,6 @@ import { createWorker } from '@loaders.gl/worker-utils';
2
2
  import { convertAttributes } from '../i3s-converter/helpers/geometry-converter';
3
3
  createWorker(async function (data) {
4
4
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5
- return await convertAttributes(data, options.useCartesianPositions);
5
+ return await convertAttributes(data, options.materialAndTextureList, options.useCartesianPositions);
6
6
  });
7
7
  //# sourceMappingURL=i3s-attributes-worker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"i3s-attributes-worker.js","names":["createWorker","convertAttributes","data","options","useCartesianPositions"],"sources":["../../../src/workers/i3s-attributes-worker.ts"],"sourcesContent":["import {createWorker} from '@loaders.gl/worker-utils';\nimport {convertAttributes} from '../i3s-converter/helpers/geometry-converter';\n\ncreateWorker(\n async (data, options = {}) => await convertAttributes(data, options.useCartesianPositions)\n);\n"],"mappings":"AAAA,SAAQA,YAAY,QAAO,0BAA0B;AACrD,SAAQC,iBAAiB,QAAO,6CAA6C;AAE7ED,YAAY,CACV,gBAAOE,IAAI;EAAA,IAAEC,OAAO,uEAAG,CAAC,CAAC;EAAA,OAAK,MAAMF,iBAAiB,CAACC,IAAI,EAAEC,OAAO,CAACC,qBAAqB,CAAC;AAAA,EAC3F"}
1
+ {"version":3,"file":"i3s-attributes-worker.js","names":["createWorker","convertAttributes","data","options","materialAndTextureList","useCartesianPositions"],"sources":["../../../src/workers/i3s-attributes-worker.ts"],"sourcesContent":["import {createWorker} from '@loaders.gl/worker-utils';\nimport {convertAttributes} from '../i3s-converter/helpers/geometry-converter';\n\ncreateWorker(\n async (data, options = {}) =>\n await convertAttributes(data, options.materialAndTextureList, options.useCartesianPositions)\n);\n"],"mappings":"AAAA,SAAQA,YAAY,QAAO,0BAA0B;AACrD,SAAQC,iBAAiB,QAAO,6CAA6C;AAE7ED,YAAY,CACV,gBAAOE,IAAI;EAAA,IAAEC,OAAO,uEAAG,CAAC,CAAC;EAAA,OACvB,MAAMF,iBAAiB,CAACC,IAAI,EAAEC,OAAO,CAACC,sBAAsB,EAAED,OAAO,CAACE,qBAAqB,CAAC;AAAA,EAC/F"}
@@ -2,13 +2,13 @@ import type { WorkerObject } from '@loaders.gl/worker-utils';
2
2
  import type { ConvertedAttributes } from './i3s-converter/types';
3
3
  import type { Matrix4, Vector3 } from '@math.gl/core';
4
4
  import type { GLTFImagePostprocessed, GLTFNodePostprocessed } from '@loaders.gl/gltf';
5
- export declare type I3SAttributesWorkerOptions = {
5
+ export type I3SAttributesWorkerOptions = {
6
6
  _nodeWorkers: boolean;
7
7
  reuseWorkers: boolean;
8
8
  useCartesianPositions: boolean;
9
9
  source: string;
10
10
  };
11
- export declare type B3DMAttributesData = {
11
+ export type B3DMAttributesData = {
12
12
  gltfMaterials?: {
13
13
  id: string;
14
14
  }[];
@@ -1 +1 @@
1
- {"version":3,"file":"i3s-attributes-worker.d.ts","sourceRoot":"","sources":["../src/i3s-attributes-worker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EAAC,OAAO,EAAE,OA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