@eturnity/eturnity_3d 7.20.1 → 7.24.0

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.
Files changed (41) hide show
  1. package/package.json +2 -2
  2. package/src/EventManager/EventManager.js +48 -0
  3. package/src/Item/Item.js +12 -0
  4. package/src/Layer/Layer.js +119 -0
  5. package/src/Overlay/AirTeamOverlay.js +605 -0
  6. package/src/Overlay/ImageOverlay.js +309 -0
  7. package/src/Overlay/Overlay.js +255 -0
  8. package/src/Overlay/OverlayFactory.js +19 -0
  9. package/src/Overlay/OverlayLayer.js +36 -0
  10. package/src/components/ThreeCanvasViewer.vue +17 -6
  11. package/src/config.js +120 -17
  12. package/src/helper/UpdateRoofModuleFieldRelations.js +65 -25
  13. package/src/helper/cameraMixin.js +25 -0
  14. package/src/helper/materialMixin.js +14 -1
  15. package/src/helper/projectedMaterial.js +662 -0
  16. package/src/helper/render/base.js +5 -5
  17. package/src/helper/render/clear.js +0 -17
  18. package/src/helper/render/edge.js +2 -0
  19. package/src/helper/render/geometryHandler.js +60 -31
  20. package/src/helper/render/imageOverlay.js +25 -144
  21. package/src/helper/render/index.js +2 -0
  22. package/src/helper/render/mergedGeometry.js +11 -2
  23. package/src/helper/render/obstacle.js +2 -1
  24. package/src/helper/render/overlay.js +41 -0
  25. package/src/helper/render/projectionMaterial.js +17 -19
  26. package/src/helper/render/roof.js +49 -52
  27. package/src/helper/render/texture.js +25 -0
  28. package/src/helper/render/tile.js +84 -24
  29. package/src/helper/render/tileProjection.js +23 -14
  30. package/src/helper/renderMixin.js +22 -8
  31. package/src/helper/threeMixin.js +5 -2
  32. package/src/store/hydrateData.js +23 -11
  33. package/src/store/nodesEdgesCreation.js +78 -4
  34. package/src/store/three-d-module.js +1 -1
  35. package/dist/css/app.58568098.css +0 -1
  36. package/dist/img/reneSola_Virtus_2_JC320S_24_Bbw.85a0cb6d.png +0 -0
  37. package/dist/index.html +0 -15
  38. package/dist/js/app-legacy.aa792c98.js +0 -2
  39. package/dist/js/app-legacy.aa792c98.js.map +0 -1
  40. package/dist/js/chunk-vendors-legacy.9bb3863d.js +0 -41
  41. package/dist/js/chunk-vendors-legacy.9bb3863d.js.map +0 -1
