deeptwins-engine-3d 0.1.47 → 0.1.48

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 (28) hide show
  1. package/dist/esm/analyze/ViewshedAnalysis.js +3 -2
  2. package/dist/esm/constant.d.ts +11 -0
  3. package/dist/esm/constant.js +24 -0
  4. package/dist/esm/graphicLayer/BaseLayer.js +3 -0
  5. package/dist/esm/graphicLayer/BaseSource.d.ts +1 -1
  6. package/dist/esm/graphicLayer/PolygonPrimitive.js +6 -4
  7. package/dist/esm/graphicLayer/PolygonPrimitiveImageMaterialInstance.d.ts +5 -0
  8. package/dist/esm/graphicLayer/PolygonPrimitiveImageMaterialInstance.js +75 -0
  9. package/dist/esm/graphicLayer/PolygonPrimitiveInstance.d.ts +1 -1
  10. package/dist/esm/graphicLayer/PolygonPrimitiveInstance.js +8 -23
  11. package/dist/esm/index.d.ts +1 -1
  12. package/dist/esm/index.js +4 -4
  13. package/dist/esm/material/primitive/BaseMaterialAppearance.d.ts +1 -0
  14. package/dist/esm/material/primitive/BaseMaterialAppearance.js +1 -0
  15. package/dist/esm/material/primitive/ImageMaterialAppearance.d.ts +10 -0
  16. package/dist/esm/material/primitive/ImageMaterialAppearance.js +77 -0
  17. package/dist/esm/material/shader/ImageShader.glsl +22 -0
  18. package/dist/esm/tool/utils.d.ts +10 -1
  19. package/dist/esm/tool/utils.js +90 -44
  20. package/dist/esm/videoFusion/VideoProject.js +1 -1
  21. package/dist/esm/visualization/Frustum.d.ts +27 -2
  22. package/dist/esm/visualization/Frustum.js +158 -42
  23. package/dist/umd/deeptwins-engine-3d.min.js +1 -1
  24. package/package.json +7 -4
  25. package/dist/esm/visualization/BaseFrustum.d.ts +0 -14
  26. package/dist/esm/visualization/BaseFrustum.js +0 -96
  27. package/dist/esm/visualization/FrustumWithCamera.d.ts +0 -5
  28. package/dist/esm/visualization/FrustumWithCamera.js +0 -133
@@ -15,7 +15,7 @@ import * as Cesium from 'deeptwins-cesium';
15
15
  import { merge } from 'lodash';
16
16
  import { DEFAULT_VIEWSHED_ANALYSIS_OPTIONS } from "../constant";
17
17
  import * as utils from "../tool/utils";
18
- import FrustumWithCamera from "../visualization/FrustumWithCamera";
18
+ import Frustum from "../visualization/Frustum";
19
19
 
20
20
  // 可视域分析。
