Cesium3DTilePointFeature.js 22 KB

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