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

PointCloudShading.js 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import PointCloudEyeDomeLighting from "./PointCloudEyeDomeLighting.js";
  2. /**
  3. * Options for performing point attenuation based on geometric error when rendering
  4. * point clouds using 3D Tiles.
  5. *
  6. * @param {object} [options] Object with the following properties:
  7. * @param {boolean} [options.attenuation=false] Perform point attenuation based on geometric error.
  8. * @param {number} [options.geometricErrorScale=1.0] Scale to be applied to each tile's geometric error.
  9. * @param {number} [options.maximumAttenuation] Maximum attenuation in pixels. Defaults to the Cesium3DTileset's maximumScreenSpaceError.
  10. * @param {number} [options.baseResolution] Average base resolution for the dataset in meters. Substitute for Geometric Error when not available.
  11. * @param {boolean} [options.eyeDomeLighting=true] When true, use eye dome lighting when drawing with point attenuation.
  12. * @param {number} [options.eyeDomeLightingStrength=1.0] Increasing this value increases contrast on slopes and edges.
  13. * @param {number} [options.eyeDomeLightingRadius=1.0] Increase the thickness of contours from eye dome lighting.
  14. * @param {boolean} [options.backFaceCulling=false] Determines whether back-facing points are hidden. This option works only if data has normals included.
  15. * @param {boolean} [options.normalShading=true] Determines whether a point cloud that contains normals is shaded by the scene's light source.
  16. *
  17. * @alias PointCloudShading
  18. * @constructor
  19. */
  20. function PointCloudShading(options) {
  21. const pointCloudShading = options ?? {};
  22. /**
  23. * Perform point attenuation based on geometric error.
  24. * @type {boolean}
  25. * @default false
  26. */
  27. this.attenuation = pointCloudShading.attenuation ?? false;
  28. /**
  29. * Scale to be applied to the geometric error before computing attenuation.
  30. * @type {number}
  31. * @default 1.0
  32. */
  33. this.geometricErrorScale = pointCloudShading.geometricErrorScale ?? 1.0;
  34. /**
  35. * Maximum point attenuation in pixels. If undefined, the Cesium3DTileset's maximumScreenSpaceError will be used.
  36. * @type {number}
  37. */
  38. this.maximumAttenuation = pointCloudShading.maximumAttenuation;
  39. /**
  40. * Average base resolution for the dataset in meters.
  41. * Used in place of geometric error when geometric error is 0.
  42. * If undefined, an approximation will be computed for each tile that has geometric error of 0.
  43. * @type {number}
  44. */
  45. this.baseResolution = pointCloudShading.baseResolution;
  46. /**
  47. * Use eye dome lighting when drawing with point attenuation
  48. * Requires support for EXT_frag_depth, OES_texture_float, and WEBGL_draw_buffers extensions in WebGL 1.0,
  49. * otherwise eye dome lighting is ignored.
  50. *
  51. * @type {boolean}
  52. * @default true
  53. */
  54. this.eyeDomeLighting = pointCloudShading.eyeDomeLighting ?? true;
  55. /**
  56. * Eye dome lighting strength (apparent contrast)
  57. * @type {number}
  58. * @default 1.0
  59. */
  60. this.eyeDomeLightingStrength =
  61. pointCloudShading.eyeDomeLightingStrength ?? 1.0;
  62. /**
  63. * Thickness of contours from eye dome lighting
  64. * @type {number}
  65. * @default 1.0
  66. */
  67. this.eyeDomeLightingRadius = pointCloudShading.eyeDomeLightingRadius ?? 1.0;
  68. /**
  69. * Determines whether back-facing points are hidden.
  70. * This option works only if data has normals included.
  71. *
  72. * @type {boolean}
  73. * @default false
  74. */
  75. this.backFaceCulling = pointCloudShading.backFaceCulling ?? false;
  76. /**
  77. * Determines whether a point cloud that contains normals is shaded by the scene's light source.
  78. *
  79. * @type {boolean}
  80. * @default true
  81. */
  82. this.normalShading = pointCloudShading.normalShading ?? true;
  83. }
  84. /**
  85. * Determines if point cloud shading is supported.
  86. *
  87. * @param {Scene} scene The scene.
  88. * @returns {boolean} <code>true</code> if point cloud shading is supported; otherwise, returns <code>false</code>
  89. */
  90. PointCloudShading.isSupported = function (scene) {
  91. return PointCloudEyeDomeLighting.isSupported(scene.context);
  92. };
  93. export default PointCloudShading;