@loaders.gl/tile-converter 3.4.0-alpha.2 → 3.4.0-alpha.4

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 (156) hide show
  1. package/dist/3d-tiles-attributes-worker.js +2 -2
  2. package/dist/3d-tiles-attributes-worker.js.map +3 -3
  3. package/dist/converter.min.js +90 -2875
  4. package/dist/dist.min.js +1823 -19725
  5. package/dist/es5/3d-tiles-attributes-worker.js +1 -2
  6. package/dist/es5/3d-tiles-attributes-worker.js.map +1 -1
  7. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +264 -287
  8. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  9. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +89 -113
  10. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  11. package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -1
  12. package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js +0 -2
  13. package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
  14. package/dist/es5/3d-tiles-converter/json-templates/tileset.js.map +1 -1
  15. package/dist/es5/constants.js.map +1 -1
  16. package/dist/es5/converter-cli.js +67 -81
  17. package/dist/es5/converter-cli.js.map +1 -1
  18. package/dist/es5/deps-installer/deps-installer.js +64 -69
  19. package/dist/es5/deps-installer/deps-installer.js.map +1 -1
  20. package/dist/es5/i3s-attributes-worker.js +1 -2
  21. package/dist/es5/i3s-attributes-worker.js.map +1 -1
  22. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +0 -8
  23. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  24. package/dist/es5/i3s-converter/helpers/coordinate-converter.js +0 -5
  25. package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  26. package/dist/es5/i3s-converter/helpers/create-scene-server-path.js +14 -16
  27. package/dist/es5/i3s-converter/helpers/create-scene-server-path.js.map +1 -1
  28. package/dist/es5/i3s-converter/helpers/feature-attributes.js +1 -11
  29. package/dist/es5/i3s-converter/helpers/feature-attributes.js.map +1 -1
  30. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +3 -10
  31. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  32. package/dist/es5/i3s-converter/helpers/geometry-converter.js +427 -457
  33. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  34. package/dist/es5/i3s-converter/helpers/gltf-attributes.js +0 -2
  35. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  36. package/dist/es5/i3s-converter/helpers/node-debug.js +3 -13
  37. package/dist/es5/i3s-converter/helpers/node-debug.js.map +1 -1
  38. package/dist/es5/i3s-converter/helpers/node-index-document.js +293 -318
  39. package/dist/es5/i3s-converter/helpers/node-index-document.js.map +1 -1
  40. package/dist/es5/i3s-converter/helpers/node-pages.js +279 -319
  41. package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
  42. package/dist/es5/i3s-converter/i3s-converter.js +964 -1030
  43. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  44. package/dist/es5/i3s-converter/json-templates/geometry-definitions.js.map +1 -1
  45. package/dist/es5/i3s-converter/json-templates/layers.js.map +1 -1
  46. package/dist/es5/i3s-converter/json-templates/metadata.js.map +1 -1
  47. package/dist/es5/i3s-converter/json-templates/node.js.map +1 -1
  48. package/dist/es5/i3s-converter/json-templates/scene-server.js.map +1 -1
  49. package/dist/es5/i3s-converter/json-templates/shared-resources.js +1 -1
  50. package/dist/es5/i3s-converter/json-templates/shared-resources.js.map +1 -1
  51. package/dist/es5/i3s-converter/json-templates/store.js.map +1 -1
  52. package/dist/es5/i3s-converter/types.js.map +1 -1
  53. package/dist/es5/i3s-server/app.js.map +1 -1
  54. package/dist/es5/i3s-server/controllers/index-controller.js +28 -30
  55. package/dist/es5/i3s-server/controllers/index-controller.js.map +1 -1
  56. package/dist/es5/i3s-server/routes/index.js +15 -18
  57. package/dist/es5/i3s-server/routes/index.js.map +1 -1
  58. package/dist/es5/index.js.map +1 -1
  59. package/dist/es5/lib/utils/compress-util.js +198 -218
  60. package/dist/es5/lib/utils/compress-util.js.map +1 -1
  61. package/dist/es5/lib/utils/file-utils.js +118 -128
  62. package/dist/es5/lib/utils/file-utils.js.map +1 -1
  63. package/dist/es5/lib/utils/lod-conversion-utils.js +0 -1
  64. package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
  65. package/dist/es5/lib/utils/queue.js.map +1 -1
  66. package/dist/es5/lib/utils/statistic-utills.js +81 -85
  67. package/dist/es5/lib/utils/statistic-utills.js.map +1 -1
  68. package/dist/es5/lib/utils/write-queue.js +84 -92
  69. package/dist/es5/lib/utils/write-queue.js.map +1 -1
  70. package/dist/es5/pgm-loader.js +7 -10
  71. package/dist/es5/pgm-loader.js.map +1 -1
  72. package/dist/es5/workers/3d-tiles-attributes-worker.js +7 -9
  73. package/dist/es5/workers/3d-tiles-attributes-worker.js.map +1 -1
  74. package/dist/es5/workers/i3s-attributes-worker.js +10 -12
  75. package/dist/es5/workers/i3s-attributes-worker.js.map +1 -1
  76. package/dist/esm/3d-tiles-attributes-worker.js +1 -3
  77. package/dist/esm/3d-tiles-attributes-worker.js.map +1 -1
  78. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +1 -15
  79. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  80. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +0 -12
  81. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  82. package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +0 -1
  83. package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -1
  84. package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js +0 -3
  85. package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
  86. package/dist/esm/3d-tiles-converter/json-templates/tileset.js.map +1 -1
  87. package/dist/esm/bundle.js +0 -1
  88. package/dist/esm/bundle.js.map +1 -1
  89. package/dist/esm/converter-cli.js +0 -11
  90. package/dist/esm/converter-cli.js.map +1 -1
  91. package/dist/esm/deps-installer/deps-installer.js +1 -4
  92. package/dist/esm/deps-installer/deps-installer.js.map +1 -1
  93. package/dist/esm/i3s-attributes-worker.js +1 -3
  94. package/dist/esm/i3s-attributes-worker.js.map +1 -1
  95. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +0 -8
  96. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  97. package/dist/esm/i3s-converter/helpers/coordinate-converter.js +0 -5
  98. package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  99. package/dist/esm/i3s-converter/helpers/create-scene-server-path.js +0 -1
  100. package/dist/esm/i3s-converter/helpers/create-scene-server-path.js.map +1 -1
  101. package/dist/esm/i3s-converter/helpers/feature-attributes.js +0 -11
  102. package/dist/esm/i3s-converter/helpers/feature-attributes.js.map +1 -1
  103. package/dist/esm/i3s-converter/helpers/geometry-attributes.js +0 -7
  104. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  105. package/dist/esm/i3s-converter/helpers/geometry-converter.js +30 -56
  106. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  107. package/dist/esm/i3s-converter/helpers/gltf-attributes.js +0 -3
  108. package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  109. package/dist/esm/i3s-converter/helpers/node-debug.js +3 -13
  110. package/dist/esm/i3s-converter/helpers/node-debug.js.map +1 -1
  111. package/dist/esm/i3s-converter/helpers/node-index-document.js +0 -14
  112. package/dist/esm/i3s-converter/helpers/node-index-document.js.map +1 -1
  113. package/dist/esm/i3s-converter/helpers/node-pages.js +0 -18
  114. package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
  115. package/dist/esm/i3s-converter/i3s-converter.js +4 -42
  116. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  117. package/dist/esm/i3s-converter/json-templates/geometry-definitions.js.map +1 -1
  118. package/dist/esm/i3s-converter/json-templates/layers.js.map +1 -1
  119. package/dist/esm/i3s-converter/json-templates/metadata.js.map +1 -1
  120. package/dist/esm/i3s-converter/json-templates/node.js.map +1 -1
  121. package/dist/esm/i3s-converter/json-templates/scene-server.js.map +1 -1
  122. package/dist/esm/i3s-converter/json-templates/shared-resources.js.map +1 -1
  123. package/dist/esm/i3s-converter/json-templates/store.js.map +1 -1
  124. package/dist/esm/i3s-converter/types.js.map +1 -1
  125. package/dist/esm/i3s-server/app.js.map +1 -1
  126. package/dist/esm/i3s-server/controllers/index-controller.js +0 -2
  127. package/dist/esm/i3s-server/controllers/index-controller.js.map +1 -1
  128. package/dist/esm/i3s-server/routes/index.js +0 -1
  129. package/dist/esm/i3s-server/routes/index.js.map +1 -1
  130. package/dist/esm/lib/utils/compress-util.js +1 -17
  131. package/dist/esm/lib/utils/compress-util.js.map +1 -1
  132. package/dist/esm/lib/utils/file-utils.js +0 -7
  133. package/dist/esm/lib/utils/file-utils.js.map +1 -1
  134. package/dist/esm/lib/utils/lod-conversion-utils.js +0 -2
  135. package/dist/esm/lib/utils/lod-conversion-utils.js.map +1 -1
  136. package/dist/esm/lib/utils/queue.js.map +1 -1
  137. package/dist/esm/lib/utils/statistic-utills.js.map +1 -1
  138. package/dist/esm/lib/utils/write-queue.js +0 -2
  139. package/dist/esm/lib/utils/write-queue.js.map +1 -1
  140. package/dist/esm/pgm-loader.js +1 -3
  141. package/dist/esm/pgm-loader.js.map +1 -1
  142. package/dist/esm/workers/3d-tiles-attributes-worker.js.map +1 -1
  143. package/dist/esm/workers/i3s-attributes-worker.js.map +1 -1
  144. package/dist/i3s-attributes-worker.js +2 -2
  145. package/dist/i3s-attributes-worker.js.map +3 -3
  146. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  147. package/dist/i3s-converter/helpers/geometry-converter.js +44 -6
  148. package/dist/i3s-converter/helpers/node-debug.d.ts.map +1 -1
  149. package/dist/i3s-converter/helpers/node-debug.js +10 -4
  150. package/dist/i3s-converter/helpers/node-pages.js +1 -1
  151. package/dist/i3s-converter/types.d.ts +1 -0
  152. package/dist/i3s-converter/types.d.ts.map +1 -1
  153. package/package.json +15 -16
  154. package/src/i3s-converter/helpers/geometry-converter.ts +59 -14
  155. package/src/i3s-converter/helpers/node-debug.ts +11 -5
  156. package/src/i3s-converter/types.ts +10 -0
@@ -3,10 +3,8 @@ import { ZipLoader } from '@loaders.gl/zip';
3
3
  import { writeFile } from '../lib/utils/file-utils';
4
4
  import { join } from 'path';
5
5
  import { ChildProcessProxy } from '@loaders.gl/worker-utils';
6
-
7
- const VERSION = typeof "3.4.0-alpha.2" !== 'undefined' ? "3.4.0-alpha.2" : 'beta';
6
+ const VERSION = typeof "3.4.0-alpha.4" !== 'undefined' ? "3.4.0-alpha.4" : 'beta';
8
7
  const PGM_LINK = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/egm/egm2008-5.zip';
9
-
10
8
  export class DepsInstaller {
11
9
  async install() {
12
10
  let path = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
@@ -33,7 +31,6 @@ export class DepsInstaller {
33
31
  });
34
32
  console.log('All dependencies were installed succesfully.');
35
33
  }
