PolylineGraphics.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*global define*/
  2. define([
  3. '../Core/defaultValue',
  4. '../Core/defined',
  5. '../Core/defineProperties',
  6. '../Core/DeveloperError',
  7. '../Core/Event',
  8. './createPropertyDescriptor'
  9. ], function(
  10. defaultValue,
  11. defined,
  12. defineProperties,
  13. DeveloperError,
  14. Event,
  15. createPropertyDescriptor) {
  16. "use strict";
  17. /**
  18. * An optionally time-dynamic polyline.
  19. * @alias PolylineGraphics
  20. * @constructor
  21. */
  22. var PolylineGraphics = function() {
  23. this._show = undefined;
  24. this._showSubscription = undefined;
  25. this._material = undefined;
  26. this._materialSubscription = undefined;
  27. this._positions = undefined;
  28. this._positionsSubscription = undefined;
  29. this._followSurface = undefined;
  30. this._followSurfaceSubscription = undefined;
  31. this._granularity = undefined;
  32. this._granularitySubscription = undefined;
  33. this._widthSubscription = undefined;
  34. this._width = undefined;
  35. this._widthSubscription = undefined;
  36. this._definitionChanged = new Event();
  37. };
  38. defineProperties(PolylineGraphics.prototype, {
  39. /**
  40. * Gets the event that is raised whenever a new property is assigned.
  41. * @memberof PolylineGraphics.prototype
  42. *
  43. * @type {Event}
  44. * @readonly
  45. */
  46. definitionChanged : {
  47. get : function() {
  48. return this._definitionChanged;
  49. }
  50. },
  51. /**
  52. * Gets or sets the boolean {@link Property} specifying the line's visibility.
  53. * @memberof PolylineGraphics.prototype
  54. * @type {Property}
  55. */
  56. show : createPropertyDescriptor('show'),
  57. /**
  58. * Gets or sets the {@link MaterialProperty} specifying the appearance of the polyline.
  59. * @memberof PolylineGraphics.prototype
  60. * @type {MaterialProperty}
  61. */
  62. material : createPropertyDescriptor('material'),
  63. /**
  64. * Gets or sets the vertex positions.
  65. * @memberof PolylineGraphics.prototype
  66. * @type {Property}
  67. */
  68. positions : createPropertyDescriptor('positions'),
  69. /**
  70. * Gets or sets the numeric {@link Property} specifying the the line's width.
  71. * @memberof PolylineGraphics.prototype
  72. * @type {Property}
  73. */
  74. width : createPropertyDescriptor('width'),
  75. /**
  76. * Gets or sets the boolean {@link Property} specifying whether or not the
  77. * points connecting the line should follow the curve of globe's surface.
  78. * @memberof PolylineGraphics.prototype
  79. * @type {Property}
  80. */
  81. followSurface : createPropertyDescriptor('followSurface'),
  82. /**
  83. * Gets or sets the numeric {@link Property} specifying the granularity
  84. * of the resulting curve when followSurface is true.
  85. * @memberof PolylineGraphics.prototype
  86. * @type {Property}
  87. */
  88. granularity : createPropertyDescriptor('granularity')
  89. });
  90. /**
  91. * Duplicates a PolylineGraphics instance.
  92. *
  93. * @param {PolylineGraphics} [result] The object onto which to store the result.
  94. * @returns {PolylineGraphics} The modified result parameter or a new instance if one was not provided.
  95. */
  96. PolylineGraphics.prototype.clone = function(result) {
  97. if (!defined(result)) {
  98. result = new PolylineGraphics();
  99. }
  100. result.show = this.show;
  101. result.material = this.material;
  102. result.positions = this.positions;
  103. result.width = this.width;
  104. result.followSurface = this.followSurface;
  105. result.granularity = this.granularity;
  106. return result;
  107. };
  108. /**
  109. * Assigns each unassigned property on this object to the value
  110. * of the same property on the provided source object.
  111. *
  112. * @param {PolylineGraphics} source The object to be merged into this object.
  113. */
  114. PolylineGraphics.prototype.merge = function(source) {
  115. //>>includeStart('debug', pragmas.debug);
  116. if (!defined(source)) {
  117. throw new DeveloperError('source is required.');
  118. }
  119. //>>includeEnd('debug');
  120. this.show = defaultValue(this.show, source.show);
  121. this.material = defaultValue(this.material, source.material);
  122. this.positions = defaultValue(this.positions, source.positions);
  123. this.width = defaultValue(this.width, source.width);
  124. this.followSurface = defaultValue(this.followSurface, source.followSurface);
  125. this.granularity = defaultValue(this.granularity, source.granularity);
  126. };
  127. return PolylineGraphics;
  128. });