deeptwins-engine-3d 0.0.44 → 0.0.45

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/index.js CHANGED
@@ -44,7 +44,7 @@ window.Cesium = Cesium;
44
44
  var DeepTwinsEngine3D = /*#__PURE__*/_createClass(function DeepTwinsEngine3D() {
45
45
  _classCallCheck(this, DeepTwinsEngine3D);
46
46
  });
47
- _defineProperty(DeepTwinsEngine3D, "Version", '0.0.44');
47
+ _defineProperty(DeepTwinsEngine3D, "Version", '0.0.45');
48
48
  _defineProperty(DeepTwinsEngine3D, "Map", Map);
49
49
  _defineProperty(DeepTwinsEngine3D, "GroundSkyBox", GroundSkyBox);
50
50
  _defineProperty(DeepTwinsEngine3D, "RasterLayer", RasterLayer);
@@ -23,9 +23,8 @@ import { cloneDeep, isEqual, merge } from 'lodash';
23
23
  import { DEFAULT_CIRCLE_WAVE_MATERIAL_STYLE } from "../constant";
24
24
  import * as utils from "../tool/utils";
25
25
  import BaseMaterialProperty from "./BaseMaterialProperty";
26
- import CircleWaveShader from "./shader/CircleWaveShader.glsl";
27
-
28
- // 水波纹材质
26
+ /* babel-plugin-inline-import './shader/CircleWaveShader.glsl' */
27
+ var CircleWaveShader = "czm_material czm_getMaterial(czm_materialInput materialInput) {\n czm_material material = czm_getDefaultMaterial(materialInput);\n material.diffuse = 1.5 * color.rgb;\n vec2 st = materialInput.st;\n vec3 str = materialInput.str;\n float dis = distance(st, vec2(0.5, 0.5));\n float per = fract(time);\n if (abs(str.z) > 0.001) {\n discard;\n }\n if (dis > 0.5) {\n discard;\n } else {\n float perDis = 0.5 / count;\n float disNum;\n float bl = .0;\n for (int i = 0; i <= 9; i++) {\n if (float(i) <= count) {\n disNum = perDis * float(i) - dis + per / count;\n if (disNum > 0.0) {\n if (disNum < perDis) {\n bl = 1.0 - disNum / perDis;\n } else if (disNum - perDis < perDis) {\n bl = 1.0 - abs(1.0 - disNum / perDis);\n }\n material.alpha = pow(bl, gradient);\n }\n }\n }\n }\n return material;\n}\n"; // 水波纹材质
29
28
  var CircleWaveMaterialProperty = /*#__PURE__*/function (_BaseMaterialProperty) {
30
29
  _inherits(CircleWaveMaterialProperty, _BaseMaterialProperty);
31
30
  var _super = _createSuper(CircleWaveMaterialProperty);
@@ -23,9 +23,8 @@ import { cloneDeep, isEqual, merge } from 'lodash';
23
23
  import { DEFAULT_DYNAMIC_WALL_MATERIAL_STYLE } from "../constant";
24
24
  import * as utils from "../tool/utils";
25
25
  import BaseMaterialProperty from "./BaseMaterialProperty";
26
- import DynamicWallShader from "./shader/DynamicWallShader.glsl";
27
-
28
- // 动态墙材质
26
+ /* babel-plugin-inline-import './shader/DynamicWallShader.glsl' */
27
+ var DynamicWallShader = "czm_material czm_getMaterial(czm_materialInput materialInput)\n{\n czm_material material = czm_getDefaultMaterial(materialInput);\n vec2 st = materialInput.st;\n float vertical = 1.0;\n float directionAdd = 1.0;\n vec2 uv = vec2(0, 0);\n // \u5224\u65AD\u6392\u5217\u65B9\u5411\n if (freely == vertical) {\n // \u5224\u65AD\u8FD0\u52A8\u65B9\u5411\n if (direction == directionAdd) {\n uv = vec2(fract(st.s), fract(count * st.t + time));\n } else {\n uv = vec2(fract(st.s), fract(count * st.t - time));\n }\n } else {\n // \u5224\u65AD\u8FD0\u52A8\u65B9\u5411\n if (direction == directionAdd) {\n uv = vec2(fract(count * st.s + time), fract(st.t));\n } else {\n uv = vec2(fract(count * st.s - time), fract(st.t));\n }\n }\n vec4 colorImage = texture(image, uv);\n vec3 mixedColor = mix(colorImage.rgb, color.rgb, mixRatio);\n vec4 fragColor;\n fragColor.rgb = mixedColor;\n fragColor = czm_gammaCorrect(fragColor);\n\n material.diffuse = mixedColor;\n material.alpha = colorImage.a * color.a; // \u53EF\u6839\u636E\u9700\u8981\u51B3\u5B9A\u662F\u5426\u76F8\u4E58\n material.emission = fragColor.rgb;\n\n return material;\n}\n"; // 动态墙材质
29
28
  var DynamicWallMaterialProperty = /*#__PURE__*/function (_BaseMaterialProperty) {
30
29
  _inherits(DynamicWallMaterialProperty, _BaseMaterialProperty);
31
30
  var _super = _createSuper(DynamicWallMaterialProperty);
@@ -23,9 +23,8 @@ import { cloneDeep, isEqual, merge } from 'lodash';
23
23
  import { DEFAULT_POLYLINE_TRAIL_LINK_MATERIAL_STYLE } from "../constant";
24
24
  import * as utils from "../tool/utils";
25
25
  import BaseMaterialProperty from "./BaseMaterialProperty";
26
- import PolylineTrailLinkShader from "./shader/PolylineTrailLinkShader.glsl";
27
-
28
- // 流动线材质
26
+ /* babel-plugin-inline-import './shader/PolylineTrailLinkShader.glsl' */
27
+ var PolylineTrailLinkShader = "czm_material czm_getMaterial(czm_materialInput materialInput)\n{\n czm_material material = czm_getDefaultMaterial(materialInput);\n vec2 st = vec2(fract(materialInput.st.s * count - time), materialInput.st.t * 1.0);\n vec4 colorImage = texture(image, vec2(fract(st.s - time), st.t));\n material.alpha = colorImage.a * color.a;\n material.diffuse = mix(colorImage.rgb, color.rgb, mixRatio);\n return material;\n}\n"; // 流动线材质
29
28
  var PolylineTrailLinkMaterialProperty = /*#__PURE__*/function (_BaseMaterialProperty) {
30
29
  _inherits(PolylineTrailLinkMaterialProperty, _BaseMaterialProperty);
31
30
  var _super = _createSuper(PolylineTrailLinkMaterialProperty);
@@ -9,9 +9,12 @@ import * as Cesium from 'deeptwins-cesium';
9
9
  import { merge } from 'lodash';
10
10
  import { DEFAULT_FOG, DEFAULT_RAIN, DEFAULT_SNOW } from "../constant";
11
11
  import { colorString, toRadians } from "../tool/utils";
12
- import FogShader from "./shader/FogShader.glsl";
13
- import RainShader from "./shader/RainShader.glsl";
14
- import SnowShader from "./shader/SnowShader.glsl";
12
+ /* babel-plugin-inline-import './shader/FogShader.glsl' */
13
+ 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
+ /* 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 vec3 c = vec3(0.6, 0.7, 0.8);\n float a = direction;\n float si = sin(a), co = cos(a);\n uv *= mat2(co, -si, si, co);\n uv *= length(uv + vec2(0.0, 4.9)) * size + 1.0;\n float v = 1.0 - sin(hash(floor(uv.x * 100.0)) * 2.0);\n float b = clamp(abs(sin(20.0 * time * v + uv.y * (5.0 / (2.0 + v)))) - 0.95, 0.0, 1.0) * 20.0;\n c *= v * b;\n\n fragColor = mix(texture(colorTexture, v_textureCoordinates), vec4(c, 1.0), 0.5);\n}\n";
16
+ /* babel-plugin-inline-import './shader/SnowShader.glsl' */
17
+ 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";
15
18
  var WeatherEffects = /*#__PURE__*/function () {
16
19
  function WeatherEffects(type) {
17
20
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deeptwins-engine-3d",
3
- "version": "0.0.44",
3
+ "version": "0.0.45",
4
4
  "description": "map for 3d",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -66,6 +66,7 @@
66
66
  "@typescript-eslint/parser": "^6.0.0",
67
67
  "@umijs/lint": "^4.0.0",
68
68
  "babel-loader": "^9.2.1",
69
+ "babel-plugin-inline-import": "^3.0.0",
69
70
  "copy-webpack-plugin": "^12.0.2",
70
71
  "dumi": "^2.4.13",
71
72
  "eslint": "^8.57.1",