QuadtreeTileProvider.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. import DeveloperError from "../Core/DeveloperError.js";
  2. /**
  3. * Provides general quadtree tiles to be displayed on or near the surface of an ellipsoid. It is intended to be
  4. * used with the {@link QuadtreePrimitive}. This type describes an interface and is not intended to be
  5. * instantiated directly.
  6. *
  7. * @alias QuadtreeTileProvider
  8. * @constructor
  9. * @private
  10. */
  11. function QuadtreeTileProvider() {
  12. DeveloperError.throwInstantiationError();
  13. }
  14. /**
  15. * Computes the default geometric error for level zero of the quadtree.
  16. *
  17. * @memberof QuadtreeTileProvider
  18. *
  19. * @param {TilingScheme} tilingScheme The tiling scheme for which to compute the geometric error.
  20. * @returns {Number} The maximum geometric error at level zero, in meters.
  21. */
  22. QuadtreeTileProvider.computeDefaultLevelZeroMaximumGeometricError = function (
  23. tilingScheme
  24. ) {
  25. return (
  26. (tilingScheme.ellipsoid.maximumRadius * 2 * Math.PI * 0.25) /
  27. (65 * tilingScheme.getNumberOfXTilesAtLevel(0))
  28. );
  29. };
  30. Object.defineProperties(QuadtreeTileProvider.prototype, {
  31. /**
  32. * Gets or sets the {@link QuadtreePrimitive} for which this provider is
  33. * providing tiles.
  34. * @memberof QuadtreeTileProvider.prototype
  35. * @type {QuadtreePrimitive}
  36. */
  37. quadtree: {
  38. get: DeveloperError.throwInstantiationError,
  39. set: DeveloperError.throwInstantiationError,
  40. },
  41. /**
  42. * Gets a value indicating whether or not the provider is ready for use.
  43. * @memberof QuadtreeTileProvider.prototype
  44. * @type {Boolean}
  45. */
  46. ready: {
  47. get: DeveloperError.throwInstantiationError,
  48. },
  49. /**
  50. * Gets the tiling scheme used by the provider. This property should
  51. * not be accessed before {@link QuadtreeTileProvider#ready} returns true.
  52. * @memberof QuadtreeTileProvider.prototype
  53. * @type {TilingScheme}
  54. */
  55. tilingScheme: {
  56. get: DeveloperError.throwInstantiationError,
  57. },
  58. /**
  59. * Gets an event that is raised when the geometry provider encounters an asynchronous error. By subscribing
  60. * to the event, you will be notified of the error and can potentially recover from it. Event listeners
  61. * are passed an instance of {@link TileProviderError}.
  62. * @memberof QuadtreeTileProvider.prototype
  63. * @type {Event}
  64. */
  65. errorEvent: {
  66. get: DeveloperError.throwInstantiationError,
  67. },
  68. });
  69. /**
  70. * Called at the beginning of the update cycle, regardless of id a new frame is being rendered, before {@link QuadtreeTileProvider#beginUpdate}
  71. * @memberof QuadtreeTileProvider
  72. * @function
  73. *
  74. * @param {Context} context The rendering context.
  75. * @param {FrameState} frameState The frame state.
  76. */
  77. QuadtreeTileProvider.prototype.update = DeveloperError.throwInstantiationError;
  78. /**
  79. * Called at the beginning of the update cycle for each render frame, before {@link QuadtreeTileProvider#showTileThisFrame}
  80. * or any other functions.
  81. * @memberof QuadtreeTileProvider
  82. * @function
  83. *
  84. * @param {Context} context The rendering context.
  85. * @param {FrameState} frameState The frame state.
  86. * @param {DrawCommand[]} commandList An array of rendering commands. This method may push
  87. * commands into this array.
  88. */
  89. QuadtreeTileProvider.prototype.beginUpdate =
  90. DeveloperError.throwInstantiationError;
  91. /**
  92. * Called at the end of the update cycle for each render frame, after {@link QuadtreeTileProvider#showTileThisFrame}
  93. * and any other functions.
  94. * @memberof QuadtreeTileProvider
  95. * @function
  96. *
  97. * @param {Context} context The rendering context.
  98. * @param {FrameState} frameState The frame state.
  99. * @param {DrawCommand[]} commandList An array of rendering commands. This method may push
  100. * commands into this array.
  101. */
  102. QuadtreeTileProvider.prototype.endUpdate =
  103. DeveloperError.throwInstantiationError;
  104. /**
  105. * Gets the maximum geometric error allowed in a tile at a given level, in meters. This function should not be
  106. * called before {@link QuadtreeTileProvider#ready} returns true.
  107. *
  108. * @see QuadtreeTileProvider#computeDefaultLevelZeroMaximumGeometricError
  109. *
  110. * @memberof QuadtreeTileProvider
  111. * @function
  112. *
  113. * @param {Number} level The tile level for which to get the maximum geometric error.
  114. * @returns {Number} The maximum geometric error in meters.
  115. */
  116. QuadtreeTileProvider.prototype.getLevelMaximumGeometricError =
  117. DeveloperError.throwInstantiationError;
  118. /**
  119. * Loads, or continues loading, a given tile. This function will continue to be called
  120. * until {@link QuadtreeTile#state} is no longer {@link QuadtreeTileLoadState#LOADING}. This function should
  121. * not be called before {@link QuadtreeTileProvider#ready} returns true.
  122. *
  123. * @memberof QuadtreeTileProvider
  124. * @function
  125. *
  126. * @param {Context} context The rendering context.
  127. * @param {FrameState} frameState The frame state.
  128. * @param {QuadtreeTile} tile The tile to load.
  129. *
  130. * @exception {DeveloperError} <code>loadTile</code> must not be called before the tile provider is ready.
  131. */
  132. QuadtreeTileProvider.prototype.loadTile =
  133. DeveloperError.throwInstantiationError;
  134. /**
  135. * Determines the visibility of a given tile. The tile may be fully visible, partially visible, or not
  136. * visible at all. Tiles that are renderable and are at least partially visible will be shown by a call
  137. * to {@link QuadtreeTileProvider#showTileThisFrame}.
  138. *
  139. * @memberof QuadtreeTileProvider
  140. *
  141. * @param {QuadtreeTile} tile The tile instance.
  142. * @param {FrameState} frameState The state information about the current frame.
  143. * @param {QuadtreeOccluders} occluders The objects that may occlude this tile.
  144. *
  145. * @returns {Visibility} The visibility of the tile.
  146. */
  147. QuadtreeTileProvider.prototype.computeTileVisibility =
  148. DeveloperError.throwInstantiationError;
  149. /**
  150. * Shows a specified tile in this frame. The provider can cause the tile to be shown by adding
  151. * render commands to the commandList, or use any other method as appropriate. The tile is not
  152. * expected to be visible next frame as well, unless this method is call next frame, too.
  153. *
  154. * @memberof QuadtreeTileProvider
  155. * @function
  156. *
  157. * @param {QuadtreeTile} tile The tile instance.
  158. * @param {Context} context The rendering context.
  159. * @param {FrameState} frameState The state information of the current rendering frame.
  160. * @param {DrawCommand[]} commandList The list of rendering commands. This method may add additional commands to this list.
  161. */
  162. QuadtreeTileProvider.prototype.showTileThisFrame =
  163. DeveloperError.throwInstantiationError;
  164. /**
  165. * Gets the distance from the camera to the closest point on the tile. This is used for level-of-detail selection.
  166. *
  167. * @memberof QuadtreeTileProvider
  168. * @function
  169. *
  170. * @param {QuadtreeTile} tile The tile instance.
  171. * @param {FrameState} frameState The state information of the current rendering frame.
  172. *
  173. * @returns {Number} The distance from the camera to the closest point on the tile, in meters.
  174. */
  175. QuadtreeTileProvider.prototype.computeDistanceToTile =
  176. DeveloperError.throwInstantiationError;
  177. /**
  178. * Returns true if this object was destroyed; otherwise, false.
  179. * <br /><br />
  180. * If this object was destroyed, it should not be used; calling any function other than
  181. * <code>isDestroyed</code> will result in a {@link DeveloperError} exception.
  182. *
  183. * @memberof QuadtreeTileProvider
  184. *
  185. * @returns {Boolean} True if this object was destroyed; otherwise, false.
  186. *
  187. * @see QuadtreeTileProvider#destroy
  188. */
  189. QuadtreeTileProvider.prototype.isDestroyed =
  190. DeveloperError.throwInstantiationError;
  191. /**
  192. * Destroys the WebGL resources held by this object. Destroying an object allows for deterministic
  193. * release of WebGL resources, instead of relying on the garbage collector to destroy this object.
  194. * <br /><br />
  195. * Once an object is destroyed, it should not be used; calling any function other than
  196. * <code>isDestroyed</code> will result in a {@link DeveloperError} exception. Therefore,
  197. * assign the return value (<code>undefined</code>) to the object as done in the example.
  198. *
  199. * @memberof QuadtreeTileProvider
  200. *
  201. * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
  202. *
  203. *
  204. * @example
  205. * provider = provider && provider();
  206. *
  207. * @see QuadtreeTileProvider#isDestroyed
  208. */
  209. QuadtreeTileProvider.prototype.destroy = DeveloperError.throwInstantiationError;
  210. export default QuadtreeTileProvider;