deeptwins-engine-3d 0.1.24 → 0.1.26

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.
@@ -23,6 +23,7 @@ export default class BaseLayer {
23
23
  setStyleOne(layer: any, style: any): void;
24
24
  setData(data: any): void;
25
25
  remove(): void;
26
+ onModelReady(fun: any): void;
26
27
  removeOne(layer: any): void;
27
28
  flyTo(options: any): void;
28
29
  on(type: any, event: any): any;
@@ -24,8 +24,6 @@ import PolylinePrimitive from "./PolylinePrimitive";
24
24
  import PolylineVolumePrimitive from "./PolylineVolumePrimitive";
25
25
  import WallPrimitive from "./WallPrimitive";
26
26
  var BaseLayer = /*#__PURE__*/function () {
27
- // 处理类的函数
28
-
29
27
  function BaseLayer(_ref) {
30
28
  var _this = this;
31
29
  var id = _ref.id,
@@ -47,6 +45,7 @@ var BaseLayer = /*#__PURE__*/function () {
47
45
  _defineProperty(this, "isPrimitive", false);
48
46
  // 是否是完整的信息
49
47
  _defineProperty(this, "_isCompleteInfo", true);
48
+ // 处理类的函数
50
49
  _defineProperty(this, "_renderClass", void 0);
51
50
  if (!(options !== null && options !== void 0 && options.type)) {
52
51
  utils.error('请传入type参数');
@@ -318,6 +317,16 @@ var BaseLayer = /*#__PURE__*/function () {
318
317
  this.getMap().graphicLayerCollection._removeGraphicMapLayer(this.id);
319
318
  }
320
319
 
320
+ // 模型加载完成
321
+ }, {
322
+ key: "onModelReady",
323
+ value: function onModelReady(fun) {
324
+ if (!this._canOperate()) return;
325
+ if (this.isPrimitive) {
326
+ this.primitiveCollection.onReady(fun);
327
+ }
328
+ }
329
+
321
330
  // 清除图层中某个
322
331
  }, {
323
332
  key: "removeOne",
@@ -1,5 +1,7 @@
1
1
  import BasePrimitive from './BasePrimitive';
2
2
  export default class ModelPrimitive extends BasePrimitive {
3
+ private _readyEvent;
3
4
  constructor(map: any);
4
5
  createPrimitive(options: any, primitiveInstance: any[]): void;
6
+ onReady(fun: any): void;
5
7
  }
@@ -2,8 +2,6 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
2
2
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
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
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 _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
- 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); }
7
5
  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
6
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
9
7
  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); }; }
@@ -11,6 +9,9 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
11
9
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
12
10
  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
11
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
12
+ 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; }
13
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
14
+ 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); }
14
15
  import * as Cesium from 'deeptwins-cesium';
15
16
  import { cloneDeep, merge } from 'lodash';
16
17
  import { DEFAULT_MODEL_PRIMITIVE_OPTIONS } from "../constant";