36
-
37
34
  async installWorker(module, name, extraPath) {
38
35
  const fileResponse = await fetchFile("https://unpkg.com/@loaders.gl/".concat(module, "@").concat(VERSION, "/dist/").concat(name));
39
36
  const fileData = await fileResponse.arrayBuffer();
@@ -1 +1 @@
1
- {"version":3,"file":"deps-installer.js","names":["load","fetchFile","ZipLoader","writeFile","join","ChildProcessProxy","VERSION","PGM_LINK","DepsInstaller","install","path","workersPath","console","log","fileMap","depsPath","process","cwd","Uint8Array","installWorker","childProcess","start","command","arguments","wait","module","name","extraPath","fileResponse","fileData","arrayBuffer"],"sources":["../../../src/deps-installer/deps-installer.ts"],"sourcesContent":["import {load, fetchFile} from '@loaders.gl/core';\nimport {ZipLoader} from '@loaders.gl/zip';\nimport {writeFile} from '../lib/utils/file-utils';\nimport {join} from 'path';\nimport {ChildProcessProxy} from '@loaders.gl/worker-utils';\n\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'beta';\n\nconst PGM_LINK = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/egm/egm2008-5.zip';\n\n/**\n * Install external dependencies for converter:\n * * PGM file (implemented);\n * * Draco library (not implemented);\n * * 7z archiver (not implemented);\n */\nexport class DepsInstaller {\n /**\n * Run instalation\n * @param path destination folder\n * @param workersPath destination folder for workers.\n * This path is '' by default and is not used by tile-converter.\n * It is used in tests to prevent rewriting actual workers during tests running\n */\n async install(path: string = '', workersPath: string = ''): Promise<void> {\n console.log('Installing \"EGM2008-5\" model...'); // eslint-disable-line no-console\n const fileMap = await load(PGM_LINK, ZipLoader, {});\n\n let depsPath = process.cwd();\n if (path) {\n depsPath = join(depsPath, path);\n }\n\n await writeFile(depsPath, new Uint8Array(fileMap['geoids/egm2008-5.pgm']), 'egm2008-5.pgm');\n\n console.log('Installing \"I3S Content Loader worker\"'); // eslint-disable-line no-console\n await this.installWorker('i3s', 'i3s-content-nodejs-worker.js', workersPath);\n\n console.log('Installing \"Draco Loader worker\"'); // eslint-disable-line no-console\n await this.installWorker('draco', 'draco-nodejs-worker.js', workersPath);\n\n console.log('Installing \"Basis Loader worker\"'); // eslint-disable-line no-console\n await this.installWorker('textures', 'basis-nodejs-worker.js', workersPath);\n\n console.log('Installing \"join-images\" npm package');\n const childProcess = new ChildProcessProxy();\n await childProcess.start({\n command: 'npm',\n // `npm install sharp join-images` works unstable. It fails because installed `sharp` version\n // may be different from the version required by `join-images`. Pointing to specific versions\n // resolve this issue\n arguments: ['install', 'sharp@^0.30.4', 'join-images@^1.1.3'],\n wait: 0\n });\n\n console.log('All dependencies were installed succesfully.'); // eslint-disable-line no-console\n }\n\n private async installWorker(module: string, name: string, extraPath: string) {\n const fileResponse = await fetchFile(\n `https://unpkg.com/@loaders.gl/${module}@${VERSION}/dist/${name}`\n );\n const fileData = await fileResponse.arrayBuffer();\n if (!fileData) {\n return;\n }\n const path = join(process.cwd(), extraPath, 'modules', module, 'dist');\n await writeFile(path, fileData, name);\n }\n}\n"],"mappings":"AAAA,SAAQA,IAAI,EAAEC,SAAS,QAAO,kBAAkB;AAChD,SAAQC,SAAS,QAAO,iBAAiB;AACzC,SAAQC,SAAS,QAAO,yBAAyB;AACjD,SAAQC,IAAI,QAAO,MAAM;AACzB,SAAQC,iBAAiB,QAAO,0BAA0B;;AAG1D,MAAMC,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiB,MAAM;AAEzE,MAAMC,QAAQ,GAAG,+EAA+E;;AAQhG,OAAO,MAAMC,aAAa,CAAC;EAQzB,MAAMC,OAAO,GAA6D;IAAA,IAA5DC,IAAY,uEAAG,EAAE;IAAA,IAAEC,WAAmB,uEAAG,EAAE;IACvDC,OAAO,CAACC,GAAG,CAAC,iCAAiC,CAAC;IAC9C,MAAMC,OAAO,GAAG,MAAMd,IAAI,CAACO,QAAQ,EAAEL,SAAS,EAAE,CAAC,CAAC,CAAC;IAEnD,IAAIa,QAAQ,GAAGC,OAAO,CAACC,GAAG,EAAE;IAC5B,IAAIP,IAAI,EAAE;MACRK,QAAQ,GAAGX,IAAI,CAACW,QAAQ,EAAEL,IAAI,CAAC;IACjC;IAEA,MAAMP,SAAS,CAACY,QAAQ,EAAE,IAAIG,UAAU,CAACJ,OAAO,CAAC,sBAAsB,CAAC,CAAC,EAAE,eAAe,CAAC;IAE3FF,OAAO,CAACC,GAAG,CAAC,wCAAwC,CAAC;IACrD,MAAM,IAAI,CAACM,aAAa,CAAC,KAAK,EAAE,8BAA8B,EAAER,WAAW,CAAC;IAE5EC,OAAO,CAACC,GAAG,CAAC,kCAAkC,CAAC;IAC/C,MAAM,IAAI,CAACM,aAAa,CAAC,OAAO,EAAE,wBAAwB,EAAER,WAAW,CAAC;IAExEC,OAAO,CAACC,GAAG,CAAC,kCAAkC,CAAC;IAC/C,MAAM,IAAI,CAACM,aAAa,CAAC,UAAU,EAAE,wBAAwB,EAAER,WAAW,CAAC;IAE3EC,OAAO,CAACC,GAAG,CAAC,sCAAsC,CAAC;IACnD,MAAMO,YAAY,GAAG,IAAIf,iBAAiB,EAAE;IAC5C,MAAMe,YAAY,CAACC,KAAK,CAAC;MACvBC,OAAO,EAAE,KAAK;MAIdC,SAAS,EAAE,CAAC,SAAS,EAAE,eAAe,EAAE,oBAAoB,CAAC;MAC7DC,IAAI,EAAE;IACR,CAAC,CAAC;IAEFZ,OAAO,CAACC,GAAG,CAAC,8CAA8C,CAAC;EAC7D;;EAEA,MAAcM,aAAa,CAACM,MAAc,EAAEC,IAAY,EAAEC,SAAiB,EAAE;IAC3E,MAAMC,YAAY,GAAG,MAAM3B,SAAS,yCACDwB,MAAM,cAAInB,OAAO,mBAASoB,IAAI,EAChE;IACD,MAAMG,QAAQ,GAAG,MAAMD,YAAY,CAACE,WAAW,EAAE;IACjD,IAAI,CAACD,QAAQ,EAAE;MACb;IACF;IACA,MAAMnB,IAAI,GAAGN,IAAI,CAACY,OAAO,CAACC,GAAG,EAAE,EAAEU,SAAS,EAAE,SAAS,EAAEF,MAAM,EAAE,MAAM,CAAC;IACtE,MAAMtB,SAAS,CAACO,IAAI,EAAEmB,QAAQ,EAAEH,IAAI,CAAC;EACvC;AACF"}
1
+ {"version":3,"file":"deps-installer.js","names":["load","fetchFile","ZipLoader","writeFile","join","ChildProcessProxy","VERSION","PGM_LINK","DepsInstaller","install","path","arguments","length","undefined","workersPath","console","log","fileMap","depsPath","process","cwd","Uint8Array","installWorker","childProcess","start","command","wait","module","name","extraPath","fileResponse","concat","fileData","arrayBuffer"],"sources":["../../../src/deps-installer/deps-installer.ts"],"sourcesContent":["import {load, fetchFile} from '@loaders.gl/core';\nimport {ZipLoader} from '@loaders.gl/zip';\nimport {writeFile} from '../lib/utils/file-utils';\nimport {join} from 'path';\nimport {ChildProcessProxy} from '@loaders.gl/worker-utils';\n\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'beta';\n\nconst PGM_LINK = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/egm/egm2008-5.zip';\n\n/**\n * Install external dependencies for converter:\n * * PGM file (implemented);\n * * Draco library (not implemented);\n * * 7z archiver (not implemented);\n */\nexport class DepsInstaller {\n /**\n * Run instalation\n * @param path destination folder\n * @param workersPath destination folder for workers.\n * This path is '' by default and is not used by tile-converter.\n * It is used in tests to prevent rewriting actual workers during tests running\n */\n async install(path: string = '', workersPath: string = ''): Promise<void> {\n console.log('Installing \"EGM2008-5\" model...'); // eslint-disable-line no-console\n const fileMap = await load(PGM_LINK, ZipLoader, {});\n\n let depsPath = process.cwd();\n if (path) {\n depsPath = join(depsPath, path);\n }\n\n await writeFile(depsPath, new Uint8Array(fileMap['geoids/egm2008-5.pgm']), 'egm2008-5.pgm');\n\n console.log('Installing \"I3S Content Loader worker\"'); // eslint-disable-line no-console\n await this.installWorker('i3s', 'i3s-content-nodejs-worker.js', workersPath);\n\n console.log('Installing \"Draco Loader worker\"'); // eslint-disable-line no-console\n await this.installWorker('draco', 'draco-nodejs-worker.js', workersPath);\n\n console.log('Installing \"Basis Loader worker\"'); // eslint-disable-line no-console\n await this.installWorker('textures', 'basis-nodejs-worker.js', workersPath);\n\n console.log('Installing \"join-images\" npm package');\n const childProcess = new ChildProcessProxy();\n await childProcess.start({\n command: 'npm',\n // `npm install sharp join-images` works unstable. It fails because installed `sharp` version\n // may be different from the version required by `join-images`. Pointing to specific versions\n // resolve this issue\n arguments: ['install', 'sharp@^0.30.4', 'join-images@^1.1.3'],\n wait: 0\n });\n\n console.log('All dependencies were installed succesfully.'); // eslint-disable-line no-console\n }\n\n private async installWorker(module: string, name: string, extraPath: string) {\n const fileResponse = await fetchFile(\n `https://unpkg.com/@loaders.gl/${module}@${VERSION}/dist/${name}`\n );\n const fileData = await fileResponse.arrayBuffer();\n if (!fileData) {\n return;\n }\n const path = join(process.cwd(), extraPath, 'modules', module, 'dist');\n await writeFile(path, fileData, name);\n }\n}\n"],"mappings":"AAAA,SAAQA,IAAI,EAAEC,SAAS,QAAO,kBAAkB;AAChD,SAAQC,SAAS,QAAO,iBAAiB;AACzC,SAAQC,SAAS,QAAO,yBAAyB;AACjD,SAAQC,IAAI,QAAO,MAAM;AACzB,SAAQC,iBAAiB,QAAO,0BAA0B;AAG1D,MAAMC,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiB,MAAM;AAEzE,MAAMC,QAAQ,GAAG,+EAA+E;AAQhG,OAAO,MAAMC,aAAa,CAAC;EAQzB,MAAMC,OAAOA,CAAA,EAA6D;IAAA,IAA5DC,IAAY,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;IAAA,IAAEG,WAAmB,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;IACvDI,OAAO,CAACC,GAAG,CAAC,iCAAiC,CAAC;IAC9C,MAAMC,OAAO,GAAG,MAAMjB,IAAI,CAACO,QAAQ,EAAEL,SAAS,EAAE,CAAC,CAAC,CAAC;IAEnD,IAAIgB,QAAQ,GAAGC,OAAO,CAACC,GAAG,CAAC,CAAC;IAC5B,IAAIV,IAAI,EAAE;MACRQ,QAAQ,GAAGd,IAAI,CAACc,QAAQ,EAAER,IAAI,CAAC;IACjC;IAEA,MAAMP,SAAS,CAACe,QAAQ,EAAE,IAAIG,UAAU,CAACJ,OAAO,CAAC,sBAAsB,CAAC,CAAC,EAAE,eAAe,CAAC;IAE3FF,OAAO,CAACC,GAAG,CAAC,wCAAwC,CAAC;IACrD,MAAM,IAAI,CAACM,aAAa,CAAC,KAAK,EAAE,8BAA8B,EAAER,WAAW,CAAC;IAE5EC,OAAO,CAACC,GAAG,CAAC,kCAAkC,CAAC;IAC/C,MAAM,IAAI,CAACM,aAAa,CAAC,OAAO,EAAE,wBAAwB,EAAER,WAAW,CAAC;IAExEC,OAAO,CAACC,GAAG,CAAC,kCAAkC,CAAC;IAC/C,MAAM,IAAI,CAACM,aAAa,CAAC,UAAU,EAAE,wBAAwB,EAAER,WAAW,CAAC;IAE3EC,OAAO,CAACC,GAAG,CAAC,sCAAsC,CAAC;IACnD,MAAMO,YAAY,GAAG,IAAIlB,iBAAiB,CAAC,CAAC;IAC5C,MAAMkB,YAAY,CAACC,KAAK,CAAC;MACvBC,OAAO,EAAE,KAAK;MAIdd,SAAS,EAAE,CAAC,SAAS,EAAE,eAAe,EAAE,oBAAoB,CAAC;MAC7De,IAAI,EAAE;IACR,CAAC,CAAC;IAEFX,OAAO,CAACC,GAAG,CAAC,8CAA8C,CAAC;EAC7D;EAEA,MAAcM,aAAaA,CAACK,MAAc,EAAEC,IAAY,EAAEC,SAAiB,EAAE;IAC3E,MAAMC,YAAY,GAAG,MAAM7B,SAAS,kCAAA8B,MAAA,CACDJ,MAAM,OAAAI,MAAA,CAAIzB,OAAO,YAAAyB,MAAA,CAASH,IAAI,CACjE,CAAC;IACD,MAAMI,QAAQ,GAAG,MAAMF,YAAY,CAACG,WAAW,CAAC,CAAC;IACjD,IAAI,CAACD,QAAQ,EAAE;MACb;IACF;IACA,MAAMtB,IAAI,GAAGN,IAAI,CAACe,OAAO,CAACC,GAAG,CAAC,CAAC,EAAES,SAAS,EAAE,SAAS,EAAEF,MAAM,EAAE,MAAM,CAAC;IACtE,MAAMxB,SAAS,CAACO,IAAI,EAAEsB,QAAQ,EAAEJ,IAAI,CAAC;EACvC;AACF"}
@@ -1,6 +1,5 @@
1
1
  import { processOnWorker } from '@loaders.gl/worker-utils';
2
-
3
- const VERSION = typeof "3.4.0-alpha.2" !== 'undefined' ? "3.4.0-alpha.2" : 'latest';
2
+ const VERSION = typeof "3.4.0-alpha.4" !== 'undefined' ? "3.4.0-alpha.4" : 'latest';
4
3
  export const I3SAttributesWorker = {
5
4
  id: 'i3s-attributes',
6
5
  name: 'I3S Attributes Worker',
@@ -10,7 +9,6 @@ export const I3SAttributesWorker = {
10
9
  useCartesianPositions: false
11
10
  }
12
11
  };
13
-
14
12
  export function transformI3SAttributesOnWorker(attributesData, options) {
15
13
  return processOnWorker(I3SAttributesWorker, attributesData, options);
16
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"i3s-attributes-worker.js","names":["processOnWorker","VERSION","I3SAttributesWorker","id","name","module","version","options","useCartesianPositions","transformI3SAttributesOnWorker","attributesData","_typecheckI3SAttributesWorker"],"sources":["../../src/i3s-attributes-worker.ts"],"sourcesContent":["import type {WorkerObject} from '@loaders.gl/worker-utils';\nimport type {ConvertedAttributes} from './i3s-converter/types';\nimport type {Matrix4, Vector3} from '@math.gl/core';\nimport type {GLTFImagePostprocessed, GLTFNodePostprocessed} from '@loaders.gl/gltf';\n\nimport {processOnWorker} from '@loaders.gl/worker-utils';\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\nexport type I3SAttributesWorkerOptions = {\n _nodeWorkers: boolean;\n reuseWorkers: boolean;\n useCartesianPositions: boolean;\n source: string;\n};\n\nexport type B3DMAttributesData = {\n gltfMaterials?: {id: string}[];\n nodes: GLTFNodePostprocessed[];\n images: GLTFImagePostprocessed[];\n cartographicOrigin: Vector3;\n cartesianModelMatrix: Matrix4;\n};\n\n/**\n * I3S Attributes Worker to handle B3DM object\n */\nexport const I3SAttributesWorker = {\n id: 'i3s-attributes',\n name: 'I3S Attributes Worker',\n module: 'tile-converter',\n version: VERSION,\n options: {\n useCartesianPositions: false\n }\n};\n\n/**\n * Performs I3S attributes transformation\n */\nexport function transformI3SAttributesOnWorker(\n attributesData: B3DMAttributesData,\n options: I3SAttributesWorkerOptions\n): Promise<Map<string, ConvertedAttributes>> {\n return processOnWorker(I3SAttributesWorker, attributesData, options);\n}\n\nexport const _typecheckI3SAttributesWorker: WorkerObject = I3SAttributesWorker;\n"],"mappings":"AAKA,SAAQA,eAAe,QAAO,0BAA0B;;AAIxD,MAAMC,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiB,QAAQ;AAoB3E,OAAO,MAAMC,mBAAmB,GAAG;EACjCC,EAAE,EAAE,gBAAgB;EACpBC,IAAI,EAAE,uBAAuB;EAC7BC,MAAM,EAAE,gBAAgB;EACxBC,OAAO,EAAEL,OAAO;EAChBM,OAAO,EAAE;IACPC,qBAAqB,EAAE;EACzB;AACF,CAAC;;AAKD,OAAO,SAASC,8BAA8B,CAC5CC,cAAkC,EAClCH,OAAmC,EACQ;EAC3C,OAAOP,eAAe,CAACE,mBAAmB,EAAEQ,cAAc,EAAEH,OAAO,CAAC;AACtE;AAEA,OAAO,MAAMI,6BAA2C,GAAGT,mBAAmB"}
1
+ {"version":3,"file":"i3s-attributes-worker.js","names":["processOnWorker","VERSION","I3SAttributesWorker","id","name","module","version","options","useCartesianPositions","transformI3SAttributesOnWorker","attributesData","_typecheckI3SAttributesWorker"],"sources":["../../src/i3s-attributes-worker.ts"],"sourcesContent":["import type {WorkerObject} from '@loaders.gl/worker-utils';\nimport type {ConvertedAttributes} from './i3s-converter/types';\nimport type {Matrix4, Vector3} from '@math.gl/core';\nimport type {GLTFImagePostprocessed, GLTFNodePostprocessed} from '@loaders.gl/gltf';\n\nimport {processOnWorker} from '@loaders.gl/worker-utils';\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\nexport type I3SAttributesWorkerOptions = {\n _nodeWorkers: boolean;\n reuseWorkers: boolean;\n useCartesianPositions: boolean;\n source: string;\n};\n\nexport type B3DMAttributesData = {\n gltfMaterials?: {id: string}[];\n nodes: GLTFNodePostprocessed[];\n images: GLTFImagePostprocessed[];\n cartographicOrigin: Vector3;\n cartesianModelMatrix: Matrix4;\n};\n\n/**\n * I3S Attributes Worker to handle B3DM object\n */\nexport const I3SAttributesWorker = {\n id: 'i3s-attributes',\n name: 'I3S Attributes Worker',\n module: 'tile-converter',\n version: VERSION,\n options: {\n useCartesianPositions: false\n }\n};\n\n/**\n * Performs I3S attributes transformation\n */\nexport function transformI3SAttributesOnWorker(\n attributesData: B3DMAttributesData,\n options: I3SAttributesWorkerOptions\n): Promise<Map<string, ConvertedAttributes>> {\n return processOnWorker(I3SAttributesWorker, attributesData, options);\n}\n\nexport const _typecheckI3SAttributesWorker: WorkerObject = I3SAttributesWorker;\n"],"mappings":"AAKA,SAAQA,eAAe,QAAO,0BAA0B;AAIxD,MAAMC,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiB,QAAQ;AAoB3E,OAAO,MAAMC,mBAAmB,GAAG;EACjCC,EAAE,EAAE,gBAAgB;EACpBC,IAAI,EAAE,uBAAuB;EAC7BC,MAAM,EAAE,gBAAgB;EACxBC,OAAO,EAAEL,OAAO;EAChBM,OAAO,EAAE;IACPC,qBAAqB,EAAE;EACzB;AACF,CAAC;AAKD,OAAO,SAASC,8BAA8BA,CAC5CC,cAAkC,EAClCH,OAAmC,EACQ;EAC3C,OAAOP,eAAe,CAACE,mBAAmB,EAAEQ,cAAc,EAAEH,OAAO,CAAC;AACtE;AAEA,OAAO,MAAMI,6BAA2C,GAAGT,mBAAmB"}
@@ -1,6 +1,5 @@
1
1
  const EXT_MESH_FEATURES = 'EXT_mesh_features';
2
2
  const EXT_FEATURE_METADATA = 'EXT_feature_metadata';
3
-
4
3
  export function handleBatchIdsExtensions(attributes, primitive, images) {
5
4
  const extensions = primitive === null || primitive === void 0 ? void 0 : primitive.extensions;
6
5
  if (!extensions) {
@@ -19,7 +18,6 @@ export function handleBatchIdsExtensions(attributes, primitive, images) {
19
18
  }
20
19
  return [];
21
20
  }
22
-
23
21
  function handleExtFeatureMetadataExtension(attributes, extFeatureMetadata, images) {
24
22
  var _extFeatureMetadata$f, _featureIdAttribute$f, _featureIdAttribute$f2, _featureIdAttribute$f3;
25
23
  const featureIdAttribute = extFeatureMetadata === null || extFeatureMetadata === void 0 ? void 0 : (_extFeatureMetadata$f = extFeatureMetadata.featureIdAttributes) === null || _extFeatureMetadata$f === void 0 ? void 0 : _extFeatureMetadata$f[0];
@@ -32,7 +30,6 @@ function handleExtFeatureMetadataExtension(attributes, extFeatureMetadata, image
32
30
  const featuresCount = (attributes === null || attributes === void 0 ? void 0 : (_attributes$POSITIONS = attributes.POSITIONS) === null || _attributes$POSITIONS === void 0 ? void 0 : _attributes$POSITIONS.value.length) / 3 || 0;
33
31
  return generateImplicitFeatureIds(featuresCount, featureIdAttribute.featureIds.constant, featureIdAttribute.featureIds.divisor);
34
32
  }
35
-
36
33
  const featureIdTexture = (extFeatureMetadata === null || extFeatureMetadata === void 0 ? void 0 : extFeatureMetadata.featureIdTextures) && (extFeatureMetadata === null || extFeatureMetadata === void 0 ? void 0 : extFeatureMetadata.featureIdTextures[0]);
37
34
  if (featureIdTexture) {
38
35
  var _featureIdTexture$fea, _featureIdTexture$fea2;
@@ -41,16 +38,13 @@ function handleExtFeatureMetadataExtension(attributes, extFeatureMetadata, image
41
38
  const textureCoordinates = attributes[textCoordAttribute].value;
42
39
  return generateBatchIdsFromTexture(featureIdTexture, textureCoordinates, images);
43
40
  }
44
-
45
41
  const featureTexture = (extFeatureMetadata === null || extFeatureMetadata === void 0 ? void 0 : extFeatureMetadata.featureTextures) && (extFeatureMetadata === null || extFeatureMetadata === void 0 ? void 0 : extFeatureMetadata.featureTextures[0]);
46
-
47
42
  if (featureTexture) {
48
43
  console.warn("EXT_feature_metadata doesn't yet support featureTextures in primitive");
49
44
  return [];
50
45
  }
51
46
  return [];
52
47
  }
53
-
54
48
  function generateImplicitFeatureIds(featuresCount) {
55
49
  let constant = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
56
50
  let divisor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
@@ -71,7 +65,6 @@ function generateImplicitFeatureIds(featuresCount) {
71
65
  }
72
66
  return featureIds;
73
67
  }
74
-
75
68
  function generateBatchIdsFromTexture(featureIdTexture, textureCoordinates, images) {
76
69
  var _featureIdTexture$fea3, _featureIdTexture$fea4, _featureIdTexture$fea5;
77
70
  if (!(images !== null && images !== void 0 && images.length)) {
@@ -106,7 +99,6 @@ function generateBatchIdsFromTexture(featureIdTexture, textureCoordinates, image
106
99
  }
107
100
  return batchIds;
108
101
  }
109
-
110
102
  function emod(n) {
111
103
  return (n % 1 + 1) % 1;
112
104
  }
@@ -1 +1 @@
1
- {"version":3,"file":"batch-ids-extensions.js","names":["EXT_MESH_FEATURES","EXT_FEATURE_METADATA","handleBatchIdsExtensions","attributes","primitive","images","extensions","extensionName","extensionData","Object","entries","handleExtFeatureMetadataExtension","console","warn","extFeatureMetadata","featureIdAttribute","featureIdAttributes","featureIds","attribute","batchIdsAttribute","value","hasOwnProperty","featuresCount","POSITIONS","length","generateImplicitFeatureIds","constant","divisor","featureIdTexture","featureIdTextures","textureAttributeIndex","texture","texCoord","textCoordAttribute","textureCoordinates","generateBatchIdsFromTexture","featureTexture","featureTextures","currentValue","devisorCounter","index","push","Array","fill","CHANNELS_MAP","r","g","b","a","textureIndex","featureChannel","channels","undefined","image","batchIds","compressed","u","v","tx","Math","min","emod","width","ty","height","offset","components","batchId","Uint8Array","data","mimeType","n"],"sources":["../../../../src/i3s-converter/helpers/batch-ids-extensions.ts"],"sourcesContent":["import {\n GLTFAccessorPostprocessed,\n GLTFImagePostprocessed,\n GLTFMeshPrimitivePostprocessed\n} from '@loaders.gl/gltf';\nimport type {\n GLTF_EXT_feature_metadata_attribute,\n GLTF_EXT_feature_metadata_primitive\n} from 'modules/gltf/src/lib/types/gltf-json-schema';\n\nconst EXT_MESH_FEATURES = 'EXT_mesh_features';\nconst EXT_FEATURE_METADATA = 'EXT_feature_metadata';\n\n/**\n * Getting batchIds from 3DTilesNext extensions.\n * @param attributes - gltf accessors\n * @param primitive - gltf primitive data\n * @param images - gltf texture images\n */\nexport function handleBatchIdsExtensions(\n attributes: {\n [key: string]: GLTFAccessorPostprocessed;\n },\n primitive: GLTFMeshPrimitivePostprocessed,\n images: GLTFImagePostprocessed[]\n): number[] {\n const extensions = primitive?.extensions;\n\n if (!extensions) {\n return [];\n }\n\n for (const [extensionName, extensionData] of Object.entries(extensions || {})) {\n switch (extensionName) {\n case EXT_FEATURE_METADATA:\n return handleExtFeatureMetadataExtension(\n attributes,\n extensionData as GLTF_EXT_feature_metadata_primitive,\n images\n );\n case EXT_MESH_FEATURES:\n console.warn('EXT_mesh_features extension is not supported yet');\n return [];\n default:\n return [];\n }\n }\n\n return [];\n}\n\n/**\n * Get batchIds from EXT_feature_metadata extension.\n * Docs - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata\n * @param attributes\n * @param extFeatureMetadata\n * @param textures\n */\nfunction handleExtFeatureMetadataExtension(\n attributes: {\n [key: string]: GLTFAccessorPostprocessed;\n },\n extFeatureMetadata: GLTF_EXT_feature_metadata_primitive,\n images: GLTFImagePostprocessed[]\n): number[] {\n // Take only first extension object to get batchIds attribute name.\n const featureIdAttribute = extFeatureMetadata?.featureIdAttributes?.[0];\n\n if (featureIdAttribute?.featureIds?.attribute) {\n const batchIdsAttribute = attributes[featureIdAttribute.featureIds.attribute];\n return batchIdsAttribute.value;\n }\n\n if (\n featureIdAttribute?.featureIds?.hasOwnProperty('constant') &&\n featureIdAttribute?.featureIds?.hasOwnProperty('divisor')\n ) {\n const featuresCount = attributes?.POSITIONS?.value.length / 3 || 0;\n return generateImplicitFeatureIds(\n featuresCount,\n featureIdAttribute.featureIds.constant,\n featureIdAttribute.featureIds.divisor\n );\n }\n\n // Take only first extension object to get batchIds attribute name.\n const featureIdTexture =\n extFeatureMetadata?.featureIdTextures && extFeatureMetadata?.featureIdTextures[0];\n\n if (featureIdTexture) {\n const textureAttributeIndex = featureIdTexture?.featureIds?.texture?.texCoord || 0;\n const textCoordAttribute = `TEXCOORD_${textureAttributeIndex}`;\n const textureCoordinates = attributes[textCoordAttribute].value;\n return generateBatchIdsFromTexture(featureIdTexture, textureCoordinates, images);\n }\n\n // Take only first extension texture to get batchIds from the root EXT_feature_metadata object.\n const featureTexture =\n extFeatureMetadata?.featureTextures && extFeatureMetadata?.featureTextures[0];\n\n /**\n * TODO need to get batchIds from root extension\n */\n if (featureTexture) {\n console.warn(\"EXT_feature_metadata doesn't yet support featureTextures in primitive\");\n return [];\n }\n\n return [];\n}\n\n/**\n * Generates implicit feature ids\n * Spec - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata#implicit-feature-ids\n * @param featuresCount\n * @param constant\n * @param devisor\n */\nfunction generateImplicitFeatureIds(\n featuresCount: number,\n constant: number = 0,\n divisor: number = 0\n): number[] {\n let featureIds: number[] = [];\n\n if (divisor > 0) {\n let currentValue = constant;\n let devisorCounter = divisor;\n\n for (let index = 0; index < featuresCount; index++) {\n featureIds.push(currentValue);\n\n devisorCounter -= 1;\n\n if (devisorCounter === 0) {\n currentValue++;\n devisorCounter = divisor;\n }\n }\n } else {\n featureIds = Array<number>(featuresCount).fill(constant, 0, featuresCount);\n }\n\n return featureIds;\n}\n\n/**\n * Get batchIds from texture.\n * @param primitive\n * @param featureIdTextures\n */\nfunction generateBatchIdsFromTexture(\n featureIdTexture: GLTF_EXT_feature_metadata_attribute,\n textureCoordinates: Float32Array,\n images: GLTFImagePostprocessed[]\n) {\n if (!images?.length) {\n return [];\n }\n\n const CHANNELS_MAP = {\n r: 0,\n g: 1,\n b: 2,\n a: 3\n };\n\n const textureIndex = featureIdTexture?.featureIds?.texture?.index;\n const featureChannel = featureIdTexture?.featureIds?.channels;\n\n if (!featureChannel || textureIndex === undefined) {\n return [];\n }\n\n const image = images[textureIndex];\n const batchIds: number[] = [];\n const channels = CHANNELS_MAP[featureChannel];\n\n if (!image.compressed) {\n for (let index = 0; index < textureCoordinates.length; index += 2) {\n const u = textureCoordinates[index];\n const v = textureCoordinates[index + 1];\n\n const tx = Math.min((emod(u) * image.width) | 0, image.width - 1);\n const ty = Math.min((emod(v) * image.height) | 0, image.height - 1);\n\n const offset = (ty * image.width + tx) * image.components + channels;\n const batchId = new Uint8Array(image.data)[offset];\n\n batchIds.push(batchId);\n }\n } else {\n console.warn(`Can't get batch Ids from ${image.mimeType} compressed texture`);\n }\n\n return batchIds;\n}\n\n/**\n * Handle UVs if they are out of range [0,1].\n * @param n\n * @param m\n */\nfunction emod(n: number): number {\n return ((n % 1) + 1) % 1;\n}\n"],"mappings":"AAUA,MAAMA,iBAAiB,GAAG,mBAAmB;AAC7C,MAAMC,oBAAoB,GAAG,sBAAsB;;AAQnD,OAAO,SAASC,wBAAwB,CACtCC,UAEC,EACDC,SAAyC,EACzCC,MAAgC,EACtB;EACV,MAAMC,UAAU,GAAGF,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEE,UAAU;EAExC,IAAI,CAACA,UAAU,EAAE;IACf,OAAO,EAAE;EACX;EAEA,KAAK,MAAM,CAACC,aAAa,EAAEC,aAAa,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACJ,UAAU,IAAI,CAAC,CAAC,CAAC,EAAE;IAC7E,QAAQC,aAAa;MACnB,KAAKN,oBAAoB;QACvB,OAAOU,iCAAiC,CACtCR,UAAU,EACVK,aAAa,EACbH,MAAM,CACP;MACH,KAAKL,iBAAiB;QACpBY,OAAO,CAACC,IAAI,CAAC,kDAAkD,CAAC;QAChE,OAAO,EAAE;MACX;QACE,OAAO,EAAE;IAAC;EAEhB;EAEA,OAAO,EAAE;AACX;;AASA,SAASF,iCAAiC,CACxCR,UAEC,EACDW,kBAAuD,EACvDT,MAAgC,EACtB;EAAA;EAEV,MAAMU,kBAAkB,GAAGD,kBAAkB,aAAlBA,kBAAkB,gDAAlBA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KAAK,CAACS,KAAK,GAAGJ,EAAE,IAAIL,KAAK,CAACa,UAAU,GAAGf,QAAQ;MACpE,MAAMgB,OAAO,GAAG,IAAIC,UAAU,CAACf,KAAK,CAACgB,IAAI,CAAC,CAACJ,MAAM,CAAC;MAElDX,QAAQ,CAACb,IAAI,CAAC0B,OAAO,CAAC;IACxB;EACF,CAAC,MAAM;IACLvD,OAAO,CAACC,IAAI,oCAA6BwC,KAAK,CAACiB,QAAQ,yBAAsB;EAC/E;EAEA,OAAOhB,QAAQ;AACjB;;AAOA,SAASO,IAAI,CAACU,CAAS,EAAU;EAC/B,OAAO,CAAEA,CAAC,GAAG,CAAC,GAAI,CAAC,IAAI,CAAC;AAC1B"}
1
+ {"version":3,"file":"batch-ids-extensions.js","names":["EXT_MESH_FEATURES","EXT_FEATURE_METADATA","handleBatchIdsExtensions","attributes","primitive","images","extensions","extensionName","extensionData","Object","entries","handleExtFeatureMetadataExtension","console","warn","extFeatureMetadata","_extFeatureMetadata$f","_featureIdAttribute$f","_featureIdAttribute$f2","_featureIdAttribute$f3","featureIdAttribute","featureIdAttributes","featureIds","attribute","batchIdsAttribute","value","hasOwnProperty","_attributes$POSITIONS","featuresCount","POSITIONS","length","generateImplicitFeatureIds","constant","divisor","featureIdTexture","featureIdTextures","_featureIdTexture$fea","_featureIdTexture$fea2","textureAttributeIndex","texture","texCoord","textCoordAttribute","concat","textureCoordinates","generateBatchIdsFromTexture","featureTexture","featureTextures","arguments","undefined","currentValue","devisorCounter","index","push","Array","fill","_featureIdTexture$fea3","_featureIdTexture$fea4","_featureIdTexture$fea5","CHANNELS_MAP","r","g","b","a","textureIndex","featureChannel","channels","image","batchIds","compressed","u","v","tx","Math","min","emod","width","ty","height","offset","components","batchId","Uint8Array","data","mimeType","n"],"sources":["../../../../src/i3s-converter/helpers/batch-ids-extensions.ts"],"sourcesContent":["import {\n GLTFAccessorPostprocessed,\n GLTFImagePostprocessed,\n GLTFMeshPrimitivePostprocessed\n} from '@loaders.gl/gltf';\nimport type {\n GLTF_EXT_feature_metadata_attribute,\n GLTF_EXT_feature_metadata_primitive\n} from 'modules/gltf/src/lib/types/gltf-json-schema';\n\nconst EXT_MESH_FEATURES = 'EXT_mesh_features';\nconst EXT_FEATURE_METADATA = 'EXT_feature_metadata';\n\n/**\n * Getting batchIds from 3DTilesNext extensions.\n * @param attributes - gltf accessors\n * @param primitive - gltf primitive data\n * @param images - gltf texture images\n */\nexport function handleBatchIdsExtensions(\n attributes: {\n [key: string]: GLTFAccessorPostprocessed;\n },\n primitive: GLTFMeshPrimitivePostprocessed,\n images: GLTFImagePostprocessed[]\n): number[] {\n const extensions = primitive?.extensions;\n\n if (!extensions) {\n return [];\n }\n\n for (const [extensionName, extensionData] of Object.entries(extensions || {})) {\n switch (extensionName) {\n case EXT_FEATURE_METADATA:\n return handleExtFeatureMetadataExtension(\n attributes,\n extensionData as GLTF_EXT_feature_metadata_primitive,\n images\n );\n case EXT_MESH_FEATURES:\n console.warn('EXT_mesh_features extension is not supported yet');\n return [];\n default:\n return [];\n }\n }\n\n return [];\n}\n\n/**\n * Get batchIds from EXT_feature_metadata extension.\n * Docs - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata\n * @param attributes\n * @param extFeatureMetadata\n * @param textures\n */\nfunction handleExtFeatureMetadataExtension(\n attributes: {\n [key: string]: GLTFAccessorPostprocessed;\n },\n extFeatureMetadata: GLTF_EXT_feature_metadata_primitive,\n images: GLTFImagePostprocessed[]\n): number[] {\n // Take only first extension object to get batchIds attribute name.\n const featureIdAttribute = extFeatureMetadata?.featureIdAttributes?.[0];\n\n if (featureIdAttribute?.featureIds?.attribute) {\n const batchIdsAttribute = attributes[featureIdAttribute.featureIds.attribute];\n return batchIdsAttribute.value;\n }\n\n if (\n featureIdAttribute?.featureIds?.hasOwnProperty('constant') &&\n featureIdAttribute?.featureIds?.hasOwnProperty('divisor')\n ) {\n const featuresCount = attributes?.POSITIONS?.value.length / 3 || 0;\n return generateImplicitFeatureIds(\n featuresCount,\n featureIdAttribute.featureIds.constant,\n featureIdAttribute.featureIds.divisor\n );\n }\n\n // Take only first extension object to get batchIds attribute name.\n const featureIdTexture =\n extFeatureMetadata?.featureIdTextures && extFeatureMetadata?.featureIdTextures[0];\n\n if (featureIdTexture) {\n const textureAttributeIndex = featureIdTexture?.featureIds?.texture?.texCoord || 0;\n const textCoordAttribute = `TEXCOORD_${textureAttributeIndex}`;\n const textureCoordinates = attributes[textCoordAttribute].value;\n return generateBatchIdsFromTexture(featureIdTexture, textureCoordinates, images);\n }\n\n // Take only first extension texture to get batchIds from the root EXT_feature_metadata object.\n const featureTexture =\n extFeatureMetadata?.featureTextures && extFeatureMetadata?.featureTextures[0];\n\n /**\n * TODO need to get batchIds from root extension\n */\n if (featureTexture) {\n console.warn(\"EXT_feature_metadata doesn't yet support featureTextures in primitive\");\n return [];\n }\n\n return [];\n}\n\n/**\n * Generates implicit feature ids\n * Spec - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata#implicit-feature-ids\n * @param featuresCount\n * @param constant\n * @param devisor\n */\nfunction generateImplicitFeatureIds(\n featuresCount: number,\n constant: number = 0,\n divisor: number = 0\n): number[] {\n let featureIds: number[] = [];\n\n if (divisor > 0) {\n let currentValue = constant;\n let devisorCounter = divisor;\n\n for (let index = 0; index < featuresCount; index++) {\n featureIds.push(currentValue);\n\n devisorCounter -= 1;\n\n if (devisorCounter === 0) {\n currentValue++;\n devisorCounter = divisor;\n }\n }\n } else {\n featureIds = Array<number>(featuresCount).fill(constant, 0, featuresCount);\n }\n\n return featureIds;\n}\n\n/**\n * Get batchIds from texture.\n * @param primitive\n * @param featureIdTextures\n */\nfunction generateBatchIdsFromTexture(\n featureIdTexture: GLTF_EXT_feature_metadata_attribute,\n textureCoordinates: Float32Array,\n images: GLTFImagePostprocessed[]\n) {\n if (!images?.length) {\n return [];\n }\n\n const CHANNELS_MAP = {\n r: 0,\n g: 1,\n b: 2,\n a: 3\n };\n\n const textureIndex = featureIdTexture?.featureIds?.texture?.index;\n const featureChannel = featureIdTexture?.featureIds?.channels;\n\n if (!featureChannel || textureIndex === undefined) {\n return [];\n }\n\n const image = images[textureIndex];\n const batchIds: number[] = [];\n const channels = CHANNELS_MAP[featureChannel];\n\n if (!image.compressed) {\n for (let index = 0; index < textureCoordinates.length; index += 2) {\n const u = textureCoordinates[index];\n const v = textureCoordinates[index + 1];\n\n const tx = Math.min((emod(u) * image.width) | 0, image.width - 1);\n const ty = Math.min((emod(v) * image.height) | 0, image.height - 1);\n\n const offset = (ty * image.width + tx) * image.components + channels;\n const batchId = new Uint8Array(image.data)[offset];\n\n batchIds.push(batchId);\n }\n } else {\n console.warn(`Can't get batch Ids from ${image.mimeType} compressed texture`);\n }\n\n return batchIds;\n}\n\n/**\n * Handle UVs if they are out of range [0,1].\n * @param n\n * @param m\n */\nfunction emod(n: number): number {\n return ((n % 1) + 1) % 1;\n}\n"],"mappings":"AAUA,MAAMA,iBAAiB,GAAG,mBAAmB;AAC7C,MAAMC,oBAAoB,GAAG,sBAAsB;AAQnD,OAAO,SAASC,wBAAwBA,CACtCC,UAEC,EACDC,SAAyC,EACzCC,MAAgC,EACtB;EACV,MAAMC,UAAU,GAAGF,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEE,UAAU;EAExC,IAAI,CAACA,UAAU,EAAE;IACf,OAAO,EAAE;EACX;EAEA,KAAK,MAAM,CAACC,aAAa,EAAEC,aAAa,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACJ,UAAU,IAAI,CAAC,CAAC,CAAC,EAAE;IAC7E,QAAQC,aAAa;MACnB,KAAKN,oBAAoB;QACvB,OAAOU,iCAAiC,CACtCR,UAAU,EACVK,aAAa,EACbH,MACF,CAAC;MACH,KAAKL,iBAAiB;QACpBY,OAAO,CAACC,IAAI,CAAC,kDAAkD,CAAC;QAChE,OAAO,EAAE;MACX;QACE,OAAO,EAAE;IACb;EACF;EAEA,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,OAAO,CAAEA,CAAC,GAAG,CAAC,GAAI,CAAC,IAAI,CAAC;AAC1B"}
@@ -26,7 +26,6 @@ export function createBoundingVolumes(tile, geoidHeightModel) {
26
26
  }
27
27
  };
28
28
  }
29
-
30
29
  export function createBoundingVolumesFromGeometry(cartesianPositions, geoidHeightModel) {
31
30
  const positionVectors = convertPositionsToVectors(cartesianPositions);
32
31
  const geometryObb = makeOrientedBoundingBoxFromPoints(positionVectors);
@@ -44,7 +43,6 @@ export function createBoundingVolumesFromGeometry(cartesianPositions, geoidHeigh
44
43
  }
45
44
  };
46
45
  }
47
-
48
46
  export function convertPositionsToVectors(positions) {
49
47
  const result = [];
50
48
  for (let i = 0; i < positions.length; i += 3) {
@@ -53,7 +51,6 @@ export function convertPositionsToVectors(positions) {
53
51
  }
54
52
  return result;
55
53
  }
56
-
57
54
  export function convertBoundingVolumeToI3SFullExtent(boundingVolume) {
58
55
  let sphere;
59
56
  if (boundingVolume instanceof BoundingSphere) {
@@ -65,7 +62,6 @@ export function convertBoundingVolumeToI3SFullExtent(boundingVolume) {
65
62
  const radius = sphere.radius;
66
63
  const vertexMax = Ellipsoid.WGS84.cartesianToCartographic(new Vector3(center[0] + radius, center[1] + radius, center[2] + radius), new Vector3());
67
64
  const vertexMin = Ellipsoid.WGS84.cartesianToCartographic(new Vector3(center[0] - radius, center[1] - radius, center[2] - radius), new Vector3());
68
-
69
65
  return {
70
66
  xmin: Math.min(vertexMin[0], vertexMax[0]),
71
67
  xmax: Math.max(vertexMin[0], vertexMax[0]),
@@ -75,7 +71,6 @@ export function convertBoundingVolumeToI3SFullExtent(boundingVolume) {
75
71
  zmax: Math.max(vertexMin[2], vertexMax[2])
76
72
  };
77
73
  }
78
-
79
74
  export function createObbFromMbs(mbs) {
80
75
  const radius = mbs[3];
81
76
  const center = new Vector3(mbs[0], mbs[1], mbs[2]);
@@ -1 +1 @@
1
- {"version":3,"file":"coordinate-converter.js","names":["Matrix3","Quaternion","Vector3","Ellipsoid","OrientedBoundingBox","makeOrientedBoundingBoxFromPoints","makeBoundingSphereFromPoints","BoundingSphere","createBoundingVolumes","tile","geoidHeightModel","radius","halfSize","quaternion","boundingVolume","cartographicCenter","WGS84","cartesianToCartographic","center","getHeight","len","fromMatrix3","normalize","mbs","obb","createBoundingVolumesFromGeometry","cartesianPositions","positionVectors","convertPositionsToVectors","geometryObb","geometryMbs","mbsCenter","obbCenter","positions","result","i","length","positionVector","push","convertBoundingVolumeToI3SFullExtent","sphere","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,SAAQA,OAAO,EAAEC,UAAU,EAAEC,OAAO,QAAO,eAAe;AAC1D,SAAQC,SAAS,QAAO,qBAAqB;AAC7C,SACEC,mBAAmB,EACnBC,iCAAiC,EACjCC,4BAA4B,EAC5BC,cAAc,QACT,kBAAkB;AAUzB,OAAO,SAASC,qBAAqB,CAACC,IAAY,EAAEC,gBAAuB,EAAmB;EAC5F,IAAIC,MAAM;EACV,IAAIC,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vector3","Ellipsoid","OrientedBoundingBox","makeOrientedBoundingBoxFromPoints","makeBoundingSphereFromPoints","BoundingSphere","createBoundingVolumes","tile","geoidHeightModel","radius","halfSize","quaternion","boundingVolume","cartographicCenter","WGS84","cartesianToCartographic","center","getHeight","len","fromMatrix3","normalize","mbs","obb","createBoundingVolumesFromGeometry","cartesianPositions","positionVectors","convertPositionsToVectors","geometryObb","geometryMbs","mbsCenter","obbCenter","positions","result","i","length","positionVector","push","convertBoundingVolumeToI3SFullExtent","sphere","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,SAAQA,OAAO,EAAEC,UAAU,EAAEC,OAAO,QAAO,eAAe;AAC1D,SAAQC,SAAS,QAAO,qBAAqB;AAC7C,SACEC,mBAAmB,EACnBC,iCAAiC,EACjCC,4BAA4B,EAC5BC,cAAc,QACT,kBAAkB;AAUzB,OAAO,SAASC,qBAAqBA,CAACC,IAAY,EAAEC,gBAAuB,EAAmB;EAC5F,IAAI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oC,QAAQ,CAAC;AAClD"}
@@ -3,7 +3,6 @@ import transform from 'json-map-transform';
3
3
  import { join } from 'path';
4
4
  import { SCENE_SERVER as sceneServerTemplate } from '../json-templates/scene-server';
5
5
  import { writeFile } from '../../lib/utils/file-utils';
6
-
7
6
  export async function createSceneServerPath(layerName, layers0, rootPath) {
8
7
  const sceneServerData = {
9
8
  serviceItemId: uuidv4().replace(/-/gi, ''),
@@ -1 +1 @@
1
- {"version":3,"file":"create-scene-server-path.js","names":["v4","uuidv4","transform","join","SCENE_SERVER","sceneServerTemplate","writeFile","createSceneServerPath","layerName","layers0","rootPath","sceneServerData","serviceItemId","replace","sceneServer","nodePagePath","JSON","stringify"],"sources":["../../../../src/i3s-converter/helpers/create-scene-server-path.ts"],"sourcesContent":["import type {SceneLayer3D} from '@loaders.gl/i3s';\nimport {v4 as uuidv4} from 'uuid';\nimport transform from 'json-map-transform';\nimport {join} from 'path';\n\nimport {SCENE_SERVER as sceneServerTemplate} from '../json-templates/scene-server';\nimport {writeFile} from '../../lib/utils/file-utils';\n\n/**\n * Form and save sceneServer meta data into a file\n * @param layerName - layer name to display\n * @param layers0 - layer object embedded into sceneServer meta data\n * @param rootPath - root path of new converted tileset\n */\nexport async function createSceneServerPath(\n layerName: string,\n layers0: SceneLayer3D,\n rootPath: string\n): Promise<void> {\n const sceneServerData = {\n serviceItemId: uuidv4().replace(/-/gi, ''),\n layerName,\n layers0\n };\n\n const sceneServer = transform(sceneServerData, sceneServerTemplate());\n const nodePagePath = join(rootPath, 'SceneServer');\n await writeFile(nodePagePath, JSON.stringify(sceneServer));\n}\n"],"mappings":"AACA,SAAQA,EAAE,IAAIC,MAAM,QAAO,MAAM;AACjC,OAAOC,SAAS,MAAM,oBAAoB;AAC1C,SAAQC,IAAI,QAAO,MAAM;AAEzB,SAAQC,YAAY,IAAIC,mBAAmB,QAAO,gCAAgC;AAClF,SAAQC,SAAS,QAAO,4BAA4B;;AAQpD,OAAO,eAAeC,qBAAqB,CACzCC,SAAiB,EACjBC,OAAqB,EACrBC,QAAgB,EACD;EACf,MAAMC,eAAe,GAAG;IACtBC,aAAa,EAAEX,MAAM,EAAE,CAACY,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;IAC1CL,SAAS;IACTC;EACF,CAAC;EAED,MAAMK,WAAW,GAAGZ,SAAS,CAACS,eAAe,EAAEN,mBAAmB,EAAE,CAAC;EACrE,MAAMU,YAAY,GAAGZ,IAAI,CAACO,QAAQ,EAAE,aAAa,CAAC;EAClD,MAAMJ,SAAS,CAACS,YAAY,EAAEC,IAAI,CAACC,SAAS,CAACH,WAAW,CAAC,CAAC;AAC5D"}
1
+ {"version":3,"file":"create-scene-server-path.js","names":["v4","uuidv4","transform","join","SCENE_SERVER","sceneServerTemplate","writeFile","createSceneServerPath","layerName","layers0","rootPath","sceneServerData","serviceItemId","replace","sceneServer","nodePagePath","JSON","stringify"],"sources":["../../../../src/i3s-converter/helpers/create-scene-server-path.ts"],"sourcesContent":["import type {SceneLayer3D} from '@loaders.gl/i3s';\nimport {v4 as uuidv4} from 'uuid';\nimport transform from 'json-map-transform';\nimport {join} from 'path';\n\nimport {SCENE_SERVER as sceneServerTemplate} from '../json-templates/scene-server';\nimport {writeFile} from '../../lib/utils/file-utils';\n\n/**\n * Form and save sceneServer meta data into a file\n * @param layerName - layer name to display\n * @param layers0 - layer object embedded into sceneServer meta data\n * @param rootPath - root path of new converted tileset\n */\nexport async function createSceneServerPath(\n layerName: string,\n layers0: SceneLayer3D,\n rootPath: string\n): Promise<void> {\n const sceneServerData = {\n serviceItemId: uuidv4().replace(/-/gi, ''),\n layerName,\n layers0\n };\n\n const sceneServer = transform(sceneServerData, sceneServerTemplate());\n const nodePagePath = join(rootPath, 'SceneServer');\n await writeFile(nodePagePath, JSON.stringify(sceneServer));\n}\n"],"mappings":"AACA,SAAQA,EAAE,IAAIC,MAAM,QAAO,MAAM;AACjC,OAAOC,SAAS,MAAM,oBAAoB;AAC1C,SAAQC,IAAI,QAAO,MAAM;AAEzB,SAAQC,YAAY,IAAIC,mBAAmB,QAAO,gCAAgC;AAClF,SAAQC,SAAS,QAAO,4BAA4B;AAQpD,OAAO,eAAeC,qBAAqBA,CACzCC,SAAiB,EACjBC,OAAqB,EACrBC,QAAgB,EACD;EACf,MAAMC,eAAe,GAAG;IACtBC,aAAa,EAAEX,MAAM,CAAC,CAAC,CAACY,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;IAC1CL,SAAS;IACTC;EACF,CAAC;EAED,MAAMK,WAAW,GAAGZ,SAAS,CAACS,eAAe,EAAEN,mBAAmB,CAAC,CAAC,CAAC;EACrE,MAAMU,YAAY,GAAGZ,IAAI,CAACO,QAAQ,EAAE,aAAa,CAAC;EAClD,MAAMJ,SAAS,CAACS,YAAY,EAAEC,IAAI,CAACC,SAAS,CAACH,WAAW,CAAC,CAAC;AAC5D"}
@@ -1,4 +1,3 @@
1
-
2
1
  export function flattenPropertyTableByFeatureIds(featureIds, propertyTable) {
3
2
  const resultPropertyTable = {};
4
3
  for (const propertyName in propertyTable) {
@@ -7,7 +6,6 @@ export function flattenPropertyTableByFeatureIds(featureIds, propertyTable) {
7
6
  }
8
7
  return resultPropertyTable;
9
8
  }
10
-
11
9
  function getPropertiesByFeatureIds(properties, featureIds) {
12
10
  const resultProperties = [];
13
11
  for (const featureId of featureIds) {
@@ -16,7 +14,6 @@ function getPropertiesByFeatureIds(properties, featureIds) {
16
14
  }
17
15
  return resultProperties;
18
16
  }
19
-
20
17
  export function checkPropertiesLength(featureIds, propertyTable) {
21
18
  let needFlatten = false;
22
19
  for (const attribute of Object.values(propertyTable)) {
@@ -26,7 +23,6 @@ export function checkPropertiesLength(featureIds, propertyTable) {
26
23
  }
27
24
  return needFlatten;
28
25
  }
29
-
30
26
  const STRING_TYPE = 'string';
31
27
  const SHORT_INT_TYPE = 'Int32';
32
28
  const DOUBLE_TYPE = 'double';
@@ -42,7 +38,6 @@ export function getAttributeType(key, attribute) {
42
38
  }
43
39
  return STRING_TYPE;
44
40
  }
45
-
46
41
  export function createdStorageAttribute(attributeIndex, key, attributeType) {
47
42
  const storageAttribute = {
48
43
  key: "f_".concat(attributeIndex),
@@ -74,7 +69,6 @@ export function createdStorageAttribute(attributeIndex, key, attributeType) {
74
69
  }
75
70
  return storageAttribute;
76
71
  }
77
-
78
72
  export function getFieldAttributeType(attributeType) {
79
73
  switch (attributeType) {
80
74
  case OBJECT_ID_TYPE:
@@ -89,7 +83,6 @@ export function getFieldAttributeType(attributeType) {
89
83
  return 'esriFieldTypeString';
90
84
  }
91
85
  }
92
-
93
86
  export function createFieldAttribute(key, fieldAttributeType) {
94
87
  return {
95
88
  name: key,
@@ -97,7 +90,6 @@ export function createFieldAttribute(key, fieldAttributeType) {
97
90
  alias: key
98
91
  };
99
92
  }
100
-
101
93
  export function createPopupInfo(propertyTable) {
102
94
  const title = '{OBJECTID}';
103
95
  const mediaInfos = [];
@@ -124,7 +116,6 @@ export function createPopupInfo(propertyTable) {
124
116
  expressionInfos
125
117
  };
126
118
  }
127
-
128
119
  function setupStringAttribute(storageAttribute) {
129
120
  storageAttribute.ordering.unshift('attributeByteCounts');
130
121
  storageAttribute.header.push({
@@ -141,14 +132,12 @@ function setupStringAttribute(storageAttribute) {
141
132
  valuesPerElement: 1
142
133
  };
143
134
  }
144
-
145
135
  function setupIdAttribute(storageAttribute) {
146
136
  storageAttribute.attributeValues = {
147
137
  valueType: 'Oid32',
148
138
  valuesPerElement: 1
149
139
  };
150
140
  }
151
-
152
141
  function setupDoubleAttribute(storageAttribute) {
153
142
  storageAttribute.attributeValues = {
154
143
  valueType: 'Float64',
@@ -1 +1 @@
1
- {"version":3,"file":"feature-attributes.js","names":["flattenPropertyTableByFeatureIds","featureIds","propertyTable","resultPropertyTable","propertyName","properties","getPropertiesByFeatureIds","resultProperties","featureId","property","push","checkPropertiesLength","needFlatten","attribute","Object","values","length","STRING_TYPE","SHORT_INT_TYPE","DOUBLE_TYPE","OBJECT_ID_TYPE","getAttributeType","key","Number","isInteger","createdStorageAttribute","attributeIndex","attributeType","storageAttribute","name","ordering","header","valueType","attributeValues","valuesPerElement","setupIdAttribute","setupStringAttribute","setupDoubleAttribute","getFieldAttributeType","createFieldAttribute","fieldAttributeType","type","alias","createPopupInfo","title","mediaInfos","fieldInfos","popupElements","expressionInfos","fieldName","visible","isEditable","label","unshift","encoding","attributeByteCounts"],"sources":["../../../../src/i3s-converter/helpers/feature-attributes.ts"],"sourcesContent":["import type {FeatureTableJson} from '@loaders.gl/3d-tiles';\nimport {\n Attribute,\n AttributeStorageInfo,\n ESRIField,\n Field,\n FieldInfo,\n PopupInfo\n} from '@loaders.gl/i3s';\n\n/**\n * Takes attributes from property table based on featureIds.\n * If there is no property value for particular featureId (index) the property will be null.\n * Example:\n * Initial data:\n * OBJECTID: [0, 1, 5]\n * component: ['Windows', 'Frames', 'Wall', 'Roof', 'Skylight']\n * Result:\n * OBJECTID: [0, 1, 5]\n * component: ['Windows', 'Frames', 'null']\n * @param featureIds\n * @param propertyTable\n */\nexport function flattenPropertyTableByFeatureIds(\n featureIds: number[],\n propertyTable: FeatureTableJson\n): FeatureTableJson {\n const resultPropertyTable: FeatureTableJson = {};\n for (const propertyName in propertyTable) {\n const properties = propertyTable[propertyName];\n resultPropertyTable[propertyName] = getPropertiesByFeatureIds(properties, featureIds);\n }\n\n return resultPropertyTable;\n}\n\n/**\n * Getting properties by featureId index\n * @param properties\n * @param featureIds\n */\nfunction getPropertiesByFeatureIds(properties: any[], featureIds: number[]): any[] {\n const resultProperties: any = [];\n\n for (const featureId of featureIds) {\n const property = properties[featureId] || null;\n resultProperties.push(property);\n }\n\n return resultProperties;\n}\n\n/**\n * Check that all attributes in propertyTable have the same length as FeatureIds.\n * If there are differencies between lengths we should flatten property table based on exiesting featureIds.\n * @param featureIds\n * @param propertyTable\n * @returns\n */\nexport function checkPropertiesLength(\n featureIds: number[],\n propertyTable: FeatureTableJson\n): boolean {\n let needFlatten = false;\n\n for (const attribute of Object.values(propertyTable)) {\n if (featureIds.length !== attribute.length) {\n needFlatten = true;\n }\n }\n\n return needFlatten;\n}\n\n/** String data type name for feature attributes */\nconst STRING_TYPE = 'string';\n/** Integer data type name for feature attributes */\nconst SHORT_INT_TYPE = 'Int32';\n/** Double data type name for feature attributes */\nconst DOUBLE_TYPE = 'double';\n/** Type of attribute that is linked with feature ids */\nconst OBJECT_ID_TYPE = 'OBJECTID';\n/**\n * Get the attribute type for attributeStorageInfo https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md\n * @param key - attribute's key\n * @param attribute - attribute's type in propertyTable\n */\nexport function getAttributeType(key: string, attribute: string): string {\n if (key === OBJECT_ID_TYPE) {\n return OBJECT_ID_TYPE;\n }\n if (typeof attribute === STRING_TYPE) {\n return STRING_TYPE;\n } else if (typeof attribute === 'number') {\n return Number.isInteger(attribute) ? SHORT_INT_TYPE : DOUBLE_TYPE;\n }\n return STRING_TYPE;\n}\n\n/**\n * Generate storage attribute for map segmentation.\n * @param attributeIndex - order index of attribute (f_0, f_1 ...).\n * @param key - attribute key from propertyTable.\n * @param attributeType - attribute type.\n * @return Updated storageAttribute.\n */\nexport function createdStorageAttribute(\n attributeIndex: number,\n key: string,\n attributeType: Attribute\n): AttributeStorageInfo {\n const storageAttribute = {\n key: `f_${attributeIndex}`,\n name: key,\n ordering: ['attributeValues'],\n header: [{property: 'count', valueType: 'UInt32'}],\n attributeValues: {valueType: 'Int32', valuesPerElement: 1}\n };\n\n switch (attributeType) {\n case OBJECT_ID_TYPE:\n setupIdAttribute(storageAttribute);\n break;\n case STRING_TYPE:\n setupStringAttribute(storageAttribute);\n break;\n case DOUBLE_TYPE:\n setupDoubleAttribute(storageAttribute);\n break;\n case SHORT_INT_TYPE:\n break;\n default:\n setupStringAttribute(storageAttribute);\n }\n\n return storageAttribute;\n}\n\n/**\n * Find and return attribute type based on key form propertyTable.\n * @param attributeType\n */\nexport function getFieldAttributeType(attributeType: Attribute): ESRIField {\n switch (attributeType) {\n case OBJECT_ID_TYPE:\n return 'esriFieldTypeOID';\n case STRING_TYPE:\n return 'esriFieldTypeString';\n case SHORT_INT_TYPE:\n return 'esriFieldTypeInteger';\n case DOUBLE_TYPE:\n return 'esriFieldTypeDouble';\n default:\n return 'esriFieldTypeString';\n }\n}\n\n/**\n * Setup field attribute for map segmentation.\n * @param key - attribute for map segmentation.\n * @param fieldAttributeType - esri attribute type ('esriFieldTypeString' or 'esriFieldTypeOID').\n */\nexport function createFieldAttribute(key: string, fieldAttributeType: ESRIField): Field {\n return {\n name: key,\n type: fieldAttributeType,\n alias: key\n };\n}\n\n/**\n * Generate popup info to show metadata on the map.\n * @param propertyTable - table data with OBJECTID.\n * @return data for correct rendering of popup.\n */\nexport function createPopupInfo(propertyTable: FeatureTableJson): PopupInfo {\n const title = '{OBJECTID}';\n const mediaInfos = [];\n const fieldInfos: FieldInfo[] = [];\n const popupElements: {\n fieldInfos: FieldInfo[];\n type: string;\n }[] = [];\n const expressionInfos = [];\n\n for (const key in propertyTable) {\n fieldInfos.push({\n fieldName: key,\n visible: true,\n isEditable: false,\n label: key\n });\n }\n popupElements.push({\n fieldInfos,\n type: 'fields'\n });\n\n return {\n title,\n mediaInfos,\n popupElements,\n fieldInfos,\n expressionInfos\n };\n}\n\n/**\n * Setup storage attribute as string.\n * @param storageAttribute - attribute for map segmentation.\n */\nfunction setupStringAttribute(storageAttribute: AttributeStorageInfo): void {\n // @ts-expect-error\n storageAttribute.ordering.unshift('attributeByteCounts');\n storageAttribute.header.push({property: 'attributeValuesByteCount', valueType: 'UInt32'});\n storageAttribute.attributeValues = {\n valueType: 'String',\n encoding: 'UTF-8',\n valuesPerElement: 1\n };\n storageAttribute.attributeByteCounts = {\n valueType: 'UInt32',\n valuesPerElement: 1\n };\n}\n\n/**\n * Setup Id attribute for map segmentation.\n * @param storageAttribute - attribute for map segmentation .\n */\nfunction setupIdAttribute(storageAttribute: AttributeStorageInfo): void {\n storageAttribute.attributeValues = {\n valueType: 'Oid32',\n valuesPerElement: 1\n };\n}\n\n/**\n * Setup double attribute for map segmentation.\n * @param storageAttribute - attribute for map segmentation .\n */\nfunction setupDoubleAttribute(storageAttribute: AttributeStorageInfo): void {\n storageAttribute.attributeValues = {\n valueType: 'Float64',\n valuesPerElement: 1\n };\n}\n"],"mappings":";AAuBA,OAAO,SAASA,gCAAgC,CAC9CC,UAAoB,EACpBC,aAA+B,EACb;EAClB,MAAMC,mBAAqC,GAAG,CAAC,CAAC;EAChD,KAAK,MAAMC,YAAY,IAAIF,aAAa,EAAE;IACxC,MAAMG,UAAU,GAAGH,aAAa,CAACE,YAAY,CAAC;IAC9CD,mBAAmB,CAACC,YAAY,CAAC,GAAGE,yBAAyB,CAACD,UAAU,EAAEJ,UAAU,CAAC;EACvF;EAEA,OAAOE,mBAAmB;AAC5B;;AAOA,SAASG,yBAAyB,CAACD,UAAiB,EAAEJ,UAAoB,EAAS;EACjF,MAAMM,gBAAqB,GAAG,EAAE;EAEhC,KAAK,MAAMC,SAAS,IAAIP,UAAU,EAAE;IAClC,MAAMQ,QAAQ,GAAGJ,UAAU,CAACG,SAAS,CAAC,IAAI,IAAI;IAC9CD,gBAAgB,CAACG,IAAI,CAACD,QAAQ,CAAC;EACjC;EAEA,OAAOF,gBAAgB;AACzB;;AASA,OAAO,SAASI,qBAAqB,CACnCV,UAAoB,EACpBC,aAA+B,EACtB;EACT,IAAIU,WAAW,GAAG,KAAK;EAEvB,KAAK,MAAMC,SAAS,IAAIC,MAAM,CAACC,MAAM,CAACb,aAAa,CAAC,EAAE;IACpD,IAAID,UAAU,CAACe,MAAM,KAAKH,SAAS,CAACG,MAAM,EAAE;MAC1CJ,WAAW,GAAG,IAAI;IACpB;EACF;EAEA,OAAOA,WAAW;AACpB;;AAGA,MAAMK,WAAW,GAAG,QAAQ;AAE5B,MAAMC,cAAc,GAAG,OAAO;AAE9B,MAAMC,WAAW,GAAG,QAAQ;AAE5B,MAAMC,cAAc,GAAG,UAAU;AAMjC,OAAO,SAASC,gBAAg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AAMA,SAASC,gBAAgB,CAACP,gBAAsC,EAAQ;EACtEA,gBAAgB,CAACK,eAAe,GAAG;IACjCD,SAAS,EAAE,OAAO;IAClBE,gBAAgB,EAAE;EACpB,CAAC;AACH;;AAMA,SAASG,oBAAoB,CAACT,gBAAsC,EAAQ;EAC1EA,gBAAgB,CAACK,eAAe,GAAG;IACjCD,SAAS,EAAE,SAAS;IACpBE,gBAAgB,EAAE;EACpB,CAAC;AACH"}
1
+ {"version":3,"file":"feature-attributes.js","names":["flattenPropertyTableByFeatureIds","featureIds","propertyTable","resultPropertyTable","propertyName","properties","getPropertiesByFeatureIds","resultProperties","featureId","property","push","checkPropertiesLength","needFlatten","attribute","Object","values","length","STRING_TYPE","SHORT_INT_TYPE","DOUBLE_TYPE","OBJECT_ID_TYPE","getAttributeType","key","Number","isInteger","createdStorageAttribute","attributeIndex","attributeType","storageAttribute","concat","name","ordering","header","valueType","attributeValues","valuesPerElement","setupIdAttribute","setupStringAttribute","setupDoubleAttribute","getFieldAttributeType","createFieldAttribute","fieldAttributeType","type","alias","createPopupInfo","title","mediaInfos","fieldInfos","popupElements","expressionInfos","fieldName","visible","isEditable","label","unshift","encoding","attributeByteCounts"],"sources":["../../../../src/i3s-converter/helpers/feature-attributes.ts"],"sourcesContent":["import type {FeatureTableJson} from '@loaders.gl/3d-tiles';\nimport {\n Attribute,\n AttributeStorageInfo,\n ESRIField,\n Field,\n FieldInfo,\n PopupInfo\n} from '@loaders.gl/i3s';\n\n/**\n * Takes attributes from property table based on featureIds.\n * If there is no property value for particular featureId (index) the property will be null.\n * Example:\n * Initial data:\n * OBJECTID: [0, 1, 5]\n * component: ['Windows', 'Frames', 'Wall', 'Roof', 'Skylight']\n * Result:\n * OBJECTID: [0, 1, 5]\n * component: ['Windows', 'Frames', 'null']\n * @param featureIds\n * @param propertyTable\n */\nexport function flattenPropertyTableByFeatureIds(\n featureIds: number[],\n propertyTable: FeatureTableJson\n): FeatureTableJson {\n const resultPropertyTable: FeatureTableJson = {};\n for (const propertyName in propertyTable) {\n const properties = propertyTable[propertyName];\n resultPropertyTable[propertyName] = getPropertiesByFeatureIds(properties, featureIds);\n }\n\n return resultPropertyTable;\n}\n\n/**\n * Getting properties by featureId index\n * @param properties\n * @param featureIds\n */\nfunction getPropertiesByFeatureIds(properties: any[], featureIds: number[]): any[] {\n const resultProperties: any = [];\n\n for (const featureId of featureIds) {\n const property = properties[featureId] || null;\n resultProperties.push(property);\n }\n\n return resultProperties;\n}\n\n/**\n * Check that all attributes in propertyTable have the same length as FeatureIds.\n * If there are differencies between lengths we should flatten property table based on exiesting featureIds.\n * @param featureIds\n * @param propertyTable\n * @returns\n */\nexport function checkPropertiesLength(\n featureIds: number[],\n propertyTable: FeatureTableJson\n): boolean {\n let needFlatten = false;\n\n for (const attribute of Object.values(propertyTable)) {\n if (featureIds.length !== attribute.length) {\n needFlatten = true;\n }\n }\n\n return needFlatten;\n}\n\n/** String data type name for feature attributes */\nconst STRING_TYPE = 'string';\n/** Integer data type name for feature attributes */\nconst SHORT_INT_TYPE = 'Int32';\n/** Double data type name for feature attributes */\nconst DOUBLE_TYPE = 'double';\n/** Type of attribute that is linked with feature ids */\nconst OBJECT_ID_TYPE = 'OBJECTID';\n/**\n * Get the attribute type for attributeStorageInfo https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md\n * @param key - attribute's key\n * @param attribute - attribute's type in propertyTable\n */\nexport function getAttributeType(key: string, attribute: string): string {\n if (key === OBJECT_ID_TYPE) {\n return OBJECT_ID_TYPE;\n }\n if (typeof attribute === STRING_TYPE) {\n return STRING_TYPE;\n } else if (typeof attribute === 'number') {\n return Number.isInteger(attribute) ? SHORT_INT_TYPE : DOUBLE_TYPE;\n }\n return STRING_TYPE;\n}\n\n/**\n * Generate storage attribute for map segmentation.\n * @param attributeIndex - order index of attribute (f_0, f_1 ...).\n * @param key - attribute key from propertyTable.\n * @param attributeType - attribute type.\n * @return Updated storageAttribute.\n */\nexport function createdStorageAttribute(\n attributeIndex: number,\n key: string,\n attributeType: Attribute\n): AttributeStorageInfo {\n const storageAttribute = {\n key: `f_${attributeIndex}`,\n name: key,\n ordering: ['attributeValues'],\n header: [{property: 'count', valueType: 'UInt32'}],\n attributeValues: {valueType: 'Int32', valuesPerElement: 1}\n };\n\n switch (attributeType) {\n case OBJECT_ID_TYPE:\n setupIdAttribute(storageAttribute);\n break;\n case STRING_TYPE:\n setupStringAttribute(storageAttribute);\n break;\n case DOUBLE_TYPE:\n setupDoubleAttribute(storageAttribute);\n break;\n case SHORT_INT_TYPE:\n break;\n default:\n setupStringAttribute(storageAttribute);\n }\n\n return storageAttribute;\n}\n\n/**\n * Find and return attribute type based on key form propertyTable.\n * @param attributeType\n */\nexport function getFieldAttributeType(attributeType: Attribute): ESRIField {\n switch (attributeType) {\n case OBJECT_ID_TYPE:\n return 'esriFieldTypeOID';\n case STRING_TYPE:\n return 'esriFieldTypeString';\n case SHORT_INT_TYPE:\n return 'esriFieldTypeInteger';\n case DOUBLE_TYPE:\n return 'esriFieldTypeDouble';\n default:\n return 'esriFieldTypeString';\n }\n}\n\n/**\n * Setup field attribute for map segmentation.\n * @param key - attribute for map segmentation.\n * @param fieldAttributeType - esri attribute type ('esriFieldTypeString' or 'esriFieldTypeOID').\n */\nexport function createFieldAttribute(key: string, fieldAttributeType: ESRIField): Field {\n return {\n name: key,\n type: fieldAttributeType,\n alias: key\n };\n}\n\n/**\n * Generate popup info to show metadata on the map.\n * @param propertyTable - table data with OBJECTID.\n * @return data for correct rendering of popup.\n */\nexport function createPopupInfo(propertyTable: FeatureTableJson): PopupInfo {\n const title = '{OBJECTID}';\n const mediaInfos = [];\n const fieldInfos: FieldInfo[] = [];\n const popupElements: {\n fieldInfos: FieldInfo[];\n type: string;\n }[] = [];\n const expressionInfos = [];\n\n for (const key in propertyTable) {\n fieldInfos.push({\n fieldName: key,\n visible: true,\n isEditable: false,\n label: key\n });\n }\n popupElements.push({\n fieldInfos,\n type: 'fields'\n });\n\n return {\n title,\n mediaInfos,\n popupElements,\n fieldInfos,\n expressionInfos\n };\n}\n\n/**\n * Setup storage attribute as string.\n * @param storageAttribute - attribute for map segmentation.\n */\nfunction setupStringAttribute(storageAttribute: AttributeStorageInfo): void {\n // @ts-expect-error\n storageAttribute.ordering.unshift('attributeByteCounts');\n storageAttribute.header.push({property: 'attributeValuesByteCount', valueType: 'UInt32'});\n storageAttribute.attributeValues = {\n valueType: 'String',\n encoding: 'UTF-8',\n valuesPerElement: 1\n };\n storageAttribute.attributeByteCounts = {\n valueType: 'UInt32',\n valuesPerElement: 1\n };\n}\n\n/**\n * Setup Id attribute for map segmentation.\n * @param storageAttribute - attribute for map segmentation .\n */\nfunction setupIdAttribute(storageAttribute: AttributeStorageInfo): void {\n storageAttribute.attributeValues = {\n valueType: 'Oid32',\n valuesPerElement: 1\n };\n}\n\n/**\n * Setup double attribute for map segmentation.\n * @param storageAttribute - attribute for map segmentation .\n */\nfunction setupDoubleAttribute(storageAttribute: AttributeStorageInfo): void {\n storageAttribute.attributeValues = {\n valueType: 'Float64',\n valuesPerElement: 1\n };\n}\n"],"mappings":"AAuBA,OAAO,SAASA,gCAAgCA,CAC9CC,UAAoB,EACpBC,aAA+B,EACb;EAClB,MAAMC,mBAAqC,GAAG,CAAC,CAAC;EAChD,KAAK,MAAMC,YAAY,IAAIF,aAAa,EAAE;IACxC,MAAMG,UAAU,GAAGH,aAAa,CAACE,YAAY,CAAC;IAC9CD,mBAAmB,CAACC,YAAY,CAAC,GAAGE,yBAAyB,CAACD,UAAU,EAAEJ,UAAU,CAAC;EACvF;EAEA,OAAOE,mBAAmB;AAC5B;AAOA,SAASG,yBAAyBA,CAACD,UAAiB,EAAEJ,UAAoB,EAAS;EACjF,MAAMM,gBAAqB,GAAG,EAAE;EAEhC,KAAK,MAAMC,SAAS,IAAIP,UAAU,EAAE;IAClC,MAAMQ,QAAQ,GAAGJ,UAAU,CAACG,SAAS,CAAC,IAAI,IAAI;IAC9CD,gBAAgB,CA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IACLG,KAAK;IACLC,UAAU;IACVE,aAAa;IACbD,UAAU;IACVE;EACF,CAAC;AACH;AAMA,SAASZ,oBAAoBA,CAACT,gBAAsC,EAAQ;EAE1EA,gBAAgB,CAACG,QAAQ,CAACuB,OAAO,CAAC,qBAAqB,CAAC;EACxD1B,gBAAgB,CAACI,MAAM,CAACtB,IAAI,CAAC;IAACD,QAAQ,EAAE,0BAA0B;IAAEwB,SAAS,EAAE;EAAQ,CAAC,CAAC;EACzFL,gBAAgB,CAACM,eAAe,GAAG;IACjCD,SAAS,EAAE,QAAQ;IACnBsB,QAAQ,EAAE,OAAO;IACjBpB,gBAAgB,EAAE;EACpB,CAAC;EACDP,gBAAgB,CAAC4B,mBAAmB,GAAG;IACrCvB,SAAS,EAAE,QAAQ;IACnBE,gBAAgB,EAAE;EACpB,CAAC;AACH;AAMA,SAASC,gBAAgBA,CAACR,gBAAsC,EAAQ;EACtEA,gBAAgB,CAACM,eAAe,GAAG;IACjCD,SAAS,EAAE,OAAO;IAClBE,gBAAgB,EAAE;EACpB,CAAC;AACH;AAMA,SAASG,oBAAoBA,CAACV,gBAAsC,EAAQ;EAC1EA,gBAAgB,CAACM,eAAe,GAAG;IACjCD,SAAS,EAAE,SAAS;IACpBE,gBAAgB,EAAE;EACpB,CAAC;AACH"}
@@ -1,7 +1,6 @@
1
1
  import { concatenateTypedArrays } from '@loaders.gl/loader-utils';
2
2
  const VALUES_PER_VERTEX = 3;
3
3
  const POSITIONS_AND_NORMALS_PER_TRIANGLE = 9;
4
-
5
4
  export function generateAttributes(attributes) {
6
5
  const {
7
6
  positions,
@@ -33,7 +32,6 @@ export function generateAttributes(attributes) {
33
32
  const groupedAttributes = groupAttributesAndRangesByFeatureId(unifiedAttributeObjectsByFeatureIds, data.featureCount);
34
33
  return groupedAttributes;
35
34
  }
36
-
37
35
  function calculateFaceRangesAndFeaturesCount(featureIndices) {
38
36
  let rangeIndex = 1;
39
37
  let featureIndex = 1;
@@ -66,7 +64,6 @@ function calculateFaceRangesAndFeaturesCount(featureIndices) {
66
64
  featureIds
67
65
  };
68
66
  }
69
-
70
67
  function getFrequentValue(values) {
71
68
  const map = {};
72
69
  let mostFrequentValue = values[0];
@@ -78,7 +75,6 @@ function getFrequentValue(values) {
78
75
  }
79
76
  return mostFrequentValue;
80
77
  }
81
-
82
78
  function makeAttributeObjects(attributes) {
83
79
  const {
84
80
  featureIds,
@@ -119,7 +115,6 @@ function makeAttributeObjects(attributes) {
119
115
  }
120
116
  return groupedData.sort((first, second) => first.featureId - second.featureId);
121
117
  }
122
-
123
118
  function getSliceAttributeCount(attributeName, startIndex, endIndex) {
124
119
  const itemsPerVertex4 = 4;
125
120
  const texCoordsPerVertex = 2;
@@ -138,7 +133,6 @@ function getSliceAttributeCount(attributeName, startIndex, endIndex) {
138
133
  return 0;
139
134
  }
140
135
  }
141
-
142
136
  function unifyObjectsByFeatureId(sortedData) {
143
137
  const uniqueObjects = [];
144
138
  for (let index = 0; index < sortedData.length; index++) {
@@ -155,7 +149,6 @@ function unifyObjectsByFeatureId(sortedData) {
155
149
  }
156
150
  return uniqueObjects;
157
151
  }
158
-
159
152
  function groupAttributesAndRangesByFeatureId(unifiedObjects, featureCount) {
160
153
  const firstAttributeObject = unifiedObjects[0];
161
154
  const featureIds = [firstAttributeObject.featureId || 0];
@@ -1 +1 @@
1
- {"version":3,"file":"geometry-attributes.js","names":["concatenateTypedArrays","VALUES_PER_VERTEX","POSITIONS_AND_NORMALS_PER_TRIANGLE","generateAttributes","attributes","positions","normals","texCoords","colors","uvRegions","featureIndices","triangleCount","length","faceRange","Uint32Array","featureIds","featureCount","data","calculateFaceRangesAndFeaturesCount","attributeObjects","makeAttributeObjects","unifiedAttributeObjectsByFeatureIds","unifyObjectsByFeatureId","groupedAttributes","groupAttributesAndRangesByFeatureId","rangeIndex","featureIndex","currentFeatureId","getFrequentValue","slice","faceRangeList","uniqueFeatureIds","index","newFeatureId","includes","push","values","map","mostFrequentValue","maxCount","value","groupedData","positionsList","Float32Array","normalsList","colorsList","Uint8Array","texCoordsList","uvRegionsList","Uint16Array","startIndex","endIndex","positionsCount","getSliceAttributeCount","normalsCount","colorsCount","uvRegionsCount","texCoordsCount","featureId","sort","first","second","attributeName","itemsPerVertex4","texCoordsPerVertex","trianglesCount","vertexCount","sortedData","uniqueObjects","currentObject","existedObject","find","obj","unifiedObjects","firstAttributeObject","range","objIndex","sum","currentAttributesObject","groupedObject"],"sources":["../../../../src/i3s-converter/helpers/geometry-attributes.ts"],"sourcesContent":["import type {GeometryAttributes, ConvertedAttributes, GroupedByFeatureIdAttributes} from '../types';\nimport {concatenateTypedArrays} from '@loaders.gl/loader-utils';\n\nconst VALUES_PER_VERTEX = 3;\nconst POSITIONS_AND_NORMALS_PER_TRIANGLE = 9;\n\n/**\n * Generate geometry attributes with faceRange and featureCount\n * @param attributes\n * @returns attirbutes with featureCount, featureIds and changed faceRange.\n */\nexport function generateAttributes(attributes: ConvertedAttributes): GeometryAttributes {\n const {positions, normals, texCoords, colors, uvRegions, featureIndices} = attributes;\n const triangleCount = positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;\n\n if (!featureIndices.length) {\n return {\n faceRange: new Uint32Array([0, triangleCount - 1]),\n featureIds: [0],\n featureCount: 1,\n positions,\n normals,\n texCoords,\n colors,\n uvRegions\n };\n }\n\n const data = calculateFaceRangesAndFeaturesCount(featureIndices);\n const attributeObjects = makeAttributeObjects({...data, ...attributes});\n const unifiedAttributeObjectsByFeatureIds = unifyObjectsByFeatureId(attributeObjects);\n const groupedAttributes = groupAttributesAndRangesByFeatureId(\n unifiedAttributeObjectsByFeatureIds,\n data.featureCount\n );\n return groupedAttributes;\n}\n\n/**\n * Calculates face Ranges and feature count based on featureIndices.\n * @param featureIndices\n * @returns Object with featureCount, reordered attributes and changed faceRange.\n */\nfunction calculateFaceRangesAndFeaturesCount(featureIndices: number[]): {\n faceRange: Uint32Array;\n featureCount: number;\n featureIds: number[];\n} {\n let rangeIndex = 1;\n let featureIndex = 1;\n let currentFeatureId = getFrequentValue(featureIndices.slice(0, VALUES_PER_VERTEX));\n const faceRangeList: any[] = [];\n const featureIds: any[] = [];\n const uniqueFeatureIds = [currentFeatureId];\n\n faceRangeList[0] = 0;\n featureIds[0] = currentFeatureId;\n\n for (let index = VALUES_PER_VERTEX; index < featureIndices.length; index += VALUES_PER_VERTEX) {\n const newFeatureId = getFrequentValue(featureIndices.slice(index, index + VALUES_PER_VERTEX));\n if (currentFeatureId !== newFeatureId) {\n faceRangeList[rangeIndex] = index / VALUES_PER_VERTEX - 1;\n faceRangeList[rangeIndex + 1] = index / VALUES_PER_VERTEX;\n featureIds[featureIndex] = newFeatureId;\n\n if (!uniqueFeatureIds.includes(newFeatureId)) {\n uniqueFeatureIds.push(newFeatureId);\n }\n\n rangeIndex += 2;\n featureIndex += 1;\n }\n currentFeatureId = newFeatureId;\n }\n\n faceRangeList[rangeIndex] = featureIndices.length / VALUES_PER_VERTEX - 1;\n\n const faceRange = new Uint32Array(faceRangeList);\n const featureCount = uniqueFeatureIds.length;\n\n return {faceRange, featureCount, featureIds};\n}\n\n/**\n * Find most frequent value to avoid situation where one vertex can be part of multiple features (objects).\n * @param values\n */\nfunction getFrequentValue(values: number[]): number {\n const map: {[key: number]: number} = {};\n\n let mostFrequentValue = values[0];\n let maxCount = 1;\n\n for (const value of values) {\n // Save item and it's frequency count to the map.\n map[value] = (map[value] || 0) + 1;\n // Find max count of frequency.\n maxCount = maxCount > map[value] ? maxCount : map[value];\n // Find the most frequent value.\n mostFrequentValue = maxCount > map[value] ? mostFrequentValue : value;\n }\n\n return mostFrequentValue;\n}\n\n/**\n * Generate list of attribute object grouped by feature ids.\n * @param attributes\n * @returns sorted list of attribute objects.\n */\nfunction makeAttributeObjects(attributes: GeometryAttributes): GroupedByFeatureIdAttributes[] {\n const {\n featureIds,\n positions,\n normals,\n colors,\n uvRegions,\n texCoords,\n faceRange = new Uint32Array(0)\n } = attributes;\n const groupedData: GroupedByFeatureIdAttributes[] = [];\n\n let positionsList = new Float32Array(positions);\n let normalsList = new Float32Array(normals);\n let colorsList = new Uint8Array(colors);\n let texCoordsList = new Float32Array(texCoords);\n let uvRegionsList = new Uint16Array(uvRegions);\n\n for (let index = 0; index < featureIds.length; index++) {\n const startIndex = faceRange[index * 2];\n const endIndex = faceRange[index * 2 + 1];\n\n const positionsCount = getSliceAttributeCount('positions', startIndex, endIndex);\n const normalsCount = getSliceAttributeCount('normals', startIndex, endIndex);\n const colorsCount = getSliceAttributeCount('colors', startIndex, endIndex);\n const uvRegionsCount = getSliceAttributeCount('uvRegions', startIndex, endIndex);\n const texCoordsCount = getSliceAttributeCount('texCoords', startIndex, endIndex);\n\n groupedData.push({\n featureId: featureIds[index],\n positions: positionsList.slice(0, positionsCount),\n normals: normalsList.slice(0, normalsCount),\n colors: colorsList.slice(0, colorsCount),\n uvRegions: uvRegionsList.slice(0, uvRegionsCount),\n texCoords: texCoordsList.slice(0, texCoordsCount)\n });\n\n positionsList = positionsList.slice(positionsCount);\n normalsList = normalsList.slice(normalsCount);\n colorsList = colorsList.slice(colorsCount);\n uvRegionsList = uvRegionsList.slice(uvRegionsCount);\n texCoordsList = texCoordsList.slice(texCoordsCount);\n }\n\n return groupedData.sort((first, second) => first.featureId - second.featureId);\n}\n\n/**\n * Generate sliced count for generating attribute objects depends on attribute name and range.\n * @param attributeName\n * @param startIndex\n * @param endIndex\n * @returns sliced count\n */\nfunction getSliceAttributeCount(\n attributeName: string,\n startIndex: number,\n endIndex: number\n): number {\n const itemsPerVertex4 = 4;\n const texCoordsPerVertex = 2;\n\n const trianglesCount = endIndex - startIndex + 1;\n const vertexCount = trianglesCount * 3;\n\n switch (attributeName) {\n case 'positions':\n case 'normals':\n return trianglesCount * POSITIONS_AND_NORMALS_PER_TRIANGLE;\n case 'colors':\n case 'uvRegions':\n return vertexCount * itemsPerVertex4;\n case 'texCoords':\n return vertexCount * texCoordsPerVertex;\n default:\n return 0;\n }\n}\n\n/**\n * Generates unique object list depends on feature ids and concantenate their attributes.\n * @param sortedData\n * @returns unique list of objects\n */\nfunction unifyObjectsByFeatureId(\n sortedData: GroupedByFeatureIdAttributes[]\n): GroupedByFeatureIdAttributes[] {\n const uniqueObjects: GroupedByFeatureIdAttributes[] = [];\n\n for (let index = 0; index < sortedData.length; index++) {\n const currentObject = sortedData[index];\n const existedObject = uniqueObjects.find((obj) => obj.featureId === currentObject.featureId);\n\n if (existedObject) {\n existedObject.positions = concatenateTypedArrays(\n existedObject.positions,\n currentObject.positions\n );\n existedObject.normals = concatenateTypedArrays(existedObject.normals, currentObject.normals);\n existedObject.colors = concatenateTypedArrays(existedObject.colors, currentObject.colors);\n existedObject.texCoords = concatenateTypedArrays(\n existedObject.texCoords,\n currentObject.texCoords\n );\n } else {\n uniqueObjects.push(currentObject);\n }\n }\n\n return uniqueObjects;\n}\n\n/**\n * Generates attribute objects with new faceRange and reordered attributes.\n * @param unifiedObjects\n * @returns generated attributes with new faceRange.\n */\nfunction groupAttributesAndRangesByFeatureId(\n unifiedObjects: GroupedByFeatureIdAttributes[],\n featureCount: number\n): GeometryAttributes {\n const firstAttributeObject = unifiedObjects[0];\n const featureIds = [firstAttributeObject.featureId || 0];\n\n let positions = new Float32Array(firstAttributeObject.positions);\n let normals = new Float32Array(firstAttributeObject.normals);\n let colors = new Uint8Array(firstAttributeObject.colors);\n let uvRegions = new Uint16Array(firstAttributeObject.uvRegions);\n let texCoords = new Float32Array(firstAttributeObject.texCoords);\n const range = [0];\n\n let objIndex = 0;\n let sum = 0;\n\n for (let index = 1; index < unifiedObjects.length; index++) {\n const currentAttributesObject = unifiedObjects[index];\n featureIds.push(currentAttributesObject.featureId || 0);\n\n positions = concatenateTypedArrays(positions, currentAttributesObject.positions);\n normals = concatenateTypedArrays(normals, currentAttributesObject.normals);\n colors = concatenateTypedArrays(colors, currentAttributesObject.colors);\n uvRegions = concatenateTypedArrays(uvRegions, currentAttributesObject.uvRegions);\n texCoords = concatenateTypedArrays(texCoords, currentAttributesObject.texCoords);\n\n const groupedObject = unifiedObjects[objIndex];\n range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1 + sum);\n range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE + sum);\n\n sum += groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;\n objIndex += 1;\n }\n\n range.push(positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1);\n\n const faceRange = new Uint32Array(range);\n return {faceRange, featureIds, positions, normals, colors, uvRegions, texCoords, featureCount};\n}\n"],"mappings":"AACA,SAAQA,sBAAsB,QAAO,0BAA0B;AAE/D,MAAMC,iBAAiB,GAAG,CAAC;AAC3B,MAAMC,kCAAkC,GAAG,CAAC;;AAO5C,OAAO,SAASC,kBAAkB,CAACC,UAA+B,EAAsB;EACtF,MAAM;IAACC,SAAS;IAAEC,OAAO;IAAEC,SAAS;IAAEC,MAAM;IAAEC,SAAS;IAAEC;EAAc,CAAC,GAAGN,UAAU;EACrF,MAAMO,aAAa,GAAGN,SAAS,CAACO,MAAM,GAAGV,kCAAkC;EAE3E,IAAI,CAACQ,cAAc,CAACE,MAAM,EAAE;IAC1B,OAAO;MACLC,SAAS,EAAE,IAAIC,WAAW,CAAC,CAAC,CAAC,EAAEH,aAAa,GAAG,CAAC,CAAC,CAAC;MAClDI,UAAU,EAAE,CAAC,CAAC,CAAC;MACfC,YAAY,EAAE,CAAC;MACfX,SAAS;MACTC,OAAO;MACPC,SAAS;MACTC,MAAM;MACNC;IACF,CAAC;EACH;EAEA,MAAMQ,IAAI,GAAGC,mCAAmC,CAACR,cAAc,CAAC;EAChE,MAAMS,gBAAgB,GAAGC,oBAAoB,CAAC;IAAC,GAAGH,IAAI;IAAE,GAAGb;EAAU,CAAC,CAAC;EACvE,MAAMiB,mCAAmC,GAAGC,uBAAuB,CAACH,gBAAgB,CAAC;EACrF,MAAMI,iBAAiB,GAAGC,mCAAmC,CAC3DH,mCAAmC,EACnCJ,IAAI,CA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version":3,"file":"geometry-attributes.js","names":["concatenateTypedArrays","VALUES_PER_VERTEX","POSITIONS_AND_NORMALS_PER_TRIANGLE","generateAttributes","attributes","positions","normals","texCoords","colors","uvRegions","featureIndices","triangleCount","length","faceRange","Uint32Array","featureIds","featureCount","data","calculateFaceRangesAndFeaturesCount","attributeObjects","makeAttributeObjects","unifiedAttributeObjectsByFeatureIds","unifyObjectsByFeatureId","groupedAttributes","groupAttributesAndRangesByFeatureId","rangeIndex","featureIndex","currentFeatureId","getFrequentValue","slice","faceRangeList","uniqueFeatureIds","index","newFeatureId","includes","push","values","map","mostFrequentValue","maxCount","value","groupedData","positionsList","Float32Array","normalsList","colorsList","Uint8Array","texCoordsList","uvRegionsList","Uint16Array","startIndex","endIndex","positionsCount","getSliceAttributeCount","normalsCount","colorsCount","uvRegionsCount","texCoordsCount","featureId","sort","first","second","attributeName","itemsPerVertex4","texCoordsPerVertex","trianglesCount","vertexCount","sortedData","uniqueObjects","currentObject","existedObject","find","obj","unifiedObjects","firstAttributeObject","range","objIndex","sum","currentAttributesObject","groupedObject"],"sources":["../../../../src/i3s-converter/helpers/geometry-attributes.ts"],"sourcesContent":["import type {GeometryAttributes, ConvertedAttributes, GroupedByFeatureIdAttributes} from '../types';\nimport {concatenateTypedArrays} from '@loaders.gl/loader-utils';\n\nconst VALUES_PER_VERTEX = 3;\nconst POSITIONS_AND_NORMALS_PER_TRIANGLE = 9;\n\n/**\n * Generate geometry attributes with faceRange and featureCount\n * @param attributes\n * @returns attirbutes with featureCount, featureIds and changed faceRange.\n */\nexport function generateAttributes(attributes: ConvertedAttributes): GeometryAttributes {\n const {positions, normals, texCoords, colors, uvRegions, featureIndices} = attributes;\n const triangleCount = positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;\n\n if (!featureIndices.length) {\n return {\n faceRange: new Uint32Array([0, triangleCount - 1]),\n featureIds: [0],\n featureCount: 1,\n positions,\n normals,\n texCoords,\n colors,\n uvRegions\n };\n }\n\n const data = calculateFaceRangesAndFeaturesCount(featureIndices);\n const attributeObjects = makeAttributeObjects({...data, ...attributes});\n const unifiedAttributeObjectsByFeatureIds = unifyObjectsByFeatureId(attributeObjects);\n const groupedAttributes = groupAttributesAndRangesByFeatureId(\n unifiedAttributeObjectsByFeatureIds,\n data.featureCount\n );\n return groupedAttributes;\n}\n\n/**\n * Calculates face Ranges and feature count based on featureIndices.\n * @param featureIndices\n * @returns Object with featureCount, reordered attributes and changed faceRange.\n */\nfunction calculateFaceRangesAndFeaturesCount(featureIndices: number[]): {\n faceRange: Uint32Array;\n featureCount: number;\n featureIds: number[];\n} {\n let rangeIndex = 1;\n let featureIndex = 1;\n let currentFeatureId = getFrequentValue(featureIndices.slice(0, VALUES_PER_VERTEX));\n const faceRangeList: any[] = [];\n const featureIds: any[] = [];\n const uniqueFeatureIds = [currentFeatureId];\n\n faceRangeList[0] = 0;\n featureIds[0] = currentFeatureId;\n\n for (let index = VALUES_PER_VERTEX; index < featureIndices.length; index += VALUES_PER_VERTEX) {\n const newFeatureId = getFrequentValue(featureIndices.slice(index, index + VALUES_PER_VERTEX));\n if (currentFeatureId !== newFeatureId) {\n faceRangeList[rangeIndex] = index / VALUES_PER_VERTEX - 1;\n faceRangeList[rangeIndex + 1] = index / VALUES_PER_VERTEX;\n featureIds[featureIndex] = newFeatureId;\n\n if (!uniqueFeatureIds.includes(newFeatureId)) {\n uniqueFeatureIds.push(newFeatureId);\n }\n\n rangeIndex += 2;\n featureIndex += 1;\n }\n currentFeatureId = newFeatureId;\n }\n\n faceRangeList[rangeIndex] = featureIndices.length / VALUES_PER_VERTEX - 1;\n\n const faceRange = new Uint32Array(faceRangeList);\n const featureCount = uniqueFeatureIds.length;\n\n return {faceRange, featureCount, featureIds};\n}\n\n/**\n * Find most frequent value to avoid situation where one vertex can be part of multiple features (objects).\n * @param values\n */\nfunction getFrequentValue(values: number[]): number {\n const map: {[key: number]: number} = {};\n\n let mostFrequentValue = values[0];\n let maxCount = 1;\n\n for (const value of values) {\n // Save item and it's frequency count to the map.\n map[value] = (map[value] || 0) + 1;\n // Find max count of frequency.\n maxCount = maxCount > map[value] ? maxCount : map[value];\n // Find the most frequent value.\n mostFrequentValue = maxCount > map[value] ? mostFrequentValue : value;\n }\n\n return mostFrequentValue;\n}\n\n/**\n * Generate list of attribute object grouped by feature ids.\n * @param attributes\n * @returns sorted list of attribute objects.\n */\nfunction makeAttributeObjects(attributes: GeometryAttributes): GroupedByFeatureIdAttributes[] {\n const {\n featureIds,\n positions,\n normals,\n colors,\n uvRegions,\n texCoords,\n faceRange = new Uint32Array(0)\n } = attributes;\n const groupedData: GroupedByFeatureIdAttributes[] = [];\n\n let positionsList = new Float32Array(positions);\n let normalsList = new Float32Array(normals);\n let colorsList = new Uint8Array(colors);\n let texCoordsList = new Float32Array(texCoords);\n let uvRegionsList = new Uint16Array(uvRegions);\n\n for (let index = 0; index < featureIds.length; index++) {\n const startIndex = faceRange[index * 2];\n const endIndex = faceRange[index * 2 + 1];\n\n const positionsCount = getSliceAttributeCount('positions', startIndex, endIndex);\n const normalsCount = getSliceAttributeCount('normals', startIndex, endIndex);\n const colorsCount = getSliceAttributeCount('colors', startIndex, endIndex);\n const uvRegionsCount = getSliceAttributeCount('uvRegions', startIndex, endIndex);\n const texCoordsCount = getSliceAttributeCount('texCoords', startIndex, endIndex);\n\n groupedData.push({\n featureId: featureIds[index],\n positions: positionsList.slice(0, positionsCount),\n normals: normalsList.slice(0, normalsCount),\n colors: colorsList.slice(0, colorsCount),\n uvRegions: uvRegionsList.slice(0, uvRegionsCount),\n texCoords: texCoordsList.slice(0, texCoordsCount)\n });\n\n positionsList = positionsList.slice(positionsCount);\n normalsList = normalsList.slice(normalsCount);\n colorsList = colorsList.slice(colorsCount);\n uvRegionsList = uvRegionsList.slice(uvRegionsCount);\n texCoordsList = texCoordsList.slice(texCoordsCount);\n }\n\n return groupedData.sort((first, second) => first.featureId - second.featureId);\n}\n\n/**\n * Generate sliced count for generating attribute objects depends on attribute name and range.\n * @param attributeName\n * @param startIndex\n * @param endIndex\n * @returns sliced count\n */\nfunction getSliceAttributeCount(\n attributeName: string,\n startIndex: number,\n endIndex: number\n): number {\n const itemsPerVertex4 = 4;\n const texCoordsPerVertex = 2;\n\n const trianglesCount = endIndex - startIndex + 1;\n const vertexCount = trianglesCount * 3;\n\n switch (attributeName) {\n case 'positions':\n case 'normals':\n return trianglesCount * POSITIONS_AND_NORMALS_PER_TRIANGLE;\n case 'colors':\n case 'uvRegions':\n return vertexCount * itemsPerVertex4;\n case 'texCoords':\n return vertexCount * texCoordsPerVertex;\n default:\n return 0;\n }\n}\n\n/**\n * Generates unique object list depends on feature ids and concantenate their attributes.\n * @param sortedData\n * @returns unique list of objects\n */\nfunction unifyObjectsByFeatureId(\n sortedData: GroupedByFeatureIdAttributes[]\n): GroupedByFeatureIdAttributes[] {\n const uniqueObjects: GroupedByFeatureIdAttributes[] = [];\n\n for (let index = 0; index < sortedData.length; index++) {\n const currentObject = sortedData[index];\n const existedObject = uniqueObjects.find((obj) => obj.featureId === currentObject.featureId);\n\n if (existedObject) {\n existedObject.positions = concatenateTypedArrays(\n existedObject.positions,\n currentObject.positions\n );\n existedObject.normals = concatenateTypedArrays(existedObject.normals, currentObject.normals);\n existedObject.colors = concatenateTypedArrays(existedObject.colors, currentObject.colors);\n existedObject.texCoords = concatenateTypedArrays(\n existedObject.texCoords,\n currentObject.texCoords\n );\n } else {\n uniqueObjects.push(currentObject);\n }\n }\n\n return uniqueObjects;\n}\n\n/**\n * Generates attribute objects with new faceRange and reordered attributes.\n * @param unifiedObjects\n * @returns generated attributes with new faceRange.\n */\nfunction groupAttributesAndRangesByFeatureId(\n unifiedObjects: GroupedByFeatureIdAttributes[],\n featureCount: number\n): GeometryAttributes {\n const firstAttributeObject = unifiedObjects[0];\n const featureIds = [firstAttributeObject.featureId || 0];\n\n let positions = new Float32Array(firstAttributeObject.positions);\n let normals = new Float32Array(firstAttributeObject.normals);\n let colors = new Uint8Array(firstAttributeObject.colors);\n let uvRegions = new Uint16Array(firstAttributeObject.uvRegions);\n let texCoords = new Float32Array(firstAttributeObject.texCoords);\n const range = [0];\n\n let objIndex = 0;\n let sum = 0;\n\n for (let index = 1; index < unifiedObjects.length; index++) {\n const currentAttributesObject = unifiedObjects[index];\n featureIds.push(currentAttributesObject.featureId || 0);\n\n positions = concatenateTypedArrays(positions, currentAttributesObject.positions);\n normals = concatenateTypedArrays(normals, currentAttributesObject.normals);\n colors = concatenateTypedArrays(colors, currentAttributesObject.colors);\n uvRegions = concatenateTypedArrays(uvRegions, currentAttributesObject.uvRegions);\n texCoords = concatenateTypedArrays(texCoords, currentAttributesObject.texCoords);\n\n const groupedObject = unifiedObjects[objIndex];\n range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1 + sum);\n range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE + sum);\n\n sum += groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;\n objIndex += 1;\n }\n\n range.push(positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1);\n\n const faceRange = new Uint32Array(range);\n return {faceRange, featureIds, positions, normals, colors, uvRegions, texCoords, featureCount};\n}\n"],"mappings":"AACA,SAAQA,sBAAsB,QAAO,0BAA0B;AAE/D,MAAMC,iBAAiB,GAAG,CAAC;AAC3B,MAAMC,kCAAkC,GAAG,CAAC;AAO5C,OAAO,SAASC,kBAAkBA,CAACC,UAA+B,EAAsB;EACtF,MAAM;IAACC,SAAS;IAAEC,OAAO;IAAEC,SAAS;IAAEC,MAAM;IAAEC,SAAS;IAAEC;EAAc,CAAC,GAAGN,UAAU;EACrF,MAAMO,aAAa,GAAGN,SAAS,CAACO,MAAM,GAAGV,kCAAkC;EAE3E,IAAI,CAACQ,cAAc,CAACE,MAAM,EAAE;IAC1B,OAAO;MACLC,SAAS,EAAE,IAAIC,WAAW,CAAC,CAAC,CAAC,EAAEH,aAAa,GAAG,CAAC,CAAC,CAAC;MAClDI,U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