You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

WaterMaterialProperty.js 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /**
  2. * @Author: Caven
  3. * @Date: 2020-02-25 21:16:00
  4. */
  5. import { Cesium } from '@dc-modules/namespace'
  6. class WaterMaterialProperty {
  7. constructor(options) {
  8. options = options || {}
  9. this._definitionChanged = new Cesium.Event()
  10. this._baseWaterColor = undefined
  11. this._baseWaterColorSubscription = undefined
  12. this.baseWaterColor =
  13. options.baseWaterColor || new Cesium.Color(0.2, 0.3, 0.6, 1.0)
  14. this._blendColor = undefined
  15. this._blendColorSubscription = undefined
  16. this.blendColor =
  17. options.blendColor || new Cesium.Color(0.0, 1.0, 0.699, 1.0)
  18. this._specularMap = undefined
  19. this._specularMapSubscription = undefined
  20. this.specularMap = options.specularMap || Cesium.Material.DefaultImageId
  21. this._normalMap = undefined
  22. this._normalMapSubscription = undefined
  23. this.normalMap = options.normalMap || Cesium.Material.DefaultImageId
  24. this.frequency = Cesium.defaultValue(options.frequency, 1000)
  25. this.animationSpeed = Cesium.defaultValue(options.animationSpeed, 0.01)
  26. this.amplitude = Cesium.defaultValue(options.amplitude, 10.0)
  27. this.specularIntensity = Cesium.defaultValue(options.specularIntensity, 0.5)
  28. }
  29. get isConstant() {
  30. return false
  31. }
  32. get definitionChanged() {
  33. return this._definitionChanged
  34. }
  35. getType(time) {
  36. return Cesium.Material.WaterType
  37. }
  38. getValue(time, result) {
  39. if (!result) {
  40. result = {}
  41. }
  42. result.baseWaterColor = Cesium.Property.getValueOrUndefined(
  43. this._baseWaterColor,
  44. time
  45. )
  46. result.blendColor = Cesium.Property.getValueOrUndefined(
  47. this._blendColor,
  48. time
  49. )
  50. result.specularMap = Cesium.Property.getValueOrUndefined(
  51. this._specularMap,
  52. time
  53. )
  54. result.normalMap = Cesium.Property.getValueOrUndefined(
  55. this._normalMap,
  56. time
  57. )
  58. result.frequency = this.frequency
  59. result.animationSpeed = this.animationSpeed
  60. result.amplitude = this.amplitude
  61. result.specularIntensity = this.specularIntensity
  62. return result
  63. }
  64. equals(other) {
  65. return (
  66. this === other ||
  67. (other instanceof WaterMaterialProperty &&
  68. Cesium.Property.equals(this._baseWaterColor, other._baseWaterColor))
  69. )
  70. }
  71. }
  72. Object.defineProperties(WaterMaterialProperty.prototype, {
  73. baseWaterColor: Cesium.createPropertyDescriptor('baseWaterColor'),
  74. blendColor: Cesium.createPropertyDescriptor('blendColor'),
  75. specularMap: Cesium.createPropertyDescriptor('specularMap'),
  76. normalMap: Cesium.createPropertyDescriptor('normalMap')
  77. })
  78. export default WaterMaterialProperty