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

BufferPolylineMaterial.js 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // @ts-check
  2. import Frozen from "../Core/Frozen.js";
  3. import BufferPrimitiveMaterial from "./BufferPrimitiveMaterial.js";
  4. /** @import Color from "../Core/Color.js"; */
  5. /** @import BufferPolyline from "./BufferPolyline.js"; */
  6. /**
  7. * @typedef {object} BufferPolylineMaterialOptions
  8. * @property {Color} [color=Color.WHITE] Color of fill.
  9. * @property {Color} [outlineColor=Color.WHITE] Color of outline.
  10. * @property {number} [outlineWidth=0.0] Width of outline, 0-255px.
  11. * @property {number} [width=1.0] Width of line, 0-255px.
  12. */
  13. /**
  14. * Material description for a {@link BufferPolyline}.
  15. *
  16. * <p>BufferPolylineMaterial objects are {@link Packable|packable}, stored
  17. * when calling {@link BufferPolyline#setMaterial}. Subsequent changes to the
  18. * material will not affect the polyline until setMaterial() is called again.</p>
  19. *
  20. * @experimental This feature is not final and is subject to change without Cesium's standard deprecation policy.
  21. * @extends BufferPrimitiveMaterial
  22. */
  23. class BufferPolylineMaterial extends BufferPrimitiveMaterial {
  24. /** @ignore */
  25. static Layout = {
  26. ...BufferPrimitiveMaterial.Layout,
  27. WIDTH_U8: BufferPrimitiveMaterial.Layout.__BYTE_LENGTH,
  28. __BYTE_LENGTH: BufferPrimitiveMaterial.Layout.__BYTE_LENGTH + 4,
  29. };
  30. /**
  31. * @type {BufferPolylineMaterial}
  32. * @ignore
  33. */
  34. static DEFAULT_MATERIAL = Object.freeze(new BufferPolylineMaterial());
  35. /**
  36. * @param {BufferPolylineMaterialOptions} [options]
  37. */
  38. constructor(options = Frozen.EMPTY_OBJECT) {
  39. super(options);
  40. /**
  41. * Width of polyline, 0–255px.
  42. * @type {number}
  43. */
  44. this.width = options.width ?? 1;
  45. }
  46. /**
  47. * @param {BufferPolylineMaterial} material
  48. * @param {DataView} view
  49. * @param {number} byteOffset
  50. * @override
  51. */
  52. static pack(material, view, byteOffset) {
  53. super.pack(material, view, byteOffset);
  54. view.setUint8(this.Layout.WIDTH_U8 + byteOffset, material.width);
  55. }
  56. /**
  57. * @param {DataView} view
  58. * @param {number} byteOffset
  59. * @param {BufferPolylineMaterial} result
  60. * @returns {BufferPolylineMaterial}
  61. * @override
  62. */
  63. static unpack(view, byteOffset, result) {
  64. super.unpack(view, byteOffset, result);
  65. result.width = view.getUint8(this.Layout.WIDTH_U8 + byteOffset);
  66. return result;
  67. }
  68. /////////////////////////////////////////////////////////////////////////////
  69. // DEBUG
  70. /**
  71. * Returns a JSON-serializable object representing the material. This encoding
  72. * is not memory-efficient, and should generally be used for debugging and
  73. * testing.
  74. *
  75. * @returns {Object} JSON-serializable object.
  76. */
  77. toJSON() {
  78. return { ...super.toJSON(), width: this.width };
  79. }
  80. }
  81. export default BufferPolylineMaterial;