deeptwins-engine-3d 0.0.42 → 0.0.43

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.
@@ -111,6 +111,9 @@ export declare const DEFAULT_BASE_LAYER_TYPE: any;
111
111
  export declare const DEFAULT_BASE_LAYER: any;
112
112
  export declare const LAYER_TYPE_TO_CLASS: any;
113
113
  export declare const DEFAULT_SKY_BOX: any;
114
+ export declare const DEFAULT_POLYLINE_TRAIL_LINK_MATERIAL_STYLE: any;
115
+ export declare const DEFAULT_DYNAMIC_WALL_MATERIAL_STYLE: any;
116
+ export declare const DEFAULT_CIRCLE_WAVE_MATERIAL_STYLE: any;
114
117
  export declare const GRAPHIC_LAYER_TYPE_TO_CLASS: any;
115
118
  export declare const DEFAULT_YJ_LAYER: any;
116
119
  export declare const DEFAULT_YJ_PICK: any;
package/dist/constant.js CHANGED
@@ -343,6 +343,40 @@ export var DEFAULT_SKY_BOX = {
343
343
  }
344
344
  };
345
345
 
346
+ // 流动线材质默认的配置
347
+ export var DEFAULT_POLYLINE_TRAIL_LINK_MATERIAL_STYLE = function DEFAULT_POLYLINE_TRAIL_LINK_MATERIAL_STYLE() {
348
+ return {
349
+ color: Cesium.Color.BLUE,
350
+ mixRatio: 0.5,
351
+ duration: 2,
352
+ count: 3,
353
+ image: utils.getDeepTwinsFile('Image/line.png')
354
+ };
355
+ };
356
+
357
+ // 动态墙材质默认的配置
358
+ export var DEFAULT_DYNAMIC_WALL_MATERIAL_STYLE = function DEFAULT_DYNAMIC_WALL_MATERIAL_STYLE() {
359
+ return {
360
+ color: Cesium.Color.BLUE,
361
+ mixRatio: 0.5,
362
+ duration: 2,
363
+ direction: '-',
364
+ freely: 'vertical',
365
+ count: 3,
366
+ image: utils.getDeepTwinsFile('Image/wall.png')
367
+ };
368
+ };
369
+
370
+ // 动态墙材质默认的配置
371
+ export var DEFAULT_CIRCLE_WAVE_MATERIAL_STYLE = function DEFAULT_CIRCLE_WAVE_MATERIAL_STYLE() {
372
+ return {
373
+ color: Cesium.Color.BLUE,
374
+ duration: 2,
375
+ count: 3,
376
+ gradient: 0.1
377
+ };
378
+ };
379
+
346
380
  // 矢量图层类型对应的处理函数
