PointPrimitive.js 21 KB

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