WallGraphics.js 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. import defaultValue from '../Core/defaultValue.js';
  2. import defined from '../Core/defined.js';
  3. import defineProperties from '../Core/defineProperties.js';
  4. import DeveloperError from '../Core/DeveloperError.js';
  5. import Event from '../Core/Event.js';
  6. import createMaterialPropertyDescriptor from './createMaterialPropertyDescriptor.js';
  7. import createPropertyDescriptor from './createPropertyDescriptor.js';
  8. /**
  9. * Describes a two dimensional wall defined as a line strip and optional maximum and minimum heights.
  10. * The wall conforms to the curvature of the globe and can be placed along the surface or at altitude.
  11. *
  12. * @alias WallGraphics
  13. * @constructor
  14. *
  15. * @param {Object} [options] Object with the following properties:
  16. * @param {Property} [options.show=true] A boolean Property specifying the visibility of the wall.
  17. * @param {Property} [options.positions] A Property specifying the array of {@link Cartesian3} positions which define the top of the wall.
  18. * @param {Property} [options.minimumHeights] A Property specifying an array of heights to be used for the bottom of the wall instead of the globe surface.
  19. * @param {Property} [options.maximumHeights] A Property specifying an array of heights to be used for the top of the wall instead of the height of each position.
  20. * @param {Property} [options.granularity=Cesium.Math.RADIANS_PER_DEGREE] A numeric Property specifying the angular distance between each latitude and longitude point.
  21. * @param {Property} [options.fill=true] A boolean Property specifying whether the wall is filled with the provided material.
  22. * @param {MaterialProperty} [options.material=Color.WHITE] A Property specifying the material used to fill the wall.
  23. * @param {Property} [options.outline=false] A boolean Property specifying whether the wall is outlined.
  24. * @param {Property} [options.outlineColor=Color.BLACK] A Property specifying the {@link Color} of the outline.
  25. * @param {Property} [options.outlineWidth=1.0] A numeric Property specifying the width of the outline.
  26. * @param {Property} [options.shadows=ShadowMode.DISABLED] An enum Property specifying whether the wall casts or receives shadows from each light source.
  27. * @param {Property} [options.distanceDisplayCondition] A Property specifying at what distance from the camera that this wall will be displayed.
  28. *
  29. * @see Entity
  30. * @demo {@link https://sandcastle.cesium.com/index.html?src=Wall.html|Cesium Sandcastle Wall Demo}
  31. */
  32. function WallGraphics(options) {
  33. this._definitionChanged = new Event();
  34. this._show = undefined;
  35. this._showSubscription = undefined;
  36. this._positions = undefined;
  37. this._positionsSubscription = undefined;
  38. this._minimumHeights = undefined;
  39. this._minimumHeightsSubscription = undefined;
  40. this._maximumHeights = undefined;
  41. this._maximumHeightsSubscription = undefined;
  42. this._granularity = undefined;
  43. this._granularitySubscription = undefined;
  44. this._fill = undefined;
  45. this._fillSubscription = undefined;
  46. this._material = undefined;
  47. this._materialSubscription = undefined;
  48. this._outline = undefined;
  49. this._outlineSubscription = undefined;
  50. this._outlineColor = undefined;
  51. this._outlineColorSubscription = undefined;
  52. this._outlineWidth = undefined;
  53. this._outlineWidthSubscription = undefined;
  54. this._shadows = undefined;
  55. this._shadowsSubscription = undefined;
  56. this._distanceDisplayCondition = undefined;
  57. this._distanceDisplayConditionSubscription = undefined;
  58. this.merge(defaultValue(options, defaultValue.EMPTY_OBJECT));
  59. }
  60. defineProperties(WallGraphics.prototype, {
  61. /**
  62. * Gets the event that is raised whenever a property or sub-property is changed or modified.
  63. * @memberof WallGraphics.prototype
  64. *
  65. * @type {Event}
  66. * @readonly
  67. */
  68. definitionChanged : {
  69. get : function() {
  70. return this._definitionChanged;
  71. }
  72. },
  73. /**
  74. * Gets or sets the boolean Property specifying the visibility of the wall.
  75. * @memberof WallGraphics.prototype
  76. * @type {Property}
  77. * @default true
  78. */
  79. show : createPropertyDescriptor('show'),
  80. /**
  81. * Gets or sets the Property specifying the array of {@link Cartesian3} positions which define the top of the wall.
  82. * @memberof WallGraphics.prototype
  83. * @type {Property}
  84. */
  85. positions : createPropertyDescriptor('positions'),
  86. /**
  87. * Gets or sets the Property specifying an array of heights to be used for the bottom of the wall instead of the surface of the globe.
  88. * If defined, the array must be the same length as {@link Wall#positions}.
  89. * @memberof WallGraphics.prototype
  90. * @type {Property}
  91. */
  92. minimumHeights : createPropertyDescriptor('minimumHeights'),
  93. /**
  94. * Gets or sets the Property specifying an array of heights to be used for the top of the wall instead of the height of each position.
  95. * If defined, the array must be the same length as {@link Wall#positions}.
  96. * @memberof WallGraphics.prototype
  97. * @type {Property}
  98. */
  99. maximumHeights : createPropertyDescriptor('maximumHeights'),
  100. /**
  101. * Gets or sets the numeric Property specifying the angular distance between points on the wall.
  102. * @memberof WallGraphics.prototype
  103. * @type {Property}
  104. * @default {CesiumMath.RADIANS_PER_DEGREE}
  105. */
  106. granularity : createPropertyDescriptor('granularity'),
  107. /**
  108. * Gets or sets the boolean Property specifying whether the wall is filled with the provided material.
  109. * @memberof WallGraphics.prototype
  110. * @type {Property}
  111. * @default true
  112. */
  113. fill : createPropertyDescriptor('fill'),
  114. /**
  115. * Gets or sets the Property specifying the material used to fill the wall.
  116. * @memberof WallGraphics.prototype
  117. * @type {MaterialProperty}
  118. * @default Color.WHITE
  119. */
  120. material : createMaterialPropertyDescriptor('material'),
  121. /**
  122. * Gets or sets the Property specifying whether the wall is outlined.
  123. * @memberof WallGraphics.prototype
  124. * @type {Property}
  125. * @default false
  126. */
  127. outline : createPropertyDescriptor('outline'),
  128. /**
  129. * Gets or sets the Property specifying the {@link Color} of the outline.
  130. * @memberof WallGraphics.prototype
  131. * @type {Property}
  132. * @default Color.BLACK
  133. */
  134. outlineColor : createPropertyDescriptor('outlineColor'),
  135. /**
  136. * Gets or sets the numeric Property specifying the width of the outline.
  137. * @memberof WallGraphics.prototype
  138. * @type {Property}
  139. * @default 1.0
  140. */
  141. outlineWidth : createPropertyDescriptor('outlineWidth'),
  142. /**
  143. * Get or sets the enum Property specifying whether the wall
  144. * casts or receives shadows from each light source.
  145. * @memberof WallGraphics.prototype
  146. * @type {Property}
  147. * @default ShadowMode.DISABLED
  148. */
  149. shadows : createPropertyDescriptor('shadows'),
  150. /**
  151. * Gets or sets the {@link DistanceDisplayCondition} Property specifying at what distance from the camera that this wall will be displayed.
  152. * @memberof WallGraphics.prototype
  153. * @type {Property}
  154. */
  155. distanceDisplayCondition : createPropertyDescriptor('distanceDisplayCondition')
  156. });
  157. /**
  158. * Duplicates this instance.
  159. *
  160. * @param {WallGraphics} [result] The object onto which to store the result.
  161. * @returns {WallGraphics} The modified result parameter or a new instance if one was not provided.
  162. */
  163. WallGraphics.prototype.clone = function(result) {
  164. if (!defined(result)) {
  165. return new WallGraphics(this);
  166. }
  167. result.show = this.show;
  168. result.positions = this.positions;
  169. result.minimumHeights = this.minimumHeights;
  170. result.maximumHeights = this.maximumHeights;
  171. result.granularity = this.granularity;
  172. result.fill = this.fill;
  173. result.material = this.material;
  174. result.outline = this.outline;
  175. result.outlineColor = this.outlineColor;
  176. result.outlineWidth = this.outlineWidth;
  177. result.shadows = this.shadows;
  178. result.distanceDisplayCondition = this.distanceDisplayCondition;
  179. return result;
  180. };
  181. /**
  182. * Assigns each unassigned property on this object to the value
  183. * of the same property on the provided source object.
  184. *
  185. * @param {WallGraphics} source The object to be merged into this object.
  186. */
  187. WallGraphics.prototype.merge = function(source) {
  188. //>>includeStart('debug', pragmas.debug);
  189. if (!defined(source)) {
  190. throw new DeveloperError('source is required.');
  191. }
  192. //>>includeEnd('debug');
  193. this.show = defaultValue(this.show, source.show);
  194. this.positions = defaultValue(this.positions, source.positions);
  195. this.minimumHeights = defaultValue(this.minimumHeights, source.minimumHeights);
  196. this.maximumHeights = defaultValue(this.maximumHeights, source.maximumHeights);
  197. this.granularity = defaultValue(this.granularity, source.granularity);
  198. this.fill = defaultValue(this.fill, source.fill);
  199. this.material = defaultValue(this.material, source.material);
  200. this.outline = defaultValue(this.outline, source.outline);
  201. this.outlineColor = defaultValue(this.outlineColor, source.outlineColor);
  202. this.outlineWidth = defaultValue(this.outlineWidth, source.outlineWidth);
  203. this.shadows = defaultValue(this.shadows, source.shadows);
  204. this.distanceDisplayCondition = defaultValue(this.distanceDisplayCondition, source.distanceDisplayCondition);
  205. };
  206. export default WallGraphics;