347
381
  export var GRAPHIC_LAYER_TYPE_TO_CLASS = {
348
382
  point: PointEntity,
package/dist/index.d.ts CHANGED
@@ -25,7 +25,6 @@ declare class DeepTwinsEngine3D {
25
25
  static CircleWaveMaterialProperty: any;
26
26
  static PolylineTrailLinkMaterialProperty: any;
27
27
  static ImageMaterialProperty: any;
28
- static ImageMaterial: any;
29
28
  static Heatmap2d: any;
30
29
  static Heatmap3d: any;
31
30
  static PointCluster: any;
package/dist/index.js CHANGED
@@ -22,7 +22,6 @@ import GroundSkyBox from "./map/GroundSkyBox";
22
22
  import Map from "./map/Map";
23
23
  import CircleWaveMaterialProperty from "./material/CircleWaveMaterialProperty";
24
24
  import DynamicWallMaterialProperty from "./material/DynamicWallMaterialProperty";
25
- import ImageMaterial from "./material/ImageMaterial";
26
25
  import ImageMaterialProperty from "./material/ImageMaterialProperty";
27
26
  import PolylineTrailLinkMaterialProperty from "./material/PolylineTrailLinkMaterialProperty";
28
27
  import WeatherEffects from "./material/WeatherEffects";
@@ -46,7 +45,7 @@ window.Cesium = Cesium;
46
45
  var DeepTwinsEngine3D = /*#__PURE__*/_createClass(function DeepTwinsEngine3D() {
47
46
  _classCallCheck(this, DeepTwinsEngine3D);
48
47
  });
49
- _defineProperty(DeepTwinsEngine3D, "Version", '0.0.42');
48
+ _defineProperty(DeepTwinsEngine3D, "Version", '0.0.43');
50
49
  _defineProperty(DeepTwinsEngine3D, "Map", Map);
51
50
  _defineProperty(DeepTwinsEngine3D, "GroundSkyBox", GroundSkyBox);
52
51
  _defineProperty(DeepTwinsEngine3D, "RasterLayer", RasterLayer);
@@ -70,7 +69,6 @@ _defineProperty(DeepTwinsEngine3D, "DynamicWallMaterialProperty", DynamicWallMat
70
69
  _defineProperty(DeepTwinsEngine3D, "CircleWaveMaterialProperty", CircleWaveMaterialProperty);
71
70
  _defineProperty(DeepTwinsEngine3D, "PolylineTrailLinkMaterialProperty", PolylineTrailLinkMaterialProperty);
72
71
  _defineProperty(DeepTwinsEngine3D, "ImageMaterialProperty", ImageMaterialProperty);
73
- _defineProperty(DeepTwinsEngine3D, "ImageMaterial", ImageMaterial);
74
72
  _defineProperty(DeepTwinsEngine3D, "Heatmap2d", Heatmap2d);
75
73
  _defineProperty(DeepTwinsEngine3D, "Heatmap3d", Heatmap3d);
76
74
  _defineProperty(DeepTwinsEngine3D, "PointCluster", PointCluster);
@@ -0,0 +1,12 @@
1
+ export default class BaseMaterialProperty {
2
+ private _definitionChanged;
3
+ readonly _time: number;
4
+ type: string;
5
+ style: any;
6
+ constructor(type: string, style: any);
7
+ get isConstant(): boolean;
8
+ get definitionChanged(): any;
9
+ getType(): string;
10
+ getValue(time: any, result: any): any;
11
+ equals(other: any): boolean;
12
+ }
@@ -0,0 +1,51 @@
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
+ 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
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
5
+ 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
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ 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
+ import * as Cesium from 'deeptwins-cesium';
9
+ import { v4 as uuidv4 } from 'uuid';
10
+ var BaseMaterialProperty = /*#__PURE__*/function () {
11
+ function BaseMaterialProperty(type, style) {
12
+ _classCallCheck(this, BaseMaterialProperty);
13
+ _defineProperty(this, "_definitionChanged", new Cesium.Event());
14
+ _defineProperty(this, "_time", new Date().getTime());
15
+ _defineProperty(this, "type", void 0);
16
+ _defineProperty(this, "style", void 0);
17
+ this.type = type + uuidv4();
18
+ this.style = style || {};
19
+ }
20
+ _createClass(BaseMaterialProperty, [{
21
+ key: "isConstant",
22
+ get: function get() {
23
+ return false;
24
+ }
25
+ }, {
26
+ key: "definitionChanged",
27
+ get: function get() {
28
+ return this._definitionChanged;
29
+ }
30
+ }, {
31
+ key: "getType",
32
+ value: function getType() {
33
+ return this.type;
34
+ }
35
+ }, {
36
+ key: "getValue",
37
+ value: function getValue(time, result) {
38
+ return result;
39
+ }
40
+
41
+ // 默认重新渲染
42
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
43
+ }, {
44
+ key: "equals",
45
+ value: function equals(other) {
46
+ return false;
47
+ }
48
+ }]);
49
+ return BaseMaterialProperty;
50
+ }();
51
+ export { BaseMaterialProperty as default };
@@ -1,17 +1,9 @@
1
- export default class CircleWaveMaterialProperty {
2
- private _definitionChanged;
3
- color: any;
4
- duration: number;
5
- count: number;
6
- gradient: number;
7
- time: any;
8
- materialType: any;
9
- constructor(options: any);
1
+ import BaseMaterialProperty from './BaseMaterialProperty';
2
+ export default class CircleWaveMaterialProperty extends BaseMaterialProperty {
3
+ private readonly currStyle;
4
+ constructor(style: any);
5
+ static handleStyle(style: any): any;
10
6
  private _init;
11
- get isConstant(): boolean;
12
- get definitionChanged(): any;
13
- getType(): any;
14
7
  getValue(time: any, result: any): any;
15
- equals(other: any): any;
16
- getShader(): string;
8
+ equals(other: any): boolean;
17
9
  }
@@ -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
  }
@@ -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 { v4 as uuidv4 } from 'uuid';
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
- var PolylineTrailLinkMaterialProperty = /*#__PURE__*/function () {
12
- function PolylineTrailLinkMaterialProperty(options) {
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
- _defineProperty(this, "_definitionChanged", new Cesium.Event());
15
- _defineProperty(this, "_color", void 0);
16
- _defineProperty(this, "_time", void 0);
17
- _defineProperty(this, "color", void 0);
18
- _defineProperty(this, "mixRatio", void 0);
19
- _defineProperty(this, "duration", void 0);
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.materialType, {
48
+ Cesium.Material._materialCache.addMaterial(this.type, {
38
49
  fabric: {
39
- type: this.materialType,
40
- uniforms: {
41
- color: new Cesium.Color(1.0, 0.0, 0.0, 0.5),
42
- image: this.image,
43
- count: this.count,
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
- // @ts-ignore
76
- result.color = Cesium.Property.getValueOrClonedDefault(this._color, time, Cesium.Color.WHITE, result.color);
77
- result.image = this.image;
78
- result.count = this.count;
79
- result.time = (new Date().getTime() - this._time) % (this.duration * 1000) / (this.duration * 1000);
80
- result.mixRatio = this.mixRatio;
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 this === other || other instanceof PolylineTrailLinkMaterialProperty &&
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: "getShader",
92
- value: function getShader() {
93
- return "czm_material czm_getMaterial(czm_materialInput materialInput)\n\t {\n\t czm_material material = czm_getDefaultMaterial(materialInput);\n\t vec2 st = vec2(fract(materialInput.st.s * count - time), materialInput.st.t * 1.0);\n\t vec4 colorImage = texture(image, vec2(fract(st.s - time), st.t));\n\t material.alpha = colorImage.a * color.a;\n\t material.diffuse = mix(colorImage.rgb, color.rgb, mixRatio);\n\t return material;\n\t }\n\t ";
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
- var fsSnow = "\n precision highp float;\n\n uniform sampler2D colorTexture;\n uniform float speed;\n uniform float size;\n in vec2 v_textureCoordinates;\n out vec4 fragColor;\n\n float 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\n void 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 ";
13
- var fsRain = "\n precision highp float;\n\n uniform sampler2D colorTexture;\n uniform float direction;\n uniform float size;\n uniform float speed;\n in vec2 v_textureCoordinates;\n out vec4 fragColor;\n\n float hash(float x){\n return fract(sin(x * 133.3) * 13.13);\n }\n\n void 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 ";
14
- var fsFog = "\n 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\n float 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 }\n vec4 alphaBlend(vec4 sourceColor, vec4 destinationColor)\n {\n return sourceColor * vec4(sourceColor.aaa, 1.0) + destinationColor * (1.0 - sourceColor.a);\n }\n uniform sampler2D colorTexture;\n uniform sampler2D depthTexture;\n uniform vec4 fogByDistance;\n uniform vec4 fogColor;\n in vec2 v_textureCoordinates;\n void 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 }";
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: fsSnow,
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: fsRain,
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: fsFog,
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
+ }
@@ -0,0 +1,4 @@
1
+ declare module '*.glsl' {
2
+ const value: string;
3
+ export default value;
4
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deeptwins-engine-3d",
3
- "version": "0.0.42",
3
+ "version": "0.0.43",
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,4 +0,0 @@
1
- import * as Cesium from 'deeptwins-cesium';
2
- export default class ImageMaterial extends Cesium.Material {
3
- constructor(options: any);
4
- }
@@ -1,35 +0,0 @@
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 _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); } }
3
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
5
- 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); }
6
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7
- 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); }
8
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
9
- 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); }; }
10
- 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); }
11
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
12
- 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; } }
13
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
14
- import * as Cesium from 'deeptwins-cesium';
15
- import * as utils from "../tool/utils";
16
- var ImageMaterial = /*#__PURE__*/function (_Cesium$Material) {
17
- _inherits(ImageMaterial, _Cesium$Material);
18
- var _super = _createSuper(ImageMaterial);
19
- function ImageMaterial(options) {
20
- _classCallCheck(this, ImageMaterial);
21
- var fabric = {
22
- type: 'Image',
23
- uniforms: {
24
- image: options.image,
25
- repeat: utils.arrCartesian2(options.repeat || [1, 1]),
26
- stRotation: utils.toRadians(options.stRotation || 0)
27
- }
28
- };
29
- return _super.call(this, {
30
- fabric: fabric
31
- });
32
- }
33
- return _createClass(ImageMaterial);
34
- }(Cesium.Material);
35
- export { ImageMaterial as default };