Cesium3DTileContent.js 9.5 KB

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