智慧水务管理系统 - 精河县供水工程综合管理平台

PolylineArrowMaterialProperty.js 3.3KB

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