PolylineVolumeGraphics.js 9.3 KB

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