@@ -19,13 +20,16 @@ var ModelPrimitive = /*#__PURE__*/function (_BasePrimitive) {
19
20
  _inherits(ModelPrimitive, _BasePrimitive);
20
21
  var _super = _createSuper(ModelPrimitive);
21
22
  function ModelPrimitive(map) {
23
+ var _this;
22
24
  _classCallCheck(this, ModelPrimitive);
23
- return _super.call(this, map);
25
+ _this = _super.call(this, map);
26
+ _defineProperty(_assertThisInitialized(_this), "_readyEvent", void 0);
27
+ return _this;
24
28
  }
25
29
  _createClass(ModelPrimitive, [{
26
30
  key: "createPrimitive",
27
31
  value: function createPrimitive() {
28
- var _this = this;
32
+ var _this2 = this;
29
33
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
30
34
  var primitiveInstance = arguments.length > 1 ? arguments[1] : undefined;
31
35
  var style = merge(DEFAULT_MODEL_PRIMITIVE_OPTIONS(), cloneDeep(options.style || {}));
@@ -33,14 +37,22 @@ var ModelPrimitive = /*#__PURE__*/function (_BasePrimitive) {
33
37
  Promise.allSettled(primitiveInstance).then(function (models) {
34
38
  models.forEach(function (model) {
35
39
  if (model.status === 'fulfilled') {
36
- _this.primitive.add(model.value);
40
+ _this2.primitive.add(model.value);
37
41
  } else {
38
42
  console.error(model);
39
43
  }
40
44
  });
45
+ _this2._readyEvent && _this2._readyEvent(_this2.primitive._primitives);
41
46
  });
42
47
  this.show = !!(style !== null && style !== void 0 && style.show);
43
48
  }
49
+
50
+ // 模型加载完成
51
+ }, {
52
+ key: "onReady",
53
+ value: function onReady(fun) {
54
+ this._readyEvent = fun;
55
+ }
44
56
  }]);
45
57
  return ModelPrimitive;
46
58
  }(BasePrimitive);
package/dist/esm/index.js CHANGED
@@ -50,7 +50,7 @@ loadCss(Cesium.buildModuleUrl('Widgets/widgets.css'));
50
50
  export var DeepTwinsEngine3D = /*#__PURE__*/_createClass(function DeepTwinsEngine3D() {
51
51
  _classCallCheck(this, DeepTwinsEngine3D);
52
52
  });
53
- _defineProperty(DeepTwinsEngine3D, "Version", "0.1.24");
53
+ _defineProperty(DeepTwinsEngine3D, "Version", "0.1.26");
54
54
  _defineProperty(DeepTwinsEngine3D, "Map", Map);
55
55
  _defineProperty(DeepTwinsEngine3D, "GroundSkyBox", GroundSkyBox);
56
56
  _defineProperty(DeepTwinsEngine3D, "RasterLayer", RasterLayer);
@@ -5,12 +5,14 @@ export default class Airspace {
5
5
  primitives: any[];
6
6
  isDestroyed: boolean;
7
7
  private _events;
8
+ private _isShow;
8
9
  constructor(map: any, geoJson: any, options?: any);
9
10
  getMap(): any;
10
11
  startDraw(geoJson: any): void;
11
12
  private _canOperate;
12
13
  sliceArrayAsync(data: any[], chunkSize?: number): void;
13
- on(eventType: string, event: any): void;
14
14
  create(source: any[]): void;
15
+ show(isShow: boolean): void;
16
+ on(eventType: string, event: any): void;
15
17
  destroy(): void;
16
18
  }
@@ -22,6 +22,7 @@ var Airspace = /*#__PURE__*/function () {
22
22
  _defineProperty(this, "primitives", []);
23
23
  _defineProperty(this, "isDestroyed", false);
24
24
  _defineProperty(this, "_events", {});
25
+ _defineProperty(this, "_isShow", true);
25
26
  this._mapContext = map._mapContext;
26
27
  this.options = merge(DEFAULT_AIRSPACE_STYLE(), options);
27
28
  this.startDraw(geoJson);
@@ -66,13 +67,6 @@ var Airspace = /*#__PURE__*/function () {
66
67
  };
67
68
  processChunk();
68
69
  }
69
-
70
- // 事件
71
- }, {
72
- key: "on",
73
- value: function on(eventType, event) {
74
- this._events[eventType] = event;
75
- }
76
70
  }, {
77
71
  key: "create",
78
72
  value: function create(source) {
@@ -86,6 +80,7 @@ var Airspace = /*#__PURE__*/function () {
86
80
  new BoxPrimitiveInstance({
87
81
  positions: source[i].positions,
88
82
  style: {
83
+ show: this._isShow,
89
84
  color: source[i].properties.color,
90
85
  dimensions: this.options.dimensions,
91
86
  scale: this.options.scale
@@ -98,6 +93,23 @@ var Airspace = /*#__PURE__*/function () {
98
93
  }, primitiveInstance);
99
94
  this.getMap().scene.primitives.add(boxPrimitive.primitive);
100
95
  }
96
+
97
+ // 显示隐藏
98
+ }, {
99
+ key: "show",
100
+ value: function show(isShow) {
101
+ this._isShow = isShow;
102
+ this.primitives.forEach(function (t) {
103
+ t.show = isShow;
104
+ });
105
+ }
106
+
107
+ // 事件
108
+ }, {
109
+ key: "on",
110
+ value: function on(eventType, event) {
111
+ this._events[eventType] = event;
112
+ }
101
113
  }, {
102
114
  key: "destroy",
103
115
  value: function destroy() {