PointPrimitive.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. import BoundingRectangle from "../Core/BoundingRectangle.js";
  2. import Cartesian2 from "../Core/Cartesian2.js";
  3. import Cartesian3 from "../Core/Cartesian3.js";
  4. import Cartesian4 from "../Core/Cartesian4.js";
  5. import Color from "../Core/Color.js";
  6. import defaultValue from "../Core/defaultValue.js";
  7. import defined from "../Core/defined.js";
  8. import DeveloperError from "../Core/DeveloperError.js";
  9. import DistanceDisplayCondition from "../Core/DistanceDisplayCondition.js";
  10. import Matrix4 from "../Core/Matrix4.js";
  11. import NearFarScalar from "../Core/NearFarScalar.js";
  12. import SceneMode from "./SceneMode.js";
  13. import SceneTransforms from "./SceneTransforms.js";
  14. /**
  15. * <div class="notice">
  16. * A point is created and its initial properties are set by calling {@link PointPrimitiveCollection#add}. Do not call the constructor directly.
  17. * </div>
  18. * A graphical point positioned in the 3D scene, that is created
  19. * and rendered using a {@link PointPrimitiveCollection}.
  20. *
  21. * @alias PointPrimitive
  22. *
  23. * @performance Reading a property, e.g., {@link PointPrimitive#show}, is constant time.
  24. * Assigning to a property is constant time but results in
  25. * CPU to GPU traffic when {@link PointPrimitiveCollection#update} is called. The per-pointPrimitive traffic is
  26. * the same regardless of how many properties were updated. If most pointPrimitives in a collection need to be
  27. * updated, it may be more efficient to clear the collection with {@link PointPrimitiveCollection#removeAll}
  28. * and add new pointPrimitives instead of modifying each one.
  29. *
  30. * @exception {DeveloperError} scaleByDistance.far must be greater than scaleByDistance.near
  31. * @exception {DeveloperError} translucencyByDistance.far must be greater than translucencyByDistance.near
  32. * @exception {DeveloperError} distanceDisplayCondition.far must be greater than distanceDisplayCondition.near
  33. *
  34. * @see PointPrimitiveCollection
  35. * @see PointPrimitiveCollection#add
  36. *
  37. * @internalConstructor
  38. * @class
  39. *
  40. * @demo {@link https://sandcastle.cesium.com/index.html?src=Points.html|Cesium Sandcastle Points Demo}
  41. */
  42. function PointPrimitive(options, pointPrimitiveCollection) {
  43. options = defaultValue(options, defaultValue.EMPTY_OBJECT);
  44. //>>includeStart('debug', pragmas.debug);
  45. if (
  46. defined(options.disableDepthTestDistance) &&
  47. options.disableDepthTestDistance < 0.0
  48. ) {
  49. throw new DeveloperError(
  50. "disableDepthTestDistance must be greater than or equal to 0.0."
  51. );
  52. }
  53. //>>includeEnd('debug');
  54. let translucencyByDistance = options.translucencyByDistance;
  55. let scaleByDistance = options.scaleByDistance;
  56. let distanceDisplayCondition = options.distanceDisplayCondition;
  57. if (defined(translucencyByDistance)) {
  58. //>>includeStart('debug', pragmas.debug);
  59. if (translucencyByDistance.far <= translucencyByDistance.near) {
  60. throw new DeveloperError(
  61. "translucencyByDistance.far must be greater than translucencyByDistance.near."
  62. );
  63. }
  64. //>>includeEnd('debug');
  65. translucencyByDistance = NearFarScalar.clone(translucencyByDistance);
  66. }
  67. if (defined(scaleByDistance)) {
  68. //>>includeStart('debug', pragmas.debug);
  69. if (scaleByDistance.far <= scaleByDistance.near) {
  70. throw new DeveloperError(
  71. "scaleByDistance.far must be greater than scaleByDistance.near."
  72. );
  73. }
  74. //>>includeEnd('debug');
  75. scaleByDistance = NearFarScalar.clone(scaleByDistance);
  76. }
  77. if (defined(distanceDisplayCondition)) {
  78. //>>includeStart('debug', pragmas.debug);
  79. if (distanceDisplayCondition.far <= distanceDisplayCondition.near) {
  80. throw new DeveloperError(
  81. "distanceDisplayCondition.far must be greater than distanceDisplayCondition.near."
  82. );
  83. }
  84. //>>includeEnd('debug');
  85. distanceDisplayCondition = DistanceDisplayCondition.clone(
  86. distanceDisplayCondition
  87. );
  88. }
  89. this._show = defaultValue(options.show, true);
  90. this._position = Cartesian3.clone(
  91. defaultValue(options.position, Cartesian3.ZERO)
  92. );
  93. this._actualPosition = Cartesian3.clone(this._position); // For columbus view and 2D
  94. this._color = Color.clone(defaultValue(options.color, Color.WHITE));
  95. this._outlineColor = Color.clone(
  96. defaultValue(options.outlineColor, Color.TRANSPARENT)
  97. );
  98. this._outlineWidth = defaultValue(options.outlineWidth, 0.0);
  99. this._pixelSize = defaultValue(options.pixelSize, 10.0);
  100. this._scaleByDistance = scaleByDistance;
  101. this._translucencyByDistance = translucencyByDistance;
  102. this._distanceDisplayCondition = distanceDisplayCondition;
  103. this._disableDepthTestDistance = defaultValue(
  104. options.disableDepthTestDistance,
  105. 0.0
  106. );
  107. this._id = options.id;
  108. this._collection = defaultValue(options.collection, pointPrimitiveCollection);
  109. this._clusterShow = true;
  110. this._pickId = undefined;
  111. this._pointPrimitiveCollection = pointPrimitiveCollection;
  112. this._dirty = false;
  113. this._index = -1; //Used only by PointPrimitiveCollection
  114. }
  115. const SHOW_INDEX = (PointPrimitive.SHOW_INDEX = 0);
  116. const POSITION_INDEX = (PointPrimitive.POSITION_INDEX = 1);
  117. const COLOR_INDEX = (PointPrimitive.COLOR_INDEX = 2);
  118. const OUTLINE_COLOR_INDEX = (PointPrimitive.OUTLINE_COLOR_INDEX = 3);
  119. const OUTLINE_WIDTH_INDEX = (PointPrimitive.OUTLINE_WIDTH_INDEX = 4);
  120. const PIXEL_SIZE_INDEX = (PointPrimitive.PIXEL_SIZE_INDEX = 5);
  121. const SCALE_BY_DISTANCE_INDEX = (PointPrimitive.SCALE_BY_DISTANCE_INDEX = 6);
  122. const TRANSLUCENCY_BY_DISTANCE_INDEX = (PointPrimitive.TRANSLUCENCY_BY_DISTANCE_INDEX = 7);
  123. const DISTANCE_DISPLAY_CONDITION_INDEX = (PointPrimitive.DISTANCE_DISPLAY_CONDITION_INDEX = 8);
  124. const DISABLE_DEPTH_DISTANCE_INDEX = (PointPrimitive.DISABLE_DEPTH_DISTANCE_INDEX = 9);
  125. PointPrimitive.NUMBER_OF_PROPERTIES = 10;
  126. function makeDirty(pointPrimitive, propertyChanged) {
  127. const pointPrimitiveCollection = pointPrimitive._pointPrimitiveCollection;
  128. if (defined(pointPrimitiveCollection)) {
  129. pointPrimitiveCollection._updatePointPrimitive(
  130. pointPrimitive,
  131. propertyChanged
  132. );
  133. pointPrimitive._dirty = true;
  134. }
  135. }
  136. Object.defineProperties(PointPrimitive.prototype, {
  137. /**
  138. * Determines if this point will be shown. Use this to hide or show a point, instead
  139. * of removing it and re-adding it to the collection.
  140. * @memberof PointPrimitive.prototype
  141. * @type {boolean}
  142. */
  143. show: {
  144. get: function () {
  145. return this._show;
  146. },
  147. set: function (value) {
  148. //>>includeStart('debug', pragmas.debug);
  149. if (!defined(value)) {
  150. throw new DeveloperError("value is required.");
  151. }
  152. //>>includeEnd('debug');
  153. if (this._show !== value) {
  154. this._show = value;
  155. makeDirty(this, SHOW_INDEX);
  156. }
  157. },
  158. },
  159. /**
  160. * Gets or sets the Cartesian position of this point.
  161. * @memberof PointPrimitive.prototype
  162. * @type {Cartesian3}
  163. */
  164. position: {
  165. get: function () {
  166. return this._position;
  167. },
  168. set: function (value) {
  169. //>>includeStart('debug', pragmas.debug)
  170. if (!defined(value)) {
  171. throw new DeveloperError("value is required.");
  172. }
  173. //>>includeEnd('debug');
  174. const position = this._position;
  175. if (!Cartesian3.equals(position, value)) {
  176. Cartesian3.clone(value, position);
  177. Cartesian3.clone(value, this._actualPosition);
  178. makeDirty(this, POSITION_INDEX);
  179. }
  180. },
  181. },
  182. /**
  183. * Gets or sets near and far scaling properties of a point based on the point's distance from the camera.
  184. * A point's scale will interpolate between the {@link NearFarScalar#nearValue} and
  185. * {@link NearFarScalar#farValue} while the camera distance falls within the lower and upper bounds
  186. * of the specified {@link NearFarScalar#near} and {@link NearFarScalar#far}.
  187. * Outside of these ranges the point's scale remains clamped to the nearest bound. This scale
  188. * multiplies the pixelSize and outlineWidth to affect the total size of the point. If undefined,
  189. * scaleByDistance will be disabled.
  190. * @memberof PointPrimitive.prototype
  191. * @type {NearFarScalar}
  192. *
  193. * @example
  194. * // Example 1.
  195. * // Set a pointPrimitive's scaleByDistance to scale to 15 when the
  196. * // camera is 1500 meters from the pointPrimitive and disappear as
  197. * // the camera distance approaches 8.0e6 meters.
  198. * p.scaleByDistance = new Cesium.NearFarScalar(1.5e2, 15, 8.0e6, 0.0);
  199. *
  200. * @example
  201. * // Example 2.
  202. * // disable scaling by distance
  203. * p.scaleByDistance = undefined;
  204. */
  205. scaleByDistance: {
  206. get: function () {
  207. return this._scaleByDistance;
  208. },
  209. set: function (value) {
  210. //>>includeStart('debug', pragmas.debug);
  211. if (defined(value) && value.far <= value.near) {
  212. throw new DeveloperError(
  213. "far distance must be greater than near distance."
  214. );
  215. }
  216. //>>includeEnd('debug');
  217. const scaleByDistance = this._scaleByDistance;
  218. if (!NearFarScalar.equals(scaleByDistance, value)) {
  219. this._scaleByDistance = NearFarScalar.clone(value, scaleByDistance);
  220. makeDirty(this, SCALE_BY_DISTANCE_INDEX);
  221. }
  222. },
  223. },
  224. /**
  225. * Gets or sets near and far translucency properties of a point based on the point's distance from the camera.
  226. * A point's translucency will interpolate between the {@link NearFarScalar#nearValue} and
  227. * {@link NearFarScalar#farValue} while the camera distance falls within the lower and upper bounds
  228. * of the specified {@link NearFarScalar#near} and {@link NearFarScalar#far}.
  229. * Outside of these ranges the point's translucency remains clamped to the nearest bound. If undefined,
  230. * translucencyByDistance will be disabled.
  231. * @memberof PointPrimitive.prototype
  232. * @type {NearFarScalar}
  233. *
  234. * @example
  235. * // Example 1.
  236. * // Set a point's translucency to 1.0 when the
  237. * // camera is 1500 meters from the point and disappear as
  238. * // the camera distance approaches 8.0e6 meters.
  239. * p.translucencyByDistance = new Cesium.NearFarScalar(1.5e2, 1.0, 8.0e6, 0.0);
  240. *
  241. * @example
  242. * // Example 2.
  243. * // disable translucency by distance
  244. * p.translucencyByDistance = undefined;
  245. */
  246. translucencyByDistance: {
  247. get: function () {
  248. return this._translucencyByDistance;
  249. },
  250. set: function (value) {
  251. //>>includeStart('debug', pragmas.debug);
  252. if (defined(value) && value.far <= value.near) {
  253. throw new DeveloperError(
  254. "far distance must be greater than near distance."
  255. );
  256. }
  257. //>>includeEnd('debug');
  258. const translucencyByDistance = this._translucencyByDistance;
  259. if (!NearFarScalar.equals(translucencyByDistance, value)) {
  260. this._translucencyByDistance = NearFarScalar.clone(
  261. value,
  262. translucencyByDistance
  263. );
  264. makeDirty(this, TRANSLUCENCY_BY_DISTANCE_INDEX);
  265. }
  266. },
  267. },
  268. /**
  269. * Gets or sets the inner size of the point in pixels.
  270. * @memberof PointPrimitive.prototype
  271. * @type {number}
  272. */
  273. pixelSize: {
  274. get: function () {
  275. return this._pixelSize;
  276. },
  277. set: function (value) {
  278. //>>includeStart('debug', pragmas.debug);
  279. if (!defined(value)) {
  280. throw new DeveloperError("value is required.");
  281. }
  282. //>>includeEnd('debug');
  283. if (this._pixelSize !== value) {
  284. this._pixelSize = value;
  285. makeDirty(this, PIXEL_SIZE_INDEX);
  286. }
  287. },
  288. },
  289. /**
  290. * Gets or sets the inner color of the point.
  291. * The red, green, blue, and alpha values are indicated by <code>value</code>'s <code>red</code>, <code>green</code>,
  292. * <code>blue</code>, and <code>alpha</code> properties as shown in Example 1. These components range from <code>0.0</code>
  293. * (no intensity) to <code>1.0</code> (full intensity).
  294. * @memberof PointPrimitive.prototype
  295. * @type {Color}
  296. *
  297. * @example
  298. * // Example 1. Assign yellow.
  299. * p.color = Cesium.Color.YELLOW;
  300. *
  301. * @example
  302. * // Example 2. Make a pointPrimitive 50% translucent.
  303. * p.color = new Cesium.Color(1.0, 1.0, 1.0, 0.5);
  304. */
  305. color: {
  306. get: function () {
  307. return this._color;
  308. },
  309. set: function (value) {
  310. //>>includeStart('debug', pragmas.debug);
  311. if (!defined(value)) {
  312. throw new DeveloperError("value is required.");
  313. }
  314. //>>includeEnd('debug');
  315. const color = this._color;
  316. if (!Color.equals(color, value)) {
  317. Color.clone(value, color);
  318. makeDirty(this, COLOR_INDEX);
  319. }
  320. },
  321. },
  322. /**
  323. * Gets or sets the outline color of the point.
  324. * @memberof PointPrimitive.prototype
  325. * @type {Color}
  326. */
  327. outlineColor: {
  328. get: function () {
  329. return this._outlineColor;
  330. },
  331. set: function (value) {
  332. //>>includeStart('debug', pragmas.debug);
  333. if (!defined(value)) {
  334. throw new DeveloperError("value is required.");
  335. }
  336. //>>includeEnd('debug');
  337. const outlineColor = this._outlineColor;
  338. if (!Color.equals(outlineColor, value)) {
  339. Color.clone(value, outlineColor);
  340. makeDirty(this, OUTLINE_COLOR_INDEX);
  341. }
  342. },
  343. },
  344. /**
  345. * Gets or sets the outline width in pixels. This width adds to pixelSize,
  346. * increasing the total size of the point.
  347. * @memberof PointPrimitive.prototype
  348. * @type {number}
  349. */
  350. outlineWidth: {
  351. get: function () {
  352. return this._outlineWidth;
  353. },
  354. set: function (value) {
  355. //>>includeStart('debug', pragmas.debug);
  356. if (!defined(value)) {
  357. throw new DeveloperError("value is required.");
  358. }
  359. //>>includeEnd('debug');
  360. if (this._outlineWidth !== value) {
  361. this._outlineWidth = value;
  362. makeDirty(this, OUTLINE_WIDTH_INDEX);
  363. }
  364. },
  365. },
  366. /**
  367. * Gets or sets the condition specifying at what distance from the camera that this point will be displayed.
  368. * @memberof PointPrimitive.prototype
  369. * @type {DistanceDisplayCondition}
  370. * @default undefined
  371. */
  372. distanceDisplayCondition: {
  373. get: function () {
  374. return this._distanceDisplayCondition;
  375. },
  376. set: function (value) {
  377. //>>includeStart('debug', pragmas.debug);
  378. if (defined(value) && value.far <= value.near) {
  379. throw new DeveloperError("far must be greater than near");
  380. }
  381. //>>includeEnd('debug');
  382. if (
  383. !DistanceDisplayCondition.equals(this._distanceDisplayCondition, value)
  384. ) {
  385. this._distanceDisplayCondition = DistanceDisplayCondition.clone(
  386. value,
  387. this._distanceDisplayCondition
  388. );
  389. makeDirty(this, DISTANCE_DISPLAY_CONDITION_INDEX);
  390. }
  391. },
  392. },
  393. /**
  394. * Gets or sets the distance from the camera at which to disable the depth test to, for example, prevent clipping against terrain.
  395. * When set to zero, the depth test is always applied. When set to Number.POSITIVE_INFINITY, the depth test is never applied.
  396. * @memberof PointPrimitive.prototype
  397. * @type {number}
  398. * @default 0.0
  399. */
  400. disableDepthTestDistance: {
  401. get: function () {
  402. return this._disableDepthTestDistance;
  403. },
  404. set: function (value) {
  405. if (this._disableDepthTestDistance !== value) {
  406. //>>includeStart('debug', pragmas.debug);
  407. if (!defined(value) || value < 0.0) {
  408. throw new DeveloperError(
  409. "disableDepthTestDistance must be greater than or equal to 0.0."
  410. );
  411. }
  412. //>>includeEnd('debug');
  413. this._disableDepthTestDistance = value;
  414. makeDirty(this, DISABLE_DEPTH_DISTANCE_INDEX);
  415. }
  416. },
  417. },
  418. /**
  419. * Gets or sets the user-defined value returned when the point is picked.
  420. * @memberof PointPrimitive.prototype
  421. * @type {*}
  422. */
  423. id: {
  424. get: function () {
  425. return this._id;
  426. },
  427. set: function (value) {
  428. this._id = value;
  429. if (defined(this._pickId)) {
  430. this._pickId.object.id = value;
  431. }
  432. },
  433. },
  434. /**
  435. * @private
  436. */
  437. pickId: {
  438. get: function () {
  439. return this._pickId;
  440. },
  441. },
  442. /**
  443. * Determines whether or not this point will be shown or hidden because it was clustered.
  444. * @memberof PointPrimitive.prototype
  445. * @type {boolean}
  446. * @private
  447. */
  448. clusterShow: {
  449. get: function () {
  450. return this._clusterShow;
  451. },
  452. set: function (value) {
  453. if (this._clusterShow !== value) {
  454. this._clusterShow = value;
  455. makeDirty(this, SHOW_INDEX);
  456. }
  457. },
  458. },
  459. });
  460. PointPrimitive.prototype.getPickId = function (context) {
  461. if (!defined(this._pickId)) {
  462. this._pickId = context.createPickId({
  463. primitive: this,
  464. collection: this._collection,
  465. id: this._id,
  466. });
  467. }
  468. return this._pickId;
  469. };
  470. PointPrimitive.prototype._getActualPosition = function () {
  471. return this._actualPosition;
  472. };
  473. PointPrimitive.prototype._setActualPosition = function (value) {
  474. Cartesian3.clone(value, this._actualPosition);
  475. makeDirty(this, POSITION_INDEX);
  476. };
  477. const tempCartesian3 = new Cartesian4();
  478. PointPrimitive._computeActualPosition = function (
  479. position,
  480. frameState,
  481. modelMatrix
  482. ) {
  483. if (frameState.mode === SceneMode.SCENE3D) {
  484. return position;
  485. }
  486. Matrix4.multiplyByPoint(modelMatrix, position, tempCartesian3);
  487. return SceneTransforms.computeActualWgs84Position(frameState, tempCartesian3);
  488. };
  489. const scratchCartesian4 = new Cartesian4();
  490. // This function is basically a stripped-down JavaScript version of PointPrimitiveCollectionVS.glsl
  491. PointPrimitive._computeScreenSpacePosition = function (
  492. modelMatrix,
  493. position,
  494. scene,
  495. result
  496. ) {
  497. // Model to world coordinates
  498. const positionWorld = Matrix4.multiplyByVector(
  499. modelMatrix,
  500. Cartesian4.fromElements(
  501. position.x,
  502. position.y,
  503. position.z,
  504. 1,
  505. scratchCartesian4
  506. ),
  507. scratchCartesian4
  508. );
  509. const positionWC = SceneTransforms.wgs84ToWindowCoordinates(
  510. scene,
  511. positionWorld,
  512. result
  513. );
  514. return positionWC;
  515. };
  516. /**
  517. * Computes the screen-space position of the point's origin.
  518. * The screen space origin is the top, left corner of the canvas; <code>x</code> increases from
  519. * left to right, and <code>y</code> increases from top to bottom.
  520. *
  521. * @param {Scene} scene The scene.
  522. * @param {Cartesian2} [result] The object onto which to store the result.
  523. * @returns {Cartesian2} The screen-space position of the point.
  524. *
  525. * @exception {DeveloperError} PointPrimitive must be in a collection.
  526. *
  527. * @example
  528. * console.log(p.computeScreenSpacePosition(scene).toString());
  529. */
  530. PointPrimitive.prototype.computeScreenSpacePosition = function (scene, result) {
  531. const pointPrimitiveCollection = this._pointPrimitiveCollection;
  532. if (!defined(result)) {
  533. result = new Cartesian2();
  534. }
  535. //>>includeStart('debug', pragmas.debug);
  536. if (!defined(pointPrimitiveCollection)) {
  537. throw new DeveloperError("PointPrimitive must be in a collection.");
  538. }
  539. if (!defined(scene)) {
  540. throw new DeveloperError("scene is required.");
  541. }
  542. //>>includeEnd('debug');
  543. const modelMatrix = pointPrimitiveCollection.modelMatrix;
  544. const windowCoordinates = PointPrimitive._computeScreenSpacePosition(
  545. modelMatrix,
  546. this._actualPosition,
  547. scene,
  548. result
  549. );
  550. if (!defined(windowCoordinates)) {
  551. return undefined;
  552. }
  553. windowCoordinates.y = scene.canvas.clientHeight - windowCoordinates.y;
  554. return windowCoordinates;
  555. };
  556. /**
  557. * Gets a point's screen space bounding box centered around screenSpacePosition.
  558. * @param {PointPrimitive} point The point to get the screen space bounding box for.
  559. * @param {Cartesian2} screenSpacePosition The screen space center of the label.
  560. * @param {BoundingRectangle} [result] The object onto which to store the result.
  561. * @returns {BoundingRectangle} The screen space bounding box.
  562. *
  563. * @private
  564. */
  565. PointPrimitive.getScreenSpaceBoundingBox = function (
  566. point,
  567. screenSpacePosition,
  568. result
  569. ) {
  570. const size = point.pixelSize;
  571. const halfSize = size * 0.5;
  572. const x = screenSpacePosition.x - halfSize;
  573. const y = screenSpacePosition.y - halfSize;
  574. const width = size;
  575. const height = size;
  576. if (!defined(result)) {
  577. result = new BoundingRectangle();
  578. }
  579. result.x = x;
  580. result.y = y;
  581. result.width = width;
  582. result.height = height;
  583. return result;
  584. };
  585. /**
  586. * Determines if this point equals another point. Points are equal if all their properties
  587. * are equal. Points in different collections can be equal.
  588. *
  589. * @param {PointPrimitive} other The point to compare for equality.
  590. * @returns {boolean} <code>true</code> if the points are equal; otherwise, <code>false</code>.
  591. */
  592. PointPrimitive.prototype.equals = function (other) {
  593. return (
  594. this === other ||
  595. (defined(other) &&
  596. this._id === other._id &&
  597. Cartesian3.equals(this._position, other._position) &&
  598. Color.equals(this._color, other._color) &&
  599. this._pixelSize === other._pixelSize &&
  600. this._outlineWidth === other._outlineWidth &&
  601. this._show === other._show &&
  602. Color.equals(this._outlineColor, other._outlineColor) &&
  603. NearFarScalar.equals(this._scaleByDistance, other._scaleByDistance) &&
  604. NearFarScalar.equals(
  605. this._translucencyByDistance,
  606. other._translucencyByDistance
  607. ) &&
  608. DistanceDisplayCondition.equals(
  609. this._distanceDisplayCondition,
  610. other._distanceDisplayCondition
  611. ) &&
  612. this._disableDepthTestDistance === other._disableDepthTestDistance)
  613. );
  614. };
  615. PointPrimitive.prototype._destroy = function () {
  616. this._pickId = this._pickId && this._pickId.destroy();
  617. this._pointPrimitiveCollection = undefined;
  618. };
  619. export default PointPrimitive;