@ohuoy/easymap 1.0.20 → 1.0.22

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.
@@ -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
- var tb = {};
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
  }
@@ -21,30 +21,35 @@ const params = {
21
21
  radius: 2.5,
22
22
  exposure: 0,
23
23
  };
24
- var tb = {};
25
- let scene;
26
24
  let sceneTarget;
27
25
  let cameraMap;
28
- let target;
29
26
  let cameraTarget;
30
- let materialTarget;
31
27
  let cameraTransform;
32
28
 
33
- var camera
34
- let outlineComposer;
29
+ // let this.outlineComposer;
35
30
  let bloomComposer;
36
31
  let renderScene;
37
32
  let bloomPass;
38
33
  let composer;
39
- let outlinePass;
34
+ // let this.outlinePass;
40
35
  let composer2;
41
- var group = new THREE.Group();
42
- let group2 = new THREE.Group();
43
- let group3 = new THREE.Group();
36
+ // var this.group = new THREE.Group();
37
+ // let this.group2 = new THREE.Group();
38
+ // let this.group3 = new THREE.Group();
44
39
  let sceneMap;
45
40
  var darkMaterial = new THREE.MeshBasicMaterial({ color: 'black' ,transparent:true,opacity:1});
46
41
  var bloomLayer = new THREE.Layers();
