deeptwins-engine-3d 0.0.42 → 0.0.44
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/cameraControl/ModelRoamHistory.d.ts +11 -3
- package/dist/cameraControl/ModelRoamHistory.js +101 -27
- package/dist/cameraControl/ModelRoamRealTime.d.ts +23 -47
- package/dist/cameraControl/ModelRoamRealTime.js +210 -374
- package/dist/constant.d.ts +6 -1
- package/dist/constant.js +38 -20
- package/dist/deepTwins/index.d.ts +0 -3
- package/dist/deepTwins/index.js +2 -18
- package/dist/drawer/base.js +1 -1
- package/dist/drawer/index.js +1 -1
- package/dist/graphicLayer/BaseLayer.d.ts +1 -1
- package/dist/graphicLayer/BaseLayer.js +1 -1
- package/dist/graphicLayer/BaseSource.d.ts +1 -1
- package/dist/graphicLayer/BaseSource.js +4 -6
- package/dist/graphicLayer/GraphicLayerCollection.d.ts +3 -2
- package/dist/graphicLayer/GraphicLayerCollection.js +33 -40
- package/dist/graphicLayer/PolylinePrimitiveInstance.js +2 -6
- package/dist/index.d.ts +0 -2
- package/dist/index.js +1 -5
- package/dist/map/Map.d.ts +1 -1
- package/dist/map/Map.js +12 -6
- package/dist/material/BaseMaterialProperty.d.ts +12 -0
- package/dist/material/BaseMaterialProperty.js +51 -0
- package/dist/material/CircleWaveMaterialProperty.d.ts +6 -14
- package/dist/material/CircleWaveMaterialProperty.js +63 -71
- package/dist/material/DynamicWallMaterialProperty.d.ts +6 -42
- package/dist/material/DynamicWallMaterialProperty.js +61 -123
- package/dist/material/PolylineTrailLinkMaterialProperty.d.ts +6 -16
- package/dist/material/PolylineTrailLinkMaterialProperty.js +59 -65
- package/dist/material/WeatherEffects.js +6 -6
- package/dist/material/shader/CircleWaveShader.glsl +32 -0
- package/dist/material/shader/DynamicWallShader.glsl +35 -0
- package/dist/material/shader/FogShader.glsl +48 -0
- package/dist/material/shader/PolylineTrailLinkShader.glsl +9 -0
- package/dist/material/shader/RainShader.glsl +28 -0
- package/dist/material/shader/SnowShader.glsl +48 -0
- package/dist/typings.d.ts +4 -0
- package/package.json +5 -3
- package/dist/cameraControl/ModelRoamRunTime.d.ts +0 -32
- package/dist/cameraControl/ModelRoamRunTime.js +0 -244
- package/dist/material/ImageMaterial.d.ts +0 -4
- package/dist/material/ImageMaterial.js +0 -35
|
@@ -1,102 +1,96 @@
|
|
|
1
|
+
var _excluded = ["duration"],
|
|
2
|
+
_excluded2 = ["color", "count"];
|
|
1
3
|
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); }
|
|
4
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
5
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
6
|
+
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; }
|
|
7
|
+
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
8
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
9
|
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
10
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
11
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
12
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
13
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
14
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
15
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
16
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
17
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
5
18
|
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; }
|
|
6
19
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
20
|
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
21
|
import * as Cesium from 'deeptwins-cesium';
|
|
9
|
-
import {
|
|
22
|
+
import { cloneDeep, isEqual, merge } from 'lodash';
|
|
23
|
+
import { DEFAULT_POLYLINE_TRAIL_LINK_MATERIAL_STYLE } from "../constant";
|
|
10
24
|
import * as utils from "../tool/utils";
|
|
11
|
-
|
|
12
|
-
|
|
25
|
+
import BaseMaterialProperty from "./BaseMaterialProperty";
|
|
26
|
+
import PolylineTrailLinkShader from "./shader/PolylineTrailLinkShader.glsl";
|
|
27
|
+
|
|
28
|
+
// 流动线材质
|
|
29
|
+
var PolylineTrailLinkMaterialProperty = /*#__PURE__*/function (_BaseMaterialProperty) {
|
|
30
|
+
_inherits(PolylineTrailLinkMaterialProperty, _BaseMaterialProperty);
|
|
31
|
+
var _super = _createSuper(PolylineTrailLinkMaterialProperty);
|
|
32
|
+
function PolylineTrailLinkMaterialProperty(style) {
|
|
33
|
+
var _this;
|
|
13
34
|
_classCallCheck(this, PolylineTrailLinkMaterialProperty);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
_defineProperty(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
_defineProperty(this, "image", void 0);
|
|
21
|
-
_defineProperty(this, "count", void 0);
|
|
22
|
-
_defineProperty(this, "materialType", void 0);
|
|
23
|
-
this.materialType = 'PolylineTrailLink' + uuidv4();
|
|
24
|
-
this._definitionChanged = new Cesium.Event();
|
|
25
|
-
this.color = utils.colorString(options.color) || Cesium.Color.BLUE;
|
|
26
|
-
this.mixRatio = options.mixRatio || 0.5;
|
|
27
|
-
this.duration = options.duration || 2;
|
|
28
|
-
this.count = options.count || 1;
|
|
29
|
-
this.image = options.image || utils.getDeepTwinsFile('Image/line.png');
|
|
30
|
-
this._time = new Date().getTime();
|
|
31
|
-
this._init();
|
|
35
|
+
var mergeStyle = merge(DEFAULT_POLYLINE_TRAIL_LINK_MATERIAL_STYLE(), cloneDeep(style || {}));
|
|
36
|
+
_this = _super.call(this, 'PolylineTrailLink', mergeStyle);
|
|
37
|
+
_defineProperty(_assertThisInitialized(_this), "currStyle", void 0);
|
|
38
|
+
_this.currStyle = PolylineTrailLinkMaterialProperty.handleStyle(mergeStyle);
|
|
39
|
+
_this._init();
|
|
40
|
+
return _this;
|
|
32
41
|
}
|
|
42
|
+
|
|
43
|
+
// 处理参数
|
|
33
44
|
_createClass(PolylineTrailLinkMaterialProperty, [{
|
|
34
45
|
key: "_init",
|
|
35
46
|
value: function _init() {
|
|
36
47
|
// @ts-ignore
|
|
37
|
-
Cesium.Material._materialCache.addMaterial(this.
|
|
48
|
+
Cesium.Material._materialCache.addMaterial(this.type, {
|
|
38
49
|
fabric: {
|
|
39
|
-
type: this.
|
|
40
|
-
uniforms: {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
time: 0,
|
|
45
|
-
mixRatio: this.mixRatio
|
|
46
|
-
},
|
|
47
|
-
source: this.getShader()
|
|
50
|
+
type: this.type,
|
|
51
|
+
uniforms: _objectSpread(_objectSpread({}, this.currStyle), {}, {
|
|
52
|
+
time: this._time
|
|
53
|
+
}),
|
|
54
|
+
source: PolylineTrailLinkShader
|
|
48
55
|
},
|
|
49
56
|
translucent: function translucent() {
|
|
50
57
|
return true;
|
|
51
58
|
}
|
|
52
59
|
});
|
|
53
60
|
}
|
|
54
|
-
}, {
|
|
55
|
-
key: "isConstant",
|
|
56
|
-
get: function get() {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
}, {
|
|
60
|
-
key: "definitionChanged",
|
|
61
|
-
get: function get() {
|
|
62
|
-
return this._definitionChanged;
|
|
63
|
-
}
|
|
64
|
-
}, {
|
|
65
|
-
key: "getType",
|
|
66
|
-
value: function getType() {
|
|
67
|
-
return this.materialType;
|
|
68
|
-
}
|
|
69
61
|
}, {
|
|
70
62
|
key: "getValue",
|
|
71
63
|
value: function getValue(time, result) {
|
|
64
|
+
var _Object$keys;
|
|
72
65
|
if (!Cesium.defined(result)) {
|
|
73
66
|
result = {};
|
|
74
67
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
68
|
+
var _this$currStyle = this.currStyle,
|
|
69
|
+
duration = _this$currStyle.duration,
|
|
70
|
+
options = _objectWithoutProperties(_this$currStyle, _excluded);
|
|
71
|
+
(_Object$keys = Object.keys(options)) === null || _Object$keys === void 0 || _Object$keys.forEach(function (key) {
|
|
72
|
+
result[key] = options[key];
|
|
73
|
+
});
|
|
74
|
+
result.time = (new Date().getTime() - this._time) % (duration * 1000) / (duration * 1000);
|
|
81
75
|
return result;
|
|
82
76
|
}
|
|
83
77
|
}, {
|
|
84
78
|
key: "equals",
|
|
85
79
|
value: function equals(other) {
|
|
86
|
-
return
|
|
87
|
-
// @ts-ignore
|
|
88
|
-
Cesium.Property.equals(this._color, other._color) && this.duration === other.duration && this.count === other.count && this.image === other.image && this.mixRatio === other.mixRatio;
|
|
80
|
+
return other instanceof PolylineTrailLinkMaterialProperty && isEqual(this.style, other.style);
|
|
89
81
|
}
|
|
90
|
-
}, {
|
|
91
|
-
key: "
|
|
92
|
-
value: function
|
|
93
|
-
|
|
82
|
+
}], [{
|
|
83
|
+
key: "handleStyle",
|
|
84
|
+
value: function handleStyle(style) {
|
|
85
|
+
var color = style.color,
|
|
86
|
+
count = style.count,
|
|
87
|
+
options = _objectWithoutProperties(style, _excluded2);
|
|
88
|
+
var backStyle = _objectSpread({}, options);
|
|
89
|
+
backStyle.color = utils.colorString(color);
|
|
90
|
+
backStyle.count = count <= 0 ? 1 : count;
|
|
91
|
+
return backStyle;
|
|
94
92
|
}
|
|
95
93
|
}]);
|
|
96
94
|
return PolylineTrailLinkMaterialProperty;
|
|
97
|
-
}();
|
|
98
|
-
export { PolylineTrailLinkMaterialProperty as default };
|
|
99
|
-
Object.defineProperties(PolylineTrailLinkMaterialProperty.prototype, {
|
|
100
|
-
// @ts-ignore
|
|
101
|
-
color: Cesium.createPropertyDescriptor('color')
|
|
102
|
-
});
|
|
95
|
+
}(BaseMaterialProperty);
|
|
96
|
+
export { PolylineTrailLinkMaterialProperty as default };
|
|
@@ -9,9 +9,9 @@ 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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
import FogShader from "./shader/FogShader.glsl";
|
|
13
|
+
import RainShader from "./shader/RainShader.glsl";
|
|
14
|
+
import SnowShader from "./shader/SnowShader.glsl";
|
|
15
15
|
var WeatherEffects = /*#__PURE__*/function () {
|
|
16
16
|
function WeatherEffects(type) {
|
|
17
17
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -93,7 +93,7 @@ var WeatherEffects = /*#__PURE__*/function () {
|
|
|
93
93
|
key: "_snowEffect",
|
|
94
94
|
value: function _snowEffect(options) {
|
|
95
95
|
this.stage = new Cesium.PostProcessStage({
|
|
96
|
-
fragmentShader:
|
|
96
|
+
fragmentShader: SnowShader,
|
|
97
97
|
uniforms: this._handleSnowOptions(options)
|
|
98
98
|
});
|
|
99
99
|
}
|
|
@@ -123,7 +123,7 @@ var WeatherEffects = /*#__PURE__*/function () {
|
|
|
123
123
|
key: "_rainEffect",
|
|
124
124
|
value: function _rainEffect(options) {
|
|
125
125
|
this.stage = new Cesium.PostProcessStage({
|
|
126
|
-
fragmentShader:
|
|
126
|
+
fragmentShader: RainShader,
|
|
127
127
|
uniforms: this._handleRainOptions(options)
|
|
128
128
|
});
|
|
129
129
|
}
|
|
@@ -149,7 +149,7 @@ var WeatherEffects = /*#__PURE__*/function () {
|
|
|
149
149
|
key: "_fogEffect",
|
|
150
150
|
value: function _fogEffect(options) {
|
|
151
151
|
this.stage = new Cesium.PostProcessStage({
|
|
152
|
-
fragmentShader:
|
|
152
|
+
fragmentShader: FogShader,
|
|
153
153
|
uniforms: this._handleFogOptions(options)
|
|
154
154
|
});
|
|
155
155
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
czm_material czm_getMaterial(czm_materialInput materialInput) {
|
|
2
|
+
czm_material material = czm_getDefaultMaterial(materialInput);
|
|
3
|
+
material.diffuse = 1.5 * color.rgb;
|
|
4
|
+
vec2 st = materialInput.st;
|
|
5
|
+
vec3 str = materialInput.str;
|
|
6
|
+
float dis = distance(st, vec2(0.5, 0.5));
|
|
7
|
+
float per = fract(time);
|
|
8
|
+
if (abs(str.z) > 0.001) {
|
|
9
|
+
discard;
|
|
10
|
+
}
|
|
11
|
+
if (dis > 0.5) {
|
|
12
|
+
discard;
|
|
13
|
+
} else {
|
|
14
|
+
float perDis = 0.5 / count;
|
|
15
|
+
float disNum;
|
|
16
|
+
float bl = .0;
|
|
17
|
+
for (int i = 0; i <= 9; i++) {
|
|
18
|
+
if (float(i) <= count) {
|
|
19
|
+
disNum = perDis * float(i) - dis + per / count;
|
|
20
|
+
if (disNum > 0.0) {
|
|
21
|
+
if (disNum < perDis) {
|
|
22
|
+
bl = 1.0 - disNum / perDis;
|
|
23
|
+
} else if (disNum - perDis < perDis) {
|
|
24
|
+
bl = 1.0 - abs(1.0 - disNum / perDis);
|
|
25
|
+
}
|
|
26
|
+
material.alpha = pow(bl, gradient);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return material;
|
|
32
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
czm_material czm_getMaterial(czm_materialInput materialInput)
|
|
2
|
+
{
|
|
3
|
+
czm_material material = czm_getDefaultMaterial(materialInput);
|
|
4
|
+
vec2 st = materialInput.st;
|
|
5
|
+
float vertical = 1.0;
|
|
6
|
+
float directionAdd = 1.0;
|
|
7
|
+
vec2 uv = vec2(0, 0);
|
|
8
|
+
// 判断排列方向
|
|
9
|
+
if (freely == vertical) {
|
|
10
|
+
// 判断运动方向
|
|
11
|
+
if (direction == directionAdd) {
|
|
12
|
+
uv = vec2(fract(st.s), fract(count * st.t + time));
|
|
13
|
+
} else {
|
|
14
|
+
uv = vec2(fract(st.s), fract(count * st.t - time));
|
|
15
|
+
}
|
|
16
|
+
} else {
|
|
17
|
+
// 判断运动方向
|
|
18
|
+
if (direction == directionAdd) {
|
|
19
|
+
uv = vec2(fract(count * st.s + time), fract(st.t));
|
|
20
|
+
} else {
|
|
21
|
+
uv = vec2(fract(count * st.s - time), fract(st.t));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
vec4 colorImage = texture(image, uv);
|
|
25
|
+
vec3 mixedColor = mix(colorImage.rgb, color.rgb, mixRatio);
|
|
26
|
+
vec4 fragColor;
|
|
27
|
+
fragColor.rgb = mixedColor;
|
|
28
|
+
fragColor = czm_gammaCorrect(fragColor);
|
|
29
|
+
|
|
30
|
+
material.diffuse = mixedColor;
|
|
31
|
+
material.alpha = colorImage.a * color.a; // 可根据需要决定是否相乘
|
|
32
|
+
material.emission = fragColor.rgb;
|
|
33
|
+
|
|
34
|
+
return material;
|
|
35
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
float getDistance(sampler2D depthTexture, vec2 texCoords)
|
|
2
|
+
{
|
|
3
|
+
float depth = czm_unpackDepth(texture(depthTexture, texCoords));
|
|
4
|
+
if (depth == 0.0) {
|
|
5
|
+
return czm_infinity;
|
|
6
|
+
}
|
|
7
|
+
vec4 eyeCoordinate = czm_windowToEyeCoordinates(gl_FragCoord.xy, depth);
|
|
8
|
+
return -eyeCoordinate.z / eyeCoordinate.w;
|
|
9
|
+
}
|
|
10
|
+
//根据距离,在中间进行插值
|
|
11
|
+
float interpolateByDistance(vec4 nearFarScalar, float distance)
|
|
12
|
+
{
|
|
13
|
+
//根据常识,雾应该是距离远,越看不清,近距离内的物体可以看清
|
|
14
|
+
//因此近距离alpha=0,远距离的alpha=1.0
|
|
15
|
+
//本例中设置可见度为200米
|
|
16
|
+
//雾特效的起始距离
|
|
17
|
+
float startDistance = nearFarScalar.x;
|
|
18
|
+
//雾特效的起始alpha值
|
|
19
|
+
float startValue = nearFarScalar.y;
|
|
20
|
+
//雾特效的结束距离
|
|
21
|
+
float endDistance = nearFarScalar.z;
|
|
22
|
+
//雾特效的结束alpha值
|
|
23
|
+
float endValue = nearFarScalar.w;
|
|
24
|
+
//根据每段距离占总长度的占比,插值alpha,距离越远,alpha值越大。插值范围0,1。
|
|
25
|
+
float t = clamp((distance - startDistance) / (endDistance - startDistance), 0.0, 1.0);
|
|
26
|
+
return mix(startValue, endValue, t);
|
|
27
|
+
}
|
|
28
|
+
vec4 alphaBlend(vec4 sourceColor, vec4 destinationColor)
|
|
29
|
+
{
|
|
30
|
+
return sourceColor * vec4(sourceColor.aaa, 1.0) + destinationColor * (1.0 - sourceColor.a);
|
|
31
|
+
}
|
|
32
|
+
uniform sampler2D colorTexture;
|
|
33
|
+
uniform sampler2D depthTexture;
|
|
34
|
+
uniform vec4 fogByDistance;
|
|
35
|
+
uniform vec4 fogColor;
|
|
36
|
+
in vec2 v_textureCoordinates;
|
|
37
|
+
void main(void)
|
|
38
|
+
{
|
|
39
|
+
//获取地物距相机的距离
|
|
40
|
+
float distance = getDistance(depthTexture, v_textureCoordinates);
|
|
41
|
+
//获取场景原本的纹理颜色
|
|
42
|
+
vec4 sceneColor = texture(colorTexture, v_textureCoordinates);
|
|
43
|
+
//根据距离,对alpha进行插值
|
|
44
|
+
float blendAmount = interpolateByDistance(fogByDistance, distance);
|
|
45
|
+
//将alpha变化值代入雾的原始颜色中,并将雾与场景原始纹理进行融合
|
|
46
|
+
vec4 finalFogColor = vec4(fogColor.rgb, fogColor.a * blendAmount);
|
|
47
|
+
out_FragColor = alphaBlend(finalFogColor, sceneColor);
|
|
48
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
czm_material czm_getMaterial(czm_materialInput materialInput)
|
|
2
|
+
{
|
|
3
|
+
czm_material material = czm_getDefaultMaterial(materialInput);
|
|
4
|
+
vec2 st = vec2(fract(materialInput.st.s * count - time), materialInput.st.t * 1.0);
|
|
5
|
+
vec4 colorImage = texture(image, vec2(fract(st.s - time), st.t));
|
|
6
|
+
material.alpha = colorImage.a * color.a;
|
|
7
|
+
material.diffuse = mix(colorImage.rgb, color.rgb, mixRatio);
|
|
8
|
+
return material;
|
|
9
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
precision highp float;
|
|
2
|
+
|
|
3
|
+
uniform sampler2D colorTexture;
|
|
4
|
+
uniform float direction;
|
|
5
|
+
uniform float size;
|
|
6
|
+
uniform float speed;
|
|
7
|
+
in vec2 v_textureCoordinates;
|
|
8
|
+
out vec4 fragColor;
|
|
9
|
+
|
|
10
|
+
float hash(float x) {
|
|
11
|
+
return fract(sin(x * 133.3) * 13.13);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
void main() {
|
|
15
|
+
float time = czm_frameNumber / speed;
|
|
16
|
+
vec2 resolution = czm_viewport.zw;
|
|
17
|
+
vec2 uv = (gl_FragCoord.xy * 2.0 - resolution) / min(resolution.x, resolution.y);
|
|
18
|
+
vec3 c = vec3(0.6, 0.7, 0.8);
|
|
19
|
+
float a = direction;
|
|
20
|
+
float si = sin(a), co = cos(a);
|
|
21
|
+
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
|
+
|
|
27
|
+
fragColor = mix(texture(colorTexture, v_textureCoordinates), vec4(c, 1.0), 0.5);
|
|
28
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
precision highp float;
|
|
2
|
+
|
|
3
|
+
uniform sampler2D colorTexture;
|
|
4
|
+
uniform float speed;
|
|
5
|
+
uniform float size;
|
|
6
|
+
in vec2 v_textureCoordinates;
|
|
7
|
+
out vec4 fragColor;
|
|
8
|
+
|
|
9
|
+
float snow(vec2 uv, float sc) {
|
|
10
|
+
float scale = sc * size;
|
|
11
|
+
float time = float(czm_frameNumber) / speed;
|
|
12
|
+
float w = smoothstep(1.0, 0.0, -uv.y * (scale / 10.0));
|
|
13
|
+
if (w < 0.1) return 0.0;
|
|
14
|
+
uv += time / scale;
|
|
15
|
+
uv.y += time * 2.0 / scale;
|
|
16
|
+
uv.x += sin(uv.y + time * 0.5) / scale;
|
|
17
|
+
uv *= scale;
|
|
18
|
+
vec2 s = floor(uv), f = fract(uv), p;
|
|
19
|
+
float k = 3.0, d;
|
|
20
|
+
p = 0.5 + 0.35 * sin(11.0 * fract(sin((s + p + scale) * mat2(7, 3, 6, 5)) * 5.0)) - f;
|
|
21
|
+
d = length(p);
|
|
22
|
+
k = min(d, k);
|
|
23
|
+
k = smoothstep(0.0, k, sin(f.x + f.y) * 0.01);
|
|
24
|
+
return k * w;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
void main() {
|
|
28
|
+
vec2 resolution = czm_viewport.zw;
|
|
29
|
+
vec2 uv = (gl_FragCoord.xy * 2.0 - resolution.xy) / min(resolution.x, resolution.y);
|
|
30
|
+
vec3 finalColor = vec3(0.0);
|
|
31
|
+
float c = 0.0;
|
|
32
|
+
c += snow(uv, 10.);
|
|
33
|
+
c += snow(uv, 8.);
|
|
34
|
+
c += snow(uv, 7.);
|
|
35
|
+
c += snow(uv, 6.);
|
|
36
|
+
c += snow(uv, 5.);
|
|
37
|
+
c += snow(uv, 4.);
|
|
38
|
+
c += snow(uv, 3.);
|
|
39
|
+
c += snow(uv, 2.);
|
|
40
|
+
c += snow(uv, 1.);
|
|
41
|
+
c += snow(uv, .6);
|
|
42
|
+
finalColor = vec3(c);
|
|
43
|
+
|
|
44
|
+
// 调整亮度
|
|
45
|
+
finalColor = finalColor * 2.2;
|
|
46
|
+
|
|
47
|
+
fragColor = mix(texture(colorTexture, v_textureCoordinates), vec4(finalColor, 1.0), 0.2);
|
|
48
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "deeptwins-engine-3d",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.44",
|
|
4
4
|
"description": "map for 3d",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -72,6 +72,7 @@
|
|
|
72
72
|
"eslint-config-prettier": "^9.1.0",
|
|
73
73
|
"eslint-plugin-prettier": "^4.2.1",
|
|
74
74
|
"father": "^4.1.0",
|
|
75
|
+
"glslify": "^7.1.1",
|
|
75
76
|
"gulp": "^5.0.0",
|
|
76
77
|
"husky": "^8.0.1",
|
|
77
78
|
"lint-staged": "^13.0.3",
|
|
@@ -79,6 +80,7 @@
|
|
|
79
80
|
"prettier-eslint": "^16.3.0",
|
|
80
81
|
"prettier-plugin-organize-imports": "^3.0.0",
|
|
81
82
|
"prettier-plugin-packagejson": "^2.2.18",
|
|
83
|
+
"raw-loader": "^4.0.2",
|
|
82
84
|
"react": "^18.0.0",
|
|
83
85
|
"react-dom": "^18.0.0",
|
|
84
86
|
"stylelint": "^14.9.1",
|
|
@@ -91,13 +93,13 @@
|
|
|
91
93
|
"@turf/random": "^6.5.0",
|
|
92
94
|
"@turf/turf": "^6.5.0",
|
|
93
95
|
"@turf/voronoi": "^6.5.0",
|
|
96
|
+
"beidou-grid-location-codec": "^1.1.12",
|
|
94
97
|
"deeptwins-cesium": "0.0.21",
|
|
95
98
|
"heatmap.js": "^2.0.5",
|
|
96
99
|
"hls.js": "^1.5.20",
|
|
97
100
|
"kdbush": "^4.0.2",
|
|
98
101
|
"lodash": "^4.17.21",
|
|
99
102
|
"uuid": "^11.0.3",
|
|
100
|
-
"wellknown": "^0.5.0"
|
|
101
|
-
"beidou-grid-location-codec": "^1.1.12"
|
|
103
|
+
"wellknown": "^0.5.0"
|
|
102
104
|
}
|
|
103
105
|
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export default class ModelRoamRunTime {
|
|
2
|
-
polylineLayer: any;
|
|
3
|
-
polylineEntity: any;
|
|
4
|
-
polylineOptions: any;
|
|
5
|
-
modelLayer: any;
|
|
6
|
-
modelEntity: any;
|
|
7
|
-
modelOptions: any;
|
|
8
|
-
startPosition: any;
|
|
9
|
-
positionProperty: any;
|
|
10
|
-
isFlyTo: any;
|
|
11
|
-
clampToGround: boolean;
|
|
12
|
-
timeDiff: number;
|
|
13
|
-
status: string;
|
|
14
|
-
private _map;
|
|
15
|
-
private readonly _eventRunning;
|
|
16
|
-
private _startTime;
|
|
17
|
-
private _positions;
|
|
18
|
-
private _positionsCartesian3;
|
|
19
|
-
private _path;
|
|
20
|
-
private _listenScene;
|
|
21
|
-
private _listenRunning;
|
|
22
|
-
constructor(map: any, options?: any);
|
|
23
|
-
private _init;
|
|
24
|
-
updatePosition(position: any): void;
|
|
25
|
-
setFollowFirst(distance?: number): void;
|
|
26
|
-
setFollowThird(): void;
|
|
27
|
-
cancelFollow(): void;
|
|
28
|
-
on(type: any, event: any): any;
|
|
29
|
-
updatePolyline(style: any): void;
|
|
30
|
-
updateModel(style: any): void;
|
|
31
|
-
destroy(): void;
|
|
32
|
-
}
|