@eturnity/eturnity_3d 6.34.4 → 6.34.5

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_3d",
3
3
  "private": false,
4
- "version": "6.34.4",
4
+ "version": "6.34.5",
5
5
  "main": "dist/main.js",
6
6
  "scripts": {
7
7
  "dev": "vue-cli-service serve --skip-plugins @vue/cli-plugin-eslint",
@@ -19,6 +19,7 @@
19
19
  "geo-three": "^0.1.11",
20
20
  "leaflet": "^1.8.0",
21
21
  "leaflet.gridlayer.googlemutant": "^0.14.0",
22
+ "lodash": "4.17.21",
22
23
  "svd-js": "^1.1.1",
23
24
  "three": "^0.149.0",
24
25
  "three-projected-material": "2.2.1",
@@ -9,6 +9,7 @@ import {
9
9
  tileToCorners
10
10
  } from '@eturnity/eturnity_maths'
11
11
  import { earthRadius } from '../../config'
12
+ import { debounce } from 'lodash'
12
13
 
13
14
  import { cancellablePromise } from '../../utils/cancellablePromise'
14
15
 
@@ -19,6 +20,9 @@ export default {
19
20
  }
20
21
  },
21
22
  methods: {
23
+ debouncedRenderTiles: debounce(function () {
24
+ this.renderTiles()
25
+ }, 1000),
22
26
  async renderTiles() {
23
27
  if (
24
28
  !this.selectedMapLayer ||
@@ -254,6 +258,7 @@ export default {
254
258
  googleMapType = 'terrain'
255
259
  break
256
260
  }
261
+ let size = 640
257
262
  let roofsBoundZoomLvl = 19
258
263
  let { xMin, xMax, yMin, yMax } = this.roofsBounds
259
264
  if (xMin == Infinity) {
@@ -261,14 +266,26 @@ export default {
261
266
  yMin = 0
262
267
  xMax = 0
263
268
  yMax = 0
269
+ } else {
270
+ let roofBoundSizeInMeter = Math.max(xMax - xMin, yMax - yMin) / 1000
271
+
272
+ let exactZoomLvl = Math.log2(
273
+ (Math.cos((this.layoutSettings.layout_latitude * Math.PI) / 180) *
274
+ 2 *
275
+ Math.PI *
276
+ earthRadius *
277
+ size) /
278
+ (256 * roofBoundSizeInMeter)
279
+ )
280
+ roofsBoundZoomLvl = Math.min(roofsBoundZoomLvl, parseInt(exactZoomLvl))
264
281
  }
265
282
  let roofsBoundCenterMeter = {
266
283
  x: (xMax + xMin) / 2000,
267
284
  y: (yMax + yMin) / 2000
268
285
  }
269
286
  let deltaLatLng = distanceToDeltaLatLng(
270
- roofsBoundCenterMeter.x*1000,
271
- roofsBoundCenterMeter.y*1000,
287
+ roofsBoundCenterMeter.x * 1000,
288
+ roofsBoundCenterMeter.y * 1000,
272
289
  this.layoutSettings.layout_latitude
273
290
  )
274
291
  let roofsBoundCenterLatLng = {
@@ -278,7 +295,7 @@ export default {
278
295
 
279
296
  let apiKey = process.env.VUE_APP_GOOGLE_MAP_API_KEY
280
297
  let backgroundPlane = []
281
- let size = 640
298
+
282
299
  let planeGeometry = []
283
300
  let planeMaterial = []
284
301
  let texture = []
@@ -299,8 +316,8 @@ export default {
299
316
  2 *
300
317
  Math.PI *
301
318
  earthRadius) /
302
- ( Math.pow(2, zoomLevel))
303
- let sizeInMeter = groundResolution * size / 256
319
+ (256 * Math.pow(2, zoomLevel))
320
+ let sizeInMeter = groundResolution * size
304
321
  planeGeometry[indexGoogleBackground] = new THREE.PlaneGeometry(
305
322
  sizeInMeter,
306
323
  sizeInMeter * 0.9
@@ -349,83 +366,7 @@ export default {
349
366
  backgroundPlane[indexGoogleBackground].position.z =
350
367
  -indexGoogleBackground / 2
351
368
  this.backgroundMap.add(backgroundPlane[indexGoogleBackground])
352
- }
353
- this.scene.add(this.backgroundMap)
354
- },
355
- async renderGoogleTilesCenter() {
356
- this.clearByType('tileMeshes')
357
- if (this.backgroundMap) {
358
- this.backgroundMap.clear()
359
- this.scene.remove(this.backgroundMap)
360
- this.clearThreeObjects(this.backgroundMap)
361
- }
362
- this.backgroundMap = new THREE.Group()
363
-
364
- let googleMapType = 'satellite'
365
- switch (this.selectedMapLayer.key) {
366
- case 'googleLayerRoadmap':
367
- googleMapType = 'roadmap'
368
- break
369
- case 'googleLayer':
370
- googleMapType = 'satellite'
371
- break
372
- case 'googleLayerTerrain':
373
- googleMapType = 'terrain'
374
- break
375
- }
376
-
377
- let apiKey = process.env.VUE_APP_GOOGLE_MAP_API_KEY
378
- let backgroundPlane = []
379
- let size = 640
380
- let planeGeometry = []
381
- let planeMaterial = []
382
- let texture = []
383
- let zoomLevels = [19, 16]
384
-
385
- for (
386
- let indexGoogleBackground = 0;
387
- indexGoogleBackground < zoomLevels.length;
388
- indexGoogleBackground++
389
- ) {
390
- let zoomLevel = zoomLevels[indexGoogleBackground]
391
- let groundResolution =
392
- (Math.cos((this.layoutSettings.layout_latitude * Math.PI) / 180) *
393
- 2 *
394
- Math.PI *
395
- earthRadius) /
396
- (256 * Math.pow(2, zoomLevel))
397
- let sizeInMeter = groundResolution * size
398
- planeGeometry[indexGoogleBackground] = new THREE.PlaneGeometry(
399
- sizeInMeter,
400
- sizeInMeter
401
- )
402
- let googleBackgroundUrl = `https://maps.googleapis.com/maps/api/staticmap?center=${
403
- this.layoutSettings.layout_latitude +
404
- ',' +
405
- this.layoutSettings.layout_longitude
406
- }&maptype=${googleMapType}&zoom=${zoomLevel}&size=${size}x${size}&key=${apiKey}`
407
-
408
- texture[indexGoogleBackground] = await this.loader.load(
409
- googleBackgroundUrl
410
- )
411
- if (indexGoogleBackground == 0) {
412
- this.newGoogleTileMaterial(
413
- texture[indexGoogleBackground],
414
- sizeInMeter,
415
- googleMapType
416
- )
417
- }
418
- planeMaterial[indexGoogleBackground] = new THREE.MeshBasicMaterial({
419
- map: texture[indexGoogleBackground],
420
- side: THREE.DoubleSide
421
- })
422
- backgroundPlane[indexGoogleBackground] = new THREE.Mesh(
423
- planeGeometry[indexGoogleBackground],
424
- planeMaterial[indexGoogleBackground]
425
- )
426
- backgroundPlane[indexGoogleBackground].position.z =
427
- -indexGoogleBackground / 2
428
- this.backgroundMap.add(backgroundPlane[indexGoogleBackground])
369
+ backgroundPlane[indexGoogleBackground].needsUpdate = true
429
370
  }
430
371
  this.scene.add(this.backgroundMap)
431
372
  }
@@ -193,6 +193,11 @@ export default {
193
193
  })
194
194
  break
195
195
  case 'changeMapProjection':
196
+ methodList.push({
197
+ name: 'renderTiles',
198
+ method: this.debouncedRenderTiles,
199
+ arg: []
200
+ })
196
201
  methodList.push({
197
202
  name: 'changeMapProjection',
198
203
  method: this.changeMapProjection,
@@ -203,11 +208,6 @@ export default {
203
208
  method: this.applyTextureOnRoofs,
204
209
  arg: []
205
210
  })
206
- methodList.push({
207
- name: 'renderTiles',
208
- method: this.renderTiles,
209
- arg: []
210
- })
211
211
  break
212
212
  // methodList.push({
213
213
  // name: 'removeImageOverlay',
@@ -55,8 +55,8 @@ export default {
55
55
  // const helper = new THREE.CameraHelper( this.cameraProjection );
56
56
  // this.scene.add( helper );
57
57
 
58
- // const axesHelper = new THREE.AxesHelper( 20 );
59
- // this.scene.add( axesHelper );
58
+ const axesHelper = new THREE.AxesHelper( 20 );
59
+ this.scene.add( axesHelper );
60
60
  //Light
61
61
  const ambientLight = new THREE.AmbientLight(0xf0f0f0, 0.5)
62
62
  this.scene.add(ambientLight)