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

PointGraphics.js 8.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. import Frozen from "../Core/Frozen.js";
  2. import defined from "../Core/defined.js";
  3. import DeveloperError from "../Core/DeveloperError.js";
  4. import Event from "../Core/Event.js";
  5. import createPropertyDescriptor from "./createPropertyDescriptor.js";
  6. /**
  7. * @typedef {object} PointGraphics.ConstructorOptions
  8. *
  9. * Initialization options for the PointGraphics constructor
  10. *
  11. * @property {Property | boolean} [show=true] A boolean Property specifying the visibility of the point.
  12. * @property {Property | number} [pixelSize=1] A numeric Property specifying the size in pixels.
  13. * @property {Property | HeightReference} [heightReference=HeightReference.NONE] A Property specifying what the height is relative to.
  14. * @property {Property | Color} [color=Color.WHITE] A Property specifying the {@link Color} of the point.
  15. * @property {Property | Color} [outlineColor=Color.BLACK] A Property specifying the {@link Color} of the outline.
  16. * @property {Property | number} [outlineWidth=0] A numeric Property specifying the the outline width in pixels.
  17. * @property {Property | NearFarScalar} [scaleByDistance] A {@link NearFarScalar} Property used to scale the point based on distance.
  18. * @property {Property | NearFarScalar} [translucencyByDistance] A {@link NearFarScalar} Property used to set translucency based on distance from the camera.
  19. * @property {Property | DistanceDisplayCondition} [distanceDisplayCondition] A Property specifying at what distance from the camera that this point will be displayed.
  20. * @property {Property | number} [disableDepthTestDistance] A Property specifying the distance from the camera at which to disable the depth test to.
  21. * @property {Property | SplitDirection} [splitDirection] A Property specifying the {@link SplitDirection} split to apply to this point.
  22. */
  23. /**
  24. * Describes a graphical point located at the position of the containing {@link Entity}.
  25. *
  26. * @alias PointGraphics
  27. * @constructor
  28. *
  29. * @param {PointGraphics.ConstructorOptions} [options] Object describing initialization options
  30. */
  31. function PointGraphics(options) {
  32. this._definitionChanged = new Event();
  33. this._show = undefined;
  34. this._showSubscription = undefined;
  35. this._pixelSize = undefined;
  36. this._pixelSizeSubscription = undefined;
  37. this._heightReference = undefined;
  38. this._heightReferenceSubscription = undefined;
  39. this._color = undefined;
  40. this._colorSubscription = undefined;
  41. this._outlineColor = undefined;
  42. this._outlineColorSubscription = undefined;
  43. this._outlineWidth = undefined;
  44. this._outlineWidthSubscription = undefined;
  45. this._scaleByDistance = undefined;
  46. this._scaleByDistanceSubscription = undefined;
  47. this._translucencyByDistance = undefined;
  48. this._translucencyByDistanceSubscription = undefined;
  49. this._distanceDisplayCondition = undefined;
  50. this._distanceDisplayConditionSubscription = undefined;
  51. this._disableDepthTestDistance = undefined;
  52. this._disableDepthTestDistanceSubscription = undefined;
  53. this._splitDirection = undefined;
  54. this._splitDirectionSubscription = undefined;
  55. this.merge(options ?? Frozen.EMPTY_OBJECT);
  56. }
  57. Object.defineProperties(PointGraphics.prototype, {
  58. /**
  59. * Gets the event that is raised whenever a property or sub-property is changed or modified.
  60. * @memberof PointGraphics.prototype
  61. *
  62. * @type {Event}
  63. * @readonly
  64. */
  65. definitionChanged: {
  66. get: function () {
  67. return this._definitionChanged;
  68. },
  69. },
  70. /**
  71. * Gets or sets the boolean Property specifying the visibility of the point.
  72. * @memberof PointGraphics.prototype
  73. * @type {Property|undefined}
  74. * @default true
  75. */
  76. show: createPropertyDescriptor("show"),
  77. /**
  78. * Gets or sets the numeric Property specifying the size in pixels.
  79. * @memberof PointGraphics.prototype
  80. * @type {Property|undefined}
  81. * @default 1
  82. */
  83. pixelSize: createPropertyDescriptor("pixelSize"),
  84. /**
  85. * Gets or sets the Property specifying the {@link HeightReference}.
  86. * @memberof PointGraphics.prototype
  87. * @type {Property|undefined}
  88. * @default HeightReference.NONE
  89. */
  90. heightReference: createPropertyDescriptor("heightReference"),
  91. /**
  92. * Gets or sets the Property specifying the {@link Color} of the point.
  93. * @memberof PointGraphics.prototype
  94. * @type {Property|undefined}
  95. * @default Color.WHITE
  96. */
  97. color: createPropertyDescriptor("color"),
  98. /**
  99. * Gets or sets the Property specifying the {@link Color} of the outline.
  100. * @memberof PointGraphics.prototype
  101. * @type {Property|undefined}
  102. * @default Color.BLACK
  103. */
  104. outlineColor: createPropertyDescriptor("outlineColor"),
  105. /**
  106. * Gets or sets the numeric Property specifying the the outline width in pixels.
  107. * @memberof PointGraphics.prototype
  108. * @type {Property|undefined}
  109. * @default 0
  110. */
  111. outlineWidth: createPropertyDescriptor("outlineWidth"),
  112. /**
  113. * Gets or sets the {@link NearFarScalar} Property used to scale the point based on distance.
  114. * If undefined, a constant size is used.
  115. * @memberof PointGraphics.prototype
  116. * @type {Property|undefined}
  117. */
  118. scaleByDistance: createPropertyDescriptor("scaleByDistance"),
  119. /**
  120. * Gets or sets {@link NearFarScalar} Property specifying the translucency of the point based on the distance from the camera.
  121. * A point's translucency will interpolate between the {@link NearFarScalar#nearValue} and
  122. * {@link NearFarScalar#farValue} while the camera distance falls within the lower and upper bounds
  123. * of the specified {@link NearFarScalar#near} and {@link NearFarScalar#far}.
  124. * Outside of these ranges the points's translucency remains clamped to the nearest bound.
  125. * @memberof PointGraphics.prototype
  126. * @type {Property|undefined}
  127. */
  128. translucencyByDistance: createPropertyDescriptor("translucencyByDistance"),
  129. /**
  130. * Gets or sets the {@link DistanceDisplayCondition} Property specifying at what distance from the camera that this point will be displayed.
  131. * @memberof PointGraphics.prototype
  132. * @type {Property|undefined}
  133. */
  134. distanceDisplayCondition: createPropertyDescriptor(
  135. "distanceDisplayCondition",
  136. ),
  137. /**
  138. * Gets or sets the distance from the camera at which to disable the depth test to, for example, prevent clipping against terrain.
  139. * When set to zero, the depth test is always applied. When set to Number.POSITIVE_INFINITY, the depth test is never applied.
  140. * @memberof PointGraphics.prototype
  141. * @type {Property|undefined}
  142. */
  143. disableDepthTestDistance: createPropertyDescriptor(
  144. "disableDepthTestDistance",
  145. ),
  146. /**
  147. * Gets or sets the Property specifying the {@link SplitDirection} of this point.
  148. * @memberof PointGraphics.prototype
  149. * @type {Property|undefined}
  150. * @default SplitDirection.NONE
  151. */
  152. splitDirection: createPropertyDescriptor("splitDirection"),
  153. });
  154. /**
  155. * Duplicates this instance.
  156. *
  157. * @param {PointGraphics} [result] The object onto which to store the result.
  158. * @returns {PointGraphics} The modified result parameter or a new instance if one was not provided.
  159. */
  160. PointGraphics.prototype.clone = function (result) {
  161. if (!defined(result)) {
  162. return new PointGraphics(this);
  163. }
  164. result.show = this.show;
  165. result.pixelSize = this.pixelSize;
  166. result.heightReference = this.heightReference;
  167. result.color = this.color;
  168. result.outlineColor = this.outlineColor;
  169. result.outlineWidth = this.outlineWidth;
  170. result.scaleByDistance = this.scaleByDistance;
  171. result.translucencyByDistance = this._translucencyByDistance;
  172. result.distanceDisplayCondition = this.distanceDisplayCondition;
  173. result.disableDepthTestDistance = this.disableDepthTestDistance;
  174. result.splitDirection = this.splitDirection;
  175. return result;
  176. };
  177. /**
  178. * Assigns each unassigned property on this object to the value
  179. * of the same property on the provided source object.
  180. *
  181. * @param {PointGraphics} source The object to be merged into this object.
  182. */
  183. PointGraphics.prototype.merge = function (source) {
  184. //>>includeStart('debug', pragmas.debug);
  185. if (!defined(source)) {
  186. throw new DeveloperError("source is required.");
  187. }
  188. //>>includeEnd('debug');
  189. this.show = this.show ?? source.show;
  190. this.pixelSize = this.pixelSize ?? source.pixelSize;
  191. this.heightReference = this.heightReference ?? source.heightReference;
  192. this.color = this.color ?? source.color;
  193. this.outlineColor = this.outlineColor ?? source.outlineColor;
  194. this.outlineWidth = this.outlineWidth ?? source.outlineWidth;
  195. this.scaleByDistance = this.scaleByDistance ?? source.scaleByDistance;
  196. this.translucencyByDistance =
  197. this._translucencyByDistance ?? source.translucencyByDistance;
  198. this.distanceDisplayCondition =
  199. this.distanceDisplayCondition ?? source.distanceDisplayCondition;
  200. this.disableDepthTestDistance =
  201. this.disableDepthTestDistance ?? source.disableDepthTestDistance;
  202. this.splitDirection = this.splitDirection ?? source.splitDirection;
  203. };
  204. export default PointGraphics;