deeptwins-engine-3d 0.1.12 → 0.1.14
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/cameraControl/ModelRoamRealTime.d.ts +0 -1
- package/dist/esm/cameraControl/ModelRoamRealTime.js +2 -15
- package/dist/esm/constant.d.ts +11 -0
- package/dist/esm/constant.js +26 -2
- package/dist/esm/graphicLayer/BaseLayer.js +8 -0
- package/dist/esm/graphicLayer/PolygonGroundPrimitive.d.ts +5 -0
- package/dist/esm/graphicLayer/PolygonGroundPrimitive.js +49 -0
- package/dist/esm/graphicLayer/PolylineGroundPrimitive.d.ts +5 -0
- package/dist/esm/graphicLayer/PolylineGroundPrimitive.js +55 -0
- package/dist/esm/graphicLayer/PolylineGroundPrimitiveInstance.d.ts +7 -0
- package/dist/esm/graphicLayer/PolylineGroundPrimitiveInstance.js +89 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +5 -1
- package/dist/esm/map/Map.js +1 -1
- package/dist/esm/material/ImageGlowingMaterialProperty.d.ts +10 -0
- package/dist/esm/material/ImageGlowingMaterialProperty.js +87 -0
- package/dist/esm/material/VolumeCloud.d.ts +16 -0
- package/dist/esm/material/VolumeCloud.js +115 -0
- package/dist/esm/material/shader/ImageGlowingShader.glsl +23 -0
- package/dist/umd/deeptwins-engine-3d.min.js +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
var _excluded = ["polygon", "number", "heightRange"];
|
|
2
|
+
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); }
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
5
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6
|
+
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
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
8
|
+
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; }
|
|
9
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
10
|
+
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); }
|
|
11
|
+
import { bbox, randomPoint } from '@turf/turf';
|
|
12
|
+
import * as Cesium from 'deeptwins-cesium';
|
|
13
|
+
import { merge } from 'lodash';
|
|
14
|
+
import { DEFAULT_VOLUME_CLOUD } from "../constant";
|
|
15
|
+
import BaseSource from "../graphicLayer/BaseSource";
|
|
16
|
+
import * as utils from "../tool/utils";
|
|
17
|
+
var VolumeCloud = /*#__PURE__*/function () {
|
|
18
|
+
function VolumeCloud(map, _ref) {
|
|
19
|
+
var polygon = _ref.polygon,
|
|
20
|
+
_ref$number = _ref.number,
|
|
21
|
+
number = _ref$number === void 0 ? 10 : _ref$number,
|
|
22
|
+
_ref$heightRange = _ref.heightRange,
|
|
23
|
+
heightRange = _ref$heightRange === void 0 ? [2000, 3000] : _ref$heightRange,
|
|
24
|
+
options = _objectWithoutProperties(_ref, _excluded);
|
|
25
|
+
_classCallCheck(this, VolumeCloud);
|
|
26
|
+
_defineProperty(this, "_mapContext", void 0);
|
|
27
|
+
_defineProperty(this, "_polygon", void 0);
|
|
28
|
+
_defineProperty(this, "isDestroyed", false);
|
|
29
|
+
_defineProperty(this, "_pointGeoJson", void 0);
|
|
30
|
+
_defineProperty(this, "_options", void 0);
|
|
31
|
+
_defineProperty(this, "_clouds", void 0);
|
|
32
|
+
this._mapContext = map._mapContext;
|
|
33
|
+
this._polygon = polygon;
|
|
34
|
+
var randomPoints = randomPoint(number, {
|
|
35
|
+
bbox: bbox(polygon)
|
|
36
|
+
});
|
|
37
|
+
randomPoints.features.forEach(function (feature) {
|
|
38
|
+
feature.geometry.coordinates.push(Math.random() * (heightRange[1] - heightRange[0]) + heightRange[0]);
|
|
39
|
+
});
|
|
40
|
+
this._pointGeoJson = randomPoints;
|
|
41
|
+
this._options = merge(DEFAULT_VOLUME_CLOUD(), options);
|
|
42
|
+
this._init();
|
|
43
|
+
}
|
|
44
|
+
_createClass(VolumeCloud, [{
|
|
45
|
+
key: "_init",
|
|
46
|
+
value: function _init() {
|
|
47
|
+
var _this$_options = this._options,
|
|
48
|
+
show = _this$_options.show,
|
|
49
|
+
noiseDetail = _this$_options.noiseDetail,
|
|
50
|
+
noiseOffset = _this$_options.noiseOffset,
|
|
51
|
+
cloudWidth = _this$_options.cloudWidth,
|
|
52
|
+
cloudHeight = _this$_options.cloudHeight,
|
|
53
|
+
color = _this$_options.color,
|
|
54
|
+
slice = _this$_options.slice,
|
|
55
|
+
brightness = _this$_options.brightness;
|
|
56
|
+
this._clouds = this.getMap().scene.primitives.add(new Cesium.CloudCollection({
|
|
57
|
+
show: show,
|
|
58
|
+
noiseDetail: noiseDetail + Math.random(),
|
|
59
|
+
// @ts-ignore
|
|
60
|
+
noiseOffset: utils.arrCartesian3(noiseOffset.map(function (t) {
|
|
61
|
+
return t * Math.random();
|
|
62
|
+
}))
|
|
63
|
+
}));
|
|
64
|
+
var source = BaseSource.geoJsonToGeoCartesian3Array(this._pointGeoJson);
|
|
65
|
+
for (var i = 0; i < source.length; i++) {
|
|
66
|
+
var r = Math.random();
|
|
67
|
+
var position = source[i].positions;
|
|
68
|
+
this._clouds.add({
|
|
69
|
+
position: position,
|
|
70
|
+
scale: new Cesium.Cartesian2(cloudWidth * (0.8 + Math.random() * 0.4), cloudHeight * (0.8 + Math.random() * 0.4)),
|
|
71
|
+
maximumSize: new Cesium.Cartesian3(5 + r * 15, 4 + r * 10, 3 + r * 5),
|
|
72
|
+
slice: slice + Math.random() * 0.3,
|
|
73
|
+
// 调整切分比例范围
|
|
74
|
+
brightness: brightness + Math.random() * 0.4,
|
|
75
|
+
// 亮度变化范围
|
|
76
|
+
color: utils.colorString(color)
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}, {
|
|
81
|
+
key: "getMap",
|
|
82
|
+
value: function getMap() {
|
|
83
|
+
return this._mapContext && this._mapContext.getMap();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// 是否能进行操作
|
|
87
|
+
}, {
|
|
88
|
+
key: "_canOperate",
|
|
89
|
+
value: function _canOperate() {
|
|
90
|
+
if (this.isDestroyed) {
|
|
91
|
+
utils.error('VolumeCloud实例已销毁');
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// 显示隐藏
|
|
98
|
+
}, {
|
|
99
|
+
key: "show",
|
|
100
|
+
value: function show(isShow) {
|
|
101
|
+
this._clouds.show = isShow;
|
|
102
|
+
}
|
|
103
|
+
}, {
|
|
104
|
+
key: "destroy",
|
|
105
|
+
value: function destroy() {
|
|
106
|
+
if (!this._canOperate()) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
this.isDestroyed = true;
|
|
110
|
+
this.getMap().scene.primitives.remove(this._clouds);
|
|
111
|
+
}
|
|
112
|
+
}]);
|
|
113
|
+
return VolumeCloud;
|
|
114
|
+
}();
|
|
115
|
+
export default VolumeCloud;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
uniform sampler2D image;
|
|
2
|
+
uniform float glowStrength;
|
|
3
|
+
uniform vec4 color;
|
|
4
|
+
uniform float mixRatio;
|
|
5
|
+
|
|
6
|
+
czm_material czm_getMaterial(czm_materialInput materialInput) {
|
|
7
|
+
czm_material material = czm_getDefaultMaterial(materialInput);
|
|
8
|
+
vec2 st = materialInput.st;
|
|
9
|
+
|
|
10
|
+
// 采样图片
|
|
11
|
+
vec4 texColor = texture(image, st);
|
|
12
|
+
|
|
13
|
+
// 颜色混合:mix(原始颜色, 目标颜色, mixRatio)
|
|
14
|
+
vec3 mixedColor = mix(texColor.rgb, texColor.rgb * color.rgb, mixRatio);
|
|
15
|
+
|
|
16
|
+
// 发光增强
|
|
17
|
+
material.diffuse = mixedColor * glowStrength;
|
|
18
|
+
|
|
19
|
+
// 透明度随颜色变化
|
|
20
|
+
material.alpha = texColor.a * mix(color.a, 1.0, 1.0 - mixRatio);
|
|
21
|
+
|
|
22
|
+
return material;
|
|
23
|
+
}
|