QuadtreeTileProvider.js 8.8 KB

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