47
42
  export default class ExtrusionLayer{
43
+ tb = {};
44
+ scene;
45
+ camera;
46
+ outlineComposer;
47
+ outlinePass;
48
+ group = new THREE.Group();
49
+ group2 = new THREE.Group();
50
+ group3 = new THREE.Group();
51
+ materialTarget;
52
+ target;
48
53
  opacity = 0.8
49
54
  previewCanvas = null;
50
55
  w = 0;
@@ -72,7 +77,7 @@ export default class ExtrusionLayer{
72
77
  }
73
78
  const material1 = new THREE.MeshLambertMaterial({ color: 0xb00000, wireframe: false });
74
79
  const material2 = new THREE.MeshLambertMaterial({ color: 0xff8000, wireframe: false });
75
- let star = tb.extrusion({
80
+ let star = this.tb.extrusion({
76
81
  coordinates: [points],
77
82
  geometryOptions: { depth: 20, steps: 1, bevelEnabled: true, bevelThickness: 2, bevelSize: 4, bevelSegments: 1 },
78
83
  anchor: 'center',
@@ -83,7 +88,7 @@ export default class ExtrusionLayer{
83
88
  star.addTooltip("A animated extruded star over Columbus Park", true);
84
89
  star.setCoords([-74.0001269, 40.7151698, 50]);
85
90
  star.set({ rotation: {x: 0, y: 0, z: 720}, duration: 20000 })
86
- tb.add(star);
91
+ this.tb.add(star);
87
92
  }
88
93
 
89
94
  addExtrusionsThreeBox(coordinates,center, height = 1000) {
@@ -96,11 +101,11 @@ export default class ExtrusionLayer{
96
101
  // let coords = []
97
102
  // data.forEach((b) => {
98
103
  // // let center = b.properties.center;
99
- // // let s = tb.projectedUnitsPerMeter(center[1]);
104
+ // // let s = this.tb.projectedUnitsPerMeter(center[1]);
100
105
  // coords.push(b.geometry.coordinates)
101
106
 
102
107
  // });
103
- let extrusion = tb.extrusion({
108
+ let extrusion = this.tb.extrusion({
104
109
  coordinates: coordinates,
105
110
  anchor:'center',
106
111
  geometryOptions: { curveSegments: 1, depth: height },
@@ -108,7 +113,7 @@ export default class ExtrusionLayer{
108
113
  },this.map);
109
114
  // extrusion.addTooltip(b.properties.tooltip, true);
110
115
  extrusion.setCoords([...transform(center), 0]);
111
- tb.add(extrusion);
116
+ this.tb.add(extrusion);
112
117
  this.outlineObj(extrusion)
113
118
  }
114
119
 
@@ -144,43 +149,43 @@ export default class ExtrusionLayer{
144
149
  const geometry = new THREE.ExtrudeGeometry( shape, { curveSegments: 1, depth: height } );
145
150
  const mesh = new THREE.Mesh( geometry, material ) ;
146
151
  mesh.layers.enable(BLOOM_SCENE)
147
- group.add(mesh)
148
- // /group2.add()
152
+ this.group.add(mesh)
153
+ // /this.group2.add()
149
154
  })
150
155
  }
151
156
 
152
157
  outlineObj(selectedObjects) {
153
- if (outlinePass) {
154
- outlineComposer.removePass(outlinePass)
155
- outlinePass = null
158
+ if (this.outlinePass) {
159
+ this.outlineComposer.removePass(this.outlinePass)
160
+ this.outlinePass = null
156
161
  }
157
162
  // 物体边缘发光通道
158
- outlinePass = new OutlinePass(
163
+ this.outlinePass = new OutlinePass(
159
164
  new THREE.Vector2(window.innerWidth, window.innerHeight),
160
- scene,
161
- camera
165
+ this.scene,
166
+ this.camera
162
167
  )
163
- outlinePass.edgeStrength = 5 // 边框的亮度
164
- outlinePass.edgeGlow = 0.1 // 光晕[0,1]
165
- outlinePass.edgeThickness = 0.1 // 边框宽度
166
- outlinePass.pulsePeriod = 2 // 呼吸闪烁的速度
167
- outlinePass.visibleEdgeColor.set(0xff4ecfff)
168
- outlinePass.hiddenEdgeColor.set(0x00ffff)
169
- outlinePass.selectedObjects = selectedObjects
170
- outlineComposer.addPass(outlinePass)
168
+ this.outlinePass.edgeStrength = 5 // 边框的亮度
169
+ this.outlinePass.edgeGlow = 0.1 // 光晕[0,1]
170
+ this.outlinePass.edgeThickness = 0.1 // 边框宽度
171
+ this.outlinePass.pulsePeriod = 2 // 呼吸闪烁的速度
172
+ this.outlinePass.visibleEdgeColor.set(0xff4ecfff)
173
+ this.outlinePass.hiddenEdgeColor.set(0x00ffff)
174
+ this.outlinePass.selectedObjects = selectedObjects
175
+ this.outlineComposer.addPass(this.outlinePass)
171
176
  // 自定义的着色器通道 作为参数
172
177
  }
173
178
 
174
179
 
175
180
  addLineThreeBox(coordinates,center, height = 1000){
176
181
  coordinates.forEach(coords => {
177
- let line = tb.line({
182
+ let line = this.tb.line({
178
183
  geometry:coords,
179
184
  color:0xe6f2ff,
180
185
  width:2
181
186
  });
182
187
  //line.setCoords([...transform(center), 0]);
183
- tb.add(line);
188
+ this.tb.add(line);
184
189
  });
185
190
 
186
191
  }
@@ -239,7 +244,7 @@ export default class ExtrusionLayer{
239
244
  let line = new Line2(geometry, matLine);
240
245
  line.position.copy(normalized.position);
241
246
  line.computeLineDistances();
242
- group.add(line)
247
+ this.group.add(line)
243
248
  }
244
249
 
245
250
  addLine(coordinates, height = 1000,opacity = 0.5,width = 2,color = 0xb6d1fc){
@@ -263,10 +268,10 @@ export default class ExtrusionLayer{
263
268
  // let line = new Line2( geometry, matLine );
264
269
  let line = this.createLine(coords,height,opacity,width,color)
265
270
  line.layers.enable(BLOOM_SCENE)
266
- group.add(line)
271
+ this.group.add(line)
267
272
  lines.push(line)
268
273
  })
269
- //this.outlineObj([group])
274
+ //this.outlineObj([this.group])
270
275
  }
271
276
 
272
277
 
@@ -289,7 +294,7 @@ export default class ExtrusionLayer{
289
294
  // composePlaneGeometry.setAttribute( 'uv', new THREE.Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );
290
295
  let composePlaneGeometry = new THREE.PlaneGeometry(w * 10000 ,h * 10000);
291
296
  //debugger
292
- // materialTarget = new THREE.ShaderMaterial( {
297
+ // this.materialTarget = new THREE.ShaderMaterial( {
293
298
  // uniforms: {
294
299
  // 'tDiffuse': { value: null },
295
300
  // 'opacity': { value: 1 }
@@ -315,23 +320,23 @@ export default class ExtrusionLayer{
315
320
  // depthTest: false,
316
321
  // depthWrite: false
317
322
  // } );
318
- materialTarget = new THREE.MeshPhongMaterial({
319
- map:target.texture,
323
+ this.materialTarget = new THREE.MeshPhongMaterial({
324
+ map:this.target.texture,
320
325
  opacity:1,
321
326
  transparent: true,
322
327
  });
323
- let mesh = new THREE.Mesh(composePlaneGeometry, materialTarget);
324
- mesh = tb.Object3D({ obj: mesh, units: 'meters',fixedZoom :15 ,anchor:'center'});
328
+ let mesh = new THREE.Mesh(composePlaneGeometry, this.materialTarget);
329
+ mesh = this.tb.Object3D({ obj: mesh, units: 'meters',fixedZoom :15 ,anchor:'center'});
325
330
  mesh.setCoords( [0,0]);
326
- tb.add(mesh);
331
+ this.tb.add(mesh);
327
332
 
328
- group2.add(mesh)
333
+ this.group2.add(mesh)
329
334
  }
330
335
 
331
336
 
332
337
  onAdd(map, gl) {
333
338
  this.map = map;
334
- tb = new Threebox(
339
+ this.tb = new Threebox(
335
340
  map,
336
341
  gl, //get the context from Mapbox
337
342
  { defaultLights: true ,passiveRendering:false}
@@ -342,16 +347,16 @@ export default class ExtrusionLayer{
342
347
  this.w = w;
343
348
  this.h = h;
344
349
 
345
- scene = new THREE.Scene();
350
+ this.scene = new THREE.this.scene();
346
351
  //sceneTarget.background = new THREE.Color('rgba(0,0,0,0)')
347
- camera = new THREE.PerspectiveCamera(map.transform.fov, w / h, 0.1, 1e21);
348
- scene.add(group)
349
- scene.add(new THREE.AmbientLight(0xffffff));
350
- //scene.add(group2)
352
+ this.camera = new THREE.PerspectiveCamera(map.transform.fov, w / h, 0.1, 1e21);
353
+ this.scene.add(this.group)
354
+ this.scene.add(new THREE.AmbientLight(0xffffff));
355
+ //this.scene.add(this.group2)
351
356
 
352
- new CameraSync(this.map, camera, group);
357
+ new CameraSync(this.map, this.camera, this.group);
353
358
 
354
- //new CameraSync(this.map, camera, group2);
359
+ //new CameraSync(this.map, this.camera, this.group2);
355
360
  this.renderer = new THREE.WebGLRenderer({
356
361
  canvas: map.getCanvas(),
357
362
  context: gl,
@@ -360,13 +365,13 @@ export default class ExtrusionLayer{
360
365
  });
361
366
  this.renderer.outputEncoding = THREE.sRGBEncoding;
362
367
  this.renderer.autoClear = false;
363
- scene.add(new THREE.AxesHelper(0))
364
- //scene.background =null;
365
- //scene.background = new THREE.Color(0x000000);
368
+ this.scene.add(new THREE.AxesHelper(0))
369
+ //this.scene.background =null;
370
+ //this.scene.background = new THREE.Color(0x000000);
366
371
  //this.renderer.setClearAlpha(0.0);
367
- // target = new THREE.WebGLRenderTarget(w,h,{encoding: THREE.sRGBEncoding });
372
+ // this.target = new THREE.WebGLRenderTarget(w,h,{encoding: THREE.sRGBEncoding });
368
373
  // this.setTargetTexture(w,h)
369
- //renderScene = new RenderPass(scene, camera);
374
+ //renderScene = new RenderPass(this.scene, this.camera);
370
375
  //composer2 = new EffectComposer(this.renderer);
371
376
  //bloomPass = new UnrealBloomPass(new THREE.Vector2(w/2, h/2), params.strength, params.radius, params.threshold);
372
377
  //composer2.addPass(renderScene);
@@ -379,14 +384,14 @@ export default class ExtrusionLayer{
379
384
  // bloomComposer.renderToScreen = true;
380
385
  // bloomComposer.addPass(renderScene);
381
386
  // bloomComposer.addPass(bloomPass);
382
- //outlineComposer = new EffectComposer(this.renderer)
387
+ //this.outlineComposer = new EffectComposer(this.renderer)
383
388
  // bloomLayer.set(BLOOM_SCENE);
384
389
 
385
390
 
386
391
  // const bloomPass = new OutlinePass(
387
392
  // new THREE.Vector2(window.innerWidth, window.innerHeight),
388
- // scene,
389
- // camera
393
+ // this.scene,
394
+ // this.camera
390
395
  // )
391
396
  // bloomPass.edgeStrength = 5 // 边框的亮度
392
397
  // bloomPass.edgeGlow = 1 // 光晕[0,1]
@@ -394,7 +399,7 @@ export default class ExtrusionLayer{
394
399
  // bloomPass.pulsePeriod = 3 // 呼吸闪烁的速度
395
400
  // bloomPass.visibleEdgeColor.set(0xff4ecfff)
396
401
  // bloomPass.hiddenEdgeColor.set(0x00ffff)
397
- //bloomPass.selectedObjects = [group]
402
+ //bloomPass.selectedObjects = [this.group]
398
403
 
399
404
 
400
405
 
@@ -422,8 +427,8 @@ export default class ExtrusionLayer{
422
427
  // composer.addPass(outputPass);
423
428
 
424
429
 
425
- //let renderPass = new RenderPass(scene, camera)
426
- //outlineComposer.addPass(renderPass)
430
+ //let renderPass = new RenderPass(this.scene, this.camera)
431
+ //this.outlineComposer.addPass(renderPass)
427
432
  }
428
433
 
429
434
 
@@ -449,17 +454,17 @@ export default class ExtrusionLayer{
449
454
  render(gl, matrix) {
450
455
 
451
456
  //composer.render()
452
- // scene.traverse(this.darkenNonBloomed);
457
+ // this.scene.traverse(this.darkenNonBloomed);
453
458
  // bloomComposer.render();
454
- //outlineComposer.render()
459
+ //this.outlineComposer.render()
455
460
  //composer2.render();
456
461
  this.renderer.resetState();
457
- this.renderer.render(scene,camera)
462
+ this.renderer.render(this.scene,this.camera)
458
463
  this.map.triggerRepaint();
459
464
  }
460
465
 
461
466
  darkenNonBloomed(obj) {
462
- // if (obj instanceof THREE.Scene) {
467
+ // if (obj instanceof THREE.this.scene) {
463
468
  // obj.background = new THREE.Color(0x000fff)
464
469
  // debugger
465
470
  // }
@@ -3,12 +3,13 @@ import {hasProperty,transform,downloadFileByBase64, sleep} from '../../utils/uti
3
3
  import mapboxgl from '../../../lib/mapbox-gl/dist/mapbox-gl.js';
4
4
  import * as THREE from 'three'
5
5
  import {Threebox} from '../../../lib/threebox-plugin';
6
- var tb = {};
7
- let markerGroup = new THREE.Group();
6
+ // let this.markerGroup = new THREE.Group();
8
7
  export default class MarkerAreaLayer{
8
+ tb = {};
9
9
  markerArr = []
10
10
  opacity = 0.8
11
11
  textClass = ''
12
+ markerGroup = new THREE.Group();
12
13
  constructor(id,config) {
13
14
  this.id = id;
14
15
  this.opacity = config?.opacity ? Number(config.opacity):0.8
@@ -24,7 +25,7 @@ export default class MarkerAreaLayer{
24
25
  transparent: true
25
26
  });
26
27
  let mesh = new THREE.Mesh( geometry, material) ;
27
- mesh = tb.Object3D({ obj: mesh, units: 'meters' ,anchor:'center'});
28
+ mesh = this.tb.Object3D({ obj: mesh, units: 'meters' ,anchor:'center'});
28
29
  mesh.setCoords(transform(item.coords))
29
30
  let geometryB = new THREE.CylinderGeometry( 5000 * item.size,7000 * item.size, 4000 * item.size,32)
30
31
  let materialB = new THREE.MeshBasicMaterial({
@@ -38,11 +39,11 @@ export default class MarkerAreaLayer{
38
39
  meshB.position.z -= 600000
39
40
  meshB.rotation.set(-Math.PI / 2, 0, 0);
40
41
 
41
- meshB = tb.Object3D({ obj: meshB, units: 'meters' ,anchor:'center',rotation: { x: 90, y: 0, z: 0 } });
42
+ meshB = this.tb.Object3D({ obj: meshB, units: 'meters' ,anchor:'center',rotation: { x: 90, y: 0, z: 0 } });
42
43
  meshB.setCoords(transform(item.coords))
43
44
  //meshB.setRotation({x:0,y:Math.PI / 4,z:0})
44
- markerGroup.add(mesh)
45
- markerGroup.add(meshB)
45
+ this.markerGroup.add(mesh)
46
+ this.markerGroup.add(meshB)
46
47
  }
47
48
 
48
49
 
@@ -60,15 +61,15 @@ export default class MarkerAreaLayer{
60
61
 
61
62
  onAdd(map, gl) {
62
63
  this.map = map;
63
- tb = new Threebox(
64
+ this.tb = new Threebox(
64
65
  map,
65
66
  gl, //get the context from Mapbox
66
67
  { defaultLights: true ,passiveRendering:false}
67
68
  );
68
- tb.add(markerGroup)
69
+ this.tb.add(this.markerGroup)
69
70
  }
70
71
  render(gl, matrix) {
71
- tb.update();
72
+ this.tb.update();
72
73
  this.map.triggerRepaint();
73
74
  }
74
75
 
@@ -4,8 +4,9 @@ import { getBBox } from '../../utils/util.js';
4
4
  import { sleep } from '../../utils/util.js';
5
5
  import {hasProperty,transform} from '../../utils/util.js'
6
6
  import mapboxgl from '../../../lib/mapbox-gl/dist/mapbox-gl.js';
7
- var tb = {};
7
+
8
8
  export default class PathLineLayer{
9
+ tb={}
9
10
  lines = []
10
11
  constructor(id,config) {
11
12
  this.id = id;
@@ -14,7 +15,7 @@ export default class PathLineLayer{
14
15
  }
15
16
 
16
17
  remove(){
17
- this.lines.forEach(a=>tb.remove(a))
18
+ this.lines.forEach(a=>this.tb.remove(a))
18
19
  }
19
20
 
20
21
  drawLine(list){
@@ -57,8 +58,8 @@ export default class PathLineLayer{
57
58
  // width: Math.random() + 1 // random width between 1 and 2
58
59
  // }
59
60
 
60
- let lineMesh = tb.line(line);
61
- tb.add(lineMesh)
61
+ let lineMesh = this.tb.line(line);
62
+ this.tb.add(lineMesh)
62
63
  this.lines.push(lineMesh)
63
64
  })
64
65
  this.map.fitBounds(getBBox(list.map(a=>a.point)), {
@@ -70,14 +71,14 @@ export default class PathLineLayer{
70
71
 
71
72
  onAdd(map, gl) {
72
73
  this.map = map;
73
- tb = new Threebox(
74
+ this.tb = new Threebox(
74
75
  map,
75
76
  gl, //get the context from Mapbox
76
77
  { defaultLights: true ,passiveRendering:false}
77
78
  );
78
79
  }
79
80
  render(gl, matrix) {
80
- tb.update();
81
+ this.tb.update();
81
82
  this.map.triggerRepaint();
82
83
  }
83
84
  }
@@ -7,8 +7,8 @@ import { Line2 } from 'three/addons/lines/Line2.js';
7
7
  import {LineMaterial} from 'three/examples/jsm/lines/LineMaterial.js'
8
8
  import * as THREE from 'three'
9
9
  import {Threebox} from '../../../lib/threebox-plugin';
10
- var tb = {};
11
10
  export default class ThreeScanLayer{
11
+ tb = {};
12
12
  drawArray = []
13
13
  opacity = 0.8
14
14
  textClass = ''
@@ -23,11 +23,11 @@ export default class ThreeScanLayer{
23
23
  }
24
24
 
25
25
  //同时渲染多个地点图片文本
26
- async drawImageList(list,delay = 300){
26
+ async drawImageList(list,delay = 300){
27
27
  for(let i in list){
28
28
  await this.update(list[i])
29
29
  //this.drawArray.push(list[i])
30
- }
30
+ }
31
31
  for(let i in this.drawArray){
32
32
  let _point = list.find(a=>a.center[0] == this.drawArray[i].center[0] && a.center[1] == this.drawArray[i].center[1])
33
33
  if(!_point){
@@ -36,16 +36,21 @@ export default class ThreeScanLayer{
36
36
  }
37
37
  }
38
38
  this.drawArray = this.drawArray.filter(a=>a)
39
- tb.update();
39
+ this.tb.update();
40
40
  this.map.triggerRepaint();
41
41
  await sleep(delay)
42
42
  let canvas = this.map.getCanvas()
43
43
  return canvas.toDataURL();
44
44
  }
45
45
 
46
+
47
+ onRemove(){
48
+ this.removeAll()
49
+ }
50
+
46
51
  remove(point){
47
52
  point.mesh.label.element.remove()
48
- tb.remove(point.mesh)
53
+ this.tb.remove(point.mesh)
49
54
  }
50
55
 
51
56
  removeAll(){
@@ -54,7 +59,7 @@ export default class ThreeScanLayer{
54
59
  this.drawArray[i] = null
55
60
  }
56
61
  this.drawArray = this.drawArray.filter(a=>a)
57
- tb.update();
62
+ this.tb.update();
58
63
  this.map.triggerRepaint();
59
64
  }
60
65
 
@@ -77,7 +82,7 @@ export default class ThreeScanLayer{
77
82
  let w = point.rect.width ? point.rect.width: this.rectMesh.w
78
83
  if(!this.rectMesh.mesh || w!= this.rectMesh.w || point.rect.position[0]!=this.rectMesh.lng || point.rect.position[1] !=this.rectMesh.lat){
79
84
  if(this.rectMesh.mesh){
80
- tb.remove(this.rectMesh.mesh)
85
+ this.tb.remove(this.rectMesh.mesh)
81
86
  }
82
87
  let bounds = getLayerMapPosition(w,transform(point.rect.position))
83
88
  bounds.push(bounds[0])
@@ -87,11 +92,11 @@ export default class ThreeScanLayer{
87
92
  width: 20 // random width between 1 and 2
88
93
  }
89
94
 
90
- let lineMesh = tb.line(lineOptions);
95
+ let lineMesh = this.tb.line(lineOptions);
91
96
  this.rectMesh.mesh = lineMesh;
92
- tb.add(lineMesh)
97
+ this.tb.add(lineMesh)
93
98
  // if(this.rectMesh.mesh){
94
- // tb.remove(this.rectMesh.mesh)
99
+ // this.tb.remove(this.rectMesh.mesh)
95
100
  // }
96
101
  // let plane = new THREE.PlaneGeometry( w*20,w*20);
97
102
  // let material = new THREE.MeshLambertMaterial({
@@ -108,14 +113,14 @@ export default class ThreeScanLayer{
108
113
 
109
114
  // let line = new THREE.LineSegments(edges, edgesMaterial);
110
115
  // mesh.add(line);
111
- // mesh = tb.Object3D({ obj: mesh, units: 'meters',fixedZoom :15 ,anchor:'center'});
116
+ // mesh = this.tb.Object3D({ obj: mesh, units: 'meters',fixedZoom :15 ,anchor:'center'});
112
117
  // this.rectMesh.mesh = mesh;
113
118
  // this.rectMesh.w = w;
114
119
 
115
120
  }
116
121
  // if(this.rectMesh.mesh){
117
122
  // this.rectMesh.mesh.setCoords(transform(point.rect.position))
118
- // tb.add(this.rectMesh.mesh);
123
+ // this.tb.add(this.rectMesh.mesh);
119
124
  // }
120
125
  }
121
126
 
@@ -148,15 +153,25 @@ export default class ThreeScanLayer{
148
153
  point.url += `?tempid=${Math.random()}`
149
154
  }
150
155
  let p = ()=>new Promise(function(resolve,reject){
151
- new THREE.TextureLoader().load(point.url,(_texture)=>{
152
- resolve(_texture)
153
- })
156
+ try{
157
+ new THREE.TextureLoader().load(point.url,(_texture)=>{
158
+ resolve(_texture)
159
+ },()=>{},()=>{
160
+ resolve(null)
161
+ })
162
+ }catch{
163
+ reject(null)
164
+ }
154
165
  })
155
- texture = await p()
166
+ texture = await p()
167
+ if(!texture) return;
168
+ texture.center.set(0.5,0.5);
169
+ texture.rotation = -Math.PI;
156
170
  }
171
+ texture.colorSpace = THREE.SRGBColorSpace
157
172
  texture.encoding = THREE.sRGBEncoding;
158
- texture.flipY = false;
159
- //texture.flipX = true;
173
+ // texture.flipY = false;
174
+ // texture.flipX = true;
160
175
  let index = this.drawArray.findIndex(a=>a.center[0] == point.center[0] && a.center[1] == point.center[1])
161
176
  if(index >= 0){
162
177
  let _point = this.drawArray[index]
@@ -166,7 +181,7 @@ export default class ThreeScanLayer{
166
181
  this.drawArray = this.drawArray.filter(a=>a)
167
182
  let geometry = new THREE.PlaneGeometry(point.width *20,point.width*20);
168
183
  //geometry.setAttribute('position', new THREE.BufferAttribute(vertices, 3));
169
- let material = new THREE.MeshPhongMaterial({
184
+ let material = new THREE.MeshBasicMaterial({
170
185
  map:texture,
171
186
  opacity:this.opacity,
172
187
  transparent: true,
@@ -174,10 +189,10 @@ export default class ThreeScanLayer{
174
189
  material.color.convertSRGBToLinear();
175
190
  let mesh = new THREE.Mesh(geometry, material);
176
191
  mesh.name = 'scanimg'
177
- mesh = tb.Object3D({ obj: mesh, units: 'meters',fixedZoom :15 ,anchor:'center'});
192
+ mesh = this.tb.Object3D({ obj: mesh, units: 'meters',fixedZoom :15 ,anchor:'center'});
178
193
  mesh.setCoords( transform(point.center));
179
- tb.renderer.outputEncoding = THREE.sRGBEncoding;
180
- tb.add(mesh);
194
+ this.tb.renderer.outputEncoding = THREE.sRGBEncoding;
195
+ this.tb.add(mesh);
181
196
  let dom =document.createElement('div')
182
197
  mesh.addLabel(dom,true,{x:mesh.anchor.x,y:mesh.anchor.y+point.distance *1200,z:mesh.anchor.z},0)
183
198
  mesh.label.element.className += ('' +this.textClass)
@@ -201,7 +216,7 @@ export default class ThreeScanLayer{
201
216
  }else{
202
217
  let geometry = new THREE.PlaneGeometry(point.width *20,point.width*20);
203
218
  //geometry.setAttribute('position', new THREE.BufferAttribute(vertices, 3));
204
- let material = new THREE.MeshPhongMaterial({
219
+ let material = new THREE.MeshBasicMaterial({
205
220
  map:texture,
206
221
  opacity:this.opacity,
207
222
  transparent: true,
@@ -209,10 +224,10 @@ export default class ThreeScanLayer{
209
224
  material.color.convertSRGBToLinear();
210
225
  let mesh = new THREE.Mesh(geometry, material);
211
226
  mesh.name = 'scanimg'
212
- mesh = tb.Object3D({ obj: mesh, units: 'meters',fixedZoom :15 ,anchor:'center'});
227
+ mesh = this.tb.Object3D({ obj: mesh, units: 'meters',fixedZoom :15 ,anchor:'center'});
213
228
  mesh.setCoords( transform(point.center));
214
- tb.renderer.outputEncoding = THREE.sRGBEncoding;
215
- tb.add(mesh);
229
+ this.tb.renderer.outputEncoding = THREE.sRGBEncoding;
230
+ this.tb.add(mesh);
216
231
  let dom =document.createElement('div')
217
232
  mesh.addLabel(dom,true,{x:mesh.anchor.x,y:mesh.anchor.y+point.distance *1200,z:mesh.anchor.z},0)
218
233
  mesh.label.element.className += ('' +this.textClass)
@@ -246,10 +261,10 @@ export default class ThreeScanLayer{
246
261
  material.color.convertSRGBToLinear();
247
262
  let mesh = new THREE.Mesh(geometry, material);
248
263
  mesh.name = 'scanimg'
249
- mesh = tb.Object3D({ obj: mesh, units: 'meters',fixedZoom :15 ,anchor:'center'});
264
+ mesh = this.tb.Object3D({ obj: mesh, units: 'meters',fixedZoom :15 ,anchor:'center'});
250
265
  mesh.setCoords( transform(point.center));
251
- tb.renderer.outputEncoding = THREE.sRGBEncoding;
252
- tb.add(mesh);
266
+ this.tb.renderer.outputEncoding = THREE.sRGBEncoding;
267
+ this.tb.add(mesh);
253
268
  let dom =document.createElement('div')
254
269
  mesh.addLabel(dom,true,{x:mesh.anchor.x,y:mesh.anchor.y+point.distance *1200,z:mesh.anchor.z},0)
255
270
  mesh.label.element.className += ('' +this.textClass)
@@ -258,15 +273,15 @@ export default class ThreeScanLayer{
258
273
  }
259
274
 
260
275
  onAdd(map, gl) {
261
- this.map = map;
262
- tb = new Threebox(
276
+ this.map = map;
277
+ this.tb = new Threebox(
263
278
  map,
264
279
  gl, //get the context from Mapbox
265
280
  { defaultLights: true ,passiveRendering:false}
266
281
  );
267
282
  }
268
- render(gl, matrix) {
269
- tb.update();
283
+ render(gl, matrix) {
284
+ this.tb.update();
270
285
  this.map.triggerRepaint();
271
286
  }
272
287