deeptwins-engine-3d 0.1.66 → 0.1.67
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.
- package/dist/esm/constant.d.ts +9 -0
- package/dist/esm/constant.js +10 -1
- package/dist/esm/graphicLayer/BaseLayer.d.ts +23 -0
- package/dist/esm/graphicLayer/BaseLayer.js +387 -65
- package/dist/esm/graphicLayer/BasePrimitiveInstance.d.ts +0 -1
- package/dist/esm/graphicLayer/BasePrimitiveInstance.js +0 -7
- package/dist/esm/graphicLayer/BaseSource.d.ts +1 -1
- package/dist/esm/graphicLayer/BoxPrimitiveInstance.d.ts +0 -1
- package/dist/esm/graphicLayer/BoxPrimitiveInstance.js +4 -8
- package/dist/esm/graphicLayer/EllipsePrimitiveInstance.d.ts +0 -1
- package/dist/esm/graphicLayer/EllipsePrimitiveInstance.js +5 -9
- package/dist/esm/graphicLayer/EllipsoidPrimitiveInstance.d.ts +0 -1
- package/dist/esm/graphicLayer/EllipsoidPrimitiveInstance.js +5 -9
- package/dist/esm/graphicLayer/GraphicLayerCollection.js +20 -27
- package/dist/esm/graphicLayer/ModelPrimitiveInstance.d.ts +0 -1
- package/dist/esm/graphicLayer/ModelPrimitiveInstance.js +0 -7
- package/dist/esm/graphicLayer/PolygonGroundPrimitiveImageMaterialInstance.js +5 -2
- package/dist/esm/graphicLayer/PolygonPrimitiveImageMaterialInstance.js +5 -2
- package/dist/esm/graphicLayer/PolygonPrimitiveInstance.d.ts +0 -1
- package/dist/esm/graphicLayer/PolygonPrimitiveInstance.js +5 -9
- package/dist/esm/graphicLayer/PolylineGroundPrimitiveInstance.d.ts +0 -1
- package/dist/esm/graphicLayer/PolylineGroundPrimitiveInstance.js +4 -8
- package/dist/esm/graphicLayer/PolylinePrimitiveInstance.d.ts +0 -1
- package/dist/esm/graphicLayer/PolylinePrimitiveInstance.js +4 -8
- package/dist/esm/graphicLayer/PolylineVolumePrimitiveInstance.d.ts +0 -1
- package/dist/esm/graphicLayer/PolylineVolumePrimitiveInstance.js +4 -8
- package/dist/esm/graphicLayer/WallPrimitiveInstance.d.ts +0 -1
- package/dist/esm/graphicLayer/WallPrimitiveInstance.js +4 -8
- package/dist/esm/index.js +2 -2
- package/dist/esm/material/WeatherEffects.d.ts +64 -14
- package/dist/esm/material/WeatherEffects.js +279 -95
- package/dist/esm/material/shader/RainShader.glsl +44 -6
- package/dist/esm/material/shader/lightning.glsl +70 -0
- package/dist/esm/tileLayer/MvtVectorLoad.d.ts +12 -0
- package/dist/esm/tileLayer/MvtVectorLoad.js +245 -49
- package/dist/umd/deeptwins-engine-3d.min.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
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); }
|
|
2
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
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); }
|
|
5
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
|
+
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; }
|
|
8
|
+
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; }
|
|
9
|
+
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; }
|
|
2
10
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
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); } }
|
|
4
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; }
|
|
@@ -6,160 +14,336 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
6
14
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
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); }
|
|
8
16
|
import * as Cesium from 'deeptwins-cesium';
|
|
9
|
-
import { merge } from 'lodash';
|
|
10
17
|
import { DEFAULT_FOG, DEFAULT_RAIN, DEFAULT_SNOW } from "../constant";
|
|
11
18
|
import { colorString, toRadians } from "../tool/utils";
|
|
12
19
|
/* babel-plugin-inline-import './shader/FogShader.glsl' */
|
|
13
20
|
var FogShader = "float getDistance(sampler2D depthTexture, vec2 texCoords)\n{\n float depth = czm_unpackDepth(texture(depthTexture, texCoords));\n if (depth == 0.0) {\n return czm_infinity;\n }\n vec4 eyeCoordinate = czm_windowToEyeCoordinates(gl_FragCoord.xy, depth);\n return -eyeCoordinate.z / eyeCoordinate.w;\n}\n//\u6839\u636E\u8DDD\u79BB\uFF0C\u5728\u4E2D\u95F4\u8FDB\u884C\u63D2\u503C\nfloat interpolateByDistance(vec4 nearFarScalar, float distance)\n{\n //\u6839\u636E\u5E38\u8BC6\uFF0C\u96FE\u5E94\u8BE5\u662F\u8DDD\u79BB\u8FDC\uFF0C\u8D8A\u770B\u4E0D\u6E05\uFF0C\u8FD1\u8DDD\u79BB\u5185\u7684\u7269\u4F53\u53EF\u4EE5\u770B\u6E05\n //\u56E0\u6B64\u8FD1\u8DDD\u79BBalpha=0\uFF0C\u8FDC\u8DDD\u79BB\u7684alpha=1.0\n //\u672C\u4F8B\u4E2D\u8BBE\u7F6E\u53EF\u89C1\u5EA6\u4E3A200\u7C73\n //\u96FE\u7279\u6548\u7684\u8D77\u59CB\u8DDD\u79BB\n float startDistance = nearFarScalar.x;\n //\u96FE\u7279\u6548\u7684\u8D77\u59CBalpha\u503C\n float startValue = nearFarScalar.y;\n //\u96FE\u7279\u6548\u7684\u7ED3\u675F\u8DDD\u79BB\n float endDistance = nearFarScalar.z;\n //\u96FE\u7279\u6548\u7684\u7ED3\u675Falpha\u503C\n float endValue = nearFarScalar.w;\n //\u6839\u636E\u6BCF\u6BB5\u8DDD\u79BB\u5360\u603B\u957F\u5EA6\u7684\u5360\u6BD4\uFF0C\u63D2\u503Calpha\uFF0C\u8DDD\u79BB\u8D8A\u8FDC\uFF0Calpha\u503C\u8D8A\u5927\u3002\u63D2\u503C\u8303\u56F40,1\u3002\n float t = clamp((distance - startDistance) / (endDistance - startDistance), 0.0, 1.0);\n return mix(startValue, endValue, t);\n}\nvec4 alphaBlend(vec4 sourceColor, vec4 destinationColor)\n{\n return sourceColor * vec4(sourceColor.aaa, 1.0) + destinationColor * (1.0 - sourceColor.a);\n}\nuniform sampler2D colorTexture;\nuniform sampler2D depthTexture;\nuniform vec4 fogByDistance;\nuniform vec4 fogColor;\nin vec2 v_textureCoordinates;\nvoid main(void)\n{\n //\u83B7\u53D6\u5730\u7269\u8DDD\u76F8\u673A\u7684\u8DDD\u79BB\n float distance = getDistance(depthTexture, v_textureCoordinates);\n //\u83B7\u53D6\u573A\u666F\u539F\u672C\u7684\u7EB9\u7406\u989C\u8272\n vec4 sceneColor = texture(colorTexture, v_textureCoordinates);\n //\u6839\u636E\u8DDD\u79BB\uFF0C\u5BF9alpha\u8FDB\u884C\u63D2\u503C\n float blendAmount = interpolateByDistance(fogByDistance, distance);\n //\u5C06alpha\u53D8\u5316\u503C\u4EE3\u5165\u96FE\u7684\u539F\u59CB\u989C\u8272\u4E2D\uFF0C\u5E76\u5C06\u96FE\u4E0E\u573A\u666F\u539F\u59CB\u7EB9\u7406\u8FDB\u884C\u878D\u5408\n vec4 finalFogColor = vec4(fogColor.rgb, fogColor.a * blendAmount);\n out_FragColor = alphaBlend(finalFogColor, sceneColor);\n}\n";
|
|
14
21
|
/* babel-plugin-inline-import './shader/RainShader.glsl' */
|
|
15
|
-
var RainShader = "precision highp float;\n\nuniform sampler2D colorTexture;\nuniform float direction;\nuniform float size;\nuniform float speed;\nin vec2 v_textureCoordinates;\nout vec4 fragColor;\n\nfloat hash(float x) {\n return fract(sin(x * 133.3) * 13.13);\n}\n\nvoid main() {\n float time = czm_frameNumber / speed;\n vec2 resolution = czm_viewport.zw;\n vec2 uv = (gl_FragCoord.xy * 2.0 - resolution) / min(resolution.x, resolution.y);\n
|
|
22
|
+
var RainShader = "precision highp float;\n\nuniform sampler2D colorTexture;\nuniform float direction;\nuniform float size;\nuniform float speed;\nuniform float density;\nuniform float opacity;\nuniform float gloominess;\nuniform vec4 rainColor;\nin vec2 v_textureCoordinates;\nout vec4 fragColor;\n\nfloat hash(float x) {\n return fract(sin(x * 133.3) * 13.13);\n}\n\nfloat rainLayer(vec2 uv, float time, float densityFactor, float scaleFactor, float seed) {\n vec2 warpedUv = uv;\n warpedUv *= scaleFactor;\n\n float v = 1.0 - sin(hash(floor((warpedUv.x + seed) * 100.0 * densityFactor)) * 2.0);\n float b = clamp(\n abs(sin((20.0 + seed * 2.5) * time * v + warpedUv.y * (5.0 / (2.0 + v)))) - 0.95,\n 0.0,\n 1.0\n ) * (18.0 + densityFactor * 2.0);\n\n return v * b;\n}\n\nvec3 applyGloominess(vec3 sceneColor) {\n float gloomFactor = clamp(gloominess, 0.0, 1.0);\n float luminance = dot(sceneColor, vec3(0.299, 0.587, 0.114));\n vec3 mutedScene = mix(sceneColor, vec3(luminance), gloomFactor * 0.45);\n return mutedScene * (1.0 - gloomFactor * 0.55);\n}\n\nvoid main() {\n float time = czm_frameNumber / speed;\n vec2 resolution = czm_viewport.zw;\n vec2 uv = (gl_FragCoord.xy * 2.0 - resolution) / min(resolution.x, resolution.y);\n float a = direction;\n float si = sin(a), co = cos(a);\n uv *= mat2(co, -si, si, co);\n\n vec2 primaryUv = uv;\n primaryUv *= length(primaryUv + vec2(0.0, 4.9)) * size + 1.0;\n\n float densityFactor = mix(0.65, 2.1, clamp(density / 100.0, 0.0, 1.0));\n float primaryLayer = rainLayer(primaryUv, time, densityFactor, 1.0, 0.0);\n\n vec2 secondaryUv = primaryUv * 1.35;\n secondaryUv.x += time * 0.25;\n secondaryUv.y += hash(floor(primaryUv.x * 8.0) + 17.0) * 0.75;\n float secondaryLayer = rainLayer(secondaryUv, time * 1.15, densityFactor * 0.85, 1.0, 3.7) * 0.65;\n\n float rainMask = clamp(primaryLayer + secondaryLayer, 0.0, 1.0);\n\n vec4 scene = texture(colorTexture, v_textureCoordinates);\n vec3 baseScene = applyGloominess(scene.rgb);\n vec3 rainLayerColor = rainColor.rgb * rainMask * opacity;\n vec3 finalColor = clamp(baseScene + rainLayerColor, 0.0, 1.0);\n\n fragColor = vec4(finalColor, scene.a);\n}\n";
|
|
16
23
|
/* babel-plugin-inline-import './shader/SnowShader.glsl' */
|
|
17
24
|
var SnowShader = "precision highp float;\n\nuniform sampler2D colorTexture;\nuniform float speed;\nuniform float size;\nin vec2 v_textureCoordinates;\nout vec4 fragColor;\n\nfloat snow(vec2 uv, float sc) {\n float scale = sc * size;\n float time = float(czm_frameNumber) / speed;\n float w = smoothstep(1.0, 0.0, -uv.y * (scale / 10.0));\n if (w < 0.1) return 0.0;\n uv += time / scale;\n uv.y += time * 2.0 / scale;\n uv.x += sin(uv.y + time * 0.5) / scale;\n uv *= scale;\n vec2 s = floor(uv), f = fract(uv), p;\n float k = 3.0, d;\n p = 0.5 + 0.35 * sin(11.0 * fract(sin((s + p + scale) * mat2(7, 3, 6, 5)) * 5.0)) - f;\n d = length(p);\n k = min(d, k);\n k = smoothstep(0.0, k, sin(f.x + f.y) * 0.01);\n return k * w;\n}\n\nvoid main() {\n vec2 resolution = czm_viewport.zw;\n vec2 uv = (gl_FragCoord.xy * 2.0 - resolution.xy) / min(resolution.x, resolution.y);\n vec3 finalColor = vec3(0.0);\n float c = 0.0;\n c += snow(uv, 10.);\n c += snow(uv, 8.);\n c += snow(uv, 7.);\n c += snow(uv, 6.);\n c += snow(uv, 5.);\n c += snow(uv, 4.);\n c += snow(uv, 3.);\n c += snow(uv, 2.);\n c += snow(uv, 1.);\n c += snow(uv, .6);\n finalColor = vec3(c);\n\n // \u8C03\u6574\u4EAE\u5EA6\n finalColor = finalColor * 2.2;\n\n fragColor = mix(texture(colorTexture, v_textureCoordinates), vec4(finalColor, 1.0), 0.2);\n}\n";
|
|
25
|
+
/* babel-plugin-inline-import './shader/lightning.glsl' */
|
|
26
|
+
var LightningShader = "precision highp float;\n\nfloat hash(float x)\n{\n return fract(21654.6512 * sin(385.51 * x));\n}\nfloat hash(vec2 p)\n{\n return fract(1654.65157 * sin(15.5134763 * p.x + 45.5173247 * p.y + 5.21789));\n}\nvec2 hash2(vec2 p)\n{\n return vec2(hash(p * .754), hash(1.5743 * p + 4.5476351));\n}\nconst vec2 hashAdd = vec2(1.0, 0.0);\nvec2 noise2(vec2 x)\n{\n vec2 p = floor(x);\n vec2 f = fract(x);\n f = f * f * (3.0 - 2.0 * f);\n vec2 res = mix(mix(hash2(p),\n hash2(p + hashAdd.xy), f.x),\n mix(hash2(p + hashAdd.yx), hash2(p + hashAdd.xx), f.x), f.y);\n return res;\n}\nvec2 fbm2(vec2 x)\n{\n vec2 r = vec2(0.0);\n float a = 1.0;\n for (int i = 0; i < 8; i++)\n {\n r += noise2(x) * a;\n x *= 2.;\n a *= .5;\n }\n return r;\n}\nfloat dseg(vec2 ba, vec2 pa)\n{\n float h = clamp(dot(pa, ba) / dot(ba, ba), -0.2, 1.);\n return length(pa - ba * h);\n}\nuniform sampler2D colorTexture;\nuniform float fall_interval;\nuniform float mix_factor;\nin vec2 v_textureCoordinates;\nout vec4 fragColor;\nvoid main(void){\n float iTime = czm_frameNumber * fall_interval * clamp(fall_interval * 0.1, 0.01, 0.1);\n vec2 p = gl_FragCoord.xy / czm_viewport.zw;\n vec2 d;\n vec2 tgt = vec2(1., -1.);\n vec3 col = vec3(0.);\n float mdist = 100000.;\n float t = hash(floor(5. * iTime));\n tgt += 4. * hash2(tgt + t) - 1.5;\n if (hash(t + 2.3) > .6)\n for (int i = 0; i < 100; i++) {\n vec2 dtgt = tgt - p;\n d = .05 * (vec2(-.5, -1.) + hash2(vec2(float(i), t)));\n float dist = dseg(d, dtgt);\n mdist = min(mdist, dist);\n tgt -= d;\n float bolt = exp(-1.2 * dist) + exp(-55. * mdist);\n col = max(col, bolt * vec3(.7, .8, 1.));\n }\n vec4 scene = texture(colorTexture, v_textureCoordinates);\n vec3 finalColor = clamp(scene.rgb + col * mix_factor, 0.0, 1.0);\n fragColor = vec4(finalColor, scene.a);\n}\n";
|
|
27
|
+
var WEATHER_EFFECT_TYPES = ['snow', 'rain', 'fog'];
|
|
28
|
+
// 天气效果
|
|
18
29
|
var WeatherEffects = /*#__PURE__*/function () {
|
|
19
30
|
function WeatherEffects(type) {
|
|
20
|
-
var
|
|
31
|
+
var _this = this;
|
|
32
|
+
var _options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
21
33
|
_classCallCheck(this, WeatherEffects);
|
|
22
34
|
_defineProperty(this, "_mapContext", void 0);
|
|
23
35
|
_defineProperty(this, "type", void 0);
|
|
24
36
|
_defineProperty(this, "options", void 0);
|
|
25
37
|
_defineProperty(this, "stage", void 0);
|
|
26
|
-
this
|
|
27
|
-
this
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
_defineProperty(this, "isDestroyed", false);
|
|
39
|
+
_defineProperty(this, "_isAdded", false);
|
|
40
|
+
// 雨天除了主雨层外,还会挂一个独立的闪电后处理层。
|
|
41
|
+
_defineProperty(this, "_extraStages", []);
|
|
42
|
+
_defineProperty(this, "_stageConfigBuilders", {
|
|
43
|
+
snow: function snow(options) {
|
|
44
|
+
return _this._buildSnowStageConfig(options);
|
|
45
|
+
},
|
|
46
|
+
rain: function rain(options) {
|
|
47
|
+
return _this._buildRainStageConfig(options);
|
|
48
|
+
},
|
|
49
|
+
fog: function fog(options) {
|
|
50
|
+
return _this._buildFogStageConfig(options);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
this.type = this._assertWeatherEffectType(type);
|
|
54
|
+
var stageConfig = this._buildStageConfig(this.type, _options);
|
|
55
|
+
this.options = stageConfig.options;
|
|
56
|
+
this.stage = this._createStage(stageConfig.mainStage);
|
|
57
|
+
this._extraStages = this._createExtraStages(stageConfig.extraStages);
|
|
39
58
|
}
|
|
40
59
|
_createClass(WeatherEffects, [{
|
|
41
60
|
key: "getMap",
|
|
42
61
|
value: function getMap() {
|
|
43
|
-
|
|
62
|
+
var _this$_mapContext;
|
|
63
|
+
return (_this$_mapContext = this._mapContext) === null || _this$_mapContext === void 0 ? void 0 : _this$_mapContext.getMap();
|
|
44
64
|
}
|
|
45
65
|
|
|
46
66
|
// 移除
|
|
47
67
|
}, {
|
|
48
68
|
key: "remove",
|
|
49
69
|
value: function remove() {
|
|
50
|
-
if (!this.
|
|
51
|
-
|
|
70
|
+
if (this.isDestroyed || !this._isAdded) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
this._removeStagesFromMap();
|
|
74
|
+
this._resetStagesFromCurrentOptions();
|
|
52
75
|
}
|
|
53
76
|
|
|
54
77
|
// 添加到地图
|
|
55
78
|
}, {
|
|
56
79
|
key: "addToMap",
|
|
57
80
|
value: function addToMap(map) {
|
|
58
|
-
this.
|
|
59
|
-
|
|
81
|
+
this._assertNotDestroyed();
|
|
82
|
+
if (this._isAdded) {
|
|
83
|
+
var currentMap = this.getMap();
|
|
84
|
+
if (currentMap === map) {
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
this.remove();
|
|
88
|
+
}
|
|
89
|
+
this._mapContext = map;
|
|
90
|
+
this._getStages().forEach(function (stage) {
|
|
91
|
+
map.scene.postProcessStages.add(stage);
|
|
92
|
+
});
|
|
93
|
+
this._isAdded = true;
|
|
94
|
+
return this;
|
|
60
95
|
}
|
|
61
96
|
|
|
62
97
|
// 修改参数
|
|
63
98
|
}, {
|
|
64
99
|
key: "setEffect",
|
|
65
|
-
value: function setEffect(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
100
|
+
value: function setEffect() {
|
|
101
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
102
|
+
this._assertNotDestroyed();
|
|
103
|
+
var stageConfig = this._buildStageConfig(this.type, _objectSpread(_objectSpread({}, this.options), options));
|
|
104
|
+
this.options = stageConfig.options;
|
|
105
|
+
this._applyStageConfig(stageConfig);
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
}, {
|
|
109
|
+
key: "destroy",
|
|
110
|
+
value: function destroy() {
|
|
111
|
+
if (this.isDestroyed) {
|
|
112
|
+
return;
|
|
78
113
|
}
|
|
79
|
-
|
|
80
|
-
this.
|
|
114
|
+
if (this._isAdded) {
|
|
115
|
+
this._removeStagesFromMap();
|
|
116
|
+
} else if (!this.stage.isDestroyed()) {
|
|
117
|
+
this._destroyStages();
|
|
81
118
|
}
|
|
119
|
+
this._extraStages = [];
|
|
120
|
+
this.isDestroyed = true;
|
|
82
121
|
}
|
|
83
122
|
}, {
|
|
84
|
-
key: "
|
|
85
|
-
value: function
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
speed = _merge.speed;
|
|
89
|
-
if (size < 1 || size > 30) {
|
|
90
|
-
throw new Error('size属性超出限制');
|
|
123
|
+
key: "_assertWeatherEffectType",
|
|
124
|
+
value: function _assertWeatherEffectType(type) {
|
|
125
|
+
if (WEATHER_EFFECT_TYPES.includes(type)) {
|
|
126
|
+
return type;
|
|
91
127
|
}
|
|
92
|
-
|
|
93
|
-
|
|
128
|
+
throw new Error("\u4E0D\u652F\u6301\u7684\u5929\u6C14\u7C7B\u578B: ".concat(type));
|
|
129
|
+
}
|
|
130
|
+
}, {
|
|
131
|
+
key: "_assertNotDestroyed",
|
|
132
|
+
value: function _assertNotDestroyed() {
|
|
133
|
+
if (this.isDestroyed) {
|
|
134
|
+
throw new Error('WeatherEffects实例已销毁');
|
|
94
135
|
}
|
|
95
|
-
return {
|
|
96
|
-
size: 20 / size,
|
|
97
|
-
speed: 1800 / speed
|
|
98
|
-
};
|
|
99
136
|
}
|
|
100
137
|
}, {
|
|
101
|
-
key: "
|
|
102
|
-
value: function
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
138
|
+
key: "_createStage",
|
|
139
|
+
value: function _createStage(stageConfig) {
|
|
140
|
+
var _stageConfig$enabled;
|
|
141
|
+
var stage = new Cesium.PostProcessStage({
|
|
142
|
+
fragmentShader: stageConfig.fragmentShader,
|
|
143
|
+
uniforms: stageConfig.uniforms
|
|
106
144
|
});
|
|
145
|
+
stage.enabled = (_stageConfig$enabled = stageConfig.enabled) !== null && _stageConfig$enabled !== void 0 ? _stageConfig$enabled : true;
|
|
146
|
+
return stage;
|
|
107
147
|
}
|
|
108
148
|
}, {
|
|
109
|
-
key: "
|
|
110
|
-
value: function
|
|
111
|
-
var
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
149
|
+
key: "_createExtraStages",
|
|
150
|
+
value: function _createExtraStages(stageConfigs) {
|
|
151
|
+
var _this2 = this;
|
|
152
|
+
return stageConfigs.map(function (stageConfig) {
|
|
153
|
+
return _this2._createStage(stageConfig);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}, {
|
|
157
|
+
key: "_resetStagesFromCurrentOptions",
|
|
158
|
+
value: function _resetStagesFromCurrentOptions() {
|
|
159
|
+
var stageConfig = this._buildStageConfig(this.type, this.options);
|
|
160
|
+
this.stage = this._createStage(stageConfig.mainStage);
|
|
161
|
+
this._extraStages = this._createExtraStages(stageConfig.extraStages);
|
|
162
|
+
}
|
|
163
|
+
}, {
|
|
164
|
+
key: "_getStages",
|
|
165
|
+
value: function _getStages() {
|
|
166
|
+
return [this.stage].concat(_toConsumableArray(this._extraStages));
|
|
167
|
+
}
|
|
168
|
+
}, {
|
|
169
|
+
key: "_removeStagesFromMap",
|
|
170
|
+
value: function _removeStagesFromMap() {
|
|
171
|
+
var map = this.getMap();
|
|
172
|
+
var weatherStages = this._getStages();
|
|
173
|
+
if (map) {
|
|
174
|
+
var stages = map.scene.postProcessStages;
|
|
175
|
+
weatherStages.forEach(function (stage) {
|
|
176
|
+
if (stages.contains(stage)) {
|
|
177
|
+
stages.remove(stage);
|
|
178
|
+
} else if (!stage.isDestroyed()) {
|
|
179
|
+
stage.destroy();
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
} else {
|
|
183
|
+
this._destroyStages();
|
|
117
184
|
}
|
|
118
|
-
|
|
119
|
-
|
|
185
|
+
this._isAdded = false;
|
|
186
|
+
this._mapContext = undefined;
|
|
187
|
+
}
|
|
188
|
+
}, {
|
|
189
|
+
key: "_destroyStages",
|
|
190
|
+
value: function _destroyStages() {
|
|
191
|
+
this._getStages().forEach(function (stage) {
|
|
192
|
+
if (!stage.isDestroyed()) {
|
|
193
|
+
stage.destroy();
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
}, {
|
|
198
|
+
key: "_applyUniforms",
|
|
199
|
+
value: function _applyUniforms(stage, uniforms) {
|
|
200
|
+
Object.keys(uniforms).forEach(function (key) {
|
|
201
|
+
stage.uniforms[key] = uniforms[key];
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}, {
|
|
205
|
+
key: "_applyStageConfig",
|
|
206
|
+
value: function _applyStageConfig(stageConfig) {
|
|
207
|
+
var _stageConfig$mainStag,
|
|
208
|
+
_this3 = this;
|
|
209
|
+
var nextExtraStages = stageConfig.extraStages;
|
|
210
|
+
if (nextExtraStages.length !== this._extraStages.length) {
|
|
211
|
+
var map = this.getMap();
|
|
212
|
+
var shouldReAdd = this._isAdded && !!map;
|
|
213
|
+
if (shouldReAdd) {
|
|
214
|
+
this._removeStagesFromMap();
|
|
215
|
+
} else {
|
|
216
|
+
this._destroyStages();
|
|
217
|
+
}
|
|
218
|
+
this.stage = this._createStage(stageConfig.mainStage);
|
|
219
|
+
this._extraStages = this._createExtraStages(nextExtraStages);
|
|
220
|
+
if (shouldReAdd && map) {
|
|
221
|
+
this.addToMap(map);
|
|
222
|
+
}
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
this._applyUniforms(this.stage, stageConfig.mainStage.uniforms);
|
|
226
|
+
this.stage.enabled = (_stageConfig$mainStag = stageConfig.mainStage.enabled) !== null && _stageConfig$mainStag !== void 0 ? _stageConfig$mainStag : true;
|
|
227
|
+
nextExtraStages.forEach(function (extraStageConfig, index) {
|
|
228
|
+
var _extraStageConfig$ena;
|
|
229
|
+
var extraStage = _this3._extraStages[index];
|
|
230
|
+
_this3._applyUniforms(extraStage, extraStageConfig.uniforms);
|
|
231
|
+
extraStage.enabled = (_extraStageConfig$ena = extraStageConfig.enabled) !== null && _extraStageConfig$ena !== void 0 ? _extraStageConfig$ena : true;
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}, {
|
|
235
|
+
key: "_buildStageConfig",
|
|
236
|
+
value: function _buildStageConfig(type, options) {
|
|
237
|
+
return this._stageConfigBuilders[type](options);
|
|
238
|
+
}
|
|
239
|
+
}, {
|
|
240
|
+
key: "_assertNumberInRange",
|
|
241
|
+
value: function _assertNumberInRange(key, value, min, max) {
|
|
242
|
+
if (!Number.isFinite(value) || value < min || value > max) {
|
|
243
|
+
throw new Error("".concat(key, "\u5C5E\u6027\u8D85\u51FA\u9650\u5236\uFF0C\u53D6\u503C\u8303\u56F4\u4E3A").concat(min, "~").concat(max));
|
|
120
244
|
}
|
|
121
|
-
|
|
122
|
-
|
|
245
|
+
}
|
|
246
|
+
}, {
|
|
247
|
+
key: "_assertBoolean",
|
|
248
|
+
value: function _assertBoolean(key, value) {
|
|
249
|
+
if (typeof value !== 'boolean') {
|
|
250
|
+
throw new Error("".concat(key, "\u5C5E\u6027\u5FC5\u987B\u662F\u5E03\u5C14\u503C"));
|
|
123
251
|
}
|
|
252
|
+
}
|
|
253
|
+
}, {
|
|
254
|
+
key: "_buildSnowStageConfig",
|
|
255
|
+
value: function _buildSnowStageConfig() {
|
|
256
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
257
|
+
var nextOptions = _objectSpread(_objectSpread({}, DEFAULT_SNOW()), options);
|
|
258
|
+
this._assertNumberInRange('size', nextOptions.size, 1, 30);
|
|
259
|
+
this._assertNumberInRange('speed', nextOptions.speed, 1, 100);
|
|
124
260
|
return {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
261
|
+
mainStage: {
|
|
262
|
+
fragmentShader: SnowShader,
|
|
263
|
+
uniforms: {
|
|
264
|
+
size: 20 / nextOptions.size,
|
|
265
|
+
speed: 1800 / nextOptions.speed
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
extraStages: [],
|
|
269
|
+
options: nextOptions
|
|
128
270
|
};
|
|
129
271
|
}
|
|
130
272
|
}, {
|
|
131
|
-
key: "
|
|
132
|
-
value: function
|
|
133
|
-
|
|
134
|
-
fragmentShader: RainShader,
|
|
135
|
-
uniforms: this._handleRainOptions(options)
|
|
136
|
-
});
|
|
273
|
+
key: "_isRainLightningActive",
|
|
274
|
+
value: function _isRainLightningActive(options) {
|
|
275
|
+
return options.lightningEnabled && options.lightningFrequency > 0 && options.lightningIntensity > 0;
|
|
137
276
|
}
|
|
138
277
|
}, {
|
|
139
|
-
key: "
|
|
140
|
-
value: function
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
throw new Error('startDistance属性超出限制');
|
|
147
|
-
}
|
|
148
|
-
if (endDistance < 5000 || endDistance > 50000) {
|
|
149
|
-
throw new Error('endDistance属性超出限制');
|
|
150
|
-
}
|
|
278
|
+
key: "_mapRainLightningInterval",
|
|
279
|
+
value: function _mapRainLightningInterval(lightningFrequency) {
|
|
280
|
+
return 0.18 + lightningFrequency / 100 * 0.78;
|
|
281
|
+
}
|
|
282
|
+
}, {
|
|
283
|
+
key: "_buildRainLightningStageConfig",
|
|
284
|
+
value: function _buildRainLightningStageConfig(options) {
|
|
151
285
|
return {
|
|
152
|
-
|
|
153
|
-
|
|
286
|
+
fragmentShader: LightningShader,
|
|
287
|
+
uniforms: {
|
|
288
|
+
fall_interval: this._mapRainLightningInterval(options.lightningFrequency),
|
|
289
|
+
mix_factor: options.lightningIntensity
|
|
290
|
+
},
|
|
291
|
+
enabled: this._isRainLightningActive(options)
|
|
154
292
|
};
|
|
155
293
|
}
|
|
156
294
|
}, {
|
|
157
|
-
key: "
|
|
158
|
-
value: function
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
295
|
+
key: "_buildRainStageConfig",
|
|
296
|
+
value: function _buildRainStageConfig() {
|
|
297
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
298
|
+
var nextOptions = _objectSpread(_objectSpread({}, DEFAULT_RAIN()), options);
|
|
299
|
+
this._assertNumberInRange('direction', nextOptions.direction, -90, 90);
|
|
300
|
+
this._assertNumberInRange('size', nextOptions.size, 1, 100);
|
|
301
|
+
this._assertNumberInRange('speed', nextOptions.speed, 1, 100);
|
|
302
|
+
this._assertNumberInRange('density', nextOptions.density, 0, 100);
|
|
303
|
+
this._assertNumberInRange('opacity', nextOptions.opacity, 0, 1);
|
|
304
|
+
this._assertNumberInRange('gloominess', nextOptions.gloominess, 0, 1);
|
|
305
|
+
this._assertBoolean('lightningEnabled', nextOptions.lightningEnabled);
|
|
306
|
+
this._assertNumberInRange('lightningFrequency', nextOptions.lightningFrequency, 0, 100);
|
|
307
|
+
this._assertNumberInRange('lightningIntensity', nextOptions.lightningIntensity, 0, 1);
|
|
308
|
+
this._assertNumberInRange('lightningDuration', nextOptions.lightningDuration, 0, 1);
|
|
309
|
+
return {
|
|
310
|
+
mainStage: {
|
|
311
|
+
fragmentShader: RainShader,
|
|
312
|
+
uniforms: {
|
|
313
|
+
direction: toRadians(nextOptions.direction),
|
|
314
|
+
size: 10 / nextOptions.size,
|
|
315
|
+
speed: 1800 / nextOptions.speed,
|
|
316
|
+
density: nextOptions.density,
|
|
317
|
+
opacity: nextOptions.opacity,
|
|
318
|
+
gloominess: nextOptions.gloominess,
|
|
319
|
+
rainColor: colorString(nextOptions.color)
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
extraStages: [this._buildRainLightningStageConfig(nextOptions)],
|
|
323
|
+
options: nextOptions
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
}, {
|
|
327
|
+
key: "_buildFogStageConfig",
|
|
328
|
+
value: function _buildFogStageConfig() {
|
|
329
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
330
|
+
var nextOptions = _objectSpread(_objectSpread({}, DEFAULT_FOG()), options);
|
|
331
|
+
this._assertNumberInRange('startDistance', nextOptions.startDistance, 1, 5000);
|
|
332
|
+
this._assertNumberInRange('endDistance', nextOptions.endDistance, 5000, 50000);
|
|
333
|
+
if (nextOptions.startDistance >= nextOptions.endDistance) {
|
|
334
|
+
throw new Error('startDistance必须小于endDistance');
|
|
335
|
+
}
|
|
336
|
+
return {
|
|
337
|
+
mainStage: {
|
|
338
|
+
fragmentShader: FogShader,
|
|
339
|
+
uniforms: {
|
|
340
|
+
fogByDistance: new Cesium.Cartesian4(nextOptions.startDistance, 0.1, nextOptions.endDistance, 0.8),
|
|
341
|
+
fogColor: colorString(nextOptions.color)
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
extraStages: [],
|
|
345
|
+
options: nextOptions
|
|
346
|
+
};
|
|
163
347
|
}
|
|
164
348
|
}]);
|
|
165
349
|
return WeatherEffects;
|
|
@@ -4,6 +4,10 @@ uniform sampler2D colorTexture;
|
|
|
4
4
|
uniform float direction;
|
|
5
5
|
uniform float size;
|
|
6
6
|
uniform float speed;
|
|
7
|
+
uniform float density;
|
|
8
|
+
uniform float opacity;
|
|
9
|
+
uniform float gloominess;
|
|
10
|
+
uniform vec4 rainColor;
|
|
7
11
|
in vec2 v_textureCoordinates;
|
|
8
12
|
out vec4 fragColor;
|
|
9
13
|
|
|
@@ -11,18 +15,52 @@ float hash(float x) {
|
|
|
11
15
|
return fract(sin(x * 133.3) * 13.13);
|
|
12
16
|
}
|
|
13
17
|
|
|
18
|
+
float rainLayer(vec2 uv, float time, float densityFactor, float scaleFactor, float seed) {
|
|
19
|
+
vec2 warpedUv = uv;
|
|
20
|
+
warpedUv *= scaleFactor;
|
|
21
|
+
|
|
22
|
+
float v = 1.0 - sin(hash(floor((warpedUv.x + seed) * 100.0 * densityFactor)) * 2.0);
|
|
23
|
+
float b = clamp(
|
|
24
|
+
abs(sin((20.0 + seed * 2.5) * time * v + warpedUv.y * (5.0 / (2.0 + v)))) - 0.95,
|
|
25
|
+
0.0,
|
|
26
|
+
1.0
|
|
27
|
+
) * (18.0 + densityFactor * 2.0);
|
|
28
|
+
|
|
29
|
+
return v * b;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
vec3 applyGloominess(vec3 sceneColor) {
|
|
33
|
+
float gloomFactor = clamp(gloominess, 0.0, 1.0);
|
|
34
|
+
float luminance = dot(sceneColor, vec3(0.299, 0.587, 0.114));
|
|
35
|
+
vec3 mutedScene = mix(sceneColor, vec3(luminance), gloomFactor * 0.45);
|
|
36
|
+
return mutedScene * (1.0 - gloomFactor * 0.55);
|
|
37
|
+
}
|
|
38
|
+
|
|
14
39
|
void main() {
|
|
15
40
|
float time = czm_frameNumber / speed;
|
|
16
41
|
vec2 resolution = czm_viewport.zw;
|
|
17
42
|
vec2 uv = (gl_FragCoord.xy * 2.0 - resolution) / min(resolution.x, resolution.y);
|
|
18
|
-
vec3 c = vec3(0.6, 0.7, 0.8);
|
|
19
43
|
float a = direction;
|
|
20
44
|
float si = sin(a), co = cos(a);
|
|
21
45
|
uv *= mat2(co, -si, si, co);
|
|
22
|
-
uv *= length(uv + vec2(0.0, 4.9)) * size + 1.0;
|
|
23
|
-
float v = 1.0 - sin(hash(floor(uv.x * 100.0)) * 2.0);
|
|
24
|
-
float b = clamp(abs(sin(20.0 * time * v + uv.y * (5.0 / (2.0 + v)))) - 0.95, 0.0, 1.0) * 20.0;
|
|
25
|
-
c *= v * b;
|
|
26
46
|
|
|
27
|
-
|
|
47
|
+
vec2 primaryUv = uv;
|
|
48
|
+
primaryUv *= length(primaryUv + vec2(0.0, 4.9)) * size + 1.0;
|
|
49
|
+
|
|
50
|
+
float densityFactor = mix(0.65, 2.1, clamp(density / 100.0, 0.0, 1.0));
|
|
51
|
+
float primaryLayer = rainLayer(primaryUv, time, densityFactor, 1.0, 0.0);
|
|
52
|
+
|
|
53
|
+
vec2 secondaryUv = primaryUv * 1.35;
|
|
54
|
+
secondaryUv.x += time * 0.25;
|
|
55
|
+
secondaryUv.y += hash(floor(primaryUv.x * 8.0) + 17.0) * 0.75;
|
|
56
|
+
float secondaryLayer = rainLayer(secondaryUv, time * 1.15, densityFactor * 0.85, 1.0, 3.7) * 0.65;
|
|
57
|
+
|
|
58
|
+
float rainMask = clamp(primaryLayer + secondaryLayer, 0.0, 1.0);
|
|
59
|
+
|
|
60
|
+
vec4 scene = texture(colorTexture, v_textureCoordinates);
|
|
61
|
+
vec3 baseScene = applyGloominess(scene.rgb);
|
|
62
|
+
vec3 rainLayerColor = rainColor.rgb * rainMask * opacity;
|
|
63
|
+
vec3 finalColor = clamp(baseScene + rainLayerColor, 0.0, 1.0);
|
|
64
|
+
|
|
65
|
+
fragColor = vec4(finalColor, scene.a);
|
|
28
66
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
precision highp float;
|
|
2
|
+
|
|
3
|
+
float hash(float x)
|
|
4
|
+
{
|
|
5
|
+
return fract(21654.6512 * sin(385.51 * x));
|
|
6
|
+
}
|
|
7
|
+
float hash(vec2 p)
|
|
8
|
+
{
|
|
9
|
+
return fract(1654.65157 * sin(15.5134763 * p.x + 45.5173247 * p.y + 5.21789));
|
|
10
|
+
}
|
|
11
|
+
vec2 hash2(vec2 p)
|
|
12
|
+
{
|
|
13
|
+
return vec2(hash(p * .754), hash(1.5743 * p + 4.5476351));
|
|
14
|
+
}
|
|
15
|
+
const vec2 hashAdd = vec2(1.0, 0.0);
|
|
16
|
+
vec2 noise2(vec2 x)
|
|
17
|
+
{
|
|
18
|
+
vec2 p = floor(x);
|
|
19
|
+
vec2 f = fract(x);
|
|
20
|
+
f = f * f * (3.0 - 2.0 * f);
|
|
21
|
+
vec2 res = mix(mix(hash2(p),
|
|
22
|
+
hash2(p + hashAdd.xy), f.x),
|
|
23
|
+
mix(hash2(p + hashAdd.yx), hash2(p + hashAdd.xx), f.x), f.y);
|
|
24
|
+
return res;
|
|
25
|
+
}
|
|
26
|
+
vec2 fbm2(vec2 x)
|
|
27
|
+
{
|
|
28
|
+
vec2 r = vec2(0.0);
|
|
29
|
+
float a = 1.0;
|
|
30
|
+
for (int i = 0; i < 8; i++)
|
|
31
|
+
{
|
|
32
|
+
r += noise2(x) * a;
|
|
33
|
+
x *= 2.;
|
|
34
|
+
a *= .5;
|
|
35
|
+
}
|
|
36
|
+
return r;
|
|
37
|
+
}
|
|
38
|
+
float dseg(vec2 ba, vec2 pa)
|
|
39
|
+
{
|
|
40
|
+
float h = clamp(dot(pa, ba) / dot(ba, ba), -0.2, 1.);
|
|
41
|
+
return length(pa - ba * h);
|
|
42
|
+
}
|
|
43
|
+
uniform sampler2D colorTexture;
|
|
44
|
+
uniform float fall_interval;
|
|
45
|
+
uniform float mix_factor;
|
|
46
|
+
in vec2 v_textureCoordinates;
|
|
47
|
+
out vec4 fragColor;
|
|
48
|
+
void main(void){
|
|
49
|
+
float iTime = czm_frameNumber * fall_interval * clamp(fall_interval * 0.1, 0.01, 0.1);
|
|
50
|
+
vec2 p = gl_FragCoord.xy / czm_viewport.zw;
|
|
51
|
+
vec2 d;
|
|
52
|
+
vec2 tgt = vec2(1., -1.);
|
|
53
|
+
vec3 col = vec3(0.);
|
|
54
|
+
float mdist = 100000.;
|
|
55
|
+
float t = hash(floor(5. * iTime));
|
|
56
|
+
tgt += 4. * hash2(tgt + t) - 1.5;
|
|
57
|
+
if (hash(t + 2.3) > .6)
|
|
58
|
+
for (int i = 0; i < 100; i++) {
|
|
59
|
+
vec2 dtgt = tgt - p;
|
|
60
|
+
d = .05 * (vec2(-.5, -1.) + hash2(vec2(float(i), t)));
|
|
61
|
+
float dist = dseg(d, dtgt);
|
|
62
|
+
mdist = min(mdist, dist);
|
|
63
|
+
tgt -= d;
|
|
64
|
+
float bolt = exp(-1.2 * dist) + exp(-55. * mdist);
|
|
65
|
+
col = max(col, bolt * vec3(.7, .8, 1.));
|
|
66
|
+
}
|
|
67
|
+
vec4 scene = texture(colorTexture, v_textureCoordinates);
|
|
68
|
+
vec3 finalColor = clamp(scene.rgb + col * mix_factor, 0.0, 1.0);
|
|
69
|
+
fragColor = vec4(finalColor, scene.a);
|
|
70
|
+
}
|
|
@@ -152,8 +152,13 @@ declare class MvtVectorLoad {
|
|
|
152
152
|
_tilesToUpdate: VectorLoadTile[];
|
|
153
153
|
_loadedTiles: Record<string, LoadedTile>;
|
|
154
154
|
_pendingTiles: Map<string, Promise<LoadedTile>>;
|
|
155
|
+
private _pendingRequestControllers;
|
|
156
|
+
private _pendingRequestTiles;
|
|
155
157
|
private _cacheOrder;
|
|
156
158
|
_requestToken: number;
|
|
159
|
+
private _requestQueue;
|
|
160
|
+
private _queuedTileKeys;
|
|
161
|
+
private _activeRequestCount;
|
|
157
162
|
private _levelZeroMaximumGeometricError;
|
|
158
163
|
private _decodeWithWorker;
|
|
159
164
|
private _autoDisplayLayers;
|
|
@@ -178,6 +183,9 @@ declare class MvtVectorLoad {
|
|
|
178
183
|
private _doInit;
|
|
179
184
|
private _validateOptions;
|
|
180
185
|
private _emitError;
|
|
186
|
+
private _isAbortError;
|
|
187
|
+
private _markTileLoading;
|
|
188
|
+
private _resetTileRequestState;
|
|
181
189
|
private _createRootTiles;
|
|
182
190
|
private _getTileKey;
|
|
183
191
|
private _touchTileCache;
|
|
@@ -212,11 +220,14 @@ declare class MvtVectorLoad {
|
|
|
212
220
|
private _loadTile;
|
|
213
221
|
tileToGeoJSON(tile: LoadedTile): TileGeoJSONResult;
|
|
214
222
|
update(frameState: FrameStateLike): void;
|
|
223
|
+
private _cancelStaleRequests;
|
|
215
224
|
private _updateTiles;
|
|
225
|
+
private _drainRequestQueue;
|
|
216
226
|
private _loadVisibleTile;
|
|
217
227
|
getLoadedTiles(): LoadedTile[];
|
|
218
228
|
getTile(x: number, y: number, z: number): LoadedTile | undefined;
|
|
219
229
|
clearCache(): void;
|
|
230
|
+
private _abortAllPendingRequests;
|
|
220
231
|
private _resetTileStates;
|
|
221
232
|
destroy(): void;
|
|
222
233
|
isDestroyed(): boolean;
|
|
@@ -234,6 +245,7 @@ declare class VectorLoadTile {
|
|
|
234
245
|
distanceToCamera: number;
|
|
235
246
|
visibility: Cesium.Intersect;
|
|
236
247
|
state: TileState;
|
|
248
|
+
requestVersion: number;
|
|
237
249
|
constructor(options: VectorLoadTileOptions);
|
|
238
250
|
createChildren(): void;
|
|
239
251
|
visit(frameState: FrameStateLike, visitor: TileVisitor, getScreenSpaceError: ScreenSpaceErrorCalculator): void;
|