deeptwins-engine-3d 0.1.65 → 0.1.66

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/esm/constant.d.ts +1 -0
  2. package/dist/esm/drawCommand/viewShed/RectangularSensorPrimitive.d.ts +1 -0
  3. package/dist/esm/drawCommand/viewShed/ViewShedAnalyserLayer.d.ts +1 -0
  4. package/dist/esm/drawer/common.d.ts +1 -0
  5. package/dist/esm/drawer/coordinate.d.ts +1 -0
  6. package/dist/esm/drawer/index.d.ts +1 -1
  7. package/dist/esm/drawer/shape/BaseShape.d.ts +1 -0
  8. package/dist/esm/graphicLayer/BaseSource.d.ts +1 -1
  9. package/dist/esm/index.d.ts +2 -0
  10. package/dist/esm/index.js +6 -2
  11. package/dist/esm/map/Map.d.ts +9 -0
  12. package/dist/esm/map/Map.js +115 -2
  13. package/dist/esm/material/AtmosphericDispersion.d.ts +71 -0
  14. package/dist/esm/material/AtmosphericDispersion.js +485 -33
  15. package/dist/esm/material/GlobalVolumetricCloud.d.ts +117 -0
  16. package/dist/esm/material/GlobalVolumetricCloud.js +219 -223
  17. package/dist/esm/material/entity/ImageMaterialProperty.d.ts +1 -0
  18. package/dist/esm/material/shader/AtmosphericShader.glsl +244 -0
  19. package/dist/esm/measure/BaseDraw.d.ts +1 -0
  20. package/dist/esm/measure/types.d.ts +1 -0
  21. package/dist/esm/measure/utils.d.ts +1 -0
  22. package/dist/esm/sceneFusion/Airway.d.ts +0 -0
  23. package/dist/esm/sceneFusion/Airway.js +692 -0
  24. package/dist/esm/tileLayer/ArcGisLayer.d.ts +1 -0
  25. package/dist/esm/tileLayer/ImageryLayer.d.ts +1 -0
  26. package/dist/esm/tileLayer/MvtVectorLoad.d.ts +1 -0
  27. package/dist/esm/tool/common.d.ts +1 -0
  28. package/dist/esm/tool/utils.d.ts +1 -0
  29. package/dist/esm/typings.d.ts +8 -0
  30. package/dist/esm/visualization/BaseHeatmap.d.ts +5 -0
  31. package/dist/esm/visualization/BaseHeatmap.js +54 -12
  32. package/dist/esm/visualization/Heatmap2d.d.ts +1 -0
  33. package/dist/esm/visualization/Heatmap2d.js +17 -26
  34. package/dist/esm/visualization/Heatmap3d.d.ts +8 -2
  35. package/dist/esm/visualization/Heatmap3d.js +195 -59
  36. package/dist/umd/deeptwins-engine-3d.min.js +1 -1
  37. package/package.json +1 -1
