deeptwins-engine-3d 0.1.44 → 0.1.46

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.
@@ -66,9 +66,9 @@ var BaseVideo = /*#__PURE__*/function () {
66
66
  if (!videoContainer) {
67
67
  return;
68
68
  }
69
- this.videoElement = document.createElement('video');
70
- this.videoElement.id = uuidv4();
71
69
  if (this.videoType === 'video') {
70
+ this.videoElement = document.createElement('video');
71
+ this.videoElement.id = uuidv4();
72
72
  var _merge = merge(DEFAULT_VIDEO_TEXTURE_VIDEO(), this.options.video),
73
73
  loop = _merge.loop,
74
74
  muted = _merge.muted,
@@ -89,6 +89,8 @@ var BaseVideo = /*#__PURE__*/function () {
89
89
  this.videoElement.appendChild(sourceEl);
90
90
  videoContainer.appendChild(this.videoElement);
91
91
  } else if (this.videoType === 'hls') {
92
+ this.videoElement = document.createElement('video');
93
+ this.videoElement.id = uuidv4();
92
94
  var _merge2 = merge(DEFAULT_VIDEO_TEXTURE_HLS(), this.options.hls),
93
95
  _muted = _merge2.muted,
94
96
  _autoPlay = _merge2.autoPlay,
@@ -128,16 +130,15 @@ var BaseVideo = /*#__PURE__*/function () {
128
130
  });
129
131
  }
130
132
  } else if (this.videoType === 'custom') {
131
- var _this$options$custom = this.options.custom,
132
- _width2 = _this$options$custom.width,
133
- _height2 = _this$options$custom.height,
134
- onReady = _this$options$custom.onReady;
135
- this.videoElement.width = _width2;
136
- this.videoElement.height = _height2;
137
- videoContainer.appendChild(this.videoElement);
133
+ var element = document.createElement('div');
134
+ element.id = uuidv4();
135
+ var onReady = this.options.custom.onReady;
136
+ videoContainer.appendChild(element);
138
137
  if (onReady) {
139
138
  this.status = 'READY';
140
- onReady(this.videoElement, this.play, this.pause);
139
+ onReady(element, function (video) {
140
+ _this.videoElement = video;
141
+ });
141
142
  }
142
143
  }
143
144
  }
