智慧水务管理系统 - 精河县供水工程综合管理平台

Cesium3DTileContent.js 10KB

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