Cesium3DTileContent.js 11 KB

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