@loaders.gl/tiles 4.0.0-beta.2 → 4.0.0-beta.3

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 (126) hide show
  1. package/dist/constants.js.map +1 -0
  2. package/dist/dist.dev.js +8162 -0
  3. package/dist/index.cjs +2537 -0
  4. package/dist/index.js +10 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/{esm/tileset → tileset}/format-3d-tiles/tileset-3d-traverser.js +2 -2
  7. package/dist/tileset/format-3d-tiles/tileset-3d-traverser.js.map +1 -0
  8. package/dist/{esm/tileset → tileset}/format-i3s/i3s-pending-tiles-register.js +1 -2
  9. package/dist/tileset/format-i3s/i3s-pending-tiles-register.js.map +1 -0
  10. package/dist/{esm/tileset → tileset}/format-i3s/i3s-tile-manager.js +3 -4
  11. package/dist/tileset/format-i3s/i3s-tile-manager.js.map +1 -0
  12. package/dist/{esm/tileset → tileset}/format-i3s/i3s-tileset-traverser.js +7 -8
  13. package/dist/tileset/format-i3s/i3s-tileset-traverser.js.map +1 -0
  14. package/dist/tileset/helpers/3d-tiles-options.js.map +1 -0
  15. package/dist/tileset/helpers/bounding-volume.d.ts +1 -1
  16. package/dist/tileset/helpers/bounding-volume.d.ts.map +1 -1
  17. package/dist/{esm/tileset → tileset}/helpers/bounding-volume.js +16 -6
  18. package/dist/tileset/helpers/bounding-volume.js.map +1 -0
  19. package/dist/tileset/helpers/frame-state.js.map +1 -0
  20. package/dist/tileset/helpers/i3s-lod.js.map +1 -0
  21. package/dist/tileset/helpers/tiles-3d-lod.js.map +1 -0
  22. package/dist/tileset/helpers/transform-utils.js.map +1 -0
  23. package/dist/{esm/tileset → tileset}/helpers/zoom.js +2 -2
  24. package/dist/tileset/helpers/zoom.js.map +1 -0
  25. package/dist/tileset/tile-3d.d.ts.map +1 -1
  26. package/dist/{esm/tileset → tileset}/tile-3d.js +55 -56
  27. package/dist/tileset/tile-3d.js.map +1 -0
  28. package/dist/tileset/tileset-3d.d.ts.map +1 -1
  29. package/dist/{esm/tileset → tileset}/tileset-3d.js +64 -62
  30. package/dist/tileset/tileset-3d.js.map +1 -0
  31. package/dist/{esm/tileset → tileset}/tileset-cache.js +4 -5
  32. package/dist/tileset/tileset-cache.js.map +1 -0
  33. package/dist/{esm/tileset → tileset}/tileset-traverser.js +12 -13
  34. package/dist/tileset/tileset-traverser.js.map +1 -0
  35. package/dist/types.js.map +1 -0
  36. package/dist/utils/doubly-linked-list-node.js +11 -0
  37. package/dist/utils/doubly-linked-list-node.js.map +1 -0
  38. package/dist/{esm/utils → utils}/doubly-linked-list.js +4 -5
  39. package/dist/utils/doubly-linked-list.js.map +1 -0
  40. package/dist/{esm/utils → utils}/managed-array.js +3 -4
  41. package/dist/utils/managed-array.js.map +1 -0
  42. package/package.json +20 -12
  43. package/src/tileset/helpers/bounding-volume.ts +53 -24
  44. package/src/tileset/helpers/zoom.ts +5 -5
  45. package/src/tileset/tile-3d.ts +1 -1
  46. package/src/tileset/tileset-3d.ts +6 -9
  47. package/dist/bundle.d.ts +0 -2
  48. package/dist/bundle.d.ts.map +0 -1
  49. package/dist/dist.min.js +0 -9231
  50. package/dist/es5/bundle.js +0 -6
  51. package/dist/es5/bundle.js.map +0 -1
  52. package/dist/es5/constants.js +0 -48
  53. package/dist/es5/constants.js.map +0 -1
  54. package/dist/es5/index.js +0 -93
  55. package/dist/es5/index.js.map +0 -1
  56. package/dist/es5/tileset/format-3d-tiles/tileset-3d-traverser.js +0 -70
  57. package/dist/es5/tileset/format-3d-tiles/tileset-3d-traverser.js.map +0 -1
  58. package/dist/es5/tileset/format-i3s/i3s-pending-tiles-register.js +0 -45
  59. package/dist/es5/tileset/format-i3s/i3s-pending-tiles-register.js.map +0 -1
  60. package/dist/es5/tileset/format-i3s/i3s-tile-manager.js +0 -84
  61. package/dist/es5/tileset/format-i3s/i3s-tile-manager.js.map +0 -1
  62. package/dist/es5/tileset/format-i3s/i3s-tileset-traverser.js +0 -143
  63. package/dist/es5/tileset/format-i3s/i3s-tileset-traverser.js.map +0 -1
  64. package/dist/es5/tileset/helpers/3d-tiles-options.js +0 -12
  65. package/dist/es5/tileset/helpers/3d-tiles-options.js.map +0 -1
  66. package/dist/es5/tileset/helpers/bounding-volume.js +0 -176
  67. package/dist/es5/tileset/helpers/bounding-volume.js.map +0 -1
  68. package/dist/es5/tileset/helpers/frame-state.js +0 -129
  69. package/dist/es5/tileset/helpers/frame-state.js.map +0 -1
  70. package/dist/es5/tileset/helpers/i3s-lod.js +0 -60
  71. package/dist/es5/tileset/helpers/i3s-lod.js.map +0 -1
  72. package/dist/es5/tileset/helpers/tiles-3d-lod.js +0 -103
  73. package/dist/es5/tileset/helpers/tiles-3d-lod.js.map +0 -1
  74. package/dist/es5/tileset/helpers/transform-utils.js +0 -50
  75. package/dist/es5/tileset/helpers/transform-utils.js.map +0 -1
  76. package/dist/es5/tileset/helpers/zoom.js +0 -63
  77. package/dist/es5/tileset/helpers/zoom.js.map +0 -1
  78. package/dist/es5/tileset/tile-3d.js +0 -536
  79. package/dist/es5/tileset/tile-3d.js.map +0 -1
  80. package/dist/es5/tileset/tileset-3d.js +0 -859
  81. package/dist/es5/tileset/tileset-3d.js.map +0 -1
  82. package/dist/es5/tileset/tileset-cache.js +0 -82
  83. package/dist/es5/tileset/tileset-cache.js.map +0 -1
  84. package/dist/es5/tileset/tileset-traverser.js +0 -321
  85. package/dist/es5/tileset/tileset-traverser.js.map +0 -1
  86. package/dist/es5/types.js +0 -2
  87. package/dist/es5/types.js.map +0 -1
  88. package/dist/es5/utils/doubly-linked-list-node.js +0 -21
  89. package/dist/es5/utils/doubly-linked-list-node.js.map +0 -1
  90. package/dist/es5/utils/doubly-linked-list.js +0 -88
  91. package/dist/es5/utils/doubly-linked-list.js.map +0 -1
  92. package/dist/es5/utils/managed-array.js +0 -126
  93. package/dist/es5/utils/managed-array.js.map +0 -1
  94. package/dist/esm/bundle.js +0 -4
  95. package/dist/esm/bundle.js.map +0 -1
  96. package/dist/esm/constants.js.map +0 -1
  97. package/dist/esm/index.js +0 -10
  98. package/dist/esm/index.js.map +0 -1
  99. package/dist/esm/tileset/format-3d-tiles/tileset-3d-traverser.js.map +0 -1
  100. package/dist/esm/tileset/format-i3s/i3s-pending-tiles-register.js.map +0 -1
  101. package/dist/esm/tileset/format-i3s/i3s-tile-manager.js.map +0 -1
  102. package/dist/esm/tileset/format-i3s/i3s-tileset-traverser.js.map +0 -1
  103. package/dist/esm/tileset/helpers/3d-tiles-options.js.map +0 -1
  104. package/dist/esm/tileset/helpers/bounding-volume.js.map +0 -1
  105. package/dist/esm/tileset/helpers/frame-state.js.map +0 -1
  106. package/dist/esm/tileset/helpers/i3s-lod.js.map +0 -1
  107. package/dist/esm/tileset/helpers/tiles-3d-lod.js.map +0 -1
  108. package/dist/esm/tileset/helpers/transform-utils.js.map +0 -1
  109. package/dist/esm/tileset/helpers/zoom.js.map +0 -1
  110. package/dist/esm/tileset/tile-3d.js.map +0 -1
  111. package/dist/esm/tileset/tileset-3d.js.map +0 -1
  112. package/dist/esm/tileset/tileset-cache.js.map +0 -1
  113. package/dist/esm/tileset/tileset-traverser.js.map +0 -1
  114. package/dist/esm/types.js.map +0 -1
  115. package/dist/esm/utils/doubly-linked-list-node.js +0 -12
  116. package/dist/esm/utils/doubly-linked-list-node.js.map +0 -1
  117. package/dist/esm/utils/doubly-linked-list.js.map +0 -1
  118. package/dist/esm/utils/managed-array.js.map +0 -1
  119. package/src/bundle.ts +0 -4
  120. /package/dist/{esm/constants.js → constants.js} +0 -0
  121. /package/dist/{esm/tileset → tileset}/helpers/3d-tiles-options.js +0 -0
  122. /package/dist/{esm/tileset → tileset}/helpers/frame-state.js +0 -0
  123. /package/dist/{esm/tileset → tileset}/helpers/i3s-lod.js +0 -0
  124. /package/dist/{esm/tileset → tileset}/helpers/tiles-3d-lod.js +0 -0
  125. /package/dist/{esm/tileset → tileset}/helpers/transform-utils.js +0 -0
  126. /package/dist/{esm/types.js → types.js} +0 -0
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ export { Tileset3D } from "./tileset/tileset-3d.js";
2
+ export { Tile3D } from "./tileset/tile-3d.js";
3
+ export { TilesetTraverser } from "./tileset/tileset-traverser.js";
4
+ export { TilesetCache } from "./tileset/tileset-cache.js";
5
+ export { createBoundingVolume } from "./tileset/helpers/bounding-volume.js";
6
+ export { calculateTransformProps } from "./tileset/helpers/transform-utils.js";
7
+ export { getFrameState } from "./tileset/helpers/frame-state.js";
8
+ export { getLodStatus } from "./tileset/helpers/i3s-lod.js";
9
+ export { TILE_CONTENT_STATE, TILE_REFINEMENT, TILE_TYPE, TILESET_TYPE, LOD_METRIC_TYPE } from "./constants.js";
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["Tileset3D","Tile3D","TilesetTraverser","TilesetCache","createBoundingVolume","calculateTransformProps","getFrameState","getLodStatus","TILE_CONTENT_STATE","TILE_REFINEMENT","TILE_TYPE","TILESET_TYPE","LOD_METRIC_TYPE"],"sources":["../src/index.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nexport type {Tileset3DProps} from './tileset/tileset-3d';\nexport {Tileset3D} from './tileset/tileset-3d';\nexport {Tile3D} from './tileset/tile-3d';\n\nexport {TilesetTraverser} from './tileset/tileset-traverser';\nexport {TilesetCache} from './tileset/tileset-cache';\n\nexport {createBoundingVolume} from './tileset/helpers/bounding-volume';\nexport {calculateTransformProps} from './tileset/helpers/transform-utils';\n\nexport {getFrameState} from './tileset/helpers/frame-state';\nexport {getLodStatus} from './tileset/helpers/i3s-lod';\n\nexport {\n TILE_CONTENT_STATE,\n TILE_REFINEMENT,\n TILE_TYPE,\n TILESET_TYPE,\n LOD_METRIC_TYPE\n} from './constants';\n"],"mappings":"SAGQA,SAAS;AAAA,SACTC,MAAM;AAAA,SAENC,gBAAgB;AAAA,SAChBC,YAAY;AAAA,SAEZC,oBAAoB;AAAA,SACpBC,uBAAuB;AAAA,SAEvBC,aAAa;AAAA,SACbC,YAAY;AAAA,SAGlBC,kBAAkB,EAClBC,eAAe,EACfC,SAAS,EACTC,YAAY,EACZC,eAAe"}
@@ -1,5 +1,5 @@
1
- import { TILE3D_OPTIMIZATION_HINT, TILE_REFINEMENT } from '../../constants';
2
- import { TilesetTraverser } from '../tileset-traverser';
1
+ import { TILE3D_OPTIMIZATION_HINT, TILE_REFINEMENT } from "../../constants.js";
2
+ import { TilesetTraverser } from "../tileset-traverser.js";
3
3
  export class Tileset3DTraverser extends TilesetTraverser {
4
4
  compareDistanceToCamera(a, b) {
5
5
  return b._distanceToCamera === 0 && a._distanceToCamera === 0 ? b._centerZDepth - a._centerZDepth : b._distanceToCamera - a._distanceToCamera;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tileset-3d-traverser.js","names":["TILE3D_OPTIMIZATION_HINT","TILE_REFINEMENT","TilesetTraverser","Tileset3DTraverser","compareDistanceToCamera","a","b","_distanceToCamera","_centerZDepth","updateTileVisibility","tile","frameState","isVisibleAndInRequestVolume","hasChildren","children","length","hasTilesetContent","firstChild","_visible","meetsScreenSpaceErrorEarly","replace","refine","REPLACE","useOptimization","_optimChildrenWithinParent","USE_OPTIMIZATION","anyChildrenVisible","parent","ADD","shouldRefine"],"sources":["../../../src/tileset/format-3d-tiles/tileset-3d-traverser.ts"],"sourcesContent":["// loaders.gl, MIT license\n\n// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\nimport {TILE3D_OPTIMIZATION_HINT, TILE_REFINEMENT} from '../../constants';\nimport {TilesetTraverser} from '../tileset-traverser';\n\nexport class Tileset3DTraverser extends TilesetTraverser {\n compareDistanceToCamera(a, b) {\n // Sort by farthest child first since this is going on a stack\n return b._distanceToCamera === 0 && a._distanceToCamera === 0\n ? b._centerZDepth - a._centerZDepth\n : b._distanceToCamera - a._distanceToCamera;\n }\n\n updateTileVisibility(tile, frameState) {\n super.updateTileVisibility(tile, frameState);\n\n // Optimization - if none of the tile's children are visible then this tile isn't visible\n if (!tile.isVisibleAndInRequestVolume) {\n return;\n }\n\n const hasChildren = tile.children.length > 0;\n if (tile.hasTilesetContent && hasChildren) {\n // Use the root tile's visibility instead of this tile's visibility.\n // The root tile may be culled by the children bounds optimization in which\n // case this tile should also be culled.\n const firstChild = tile.children[0];\n this.updateTileVisibility(firstChild, frameState);\n tile._visible = firstChild._visible;\n return;\n }\n\n if (this.meetsScreenSpaceErrorEarly(tile, frameState)) {\n tile._visible = false;\n return;\n }\n\n const replace = tile.refine === TILE_REFINEMENT.REPLACE;\n const useOptimization =\n tile._optimChildrenWithinParent === TILE3D_OPTIMIZATION_HINT.USE_OPTIMIZATION;\n if (replace && useOptimization && hasChildren) {\n if (!this.anyChildrenVisible(tile, frameState)) {\n tile._visible = false;\n return;\n }\n }\n }\n\n meetsScreenSpaceErrorEarly(tile, frameState) {\n const {parent} = tile;\n if (!parent || parent.hasTilesetContent || parent.refine !== TILE_REFINEMENT.ADD) {\n return false;\n }\n\n // Use parent's geometric error with child's box to see if the tile already meet the SSE\n return !this.shouldRefine(tile, frameState, true);\n }\n}\n"],"mappings":"SAKQA,wBAAwB,EAAEC,eAAe;AAAA,SACzCC,gBAAgB;AAExB,OAAO,MAAMC,kBAAkB,SAASD,gBAAgB,CAAC;EACvDE,uBAAuBA,CAACC,CAAC,EAAEC,CAAC,EAAE;IAE5B,OAAOA,CAAC,CAACC,iBAAiB,KAAK,CAAC,IAAIF,CAAC,CAACE,iBAAiB,KAAK,CAAC,GACzDD,CAAC,CAACE,aAAa,GAAGH,CAAC,CAACG,aAAa,GACjCF,CAAC,CAACC,iBAAiB,GAAGF,CAAC,CAACE,iBAAiB;EAC/C;EAEAE,oBAAoBA,CAACC,IAAI,EAAEC,UAAU,EAAE;IACrC,KAAK,CAACF,oBAAoB,CAACC,IAAI,EAAEC,UAAU,CAAC;IAG5C,IAAI,CAACD,IAAI,CAACE,2BAA2B,EAAE;MACrC;IACF;IAEA,MAAMC,WAAW,GAAGH,IAAI,CAACI,QAAQ,CAACC,MAAM,GAAG,CAAC;IAC5C,IAAIL,IAAI,CAACM,iBAAiB,IAAIH,WAAW,EAAE;MAIzC,MAAMI,UAAU,GAAGP,IAAI,CAACI,QAAQ,CAAC,CAAC,CAAC;MACnC,IAAI,CAACL,oBAAoB,CAACQ,UAAU,EAAEN,UAAU,CAAC;MACjDD,IAAI,CAACQ,QAAQ,GAAGD,UAAU,CAACC,QAAQ;MACnC;IACF;IAEA,IAAI,IAAI,CAACC,0BAA0B,CAACT,IAAI,EAAEC,UAAU,CAAC,EAAE;MACrDD,IAAI,CAACQ,QAAQ,GAAG,KAAK;MACrB;IACF;IAEA,MAAME,OAAO,GAAGV,IAAI,CAACW,MAAM,KAAKpB,eAAe,CAACqB,OAAO;IACvD,MAAMC,eAAe,GACnBb,IAAI,CAACc,0BAA0B,KAAKxB,wBAAwB,CAACyB,gBAAgB;IAC/E,IAAIL,OAAO,IAAIG,eAAe,IAAIV,WAAW,EAAE;MAC7C,IAAI,CAAC,IAAI,CAACa,kBAAkB,CAAChB,IAAI,EAAEC,UAAU,CAAC,EAAE;QAC9CD,IAAI,CAACQ,QAAQ,GAAG,KAAK;QACrB;MACF;IACF;EACF;EAEAC,0BAA0BA,CAACT,IAAI,EAAEC,UAAU,EAAE;IAC3C,MAAM;MAACgB;IAAM,CAAC,GAAGjB,IAAI;IACrB,IAAI,CAACiB,MAAM,IAAIA,MAAM,CAACX,iBAAiB,IAAIW,MAAM,CAACN,MAAM,KAAKpB,eAAe,CAAC2B,GAAG,EAAE;MAChF,OAAO,KAAK;IACd;IAGA,OAAO,CAAC,IAAI,CAACC,YAAY,CAACnB,IAAI,EAAEC,UAAU,EAAE,IAAI,CAAC;EACnD;AACF"}
@@ -1,7 +1,6 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
1
  export class I3SPendingTilesRegister {
3
2
  constructor() {
4
- _defineProperty(this, "frameNumberMap", new Map());
3
+ this.frameNumberMap = new Map();
5
4
  }
6
5
  register(viewportId, frameNumber) {
7
6
  const viewportMap = this.frameNumberMap.get(viewportId) || new Map();
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i3s-pending-tiles-register.js","names":["I3SPendingTilesRegister","constructor","frameNumberMap","Map","register","viewportId","frameNumber","viewportMap","get","oldCount","set","deregister","isZero","_this$frameNumberMap$","count"],"sources":["../../../src/tileset/format-i3s/i3s-pending-tiles-register.ts"],"sourcesContent":["/**\n * Counter to register pending tile headers for the particular frameNumber\n * Until all tiles are loaded we won't call `onTraversalEnd` callback\n */\nexport class I3SPendingTilesRegister {\n private frameNumberMap: Map<string, Map<number, number>> = new Map();\n\n /**\n * Register a new pending tile header for the particular frameNumber\n * @param viewportId\n * @param frameNumber\n */\n register(viewportId: string, frameNumber: number) {\n const viewportMap = this.frameNumberMap.get(viewportId) || new Map();\n const oldCount = viewportMap.get(frameNumber) || 0;\n viewportMap.set(frameNumber, oldCount + 1);\n this.frameNumberMap.set(viewportId, viewportMap);\n }\n\n /**\n * Deregister a pending tile header for the particular frameNumber\n * @param viewportId\n * @param frameNumber\n */\n deregister(viewportId: string, frameNumber: number) {\n const viewportMap = this.frameNumberMap.get(viewportId);\n if (!viewportMap) {\n return;\n }\n const oldCount = viewportMap.get(frameNumber) || 1;\n viewportMap.set(frameNumber, oldCount - 1);\n }\n\n /**\n * Check is there are no pending tile headers registered for the particular frameNumber\n * @param viewportId\n * @param frameNumber\n * @returns\n */\n isZero(viewportId: string, frameNumber: number) {\n const count = this.frameNumberMap.get(viewportId)?.get(frameNumber) || 0;\n return count === 0;\n }\n}\n"],"mappings":"AAIA,OAAO,MAAMA,uBAAuB,CAAC;EAAAC,YAAA;IAAA,KAC3BC,cAAc,GAAqC,IAAIC,GAAG,CAAC,CAAC;EAAA;EAOpEC,QAAQA,CAACC,UAAkB,EAAEC,WAAmB,EAAE;IAChD,MAAMC,WAAW,GAAG,IAAI,CAACL,cAAc,CAACM,GAAG,CAACH,UAAU,CAAC,IAAI,IAAIF,GAAG,CAAC,CAAC;IACpE,MAAMM,QAAQ,GAAGF,WAAW,CAACC,GAAG,CAACF,WAAW,CAAC,IAAI,CAAC;IAClDC,WAAW,CAACG,GAAG,CAACJ,WAAW,EAAEG,QAAQ,GAAG,CAAC,CAAC;IAC1C,IAAI,CAACP,cAAc,CAACQ,GAAG,CAACL,UAAU,EAAEE,WAAW,CAAC;EAClD;EAOAI,UAAUA,CAACN,UAAkB,EAAEC,WAAmB,EAAE;IAClD,MAAMC,WAAW,GAAG,IAAI,CAACL,cAAc,CAACM,GAAG,CAACH,UAAU,CAAC;IACvD,IAAI,CAACE,WAAW,EAAE;MAChB;IACF;IACA,MAAME,QAAQ,GAAGF,WAAW,CAACC,GAAG,CAACF,WAAW,CAAC,IAAI,CAAC;IAClDC,WAAW,CAACG,GAAG,CAACJ,WAAW,EAAEG,QAAQ,GAAG,CAAC,CAAC;EAC5C;EAQAG,MAAMA,CAACP,UAAkB,EAAEC,WAAmB,EAAE;IAAA,IAAAO,qBAAA;IAC9C,MAAMC,KAAK,GAAG,EAAAD,qBAAA,OAAI,CAACX,cAAc,CAACM,GAAG,CAACH,UAAU,CAAC,cAAAQ,qBAAA,uBAAnCA,qBAAA,CAAqCL,GAAG,CAACF,WAAW,CAAC,KAAI,CAAC;IACxE,OAAOQ,KAAK,KAAK,CAAC;EACpB;AACF"}
@@ -1,5 +1,4 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import { I3SPendingTilesRegister } from './i3s-pending-tiles-register';
1
+ import { I3SPendingTilesRegister } from "./i3s-pending-tiles-register.js";
3
2
  const STATUS = {
4
3
  REQUESTED: 'REQUESTED',
5
4
  COMPLETED: 'COMPLETED',
@@ -7,8 +6,8 @@ const STATUS = {
7
6
  };
8
7
  export class I3STileManager {
9
8
  constructor() {
10
- _defineProperty(this, "_statusMap", void 0);
11
- _defineProperty(this, "pendingTilesRegister", new I3SPendingTilesRegister());
9
+ this._statusMap = void 0;
10
+ this.pendingTilesRegister = new I3SPendingTilesRegister();
12
11
  this._statusMap = {};
13
12
  }
14
13
  add(request, key, callback, frameState) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i3s-tile-manager.js","names":["I3SPendingTilesRegister","STATUS","REQUESTED","COMPLETED","ERROR","I3STileManager","constructor","_statusMap","pendingTilesRegister","add","request","key","callback","frameState","frameNumber","viewport","id","status","register","then","data","actualFrameNumber","deregister","catch","error","update","newFrameNumber","newViewportId","find","hasPendingTiles","viewportId","isZero"],"sources":["../../../src/tileset/format-i3s/i3s-tile-manager.ts"],"sourcesContent":["import {FrameState} from '../helpers/frame-state';\nimport {I3SPendingTilesRegister} from './i3s-pending-tiles-register';\n\nconst STATUS = {\n REQUESTED: 'REQUESTED',\n COMPLETED: 'COMPLETED',\n ERROR: 'ERROR'\n};\n\n// A helper class to manage tile metadata fetching\nexport class I3STileManager {\n private _statusMap: object;\n private pendingTilesRegister = new I3SPendingTilesRegister();\n\n constructor() {\n this._statusMap = {};\n }\n\n /**\n * Add request to map\n * @param request - node metadata request\n * @param key - unique key\n * @param callback - callback after request completed\n * @param frameState - frameState data\n */\n add(request, key, callback, frameState: FrameState) {\n if (!this._statusMap[key]) {\n const {\n frameNumber,\n viewport: {id}\n } = frameState;\n this._statusMap[key] = {request, callback, key, frameState, status: STATUS.REQUESTED};\n // Register pending request for the frameNumber\n this.pendingTilesRegister.register(id, frameNumber);\n request()\n .then((data) => {\n this._statusMap[key].status = STATUS.COMPLETED;\n const {\n frameNumber: actualFrameNumber,\n viewport: {id}\n } = this._statusMap[key].frameState;\n // Deregister pending request for the frameNumber\n this.pendingTilesRegister.deregister(id, actualFrameNumber);\n this._statusMap[key].callback(data, frameState);\n })\n .catch((error) => {\n this._statusMap[key].status = STATUS.ERROR;\n const {\n frameNumber: actualFrameNumber,\n viewport: {id}\n } = this._statusMap[key].frameState;\n // Deregister pending request for the frameNumber\n this.pendingTilesRegister.deregister(id, actualFrameNumber);\n callback(error);\n });\n }\n }\n\n /**\n * Update request if it is still actual for the new frameState\n * @param key - unique key\n * @param frameState - frameState data\n */\n update(key, frameState: FrameState) {\n if (this._statusMap[key]) {\n // Deregister pending request for the old frameNumber\n const {\n frameNumber,\n viewport: {id}\n } = this._statusMap[key].frameState;\n this.pendingTilesRegister.deregister(id, frameNumber);\n\n // Register pending request for the new frameNumber\n const {\n frameNumber: newFrameNumber,\n viewport: {id: newViewportId}\n } = frameState;\n this.pendingTilesRegister.register(newViewportId, newFrameNumber);\n this._statusMap[key].frameState = frameState;\n }\n }\n\n /**\n * Find request in the map\n * @param key - unique key\n * @returns\n */\n find(key) {\n return this._statusMap[key];\n }\n\n /**\n * Check it there are pending tile headers for the particular frameNumber\n * @param viewportId\n * @param frameNumber\n * @returns\n */\n hasPendingTiles(viewportId: string, frameNumber: number): boolean {\n return !this.pendingTilesRegister.isZero(viewportId, frameNumber);\n }\n}\n"],"mappings":"SACQA,uBAAuB;AAE/B,MAAMC,MAAM,GAAG;EACbC,SAAS,EAAE,WAAW;EACtBC,SAAS,EAAE,WAAW;EACtBC,KAAK,EAAE;AACT,CAAC;AAGD,OAAO,MAAMC,cAAc,CAAC;EAI1BC,WAAWA,CAAA,EAAG;IAAA,KAHNC,UAAU;IAAA,KACVC,oBAAoB,GAAG,IAAIR,uBAAuB,CAAC,CAAC;IAG1D,IAAI,CAACO,UAAU,GAAG,CAAC,CAAC;EACtB;EASAE,GAAGA,CAACC,OAAO,EAAEC,GAAG,EAAEC,QAAQ,EAAEC,UAAsB,EAAE;IAClD,IAAI,CAAC,IAAI,CAACN,UAAU,CAACI,GAAG,CAAC,EAAE;MACzB,MAAM;QACJG,WAAW;QACXC,QAAQ,EAAE;UAACC;QAAE;MACf,CAAC,GAAGH,UAAU;MACd,IAAI,CAACN,UAAU,CAACI,GAAG,CAAC,GAAG;QAACD,OAAO;QAAEE,QAAQ;QAAED,GAAG;QAAEE,UAAU;QAAEI,MAAM,EAAEhB,MAAM,CAACC;MAAS,CA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AW,EAAEY,cAAc;QAC3BX,QAAQ,EAAE;UAACC,EAAE,EAAEW;QAAa;MAC9B,CAAC,GAAGd,UAAU;MACd,IAAI,CAACL,oBAAoB,CAACU,QAAQ,CAACS,aAAa,EAAED,cAAc,CAAC;MACjE,IAAI,CAACnB,UAAU,CAACI,GAAG,CAAC,CAACE,UAAU,GAAGA,UAAU;IAC9C;EACF;EAOAe,IAAIA,CAACjB,GAAG,EAAE;IACR,OAAO,IAAI,CAACJ,UAAU,CAACI,GAAG,CAAC;EAC7B;EAQAkB,eAAeA,CAACC,UAAkB,EAAEhB,WAAmB,EAAW;IAChE,OAAO,CAAC,IAAI,CAACN,oBAAoB,CAACuB,MAAM,CAACD,UAAU,EAAEhB,WAAW,CAAC;EACnE;AACF"}
@@ -1,13 +1,12 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
1
  import { load } from '@loaders.gl/core';
3
- import { TilesetTraverser } from '../tileset-traverser';
4
- import { getLodStatus } from '../helpers/i3s-lod';
5
- import { Tile3D } from '../tile-3d';
6
- import { I3STileManager } from './i3s-tile-manager';
2
+ import { TilesetTraverser } from "../tileset-traverser.js";
3
+ import { getLodStatus } from "../helpers/i3s-lod.js";
4
+ import { Tile3D } from "../tile-3d.js";
5
+ import { I3STileManager } from "./i3s-tile-manager.js";
7
6
  export class I3STilesetTraverser extends TilesetTraverser {
8
7
  constructor(options) {
9
8
  super(options);
10
- _defineProperty(this, "_tileManager", void 0);
9
+ this._tileManager = void 0;
11
10
  this._tileManager = new I3STileManager();
12
11
  }
13
12
  traversalFinished(frameState) {
@@ -22,7 +21,7 @@ export class I3STilesetTraverser extends TilesetTraverser {
22
21
  const childTiles = tile.children;
23
22
  const tileset = tile.tileset;
24
23
  for (const child of children) {
25
- const extendedId = "".concat(child.id, "-").concat(frameState.viewport.id);
24
+ const extendedId = `${child.id}-${frameState.viewport.id}`;
26
25
  const childTile = childTiles && childTiles.find(t => t.id === extendedId);
27
26
  if (!childTile) {
28
27
  let request = () => this._loadTile(child.id, tileset);
@@ -45,7 +44,7 @@ export class I3STilesetTraverser extends TilesetTraverser {
45
44
  const {
46
45
  loader
47
46
  } = tileset;
48
- const nodeUrl = tileset.getTileUrl("".concat(tileset.url, "/nodes/").concat(nodeId));
47
+ const nodeUrl = tileset.getTileUrl(`${tileset.url}/nodes/${nodeId}`);
49
48
  const options = {
50
49
  ...tileset.loadOptions,
51
50
  i3s: {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i3s-tileset-traverser.js","names":["load","TilesetTraverser","getLodStatus","Tile3D","I3STileManager","I3STilesetTraverser","constructor","options","_tileManager","traversalFinished","frameState","hasPendingTiles","viewport","id","_frameNumber","shouldRefine","tile","_lodJudge","updateChildTiles","children","header","childTiles","tileset","child","extendedId","childTile","find","t","request","_loadTile","cachedRequest","nodePages","nodePagesTile","formTileFromNodePages","add","_onTileLoad","update","updateTile","nodeId","loader","nodeUrl","getTileUrl","url","loadOptions","i3s","isTileHeader","push","frameNumber","Date","getTime","lastUpdate","updateDebounceTime","executeTraversal"],"sources":["../../../src/tileset/format-i3s/i3s-tileset-traverser.ts"],"sourcesContent":["import {load} from '@loaders.gl/core';\nimport {TilesetTraverser} from '../tileset-traverser';\n\nimport {getLodStatus} from '../helpers/i3s-lod';\nimport {Tile3D} from '../tile-3d';\nimport {I3STileManager} from './i3s-tile-manager';\nimport {FrameState} from '../helpers/frame-state';\n\nexport class I3STilesetTraverser extends TilesetTraverser {\n private _tileManager: I3STileManager;\n\n constructor(options) {\n super(options);\n this._tileManager = new I3STileManager();\n }\n\n /**\n * Check if there are no penging tile header requests,\n * that means the traversal is finished and we can call\n * following-up callbacks.\n */\n traversalFinished(frameState: FrameState): boolean {\n return !this._tileManager.hasPendingTiles(frameState.viewport.id, this._frameNumber || 0);\n }\n\n shouldRefine(tile, frameState: FrameState) {\n tile._lodJudge = getLodStatus(tile, frameState);\n return tile._lodJudge === 'DIG';\n }\n\n updateChildTiles(tile, frameState: FrameState): boolean {\n const children = tile.header.children || [];\n // children which are already fetched and constructed as Tile3D instances\n const childTiles = tile.children;\n const tileset = tile.tileset;\n\n for (const child of children) {\n const extendedId = `${child.id}-${frameState.viewport.id}`;\n // if child tile is not fetched\n const childTile = childTiles && childTiles.find((t) => t.id === extendedId);\n if (!childTile) {\n let request = () => this._loadTile(child.id, tileset);\n const cachedRequest = this._tileManager.find(extendedId);\n if (!cachedRequest) {\n // eslint-disable-next-line max-depth\n if (tileset.tileset.nodePages) {\n request = () => tileset.tileset.nodePagesTile.formTileFromNodePages(child.id);\n }\n this._tileManager.add(\n request,\n extendedId,\n (header) => this._onTileLoad(header, tile, extendedId),\n frameState\n );\n } else {\n // update frameNumber since it is still needed in current frame\n this._tileManager.update(extendedId, frameState);\n }\n } else if (childTile) {\n // if child tile is fetched and available\n this.updateTile(childTile, frameState);\n }\n }\n return false;\n }\n\n async _loadTile(nodeId, tileset) {\n const {loader} = tileset;\n const nodeUrl = tileset.getTileUrl(`${tileset.url}/nodes/${nodeId}`);\n // load metadata\n const options = {\n ...tileset.loadOptions,\n i3s: {\n ...tileset.loadOptions.i3s,\n isTileHeader: true\n }\n };\n\n return await load(nodeUrl, loader, options);\n }\n\n /**\n * The callback to init Tile3D instance after loading the tile JSON\n * @param {Object} header - the tile JSON from a dataset\n * @param {Tile3D} tile - the parent Tile3D instance\n * @param {string} extendedId - optional ID to separate copies of a tile for different viewports.\n * const extendedId = `${tile.id}-${frameState.viewport.id}`;\n * @return {void}\n */\n _onTileLoad(header, tile, extendedId) {\n // after child tile is fetched\n const childTile = new Tile3D(tile.tileset, header, tile, extendedId);\n tile.children.push(childTile);\n const frameState = this._tileManager.find(childTile.id).frameState;\n this.updateTile(childTile, frameState);\n\n // after tile fetched, resume traversal if still in current update/traversal frame\n if (\n this._frameNumber === frameState.frameNumber &&\n (this.traversalFinished(frameState) ||\n new Date().getTime() - this.lastUpdate > this.updateDebounceTime)\n ) {\n this.executeTraversal(childTile, frameState);\n }\n }\n}\n"],"mappings":"AA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I,CAACM,OAAO,EAAEF,MAAM,EAAEJ,IAAI,EAAEQ,UAAU,CAAC;IACpER,IAAI,CAACG,QAAQ,CAAC2B,IAAI,CAACrB,SAAS,CAAC;IAC7B,MAAMf,UAAU,GAAG,IAAI,CAACF,YAAY,CAACkB,IAAI,CAACD,SAAS,CAACZ,EAAE,CAAC,CAACH,UAAU;IAClE,IAAI,CAAC2B,UAAU,CAACZ,SAAS,EAAEf,UAAU,CAAC;IAGtC,IACE,IAAI,CAACI,YAAY,KAAKJ,UAAU,CAACqC,WAAW,KAC3C,IAAI,CAACtC,iBAAiB,CAACC,UAAU,CAAC,IACjC,IAAIsC,IAAI,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC,GAAG,IAAI,CAACC,UAAU,GAAG,IAAI,CAACC,kBAAkB,CAAC,EACnE;MACA,IAAI,CAACC,gBAAgB,CAAC3B,SAAS,EAAEf,UAAU,CAAC;IAC9C;EACF;AACF"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"3d-tiles-options.js","names":["get3dTilesOptions","tileset","assetGltfUpAxis","asset","gltfUpAxis"],"sources":["../../../src/tileset/helpers/3d-tiles-options.ts"],"sourcesContent":["import type {Tileset3D} from '../tileset-3d';\n\nexport function get3dTilesOptions(tileset: Tileset3D): {assetGltfUpAxis: 'X' | 'Y' | 'Z'} {\n return {\n assetGltfUpAxis: (tileset.asset && tileset.asset.gltfUpAxis) || 'Y'\n };\n}\n"],"mappings":"AAEA,OAAO,SAASA,iBAAiBA,CAACC,OAAkB,EAAsC;EACxF,OAAO;IACLC,eAAe,EAAGD,OAAO,CAACE,KAAK,IAAIF,OAAO,CAACE,KAAK,CAACC,UAAU,IAAK;EAClE,CAAC;AACH"}
@@ -6,7 +6,7 @@ import { BoundingSphere, OrientedBoundingBox } from '@math.gl/culling';
6
6
  * @param [result] The object onto which to store the result.
7
7
  * @returns The modified result parameter or a new TileBoundingVolume instance if none was provided.
8
8
  */
9
- export declare function createBoundingVolume(boundingVolumeHeader: any, transform: any, result: any): any;
9
+ export declare function createBoundingVolume(boundingVolumeHeader: any, transform: any, result?: any): any;
10
10
  /** [min, max] each in [longitude, latitude, altitude] */
11
11
  export type CartographicBounds = [min: number[], max: number[]];
12
12
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"bounding-volume.d.ts","sourceRoot":"","sources":["../../../src/tileset/helpers/bounding-volume.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,MAAM,kBAAkB,CAAC;AAmBrE;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,oBAAoB,KAAA,EAAE,SAAS,KAAA,EAAE,MAAM,KAAA,OAsC3E;AAED,yDAAyD;AACzD,MAAM,MAAM,kBAAkB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;AAEhE;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,oBAAoB,KAAA,EACpB,cAAc,EAAE,mBAAmB,GAAG,cAAc,GACnD,kBAAkB,CAuBpB"}
1
+ {"version":3,"file":"bounding-volume.d.ts","sourceRoot":"","sources":["../../../src/tileset/helpers/bounding-volume.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,MAAM,kBAAkB,CAAC;AAuBrE;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,oBAAoB,KAAA,EAAE,SAAS,KAAA,EAAE,MAAM,CAAC,KAAA,OAiB5E;AAED,yDAAyD;AACzD,MAAM,MAAM,kBAAkB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;AAEhE;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,oBAAoB,KAAA,EACpB,cAAc,EAAE,mBAAmB,GAAG,cAAc,GACnD,kBAAkB,CAuBpB"}
@@ -9,18 +9,17 @@ const scratchPoint = new Vector3();
9
9
  const scratchScale = new Vector3();
10
10
  const scratchNorthWest = new Vector3();
11
11
  const scratchSouthEast = new Vector3();
12
+ const scratchCenter = new Vector3();
13
+ const scratchXAxis = new Vector3();
14
+ const scratchYAxis = new Vector3();
15
+ const scratchZAxis = new Vector3();
12
16
  export function createBoundingVolume(boundingVolumeHeader, transform, result) {
13
17
  assert(boundingVolumeHeader, '3D Tile: boundingVolume must be defined');
14
18
  if (boundingVolumeHeader.box) {
15
19
  return createBox(boundingVolumeHeader.box, transform, result);
16
20
  }
17
21
  if (boundingVolumeHeader.region) {
18
- const [west, south, east, north, minHeight, maxHeight] = boundingVolumeHeader.region;
19
- const northWest = Ellipsoid.WGS84.cartographicToCartesian([degrees(west), degrees(north), minHeight], scratchNorthWest);
20
- const southEast = Ellipsoid.WGS84.cartographicToCartesian([degrees(east), degrees(south), maxHeight], scratchSouthEast);
21
- const centerInCartesian = new Vector3().addVectors(northWest, southEast).multiplyScalar(0.5);
22
- const radius = new Vector3().subVectors(northWest, southEast).len() / 2.0;
23
- return createSphere([centerInCartesian[0], centerInCartesian[1], centerInCartesian[2], radius], new Matrix4());
22
+ return createObbFromRegion(boundingVolumeHeader.region);
24
23
  }
25
24
  if (boundingVolumeHeader.sphere) {
26
25
  return createSphere(boundingVolumeHeader.sphere, transform, result);
@@ -85,6 +84,17 @@ function createSphere(sphere, transform, result) {
85
84
  }
86
85
  return new BoundingSphere(center, radius);
87
86
  }
87
+ function createObbFromRegion(region) {
88
+ const [west, south, east, north, minHeight, maxHeight] = region;
89
+ const northWest = Ellipsoid.WGS84.cartographicToCartesian([degrees(west), degrees(north), minHeight], scratchNorthWest);
90
+ const southEast = Ellipsoid.WGS84.cartographicToCartesian([degrees(east), degrees(south), maxHeight], scratchSouthEast);
91
+ const centerInCartesian = new Vector3().addVectors(northWest, southEast).multiplyByScalar(0.5);
92
+ Ellipsoid.WGS84.cartesianToCartographic(centerInCartesian, scratchCenter);
93
+ Ellipsoid.WGS84.cartographicToCartesian([degrees(east), scratchCenter[1], scratchCenter[2]], scratchXAxis);
94
+ Ellipsoid.WGS84.cartographicToCartesian([scratchCenter[0], degrees(north), scratchCenter[2]], scratchYAxis);
95
+ Ellipsoid.WGS84.cartographicToCartesian([scratchCenter[0], scratchCenter[1], maxHeight], scratchZAxis);
96
+ return createBox([...centerInCartesian, ...scratchXAxis.subtract(centerInCartesian), ...scratchYAxis.subtract(centerInCartesian), ...scratchZAxis.subtract(centerInCartesian)], new Matrix4());
97
+ }
88
98
  function orientedBoundingBoxToCartographicBounds(boundingVolume) {
89
99
  const result = emptyCartographicBounds();
90
100
  const {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bounding-volume.js","names":["Quaternion","Vector3","Matrix3","Matrix4","degrees","BoundingSphere","OrientedBoundingBox","Ellipsoid","assert","defined","x","undefined","scratchPoint","scratchScale","scratchNorthWest","scratchSouthEast","scratchCenter","scratchXAxis","scratchYAxis","scratchZAxis","createBoundingVolume","boundingVolumeHeader","transform","result","box","createBox","region","createObbFromRegion","sphere","createSphere","Error","getCartographicBounds","boundingVolume","orientedBoundingBoxToCartographicBounds","west","south","east","north","minHeight","maxHeight","boundingSphereToCartographicBounds","center","origin","length","halfSize","slice","quaternion","fromArray","y","z","transformByQuaternion","scale","toArray","xAxis","transformAsVector","yAxis","zAxis","halfAxes","getScale","uniformScale","Math","max","radius","northWest","WGS84","cartographicToCartesian","southEast","centerInCartesian","addVectors","multiplyByScalar","cartesianToCartographic","subtract","emptyCartographicBounds","getColumn","copy","add","addToCartographicBounds","negate","point","scaleToGeodeticSurface","geodeticSurfaceNormal","len","normalize","clone","cross","axis","dir","Infinity","target","cartesian","min"],"sources":["../../../src/tileset/helpers/bounding-volume.ts"],"sourcesContent":["// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n/* eslint-disable */\nimport {Quaternion, Vector3, Matrix3, Matrix4, degrees} from '@math.gl/core';\nimport {BoundingSphere, OrientedBoundingBox} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {assert} from '@loaders.gl/loader-utils';\n\n// const scratchProjectedBoundingSphere = new BoundingSphere();\n\nfunction defined(x) {\n return x !== undefined && x !== null;\n}\n\n// const scratchMatrix = new Matrix3();\nconst scratchPoint = new Vector3();\nconst scratchScale = new Vector3();\nconst scratchNorthWest = new Vector3();\nconst scratchSouthEast = new Vector3();\nconst scratchCenter = new Vector3();\nconst scratchXAxis = new Vector3();\nconst scratchYAxis = new Vector3();\nconst scratchZAxis = new Vector3();\n// const scratchRectangle = new Rectangle();\n// const scratchOrientedBoundingBox = new OrientedBoundingBox();\n// const scratchTransform = new Matrix4();\n\n/**\n * Create a bounding volume from the tile's bounding volume header.\n * @param {Object} boundingVolumeHeader The tile's bounding volume header.\n * @param {Matrix4} transform The transform to apply to the bounding volume.\n * @param [result] The object onto which to store the result.\n * @returns The modified result parameter or a new TileBoundingVolume instance if none was provided.\n */\nexport function createBoundingVolume(boundingVolumeHeader, transform, result?) {\n assert(boundingVolumeHeader, '3D Tile: boundingVolume must be defined');\n\n // boundingVolume schema:\n // https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/specification/schema/boundingVolume.schema.json\n if (boundingVolumeHeader.box) {\n return createBox(boundingVolumeHeader.box, transform, result);\n }\n if (boundingVolumeHeader.region) {\n return createObbFromRegion(boundingVolumeHeader.region);\n }\n\n if (boundingVolumeHeader.sphere) {\n return createSphere(boundingVolumeHeader.sphere, transform, result);\n }\n\n throw new Error('3D Tile: boundingVolume must contain a sphere, region, or box');\n}\n\n/** [min, max] each in [longitude, latitude, altitude] */\nexport type CartographicBounds = [min: number[], max: number[]];\n\n/**\n * Calculate the cartographic bounding box the tile's bounding volume.\n * @param {Object} boundingVolumeHeader The tile's bounding volume header.\n * @param {BoundingVolume} boundingVolume The bounding volume.\n * @returns {CartographicBounds}\n */\nexport function getCartographicBounds(\n boundingVolumeHeader,\n boundingVolume: OrientedBoundingBox | BoundingSphere\n): CartographicBounds {\n // boundingVolume schema:\n // https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/specification/schema/boundingVolume.schema.json\n if (boundingVolumeHeader.box) {\n return orientedBoundingBoxToCartographicBounds(boundingVolume as OrientedBoundingBox);\n }\n if (boundingVolumeHeader.region) {\n // [west, south, east, north, minimum height, maximum height]\n // Latitudes and longitudes are in the WGS 84 datum as defined in EPSG 4979 and are in radians.\n // Heights are in meters above (or below) the WGS 84 ellipsoid.\n const [west, south, east, north, minHeight, maxHeight] = boundingVolumeHeader.region;\n\n return [\n [degrees(west), degrees(south), minHeight],\n [degrees(east), degrees(north), maxHeight]\n ];\n }\n\n if (boundingVolumeHeader.sphere) {\n return boundingSphereToCartographicBounds(boundingVolume as BoundingSphere);\n }\n\n throw new Error('Unkown boundingVolume type');\n}\n\nfunction createBox(box, transform, result?) {\n // https://math.gl/modules/culling/docs/api-reference/oriented-bounding-box\n // 1. A half-axes based representation.\n // box: An array of 12 numbers that define an oriented bounding box.\n // The first three elements define the x, y, and z values for the center of the box.\n // The next three elements (with indices 3, 4, and 5) define the x axis direction and half-length.\n // The next three elements (indices 6, 7, and 8) define the y axis direction and half-length.\n // The last three elements (indices 9, 10, and 11) define the z axis direction and half-length.\n // 2. A half-size-quaternion based representation.\n // box: An array of 10 numbers that define an oriented bounding box.\n // The first three elements define the x, y, and z values for the center of the box in a right-handed 3-axis (x, y, z) Cartesian coordinate system where the z-axis is up.\n // The next three elements (with indices 3, 4, and 5) define the halfSize.\n // The last four elements (indices 6, 7, 8 and 10) define the quaternion.\n const center = new Vector3(box[0], box[1], box[2]);\n transform.transform(center, center);\n let origin: number[] = [];\n if (box.length === 10) {\n const halfSize = box.slice(3, 6);\n const quaternion = new Quaternion();\n quaternion.fromArray(box, 6);\n const x = new Vector3([1, 0, 0]);\n const y = new Vector3([0, 1, 0]);\n const z = new Vector3([0, 0, 1]);\n x.transformByQuaternion(quaternion);\n x.scale(halfSize[0]);\n y.transformByQuaternion(quaternion);\n y.scale(halfSize[1]);\n z.transformByQuaternion(quaternion);\n z.scale(halfSize[2]);\n origin = [...x.toArray(), ...y.toArray(), ...z.toArray()];\n } else {\n origin = [...box.slice(3, 6), ...box.slice(6, 9), ...box.slice(9, 12)];\n }\n const xAxis = transform.transformAsVector(origin.slice(0, 3));\n const yAxis = transform.transformAsVector(origin.slice(3, 6));\n const zAxis = transform.transformAsVector(origin.slice(6, 9));\n const halfAxes = new Matrix3([\n xAxis[0],\n xAxis[1],\n xAxis[2],\n yAxis[0],\n yAxis[1],\n yAxis[2],\n zAxis[0],\n zAxis[1],\n zAxis[2]\n ]);\n\n if (defined(result)) {\n result.center = center;\n result.halfAxes = halfAxes;\n return result;\n }\n\n return new OrientedBoundingBox(center, halfAxes);\n}\n\n/*\nfunction createBoxFromTransformedRegion(region, transform, initialTransform, result) {\n const rectangle = Rectangle.unpack(region, 0, scratchRectangle);\n const minimumHeight = region[4];\n const maximumHeight = region[5];\n\n const orientedBoundingBox = OrientedBoundingBox.fromRectangle(\n rectangle,\n minimumHeight,\n maximumHeight,\n Ellipsoid.WGS84,\n scratchOrientedBoundingBox\n );\n const center = orientedBoundingBox.center;\n const halfAxes = orientedBoundingBox.halfAxes;\n\n // A region bounding volume is not transformed by the transform in the tileset JSON,\n // but may be transformed by additional transforms applied in Cesium.\n // This is why the transform is calculated as the difference between the initial transform and the current transform.\n transform = Matrix4.multiplyTransformation(\n transform,\n Matrix4.inverseTransformation(initialTransform, scratchTransform),\n scratchTransform\n );\n center = Matrix4.multiplyByPoint(transform, center, center);\n const rotationScale = Matrix4.getRotation(transform, scratchMatrix);\n halfAxes = Matrix3.multiply(rotationScale, halfAxes, halfAxes);\n\n if (defined(result) && result instanceof TileOrientedBoundingBox) {\n result.update(center, halfAxes);\n return result;\n }\n\n return new TileOrientedBoundingBox(center, halfAxes);\n}\n\nfunction createRegion(region, transform, initialTransform, result) {\n if (!Matrix4.equalsEpsilon(transform, initialTransform, CesiumMath.EPSILON8)) {\n return createBoxFromTransformedRegion(region, transform, initialTransform, result);\n }\n\n if (defined(result)) {\n return result;\n }\n\n const rectangleRegion = Rectangle.unpack(region, 0, scratchRectangle);\n\n return new TileBoundingRegion({\n rectangle: rectangleRegion,\n minimumHeight: region[4],\n maximumHeight: region[5]\n });\n}\n*/\n\nfunction createSphere(sphere, transform, result?) {\n // Find the transformed center\n const center = new Vector3(sphere[0], sphere[1], sphere[2]);\n transform.transform(center, center);\n const scale = transform.getScale(scratchScale);\n\n const uniformScale = Math.max(Math.max(scale[0], scale[1]), scale[2]);\n const radius = sphere[3] * uniformScale;\n\n if (defined(result)) {\n result.center = center;\n result.radius = radius;\n return result;\n }\n\n return new BoundingSphere(center, radius);\n}\n\n/**\n * Create OrientedBoundingBox instance from region 3D tiles bounding volume\n * @param region - region 3D tiles bounding volume\n * @returns OrientedBoundingBox instance\n */\nfunction createObbFromRegion(region: number[]): OrientedBoundingBox {\n // [west, south, east, north, minimum height, maximum height]\n // Latitudes and longitudes are in the WGS 84 datum as defined in EPSG 4979 and are in radians.\n // Heights are in meters above (or below) the WGS 84 ellipsoid.\n const [west, south, east, north, minHeight, maxHeight] = region;\n\n const northWest = Ellipsoid.WGS84.cartographicToCartesian(\n [degrees(west), degrees(north), minHeight],\n scratchNorthWest\n );\n const southEast = Ellipsoid.WGS84.cartographicToCartesian(\n [degrees(east), degrees(south), maxHeight],\n scratchSouthEast\n );\n const centerInCartesian = new Vector3().addVectors(northWest, southEast).multiplyByScalar(0.5);\n Ellipsoid.WGS84.cartesianToCartographic(centerInCartesian, scratchCenter);\n\n Ellipsoid.WGS84.cartographicToCartesian(\n [degrees(east), scratchCenter[1], scratchCenter[2]],\n scratchXAxis\n );\n Ellipsoid.WGS84.cartographicToCartesian(\n [scratchCenter[0], degrees(north), scratchCenter[2]],\n scratchYAxis\n );\n Ellipsoid.WGS84.cartographicToCartesian(\n [scratchCenter[0], scratchCenter[1], maxHeight],\n scratchZAxis\n );\n\n return createBox(\n [\n ...centerInCartesian,\n ...scratchXAxis.subtract(centerInCartesian),\n ...scratchYAxis.subtract(centerInCartesian),\n ...scratchZAxis.subtract(centerInCartesian)\n ],\n new Matrix4()\n );\n}\n\n/**\n * Convert a bounding volume defined by OrientedBoundingBox to cartographic bounds\n * @returns {CartographicBounds}\n */\nfunction orientedBoundingBoxToCartographicBounds(\n boundingVolume: OrientedBoundingBox\n): CartographicBounds {\n const result = emptyCartographicBounds();\n\n const {halfAxes} = boundingVolume as OrientedBoundingBox;\n const xAxis = new Vector3(halfAxes.getColumn(0));\n const yAxis = new Vector3(halfAxes.getColumn(1));\n const zAxis = new Vector3(halfAxes.getColumn(2));\n\n // Test all 8 corners of the box\n for (let x = 0; x < 2; x++) {\n for (let y = 0; y < 2; y++) {\n for (let z = 0; z < 2; z++) {\n scratchPoint.copy(boundingVolume.center);\n scratchPoint.add(xAxis);\n scratchPoint.add(yAxis);\n scratchPoint.add(zAxis);\n\n addToCartographicBounds(result, scratchPoint);\n zAxis.negate();\n }\n yAxis.negate();\n }\n xAxis.negate();\n }\n return result;\n}\n\n/**\n * Convert a bounding volume defined by BoundingSphere to cartographic bounds\n * @returns {CartographicBounds}\n */\nfunction boundingSphereToCartographicBounds(boundingVolume: BoundingSphere): CartographicBounds {\n const result = emptyCartographicBounds();\n\n const {center, radius} = boundingVolume as BoundingSphere;\n const point = Ellipsoid.WGS84.scaleToGeodeticSurface(center, scratchPoint);\n\n let zAxis: Vector3;\n if (point) {\n zAxis = Ellipsoid.WGS84.geodeticSurfaceNormal(point) as Vector3;\n } else {\n zAxis = new Vector3(0, 0, 1);\n }\n let xAxis = new Vector3(zAxis[2], -zAxis[1], 0);\n if (xAxis.len() > 0) {\n xAxis.normalize();\n } else {\n xAxis = new Vector3(0, 1, 0);\n }\n const yAxis = xAxis.clone().cross(zAxis);\n\n // Test 6 end points of the 3 axes\n for (const axis of [xAxis, yAxis, zAxis]) {\n scratchScale.copy(axis).scale(radius);\n for (let dir = 0; dir < 2; dir++) {\n scratchPoint.copy(center);\n scratchPoint.add(scratchScale);\n addToCartographicBounds(result, scratchPoint);\n // Flip the axis\n scratchScale.negate();\n }\n }\n return result;\n}\n\n/**\n * Create a new cartographic bounds that contains no points\n * @returns {CartographicBounds}\n */\nfunction emptyCartographicBounds(): CartographicBounds {\n return [\n [Infinity, Infinity, Infinity],\n [-Infinity, -Infinity, -Infinity]\n ];\n}\n\n/**\n * Add a point to the target cartographic bounds\n * @param {CartographicBounds} target\n * @param {Vector3} cartesian coordinates of the point to add\n */\nfunction addToCartographicBounds(target: CartographicBounds, cartesian: Readonly<Vector3>) {\n Ellipsoid.WGS84.cartesianToCartographic(cartesian, scratchPoint);\n target[0][0] = Math.min(target[0][0], scratchPoint[0]);\n target[0][1] = Math.min(target[0][1], scratchPoint[1]);\n target[0][2] = Math.min(target[0][2], scratchPoint[2]);\n\n target[1][0] = Math.max(target[1][0], scratchPoint[0]);\n target[1][1] = Math.max(target[1][1], scratchPoint[1]);\n target[1][2] = Math.max(target[1][2], scratchPoint[2]);\n}\n"],"mappings":"AAIA,SAAQA,UAAU,EAAEC,OAAO,EAAEC,OAAO,EAAEC,OAAO,EAAEC,OAAO,QAAO,eAAe;AAC5E,SAAQC,cAAc,EAAEC,mBAAmB,QAAO,kBAAkB;AACpE,SAAQC,SAAS,QAAO,qBAAqB;AAC7C,SAAQC,MAAM,QAAO,0BAA0B;AAI/C,SAASC,OAAOA,CAACC,CAAC,EAAE;EAClB,OAAOA,CAAC,KAAKC,SAAS,IAAID,CAAC,KAAK,IAAI;AACtC;AAGA,MAAME,YAAY,GAAG,IAAIX,OAAO,CAAC,CAAC;AAClC,MAAMY,YAAY,GAAG,IAAIZ,OAAO,CAAC,CAAC;AAClC,MAAMa,gBAAgB,GAAG,IAAIb,OAAO,CAAC,CAAC;AACtC,MAAMc,gBAAgB,GAAG,IAAId,OAAO,CAAC,CAAC;AACtC,MAAMe,aAAa,GAAG,IAAIf,OAAO,CAAC,CAAC;AACnC,MAAMgB,YAAY,GAAG,IAAIhB,OAAO,CAAC,CAAC;A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.js","names":["Vector3","CullingVolume","Plane","Ellipsoid","scratchVector","scratchPosition","cullingVolume","getFrameState","viewport","frameNumber","cameraDirection","cameraUp","height","metersPerUnit","distanceScales","viewportCenterCartesian","worldToCartesian","center","enuToFixedTransform","WGS84","eastNorthUpToFixedFrame","cameraPositionCartographic","unprojectPosition","cameraPosition","cameraPositionCartesian","cartographicToCartesian","cameraDirectionCartesian","transformAsVector","scale","normalize","cameraUpCartesian","commonSpacePlanesToWGS84","ViewportClass","constructor","longitude","latitude","width","bearing","zoom","topDownViewport","pitch","camera","position","direction","up","sseDenominator","limitSelectedTiles","tiles","frameState","maximumTilesSelected","length","tuples","viewportLongitude","viewportLatitude","index","tile","entries","header","mbs","deltaLon","Math","abs","deltaLat","distance","sqrt","push","tuplesSorted","sort","a","b","selectedTiles","i","unselectedTiles","frustumPlanes","getFrustumPlanes","nearCenterCommon","closestPointOnPlane","near","nearCenterCartesian","cameraCartesian","planes","fromPointNormal","copy","subtract","dir","plane","posCommon","cartesianPos","refPoint","out","arguments","undefined","distanceToRef","normal","dot","add","point","cartographicPos"],"sources":["../../../src/tileset/helpers/frame-state.ts"],"sourcesContent":["import {Tile3D} from '@loaders.gl/tiles';\nimport {Vector3} from '@math.gl/core';\nimport {CullingVolume, Plane} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {GeospatialViewport, Viewport} from '../../types';\n\nexport type FrameState = {\n camera: {\n position: number[];\n direction: number[];\n up: number[];\n };\n viewport: GeospatialViewport;\n topDownViewport: GeospatialViewport; // Use it to calculate projected radius for a tile\n height: number;\n cullingVolume: CullingVolume;\n frameNumber: number; // TODO: This can be the same between updates, what number is unique for between updates?\n sseDenominator: number; // Assumes fovy = 60 degrees\n};\n\nconst scratchVector = new Vector3();\nconst scratchPosition = new Vector3();\nconst cullingVolume = new CullingVolume([\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane()\n]);\n\n// Extracts a frame state appropriate for tile culling from a deck.gl viewport\n// TODO - this could likely be generalized and merged back into deck.gl for other culling scenarios\nexport function getFrameState(viewport: GeospatialViewport, frameNumber: number): FrameState {\n // Traverse and and request. Update _selectedTiles so that we know what to render.\n // Traverse and and request. Update _selectedTiles so that we know what to render.\n const {cameraDirection, cameraUp, height} = viewport;\n const {metersPerUnit} = viewport.distanceScales;\n\n // TODO - Ellipsoid.eastNorthUpToFixedFrame() breaks on raw array, create a Vector.\n // TODO - Ellipsoid.eastNorthUpToFixedFrame() takes a cartesian, is that intuitive?\n const viewportCenterCartesian = worldToCartesian(viewport, viewport.center);\n const enuToFixedTransform = Ellipsoid.WGS84.eastNorthUpToFixedFrame(viewportCenterCartesian);\n\n const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);\n const cameraPositionCartesian = Ellipsoid.WGS84.cartographicToCartesian(\n cameraPositionCartographic,\n new Vector3()\n );\n\n // These should still be normalized as the transform has scale 1 (goes from meters to meters)\n const cameraDirectionCartesian = new Vector3(\n // @ts-ignore\n enuToFixedTransform.transformAsVector(new Vector3(cameraDirection).scale(metersPerUnit))\n ).normalize();\n const cameraUpCartesian = new Vector3(\n // @ts-ignore\n enuToFixedTransform.transformAsVector(new Vector3(cameraUp).scale(metersPerUnit))\n ).normalize();\n\n commonSpacePlanesToWGS84(viewport);\n\n const ViewportClass = viewport.constructor;\n const {longitude, latitude, width, bearing, zoom} = viewport;\n // @ts-ignore\n const topDownViewport = new ViewportClass({\n longitude,\n latitude,\n height,\n width,\n bearing,\n zoom,\n pitch: 0\n });\n\n // TODO: make a file/class for frameState and document what needs to be attached to this so that traversal can function\n return {\n camera: {\n position: cameraPositionCartesian,\n direction: cameraDirectionCartesian,\n up: cameraUpCartesian\n },\n viewport,\n topDownViewport,\n height,\n cullingVolume,\n frameNumber, // TODO: This can be the same between updates, what number is unique for between updates?\n sseDenominator: 1.15 // Assumes fovy = 60 degrees\n };\n}\n\n/**\n * Limit `tiles` array length with `maximumTilesSelected` number.\n * The criteria for this filtering is distance of a tile center\n * to the `frameState.viewport`'s longitude and latitude\n * @param tiles - tiles array to filter\n * @param frameState - frameState to calculate distances\n * @param maximumTilesSelected - maximal amount of tiles in the output array\n * @returns new tiles array\n */\nexport function limitSelectedTiles(\n tiles: Tile3D[],\n frameState: FrameState,\n maximumTilesSelected: number\n): [Tile3D[], Tile3D[]] {\n if (maximumTilesSelected === 0 || tiles.length <= maximumTilesSelected) {\n return [tiles, []];\n }\n // Accumulate distances in couples array: [tileIndex: number, distanceToViewport: number]\n const tuples: [number, number][] = [];\n const {longitude: viewportLongitude, latitude: viewportLatitude} = frameState.viewport;\n for (const [index, tile] of tiles.entries()) {\n const [longitude, latitude] = tile.header.mbs;\n const deltaLon = Math.abs(viewportLongitude - longitude);\n const deltaLat = Math.abs(viewportLatitude - latitude);\n const distance = Math.sqrt(deltaLat * deltaLat + deltaLon * deltaLon);\n tuples.push([index, distance]);\n }\n const tuplesSorted = tuples.sort((a, b) => a[1] - b[1]);\n const selectedTiles: Tile3D[] = [];\n for (let i = 0; i < maximumTilesSelected; i++) {\n selectedTiles.push(tiles[tuplesSorted[i][0]]);\n }\n const unselectedTiles: Tile3D[] = [];\n for (let i = maximumTilesSelected; i < tuplesSorted.length; i++) {\n unselectedTiles.push(tiles[tuplesSorted[i][0]]);\n }\n\n return [selectedTiles, unselectedTiles];\n}\n\nfunction commonSpacePlanesToWGS84(viewport) {\n // Extract frustum planes based on current view.\n const frustumPlanes = viewport.getFrustumPlanes();\n\n // Get the near/far plane centers\n const nearCenterCommon = closestPointOnPlane(frustumPlanes.near, viewport.cameraPosition);\n const nearCenterCartesian = worldToCartesian(viewport, nearCenterCommon);\n const cameraCartesian = worldToCartesian(viewport, viewport.cameraPosition, scratchPosition);\n\n let i = 0;\n cullingVolume.planes[i++].fromPointNormal(\n nearCenterCartesian,\n scratchVector.copy(nearCenterCartesian).subtract(cameraCartesian)\n );\n\n for (const dir in frustumPlanes) {\n if (dir === 'near') {\n continue; // eslint-disable-line no-continue\n }\n const plane = frustumPlanes[dir];\n const posCommon = closestPointOnPlane(plane, nearCenterCommon, scratchPosition);\n const cartesianPos = worldToCartesian(viewport, posCommon, scratchPosition);\n\n cullingVolume.planes[i++].fromPointNormal(\n cartesianPos,\n // Want the normal to point into the frustum since that's what culling expects\n scratchVector.copy(nearCenterCartesian).subtract(cartesianPos)\n );\n }\n}\n\nfunction closestPointOnPlane(\n plane: {distance: number; normal: Vector3},\n refPoint: [number, number, number] | Vector3,\n out: Vector3 = new Vector3()\n): Vector3 {\n const distanceToRef = plane.normal.dot(refPoint);\n out\n .copy(plane.normal)\n .scale(plane.distance - distanceToRef)\n .add(refPoint);\n return out;\n}\n\nfunction worldToCartesian(\n viewport: Viewport,\n point: number[] | Vector3,\n out: Vector3 = new Vector3()\n): Vector3 {\n const cartographicPos = viewport.unprojectPosition(point);\n return Ellipsoid.WGS84.cartographicToCartesian(cartographicPos, out);\n}\n"],"mappings":"AACA,SAAQA,OAAO,QAAO,eAAe;AACrC,SAAQC,aAAa,EAAEC,KAAK,QAAO,kBAAkB;AACrD,SAAQC,SAAS,QAAO,qBAAqB;AAiB7C,MAAMC,aAAa,GAAG,IAAIJ,OAAO,CAAC,CAAC;AACnC,MAAMK,eAAe,GAAG,IAAIL,OAAO,CAAC,CAAC;AACrC,MAAMM,aAAa,GAAG,IAAIL,aAAa,CAAC,CACtC,IAAIC,KAAK,CAAC,CAAC,EACX,IAAIA,KAAK,CAAC,CAAC,EACX,IAAIA,KAAK,CAAC,CAAC,EACX,IAAIA,KAAK,CAAC,CAAC,EACX,IAAIA,KAAK,CAAC,CAAC,EACX,IAAIA,KAAK,CAAC,CAAC,CACZ,CAAC;AAIF,OAAO,SAASK,aAAaA,CAACC,QAA4B,EAAEC,WAAmB,EAAc;EAG3F,MAAM;IAACC,eAAe;IAAEC,QAAQ;IAAEC;EAAM,CAAC,GAAGJ,QAAQ;EACpD,MAAM;IAACK;EAAa,CAAC,GAAGL,QAAQ,CAACM,cAAc;EAI/C,MAAMC,uB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AS,EAAEjF,eAAe,CAAC;IAE3EC,aAAa,CAAC0E,MAAM,CAACT,CAAC,EAAE,CAAC,CAACU,eAAe,CACvCM,YAAY,EAEZnF,aAAa,CAAC8E,IAAI,CAACJ,mBAAmB,CAAC,CAACK,QAAQ,CAACI,YAAY,CAC/D,CAAC;EACH;AACF;AAEA,SAASX,mBAAmBA,CAC1BS,KAA0C,EAC1CG,QAA4C,EAEnC;EAAA,IADTC,GAAY,GAAAC,SAAA,CAAAxC,MAAA,QAAAwC,SAAA,QAAAC,SAAA,GAAAD,SAAA,MAAG,IAAI1F,OAAO,CAAC,CAAC;EAE5B,MAAM4F,aAAa,GAAGP,KAAK,CAACQ,MAAM,CAACC,GAAG,CAACN,QAAQ,CAAC;EAChDC,GAAG,CACAP,IAAI,CAACG,KAAK,CAACQ,MAAM,CAAC,CAClBjE,KAAK,CAACyD,KAAK,CAACtB,QAAQ,GAAG6B,aAAa,CAAC,CACrCG,GAAG,CAACP,QAAQ,CAAC;EAChB,OAAOC,GAAG;AACZ;AAEA,SAASzE,gBAAgBA,CACvBR,QAAkB,EAClBwF,KAAyB,EAEhB;EAAA,IADTP,GAAY,GAAAC,SAAA,CAAAxC,MAAA,QAAAwC,SAAA,QAAAC,SAAA,GAAAD,SAAA,MAAG,IAAI1F,OAAO,CAAC,CAAC;EAE5B,MAAMiG,eAAe,GAAGzF,QAAQ,CAACc,iBAAiB,CAAC0E,KAAK,CAAC;EACzD,OAAO7F,SAAS,CAACgB,KAAK,CAACM,uBAAuB,CAACwE,eAAe,EAAER,GAAG,CAAC;AACtE"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i3s-lod.js","names":["Matrix4","Vector3","Ellipsoid","cameraPositionCartesian","toEye","cameraPositionEnu","extraVertexEnu","projectedOriginVector","enuToCartesianMatrix","cartesianToEnuMatrix","getLodStatus","tile","frameState","lodMetricValue","isNaN","screenSize","getProjectedRadius","header","children","topDownViewport","viewport","mbsLat","mbs","mbsLon","mbsZ","mbsR","mbsCenterCartesian","boundingVolume","center","cameraPositionCartographic","unprojectPosition","cameraPosition","WGS84","cartographicToCartesian","copy","subtract","normalize","eastNorthUpToFixedFrame","invert","transform","projection","Math","sqrt","extraZ","extraVertexCartesian","extraVectorCartesian","radiusVector","cross","scale","sphereMbsBorderVertexCartesian","add","sphereMbsBorderVertexCartographic","cartesianToCartographic","projectedOrigin","project","projectedMbsBorderVertex","projectedRadius","magnitude"],"sources":["../../../src/tileset/helpers/i3s-lod.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport {Matrix4, Vector3} from '@math.gl/core';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {Tile3D} from '../tile-3d';\nimport {FrameState} from './frame-state';\n\nconst cameraPositionCartesian = new Vector3();\nconst toEye = new Vector3();\nconst cameraPositionEnu = new Vector3();\nconst extraVertexEnu = new Vector3();\nconst projectedOriginVector = new Vector3();\nconst enuToCartesianMatrix = new Matrix4();\nconst cartesianToEnuMatrix = new Matrix4();\n\n/**\n * For the maxScreenThreshold error metric, maxError means that you should replace the node with it's children\n as soon as the nodes bounding sphere has a screen radius larger than maxError pixels.\n In this sense a value of 0 means you should always load it's children,\n or if it's a leaf node, you should always display it.\n * @param tile \n * @param frameState \n * @returns \n */\nexport function getLodStatus(tile: Tile3D, frameState: FrameState): 'DIG' | 'OUT' | 'DRAW' {\n if (tile.lodMetricValue === 0 || isNaN(tile.lodMetricValue)) {\n return 'DIG';\n }\n const screenSize = 2 * getProjectedRadius(tile, frameState);\n if (screenSize < 2) {\n return 'OUT';\n }\n if (!tile.header.children || screenSize <= tile.lodMetricValue) {\n return 'DRAW';\n } else if (tile.header.children) {\n return 'DIG';\n }\n return 'OUT';\n}\n\n/**\n * Calculate size of MBS radius projected on the screen plane\n * @param tile\n * @param frameState\n * @returns\n */\n// eslint-disable-next-line max-statements\nexport function getProjectedRadius(tile: Tile3D, frameState: FrameState): number {\n const {topDownViewport: viewport} = frameState;\n const mbsLat = tile.header.mbs[1];\n const mbsLon = tile.header.mbs[0];\n const mbsZ = tile.header.mbs[2];\n const mbsR = tile.header.mbs[3];\n const mbsCenterCartesian = [...tile.boundingVolume.center];\n const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);\n Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, cameraPositionCartesian);\n\n // ---------------------------\n // Calculate mbs border vertex\n // ---------------------------\n toEye.copy(cameraPositionCartesian).subtract(mbsCenterCartesian).normalize();\n // Add extra vector to form plane\n Ellipsoid.WGS84.eastNorthUpToFixedFrame(mbsCenterCartesian, enuToCartesianMatrix);\n cartesianToEnuMatrix.copy(enuToCartesianMatrix).invert();\n cameraPositionEnu.copy(cameraPositionCartesian).transform(cartesianToEnuMatrix);\n // Mean Proportionals in Right Triangles - Altitude rule\n // https://mathbitsnotebook.com/Geometry/RightTriangles/RTmeanRight.html\n const projection = Math.sqrt(\n cameraPositionEnu[0] * cameraPositionEnu[0] + cameraPositionEnu[1] * cameraPositionEnu[1]\n );\n const extraZ = (projection * projection) / cameraPositionEnu[2];\n extraVertexEnu.copy([cameraPositionEnu[0], cameraPositionEnu[1], extraZ]);\n const extraVertexCartesian = extraVertexEnu.transform(enuToCartesianMatrix);\n const extraVectorCartesian = extraVertexCartesian.subtract(mbsCenterCartesian).normalize();\n // We need radius vector orthogonal to toEye vector\n const radiusVector = toEye.cross(extraVectorCartesian).normalize().scale(mbsR);\n const sphereMbsBorderVertexCartesian = radiusVector.add(mbsCenterCartesian);\n const sphereMbsBorderVertexCartographic = Ellipsoid.WGS84.cartesianToCartographic(\n sphereMbsBorderVertexCartesian\n );\n // ---------------------------\n\n // Project center vertex and border vertex and calculate projected radius of MBS\n const projectedOrigin = viewport.project([mbsLon, mbsLat, mbsZ]);\n const projectedMbsBorderVertex = viewport.project(\n sphereMbsBorderVertexCartographic as [number, number, number]\n );\n const projectedRadius = projectedOriginVector\n .copy(projectedOrigin)\n .subtract(projectedMbsBorderVertex)\n .magnitude();\n return projectedRadius;\n}\n"],"mappings":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C/B,oBAAoB,CAAC;EAC3E,MAAMqC,oBAAoB,GAAGD,oBAAoB,CAACT,QAAQ,CAACT,kBAAkB,CAAC,CAACU,SAAS,CAAC,CAAC;EAE1F,MAAMU,YAAY,GAAG1C,KAAK,CAAC2C,KAAK,CAACF,oBAAoB,CAAC,CAACT,SAAS,CAAC,CAAC,CAACY,KAAK,CAACvB,IAAI,CAAC;EAC9E,MAAMwB,8BAA8B,GAAGH,YAAY,CAACI,GAAG,CAACxB,kBAAkB,CAAC;EAC3E,MAAMyB,iCAAiC,GAAGjD,SAAS,CAAC8B,KAAK,CAACoB,uBAAuB,CAC/EH,8BACF,CAAC;EAID,MAAMI,eAAe,GAAGjC,QAAQ,CAACkC,OAAO,CAAC,CAAC/B,MAAM,EAAEF,MAAM,EAAEG,IAAI,CAAC,CAAC;EAChE,MAAM+B,wBAAwB,GAAGnC,QAAQ,CAACkC,OAAO,CAC/CH,iCACF,CAAC;EACD,MAAMK,eAAe,GAAGjD,qBAAqB,CAC1C2B,IAAI,CAACmB,eAAe,CAAC,CACrBlB,QAAQ,CAACoB,wBAAwB,CAAC,CAClCE,SAAS,CAAC,CAAC;EACd,OAAOD,eAAe;AACxB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tiles-3d-lod.js","names":["Matrix4","Vector3","clamp","scratchPositionNormal","scratchCartographic","scratchMatrix","scratchCenter","scratchPosition","scratchDirection","calculateDynamicScreenSpaceError","root","_ref","camera","mapProjection","options","arguments","length","undefined","dynamicScreenSpaceErrorHeightFalloff","dynamicScreenSpaceErrorDensity","up","direction","height","minimumHeight","maximumHeight","tileBoundingVolume","contentBoundingVolume","TileBoundingRegion","Cartesian3","normalize","positionWC","directionWC","positionCartographic","transformLocal","inverseTransformation","computedTransform","ellipsoid","boundingVolume","centerLocal","multiplyByPoint","center","magnitude","minimumRadius","centerCartographic","Cartographic","fromCartesian","positionLocal","UNIT_Z","multiplyByPointAsVector","z","TileOrientedBoundingBox","boxHeight","_header","box","TileBoundingSphere","radius","heightFalloff","heightClose","heightFar","t","dot","Math","abs","horizonFactor","fog","distanceToCamera","density","scalar","exp","getDynamicScreenSpaceError","tileset","dynamicScreenSpaceError","dynamicScreenSpaceErrorComputedDensity","factor","dynamicScreenSpaceErrorFactor","dynamicError","getTiles3DScreenSpaceError","tile","frameState","useParentLodMetric","parentLodMetricValue","parent","lodMetricValue","distance","max","_distanceToCamera","sseDenominator","viewDistanceScale","error"],"sources":["../../../src/tileset/helpers/tiles-3d-lod.ts"],"sourcesContent":["// loaders.gl, MIT license\n\n// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n// TODO - Dynamic screen space error provides an optimization when looking at\n// tilesets from above\n\n/* eslint-disable */\n// @ts-nocheck\nimport {Matrix4, Vector3, clamp} from '@math.gl/core';\n\nconst scratchPositionNormal = new Vector3();\nconst scratchCartographic = new Vector3();\nconst scratchMatrix = new Matrix4();\nconst scratchCenter = new Vector3();\nconst scratchPosition = new Vector3();\nconst scratchDirection = new Vector3();\n\n// eslint-disable-next-line max-statements, complexity\nexport function calculateDynamicScreenSpaceError(root, {camera, mapProjection}, options = {}) {\n const {dynamicScreenSpaceErrorHeightFalloff = 0.25, dynamicScreenSpaceErrorDensity = 0.00278} =\n options;\n\n let up;\n let direction;\n let height;\n let minimumHeight;\n let maximumHeight;\n\n const tileBoundingVolume = root.contentBoundingVolume;\n\n if (tileBoundingVolume instanceof TileBoundingRegion) {\n up = Cartesian3.normalize(camera.positionWC, scratchPositionNormal);\n direction = camera.directionWC;\n height = camera.positionCartographic.height;\n minimumHeight = tileBoundingVolume.minimumHeight;\n maximumHeight = tileBoundingVolume.maximumHeight;\n } else {\n // Transform camera position and direction into the local coordinate system of the tileset\n const transformLocal = Matrix4.inverseTransformation(root.computedTransform, scratchMatrix);\n const ellipsoid = mapProjection.ellipsoid;\n const boundingVolume = tileBoundingVolume.boundingVolume;\n const centerLocal = Matrix4.multiplyByPoint(\n transformLocal,\n boundingVolume.center,\n scratchCenter\n );\n if (Cartesian3.magnitude(centerLocal) > ellipsoid.minimumRadius) {\n // The tileset is defined in WGS84. Approximate the minimum and maximum height.\n const centerCartographic = Cartographic.fromCartesian(\n centerLocal,\n ellipsoid,\n scratchCartographic\n );\n up = Cartesian3.normalize(camera.positionWC, scratchPositionNormal);\n direction = camera.directionWC;\n height = camera.positionCartographic.height;\n minimumHeight = 0.0;\n maximumHeight = centerCartographic.height * 2.0;\n } else {\n // The tileset is defined in local coordinates (z-up)\n const positionLocal = Matrix4.multiplyByPoint(\n transformLocal,\n camera.positionWC,\n scratchPosition\n );\n up = Cartesian3.UNIT_Z;\n direction = Matrix4.multiplyByPointAsVector(\n transformLocal,\n camera.directionWC,\n scratchDirection\n );\n direction = Cartesian3.normalize(direction, direction);\n height = positionLocal.z;\n if (tileBoundingVolume instanceof TileOrientedBoundingBox) {\n // Assuming z-up, the last component stores the half-height of the box\n const boxHeight = root._header.boundingVolume.box[11];\n minimumHeight = centerLocal.z - boxHeight;\n maximumHeight = centerLocal.z + boxHeight;\n } else if (tileBoundingVolume instanceof TileBoundingSphere) {\n const radius = boundingVolume.radius;\n minimumHeight = centerLocal.z - radius;\n maximumHeight = centerLocal.z + radius;\n }\n }\n }\n\n // The range where the density starts to lessen. Start at the quarter height of the tileset.\n const heightFalloff = dynamicScreenSpaceErrorHeightFalloff;\n const heightClose = minimumHeight + (maximumHeight - minimumHeight) * heightFalloff;\n const heightFar = maximumHeight;\n\n const t = clamp((height - heightClose) / (heightFar - heightClose), 0.0, 1.0);\n\n // Increase density as the camera tilts towards the horizon\n const dot = Math.abs(Cartesian3.dot(direction, up));\n\n let horizonFactor = 1.0 - dot;\n\n // Weaken the horizon factor as the camera height increases, implying the camera is further away from the tileset.\n // The goal is to increase density for the \"street view\", not when viewing the tileset from a distance.\n horizonFactor = horizonFactor * (1.0 - t);\n\n return dynamicScreenSpaceErrorDensity * horizonFactor;\n}\n\nexport function fog(distanceToCamera, density) {\n const scalar = distanceToCamera * density;\n return 1.0 - Math.exp(-(scalar * scalar));\n}\n\nexport function getDynamicScreenSpaceError(tileset, distanceToCamera) {\n if (tileset.dynamicScreenSpaceError && tileset.dynamicScreenSpaceErrorComputedDensity) {\n const density = tileset.dynamicScreenSpaceErrorComputedDensity;\n const factor = tileset.dynamicScreenSpaceErrorFactor;\n // TODO: Refined screen space error that minimizes tiles in non-first-person\n const dynamicError = fog(distanceToCamera, density) * factor;\n return dynamicError;\n }\n\n return 0;\n}\n\nexport function getTiles3DScreenSpaceError(tile, frameState, useParentLodMetric) {\n const tileset = tile.tileset;\n const parentLodMetricValue = (tile.parent && tile.parent.lodMetricValue) || tile.lodMetricValue;\n const lodMetricValue = useParentLodMetric ? parentLodMetricValue : tile.lodMetricValue;\n\n // Leaf tiles do not have any error so save the computation\n if (lodMetricValue === 0.0) {\n return 0.0;\n }\n\n // TODO: Orthographic Frustum needs special treatment?\n // this._getOrthograhicScreenSpaceError();\n\n // Avoid divide by zero when viewer is inside the tile\n const distance = Math.max(tile._distanceToCamera, 1e-7);\n const {height, sseDenominator} = frameState;\n const {viewDistanceScale} = tileset.options;\n let error = (lodMetricValue * height * (viewDistanceScale || 1.0)) / (distance * sseDenominator);\n\n error -= getDynamicScreenSpaceError(tileset, distance);\n\n return error;\n}\n"],"mappings":"AAUA,SAAQA,OAAO,EAAEC,OAAO,EAAEC,KAAK,QAAO,eAAe;AAErD,MAAMC,qBAAqB,GAAG,IAAIF,OAAO,CAAC,CAAC;AAC3C,MAAMG,mBAAmB,GAAG,IAAIH,OAAO,CAAC,CAAC;AACzC,MAAMI,aAAa,GAAG,IAAIL,OAAO,CAAC,CAAC;AACnC,MAAMM,aAAa,GAAG,IAAIL,OAAO,CAAC,CAAC;AACnC,MAAMM,eAAe,GAAG,IAAIN,OAAO,CAAC,CAAC;AACrC,MAAMO,gBAAgB,GAAG,IAAIP,OAAO,CAAC,CAAC;AAGtC,OAAO,SAASQ,gCAAgCA,CAACC,I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AAkB,GAAGC,oBAAoB,GAAGH,IAAI,CAACK,cAAc;EAGtF,IAAIA,cAAc,KAAK,GAAG,EAAE;IAC1B,OAAO,GAAG;EACZ;EAMA,MAAMC,QAAQ,GAAGtB,IAAI,CAACuB,GAAG,CAACP,IAAI,CAACQ,iBAAiB,EAAE,IAAI,CAAC;EACvD,MAAM;IAAC/D,MAAM;IAAEgE;EAAc,CAAC,GAAGR,UAAU;EAC3C,MAAM;IAACS;EAAiB,CAAC,GAAGjB,OAAO,CAACxD,OAAO;EAC3C,IAAI0E,KAAK,GAAIN,cAAc,GAAG5D,MAAM,IAAIiE,iBAAiB,IAAI,GAAG,CAAC,IAAKJ,QAAQ,GAAGG,cAAc,CAAC;EAEhGE,KAAK,IAAInB,0BAA0B,CAACC,OAAO,EAAEa,QAAQ,CAAC;EAEtD,OAAOK,KAAK;AACd"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform-utils.js","names":["Ellipsoid","Matrix4","Vector3","assert","calculateTransformProps","tileHeader","tile","rtcCenter","gltfUpAxis","computedTransform","boundingVolume","center","modelMatrix","translate","rotationY","rotateX","Math","PI","multiplyRight","rotationX","rotateY","isQuantized","quantizedVolumeOffset","scale","quantizedVolumeScale","cartesianOrigin","cartesianModelMatrix","cartographicOrigin","WGS84","cartesianToCartographic","fromFixedFrameMatrix","eastNorthUpToFixedFrame","toFixedFrameMatrix","invert","cartographicModelMatrix","coordinateSystem"],"sources":["../../../src/tileset/helpers/transform-utils.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {Matrix4, Vector3} from '@math.gl/core';\nimport {assert} from '@loaders.gl/loader-utils';\n\nexport function calculateTransformProps(tileHeader, tile) {\n assert(tileHeader);\n assert(tile);\n\n const {rtcCenter, gltfUpAxis} = tile;\n const {\n computedTransform,\n boundingVolume: {center}\n } = tileHeader;\n\n let modelMatrix = new Matrix4(computedTransform);\n\n // Translate if appropriate\n if (rtcCenter) {\n modelMatrix.translate(rtcCenter);\n }\n\n // glTF models need to be rotated from Y to Z up\n // https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification#y-up-to-z-up\n switch (gltfUpAxis) {\n case 'Z':\n break;\n case 'Y':\n const rotationY = new Matrix4().rotateX(Math.PI / 2);\n modelMatrix = modelMatrix.multiplyRight(rotationY);\n break;\n case 'X':\n const rotationX = new Matrix4().rotateY(-Math.PI / 2);\n modelMatrix = modelMatrix.multiplyRight(rotationX);\n break;\n default:\n break;\n }\n\n // Scale/offset positions if normalized integers\n if (tile.isQuantized) {\n modelMatrix.translate(tile.quantizedVolumeOffset).scale(tile.quantizedVolumeScale);\n }\n\n // Option 1: Cartesian matrix and origin\n const cartesianOrigin = new Vector3(center);\n\n tile.cartesianModelMatrix = modelMatrix;\n tile.cartesianOrigin = cartesianOrigin;\n\n // Option 2: Cartographic matrix and origin\n const cartographicOrigin = Ellipsoid.WGS84.cartesianToCartographic(\n cartesianOrigin,\n new Vector3()\n );\n const fromFixedFrameMatrix = Ellipsoid.WGS84.eastNorthUpToFixedFrame(cartesianOrigin);\n const toFixedFrameMatrix = fromFixedFrameMatrix.invert();\n\n tile.cartographicModelMatrix = toFixedFrameMatrix.multiplyRight(modelMatrix);\n tile.cartographicOrigin = cartographicOrigin;\n\n // Deprecated, drop\n if (!tile.coordinateSystem) {\n tile.modelMatrix = tile.cartographicModelMatrix;\n }\n}\n"],"mappings":"AAEA,SAAQA,SAAS,QAAO,qBAAqB;AAC7C,SAAQC,OAAO,EAAEC,OAAO,QAAO,eAAe;AAC9C,SAAQC,MAAM,QAAO,0BAA0B;AAE/C,OAAO,SAASC,uBAAuBA,CAACC,UAAU,EAAEC,IAAI,EAAE;EACxDH,MAAM,CAACE,UAAU,CAAC;EAClBF,MAAM,CAACG,IAAI,CAAC;EAEZ,MAAM;IAACC,SAAS;IAAEC;EAAU,CAAC,GAAGF,IAAI;EACpC,MAAM;IACJG,iBAAiB;IACjBC,cAAc,EAAE;MAACC;IAAM;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AI,CAACqB,kBAAkB,GAAGA,kBAAkB;EAG5C,IAAI,CAACrB,IAAI,CAAC6B,gBAAgB,EAAE;IAC1B7B,IAAI,CAACM,WAAW,GAAGN,IAAI,CAAC4B,uBAAuB;EACjD;AACF"}
@@ -29,8 +29,8 @@ export function getZoomFromBoundingVolume(boundingVolume, cartorgraphicCenter) {
29
29
  return 1;
30
30
  }
31
31
  export function getZoomFromFullExtent(fullExtent, cartorgraphicCenter, cartesianCenter) {
32
- const extentVertex = Ellipsoid.WGS84.cartographicToCartesian([fullExtent.xmax, fullExtent.ymax, fullExtent.zmax], new Vector3());
33
- const extentSize = Math.sqrt(Math.pow(extentVertex[0] - cartesianCenter[0], 2) + Math.pow(extentVertex[1] - cartesianCenter[1], 2) + Math.pow(extentVertex[2] - cartesianCenter[2], 2));
32
+ Ellipsoid.WGS84.cartographicToCartesian([fullExtent.xmax, fullExtent.ymax, fullExtent.zmax], scratchVector);
33
+ const extentSize = Math.sqrt(Math.pow(scratchVector[0] - cartesianCenter[0], 2) + Math.pow(scratchVector[1] - cartesianCenter[1], 2) + Math.pow(scratchVector[2] - cartesianCenter[2], 2));
34
34
  return Math.log2(WGS84_RADIUS_Z / (extentSize + cartorgraphicCenter[2]));
35
35
  }
36
36
  export function getZoomFromExtent(extent, cartorgraphicCenter, cartesianCenter) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zoom.js","names":["Vector3","BoundingSphere","OrientedBoundingBox","Ellipsoid","WGS84_RADIUS_X","WGS84_RADIUS_Y","WGS84_RADIUS_Z","scratchVector","getZoomFromBoundingVolume","boundingVolume","cartorgraphicCenter","halfAxes","obbSize","getObbSize","Math","log2","radius","width","height","zoomX","zoomY","getZoomFromFullExtent","fullExtent","cartesianCenter","WGS84","cartographicToCartesian","xmax","ymax","zmax","extentSize","sqrt","pow","getZoomFromExtent","extent","xmin","ymin","zmin","getColumn","axeY","axeZ","farthestVertex","add","size","len"],"sources":["../../../src/tileset/helpers/zoom.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport {Vector3} from '@math.gl/core';\nimport {BoundingSphere, OrientedBoundingBox} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {BoundingRectangle} from '../../types';\n\nconst WGS84_RADIUS_X = 6378137.0;\nconst WGS84_RADIUS_Y = 6378137.0;\nconst WGS84_RADIUS_Z = 6356752.3142451793;\n\nconst scratchVector = new Vector3();\n\n/**\n * Calculate appropriate zoom value for a particular boundingVolume\n * @param boundingVolume - the instance of bounding volume\n * @param cartorgraphicCenter - cartographic center of the bounding volume\n * @returns {number} - zoom value\n */\nexport function getZoomFromBoundingVolume(\n boundingVolume: BoundingSphere | OrientedBoundingBox | BoundingRectangle,\n cartorgraphicCenter: Vector3\n) {\n if (boundingVolume instanceof OrientedBoundingBox) {\n // OrientedBoundingBox\n const {halfAxes} = boundingVolume;\n const obbSize = getObbSize(halfAxes);\n // Use WGS84_RADIUS_Z to allign with BoundingSphere algorithm\n // Add the tile elevation value for correct zooming to elevated tiles\n return Math.log2(WGS84_RADIUS_Z / (obbSize + cartorgraphicCenter[2]));\n } else if (boundingVolume instanceof BoundingSphere) {\n // BoundingSphere\n const {radius} = boundingVolume;\n // Add the tile elevation value for correct zooming to elevated tiles\n return Math.log2(WGS84_RADIUS_Z / (radius + cartorgraphicCenter[2]));\n } else if (boundingVolume.width && boundingVolume.height) {\n // BoundingRectangle\n const {width, height} = boundingVolume;\n const zoomX = Math.log2(WGS84_RADIUS_X / width);\n const zoomY = Math.log2(WGS84_RADIUS_Y / height);\n\n return (zoomX + zoomY) / 2;\n }\n\n return 1;\n}\n\n/**\n * Calculate initial zoom for the tileset from 3D `fullExtent` defined in\n * the tileset metadata\n * @param fullExtent - 3D extent of the tileset\n * @param fullExtent.xmin - minimal longitude in decimal degrees\n * @param fullExtent.xmax - maximal longitude in decimal degrees\n * @param fullExtent.ymin - minimal latitude in decimal degrees\n * @param fullExtent.ymax - maximal latitude in decimal degrees\n * @param fullExtent.zmin - minimal elevation in meters\n * @param fullExtent.zmax - maximal elevation in meters\n * @param cartorgraphicCenter - tileset center in cartographic coordinate system\n * @param cartesianCenter - tileset center in cartesian coordinate system\n * @returns - initial zoom for the tileset\n */\nexport function getZoomFromFullExtent(\n fullExtent: {\n xmin: number;\n xmax: number;\n ymin: number;\n ymax: number;\n zmin: number;\n zmax: number;\n },\n cartorgraphicCenter: Vector3,\n cartesianCenter: Vector3\n) {\n Ellipsoid.WGS84.cartographicToCartesian(\n [fullExtent.xmax, fullExtent.ymax, fullExtent.zmax],\n scratchVector\n );\n const extentSize = Math.sqrt(\n Math.pow(scratchVector[0] - cartesianCenter[0], 2) +\n Math.pow(scratchVector[1] - cartesianCenter[1], 2) +\n Math.pow(scratchVector[2] - cartesianCenter[2], 2)\n );\n return Math.log2(WGS84_RADIUS_Z / (extentSize + cartorgraphicCenter[2]));\n}\n\n/**\n * Calculate initial zoom for the tileset from 2D `extent` defined in\n * the tileset metadata\n * @param extent - 2D extent of the tileset. It is array of 4 elements [xmin, ymin, xmax, ymax]\n * @param extent[0] - minimal longitude in decimal degrees\n * @param extent[1] - minimal latitude in decimal degrees\n * @param extent[2] - maximal longitude in decimal degrees\n * @param extent[3] - maximal latitude in decimal degrees\n * @param cartorgraphicCenter - tileset center in cartographic coordinate system\n * @param cartesianCenter - tileset center in cartesian coordinate system\n * @returns - initial zoom for the tileset\n */\nexport function getZoomFromExtent(\n extent: [number, number, number, number],\n cartorgraphicCenter: Vector3,\n cartesianCenter: Vector3\n) {\n const [xmin, ymin, xmax, ymax] = extent;\n return getZoomFromFullExtent(\n {xmin, xmax, ymin, ymax, zmin: 0, zmax: 0},\n cartorgraphicCenter,\n cartesianCenter\n );\n}\n\nfunction getObbSize(halfAxes) {\n halfAxes.getColumn(0, scratchVector);\n const axeY = halfAxes.getColumn(1);\n const axeZ = halfAxes.getColumn(2);\n const farthestVertex = scratchVector.add(axeY).add(axeZ);\n const size = farthestVertex.len();\n return size;\n}\n"],"mappings":"AAEA,SAAQA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oErC,aAAa;IAab;;;;;OAKG;IACH,gBAAgB,CAAC,UAAU,KAAA,EAAE,WAAW,KAAA;IA+BxC,UAAU,CAAC,UAAU,KAAA,EAAE,yBAAyB,KAAA;IAyBhD,iBAAiB;IAuCjB;;;;OAIG;IACH,cAAc,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM;IAK9C;;;;OAIG;IACH,iBAAiB,CAAC,EAAC,MAAM,EAAC;;KAAA,GAAG,MAAM;IAMnC;;;;OAIG;IACH,yBAAyB,CAAC,UAAU,EAAE,UAAU;IAUhD,gBAAgB;IAWhB,IAAI,MAAM,QAET;IAID,oBAAoB,CAAC,MAAM,KAAA;IAsB3B,qBAAqB,CAAC,UAAU,KAAA;IAkBhC,0BAA0B,CAAC,UAAU,KAAA;IAOrC,kBAAkB,CAAC,UAAU,KAAA;IAiB7B,yBAAyB,CAAC,MAAM,KAAA;IAwBhC,UAAU,CAAC,MAAM,KAAA;IAKjB,UAAU;IAIV,gBAAgB;IAmBhB,qBAAqB,CAAC,MAAM,KAAA;IAoC5B,gBAAgB,CAAC,eAAe,UAAgB;IAchD,yBAAyB,CAAC,QAAQ,KAAA;;;;;;;;;;;;;;;;;;;CA2BnC"}
@@ -1,13 +1,12 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
1
  import { Vector3, Matrix4 } from '@math.gl/core';
3
2
  import { CullingVolume } from '@math.gl/culling';
4
3
  import { load } from '@loaders.gl/core';
5
- import { TILE_REFINEMENT, TILE_CONTENT_STATE, TILESET_TYPE } from '../constants';
6
- import { createBoundingVolume, getCartographicBounds } from './helpers/bounding-volume';
7
- import { getTiles3DScreenSpaceError } from './helpers/tiles-3d-lod';
8
- import { getProjectedRadius } from './helpers/i3s-lod';
9
- import { get3dTilesOptions } from './helpers/3d-tiles-options';
10
- import { TilesetTraverser } from './tileset-traverser';
4
+ import { TILE_REFINEMENT, TILE_CONTENT_STATE, TILESET_TYPE } from "../constants.js";
5
+ import { createBoundingVolume, getCartographicBounds } from "./helpers/bounding-volume.js";
6
+ import { getTiles3DScreenSpaceError } from "./helpers/tiles-3d-lod.js";
7
+ import { getProjectedRadius } from "./helpers/i3s-lod.js";
8
+ import { get3dTilesOptions } from "./helpers/3d-tiles-options.js";
9
+ import { TilesetTraverser } from "./tileset-traverser.js";
11
10
  const scratchVector = new Vector3();
12
11
  function defined(x) {
13
12
  return x !== undefined && x !== null;
@@ -15,54 +14,54 @@ function defined(x) {
15
14
  export class Tile3D {
16
15
  constructor(tileset, header, parentHeader) {
17
16
  let extendedId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
18
- _defineProperty(this, "tileset", void 0);
19
- _defineProperty(this, "header", void 0);
20
- _defineProperty(this, "id", void 0);
21
- _defineProperty(this, "url", void 0);
22
- _defineProperty(this, "parent", void 0);
23
- _defineProperty(this, "refine", void 0);
24
- _defineProperty(this, "type", void 0);
25
- _defineProperty(this, "contentUrl", void 0);
26
- _defineProperty(this, "lodMetricType", 'geometricError');
27
- _defineProperty(this, "lodMetricValue", 0);
28
- _defineProperty(this, "boundingVolume", null);
29
- _defineProperty(this, "content", null);
30
- _defineProperty(this, "contentState", TILE_CONTENT_STATE.UNLOADED);
31
- _defineProperty(this, "gpuMemoryUsageInBytes", 0);
32
- _defineProperty(this, "children", []);
33
- _defineProperty(this, "depth", 0);
34
- _defineProperty(this, "viewportIds", []);
35
- _defineProperty(this, "transform", new Matrix4());
36
- _defineProperty(this, "extensions", null);
37
- _defineProperty(this, "implicitTiling", null);
38
- _defineProperty(this, "userData", {});
39
- _defineProperty(this, "computedTransform", void 0);
40
- _defineProperty(this, "hasEmptyContent", false);
41
- _defineProperty(this, "hasTilesetContent", false);
42
- _defineProperty(this, "traverser", new TilesetTraverser({}));
43
- _defineProperty(this, "_cacheNode", null);
44
- _defineProperty(this, "_frameNumber", null);
45
- _defineProperty(this, "_expireDate", null);
46
- _defineProperty(this, "_expiredContent", null);
47
- _defineProperty(this, "_boundingBox", void 0);
48
- _defineProperty(this, "_distanceToCamera", 0);
49
- _defineProperty(this, "_screenSpaceError", 0);
50
- _defineProperty(this, "_visibilityPlaneMask", void 0);
51
- _defineProperty(this, "_visible", undefined);
52
- _defineProperty(this, "_contentBoundingVolume", void 0);
53
- _defineProperty(this, "_viewerRequestVolume", void 0);
54
- _defineProperty(this, "_initialTransform", new Matrix4());
55
- _defineProperty(this, "_priority", 0);
56
- _defineProperty(this, "_selectedFrame", 0);
57
- _defineProperty(this, "_requestedFrame", 0);
58
- _defineProperty(this, "_selectionDepth", 0);
59
- _defineProperty(this, "_touchedFrame", 0);
60
- _defineProperty(this, "_centerZDepth", 0);
61
- _defineProperty(this, "_shouldRefine", false);
62
- _defineProperty(this, "_stackLength", 0);
63
- _defineProperty(this, "_visitedFrame", 0);
64
- _defineProperty(this, "_inRequestVolume", false);
65
- _defineProperty(this, "_lodJudge", null);
17
+ this.tileset = void 0;
18
+ this.header = void 0;
19
+ this.id = void 0;
20
+ this.url = void 0;
21
+ this.parent = void 0;
22
+ this.refine = void 0;
23
+ this.type = void 0;
24
+ this.contentUrl = void 0;
25
+ this.lodMetricType = 'geometricError';
26
+ this.lodMetricValue = 0;
27
+ this.boundingVolume = null;
28
+ this.content = null;
29
+ this.contentState = TILE_CONTENT_STATE.UNLOADED;
30
+ this.gpuMemoryUsageInBytes = 0;
31
+ this.children = [];
32
+ this.depth = 0;
33
+ this.viewportIds = [];
34
+ this.transform = new Matrix4();
35
+ this.extensions = null;
36
+ this.implicitTiling = null;
37
+ this.userData = {};
38
+ this.computedTransform = void 0;
39
+ this.hasEmptyContent = false;
40
+ this.hasTilesetContent = false;
41
+ this.traverser = new TilesetTraverser({});
42
+ this._cacheNode = null;
43
+ this._frameNumber = null;
44
+ this._expireDate = null;
45
+ this._expiredContent = null;
46
+ this._boundingBox = undefined;
47
+ this._distanceToCamera = 0;
48
+ this._screenSpaceError = 0;
49
+ this._visibilityPlaneMask = void 0;
50
+ this._visible = undefined;
51
+ this._contentBoundingVolume = void 0;
52
+ this._viewerRequestVolume = void 0;
53
+ this._initialTransform = new Matrix4();
54
+ this._priority = 0;
55
+ this._selectedFrame = 0;
56
+ this._requestedFrame = 0;
57
+ this._selectionDepth = 0;
58
+ this._touchedFrame = 0;
59
+ this._centerZDepth = 0;
60
+ this._shouldRefine = false;
61
+ this._stackLength = 0;
62
+ this._visitedFrame = 0;
63
+ this._inRequestVolume = false;
64
+ this._lodJudge = null;
66
65
  this.header = header;
67
66
  this.tileset = tileset;
68
67
  this.id = extendedId || header.id;
@@ -286,7 +285,7 @@ export class Tile3D {
286
285
  this.lodMetricType = header.lodMetricType;
287
286
  } else {
288
287
  this.lodMetricType = this.parent && this.parent.lodMetricType || this.tileset.lodMetricType;
289
- console.warn("3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType");
288
+ console.warn(`3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType`);
290
289
  }
291
290
  if ('lodMetricValue' in header) {
292
291
  this.lodMetricValue = header.lodMetricValue;