@ohuoy/easymap 1.0.21 → 1.0.23
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.
- package/dist/bundle.js +80 -47
- package/dist/example - /345/211/257/346/234/254/bundle.js" +80 -47
- package/dist/example - /345/211/257/346/234/254/index.html" +33 -3
- package/index.js +195 -7
- package/lib/threebox-plugin/src/three.module.js +1 -0
- package/package.json +2 -2
- package/src/components/EasyMapMarker.js +7 -3
- package/src/components/control/TilesBar.js +87 -12
- package/src/components/control/Toobars.js +63 -24
- package/src/components/index.js +9 -2
- package/src/components/layer/AlarmLayer.js +13 -12
- package/src/components/layer/AnimationBarbsLayer.js +13 -12
- package/src/components/layer/AnimationLayer.js +38 -21
- package/src/components/layer/CustomIconLayer.js +6 -5
- package/src/components/layer/ExtrusionLayer.js +71 -66
- package/src/components/layer/MarkerAreaLayer.js +10 -9
- package/src/components/layer/PathLineLayer.js +30 -14
- package/src/components/layer/ScanWallLayer.js +467 -0
- package/src/components/layer/ThreeBoxWallLayer.js +253 -0
- package/src/components/layer/ThreeScanLayer.js +63 -37
- package/src/components/layer/ThreeWallLayer copy 2.js +1104 -0
- package/src/components/layer/ThreeWallLayer copy.js +517 -0
- package/src/components/layer/ThreeWallLayer.js +231 -256
- package/src/components/layer/WallLayer.js +3 -2
- package/src/components/layer/WebGlWallLayer.js +320 -0
- package/src/components/mapOutScreen.js +15 -3
- package/src/utils/CameraSync.js +6 -3
- package/src/utils/mapWatch.js +70 -0
- package/src/utils/util.js +3 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as turf from '@turf/turf'
|
|
2
2
|
import { transform } from '../../../src/utils/util.js';
|
|
3
|
+
import { esMapWatchEffect } from '../../utils/mapWatch.js';
|
|
3
4
|
export default class Toobars {
|
|
4
5
|
_map;
|
|
5
6
|
_container;
|
|
@@ -48,6 +49,7 @@ export default class Toobars {
|
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
this.config =_c;
|
|
52
|
+
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
onAdd(map) {
|
|
@@ -57,7 +59,7 @@ export default class Toobars {
|
|
|
57
59
|
this._container.innerHTML += `<div aria-label="infobox" class='mapboxgl-ctrl-infobox' style='display:flex;flex-direction:column;position:absolute;top:-100px;margin: 0 50px;width:140px' ></div>`
|
|
58
60
|
if(this.config.line?.show){
|
|
59
61
|
this._container.getElementsByClassName('mapboxgl-ctrl-infobox')[0].innerHTML+=`
|
|
60
|
-
<div class='linedis-message-show ${this.config.line.messageClass}' ></div>`
|
|
62
|
+
<div class='linedis-message-show msg-font ${this.config.line.messageClass}' ></div>`
|
|
61
63
|
this._container.innerHTML += `
|
|
62
64
|
<button class="mapboxgl-ctrl-linedis ${this.config.line.btnClass}" type="button" aria-label="linedis" aria-disabled="false">
|
|
63
65
|
<span style='display:flex;align-item:center;' class="mapboxgl-ctrl-icon" aria-hidden="true" title="划线测距">
|
|
@@ -77,7 +79,7 @@ export default class Toobars {
|
|
|
77
79
|
}
|
|
78
80
|
if(this.config.position?.show){
|
|
79
81
|
this._container.getElementsByClassName('mapboxgl-ctrl-infobox')[0].innerHTML+=`
|
|
80
|
-
<div class='position-message-show ${this.config.line.messageClass}' ></div>`
|
|
82
|
+
<div class='position-message-show msg-font ${this.config.line.messageClass}' ></div>`
|
|
81
83
|
this._container.innerHTML += `
|
|
82
84
|
<button class="mapboxgl-ctrl-position ${this.config.position.btnClass}" type="button" aria-label="position" aria-disabled="false">
|
|
83
85
|
<span style='display:flex;align-item:center;' class="mapboxgl-ctrl-icon" aria-hidden="true" title="显示经纬度">
|
|
@@ -113,6 +115,11 @@ export default class Toobars {
|
|
|
113
115
|
// let btn = this._container.getElementsByClassName('mapboxgl-ctrl-rect')[0]
|
|
114
116
|
// this.addRect(btn)
|
|
115
117
|
// }
|
|
118
|
+
|
|
119
|
+
esMapWatchEffect(()=>{
|
|
120
|
+
this.updateStyleByTheme()
|
|
121
|
+
})
|
|
122
|
+
|
|
116
123
|
return this._container;
|
|
117
124
|
}
|
|
118
125
|
|
|
@@ -122,6 +129,27 @@ export default class Toobars {
|
|
|
122
129
|
this.addLocation(btn)
|
|
123
130
|
}
|
|
124
131
|
}
|
|
132
|
+
|
|
133
|
+
updateStyleByTheme(){
|
|
134
|
+
let fontMsg = this._container.getElementsByClassName('msg-font')
|
|
135
|
+
let _currentTheme = this._map.theme.value;
|
|
136
|
+
let layerPoint = this._map.getLayer('measure-points')
|
|
137
|
+
let layerLine = this._map.getLayer('measure-lines')
|
|
138
|
+
let color = _currentTheme == "dark" ? "#fff" :'#000'
|
|
139
|
+
for(let el of fontMsg){
|
|
140
|
+
el.style.color = color
|
|
141
|
+
}
|
|
142
|
+
if(layerPoint){
|
|
143
|
+
this._map.setPaintProperty('measure-points','circle-color' ,color )
|
|
144
|
+
// layerPoint.paint["circle-color"] = color
|
|
145
|
+
}
|
|
146
|
+
if(layerLine) {
|
|
147
|
+
// layerLine.paint['line-color'] = color;
|
|
148
|
+
this._map.setPaintProperty('measure-lines','line-color' ,color )
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
}
|
|
152
|
+
|
|
125
153
|
addLindDis(btn){
|
|
126
154
|
let lineDis = {
|
|
127
155
|
'type': 'FeatureCollection',
|
|
@@ -137,7 +165,7 @@ export default class Toobars {
|
|
|
137
165
|
btn.addEventListener('click',()=>{
|
|
138
166
|
let box = this._container.getElementsByClassName('linedis-message-show')[0].parentNode;
|
|
139
167
|
let pos = box.getBoundingClientRect()
|
|
140
|
-
if(pos.x >
|
|
168
|
+
if(pos.x > this._map._container.clientWidth/2){
|
|
141
169
|
box.style.right = 0
|
|
142
170
|
box.style.left = ''
|
|
143
171
|
}else{
|
|
@@ -154,7 +182,7 @@ export default class Toobars {
|
|
|
154
182
|
'type': 'LineString',
|
|
155
183
|
'coordinates': []
|
|
156
184
|
}
|
|
157
|
-
};
|
|
185
|
+
};
|
|
158
186
|
if(!this.clickLineDisFun){
|
|
159
187
|
this.clickLineDisFun = (e) => {
|
|
160
188
|
let features = this._map.queryRenderedFeatures(e.point, {
|
|
@@ -203,6 +231,7 @@ export default class Toobars {
|
|
|
203
231
|
}
|
|
204
232
|
if(!this.mousemoveLineDisFun){
|
|
205
233
|
this.mousemoveLineDisFun = (e) => {
|
|
234
|
+
if(!this.lineClicked){return}
|
|
206
235
|
let features = this._map.queryRenderedFeatures(e.point, {
|
|
207
236
|
layers: ['measure-points']
|
|
208
237
|
});
|
|
@@ -221,6 +250,9 @@ export default class Toobars {
|
|
|
221
250
|
'data': lineDis
|
|
222
251
|
});
|
|
223
252
|
|
|
253
|
+
let currentTheme =this._map.theme.value ? this._map.theme.value: this._map.style.stylesheet.theme;
|
|
254
|
+
|
|
255
|
+
let lineColor = currentTheme && currentTheme == 'dark' ? '#fff':'#000'
|
|
224
256
|
// Add styles to the map
|
|
225
257
|
this._map.addLayer({
|
|
226
258
|
id: 'measure-points',
|
|
@@ -228,7 +260,7 @@ export default class Toobars {
|
|
|
228
260
|
source: 'lineDis',
|
|
229
261
|
paint: {
|
|
230
262
|
'circle-radius': 5,
|
|
231
|
-
'circle-color':
|
|
263
|
+
'circle-color': lineColor
|
|
232
264
|
},
|
|
233
265
|
filter: ['in', '$type', 'Point']
|
|
234
266
|
});
|
|
@@ -241,7 +273,7 @@ export default class Toobars {
|
|
|
241
273
|
'line-join': 'round'
|
|
242
274
|
},
|
|
243
275
|
paint: {
|
|
244
|
-
'line-color':
|
|
276
|
+
'line-color': lineColor,
|
|
245
277
|
'line-width': 2.5
|
|
246
278
|
},
|
|
247
279
|
filter: ['in', '$type', 'LineString']
|
|
@@ -251,23 +283,30 @@ export default class Toobars {
|
|
|
251
283
|
|
|
252
284
|
this._map.on('mousemove',this.mousemoveLineDisFun);
|
|
253
285
|
}else{
|
|
254
|
-
|
|
255
|
-
this._container.getElementsByClassName('linedis-message-show')[0].innerHTML = ''
|
|
256
|
-
this._map.off('click',this.clickLineDisFun)
|
|
257
|
-
this._map.off('mousemove',this.mousemoveLineDisFun)
|
|
258
|
-
// Add styles to the map
|
|
259
|
-
let points = this._map.getLayer('measure-points')
|
|
260
|
-
if(points){
|
|
261
|
-
this._map.removeLayer('measure-points');
|
|
262
|
-
}
|
|
263
|
-
if(this._map.getLayer('measure-lines')){
|
|
264
|
-
this._map.removeLayer('measure-lines');
|
|
265
|
-
}
|
|
266
|
-
this._map.removeSource('lineDis');
|
|
286
|
+
this.removeLine()
|
|
267
287
|
}
|
|
268
288
|
})
|
|
269
289
|
}
|
|
270
290
|
|
|
291
|
+
removeLine(){
|
|
292
|
+
this.lineClicked=false;
|
|
293
|
+
if(this._container.getElementsByClassName('linedis-message-show').length > 0){
|
|
294
|
+
this._container.getElementsByClassName('linedis-message-show')[0].innerHTML = ''
|
|
295
|
+
this._map.off('click',this.clickLineDisFun)
|
|
296
|
+
this._map.off('mousemove',this.mousemoveLineDisFun)
|
|
297
|
+
// Add styles to the map
|
|
298
|
+
let points = this._map.getLayer('measure-points')
|
|
299
|
+
if(points){
|
|
300
|
+
this._map.removeLayer('measure-points');
|
|
301
|
+
}
|
|
302
|
+
if(this._map.getLayer('measure-lines')){
|
|
303
|
+
this._map.removeLayer('measure-lines');
|
|
304
|
+
}
|
|
305
|
+
if(this._map.getSource('lineDis')){
|
|
306
|
+
this._map.removeSource('lineDis');
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
271
310
|
|
|
272
311
|
addRect(){
|
|
273
312
|
|
|
@@ -302,20 +341,20 @@ export default class Toobars {
|
|
|
302
341
|
|
|
303
342
|
}
|
|
304
343
|
|
|
305
|
-
addPosition(btn){
|
|
306
|
-
|
|
307
|
-
if(!this.mousemovePositionFun){
|
|
344
|
+
addPosition(btn){
|
|
345
|
+
if(!this.mousemovePositionFun){
|
|
308
346
|
this.mousemovePositionFun = (e) => {
|
|
347
|
+
// this.removeLine()
|
|
309
348
|
let lngLat = transform([e.lngLat.lng,e.lngLat.lat],true)
|
|
310
349
|
this._container.getElementsByClassName('position-message-show')[0].innerHTML =
|
|
311
350
|
this.config.position.pointShow ? `经度:${lngLat[0].toFixed(6)}<br/>纬度:${lngLat[1].toFixed(6)}<br/>x:${e.point.x},y:${e.point.y}`
|
|
312
351
|
: `经度:${lngLat[0].toFixed(6)}<br/>纬度:${lngLat[1].toFixed(6)}`
|
|
313
352
|
}
|
|
314
353
|
}
|
|
315
|
-
btn.addEventListener('click',()=>{
|
|
354
|
+
btn.addEventListener('click',()=>{
|
|
316
355
|
let box = this._container.getElementsByClassName('position-message-show')[0].parentNode;
|
|
317
356
|
let pos = box.getBoundingClientRect()
|
|
318
|
-
if(pos.x >
|
|
357
|
+
if(pos.x > this._map._container.clientWidth/2){
|
|
319
358
|
box.style.right = 0
|
|
320
359
|
box.style.left = ''
|
|
321
360
|
}else{
|
package/src/components/index.js
CHANGED
|
@@ -7,16 +7,21 @@ import LineTool from './control/Toobars'
|
|
|
7
7
|
import ScanLayer from './layer/ScanLayer'
|
|
8
8
|
import TextLayer from './layer/TextLayer'
|
|
9
9
|
import AlarmLayer from './layer/AlarmLayer'
|
|
10
|
-
import WallLayer from './layer/
|
|
10
|
+
// import WallLayer from './layer/ScanWallLayer'
|
|
11
11
|
import AnimationLayer from './layer/AnimationLayer'
|
|
12
12
|
import CustomIconLayer from './layer/CustomIconLayer'
|
|
13
13
|
import ThreeScanLayer from './layer/ThreeScanLayer'
|
|
14
14
|
import ThreeWallLayer from './layer/ThreeWallLayer'
|
|
15
|
+
import ThreeBoxWallLayer from './layer/ThreeBoxWallLayer'
|
|
16
|
+
import WebGlWallLayer from './layer/WebGlWallLayer'
|
|
15
17
|
import AnimationBarbsLayer from './layer/AnimationBarbsLayer'
|
|
16
18
|
import PathLineLayer from './layer/PathLineLayer'
|
|
17
19
|
import ExtrusionLayer from './layer/ExtrusionLayer'
|
|
18
20
|
import MarkerAreaLayer from './layer/MarkerAreaLayer'
|
|
21
|
+
import ScanWallLayer from './layer/ScanWallLayer'
|
|
22
|
+
import WallLayer from './layer/WallLayer'
|
|
19
23
|
export{
|
|
24
|
+
ThreeBoxWallLayer,
|
|
20
25
|
EasyMapMarker,
|
|
21
26
|
LineTool,
|
|
22
27
|
ScanLayer,
|
|
@@ -30,5 +35,7 @@ export{
|
|
|
30
35
|
AnimationBarbsLayer,
|
|
31
36
|
PathLineLayer,
|
|
32
37
|
ExtrusionLayer,
|
|
33
|
-
MarkerAreaLayer
|
|
38
|
+
MarkerAreaLayer,
|
|
39
|
+
WebGlWallLayer,
|
|
40
|
+
ScanWallLayer
|
|
34
41
|
}
|
|
@@ -4,8 +4,9 @@ import { sleep } from '../../utils/util';
|
|
|
4
4
|
import {hasProperty,transform} from '../../utils/util'
|
|
5
5
|
import Pulse from "../../utils/Pulses/Pulse";
|
|
6
6
|
import mapboxgl from '../../../lib/mapbox-gl/dist/mapbox-gl.js';
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
export default class AlarmLayer{
|
|
9
|
+
tb = {};
|
|
9
10
|
alarmList = []
|
|
10
11
|
scale = 0.01;
|
|
11
12
|
iconHtml;
|
|
@@ -37,7 +38,7 @@ export default class AlarmLayer{
|
|
|
37
38
|
|
|
38
39
|
onAdd(map, gl) {
|
|
39
40
|
this.map = map;
|
|
40
|
-
tb = new Threebox(
|
|
41
|
+
this.tb = new Threebox(
|
|
41
42
|
map,
|
|
42
43
|
gl, //get the context from Mapbox
|
|
43
44
|
{ defaultLights: true }
|
|
@@ -110,15 +111,15 @@ export default class AlarmLayer{
|
|
|
110
111
|
// units: 'meters',
|
|
111
112
|
// rotation: { x: 90, y: -90, z: 0 }
|
|
112
113
|
// };
|
|
113
|
-
// tb.loadObj(options, (model) => {
|
|
114
|
+
// this.tb.loadObj(options, (model) => {
|
|
114
115
|
// model.setCoords(transform([lng,lat]));
|
|
115
116
|
// model.setRotation({ x: 0, y: 0, z: 241 });
|
|
116
|
-
// tb.add(model);
|
|
117
|
+
// this.tb.add(model);
|
|
117
118
|
// });
|
|
118
119
|
let center = transform([lng,lat]);
|
|
119
120
|
var geometry = new THREE.CircleGeometry(0);
|
|
120
121
|
let circle = new THREE.Mesh(geometry, new THREE.MeshPhongMaterial({ color: 0x660000 }));
|
|
121
|
-
circle = tb.Object3D({ obj: circle, units: 'meters',fixedZoom :15 ,anchor:'center'});
|
|
122
|
+
circle = this.tb.Object3D({ obj: circle, units: 'meters',fixedZoom :15 ,anchor:'center'});
|
|
122
123
|
circle.addLabel = (HTMLElement, visible, center, height,ev)=>{
|
|
123
124
|
if (HTMLElement) {
|
|
124
125
|
let label = circle.drawLabelHTML(HTMLElement, visible, center, height);
|
|
@@ -133,11 +134,11 @@ export default class AlarmLayer{
|
|
|
133
134
|
}
|
|
134
135
|
circle.setCoords(center);
|
|
135
136
|
//circle.addEventListener('ObjectMouseOver', (e)=>{console.log(111,e)}, false)
|
|
136
|
-
// let pulseObj = tb
|
|
137
|
+
// let pulseObj = this.tb
|
|
137
138
|
// .Object3D({ obj: this.pulse, units: "meters" ,anchor:'center'})
|
|
138
139
|
// .setCoords(center);
|
|
139
|
-
// tb.add(pulseObj)
|
|
140
|
-
tb.add(circle);
|
|
140
|
+
// this.tb.add(pulseObj)
|
|
141
|
+
this.tb.add(circle);
|
|
141
142
|
point.circle = circle;
|
|
142
143
|
if(point.iconHtml){
|
|
143
144
|
circle.addLabel(point.iconHtml,true,circle.anchor,0.5)
|
|
@@ -164,9 +165,9 @@ export default class AlarmLayer{
|
|
|
164
165
|
// let circle = new THREE.CircleGeometry(500)
|
|
165
166
|
// let material = new THREE.MeshBasicMaterial({color: 0xffff00,transparent:true})
|
|
166
167
|
// let mesh = new THREE.Mesh(circle,material)
|
|
167
|
-
// let cube = tb.Object3D({obj:mesh,units:'meters'})
|
|
168
|
+
// let cube = this.tb.Object3D({obj:mesh,units:'meters'})
|
|
168
169
|
// cube.setCoords(transform([lng,lat]))
|
|
169
|
-
// tb.add(mesh);
|
|
170
|
+
// this.tb.add(mesh);
|
|
170
171
|
}
|
|
171
172
|
|
|
172
173
|
setPopup(point){
|
|
@@ -208,7 +209,7 @@ export default class AlarmLayer{
|
|
|
208
209
|
// a?.circle?.set({ scale:this.scale,duration:600})
|
|
209
210
|
// });
|
|
210
211
|
// await sleep(600)
|
|
211
|
-
// tb.update();
|
|
212
|
+
// this.tb.update();
|
|
212
213
|
// requestAnimationFrame(this.animate);
|
|
213
214
|
// }
|
|
214
215
|
|
|
@@ -246,7 +247,7 @@ export default class AlarmLayer{
|
|
|
246
247
|
|
|
247
248
|
// this.camera.projectionMatrix = m.multiply(l);
|
|
248
249
|
//this.pulse.update();
|
|
249
|
-
tb.update();
|
|
250
|
+
this.tb.update();
|
|
250
251
|
this.map.triggerRepaint();
|
|
251
252
|
}
|
|
252
253
|
}
|
|
@@ -6,7 +6,7 @@ import { sleep } from '../../utils/util.js';
|
|
|
6
6
|
import { SVGLoader } from 'three/addons/loaders/SVGLoader.js';
|
|
7
7
|
import getBarbs from '../../utils/barbsHelper.js';
|
|
8
8
|
import * as THREE from 'three'
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
const actionStatus = {
|
|
11
11
|
Play:0,
|
|
12
12
|
Stop:1,
|
|
@@ -14,6 +14,7 @@ const actionStatus = {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export default class AnimationLayer{
|
|
17
|
+
tb = {};
|
|
17
18
|
//当前帧率
|
|
18
19
|
timerId
|
|
19
20
|
speed=1//帧
|
|
@@ -93,7 +94,7 @@ export default class AnimationLayer{
|
|
|
93
94
|
this.remove();
|
|
94
95
|
//重置状态
|
|
95
96
|
this.current = 0;
|
|
96
|
-
this.
|
|
97
|
+
this.status = 0;
|
|
97
98
|
this.itemList = list
|
|
98
99
|
// item.imageList.forEach(async _item => {
|
|
99
100
|
// let texture = new THREE.TextureLoader().load(
|
|
@@ -127,12 +128,12 @@ export default class AnimationLayer{
|
|
|
127
128
|
let material = new THREE.MeshBasicMaterial({ color: 0xffffff });
|
|
128
129
|
// 创建网格
|
|
129
130
|
let mesh = new THREE.Mesh(geometry, material);
|
|
130
|
-
mesh = tb.Object3D({ obj: mesh, units: 'meters',fixedZoom :15 ,anchor:'center'});
|
|
131
|
+
mesh = this.tb.Object3D({ obj: mesh, units: 'meters',fixedZoom :15 ,anchor:'center'});
|
|
131
132
|
// 将网格添加到场景中
|
|
132
133
|
// scene.add(mesh);
|
|
133
134
|
mesh.setCoords( transform(center));
|
|
134
|
-
tb.renderer.outputEncoding = THREE.sRGBEncoding;
|
|
135
|
-
tb.add(mesh);
|
|
135
|
+
this.tb.renderer.outputEncoding = THREE.sRGBEncoding;
|
|
136
|
+
this.tb.add(mesh);
|
|
136
137
|
this.meshList[id] = mesh
|
|
137
138
|
// let texture = this.itemList[0].texture
|
|
138
139
|
// let _item = this.itemList[0].item;
|
|
@@ -146,10 +147,10 @@ export default class AnimationLayer{
|
|
|
146
147
|
// material.color.convertSRGBToLinear();
|
|
147
148
|
// let mesh = new THREE.Mesh(geometry, material);
|
|
148
149
|
// mesh.name = 'scanimg'
|
|
149
|
-
// mesh = tb.Object3D({ obj: mesh, units: 'meters',fixedZoom :15 ,anchor:'center'});
|
|
150
|
+
// mesh = this.tb.Object3D({ obj: mesh, units: 'meters',fixedZoom :15 ,anchor:'center'});
|
|
150
151
|
// mesh.setCoords( transform(_item.center));
|
|
151
|
-
// tb.renderer.outputEncoding = THREE.sRGBEncoding;
|
|
152
|
-
// tb.add(mesh);
|
|
152
|
+
// this.tb.renderer.outputEncoding = THREE.sRGBEncoding;
|
|
153
|
+
// this.tb.add(mesh);
|
|
153
154
|
// let dom =document.createElement('div')
|
|
154
155
|
// mesh.addLabel(dom,true,{x:mesh.anchor.x,y:mesh.anchor.y+_item.distance *1200,z:mesh.anchor.z},0)
|
|
155
156
|
// mesh.label.element.className += ('' +this.textClass)
|
|
@@ -289,11 +290,11 @@ export default class AnimationLayer{
|
|
|
289
290
|
let shapeItemInfo = this.barbsList[level]
|
|
290
291
|
let _color = color.set(shapeItemInfo.color)
|
|
291
292
|
let mesh = new THREE.Mesh(new THREE.ShapeGeometry( shapeItemInfo.shape.toShapes()[0] ), this.meshList[_item.data[i].id].model.material);
|
|
292
|
-
mesh = tb.Object3D({ obj: mesh, units: 'meters',fixedZoom :15 ,anchor:'center'});
|
|
293
|
+
mesh = this.tb.Object3D({ obj: mesh, units: 'meters',fixedZoom :15 ,anchor:'center'});
|
|
293
294
|
mesh.setCoords( transform(_item.data[i].center));
|
|
294
295
|
this.meshList[_item.data[i].id].model.geometry = mesh.model.geometry
|
|
295
296
|
this.meshList[_item.data[i].id].model.material.color= _color
|
|
296
|
-
tb.update();
|
|
297
|
+
this.tb.update();
|
|
297
298
|
this.map.triggerRepaint();
|
|
298
299
|
}
|
|
299
300
|
//console.log(this.meshList[_item.data[i].id].model.geometry,mesh)
|
|
@@ -311,7 +312,7 @@ export default class AnimationLayer{
|
|
|
311
312
|
}
|
|
312
313
|
onAdd(map, gl) {
|
|
313
314
|
this.map = map;
|
|
314
|
-
tb = new Threebox(
|
|
315
|
+
this.tb = new Threebox(
|
|
315
316
|
map,
|
|
316
317
|
gl, //get the context from Mapbox
|
|
317
318
|
{ defaultLights: true ,passiveRendering:false}
|
|
@@ -319,7 +320,7 @@ export default class AnimationLayer{
|
|
|
319
320
|
this.createInterval()
|
|
320
321
|
}
|
|
321
322
|
render(gl, matrix) {
|
|
322
|
-
tb.update();
|
|
323
|
+
this.tb.update();
|
|
323
324
|
this.map.triggerRepaint();
|
|
324
325
|
}
|
|
325
326
|
}
|
|
@@ -4,13 +4,14 @@ import mapboxgl from '../../../lib/mapbox-gl/dist/mapbox-gl.js';
|
|
|
4
4
|
import {Threebox} from '../../../lib/threebox-plugin';
|
|
5
5
|
import { sleep } from '../../utils/util';
|
|
6
6
|
import * as THREE from 'three'
|
|
7
|
-
|
|
7
|
+
import { esMapWatchEffect } from '../../utils/mapWatch.js';
|
|
8
8
|
const actionStatus = {
|
|
9
9
|
Play:0,
|
|
10
10
|
Stop:1,
|
|
11
11
|
Pause:2
|
|
12
12
|
}
|
|
13
13
|
export default class AnimationLayer{
|
|
14
|
+
tb = {};
|
|
14
15
|
//当前帧率
|
|
15
16
|
timerId
|
|
16
17
|
speed=1//帧
|
|
@@ -63,7 +64,7 @@ export default class AnimationLayer{
|
|
|
63
64
|
this.remove();
|
|
64
65
|
//重置状态
|
|
65
66
|
this.current = 0;
|
|
66
|
-
this.
|
|
67
|
+
this.status = 0;
|
|
67
68
|
this.itemList = []
|
|
68
69
|
item.imageList.forEach(async _item => {
|
|
69
70
|
let texture = new THREE.TextureLoader().load(
|
|
@@ -86,9 +87,9 @@ export default class AnimationLayer{
|
|
|
86
87
|
|
|
87
88
|
remove(){
|
|
88
89
|
if(this.obj.label){
|
|
89
|
-
this.obj.label.element.remove()
|
|
90
|
-
tb.remove(this.obj)
|
|
90
|
+
this.obj.label.element.remove()
|
|
91
91
|
}
|
|
92
|
+
this.tb.remove(this.obj)
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
loadMesh(){
|
|
@@ -104,13 +105,13 @@ export default class AnimationLayer{
|
|
|
104
105
|
material.color.convertSRGBToLinear();
|
|
105
106
|
let mesh = new THREE.Mesh(geometry, material);
|
|
106
107
|
mesh.name = 'scanimg'
|
|
107
|
-
mesh = tb.Object3D({ obj: mesh, units: 'meters',fixedZoom :15 ,anchor:'center'});
|
|
108
|
+
mesh = this.tb.Object3D({ obj: mesh, units: 'meters',fixedZoom :15 ,anchor:'center'});
|
|
108
109
|
mesh.setCoords( transform(_item.center));
|
|
109
|
-
tb.renderer.outputEncoding = THREE.sRGBEncoding;
|
|
110
|
-
tb.add(mesh);
|
|
110
|
+
this.tb.renderer.outputEncoding = THREE.sRGBEncoding;
|
|
111
|
+
this.tb.add(mesh);
|
|
111
112
|
let dom =document.createElement('div')
|
|
112
113
|
mesh.addLabel(dom,true,{x:mesh.anchor.x,y:mesh.anchor.y+_item.distance *1200,z:mesh.anchor.z},0)
|
|
113
|
-
mesh.label.element.className += ('' +this.textClass)
|
|
114
|
+
mesh.label.element.className += (' esm-font-time ' +this.textClass)
|
|
114
115
|
mesh.label.element.style.fontSize = '24px'
|
|
115
116
|
return mesh;
|
|
116
117
|
}
|
|
@@ -118,16 +119,18 @@ export default class AnimationLayer{
|
|
|
118
119
|
setOpacity(opacity){
|
|
119
120
|
this.opacity = opacity
|
|
120
121
|
this.obj.model.material.opacity = this.opacity;
|
|
122
|
+
this.tb.update();
|
|
123
|
+
this.map.triggerRepaint();
|
|
121
124
|
}
|
|
122
125
|
|
|
123
126
|
pause(){
|
|
124
127
|
this.status = actionStatus.Pause
|
|
125
|
-
this.getProgress(this.progress.value,this.status)
|
|
128
|
+
this.getProgress(this.progress.value,this.status,this.current)
|
|
126
129
|
}
|
|
127
130
|
|
|
128
131
|
stop(){
|
|
129
132
|
this.status = actionStatus.Stop
|
|
130
|
-
this.getProgress(this.progress.value,this.status)
|
|
133
|
+
this.getProgress(this.progress.value,this.status,this.current)
|
|
131
134
|
}
|
|
132
135
|
|
|
133
136
|
setCurrent(index){
|
|
@@ -138,7 +141,7 @@ export default class AnimationLayer{
|
|
|
138
141
|
return
|
|
139
142
|
}
|
|
140
143
|
this.status = actionStatus.Pause
|
|
141
|
-
this.getProgress(this.progress.value,this.status)
|
|
144
|
+
this.getProgress(this.progress.value,this.status,this.current)
|
|
142
145
|
}
|
|
143
146
|
|
|
144
147
|
next(){
|
|
@@ -148,7 +151,7 @@ export default class AnimationLayer{
|
|
|
148
151
|
this.status = actionStatus.Pause
|
|
149
152
|
this.current++
|
|
150
153
|
this.animate()
|
|
151
|
-
this.getProgress(this.progress.value,this.status)
|
|
154
|
+
this.getProgress(this.progress.value,this.status,this.current)
|
|
152
155
|
}
|
|
153
156
|
|
|
154
157
|
previous(){
|
|
@@ -158,7 +161,7 @@ export default class AnimationLayer{
|
|
|
158
161
|
this.status = actionStatus.Pause
|
|
159
162
|
this.current--
|
|
160
163
|
this.animate()
|
|
161
|
-
this.getProgress(this.progress.value,this.status)
|
|
164
|
+
this.getProgress(this.progress.value,this.status,this.current)
|
|
162
165
|
}
|
|
163
166
|
|
|
164
167
|
createInterval(){
|
|
@@ -171,13 +174,14 @@ export default class AnimationLayer{
|
|
|
171
174
|
this.current = 0;
|
|
172
175
|
this.animate()
|
|
173
176
|
this.status = actionStatus.Pause
|
|
174
|
-
this.getProgress(this.progress.value,this.status)
|
|
177
|
+
this.getProgress(this.progress.value,this.status,this.current)
|
|
175
178
|
}else{
|
|
176
179
|
this.animate()
|
|
177
|
-
this.getProgress(this.progress.value,this.status)
|
|
180
|
+
this.getProgress(this.progress.value,this.status,this.current)
|
|
178
181
|
this.current++;
|
|
179
182
|
}
|
|
180
183
|
}
|
|
184
|
+
this.updateStyleByTheme()
|
|
181
185
|
},1000/this.speed)
|
|
182
186
|
}
|
|
183
187
|
|
|
@@ -186,7 +190,7 @@ export default class AnimationLayer{
|
|
|
186
190
|
this.status = actionStatus.Play;
|
|
187
191
|
if(this.itemList.length == 0){
|
|
188
192
|
this.status = actionStatus.Pause
|
|
189
|
-
this.getProgress(this.progress.value,this.status)
|
|
193
|
+
this.getProgress(this.progress.value,this.status,this.current)
|
|
190
194
|
return 0;
|
|
191
195
|
}
|
|
192
196
|
}
|
|
@@ -198,7 +202,7 @@ export default class AnimationLayer{
|
|
|
198
202
|
this.status = actionStatus.Play;
|
|
199
203
|
if(this.itemList.length == 0){
|
|
200
204
|
this.status = actionStatus.Pause
|
|
201
|
-
this.getProgress(this.progress.value,this.status)
|
|
205
|
+
this.getProgress(this.progress.value,this.status,this.current)
|
|
202
206
|
return 0;
|
|
203
207
|
}
|
|
204
208
|
}
|
|
@@ -213,19 +217,32 @@ export default class AnimationLayer{
|
|
|
213
217
|
if(this.timerId){
|
|
214
218
|
clearInterval(this.timerId)
|
|
215
219
|
}
|
|
220
|
+
this.remove()
|
|
216
221
|
this.destory()
|
|
217
222
|
}
|
|
218
223
|
onAdd(map, gl) {
|
|
219
224
|
this.map = map;
|
|
220
|
-
tb = new Threebox(
|
|
225
|
+
this.tb = new Threebox(
|
|
221
226
|
map,
|
|
222
227
|
gl, //get the context from Mapbox
|
|
223
228
|
{ defaultLights: true ,passiveRendering:false}
|
|
224
229
|
);
|
|
225
|
-
this.createInterval()
|
|
226
|
-
|
|
230
|
+
this.createInterval()
|
|
231
|
+
esMapWatchEffect(()=>{
|
|
232
|
+
this.updateStyleByTheme()
|
|
233
|
+
})
|
|
234
|
+
}
|
|
235
|
+
updateStyleByTheme(){
|
|
236
|
+
let elList = this.map._container.getElementsByClassName('esm-font-time')
|
|
237
|
+
this.map.theme = this.map.theme ? this.map.theme :this.map.style.stylesheet.theme
|
|
238
|
+
let color = this.map.theme.value == "dark"?"#fff" : "#000"
|
|
239
|
+
for(let el of elList){
|
|
240
|
+
el.style.color = color
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
227
244
|
render(gl, matrix) {
|
|
228
|
-
tb.update();
|
|
245
|
+
this.tb.update();
|
|
229
246
|
this.map.triggerRepaint();
|
|
230
247
|
}
|
|
231
248
|
}
|
|
@@ -3,8 +3,9 @@ import * as THREE from 'three'
|
|
|
3
3
|
import { sleep } from '../../utils/util.js';
|
|
4
4
|
import {hasProperty,transform} from '../../utils/util.js'
|
|
5
5
|
import mapboxgl from '../../../lib/mapbox-gl/dist/mapbox-gl.js';
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
export default class CustomIconLayer{
|
|
8
|
+
tb = {};
|
|
8
9
|
iconList = []
|
|
9
10
|
scale = 0.01;
|
|
10
11
|
iconHtml;
|
|
@@ -30,7 +31,7 @@ export default class CustomIconLayer{
|
|
|
30
31
|
|
|
31
32
|
onAdd(map, gl) {
|
|
32
33
|
this.map = map;
|
|
33
|
-
tb = new Threebox(
|
|
34
|
+
this.tb = new Threebox(
|
|
34
35
|
map,
|
|
35
36
|
gl, //get the context from Mapbox
|
|
36
37
|
{ defaultLights: true }
|
|
@@ -177,7 +178,7 @@ export default class CustomIconLayer{
|
|
|
177
178
|
let center = transform([lng,lat]);
|
|
178
179
|
var geometry = new THREE.CircleGeometry(0);
|
|
179
180
|
let circle = new THREE.Mesh(geometry, new THREE.MeshPhongMaterial({ color: 0x660000 }));
|
|
180
|
-
circle = tb.Object3D({ obj: circle, units: 'meters' ,anchor:'center'});
|
|
181
|
+
circle = this.tb.Object3D({ obj: circle, units: 'meters' ,anchor:'center'});
|
|
181
182
|
circle.addLabel = (HTMLElement, visible, center, height,ev)=>{
|
|
182
183
|
if (HTMLElement) {
|
|
183
184
|
let label = circle.drawLabelHTML(HTMLElement, visible, center, height);
|
|
@@ -189,7 +190,7 @@ export default class CustomIconLayer{
|
|
|
189
190
|
}
|
|
190
191
|
}
|
|
191
192
|
circle.setCoords(center);
|
|
192
|
-
tb.add(circle);
|
|
193
|
+
this.tb.add(circle);
|
|
193
194
|
point.circle = circle;
|
|
194
195
|
if(point.icon){
|
|
195
196
|
|
|
@@ -225,7 +226,7 @@ export default class CustomIconLayer{
|
|
|
225
226
|
}
|
|
226
227
|
|
|
227
228
|
render(gl, matrix) {
|
|
228
|
-
tb.update();
|
|
229
|
+
this.tb.update();
|
|
229
230
|
this.map.triggerRepaint();
|
|
230
231
|
}
|
|
231
232
|
}
|