21
21
  var ViewshedAnalysis = /*#__PURE__*/function () {
@@ -204,10 +204,11 @@ var ViewshedAnalysis = /*#__PURE__*/function () {
204
204
  key: "_drawFrustumOutline",
205
205
  value: function _drawFrustumOutline() {
206
206
  if (!this._canOperate) return;
207
- this.frustumCamera = new FrustumWithCamera(this.getMap(), {
207
+ this.frustumCamera = new Frustum(this.getMap(), {
208
208
  position: this.options.position,
209
209
  fill: false,
210
210
  outlineColor: this.options.outlineColor,
211
+ isWithCamera: true,
211
212
  camera: this.lightCamera
212
213
  });
213
214
  }
@@ -183,6 +183,16 @@ export declare const DEFAULT_FLIGHT_RISK_EVALUATION_OPTIONS: () => {
183
183
  color: string;
184
184
  }[];
185
185
  };
186
+ export declare const DEFAULT_FRUSTUM_OPTIONS: () => {
187
+ show: boolean;
188
+ heading: number;
189
+ pitch: number;
190
+ roll: number;
191
+ color: string;
192
+ outline: boolean;
193
+ outlineColor: string;
194
+ isWithCamera: boolean;
195
+ };
186
196
  export declare const DEFAULT_SUBMERGENCE_ANALYSIS_OPTIONS: () => {
187
197
  startHeight: number;
188
198
  targetHeight: number;
@@ -221,6 +231,7 @@ export declare const DEFAULT_MATERIAL_APPEARANCE: any;
221
231
  export declare const DEFAULT_POLYLINE_TRAIL_LINK_MATERIAL_STYLE: any;
222
232
  export declare const DEFAULT_DYNAMIC_WALL_MATERIAL_STYLE: any;
223
233
  export declare const DEFAULT_CIRCLE_WAVE_MATERIAL_STYLE: any;
234
+ export declare const DEFAULT_IMAGE_MATERIAL_STYLE: any;
224
235
  export declare const DEFAULT_GLOW_MATERIAL_STYLE: any;
225
236
  export declare const GRAPHIC_LAYER_TYPE_TO_CLASS: any;
226
237
  export declare const DEFAULT_YJ_LAYER: any;
@@ -15,6 +15,7 @@ import ModelPrimitiveInstance from "./graphicLayer/ModelPrimitiveInstance";
15
15
  import PointEntity from "./graphicLayer/PointEntity";
16
16
  import PointPrimitive from "./graphicLayer/PointPrimitive";
17
17
  import PolygonEntity from "./graphicLayer/PolygonEntity";
18
+ import PolygonPrimitiveImageMaterialInstance from "./graphicLayer/PolygonPrimitiveImageMaterialInstance";
18
19
  import PolygonPrimitiveInstance from "./graphicLayer/PolygonPrimitiveInstance";
19
20
  import PolylineEntity from "./graphicLayer/PolylineEntity";
20
21
  import PolylineGroundPrimitiveInstance from "./graphicLayer/PolylineGroundPrimitiveInstance";
@@ -310,6 +311,20 @@ export var DEFAULT_FLIGHT_RISK_EVALUATION_OPTIONS = function DEFAULT_FLIGHT_RISK
310
311
  };
311
312
  };
312
313
 
314
+ // 默认视锥体配置选项
315
+ export var DEFAULT_FRUSTUM_OPTIONS = function DEFAULT_FRUSTUM_OPTIONS() {
316
+ return {
317
+ show: true,
318
+ heading: 0,
319
+ pitch: 0,
320
+ roll: 0,
321
+ color: 'rgba(255,0,0,0.3)',
322
+ outline: true,
323
+ outlineColor: '#ffffff',
324
+ isWithCamera: false
325
+ };
326
+ };
327
+
313
328
  // 默认淹没分析配置选项 SubmergenceAnalysis
314
329
  export var DEFAULT_SUBMERGENCE_ANALYSIS_OPTIONS = function DEFAULT_SUBMERGENCE_ANALYSIS_OPTIONS() {
315
330
  return {
@@ -586,6 +601,14 @@ export var DEFAULT_CIRCLE_WAVE_MATERIAL_STYLE = function DEFAULT_CIRCLE_WAVE_MAT
586
601
  };
587
602
  };
588
603
 
604
+ // 贴图材质默认的配置
605
+ export var DEFAULT_IMAGE_MATERIAL_STYLE = function DEFAULT_IMAGE_MATERIAL_STYLE() {
606
+ return {
607
+ color: Cesium.Color.WHITE,
608
+ mixRatio: 0.5
609
+ };
610
+ };
611
+
589
612
  // 发光材质默认的配置
590
613
  export var DEFAULT_GLOW_MATERIAL_STYLE = function DEFAULT_GLOW_MATERIAL_STYLE() {
591
614
  return {
@@ -614,6 +637,7 @@ export var GRAPHIC_LAYER_TYPE_TO_CLASS = {
614
637
  polylineP: PolylinePrimitiveInstance,
615
638
  polylineGroundP: PolylineGroundPrimitiveInstance,
616
639
  polygonP: PolygonPrimitiveInstance,
640
+ polygonImageP: PolygonPrimitiveImageMaterialInstance,
617
641
  polygonGroundP: PolygonPrimitiveInstance,
618
642
  boxP: BoxPrimitiveInstance,
619
643
  modelP: ModelPrimitiveInstance,
@@ -112,6 +112,9 @@ var BaseLayer = /*#__PURE__*/function () {
112
112
  polygonP: function polygonP() {
113
113
  _this2.primitiveCollection = new PolygonPrimitive(_this2._mapContext);
114
114
  },
115
+ polygonImageP: function polygonImageP() {
116
+ _this2.primitiveCollection = new PolygonPrimitive(_this2._mapContext);
117
+ },
115
118
  polygonGroundP: function polygonGroundP() {
116
119
  _this2.primitiveCollection = new PolygonGroundPrimitive(_this2._mapContext);
117
120
  },
@@ -15,7 +15,7 @@ export default class BaseSource {
15
15
  remove(): void;
16
16
  setData(data: any): this | undefined;
17
17
  _toDestroy(): void;
18
- static analysisSourceType(data: any): "wkt" | "sourceId" | "sourceInstance" | "geoJson" | "other";
18
+ static analysisSourceType(data: any): "other" | "wkt" | "sourceId" | "sourceInstance" | "geoJson";
19
19
  static wktToGeoJon(wkt: string): any;
20
20
  static geoJsonToGeoCartesian3Array(geoJson: any): any[];
21
21
  static handleFeaturePoint(feature: any): any;
@@ -1,5 +1,5 @@
1
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
- var _excluded = ["materialAppearance"];
2
+ var _excluded = ["material"];
3
3
  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; }
4
4
  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; }
5
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; }
@@ -34,13 +34,15 @@ var PolygonPrimitive = /*#__PURE__*/function (_BasePrimitive) {
34
34
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
35
35
  var primitiveInstance = arguments.length > 1 ? arguments[1] : undefined;
36
36
  var _ref = options.style || {},
37
- materialAppearance = _ref.materialAppearance,
37
+ material = _ref.material,
38
38
  otherStyle = _objectWithoutProperties(_ref, _excluded);
39
39
  var style = merge(DEFAULT_POLYGON_PRIMITIVE_OPTIONS(), cloneDeep(otherStyle || {}));
40
40
  var primitiveOptions = merge(DEFAULT_PRIMITIVE_OPTIONS(), cloneDeep(options.primitive || {}));
41
41
  var appearance = {};
42
- if (materialAppearance) {
43
- appearance = materialAppearance.appearance;
42
+
43
+ // 自定义材质
44
+ if (material !== null && material !== void 0 && material.customMaterial) {
45
+ appearance = material.appearance;
44
46
  } else {
45
47
  appearance = new Cesium.PerInstanceColorAppearance({
46
48
  translucent: !!(style !== null && style !== void 0 && style.translucent)
@@ -0,0 +1,5 @@
1
+ import PolygonPrimitiveInstance from './PolygonPrimitiveInstance';
2
+ export default class PolygonPrimitiveImageMaterialInstance extends PolygonPrimitiveInstance {
3
+ constructor(options: any);
4
+ _init(options: any): void;
5
+ }
@@ -0,0 +1,75 @@
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
+ var _excluded = ["color", "stRotation"];
3
+ 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; }
4
+ 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; }
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 _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; }
7
+ 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; }
8
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
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); } }
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 _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
+ 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); }
13
+ 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); }
14
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
15
+ 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); }; }
16
+ 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); }
17
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
18
+ 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; } }
19
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
20
+ import * as Cesium from 'deeptwins-cesium';
21
+ import * as utils from "../tool/utils";
22
+ import PolygonPrimitiveInstance from "./PolygonPrimitiveInstance";
23
+
24
+ // polygon Primitive 图片材质贴图
25
+ var PolygonPrimitiveImageMaterialInstance = /*#__PURE__*/function (_PolygonPrimitiveInst) {
26
+ _inherits(PolygonPrimitiveImageMaterialInstance, _PolygonPrimitiveInst);
27
+ var _super = _createSuper(PolygonPrimitiveImageMaterialInstance);
28
+ function PolygonPrimitiveImageMaterialInstance(options) {
29
+ _classCallCheck(this, PolygonPrimitiveImageMaterialInstance);
30
+ return _super.call(this, options);
31
+ }
32
+
33
+ // 初始化
34
+ _createClass(PolygonPrimitiveImageMaterialInstance, [{
35
+ key: "_init",
36
+ value: function _init(options) {
37
+ var _options$style = options.style,
38
+ color = _options$style.color,
39
+ stRotation = _options$style.stRotation,
40
+ style = _objectWithoutProperties(_options$style, _excluded),
41
+ positions = options.positions,
42
+ holes = options.holes,
43
+ primitiveInstance = options.primitiveInstance;
44
+ var geometry = null;
45
+ var polygonGeometry = new Cesium.PolygonGeometry(_objectSpread({
46
+ polygonHierarchy: new Cesium.PolygonHierarchy(positions, holes.map(function (t) {
47
+ return new Cesium.PolygonHierarchy(t);
48
+ })),
49
+ vertexFormat: Cesium.VertexFormat.POSITION_AND_ST,
50
+ stRotation: stRotation
51
+ }, style));
52
+ if (!style.extrudedHeight) {
53
+ geometry = Cesium.PolygonGeometry.createGeometry(polygonGeometry);
54
+ geometry.attributes.st = new Cesium.GeometryAttribute({
55
+ componentDatatype: Cesium.ComponentDatatype.FLOAT,
56
+ componentsPerAttribute: 2,
57
+ values: utils.computeSTAlongPlane(positions, stRotation)
58
+ });
59
+ } else {
60
+ utils.error('不支持extrudedHeight');
61
+ return;
62
+ }
63
+ var instance = new Cesium.GeometryInstance({
64
+ id: this.id,
65
+ geometry: geometry,
66
+ attributes: {
67
+ color: color
68
+ }
69
+ });
70
+ primitiveInstance.push(instance);
71
+ }
72
+ }]);
73
+ return PolygonPrimitiveImageMaterialInstance;
74
+ }(PolygonPrimitiveInstance);
75
+ export { PolygonPrimitiveImageMaterialInstance as default };
@@ -2,6 +2,6 @@ import BasePrimitiveInstance from './BasePrimitiveInstance';
2
2
  export default class PolygonPrimitiveInstance extends BasePrimitiveInstance {
3
3
  constructor(options: any);
4
4
  static handleOptions(style: any): any;
5
- private _init;
5
+ _init(options: any): void;
6
6
  updateData(): void;
7
7
  }
