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.
Files changed (42) hide show
  1. package/dist/cameraControl/ModelRoamHistory.d.ts +11 -3
  2. package/dist/cameraControl/ModelRoamHistory.js +101 -27
  3. package/dist/cameraControl/ModelRoamRealTime.d.ts +23 -47
  4. package/dist/cameraControl/ModelRoamRealTime.js +210 -374
  5. package/dist/constant.d.ts +6 -1
  6. package/dist/constant.js +38 -20
  7. package/dist/deepTwins/index.d.ts +0 -3
  8. package/dist/deepTwins/index.js +2 -18
  9. package/dist/drawer/base.js +1 -1
  10. package/dist/drawer/index.js +1 -1
  11. package/dist/graphicLayer/BaseLayer.d.ts +1 -1
  12. package/dist/graphicLayer/BaseLayer.js +1 -1
  13. package/dist/graphicLayer/BaseSource.d.ts +1 -1
  14. package/dist/graphicLayer/BaseSource.js +4 -6
  15. package/dist/graphicLayer/GraphicLayerCollection.d.ts +3 -2
  16. package/dist/graphicLayer/GraphicLayerCollection.js +33 -40
  17. package/dist/graphicLayer/PolylinePrimitiveInstance.js +2 -6
  18. package/dist/index.d.ts +0 -2
  19. package/dist/index.js +1 -5
  20. package/dist/map/Map.d.ts +1 -1
  21. package/dist/map/Map.js +12 -6
  22. package/dist/material/BaseMaterialProperty.d.ts +12 -0
  23. package/dist/material/BaseMaterialProperty.js +51 -0
  24. package/dist/material/CircleWaveMaterialProperty.d.ts +6 -14
  25. package/dist/material/CircleWaveMaterialProperty.js +63 -71
  26. package/dist/material/DynamicWallMaterialProperty.d.ts +6 -42
  27. package/dist/material/DynamicWallMaterialProperty.js +61 -123
  28. package/dist/material/PolylineTrailLinkMaterialProperty.d.ts +6 -16
  29. package/dist/material/PolylineTrailLinkMaterialProperty.js +59 -65
  30. package/dist/material/WeatherEffects.js +6 -6
  31. package/dist/material/shader/CircleWaveShader.glsl +32 -0
  32. package/dist/material/shader/DynamicWallShader.glsl +35 -0
  33. package/dist/material/shader/FogShader.glsl +48 -0
  34. package/dist/material/shader/PolylineTrailLinkShader.glsl +9 -0
  35. package/dist/material/shader/RainShader.glsl +28 -0
  36. package/dist/material/shader/SnowShader.glsl +48 -0
  37. package/dist/typings.d.ts +4 -0
  38. package/package.json +5 -3
  39. package/dist/cameraControl/ModelRoamRunTime.d.ts +0 -32
  40. package/dist/cameraControl/ModelRoamRunTime.js +0 -244
  41. package/dist/material/ImageMaterial.d.ts +0 -4
  42. package/dist/material/ImageMaterial.js +0 -35
@@ -1,108 +1,100 @@
1
+ var _excluded = ["duration", "gradient"],
2
+ _excluded2 = ["color", "count", "gradient"];
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 { v4 as uuidv4 } from 'uuid';
22
+ import { cloneDeep, isEqual, merge } from 'lodash';
23
+ import { DEFAULT_CIRCLE_WAVE_MATERIAL_STYLE } from "../constant";
10
24
  import * as utils from "../tool/utils";
