Source: DataSources/CorridorGraphics.js

  1. /*global define*/
  2. define([
  3. '../Core/defaultValue',
  4. '../Core/defined',
  5. '../Core/defineProperties',
  6. '../Core/DeveloperError',
  7. '../Core/Event',
  8. './createMaterialPropertyDescriptor',
  9. './createPropertyDescriptor'
  10. ], function(
  11. defaultValue,
  12. defined,
  13. defineProperties,
  14. DeveloperError,
  15. Event,
  16. createMaterialPropertyDescriptor,
  17. createPropertyDescriptor) {
  18. 'use strict';
  19. /**
  20. * Describes a corridor, which is a shape defined by a centerline and width that
  21. * conforms to the curvature of the globe. It can be placed on the surface or at altitude
  22. * and can optionally be extruded into a volume.
  23. *
  24. * @alias CorridorGraphics
  25. * @constructor
  26. *
  27. * @param {Object} [options] Object with the following properties:
  28. * @param {Property} [options.positions] A Property specifying the array of {@link Cartesian3} positions that define the centerline of the corridor.
  29. * @param {Property} [options.width] A numeric Property specifying the distance between the edges of the corridor.
  30. * @param {Property} [options.cornerType=CornerType.ROUNDED] A {@link CornerType} Property specifying the style of the corners.
  31. * @param {Property} [options.height=0] A numeric Property specifying the altitude of the corridor relative to the ellipsoid surface.
  32. * @param {Property} [options.extrudedHeight] A numeric Property specifying the altitude of the corridor's extruded face relative to the ellipsoid surface.
  33. * @param {Property} [options.show=true] A boolean Property specifying the visibility of the corridor.
  34. * @param {Property} [options.fill=true] A boolean Property specifying whether the corridor is filled with the provided material.
  35. * @param {MaterialProperty} [options.material=Color.WHITE] A Property specifying the material used to fill the corridor.
  36. * @param {Property} [options.outline=false] A boolean Property specifying whether the corridor is outlined.
  37. * @param {Property} [options.outlineColor=Color.BLACK] A Property specifying the {@link Color} of the outline.
  38. * @param {Property} [options.outlineWidth=1.0] A numeric Property specifying the width of the outline.
  39. * @param {Property} [options.granularity=Cesium.Math.RADIANS_PER_DEGREE] A numeric Property specifying the distance between each latitude and longitude.
  40. * @param {Property} [options.shadows=ShadowMode.DISABLED] An enum Property specifying whether the corridor casts or receives shadows from each light source.
  41. * @param {Property} [options.distanceDisplayCondition] A Property specifying at what distance from the camera that this corridor will be displayed.
  42. *
  43. * @see Entity
  44. * @demo {@link http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Corridor.html|Cesium Sandcastle Corridor Demo}
  45. */
  46. function CorridorGraphics(options) {
  47. this._show = undefined;
  48. this._showSubscription = undefined;
  49. this._material = undefined;
  50. this._materialSubscription = undefined;
  51. this._positions = undefined;
  52. this._positionsSubscription = undefined;
  53. this._height = undefined;
  54. this._heightSubscription = undefined;
  55. this._extrudedHeight = undefined;
  56. this._extrudedHeightSubscription = undefined;
  57. this._granularity = undefined;
  58. this._granularitySubscription = undefined;
  59. this._width = undefined;
  60. this._widthSubscription = undefined;
  61. this._cornerType = undefined;
  62. this._cornerTypeSubscription = undefined;
  63. this._fill = undefined;
  64. this._fillSubscription = undefined;
  65. this._outline = undefined;
  66. this._outlineSubscription = undefined;
  67. this._outlineColor = undefined;
  68. this._outlineColorSubscription = undefined;
  69. this._outlineWidth = undefined;
  70. this._outlineWidthSubscription = undefined;
  71. this._shadows = undefined;
  72. this._shadowsSubscription = undefined;
  73. this._distanceDisplayCondition = undefined;
  74. this._distanceDisplayConditionSubscription = undefined;
  75. this._definitionChanged = new Event();
  76. this.merge(defaultValue(options, defaultValue.EMPTY_OBJECT));
  77. }
  78. defineProperties(CorridorGraphics.prototype, {
  79. /**
  80. * Gets the event that is raised whenever a property or sub-property is changed or modified.
  81. * @memberof CorridorGraphics.prototype
  82. * @type {Event}
  83. * @readonly
  84. */
  85. definitionChanged : {
  86. get : function() {
  87. return this._definitionChanged;
  88. }
  89. },
  90. /**
  91. * Gets or sets the boolean Property specifying the visibility of the corridor.
  92. * @memberof CorridorGraphics.prototype
  93. * @type {Property}
  94. * @default true
  95. */
  96. show : createPropertyDescriptor('show'),
  97. /**
  98. * Gets or sets the Property specifying the material used to fill the corridor.
  99. * @memberof CorridorGraphics.prototype
  100. * @type {MaterialProperty}
  101. * @default Color.WHITE
  102. */
  103. material : createMaterialPropertyDescriptor('material'),
  104. /**
  105. * Gets or sets a Property specifying the array of {@link Cartesian3} positions that define the centerline of the corridor.
  106. * @memberof CorridorGraphics.prototype
  107. * @type {Property}
  108. */
  109. positions : createPropertyDescriptor('positions'),
  110. /**
  111. * Gets or sets the numeric Property specifying the altitude of the corridor.
  112. * @memberof CorridorGraphics.prototype
  113. * @type {Property}
  114. * @default 0.0
  115. */
  116. height : createPropertyDescriptor('height'),
  117. /**
  118. * Gets or sets the numeric Property specifying the altitude of the corridor extrusion.
  119. * Setting this property creates a corridor shaped volume starting at height and ending
  120. * at this altitude.
  121. * @memberof CorridorGraphics.prototype
  122. * @type {Property}
  123. */
  124. extrudedHeight : createPropertyDescriptor('extrudedHeight'),
  125. /**
  126. * Gets or sets the numeric Property specifying the sampling distance between each latitude and longitude point.
  127. * @memberof CorridorGraphics.prototype
  128. * @type {Property}
  129. * @default {CesiumMath.RADIANS_PER_DEGREE}
  130. */
  131. granularity : createPropertyDescriptor('granularity'),
  132. /**
  133. * Gets or sets the numeric Property specifying the width of the corridor.
  134. * @memberof CorridorGraphics.prototype
  135. * @type {Property}
  136. */
  137. width : createPropertyDescriptor('width'),
  138. /**
  139. * Gets or sets the boolean Property specifying whether the corridor is filled with the provided material.
  140. * @memberof CorridorGraphics.prototype
  141. * @type {Property}
  142. * @default true
  143. */
  144. fill : createPropertyDescriptor('fill'),
  145. /**
  146. * Gets or sets the Property specifying whether the corridor is outlined.
  147. * @memberof CorridorGraphics.prototype
  148. * @type {Property}
  149. * @default false
  150. */
  151. outline : createPropertyDescriptor('outline'),
  152. /**
  153. * Gets or sets the Property specifying the {@link Color} of the outline.
  154. * @memberof CorridorGraphics.prototype
  155. * @type {Property}
  156. * @default Color.BLACK
  157. */
  158. outlineColor : createPropertyDescriptor('outlineColor'),
  159. /**
  160. * Gets or sets the numeric Property specifying the width of the outline.
  161. * @memberof CorridorGraphics.prototype
  162. * @type {Property}
  163. * @default 1.0
  164. */
  165. outlineWidth : createPropertyDescriptor('outlineWidth'),
  166. /**
  167. * Gets or sets the {@link CornerType} Property specifying how corners are styled.
  168. * @memberof CorridorGraphics.prototype
  169. * @type {Property}
  170. * @default CornerType.ROUNDED
  171. */
  172. cornerType : createPropertyDescriptor('cornerType'),
  173. /**
  174. * Get or sets the enum Property specifying whether the corridor
  175. * casts or receives shadows from each light source.
  176. * @memberof CorridorGraphics.prototype
  177. * @type {Property}
  178. * @default ShadowMode.DISABLED
  179. */
  180. shadows : createPropertyDescriptor('shadows'),
  181. /**
  182. * Gets or sets the {@link DistanceDisplayCondition} Property specifying at what distance from the camera that this corridor will be displayed.
  183. * @memberof CorridorGraphics.prototype
  184. * @type {Property}
  185. */
  186. distanceDisplayCondition : createPropertyDescriptor('distanceDisplayCondition')
  187. });
  188. /**
  189. * Duplicates this instance.
  190. *
  191. * @param {CorridorGraphics} [result] The object onto which to store the result.
  192. * @returns {CorridorGraphics} The modified result parameter or a new instance if one was not provided.
  193. */
  194. CorridorGraphics.prototype.clone = function(result) {
  195. if (!defined(result)) {
  196. return new CorridorGraphics(this);
  197. }
  198. result.show = this.show;
  199. result.material = this.material;
  200. result.positions = this.positions;
  201. result.height = this.height;
  202. result.extrudedHeight = this.extrudedHeight;
  203. result.granularity = this.granularity;
  204. result.width = this.width;
  205. result.fill = this.fill;
  206. result.outline = this.outline;
  207. result.outlineColor = this.outlineColor;
  208. result.outlineWidth = this.outlineWidth;
  209. result.cornerType = this.cornerType;
  210. result.shadows = this.shadows;
  211. result.distanceDisplayCondition = this.distanceDisplayCondition;
  212. return result;
  213. };
  214. /**
  215. * Assigns each unassigned property on this object to the value
  216. * of the same property on the provided source object.
  217. *
  218. * @param {CorridorGraphics} source The object to be merged into this object.
  219. */
  220. CorridorGraphics.prototype.merge = function(source) {
  221. //>>includeStart('debug', pragmas.debug);
  222. if (!defined(source)) {
  223. throw new DeveloperError('source is required.');
  224. }
  225. //>>includeEnd('debug');
  226. this.show = defaultValue(this.show, source.show);
  227. this.material = defaultValue(this.material, source.material);
  228. this.positions = defaultValue(this.positions, source.positions);
  229. this.height = defaultValue(this.height, source.height);
  230. this.extrudedHeight = defaultValue(this.extrudedHeight, source.extrudedHeight);
  231. this.granularity = defaultValue(this.granularity, source.granularity);
  232. this.width = defaultValue(this.width, source.width);
  233. this.fill = defaultValue(this.fill, source.fill);
  234. this.outline = defaultValue(this.outline, source.outline);
  235. this.outlineColor = defaultValue(this.outlineColor, source.outlineColor);
  236. this.outlineWidth = defaultValue(this.outlineWidth, source.outlineWidth);
  237. this.cornerType = defaultValue(this.cornerType, source.cornerType);
  238. this.shadows = defaultValue(this.shadows, source.shadows);
  239. this.distanceDisplayCondition = defaultValue(this.distanceDisplayCondition, source.distanceDisplayCondition);
  240. };
  241. return CorridorGraphics;
  242. });