PolylineGlowMaterialProperty.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 defaultGlowPower = 0.25;
  19. /**
  20. * A {@link MaterialProperty} that maps to polyline glow {@link Material} uniforms.
  21. * @alias PolylineGlowProperty
  22. * @constructor
  23. */
  24. var PolylineGlowProperty = function() {
  25. this._definitionChanged = new Event();
  26. this._color = undefined;
  27. this._colorSubscription = undefined;
  28. this._glowPower = undefined;
  29. this._glowPowerSubscription = undefined;
  30. };
  31. defineProperties(PolylineGlowProperty.prototype, {
  32. /**
  33. * Gets a value indicating if this property is constant. A property is considered
  34. * constant if getValue always returns the same result for the current definition.
  35. * @memberof PolylineGlowProperty.prototype
  36. * @type {Boolean}
  37. * @readonly
  38. */
  39. isConstant : {
  40. get : function() {
  41. return Property.isConstant(this._color) && Property.isConstant(this._glow);
  42. }
  43. },
  44. /**
  45. * Gets the event that is raised whenever the definition of this property changes.
  46. * The definition is considered to have changed if a call to getValue would return
  47. * a different result for the same time.
  48. * @memberof PolylineGlowProperty.prototype
  49. * @type {Event}
  50. * @readonly
  51. */
  52. definitionChanged : {
  53. get : function() {
  54. return this._definitionChanged;
  55. }
  56. },
  57. /**
  58. * A {@link Color} {@link Property} which determines the line's color.
  59. * @memberof PolylineGlowProperty.prototype
  60. * @type {Property}
  61. */
  62. color : createPropertyDescriptor('color'),
  63. /**
  64. * A numeric {@link Property} which determines the strength of the glow, as a percentage of the total line width (less than 1.0).
  65. * @memberof PolylineGlowProperty.prototype
  66. * @type {Property}
  67. */
  68. glowPower : createPropertyDescriptor('glowPower')
  69. });
  70. /**
  71. * Gets the {@link Material} type at the provided time.
  72. *
  73. * @param {JulianDate} time The time for which to retrieve the type.
  74. * @returns {String} The type of material.
  75. */
  76. PolylineGlowProperty.prototype.getType = function(time) {
  77. return 'PolylineGlow';
  78. };
  79. /**
  80. * Gets the value of the property at the provided time.
  81. *
  82. * @param {JulianDate} time The time for which to retrieve the value.
  83. * @param {Object} [result] The object to store the value into, if omitted, a new instance is created and returned.
  84. * @returns {Object} The modified result parameter or a new instance if the result parameter was not supplied.
  85. */
  86. PolylineGlowProperty.prototype.getValue = function(time, result) {
  87. if (!defined(result)) {
  88. result = {};
  89. }
  90. result.color = Property.getValueOrClonedDefault(this._color, time, defaultColor, result.color);
  91. result.glowPower = Property.getValueOrDefault(this._glowPower, time, defaultGlowPower, result.glowPower);
  92. return result;
  93. };
  94. /**
  95. * Compares this property to the provided property and returns
  96. * <code>true</code> if they are equal, <code>false</code> otherwise.
  97. *
  98. * @param {Property} [other] The other property.
  99. * @returns {Boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
  100. */
  101. PolylineGlowProperty.prototype.equals = function(other) {
  102. return this === other || //
  103. (other instanceof PolylineGlowProperty && //
  104. Property.equals(this._color, other._color) &&
  105. Property.equals(this._glowPower, other._glowPower));
  106. };
  107. return PolylineGlowProperty;
  108. });