PolylineArrowMaterialProperty.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import Color from "../Core/Color.js";
  2. import defined from "../Core/defined.js";
  3. import Event from "../Core/Event.js";
  4. import createPropertyDescriptor from "./createPropertyDescriptor.js";
  5. import Property from "./Property.js";
  6. /**
  7. * A {@link MaterialProperty} that maps to PolylineArrow {@link Material} uniforms.
  8. *
  9. * @param {Property|Color} [color=Color.WHITE] The {@link Color} Property to be used.
  10. *
  11. * @alias PolylineArrowMaterialProperty
  12. * @constructor
  13. */
  14. function PolylineArrowMaterialProperty(color) {
  15. this._definitionChanged = new Event();
  16. this._color = undefined;
  17. this._colorSubscription = undefined;
  18. this.color = color;
  19. }
  20. Object.defineProperties(PolylineArrowMaterialProperty.prototype, {
  21. /**
  22. * Gets a value indicating if this property is constant. A property is considered
  23. * constant if getValue always returns the same result for the current definition.
  24. * @memberof PolylineArrowMaterialProperty.prototype
  25. *
  26. * @type {boolean}
  27. * @readonly
  28. */
  29. isConstant: {
  30. get: function () {
  31. return Property.isConstant(this._color);
  32. },
  33. },
  34. /**
  35. * Gets the event that is raised whenever the definition of this property changes.
  36. * The definition is considered to have changed if a call to getValue would return
  37. * a different result for the same time.
  38. * @memberof PolylineArrowMaterialProperty.prototype
  39. *
  40. * @type {Event}
  41. * @readonly
  42. */
  43. definitionChanged: {
  44. get: function () {
  45. return this._definitionChanged;
  46. },
  47. },
  48. /**
  49. * Gets or sets the {@link Color} {@link Property}.
  50. * @memberof PolylineArrowMaterialProperty.prototype
  51. * @type {Property|undefined}
  52. * @default Color.WHITE
  53. */
  54. color: createPropertyDescriptor("color"),
  55. });
  56. /**
  57. * Gets the {@link Material} type at the provided time.
  58. *
  59. * @param {JulianDate} time The time for which to retrieve the type.
  60. * @returns {string} The type of material.
  61. */
  62. PolylineArrowMaterialProperty.prototype.getType = function (time) {
  63. return "PolylineArrow";
  64. };
  65. /**
  66. * Gets the value of the property at the provided time.
  67. *
  68. * @param {JulianDate} time The time for which to retrieve the value.
  69. * @param {object} [result] The object to store the value into, if omitted, a new instance is created and returned.
  70. * @returns {object} The modified result parameter or a new instance if the result parameter was not supplied.
  71. */
  72. PolylineArrowMaterialProperty.prototype.getValue = function (time, result) {
  73. if (!defined(result)) {
  74. result = {};
  75. }
  76. result.color = Property.getValueOrClonedDefault(
  77. this._color,
  78. time,
  79. Color.WHITE,
  80. result.color
  81. );
  82. return result;
  83. };
  84. /**
  85. * Compares this property to the provided property and returns
  86. * <code>true</code> if they are equal, <code>false</code> otherwise.
  87. *
  88. * @param {Property} [other] The other property.
  89. * @returns {boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
  90. */
  91. PolylineArrowMaterialProperty.prototype.equals = function (other) {
  92. return (
  93. this === other || //
  94. (other instanceof PolylineArrowMaterialProperty && //
  95. Property.equals(this._color, other._color))
  96. );
  97. };
  98. export default PolylineArrowMaterialProperty;