PolylineOutlineMaterialProperty.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*global define*/
  2. define([
  3. '../Core/Color',
  4. '../Core/defined',
  5. '../Core/defineProperties',
  6. '../Core/Event',
  7. './createPropertyDescriptor',
  8. './Property'
  9. ], function(
  10. Color,
  11. defined,
  12. defineProperties,
  13. Event,
  14. createPropertyDescriptor,
  15. Property) {
  16. "use strict";
  17. var defaultColor = Color.WHITE;
  18. var defaultOutlineColor = Color.BLACK;
  19. var defaultOutlineWidth = 0.0;
  20. /**
  21. * A {@link MaterialProperty} that maps to polyline outline {@link Material} uniforms.
  22. * @alias PolylineOutlineMaterialProperty
  23. * @constructor
  24. */
  25. var PolylineOutlineMaterialProperty = function() {
  26. this._definitionChanged = new Event();
  27. this._color = undefined;
  28. this._colorSubscription = undefined;
  29. this._outlineColor = undefined;
  30. this._outlineColorSubscription = undefined;
  31. this._outlineWidth = undefined;
  32. this._outlineWidthSubscription = undefined;
  33. };
  34. defineProperties(PolylineOutlineMaterialProperty.prototype, {
  35. /**
  36. * Gets a value indicating if this property is constant. A property is considered
  37. * constant if getValue always returns the same result for the current definition.
  38. * @memberof PolylineOutlineMaterialProperty.prototype
  39. *
  40. * @type {Boolean}
  41. * @readonly
  42. */
  43. isConstant : {
  44. get : function() {
  45. return Property.isConstant(this._color) && Property.isConstant(this._outlineColor) && Property.isConstant(this._outlineWidth);
  46. }
  47. },
  48. /**
  49. * Gets the event that is raised whenever the definition of this property changes.
  50. * The definition is considered to have changed if a call to getValue would return
  51. * a different result for the same time.
  52. * @memberof PolylineOutlineMaterialProperty.prototype
  53. *
  54. * @type {Event}
  55. * @readonly
  56. */
  57. definitionChanged : {
  58. get : function() {
  59. return this._definitionChanged;
  60. }
  61. },
  62. /**
  63. * Gets or sets {@link Color} property which determines the polyline's color.
  64. * @memberof PolylineOutlineMaterialProperty.prototype
  65. * @type {Property}
  66. * @default new ConstantProperty(Color.WHITE)
  67. */
  68. color : createPropertyDescriptor('color'),
  69. /**
  70. * Gets or sets the {@link Color} property which determines the polyline's outline color.
  71. * @memberof PolylineOutlineMaterialProperty.prototype
  72. * @type {Property}
  73. * @default new ConstantProperty(Color.BLACK)
  74. */
  75. outlineColor : createPropertyDescriptor('outlineColor'),
  76. /**
  77. * Gets or sets the numberic property which determines the polyline's outline width.
  78. * @memberof PolylineOutlineMaterialProperty.prototype
  79. * @type {Property}
  80. * @default new ConstantProperty(0)
  81. */
  82. outlineWidth : createPropertyDescriptor('outlineWidth')
  83. });
  84. /**
  85. * Gets the {@link Material} type at the provided time.
  86. *
  87. * @param {JulianDate} time The time for which to retrieve the type.
  88. * @returns {String} The type of material.
  89. */
  90. PolylineOutlineMaterialProperty.prototype.getType = function(time) {
  91. return 'PolylineOutline';
  92. };
  93. /**
  94. * Gets the value of the property at the provided time.
  95. *
  96. * @param {JulianDate} time The time for which to retrieve the value.
  97. * @param {Object} [result] The object to store the value into, if omitted, a new instance is created and returned.
  98. * @returns {Object} The modified result parameter or a new instance if the result parameter was not supplied.
  99. */
  100. PolylineOutlineMaterialProperty.prototype.getValue = function(time, result) {
  101. if (!defined(result)) {
  102. result = {};
  103. }
  104. result.color = Property.getValueOrClonedDefault(this._color, time, defaultColor, result.color);
  105. result.outlineColor = Property.getValueOrClonedDefault(this._outlineColor, time, defaultOutlineColor, result.outlineColor);
  106. result.outlineWidth = Property.getValueOrDefault(this._outlineWidth, time, defaultOutlineWidth);
  107. return result;
  108. };
  109. /**
  110. * Compares this property to the provided property and returns
  111. * <code>true</code> if they are equal, <code>false</code> otherwise.
  112. *
  113. * @param {Property} [other] The other property.
  114. * @returns {Boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
  115. */
  116. PolylineOutlineMaterialProperty.prototype.equals = function(other) {
  117. return this === other || //
  118. (other instanceof PolylineOutlineMaterialProperty && //
  119. Property.equals(this._color, other._color) && //
  120. Property.equals(this._outlineColor, other._outlineColor) && //
  121. Property.equals(this._outlineWidth, other._outlineWidth));
  122. };
  123. return PolylineOutlineMaterialProperty;
  124. });