QuadtreeTileProvider.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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. * @deprecated
  46. */
  47. ready: {
  48. get: DeveloperError.throwInstantiationError,
  49. },
  50. /**
  51. * Gets the tiling scheme used by the provider.
  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.
  106. *
  107. * @see QuadtreeTileProvider#computeDefaultLevelZeroMaximumGeometricError
  108. *
  109. * @memberof QuadtreeTileProvider
  110. * @function
  111. *
  112. * @param {number} level The tile level for which to get the maximum geometric error.
  113. * @returns {number} The maximum geometric error in meters.
  114. */
  115. QuadtreeTileProvider.prototype.getLevelMaximumGeometricError =
  116. DeveloperError.throwInstantiationError;
  117. /**
  118. * Loads, or continues loading, a given tile. This function will continue to be called
  119. * until {@link QuadtreeTile#state} is no longer {@link QuadtreeTileLoadState#LOADING}.
  120. *
  121. * @memberof QuadtreeTileProvider
  122. * @function
  123. *
  124. * @param {Context} context The rendering context.
  125. * @param {FrameState} frameState The frame state.
  126. * @param {QuadtreeTile} tile The tile to load.
  127. */
  128. QuadtreeTileProvider.prototype.loadTile =
  129. DeveloperError.throwInstantiationError;
  130. /**
  131. * Determines the visibility of a given tile. The tile may be fully visible, partially visible, or not
  132. * visible at all. Tiles that are renderable and are at least partially visible will be shown by a call
  133. * to {@link QuadtreeTileProvider#showTileThisFrame}.
  134. *
  135. * @memberof QuadtreeTileProvider
  136. *
  137. * @param {QuadtreeTile} tile The tile instance.
  138. * @param {FrameState} frameState The state information about the current frame.
  139. * @param {QuadtreeOccluders} occluders The objects that may occlude this tile.
  140. *
  141. * @returns {Visibility} The visibility of the tile.
  142. */
  143. QuadtreeTileProvider.prototype.computeTileVisibility =
  144. DeveloperError.throwInstantiationError;
  145. /**
  146. * Shows a specified tile in this frame. The provider can cause the tile to be shown by adding
  147. * render commands to the commandList, or use any other method as appropriate. The tile is not
  148. * expected to be visible next frame as well, unless this method is call next frame, too.
  149. *
  150. * @memberof QuadtreeTileProvider
  151. * @function
  152. *
  153. * @param {QuadtreeTile} tile The tile instance.
  154. * @param {Context} context The rendering context.
  155. * @param {FrameState} frameState The state information of the current rendering frame.
  156. * @param {DrawCommand[]} commandList The list of rendering commands. This method may add additional commands to this list.
  157. */
  158. QuadtreeTileProvider.prototype.showTileThisFrame =
  159. DeveloperError.throwInstantiationError;
  160. /**
  161. * Gets the distance from the camera to the closest point on the tile. This is used for level-of-detail selection.
  162. *
  163. * @memberof QuadtreeTileProvider
  164. * @function
  165. *
  166. * @param {QuadtreeTile} tile The tile instance.
  167. * @param {FrameState} frameState The state information of the current rendering frame.
  168. *
  169. * @returns {number} The distance from the camera to the closest point on the tile, in meters.
  170. */
  171. QuadtreeTileProvider.prototype.computeDistanceToTile =
  172. DeveloperError.throwInstantiationError;
  173. /**
  174. * Returns true if this object was destroyed; otherwise, false.
  175. * <br /><br />
  176. * If this object was destroyed, it should not be used; calling any function other than
  177. * <code>isDestroyed</code> will result in a {@link DeveloperError} exception.
  178. *
  179. * @memberof QuadtreeTileProvider
  180. *
  181. * @returns {boolean} True if this object was destroyed; otherwise, false.
  182. *
  183. * @see QuadtreeTileProvider#destroy
  184. */
  185. QuadtreeTileProvider.prototype.isDestroyed =
  186. DeveloperError.throwInstantiationError;
  187. /**
  188. * Destroys the WebGL resources held by this object. Destroying an object allows for deterministic
  189. * release of WebGL resources, instead of relying on the garbage collector to destroy this object.
  190. * <br /><br />
  191. * Once an object is destroyed, it should not be used; calling any function other than
  192. * <code>isDestroyed</code> will result in a {@link DeveloperError} exception. Therefore,
  193. * assign the return value (<code>undefined</code>) to the object as done in the example.
  194. *
  195. * @memberof QuadtreeTileProvider
  196. *
  197. * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
  198. *
  199. *
  200. * @example
  201. * provider = provider && provider();
  202. *
  203. * @see QuadtreeTileProvider#isDestroyed
  204. */
  205. QuadtreeTileProvider.prototype.destroy = DeveloperError.throwInstantiationError;
  206. export default QuadtreeTileProvider;