PolygonGraphics.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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 polygon.
  19. *
  20. * @alias PolygonGraphics
  21. * @constructor
  22. */
  23. var PolygonGraphics = function() {
  24. this._show = undefined;
  25. this._showSubscription = undefined;
  26. this._material = undefined;
  27. this._materialSubscription = undefined;
  28. this._positions = undefined;
  29. this._positionsSubscription = undefined;
  30. this._height = undefined;
  31. this._heightSubscription = undefined;
  32. this._extrudedHeight = undefined;
  33. this._extrudedHeightSubscription = undefined;
  34. this._granularity = undefined;
  35. this._granularitySubscription = undefined;
  36. this._stRotation = undefined;
  37. this._stRotationSubscription = undefined;
  38. this._perPositionHeight = undefined;
  39. this._perPositionHeightSubscription = undefined;
  40. this._outline = undefined;
  41. this._outlineSubscription = undefined;
  42. this._outlineColor = undefined;
  43. this._outlineColorSubscription = undefined;
  44. this._outlineWidth = undefined;
  45. this._outlineWidthSubscription = undefined;
  46. this._definitionChanged = new Event();
  47. this._fill = undefined;
  48. this._fillSubscription = undefined;
  49. };
  50. defineProperties(PolygonGraphics.prototype, {
  51. /**
  52. * Gets the event that is raised whenever a new property is assigned.
  53. * @memberof PolygonGraphics.prototype
  54. *
  55. * @type {Event}
  56. * @readonly
  57. */
  58. definitionChanged : {
  59. get : function() {
  60. return this._definitionChanged;
  61. }
  62. },
  63. /**
  64. * Gets or sets the boolean {@link Property} specifying the polygon's visibility.
  65. * @memberof PolygonGraphics.prototype
  66. * @type {Property}
  67. */
  68. show : createPropertyDescriptor('show'),
  69. /**
  70. * Gets or sets the {@link MaterialProperty} specifying the appearance of the polygon.
  71. * @memberof PolygonGraphics.prototype
  72. * @type {MaterialProperty}
  73. */
  74. material : createPropertyDescriptor('material'),
  75. /**
  76. * Gets or sets the vertex positions.
  77. * @memberof PolygonGraphics.prototype
  78. * @type {Property}
  79. */
  80. positions : createPropertyDescriptor('positions'),
  81. /**
  82. * Gets or sets the Number {@link Property} specifying the height of the polygon.
  83. * If undefined, the polygon will be on the surface.
  84. * @memberof PolygonGraphics.prototype
  85. * @type {Property}
  86. */
  87. height : createPropertyDescriptor('height'),
  88. /**
  89. * Gets or sets the Number {@link Property} specifying the extruded height of the polygon.
  90. * Setting this property creates a polygon shaped volume starting at height and ending
  91. * at the extruded height.
  92. * @memberof PolygonGraphics.prototype
  93. * @type {Property}
  94. */
  95. extrudedHeight : createPropertyDescriptor('extrudedHeight'),
  96. /**
  97. * Gets or sets the Number {@link Property} specifying the sampling distance, in radians,
  98. * between each latitude and longitude point.
  99. * @memberof PolygonGraphics.prototype
  100. * @type {Property}
  101. */
  102. granularity : createPropertyDescriptor('granularity'),
  103. /**
  104. * Gets or sets the Number {@link Property} specifying the rotation of the texture coordinates,
  105. * in radians. A positive rotation is counter-clockwise.
  106. * @memberof PolygonGraphics.prototype
  107. * @type {Property}
  108. */
  109. stRotation : createPropertyDescriptor('stRotation'),
  110. /**
  111. * Gets or sets the Boolean {@link Property} specifying whether the polygon should be filled.
  112. * @memberof PolygonGraphics.prototype
  113. * @type {Property}
  114. */
  115. fill : createPropertyDescriptor('fill'),
  116. /**
  117. * Gets or sets the Boolean {@link Property} specifying whether the polygon should be outlined.
  118. * @memberof PolygonGraphics.prototype
  119. * @type {Property}
  120. */
  121. outline : createPropertyDescriptor('outline'),
  122. /**
  123. * Gets or sets the Color {@link Property} specifying whether the color of the outline.
  124. * @memberof PolygonGraphics.prototype
  125. * @type {Property}
  126. */
  127. outlineColor : createPropertyDescriptor('outlineColor'),
  128. /**
  129. * Gets or sets the Number {@link Property} specifying the width of the outline.
  130. * @memberof PolygonGraphics.prototype
  131. * @type {Property}
  132. */
  133. outlineWidth : createPropertyDescriptor('outlineWidth'),
  134. /**
  135. * Gets or sets the Boolean {@link Property} specifying whether the polygon uses per-position heights.
  136. * @memberof PolygonGraphics.prototype
  137. * @type {Property}
  138. */
  139. perPositionHeight : createPropertyDescriptor('perPositionHeight')
  140. });
  141. /**
  142. * Duplicates a PolygonGraphics instance.
  143. *
  144. * @param {PolygonGraphics} [result] The object onto which to store the result.
  145. * @returns {PolygonGraphics} The modified result parameter or a new instance if one was not provided.
  146. */
  147. PolygonGraphics.prototype.clone = function(result) {
  148. if (!defined(result)) {
  149. result = new PolygonGraphics();
  150. }
  151. result.show = this.show;
  152. result.material = this.material;
  153. result.positions = this.positions;
  154. result.height = this.height;
  155. result.extrudedHeight = this.extrudedHeight;
  156. result.granularity = this.granularity;
  157. result.stRotation = this.stRotation;
  158. result.fill = this.fill;
  159. result.outline = this.outline;
  160. result.outlineColor = this.outlineColor;
  161. result.outlineWidth = this.outlineWidth;
  162. result.perPositionHeight = this.perPositionHeight;
  163. return result;
  164. };
  165. /**
  166. * Assigns each unassigned property on this object to the value
  167. * of the same property on the provided source object.
  168. *
  169. * @param {PolygonGraphics} source The object to be merged into this object.
  170. */
  171. PolygonGraphics.prototype.merge = function(source) {
  172. //>>includeStart('debug', pragmas.debug);
  173. if (!defined(source)) {
  174. throw new DeveloperError('source is required.');
  175. }
  176. //>>includeEnd('debug');
  177. this.show = defaultValue(this.show, source.show);
  178. this.material = defaultValue(this.material, source.material);
  179. this.positions = defaultValue(this.positions, source.positions);
  180. this.height = defaultValue(this.height, source.height);
  181. this.extrudedHeight = defaultValue(this.extrudedHeight, source.extrudedHeight);
  182. this.granularity = defaultValue(this.granularity, source.granularity);
  183. this.stRotation = defaultValue(this.stRotation, source.stRotation);
  184. this.fill = defaultValue(this.fill, source.fill);
  185. this.outline = defaultValue(this.outline, source.outline);
  186. this.outlineColor = defaultValue(this.outlineColor, source.outlineColor);
  187. this.outlineWidth = defaultValue(this.outlineWidth, source.outlineWidth);
  188. this.perPositionHeight = defaultValue(this.perPositionHeight, source.perPositionHeight);
  189. };
  190. return PolygonGraphics;
  191. });