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

BufferPointMaterial.js 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 BufferPoint from "./BufferPoint.js"; */
  6. /**
  7. * @typedef {object} BufferPointMaterialOptions
  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} [size=1.0] Size of point, 0-255px.
  12. */
  13. /**
  14. * Material description for a {@link BufferPoint}.
  15. *
  16. * <p>BufferPointMaterial objects are {@link Packable|packable}, stored
  17. * when calling {@link BufferPoint#setMaterial}. Subsequent changes to the
  18. * material will not affect the point 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 BufferPointMaterial extends BufferPrimitiveMaterial {
  24. /** @ignore */
  25. static Layout = {
  26. ...BufferPrimitiveMaterial.Layout,
  27. SIZE_U8: BufferPrimitiveMaterial.Layout.__BYTE_LENGTH,
  28. __BYTE_LENGTH: BufferPrimitiveMaterial.Layout.__BYTE_LENGTH + 4,
  29. };
  30. /**
  31. * @type {BufferPointMaterial}
  32. * @ignore
  33. */
  34. static DEFAULT_MATERIAL = Object.freeze(new BufferPointMaterial());
  35. /**
  36. * @param {BufferPointMaterialOptions} [options]
  37. */
  38. constructor(options = Frozen.EMPTY_OBJECT) {
  39. super(options);
  40. /**
  41. * Size of point, 0-255px.
  42. * @type {number}
  43. */
  44. this.size = options.size ?? 1;
  45. }
  46. /**
  47. * @override
  48. * @param {BufferPointMaterial} material
  49. * @param {DataView} view
  50. * @param {number} byteOffset
  51. * @override
  52. */
  53. static pack(material, view, byteOffset) {
  54. super.pack(material, view, byteOffset);
  55. view.setUint8(this.Layout.SIZE_U8 + byteOffset, material.size);
  56. }
  57. /**
  58. * @override
  59. * @param {DataView} view
  60. * @param {number} byteOffset
  61. * @param {BufferPointMaterial} result
  62. * @returns {BufferPointMaterial}
  63. * @override
  64. */
  65. static unpack(view, byteOffset, result) {
  66. super.unpack(view, byteOffset, result);
  67. result.size = view.getUint8(this.Layout.SIZE_U8 + byteOffset);
  68. return result;
  69. }
  70. /////////////////////////////////////////////////////////////////////////////
  71. // DEBUG
  72. /**
  73. * Returns a JSON-serializable object representing the material. This encoding
  74. * is not memory-efficient, and should generally be used for debugging and
  75. * testing.
  76. *
  77. * @returns {Object} JSON-serializable object.
  78. */
  79. toJSON() {
  80. return { ...super.toJSON(), size: this.size };
  81. }
  82. }
  83. export default BufferPointMaterial;