Cesium3DTileContent.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. import defineProperties from '../Core/defineProperties.js';
  2. import DeveloperError from '../Core/DeveloperError.js';
  3. /**
  4. * The content of a tile in a {@link Cesium3DTileset}.
  5. * <p>
  6. * Derived classes of this interface provide access to individual features in the tile.
  7. * Access derived objects through {@link Cesium3DTile#content}.
  8. * </p>
  9. * <p>
  10. * This type describes an interface and is not intended to be instantiated directly.
  11. * </p>
  12. *
  13. * @alias Cesium3DTileContent
  14. * @constructor
  15. */
  16. function Cesium3DTileContent(tileset, tile, url, arrayBuffer, byteOffset) {
  17. /**
  18. * Gets or sets if any feature's property changed. Used to
  19. * optimized applying a style when a feature's property changed.
  20. * <p>
  21. * This is used to implement the <code>Cesium3DTileContent</code> interface, but is
  22. * not part of the public Cesium API.
  23. * </p>
  24. *
  25. * @type {Boolean}
  26. *
  27. * @private
  28. */
  29. this.featurePropertiesDirty = false;
  30. }
  31. defineProperties(Cesium3DTileContent.prototype, {
  32. /**
  33. * Gets the number of features in the tile.
  34. *
  35. * @memberof Cesium3DTileContent.prototype
  36. *
  37. * @type {Number}
  38. * @readonly
  39. */
  40. featuresLength : {
  41. get : function() {
  42. DeveloperError.throwInstantiationError();
  43. }
  44. },
  45. /**
  46. * Gets the number of points in the tile.
  47. * <p>
  48. * Only applicable for tiles with Point Cloud content. This is different than {@link Cesium3DTileContent#featuresLength} which
  49. * equals the number of groups of points as distinguished by the <code>BATCH_ID</code> feature table semantic.
  50. * </p>
  51. *
  52. * @see {@link https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification/TileFormats/PointCloud#batched-points}
  53. *
  54. * @memberof Cesium3DTileContent.prototype
  55. *
  56. * @type {Number}
  57. * @readonly
  58. */
  59. pointsLength : {
  60. get : function() {
  61. DeveloperError.throwInstantiationError();
  62. }
  63. },
  64. /**
  65. * Gets the number of triangles in the tile.
  66. *
  67. * @memberof Cesium3DTileContent.prototype
  68. *
  69. * @type {Number}
  70. * @readonly
  71. */
  72. trianglesLength : {
  73. get : function() {
  74. DeveloperError.throwInstantiationError();
  75. }
  76. },
  77. /**
  78. * Gets the tile's geometry memory in bytes.
  79. *
  80. * @memberof Cesium3DTileContent.prototype
  81. *
  82. * @type {Number}
  83. * @readonly
  84. */
  85. geometryByteLength : {
  86. get : function() {
  87. DeveloperError.throwInstantiationError();
  88. }
  89. },
  90. /**
  91. * Gets the tile's texture memory in bytes.
  92. *
  93. * @memberof Cesium3DTileContent.prototype
  94. *
  95. * @type {Number}
  96. * @readonly
  97. */
  98. texturesByteLength : {
  99. get : function() {
  100. DeveloperError.throwInstantiationError();
  101. }
  102. },
  103. /**
  104. * Gets the amount of memory used by the batch table textures, in bytes.
  105. *
  106. * @memberof Cesium3DTileContent.prototype
  107. *
  108. * @type {Number}
  109. * @readonly
  110. */
  111. batchTableByteLength : {
  112. get : function() {
  113. DeveloperError.throwInstantiationError();
  114. }
  115. },
  116. /**
  117. * Gets the array of {@link Cesium3DTileContent} objects that represent the
  118. * content a composite's inner tiles, which can also be composites.
  119. *
  120. * @see {@link https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification/TileFormats/Composite}
  121. *
  122. * @memberof Cesium3DTileContent.prototype
  123. *
  124. * @type {Array}
  125. * @readonly
  126. */
  127. innerContents : {
  128. get : function() {
  129. DeveloperError.throwInstantiationError();
  130. }
  131. },
  132. /**
  133. * Gets the promise that will be resolved when the tile's content is ready to render.
  134. *
  135. * @memberof Cesium3DTileContent.prototype
  136. *
  137. * @type {Promise.<Cesium3DTileContent>}
  138. * @readonly
  139. */
  140. readyPromise : {
  141. get : function() {
  142. DeveloperError.throwInstantiationError();
  143. }
  144. },
  145. /**
  146. * Gets the tileset for this tile.
  147. *
  148. * @memberof Cesium3DTileContent.prototype
  149. *
  150. * @type {Cesium3DTileset}
  151. * @readonly
  152. */
  153. tileset : {
  154. get : function() {
  155. DeveloperError.throwInstantiationError();
  156. }
  157. },
  158. /**
  159. * Gets the tile containing this content.
  160. *
  161. * @memberof Cesium3DTileContent.prototype
  162. *
  163. * @type {Cesium3DTile}
  164. * @readonly
  165. */
  166. tile : {
  167. get : function() {
  168. DeveloperError.throwInstantiationError();
  169. }
  170. },
  171. /**
  172. * Gets the url of the tile's content.
  173. * @memberof Cesium3DTileContent.prototype
  174. *
  175. * @type {String}
  176. * @readonly
  177. */
  178. url : {
  179. get : function() {
  180. DeveloperError.throwInstantiationError();
  181. }
  182. },
  183. /**
  184. * Gets the batch table for this content.
  185. * <p>
  186. * This is used to implement the <code>Cesium3DTileContent</code> interface, but is
  187. * not part of the public Cesium API.
  188. * </p>
  189. *
  190. * @type {Cesium3DTileBatchTable}
  191. * @readonly
  192. *
  193. * @private
  194. */
  195. batchTable : {
  196. get : function() {
  197. DeveloperError.throwInstantiationError();
  198. }
  199. }
  200. });
  201. /**
  202. * Determines if the tile's batch table has a property. If it does, each feature in
  203. * the tile will have the property.
  204. *
  205. * @param {Number} batchId The batchId for the feature.
  206. * @param {String} name The case-sensitive name of the property.
  207. * @returns {Boolean} <code>true</code> if the property exists; otherwise, <code>false</code>.
  208. */
  209. Cesium3DTileContent.prototype.hasProperty = function(batchId, name) {
  210. DeveloperError.throwInstantiationError();
  211. };
  212. /**
  213. * Returns the {@link Cesium3DTileFeature} object for the feature with the
  214. * given <code>batchId</code>. This object is used to get and modify the
  215. * feature's properties.
  216. * <p>
  217. * Features in a tile are ordered by <code>batchId</code>, an index used to retrieve their metadata from the batch table.
  218. * </p>
  219. *
  220. * @see {@link https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification/TileFormats/BatchTable}.
  221. *
  222. * @param {Number} batchId The batchId for the feature.
  223. * @returns {Cesium3DTileFeature} The corresponding {@link Cesium3DTileFeature} object.
  224. *
  225. * @exception {DeveloperError} batchId must be between zero and {@link Cesium3DTileContent#featuresLength} - 1.
  226. */
  227. Cesium3DTileContent.prototype.getFeature = function(batchId) {
  228. DeveloperError.throwInstantiationError();
  229. };
  230. /**
  231. * Called when {@link Cesium3DTileset#debugColorizeTiles} changes.
  232. * <p>
  233. * This is used to implement the <code>Cesium3DTileContent</code> interface, but is
  234. * not part of the public Cesium API.
  235. * </p>
  236. *
  237. * @param {Boolean} enabled Whether to enable or disable debug settings.
  238. * @returns {Cesium3DTileFeature} The corresponding {@link Cesium3DTileFeature} object.
  239. * @private
  240. */
  241. Cesium3DTileContent.prototype.applyDebugSettings = function(enabled, color) {
  242. DeveloperError.throwInstantiationError();
  243. };
  244. /**
  245. * Apply a style to the content
  246. * <p>
  247. * This is used to implement the <code>Cesium3DTileContent</code> interface, but is
  248. * not part of the public Cesium API.
  249. * </p>
  250. *
  251. * @param {Cesium3DTileStyle} style The style.
  252. *
  253. * @private
  254. */
  255. Cesium3DTileContent.prototype.applyStyle = function(style) {
  256. DeveloperError.throwInstantiationError();
  257. };
  258. /**
  259. * Called by the tile during tileset traversal to get the draw commands needed to render this content.
  260. * When the tile's content is in the PROCESSING state, this creates WebGL resources to ultimately
  261. * move to the READY state.
  262. * <p>
  263. * This is used to implement the <code>Cesium3DTileContent</code> interface, but is
  264. * not part of the public Cesium API.
  265. * </p>
  266. *
  267. * @param {Cesium3DTileset} tileset The tileset containing this tile.
  268. * @param {FrameState} frameState The frame state.
  269. *
  270. * @private
  271. */
  272. Cesium3DTileContent.prototype.update = function(tileset, frameState) {
  273. DeveloperError.throwInstantiationError();
  274. };
  275. /**
  276. * Returns true if this object was destroyed; otherwise, false.
  277. * <br /><br />
  278. * If this object was destroyed, it should not be used; calling any function other than
  279. * <code>isDestroyed</code> will result in a {@link DeveloperError} exception.
  280. * <p>
  281. * This is used to implement the <code>Cesium3DTileContent</code> interface, but is
  282. * not part of the public Cesium API.
  283. * </p>
  284. *
  285. * @returns {Boolean} <code>true</code> if this object was destroyed; otherwise, <code>false</code>.
  286. *
  287. * @see Cesium3DTileContent#destroy
  288. *
  289. * @private
  290. */
  291. Cesium3DTileContent.prototype.isDestroyed = function() {
  292. DeveloperError.throwInstantiationError();
  293. };
  294. /**
  295. * Destroys the WebGL resources held by this object. Destroying an object allows for deterministic
  296. * release of WebGL resources, instead of relying on the garbage collector to destroy this object.
  297. * <br /><br />
  298. * Once an object is destroyed, it should not be used; calling any function other than
  299. * <code>isDestroyed</code> will result in a {@link DeveloperError} exception. Therefore,
  300. * assign the return value (<code>undefined</code>) to the object as done in the example.
  301. * <p>
  302. * This is used to implement the <code>Cesium3DTileContent</code> interface, but is
  303. * not part of the public Cesium API.
  304. * </p>
  305. *
  306. * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
  307. *
  308. * @example
  309. * content = content && content.destroy();
  310. *
  311. * @see Cesium3DTileContent#isDestroyed
  312. *
  313. * @private
  314. */
  315. Cesium3DTileContent.prototype.destroy = function() {
  316. DeveloperError.throwInstantiationError();
  317. };
  318. export default Cesium3DTileContent;