@@ -1,6 +1,6 @@
1
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
2
  var _excluded = ["style"],
3
- _excluded2 = ["color", "stRotation", "materialAppearance", "vertexFormat"],
3
+ _excluded2 = ["color", "stRotation"],
4
4
  _excluded3 = ["color", "height", "stRotation"];
5
5
  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; }
6
6
  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; }
@@ -52,34 +52,19 @@ var PolygonPrimitiveInstance = /*#__PURE__*/function (_BasePrimitiveInstanc) {
52
52
  var _options$style = options.style,
53
53
  color = _options$style.color,
54
54
  stRotation = _options$style.stRotation,
55
- materialAppearance = _options$style.materialAppearance,
56
- vertexFormat = _options$style.vertexFormat,
57
55
  style = _objectWithoutProperties(_options$style, _excluded2),
58
56
  positions = options.positions,
59
57
  holes = options.holes,
60
58
  primitiveInstance = options.primitiveInstance;
61
- var currVertexFormat = vertexFormat || materialAppearance ? Cesium.VertexFormat.POSITION_AND_ST : Cesium.PerInstanceColorAppearance.VERTEX_FORMAT;
62
- var geometry = null;
63
- var polygonGeometry = new Cesium.PolygonGeometry(_objectSpread({
64
- polygonHierarchy: new Cesium.PolygonHierarchy(positions, holes.map(function (t) {
65
- return new Cesium.PolygonHierarchy(t);
66
- })),
67
- vertexFormat: currVertexFormat,
68
- stRotation: stRotation
69
- }, style));
70
- if (materialAppearance && !style.extrudedHeight) {
71
- geometry = Cesium.PolygonGeometry.createGeometry(polygonGeometry);
72
- geometry.attributes.st = new Cesium.GeometryAttribute({
73
- componentDatatype: Cesium.ComponentDatatype.FLOAT,
74
- componentsPerAttribute: 2,
75
- values: utils.computeSTAlongPlane(positions, stRotation)
76
- });
77
- } else {
78
- geometry = polygonGeometry;
79
- }
80
59
  var instance = new Cesium.GeometryInstance({
81
60
  id: this.id,
82
- geometry: geometry,
61
+ geometry: new Cesium.PolygonGeometry(_objectSpread({
62
+ polygonHierarchy: new Cesium.PolygonHierarchy(positions, holes.map(function (t) {
63
+ return new Cesium.PolygonHierarchy(t);
64
+ })),
65
+ vertexFormat: Cesium.PerInstanceColorAppearance.VERTEX_FORMAT,
66
+ stRotation: stRotation
67
+ }, style)),
83
68
  attributes: {
84
69
  color: color
85
70
  }
@@ -24,6 +24,7 @@ export declare class DeepTwinsEngine3D {
24
24
  static CircleWaveMaterialProperty: any;
25
25
  static PolylineTrailLinkMaterialProperty: any;
26
26
  static ImageMaterialProperty: any;
27
+ static ImageMaterialAppearance: any;
27
28
  static ImageGlowingMaterialAppearance: any;
28
29
  static VolumeCloud: any;
29
30
  static Heatmap2d: any;
@@ -31,7 +32,6 @@ export declare class DeepTwinsEngine3D {
31
32
  static PointCluster: any;
32
33
  static PositionProperty: any;
33
34
  static Frustum: any;
34
- static FrustumWithCamera: any;
35
35
  static GridDraw: any;
36
36
  static VideoTexture: any;
37
37
  static VideoProject: any;
package/dist/esm/index.js CHANGED
@@ -35,6 +35,7 @@ import ImageGlowingMaterialProperty from "./material/entity/ImageGlowingMaterial
35
35
  import ImageMaterialProperty from "./material/entity/ImageMaterialProperty";
36
36
  import PolylineTrailLinkMaterialProperty from "./material/entity/PolylineTrailLinkMaterialProperty";
37
37
  import ImageGlowingMaterialAppearance from "./material/primitive/ImageGlowingMaterialAppearance";
38
+ import ImageMaterialAppearance from "./material/primitive/ImageMaterialAppearance";
38
39
  import Measure from "./measure";
39
40
  import PositionProperty from "./property/PositionProperty";
40
41
  import ArcGisLayer from "./tileLayer/ArcGisLayer";
@@ -48,7 +49,6 @@ import { loadCss } from "./tool/utils";
48
49
  import VideoProject from "./videoFusion/VideoProject";
49
50
  import VideoTexture from "./videoFusion/VideoTexture";
50
51
  import Frustum from "./visualization/Frustum";
51
- import FrustumWithCamera from "./visualization/FrustumWithCamera";
52
52
  import Heatmap2d from "./visualization/Heatmap2d";
53
53
  import Heatmap3d from "./visualization/Heatmap3d";
54
54
  import PointCluster from "./visualization/PointCluster";
@@ -58,11 +58,11 @@ DEEP_TWINS_BASE_URL && (window.CESIUM_BASE_URL = DEEP_TWINS_BASE_URL);
58
58
  // 全局加载css
59
59
  loadCss(Cesium.buildModuleUrl('Widgets/widgets.css'));
60
60
  // 打印版本信息
61
- console.log('DeepTwinsEngine3D Version:', "0.1.47");
61
+ console.log('DeepTwinsEngine3D Version:', "0.1.48");
62
62
  export var DeepTwinsEngine3D = /*#__PURE__*/_createClass(function DeepTwinsEngine3D() {
63
63
  _classCallCheck(this, DeepTwinsEngine3D);
64
64
  });
65
- _defineProperty(DeepTwinsEngine3D, "Version", "0.1.47");
65
+ _defineProperty(DeepTwinsEngine3D, "Version", "0.1.48");
66
66
  _defineProperty(DeepTwinsEngine3D, "Map", Map);
67
67
  _defineProperty(DeepTwinsEngine3D, "GroundSkyBox", GroundSkyBox);
68
68
  _defineProperty(DeepTwinsEngine3D, "RasterLayer", RasterLayer);
@@ -86,6 +86,7 @@ _defineProperty(DeepTwinsEngine3D, "DynamicWallMaterialProperty", DynamicWallMat
86
86
  _defineProperty(DeepTwinsEngine3D, "CircleWaveMaterialProperty", CircleWaveMaterialProperty);
87
87
  _defineProperty(DeepTwinsEngine3D, "PolylineTrailLinkMaterialProperty", PolylineTrailLinkMaterialProperty);
88
88
  _defineProperty(DeepTwinsEngine3D, "ImageMaterialProperty", ImageMaterialProperty);
89
+ _defineProperty(DeepTwinsEngine3D, "ImageMaterialAppearance", ImageMaterialAppearance);
89
90
  _defineProperty(DeepTwinsEngine3D, "ImageGlowingMaterialAppearance", ImageGlowingMaterialAppearance);
90
91
  _defineProperty(DeepTwinsEngine3D, "VolumeCloud", VolumeCloud);
91
92
  _defineProperty(DeepTwinsEngine3D, "Heatmap2d", Heatmap2d);
@@ -93,7 +94,6 @@ _defineProperty(DeepTwinsEngine3D, "Heatmap3d", Heatmap3d);
93
94
  _defineProperty(DeepTwinsEngine3D, "PointCluster", PointCluster);
94
95
  _defineProperty(DeepTwinsEngine3D, "PositionProperty", PositionProperty);
95
96
  _defineProperty(DeepTwinsEngine3D, "Frustum", Frustum);
96
- _defineProperty(DeepTwinsEngine3D, "FrustumWithCamera", FrustumWithCamera);
97
97
  _defineProperty(DeepTwinsEngine3D, "GridDraw", GridDraw);
98
98
  _defineProperty(DeepTwinsEngine3D, "VideoTexture", VideoTexture);
99
99
  _defineProperty(DeepTwinsEngine3D, "VideoProject", VideoProject);
@@ -1,4 +1,5 @@
1
1
  export default class BaseMaterialAppearance {
2
+ customMaterial: boolean;
2
3
  type: string;
3
4
  style: any;
4
5
  material: any;
@@ -9,6 +9,7 @@ import { v4 as uuidv4 } from 'uuid';
9
9
  var BaseMaterialAppearance = /*#__PURE__*/function () {
10
10
  function BaseMaterialAppearance(type, style) {
11
11
  _classCallCheck(this, BaseMaterialAppearance);
12
+ _defineProperty(this, "customMaterial", true);
12
13
  _defineProperty(this, "type", void 0);
13
14
  _defineProperty(this, "style", void 0);
14
15
  _defineProperty(this, "material", void 0);
@@ -0,0 +1,10 @@
1
+ import BaseMaterialAppearance from './BaseMaterialAppearance';
2
+ declare class ImageMaterialAppearance extends BaseMaterialAppearance {
3
+ private readonly currMaterial;
4
+ private readonly currAppearance;
5
+ constructor(material: any, appearance: any);
6
+ static handleMaterial(style: any): any;
7
+ private _createMaterial;
8
+ private _createAppearance;
9
+ }
10
+ export default ImageMaterialAppearance;
@@ -0,0 +1,77 @@
1
+ var _excluded = ["color"];
2
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
4
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
5
+ function 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; }
6
+ 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; }
7
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
+ 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); } }
9
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
10
+ 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); }
11
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
12
+ 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); }; }
13
+ 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); }
14
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
15
+ 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; } }
16
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
17
+ 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; }
18
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
19
+ 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); }
20
+ import * as Cesium from 'deeptwins-cesium';
21
+ import { cloneDeep, merge } from 'lodash';
22
+ import { DEFAULT_IMAGE_MATERIAL_STYLE, DEFAULT_MATERIAL_APPEARANCE } from "../../constant";
23
+ import * as utils from "../../tool/utils";
24
+ /* babel-plugin-inline-import '../shader/ImageShader.glsl' */
25
+ var ImageShader = "uniform sampler2D image;\nuniform vec4 color;\nuniform float mixRatio;\n\nczm_material czm_getMaterial(czm_materialInput materialInput) {\n czm_material material = czm_getDefaultMaterial(materialInput);\n vec2 st = materialInput.st;\n\n // \u91C7\u6837\u56FE\u7247\n vec4 texColor = texture(image, st);\n\n // \u989C\u8272\u6DF7\u5408\uFF1Amix(\u539F\u59CB\u989C\u8272, \u76EE\u6807\u989C\u8272, mixRatio)\n vec3 mixedColor = mix(texColor.rgb, texColor.rgb * color.rgb, mixRatio);\n\n // \u53D1\u5149\u589E\u5F3A\n material.diffuse = mixedColor * 2.0;\n\n // \u900F\u660E\u5EA6\u968F\u989C\u8272\u53D8\u5316\n material.alpha = texColor.a * mix(color.a, 1.0, 1.0 - mixRatio);\n\n return material;\n}\n";
26
+ import BaseMaterialAppearance from "./BaseMaterialAppearance";
27
+
28
+ // 图片材质 适用于primitive
29
+ var ImageMaterialAppearance = /*#__PURE__*/function (_BaseMaterialAppearan) {
30
+ _inherits(ImageMaterialAppearance, _BaseMaterialAppearan);
31
+ var _super = _createSuper(ImageMaterialAppearance);
32
+ function ImageMaterialAppearance(material, appearance) {
33
+ var _this;
34
+ _classCallCheck(this, ImageMaterialAppearance);
35
+ var mergeMaterial = merge(DEFAULT_IMAGE_MATERIAL_STYLE(), cloneDeep(material || {}));
36
+ _this = _super.call(this, 'ImageMaterialAsset', mergeMaterial);
37
+ _defineProperty(_assertThisInitialized(_this), "currMaterial", void 0);
38
+ _defineProperty(_assertThisInitialized(_this), "currAppearance", void 0);
39
+ _this.currMaterial = ImageMaterialAppearance.handleMaterial(mergeMaterial);
40
+ _this.currAppearance = merge(DEFAULT_MATERIAL_APPEARANCE(), appearance || {});
41
+ _this._createMaterial();
42
+ return _this;
43
+ }
44
+
45
+ // 处理参数
46
+ _createClass(ImageMaterialAppearance, [{
47
+ key: "_createMaterial",
48
+ value: function _createMaterial() {
49
+ this.material = new Cesium.Material({
50
+ fabric: {
51
+ type: this.type,
52
+ uniforms: _objectSpread({}, this.currMaterial),
53
+ source: ImageShader
54
+ }
55
+ });
56
+ this._createAppearance();
57
+ }
58
+ }, {
59
+ key: "_createAppearance",
60
+ value: function _createAppearance() {
61
+ this.appearance = new Cesium.MaterialAppearance(_objectSpread({
62
+ material: this.material
63
+ }, this.currAppearance));
64
+ }
65
+ }], [{
66
+ key: "handleMaterial",
67
+ value: function handleMaterial(style) {
68
+ var color = style.color,
69
+ options = _objectWithoutProperties(style, _excluded);
70
+ var backStyle = _objectSpread({}, options);
71
+ backStyle.color = utils.colorString(color);
72
+ return backStyle;
73
+ }
74
+ }]);
75
+ return ImageMaterialAppearance;
76
+ }(BaseMaterialAppearance);
77
+ export default ImageMaterialAppearance;
@@ -0,0 +1,22 @@
1
+ uniform sampler2D image;
2
+ uniform vec4 color;
3
+ uniform float mixRatio;
4
+
5
+ czm_material czm_getMaterial(czm_materialInput materialInput) {
6
+ czm_material material = czm_getDefaultMaterial(materialInput);
7
+ vec2 st = materialInput.st;
8
+
9
+ // 采样图片
10
+ vec4 texColor = texture(image, st);
11
+
12
+ // 颜色混合:mix(原始颜色, 目标颜色, mixRatio)
13
+ vec3 mixedColor = mix(texColor.rgb, texColor.rgb * color.rgb, mixRatio);
14
+
15
+ // 发光增强
16
+ material.diffuse = mixedColor * 2.0;
17
+
18
+ // 透明度随颜色变化
19
+ material.alpha = texColor.a * mix(color.a, 1.0, 1.0 - mixRatio);
20
+
21
+ return material;
22
+ }
@@ -42,13 +42,22 @@ export declare const getHeightCompensatedScale: (map: Cesium.Viewer, entityHeigh
42
42
  export declare function calculateLength(positions: any[]): number;
43
43
  export declare function warn(message: string): void;
44
44
  export declare function error(message: string): void;
45
+ /**
46
+ * 去除 Polygon ring 的闭合点(首尾重复)
47
+ */
48
+ export declare function normalizeRing(ring: Cesium.Cartesian3[]): Cesium.Cartesian3[];
49
+ /**
50
+ * 构建 Cesium 安全的 PolygonHierarchy
51
+ * 支持闭合 / 非闭合 / holes
52
+ */
53
+ export declare function buildPolygonHierarchy(positions: Cesium.Cartesian3[], holes?: Cesium.Cartesian3[][]): Cesium.PolygonHierarchy;
45
54
  /**
46
55
  * 沿多边形平面局部坐标系计算 ST
47
56
  * @param positions Cartesian3[] 多边形顶点
48
57
  * @param rotation number 旋转
49
58
  * @returns Float32Array ST 坐标
50
59
  */
51
- export declare function computeSTAlongPlane(positions: any, rotation?: number): Float32Array;
60
+ export declare function computeSTAlongPlane(positions: Cesium.Cartesian3[], rotation?: number): Float32Array;
52
61
  export declare function getMidpoint(position1: Cartesian3, position2: Cartesian3): {
53
62
  lng: number;
54
63
  lat: number;