PathGraphics.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. * A time-dynamic path representing the visualization of a moving object.
  19. * @alias PathGraphics
  20. * @constructor
  21. */
  22. var PathGraphics = function() {
  23. this._material = undefined;
  24. this._materialSubscription = undefined;
  25. this._show = undefined;
  26. this._showSubscription = undefined;
  27. this._width = undefined;
  28. this._widthSubscription = undefined;
  29. this._resolution = undefined;
  30. this._resolutionSubscription = undefined;
  31. this._leadTime = undefined;
  32. this._leadTimeSubscription = undefined;
  33. this._trailTime = undefined;
  34. this._trailTimeSubscription = undefined;
  35. this._definitionChanged = new Event();
  36. };
  37. defineProperties(PathGraphics.prototype, {
  38. /**
  39. * Gets the event that is raised whenever a new property is assigned.
  40. * @memberof PathGraphics.prototype
  41. *
  42. * @type {Event}
  43. * @readonly
  44. */
  45. definitionChanged : {
  46. get : function() {
  47. return this._definitionChanged;
  48. }
  49. },
  50. /**
  51. * Gets or sets the {@link MaterialProperty} specifying the appearance of the path.
  52. * @memberof PathGraphics.prototype
  53. * @type {MaterialProperty}
  54. */
  55. material : createPropertyDescriptor('material'),
  56. /**
  57. * Gets or sets the boolean {@link Property} specifying the path's visibility.
  58. * @memberof PathGraphics.prototype
  59. * @type {Property}
  60. */
  61. show : createPropertyDescriptor('show'),
  62. /**
  63. * Gets or sets the numeric {@link Property} specifying the the path's width.
  64. * @memberof PathGraphics.prototype
  65. * @type {Property}
  66. */
  67. width : createPropertyDescriptor('width'),
  68. /**
  69. * Gets or sets the numeric {@link Property} specifying the maximum step size, in seconds, to take when sampling the position.
  70. * @memberof PathGraphics.prototype
  71. * @type {Property}
  72. */
  73. resolution : createPropertyDescriptor('resolution'),
  74. /**
  75. * Gets or sets the numeric {@link Property} specifying the number of seconds in front of the object to show.
  76. * @memberof PathGraphics.prototype
  77. * @type {Property}
  78. */
  79. leadTime : createPropertyDescriptor('leadTime'),
  80. /**
  81. * Gets or sets the numeric {@link Property} specifying the number of seconds behind the object to show.
  82. * @memberof PathGraphics.prototype
  83. * @type {Property}
  84. */
  85. trailTime : createPropertyDescriptor('trailTime')
  86. });
  87. /**
  88. * Duplicates a PathGraphics instance.
  89. *
  90. * @param {PathGraphics} [result] The object onto which to store the result.
  91. * @returns {PathGraphics} The modified result parameter or a new instance if one was not provided.
  92. */
  93. PathGraphics.prototype.clone = function(result) {
  94. if (!defined(result)) {
  95. result = new PathGraphics();
  96. }
  97. result.material = this.material;
  98. result.width = this.width;
  99. result.resolution = this.resolution;
  100. result.show = this.show;
  101. result.leadTime = this.leadTime;
  102. result.trailTime = this.trailTime;
  103. return result;
  104. };
  105. /**
  106. * Assigns each unassigned property on this object to the value
  107. * of the same property on the provided source object.
  108. *
  109. * @param {PathGraphics} source The object to be merged into this object.
  110. */
  111. PathGraphics.prototype.merge = function(source) {
  112. //>>includeStart('debug', pragmas.debug);
  113. if (!defined(source)) {
  114. throw new DeveloperError('source is required.');
  115. }
  116. //>>includeEnd('debug');
  117. this.material = defaultValue(this.material, source.material);
  118. this.width = defaultValue(this.width, source.width);
  119. this.resolution = defaultValue(this.resolution, source.resolution);
  120. this.show = defaultValue(this.show, source.show);
  121. this.leadTime = defaultValue(this.leadTime, source.leadTime);
  122. this.trailTime = defaultValue(this.trailTime, source.trailTime);
  123. };
  124. return PathGraphics;
  125. });