Cesium3DTilePointFeature.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864
  1. import Cartographic from "../Core/Cartographic.js";
  2. import Color from "../Core/Color.js";
  3. import defaultValue from "../Core/defaultValue.js";
  4. import defined from "../Core/defined.js";
  5. import Cesium3DTileFeature from "./Cesium3DTileFeature.js";
  6. import createBillboardPointCallback from "./createBillboardPointCallback.js";
  7. /**
  8. * A point feature of a {@link Cesium3DTileset}.
  9. * <p>
  10. * Provides access to a feature's properties stored in the tile's batch table, as well
  11. * as the ability to show/hide a feature and change its point properties
  12. * </p>
  13. * <p>
  14. * Modifications to a <code>Cesium3DTilePointFeature</code> object have the lifetime of the tile's
  15. * content. If the tile's content is unloaded, e.g., due to it going out of view and needing
  16. * to free space in the cache for visible tiles, listen to the {@link Cesium3DTileset#tileUnload} event to save any
  17. * modifications. Also listen to the {@link Cesium3DTileset#tileVisible} event to reapply any modifications.
  18. * </p>
  19. * <p>
  20. * Do not construct this directly. Access it through {@link Cesium3DTileContent#getFeature}
  21. * or picking using {@link Scene#pick} and {@link Scene#pickPosition}.
  22. * </p>
  23. *
  24. * @alias Cesium3DTilePointFeature
  25. * @constructor
  26. *
  27. * @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.
  28. *
  29. * @example
  30. * // On mouse over, display all the properties for a feature in the console log.
  31. * handler.setInputAction(function(movement) {
  32. * const feature = scene.pick(movement.endPosition);
  33. * if (feature instanceof Cesium.Cesium3DTilePointFeature) {
  34. * const propertyIds = feature.getPropertyIds();
  35. * const length = propertyIds.length;
  36. * for (let i = 0; i < length; ++i) {
  37. * const propertyId = propertyIds[i];
  38. * console.log(`{propertyId}: ${feature.getProperty(propertyId)}`);
  39. * }
  40. * }
  41. * }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
  42. */
  43. function Cesium3DTilePointFeature(
  44. content,
  45. batchId,
  46. billboard,
  47. label,
  48. polyline
  49. ) {
  50. this._content = content;
  51. this._billboard = billboard;
  52. this._label = label;
  53. this._polyline = polyline;
  54. this._batchId = batchId;
  55. this._billboardImage = undefined;
  56. this._billboardColor = undefined;
  57. this._billboardOutlineColor = undefined;
  58. this._billboardOutlineWidth = undefined;
  59. this._billboardSize = undefined;
  60. this._pointSize = undefined;
  61. this._color = undefined;
  62. this._pointSize = undefined;
  63. this._pointOutlineColor = undefined;
  64. this._pointOutlineWidth = undefined;
  65. this._heightOffset = undefined;
  66. this._pickIds = new Array(3);
  67. setBillboardImage(this);
  68. }
  69. const scratchCartographic = new Cartographic();
  70. Object.defineProperties(Cesium3DTilePointFeature.prototype, {
  71. /**
  72. * Gets or sets if the feature will be shown. This is set for all features
  73. * when a style's show is evaluated.
  74. *
  75. * @memberof Cesium3DTilePointFeature.prototype
  76. *
  77. * @type {boolean}
  78. *
  79. * @default true
  80. */
  81. show: {
  82. get: function () {
  83. return this._label.show;
  84. },
  85. set: function (value) {
  86. this._label.show = value;
  87. this._billboard.show = value;
  88. this._polyline.show = value;
  89. },
  90. },
  91. /**
  92. * Gets or sets the color of the point of this feature.
  93. * <p>
  94. * Only applied when <code>image</code> is <code>undefined</code>.
  95. * </p>
  96. *
  97. * @memberof Cesium3DTilePointFeature.prototype
  98. *
  99. * @type {Color}
  100. */
  101. color: {
  102. get: function () {
  103. return this._color;
  104. },
  105. set: function (value) {
  106. this._color = Color.clone(value, this._color);
  107. setBillboardImage(this);
  108. },
  109. },
  110. /**
  111. * Gets or sets the point size of this feature.
  112. * <p>
  113. * Only applied when <code>image</code> is <code>undefined</code>.
  114. * </p>
  115. *
  116. * @memberof Cesium3DTilePointFeature.prototype
  117. *
  118. * @type {number}
  119. */
  120. pointSize: {
  121. get: function () {
  122. return this._pointSize;
  123. },
  124. set: function (value) {
  125. this._pointSize = value;
  126. setBillboardImage(this);
  127. },
  128. },
  129. /**
  130. * Gets or sets the point outline color of this feature.
  131. * <p>
  132. * Only applied when <code>image</code> is <code>undefined</code>.
  133. * </p>
  134. *
  135. * @memberof Cesium3DTilePointFeature.prototype
  136. *
  137. * @type {Color}
  138. */
  139. pointOutlineColor: {
  140. get: function () {
  141. return this._pointOutlineColor;
  142. },
  143. set: function (value) {
  144. this._pointOutlineColor = Color.clone(value, this._pointOutlineColor);
  145. setBillboardImage(this);
  146. },
  147. },
  148. /**
  149. * Gets or sets the point outline width in pixels of this feature.
  150. * <p>
  151. * Only applied when <code>image</code> is <code>undefined</code>.
  152. * </p>
  153. *
  154. * @memberof Cesium3DTilePointFeature.prototype
  155. *
  156. * @type {number}
  157. */
  158. pointOutlineWidth: {
  159. get: function () {
  160. return this._pointOutlineWidth;
  161. },
  162. set: function (value) {
  163. this._pointOutlineWidth = value;
  164. setBillboardImage(this);
  165. },
  166. },
  167. /**
  168. * Gets or sets the label color of this feature.
  169. * <p>
  170. * The color will be applied to the label if <code>labelText</code> is defined.
  171. * </p>
  172. *
  173. * @memberof Cesium3DTilePointFeature.prototype
  174. *
  175. * @type {Color}
  176. */
  177. labelColor: {
  178. get: function () {
  179. return this._label.fillColor;
  180. },
  181. set: function (value) {
  182. this._label.fillColor = value;
  183. this._polyline.show = this._label.show && value.alpha > 0.0;
  184. },
  185. },
  186. /**
  187. * Gets or sets the label outline color of this feature.
  188. * <p>
  189. * The outline color will be applied to the label if <code>labelText</code> is defined.
  190. * </p>
  191. *
  192. * @memberof Cesium3DTilePointFeature.prototype
  193. *
  194. * @type {Color}
  195. */
  196. labelOutlineColor: {
  197. get: function () {
  198. return this._label.outlineColor;
  199. },
  200. set: function (value) {
  201. this._label.outlineColor = value;
  202. },
  203. },
  204. /**
  205. * Gets or sets the outline width in pixels of this feature.
  206. * <p>
  207. * The outline width will be applied to the point if <code>labelText</code> is defined.
  208. * </p>
  209. *
  210. * @memberof Cesium3DTilePointFeature.prototype
  211. *
  212. * @type {number}
  213. */
  214. labelOutlineWidth: {
  215. get: function () {
  216. return this._label.outlineWidth;
  217. },
  218. set: function (value) {
  219. this._label.outlineWidth = value;
  220. },
  221. },
  222. /**
  223. * Gets or sets the font of this feature.
  224. * <p>
  225. * Only applied when the <code>labelText</code> is defined.
  226. * </p>
  227. *
  228. * @memberof Cesium3DTilePointFeature.prototype
  229. *
  230. * @type {string}
  231. */
  232. font: {
  233. get: function () {
  234. return this._label.font;
  235. },
  236. set: function (value) {
  237. this._label.font = value;
  238. },
  239. },
  240. /**
  241. * Gets or sets the fill and outline style of this feature.
  242. * <p>
  243. * Only applied when <code>labelText</code> is defined.
  244. * </p>
  245. *
  246. * @memberof Cesium3DTilePointFeature.prototype
  247. *
  248. * @type {LabelStyle}
  249. */
  250. labelStyle: {
  251. get: function () {
  252. return this._label.style;
  253. },
  254. set: function (value) {
  255. this._label.style = value;
  256. },
  257. },
  258. /**
  259. * Gets or sets the text for this feature.
  260. *
  261. * @memberof Cesium3DTilePointFeature.prototype
  262. *
  263. * @type {string}
  264. */
  265. labelText: {
  266. get: function () {
  267. return this._label.text;
  268. },
  269. set: function (value) {
  270. if (!defined(value)) {
  271. value = "";
  272. }
  273. this._label.text = value;
  274. },
  275. },
  276. /**
  277. * Gets or sets the background color of the text for this feature.
  278. * <p>
  279. * Only applied when <code>labelText</code> is defined.
  280. * </p>
  281. *
  282. * @memberof Cesium3DTilePointFeature.prototype
  283. *
  284. * @type {Color}
  285. */
  286. backgroundColor: {
  287. get: function () {
  288. return this._label.backgroundColor;
  289. },
  290. set: function (value) {
  291. this._label.backgroundColor = value;
  292. },
  293. },
  294. /**
  295. * Gets or sets the background padding of the text for this feature.
  296. * <p>
  297. * Only applied when <code>labelText</code> is defined.
  298. * </p>
  299. *
  300. * @memberof Cesium3DTilePointFeature.prototype
  301. *
  302. * @type {Cartesian2}
  303. */
  304. backgroundPadding: {
  305. get: function () {
  306. return this._label.backgroundPadding;
  307. },
  308. set: function (value) {
  309. this._label.backgroundPadding = value;
  310. },
  311. },
  312. /**
  313. * Gets or sets whether to display the background of the text for this feature.
  314. * <p>
  315. * Only applied when <code>labelText</code> is defined.
  316. * </p>
  317. *
  318. * @memberof Cesium3DTilePointFeature.prototype
  319. *
  320. * @type {boolean}
  321. */
  322. backgroundEnabled: {
  323. get: function () {
  324. return this._label.showBackground;
  325. },
  326. set: function (value) {
  327. this._label.showBackground = value;
  328. },
  329. },
  330. /**
  331. * Gets or sets the near and far scaling properties for this feature.
  332. *
  333. * @memberof Cesium3DTilePointFeature.prototype
  334. *
  335. * @type {NearFarScalar}
  336. */
  337. scaleByDistance: {
  338. get: function () {
  339. return this._label.scaleByDistance;
  340. },
  341. set: function (value) {
  342. this._label.scaleByDistance = value;
  343. this._billboard.scaleByDistance = value;
  344. },
  345. },
  346. /**
  347. * Gets or sets the near and far translucency properties for this feature.
  348. *
  349. * @memberof Cesium3DTilePointFeature.prototype
  350. *
  351. * @type {NearFarScalar}
  352. */
  353. translucencyByDistance: {
  354. get: function () {
  355. return this._label.translucencyByDistance;
  356. },
  357. set: function (value) {
  358. this._label.translucencyByDistance = value;
  359. this._billboard.translucencyByDistance = value;
  360. },
  361. },
  362. /**
  363. * Gets or sets the condition specifying at what distance from the camera that this feature will be displayed.
  364. *
  365. * @memberof Cesium3DTilePointFeature.prototype
  366. *
  367. * @type {DistanceDisplayCondition}
  368. */
  369. distanceDisplayCondition: {
  370. get: function () {
  371. return this._label.distanceDisplayCondition;
  372. },
  373. set: function (value) {
  374. this._label.distanceDisplayCondition = value;
  375. this._polyline.distanceDisplayCondition = value;
  376. this._billboard.distanceDisplayCondition = value;
  377. },
  378. },
  379. /**
  380. * Gets or sets the height offset in meters of this feature.
  381. *
  382. * @memberof Cesium3DTilePointFeature.prototype
  383. *
  384. * @type {number}
  385. */
  386. heightOffset: {
  387. get: function () {
  388. return this._heightOffset;
  389. },
  390. set: function (value) {
  391. const offset = defaultValue(this._heightOffset, 0.0);
  392. const ellipsoid = this._content.tileset.ellipsoid;
  393. const cart = ellipsoid.cartesianToCartographic(
  394. this._billboard.position,
  395. scratchCartographic
  396. );
  397. cart.height = cart.height - offset + value;
  398. const newPosition = ellipsoid.cartographicToCartesian(cart);
  399. this._billboard.position = newPosition;
  400. this._label.position = this._billboard.position;
  401. this._polyline.positions = [this._polyline.positions[0], newPosition];
  402. this._heightOffset = value;
  403. },
  404. },
  405. /**
  406. * Gets or sets whether the anchor line is displayed.
  407. * <p>
  408. * Only applied when <code>heightOffset</code> is defined.
  409. * </p>
  410. *
  411. * @memberof Cesium3DTilePointFeature.prototype
  412. *
  413. * @type {boolean}
  414. */
  415. anchorLineEnabled: {
  416. get: function () {
  417. return this._polyline.show;
  418. },
  419. set: function (value) {
  420. this._polyline.show = value;
  421. },
  422. },
  423. /**
  424. * Gets or sets the color for the anchor line.
  425. * <p>
  426. * Only applied when <code>heightOffset</code> is defined.
  427. * </p>
  428. *
  429. * @memberof Cesium3DTilePointFeature.prototype
  430. *
  431. * @type {Color}
  432. */
  433. anchorLineColor: {
  434. get: function () {
  435. return this._polyline.material.uniforms.color;
  436. },
  437. set: function (value) {
  438. this._polyline.material.uniforms.color = Color.clone(
  439. value,
  440. this._polyline.material.uniforms.color
  441. );
  442. },
  443. },
  444. /**
  445. * Gets or sets the image of this feature.
  446. *
  447. * @memberof Cesium3DTilePointFeature.prototype
  448. *
  449. * @type {string}
  450. */
  451. image: {
  452. get: function () {
  453. return this._billboardImage;
  454. },
  455. set: function (value) {
  456. const imageChanged = this._billboardImage !== value;
  457. this._billboardImage = value;
  458. if (imageChanged) {
  459. setBillboardImage(this);
  460. }
  461. },
  462. },
  463. /**
  464. * Gets or sets the distance where depth testing will be disabled.
  465. *
  466. * @memberof Cesium3DTilePointFeature.prototype
  467. *
  468. * @type {number}
  469. */
  470. disableDepthTestDistance: {
  471. get: function () {
  472. return this._label.disableDepthTestDistance;
  473. },
  474. set: function (value) {
  475. this._label.disableDepthTestDistance = value;
  476. this._billboard.disableDepthTestDistance = value;
  477. },
  478. },
  479. /**
  480. * Gets or sets the horizontal origin of this point, which determines if the point is
  481. * to the left, center, or right of its anchor position.
  482. *
  483. * @memberof Cesium3DTilePointFeature.prototype
  484. *
  485. * @type {HorizontalOrigin}
  486. */
  487. horizontalOrigin: {
  488. get: function () {
  489. return this._billboard.horizontalOrigin;
  490. },
  491. set: function (value) {
  492. this._billboard.horizontalOrigin = value;
  493. },
  494. },
  495. /**
  496. * Gets or sets the vertical origin of this point, which determines if the point is
  497. * to the bottom, center, or top of its anchor position.
  498. *
  499. * @memberof Cesium3DTilePointFeature.prototype
  500. *
  501. * @type {VerticalOrigin}
  502. */
  503. verticalOrigin: {
  504. get: function () {
  505. return this._billboard.verticalOrigin;
  506. },
  507. set: function (value) {
  508. this._billboard.verticalOrigin = value;
  509. },
  510. },
  511. /**
  512. * Gets or sets the horizontal origin of this point's text, which determines if the point's text is
  513. * to the left, center, or right of its anchor position.
  514. *
  515. * @memberof Cesium3DTilePointFeature.prototype
  516. *
  517. * @type {HorizontalOrigin}
  518. */
  519. labelHorizontalOrigin: {
  520. get: function () {
  521. return this._label.horizontalOrigin;
  522. },
  523. set: function (value) {
  524. this._label.horizontalOrigin = value;
  525. },
  526. },
  527. /**
  528. * Get or sets the vertical origin of this point's text, which determines if the point's text is
  529. * to the bottom, center, top, or baseline of it's anchor point.
  530. *
  531. * @memberof Cesium3DTilePointFeature.prototype
  532. *
  533. * @type {VerticalOrigin}
  534. */
  535. labelVerticalOrigin: {
  536. get: function () {
  537. return this._label.verticalOrigin;
  538. },
  539. set: function (value) {
  540. this._label.verticalOrigin = value;
  541. },
  542. },
  543. /**
  544. * Gets the content of the tile containing the feature.
  545. *
  546. * @memberof Cesium3DTilePointFeature.prototype
  547. *
  548. * @type {Cesium3DTileContent}
  549. *
  550. * @readonly
  551. * @private
  552. */
  553. content: {
  554. get: function () {
  555. return this._content;
  556. },
  557. },
  558. /**
  559. * Gets the tileset containing the feature.
  560. *
  561. * @memberof Cesium3DTilePointFeature.prototype
  562. *
  563. * @type {Cesium3DTileset}
  564. *
  565. * @readonly
  566. */
  567. tileset: {
  568. get: function () {
  569. return this._content.tileset;
  570. },
  571. },
  572. /**
  573. * All objects returned by {@link Scene#pick} have a <code>primitive</code> property. This returns
  574. * the tileset containing the feature.
  575. *
  576. * @memberof Cesium3DTilePointFeature.prototype
  577. *
  578. * @type {Cesium3DTileset}
  579. *
  580. * @readonly
  581. */
  582. primitive: {
  583. get: function () {
  584. return this._content.tileset;
  585. },
  586. },
  587. /**
  588. * @private
  589. */
  590. pickIds: {
  591. get: function () {
  592. const ids = this._pickIds;
  593. ids[0] = this._billboard.pickId;
  594. ids[1] = this._label.pickId;
  595. ids[2] = this._polyline.pickId;
  596. return ids;
  597. },
  598. },
  599. });
  600. Cesium3DTilePointFeature.defaultColor = Color.WHITE;
  601. Cesium3DTilePointFeature.defaultPointOutlineColor = Color.BLACK;
  602. Cesium3DTilePointFeature.defaultPointOutlineWidth = 0.0;
  603. Cesium3DTilePointFeature.defaultPointSize = 8.0;
  604. function setBillboardImage(feature) {
  605. const b = feature._billboard;
  606. if (defined(feature._billboardImage) && feature._billboardImage !== b.image) {
  607. b.image = feature._billboardImage;
  608. return;
  609. }
  610. if (defined(feature._billboardImage)) {
  611. return;
  612. }
  613. const newColor = defaultValue(
  614. feature._color,
  615. Cesium3DTilePointFeature.defaultColor
  616. );
  617. const newOutlineColor = defaultValue(
  618. feature._pointOutlineColor,
  619. Cesium3DTilePointFeature.defaultPointOutlineColor
  620. );
  621. const newOutlineWidth = defaultValue(
  622. feature._pointOutlineWidth,
  623. Cesium3DTilePointFeature.defaultPointOutlineWidth
  624. );
  625. const newPointSize = defaultValue(
  626. feature._pointSize,
  627. Cesium3DTilePointFeature.defaultPointSize
  628. );
  629. const currentColor = feature._billboardColor;
  630. const currentOutlineColor = feature._billboardOutlineColor;
  631. const currentOutlineWidth = feature._billboardOutlineWidth;
  632. const currentPointSize = feature._billboardSize;
  633. if (
  634. Color.equals(newColor, currentColor) &&
  635. Color.equals(newOutlineColor, currentOutlineColor) &&
  636. newOutlineWidth === currentOutlineWidth &&
  637. newPointSize === currentPointSize
  638. ) {
  639. return;
  640. }
  641. feature._billboardColor = Color.clone(newColor, feature._billboardColor);
  642. feature._billboardOutlineColor = Color.clone(
  643. newOutlineColor,
  644. feature._billboardOutlineColor
  645. );
  646. feature._billboardOutlineWidth = newOutlineWidth;
  647. feature._billboardSize = newPointSize;
  648. const centerAlpha = newColor.alpha;
  649. const cssColor = newColor.toCssColorString();
  650. const cssOutlineColor = newOutlineColor.toCssColorString();
  651. const textureId = JSON.stringify([
  652. cssColor,
  653. newPointSize,
  654. cssOutlineColor,
  655. newOutlineWidth,
  656. ]);
  657. b.setImage(
  658. textureId,
  659. createBillboardPointCallback(
  660. centerAlpha,
  661. cssColor,
  662. cssOutlineColor,
  663. newOutlineWidth,
  664. newPointSize
  665. )
  666. );
  667. }
  668. /**
  669. * Returns whether the feature contains this property. This includes properties from this feature's
  670. * class and inherited classes when using a batch table hierarchy.
  671. *
  672. * @see {@link https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_batch_table_hierarchy}
  673. *
  674. * @param {string} name The case-sensitive name of the property.
  675. * @returns {boolean} Whether the feature contains this property.
  676. */
  677. Cesium3DTilePointFeature.prototype.hasProperty = function (name) {
  678. return this._content.batchTable.hasProperty(this._batchId, name);
  679. };
  680. /**
  681. * Returns an array of property IDs for the feature. This includes properties from this feature's
  682. * class and inherited classes when using a batch table hierarchy.
  683. *
  684. * @see {@link https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_batch_table_hierarchy}
  685. *
  686. * @param {string[]} [results] An array into which to store the results.
  687. * @returns {string[]} The IDs of the feature's properties.
  688. */
  689. Cesium3DTilePointFeature.prototype.getPropertyIds = function (results) {
  690. return this._content.batchTable.getPropertyIds(this._batchId, results);
  691. };
  692. /**
  693. * Returns a copy of the value of the feature's property with the given name. This includes properties from this feature's
  694. * class and inherited classes when using a batch table hierarchy.
  695. *
  696. * @see {@link https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_batch_table_hierarchy}
  697. *
  698. * @param {string} name The case-sensitive name of the property.
  699. * @returns {*} The value of the property or <code>undefined</code> if the feature does not have this property.
  700. *
  701. * @example
  702. * // Display all the properties for a feature in the console log.
  703. * const propertyIds = feature.getPropertyIds();
  704. * const length = propertyIds.length;
  705. * for (let i = 0; i < length; ++i) {
  706. * const propertyId = propertyIds[i];
  707. * console.log(`{propertyId} : ${feature.getProperty(propertyId)}`);
  708. * }
  709. */
  710. Cesium3DTilePointFeature.prototype.getProperty = function (name) {
  711. return this._content.batchTable.getProperty(this._batchId, name);
  712. };
  713. /**
  714. * Returns a copy of the value of the feature's property with the given name.
  715. * If the feature is contained within a tileset that has metadata (3D Tiles 1.1)
  716. * or uses the <code>3DTILES_metadata</code> extension, tileset, group and tile metadata is
  717. * inherited.
  718. * <p>
  719. * To resolve name conflicts, this method resolves names from most specific to
  720. * least specific by metadata granularity in the order: feature, tile, group,
  721. * tileset. Within each granularity, semantics are resolved first, then other
  722. * properties.
  723. * </p>
  724. * @param {string} name The case-sensitive name of the property.
  725. * @returns {*} The value of the property or <code>undefined</code> if the feature does not have this property.
  726. * @private
  727. * @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.
  728. */
  729. Cesium3DTilePointFeature.prototype.getPropertyInherited = function (name) {
  730. return Cesium3DTileFeature.getPropertyInherited(
  731. this._content,
  732. this._batchId,
  733. name
  734. );
  735. };
  736. /**
  737. * Sets the value of the feature's property with the given name.
  738. * <p>
  739. * If a property with the given name doesn't exist, it is created.
  740. * </p>
  741. *
  742. * @param {string} name The case-sensitive name of the property.
  743. * @param {*} value The value of the property that will be copied.
  744. *
  745. * @exception {DeveloperError} Inherited batch table hierarchy property is read only.
  746. *
  747. * @example
  748. * const height = feature.getProperty('Height'); // e.g., the height of a building
  749. *
  750. * @example
  751. * const name = 'clicked';
  752. * if (feature.getProperty(name)) {
  753. * console.log('already clicked');
  754. * } else {
  755. * feature.setProperty(name, true);
  756. * console.log('first click');
  757. * }
  758. */
  759. Cesium3DTilePointFeature.prototype.setProperty = function (name, value) {
  760. this._content.batchTable.setProperty(this._batchId, name, value);
  761. // PERFORMANCE_IDEA: Probably overkill, but maybe only mark the tile dirty if the
  762. // property is in one of the style's expressions or - if it can be done quickly -
  763. // if the new property value changed the result of an expression.
  764. this._content.featurePropertiesDirty = true;
  765. };
  766. /**
  767. * Returns whether the feature's class name equals <code>className</code>. Unlike {@link Cesium3DTilePointFeature#isClass}
  768. * this function only checks the feature's exact class and not inherited classes.
  769. * <p>
  770. * This function returns <code>false</code> if no batch table hierarchy is present.
  771. * </p>
  772. *
  773. * @param {string} className The name to check against.
  774. * @returns {boolean} Whether the feature's class name equals <code>className</code>
  775. *
  776. * @private
  777. */
  778. Cesium3DTilePointFeature.prototype.isExactClass = function (className) {
  779. return this._content.batchTable.isExactClass(this._batchId, className);
  780. };
  781. /**
  782. * Returns whether the feature's class or any inherited classes are named <code>className</code>.
  783. * <p>
  784. * This function returns <code>false</code> if no batch table hierarchy is present.
  785. * </p>
  786. *
  787. * @param {string} className The name to check against.
  788. * @returns {boolean} Whether the feature's class or inherited classes are named <code>className</code>
  789. *
  790. * @private
  791. */
  792. Cesium3DTilePointFeature.prototype.isClass = function (className) {
  793. return this._content.batchTable.isClass(this._batchId, className);
  794. };
  795. /**
  796. * Returns the feature's class name.
  797. * <p>
  798. * This function returns <code>undefined</code> if no batch table hierarchy is present.
  799. * </p>
  800. *
  801. * @returns {string} The feature's class name.
  802. *
  803. * @private
  804. */
  805. Cesium3DTilePointFeature.prototype.getExactClassName = function () {
  806. return this._content.batchTable.getExactClassName(this._batchId);
  807. };
  808. export default Cesium3DTilePointFeature;