PolylineVolumeGraphics.js 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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 polyline volume defined as a line strip and corresponding two dimensional shape which is extruded along it.
  10. * The resulting volume conforms to the curvature of the globe.
  11. *
  12. * @alias PolylineVolumeGraphics
  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 volume.
  17. * @param {Property} [options.positions] A Property specifying the array of {@link Cartesian3} positions which define the line strip.
  18. * @param {Property} [options.shape] A Property specifying the array of {@link Cartesian2} positions which define the shape to be extruded.
  19. * @param {Property} [options.cornerType=CornerType.ROUNDED] A {@link CornerType} Property specifying the style of the corners.
  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 volume is filled with the provided material.
  22. * @param {MaterialProperty} [options.material=Color.WHITE] A Property specifying the material used to fill the volume.
  23. * @param {Property} [options.outline=false] A boolean Property specifying whether the volume 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 volume casts or receives shadows from each light source.
  27. * @param {Property} [options.distanceDisplayCondition] A Property specifying at what distance from the camera that this volume will be displayed.
  28. *
  29. * @see Entity
  30. * @demo {@link https://sandcastle.cesium.com/index.html?src=Polyline%20Volume.html|Cesium Sandcastle Polyline Volume Demo}
  31. */
  32. function PolylineVolumeGraphics(options) {
  33. this._definitionChanged = new Event();
  34. this._show = undefined;
  35. this._showSubscription = undefined;
  36. this._positions = undefined;
  37. this._positionsSubscription = undefined;
  38. this._shape = undefined;
  39. this._shapeSubscription = undefined;
  40. this._cornerType = undefined;
  41. this._cornerTypeSubscription = 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._distanceDisplayConditionSubsription = undefined;
  58. this.merge(defaultValue(options, defaultValue.EMPTY_OBJECT));
  59. }
  60. defineProperties(PolylineVolumeGraphics.prototype, {
  61. /**
  62. * Gets the event that is raised whenever a property or sub-property is changed or modified.
  63. * @memberof PolylineVolumeGraphics.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 volume.
  75. * @memberof PolylineVolumeGraphics.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 line strip.
  82. * @memberof PolylineVolumeGraphics.prototype
  83. * @type {Property}
  84. */
  85. positions : createPropertyDescriptor('positions'),
  86. /**
  87. * Gets or sets the Property specifying the array of {@link Cartesian2} positions which define the shape to be extruded.
  88. * @memberof PolylineVolumeGraphics.prototype
  89. * @type {Property}
  90. */
  91. shape : createPropertyDescriptor('shape'),
  92. /**
  93. * Gets or sets the {@link CornerType} Property specifying the style of the corners.
  94. * @memberof PolylineVolumeGraphics.prototype
  95. * @type {Property}
  96. * @default CornerType.ROUNDED
  97. */
  98. cornerType : createPropertyDescriptor('cornerType'),
  99. /**
  100. * Gets or sets the numeric Property specifying the angular distance between points on the volume.
  101. * @memberof PolylineVolumeGraphics.prototype
  102. * @type {Property}
  103. * @default {CesiumMath.RADIANS_PER_DEGREE}
  104. */
  105. granularity : createPropertyDescriptor('granularity'),
  106. /**
  107. * Gets or sets the boolean Property specifying whether the volume is filled with the provided material.
  108. * @memberof PolylineVolumeGraphics.prototype
  109. * @type {Property}
  110. * @default true
  111. */
  112. fill : createPropertyDescriptor('fill'),
  113. /**
  114. * Gets or sets the Property specifying the material used to fill the volume.
  115. * @memberof PolylineVolumeGraphics.prototype
  116. * @type {MaterialProperty}
  117. * @default Color.WHITE
  118. */
  119. material : createMaterialPropertyDescriptor('material'),
  120. /**
  121. * Gets or sets the Property specifying whether the volume is outlined.
  122. * @memberof PolylineVolumeGraphics.prototype
  123. * @type {Property}
  124. * @default false
  125. */
  126. outline : createPropertyDescriptor('outline'),
  127. /**
  128. * Gets or sets the Property specifying the {@link Color} of the outline.
  129. * @memberof PolylineVolumeGraphics.prototype
  130. * @type {Property}
  131. * @default Color.BLACK
  132. */
  133. outlineColor : createPropertyDescriptor('outlineColor'),
  134. /**
  135. * Gets or sets the numeric Property specifying the width of the outline.
  136. * @memberof PolylineVolumeGraphics.prototype
  137. * @type {Property}
  138. * @default 1.0
  139. */
  140. outlineWidth : createPropertyDescriptor('outlineWidth'),
  141. /**
  142. * Get or sets the enum Property specifying whether the volume
  143. * casts or receives shadows from each light source.
  144. * @memberof PolylineVolumeGraphics.prototype
  145. * @type {Property}
  146. * @default ShadowMode.DISABLED
  147. */
  148. shadows : createPropertyDescriptor('shadows'),
  149. /**
  150. * Gets or sets the {@link DistanceDisplayCondition} Property specifying at what distance from the camera that this volume will be displayed.
  151. * @memberof PolylineVolumeGraphics.prototype
  152. * @type {Property}
  153. */
  154. distanceDisplayCondition : createPropertyDescriptor('distanceDisplayCondition')
  155. });
  156. /**
  157. * Duplicates this instance.
  158. *
  159. * @param {PolylineVolumeGraphics} [result] The object onto which to store the result.
  160. * @returns {PolylineVolumeGraphics} The modified result parameter or a new instance if one was not provided.
  161. */
  162. PolylineVolumeGraphics.prototype.clone = function(result) {
  163. if (!defined(result)) {
  164. return new PolylineVolumeGraphics(this);
  165. }
  166. result.show = this.show;
  167. result.positions = this.positions;
  168. result.shape = this.shape;
  169. result.cornerType = this.cornerType;
  170. result.granularity = this.granularity;
  171. result.fill = this.fill;
  172. result.material = this.material;
  173. result.outline = this.outline;
  174. result.outlineColor = this.outlineColor;
  175. result.outlineWidth = this.outlineWidth;
  176. result.shadows = this.shadows;
  177. result.distanceDisplayCondition = this.distanceDisplayCondition;
  178. return result;
  179. };
  180. /**
  181. * Assigns each unassigned property on this object to the value
  182. * of the same property on the provided source object.
  183. *
  184. * @param {PolylineVolumeGraphics} source The object to be merged into this object.
  185. */
  186. PolylineVolumeGraphics.prototype.merge = function(source) {
  187. //>>includeStart('debug', pragmas.debug);
  188. if (!defined(source)) {
  189. throw new DeveloperError('source is required.');
  190. }
  191. //>>includeEnd('debug');
  192. this.show = defaultValue(this.show, source.show);
  193. this.positions = defaultValue(this.positions, source.positions);
  194. this.shape = defaultValue(this.shape, source.shape);
  195. this.cornerType = defaultValue(this.cornerType, source.cornerType);
  196. this.granularity = defaultValue(this.granularity, source.granularity);
  197. this.fill = defaultValue(this.fill, source.fill);
  198. this.material = defaultValue(this.material, source.material);
  199. this.outline = defaultValue(this.outline, source.outline);
  200. this.outlineColor = defaultValue(this.outlineColor, source.outlineColor);
  201. this.outlineWidth = defaultValue(this.outlineWidth, source.outlineWidth);
  202. this.shadows = defaultValue(this.shadows, source.shadows);
  203. this.distanceDisplayCondition = defaultValue(this.distanceDisplayCondition, source.distanceDisplayCondition);
  204. };
  205. export default PolylineVolumeGraphics;