Cesium3DTileContent.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  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() {
  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/main/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 for contents that contain other contents, such as composite tiles. The inner contents may in turn have inner contents, such as a composite tile that contains a composite tile.
  123. *
  124. * @see {@link https://github.com/CesiumGS/3d-tiles/tree/main/specification/TileFormats/Composite|Composite specification}
  125. *
  126. * @memberof Cesium3DTileContent.prototype
  127. *
  128. * @type {Array}
  129. * @readonly
  130. */
  131. innerContents: {
  132. // eslint-disable-next-line getter-return
  133. get: function () {
  134. DeveloperError.throwInstantiationError();
  135. },
  136. },
  137. /**
  138. * Gets the promise that will be resolved when the tile's content is ready to render.
  139. *
  140. * @memberof Cesium3DTileContent.prototype
  141. *
  142. * @type {Promise.<Cesium3DTileContent>}
  143. * @readonly
  144. */
  145. readyPromise: {
  146. // eslint-disable-next-line getter-return
  147. get: function () {
  148. DeveloperError.throwInstantiationError();
  149. },
  150. },
  151. /**
  152. * Gets the tileset for this tile.
  153. *
  154. * @memberof Cesium3DTileContent.prototype
  155. *
  156. * @type {Cesium3DTileset}
  157. * @readonly
  158. */
  159. tileset: {
  160. // eslint-disable-next-line getter-return
  161. get: function () {
  162. DeveloperError.throwInstantiationError();
  163. },
  164. },
  165. /**
  166. * Gets the tile containing this content.
  167. *
  168. * @memberof Cesium3DTileContent.prototype
  169. *
  170. * @type {Cesium3DTile}
  171. * @readonly
  172. */
  173. tile: {
  174. // eslint-disable-next-line getter-return
  175. get: function () {
  176. DeveloperError.throwInstantiationError();
  177. },
  178. },
  179. /**
  180. * Gets the url of the tile's content.
  181. * @memberof Cesium3DTileContent.prototype
  182. *
  183. * @type {String}
  184. * @readonly
  185. */
  186. url: {
  187. // eslint-disable-next-line getter-return
  188. get: function () {
  189. DeveloperError.throwInstantiationError();
  190. },
  191. },
  192. /**
  193. * Gets the batch table for this content.
  194. * <p>
  195. * This is used to implement the <code>Cesium3DTileContent</code> interface, but is
  196. * not part of the public Cesium API.
  197. * </p>
  198. *
  199. * @type {Cesium3DTileBatchTable}
  200. * @readonly
  201. *
  202. * @private
  203. */
  204. batchTable: {
  205. // eslint-disable-next-line getter-return
  206. get: function () {
  207. DeveloperError.throwInstantiationError();
  208. },
  209. },
  210. /**
  211. * Gets the metadata for this content, whether it is available explicitly or via
  212. * implicit tiling. If there is no metadata, this property should be undefined.
  213. * <p>
  214. * This is used to implement the <code>Cesium3DTileContent</code> interface, but is
  215. * not part of the public Cesium API.
  216. * </p>
  217. *
  218. * @type {ImplicitMetadataView|undefined}
  219. *
  220. * @private
  221. * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
  222. */
  223. metadata: {
  224. // eslint-disable-next-line getter-return
  225. get: function () {
  226. DeveloperError.throwInstantiationError();
  227. },
  228. set: function (value) {
  229. DeveloperError.throwInstantiationError();
  230. },
  231. },
  232. /**
  233. * Gets the group for this content if the content has metadata (3D Tiles 1.1) or
  234. * if it uses the <code>3DTILES_metadata</code> extension. If neither are present,
  235. * this property should be undefined.
  236. * <p>
  237. * This is used to implement the <code>Cesium3DTileContent</code> interface, but is
  238. * not part of the public Cesium API.
  239. * </p>
  240. *
  241. * @type {Cesium3DTileContentGroup|undefined}
  242. *
  243. * @private
  244. * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
  245. */
  246. group: {
  247. // eslint-disable-next-line getter-return
  248. get: function () {
  249. DeveloperError.throwInstantiationError();
  250. },
  251. set: function (value) {
  252. DeveloperError.throwInstantiationError();
  253. },
  254. },
  255. });
  256. /**
  257. * Returns whether the feature has this property.
  258. *
  259. * @param {Number} batchId The batchId for the feature.
  260. * @param {String} name The case-sensitive name of the property.
  261. * @returns {Boolean} <code>true</code> if the feature has this property; otherwise, <code>false</code>.
  262. */
  263. Cesium3DTileContent.prototype.hasProperty = function (batchId, name) {
  264. DeveloperError.throwInstantiationError();
  265. };
  266. /**
  267. * Returns the {@link Cesium3DTileFeature} object for the feature with the
  268. * given <code>batchId</code>. This object is used to get and modify the
  269. * feature's properties.
  270. * <p>
  271. * Features in a tile are ordered by <code>batchId</code>, an index used to retrieve their metadata from the batch table.
  272. * </p>
  273. *
  274. * @see {@link https://github.com/CesiumGS/3d-tiles/tree/main/specification/TileFormats/BatchTable}.
  275. *
  276. * @param {Number} batchId The batchId for the feature.
  277. * @returns {Cesium3DTileFeature} The corresponding {@link Cesium3DTileFeature} object.
  278. *
  279. * @exception {DeveloperError} batchId must be between zero and {@link Cesium3DTileContent#featuresLength} - 1.
  280. */
  281. Cesium3DTileContent.prototype.getFeature = function (batchId) {
  282. DeveloperError.throwInstantiationError();
  283. };
  284. /**
  285. * Called when {@link Cesium3DTileset#debugColorizeTiles} changes.
  286. * <p>
  287. * This is used to implement the <code>Cesium3DTileContent</code> interface, but is
  288. * not part of the public Cesium API.
  289. * </p>
  290. *
  291. * @param {Boolean} enabled Whether to enable or disable debug settings.
  292. * @returns {Cesium3DTileFeature} The corresponding {@link Cesium3DTileFeature} object.
  293. * @private
  294. */
  295. Cesium3DTileContent.prototype.applyDebugSettings = function (enabled, color) {
  296. DeveloperError.throwInstantiationError();
  297. };
  298. /**
  299. * Apply a style to the content
  300. * <p>
  301. * This is used to implement the <code>Cesium3DTileContent</code> interface, but is
  302. * not part of the public Cesium API.
  303. * </p>
  304. *
  305. * @param {Cesium3DTileStyle} style The style.
  306. *
  307. * @private
  308. */
  309. Cesium3DTileContent.prototype.applyStyle = function (style) {
  310. DeveloperError.throwInstantiationError();
  311. };
  312. /**
  313. * Called by the tile during tileset traversal to get the draw commands needed to render this content.
  314. * When the tile's content is in the PROCESSING state, this creates WebGL resources to ultimately
  315. * move to the READY state.
  316. * <p>
  317. * This is used to implement the <code>Cesium3DTileContent</code> interface, but is
  318. * not part of the public Cesium API.
  319. * </p>
  320. *
  321. * @param {Cesium3DTileset} tileset The tileset containing this tile.
  322. * @param {FrameState} frameState The frame state.
  323. *
  324. * @private
  325. */
  326. Cesium3DTileContent.prototype.update = function (tileset, frameState) {
  327. DeveloperError.throwInstantiationError();
  328. };
  329. /**
  330. * Returns true if this object was destroyed; otherwise, false.
  331. * <br /><br />
  332. * If this object was destroyed, it should not be used; calling any function other than
  333. * <code>isDestroyed</code> will result in a {@link DeveloperError} exception.
  334. * <p>
  335. * This is used to implement the <code>Cesium3DTileContent</code> interface, but is
  336. * not part of the public Cesium API.
  337. * </p>
  338. *
  339. * @returns {Boolean} <code>true</code> if this object was destroyed; otherwise, <code>false</code>.
  340. *
  341. * @see Cesium3DTileContent#destroy
  342. *
  343. * @private
  344. */
  345. Cesium3DTileContent.prototype.isDestroyed = function () {
  346. DeveloperError.throwInstantiationError();
  347. };
  348. /**
  349. * Destroys the WebGL resources held by this object. Destroying an object allows for deterministic
  350. * release of WebGL resources, instead of relying on the garbage collector to destroy this object.
  351. * <br /><br />
  352. * Once an object is destroyed, it should not be used; calling any function other than
  353. * <code>isDestroyed</code> will result in a {@link DeveloperError} exception. Therefore,
  354. * assign the return value (<code>undefined</code>) to the object as done in the example.
  355. * <p>
  356. * This is used to implement the <code>Cesium3DTileContent</code> interface, but is
  357. * not part of the public Cesium API.
  358. * </p>
  359. *
  360. * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
  361. *
  362. * @example
  363. * content = content && content.destroy();
  364. *
  365. * @see Cesium3DTileContent#isDestroyed
  366. *
  367. * @private
  368. */
  369. Cesium3DTileContent.prototype.destroy = function () {
  370. DeveloperError.throwInstantiationError();
  371. };
  372. export default Cesium3DTileContent;