11
- var CircleWaveMaterialProperty = /*#__PURE__*/function () {
12
- function CircleWaveMaterialProperty(options) {
25
+ import BaseMaterialProperty from "./BaseMaterialProperty";
26
+ import CircleWaveShader from "./shader/CircleWaveShader.glsl";
27
+
28
+ // 水波纹材质
29
+ var CircleWaveMaterialProperty = /*#__PURE__*/function (_BaseMaterialProperty) {
30
+ _inherits(CircleWaveMaterialProperty, _BaseMaterialProperty);
31
+ var _super = _createSuper(CircleWaveMaterialProperty);
32
+ function CircleWaveMaterialProperty(style) {
33
+ var _this;
13
34
  _classCallCheck(this, CircleWaveMaterialProperty);
14
- _defineProperty(this, "_definitionChanged", new Cesium.Event());
15
- _defineProperty(this, "color", void 0);
16
- _defineProperty(this, "duration", void 0);
17
- _defineProperty(this, "count", void 0);
18
- _defineProperty(this, "gradient", void 0);
19
- _defineProperty(this, "time", void 0);
20
- _defineProperty(this, "materialType", void 0);
21
- this.materialType = 'CircleWaveMaterial' + uuidv4();
22
- this.color = utils.colorString(options.color) || Cesium.Color.BLUE;
23
- this.duration = options.duration || 2;
24
- this.count = options.count || 3;
25
- if (this.count <= 0) {
26
- this.count = 1;
27
- }
28
- this.gradient = options.gradient || 0.1;
29
- if (this.gradient > 1) {
30
- this.gradient = 1;
31
- }
32
- this.time = new Date().getTime();
33
- this._init();
35
+ var mergeStyle = merge(DEFAULT_CIRCLE_WAVE_MATERIAL_STYLE(), cloneDeep(style || {}));
36
+ _this = _super.call(this, 'CircleWaveMaterial', mergeStyle);
37
+ _defineProperty(_assertThisInitialized(_this), "currStyle", void 0);
38
+ _this.currStyle = CircleWaveMaterialProperty.handleStyle(mergeStyle);
39
+ _this._init();
40
+ return _this;
34
41
  }
42
+
43
+ // 处理参数
35
44
  _createClass(CircleWaveMaterialProperty, [{
36
45
  key: "_init",
37
46
  value: function _init() {
38
47
  // @ts-ignore
39
- Cesium.Material._materialCache.addMaterial(this.materialType, {
48
+ Cesium.Material._materialCache.addMaterial(this.type, {
40
49
  fabric: {
41
- type: this.materialType,
42
- uniforms: {
43
- color: new Cesium.Color(181, 241, 254, 1),
44
- time: 1,
45
- count: 1,
46
- gradient: 0.1
47
- },
48
- source: this.getShader()
50
+ type: this.type,
51
+ uniforms: _objectSpread(_objectSpread({}, this.currStyle), {}, {
52
+ time: this._time
53
+ }),
54
+ source: CircleWaveShader
49
55
  },
50
56
  translucent: function translucent() {
51
57
  return true;
52
58
  }
53
59
  });
54
60
  }
55
- }, {
56
- key: "isConstant",
57
- get: function get() {
58
- return false;
59
- }
60
- }, {
61
- key: "definitionChanged",
62
- get: function get() {
63
- return this._definitionChanged;
64
- }
65
- }, {
66
- key: "getType",
67
- value: function getType() {
68
- return this.materialType;
69
- }
70
61
  }, {
71
62
  key: "getValue",
72
63
  value: function getValue(time, result) {
64
+ var _Object$keys;
73
65
  if (!Cesium.defined(result)) {
74
66
  result = {};
75
67
  }
76
- // @ts-ignore
77
- result.color = Cesium.Property.getValueOrClonedDefault(this.color, time, Cesium.Color.WHITE, result.color);
78
- result.time = (new Date().getTime() - this.time) % (this.duration * 1000) / (this.duration * 1000);
79
- result.count = this.count;
80
- result.gradient = 1 + 10 * (1 - this.gradient);
68
+ var _this$currStyle = this.currStyle,
69
+ duration = _this$currStyle.duration,
70
+ gradient = _this$currStyle.gradient,
71
+ options = _objectWithoutProperties(_this$currStyle, _excluded);
72
+ (_Object$keys = Object.keys(options)) === null || _Object$keys === void 0 || _Object$keys.forEach(function (key) {
73
+ result[key] = options[key];
74
+ });
75
+ result.time = (new Date().getTime() - this._time) % (duration * 1000) / (duration * 1000);
76
+ result.gradient = 1 + 10 * (1 - gradient);
81
77
  return result;
82
78
  }
83
79
  }, {
84
80
  key: "equals",
85
81
  value: function equals(other) {
86
- return this === other || other instanceof CircleWaveMaterialProperty &&
87
- // @ts-ignore
88
- Cesium.Property.equals(this.color, other.color) && this.duration === other.duration && this.count === other.count && this.gradient === other.gradient;
82
+ return other instanceof CircleWaveMaterialProperty && isEqual(this.style, other.style);
89
83
  }
90
- }, {
91
- key: "getShader",
92
- value: function getShader() {
93
- return "\n 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 ";
84
+ }], [{
85
+ key: "handleStyle",
86
+ value: function handleStyle(style) {
87
+ var color = style.color,
88
+ count = style.count,
89
+ gradient = style.gradient,
90
+ options = _objectWithoutProperties(style, _excluded2);
91
+ var backStyle = _objectSpread({}, options);
92
+ backStyle.color = utils.colorString(color);
93
+ backStyle.count = count <= 0 ? 1 : count;
94
+ backStyle.gradient = gradient <= 0 ? 0 : gradient > 1 ? 1 : gradient;
95
+ return backStyle;
94
96
  }
95
97
  }]);
96
98
  return CircleWaveMaterialProperty;
97
- }();
98
- export { CircleWaveMaterialProperty as default };
99
- Object.defineProperties(CircleWaveMaterialProperty.prototype, {
100
- // @ts-ignore
101
- color: Cesium.createPropertyDescriptor('color'),
102
- // @ts-ignore
103
- gradient: Cesium.createPropertyDescriptor('gradient'),
104
- // @ts-ignore
105
- duration: Cesium.createPropertyDescriptor('duration'),
106
- // @ts-ignore
107
- count: Cesium.createPropertyDescriptor('count')
108
- });
99
+ }(BaseMaterialProperty);
100
+ export { CircleWaveMaterialProperty as default };
@@ -1,45 +1,9 @@
1
- export default class DynamicWallMaterialProperty {
2
- private _definitionChanged;
3
- private _time;
4
- color: string;
5
- mixRatio: number;
6
- duration: number;
7
- direction: string;
8
- freely: string;
9
- image: any;
10
- count: number;
11
- materialType: any;
12
- private _map;
13
- constructor(options: any);
1
+ import BaseMaterialProperty from './BaseMaterialProperty';
2
+ export default class DynamicWallMaterialProperty extends BaseMaterialProperty {
3
+ private readonly currStyle;
4
+ constructor(style: any);
5
+ static handleStyle(style: any): any;
14
6
  private _init;
15
- get isConstant(): boolean;
16
- get definitionChanged(): any;
17
- /**
18
- * 获取材质类型
19
- * @returns {String} 材质类型
20
- */
21
- getType(): any;
22
- /**
23
- * 获取材质值
24
- * @param {Cesium.JulianDate} time 当前时间
25
- * @param {Object} [result] 输出结果对象
26
- * @returns {Object} 材质值
27
- */
28
7
  getValue(time: any, result: any): any;
29
- /**
30
- * 判断材质是否相等
31
- * @param {DynamicWallMaterialProperty} other 另一个材质实例
32
- * @returns {Boolean} 是否相等
33
- */
34
- equals(other: any): any;
35
- /**
36
- * 带方向的墙体
37
- * @param {*} options.get:true/false
38
- * @param {*} options.count:数量
39
- * @param {*} options.freely:vertical/horizontal
40
- * @param {*} options.direction:+/-
41
- * @param {*} options.color:颜色
42
- * @param {*} options.mixRatio:颜色混合比例
43
- */
44
- getShader(options: any): string | undefined;
8
+ equals(other: any): boolean;
45
9
  }
@@ -1,162 +1,100 @@
1
+ var _excluded = ["duration"],
2
+ _excluded2 = ["color", "count", "freely", "direction"];
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 { v4 as uuidv4 } from 'uuid';
22
+ import { cloneDeep, isEqual, merge } from 'lodash';
23
+ import { DEFAULT_DYNAMIC_WALL_MATERIAL_STYLE } from "../constant";
10
24
  import * as utils from "../tool/utils";
25
+ import BaseMaterialProperty from "./BaseMaterialProperty";
26
+ import DynamicWallShader from "./shader/DynamicWallShader.glsl";
11
27
 
12
28
  // 动态墙材质
13
- var DynamicWallMaterialProperty = /*#__PURE__*/function () {
14
- function DynamicWallMaterialProperty(options) {
29
+ var DynamicWallMaterialProperty = /*#__PURE__*/function (_BaseMaterialProperty) {
30
+ _inherits(DynamicWallMaterialProperty, _BaseMaterialProperty);
31
+ var _super = _createSuper(DynamicWallMaterialProperty);
32
+ function DynamicWallMaterialProperty(style) {
33
+ var _this;
15
34
  _classCallCheck(this, DynamicWallMaterialProperty);
16
- _defineProperty(this, "_definitionChanged", new Cesium.Event());
17
- _defineProperty(this, "_time", void 0);
18
- _defineProperty(this, "color", void 0);
19
- _defineProperty(this, "mixRatio", void 0);
20
- _defineProperty(this, "duration", void 0);
21
- _defineProperty(this, "direction", void 0);
22
- _defineProperty(this, "freely", void 0);
23
- _defineProperty(this, "image", void 0);
24
- _defineProperty(this, "count", void 0);
25
- _defineProperty(this, "materialType", void 0);
26
- _defineProperty(this, "_map", void 0);
27
- this.materialType = 'DynamicWallMaterial' + uuidv4();
28
- this._time = new Date().getTime();
29
- this.color = utils.colorString(options.color) || Cesium.Color.BLUE;
30
- this.mixRatio = options.mixRatio || 0.5;
31
- this.duration = options.duration || 2;
32
- this.direction = options.direction || '-';
33
- this.freely = options.freely || 'vertical';
34
- this.count = options.count || 3;
35
- if (this.count <= 0) {
36
- this.count = 1;
37
- }
38
- this.image = options.image || utils.getDeepTwinsFile('Image/wall.png');
39
- this._map = options.map;
40
- this._init();
35
+ var mergeStyle = merge(DEFAULT_DYNAMIC_WALL_MATERIAL_STYLE(), cloneDeep(style || {}));
36
+ _this = _super.call(this, 'DynamicWallMaterial', mergeStyle);
37
+ _defineProperty(_assertThisInitialized(_this), "currStyle", void 0);
38
+ _this.currStyle = DynamicWallMaterialProperty.handleStyle(mergeStyle);
39
+ _this._init();
40
+ return _this;
41
41
  }
42
+
43
+ // 处理参数
42
44
  _createClass(DynamicWallMaterialProperty, [{
43
45
  key: "_init",
44
46
  value: function _init() {
45
47
  // @ts-ignore
46
- Cesium.Material._materialCache.addMaterial(this.materialType, {
48
+ Cesium.Material._materialCache.addMaterial(this.type, {
47
49
  fabric: {
48
- type: this.materialType,
49
- uniforms: {
50
- color: new Cesium.Color(1.0, 0.0, 0.0, 0.5),
51
- image: Cesium.Material.DefaultImageId,
52
- time: -20
53
- },
54
- source: this.getShader({
55
- get: true,
56
- count: this.count,
57
- freely: this.freely,
58
- direction: this.direction,
59
- color: this.color,
60
- mixRatio: this.mixRatio
61
- })
50
+ type: this.type,
51
+ uniforms: _objectSpread(_objectSpread({}, this.currStyle), {}, {
52
+ time: this._time
53
+ }),
54
+ source: DynamicWallShader
62
55
  },
63
56
  translucent: function translucent() {
64
57
  return true;
65
58
  }
66
59
  });
67
60
  }
68
- }, {
69
- key: "isConstant",
70
- get: function get() {
71
- return false;
72
- }
73
- }, {
74
- key: "definitionChanged",
75
- get: function get() {
76
- return this._definitionChanged;
77
- }
78
-
79
- /**
80
- * 获取材质类型
81
- * @returns {String} 材质类型
82
- */
83
- }, {
84
- key: "getType",
85
- value: function getType() {
86
- return this.materialType;
87
- }
88
-
89
- /**
90
- * 获取材质值
91
- * @param {Cesium.JulianDate} time 当前时间
92
- * @param {Object} [result] 输出结果对象
93
- * @returns {Object} 材质值
94
- */
95
61
  }, {
96
62
  key: "getValue",
97
63
  value: function getValue(time, result) {
64
+ var _Object$keys;
98
65
  if (!Cesium.defined(result)) {
99
66
  result = {};
100
67
  }
101
- // @ts-ignore
102
- result.color = Cesium.Property.getValueOrClonedDefault(
103
- // this._color,
104
- this.color, time, Cesium.Color.WHITE, result.color);
105
- result.image = this.image;
106
- if (this.duration) {
107
- result.time = (new Date().getTime() - this._time) % (this.duration * 1000) / (this.duration * 1000);
108
- }
109
- this._map.scene.requestRender();
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);
110
75
  return result;
111
76
  }
112
-
113
- /**
114
- * 判断材质是否相等
115
- * @param {DynamicWallMaterialProperty} other 另一个材质实例
116
- * @returns {Boolean} 是否相等
117
- */
118
77
  }, {
119
78
  key: "equals",
120
79
  value: function equals(other) {
121
- return this === other || other instanceof DynamicWallMaterialProperty &&
122
- // @ts-ignore
123
- Cesium.Property.equals(this.color, other.color) && this.duration === other.duration && this.direction === other.direction && this.freely === other.freely && this.image === other.image && this.count === other.count && this.mixRatio === other.mixRatio;
80
+ return other instanceof DynamicWallMaterialProperty && isEqual(this.style, other.style);
124
81
  }
125
-
126
- /**
127
- * 带方向的墙体
128
- * @param {*} options.get:true/false
129
- * @param {*} options.count:数量
130
- * @param {*} options.freely:vertical/horizontal
131
- * @param {*} options.direction:+/-
132
- * @param {*} options.color:颜色
133
- * @param {*} options.mixRatio:颜色混合比例
134
- */
135
- }, {
136
- key: "getShader",
137
- value: function getShader(options) {
138
- if (options && options.get) {
139
- var materail = 'czm_material czm_getMaterial(czm_materialInput materialInput)\n\
140
- {\n\
141
- czm_material material = czm_getDefaultMaterial(materialInput);\n\
142
- vec2 st = materialInput.st;';
143
- if (options.freely == 'vertical') {
144
- //(由下到上)
145
- materail += 'vec4 colorImage = texture(image, vec2(fract(st.s), fract(float(' + options.count + ')*st.t' + options.direction + ' time)));\n ';
146
- } else {
147
- //(逆时针)
148
- materail += 'vec4 colorImage = texture(image, vec2(fract(float(' + options.count + ')*st.s ' + options.direction + ' time), fract(st.t)));\n ';
149
- }
150
- //泛光
151
- materail += "\n vec3 mixedColor = mix(colorImage.rgb, color.rgb, ".concat(options.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 }");
152
- return materail;
153
- }
82
+ }], [{
83
+ key: "handleStyle",
84
+ value: function handleStyle(style) {
85
+ var color = style.color,
86
+ count = style.count,
87
+ freely = style.freely,
88
+ direction = style.direction,
89
+ options = _objectWithoutProperties(style, _excluded2);
90
+ var backStyle = _objectSpread({}, options);
91
+ backStyle.color = utils.colorString(color);
92
+ backStyle.count = count <= 0 ? 1 : count;
93
+ backStyle.freely = freely === 'vertical' ? 1.0 : 0.0;
94
+ backStyle.direction = direction === '+' ? 1.0 : 0.0;
95
+ return backStyle;
154
96
  }
155
97
  }]);
156
98
  return DynamicWallMaterialProperty;
157
- }();
158
- export { DynamicWallMaterialProperty as default };
159
- Object.defineProperties(DynamicWallMaterialProperty.prototype, {
160
- // @ts-ignore
161
- color: Cesium.createPropertyDescriptor('color')
162
- });
99
+ }(BaseMaterialProperty);
100
+ export { DynamicWallMaterialProperty as default };
@@ -1,19 +1,9 @@
1
- export default class PolylineTrailLinkMaterialProperty {
2
- private _definitionChanged;
3
- private _color;
4
- private _time;
5
- color: any;
6
- mixRatio: number;
7
- duration: number;
8
- image: any;
9
- count: number;
10
- materialType: any;
11
- constructor(options: any);
1
+ import BaseMaterialProperty from './BaseMaterialProperty';
2
+ export default class PolylineTrailLinkMaterialProperty extends BaseMaterialProperty {
3
+ private readonly currStyle;
4
+ constructor(style: any);
5
+ static handleStyle(style: any): any;
12
6
  private _init;
13
- get isConstant(): boolean;
14
- get definitionChanged(): any;
15
- getType(): any;
16
7
  getValue(time: any, result: any): any;
17
- equals(other: any): any;
18
- getShader(): string;
8
+ equals(other: any): boolean;
19
9
  }