QuadtreeTileProvider.js 8.9 KB

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