@loaders.gl/tiles 4.0.0-alpha.5 → 4.0.0-alpha.7

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 (201) hide show
  1. package/dist/bundle.js +2 -2
  2. package/dist/constants.d.ts +6 -0
  3. package/dist/constants.d.ts.map +1 -1
  4. package/dist/constants.js +29 -26
  5. package/dist/dist.min.js +1994 -1035
  6. package/dist/es5/bundle.js +6 -0
  7. package/dist/es5/bundle.js.map +1 -0
  8. package/dist/es5/constants.js +44 -0
  9. package/dist/es5/constants.js.map +1 -0
  10. package/dist/es5/index.js +93 -0
  11. package/dist/es5/index.js.map +1 -0
  12. package/dist/es5/tileset/format-3d-tiles/tileset-3d-traverser.js +70 -0
  13. package/dist/es5/tileset/format-3d-tiles/tileset-3d-traverser.js.map +1 -0
  14. package/dist/es5/tileset/format-i3s/i3s-pending-tiles-register.js +45 -0
  15. package/dist/es5/tileset/format-i3s/i3s-pending-tiles-register.js.map +1 -0
  16. package/dist/es5/tileset/format-i3s/i3s-tile-manager.js +84 -0
  17. package/dist/es5/tileset/format-i3s/i3s-tile-manager.js.map +1 -0
  18. package/dist/es5/tileset/format-i3s/i3s-tileset-traverser.js +143 -0
  19. package/dist/es5/tileset/format-i3s/i3s-tileset-traverser.js.map +1 -0
  20. package/dist/es5/tileset/helpers/3d-tiles-options.js +12 -0
  21. package/dist/es5/tileset/helpers/3d-tiles-options.js.map +1 -0
  22. package/dist/es5/tileset/helpers/bounding-volume.js +176 -0
  23. package/dist/es5/tileset/helpers/bounding-volume.js.map +1 -0
  24. package/dist/es5/tileset/helpers/frame-state.js +129 -0
  25. package/dist/es5/tileset/helpers/frame-state.js.map +1 -0
  26. package/dist/es5/tileset/helpers/i3s-lod.js +60 -0
  27. package/dist/es5/tileset/helpers/i3s-lod.js.map +1 -0
  28. package/dist/es5/tileset/helpers/tiles-3d-lod.js +103 -0
  29. package/dist/es5/tileset/helpers/tiles-3d-lod.js.map +1 -0
  30. package/dist/es5/tileset/helpers/transform-utils.js +50 -0
  31. package/dist/es5/tileset/helpers/transform-utils.js.map +1 -0
  32. package/dist/es5/tileset/helpers/zoom.js +63 -0
  33. package/dist/es5/tileset/helpers/zoom.js.map +1 -0
  34. package/dist/es5/tileset/tile-3d.js +536 -0
  35. package/dist/es5/tileset/tile-3d.js.map +1 -0
  36. package/dist/es5/tileset/tileset-3d.js +855 -0
  37. package/dist/es5/tileset/tileset-3d.js.map +1 -0
  38. package/dist/es5/tileset/tileset-cache.js +82 -0
  39. package/dist/es5/tileset/tileset-cache.js.map +1 -0
  40. package/dist/es5/tileset/tileset-traverser.js +321 -0
  41. package/dist/es5/tileset/tileset-traverser.js.map +1 -0
  42. package/dist/es5/types.js +2 -0
  43. package/dist/es5/types.js.map +1 -0
  44. package/dist/es5/utils/doubly-linked-list-node.js +21 -0
  45. package/dist/es5/utils/doubly-linked-list-node.js.map +1 -0
  46. package/dist/es5/utils/doubly-linked-list.js +88 -0
  47. package/dist/es5/utils/doubly-linked-list.js.map +1 -0
  48. package/dist/es5/utils/managed-array.js +126 -0
  49. package/dist/es5/utils/managed-array.js.map +1 -0
  50. package/dist/esm/bundle.js +4 -0
  51. package/dist/esm/bundle.js.map +1 -0
  52. package/dist/esm/constants.js +32 -0
  53. package/dist/esm/constants.js.map +1 -0
  54. package/dist/esm/index.js +10 -0
  55. package/dist/esm/index.js.map +1 -0
  56. package/dist/{tileset/traversers → esm/tileset/format-3d-tiles}/tileset-3d-traverser.js +2 -13
  57. package/dist/esm/tileset/format-3d-tiles/tileset-3d-traverser.js.map +1 -0
  58. package/dist/esm/tileset/format-i3s/i3s-pending-tiles-register.js +26 -0
  59. package/dist/esm/tileset/format-i3s/i3s-pending-tiles-register.js.map +1 -0
  60. package/dist/esm/tileset/format-i3s/i3s-tile-manager.js +79 -0
  61. package/dist/esm/tileset/format-i3s/i3s-tile-manager.js.map +1 -0
  62. package/dist/{tileset/traversers → esm/tileset/format-i3s}/i3s-tileset-traverser.js +14 -26
  63. package/dist/esm/tileset/format-i3s/i3s-tileset-traverser.js.map +1 -0
  64. package/dist/esm/tileset/helpers/3d-tiles-options.js +6 -0
  65. package/dist/esm/tileset/helpers/3d-tiles-options.js.map +1 -0
  66. package/dist/esm/tileset/helpers/bounding-volume.js +155 -0
  67. package/dist/esm/tileset/helpers/bounding-volume.js.map +1 -0
  68. package/dist/esm/tileset/helpers/frame-state.js +109 -0
  69. package/dist/esm/tileset/helpers/frame-state.js.map +1 -0
  70. package/dist/esm/tileset/helpers/i3s-lod.js +53 -0
  71. package/dist/esm/tileset/helpers/i3s-lod.js.map +1 -0
  72. package/dist/esm/tileset/helpers/tiles-3d-lod.js +100 -0
  73. package/dist/{tileset → esm/tileset}/helpers/tiles-3d-lod.js.map +1 -1
  74. package/dist/esm/tileset/helpers/transform-utils.js +50 -0
  75. package/dist/esm/tileset/helpers/transform-utils.js.map +1 -0
  76. package/dist/esm/tileset/helpers/zoom.js +55 -0
  77. package/dist/esm/tileset/helpers/zoom.js.map +1 -0
  78. package/dist/esm/tileset/tile-3d.js +414 -0
  79. package/dist/esm/tileset/tile-3d.js.map +1 -0
  80. package/dist/esm/tileset/tileset-3d.js +606 -0
  81. package/dist/esm/tileset/tileset-3d.js.map +1 -0
  82. package/dist/esm/tileset/tileset-cache.js +57 -0
  83. package/dist/esm/tileset/tileset-cache.js.map +1 -0
  84. package/dist/{tileset/traversers → esm/tileset}/tileset-traverser.js +29 -88
  85. package/dist/esm/tileset/tileset-traverser.js.map +1 -0
  86. package/dist/esm/types.js +2 -0
  87. package/dist/esm/types.js.map +1 -0
  88. package/dist/esm/utils/doubly-linked-list-node.js +12 -0
  89. package/dist/esm/utils/doubly-linked-list-node.js.map +1 -0
  90. package/dist/esm/utils/doubly-linked-list.js +65 -0
  91. package/dist/esm/utils/doubly-linked-list.js.map +1 -0
  92. package/dist/esm/utils/managed-array.js +87 -0
  93. package/dist/esm/utils/managed-array.js.map +1 -0
  94. package/dist/index.d.ts +4 -4
  95. package/dist/index.d.ts.map +1 -1
  96. package/dist/index.js +26 -10
  97. package/dist/tileset/{traversers → format-3d-tiles}/tileset-3d-traverser.d.ts +2 -2
  98. package/dist/tileset/format-3d-tiles/tileset-3d-traverser.d.ts.map +1 -0
  99. package/dist/tileset/format-3d-tiles/tileset-3d-traverser.js +54 -0
  100. package/dist/tileset/format-i3s/i3s-pending-tiles-register.d.ts +27 -0
  101. package/dist/tileset/format-i3s/i3s-pending-tiles-register.d.ts.map +1 -0
  102. package/dist/tileset/format-i3s/i3s-pending-tiles-register.js +47 -0
  103. package/dist/tileset/format-i3s/i3s-tile-manager.d.ts +34 -0
  104. package/dist/tileset/format-i3s/i3s-tile-manager.d.ts.map +1 -0
  105. package/dist/tileset/format-i3s/i3s-tile-manager.js +80 -0
  106. package/dist/tileset/format-i3s/i3s-tileset-traverser.d.ts +25 -0
  107. package/dist/tileset/format-i3s/i3s-tileset-traverser.d.ts.map +1 -0
  108. package/dist/tileset/format-i3s/i3s-tileset-traverser.js +92 -0
  109. package/dist/tileset/helpers/3d-tiles-options.d.ts +3 -2
  110. package/dist/tileset/helpers/3d-tiles-options.d.ts.map +1 -1
  111. package/dist/tileset/helpers/3d-tiles-options.js +8 -5
  112. package/dist/tileset/helpers/bounding-volume.d.ts +10 -0
  113. package/dist/tileset/helpers/bounding-volume.d.ts.map +1 -1
  114. package/dist/tileset/helpers/bounding-volume.js +274 -69
  115. package/dist/tileset/helpers/frame-state.d.ts +16 -5
  116. package/dist/tileset/helpers/frame-state.d.ts.map +1 -1
  117. package/dist/tileset/helpers/frame-state.js +131 -49
  118. package/dist/tileset/helpers/i3s-lod.d.ts +1 -1
  119. package/dist/tileset/helpers/i3s-lod.d.ts.map +1 -1
  120. package/dist/tileset/helpers/i3s-lod.js +82 -64
  121. package/dist/tileset/helpers/tiles-3d-lod.d.ts.map +1 -1
  122. package/dist/tileset/helpers/tiles-3d-lod.js +112 -100
  123. package/dist/tileset/helpers/transform-utils.d.ts.map +1 -1
  124. package/dist/tileset/helpers/transform-utils.js +51 -56
  125. package/dist/tileset/helpers/zoom.d.ts +41 -2
  126. package/dist/tileset/helpers/zoom.d.ts.map +1 -1
  127. package/dist/tileset/helpers/zoom.js +83 -30
  128. package/dist/tileset/tile-3d.d.ts +82 -35
  129. package/dist/tileset/tile-3d.d.ts.map +1 -1
  130. package/dist/tileset/tile-3d.js +607 -534
  131. package/dist/tileset/tileset-3d.d.ts +140 -48
  132. package/dist/tileset/tileset-3d.d.ts.map +1 -1
  133. package/dist/tileset/tileset-3d.js +693 -652
  134. package/dist/tileset/tileset-cache.d.ts +6 -5
  135. package/dist/tileset/tileset-cache.d.ts.map +1 -1
  136. package/dist/tileset/tileset-cache.js +66 -73
  137. package/dist/tileset/tileset-traverser.d.ts +57 -0
  138. package/dist/tileset/tileset-traverser.d.ts.map +1 -0
  139. package/dist/tileset/tileset-traverser.js +300 -0
  140. package/dist/types.d.ts +34 -0
  141. package/dist/types.d.ts.map +1 -0
  142. package/dist/types.js +2 -0
  143. package/dist/utils/doubly-linked-list-node.d.ts +1 -2
  144. package/dist/utils/doubly-linked-list-node.d.ts.map +1 -1
  145. package/dist/utils/doubly-linked-list-node.js +17 -15
  146. package/dist/utils/doubly-linked-list.d.ts +2 -3
  147. package/dist/utils/doubly-linked-list.d.ts.map +1 -1
  148. package/dist/utils/doubly-linked-list.js +91 -75
  149. package/dist/utils/managed-array.d.ts +1 -1
  150. package/dist/utils/managed-array.d.ts.map +1 -1
  151. package/dist/utils/managed-array.js +144 -109
  152. package/package.json +11 -8
  153. package/src/constants.ts +20 -0
  154. package/src/index.ts +6 -4
  155. package/src/tileset/{traversers → format-3d-tiles}/tileset-3d-traverser.ts +4 -2
  156. package/src/tileset/format-i3s/i3s-pending-tiles-register.ts +44 -0
  157. package/src/tileset/format-i3s/i3s-tile-manager.ts +101 -0
  158. package/src/tileset/{traversers → format-i3s}/i3s-tileset-traverser.ts +25 -12
  159. package/src/tileset/helpers/3d-tiles-options.ts +3 -1
  160. package/src/tileset/helpers/bounding-volume.ts +136 -0
  161. package/src/tileset/helpers/frame-state.ts +102 -18
  162. package/src/tileset/helpers/i3s-lod.ts +24 -21
  163. package/src/tileset/helpers/tiles-3d-lod.ts +2 -0
  164. package/src/tileset/helpers/transform-utils.ts +2 -0
  165. package/src/tileset/helpers/zoom.ts +84 -9
  166. package/src/tileset/tile-3d.ts +137 -123
  167. package/src/tileset/tileset-3d.ts +378 -251
  168. package/src/tileset/tileset-cache.ts +24 -17
  169. package/src/tileset/{traversers/tileset-traverser.ts → tileset-traverser.ts} +71 -72
  170. package/src/types.ts +36 -0
  171. package/src/utils/doubly-linked-list-node.ts +3 -2
  172. package/src/utils/doubly-linked-list.ts +2 -3
  173. package/src/utils/managed-array.ts +1 -1
  174. package/dist/bundle.js.map +0 -1
  175. package/dist/constants.js.map +0 -1
  176. package/dist/index.js.map +0 -1
  177. package/dist/tileset/helpers/3d-tiles-options.js.map +0 -1
  178. package/dist/tileset/helpers/bounding-volume.js.map +0 -1
  179. package/dist/tileset/helpers/frame-state.js.map +0 -1
  180. package/dist/tileset/helpers/i3s-lod.js.map +0 -1
  181. package/dist/tileset/helpers/transform-utils.js.map +0 -1
  182. package/dist/tileset/helpers/zoom.js.map +0 -1
  183. package/dist/tileset/tile-3d.js.map +0 -1
  184. package/dist/tileset/tileset-3d.js.map +0 -1
  185. package/dist/tileset/tileset-cache.js.map +0 -1
  186. package/dist/tileset/traversers/i3s-tile-manager.d.ts +0 -8
  187. package/dist/tileset/traversers/i3s-tile-manager.d.ts.map +0 -1
  188. package/dist/tileset/traversers/i3s-tile-manager.js +0 -45
  189. package/dist/tileset/traversers/i3s-tile-manager.js.map +0 -1
  190. package/dist/tileset/traversers/i3s-tileset-traverser.d.ts +0 -18
  191. package/dist/tileset/traversers/i3s-tileset-traverser.d.ts.map +0 -1
  192. package/dist/tileset/traversers/i3s-tileset-traverser.js.map +0 -1
  193. package/dist/tileset/traversers/tileset-3d-traverser.d.ts.map +0 -1
  194. package/dist/tileset/traversers/tileset-3d-traverser.js.map +0 -1
  195. package/dist/tileset/traversers/tileset-traverser.d.ts +0 -52
  196. package/dist/tileset/traversers/tileset-traverser.d.ts.map +0 -1
  197. package/dist/tileset/traversers/tileset-traverser.js.map +0 -1
  198. package/dist/utils/doubly-linked-list-node.js.map +0 -1
  199. package/dist/utils/doubly-linked-list.js.map +0 -1
  200. package/dist/utils/managed-array.js.map +0 -1
  201. package/src/tileset/traversers/i3s-tile-manager.ts +0 -39
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/tileset/helpers/tiles-3d-lod.ts"],"names":["Matrix4","Vector3","clamp","scratchPositionNormal","scratchCartographic","scratchMatrix","scratchCenter","scratchPosition","scratchDirection","calculateDynamicScreenSpaceError","root","camera","mapProjection","options","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"],"mappings":"AAQA,SAAQA,OAAR,EAAiBC,OAAjB,EAA0BC,KAA1B,QAAsC,eAAtC;AAEA,MAAMC,qBAAqB,GAAG,IAAIF,OAAJ,EAA9B;AACA,MAAMG,mBAAmB,GAAG,IAAIH,OAAJ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AH,GAAiCO,MAAtD;AACA,WAAOE,YAAP;AACD;;AAED,SAAO,CAAP;AACD;AAED,OAAO,SAASC,0BAAT,CAAoCC,IAApC,EAA0CC,UAA1C,EAAsDC,kBAAtD,EAA0E;AAC/E,QAAMT,OAAO,GAAGO,IAAI,CAACP,OAArB;AACA,QAAMU,oBAAoB,GAAIH,IAAI,CAACI,MAAL,IAAeJ,IAAI,CAACI,MAAL,CAAYC,cAA5B,IAA+CL,IAAI,CAACK,cAAjF;AACA,QAAMA,cAAc,GAAGH,kBAAkB,GAAGC,oBAAH,GAA0BH,IAAI,CAACK,cAAxE;;AAGA,MAAIA,cAAc,KAAK,GAAvB,EAA4B;AAC1B,WAAO,GAAP;AACD;;AAMD,QAAMC,QAAQ,GAAGtB,IAAI,CAACuB,GAAL,CAASP,IAAI,CAACQ,iBAAd,EAAiC,IAAjC,CAAjB;AACA,QAAM;AAAC/D,IAAAA,MAAD;AAASgE,IAAAA;AAAT,MAA2BR,UAAjC;AACA,QAAM;AAACS,IAAAA;AAAD,MAAsBjB,OAAO,CAACrD,OAApC;AACA,MAAIuE,KAAK,GAAIN,cAAc,GAAG5D,MAAjB,IAA2BiE,iBAAiB,IAAI,GAAhD,CAAD,IAA0DJ,QAAQ,GAAGG,cAArE,CAAZ;AAEAE,EAAAA,KAAK,IAAInB,0BAA0B,CAACC,OAAD,EAAUa,QAAV,CAAnC;AAEA,SAAOK,KAAP;AACD","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// 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"],"file":"tiles-3d-lod.js"}
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,IAAI,EAAAC,IAAA,EAAyC;EAAA,IAAvC;IAACC,MAAM;IAAEC;EAAa,CAAC,GAAAF,IAAA;EAAA,IAAEG,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAC1F,MAAM;IAACG,oCAAoC,GAAG,IAAI;IAAEC,8BAA8B,GAAG;EAAO,CAAC,GAC3FL,OAAO;EAET,IAAIM,EAAE;EACN,IAAIC,SAAS;EACb,IAAIC,MAAM;EACV,IAAIC,aAAa;EACjB,IAAIC,aAAa;EAEjB,MAAMC,kBAAkB,GAAGf,IAAI,CAACgB,qBAAqB;EAErD,IAAID,kBAAkB,YAAYE,kBAAkB,EAAE;IACpDP,EAAE,GAAGQ,UAAU,CAACC,SAAS,CAACjB,MAAM,CAACkB,UAAU,EAAE3B,qBAAqB,CAAC;IACnEkB,SAAS,GAAGT,MAAM,CAACmB,WAAW;I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 import { Matrix4, Vector3 } from '@math.gl/core';
3
+ import { assert } from '@loaders.gl/loader-utils';
4
+ export function calculateTransformProps(tileHeader, tile) {
5
+ assert(tileHeader);
6
+ assert(tile);
7
+ const {
8
+ rtcCenter,
9
+ gltfUpAxis
10
+ } = tile;
11
+ const {
12
+ computedTransform,
13
+ boundingVolume: {
14
+ center
15
+ }
16
+ } = tileHeader;
17
+ let modelMatrix = new Matrix4(computedTransform);
18
+ if (rtcCenter) {
19
+ modelMatrix.translate(rtcCenter);
20
+ }
21
+ switch (gltfUpAxis) {
22
+ case 'Z':
23
+ break;
24
+ case 'Y':
25
+ const rotationY = new Matrix4().rotateX(Math.PI / 2);
26
+ modelMatrix = modelMatrix.multiplyRight(rotationY);
27
+ break;
28
+ case 'X':
29
+ const rotationX = new Matrix4().rotateY(-Math.PI / 2);
30
+ modelMatrix = modelMatrix.multiplyRight(rotationX);
31
+ break;
32
+ default:
33
+ break;
34
+ }
35
+ if (tile.isQuantized) {
36
+ modelMatrix.translate(tile.quantizedVolumeOffset).scale(tile.quantizedVolumeScale);
37
+ }
38
+ const cartesianOrigin = new Vector3(center);
39
+ tile.cartesianModelMatrix = modelMatrix;
40
+ tile.cartesianOrigin = cartesianOrigin;
41
+ const cartographicOrigin = Ellipsoid.WGS84.cartesianToCartographic(cartesianOrigin, new Vector3());
42
+ const fromFixedFrameMatrix = Ellipsoid.WGS84.eastNorthUpToFixedFrame(cartesianOrigin);
43
+ const toFixedFrameMatrix = fromFixedFrameMatrix.invert();
44
+ tile.cartographicModelMatrix = toFixedFrameMatrix.multiplyRight(modelMatrix);
45
+ tile.cartographicOrigin = cartographicOrigin;
46
+ if (!tile.coordinateSystem) {
47
+ tile.modelMatrix = tile.cartographicModelMatrix;
48
+ }
49
+ }
50
+ //# sourceMappingURL=transform-utils.js.map
@@ -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;EACzB,CAAC,GAAGN,UAAU;EAEd,IAAIO,WAAW,GAAG,IAAIX,OAAO,CAACQ,iBAAiB,CAAC;EAGhD,IAAIF,SAAS,EAAE;IACbK,WAAW,CAACC,SAAS,CAACN,SAAS,CAAC;EAClC;EAIA,QAAQC,UAAU;IAChB,KAAK,GAAG;MACN;IACF,KAAK,GAAG;MACN,MAAMM,SAAS,GAAG,IAAIb,OAAO,CAAC,CAAC,CAACc,OAAO,CAACC,IAAI,CAACC,EAAE,GAAG,CAAC,CAAC;MACpDL,WAAW,GAAGA,WAAW,CAACM,aAAa,CAACJ,SAAS,CAAC;MAClD;IACF,KAAK,GAAG;MACN,MAAMK,SAAS,GAAG,IAAIlB,OAAO,CAAC,CAAC,CAACmB,OAAO,CAAC,CAACJ,IAAI,CAACC,EAAE,GAAG,CAAC,CAAC;MACrDL,WAAW,GAAGA,WAAW,CAACM,aAAa,CAACC,SAAS,CAAC;MAClD;IACF;MACE;EACJ;EAGA,IAAIb,IAAI,CAACe,WAAW,EAAE;IACpBT,WAAW,CAACC,SAAS,CAACP,IAAI,CAACgB,qBAAqB,CAAC,CAACC,KAAK,CAACjB,IAAI,CAACkB,oBAAoB,CAAC;EACpF;EAGA,MAAMC,eAAe,GAAG,IAAIvB,OAAO,CAACS,MAAM,CAAC;EAE3CL,IAAI,CAACoB,oBAAoB,GAAGd,WAAW;EACvCN,IAAI,CAACmB,eAAe,GAAGA,eAAe;EAGtC,MAAME,kBAAkB,GAAG3B,SAAS,CAAC4B,KAAK,CAACC,uBAAuB,CAChEJ,eAAe,EACf,IAAIvB,OAAO,CAAC,CACd,CAAC;EACD,MAAM4B,oBAAoB,GAAG9B,SAAS,CAAC4B,KAAK,CAACG,uBAAuB,CAACN,eAAe,CAAC;EACrF,MAAMO,kBAAkB,GAAGF,oBAAoB,CAACG,MAAM,CAAC,CAAC;EAExD3B,IAAI,CAAC4B,uBAAuB,GAAGF,kBAAkB,CAACd,aAAa,CAACN,WAAW,CAAC;EAC5EN,IAAI,CAACqB,kBAAkB,GAAGA,kBAAkB;EAG5C,IAAI,CAACrB,IAAI,CAAC6B,gBAAgB,EAAE;IAC1B7B,IAAI,CAACM,WAAW,GAAGN,IAAI,CAAC4B,uBAAuB;EACjD;AACF"}
@@ -0,0 +1,55 @@
1
+ import { Vector3 } from '@math.gl/core';
2
+ import { BoundingSphere, OrientedBoundingBox } from '@math.gl/culling';
3
+ import { Ellipsoid } from '@math.gl/geospatial';
4
+ const WGS84_RADIUS_X = 6378137.0;
5
+ const WGS84_RADIUS_Y = 6378137.0;
6
+ const WGS84_RADIUS_Z = 6356752.3142451793;
7
+ const scratchVector = new Vector3();
8
+ export function getZoomFromBoundingVolume(boundingVolume, cartorgraphicCenter) {
9
+ if (boundingVolume instanceof OrientedBoundingBox) {
10
+ const {
11
+ halfAxes
12
+ } = boundingVolume;
13
+ const obbSize = getObbSize(halfAxes);
14
+ return Math.log2(WGS84_RADIUS_Z / (obbSize + cartorgraphicCenter[2]));
15
+ } else if (boundingVolume instanceof BoundingSphere) {
16
+ const {
17
+ radius
18
+ } = boundingVolume;
19
+ return Math.log2(WGS84_RADIUS_Z / (radius + cartorgraphicCenter[2]));
20
+ } else if (boundingVolume.width && boundingVolume.height) {
21
+ const {
22
+ width,
23
+ height
24
+ } = boundingVolume;
25
+ const zoomX = Math.log2(WGS84_RADIUS_X / width);
26
+ const zoomY = Math.log2(WGS84_RADIUS_Y / height);
27
+ return (zoomX + zoomY) / 2;
28
+ }
29
+ return 1;
30
+ }
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));
34
+ return Math.log2(WGS84_RADIUS_Z / (extentSize + cartorgraphicCenter[2]));
35
+ }
36
+ export function getZoomFromExtent(extent, cartorgraphicCenter, cartesianCenter) {
37
+ const [xmin, ymin, xmax, ymax] = extent;
38
+ return getZoomFromFullExtent({
39
+ xmin,
40
+ xmax,
41
+ ymin,
42
+ ymax,
43
+ zmin: 0,
44
+ zmax: 0
45
+ }, cartorgraphicCenter, cartesianCenter);
46
+ }
47
+ function getObbSize(halfAxes) {
48
+ halfAxes.getColumn(0, scratchVector);
49
+ const axeY = halfAxes.getColumn(1);
50
+ const axeZ = halfAxes.getColumn(2);
51
+ const farthestVertex = scratchVector.add(axeY).add(axeZ);
52
+ const size = farthestVertex.len();
53
+ return size;
54
+ }
55
+ //# sourceMappingURL=zoom.js.map
@@ -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","extentVertex","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 const extentVertex = Ellipsoid.WGS84.cartographicToCartesian(\n [fullExtent.xmax, fullExtent.ymax, fullExtent.zmax],\n new Vector3()\n );\n const extentSize = Math.sqrt(\n Math.pow(extentVertex[0] - cartesianCenter[0], 2) +\n Math.pow(extentVertex[1] - cartesianCenter[1], 2) +\n Math.pow(extentVertex[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,OAAO,QAAO,eAAe;AACrC,SAAQC,cAAc,EAAEC,mBAAmB,QAAO,kBAAkB;AACpE,SAAQC,SAAS,QAAO,qBAAqB;AAG7C,MAAMC,cAAc,GAAG,SAAS;AAChC,MAAMC,cAAc,GAAG,SAAS;AAChC,MAAMC,cAAc,GAAG,kBAAkB;AAEzC,MAAMC,aAAa,GAAG,IAAIP,OAAO,CAAC,CAAC;AAQnC,OAAO,SAASQ,yBAAyBA,CACvCC,cAAwE,EACxEC,mBAA4B,EAC5B;EACA,IAAID,cAAc,YAAYP,mBAAmB,EAAE;IAEjD,MAAM;MAACS;IAAQ,CAAC,GAAGF,cAAc;IACjC,MAAMG,OAAO,GAAGC,UAAU,CAACF,QAAQ,CAAC;IAGpC,OAAOG,IAAI,CAACC,IAAI,CAACT,cAAc,IAAIM,OAAO,GAAGF,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;EACvE,CAAC,MAAM,IAAID,cAAc,YAAYR,cAAc,EAAE;IAEnD,MAAM;MAACe;IAAM,CAAC,GAAGP,cAAc;IAE/B,OAAOK,IAAI,CAACC,IAAI,CAACT,cAAc,IAAIU,MAAM,GAAGN,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;EACtE,CAAC,MAAM,IAAID,cAAc,CAACQ,KAAK,IAAIR,cAAc,CAACS,MAAM,EAAE;IAExD,MAAM;MAACD,KAAK;MAAEC;IAAM,CAAC,GAAGT,cAAc;IACtC,MAAMU,KAAK,GAAGL,IAAI,CAACC,IAAI,CAACX,cAAc,GAAGa,KAAK,CAAC;IAC/C,MAAMG,KAAK,GAAGN,IAAI,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CAACF,QAAQ,EAAE;EAC5BA,QAAQ,CAAC2B,SAAS,CAAC,CAAC,EAAE/B,aAAa,CAAC;EACpC,MAAMgC,IAAI,GAAG5B,QAAQ,CAAC2B,SAAS,CAAC,CAAC,CAAC;EAClC,MAAME,IAAI,GAAG7B,QAAQ,CAAC2B,SAAS,CAAC,CAAC,CAAC;EAClC,MAAMG,cAAc,GAAGlC,aAAa,CAACmC,GAAG,CAACH,IAAI,CAAC,CAACG,GAAG,CAACF,IAAI,CAAC;EACxD,MAAMG,IAAI,GAAGF,cAAc,CAACG,GAAG,CAAC,CAAC;EACjC,OAAOD,IAAI;AACb"}
@@ -0,0 +1,414 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import { Vector3, Matrix4 } from '@math.gl/core';
3
+ import { CullingVolume } from '@math.gl/culling';
4
+ 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';
11
+ const scratchVector = new Vector3();
12
+ function defined(x) {
13
+ return x !== undefined && x !== null;
14
+ }
15
+ export class Tile3D {
16
+ constructor(tileset, header, parentHeader) {
17
+ 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);
66
+ this.header = header;
67
+ this.tileset = tileset;
68
+ this.id = extendedId || header.id;
69
+ this.url = header.url;
70
+ this.parent = parentHeader;
71
+ this.refine = this._getRefine(header.refine);
72
+ this.type = header.type;
73
+ this.contentUrl = header.contentUrl;
74
+ this._initializeLodMetric(header);
75
+ this._initializeTransforms(header);
76
+ this._initializeBoundingVolumes(header);
77
+ this._initializeContent(header);
78
+ this._initializeRenderingState(header);
79
+ Object.seal(this);
80
+ }
81
+ destroy() {
82
+ this.header = null;
83
+ }
84
+ isDestroyed() {
85
+ return this.header === null;
86
+ }
87
+ get selected() {
88
+ return this._selectedFrame === this.tileset._frameNumber;
89
+ }
90
+ get isVisible() {
91
+ return this._visible;
92
+ }
93
+ get isVisibleAndInRequestVolume() {
94
+ return this._visible && this._inRequestVolume;
95
+ }
96
+ get hasRenderContent() {
97
+ return !this.hasEmptyContent && !this.hasTilesetContent;
98
+ }
99
+ get hasChildren() {
100
+ return this.children.length > 0 || this.header.children && this.header.children.length > 0;
101
+ }
102
+ get contentReady() {
103
+ return this.contentState === TILE_CONTENT_STATE.READY || this.hasEmptyContent;
104
+ }
105
+ get contentAvailable() {
106
+ return Boolean(this.contentReady && this.hasRenderContent || this._expiredContent && !this.contentFailed);
107
+ }
108
+ get hasUnloadedContent() {
109
+ return this.hasRenderContent && this.contentUnloaded;
110
+ }
111
+ get contentUnloaded() {
112
+ return this.contentState === TILE_CONTENT_STATE.UNLOADED;
113
+ }
114
+ get contentExpired() {
115
+ return this.contentState === TILE_CONTENT_STATE.EXPIRED;
116
+ }
117
+ get contentFailed() {
118
+ return this.contentState === TILE_CONTENT_STATE.FAILED;
119
+ }
120
+ get distanceToCamera() {
121
+ return this._distanceToCamera;
122
+ }
123
+ get screenSpaceError() {
124
+ return this._screenSpaceError;
125
+ }
126
+ get boundingBox() {
127
+ if (!this._boundingBox) {
128
+ this._boundingBox = getCartographicBounds(this.header.boundingVolume, this.boundingVolume);
129
+ }
130
+ return this._boundingBox;
131
+ }
132
+ getScreenSpaceError(frameState, useParentLodMetric) {
133
+ switch (this.tileset.type) {
134
+ case TILESET_TYPE.I3S:
135
+ return getProjectedRadius(this, frameState);
136
+ case TILESET_TYPE.TILES3D:
137
+ return getTiles3DScreenSpaceError(this, frameState, useParentLodMetric);
138
+ default:
139
+ throw new Error('Unsupported tileset type');
140
+ }
141
+ }
142
+ unselect() {
143
+ this._selectedFrame = 0;
144
+ }
145
+ _getGpuMemoryUsageInBytes() {
146
+ return this.content.gpuMemoryUsageInBytes || this.content.byteLength || 0;
147
+ }
148
+ _getPriority() {
149
+ const traverser = this.tileset._traverser;
150
+ const {
151
+ skipLevelOfDetail
152
+ } = traverser.options;
153
+ const maySkipTile = this.refine === TILE_REFINEMENT.ADD || skipLevelOfDetail;
154
+ if (maySkipTile && !this.isVisible && this._visible !== undefined) {
155
+ return -1;
156
+ }
157
+ if (this.tileset._frameNumber - this._touchedFrame >= 1) {
158
+ return -1;
159
+ }
160
+ if (this.contentState === TILE_CONTENT_STATE.UNLOADED) {
161
+ return -1;
162
+ }
163
+ const parent = this.parent;
164
+ const useParentScreenSpaceError = parent && (!maySkipTile || this._screenSpaceError === 0.0 || parent.hasTilesetContent);
165
+ const screenSpaceError = useParentScreenSpaceError ? parent._screenSpaceError : this._screenSpaceError;
166
+ const rootScreenSpaceError = traverser.root ? traverser.root._screenSpaceError : 0.0;
167
+ return Math.max(rootScreenSpaceError - screenSpaceError, 0);
168
+ }
169
+ async loadContent() {
170
+ if (this.hasEmptyContent) {
171
+ return false;
172
+ }
173
+ if (this.content) {
174
+ return true;
175
+ }
176
+ const expired = this.contentExpired;
177
+ if (expired) {
178
+ this._expireDate = null;
179
+ }
180
+ this.contentState = TILE_CONTENT_STATE.LOADING;
181
+ const requestToken = await this.tileset._requestScheduler.scheduleRequest(this.id, this._getPriority.bind(this));
182
+ if (!requestToken) {
183
+ this.contentState = TILE_CONTENT_STATE.UNLOADED;
184
+ return false;
185
+ }
186
+ try {
187
+ const contentUrl = this.tileset.getTileUrl(this.contentUrl);
188
+ const loader = this.tileset.loader;
189
+ const options = {
190
+ ...this.tileset.loadOptions,
191
+ [loader.id]: {
192
+ ...this.tileset.loadOptions[loader.id],
193
+ isTileset: this.type === 'json',
194
+ ...this._getLoaderSpecificOptions(loader.id)
195
+ }
196
+ };
197
+ this.content = await load(contentUrl, loader, options);
198
+ if (this.tileset.options.contentLoader) {
199
+ await this.tileset.options.contentLoader(this);
200
+ }
201
+ if (this._isTileset()) {
202
+ this.tileset._initializeTileHeaders(this.content, this);
203
+ }
204
+ this.contentState = TILE_CONTENT_STATE.READY;
205
+ this._onContentLoaded();
206
+ return true;
207
+ } catch (error) {
208
+ this.contentState = TILE_CONTENT_STATE.FAILED;
209
+ throw error;
210
+ } finally {
211
+ requestToken.done();
212
+ }
213
+ }
214
+ unloadContent() {
215
+ if (this.content && this.content.destroy) {
216
+ this.content.destroy();
217
+ }
218
+ this.content = null;
219
+ if (this.header.content && this.header.content.destroy) {
220
+ this.header.content.destroy();
221
+ }
222
+ this.header.content = null;
223
+ this.contentState = TILE_CONTENT_STATE.UNLOADED;
224
+ return true;
225
+ }
226
+ updateVisibility(frameState, viewportIds) {
227
+ if (this._frameNumber === frameState.frameNumber) {
228
+ return;
229
+ }
230
+ const parent = this.parent;
231
+ const parentVisibilityPlaneMask = parent ? parent._visibilityPlaneMask : CullingVolume.MASK_INDETERMINATE;
232
+ if (this.tileset._traverser.options.updateTransforms) {
233
+ const parentTransform = parent ? parent.computedTransform : this.tileset.modelMatrix;
234
+ this._updateTransform(parentTransform);
235
+ }
236
+ this._distanceToCamera = this.distanceToTile(frameState);
237
+ this._screenSpaceError = this.getScreenSpaceError(frameState, false);
238
+ this._visibilityPlaneMask = this.visibility(frameState, parentVisibilityPlaneMask);
239
+ this._visible = this._visibilityPlaneMask !== CullingVolume.MASK_OUTSIDE;
240
+ this._inRequestVolume = this.insideViewerRequestVolume(frameState);
241
+ this._frameNumber = frameState.frameNumber;
242
+ this.viewportIds = viewportIds;
243
+ }
244
+ visibility(frameState, parentVisibilityPlaneMask) {
245
+ const {
246
+ cullingVolume
247
+ } = frameState;
248
+ const {
249
+ boundingVolume
250
+ } = this;
251
+ return cullingVolume.computeVisibilityWithPlaneMask(boundingVolume, parentVisibilityPlaneMask);
252
+ }
253
+ contentVisibility() {
254
+ return true;
255
+ }
256
+ distanceToTile(frameState) {
257
+ const boundingVolume = this.boundingVolume;
258
+ return Math.sqrt(Math.max(boundingVolume.distanceSquaredTo(frameState.camera.position), 0));
259
+ }
260
+ cameraSpaceZDepth(_ref) {
261
+ let {
262
+ camera
263
+ } = _ref;
264
+ const boundingVolume = this.boundingVolume;
265
+ scratchVector.subVectors(boundingVolume.center, camera.position);
266
+ return camera.direction.dot(scratchVector);
267
+ }
268
+ insideViewerRequestVolume(frameState) {
269
+ const viewerRequestVolume = this._viewerRequestVolume;
270
+ return !viewerRequestVolume || viewerRequestVolume.distanceSquaredTo(frameState.camera.position) <= 0;
271
+ }
272
+ updateExpiration() {
273
+ if (defined(this._expireDate) && this.contentReady && !this.hasEmptyContent) {
274
+ const now = Date.now();
275
+ if (Date.lessThan(this._expireDate, now)) {
276
+ this.contentState = TILE_CONTENT_STATE.EXPIRED;
277
+ this._expiredContent = this.content;
278
+ }
279
+ }
280
+ }
281
+ get extras() {
282
+ return this.header.extras;
283
+ }
284
+ _initializeLodMetric(header) {
285
+ if ('lodMetricType' in header) {
286
+ this.lodMetricType = header.lodMetricType;
287
+ } else {
288
+ this.lodMetricType = this.parent && this.parent.lodMetricType || this.tileset.lodMetricType;
289
+ console.warn("3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType");
290
+ }
291
+ if ('lodMetricValue' in header) {
292
+ this.lodMetricValue = header.lodMetricValue;
293
+ } else {
294
+ this.lodMetricValue = this.parent && this.parent.lodMetricValue || this.tileset.lodMetricValue;
295
+ console.warn('3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue');
296
+ }
297
+ }
298
+ _initializeTransforms(tileHeader) {
299
+ this.transform = tileHeader.transform ? new Matrix4(tileHeader.transform) : new Matrix4();
300
+ const parent = this.parent;
301
+ const tileset = this.tileset;
302
+ const parentTransform = parent && parent.computedTransform ? parent.computedTransform.clone() : tileset.modelMatrix.clone();
303
+ this.computedTransform = new Matrix4(parentTransform).multiplyRight(this.transform);
304
+ const parentInitialTransform = parent && parent._initialTransform ? parent._initialTransform.clone() : new Matrix4();
305
+ this._initialTransform = new Matrix4(parentInitialTransform).multiplyRight(this.transform);
306
+ }
307
+ _initializeBoundingVolumes(tileHeader) {
308
+ this._contentBoundingVolume = null;
309
+ this._viewerRequestVolume = null;
310
+ this._updateBoundingVolume(tileHeader);
311
+ }
312
+ _initializeContent(tileHeader) {
313
+ this.content = {
314
+ _tileset: this.tileset,
315
+ _tile: this
316
+ };
317
+ this.hasEmptyContent = true;
318
+ this.contentState = TILE_CONTENT_STATE.UNLOADED;
319
+ this.hasTilesetContent = false;
320
+ if (tileHeader.contentUrl) {
321
+ this.content = null;
322
+ this.hasEmptyContent = false;
323
+ }
324
+ }
325
+ _initializeRenderingState(header) {
326
+ this.depth = header.level || (this.parent ? this.parent.depth + 1 : 0);
327
+ this._shouldRefine = false;
328
+ this._distanceToCamera = 0;
329
+ this._centerZDepth = 0;
330
+ this._screenSpaceError = 0;
331
+ this._visibilityPlaneMask = CullingVolume.MASK_INDETERMINATE;
332
+ this._visible = undefined;
333
+ this._inRequestVolume = false;
334
+ this._stackLength = 0;
335
+ this._selectionDepth = 0;
336
+ this._frameNumber = 0;
337
+ this._touchedFrame = 0;
338
+ this._visitedFrame = 0;
339
+ this._selectedFrame = 0;
340
+ this._requestedFrame = 0;
341
+ this._priority = 0.0;
342
+ }
343
+ _getRefine(refine) {
344
+ return refine || this.parent && this.parent.refine || TILE_REFINEMENT.REPLACE;
345
+ }
346
+ _isTileset() {
347
+ return this.contentUrl.indexOf('.json') !== -1;
348
+ }
349
+ _onContentLoaded() {
350
+ switch (this.content && this.content.type) {
351
+ case 'vctr':
352
+ case 'geom':
353
+ this.tileset._traverser.disableSkipLevelOfDetail = true;
354
+ break;
355
+ default:
356
+ }
357
+ if (this._isTileset()) {
358
+ this.hasTilesetContent = true;
359
+ } else {
360
+ this.gpuMemoryUsageInBytes = this._getGpuMemoryUsageInBytes();
361
+ }
362
+ }
363
+ _updateBoundingVolume(header) {
364
+ this.boundingVolume = createBoundingVolume(header.boundingVolume, this.computedTransform, this.boundingVolume);
365
+ const content = header.content;
366
+ if (!content) {
367
+ return;
368
+ }
369
+ if (content.boundingVolume) {
370
+ this._contentBoundingVolume = createBoundingVolume(content.boundingVolume, this.computedTransform, this._contentBoundingVolume);
371
+ }
372
+ if (header.viewerRequestVolume) {
373
+ this._viewerRequestVolume = createBoundingVolume(header.viewerRequestVolume, this.computedTransform, this._viewerRequestVolume);
374
+ }
375
+ }
376
+ _updateTransform() {
377
+ let parentTransform = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Matrix4();
378
+ const computedTransform = parentTransform.clone().multiplyRight(this.transform);
379
+ const didTransformChange = !computedTransform.equals(this.computedTransform);
380
+ if (!didTransformChange) {
381
+ return;
382
+ }
383
+ this.computedTransform = computedTransform;
384
+ this._updateBoundingVolume(this.header);
385
+ }
386
+ _getLoaderSpecificOptions(loaderId) {
387
+ switch (loaderId) {
388
+ case 'i3s':
389
+ return {
390
+ ...this.tileset.options.i3s,
391
+ _tileOptions: {
392
+ attributeUrls: this.header.attributeUrls,
393
+ textureUrl: this.header.textureUrl,
394
+ textureFormat: this.header.textureFormat,
395
+ textureLoaderOptions: this.header.textureLoaderOptions,
396
+ materialDefinition: this.header.materialDefinition,
397
+ isDracoGeometry: this.header.isDracoGeometry,
398
+ mbs: this.header.mbs
399
+ },
400
+ _tilesetOptions: {
401
+ store: this.tileset.tileset.store,
402
+ attributeStorageInfo: this.tileset.tileset.attributeStorageInfo,
403
+ fields: this.tileset.tileset.fields
404
+ },
405
+ isTileHeader: false
406
+ };
407
+ case '3d-tiles':
408
+ case 'cesium-ion':
409
+ default:
410
+ return get3dTilesOptions(this.tileset.tileset);
411
+ }
412
+ }
413
+ }
414
+ //# sourceMappingURL=tile-3d.js.map