@@ -1,39 +1,166 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1
7
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2
8
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
9
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
5
10
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
11
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
7
12
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
13
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
14
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
9
15
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
- var AtmosphericDispersion = /*#__PURE__*/function () {
11
- function AtmosphericDispersion(viewer) {
16
+ import * as Cesium from 'deeptwins-cesium';
17
+ /* babel-plugin-inline-import './shader/AtmosphericShader.glsl' */
18
+ var AtmosphericShader = "precision highp float;\nuniform sampler2D colorTexture;\nuniform sampler2D depthTexture;\nuniform float u_threshold;\nuniform float u_blendFactor;\nuniform float u_lightIntensity;\nuniform float u_scatterStrength;\nuniform float u_tonemapExposure;\nuniform float u_mieExtinctionStrength;\nuniform float u_fogOpacity;\nuniform float u_fogPower;\nuniform float u_clearMixBias;\nin vec2 v_textureCoordinates;\nconst float PI = 3.14159265359;\nconst float TWO_PI = PI * 2.0;\nconst float FOUR_PI = PI * 4.0;\nconst float SCATTER_VISIBILITY_SCALE = 30000.0;\nconst float MAX_EXPOSURE_RESPONSE = 1.8;\nconst float MAX_LIGHT_RESPONSE = 3.0;\n\nconst vec3 betaR = vec3(5.5e-6, 13.0e-6, 22.4e-6);\n\nconst vec3 betaM = vec3(21e-6);\n\nconst float hR = 10e3;\nconst float hM = 3.8e3;\nconst int num_samples = 16;\nconst int num_samples_light = 4;\n#ifdef GL_ES\n #define _in(T) const in T\n #define _inout(T) inout T\n #define _out(T) out T\n #define _begin(type) type (\n #define _end )\n #define mul(a, b) (a) * (b)\n #endif\n\nstruct ray_t {\n vec3 origin;\n vec3 direction;\n};\nstruct sphere_t {\n vec3 origin;\n float radius;\n int material;\n};\nstruct plane_t {\n vec3 direction;\n float distance;\n int material;\n};\nplane_t plane;\nmat3 rotate_around_x(_in(float) angle_degrees) {\n float angle = radians(angle_degrees);\n float _sin = sin(angle);\n float _cos = cos(angle);\n return mat3(1, 0, 0, 0, _cos, -_sin, 0, _sin, _cos);\n}\n\nbool isect_sphere(_in(ray_t) ray, _in(sphere_t) sphere, _inout(float) t0, _inout(float) t1) {\n vec3 rc = sphere.origin - ray.origin;\n float radius2 = sphere.radius * sphere.radius;\n float tca = dot(rc, ray.direction);\n float d2 = dot(rc, rc) - tca * tca;\n if (d2 > radius2) return false;\n float thc = sqrt(radius2 - d2);\n t0 = tca - thc;\n t1 = tca + thc;\n return true;\n}\nfloat rayleigh_phase_func(float mu) {\n return\n 3. * (1. + mu * mu)\n /\n (16. * PI);\n}\nconst float g = 0.76;\nfloat henyey_greenstein_phase_func(float mu) {\n return\n (1. - g * g)\n /\n ((4. * PI) * pow(1. + g * g - 2. * g * mu, 1.5));\n}\nconst float k = 1.55 * g - 0.55 * (g * g * g);\nfloat schlick_phase_func(float mu) {\n return\n (1. - k * k)\n /\n (4. * PI * (1. + k * mu) * (1. + k * mu));\n}\nconst sphere_t atmosphere = _begin(sphere_t)\nvec3(0, 0, 0), 6420e3, 0\n_end;\n\nbool get_sun_light(\n_in(ray_t) ray, _inout(float) optical_depthR, _inout(float) optical_depthM\n) {\n float t0, t1;\n isect_sphere(ray, atmosphere, t0, t1);\n float march_pos = 0.;\n float march_step = t1 / float(num_samples_light);\n for (int i = 0; i < num_samples_light; i++) {\n vec3 s = ray.origin +\n ray.direction * (march_pos + 0.5 * march_step);\n float height = length(s) - 6360e3;\n if (height < 0.)\n return false;\n optical_depthR += exp(-height / hR) * march_step;\n optical_depthM += exp(-height / hM) * march_step;\n march_pos += march_step;\n }\n return true;\n}\nvec4 get_incident_light(_in(ray_t) ray) {\n vec3 dir = ray.direction;\n vec3 start = ray.origin;\n float a = dot(dir, dir);\n float b = 2.0 * dot(dir, start);\n float radius2 = atmosphere.radius * atmosphere.radius;\n float c = dot(start, start) - radius2;\n float d = (b * b) - 4.0 * a * c;\n if (d < 0.0) return vec4(0.0);\n float squaredD = sqrt(d);\n vec2 ray_length = vec2(\n max((-b - squaredD) / (2.0 * a), 0.0), min((-b + squaredD) / (2.0 * a), plane.distance)\n );\n if (ray_length.x > ray_length.y) return vec4(0.0);\n float march_step = (ray_length.y - ray_length.x) / float(num_samples);\n float mu = dot(ray.direction, normalize(czm_sunPositionWC));\n float phaseR = rayleigh_phase_func(mu);\n float phaseM =\n #if 1\n henyey_greenstein_phase_func(mu);\n #else\n schlick_phase_func(mu);\n #endif\n\n float optical_depthR = 0.;\n float optical_depthM = 0.;\n vec3 sumR = vec3(0);\n vec3 sumM = vec3(0);\n float march_pos = 0.;\n for (int i = 0; i < num_samples; i++) {\n vec3 s = ray.origin +\n ray.direction * (march_pos + 0.5 * march_step);\n float height = length(s) - 6360e3;\n\n float hr = exp(-height / hR) * march_step;\n float hm = exp(-height / hM) * march_step;\n optical_depthR += hr;\n optical_depthM += hm;\n\n ray_t light_ray = _begin(ray_t)\n s, normalize(czm_sunPositionWC)\n _end;\n float optical_depth_lightR = 0.;\n float optical_depth_lightM = 0.;\n bool overground = get_sun_light(\n light_ray,\n optical_depth_lightR,\n optical_depth_lightM);\n\n if (overground) {\n\n vec3 tau =\n betaR * (optical_depthR + optical_depth_lightR) +\n betaM * u_mieExtinctionStrength * (optical_depthM + optical_depth_lightM);\n vec3 attenuation = exp(-tau);\n sumR += hr * attenuation;\n sumM += hm * attenuation;\n }\n\n march_pos += march_step;\n }\n vec3 transmittance = exp(-((betaM * optical_depthM * u_mieExtinctionStrength)\n + (betaR * optical_depthR)) * 4.);\n float attenuation = clamp(dot(transmittance, vec3(0.3333333)), 0.0, 1.0);\n\n return vec4(\n u_scatterStrength *\n (sumR * phaseR * betaR +\n sumM * phaseM * betaM), 1.0 - attenuation);\n}\n\nvoid main() {\n vec4 rawColor = texture(colorTexture, v_textureCoordinates);\n float depth = czm_unpackDepth(texture(depthTexture, v_textureCoordinates));\n\n vec4 positionEC = czm_windowToEyeCoordinates(gl_FragCoord.xy, depth);\n vec4 positionWC = czm_inverseView * positionEC;\n positionWC.xyz = positionWC.xyz / positionWC.w;\n\n vec3 lVector = positionWC.xyz - czm_viewerPositionWC;\n ray_t ray;\n ray.origin = czm_viewerPositionWC;\n ray.direction = normalize(lVector);\n plane.distance = length(lVector);\n\n vec4 atmosphereColor = get_incident_light(ray);\n float lightControl = clamp(u_lightIntensity / 4.0, 0.0, 1.0);\n float lightStrength = MAX_LIGHT_RESPONSE * (\n 1.0 - exp(-2.6 * pow(lightControl, 1.6))\n );\n vec3 scatterColor = atmosphereColor.rgb * lightStrength;\n float exposureControl = clamp(u_tonemapExposure / 3.0, 0.0, 1.0);\n float exposureStrength = pow(exposureControl, 1.25) * MAX_EXPOSURE_RESPONSE;\n float mieVisualFactor = mix(\n 0.6,\n 1.8,\n clamp(u_mieExtinctionStrength / 2.0, 0.0, 1.0)\n );\n vec3 visibleScatter = 1.0 - exp(\n -max(scatterColor * SCATTER_VISIBILITY_SCALE, 0.0) * exposureStrength\n );\n visibleScatter *= mieVisualFactor;\n float brightness = dot(visibleScatter, vec3(0.299, 0.587, 0.114));\n float thresholdMask = u_threshold > 0.0\n ? smoothstep(0.0, u_threshold, brightness)\n : 1.0;\n visibleScatter *= thresholdMask;\n float fogSignal = clamp(atmosphereColor.a * 2.5, 0.0, 1.0);\n float fogAlpha = clamp(\n pow(fogSignal, u_fogPower) * u_fogOpacity * mieVisualFactor,\n 0.0,\n 1.0\n );\n float clearPreserve = clamp(1.0 - u_clearMixBias, 0.0, 1.0);\n float fogMix = fogAlpha * clearPreserve * 0.85;\n vec3 foggedBase = mix(\n rawColor.rgb,\n rawColor.rgb * (1.0 - fogAlpha * 0.35),\n fogMix\n );\n vec3 overlayColor = visibleScatter *\n (0.55 + fogAlpha * 1.25) *\n mix(1.0, 0.6, u_clearMixBias);\n vec3 finalColor = mix(\n rawColor.rgb,\n foggedBase + overlayColor,\n u_blendFactor\n );\n\n out_FragColor = vec4(clamp(finalColor, 0.0, 1.0), rawColor.a);\n}\n";
19
+ var DEFAULT_PARAMS = {
20
+ u_threshold: 0.5,
21
+ u_blendFactor: 0.22,
22
+ u_lightIntensity: 0.9,
23
+ u_scatterStrength: 8,
24
+ u_tonemapExposure: 1,
25
+ u_mieExtinctionStrength: 0.65,
26
+ u_fogOpacity: 0.22,
27
+ u_fogPower: 1.9,
28
+ u_clearMixBias: 0.78
29
+ };
30
+ var DEFAULT_ZOOM_DAMPING_OPTIONS = {
31
+ enableZoomDamping: true,
32
+ dampingStartPitchDeg: -60,
33
+ dampingFullPitchDeg: -89.9,
34
+ minZoomScale: 0.12
35
+ };
36
+ var DEFAULT_CLOCK_TEXT = '12:00:00';
37
+ var MIN_ZOOM_FACTOR = 0.01;
38
+ var ZOOM_DAMPING_STATE_KEY = '__atmosphericDispersionZoomDampingState';
39
+ var CLOCK_CONTROL_STATE_KEY = '__atmosphericDispersionClockControlState';
40
+ var atmosphericDispersionInstanceSeed = 0;
41
+
42
+ // 大气散射
43
+ export var AtmosphericDispersion = /*#__PURE__*/function () {
44
+ function AtmosphericDispersion(map) {
12
45
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
13
46
  _classCallCheck(this, AtmosphericDispersion);
14
- this.viewer = viewer.viewer;
15
- if (!this.viewer || _typeof(this.viewer) !== 'object') {
47
+ // 地图上下文
48
+ _defineProperty(this, "_mapContext", void 0);
49
+ // 当前生效的参数
50
+ _defineProperty(this, "params", void 0);
51
+ // 构造时的原始参数
52
+ _defineProperty(this, "originalOptions", void 0);
53
+ // 后处理阶段实例
54
+ _defineProperty(this, "atmosphericDispersion", void 0);
55
+ // 极俯角缩放降速配置
56
+ _defineProperty(this, "zoomDampingOptions", void 0);
57
+ // 场景时间配置
58
+ _defineProperty(this, "clockOption", void 0);
59
+ // 相机变化监听
60
+ _defineProperty(this, "_cameraChangedHandler", void 0);
61
+ // 当前实例的缩放保护标识
62
+ _defineProperty(this, "_zoomDampingOwnerId", void 0);
63
+ // 当前实例的时间控制标识
64
+ _defineProperty(this, "_clockControlOwnerId", void 0);
65
+ this._mapContext = map._mapContext;
66
+ var viewer = this.getMap();
67
+ if (!viewer || _typeof(viewer) !== 'object') {
16
68
  throw new Error('Invalid Cesium Viewer instance provided');
17
69
  }
18
- if (!this.viewer.scene || !this.viewer.scene.postProcessStages) {
70
+ if (!viewer.scene || !viewer.scene.postProcessStages) {
19
71
  throw new Error('Viewer instance must have valid scene and postProcessStages');
20
72
  }
21
- this.params = {
22
- u_threshold: options.u_threshold !== undefined ? options.u_threshold : 1.1,
23
- u_blendFactor: options.u_blendFactor !== undefined ? options.u_blendFactor : 0.5,
24
- u_lightIntensity: options.u_lightIntensity !== undefined ? options.u_lightIntensity : 1.6
25
- };
73
+ this.params = this._buildParams(options);
74
+ this.zoomDampingOptions = this._buildZoomDampingOptions(options);
75
+ this.clockOption = this._buildClockOption(options);
26
76
  this.originalOptions = _objectSpread({}, options);
27
77
  this.atmosphericDispersion = null;
28
- this.initialize();
78
+ this._cameraChangedHandler = null;
79
+ atmosphericDispersionInstanceSeed += 1;
80
+ var ownerId = "atmospheric-dispersion-".concat(atmosphericDispersionInstanceSeed);
81
+ this._zoomDampingOwnerId = ownerId;
82
+ this._clockControlOwnerId = ownerId;
83
+ this._initialize();
29
84
  }
85
+
86
+ // 获取地图实例
30
87
  _createClass(AtmosphericDispersion, [{
31
- key: "initialize",
32
- value: function initialize() {
88
+ key: "getMap",
89
+ value: function getMap() {
90
+ return this._mapContext && this._mapContext.getMap();
91
+ }
92
+
93
+ // 统一构建参数,避免重复逻辑
94
+ }, {
95
+ key: "_buildParams",
96
+ value: function _buildParams(options) {
97
+ return {
98
+ u_threshold: typeof options.u_threshold === 'number' ? Math.max(options.u_threshold, 0) : DEFAULT_PARAMS.u_threshold,
99
+ u_blendFactor: typeof options.u_blendFactor === 'number' ? Cesium.Math.clamp(options.u_blendFactor, 0, 1) : DEFAULT_PARAMS.u_blendFactor,
100
+ u_lightIntensity: typeof options.u_lightIntensity === 'number' ? Math.max(options.u_lightIntensity, 0) : DEFAULT_PARAMS.u_lightIntensity,
101
+ u_scatterStrength: typeof options.u_scatterStrength === 'number' ? Math.max(options.u_scatterStrength, 0) : DEFAULT_PARAMS.u_scatterStrength,
102
+ u_tonemapExposure: typeof options.u_tonemapExposure === 'number' ? Math.max(options.u_tonemapExposure, 0) : DEFAULT_PARAMS.u_tonemapExposure,
103
+ u_mieExtinctionStrength: typeof options.u_mieExtinctionStrength === 'number' ? Math.max(options.u_mieExtinctionStrength, 0) : DEFAULT_PARAMS.u_mieExtinctionStrength,
104
+ u_fogOpacity: typeof options.u_fogOpacity === 'number' ? Math.max(options.u_fogOpacity, 0) : DEFAULT_PARAMS.u_fogOpacity,
105
+ u_fogPower: typeof options.u_fogPower === 'number' ? Math.max(options.u_fogPower, 0.0001) : DEFAULT_PARAMS.u_fogPower,
106
+ u_clearMixBias: typeof options.u_clearMixBias === 'number' ? Cesium.Math.clamp(options.u_clearMixBias, 0, 1) : DEFAULT_PARAMS.u_clearMixBias
107
+ };
108
+ }
109
+
110
+ // 统一构建缩放降速参数,避免危险配置导致交互异常
111
+ }, {
112
+ key: "_buildZoomDampingOptions",
113
+ value: function _buildZoomDampingOptions(options) {
114
+ var dampingStartPitchDeg = typeof options.dampingStartPitchDeg === 'number' ? options.dampingStartPitchDeg : DEFAULT_ZOOM_DAMPING_OPTIONS.dampingStartPitchDeg;
115
+ var dampingFullPitchDegCandidate = typeof options.dampingFullPitchDeg === 'number' ? options.dampingFullPitchDeg : DEFAULT_ZOOM_DAMPING_OPTIONS.dampingFullPitchDeg;
116
+ return {
117
+ enableZoomDamping: typeof options.enableZoomDamping === 'boolean' ? options.enableZoomDamping : DEFAULT_ZOOM_DAMPING_OPTIONS.enableZoomDamping,
118
+ dampingStartPitchDeg: dampingStartPitchDeg,
119
+ dampingFullPitchDeg: Math.min(dampingFullPitchDegCandidate, dampingStartPitchDeg - 0.1),
120
+ minZoomScale: Cesium.Math.clamp(typeof options.minZoomScale === 'number' ? options.minZoomScale : DEFAULT_ZOOM_DAMPING_OPTIONS.minZoomScale, 0.01, 1)
121
+ };
122
+ }
123
+
124
+ // 规范化字符串时间,支持 HH:mm:ss
125
+ }, {
126
+ key: "_normalizeClockText",
127
+ value: function _normalizeClockText(clockText) {
128
+ var matchResult = /^(\d{1,2}):(\d{1,2}):(\d{1,2})$/.exec(clockText.trim());
129
+ if (!matchResult) return null;
130
+ var hours = Number(matchResult[1]);
131
+ var minutes = Number(matchResult[2]);
132
+ var seconds = Number(matchResult[3]);
133
+ if (!Number.isInteger(hours) || !Number.isInteger(minutes) || !Number.isInteger(seconds) || hours < 0 || hours > 23 || minutes < 0 || minutes > 59 || seconds < 0 || seconds > 59) {
134
+ return null;
135
+ }
136
+ return "".concat(String(hours).padStart(2, '0'), ":").concat(String(minutes).padStart(2, '0'), ":").concat(String(seconds).padStart(2, '0'));
137
+ }
138
+
139
+ // 统一构建时间参数,只接收字符串时间,非法值回退到默认12点
140
+ }, {
141
+ key: "_buildClockOption",
142
+ value: function _buildClockOption(options) {
143
+ if (options.clock === 'auto') {
144
+ return 'auto';
145
+ }
146
+ if (typeof options.clock === 'string') {
147
+ var normalizedClockText = this._normalizeClockText(options.clock);
148
+ if (normalizedClockText) {
149
+ return normalizedClockText;
150
+ }
151
+ }
152
+ return DEFAULT_CLOCK_TEXT;
153
+ }
154
+
155
+ // 初始化后处理效果并挂载到场景
156
+ }, {
157
+ key: "_initialize",
158
+ value: function _initialize() {
33
159
  var _this = this;
34
- var atmosphereFs = this._createFragmentShader();
160
+ var map = this.getMap();
161
+ if (!map) return;
35
162
  this.atmosphericDispersion = new Cesium.PostProcessStage({
36
- fragmentShader: atmosphereFs,
163
+ fragmentShader: AtmosphericShader,
37
164
  uniforms: {
38
165
  u_threshold: function u_threshold() {
39
166
  return _this.params.u_threshold;
@@ -43,72 +170,397 @@ var AtmosphericDispersion = /*#__PURE__*/function () {
43
170
  },
44
171
  u_lightIntensity: function u_lightIntensity() {
45
172
  return _this.params.u_lightIntensity;
173
+ },
174
+ u_scatterStrength: function u_scatterStrength() {
175
+ return _this.params.u_scatterStrength;
176
+ },
177
+ u_tonemapExposure: function u_tonemapExposure() {
178
+ return _this.params.u_tonemapExposure;
179
+ },
180
+ u_mieExtinctionStrength: function u_mieExtinctionStrength() {
181
+ return _this.params.u_mieExtinctionStrength;
182
+ },
183
+ u_fogOpacity: function u_fogOpacity() {
184
+ return _this.params.u_fogOpacity;
185
+ },
186
+ u_fogPower: function u_fogPower() {
187
+ return _this.params.u_fogPower;
188
+ },
189
+ u_clearMixBias: function u_clearMixBias() {
190
+ return _this.params.u_clearMixBias;
46
191
  }
47
192
  }
48
193
  });
49
- this.viewer.scene.postProcessStages.add(this.atmosphericDispersion);
194
+ map.scene.postProcessStages.add(this.atmosphericDispersion);
195
+ this._syncClockControlState();
196
+ this._syncZoomDampingState();
197
+ }
198
+
199
+ // 获取缩放控制器
200
+ }, {
201
+ key: "_getCameraController",
202
+ value: function _getCameraController() {
203
+ var _this$getMap;
204
+ return (_this$getMap = this.getMap()) === null || _this$getMap === void 0 || (_this$getMap = _this$getMap.scene) === null || _this$getMap === void 0 ? void 0 : _this$getMap.screenSpaceCameraController;
205
+ }
206
+
207
+ // 读取当前缩放降速共享状态
208
+ }, {
209
+ key: "_getZoomDampingControllerState",
210
+ value: function _getZoomDampingControllerState() {
211
+ var controller = this._getCameraController();
212
+ if (!controller) return null;
213
+ if (!controller[ZOOM_DAMPING_STATE_KEY]) {
214
+ controller[ZOOM_DAMPING_STATE_KEY] = {
215
+ baseZoomFactor: this._normalizeZoomFactor(controller.zoomFactor),
216
+ owners: new Map()
217
+ };
218
+ }
219
+ return controller[ZOOM_DAMPING_STATE_KEY];
220
+ }
221
+
222
+ // 兜底缩放倍率,避免出现非法值
223
+ }, {
224
+ key: "_normalizeZoomFactor",
225
+ value: function _normalizeZoomFactor(zoomFactor) {
226
+ return typeof zoomFactor === 'number' && Number.isFinite(zoomFactor) ? Math.max(zoomFactor, MIN_ZOOM_FACTOR) : MIN_ZOOM_FACTOR;
227
+ }
228
+
229
+ // 获取时钟控制共享状态
230
+ }, {
231
+ key: "_getClockControlState",
232
+ value: function _getClockControlState() {
233
+ var _this$getMap2;
234
+ var viewerClock = (_this$getMap2 = this.getMap()) === null || _this$getMap2 === void 0 ? void 0 : _this$getMap2.clock;
235
+ if (!viewerClock) return null;
236
+ if (!viewerClock[CLOCK_CONTROL_STATE_KEY]) {
237
+ viewerClock[CLOCK_CONTROL_STATE_KEY] = {
238
+ baseCurrentTime: Cesium.JulianDate.clone(viewerClock.currentTime),
239
+ owners: new Map(),
240
+ preRenderHandler: null
241
+ };
242
+ }
243
+ return viewerClock[CLOCK_CONTROL_STATE_KEY];
244
+ }
245
+
246
+ // 获取当前生效的时间配置,后激活的实例优先
247
+ }, {
248
+ key: "_getEffectiveClockOption",
249
+ value: function _getEffectiveClockOption(state) {
250
+ var effectiveClockOption = null;
251
+ state.owners.forEach(function (clockOption) {
252
+ effectiveClockOption = clockOption;
253
+ });
254
+ return effectiveClockOption;
255
+ }
256
+
257
+ // 将固定时间转换为当天本地时间的 JulianDate
258
+ }, {
259
+ key: "_buildClockCurrentTime",
260
+ value: function _buildClockCurrentTime(clockOption) {
261
+ var date = new Date();
262
+ var _clockOption$split$ma = clockOption.split(':').map(Number),
263
+ _clockOption$split$ma2 = _slicedToArray(_clockOption$split$ma, 3),
264
+ hours = _clockOption$split$ma2[0],
265
+ minutes = _clockOption$split$ma2[1],
266
+ seconds = _clockOption$split$ma2[2];
267
+ date.setHours(hours, minutes, seconds, 0);
268
+ return Cesium.JulianDate.fromDate(date);
269
+ }
270
+
271
+ // 开始自动跟随系统时间
272
+ }, {
273
+ key: "_startClockAutoSync",
274
+ value: function _startClockAutoSync(state) {
275
+ if (state.preRenderHandler) return;
276
+ var map = this.getMap();
277
+ if (!map) return;
278
+ state.preRenderHandler = function () {
279
+ var effectiveClockOption = null;
280
+ state.owners.forEach(function (clockOption) {
281
+ effectiveClockOption = clockOption;
282
+ });
283
+ if (effectiveClockOption !== 'auto') return;
284
+ map.clock.currentTime = Cesium.JulianDate.fromDate(new Date());
285
+ };
286
+ map.scene.preRender.addEventListener(state.preRenderHandler);
287
+ }
288
+
289
+ // 停止自动跟随系统时间
290
+ }, {
291
+ key: "_stopClockAutoSync",
292
+ value: function _stopClockAutoSync(state) {
293
+ var map = this.getMap();
294
+ if (!state.preRenderHandler || !map) return;
295
+ map.scene.preRender.removeEventListener(state.preRenderHandler);
296
+ state.preRenderHandler = null;
297
+ }
298
+
299
+ // 将共享时间状态同步到场景时钟
300
+ }, {
301
+ key: "_syncSceneClockControl",
302
+ value: function _syncSceneClockControl(state) {
303
+ var _this$getMap3;
304
+ var viewerClock = (_this$getMap3 = this.getMap()) === null || _this$getMap3 === void 0 ? void 0 : _this$getMap3.clock;
305
+ if (!viewerClock) return;
306
+ var effectiveClockOption = this._getEffectiveClockOption(state);
307
+ if (effectiveClockOption === null) {
308
+ this._stopClockAutoSync(state);
309
+ viewerClock.currentTime = Cesium.JulianDate.clone(state.baseCurrentTime);
310
+ delete viewerClock[CLOCK_CONTROL_STATE_KEY];
311
+ return;
312
+ }
313
+ if (effectiveClockOption === 'auto') {
314
+ this._startClockAutoSync(state);
315
+ viewerClock.currentTime = Cesium.JulianDate.fromDate(new Date());
316
+ return;
317
+ }
318
+ this._stopClockAutoSync(state);
319
+ viewerClock.currentTime = this._buildClockCurrentTime(effectiveClockOption);
320
+ }
321
+
322
+ // 应用当前实例的时间控制
323
+ }, {
324
+ key: "_applyClockControl",
325
+ value: function _applyClockControl() {
326
+ var _this$getMap4;
327
+ var viewerClock = (_this$getMap4 = this.getMap()) === null || _this$getMap4 === void 0 ? void 0 : _this$getMap4.clock;
328
+ var state = this._getClockControlState();
329
+ if (!viewerClock || !state) return;
330
+ if (state.owners.size === 0) {
331
+ state.baseCurrentTime = Cesium.JulianDate.clone(viewerClock.currentTime);
332
+ }
333
+ state.owners.delete(this._clockControlOwnerId);
334
+ state.owners.set(this._clockControlOwnerId, this.clockOption);
335
+ this._syncSceneClockControl(state);
336
+ }
337
+
338
+ // 移除当前实例对场景时间的影响
339
+ }, {
340
+ key: "_releaseClockControl",
341
+ value: function _releaseClockControl() {
342
+ var _this$getMap5;
343
+ var viewerClock = (_this$getMap5 = this.getMap()) === null || _this$getMap5 === void 0 ? void 0 : _this$getMap5.clock;
344
+ if (!viewerClock || !viewerClock[CLOCK_CONTROL_STATE_KEY]) return;
345
+ var state = viewerClock[CLOCK_CONTROL_STATE_KEY];
346
+ state.owners.delete(this._clockControlOwnerId);
347
+ this._syncSceneClockControl(state);
348
+ }
349
+
350
+ // 根据效果状态同步时间控制
351
+ }, {
352
+ key: "_syncClockControlState",
353
+ value: function _syncClockControlState() {
354
+ if (this.isEnabled()) {
355
+ this._applyClockControl();
356
+ return;
357
+ }
358
+ this._releaseClockControl();
359
+ }
360
+
361
+ // 绑定相机变化监听,在俯角变化时动态调整缩放速率
362
+ }, {
363
+ key: "_bindCameraChangedHandler",
364
+ value: function _bindCameraChangedHandler() {
365
+ if (this._cameraChangedHandler) return;
366
+ var map = this.getMap();
367
+ if (!map) return;
368
+ this._cameraChangedHandler = this._handleCameraChanged.bind(this);
369
+ map.camera.changed.addEventListener(this._cameraChangedHandler);
370
+ }
371
+
372
+ // 移除相机变化监听
373
+ }, {
374
+ key: "_unbindCameraChangedHandler",
375
+ value: function _unbindCameraChangedHandler() {
376
+ var map = this.getMap();
377
+ if (!this._cameraChangedHandler) return;
378
+ map === null || map === void 0 || map.camera.changed.removeEventListener(this._cameraChangedHandler);
379
+ this._cameraChangedHandler = null;
380
+ }
381
+
382
+ // 相机变化时更新缩放阻尼
383
+ }, {
384
+ key: "_handleCameraChanged",
385
+ value: function _handleCameraChanged() {
386
+ this._applyZoomDamping();
387
+ }
388
+
389
+ // 根据当前俯仰角计算应使用的缩放倍率
390
+ }, {
391
+ key: "_computeDampedZoomFactor",
392
+ value: function _computeDampedZoomFactor(baseZoomFactor) {
393
+ var map = this.getMap();
394
+ if (!map) return baseZoomFactor;
395
+ var cameraPitchDeg = Cesium.Math.toDegrees(map.camera.pitch);
396
+ var _this$zoomDampingOpti = this.zoomDampingOptions,
397
+ dampingStartPitchDeg = _this$zoomDampingOpti.dampingStartPitchDeg,
398
+ dampingFullPitchDeg = _this$zoomDampingOpti.dampingFullPitchDeg,
399
+ minZoomScale = _this$zoomDampingOpti.minZoomScale;
400
+ if (!Number.isFinite(cameraPitchDeg) || cameraPitchDeg > dampingStartPitchDeg) {
401
+ return baseZoomFactor;
402
+ }
403
+ var progress = Cesium.Math.clamp((dampingStartPitchDeg - cameraPitchDeg) / (dampingStartPitchDeg - dampingFullPitchDeg), 0, 1);
404
+ var smoothProgress = progress * progress * (3 - 2 * progress);
405
+ var zoomScale = 1 - (1 - minZoomScale) * smoothProgress;
406
+ return this._normalizeZoomFactor(baseZoomFactor * zoomScale);
407
+ }
408
+
409
+ // 将所有实例的缩放保护合并到控制器上
410
+ }, {
411
+ key: "_syncControllerZoomFactor",
412
+ value: function _syncControllerZoomFactor(state, controller) {
413
+ if (state.owners.size === 0) {
414
+ controller.zoomFactor = state.baseZoomFactor;
415
+ delete controller[ZOOM_DAMPING_STATE_KEY];
416
+ return;
417
+ }
418
+ var nextZoomFactor = state.baseZoomFactor;
419
+ state.owners.forEach(function (zoomFactor) {
420
+ nextZoomFactor = Math.min(nextZoomFactor, zoomFactor);
421
+ });
422
+ controller.zoomFactor = this._normalizeZoomFactor(nextZoomFactor);
50
423
  }
424
+
425
+ // 应用极俯角缩放降速
51
426
  }, {
52
- key: "_createFragmentShader",
53
- value: function _createFragmentShader() {
54
- return "\n precision highp float;\n uniform sampler2D colorTexture;\n uniform sampler2D depthTexture;\n uniform float u_threshold;\n uniform float u_blendFactor;\n uniform float u_lightIntensity;\n in vec2 v_textureCoordinates;\n const float PI = 3.14159265359;\n const float TWO_PI = PI * 2.0;\n const float FOUR_PI = PI * 4.0;\n\n const vec3 betaR = vec3(5.5e-6, 13.0e-6, 22.4e-6);\n\n const vec3 betaM = vec3(21e-6);\n\n const float hR = 10e3;\n const float hM = 3.8e3;\n const int num_samples = 16;\n const int num_samples_light = 4;\n #ifdef GL_ES\n #define _in(T) const in T\n #define _inout(T) inout T\n #define _out(T) out T\n #define _begin(type) type (\n #define _end )\n #define mul(a, b) (a) * (b)\n #endif\n\n struct ray_t {\n vec3 origin;\n vec3 direction;\n };\n struct sphere_t {\n vec3 origin;\n float radius;\n int material;\n };\n struct plane_t {\n vec3 direction;\n float distance;\n int material;\n };\n plane_t plane;\n mat3 rotate_around_x(_in(float) angle_degrees) {\n float angle = radians(angle_degrees);\n float _sin = sin(angle);\n float _cos = cos(angle);\n return mat3(1, 0, 0, 0, _cos, -_sin, 0, _sin, _cos);\n }\n\n bool isect_sphere(_in(ray_t) ray, _in(sphere_t) sphere, _inout(float) t0, _inout(float) t1) {\n vec3 rc = sphere.origin - ray.origin;\n float radius2 = sphere.radius * sphere.radius;\n float tca = dot(rc, ray.direction);\n float d2 = dot(rc, rc) - tca * tca;\n if (d2 > radius2) return false;\n float thc = sqrt(radius2 - d2);\n t0 = tca - thc;\n t1 = tca + thc;\n return true;\n }\n float rayleigh_phase_func(float mu) {\n return\n 3. * (1. + mu*mu)\n /\n (16. * PI);\n }\n const float g = 0.76;\n float henyey_greenstein_phase_func(float mu) {\n return\n (1. - g*g)\n /\n ((4. * PI) * pow(1. + g*g - 2.*g*mu, 1.5));\n }\n const float k = 1.55*g - 0.55 * (g*g*g);\n float schlick_phase_func(float mu) {\n return\n (1. - k*k)\n /\n (4. * PI * (1. + k*mu) * (1. + k*mu));\n }\n const sphere_t atmosphere = _begin(sphere_t)\n vec3(0, 0, 0), 6420e3, 0\n _end;\n\n bool get_sun_light(\n _in(ray_t) ray, _inout(float) optical_depthR, _inout(float) optical_depthM\n ) {\n float t0, t1;\n isect_sphere(ray, atmosphere, t0, t1);\n float march_pos = 0.;\n float march_step = t1 / float(num_samples_light);\n for (int i = 0; i < num_samples_light; i++) {\n vec3 s = ray.origin +\n ray.direction * (march_pos + 0.5 * march_step);\n float height = length(s) - 6360e3;\n if (height < 0.)\n return false;\n optical_depthR += exp(-height / hR) * march_step;\n optical_depthM += exp(-height / hM) * march_step;\n march_pos += march_step;\n }\n return true;\n }\n vec4 get_incident_light(_in(ray_t) ray) {\n vec3 dir = ray.direction;\n vec3 start = ray.origin;\n float a = dot( dir, dir);\n float b = 2.0 * dot(dir, start);\n float radius2 = atmosphere.radius * atmosphere.radius;\n float c = dot(start, start) - radius2;\n float d = (b * b) - 4.0 * a * c;\n if (d < 0.0) return vec4(0.0);\n float squaredD = sqrt(d);\n vec2 ray_length = vec2(\n max((-b - squaredD) / (2.0 * a), 0.0), min((-b + squaredD) / (2.0 * a), plane.distance)\n );\n if (ray_length.x > ray_length.y) return vec4(0.0);\n float march_step = (ray_length.y - ray_length.x) / float(num_samples);\n float mu = dot(ray.direction, normalize(czm_sunPositionWC));\n float phaseR = rayleigh_phase_func(mu);\n float phaseM =\n #if 1\n henyey_greenstein_phase_func(mu);\n #else\n schlick_phase_func(mu);\n #endif\n\n float optical_depthR = 0.;\n float optical_depthM = 0.;\n vec3 sumR = vec3(0);\n vec3 sumM = vec3(0);\n float march_pos = 0.;\n for (int i = 0; i < num_samples; i++) {\n vec3 s = ray.origin +\n ray.direction * (march_pos + 0.5 * march_step);\n float height = length(s) - 6360e3;\n\n float hr = exp(-height / hR) * march_step;\n float hm = exp(-height / hM) * march_step;\n optical_depthR += hr;\n optical_depthM += hm;\n\n ray_t light_ray = _begin(ray_t)\n s, normalize(czm_sunPositionWC)\n _end;\n float optical_depth_lightR = 0.;\n float optical_depth_lightM = 0.;\n bool overground = get_sun_light(\n light_ray,\n optical_depth_lightR,\n optical_depth_lightM);\n\n if (overground) {\n\n vec3 tau =\n betaR * (optical_depthR + optical_depth_lightR) +\n betaM * 1.1 * (optical_depthM + optical_depth_lightM);\n vec3 attenuation = exp(-tau);\n sumR += hr * attenuation;\n sumM += hm * attenuation;\n }\n\n march_pos += march_step;\n }\n float attenuation = length(exp(-((betaM * optical_depthM)\n + (betaR * optical_depthR)) * 4.));\n\n return vec4(\n 23. *\n (sumR * phaseR * betaR +\n sumM * phaseM * betaM), 1.0-attenuation);\n }\n\n void main() {\n vec4 rawColor = texture(colorTexture, v_textureCoordinates);\n float depth = czm_unpackDepth(texture(depthTexture, v_textureCoordinates));\n\n vec4 positionEC = czm_windowToEyeCoordinates(gl_FragCoord.xy, depth);\n vec4 positionWC = czm_inverseView * positionEC;\n positionWC.xyz = positionWC.xyz / positionWC.w;\n\n vec3 lVector = positionWC.xyz - czm_viewerPositionWC;\n ray_t ray;\n ray.origin = czm_viewerPositionWC;\n ray.direction = normalize(lVector);\n plane.distance = length(lVector);\n\n vec4 atmosphereColor = get_incident_light(ray);\n atmosphereColor.rgb *= u_lightIntensity;\n float brightness = dot(atmosphereColor.rgb, vec3(0.299, 0.587, 0.114));\n if (brightness < u_threshold) {\n atmosphereColor.rgb *= brightness / u_threshold;\n }\n rawColor = mix(rawColor, atmosphereColor + rawColor * (1.0 - atmosphereColor.a), u_blendFactor);\n rawColor = vec4(1.0 - exp(-2.2 * rawColor));\n\n out_FragColor = rawColor;\n }\n ";
427
+ key: "_applyZoomDamping",
428
+ value: function _applyZoomDamping() {
429
+ var controller = this._getCameraController();
430
+ var state = this._getZoomDampingControllerState();
431
+ if (!controller || !state) return;
432
+ if (state.owners.size === 0) {
433
+ state.baseZoomFactor = this._normalizeZoomFactor(controller.zoomFactor);
434
+ }
435
+ var nextZoomFactor = this._computeDampedZoomFactor(state.baseZoomFactor);
436
+ if (nextZoomFactor >= state.baseZoomFactor) {
437
+ state.owners.delete(this._zoomDampingOwnerId);
438
+ } else {
439
+ state.owners.set(this._zoomDampingOwnerId, nextZoomFactor);
440
+ }
441
+ this._syncControllerZoomFactor(state, controller);
55
442
  }
443
+
444
+ // 移除当前实例对缩放降速的影响
445
+ }, {
446
+ key: "_releaseZoomDamping",
447
+ value: function _releaseZoomDamping() {
448
+ var controller = this._getCameraController();
449
+ if (!controller || !controller[ZOOM_DAMPING_STATE_KEY]) return;
450
+ var state = controller[ZOOM_DAMPING_STATE_KEY];
451
+ state.owners.delete(this._zoomDampingOwnerId);
452
+ this._syncControllerZoomFactor(state, controller);
453
+ }
454
+
455
+ // 根据效果状态同步缩放降速监听与倍率
456
+ }, {
457
+ key: "_syncZoomDampingState",
458
+ value: function _syncZoomDampingState() {
459
+ if (this.isEnabled() && this.zoomDampingOptions.enableZoomDamping) {
460
+ this._bindCameraChangedHandler();
461
+ this._applyZoomDamping();
462
+ return;
463
+ }
464
+ this._releaseZoomDamping();
465
+ this._unbindCameraChangedHandler();
466
+ }
467
+
468
+ // 更新效果参数
56
469
  }, {
57
470
  key: "updateParameters",
58
471
  value: function updateParameters(params) {
59
472
  if (params && _typeof(params) === 'object') {
60
473
  if (typeof params.u_threshold === 'number') {
61
- this.params.u_threshold = params.u_threshold;
474
+ this.params.u_threshold = Math.max(params.u_threshold, 0);
62
475
  }
63
476
  if (typeof params.u_blendFactor === 'number') {
64
- this.params.u_blendFactor = params.u_blendFactor;
477
+ this.params.u_blendFactor = Cesium.Math.clamp(params.u_blendFactor, 0, 1);
65
478
  }
66
479
  if (typeof params.u_lightIntensity === 'number') {
67
- this.params.u_lightIntensity = params.u_lightIntensity;
480
+ this.params.u_lightIntensity = Math.max(params.u_lightIntensity, 0);
481
+ }
482
+ if (typeof params.u_scatterStrength === 'number') {
483
+ this.params.u_scatterStrength = Math.max(params.u_scatterStrength, 0);
484
+ }
485
+ if (typeof params.u_tonemapExposure === 'number') {
486
+ this.params.u_tonemapExposure = Math.max(params.u_tonemapExposure, 0);
487
+ }
488
+ if (typeof params.u_mieExtinctionStrength === 'number') {
489
+ this.params.u_mieExtinctionStrength = Math.max(params.u_mieExtinctionStrength, 0);
68
490
  }
491
+ if (typeof params.u_fogOpacity === 'number') {
492
+ this.params.u_fogOpacity = Math.max(params.u_fogOpacity, 0);
493
+ }
494
+ if (typeof params.u_fogPower === 'number') {
495
+ this.params.u_fogPower = Math.max(params.u_fogPower, 0.0001);
496
+ }
497
+ if (typeof params.u_clearMixBias === 'number') {
498
+ this.params.u_clearMixBias = Cesium.Math.clamp(params.u_clearMixBias, 0, 1);
499
+ }
500
+ this.clockOption = this._buildClockOption(_objectSpread({
501
+ clock: this.clockOption
502
+ }, params));
503
+ this.zoomDampingOptions = this._buildZoomDampingOptions(_objectSpread(_objectSpread({}, this.zoomDampingOptions), params));
504
+ this._syncClockControlState();
505
+ this._syncZoomDampingState();
69
506
  }
70
507
  return this;
71
508
  }
509
+
510
+ // 重置参数到初始化值
72
511
  }, {
73
512
  key: "resetParameters",
74
513
  value: function resetParameters() {
75
- this.params = {
76
- u_threshold: this.originalOptions.u_threshold !== undefined ? this.originalOptions.u_threshold : 1.1,
77
- u_blendFactor: this.originalOptions.u_blendFactor !== undefined ? this.originalOptions.u_blendFactor : 0.5,
78
- u_lightIntensity: this.originalOptions.u_lightIntensity !== undefined ? this.originalOptions.u_lightIntensity : 1.6
79
- };
514
+ this.params = this._buildParams(this.originalOptions);
515
+ this.clockOption = this._buildClockOption(this.originalOptions);
516
+ this.zoomDampingOptions = this._buildZoomDampingOptions(this.originalOptions);
517
+ this._syncClockControlState();
518
+ this._syncZoomDampingState();
80
519
  return this;
81
520
  }
521
+
522
+ // 显示效果
82
523
  }, {
83
524
  key: "show",
84
525
  value: function show() {
85
526
  if (this.atmosphericDispersion) {
86
527
  this.atmosphericDispersion.enabled = true;
87
528
  }
529
+ this._syncClockControlState();
530
+ this._syncZoomDampingState();
88
531
  return this;
89
532
  }
533
+
534
+ // 隐藏效果
90
535
  }, {
91
536
  key: "hide",
92
537
  value: function hide() {
93
538
  if (this.atmosphericDispersion) {
94
539
  this.atmosphericDispersion.enabled = false;
95
540
  }
541
+ this._syncClockControlState();
542
+ this._syncZoomDampingState();
96
543
  return this;
97
544
  }
545
+
546
+ // 判断效果是否启用
98
547
  }, {
99
548
  key: "isEnabled",
100
549
  value: function isEnabled() {
101
550
  return this.atmosphericDispersion ? this.atmosphericDispersion.enabled : false;
102
551
  }
552
+
553
+ // 销毁效果并移除后处理阶段
103
554
  }, {
104
555
  key: "destroy",
105
556
  value: function destroy() {
106
- if (this.atmosphericDispersion) {
107
- this.viewer.scene.postProcessStages.remove(this.atmosphericDispersion);
557
+ var map = this.getMap();
558
+ this._releaseClockControl();
559
+ this._releaseZoomDamping();
560
+ this._unbindCameraChangedHandler();
561
+ if (this.atmosphericDispersion && map) {
562
+ map.scene.postProcessStages.remove(this.atmosphericDispersion);
108
563
  this.atmosphericDispersion = null;
109
- this.viewer = null;
110
- this.params = null;
111
- this.originalOptions = null;
112
564
  }
113
565
  }
114
566
  }]);