@@ -157,9 +158,7 @@ var BaseVideo = /*#__PURE__*/function () {
157
158
  key: "_drawCanvas",
158
159
  value: function _drawCanvas(options) {
159
160
  var width = options.width,
160
- height = options.height,
161
- _options$featherSize = options.featherSize,
162
- featherSize = _options$featherSize === void 0 ? 100 : _options$featherSize;
161
+ height = options.height;
163
162
  var canvas = document.createElement('canvas');
164
163
  canvas.width = width;
165
164
  canvas.height = height;
@@ -315,7 +314,7 @@ var BaseVideo = /*#__PURE__*/function () {
315
314
  this.isDestroyed = true;
316
315
  if (this.videoType === 'hls') {
317
316
  this.synchronizer && this.synchronizer.destroy();
318
- this.hls && this.hls.destroyed();
317
+ this.hls && this.hls.destroy();
319
318
  this.getMap().clock.shouldAnimate = false;
320
319
  }
321
320
  if (this.videoType === 'custom') {
@@ -53,81 +53,83 @@ var VideoProject = /*#__PURE__*/function (_BaseVideo) {
53
53
  if (this.videoType === 'custom') {
54
54
  videoOptions = merge({}, this.options.custom);
55
55
  }
56
- var _this$options = this.options,
57
- _this$options$type = _this$options.type,
58
- type = _this$options$type === void 0 ? 'fixed' : _this$options$type,
59
- frustum = _this$options.frustum,
60
- _this$options$style = _this$options.style,
61
- _this$options$style2 = _this$options$style === void 0 ? {
62
- edgeFeather: false,
63
- clampToGround: 'terrain',
64
- showLine: true
65
- } : _this$options$style,
66
- edgeFeather = _this$options$style2.edgeFeather,
67
- clampToGround = _this$options$style2.clampToGround,
68
- showLine = _this$options$style2.showLine;
69
- frustum.show(false);
70
- this.type = type;
71
- this.frustum = frustum;
72
- // 取后4个点
73
- var points = this.frustum.getFrustumVertexPoints().slice(-4);
74
- if (this.type === 'projection') {
75
- // 交点数组
76
- var interPoints = [];
77
- points.forEach(function (point) {
78
- var interPoint = _this2._getInterPointByLine(_this2.frustum.options.position, point);
79
- interPoints.push(interPoint);
80
- });
81
- if (showLine) {
82
- // 绘制线
83
- this._drawLine(interPoints);
84
- }
85
- this.videoPolygonLayer = map.addGraphicLayer({
86
- type: 'Feature',
87
- geometry: {
88
- type: 'Polygon',
89
- coordinates: [interPoints]
90
- }
91
- }, {
92
- type: 'polygon',
93
- style: {
94
- material: edgeFeather ? new Cesium.ImageMaterialProperty({
95
- image: new Cesium.CallbackProperty(function () {
96
- return _this2._drawCanvas(videoOptions);
97
- }, false),
98
- transparent: true
99
- }) : this.videoElement,
100
- heightReference: clampToGround ? Cesium.HeightReference.CLAMP_TO_GROUND : Cesium.HeightReference.NONE,
101
- perPositionHeight: !clampToGround
56
+ setTimeout(function () {
57
+ var _this2$options = _this2.options,
58
+ _this2$options$type = _this2$options.type,
59
+ type = _this2$options$type === void 0 ? 'fixed' : _this2$options$type,
60
+ frustum = _this2$options.frustum,
61
+ _this2$options$style = _this2$options.style,
62
+ _this2$options$style2 = _this2$options$style === void 0 ? {
63
+ edgeFeather: false,
64
+ clampToGround: 'terrain',
65
+ showLine: true
66
+ } : _this2$options$style,
67
+ edgeFeather = _this2$options$style2.edgeFeather,
68
+ clampToGround = _this2$options$style2.clampToGround,
69
+ showLine = _this2$options$style2.showLine;
70
+ frustum.show(false);
71
+ _this2.type = type;
72
+ _this2.frustum = frustum;
73
+ // 取后4个点
74
+ var points = _this2.frustum.getFrustumVertexPoints().slice(-4);
75
+ if (_this2.type === 'projection') {
76
+ // 交点数组
77
+ var interPoints = [];
78
+ points.forEach(function (point) {
79
+ var interPoint = _this2._getInterPointByLine(_this2.frustum.options.position, point);
80
+ interPoints.push(interPoint);
81
+ });
82
+ if (showLine) {
83
+ // 绘制线
84
+ _this2._drawLine(interPoints);
102
85
  }
103
- });
104
- }
105
- if (this.type === 'fixed') {
106
- if (showLine) {
107
- // 绘制线
108
- this._drawLine(points);
86
+ _this2.videoPolygonLayer = map.addGraphicLayer({
87
+ type: 'Feature',
88
+ geometry: {
89
+ type: 'Polygon',
90
+ coordinates: [interPoints]
91
+ }
92
+ }, {
93
+ type: 'polygon',
94
+ style: {
95
+ material: edgeFeather ? new Cesium.ImageMaterialProperty({
96
+ image: new Cesium.CallbackProperty(function () {
97
+ return _this2._drawCanvas(videoOptions);
98
+ }, false),
99
+ transparent: true
100
+ }) : _this2.videoElement,
101
+ heightReference: clampToGround ? Cesium.HeightReference.CLAMP_TO_GROUND : Cesium.HeightReference.NONE,
102
+ perPositionHeight: !clampToGround
103
+ }
104
+ });
109
105
  }
110
- this.videoPolygonLayer = map.addGraphicLayer({
111
- type: 'Feature',
112
- geometry: {
113
- type: 'Polygon',
114
- coordinates: [points]
115
- }
116
- }, {
117
- type: 'polygon',
118
- style: {
119
- material: edgeFeather ? new Cesium.ImageMaterialProperty({
120
- image: new Cesium.CallbackProperty(function () {
121
- return _this2._drawCanvas(videoOptions);
122
- }, false),
123
- transparent: true
124
- }) : this.videoElement,
125
- heightReference: Cesium.HeightReference.NONE,
126
- perPositionHeight: true
106
+ if (_this2.type === 'fixed') {
107
+ if (showLine) {
108
+ // 绘制线
109
+ _this2._drawLine(points);
127
110
  }
128
- });
129
- }
130
- this.status = 'START';
111
+ _this2.videoPolygonLayer = map.addGraphicLayer({
112
+ type: 'Feature',
113
+ geometry: {
114
+ type: 'Polygon',
115
+ coordinates: [points]
116
+ }
117
+ }, {
118
+ type: 'polygon',
119
+ style: {
120
+ material: edgeFeather ? new Cesium.ImageMaterialProperty({
121
+ image: new Cesium.CallbackProperty(function () {
122
+ return _this2._drawCanvas(videoOptions);
123
+ }, false),
124
+ transparent: true
125
+ }) : _this2.videoElement,
126
+ heightReference: Cesium.HeightReference.NONE,
127
+ perPositionHeight: true
128
+ }
129
+ });
130
+ }
131
+ _this2.status = 'START';
132
+ }, 200);
131
133
  }
132
134
 
133
135
  // 显示隐藏
@@ -146,7 +148,7 @@ var VideoProject = /*#__PURE__*/function (_BaseVideo) {
146
148
  key: "_drawLine",
147
149
  value: function _drawLine(interPoints) {
148
150
  var _this3 = this,
149
- _this$options$style3;
151
+ _this$options$style;
150
152
  var draw = function draw(geoJson) {
151
153
  _this3.frustumLineLayer = _this3.getMap().addGraphicLayer(geoJson, {
152
154
  type: 'polylineP',
@@ -157,7 +159,7 @@ var VideoProject = /*#__PURE__*/function (_BaseVideo) {
157
159
  };
158
160
  var linePoints = [];
159
161
  // 是否计算贴地
160
- if ((_this$options$style3 = this.options.style) !== null && _this$options$style3 !== void 0 && _this$options$style3.clampToGround && this.type === 'projection') {
162
+ if ((_this$options$style = this.options.style) !== null && _this$options$style !== void 0 && _this$options$style.clampToGround && this.type === 'projection') {
161
163
  var clampToGround = new ClampToGround(this.getMap());
162
164
  var c3arr = utils.lngLatAltArrayToCartesian3Array(interPoints);
163
165
  clampToGround.getLngLatAltArrToHeight(c3arr, 'terrain').then(function (result) {
@@ -55,18 +55,20 @@ var VideoTexture = /*#__PURE__*/function (_BaseVideo) {
55
55
  } : _this$options$style,
56
56
  edgeFeather = _this$options$style2.edgeFeather,
57
57
  style = _objectWithoutProperties(_this$options$style2, _excluded);
58
- this.videoPolygonLayer = map.addGraphicLayer(this.options.data, {
59
- type: 'polygon',
60
- style: _objectSpread({
61
- material: edgeFeather ? new Cesium.ImageMaterialProperty({
62
- image: new Cesium.CallbackProperty(function () {
63
- return _this._drawCanvas(videoOptions);
64
- }, false),
65
- transparent: true
66
- }) : this.videoElement
67
- }, style || {})
68
- });
69
- this.status = 'START';
58
+ setTimeout(function () {
59
+ _this.videoPolygonLayer = map.addGraphicLayer(_this.options.data, {
60
+ type: 'polygon',
61
+ style: _objectSpread({
62
+ material: edgeFeather ? new Cesium.ImageMaterialProperty({
63
+ image: new Cesium.CallbackProperty(function () {
64
+ return _this._drawCanvas(videoOptions);
65
+ }, false),
66
+ transparent: true
67
+ }) : _this.videoElement
68
+ }, style || {})
69
+ });
70
+ _this.status = 'START';
71
+ }, 200);
70
72
  }
71
73
  }]);
72
74
  return VideoTexture;
@@ -15,6 +15,7 @@ import { cloneDeep, flattenDeep, merge } from 'lodash';
15
15
  import { v4 as uuidv4 } from 'uuid';
16
16
  import { DEFAULT_POINT_CLUSTER_STYLE } from "../constant";
17
17
  import BaseSource from "../graphicLayer/BaseSource";
18
+ import BillboardPrimitive from "../graphicLayer/BillboardPrimitive";
18
19
  import PrimitiveCluster from "../tool/PrimitiveCluster";
19
20
  import * as utils from "../tool/utils";
20
21
  var PointCluster = /*#__PURE__*/function () {
@@ -68,17 +69,21 @@ var PointCluster = /*#__PURE__*/function () {
68
69
  primitiveCluster.pixelRange = this.options.pixelRange;
69
70
  primitiveCluster.minimumClusterSize = 1;
70
71
  this.source.forEach(function (t) {
71
- var billboard = _objectSpread(_objectSpread({
72
- id: uuidv4()
73
- }, merge({
72
+ var style = BillboardPrimitive.handleOptions(merge({
74
73
  width: 30,
75
74
  height: 30
76
- }, _this.options.billboard || {})), {}, {
75
+ }, utils.styleFun(cloneDeep(_this.options.billboard || {}), t.properties)));
76
+ var billboard = _objectSpread(_objectSpread({
77
+ id: uuidv4()
78
+ }, style), {}, {
77
79
  position: t.positions,
78
- source: t
80
+ properties: t.properties,
81
+ geometry: t.geometry,
82
+ style: _this.options.billboard
79
83
  });
80
84
  _this.billboards.push(billboard);
81
- _this.billboardsCollectionCombine.add(billboard);
85
+ var billboarded = _this.billboardsCollectionCombine.add(billboard);
86
+ billboarded.properties = t.properties;
82
87
  });
83
88
 
84
89
  // 将数据传给primitiveCluster的标签属性
@@ -101,16 +106,38 @@ var PointCluster = /*#__PURE__*/function () {
101
106
  }
102
107
  }
103
108
  if (step == -1) {
104
- if (_this.options.billboard) {
105
- var _this$options$billboa, _this$options$billboa2, _this$options$billboa3;
106
- cluster.billboard.image = (_this$options$billboa = _this.options.billboard) === null || _this$options$billboa === void 0 ? void 0 : _this$options$billboa.image;
107
- cluster.billboard.width = (_this$options$billboa2 = _this.options.billboard) === null || _this$options$billboa2 === void 0 ? void 0 : _this$options$billboa2.width;
108
- cluster.billboard.height = (_this$options$billboa3 = _this.options.billboard) === null || _this$options$billboa3 === void 0 ? void 0 : _this$options$billboa3.height;
109
- } else {
109
+ if (_this.options.onCustomRender) {
110
110
  cluster.billboard.show = false;
111
+ var clusterPoints = _this.billboards.filter(function (t) {
112
+ return clusteredEntities.includes(t.id);
113
+ });
114
+ _this.options.onCustomRender(step, utils.cartesian3ToLngLatAlt(cluster.billboard.position), clusterPoints);
115
+ } else {
116
+ if (_this.options.billboard) {
117
+ var billboard = _this.billboardsCollectionCombine._billboards.find(function (t) {
118
+ return clusteredEntities.includes(t.id);
119
+ });
120
+ var style = BillboardPrimitive.handleOptions(merge({
121
+ width: 30,
122
+ height: 30
123
+ }, utils.styleFun(cloneDeep(_this.options.billboard || {}), (billboard === null || billboard === void 0 ? void 0 : billboard.properties) || {})));
124
+ Object.keys(style).forEach(function (key) {
125
+ cluster.billboard[key] = style[key];
126
+ });
127
+ } else {
128
+ cluster.billboard.show = false;
129
+ }
111
130
  }
112
131
  } else {
113
- cluster.billboard.image = _this._drawImage(clusteredEntities.length, _this.options.grade[step].size, _this.options.grade[step].color);
132
+ if (_this.options.onCustomRender) {
133
+ cluster.billboard.show = false;
134
+ var _clusterPoints = _this.billboards.filter(function (t) {
135
+ return clusteredEntities.includes(t.id);
136
+ });
137
+ _this.options.onCustomRender(step, utils.cartesian3ToLngLatAlt(cluster.billboard.position), _clusterPoints);
138
+ } else {
139
+ cluster.billboard.image = _this._drawImage(clusteredEntities.length, _this.options.grade[step].size, _this.options.grade[step].color);
140
+ }
114
141
  }
115
142
  });
116
143
  }