@@ -16,25 +16,23 @@ export default {
16
16
  methods: {
17
17
  updateRoofGeometry(geometry, roofPolygon) {
18
18
  const roofOutline = roofPolygon.outline
19
- let cropedHolesOutline = roofPolygon.holes
20
- .filter((h) => h.layer == 'obstacle')
21
- .map((h) => {
22
- //let's crop obstacle with roof outline
23
- const cropedHoleOutline =
24
- intersectOutlines(h.outline, roofPolygon.outline)[0] || []
25
- const outline = cropedHoleOutline.map((p) => {
26
- return {
27
- x: p.x,
28
- y: p.y,
29
- z: verticalProjectionOnPlane(
30
- p,
31
- roofPolygon.normalVector,
32
- roofPolygon.flatOutline[0]
33
- ).z
34
- }
35
- })
36
- return outline
19
+ let cropedHolesOutline = roofPolygon.holes.map((h) => {
20
+ //let's crop obstacle with roof outline
21
+ const cropedHoleOutline =
22
+ intersectOutlines(h.outline, roofPolygon.outline)[0] || []
23
+ const outline = cropedHoleOutline.map((p) => {
24
+ return {
25
+ x: p.x,
26
+ y: p.y,
27
+ z: verticalProjectionOnPlane(
28
+ p,
29
+ roofPolygon.normalVector,
30
+ roofPolygon.flatOutline[0]
31
+ ).z
32
+ }
37
33
  })
34
+ return outline
35
+ })
38
36
 
39
37
  cropedHolesOutline = cropedHolesOutline.filter((outline) => !!outline)
40
38
  geometry = updateBufferRoofGeometry(
@@ -47,25 +45,23 @@ export default {
47
45
  },
48
46
  createRoofGeometry(roofPolygon) {
49
47
  const roofOutline = roofPolygon.outline
50
- let cropedHolesOutline = roofPolygon.holes
51
- .filter((h) => h.layer == 'obstacle')
52
- .map((h) => {
53
- //let's crop obstacle with roof outline
54
- const cropedHoleOutline =
55
- intersectOutlines(h.outline, roofPolygon.outline)[0] || []
56
- const outline = cropedHoleOutline.map((p) => {
57
- return {
58
- x: p.x,
59
- y: p.y,
60
- z: verticalProjectionOnPlane(
61
- p,
62
- roofPolygon.normalVector,
63
- roofPolygon.flatOutline[0]
64
- ).z
65
- }
66
- })
67
- return outline
48
+ let cropedHolesOutline = roofPolygon.holes.map((h) => {
49
+ //let's crop obstacle with roof outline
50
+ const cropedHoleOutline =
51
+ intersectOutlines(h.outline, roofPolygon.outline)[0] || []
52
+ const outline = cropedHoleOutline.map((p) => {
53
+ return {
54
+ x: p.x,
55
+ y: p.y,
56
+ z: verticalProjectionOnPlane(
57
+ p,
58
+ roofPolygon.normalVector,
59
+ roofPolygon.flatOutline[0]
60
+ ).z
61
+ }
68
62
  })
63
+ return outline
64
+ })
69
65
 
70
66
  cropedHolesOutline = cropedHolesOutline.filter((outline) => !!outline)
71
67
  let geometry = getBufferRoofGeometry(roofOutline, cropedHolesOutline)
@@ -74,17 +70,22 @@ export default {
74
70
  },
75
71
 
76
72
  applyTextureOnRoofs() {
77
- const material = this.material.roof
78
73
  this.reorderRoofMaterials()
79
- if (this.mergedRoofMesh) {
80
- this.applyTextureOnMesh(material, this.mergedRoofMesh)
81
- this.render()
82
- }
74
+ const material = this.material.roof
75
+ this.roofs.forEach((roof) => {
76
+ const roofMesh = this.meshes.roofMeshes[roof.id]
77
+ if (roofMesh) {
78
+ this.applyTextureOnMesh(material, roofMesh)
79
+ }
80
+ })
81
+ this.render()
83
82
  },
84
83
  renderRoofs() {
85
84
  this.clearRemovedOnes('roofMeshes')
86
- let roofGeometries = []
87
85
  this.roofs.forEach((roofPolygon) => {
86
+ const material = roofPolygon.isFlat
87
+ ? this.material.roof
88
+ : this.material.warningRoof
88
89
  let mesh
89
90
  let geometry
90
91
  if (
@@ -107,25 +108,21 @@ export default {
107
108
  geometry = this.createRoofGeometry(roofPolygon)
108
109
  if (geometry) {
109
110
  //material not used here.
110
- mesh = new THREE.Mesh(geometry, this.material.hidden)
111
+ mesh = new THREE.Mesh(geometry, material)
111
112
  mesh.userData.version = roofPolygon.version
112
113
  mesh.userData.type = 'roofMeshes'
113
114
  mesh.userData.meshId = roofPolygon.id
114
115
  mesh.userData.polygonId = roofPolygon.id
116
+ mesh.frustumCulled = false
115
117
  this.meshes.roofMeshes[roofPolygon.id] = mesh
116
118
  this.scene.add(mesh)
117
119
  }
118
120
  }
119
- roofGeometries.push(this.meshes.roofMeshes[roofPolygon.id].geometry)
121
+ //roofGeometries.push(this.meshes.roofMeshes[roofPolygon.id].geometry)
122
+ if (mesh) {
123
+ this.applyTextureOnMesh(material, mesh)
124
+ }
120
125
  })
121
- // Create the mesh using the merged geometry and shared material
122
- this.mergedRoofMesh = this.updateOrCreateMergedMesh(
123
- this.mergedRoofMesh,
124
- roofGeometries,
125
- this.material.roof
126
- )
127
- this.mergedRoofMesh.userData.type = 'mergedRoofMesh'
128
- this.applyTextureOnMesh(this.material.roof, this.mergedRoofMesh)
129
126
  },
130
127
  renderFlatRoofs() {
131
128
  this.clearRemovedOnes('flatRoofMeshes')
@@ -2,6 +2,24 @@ export default {
2
2
  methods: {
3
3
  applyTextureOnMesh(materials, mesh) {
4
4
  if (mesh && materials && materials.length > 0) {
5
+ const materialsVersionsOnMesh = mesh.userData.materialsVersions
6
+ if (materialsVersionsOnMesh) {
7
+ const materialUuids = materials.map((m) => m.uuid)
8
+ const materialVersions = materials.map((m) => m.userData.version)
9
+ const allMaterialAlreadyProjectedOnMesh =
10
+ materials.length == materialsVersionsOnMesh.length &&
11
+ materialsVersionsOnMesh.every((versionMaterial, index) => {
12
+ return (
13
+ materialUuids[index] == versionMaterial.uuid &&
14
+ materialVersions[index] == versionMaterial.materialVersion &&
15
+ mesh.geometry.userData.version ==
16
+ versionMaterial.geometryVersion
17
+ )
18
+ })
19
+ if (allMaterialAlreadyProjectedOnMesh) {
20
+ return
21
+ }
22
+ }
5
23
  let geometry = mesh.geometry
6
24
  geometry.clearGroups()
7
25
  for (let k = 0; k < materials.length; k++) {
@@ -15,6 +33,13 @@ export default {
15
33
  }
16
34
  materials[m].needsUpdate = true
17
35
  }
36
+ mesh.userData.materialsVersions = materials.map((m) => {
37
+ return {
38
+ uuid: m.uuid,
39
+ materialVersion: m.userData.version,
40
+ geometryVersion: mesh.geometry.userData.version
41
+ }
42
+ })
18
43
  mesh.needsUpdate = true
19
44
  }
20
45
  }
@@ -64,7 +64,7 @@ export default {
64
64
  this.scene.remove(this.googleBackgroundMap)
65
65
  this.clearThreeObjects(this.googleBackgroundMap)
66
66
  }
67
-
67
+ let providerMapLayer = this.provider.mapLayer
68
68
  let zoomLvl = this.provider.maxZoom
69
69
 
70
70
  const latitude = this.layoutSettings.layout_latitude
@@ -115,6 +115,16 @@ export default {
115
115
  for (let xTile = xTileMin; xTile <= xTileMax; xTile++) {
116
116
  for (let yTile = yTileMin; yTile <= yTileMax; yTile++) {
117
117
  this.tileToRender.push({
118
+ materialId:
119
+ 'material_' +
120
+ xTile +
121
+ '_' +
122
+ yTile +
123
+ '_' +
124
+ zoomLvl +
125
+ '_' +
126
+ providerMapLayer,
127
+ id: 'tile_' + xTile + '_' + yTile + '_' + zoomLvl,
118
128
  xTile,
119
129
  yTile,
120
130
  zoomLvl,
@@ -122,7 +132,6 @@ export default {
122
132
  })
123
133
  }
124
134
  }
125
-
126
135
  while (zoomLvl > 17) {
127
136
  xTileMin = xTileMin / 2 - 1
128
137
  xTileMax = (xTileMax + 1) / 2
@@ -147,6 +156,16 @@ export default {
147
156
  yTileMax - yTile <= yMaxEven
148
157
  ) {
149
158
  this.tileToRender.push({
159
+ materialId:
160
+ 'material_' +
161
+ xTile +
162
+ '_' +
163
+ yTile +
164
+ '_' +
165
+ zoomLvl +
166
+ '_' +
167
+ providerMapLayer,
168
+ id: 'tile_' + xTile + '_' + yTile + '_' + zoomLvl,
150
169
  xTile,
151
170
  yTile,
152
171
  zoomLvl,
@@ -158,13 +177,38 @@ export default {
158
177
  }
159
178
  this.numberOfTilesToRender = this.tileToRender.length
160
179
  this.numberOfTilesRendered = 0
180
+
181
+ this.removeUnusedTiles()
182
+ const promiseArray = []
161
183
  for (let k in this.tileToRender) {
162
184
  let xTile = this.tileToRender[k].xTile
163
185
  let yTile = this.tileToRender[k].yTile
164
186
  zoomLvl = this.tileToRender[k].zoomLvl
165
187
  let isTileOnRoofBound = this.tileToRender[k].isTileOnRoofBound
166
- this.renderTile(xTile, yTile, zoomLvl, isTileOnRoofBound)
188
+ promiseArray.push(
189
+ this.renderTile(xTile, yTile, zoomLvl, isTileOnRoofBound)
190
+ )
167
191
  }
192
+ Promise.all(promiseArray).then((res) => {
193
+ const tileToRenderOverRoof = this.tileToRender.filter(
194
+ (tile) => tile.isTileOnRoofBound
195
+ )
196
+ const tileToRenderOverRoofMaterialIds = tileToRenderOverRoof.map(
197
+ (tile) => tile.materialId
198
+ )
199
+ this.material.roof = this.material.roof.filter(
200
+ (m) => m.userData.type != 'tileProjectionMaterial'
201
+ )
202
+ this.material.roof.push(
203
+ ...this.material.projectionTiles.filter((material) => {
204
+ let materialId = material.userData.materialId
205
+ return tileToRenderOverRoofMaterialIds.includes(materialId)
206
+ })
207
+ )
208
+ this.applyTextureOnRoofs()
209
+ this.applyTextureOnObstacles()
210
+ this.render()
211
+ })
168
212
  },
169
213
  removeTileFromPending(meshId, mapLayer) {
170
214
  this.pendingTiles = this.pendingTiles.filter(
@@ -172,18 +216,21 @@ export default {
172
216
  )
173
217
  },
174
218
  async renderTile(x, y, zoomLvl, isTileOnRoofBound = false) {
175
- const meshId = 'tile_' + x + '_' + y + '_' + zoomLvl
176
- const mapLayer = this.provider.mapLayer
177
- if (
178
- this.pendingTiles.find(
179
- (t) => t.meshId == meshId && t.mapLayer == mapLayer
180
- )
181
- ) {
182
- return
183
- }
219
+ const promise = new Promise((resolve, reject) => {
220
+ const meshId = 'tile_' + x + '_' + y + '_' + zoomLvl
221
+ const mapLayer = this.provider.mapLayer
222
+ if (
223
+ this.pendingTiles.find(
224
+ (t) => t.meshId == meshId && t.mapLayer == mapLayer
225
+ )
226
+ ) {
227
+ resolve()
228
+ return
229
+ }
184
230
 
185
231
  let mesh = this.meshes.tileMeshes[meshId]
186
232
  if (mesh && this.provider.mapLayer == mesh.userData.mapLayer) {
233
+ resolve()
187
234
  return
188
235
  }
189
236
 
@@ -194,9 +241,12 @@ export default {
194
241
  this.provider.fetchTile(zoomLvl, x, y)
195
242
  )
196
243
  this.pendingTiles.push({ x, y, zoomLvl, mapLayer, meshId, imagePromise })
244
+ this.isReady.texturesToLoad++
197
245
  imagePromise.then((image) => {
246
+ this.isReady.texturesLoaded++
198
247
  if (!image) {
199
248
  this.removeTileFromPending(meshId, mapLayer)
249
+ resolve()
200
250
  return
201
251
  }
202
252
  const texture = new THREE.Texture(image)
@@ -228,7 +278,9 @@ export default {
228
278
  map: texture,
229
279
  color: 0xffffff,
230
280
  side: THREE.FrontSide,
231
- transparent: true
281
+ transparent: false,
282
+ // opacity:isTileOnRoofBound?0.8:1,
283
+ // color:isTileOnRoofBound?'red':'white'
232
284
  })
233
285
  material.map = texture
234
286
  material.needsUpdate = true
@@ -240,19 +292,25 @@ export default {
240
292
  mesh.userData.mapLayer = this.provider.mapLayer
241
293
  mesh.name = meshId
242
294
 
243
- if (!this.scene.getObjectByName(meshId)) {
244
- this.meshes.tileMeshes[meshId] = mesh
245
- this.scene.add(this.meshes.tileMeshes[meshId])
295
+ if (!this.scene.getObjectByName(meshId)) {
296
+ this.meshes.tileMeshes[meshId] = mesh
297
+ this.scene.add(this.meshes.tileMeshes[meshId])
298
+ }
299
+ }
246
300
  }
247
- }
248
- }
249
- this.removeTileFromPending(meshId, mapLayer)
250
- this.numberOfTilesRendered++
251
- if (this.numberOfTilesRendered == this.numberOfTilesToRender) {
252
- this.removeUnusedTiles()
253
- this.render()
254
- }
301
+ this.removeTileFromPending(meshId, mapLayer)
302
+ this.numberOfTilesRendered++
303
+ if (this.numberOfTilesRendered == this.numberOfTilesToRender) {
304
+ this.removeUnusedTiles()
305
+ this.render()
306
+ }
307
+ resolve()
308
+ })
309
+ .catch((err) => {
310
+ reject()
311
+ })
255
312
  })
313
+ return promise
256
314
  },
257
315
  async renderGoogleTiles() {
258
316
  this.clearByType('tileMeshes')
@@ -354,7 +412,9 @@ export default {
354
412
  let googleBackgroundUrl = `https://maps.googleapis.com/maps/api/staticmap?center=${
355
413
  roofsBoundCenterLatLng.lat + ',' + roofsBoundCenterLatLng.lng
356
414
  }&maptype=${googleMapType}&zoom=${zoomLevel}&size=${size}x${size}&key=${apiKey}`
415
+ this.isReady.texturesToLoad++
357
416
  this.loader.load(googleBackgroundUrl, (texture) => {
417
+ this.isReady.texturesLoaded++
358
418
  texture[indexGoogleBackground] = texture
359
419
  if (indexGoogleBackground == 0) {
360
420
  this.newGoogleTileMaterial(
@@ -1,5 +1,5 @@
1
1
  import * as THREE from 'three'
2
- import ProjectedMaterial from 'three-projected-material'
2
+ import ProjectedMaterial from '../projectedMaterial'
3
3
  import { tileToCorners } from '@eturnity/eturnity_maths'
4
4
  import { earthRadius } from '../../config'
5
5
  export default {
@@ -28,8 +28,10 @@ export default {
28
28
  transparent: true,
29
29
  side: THREE.DoubleSide
30
30
  })
31
+ tileProjectionMaterial.camera = cameraProjection
31
32
  tileProjectionMaterial.userData = {}
32
33
  tileProjectionMaterial.userData.type = 'tileProjectionMaterial'
34
+ tileProjectionMaterial.userData.version = 0
33
35
  tileProjectionMaterial.userData.materialId =
34
36
  'material_' +
35
37
  sizeInMeter +
@@ -41,9 +43,14 @@ export default {
41
43
  mapLayer
42
44
  tileProjectionMaterial.userData.mapLayer = mapLayer
43
45
  tileProjectionMaterial.userData.priority = 10
46
+ this.material.projectionTiles.push(tileProjectionMaterial)
47
+ this.material.roof = this.material.roof.filter(
48
+ (m) => m.userData.type != 'tileProjectionMaterial'
49
+ )
44
50
  this.material.roof.push(tileProjectionMaterial)
45
51
  this.applyTextureOnRoofs()
46
52
  this.applyTextureOnObstacles()
53
+ this.render()
47
54
  },
48
55
  async newTileMaterial(texture, x, y, zoom, mapLayer) {
49
56
  if (!this.material.roof) {
@@ -65,33 +72,35 @@ export default {
65
72
  transparent: true,
66
73
  side: THREE.DoubleSide
67
74
  })
75
+ tileProjectionMaterial.camera = cameraProjection
68
76
  tileProjectionMaterial.userData = {}
69
77
  tileProjectionMaterial.userData.type = 'tileProjectionMaterial'
78
+ tileProjectionMaterial.userData.version = 0
70
79
  tileProjectionMaterial.userData.materialId =
71
80
  'material_' + x + '_' + y + '_' + zoom + '_' + mapLayer
72
81
  tileProjectionMaterial.userData.mapLayer = mapLayer
73
82
  tileProjectionMaterial.priority = 10
74
83
  this.setTileCameraPosition(cameraProjection, x, y, zoom)
75
- this.material.roof.push(tileProjectionMaterial)
76
- this.applyTextureOnRoofs()
77
- this.applyTextureOnObstacles()
84
+ this.material.projectionTiles.push(tileProjectionMaterial)
78
85
  },
79
86
  disposeTileMaterial(material) {
80
87
  material.texture.dispose()
81
88
  material.dispose()
82
89
  },
83
90
  disposeTileMaterialDifferentMapLayer(mapLayer) {
84
- if (!this.material.roof) return
85
- this.material.roof = this.material.roof.filter((m) => {
86
- if (
87
- m.userData.type == 'tileProjectionMaterial' &&
88
- m.userData.mapLayer != mapLayer
89
- ) {
90
- this.disposeTileMaterial(m)
91
- return false
91
+ if (!this.material.projectionTiles) return
92
+ this.material.projectionTiles = this.material.projectionTiles.filter(
93
+ (m) => {
94
+ if (
95
+ m.userData.type == 'tileProjectionMaterial' &&
96
+ m.userData.mapLayer != mapLayer
97
+ ) {
98
+ this.disposeTileMaterial(m)
99
+ return false
100
+ }
101
+ return true
92
102
  }
93
- return true
94
- })
103
+ )
95
104
  },
96
105
  setTileCameraPosition(camera, x, y, zoom) {
97
106
  const latitude = this.layoutSettings.layout_latitude
@@ -24,7 +24,8 @@ export default {
24
24
  edgeMeshes: {},
25
25
  roofMarginMeshes: {},
26
26
  moduleFieldsMeshes: {},
27
- tileMeshes: {}
27
+ tileMeshes: {},
28
+ overlayMeshes: {}
28
29
  }
29
30
  },
30
31
  mounted() {
@@ -145,6 +146,13 @@ export default {
145
146
  arg: []
146
147
  })
147
148
  break
149
+ case 'setCameraToOverlay':
150
+ methodList.push({
151
+ name: 'setCameraToOverlay',
152
+ method: this.setCameraToOverlay,
153
+ arg: [params.overlayId]
154
+ })
155
+ break
148
156
  case 'toolChange': //params.toolName
149
157
  methodList.push({
150
158
  name: 'renderEdges',
@@ -162,6 +170,12 @@ export default {
162
170
  break
163
171
  case 'full':
164
172
  case 'reset':
173
+ case 'changeOverlays':
174
+ methodList.push({
175
+ name: 'renderOverlays',
176
+ method: this.renderOverlays,
177
+ arg: []
178
+ })
165
179
  case 'removeNodes': //params.nodes
166
180
  case 'removeEdges': //params.edges
167
181
  case 'translate': //params.edges
@@ -298,7 +312,6 @@ export default {
298
312
  method: this.renderRoofsMargin,
299
313
  arg: []
300
314
  })
301
- break
302
315
  case 'selectedModuleFieldChange':
303
316
  methodList.push({
304
317
  name: 'renderEdges',
@@ -381,12 +394,10 @@ export default {
381
394
  method: this.updateProjectionMaterials,
382
395
  arg: []
383
396
  })
384
- break
385
- case 'clearPanelFromChangingRoofs':
386
397
  methodList.push({
387
- name: 'clearPanelsFromChangingRoofs',
388
- method: this.clearPanelsFromChangingRoofs,
389
- arg: [params.roofIds]
398
+ name: 'renderOverlays',
399
+ method: this.renderOverlays,
400
+ arg: []
390
401
  })
391
402
  break
392
403
  case 'selectedPanelChange':
@@ -409,7 +420,11 @@ export default {
409
420
  async renderMethods(methodList) {
410
421
  for (let item of methodList) {
411
422
  if (item.method) {
423
+ try{
412
424
  await item.method(...item.arg)
425
+ }catch(err){
426
+ console.error(err)
427
+ }
413
428
  }
414
429
  }
415
430
  this.render()
@@ -472,7 +487,6 @@ export default {
472
487
  }
473
488
  },
474
489
  beforeDestroy() {
475
- this.clearThreeObjects(this.scene)
476
490
  if (this.renderer) {
477
491
  this.renderer.clear()
478
492
  this.renderer.dispose()
@@ -74,6 +74,7 @@ export default {
74
74
  this.renderer.domElement.style.height = height + 'px'
75
75
  this.renderer.setSize(width, height, false)
76
76
  this.renderer.setViewport(0, 0, width, height)
77
+ // this.renderer.gammaOutput = true
77
78
  }
78
79
  },
79
80
  initialiseControl(isPerspectiveCamera) {
@@ -177,8 +178,10 @@ export default {
177
178
  if (this.composer) {
178
179
  this.composer.render()
179
180
  } else if (this.renderer) {
180
- this.renderer.clear()
181
- this.renderer.render(this.scene, this.camera)
181
+ try {
182
+ this.renderer.clear()
183
+ this.renderer.render(this.scene, this.camera)
184
+ } catch (err) {}
182
185
  }
183
186
  },
184
187
  orbitControlChange() {
@@ -5,6 +5,7 @@ import {
5
5
  getRoofMarginOutline,
6
6
  getObstacleMarginOutline
7
7
  } from '@eturnity/eturnity_maths'
8
+ import OverlayLayer from '../Overlay/OverlayLayer'
8
9
  import getLayers from '../utils/layers'
9
10
  import { UpdateRoofObstacleRelations } from '../helper/UpdateRoofObstacleRelations'
10
11
  function sanitizedOutline(outline) {
@@ -25,9 +26,7 @@ function sanitizedOutline(outline) {
25
26
  export async function hydratePolygons({
26
27
  roofsResponse,
27
28
  obstaclesResponse,
28
- moduleFieldsResponse,
29
- projectId,
30
- projectVariantId
29
+ moduleFieldsResponse
31
30
  }) {
32
31
  //removing empty roof,obstacle and modulefield generated by BE on variant creation
33
32
  roofsResponse = roofsResponse.reduce((acc, cur) => {
@@ -80,8 +79,12 @@ export async function hydratePolygons({
80
79
  ? roofResp.roof_margins_mm[0]
81
80
  : 200
82
81
  roof.moduleFields = []
82
+ try{
83
83
  roof = updateComputedGeometryPolygon(roof)
84
84
  roofs.push(roof)
85
+ }catch(err){
86
+ console.error(err)
87
+ }
85
88
  })
86
89
  obstaclesResponse.forEach((obstacleResp) => {
87
90
  const obstacle_outline = obstacleResp.obstacle_outline.map((p) => {
@@ -92,6 +95,7 @@ export async function hydratePolygons({
92
95
  obstacle.version = obstacleResp.version
93
96
  obstacle.height = obstacleResp.obstacle_height_above_ground_mm
94
97
  obstacle.isParallel = obstacleResp.obstacle_slope_is_parallel_to_roof
98
+ try{
95
99
  obstacle = updateComputedGeometryPolygon(obstacle)
96
100
  obstacle.margins.distances = obstacleResp.obstacle_margins_mm
97
101
  obstacle.margins.isSameMargin = obstacleResp.obstacle_margins_mm.every(
@@ -102,6 +106,9 @@ export async function hydratePolygons({
102
106
  : 200
103
107
  obstacle = getObstacleMarginOutline(obstacle)
104
108
  obstacles.push(obstacle)
109
+ }catch(err){
110
+ console.error(err)
111
+ }
105
112
  })
106
113
  moduleFieldsResponse.forEach((moduleFieldResp) => {
107
114
  const MFpanels = []
@@ -204,13 +211,16 @@ export async function hydratePolygons({
204
211
  moduleField.roof = roof
205
212
  moduleField.panels = MFpanels
206
213
  moduleField.userDeactivatedPanels = MFuserDeactivatedPanels
214
+ try{
207
215
  moduleField = updateComputedGeometryPolygon(moduleField)
208
216
  moduleFields.push(moduleField)
217
+ }catch(err){
218
+ console.error(err)
219
+ }
209
220
  })
210
221
  //Get PV & Mounting system component Data:
211
222
  pv_module_ids = [...new Set(pv_module_ids)]
212
223
  mounting_system_ids = [...new Set(mounting_system_ids)]
213
-
214
224
  return {
215
225
  polygons: [
216
226
  ...roofs,
@@ -229,19 +239,21 @@ export async function hydrateData({ state, commit }, data) {
229
239
  let obstaclesResponse = data.obstacles
230
240
  let moduleFieldsResponse = data.moduleFields
231
241
  const layoutSettingResponse = data.layoutSettings
232
- const imageOverlayResponse = data.imageOverlay
242
+ const overlaysResponse = data.layoutingOverlays
233
243
  const mapType = data.mapType
234
244
  let layers = getLayers()
235
245
  let selectedLayer = layers.find((layer) => layer.key == mapType)
236
246
  commit('mutate_selectedMapLayer', selectedLayer)
237
247
 
238
- if (imageOverlayResponse && imageOverlayResponse.image_overlay_url) {
239
- let imageOverlay = {
240
- url: imageOverlayResponse.image_overlay_url,
241
- uuid: imageOverlayResponse.image_overlay_uuid,
242
- corners: imageOverlayResponse.image_overlay_settings.corners
248
+ if (overlaysResponse) {
249
+ let origin
250
+ if (layoutSettingResponse) {
251
+ origin = {
252
+ lat: layoutSettingResponse.layout_latitude,
253
+ lng: layoutSettingResponse.layout_longitude
254
+ }
243
255
  }
244
- commit('mutate_imageOverlay', imageOverlay)
256
+ OverlayLayer.addOrUpdateSerializedItems(overlaysResponse, origin)
245
257
  }
246
258
  if (!!layoutSettingResponse) {
247
259
  const layoutSetting = layoutSettingResponse