@ohuoy/easymap 1.0.21 → 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.
package/index.js CHANGED
@@ -737,7 +737,9 @@ export class EasyMap {
737
737
 
738
738
  removeLayer(layerId)
739
739
  {
740
- if (this.map.getLayer(layerId)) this.map.removeLayer(layerId)
740
+ if (this.map.getLayer(layerId)) {
741
+ this.map.removeLayer(layerId)
742
+ }
741
743
  }
742
744
 
743
745
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ohuoy/easymap",
3
- "version": "1.0.21",
3
+ "version": "1.0.22",
4
4
  "description": "self map easy use",
5
5
  "main": "main.js",
6
6
  "scripts": {
@@ -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
- var tb = {};
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
- var tb = {};
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.actionStatus = 0;
97
+ this.status = 0;
97
98
  this.itemList = list
98
99
  // item.imageList.forEach(async _item => {
99
100
  // let texture = new THREE.TextureLoader().load(
@@ -113,7 +114,7 @@ export default class AnimationLayer{
113
114
 
114
115
  remove(){
115
116
  for(let i in this.meshList){
116
- this.tb.remove(this.meshList[i])
117
+ this.this.tb.remove(this.meshList[i])
117
118
  delete this.meshList[i]
118
119
  }
119
120
  }
@@ -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,13 @@ 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
- var tb = {};
8
7
  const actionStatus = {
9
8
  Play:0,
10
9
  Stop:1,
11
10
  Pause:2
12
11
  }
13
12
  export default class AnimationLayer{
13
+ tb = {};
14
14
  //当前帧率
15
15
  timerId
16
16
  speed=1//帧
@@ -63,7 +63,7 @@ export default class AnimationLayer{
63
63
  this.remove();
64
64
  //重置状态
65
65
  this.current = 0;
66
- this.actionStatus = 0;
66
+ this.status = 0;
67
67
  this.itemList = []
68
68
  item.imageList.forEach(async _item => {
69
69
  let texture = new THREE.TextureLoader().load(
@@ -86,9 +86,9 @@ export default class AnimationLayer{
86
86
 
87
87
  remove(){
88
88
  if(this.obj.label){
89
- this.obj.label.element.remove()
90
- tb.remove(this.obj)
89
+ this.obj.label.element.remove()
91
90
  }
91
+ this.tb.remove(this.obj)
92
92
  }
93
93
 
94
94
  loadMesh(){
@@ -104,10 +104,10 @@ export default class AnimationLayer{
104
104
  material.color.convertSRGBToLinear();
105
105
  let mesh = new THREE.Mesh(geometry, material);
106
106
  mesh.name = 'scanimg'
107
- mesh = tb.Object3D({ obj: mesh, units: 'meters',fixedZoom :15 ,anchor:'center'});
107
+ mesh = this.tb.Object3D({ obj: mesh, units: 'meters',fixedZoom :15 ,anchor:'center'});
108
108
  mesh.setCoords( transform(_item.center));
109
- tb.renderer.outputEncoding = THREE.sRGBEncoding;
110
- tb.add(mesh);
109
+ this.tb.renderer.outputEncoding = THREE.sRGBEncoding;
110
+ this.tb.add(mesh);
111
111
  let dom =document.createElement('div')
112
112
  mesh.addLabel(dom,true,{x:mesh.anchor.x,y:mesh.anchor.y+_item.distance *1200,z:mesh.anchor.z},0)
113
113
  mesh.label.element.className += ('' +this.textClass)
@@ -118,6 +118,8 @@ export default class AnimationLayer{
118
118
  setOpacity(opacity){
119
119
  this.opacity = opacity
120
120
  this.obj.model.material.opacity = this.opacity;
121
+ this.tb.update();
122
+ this.map.triggerRepaint();
121
123
  }
122
124
 
123
125
  pause(){
@@ -213,11 +215,12 @@ export default class AnimationLayer{
213
215
  if(this.timerId){
214
216
  clearInterval(this.timerId)
215
217
  }
218
+ this.remove()
216
219
  this.destory()
217
220
  }
218
221
  onAdd(map, gl) {
219
222
  this.map = map;
220
- tb = new Threebox(
223
+ this.tb = new Threebox(
221
224
  map,
222
225
  gl, //get the context from Mapbox
223
226
  { defaultLights: true ,passiveRendering:false}
@@ -225,7 +228,7 @@ export default class AnimationLayer{
225
228
  this.createInterval()
226
229
  }
227
230
  render(gl, matrix) {
228
- tb.update();
231
+ this.tb.update();
229
232
  this.map.triggerRepaint();
230
233
  }
231
234
  }
@@ -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
  // }